/*
 * Genbient: an instrument, not a landing page.
 * Ink on a ground, one accent used sparingly, type doing the work.
 * No blur, no glow, no gradients in the chrome (they also cost battery).
 */
:root {
  --bg: #0f1417;
  --bg-rgb: 15 20 23;
  --ink-rgb: 205 214 214;
  --accent: #e0a458;
  --surface: #161c1f;
  --ink: rgb(var(--ink-rgb));
  --ink-2: rgb(var(--ink-rgb) / 0.66);
  --ink-3: rgb(var(--ink-rgb) / 0.58);
  --rule: rgb(var(--ink-rgb) / 0.14);
  --serif: 'Newsreader', 'Iowan Old Style', Georgia, serif;
  --sans: 'IBM Plex Sans', system-ui, -apple-system, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  --ease: cubic-bezier(0.3, 0.7, 0.2, 1);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}
:root.light { color-scheme: light; --ink-3: rgb(var(--ink-rgb) / 0.64); }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 var(--sans);
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
  transition: background-color 1.2s;
}

button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }

#bg { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

.grain {
  position: fixed; inset: 0; pointer-events: none; opacity: var(--grain, 0.05);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .5 0 0 0 0 .5 0 0 0 0 .5 0 0 0 .9 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

#app {
  position: fixed; inset: 0;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  padding: calc(var(--safe-t) + 10px) max(20px, env(safe-area-inset-right, 0px)) 0 max(20px, env(safe-area-inset-left, 0px));
  max-width: 680px; margin: 0 auto;
  touch-action: none;
}

/* ─── header: the three modes, then Rec and Share ─── */
.modes { display: flex; gap: 20px; }
.modes button { position: relative; font: italic 400 19px/1 var(--serif); color: var(--ink-3); padding: 10px 0; transition: color 0.3s; }
.modes button.on { color: var(--ink); }
.modes button.on::after { content: ''; position: absolute; left: 0; right: 0; bottom: 3px; height: 1px; background: var(--accent); }
#sleep-left { font: 400 10px/1 var(--mono); color: var(--accent); margin-left: 3px; vertical-align: super; font-style: normal; }
#sleep-left:empty { display: none; }

/* A quiet scrim in the scene's own ground colour sits behind the words
   while the interface is showing, and fades to the waves below them. */
.title { position: relative; z-index: 0; }
.top { position: relative; z-index: 1; }
.title::before {
  content: ''; position: absolute; z-index: -1; pointer-events: none;
  left: calc(50% - 50vw); width: 100vw; top: -160px; bottom: -56px;
  background: linear-gradient(to bottom,
    rgb(var(--bg-rgb) / 0.94) 0, rgb(var(--bg-rgb) / 0.9) calc(100% - 96px),
    rgb(var(--bg-rgb) / 0.55) calc(100% - 44px), rgb(var(--bg-rgb) / 0) 100%);
  transition: opacity 1.4s var(--ease);
}
.idle .title::before { opacity: 0; }
body[data-mode="run"].idle .title::before { opacity: 0.6; }

