/* Bio-Tapp Companion — styles
   Warm clinic: cream paper, sage, terracotta accent, deep ink. Fraunces for the
   spoken phrases (they should feel like words, not UI), Inter for everything else. */

:root {
  --paper: #f6f1e7;
  --paper-2: #efe7d8;
  --card: #fffdf8;
  --ink: #1f2a24;
  --ink-2: #4b5a51;
  --ink-3: #7c8a82;
  --line: #e2d9c8;
  --sage: #6f8f74;
  --sage-2: #587a5e;
  --sage-soft: #dfe8df;
  --terra: #c8694a;
  --terra-soft: #f3d9cf;
  --gold: #d9a441;
  --tee: #7a9b7e;
  --tee-line: #62815f;
  --glow: #fff8ea;
  --shadow: 0 10px 30px rgba(31, 42, 36, .10), 0 1px 2px rgba(31, 42, 36, .06);
  --r: 18px;
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --serif: 'Fraunces', 'Iowan Old Style', Georgia, serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #1c2320; --paper-2: #232c28; --card: #26302b; --ink: #eef0ea; --ink-2: #c6cdc4; --ink-3: #8f9b92;
    --line: #37423c; --sage: #8fb193; --sage-2: #a6c4a8; --sage-soft: #2d3a32; --terra: #e0866a; --terra-soft: #4a3028;
    --tee: #5f7d63; --tee-line: #4b6650; --glow: #2c3a32; --shadow: 0 10px 30px rgba(0,0,0,.35);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow-x: hidden; }
body {
  font-family: var(--font); color: var(--ink); background: var(--paper);
  -webkit-font-smoothing: antialiased; line-height: 1.45; overscroll-behavior: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--sage-2); }
h2 { font-family: var(--serif); font-weight: 500; font-size: 1.6rem; margin: 0 0 .6rem; letter-spacing: -.01em; }
h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .12em; color: var(--ink-3); margin: 1.2rem 0 .5rem; font-weight: 600; }
.hint { color: var(--ink-3); font-size: .85rem; margin: .5rem 0 0; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 1rem 1.1rem; }

/* ───────── shell ───────── */
.app {
  display: grid; grid-template-rows: auto 1fr auto; grid-template-columns: minmax(0, 1fr); grid-template-areas: "top" "main" "nav";
  height: 100vh; height: 100dvh; max-width: 100vw; overflow: hidden;
}
main, .screen, .panel, .panel-chat, .panel-player, .stage-wrap, .chat-log, .chat-input, .p-card { min-width: 0; }
.topbar { grid-area: top; min-width: 0; display: flex; align-items: center; justify-content: space-between; padding: .55rem .9rem; border-bottom: 1px solid var(--line); background: var(--paper); z-index: 5; }
.brand { display: flex; align-items: center; gap: .5rem; text-decoration: none; color: var(--ink); }
.brand-mark { color: var(--terra); font-size: 1.1rem; }
.brand-name { font-family: var(--serif); font-size: 1.15rem; letter-spacing: -.01em; }
.brand-name em { font-style: italic; color: var(--sage-2); }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name .tm { font-size: .55em; vertical-align: super; margin-left: .05em; font-family: var(--sans, system-ui); }
.brand-sub { font-size: .68rem; color: var(--ink-2); letter-spacing: .01em; }
@media (max-width: 899px) { .brand-sub { display: none; } }
.tag { font-size: .62rem; letter-spacing: .08em; text-transform: uppercase; border: 1px solid var(--line); border-radius: 999px; padding: .1rem .45rem; color: var(--ink-2); margin-left: .1rem; }
.nav { grid-area: nav; min-width: 0; display: flex; align-items: center; gap: .25rem; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; background: var(--paper); z-index: 5; }
.nav::-webkit-scrollbar { display: none; }
.nav-btn { background: transparent; border: 0; padding: .45rem .7rem; border-radius: 999px; color: var(--ink-2); cursor: pointer; font-size: .9rem; display: inline-flex; align-items: center; justify-content: center; gap: .3rem; white-space: nowrap; }
.nav-ico { display: none; width: 22px; height: 22px; flex: none; }
.nav-btn.on { background: var(--sage-soft); color: var(--sage-2); font-weight: 600; }
.nav-btn:hover { color: var(--ink); }
main { grid-area: main; min-height: 0; overflow: hidden; }
.screen { height: 100%; }
.page { overflow: auto; padding: 1.2rem; max-width: 820px; margin: 0 auto; width: 100%; }

