:root {
    --bg-dark: #F8FAFC; /* Clean slate light background */
    --card-bg: #FFFFFF; /* Premium white cards */
    --card-border: #E2E8F0; /* Slate border */
    --card-hover: #F1F5F9; /* Slate hover */
    --text-main: #0F172A; /* Slate Navy */
    --text-muted: #475569; /* Slate gray */
    --accent-primary: #0F172A; /* Slate Navy */
    --accent-secondary: #2563EB; /* Royal Blue */
    --accent-teal: #0D9488; /* Teal Accent */
    --status-success: #10B981;
    --status-error: #EF4444;
    --status-warning: #F59E0B;

    --border-color: var(--card-border);
    --text-primary: var(--text-main);
    --text-secondary: var(--text-muted);
    --accent-blue: var(--accent-secondary);
    --error: var(--status-error);
    --warning: var(--status-warning);
    --success: var(--status-success);
    
    --bg-alpha: rgba(15, 23, 42, 0.04);
    --border-alpha: rgba(15, 23, 42, 0.08);

    /* Sidebar */
    --sidebar-width: 200px;
    --sidebar-bg: #0F172A;
    --sidebar-text: #CBD5E1;
    --sidebar-text-active: #FFFFFF;
    --sidebar-item-hover: rgba(255,255,255,0.06);
    --sidebar-item-active: rgba(37,99,235,0.2);
    --sidebar-accent: #2563EB;
}

/* ─── App Layout ─── */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* ─── Sidebar ─── */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 50;
    overflow-y: auto;
    overflow-x: hidden;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 20px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-brand-logo {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    object-fit: cover;
    flex-shrink: 0;
}

.sidebar-brand-text h1 {
    font-size: 1.15rem;
    font-weight: 800;
    color: #FFFFFF;
    margin: 0;
    line-height: 1.1;
    letter-spacing: -0.3px;
}

.sidebar-brand-text p {
    font-size: 0.68rem;
    color: #64748B;
    margin: 2px 0 0;
    font-weight: 500;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 10px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar-nav-label {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #475569;
    padding: 16px 12px 6px;
    margin: 0;
}

.sidebar-nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--sidebar-text);
    text-decoration: none;
    cursor: pointer;
    transition: all 0.15s ease;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-family: inherit;
}

.sidebar-nav-item:hover {
    background: var(--sidebar-item-hover);
    color: var(--sidebar-text-active);
}

.sidebar-nav-item.active {
    background: var(--sidebar-item-active);
    color: var(--sidebar-text-active);
    font-weight: 600;
}

.sidebar-nav-item.active .sidebar-nav-icon {
    color: var(--sidebar-accent);
}

.sidebar-nav-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    opacity: 0.7;
}

.sidebar-nav-item.active .sidebar-nav-icon,
.sidebar-nav-item:hover .sidebar-nav-icon {
    opacity: 1;
}

/* Sidebar bottom section */
.sidebar-bottom {
    padding: 12px 14px 16px;
    border-top: 1px solid rgba(255,255,255,0.08);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 10px;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.06);
    cursor: pointer;
    transition: background 0.2s;
}

.sidebar-user:hover {
    background: rgba(255,255,255,0.08);
}

.sidebar-user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--brand, #7C5CFF), #4C8DFF);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 0.8rem;
    font-weight: 700;
    flex-shrink: 0;
}

.sidebar-user-info {
    flex: 1;
    min-width: 0;
}

.sidebar-user-name {
    font-size: 0.82rem;
    font-weight: 600;
    color: #FFFFFF;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-role {
    font-size: 0.68rem;
    color: #64748B;
    text-transform: capitalize;
}

.sidebar-help {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    margin-top: 8px;
    border-radius: 8px;
    font-size: 0.8rem;
    color: #64748B;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
}

.sidebar-help:hover {
    background: rgba(255,255,255,0.06);
    color: var(--sidebar-text-active);
}

/* ─── Main Content (beside sidebar) ─── */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    background: var(--bg-dark);
    display: flex;
    flex-direction: column;
}

