/* ───────────────────────── Dostoevsky’s Petersburg ───────────────────────── */

:root {
  /* Colours taken from the murals: map blues, garden sage, roof rose, chalky highlights; slate ink. */
  --ink: #1e2027;
  --ink-soft: #4b4e5a;
  --paper: #eeebe3;
  --paper-2: #e2ded4;
  --paper-edge: #c8c4ba;
  --night: #0e1014;
  --mist: #c4cfe0;            /* pale street-map blue */
  --periwinkle: #8e9cc0;      /* street lines */
  --periwinkle-hi: #a9b6d4;
  --sage: #a3b29a;            /* gardens */
  --rose: #c7998f;            /* roofs and brick */
  --chalk: #ece7dc;           /* highlights */
  --accent: #9a5248;          /* muted brick for Crime and Punishment */
  --accent-soft: rgba(154, 82, 72, .13);
  --glass: rgba(16, 18, 23, .62);
  --line: rgba(234, 233, 228, .22);
  --reader-w: clamp(425px, 34vw, 625px);
  --debug-panel-w: 15rem;     /* the debug menu, on the left */
  --debug-side-w: 18.75rem;      /* a debug topic's knobs, on the right */
  --edit-side-w: 24rem;       /* the shot editor's, there */
  --debug-w: 0px;             /* the debug menu's width while it's open */
  --side-w: 0px;              /* the debug topic's width while it's open; the page sits beside it */
  /* Where the viewer stops: set by js/app.js so nothing is drawn behind the page or the debug panel. */
  --view-l: 0px;
  --view-r: 0px;
  --view-b: 0px;
  --hud-h: 3.5rem;
  --thread-h: 2.875rem;
  --voice-lanes: 0;   /* the shot editor's voice lanes, set by js/editor.js */
  --timeline-h: calc(9.5rem + var(--voice-lanes) * 2.25rem);
  --display: 'Cormorant Garamond', 'Cormorant', Georgia, serif;
  --sc: 'Cormorant SC', 'Cormorant Garamond', Georgia, serif;
  --body: 'EB Garamond', Garamond, Georgia, serif;
  --ui: system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: ui-monospace, 'SF Mono', SFMono-Regular, Menlo, monospace;
  --t-slow: 1.2s cubic-bezier(.22, .61, .36, 1);
}
body[data-book="idiot"] {
  --accent: #3f5f86;          /* deep map blue for The Idiot */
  --accent-soft: rgba(63, 95, 134, .13);
}

