/* Dispatch STT Review — light responsive theme */

:root {
    --bg: #f1f5f9;
    --surface: #ffffff;
    --surface-raised: #ffffff;
    --surface-muted: #f8fafc;
    --border: #e2e8f0;
    --border-strong: #cbd5e1;
    --text: #0f172a;
    --text-secondary: #475569;
    --muted: #64748b;
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --accent-soft: #eff6ff;
    --accent-border: #bfdbfe;
    --active: #dbeafe;
    --highlight: #ecfdf5;
    --highlight-border: #6ee7b7;
    --success: #059669;
    --success-soft: #ecfdf5;
    --warning: #d97706;
    --warning-soft: #fffbeb;
    --danger: #dc2626;
    --danger-soft: #fef2f2;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08);
    --radius: 12px;
    --radius-sm: 8px;
    --font: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    line-height: 1.5;
}

/* Header */

.app-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    flex-shrink: 0;
    z-index: 20;
}

.app-header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 20px;
    max-width: 1600px;
    margin: 0 auto;
    width: 100%;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.brand-mark {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--accent-soft);
    color: var(--accent);
    flex-shrink: 0;
}

.brand-text h1 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text);
}

.brand-subtitle {
    margin: 0;
    font-size: 0.78rem;
    color: var(--muted);
}

.app-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.toolbar-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    line-height: 1;
    min-height: 40px;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    text-decoration: none;
}

.toolbar-btn:hover {
    background: var(--surface-muted);
    color: var(--text);
    border-color: var(--border-strong);
}

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

.toolbar-btn.has-activity {
    border-color: var(--accent);
    color: var(--accent);
}

.toolbar-btn .activity-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent);
    animation: pulse-dot 1.2s ease-in-out infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.45; transform: scale(0.85); }
}

.training-panel {
    border-top: 1px solid var(--border);
    padding: 14px 20px 16px;
    background: var(--surface-muted);
}

.training-panel[hidden] { display: none; }

.training-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 14px;
    max-width: 1600px;
    margin: 0 auto;
}

.training-status-wrap {
    flex: 1;
    min-width: 200px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

#training-status-text {
    font-size: 0.88rem;
    color: var(--muted);
}

#training-status-text.running { color: var(--accent); font-weight: 500; }
#training-status-text.failed { color: var(--danger); }
#training-status-text.succeeded { color: var(--success); font-weight: 500; }

.training-progress {
    width: 100%;
    height: 8px;
    accent-color: var(--accent);
}

.training-detail {
    flex: 1 1 100%;
    font-size: 0.82rem;
    color: var(--muted);
    font-family: var(--mono);
    white-space: pre-wrap;
    line-height: 1.45;
    padding: 10px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.training-detail[hidden] { display: none; }

.training-history {
    flex: 1 1 100%;
    font-size: 0.85rem;
}

.training-history summary {
    cursor: pointer;
    color: var(--text-secondary);
    font-weight: 500;
    user-select: none;
}

.training-history table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 8px;
    background: var(--surface);
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--border);
}

