/* LeadVision Speech portal */

:root {
  color-scheme: light;
  --bg: #f2f4f3;
  --surface: #ffffff;
  --surface-2: #edf0ef;
  --surface-3: #e3e8e7;
  --line: #d6dddb;
  --line-strong: #b9c4c2;
  --ink: #15222a;
  --ink-2: #44555d;
  --ink-3: #6d7d84;
  --brand: #1c5568;
  --brand-hover: #164556;
  --brand-ink: #ffffff;
  --brand-soft: #dfecef;
  --accent: #b5741a;
  --accent-soft: #fbf0dc;
  --focus: #2b7fa0;
  --ok: #276b45; --ok-soft: #e1f1e7;
  --warn: #8a5d00; --warn-soft: #faefd2;
  --err: #a8322b; --err-soft: #fbe4e1;
  --info: #255d9e; --info-soft: #e2ebf7;
  --neutral: #4f5f66; --neutral-soft: #e7ebea;
  --spk-1: #1c5568; --spk-1-bg: #dcebef;
  --spk-2: #9a5b0c; --spk-2-bg: #f9ecd6;
  --spk-3: #3d6b2f; --spk-3-bg: #e3efdc;
  --spk-4: #7a3b5c; --spk-4-bg: #f3e1ea;
  --spk-5: #2f4f9a; --spk-5-bg: #e1e8f7;
  --spk-6: #8c3a2c; --spk-6-bg: #f7e2dd;
  --spk-7: #4d5a1f; --spk-7-bg: #ecefd9;
  --spk-8: #5b4a8c; --spk-8-bg: #e9e4f5;
  --shadow: 0 1px 2px rgba(18, 34, 42, .06), 0 4px 16px rgba(18, 34, 42, .05);
  --shadow-lg: 0 10px 40px rgba(18, 34, 42, .18);
  --radius: 10px;
  --radius-sm: 6px;
  --font: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0d1518; --surface: #142026; --surface-2: #192931; --surface-3: #20323b;
    --line: #26383f; --line-strong: #375058;
    --ink: #e3ebed; --ink-2: #a7b8bd; --ink-3: #7c8f95;
    --brand: #62b2c6; --brand-hover: #7cc2d3; --brand-ink: #06222a; --brand-soft: #173843;
    --accent: #e2a94a; --accent-soft: #3a2b12; --focus: #7cc8dc;
    --ok: #6cc893; --ok-soft: #133022; --warn: #e6b955; --warn-soft: #33290e;
    --err: #f2837a; --err-soft: #3b1a17; --info: #86b3f0; --info-soft: #16273e;
    --neutral: #a7b8bd; --neutral-soft: #1f2e35;
    --spk-1: #7cc4d6; --spk-1-bg: #16343e; --spk-2: #e9b260; --spk-2-bg: #3a2b13;
    --spk-3: #93cf7e; --spk-3-bg: #1b3218; --spk-4: #e59ac0; --spk-4-bg: #3a1e2d;
    --spk-5: #9db7f5; --spk-5-bg: #1c2847; --spk-6: #f0a291; --spk-6-bg: #3d211b;
    --spk-7: #c8d47a; --spk-7-bg: #2c3115; --spk-8: #b9a8ee; --spk-8-bg: #2a2445;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .2);
    --shadow-lg: 0 10px 40px rgba(0, 0, 0, .5);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d1518; --surface: #142026; --surface-2: #192931; --surface-3: #20323b;
  --line: #26383f; --line-strong: #375058;
  --ink: #e3ebed; --ink-2: #a7b8bd; --ink-3: #7c8f95;
  --brand: #62b2c6; --brand-hover: #7cc2d3; --brand-ink: #06222a; --brand-soft: #173843;
  --accent: #e2a94a; --accent-soft: #3a2b12; --focus: #7cc8dc;
  --ok: #6cc893; --ok-soft: #133022; --warn: #e6b955; --warn-soft: #33290e;
  --err: #f2837a; --err-soft: #3b1a17; --info: #86b3f0; --info-soft: #16273e;
  --neutral: #a7b8bd; --neutral-soft: #1f2e35;
  --spk-1: #7cc4d6; --spk-1-bg: #16343e; --spk-2: #e9b260; --spk-2-bg: #3a2b13;
  --spk-3: #93cf7e; --spk-3-bg: #1b3218; --spk-4: #e59ac0; --spk-4-bg: #3a1e2d;
  --spk-5: #9db7f5; --spk-5-bg: #1c2847; --spk-6: #f0a291; --spk-6-bg: #3d211b;
  --spk-7: #c8d47a; --spk-7-bg: #2c3115; --spk-8: #b9a8ee; --spk-8-bg: #2a2445;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .2);
  --shadow-lg: 0 10px 40px rgba(0, 0, 0, .5);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 var(--font);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
[hidden] { display: none !important; }
#app { flex: 1; display: flex; flex-direction: column; min-width: 0; }
a { color: var(--brand); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--brand-hover); }
h1, h2, h3 { margin: 0; line-height: 1.25; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.1rem; }
h3 { font-size: .95rem; }
p { margin: 0; }
code, .mono { font-family: var(--mono); font-size: .88em; }
.num, td, .tabular { font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-3); }
.small { font-size: .85rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
::selection { background: var(--brand-soft); }

/* ---------- header ---------- */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.topbar-inner {
  max-width: 1240px; margin: 0 auto; padding: 0 20px;
  display: flex; align-items: center; gap: 20px; min-height: 60px;
}
.mark { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); flex-shrink: 0; }
.mark:hover { color: var(--ink); }
.mark-glyph { width: 28px; height: 28px; flex-shrink: 0; }
.mark-name { font-weight: 600; font-size: 1.05rem; letter-spacing: -.01em; }
.mark-name span { color: var(--ink-3); font-weight: 400; }
.model-pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--mono); font-size: .75rem; color: var(--ink-2);
  border: 1px solid var(--line); border-radius: 999px; padding: 2px 9px 2px 7px;
  background: var(--surface-2); white-space: nowrap;
}
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-3); flex-shrink: 0; }
.dot.ok { background: var(--ok); }
.dot.warn { background: var(--warn); }
.dot.err { background: var(--err); }
.nav { display: flex; gap: 2px; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a {
  color: var(--ink-2); text-decoration: none; padding: 7px 11px; border-radius: var(--radius-sm);
  font-size: .92rem; white-space: nowrap;
}
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a[aria-current="page"] { color: var(--brand); background: var(--brand-soft); font-weight: 500; }
.nav .sep { width: 1px; background: var(--line); margin: 8px 6px; flex-shrink: 0; }
.userbox { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.userbox .who { text-decoration: none; color: inherit; padding: 2px 6px; border-radius: var(--radius-sm); }
.userbox .who:hover { background: var(--surface-2); color: inherit; }
.userbox .who { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.2; }
.userbox .who b { font-weight: 500; font-size: .9rem; }
.userbox .who small { color: var(--ink-3); font-size: .75rem; text-transform: capitalize; }

/* ---------- layout ---------- */
main { flex: 1; width: 100%; max-width: 1240px; margin: 0 auto; padding: 28px 20px 48px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head .sub { color: var(--ink-2); margin-top: 4px; }
.crumb { font-size: .85rem; margin-bottom: 6px; display: inline-flex; gap: 6px; align-items: center; }
.crumb a { text-decoration: none; color: var(--ink-3); }
.crumb a:hover { color: var(--brand); }
.footer { color: var(--ink-3); font-size: .82rem; text-align: center; padding: 18px 16px 24px; border-top: 1px solid var(--line); }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-pad { padding: 20px; }
.section-title { display: flex; align-items: baseline; gap: 10px; margin-bottom: 12px; }
.section-title .step {
  font-family: var(--mono); font-size: .75rem; color: var(--brand); border: 1px solid var(--brand);
  border-radius: 999px; width: 22px; height: 22px; display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0; align-self: center;
}

/* ---------- buttons & inputs ---------- */
.btn {
  appearance: none; display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font: inherit; font-size: .9rem; font-weight: 500; line-height: 1;
  padding: 9px 14px; border-radius: var(--radius-sm); cursor: pointer; text-decoration: none;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  min-height: 36px; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); color: var(--ink); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); color: var(--brand-ink); }
.btn.danger { color: var(--err); border-color: color-mix(in srgb, var(--err) 45%, var(--line)); }
.btn.danger:hover { background: var(--err-soft); }
.btn.danger.solid { background: var(--err); color: #fff; border-color: var(--err); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn.sm { padding: 6px 10px; min-height: 30px; font-size: .84rem; }
.btn.icon { padding: 0; width: 34px; min-height: 34px; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; pointer-events: none; }
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }

label.field { display: flex; flex-direction: column; gap: 6px; font-size: .88rem; color: var(--ink-2); font-weight: 500; }
label.field .hint { font-weight: 400; color: var(--ink-3); font-size: .8rem; }
input[type="text"], input[type="password"], input[type="search"], select, textarea {
  font: inherit; font-size: .93rem; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  padding: 8px 10px; min-height: 38px; width: 100%;
}
textarea { min-height: 220px; resize: vertical; font-family: var(--mono); font-size: .85rem; line-height: 1.55; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--focus); outline-offset: 0; border-color: var(--focus); }
input[readonly] { background: var(--surface-2); color: var(--ink-2); }
select { cursor: pointer; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 640px) { .grid-2 { grid-template-columns: 1fr; } }

