/* ============================================================
   THE KINGDOM OF EVERBRIGHT — Field Notebook
   Design system. Palette sampled from the source paintings.
   ============================================================ */

/* ---------- 1. TOKENS ---------- */
:root {
  /* paper substrate — cooler and lighter than the painted plates,
     so plates read as objects tipped onto the page */
  --paper:      #F7F2E6;
  --paper-2:    #FBF7EE;
  --plate:      #EFE3CB;   /* exact bg of the still-life renders */
  --plate-badge:#F3E9D5;
  --inset:      #ECE3CE;
  --rule:       #DACEB2;
  --rule-soft:  #E6DCC4;
  --grid:       #E1D6BB;

  /* ink — warm sepia black, never #000 */
  --ink:        #241E17;
  --ink-2:      #584E40;
  --ink-3:      #6F6353;
  --ink-4:      #766B58;

  /* accents, straight off the canvas */
  --moss:       #4E6B2A;
  --moss-deep:  #33471B;
  --moss-soft:  #E7EBD8;
  --ochre:      #945D0F;
  --ochre-lite: #D9A441;
  --ochre-soft: #F6E9CE;
  --teal:       #276E6B;
  --teal-soft:  #DCEAE7;
  --rose:       #9C4A63;
  --rose-soft:  #F3E2E6;
  --umber:      #5A3410;

  --focus:      #2E6E70;

  --shadow-1: 0 1px 2px rgba(52,40,24,.06), 0 2px 6px rgba(52,40,24,.05);
  --shadow-2: 0 2px 4px rgba(52,40,24,.07), 0 10px 24px -8px rgba(52,40,24,.16);
  --shadow-3: 0 4px 8px rgba(52,40,24,.09), 0 24px 56px -16px rgba(52,40,24,.28);

  --rail-w: 292px;
  --canvas: 1104px;
  --read: 66ch;

  --f-display: "Instrument Serif", "Iowan Old Style", Georgia, serif;
  --f-body: "Literata", Georgia, "Times New Roman", serif;
  --f-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --ease: cubic-bezier(.22,.61,.36,1);
  --ease-out: cubic-bezier(.16,1,.3,1);
  --dur: 420ms;

  color-scheme: light;
}

/* Night observation mode — the missions happen at dusk. */
[data-theme="night"] {
  --paper:      #151814;
  --paper-2:    #1B1F1A;
  --plate:      #232821;
  --plate-badge:#232821;
  --inset:      #1F241E;
  --rule:       #38402F;
  --rule-soft:  #2A3025;
  --grid:       #232A1F;

  --ink:        #EDE6D3;
  --ink-2:      #BDB49E;
  --ink-3:      #9A9179;
  --ink-4:      #8B8470;

  --moss:       #A3C267;
  --moss-deep:  #C6DC96;
  --moss-soft:  #232B1A;
  --ochre:      #E0AE5C;
  --ochre-lite: #F0CE8E;
  --ochre-soft: #2C2417;
  --teal:       #6FBDB4;
  --teal-soft:  #172624;
  --rose:       #DE94A8;
  --rose-soft:  #2A1D21;
  --umber:      #C69565;
  --focus:      #7FCBC2;

  --shadow-1: 0 1px 2px rgba(0,0,0,.4);
  --shadow-2: 0 2px 6px rgba(0,0,0,.45), 0 12px 28px -10px rgba(0,0,0,.6);
  --shadow-3: 0 6px 14px rgba(0,0,0,.5), 0 28px 64px -18px rgba(0,0,0,.75);

  color-scheme: dark;
}

/* ---------- 2. RESET ---------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .001ms !important; animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}
img, svg { display: block; max-width: 100%; }
button, input, select { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }
a { color: inherit; }

body {
  font-family: var(--f-body);
  font-size: 17px;
  line-height: 1.62;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-variant-numeric: oldstyle-nums proportional-nums;
  overflow-x: hidden;
}

::selection { background: var(--ochre-lite); color: #241E17; }

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

/* ---------- 3. SUBSTRATE ---------- */
/* graph paper + grain. Both fixed, both nearly invisible; together they
   stop the flat CSS from looking pasted onto the painted art. */