/* ─── the panel under the title: a sentence you can edit ─── */
.panel { margin-top: 14px; max-width: 30em; transition: opacity 1.4s var(--ease); }
.panel:empty { display: none; }
.phrase {
  margin: 0; font: 400 18px/1.6 var(--serif); color: var(--ink-2); text-wrap: pretty;
  text-shadow: 0 0 10px var(--bg), 0 0 3px var(--bg); /* stays legible over the lines */
}
.tok {
  font: inherit; color: var(--ink); padding: 6px 0; margin: -6px 0;
  background-image: linear-gradient(rgb(var(--ink-rgb) / 0.35), rgb(var(--ink-rgb) / 0.35));
  background-size: 100% 1px; background-repeat: no-repeat; background-position: 0 calc(100% - 7px);
  transition: color 0.3s;
}
.tok:active, .tok.open { color: var(--accent); background-image: linear-gradient(var(--accent), var(--accent)); }
.picker { margin: 10px 0 2px; }
.picker .chips.pchips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; gap: 4px; padding: 2px 0; margin: 0 -20px; padding-left: 20px; padding-right: 44px; touch-action: pan-x; }
.picker .chips.pchips::-webkit-scrollbar { display: none; }
.pchips .chip { flex: none; min-height: 36px; padding: 8px 12px; font: italic 400 15px/1 var(--serif); background: var(--bg); white-space: nowrap; }
.pchips .chip.on { background: var(--ink); }
.whisper { display: flex; align-items: center; gap: 14px; min-height: 30px; margin-top: 6px; font: 400 12px/1 var(--mono); color: var(--ink-3); }
.whisper .text-btn { padding: 9px 0; color: var(--ink-3); }
.whisper .skip-btn { color: var(--accent); margin-left: auto; }
.whisper .skip-btn[hidden] { display: none; }
.run-top { display: flex; align-items: center; gap: 16px; margin-bottom: 8px; }
.run-top .cadence button { width: 40px; height: 40px; border-radius: 50%; background: var(--bg); font: 300 20px/1 var(--sans); }
.run-top .cadence output { font: 400 44px/1 var(--serif); min-width: 84px; font-variant-numeric: lining-nums; }
.run-top .cadence span { display: inline-block; width: 3.2em; margin-left: 2px; font: 400 11px/1.2 var(--mono); color: var(--ink-3); }
.run-top .tap-link { font: italic 400 16px/1 var(--serif); color: var(--ink-2); padding: 12px 0; }
body[data-mode="run"] .title h1 { font-size: clamp(30px, 8.5vw, 46px); }
.idle .panel { opacity: 0; pointer-events: none; }
/* sleep: once the interface fades, the lines dim too */
#bg { transition: opacity 4s var(--ease); }
body[data-mode="sleep"].idle #bg { opacity: 0.3; }
body[data-mode="run"].idle .panel { opacity: 0.5; }
body[data-mode="run"].idle .panel .phrase, body[data-mode="run"].idle .panel .picker { visibility: hidden; }

/* ─── header ─── */
.top { display: flex; align-items: center; justify-content: space-between; height: 40px; transition: opacity 1.4s var(--ease); }
.top-actions { display: flex; gap: 18px; }
.text-btn { font: 500 12px/1 var(--mono); color: var(--ink-2); padding: 14px 0; min-width: 28px; white-space: nowrap; }
.text-btn.active, .text-btn:active { color: var(--ink); }
#btn-rhythm[aria-pressed="false"] { color: var(--ink-3); }

/* ─── title: left-aligned, like a record label ─── */
.title { min-width: 0; padding-top: 3vh; transition: opacity 0.6s var(--ease), transform 0.6s var(--ease); }
.title.swap { opacity: 0; transform: translateX(-8px); }
.title h1 {
  font: 400 clamp(38px, 11vw, 60px)/0.98 var(--serif); margin: 0; letter-spacing: -0.015em;
  font-optical-sizing: auto; text-wrap: balance; max-width: 11em;
}
.tag { display: none; }
.meta { font: italic 400 16px/1.4 var(--serif); color: var(--ink-3); margin: 8px 0 0; transition: opacity 1.4s var(--ease); }

.title-actions { display: flex; gap: 18px; margin-top: 4px; transition: opacity 1.4s var(--ease); }
.title-actions .text-btn { padding: 10px 0; color: var(--ink-2); }
.title-actions [hidden] { display: none; }
#btn-save.done { color: var(--accent); }
.idle .title-actions { opacity: 0; pointer-events: none; }

