/*
  ============================================================================
  Zombie Scholar: all styling (no inline styles, so the CSP holds)
  ============================================================================
  Concept: a card catalog in a quarantined library. Ruled index cards with a
  punch hole, typewritten call numbers and rubber-stamp review statuses, in
  the v2 palette: green leads, paper supports, yellow highlights. Dark by
  default; light when the device asks for it or the reader chooses it.
  ============================================================================
*/

/* v2 palette (Projects/Zombie-Scholar/Zombie_Scholar_Palette_Infographic_v2.pdf):
   Scholar Green #244B35, Deep Forest #14291E, Moss Green #64834A, Pale Sage #E5ECDD,
   Graveyard Yellow #E7C85A, Aged Paper #F7F3E6, Ink Charcoal #222822.
   "Green leads. Paper supports. Yellow highlights." Pairings: paper on dark green;
   charcoal on yellow. Tokens marked "derived" are tints of the palette for rules/bands.

   Theme: DARK is the default. Light applies only when the device explicitly prefers
   light (and the reader has not chosen dark), or when the reader picks light.
   site.js sets data-theme; the media query covers readers without JavaScript. */
:root {
  --bg: #14291e;            /* Deep Forest: page */
  --bg-2: #1a3526;          /* derived: between Deep Forest and Scholar Green, for bands */
  --paper: #244b35;         /* Scholar Green: cards, panels, UI surfaces */
  --field: #222822;         /* Ink Charcoal: inputs */
  --head: #244b35;          /* header and footer surface */
  --ink: #f7f3e6;           /* Aged Paper: text */
  --muted: #c3cebb;         /* Pale Sage, softened: secondary text */
  --rule: #3f6b50;          /* derived: Scholar Green lightened */
  --line: #2f5a41;          /* derived: index-card ruling */
  --accent: #e7c85a;        /* Graveyard Yellow: accent text, rules, links */
  --hl: #e7c85a;            /* Graveyard Yellow: highlight fill */
  --on-hl: #222822;         /* Ink Charcoal on yellow */
  --moss: #64834a;          /* Moss Green: decorative */
  --brand: #244b35;
  --on-brand: #f7f3e6;
  --green: #b9d29c;         /* verified (Moss, lightened for contrast) */
  --green-soft: #2f5a3c;
  --info: #e5ecdd;          /* under review, editorial (Pale Sage) */
  --amber: #e7c85a;         /* needs sources, opinion */
  --focus: #e7c85a;
  --shadow: 0 1px 0 rgba(0, 0, 0, .35), 0 10px 24px -14px rgba(0, 0, 0, .75);
  color-scheme: dark;
  --display: "Fraunces", "Iowan Old Style", Georgia, serif;
  --body: "Literata", Georgia, serif;
  --mono: "Courier Prime", "Courier New", monospace;
  --wrap: 1160px;
  --gutter: clamp(16px, 4vw, 40px);
}
:root[data-theme="light"] {
  --bg: #f7f3e6;            /* Aged Paper: page */
  --bg-2: #ede8d6;          /* derived: Aged Paper deepened, for bands */
  --paper: #e5ecdd;         /* Pale Sage: cards and light panels */
  --field: #fffdf6;
  --head: #f7f3e6;
  --ink: #222822;           /* Ink Charcoal: text */
  --muted: #4c5947;         /* derived: charcoal toward Moss */
  --rule: #c5d0ba;          /* derived: Pale Sage deepened */
  --line: #cdd8c2;
  --accent: #244b35;        /* Scholar Green: accent text, rules, links */
  --hl: #e7c85a;            /* Graveyard Yellow: highlight fill */
  --on-hl: #222822;
  --moss: #64834a;
  --brand: #244b35;
  --on-brand: #f7f3e6;
  --green: #244b35;         /* verified */
  --green-soft: #d3dfc6;
  --info: #45622f;          /* under review, editorial (Moss, deepened for contrast) */
  --amber: #765b0c;         /* needs sources, opinion (Graveyard Yellow, deepened for contrast) */
  --focus: #244b35;
  --shadow: 0 1px 0 rgba(34, 40, 34, .06), 0 8px 20px -12px rgba(34, 40, 34, .3);
  color-scheme: light;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f7f3e6;            /* Aged Paper: page */
    --bg-2: #ede8d6;          /* derived: Aged Paper deepened, for bands */
    --paper: #e5ecdd;         /* Pale Sage: cards and light panels */
    --field: #fffdf6;
    --head: #f7f3e6;
    --ink: #222822;           /* Ink Charcoal: text */
    --muted: #4c5947;         /* derived: charcoal toward Moss */
    --rule: #c5d0ba;          /* derived: Pale Sage deepened */
    --line: #cdd8c2;
    --accent: #244b35;        /* Scholar Green: accent text, rules, links */
    --hl: #e7c85a;            /* Graveyard Yellow: highlight fill */
    --on-hl: #222822;
    --moss: #64834a;
    --brand: #244b35;
    --on-brand: #f7f3e6;
    --green: #244b35;         /* verified */
    --green-soft: #d3dfc6;
    --info: #45622f;          /* under review, editorial (Moss, deepened for contrast) */
    --amber: #765b0c;         /* needs sources, opinion (Graveyard Yellow, deepened for contrast) */
    --focus: #244b35;
    --shadow: 0 1px 0 rgba(34, 40, 34, .06), 0 8px 20px -12px rgba(34, 40, 34, .3);
    color-scheme: light;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 1rem; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 1.0625rem/1.65 var(--body);
  overflow-x: hidden;
}
/* Paper grain: a tiny SVG noise tile (data: is allowed by the CSP's img-src). */
body::before {
  content: "";
  position: fixed; inset: 0;
  pointer-events: none; z-index: 0;
  opacity: .07;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .2 0 0 0 0 .15 0 0 0 0 .05 0 0 0 .9 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
body > * { position: relative; z-index: 1; }

h1, h2, h3 { font-family: var(--display); font-weight: 800; line-height: 1.1; letter-spacing: -.01em; margin: 0 0 .5em; }
h1 { font-size: clamp(2.3rem, 6vw, 4.4rem); letter-spacing: -.025em; }
h2 { font-size: clamp(1.5rem, 3vw, 2.1rem); }
h3 { font-size: 1.2rem; font-weight: 600; }
p { margin: 0 0 1em; }
a { color: inherit; text-decoration-color: var(--accent); text-decoration-thickness: 1.5px; text-underline-offset: .18em; }
a:hover { color: var(--accent); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 2px; }
em { font-style: italic; }
cite { font-style: italic; }
.vh { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); }
.hint { color: var(--muted); font-size: .95rem; }
.skip { position: absolute; left: -999px; top: 0; background: var(--ink); color: var(--bg); padding: .6em 1em; z-index: 50; }
.skip:focus { left: 1rem; top: 1rem; }
.js-only { display: none; }
.js .js-only { display: inline; }

