:root {
    color-scheme: light dark;
    --bg: #f7f9f4;
    --ink: #17201d;
    --muted: #5f6963;
    --line: #d8ddd4;
    --panel: #ffffff;
    --inset: #f2f5ef;
    --accent: #6f8d86;
    --accent-dark: #24302d;
    --accent-strong: #24302d;
    --button: #3a5048;
    --wood: #9b704d;
    --shadow: 0 1px 2px rgba(20, 30, 25, 0.04), 0 6px 16px rgba(20, 30, 25, 0.03);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 16px;
    line-height: 1.6;
}

a {
    color: inherit;
}

.site-shell {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    min-height: 100vh;
    max-width: 1320px;
    margin: 0 auto;
}

.sidebar {
    border-right: 1px solid var(--line);
    padding: 28px 22px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    background: var(--bg);
}

.brand {
    display: grid;
    grid-template-columns: 52px 1fr;
    gap: 12px;
    align-items: center;
    text-decoration: none;
}

.brand-mark {
    width: 52px;
    height: 52px;
    display: block;
    object-fit: contain;
}

.brand strong {
    display: block;
    font-size: 18px;
    line-height: 1.1;
}

.brand small {
    display: block;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.3;
    margin-top: 4px;
}

.nav {
    display: grid;
    gap: 4px;
    margin-top: 42px;
}

.nav a {
    border-left: 3px solid transparent;
    color: var(--muted);
    padding: 9px 10px;
    text-decoration: none;
}

.nav a:hover,
.nav a.active,
.nav summary:hover,
.nav summary.active {
    border-left-color: var(--wood);
    color: var(--ink);
    background: var(--inset);
}

.nav-group {
    color: var(--muted);
}

.nav summary {
    border-left: 3px solid transparent;
    cursor: pointer;
    display: block;
    font-weight: 700;
    list-style: none;
    padding: 9px 10px;
}

.nav summary::-webkit-details-marker {
    display: none;
}

.nav summary::after {
    content: "+";
    float: right;
}

.nav-group[open] summary::after {
    content: "-";
}

.subnav {
    display: grid;
    gap: 2px;
    margin: 2px 0 6px 14px;
}

.subnav a {
    font-size: 14px;
    padding: 6px 10px;
}

.sidebar-note {
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 14px;
    margin-top: 42px;
    padding-top: 20px;
}