.substrate {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
}
.substrate::before {
  content: ""; position: absolute; inset: 0;
  background-image:
    linear-gradient(var(--grid) .6px, transparent .6px),
    linear-gradient(90deg, var(--grid) .6px, transparent .6px);
  background-size: 26px 26px;
  opacity: .5;
  mask-image: radial-gradient(120% 90% at 50% 0%, #000 25%, transparent 78%);
}
.substrate::after {
  content: ""; position: absolute; inset: 0;
  background-image: var(--grain);
  opacity: .32;
  mix-blend-mode: multiply;
}
[data-theme="night"] .substrate::after { opacity: .5; mix-blend-mode: overlay; }

/* ---------- 4. TYPE ---------- */
.eyebrow {
  font-family: var(--f-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}
.display {
  font-family: var(--f-display);
  font-weight: 400;
  line-height: 1.03;
  letter-spacing: -.014em;
  color: var(--ink);
}
h1.display { font-size: clamp(2.6rem, 6.2vw, 4.4rem); }
h2.display { font-size: clamp(2rem, 4.2vw, 3rem); }
h3.display { font-size: clamp(1.4rem, 2.4vw, 1.85rem); letter-spacing: -.01em; }

.lede {
  font-size: clamp(1.08rem, 1.6vw, 1.28rem);
  line-height: 1.55;
  color: var(--ink-2);
  font-style: italic;
}
.prose { max-width: var(--read); }
.prose p + p { margin-top: 1.05em; }
.prose strong { font-weight: 600; color: var(--ink); }
.prose em { font-style: italic; }

.dropcap::first-letter {
  font-family: var(--f-display);
  float: left;
  font-size: 3.55em;
  line-height: .82;
  padding: .06em .1em 0 0;
  margin-right: .02em;
  color: var(--moss);
}

.rule { height: 1px; background: var(--rule); border: 0; }
.rule-double {
  height: 4px; border: 0;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  background: none;
}

/* section header: mono label, hairline, optional trailing meta */
.sec-head {
  display: flex; align-items: baseline; gap: 16px;
  margin: 0 0 22px;
}
.sec-head::after {
  content: ""; flex: 1; height: 1px; background: var(--rule);
  transform: translateY(-3px);
}
.sec-head .meta {
  order: 3; flex: none;
  font-family: var(--f-mono); font-size: 11px; letter-spacing: .1em;
  text-transform: uppercase; color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

/* ---------- 5. APP FRAME ---------- */
.app { position: relative; z-index: 1; }

.rail {
  position: fixed; inset: 0 auto 0 0; width: var(--rail-w);
  display: flex; flex-direction: column;
  background: var(--paper-2);
  border-right: 1px solid var(--rule);
  z-index: 40;
}
.rail::after {
  content: ""; position: absolute; top: 0; right: -1px; bottom: 0; width: 1px;
  background: linear-gradient(180deg, transparent, var(--rule) 12%, var(--rule) 88%, transparent);
}

.brand {
  padding: 26px 24px 20px;
  border-bottom: 1px solid var(--rule-soft);
}
.brand a { text-decoration: none; display: block; }
.brand .crest {
  width: 34px; height: 34px; margin-bottom: 12px; color: var(--moss);
}
.brand .name {
  font-family: var(--f-display);
  font-size: 1.42rem; line-height: 1.06; letter-spacing: -.01em;
}
.brand .sub {
  margin-top: 7px;
  font-family: var(--f-mono); font-size: 10px; letter-spacing: .15em;
  text-transform: uppercase; color: var(--ink-3);
}

.rail-scroll { flex: 1; overflow-y: auto; padding: 18px 0 24px; scrollbar-width: thin; }
.rail-scroll::-webkit-scrollbar { width: 9px; }
.rail-scroll::-webkit-scrollbar-thumb { background: var(--rule); border-radius: 9px; border: 3px solid var(--paper-2); }

.nav-group { padding: 0 14px; }
.nav-group + .nav-group { margin-top: 22px; }
.nav-label {
  display: flex; align-items: center; gap: 10px;
  padding: 0 10px 9px;
  font-family: var(--f-mono); font-size: 10px; letter-spacing: .16em;
  text-transform: uppercase; color: var(--ink-4);
}
.nav-label::after { content: ""; flex: 1; height: 1px; background: var(--rule-soft); }

.navitem {
  position: relative;
  display: flex; align-items: center; gap: 11px;
  width: 100%; padding: 8px 10px; border-radius: 6px;
  text-align: left; text-decoration: none;
  color: var(--ink-2); font-size: 14.5px; line-height: 1.3;
  transition: background var(--dur) var(--ease), color 180ms;
}
.navitem:hover { background: color-mix(in srgb, var(--moss) 8%, transparent); color: var(--ink); }
.navitem[aria-current="page"] { background: color-mix(in srgb, var(--moss) 13%, transparent); color: var(--ink); font-weight: 600; }
.navitem[aria-current="page"]::before {
  content: ""; position: absolute; left: -14px; top: 50%; translate: 0 -50%;
  width: 3px; height: 22px; border-radius: 0 3px 3px 0; background: var(--moss);
}
.navitem .num {
  flex: none; width: 22px;
  font-family: var(--f-mono); font-size: 11px; font-variant-numeric: tabular-nums;
  color: var(--ink-4); letter-spacing: .02em;
}
.navitem[aria-current="page"] .num { color: var(--moss); }
.navitem .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.navitem .tick { flex: none; width: 15px; height: 15px; color: var(--moss); opacity: 0; transition: opacity 200ms; }
.navitem.done .tick { opacity: 1; }
.navitem.done .t { color: var(--ink-3); }

.rail-foot {
  border-top: 1px solid var(--rule-soft);
  padding: 14px 18px;
  display: flex; align-items: center; gap: 8px;
}

/* progress meter in the rail */
.meter { padding: 4px 24px 16px; }
.meter-top {
  display: flex; justify-content: space-between; align-items: baseline;
  font-family: var(--f-mono); font-size: 10.5px; letter-spacing: .12em;
  text-transform: uppercase; color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}
.meter-track {
  margin-top: 8px; height: 5px; border-radius: 5px;
  background: var(--inset); overflow: hidden;
  box-shadow: inset 0 1px 2px rgba(52,40,24,.09);
}
.meter-fill {
  height: 100%; border-radius: 5px;
  background: linear-gradient(90deg, var(--moss-deep), var(--moss));
  transition: width 700ms var(--ease-out);
}

/* ---------- 6. TOP BAR (mobile) ---------- */
.topbar {
  display: none;
  position: sticky; top: 0; z-index: 45;
  align-items: center; gap: 12px;
  padding: 10px 14px;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--rule);
}
.topbar .tb-name { font-family: var(--f-display); font-size: 1.12rem; flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.iconbtn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 8px;
  color: var(--ink-2);
  border: 1px solid transparent;
  transition: background 200ms, color 200ms, border-color 200ms;
}
.iconbtn:hover { background: var(--inset); color: var(--ink); border-color: var(--rule-soft); }
.iconbtn svg { width: 18px; height: 18px; }

/* ---------- 7. CANVAS ---------- */
.canvas {
  margin-left: var(--rail-w);
  min-height: 100vh;
  padding: 0 clamp(20px, 4.6vw, 72px) 120px;
}
.view { max-width: var(--canvas); margin: 0 auto; padding-top: clamp(38px, 6vw, 72px); }

.view-enter { animation: viewIn 520ms var(--ease-out) both; }
@keyframes viewIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}
.stagger > * { animation: viewIn 560ms var(--ease-out) both; }
.stagger > *:nth-child(1) { animation-delay: 40ms; }
.stagger > *:nth-child(2) { animation-delay: 100ms; }
.stagger > *:nth-child(3) { animation-delay: 160ms; }
.stagger > *:nth-child(4) { animation-delay: 220ms; }
.stagger > *:nth-child(5) { animation-delay: 280ms; }
.stagger > *:nth-child(6) { animation-delay: 340ms; }

/* ---------- 8. PLATES (images) ---------- */
.plate { position: relative; margin: 0; }
.plate figure { margin: 0; }
.plate .frame {
  display: block;
  position: relative; overflow: hidden;
  background: var(--inset);
  border: 1px solid var(--rule);
  border-radius: 3px;
  box-shadow: var(--shadow-2);
}
.plate .frame::after {
  /* inner hairline: gives the print an edge without a heavy border */
  content: ""; position: absolute; inset: 0; pointer-events: none;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.4), inset 0 0 34px rgba(70,55,30,.09);
}
[data-theme="night"] .plate .frame::after { box-shadow: inset 0 0 0 1px rgba(255,255,255,.05), inset 0 0 34px rgba(0,0,0,.4); }
.plate img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* progressive image: LQIP blurs out under the real file */
.pimg { position: relative; display: block; background-size: cover; background-position: center; }
.pimg > img { opacity: 0; transition: opacity 620ms var(--ease); }
.pimg.loaded > img { opacity: 1; }
.pimg::after {
  content: ""; position: absolute; inset: 0;
  backdrop-filter: blur(14px);
  transition: opacity 620ms var(--ease);
}
.pimg.loaded::after { opacity: 0; backdrop-filter: blur(0); }

