*, *::before, *::after { 
    box-sizing: border-box;
    margin: 0;
    padding: 0; 
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #262730;
    color: #F5F5E0;
    line-height: 1.6;
    padding: 2rem 1rem;
}

.container {
    max-width: 900px;
    margin: 0 auto;
}

nav {
    margin-bottom: 3rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #A4969B;
}

nav a {
    color: #77BA99;
    text-decoration: none;
    margin-right: 1.5rem;
    font-size: 0.9rem;
    font-weight: 500;
}

nav a:hover, a:hover { 
    text-decoration: underline; 
}

h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

h2 {
    font-size: 1.25rem;
    font-weight: 500;
    margin-bottom: 1.5rem;
    color: #A4969B;
}

h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

p { 
    margin-bottom: 1rem;
}

a {
    color: #77BA99;
    text-decoration: none;
}

.subtitle {
    font-size: 1.1rem;
    color: #A4969B;
    margin-bottom: 2rem;
}

.intro {
    margin-bottom: 3rem;
}

.entry {
    margin-bottom: 2rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid #A4969B;
}

.entry:last-of-type { 
    border-bottom: none;
}

.meta {
    font-size: 0.85rem;
    color: #A4969B;
    margin-bottom: 0.5rem;
}

.meta a {
    color: #A4969B;
}

.meta a:hover {
    color: #77BA99;
}

footer {
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid #A4969B;
    font-size: 0.85rem;
    color: #A4969B;
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
}

footer a {
    color: #A4969B;
}

footer a:hover { 
    color: #77BA99; 
}

/* Wiki links */
.wikilink {
    color: #77BA99;
    font-weight: 500;
}

.wikilink.broken {
    color: #e57373;
    cursor: not-allowed;
}

/* Graph */
#graph, #mini-graph {
    background: #1e1f26;
    border-radius: 4px;
    margin-top: 1rem;
}

#mini-graph {
}

.graph-node {
    fill: #77BA99;
    stroke: #262730;
    stroke-width: 1.5px;
    cursor: pointer;
}

#graph {
    width: 100%;
    aspect-ratio: 1 / 1;
}

#mini-graph {
    width: 100%;
    aspect-ratio: 1 / 1;
}

.graph-node.tag-node {
    fill: #A4969B;
}

.graph-node.current-node {
    fill: #F5F5E0;
    stroke: #77BA99;
    stroke-width: 2px;
}

.graph-link {
    stroke: #A4969B;
    stroke-opacity: 0.3;
}

.graph-link.direct-link {
    stroke: #77BA99;
    stroke-opacity: 0.5;
}

.graph-label {
    fill: #F5F5E0;
    stroke: none;
    font-size: 10px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    pointer-events: none;
}

.graph-label.tag-label {
    fill: #A4969B;
}

/* Content styling */
article ul, article ol {
    margin-left: 1.5rem;
    margin-bottom: 1rem;
}

article li {
    margin-bottom: 0.5rem;
}

article hr {
    border: none;
    border-top: 1px solid #A4969B;
    margin: 2rem 0;
}

article code {
    background: #1e1f26;
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
    font-family: "SF Mono", Monaco, "Cascadia Code", monospace;
    font-size: 0.9em;
}

article pre {
    background: #1e1f26;
    padding: 1rem;
    border-radius: 4px;
    overflow-x: auto;
    margin-bottom: 1rem;
}

article pre code {
    background: none;
    padding: 0;
}

/* Chroma syntax highlighting — minimal dark theme */
.highlight {
    background: none;
}

.highlight pre {
    background: #1e1f26;
}

/* Base text */
.chroma {
    color: #F5F5E0;
}

/* Comments */
.chroma .c,
.chroma .ch,
.chroma .cm,
.chroma .cp,
.chroma .cpf,
.chroma .c1,
.chroma .cs,
.chroma .cd {
    color: #A4969B;
    font-style: italic;
}

/* Keywords */
.chroma .k,
.chroma .kc,
.chroma .kd,
.chroma .kn,
.chroma .kp,
.chroma .kr,
.chroma .kt {
    color: #77BA99;
}

/* Names / identifiers */
.chroma .n,
.chroma .na,
.chroma .nc,
.chroma .no,
.chroma .nd,
.chroma .ni,
.chroma .ne,
.chroma .nl,
.chroma .nn,
.chroma .py,
.chroma .nt,
.chroma .nv {
    color: #F5F5E0;
}

/* Function names */
.chroma .nf {
    color: #F5F5E0;
    font-weight: 500;
}

/* Builtin functions */
.chroma .nb {
    color: #A4969B;
}

/* Variables / parameters */
.chroma .nx {
    color: #F5F5E0;
}

/* Operators and punctuation */
.chroma .o,
.chroma .ow,
.chroma .p {
    color: #A4969B;
}