/* ─── play control ─── */
.stage { --lift: clamp(40px, 12vh, 110px); position: relative; display: grid; place-items: end center; padding-bottom: var(--lift); min-height: 0; }
.orb {
  width: 68px; height: 68px; border-radius: 50%; display: grid; place-items: center;
  background: var(--bg); border: 1px solid rgb(var(--ink-rgb) / 0.5); color: var(--ink);
  transition: transform 0.25s var(--ease), border-color 0.3s, opacity 1.4s var(--ease);
}
.orb:active { transform: scale(0.94); }
.orb svg { width: 22px; height: 22px; fill: currentColor; stroke: none; }
.orb .i-pause { display: none; }
.playing .orb .i-play { display: none; }
.playing .orb .i-pause { display: block; }
.orb-label { position: absolute; bottom: calc(var(--lift) - 26px); font: 400 12px/1 var(--mono); color: var(--ink-3); pointer-events: none; }
.playing .orb-label { opacity: 0; }
.breath-text {
  position: absolute; left: 0; right: 0; bottom: calc(var(--lift) + 100px); margin: 0; text-align: center;
  font: italic 400 26px/1 var(--serif); color: var(--ink); opacity: 0; transition: opacity 0.9s var(--ease); pointer-events: none;
}
.breath-text.show { opacity: 1; }
.hint { position: absolute; left: 0; right: 0; bottom: 14px; margin: 0; text-align: center; font: 400 12px/1.4 var(--mono); color: var(--ink-3); pointer-events: none; transition: opacity 1s; }
.started.knows .hint, .idle .hint { opacity: 0; }

/* ─── dock: a plain toolbar ─── */
.dock {
  display: grid; grid-template-columns: repeat(5, 1fr); margin: 0 -20px;
  padding: 0 8px var(--safe-b); border-top: 1px solid var(--rule); background: var(--bg);
  transition: opacity 1.4s var(--ease);
}
.dock-btn, .dock-main {
  position: relative; padding: 16px 0 18px; font: 500 13px/1 var(--sans); color: var(--ink-2); text-align: center;
}
.dock-btn.active { color: var(--ink); }
.dock-btn.active::after { content: ''; position: absolute; left: 30%; right: 30%; top: -1px; height: 2px; background: var(--accent); }
.dock-main { color: var(--accent); font-weight: 600; }
.dock-main:active, .dock-btn:active { opacity: 0.6; }

/* ─── idle: chrome dissolves ─── */
.idle .top, .idle .meta, .idle .dock, .idle .orb { opacity: 0; }
.idle .dock, .idle .orb, .idle .top { pointer-events: none; }
.recording.idle .top { pointer-events: auto; }
.idle .title h1 { opacity: 0.5; transition: opacity 2.5s var(--ease); }

/* ─── sheet ─── */
.backdrop { position: fixed; inset: 0; background: rgb(0 0 0 / 0.35); opacity: 0; pointer-events: none; transition: opacity 0.4s var(--ease); }
.light .backdrop { background: rgb(0 0 0 / 0.15); }
.backdrop.open { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; margin: 0 auto; max-width: 680px;
  max-height: 84vh; display: flex; flex-direction: column;
  background: var(--surface); border-top: 1px solid var(--rule); border-radius: 14px 14px 0 0;
  transform: translateY(calc(100% + 24px)); transition: transform 0.45s var(--ease); will-change: transform;
}
@supports (max-height: 1dvh) { .sheet { max-height: 84dvh; } }
.sheet.open { transform: translateY(0); }
.sheet.dragging { transition: none; }
.grab { width: 100%; padding: 12px 0 10px; display: grid; place-items: center; touch-action: none; cursor: grab; }
.grab span { width: 36px; height: 3px; border-radius: 2px; background: var(--rule); }
.sheet-body { overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; padding: 0 20px calc(var(--safe-b) + 28px); }

.sheet-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 8px 0 10px; }
.sheet-head h2 { font: 400 32px/1.1 var(--serif); margin: 0; letter-spacing: -0.01em; }
.sheet-head small { font: 400 12px/1 var(--mono); color: var(--ink-3); }

.section { padding: 18px 0 8px; border-top: 1px solid var(--rule); margin-top: 10px; }
.section:first-of-type { border-top: 0; }
.section-title { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin: 0 0 10px; min-height: 28px; font: italic 400 21px/1.2 var(--serif); }
.section-aside { display: flex; align-items: center; gap: 10px; }
.section-title em { font: 400 12px/1.2 var(--mono); font-style: normal; color: var(--ink-3); }
.note { color: var(--ink-2); font-size: 13.5px; line-height: 1.55; margin: 6px 0 10px; max-width: 46ch; }
.note b { color: var(--ink); font-weight: 600; }

