/* Palette mappings use the tokens maintained in palettes.css. */
html.light, html.rust, html.navy, html.coal, html.ayu {
    --bg: var(--app-bg);
    --fg: var(--app-text);
    --sidebar-bg: var(--app-surface);
    --sidebar-fg: var(--app-text);
    --sidebar-active: var(--app-accent);
    --sidebar-non-existant: var(--app-text);
    --links: var(--app-accent2);
    --inline-code-color: var(--app-accent);
    --theme-popup-bg: var(--app-surface);
    --theme-popup-border: var(--app-border2);
    --theme-hover: var(--app-border);
    --icons: var(--app-text);
    --icons-hover: var(--app-accent);
    --quote-bg: var(--app-surface);
    --quote-border: var(--app-accent);
    --table-border-color: var(--app-border2);
    --table-header-bg: var(--app-surface);
    --table-alternate-bg: var(--app-surface);
    --searchbar-border-color: var(--app-border2);
    --searchbar-bg: var(--app-surface);
    --searchbar-fg: var(--app-text);
    --searchresults-header-fg: var(--app-text);
    --searchresults-border-color: var(--app-border2);
    --searchresults-li-bg: var(--app-surface);
    --search-mark-bg: var(--app-accent);
    --warning-border: var(--app-warn);
    --mono-font: 'IBM Plex Mono', ui-monospace, monospace;
}
body { font-family: 'IBM Plex Sans', system-ui, sans-serif; }
.menu-title, h1, h2, h3, .chapter { font-family: var(--mono-font); }
.menu-title { font-size: 1.6rem; font-weight: 500; }
.menu-bar { border-bottom: 1px solid var(--app-border); background: var(--app-surface); }
.sidebar {
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--app-border);
}
.sidebar .sidebar-scrollbox {
    position: relative;
    flex: 1;
    min-height: 0;
    height: auto;
}
.sidebar-footer {
    flex-shrink: 0;
    padding: 12px 20px;
    border-top: 1px solid var(--app-border);
    font-family: var(--mono-font);
    font-size: 10px;
    color: var(--app-muted);
    letter-spacing: 0.5px;
}
.sidebar-footer a { color: inherit; text-decoration: none; }
.sidebar-footer a:hover { color: var(--app-accent); text-decoration: underline; }
.sidebar-brand {
    display: block;
    padding: 20px 10px 16px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--app-border);
    text-decoration: none;
}
.sidebar-wordmark {
    display: block;
    font-family: var(--mono-font);
    font-size: 18px;
    font-weight: 600;
    letter-spacing: -0.5px;
    color: var(--app-accent);
}
.sidebar-brand-subtitle {
    display: block;
    margin-top: 2px;
    font-size: 10px;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--fg);
}
.mermaid { overflow-x: auto; margin: 1.5rem 0; text-align: center; }
.mermaid svg { height: auto; max-width: none; }
.chapter li { line-height: 2; }
.chapter li a.active { font-weight: 600; }
.content {
    --content-max-width: 1100px;
    max-width: 1180px;
    margin-inline: auto;
}
.content main { line-height: 1.65; }
.content:has(.docs-landing) {
    --content-max-width: 1400px;
    max-width: 1480px;
    margin-inline: auto;
    container-type: inline-size;
}
.docs-landing {
    display: grid;
    gap: 3rem;
    align-items: start;
}
.docs-landing-intro, .docs-landing-previews { min-width: 0; }
.docs-landing-intro > p:first-child { margin-top: 0; }
.docs-landing-preview { margin: 0; }
.docs-landing-preview a { display: block; }
.docs-landing-preview img {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    object-position: top;
    box-sizing: border-box;
    border: 1px solid var(--app-border2);
    border-radius: 6px;
}
.docs-landing-preview figcaption {
    margin-top: 0.8rem;
    font-family: var(--mono-font);
    font-size: 1.2rem;
}
.docs-landing-preview-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.6rem;
    margin-top: 2rem;
}
@container (min-width: 900px) {
    .docs-landing { grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.25fr); }
    .docs-landing-previews > .docs-landing-preview img { aspect-ratio: 3 / 1; }
}
h1, h2, h3 { font-weight: 500; line-height: 1.35; }
h1 { padding-bottom: 1rem; border-bottom: 1px solid var(--app-border2); }
pre { border: 1px solid var(--app-border2); border-radius: 6px; }
pre > code, pre > .hljs { background: var(--app-editor-bg); color: var(--app-editor-text); }
code { font-family: var(--mono-font); }
table { width: 100%; }
table td, table th { padding: 10px 14px; }
.docs-environment-variables table {
    table-layout: fixed;
    min-width: 700px;
}
.docs-environment-variables th { box-sizing: border-box; }
.docs-environment-variables th:first-child { width: 30%; }
.docs-environment-variables th:nth-child(2) { width: 22%; }
.docs-environment-variables td {
    vertical-align: top;
    overflow-wrap: anywhere;
}
blockquote { border-radius: 0 6px 6px 0; }
a:hover { color: var(--app-accent); }
/* Use readable foreground for navigation; the app's muted token is too dim
   for documentation text. Fonts fall back locally, with no third-party CDN. */
:focus-visible { outline: 2px solid var(--app-accent); outline-offset: 3px; }
@media (max-width: 600px) {
    .menu-title { font-size: 1.25rem; }
    .content { padding: 0 16px; }
}
@media print {
    html { --bg: white !important; --fg: black !important; }
    pre > code, pre > .hljs { background: #f5f5f5; color: black; }
}

/* Stronger documentation heading hierarchy */
.content main h2 {
    font-size: 2.6rem;
    font-weight: 700;
    margin: 3rem 0 1.2rem;
    padding-bottom: 0.6rem;
    border-bottom: 1px solid var(--app-border2);
}
.content main h3 {
    font-size: 2.1rem;
    font-weight: 600;
    margin: 2.2rem 0 1rem;
}
.content main h4 {
    font-size: 1.8rem;
    font-weight: 600;
    margin: 1.8rem 0 0.8rem;
}

.content:has(.docs-features) {
    container-type: inline-size;
}
.docs-feature-grid { display: grid; gap: 2.4rem; }
.docs-feature-group {
    min-width: 0;
    padding: 2rem;
    background: var(--app-surface);
    border: 1px solid var(--app-border);
    border-radius: 6px;
}
.content .docs-feature-group h2 {
    margin-top: 0;
    font-size: 2rem;
    line-height: 1.4;
}
.docs-feature-group ul { list-style: none; padding: 0; }
.docs-feature-group li { margin: 1.4rem 0; }
.docs-feature-group li > strong:first-child { display: block; margin-bottom: 0.3rem; }
.docs-feature-group > p:last-child { margin-bottom: 0; }
.docs-feature-reference {
    margin: 1.2rem 0;
    padding: 1.4rem 1.8rem;
    border: 1px solid var(--app-border);
    border-radius: 6px;
}
.docs-feature-reference summary { cursor: pointer; font-family: var(--mono-font); }
.docs-feature-reference[open] summary { margin-bottom: 1.6rem; }
.docs-feature-reference li { margin-bottom: 1.2rem; }
@container (min-width: 700px) {
    .docs-feature-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.docs-architecture > p { max-width: 75ch; }
.docs-architecture .mermaid { padding: 1.6rem 0; }
.docs-architecture-reference .table-wrapper { overflow-x: auto; }
.docs-architecture-reference table { min-width: 600px; }