/* switch */
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: .92rem; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track {
  width: 34px; height: 20px; border-radius: 999px; background: var(--surface-3); border: 1px solid var(--line-strong);
  position: relative; flex-shrink: 0; transition: background .15s;
}
.switch .track::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%;
  background: var(--surface); box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .15s;
}
.switch input:checked + .track { background: var(--brand); border-color: var(--brand); }
.switch input:checked + .track::after { transform: translateX(14px); }
.switch input:focus-visible + .track { outline: 2px solid var(--focus); outline-offset: 2px; }
.switch input:disabled + .track { opacity: .45; }
.switch.disabled { cursor: not-allowed; color: var(--ink-3); }
.checkline { display: inline-flex; gap: 8px; align-items: center; font-size: .92rem; cursor: pointer; }
.checkline input { width: 16px; height: 16px; accent-color: var(--brand); }

/* ---------- chips ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 6px; font-size: .78rem; font-weight: 500; line-height: 1;
  padding: 4px 9px; border-radius: 999px; white-space: nowrap;
  background: var(--neutral-soft); color: var(--neutral);
}
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.err { background: var(--err-soft); color: var(--err); }
.chip.info { background: var(--info-soft); color: var(--info); }
.chip.brand { background: var(--brand-soft); color: var(--brand); }
.chip.outline { background: transparent; border: 1px solid var(--line-strong); color: var(--ink-2); }
.chip .pulse { width: 6px; height: 6px; border-radius: 50%; background: currentColor; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .25; } }
@media (prefers-reduced-motion: reduce) { .chip .pulse { animation: none; } }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius); }
table.data { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.data th {
  text-align: left; font-weight: 500; color: var(--ink-3); font-size: .78rem; text-transform: uppercase; letter-spacing: .04em;
  padding: 11px 14px; border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap;
}
table.data td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; white-space: nowrap; }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr.clickable { cursor: pointer; }
table.data tbody tr.clickable:hover td { background: var(--surface-2); }
table.data td.wrap { white-space: normal; min-width: 180px; }
table.data td.right, table.data th.right { text-align: right; }
table.data td.actions { text-align: right; }
table.data td.actions .row { justify-content: flex-end; flex-wrap: nowrap; }
.cell-main { font-weight: 500; color: var(--ink); text-decoration: none; }
a.cell-main:hover { color: var(--brand); text-decoration: underline; }
.cell-sub { color: var(--ink-3); font-size: .8rem; }
.progress { display: flex; align-items: center; gap: 10px; min-width: 150px; }
.bar { flex: 1; height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; display: flex; min-width: 70px; }
.bar > span { display: block; height: 100%; background: var(--ok); transition: width .3s; }
.bar > span.fail { background: var(--err); }
.bar > span.up { background: var(--brand); }

/* ---------- filters ---------- */
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 14px; }
.filters label.field { min-width: 160px; flex: 1 1 160px; }
.filters .grow { flex: 3 1 220px; min-width: 200px; }
.pager { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-top: 1px solid var(--line); gap: 10px; flex-wrap: wrap; }

