:root {
    --paper: #fafafa;
    --ink-dark: #1a1a1a;
    --ink-medium: #4a4a4a;
    --ink-light: #7a7a7a;
    --border-faint: #d4d4d4;
    --accent-steel: #8a8a8a;

    --font-serif: "Iowan Old Style", "Apple Garamond", "Baskerville", "Times New Roman", "Droid Serif", Times, "Source Serif Pro", serif;
    --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace;

    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 2rem;
    --space-xl: 4rem;
}

/* ── Reset ── */

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

body {
    background-color: var(--paper);
    color: var(--ink-dark);
    font-family: var(--font-serif);
    line-height: 1.6;
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    color: inherit;
    text-decoration: none;
}

ul, ol {
    list-style: none;
}

/* ── Site Header ── */

.site-header {
    padding: var(--space-lg) var(--space-xl);
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-family: var(--font-sans);
    font-size: 0.85rem;
    letter-spacing: -0.01em;
    border-bottom: 1px solid var(--border-faint);
    position: sticky;
    top: 0;
    background: rgba(250, 250, 250, 0.95);
    backdrop-filter: blur(4px);
    z-index: 10;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5em;
    color: var(--ink-dark);
}

.logo-img {
    height: 20px;
    width: auto;
}

.logo-divider {
    color: var(--border-faint);
    font-weight: 300;
    font-size: 1rem;
}

.logo-label {
    font-family: var(--font-sans);
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.search-container {
    position: relative;
}

.search-input {
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--accent-steel);
    padding: var(--space-xs) 0;
    font-family: var(--font-sans);
    font-size: 0.85rem;
    color: var(--ink-dark);
    width: 200px;
    transition: border-color 0.2s ease;
    outline: none;
}

.search-input:focus {
    border-bottom-color: var(--ink-dark);
}

.search-input::placeholder {
    color: var(--ink-light);
}

/* ── Search Icon Button (mobile only) ── */

.search-icon-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: none;
    border: 1px solid var(--border-faint);
    border-radius: 6px;
    cursor: pointer;
    color: var(--ink-medium);
    padding: 0;
    flex-shrink: 0;
    transition: color 0.15s ease, border-color 0.15s ease;
}

.search-icon-btn:hover {
    color: var(--ink-dark);
    border-color: var(--ink-light);
}

/* ── Grid Layout ── */

.grid-container {
    display: grid;
    grid-template-columns: 220px minmax(500px, 680px) 280px;
    gap: 4rem;
    max-width: 1400px;
    margin: 0 auto;
    padding: var(--space-xl);
    align-items: start;
}

/* ── Nav Sidebar ── */

.nav-sidebar {
    font-family: var(--font-sans);
    position: sticky;
    top: 100px;
}

.nav-group {
    margin-bottom: var(--space-lg);
}

.nav-group-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--ink-light);
    margin-bottom: var(--space-sm);
}

.nav-list {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.nav-link {
    font-size: 0.85rem;
    color: var(--ink-medium);
    transition: color 0.15s ease;
    display: block;
    line-height: 1.3;
}

.nav-link:hover {
    color: var(--ink-dark);
}

.nav-link.active {
    color: var(--ink-dark);
    font-weight: 600;
}

.nav-link.active::before {
    content: "\2014\00a0";
    color: var(--accent-steel);
}

.nav-link--external::after {
    content: "\00a0\2197";
    font-size: 0.7em;
    opacity: 0.5;
}

/* ── CTA Button ── */

.cta-button {
    display: inline-block;
    font-family: var(--font-sans);
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--paper);
    background: var(--ink-dark);
    padding: 0.6rem 1.5rem;
    text-decoration: none;
    transition: opacity 0.15s ease;
    margin: var(--space-md) 0;
}

.cta-button:hover {
    opacity: 0.85;
}

/* ── Content Main ── */

.content-main {
    padding-bottom: var(--space-xl);
    min-width: 0;
}

.content-header {
    margin-bottom: var(--space-lg);
}

.kicker {
    font-family: var(--font-sans);
    font-size: 0.75rem;
    color: var(--accent-steel);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: var(--space-sm);
    display: block;
}

h1 {
    font-size: 2.2rem;
    font-weight: 400;
    line-height: 1.1;
    margin-bottom: var(--space-md);
    letter-spacing: -0.01em;
    color: var(--ink-dark);
}

.lead {
    font-size: 1.1rem;
    color: var(--ink-medium);
    line-height: 1.5;
    margin-bottom: var(--space-lg);
}

.jump-faq {
    display: inline-block;
    font-family: var(--font-sans);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--ink-light);
    border: 1px solid var(--border-faint);
    padding: 0.25em 0.7em;
    transition: color 0.15s ease, border-color 0.15s ease;
    text-decoration: none;
}

