/* "Ledger" Theme — a bookkeeper's account book.
 *
 * Clean is this site's editorial era — a magazine page. This is the other
 * document that the index's audits, budgets, and mineral-summary trackers
 * actually produce: a ruled ledger sheet, two pens deep — blue ink for what
 * was entered, a red stamp for what was checked.
 *
 * Costs nothing to ship: Inter and JetBrains Mono are both already in the
 * base font request (JetBrains Mono carries headings here instead of body
 * text), and the ledger's ruled lines are a CSS gradient — no image asset.
 *
 * Contrast: ink on sheet is 16.1:1. --stamp (6.0:1), --entry (8.7:1) and
 * --muted (6.4:1) all clear AA at body size with real margin. --stamp-light
 * is decorative only (hover borders, the status dot, the reading-progress
 * bar) and is never used for text.
 *
 * Every rule is scoped under `body.theme-ledger`.
 */

body.theme-ledger {
    --sheet:       #F7F5EE; /* ledger paper                                    */
    --panel:       #FCFBF6; /* a shade up from the sheet — cards, chips        */
    --entry:       #1E4A63; /* entry ink (blue pen) — headings, active states  */
    --stamp:       #A23B2C; /* the checker's stamp (red pen) — links, badges   */
    --stamp-light: #BD6748; /* stamp, diluted — hover borders, dots, decoration only */
    --tint:        #F1E2DC; /* pale stamp wash — badge & chip fills            */
    --rule:        rgba(26, 25, 23, 0.16); /* hairlines, column rules — never text */
    --ink:         #1A1917; /* body text, the whole voice                      */
    --muted:       #5C5952; /* labels / secondary text (WCAG AA 6.4:1 on sheet) */

    background-color: var(--sheet);
    /* Faint ruled lines, like the printed rows of an account-book page.
       Never used for text — decoration only. */
    background-image: repeating-linear-gradient(to bottom,
        transparent 0 31px, rgba(30, 74, 99, 0.07) 31px 32px);
    color: var(--ink);
    font-family: 'Inter', sans-serif;
    margin: 0;
    padding: 0;
    line-height: 1.6;
}

body.theme-ledger .container {
    width: 90%;
    max-width: 1200px;
    margin: 40px auto;
    background-color: transparent;
    border: none;
    padding: 0;
}

/* Hide retro elements */
body.theme-ledger .ticker,
body.theme-ledger .retro-img,
body.theme-ledger .hit-counter,
body.theme-ledger hr {
    display: none;
}

body.theme-ledger .blink {
    animation: none;
    color: var(--stamp);
    font-weight: 600;
    font-size: 0.85em;
    text-transform: uppercase;
    letter-spacing: 1px;
    background: var(--tint);
    padding: 2px 6px;
    border-radius: 2px;
}

/* Typography */
body.theme-ledger h1,
body.theme-ledger h2,
body.theme-ledger h3 {
    font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
    color: var(--entry);
    text-shadow: none;
    text-align: left;
    margin-top: 40px;
    margin-bottom: 20px;
    font-weight: 700;
    letter-spacing: -0.015em;
}

body.theme-ledger h1 {
    font-size: clamp(2.6rem, 5vw, 3.4rem);
    line-height: 1.04;
    margin-bottom: 10px;
    margin-top: 20px;
    letter-spacing: -0.03em;
}

/* All-caps letterspaced kicker labels (TypeMatch-style section eyebrows) */
body.theme-ledger .kicker {
    font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.72rem;
    font-weight: 500;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--stamp);
    margin: 0 0 10px;
}

/* A double rule, the way a ledger closes out a total. */
body.theme-ledger h2 {
    font-size: 2rem;
    border-bottom: 4px double var(--stamp);
    padding-bottom: 8px;
    margin-top: 60px;
}

body.theme-ledger h3 {
    font-size: 1.4rem;
}

body.theme-ledger .center {
    text-align: left;
    max-width: 800px;
}

body.theme-ledger .center p {
    max-width: 700px;
    margin-bottom: 1.8rem;
    font-size: 1.05rem;
    line-height: 1.6;
}

/* Small "views are my own" disclaimer, tucked under the intro paragraph */
body.theme-ledger .center p.disclaimer {
    font-size: 0.8rem;
    color: var(--muted);
    margin-top: -0.5rem;
    margin-bottom: 1.6rem;
    line-height: 1.5;
}

