:root {
  --bg: #0b0d12;
  --surface: #13161d;
  --surface-2: #1a1e27;
  --surface-3: #232835;
  --border: #252a35;
  --border-strong: #343b4a;
  --text: #eceef3;
  --text-2: #b7bdca;
  --muted: #7f879a;
  --accent: #5eead4;
  --on-accent: #032320;
  --rec: #ff4d5e;
  --ok: #34d399;
  --warn: #fbbf24;
  --bad: #f87171;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 10px 30px rgba(0, 0, 0, 0.22);

  /* canvas colours (read from JS) */
  --wave: #5eead4;
  --wave-played: #f0fdfa;
  --played-bg: rgba(94, 234, 212, 0.08);
  --playhead: #ffffff;
  --scope-bg: #0d1016;
  --meter-bg: #0d1016;
  --target: rgba(255, 255, 255, 0.08);
  --grid: rgba(255, 255, 255, 0.08);
  --tick: rgba(255, 255, 255, 0.14);

  --radius: 14px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Charter, "Bitstream Charter", Georgia, serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f5f8;
    --surface: #ffffff;
    --surface-2: #f4f6f9;
    --surface-3: #e9ecf2;
    --border: #e3e6ec;
    --border-strong: #d2d7e0;
    --text: #12151c;
    --text-2: #3d4452;
    --muted: #6b7384;
    --accent: #0d9488;
    --on-accent: #ffffff;
    --rec: #e11d48;
    --ok: #059669;
    --warn: #b45309;
    --bad: #dc2626;
    --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 10px 30px rgba(16, 24, 40, 0.06);

    --wave: #14b8a6;
    --wave-played: #134e4a;
    --played-bg: rgba(13, 148, 136, 0.08);
    --playhead: #12151c;
    --scope-bg: #f7f9fb;
    --meter-bg: #e9ecf1;
    --target: rgba(15, 23, 42, 0.07);
    --grid: rgba(15, 23, 42, 0.1);
    --tick: rgba(15, 23, 42, 0.14);
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(1100px 420px at 50% -180px, color-mix(in srgb, var(--accent) 9%, transparent), transparent 70%),
    var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; color: inherit; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 0.8rem; }
.center { text-align: center; }
.spacer { flex: 1; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

kbd {
  display: inline-block;
  min-width: 1.6em;
  padding: 2px 6px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--surface);
  color: var(--text);
  font: 11px/1.3 var(--mono);
  text-align: center;
}

.eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

/* ---------- top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(12px);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark { flex: none; width: 22px; height: 22px; fill: var(--accent); }
.brand-name { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-right { display: flex; align-items: center; gap: 10px; min-width: 0; }
.format-badge {
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  font: 500 11.5px/1 var(--mono);
  white-space: nowrap;
}

.mic-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  max-width: 280px;
  padding: 6px 10px 6px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font-size: 0.84rem;
  cursor: pointer;
  transition: border-color 0.15s;
}
.mic-chip:hover { border-color: var(--border-strong); }
.mic-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mic-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.mic-chip.live .mic-dot { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 25%, transparent); }
body[data-stage="recording"] .mic-chip .mic-dot { background: var(--rec); box-shadow: 0 0 0 3px color-mix(in srgb, var(--rec) 30%, transparent); animation: blink 1s steps(2, start) infinite; }
.chevron { flex: none; width: 14px; height: 14px; color: var(--muted); }

/* ---------- layout ---------- */

.app { max-width: 900px; margin: 0 auto; padding: 22px 20px 32px; }

.stage { display: none; }
body[data-stage="setup"] #stage-setup,
body[data-stage="ready"] #stage-record,
body[data-stage="countdown"] #stage-record,
body[data-stage="recording"] #stage-record,
body[data-stage="review"] #stage-review {
  display: grid;
  gap: 16px;
  animation: rise 0.35s ease both;
}