/* ---------- empty / notice ---------- */
.empty { text-align: center; padding: 48px 20px; color: var(--ink-2); }
.empty h3 { font-size: 1rem; color: var(--ink); margin-bottom: 6px; }
.empty .btn { margin-top: 14px; }
.notice { border-radius: var(--radius-sm); padding: 10px 14px; font-size: .9rem; display: flex; gap: 10px; align-items: flex-start; }
.notice.err { background: var(--err-soft); color: var(--err); }
.notice.warn { background: var(--warn-soft); color: var(--warn); }
.notice.info { background: var(--info-soft); color: var(--info); }
.skeleton { height: 14px; border-radius: 4px; background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- login ---------- */
.login-wrap { flex: 1; display: grid; place-items: center; padding: 32px 16px; }
.login-card { width: 100%; max-width: 380px; padding: 30px 28px; }
.login-card .mark { margin-bottom: 22px; }
.login-card h1 { font-size: 1.25rem; margin-bottom: 4px; }
.login-card form { display: flex; flex-direction: column; gap: 14px; margin-top: 20px; }
.login-card .btn { width: 100%; min-height: 40px; }

/* ---------- new transcription ---------- */
.uc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.uc-card {
  text-align: left; font: inherit; color: inherit; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; position: relative;
  transition: border-color .12s, box-shadow .12s;
}
.uc-card:hover { border-color: var(--line-strong); }
.uc-card[aria-checked="true"] { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand) inset; background: color-mix(in srgb, var(--brand-soft) 45%, var(--surface)); }
.uc-card[aria-checked="true"]::after {
  content: ""; position: absolute; top: 14px; right: 14px; width: 16px; height: 16px; border-radius: 50%;
  background: var(--brand) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4.5 8.2l2.2 2.2 4.8-4.8' fill='none' stroke='white' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/16px no-repeat;
}
.uc-card[disabled] { opacity: .55; cursor: not-allowed; }
.uc-card .uc-name { font-weight: 600; padding-right: 22px; }
.uc-card .uc-desc { color: var(--ink-2); font-size: .84rem; }
.uc-card .uc-badges { display: flex; gap: 5px; flex-wrap: wrap; }
.uc-card .uc-badges .chip { font-size: .72rem; padding: 3px 7px; }
.chan-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 3px; font-size: .8rem; color: var(--ink-2); }
.chan-list li { display: flex; gap: 6px; align-items: baseline; }
.chan-list .chan-n { font-family: var(--mono); font-size: .72rem; color: var(--ink-3); min-width: 32px; }

