:root {
  --bg: #f6f6f4;
  --surface: #ffffff;
  --surface-2: #f0f0ed;
  --text: #1c1c1a;
  --muted: #6b6b66;
  --border: #e2e2dd;
  --accent: #2f6fde;
  --accent-text: #ffffff;
  --rec: #e5484d;
  --mic-a: #2f6fde;
  --mic-b: #c2410c;
  --ok: #1f8a4c;
  --warn: #b26a00;
  --err: #c7362f;
  --info-bg: #eef3fc;
  --warn-bg: #fdf4e3;
  --err-bg: #fcecea;
  --meter-bg: #e7e7e2;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 2px 8px rgba(0, 0, 0, .04);
  --radius: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141413; --surface: #1d1d1b; --surface-2: #262624; --text: #ececea; --muted: #9c9c96;
    --border: #33332f; --accent: #6b9cf2; --accent-text: #0e1420; --rec: #f0595e;
    --mic-a: #6b9cf2; --mic-b: #f08a4b; --ok: #4cc283; --warn: #e8a93c; --err: #f07067;
    --info-bg: #1b2433; --warn-bg: #2e2514; --err-bg: #331c1a; --meter-bg: #2c2c29;
    --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #141413; --surface: #1d1d1b; --surface-2: #262624; --text: #ececea; --muted: #9c9c96;
  --border: #33332f; --accent: #6b9cf2; --accent-text: #0e1420; --rec: #f0595e;
  --mic-a: #6b9cf2; --mic-b: #f08a4b; --ok: #4cc283; --warn: #e8a93c; --err: #f07067;
  --info-bg: #1b2433; --warn-bg: #2e2514; --err-bg: #331c1a; --meter-bg: #2c2c29;
  --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
code { font: 0.9em ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 650; font-size: 16px; }
.brand svg { width: 22px; height: 22px; }
.brand rect { fill: var(--rec); }
.brand path { stroke: var(--rec); stroke-width: 2.5; fill: none; stroke-linecap: round; }
.pill {
  font-size: 13px; padding: 3px 10px; border-radius: 999px;
  background: var(--surface-2); color: var(--muted); white-space: nowrap;
}
.pill.ready { color: var(--ok); }
.pill.rec { background: var(--rec); color: #fff; }
.pill.busy { color: var(--accent); }

main { max-width: 820px; margin: 0 auto; padding: 20px 16px 8px; display: grid; gap: 16px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow); min-width: 0;
}
.card h2 { margin: 0 0 8px; font-size: 18px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.card p { margin: 6px 0 12px; }
.num {
  display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%;
  background: var(--surface-2); font-size: 13px; color: var(--muted);
}
.aside { font-size: 12px; font-weight: 500; color: var(--muted); }
.sub { font-size: 14px; margin: 16px 0 6px; color: var(--muted); font-weight: 600; }
.hint { color: var(--muted); font-size: 13px; }
.muted { color: var(--muted); }

.row { display: flex; gap: 10px; align-items: center; margin: 12px 0; }
.row.wrap { flex-wrap: wrap; }
.btn {
  appearance: none; border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  font: inherit; font-weight: 550; padding: 8px 14px; border-radius: 8px; cursor: pointer;
  text-decoration: none; display: inline-flex; align-items: center; gap: 6px; min-height: 38px;
}
.btn:hover:not(:disabled) { border-color: var(--muted); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--err); }
.btn:focus-visible, .select:focus-visible, .name:focus-visible, .rec-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.select, .name {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 7px 10px; min-height: 38px; max-width: 100%;
}
.select { width: 100%; }
.select.small { width: auto; }
.field { display: inline-flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.field-error { color: var(--err); font-size: 14px; }

.callout { border-radius: 10px; padding: 10px 14px; margin: 12px 0; font-size: 14px; }
.callout.info { background: var(--info-bg); }
.callout.warn { background: var(--warn-bg); }
.callout.error { background: var(--err-bg); }

/* Mics */
.mic-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 4px; }
.mic { border: 1px solid var(--border); border-radius: 10px; padding: 12px; display: grid; gap: 10px; min-width: 0; }
.mic-head { display: flex; align-items: center; gap: 8px; }
.mic-head .name { flex: 1; min-width: 0; font-weight: 600; }
.tag {
  display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 6px;
  font-size: 13px; font-weight: 700; color: #fff; flex: none;
}
.tag.a { background: var(--mic-a); }
.tag.b { background: var(--mic-b); }

.meter { position: relative; height: 14px; border-radius: 4px; background: var(--meter-bg); overflow: hidden; }
.meter.slim { height: 8px; }
/* Scale: −60 dB … 0 dB. Green to −18, amber to −6, red above. */
.meter .fill {
  position: absolute; inset: 0;
  background: linear-gradient(90deg, var(--ok) 0 70%, var(--warn) 70% 90%, var(--err) 90%);
  clip-path: inset(0 100% 0 0);
}
.meter .hold { position: absolute; top: 0; bottom: 0; width: 2px; left: 0; background: var(--text); opacity: .55; }
.meter-meta { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.clip { font-size: 11px; font-weight: 700; padding: 0 6px; border-radius: 4px; color: var(--muted); opacity: .4; }
.clip.on { background: var(--err); color: #fff; opacity: 1; }
.clip.inline { display: inline-block; }

.checklist { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 4px; font-size: 14px; }
.checklist li { display: flex; gap: 8px; align-items: baseline; }
.checklist .ic { flex: none; width: 16px; text-align: center; font-weight: 700; }
.checklist .ok .ic { color: var(--ok); }
.checklist .warn .ic { color: var(--warn); }
.checklist .bad .ic { color: var(--err); }
.checklist .info .ic { color: var(--muted); }

.tips { margin-top: 14px; font-size: 14px; }
.tips summary { cursor: pointer; font-weight: 600; }
.tips ul { margin: 8px 0 0; padding-left: 20px; display: grid; gap: 4px; }

/* Progress */
.progress-line { display: flex; align-items: center; gap: 10px; margin: 10px 0; font-size: 14px; }
.bar { flex: 1; height: 6px; background: var(--meter-bg); border-radius: 3px; overflow: hidden; min-width: 60px; }
.bar span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }

/* Results */
.result { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; margin-top: 12px; }
.result .verdict { font-weight: 600; margin: 0 0 8px; }
.result .verdict.good { color: var(--ok); }
.result .verdict.warn { color: var(--warn); }
.result .verdict.bad { color: var(--err); }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 0; font-size: 14px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-variant-numeric: tabular-nums; min-width: 0; }

/* Record */
.rec-row { display: flex; align-items: center; gap: 18px; margin: 8px 0 14px; }
.rec-btn {
  appearance: none; border: 2px solid var(--border); background: var(--surface); color: var(--text);
  border-radius: 999px; padding: 10px 22px 10px 14px; font: inherit; font-size: 16px; font-weight: 650;
  display: inline-flex; align-items: center; gap: 10px; cursor: pointer; min-height: 52px;
}
.rec-btn:disabled { opacity: .45; cursor: not-allowed; }
.rec-btn .dot { width: 22px; height: 22px; border-radius: 50%; background: var(--rec); transition: border-radius .15s; }
.rec-btn.on { border-color: var(--rec); }
.rec-btn.on .dot { border-radius: 4px; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .55; } }
@media (prefers-reduced-motion: reduce) { .rec-btn.on .dot { animation: none; } }
.timer { font-size: 28px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: .5px; }

