/* Firelight — starlit dusk, lamplight, one living flame. No confetti, ever.
   Rebuilt 2026-08-18 from the approved overhaul plan. */

@font-face {
  font-family: "Kaisei HarunoUmi";
  font-style: normal; font-weight: 700; font-display: swap;
  src: url("/fonts/kaisei-700.woff2") format("woff2");
}
@font-face {
  font-family: "Kaisei HarunoUmi";
  font-style: normal; font-weight: 400; font-display: swap;
  src: url("/fonts/kaisei-400.woff2") format("woff2");
}

:root {
  /* ground */
  --night:       #171420;   /* dusk indigo-plum */
  --night-deep:  #100e18;
  --night-high:  #241f38;   /* top of the sky gradient */
  --card:        #221e30;
  --card-soft:   #2a2440;
  --card-edge:   #3a3352;
  /* ink */
  --ink:         #f2e9d8;   /* warm cream */
  --ink-dim:     #bfb2a0;
  /* Instruction tier keeps ≥4.5:1 on --night; the audience skews 40+.
     Decorative-only text may use --ink-ghost. */
  --ink-faint:   #9a9083;
  --ink-ghost:   #6b6357;
  /* light */
  --ember:       #f0a860;   /* lamplight amber — the one accent */
  --ember-hot:   #ffd9a0;
  --ember-deep:  #c96f42;   /* terracotta depth */
  --good:        #97b585;   /* moss — loved only */
  --danger:      #c97a6b;   /* clay — flagged only */
  /* legacy aliases (app.js and inline styles reference these) */
  --accent:      var(--ember);
  --accent-soft: var(--ember-deep);
  --bg:          var(--night);
  --bg-soft:     var(--night-deep);
  /* type */
  --display: "Kaisei HarunoUmi", Georgia, serif;
  --body: Georgia, "Times New Roman", serif;
  --ui: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  /* shape & rhythm (8px scale) */
  --radius: 16px;
  --radius-lg: 20px;
  --s1: 8px; --s2: 16px; --s3: 24px; --s4: 32px; --s5: 40px; --s6: 48px;
  --tabbar-h: 62px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  background: linear-gradient(180deg, var(--night-high) 0%, var(--night) 30%, var(--night) 75%, var(--night-deep) 100%) fixed var(--night);
  color: var(--ink);
  font: 17px/1.55 var(--body);
  overscroll-behavior: none;
}

/* ---- the sky (painted once by app.js; shown only on open-air screens) ---- */
#sky {
  position: fixed; inset: 0; width: 100%; height: 100%;
  z-index: 0; pointer-events: none;
  opacity: 0; transition: opacity 1.2s ease;
}
body.sky-on #sky { opacity: 1; }
.tw {
  position: fixed; border-radius: 50%; background: var(--ember-hot);
  pointer-events: none; z-index: 0; opacity: 0;
  animation: shimmer var(--d, 7s) ease-in-out infinite;
}
body:not(.sky-on) .tw { display: none; }
@keyframes shimmer { 0%, 100% { opacity: 0.1; } 50% { opacity: 0.65; } }

#app {
  position: relative; z-index: 1;
  max-width: 560px; margin: 0 auto; min-height: 100%;
  padding: calc(env(safe-area-inset-top, 0px) + 14px)
           calc(env(safe-area-inset-right, 0px) + 18px)
           calc(env(safe-area-inset-bottom, 0px) + 60px)
           calc(env(safe-area-inset-left, 0px) + 18px);
}
body.with-tabs #app { padding-bottom: calc(env(safe-area-inset-bottom, 0px) + var(--tabbar-h) + 28px); }

