:root {
  --bg: #040405;
  --ink: #ede6d8;
  --muted: rgba(237, 230, 216, .66);
  --faint: rgba(237, 230, 216, .4);
  --line: rgba(237, 230, 216, .12);
  --line-strong: rgba(237, 230, 216, .24);
  --glass: rgba(10, 10, 13, .58);
  --glass-strong: rgba(12, 12, 16, .9);
  --violet: #8a3cff;
  --magenta: #ff2fb0;
  --ember: #ff4a1a;
  --amber: #ff9a3c;
  --ww: #ffcf96;
  --sage: #8fae9a;
  --haptic: #8ce6cc;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --r: 12px;
  --gutter: 20px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font: 14px/1.45 var(--sans); overflow: hidden; -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; }
canvas#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
canvas#scene.over { cursor: pointer; }
canvas#scene.holding { cursor: none; }
:focus-visible { outline: 2px solid var(--ww); outline-offset: 2px; }

/* ---------- top ---------- */
.top { position: fixed; top: 0; left: 0; right: 0; display: grid; grid-template-columns: 1fr auto 1fr; align-items: start; gap: 16px; padding: calc(var(--gutter) + env(safe-area-inset-top)) var(--gutter) 0; pointer-events: none; z-index: 5; }
.top > * { pointer-events: auto; }
.eyebrow { font-size: 10.5px; letter-spacing: .22em; text-transform: uppercase; color: var(--muted); }
.eyebrow-sub { color: var(--faint); letter-spacing: .14em; }
.phase { font-family: var(--serif); font-style: italic; font-size: 30px; line-height: 1.1; margin-top: 6px; letter-spacing: .005em; transition: color 1.2s; }
.phase-line { max-width: 34ch; color: var(--muted); font-family: var(--serif); font-size: 14px; margin-top: 4px; min-height: 2.9em; }
.brand { text-shadow: 0 1px 12px #000; }

.top .arc { list-style: none; margin: 4px 0 0; padding: 4px; display: flex; gap: 2px; background: var(--glass); border: 1px solid var(--line); border-radius: 999px; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.top .arc li { display: flex; }
/* phase pills: buttons that jump the show to that phase */
.top .arc .ph-pill { display: flex; align-items: center; gap: 7px; min-height: 28px; padding: 0 11px; border: 0; border-radius: 999px; background: none; cursor: pointer;
  font: inherit; font-size: 11.5px; color: var(--muted); letter-spacing: .04em; white-space: nowrap; transition: color .3s, background .3s, box-shadow .2s; }
.top .arc .ph-pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .6; flex: none; }
.top .arc li.done .ph-pill { color: var(--ink); }
.top .arc li.now .ph-pill { color: var(--ink); background: rgba(237, 230, 216, .1); }
.top .arc li.now .ph-pill::before { background: var(--ph, var(--violet)); box-shadow: 0 0 10px var(--ph, var(--violet)); opacity: 1; }
.top .arc .ph-pill:hover { color: var(--ink); background: rgba(237, 230, 216, .14); box-shadow: inset 0 0 0 1px rgba(237, 230, 216, .22); }
.top .arc .ph-pill:hover::before { opacity: 1; }
.top .arc .ph-pill:focus-visible { outline: 2px solid var(--ww); outline-offset: 1px; }
.top .arc .ph-pill:active { background: rgba(255, 207, 150, .16); }


/* ---------- bottom ---------- */
.bottom { position: fixed; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: auto 1fr auto; align-items: end; gap: 16px; padding: 0 var(--gutter) calc(var(--gutter) + env(safe-area-inset-bottom)); pointer-events: none; z-index: 5; }
.bottom > * { pointer-events: auto; }
.dock { display: flex; gap: 6px; padding: 6px; background: var(--glass); border: 1px solid var(--line); border-radius: 16px; backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
.dock .chip { --c: var(--violet); display: grid; grid-template-columns: 34px auto; gap: 9px; align-items: center; padding: 6px 12px 6px 6px; min-height: 46px; border-radius: 11px; border: 1px solid transparent; background: none; cursor: pointer; text-align: left; touch-action: none; user-select: none; -webkit-user-select: none; transition: background .3s, border-color .3s; }
.dock .chip:hover { background: rgba(237, 230, 216, .05); }
.dock .chip.held { background: rgba(237, 230, 216, .08); border-color: var(--line-strong); }
.dock .chip[disabled] { opacity: .38; cursor: default; }
.dock .chip svg { width: 34px; height: 34px; transform: rotate(-90deg); }
.dock .chip .ring-bg { fill: none; stroke: var(--line-strong); stroke-width: 2.5; }
.dock .chip .ring-clar { fill: none; stroke: var(--c); stroke-opacity: .45; stroke-width: 2.5; stroke-linecap: round; transition: stroke-dasharray .15s; }
.dock .chip .ring-lock { fill: none; stroke: var(--c); stroke-width: 2.5; stroke-linecap: round; }
.dock .chip .pent { fill: var(--c); fill-opacity: .18; stroke: var(--c); stroke-width: 1.2; transform-origin: 17px 17px; transform: rotate(90deg); }
.dock .chip.on .pent { fill-opacity: .85; }
.dock .chip .nm { font-size: 13px; color: var(--ink); line-height: 1.15; }
.dock .chip .st { font-size: 11px; color: var(--faint); line-height: 1.2; white-space: nowrap; }
.dock .chip.on .st { color: var(--muted); }
.dock .chip kbd { font: 10px var(--mono); color: var(--faint); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; margin-left: 4px; }
.dock-sep { width: 1px; background: var(--line); margin: 6px 2px; }

.hint { justify-self: center; align-self: end; margin: 0 0 12px; max-width: 46ch; text-align: center; font-family: var(--serif); font-size: 15px; color: var(--muted); text-shadow: 0 1px 14px #000, 0 0 2px #000; transition: opacity 1.5s; }
.hint.gone { opacity: 0; }

.floormap { display: flex; gap: 10px; align-items: center; padding: 8px 12px 8px 8px; background: var(--glass); border: 1px solid var(--line); border-radius: 16px; backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); cursor: pointer; }
.fm-cap { font-size: 12px; color: var(--ink); line-height: 1.3; }
.fm-cap span { color: var(--faint); font-size: 11px; }
#floorSvg rect.t { fill: rgba(237, 230, 216, .05); stroke: rgba(255, 190, 120, .35); stroke-width: .03; }
#floorSvg rect.s { fill: rgba(120, 150, 110, .22); stroke: rgba(237, 230, 216, .10); stroke-width: .02; }
#floorSvg .col { fill: none; stroke-width: .06; }

.feed { position: fixed; left: var(--gutter); bottom: calc(96px + env(safe-area-inset-bottom)); width: min(420px, calc(100vw - 2 * var(--gutter))); display: flex; flex-direction: column; gap: 4px; pointer-events: none; z-index: 4; }
.feed div { font-size: 12.5px; color: var(--muted); text-shadow: 0 1px 10px #000, 0 0 2px #000; animation: feedIn .5s ease both; transition: opacity 1.2s; }
.feed b { color: var(--ink); font-weight: 600; }
@keyframes feedIn { from { opacity: 0; transform: translateY(6px); } }

/* ---------- in-scene overlays ---------- */
.dial { position: fixed; left: 0; top: 0; pointer-events: none; opacity: 0; transition: opacity .25s; z-index: 3; }
.dial.on { opacity: 1; }
.dial circle { fill: none; }
.dial-track { stroke: rgba(237, 230, 216, .32); stroke-width: 1.2; stroke-dasharray: 1 3.5; }
.dial-clarity { stroke: var(--magenta); stroke-width: 2.5; stroke-linecap: round; transform: rotate(-90deg); opacity: .9; }
.dial-lock { stroke: var(--ww); stroke-width: 3; stroke-linecap: round; transform: rotate(-90deg); }
.dial .dial-knob { fill: #fff; filter: drop-shadow(0 0 6px var(--magenta)); }

.labels { position: fixed; inset: 0; pointer-events: none; z-index: 2; }
.lbl { position: absolute; left: 0; top: 0; transform: translate(-50%, -100%); white-space: nowrap; text-align: center; font-size: 11px; line-height: 1.25; color: var(--muted); text-shadow: 0 1px 8px #000, 0 0 2px #000; transition: opacity .4s; }
.lbl b { color: var(--ink); font-weight: 600; font-size: 11.5px; }
.lbl i { font-style: normal; color: var(--faint); }
.lbl .act { display: block; color: var(--ww); }
.lbl.tree { font-family: var(--serif); font-size: 13px; color: var(--ink); letter-spacing: .02em; }
.lbl.tree i { font-family: var(--sans); font-size: 10.5px; display: block; }

/* ---------- sensor HUD bars (base; .bars .bar below refines) ---------- */
.bars .bar { height: 5px; border-radius: 3px; background: var(--line); overflow: hidden; align-self: center; }
.bars .bar i { display: block; height: 100%; background: var(--c, var(--ww)); }

blockquote { margin: 14px 0 0; padding: 0 0 0 12px; border-left: 2px solid var(--line-strong); font-family: var(--serif); font-style: italic; color: var(--muted); font-size: 14px; }

/* ---------- enter ---------- */
.enter { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 24px; background: radial-gradient(120% 80% at 50% 60%, rgba(4, 4, 6, .55), rgba(4, 4, 6, .92)); transition: opacity 1.6s ease; }
.enter.gone { opacity: 0; pointer-events: none; }
.enter-card { max-width: 520px; text-align: center; }
.enter h1 { font-family: var(--serif); font-weight: 400; font-size: clamp(40px, 8vw, 64px); line-height: 1; margin: 14px 0 14px; letter-spacing: -.01em; }
.lede { font-family: var(--serif); font-size: 18px; color: var(--muted); margin: 0 auto 26px; max-width: 34ch; }
.enter-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.primary, .ghost { min-height: 46px; padding: 0 22px; border-radius: 999px; font-size: 14.5px; cursor: pointer; }
.primary { border: 0; background: var(--ww); color: #1a120a; font-weight: 600; box-shadow: 0 0 40px rgba(255, 180, 110, .25); }
.ghost { border: 1px solid var(--line-strong); background: rgba(237, 230, 216, .04); }
.small { font-size: 12.5px; color: var(--faint); margin-top: 18px; }
.link { border: 0; background: none; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; padding: 0; font-size: inherit; }
.enter blockquote { border: 0; padding: 0; margin: 34px auto 0; max-width: 40ch; font-size: 14px; color: var(--faint); }
.err { position: fixed; inset: auto 20px 20px; z-index: 30; background: #2a0d0d; border: 1px solid #a33; padding: 12px; border-radius: 10px; }


/* ---------- first person: distance stepper ---------- */
.fp-dist { display: inline-flex; align-items: center; gap: 4px; padding: 0 2px; }
.fp-dist[hidden] { display: none; }
.fp-dist output { min-width: 44px; text-align: center; font: 500 12px/1 var(--sans); color: var(--ww); font-variant-numeric: tabular-nums; }
.fp-dist .pill:disabled { opacity: .4; cursor: default; }

/* tree labels are buttons: stand here */
.lbl.tree { pointer-events: auto; cursor: pointer; padding: 2px 6px; border-radius: 8px; }
.lbl.tree:hover { background: rgba(10, 10, 13, .55); }
.lbl.tree u { display: block; text-decoration: none; font: 10px/1.4 var(--sans); letter-spacing: .1em; text-transform: uppercase; color: var(--ww); opacity: 0; transition: opacity .25s; }
.lbl.tree:hover u, .lbl.tree:focus-visible u { opacity: .9; }
.ghost { position: fixed; left: -14px; top: -14px; width: 28px; height: 28px; border-radius: 50%; border: 1.5px solid rgba(237, 230, 216, .8); box-shadow: 0 0 18px rgba(237, 230, 216, .35); pointer-events: none; opacity: 0; z-index: 3; transition: opacity .2s; }
.dial.low .dial-knob { fill: rgba(255, 255, 255, .5); }

/* ---------- first person ---------- */
body.fp .dock, body.fp .hint, body.fp .floormap { display: none; }
body.fp .feed { bottom: calc(300px + env(safe-area-inset-bottom)); }
body.fp canvas#scene { cursor: default; }
.pill { border: 1px solid var(--line-strong); background: var(--glass); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-radius: 999px; padding: 0 14px; min-height: 34px; font-size: 12.5px; color: var(--ink); cursor: pointer; }
.pill:hover { background: rgba(237, 230, 216, .1); }
.pill[aria-pressed="true"] { background: rgba(255, 207, 150, .14); border-color: rgba(255, 207, 150, .45); color: var(--ww); }
.pill.strong { background: rgba(237, 230, 216, .12); }
.pill.pulse { animation: pulse 1.6s ease-in-out infinite; border-color: rgba(255, 207, 150, .7); color: var(--ww); }
.pill.tiny { min-height: 24px; padding: 0 10px; font-size: 11px; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(255, 207, 150, .12), 0 0 24px rgba(255, 207, 150, .25); } }
.fp-bar { position: fixed; bottom: calc(var(--gutter) + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); z-index: 6; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: center; width: 560px; }
.fp-where { flex-basis: 100%; text-align: center; }
.fp-bar[hidden], .fp-cap[hidden], .card[hidden] { display: none; }
.fp-where { font-family: var(--serif); font-style: italic; font-size: 15px; color: var(--ink); padding: 0 8px; text-shadow: 0 1px 10px #000; white-space: nowrap; }
.fp-cap { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(150px + env(safe-area-inset-bottom)); z-index: 4; margin: 0; font-family: var(--serif); font-style: italic; font-size: 22px; color: var(--ink); text-shadow: 0 1px 16px #000, 0 0 3px #000; white-space: nowrap; pointer-events: none; }
.fp-cap.in { animation: capIn 1.2s ease both; }
@keyframes capIn { from { opacity: 0; transform: translate(-50%, 6px); } }

.card { position: fixed; z-index: 5; background: var(--glass); border: 1px solid var(--line); border-radius: 14px; backdrop-filter: blur(14px) saturate(1.1); -webkit-backdrop-filter: blur(14px) saturate(1.1); padding: 12px 14px 10px; }
.card header { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.card .k b { color: var(--ink); letter-spacing: .14em; }
.inp { left: var(--gutter); bottom: calc(var(--gutter) + env(safe-area-inset-bottom)); width: 480px; }
.inp .hw { margin: 8px 0; color: var(--muted); font-size: 11.5px; line-height: 1.4; }
.inp .hw b { font-weight: 600; color: var(--ink); }
.inp .hw .si { display: block; color: var(--faint); margin-top: 2px; }
.inp .row { display: grid; grid-template-columns: 132px 1fr 56px; gap: 12px; align-items: center; flex-wrap: nowrap; }
#preview { width: 132px; height: 96px; border-radius: 8px; background: #050808; border: 1px solid var(--line); }
.bars { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.bars .bar { display: grid; grid-template-columns: 56px 1fr 34px; align-items: center; gap: 8px; height: auto; background: none; overflow: visible; }
.bars .bar label { font: 500 10.5px/1 var(--sans); color: var(--faint); letter-spacing: .04em; }
.bars .bar i { height: 3px; background: rgba(237, 230, 216, .08); border-radius: 3px; overflow: hidden; display: block; }
.bars .bar b { display: block; height: 100%; width: 0; background: var(--muted); border-radius: 3px; }
.bars .bar output { font: 400 10.5px/1 var(--mono); color: var(--muted); text-align: right; }
.trace { position: relative; }
#trace { width: 100%; height: 36px; display: block; }
.trace .tl { position: absolute; left: 0; top: 0; font: 500 9.5px/1 var(--sans); color: var(--faint); letter-spacing: .06em; }
.focus { display: flex; flex-direction: column; align-items: center; }
.focus svg { transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: rgba(237, 230, 216, .1); stroke-width: 2; }
.ring { fill: none; stroke: var(--violet); stroke-width: 2.2; stroke-linecap: round; stroke-dasharray: 113.1; stroke-dashoffset: 113.1; transition: stroke .4s; }
.focus span { font: 500 12px/1 var(--mono); margin-top: -34px; height: 30px; }
.focus small { font: 500 9px/1 var(--sans); color: var(--faint); letter-spacing: .12em; text-transform: uppercase; margin-top: 2px; }
.card .status { margin: 8px 0 0; display: flex; justify-content: space-between; gap: 12px; font-size: 11px; color: var(--faint); }
.card .status code { font: 400 10.5px/1.3 var(--mono); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 50%; }
.plat { right: var(--gutter); bottom: calc(var(--gutter) + env(safe-area-inset-bottom)); width: 330px; }
.plat .meta span { font-size: 10px; }
.plat header .k, .plat header .zn { white-space: nowrap; }
.plat header .zn { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.plat .meta { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.plat .meta output { white-space: nowrap; }
.zn { font: 500 11px/1 var(--mono); color: var(--muted); }
#scope { width: 100%; height: 48px; display: block; margin: 8px 0 6px; }
.zm { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; }
.zm div { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.zm i { width: 100%; height: 20px; border-radius: 3px; background: rgba(237, 230, 216, .05); position: relative; overflow: hidden; display: block; }
.zm i b { position: absolute; left: 0; right: 0; bottom: 0; height: 0; background: linear-gradient(to top, var(--haptic), var(--ww)); opacity: .85; }
.zm span { font: 500 9px/1 var(--mono); color: var(--faint); }
.zm div.me span { color: var(--ink); }
.zm div.me i { outline: 1px solid rgba(237, 230, 216, .5); }
.meta { margin: 8px 0 0; display: flex; justify-content: space-between; gap: 8px; font-size: 10.5px; color: var(--faint); }
.meta output { font: 400 10.5px/1 var(--mono); color: var(--muted); }

code { font-family: var(--mono); font-size: 11px; }

/* ---------- responsive ---------- */
@media (max-width: 1400px) and (min-width: 761px) {
  .fp-bar { bottom: calc(250px + env(safe-area-inset-bottom)); }
  .fp-cap { bottom: calc(330px + env(safe-area-inset-bottom)); }
}
@media (max-width: 1100px) {
  .top .arc { display: none; }
  .top { grid-template-columns: 1fr auto; }
}
@media (max-width: 760px) {
  body.watching #hint { display: none; }   /* the feed carries the story in Watch; the hint would sit on top of it */
  :root { --gutter: 14px; }
  .top { grid-template-columns: 1fr; gap: 8px; }
  .phase { font-size: 24px; }
  .phase-line { font-size: 13px; min-height: 0; }
  .eyebrow-sub { display: none; }
  .bottom { grid-template-columns: 1fr; gap: 8px; }
  .dock { display: grid; grid-template-columns: repeat(5, 1fr); gap: 2px; padding: 6px; }
  .dock-sep { display: none; }
  .dock .chip { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 6px 2px 5px; gap: 3px; min-height: 64px; min-width: 0; }
  .dock .chip svg { width: 34px; height: 34px; }
  .dock .chip br, .chip .st { display: none; }
  .dock .chip .nm { font-size: 12px; }
  .dock .chip kbd { display: none; }
  .hint { order: -1; font-size: 13.5px; margin: 0; }
  .floormap { display: none; }
  .feed { bottom: calc(140px + env(safe-area-inset-bottom)); }
  .inp { left: 8px; right: 8px; width: auto; bottom: calc(8px + env(safe-area-inset-bottom)); padding: 10px 12px 8px; }
  .inp .hw .si, #preview { display: none; }
  .inp .hw { font-size: 10.5px; margin: 6px 0; }
  .inp .row { grid-template-columns: 1fr 50px; gap: 10px; }
  #trace { height: 26px; }
  .card .status { font-size: 10.5px; }
  .card .status code { display: none; }
  .plat { left: 8px; right: 8px; width: auto; bottom: calc(196px + env(safe-area-inset-bottom)); padding: 8px 12px 6px; }
  .plat .meta { display: none; }
  #scope { height: 26px; margin: 4px 0; }
  .zm i { height: 12px; }
  .fp-bar { top: auto; bottom: calc(330px + env(safe-area-inset-bottom)); width: calc(100vw - 16px); flex-wrap: wrap; justify-content: center; gap: 6px; }
  .fp-where { flex-basis: 100%; text-align: center; font-size: 14px; }
  .fp-bar .pill { min-height: 32px; padding: 0 11px; font-size: 12px; }
  .fp-cap { bottom: calc(420px + env(safe-area-inset-bottom)); font-size: 17px; white-space: normal; text-align: center; width: calc(100vw - 32px); }
  body.fp .feed { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
.err.lost { background: #1a1210; border-color: #7a5236; color: var(--ink); line-height: 1.5; }
.err.lost b { font-weight: 600; }
.err.lost button { margin-left: 8px; padding: 4px 14px; border-radius: 99px; border: 0; background: #ffd9a8; color: #1a1006; font: inherit; font-weight: 600; cursor: pointer; }

/* settings panel: the scene box (#stage) is narrower than the window while the panel is open, so the size rules that
   used the viewport also follow the stage */
@container stage (max-width: 1400px) and (min-width: 761px) {
  .fp-bar { bottom: calc(250px + env(safe-area-inset-bottom)); }
  .fp-cap { bottom: calc(330px + env(safe-area-inset-bottom)); }
}
/* with the panel open the stage is narrower: give the hint its own row instead of a thin column between dock and floormap */
@container stage (max-width: 1300px) and (min-width: 761px) {
  .bottom { grid-template-columns: auto 1fr; }
  .hint { grid-column: 1 / -1; order: -1; margin: 0 0 4px; max-width: 60ch; }
  .floormap { justify-self: end; }
}
