/* MediVox Medical Dictation - Main Styles */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --background: #f8fafc;
    --surface: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border: #e2e8f0;
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    
    /* Layout heights */
    --top-bar-height: 60px;
    --lower-bar-height: 196px; /* room for a readable waveform above the controls */
}

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    min-width: 700px;
    overflow-x: hidden;
}

.app-container {
    height: 100vh;
    display: flex;
    flex-direction: column;
    min-width: 700px;
}

/* Top Bar */
.top-bar {
    height: var(--top-bar-height);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    box-shadow: var(--shadow);
    z-index: 100;
}

.logo-section {
    display: flex;
    align-items: center;
}

/* Sync indicator: beside the name. A ring that fills in lantern amber and closes green with a tick */
.sync-indicator { display: flex; align-items: center; gap: 8px; margin-left: 18px; padding: 3px 12px 3px 4px; border-radius: 999px; background: #f6f7f9; border: 1px solid var(--border); cursor: default; user-select: none; }
.sync-indicator[hidden] { display: none; }
.sync-ring .track { fill: none; stroke: #e3e7ec; stroke-width: 3.2; }
.sync-ring .arc { fill: none; stroke: url(#syncGlow); stroke-width: 3.2; stroke-linecap: round; transition: stroke-dashoffset .6s ease, stroke .4s ease; }
.sync-ring .pct { font: 600 10.5px -apple-system, "Segoe UI", sans-serif; fill: #8a5a00; font-variant-numeric: tabular-nums; }
.sync-ring .tick { fill: none; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; opacity: 0; transition: opacity .4s ease; }
.sync-ring .tick { stroke: #0e9f6e; stroke-dasharray: 22; stroke-dashoffset: 22; }
.sync-indicator[data-state="complete"] .arc, .sync-indicator[data-state="publishing"] .arc { stroke: #10b981; }
.sync-indicator[data-state="complete"] .tick, .sync-indicator[data-state="publishing"] .tick { opacity: 1; stroke-dashoffset: 0; transition: opacity .2s ease, stroke-dashoffset .5s ease .15s; }
.sync-indicator[data-state="syncing"] .sync-ring { animation: sync-breathe 2.4s ease-in-out infinite; }
.sync-indicator[data-state="offline"] .arc { stroke: #aab3bd; }
.sync-indicator[data-state="offline"] .pct { fill: #6b7480; }
@keyframes sync-breathe { 0%, 100% { filter: drop-shadow(0 0 0 rgba(240, 138, 36, 0)); } 50% { filter: drop-shadow(0 0 3px rgba(240, 138, 36, .55)); } }
@media (prefers-reduced-motion: reduce) { .sync-indicator[data-state="syncing"] .sync-ring { animation: none; } .sync-ring .arc, .sync-ring .tick { transition: none; } }
/* Install Lantern: there only while the browser offers it and Lantern is running in a browser tab */
.install-btn { background: #1D5C8A; color: #fff; border-color: #1D5C8A; font-weight: 600; }
.install-btn:hover { background: #17496e; border-color: #17496e; color: #fff; }
.whats-new { margin-left: 10px; padding: 5px 12px; border-radius: 999px; border: 1px solid #f3d19c; background: #fff7e6; color: #8a5a00; font: 600 12.5px inherit; font-family: inherit; cursor: pointer; white-space: nowrap; }
.whats-new:hover { background: #ffefcc; }
.whats-new[hidden] { display: none; }
.sync-words { display: flex; flex-direction: column; line-height: 1.15; }
.sync-title { font-size: 12.5px; font-weight: 600; color: var(--text-primary); white-space: nowrap; }
.sync-detail { font-size: 11px; color: var(--text-secondary); white-space: nowrap; }
@media (max-width: 1100px) { .sync-detail { display: none; } }
@media (max-width: 900px) { .sync-words { display: none; } .sync-indicator { padding: 3px 4px; } }

.app-logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-icon {
    height: 42px;
    width: auto;
    display: block;
}

.update-pill {
    border-color: #1D5C8A !important;
    color: #1D5C8A !important;
    font-weight: 600;
}
.update-pill .update-dot {
    width: 9px; height: 9px; border-radius: 50%;
    background: #E9A33B;
    box-shadow: 0 0 0 3px rgba(233, 163, 59, 0.25);
    display: inline-block;
    animation: update-pulse 1.6s ease-in-out infinite;
}
@keyframes update-pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.25); } }
.env-badge {
    background: #9B2C2C;
    color: #fff;
    font: 700 11px/1 -apple-system, "Segoe UI", sans-serif;
    letter-spacing: 0.08em;
    padding: 4px 7px;
    border-radius: 4px;
    margin-left: 4px;
    align-self: center;
}
.logo-text {
    font-family: "IBM Plex Serif", Georgia, "Times New Roman", serif;
    font-size: 1.9rem;
    font-weight: 600;
    letter-spacing: -0.015em;
    color: #1D5C8A;
}

.action-buttons {
    display: flex;
    gap: 12px;
}

.action-btn[hidden] { display: none; }
.action-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.9rem;
    font-weight: 500;
}

.action-btn:hover {
    background: var(--background);
    border-color: var(--primary-color);
}

.action-btn .btn-icon {
    font-size: 1rem;
}

/* Drag and drop styling for Import button */
.action-btn.drag-over {
    background: var(--accent-bg);
    border-color: var(--accent);
    border-width: 2px;
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.2);
}

.action-btn.drag-over .btn-icon {
    animation: bounce 0.6s infinite alternate;
}

@keyframes bounce {
    0% { transform: translateY(0); }
    100% { transform: translateY(-2px); }
}

/* Main Content Area */
.main-content {
    flex: 1;
    padding: 6px;          /* a few pixels round the panes, not a frame */
    overflow: hidden;
}

.recordings-table-container {
    height: 100%;
    background: var(--surface);
    border-radius: 8px;
    box-shadow: var(--shadow);
    overflow-y: auto;
    overflow-x: hidden;
}

.recordings-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.recordings-table th,
.recordings-table td {
    text-align: left;
    padding: 12px;
    border-bottom: 1px solid var(--border);
}

.recordings-table th {
    background: var(--background);
    font-weight: 600;
    color: var(--text-primary);
    position: sticky;
    top: 0;
    z-index: 10;
}

.recordings-table th.sortable {
    cursor: pointer;
    user-select: none;
    position: relative;
}

.recordings-table th.sortable:hover {
    background: #e2e8f0;
}

.recordings-table th.sortable::after {
    content: '↕️';
    position: absolute;
    right: 8px;
    opacity: 0.5;
    font-size: 0.8rem;
}

.recordings-table th.sorted-asc::after {
    content: '↑';
    opacity: 1;
}

.recordings-table th.sorted-desc::after {
    content: '↓';
    opacity: 1;
}

.recordings-table tbody tr:hover {
    background: var(--background);
}

/* Selected recording highlighting - thicker left border */
.recordings-table tbody tr.selected {
    border-top: 2px solid var(--primary-color);
    border-right: 2px solid var(--primary-color);
    border-bottom: 2px solid var(--primary-color);
    border-left: 9px solid var(--primary-color);
    background: rgba(37, 99, 235, 0.05);
}

/* Remove Safari-specific rule since @supports was affecting Chrome too */

/* Audio level meter styling */
.recordings-table .exam-id {
    position: relative;
    z-index: 1;
}

.recordings-table .exam-id::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: -1;
    background: inherit;
    border-radius: 2px;
}


.no-recordings-row td {
    text-align: center;
    color: var(--text-secondary);
    font-style: italic;
    padding: 40px;
}

/* Lower Bar */
.lower-bar {
    height: var(--lower-bar-height);
    background: var(--surface);
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: relative;
    padding-bottom: 5px; /* Reduced padding for tighter layout */
}

.waveform-container {
    flex: 1;
    background: var(--background);
    margin: 10px;
    border-radius: 4px;
    border: 1px solid var(--border);
    position: relative;
    overflow: hidden;
    min-height: 48px;
    max-height: 72px;
}

.waveform-canvas {
    width: 100%;
    height: 100%;
    display: block;
    cursor: pointer;
}

.controls-placeholder {
    height: 40px;
    background: var(--background);
    margin: 0 10px 10px 10px;
    border-radius: 4px;
    border: 2px dashed var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-style: italic;
}

.controls-placeholder::before {
    content: 'Audio controls will appear here';
}

.network-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--surface);
    padding: 6px 12px;
    border-radius: 20px;
    border: 1px solid var(--border);
    font-size: 0.8rem;
    overflow: hidden;
}

/* Network Quality Indicator */

.network-icon {
    font-size: 0.9rem;
    color: var(--text-secondary);
    width: 14px;
    height: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.network-status {
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 60px;
    display: inline-block;
}

.network-quality-dots {
    display: flex;
    gap: 3px;
    overflow: hidden;
}

.network-quality-dots .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--border);
    transition: background 0.3s;
    flex-shrink: 0;
}

.network-quality-dots.excellent .dot {
    background: var(--success-color);
}

.network-quality-dots.good .dot:nth-child(-n+3) {
    background: var(--success-color);
}

.network-quality-dots.fair .dot:nth-child(-n+2) {
    background: var(--warning-color);
}

.network-quality-dots.poor .dot:nth-child(1) {
    background: var(--danger-color);
}

/* Status Indicators Container */
.status-indicators {
    position: absolute;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: flex-end;
}

/* Transcription Indicator */
.transcription-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--surface);
    padding: 6px 12px;
    border-radius: 20px;
    border: 1px solid var(--border);
    font-size: 0.8rem;
    overflow: hidden;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.transcription-icon {
    font-size: 0.9rem;
    width: 14px;
    height: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.transcription-status {
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
}

.transcription-status.streaming {
    color: var(--accent);
}

.transcription-status.batch {
    color: var(--text-secondary);
}

.transcription-status.queued {
    color: var(--warning-color);
}

.transcription-status.complete {
    color: var(--success-color);
}

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

.transcription-mode {
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 600;
    white-space: nowrap;
}

.transcription-mode.streaming {
    background: rgba(99, 102, 241, 0.1);
    color: var(--accent);
}

.transcription-mode.batch {
    background: rgba(107, 114, 128, 0.1);
    color: var(--text-secondary);
}

/* Enhanced transcription status indicator (clickable) */
.transcription-indicator {
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.transcription-indicator:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.transcription-indicator.active {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

/* Live Transcription Floating Panel */
.live-transcription-panel {
    position: fixed;
    top: 80px;
    right: 20px;
    width: 400px;
    max-width: 90vw;
    max-height: 500px;
    background: var(--surface);
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    z-index: 900;
    display: flex;
    flex-direction: column;
    animation: panelSlideIn 0.3s ease-out;
    border: 1px solid var(--border);
}

@keyframes panelSlideIn {
    from {
        opacity: 0;
        transform: translateX(50px) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0) translateY(0);
    }
}

.live-transcription-panel.minimized {
    max-height: 50px;
}

.live-transcription-panel.minimized .panel-body,
.live-transcription-panel.minimized .panel-footer {
    display: none;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(to bottom, var(--surface), var(--background));
    border-radius: 12px 12px 0 0;
    cursor: move;
    user-select: none;
}

.panel-header:active {
    cursor: grabbing;
}

.panel-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.panel-icon {
    font-size: 1.1rem;
}

.panel-title-text {
    color: var(--text-primary);
}

.panel-exam-id {
    padding: 2px 8px;
    background: var(--accent-bg);
    color: var(--accent);
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 700;
}

.panel-controls {
    display: flex;
    gap: 4px;
}

.panel-btn {
    background: none;
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.panel-btn:hover {
    background: var(--background);
    color: var(--text-primary);
}

.close-btn:hover {
    background: var(--danger-color);
    color: white;
}

.panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    min-height: 200px;
    max-height: 380px;
}

.transcript-content {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--text-primary);
}

.transcript-content p {
    margin: 0;
    padding: 0;
}

.waiting-message {
    color: var(--text-secondary);
    font-style: italic;
    text-align: center;
    padding: 40px 20px;
}

.offline-message {
    text-align: center;
    padding: 30px 20px;
    color: var(--text-secondary);
}

.offline-icon {
    font-size: 3rem;
    margin-bottom: 12px;
    opacity: 0.7;
}

.offline-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 8px 0;
}

.offline-description {
    font-size: 0.9rem;
    line-height: 1.5;
    margin: 0;
    color: var(--text-secondary);
}

.streaming-status.offline {
    color: #f59e0b;
    background: rgba(245, 158, 11, 0.1);
}

/* Live transcript word styling (same as transcription viewer) */
.transcript-content .word {
    display: inline;
    padding: 2px 0;
    transition: background-color 0.2s;
    border-radius: 3px;
}

.transcript-content .word.active {
    background: rgba(99, 102, 241, 0.2);
    font-weight: 600;
}

.transcript-content .word.confidence-high {
    /* No background - high confidence */
}

.transcript-content .word.confidence-good {
    background: rgba(156, 163, 175, 0.1);
}

.transcript-content .word.confidence-medium {
    background: rgba(251, 191, 36, 0.15);
}

.transcript-content .word.confidence-low {
    background: rgba(239, 68, 68, 0.15);
    color: #b91c1c;
}

.transcript-content .word.partial {
    opacity: 0.5;
    font-style: italic;
    color: #6b7280;
}

.panel-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    background: var(--background);
    border-radius: 0 0 12px 12px;
}

.transcript-stats {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    flex-wrap: wrap;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

.stat-icon {
    font-size: 0.9rem;
}

.stat-separator {
    color: var(--border);
}

.streaming-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--accent);
    font-weight: 600;
}

.streaming-pulse {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.5;
        transform: scale(0.8);
    }
}