/* Footnote under the projects table (e.g. the "may be offline" note) */
body.theme-ledger .table-note {
    font-size: 0.78rem;
    color: var(--muted);
    margin-top: 14px;
    line-height: 1.4;
}

/* Links */
body.theme-ledger a {
    color: var(--stamp);
    text-decoration: none;
    border-bottom: 1px solid var(--stamp-light);
    transition: all 0.2s ease;
    font-weight: 500;
}

body.theme-ledger a:hover {
    background-color: transparent;
    color: var(--entry);
    border-bottom-color: var(--entry);
}

body.theme-ledger a:visited {
    color: var(--stamp);
}

/* Tables -> Ledger Grid */
body.theme-ledger table {
    width: 100%;
    border-collapse: collapse;
    border: none;
    margin-top: 20px;
}

body.theme-ledger th,
body.theme-ledger td {
    border: none;
    border-bottom: 1px solid var(--rule);
    padding: 16px 10px;
    text-align: left;
    vertical-align: top;
}

body.theme-ledger th {
    background-color: transparent;
    color: var(--muted);
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

/* Links cell — Case Study | Website | Code, separated by muted pipes */
body.theme-ledger td.links {
    color: var(--muted);
}

/* Row hover: the projects table is the densest surface on the site and gave
   zero pointer feedback. Desktop only — there is no hover on the card layout. */
@media (hover: hover) and (min-width: 769px) {
    body.theme-ledger tr.project-item {
        transition: background-color 0.15s ease;
    }
    body.theme-ledger tr.project-item:hover {
        background-color: var(--tint);
    }
}

/* First cell: bold friendly name on top, description as a subheading under it */
body.theme-ledger .proj-name {
    display: block;
    font-weight: 700;
}
/* Where a case study exists the name is the link to it: entry-blue, no resting
   underline (the row is dense enough), stamp-red underline on hover/focus. */
body.theme-ledger .proj-name a {
    color: var(--entry);
    font-weight: 700;
    border-bottom: 1px solid transparent;
}
body.theme-ledger .proj-name a:hover,
body.theme-ledger .proj-name a:focus-visible {
    color: var(--stamp);
    border-bottom-color: var(--stamp-light);
}
body.theme-ledger .proj-desc {
    display: block;
    margin-top: 3px;
    font-family: 'Inter', sans-serif;
    font-weight: 400;
    font-size: 0.8rem;
    color: var(--muted);
    line-height: 1.4;
}

/* Case-study header metadata: Source / Website */
body.theme-ledger .cs-meta {
    font-size: 0.85rem;
    color: var(--muted);
    margin-top: 10px;
    line-height: 1.6;
    overflow-wrap: anywhere;
}

/* Case-study screenshot gallery (desktop + mobile pairs) */
body.theme-ledger .cs-shots-note {
    font-size: 0.8rem;
    color: var(--muted);
    margin: 0 0 24px 0;
}
body.theme-ledger .cs-shots {
    display: flex;
    flex-direction: column;
    gap: 42px;
    margin-top: 4px;
}
body.theme-ledger .cs-shot {
    margin: 0;
}
body.theme-ledger .cs-shot-row {
    display: flex;
    gap: 20px;
    align-items: flex-end;
    flex-wrap: wrap;
}
body.theme-ledger .shot-frame {
    display: block;
    border: 1px solid var(--rule);
    overflow: hidden;
    background: var(--panel);
    box-shadow: 0 2px 0 rgba(26, 25, 23, 0.14);
    transition: border-color 0.15s ease;
}
body.theme-ledger .shot-frame:hover {
    border-color: var(--stamp-light);
}
body.theme-ledger .shot-frame img {
    display: block;
    width: 100%;
    height: auto;
}
body.theme-ledger .shot-frame.desktop {
    flex: 1 1 420px;
    min-width: 0;
    border-radius: 2px;
}
body.theme-ledger .shot-frame.mobile {
    flex: 0 0 auto;
    width: 180px;
    border-radius: 2px;
}
body.theme-ledger .cs-shot figcaption {
    margin-top: 14px;
    font-size: 0.85rem;
    color: var(--muted);
    line-height: 1.5;
}
@media screen and (max-width: 768px) {
    body.theme-ledger .cs-shot-row {
        flex-direction: column;
        align-items: center;
        gap: 20px;
    }
    body.theme-ledger .shot-frame.desktop {
        width: 100%;
        max-width: 100%;
        flex-basis: auto;
    }
    body.theme-ledger .shot-frame.mobile {
        width: 100%;
        max-width: 320px;
        margin: 0 auto;
    }
}

/* Tighter spacing for the Selected Writings lists (scoped to the accordions) */
body.theme-ledger details.accordion-section ul li {
    padding: 4px 0;
    line-height: 1.4;
}

/* Sections */
body.theme-ledger .projects-section {
    border: none !important; /* Override inline styles */
    padding: 0;
    margin-bottom: 40px;
}

/* Lists */
body.theme-ledger ul {
    list-style-type: none;
    padding: 0;
}

body.theme-ledger ul li {
    padding: 12px 0;
    border-bottom: 1px solid var(--rule);
    line-height: 1.5;
}

body.theme-ledger ul li i {
    color: var(--muted);
    font-style: normal;
    font-size: 0.9em;
}

body.theme-ledger .industry-note {
    display: block;
    margin-top: 6px;
    padding-left: 14px;
    border-left: 2px solid var(--rule);
    font-size: 0.92em;
    color: var(--muted);
    line-height: 1.45;
}
body.theme-ledger .note-label { font-weight: 600; }

/* Accordions */
body.theme-ledger details.accordion-section summary {
    cursor: pointer;
    list-style: none;
    outline: none;
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--rule);
    padding-bottom: 10px;
    margin-top: 60px;
    margin-bottom: 20px;
}