.training-history th,
.training-history td {
    text-align: left;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

.training-history th {
    background: var(--surface-muted);
    color: var(--muted);
    font-weight: 600;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.training-history tr:last-child td { border-bottom: none; }

/* Layout */

.layout {
    flex: 1;
    display: grid;
    grid-template-columns: minmax(300px, 380px) 1fr;
    min-height: 0;
    max-width: 1600px;
    margin: 0 auto;
    width: 100%;
    gap: 0;
}

/* List panel */

.list-panel {
    background: var(--surface);
    border-right: 1px solid var(--border);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.filter-row {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    position: relative;
    background: var(--surface);
}

.field-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    margin-bottom: 8px;
}

.filter-combo {
    display: flex;
    gap: 8px;
    align-items: center;
}

.filter-combo input[type="search"] {
    flex: 1;
    min-width: 0;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-size: 0.9rem;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.filter-combo input[type="search"]:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.filter-active {
    font-size: 0.82rem;
    color: var(--muted);
    margin: 10px 0 0;
    line-height: 1.4;
}

.filter-active strong { color: var(--text-secondary); }

.list-mode-row {
    margin-top: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.list-mode-row label {
    font-size: 0.82rem;
    color: var(--muted);
    font-weight: 500;
}

.list-mode-row select,
.list-toolbar select {
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-size: 0.85rem;
}

.autocomplete-list {
    position: absolute;
    left: 16px;
    right: 16px;
    top: calc(100% - 6px);
    z-index: 30;
    max-height: 280px;
    overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
}

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

.autocomplete-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: 10px 12px;
    border: none;
    border-bottom: 1px solid var(--border);
    background: transparent;
    color: var(--text);
    cursor: pointer;
    font-size: 0.88rem;
}

.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover,
.autocomplete-item.active { background: var(--accent-soft); }

.autocomplete-item .type-badge {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--accent);
    background: var(--accent-soft);
    padding: 2px 6px;
    border-radius: 4px;
    margin-right: 8px;
}

.autocomplete-item .detail {
    display: block;
    font-size: 0.78rem;
    color: var(--muted);
    margin-top: 3px;
}

.list-toolbar {
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 0.82rem;
    color: var(--muted);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-shrink: 0;
    background: var(--surface-muted);
}

.list-range { font-variant-numeric: tabular-nums; }

.list-toolbar-nav { display: flex; gap: 6px; }

.message-list-items,
#message-list-items {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.list-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: 12px 16px;
    border: none;
    border-bottom: 1px solid var(--border);
    background: transparent;
    color: var(--text);
    cursor: pointer;
    transition: background 0.12s;
    min-height: 44px;
}

.list-item:hover { background: var(--surface-muted); }

.list-item.active {
    background: var(--accent-soft);
    border-left: 3px solid var(--accent);
    padding-left: 13px;
}

.list-item-top {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
}

.list-item-id {
    font-weight: 700;
    font-size: 0.92rem;
    font-variant-numeric: tabular-nums;
    color: var(--text);
}

.list-item-time {
    font-size: 0.72rem;
    color: var(--muted);
    white-space: nowrap;
}

.list-item .meta {
    font-size: 0.78rem;
    color: var(--muted);
    margin-top: 3px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.list-item .preview {
    font-size: 0.84rem;
    margin-top: 5px;
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-secondary);
}

.list-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 6px;
}

.list-badge-pill {
    display: inline-block;
    font-size: 0.68rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent);
    border: 1px solid var(--accent-border);
}

.list-badge-pill.corrected {
    background: var(--success-soft);
    color: var(--success);
    border-color: #a7f3d0;
}

/* Detail panel */

.detail-shell {
    display: flex;
    flex-direction: column;
    min-height: 0;
    min-width: 0;
    background: var(--bg);
}

.detail-back-btn {
    display: none;
    align-items: center;
    gap: 6px;
    margin: 12px 16px 0;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    min-height: 44px;
    align-self: flex-start;
    box-shadow: var(--shadow-sm);
}

.detail-back-btn:hover {
    background: var(--surface-muted);
    color: var(--text);
}

.detail-panel {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 20px 24px 32px;
    min-height: 0;
}

.message-detail { max-width: 960px; }

.empty-state {
    color: var(--muted);
    padding: 48px 24px;
    text-align: center;
}

.empty-icon {
    color: var(--border-strong);
    margin-bottom: 12px;
}

.empty-title {
    margin: 0 0 6px;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.empty-hint {
    margin: 0;
    font-size: 0.9rem;
    max-width: 320px;
    margin-inline: auto;
    line-height: 1.5;
}

/* Cards */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-sm);
}

.card-title {
    margin: 0 0 14px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--muted);
}

.message-header-card { margin-bottom: 16px; }

.message-header { margin: 0; }

.message-header-top {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.message-id {
    font-size: 1.2rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--text);
}

.message-time {
    font-size: 0.82rem;
    color: var(--muted);
}