.jump-faq:hover {
    color: var(--ink-dark);
    border-color: var(--accent-steel);
}

h2 {
    font-size: 1.4rem;
    font-weight: 400;
    margin: var(--space-lg) 0 var(--space-md);
    padding-top: var(--space-md);
    border-top: 1px solid var(--border-faint);
    color: var(--ink-dark);
    overflow: hidden;
}

h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin: var(--space-md) 0 var(--space-sm);
    color: var(--ink-dark);
}

p {
    margin-bottom: var(--space-md);
    color: var(--ink-dark);
}

a.inline-link {
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
    text-decoration-color: var(--accent-steel);
    color: var(--ink-dark);
    transition: text-decoration-color 0.2s ease;
}

a.inline-link:hover {
    text-decoration-color: var(--ink-dark);
}

/* ── Code ── */

kbd, code {
    font-family: var(--font-mono);
    font-size: 0.85em;
    background: rgba(26, 26, 26, 0.05);
    padding: 0.1em 0.3em;
    color: var(--ink-dark);
}

pre {
    background: transparent;
    border-top: 1px solid var(--accent-steel);
    border-bottom: 1px solid var(--accent-steel);
    padding: var(--space-md) 0;
    margin: var(--space-lg) 0;
    overflow-x: auto;
    font-size: 0.85rem;
    line-height: 1.4;
    color: var(--ink-medium);
}

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

/* ── Tables ── */

.content-main table {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--font-sans);
    font-size: 0.82rem;
    line-height: 1.4;
    margin: var(--space-md) 0 var(--space-lg);
}

.content-main thead {
    border-bottom: 2px solid var(--ink-dark);
}

.content-main th {
    font-weight: 600;
    color: var(--ink-dark);
    text-align: left;
    padding: var(--space-sm) var(--space-md) var(--space-sm) 0;
    letter-spacing: 0.01em;
    white-space: nowrap;
}

.content-main th:last-child {
    padding-right: 0;
}

.content-main td {
    color: var(--ink-medium);
    padding: var(--space-sm) var(--space-md) var(--space-sm) 0;
    border-bottom: 1px solid var(--border-faint);
    vertical-align: top;
}

.content-main td:last-child {
    padding-right: 0;
}

/* First column gets darker ink when it holds a key/label */
.content-main td:first-child {
    color: var(--ink-dark);
}

/* Inline code inside table cells — tighter fit */
.content-main td code,
.content-main td kbd {
    font-size: 0.8em;
    padding: 0.15em 0.4em;
    white-space: nowrap;
}

/* ── Content Lists ── */

.content-main ul {
    margin-bottom: var(--space-md);
    padding-left: 1.5rem;
}

.content-main li {
    margin-bottom: var(--space-xs);
    position: relative;
    color: var(--ink-dark);
}

.content-main ul li::before {
    content: "\2022";
    position: absolute;
    left: -1rem;
    color: var(--accent-steel);
}

/* ── Footnotes ── */

.footnotes-section {
    margin-top: var(--space-xl);
    padding-top: var(--space-md);
    border-top: 2px solid var(--ink-dark);
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-md);
    font-family: var(--font-sans);
    font-size: 0.7rem;
    color: var(--ink-medium);
    line-height: 1.4;
}

.footnote-item sup {
    font-weight: 600;
    margin-right: 0.2rem;
    color: var(--accent-steel);
}

/* ── Marginalia / Right Sidebar ── */

.marginalia {
    position: sticky;
    top: 100px;
}

.toc-mini {
    font-family: var(--font-sans);
    margin-bottom: var(--space-xl);
}

.toc-mini-title {
    font-size: 0.75rem;
    font-weight: 600;
    border-bottom: 1px solid var(--ink-dark);
    padding-bottom: var(--space-xs);
    margin-bottom: var(--space-sm);
    color: var(--ink-dark);
    text-transform: uppercase;
}

.toc-mini-list a {
    display: block;
    font-size: 0.8rem;
    color: var(--ink-medium);
    padding: var(--space-xs) 0;
    border-bottom: 1px solid var(--border-faint);
    transition: color 0.1s;
}

.toc-mini-list a:hover {
    color: var(--ink-dark);
}

/* Hugo TOC overrides — nested structure with indented sub-headings */

.toc-mini-list #TableOfContents {
    margin: 0;
    padding: 0;
}

.toc-mini-list #TableOfContents ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

.toc-mini-list #TableOfContents li {
    margin: 0;
    padding: 0;
}

