/* ==========================================================================
   Bench Notes: paper editorial × workshop bench
   1. Tokens   2. Base   3. Primitives   4. Header   5. Home
   6. Cards    7. Sidebar   8. Archive   9. Article   10. Content & cards
   11. Diagnostic components   12. Footer   13. Responsive
   ========================================================================== */

/* 1. Tokens
   -------------------------------------------------------------------------- */
:root {
    --paper: #fbf8f2;
    --paper-2: #f5f0e7;
    --paper-3: #ece5d9;
    --card: #fffdf9;
    --line: #e4dbcc;
    --line-strong: #cbbfac;
    --ink: #1b1f25;
    --ink-2: #44474d;
    --muted: #6a6964;

    --accent: var(--ghost-accent-color, #b34700);
    --accent-soft: color-mix(in srgb, var(--accent) 12%, transparent);
    --on-accent: #fff;

    --scope-bg: #0d1218;
    --scope-grid: #233042;
    --trace-1: #ffa53d;
    --trace-2: #3fd9e8;
    --pass: #4ade80;

    --font-serif: var(--gh-font-body, "Newsreader", "Iowan Old Style", Georgia, serif);
    --font-display: var(--gh-font-heading, "Newsreader", "Iowan Old Style", Georgia, serif);
    --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

    --radius: 6px;
    --radius-lg: 10px;
    --shadow: 0 1px 0 rgba(40, 30, 10, .04), 0 2px 10px -6px rgba(40, 30, 10, .12);
    --shadow-lift: 0 1px 0 rgba(40, 30, 10, .05), 0 10px 28px -14px rgba(40, 30, 10, .28);

    --gutter: clamp(16px, 4vw, 40px);
    --container: 1200px;
    --content: 700px;
    --wide: 1000px;
    --header-h: 64px;
}

/* 2. Base
   -------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html {
    -webkit-text-size-adjust: 100%;
    scroll-padding-top: calc(var(--header-h) + 24px);
}

body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--font-serif);
    font-size: 1.0625rem;
    line-height: 1.65;
    font-optical-sizing: auto;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

img, svg, video { display: block; max-width: 100%; height: auto; }
a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent); }
button { font: inherit; color: inherit; cursor: pointer; }
h1, h2, h3, h4, h5, h6 { font-family: var(--font-display); font-weight: 500; line-height: 1.2; margin: 0; }
p { margin: 0; }

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 3px;
}

::selection { background: color-mix(in srgb, var(--accent) 25%, transparent); }

.sr-only {
    position: absolute !important;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0);
    white-space: nowrap; border: 0;
}

.skip-link {
    position: absolute; left: 16px; top: -60px; z-index: 100;
    padding: 8px 14px;
    background: var(--ink); color: var(--paper);
    font-family: var(--font-mono); font-size: 13px;
    border-radius: var(--radius);
}
.skip-link:focus { top: 12px; color: var(--paper); }

.container {
    width: 100%;
    max-width: calc(var(--container) + var(--gutter) * 2);
    margin: 0 auto;
    padding: 0 var(--gutter);
}

.page-pad { padding-top: 40px; padding-bottom: 24px; }

/* 3. Primitives
   -------------------------------------------------------------------------- */
.label, .mono-sm, .meta-row, .badge, .chip, .btn, .btn-quiet, .link-mono, .pill {
    font-family: var(--font-mono);
}

.label {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 11px; font-weight: 600;
    letter-spacing: .08em; text-transform: uppercase;
    color: var(--muted);
}
.label-accent { color: var(--accent); }
.label-strong { color: var(--ink); font-weight: 700; }
.label .icon { width: 14px; height: 14px; }

.mono-sm { font-size: 12px; letter-spacing: .02em; }
.muted { color: var(--muted); }
.text-accent { color: var(--accent); }
.strong { color: var(--ink); font-weight: 600; }

.icon { flex-shrink: 0; }

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

.badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 2px 8px;
    font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
    color: var(--accent);
    background: var(--accent-soft);
    border-radius: 4px;
    white-space: nowrap;
}
a.badge:hover { background: var(--accent); color: var(--on-accent); }
.badge-solid { background: var(--accent); color: var(--on-accent); border-radius: 999px; padding: 2px 9px; }

.pill {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 4px 12px;
    font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
    color: var(--accent);
    background: var(--paper-2);
    border: 1px solid var(--line);
    border-radius: 999px;
}
.pill-small { padding: 2px 8px; font-size: 10px; gap: 6px; }

.led {
    width: 7px; height: 7px; border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 50%, transparent);
    animation: led 2.4s ease-out infinite;
}
@keyframes led {
    0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 45%, transparent); }
    70%, 100% { box-shadow: 0 0 0 6px transparent; }
}