.mini-dice { font: italic 400 15px/1 var(--serif); color: var(--ink-2); padding: 14px 0 14px 12px; text-decoration: underline; text-decoration-color: rgb(var(--ink-rgb) / 0.35); text-underline-offset: 5px; }
.mini-dice:active { color: var(--accent); }

/* primary action */
.primary {
  width: 100%; padding: 15px 16px; border-radius: 6px; background: var(--ink); color: var(--bg);
  font: 400 18px/1 var(--serif); text-align: left; display: flex; justify-content: space-between; align-items: center; margin: 4px 0 6px;
}
.primary span { font: 400 12px/1 var(--mono); opacity: 0.7; }
.primary:active { opacity: 0.85; }

/* chips → segmented options */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  min-height: 38px; padding: 8px 12px; border-radius: 6px; font: italic 400 15px/1.1 var(--serif); color: var(--ink-2);
  border: 1px solid var(--rule); transition: background 0.2s, color 0.2s, border-color 0.2s;
}
.chip.on { color: var(--bg); background: var(--ink); border-color: var(--ink); }
.chips.keys { display: grid; grid-template-columns: repeat(6, 1fr); }
.chips.keys .chip { padding: 10px 0; text-align: center; font: 400 14px/1 var(--mono); }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -20px; padding: 0 44px 2px 20px; touch-action: pan-x; }
.chips.scroll::-webkit-scrollbar { display: none; }
.chips.scroll .chip { flex: none; white-space: nowrap; }
.chips.filter { margin: 6px -20px 8px; }
.choice { padding: 8px 0; }
.choice-label { display: block; font-size: 13px; color: var(--ink-2); margin: 0 0 8px; }
.choice .chip { padding: 7px 11px; font-size: 14.5px; }
/* long rows fade out at the edge instead of stopping dead */
.chips.scroll, .picker .chips.pchips { -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 32px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 32px), transparent); }
.layer.muted .layer-name { opacity: 0.5; }

/* sliders */
.slider { display: block; padding: 7px 0; }
.slider > span { display: flex; justify-content: space-between; font-size: 13px; color: var(--ink-2); }
.slider > span em { font: 400 12px/1.4 var(--mono); font-style: normal; color: var(--ink-3); font-variant-numeric: tabular-nums; }
input[type=range] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 36px; background: transparent; margin: 0; touch-action: pan-y; --v: 50%;
}
input[type=range]::-webkit-slider-runnable-track {
  height: 2px; background: linear-gradient(90deg, var(--ink) var(--v), var(--rule) var(--v));
}
input[type=range]::-moz-range-track { height: 2px; background: var(--rule); }
input[type=range]::-moz-range-progress { height: 2px; background: var(--ink); }
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 22px; height: 22px; border-radius: 50%; margin-top: -10px;
  background: var(--bg); border: 2px solid var(--ink);
}
input[type=range]::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: var(--bg); border: 2px solid var(--ink); }
input[type=range]:active::-webkit-slider-thumb { background: var(--accent); border-color: var(--accent); }

/* switches */
.switch { width: 34px; height: 20px; border-radius: 10px; border: 1px solid rgb(var(--ink-rgb) / 0.35); position: relative; flex: none; transition: background 0.25s, border-color 0.25s; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 12px; height: 12px; border-radius: 50%; background: var(--ink-3); transition: transform 0.3s var(--ease), background 0.25s; }
.on > .layer-toggle .switch, .switch.on { background: var(--accent); border-color: var(--accent); }
.on > .layer-toggle .switch::after, .switch.on::after { transform: translateX(14px); background: var(--bg); }
.toggle-row { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; text-align: left; }
.toggle-row b { font-weight: 500; font-size: 14px; display: block; }
.toggle-row small { color: var(--ink-3); font-size: 12px; }
.toggle-row.small { padding: 8px 0; }
.toggle-row.small b { font-size: 13px; font-weight: 400; color: var(--ink-2); }