.wrap { max-width: var(--wrap); margin-left: auto; margin-right: auto; padding: 0 var(--gutter); }
main > section, main > div, main > nav { margin-bottom: clamp(2.5rem, 6vw, 4.5rem); }

.kicker, .label, .callno, .medium, .phase, .trail-status, .shelf-count, .label-kind {
  font-family: var(--mono); font-weight: 700; text-transform: uppercase; letter-spacing: .12em; font-size: .74rem;
}
.kicker { color: var(--accent); margin-bottom: .6em; }
.label { color: var(--muted); margin-right: .5em; }
.lede { font-size: clamp(1.1rem, 1.6vw, 1.28rem); max-width: 46rem; }

/* ------------------------------------------------------------------ header */
header.site { border-bottom: 1px solid var(--rule); background: var(--head); }
.bar { max-width: var(--wrap); margin: 0 auto; padding: .8rem var(--gutter); display: flex; align-items: center; gap: 1rem; }
.brand { display: inline-flex; align-items: center; gap: .55rem; text-decoration: none; color: var(--ink); }
.brand:hover { color: var(--ink); }
.brand-name { font-family: var(--display); font-weight: 800; font-size: 1.35rem; letter-spacing: -.01em; white-space: nowrap; }
.brand-name i { font-weight: 600; color: var(--accent); }
.mark { width: 40px; height: 32px; flex: none; }
.mark-card { fill: var(--paper); stroke: var(--ink); stroke-width: 1.6; }
.mark-rule { stroke: var(--accent); stroke-width: 1.6; }
.mark-rule { stroke-dasharray: none; }
.mark-hole { fill: var(--bg); stroke: var(--ink); stroke-width: 1.2; }
.mini-search { flex: 1; max-width: 360px; margin-left: auto; }
.mini-search input { width: 100%; }
.controls { display: flex; gap: .4rem; align-items: center; }
.theme-btn, .menu-btn {
  width: 42px; height: 42px; display: inline-grid; place-items: center;
  border: 1px solid var(--rule); background: var(--paper); color: var(--ink); border-radius: 6px; cursor: pointer;
}
.theme-btn svg { width: 20px; height: 20px; }
.ic-moon { display: none; }
:root[data-theme="dark"] .ic-sun { display: none; }
:root[data-theme="dark"] .ic-moon { display: block; }
.menu-btn { display: none; flex-direction: column; align-items: center; justify-content: center; gap: 4px; }
.menu-btn span { display: block; width: 18px; height: 2px; background: currentColor; }

nav.primary { max-width: var(--wrap); margin: 0 auto; padding: 0 var(--gutter); display: flex; gap: .25rem; flex-wrap: wrap; }
nav.primary a {
  font-family: var(--mono); font-weight: 700; font-size: .8rem; letter-spacing: .1em; text-transform: uppercase;
  text-decoration: none; padding: .55rem .8rem .5rem; border: 1px solid transparent; border-bottom: 0;
  border-radius: 6px 6px 0 0; margin-bottom: -1px;
}
nav.primary a[aria-current="page"] { background: var(--hl); border-color: var(--hl); color: var(--on-hl); }
nav.primary a:not([aria-current]):hover { color: var(--accent); }