.toc-mini-list #TableOfContents > ul > li > ul {
    padding-left: 0.75rem;
}

.toc-mini-list #TableOfContents a {
    display: block;
    font-size: 0.8rem;
    color: var(--ink-medium);
    padding: var(--space-xs) 0;
    border-bottom: 1px solid var(--border-faint);
    transition: color 0.1s;
}

.toc-mini-list #TableOfContents > ul > li > ul a {
    font-size: 0.75rem;
    color: var(--ink-light);
}

.toc-mini-list #TableOfContents a:hover {
    color: var(--ink-dark);
}

/* ── Marginalia Figures (legacy) ── */

.figure {
    margin-bottom: var(--space-lg);
}

.figure-placeholder {
    width: 100%;
    aspect-ratio: 4/3;
    background-color: #e5e5e5;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-sans);
    font-size: 0.7rem;
    color: var(--ink-light);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border: 1px solid var(--border-faint);
}

.figure img {
    width: 100%;
    height: auto;
    border: 1px solid var(--border-faint);
}

.figure-caption {
    font-family: var(--font-sans);
    font-size: 0.7rem;
    line-height: 1.3;
    color: var(--ink-medium);
    margin-top: var(--space-xs);
    display: flex;
    gap: var(--space-sm);
}

.figure-number {
    font-weight: 600;
    color: var(--ink-dark);
}

/* ── Inline Figures (fig shortcode) ── */

.fig {
    margin: var(--space-lg) 0;
}

.fig__media img {
    width: 100%;
    height: auto;
    display: block;
    border: 1px solid var(--border-faint);
}

.fig__caption {
    font-family: var(--font-sans);
    font-size: 0.7rem;
    line-height: 1.3;
    color: var(--ink-medium);
    margin-top: var(--space-xs);
    display: flex;
    gap: var(--space-sm);
}

.fig__number {
    font-weight: 600;
    color: var(--ink-dark);
    white-space: nowrap;
}

/* Wide layout — full content-column width, image below text */

.fig--wide .fig__media img {
    width: 100%;
}

/* Aside layout — image floats beside adjacent text */

.fig--aside {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-lg);
    align-items: start;
}

.fig--aside .fig__media {
    order: 2;
}

.fig--aside .fig__caption {
    grid-column: 1 / -1;
    order: 3;
}

/* Aside-left — image on the left, text flows right (use with prose after) */

.fig--aside-left {
    float: left;
    width: 44%;
    margin-right: var(--space-lg);
    margin-bottom: var(--space-md);
}

/* Aside-right — image on the right, text flows left */

.fig--aside-right {
    float: right;
    width: 44%;
    margin-left: var(--space-lg);
    margin-bottom: var(--space-md);
}

/* Compact — narrower image centered, for small UI elements like menus */

.fig--compact {
    max-width: 320px;
}

.fig--compact .fig__media img {
    width: 100%;
}

/* Column — image and adjacent prose sit in a two-column grid.
   Use the {{< fig-col >}} wrapper shortcode. Image takes the
   narrower column, text takes the wider one. Clears cleanly
   at the section boundary — no float bleed. */

.fig-col {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: var(--space-lg);
    align-items: start;
    margin: var(--space-md) 0 var(--space-lg);
}

.fig-col--left {
    grid-template-columns: auto 1fr;
}

.fig-col .fig {
    margin: 0;
    max-width: 240px;
}

.fig-col .fig__media img {
    width: 100%;
}

.fig-col__text {
    min-width: 0;
}

.fig-col__text p:last-child,
.fig-col__text ul:last-child,
.fig-col__text ol:last-child {
    margin-bottom: 0;
}

/* Inherit content-main list styles inside fig-col */
.fig-col__text ul {
    margin-bottom: var(--space-md);
    padding-left: 1.5rem;
}

.fig-col__text li {
    margin-bottom: var(--space-xs);
    position: relative;
    color: var(--ink-dark);
}

.fig-col__text ul li::before {
    content: "\2022";
    position: absolute;
    left: -1rem;
    color: var(--accent-steel);
}

/* Pair layout — used to show two related screenshots side by side.
   Wrap two .fig--pair in a .fig-row container div. */

.fig-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-lg);
    margin: var(--space-lg) 0;
    align-items: start;
}

.fig--pair {
    margin: 0;
}

/* Bar layout — for wide, short images like toolbars.
   No max-height clamp; image renders at natural aspect ratio. */

.fig--bar {
    max-width: 100%;
}

.fig--bar .fig__media img {
    border-top: 1px solid var(--border-faint);
    border-bottom: 1px solid var(--border-faint);
    border-left: none;
    border-right: none;
}

/* Clear floats after aside-left / aside-right figures */