/* layers: a list, not cards */
.layer { border-top: 1px solid var(--rule); }
.layer-toggle { width: 100%; display: flex; align-items: center; gap: 12px; padding: 14px 0; text-align: left; }
.layer-name { flex: 1; font-size: 15px; font-weight: 500; color: var(--ink-2); transition: color 0.2s; }
.layer.on .layer-name { color: var(--ink); }
.layer-name small { font: 400 11.5px/1 var(--mono); color: var(--ink-3); margin-left: 8px; }
.layer .dot { display: none; }
.layer-controls { display: none; padding: 0 0 12px; }
.layer.on .layer-controls { display: block; }
.layer-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.more { display: flex; align-items: center; gap: 6px; padding: 8px 0; font: 500 12.5px/1 var(--sans); color: var(--ink-2); }
.more span { font: 400 12px/1 var(--mono); color: var(--ink-3); }
.more svg { width: 14px; height: 14px; transition: transform 0.3s var(--ease); }
.layer.open .more svg { transform: rotate(180deg); }
.layer-params { display: none; padding: 4px 0 0 12px; border-left: 1px solid var(--rule); margin-top: 4px; }
.layer.open .layer-params { display: block; }
.hint-line { display: block; margin-top: -4px; font: italic 400 13px/1.3 var(--serif); color: var(--ink-3); }
.mix { margin: 8px 0 4px; }
.mix summary { list-style: none; cursor: pointer; padding: 10px 0; font: italic 400 15px/1 var(--serif); color: var(--ink-2); }
.mix summary::-webkit-details-marker { display: none; }
.mix summary::after { content: ' +'; color: var(--ink-3); }
.mix[open] summary::after { content: ' −'; }

/* reroll: an inline list of words */
.reroll-list { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.reroll { padding: 8px 0; font-size: 14px; color: var(--ink); border-bottom: 1px solid var(--rule); }
.reroll:active { color: var(--accent); border-color: var(--accent); }

/* starting points: a list */
.starts { list-style: none; margin: 0; padding: 0; }
.starts button { width: 100%; display: flex; justify-content: space-between; align-items: baseline; padding: 11px 0; border-top: 1px solid var(--rule); text-align: left; }
.starts b { font: 400 19px/1.2 var(--serif); }
.starts span { font: 400 12px/1 var(--mono); color: var(--ink-3); }
.saved-item { display: flex; align-items: stretch; }
.saved-item > button:first-child { flex: 1; min-width: 0; }
.saved-item b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.saved-item .remove { width: 44px; flex: none; justify-content: center; font: 400 20px/1 var(--sans); color: var(--ink-3); }
.saved-item.current b::after { content: ' ●'; color: var(--accent); font-size: 10px; vertical-align: middle; }
.starts .current b::after { content: ' ●'; color: var(--accent); font-size: 10px; vertical-align: middle; }

.row-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.btn { padding: 12px; border-radius: 6px; border: 1px solid var(--rule); font-size: 14px; font-weight: 500; display: flex; align-items: center; justify-content: center; gap: 8px; }
.btn:active { background: var(--rule); }
.btn svg { width: 16px; height: 16px; }

.palette-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 6px; }
.swatch { height: 40px; border-radius: 6px; border: 1px solid var(--rule); position: relative; text-align: left; padding: 0 8px; font: 400 11.5px/1 var(--mono); display: flex; align-items: center; gap: 6px; }
.swatch i { width: 10px; height: 10px; border-radius: 2px; flex: none; }
.swatch.on { outline: 2px solid var(--ink); outline-offset: 1px; }

