/* LinguaFlow — production UI
   Dark charcoal surfaces, one indigo accent, restrained status colours. */

:root {
  --bg: #0f1012;
  --bg-rail: #121316;
  --surface: #16171b;
  --surface-2: #1b1d22;
  --surface-3: #22242a;
  --hover: #26282f;
  --border: #25272d;
  --border-2: #30333a;
  --text: #e9eaee;
  --text-2: #a9acb6;
  --text-3: #70747f;
  --accent: #8b95ff;
  --accent-2: #a9b0ff;
  --accent-ink: #0f1012;
  --accent-bg: rgba(139, 149, 255, 0.12);
  --accent-line: rgba(139, 149, 255, 0.45);
  --ok: #52c08d;
  --ok-bg: rgba(82, 192, 141, 0.12);
  --warn: #e4a54b;
  --warn-bg: rgba(228, 165, 75, 0.13);
  --danger: #ee6b5c;
  --danger-bg: rgba(238, 107, 92, 0.13);
  --neutral-bg: rgba(169, 172, 182, 0.12);
  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 0 rgba(255,255,255,0.03) inset, 0 8px 24px rgba(0,0,0,0.28);
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --top-h: 52px;
  --rail-w: 208px;
  --bottom-h: 0px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  font-feature-settings: "cv11", "ss01";
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
a { color: var(--accent-2); }
::selection { background: rgba(139,149,255,.35); }
.mono { font-family: var(--mono); font-feature-settings: "zero"; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.i { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.i.sm { width: 15px; height: 15px; }
.i.lg { width: 22px; height: 22px; }
.spin { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Scrollbars ---------- */
* { scrollbar-width: thin; scrollbar-color: #33363d transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: #2c2f36; border-radius: 10px; border: 3px solid var(--bg); }
*::-webkit-scrollbar-track { background: transparent; }

/* ---------- Buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; padding: 0 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-2); background: var(--surface-2); color: var(--text);
  font-weight: 500; font-size: 13.5px; white-space: nowrap; user-select: none;
  transition: background .15s, border-color .15s, color .15s, opacity .15s;
}
.btn:hover { background: var(--hover); border-color: #3a3d45; }
.btn:active { transform: translateY(0.5px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-3); color: var(--text); }
.btn.outline { background: transparent; }
.btn.danger { background: transparent; border-color: rgba(238,107,92,.45); color: var(--danger); }
.btn.danger:hover { background: var(--danger-bg); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 12.5px; gap: 6px; }
.btn.lg { height: 44px; padding: 0 20px; font-size: 14.5px; }
.btn.block { width: 100%; }
.btn .i { width: 16px; height: 16px; }
.btn.sm .i { width: 14px; height: 14px; }

.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: var(--radius-sm);
  border: 1px solid transparent; background: transparent; color: var(--text-2); transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn.sm { width: 30px; height: 30px; }
.icon-btn.sm .i { width: 15px; height: 15px; }
.icon-btn.active { color: var(--accent-2); background: var(--accent-bg); }
.icon-btn:disabled { opacity: .35; cursor: not-allowed; }

.input, .select, .textarea {
  width: 100%; height: 38px; padding: 0 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-2); background: var(--bg); color: var(--text); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.textarea { height: auto; padding: 9px 12px; resize: vertical; min-height: 70px; line-height: 1.5; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-bg); }
.select { appearance: none; padding-right: 32px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23a9acb6' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 11px center; }
.input.sm, .select.sm { height: 32px; font-size: 13px; }
.field { display: grid; gap: 6px; }
.field > label, .label { font-size: 12px; font-weight: 500; color: var(--text-2); letter-spacing: .01em; }
.hint { font-size: 12px; color: var(--text-3); line-height: 1.45; }
.input-group { display: flex; gap: 6px; align-items: center; }
.input-group .input { flex: 1; }

.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { width: 34px; height: 20px; border-radius: 20px; background: var(--surface-3); border: 1px solid var(--border-2); position: relative; transition: background .15s; flex: none; }
.switch .track::after { content: ""; position: absolute; width: 14px; height: 14px; top: 2px; left: 2px; border-radius: 50%; background: var(--text-2); transition: transform .18s, background .18s; }
.switch input:checked + .track { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .track::after { transform: translateX(14px); background: #fff; }
.switch input:focus-visible + .track { box-shadow: 0 0 0 3px var(--accent-bg); }

.seg-ctl { display: inline-flex; background: var(--bg); border: 1px solid var(--border-2); border-radius: var(--radius-sm); padding: 2px; gap: 2px; }
.seg-ctl button { height: 28px; padding: 0 10px; border: 0; border-radius: 5px; background: transparent; color: var(--text-2); font-size: 12.5px; }
.seg-ctl button.on { background: var(--surface-3); color: var(--text); }

:focus-visible { outline: 2px solid var(--accent-line); outline-offset: 2px; }
.btn:focus-visible, .icon-btn:focus-visible { outline-offset: 1px; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px; height: 21px; padding: 0 8px; border-radius: 5px;
  font-size: 10.5px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; white-space: nowrap;
  background: var(--neutral-bg); color: var(--text-2);
}
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.danger { background: var(--danger-bg); color: var(--danger); }
.badge.accent { background: var(--accent-bg); color: var(--accent-2); }
.badge.neutral { background: var(--neutral-bg); color: var(--text-2); }
.lang {
  display: inline-flex; align-items: center; gap: 6px; height: 21px; padding: 0 8px 0 7px; border-radius: 5px;
  border: 1px solid var(--border-2); font-size: 10.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text); white-space: nowrap;
}
.lang .dot { width: 7px; height: 7px; border-radius: 2px; background: var(--c, #888); }
.conf { display: inline-flex; gap: 2px; align-items: flex-end; height: 12px; }
.conf i { width: 3px; border-radius: 1px; background: var(--border-2); }
.conf i:nth-child(1) { height: 5px; } .conf i:nth-child(2) { height: 8px; } .conf i:nth-child(3) { height: 11px; }
.conf.c1 i:nth-child(1) { background: var(--danger); }
.conf.c2 i:nth-child(-n+2) { background: var(--warn); }
.conf.c3 i { background: var(--ok); }

/* ---------- App shell ---------- */
.app {
  height: 100dvh; display: grid;
  grid-template-columns: var(--rail-w) 1fr;
  grid-template-rows: var(--top-h) 1fr;
  grid-template-areas: "top top" "rail main";
}
.topbar {
  grid-area: top; display: flex; align-items: center; gap: 16px; padding: 0 14px 0 18px;
  border-bottom: 1px solid var(--border); background: var(--bg-rail); min-width: 0;
}
.brand { display: flex; align-items: center; gap: 9px; width: calc(var(--rail-w) - 18px); flex: none; }
.brand-mark { width: 22px; height: 22px; color: var(--accent); stroke-width: 2; }
.brand-name { font-weight: 650; letter-spacing: .02em; font-size: 15px; }
.brand-name span { color: var(--text-2); font-weight: 500; }
.tb-project { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; }
.tb-project .pname {
  min-width: 0; max-width: 420px; height: 32px; padding: 0 9px; border: 1px solid transparent; border-radius: 6px;
  background: transparent; font-weight: 550; font-size: 14px; outline: none; text-overflow: ellipsis;
}
.tb-project .pname:hover { border-color: var(--border-2); }
.tb-project .pname:focus { border-color: var(--accent-line); background: var(--bg); }
.tb-project .sep { color: var(--text-3); }
.tb-right { display: flex; align-items: center; gap: 10px; flex: none; }
.save-ind { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-3); white-space: nowrap; }
.save-ind .i { width: 14px; height: 14px; }
.save-ind.saved { color: var(--text-3); }
.save-ind.saved .i { color: var(--ok); }
.save-ind.error { color: var(--danger); }
.proc-pill {
  display: inline-flex; align-items: center; gap: 8px; height: 30px; padding: 0 12px; border-radius: 30px;
  border: 1px solid var(--border-2); background: var(--surface); font-size: 12.5px; color: var(--text-2);
}
.proc-pill .bar { width: 64px; height: 4px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.proc-pill .bar i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .4s; }
.proc-pill.paused { color: var(--warn); }

.rail {
  grid-area: rail; display: flex; flex-direction: column; gap: 2px; padding: 12px 10px;
  border-right: 1px solid var(--border); background: var(--bg-rail); overflow-y: auto;
}
.nav-item {
  position: relative; display: flex; align-items: center; gap: 11px; height: 38px; padding: 0 12px; border-radius: 8px;
  border: 0; background: transparent; color: var(--text-2); font-weight: 500; font-size: 13.5px; text-align: left;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--surface-3); color: var(--text); }
.nav-item.active::before { content: ""; position: absolute; left: -10px; top: 9px; bottom: 9px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.nav-item .i { width: 18px; height: 18px; }
.nav-badge { margin-left: auto; min-width: 20px; height: 18px; padding: 0 6px; border-radius: 9px; background: var(--warn-bg); color: var(--warn); font-size: 11px; font-weight: 600; display: grid; place-items: center; }
.rail-foot { margin-top: auto; padding: 10px 6px 4px; font-size: 11.5px; color: var(--text-3); line-height: 1.45; }
.rail-foot kbd { font-family: var(--mono); font-size: 10.5px; padding: 1px 5px; border: 1px solid var(--border-2); border-radius: 4px; color: var(--text-2); }

.main { grid-area: main; min-width: 0; min-height: 0; position: relative; }
.pane { position: absolute; inset: 0; overflow-y: auto; overflow-x: hidden; }
.pane-inner { max-width: 1180px; margin: 0 auto; padding: 28px 28px 48px; }
.pane-h { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.pane-h h1 { margin: 0; font-size: 21px; font-weight: 650; letter-spacing: -.01em; }
.pane-h p { margin: 4px 0 0; color: var(--text-2); }
.eyebrow { font-size: 11px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--text-3); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 10px 12px; flex-wrap: wrap; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.card-h h3 { margin: 0; font-size: 13.5px; font-weight: 600; }
.card-b { padding: 16px; }

/* ---------- Dashboard ---------- */
.dash-hero { display: grid; grid-template-columns: 1.3fr 1fr; gap: 16px; margin-bottom: 16px; }
.proj-card { padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.proj-card .title { font-size: 18px; font-weight: 650; margin: 2px 0 0; overflow-wrap: anywhere; }
.proj-meta { display: flex; flex-wrap: wrap; gap: 6px 18px; color: var(--text-2); font-size: 13px; }
.proj-meta span { display: inline-flex; align-items: center; gap: 6px; }
.proj-meta .i { width: 15px; height: 15px; color: var(--text-3); }
.proj-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: auto; }
.status-card { padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.status-line { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.status-line .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); }
.status-line .dot.running { background: var(--accent); box-shadow: 0 0 0 4px var(--accent-bg); }
.status-line .dot.done { background: var(--ok); }
.status-line .dot.paused, .status-line .dot.needs_attention { background: var(--warn); }
.progress { height: 6px; border-radius: 6px; background: var(--surface-3); overflow: hidden; }
.progress > i { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 6px; transition: width .4s ease; }
.progress.ok > i { background: var(--ok); }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.stat { padding: 14px 16px; }
.stat .k { font-size: 12px; color: var(--text-2); display: flex; align-items: center; gap: 7px; }
.stat .k .sw { width: 8px; height: 8px; border-radius: 2px; }
.stat .v { font-size: 24px; font-weight: 650; margin-top: 6px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat .s { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.lang-list { display: flex; flex-wrap: wrap; gap: 8px; }
.lang-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.lang-row:last-child { border-bottom: 0; }
.lang-row .bar { flex: 1; height: 4px; background: var(--surface-3); border-radius: 4px; overflow: hidden; }
.lang-row .bar i { display: block; height: 100%; }
.lang-row .n { width: 64px; text-align: right; color: var(--text-2); font-variant-numeric: tabular-nums; font-size: 12.5px; }
.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.proj-list { display: flex; flex-direction: column; }
.proj-row { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--border); }
.proj-row:last-child { border-bottom: 0; }
.proj-row .meta { flex: 1; min-width: 0; }
.proj-row .meta b { display: block; font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.proj-row .meta small { color: var(--text-3); }
.proj-row.current b::after { content: "Current"; margin-left: 8px; font-size: 10.5px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--accent-2); }

.dropzone {
  border: 1.5px dashed var(--border-2); border-radius: 14px; padding: 48px 24px; text-align: center;
  display: grid; justify-items: center; gap: 14px; background: linear-gradient(180deg, rgba(255,255,255,.012), transparent);
  transition: border-color .15s, background .15s;
}
.dropzone.drag { border-color: var(--accent); background: var(--accent-bg); }
.dropzone .big-i { width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--border-2); color: var(--accent-2); }
.dropzone h2 { margin: 0; font-size: 19px; font-weight: 650; }
.dropzone p { margin: 0; color: var(--text-2); max-width: 520px; }
.steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: 18px; }
.step { padding: 14px; }
.step b { display: block; font-size: 13px; margin-bottom: 4px; }
.step span { color: var(--text-2); font-size: 12.5px; }
.step .n { font-family: var(--mono); font-size: 11px; color: var(--accent-2); margin-bottom: 8px; display: block; }

/* ---------- Workspace ---------- */
.ws { display: grid; grid-template-columns: minmax(0, 1fr) 360px; overflow: hidden; }
.ws-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: hidden; }
.ws-side { border-left: 1px solid var(--border); background: var(--bg-rail); min-height: 0; overflow-y: auto; }
.ws[data-mode="video"] .editor-wrap { display: none; }
.ws[data-mode="video"] .side-details { display: none; }
.ws[data-mode="video"] .stage { flex: 1; }
.ws[data-mode="subtitles"] .side-queue { display: none; }
.ws.side-collapsed { grid-template-columns: minmax(0, 1fr) 0; }
.ws.side-collapsed .ws-side { display: none; }

.stage { display: flex; flex-direction: column; min-height: 0; background: #0b0b0d; border-bottom: 1px solid var(--border); position: relative; }
.ws[data-mode="subtitles"] .stage { flex: none; }
.player { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; }
.video-box { position: relative; flex: 1; min-height: 200px; display: grid; place-items: center; background: #000; overflow: hidden; }
.ws[data-mode="subtitles"] .video-box { height: 34vh; flex: none; min-height: 160px; }
.video-box video { width: 100%; height: 100%; object-fit: contain; display: block; background: #000; }
.video-box .overlay-sub {
  position: absolute; left: 50%; bottom: 7%; transform: translateX(-50%); max-width: 86%; text-align: center; pointer-events: none;
  font-size: clamp(14px, 2.1vw, 21px); font-weight: 500; line-height: 1.35; color: #fff; text-shadow: 0 1px 2px #000, 0 0 6px rgba(0,0,0,.7);
  background: rgba(0,0,0,.42); padding: 4px 10px; border-radius: 6px; white-space: pre-line;
}
.video-box .overlay-sub:empty { display: none; }
.video-empty { display: grid; justify-items: center; gap: 12px; color: var(--text-2); text-align: center; padding: 24px; }
.video-empty .i { width: 34px; height: 34px; color: var(--text-3); }
.reconnect { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(10,10,12,.9); z-index: 3; padding: 20px; text-align: center; }
.reconnect .box { max-width: 420px; display: grid; gap: 12px; justify-items: center; }
.reconnect .box b { font-size: 12px; letter-spacing: .1em; color: var(--warn); }
.reconnect .box p { margin: 0; color: var(--text-2); }

.controls { display: flex; align-items: center; gap: 4px; padding: 6px 10px; background: var(--bg-rail); border-top: 1px solid var(--border); flex-wrap: nowrap; }
.controls .time { font-family: var(--mono); font-size: 12px; color: var(--text-2); padding: 0 8px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.controls .grow { flex: 1; }
.controls .vol { width: 80px; }
.controls .speed { height: 30px; padding: 0 26px 0 8px; width: auto; font-size: 12.5px; background-position: right 7px center; }
input[type=range] { -webkit-appearance: none; appearance: none; background: transparent; height: 20px; cursor: pointer; }
input[type=range]::-webkit-slider-runnable-track { height: 4px; border-radius: 4px; background: var(--surface-3); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 12px; height: 12px; border-radius: 50%; background: var(--text); margin-top: -4px; }
input[type=range]::-moz-range-track { height: 4px; border-radius: 4px; background: var(--surface-3); }
input[type=range]::-moz-range-thumb { width: 12px; height: 12px; border: 0; border-radius: 50%; background: var(--text); }

.timeline { position: relative; height: 38px; padding: 0 12px; background: var(--bg-rail); cursor: pointer; touch-action: none; user-select: none; }
.timeline canvas { position: absolute; left: 12px; right: 12px; top: 6px; width: calc(100% - 24px); height: 26px; }
.timeline .head { position: absolute; top: 2px; bottom: 2px; width: 2px; background: var(--text); border-radius: 2px; pointer-events: none; transform: translateX(-1px); }
.timeline .hover-t { position: absolute; top: -22px; padding: 2px 6px; border-radius: 4px; background: var(--surface-3); font: 11px var(--mono); pointer-events: none; transform: translateX(-50%); white-space: nowrap; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; padding: 8px 14px 10px; background: var(--bg-rail); font-size: 12px; color: var(--text-2); border-top: 1px solid var(--border); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 9px; height: 9px; border-radius: 2px; }
.ws[data-mode="subtitles"] .legend { display: none; }
.mini-bar { display: none; }

/* ---------- Queue panel ---------- */
.side-sec { padding: 16px; border-bottom: 1px solid var(--border); }
.side-sec h3 { margin: 0 0 12px; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--text-3); font-weight: 600; display: flex; align-items: center; justify-content: space-between; }
.q-summary { display: grid; gap: 10px; }
.q-summary .row { display: flex; justify-content: space-between; align-items: baseline; font-size: 13px; }
.q-summary .big { font-size: 22px; font-weight: 650; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.q-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.q-msg { font-size: 12.5px; color: var(--text-2); padding: 10px 12px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--border); line-height: 1.45; }
.q-msg.warn { color: var(--warn); background: var(--warn-bg); border-color: transparent; }
.q-msg.error { color: var(--danger); background: var(--danger-bg); border-color: transparent; }
.q-list { display: flex; flex-direction: column; }
.q-item { display: grid; grid-template-columns: 20px 1fr auto; gap: 10px; align-items: center; padding: 8px 16px; border-bottom: 1px solid var(--border); font-size: 12.5px; min-height: 40px; }
.q-item .st { width: 16px; height: 16px; display: grid; place-items: center; color: var(--text-3); }
.q-item .st .i { width: 15px; height: 15px; }
.q-item.done .st { color: var(--ok); }
.q-item.failed .st { color: var(--danger); }
.q-item.processing .st, .q-item.extracting .st { color: var(--accent-2); }
.q-item .t b { font-weight: 550; }
.q-item .t small { display: block; color: var(--text-3); font-size: 11.5px; }
.q-item .t .err { color: var(--danger); }
.q-item .r { color: var(--text-3); font-size: 11.5px; text-align: right; }
.q-prep { display: grid; grid-template-columns: 20px 1fr; gap: 10px; align-items: start; font-size: 12.5px; padding: 10px 16px; border-bottom: 1px solid var(--border); }
.q-prep .progress { margin-top: 6px; height: 4px; }

/* ---------- Editor ---------- */
.editor-wrap { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.ed-toolbar { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--bg); flex-wrap: wrap; }
.ed-search { position: relative; flex: 1; min-width: 160px; max-width: 340px; }
.ed-search .i { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--text-3); }
.ed-search input { padding-left: 32px; height: 32px; }
.ed-toolbar .select { height: 32px; width: auto; font-size: 13px; }
.ed-toolbar .sp { flex: 1; }
.ed-count { font-size: 12px; color: var(--text-3); white-space: nowrap; }
.ed-list { flex: 1; min-height: 0; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; overscroll-behavior: contain; }
.ed-empty { padding: 48px 20px; text-align: center; color: var(--text-2); display: grid; gap: 12px; justify-items: center; }
.ed-empty .i { width: 30px; height: 30px; color: var(--text-3); }
.sentinel { height: 1px; }

.seg {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  transition: border-color .15s, box-shadow .15s; position: relative; scroll-margin: 12px;
  content-visibility: auto; contain-intrinsic-size: auto 210px;
}
.seg:hover { border-color: var(--border-2); }
.seg.is-active { border-color: var(--accent-line); box-shadow: 0 0 0 1px var(--accent-line) inset; }
.seg.is-active::before { content: ""; position: absolute; left: -1px; top: 10px; bottom: 10px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.seg.is-selected { border-color: #3d4150; }
.seg-h { display: flex; align-items: center; gap: 8px; padding: 9px 10px 0 12px; flex-wrap: wrap; }
.seg-h .tc { border: 0; background: transparent; padding: 3px 6px; margin-left: -6px; border-radius: 5px; font: 12px var(--mono); color: var(--text-2); font-variant-numeric: tabular-nums; }
.seg-h .tc:hover { background: var(--surface-3); color: var(--text); }
.seg-h .tc .arr { color: var(--text-3); margin: 0 4px; }
.seg-h .sp { flex: 1; }
.seg-h .spk { font-size: 11px; color: var(--text-3); }
.seg-b { padding: 6px 12px 4px; display: grid; gap: 4px; }
.fl { font-size: 10.5px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--text-3); margin-top: 4px; display: flex; align-items: center; gap: 8px; }
.fl .fl-state { letter-spacing: 0; text-transform: none; font-weight: 500; font-size: 11.5px; color: var(--text-3); display: inline-flex; align-items: center; gap: 5px; }
.fl .fl-state.corrected { color: var(--ok); }
.fl .fl-state.failed { color: var(--warn); }
.fl .fl-state button { border: 0; background: transparent; color: var(--accent-2); font-size: 11.5px; padding: 0 2px; text-decoration: underline; text-underline-offset: 2px; }
.ta {
  width: 100%; resize: none; overflow: hidden; border: 1px solid transparent; border-radius: 7px; background: transparent;
  padding: 6px 8px; margin-left: -8px; width: calc(100% + 16px); color: var(--text); line-height: 1.5; outline: none; min-height: 34px;
  transition: background .12s, border-color .12s; font-size: 14px;
}
.ta:hover { background: var(--surface-2); }
.ta:focus { background: var(--bg); border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-bg); }
.ta.orig { color: var(--text-2); font-size: 13.5px; }
.ta.en { font-weight: 450; }
.ta.en.needs { background: var(--surface-2); border-color: var(--border-2); }
.ta.en.needs:focus { background: var(--bg); border-color: var(--accent-line); }
.ta::placeholder { color: var(--text-3); }
.seg-f { display: flex; align-items: center; gap: 6px; padding: 4px 8px 8px 12px; flex-wrap: wrap; min-height: 38px; }
.seg-f .note { font-size: 12px; color: var(--text-3); display: inline-flex; align-items: center; gap: 6px; margin-right: auto; }
.seg-f .note .i { width: 14px; height: 14px; }
.seg-f .note.ok { color: var(--ok); }
.seg-f .note.warn { color: var(--warn); }
.seg-f .note.danger { color: var(--danger); }
.seg-f .note.accent { color: var(--accent-2); }
.btn.mic.listening { color: var(--danger); border-color: rgba(238,107,92,.5); background: var(--danger-bg); }
.btn.mic.listening .i { animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.interim { font-size: 12.5px; color: var(--text-3); font-style: italic; padding: 0 12px 6px; }
.interim:empty { display: none; }

/* ---------- Details panel ---------- */
.details { padding: 16px; display: grid; gap: 16px; }
.details .head { display: flex; align-items: center; justify-content: space-between; }
.details .head b { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--text-3); }
.details .grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 13px; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; text-align: right; overflow-wrap: anywhere; }
.time-edit { display: flex; gap: 4px; }
.time-edit .input { font-family: var(--mono); font-size: 12.5px; padding: 0 8px; }
.time-edit .input.bad { border-color: var(--danger); }
.actions-col { display: grid; gap: 6px; }
.actions-col .btn { justify-content: flex-start; }
.details-empty { padding: 32px 18px; color: var(--text-3); text-align: center; font-size: 13px; }

/* ---------- Review ---------- */
.rv-stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 16px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.chip { height: 30px; padding: 0 12px; border-radius: 30px; border: 1px solid var(--border-2); background: transparent; color: var(--text-2); font-size: 12.5px; font-weight: 500; display: inline-flex; align-items: center; gap: 7px; }
.chip:hover { color: var(--text); background: var(--surface-2); }
.chip.on { background: var(--text); border-color: var(--text); color: var(--bg); }
.chip .n { font-variant-numeric: tabular-nums; opacity: .7; font-size: 11.5px; }
.rv-list { overflow: hidden; }
.rv-row { display: grid; grid-template-columns: 112px 110px 1fr auto; gap: 14px; align-items: center; padding: 10px 16px; border-bottom: 1px solid var(--border); cursor: pointer; }
.rv-row:hover { background: var(--surface-2); }
.rv-row:last-child { border-bottom: 0; }
.rv-row .t { font: 12px var(--mono); color: var(--text-2); }
.rv-row .txt { min-width: 0; }
.rv-row .txt div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rv-row .txt .o { color: var(--text-3); font-size: 12.5px; }
.rv-row .txt .missing { color: var(--warn); font-style: italic; }
.rv-more { padding: 12px; text-align: center; }

/* ---------- Export ---------- */
.ex-grid { display: grid; grid-template-columns: 420px 1fr; gap: 16px; align-items: start; }
.qc-list { display: flex; flex-direction: column; }
.qc-item { display: grid; grid-template-columns: 18px 1fr auto; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); align-items: start; }
.qc-item:last-child { border-bottom: 0; }
.qc-item .i { width: 16px; height: 16px; margin-top: 2px; }
.qc-item.error .i { color: var(--danger); }
.qc-item.warning .i { color: var(--warn); }
.qc-item.info .i { color: var(--text-3); }
.qc-item.good .i { color: var(--ok); }
.qc-item b { font-weight: 550; font-size: 13px; }
.qc-item p { margin: 2px 0 0; color: var(--text-3); font-size: 12px; }
.qc-item .cnt { font-variant-numeric: tabular-nums; font-size: 12.5px; color: var(--text-2); }
.opt { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.opt:last-child { border-bottom: 0; }
.opt div b { font-weight: 500; font-size: 13px; display: block; }
.opt div small { color: var(--text-3); font-size: 12px; }
.preview {
  margin: 0; padding: 16px; font: 12.5px/1.6 var(--mono); color: var(--text); background: var(--bg); border-top: 1px solid var(--border);
  max-height: 62vh; overflow: auto; white-space: pre-wrap; word-break: break-word; border-radius: 0 0 var(--radius) var(--radius);
}
.preview-empty { padding: 56px 20px; text-align: center; color: var(--text-3); display: grid; gap: 10px; justify-items: center; }
.preview-empty .i { width: 30px; height: 30px; }
.ex-result { display: flex; gap: 8px; flex-wrap: wrap; }
.ex-summary { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12.5px; color: var(--text-2); }

/* ---------- Modals ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(5,5,7,.6); backdrop-filter: blur(3px); display: grid; place-items: center; z-index: 50; opacity: 0; transition: opacity .16s; padding: 16px; }
.modal-backdrop.in { opacity: 1; }
.modal { width: min(520px, 100%); max-height: calc(100dvh - 32px); display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border-2); border-radius: 14px; box-shadow: 0 24px 60px rgba(0,0,0,.5); transform: translateY(6px) scale(.99); transition: transform .16s; }
.modal.wide { width: min(720px, 100%); }
.modal-backdrop.in .modal { transform: none; }
.modal-h { display: flex; align-items: center; justify-content: space-between; padding: 14px 14px 14px 20px; border-bottom: 1px solid var(--border); }
.modal-h h2 { margin: 0; font-size: 15px; font-weight: 600; }
.modal-b { padding: 18px 20px; overflow-y: auto; }
.modal-b p { margin: 0 0 8px; }
.modal-f { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border); }
.set-sec { display: grid; gap: 14px; padding-bottom: 18px; margin-bottom: 18px; border-bottom: 1px solid var(--border); }
.set-sec:last-child { border-bottom: 0; margin-bottom: 0; padding-bottom: 0; }
.set-sec > h4 { margin: 0; font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--text-3); font-weight: 600; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.set-row > div b { display: block; font-weight: 500; font-size: 13.5px; }
.set-row > div small { color: var(--text-3); font-size: 12px; }
.key-status { font-size: 12.5px; display: inline-flex; align-items: center; gap: 6px; }
.key-status.ok { color: var(--ok); } .key-status.err { color: var(--danger); }
.kbd-list { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 12.5px; color: var(--text-2); }
.kbd-list kbd { font-family: var(--mono); font-size: 11px; padding: 2px 6px; border: 1px solid var(--border-2); border-radius: 4px; color: var(--text); background: var(--bg); white-space: nowrap; }
.sheet .modal-b { padding: 0; }

/* ---------- Toasts & drop ---------- */
.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 60; max-width: min(420px, calc(100vw - 32px)); pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 10px; padding: 10px 8px 10px 14px; border-radius: 10px; background: var(--surface-3); border: 1px solid var(--border-2); box-shadow: var(--shadow); font-size: 13px; opacity: 0; transform: translateY(6px); transition: opacity .18s, transform .18s; }
.toast.in { opacity: 1; transform: none; }
.toast .toast-text { flex: 1; line-height: 1.4; }
.toast.ok > .i { color: var(--ok); } .toast.error > .i { color: var(--danger); } .toast.warn > .i { color: var(--warn); } .toast.info > .i { color: var(--accent-2); }
.drop-overlay { position: fixed; inset: 0; z-index: 70; display: none; place-items: center; background: rgba(15,16,18,.86); border: 2px dashed var(--accent); }
.drop-overlay.show { display: grid; }
.drop-overlay div { text-align: center; color: var(--accent-2); }
.drop-overlay .i { width: 40px; height: 40px; }
.drop-overlay p { font-size: 16px; font-weight: 600; }

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
  .ws { grid-template-columns: minmax(0, 1fr) 320px; }
  .ex-grid { grid-template-columns: 1fr; }
}
@media (max-width: 1024px) {
  :root { --rail-w: 64px; }
  .nav-item span, .rail-foot { display: none; }
  .nav-item { justify-content: center; padding: 0; }
  .nav-badge { position: absolute; top: 2px; right: 2px; min-width: 16px; height: 16px; font-size: 10px; padding: 0 4px; }
  .brand { width: auto; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .rv-stats { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 900px) {
  :root { --top-h: 50px; --bottom-h: 60px; }
  body { font-size: 15px; }
  .app { grid-template-columns: 1fr; grid-template-rows: var(--top-h) 1fr calc(var(--bottom-h) + env(safe-area-inset-bottom)); grid-template-areas: "top" "main" "rail"; }
  .topbar { padding: 0 8px 0 12px; gap: 8px; }
  .brand-name { display: none; }
  .tb-project .pname { max-width: none; width: 100%; font-size: 14.5px; }
  .tb-project .sep, .tb-project .vid-name { display: none; }
  .save-ind .lbl { display: none; }
  .proc-pill .bar { display: none; }
  .rail { flex-direction: row; padding: 4px 4px env(safe-area-inset-bottom); border-right: 0; border-top: 1px solid var(--border); gap: 0; overflow: visible; }
  .nav-item { flex: 1; flex-direction: column; gap: 3px; height: 54px; font-size: 10.5px; justify-content: center; padding: 0; }
  .nav-item span { display: block; }
  .nav-item.active { background: transparent; color: var(--accent-2); }
  .nav-item.active::before { left: 30%; right: 30%; top: -5px; bottom: auto; width: auto; height: 2px; border-radius: 0 0 2px 2px; }
  .nav-badge { top: 4px; right: calc(50% - 22px); }
  .pane-inner { padding: 18px 14px 32px; }
  .pane-h h1 { font-size: 19px; }
  .dash-hero, .dash-grid { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat .v { font-size: 21px; }
  .steps { grid-template-columns: 1fr 1fr; }
  .dropzone { padding: 32px 16px; }

  /* Workspace: single column, stage sticky on top, page scrolls */
  .ws { display: block; overflow-y: auto; }
  .ws-main { display: block; overflow: visible; }
  .ws-side { border-left: 0; overflow: visible; background: transparent; }
  .ws .side-details { display: none !important; }
  .stage { position: sticky; top: 0; z-index: 5; }
  .ws[data-mode="video"] .video-box { height: auto; aspect-ratio: 16/9; max-height: 46dvh; flex: none; min-height: 0; }
  .ws[data-mode="subtitles"] .video-box { height: 28dvh; min-height: 120px; }
  .ws[data-mode="subtitles"] .timeline { height: 30px; }
  .ws[data-mode="subtitles"] .timeline canvas { top: 4px; height: 22px; }
  .editor-wrap { display: block; }
  .ed-toolbar { position: static; padding: 10px 12px; }
  .ed-search { max-width: none; flex-basis: 100%; }
  .ed-list { overflow: visible; padding: 10px; }
  .controls { gap: 0; padding: 4px 4px; }
  .controls .vol, .controls .hide-m { display: none; }
  .icon-btn { width: 40px; height: 40px; }
  .seg-h { padding: 10px 8px 0 12px; }
  .ta { font-size: 16px; } /* prevents iOS zoom; comfortable on Android */
  .ta.orig { font-size: 15px; }
  .seg-f .btn.sm { height: 36px; padding: 0 12px; }
  .rv-row { grid-template-columns: 1fr auto; gap: 6px 10px; }
  .rv-row .t { grid-column: 1; }
  .rv-row .txt { grid-column: 1 / -1; grid-row: 2; }
  .rv-stats { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .rv-stats .stat:first-child { grid-column: 1 / -1; }
  .toasts { left: 12px; right: 12px; bottom: calc(var(--bottom-h) + env(safe-area-inset-bottom) + 10px); max-width: none; }
  .modal-backdrop { align-items: end; padding: 0; }
  .modal { width: 100%; max-height: 92dvh; border-radius: 16px 16px 0 0; border-bottom: 0; }
  .modal-f { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
  .mini-bar { display: none; }

  /* Keyboard open while editing: collapse the sticky player to a slim bar */
  body.kb-open .ws[data-mode="subtitles"] .video-box,
  body.kb-open .ws[data-mode="subtitles"] .timeline { display: none; }
  body.kb-open .app { grid-template-rows: var(--top-h) 1fr 0; }
  body.kb-open .rail { display: none; }
}
@media (max-width: 420px) {
  .controls .speed { display: none; }
  .stats { gap: 8px; }
  .stat { padding: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