.fig--aside-left + *,
.fig--aside-right + * {
    /* no-op — clearfix handled by .fig-clear */
}

.fig-clear {
    clear: both;
}

/* ── Image Zoom Overlay ── */

[data-zoom] {
    cursor: zoom-in;
    position: relative;
}

.fig__zoom-hint {
    position: absolute;
    top: 0;
    right: 0;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 0 32px 32px 0;
    border-color: transparent var(--ink-dark) transparent transparent;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.fig__zoom-hint svg {
    position: absolute;
    top: 2px;
    right: -28px;
    width: 14px;
    height: 14px;
    color: var(--paper);
}

[data-zoom]:hover .fig__zoom-hint {
    opacity: 1;
}

.zoom-overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    background: rgba(250, 250, 250, 0.92);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: zoom-out;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.zoom-overlay[data-visible] {
    opacity: 1;
}

.zoom-overlay img {
    max-width: 90vw;
    max-height: 90vh;
    width: auto;
    height: auto;
    border: 1px solid var(--border-faint);
    box-shadow: 0 4px 40px rgba(26, 26, 26, 0.08);
}

/* ── Reading Progress Bar ── */

.reading-progress {
    position: fixed;
    top: 0;
    left: 0;
    height: 2px;
    width: 0%;
    background: var(--accent-steel);
    z-index: 11;
    transition: width 0.1s linear;
    pointer-events: none;
}

/* ── TOC Scroll Spy ── */

.toc-mini-list #TableOfContents a.toc-active {
    color: var(--ink-dark);
    font-weight: 600;
}

/* ── Breadcrumbs ── */

.breadcrumbs {
    font-family: var(--font-sans);
    font-size: 0.75rem;
    color: var(--ink-light);
    margin-bottom: var(--space-sm);
    line-height: 1.3;
}

.breadcrumb-link {
    color: var(--ink-light);
    transition: color 0.15s ease;
}

.breadcrumb-link:hover {
    color: var(--ink-dark);
}

.breadcrumb-sep {
    margin: 0 0.3em;
    color: var(--border-faint);
}

.breadcrumb-current {
    color: var(--ink-medium);
}

/* ── Search Kbd Badge ── */

.search-kbd {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    font-family: var(--font-sans);
    font-size: 0.65rem;
    color: var(--ink-light);
    background: rgba(26, 26, 26, 0.05);
    border: 1px solid var(--border-faint);
    border-radius: 3px;
    padding: 0.1em 0.4em;
    pointer-events: none;
    line-height: 1;
}

.search-input {
    padding-right: 3rem;
}

/* ── Search Command Palette ── */

.search-modal {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding-top: 15vh;
}

.search-modal.open {
    display: flex;
}

.search-modal__backdrop {
    position: fixed;
    inset: 0;
    background: rgba(250, 250, 250, 0.92);
    backdrop-filter: blur(8px);
}

.search-modal__panel {
    position: relative;
    width: 560px;
    max-width: 90vw;
    max-height: 60vh;
    background: var(--paper);
    border: 1px solid var(--border-faint);
    box-shadow: 0 8px 60px rgba(26, 26, 26, 0.10);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.search-modal__input-wrap {
    padding: var(--space-md);
    border-bottom: 1px solid var(--border-faint);
}

.search-modal__input {
    width: 100%;
    border: none;
    background: transparent;
    font-family: var(--font-sans);
    font-size: 1rem;
    color: var(--ink-dark);
    outline: none;
}

.search-modal__input::placeholder {
    color: var(--ink-light);
}

.search-modal__results {
    overflow-y: auto;
    padding: var(--space-sm) 0;
    flex: 1;
}

.search-modal__empty {
    padding: var(--space-lg) var(--space-md);
    font-family: var(--font-sans);
    font-size: 0.85rem;
    color: var(--ink-light);
    text-align: center;
}

.search-modal__result {
    display: block;
    padding: var(--space-sm) var(--space-md);
    text-decoration: none;
    transition: background 0.1s ease;
}

.search-modal__result:hover,
.search-modal__result.active {
    background: rgba(26, 26, 26, 0.03);
}

.search-modal__result-section {
    display: block;
    font-family: var(--font-sans);
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--accent-steel);
    margin-bottom: 0.15em;
}

.search-modal__result-title {
    display: block;
    font-family: var(--font-sans);
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--ink-dark);
    margin-bottom: 0.2em;
}

.search-modal__result-excerpt {
    display: block;
    font-family: var(--font-sans);
    font-size: 0.8rem;
    color: var(--ink-medium);
    line-height: 1.4;
}