.cadence { display: flex; align-items: center; gap: 4px; }
.cadence button { width: 44px; height: 44px; border: 1px solid var(--rule); border-radius: 6px; font: 400 22px/1 var(--mono); color: var(--ink); }
.cadence button:active { background: var(--rule); }
.cadence output { min-width: 64px; text-align: center; font: 400 28px/1 var(--mono); font-variant-numeric: tabular-nums; }
.cadence span { font: 400 12px/1.2 var(--mono); color: var(--ink-3); margin-left: 8px; }
.section-label { font: 400 12px/1 var(--mono); color: var(--accent); }
.run-time { font: 400 12px/1 var(--mono); color: var(--ink-2); font-variant-numeric: tabular-nums; }
.tap { width: 100%; margin: 12px 0 6px; padding: 16px; border: 1px dashed rgb(var(--ink-rgb) / 0.35); border-radius: 6px; font: 500 14px/1.3 var(--sans); color: var(--ink); }
.tap:active { background: var(--rule); border-style: solid; }
.tap small { display: block; font: 400 12px/1.3 var(--mono); color: var(--ink-3); margin-top: 4px; }
#btn-rec.rec { color: #e0564a; }
.recording.idle .top { opacity: 1; } /* always show that a recording is running */
#btn-rec.rec::before { content: '● '; animation: blink 1.2s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0.2; } }
.clip {
  position: fixed; left: 12px; right: 12px; bottom: calc(var(--safe-b) + 64px); max-width: 520px; margin: 0 auto;
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 8px;
  background: var(--surface); border: 1px solid var(--rule); z-index: 5;
}
.clip[hidden] { display: none; }
.clip-info { flex: 1; min-width: 0; }
.clip-info b { display: block; font-size: 14px; font-weight: 600; }
.clip-info small { font: 400 12px/1.3 var(--mono); color: var(--ink-3); }
.clip .btn { padding: 10px 18px; background: var(--ink); color: var(--bg); border-color: var(--ink); }
.timer-status { font: 400 13px/1 var(--mono); color: var(--ink-2); margin: 10px 0 0; min-height: 16px; }

.toast {
  position: fixed; left: 20px; bottom: calc(var(--safe-b) + 70px);
  padding: 10px 14px; border-radius: 6px; font: 400 13px/1.2 var(--mono); background: var(--ink); color: var(--bg);
  opacity: 0; transform: translateY(8px); pointer-events: none; transition: opacity 0.3s, transform 0.3s var(--ease); max-width: calc(100% - 40px); z-index: 10;
}
.toast.show { opacity: 1; transform: none; }
.sheet-open .toast { bottom: auto; top: calc(var(--safe-t) + 12px); } /* never over the controls you're using */
.toast { display: flex; align-items: center; gap: 14px; }
.toast.actionable { pointer-events: auto; padding-right: 6px; }
#toast-act { font: 600 13px/1 var(--mono); color: var(--bg); padding: 4px 8px; border-left: 1px solid rgb(var(--bg-rgb) / 0.3); }
#toast-act[hidden] { display: none; }

.noscript { position: fixed; inset: auto 0 40% 0; text-align: center; color: var(--ink-2); }

@media (min-width: 720px) {
  .title { padding-top: 5vh; }
  .sheet { bottom: 16px; border-radius: 14px; border: 1px solid var(--rule); max-height: 78vh; }
}
@media (max-height: 640px) {
  .title h1 { font-size: 34px; }
  .title { padding-top: 1vh; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.15s !important; }
  #btn-rec.rec::before { animation: none; }
}
@media (max-width: 359px) {
  .modes { gap: 14px; }
  .modes button { font-size: 17px; }
  .top-actions { gap: 14px; }
}
@media (orientation: landscape) and (max-height: 500px) {
  .title { padding-top: 0; max-width: none; }
  .title h1 { font-size: 28px; }
  .meta { margin-top: 4px; }
  .panel { margin-top: 4px; }
  .breath-text { top: 4px; font-size: 20px; }
  .orb-label { display: none; }
  body[data-mode="run"] .title h1 { font-size: 28px; }
  .stage { --lift: 16px; }
  .dock-btn, .dock-main { padding: 10px 0 12px; }
}
@media (max-width: 359px) {
  .clip { flex-wrap: wrap; }
  .clip-info { flex-basis: 100%; }
}

