/* ═══════════════════════════════════════════════════════════
   Trans App — 翻译配音平台样式
   ═══════════════════════════════════════════════════════════ */

:root {
    --bg: #f0f2f5;
    --panel: #ffffff;
    --text: #1a1a2e;
    --muted: #6b7280;
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --accent-soft: #dbeafe;
    --line: #e5e7eb;
    --danger: #dc2626;
    --success: #16a34a;
    --warning: #d97706;
    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
    --shadow-lg: 0 4px 14px rgba(0,0,0,.1);
}

*, *::before, *::after { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans SC", sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.6;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Shell ── */

.shell { width: min(1200px, calc(100% - 24px)); margin: 0 auto; }

.topbar {
    background: var(--panel);
    border-bottom: 1px solid var(--line);
    padding: 0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
}

.topbar-inner {
    width: min(1200px, calc(100% - 24px));
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 52px;
    gap: 12px;
}

.brand {
    font-weight: 700;
    font-size: 16px;
    color: var(--text);
    white-space: nowrap;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
    white-space: nowrap;
}

.user-chip {
    font-size: 13px;
    color: var(--muted);
}

.auth-btn {
    font-size: 13px;
    background: none;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 4px 12px;
    cursor: pointer;
    color: var(--text);
}
.auth-btn:hover { background: var(--bg); }

/* ── Tabs ── */

.tabs {
    display: flex;
    gap: 2px;
    background: var(--panel);
    border-bottom: 1px solid var(--line);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.tabs-inner {
    width: min(1200px, calc(100% - 24px));
    margin: 0 auto;
    display: flex;
    gap: 2px;
}

.tab {
    padding: 10px 16px;
    font-size: 13px;
    color: var(--muted);
    white-space: nowrap;
    border-bottom: 2px solid transparent;
    transition: color .15s, border-color .15s;
}
.tab:hover { color: var(--text); text-decoration: none; }
.tab.is-active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    font-weight: 600;
}

/* ── Step Tabs ── */

.step-tabs {
    display: flex;
    gap: 0;
    background: var(--panel);
    border-bottom: 1px solid var(--line);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.step-tabs-inner {
    width: min(1200px, calc(100% - 24px));
    margin: 0 auto;
    display: flex;
    gap: 0;
}

.step-tab {
    padding: 8px 14px;
    font-size: 12px;
    color: var(--muted);
    white-space: nowrap;
    border-bottom: 2px solid transparent;
    position: relative;
}
.step-tab:hover { color: var(--text); text-decoration: none; }
.step-tab.is-active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    font-weight: 600;
}
.step-tab::after {
    content: '→';
    position: absolute;
    right: -4px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 10px;
    color: var(--line);
}
.step-tab:last-child::after { content: none; }

/* ── Page ── */

.page {
    width: min(1200px, calc(100% - 24px));
    margin: 20px auto;
    padding-bottom: 40px;
}

.page-footer-meta {
    width: min(1200px, calc(100% - 24px));
    margin: -20px auto 24px;
    font-size: 11px;
    color: var(--muted);
    opacity: 0.72;
    text-align: right;
}

.page-title {
    font-size: 20px;
    font-weight: 700;
    margin: 0 0 16px;
}

.page-subtitle {
    margin: -10px 0 16px;
    font-size: 13px;
    color: var(--muted);
}

/* ── Cards / Panels ── */

.card {
    background: var(--panel);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    margin-bottom: 16px;
}

.card-title {
    font-size: 15px;
    font-weight: 600;
    margin: 0 0 12px;
}

/* ── Buttons ── */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 18px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: background .15s, opacity .15s;
    white-space: nowrap;
}
.btn:hover { opacity: .9; text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-outline {
    background: transparent;
    border: 1px solid var(--line);
    color: var(--text);
}
.btn-outline:hover { background: var(--bg); }

.btn-sm { padding: 5px 12px; font-size: 12px; }

/* ── Forms ── */

.form-group { margin-bottom: 14px; }
.form-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 4px;
    color: var(--text);
}
.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-family: inherit;
    background: var(--panel);
    color: var(--text);
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-soft);
}
.form-textarea { resize: vertical; min-height: 80px; }
.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}

.autocomplete {
    position: relative;
}

.autocomplete-menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    z-index: 20;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 6px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
}

.autocomplete-menu[hidden] {
    display: none;
}