body.theme-ledger details.accordion-section summary::-webkit-details-marker {
    display: none;
}

body.theme-ledger details.accordion-section summary::before {
    content: none !important;
}

body.theme-ledger details.accordion-section summary h2 {
    margin: 0;
    border-bottom: none;
    padding-bottom: 0;
    flex-grow: 1;
}

body.theme-ledger details.accordion-section summary::after {
    content: "↓";
    font-size: 1.5rem;
    color: var(--stamp); /* ≥3:1 against the page for a discernible expand/collapse control */
    transition: transform 0.3s ease;
}

body.theme-ledger details[open].accordion-section summary::after {
    transform: rotate(180deg);
}

body.theme-ledger details[open].accordion-section {
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* The theme switcher in ledger view (position is set here now that the retro
   stylesheet no longer supplies it globally). */
body.theme-ledger #theme-toggle {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 1000;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background-color: var(--entry);
    color: #FFF;
    border: none;
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    padding: 10px 18px;
    border-radius: 2px;
    font-size: 0.9rem;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(26, 25, 23, 0.18);
    transition: background-color 0.2s, box-shadow 0.2s;
}

body.theme-ledger #theme-toggle:hover {
    background-color: var(--stamp);
    box-shadow: 0 6px 16px rgba(26, 25, 23, 0.24);
}

body.theme-ledger #theme-toggle .tt-caret {
    font-size: 0.7em;
    opacity: 0.85;
    transition: transform 0.2s ease;
}
body.theme-ledger #theme-toggle[aria-expanded="true"] .tt-caret {
    transform: rotate(180deg);
}

/* Theme-picker popover */
body.theme-ledger .theme-menu {
    position: fixed;
    top: 62px;
    right: 16px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 220px;
    padding: 8px;
    background: var(--panel);
    border: 1px solid var(--rule);
    border-radius: 2px;
    box-shadow: 0 16px 40px rgba(26, 25, 23, 0.20);
    animation: fadeIn 0.16s ease-in-out;
}
body.theme-ledger .theme-menu[hidden] { display: none; }

body.theme-ledger .theme-menu-item {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 1px;
    width: 100%;
    padding: 10px 12px;
    background: transparent;
    border: none;
    border-radius: 2px;
    font-family: 'Inter', sans-serif;
    color: var(--ink);
    text-align: left;
    cursor: pointer;
    transition: background-color 0.15s ease;
}
body.theme-ledger .theme-menu-item:hover { background: var(--tint); }
body.theme-ledger .theme-menu-item .tm-name { font-weight: 600; font-size: 0.95rem; }
body.theme-ledger .theme-menu-item .tm-hint {
    font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.68rem;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--muted);
}
body.theme-ledger .theme-menu-item[aria-checked="true"] {
    background: var(--tint);
}
body.theme-ledger .theme-menu-item[aria-checked="true"] .tm-name { color: var(--entry); }
body.theme-ledger .theme-menu-item[aria-checked="true"] .tm-name::after {
    content: "  ✓";
    color: var(--stamp);
}

