:root {
  --bg: #f5f4ef;
  --surface: #ffffff;
  --surface-2: #f0efe9;
  --text: #1c1c1e;
  --muted: #595964;
  --border: #dcdad2;
  --accent: #1d5c8a;
  --accent-ink: #ffffff;
  --accent-soft: #e3eef7;
  --danger: #a3262b;
  --danger-soft: #fbe9ea;
  --ok: #1d7a3a;
  --ok-soft: #e4f4e8;
  --warn-bg: #fff3c9;
  --warn-ink: #5a4300;
  --ph-bg: #ffe28a;
  --ph-ink: #3d2f00;
  --meter-quiet: #9fb3c4;
  --meter-good: #2f9a52;
  --meter-hot: #d79a1c;
  --meter-clip: #c8333a;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .05), 0 3px 12px rgba(0, 0, 0, .04);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Devanagari", "Nirmala UI", sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141517;
    --surface: #1d1f22;
    --surface-2: #25282c;
    --text: #ecebe6;
    --muted: #a6a6ae;
    --border: #34373c;
    --accent: #6fb0e3;
    --accent-ink: #0c1620;
    --accent-soft: #1d3446;
    --danger: #f08a8f;
    --danger-soft: #3a1f21;
    --ok: #79cf94;
    --ok-soft: #1c3324;
    --warn-bg: #3d3416;
    --warn-ink: #f3dd94;
    --ph-bg: #6b5717;
    --ph-ink: #fff3c4;
    --meter-quiet: #5a6b79;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 var(--font);
}
.wrap { max-width: 780px; margin: 0 auto; padding: 0 16px; }
.wide .wrap { max-width: 1200px; }

header.top { background: var(--surface); border-bottom: 1px solid var(--border); }
header.top .wrap { display: flex; align-items: center; gap: 12px; min-height: 56px; flex-wrap: wrap; }
.brand { font-weight: 650; letter-spacing: .01em; }
.spacer { flex: 1; }
.chip {
  display: inline-block; padding: 2px 10px; border-radius: 999px; background: var(--accent-soft);
  color: var(--accent); font-weight: 600; font-size: 14px; font-variant-numeric: tabular-nums;
}
.langs a, .langs span { margin-left: 6px; font-size: 15px; }
.langs .current { font-weight: 700; }

.rule {
  background: var(--warn-bg); color: var(--warn-ink); font-size: 14px; padding: 7px 0;
  border-bottom: 1px solid var(--border);
}
.rule strong { font-weight: 700; }

main { padding: 20px 0 48px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px; margin: 0 0 18px;
}
.card h2 { margin: 0 0 10px; font-size: 21px; }
.card h3 { margin: 18px 0 8px; font-size: 16px; }
.sheet { padding-right: 8px; }
.sheet h1 { font-size: 20px; margin: 0 0 12px; }
.sheet p { margin: 0 0 12px; }
.sheet blockquote {
  margin: 0 0 14px; padding: 10px 14px 1px; border-left: 4px solid var(--meter-hot);
  background: var(--warn-bg); color: var(--warn-ink); border-radius: 0 8px 8px 0;
}
mark.ph { background: var(--ph-bg); color: var(--ph-ink); border-radius: 3px; padding: 0 2px; }
a { color: var(--accent); }

.tick {
  display: flex; gap: 12px; align-items: flex-start; padding: 12px; margin: 0 0 10px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); cursor: pointer;
}
.tick input { width: 22px; height: 22px; margin: 2px 0 0; flex: 0 0 auto; accent-color: var(--accent); }
.tick.checked { border-color: var(--accent); background: var(--accent-soft); }
.tick.choice { cursor: default; }
.tick.choice > div { flex: 1; }
.tick.choice > button { flex: 0 0 auto; }
a.button {
  display: inline-flex; align-items: center; font-weight: 600; padding: 10px 18px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); min-height: 44px; text-decoration: none;
}
a.button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

label.field { display: block; margin: 12px 0; font-weight: 600; font-size: 15px; }
label.field input, label.field select, .field-inline select {
  display: block; width: 100%; margin-top: 5px; padding: 10px 12px; font: inherit; font-weight: 400;
  color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
}
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
@media (max-width: 600px) { .grid2 { grid-template-columns: 1fr; } }

