:root {
  color-scheme: dark;
  --ink: #f8f4ea;
  --muted: #c6c0b2;
  --deep: #091410;
  --line: rgba(235, 222, 193, 0.2);
  --green: #8ee0a3;
  --gold: #e1bd6d;
  --rust: #e48f69;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.32);
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; overflow: hidden; }

body {
  min-width: 320px;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 85% 10%, rgba(142, 224, 163, 0.13), transparent 32rem),
    radial-gradient(circle at 10% 55%, rgba(225, 189, 109, 0.1), transparent 30rem),
    linear-gradient(145deg, #07100d 0%, #0c1b15 55%, #08120f 100%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body::before {
  position: fixed;
  inset: 0;
  content: "";
  pointer-events: none;
  opacity: 0.2;
  background-image: linear-gradient(rgba(255,255,255,.025) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.025) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: linear-gradient(to bottom, black, transparent 78%);
}

a { color: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; }
[hidden] { display: none !important; }

.reader {
  position: relative;
  width: min(1440px, 100%);
  height: 100dvh;
  margin: 0 auto;
  padding: clamp(10px, 1.4vw, 20px);
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: clamp(7px, 1vw, 12px);
}

.story-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 24px;
  align-items: center;
  min-width: 0;
}

.header-copy { min-width: 0; }
.eyebrow, .card-label, .chapter-kicker, .chapter-number {
  margin: 0;
  color: var(--green);
  font-size: .67rem;
  font-weight: 850;
  letter-spacing: .13em;
  text-transform: uppercase;
}

h1 {
  margin: 2px 0 3px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.7rem, 3vw, 2.75rem);
  font-weight: 500;
  letter-spacing: -.04em;
  line-height: .95;
}

.standfirst {
  max-width: 860px;
  margin: 0;
  color: var(--muted);
  font-size: clamp(.78rem, 1.15vw, .95rem);
  line-height: 1.35;
}

.header-side { display: grid; justify-items: end; gap: 7px; }
.status-note {
  display: flex;
  gap: 8px;
  align-items: center;
  max-width: 560px;
  padding: 7px 11px;
  border: 1px solid rgba(225, 189, 109, .34);
  border-radius: 11px;
  color: #eadcbd;
  background: rgba(225, 189, 109, .08);
  font-size: .72rem;
  line-height: 1.3;
}
.status-note strong { flex: 0 0 auto; color: var(--gold); }
.header-actions { display: flex; flex-wrap: wrap; justify-content: end; gap: 6px; }