/* Scrollbar styling for panel */
.panel-body::-webkit-scrollbar {
    width: 8px;
}

.panel-body::-webkit-scrollbar-track {
    background: transparent;
}

.panel-body::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

.panel-body::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* Global Drag and Drop Overlay */
.global-drag-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(37, 99, 235, 0.1);
    backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.2s ease-in-out;
    pointer-events: none;
}

.global-drag-overlay.show {
    opacity: 1;
}

.drag-overlay-content {
    background: var(--surface);
    border: 3px dashed var(--primary-color);
    border-radius: 12px;
    padding: 40px;
    text-align: center;
    box-shadow: var(--shadow-lg);
    transform: scale(0.9);
    transition: transform 0.2s ease-in-out;
}

.global-drag-overlay.show .drag-overlay-content {
    transform: scale(1);
}

.drag-overlay-icon {
    font-size: 3rem;
    margin-bottom: 16px;
    display: block;
    animation: pulse 1.5s infinite;
}

.drag-overlay-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 8px;
}

.drag-overlay-subtitle {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.drag-overlay-types {
    display: flex;
    gap: 20px;
    justify-content: center;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.drag-overlay-type {
    display: flex;
    align-items: center;
    gap: 6px;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 0.8; }
    50% { transform: scale(1.1); opacity: 1; }
}

/* Responsive Design */
@media (max-width: 768px) {
    .action-buttons {
        flex-wrap: wrap;
    }
    
    .action-btn .btn-text {
        display: none;
    }
    
    .recordings-table {
        font-size: 0.8rem;
    }
    
    .recordings-table th,
    .recordings-table td {
        padding: 8px;
    }
    
    .drag-overlay-content {
        padding: 30px 20px;
        margin: 20px;
    }
    
    .drag-overlay-types {
        flex-direction: column;
        gap: 12px;
    }
}

/* ============================================================
   Folder pane (records-delivery demo)
   ============================================================ */
.main-content {
    display: flex;
    gap: 6px;
    min-height: 0;
}
.recordings-table-container {
    flex: 1 1 auto;
    min-width: 0;
}
.folder-pane {
    flex: 0 0 320px;
    min-width: 0;
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border-radius: 8px;
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: flex-basis 0.15s ease;
}
.folder-pane.collapsed { flex-basis: 0; }

/* The dictation recorder is a tab in the reading area (#recorderPanel). Its own buttons (New
   Recording, Import) sit at the head of the tab; until the page has moved them there they stay hidden */
.top-bar #newRecordingBtn, .top-bar #importBtn { display: none; }
.recorder-toolbar { flex: 0 0 auto; display: flex; gap: 8px; padding: 8px 6px 2px; }
.recorder-toolbar .action-btn { padding: 6px 12px; font-size: 13px; }
/* A light grey ground, so the recorder's white cards stand apart from the white tab above them */
.recorder-panel { position: absolute; inset: 0; display: flex; flex-direction: column; background: #e8ecf1; outline: none; }
.recorder-panel[hidden] { display: none; }
/* Until the page has moved them into their panel (while a first-run dialog holds the start, say) the recorder's parts stay out of sight */
.main-content > .recordings-table-container, .app-container > .lower-bar { display: none; }
#readerPopOut[hidden] { display: none; }   /* the recorder cannot move to a window */
.recorder-panel .recordings-table-container { flex: 1 1 auto; min-height: 0; height: auto; margin: 6px 6px 0; }
.recorder-panel .lower-bar { flex: 0 0 var(--lower-bar-height); margin: 6px; border: 0; border-radius: 8px; box-shadow: var(--shadow); }
.reader-body.showing-panel { background: #e8ecf1; }
/* Layout: file list | divider | reading area */
.pane-divider, .reader-pane { display: none; }
.folder-pane { flex: 0 0 var(--folder-pane-width, 340px); }
.folder-pane.collapsed { flex: 0 0 0; min-width: 0; box-shadow: none; }
.folder-pane.collapsed > * { display: none; }
.folder-pane.collapsed + .pane-divider { display: none; }
.folder-pane.will-hide { opacity: .35; transition: opacity .12s ease; }   /* dragged well past its narrowest: letting go hides it */
/* The way back to the file list: at the left end of the tab bar, only while the list is hidden */
.folder-pane-expand { flex: 0 0 auto; align-self: center; margin: 0 6px 0 8px; width: 26px; height: 26px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text-secondary); font-size: 11px; line-height: 1; cursor: pointer; }
.folder-pane-expand:hover { background: #eef2f7; color: var(--text-primary); }
.folder-pane-expand[hidden] { display: none; }
.action-btn[hidden] { display: none; }
.main-content { gap: 0; }
.pane-divider {
    display: block;
    flex: 0 0 8px;
    cursor: col-resize;
    position: relative;
}
.pane-divider::before {
    content: "";
    position: absolute;
    top: 8px; bottom: 8px; left: 3px;
    width: 2px;
    border-radius: 1px;
    background: var(--border);
}
.pane-divider:hover::before, body.dragging-divider .pane-divider::before { background: var(--accent, #6366f1); }
body.dragging-divider { cursor: col-resize; user-select: none; }
body.dragging-divider iframe { pointer-events: none; }
.reader-pane {
    display: flex;
    flex: 1 1 auto;
    min-width: 0;
    flex-direction: column;
    background: var(--surface);
    border-radius: 8px;
    box-shadow: var(--shadow);
    overflow: hidden;
}
.reader-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 8px 6px 12px;
    border-bottom: 1px solid var(--border);
    background: var(--background);
    font-size: 13px;
    min-height: 36px;
}
.reader-tabs {
    display: flex; align-items: flex-end; gap: 2px;
    flex: 1 1 auto; min-width: 0; align-self: stretch;
    overflow-x: auto; overflow-y: hidden; scrollbar-width: thin;
}
.reader-tab {
    display: inline-flex; align-items: center; gap: 6px;
    flex: 0 1 auto; min-width: 0; max-width: 240px; height: 30px;
    margin-top: 4px; padding: 0 6px 0 10px;
    border: 1px solid transparent; border-bottom: 0; border-radius: 7px 7px 0 0;
    background: transparent; color: var(--text-secondary);
    font: inherit; font-size: 13px; white-space: nowrap; cursor: pointer;
}
.reader-tab:hover { background: var(--accent-bg); color: var(--text-primary); }
.reader-tab.active {
    background: var(--surface); color: var(--text-primary); font-weight: 600;
    border-color: var(--border); position: relative; top: 1px;
}
.reader-tab .label { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.reader-tab { touch-action: none; }
.reader-tab:focus { outline: none; }
.reader-tab:focus-visible { outline: 2px solid var(--accent, #6366f1); outline-offset: -2px; }
.reader-tab.sliding { position: relative; }
.reader-tab.placeholder { visibility: hidden; }
.reader-tab.collapsed { display: none; }
/* The moving copy lives on the page body: fixed, above everything, never clipped by the strip */
.reader-tab.ghost {
    position: fixed; z-index: 1000; margin: 0; height: 30px; box-sizing: border-box;
    outline: none; pointer-events: none; cursor: grabbing; transition: none;
    background: var(--surface); color: var(--text-primary); font-weight: 600;
    border: 1px solid var(--text-secondary); border-radius: 7px 7px 3px 3px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
.reader-tab.ghost.pop { border-radius: 15px; padding: 0 8px 0 12px; box-shadow: 0 6px 18px rgba(0,0,0,0.2); border-color: var(--accent, #6366f1); }
.reader-tab.ghost.pop::before { content: "⧉"; flex: 0 0 auto; margin-right: 6px; color: var(--accent, #6366f1); font-size: 14px; line-height: 1; }
.reader-tab.flying { transition: opacity 160ms ease-in; }
/* The window outline that zooms out of a dropped pill */
.reader-zoom {
    position: fixed; z-index: 999; pointer-events: none; box-sizing: border-box;
    border: 2px solid var(--accent, #6366f1); border-radius: 8px; background: rgba(99, 102, 241, 0.08);
    box-shadow: 0 8px 28px rgba(0,0,0,0.25); opacity: 1;
}
.reader-zoom.go { transition: left 360ms cubic-bezier(0.2, 0.7, 0.2, 1), top 360ms cubic-bezier(0.2, 0.7, 0.2, 1), width 360ms cubic-bezier(0.2, 0.7, 0.2, 1), height 360ms cubic-bezier(0.2, 0.7, 0.2, 1), opacity 260ms ease-in 160ms; }
@media (prefers-reduced-motion: reduce) { .reader-zoom.go { transition: none; opacity: 0; } }
body.dragging-tab { cursor: grabbing; user-select: none; }
body.dragging-tab iframe { pointer-events: none; }
.reader-tab .b {
    flex: 0 0 auto; font-size: 10px; font-weight: 700; line-height: 1;
    padding: 2px 4px; border-radius: 3px; color: #fff; background: var(--accent, #6366f1);
}
.reader-tab .kind { flex: 0 0 auto; font-size: 12px; }
.reader-tab .close {
    flex: 0 0 auto; width: 18px; height: 18px; border-radius: 4px; border: 0; background: transparent;
    color: inherit; font-size: 15px; line-height: 1; cursor: pointer; padding: 0; opacity: 0.6;
}
.reader-tab .close:hover { opacity: 1; background: var(--border); }
.reader-actions { display: flex; gap: 4px; flex: 0 0 auto; }
.reader-actions button {
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-secondary);
    border-radius: 5px;
    width: 28px; height: 26px;
    display: inline-flex; align-items: center; justify-content: center;
    cursor: pointer;
    font-size: 16px; line-height: 1;
}
.reader-actions button:hover { color: var(--text-primary); border-color: var(--text-secondary); }
.reader-pane.empty .reader-actions > button { visibility: hidden; }   /* nothing to pop out or close; the Windows chip stays */
.reader-body { flex: 1 1 auto; min-height: 0; position: relative; background: #2b2b2b; }
.reader-body iframe { display: block; width: 100%; height: 100%; border: 0; }
/* Notices over the page: a record withdrawn or replaced on the server, or one that could not be restored */
.reader-notices { position: absolute; top: 0; left: 0; right: 0; z-index: 2; display: flex; flex-direction: column; gap: 4px; padding: 6px; pointer-events: none; }
.reader-notices:empty { display: none; }
.reader-notice {
    pointer-events: auto; display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    background: #fff7e6; color: #7a4a00; border: 1px solid #f0c36d; border-left: 4px solid #d97706;
    border-radius: 6px; padding: 8px 10px; font-size: 13px; box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.reader-notice.withdrawn { background: #fdecec; color: #7f1d1d; border-color: #f2b1b1; border-left-color: #dc2626; }
.reader-notice .text { flex: 1 1 auto; min-width: 12em; }
.reader-notice button {
    border: 1px solid currentColor; background: transparent; color: inherit; border-radius: 5px;
    padding: 4px 10px; font: inherit; font-size: 12px; font-weight: 600; cursor: pointer;
}
.reader-notice button:hover { background: rgba(0,0,0,0.06); }
.reader-tab .flag { flex: 0 0 auto; font-size: 10px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; padding: 2px 5px; border-radius: 3px; }
.reader-tab.withdrawn .label { text-decoration: line-through; }
.reader-tab.withdrawn .flag { background: #dc2626; color: #fff; }
.reader-tab.replaced .flag { background: #d97706; color: #fff; }
.reader-body iframe[hidden] { display: none; }
.reader-pane.empty .reader-body { background: var(--surface); }
.reader-empty {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    padding: 24px; text-align: center;
    color: var(--text-secondary); font-size: 14px; max-width: 34em; margin: 0 auto;
}
.reader-pane:not(.empty) .reader-empty { display: none; }
.folder-pane.collapsed .folder-tree,
.folder-pane.collapsed .folder-status-line,
.folder-pane.collapsed .folder-pane-title { display: none; }
.folder-pane.collapsed .folder-pane-toggle { transform: rotate(180deg); }
.folder-pane-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    background: var(--background);
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.folder-pane-toggle {
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: 4px;
    padding: 2px 6px;
    cursor: pointer;
    font-size: 11px;
}
.folder-tree {
    flex: 1;
    min-height: 0;
    overflow: auto;
    outline: none;
    font-size: 13px;
    padding: 4px 0;
    user-select: none;
}
.folder-tree:focus-visible { box-shadow: inset 0 0 0 2px var(--primary-color); }
.tree-empty { padding: 12px; color: var(--text-secondary); }
.tree-row {
    display: flex;
    align-items: center;
    gap: 4px;
    height: 26px;
    padding-left: calc(var(--depth, 0) * 16px + 6px);
    padding-right: 6px;
    white-space: nowrap;
    cursor: default;
}
.tree-row:hover { background: rgba(37, 99, 235, 0.06); }
.tree-row.selected { background: var(--primary-color); color: #fff; }
.tree-row.selected .tree-folder-status,
.tree-row.selected .tree-pill { color: #fff; opacity: 0.9; }
.tree-row.greyed { color: var(--text-secondary); opacity: 0.7; }
.tree-row.not-cached .tree-label { opacity: 0.55; }
.tree-chevron { width: 12px; text-align: center; font-size: 11px; color: var(--text-secondary); flex: 0 0 auto; }
.tree-row.selected .tree-chevron { color: #fff; }
.tree-icon { flex: 0 0 auto; font-size: 14px; display: inline-flex; align-items: center; justify-content: center; min-width: 18px; }
.tree-label { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.tree-right { flex: 0 0 auto; display: flex; align-items: center; gap: 6px; font-size: 11px; }
.tree-folder-status { color: var(--text-secondary); }
.tree-folder-status.status-ready { color: var(--success-color); }
.tree-folder-status.status-updating,
.tree-folder-status.status-downloading { color: var(--warning-color); }
.tree-folder-status.status-offline { color: var(--danger-color); }
.tree-pill { color: var(--warning-color); }
.tree-progress {
    display: inline-block;
    width: 56px;
    height: 6px;
    border-radius: 3px;
    background: rgba(0, 0, 0, 0.1);
    overflow: hidden;
}
.tree-progress-fill { display: block; height: 100%; background: var(--primary-color); transition: width 0.2s; }
.tree-badge-beacon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 15px;
    height: 15px;
    border-radius: 4px;
    background: #1d5c8a;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    font-family: Georgia, 'Times New Roman', serif;
    line-height: 1;
    letter-spacing: 0;
    cursor: default;
}
.tree-row.greyed .tree-badge-beacon { opacity: 0.5; }
.tree-badge-changed {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--warning-color);
}
.tree-mic {
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 13px;
    padding: 0 2px;
    line-height: 1;
    opacity: 0.35;
}
.tree-row:hover .tree-mic, .tree-row.selected .tree-mic { opacity: 1; }
.folder-status-line {
    padding: 6px 10px;
    border-top: 1px solid var(--border);
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.folder-status-line.offline { color: var(--danger-color); }

/* Records open in windows of their own: a chip at the end of the tab strip, with a menu */
.reader-windows { position: relative; }
.reader-windows[hidden] { display: none; }
#readerWindowsBtn { width: auto; padding: 0 9px; font-size: 12px; font-weight: 600; white-space: nowrap; color: var(--primary-color); border-color: var(--primary-color); background: #eff6ff; }
.reader-windows-menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; min-width: 260px; max-width: 380px; padding: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow-lg); }
.reader-windows-menu[hidden] { display: none; }
.reader-windows-row { display: flex; align-items: center; gap: 4px; }
.reader-windows-menu button { font: inherit; font-size: 13px; border: 0; background: none; cursor: pointer; border-radius: 5px; color: var(--text-primary); height: auto; width: auto; }
.reader-windows-menu button:hover, .reader-windows-menu button:focus-visible { background: var(--accent-bg, #e0e7ff); outline: none; }
.reader-windows-menu .name { justify-content: flex-start; flex: 1 1 auto; min-width: 0; text-align: left; padding: 7px 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reader-windows-menu .dock { flex: 0 0 auto; padding: 7px 8px; color: var(--primary-color); display: inline-flex; }
.reader-windows-menu .all { display: block; justify-content: flex-start; width: 100%; text-align: left; padding: 8px; margin-top: 4px; border-top: 1px solid var(--border); border-radius: 0 0 5px 5px; color: var(--primary-color); font-weight: 600; }

/* Tabs are tinted by what they hold: a record is plain, a Beacon bundle teal, video light blue, the
   dictation recorder rose, the administration tools lavender. Resting tabs carry the tint; the tab on
   show stays white, as the page beneath it is, with the colour as a line along its top. */
.reader-tab[data-kind] { --tab-tint: transparent; --tab-line: transparent; background: var(--tab-tint); }
.reader-tab[data-kind="beacon"]   { --tab-tint: #e2f3ef; --tab-line: #2f9e8a; }
.reader-tab[data-kind="video"]    { --tab-tint: #e1effb; --tab-line: #3b8fd6; }
.reader-tab[data-kind="statement"] { --tab-tint: #fdf3d7; --tab-line: #c9971c; }
.reader-tab[data-kind="recorder"] { --tab-tint: #fde8e8; --tab-line: #dc5a5a; }
.reader-tab[data-kind="tool"]     { --tab-tint: #ece8fb; --tab-line: #7c6fd6; }
.reader-tab[data-kind]:hover { background: color-mix(in srgb, var(--tab-tint) 70%, #cbd5e1); }
.reader-tab[data-kind].active { background: var(--surface); box-shadow: inset 0 2px 0 var(--tab-line); }

/* The Admin button when something needs an administrator's attention */
#adminBtn.attention { border-color: #f59e0b; background: #fffbeb; color: #92400e; }