.screen { display: none; animation: fade 0.5s ease; }
.screen.active { display: block; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

h1 {
  font-family: var(--display); font-weight: 700;
  font-size: 1.85rem; line-height: 1.2; letter-spacing: 0.01em;
  text-wrap: balance;
}
h2 {
  font-family: var(--ui); font-size: 0.76rem; font-weight: 600;
  color: var(--ink-faint); text-transform: uppercase; letter-spacing: 0.14em;
  margin: var(--s3) 0 10px;
}
.dim { color: var(--ink-dim); }
.faint { color: var(--ink-faint); font-size: 0.85rem; }

button {
  font: 0.95rem/1.3 var(--ui); color: var(--ink);
  background: var(--card-soft);
  border: none; border-radius: var(--radius);
  padding: 12px 18px; min-height: 44px; cursor: pointer;
  transition: transform 0.12s ease, filter 0.12s ease, background 0.12s ease;
}
button:active { transform: scale(0.97); filter: brightness(1.18); }
button.primary {
  background: linear-gradient(180deg, var(--ember-hot), var(--ember));
  color: #2b1a0c; font-weight: 600;
  box-shadow: 0 2px 14px rgba(240, 168, 96, 0.22);
}
button.quiet { background: none; color: var(--ink-dim); padding: 11px 10px; }
button:disabled { opacity: 0.45; cursor: default; transform: none; filter: none; }

textarea, input[type="text"], input[type="password"] {
  font: inherit; width: 100%; color: var(--ink); background: rgba(16, 14, 24, 0.7);
  border: 1px solid var(--card-edge); border-radius: 12px; padding: 12px 14px;
  min-height: 44px;
}
textarea { min-height: 90px; resize: vertical; line-height: 1.5; }
textarea:focus, input:focus { outline: none; border-color: var(--accent-soft); }
button:focus-visible, a:focus-visible { outline: 2px solid var(--ember); outline-offset: 2px; }

/* ---- tab bar ---- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: none;
  justify-content: space-around; align-items: flex-start;
  padding: 8px 6px calc(env(safe-area-inset-bottom, 0px) + 6px);
  min-height: var(--tabbar-h);
  background: rgba(16, 14, 24, 0.82);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border-top: 1px solid rgba(58, 51, 82, 0.6);
}
body.with-tabs .tabbar { display: flex; }
.tabbar button {
  flex: 1; max-width: 120px; background: none; border-radius: 12px;
  padding: 4px 2px 6px; min-height: 44px;
  font-family: var(--ui); font-size: 0.68rem; letter-spacing: 0.04em;
  color: var(--ink-faint);
  display: flex; flex-direction: column; align-items: center; gap: 3px;
}
/* Drawn icons: one stroke weight, the label's own ink, lit with it. */
.tabbar button .t-ic { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; opacity: 0.85; }
.tabbar button .t-ic .knob { fill: var(--night-deep); }
.tabbar button.on { color: var(--ember-hot); }
.tabbar button.on .t-ic { opacity: 1; }
.tabbar button:active { transform: none; filter: none; background: rgba(240, 168, 96, 0.08); }

/* ---- home: the ask above, the loom below ---- */
.greet { font-family: var(--display); font-size: 1.05rem; color: var(--ink-faint); margin: var(--s1) 0 2px; }
.weather-row { display: flex; gap: var(--s1); margin: 14px 0 22px; flex-wrap: wrap; }
.chip {
  border: none; border-radius: 999px; padding: 8px 16px; min-height: 36px;
  background: rgba(242, 233, 216, 0.06); color: var(--ink-dim);
  font-family: var(--ui); font-size: 0.88rem;
}
.chip.on { color: var(--ember-hot); background: rgba(240, 168, 96, 0.14); }

/* The ask — the question gets the room (Su 08-29): the question, the flame
   under it, the pill under that. Day zero is the same shape, larger and alone. */
.ask { margin: 22px 0 6px; text-align: center; }
.ask-orb-wrap {
  display: flex; flex-direction: column; align-items: center; gap: 4px; cursor: pointer;
  background: none; border: none; border-radius: 0; padding: 0; margin: 0 auto 10px; min-height: 0; font: inherit; color: inherit;
}
.ask-orb-wrap:active { transform: none; filter: none; }
.ask-q { display: block; text-align: center; font-size: 1.85rem; margin: 6px 0 14px; }
.ask-cold-note { display: none; text-align: center; max-width: 34ch; margin: 0 auto 18px; font-size: 0.92rem; }
.ask.cold { margin-top: 42px; }
.ask.cold .ask-cold-note { display: block; }
.ask.cold .orb-ask { width: 132px; height: 132px; }
.ask-pill {
  display: flex; align-items: center; gap: 6px;
  background: rgba(16, 14, 24, 0.55); border: 1px solid var(--card-edge); border-radius: 999px;
  padding: 4px 4px 4px 6px; min-height: 52px;
}
/* The mic sits in the bar, next to typing (Su 2026-09-05) — same glyph as the composer's. */
.ask-mic {
  flex: 0 0 44px; width: 44px; height: 44px; min-height: 0; padding: 0; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; background: none; color: var(--ink-dim);
}
.ask-mic svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.ask-pill input[type="text"] {
  flex: 1; min-width: 0; background: none; border: none; border-radius: 0; padding: 8px 0; min-height: 40px;
  font-family: var(--display); font-size: 1.08rem; color: var(--ink);
}
.ask-pill input::placeholder { color: var(--ink-faint); font-style: italic; }
.ask-pill input:focus { border: none; }
.ask-go {
  width: 44px; height: 44px; min-height: 44px; padding: 0; border-radius: 50%; flex: none;
  background: linear-gradient(180deg, var(--ember-hot), var(--ember)); color: #2b1a0c;
  font-size: 1.1rem; font-weight: 700;
}
/* The guide's line — Firelight speaks first, about her. Tapping opens catch-up. */
.guide {
  display: block; width: 100%; text-align: left; margin: 18px 0 0;
  background: none; border: none; border-radius: 0; padding: 4px 0; min-height: 0;
  font-family: var(--display); font-weight: 400; font-size: 1.02rem; line-height: 1.5; color: var(--ember-hot);
}
.guide::after { content: "\00a0→"; color: var(--ember); white-space: nowrap; }
.guide:active { transform: none; filter: none; }
/* The offered move, answered on home (UX sweep 2026-09-05): the line asks, the chips under it answer. */
.guide.static { cursor: default; }
.guide.static::after { content: none; }
.guide-actions { justify-content: flex-start; margin: 8px 0 0; }

/* Sideways rows under the question (Su 08-29): picks, then listen again. */
.row-label {
  font-family: var(--ui); font-size: 0.7rem; font-weight: 600; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--ink-faint); margin: 24px 0 8px;
}
.pick-row, .shelf {
  display: flex; gap: 8px; flex-wrap: nowrap; margin: 0 -18px; padding: 2px 18px 6px;
  overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.pick-row::-webkit-scrollbar, .shelf::-webkit-scrollbar { display: none; }
.pick-row .chip { font-family: var(--body); font-size: 0.92rem; color: var(--ink-dim); white-space: nowrap; flex: none; padding: 9px 16px; min-height: 44px; }
.shelf { gap: 10px; }
.shelfcard {
  flex: 0 0 168px; display: flex; flex-direction: column; gap: 4px; text-align: left;
  background: linear-gradient(165deg, var(--card-soft), var(--card));
  border: 1px solid rgba(58, 51, 82, 0.9); border-radius: var(--radius-lg);
  padding: 14px 14px 12px; min-height: 122px; color: var(--ink); font-family: var(--body);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.22);
}
.shelfcard.hero {
  background: linear-gradient(160deg, #302848, var(--card));
  border-color: rgba(240, 168, 96, 0.28);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(240, 168, 96, 0.06), inset 0 1px 0 rgba(255, 217, 160, 0.08);
}
.shelfcard .eyebrow {
  font-family: var(--ui); font-size: 0.64rem; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--ember); min-height: 0.9em;
}
.shelfcard .ttl { font-family: var(--display); font-size: 1.02rem; line-height: 1.25; }
.shelfcard .holds { font-size: 0.82rem; color: var(--ink-dim); line-height: 1.4; font-style: italic; flex: 1; }
.shelfcard .meta { font-size: 0.74rem; color: var(--ink-faint); line-height: 1.4; margin-top: 4px; }
.shelfcard.all { justify-content: center; align-items: center; text-align: center; color: var(--ink-dim); font-size: 0.92rem; background: none; border-style: dashed; box-shadow: none; }