.message-meta {
    margin-top: 6px;
    font-size: 0.88rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.message-meta-company-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
    margin-top: 4px;
}

.message-meta-company-name { color: var(--text); font-weight: 500; }
.message-meta-company-id { color: var(--muted); font-size: 0.82rem; }

.company-terms-btn {
    padding: 5px 12px;
    font-size: 0.8rem;
}

/* Audio player */

/* Keep the player visible while scrolling/editing the transcription (item 2). */
.player-card {
    position: sticky;
    top: 0;
    z-index: 5;
}

.player-card.is-stuck {
    box-shadow: var(--shadow-md);
    border-color: var(--border-strong);
}

.player-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.player-bar audio {
    flex: 1;
    min-width: 200px;
    width: 100%;
    border-radius: var(--radius-sm);
}

.playback-options {
    margin-top: 12px;
    font-size: 0.85rem;
    color: var(--muted);
}

.playback-options summary {
    cursor: pointer;
    user-select: none;
    color: var(--text-secondary);
    font-weight: 500;
}

.playback-options-inner {
    display: flex;
    flex-wrap: wrap;
    gap: 14px 20px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.speed-control,
.normalize-toggle,
.debug-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
}

.speed-control select {
    padding: 5px 10px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-size: 0.85rem;
}

/* Transcription tabs */

.transcription-tabs { margin-bottom: 0; }

.tab-bar {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 0;
}

.tab-btn {
    padding: 10px 16px;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    background: transparent;
    color: var(--muted);
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: color 0.12s, border-color 0.12s;
}

.tab-btn:hover { color: var(--text); }

.tab-btn.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.tab-panel {
    display: none;
    background: var(--surface-muted);
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    padding: 14px;
}

.tab-panel.active { display: block; }

.transcription-panel {
    background: transparent;
    border: none;
    padding: 0;
}

.transcription-panel .panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 10px;
}

.transcription-panel h3 {
    margin: 0;
    font-size: 0.95rem;
    color: var(--text-secondary);
    font-weight: 600;
}

/* Segments */

.segment-line {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    padding: 8px 10px;
    margin: 3px 0;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    line-height: 1.45;
    cursor: pointer;
    transition: background 0.12s;
}

.segment-line:hover { background: var(--surface-muted); }

.segment-line.active {
    background: var(--highlight);
    outline: 1px solid var(--highlight-border);
}

.segment-line.editing {
    cursor: default;
    background: var(--surface-muted);
}

.segment-line.corrected .segment-text { color: var(--accent); font-weight: 500; }

.segment-text { flex: 1; min-width: 0; }

.segment-edit-btn {
    flex-shrink: 0;
    border: none;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    padding: 4px 8px;
    font-size: 0.95rem;
    line-height: 1;
    opacity: 0;
    border-radius: 4px;
    min-width: 32px;
    min-height: 32px;
}

.segment-line:hover .segment-edit-btn,
.segment-line.corrected .segment-edit-btn,
.segment-line.editing .segment-edit-btn { opacity: 1; }

.segment-edit-btn:hover {
    color: var(--accent);
    background: var(--accent-soft);
}

.segment-edit-input {
    flex: 1;
    min-width: 0;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--accent);
    background: var(--surface);
    color: var(--text);
    font-family: inherit;
    font-size: 0.9rem;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.segment-line .time {
    font-size: 0.72rem;
    color: var(--muted);
    margin-right: 4px;
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
    padding-top: 2px;
}

.segment-line.readonly { cursor: pointer; }
.segment-line.tone-segment { opacity: 0.8; }
.segment-line.tone-segment .segment-text {
    font-style: italic;
    color: var(--muted);
}

/* Word-by-word highlight during playback (item 8) */
.seg-word {
    border-radius: 3px;
    padding: 0 1px;
    cursor: pointer;
    transition: background 0.08s, color 0.08s;
}

.seg-word.word-active {
    background: var(--accent);
    color: #fff;
    font-weight: 600;
}

/* Read-only transcription block + correction editor (items 1, 4, 5) */
.transcription-readonly {
    margin-top: 4px;
}