.caption {
  margin-top: 11px;
  display: flex; gap: 10px; align-items: baseline;
  font-family: var(--f-mono); font-size: 10.5px; letter-spacing: .1em;
  text-transform: uppercase; color: var(--ink-3);
}
.caption .n { color: var(--ochre); flex: none; font-variant-numeric: tabular-nums; }
.caption .c { color: var(--ink-3); font-family: var(--f-body); font-size: 12.5px;
  letter-spacing: 0; text-transform: none; font-style: italic; }

/* tape: sits on the figure, not the frame, so it can overhang the print */
.plate.taped { padding-top: 12px; }
.plate.taped::before {
  content: ""; position: absolute; z-index: 4; top: 0; left: 50%; translate: -50% 0;
  width: 96px; height: 26px;
  background: linear-gradient(180deg, rgba(214,196,150,.62), rgba(198,178,128,.42));
  border-left: 1px solid rgba(255,255,255,.4); border-right: 1px solid rgba(150,132,90,.3);
  box-shadow: 0 1px 3px rgba(60,45,20,.16);
  rotate: -1.2deg;
}
[data-theme="night"] .plate.taped::before { background: linear-gradient(180deg, rgba(90,84,62,.55), rgba(70,66,48,.42)); }

/* hairline contents list */
.toc { margin-top: 34px; border-top: 1px solid var(--rule); }
.toc a {
  display: flex; align-items: baseline; gap: 14px;
  padding: 11px 2px; border-bottom: 1px solid var(--rule-soft);
  text-decoration: none; color: var(--ink-2);
  transition: color 240ms, padding-left 320ms var(--ease);
}
.toc a:hover { color: var(--moss); padding-left: 8px; }
.toc a .k { font-family: var(--f-mono); font-size: 10px; letter-spacing: .14em;
  text-transform: uppercase; color: var(--ink-4); width: 34px; flex: none; font-variant-numeric: tabular-nums; }
.toc a .l { flex: 1; font-size: 15px; }
.toc a .n { font-family: var(--f-mono); font-size: 10.5px; color: var(--ink-4); font-variant-numeric: tabular-nums; }