.dropzone {
  border: 1.5px dashed var(--line-strong); border-radius: var(--radius); padding: 28px 18px; text-align: center;
  background: var(--surface-2); cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 6px;
  transition: border-color .12s, background .12s;
}
.dropzone:hover, .dropzone.over { border-color: var(--brand); background: var(--brand-soft); }
.dropzone:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }
.dropzone svg { width: 30px; height: 30px; color: var(--brand); }
.dropzone b { font-weight: 600; }
.dropzone input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.file-list { list-style: none; margin: 12px 0 0; padding: 0; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.file-list li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 9px 12px; border-bottom: 1px solid var(--line); background: var(--surface); }
.file-list li:last-child { border-bottom: 0; }
.file-list .fname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .9rem; }
.file-list .fmeta { color: var(--ink-3); font-size: .8rem; }
.file-list .fstate { display: flex; align-items: center; gap: 10px; min-width: 150px; justify-content: flex-end; font-size: .8rem; color: var(--ink-2); }
.file-list .fstate .bar { width: 90px; flex: none; }
.file-list .fstate.err { color: var(--err); }
.file-sum { display: flex; justify-content: space-between; margin-top: 8px; color: var(--ink-3); font-size: .82rem; }

details.adv { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
details.adv > summary { cursor: pointer; padding: 13px 16px; display: flex; gap: 10px; align-items: center; list-style: none; font-weight: 500; }
details.adv > summary::-webkit-details-marker { display: none; }
details.adv > summary::before { content: ""; width: 8px; height: 8px; border-right: 1.5px solid var(--ink-3); border-bottom: 1.5px solid var(--ink-3); transform: rotate(-45deg); transition: transform .15s; margin-right: 2px; }
details.adv[open] > summary::before { transform: rotate(45deg); }
details.adv > summary .chip { margin-left: auto; }
.adv-body { padding: 4px 16px 18px; display: flex; flex-direction: column; gap: 18px; border-top: 1px solid var(--line); }
.adv-body h3 { margin: 14px 0 8px; color: var(--ink-2); font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; font-weight: 500; }
.chan-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.chan-table td, .chan-table th { padding: 7px 8px; text-align: left; border-bottom: 1px solid var(--line); }
.chan-table th { font-size: .76rem; color: var(--ink-3); font-weight: 500; text-transform: uppercase; letter-spacing: .04em; }
.chan-table select { min-width: 140px; width: auto; }
.opt-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px 22px; align-items: start; }
.opt { display: flex; flex-direction: column; gap: 4px; }
.opt .hint { color: var(--ink-3); font-size: .8rem; padding-left: 44px; }
.submit-bar { display: flex; align-items: center; gap: 14px; justify-content: flex-end; flex-wrap: wrap; }