input[type="search"], input[type="text"], select, textarea {
  font: inherit; font-size: 1rem; color: var(--ink); background: var(--field);
  border: 1.5px solid var(--rule); border-radius: 4px; padding: .55rem .7rem; min-height: 44px; max-width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
::placeholder { color: var(--muted); opacity: .8; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 44px;
  font-family: var(--mono); font-weight: 700; letter-spacing: .08em; text-transform: uppercase; font-size: .82rem;
  background: var(--hl); color: var(--on-hl); border: 1.5px solid var(--hl); border-radius: 4px;
  padding: .55rem 1.1rem; text-decoration: none; cursor: pointer;
}
.btn:hover { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--ink); }
.btn-ghost:hover { background: var(--hl); border-color: var(--hl); color: var(--on-hl); }
.btn-big { font-size: .95rem; padding: .9rem 1.5rem; }
.btn[disabled], fieldset[disabled] .btn { opacity: .45; cursor: not-allowed; }

/* -------------------------------------------------------------------- hero */
.hero {
  max-width: var(--wrap); margin: 0 auto; padding: clamp(2.5rem, 7vw, 5.5rem) var(--gutter) clamp(2rem, 5vw, 3rem);
  display: grid; grid-template-columns: 1.15fr 1fr; gap: clamp(1.5rem, 4vw, 3.5rem); align-items: end;
}
.hero h1 { font-size: clamp(2.8rem, 8vw, 6.2rem); line-height: .93; }
.hero h1 em { color: var(--accent); font-weight: 600; display: block; }
.hero-text > * { animation: rise .7s cubic-bezier(.2, .7, .2, 1) both; }
.hero-text > :nth-child(2) { animation-delay: .08s; }
.hero-text > :nth-child(3) { animation-delay: .16s; }
.drawer { animation: rise .7s .26s cubic-bezier(.2, .7, .2, 1) both; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* The search box as a card-catalog drawer front. */
.drawer {
  background: linear-gradient(180deg, color-mix(in srgb, var(--paper) 70%, var(--bg-2)), var(--paper));
  border: 2px solid var(--ink); border-radius: 8px; padding: 1.1rem; box-shadow: var(--shadow), inset 0 -6px 0 var(--bg-2);
}
.drawer-label {
  display: flex; justify-content: space-between; align-items: center; margin: -.2rem 0 .8rem;
  font-family: var(--mono); font-weight: 700; text-transform: uppercase; letter-spacing: .14em; font-size: .78rem;
}
.drawer-label span:first-child { border: 1.5px solid var(--ink); padding: .15rem .55rem; background: var(--paper); }
.drawer-pull { width: 64px; height: 14px; border: 2px solid var(--ink); border-top: 0; border-radius: 0 0 40px 40px; }
.drawer-row { display: flex; gap: .5rem; }
.drawer-row input { flex: 1; min-width: 0; font-size: 1.05rem; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .9rem; }
.chip {
  font-family: var(--mono); font-size: .8rem; text-decoration: none; border: 1px solid var(--rule);
  padding: .3rem .6rem; border-radius: 99px; background: var(--paper); white-space: nowrap;
}
.chip b { color: var(--accent); margin-left: .2rem; }
.chip:hover { border-color: var(--accent); }
.drawer-sm { max-width: 520px; margin: 1.5rem 0; }

/* -------------------------------------------------------------------- tally */
.band { background: var(--bg-2); border-block: 1px solid var(--rule); padding: clamp(1.8rem, 4vw, 2.6rem) 0; }
.tally-band > * { max-width: var(--wrap); margin-left: auto; margin-right: auto; padding: 0 var(--gutter); }
.tally { display: grid; grid-template-columns: repeat(6, 1fr); gap: 0; margin: 0 auto 1rem; }
.tally div { padding: .3rem 1rem; border-left: 1px dashed var(--rule); }
.tally div:first-child { border-left: 0; }
.tally dt { font-family: var(--mono); font-size: .72rem; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); }
.tally dd { margin: 0; font-family: var(--display); font-weight: 800; font-size: clamp(2rem, 5vw, 3.4rem); line-height: 1.05; }
.tally-note { font-family: var(--mono); font-size: .85rem; color: var(--muted); }
.tally-band .tally-honest { max-width: var(--wrap); }

/* ------------------------------------------------------------------- layout */
.split { display: grid; grid-template-columns: 1.1fr 1fr; gap: clamp(1.5rem, 4vw, 3.5rem); align-items: start; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(1.5rem, 4vw, 3rem); }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; flex-wrap: wrap; }
.page-head { padding-top: clamp(2.2rem, 6vw, 4.5rem); }
.page-head h1 { max-width: 18ch; }
.page-head > * { animation: rise .6s cubic-bezier(.2, .7, .2, 1) both; }
.page-head > :nth-child(2) { animation-delay: .06s; }
.page-head > :nth-child(3) { animation-delay: .12s; }