.autocomplete-option {
    width: 100%;
    padding: 8px 10px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text);
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.autocomplete-option:hover,
.autocomplete-option.is-active {
    background: var(--accent-soft);
    color: var(--accent-hover);
}

/* ── Task Panel ── */

.task-panel {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px;
    margin-top: 16px;
    background: #fafbfc;
}

.task-panel-title {
    font-size: 14px;
    font-weight: 600;
    margin: 0 0 10px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.task-panel-name {
    white-space: nowrap;
    flex: 0 0 auto;
}

.task-panel-meta {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
    margin: 0 0 12px;
}

.task-panel-meta-item {
    min-width: 0;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: #fff;
}

.task-panel-actions {
    display: flex;
    justify-content: flex-start;
    margin: 0 0 12px;
}

.task-panel-meta-label {
    display: block;
    margin-bottom: 4px;
    font-size: 11px;
    color: var(--muted);
}

.task-panel-meta-value {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    word-break: break-word;
    font-variant-numeric: tabular-nums;
}

@media (min-width: 640px) {
    .task-panel-meta {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.task-step {
    display: grid;
    grid-template-columns: 18px max-content minmax(0, 1fr);
    align-items: start;
    gap: 8px;
    padding: 6px 0;
    font-size: 13px;
    border-bottom: 1px solid var(--line);
}
.task-step:last-child { border-bottom: none; }

.task-step-icon {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    flex-shrink: 0;
}
.task-step-icon.queued { background: var(--line); color: var(--muted); }
.task-step-icon.running { background: var(--accent-soft); color: var(--accent); }
.task-step-icon.completed { background: #dcfce7; color: var(--success); }
.task-step-icon.failed { background: #fee2e2; color: var(--danger); }
.task-step-icon.terminated { background: #fff7ed; color: #b45309; }

.task-step-label {
    white-space: nowrap;
    flex: 0 0 auto;
}

.task-step-detail {
    color: var(--muted);
    font-size: 12px;
    min-width: 0;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.task-step-detail-lines {
    display: grid;
    gap: 4px;
}

.task-step-fold {
    margin-top: 8px;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: #f8fafc;
}

.task-step-fold-toggle {
    width: 100%;
    padding: 0;
    border: 0;
    background: none;
    color: var(--text);
    font: inherit;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
}

.task-step-fold-toggle::before {
    content: '▸';
    display: inline-block;
    margin-right: 6px;
}

.task-step-fold-toggle[aria-expanded="true"]::before {
    content: '▾';
}

.task-step-fold-body {
    margin-top: 8px;
    color: var(--muted);
    overflow-wrap: anywhere;
    word-break: break-word;
}

.task-step-table-title {
    margin-bottom: 6px;
}

.task-step-table-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 8px;
}

.task-step-table-wrap {
    overflow-x: auto;
}

.task-step-table-host-only-mode tbody tr[data-speaker-role="non_host"] {
    display: none;
}

.task-step-table {
    width: auto;
    min-width: 0;
    border-collapse: collapse;
    background: #f8fafc;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    font-size: 11px;
}

.task-step-table-compact {
    width: 100%;
    min-width: max-content;
    font-size: 10px;
    line-height: 1.3;
}

.task-step-table th,
.task-step-table td {
    padding: 4px 6px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    white-space: nowrap;
}

.task-step-table-compact th,
.task-step-table-compact td {
    padding: 3px 5px;
}

.task-step-table th {
    color: var(--text);
    font-weight: 600;
    background: #eef2ff;
}

.task-step-table tbody tr:last-child td {
    border-bottom: none;
}

.task-step-table-link {
    padding: 0;
    border: 0;
    background: none;
    color: var(--accent);
    font: inherit;
    line-height: inherit;
    text-decoration: underline;
    cursor: pointer;
    white-space: nowrap;
}

.task-step-table-link:hover {
    color: var(--accent-hover);
    text-decoration: none;
}

.task-step-table-link.is-playing {
    color: var(--accent-hover);
    font-weight: 600;
}

.task-current-detail {
    margin-top: 8px;
    font-size: 12px;
    color: var(--muted);
    overflow-wrap: anywhere;
    word-break: break-word;
}

.task-error {
    margin-top: 10px;
    padding: 10px;
    background: #fee2e2;
    border-radius: var(--radius-sm);
    color: var(--danger);
    font-size: 13px;
    word-break: break-word;
}

.task-note {
    margin-top: 10px;
    padding: 10px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    word-break: break-word;
}

.task-note-terminated {
    background: #fff7ed;
    color: #b45309;
}

/* ── Media Previews ── */

.media-player {
    margin: 12px 0;
    border-radius: var(--radius-sm);
    overflow: hidden;
}
.media-player video, .media-player audio { width: 100%; display: block; }
.media-player img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-sm);
}

/* ── Tools Grid ── */

.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
}

.tool-card {
    background: var(--panel);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    transition: box-shadow .15s;
}
.tool-card:hover { box-shadow: var(--shadow-lg); text-decoration: none; }
.tool-card-title {
    font-size: 15px;
    font-weight: 600;
    margin: 0 0 6px;
    color: var(--text);
}
.tool-card-desc {
    font-size: 13px;
    color: var(--muted);
    margin: 0;
}

.tools-history-table-wrap {
    width: 100%;
    overflow-x: auto;
}

.tools-history-table {
    width: 100%;
    border-collapse: collapse;
    background: #fafbfc;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    font-size: 13px;
}

.tools-history-table th,
.tools-history-table td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
    white-space: nowrap;
}

.tools-history-table td {
    white-space: normal;
    word-break: break-word;
}

.tools-history-table tbody tr:last-child td {
    border-bottom: none;
}

.tools-history-table thead th {
    background: #eef2ff;
    font-weight: 600;
}

.tools-history-row-current {
    background: #fff7e6;
}

.voice-preview-result-table-wrap {
    margin-top: 8px;
}

.voice-preview-name-cell {
    min-width: 180px;
}

.voice-preview-result-table audio {
    width: 100%;
    min-width: 220px;
}

/* ── Project List ── */

.project-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
}

.project-card {
    background: var(--panel);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: box-shadow .15s;
}
.project-card:hover { box-shadow: var(--shadow-lg); text-decoration: none; }

.project-card-main {
    display: block;
    color: inherit;
}

.project-card-main:hover {
    text-decoration: none;
}

.project-card-thumb-frame {
    position: relative;
    aspect-ratio: 16 / 9;
    background: var(--line);
}

.project-card-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    background: var(--line);
}