.btn, .btn-quiet {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    height: 36px; padding: 0 14px;
    font-size: 12px; font-weight: 600; letter-spacing: .04em;
    border-radius: var(--radius);
    border: 1px solid transparent;
    white-space: nowrap;
    transition: background-color .15s, color .15s, border-color .15s;
}
.btn-dark { background: var(--ink); color: var(--paper); }
.btn-dark:hover { background: var(--accent); color: var(--on-accent); }
.btn-accent { background: var(--accent); color: var(--on-accent); }
.btn-accent:hover { background: var(--ink); color: var(--paper); }
.btn-quiet {
    background: var(--paper-2);
    border-color: var(--line);
    color: var(--ink-2);
    font-weight: 500;
}
.btn-quiet:hover { background: var(--paper-3); color: var(--ink); }
.btn-block { width: 100%; }

.link-mono {
    font-size: 12px; font-weight: 500;
    color: var(--ink);
    white-space: nowrap;
}
.link-mono:hover { color: var(--accent); }

.link-button {
    padding: 0; border: 0; background: none;
    font: inherit; color: inherit;
}
.link-button:hover { color: var(--accent); }

.chip {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 6px 13px;
    font-size: 12px; font-weight: 500;
    color: var(--ink-2);
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 999px;
    transition: background-color .15s, color .15s, border-color .15s;
}
.chip:hover { color: var(--ink); border-color: var(--line-strong); background: var(--paper-2); }
.chip.is-active { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.chip-count { font-size: 10px; color: var(--muted); }
.chip.is-active .chip-count { color: color-mix(in srgb, var(--paper) 70%, transparent); }

.meta-row {
    display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px;
    font-size: 12px; letter-spacing: .03em; text-transform: uppercase;
    color: var(--muted);
}
.meta-row .sep { color: var(--line-strong); }
.meta-row-split { justify-content: space-between; }

.avatar {
    width: 28px; height: 28px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--paper-3);
    border: 2px solid var(--card);
    box-shadow: 0 0 0 1px var(--line);
}
.avatar-lg { width: 52px; height: 52px; }
.avatar-xl { width: 96px; height: 96px; }
.avatar-empty { display: grid; place-items: center; color: var(--muted); }

/* 4. Header
   -------------------------------------------------------------------------- */
.site-header {
    position: sticky; top: 0; z-index: 50;
    background: color-mix(in srgb, var(--paper) 92%, transparent);
    -webkit-backdrop-filter: saturate(1.4) blur(10px);
    backdrop-filter: saturate(1.4) blur(10px);
}

.header-inner {
    display: flex; align-items: center; justify-content: space-between; gap: 24px;
    height: var(--header-h);
}

/* millimetre rule under the header */
.ruler {
    height: 8px;
    border-top: 1px solid var(--line);
    background:
        repeating-linear-gradient(90deg, var(--line-strong) 0 1px, transparent 1px 80px) top left / 100% 8px no-repeat,
        repeating-linear-gradient(90deg, var(--line) 0 1px, transparent 1px 8px) top left / 100% 4px no-repeat;
    opacity: .9;
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 0 1 auto; }
.brand:hover { color: inherit; }
.brand-logo { max-height: 36px; width: auto; }
.brand-mark {
    display: grid; place-items: center;
    width: 36px; height: 36px; flex-shrink: 0;
    font-family: var(--font-mono); font-size: 13px; font-weight: 600; letter-spacing: .02em;
    color: var(--paper);
    background: var(--ink);
    border-radius: var(--radius);
    position: relative;
}
.brand-mark::after {
    content: "";
    position: absolute; right: 4px; bottom: 4px;
    width: 4px; height: 4px; border-radius: 50%;
    background: var(--accent);
}
.brand-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.15; }
.brand-title {
    font-family: var(--font-display);
    font-size: 1.2rem; font-weight: 600; letter-spacing: -.01em;
    white-space: nowrap;
}
.brand:hover .brand-title { color: var(--accent); }
.brand-tagline {
    font-family: var(--font-mono);
    font-size: 10px; letter-spacing: .12em; text-transform: uppercase;
    color: var(--muted);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    max-width: 260px;
}

.site-nav .nav-list {
    display: flex; align-items: center; gap: 2px;
    margin: 0; padding: 0; list-style: none;
}
.site-nav a {
    display: block;
    padding: 6px 12px;
    font-size: 14px; font-weight: 500;
    color: var(--ink-2);
    border-radius: var(--radius);
}
.site-nav a:hover { color: var(--ink); background: var(--paper-2); }
.site-nav .is-current a { background: var(--ink); color: var(--paper); }

.header-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }

.search-btn kbd {
    padding: 1px 5px;
    font-family: var(--font-mono); font-size: 10px;
    color: var(--muted);
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 4px;
}
.search-label { font-size: 12px; color: var(--muted); margin-right: 8px; }

.nav-toggle {
    display: none;
    width: 36px; height: 36px;
    padding: 0;
    background: var(--paper-2);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    position: relative;
}
.nav-toggle span {
    position: absolute; left: 10px; right: 10px; height: 1.5px;
    background: var(--ink);
    transition: transform .2s;
}
.nav-toggle span:first-child { top: 14px; }
.nav-toggle span:last-child { top: 20px; }
.nav-open .nav-toggle span:first-child { transform: translateY(3px) rotate(45deg); }
.nav-open .nav-toggle span:last-child { transform: translateY(-3px) rotate(-45deg); }