.mini-meters { display: grid; gap: 8px; }
.mini { display: grid; grid-template-columns: 24px minmax(0, 110px) 1fr; align-items: center; gap: 10px; font-size: 14px; }
.mini-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.events { list-style: none; margin: 0; padding: 0; font-size: 14px; display: grid; gap: 4px; max-height: 220px; overflow-y: auto; }
.events li { display: grid; grid-template-columns: 64px 1fr; gap: 8px; }
.events li.muted { display: block; }
.events time { color: var(--muted); font-variant-numeric: tabular-nums; }
.events .warn { color: var(--warn); }
.events .error { color: var(--err); }

.stages { display: grid; gap: 8px; margin: 8px 0; }
.stage { display: grid; grid-template-columns: minmax(0, 260px) 1fr; align-items: center; gap: 12px; font-size: 14px; color: var(--muted); }
.stage.active { color: var(--text); font-weight: 550; }
.stage.done { color: var(--ok); }
.stage.done .bar span { background: var(--ok); }

.stored-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.stored-list li {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: space-between;
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; font-size: 14px;
}
.stored-list .meta { color: var(--muted); }

.foot { text-align: center; color: var(--muted); font-size: 12px; padding: 16px; }

@media (max-width: 600px) {
  .mic-grid { grid-template-columns: 1fr; }
  .card { padding: 16px; }
  .stage { grid-template-columns: 1fr; gap: 4px; }
  .facts { grid-template-columns: 1fr; gap: 0 0; }
  .facts dd { margin-bottom: 6px; }
  .timer { font-size: 24px; }
}

/* Podcast polish */
.psteps { list-style: none; margin: 12px 0; padding: 0; display: grid; gap: 2px; }
.pstep { padding: 10px 12px; border-radius: 10px; border: 1px solid transparent; }
.pstep label { display: flex; align-items: center; gap: 8px; font-weight: 600; cursor: pointer; }
.pstep.always label { cursor: default; }
.pstep input[type="checkbox"] { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); flex: none; }
.pstep .ic { display: none; width: 16px; flex: none; text-align: center; font-weight: 700; }
.pdesc { margin: 4px 0 0 24px !important; font-size: 13px; color: var(--muted); }
.presult { margin: 6px 0 0 24px !important; font-size: 13px; font-variant-numeric: tabular-nums; }
.pstep.off .ptitle, .pstep.off .pdesc { opacity: .55; }
.psteps.running input[type="checkbox"], .psteps.finished input[type="checkbox"] { display: none; }
.psteps.running .ic, .psteps.finished .ic { display: inline-block; }
.pstep.working { background: var(--info-bg); }
.pstep.working .ic::before { content: "…"; color: var(--accent); }
.pstep.done .ic::before { content: "✓"; color: var(--ok); }
.pstep.done .presult { color: var(--text); }
.pstep.skipped .ic::before { content: "–"; color: var(--muted); }
.pstep.skipped .presult { color: var(--muted); }
.select.inline { display: inline-block; width: auto; max-width: 100%; padding: 2px 6px; font-size: 13px; margin: 2px 0; }
.seg { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; margin: 4px 0 4px; }
.seg label { display: flex; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { padding: 7px 14px; font-size: 14px; cursor: pointer; color: var(--muted); }
.seg input:checked + span { background: var(--accent); color: var(--accent-text); }
.seg input:disabled + span { cursor: not-allowed; opacity: .5; }
.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: -2px; }