.project-card-thumb-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    font-size: 13px;
}

.project-card-body { padding: 14px; }
.project-card-title {
    font-size: 14px;
    font-weight: 600;
    margin: 0 0 4px;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.project-card-meta {
    font-size: 12px;
    color: var(--muted);
}

.project-card-note {
    margin-top: 6px;
    font-size: 12px;
    color: var(--muted);
    line-height: 1.45;
    word-break: break-word;
}

.project-card-actions {
    position: absolute;
    right: 10px;
    bottom: 10px;
    display: flex;
    gap: 6px;
    z-index: 1;
}

.project-card-action {
    padding: 6px 10px;
    border-color: rgba(255, 255, 255, .72);
    background: rgba(255, 255, 255, .92);
    backdrop-filter: blur(6px);
    box-shadow: 0 4px 12px rgba(15, 23, 42, .18);
}

.project-card-action:hover,
.project-card-action:focus-visible {
    border-color: rgba(255, 255, 255, .92);
    background: rgba(255, 255, 255, .98);
}

.project-card-action:disabled {
    opacity: .68;
    box-shadow: none;
}

.split-reference-time-group {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 8px;
}

.split-reference-time-group .form-input {
    flex: 1;
    min-width: 0;
}

.split-preview-list {
    display: grid;
    gap: 14px;
}

.split-preview-cut {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 14px;
    background: #fafbfc;
}

.split-preview-summary {
    font-size: 13px;
    margin-bottom: 12px;
    color: var(--text);
    display: grid;
    gap: 4px;
}

.split-preview-frames {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
}

.split-preview-frame {
    margin: 0;
    width: 100%;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: #fff;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 8px;
    text-align: left;
    font: inherit;
    color: inherit;
    transition: border-color .15s, background .15s, box-shadow .15s;
}

.split-preview-frame:hover,
.split-preview-frame:focus-visible {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.split-preview-frame.is-reference {
    border-color: #e2b84a;
    background: #fff8e6;
}

.split-preview-frame.is-selected {
    border-color: var(--accent);
    background: var(--accent-soft);
    box-shadow: 0 0 0 1px var(--accent);
}

.split-preview-frame img {
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    display: block;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line);
    background: var(--line);
}

.split-preview-frame-badge {
    align-self: flex-start;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 12px;
    color: #7a4b00;
    border: 1px solid #e2b84a;
    background: #fff3c7;
}

.split-preview-frame-caption {
    font-size: 12px;
    color: var(--muted);
    line-height: 1.4;
}

.split-created-project-list {
    display: grid;
    gap: 10px;
}

.split-created-project-item {
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 12px;
    background: #fafbfc;
}

.split-created-project-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 8px;
}