.card {
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

/* ---------- stepper ---------- */

.stepper {
  display: flex;
  justify-content: center;
  gap: 0;
  margin: 0 0 22px;
  padding: 0;
  list-style: none;
}
.step { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 0.85rem; font-weight: 550; }
.step + .step::before {
  content: "";
  width: clamp(24px, 7vw, 64px);
  height: 2px;
  margin: 0 12px;
  border-radius: 2px;
  background: var(--border-strong);
}
.step.done + .step::before { background: var(--accent); }
.step-dot {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border: 2px solid var(--border-strong);
  border-radius: 50%;
  font-size: 0.78rem;
  font-weight: 700;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}
.step-dot svg { width: 14px; height: 14px; }
.step.current { color: var(--text); }
.step.current .step-dot { border-color: var(--accent); color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 16%, transparent); }
.step.done .step-dot { border-color: var(--accent); background: var(--accent); color: var(--on-accent); }

/* ---------- buttons & fields ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface-2);
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, filter 0.15s, transform 0.1s;
}
.btn:hover:not(:disabled) { background: var(--surface-3); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.primary { border-color: var(--accent); background: var(--accent); color: var(--on-accent); }
.btn.primary:hover:not(:disabled) { background: var(--accent); filter: brightness(1.08); }
.btn.lg { padding: 12px 22px; border-radius: 12px; font-size: 1rem; }
.btn svg { width: 16px; height: 16px; flex: none; }

.link-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 0;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 550;
  cursor: pointer;
}
.link-btn:hover { color: var(--text); }

.icon-btn {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--muted);
  cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn svg { width: 16px; height: 16px; }

.field { display: grid; gap: 6px; margin-bottom: 14px; color: var(--muted); font-size: 0.8rem; font-weight: 550; }
.field select, textarea {
  width: 100%;
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 0.92rem;
  font-weight: 400;
}
.field select:disabled { opacity: 0.6; }
.field-hint { color: var(--muted); font-size: 0.78rem; font-weight: 400; }

.segmented { display: inline-flex; gap: 2px; padding: 3px; border-radius: 9px; background: var(--surface-2); }
.segmented button {
  padding: 4px 10px;
  border: 0;
  border-radius: 7px;
  background: none;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}
.segmented button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18); }

/* ---------- step 1: setup ---------- */

.hero { display: grid; justify-items: center; gap: 10px; padding: 10px 0 4px; text-align: center; }
.hero-icon {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: 20px;
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  color: var(--accent);
}
.hero-icon svg { width: 32px; height: 32px; }
.hero h1 { margin: 6px 0 0; font-size: clamp(1.6rem, 1.2rem + 1.4vw, 2.1rem); line-height: 1.2; letter-spacing: -0.01em; }
.lead { max-width: 540px; margin: 0; color: var(--text-2); font-size: 1.05rem; }

.tips { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 8px 0 0; padding: 0; list-style: none; }
.tip {
  display: flex;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}
.tip b { display: block; margin-bottom: 2px; font-size: 0.92rem; }
.tip span { color: var(--muted); font-size: 0.85rem; }
.tip-icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--accent);
}
.tip-icon svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.hero-actions { display: grid; justify-items: center; gap: 10px; margin-top: 10px; text-align: center; }
.error { max-width: 520px; margin: 0; padding: 10px 14px; border-radius: 10px; background: color-mix(in srgb, var(--bad) 12%, transparent); color: var(--bad); font-size: 0.88rem; }
.fine { margin: 0; color: var(--muted); font-size: 0.8rem; }

/* ---------- step 2: passage ---------- */

.passage-card { position: relative; padding: 22px 28px 26px; overflow: hidden; transition: border-color 0.25s, box-shadow 0.25s; }
body[data-stage="recording"] .passage-card {
  border-color: color-mix(in srgb, var(--rec) 55%, var(--border));
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--rec) 10%, transparent), var(--shadow);
}
.passage-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; white-space: nowrap; }
.passage-meta.warn { color: var(--warn); }
body:not([data-stage="ready"]) #edit-text { visibility: hidden; }
.passage {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(1.18rem, 1rem + 0.8vw, 1.5rem);
  line-height: 1.65;
  text-wrap: pretty;
  overflow-wrap: anywhere;
}
.passage-editor textarea { display: block; resize: vertical; font-family: var(--serif); font-size: 1.05rem; line-height: 1.6; }
.editor-actions { display: flex; align-items: center; gap: 8px; margin-top: 10px; }