/* Mobile Responsiveness for Ledger Theme */
@media screen and (max-width: 768px) {
    body.theme-ledger .container {
        width: 100%;
        margin: 0 auto;
        /* bottom padding so the list clears the fixed theme toggle, plus the
           iPhone home indicator (needs viewport-fit=cover in the meta tag) */
        padding: 0 20px calc(96px + env(safe-area-inset-bottom));
        box-sizing: border-box;
    }

    body.theme-ledger h1 {
        font-size: 2.2rem;
    }

    body.theme-ledger h2 {
        font-size: 1.6rem;
    }

    /* Transform tables into stacked cards */
    body.theme-ledger table,
    body.theme-ledger tbody,
    body.theme-ledger tr,
    body.theme-ledger th,
    body.theme-ledger td {
        display: block;
        width: 100%;
        box-sizing: border-box;
    }

    body.theme-ledger tr {
        margin-bottom: 16px;
        border-bottom: 2px solid var(--rule);
    }

    body.theme-ledger th {
        display: none; /* Hide headers, the data is self-explanatory in card layout */
    }

    body.theme-ledger td {
        border-bottom: none;
        padding: 4px 0;
    }

    /* The first cell (Policy Question) acts as the card header */
    body.theme-ledger td:first-child {
        font-weight: 600;
        font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
        font-size: 1.25rem;
        color: var(--entry);
        padding-bottom: 2px;
        line-height: 1.3;
    }

    /* Hide the column-header row in card view */
    body.theme-ledger tr:not(.project-item) {
        display: none;
    }

    /* Long repo names / URLs wrap instead of forcing width */
    body.theme-ledger td {
        overflow-wrap: anywhere;
    }

    /* Compact card body: the links row on its own line, then the status chip. */
    body.theme-ledger td.links {
        display: block;
        padding: 4px 0;
    }
    body.theme-ledger td:nth-child(3) {
        display: inline;
        padding: 0;
        font-size: 0.85rem;
        color: var(--muted);
    }

    /* Ensure touch targets for links are >= 44px */
    body.theme-ledger ul li {
        padding: 16px 0; /* Larger padding for touch */
    }

    /* Keep underlines on content links so they aren't distinguished by color
       alone (WCAG 1.4.1). Only the table's links row drops the underline — its
       dedicated column and pipe separators carry the structure there. */
    body.theme-ledger a {
        display: inline-block;
        padding: 4px 0; /* vertical touch area */
    }

    /* Space the pipe separators in the links row for easier tapping */
    body.theme-ledger td.links a {
        padding: 4px 6px;
        border-bottom: none;
    }
    body.theme-ledger td.links a:first-child {
        padding-left: 0;
    }

    /* Reposition and scale toggle button for mobile */
    body.theme-ledger #theme-toggle {
        top: auto;
        bottom: calc(20px + env(safe-area-inset-bottom));
        right: 20px;
        padding: 12px 24px; /* Ensure touch target >= 44px */
        font-size: 1rem;
        box-shadow: 0 4px 16px rgba(26, 25, 23, 0.28);
    }
    body.theme-ledger .theme-menu {
        top: auto;
        bottom: calc(74px + env(safe-area-inset-bottom));
        right: 20px;
        left: 20px;
        min-width: 0;
    }
}

/* Headshot & Socials (Ledger) — a stamped-seal ring around the portrait */
body.theme-ledger .headshot {
    border-radius: 50%;
    border: 3px solid var(--stamp);
    outline: 1px solid var(--sheet);
    outline-offset: -6px;
    box-shadow: none;
    margin-bottom: 24px;
    margin-top: 10px;
    width: 120px;
    height: 120px;
    object-fit: cover;
}

body.theme-ledger .social-links {
    margin: 20px 0 40px 0;
    display: flex;
    gap: 16px;
}