/* ---------- batch / detail ---------- */
.meta-grid { margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px 20px; }
.meta-grid dt { font-size: .76rem; color: var(--ink-3); text-transform: uppercase; letter-spacing: .04em; }
.meta-grid dd { margin: 3px 0 0; font-weight: 500; overflow-wrap: anywhere; }
.meta-grid dd.mono { font-weight: 400; }
.stat-row { display: flex; gap: 22px; flex-wrap: wrap; }
.stat b { font-size: 1.35rem; font-weight: 600; display: block; font-variant-numeric: tabular-nums; }
.stat span { font-size: .78rem; color: var(--ink-3); }
.err-text { color: var(--err); font-size: .8rem; white-space: normal; }

/* ---------- transcript viewer ---------- */
.player-card { position: sticky; top: calc(var(--header-h, 61px) + 8px); z-index: 10; padding: 14px 16px; }
.player-card audio { width: 100%; height: 40px; display: block; }
.player-controls { display: flex; gap: 8px; align-items: center; margin-top: 10px; flex-wrap: wrap; }
.player-controls .now { font-family: var(--mono); font-size: .82rem; color: var(--ink-2); }
.player-controls select { width: auto; min-height: 30px; padding: 4px 8px; font-size: .84rem; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.toolbar input[type="search"] { max-width: 280px; }
.legend { display: flex; gap: 6px; flex-wrap: wrap; padding: 10px 14px; border-bottom: 1px solid var(--line); align-items: center; }
.legend .chip { cursor: pointer; border: 1px solid transparent; font: inherit; font-size: .78rem; font-weight: 500; }
.legend .chip[aria-pressed="false"] { opacity: .45; text-decoration: line-through; }
.segs { list-style: none; margin: 0; padding: 4px 0; }
.seg {
  display: grid; grid-template-columns: 56px 118px minmax(0, 1fr); gap: 12px; align-items: baseline;
  padding: 9px 14px; cursor: pointer; border-left: 3px solid transparent;
}
.seg:hover { background: var(--surface-2); }
.seg.active { background: var(--accent-soft); border-left-color: var(--accent); }
.seg .t { font-family: var(--mono); font-size: .8rem; color: var(--ink-3); }
.seg.active .t { color: var(--accent); font-weight: 500; }
.seg .txt { line-height: 1.55; overflow-wrap: anywhere; }
.seg mark { background: color-mix(in srgb, var(--accent) 35%, transparent); color: inherit; border-radius: 2px; padding: 0 1px; }
.spk { justify-self: start; }
.spk-1 { background: var(--spk-1-bg); color: var(--spk-1); }
.spk-2 { background: var(--spk-2-bg); color: var(--spk-2); }
.spk-3 { background: var(--spk-3-bg); color: var(--spk-3); }
.spk-4 { background: var(--spk-4-bg); color: var(--spk-4); }
.spk-5 { background: var(--spk-5-bg); color: var(--spk-5); }
.spk-6 { background: var(--spk-6-bg); color: var(--spk-6); }
.spk-7 { background: var(--spk-7-bg); color: var(--spk-7); }
.spk-8 { background: var(--spk-8-bg); color: var(--spk-8); }
@media (max-width: 640px) {
  .seg { grid-template-columns: auto minmax(0, 1fr); gap: 4px 10px; }
  .seg .txt { grid-column: 1 / -1; }
}

/* ---------- admin ---------- */
.vocab-layout { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 820px) { .vocab-layout { grid-template-columns: 1fr; } }
.brand-list { list-style: none; margin: 0; padding: 6px; }
.brand-list button {
  width: 100%; text-align: left; font: inherit; color: inherit; background: transparent; border: 0; cursor: pointer;
  padding: 10px 12px; border-radius: var(--radius-sm); display: flex; flex-direction: column; gap: 2px;
}
.brand-list button:hover { background: var(--surface-2); }
.brand-list button[aria-current="true"] { background: var(--brand-soft); }
.brand-list button[aria-current="true"] b { color: var(--brand); }
.brand-list b { font-weight: 500; }
.brand-list span { font-size: .8rem; color: var(--ink-3); }
.uc-admin-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.uc-admin { padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; }
.uc-admin dl { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 6px 12px; margin: 0; font-size: .86rem; }
.uc-admin dt { color: var(--ink-3); }
.uc-admin dd { margin: 0; }

/* ---------- dialog ---------- */
dialog {
  border: 1px solid var(--line); border-radius: 12px; padding: 0; background: var(--surface); color: var(--ink);
  box-shadow: var(--shadow-lg); width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 32px);
}
dialog::backdrop { background: rgba(10, 20, 25, .45); }
dialog form { display: flex; flex-direction: column; max-height: calc(100vh - 34px); }
.dlg-head { padding: 18px 20px 6px; }
.dlg-head p { color: var(--ink-2); font-size: .9rem; margin-top: 4px; }
.dlg-body { padding: 12px 20px; display: flex; flex-direction: column; gap: 14px; overflow-y: auto; }
.dlg-foot { padding: 14px 20px 18px; display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; border-top: 1px solid var(--line); margin-top: 6px; }
dialog.wide { width: min(760px, calc(100vw - 24px)); }