/* Strings */
.chroma .s,
.chroma .sb,
.chroma .sc,
.chroma .sd,
.chroma .s2,
.chroma .se,
.chroma .sh,
.chroma .si,
.chroma .sx,
.chroma .sr,
.chroma .s1,
.chroma .ss {
    color: #77BA99;
}

/* Numbers */
.chroma .m,
.chroma .mb,
.chroma .mf,
.chroma .mh,
.chroma .mi,
.chroma .il,
.chroma .mo {
    color: #A4969B;
}

/* Errors */
.chroma .err,
.chroma .gr,
.chroma .gt {
    color: #e57373;
}

/* Generic inserted/deleted */
.chroma .gi {
    color: #77BA99;
}
.chroma .gd {
    color: #e57373;
}

/* Line numbers */
.chroma .lnt,
.chroma .ln {
    color: #A4969B;
    margin-right: 0.75rem;
}

article blockquote {
    border-left: 3px solid #77BA99;
    padding-left: 1rem;
    margin-left: 0;
    color: #A4969B;
    margin-bottom: 1rem;
}

article table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1rem;
}

article th, article td {
    border: 1px solid #A4969B;
    padding: 0.5rem;
    text-align: left;
}

article th {
    background: #1e1f26;
}

/* Inline tag pills (dark cards, matching /tags/ grid) */
.meta a,
.entry .meta a {
    display: inline-block;
    padding: 0.15rem 0.45rem;
    background: #1e1f26;
    border-radius: 3px;
    font-size: 0.8rem;
    color: #F5F5E0;
    text-decoration: none;
    transition: all 0.2s;
    line-height: 1.3;
    margin-right: 0.35rem;
    margin-bottom: 0.25rem;
}

.meta a:hover,
.entry .meta a:hover {
    color: #77BA99;
    background: #262730;
    text-decoration: none;
}

/* Tag grid (3-column layout on /tags/) */
.tag-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
    margin-top: 1.5rem;
}

.tag-grid-item {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 0.5rem 0.6rem;
    border-radius: 3px;
    background: #1e1f26;
    text-decoration: none;
    color: #F5F5E0;
    transition: all 0.2s;
    font-size: 0.85rem;
}

.tag-grid-item:hover {
    color: #77BA99;
    background: #262730;
}

.tag-grid-item .name {
    font-weight: 500;
}

.tag-grid-item .count {
    font-size: 0.75rem;
    color: #A4969B;
    white-space: nowrap;
    margin-left: 0.5rem;
}

@media (max-width: 720px) {
    .tag-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .tag-grid {
        grid-template-columns: 1fr;
    }
}

/* Graph fullscreen overlay */
.graph-wrapper {
    position: relative;
}

article img {
    display: block;
    margin: 1.5rem auto;
    max-width: 100%;
    border-radius: 4px;
    border: 1px solid #1e1f26;
    transition: opacity 0.2s;
}

.img-link {
    display: block;
    text-decoration: none;
}

.img-link:hover img {
    opacity: 0.85;
}

.file-embed {
    color: #77BA99;
    text-decoration: underline;
    text-underline-offset: 0.2em;
    font-weight: 500;
}

.file-embed:hover {
    color: #F5F5E0;
}

/* Graph physics controls */
.graph-controls {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
}

.physics-control {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.75rem;
    color: #A4969B;
    flex-shrink: 0;
}

.physics-control input[type="range"] {
    width: 80px;
    accent-color: #77BA99;
}

.physics-control .val {
    font-variant-numeric: tabular-nums;
    width: 3ch;
    text-align: right;
}

.graph-expand-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.6rem;
    background: transparent;
    border: 1px solid #A4969B;
    border-radius: 3px;
    color: #A4969B;
    font-size: 0.8rem;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
}

.graph-expand-btn:hover {
    color: #77BA99;
    border-color: #77BA99;
}

#graph.expanded {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 100;
    border-radius: 0;
    margin: 0;
    background: #1e1f26;
}

.graph-wrapper:has(#graph.expanded) .graph-controls {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 101;
    margin: 0;
}

/* Post footer triple column */
.post-footer {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 2rem;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid #A4969B;
}

.post-footer-col h3 {
    font-size: 1rem;
    font-weight: 600;
    color: #A4969B;
    margin-bottom: 0.75rem;
}

.post-footer-col ul {
    margin-left: 0;
    list-style: none;
    padding-left: 0;
}

.post-footer-col li {
    margin-bottom: 0.35rem;
}

.post-footer-col a {
    color: #77BA99;
    text-decoration: none;
}

.post-footer-col a:hover {
    text-decoration: underline;
}

@media (max-width: 720px) {
    .post-footer {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
}

/* Search */
.search-container {
    margin-top: 1.5rem;
}

#search-input {
    width: 100%;
    padding: 0.6rem 0.8rem;
    font-size: 1rem;
    font-family: inherit;
    background: #1e1f26;
    border: 1px solid #A4969B;
    border-radius: 3px;
    color: #F5F5E0;
    outline: none;
    transition: border-color 0.2s;
}