body.theme-ledger .social-links a {
    color: var(--entry);
    border: none;
    padding: 8px; /* Touch target */
    border-radius: 50%;
    background-color: var(--tint);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

body.theme-ledger .social-links a:hover {
    color: #FFF;
    background-color: var(--stamp);
}

/* Filter Buttons (Ledger) */
body.theme-ledger .filter-bar {
    background: transparent;
    border: none;
    padding: 0;
    margin-bottom: 30px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

body.theme-ledger .filter-btn {
    background-color: var(--panel);
    color: var(--ink);
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    font-weight: 500;
    border: 1px solid var(--rule);
    border-radius: 2px;
    padding: 12px 16px;
    cursor: pointer;
    transition: all 0.2s ease;
}

body.theme-ledger .filter-btn:focus-visible,
body.theme-ledger #theme-toggle:focus-visible,
body.theme-ledger details.accordion-section summary:focus-visible,
body.theme-ledger a:focus-visible {
    outline: 3px solid var(--stamp);
    outline-offset: 2px;
}

body.theme-ledger .filter-btn:hover {
    border-color: var(--stamp-light);
    color: var(--stamp);
    background-color: var(--tint);
}

body.theme-ledger .filter-btn.active {
    background-color: var(--entry);
    color: #FFF;
    border-color: var(--entry);
}

/* Desktop refinements (ledger): tighter spacing, smaller text, thicker delineation.
   Scoped to >=769px so the mobile card layout is untouched. */
@media screen and (min-width: 769px) {
    body.theme-ledger {
        font-size: 16px;
        line-height: 1.55;
    }
    body.theme-ledger .container { margin: 28px auto; }

    body.theme-ledger h2 {
        font-size: 1.75rem;
        margin-top: 48px;
        margin-bottom: 14px;
        padding-bottom: 6px;
        border-bottom: 4px double var(--stamp);
    }
    body.theme-ledger h3 { font-size: 1.2rem; margin-top: 30px; margin-bottom: 10px; }

    body.theme-ledger .center p {
        font-size: 1rem;
        line-height: 1.6;
        margin-bottom: 1.2rem;
    }

    /* Border diet (F6): 1px hairlines only between rows, whitespace elsewhere */
    body.theme-ledger th,
    body.theme-ledger td {
        padding: 12px 10px;
        font-size: 0.94rem;
        border-bottom: 1px solid var(--rule);
    }
    body.theme-ledger th { font-size: 0.72rem; }

    body.theme-ledger ul li {
        padding: 9px 0;
        font-size: 0.95rem;
        border-bottom: 1px solid var(--rule);
    }

    body.theme-ledger details.accordion-section summary {
        margin-top: 48px;
        border-bottom: 1px solid var(--rule);
    }

    body.theme-ledger .filter-bar { margin-bottom: 20px; }
    body.theme-ledger .filter-btn { font-size: 0.82rem; padding: 8px 14px; }
    body.theme-ledger .social-links { margin: 16px 0 28px 0; }

    /* Keep the Links, Status and (now friendly) date columns on a single line;
       only the first column (the question) is allowed to wrap. */
    body.theme-ledger th:not(:first-child),
    body.theme-ledger td:not(:first-child) {
        white-space: nowrap;
    }
}

/* Mobile compaction: with sections collapsed by default, the intro + both
   section headers + footer should fit within a single phone viewport.
   Placed last so it wins over the base headshot/social-links rules. */
@media screen and (max-width: 768px) {
    body.theme-ledger h1 {
        font-size: 1.8rem;
        margin-top: 10px;
        margin-bottom: 6px;
    }

    /* The intro is the first thing a phone visitor reads — don't shrink it to
       0.9rem/1.4 just to win vertical space. */
    body.theme-ledger .center p {
        font-size: 0.95rem;
        line-height: 1.5;
        margin-bottom: 0.7rem;
    }

    body.theme-ledger .social-links {
        margin: 8px 0 14px 0;
    }

    body.theme-ledger h2 {
        font-size: 1.5rem;
    }

    body.theme-ledger h3 {
        margin-top: 16px;
        margin-bottom: 8px;
    }

    body.theme-ledger details.accordion-section summary {
        margin-top: 18px;
        margin-bottom: 12px;
    }

    /* Filter chips scroll horizontally rather than being squeezed onto one row:
       at 320px a forced single row cramps them below a comfortable tap size. */
    body.theme-ledger .filter-bar {
        flex-wrap: nowrap;
        justify-content: flex-start;
        gap: 8px;
        overflow-x: auto;
        scroll-snap-type: x proximity;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding-bottom: 2px;
    }
    body.theme-ledger .filter-bar::-webkit-scrollbar { display: none; }
    body.theme-ledger .filter-btn {
        flex: 0 0 auto;
        scroll-snap-align: start;
        padding: 11px 16px;   /* >= 44px tall with the 0.85rem line box */
        font-size: 0.85rem;
        white-space: nowrap;
    }
}

/* ============================================================================
   Ledger components (adapted from Clean v2, REDESIGN-PLAN.md Phase 2): split hero, stat strip,
   /now block, featured cards, table thumbnails, quiet status dot, footer.
   ============================================================================ */

/* --- Hero (single column, editorial) --- */
body.theme-ledger .hero {
    margin-top: 8px;
}
body.theme-ledger .identity {
    display: flex;
    align-items: center;
    gap: 18px;
    margin-bottom: 16px;
}
body.theme-ledger .identity .headshot {
    margin: 0;
    flex: 0 0 auto;
    width: 96px;
    height: 96px;
}
body.theme-ledger .identity-text { min-width: 0; }
body.theme-ledger .identity-text .kicker { margin-bottom: 6px; }
body.theme-ledger .identity-text h1 { margin: 0; }
body.theme-ledger .hero-main > p {
    max-width: 88ch;
    font-size: 1rem;
    line-height: 1.6;
    margin: 0 0 1rem;
}
body.theme-ledger .hero .disclaimer {
    font-size: 0.8rem;
    color: var(--muted);
    line-height: 1.5;
    margin: 0 0 1.2rem;
}

/* --- Featured work — accordion of flagship projects --- */
body.theme-ledger .featured { margin: 12px 0 8px; }
body.theme-ledger .featured .kicker { margin-bottom: 14px; }
body.theme-ledger .feat-accordion { display: flex; flex-direction: column; gap: 10px; }
body.theme-ledger .feat-item {
    background: var(--panel);
    border: 1px solid var(--rule);
    border-radius: 2px;
    overflow: hidden;
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
}
body.theme-ledger .feat-item:hover { border-color: var(--stamp-light); }
body.theme-ledger .feat-item[open] { box-shadow: 0 8px 24px rgba(26, 25, 23, 0.10); }
body.theme-ledger .feat-item summary {
    list-style: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 14px 16px;
}
body.theme-ledger .feat-item summary::-webkit-details-marker { display: none; }
body.theme-ledger .feat-heading { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
body.theme-ledger .feat-name {
    font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--entry);
    line-height: 1.2;
}
body.theme-ledger .feat-q { font-size: 0.85rem; color: var(--muted); line-height: 1.4; }
body.theme-ledger .feat-item summary::after {
    content: "↓";
    flex: 0 0 auto;
    color: var(--stamp);
    font-size: 1.1rem;
    transition: transform 0.3s ease;
}
body.theme-ledger .feat-item[open] summary::after { transform: rotate(180deg); }
body.theme-ledger .feat-panel { padding: 0 16px 16px; }
body.theme-ledger .feat-shot {
    display: block;
    border: 1px solid var(--rule);
    border-radius: 2px;
    overflow: hidden;
    background: var(--tint);
}
body.theme-ledger .feat-shot img { display: block; width: 100%; height: auto; }
body.theme-ledger .feat-links {
    margin: 12px 0 0;
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 0.8rem;
    color: var(--muted);
}

/* --- Table row thumbnails (Barron-style; image or initial placeholder) --- */
body.theme-ledger .proj-thumb {
    float: left;
    width: 72px;
    height: 50px;
    margin: 2px 14px 2px 0;
    border-radius: 2px;
    overflow: hidden;
    background: var(--tint);
    border: 1px solid var(--rule);
    display: flex;
    align-items: center;
    justify-content: center;
}
body.theme-ledger .proj-thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top; display: block; }
body.theme-ledger .proj-thumb[data-initial]::after {
    content: attr(data-initial);
    font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
    font-weight: 700;
    font-size: 1.15rem;
    color: var(--stamp);
}
body.theme-ledger .proj-text { display: block; overflow: hidden; }

/* --- Quiet status dot (F3): LIVE becomes a small stamp-red dot + word --- */
body.theme-ledger .blink {
    animation: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: none;
    padding: 0;
    color: var(--muted);
    font-weight: 600;
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}
body.theme-ledger .blink::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--stamp-light);
    box-shadow: 0 0 0 3px var(--tint);
}