.transcription-readonly h4,
.correction-editor-head h4 {
    margin: 0 0 6px;
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.transcription-hint { margin: 0 0 8px; }

.correction-editor-wrap {
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.correction-editor-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.correction-editor-head h4 { color: var(--accent); }

.correction-editor {
    width: 100%;
    min-height: 150px;
    margin-top: 4px;
    font-size: 0.95rem;
    line-height: 1.6;
    resize: vertical;
}

.correction-editor[readonly] {
    background: var(--surface-muted);
    color: var(--text-secondary);
    cursor: default;
}

.correction-autosave-hint { margin-top: 8px; line-height: 1.45; }

/* Compare grid */

.compare-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.compare-col {
    min-width: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px;
    background: var(--surface);
}

.compare-col h4 {
    margin: 0 0 10px;
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.compare-col.correction-col h4 { color: var(--accent); }

.correction-status-pill {
    display: inline-block;
    margin-left: 6px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: none;
    letter-spacing: 0;
    vertical-align: middle;
    border: 1px solid var(--border);
}

.correction-status-pill.saved {
    color: var(--success);
    border-color: #a7f3d0;
    background: var(--success-soft);
}

.correction-status-pill.unsaved {
    color: var(--warning);
    border-color: #fde68a;
    background: var(--warning-soft);
}

.correction-status-pill.processed {
    color: var(--accent);
    border-color: var(--accent-border);
    background: var(--accent-soft);
}

/* WER & confidence */

.wer-summary {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 14px;
    padding: 12px 14px;
    background: var(--surface-muted);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
}

.wer-badge {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.wer-good { color: var(--success); }
.wer-bad { color: var(--danger); }
.wer-meta { color: var(--muted); }

.confidence-badge {
    display: inline-block;
    margin: 0 0 8px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    border: 1px solid var(--border);
}

.confidence-badge.confidence-high {
    color: var(--success);
    border-color: #a7f3d0;
    background: var(--success-soft);
}

.confidence-badge.confidence-mid {
    color: var(--warning);
    border-color: #fde68a;
    background: var(--warning-soft);
}

.confidence-badge.confidence-low {
    color: var(--danger);
    border-color: #fecaca;
    background: var(--danger-soft);
}

/* Work card footer */

.work-card .card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.work-card .card-actions .btn-primary { margin-right: auto; }

.work-card-footer { margin-top: 14px; }

.correction-processed-note {
    font-size: 0.85rem;
    color: var(--success);
    margin: 0 0 8px;
    padding: 8px 12px;
    background: var(--success-soft);
    border-radius: var(--radius-sm);
    border: 1px solid #a7f3d0;
}

.correction-user-review-note {
    font-size: 0.85rem;
    color: var(--warning);
    margin: 0 0 8px;
    padding: 8px 12px;
    background: var(--warning-soft);
    border-radius: var(--radius-sm);
    border: 1px solid #fde68a;
}

.training-scope-row { margin: 0 0 12px; }

.training-scope-row label.scope-option {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-right: 18px;
    color: var(--text);
    font-size: 0.88rem;
    cursor: pointer;
}

.force-train-row { margin: 0 0 12px; }

.force-train-row label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text);
    font-size: 0.88rem;
    cursor: pointer;
}

.training-scope-readonly,
.force-train-readonly {
    font-size: 0.85rem;
    color: var(--muted);
    margin: 0 0 8px;
}

.whisper-run-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 12px;
    flex-wrap: wrap;
}

.whisper-run-row label {
    font-size: 0.85rem;
    color: var(--muted);
    font-weight: 500;
}

.whisper-run-row select {
    flex: 1;
    min-width: 180px;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-size: 0.85rem;
}

/* LLM debug */

.llm-debug {
    margin: 10px 0 0;
    font-size: 0.82rem;
}

.llm-debug summary {
    cursor: pointer;
    color: var(--muted);
    user-select: none;
}

.llm-debug pre {
    margin: 8px 0 0;
    padding: 12px;
    background: var(--surface-muted);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 240px;
    overflow: auto;
    font-size: 0.78rem;
    line-height: 1.45;
    font-family: var(--mono);
}

.extracted-fields {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin: 0 0 8px;
}

/* Buttons */

button.btn,
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 9px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-size: 0.88rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    min-height: 40px;
    transition: background 0.12s, border-color 0.12s, color 0.12s;
    text-decoration: none;
}