.button {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 12px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 760;
  text-decoration: none;
  cursor: pointer;
}
.button:focus-visible, .chapter-tab:focus-visible, .view-tab:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.button.primary { color: #07100d; background: var(--green); }
.button.secondary { border-color: var(--line); color: var(--ink); background: rgba(255,255,255,.055); }
.button.ghost { color: var(--muted); background: transparent; }
.button:disabled { opacity: .38; cursor: not-allowed; }

.chapter-rail {
  display: grid;
  grid-template-columns: repeat(7, minmax(112px, 1fr));
  gap: 6px;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: thin;
}

.chapter-tab {
  min-width: 0;
  min-height: 58px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--muted);
  background: rgba(255,255,255,.035);
  text-align: left;
  cursor: pointer;
}
.chapter-tab span { display: block; margin-bottom: 3px; color: var(--green); font-size: .56rem; font-weight: 850; letter-spacing: .1em; }
.chapter-tab strong { display: -webkit-box; overflow: hidden; font-size: .72rem; line-height: 1.2; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.chapter-tab[aria-current="step"] { border-color: rgba(142, 224, 163, .7); color: var(--ink); background: rgba(142, 224, 163, .12); }

.chapter-stage {
  min-height: 0;
  padding: clamp(10px, 1.25vw, 18px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: linear-gradient(150deg, rgba(21, 43, 34, .96), rgba(8, 22, 16, .95));
  box-shadow: var(--shadow);
  overflow: hidden;
}

.stage-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.chapter-number { color: var(--gold); }
.view-tabs { display: flex; gap: 5px; padding: 3px; border: 1px solid var(--line); border-radius: 999px; background: rgba(0,0,0,.18); }
.view-tab { min-height: 30px; padding: 5px 11px; border: 0; border-radius: 999px; color: var(--muted); background: transparent; font-size: .72rem; font-weight: 800; cursor: pointer; }
.view-tab[aria-selected="true"] { color: #07100d; background: var(--green); }

.chapter-viewport {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1.22fr) minmax(340px, .78fr);
  gap: clamp(12px, 1.5vw, 22px);
}

.chapter-visual {
  position: relative;
  min-width: 0;
  min-height: 0;
  height: 100%;
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #07100d;
}
.chapter-visual picture, .chapter-visual img { display: block; width: 100%; height: 100%; }
.chapter-visual img { object-fit: cover; }
.chapter-visual::after { position: absolute; inset: 0; content: ""; pointer-events: none; background: linear-gradient(to top, rgba(4, 13, 9, .48), transparent 24%); }
.chapter-visual figcaption { position: absolute; z-index: 1; left: 11px; bottom: 10px; padding: 5px 8px; border: 1px solid rgba(255,255,255,.18); border-radius: 999px; color: rgba(255,255,255,.88); background: rgba(4,13,9,.58); font-size: .6rem; font-weight: 750; backdrop-filter: blur(7px); }

.chapter-content, .view-panel { min-width: 0; min-height: 0; height: 100%; }
.chapter-content { overflow: hidden; }
.story-view { display: grid; grid-template-rows: minmax(0, 1fr) auto; gap: 9px; }
.story-card { min-height: 0; overflow: auto; padding-right: 5px; scrollbar-width: thin; }
.chapter-kicker { margin-bottom: 5px; }
.story-card h2 { margin: 0 0 9px; font-family: Georgia, "Times New Roman", serif; font-size: clamp(1.65rem, 3vw, 3rem); font-weight: 500; letter-spacing: -.035em; line-height: .98; }
.chapter-scene { margin: 0 0 11px; color: var(--muted); font-size: clamp(.78rem, 1vw, .94rem); line-height: 1.48; }
blockquote { margin: 0; padding: 10px 0 0 13px; border-left: 3px solid var(--green); color: #eee7da; font-family: Georgia, "Times New Roman", serif; font-size: clamp(.92rem, 1.4vw, 1.14rem); line-height: 1.48; }
blockquote::before { display: block; margin-bottom: 5px; color: var(--gold); content: "Written narration script · voice not recorded"; font-family: Inter, ui-sans-serif, system-ui, sans-serif; font-size: .58rem; font-weight: 850; letter-spacing: .1em; text-transform: uppercase; }

details { border: 1px solid var(--line); border-radius: 12px; background: rgba(255,255,255,.04); }
summary { padding: 9px 11px; color: var(--gold); font-size: .7rem; font-weight: 800; cursor: pointer; }
.evidence-card[open] { max-height: 46%; overflow: auto; }
.evidence-card > .card-label, .evidence-card ul, .pending-box { margin-right: 12px; margin-left: 12px; }
.evidence-card ul { display: grid; gap: 5px; margin-top: 6px; margin-bottom: 9px; padding-left: 18px; color: #ded8cc; font-size: .7rem; line-height: 1.35; }
.evidence-card li::marker { color: var(--gold); }
.pending-box { padding: 9px 0 11px; border-top: 1px solid var(--line); }
.pending-box .card-label { color: var(--rust); }
.pending-box p:last-child { margin: 5px 0 0; color: var(--muted); font-size: .7rem; line-height: 1.35; }

.tutorial-card { display: grid; grid-template-rows: auto auto minmax(0, 1fr) auto auto; gap: 9px; }
.tutorial-heading { min-height: 0; }
.tutorial-heading h3 { margin: 3px 0 5px; font-family: Georgia, "Times New Roman", serif; font-size: clamp(1.4rem, 2.5vw, 2.35rem); font-weight: 500; letter-spacing: -.035em; line-height: 1; }
.tutorial-heading > p:last-child { margin: 0; color: var(--muted); font-size: .76rem; line-height: 1.4; }
.tutorial-state { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border: 1px solid rgba(225,189,109,.34); border-radius: 10px; color: var(--muted); background: rgba(225,189,109,.07); font-size: .68rem; line-height: 1.3; }
.tutorial-state strong { flex: 0 0 auto; color: var(--gold); }
.tutorial-steps { min-height: 0; margin: 0; padding: 0; list-style: none; }
.tutorial-step { height: 100%; min-height: 0; padding: clamp(13px, 1.5vw, 20px); overflow: auto; border: 1px solid var(--line); border-radius: 14px; background: rgba(4,13,9,.42); scrollbar-width: thin; }
.tutorial-step::before { display: inline-flex; min-width: 31px; height: 31px; align-items: center; justify-content: center; margin-bottom: 9px; border-radius: 50%; color: #07100d; background: var(--green); content: attr(data-step-number); font-size: .66rem; font-weight: 900; }
.tutorial-step h4 { margin: 0 0 6px; font-size: .92rem; line-height: 1.3; }
.tutorial-step .step-action { margin: 0 0 10px; color: var(--muted); font-size: .77rem; line-height: 1.4; }
.tutorial-step .step-script { margin: 0; padding-top: 10px; border-top: 1px solid var(--line); color: #eee7da; font-family: Georgia, "Times New Roman", serif; font-size: clamp(.9rem, 1.35vw, 1.06rem); line-height: 1.45; }
.tutorial-step .step-script::before { display: block; margin-bottom: 5px; color: var(--gold); content: "Narration script · voice not recorded"; font-family: Inter, ui-sans-serif, system-ui, sans-serif; font-size: .58rem; font-weight: 850; letter-spacing: .09em; text-transform: uppercase; }
.tutorial-step-controls { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: center; }
.tutorial-step-controls p { margin: 0; color: var(--muted); font-size: .68rem; text-align: center; }
.tutorial-review p { margin: 0; padding: 0 11px 10px; color: var(--muted); font-size: .7rem; line-height: 1.35; }

.chapter-controls { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; padding-top: 8px; border-top: 1px solid var(--line); }
.chapter-controls p { margin: 0; color: var(--muted); font-size: .7rem; text-align: center; }
.noscript { padding: 20px; text-align: center; }

@media (max-width: 880px) {
  .reader { padding: 8px; gap: 7px; }
  .story-header { grid-template-columns: minmax(0, 1fr) auto; gap: 10px; }
  .standfirst { display: none; }
  .status-note { max-width: 340px; }
  .status-note span { display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
  .chapter-rail { grid-template-columns: repeat(7, 122px); }
  .chapter-viewport { grid-template-columns: 1fr; grid-template-rows: minmax(150px, 40%) minmax(0, 1fr); }
  .chapter-visual { border-radius: 12px; }
  .chapter-content { min-height: 0; }
}

@media (max-width: 560px) {
  .story-header { grid-template-columns: 1fr; }
  .header-copy { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
  .header-copy .eyebrow { display: none; }
  h1 { margin: 0; font-size: 1.5rem; }
  .header-side { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
  .status-note { min-width: 0; padding: 5px 8px; }
  .status-note span { display: none; }
  .header-actions { flex-wrap: nowrap; }
  .header-actions .button { min-height: 31px; padding: 5px 8px; font-size: .65rem; }
  .chapter-tab { min-height: 48px; padding: 6px 8px; }
  .chapter-stage { padding: 8px; border-radius: 14px; }
  .stage-toolbar { gap: 7px; }
  .view-tab { padding: 4px 8px; font-size: .64rem; }
  .chapter-viewport { grid-template-rows: minmax(130px, 34%) minmax(0, 1fr); gap: 8px; }
  .story-card h2 { font-size: clamp(1.35rem, 6.5vw, 1.8rem); }
  .chapter-scene { font-size: .72rem; line-height: 1.35; }
  blockquote { font-size: .82rem; line-height: 1.35; }
  .tutorial-heading > p:last-child { display: none; }
  .tutorial-state span { display: none; }
  .tutorial-step-controls .button { min-height: 32px; padding: 5px 8px; font-size: .64rem; }
  .chapter-controls .button { min-height: 32px; padding: 5px 9px; font-size: .68rem; }
}

@media (max-height: 720px) and (min-width: 881px) {
  .standfirst { display: none; }
  .chapter-tab { min-height: 48px; }
  .status-note { padding-block: 5px; }
  .reader { padding-block: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
}