/* --- Footer with a life (F7) --- */
body.theme-ledger .site-footer {
    margin-top: 44px;
    padding-top: 22px;
    border-top: 1px solid var(--rule);
    color: var(--muted);
}
body.theme-ledger .site-footer a { color: var(--stamp); border-bottom-color: var(--rule); }
body.theme-ledger .colophon {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 0.74rem;
    letter-spacing: 0.02em;
    margin: 0 0 12px;
    color: var(--muted);
}
body.theme-ledger .footer-meta {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px 24px;
    margin: 0 0 8px;
    font-size: 0.85rem;
}
body.theme-ledger .footer-links { display: flex; gap: 18px; flex-wrap: wrap; }
body.theme-ledger .footer-thanks { margin: 6px 0 0; font-size: 0.85rem; }

/* --- Desktop: mono metadata for the status column --- */
@media screen and (min-width: 769px) {
    body.theme-ledger td:nth-child(3) {
        font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
        font-size: 0.8rem;
        color: var(--muted);
    }
}

/* --- Mobile tweaks for the new components --- */
@media screen and (max-width: 768px) {
    body.theme-ledger .identity { gap: 14px; }
    body.theme-ledger .identity .headshot { width: 72px; height: 72px; }
    body.theme-ledger .proj-thumb { width: 72px; height: 50px; margin-right: 12px; }
    body.theme-ledger .footer-meta { flex-direction: column; }
}