@media (max-width: 640px) {
    .split-reference-time-group {
        flex-direction: column;
        align-items: stretch;
    }
}

/* ── Upload Zone ── */

.upload-zone {
    border: 2px dashed var(--line);
    border-radius: var(--radius);
    padding: 30px;
    text-align: center;
    cursor: pointer;
    transition: border-color .15s, background .15s;
}
.upload-zone:hover, .upload-zone.drag-over {
    border-color: var(--accent);
    background: var(--accent-soft);
}
.upload-zone-text { color: var(--muted); font-size: 13px; margin: 8px 0 0; }

.upload-copy-item {
    padding: 8px 10px;
    display: flex;
    gap: 8px;
    align-items: center;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: #fafbfc;
}

.upload-copy-item-compact {
    gap: 6px;
}

.upload-copy-index {
    font-size: 12px;
    color: var(--muted);
    white-space: nowrap;
}

.upload-copy-source {
    flex: 1;
    min-width: 0;
    font-size: 14px;
    line-height: 1.35;
    word-break: break-word;
}

.recognize-ocr-editor {
    display: grid;
    gap: 12px;
}

.recognize-ocr-preview-shell {
    position: relative;
    width: 100%;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
    background: #0f172a;
    min-height: 220px;
}

.recognize-ocr-preview-video {
    position: absolute;
    width: 0;
    height: 0;
    opacity: 0;
    pointer-events: none;
}

.recognize-ocr-preview-canvas {
    display: block;
    width: 100%;
    height: auto;
    touch-action: none;
    cursor: crosshair;
}

.recognize-ocr-editor.is-select-mode .recognize-ocr-preview-canvas {
    cursor: default;
}

.recognize-ocr-preview-empty {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    text-align: center;
    color: rgba(255, 255, 255, .78);
    font-size: 13px;
    line-height: 1.6;
    pointer-events: none;
}

.recognize-ocr-preview-empty[hidden] {
    display: none;
}

.recognize-ocr-preview-meta {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
}

.recognize-ocr-preview-range {
    width: 100%;
}

.recognize-ocr-toolbar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.recognize-ocr-toolbar .is-active {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--accent);
}

.recognize-ocr-item-list,
.recognize-ocr-preset-list {
    display: grid;
    gap: 8px;
}

.recognize-ocr-item,
.recognize-ocr-preset {
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 10px;
    background: #fafbfc;
}

.recognize-ocr-item.is-selected,
.recognize-ocr-preset.is-selected {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, .12);
}

.recognize-ocr-item-top,
.recognize-ocr-preset-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
}

.recognize-ocr-item-actions,
.recognize-ocr-preset-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.recognize-ocr-item-title,
.recognize-ocr-preset-title {
    font-size: 13px;
    font-weight: 600;
    line-height: 1.4;
    word-break: break-word;
}

.recognize-ocr-item-coords {
    margin-top: 6px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.5;
}

.recognize-ocr-label-input {
    width: 100%;
    margin-top: 8px;
}

.recognize-ocr-preset-body {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    margin-top: 8px;
}

.recognize-ocr-preset-thumb {
    width: 112px;
    max-width: 35%;
    aspect-ratio: 16 / 9;
    border-radius: 8px;
    object-fit: cover;
    border: 1px solid var(--line);
    background: #e5e7eb;
}

.recognize-ocr-preset-meta {
    min-width: 0;
    flex: 1;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.6;
    word-break: break-word;
}

.recognize-ocr-empty-list {
    padding: 12px;
    border: 1px dashed var(--line);
    border-radius: var(--radius-sm);
    color: var(--muted);
    font-size: 12px;
    line-height: 1.6;
}

.recognize-ocr-advanced {
    border-top: 1px solid var(--line);
    padding-top: 12px;
}

.recognize-ocr-advanced > summary {
    cursor: pointer;
    color: var(--muted);
    font-size: 13px;
    user-select: none;
}

