:root {
  --bg: #f4f6f8; --surface: #ffffff; --surface-2: #eef1f4; --line: #dde2e8; --text: #16202b; --muted: #637083;
  --accent: #0e8f6e; --accent-ink: #ffffff; --accent-soft: #dff3ec; --danger: #c43d3d; --danger-soft: #fbe7e7;
  --warn: #9a6a00; --warn-soft: #fff4d6; --ins: #dbeafe; --del: #fde2e2; --sub: #fff1c2;
  --radius: 14px; --shadow: 0 1px 2px rgba(16,24,40,.05), 0 4px 16px rgba(16,24,40,.06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1318; --surface: #151c23; --surface-2: #1c252e; --line: #2a3540; --text: #e5ebf1; --muted: #8d9aa8;
    --accent: #34c39b; --accent-ink: #062018; --accent-soft: #123a30; --danger: #ff7b7b; --danger-soft: #3a1c1c;
    --warn: #f0c050; --warn-soft: #3a2f12; --ins: #1d3557; --del: #4a2020; --sub: #4a3d10;
    --shadow: 0 1px 2px rgba(0,0,0,.4); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1318; --surface: #151c23; --surface-2: #1c252e; --line: #2a3540; --text: #e5ebf1; --muted: #8d9aa8;
  --accent: #34c39b; --accent-ink: #062018; --accent-soft: #123a30; --danger: #ff7b7b; --danger-soft: #3a1c1c;
  --warn: #f0c050; --warn-soft: #3a2f12; --ins: #1d3557; --del: #4a2020; --sub: #4a3d10;
  --shadow: 0 1px 2px rgba(0,0,0,.4); color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif; }
a { color: var(--accent); }
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 13px; }

.top { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 16px; background: var(--surface);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.brand { display: flex; align-items: center; gap: 10px; margin-right: auto; }
.brand svg { width: 30px; height: 30px; fill: var(--accent); }
.brand b { display: block; font-size: 16px; }
.brand small { color: var(--muted); font-size: 12px; }
.status { display: flex; gap: 6px; }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 3px 10px; border-radius: 99px;
  background: var(--surface-2); border: 1px solid var(--line); }
.pill i { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.pill.ok i { background: var(--accent); } .pill.bad i { background: var(--danger); }
.tools { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
select, input[type=password], input[type=text] { font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px; }

.btn { font: inherit; border: 1px solid transparent; border-radius: 10px; padding: 9px 16px; cursor: pointer;
  text-decoration: none; display: inline-flex; align-items: center; gap: 6px; transition: background .15s, opacity .15s; }
.btn.sm { padding: 5px 11px; font-size: 13px; }
.btn.icon { width: 34px; justify-content: center; padding: 5px 0; }
.btn.primary { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover:not(:disabled) { filter: brightness(1.07); }
.btn.ghost { background: transparent; color: var(--text); border-color: var(--line); }
.btn.ghost:hover:not(:disabled) { background: var(--surface-2); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.wrap { max-width: 1040px; margin: 0 auto; padding: 16px; display: grid; gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); min-width: 0; }
.card h2 { margin: 0; font-size: 17px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row.between { justify-content: space-between; } .row.end { justify-content: flex-end; }

.tabs { display: flex; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: 12px; margin-bottom: 14px; }
.tab { flex: 1; font: inherit; border: 0; background: transparent; color: var(--muted); padding: 8px; border-radius: 9px; cursor: pointer; }
.tab.active { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: var(--shadow); }

.recorder { display: flex; align-items: center; gap: 16px; padding: 6px 0 10px; }
.mic { width: 72px; height: 72px; border-radius: 50%; border: 0; background: var(--accent); cursor: pointer; position: relative;
  flex: none; box-shadow: 0 0 0 0 var(--accent-soft); transition: transform .15s; }
.mic span { position: absolute; inset: 0; margin: auto; width: 22px; height: 34px; border-radius: 12px; background: var(--accent-ink); }
.mic.on { background: var(--danger); animation: pulse 1.4s infinite; }
.mic.on span { width: 24px; height: 24px; border-radius: 5px; }
.mic:active { transform: scale(.96); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(196,61,61,.45); } 100% { box-shadow: 0 0 0 18px rgba(196,61,61,0); } }
.timer { font-size: 28px; font-variant-numeric: tabular-nums; font-weight: 600; }
.timer.sm { font-size: 18px; }
.wave { width: 100%; height: 64px; display: block; background: var(--surface-2); border-radius: 10px; }
.wave.clickable { cursor: pointer; }
#clipWave { height: 72px; } #streamWave { height: 48px; }

.drop { display: grid; place-items: center; gap: 4px; text-align: center; padding: 34px 16px; border: 2px dashed var(--line);
  border-radius: 12px; cursor: pointer; transition: border-color .15s, background .15s; }
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); }

.clip { margin-top: 12px; display: grid; gap: 8px; }
.clip .row { justify-content: space-between; }

.live-text { min-height: 72px; margin-top: 10px; padding: 12px; background: var(--surface-2); border-radius: 10px; white-space: pre-wrap; }
.live-text .partial { color: var(--muted); font-style: italic; }

.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 14px; }
.controls .btn.primary { margin-left: auto; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 10px; padding: 3px; flex-wrap: wrap; }
.seg button { font: inherit; font-size: 13px; border: 0; background: transparent; color: var(--muted); padding: 6px 11px; border-radius: 8px; cursor: pointer; }
.seg button.on { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: var(--shadow); }
.chk { display: inline-flex; gap: 6px; align-items: center; font-size: 13px; color: var(--muted); cursor: pointer; }