.search-modal__result-excerpt mark {
    background: rgba(138, 138, 138, 0.2);
    color: var(--ink-dark);
    padding: 0 0.1em;
}

/* ── Backlinks ── */

.backlinks {
    margin-top: var(--space-lg);
}

.backlinks-title {
    font-family: var(--font-sans);
    font-size: 0.75rem;
    font-weight: 600;
    border-bottom: 1px solid var(--ink-dark);
    padding-bottom: var(--space-xs);
    margin-bottom: var(--space-sm);
    color: var(--ink-dark);
    text-transform: uppercase;
}

.backlinks-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.backlinks-link {
    display: block;
    font-family: var(--font-sans);
    font-size: 0.8rem;
    color: var(--ink-medium);
    padding: var(--space-xs) 0;
    border-bottom: 1px solid var(--border-faint);
    transition: color 0.1s;
}

.backlinks-link:hover {
    color: var(--ink-dark);
}

.backlinks-kicker {
    display: block;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--accent-steel);
    margin-bottom: 0.1em;
}

.backlinks-page-title {
    display: block;
}

/* ── Link Preview Popovers ── */

.link-preview {
    position: absolute;
    z-index: 50;
    width: 300px;
    max-width: 90vw;
    background: var(--paper);
    border: 1px solid var(--border-faint);
    box-shadow: 0 4px 24px rgba(26, 26, 26, 0.08);
    padding: var(--space-sm) var(--space-md);
    pointer-events: auto;
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 0.15s ease, transform 0.15s ease;
}

.link-preview.visible {
    opacity: 1;
    transform: translateY(0);
}

.link-preview__kicker {
    display: block;
    font-family: var(--font-sans);
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--accent-steel);
    margin-bottom: 0.15em;
}

.link-preview__title {
    display: block;
    font-family: var(--font-serif);
    font-size: 1rem;
    font-weight: 400;
    color: var(--ink-dark);
    line-height: 1.2;
    margin-bottom: 0.3em;
}

.link-preview__lead {
    display: block;
    font-family: var(--font-sans);
    font-size: 0.8rem;
    color: var(--ink-medium);
    line-height: 1.4;
}

/* ── Callout Shortcodes ── */

.callout {
    border-left: 3px solid var(--accent-steel);
    padding: var(--space-sm) var(--space-md);
    margin: var(--space-md) 0 var(--space-lg);
}

.callout__label {
    display: block;
    font-family: var(--font-sans);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--accent-steel);
    margin-bottom: var(--space-xs);
}

.callout__body {
    font-size: 0.95rem;
    color: var(--ink-dark);
}

.callout__body p:last-child {
    margin-bottom: 0;
}

.callout--tip {
    border-left-color: #6a6a6a;
}

.callout--tip .callout__label {
    color: #6a6a6a;
}

.callout--warning {
    border-left-color: var(--ink-dark);
}

.callout--warning .callout__label {
    color: var(--ink-dark);
}

/* ── Search Highlight ── */

.pagefind-highlight {
    background: rgba(138, 138, 138, 0.18);
    color: var(--ink-dark);
    padding: 0.05em 0.15em;
    border-bottom: 2px solid var(--accent-steel);
    scroll-margin-top: 100px;
}

/* ── Accordion / FAQ ── */

.accordion {
    border-bottom: 1px solid var(--border-faint);
}

.accordion:first-of-type {
    border-top: 1px solid var(--border-faint);
}

.accordion__trigger {
    display: block;
    width: 100%;
    padding: var(--space-md) 0;
    font-family: var(--font-sans);
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--ink-dark);
    cursor: pointer;
    list-style: none;
    position: relative;
    padding-right: 1.5rem;
}

.accordion__trigger::-webkit-details-marker {
    display: none;
}

.accordion__trigger::after {
    content: "+";
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    font-family: var(--font-sans);
    font-size: 1rem;
    font-weight: 400;
    color: var(--ink-light);
    transition: transform 0.15s ease;
}

.accordion[open] .accordion__trigger::after {
    content: "−";
}

.accordion__trigger:hover {
    color: var(--ink-dark);
}

.accordion__body {
    padding: 0 0 var(--space-md);
    font-size: 0.92rem;
    color: var(--ink-medium);
    line-height: 1.6;
}

.accordion__body p:last-child {
    margin-bottom: 0;
}

/* ── Section Landing Page Grid ── */

.section-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-md);
    margin-top: var(--space-lg);
}

.section-card {
    display: flex;
    flex-direction: column;
    padding: var(--space-md);
    border: 1px solid var(--border-faint);
    transition: border-color 0.15s ease;
    text-decoration: none;
}

.section-card:hover {
    border-color: var(--accent-steel);
}