* { box-sizing: border-box; }
html { font-size: 125%; } /* all type and controls at 125% */
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--night); color: var(--paper); }
body { font-family: var(--body); -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
svg { fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.smallcaps { font-family: var(--sc); letter-spacing: .14em; text-transform: lowercase; font-variant: small-caps; }
em { font-style: italic; }

/* ── Painting & atmosphere ─────────────────────────────────────────────── */

#viewer { position: fixed; top: 0; left: var(--view-l); right: var(--view-r); bottom: var(--view-b); background: #121418; opacity: 0; transition: opacity 1.8s ease; }
body:not([data-mode="landing"]) #viewer { opacity: 1; }
#viewer .openseadragon-canvas { outline: none; }

#vignette, #flash { position: fixed; inset: 0; pointer-events: none; }
/* A shot's fade to and from black (js/reading.js lookAt): over the painting, under the page. */
#blackout { position: fixed; inset: 0; pointer-events: none; background: #000; opacity: 0; }

#vignette {
  background: radial-gradient(ellipse 75% 70% at var(--vx, 50%) 50%, transparent 55%, rgba(8, 10, 14, .55) 100%);
  opacity: .55; transition: opacity 2s ease;
}

/* WebGPU atmosphere (js/effects.js): buffers drawn in mural space, moved with the camera by transform. */
#effects { position: fixed; top: 0; left: var(--view-l); right: var(--view-r); bottom: var(--view-b); pointer-events: none; overflow: hidden; opacity: 0; transition: opacity 1.8s ease; }
#effects.ready { opacity: 1; }
body[data-mode="landing"] #effects { opacity: 0; }
#effects .fx-layer { position: absolute; left: 0; top: 0; transform-origin: 0 0; }

/* One-shot effects */
#flash { opacity: 0; mix-blend-mode: screen; }
#flash.lightning { background: #dfe8ff; animation: lightning .9s ease-out; }
@keyframes lightning { 0% { opacity: 0; } 6% { opacity: .75; } 12% { opacity: .05; } 22% { opacity: .5; } 40% { opacity: 0; } 100% { opacity: 0; } }
#flash.aura { background: radial-gradient(circle at var(--vx, 50%) 45%, rgba(255, 236, 170, .85), rgba(255, 200, 110, .25) 40%, transparent 70%); animation: aura 4.5s ease-in-out; }
@keyframes aura { 0% { opacity: 0; } 35% { opacity: .9; } 100% { opacity: 0; } }
#flash.blackout { background: #000; mix-blend-mode: normal; animation: blackout 4.2s ease-in-out forwards; }
@keyframes blackout { 0% { opacity: 0; } 25% { opacity: 1; } 70% { opacity: 1; } 100% { opacity: 0; } }
#flash.candle { background: radial-gradient(circle at var(--vx, 50%) 50%, rgba(255, 196, 120, .55), transparent 55%); animation: aura 3s ease-in-out; }

/* ── Landing ───────────────────────────────────────────────────────────── */

#landing {
  position: fixed; inset: 0; z-index: 40; overflow-y: auto;
  background: radial-gradient(ellipse at 50% 0%, #262b35 0%, #13161b 55%, #0b0d10 100%);
  transition: opacity 1.4s ease, visibility 1.4s;
}
body:not([data-mode="landing"]) #landing { opacity: 0; visibility: hidden; pointer-events: none; }
/* Hero: the hallway (js/hero.js). The canvas fades up once the murals have loaded; the title
   comes in as the camera draws back from the door. */
#hero { position: relative; height: 100svh; min-height: 30rem; overflow: hidden; background: #0b0d10; isolation: isolate; }
/* The hallway keeps its own camera pace. The reading surface rises over it through shadow. */
#hero-stage { position: relative; overflow: clip; background: #0b0d10; }
#hero-stage #hero { position: sticky; top: 0; }
.hero-ui { position: absolute; inset: 0; z-index: 2; pointer-events: none; }
.hero-ui #hero-more { pointer-events: auto; }
#hero.reading #hero-more, #hero.reading #hero-label { opacity: 0 !important; pointer-events: none; transition: opacity .4s ease; }
#hero.reading #hero-canvas { pointer-events: none; }
.hero-scrim { position: absolute; inset: 0; z-index: 3; background: #0b0d10; opacity: 0; pointer-events: none; }
#hero-text {
  position: relative; z-index: 1; margin-top: -30svh; padding: 30svh 6vw 18vh; pointer-events: none;
  background: linear-gradient(to bottom, transparent, #0b0d10 30svh);
}
.hero-text-col { max-width: 34rem; margin: 0 auto; pointer-events: auto; color: rgba(236, 231, 220, .88); font-size: 1.05rem; line-height: 1.65; text-wrap: pretty; }
.hero-text-col h2 { margin: 0 0 1.6rem; font-family: var(--display); font-weight: 500; font-size: clamp(1.8rem, 3.6vw, 2.8rem); line-height: 1.1; color: #f1ece0; text-wrap: balance; }
.hero-text-col p { margin: 0 0 1.25em; }
.hero-text-col .hero-intro-byline { margin-top: 2rem; margin-bottom: 0; text-align: right; font-style: italic; color: rgba(236, 231, 220, .7); }
.hero-intro-photo { margin: 2rem 0; }
.hero-intro-photo img { display: block; width: 100%; height: auto; }
.hero-intro-photo figcaption { margin-top: .5rem; font-size: .8rem; line-height: 1.4; color: rgba(236, 231, 220, .65); }
#hero-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; opacity: 0; transition: opacity 3.2s ease .3s; }
#hero.loaded #hero-canvas { opacity: 1; }
#hero.pointing #hero-canvas { cursor: pointer; }
#hero.static { background: url(../img/hall/poster.jpg) center / cover no-repeat, #0b0d10; }
.hero-veil {
  position: absolute; inset: 0; pointer-events: none;
  background:
    linear-gradient(180deg, rgba(11, 13, 16, .45) 0%, rgba(11, 13, 16, 0) 22%, rgba(11, 13, 16, 0) 74%, #0b0d10 100%),
    radial-gradient(ellipse 46% 26% at 50% 50%, rgba(5, 6, 8, .5) 0%, transparent 100%),
    radial-gradient(ellipse 72% 68% at 50% 50%, transparent 45%, rgba(5, 6, 8, .85) 100%);
}
.hero-veil::after {   /* a little grain, so the render reads as paint and paper rather than glass */
  content: ''; position: absolute; inset: 0; opacity: .14; mix-blend-mode: overlay;
  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%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
.hero-copy {
  position: absolute; left: 0; right: 0; top: 50%; transform: translateY(-50%); padding: 0 5vw; text-align: center; pointer-events: none;
  text-shadow: 0 2px 18px rgba(0, 0, 0, .7), 0 1px 2px rgba(0, 0, 0, .6);
}
.hero-copy h1 {
  font-family: var(--display); font-weight: 500; font-size: clamp(2.4rem, 6.2vw, 5.4rem); line-height: 1; margin: 0;
  letter-spacing: .01em; color: #f1ece0; text-wrap: balance;
  opacity: 0; transform: translateY(.3em); filter: blur(4px);
  transition: opacity 1.6s ease, transform 1.8s cubic-bezier(.22, .61, .36, 1), filter 1.6s ease;
}
.hero-sub {
  margin: .9rem auto 0; max-width: 34em; font-family: var(--display); font-style: italic; font-size: clamp(1.1rem, 2vw, 1.55rem);
  line-height: 1.35; color: rgba(236, 231, 220, .86); text-wrap: balance;
  opacity: 0; transform: translateY(.5em); transition: opacity 1.8s ease .7s, transform 1.8s cubic-bezier(.22, .61, .36, 1) .7s;
}
.hero-sub em { font-style: normal; font-family: var(--sc); letter-spacing: .06em; font-size: .92em; }
#hero.revealed .hero-copy h1 { opacity: 1; transform: none; filter: none; }
#hero.revealed .hero-sub { opacity: 1; transform: none; }
/* walking up to a painting: the words and the chevron step aside */
#hero.entering .hero-copy, #hero.entering #hero-more, #hero.entering #hero-label { opacity: 0 !important; transition: opacity .8s ease; }
#hero .hero-copy { transition: opacity .8s ease; }
/* Walking into a painting: the card's mural is shown at once behind the hall, framed just as the
   hall's last view, and the hall dissolves away over it (js/hero.js). */
body.hero-handoff #landing { transition: opacity 1.8s ease, visibility 1.8s; }
body.hero-handoff #viewer { opacity: 1; transition: none; }
#hero-label {
  position: absolute; bottom: 16vh; margin: 0; font-family: var(--sc); letter-spacing: .16em; font-size: clamp(.95rem, 1.4vw, 1.15rem);
  color: var(--chalk); text-shadow: 0 1px 10px rgba(0, 0, 0, .9); pointer-events: none;
  opacity: 0; transition: opacity .5s ease, transform .5s ease;
}
#hero-label[data-side="left"] { left: 8vw; transform: translateX(-.6rem); }
#hero-label[data-side="right"] { right: 8vw; transform: translateX(.6rem); }
#hero.pointing #hero-label { opacity: 1; transform: none; }
#hero-more {
  position: absolute; left: 50%; bottom: calc(4.5rem + 3.5vh); width: 3rem; height: 3rem; margin-left: -1.5rem; border-radius: 50%;
  display: grid; place-items: center; color: var(--chalk); background: rgba(16, 18, 23, .35);
  box-shadow: 0 0 0 1px rgba(234, 233, 228, .25); opacity: 0; transition: opacity 1.6s ease, box-shadow .4s, background .4s;
}
#hero-more svg { width: 1.4rem; height: 1.4rem; fill: none; stroke: currentColor; stroke-width: 1.5; }
#hero.revealed #hero-more, #hero.static #hero-more { opacity: 1; animation: hero-bob 2.8s ease-in-out infinite; }
#hero-more:hover, #hero-more:focus-visible { background: rgba(16, 18, 23, .6); box-shadow: 0 0 0 1px rgba(234, 233, 228, .6); }
/* The call to play the music, under the title; once it plays, a note on hearing it, then it goes. */
#sound-cta {
  margin-top: 2.2rem; display: flex; flex-direction: column; align-items: center; gap: .75rem;
  opacity: 0; transform: translateY(.5em); transition: opacity 1.8s ease 1.4s, transform 1.8s cubic-bezier(.22, .61, .36, 1) 1.4s;
}
#hero.revealed #sound-cta { opacity: 1; transform: none; }
#sound-cta-play {
  pointer-events: auto; display: inline-flex; align-items: center; gap: .7rem; padding: .85rem 1.7rem .85rem 1.4rem; border-radius: 999px;
  font-family: var(--sc); font-size: clamp(1.05rem, 1.6vw, 1.25rem); letter-spacing: .12em; color: #15171c;
  background: rgba(241, 236, 224, .94); box-shadow: 0 10px 30px -8px rgba(0, 0, 0, .8), 0 0 0 0 rgba(241, 236, 224, .5);
  text-shadow: none; animation: cta-glow 3s ease-in-out 3.5s infinite; transition: background .3s, transform .3s;
}
#sound-cta-play:hover, #sound-cta-play:focus-visible { background: #fff; transform: scale(1.03); }
#sound-cta-play:focus-visible { outline: 2px solid var(--chalk); outline-offset: 4px; }
#sound-cta-play svg { width: 1.35rem; height: 1.35rem; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linejoin: round; stroke-linecap: round; }
@keyframes cta-glow { 50% { box-shadow: 0 10px 30px -8px rgba(0, 0, 0, .8), 0 0 0 .55rem rgba(241, 236, 224, 0); } 0%, 49.9% { box-shadow: 0 10px 30px -8px rgba(0, 0, 0, .8), 0 0 0 0 rgba(241, 236, 224, .45); } }
#sound-note {
  margin: 0; max-width: 26rem; font-family: var(--display); font-style: italic; font-size: clamp(.98rem, 1.4vw, 1.12rem); line-height: 1.35;
  color: rgba(236, 231, 220, .82); text-wrap: balance; pointer-events: auto; transition: opacity .6s ease;
}
#sound-note strong { font-style: normal; font-weight: 600; color: #f1ece0; }
#sound-note button { font: inherit; font-style: normal; color: var(--mist); text-decoration: underline; text-underline-offset: .2em; margin-left: .3em; }
#sound-cta.started #sound-cta-play { display: none; }
#sound-cta.gone { opacity: 0 !important; transition: opacity 1.2s ease; pointer-events: none; }
#sound-cta.gone * { pointer-events: none; }
@media (prefers-reduced-motion: reduce) { #sound-cta-play { animation: none; } #sound-cta { transition: none; } }

/* Music for the title page (js/title-music.js): a persistent, full-width bottom bar. */
#title-music {
  position: fixed; left: 0; right: 0; bottom: 0; display: flex; align-items: center; gap: .8rem; z-index: 4;
  padding: .75rem max(4vw, env(safe-area-inset-right)) max(.75rem, env(safe-area-inset-bottom)) max(4vw, env(safe-area-inset-left));
  background: #0b0d10; border-top: 1px solid rgba(234, 233, 228, .12);
  opacity: 1; transition: opacity .8s ease;
}
#landing:has(#hero.entering) #title-music { opacity: 0; pointer-events: none; }
#tm-play {
  flex: none; width: 2.6rem; height: 2.6rem; border-radius: 50%; display: grid; place-items: center; color: var(--chalk);
  background: rgba(16, 18, 23, .35); box-shadow: 0 0 0 1px rgba(234, 233, 228, .25); transition: box-shadow .4s, background .4s;
}
#tm-play:hover, #tm-play:focus-visible { background: rgba(16, 18, 23, .6); box-shadow: 0 0 0 1px rgba(234, 233, 228, .6); }
#tm-play svg { grid-area: 1 / 1; width: 1.1rem; height: 1.1rem; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linejoin: round; }
#tm-play .ico-play { fill: currentColor; stroke: none; margin-left: .15rem; }
#title-music.paused .ico-pause, #title-music:not(.paused) .ico-play { display: none; }
.tm-label {
  margin: 0; display: flex; flex-direction: column; gap: .1rem; line-height: 1.2; text-shadow: 0 1px 10px rgba(0, 0, 0, .9);
  opacity: .62; transition: opacity .6s ease;
}
#title-music:not(.paused) .tm-label, #title-music:hover .tm-label { opacity: 1; }
.tm-piece { font-family: var(--display); font-size: 1.02rem; color: #f1ece0; }
.tm-piece em { font-style: italic; }
.tm-composer { font-family: var(--sc); font-size: .78rem; letter-spacing: .14em; color: var(--mist); }
@media (max-width: 40rem) {
  .tm-piece { font-size: .85rem; }
  .tm-composer { font-size: .68rem; }
}
@keyframes hero-bob { 50% { transform: translateY(.35rem); } }
.volume.beckon { animation: beckon 1.6s ease 1; }
@keyframes beckon { 30% { box-shadow: 0 44px 80px -24px rgba(0, 0, 0, .9), 0 0 0 2px var(--chalk); } }
@media (prefers-reduced-motion: reduce) {
  .hero-copy h1, .hero-sub { transition: none; }
  #hero-more { animation: none !important; }
}

.landing-inner { min-height: 100%; display: flex; flex-direction: column; align-items: center; padding: 6vh 4vw 4vh; gap: 4vh; }
#landing-reel { display: block; flex: none; width: min(54rem, 100%); aspect-ratio: 16 / 9; max-height: 52vh; object-fit: contain; background: #0b0d10; border-radius: 2px; }
#landing-reel:focus-visible { outline: 2px solid var(--mist); outline-offset: 4px; }
.landing-head { text-align: center; max-width: 51.25rem; }
.landing-head .kicker { color: var(--mist); font-size: 1.05rem; margin: 0 0 .6rem; }
.landing-head h1 {
  font-family: var(--display); font-weight: 500; font-size: clamp(2.6rem, 6vw, 5rem); line-height: 1; margin: 0;
  letter-spacing: .01em; color: #ecebe6;
}
.epigraph { margin: 2.2rem auto 0; max-width: 40rem; font-family: var(--display); font-style: italic; }
.epigraph p { font-size: clamp(1.15rem, 1.9vw, 1.45rem); line-height: 1.45; margin: 0; color: rgba(234, 233, 228, .86); transition: opacity 1s ease; }
.epigraph cite { display: block; margin-top: .7rem; font-family: var(--sc); font-style: normal; letter-spacing: .14em; font-size: .9rem; color: var(--mist); }
.epigraph cite::before { content: '— '; }

.volumes { display: flex; gap: clamp(1.4rem, 4vw, 4rem); flex-wrap: wrap; justify-content: center; }
.volume {
  width: min(25rem, 86vw); text-align: left; position: relative; padding: 0; border-radius: 2px;
  background: #191c22; box-shadow: 0 30px 60px -20px rgba(0, 0, 0, .8), 0 0 0 1px rgba(196, 207, 224, .16);
  transition: transform .8s cubic-bezier(.22, .61, .36, 1), box-shadow .8s;
}
.volume:hover, .volume:focus-within { transform: translateY(-6px); box-shadow: 0 44px 80px -24px rgba(0, 0, 0, .9), 0 0 0 1px rgba(196, 207, 224, .45); }
.volume .cover { height: 18.75rem; overflow: hidden; position: relative; background: #191c22; isolation: isolate; }
.volume .cover img { display: block; width: 100%; height: 100%; object-fit: cover; transform: scale(1.08); transition: transform 9s ease-out, filter 1.2s; filter: saturate(.85) brightness(.9); }
.volume:hover .cover img { transform: scale(1.22) translate(-2%, 2%); filter: saturate(1) brightness(1); }
.volume .cover::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(25, 28, 34, 0) 45%, #191c22 96%); pointer-events: none; }
/* Overlap the clipped image edge, and contain the heading’s margin so it cannot open a gap. */
.volume .meta { display: flow-root; padding: 2px 1.6rem 1.6rem; margin-top: -2px; position: relative; z-index: 1; background: #191c22; }
.volume h2 { font-family: var(--display); font-weight: 500; font-size: 2.2rem; margin: .1rem 0 .2rem; color: #eeede8; line-height: 1.05; }
.volume .sub { margin: 0 0 1.2rem; color: rgba(234, 233, 228, .65); font-style: italic; }
.volume .row { display: flex; gap: .7rem; flex-wrap: wrap; }
.landing-foot { color: rgba(234, 233, 228, .45); font-size: .95rem; text-align: center; max-width: 720px; margin-top: auto; }

.btn {
  font-family: var(--sc); letter-spacing: .14em; font-size: 1rem; padding: .62rem 1.2rem; border-radius: 999px;
  transition: background .4s, color .4s, box-shadow .4s, opacity .6s; font-variant: small-caps; text-transform: lowercase;
}
.btn.primary { background: var(--periwinkle); color: #15171c; box-shadow: 0 0 0 0 rgba(169, 182, 212, .5); }
.btn.primary:hover { background: var(--periwinkle-hi); box-shadow: 0 0 24px 2px rgba(169, 182, 212, .3); }
.btn.ghost { color: var(--paper); box-shadow: inset 0 0 0 1px rgba(234, 233, 228, .35); }
.btn.ghost:hover { box-shadow: inset 0 0 0 1px var(--mist); color: var(--mist); }

/* ── Title card & finale ──────────────────────────────────────────────── */

#titlecard, #finale {
  position: fixed; inset: 0; z-index: 30; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 6vh 6vw; pointer-events: none; opacity: 0; transition: opacity 1.6s ease;
  background: radial-gradient(ellipse at 50% 50%, rgba(10, 12, 16, .55), rgba(10, 12, 16, .82));
}
#titlecard.show, #finale.show { opacity: 1; pointer-events: auto; }
#titlecard h2 { font-family: var(--display); font-weight: 500; font-size: clamp(2.6rem, 7vw, 5.6rem); margin: .2rem 0; line-height: 1; }
.tc-meta { font-style: italic; color: rgba(234, 233, 228, .7); margin: .2rem 0 0; font-size: 1.1rem; }
.tc-actions { display: flex; gap: .8rem; margin-top: 2.4rem; flex-wrap: wrap; justify-content: center; }
#titlecard .epigraph p, #finale blockquote p { text-wrap: balance; }

#finale blockquote { max-width: 47.5rem; margin: 0; font-family: var(--display); font-style: italic; }
#finale blockquote p { font-size: clamp(1.4rem, 2.6vw, 2.1rem); line-height: 1.4; margin: 0; }
#finale cite { display: block; margin-top: 1rem; font-family: var(--sc); font-style: normal; letter-spacing: .14em; color: var(--mist); }
.fin-end { margin-top: 2.6rem; color: var(--rose); font-size: 1.3rem; }

/* ── Intertitle (chapter card in flight) ──────────────────────────────── */

#intertitle {
  position: fixed; z-index: 12; left: var(--debug-w); top: 0; width: calc(100vw - var(--reader-w) - var(--debug-w) - var(--side-w)); height: 100vh;
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: .35rem;
  pointer-events: none; opacity: 0; transition: opacity 1.1s ease;
  text-shadow: 0 2px 18px rgba(0, 0, 0, .85), 0 0 2px rgba(0, 0, 0, .9);
}
body.reader-hidden #intertitle, body[data-layout="portrait"] #intertitle { width: calc(100vw - var(--debug-w) - var(--side-w)); }
body[data-layout="portrait"] #intertitle { height: 58vh; }
#intertitle.show { opacity: 1; }
#intertitle .it-n { font-family: var(--sc); letter-spacing: .3em; color: var(--mist); font-size: 1.1rem; }
#intertitle .it-n::before, #intertitle .it-n::after { content: ''; display: inline-block; width: 2.4em; height: 1px; background: currentColor; vertical-align: middle; margin: 0 .9em; opacity: .7; }
#intertitle .it-title { font-family: var(--display); font-style: italic; font-size: clamp(2rem, 4.4vw, 3.6rem); line-height: 1.05; max-width: 16em; }
#intertitle .it-src { font-family: var(--sc); letter-spacing: .16em; font-size: .95rem; color: rgba(234, 233, 228, .78); }

/* ── HUD ──────────────────────────────────────────────────────────────── */

#hud {
  position: fixed; z-index: 20; top: 0; left: var(--debug-w); right: var(--side-w); height: var(--hud-h);
  display: flex; align-items: center; gap: .8rem; padding: 0 .8rem;
  background: linear-gradient(180deg, rgba(10, 12, 16, .72), rgba(10, 12, 16, 0));
  opacity: 0; pointer-events: none; transition: opacity 1s ease, left 1.1s cubic-bezier(.22, .61, .36, 1), right 1.1s cubic-bezier(.22, .61, .36, 1);
}
body[data-mode="explore"] #hud, body[data-mode="tour"] #hud { opacity: 1; pointer-events: auto; }
body[data-mode="tour"]:not(.reader-hidden):not([data-layout="portrait"]) #hud { right: calc(var(--reader-w) + var(--side-w)); transition: opacity 1s ease, left 1.1s cubic-bezier(.22, .61, .36, 1), right 1.1s cubic-bezier(.22, .61, .36, 1); }
body.idle[data-mode="tour"] #hud { opacity: 0; }
.hud-title { display: flex; align-items: baseline; gap: .7rem; min-width: 0; overflow: hidden; }
.hud-book { overflow: hidden; text-overflow: ellipsis; }
.hud-book { font-family: var(--display); font-size: 1.35rem; font-style: italic; white-space: nowrap; }
.hud-actions { margin-left: auto; display: flex; gap: .2rem; flex: none; }
.hud-btn { display: inline-flex; align-items: center; gap: .4rem; height: 2.375rem; padding: 0 .65rem; border-radius: 999px; color: rgba(234, 233, 228, .85); transition: background .3s, color .3s; }
.hud-btn svg { width: 1.25rem; height: 1.25rem; }
.hud-btn:disabled { opacity: .4; cursor: default; }
.hud-btn span { font-family: var(--sc); letter-spacing: .12em; font-variant: small-caps; text-transform: lowercase; font-size: 1rem; }
.hud-btn:hover, .hud-btn[aria-pressed="true"]:not(#btn-sound) { background: rgba(234, 233, 228, .12); color: var(--mist); }
#btn-sound .ico-off { display: none; }
#btn-sound[aria-pressed="false"] .ico-on { display: none; }
#btn-sound[aria-pressed="false"] .ico-off { display: inline; }
body[data-mode="tour"] #btn-tour { display: none; }




/* ── Reader page ──────────────────────────────────────────────────────── */

#reader {
  position: fixed; z-index: 15; top: 0; right: var(--side-w); bottom: 0; width: var(--reader-w);
  display: flex; flex-direction: column; color: var(--ink);
  background:
    radial-gradient(ellipse at 0% 0%, rgba(255, 255, 255, .35), transparent 50%),
    radial-gradient(ellipse at 100% 100%, rgba(120, 130, 150, .14), transparent 55%),
    linear-gradient(90deg, var(--paper-2) 0%, var(--paper) 7%, var(--paper) 100%);
  box-shadow: -18px 0 50px -10px rgba(0, 0, 0, .65), inset 10px 0 18px -12px rgba(50, 55, 70, .4);
  transform: translateX(105%); transition: transform 1.1s cubic-bezier(.22, .61, .36, 1), right 1.1s cubic-bezier(.22, .61, .36, 1);
}
#reader::before { /* paper fibre */
  content: ''; position: absolute; inset: 0; pointer-events: none; opacity: .5; mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='300' height='300'><filter id='p'><feTurbulence type='fractalNoise' baseFrequency='.6' numOctaves='4'/><feColorMatrix values='0 0 0 0 .46 0 0 0 0 .46 0 0 0 0 .5 0 0 0 .2 0'/></filter><rect width='100%' height='100%' filter='url(%23p)'/></svg>");
}
body[data-mode="tour"]:not(.reader-hidden) #reader { transform: none; }
.page { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 1.5rem 2.2rem 0 2.4rem; }
.page-head { transition: opacity .25s ease; }
.page-title { font-family: var(--display); font-weight: 500; font-style: italic; font-size: clamp(2.55rem, 3.45vw, 3.45rem); line-height: 1.08; margin: .25rem 0 .2rem; color: var(--ink); text-wrap: balance; }
.page-note { margin: .6rem 0 0; font-size: 1.47rem; line-height: 1.45; color: var(--ink-soft); font-style: italic; border-left: 2px solid var(--accent); padding-left: .8rem; }
.page-note:empty { display: none; }
.ornament { color: var(--accent); opacity: .6; margin: .45rem 0 .25rem; }
.ornament svg { width: 7.5rem; height: .75rem; display: block; stroke-width: 1; }

.prose {
  position: relative; flex: 1 1 0; min-height: 0; overflow-y: auto; padding: .4rem .4rem 0 0; margin-right: -.4rem;
  font-size: clamp(1.62rem, 1.77vw, 1.83rem); line-height: 1.62; hyphens: auto; text-align: left;
  scrollbar-width: thin; scrollbar-color: rgba(50, 55, 70, .25) transparent;
  mask-image: linear-gradient(180deg, transparent 0, #000 1.6rem, #000 calc(100% - 5rem), transparent 100%);
  transition: opacity .25s ease;
}
.prose::after { content: ''; display: block; height: 22vh; } /* room for the last lines to rise to reading height */
.prose p { margin: 0 0 .9em; text-indent: 1.4em; }
.prose p:first-child { text-indent: 0; }
.prose p:first-child:not(.silence)::first-letter {
  font-family: var(--display); font-weight: 500; float: left; font-size: 3.6em; line-height: .82; padding: .08em .1em 0 0;
  color: var(--accent);
}
/* Ink arrives in 5 steps over 0.5 s, not 30 frames: a smooth fade repainted the text every frame. */
.prose .w { color: rgba(30, 32, 39, .26); transition: color .5s steps(5, end), text-shadow .5s steps(5, end); }
.prose .w.lit { color: var(--ink); }
.prose .w.now { color: var(--ink); text-shadow: 0 0 .5em rgba(142, 156, 192, .6); }
.prose .w.elide { color: var(--accent); opacity: .55; font-size: .9em; }
.prose.static .w { color: var(--ink); }

.page-foot { padding: .5rem 0 0; border-top: 1px solid rgba(50, 55, 70, .18); font-size: 1.32rem; color: var(--ink-soft); }
.page-foot:has(.page-voice:empty) { display: none; }
.page-foot p { margin: .1rem 0; }
.page-voice { font-style: italic; opacity: .8; }
.page-voice:empty { display: none; }

.transport { position: relative; display: flex; align-items: center; gap: .2rem; padding: .35rem 1.1rem .7rem 1.6rem; color: var(--ink); }
.tbtn { flex: none; width: 2.375rem; height: 2.375rem; border-radius: 50%; display: grid; place-items: center; color: var(--ink-soft); transition: background .3s, color .3s; }
.tbtn svg { width: 1.1875rem; height: 1.1875rem; }
.tbtn:hover { background: var(--accent-soft); color: var(--accent); }
.tbtn.big { width: 3rem; height: 3rem; background: var(--ink); color: var(--paper); }
.tbtn.big:hover { background: var(--accent); color: var(--paper); }
.tbtn.big svg { fill: currentColor; stroke: none; }
.tbtn.big .ico-pause { fill: none; stroke: currentColor; stroke-width: 2.4; }
.tbtn.big .ico-play { display: none; }
body.paused .tbtn.big .ico-play { display: block; }
body.paused .tbtn.big .ico-pause { display: none; }
#t-hide { margin-left: auto; }

#reader-tab {
  position: fixed; z-index: 15; right: var(--side-w); top: 50%; transform: translate(100%, -50%); width: 2.125rem; height: 4.75rem;
  background: var(--paper); color: var(--ink); border-radius: 8px 0 0 8px; box-shadow: -6px 0 20px rgba(0, 0, 0, .4);
  display: grid; place-items: center; transition: transform .8s cubic-bezier(.22, .61, .36, 1), right 1.1s cubic-bezier(.22, .61, .36, 1);
}
#reader-tab svg { width: 1.125rem; height: 1.125rem; }
body[data-mode="tour"].reader-hidden #reader-tab { transform: translate(0, -50%); }
/* With the tools (?debug) the tab stays out, beside the page and the topic's panel, to fold them away and back. */
body.tools[data-mode="tour"] #reader-tab, body.tools.debug-side #reader-tab { transform: translate(0, -50%); }
body.tools[data-mode="tour"]:not(.reader-hidden):not([data-layout="portrait"]) #reader-tab { right: calc(var(--reader-w) + var(--side-w)); }
#reader-tab[aria-expanded="true"] svg { transform: scaleX(-1); }

/* ── Subtitle: the line being read while the page is hidden ─────────────── */

#subtitle {
  position: fixed; z-index: 13; left: var(--debug-w); right: var(--side-w); bottom: calc(var(--thread-h) + 1.4rem);
  display: flex; justify-content: center; padding: 0 1.5rem; pointer-events: none;
  opacity: 0; transition: opacity .8s ease, left 1.1s cubic-bezier(.22, .61, .36, 1);
}
#subtitle p {
  margin: 0; max-width: 40em; padding: .45rem 1.1rem .5rem; border-radius: 4px; text-align: center; text-wrap: balance;
  font-family: var(--body); font-size: clamp(1.05rem, 1.3vw, 1.3rem); line-height: 1.4;
  /* A slip of the page: its paper and ink, the words to come faint until they're read. */
  color: var(--ink);
  background:
    radial-gradient(ellipse at 0% 0%, rgba(255, 255, 255, .35), transparent 60%),
    linear-gradient(180deg, var(--paper) 0%, var(--paper-2) 100%);
  box-shadow: 0 8px 28px -6px rgba(0, 0, 0, .6), inset 0 0 0 1px rgba(50, 55, 70, .12);
}
/* Karaoke, as on the page: words ink in as they're read, the one being read with the page's glow. */
#subtitle span { color: rgba(30, 32, 39, .26); transition: color .5s steps(5, end), text-shadow .5s steps(5, end); }
#subtitle span.lit { color: var(--ink); }
#subtitle span.now { color: var(--ink); text-shadow: 0 0 .5em rgba(142, 156, 192, .6); }
body[data-mode="tour"].reader-hidden #subtitle.show { opacity: 1; }
body.detached #subtitle { opacity: 0 !important; }
body[data-layout="portrait"] #subtitle { bottom: calc(var(--thread-h) + 1rem); }
body.demo2 #subtitle { transition: none; }
body.demo2 :is(#reader, #reader-tab, #btn-sound, #btn-voice, #resume) { display: none; }
body.demo2[data-mode="tour"]:not(.editing) #viewer .openseadragon-canvas { cursor: grab; }
body.demo2[data-mode="tour"]:not(.editing) #viewer .openseadragon-canvas:active { cursor: grabbing; }

/* Demo playback sits over the mural, with room above for subtitles. */
body.demo2 {
  --demo-bottom: max(.75rem, env(safe-area-inset-bottom));
}
body.demo2:not(.public-view) {
  --demo-bottom: max(calc(var(--thread-h) + .7rem), env(safe-area-inset-bottom));
}
#demo-transport, #demo-speed-control {
  display: none; position: fixed; z-index: 21;
  background: rgba(14, 16, 20, .9); color: var(--paper);
  border: 1px solid rgba(234, 233, 228, .25); border-radius: 999px;
  box-shadow: 0 4px 20px #0006;
}
body.demo2[data-mode="tour"]:not(.editing) :is(#demo-transport, #demo-speed-control) { display: flex; }
body.demo2[data-mode="tour"]:not(.detached, .editing) #subtitle { bottom: calc(var(--demo-bottom) + 4rem); }
#demo-transport {
  left: calc(var(--debug-w) + (100% - var(--debug-w) - var(--side-w)) / 2);
  bottom: var(--demo-bottom); transform: translateX(-50%);
  align-items: center; gap: .25rem; padding: .25rem;
}
#demo-transport .tbtn { color: var(--paper); }
#demo-transport .tbtn.big { background: var(--paper); color: var(--ink); }
#demo-transport .tbtn:hover:not(:disabled) { background: var(--accent); color: var(--paper); }
#demo-transport .tbtn:disabled { opacity: .35; cursor: default; }
#demo-speed-control {
  left: calc(var(--debug-w) + max(.5rem, env(safe-area-inset-left)));
  top: 50%; transform: translateY(-50%); flex-direction: column; align-items: center;
  gap: .3rem; padding: .55rem .3rem; font: 600 .65rem/1.2 var(--ui);
  font-variant-numeric: tabular-nums;
}
#demo-speed {
  writing-mode: vertical-lr; direction: rtl;
  width: 1.6rem; height: clamp(3rem, 24dvh, 8rem); margin: 0;
  accent-color: var(--paper); cursor: pointer;
}
#demo-transport button:focus-visible, #demo-speed:focus-visible { outline: 2px solid var(--paper); outline-offset: 2px; }

