/* Transcribe app — app-specific styles. Shared look/feel lives in
   ../../css/{shared,app-shell,modal,dropdown}.css.

   Design language: MD3 tonal, indigo accent, fluid spacing scale.
   Mobile-first. Breakpoints: sm 640 · md 768 · lg 1024. */

:root {
    --tx-accent: #6366f1;
    --tx-accent-hover: #4f46e5;
    --tx-accent-soft: rgba(99, 102, 241, 0.12);
    --tx-accent-softer: rgba(99, 102, 241, 0.06);
    --tx-danger: #ef4444;
    --tx-danger-soft: rgba(239, 68, 68, 0.12);

    /* Fluid type scale — readable on phones, comfortable on desktop. */
    --tx-fs-xs: 0.75rem;
    --tx-fs-sm: 0.875rem;
    --tx-fs-base: 0.95rem;
    --tx-fs-md: 1rem;
    --tx-fs-lg: 1.125rem;
    --tx-fs-xl: 1.5rem;
}

body {
    -webkit-tap-highlight-color: transparent;
}

/* ──────────────────────────────────────────────────────────────────
   Page shell
   ────────────────────────────────────────────────────────────────── */
.tx-main {
    max-width: 1100px;
    margin: 0 auto;
    padding: 1.25rem 1rem 4rem;
}
@media (min-width: 768px) {
    .tx-main { padding: 2rem 1.5rem 5rem; }
}

.tx-card {
    background: var(--card-bg, #fff);
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 16px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 4px 12px rgba(15, 17, 24, 0.04);
    padding: 1.25rem;
}
@media (min-width: 768px) { .tx-card { padding: 1.75rem 2rem; } }

/* Views — all sections use the same vertical rhythm. */
.tx-view { display: flex; flex-direction: column; gap: 1.25rem; }
@media (min-width: 768px) { .tx-view { gap: 1.5rem; } }
.tx-view-center { align-items: center; text-align: center; padding: 2rem 0; }
/* Tailwind's `hidden` is `display: none`; our `.tx-view` rule loads later
   and would otherwise win the cascade. Force `hidden` to take precedence
   on view sections so showView() can actually hide them. */
.tx-view.hidden { display: none; }

/* ──────────────────────────────────────────────────────────────────
   Card header (title + user chip)
   ────────────────────────────────────────────────────────────────── */
.tx-card-header {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--border-color, #e5e7eb);
}
@media (min-width: 768px) {
    .tx-card-header {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }
}
.tx-card-header-titles { min-width: 0; }
.tx-card-subtitle {
    margin-top: 0.35rem;
    color: var(--md-on-surface-variant);
    font-size: var(--tx-fs-sm);
    line-height: 1.5;
    max-width: 60ch;
}
@media (min-width: 768px) { .tx-card-subtitle { font-size: var(--tx-fs-base); } }

/* User chip (avatar + name + logout) — reuses shell tokens. */
.tx-user-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.25rem 0.25rem 0.5rem;
    border-radius: var(--md-shape-full);
    background: var(--md-surface-container);
    color: var(--md-on-surface);
    align-self: flex-start;
}
@media (min-width: 768px) { .tx-user-chip { align-self: auto; } }
.tx-user-avatar {
    width: 32px; height: 32px; border-radius: 50%;
    overflow: hidden; background: var(--md-surface-container-high);
    display: flex; align-items: center; justify-content: center;
    color: var(--md-on-surface-variant);
    flex-shrink: 0;
}
.tx-user-avatar img { width: 100%; height: 100%; object-fit: cover; }
.tx-user-avatar .material-symbols-outlined { font-size: 22px; }
.tx-user-meta {
    display: flex; flex-direction: column; line-height: 1.15;
    font-size: var(--tx-fs-sm); padding-right: 0.25rem;
    min-width: 0;
}
.tx-user-greeting { color: var(--md-on-surface-variant); font-size: var(--tx-fs-xs); }
.tx-user-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 14ch; }

/* ──────────────────────────────────────────────────────────────────
   Drop zone
   ────────────────────────────────────────────────────────────────── */