.section-card__title {
    font-family: var(--font-serif);
    font-size: 1.1rem;
    color: var(--ink-dark);
    margin-bottom: var(--space-xs);
    line-height: 1.2;
}

.section-card__lead {
    font-family: var(--font-sans);
    font-size: 0.82rem;
    color: var(--ink-medium);
    line-height: 1.4;
    flex: 1;
}

.section-card__meta {
    font-family: var(--font-sans);
    font-size: 0.7rem;
    color: var(--ink-light);
    margin-top: var(--space-sm);
}

/* ── Keyboard Help Overlay ── */

.keyboard-help {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.keyboard-help.open {
    opacity: 1;
}

.keyboard-help__backdrop {
    position: fixed;
    inset: 0;
    background: rgba(250, 250, 250, 0.92);
    backdrop-filter: blur(8px);
}

.keyboard-help__panel {
    position: relative;
    width: 340px;
    max-width: 90vw;
    background: var(--paper);
    border: 1px solid var(--border-faint);
    box-shadow: 0 8px 60px rgba(26, 26, 26, 0.10);
    padding: var(--space-lg);
}

.keyboard-help__title {
    font-family: var(--font-sans);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--ink-dark);
    border-bottom: 1px solid var(--ink-dark);
    padding-bottom: var(--space-xs);
    margin-bottom: var(--space-md);
}

.keyboard-help__grid {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: var(--space-sm) var(--space-md);
    align-items: baseline;
}

.keyboard-help__key {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    background: rgba(26, 26, 26, 0.05);
    border: 1px solid var(--border-faint);
    border-radius: 3px;
    padding: 0.15em 0.5em;
    color: var(--ink-dark);
    text-align: center;
    min-width: 2rem;
}

.keyboard-help__desc {
    font-family: var(--font-sans);
    font-size: 0.85rem;
    color: var(--ink-medium);
}

/* ── Phase 6: Visual Polish ── */

html {
    scroll-behavior: smooth;
}

h2, h3 {
    scroll-margin-top: 100px;
}

/* Heading anchor links */
.content-main h2,
.content-main h3 {
    position: relative;
}

.content-main h2:hover::before,
.content-main h3:hover::before {
    content: "#";
    position: absolute;
    left: -1.2em;
    color: var(--accent-steel);
    font-weight: 400;
    opacity: 0.6;
}

/* Page fade-in */
.content-main {
    animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0.85; }
    to { opacity: 1; }
}

/* Typography refinements */
body {
    font-variant-numeric: oldstyle-nums;
    text-wrap: pretty;
}

.content-main p {
    hyphens: auto;
}

.lead {
    line-height: 1.55;
}

/* Nav hover indent */
.nav-link {
    transition: color 0.15s ease, transform 0.15s ease;
}

.nav-link:hover {
    transform: translateX(3px);
}

.nav-link.active {
    transform: none;
}

/* Hamburger button — hidden on desktop */
.hamburger {
    display: none;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    position: relative;
}

.hamburger span {
    display: block;
    width: 18px;
    height: 1.5px;
    background: var(--ink-dark);
    transition: transform 0.2s ease;
    position: relative;
}

.hamburger span::before,
.hamburger span::after {
    display: block;
    width: 18px;
    height: 1.5px;
    background: var(--ink-dark);
    transition: transform 0.2s ease;
}

.hamburger span::before,
.hamburger span::after {
    content: "";
    position: absolute;
}

.hamburger span::before { top: -5px; }
.hamburger span::after { top: 5px; }

/* ── Phase 5: Responsive Design ── */

@media (max-width: 1100px) {
    .grid-container {
        grid-template-columns: 200px 1fr;
        gap: var(--space-lg);
    }

    .marginalia {
        display: none;
    }
}