/* ── Resume pill ──────────────────────────────────────────────────────── */

#resume {
  position: fixed; z-index: 22; left: calc(var(--debug-w) + (100vw - var(--reader-w) - var(--debug-w) - var(--side-w)) / 2); bottom: calc(var(--thread-h) + 1.4rem);
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none; transition: opacity .6s, transform .6s;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .5);
}
body.reader-hidden #resume { left: calc(var(--debug-w) + (100vw - var(--debug-w) - var(--side-w)) / 2); }
body.detached #resume { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }

/* ── Thread of scenes ─────────────────────────────────────────────────── */

#thread {
  position: fixed; z-index: 14; left: calc(var(--debug-w) + 1.2rem); right: calc(var(--reader-w) + var(--side-w) + 1.2rem); bottom: .7rem; height: var(--thread-h);
  opacity: 0; pointer-events: none; transition: opacity 1s ease, left 1.1s cubic-bezier(.22, .61, .36, 1), right 1.1s cubic-bezier(.22, .61, .36, 1);
}
body[data-mode="explore"] #thread, body.reader-hidden #thread { right: calc(var(--side-w) + 1.2rem); }
body[data-mode="explore"] #thread, body[data-mode="tour"] #thread { opacity: 1; pointer-events: auto; }
body.idle[data-mode="tour"] #thread { opacity: .35; }
.thread-line { position: absolute; left: 0; right: 0; top: 50%; height: 1px; background: rgba(234, 233, 228, .3); }
.thread-fill { position: absolute; left: 0; top: -.5px; height: 2px; width: 100%; transform: scaleX(0); transform-origin: 0 50%; will-change: transform; background: linear-gradient(90deg, var(--sage), var(--mist) 70%, var(--rose)); box-shadow: 0 0 10px rgba(196, 207, 224, .45); transition: transform .4s linear; }
#thread-nodes { list-style: none; margin: 0; padding: 0; position: absolute; inset: 0; }
#thread-nodes li { position: absolute; top: 50%; transform: translate(-50%, -50%); }
#thread-nodes button { width: 1.375rem; height: 1.375rem; display: grid; place-items: center; }
#thread-nodes button::before {
  content: ''; width: .4375rem; height: .4375rem; border-radius: 50%; background: #1a1d24; box-shadow: 0 0 0 1.5px rgba(234, 233, 228, .6);
  transition: transform .4s, background .4s, box-shadow .4s;
}
#thread-nodes li.kind-interlude button::before { border-radius: 1px; transform: rotate(45deg); }
#thread-nodes li.done button::before { background: var(--sage); box-shadow: 0 0 0 1.5px var(--sage); }
#thread-nodes li.current button::before { background: var(--rose); box-shadow: 0 0 0 4px rgba(199, 153, 143, .25), 0 0 14px rgba(199, 153, 143, .7); transform: scale(1.35); }
#thread-nodes li.kind-interlude.current button::before { transform: rotate(45deg) scale(1.35); }
#thread-nodes button:hover::before { transform: scale(1.6); background: var(--mist); }
#thread-tip {
  position: absolute; bottom: calc(100% + 6px); transform: translateX(-50%); width: 12.5rem; pointer-events: none;
  background: rgba(16, 18, 23, .92); border: 1px solid rgba(196, 207, 224, .28); padding: 6px; border-radius: 3px;
  opacity: 0; transition: opacity .3s; text-align: center;
}
#thread-tip.show { opacity: 1; }
#thread-tip img { width: 100%; height: 6.875rem; object-fit: cover; display: block; }
#thread-tip span { display: block; font-family: var(--display); font-style: italic; font-size: 1.02rem; padding: 4px 2px 1px; line-height: 1.15; }