/* ─── header icon ─── */
.icon-btn { display: grid; place-items: center; width: 36px; height: 40px; color: var(--ink-2); }
.icon-btn svg { width: 19px; height: 19px; }
.top-actions { align-items: center; }

/* ─── full screen: only the lines and your fingers ─── */
.immersive .top, .immersive .title, .immersive .dock, .immersive .orb, .immersive .orb-label,
.immersive .hint, .immersive .toast, .immersive .clip, .immersive .breath-text { opacity: 0 !important; pointer-events: none !important; }
.immersive #app { padding-top: 0; }
body, #app { -webkit-touch-callout: none; }
.exit-hold {
  position: fixed; top: calc(var(--safe-t) + 10px); right: 12px; width: 48px; height: 48px; z-index: 20;
  display: none; place-items: center; color: var(--ink-2); opacity: 0.45; transition: opacity 0.3s;
}
.immersive .exit-hold { display: grid; }
.exit-hold svg { position: absolute; inset: 6px; width: 36px; height: 36px; transform: rotate(-90deg); }
.exit-hold circle { fill: none; stroke-width: 1.5; }
.exit-hold .track { stroke: rgb(var(--ink-rgb) / 0.3); }
.exit-hold .fill { stroke: var(--accent); stroke-dasharray: 94.25; stroke-dashoffset: 94.25; }
.exit-hold span { font: 300 18px/1 var(--sans); }
.exit-hold.holding { opacity: 1; }
.exit-hold.holding .fill { stroke-dashoffset: 0; transition: stroke-dashoffset 1.5s linear; }
.immersive-hint {
  position: fixed; left: 0; right: 0; top: 42%; margin: 0; text-align: center; z-index: 15; pointer-events: none;
  font: italic 400 20px/1.3 var(--serif); color: var(--ink); opacity: 0; transition: opacity 0.8s var(--ease);
  text-shadow: 0 0 12px var(--bg), 0 0 3px var(--bg);
}
.immersive .immersive-hint.show { opacity: 1; }

/* ─── Simple mode ─── */
.kids { margin-top: 4px; }
.kids-q { margin: 10px 0 8px; font: italic 400 17px/1.2 var(--serif); color: var(--ink-2); text-shadow: 0 0 10px var(--bg); }
.worlds { display: flex; gap: 10px; overflow-x: auto; scrollbar-width: none; margin: 0 -20px; padding: 2px 20px 4px; }
.worlds::-webkit-scrollbar { display: none; }
.world { flex: none; display: grid; justify-items: center; gap: 6px; font: italic 400 15px/1 var(--serif); color: var(--ink-2); }
.world-ring { display: grid; place-items: center; width: 60px; height: 60px; border-radius: 50%; border: 1px solid rgb(var(--ink-rgb) / 0.4); background: var(--bg); transition: border-color 0.3s, background 0.3s; }
.world-ring svg { width: 26px; height: 26px; }
.world.on { color: var(--ink); }
.world.on .world-ring { border: 2px solid var(--accent); color: var(--accent); }
.world:active .world-ring { transform: scale(0.94); }
.kid-voices .chip { background: var(--bg); min-height: 42px; font-size: 16px; }
.kid-voices .chip.on { background: var(--ink); color: var(--bg); }
body[data-mode="kids"] .hint { opacity: 0; }
.kids-actions { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-top: 14px; }
.kids-actions .primary { margin: 0; }
.kids-actions .btn { background: var(--bg); padding: 0 18px; font: italic 400 17px/1 var(--serif); }
.kids-bed { margin-top: 4px; padding: 12px 0; color: var(--ink-3); }
body[data-mode="kids"] .title h1 { font-size: clamp(32px, 9vw, 50px); }
@media (max-width: 400px) {
  .modes { gap: 14px; }
  .modes button { font-size: 17px; }
  .top-actions { gap: 10px; }
}
@media (max-width: 340px) {
  .modes { gap: 10px; }
  .modes button { font-size: 15.5px; }
}
@media (max-width: 360px) {
  .world-ring { width: 50px; height: 50px; }
  .kids-q { margin: 6px 0 6px; }
}