/* ───────── session layout ───────── */
/* stacked (phones): the figure on top, smaller while we talk, taller while we tap; the chat can never be squeezed out */
.session { display: grid; grid-template-rows: minmax(190px, 36dvh) minmax(0, 1fr); height: 100%; }
body.playing .session { grid-template-rows: minmax(220px, 38dvh) minmax(0, 1fr); }
@media (min-width: 900px) {
  .app { grid-template-rows: auto 1fr; grid-template-columns: 1fr auto; grid-template-areas: "top nav" "main main"; }
  .nav { padding: .55rem .9rem .55rem 0; border-bottom: 1px solid var(--line); }
  .session, body.playing .session { grid-template-rows: 1fr; grid-template-columns: 1fr minmax(380px, 460px); }
}
/* landscape phones and small tablets: side by side, otherwise the figure would leave no room to read */
@media (max-width: 899px) and (min-width: 600px) and (orientation: landscape) {
  .session, body.playing .session { grid-template-rows: 1fr; grid-template-columns: 1fr minmax(300px, 46%); }
  .panel { border-top: 0; border-left: 1px solid var(--line); }
}
.stage-wrap { position: relative; background: radial-gradient(120% 90% at 50% 30%, #0b1220, #04070d 70%); overflow: hidden; }
.stage { position: absolute; inset: 0; }
.companion { position: relative; width: 100%; height: 100%; }
.cmp-gl { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.companion.mirror .cmp-gl { transform: scaleX(-1); }
.cmp-overlay { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.cmp-fallback { position: absolute; inset: 0; display: grid; place-items: center; color: #9fc3d6; font-size: .9rem; padding: 1rem; text-align: center; }
.cmp-fallback[hidden] { display: none; }
.stage-wrap::after { content: ''; position: absolute; inset: 0; pointer-events: none; background: radial-gradient(90% 70% at 50% 45%, transparent 55%, rgba(2,4,8,.55) 100%); }
.stage-wrap .cmp-caption { color: #9fc3d6; z-index: 2; }
.stage-overlay { z-index: 2; }
.stage-wrap .o-round { color: #8fb3c9; }
.stage-wrap .o-point { color: #ffd8a8; }
.cmp-svg.inset {
  position: absolute; left: 4%; top: 6%; width: 30%; height: auto; max-width: 190px; aspect-ratio: 192 / 200;
  border-radius: 50%; background: var(--paper-2); border: 3px solid var(--card); box-shadow: var(--shadow);
  animation: inset-in .35s ease-out;
}
.cmp-svg.inset .cmp-tapper, .cmp-svg.inset .cmp-points { display: none; }
@keyframes inset-in { from { opacity: 0; transform: scale(.7); } }
.cmp-tapper { filter: drop-shadow(0 6px 8px rgba(0,0,0,.28)); }
.cmp-caption { position: absolute; bottom: .6rem; left: 50%; transform: translateX(-50%); font-size: .8rem; color: var(--ink-3); }
.stage-overlay { position: absolute; top: .7rem; left: .8rem; right: .8rem; display: flex; justify-content: space-between; pointer-events: none; }
.o-round { font-size: .75rem; text-transform: uppercase; letter-spacing: .12em; color: var(--ink-3); font-weight: 600; }
.o-point { font-family: var(--serif); font-size: 1rem; color: var(--terra); font-style: italic; max-width: 62%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: right; }
body.playing .o-point::before { content: '● '; font-style: normal; font-size: .6rem; vertical-align: middle; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .2; } }

/* companion SVG bits */
:root { --aur-1: #bcd3bb; --aur-2: #f2d6c0; --aur-3: #dcd6ec; --tee-hi: #98b59b; --tee-deep: #4f6a53; --node: #d98a5f; --node-hi: #fff1e4; }
.cmp-aurora ellipse { transform-box: fill-box; transform-origin: 50% 50%; will-change: transform; }
.cmp-aurora .a1 { animation: aur-a 26s ease-in-out infinite alternate; }
.cmp-aurora .a2 { animation: aur-b 31s ease-in-out infinite alternate; }
.cmp-aurora .a3 { animation: aur-c 23s ease-in-out infinite alternate; }
@keyframes aur-a { from { transform: translate(-12px, -8px) scale(1); } to { transform: translate(26px, 22px) scale(1.12); } }
@keyframes aur-b { from { transform: translate(16px, 10px) scale(1.08); } to { transform: translate(-22px, -18px) scale(.96); } }
@keyframes aur-c { from { transform: translate(8px, 14px) scale(.98); } to { transform: translate(-18px, -10px) scale(1.1); } }
.cmp-head { will-change: transform; }
.cmp-point .halo { fill: var(--node); opacity: .12; transition: opacity .25s, r .25s; }
.cmp-point .ring { fill: none; stroke: var(--node); stroke-width: 1.2; opacity: .35; transition: opacity .25s, r .25s; }
.cmp-point .core { fill: var(--node); opacity: .55; transition: opacity .25s, r .25s; }
.cmp-point.active .halo { opacity: .28; r: 16; animation: node-pulse 1.6s ease-in-out infinite; }
.cmp-point.active .ring { opacity: .9; r: 8; stroke-width: 1.6; }
.cmp-point.active .core { opacity: 1; fill: var(--node-hi); r: 3.2; filter: drop-shadow(0 0 5px var(--node)); }
.cmp-point.hit .ring { animation: hit .36s ease-out; }
@keyframes node-pulse { 0%, 100% { opacity: .22; r: 15; } 50% { opacity: .38; r: 19; } }
@keyframes hit { 0% { r: 8; opacity: 1; } 45% { r: 13; opacity: .6; } 100% { r: 8; opacity: .9; } }
.cmp-ripple { fill: none; stroke: var(--node-hi); stroke-width: 2.2; filter: drop-shadow(0 0 4px var(--node)); }
.cmp-ripple.soft { stroke: var(--node); stroke-width: 6; filter: none; }
.cmp-grain { pointer-events: none; }
@media (prefers-color-scheme: dark) {
  :root { --aur-1: #2f4a3c; --aur-2: #4a3a37; --aur-3: #35365a; --tee-hi: #7a9a7e; --tee-deep: #3b5140; --node: #f0a06e; --node-hi: #fff4ea; }
  .cmp-grain { mix-blend-mode: screen !important; opacity: .05; }
}
@media (prefers-reduced-motion: reduce) {
  .cmp-aurora ellipse, .cmp-point.active .halo { animation: none; }
}
.cmp-note { position: absolute; font-size: 1.4rem; color: #d8f7ff; font-family: var(--serif); text-shadow: 0 0 10px #5fd8ff, 0 0 20px rgba(95,216,255,.6); animation: note-up 1.4s ease-out forwards; }
@keyframes note-up { from { opacity: 1; transform: translate(0, 0); } to { opacity: 0; transform: translate(10px, -70px); } }
.cmp-count { position: absolute; font-size: 2.6rem; color: #fff3dd; font-family: var(--serif); font-weight: 600; text-shadow: 0 0 12px #ffb86b, 0 0 28px rgba(255,184,107,.6); animation: count-pop .9s ease-out forwards; }
@keyframes count-pop { 0% { opacity: 0; transform: scale(.5); } 25% { opacity: 1; transform: scale(1.15); } 40% { transform: scale(1); } 70% { opacity: 1; } 100% { opacity: 0; transform: scale(1) translateY(-20px); } }

/* ───────── panel ───────── */
.panel { position: relative; min-height: 0; border-top: 1px solid var(--line); background: var(--paper); display: grid; }
@media (min-width: 900px) { .panel { border-top: 0; border-left: 1px solid var(--line); } }
.panel-chat { display: grid; grid-template-rows: 1fr auto; min-height: 0; height: 100%; }
.chat-log { overflow: auto; padding: .9rem .9rem .4rem; display: flex; flex-direction: column; gap: .55rem; scroll-behavior: smooth; }
.msg { display: flex; gap: .5rem; align-items: flex-end; max-width: 92%; animation: rise .28s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
.msg.you { align-self: flex-end; flex-direction: row-reverse; }
.avatar { width: 24px; height: 24px; border-radius: 50%; background: var(--sage-soft); color: var(--terra); display: grid; place-items: center; font-size: .8rem; flex: none; }
.bubble { background: var(--card); border: 1px solid var(--line); padding: .6rem .85rem; border-radius: 16px 16px 16px 4px; font-size: .96rem; }
.msg.you .bubble { background: var(--sage-soft); border-color: transparent; border-radius: 16px 16px 4px 16px; }
.msg.strong .bubble { border-color: var(--terra); font-weight: 600; }
.typing .bubble { display: flex; gap: 4px; padding: .7rem .8rem; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--ink-3); animation: dot 1s infinite; }
.typing i:nth-child(2) { animation-delay: .15s; } .typing i:nth-child(3) { animation-delay: .3s; }
@keyframes dot { 0%, 60%, 100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-4px); opacity: 1; } }
.chat-input { padding: .6rem .9rem calc(.9rem + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--paper); }

/* widgets */
.w { display: flex; flex-direction: column; gap: .55rem; }
.w-text { flex-direction: row; align-items: flex-end; }
.txt { width: 100%; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: .65rem .8rem; resize: none; outline: none; }
.txt:focus { border-color: var(--sage); box-shadow: 0 0 0 3px var(--sage-soft); }
.btn { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: .6rem 1rem; cursor: pointer; font-weight: 600; transition: transform .08s, background .15s; }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--sage-2); border-color: var(--sage-2); color: #fff; }
.btn.primary:hover { background: var(--sage); }
.btn.big { padding: .85rem 1.2rem; font-size: 1.02rem; }
.btn.ghost { background: transparent; }
.btn.ghost.danger { color: var(--terra); }
.btn.small { padding: .4rem .8rem; font-size: .85rem; }
.btn.icon { width: 44px; height: 44px; padding: 0; display: grid; place-items: center; font-size: 1.3rem; }
.btn.round { width: 64px; height: 64px; padding: 0; font-size: 1.1rem; border-radius: 50%; display: grid; place-items: center; }
.btn.pulse { animation: pulse 2.2s infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(88,122,94,.35); } 50% { box-shadow: 0 0 0 10px rgba(88,122,94,0); } }
.row { display: flex; gap: .5rem; flex-wrap: wrap; }
.lbl { font-size: .75rem; text-transform: uppercase; letter-spacing: .1em; color: var(--ink-3); font-weight: 600; }
.chip { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: .55rem .9rem; cursor: pointer; text-align: left; }
.chip:hover { border-color: var(--sage); }
.chip.with-hint { border-radius: 14px; }
.homage { padding: 1rem 1.1rem; margin: .4rem 0 1rem; }
.homage-lead { font-family: var(--serif); font-size: 1.08rem; margin-top: 0; }
.homage-links { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.homage-line a { color: var(--sage-2); }
.chip small { display: block; font-size: .76rem; color: var(--ink-2); margin-top: .1rem; }
.w-choices { flex-direction: row; flex-wrap: wrap; }
.w-textwrap { gap: .4rem; }
.starters { display: flex; gap: .35rem; flex-wrap: wrap; }
.chip.mini { padding: .3rem .65rem; font-size: .8rem; color: var(--ink-2); }
.notice { margin-top: .5rem; font-size: .85rem; color: var(--ink-2); display: grid; gap: .4rem; }
.notice .txt { font-size: .75rem; font-family: ui-monospace, monospace; }

.suds-head { display: flex; align-items: baseline; gap: .7rem; }
.suds-num { font-family: var(--serif); font-size: 3rem; line-height: 1; color: var(--terra); font-weight: 500; }
.suds-desc { color: var(--ink-2); }
.suds { width: 100%; accent-color: var(--terra); }
.suds-scale { display: flex; justify-content: space-between; font-size: .75rem; color: var(--ink-3); }

.w-review .setup { font-family: var(--serif); font-size: 1.05rem; line-height: 1.4; }
.rem-preview { font-family: var(--serif); font-size: 1.05rem; padding: .4rem .2rem; }
.rem-details summary { cursor: pointer; color: var(--sage-2); font-size: .9rem; }
.rem-list { display: grid; gap: .4rem; margin-top: .5rem; }
.rem-row { display: grid; grid-template-columns: 120px 1fr; gap: .5rem; align-items: center; font-size: .85rem; }
.rem-pt { color: var(--ink-3); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; width: max-content; }
.seg-btn { border: 0; background: transparent; padding: .45rem .9rem; cursor: pointer; color: var(--ink-2); }
.seg-btn.on { background: var(--sage-soft); color: var(--sage-2); font-weight: 600; }

.w-resources .res { display: flex; justify-content: space-between; align-items: center; background: var(--card); border: 1px solid var(--terra); border-radius: 14px; padding: .75rem .9rem; text-decoration: none; color: var(--ink); }
.w-resources .res span { color: var(--terra); font-weight: 600; }

.sum { text-align: center; padding: .6rem 0; }
.sum-big { font-family: var(--serif); font-size: 2.6rem; display: flex; justify-content: center; gap: .6rem; align-items: center; }
.sum-big .b, .hist-num .b { color: var(--ink-3); }
.sum-big .a, .hist-num .a { color: var(--sage-2); font-weight: 600; }
.arrow { color: var(--ink-3); font-size: .7em; }
.sum-issue { font-family: var(--serif); font-style: italic; color: var(--ink-2); }
.sum-meta { font-size: .8rem; color: var(--ink-3); }

/* ───────── player ───────── */
.panel-player { display: grid; grid-template-rows: auto 1fr auto auto; gap: .6rem; padding: .8rem .9rem calc(.8rem + env(safe-area-inset-bottom)); min-height: 0; height: 100%; }
.p-head { display: flex; align-items: center; gap: .7rem; }
.p-step { font-size: .72rem; text-transform: uppercase; letter-spacing: .12em; color: var(--ink-3); font-weight: 600; white-space: nowrap; }
.p-track { flex: 1; height: 4px; background: var(--line); border-radius: 2px; overflow: hidden; }
.p-bar { height: 100%; width: 0; background: var(--sage-2); transition: width .4s; }
.p-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 1rem 1.1rem; display: grid; align-content: center; gap: .5rem; min-height: 0; overflow: auto; box-shadow: var(--shadow); }
.p-point { font-size: .78rem; text-transform: uppercase; letter-spacing: .12em; color: var(--terra); font-weight: 600; }
.p-phrase { font-family: var(--serif); font-size: clamp(1.35rem, 2.6vw + .6rem, 1.9rem); line-height: 1.25; letter-spacing: -.01em; font-weight: 500; }
.p-phrase.emphatic { text-transform: uppercase; letter-spacing: .02em; color: var(--terra); }
.p-phrase.gamut { font-size: clamp(1.2rem, 2vw + .5rem, 1.5rem); }
.p-dots { display: flex; gap: 6px; }
.p-dots i { width: 10px; height: 10px; border-radius: 50%; background: var(--line); transition: background .12s, transform .12s; }
.p-dots i.rep { width: 16px; height: 16px; }
.p-dots i.on { background: var(--terra); transform: scale(1.15); }
.p-where { color: var(--ink-2); font-size: .9rem; }
.p-controls { display: flex; justify-content: center; align-items: center; gap: 1.2rem; }
.p-extras { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; justify-content: center; }
.tog { border: 1px solid var(--line); background: transparent; border-radius: 999px; padding: .35rem .7rem; font-size: .8rem; color: var(--ink-3); cursor: pointer; }
.tog.on { background: var(--sage-soft); color: var(--sage-2); border-color: transparent; }
.p-speed { display: flex; align-items: center; gap: .4rem; font-size: .8rem; color: var(--ink-3); }
.p-speed input { width: 90px; accent-color: var(--sage-2); }

/* ───────── history ───────── */
.chart { padding: .8rem; margin-bottom: 1rem; }
.chart svg { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .tick { font-size: 11px; fill: var(--ink-3); text-anchor: end; }
.chart .bar.before { fill: var(--line); }
.chart .bar.after { fill: var(--sage-2); }
.legend { display: flex; gap: 1rem; font-size: .8rem; color: var(--ink-3); margin-top: .4rem; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: middle; }
.legend .before { background: var(--line); } .legend .after { background: var(--sage-2); }
.hist-list { display: grid; gap: .5rem; margin-bottom: 1rem; }
.hist-row { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: .8rem; }
.hist-issue { font-family: var(--serif); font-size: 1.05rem; }
.hist-meta { font-size: .78rem; color: var(--ink-3); }
.hist-num { font-family: var(--serif); font-size: 1.5rem; display: flex; gap: .4rem; align-items: center; }
.empty { color: var(--ink-3); }

/* ───────── settings / about ───────── */
.set-row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .6rem 0; border-top: 1px solid var(--line); }
.set-row:first-of-type { border-top: 0; }
.set-lbl { display: grid; }
.set-lbl small { color: var(--ink-3); font-size: .78rem; }
.set-row input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--sage-2); }
.set-row select { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: .4rem .6rem; max-width: 220px; }
.set-row input[type=range] { accent-color: var(--sage-2); width: 160px; }
.about p { color: var(--ink-2); }
.steps li { margin: .45rem 0; }
.pts { list-style: none; padding: 0; display: grid; gap: .5rem; }
.pts li { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: .6rem .8rem; }
.pts.plain li { background: transparent; border: 0; padding: .2rem 0; }
.pts .code { font-size: .72rem; color: var(--ink-3); margin-left: .5rem; font-family: ui-monospace, monospace; }
.pts div { color: var(--ink-2); font-size: .9rem; }

/* ───────── consent modal ───────── */
.modal { position: fixed; inset: 0; background: rgba(31,42,36,.55); display: grid; place-items: center; padding: 1rem; z-index: 20; backdrop-filter: blur(3px); }
.modal[hidden] { display: none; }
.consent { max-width: 520px; width: 100%; max-height: 90dvh; overflow: auto; box-shadow: var(--shadow); }
.consent ul { padding-left: 1.2rem; color: var(--ink-2); }
.consent li { margin: .4rem 0; }
.consent .btn { width: 100%; margin-top: .6rem; }

@media (max-width: 899px) {
  .nav { border-top: 1px solid var(--line); padding: .25rem .25rem calc(.25rem + env(safe-area-inset-bottom)); gap: 0; overflow: visible; }
  .nav-btn { flex: 1 1 0; min-width: 0; flex-direction: column; gap: .12rem; padding: .3rem .15rem; min-height: 50px; border-radius: 12px; font-size: .68rem; letter-spacing: .01em; }
  .nav-ico { display: block; }
  .nav-btn span { overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
  body.playing .nav { display: none; }                     /* a round needs the room; End round is on the card */
  .chat-input { padding-bottom: .7rem; max-height: 66%; overflow: auto; } /* the tab bar carries the safe-area inset; a tall widget scrolls instead of eating the chat */
  .panel-player { padding-bottom: .8rem; }
  body.playing .panel-player { padding-bottom: calc(.8rem + env(safe-area-inset-bottom)); }
  .page { padding: 1rem .9rem calc(1rem + env(safe-area-inset-bottom)); }
  .msg { max-width: 95%; }
  .p-card { gap: .35rem; align-content: start; }             /* point + words first; the location text is what scrolls */
  .p-where { font-size: .85rem; }
  .w-review .setup { min-height: 6.4em; field-sizing: content; }
  .p-chart svg { max-height: 120px; }
  input, textarea, select { font-size: max(16px, 1em); } /* iOS zooms into anything smaller */
  .notice .txt { font-size: 16px; }
}
@media (max-width: 899px) and (max-height: 640px) and (orientation: portrait) {
  .session { grid-template-rows: minmax(160px, 32dvh) minmax(0, 1fr); }
  .w-welcome .homage-line { display: none; }               /* short screen: the credit line stays in the welcome bubble and the Guide page */
}
/* landscape phones: an icon-only tab bar, so the figure and the words keep the height */
@media (max-width: 899px) and (orientation: landscape) and (max-height: 500px) {
  .nav { padding: .1rem .25rem calc(.1rem + env(safe-area-inset-bottom)); }
  .nav-btn { min-height: 40px; padding: .2rem; flex-direction: row; gap: .3rem; font-size: .7rem; }
  .topbar { padding-top: .35rem; padding-bottom: .35rem; }
  .w-welcome .homage-line { display: none; }
}
/* tablets: the tabs need not stretch across the whole width */
@media (min-width: 600px) and (max-width: 899px) {
  .nav { justify-content: center; }
  .nav-btn { max-width: 150px; }
}
@media (max-width: 600px) {
  .topbar { padding: .45rem .7rem; gap: .5rem; }
  .brand-name { font-size: 1.05rem; white-space: nowrap; }
  .brand-name em { display: none; }
  .p-extras { gap: .35rem; }
  .p-speed input { width: 70px; }
  .p-card { padding: .8rem .9rem; }
  .btn.round { width: 58px; height: 58px; }
  .p-phrase { font-size: clamp(1.1rem, 4.2vw + .2rem, 1.6rem); }
  .p-phrase.gamut { font-size: clamp(1rem, 3.6vw + .2rem, 1.35rem); }
  .chat-log { padding: .7rem .7rem .3rem; }
  .chat-input { padding-left: .7rem; padding-right: .7rem; }
  .set-row { flex-wrap: wrap; }                              /* a select or a slider drops under its label; a checkbox stays beside it */
  .set-lbl { flex: 1 1 60%; min-width: 0; }
  .set-row select { max-width: 100%; }
  .rem-row { grid-template-columns: 1fr; gap: .15rem; }
  .sum-big { font-size: 2.2rem; }
  .atlas { padding: .7rem; }
  .atlas-head { flex-wrap: wrap; row-gap: .3rem; }           /* title + Close on one line, the hint under them */
  .atlas-head strong { flex: 1; font-size: 1.05rem; }
  .atlas-head .hint { flex: 1 1 100%; order: 3; margin: 0; }
}
/* small or short screens: the consent list scrolls, the accept button stays in view */
@media (max-width: 600px), (max-height: 560px) {
  .consent { padding: .9rem 1rem; }
  .consent h2 { font-size: 1.35rem; }
  .consent li { margin: .3rem 0; font-size: .95rem; }
  .consent .btn { position: sticky; bottom: 0; box-shadow: 0 -10px 14px var(--card); }
}
@media (max-width: 360px) {
  .tag { display: none; }
  .nav-btn { font-size: .64rem; }
}
/* fingers, not cursors: nothing smaller than 44px to hit */
@media (pointer: coarse) {
  .btn, .chip, .tog, .seg-btn, .res { min-height: 44px; }
  .btn.small { min-height: 40px; }
  .chip.mini { min-height: 38px; }
  .btn.icon { width: 48px; height: 48px; }
  .set-row input[type=checkbox] { width: 26px; height: 26px; }
  .suds, .p-speed input, .set-row input[type=range] { height: 32px; }
  .pts li .show-me { min-height: 40px; }
}

@media (prefers-reduced-motion: reduce) {
  .msg, .btn.pulse, .cmp-point.hit { animation: none; }
}

/* ───────────── agent: streaming bubble ───────────── */
.msg.guide.stream .bubble::after { content: '▍'; margin-left: 1px; color: var(--accent, #6a8f6d); animation: bt-blink 1s steps(2) infinite; }
@keyframes bt-blink { 50% { opacity: 0; } }
.w-slider .lbl, .w-choices .lbl { margin-bottom: .4rem; }
.hist-note { font-size: .82rem; color: var(--ink-2); margin-top: .15rem; }

/* ───────────── agent: TUI harness drawer ───────────── */
.tui { position: fixed; left: 12px; bottom: 12px; z-index: 40; font: 12px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; }
.tui-toggle { background: #0b0f0c; color: #7dff9a; border: 1px solid #1f3a26; border-radius: 8px; padding: .35rem .7rem; cursor: pointer; box-shadow: 0 6px 20px rgba(0,0,0,.3); font: inherit; }
.tui-toggle:hover { border-color: #3a7a4a; }
.tui-body { position: absolute; left: 0; bottom: 38px; width: min(560px, calc(100vw - 24px)); height: min(340px, 55vh); background: #070a08; color: #9dffb0; border: 1px solid #1f3a26; border-radius: 10px; display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 12px 40px rgba(0,0,0,.45); }
.tui-body[hidden] { display: none; }
.tui-head { display: flex; justify-content: space-between; gap: .5rem; padding: .4rem .7rem; border-bottom: 1px solid #1f3a26; color: #5fd37a; background: #0b0f0c; }
.tui-meta { color: #4c8a5c; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tui-log { margin: 0; padding: .5rem .7rem; overflow: auto; flex: 1; white-space: pre-wrap; word-break: break-word; font: inherit; }
.tui-log .l.sys { color: #5fd37a; }
.tui-log .l.dim { color: #4c8a5c; }
.tui-log .l.tool { color: #ffd166; }
.tui-log .l.ok { color: #9dffb0; }
.tui-log .l.err { color: #ff6b6b; }
.tui-log .l.delta { color: #d6f5dc; }
body.playing .tui { display: none; }
/* stacked layout: the stage is on top, so the drawer hangs from the stage's top-right corner instead of covering the composer */
@media (max-width: 899px) { .tui { left: auto; right: 8px; top: 60px; bottom: auto; } .tui-body { left: auto; right: 0; top: 38px; bottom: auto; height: min(300px, 50vh); } }

/* floating point name tags (companion.showPoint / tour) */
.cmp-label {
  position: absolute; transform: translate(-50%, calc(-100% - 18px));
  font: 600 12px/1.2 system-ui, sans-serif; letter-spacing: .02em; white-space: nowrap;
  color: #eaf7ff; background: rgba(6, 16, 26, .6); border: 1px solid rgba(120, 220, 255, .4);
  padding: 4px 9px; border-radius: 999px; pointer-events: none;
  text-shadow: 0 0 8px rgba(95, 216, 255, .6); box-shadow: 0 0 14px rgba(95, 216, 255, .18);
  animation: cmp-label-in .25s ease-out;
}
.cmp-label small { opacity: .7; margin-left: .45em; font-weight: 500; }
@keyframes cmp-label-in { from { opacity: 0; transform: translate(-50%, calc(-100% - 8px)); } to { opacity: 1; transform: translate(-50%, calc(-100% - 18px)); } }
.cmp-label::after { content: ''; position: absolute; left: 50%; top: 100%; width: 1px; height: 15px; background: linear-gradient(to bottom, rgba(120, 220, 255, .8), rgba(120, 220, 255, 0)); }

/* "Show me" buttons on the Guide page point list */
.pts li .show-me { float: right; margin: -.1rem 0 .3rem .6rem; background: transparent; border: 1px solid var(--line); color: var(--ink-2, inherit); }
.pts li .show-me:hover { border-color: var(--accent, #7dd3fc); color: var(--accent, #7dd3fc); }

/* ── point charts (line drawings of the figure with the projected points) ── */
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; }
.chart-card { background: #f4f1ea; border: 1px solid var(--line); border-radius: 12px; padding: .4rem; margin: .3rem 0 .6rem; max-width: 420px; }
.chart-dot { fill: #d8432b; stroke: #fff; stroke-width: 1.5; }
.chart-halo { fill: #d8432b; opacity: 0; transition: opacity .2s; }
.chart-pt.active .chart-halo { opacity: .28; }
.chart-pt.active .chart-dot { fill: #ff5a3c; }
.chart-lead { stroke: #7a4a3a; stroke-width: 1.2; opacity: .85; }
.chart-label { fill: #2a2420; font-family: var(--serif, Georgia, serif); }
.chart-num { font-weight: 700; fill: #b03a22; }
.chart-code { fill: #6a5c52; font-size: 80%; font-family: ui-monospace, monospace; }
.chart-pt.active .chart-label { fill: #b03a22; }
.p-chart { margin-top: .5rem; background: #f4f1ea; border-radius: 10px; padding: .25rem; }
.p-chart[hidden] { display: none; }
.p-chart svg { max-height: 190px; margin: 0 auto; }
.points-btn.on { background: var(--accent, #7dd3fc); color: #06121a; }
.atlas { position: fixed; inset: 0; z-index: 40; background: rgba(6, 10, 16, .82); backdrop-filter: blur(6px); display: grid; grid-template-rows: auto 1fr; padding: 1rem; overflow: auto; }
.atlas[hidden] { display: none; }
.atlas-head { display: flex; align-items: center; gap: .8rem; color: var(--ink); margin-bottom: .6rem; }
.atlas-head .hint { flex: 1; color: var(--ink-3); font-size: .85rem; }
.atlas-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(340px, 100%), 1fr)); gap: .8rem; align-content: start; max-width: 1240px; margin: 0 auto; width: 100%; }
.atlas-grid > div { background: #f4f1ea; border-radius: 12px; padding: .4rem; }
/* phones (stacked layout): the words must stay readable on the card, so the inset drawing only appears on tall screens
   (portrait tablets); the figure itself is already showing the point. While the words are being reviewed the figure
   makes room for the two text fields. */
@media (max-width: 899px) { .panel-player .p-chart svg { max-height: 120px; } }
@media (max-width: 899px) and (max-height: 999px) { .panel-player .p-chart { display: none; } }
@media (max-width: 899px) and (orientation: portrait) {
  .session:has(.w-review), .session:has(.w-close) { grid-template-rows: minmax(130px, 22dvh) minmax(0, 1fr); }
  .chat-input:has(.w-review), .chat-input:has(.w-close), .chat-input:has(.w-resources) { max-height: 92%; }
}