/* ---------- toasts ---------- */
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 100; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 32px)); }
.toast {
  background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-left: 4px solid var(--info);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); padding: 11px 12px 11px 14px; font-size: .9rem;
  display: flex; gap: 10px; align-items: flex-start; animation: toast-in .18s ease-out;
}
.toast.ok { border-left-color: var(--ok); }
.toast.err { border-left-color: var(--err); }
.toast p { flex: 1; }
.toast button { background: none; border: 0; color: var(--ink-3); cursor: pointer; font-size: 1.1rem; line-height: 1; padding: 0 2px; }
@keyframes toast-in { from { transform: translateY(6px); opacity: 0; } }

/* ---------- misc ---------- */
main:focus { outline: none; }
.skip { position: absolute; left: 12px; top: -48px; z-index: 50; background: var(--brand); color: var(--brand-ink); padding: 8px 12px; border-radius: var(--radius-sm); text-decoration: none; }
.skip:focus { top: 10px; color: var(--brand-ink); }
.login-model { margin-top: 22px; display: flex; justify-content: center; }
.fcell { min-width: 0; }
.meta-grid .span-2 { grid-column: span 2; }

.narrow { max-width: 480px; }
.card-title { margin-bottom: 14px; }
.label-row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.label-row .count { font-weight: 400; color: var(--ink-3); font-size: .8rem; }
textarea.short { min-height: 110px; }
.add-chan { margin-top: 8px; }
fieldset.group { border: 0; padding: 0; margin: 0; min-width: 0; }
fieldset.group legend { padding: 0; margin-bottom: 8px; font-size: .88rem; color: var(--ink-2); font-weight: 500; }
.stack.tight { gap: 10px; }
.page-title { min-width: 0; }
.page-title h1 { overflow-wrap: anywhere; }
noscript p { padding: 24px; }

/* ---------- small screens ---------- */
@media (max-width: 1080px) {
  .topbar-inner { flex-wrap: wrap; gap: 4px 14px; padding: 10px 20px 0; min-height: 0; }
  .nav { order: 3; flex-basis: 100%; margin: 0 -8px; padding-bottom: 6px; }
  .userbox { margin-left: auto; }
}
@media (max-width: 760px) {
  .topbar-inner { padding: 8px 16px 0; gap: 4px 10px; }
  .mark-name span { display: none; }
  .userbox .who { display: none; }
  main { padding: 20px 16px 40px; }
  .player-card { top: 0; position: relative; }
  .model-pill .label-long { display: none; }
}
@media (max-width: 480px) {
  .topbar-inner > .mark { order: 1; }
  .topbar-inner > .userbox { order: 2; }
  .topbar-inner > .model-pill { order: 3; font-size: .68rem; padding: 1px 8px 1px 6px; }
  .topbar-inner > .nav { order: 4; }
  .meta-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