/* --- Case-study v2: prose measure + prev/next ring (F8) --- */
body.theme-ledger .projects-section p,
body.theme-ledger .projects-section ul { max-width: 72ch; }
body.theme-ledger .cs-kicker { margin: 8px 0 4px; }

/* --- Case-study v3: at-a-glance strip, question lead, related links --- */
body.theme-ledger .cs-tagline {
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--ink);
    margin: 4px 0 18px;
    max-width: 60ch;
}
/* Two-column definition grid. The wrapper <div>s exist so the markup stays valid
   HTML5 grouping; display:contents lets their dt/dd join the parent grid. */
body.theme-ledger .cs-glance {
    display: grid;
    grid-template-columns: max-content minmax(0, 1fr);
    gap: 8px 20px;
    max-width: 760px;
    margin: 0;
    padding: 16px 18px;
    background: var(--panel);
    border: 1px solid var(--rule);
    border-radius: 2px;
    font-size: 0.9rem;
    line-height: 1.5;
}
body.theme-ledger .cs-glance > div { display: contents; }
body.theme-ledger .cs-glance dt {
    font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.68rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted);
    padding-top: 2px;
}
body.theme-ledger .cs-glance dd { margin: 0; color: var(--ink); }

body.theme-ledger .cs-question {
    font-size: 1.05rem;
    line-height: 1.5;
    color: var(--entry);
    border-left: 3px solid var(--stamp-light);
    padding-left: 14px;
    margin: 0 0 16px;
}

body.theme-ledger .cs-related { font-size: 0.85rem; color: var(--muted); margin: 24px 0 0; }

body.theme-ledger .cs-shots-title {
    font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
    font-weight: 700;
    font-size: 1.75rem;
    color: var(--entry);
    letter-spacing: -0.015em;
    flex-grow: 1;
}
@media screen and (max-width: 768px) {
    body.theme-ledger .cs-shots-title { font-size: 1.5rem; }
    body.theme-ledger .cs-glance { grid-template-columns: 1fr; gap: 2px 0; padding: 14px 16px; }
    body.theme-ledger .cs-glance dd { margin-bottom: 10px; }
}

body.theme-ledger .cs-nav {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin: 26px 0;
}
body.theme-ledger .cs-nav-link {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 14px 16px;
    background: var(--panel);
    border: 1px solid var(--rule);
    border-radius: 2px;
    color: var(--ink);
    text-decoration: none;
    transition: border-color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}
body.theme-ledger .cs-nav-link:hover {
    border-color: var(--stamp-light);
    background: var(--tint);
}
body.theme-ledger .cs-nav-next { text-align: right; align-items: flex-end; }
body.theme-ledger .cs-nav-dir {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 0.68rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--stamp);
}
body.theme-ledger .cs-nav-title { font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 700; color: var(--entry); }
@media screen and (max-width: 560px) {
    body.theme-ledger .cs-nav { grid-template-columns: 1fr; }
    body.theme-ledger .cs-nav-next { text-align: left; align-items: flex-start; }
}

/* --- Case-study header & navigation with up/down arrows --- */
body.theme-ledger .cs-header {
    text-align: left;
    max-width: 800px;
    margin: 0 0 28px 0;
}
body.theme-ledger .cs-header h1 {
    text-align: left;
    margin: 6px 0 8px;
}
body.theme-ledger .cs-header .cs-kicker {
    text-align: left;
}
body.theme-ledger .cs-header .cs-tagline {
    text-align: left;
}
body.theme-ledger .cs-top-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--rule);
}
body.theme-ledger .cs-top-back {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 6px 0;
    color: var(--stamp);
    text-decoration: none;
    font-weight: 500;
}
body.theme-ledger .cs-top-back:hover {
    color: var(--entry);
}
body.theme-ledger .cs-arrows {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
body.theme-ledger .cs-arrow-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 44px;
    min-width: 44px;
    padding: 8px 14px;
    border-radius: 2px;
    border: 1px solid var(--rule);
    background: var(--panel);
    color: var(--entry);
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 0.8rem;
    font-weight: 600;
    text-decoration: none;
    transition: border-color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}