.content-top-bar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 28px;
    background: rgba(255,255,255,0.92);
    border-bottom: 1px solid var(--card-border);
    backdrop-filter: blur(8px);
    gap: 16px;
}

.content-top-bar-left {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.content-top-bar-left h2 {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text-main);
    margin: 0;
    line-height: 1.2;
}

.content-top-bar-left p {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin: 0;
}

.content-top-bar-right {
    display: flex;
    align-items: center;
    gap: 14px;
}

.content-search-box {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--surface-2);
    border: 1px solid var(--card-border);
    border-radius: 10px;
    padding: 8px 14px;
    min-width: 240px;
    transition: all 0.2s;
}

.content-search-box:focus-within {
    background: var(--surface-hover);
    border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--brand-soft);
}

.content-search-box input {
    background: transparent;
    border: none;
    outline: none;
    font-family: inherit;
    font-size: 0.88rem;
    color: var(--text-main);
    width: 100%;
}

.content-search-box input::placeholder {
    color: var(--text-faint);
}

.content-search-box svg {
    color: var(--text-faint);
    flex-shrink: 0;
}

.content-notification-btn {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    border: 1px solid var(--card-border);
    background: var(--surface);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    position: relative;
}

.content-notification-btn:hover {
    background: var(--card-hover);
    color: var(--text-main);
}

.content-user-pill {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 5px 12px 5px 5px;
    border-radius: 10px;
    border: 1px solid var(--card-border);
    background: var(--surface);
    cursor: pointer;
    transition: all 0.2s;
}

.content-user-pill:hover {
    background: var(--card-hover);
}

.content-user-pill-avatar {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--brand, #7C5CFF), #4C8DFF);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 0.75rem;
    font-weight: 700;
}

.content-user-pill-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-main);
}

.content-user-pill-role {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.content-body {
    flex: 1;
    padding: 24px 28px 36px;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
}

/* Mobile sidebar toggle */
.sidebar-toggle {
    display: none;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    border: 1px solid var(--card-border);
    background: var(--surface);
    color: var(--text-main);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--scrim);
    z-index: 40;
}

/* ─── Responsive Sidebar ─── */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .sidebar-overlay.open {
        display: block;
    }
    .main-content {
        margin-left: 0;
    }
    .sidebar-toggle {
        display: flex;
    }
    .content-search-box {
        min-width: 160px;
    }
}

@media (max-width: 680px) {
    .content-top-bar {
        padding: 12px 16px;
    }
    .content-body {
        padding: 16px;
    }
    .content-search-box {
        min-width: 120px;
        padding: 6px 10px;
    }
    .content-user-pill-name,
    .content-user-pill-role {
        display: none;
    }
}

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

body.dark-theme {
    background: radial-gradient(1200px 600px at 10% 10%, rgba(99, 102, 241, 0.10) 0%, transparent 55%),
                radial-gradient(1000px 600px at 85% 90%, rgba(22, 199, 164, 0.07) 0%, transparent 55%),
                var(--bg-dark);
    color: var(--text-main);
    font-family: 'Inter', -apple-system, Segoe UI, Roboto, sans-serif;
    min-height: 100vh;
    line-height: 1.5;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

.ambient-glow {
    position: fixed;
    z-index: -1;
    pointer-events: none;
    border-radius: 50%;
    filter: blur(60px);
    opacity: 0.18;
}

.ambient-glow-1 {
    width: 260px;
    height: 260px;
    background: var(--brand, #7C5CFF);
    top: -80px;
    left: -80px;
}

.ambient-glow-2 {
    width: 300px;
    height: 300px;
    background: var(--accent-teal, #16C7A4);
    right: -100px;
    bottom: -100px;
}

.top-nav {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 24px;
    background: rgba(16, 19, 34, 0.85);
    border-bottom: 1px solid var(--card-border);
    backdrop-filter: blur(6px);
    flex-wrap: wrap;
    gap: 12px;
}

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

.logo-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: #fff;
}

.highlight-text {
    background: linear-gradient(90deg, #A78BFF, #5CC8FF);
    background-clip: text;
    -webkit-background-clip: text;
    color: transparent;
}

.nav-left h2 {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1;
}

.nav-tagline {
    color: var(--text-muted);
    border-left: 1px solid var(--card-border);
    padding-left: 12px;
}

.credits-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    visibility: visible !important;
    opacity: 1 !important;
    max-width: 350px;
}

.credits-info {
    text-align: right;
    line-height: 1.15;
}

.credits-label {
    font-size: 12px;
    color: #a28bff;
    font-weight: 700;
    text-transform: uppercase;
}

.credits-usage,
.credits-text {
    font-size: 13px;
    color: var(--text-muted);
}

.credits-track {
    width: 120px;
    height: 6px;
    border-radius: 999px;
    overflow: hidden;
    background: var(--border-alpha);
}

.credits-fill {
    width: 0%;
    height: 100%;
    transition: width 0.3s ease;
}

.gradient-bg {
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
}

.container {
    max-width: 1100px;
    margin: 24px auto;
    padding: 0 16px 36px;
}

.glass-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.25);
    padding: 22px;
    margin-bottom: 18px;
}