@media (max-width: 768px) {
    .site-header {
        padding: var(--space-md);
    }

    .grid-container {
        grid-template-columns: 1fr;
        gap: 0;
        padding: var(--space-md);
    }

    .nav-sidebar {
        display: none;
    }

    .nav-sidebar.open {
        display: block;
        position: fixed;
        top: 0;
        left: 0;
        width: 280px;
        height: 100vh;
        background: var(--paper);
        z-index: 50;
        padding: var(--space-xl) var(--space-lg);
        overflow-y: auto;
        border-right: 1px solid var(--border-faint);
        box-shadow: 4px 0 24px rgba(26, 26, 26, 0.06);
    }

    .nav-backdrop {
        display: none;
    }

    .nav-backdrop.open {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 49;
        background: rgba(250, 250, 250, 0.8);
        backdrop-filter: blur(4px);
    }

    .hamburger {
        display: flex;
    }

    .marginalia {
        display: none;
    }

    .content-main {
        padding-bottom: var(--space-lg);
    }

    .section-grid {
        grid-template-columns: 1fr;
    }

    /* Collapse figure layouts */
    .fig--aside { grid-template-columns: 1fr; }
    .fig--aside-left,
    .fig--aside-right {
        float: none;
        width: 100%;
        margin-left: 0;
        margin-right: 0;
    }
    .fig-col {
        grid-template-columns: 1fr;
    }
    .fig-col .fig {
        max-width: 100%;
    }

    .search-modal__panel {
        width: 100%;
        max-width: 100%;
        max-height: 80vh;
    }

    /* Header alignment for touch */
    .site-header { align-items: center; gap: var(--space-sm); }

    /* Touch targets: 44px minimum */
    .hamburger { width: 44px; height: 44px; }
    .nav-link { min-height: 44px; display: flex; align-items: center; }

    /* Header search: hide full input, show icon button */
    .search-container { display: none; }
    .search-icon-btn { display: flex; }

    /* Sidebar: clamp to viewport */
    .nav-sidebar.open { width: min(280px, calc(100vw - 60px)); }

    /* Text readability */
    .content-main p { hyphens: auto; word-break: break-word; }
}

/* ── Homepage ── */

/* Home layout — keep sidebar, hide marginalia, content fills remaining space */
.home-layout .marginalia {
    display: none;
}

.home-layout .grid-container {
    grid-template-columns: 220px 1fr;
}

.home {
    padding-bottom: var(--space-xl);
    max-width: 680px;
    margin: 0 auto;
    min-width: 0;
}

.home-hero {
    text-align: center;
    padding: var(--space-lg) 0;
    margin-bottom: var(--space-lg);
    border-bottom: 1px solid var(--border-faint);
}

.home-hero h1 {
    font-size: 2.6rem;
    margin-bottom: var(--space-sm);
}

.home-hero__lead {
    font-size: 1.1rem;
    color: var(--ink-medium);
    line-height: 1.5;
    margin-bottom: var(--space-lg);
}

.home-search {
    position: relative;
    max-width: 400px;
    margin: 0 auto;
}

.home-search__input {
    width: 100%;
    border: 1px solid var(--border-faint);
    background: transparent;
    padding: 0.6rem 3.5rem 0.6rem 1rem;
    font-family: var(--font-sans);
    font-size: 0.9rem;
    color: var(--ink-dark);
    outline: none;
    transition: border-color 0.2s ease;
}

.home-search__input:focus {
    border-color: var(--ink-dark);
}

.home-search__input::placeholder {
    color: var(--ink-light);
}

.home-search__kbd {
    position: absolute;
    right: 0.6rem;
    top: 50%;
    transform: translateY(-50%);
    font-family: var(--font-sans);
    font-size: 0.65rem;
    color: var(--ink-light);
    background: rgba(26, 26, 26, 0.05);
    border: 1px solid var(--border-faint);
    border-radius: 3px;
    padding: 0.15em 0.45em;
    pointer-events: none;
    line-height: 1;
}

/* Getting Started section */

.home-getting-started {
    margin-bottom: var(--space-xl);
}

.home-section-title {
    font-family: var(--font-sans);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--ink-dark);
    border-bottom: 1px solid var(--ink-dark);
    padding-bottom: var(--space-xs);
    margin-bottom: var(--space-md);
}

.home-getting-started__grid {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

/* Featured link rows */

.home-featured {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md) var(--space-lg);
    border: 1px solid var(--border-faint);
    margin-bottom: var(--space-md);
    text-decoration: none;
    transition: border-color 0.15s ease;
}

.home-featured:hover {
    border-color: var(--ink-dark);
}

.home-featured__icon {
    color: var(--ink-light);
    flex-shrink: 0;
}

.home-featured:hover .home-featured__icon {
    color: var(--ink-dark);
}

.home-featured__text {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.home-featured__title {
    font-family: var(--font-sans);
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--ink-dark);
}

.home-featured__sub {
    font-family: var(--font-sans);
    font-size: 0.8rem;
    color: var(--ink-medium);
}

.home-featured__arrow {
    font-size: 1.1rem;
    color: var(--ink-light);
    transition: color 0.15s ease, transform 0.15s ease;
}

.home-featured:hover .home-featured__arrow {
    color: var(--ink-dark);
    transform: translateX(3px);
}

/* Category grid */

.home-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-md);
    margin-bottom: var(--space-xl);
}

.home-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-lg) var(--space-md);
    border: 1px solid var(--border-faint);
    text-decoration: none;
    text-align: center;
    transition: border-color 0.15s ease;
}