/* The track to return to (Su 2026-09-05): one card, full width, a real listen button. */
.hero-card {
  position: relative; display: flex; flex-direction: column; gap: 6px; text-align: left;
  margin: 12px 0 0; padding: 18px 18px 16px; min-height: 190px; cursor: pointer;
  background: linear-gradient(160deg, #302848, var(--card));
  border: 1px solid rgba(240, 168, 96, 0.28); border-radius: var(--radius-lg);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 217, 160, 0.08);
  color: var(--ink); font-family: var(--body); -webkit-tap-highlight-color: transparent;
}
.hero-card:focus-visible { outline: 2px solid var(--ember); outline-offset: 2px; }
.hero-card.pic { background-size: cover; background-position: center; border-color: rgba(58, 51, 82, 0.7); }
.hero-card.pic::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit;
  background: linear-gradient(180deg, rgba(16, 14, 24, 0.12) 0%, rgba(16, 14, 24, 0.5) 42%, rgba(16, 14, 24, 0.9) 78%, rgba(16, 14, 24, 0.95) 100%);
}
.hero-card > * { position: relative; }
.hero-card.pic > * { text-shadow: 0 1px 6px rgba(0, 0, 0, 0.55); }
.hero-card .eyebrow { font-family: var(--ui); font-size: 0.66rem; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ember); min-height: 0.9em; }
.hero-card .ttl { font-family: var(--display); font-size: 1.5rem; line-height: 1.15; text-wrap: balance; }
.hero-card .holds { font-size: 0.95rem; color: var(--ink-dim); font-style: italic; line-height: 1.45; }
.hero-card.pic .holds { color: var(--ink); opacity: 0.88; }
.hero-card .meta { font-size: 0.78rem; color: var(--ink-faint); }
.hero-card .hero-actions { display: flex; gap: 10px; align-items: center; margin-top: 10px; text-shadow: none; }
.hero-card .hero-actions .primary { padding: 12px 22px; }
.hero-card .hero-actions .primary .ic { width: 15px; height: 15px; margin-right: 7px; vertical-align: -2px; }
.hero-card .hero-actions .quiet { color: var(--ink-dim); }
/* Under her tracks the question is quieter; on day zero it is the whole screen. */
.ask:not(.cold) { margin: 34px 0 4px; }
.ask:not(.cold) .ask-q { font-size: 1.35rem; margin: 4px 0 8px; }
.ask:not(.cold) .ask-orb-wrap { margin-bottom: 6px; }

.more-ways { margin-top: var(--s2); width: 100%; text-align: center; }

/* legacy sheet block (kept for anything still inside panels) */
.sheet { margin-top: 12px; }
.type-row { display: flex; gap: var(--s1); flex-wrap: wrap; margin: 10px 0; }

.tile-row { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 6px; }
.tile {
  min-width: 150px; text-align: left; background: var(--card);
  border: 1px solid var(--card-edge); border-radius: var(--radius); padding: 12px 14px;
}
.tile .t-title { font-size: 0.98rem; font-family: var(--body); }
.tile .t-sub { color: var(--ink-faint); font-size: 0.78rem; margin-top: 4px; }
.tile.keystone { border-color: var(--accent-soft); }

/* The move she kept — one quiet line above the loom, never a card that nags. */
.move-chip {
  margin: 16px 0 0; padding: 10px 12px; border-radius: var(--radius);
  background: rgba(42, 36, 64, 0.45); border: 1px dashed var(--card-edge);
  color: var(--ink-dim); font-size: 0.88rem; line-height: 1.45;
}
.move-chip .chip { min-height: 32px; padding: 6px 12px; font-size: 0.8rem; }