.steps { counter-reset: s; list-style: none; padding: 0; margin: 0; }
.steps li { counter-increment: s; position: relative; padding: 0 0 1rem 3rem; }
.steps li::before {
  content: counter(s); position: absolute; left: 0; top: .1rem; width: 2rem; height: 2rem; display: grid; place-items: center;
  font-family: var(--mono); font-weight: 700; border: 1.5px solid var(--ink); border-radius: 50%; font-size: .9rem;
}

/* Featured connection: a pinned note. */
.feature {
  background: var(--paper); border: 1px solid var(--rule); padding: 1.6rem; box-shadow: var(--shadow);
  transform: rotate(.6deg); position: relative;
}
.feature::before {
  content: ""; position: absolute; top: -10px; left: 50%; width: 90px; height: 22px; transform: translateX(-50%) rotate(-2deg);
  background: color-mix(in srgb, var(--moss) 70%, transparent);
}
.feature-moral { font-family: var(--display); font-style: italic; font-weight: 600; font-size: 1.3rem; color: var(--accent); }

.call { background: var(--brand); color: var(--on-brand); border: 0; }
.call a:not(.btn) { color: inherit; }
.call .btn { background: var(--hl); border-color: var(--hl); color: var(--on-hl); }
.call .btn:hover { background: var(--on-brand); color: var(--brand); border-color: var(--on-brand); }
.call-inner { display: flex; justify-content: space-between; align-items: center; gap: 2rem; flex-wrap: wrap; }
.call-inner p { max-width: 40rem; margin: 0; opacity: .85; }

.promise-list { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(2, 1fr); gap: .8rem 2rem; }
.promise-list li { padding: .8rem 0; border-top: 1px solid var(--rule); }
.label-kind {
  display: inline-block; font-size: .68rem; padding: .12rem .45rem; border-radius: 3px; margin-right: .35rem;
  background: var(--green-soft); color: var(--green); vertical-align: .15em;
}
.label-ed { background: color-mix(in srgb, var(--info) 16%, transparent); color: var(--info); }
.label-opinion { background: color-mix(in srgb, var(--amber) 18%, transparent); color: var(--amber); }
.label-humor { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }
h2 .label-kind { font-family: var(--mono); letter-spacing: .1em; }