button {
  font: inherit; font-weight: 600; padding: 10px 18px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); min-height: 44px;
}
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
button.record { background: var(--meter-clip); border-color: var(--meter-clip); color: #fff; }
button.link { border: none; background: none; color: var(--accent); padding: 10px 4px; text-decoration: underline; }
button:disabled { opacity: .45; cursor: not-allowed; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; align-items: center; }

.note { color: var(--muted); font-size: 14px; }
.error { color: var(--danger); background: var(--danger-soft); padding: 8px 12px; border-radius: 8px; }
.success { color: var(--ok); background: var(--ok-soft); padding: 8px 12px; border-radius: 8px; }
.warn { color: var(--warn-ink); background: var(--warn-bg); padding: 8px 12px; border-radius: 8px; }
.hidden, [hidden] { display: none !important; }

/* microphone */
.meter { position: relative; height: 18px; border-radius: 9px; background: var(--surface-2); border: 1px solid var(--border); overflow: hidden; }
.meter .bar { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: var(--meter-good); transition: width 60ms linear; }
.meter .bar.quiet { background: var(--meter-quiet); }
.meter .bar.hot { background: var(--meter-hot); }
.meter .bar.clip { background: var(--meter-clip); }
.meter .zone { position: absolute; top: 0; bottom: 0; border-left: 2px dashed rgba(0, 0, 0, .25); border-right: 2px dashed rgba(0, 0, 0, .25); }
.meter .hold { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--text); opacity: .6; }
.meter-row { display: flex; gap: 10px; align-items: center; }
.meter-row .meter { flex: 1; }
.meter-row .db { min-width: 82px; text-align: right; font-variant-numeric: tabular-nums; font-size: 14px; color: var(--muted); }
.settings { list-style: none; padding: 0; margin: 10px 0; display: grid; grid-template-columns: 1fr 1fr; gap: 4px 16px; font-size: 14px; }
@media (max-width: 600px) { .settings { grid-template-columns: 1fr; } }
.settings .bad { color: var(--danger); font-weight: 600; }
.settings .good { color: var(--ok); }

/* prompt card */
.badge { display: inline-block; font-size: 13px; font-weight: 700; padding: 2px 10px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.badge.read { background: var(--accent-soft); color: var(--accent); }
.badge.roleplay { background: var(--warn-bg); color: var(--warn-ink); }
.badge.extempore { background: var(--ok-soft); color: var(--ok); }
.prompt-text { font-size: 22px; line-height: 1.6; margin: 14px 0; font-weight: 500; }
:lang(hi) { font-family: "Noto Sans Devanagari", "Nirmala UI", "Kohinoor Devanagari", "Mangal", system-ui, sans-serif; }
.prompt-text:lang(hi) { font-size: 24px; line-height: 1.75; }
.prompt-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.prompt-head .script-toggle { margin-left: auto; padding: 4px; }
/* The same line in two scripts, both full size and colour so either is easy to read. */
.script-pair { margin: 14px 0; }
.script-pair .prompt-text { margin: 0; }
.script-pair > :not(:first-child) { margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--border); }
.opener-line { margin: 0; font-size: 17px; }
.twist-dev { margin-top: 6px; }
/* role-play cards read as steps */
.howto { margin: 12px 0; padding: 10px 12px; border-radius: 8px; background: var(--accent-soft); font-weight: 600; }
.call-steps { margin: 12px 0; padding-left: 24px; }
.call-steps > li { margin: 0 0 14px; }
.call-steps > li::marker { font-weight: 700; color: var(--accent); }
.step-label { display: block; font-weight: 650; margin-bottom: 4px; }
.call-steps .script-pair, .call-steps .facts, .call-steps .twist { margin: 4px 0 0; }
#take { margin: 6px 0 10px; }
#take p { margin: 0 0 6px; }
/* prompt grid */
.prompt-map { margin-top: 20px; padding-top: 12px; border-top: 1px solid var(--border); }
.prompt-map summary { cursor: pointer; font-weight: 650; }
.prompt-map summary .note { font-weight: 400; margin-left: 6px; }
.map { display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: 5px; margin: 12px 0 8px; }
.map-item { min-height: 40px; padding: 0 4px; font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
.map-item.recorded { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.map-item.recorded::after { content: " ✓"; }
.map-item.uploading { background: var(--warn-bg); color: var(--warn-ink); }
.map-item.skipped { border-style: dashed; color: var(--muted); }
.map-item.current { outline: 3px solid var(--accent); outline-offset: 1px; }
#record.recording .map-item { pointer-events: none; opacity: .45; }
.prompt-en { color: var(--muted); font-size: 15px; margin: -6px 0 12px; }
.facts { width: 100%; border-collapse: collapse; margin: 10px 0; font-size: 17px; }
.facts td { padding: 7px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
.facts td:first-child { color: var(--muted); width: 40%; font-size: 15px; }
.facts td:last-child { font-weight: 600; font-variant-numeric: tabular-nums; }
.twist { border-left: 4px solid var(--meter-hot); background: var(--warn-bg); color: var(--warn-ink); padding: 10px 12px; border-radius: 0 8px 8px 0; margin: 12px 0; }
.timer { font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; }
.timer.near { color: var(--danger); }
.progress { font-size: 14px; color: var(--muted); }
.progress-bar { height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; margin: 6px 0 14px; }
.progress-bar > div { height: 100%; width: 0; background: var(--accent); }
audio { width: 100%; margin: 10px 0; }
.steps { display: flex; gap: 6px; flex-wrap: wrap; margin: 0 0 14px; font-size: 13px; }
.steps span { padding: 3px 10px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.steps span.on { background: var(--accent); color: var(--accent-ink); }
.steps span.done { background: var(--ok-soft); color: var(--ok); }

/* tables (manage, admin) */
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th, table.data td { padding: 6px 8px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
table.data th { background: var(--surface-2); position: sticky; top: 0; }
.scroll { overflow-x: auto; max-height: 70vh; }
.stat { display: inline-block; margin: 0 22px 10px 0; }
.stat b { display: block; font-size: 26px; font-variant-numeric: tabular-nums; }
.yes { color: var(--ok); font-weight: 700; }
.no { color: var(--muted); }

footer { color: var(--muted); font-size: 13px; padding: 0 0 32px; }