.subtle-glass {
    background: var(--bg-alpha);
    border: 1px solid var(--border-alpha);
    border-radius: 12px;
    padding: 14px;
}

.hidden {
    display: none !important;
}

.drop-zone {
    border: 2px dashed rgba(147, 173, 226, 0.35);
    border-radius: 14px;
    padding: 34px 18px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s ease, background-color 0.2s ease;
    min-height: 160px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.drop-zone:hover,
.drop-zone.dragover {
    border-color: #7b9cff;
    background: rgba(86, 118, 204, 0.13);
}

.upload-icon-wrap {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    margin: 0 auto 12px;
    background: var(--border-alpha);
    color: #7b9cff;
}

.drop-text {
    font-size: 1.06rem;
    margin: 6px 0;
}

.file-formats,
.file-info {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.bold {
    font-weight: 700;
}

.modern-steps {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 14px;
}

.step {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: var(--text-muted);
    gap: 6px;
    font-size: 0.9rem;
}

.step-icon {
    width: 40px;
    height: 40px;
    border-radius: 999px;
    display: grid;
    place-items: center;
    border: 1px solid var(--card-border);
    background: var(--bg-alpha);
}

.step-line {
    flex: 1;
    height: 2px;
    border-radius: 999px;
    background: var(--border-alpha);
    margin-bottom: 22px;
}

.step.active {
    color: #9ab6ff;
}

.step.active .step-icon,
.step.done .step-icon {
    border-color: #88a4ff;
    background: rgba(120, 142, 255, 0.2);
}

.status-message {
    color: var(--text-main);
    margin-bottom: 8px;
}

.progress-bar-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
}

.progress-bar-track,
.logic-track {
    flex: 1;
    height: 8px;
    border-radius: 999px;
    overflow: hidden;
    background: var(--border-alpha);
}

.progress-bar-fill {
    width: 0%;
    height: 100%;
    transition: width 0.25s linear;
}

.progress-pct-label {
    min-width: 40px;
    text-align: right;
    font-weight: 600;
}

.result-header,
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
    border-bottom: 1px solid var(--card-border);
    padding-bottom: 12px;
}

.result-title-group,
.actions-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.modern-badges {
    display: flex;
    gap: 8px;
}

.badge {
    padding: 5px 10px;
    border-radius: 999px;
    border: 1px solid var(--card-border);
    background: var(--bg-alpha);
    font-size: 12px;
    font-weight: 600;
}

.icon-button {
    width: 34px;
    height: 34px;
    border-radius: 999px;
    border: 1px solid var(--card-border);
    background: var(--bg-alpha);
    color: var(--text-main);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
    transition: all 0.2s ease;
    min-width: 44px;
    min-height: 44px;
}

.content-grid {
    display: grid;
    grid-template-columns: 1.35fr 1fr;
    gap: 14px;
    margin-bottom: 14px;
    align-items: stretch; /* Ensure columns match height */
}