.label,
.eyebrow {
    color: var(--accent);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.content {
    max-width: 1040px;
    padding: 52px 64px 72px;
}

.site-banner {
    display: block;
    margin: -52px -64px 0;
    width: calc(100% + 128px);
    max-width: none;
    height: auto;
}

.intro {
    border-bottom: 1px solid var(--line);
    margin: 0 -64px;
    padding: 22px 64px 34px;
}

.intro.compact {
    padding-bottom: 28px;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

h1 {
    font-size: 44px;
    font-weight: 680;
    letter-spacing: 0;
    line-height: 1.08;
    max-width: 860px;
}

h2 {
    font-size: 22px;
    line-height: 1.25;
    margin-bottom: 12px;
}

h3 {
    font-size: 16px;
    margin-bottom: 8px;
}

.lead {
    color: var(--muted);
    font-size: 20px;
    max-width: 820px;
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 24px;
}

.two-column,
.grid-list {
    display: grid;
    gap: 24px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.two-column {
    margin-top: 34px;
}

.two-column article,
.grid-list div,
.demo-card,
.panel,
.callout {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 6px;
}

.panel,
.callout,
.two-column article {
    box-shadow: var(--shadow);
}

.two-column article {
    padding: 24px;
}

.panel {
    margin-top: 28px;
    padding: 28px;
}

.grid-list {
    margin-top: 18px;
}

.grid-list div {
    background: var(--inset);
    padding: 20px;
}

.dense-grid {
    gap: 16px;
}

.demo-card {
    background: var(--inset);
    color: inherit;
    display: block;
    padding: 20px;
    text-decoration: none;
}

.demo-card:hover {
    border-color: #b8c2b5;
}

.stack {
    display: grid;
    gap: 18px;
}

.stack article {
    border-top: 1px solid var(--line);
    padding-top: 18px;
}

.stack article:first-child {
    border-top: 0;
    padding-top: 0;
}

.comparison-list {
    display: grid;
    gap: 18px;
}

.comparison-list article {
    border-top: 1px solid var(--line);
    padding-top: 18px;
}

.comparison-list article:first-child {
    border-top: 0;
    padding-top: 0;
}

.plain-list {
    margin: 0;
    padding-left: 20px;
}

.plain-list li {
    margin: 10px 0;
}

.anchor-panel {
    scroll-margin-top: 24px;
}

.muted-copy {
    color: var(--muted);
}

.architecture-flow {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    margin: 18px 0;
}

.architecture-flow div {
    background: var(--inset);
    border: 1px solid var(--line);
    border-radius: 4px;
    font-weight: 700;
    padding: 12px;
    position: relative;
    text-align: center;
}

.architecture-flow div:not(:last-child)::after {
    color: var(--muted);
    content: ">";
    position: absolute;
    right: -9px;
    top: 50%;
    transform: translateY(-50%);
}

.product-flow,
.numbered-grid {
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-top: 18px;
}

.product-flow div,
.numbered-grid div {
    background: var(--inset);
    border: 1px solid var(--line);
    border-radius: 6px;
    min-height: 150px;
    padding: 18px;
}

.product-flow strong,
.numbered-grid strong {
    display: block;
    font-size: 17px;
    line-height: 1.25;
    margin-bottom: 10px;
}

.product-flow span,
.numbered-grid span {
    color: var(--muted);
    display: block;
}

.capability-table {
    border: 1px solid var(--line);
    border-radius: 6px;
    overflow: hidden;
}

.capability-table div {
    display: grid;
    gap: 16px;
    grid-template-columns: 160px minmax(0, 1fr);
    padding: 14px 16px;
}

.capability-table div:nth-child(odd) {
    background: var(--inset);
}

.capability-table div + div {
    border-top: 1px solid var(--line);
}

.capability-table span {
    color: var(--muted);
}

.callout {
    align-items: center;
    display: flex;
    gap: 24px;
    justify-content: space-between;
    margin-top: 28px;
    padding: 24px;
}

.callout-actions {
    display: flex;
    flex: 0 0 auto;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-end;
}

.button {
    background: var(--button);
    border-radius: 4px;
    color: #fff;
    display: inline-block;
    flex: 0 0 auto;
    font-weight: 700;
    padding: 11px 16px;
    text-decoration: none;
}

.button.secondary {
    background: #eef1eb;
    border: 1px solid var(--line);
    color: var(--ink);
}

code {
    background: #eef1eb;
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: 1px 5px;
}

/* --- showcase code block (dark, for hero + worked examples) --- */
.codeblock {
    background: #1e2620;
    border-radius: 6px;
    color: #c8d4c0;
    font-family: "JetBrains Mono", "Fira Code", ui-monospace, "Cascadia Code", Consolas, monospace;
    font-size: 13px;
    line-height: 1.7;
    margin: 18px 0;
    overflow-x: auto;
    padding: 20px 22px;
    white-space: pre;
}
.codeblock .kw  { color: #7ec8a0; }
.codeblock .ty  { color: #89b4ea; }
.codeblock .cm,
.codeblock .dim { color: #6b7f72; font-style: italic; }
.codeblock .at  { color: #d4a574; }
.codeblock .st  { color: #c9a472; }
.codeblock .lit { color: #b5cea8; }

/* light variant — for plain config / shell snippets in body copy */
.codeblock.light {
    background: #eef1eb;
    border: 1px solid var(--line);
    color: var(--ink);
    white-space: pre-wrap;
}

/* --- status pill --- */
.status-pill {
    border-radius: 20px;
    display: inline-block;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    padding: 4px 10px;
    text-transform: uppercase;
    vertical-align: middle;
    white-space: nowrap;
}
.status-pill.open     { background: #e8f0e6; color: #2a5a30; }
.status-pill.building { background: #dfeae6; color: #34564e; }
.status-pill.planned  { background: #fdf5e8; color: #8a6030; }

/* --- diagram panel (wraps an inline SVG) --- */
.diagram-panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 6px;
    margin-top: 28px;
    overflow: hidden;
}
.diagram-panel-header {
    border-bottom: 1px solid var(--line);
    padding: 16px 24px;
}
.diagram-panel-header h2 { margin: 0; }
.diagram-panel-header strong {
    color: var(--accent);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}
.diagram-panel-header p { color: var(--muted); font-size: 15px; margin: 6px 0 0; }
.diagram-panel-body {
    overflow-x: auto;
    padding: 24px;
    text-align: center;
}

/* --- inline flow / sequence diagrams (SVG) --- */
.flow-diagram { display: block; height: auto; margin: 0 auto; max-width: 100%; }
.flow-diagram text { text-anchor: middle; }
.fd-box    { fill: #fff;     stroke: #d8ddd4; stroke-width: 1.5; }
.fd-accent { fill: #6f8d86;  stroke: #5a756e; stroke-width: 1.5; }
.fd-dark   { fill: #24302d;  stroke: #24302d; stroke-width: 1.5; }
.fd-pill   { fill: #e8f0e6;  stroke: #b0c4b0; stroke-width: 1.5; }
.fd-soft   { fill: #f0f4ee;  stroke: #cdd6c9; stroke-width: 1.5; }
.fd-t   { font: 600 14px Inter, system-ui, sans-serif; fill: #17201d; }
.fd-tw  { font: 600 14px Inter, system-ui, sans-serif; fill: #fff; }
.fd-s   { font: 400 11px Inter, system-ui, sans-serif; fill: #5f6963; }
.fd-lbl { font: italic 400 10.5px Inter, system-ui, sans-serif; fill: #5f6963; }
.fd-num { font: 700 12px Inter, system-ui, sans-serif; fill: #6f8d86; }
.fd-flow { fill: none; stroke: #6f8d86; stroke-width: 1.6; }

@media (max-width: 820px) {
    .site-shell {
        display: block;
    }

    .sidebar {
        border-bottom: 1px solid var(--line);
        border-right: 0;
        height: auto;
        position: static;
    }

    .nav {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        margin-top: 24px;
    }

    .sidebar-note {
        display: none;
    }

    .content {
        padding: 34px 22px 48px;
    }

    .site-banner {
        margin: -34px -22px 0;
        width: calc(100% + 44px);
    }

    .intro {
        margin: 0 -22px;
        padding-left: 22px;
        padding-right: 22px;
    }

    h1 {
        font-size: 34px;
    }

    .lead {
        font-size: 18px;
    }

    .two-column,
    .grid-list,
    .product-flow,
    .numbered-grid,
    .architecture-flow,
    .capability-table div {
        grid-template-columns: 1fr;
    }

    .architecture-flow div:not(:last-child)::after {
        bottom: -16px;
        content: "v";
        right: auto;
        top: auto;
        left: 50%;
        transform: translateX(-50%);
    }

    .callout {
        align-items: flex-start;
        flex-direction: column;
    }

    .callout-actions {
        justify-content: flex-start;
    }
}

/* --- dark mode: flip the palette, near-invert the generative graphics.
   Kept at the end of the file so these property overrides win on source order. --- */
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0f1513;
        --ink: #e6ece5;
        --muted: #9aa8a0;
        --line: #2b332f;
        --panel: #161d1a;
        --inset: #1c2420;
        --accent: #8aa79f;
        --accent-dark: #1f2a27;    /* stays a dark surface (e.g. stat bar) */
        --accent-strong: #aec9bd;  /* accent text that must read on dark */
        --button: #46615a;
        --wood: #b98c61;
        --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 6px 16px rgba(0, 0, 0, 0.3);
    }

    /* hardcoded light surfaces that variables don't cover */
    .button.secondary {
        background: #27332d;
        border-color: #47584f;
        color: var(--ink);
    }
    code { background: #1c2420; }
    .codeblock.light { background: #161d1a; }
    .demo-card:hover { border-color: #3a463f; }

    /* near-invert the graphics: inverts lightness, hue-rotate keeps the hues */
    .site-banner,
    .flow-diagram,
    .brand-mark { filter: invert(1) hue-rotate(180deg); }

    /* keep the pastel status pills legible on a dark page */
    .status-pill.open     { background: #1f3a25; color: #9fe0ad; }
    .status-pill.building { background: #1d352f; color: #8fd0c2; }
    .status-pill.planned  { background: #3a2f1c; color: #e0bd8a; }
}