/* 5. Home
   -------------------------------------------------------------------------- */
.hero {
    position: relative;
    display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: 48px; align-items: center;
    margin-bottom: 32px;
    padding: clamp(24px, 4vw, 48px);
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
    isolation: isolate;
}
/* graph-paper ground */
.hero::before {
    content: "";
    position: absolute; inset: 0; z-index: -1;
    background:
        linear-gradient(var(--paper-2) 1px, transparent 1px) 0 0 / 24px 24px,
        linear-gradient(90deg, var(--paper-2) 1px, transparent 1px) 0 0 / 24px 24px;
    mask-image: linear-gradient(105deg, #000 0%, transparent 60%);
    -webkit-mask-image: linear-gradient(105deg, #000 0%, transparent 60%);
}
.hero-badge-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 16px; }
.hero-title {
    font-size: clamp(2.1rem, 4.4vw, 3.25rem);
    font-weight: 400; letter-spacing: -.02em; line-height: 1.08;
    margin-bottom: 18px;
    text-wrap: balance;
}
.hero-sub {
    max-width: 38em;
    font-size: 1.15rem; font-style: italic; line-height: 1.6;
    color: var(--ink-2);
    margin-bottom: 28px;
}
.hero-copy > :last-child { margin-bottom: 0; }

.hero-figure { position: relative; margin: 0; padding: 14px; }
.hero-image {
    overflow: hidden;
    border-radius: var(--radius);
    background: var(--paper-3);
    aspect-ratio: 4 / 4.2;
}
.hero-image img { width: 100%; height: 100%; object-fit: cover; transition: transform .8s ease; }
.hero-figure:hover .hero-image img { transform: scale(1.03); }
.crop { position: absolute; width: 14px; height: 14px; border-color: var(--line-strong); border-style: solid; border-width: 0; }
.crop-tl { top: 0; left: 0; border-top-width: 1.5px; border-left-width: 1.5px; }
.crop-tr { top: 0; right: 0; border-top-width: 1.5px; border-right-width: 1.5px; }
.crop-bl { bottom: 0; left: 0; border-bottom-width: 1.5px; border-left-width: 1.5px; }
.crop-br { bottom: 0; right: 0; border-bottom-width: 1.5px; border-right-width: 1.5px; }
.hero-caption {
    display: flex; justify-content: space-between; gap: 12px;
    margin-top: 10px;
    font-family: var(--font-mono); font-size: 11px; letter-spacing: .06em; text-transform: uppercase;
    color: var(--muted);
}
.hero-caption span:first-child { color: var(--accent); font-weight: 600; }

.tag-bar {
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
    margin-bottom: 32px;
    padding: 12px;
    background: var(--paper-2);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
}
.tag-rack { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; list-style: none; }
.tag-bar-note {
    flex-shrink: 0;
    font-family: var(--font-mono); font-size: 11px; letter-spacing: .06em; text-transform: uppercase;
    color: var(--muted);
}

.layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 40px;
    align-items: start;
}
.feed { display: flex; flex-direction: column; gap: 24px; min-width: 0; }
.empty-state { padding: 40px; text-align: center; color: var(--muted); font-style: italic; }

.thesis {
    position: relative;
    margin-top: 72px;
    padding: clamp(40px, 7vw, 80px) clamp(20px, 5vw, 64px);
    text-align: center;
    background: var(--paper-2);
    border-top: 1px solid var(--line-strong);
    border-bottom: 1px solid var(--line-strong);
}
.thesis::before, .thesis::after {
    content: "";
    position: absolute; left: 0; right: 0; height: 3px;
    border-top: 1px solid var(--line);
}
.thesis::before { top: 3px; }
.thesis::after { bottom: 0; }
.thesis-label { margin-bottom: 20px; letter-spacing: .14em; }
.thesis-label .dot { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); }
.thesis-quote {
    max-width: 22em; margin: 0 auto 20px;
    font-family: var(--font-display);
    font-size: clamp(1.75rem, 3.6vw, 2.75rem);
    line-height: 1.2; letter-spacing: -.015em;
    text-wrap: balance;
}
.thesis-cite { display: block; font-style: normal; font-size: 1.05rem; color: var(--ink-2); }
.thesis-actions { margin-top: 28px; }

.pagination {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding-top: 8px;
}
.page-number { font-family: var(--font-mono); font-size: 12px; color: var(--muted); }

/* 6. Cards
   -------------------------------------------------------------------------- */
.post-card, .post-card-lead {
    transition: box-shadow .2s, border-color .2s;
}
.post-card:hover, .post-card-lead:hover { box-shadow: var(--shadow-lift); border-color: var(--line-strong); }

.post-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 24px;
    padding: clamp(20px, 3vw, 32px);
}
.post-card.has-image { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); align-items: center; }
.post-card.has-image.is-flipped .post-card-media { order: -1; }