.transcript-pane, .ai-pane {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.ai-block {
    flex: 1;
    display: flex;
    flex-direction: column;
}

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

.gradient-text {
    /* Token-driven so it darkens for light mode: the pale violet-to-cyan tuned
       for a black ground washes out to near-illegible on white. */
    background: linear-gradient(90deg, var(--brand, #7C5CFF), var(--accent-blue, #4C8DFF));
    background-clip: text;
    -webkit-background-clip: text;
    color: transparent;
    font-weight: 700;
}

.transcript-box,
.ai-content {
    flex: 1; /* Fill the pane height */
    overflow-y: auto;
    white-space: pre-wrap;
    color: var(--text-main);
    font-size: 0.95rem;
    line-height: 1.65;
    padding-right: 6px;
}

.ai-content {
    background: var(--surface-inset, #0A0C16);
    border: 1px solid var(--card-border);
    border-radius: var(--r-lg, 12px);
    padding: 16px 18px;
    color: var(--text-main);
    white-space: normal;
}

/* Quality Audit renders structured HTML cards, not preformatted text.
   Override the .ai-content pre-wrap so template-literal newlines/indentation
   don't render as literal line breaks. */
#modal-quality-audit-content {
    white-space: normal;
    line-height: 1.4;
}

.ai-content p {
    color: var(--text-main);
    margin: 0 0 8px;
}

.ai-loading,
.ai-empty {
    color: var(--text-muted);
}

.custom-scrollbar::-webkit-scrollbar {
    width: 7px;
}

.custom-scrollbar::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 999px;
}

.btn {
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 9px 12px;
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
}

.btn-outline {
    background: var(--bg-alpha);
    border-color: var(--card-border);
    color: var(--text-main);
}

.btn-primary {
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
    color: #fff;
}

.result-footer,
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    border-top: 1px solid var(--card-border);
    padding-top: 12px;
}

.btn-micro {
    border: 1px solid var(--card-border);
    background: var(--bg-alpha);
    color: var(--text-main);
    border-radius: 7px;
    padding: 4px 8px;
    cursor: pointer;
    font-size: 0.82rem;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
    min-height: 32px;
}

.history-header {
    margin-bottom: 8px;
}

.history-header .subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
}

@media (max-width: 1024px) {
    .history-section .history-header ~ div {
        grid-template-columns: 1fr !important;
    }
    .history-section .history-header ~ div > div:nth-child(2) {
        width: 100%;
    }
}

.table-container {
    overflow: auto;
}

.modern-table {
    width: 100%;
    border-collapse: collapse;
}

.modern-table th,
.modern-table td {
    padding: 12px 10px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: top; /* Ensure row expansion doesn't center content of other cells */
    height: 1px; /* Firefox/Chrome trick: row only takes minimum content height */
}

.modern-table tr {
    height: auto;
}

.modern-table th {
    color: var(--text-muted);
    font-size: 0.82rem;
}

.status-badge {
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 0.74rem;
    font-weight: 700;
}

.status-uploaded,
.status-processing {
    background: var(--status-warning-soft);
    color: var(--status-warning);
}

.status-completed {
    background: var(--status-success-soft);
    color: var(--status-success);
    font-weight: 700;
}

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

.action-btn {
    border: none;
    background: transparent;
    color: var(--brand);
    cursor: pointer;
    margin-right: 8px;
}

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