/* -------------------------------------------------------------- index cards */
.cards { list-style: none; padding: 0; margin: 1rem 0; display: grid; gap: 1rem; }
.cards-3 { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.cards-2 { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.cards-1 { max-width: 560px; }
#results { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.card, .entry-card {
  position: relative; background-color: var(--paper);
  background-image:
    linear-gradient(var(--accent), var(--accent)),
    repeating-linear-gradient(180deg, transparent 0 27px, color-mix(in srgb, var(--line) 55%, transparent) 27px 28px);
  background-size: 100% 2px, 100% 100%;
  background-position: 0 2.6rem, 0 2.9rem;
  background-repeat: no-repeat, no-repeat;
  border: 1px solid var(--rule); border-radius: 3px; padding: .75rem 1.1rem 1.6rem; box-shadow: var(--shadow);
  transition: transform .18s ease, box-shadow .18s ease;
}
.card::after, .entry-card::after {
  content: ""; position: absolute; bottom: .55rem; left: 50%; width: 12px; height: 12px; margin-left: -6px;
  border-radius: 50%; background: var(--bg); box-shadow: inset 0 1px 2px rgba(0, 0, 0, .35);
}
.card:hover { transform: translateY(-3px) rotate(-.3deg); }
.card-top { display: flex; align-items: center; gap: .7rem; min-height: 1.7rem; margin-bottom: .7rem; }
.callno { color: var(--ink); letter-spacing: .08em; }
.medium { color: var(--muted); }
.card-top .stamp { margin-left: auto; }
.card-title { font-size: 1.22rem; line-height: 1.25; margin: 0 0 .3rem; }
.card-title a { text-decoration: none; }
.card-title a::before { content: ""; position: absolute; inset: 0; }
.card-title a:hover { color: var(--accent); }
.card-meta { font-family: var(--mono); font-size: .82rem; color: var(--muted); margin: 0 0 .4rem; line-height: 1.75; }
.card-syn { font-size: .95rem; margin: 0; line-height: 1.75; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.aka { white-space: nowrap; }

/* Rubber stamps. The status is always written out, never color alone. */
.stamp {
  display: inline-block; font-family: var(--mono); font-weight: 700; text-transform: uppercase; letter-spacing: .12em;
  font-size: .78rem; padding: .25rem .6rem; border: 2.5px double currentColor; border-radius: 4px;
  transform: rotate(-4deg); opacity: .9; white-space: nowrap; line-height: 1.2;
}
.stamp-sm { font-size: .62rem; padding: .12rem .4rem; border-width: 2px; }
.stamp-verified { color: var(--green); }
.stamp-under-review { color: var(--info); }
.stamp-needs-sources { color: var(--amber); }
.stamp-disputed { color: var(--on-hl); background: var(--hl); border-color: var(--on-hl); }
.stamp-submitted { color: var(--muted); }

/* ------------------------------------------------------------------- search */
.filters {
  display: grid; grid-template-columns: 2fr repeat(4, 1fr); gap: .8rem; align-items: end;
  background: var(--paper); border: 1px solid var(--rule); padding: 1rem; border-radius: 6px;
}
.filters label { display: block; font-family: var(--mono); font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin-bottom: .25rem; }
.filters input, .filters select { width: 100%; }
.result-bar { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin-top: 1rem; }
.result-bar p { margin: 0; font-family: var(--mono); font-size: .9rem; }
.active-filters { display: flex; flex-wrap: wrap; gap: .4rem; }
.active-filters button {
  font-family: var(--mono); font-size: .78rem; background: var(--hl); color: var(--on-hl); border: 1px solid var(--hl);
  border-radius: 99px; padding: .25rem .65rem; cursor: pointer; min-height: 32px;
}
.did-you-mean { font-family: var(--mono); }
.did-you-mean button { font: inherit; color: var(--accent); background: none; border: 0; text-decoration: underline; cursor: pointer; padding: 0; }
.no-results { text-align: center; padding: 2.5rem 1rem; border: 2px dashed var(--rule); border-radius: 8px; margin: 1rem 0; }
.later, .spoiler { border: 1px solid var(--rule); border-radius: 6px; padding: .8rem 1rem; background: var(--paper); margin-top: 1.5rem; }
.later summary, .spoiler summary { cursor: pointer; font-family: var(--mono); font-weight: 700; font-size: .9rem; }
.later p, .spoiler p { margin: .7rem 0 0; }

.az-letters { display: flex; flex-wrap: wrap; gap: .2rem; margin-bottom: 1rem; font-family: var(--mono); font-weight: 700; }
.az-letters a, .az-letters span { width: 2.1rem; height: 2.1rem; display: grid; place-items: center; border: 1px solid var(--rule); border-radius: 3px; text-decoration: none; }
.az-letters a { background: var(--paper); }
.az-letters a:hover { background: var(--ink); color: var(--bg); }
.az-letters span { opacity: .35; }
.az-groups { columns: 2 320px; column-gap: 2.5rem; }
.az-group { break-inside: avoid; margin-bottom: 1rem; }
.az-group h3 { font-size: 1.6rem; color: var(--accent); margin: 0 0 .2rem; }
.az-group ul { list-style: none; margin: 0; padding: 0; }
.az-group li { padding: .25rem 0; border-bottom: 1px dotted var(--rule); }

/* ------------------------------------------------------------------ catalog */
.shelf-nav, .toc { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: 1.4rem; }
.shelf-nav a, .toc a { font-family: var(--mono); font-size: .8rem; text-decoration: none; border: 1px solid var(--rule); padding: .35rem .7rem; background: var(--paper); border-radius: 3px; }
.shelf-nav a:hover, .toc a:hover { border-color: var(--accent); color: var(--accent); }
.scope-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.scope-grid > div { border-top: 3px solid var(--ink); padding-top: .8rem; }
.shelf { padding: 2rem 0 1rem; border-top: 1px solid var(--rule); scroll-margin-top: 1rem; }
.shelf-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.shelf-head h2 { margin: 0; }
.shelf-count { color: var(--accent); }
.unit { max-width: 52rem; color: var(--muted); }
.empty-shelf { border: 2px dashed var(--rule); padding: 1rem 1.2rem; border-radius: 4px; color: var(--muted); }

/* -------------------------------------------------------------- field guide */
.rule-cards { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; counter-reset: r; }
.rule-cards li { counter-increment: r; background: var(--paper); border: 1px solid var(--rule); padding: 1rem; border-radius: 4px; }
.rule-cards li::before { content: "Rule " counter(r); display: block; font-family: var(--mono); font-weight: 700; color: var(--accent); font-size: .74rem; letter-spacing: .12em; text-transform: uppercase; margin-bottom: .4rem; }
.rule-cards strong { display: block; font-family: var(--display); font-size: 1.1rem; margin-bottom: .3rem; }
.checklist { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.ck-group { background: var(--paper); border: 1px solid var(--rule); border-radius: 4px; padding: 1.2rem 1.3rem; }
.ck-group h3 { display: flex; align-items: center; gap: .6rem; font-size: 1.25rem; }
.ck-num { font-family: var(--mono); font-size: .8rem; border: 1.5px solid var(--accent); color: var(--accent); border-radius: 3px; padding: 0 .35rem; }
.ck-group dl { margin: 0; }
.ck-group dl > div { padding: .55rem 0; border-top: 1px dotted var(--rule); }
.ck-group dt { font-family: var(--mono); font-weight: 700; font-size: .78rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.ck-group dd { margin: .2rem 0 0; }
.boxes { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: .25rem 1rem; font-size: .95rem; }
.boxes li::before { content: ""; display: inline-block; width: .8em; height: .8em; border: 1.5px solid var(--ink); border-radius: 2px; margin-right: .4em; vertical-align: -.05em; }
.every { margin-top: 1rem; }
.tag, .tags-list li {
  display: inline-block; font-family: var(--mono); font-size: .8rem; border: 1px solid var(--rule); background: var(--paper);
  padding: .15rem .5rem; border-radius: 3px; margin: 0 .2rem .3rem 0;
}
.tags-list { list-style: none; padding: 0; margin: 0; }
.trait-sample { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .5rem; }
.trait-sample > div { border: 1px dashed var(--rule); padding: .6rem .8rem; border-radius: 4px; }
.trait-sample .label { display: block; margin-bottom: .2rem; color: var(--accent); }
.glossary { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 0 2rem; margin: 0; }
.glossary > div { padding: .8rem 0; border-top: 1px solid var(--rule); }
.glossary dt { font-family: var(--display); font-weight: 600; font-size: 1.1rem; }
.glossary dd { margin: .2rem 0 0; }
.humor { background: var(--paper); border: 2px dashed var(--accent); border-radius: 8px; padding-top: 1.5rem; padding-bottom: 1rem; }
.badges { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: .6rem; }
.badges li { border: 1.5px solid var(--ink); border-radius: 99px; padding: .45rem .9rem; font-size: .92rem; background: var(--bg); }
.badges b { display: block; font-family: var(--display); }
.humor-hidden-note { display: none; }
:root.hide-humor .humor-content { display: none; }
:root.hide-humor .humor-hidden-note { display: block; }

/* ------------------------------------------------------------------- themes */
.vocab { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.5rem; }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
.data th, .data td { text-align: left; vertical-align: top; padding: .7rem .8rem; border-bottom: 1px solid var(--rule); }
.data thead th { font-family: var(--mono); font-size: .74rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.data tbody th { font-weight: 700; font-family: var(--body); }
.trails { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; margin-bottom: 1.5rem; }
.trail { background: var(--paper); border: 1px solid var(--rule); border-left: 5px solid var(--moss); padding: 1.2rem 1.3rem; border-radius: 3px; scroll-margin-top: 1rem; }
.trail-status { color: var(--green); margin-bottom: .3rem; }
.crit { font-size: .95rem; margin: 0; }

/* ------------------------------------------------------------------ history */
.timeline { list-style: none; padding: 0; border-left: 2px solid var(--ink); margin-left: .5rem; }
.timeline li { position: relative; padding: .4rem 0 .4rem 1.4rem; }
.timeline li::before { content: ""; position: absolute; left: -7px; top: .95rem; width: 12px; height: 12px; border-radius: 50%; background: var(--accent); }
.tl-year { font-family: var(--mono); font-weight: 700; margin-right: .8rem; }
.checks { list-style: none; padding: 0; }
.checks li { position: relative; padding: .35rem 0 .35rem 1.7rem; }
.checks li::before { content: ""; position: absolute; left: 0; top: .72rem; width: .8em; height: .8em; border: 1.5px solid var(--ink); border-radius: 2px; }
.checks li::after { content: ""; position: absolute; left: .22em; top: .66rem; width: .35em; height: .65em; border: solid var(--accent); border-width: 0 2.5px 2.5px 0; transform: rotate(40deg); }

/* ---------------------------------------------------------------- community */
.notice { }
.notice p { border: 2px solid var(--amber); background: color-mix(in srgb, var(--amber) 10%, var(--paper)); padding: 1rem 1.2rem; border-radius: 6px; margin: 0; }
.forms { display: grid; gap: 1.2rem; }
.contrib { background: var(--paper); border: 1px solid var(--rule); border-radius: 6px; padding: 1.3rem; scroll-margin-top: 1rem; }
.contrib:target { outline: 3px solid var(--accent); outline-offset: 3px; }
.contrib fieldset { border: 0; padding: 0; margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: .8rem 1rem; min-width: 0; }
.contrib fieldset[disabled] { opacity: .78; }
.field label { display: block; font-family: var(--mono); font-size: .74rem; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin-bottom: .25rem; }
.field input, .field select, .field textarea { width: 100%; }
.wide { grid-column: 1 / -1; }
.field.check { display: flex; align-items: center; gap: .5rem; }
.field.check label { margin: 0; }
.contrib .btn { justify-self: start; }
.flow { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(6, 1fr); gap: .5rem; counter-reset: f; }
.flow li { background: var(--paper); border: 1px solid var(--rule); padding: .8rem; border-radius: 4px; font-size: .95rem; position: relative; }
.flow span { display: block; font-family: var(--mono); font-weight: 700; color: var(--accent); }
.roles { margin: 0; }
.roles > div { display: grid; grid-template-columns: 11rem 1fr; padding: .45rem 0; border-top: 1px dotted var(--rule); }
.roles dt { font-weight: 700; }
.roles dd { margin: 0; }

/* -------------------------------------------------------------------- about */
.status-list { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1rem; }
.status-list li { background: var(--paper); border: 1px solid var(--rule); padding: 1rem; border-radius: 4px; }
.status-list p { margin: .7rem 0 0; font-size: .95rem; }
.tree { font-family: var(--mono); background: var(--paper); border: 1px solid var(--rule); padding: 1rem 1.2rem; border-radius: 4px; margin: 1rem 0; }
.tree p { margin: .2rem 0; }
.tree b { display: inline-block; min-width: 7.5rem; color: var(--accent); }
.roadmap { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }
.roadmap li { border-top: 4px solid var(--rule); padding-top: .8rem; }
.roadmap li.now { border-top-color: var(--accent); }
.phase { color: var(--muted); }
.roadmap .now .phase { color: var(--accent); }
.sources { padding-left: 1.3rem; }
.sources li { margin-bottom: .6rem; overflow-wrap: anywhere; }
.prose { max-width: 46rem; }
.prose h2 { font-size: 1.4rem; margin-top: 1.6rem; }
.gaps { padding-left: 1.2rem; }
.gaps li { margin-bottom: .4rem; }

.cov-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1.2rem; }
.ledger { background: var(--paper); border: 1px solid var(--rule); }
.ledger caption { text-align: left; font-family: var(--mono); font-weight: 700; font-size: .78rem; text-transform: uppercase; letter-spacing: .1em; padding: .5rem 0; color: var(--accent); }
.ledger th, .ledger td { padding: .45rem .8rem; border-bottom: 1px dotted var(--rule); text-align: left; font-weight: 400; }
.ledger td { text-align: right; font-family: var(--mono); font-weight: 700; }

/* -------------------------------------------------------------------- entry */
.entry { max-width: var(--wrap); margin: 0 auto; padding: clamp(1.5rem, 4vw, 3rem) var(--gutter) 0; }
.entry-head .crumbs { grid-column: 1 / -1; margin: 0; }
.crumbs { font-family: var(--mono); font-size: .85rem; color: var(--muted); }
.entry-head { display: grid; grid-template-columns: 1fr auto; gap: 1.5rem; align-items: end; margin-bottom: 2.5rem; }
.entry-card { padding: .9rem 1.6rem 2.4rem; max-width: 760px; animation: rise .6s cubic-bezier(.2, .7, .2, 1) both; }
.entry-card h1 { font-size: clamp(2rem, 5vw, 3.4rem); margin: .4rem 0 .4rem; line-height: 1.12; max-width: 16ch; }
.entry-card h1 .sub { display: block; font-size: .45em; font-weight: 600; font-style: italic; color: var(--muted); margin-top: .3rem; letter-spacing: 0; }
.entry-card > .stamp { position: absolute; right: 1.3rem; top: 3.4rem; font-size: 1rem; animation: thunk .5s .45s cubic-bezier(.3, 1.6, .5, 1) both; }
@keyframes thunk { from { opacity: 0; transform: scale(1.8) rotate(-12deg); } to { opacity: .9; transform: rotate(-6deg); } }
.entry-by { font-family: var(--mono); color: var(--muted); }
.parent { font-family: var(--mono); font-size: .9rem; }
.entry-actions { display: flex; flex-direction: column; gap: .5rem; }
.sec { padding: 1.6rem 0; border-top: 1px solid var(--rule); }
.sec h2 { font-size: 1.45rem; }
.sec .label-kind { font-size: .62rem; vertical-align: .35em; }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 0 1.5rem; margin: 0; }
.facts > div { padding: .55rem 0; border-bottom: 1px dotted var(--rule); }
.facts dt { font-family: var(--mono); font-size: .72rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.facts dd { margin: .15rem 0 0; }
.creators { list-style: none; padding: 0; margin: 0; }
.creators li { padding: .35rem 0; border-bottom: 1px dotted var(--rule); }
.role { font-family: var(--mono); font-size: .85rem; color: var(--muted); }
.profile-empty { border: 2px dashed var(--rule); padding: 1rem 1.2rem; border-radius: 6px; }
.profile-empty p:last-child { margin: 0; }
.rels { list-style: none; padding: 0; margin: 0; display: grid; gap: .7rem; }
.rel { background: var(--paper); border: 1px solid var(--rule); border-left: 4px solid var(--info); padding: .7rem 1rem; border-radius: 3px; }
.rel-editorial { border-left-color: var(--amber); }
.rel-type { font-family: var(--mono); font-weight: 700; font-size: .85rem; margin-right: .3rem; }
.rel-kind { float: right; font-family: var(--mono); font-size: .7rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.rel p { margin: .35rem 0 0; font-size: .95rem; clear: both; }
.where { padding-left: 1.2rem; }
.where li { margin-bottom: .4rem; }
.where .muted, .sources .muted { font-family: var(--mono); font-size: .82rem; }
.questions li { margin-bottom: .3rem; }
.copied { background: var(--moss) !important; color: var(--on-brand) !important; border-color: var(--moss) !important; }

/* ------------------------------------------------------------------- footer */
footer.site { border-top: 3px double var(--rule); margin-top: 3rem; padding: 2.5rem 0 2rem; background: var(--head); }
.foot-inner { max-width: var(--wrap); margin: 0 auto; padding: 0 var(--gutter); display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 2rem; }
.foot-tag { color: var(--muted); max-width: 26rem; margin-top: .6rem; }
.foot-nav { display: flex; flex-direction: column; gap: .3rem; }
.foot-nav a { text-decoration: none; font-family: var(--mono); font-size: .88rem; }
.foot-nav a:hover { text-decoration: underline; }
.foot-note, .foot-copy { max-width: var(--wrap); margin: 1.5rem auto 0; padding: 0 var(--gutter); font-size: .85rem; color: var(--muted); }
.foot-copy { margin-top: .6rem; font-family: var(--mono); }
/* Theme control (footer): System / Dark / Light. Hidden without JavaScript,
   where the media query alone decides. */
.theme-set { max-width: var(--wrap); margin: 1.4rem auto 0; padding: 0 var(--gutter); display: none; align-items: center; gap: .4rem; flex-wrap: wrap; }
.js .theme-set { display: flex; }
.theme-set-label { font-family: var(--mono); font-weight: 700; font-size: .78rem; text-transform: uppercase; letter-spacing: .1em; margin-right: .3rem; }
.theme-set button {
  font-family: var(--mono); font-size: .85rem; min-height: 40px; padding: .35rem .9rem; border-radius: 99px; cursor: pointer;
  border: 1px solid var(--rule); background: transparent; color: var(--ink);
}
.theme-set button:hover { border-color: var(--accent); }
.theme-set button[aria-pressed="true"] { background: var(--hl); border-color: var(--hl); color: var(--on-hl); font-weight: 700; }
.lost h1 { max-width: 14ch; }

/* ------------------------------------------------------------------ mobile */
@media (max-width: 1000px) {
  .filters { grid-template-columns: 1fr 1fr; }
  .f-q { grid-column: 1 / -1; }
  .rule-cards, .roadmap { grid-template-columns: 1fr 1fr; }
  .flow { grid-template-columns: repeat(3, 1fr); }
  .tally { grid-template-columns: repeat(3, 1fr); row-gap: 1rem; }
  .tally div:nth-child(4) { border-left: 0; }
}
@media (max-width: 820px) {
  .mini-search { display: none; }
  .controls { margin-left: auto; }
  .menu-btn { display: inline-flex; }
  .js nav.primary { display: none; padding-bottom: .8rem; }
  .js nav.primary.open { display: flex; flex-direction: column; }
  nav.primary a { border-radius: 4px; border: 1px solid var(--rule); margin: 0; }
  .hero, .split, .two-col, .checklist, .vocab, .trails, .scope-grid, .promise-list, .foot-inner, .entry-head { grid-template-columns: 1fr; }
  .feature { transform: none; }
  .entry-actions { flex-direction: row; flex-wrap: wrap; }
  .contrib fieldset { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  .rule-cards, .roadmap, .flow, .filters { grid-template-columns: 1fr; }
  .tally { grid-template-columns: repeat(2, 1fr); }
  .tally div:nth-child(odd) { border-left: 0; }
  .tally div:nth-child(4) { border-left: 1px dashed var(--rule); }
  .drawer-row { flex-direction: column; }
  .cards-2, .cards-3, #results { grid-template-columns: 1fr; }
  .entry-card > .stamp { position: static; margin: .3rem 0; }
  .roles > div { grid-template-columns: 1fr; }
  .brand-name { font-size: 1.15rem; }
}
/* Phones: data tables become labeled rows instead of squeezed columns. */
@media (max-width: 600px) {
  .data thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .data, .data tbody, .data tr, .data th, .data td { display: block; width: 100%; }
  .data tr { border: 1px solid var(--rule); border-radius: 4px; background: var(--paper); padding: .4rem .8rem; margin-bottom: .7rem; }
  .data th, .data td { border: 0; padding: .3rem 0; }
  .data td[data-label]::before {
    content: attr(data-label); display: block; font-family: var(--mono); font-size: .7rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: .1em; color: var(--muted);
  }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media print {
  header.site, footer.site, .entry-actions, .drawer { display: none; }
  body::before { display: none; }
}
.no-js .theme-btn { display: none; }