@media (max-width: 640px) {
    .recognize-ocr-preview-shell {
        min-height: 180px;
    }

    .recognize-ocr-preset-body {
        flex-direction: column;
    }

    .recognize-ocr-preset-thumb {
        width: 100%;
        max-width: none;
    }
}

/* ── Status Badges ── */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
}
.badge-queued { background: var(--line); color: var(--muted); }
.badge-running { background: var(--accent-soft); color: var(--accent); }
.badge-terminated { background: #fff7ed; color: #b45309; }
.badge-succeeded { background: #dcfce7; color: var(--success); }
.badge-failed { background: #fee2e2; color: var(--danger); }

/* ── File info ── */
.file-info {
    font-size: 12px;
    color: var(--muted);
    margin-top: 4px;
}

.field-hint {
    font-size: 12px;
    color: var(--muted);
    margin: 4px 0 0 0;
}

.synthesize-subtitle-editor {
    margin-top: 16px;
    border-top: 1px solid var(--line);
    padding-top: 16px;
}

.synthesize-subtitle-editor-toolbar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.synthesize-subtitle-editor-actions {
    display: flex;
    justify-content: flex-start;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 12px;
}

.synthesize-subtitle-editor-panel {
    margin-top: 12px;
}

.synthesize-subtitle-filter-button.is-active {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--accent);
}

.synthesize-subtitle-keyword-links {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
}

.synthesize-subtitle-proofread {
    margin-top: 12px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: #fafbfc;
}

.synthesize-subtitle-proofread-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    flex-wrap: wrap;
}

.synthesize-subtitle-proofread-controls {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: flex-end;
}

.synthesize-subtitle-proofread-submit {
    display: flex;
    align-items: flex-end;
}

.synthesize-subtitle-proofread-result {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.synthesize-subtitle-proofread-meta {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    font-size: 12px;
    color: var(--muted);
}

.synthesize-subtitle-proofread-sections {
    display: grid;
    gap: 10px;
}

.synthesize-subtitle-proofread-section {
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: #fff;
    padding: 10px 12px;
}

.synthesize-subtitle-proofread-section-title {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
}

.synthesize-subtitle-proofread-section-body {
    font-size: 13px;
    color: var(--text);
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
}

.synthesize-subtitle-proofread-table-wrap {
    overflow-x: auto;
}

.synthesize-subtitle-proofread-severity {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
}

.synthesize-subtitle-proofread-severity-high {
    background: #fee2e2;
    color: var(--danger);
}

.synthesize-subtitle-proofread-severity-medium {
    background: #fff7ed;
    color: #b45309;
}

.synthesize-subtitle-proofread-severity-low {
    background: #eff6ff;
    color: var(--accent);
}

.proofread-select-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

.synthesize-subtitle-proofread-replacement {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px dashed var(--line);
}

.synthesize-subtitle-proofread-replacement-toolbar {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.synthesize-subtitle-proofread-replacement-controls {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: flex-end;
}

.synthesize-subtitle-proofread-group-list {
    display: grid;
    gap: 8px;
}

.proofread-replacement-group-row {
    display: grid;
    grid-template-columns: auto minmax(180px, 1fr) minmax(180px, 1fr) auto;
    gap: 8px;
    align-items: center;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: #fff;
}

.proofread-replacement-group-row input {
    width: 100%;
}

.proofread-replacement-group-tag {
    font-size: 12px;
    color: var(--muted);
    white-space: nowrap;
}

.proofread-replacement-preview,
.proofread-replacement-actual,
.proofread-replacement-mismatch {
    display: grid;
    gap: 8px;
}

.proofread-replacement-empty {
    font-size: 12px;
    color: var(--muted);
}

.proofread-replacement-table-wrap {
    overflow-x: auto;
}

.proofread-replacement-table {
    table-layout: fixed;
    width: 100%;
}

.proofread-replacement-table th,
.proofread-replacement-table td {
    vertical-align: top;
}

.proofread-replacement-table td.proofread-replacement-text {
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.proofread-replacement-group-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    flex-wrap: wrap;
}

.proofread-replacement-toolbar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.proofread-replacement-toolbar .btn {
    flex: 0 0 auto;
}

.btn-copy-proofread-prompt {
    white-space: nowrap;
}

.proofread-diff-table td.proofread-diff-text {
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
    vertical-align: top;
}

.proofread-diff-table {
    table-layout: fixed;
    width: 100%;
}

.proofread-diff-table th:nth-child(1),
.proofread-diff-table td:nth-child(1) {
    width: 3.5em;
}

.proofread-diff-table th:nth-child(4),
.proofread-diff-table td:nth-child(4) {
    width: 4em;
}

mark.proofread-highlight-wrong {
    background: #ffe4e6;
    color: #be123c;
    border-radius: 2px;
    padding: 0 2px;
    font-style: normal;
}

mark.proofread-highlight-correct {
    background: #dcfce7;
    color: #15803d;
    border-radius: 2px;
    padding: 0 2px;
    font-style: normal;
}

.synthesize-subtitle-proofread-applied {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.synthesize-subtitle-keyword-group {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    font-size: 12px;
}

.synthesize-subtitle-keyword-label {
    color: var(--text);
    font-weight: 600;
}

.synthesize-subtitle-keyword-link {
    color: var(--accent);
    text-decoration: none;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--accent-soft);
    border: 1px solid rgba(37, 99, 235, 0.18);
}

.synthesize-subtitle-keyword-link:hover,
.synthesize-subtitle-keyword-link:focus-visible {
    text-decoration: none;
    border-color: rgba(37, 99, 235, 0.36);
}

.synthesize-subtitle-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 12px;
}

.synthesize-subtitle-list.synthesize-dubbed-only-mode .synthesize-subtitle-segment[data-audio-mode="original"] {
    display: none;
}

.synthesize-subtitle-segment {
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 12px;
    background: #fafbfc;
}

.synthesize-subtitle-segment-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px 12px;
    flex-wrap: wrap;
    margin-bottom: 8px;
    font-size: 13px;
}

.synthesize-subtitle-gap {
    color: var(--muted);
    font-size: 12px;
}

.synthesize-subtitle-metrics {
    display: flex;
    gap: 8px 12px;
    flex-wrap: wrap;
    margin-bottom: 8px;
    font-size: 12px;
    color: var(--muted);
}

.synthesize-subtitle-source {
    margin: 4px 0 6px;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line);
    background: #fff;
}