.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: var(--scrim);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.modal-card {
    width: min(1180px, 96vw);
    height: min(92vh, 920px);
    max-height: 92vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-content-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

.modal-content-scroll .transcript-box,
.modal-content-scroll .ai-content {
    height: auto;
    min-height: 220px;
}

.tab-pane {
    display: none !important;
    flex-direction: column;
    height: 100%;
    width: 100%;
}

.tab-pane.active {
    display: flex !important;
}

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

.modal-close:hover {
    color: #fff;
}

@media (max-width: 980px) {
    .content-grid,
    .modal-content-scroll {
        grid-template-columns: 1fr;
    }

    .transcript-box,
    .ai-content {
        height: 420px;
    }

    .modal-content-scroll .transcript-box,
    .modal-content-scroll .ai-content {
        height: calc(92vh - 320px);
    }
}

@media (max-width: 768px) {
    .nav-left h2 {
        font-size: 1.35rem;
    }

    .nav-tagline {
        display: none;
    }

    .credits-bar {
        width: 100%;
        order: 3;
    }

    .top-nav {
        padding: 12px 16px;
    }

    .container {
        padding: 0 12px 24px;
    }

    .glass-card {
        padding: 16px;
    }

    .drop-zone {
        padding: 24px 14px;
    }

    .upload-icon-wrap {
        width: 48px;
        height: 48px;
    }

    .drop-text {
        font-size: 1rem;
    }

    .modern-steps {
        gap: 6px;
        flex-wrap: wrap;
    }

    .step span {
        font-size: 0.8rem;
    }

    .step-icon {
        width: 32px;
        height: 32px;
    }

    .transcript-box,
    .ai-content {
        height: 350px;
    }

    .btn {
        padding: 8px 10px;
        font-size: 0.85rem;
    }

    .result-footer,
    .modal-footer {
        flex-wrap: wrap;
        gap: 8px;
    }

    .btn-micro {
        padding: 4px 6px;
        font-size: 0.75rem;
    }

    .table-container {
        overflow-x: auto;
    }

    .modern-table th,
    .modern-table td {
        padding: 10px 8px;
        font-size: 0.85rem;
    }
}

@media (max-width: 680px) {
    .ambient-glow {
        display: none;
    }

    .top-nav {
        padding: 10px;
        justify-content: space-between;
    }

    .nav-left h2 {
        font-size: 1.2rem;
        font-weight: 700;
    }

    .logo-icon {
        width: 32px;
        height: 32px;
    }

    .logo-icon svg {
        width: 18px;
        height: 18px;
    }

    .nav-left {
        gap: 8px;
    }

    .credits-bar {
        width: 100%;
        order: 3;
        padding: 8px 10px;
        gap: 8px;
    }

    .credits-info {
        text-align: right;
    }

    .credits-label {
        font-size: 11px;
    }

    .credits-usage,
    .credits-text {
        font-size: 12px;
    }

    .credits-track {
        width: 80px;
        height: 5px;
    }

    .container {
        max-width: 100%;
        padding: 0 10px 16px;
        margin: 12px auto;
    }

    .glass-card {
        padding: 12px;
        margin-bottom: 12px;
        border-radius: 12px;
    }

    .drop-zone {
        padding: 20px 12px;
        border-radius: 12px;
    }

    .upload-icon-wrap {
        width: 40px;
        height: 40px;
        margin: 0 auto 8px;
    }

    .upload-icon-wrap svg {
        width: 24px;
        height: 24px;
    }

    .drop-zone h3 {
        font-size: 1.1rem;
    }

    .drop-text {
        font-size: 0.9rem;
        margin: 4px 0;
    }

    .file-formats {
        font-size: 0.8rem;
    }

    .modern-steps {
        gap: 5px;
        margin-bottom: 10px;
        justify-content: center;
    }

    .step {
        gap: 4px;
        font-size: 0.75rem;
    }

    .step-icon {
        width: 28px;
        height: 28px;
    }

    .step-icon svg {
        width: 14px;
        height: 14px;
    }

    .step-line {
        flex: 0.5;
        height: 1.5px;
        margin-bottom: 16px;
    }

    .result-header,
    .modal-header {
        flex-wrap: wrap;
        gap: 8px;
    }

    .result-title-group h2,
    .modal-header h2 {
        font-size: 1.3rem;
    }

    .icon-pulse svg {
        width: 18px;
        height: 18px;
    }

    .modern-badges {
        gap: 6px;
    }

    .badge {
        padding: 4px 8px;
        font-size: 11px;
    }

    .icon-button {
        width: 30px;
        height: 30px;
    }

    .icon-button svg {
        width: 18px;
        height: 18px;
    }

    .transcript-box,
    .ai-content {
        height: 280px;
        font-size: 0.9rem;
    }

    .pane-header h3 {
        font-size: 0.95rem;
    }

    .btn {
        padding: 7px 8px;
        font-size: 0.8rem;
    }

    .result-footer,
    .modal-footer {
        flex-direction: column;
        gap: 6px;
    }

    .result-footer button,
    .modal-footer button {
        width: 100%;
        text-align: center;
    }

    .btn-micro {
        padding: 3px 5px;
        font-size: 0.7rem;
    }

    .btn-micro svg {
        width: 12px;
        height: 12px;
    }

    .modal-card {
        width: min(100vw, 95vw);
        height: min(95vh, 850px);
        max-height: 95vh;
        border-radius: 12px;
    }

    .modal-content-scroll .transcript-box,
    .modal-content-scroll .ai-content {
        height: calc(95vh - 280px);
        min-height: 150px;
    }

    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .modern-table th,
    .modern-table td {
        padding: 9px 6px;
        font-size: 0.75rem;
    }

    .modern-table {
        min-width: 100%;
    }

    .history-header {
        margin-bottom: 10px;
    }

    .history-header h2 {
        font-size: 1.2rem;
        margin-bottom: 4px;
    }

    .pane-header {
        flex-wrap: wrap;
        gap: 6px;
    }
}

@media (max-width: 480px) {
    .top-nav {
        padding: 8px;
        flex-direction: column;
    }

    .nav-left,
    .credits-bar {
        width: 100%;
        order: unset;
    }

    .nav-left {
        justify-content: center;
        gap: 6px;
    }

    .nav-left h2 {
        font-size: 1.1rem;
    }

    .logo-icon {
        width: 28px;
        height: 28px;
    }

    .logo-icon svg {
        width: 16px;
        height: 16px;
    }

    .credits-bar {
        padding: 6px 8px;
        gap: 6px;
        justify-content: space-between;
    }

    .credits-info {
        text-align: center;
        flex: 1;
    }

    .credits-label {
        font-size: 10px;
    }

    .credits-usage,
    .credits-text {
        font-size: 11px;
    }

    .credits-track {
        width: 60px;
        height: 4px;
    }

    .container {
        padding: 0 8px 12px;
        margin: 8px auto;
    }

    .glass-card {
        padding: 10px;
        margin-bottom: 10px;
    }

    .drop-zone {
        padding: 16px 10px;
    }

    .upload-icon-wrap {
        width: 36px;
        height: 36px;
        margin: 0 auto 6px;
    }

    .upload-icon-wrap svg {
        width: 20px;
        height: 20px;
    }

    .drop-zone h3 {
        font-size: 1rem;
        margin: 6px 0;
    }

    .drop-text {
        font-size: 0.85rem;
    }

    .file-formats {
        font-size: 0.75rem;
    }

    .modern-steps {
        gap: 3px;
    }

    .step {
        font-size: 0.65rem;
    }

    .step-icon {
        width: 24px;
        height: 24px;
    }

    .step-icon svg {
        width: 12px;
        height: 12px;
    }

    .step-line {
        flex: 0.3;
        margin-bottom: 14px;
    }

    .transcript-box,
    .ai-content {
        height: 240px;
        font-size: 0.85rem;
    }

    .result-header,
    .modal-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .result-title-group h2,
    .modal-header h2 {
        font-size: 1.15rem;
        margin-bottom: 4px;
    }

    .actions-group {
        width: 100%;
        justify-content: space-between;
    }

    .modern-badges {
        gap: 4px;
    }

    .badge {
        padding: 3px 6px;
        font-size: 10px;
    }

    .icon-button {
        width: 28px;
        height: 28px;
    }

    .icon-button svg {
        width: 16px;
        height: 16px;
    }

    .pane-header h3 {
        font-size: 0.85rem;
    }

    .btn {
        padding: 6px 6px;
        font-size: 0.75rem;
    }

    .btn-micro {
        padding: 2px 4px;
        font-size: 0.65rem;
    }

    .btn-micro svg {
        width: 10px;
        height: 10px;
    }

    .modal-card {
        width: 100vw;
        height: 100vh;
        border-radius: 0;
    }

    .modal-overlay {
        padding: 0;
    }

    .modal-content-scroll .transcript-box,
    .modal-content-scroll .ai-content {
        height: calc(100vh - 260px);
        min-height: 120px;
    }

    .modern-table th,
    .modern-table td {
        padding: 8px 4px;
        font-size: 0.7rem;
    }

    .status-badge {
        font-size: 0.6rem;
        padding: 2px 5px;
    }

    .action-btn {
        margin-right: 4px;
        font-size: 0.7rem;
    }

    .history-header h2 {
        font-size: 1.1rem;
    }

    .history-header .subtitle {
        font-size: 0.8rem;
    }
}

/* ─── Speaker Turn Styling ─── */
.speaker-turn {
    margin-bottom: 16px;
    padding-left: 12px;
    border-left: 3px solid var(--border-alpha);
}
.speaker-turn .speaker-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}
.speaker-turn .speaker-avatar {
    width: 24px;
    height: 24px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
}
.speaker-turn .speaker-name {
    font-size: 0.85rem;
    font-weight: 600;
}
.speaker-turn .speaker-timestamp {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-family: 'SF Mono', 'Fira Code', monospace;
    opacity: 0.7;
}
.speaker-turn .speaker-text {
    font-size: 0.93rem;
    color: var(--text-main);
    line-height: 1.6;
    padding: 4px 0;
}
.speaker-turn .speaker-text[contenteditable="true"] {
    background: var(--bg-alpha);
    border: 1px solid rgba(111, 125, 246, 0.3);
    border-radius: 8px;
    padding: 8px 12px;
    outline: none;
    min-height: 1.6em;
}
.speaker-turn .speaker-text[contenteditable="true"]:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(111, 125, 246, 0.15);
}
.overlap-indicator {
    font-size: 0.7rem;
    color: var(--text-muted);
    background: rgba(255, 209, 102, 0.1);
    border: 1px solid rgba(255, 209, 102, 0.2);
    padding: 1px 6px;
    border-radius: 4px;
    margin-left: 8px;
}
.edit-mode-bar {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    padding: 12px 0;
    border-top: 1px solid var(--border-alpha);
    margin-top: 12px;
}