.countdown {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 6px;
  background: color-mix(in srgb, var(--surface) 72%, transparent);
  backdrop-filter: blur(5px);
  animation: fade 0.2s ease both;
}
.countdown-num { font-size: 4.5rem; font-weight: 750; line-height: 1; color: var(--rec); font-variant-numeric: tabular-nums; }
.countdown-num.pop { animation: pop 0.45s cubic-bezier(0.2, 0.9, 0.3, 1.3) both; }
.countdown-label { color: var(--text-2); font-size: 0.95rem; }

/* ---------- step 2: controls ---------- */

.control-row { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 16px; }

.record-card { display: grid; justify-items: center; align-content: center; gap: 6px; text-align: center; }
.record-btn {
  display: grid;
  place-items: center;
  width: 84px;
  height: 84px;
  margin-bottom: 4px;
  border: 3px solid color-mix(in srgb, var(--rec) 35%, var(--border));
  border-radius: 50%;
  background: var(--surface-2);
  cursor: pointer;
  transition: transform 0.12s, border-color 0.15s;
}
.record-btn:hover:not(:disabled) { transform: scale(1.04); border-color: var(--rec); }
.record-btn:active:not(:disabled) { transform: scale(0.97); }
.record-btn:disabled { opacity: 0.5; cursor: default; }
.record-icon {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--rec);
  transition: width 0.18s, height 0.18s, border-radius 0.18s;
}
body[data-stage="countdown"] .record-btn { border-color: var(--rec); animation: spin-ring 1s linear infinite; }
body[data-stage="recording"] .record-btn { border-color: var(--rec); animation: ring 1.4s ease-out infinite; }
body[data-stage="recording"] .record-icon,
body[data-stage="countdown"] .record-icon { width: 28px; height: 28px; border-radius: 7px; }

.timer { font-size: 1.75rem; font-weight: 650; line-height: 1.2; }
body[data-stage="recording"] .timer { color: var(--rec); }
.record-hint { min-height: 2.6em; color: var(--muted); font-size: 0.84rem; }