.tx-dropzone {
    position: relative;
    border: 2px dashed var(--border-color, #d1d5db);
    border-radius: 20px;
    padding: 2rem 1.25rem;
    text-align: center;
    cursor: pointer;
    background: var(--md-surface-container-low, #f8fafc);
    transition: border-color 150ms ease, background 150ms ease, transform 150ms ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}
.tx-dropzone:hover,
.tx-dropzone:focus-visible {
    border-color: var(--tx-accent);
    background: var(--tx-accent-softer);
    outline: none;
}
.tx-dropzone.drag-over {
    border-color: var(--tx-accent);
    background: var(--tx-accent-softer);
    transform: scale(1.005);
}
@media (min-width: 768px) {
    .tx-dropzone { padding: 3rem 2rem; gap: 1rem; }
}
.tx-dropzone-icon-wrap {
    width: 64px; height: 64px;
    border-radius: 50%;
    background: var(--tx-accent-soft);
    color: var(--tx-accent);
    display: flex; align-items: center; justify-content: center;
    transition: transform 200ms ease;
}
.tx-dropzone:hover .tx-dropzone-icon-wrap { transform: translateY(-2px); }
.tx-dropzone-icon-wrap .material-symbols-outlined { font-size: 36px; }
.tx-dropzone-title {
    font-size: var(--tx-fs-md);
    font-weight: 600;
    color: var(--md-on-surface, #111827);
}
@media (min-width: 768px) { .tx-dropzone-title { font-size: var(--tx-fs-lg); } }
.tx-dropzone-sub {
    font-size: var(--tx-fs-sm);
    color: var(--md-on-surface-variant, #6b7280);
    margin-top: 0.15rem;
}
.tx-dropzone-formats {
    display: flex; flex-wrap: wrap; justify-content: center; gap: 0.4rem;
    margin-top: 0.25rem;
}
.tx-dropzone-formats span {
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    padding: 0.2rem 0.5rem;
    border-radius: 999px;
    background: var(--md-surface-container, #eef0f4);
    color: var(--md-on-surface-variant, #6b7280);
}

/* ──────────────────────────────────────────────────────────────────
   Action rows (record button, recorder buttons)
   ────────────────────────────────────────────────────────────────── */
.tx-action-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
}
.tx-action-row-center { justify-content: center; }
.tx-hint {
    font-size: var(--tx-fs-sm);
    color: var(--md-on-surface-variant, #6b7280);
}

.tx-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0 1.25rem;
    height: 44px;
    font-size: var(--tx-fs-sm);
    font-weight: 600;
    border-radius: var(--md-shape-full);
    border: none;
    cursor: pointer;
    transition: background 150ms ease, transform 80ms ease, box-shadow 150ms ease;
    white-space: nowrap;
}
.tx-btn:active { transform: scale(0.98); }
.tx-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.tx-btn .material-symbols-outlined { font-size: 20px; }
.tx-btn-sm { height: 36px; padding: 0 1rem; font-size: var(--tx-fs-xs); }

.tx-btn-record { background: var(--tx-danger); color: #fff; }
.tx-btn-record:hover { background: #dc2626; }

.tx-btn-stop { background: var(--tx-danger); color: #fff; }
.tx-btn-stop:hover { background: #dc2626; }

.tx-btn-ghost {
    background: var(--md-surface-container, #eef0f4);
    color: var(--md-on-surface, #111827);
}
.tx-btn-ghost:hover { background: var(--md-surface-container-high, #e2e5eb); }

.tx-btn-primary {
    background: var(--tx-accent);
    color: #fff;
    box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
.tx-btn-primary:hover { background: var(--tx-accent-hover); }

/* ──────────────────────────────────────────────────────────────────
   Options panel
   ────────────────────────────────────────────────────────────────── */
.tx-options {
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 14px;
    background: var(--md-surface-container-low, #f8fafc);
    overflow: hidden;
}
.tx-options[open] { background: var(--md-surface-container-low, #f8fafc); }
.tx-options-summary {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.85rem 1rem;
    font-size: var(--tx-fs-sm);
    font-weight: 600;
    color: var(--md-on-surface, #1f1f1f);
    cursor: pointer;
    list-style: none;
    user-select: none;
}
.tx-options-summary::-webkit-details-marker { display: none; }
.tx-options-chev {
    font-size: 20px;
    color: var(--md-on-surface-variant, #6b7280);
    transition: transform 150ms ease;
}
.tx-options[open] .tx-options-chev { transform: rotate(90deg); }
.tx-options-body {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    padding: 0 1rem 1rem;
}
@media (min-width: 640px) { .tx-options-body { grid-template-columns: 1fr 1fr; } }
.tx-field { display: flex; flex-direction: column; gap: 0.35rem; min-width: 0; }
.tx-field-full { grid-column: 1 / -1; }
.tx-label {
    font-size: var(--tx-fs-xs);
    font-weight: 600;
    color: var(--md-on-surface-variant, #6b7280);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.tx-input,
.tx-textarea {
    width: 100%;
    background: var(--card-bg, #fff);
    color: var(--md-on-surface, #111827);
    border: 1px solid var(--border-color, #d1d5db);
    border-radius: 10px;
    padding: 0.55rem 0.75rem;
    font-size: var(--tx-fs-sm);
    line-height: 1.45;
    outline: none;
    transition: border-color 120ms ease, box-shadow 120ms ease;
}
.tx-input:focus,
.tx-textarea:focus {
    border-color: var(--tx-accent);
    box-shadow: 0 0 0 3px var(--tx-accent-soft);
}
.tx-input-sm { padding: 0.35rem 0.6rem; font-size: var(--tx-fs-xs); height: 34px; }
.tx-textarea { resize: vertical; min-height: 60px; font-family: inherit; }

/* ──────────────────────────────────────────────────────────────────
   Section (History etc.)
   ────────────────────────────────────────────────────────────────── */
.tx-section { display: flex; flex-direction: column; gap: 0.75rem; }
.tx-section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
}
.tx-section-title {
    font-size: var(--tx-fs-md);
    font-weight: 700;
    color: var(--md-on-surface, #111827);
}
.tx-section-tools { display: flex; align-items: center; gap: 0.4rem; }
.tx-search {
    position: relative;
    display: flex;
    align-items: center;
}
.tx-search-icon {
    position: absolute; left: 0.55rem;
    color: var(--md-on-surface-variant, #6b7280);
    font-size: 18px; pointer-events: none;
}
.tx-search-input {
    background: var(--card-bg, #fff);
    border: 1px solid var(--border-color, #d1d5db);
    border-radius: 10px;
    padding: 0.4rem 0.6rem 0.4rem 2.1rem;
    font-size: var(--tx-fs-sm);
    width: 200px;
    outline: none;
    color: var(--md-on-surface, #111827);
}
.tx-search-input:focus { border-color: var(--tx-accent); box-shadow: 0 0 0 3px var(--tx-accent-soft); }
@media (max-width: 479px) { .tx-search-input { width: 140px; } }

.tx-list { display: flex; flex-direction: column; gap: 0.5rem; }

/* History card */
.history-card {
    background: var(--card-bg, #fff);
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 12px;
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    transition: background 120ms ease, border-color 120ms ease;
}
.history-card:hover { background: var(--tx-accent-softer); border-color: var(--tx-accent-soft); }
.history-card .history-meta { font-size: var(--tx-fs-xs); color: var(--md-on-surface-variant, #6b7280); flex-wrap: wrap; row-gap: 0.25rem; }
.history-card .history-meta > span { white-space: nowrap; }
.history-card .history-status {
    display: inline-block;
    font-size: 0.7rem; font-weight: 600;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    background: var(--tx-accent-soft);
    color: var(--tx-accent);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.history-card .history-status.failed     { background: var(--tx-danger-soft); color: var(--tx-danger); }
.history-card .history-status.processing { background: rgba(245, 158, 11, 0.15); color: #b45309; }
.history-card .history-title {
    font-weight: 600;
    font-size: var(--tx-fs-sm);
    color: var(--md-on-surface, #111827);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    flex: 1; min-width: 0;
}

/* ──────────────────────────────────────────────────────────────────
   Recording view
   ────────────────────────────────────────────────────────────────── */
.tx-recorder {
    width: 100%;
    max-width: 480px;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    background: var(--md-surface-container-low, #f8fafc);
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 18px;
    padding: 1.5rem;
}
.tx-recorder-head { display: flex; align-items: center; gap: 0.75rem; }
.tx-recorder-label { font-size: var(--tx-fs-lg); font-weight: 600; }
.tx-recorder-timer {
    margin-left: auto;
    font-variant-numeric: tabular-nums;
    font-size: var(--tx-fs-md);
    color: var(--md-on-surface-variant, #6b7280);
}
.tx-level-wrap {
    display: flex; align-items: center; gap: 0.6rem;
    height: 56px;
    padding: 0 0.75rem;
    background: var(--md-surface-container, #eef0f4);
    border-radius: 12px;
}
.tx-level-icon { color: var(--md-on-surface-variant, #6b7280); font-size: 22px; }
.tx-level-bar { display: flex; align-items: flex-end; gap: 3px; flex: 1; height: 40px; overflow: hidden; }
#levelBar .level-bar {
    width: 4px;
    background: var(--tx-accent);
    border-radius: 2px;
    height: 4px;
    transition: height 60ms linear, opacity 80ms linear;
    opacity: 0.4;
}

.recording-dot {
    width: 12px; height: 12px;
    border-radius: 999px;
    background: var(--tx-danger);
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.5);
    animation: tx-pulse 1.4s ease-out infinite;
}
@keyframes tx-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.5); }
    70%  { box-shadow: 0 0 0 12px rgba(239, 68, 68, 0); }
    100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

/* ──────────────────────────────────────────────────────────────────
   Processing view
   ────────────────────────────────────────────────────────────────── */
/* Shared transcript viewer (view/index.html) loading / error placeholder.
   Center the spinner + status text both horizontally and vertically,
   mirroring the main app's .tx-view-center convention. */
.tx-view-status {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 3rem 0;
}
/* The loading/error placeholder carries an explicit unlayered display, which
   beats Tailwind v4's layered `.hidden` utility — so `showContent()` adding
   `.hidden` would never hide it and the spinner would stick forever on top of
   the loaded result (same cascade-layer trap as #appError below). Override it
   explicitly. #viewContent is hidden the same way for symmetry. */
#viewStatus.hidden,
#viewContent.hidden { display: none; }
.spinner {
    width: 56px; height: 56px;
    border-radius: 50%;
    border: 4px solid var(--tx-accent-soft);
    border-top-color: var(--tx-accent);
    animation: tx-spin 0.9s linear infinite;
}
@keyframes tx-spin { to { transform: rotate(360deg); } }
.tx-processing-label {
    margin-top: 1rem;
    font-size: var(--tx-fs-md);
    font-weight: 600;
}
.tx-processing-detail {
    margin-top: 0.25rem;
    font-size: var(--tx-fs-sm);
    color: var(--md-on-surface-variant, #6b7280);
    max-width: 32ch;
}

/* ──────────────────────────────────────────────────────────────────
   Result view — header / actions
   ────────────────────────────────────────────────────────────────── */
.tx-result-head {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
@media (min-width: 768px) {
    .tx-result-head {
        flex-direction: row;
        align-items: flex-start;
        justify-content: space-between;
    }
}
.tx-result-meta { min-width: 0; flex: 1; }
.tx-result-title {
    width: 100%;
    font-size: var(--tx-fs-lg);
    font-weight: 700;
    color: var(--md-on-surface, #111827);
    background: transparent;
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 0.25rem 0.4rem;
    margin-left: -0.4rem;
    outline: none;
    transition: border-color 120ms ease, background 120ms ease;
    font-family: inherit;
}
.tx-result-title:hover { border-color: var(--border-color, #e5e7eb); }
.tx-result-title:focus { border-color: var(--tx-accent); background: var(--tx-accent-softer); }
@media (min-width: 768px) { .tx-result-title { font-size: var(--tx-fs-xl); } }
.tx-result-pills {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
    margin-top: 0.5rem;
    padding-left: 0.4rem;
}
.tx-pill {
    display: inline-flex;
    align-items: center;
    font-size: var(--tx-fs-xs);
    font-weight: 600;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    background: var(--md-surface-container, #eef0f4);
    color: var(--md-on-surface-variant, #4b5563);
    letter-spacing: 0.02em;
}
.tx-result-time {
    font-size: var(--tx-fs-xs);
    color: var(--md-on-surface-variant, #6b7280);
    padding-left: 0.25rem;
}
.tx-result-actions {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex-shrink: 0;
}
.tx-danger { color: var(--tx-danger) !important; }
.tx-danger:hover { color: var(--tx-danger) !important; }

/* ──────────────────────────────────────────────────────────────────
   Custom audio player (mirrors slides/studio)
   ────────────────────────────────────────────────────────────────── */
.custom-audio-player {
    display: flex;
    flex-direction: column;
    width: 100%;
    background: #f0f4f9;
    border-radius: 20px;
    padding: 12px;
    gap: 12px;
    border: 1px solid rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
    user-select: none;
}
.dark .custom-audio-player {
    background: #1e1f20;
    border-color: rgba(255, 255, 255, 0.1);
}
.audio-controls-main { display: flex; align-items: flex-end; gap: 12px; }
.play-pause-btn {
    width: 44px; height: 44px;
    border-radius: 50%;
    background: #004a77;
    color: white !important;
    display: flex; align-items: center; justify-content: center;
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), background 0.2s;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border: none;
    flex-shrink: 0;
}
.play-pause-btn:hover { transform: scale(1.05); background: #003a5c; }
.dark .play-pause-btn { background: #a8c7fa; color: #062e6f !important; }
.dark .play-pause-btn:hover { background: #d3e3fd; }
.progress-container { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.progress-bar-wrapper {
    position: relative;
    height: 6px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 3px;
    cursor: pointer;
    overflow: visible;
}
.dark .progress-bar-wrapper { background: rgba(255, 255, 255, 0.1); }
.progress-bar-fill {
    position: absolute; left: 0; top: 0; height: 100%;
    background: #004a77;
    border-radius: 3px; width: 0%;
    pointer-events: none;
}
.dark .progress-bar-fill { background: #a8c7fa; }
.progress-thumb {
    position: absolute; top: 50%; left: 0%;
    transform: translate(-50%, -50%);
    width: 14px; height: 14px;
    background: #004a77;
    border-radius: 50%;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    transition: transform 0.1s;
    pointer-events: none;
}
.progress-bar-wrapper:hover .progress-thumb { transform: translate(-50%, -50%) scale(1.2); }
.dark .progress-thumb { background: #a8c7fa; }
.audio-time {
    font-size: 11px;
    color: #5f6368;
    font-weight: 500;
    display: flex;
    justify-content: space-between;
    font-family: monospace;
}
.dark .audio-time { color: #9aa0a6; }
.audio-action-btn {
    padding: 6px;
    border-radius: 50%;
    color: #5f6368 !important;
    transition: background 0.2s;
    display: flex; align-items: center; justify-content: center;
}
.audio-action-btn:hover { background: rgba(0, 0, 0, 0.05); }
.dark .audio-action-btn { color: #c4c7c5 !important; }
.dark .audio-action-btn:hover { background: rgba(255, 255, 255, 0.1); }
.custom-audio-player .material-symbols-outlined { font-size: 24px; }

/* ──────────────────────────────────────────────────────────────────
   Tabs strip + responsive grid
   ────────────────────────────────────────────────────────────────── */
.tx-tabs {
    position: relative;
    display: flex;
    gap: 0.25rem;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    border-bottom: 1px solid var(--border-color, #e5e7eb);
    margin: 0 -0.25rem;
    padding: 0 0.25rem;
}
/* Sliding active-tab underline. Lives inside the (scrollable) tab bar so it
   tracks horizontal scroll for free; positionTabIndicator() sets its x-offset
   and width to the active button. Replaces the per-tab border-bottom so the
   accent line glides between tabs instead of fading in place. */
.tx-tab-indicator {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 2px;
    width: 0;
    background: var(--tx-accent);
    border-radius: 2px;
    transform: translateX(0);
    opacity: 0;
    pointer-events: none;
    transition: transform 280ms cubic-bezier(0.16, 1, 0.3, 1),
                width 280ms cubic-bezier(0.16, 1, 0.3, 1);
}
.tx-tab-indicator.ready { opacity: 1; }
.tx-tabs::-webkit-scrollbar { display: none; }
.tx-tab {
    flex-shrink: 0;
    padding: 0.65rem 0.85rem;
    font-size: var(--tx-fs-sm);
    font-weight: 500;
    color: var(--md-on-surface-variant, #6b7280);
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    white-space: nowrap;
    transition: color 120ms ease, border-color 120ms ease;
    font-family: inherit;
}
.tx-tab:hover { color: var(--md-on-surface, #111827); }
.tx-tab.active {
    color: var(--tx-accent);
    font-weight: 600;
    /* Underline is drawn by the sliding .tx-tab-indicator, not a static border. */
}

.tx-result-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.25rem;
}
@media (min-width: 1024px) {
    .tx-result-grid {
        grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
        gap: 1.5rem;
    }
}

/* Tab panels: on mobile/sm/md we toggle which panel is visible.
   On lg+ the transcript is pinned left, side panels are pinned right
   and only the active side panel shows. */
.tx-tab-panel { display: none; }
.tx-tab-panel.active { display: block; }
@media (min-width: 1024px) {
    #transcriptPanel { display: block; }                    /* always shown on lg+ */
    .tx-side-panels > .tx-tab-panel { display: none; }     /* …only active side panel */
    .tx-side-panels > .tx-tab-panel.active { display: flex; flex-direction: column; }
    .tx-transcript-panel { height: fit-content; }
    /* Chat panel matches the transcript panel's height (same max-height
       formula as #viewTranscriptPanel below) instead of sizing to its own
       content, so the two side-by-side columns end at the same line. The
       message list absorbs the slack and scrolls internally. */
    #viewPanelChat.active {
        max-height: calc(100dvh - 120px);
        overflow: hidden;
    }
    #viewPanelChat.active .tx-chat-list {
        flex: 1;
        min-height: 0;
        max-height: none;
    }
}

/* Slide-in when a tab panel becomes active. A CSS animation (re)starts as an
   element goes from display:none → shown, so this fires on a real tab switch.
   Scoped to panels that actually toggle: the side panels (every layout) and the
   transcript panel where it toggles (mobile + stacked). The split-desktop
   transcript is pinned-visible, so it's excluded below to avoid a needless
   fade. Disabled under prefers-reduced-motion further down. */
@keyframes txTabSlideIn {
    from { opacity: 0; transform: translateX(14px); }
    to   { opacity: 1; transform: translateX(0); }
}
.tx-side-panels > .tx-tab-panel.active,
#viewTranscriptPanel.active {
    animation: txTabSlideIn 200ms cubic-bezier(0.16, 1, 0.3, 1);
    will-change: transform, opacity;
}
@media (min-width: 1024px) {
    /* Pinned-visible in split layout — don't re-animate on tab clicks. */
    .tx-result-grid[data-layout="split"] #viewTranscriptPanel.active {
        animation: none;
        will-change: auto;
    }
}

.tx-transcript-panel {
    background: var(--md-surface-container-lowest, #fff);
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 14px;
    padding: 1rem;
}
@media (min-width: 1024px) {
    .tx-transcript-panel {
        position: sticky;
        top: 88px;
        max-height: calc(100vh - 120px);
        overflow: hidden;
        display: flex;
        flex-direction: column;
    }
}
/* Viewer (/view): keep the transcript panel inside the viewport at every
   breakpoint so only its segment list scrolls — the page never grows past
   screen height. (The home result view already caps this on lg+ above.) */
#viewTranscriptPanel {
    max-height: calc(100dvh - 120px);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
#viewTranscriptPanel .tx-segments { flex: 1; min-height: 0; }

/* Combined translation view: under the Translation tab, each segment
   card in #viewTranscriptPanel shows the original text and the
   translation together (see .segment-translation) — there is no
   separate translation panel. The transcript panel takes the full
   grid width and the (now-empty) side panels area is hidden. The
   class is toggled explicitly in setActiveTab(). Specificity beats
   the stacked-mode "hide transcript unless its tab is active" rule
   below, so the transcript stays visible across all layouts. */
.tx-result-grid.tx-translation-active #viewTranscriptPanel,
.tx-result-grid.tx-translation-active[data-layout="stacked"] #viewTranscriptPanel {
    display: flex;
}
.tx-result-grid.tx-translation-active .tx-side-panels {
    display: none;
}
@media (min-width: 1000px) {
    .tx-result-grid.tx-translation-active #viewTranscriptPanel {
        grid-column: 1 / -1;
    }
}

/* Hint shown above the segment list on the Translation tab when no
   target language is picked yet, or a translation hasn't been
   generated for the selected language. */
.tx-translation-hint {
    font-size: var(--tx-fs-sm, 0.8125rem);
    color: var(--text-muted, #64748b);
    padding: 0.5rem 0.25rem;
}

/* Inline translation under a segment's original text (Translation tab). */
.segment-translation {
    margin-top: 0.35rem;
    padding-top: 0.35rem;
    border-top: 1px dashed var(--border-color, #e5e7eb);
    font-size: var(--tx-fs-sm, 0.8125rem);
    color: var(--text-muted, #64748b);
    line-height: 1.5;
}

/* Tabs row: tab strip on the left, layout toggle on the right (desktop only). */
.tx-tabs-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    border-bottom: 1px solid var(--border-color, #e5e7eb);
}
.tx-tabs-row .tx-tabs { flex: 1; border-bottom: none; }
.tx-layout-toggle {
    display: none;                 /* hidden on mobile — stacked is the only option */
    gap: 2px;
    padding: 2px;
    border-radius: 9999px;
    background: var(--md-surface-container, #f1f5f9);
    margin-bottom: 6px;            /* align with the tab strip baseline */
}
.tx-layout-opt {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 28px;
    border-radius: 9999px;
    background: transparent;
    border: none;
    color: var(--text-muted, #64748b);
    cursor: pointer;
    transition: background-color 120ms ease, color 120ms ease;
}
.tx-layout-opt:hover { color: var(--text-color, #0f172a); }
.tx-layout-opt.active {
    background: var(--md-surface-container-lowest, #fff);
    color: var(--tx-accent, #4f46e5);
    box-shadow: 0 1px 2px rgba(0,0,0,.06);
}
.tx-layout-opt .material-symbols-outlined { font-size: 18px; }
/* Desktop threshold = 1000px (not Tailwind's lg/1024px). */
@media (min-width: 1000px) {
    .tx-layout-toggle { display: inline-flex; }
}

/* Default / split mode (desktop) — controlled by [data-layout] on the grid.
   The split (2-column) layout is the default; stacked collapses to a single
   column where the tab strip selects which panel is visible. */
.tx-result-grid { transition: grid-template-columns 160ms ease; }
@media (min-width: 1000px) {
    /* When the Transcript tab is active, it must occupy the full width
       regardless of layout mode. The right-hand side panel is for the
       other tabs (Summary, Minutes, Translation, Chat) — Transcript
       doesn't share a column with anything. */
    .tx-result-grid[data-layout="split"] #viewTranscriptPanel.active,
    .tx-result-grid[data-layout="stacked"] #viewTranscriptPanel.active {
        grid-column: 1 / -1;
    }
    .tx-result-grid[data-layout="split"] {
        grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
        gap: 1.5rem;
    }
    .tx-result-grid[data-layout="split"] #viewTranscriptPanel { display: flex; }
    .tx-result-grid[data-layout="split"] .tx-side-panels > .tx-tab-panel { display: none; }
    .tx-result-grid[data-layout="split"] .tx-side-panels > .tx-tab-panel.active { display: flex; }

    .tx-result-grid[data-layout="stacked"] {
        grid-template-columns: minmax(0, 1fr);
        gap: 1.25rem;
    }
    .tx-result-grid[data-layout="stacked"] #viewTranscriptPanel { display: none; }
    .tx-result-grid[data-layout="stacked"] #viewTranscriptPanel.active { display: flex; }
    .tx-result-grid[data-layout="stacked"] .tx-side-panels > .tx-tab-panel { display: none; }
    .tx-result-grid[data-layout="stacked"] .tx-side-panels > .tx-tab-panel.active { display: flex; }
}

/* Mid-width band (1000–1023px): at this width the side panel is too
   cramped to be a single full-height column alongside the transcript in
   split mode, and stacked mode is too sparse. Lay the side panels out as
   a 2-column mini-grid (Summary | Minutes, Translation | Chat) in the
   right column under split, or as a 2-column grid in stacked mode. */
@media (min-width: 1000px) and (max-width: 1023.98px) {
    /* Split: the right-hand side panels become a 2-column mini-grid; the
       active one takes the full row so it isn't awkwardly clipped. */
    .tx-result-grid[data-layout="split"] .tx-side-panels {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.75rem;
        align-content: start;
    }
    .tx-result-grid[data-layout="split"] .tx-side-panels > .tx-tab-panel { display: none; }
    .tx-result-grid[data-layout="split"] .tx-side-panels > .tx-tab-panel.active {
        display: flex;
        flex-direction: column;
        grid-column: 1 / -1;          /* active spans both columns */
    }

    /* Stacked: the side panels area itself is a 2-column grid; the
       active one again spans the full row. */
    .tx-result-grid[data-layout="stacked"] {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 1.25rem;
    }
    .tx-result-grid[data-layout="stacked"] .tx-side-panels {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.75rem;
        grid-column: 1 / -1;           /* occupy full row beneath the transcript */
    }
    .tx-result-grid[data-layout="stacked"] .tx-side-panels > .tx-tab-panel { display: none; }
    .tx-result-grid[data-layout="stacked"] .tx-side-panels > .tx-tab-panel.active {
        display: flex;
        flex-direction: column;
        grid-column: 1 / -1;
    }
}

/* Auto-scroll: keep the active segment centred in the list. `manual` is a
   class the renderer adds once the user scrolls the list themselves, then
   removes on the next play/seek — prevents scroll-jacking after the user
   has moved away. */
.tx-segments.auto-scroll .segment-card.active {
    scroll-margin-block: 50%;
}
.tx-segments.is-manual .segment-card.active { /* no auto-scroll on .active */ }

/* Speaker rename input replaces the badge in-place. */
.speaker-rename-input {
    font-size: 0.7rem;
    line-height: 1.1;
    padding: 2px 6px;
    border-radius: 9999px;
    border: 1px solid var(--border-color, #cbd5e1);
    background: var(--md-surface-container-lowest, #fff);
    color: inherit;
    min-width: 4ch;
    max-width: 16ch;
    outline: none;
}
.speaker-rename-input:focus {
    box-shadow: 0 0 0 2px var(--tx-accent-soft, #c7d2fe);
}
.speaker-badge { cursor: pointer; user-select: none; }

.tx-segments {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    overflow-y: auto;
    padding-right: 0.25rem;
}
@media (min-width: 1024px) {
    .tx-segments { overflow-y: auto; flex: 1; }
}

.tx-side-panels { display: flex; flex-direction: column; gap: 1rem; }
.tx-side-panel {
    background: var(--md-surface-container-lowest, #fff);
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 14px;
    padding: 1rem 1rem 1.1rem;
}
.tx-side-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}
.tx-side-panel-title {
    font-size: var(--tx-fs-md);
    font-weight: 700;
    color: var(--md-on-surface, #111827);
}
.tx-regen {
    background: transparent;
    border: 1px solid var(--border-color, #d1d5db);
    color: var(--tx-accent);
    padding: 0.25rem 0.65rem;
    font-size: var(--tx-fs-xs);
    font-weight: 600;
    border-radius: 999px;
    cursor: pointer;
    transition: background 120ms ease, border-color 120ms ease;
    font-family: inherit;
}
.tx-regen:hover { background: var(--tx-accent-softer); border-color: var(--tx-accent); }
.tx-side-panel-head-actions { display: flex; align-items: center; gap: 0.5rem; }
.tx-summary-toggle {
    display: flex;
    background: var(--md-surface-container-low, #f3f4f6);
    border: 1px solid var(--border-color, #d1d5db);
    border-radius: 999px;
    padding: 2px;
}
.tx-summary-toggle-opt {
    background: transparent;
    border: none;
    color: var(--md-on-surface-variant, #6b7280);
    padding: 0.2rem 0.6rem;
    font-size: var(--tx-fs-xs);
    font-weight: 600;
    border-radius: 999px;
    cursor: pointer;
    font-family: inherit;
    transition: background 120ms ease, color 120ms ease;
}
.tx-summary-toggle-opt.active { background: var(--tx-accent); color: #fff; }
.tx-detailed-summary { font-size: var(--tx-fs-base); line-height: 1.6; }
.detailed-summary-overview {
    color: var(--md-on-surface, #1f1f1f);
    margin: 0 0 1rem;
}
.detailed-summary-part {
    border-top: 1px solid var(--border-color, #e5e7eb);
    padding: 0.85rem 0 0;
    margin-bottom: 0.85rem;
}
.detailed-summary-part:first-child { border-top: none; padding-top: 0; }
.detailed-summary-part h4 {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    font-size: var(--tx-fs-sm);
    font-weight: 700;
    color: var(--md-on-surface, #111827);
    margin: 0 0 0.35rem;
}
.detailed-summary-part-time {
    font-size: var(--tx-fs-xs);
    font-weight: 500;
    color: var(--md-on-surface-variant, #6b7280);
}
.detailed-summary-part p {
    color: var(--md-on-surface, #1f1f1f);
    margin: 0 0 0.6rem;
    white-space: pre-wrap;
}
.detailed-summary-part pre.mermaid {
    background: var(--md-surface-container-low, #f8fafc);
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 10px;
    padding: 0.75rem;
    overflow-x: auto;
    transition: opacity 0.15s ease;
}
.tx-mermaid-wrap { position: relative; min-height: 64px; }
.tx-mermaid-loading {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
.tx-prose {
    font-size: var(--tx-fs-base);
    line-height: 1.6;
    color: var(--md-on-surface, #1f1f1f);
    white-space: pre-wrap;
    word-break: break-word;
}
.tx-prose p { margin: 0 0 0.75rem; }
.tx-prose p:last-child { margin-bottom: 0; }


/* Chat */
.tx-chat-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 50vh;
    overflow-y: auto;
    margin-bottom: 0.75rem;
    padding-right: 0.25rem;
}
.chat-message {
    border-radius: 12px;
    padding: 0.55rem 0.85rem;
    font-size: var(--tx-fs-sm);
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
    max-width: 100%;
    border: 1px solid var(--border-color, #e5e7eb);
    background: var(--card-bg, #fff);
}
.chat-message.user {
    background: var(--tx-accent-soft);
    border-color: var(--tx-accent-soft);
    margin-left: 2rem;
    color: var(--md-on-surface, #111827);
}
.chat-message.assistant {
    background: var(--md-surface-container-low, #f8fafc);
    border-color: var(--border-color, #e5e7eb);
    margin-right: 2rem;
}
@media (max-width: 479px) {
    .chat-message.user, .chat-message.assistant { margin-left: 0; margin-right: 0; }
}
.chat-typing {
    display: inline-block;
    font-size: 0.7rem;
    color: var(--md-on-surface-variant, #6b7280);
    letter-spacing: 0.2em;
    animation: tx-blink 1.2s steps(2) infinite;
}
@keyframes tx-blink { to { opacity: 0.2; } }
.tx-chat-form {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.tx-chat-input {
    flex: 1;
    min-height: 44px;
    max-height: 140px;
    background: var(--md-surface-container-low, #f3f4f6);
    border: 1px solid transparent;
    border-radius: var(--md-shape-xl, 24px);
    padding: 0.6rem 1rem;
    font-size: var(--tx-fs-sm);
    line-height: 1.45;
    color: var(--md-on-surface, #111827);
    resize: none;
    outline: none;
    font-family: inherit;
    transition: border-color 120ms ease;
}
.tx-chat-input:focus { border-color: var(--tx-accent); background: var(--card-bg, #fff); }
.tx-chat-attach {
    cursor: pointer;
    color: var(--md-on-surface-variant, #6b7280);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 44px;
    width: 44px;
    border-radius: 999px;
    flex-shrink: 0;
    transition: background 120ms ease;
}
.tx-chat-attach:hover { background: var(--md-surface-container, rgba(0,0,0,0.05)); }
.tx-chat-attach .material-symbols-outlined { font-size: 22px; }
.tx-chat-attachments {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    padding: 0.4rem 0;
    grid-column: 1 / -1;
}
.tx-chat-attachments.hidden { display: none; }
.tx-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.6rem;
    border-radius: 999px;
    background: var(--md-secondary-container, #e0e7ff);
    color: var(--md-on-secondary-container, #1e1b4b);
    font-size: var(--tx-fs-xs, 0.75rem);
    max-width: 12rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.tx-chip-x { background: none; border: 0; cursor: pointer; color: inherit; font-size: 1rem; line-height: 1; padding: 0 0.15rem; }
.tx-msg-attachments { margin-top: 0.4rem; display: flex; flex-wrap: wrap; gap: 0.3rem; }
.chat-message.assistant .visualization-block,
.chat-message.assistant .chart-block,
.chat-message.assistant .mermaid-block,
.chat-message.assistant .search-results-block { background: var(--card-bg, rgba(0,0,0,0.02)); }
.chat-message.assistant pre { background: rgba(0,0,0,0.05); padding: 0.5rem; border-radius: 6px; overflow-x: auto; font-size: 0.85em; }
.chat-message.assistant code { background: rgba(0,0,0,0.05); padding: 0.1rem 0.3rem; border-radius: 4px; font-size: 0.9em; }
.chat-message.assistant pre code { background: none; padding: 0; }
.chat-message.assistant p { margin: 0.4rem 0; }
.chat-message.assistant ul { list-style: disc; margin: 0.4rem 0; padding-left: 1.4rem; }
.chat-message.assistant ol { list-style: decimal; margin: 0.4rem 0; padding-left: 1.4rem; }
.chat-message.assistant li { margin: 0.15rem 0; }
/* markdown-it wraps "loose" list items (blank line between bullets in the
   source, common in LLM output) in <p> — without this override that p's
   margin stacks on top of the li margin above, doubling the visual gap. */
.chat-message.assistant li > p { margin: 0; }
.chat-message.assistant a { color: var(--tx-accent, #4f46e5); }
.chat-message.assistant table {
    width: 100%;
    margin: 0.5rem 0;
    border-collapse: collapse;
    font-size: 0.9em;
}
.chat-message.assistant th,
.chat-message.assistant td {
    border: 1px solid var(--border-color, #e5e7eb);
    padding: 0.35rem 0.6rem;
    text-align: left;
}
.chat-message.assistant thead th {
    background: rgba(0,0,0,0.05);
    font-weight: 600;
}

/* ──────────────────────────────────────────────────────────────────
   Minutes
   ────────────────────────────────────────────────────────────────── */
.minutes-section h4 {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--md-on-surface-variant, #6b7280);
    margin: 0.5rem 0 0.5rem;
    font-weight: 700;
}
.minutes-section:first-of-type h4 { margin-top: 0; }
.minutes-section ul { list-style: disc; padding-left: 1.25rem; margin: 0; }
.minutes-section li { margin-bottom: 0.35rem; }
.minutes-section .action-item {
    background: var(--tx-accent-softer);
    border: 1px solid var(--tx-accent-soft);
    border-radius: 10px;
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.45rem;
    font-size: var(--tx-fs-sm);
    line-height: 1.45;
}
.minutes-section .action-item .owner { font-weight: 700; color: var(--tx-accent); }

/* ──────────────────────────────────────────────────────────────────
   Transcript segment cards
   ────────────────────────────────────────────────────────────────── */
.segment-card {
    background: var(--md-surface-container-low, #f8fafc);
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 12px;
    padding: 0.7rem 0.85rem;
    display: flex;
    gap: 0.65rem;
    align-items: flex-start;
    cursor: pointer;
    transition: background 120ms ease, border-color 120ms ease;
}
.segment-card:hover { background: var(--tx-accent-softer); }
.segment-card.active {
    background: var(--tx-accent-soft);
    border-color: var(--tx-accent);
}
.segment-card.editing { background: var(--tx-accent-softer); }
.segment-timestamp {
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
    font-size: 0.7rem;
    font-weight: 600;
    background: var(--tx-accent-soft);
    color: var(--tx-accent);
    border-radius: 999px;
    padding: 0.2rem 0.55rem;
    margin-top: 0.1rem;
    cursor: pointer;
}
.segment-timestamp:hover { background: rgba(99, 102, 241, 0.22); }
/* Translation toolbar that sits above .tx-result-grid (and therefore
   above #viewTranscriptPanel). Houses the language <select> + Translate
   button. Stays visible on every tab, not just the Translation tab. */
.tx-translation-toolbar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.75rem;
    border: 1px solid var(--md-outline-variant, rgba(0, 0, 0, 0.08));
    border-radius: 0.5rem;
    background: var(--md-surface-container, rgba(0, 0, 0, 0.02));
}
.tx-translation-toolbar-icon {
    font-size: 18px;
    color: var(--tx-accent, #6366f1);
    flex-shrink: 0;
}
.tx-translation-toolbar-label {
    font-size: var(--tx-fs-sm, 0.875rem);
    font-weight: 600;
    color: var(--md-on-surface-variant, #475569);
    margin-right: 0.25rem;
}
.tx-translation-toolbar select { min-width: 9rem; flex: 0 0 auto; }
/* The custom-select widget (js/shared/ui-utils.js) replaces the <select>
   with a `.custom-select-wrapper` that defaults to width:100% — without
   this it stretches to fill the toolbar instead of sizing to its content.
   max-width caps the wrapper so the long "Pick a language to translate."
   placeholder (≈17rem at 14px) doesn't push the toolbar wider than its
   siblings. .current-value keeps its ellipsis so the placeholder truncates
   rather than overflowing. */
.tx-translation-toolbar .custom-select-wrapper { width: auto; min-width: 9rem; max-width: 10rem; flex: 0 0 auto; }
/* Override the shared dropdown's flex:1 on .current-value (dropdown.css) so
   the trigger sizes to the actual selected text (e.g. "English", "中文")
   instead of stretching to fill max-width. When the placeholder is shown
   it's truncated with ellipsis by .current-value's overflow/text-overflow. */
.tx-translation-toolbar .custom-select .current-value { flex: 0 1 auto; max-width: 100%; }
.tx-translation-toolbar .tx-btn { margin-left: auto; }

.segment-body { flex: 1; min-width: 0; }
.segment-text {
    font-size: var(--tx-fs-base);
    line-height: 1.6;
    color: var(--md-on-surface, #111827);
    /* Normalize any embedded newlines that may exist in older records;
       the backend already strips them for new transcriptions. */
    white-space: pre-wrap;
    word-break: break-word;
    overflow-wrap: anywhere;
}
.segment-text[contenteditable="true"] {
    outline: 2px solid var(--tx-accent);
    outline-offset: 2px;
    border-radius: 6px;
    padding: 2px 4px;
}
.speaker-badge {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    margin-bottom: 0.3rem;
    color: #fff;
    letter-spacing: 0.02em;
}
.speaker-badge.s1 { background: #6366f1; }
.speaker-badge.s2 { background: #ec4899; }
.speaker-badge.s3 { background: #f59e0b; }
.speaker-badge.s4 { background: #10b981; }
.speaker-badge.s5 { background: #0ea5e9; }
.speaker-badge.s6 { background: #8b5cf6; }
.speaker-badge.s7 { background: #ef4444; }
.speaker-badge.s8 { background: #14b8a6; }
.segment-edit-btn {
    opacity: 0;
    transition: opacity 120ms ease;
    color: var(--md-on-surface-variant, #6b7280);
    flex-shrink: 0;
    padding: 4px;
    border-radius: 6px;
}
.segment-card:hover .segment-edit-btn,
.segment-card:focus-within .segment-edit-btn { opacity: 1; }
.segment-edit-btn:hover { background: var(--tx-accent-soft); color: var(--tx-accent); }
/* Touch devices have no hover — keep edit affordance visible. */
@media (hover: none) { .segment-edit-btn { opacity: 1; } }

.segment-delete-btn {
    opacity: 0;
    transition: opacity 120ms ease;
    color: var(--md-on-surface-variant, #6b7280);
    flex-shrink: 0;
    padding: 4px;
    border-radius: 6px;
}
.segment-card:hover .segment-delete-btn,
.segment-card:focus-within .segment-delete-btn { opacity: 1; }
.segment-delete-btn:hover { background: var(--tx-danger-soft, #fee2e2); color: var(--tx-danger, #ef4444); }
/* Touch devices have no hover — keep delete affordance visible. */
@media (hover: none) { .segment-delete-btn { opacity: 1; } }

/* ──────────────────────────────────────────────────────────────────
   App error banner
   ────────────────────────────────────────────────────────────────── */
#appError.hidden { display: none; }   /* beat Tailwind v4 cascade layers */
.tx-app-error {
    margin-top: 1rem;
    background: var(--tx-danger-soft);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #991b1b;
    border-radius: 12px;
    padding: 0.75rem 1rem;
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    font-size: var(--tx-fs-sm);
}
.dark .tx-app-error { color: #fecaca; }
.tx-app-error .material-symbols-outlined { font-size: 20px; margin-top: 1px; }
.tx-app-error-msg { font-weight: 600; }
.tx-app-error-detail {
    font-size: var(--tx-fs-xs);
    margin-top: 0.2rem;
    opacity: 0.85;
}

/* ──────────────────────────────────────────────────────────────────
   Scrollbar polish
   ────────────────────────────────────────────────────────────────── */
.tx-segments::-webkit-scrollbar,
.tx-chat-list::-webkit-scrollbar { width: 6px; }
.tx-segments::-webkit-scrollbar-thumb,
.tx-chat-list::-webkit-scrollbar-thumb {
    background: var(--tx-accent-soft);
    border-radius: 3px;
}
.tx-segments::-webkit-scrollbar-thumb:hover,
.tx-chat-list::-webkit-scrollbar-thumb:hover {
    background: var(--tx-accent);
}

/* ──────────────────────────────────────────────────────────────────
   Translation controls
   ────────────────────────────────────────────────────────────────── */
.tx-translation-controls {
    display: flex;
    gap: 8px;
    align-items: center;
}
.tx-translation-controls select:disabled,
.tx-translation-controls button:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    pointer-events: none;
}

/* ──────────────────────────────────────────────────────────────────
   Regenerate loading states
   ────────────────────────────────────────────────────────────────── */
.spinner-inline {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid var(--tx-accent-soft);
    border-top-color: var(--tx-accent);
    border-radius: 50%;
    animation: tx-spin 0.6s linear infinite;
    vertical-align: middle;
    margin-right: 4px;
}
@keyframes tx-spin { to { transform: rotate(360deg); } }

.tx-regen:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    pointer-events: none;
}

.tx-loading-shimmer {
    position: relative;
    overflow: hidden;
    min-height: 3em;
    border-radius: 6px;
    background: var(--tx-accent-softer);
}
.tx-loading-shimmer::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(99,102,241,0.08) 40%,
        rgba(99,102,241,0.12) 50%,
        rgba(99,102,241,0.08) 60%,
        transparent 100%
    );
    animation: tx-shimmer 1.5s ease-in-out infinite;
}
@keyframes tx-shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* ──────────────────────────────────────────────────────────────────
   Reduced motion: disable decorative animations for users who prefer it.
   ────────────────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    .spinner,
    .spinner-inline {
        animation: none;
        opacity: 0.7;
    }
    .tx-loading-shimmer::after {
        animation: none;
    }
    .tx-side-panels > .tx-tab-panel.active,
    #viewTranscriptPanel.active {
        animation: none;
        will-change: auto;
    }
    .tx-tab-indicator {
        transition: none;
    }
    .tx-loading-shimmer {
        background: var(--tx-surface-2, rgba(99,102,241,0.06));
    }
    .tx-pulse,
    .chat-typing {
        animation: none;
        opacity: 0.7;
    }
    * {
        transition-duration: 0.01ms !important;
    }
}

/* ──────────────────────────────────────────────────────────────────
   Print: transcripts are still useful on paper.
   ────────────────────────────────────────────────────────────────── */
@media print {
    .shell-header, .tx-tabs, .tx-result-actions, .tx-side-panels,
    .custom-audio-player, .tx-app-error { display: none !important; }
    .tx-card { box-shadow: none; border: none; }
    .tx-transcript-panel { max-height: none; overflow: visible; }
}