/* Print Styles for Structured PDF */
@media print {
    body {
        background: #FFFFFF !important;
        color: #000000 !important;
    }
    .sidebar, .top-nav, .modal-tabs, .btn, .btn-micro, #download-options-menu, #modal-close {
        display: none !important;
    }
    .modal-overlay {
        position: static !important;
        background: none !important;
        padding: 0 !important;
    }
    .modal-container {
        width: 100% !important;
        max-width: 100% !important;
        box-shadow: none !important;
        border: none !important;
        background: none !important;
        padding: 0 !important;
    }
    .transcript-box, .ai-content {
        max-height: none !important;
        overflow: visible !important;
        border: none !important;
        background: none !important;
        padding: 0 !important;
    }
    .speaker-turn {
        border-left-color: #000000 !important;
        margin-bottom: 15px !important;
        page-break-inside: avoid;
    }
    .speaker-avatar {
        background: #000000 !important;
        color: #FFFFFF !important;
    }
    .speaker-name {
        color: #000000 !important;
        font-weight: bold !important;
    }
    .gradient-text {
        background: none !important;
        color: #000000 !important;
        -webkit-text-fill-color: #000000 !important;
        font-weight: bold !important;
    }
}

/* Workspace History numbered pager */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 16px;
}

.pagination-btn {
    min-width: 34px;
    padding: 6px 10px;
    border: 1px solid var(--card-border);
    border-radius: 6px;
    background: var(--card-bg);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.85rem;
    line-height: 1;
}

