:root {
  --bg: #0b1220;
  --bg-soft: #121a2b;
  --card: #172136;
  --line: #24324d;
  --text: #eef3fb;
  --muted: #9fb0c9;
  --accent: #2dd4bf;
  --accent-ink: #04231f;
  --primary: #2563eb;
  --danger: #ef4444;
  --warn: #f59e0b;
  --radius: 18px;
  --tap: 64px;
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6f8fc;
    --bg-soft: #ffffff;
    --card: #ffffff;
    --line: #dbe3f0;
    --text: #0d1526;
    --muted: #5b6b85;
    --accent: #0f766e;
    --accent-ink: #ecfdf5;
    --primary: #1d4ed8;
    color-scheme: light;
  }
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

#app { max-width: 820px; margin: 0 auto; padding: 0 20px 40px; }

/* ---------------------------------------------------------------- topbar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 0 8px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; letter-spacing: .2px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 22%, transparent); }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.pill {
  font-variant-numeric: tabular-nums; font-size: 14px; color: var(--muted);
  border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px;
}
.icon-btn {
  width: 48px; height: 48px; border-radius: 14px; border: 1px solid var(--line);
  background: var(--bg-soft); color: var(--text); font-size: 20px; cursor: pointer;
}

/* ---------------------------------------------------------------- screens */
.screen { display: none; animation: fade .18s ease-out; }
.screen.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .screen { animation: none; } }

.hero { padding: 18px 0 8px; }
h1 { font-size: clamp(30px, 7vw, 44px); line-height: 1.1; margin: 6px 0 8px; }
h2 { font-size: clamp(24px, 5vw, 34px); margin: 6px 0 8px; }
.eyebrow { text-transform: uppercase; letter-spacing: .14em; font-size: 13px; color: var(--accent); margin: 0 0 6px; font-weight: 700; }
.muted { color: var(--muted); font-size: 18px; line-height: 1.45; margin: 0 0 18px; }
.hint { color: var(--muted); font-size: 15px; line-height: 1.45; }
.hint.warn { color: var(--warn); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------------------------------------------------------------- cards */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; margin: 16px 0;
}
.label { margin: 0 0 12px; font-size: 17px; font-weight: 600; }

.chips { display: flex; gap: 10px; }
.chip {
  flex: 1; min-height: 52px; border-radius: 14px; border: 1px solid var(--line);
  background: var(--bg-soft); color: var(--text); font-size: 20px; font-weight: 650; cursor: pointer;
}
.chip.selected { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

.stats-row { display: flex; gap: 12px; margin: 18px 0; }
.stat {
  flex: 1; background: var(--bg-soft); border: 1px solid var(--line); border-radius: 14px;
  padding: 14px; text-align: center;
}
.stat b { display: block; font-size: 26px; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: 14px; }

/* ---------------------------------------------------------------- buttons */
.btn {
  display: block; width: 100%; min-height: var(--tap); border-radius: 16px;
  border: 1px solid transparent; font-size: 20px; font-weight: 650;
  cursor: pointer; padding: 14px 18px; margin: 10px 0; transition: transform .06s ease;
}
.btn:active { transform: scale(.985); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-secondary { background: var(--bg-soft); color: var(--text); border-color: var(--line); }
.btn-ghost { background: transparent; color: var(--muted); border-color: var(--line); }
.btn-huge { min-height: 96px; font-size: 26px; }
.btn-small { min-height: 48px; font-size: 16px; }
.btn-record {
  min-height: 100px; font-size: 26px; background: var(--accent); color: var(--accent-ink);
  border-radius: 999px;
}
.btn-stop { min-height: 88px; font-size: 24px; background: var(--danger); color: #fff; border-radius: 999px; }
.actions { display: flex; gap: 12px; margin-top: 22px; }
.actions > .btn { flex: 1; }
.actions.column { flex-direction: column; }

/* ---------------------------------------------------------------- prompt */
.progress-bar { height: 8px; border-radius: 999px; background: var(--line); overflow: hidden; margin: 8px 0 20px; }
.progress-bar > div { height: 100%; width: 0; background: var(--accent); transition: width .25s ease; }
.prompt-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.badge {
  font-size: 14px; font-weight: 700; padding: 4px 12px; border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
}
.prompt-text {
  font-size: clamp(30px, 7vw, 46px); line-height: 1.22; font-weight: 650;
  margin: 26px 0 10px; letter-spacing: -.01em;
}
.prompt-text.small { font-size: clamp(20px, 4.4vw, 26px); font-weight: 500; color: var(--text); }

/* ---------------------------------------------------------------- recording */
.level { height: 18px; border-radius: 999px; background: var(--line); overflow: hidden; margin: 26px 0 10px; }
.level > div { height: 100%; width: 0%; background: linear-gradient(90deg, var(--accent), var(--warn)); transition: width .08s linear; }
.timer { font-size: clamp(56px, 16vw, 96px); font-weight: 700; font-variant-numeric: tabular-nums; text-align: center; margin: 18px 0 8px; }

/* ---------------------------------------------------------------- review */
audio { width: 100%; margin: 12px 0 8px; }
.qc { color: var(--muted); font-size: 16px; font-variant-numeric: tabular-nums; }

.done-emoji {
  width: 96px; height: 96px; border-radius: 50%; display: grid; place-items: center;
  background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent);
  font-size: 48px; margin: 40px auto 10px;
}

/* ---------------------------------------------------------------- form */
.form label { display: block; margin: 16px 0; font-size: 16px; color: var(--muted); }
.form input[type="text"], .form input[type="url"], .form input[type="password"],
.form input[type="number"], .form select {
  display: block; width: 100%; margin-top: 8px; min-height: 52px; padding: 12px 14px;
  border-radius: 12px; border: 1px solid var(--line); background: var(--bg-soft);
  color: var(--text); font-size: 17px;
}
.form input[type="range"] { width: 100%; margin-top: 12px; }
.form .check { display: flex; align-items: center; gap: 12px; color: var(--text); font-size: 17px; }
.form .check input { width: 26px; height: 26px; }
fieldset { border: 1px solid var(--line); border-radius: 14px; padding: 8px 16px 16px; margin: 18px 0; }
legend { padding: 0 8px; color: var(--muted); }

/* ---------------------------------------------------------------- misc */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%); background: var(--card); color: var(--text);
  border: 1px solid var(--line); border-radius: 14px; padding: 14px 20px;
  font-size: 16px; max-width: min(90vw, 520px); box-shadow: 0 12px 32px rgba(0,0,0,.35); z-index: 50;
}