/* ---- bottom sheets (replace the <details> disclosures) ---- */
.sheet-overlay {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(10, 8, 16, 0.6);
  animation: fade 0.25s ease;
}
.sheet-panel {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 61;
  max-width: 560px; margin: 0 auto;
  background: var(--card);
  border: 1px solid var(--card-edge); border-bottom: none;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 10px 20px calc(env(safe-area-inset-bottom, 0px) + 20px);
  animation: rise 0.3s ease;
  max-height: 80vh; overflow-y: auto;
}
@keyframes rise { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet-grip {
  width: 40px; height: 4px; border-radius: 2px;
  background: var(--card-edge); margin: 0 auto 14px;
}
.sheet-panel h3 {
  font-family: var(--display); font-weight: 700; font-size: 1.15rem;
  margin-bottom: 10px;
}
.sheet-panel textarea { margin: 8px 0; min-height: 64px; }

/* ---- review ---- */
.beat {
  background: var(--card); border: 1px solid var(--card-edge); border-radius: 14px;
  padding: 12px 14px; margin: 10px 0; position: relative;
}
.beat.flagged { border-color: var(--danger); }
.beat.loved { border-color: var(--good); }
.beat .pause-note { color: var(--ink-faint); font-size: 0.75rem; margin-top: 6px; }
.beat .flagbtn { position: absolute; top: 8px; right: 8px; }
/* Room for the flag: the words never run under it (UX sweep 2026-09-05). */
.beat .beat-text, .beat textarea { padding-right: 34px; }
.beat textarea { margin-top: 6px; }
.flag-menu { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.flag-menu button { font-size: 0.8rem; padding: 8px 12px; min-height: 36px; border-radius: 999px; }
.review-actions { position: sticky; bottom: 0; background: linear-gradient(transparent, var(--night) 30%); padding: 18px 0 8px; display: flex; gap: 10px; }
.review-actions button { flex: 1; }

/* ---- player ---- */
#player-screen { text-align: center; }
#player-screen .topbar, #player-screen h1, #player-screen .seg-progress,
#player-screen .faint, #player-screen .player-controls { transition: opacity 0.4s ease; }
#player-screen.dimmed .topbar, #player-screen.dimmed h1, #player-screen.dimmed .seg-progress,
#player-screen.dimmed .faint, #player-screen.dimmed .player-controls { opacity: 0.08; transition: opacity 2.5s ease; }
#player-screen.dimmed .orb { opacity: 0.85; }

/* ---- the orb: a flame, not a sphere. A soft-edged tongue of light, brightest
   low in its core and thinning upward into the dark; a wide, faint halo around
   it. No concentric rings, no highlight dot — light with no edge, never an object. ---- */
.orb-wrap { display: flex; justify-content: center; margin: 56px 0 40px; }
/* The orbs and the mic are real buttons now (2026-08-29) — named for a screen
   reader, reachable by keyboard — so the button chrome is stripped back off. */
.orb, .mic { border: none; padding: 0; font: inherit; min-height: 0; display: block; }
.orb:active { transform: none; filter: none; }
.orb {
  --flame-blur: 10px;
  width: 168px; height: 168px; border-radius: 50%; position: relative;
  background: none;
  animation: breathe 9s ease-in-out infinite;
  cursor: pointer;
  transition: opacity 0.6s ease, filter 0.6s ease;
}
.orb:focus-visible { outline: 2px solid var(--ember); outline-offset: 6px; }
.orb::before {
  /* the halo */
  content: ""; position: absolute; inset: -22%; border-radius: 50%;
  /* closest-side: the glow reaches nothing before its own circle clips it — no visible rim */
  background: radial-gradient(circle closest-side at 50% 56%, rgba(240, 168, 96, 0.28) 0%, rgba(240, 168, 96, 0.09) 45%, rgba(240, 168, 96, 0) 92%);
}
.orb::after {
  /* the flame body: a teardrop, narrow at the tip, blurred past any edge */
  content: ""; position: absolute; left: 29%; right: 29%; top: 8%; bottom: 18%;
  border-radius: 50% 50% 50% 50% / 74% 74% 26% 26%;
  background: linear-gradient(180deg,
    rgba(201, 111, 66, 0) 0%, rgba(224, 136, 80, 0.42) 26%,
    rgba(246, 180, 110, 0.86) 58%, rgba(255, 232, 190, 0.98) 86%, rgba(255, 244, 222, 1) 100%);
  filter: blur(var(--flame-blur));
  transform-origin: 50% 90%;
  animation: flicker 6s ease-in-out infinite alternate;
}
/* flame.js draws the living flame on a canvas inside the orb; the CSS teardrop
   underneath is the fallback and hides once the canvas is live. */
.orb canvas.flame { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.orb.live::after { display: none; }
.orb-ask { --flame-blur: 2.5px; width: 54px; height: 54px; margin: 0; animation-duration: 7s; }
.orb-ask::before { inset: -16%; opacity: 0.7; }
.orb-ask::after { left: 29%; right: 29%; top: 10%; bottom: 16%; }
@keyframes breathe {
  0%, 100% { transform: scale(0.94); }
  45%, 60% { transform: scale(1.04); }
}
@keyframes flicker {
  0%   { transform: scaleY(0.97) skewX(-1.5deg); opacity: 0.86; }
  35%  { transform: scaleY(1.03) skewX(1deg); opacity: 1; }
  70%  { transform: scaleY(0.99) skewX(-0.5deg); opacity: 0.93; }
  100% { transform: scaleY(1.04) skewX(1.5deg); opacity: 1; }
}
.orb.paused { animation-play-state: paused; opacity: 0.55; }
.orb.paused::after { animation-play-state: paused; }
.orb.muted { animation-play-state: paused; opacity: 0.3; }
.orb.muted::after { animation-play-state: paused; }
.orb.listening {
  animation: none; transform: scale(1.02);
  filter: hue-rotate(-28deg) saturate(1.05);
}
.orb.listening::after { animation-duration: 2.6s; }

.seg-progress { display: flex; gap: 2px; margin: 30px 0 10px; height: 4px; }
.seg-progress i { flex: 1; background: var(--card-edge); border-radius: 2px; }
.seg-progress i.done { background: var(--accent-soft); }
.seg-progress i.now { background: var(--accent); }
.player-controls { display: flex; justify-content: center; gap: 14px; margin-top: 30px; }

/* ---- turn ---- */
#turn-screen { text-align: center; }
.cv-promise { max-width: 42ch; margin: 0 auto 6px; text-align: center; line-height: 1.5; }
.mic {
  width: 92px; height: 92px; border-radius: 50%; margin: 40px auto 10px;
  background: radial-gradient(circle at 50% 42%, var(--card-soft), var(--card));
  border: 1px solid var(--accent-soft);
  display: flex; align-items: center; justify-content: center; font-size: 2rem;
  cursor: pointer; color: var(--ember);
}
.mic svg { width: 36px; height: 36px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.mic.rec { background: rgba(201, 122, 107, 0.18); border-color: var(--danger); animation: pulse 1.6s infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(201, 122, 107, 0.3); } 50% { box-shadow: 0 0 0 18px rgba(201, 122, 107, 0); } }

/* ---- release ---- */
#release-screen { text-align: center; padding-top: 90px; }
#release-screen p { color: var(--ink-dim); max-width: 40ch; margin: 16px auto; }

/* ---- memory (threads) ---- */
.mem-tabs { display: flex; gap: 6px; overflow-x: auto; margin: 12px 0; }
.mem-tabs button { font-size: 0.8rem; padding: 10px 14px; min-height: 44px; white-space: nowrap; }
.mem-tabs button.on { color: var(--ember-hot); background: rgba(240, 168, 96, 0.14); }
#mem-text { min-height: 50vh; font-family: ui-monospace, Menlo, monospace; font-size: 0.85rem; }
#mem-rendered { min-height: 30vh; padding: 4px 2px; }
#mem-rendered p { margin: 10px 0; font-size: 0.98rem; }
#mem-rendered h2 { margin: 22px 0 8px; }
#mem-rendered .mem-li { margin: 6px 0 6px 8px; color: var(--ink-dim); }
#mem-rendered .mem-note { color: var(--ink-faint); font-size: 0.88rem; font-style: italic; }
/* At a glance — one page in the app's hand above the eight detailed ones.
   Each card is the gist of one page; tapping it opens that page to edit. */
.glance { display: grid; gap: 10px; margin-top: 4px; }
.glance-card {
  display: block; width: 100%; text-align: left;
  background: var(--card); border: 1px solid var(--card-edge); border-radius: 14px;
  padding: 12px 14px; color: var(--ink); font-family: var(--body); min-height: 0;
}
.glance-card:active { transform: none; filter: brightness(1.08); }
.glance-card .g-k { font-family: var(--ui); font-size: 0.66rem; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ember); }
.glance-card .g-k::after { content: "\00a0→"; color: var(--ink-ghost); letter-spacing: 0; }
.glance-card .g-v { font-size: 0.95rem; line-height: 1.45; color: var(--ink); margin-top: 4px; }
.glance-card .g-v.empty { color: var(--ink-faint); font-style: italic; }
.glance-card .g-v .g-more { color: var(--ink-faint); font-size: 0.82rem; }

/* ---- library (tracks) ---- */
.lib-row {
  display: flex; align-items: center; gap: 6px;
  background: var(--card); border: 1px solid var(--card-edge); border-radius: 14px;
  padding: 12px 6px 12px 14px; margin: 10px 0;
}
.lib-row.keystone { border-color: var(--accent-soft); }
.lib-row .lib-main { flex: 1; cursor: pointer; font-family: var(--body); }
.lib-row .t-holds { color: var(--ink-dim); font-size: 0.86rem; font-style: italic; margin-top: 2px; line-height: 1.4; }

/* ---- conversation ---- */
.bubble { max-width: 88%; padding: 10px 14px; border-radius: 16px; margin: 8px 0; line-height: 1.5; }
.bubble.app { background: var(--card); border: 1px solid var(--card-edge); }
.bubble.me { background: rgba(240, 168, 96, 0.1); border: 1px solid rgba(240, 168, 96, 0.3); margin-left: auto; }
.bubble.thinking { color: var(--ink-faint); }

/* voice conversation: the orb listens, speaks, and breathes */
.cv-orb { width: 128px; height: 128px; }
.cv-orb.thinking { animation-duration: 3.5s; opacity: 0.7; }
.cv-caption {
  min-height: 3.2em; max-width: 42ch; margin: 0 auto;
  color: var(--ink-dim); font-size: 1.02rem; line-height: 1.6;
  transition: opacity 0.6s ease;
}
#cv-log .bubble { font-size: 0.88rem; opacity: 0.75; }

.topbar {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: var(--s1); min-height: 44px;
}
/* Drawn icons in controls (2026-09-05): one stroke weight, the label's own ink —
   no text glyphs (↑ ‹ ⚑ ★ ⋯ ◌) standing in for buttons. */
.ic { width: 1.05em; height: 1.05em; vertical-align: -0.18em; display: inline-block; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.ic.solid { fill: currentColor; stroke: none; }
.ic.star.on { fill: currentColor; }
.ask-go .ic, .composer-send .ic { width: 20px; height: 20px; vertical-align: 0; stroke-width: 2.3; }
.spin.ic { width: 1em; height: 1em; }
.spin { display: inline-block; animation: spin 1.2s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.note { margin: 14px 0; color: var(--ink-dim); font-size: 0.92rem; }
.err { color: var(--danger); }

/* ---- the threshold (2026-09-04): one beat at a time, under the sky ---- */
.threshold { max-width: 36ch; margin: 6vh auto 0; text-align: center; animation: fade 0.5s ease; }
.threshold .th-icon { width: 64px; height: 64px; border-radius: 18px; margin: 0 auto 18px; display: block; }
.threshold h1 { font-size: 1.6rem; margin-bottom: 14px; }
.threshold p { color: var(--ink-dim); font-size: 0.98rem; line-height: 1.55; margin: 0 0 12px; }
.threshold p.faint { font-size: 0.85rem; color: var(--ink-faint); }
.th-places { list-style: none; text-align: left; margin: 18px auto 6px; max-width: 30ch; }
.th-places li { display: flex; gap: 12px; align-items: flex-start; padding: 7px 0; color: var(--ink-dim); font-size: 0.95rem; line-height: 1.45; }
.th-places .t-ic { width: 22px; height: 22px; flex: none; margin-top: 2px; fill: none; stroke: var(--ember-hot); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.th-places .t-ic .knob { fill: var(--night); }
.th-places b { color: var(--ink); font-weight: 400; font-family: var(--display); }
.th-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 18px; }
.th-actions button.primary { width: 100%; }
.th-verdict { min-height: 1.4em; margin-top: 14px; }
.th-dots { display: flex; justify-content: center; gap: 8px; margin-top: 22px; }
.th-dots span { width: 5px; height: 5px; border-radius: 50%; background: var(--ink-ghost); }
.th-dots span.on { background: var(--ember); }

/* ---- in-world dialog (replaces every native alert/prompt/confirm) ---- */
.dlg-overlay {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(10, 8, 16, 0.72);
  display: flex; align-items: center; justify-content: center; padding: 24px;
  animation: fade 0.25s ease;
}
.dlg {
  width: 100%; max-width: 400px;
  background: var(--card); border: 1px solid var(--card-edge); border-radius: var(--radius-lg);
  padding: 22px 20px 18px;
}
.dlg h3 { font-family: var(--display); font-weight: 700; font-size: 1.1rem; margin-bottom: 8px; }
.dlg .dlg-body { color: var(--ink-dim); font-size: 0.95rem; margin-bottom: 4px; white-space: pre-line; }
.dlg input { margin-top: 10px; }
.dlg .dlg-buttons { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.dlg .dlg-buttons button { flex: 1; min-width: 40%; }
.dlg .dlg-buttons button.danger { border: 1px solid var(--danger); color: var(--danger); background: none; }

@media (prefers-reduced-motion: reduce) {
  .orb, .orb::after, .tw, .spin { animation: none !important; }
  .tw { opacity: 0.4; }
}

/* ---- the loop (2026-08-30): the offered move and her cue, on the release screen ---- */
.loop { margin: 26px auto 0; max-width: 42ch; }
.loop-block { margin-top: 18px; }
.loop-line { color: var(--ink-dim); font-size: 0.95rem; line-height: 1.5; margin: 0; }
.loop-line em { color: var(--ink); font-style: italic; }
.loop-row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 10px; }
.loop-note { color: var(--ink-faint); font-size: 0.8rem; margin: 8px 0 0; }
.shelfcard .meta .cue { color: var(--ember); }

/* The card's small "read" (2026-08-30): opens the words, not the player. The
   card itself is a div now (a button can't hold a button), so it draws its
   own pointer and focus ring. */
.shelfcard { position: relative; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.shelfcard:focus-visible { outline: 2px solid var(--ember); outline-offset: 2px; }
.shelfcard .readbtn {
  position: absolute; right: 8px; top: 8px; min-height: 0; padding: 5px 9px;
  font-size: 0.7rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-faint);
  border: 1px solid var(--card-edge); border-radius: 999px;
}
.shelfcard .readbtn:active { color: var(--ink); }
/* The pill stays small on the card; the tap area under it does not. */
.shelfcard .readbtn::before { content: ""; position: absolute; inset: -9px; }
.lib-row .lib-read { font-size: 0.78rem; padding: 10px 8px; }

/* THE COMPOSER (typing, 2026-08-30) — pinned to the bottom like a messaging
   app: mic dictates into the box, ↑ sends, "speak instead" one tap above. */
.composer {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  padding: 4px calc(env(safe-area-inset-right, 0px) + 12px) calc(env(safe-area-inset-bottom, 0px) + 10px) calc(env(safe-area-inset-left, 0px) + 12px);
  background: linear-gradient(to top, var(--night-deep) 72%, rgba(16, 14, 24, 0));
}
.composer-tools { display: flex; justify-content: center; gap: 2px; }
.composer-tools button.quiet { font-size: 0.78rem; padding: 6px 10px; min-height: 0; color: var(--ink-faint); }
.composer-bar {
  display: flex; align-items: flex-end; gap: 6px;
  background: rgba(34, 30, 48, 0.96); border: 1px solid var(--card-edge); border-radius: 26px;
  padding: 5px 5px 5px 4px; box-shadow: 0 -6px 28px rgba(0, 0, 0, 0.35);
}
.composer-bar textarea {
  flex: 1; min-height: 40px; max-height: 132px; height: 40px; resize: none;
  background: none; border: none; border-radius: 0; padding: 10px 4px; line-height: 1.4; font-size: 1rem;
}
.composer-bar textarea:focus { border: none; }
.composer-mic, .composer-send {
  flex: 0 0 44px; width: 44px; height: 44px; min-height: 0; padding: 0; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.composer-mic { background: none; color: var(--ink-dim); }
.composer-mic svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.composer-mic.listening { color: var(--night-deep); background: var(--ember); animation: micpulse 1.3s ease-in-out infinite; }
.composer-mic.busy { color: var(--ember); }
.composer-send { background: var(--ember); color: var(--night-deep); font-size: 1.25rem; font-weight: 700; line-height: 1; }
@keyframes micpulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(240, 168, 96, 0.55); }
  50% { box-shadow: 0 0 0 10px rgba(240, 168, 96, 0); }
}
/* Room beneath the log while the composer is up, so the last bubble stays readable. */
body.composer-on #app { padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 150px); }

/* CARD PICTURES (2026-08-30): the visual anchor. A picture sits behind the
   card under a dark wash so the words stay readable; without one the card
   keeps its gradient. */
.shelfcard.pic { background-size: cover; background-position: center; border-color: rgba(58, 51, 82, 0.6); }
.shelfcard.pic::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit;
  background: linear-gradient(180deg, rgba(16, 14, 24, 0.12) 0%, rgba(16, 14, 24, 0.46) 42%, rgba(16, 14, 24, 0.86) 78%, rgba(16, 14, 24, 0.94) 100%);
}
.shelfcard.pic > :not(.readbtn) { position: relative; text-shadow: 0 1px 6px rgba(0, 0, 0, 0.55); }
.shelfcard.pic { min-height: 150px; }
.shelfcard.pic .ttl { margin-top: 14px; }
.shelfcard.pic .holds { color: var(--ink); opacity: 0.85; }
.lib-row .lib-thumb {
  flex: 0 0 44px; width: 44px; height: 44px; border-radius: 10px; object-fit: cover;
  background: var(--card-soft); margin-right: 4px;
}
.rv-picture { margin: 14px 0 0; }
.rv-picture img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 14px; display: block; background: var(--card-soft); }
.rv-picture .rv-credit { font-size: 0.72rem; color: var(--ink-faint); margin: 6px 2px 0; }
.rv-picture .rv-credit a { color: inherit; }
.rv-picture .type-row { margin: 8px 0 0; justify-content: center; }
.rv-picture .empty {
  border: 1px dashed var(--card-edge); border-radius: 14px; padding: 16px; text-align: center;
  color: var(--ink-faint); font-size: 0.88rem;
}
.shelfcard.pic .readbtn { background: rgba(16, 14, 24, 0.55); color: var(--ink-dim); }
.shelfcard.pic .eyebrow { text-shadow: 0 1px 6px rgba(0, 0, 0, 0.7); }

/* the crisis exit (2026-09-06): the number is the whole point — big, tappable, calm */
.crisis-card { margin: 14px 0 6px; padding: 16px 18px; border-radius: 16px; background: var(--card); border: 1px solid var(--card-edge); text-align: center; }
.crisis-card p { margin: 6px 0 0; }
.crisis-where { color: var(--ink-dim); font-size: 0.85rem; margin: 0 0 4px !important; }
.crisis-line { display: block; color: var(--ink); text-decoration: none; padding: 6px 0; }
.crisis-line .crisis-name { display: block; font-size: 0.95rem; color: var(--ink-dim); }
.crisis-line .crisis-number { display: block; font-size: 1.9rem; letter-spacing: 0.04em; margin-top: 2px; }
.crisis-emergency { color: var(--ink); font-size: 0.95rem; margin-top: 12px !important; }
.crisis-emergency a, .crisis-card .faint a { color: inherit; }

/* Quiet night garden — immersive journey, September 2026. */
:root {
  --night: #101c24; --night-deep: #0b141c; --night-high: #192c35;
  --card: #192a32; --card-soft: #21343c; --card-edge: #35464b;
  --ink: #eee9dd; --ink-dim: #c1c6bd; --ink-faint: #a5b3b2;
  --ember: #c9ba94; --ember-hot: #e5d8b8; --ember-deep: #8c987e;
}
body { background: radial-gradient(ellipse at 50% 30%, #243d4238, transparent 62%), linear-gradient(180deg, var(--night-high), var(--night) 50%, var(--night-deep)) fixed; }
#app { max-width: 760px; }
button, input, select, textarea { font-family: var(--ui); }
button { min-height: 44px; }
button.primary { background: #d9d4bc; color: #18282c; border-color: #d9d4bc; box-shadow: none; }
button:focus-visible, summary:focus-visible, select:focus-visible { outline: 2px solid var(--ember-hot); outline-offset: 5px; }
.arrival-header { display: flex; justify-content: space-between; align-items: center; width: 100%; }
.wordmark { font: 1.2rem var(--display); letter-spacing: .1em; }
#home-screen.active { display: flex; flex-direction: column; align-items: center; min-height: calc(100svh - 100px); }
#home-screen .arrival-header { order: 0; }
#home-screen .greet { order: 1; font: .74rem var(--ui); letter-spacing: .13em; margin-top: 18px; }
#home-note { order: 2; text-align: center; max-width: 40ch; }
#home-note:empty { display: none; }
#home-screen .ask, #home-screen .ask.cold, #home-screen .ask:not(.cold) { order: 3; margin: clamp(50px, 12vh, 120px) 0 36px; width: 100%; }
#home-screen .ask .ask-q { font-size: clamp(2rem, 5.5vw, 3.15rem); font-weight: 400; line-height: 1.35; letter-spacing: -.045em; max-width: 15ch; margin: 0 auto 24px; text-wrap: balance; }
#home-screen .ask-orb-wrap { display: none; }
.ask-pill { max-width: 510px; margin: 34px auto 0; min-height: 62px; border: 1px solid #61777566; background: #ffffff04; box-shadow: 0 12px 50px #050c101a; }
.ask-pill:focus-within { border-color: var(--ember); }
.ask-pill input[type="text"] { font: .9rem var(--ui); }
.ask-pill input::placeholder { font-style: normal; }
.ask-cold-note { font: .82rem/1.7 var(--ui); }
#home-screen #hero { order: 4; width: 100%; }
.return-invitation { text-align: center; padding: 22px 0; max-width: 470px; margin: auto; border-top: 1px solid #a5b3b225; }
.eyebrow { display: block; font: .65rem/1.7 var(--ui); letter-spacing: .14em; color: var(--ink-faint); }
.return-invitation h2 { font: 1.13rem/1.6 var(--display); margin: 8px 0 3px; }
.return-invitation p { font: .72rem/1.6 var(--ui); }
.return-invitation button { font-size: .8rem; margin-top: 8px; }
.arrival-links { order: 5; display: flex; align-items: center; gap: 8px; margin-top: auto; padding: 22px 0 12px; color: var(--ink-faint); }
.arrival-links button { font-size: .78rem; }
#home-screen #invites-sheet { order: 6; }
body:has(#home-screen.active) .tabbar { display: none; }
body.with-tabs:has(#home-screen.active) #app { padding-bottom: max(22px, env(safe-area-inset-bottom)); }
.tabbar { background: #0b141cee; border-top-color: #a5b3b225; }
.cv-promise { max-width: 43ch; margin: 26px auto 36px; text-align: center; font-size: .85rem; }
#cv-log { padding: 12px 0 24px; }
#cv-log .bubble { font-size: 1rem; opacity: 1; line-height: 1.8; margin: 24px 0; }
#cv-log .bubble.app { background: transparent; border: none; padding: 6px 0; max-width: 92%; }
#cv-log .bubble.me { background: #adc5be0b; border: 1px solid #adc5be22; margin-left: auto; padding: 14px 20px; }
.composer { background: linear-gradient(transparent, var(--night-deep) 25%); }
.composer-bar { background: #192a32; border-color: #526867; }
.mode-choice, .experience-mode { display: block; color: var(--ink-dim); font: .77rem/1.7 var(--ui); text-align: center; margin: 14px auto 24px; }
.mode-choice { border: 1px solid #a5b3b240; background: #a5b3b208; border-radius: 30px; padding: 10px 18px; }
#review-screen.active { display: flex; flex-direction: column; }
#review-screen .topbar { order: 0; }
#rv-title { order: 1; text-align: center; margin-top: 32px; font-weight: 400; }
#rv-meta { order: 2; text-align: center; font-size: .85rem; }
#rv-mode { order: 3; }
#rv-picture { order: 4; margin: 8px 0 28px; }
.rv-picture img { aspect-ratio: 16/10; border-radius: 80px 80px 12px 12px; }
.rv-picture .type-row { opacity: .8; }
#rv-actions { order: 5; width: min(100%, 490px); align-self: center; }
#rv-step { text-align: center; margin-bottom: 20px; }
#rv-hint { display: none; }
.sound-door { order: 6; align-self: center; margin: 14px 0; }
#read-view { order: 7; }
#transcript-wrap { order: 8; }
#player-screen { position: relative; isolation: isolate; min-height: calc(100svh - 70px); }
#player-screen::before { content: ''; position: absolute; z-index: -1; inset: 65px -16px 80px; background: linear-gradient(var(--night) 0%, transparent 28%, #101c2444 65%, var(--night)), var(--scene-image, none) center / cover; opacity: .36; border-radius: 100px 100px 20px 20px; pointer-events: none; }
#player-screen h1 { padding-top: 34px; font-size: clamp(1.6rem, 5vw, 2.4rem); font-weight: 400; }
#player-screen .orb-wrap { margin: clamp(50px, 14vh, 120px) 0 60px; }
#player-screen .player-controls { display: flex; justify-content: center; align-items: center; gap: 16px; }
#player-screen:focus-within .player-controls { opacity: 1; }
#player-screen .orb { filter: saturate(.45); }
.sound-control { display: flex; justify-content: space-between; align-items: center; gap: 22px; margin: 24px 0; font: .86rem var(--ui); }
.sound-control input[type=range] { width: 48%; min-height: 44px; accent-color: var(--ember-hot); }
.sound-control select { max-width: 55%; min-height: 44px; background: var(--card); color: var(--ink); border: 1px solid var(--card-edge); padding: 8px; border-radius: 8px; }
#sound-panel { max-height: 85svh; overflow-y: auto; }
#explore-screen { max-width: 590px; margin: auto; }
#explore-screen h1 { font-weight: 400; margin: 14px 0 24px; }
.explore-intro { color: var(--ink-dim); font-size: 1.2rem; line-height: 1.8; margin-bottom: 40px; }
.guide-essay { border-top: 1px solid var(--card-edge); padding: 8px 0; }
.guide-essay summary { padding: 18px 2px; cursor: pointer; }
.guide-essay p { font-size: .96rem; line-height: 1.85; color: var(--ink-dim); margin: 4px 0 24px; }
#explore-screen > .primary { margin-top: 32px; }
.lib-row { padding-top: 22px; padding-bottom: 22px; }
.lib-read { font-size: .73rem; }
@media (max-width: 420px) {
  #home-screen .ask, #home-screen .ask.cold, #home-screen .ask:not(.cold) { margin-top: 55px; }
  .arrival-links { gap: 0; }
  .sound-control { gap: 10px; }
  .lib-row { flex-wrap: wrap; }
  .lib-main { min-width: 50%; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
#progress-screen { max-width: 560px; margin: auto; }
#progress-screen h1 { font-weight: 400; margin: 18px 0; }
#progress-form label { display: block; font: .8rem/1.8 var(--ui); margin: 18px 0; color: var(--ink-dim); }
#progress-form input, #progress-form textarea, #progress-form select { display: block; width: 100%; margin-top: 8px; padding: 12px; color: var(--ink); background: var(--card); border: 1px solid var(--card-edge); border-radius: 10px; min-height: 44px; color-scheme: dark; }
.progress-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.progress-pair input { min-width: 0; }
.progress-event { border-top: 1px solid var(--card-edge); padding: 20px 0; }
.progress-event p { margin-top: 8px; }
.intention-link { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; width: 100%; text-align: left; margin: 22px 0; padding: 22px; background: #adc5be08; border: 1px solid #adc5be33; }
.intention-link .faint { font-size: .75rem; }