.result .text { margin-top: 10px; padding: 14px; border-radius: 10px; background: var(--surface-2); min-height: 64px;
  white-space: pre-wrap; font-size: 17px; line-height: 1.6; overflow-wrap: anywhere; }
.text.placeholder { color: var(--muted); font-size: 15px; }
.busy { display: flex; align-items: center; gap: 10px; margin-top: 10px; color: var(--muted); }
.spinner { width: 18px; height: 18px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.error { margin-top: 10px; padding: 10px 12px; border-radius: 10px; background: var(--danger-soft); color: var(--danger); }
.warn { margin-top: 10px; padding: 8px 12px; border-radius: 10px; background: var(--warn-soft); color: var(--warn); font-size: 13px; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; margin: 12px 0 0; }
.stats div { background: var(--surface-2); border-radius: 10px; padding: 8px 10px; }
.stats dt { font-size: 12px; color: var(--muted); } .stats dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.badge { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--warn-soft); color: var(--warn); margin-left: 6px; }
.badge.ok { background: var(--accent-soft); color: var(--accent); }

.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 10px; }
.compare h4 { margin: 0 0 4px; font-size: 14px; }
.compare .text { margin-top: 0; }
mark { border-radius: 4px; padding: 0 2px; color: inherit; }
mark.sub { background: var(--sub); } mark.del { background: var(--del); } mark.ins { background: var(--ins); }
.alts { margin-top: 10px; display: grid; gap: 8px; }
.alts div { font-size: 14px; padding: 8px 12px; border-left: 3px solid var(--line); }
.alts b { display: block; font-size: 12px; color: var(--muted); }
.words { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 4px; font-size: 13px; }
.words span { padding: 2px 6px; background: var(--surface-2); border-radius: 6px; cursor: pointer; }
.words span small { color: var(--muted); margin-left: 4px; }
.words span.low { background: var(--sub); }

.gpus { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; margin-top: 10px; }
.gpu { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; font-size: 13px; }
.gpu b { font-size: 14px; }
.bar { height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; margin: 6px 0; }
.bar i { display: block; height: 100%; background: var(--accent); }

dialog { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--text); padding: 0; width: min(440px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(0,0,0,.35); }
.dlg { padding: 18px; display: grid; gap: 12px; }
.dlg h3 { margin: 0; }
.dlg label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.foot { text-align: center; padding: 8px 16px 24px; }

@media (max-width: 640px) {
  .top { padding: 10px 16px; }
  .status { order: 3; width: 100%; }
  .compare { grid-template-columns: 1fr; }
  .controls .btn.primary { width: 100%; margin-left: 0; justify-content: center; }
  .mic { width: 64px; height: 64px; }
}