/* ── Contents drawer ──────────────────────────────────────────────────── */

#contents {
  position: fixed; z-index: 25; top: 0; left: 0; bottom: 0; width: min(27.5rem, 92vw); overflow-y: auto;
  background: rgba(17, 19, 24, .95); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  box-shadow: 20px 0 50px rgba(0, 0, 0, .5); transform: translateX(-105%); transition: transform .8s cubic-bezier(.22, .61, .36, 1);
}
#contents.open { transform: none; }
#contents header { position: sticky; top: 0; display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.2rem .6rem 1.6rem; background: inherit; z-index: 1; }
#contents header p { margin: 0; color: var(--mist); font-size: 1.15rem; }
#contents-list { list-style: none; margin: 0; padding: 0 .8rem 2rem; }
#contents-list button { width: 100%; display: grid; grid-template-columns: 4.625rem 1fr; gap: .9rem; align-items: center; text-align: left; padding: .55rem .6rem; border-radius: 4px; transition: background .3s; }
#contents-list button:hover { background: rgba(234, 233, 228, .07); }
#contents-list li.current button { background: rgba(199, 153, 143, .14); }
#contents-list img { width: 4.625rem; height: 3.5rem; object-fit: cover; border-radius: 2px; filter: saturate(.85); }
#contents-list .cn { font-family: var(--sc); letter-spacing: .14em; color: var(--sage); font-size: .85rem; display: block; }
#contents-list .ct { font-family: var(--display); font-size: 1.18rem; line-height: 1.12; display: block; }
#contents-list .cs { font-size: .85rem; color: rgba(234, 233, 228, .55); font-style: italic; display: block; margin-top: .1rem; }
#contents-list .group { padding: 1.2rem .6rem .3rem; font-family: var(--sc); letter-spacing: .14em; color: rgba(234, 233, 228, .45); font-size: .85rem; }

/* ── Street journeys ───────────────────────────────────────────────────── */

#trail {
  position: fixed; top: 0; left: var(--view-l); width: calc(100vw - var(--view-l) - var(--view-r)); height: calc(100vh - var(--view-b));
  pointer-events: none; overflow: hidden;
}
#trail .lantern { stroke: none; mix-blend-mode: screen; }
#trail.walking .lantern { animation: lantern 2.4s ease-in-out infinite; }
@keyframes lantern { 50% { opacity: .65; } }
body[data-mode="landing"] #trail, body[data-mode="title"] #trail { opacity: 0; }

.prose.walking { font-style: italic; font-size: 1.44em; }
.prose .silence { text-align: center; text-indent: 0; color: var(--accent); opacity: .45; font-size: 1.6em; margin-top: 1.2em; }
.prose.walking p:first-child::first-letter { float: none; font-size: inherit; line-height: inherit; padding: 0; font-family: inherit; color: inherit; font-weight: inherit; }
.prose.walking .w.lit { color: var(--ink-soft); }
.prose.walking .w.now { color: var(--ink); }

/* ── Scene hotspots (free exploration) ────────────────────────────────── */

.hotspot { cursor: pointer; border-radius: 3px; transition: box-shadow .5s ease, background .5s ease; }
.hotspot .hs-n {
  position: absolute; left: 50%; top: 0; transform: translate(-50%, -50%); font-family: var(--sc); letter-spacing: .14em;
  font-size: .8125rem; color: #15171c; background: var(--mist); padding: 1px 8px; border-radius: 999px; opacity: 0; transition: opacity .4s; white-space: nowrap;
}
body.reveal .hotspot { box-shadow: inset 0 0 0 1.5px rgba(196, 207, 224, .6); }
body.reveal .hotspot .hs-n { opacity: 1; }
.hotspot:hover { box-shadow: inset 0 0 0 2px rgba(236, 231, 220, .95), 0 0 40px rgba(199, 153, 143, .3) !important; background: rgba(236, 231, 220, .06); }
.hotspot:hover .hs-n { opacity: 1; }
body[data-mode="tour"] .hotspot { pointer-events: none; box-shadow: none !important; background: none !important; }
body[data-mode="tour"] .hotspot .hs-n { opacity: 0 !important; }

#hovercap {
  position: fixed; z-index: 16; pointer-events: none; transform: translate(14px, 14px); padding: .45rem .8rem .5rem; border-radius: 3px;
  background: rgba(16, 18, 23, .9); border: 1px solid rgba(196, 207, 224, .28); opacity: 0; transition: opacity .25s;
  display: flex; flex-direction: column; max-width: 17.5rem;
}
#hovercap.show { opacity: 1; }
#hovercap .hc-n { font-family: var(--sc); letter-spacing: .14em; color: var(--sage); font-size: .85rem; }
#hovercap .hc-title { font-family: var(--display); font-style: italic; font-size: 1.25rem; line-height: 1.1; }
#hovercap .hc-hint { font-size: .8rem; color: rgba(234, 233, 228, .5); font-style: italic; }

/* ── OSD navigator (the "you are here" map) ───────────────────────────── */

.navigator { border: 1px solid rgba(196, 207, 224, .45) !important; background: rgba(16, 18, 23, .6) !important; box-shadow: 0 8px 24px rgba(0, 0, 0, .5); opacity: 0; transition: opacity 1s; border-radius: 2px; }
body[data-mode="explore"] .navigator { opacity: .9; }
/* Sits above the thread of scenes, lined up with its start (OSD sets the margin inline). */
.navigator { margin: 0 0 calc(var(--thread-h) + 1.4rem) 1.2rem !important; }
body:not([data-mode="explore"]) .navigator { visibility: hidden !important; }
.navigator .displayregion { border: 1.5px solid var(--rose) !important; box-shadow: 0 0 0 9999px rgba(0, 0, 0, .25); }

/* ── Idle: during a reading the chrome recedes ────────────────────────── */
body { cursor: default; }
body.idle[data-mode="tour"] { cursor: none; }

/* ── Portrait / small screens: the page becomes a sheet at the bottom ─── */

body[data-layout="portrait"] { --reader-w: 0px; }
body[data-layout="portrait"] #reader { top: auto; left: 0; width: auto; height: 46vh; transform: translateY(105%); border-radius: 12px 12px 0 0; box-shadow: 0 -18px 40px -10px rgba(0, 0, 0, .65); }
body[data-layout="portrait"][data-mode="tour"]:not(.reader-hidden) #reader { transform: none; }
body[data-layout="portrait"] .page { padding: 1rem 1.3rem 0; }
body[data-layout="portrait"] .page-note, body[data-layout="portrait"] .page-voice { display: none; }
body[data-layout="portrait"] .ornament { display: none; }
body[data-layout="portrait"] .page-title { font-size: 2.175rem; }
body[data-layout="portrait"] .transport { padding: .3rem 1rem .7rem; }