/* briefing side list */
.reqlist { margin-top: 22px; border-top: 1px solid var(--rule); }
.reqlist li {
  display: flex; align-items: baseline; gap: 12px; list-style: none;
  padding: 9px 0; border-bottom: 1px solid var(--rule-soft); font-size: 14.5px;
}
.reqlist li .c {
  font-family: var(--f-mono); font-size: 11px; color: var(--ochre);
  font-variant-numeric: tabular-nums; flex: none; width: 66px; white-space: nowrap;
}
.reqlist li .n2 { flex: 1; color: var(--ink-2); }

/* ---------- 9. CARDS & SURFACES ---------- */
.card {
  background: var(--paper-2);
  border: 1px solid var(--rule);
  border-radius: 4px;
  box-shadow: var(--shadow-1);
}
.well {
  background: color-mix(in srgb, var(--paper-2) 70%, transparent);
  border: 1px solid var(--rule-soft);
  border-radius: 4px;
}

/* item / requisition card — interior matches the render background exactly,
   so the object appears to sit on the card rather than in a box */
.item {
  position: relative;
  display: flex; flex-direction: column;
  background: var(--paper-2);
  border: 1px solid var(--rule);
  border-radius: 4px;
  overflow: hidden;
  box-shadow: var(--shadow-1);
  transition: transform 420ms var(--ease-out), box-shadow 420ms var(--ease-out), border-color 300ms;
}
.item:hover { transform: translateY(-3px); box-shadow: var(--shadow-2); border-color: var(--ochre-lite); }
.item .thumb { display: block; background: var(--plate); aspect-ratio: 1; position: relative; overflow: hidden; }
[data-theme="night"] .item .thumb { background: #E9DDC5; }
.item .thumb img { width: 100%; height: 100%; object-fit: cover; }
.item .body { padding: 13px 14px 15px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.item .nm { font-size: 15px; font-weight: 600; line-height: 1.28; letter-spacing: -.005em; }
.item .qt { font-size: 13.5px; line-height: 1.45; color: var(--ink-2); font-style: italic; }

.coin {
  position: absolute; top: 9px; right: 9px; z-index: 2;
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px 3px 6px;
  background: color-mix(in srgb, #FBF3DF 92%, transparent);
  border: 1px solid var(--ochre-lite);
  border-radius: 999px;
  font-family: var(--f-mono); font-size: 11px; font-weight: 600;
  font-variant-numeric: tabular-nums; letter-spacing: .02em;
  color: #7A4E0C;
  box-shadow: 0 1px 3px rgba(90,60,10,.18);
}
.coin svg { width: 11px; height: 11px; }

/* got-it checkbox */
.gotit {
  display: flex; align-items: center; gap: 8px;
  margin-top: auto; padding-top: 10px;
  border-top: 1px dashed var(--rule);
  font-family: var(--f-mono); font-size: 10.5px; letter-spacing: .1em;
  text-transform: uppercase; color: var(--ink-3);
  transition: color 200ms;
}
.gotit:hover { color: var(--ink-2); }
.gotit .box {
  width: 15px; height: 15px; flex: none;
  border: 1.5px solid var(--rule); border-radius: 3px;
  background: var(--paper);
  display: grid; place-items: center;
  transition: background 220ms, border-color 220ms;
}
.gotit .box svg { width: 11px; height: 11px; color: #fff; opacity: 0; transform: scale(.6); transition: all 260ms var(--ease-out); }
.item.have { border-color: color-mix(in srgb, var(--moss) 45%, var(--rule)); }
.item.have .gotit .box { background: var(--moss); border-color: var(--moss); }
.item.have .gotit .box svg { opacity: 1; transform: none; }
.item.have .gotit { color: var(--moss); }

/* ---------- 10. MISSION HEADER ---------- */
.m-meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 20px;
  padding-bottom: 13px; border-bottom: 1px solid var(--rule);
  margin-bottom: 26px;
}
.m-meta .sep { color: var(--ink-4); }
.m-meta .grow { flex: 1; }

.m-head { display: flex; gap: clamp(18px, 3vw, 34px); align-items: flex-start; flex-wrap: wrap; }
.m-badge {
  flex: none; width: clamp(92px, 12vw, 132px); aspect-ratio: 1;
  background: var(--plate-badge);
  border: 1px solid var(--rule); border-radius: 4px;
  overflow: hidden; box-shadow: var(--shadow-2);
  rotate: -1.4deg;
  transition: rotate 500ms var(--ease-out);
}
.m-badge:hover { rotate: 0deg; }
.m-head .htext { flex: 1; min-width: 260px; }
.m-title { margin-top: 4px; }
.m-obj { margin-top: 12px; }

.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 15px; border-radius: 4px;
  border: 1px solid var(--rule);
  background: var(--paper-2);
  font-family: var(--f-mono); font-size: 11px; font-weight: 500;
  letter-spacing: .12em; text-transform: uppercase; color: var(--ink-2);
  transition: all 260ms var(--ease);
  white-space: nowrap;
}
.btn svg { width: 14px; height: 14px; }
.btn:hover { background: var(--inset); color: var(--ink); border-color: var(--ink-4); }
.btn-primary {
  background: var(--moss); border-color: var(--moss-deep); color: #FBF7EE;
  box-shadow: 0 1px 2px rgba(30,45,10,.28);
}
[data-theme="night"] .btn-primary { color: #14180F; }
.btn-primary:hover { background: var(--moss-deep); color: #FBF7EE; border-color: var(--moss-deep); }
[data-theme="night"] .btn-primary:hover { color: #14180F; }
.btn.on { background: var(--moss-soft); border-color: var(--moss); color: var(--moss-deep); }
[data-theme="night"] .btn.on { color: var(--moss-deep); }

/* ---------- 11. SCRIPT CARDS ---------- */
.script {
  position: relative;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--paper-2);
  box-shadow: var(--shadow-1);
  overflow: hidden;
}
.script + .script { margin-top: 18px; }
.script::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--tone, var(--moss));
}
.script.intro { --tone: var(--teal); }
.script.outro { --tone: var(--moss); }

.script-head {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 18px 12px 21px;
  border-bottom: 1px solid var(--rule-soft);
  background: color-mix(in srgb, var(--tone) 6%, transparent);
}
.script-head .lbl {
  font-family: var(--f-mono); font-size: 10.5px; letter-spacing: .16em;
  text-transform: uppercase; color: var(--tone); font-weight: 600;
}
.script-head .grow { flex: 1; }
.script-body {
  padding: 20px 26px 24px 29px;
  font-size: 17.5px; line-height: 1.68;
}
.script-body strong {
  display: block; margin-bottom: 7px;
  font-family: var(--f-mono); font-size: 10.5px; font-weight: 600;
  letter-spacing: .14em; text-transform: uppercase; color: var(--ink-3);
}
.script-body em { color: var(--ink-3); }

/* ---------- 12. READ-ALOUD FOCUS MODE ---------- */
.reader {
  position: fixed; inset: 0; z-index: 90;
  display: none; flex-direction: column;
  background: #16180F;
  color: #F0E8D4;
}
.reader[open] { display: flex; }
.reader::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(120% 80% at 50% -10%, rgba(210,170,90,.13), transparent 60%),
              var(--grain);
  opacity: .8;
}
.reader-bar {
  position: relative; z-index: 2;
  display: flex; align-items: center; gap: 14px;
  padding: 16px clamp(18px, 4vw, 40px);
  border-bottom: 1px solid rgba(240,232,212,.14);
}
.reader-bar .rl { font-family: var(--f-mono); font-size: 11px; letter-spacing: .16em;
  text-transform: uppercase; color: #C9BE9E; }
.reader-bar .grow { flex: 1; }
.reader-bar .iconbtn { color: #D8CFB4; }
.reader-bar .iconbtn:hover { background: rgba(240,232,212,.1); color: #fff; border-color: transparent; }
.reader-body {
  position: relative; z-index: 2;
  flex: 1; overflow-y: auto;
  padding: clamp(30px, 6vh, 72px) clamp(20px, 5vw, 48px) 100px;
}
.reader-inner { max-width: 740px; margin: 0 auto; }
.reader-title { font-family: var(--f-display); font-size: clamp(1.8rem,4vw,2.7rem); line-height: 1.05; margin-bottom: 8px; }
.reader-kicker { font-family: var(--f-mono); font-size: 11px; letter-spacing: .18em;
  text-transform: uppercase; color: var(--ochre-lite); margin-bottom: 22px; }
.reader-text {
  font-size: clamp(1.2rem, 2.1vw, 1.62rem);
  line-height: 1.62;
  text-wrap: pretty;
}
.reader-text strong {
  display: block; margin-bottom: 14px;
  font-family: var(--f-mono); font-size: 12px; font-weight: 500;
  letter-spacing: .16em; text-transform: uppercase; color: var(--ochre-lite);
}
.reader-nav {
  position: absolute; z-index: 3; left: 0; right: 0; bottom: 0;
  display: flex; gap: 12px; justify-content: center;
  padding: 56px 18px 22px;
  background: linear-gradient(transparent, rgba(22,24,15,.86) 34%, #16180F 62%);
}
.reader-body { padding-bottom: 150px; }
.reader .btn { background: rgba(240,232,212,.08); border-color: rgba(240,232,212,.24); color: #E7DEC4; }
.reader .btn:hover { background: rgba(240,232,212,.16); color: #fff; }
.reader .btn[disabled] { opacity: .32; pointer-events: none; }

/* ---------- 13. GRIDS ---------- */
.grid { display: grid; gap: clamp(14px, 1.8vw, 22px); }
.g-4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.g-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.split { display: grid; gap: clamp(24px, 3.4vw, 46px); grid-template-columns: 1fr 1fr; align-items: start; }
.split-wide { grid-template-columns: 1.05fr .95fr; }

/* ---------- 14. BADGE CASE ---------- */
.case {
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--umber) 9%, var(--paper-2)), var(--paper-2));
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: clamp(20px, 3vw, 38px);
  box-shadow: var(--shadow-2), inset 0 1px 0 rgba(255,255,255,.5);
}
[data-theme="night"] .case { box-shadow: var(--shadow-2), inset 0 1px 0 rgba(255,255,255,.05); }
.case-shelf { display: grid; grid-template-columns: repeat(5, minmax(0,1fr)); gap: clamp(14px, 2vw, 26px); }
.bslot { text-align: center; }
.bslot .disc {
  display: block;
  position: relative; aspect-ratio: 1; border-radius: 50%;
  background: var(--plate-badge);
  border: 1px solid var(--rule);
  overflow: hidden;
  box-shadow: inset 0 2px 8px rgba(70,52,20,.16), var(--shadow-1);
  transition: transform 500ms var(--ease-out), box-shadow 500ms var(--ease-out), filter 600ms;
}
.bslot .disc img { width: 100%; height: 100%; object-fit: cover; }
.bslot.locked .disc {
  filter: grayscale(.92) sepia(.42) contrast(.9) brightness(1.04) opacity(.5);
  box-shadow: inset 0 3px 12px rgba(70,52,20,.3);
}
.bslot.locked .disc::after {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(120% 120% at 50% 20%, rgba(120,96,52,.06), rgba(90,70,40,.16));
}
.bslot.locked:hover .disc { filter: grayscale(.35) sepia(.1) opacity(.82); }
.bslot:not(.locked) .disc:hover { transform: translateY(-4px) scale(1.03); box-shadow: 0 10px 26px -8px rgba(80,60,20,.45); }
.bslot .bn { margin-top: 10px; font-family: var(--f-mono); font-size: 9.5px;
  letter-spacing: .1em; text-transform: uppercase; color: var(--ink-4); font-variant-numeric: tabular-nums; }
.bslot .bt { margin-top: 3px; font-size: 12.5px; line-height: 1.3; color: var(--ink-2); }
.bslot:not(.locked) .bt { color: var(--ink); font-weight: 600; }

/* ---------- 15. MARKET INDEX ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 22px; }
.search {
  flex: 1; min-width: 220px;
  display: flex; align-items: center; gap: 9px;
  padding: 9px 13px;
  background: var(--paper-2); border: 1px solid var(--rule); border-radius: 4px;
  transition: border-color 240ms, box-shadow 240ms;
}
.search:focus-within { border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 16%, transparent); }
.search svg { width: 15px; height: 15px; color: var(--ink-4); flex: none; }
.search input { flex: 1; border: 0; background: none; outline: none; font-size: 15px; font-family: var(--f-body); }
.search input::placeholder { color: var(--ink-4); font-style: italic; }

.chip {
  padding: 7px 12px; border-radius: 999px;
  border: 1px solid var(--rule); background: var(--paper-2);
  font-family: var(--f-mono); font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--ink-2); transition: all 220ms;
  font-variant-numeric: tabular-nums;
}
.chip:hover { border-color: var(--ink-4); }
.chip[aria-pressed="true"] { background: var(--moss); border-color: var(--moss-deep); color: #FBF7EE; }
[data-theme="night"] .chip[aria-pressed="true"] { color: #14180F; }

.mi-mission {
  display: inline-block; margin-top: 6px;
  font-family: var(--f-mono); font-size: 9.5px; letter-spacing: .1em;
  text-transform: uppercase; color: var(--ochre);
}

/* ---------- 16. HOME ---------- */
.hero { position: relative; }
.hero-grid { display: grid; grid-template-columns: 1.02fr .98fr; gap: clamp(28px, 4vw, 60px); align-items: center; }
.hero-figs { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(12px, 1.4vw, 20px); }
.hero-figs .wide { grid-column: span 2; }
.item .thumb > .pimg { position: absolute; inset: 0; }
.item .thumb > .pimg img { width: 100%; height: 100%; object-fit: cover; }
.m-badge > .pimg { display: block; width: 100%; height: 100%; }
.m-badge > .pimg img { width: 100%; height: 100%; object-fit: cover; }
.bslot .disc > .pimg { position: absolute; inset: 0; }
.bslot .disc > .pimg img { width: 100%; height: 100%; object-fit: cover; }

.stat-row {
  display: grid; grid-template-columns: repeat(4, minmax(0,1fr));
  border: 1px solid var(--rule); border-radius: 4px; overflow: hidden;
  background: var(--paper-2);
}
.stat { padding: 18px 20px; border-right: 1px solid var(--rule-soft); }
.stat:last-child { border-right: 0; }
.stat .v { font-family: var(--f-display); font-size: clamp(1.7rem, 3vw, 2.3rem); line-height: 1;
  color: var(--moss); font-variant-numeric: lining-nums tabular-nums; }
.stat .k { margin-top: 7px; font-family: var(--f-mono); font-size: 10px; letter-spacing: .13em;
  text-transform: uppercase; color: var(--ink-3); }

/* the 12-day cycle diagram */
.cycle { display: flex; align-items: stretch; gap: 4px; margin-top: 6px; }
.cycle .d {
  flex: 1; height: 54px; border-radius: 3px;
  background: var(--inset); border: 1px solid var(--rule-soft);
  display: grid; place-items: center;
  font-family: var(--f-mono); font-size: 10px; color: var(--ink-4);
  font-variant-numeric: tabular-nums;
  transition: background 300ms;
}
.cycle .d.q { background: color-mix(in srgb, var(--ochre) 13%, var(--paper-2)); border-color: color-mix(in srgb, var(--ochre) 32%, var(--rule)); color: var(--ochre); }
.cycle .d.m {
  flex: 1.7; background: var(--moss); border-color: var(--moss-deep); color: #F6F2E4;
  font-weight: 600; letter-spacing: .06em; box-shadow: var(--shadow-1);
}
[data-theme="night"] .cycle .d.m { color: #14180F; }

.mgrid-card {
  position: relative; display: block; text-decoration: none;
  border: 1px solid var(--rule); border-radius: 4px; overflow: hidden;
  background: var(--paper-2); box-shadow: var(--shadow-1);
  transition: transform 420ms var(--ease-out), box-shadow 420ms var(--ease-out), border-color 260ms;
}
.mgrid-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-2); border-color: var(--moss); }
.mgrid-card .sc { display: block; aspect-ratio: 16/10; background: var(--inset); position: relative; overflow: visible; }
.mgrid-card .sc > .pimg { position: absolute; inset: 0; overflow: hidden; }
.mgrid-card .sc > .pimg img { width: 100%; height: 100%; object-fit: cover; }
.mgrid-card .bd { display: block; }
.mgrid-card .sc img { width: 100%; height: 100%; object-fit: cover; }
.mgrid-card .bg {
  position: absolute; right: 11px; bottom: -22px; z-index: 2;
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--plate-badge); border: 2px solid var(--paper-2);
  overflow: hidden; box-shadow: var(--shadow-2);
}
.mgrid-card .bd { padding: 15px 16px 17px; }
.mgrid-card .no { font-family: var(--f-mono); font-size: 10px; letter-spacing: .14em;
  text-transform: uppercase; color: var(--ochre); font-variant-numeric: tabular-nums; }
.mgrid-card .ti { font-family: var(--f-display); font-size: 1.32rem; line-height: 1.12; margin-top: 5px;
  padding-right: 52px; }
.mgrid-card .ob { margin-top: 7px; font-size: 13px; color: var(--ink-2); line-height: 1.42; }
.mgrid-card.done::after {
  content: ""; position: absolute; top: 11px; left: 11px; z-index: 3;
  width: 22px; height: 22px; border-radius: 50%; background: var(--moss);
  box-shadow: 0 0 0 2px var(--paper-2), var(--shadow-1);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='3.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E");
  background-size: 13px; background-repeat: no-repeat; background-position: center;
}

/* ---------- 17. PREV / NEXT ---------- */
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 64px; }
.pager a {
  display: block; padding: 17px 19px; text-decoration: none;
  border: 1px solid var(--rule); border-radius: 4px; background: var(--paper-2);
  transition: all 320ms var(--ease);
}
.pager a:hover { border-color: var(--moss); background: color-mix(in srgb, var(--moss) 5%, var(--paper-2)); }
.pager .dir { font-family: var(--f-mono); font-size: 10px; letter-spacing: .16em;
  text-transform: uppercase; color: var(--ink-4); }
.pager .tl { margin-top: 6px; font-family: var(--f-display); font-size: 1.18rem; line-height: 1.15; }
.pager .r { text-align: right; }

/* ---------- 18. COMMAND PALETTE ---------- */
.cmdk { position: fixed; inset: 0; z-index: 95; display: none; }
.cmdk[open] { display: block; }
.cmdk .scrim { position: absolute; inset: 0; background: rgba(30,24,14,.34); backdrop-filter: blur(1.5px) saturate(.9);
  animation: fadeIn 220ms var(--ease) both; }
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
.cmdk .panel {
  position: relative; max-width: 620px; margin: 12vh auto 0;
  background: var(--paper-2); border: 1px solid var(--rule); border-radius: 8px;
  box-shadow: var(--shadow-3); overflow: hidden;
  animation: viewIn 300ms var(--ease-out) both;
}
.cmdk .cin { display: flex; align-items: center; gap: 11px; padding: 15px 18px; border-bottom: 1px solid var(--rule-soft); }
.cmdk .cin svg { width: 17px; height: 17px; color: var(--ink-4); }
.cmdk .cin input { flex: 1; border: 0; background: none; outline: none; font-size: 17px; font-family: var(--f-body); }
.cmdk .clist { max-height: 46vh; overflow-y: auto; padding: 7px; }
.cmdk .crow {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 9px 12px; border-radius: 5px; text-align: left; font-size: 15px;
}
.cmdk .crow .k { font-family: var(--f-mono); font-size: 10px; letter-spacing: .1em;
  text-transform: uppercase; color: var(--ink-4); flex: none; width: 62px; font-variant-numeric: tabular-nums; }
.cmdk .crow .l { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmdk .crow[data-sel="1"] { background: color-mix(in srgb, var(--moss) 13%, transparent); }
.cmdk .cfoot { padding: 10px 16px; border-top: 1px solid var(--rule-soft); display: flex; gap: 16px;
  font-family: var(--f-mono); font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-4); }
kbd { font-family: var(--f-mono); font-size: 10px; padding: 2px 5px; border: 1px solid var(--rule);
  border-bottom-width: 2px; border-radius: 3px; background: var(--paper); }

/* ---------- 19. MISC ---------- */
.tag {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 9px; border-radius: 3px;
  background: var(--tone-soft, var(--moss-soft));
  color: var(--tone-c, var(--moss-deep));
  font-family: var(--f-mono); font-size: 10px; letter-spacing: .11em; text-transform: uppercase;
}
.tag.teal { --tone-soft: var(--teal-soft); --tone-c: var(--teal); }
.tag.ochre { --tone-soft: var(--ochre-soft); --tone-c: var(--ochre); }
.tag.rose { --tone-soft: var(--rose-soft); --tone-c: var(--rose); }

.skip {
  position: absolute; left: 12px; top: -60px; z-index: 200;
  padding: 10px 16px; background: var(--moss); color: #fff; border-radius: 4px;
  font-family: var(--f-mono); font-size: 12px; letter-spacing: .1em; text-transform: uppercase;
  transition: top 200ms;
}
.skip:focus { top: 12px; }

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

.toast {
  position: fixed; z-index: 120; left: 50%; bottom: 30px; translate: -50% 0;
  display: flex; align-items: center; gap: 10px;
  padding: 12px 20px; border-radius: 999px;
  background: var(--ink); color: var(--paper);
  font-family: var(--f-mono); font-size: 11px; letter-spacing: .12em; text-transform: uppercase;
  box-shadow: var(--shadow-3);
  animation: toastIn 380ms var(--ease-out) both;
}
@keyframes toastIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.toast svg { width: 15px; height: 15px; color: var(--ochre-lite); }

/* ---------- 20. RESPONSIVE ---------- */
@media (max-width: 1180px) { :root { --rail-w: 260px; } }
@media (max-width: 1040px) {
  .rail {
    transform: translateX(-100%);
    transition: transform 380ms var(--ease-out);
    box-shadow: none; width: 300px;
  }
  body.nav-open .rail { transform: none; box-shadow: var(--shadow-3); }
  body.nav-open::after {
    content: ""; position: fixed; inset: 0; z-index: 39;
    background: rgba(30,24,14,.36); backdrop-filter: blur(2px);
    animation: fadeIn 240ms var(--ease) both;
  }
  .canvas { margin-left: 0; }
  .topbar { display: flex; }
  .hero-grid { grid-template-columns: 1fr; }
  .split, .split-wide { grid-template-columns: 1fr; }
  .g-4 { grid-template-columns: repeat(3, minmax(0,1fr)); }
}
@media (max-width: 760px) {
  body { font-size: 16.5px; }
  .g-4, .g-3 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .stat-row { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .stat:nth-child(2) { border-right: 0; }
  .stat:nth-child(-n+2) { border-bottom: 1px solid var(--rule-soft); }
  .case-shelf { grid-template-columns: repeat(3, minmax(0,1fr)); }
  .pager { grid-template-columns: 1fr; }
  .cycle .d:not(.m) { font-size: 0; }
  .cycle .d { height: 42px; }
  .script-body { padding: 17px 18px 20px 21px; font-size: 16.5px; }
  .hero-figs { grid-template-columns: 1fr 1fr; }
  .actions .btn { flex: 1 1 132px; justify-content: center; }
  .m-meta { gap: 8px 12px; font-size: 13px; }
  .m-meta .sep { display: none; }
}
@media (max-width: 480px) {
  .g-4, .g-3, .g-2 { grid-template-columns: 1fr 1fr; }
  .case-shelf { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .m-badge { width: 78px; }
}

/* ---------- 21. PRINT — the GM's script sheet ---------- */
@media print {
  @page { margin: 16mm 14mm; size: letter; }
  .substrate, .rail, .topbar, .actions, .pager, .cmdk, .reader, .toast, .gotit,
  .noprint, .rail-foot { display: none !important; }
  body { background: #fff; color: #000; font-size: 11.5pt; }
  .canvas { margin: 0; padding: 0; }
  .view { padding-top: 0; max-width: none; }
  .card, .well, .script, .item, .plate .frame { box-shadow: none !important; border-color: #bbb !important; background: #fff !important; }
  .script { break-inside: avoid; }
  .m-head { break-after: avoid; }
  .grid { break-inside: avoid; }
  a[href]::after { content: ""; }
  .print-only { display: block !important; }
  .script-body { font-size: 12pt; }
  .m-badge { rotate: none; width: 74px; }

  /* purpose-built GM sheet: drop the screen furniture, keep what you read aloud */
  .plate, .req-section, .toc, .hero-figs, .case, .filters { display: none !important; }
  .split, .split-wide, .hero-grid { grid-template-columns: 1fr !important; }
  .rule-double { margin: 14px 0 !important; }
  .m-head { gap: 14px; }
  h1.display { font-size: 26pt; }
  .m-obj { font-size: 12pt; }
  .reqlist li { padding: 5px 0; font-size: 11pt; }
  .sec-head { margin-bottom: 10px; }
  section { margin-top: 22px !important; }
  .sheet-head {
    display: flex !important; justify-content: space-between; gap: 20px;
    font-family: var(--f-mono); font-size: 8pt; letter-spacing: .1em;
    text-transform: uppercase; color: #555;
    padding-bottom: 7px; margin-bottom: 16px; border-bottom: 1px solid #ccc;
  }
  .m-meta { display: none; }
  .script + .script { margin-top: 12px; }
}
.print-only { display: none; }
