/* Subtitle Review v2 */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #0e0e14;
    color: #e8e8f0;
    min-height: 100vh;
    font-size: 14px;
}

button {
    font-family: inherit;
    cursor: pointer;
    background: #2a2a4a;
    color: #fff;
    border: 1px solid #444;
    border-radius: 4px;
    padding: 5px 12px;
    font-size: 13px;
}
button:hover:not(:disabled) { background: #3a3a6a; }
button:disabled { opacity: 0.4; cursor: not-allowed; }
button.primary { background: #1976d2; border-color: #1976d2; }
button.primary:hover:not(:disabled) { background: #1565c0; }
button.teal { background: #00897b; border-color: #00897b; }
button.teal:hover:not(:disabled) { background: #00796b; }
button.blue { background: #1976d2; border-color: #1976d2; }
button.purple { background: #7b1fa2; border-color: #7b1fa2; }
button.orange { background: #e65100; border-color: #e65100; }
button.danger { background: #c62828; border-color: #c62828; }
button.wide { width: 100%; margin-top: 6px; }

input, textarea, select {
    background: #1a1a2e;
    color: #fff;
    border: 1px solid #444;
    border-radius: 4px;
    padding: 5px 8px;
    font-size: 13px;
    font-family: inherit;
    width: 100%;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: #64b5f6; }

.muted { color: #888; font-size: 12px; }
.ok { color: #66bb6a; }

/* ── Login page ─────────────────────────────────────────────── */
.auth-body {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh; padding: 20px;
}
.login-card {
    background: #1a1a2e;
    border: 1px solid #2a2a44;
    border-radius: 10px;
    padding: 32px 28px;
    max-width: 380px;
    width: 100%;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}
.login-card h1 { font-size: 22px; margin-bottom: 4px; }
.login-card .subtitle { color: #888; font-size: 14px; margin-bottom: 24px; }
.login-card label { display: block; margin-bottom: 14px; }
.login-card label span { display: block; font-size: 13px; color: #aaa; margin-bottom: 4px; }
.login-card button[type="submit"] {
    width: 100%; background: #1976d2; color: #fff; border: none;
    padding: 10px; font-size: 14px; font-weight: 600; margin-top: 8px;
}
.login-card button[type="submit"]:hover { background: #1565c0; }
.err { color: #ef5350; font-size: 13px; margin-top: 10px; min-height: 18px; }

/* ── App shell ──────────────────────────────────────────────── */
.app-body { display: flex; flex-direction: column; min-height: 100vh; }

.app-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 20px; background: #12121c; border-bottom: 1px solid #2a2a44;
    flex: 0 0 auto;
}
.app-header h1 { font-size: 18px; font-weight: 600; }
.header-actions { display: flex; align-items: center; gap: 14px; }
.header-actions #userBadge { color: #aaa; font-size: 13px; }
.header-actions .btn-link {
    color: #64b5f6;
    text-decoration: none;
    font-size: 13px;
}
.header-actions .btn-link:hover { text-decoration: underline; }

#mainContent { flex: 1; padding: 0; }
.loading { color: #888; text-align: center; margin-top: 40px; }

.layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 0;
    min-height: calc(100vh - 54px);
}
.sidebar {
    background: #0e0e18;
    border-right: 1px solid #2a2a44;
    padding: 14px;
    overflow-y: auto;
    max-height: calc(100vh - 54px);
}
.workspace { padding: 14px; overflow-y: auto; max-height: calc(100vh - 54px); }

/* ── Sidebar sections ───────────────────────────────────────── */
.side-section {
    border-bottom: 1px solid #2a2a44;
    padding: 10px 0;
}
.side-section:first-child { padding-top: 0; }
.side-section h3 {
    font-size: 13px; text-transform: uppercase;
    color: #aaa; margin-bottom: 8px; letter-spacing: 0.5px;
}
.side-section .btn-row { display: flex; gap: 6px; }
.side-section .btn-row button { flex: 1; }
.side-section .field { margin-bottom: 8px; }
.side-section label { display: block; margin-bottom: 6px; }
.side-section label span { display: block; color: #aaa; font-size: 12px; margin-bottom: 3px; }
.side-section .radio { display: block; font-size: 13px; padding: 3px 0; }
.side-section .radio input { width: auto; margin-right: 6px; }
.side-section .inline { display: inline-block; margin-right: 10px; }
.side-section .inline input { width: auto; margin-right: 4px; }
.side-section button { margin-top: 4px; }

.qc-row { padding: 3px 6px; border-radius: 3px; margin-bottom: 3px; font-size: 13px; }
.qc-row.warn { background: rgba(251, 140, 0, 0.15); }
.qc-row.info { background: rgba(100, 181, 246, 0.12); }
.qc-row.danger { background: rgba(239, 83, 80, 0.18); }

.diff-box {
    max-height: 240px; overflow-y: auto;
    background: #0e0e18; border: 1px solid #2a2a44;
    padding: 6px; border-radius: 4px; font-size: 12px;
    margin-bottom: 6px; line-height: 1.5;
}
.diff-box code {
    background: #1a1a2e; padding: 1px 4px; border-radius: 2px;
    font-family: ui-monospace, Menlo, monospace; font-size: 11px;
}

.upload-form input[type="file"] { padding: 2px; }
.recent { list-style: none; padding: 0; margin-top: 8px; }
.recent li { padding: 6px 0; border-bottom: 1px solid #2a2a44; }
.recent a { color: #64b5f6; text-decoration: none; margin-right: 8px; }
.recent a:hover { text-decoration: underline; }

/* ── Workspace layout ───────────────────────────────────────── */
.row-top {
    display: grid;
    grid-template-columns: 3fr 1fr;
    gap: 14px;
    margin-bottom: 14px;
}
.player-col { min-width: 0; }
.quick-col {
    background: #12121c;
    border: 1px solid #2a2a44;
    border-radius: 8px;
    padding: 12px;
    max-height: 620px;
    overflow-y: auto;
}
.quick-col h2 { font-size: 16px; margin-bottom: 6px; }

.timeline-col { margin-bottom: 14px; }
.list-col { margin-bottom: 20px; }

.burn-col {
    background: #12121c;
    border: 1px solid #2a2a44;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 20px;
    max-width: 900px;
}
.burn-col .burn-video { margin-top: 14px; }
.burn-col .burn-video .muted { margin-bottom: 6px; }
.burn-col .burn-video video {
    width: 100%;
    max-height: 520px;
    background: #000;
    border-radius: 6px;
    display: block;
}
.burn-col h3 {
    font-size: 14px;
    text-transform: uppercase;
    color: #aaa;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
    border-bottom: 1px solid #2a2a44;
    padding-bottom: 6px;
}
.burn-col .field { margin: 8px 0; }
.burn-col .radio { display: block; font-size: 13px; padding: 3px 0; }
.burn-col .radio input { width: auto; margin-right: 6px; }
.burn-col .inline { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.burn-col .inline input { width: auto; }
.burn-col input[type="range"] { width: 100%; }
.burn-col .btn-row { display: flex; gap: 8px; }
.burn-col .btn-row button { flex: 1; }

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #aaa;
}
.empty-state h2 { color: #e8e8f0; margin-bottom: 10px; }

/* ── Player ─────────────────────────────────────────────────── */
.player-wrap {
    position: relative;
    background: #000;
    border-radius: 8px;
    overflow: hidden;
}
.player-wrap video {
    width: 100%;
    display: block;
    background: #000;
    max-height: 560px;
}

.sub-overlay {
    position: absolute;
    bottom: 60px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    padding: 8px 18px;
    border-radius: 8px;
    font-size: 18px;
    text-align: center;
    max-width: 85%;
    line-height: 1.4;
    cursor: pointer;
    z-index: 20;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.9);
    user-select: none;
}
.sub-overlay:hover { background: rgba(30, 90, 180, 0.85); }
.sub-overlay .speaker { color: #64b5f6; font-size: 13px; display: block; margin-bottom: 2px; }

.inline-edit {
    display: none;
    position: absolute;
    bottom: 60px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(20, 20, 40, 0.96);
    border: 2px solid #64b5f6;
    border-radius: 10px;
    padding: 12px;
    min-width: 420px;
    max-width: 85%;
    z-index: 100;
}
.inline-edit.active { display: block; }
.inline-edit textarea { font-size: 16px; resize: vertical; min-height: 50px; }
.inline-edit .nudge-row {
    display: flex; gap: 6px; margin-top: 8px;
    align-items: center; justify-content: center;
    flex-wrap: wrap;
}
.inline-edit .ts-info { color: #aaa; font-size: 12px; }
.inline-edit .ts-sp { min-width: 80px; }
.inline-edit .ts-display { color: #aaa; font-size: 12px; text-align: center; margin-top: 6px; }
.inline-edit button.save { background: #1976d2; border-color: #1976d2; }

/* ── Timeline ───────────────────────────────────────────────── */
.timeline-controls {
    display: flex; gap: 8px; padding: 6px 10px;
    background: #111; border: 1px solid #2a2a44; border-radius: 6px 6px 0 0;
    align-items: center;
}
.timeline-controls span { color: #888; font-size: 12px; }
.timeline-wrap {
    position: relative;
    width: 100%;
    height: 170px;
    overflow-x: auto;
    overflow-y: hidden;
    background: #1a1a2e;
    cursor: pointer;
    border: 1px solid #2a2a44;
    border-top: none;
    border-radius: 0 0 6px 6px;
}
.timeline-inner {
    position: relative;
    height: 100%;
    min-width: 100%;
}
.sub-block {
    position: absolute;
    height: 32px;
    top: 6px;
    background: #1976d2;
    border-radius: 3px;
    opacity: 0.75;
    min-width: 2px;
    cursor: pointer;
}
.sub-block.selected {
    opacity: 1;
    box-shadow: 0 0 6px rgba(100, 181, 246, 0.6);
    outline: 1px solid #fff;
}
.sub-block.overlap { background: #e53935 !important; opacity: 0.9; }
.sub-block.cps-ok { background: #43a047; }
.sub-block.cps-fast { background: #fb8c00; }
.sub-block.cps-danger { background: #e53935; }
.playhead {
    position: absolute;
    top: 0; bottom: 0;
    width: 2px;
    background: #fff;
    z-index: 10;
    pointer-events: none;
}
.time-label {
    position: absolute;
    bottom: 4px;
    color: #ccc;
    font-size: 12px;
    pointer-events: none;
    white-space: nowrap;
    user-select: none;
}

/* ── Quick edit panel ───────────────────────────────────────── */
.quick-col .nav-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 8px 0;
}
.quick-col .nav-row button { flex: 1; }
.quick-col .nav-row .num { min-width: 40px; text-align: center; font-weight: bold; }

.quick-col .field { margin: 8px 0; }
.quick-col .field span { color: #aaa; font-size: 12px; }

.quick-col .nudge-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
    margin-bottom: 6px;
}
.quick-col .nudge-grid button {
    padding: 4px 2px;
    font-size: 12px;
}

.quick-col .timing-info {
    padding: 6px 0;
    font-size: 13px;
}
.quick-col .cps.ok { color: #66bb6a; font-weight: 600; }
.quick-col .cps.warn { color: #fb8c00; font-weight: 600; }
.quick-col .cps.danger { color: #ef5350; font-weight: 600; }

.quick-col .ts-row {
    text-align: center;
    margin: 6px 0;
    color: #ccc;
}
.quick-col code {
    background: #0e0e18;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: ui-monospace, Menlo, monospace;
    font-size: 12px;
    color: #64b5f6;
}

/* ── Subtitle list table ────────────────────────────────────── */
.sub-list {
    background: #12121c;
    border: 1px solid #2a2a44;
    border-radius: 6px;
    overflow: hidden;
    max-height: 420px;
    overflow-y: auto;
}
.sub-list .row {
    display: grid;
    align-items: center;
    gap: 8px;
    padding: 4px 10px;
    border-bottom: 1px solid #1a1a2e;
    cursor: pointer;
    font-size: 13px;
}
.sub-list.plain .row {
    grid-template-columns: 40px 90px 90px 60px 1fr 180px 30px;
}
.sub-list.with-speaker .row {
    grid-template-columns: 40px 90px 90px 60px 100px 1fr 180px 30px;
}
.sub-list .row:hover { background: #1a1a2e; }
.sub-list .row.selected { background: rgba(100, 181, 246, 0.15); }
.sub-list .row.header {
    position: sticky; top: 0;
    background: #12121c !important;
    color: #aaa;
    font-size: 12px;
    text-transform: uppercase;
    border-bottom: 1px solid #2a2a44;
    cursor: default;
    font-weight: 600;
}
.sub-list .idx { color: #888; font-family: ui-monospace, monospace; }
.sub-list .text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sub-list .status {
    color: #fb8c00;
    font-size: 11px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── v3 shared components (uses tokens.css) ─────────────────────── */

.app-nav {
    width: var(--sidebar-w);
    background: var(--bg-1);
    border-right: var(--border);
    padding: var(--space-3) 0;
    overflow-y: auto;
    flex: 0 0 var(--sidebar-w);
}
.nav-item {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: 10px var(--space-4);
    color: var(--fg-1);
    font-size: var(--font-lg);
    cursor: pointer;
    text-decoration: none;
    border-left: 3px solid transparent;
    transition: background 0.1s, color 0.1s;
}
.nav-item:hover { background: var(--bg-2); color: var(--fg-0); }
.nav-item.active {
    background: var(--bg-2);
    color: #fff;
    border-left-color: var(--brand);
}
.nav-item .nav-icon { font-size: 18px; width: 22px; text-align: center; }
.nav-section-label {
    font-size: 11px;
    text-transform: uppercase;
    color: var(--fg-2);
    letter-spacing: 0.6px;
    padding: 12px var(--space-4) 4px;
}

/* Home chooser */
.home-hero {
    max-width: 960px;
    margin: 0 auto;
    padding: var(--space-8) var(--space-5);
}
.home-hero h1 {
    font-size: 26px;
    margin-bottom: var(--space-2);
}
.home-hero .muted { margin-bottom: var(--space-6); }
.home-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-5);
}
@media (max-width: 760px) {
    .home-cards { grid-template-columns: 1fr; }
}
.home-card {
    background: var(--bg-1);
    border: var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    text-decoration: none;
    color: var(--fg-0);
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    transition: transform 0.12s, border-color 0.12s, box-shadow 0.12s;
    min-height: 220px;
}
.home-card:hover {
    transform: translateY(-2px);
    border-color: var(--brand);
    box-shadow: var(--shadow-card);
}
.home-card .icon {
    font-size: 40px;
    color: var(--brand);
}
.home-card h2 {
    font-size: 20px;
    margin-top: var(--space-2);
}
.home-card p {
    color: var(--fg-1);
    font-size: var(--font-lg);
    line-height: 1.5;
    flex: 1;
}
.home-card .cta {
    color: var(--brand);
    font-weight: 600;
    margin-top: var(--space-3);
}

/* Layout override for new shell */
.layout-v3 {
    display: flex;
    min-height: calc(100vh - var(--header-h));
}
.layout-v3 .app-main {
    flex: 1;
    overflow-y: auto;
    max-height: calc(100vh - var(--header-h));
}

.empty-state {
    max-width: 600px;
    margin: 60px auto;
    text-align: center;
}
.empty-state h2 { margin-bottom: var(--space-3); }

/* Projects grid */
.projects-list {
    max-width: 1000px;
    margin: 0 auto;
    padding: var(--space-5);
}
.projects-list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-5);
}
.projects-list-header h1 { font-size: 22px; }
.project-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--space-4);
}
.project-card {
    background: var(--bg-1);
    border: var(--border);
    border-radius: var(--radius-md);
    padding: var(--space-4);
    text-decoration: none;
    color: var(--fg-0);
    transition: border-color 0.12s;
    display: block;
}
.project-card:hover { border-color: var(--brand); }
.project-card .p-title {
    font-weight: 600;
    font-size: var(--font-lg);
    margin-bottom: var(--space-1);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.project-card .p-meta {
    color: var(--fg-2);
    font-size: var(--font-sm);
}
.project-card .p-badge {
    display: inline-block;
    padding: 2px 8px;
    font-size: 11px;
    border-radius: 3px;
    margin-top: var(--space-2);
}
.project-card .p-badge.pipeline {
    background: rgba(25, 118, 210, 0.2);
    color: #64b5f6;
}
.project-card .p-badge.standalone {
    background: rgba(0, 137, 123, 0.25);
    color: #4db6ac;
}

.upload-zone-big {
    background: var(--bg-1);
    border: 2px dashed var(--bg-3);
    border-radius: var(--radius-lg);
    padding: var(--space-8) var(--space-4);
    text-align: center;
    cursor: pointer;
    transition: border-color 0.12s, background 0.12s;
}
.upload-zone-big:hover, .upload-zone-big.dragover {
    border-color: var(--brand);
    background: var(--bg-2);
}
.upload-zone-big .cloud { font-size: 36px; color: var(--fg-2); }
.upload-zone-big .label { margin-top: var(--space-2); font-weight: 600; }
.upload-zone-big .sublabel { color: var(--fg-2); font-size: var(--font-sm); margin-top: var(--space-1); }

/* Pipeline view */
.pipeline-view {
    max-width: 860px;
    margin: 0 auto;
    padding: var(--space-5);
}
.pipeline-header { margin-bottom: var(--space-5); }
.pipeline-header h1 { font-size: 22px; margin-bottom: var(--space-1); }

.warn-banner {
    background: rgba(255, 152, 0, 0.12);
    border: 1px solid rgba(255, 152, 0, 0.4);
    border-radius: var(--radius-md);
    padding: var(--space-3) var(--space-4);
    margin-bottom: var(--space-4);
    color: #ffb74d;
    font-size: var(--font-lg);
}

.form-section {
    background: var(--bg-1);
    border: var(--border);
    border-radius: var(--radius-md);
    padding: var(--space-4);
    margin-bottom: var(--space-4);
}
.form-section h3 {
    font-size: var(--font-sm);
    text-transform: uppercase;
    color: var(--fg-1);
    letter-spacing: 0.5px;
    margin-bottom: var(--space-3);
    padding-bottom: var(--space-2);
    border-bottom: var(--border);
}
.form-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-3);
}
@media (max-width: 600px) {
    .form-grid-2 { grid-template-columns: 1fr; }
}
.form-row {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    margin-bottom: var(--space-3);
}
.form-row--inline {
    flex-direction: row;
    align-items: center;
    gap: var(--space-2);
    margin-bottom: var(--space-2);
}
.form-row--inline input[type="checkbox"] { width: auto; }
.form-label { color: var(--fg-1); font-size: var(--font-sm); }
.form-help { color: var(--fg-2); font-size: 11px; }

.chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin-top: var(--space-1);
}
.chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border: 1px solid var(--bg-3);
    border-radius: 16px;
    font-size: var(--font-sm);
    cursor: pointer;
    user-select: none;
    background: var(--bg-2);
}
.chip:hover { border-color: var(--brand); }
.chip input { width: auto; margin: 0; }
.chip input:checked + span { color: var(--brand); font-weight: 600; }

/* Progress panel */
.progress-panel {
    background: var(--bg-1);
    border: var(--border);
    border-radius: var(--radius-md);
    padding: var(--space-5);
    margin-bottom: var(--space-4);
}
.progress {
    background: var(--bg-2);
    border-radius: 999px;
    height: 8px;
    overflow: hidden;
}
.progress__fill {
    background: linear-gradient(90deg, var(--brand), var(--brand-2));
    height: 100%;
    transition: width 0.4s ease;
}
.progress-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-top: var(--space-2);
}
.progress-percent {
    font-size: var(--font-xl);
    font-weight: 600;
}
.log-tail {
    max-height: 240px;
    overflow-y: auto;
    background: var(--bg-2);
    border: var(--border);
    border-radius: var(--radius-sm);
    padding: var(--space-2);
    font-size: 11px;
    font-family: ui-monospace, monospace;
    color: var(--fg-1);
    margin-top: var(--space-1);
    white-space: pre-wrap;
}

/* Shared button variants */
.btn {
    display: inline-block;
    background: var(--bg-3);
    color: #fff;
    border: 1px solid #444;
    border-radius: var(--radius-sm);
    padding: 6px 12px;
    font-size: var(--font-md);
    cursor: pointer;
    font-family: inherit;
    text-decoration: none;
    text-align: center;
}
.btn:hover { background: #3a3a6a; }
.btn.primary { background: var(--brand); border-color: var(--brand); }
.btn.primary:hover { background: var(--brand-2); }
.btn.ghost { background: transparent; border-color: var(--bg-3); color: var(--fg-0); }
.btn.ghost:hover { background: var(--bg-2); }
.btn.danger { background: var(--err); border-color: var(--err); }
.btn.danger:hover { background: #d32f2f; }

.panel {
    background: var(--bg-1);
    border: var(--border);
    border-radius: var(--radius-md);
}

/* Dual-handle trim slider */
.trim-slider {
    position: relative;
    height: 36px;
    margin: var(--space-3) 0;
}
.trim-track {
    position: absolute;
    top: 16px;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--bg-3);
    border-radius: 2px;
}
.trim-fill {
    position: absolute;
    top: 16px;
    height: 4px;
    background: linear-gradient(90deg, var(--brand), var(--brand-2));
    border-radius: 2px;
    left: 0;
    width: 100%;
}
.trim-thumb {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 36px;
    margin: 0;
    padding: 0;
    background: transparent;
    pointer-events: none;
    appearance: none;
    -webkit-appearance: none;
    border: 0;
    outline: 0;
}
.trim-thumb::-webkit-slider-thumb {
    pointer-events: all;
    appearance: none;
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    background: var(--brand);
    border-radius: 50%;
    border: 2px solid #fff;
    cursor: grab;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
}
.trim-thumb::-webkit-slider-thumb:active { cursor: grabbing; background: var(--brand-2); }
.trim-thumb::-moz-range-thumb {
    pointer-events: all;
    width: 14px;
    height: 14px;
    background: var(--brand);
    border-radius: 50%;
    border: 2px solid #fff;
    cursor: grab;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
}
.trim-thumb::-webkit-slider-runnable-track {
    height: 4px;
    background: transparent;
    border: 0;
}
.trim-thumb::-moz-range-track {
    height: 4px;
    background: transparent;
    border: 0;
}

.trim-readout {
    display: flex;
    justify-content: space-between;
    gap: var(--space-3);
    margin-bottom: var(--space-1);
    font-size: var(--font-md);
}
.trim-readout > div {
    display: flex;
    flex-direction: column;
    gap: 2px;
    align-items: center;
    flex: 1;
}
.trim-readout > div:first-child { align-items: flex-start; }
.trim-readout > div:last-child  { align-items: flex-end; }
.trim-readout .muted { font-size: 11px; }
.trim-readout b {
    font-family: ui-monospace, monospace;
    color: var(--fg-0);
    font-size: var(--font-lg);
}
.trim-actions {
    display: flex;
    gap: var(--space-2);
    justify-content: center;
    margin-top: var(--space-3);
    flex-wrap: wrap;
}
.trim-actions .btn { font-size: var(--font-sm); padding: 4px 10px; }

/* ── Pipeline UI v2: collapsible sections + compact video header + sticky submit ── */

/* Visually-hidden (for the file input) — fully removed from layout */
.sr-only {
    position: absolute !important;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Video slot (holds either the upload zone OR the selected preview) */
.video-slot {
    margin-bottom: var(--space-4);
}
.video-slot--selected {
    background: var(--bg-1);
    border: var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
}
.video-slot__player {
    width: 100%;
    max-height: 460px;
    background: #000;
    display: block;
}

/* Video header (when a file is picked) — now sibling of video, both inside the slot */
.video-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    background: var(--bg-1);
    border-bottom: var(--border);
}
.video-header__name {
    font-weight: 600;
    color: var(--fg-0);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 540px;
}

/* Collapsible <details> sections */
.form-section--details {
    padding: 0;
    overflow: hidden;
}
.form-section--details[open] {
    padding: 0 var(--space-4) var(--space-4);
}
.form-section--details > summary {
    list-style: none;
    cursor: pointer;
    padding: var(--space-3) var(--space-4);
    display: flex;
    align-items: center;
    gap: var(--space-3);
    user-select: none;
    font-weight: 600;
    color: var(--fg-0);
    transition: background 0.1s;
    border-bottom: 1px solid transparent;
}
.form-section--details > summary::-webkit-details-marker { display: none; }
.form-section--details > summary::marker { content: ''; }
.form-section--details > summary::after {
    content: '▸';
    margin-left: auto;
    color: var(--fg-2);
    font-size: 14px;
    transition: transform 0.15s ease;
    flex-shrink: 0;
}
.form-section--details[open] > summary::after {
    transform: rotate(90deg);
}
.form-section--details > summary:hover {
    background: var(--bg-2);
}
.form-section--details[open] > summary {
    border-bottom: var(--border);
    margin-bottom: var(--space-3);
    background: var(--bg-2);
}
.form-section--details .details-icon {
    font-size: 18px;
    width: 22px;
    text-align: center;
}
.form-section--details .details-title {
    flex-shrink: 0;
}
.form-section--details .details-summary {
    font-weight: 400;
    font-size: var(--font-sm);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-left: auto;
    margin-right: var(--space-3);
}
/* When open, hide the live summary (the open content shows instead) */
.form-section--details[open] .details-summary {
    display: none;
}

/* Sticky submit bar at the bottom of the form */
.submit-bar {
    position: sticky;
    bottom: 0;
    margin: var(--space-5) calc(var(--space-5) * -1) 0;
    padding: var(--space-3) var(--space-5);
    background: linear-gradient(to top, var(--bg-0) 60%, rgba(14, 14, 20, 0));
    backdrop-filter: blur(6px);
    z-index: 10;
    border-top: 1px solid transparent;
}
.submit-bar__inner {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    justify-content: space-between;
    max-width: 820px;
    margin: 0 auto;
    background: var(--bg-1);
    border: var(--border);
    border-radius: var(--radius-md);
    padding: var(--space-3) var(--space-4);
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.3);
}
.submit-bar__inner #pipelineMsg {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.submit-bar__inner #pipelineSubmit {
    padding: 10px 20px;
    font-size: var(--font-lg);
    font-weight: 600;
    white-space: nowrap;
}

/* Make the pipeline view a bit wider to accommodate the player */
.pipeline-view {
    max-width: 960px;
    padding-bottom: 0;  /* sticky bar provides the spacing */
}

/* Modified-from-default badge on section headers */
.details-badge {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--brand);
    box-shadow: 0 0 0 2px rgba(25, 118, 210, 0.25);
    flex-shrink: 0;
}

/* Disabled sections (dependency greying) */
.form-section--details.is-disabled {
    opacity: 0.45;
    pointer-events: none;
}
.form-section--details.is-disabled > summary {
    cursor: not-allowed;
}
.form-section--details.is-disabled .details-summary::before {
    content: '⛔ ';
    color: var(--warn);
    margin-right: 4px;
}

/* Disabled individual form fields */
input:disabled, select:disabled, textarea:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ── Pipeline form polish ───────────────────────────────────── */

/* Plain section (no border/header) — for the video zone */
.form-section--plain {
    background: transparent;
    border: none;
    padding: 0;
    margin-bottom: var(--space-4);
}

/* Selected-video header row */
.video-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    margin-bottom: var(--space-3);
}
.video-header__name {
    font-weight: 600;
    font-size: var(--font-lg);
    color: var(--fg-0);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 540px;
}

/* Collapsible <details> sections */
.form-section--details {
    padding: 0;
    overflow: hidden;
}
.form-section--details > summary {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    cursor: pointer;
    user-select: none;
    list-style: none;
    transition: background 0.1s;
}
.form-section--details > summary:hover { background: var(--bg-2); }
.form-section--details > summary::-webkit-details-marker { display: none; }
.form-section--details > summary::marker { content: ''; }
.form-section--details > summary::after {
    content: '▸';
    color: var(--fg-2);
    font-size: 12px;
    margin-left: auto;
    transition: transform 0.15s;
    flex: 0 0 auto;
}
.form-section--details[open] > summary::after { transform: rotate(90deg); }
.form-section--details[open] > summary { border-bottom: var(--border); }
.form-section--details .details-icon {
    font-size: 18px;
    width: 24px;
    text-align: center;
}
.form-section--details .details-title {
    font-weight: 600;
    color: var(--fg-0);
    font-size: var(--font-lg);
}
.form-section--details .details-summary {
    margin-left: auto;
    margin-right: var(--space-2);
    font-size: var(--font-sm);
    max-width: 380px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.form-section--details[open] > *:not(summary) {
    padding-left: var(--space-4);
    padding-right: var(--space-4);
}
.form-section--details[open] > *:not(summary):first-of-type { padding-top: var(--space-3); }
.form-section--details[open] > *:not(summary):last-child { padding-bottom: var(--space-4); }

/* Sticky submit bar */
.submit-bar {
    position: sticky;
    bottom: 0;
    z-index: 20;
    background: linear-gradient(to top, var(--bg-0) 70%, rgba(14, 14, 20, 0));
    padding: var(--space-4) 0;
    margin-top: var(--space-6);
}
.submit-bar__inner {
    background: var(--bg-1);
    border: var(--border);
    border-radius: var(--radius-md);
    padding: var(--space-3) var(--space-4);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    box-shadow: var(--shadow-card);
}
.submit-bar__inner #pipelineMsg {
    flex: 1;
    font-size: var(--font-md);
    min-height: 18px;
}
.submit-bar__inner button {
    padding: 12px 24px;
    font-size: 15px;
    font-weight: 600;
    flex: 0 0 auto;
}

/* Translation QC results */
.qc-items { display: flex; flex-direction: column; gap: 6px; }
.qc-item {
    background: var(--bg-2);
    border-radius: var(--radius-sm);
    padding: 6px 8px;
    font-size: 12px;
}
.qc-head {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 4px;
}
.qc-head .qc-sev { text-transform: uppercase; font-size: 10px; font-weight: 700; letter-spacing: 0.4px; }
.qc-jump-btn {
    background: transparent; color: #64b5f6;
    border: 1px solid #444;
    font-family: ui-monospace, monospace;
    padding: 1px 6px; font-size: 11px; border-radius: 3px;
}
.qc-jump-btn:hover { background: var(--bg-3); }
.qc-pair { line-height: 1.4; }
.qc-pair > div + div { margin-top: 2px; }
.qc-pair .muted { display: inline-block; min-width: 24px; text-transform: uppercase; font-size: 10px; }
.qc-issues { margin: 4px 0 0 14px; color: var(--fg-1); padding: 0; }
.qc-issues li { list-style: disc; font-size: 11px; }
.qc-suggestion {
    margin-top: 6px;
    padding: 6px;
    background: rgba(25, 118, 210, 0.08);
    border: 1px solid rgba(25, 118, 210, 0.25);
    border-radius: 3px;
}
.qc-sug-text {
    font-style: italic;
    margin: 4px 0;
    color: var(--fg-0);
    line-height: 1.4;
}
.qc-suggestion button { font-size: 11px; padding: 3px 8px; }
.qc-suggestion button:disabled { opacity: 0.6; }

/* ── Translation QC main-view panel ─────────────────────────── */
.qc-col {
    background: #12121c;
    border: 1px solid #2a2a44;
    border-radius: 8px;
    padding: 18px 20px;
    margin-bottom: 20px;
}
.qc-col h3 {
    font-size: 16px;
    color: #e8e8f0;
    margin-bottom: 6px;
    border-bottom: 1px solid #2a2a44;
    padding-bottom: 8px;
}
.qc-col .qc-intro {
    color: #888;
    font-size: 13px;
    margin-bottom: 14px;
    max-width: 760px;
}
.qc-col .qc-controls {
    display: grid;
    grid-template-columns: 200px 280px 1fr;
    gap: 12px;
    align-items: end;
    margin-bottom: 10px;
}
@media (max-width: 900px) {
    .qc-col .qc-controls { grid-template-columns: 1fr; }
}
.qc-col .qc-controls label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin: 0;
}
.qc-col .qc-controls label span {
    color: #aaa;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.qc-col .qc-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.qc-col .qc-status {
    font-size: 13px;
    min-height: 20px;
    margin: 6px 0 14px;
}
.qc-col .qc-status.ok { color: #66bb6a; }
.qc-col .qc-status.warn { color: #fb8c00; }
.qc-col .qc-status.err { color: #ef5350; }

.qc-col .qc-summary {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding-bottom: 10px;
    border-bottom: 1px solid #2a2a44;
    margin-bottom: 12px;
}
.qc-col .qc-pill {
    display: inline-flex;
    padding: 3px 10px;
    border-radius: 14px;
    font-size: 12px;
    font-weight: 600;
}
.qc-col .qc-pill--high    { background: rgba(229, 57, 53, 0.22); color: #ef5350; }
.qc-col .qc-pill--medium  { background: rgba(251, 140, 0, 0.22); color: #fb8c00; }
.qc-col .qc-pill--low     { background: rgba(100, 181, 246, 0.2); color: #64b5f6; }
.qc-col .qc-pill--ok      { background: rgba(67, 160, 71, 0.22); color: #66bb6a; }
.qc-col .qc-pill--err     { background: rgba(239, 83, 80, 0.22); color: #ef5350; font-style: italic; }

.qc-col .qc-results {
    max-height: 680px;
    overflow-y: auto;
}
.qc-col .qc-empty {
    color: #888;
    padding: 30px;
    text-align: center;
    font-size: 14px;
}
.qc-col .qc-items {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(420px, 1fr));
    gap: 12px;
}
@media (max-width: 900px) {
    .qc-col .qc-items { grid-template-columns: 1fr; }
}
.qc-col .qc-item {
    background: #1a1a2e;
    border: 1px solid #2a2a44;
    border-radius: 6px;
    padding: 12px 14px;
    border-left-width: 4px;
    font-size: 13px;
    line-height: 1.45;
}
.qc-col .qc-item--high    { border-left-color: #ef5350; }
.qc-col .qc-item--medium  { border-left-color: #fb8c00; }
.qc-col .qc-item--low     { border-left-color: #64b5f6; }
.qc-col .qc-item--none    { border-left-color: #66bb6a; }
.qc-col .qc-item--error   { border-left-color: #ef5350; }

.qc-col .qc-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
    font-size: 12px;
}
.qc-col .qc-jump-btn {
    background: transparent;
    color: #64b5f6;
    border: 1px solid #3a3a6a;
    border-radius: 3px;
    font-family: ui-monospace, monospace;
    padding: 2px 8px;
    font-size: 11px;
}
.qc-col .qc-jump-btn:hover { background: #2a2a4a; }
.qc-col .qc-scores {
    display: flex;
    gap: 10px;
    color: #aaa;
    font-size: 12px;
}
.qc-col .qc-scores b { color: #e8e8f0; }
.qc-col .qc-sev {
    margin-left: auto;
    text-transform: uppercase;
    font-weight: 700;
    font-size: 11px;
    letter-spacing: 0.6px;
    color: #888;
}
.qc-col .qc-item--high    .qc-sev { color: #ef5350; }
.qc-col .qc-item--medium  .qc-sev { color: #fb8c00; }
.qc-col .qc-item--low     .qc-sev { color: #64b5f6; }
.qc-col .qc-item--none    .qc-sev { color: #66bb6a; }
.qc-col .qc-item--error   .qc-sev { color: #ef5350; }

.qc-col .qc-pair {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 6px;
}
.qc-col .qc-line {
    display: grid;
    grid-template-columns: 44px 1fr;
    gap: 8px;
    align-items: baseline;
}
.qc-col .qc-lbl {
    color: #888;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.5px;
    font-family: ui-monospace, monospace;
    background: #0e0e18;
    padding: 2px 6px;
    border-radius: 3px;
    text-align: center;
}
.qc-col .qc-issues {
    margin: 6px 0 0 20px;
    padding: 0;
    color: #aaa;
    font-size: 12px;
}
.qc-col .qc-issues li { list-style: disc; }
.qc-col .qc-suggestion {
    margin-top: 10px;
    padding: 10px 12px;
    background: rgba(25, 118, 210, 0.1);
    border: 1px solid rgba(25, 118, 210, 0.3);
    border-radius: 4px;
}
.qc-col .qc-suggestion .muted {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}
.qc-col .qc-sug-text {
    color: #e8e8f0;
    font-size: 14px;
    margin-bottom: 8px;
    line-height: 1.45;
}
.qc-col .qc-suggestion .btn {
    font-size: 12px;
    padding: 5px 12px;
}
.qc-col .qc-suggestion .btn.applied {
    background: #43a047;
    border-color: #43a047;
    cursor: default;
}