body[data-layout="portrait"] #thread { bottom: calc(46vh + .3rem); left: calc(var(--debug-w) + .8rem); right: calc(var(--side-w) + .8rem); }
body[data-layout="portrait"][data-mode="explore"] #thread, body[data-layout="portrait"].reader-hidden #thread { bottom: .5rem; }
body[data-layout="portrait"] #reader-tab { top: auto; bottom: 0; right: calc(var(--side-w) + (100vw - var(--side-w)) / 2); transform: translate(50%, 100%); width: 76px; height: 30px; border-radius: 8px 8px 0 0; }
body[data-layout="portrait"][data-mode="tour"].reader-hidden #reader-tab { transform: translate(50%, 0); }
body[data-layout="portrait"] #reader-tab svg { transform: rotate(90deg); }
body.tools[data-layout="portrait"] #reader-tab { transform: translate(50%, 100%); }
body.tools[data-layout="portrait"][data-mode="tour"].reader-hidden #reader-tab { transform: translate(50%, 0); }
body[data-layout="portrait"] .hud-btn span { display: none; }
body[data-layout="portrait"] #resume { left: 50vw; bottom: calc(46vh + 4rem); }

/* ── Debug panels (?debug) ────────────────────────────────────────────── */

/*
 * A menu down the left and the chosen topic's knobs down the right; both push the painting aside
 * (D toggles them). Tooling, so in the system's own type rather than the book's.
 */
body.debug-open { --debug-w: var(--debug-panel-w); }
/* Each folds away on its own: the menu with D or its tab, the topic with the page (T, or the page's tab). */
body.debug-side:not(.side-hidden) { --side-w: var(--debug-side-w); }
#debug, #debug-side {
  position: fixed; z-index: 45; top: 0; bottom: 0; overflow-y: auto;
  display: flex; flex-direction: column; gap: .3125rem; padding: .75rem .875rem .875rem;
  background: rgb(16, 18, 23); font: .8rem/1.35 var(--ui); color: rgba(234, 233, 228, .88);
  transition: transform 1.1s cubic-bezier(.22, .61, .36, 1);
}
#debug { left: 0; width: var(--debug-panel-w); border-right: 1px solid var(--line); box-shadow: 18px 0 50px -10px rgba(0, 0, 0, .65); transform: translateX(-105%); }
#debug-side { right: 0; width: var(--debug-side-w); border-left: 1px solid var(--line); box-shadow: -18px 0 50px -10px rgba(0, 0, 0, .65); transform: translateX(105%); }
body.debug-open #debug, body.debug-side:not(.side-hidden) #debug-side { transform: none; }
#debug header, #debug-side header { display: flex; align-items: center; gap: .375rem; margin-bottom: .25rem; }
#debug header strong, #debug-side header strong { margin-right: auto; font-weight: 600; letter-spacing: .02em; }
#debug header button, #debug-side header .close { width: 1.75rem; height: 1.75rem; border-radius: 50%; display: grid; place-items: center; color: rgba(234, 233, 228, .7); }
#debug header button:hover, #debug-side header .close:hover { background: rgba(234, 233, 228, .1); color: var(--mist); }
#debug-tab {
  position: fixed; z-index: 45; left: 0; top: 50%; transform: translate(0, -50%); width: 1.625rem; height: 5.9375rem;
  background: rgb(16, 18, 23); color: rgba(234, 233, 228, .7); border: 1px solid var(--line); border-left: 0;
  border-radius: 0 8px 8px 0; font: .75rem/1 var(--ui); letter-spacing: .08em; writing-mode: vertical-rl;
  transition: left 1.1s cubic-bezier(.22, .61, .36, 1);
}
body.debug-open #debug-tab { left: var(--debug-w); }
/* The right panel's tab: on its edge (the screen's, folded), below the page's tab so the two never meet. */
#side-tab {
  display: none; position: fixed; z-index: 45; right: var(--side-w); top: calc(50% + 4.25rem); width: 1.625rem; height: 5.9375rem;
  background: rgb(16, 18, 23); color: rgba(234, 233, 228, .7); border: 1px solid var(--line); border-right: 0;
  border-radius: 8px 0 0 8px; font: .75rem/1 var(--ui); letter-spacing: .08em; writing-mode: vertical-rl;
  transition: right 1.1s cubic-bezier(.22, .61, .36, 1);
}
body.debug-side #side-tab { display: block; }
#side-tab:hover, #debug-tab:hover { color: var(--mist); }
#debug button, #debug-side button { font: inherit; }
#debug code, #debug-side code, #debug .hint, #debug-side .val { font-family: var(--mono); font-size: .92em; font-variant-numeric: tabular-nums; }
/* A setting that differs from its default. */
#debug .changed .name::after, #debug-side .changed .name::after {
  content: ''; display: inline-block; width: 5px; height: 5px; margin-left: .4375rem; border-radius: 50%; vertical-align: middle; background: #e8c37e;
}

/* Grips on the panels' inner edges, to drag their widths. */
.dbg-grip { position: fixed; z-index: 46; top: 0; bottom: 0; width: 9px; margin-left: -4px; cursor: col-resize; touch-action: none; display: none; }
.dbg-grip::after { content: ''; position: absolute; top: 0; bottom: 0; left: 4px; width: 1px; transition: background .15s; }
.dbg-grip:hover::after, body.resizing .dbg-grip::after { background: rgba(196, 207, 224, .6); left: 3px; width: 3px; }
body.debug-open .dbg-grip[data-grip="menu"] { display: block; left: var(--debug-w); }
body.debug-side:not(.side-hidden) .dbg-grip[data-grip="side"] { display: block; left: calc(100vw - var(--side-w)); }
body.resizing { cursor: col-resize; user-select: none; }
body.resizing #debug, body.resizing #debug-side { transition: none; }