body.theme-ledger .cs-arrow-btn:hover {
    border-color: var(--stamp-light);
    background: var(--tint);
    color: var(--entry);
}
body.theme-ledger .cs-arrow-btn:focus-visible {
    outline: 2px solid var(--stamp-light);
    outline-offset: 2px;
}

/* Floating quick-scroll control — structure lives in components.css */
body.theme-ledger .cs-scroll-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--panel);
    border: 1px solid var(--rule);
    color: var(--entry);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
    box-shadow: 0 6px 16px rgba(26, 25, 23, 0.14);
    cursor: pointer;
    transition: transform 0.18s ease, border-color 0.18s ease;
}
body.theme-ledger .cs-scroll-btn:hover:not([disabled]) {
    transform: scale(1.08);
    border-color: var(--stamp-light);
}
body.theme-ledger .cs-scroll-btn:focus-visible {
    outline: 2px solid var(--stamp-light);
    outline-offset: 2px;
}

/* Reading progress */
body.theme-ledger .cs-reading-bar {
    background: var(--stamp-light);
}

/* Zoom affordance on a screenshot frame */
body.theme-ledger .shot-zoom-badge,
body.theme-ledger .shot-zoom-btn {
    border-radius: 2px;
    background: var(--entry);
    color: #FFF;
    border: none;
    box-shadow: 0 4px 12px rgba(26, 25, 23, 0.22);
    font-family: 'Inter', sans-serif;
    transition: background-color 0.2s, transform 0.18s;
}
body.theme-ledger .shot-frame:hover .shot-zoom-badge,
body.theme-ledger .shot-zoom-btn:hover {
    background: var(--stamp);
}
body.theme-ledger .shot-frame:focus-visible,
body.theme-ledger .shot-zoom-btn:focus-visible {
    outline: 2px solid var(--stamp-light);
    outline-offset: 2px;
}

/* Lightbox */
body.theme-ledger dialog.cs-lightbox {
    border: 1px solid var(--rule);
    border-radius: 2px;
    background: #FFF;
    box-shadow: 0 24px 64px rgba(26, 25, 23, 0.28);
}
body.theme-ledger .cs-lightbox-header {
    border-bottom: 1px solid var(--rule);
    background: var(--panel);
}
body.theme-ledger .cs-lightbox-title {
    font-weight: 600;
    font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 1rem;
    color: var(--entry);
}
body.theme-ledger .cs-lightbox-hint {
    color: var(--muted);
    font-family: 'Inter', sans-serif;
}
body.theme-ledger .cs-lightbox-link {
    color: var(--stamp);
    background: rgba(162, 59, 44, 0.10);
    border-radius: 2px;
    font-family: 'Inter', sans-serif;
}
body.theme-ledger .cs-lightbox-close {
    border-radius: 50%;
    border: 1px solid var(--rule);
    background: #FFF;
    color: var(--entry);
}
body.theme-ledger .cs-lightbox-img {
    border-radius: 2px;
}

/* Reduced motion: Ledger animates the accordion fade, the theme popover and a few
   hover lifts. Honour the preference. */
@media (prefers-reduced-motion: reduce) {
    body.theme-ledger *,
    body.theme-ledger *::before,
    body.theme-ledger *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
    }
    body.theme-ledger .shot-frame:hover,
    body.theme-ledger .cs-nav-link:hover,
    body.theme-ledger .social-links a:hover { transform: none; }
}

/* Tab panels hide via the hidden attribute (JS-driven; no-JS shows all). */
[hidden] { display: none !important; }

/* --- Section tabs (Featured / Projects / Writing) --- */
body.theme-ledger .tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
    border-bottom: 1px solid var(--rule);
    margin: 20px 0 26px;
}
body.theme-ledger .tab {
    appearance: none;
    -webkit-appearance: none;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    padding: 8px 2px;
    font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
    font-weight: 600;
    font-size: 1.05rem;
    color: var(--muted);
    cursor: pointer;
    transition: color 0.15s ease, border-color 0.15s ease;
}
body.theme-ledger .tab:hover { color: var(--entry); }
body.theme-ledger .tab[aria-selected="true"] { color: var(--entry); border-bottom-color: var(--stamp); }
body.theme-ledger .tab:focus-visible { outline: 3px solid var(--stamp); outline-offset: 3px; }