.pagination-btn:hover:not(:disabled) {
    background: var(--card-hover);
}

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

.pagination-btn:disabled {
    cursor: default;
    opacity: 0.5;
}

.pagination-btn.active:disabled {
    opacity: 1; /* the current page stays solid, not dimmed */
}

.pagination-gap {
    padding: 0 4px;
    color: var(--text-secondary);
}

.pagination-info {
    margin-left: 10px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* ─── Video Player Modal ─── */
.video-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.video-modal-container {
    background: #0f172a; /* Slate 900 for dark premium video feel */
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    width: 100%;
    max-width: 900px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.video-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.video-modal-title {
    color: #f8fafc;
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 80%;
}

.video-modal-close {
    background: none;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.video-modal-close:hover {
    color: #f8fafc;
    background: rgba(255, 255, 255, 0.1);
}

.video-modal-body {
    padding: 0;
    background: #000;
    display: flex;
    justify-content: center;
    align-items: center;
    aspect-ratio: 16/9;
}

.video-player-element {
    width: 100%;
    height: 100%;
    max-height: 70vh;
    object-fit: contain;
}

.video-loading-placeholder {
    color: #94a3b8;
    font-size: 0.95rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.video-spinner {
    width: 24px;
    height: 24px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: video-spin 0.8s linear infinite;
}

@keyframes video-spin {
    to { transform: rotate(360deg); }
}

/* Provenance cells in the history table: who uploaded a row, and when/from where.
   Two stacked lines so the identifying detail is there without a wide column. */
.uploader-cell {
    display: flex;
    flex-direction: column;
    line-height: 1.3;
    min-width: 0;
}

.uploader-name {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text, #111827);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.uploader-email {
    font-size: 11px;
    color: var(--text-muted, #6b7280);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ─── Meeting detail view ──────────────────────────────────────────────────
   Replaces the old cramped transcript modal. Recording + synced transcript on
   the left, AI panels on the right. Clicking a transcript line seeks the video;
   the line being spoken is highlighted. */

.detail-view {
    width: min(1500px, 97vw);
    height: min(94vh, 1000px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--surface, #ffffff);
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 14px;
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.22);
}

.detail-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border, #e5e7eb);
    flex-shrink: 0;
}

.detail-back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 8px;
    background: transparent;
    color: var(--text-muted, #6b7280);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.detail-back:hover {
    background: var(--surface-hover, #f3f4f6);
    color: var(--text, #111827);
}

.detail-title-group {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex: 1;
}

.detail-title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.detail-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.detail-body {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 1.55fr) minmax(340px, 1fr);
}

.detail-main {
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 18px 20px;
    border-right: 1px solid var(--border, #e5e7eb);
    overflow: hidden;
}

/* Player */
.detail-player {
    flex-shrink: 0;
    border-radius: 10px;
    overflow: hidden;
    background: #0b1220;
}

.detail-player-video {
    display: block;
    width: 100%;
    max-height: 42vh;
    background: #0b1220;
}

.detail-player-state {
    padding: 28px;
    text-align: center;
    color: #94a3b8;
    font-size: 13px;
}

.detail-player-error {
    color: var(--status-error, #dc2626);
}

/* Transcript */
.detail-transcript-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    flex-shrink: 0;
}

.detail-section-title {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 700;
}

.detail-hint {
    font-size: 11.5px;
    color: var(--text-muted, #6b7280);
}

.detail-transcript {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding-right: 6px;
}

/* The line currently being spoken. */
.speaker-turn-active {
    background: rgba(99, 102, 241, 0.16);
    border-radius: 6px;
}

.detail-transcript .speaker-turn {
    transition: background 0.12s ease;
}

.detail-transcript .speaker-turn:hover {
    /* A dark wash is invisible on a dark ground; lift the row instead. */
    background: var(--overlay-weak);
    border-radius: 6px;
}

/* Side panel */
.detail-side {
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: 18px 20px;
    overflow: hidden;
}

.detail-side .modal-tabs {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    flex-shrink: 0;
    margin-bottom: 14px;
}

.detail-side .modal-tab {
    padding: 7px 12px;
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 8px;
    background: transparent;
    color: var(--text-muted, #6b7280);
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.detail-side .modal-tab:hover {
    background: var(--surface-hover, #f3f4f6);
    color: var(--text, #111827);
}

.detail-side .modal-tab.active {
    background: var(--brand, #111827);
    border-color: var(--brand, #111827);
    color: #ffffff;
}

.detail-side .wrapper-tabs {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding-right: 6px;
}

/* Narrow screens: stack the panels instead of squeezing them. */
@media (max-width: 1100px) {
    .detail-body {
        grid-template-columns: 1fr;
        overflow-y: auto;
    }

    .detail-main {
        border-right: none;
        border-bottom: 1px solid var(--border, #e5e7eb);
        overflow: visible;
    }

    .detail-transcript,
    .detail-side .wrapper-tabs {
        overflow: visible;
    }

    .detail-player-video {
        max-height: 34vh;
    }
}