.monitor-card { display: grid; gap: 10px; }
.monitor-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.level-hint {
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
  text-align: right;
  transition: background 0.2s, color 0.2s;
}
.level-hint.ok { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); }
.level-hint.warn { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
.level-hint.bad { background: color-mix(in srgb, var(--bad) 14%, transparent); color: var(--bad); }

.meter-row { display: flex; align-items: flex-start; gap: 8px; }
.meter-col { flex: 1; min-width: 0; }
.meter { display: block; width: 100%; height: 18px; border-radius: 4px; }
.meter-scale { position: relative; height: 15px; color: var(--muted); font: 10px/1 var(--mono); }
.meter-scale span { position: absolute; top: 4px; transform: translateX(-50%); }
.meter-scale span:first-child { transform: none; }
.meter-scale span:last-child { transform: translateX(-100%); }
.clip-led {
  height: 18px;
  padding: 0 8px;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  background: var(--surface-2);
  color: var(--muted);
  font: 700 10px/1 var(--mono);
  cursor: pointer;
}
.clip-led.on { border-color: var(--bad); background: var(--bad); color: #fff; }

.monitor-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.monitor-stats { display: flex; flex-wrap: wrap; gap: 4px 16px; color: var(--muted); font-size: 0.84rem; }
.monitor-stats b { color: var(--text); font-weight: 600; }
.monitor-stats b.ok { color: var(--ok); }
.monitor-stats b.warn { color: var(--warn); }
.monitor-stats b.bad { color: var(--bad); }

.live-view { position: relative; height: 96px; }
.live-view canvas { position: absolute; inset: 0; width: 100%; height: 100%; border: 1px solid var(--border); border-radius: 10px; }
.live-wave { background: linear-gradient(var(--grid), var(--grid)) center / 100% 1px no-repeat, var(--scope-bg); }
.live-spec { background: #000004; }
.live-view[data-view="wave"] .live-spec,
.live-view[data-view="wave"] .spec-scale,
.live-view[data-view="spec"] .live-wave { visibility: hidden; }

.spec-scale { position: absolute; inset: 1px; pointer-events: none; }
.spec-scale span {
  position: absolute;
  right: 7px;
  transform: translateY(-50%);
  color: rgba(255, 255, 255, 0.6);
  font: 10px/1 var(--mono);
}

/* ---------- step 3: review ---------- */

.verdict {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.verdict h2 { margin: 0; font-size: 1.25rem; line-height: 1.3; }
.verdict p { margin: 2px 0 0; color: var(--text-2); font-size: 0.92rem; }
.verdict-icon { flex: none; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; }
.verdict-icon svg { width: 22px; height: 22px; }
.verdict.ok { border-color: color-mix(in srgb, var(--ok) 40%, var(--border)); background: color-mix(in srgb, var(--ok) 7%, var(--surface)); }
.verdict.ok .verdict-icon { background: var(--ok); color: var(--surface); }
.verdict.warn { border-color: color-mix(in srgb, var(--warn) 40%, var(--border)); background: color-mix(in srgb, var(--warn) 7%, var(--surface)); }
.verdict.warn .verdict-icon { background: var(--warn); color: var(--surface); }
.verdict.bad { border-color: color-mix(in srgb, var(--bad) 40%, var(--border)); background: color-mix(in srgb, var(--bad) 7%, var(--surface)); }
.verdict.bad .verdict-icon { background: var(--bad); color: var(--surface); }

.player-card { display: grid; gap: 12px; }
.player-card > *, .monitor-card > *, .checks-card > * { min-width: 0; }
.player-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
#take-meta { white-space: nowrap; }
.take-view-wrap { position: relative; }
.take-view {
  display: block;
  width: 100%;
  height: 170px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--scope-bg);
  cursor: pointer;
  touch-action: none;
}
#take-spec-scale { bottom: 19px; }
.take-view-wrap[data-view="wave"] .spec-scale { display: none; }

.player-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.player-actions { display: flex; gap: 10px; margin-left: auto; }
.play-btn {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
  cursor: pointer;
  transition: filter 0.15s, transform 0.1s;
}
.play-btn:hover { filter: brightness(1.08); }
.play-btn:active { transform: scale(0.96); }
.play-btn svg { width: 18px; height: 18px; }
.play-time { font-size: 0.95rem; }

.checks-card { display: grid; gap: 10px; }
.checks { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 20px; margin: 0; padding: 0; list-style: none; }
.check { display: flex; align-items: flex-start; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.check-icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  margin-top: 1px;
  border-radius: 50%;
  background: var(--surface-3);
  color: var(--muted);
}
.check-icon svg { width: 13px; height: 13px; }
.check.ok .check-icon { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.check.warn .check-icon { background: color-mix(in srgb, var(--warn) 20%, transparent); color: var(--warn); }
.check.bad .check-icon { background: color-mix(in srgb, var(--bad) 18%, transparent); color: var(--bad); }
.check-body { flex: 1; min-width: 0; }
.check-label { display: block; font-size: 0.9rem; font-weight: 600; }
.check-hint { display: block; color: var(--muted); font-size: 0.8rem; }
.check-value { flex: none; color: var(--text-2); font: 0.84rem/1.6 var(--mono); text-align: right; }


/* ---------- settings dialog ---------- */

.sheet {
  width: min(440px, calc(100vw - 32px));
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.35);
}
.sheet[open] { animation: rise 0.2s ease both; }
.sheet::backdrop { background: rgba(5, 8, 12, 0.5); backdrop-filter: blur(2px); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin: 0; padding: 14px 14px 6px 20px; }
.sheet-head h2 { margin: 0; font-size: 1.05rem; }
.sheet-body { padding: 8px 20px 4px; }
.sheet-foot { display: flex; justify-content: flex-end; padding: 12px 20px 18px; }

.info-list { display: grid; grid-template-columns: auto 1fr; gap: 7px 12px; margin: 4px 0 0; padding-top: 12px; border-top: 1px solid var(--border); font-size: 0.86rem; }
.info-list dt { color: var(--muted); }
.info-list dd { margin: 0; font: 0.8rem/1.7 var(--mono); text-align: right; overflow-wrap: anywhere; }
.info-list dd.ok { color: var(--ok); }
.info-list dd.warn { color: var(--warn); }
.info-list dd.bad { color: var(--bad); }
.note { margin: 12px 0 0; padding: 10px 12px; border-radius: 10px; background: color-mix(in srgb, var(--warn) 12%, transparent); color: var(--warn); font-size: 0.82rem; }

/* ---------- footer & toast ---------- */

.shortcuts { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 18px; padding: 0 16px 28px; color: var(--muted); font-size: 0.8rem; }
.shortcuts:empty { display: none; }
.shortcuts span { display: inline-flex; align-items: center; gap: 6px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 20;
  max-width: calc(100vw - 32px);
  padding: 10px 16px;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: var(--surface-3);
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 550;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translate(-50%, 12px);
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { border-color: color-mix(in srgb, var(--bad) 50%, var(--border)); color: var(--bad); }
.toast.warn { border-color: color-mix(in srgb, var(--warn) 50%, var(--border)); color: var(--warn); }

/* ---------- motion ---------- */

@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: scale(0.6); } to { opacity: 1; transform: none; } }
@keyframes blink { to { opacity: 0.3; } }
@keyframes ring {
  from { box-shadow: 0 0 0 0 color-mix(in srgb, var(--rec) 45%, transparent); }
  to { box-shadow: 0 0 0 16px transparent; }
}
@keyframes spin-ring {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--rec) 30%, transparent); }
  50% { box-shadow: 0 0 0 8px color-mix(in srgb, var(--rec) 12%, transparent); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

/* ---------- small screens ---------- */

@media (max-width: 720px) {
  .tips, .checks { grid-template-columns: minmax(0, 1fr); }
  .format-badge { display: none; }

  /* Keep the record button in reach while the passage scrolls: the row wrapper
     dissolves so the card can stick across the whole step, and it goes last. */
  .control-row { display: contents; }
  .monitor-card { order: 1; }
  .record-card {
    order: 2;
    position: sticky;
    bottom: 12px;
    z-index: 5;
    grid-template-columns: auto minmax(0, 1fr);
    justify-items: start;
    align-items: center;
    column-gap: 14px;
    row-gap: 0;
    padding: 12px 16px;
    text-align: left;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
  }
  .record-card .record-btn { grid-row: 1 / span 4; width: 62px; height: 62px; margin: 0; }
  .record-icon { width: 26px; height: 26px; }
  body[data-stage="recording"] .record-icon,
  body[data-stage="countdown"] .record-icon { width: 22px; height: 22px; border-radius: 6px; }
  .timer { font-size: 1.35rem; }
  .record-hint { min-height: 0; font-size: 0.8rem; }
  .record-hint br { display: none; }
  .toast { top: 70px; bottom: auto; transform: translate(-50%, -12px); }
  .toast.show { transform: translate(-50%, 0); }
}

@media (max-width: 520px) {
  .topbar { padding: 10px 16px; }
  .brand-name { display: none; }
  .mic-chip { max-width: 220px; }
  .app { padding: 18px 16px 28px; }
  .step-label { display: none; }
  .step.current .step-label { display: inline; }
  .passage-card { padding: 18px 18px 22px; }
  .passage-meta { display: none; }
  .player-actions { width: 100%; gap: 8px; }
  .player-actions .btn { flex: 1 1 0; min-width: 0; padding: 11px 8px; font-size: 0.92rem; }
  .player-actions .btn svg { display: none; }
}