.home-card:hover {
    border-color: var(--ink-dark);
}

.home-card__icon {
    color: var(--ink-light);
    margin-bottom: var(--space-xs);
    transition: color 0.15s ease;
}

.home-card:hover .home-card__icon {
    color: var(--ink-dark);
}

.home-card__title {
    font-family: var(--font-sans);
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--ink-dark);
}

.home-card__count {
    font-family: var(--font-sans);
    font-size: 0.7rem;
    color: var(--ink-light);
}

/* Popular pages */

.home-popular {
    margin-bottom: var(--space-xl);
}

.home-popular__title {
    font-family: var(--font-sans);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--ink-dark);
    border-bottom: 1px solid var(--ink-dark);
    padding-bottom: var(--space-xs);
    margin-bottom: var(--space-md);
}

.home-popular__grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-md);
}

.home-popular__item {
    display: flex;
    flex-direction: column;
    padding: var(--space-md);
    border: 1px solid var(--border-faint);
    text-decoration: none;
    transition: border-color 0.15s ease;
}

.home-popular__item:hover {
    border-color: var(--ink-dark);
}

.home-popular__kicker {
    font-family: var(--font-sans);
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--accent-steel);
    margin-bottom: 0.15em;
}

.home-popular__name {
    font-family: var(--font-serif);
    font-size: 1rem;
    color: var(--ink-dark);
    line-height: 1.2;
    margin-bottom: 0.3em;
}

.home-popular__lead {
    font-family: var(--font-sans);
    font-size: 0.78rem;
    color: var(--ink-medium);
    line-height: 1.4;
}

/* Keyboard hint */

.home-hint {
    text-align: center;
    font-family: var(--font-sans);
    font-size: 0.75rem;
    color: var(--ink-light);
}

.home-hint kbd {
    font-size: 0.7rem;
    padding: 0.1em 0.35em;
}

/* Scroll-down indicator */

.scroll-hint {
    position: fixed;
    bottom: var(--space-lg);
    right: var(--space-lg);
    color: var(--ink-medium);
    opacity: 0.7;
    animation: scrollBounce 2s ease-in-out infinite;
    transition: opacity 0.4s ease;
    pointer-events: none;
    z-index: 5;
}

.scroll-hint.hidden {
    opacity: 0;
}

@keyframes scrollBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(6px); }
}

/* Homepage responsive */

@media (max-width: 768px) {
    /* Fix home grid conflict — must be here (after base) to win cascade */
    .home-layout .grid-container { grid-template-columns: 1fr; }

    .home { max-width: none; padding-bottom: var(--space-lg); }

    .home-featured { padding: var(--space-md); }

    .home-grid { grid-template-columns: repeat(2, 1fr); }

    .home-popular__grid { grid-template-columns: 1fr; }

    .home-hero h1 { font-size: 2rem; }

    /* Hide desktop-only elements */
    .home-hint { display: none; }
    .home-search__kbd { display: none; }
    .home-search__input { padding-right: var(--space-md); }

    /* Hide scroll hint on mobile */
    .scroll-hint { display: none; }

    /* Category cards: reduce padding */
    .home-card { padding: var(--space-md); }
}

@media (max-width: 480px) {
    /* Header compact */
    .site-header { padding: var(--space-sm) var(--space-md); }
    .logo-label { font-size: 0.7rem; }
    .logo-divider { display: none; }

    /* Hero downsizing */
    .home-hero { padding: var(--space-md) 0; margin-bottom: var(--space-md); }
    .home-hero h1 { font-size: 1.6rem; }
    .home-hero__lead { font-size: 0.95rem; }

    /* Category grid: single column, compact horizontal rows */
    .home-grid { grid-template-columns: 1fr; gap: var(--space-sm); }
    .home-card {
        flex-direction: row;
        align-items: center;
        text-align: left;
        padding: var(--space-sm) var(--space-md);
        gap: var(--space-sm);
    }
    .home-card__icon { margin-bottom: 0; }
    .home-card__count { margin-left: auto; }

    /* Featured card: tighter, keep horizontal */
    .home-featured { padding: var(--space-sm) var(--space-md); gap: var(--space-sm); }

    /* Container padding */
    .grid-container { padding: var(--space-sm); }

    /* Home search full width */
    .home-search { max-width: 100%; }

    /* Readability */
    body { line-height: 1.7; }
    h1 { font-size: 1.7rem; }

    /* Popular items: tighter */
    .home-popular__item { padding: var(--space-sm) var(--space-md); }
    .home-popular { margin-bottom: var(--space-lg); }
    .home-grid { margin-bottom: var(--space-lg); }
}