.post-card-body { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.post-card-title { font-size: clamp(1.3rem, 2.2vw, 1.55rem); font-weight: 500; line-height: 1.25; text-wrap: pretty; }
.post-card-excerpt { color: var(--ink-2); line-height: 1.6; }
.post-card-foot {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px;
    margin-top: 4px;
}
.hash-tags { display: flex; flex-wrap: wrap; gap: 10px; font-family: var(--font-mono); font-size: 11px; color: var(--muted); }

.post-card-media {
    position: relative; display: block;
    overflow: hidden;
    aspect-ratio: 4 / 3;
    border-radius: var(--radius);
    background: var(--paper-3);
}
.post-card-media img { width: 100%; height: 100%; object-fit: cover; transition: transform .6s ease; }
.post-card:hover .post-card-media img { transform: scale(1.03); }
.fig-tag {
    position: absolute; left: 8px; bottom: 8px;
    padding: 2px 7px;
    font-family: var(--font-mono); font-size: 10px; font-weight: 600; letter-spacing: .08em;
    color: var(--ink);
    background: color-mix(in srgb, var(--card) 90%, transparent);
    border-radius: 4px;
}

.post-card-lead { padding: clamp(22px, 3.5vw, 40px); border-top: 3px solid var(--accent); }
.post-card-lead > .meta-row-split {
    padding-bottom: 12px; margin-bottom: 18px;
    border-bottom: 1px solid var(--line);
}
.meta-tag { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-weight: 500; }
.meta-tag .icon { color: var(--accent); width: 15px; height: 15px; }
.lead-title {
    font-size: clamp(1.7rem, 3.4vw, 2.2rem);
    font-weight: 600; line-height: 1.15; letter-spacing: -.01em;
    margin-bottom: 20px;
    text-wrap: balance;
}
.lead-media {
    display: block; overflow: hidden;
    margin-bottom: 20px;
    aspect-ratio: 16 / 8;
    border-radius: var(--radius);
    background: var(--paper-3);
}
.lead-media img { width: 100%; height: 100%; object-fit: cover; }
.abstract {
    margin-bottom: 20px;
    padding: 16px 20px;
    background: var(--paper-2);
    border-left: 3px solid var(--accent);
    border-radius: 0 var(--radius) var(--radius) 0;
}
.abstract .label { margin-bottom: 6px; }
.abstract p { font-style: italic; font-size: 1.1rem; line-height: 1.6; }
.tag-tokens { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-tokens a {
    padding: 3px 9px;
    font-family: var(--font-mono); font-size: 11px; font-weight: 500;
    background: var(--paper-3);
    border-radius: 4px;
}
.tag-tokens a:hover { background: var(--accent-soft); }

/* 7. Sidebar
   -------------------------------------------------------------------------- */
.sidebar {
    position: sticky; top: calc(var(--header-h) + 32px);
    display: flex; flex-direction: column; gap: 24px;
}
.widget {
    padding: 20px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}
.widget-head {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    padding-bottom: 10px; margin-bottom: 14px;
    border-bottom: 1px solid var(--line);
}
.author-row { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.author-name { font-family: var(--font-display); font-size: 1.2rem; font-weight: 600; }
.author-bio { font-size: .95rem; line-height: 1.55; color: var(--ink-2); margin-bottom: 10px; }

.social-links { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 0; padding: 0; list-style: none; }
.social-links:not(:has(li)) { display: none; }
.social-links a {
    display: grid; place-items: center;
    width: 34px; height: 34px;
    color: var(--ink-2);
    background: var(--paper-2);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    transition: color .15s, border-color .15s, background-color .15s;
}
.social-links a:hover { color: var(--accent); border-color: var(--accent); background: var(--card); }

.spec-list { margin: 0; font-family: var(--font-mono); font-size: 12px; }
.spec-list > div {
    display: flex; justify-content: space-between; gap: 12px;
    padding: 7px 0;
    border-bottom: 1px dashed var(--line);
}
.spec-list > div:last-child { border-bottom: 0; }
.spec-list dt { color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.spec-list dd { margin: 0; color: var(--ink); text-align: right; }
.spec-list dd a { color: var(--accent); }

.mini-list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; }
.mini-item {
    display: block;
    padding: 10px 12px;
    background: var(--paper-2);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    transition: border-color .15s;
}
.mini-item:hover { border-color: var(--accent); color: inherit; }
.mini-meta {
    display: flex; justify-content: space-between;
    font-family: var(--font-mono); font-size: 10px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 4px;
}
.mini-title { display: block; font-size: .98rem; font-weight: 500; line-height: 1.35; }
.mini-item:hover .mini-title { color: var(--accent); }
.widget-cta { background: var(--paper-2); }
.widget-cta p { font-style: italic; margin-bottom: 12px; color: var(--ink-2); }

/* 8. Archive
   -------------------------------------------------------------------------- */
.archive-header {
    display: flex; align-items: center; gap: 32px;
    margin-bottom: 24px;
    padding: clamp(24px, 4vw, 40px);
}
.archive-copy { flex: 1; min-width: 0; }
.archive-title { font-size: clamp(2rem, 4vw, 2.75rem); font-weight: 400; letter-spacing: -.02em; margin: 8px 0 10px; }
.archive-desc { max-width: 40em; font-size: 1.1rem; font-style: italic; color: var(--ink-2); margin-bottom: 12px; }
.archive-image { width: 220px; aspect-ratio: 4/3; object-fit: cover; border-radius: var(--radius); }

.error-panel { max-width: 720px; margin: 40px auto; padding: clamp(24px, 5vw, 48px); }
.error-panel .scope { margin-bottom: 28px; }
.error-panel .archive-desc { margin-bottom: 24px; }

/* 9. Article
   -------------------------------------------------------------------------- */
.canvas, .canvas-grid {
    display: grid;
    grid-template-columns:
        [full-start] minmax(var(--gutter), 1fr)
        [wide-start] minmax(0, calc((var(--wide) - var(--content)) / 2))
        [main-start] min(var(--content), calc(100% - var(--gutter) * 2))
        [main-end] minmax(0, calc((var(--wide) - var(--content)) / 2))
        [wide-end] minmax(var(--gutter), 1fr) [full-end];
}
.canvas > *, .canvas-grid > * { grid-column: main-start / main-end; min-width: 0; }
.canvas-wide {
    max-width: calc(var(--wide) + var(--gutter) * 2);
    margin-left: auto; margin-right: auto;
    padding: 0 var(--gutter);
}

.article { padding-top: 48px; }
.article-header { margin-bottom: 36px; }
.article-header .meta-row { margin-bottom: 18px; }
.article-title {
    font-size: clamp(2.1rem, 5vw, 3.2rem);
    font-weight: 500; line-height: 1.1; letter-spacing: -.02em;
    margin-bottom: 18px;
    text-wrap: balance;
}
.article-dek { font-size: 1.3rem; font-style: italic; line-height: 1.5; color: var(--ink-2); margin-bottom: 24px; }
.byline {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px;
    padding: 12px 0;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
}
.byline-authors { display: flex; flex-wrap: wrap; gap: 16px; }
.byline-author { display: inline-flex; align-items: center; gap: 8px; font-family: var(--font-mono); font-size: 13px; font-weight: 500; }
.copy-link.is-copied { color: var(--accent); border-color: var(--accent); }

.article-figure { margin: 0 auto 48px; }
.article-figure img { width: 100%; border-radius: var(--radius); }
.article-figure figcaption, .gh-content figcaption {
    margin-top: 10px;
    font-family: var(--font-mono); font-size: 12px; line-height: 1.5;
    color: var(--muted);
}
.fig-no { color: var(--accent); font-weight: 600; letter-spacing: .06em; margin-right: 6px; }

.article-body { position: relative; }

.toc { width: min(var(--content), calc(100% - var(--gutter) * 2)); margin: 0 auto 32px; }
.toc-box {
    padding: 14px 16px;
    background: var(--paper-2);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
}
.toc-box summary { cursor: pointer; list-style: none; display: flex; justify-content: space-between; }
.toc-box summary::-webkit-details-marker { display: none; }
.toc-box summary::after { content: "+"; font-size: 14px; color: var(--muted); }
.toc-box[open] summary::after { content: "−"; }
.toc-list { margin: 12px 0 0; padding: 0; list-style: none; counter-reset: toc; font-size: .95rem; }
.toc-list li { counter-increment: toc; }
.toc-list a {
    display: flex; gap: 10px;
    padding: 5px 0 5px 10px;
    line-height: 1.35;
    color: var(--ink-2);
    border-left: 2px solid var(--line);
}
.toc-list a::before { content: counter(toc, decimal-leading-zero); font-family: var(--font-mono); font-size: 11px; color: var(--muted); padding-top: 3px; }
.toc-list a:hover { color: var(--ink); }
.toc-list a.is-active { color: var(--ink); border-left-color: var(--accent); }
.toc-list a.is-active::before { color: var(--accent); }
.toc-list .toc-h3 a { padding-left: 26px; font-size: .9rem; }
.toc-list .toc-h3 a::before { content: "–"; }

.article-footer { margin-top: 56px; row-gap: 28px; }
.article-tags { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.article-tags .label { margin-right: 6px; }
.author-box { display: flex; gap: 16px; padding: 20px; align-items: flex-start; }
.author-box > div { flex: 1; min-width: 0; }
.author-box .author-bio { margin: 6px 0 0; }
.comments { margin-top: 8px; }

.related { margin-top: 72px; }
.section-head { padding-bottom: 12px; margin-bottom: 20px; border-bottom: 1px solid var(--line); }
.related-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; }
.related-card { display: flex; flex-direction: column; gap: 10px; padding: 16px; }
.related-media { display: block; aspect-ratio: 16/10; overflow: hidden; border-radius: var(--radius); background: var(--paper-3); }
.related-media img { width: 100%; height: 100%; object-fit: cover; }
.related-title { font-size: 1.15rem; line-height: 1.3; }

/* 10. Content & Koenig cards
   -------------------------------------------------------------------------- */
.gh-content { font-size: 1.15rem; line-height: 1.72; counter-reset: section; }
.gh-content > * + * { margin-top: 1.4em; }
.gh-content > [id] { scroll-margin-top: calc(var(--header-h) + 24px); }

.gh-content a { overflow-wrap: anywhere; color: var(--accent); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.gh-content a:hover { color: var(--ink); }

.gh-content > h2 { font-size: 1.9rem; font-weight: 500; letter-spacing: -.01em; margin-top: 2.2em; }
.gh-content > h3 { font-size: 1.45rem; font-weight: 600; margin-top: 1.9em; }
.gh-content > h4 { font-family: var(--font-mono); font-size: .85rem; letter-spacing: .08em; text-transform: uppercase; margin-top: 1.9em; }
.gh-content > h2 + *, .gh-content > h3 + *, .gh-content > h4 + * { margin-top: .6em; }

/* § section numbering on h2 */
.post-template .gh-content > h2 { counter-increment: section; }
.post-template .gh-content > h2::before {
    content: "§" counter(section, decimal-leading-zero);
    display: block;
    margin-bottom: 6px;
    font-family: var(--font-mono); font-size: 12px; font-weight: 600; letter-spacing: .1em;
    color: var(--accent);
}

.gh-content ul, .gh-content ol { padding-left: 1.4em; }
.gh-content li + li { margin-top: .4em; }
.gh-content ul li::marker { color: var(--accent); }
.gh-content ol li::marker { font-family: var(--font-mono); font-size: .85em; color: var(--accent); }

.gh-content hr {
    height: 8px; border: 0; margin: 3em 0;
    background:
        repeating-linear-gradient(90deg, var(--line-strong) 0 1px, transparent 1px 40px) center / 100% 8px no-repeat,
        repeating-linear-gradient(90deg, var(--line) 0 1px, transparent 1px 8px) center / 100% 4px no-repeat;
}

.gh-content blockquote:not([class]) {
    margin-left: 0; margin-right: 0;
    padding: 16px 22px;
    font-style: italic; font-size: 1.2rem;
    background: var(--paper-2);
    border-left: 3px solid var(--accent);
    border-radius: 0 var(--radius) var(--radius) 0;
}
.gh-content blockquote p + p { margin-top: .8em; }
.gh-content .kg-blockquote-alt {
    margin: 2em 0; padding: 0 1em;
    font-family: var(--font-display);
    font-size: clamp(1.5rem, 3vw, 2rem); font-style: normal; line-height: 1.3;
    text-align: center; text-wrap: balance;
    color: var(--ink);
}
.gh-content .kg-blockquote-alt::before {
    content: "";
    display: block; width: 40px; height: 3px;
    margin: 0 auto 20px;
    background: var(--accent);
}

.gh-content code:not(pre code) {
    padding: 2px 6px;
    font-family: var(--font-mono); font-size: .8em; font-weight: 600;
    color: var(--accent);
    background: var(--paper-3);
    border-radius: 4px;
}
.gh-content pre {
    overflow-x: auto;
    padding: 18px 20px;
    font-family: var(--font-mono); font-size: .82rem; line-height: 1.65;
    color: #d8e1ea;
    background: var(--scope-bg);
    border: 1px solid #1e2835;
    border-radius: var(--radius-lg);
    tab-size: 4;
}
.gh-content pre code { font: inherit; background: none; padding: 0; color: inherit; }

.gh-content table:not(.gist table) {
    display: block; overflow-x: auto;
    width: 100%;
    border-collapse: collapse;
    font-family: var(--font-mono); font-size: .85rem;
}
.gh-content th, .gh-content td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
.gh-content th { font-size: .75rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); background: var(--paper-2); }

.gh-content figure { margin-left: 0; margin-right: 0; }
.gh-content img { border-radius: var(--radius); }
.gh-content .kg-width-wide { grid-column: wide-start / wide-end; }
.gh-content .kg-width-full { grid-column: full-start / full-end; }
.gh-content .kg-width-full img { border-radius: 0; width: 100%; }
.gh-content .kg-width-full figcaption { padding: 0 var(--gutter); }
.gh-content .kg-image-card img { margin: 0 auto; }
.gh-content .kg-embed-card { display: flex; flex-direction: column; align-items: center; }

/* callout = "instructor field rule" */
.gh-content .kg-callout-card {
    padding: 16px 20px;
    font-size: 1.02rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
}
.gh-content .kg-callout-card-grey, .gh-content .kg-callout-card-white { background: var(--paper-2); }
.gh-content .kg-callout-card-accent { background: var(--accent); color: var(--on-accent); border-color: transparent; }
.gh-content .kg-callout-card-accent a { color: inherit; }
.gh-content .kg-callout-text strong:first-child { font-family: var(--font-mono); font-size: .85em; letter-spacing: .04em; }

.gh-content .kg-bookmark-container {
    background: var(--card);
    border: 1px solid var(--line) !important;
    border-radius: var(--radius-lg) !important;
    text-decoration: none !important;
    color: var(--ink) !important;
}
.gh-content .kg-bookmark-container:hover { border-color: var(--accent) !important; }
.gh-content .kg-bookmark-title { font-family: var(--font-display); font-size: 1.1rem; font-weight: 600; }
.gh-content .kg-bookmark-description, .gh-content .kg-bookmark-metadata { font-family: var(--font-mono); font-size: 12px; }

/* file card = download block */
.gh-content .kg-file-card-container {
    background: var(--paper-2) !important;
    border: 1px dashed var(--line-strong) !important;
    border-radius: var(--radius-lg) !important;
    text-decoration: none !important;
    color: var(--ink) !important;
}
.gh-content .kg-file-card-container:hover { border-color: var(--accent) !important; border-style: solid !important; }
.gh-content .kg-file-card-title { font-family: var(--font-display); }
.gh-content .kg-file-card-metadata, .gh-content .kg-file-card-filesize { font-family: var(--font-mono); }
.gh-content .kg-file-card-icon { color: var(--accent); }

.gh-content .kg-button-card a.kg-btn {
    font-family: var(--font-mono); font-size: 13px; font-weight: 600; letter-spacing: .04em;
    text-decoration: none;
    border-radius: var(--radius);
}
.gh-content .kg-toggle-card { background: var(--paper-2); border-radius: var(--radius-lg); }
.gh-content .kg-toggle-heading-text { font-family: var(--font-display); }

.gh-content .kg-header-card h2::before, .gh-content .kg-product-card h4::before { content: none !important; }

/* Portfolio: bookmark cards as tool tiles */
.portfolio .gh-content > .tool-grid {
    grid-column: wide-start / wide-end;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
    gap: 20px;
}
.tool-grid .kg-bookmark-card { margin: 0; }
.tool-grid .kg-bookmark-container {
    flex-direction: column-reverse !important;
    height: 100%;
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: box-shadow .2s, border-color .2s, transform .2s;
}
.tool-grid .kg-bookmark-container:hover { box-shadow: var(--shadow-lift); transform: translateY(-2px); }
.tool-grid .kg-bookmark-thumbnail {
    flex: 0 0 auto !important;
    width: 100%; min-width: 0 !important; max-height: none !important;
    aspect-ratio: 16 / 9;
    background: var(--paper-3);
    border-bottom: 1px solid var(--line);
}
.tool-grid .kg-bookmark-thumbnail img { border-radius: 0; }
.tool-grid .kg-bookmark-content { flex: 1 1 auto; padding: 18px 20px; }
.tool-grid .kg-bookmark-title { font-size: 1.25rem; line-height: 1.25; }
.tool-grid .kg-bookmark-title::after { content: " ↗"; font-family: var(--font-mono); font-size: .8em; color: var(--accent); }
.tool-grid .kg-bookmark-description {
    margin-top: 8px;
    display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
    max-height: none;
    color: var(--ink-2);
}
.tool-grid .kg-bookmark-metadata { margin-top: 14px; color: var(--muted); }

/* 11. Diagnostic components (use inside an HTML card; see README)
   -------------------------------------------------------------------------- */
.scope {
    padding: 14px 16px;
    font-family: var(--font-mono); font-size: 11px;
    color: #94a3b8;
    background: var(--scope-bg);
    border: 1px solid #1e2835;
    border-radius: var(--radius-lg);
    box-shadow: inset 0 0 40px rgba(63, 217, 232, .05);
}
.gh-content .scope { font-size: 11px; line-height: 1.5; }
.scope-head, .scope-foot {
    display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 16px;
}
.scope-head { padding-bottom: 8px; margin-bottom: 8px; border-bottom: 1px solid #1e2835; }
.scope-foot { padding-top: 8px; margin-top: 8px; border-top: 1px solid #1e2835; }
.scope .ch1 { color: var(--trace-1); font-weight: 600; }
.scope .ch2 { color: var(--trace-2); font-weight: 600; }
.scope .pass { color: var(--pass); font-weight: 600; }
.scope svg {
    width: 100%; height: 120px;
    background:
        linear-gradient(var(--scope-grid) 1px, transparent 1px) 0 0 / 10% 25%,
        linear-gradient(90deg, var(--scope-grid) 1px, transparent 1px) 0 0 / 10% 25%;
    border-radius: 4px;
}
.scope-compact svg { height: 80px; }
.scope svg path { fill: none; vector-effect: non-scaling-stroke; }
.scope .trace-1 { stroke: var(--trace-1); stroke-width: 2; filter: drop-shadow(0 0 3px rgba(255, 165, 61, .6)); }
.scope .trace-2 { stroke: var(--trace-2); stroke-width: 2; stroke-dasharray: 5 3; filter: drop-shadow(0 0 3px rgba(63, 217, 232, .6)); }

.ascii {
    padding: 16px 18px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
}
.ascii .label { display: flex; padding-bottom: 8px; margin-bottom: 8px; border-bottom: 1px solid var(--line); }
.gh-content .ascii pre {
    margin: 0; padding: 0;
    color: var(--ink); background: none; border: 0;
    font-size: .78rem;
}

.spec-table {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: var(--line);
    gap: 1px;
}
.spec-table > div { padding: 12px 14px; background: var(--card); }
.spec-table dt, .spec-table .k { font-family: var(--font-mono); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.spec-table dd, .spec-table .v { margin: 2px 0 0; font-family: var(--font-mono); font-size: 15px; font-weight: 600; color: var(--ink); }

/* 12. Footer
   -------------------------------------------------------------------------- */
.site-footer {
    margin-top: 80px;
    background: var(--paper-2);
    border-top: 1px solid var(--line);
}
.footer-grid {
    display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 40px;
    padding-top: 48px; padding-bottom: 40px;
}
.footer-title { font-family: var(--font-display); font-size: 1.3rem; font-weight: 600; margin-bottom: 8px; }
.footer-about p { font-size: .95rem; color: var(--ink-2); margin-bottom: 10px; max-width: 30em; }
.footer-col .label { margin-bottom: 12px; }
.footer-nav .nav-list { margin: 0; padding: 0; list-style: none; counter-reset: sect; }
.footer-nav li { counter-increment: sect; padding: 4px 0; }
.footer-nav a { display: inline-flex; gap: 10px; font-size: .98rem; color: var(--ink-2); }
.footer-nav a::before { content: "§" counter(sect, decimal-leading-zero); font-family: var(--font-mono); font-size: 11px; color: var(--muted); padding-top: 4px; }
.footer-nav a:hover { color: var(--accent); }
.footer-bottom {
    display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px;
    padding-top: 16px; padding-bottom: 24px;
    font-family: var(--font-mono); font-size: 11px; letter-spacing: .04em;
    color: var(--muted);
    border-top: 1px dashed var(--line-strong);
}
.footer-bottom a { color: var(--ink-2); }

/* 13. Responsive
   -------------------------------------------------------------------------- */
@media (min-width: 1560px) {
    /* TOC moves into the right margin, clear of wide cards */
    .toc {
        position: absolute; top: 0; bottom: 0;
        left: calc(50% + var(--wide) / 2 + 32px);
        width: 200px;
        margin: 0;
    }
    .toc-box {
        position: sticky; top: calc(var(--header-h) + 40px);
        padding: 0; background: none; border: 0;
    }
    .toc-box summary { pointer-events: none; }
    .toc-box summary::after { content: none; }
}

@media (max-width: 1100px) {
    .search-label, .search-btn kbd { display: none; }
    .layout { grid-template-columns: minmax(0, 1fr) 280px; gap: 28px; }
}

@media (max-width: 960px) {
    .nav-toggle { display: block; }
    .site-nav {
        display: none;
        position: absolute; left: 0; right: 0; top: calc(var(--header-h) + 8px);
        padding: 12px var(--gutter) 20px;
        background: var(--paper);
        border-bottom: 1px solid var(--line);
        box-shadow: 0 12px 24px -16px rgba(0, 0, 0, .2);
    }
    .nav-open .site-nav { display: block; }
    .site-nav .nav-list { flex-direction: column; align-items: stretch; gap: 4px; }
    .site-nav a { padding: 10px 12px; font-size: 1.05rem; }

    .layout { grid-template-columns: minmax(0, 1fr); }
    .sidebar { position: static; display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }

    .hero { grid-template-columns: minmax(0, 1fr); gap: 28px; }
    .hero-image { aspect-ratio: 16 / 9; }

    .tag-bar { flex-direction: column; align-items: flex-start; }
    .tag-bar-note { display: none; }

    .footer-grid { grid-template-columns: 1fr 1fr; }
    .footer-about { grid-column: 1 / -1; }
    .related-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 680px) {
    body { font-size: 1rem; }
    .header-inner { gap: 12px; }
    .brand-title {
        display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
        overflow: hidden;
        white-space: normal;
        font-size: 1.02rem; line-height: 1.15;
        text-wrap: balance;
    }
    .hide-sm { display: none; }
    .brand-tagline { display: none; }
    .page-pad { padding-top: 24px; }

    .post-card.has-image { grid-template-columns: minmax(0, 1fr); }
    .post-card.has-image .post-card-media { order: -1; aspect-ratio: 16 / 9; }

    .tag-rack { flex-wrap: nowrap; overflow-x: auto; width: 100%; padding-bottom: 4px; scrollbar-width: none; }
    .tag-rack li { flex-shrink: 0; }

    .archive-header { flex-direction: column; align-items: flex-start; }
    .archive-image { width: 100%; }

    .gh-content { font-size: 1.08rem; }
    .gh-content > h2 { font-size: 1.6rem; }
    .footer-grid, .related-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 420px) {
    .hide-xs { display: none; }
    .brand-title { font-size: .95rem; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
    html { scroll-behavior: auto; }
}