button.btn:hover:not(:disabled),
.btn:hover:not(:disabled) {
    background: var(--surface-muted);
    border-color: var(--border-strong);
}

button.btn:disabled,
.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.btn-primary:hover:not(:disabled) {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    filter: none;
}

.btn-ghost {
    background: transparent;
    border-color: var(--border);
}

.btn-ghost:hover:not(:disabled) {
    background: var(--surface-muted);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.82rem;
    min-height: 34px;
}

/* Status & loading */

.status {
    font-size: 0.85rem;
    color: var(--muted);
    margin-top: 8px;
}

.status.error { color: var(--danger); }

.loading { opacity: 0.55; pointer-events: none; }

.meta-link {
    color: var(--accent);
    text-decoration: none;
    border-bottom: 1px dotted var(--accent-border);
}

textarea {
    width: 100%;
    min-height: 100px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-family: inherit;
    font-size: 0.9rem;
    resize: vertical;
}

textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

/* Modal */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    z-index: 1000;
    backdrop-filter: blur(2px);
}

.modal-overlay[hidden] { display: none; }

.modal-card {
    width: min(560px, 100%);
    max-height: min(85vh, 720px);
    overflow: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow-md);
}

.modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
    padding: 0;
    border: none;
    background: transparent;
}

.modal-card h2 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
}

.modal-close {
    border: none;
    background: transparent;
    color: var(--muted);
    font-size: 1.4rem;
    cursor: pointer;
    line-height: 1;
    padding: 4px;
    border-radius: 4px;
}

.modal-close:hover { color: var(--text); background: var(--surface-muted); }

.modal-field { margin-bottom: 16px; }

.modal-field label {
    display: block;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.modal-field select,
.modal-field textarea {
    width: 100%;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-family: inherit;
    font-size: 0.9rem;
}

.template-terms-preview {
    font-size: 0.82rem;
    color: var(--muted);
    margin-top: 6px;
    line-height: 1.45;
}

.modal-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 16px;
}

/* Responsive */

@media (max-width: 767px) {
    .app-header-inner {
        padding: 10px 14px;
    }

    .brand-subtitle { display: none; }

    .layout {
        grid-template-columns: 1fr;
    }

    .layout.show-list .detail-shell {
        display: none;
    }

    .layout.show-detail .list-panel {
        display: none;
    }

    .detail-back-btn {
        display: inline-flex;
    }

    .detail-panel {
        padding: 12px 14px 24px;
    }

    .training-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .training-bar .btn-primary { width: 100%; }

    .filter-row {
        position: sticky;
        top: 0;
        z-index: 10;
    }

    .compare-grid {
        grid-template-columns: 1fr;
    }

    .work-card .card-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .work-card .card-actions .btn,
    .work-card .card-actions .btn-primary {
        width: 100%;
        margin-right: 0;
    }

    .player-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .segment-edit-btn { opacity: 1; }

    .modal-overlay {
        padding: 0;
        align-items: flex-end;
    }

    .modal-card {
        border-radius: var(--radius) var(--radius) 0 0;
        max-height: 92dvh;
    }

    .modal-actions {
        flex-direction: column-reverse;
    }

    .modal-actions .btn { width: 100%; }
}

@media (min-width: 768px) and (max-width: 1024px) {
    .layout {
        grid-template-columns: minmax(260px, 300px) 1fr;
    }

    .compare-grid {
        grid-template-columns: 1fr;
    }
}

@media (prefers-reduced-motion: reduce) {
    .toolbar-btn .activity-dot { animation: none; }
    .list-item, .segment-line, button.btn { transition: none; }
}