/* The menu */
.dbg-menu { position: relative; flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; margin: 0 -.35rem .5rem; }
/* Shots: shows and hides the list of them, under their scenes, each with its place in the book. */
.dbg-menu .dbg-list .name::before {   /* a triangle: ▸, turning to ▾ when open */
  content: ''; display: inline-block; margin: 0 .45em 0 .05em; vertical-align: .05em;
  border-left: .42em solid rgba(234, 233, 228, .7); border-top: .3em solid transparent; border-bottom: .3em solid transparent;
  transition: transform .15s;
}
.dbg-menu .dbg-list[aria-expanded="true"] .name::before { transform: rotate(90deg); }
/* Shots comes last in the menu, so its list can run down to the performance strip. */
.dbg-menu .dbg-list, .dbg-menu .dbg-shots { order: 1; }
/* While the list is out, the other topics step aside to give it the height. */
.dbg-menu:has(.dbg-list[aria-expanded="true"]) > button:not(.dbg-list) { display: none; }
.dbg-shots { flex: 1 1 0; min-height: 10rem; overflow-y: auto; margin: .125rem 0 .375rem .4375rem; padding-right: .25rem; border-left: 1px solid rgba(234, 233, 228, .12); }
.dbg-shots[hidden] { display: none; }
.dbg-shots .sl-new { position: sticky; top: 0; z-index: 1; padding: .3125rem .4375rem .4375rem; background: rgb(16, 18, 23); }
.dbg-shots .sl-new button { width: 100%; padding: .25rem .5625rem; border: 1px dashed var(--line); border-radius: 5px; color: var(--mist); }
.dbg-shots .sl-new button:hover { border-style: solid; background: rgba(234, 233, 228, .06); }
.dbg-shots .sl-mark { display: flex; align-items: center; gap: .375rem; margin-top: .6875rem; padding: .25rem .25rem .25rem .4375rem; border-radius: 4px; font-weight: 600; color: #e8c37e; cursor: pointer; }
.dbg-shots .sl-mark:hover { background: rgba(232, 195, 126, .08); }
.dbg-shots .sl-row { position: relative; display: flex; align-items: center; gap: .375rem; padding: .2rem .25rem .2rem .6875rem; border-radius: 4px; cursor: pointer; color: rgba(234, 233, 228, .8); }
.dbg-shots .sl-row:hover { background: rgba(234, 233, 228, .06); color: rgba(234, 233, 228, .95); }
.dbg-shots .sl-row.sel { background: rgba(232, 195, 126, .14); color: #fff; }
.dbg-shots .sl-row.sel::before { content: ''; position: absolute; left: 0; top: .25rem; bottom: .25rem; width: 2px; border-radius: 1px; background: #e8c37e; }
.dbg-shots .sl-row.quiet .sl-name { font-style: italic; color: rgba(234, 233, 228, .5); }
.dbg-shots .sl-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dbg-shots input {
  flex: none; width: 3.25rem; padding: .025rem .25rem; text-align: right; font: inherit; font-family: var(--mono); color: inherit;
  background: rgba(234, 233, 228, .06); border: 1px solid transparent; border-radius: 3px;
}
.dbg-shots input:focus, .dbg-shots .sl-row:hover input { border-color: var(--line); outline: none; }
.dbg-menu button {
  display: flex; align-items: baseline; gap: .625rem; padding: .4rem .4375rem; border-radius: 4px; text-align: left; color: inherit;
}
.dbg-menu button:hover { background: rgba(234, 233, 228, .06); }
.dbg-menu button[aria-current="true"] { background: rgba(196, 207, 224, .14); color: #fff; }
.dbg-menu .hint { margin-left: auto; color: rgba(234, 233, 228, .5); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#debug-side .reset { padding: .1rem .5625rem; border: 1px solid var(--line); border-radius: 3px; color: var(--mist); }
#debug-side .reset:hover { background: rgba(234, 233, 228, .08); }

/* The performance strip, pinned to the bottom of the menu */
.perf-strip {
  margin-top: auto; display: flex; flex-direction: column; gap: .375rem; padding: .625rem; text-align: left; color: inherit;
  border: 1px solid rgba(234, 233, 228, .1); border-radius: 5px; background: rgba(234, 233, 228, .03);
}
.perf-strip:hover { border-color: var(--line); }
.perf-strip[aria-current="true"] { border-color: rgba(196, 207, 224, .45); }
.pf-head { display: flex; align-items: baseline; gap: .5rem; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.pf-fps { font-size: 1em; font-weight: 600; }
.pf-hz { font-size: .85em; margin-left: auto; color: rgba(234, 233, 228, .45); }
.pf-delta { font-size: .9em; }
.perf-strip .good { color: #a3b29a; }
.perf-strip .fair { color: #d9b77a; }
.perf-strip .poor { color: #e0907f; }
.pf-graph { display: block; width: 100%; height: 34px; }
.pf-graph.big { height: 90px; margin-bottom: .5rem; }
.pf-bars { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5625rem; }
.pf-bar { display: flex; flex-direction: column; gap: .1875rem; }
.pf-bar b { font-weight: 400; color: rgba(234, 233, 228, .5); font-size: .9em; }
.pf-bar i { display: block; height: 4px; border-radius: 2px; background: rgba(234, 233, 228, .1); overflow: hidden; }
.pf-bar u { display: block; height: 100%; width: 0; background: var(--mist); transition: width .4s ease; }
.pf-bar.good u { background: #a3b29a; }
.pf-bar.fair u { background: #d9b77a; }
.pf-bar.poor u { background: #e0907f; }
.pf-bar.off { opacity: .35; }
.pf-foot { display: flex; align-items: center; gap: .5rem; font-family: var(--mono); font-size: .9em; color: rgba(234, 233, 228, .55); }
.pf-heap { margin-left: auto; }
.pf-dot { width: 6px; height: 6px; border-radius: 50%; background: rgba(234, 233, 228, .25); }
.pf-dot.busy { background: #8db0f0; animation: pf-pulse .8s ease-in-out infinite alternate; }
@keyframes pf-pulse { to { opacity: .3; } }

/* A topic's page */
.dbg-page { display: flex; flex-direction: column; gap: .375rem; }
.dbg-page[hidden], .dbg-page [hidden] { display: none !important; }
.dbg-page h4 { margin: .625rem 0 0; font-size: .9em; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: rgba(234, 233, 228, .45); }
#debug-side .row { display: grid; grid-template-columns: 7.75rem 1fr auto; align-items: center; gap: .625rem; cursor: pointer; min-height: 1.625rem; }
#debug-side .row .name { color: rgba(234, 233, 228, .75); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#debug-side .row select { grid-column: 2 / -1; min-width: 0; font: inherit; color: inherit; background: rgba(234, 233, 228, .08); border: 1px solid var(--line); border-radius: 3px; padding: .0625rem .25rem; }
#debug-side .row.toggle input { grid-column: 2 / -1; justify-self: start; accent-color: var(--mist); }
#debug-side input[type="range"] { min-width: 0; width: 100%; accent-color: var(--mist); }
#debug-side .val { text-align: right; color: rgba(234, 233, 228, .65); }
/* A slider runs the panel's full width, its name and value above it. */
#debug-side label.slider { display: grid; grid-template-columns: 1fr auto; gap: .0625rem .625rem; align-items: baseline; margin-top: .1875rem; }
#debug-side label.slider input[type="range"] { grid-column: 1 / -1; grid-row: 2; width: 100%; margin: 0; }
#debug-side label.slider .name { color: rgba(234, 233, 228, .75); }
#debug-side .readout { margin: .625rem 0 0; font-family: var(--mono); font-size: .92em; color: rgba(234, 233, 228, .5); }
#debug-side .perf { display: grid; grid-template-columns: auto 1fr; gap: .1875rem .75rem; margin: 0; font-family: var(--mono); font-size: .92em; font-variant-numeric: tabular-nums; }
#debug-side .perf dt { color: rgba(234, 233, 228, .5); font-family: var(--ui); }
#debug-side .perf dd { margin: 0; text-align: right; }
body.no-trail #trail { display: none; }

@media (prefers-reduced-motion: reduce) {
  #flash.lightning, #flash.aura, #flash.candle { animation-duration: .01s; }
}

/* ── Walk editor (?debug, then E) ─────────────────────────────────────── */

/*
 * The shot editor's panel, the Shots page of the tools: wider than the other pages, and in sections
 * (the shot, its words, its camera, its route), the playhead's controls under the shot's name and
 * saving pinned to the bottom.
 */
body.editing { --debug-side-w: var(--edit-side-w); }
#debug-side:has(#walk-editor:not([hidden])) { padding-bottom: 0; }
#walk-editor {
  --gold: #e8c37e; --dim: rgba(234, 233, 228, .5); --field: rgba(234, 233, 228, .05);
  display: flex; flex-direction: column; min-height: 100%; font-size: 1.08em; line-height: 1.4;
}
#walk-editor [hidden] { display: none !important; }
#walk-editor p { margin: 0; }
#walk-editor button {
  display: inline-flex; align-items: center; justify-content: center; gap: .375rem; min-height: 2rem; padding: 0 .75rem;
  border: 1px solid var(--line); border-radius: 5px; color: var(--mist); transition: background .12s, border-color .12s;
}
#walk-editor button:hover:not(:disabled) { background: rgba(234, 233, 228, .08); border-color: rgba(234, 233, 228, .35); }
#walk-editor button:disabled { opacity: .35; cursor: default; }
#walk-editor button:focus-visible, #walk-editor input:focus-visible, #walk-editor summary:focus-visible { outline: 2px solid rgba(196, 207, 224, .6); outline-offset: 1px; }
#walk-editor button.icon { width: 2rem; padding: 0; }
#walk-editor button.small { min-height: 1.6875rem; padding: 0 .625rem; font-size: .92em; }
#walk-editor button.primary { background: var(--gold); border-color: var(--gold); color: #1a1b20; font-weight: 600; }
#walk-editor button.primary:hover:not(:disabled) { background: #f0d29a; border-color: #f0d29a; }
#walk-editor button.primary:disabled { background: transparent; border-color: var(--line); color: var(--mist); font-weight: 400; }
#walk-editor button[aria-pressed="true"] { background: rgba(232, 195, 126, .16); border-color: rgba(232, 195, 126, .55); color: var(--gold); }
#walk-editor button.danger { border-color: transparent; color: #f0a08d; }
#walk-editor button.danger:hover:not(:disabled) { background: rgba(240, 160, 141, .12); border-color: rgba(240, 160, 141, .4); }

/* Keep navigation and playback visible while the editor's fields scroll underneath. */
#walk-editor .we-pinned {
  position: sticky; top: 0; z-index: 3; flex: none;
  margin: -.75rem -.875rem 0; padding: .75rem .875rem .5rem;
  background: rgb(16, 18, 23); box-shadow: 0 10px 16px -12px rgba(0, 0, 0, .7);
}

#walk-editor .we-pinned::before {
  content: ''; position: absolute; top: -.75rem; left: 0; right: 0; height: .75rem;
  background: inherit; pointer-events: none;
}

/* The shot: which, of how many, in which scene; the ones either side; close panel. */
#walk-editor .we-head { display: flex; align-items: center; gap: .625rem; margin: 0 -.1rem .6875rem; }
#walk-editor .we-nav { flex: 1; min-width: 0; display: flex; align-items: center; gap: .4375rem; }
#walk-editor .we-nav .icon { border-color: transparent; color: rgba(234, 233, 228, .7); }
#walk-editor .we-id { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; text-align: center; }
#walk-editor .we-title { font-size: 1.3em; font-weight: 600; letter-spacing: .01em; line-height: 1.2; }
#walk-editor .we-title span { font-weight: 400; color: var(--dim); }
#walk-editor .we-where { max-width: 100%; color: var(--gold); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#walk-editor .we-done { flex: none; width: 1.75rem; height: 1.75rem; min-height: 1.75rem; padding: 0; border-color: transparent; color: rgba(234, 233, 228, .7); }

/* The playhead: play, the clock, the view locked to the camera, the whole shot. */
#walk-editor .we-transport {
  display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; padding: .5rem; margin-bottom: .25rem;
  border-radius: 8px; background: rgba(234, 233, 228, .05); border: 1px solid rgba(234, 233, 228, .08);
}
#walk-editor .we-transport button.play { width: 2.625rem; height: 2.625rem; padding: 0; border-radius: 50%; background: var(--gold); border-color: var(--gold); color: #1a1b20; }
#walk-editor .we-transport button.play:hover { background: #f0d29a; }
#walk-editor .we-transport .icon { border-color: transparent; }
#walk-editor .we-transport .we-pace { flex: 0 0 100%; padding-top: .25rem; }
#walk-editor .we-pace input:disabled { opacity: .4; }
#walk-editor .we-time { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .25rem; font-family: var(--mono); font-variant-numeric: tabular-nums; }
#walk-editor .we-time b { font-size: 1.2em; font-weight: 500; color: #fff; }
#walk-editor .we-time span { color: var(--dim); }

/* Sections */
#walk-editor .we-sec { display: flex; flex-direction: column; gap: .5625rem; padding: .9375rem 0; border-top: 1px solid rgba(234, 233, 228, .09); }
#walk-editor .we-sec:first-of-type { border-top: 0; }
#walk-editor h5, #walk-editor .we-label, #walk-editor summary {
  display: flex; align-items: center; gap: .625rem; margin: 0; font-size: .86em; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--dim);
}
#walk-editor .we-label label { cursor: pointer; }
#walk-editor .we-input {
  margin: 0; width: 100%; padding: .5rem .6875rem; border: 1px solid rgba(234, 233, 228, .14); border-radius: 6px;
  background: var(--field); color: rgba(234, 233, 228, .95); transition: border-color .12s, background .12s;
}
#walk-editor input.we-input { font: inherit; font-size: 1.05em; }
#walk-editor textarea.we-input { font: 1.2em/1.45 var(--body); min-height: 8.75rem; resize: vertical; }
#walk-editor .we-input:hover { border-color: rgba(234, 233, 228, .25); }
#walk-editor .we-input:focus { outline: none; border-color: rgba(196, 207, 224, .6); background: rgba(234, 233, 228, .08); }
#walk-editor .we-input::placeholder { color: rgba(234, 233, 228, .35); font-style: italic; }
#walk-editor .we-recorded {
  padding: .0625rem .5rem; border-radius: 99px; background: rgba(232, 195, 126, .15); color: var(--gold);
  font-size: .9em; letter-spacing: .06em; cursor: help;
}
#walk-editor .we-source {
  margin-left: auto; color: var(--mist); text-transform: none; letter-spacing: 0; font-weight: 400; font-size: 1.1em; text-decoration: none;
  border-bottom: 1px solid rgba(196, 207, 224, .3);
}
#walk-editor .we-source:hover { border-bottom-color: var(--mist); }

/* How long the shot lasts, and how. */
#walk-editor .we-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; margin: 0; border-radius: 6px; overflow: hidden; background: rgba(234, 233, 228, .08); }
#walk-editor .we-stats div { padding: .375rem .625rem; background: rgb(20, 22, 28); }
#walk-editor .we-stats dt { color: var(--dim); font-size: .88em; }
#walk-editor .we-stats dd { margin: 0; font-family: var(--mono); font-variant-numeric: tabular-nums; color: rgba(234, 233, 228, .92); }
#walk-editor .we-info { color: var(--dim); font-style: italic; }

/* Sliders: name and value above, the whole width below. */
#walk-editor .we-slider { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: .3125rem .625rem; }
#walk-editor .we-slider .name { color: rgba(234, 233, 228, .8); cursor: pointer; }
#walk-editor .we-slider .val { font-family: var(--mono); font-variant-numeric: tabular-nums; color: var(--gold); }
#walk-editor .we-slider button { grid-column: 3; }
#walk-editor .we-slider input { grid-column: 1 / -1; width: 100%; min-width: 0; margin: 0; accent-color: var(--gold); }
#walk-editor .we-line { display: flex; align-items: center; justify-content: space-between; gap: .625rem; }
#walk-editor .we-line > span { color: rgba(234, 233, 228, .8); }

/* Cut, as a switch. */
#walk-editor .we-switch { display: flex; align-items: flex-start; gap: .6875rem; cursor: pointer; }
#walk-editor .we-switch input {
  appearance: none; flex: none; position: relative; width: 2.375rem; height: 1.3125rem; margin: .125rem 0 0; border-radius: 99px;
  background: rgba(234, 233, 228, .18); cursor: pointer; transition: background .15s;
}
#walk-editor .we-switch input::after {
  content: ''; position: absolute; top: .1875rem; left: .1875rem; width: .9375rem; height: .9375rem; border-radius: 50%; background: #e9e8e3; transition: transform .15s;
}
#walk-editor .we-switch input:checked { background: #e0907f; }
#walk-editor .we-switch input:checked::after { transform: translateX(1.0625rem); }
#walk-editor .we-switch span { color: var(--dim); }
#walk-editor .we-switch b { margin-right: .375rem; font-weight: 500; color: rgba(234, 233, 228, .9); }

/* The route's tools, joined. */
#walk-editor .we-seg { display: flex; }
#walk-editor .we-seg button { flex: 1; border-radius: 0; margin-left: -1px; }
#walk-editor .we-seg button:first-child { border-radius: 5px 0 0 5px; margin-left: 0; }
#walk-editor .we-seg button:last-child { border-radius: 0 5px 5px 0; }
#walk-editor .we-seg button[aria-pressed="true"] { position: relative; z-index: 1; }
#walk-editor .we-legend { display: flex; flex-wrap: wrap; align-items: center; gap: .375rem; color: var(--dim); font-size: .92em; }
#walk-editor .we-legend i { width: 1.125rem; height: 0; margin-left: .4375rem; border-top: 2px solid var(--gold); }
#walk-editor .we-legend i:first-child { margin-left: 0; }
#walk-editor .we-legend i.no-trail { border-top: 2px dotted rgba(232, 195, 126, .4); }
#walk-editor .we-legend i.track { border-top: 2px dotted #8db0f0; }
#walk-editor .we-legend i.from { height: .6875rem; border: 1.5px dashed #a3d39a; }
#walk-editor .we-legend i.end { height: .6875rem; border: 1.5px solid #f0a08d; }

/* Shortcuts, folded away. */
#walk-editor summary { cursor: pointer; list-style: none; }
#walk-editor summary::-webkit-details-marker { display: none; }
#walk-editor summary::before {
  content: ''; border-left: .4em solid currentColor; border-top: .28em solid transparent; border-bottom: .28em solid transparent; transition: transform .15s;
}
#walk-editor details[open] summary::before { transform: rotate(90deg); }
#walk-editor .we-help { width: 100%; margin-top: .5625rem; border-collapse: collapse; color: rgba(234, 233, 228, .7); }
#walk-editor .we-help td { padding: .225rem 0; vertical-align: baseline; }
#walk-editor .we-help td:first-child { padding-right: .75rem; white-space: nowrap; }
#walk-editor kbd {
  display: inline-block; padding: 0 .375rem; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 3px;
  font: .92em/1.4 var(--mono); color: rgba(234, 233, 228, .85); background: rgba(234, 233, 228, .05);
}