.synthesize-subtitle-source-label {
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 4px;
}

.synthesize-subtitle-source-content {
    font-size: 13px;
    white-space: pre-wrap;
    word-break: break-word;
}

.synthesize-subtitle-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.synthesize-subtitle-metric-ok {
    color: var(--success);
}

.synthesize-subtitle-metric-fail {
    color: var(--danger);
}

/* ── Responsive ── */

@media (max-width: 640px) {
    .topbar-inner { height: 46px; }
    .brand { font-size: 14px; }
    .page { margin: 12px auto; }
    .page-title { font-size: 17px; }
    .card { padding: 14px; }
    .form-row { grid-template-columns: 1fr; }
    .tools-grid { grid-template-columns: 1fr; }
    .project-grid { grid-template-columns: 1fr; }
    .step-tab { padding: 6px 10px; font-size: 11px; }
    .tab { padding: 8px 12px; font-size: 12px; }
    .upload-copy-item {
        flex-direction: column;
        gap: 6px;
        align-items: flex-start;
    }
    .upload-copy-source {
        white-space: normal;
        overflow: visible;
        text-overflow: clip;
        word-break: break-word;
    }
    .upload-copy-item .btn {
        align-self: flex-start;
    }
    .synthesize-subtitle-editor-toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    .synthesize-subtitle-proofread-toolbar,
    .synthesize-subtitle-proofread-controls {
        flex-direction: column;
        align-items: stretch;
    }
    .proofread-replacement-group-row {
        grid-template-columns: 1fr 1fr auto;
        align-items: center;
    }
    .proofread-replacement-group-tag {
        grid-column: 1 / -1;
    }
    .proofread-replacement-toolbar {
        flex-wrap: nowrap;
        justify-content: space-between;
    }
    .proofread-replacement-toolbar .btn {
        flex: 1 1 0;
        min-width: 0;
        white-space: nowrap;
        padding-left: 8px;
        padding-right: 8px;
        font-size: 12px;
    }
    .synthesize-subtitle-keyword-group {
        align-items: flex-start;
    }
    .synthesize-subtitle-actions .btn {
        flex: 1 1 auto;
    }
    .tools-history-table {
        font-size: 12px;
    }
    .tools-history-table th,
    .tools-history-table td {
        padding: 6px 8px;
    }
    .voice-preview-name-cell {
        min-width: 140px;
    }
    .voice-preview-result-table audio {
        min-width: 140px;
    }
}