#search-input:focus {
    border-color: #77BA99;
}

#search-input::placeholder {
    color: #A4969B;
    opacity: 0.7;
}

.search-status {
    margin-top: 0.75rem;
    font-size: 0.85rem;
    color: #A4969B;
    min-height: 1.2em;
}

.search-result {
    margin-top: 1.25rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid #A4969B;
}

.search-result:last-child {
    border-bottom: none;
}

.search-result h3 {
    margin-bottom: 0.25rem;
    font-size: 1.1rem;
}

.search-result h3 a {
    color: #77BA99;
    text-decoration: none;
}

.search-result h3 a:hover {
    text-decoration: underline;
}

.search-result .meta {
    font-size: 0.8rem;
    color: #A4969B;
    margin-bottom: 0.5rem;
}

.search-result p {
    margin-bottom: 0.25rem;
    color: #F5F5E0;
}

@media (max-width: 480px) {
    body { 
        padding: 1.5rem 1rem; 
    }
    h1 { 
        font-size: 1.5rem; 
    }
    nav a { 
        margin-right: 1rem;
        font-size: 0.85rem;
        display: inline-block;
        margin-bottom: 0.5rem; 
    }
}

/* Scrollspy TOC sidebar — overlay */
body.has-toc .container {
    max-width: 900px;
}

body.has-toc {
    scrollbar-width: none;
    -ms-overflow-style: none;
}

body.has-toc::-webkit-scrollbar {
    display: none;
}

.post-layout {
    display: block;
}

.toc-sidebar {
    position: fixed;
    top: 0;
    right: 0;
    width: 250px;
    height: 100vh;
    background: rgba(38, 39, 48, 0.92);
    backdrop-filter: blur(4px);
    border-left: 1px solid #A4969B;
    display: none;
    flex-direction: row;
    gap: 0.75rem;
    padding: 2rem 1rem 2rem 0.75rem;
    overflow-y: auto;
    z-index: 10;
}

.toc-sidebar.open {
    display: flex;
}

/* Custom scrollbar for the sidebar itself */
.toc-sidebar::-webkit-scrollbar {
    width: 4px;
}

.toc-sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.toc-sidebar::-webkit-scrollbar-thumb {
    background: #A4969B;
    border-radius: 2px;
}

.toc-progress {
    width: 3px;
    background: #1e1f26;
    border-radius: 2px;
    position: relative;
    flex-shrink: 0;
    min-height: 0;
}

.toc-progress-bar {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    background: #77BA99;
    border-radius: 2px;
    transition: height 0.1s linear;
}

.toc-content {
    flex: 1;
    font-size: 0.8rem;
    line-height: 1.5;
    min-height: 0;
}

.toc-content .toc-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: #F5F5E0;
    margin-bottom: 0.75rem;
    line-height: 1.3;
}

.toc-content nav > ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.toc-content nav > ul > li {
    margin-bottom: 0.5rem;
}

.toc-content nav > ul > li > a {
    color: #A4969B;
    text-decoration: none;
    display: block;
    padding: 0.15rem 0;
    border-left: 2px solid transparent;
    padding-left: 0.5rem;
    margin-left: -0.5rem;
    transition: color 0.15s, border-left-color 0.15s;
}

.toc-content nav > ul > li > a:hover {
    color: #77BA99;
}

.toc-content nav > ul > li > a.active {
    color: #77BA99;
    border-left-color: #77BA99;
}

.toc-content nav > ul > li > ul {
    list-style: none;
    padding-left: 0.75rem;
    margin-top: 0.25rem;
}

.toc-content nav > ul > li > ul > li {
    margin-bottom: 0.25rem;
}

.toc-content nav > ul > li > ul > li > a {
    color: #A4969B;
    text-decoration: none;
    display: block;
    padding: 0.1rem 0;
    border-left: 2px solid transparent;
    padding-left: 0.5rem;
    margin-left: -0.5rem;
    font-size: 0.75rem;
    transition: color 0.15s, border-left-color 0.15s;
}

.toc-content nav > ul > li > ul > li > a:hover {
    color: #77BA99;
}

.toc-content nav > ul > li > ul > li > a.active {
    color: #77BA99;
    border-left-color: #77BA99;
}

.toc-content nav,
.toc-content nav > ul:last-child,
.toc-content nav > ul:last-child > li:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.toc-toggle {
    display: flex;
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 50;
    width: 36px;
    height: 36px;
    border-radius: 4px;
    background: #1e1f26;
    border: 1px solid #A4969B;
    color: #A4969B;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: all 0.2s;
}

.toc-toggle:hover {
    color: #77BA99;
    border-color: #77BA99;
}

@media (max-width: 768px) {
    body.has-toc {
        overflow-y: auto;
        scrollbar-width: auto;
        -ms-overflow-style: auto;
    }

    body.has-toc::-webkit-scrollbar {
        display: block;
    }

    .toc-sidebar,
    .toc-toggle {
        display: none !important;
    }
}