/* Saving, pinned to the bottom. */
#walk-editor .we-foot {
  position: sticky; bottom: 0; z-index: 2; margin: auto -.7rem 0; padding: .6875rem .875rem .875rem;
  background: rgb(16, 18, 23); border-top: 1px solid var(--line); box-shadow: 0 -10px 20px -8px rgba(0, 0, 0, .6);
}
#walk-editor .we-status { color: var(--gold); margin-bottom: .5625rem !important; }
#walk-editor .we-status:empty { display: none; }
#walk-editor .we-actions { display: flex; align-items: center; gap: .4375rem; }
#walk-editor .we-actions .danger { margin-left: auto; }
#walk-editor .we-actions .primary { min-width: 5.625rem; }

#walk-overlay {
  position: fixed; z-index: 11; top: 0; left: var(--view-l); width: calc(100vw - var(--view-l) - var(--view-r)); height: calc(100vh - var(--view-b));
  pointer-events: none; overflow: hidden; font: .875rem/1 var(--sc); letter-spacing: .08em;
}
#walk-overlay * { vector-effect: non-scaling-stroke; }
#walk-overlay polyline { fill: none; stroke-linecap: round; stroke-linejoin: round; }
#walk-overlay .route { stroke: #e8c37e; stroke-width: 2.5; filter: drop-shadow(0 0 2px rgba(0, 0, 0, .8)); }
#walk-overlay.generated .route { stroke-dasharray: 7 5; }
#walk-overlay .track { stroke: #8db0f0; stroke-width: 1.5; stroke-dasharray: 2 4; }
#walk-overlay .other { stroke: rgba(234, 233, 228, .45); stroke-width: 1.5; stroke-dasharray: 3 5; }
#walk-overlay .sketch-guide { stroke: #e8c37e; stroke-width: 2; stroke-dasharray: 2 5; opacity: .9; }
#walk-overlay .sketch-guide.start-guide { stroke: #a3d39a; }
#walk-overlay .sketch-guide.end-guide { stroke: #f0a08d; }
#walk-overlay .stroke { stroke: #e8c37e; stroke-width: 2; opacity: .8; }
#walk-overlay rect { fill: none; stroke-width: 1.5; }
/* Where the walk starts and ends: green and red, like its first and last points. */
#walk-overlay rect.from { stroke: #a3d39a; stroke-dasharray: 5 5; }
#walk-overlay rect.end { stroke: #f0a08d; }
#walk-overlay rect.street { stroke: #8db0f0; stroke-dasharray: 4 4; }
#walk-overlay text { stroke: none; }
#walk-overlay text.from { fill: #a3d39a; }
#walk-overlay text.end { fill: #f0a08d; }
#walk-overlay rect.moment { stroke: rgba(234, 233, 228, .9); stroke-width: 1.5; }
#walk-overlay text.moment { fill: rgba(234, 233, 228, .9); }
#walk-overlay .pt { fill: rgba(16, 18, 23, .85); stroke: #e8c37e; stroke-width: 2; pointer-events: all; cursor: grab; }
#walk-overlay .pt:hover { fill: #e8c37e; }
#walk-overlay .pt.first { stroke: #a3d39a; }
#walk-overlay .pt.last { stroke: #f0a08d; }
#walk-overlay .pt.sel { fill: #e8c37e; }
#walk-overlay.previewing { opacity: .35; }
#walk-overlay.previewing .pt { pointer-events: none; }
body.editing .hotspot { visibility: hidden !important; pointer-events: none !important; }
#walk-overlay .route.no-trail { stroke: rgba(232, 195, 126, .4); stroke-dasharray: 2 6; }

/* ── The shot editor's timeline: the whole book, a block to each shot ─── */

body.editing #thread { display: none; }
body.editing #subtitle { bottom: calc(var(--timeline-h) + 1rem); }
#timeline {
  position: fixed; z-index: 14; left: var(--debug-w); right: calc(var(--reader-w) + var(--side-w)); bottom: 0; height: var(--timeline-h);
  background: rgb(16, 18, 23); border-top: 1px solid var(--line); font: .775rem/1.25 var(--ui); color: rgba(234, 233, 228, .85);
}
body.reader-hidden #timeline, body[data-layout="portrait"] #timeline { right: var(--side-w); }
/* Folded down to its tab, the painting taking the room. */
body.timeline-hidden { --timeline-h: 0px; }
body.timeline-hidden #timeline .tl-scroll { display: none; }
#timeline .tl-fold {
  position: absolute; z-index: 3; right: .75rem; bottom: 100%; height: 1.375rem; padding: 0 .625rem; display: flex; align-items: center; gap: .375rem;
  background: rgb(16, 18, 23); color: rgba(234, 233, 228, .7); border: 1px solid var(--line); border-bottom: 0; border-radius: 6px 6px 0 0;
  font: .7rem/1 var(--ui); letter-spacing: .08em;
}
#timeline .tl-fold:hover { color: var(--mist); }
#timeline .tl-fold svg { width: .75rem; height: .75rem; transform: rotate(90deg); }
#timeline .tl-fold[aria-expanded="true"] svg { transform: rotate(-90deg); }
#timeline .tl-scroll { position: absolute; inset: 0; overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; scrollbar-color: rgba(234, 233, 228, .2) transparent; }
#timeline .tl-track { position: relative; height: 100%; cursor: pointer; user-select: none; }
/* The scenes: a tick and a numeral where each begins. */
#timeline .tl-mark {
  position: absolute; top: 0; height: 2rem; display: flex; align-items: center; gap: .4375rem; padding: 0 .625rem 0 .5rem; max-width: 20rem;
  border-left: 1.5px solid rgba(232, 195, 126, .8); white-space: nowrap; overflow: hidden; color: rgba(234, 233, 228, .6);
  background: rgb(16, 18, 23);   /* each covers the title of the one before, where they crowd */
}
#timeline .tl-mark:hover { color: rgba(234, 233, 228, .9); }
#timeline .tl-mark span { flex: none; padding: .0625rem .375rem; border-radius: 3px; background: #e8c37e; color: #16171c; font-weight: 700; }
/* The shots: a block each, as long as it lasts, the travel its lighter start. */
#timeline .tl-shots { position: absolute; left: 0; right: 0; top: 2rem; height: 3.5rem; }
#timeline .tl-shot {
  position: absolute; top: 0; bottom: 0; overflow: hidden; border-right: 2px solid transparent; background-clip: padding-box;
  isolation: isolate; border-radius: 4px; background-color: rgba(196, 207, 224, .16); transition: background-color .12s;
}
#timeline .tl-shot:hover { background-color: rgba(196, 207, 224, .24); }
#timeline .tl-shot.quiet { background-color: rgba(234, 233, 228, .06); }
#timeline .tl-shot i { position: absolute; left: 0; top: 0; bottom: 0; background: repeating-linear-gradient(135deg, rgba(232, 195, 126, .22) 0 4px, rgba(232, 195, 126, .1) 4px 8px); }   /* its travel */
#timeline .tl-shot.cut { box-shadow: inset 2px 0 0 #f0a08d; }
#timeline .tl-shot span { position: relative; display: flex; align-items: center; height: 100%; padding: 0 .5625rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none; }
#timeline .tl-shot.quiet span { color: rgba(234, 233, 228, .4); }
#timeline .tl-shot.sel { background-color: rgba(232, 195, 126, .3); box-shadow: inset 0 0 0 1.5px #e8c37e; color: #fff; z-index: 1; }
#timeline .tl-shot.sel.cut { box-shadow: inset 0 0 0 1.5px #e8c37e, inset 3px 0 0 #f0a08d; }
/* The playhead: a line with a handle at the top. */
#timeline .tl-head { position: absolute; top: 0; bottom: 0; left: 0; width: 2px; margin-left: -1px; background: #fff; box-shadow: 0 0 4px rgba(0, 0, 0, .8); pointer-events: none; z-index: 2; }
#timeline .tl-head::before { content: ''; position: absolute; top: 0; left: -4px; border: 5px solid transparent; border-top: 6px solid #fff; border-bottom: 0; }

/* A still of the shot before (painting, atmosphere, black), faded out over the next shot by js/app.js. */
.shot-fade { position: fixed; inset: 0; pointer-events: none; }
.shot-fade > canvas, .shot-fade > div { position: absolute; }
.shot-fade > div { overflow: hidden; }
.shot-fade .fx-layer { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.shot-fade-black { inset: 0; background: #000; }
#walk-editor [data-f="title"] + .we-label { margin-top: 1rem; }


/* Music clips share the shot lane's horizontal scale and selection. */
#timeline .tl-music-lane { position: absolute; left: 0; right: 0; top: 5.75rem; height: 2.75rem; border-top: 1px solid rgba(163, 178, 154, .18); }
#timeline .tl-music-lane::before { content: 'Music'; position: sticky; left: 0; display: block; width: 3rem; padding-left: .3rem; font-size: .75em; line-height: 1.2; color: #a3b29a; background: #101217; }
#timeline .tl-music { position: absolute; top: .8rem; height: 1.7rem; display: flex; align-items: center; overflow: hidden; border-right: 2px solid #101217; border-radius: 4px; background: rgba(163, 178, 154, .13); color: #a3b29a; }
#timeline .tl-music-label { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; padding: 0 .5rem; font: .85em var(--mono); pointer-events: none; }
#timeline .tl-music.sel { z-index: 1; background: rgba(163, 178, 154, .25); box-shadow: inset 0 0 0 1.5px #a3b29a; color: #e8eee4; }
#timeline .tl-music-handle { position: absolute; top: 0; bottom: 0; width: min(.6rem, 30%); padding: 0; background: rgba(163, 178, 154, .35); cursor: ew-resize; opacity: 0; touch-action: none; }
#timeline .tl-music-handle.start { left: 0; border-right: 1px solid #a3b29a; }
#timeline .tl-music-handle.end { right: 0; border-left: 1px solid #a3b29a; }
#timeline .tl-music.sel .tl-music-handle, #timeline .tl-music:hover .tl-music-handle { opacity: 1; }
#timeline .tl-music.sel .tl-music-label { padding: 0 .85rem; }
#timeline .tl-music-handle:focus-visible { outline: 2px solid #fff; outline-offset: -2px; opacity: 1; }


/* Outer handles set total shot length; music keeps its separate lane. */
#timeline .tl-time-handle { position: absolute; top: 0; bottom: 0; z-index: 2; width: min(.6rem, 30%); padding: 0; background: rgba(232, 195, 126, .45); cursor: ew-resize; opacity: 0; touch-action: none; }
#timeline .tl-time-handle.start { left: 0; border-right: 1px solid #e8c37e; }
#timeline .tl-time-handle.end { right: 0; border-left: 1px solid #e8c37e; }
#timeline .tl-shot.sel .tl-time-handle, #timeline .tl-shot:hover .tl-time-handle { opacity: 1; }
#timeline .tl-time-handle:focus-visible { opacity: 1; outline: 2px solid #fff; outline-offset: -2px; }
#timeline .tl-time-value { display: none; position: absolute; right: .8rem; bottom: .15rem; padding: .1rem .2rem; border-radius: 2px; color: #e8c37e; background: #101217; font: .75em var(--mono); pointer-events: none; white-space: nowrap; }
#timeline .tl-shot.sel .tl-time-value { display: block; }
#timeline .tl-time-value[hidden] { display: none; }

#timeline .tl-shot.sel > span { padding-left: .85rem; padding-right: .85rem; }

/* The blue marker separates camera movement from the held remainder of the shot. */
#timeline .tl-camera-handle { position: absolute; top: 0; z-index: 3; width: .8rem; height: 1rem; padding: 0; transform: translateX(-50%); background: #8db0f0; border-radius: 0 0 3px 3px; cursor: ew-resize; touch-action: none; opacity: 0; }
#timeline .tl-camera-handle::after { content: ''; position: absolute; top: 100%; left: calc(50% - .5px); height: 2.5rem; width: 1px; background: #8db0f0; pointer-events: none; }
#timeline .tl-shot.sel .tl-camera-handle, #timeline .tl-shot:hover .tl-camera-handle, #timeline .tl-camera-handle:focus-visible { opacity: 1; }
#timeline .tl-camera-handle:focus-visible { outline: 2px solid white; outline-offset: -2px; }

/* Gaps in this lane are silence. Clip interiors slip the source; edges trim placement. */
#timeline .tl-music { cursor: ew-resize; isolation: isolate; }
#timeline .tl-music:focus-visible { outline: 2px solid #a3b29a; outline-offset: -2px; }
#timeline .tl-music-cut { position: absolute; top: 6.55rem; left: 50%; transform: translateX(-50%); width: 1.4rem; height: 1.7rem; padding: 0; border: 1px solid #a3b29a; border-radius: 4px; color: #e8eee4; background: #263024; font-size: 1rem; cursor: pointer; pointer-events: auto; opacity: 0; transition: opacity .1s; }
#timeline .tl-music-cut:hover, #timeline .tl-music-cut:focus-visible { opacity: 1; }
#timeline .tl-music-cut:disabled { display: none; }

/* Waveform canvases cover only the visible clip area and never intercept editing gestures. */
#timeline .tl-music-waveform { position: absolute; top: 0; pointer-events: none; opacity: .85; }
#timeline .tl-music-waveform[hidden] { display: none; }
#timeline .tl-music-label { position: relative; z-index: 1; align-self: flex-end; font-size: .65em; line-height: 1.25; background: rgba(16, 18, 23, .78); }
#timeline .tl-music-handle { z-index: 2; }
/* Recorded voices: a lane for each take, below the music, placed by its shots (not edited here). */
#timeline .tl-voice-lanes { position: absolute; left: 0; right: 0; top: 8.5rem; }
#timeline .tl-voice-lane { position: relative; height: 2.25rem; border-top: 1px solid rgba(201, 163, 214, .16); }
#timeline .tl-voice-lane::before { content: 'Voice · ' attr(data-name); position: sticky; left: 0; display: inline-block; padding: 0 .3rem; font-size: .75em; line-height: 1.2; color: #c9a3d6; background: #101217; white-space: nowrap; }
#timeline .tl-voice { position: absolute; top: .55rem; height: 1.5rem; display: flex; align-items: center; overflow: hidden; border-right: 2px solid #101217; border-radius: 4px; background: rgba(201, 163, 214, .12); color: #c9a3d6; }
#timeline .tl-voice-waveform { position: absolute; top: 0; pointer-events: none; opacity: .85; }
#timeline .tl-voice-waveform[hidden] { display: none; }
#timeline .tl-voice-label { position: relative; z-index: 1; align-self: flex-end; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; padding: 0 .5rem; font: .65em/1.25 var(--mono); background: rgba(16, 18, 23, .78); pointer-events: none; }

/* A compact route overview: each dot selects the same node as its mural marker. */
#walk-editor .we-route-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }
#walk-editor .we-point-count { font-size: .85em; font-weight: 400; letter-spacing: 0; text-transform: none; }
#walk-editor .we-route-points { display: flex; overflow-x: auto; padding: .1rem 0; scrollbar-width: thin; }
#walk-editor .we-route-points button { position: relative; height: 2rem; padding: 0; border: 0; background: transparent; border-radius: 0; }
#walk-editor .we-route-point { flex: 0 0 1.1rem; }
#walk-editor .we-route-point::after { content: ''; position: absolute; top: 50%; left: 50%; width: .55rem; height: .55rem; transform: translate(-50%, -50%); border: 2px solid var(--gold); border-radius: 50%; background: #101217; }
#walk-editor .we-route-point[aria-pressed="true"]::after { background: var(--gold); box-shadow: 0 0 0 3px rgba(232, 195, 126, .2); }
#walk-editor .we-route-point:hover::after, #walk-editor .we-route-point:focus-visible::after { border-color: #fff; }
#walk-editor .we-route-segment { flex: 1 0 .75rem; }
#walk-editor .we-route-segment::before { content: ''; position: absolute; top: 50%; left: -.15rem; right: -.15rem; border-top: 2px solid var(--gold); opacity: .7; }
#walk-editor .we-route-segment.no-trail::before { border-top-style: dotted; opacity: .4; }
#walk-editor .we-route-segment:hover::before, #walk-editor .we-route-segment:focus-visible::before { opacity: 1; border-top-color: #fff; }
#walk-editor .we-route-points button:focus-visible { outline: 1px solid var(--gold); outline-offset: -1px; }

#walk-editor .we-route-section .we-seg button { border-radius: 5px; margin-left: 0; }

#walk-editor .we-mood select { min-width: 0; max-width: 75%; padding: .35rem .5rem; border: 1px solid var(--line); border-radius: 5px; background: var(--field); color: inherit; font: inherit; }

#walk-editor .we-time-main { display: flex; align-items: baseline; gap: .4375rem; white-space: nowrap; }
#walk-editor .we-time-context { display: flex; flex-wrap: wrap; column-gap: .5em; font-size: .65em; color: var(--dim); }
#walk-editor .we-time-context > span { white-space: nowrap; }
#walk-editor .we-time-context > span + span::before { content: '·'; margin-right: .5em; }

/* The public release: keep the full controls available to the editor (?debug). */
body.public-view #hud,
body.public-view #thread,
body.public-view #t-prev,
body.public-view #t-next,
body.public-view #t-hide,
body.public-view #reader-tab,
body.public-view .volume .row { display: none; }
.volume-play, .volume-soon, .share-button { display: none; }
body.public-view .volume.available { cursor: pointer; }
body.public-view .volume-play {
  display: flex; position: absolute; inset: 0; z-index: 2; width: 100%;
  align-items: center; justify-content: center; flex-direction: column; gap: .6rem;
  background: rgba(0, 0, 0, .12); color: #fff;
}
.volume-play span {
  display: grid; place-items: center; width: 5.5rem; height: 5.5rem; border-radius: 50%;
  background: rgba(14, 16, 20, .85); border: 2px solid var(--chalk); box-shadow: 0 4px 30px #0008;
  transition: background .2s, transform .2s;
}
.volume-play svg { width: 2.7rem; height: 2.7rem; fill: currentColor; stroke: none; }
.volume-play b { font: 600 1.25rem/1.4 var(--ui); text-shadow: 0 2px 8px #000; }
.volume-play:hover span { background: #9a5248; transform: scale(1.06); }
.volume-play:focus-visible { outline: 4px solid var(--chalk); outline-offset: -6px; }
body.public-view .volume-soon {
  display: grid; place-items: center; position: absolute; inset: 0; z-index: 2;
  background: rgba(14, 16, 20, .6); color: #fff; padding: 1rem;
}
.volume-soon strong { font: 600 clamp(2rem, 4vw, 2.7rem)/1.2 var(--display); text-align: center; text-shadow: 0 2px 14px #000; }
body.public-view .volume:has(.volume-soon):hover { transform: none; }
body.public-view .volume:has(.volume-soon) .cover img { transform: scale(1.08); filter: saturate(.6) brightness(.7); }
body.public-view .transport { display: grid; grid-template-columns: 3rem 1fr; gap: 1rem; padding: .6rem 1rem .8rem; }
body.public-view .share-button {
  display: inline-flex; align-items: center; justify-content: center; gap: .6rem;
  justify-self: center; width: min(100%, 12rem); min-height: 3rem; padding: .55rem 1rem;
  border: 2px solid var(--ink); border-radius: .5rem; background: var(--ink); color: var(--paper);
  font: 600 1.15rem/1.4 var(--ui);
}
.share-button svg { width: 1.4rem; height: 1.4rem; stroke-width: 1.8; }
.share-button:hover { background: var(--accent); border-color: var(--accent); }
.share-button:focus-visible, #share-dialog :is(button, a, input):focus-visible { outline: 3px solid #3f5f86; outline-offset: 4px; }
#share-dialog {
  width: min(30rem, calc(100vw - 2rem)); max-height: calc(100dvh - 2rem); padding: 1.3rem;
  border: 1px solid var(--paper-edge); border-radius: .7rem; background: var(--paper); color: var(--ink);
  box-shadow: 0 20px 80px #0008; font: 1rem/1.5 var(--ui);
}
#share-dialog::backdrop { background: rgba(0, 0, 0, .7); }
.share-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.share-heading h2 { margin: 0; font: 600 1.4rem/1.2 var(--display); }
#share-close { min-height: 2.4rem; padding: .3rem .65rem; border: 1px solid var(--ink-soft); border-radius: .3rem; font: 600 .9rem var(--ui); }
#share-intro { margin: 1rem 0; }
.share-options { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; margin-bottom: 1.2rem; }
.share-options :is(a, button) {
  display: flex; align-items: center; justify-content: center; min-height: 2.8rem; padding: .5rem;
  background: var(--ink); color: var(--paper); border: 1px solid var(--ink); border-radius: .35rem;
  text-align: center; text-decoration: none; font: 600 1rem/1.4 var(--ui);
}
.share-options :is(a, button):hover { background: #3f5f86; }
#share-dialog label { display: block; font-size: .85rem; margin-bottom: .35rem; }
#share-url { width: 100%; min-height: 2.5rem; padding: .5rem; border: 1px solid var(--ink-soft); border-radius: .3rem; background: #fff; color: var(--ink); font: .8rem var(--ui); }
#share-status { margin: .8rem 0 0; }
#share-status:empty { display: none; }

/* Sound sits beside Share, with a full text label and a generous touch target. */
.reading-sound { display: none; }
body.public-view .transport { grid-template-columns: 3rem minmax(0, 1fr) minmax(0, 1fr); gap: .5rem; }
body.public-view :is(.share-button, .reading-sound) {
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
  width: 100%; min-height: 3rem; padding: .4rem .5rem; border: 2px solid var(--ink);
  border-radius: .5rem; background: var(--ink); color: var(--paper); font: 600 1rem/1.3 var(--ui);
}
.reading-sound svg { flex: none; width: 1.3rem; height: 1.3rem; }
.reading-sound[aria-pressed="false"] .sound-waves,
.reading-sound[aria-pressed="true"] .sound-cross { display: none; }
body.public-view :is(.share-button, .reading-sound):hover { background: var(--accent); border-color: var(--accent); }
.reading-sound:focus-visible { outline: 3px solid #3f5f86; outline-offset: 4px; }
@media (max-width: 480px) {
  body.public-view :is(.share-button, .reading-sound) { flex-direction: column; gap: .1rem; font-size: .9rem; }
  body.public-view :is(.share-button, .reading-sound) svg { width: 1.1rem; height: 1.1rem; }
}
