/* ── STUDY ROOM DESIGN TOKENS ────────────────────────────────────────────────
     * Accent / blur tokens are theme-neutral and live in :root.
     * Surface, ink, and border tokens are theme-specific.
     * ───────────────────────────────────────────────────────────────────────── */
    :root {
        --sr-blur: blur(24px);

        /* Accent colours (same in both themes) */
        --sr-blue: var(--primary,#4ecdc4);
        --sr-blue-bg: color-mix(in srgb, var(--primary,#4ecdc4) 10%, transparent);
        --sr-green: #10b981;
        --sr-red: #f87171;
        --sr-gold: #f5c542;
    }

    /* ── LIGHT MODE ── */
    :root,
    [data-theme="light"] {
        --sr-glass:       var(--app-surface);
        --sr-glass-heavy: var(--app-surface);
        --sr-border:      rgba(0, 0, 0, 0.08);
        --sr-border-hover:rgba(0, 0, 0, 0.16);

        --sr-bg:     var(--app-bg);
        --sr-surface: var(--app-surface);
        --sr-hover:  #f1f5f9;
        --sr-ink:    #0f172a;
        --sr-muted:  #475569;
        --sr-light:  #64748b;
    }

    /* ── DARK MODE ── */
    [data-theme="dark"] {
        --sr-glass:       rgba(15, 23, 42, 0.4);
        --sr-glass-heavy: rgba(15, 23, 42, 0.6);
        --sr-border:      rgba(255, 255, 255, 0.08);
        --sr-border-hover:rgba(255, 255, 255, 0.15);

        --sr-bg:     transparent;
        --sr-surface: var(--sr-glass);
        --sr-hover:  rgba(255, 255, 255, 0.05);
        --sr-ink:    #ffffff;
        --sr-muted:  #94a3b8;
        --sr-light:  #64748b;
    }


    /* Active syllabus item — works in both themes via the shared --sr-blue token */
    .sb-item.sb-active {
        background: var(--sr-blue-bg);
        color: var(--sr-blue);
    }
    /* Slightly stronger border in light mode for contrast */
    [data-theme="light"] .sb-item.sb-active { border-color: color-mix(in srgb, var(--primary,#4ecdc4) 35%, transparent); }
    .sb-active .sb-meta { color: var(--sr-blue); opacity: 0.8; }


    /* Kill the base .main-content padding/min-height for this page only */
    .main-content,
    #main-content {
        min-height: unset !important;
        padding-bottom: 0 !important;
        padding-top: 0 !important;
        display: flex;
        flex-direction: column;
        height: 100dvh;
    }

    @supports not (height: 100dvh) {
        .main-content,
        #main-content {
            height: 100vh;
        }
    }

    /* ── LAYOUT ── */
    /* .room-wrap — superseded by the position:fixed rule below */
    .room-layout {
        display: flex;
        flex: 1;
        overflow: hidden;
        position: relative; /* anchor for absolute resize handles */
    }

    .study-room-side-nav {
        width: 18rem;
        flex: none;
        display: flex;
        flex-direction: column;
        background: var(--sr-glass-heavy);
        border-right: 1px solid var(--sr-border);
        backdrop-filter: var(--sr-blur) saturate(180%);
        -webkit-backdrop-filter: var(--sr-blur) saturate(180%);
        box-sizing: border-box;
        overflow: hidden;
    }
    .study-room-side-nav__header {
        display: flex;
        align-items: flex-start;
        justify-content: space-between;
        gap: 12px;
        padding: calc(env(safe-area-inset-top, 0px) + 16px) 16px 16px;
        border-bottom: 1px solid var(--sr-border);
    }
    .study-room-side-nav__eyebrow {
        font-size: 0.65rem;
        font-weight: 800;
        text-transform: uppercase;
        letter-spacing: 0.1em;
        color: var(--sr-light);
        margin-bottom: 4px;
    }
    .study-room-side-nav__title {
        font-size: 1rem;
        font-weight: 800;
        color: var(--sr-ink);
        line-height: 1.1;
    }
    .study-room-side-nav__subtitle {
        margin-top: 4px;
        font-size: 0.78rem;
        color: var(--sr-muted);
    }
    .study-room-side-nav__exit {
        width: 36px;
        height: 36px;
        border-radius: 10px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        flex: none;
        color: var(--sr-muted);
        text-decoration: none;
        transition: background-color 0.2s ease, color 0.2s ease;
    }
    .study-room-side-nav__exit:hover {
        background: var(--sr-hover);
        color: var(--sr-ink);
    }
    .study-room-tab-list {
        flex: 1;
        overflow-y: auto;
        padding: 12px;
        display: flex;
        flex-direction: column;
            justify-content: center;
            gap: 6px;
            flex: 1;
            min-width: fit-content;
            padding: 0 12px;
            height: 100%;
            background: transparent;
            border: none;
            border-radius: 0;
            color: var(--text-muted);
            font-size: 0.8125rem;
            font-weight: 500;
            letter-spacing: 0.01em;
            white-space: nowrap;
            cursor: pointer;
            position: relative;
            transition: color 0.2s ease;
            outline: none;
        width: 100%;
        justify-content: flex-start;
        align-items: center;
        gap: 12px;
        padding: 12px 14px;
        border: 1px solid transparent;
        border-radius: 14px;
        background: transparent;
        color: var(--sr-muted);
        border-bottom: none;
        text-align: left;
        white-space: normal;
        line-height: 1.15;
    }
    .study-room-nav-link:hover {
        background: var(--sr-hover);
        color: var(--sr-ink);
    }
    .study-room-nav-link.active {
        background: color-mix(in srgb, var(--primary,#4ecdc4) 12%, transparent);
        color: var(--sr-blue);
        border-color: color-mix(in srgb, var(--primary,#4ecdc4) 20%, transparent);
    }
    .study-room-nav-link i {
        width: 18px;
        text-align: center;
        flex-shrink: 0;
    }
    /* Ensure inline SVG icons inherit color and use the project's stroke style */
    .study-room-nav-link i svg,
    .study-room-nav-link i svg * {
        width: 18px;
        height: 18px;
        stroke: currentColor;
        stroke-linecap: round;
        stroke-linejoin: round;
        fill: none;
        display: inline-block;
        vertical-align: middle;
    }
    .study-room-nav-copy {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        gap: 2px;
        min-width: 0;
        flex: 1;
    }
    .study-room-nav-meta {
        font-size: 0.72rem;
        font-weight: 500;
        color: var(--sr-light);
    }
    .study-room-nav-link.active .study-room-nav-meta {
        color: var(--sr-blue);
    }

    .study-room-side-nav,
    .desktop-side-nav.study-room-side-nav {
        display: flex !important;
    }

    /* ── ROOM TABS BAR (mobile top tabs) — Variant A: Floating Capsule ─────
       Single authoritative rule. All previous mobile media-query duplicates
       have been removed; this rule is the only source of truth.
       Inactive tabs collapse to icon-only; active tab expands to icon+label
       and fills with --primary. Bottom edge sits at y=104 (60 top + 44 high)
       to match the previous bar's bottom edge so .room-wrap top:104 unchanged. */
.room-tabs-bar {
    position: fixed;
    top: 68px;
    left: 16px;
    right: 16px;
    height: 36px;
    z-index: 99;
    display: flex;
    align-items: center;
    backdrop-filter: blur(14px) saturate(160%);
    -webkit-backdrop-filter: blur(14px) saturate(160%);
    border: 0.5px solid var(--sr-border);
    padding: 7px;
    box-sizing: border-box;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    flex-shrink: 0;
}
.room-tabs-bar::-webkit-scrollbar { display: none; }

.room-tabs-container {
    display: flex;
    align-items: center;
    gap: 3px;
    height: 100%;
    width: 100%;
    justify-content: space-between;
    padding: 0;
    margin: 0;
}

/* ── Tab dividers for Chrono-Flow tiers ── */
.room-tabs-divider {
    display: flex;
    align-items: center;
    width: 20px;
    flex-shrink: 0;
    color: var(--sr-muted);
    opacity: 0.3;
    margin: 0 2px;
}
.room-tabs-divider::before {
    content: '>';
    font-size: 0.7rem;
    font-weight: 700;
    width: 100%;
    text-align: center;
}

    .room-tabs-bar .room-tab-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 5px;
        height: 100%;
        min-width: 34px;
        padding: 0 8px;
        background: transparent;
        border: none;
        border-radius: 999px;
        color: var(--text-muted);
        font-size: 0.78rem;
        font-weight: 500;
        white-space: nowrap;
        cursor: pointer;
        position: relative;
        flex: 0 0 auto;
        outline: none;
        transition: background 0.22s cubic-bezier(0.4, 0, 0.2, 1),
                    color 0.22s ease,
                    padding 0.22s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .room-tabs-bar .room-tab-btn i,
    .room-tabs-bar .room-tab-btn svg {
        width: 16px;
        height: 16px;
        flex-shrink: 0;
        opacity: 0.85;
        transition: opacity 0.2s ease;
    }

    .room-tabs-bar .room-tab-btn svg,
    .room-tabs-bar .room-tab-btn svg * {
        stroke: currentColor;
        stroke-linecap: round;
        stroke-linejoin: round;
        fill: none;
    }

    /* Label collapses to zero width when inactive; expands smoothly when active */
    .room-tabs-bar .room-tab-label {
        display: inline-block;
        max-width: 0;
        opacity: 0;
        overflow: hidden;
        white-space: nowrap;
        font-size: 0.78rem;
        margin: 0;
        transition: max-width 0.28s cubic-bezier(0.4, 0, 0.2, 1),
                    opacity 0.22s ease,
                    margin 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .room-tabs-bar .room-tab-btn:hover {
        color: var(--text-primary);
        background: transparent;
    }

    .room-tabs-bar .room-tab-btn.active {
        background: var(--primary, #7c6cfa);
        color: #ffffff;
        font-weight: 500;
        padding: 0 12px 0 10px;
    }

    .room-tabs-bar .room-tab-btn.active .room-tab-label {
        max-width: 110px;
        opacity: 1;
        margin-left: 2px;
    }

    .room-tabs-bar .room-tab-btn.active i,
    .room-tabs-bar .room-tab-btn.active svg {
        opacity: 1;
    }

    .room-tabs-bar .room-tab-btn.active svg,
    .room-tabs-bar .room-tab-btn.active svg * {
        color: #ffffff;
        stroke: #ffffff;
    }

    .room-tabs-bar .room-tab-btn:active {
        transform: scale(0.96);
    }

    .room-tabs-bar .room-tab-btn.room-tab-btn--disabled {
        opacity: 0.35;
        cursor: not-allowed;
    }
    .room-tabs-bar .room-tab-btn.room-tab-btn--disabled:hover {
        background: transparent;
        color: var(--text-secondary);
        transform: none;
    }
    .room-tabs-bar .room-tab-btn.room-tab-btn--disabled:active {
        transform: none;
    }

    @media (prefers-reduced-motion: reduce) {
        .room-tabs-bar .room-tab-btn,
        .room-tabs-bar .room-tab-label,
        .room-tabs-bar .room-tab-btn i,
        .room-tabs-bar .room-tab-btn svg {
            transition: none;
        }
        .room-tabs-bar .room-tab-btn:active {
            transform: none;
        }
    }

    .sb-tools-panel {
        padding: 10px 0 6px;
        border-bottom: 1px solid var(--sr-border);
    }

    .sb-tools {
        display: flex;
        flex-direction: column;
        gap: 6px;
        padding: 0 8px 8px;
    }

    .sb-tools .room-tab-btn {
        width: 100%;
        justify-content: flex-start;
        align-items: center;
        gap: 10px;
        padding: 10px 12px;
        border-radius: 10px;
        border: 1px solid var(--sr-border);
        background: var(--sr-surface);
    }
    .sb-tools .room-tab-btn.active {
        border-color: var(--sr-blue);
        background: color-mix(in srgb, var(--primary,#4ecdc4) 12%, transparent);
    }

    .sb-tools .room-tab-btn i {
        width: 18px;
        text-align: center;
        flex-shrink: 0;
    }

    .sb-tool-copy {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        min-width: 0;
        flex: 1;
        gap: 1px;
    }

    .sb-tool-meta {
        font-size: 0.68rem;
        font-weight: 500;
        color: var(--sr-light);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .sb-tools .room-tab-btn.active .sb-tool-meta {
        color: var(--sr-blue);
    }

    /* ── TOGGLE BUTTONS ── */
    .sb-head-btn, .ai-toggle {
        width: 28px; height: 28px;
        display: flex; align-items: center; justify-content: center;
        background: none; border: none; cursor: pointer;
        color: var(--sr-light); border-radius: 6px;
        transition: background 0.2s, color 0.2s;
    }
    .sb-head-btn:hover, .ai-toggle:hover {
        background: var(--sr-hover);
        color: var(--sr-ink);
    }

    .tb-btn {
        display: flex; align-items: center; gap: 6px;
        padding: 5px 12px; border-radius: 7px;
        border: 1px solid var(--sr-border);
        font-size: 0.8rem; font-weight: 600;
        background: transparent; color: var(--sr-muted);
        text-decoration: none; cursor: pointer;
        transition: background 0.15s, color 0.15s, border-color 0.15s; white-space: nowrap; flex-shrink: 0;
    }
    .tb-btn:hover { background: var(--sr-hover); color: var(--sr-ink); }
    .tb-btn-exit { color: var(--sr-red); border-color: rgba(239,68,68,0.2); margin-left: auto; }
    .tb-btn-exit:hover { background: rgba(239,68,68,0.06); border-color: var(--sr-red); }

    /* ── PASTE URL (inline with Recommended Videos heading) ── */
    .vid-head-row {
        display: flex;
        align-items: center;
        gap: 10px;
        justify-content: space-between;
        margin: 0 0 10px;
    }
    .vid-head-row .vid-section-heading {
        margin: 0;
        flex-shrink: 0;
    }
    /* ── LEFT SIDEBAR ── */
    .pane-syllabus {
        width: 260px; flex: none;
        background: var(--sr-glass);
        backdrop-filter: var(--sr-blur);
        -webkit-backdrop-filter: var(--sr-blur);
        border-right: 1px solid var(--sr-border);
        display: flex; flex-direction: column;
        overflow: hidden;
        z-index: 50;
        min-width: 0;
        position: relative;
        box-sizing: border-box;
    }
    .pane-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
    .pane-syllabus *, .pane-ai *, .pane-main * { box-sizing: border-box;  }

    .pane-syllabus.snapping, .pane-ai.snapping {
        transition: width 0.3s cubic-bezier(0.16, 1, 0.3, 1) !important;
    }
    body.is-resizing .pane-syllabus,
    body.is-resizing .pane-ai { 
        transition: none !important; 
    }
    
    /* ── RAIL STATE (60px) ── 
     * Width is intentionally NOT !important here — JS inline styles must win
     * during animated transitions. This class simply acts as a style hook. */
    .pane-syllabus.rail { width: 60px; }
    .pane-syllabus.rail .sb-prog-label,
    .pane-syllabus.rail .sb-subject-name,
    .pane-syllabus.rail .sb-progress-track,
    .pane-syllabus.rail .sb-progress-fill,
    .pane-syllabus.rail .sb-progress-count,
    .pane-syllabus.rail .sb-body,
    .pane-syllabus.rail .sb-cp-body,
    .pane-syllabus.rail .sb-cp-badge,
    .pane-syllabus.rail .sb-section,
    .pane-syllabus.rail .sb-tools-panel,
    .pane-syllabus.rail .sb-tool-copy,
    .pane-syllabus.rail .sb-tool-meta,
    .pane-syllabus.rail .tab-badge,
    .pane-syllabus.rail .sb-xp,
    .pane-syllabus.rail .sb-foot span,
    .pane-syllabus.rail .sb-foot-toggle-btn { display: none !important; }
    
    .pane-syllabus.rail .sb-head,
    .pane-syllabus.rail .sb-foot {
        border: none;
        padding: 10px 0;
        display: flex;
        justify-content: center;
        align-items: center;
    }
    .pane-syllabus.rail .sb-all-videos-link {
        width: 38px; height: 38px; border-radius: 8px;
        background: var(--sr-hover); color: var(--sr-ink);
        padding: 0 !important; display: flex !important;
        align-items: center; justify-content: center;
        flex: none !important;
    }
    .pane-syllabus.rail .sb-all-videos-link i { font-size: 0.95rem !important; }
    .pane-syllabus.rail .sb-head > div:first-child { display: none; }
    
    .pane-syllabus.rail .sb-scroll { padding: 8px 4px; border: none; }
    
    .pane-syllabus.rail #sylHeaderIcon,
    .pane-syllabus.rail #sylFooterIcon {
        color: var(--sr-blue);
        font-size: 0.9rem;
    }
    .pane-syllabus.rail .sb-item,
    .pane-syllabus.rail .sb-checkpoint {
        justify-content: center;
        padding: 10px 0;
        margin-left: 0;
        margin-right: 0;
        position: relative;
    }
    .pane-syllabus.rail .sb-tools .room-tab-btn {
        justify-content: center;
        padding: 10px 0;
    }
    .pane-syllabus.rail .sb-rail-num {
        display: block;
        position: absolute;
        top: 2px; right: 2px;
        font-size: 0.55rem;
        font-weight: 800;
        color: var(--sr-light);
        background: var(--sr-bg);
        width: 14px; height: 14px;
        border-radius: 4px;
        display: flex; align-items: center; justify-content: center;
        border: 1px solid var(--sr-border);
    }
    .pane-syllabus:not(.rail) .sb-rail-num { display: none; }
    
    .sb-head {
        padding: 16px;
        border-bottom: 1px solid var(--sr-border);
        flex-shrink: 0;
        min-height: 56px;
        display: flex;
        width: 100%;
        position: sticky;
        top: 0;
        z-index: 2;
        background: var(--bg-page);
        box-sizing: border-box;
        flex-direction: column;
        justify-content: center;
    }
    .sb-prog-label { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--sr-light); font-weight: 700; margin-bottom: 3px; }
    .sb-subject-name { font-size: 0.82rem; font-weight: 700; color: var(--sr-ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 8px; }
    .sb-progress-track { height: 3px; background: var(--sr-border); border-radius: 2px; overflow: hidden; }
    .sb-progress-fill { height: 100%; background: var(--sr-green); border-radius: 2px; transition: width 600ms cubic-bezier(0.4, 0, 0.2, 1); }
    .sb-progress-count { font-size: 0.7rem; color: var(--sr-light); margin-top: 4px; }

    .sb-scroll { flex: 1; overflow-y: auto; padding: 0 0 56px; }
    .sb-scroll::-webkit-scrollbar { width: 3px; }
    .sb-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

    .sb-section {
        font-size: 0.68rem; font-weight: 700; text-transform: uppercase;
        letter-spacing: 0.08em; color: var(--text-muted);
        padding: 0.35rem 0.75rem 0.15rem;
    }

    .sb-item {
        display: flex; align-items: center; gap: 0.625rem;
        padding: 0.35rem 0.45rem; border-radius: var(--radius-sm);
        text-decoration: none; color: var(--text-secondary);
        font-weight: 600; font-family: var(--font-display);
        font-size: 14px;
        cursor: pointer; transition: background 0.12s ease;
        min-height: 44px; width: 100%; min-width: 0; /* Let this flex row shrink inside nested flex layouts. */
        margin-bottom: 5px;
    }
    .sb-item:hover { background: var(--bg-hover); color: var(--text-primary); }
    .sb-item.sb-active {
        background: var(--bg-secondary); color: var(--text-primary); font-weight: 700;
    }
    .sb-item.sb-done { color: var(--text-muted); }

    .sb-dot {
        width: 20px; height: 20px; border-radius: 50%; flex-shrink: 0;
        display: flex; align-items: center; justify-content: center; font-size: 0.6rem;
    }
    .sb-dot-play  { background: #dbeafe; color: var(--sr-blue); }
    .sb-dot-done  { background: #dcfce7; color: var(--sr-green); }
    .sb-dot-pending  { background: var(--sr-hover); color: var(--text-muted); }

    .sb-body { flex: 1; min-width: 0; }
    .sb-name {
        display: block; /* Ellipsis needs a block-like box with a constrained width. */
        width: 100%;
        min-width: 0; /* Prevent the text box from forcing the flex row wider than its container. */
        font-size: 14px;
        font-weight: 600;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        color: inherit;
    }
    .sb-meta { font-size: 0.68rem; color: var(--text-muted); margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .sb-active .sb-meta { color: var(--text-muted); }

    .sb-xp { font-size: 0.65rem; font-weight: 500; color: var(--sr-gold); background: rgba(245,158,11,0.1); padding: 2px 5px; border-radius: 4px; flex-shrink: 0; }

    .sb-foot { padding: 0.75rem 0.5rem; border-top: 1px solid var(--border); flex-shrink: 0; }
    .sb-foot a {
        display: flex; align-items: center; justify-content: center; gap: 6px;
        width: 100%; padding: 0.55rem 0.75rem; border-radius: var(--radius-sm);
        border: none; background: transparent;
        font-size: 14px; font-weight: 600; color: var(--text-secondary);
        text-decoration: none; font-family: var(--font-display);
        transition: background 0.12s ease;
        min-height: 44px;
    }
    .sb-foot a:hover { background: var(--bg-hover); color: var(--text-primary); }
    .close-syllabus-btn { display: none; background: none; border: none; cursor: pointer; color: var(--text-muted); font-size: 1rem; flex-shrink: 0; }
    
    @media (min-width: 1025px) {
        #sylHeaderBtn { display: flex !important; background: none; border: none; cursor: pointer; color: var(--text-muted); padding: 0.35rem; border-radius: var(--radius-sm); transition: background 0.12s ease; min-height: 44px; }
        #sylHeaderBtn:hover { background: var(--bg-hover); color: var(--text-primary); }
    }

    /* ── RESIZE HANDLE ──
     * Handles are position:absolute overlays anchored to .room-layout.
     * JS sets their `left`/`right` position dynamically after each width change.
     * pointer-events during drag are locked to the handle via setPointerCapture,
     * so the iframe can never steal events mid-drag.
     */

    .resize-handle {
        position: absolute; top: 0; bottom: 0;
        width: 28px;
        transform: translateX(-50%);
        cursor: col-resize;
        z-index: 200;
        background: transparent;
        touch-action: none;
        overflow: visible;
    }
    .resize-handle::after { display: none; }

    @media (max-width: 1024px) { .resize-handle { display: none !important; } }

    

    /* During drag: freeze cursor and block iframe pointer steal via pointer-events */
    body.is-resizing { cursor: col-resize !important; }
    body.is-resizing * {
        cursor: col-resize !important;
        user-select: none !important;
        -webkit-user-select: none !important;
        pointer-events: none;
    }
    body.is-resizing .resize-handle { pointer-events: all; }

    /* Re-enable text selection and pointer events for the My Slides viewer
       so a global "is-resizing" state does not block PDF text selection */
    body.is-resizing .mys-shell,
    body.is-resizing .mys-shell * {
        user-select: text !important;
        -webkit-user-select: text !important;
        pointer-events: auto !important;
        cursor: default !important;
    }
    body.is-resizing .mys-page .textLayer,
    body.is-resizing .mys-page .textLayer span {
        user-select: text !important;
        -webkit-user-select: text !important;
        pointer-events: auto !important;
        cursor: text !important;
    }
    /* Re-enable text selection and pointer events for the AI ref pane viewer */
    body.is-resizing .ai-ref-page .textLayer,
    body.is-resizing .ai-ref-page .textLayer span {
        user-select: text !important;
        -webkit-user-select: text !important;
        pointer-events: auto !important;
        cursor: text !important;
    }

    /* Kill sidebar transitions during drag — prevents jitter */
    body.is-resizing .pane-syllabus,
    body.is-resizing .pane-ai { transition: none !important; }

    /* Iframe drag shield: invisible by default, shown during drag to block iframe pointer steal */
    .iframe-drag-shield {
        display: none;
        position: absolute; inset: 0; z-index: 10;
    }
    body.is-resizing .iframe-drag-shield { display: block; }

    .pane-main {
        flex: 1; display: flex; flex-direction: column;
        overflow: hidden; background: transparent; min-width: 0;
    }

    .room-viewports {
        position: relative; flex: 1; overflow: hidden; display: flex;
    }
    .room-vp {
        position: absolute; inset: 0; display: none;
        flex-direction: column; overflow-y: auto;
        background: var(--bg-page);
        align-items: center;
        justify-content: center;
        min-height: 0;
    }
    .room-vp--active {
        display: flex;
    }

    #tab-notes.room-vp {
        justify-content: flex-start;
        align-items: stretch;
        overflow-y: auto;
    }
    /* Video pane scrolls from top; gate panes (notes/quiz/etc.) stay centred */
    #tab-video.room-vp {
        justify-content: flex-start;
        align-items: center;
        /* padding: 16px 24px; */
        overflow-y: auto;
    }
    #tab-upload.room-vp {
        justify-content: flex-start;
        align-items: stretch;
        overflow-y: auto;
        min-height: 0;
        height: 100%;
    }
    @media (min-width: 861px) {
        #tab-quiz.room-vp,
        #tab-flashcards.room-vp,
        #tab-more.room-vp {
            overflow-y: auto;
        }
        #tab-voice.room-vp {
            overflow-y: auto;
        }
    }
    #tab-video .panel-inner {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        width: 100%;
        max-width: 720px;
    }

    .panel-inner {
        padding: 24px 24px; max-width: 720px;
        margin: 0 auto; width: 100%;
    }
    .vp-gate {
        display: flex; flex-direction: column; align-items: center;
        justify-content: center; text-align: center; padding: 48px 24px;
        min-height: 300px;
    }
    .vp-ghost-line {
        height: 10px; border-radius: 5px;
        background: rgba(255,255,255,0.08); margin-bottom: 8px;
    }

    /* Video */
    .vid-section-heading { font-family: var(--font-display); font-size: 0.82rem; font-weight: 700; color: var(--sr-light); text-transform: uppercase; letter-spacing: 0.06em; margin: 0 0 10px; }
    .video-wrap { width: 100%; aspect-ratio: 16/9; background: #000; border-radius: 12px; overflow: hidden; position: relative; }
    .video-placeholder { width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; background: #0f1117; color: white; gap: 10px; }
    .video-placeholder i { font-size: 2.5rem; color: var(--sr-red); }
    .vt-retry-btn { margin-top: 12px; padding: 8px 20px; border-radius: 8px; border: 1px solid var(--sr-border, rgba(255,255,255,0.15)); background: transparent; color: var(--sr-light); cursor: pointer; font-size: 0.85rem; transition: background 0.15s, border-color 0.15s; }
    .vt-retry-btn:hover { background: rgba(255,255,255,0.06); border-color: var(--sr-light); }
    .vt-retry-btn:disabled { opacity: 0.5; cursor: default; }

    /* Video title */
    .vid-title { font-family: var(--font-body); font-size: 1.1rem; font-weight: 600; color: var(--sr-ink); line-height: 1.35; margin: 19px 0px; letter-spacing: -0.01em; }

    /* Video transcript */
    .vid-transcript { display: flex; flex-direction: column; max-height: 180px; background: rgba(0,0,0,0.03); border-radius: 8px; margin-bottom: 16px; border: 1px solid var(--sr-line); overflow: hidden; }
    .vid-transcript-label { position: sticky; top: 0; z-index: 1; font-weight: 700; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; padding: 10px 14px 8px; background: inherit; border-bottom: 1px solid var(--sr-line); color: var(--sr-ink); }
    .vid-transcript-body { overflow-y: auto; padding: 10px 14px 14px; font-family: var(--font-body); font-size: 0.875rem; color: var(--sr-ink); line-height: 1.6; white-space: pre-wrap; }

/* ── Video Tab: New Split Layout ─────────────────────────────────────────── */

/* Shell: full height flex column, no outer scroll — the scroll lives inside .vt-transcript-scroll */
.vt-shell {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 720px;
    margin: 0 auto;
    padding: 20px 24px 0;
    min-height: 0;
    flex: 1;
    box-sizing: border-box;
}

/* 16:9 ratio wrapper for the iframe */
.vt-player-wrap {
    width: 100%;
    flex-shrink: 0;
    transition: none;
}
.vt-iframe-ratio {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%;
    border-radius: 12px;
    overflow: hidden;
    background: #000;
}
.vt-iframe-ratio iframe,
.vt-iframe-ratio .video-placeholder {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    border: none;
}

/* ── Video navigation overlay (shown on hover) ── */
.vt-overlay {
    position: absolute;
    inset: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}
.vt-overlay--visible {
    opacity: 1;
}
.vt-overlay-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}
.vt-overlay-btn {
    width: 52px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.35);
    color: #fff;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
    outline: none;
    -webkit-tap-highlight-color: transparent;
}
.vt-overlay-btn:hover {
    background: rgba(255, 255, 255, 0.18);
    border-color: rgba(255, 255, 255, 0.35);
    transform: scale(1.08);
}
.vt-overlay-btn:active {
    background: var(--primary, #7c6cfa);
    border-color: var(--primary, #7c6cfa);
    transform: scale(0.96);
}
.vt-overlay-btn:focus-visible {
    outline: 2px solid var(--primary, #7c6cfa);
    outline-offset: 2px;
}
.vt-overlay-btn svg {
    display: block;
    flex-shrink: 0;
}
.vt-overlay-label {
    font-family: var(--font-body, DM Sans, system-ui, sans-serif);
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255, 255, 255, 0.7);
    white-space: nowrap;
}

/* ── Mobile video navigation bar (below video, visible on touch devices) ── */
.vt-mobile-nav {
    display: none;
}
@media (hover: none) {
    .vt-mobile-nav {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 0 16px;
        height: 56px;
        border-top: 1px solid var(--border);
        background: var(--bg-page);
    }
}
.vt-mobile-nav-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: var(--bg-hover);
    color: var(--text-muted);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    -webkit-tap-highlight-color: transparent;
    flex-shrink: 0;
}
.vt-mobile-nav-btn:hover,
.vt-mobile-nav-btn:active {
    background: var(--bg-card);
    color: var(--text-primary);
}
.vt-mobile-nav-btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}
.vt-mobile-nav-btn svg {
    width: 20px;
    height: 20px;
    display: block;
}
.vt-mobile-nav-count {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.vt-title {
    padding: 10px 0 6px;
    font-size: 1rem;
    font-weight: 600;
    color: var(--sr-ink);
    line-height: 1.4;
}

/* Transcript section: flex column, takes remaining vertical space */
.vt-transcript-section {
    display: flex;
    flex-direction: column;
    min-height: 0;
    flex: 1;
    margin-top: 16px;
}

/* Header row: label left, action buttons right */
.vt-transcript-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    padding-bottom: 8px;
}

.vt-transcript-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--sr-muted);
    margin: 0;
}

.vt-transcript-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Shared action button style — icon-only or label+icon pill */
.vt-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--sr-muted);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
    line-height: 1;
}
.vt-action-btn:hover {
    background: var(--sr-hover);
    color: var(--sr-ink);
}
.vt-btn-icon {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

/* Scrollable transcript list — fills remaining space */
.vt-transcript-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding-bottom: 24px;
    scrollbar-color: transparent transparent;
}

.vt-transcript-inner {
    border-radius: 12px;
    padding: 16px;
    background: var(--sr-glass);
    border: 1px solid var(--sr-border);
}

.vt-transcript-segments {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Each timestamp segment: full-width button */
.vt-segment-btn {
    width: 100%;
    text-align: left;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 10px;
    padding: 10px 12px;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease;
    color: inherit;
}
.vt-segment-btn:hover {
    background: var(--sr-hover);
    border-color: var(--sr-border);
}
.vt-segment-btn:hover .vt-segment-icon {
    color: var(--sr-blue);
}

.vt-segment-inner {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.vt-segment-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    margin-top: 2px;
    color: var(--sr-light);
    transition: color 0.2s ease;
}

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

.vt-segment-ts {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--sr-blue);
    margin-bottom: 3px;
    font-family: var(--font-mono, monospace);
}

.vt-segment-text {
    font-size: 0.875rem;
    line-height: 1.6;
    color: var(--sr-ink);
    margin: 0;
    word-break: break-word;
}

.vt-transcript-empty {
    padding: 24px 16px;
    font-size: 0.875rem;
    color: var(--sr-muted);
    text-align: center;
}

/* ── Video discovery notification banner ── */
.vt-discovery-banner {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px 16px;
    background: color-mix(in srgb, var(--primary, #5b4cdb) 12%, transparent);
    border-bottom: 1px solid color-mix(in srgb, var(--primary, #5b4cdb) 20%, transparent);
    font-size: 0.875rem;
    color: var(--sr-ink);
}
.vt-discovery-banner-inner {
    display: flex;
    align-items: center;
    gap: 10px;
}
.vt-discovery-banner-inner svg {
    flex-shrink: 0;
    color: var(--primary, #5b4cdb);
}
.vt-discovery-banner-text {
    white-space: nowrap;
}
.vt-discovery-banner-btn {
    flex-shrink: 0;
    padding: 4px 14px;
    border-radius: 6px;
    border: none;
    background: var(--primary, #5b4cdb);
    color: #fff;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.15s ease;
}
.vt-discovery-banner-btn:hover {
    opacity: 0.85;
}

/* Dark theme overrides for the transcript inner card */
[data-theme="dark"] .vt-transcript-inner {
    background: rgba(255, 255, 255, 0.03);
    border-color: var(--sr-border);
}
[data-theme="light"] .vt-transcript-inner {
    background: var(--app-bg, #f8fafc);
    border-color: rgba(0, 0, 0, 0.07);
}

/* Mobile: remove side padding, tighten player radius */
@media (max-width: 860px) {
    .vt-shell {
        padding: 12px 12px 0;
        max-width: none;
    }
    .vt-iframe-ratio {
        border-radius: 0;
    }
}
/* ── End Video Tab Split Layout ──────────────────────────────────────────── */

    /* Video shelf — horizontal carousel of remaining videos */
    .vid-shelf {
        margin: 8px 0 0;
        width: 100%;
    }
    .vid-shelf-header {
        display: flex;
        align-items: baseline;
        gap: 10px;
        margin-bottom: 12px;
        padding: 0 2px;
    }
    .vid-shelf-title {
        font-size: 0.92rem;
        font-weight: 700;
        color: var(--sr-ink);
        letter-spacing: -0.01em;
    }
    .vid-shelf-count {
        font-size: 0.72rem;
        color: var(--sr-light);
        font-weight: 500;
    }
    .vid-shelf-track {
        display: flex;
        gap: 12px;
        overflow-x: auto;
        overflow-y: hidden;
        scroll-snap-type: x mandatory;
        scrollbar-width: thin;
        padding: 4px 2px 12px;
        margin: 0 -24px;
        padding-left: 24px;
        padding-right: 24px;
    }
    .vid-shelf-track {
        scrollbar-width: none;
        scroll-padding: 0 24px;
    }
    .vid-shelf-track::-webkit-scrollbar {
        display: none;
    }
    .vid-shelf-card {
        flex: 0 0 200px;
        scroll-snap-align: start;
        text-decoration: none;
        border-radius: 10px;
        overflow: hidden;
        transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
        cursor: pointer;
        display: flex;
        flex-direction: column;
    }
    .vid-shelf-card:hover {
        border-color: var(--sr-border-hover);
        box-shadow: 0 8px 24px rgba(0,0,0,0.2);
    }
    .vid-shelf-card--active {
        border-color: var(--sr-blue);
        box-shadow: 0 0 0 1px var(--sr-blue);
    }
    .vid-shelf-card--active:hover {
        border-color: var(--sr-blue);
        box-shadow: 0 0 0 1px var(--sr-blue), 0 8px 24px color-mix(in srgb, var(--primary,#4ecdc4) 12%, transparent);
    }
    .vid-shelf-card--done {
        opacity: 0.7;
    }
    .vid-shelf-card--done:hover {
        opacity: 1;
    }

    .vid-shelf-thumb {
        position: relative;
        width: 100%;
        aspect-ratio: 16/9;
        background: linear-gradient(135deg, #1a1d2e 0%, #0f1117 100%);
        background-size: cover;
        background-position: center;
        display: flex;
        align-items: center;
        justify-content: center;
        overflow: hidden;
    }
    .vid-shelf-overlay {
        position: absolute;
        inset: 0;
        background: rgba(0,0,0,0.35);
        pointer-events: none;
        z-index: 1;
    }
    .vid-shelf-playicon {
        position: relative;
        z-index: 2;
        width: 36px;
        height: 36px;
        border-radius: 50%;
        background: rgba(0,0,0,0.6);
        display: flex;
        align-items: center;
        justify-content: center;
        opacity: 0;
        transition: opacity 0.18s ease, transform 0.18s ease;
        transform: scale(0.9);
    }
    .vid-shelf-playicon svg {
        width: 16px;
        height: 16px;
        color: #fff;
        margin-left: 2px;
    }
    .vid-shelf-card:hover .vid-shelf-playicon {
        opacity: 1;
        transform: scale(1);
    }
    .vid-shelf-badge {
        position: absolute;
        top: 6px;
        font-size: 0.62rem;
        font-weight: 800;
        padding: 2px 7px;
        border-radius: 4px;
        letter-spacing: 0.02em;
        text-transform: uppercase;
        line-height: 1.3;
        z-index: 2;
    }
    .vid-shelf-badge--now {
        left: 6px;
        background: var(--sr-blue);
        color: #fff;
    }
    .vid-shelf-badge--done {
        right: 6px;
        background: rgba(16,185,129,0.85);
        color: #fff;
    }
    .vid-shelf-duration {
        position: absolute;
        bottom: 6px;
        right: 6px;
        z-index: 2;
        font-size: 0.62rem;
        font-weight: 700;
        color: #fff;
        background: rgba(0,0,0,0.75);
        padding: 1px 6px;
        border-radius: 3px;
        letter-spacing: 0.02em;
        line-height: 1.4;
    }
    .vid-shelf-body {
        padding: 10px 12px 12px;
    }
    .vid-shelf-card-title {
        font-size: 0.78rem;
        font-weight: 600;
        color: var(--sr-ink);
        line-height: 1.3;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    @media (max-width: 860px) {
        .vid-title { font-size: 1rem; }
        .vid-shelf-card { flex: 0 0 170px; }
        .vid-shelf-track {
            margin: 0 -8px;
            padding-left: 8px;
            padding-right: 8px;
            gap: 10px;
        }
    }

    /* Toolbar */
    .vid-toolbar {
        display: flex; align-items: center; gap: 16px;
        background: var(--sr-glass); padding: 12px 16px;
        backdrop-filter: var(--sr-blur); -webkit-backdrop-filter: var(--sr-blur);
        border-radius: 10px; border: 1px solid var(--sr-border);
        flex-wrap: wrap;
    }
    .conf-area { flex: 1; min-width: 180px; }
    .conf-labels { display: flex; justify-content: space-between; font-size: 0.72rem; color: var(--sr-muted); margin-bottom: 5px; }
    .confidence-slider { width: 100%; cursor: pointer; accent-color: var(--sr-blue); }
    .aura-badge {
        display: flex; align-items: center; gap: 7px;
        padding: 8px 14px; border-radius: 8px;
        font-size: 0.82rem; font-weight: 700;
        background: rgba(148,163,184,0.15); color: var(--sr-light);
        white-space: nowrap; flex-shrink: 0; transition: background 0.3s ease, color 0.3s ease;
    }
    .aura-badge.earned { background: rgba(16,185,129,0.12); color: var(--sr-green); }

    /* Channel row */
    .channel-row {
        display: flex; align-items: center; gap: 10px;
        padding: 10px 14px; background: var(--sr-glass);
        backdrop-filter: var(--sr-blur); -webkit-backdrop-filter: var(--sr-blur);
        border-radius: 10px; border: 1px solid var(--sr-border);
        margin-bottom: 6px;
    }
    .ch-avatar {
        width: 30px; height: 30px; border-radius: 50%;
        background: var(--sr-blue-bg); color: var(--sr-blue);
        display: flex; align-items: center; justify-content: center;
        font-size: 0.85rem; font-weight: 700; flex-shrink: 0;
    }
    .ch-name { font-size: 0.82rem; font-weight: 600; color: var(--sr-ink); display: flex; align-items: center; gap: 4px; }
    .ch-sub { font-size: 0.72rem; color: var(--sr-light); }
    .ch-subscribe {
        margin-left: auto; font-size: 0.78rem; font-weight: 700;
        color: white; border: none;
        background: var(--sr-red); padding: 6px 14px; border-radius: 20px; cursor: pointer;
        transition: background 0.15s, transform 0.15s; text-decoration: none; display: flex; align-items: center;
        box-shadow: 0 2px 4px rgba(239, 68, 68, 0.2);
    }
    .ch-subscribe:hover { background: #dc2626; transform: translateY(-1px); }
    
    .ch-actions {
        display: flex;
        align-items: center;
        gap: 12px;
        margin-left: 12px;
        padding-left: 12px;
        border-left: 1px solid var(--sr-border);
    }
    .ch-action-link {
        color: var(--sr-muted);
        font-size: 0.9rem;
        text-decoration: none;
        transition: color 0.2s;
        display: flex;
        align-items: center;
        gap: 5px;
    }
    .ch-action-link:hover { color: var(--sr-blue); }
    .ch-action-link i { font-size: 1rem; }
    
    .ch-support-label {
        font-size: 0.68rem;
        font-weight: 700;
        color: var(--sr-muted);
        text-transform: uppercase;
        letter-spacing: 0.03em;
        margin-bottom: 2px;
        opacity: 0.8;
    }
    .ch-actions-group {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
        margin-left: auto;
        padding-left: 12px;
        border-left: 1px solid var(--sr-border);
    }
    .ch-actions-row {
        display: flex;
        align-items: center;
        gap: 12px;
    }

    .mobile-playlist-section {
        display: none;
        margin-top: 2px;
        padding: 12px 14px 14px;
        background: var(--sr-glass);
        border: 1px solid var(--sr-border);
        border-radius: 12px;
        backdrop-filter: var(--sr-blur);
        -webkit-backdrop-filter: var(--sr-blur);
    }

    .mobile-playlist-head {
        display: flex;
        align-items: flex-end;
        justify-content: space-between;
        gap: 12px;
        margin-bottom: 10px;
    }

    .mobile-playlist-label {
        font-size: 0.72rem;
        font-weight: 800;
        text-transform: uppercase;
        letter-spacing: 0.06em;
        color: var(--sr-light);
        margin-bottom: 2px;
    }

    .mobile-playlist-sub {
        font-size: 0.78rem;
        color: var(--sr-muted);
    }

    .mobile-playlist-count {
        font-size: 0.72rem;
        font-weight: 700;
        color: var(--sr-blue);
        white-space: nowrap;
    }

    .mobile-playlist-list {
        display: flex;
        flex-direction: column;
        gap: 8px;
    }

    .mobile-playlist-item {
        display: grid;
        grid-template-columns: 96px minmax(0, 1fr);
        gap: 10px;
        align-items: center;
        padding: 8px;
        border-radius: 11px;
        border: 1px solid var(--sr-border);
        background: rgba(255,255,255,0.02);
        text-decoration: none;
        color: var(--sr-ink);
        transition: background 0.15s, border-color 0.15s, transform 0.15s;
    }

    .mobile-playlist-item:hover {
        background: var(--sr-hover);
        border-color: var(--sr-border-hover);
        transform: translateY(-1px);
    }

    .mobile-playlist-item.is-active {
        border-color: var(--sr-blue);
        background: var(--sr-blue-bg);
    }

    .mobile-playlist-item.is-done .mobile-playlist-title {
        color: var(--sr-light);
    }

    .mobile-playlist-thumb {
        position: relative;
        width: 100%;
        aspect-ratio: 16 / 9;
        border-radius: 9px;
        overflow: hidden;
        background: #0f172a;
        flex-shrink: 0;
    }

    .mobile-playlist-thumb img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        display: block;
    }

    .mobile-playlist-play {
        position: absolute;
        right: 6px;
        bottom: 6px;
        width: 22px;
        height: 22px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 0.62rem;
        color: #fff;
        background: rgba(15, 23, 42, 0.8);
        backdrop-filter: blur(8px);
    }

    .mobile-playlist-item.is-active .mobile-playlist-play {
        background: var(--sr-blue);
        color: white;
    }

    .mobile-playlist-item.is-done .mobile-playlist-play {
        background: var(--sr-green);
        color: white;
    }

    .mobile-playlist-body {
        min-width: 0;
        display: flex;
        flex-direction: column;
        gap: 3px;
    }

    .mobile-playlist-title {
        font-size: 0.84rem;
        font-weight: 700;
        line-height: 1.3;
        color: var(--sr-ink);
    }

    .mobile-playlist-meta {
        font-size: 0.72rem;
        color: var(--sr-muted);
    }

    /* Tabs */
    .resource-wrap { 
        position: relative; 
        min-height: 240px; /* Ensures guest overlay isn't cut off */
    }
    .tab-bar {
        display: flex; gap: 2px; border-bottom: 1px solid var(--sr-border);
        overflow-x: auto; white-space: nowrap;
    }
    .tab-bar::-webkit-scrollbar { display: none; }
    .tab-btn {
        background: none; border: none; padding: 10px 16px;
        font-size: 0.82rem; font-weight: 600; color: var(--sr-muted);
        cursor: pointer; border-bottom: 2px solid transparent;
        margin-bottom: -1px; transition: color 0.15s, border-bottom-color 0.15s; display: flex; align-items: center; gap: 6px;
    }
    .tab-btn.on { color: var(--sr-blue); border-bottom-color: var(--sr-blue); }
    .tab-btn:hover:not(.on) { color: var(--sr-ink); }
    .tab-pane { display: none; padding-top: 12px; }
    .tab-pane.on { display: block; }

    .res-card {
        display: flex; align-items: center; justify-content: space-between; gap: 12px;
        padding: 12px 14px; background: var(--sr-glass);
        backdrop-filter: var(--sr-blur); -webkit-backdrop-filter: var(--sr-blur);
        border-radius: 9px; border: 1px solid var(--sr-border); flex-wrap: wrap;
    }
    .res-title { font-size: 0.85rem; font-weight: 600; color: var(--sr-ink); margin-bottom: 2px; }
    .res-sub { font-size: 0.76rem; color: var(--sr-muted); }
    .res-btn {
        font-size: 0.78rem; font-weight: 600; color: var(--sr-blue);
        background: var(--sr-blue-bg); border: none; padding: 7px 14px;
        border-radius: 7px; cursor: pointer; text-decoration: none;
        display: flex; align-items: center; gap: 5px; white-space: nowrap; flex-shrink: 0;
        transition: opacity 0.15s;
    }
    .res-btn:hover { opacity: 0.85; }

    /* Guest lock */
    .guest-lock { position: relative; }

    .guest-overlay {
        position: absolute; inset: 0; z-index: 10;
        display: flex; flex-direction: column; align-items: center; justify-content: center;
        gap: 8px; text-align: center; padding: 32px 20px 20px;
        backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px);
        background: rgba(255,255,255,0.6); border-radius: inherit;
    }
    [data-theme="dark"] .guest-overlay { background: rgba(15,17,23,0.7); }
    .guest-icon {
        width: 40px; height: 40px; border-radius: 50%;
        background: var(--sr-blue-bg); color: var(--sr-blue);
        display: flex; align-items: center; justify-content: center;
        flex-shrink: 0;
    }
    .guest-icon i {
        font-size: 1rem;
        display: block;
        width: auto;
        height: auto;
    }
    .guest-title { font-size: 0.88rem; font-weight: 700; color: var(--sr-ink); }
    .guest-sub { font-size: 0.76rem; color: var(--sr-muted); }
    .guest-btn {
        margin-top: 4px; background: var(--sr-blue); color: white;
        border: none; padding: 8px 20px; border-radius: 7px;
        font-size: 0.82rem; font-weight: 700; cursor: pointer;
    }

    /* ── RIGHT PANE: AI ── */
    .pane-ai {
        width: calc(40% - 0.5px);
        flex-shrink: 0;
        background: #111111;
        backdrop-filter: var(--sr-blur);
        -webkit-backdrop-filter: var(--sr-blur);
        border-left: 1px solid var(--sr-border);
        display: flex;
        flex-direction: column;
        overflow: hidden;
        position: relative;
        box-sizing: border-box;
        z-index: 50;
    }
    
    /* Mobile backdrop */
    .room-backdrop {
        display: none;
        position: absolute; inset: 0; z-index: 49;
        background: rgba(0,0,0,0.35);
    }
    .room-backdrop.show { display: block; }

    /* ── AI COLLAPSED STATE ── 
       Width is controlled by JS inline style — collapsed just hides the body */
    .pane-ai.collapsed .ai-body,
    .pane-ai.collapsed .ai-title-text { display: none; }
    .pane-ai.collapsed .ai-head {
        flex-direction: column; padding: 12px 0; align-items: center; gap: 10px;
    }
    
    /* ── FAB MODE (Hidden AI on Desktop) ── */
    .pane-ai.fab-mode { border-left: none; overflow: hidden; }

    .ai-collapse-btn.ai-collapse-fab {
        position: fixed;
        right: 0;
        top: 50%;
        transform: translateY(-50%);
        z-index: 1000;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 0;
        width: 48px;
        min-width: 48px;
        height: 56px;
        padding: 0;
        margin: 0;
        border-radius: 14px 0 0 14px;
        background: linear-gradient(135deg, var(--primary,#4ecdc4) 0%, #38bdf8 100%);
        color: #08111a;
        border: 1px solid rgba(255, 255, 255, 0.35);
        box-shadow: 0 14px 36px rgba(0, 0, 0, 0.45), 0 0 0 1px color-mix(in srgb, var(--primary,#4ecdc4) 18%, transparent);
    }
    .ai-collapse-btn.ai-collapse-fab:hover {
        transform: translateY(-50%) translateX(-2px);
        filter: brightness(1.05);
    }
    .ai-collapse-btn.ai-collapse-fab:focus-visible {
        outline: 2px solid rgba(255, 255, 255, 0.8);
        outline-offset: 2px;
    }
    .ai-collapse-btn.ai-collapse-fab #aiCollapseGlyph {
        display: inline-block;
        font-size: 22px;
        line-height: 1;
        font-weight: 900;
        text-shadow: 0 1px 0 rgba(255, 255, 255, 0.35);
    }
    .ai-collapse-btn.ai-collapse-fab #aiCollapseIcon {
        display: none !important;
    }

    .fab-ai-desktop {
        display: none; position: fixed; bottom: 24px; right: 24px;
        width: 56px; height: 56px; border-radius: 50%;
        background: var(--sr-blue); color: white; border: none;
        font-size: 1.4rem; cursor: pointer; z-index: 90;
        align-items: center; justify-content: center;
        box-shadow: 0 8px 32px rgba(37, 99, 235, 0.3);
        transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s;
        transform: scale(0); opacity: 0;
    }
    .fab-ai-desktop.visible { display: flex; transform: scale(1); opacity: 1; }
    .fab-ai-desktop:hover { transform: scale(1.1); }



    .ai-head {
        display: flex; align-items: center; justify-content: space-between;
        padding: 0 16px; border-bottom: 1px solid var(--sr-border); flex-shrink: 0;
        min-height: 56px;
    }
    .ai-title { display: flex; align-items: center; gap: 8px; font-size: 0.82rem; font-weight: 700; color: var(--sr-ink); text-transform: uppercase; letter-spacing: 0.05em; }
    .ai-title i { color: var(--sr-blue); font-size: 0.9rem; }
    
    .close-ai-btn { display: none; background: none; border: none; cursor: pointer; color: var(--sr-muted); font-size: 1rem; }
    .close-syllabus-btn { display: none; background: none; border: none; cursor: pointer; color: var(--sr-muted); font-size: 1rem; }

    .ai-body { flex: 1; display: flex; flex-direction: column; min-height: 0; position: relative; }
    .chat-history {
        flex: 1; overflow-y: auto; padding: 14px; display: flex;
        flex-direction: column; gap: 12px; background: var(--sr-bg);
    }
    .chat-history::-webkit-scrollbar { width: 3px; }
    .chat-history::-webkit-scrollbar-thumb { background: var(--sr-border); border-radius: 2px; }
    .chat-bubble { max-width: 88%; padding: 10px 14px; border-radius: 10px; font-size: 0.84rem; line-height: 1.5; }
    .chat-ai { background: var(--sr-hover); border: 1px solid var(--sr-border); align-self: flex-start; border-bottom-left-radius: 3px; }
    .chat-user { background: var(--sr-blue); color: #000; font-weight: 600; align-self: flex-end; border-bottom-right-radius: 3px; }
    .chat-input-area { padding: 12px; border-top: 1px solid var(--sr-border); background: var(--sr-glass-heavy); backdrop-filter: var(--sr-blur); -webkit-backdrop-filter: var(--sr-blur); flex-shrink: 0; }
    .chat-input-row { display: flex; align-items: center; background: var(--sr-hover); border: 1px solid var(--sr-border); border-radius: 20px; padding: 6px 14px; gap: 8px; }
    .chat-input-row input { flex: 1; border: none; background: transparent; outline: none; font-size: 0.84rem; color: var(--sr-ink); font-family: inherit; }
    .chat-send { background: none; border: none; cursor: pointer; color: var(--sr-blue); font-size: 0.9rem; padding: 0; }
    .chat-send:disabled { opacity: 0.4; cursor: not-allowed; }

    .fab-ai {
        display: none;
        position: fixed;
        bottom: calc(20px + env(safe-area-inset-bottom, 0px));
        right: 20px;
        width: 52px;
        height: 52px;
        border-radius: 50%;
        background: var(--sr-blue);
        color: #fff;
        border: none;
        cursor: pointer;
        z-index: 1050;
        align-items: center;
        justify-content: center;
        box-shadow: 0 4px 16px color-mix(in srgb, var(--primary,#4ecdc4) 25%, transparent),
                    0 8px 32px rgba(0, 0, 0, 0.3);
        transition: transform 0.18s cubic-bezier(0.16, 1, 0.3, 1),
                    box-shadow 0.18s ease,
                    opacity 0.18s ease;
    }
    .fab-ai:hover {
        transform: scale(1.08);
        box-shadow: 0 6px 24px color-mix(in srgb, var(--primary,#4ecdc4) 35%, transparent),
                    0 12px 40px rgba(0, 0, 0, 0.35);
    }
    .fab-ai:active {
        transform: scale(0.94);
    }
    .fab-ai:focus-visible {
        outline: 2px solid var(--sr-blue);
        outline-offset: 3px;
    }
    .fab-ai {
        font-size: 14px;
        font-weight: 800;
        letter-spacing: 0.08em;
        line-height: 1;
    }

    /* ── MOBILE ── */
    @media (max-width: 1024px) {
        .main-content {
            padding-top: 0 !important;
            height: 100dvh !important;
        }
        @supports not (height: 100dvh) {
            .main-content { height: 100vh !important; }
        }
        .room-topbar { display: none !important; }
        .room-tabs-bar { display: flex; }
        .pane-syllabus { position: absolute; left: 0; top: 0; bottom: 0; transform: translateX(-100%); box-shadow: 4px 0 20px rgba(0,0,0,0.1); width: 280px; background: var(--sr-glass-heavy); backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px); }
        .pane-syllabus.show { transform: translateX(0); }
        .close-syllabus-btn { display: block; }
        .sb-head-btn { display: none !important; }
        .room-topbar-center { display: none; }

        /* ── MOBILE HEADER REORG ── */
        .room-topbar {
            padding: 0 0;
            height: 56px;
            position: relative;
            grid-template-columns: 1fr;
        }
        .room-topbar-left {
            display: contents;
        }
        .room-logo {
            position: absolute;
            left: 50%;
            top: 50%;
            transform: translate(-50%, -50%);
        }
        .room-logo .logo-text { font-size: 0.9rem; }
        .room-tb-btn--left {
            position: absolute !important;
            left: 8px;
            top: 50%;
            transform: translateY(-50%);
        }
        #sylHeaderBtn { display: none !important; }
        .sb-tools-panel { display: block; }
        .pane-syllabus .room-tabs-container { display: none !important; }
        .pane-syllabus .sb-scroll { display: none !important; }

        /* Variant A capsule rules live in the canonical base block. No mobile
           overrides needed for the bar itself at this breakpoint. */
        .room-wrap {
            top: 104px !important;
        }
        .pane-main {
            padding-top: calc(var(--sr-topbar-h, 52px) + var(--sr-tabs-h, 52px) + 8px);
        }
    }

    /* Fill-In loader (Generating …) */
    #fiLoading { display: none; }
    .fi-loader { display: flex; align-items: center; gap: 10px; }
    .fi-loader > div { font-size: 0.92rem; color: var(--sr-muted); }
    .fi-dots { display: inline-flex; align-items: center; gap: 6px; }
    .fi-dots span { width: 8px; height: 8px; border-radius: 999px; background: var(--sr-light); opacity: 0.25; transform: translateY(0); animation: fi-dot 1s infinite ease-in-out; }
    .fi-dots span:nth-child(1) { animation-delay: 0s; }
    .fi-dots span:nth-child(2) { animation-delay: 0.12s; }
    .fi-dots span:nth-child(3) { animation-delay: 0.24s; }

    @keyframes fi-dot {
        0% { opacity: 0.25; transform: translateY(0); }
        50% { opacity: 1; transform: translateY(-6px); }
        100% { opacity: 0.25; transform: translateY(0); }
    }

    @media (min-width: 1025px) {
        .room-tb-btn--left { display: none !important; }
        .room-topbar {
            padding: 0 16px;
        }
        .sb-tools-panel {
            display: none;
        }
    }
    @media (max-width: 860px) {
        .pane-ai {
            position: fixed;
            top: 0 !important;
            left: 0;
            right: 0;
            bottom: 0;
            width: 100% !important;
            transform: translateY(100%);
            transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1);
            background: var(--bg-page);
            backdrop-filter: none;
            -webkit-backdrop-filter: none;
            z-index: 200;
            box-shadow: none;
            display: flex;
            flex-direction: column;
        }
        .pane-ai.show {
            transform: translateY(0);
        }
        .pane-ai.ai-collapsed {
            width: 100% !important;
            border-left: none;
        }
        .close-ai-btn { display: block !important; }
        .ai-toggle { display: none; }
        .fab-ai { display: flex; }
        #srAiToggleBtn { display: none !important; }
        #aiToggleTab { display: none; }
        .room-vp { overflow-y: auto; }
        .video-wrap { border-radius: 0; aspect-ratio: 4/3; }
        .panel-inner { padding: 8px 8px 40px; max-width: none; }
        #tab-video .panel-inner { max-width: none; }
        .mobile-playlist-section { display: block; }
        .aura-badge { display: none !important; }

        /* Reference-attachment Content tab is desktop-only — mobile always
           shows Chat full-screen, no tab switcher. */
        .ai-sidebar-header { display: none; }

        .ai-mobile-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 12px 16px;
            padding-top: calc(12px + env(safe-area-inset-top, 0px));
            border-bottom: 1px solid var(--sr-border);
            flex-shrink: 0;
            background: var(--bg-page);
        }
        .ai-mobile-back {
            width: 36px;
            height: 36px;
            display: flex;
            align-items: center;
            justify-content: center;
            background: var(--bg-hover);
            border: none;
            border-radius: 10px;
            cursor: pointer;
            color: var(--text-primary);
    flex-shrink: 0;
}

        .ai-mobile-title {
            font-size: 15px;
            font-weight: 700;
            color: var(--text-primary);
            letter-spacing: -0.01em;
        }
        .ai-mobile-logo {
            width: 96px;
            height: auto;
            object-fit: contain;
            display: block;
        }
        html[data-theme="dark"] .ai-mobile-logo {
            content: url('../../../images/new-logo-dark.png');
        }
    }

    /* ── ≤860px: make tab bar fixed, push shell below both top bars ── */
    @media (max-width: 860px) {
        .sr-topbar {
            display: flex !important;
            position: fixed;
            top: 0;
            left: 0 !important;
            right: 0;
            z-index: 100;
            height: 52px;
            min-height: 52px;
        }
        /* Variant A capsule rules live in the canonical base block. */
        .room-wrap {
            top: 104px !important;
        }
        .pane-main {
            padding-top: calc(var(--sr-topbar-h, 52px) + var(--sr-tabs-h, 52px) + 8px);
        }
    }

    @media (min-width: 861px) {
        .ai-mobile-header {
            display: none;
        }
    }

    @media (max-width: 768px) {
        /* Variant A capsule rules live in the canonical base block. */
    }

    @media (max-width: 600px) {
        .mobile-playlist-item {
            grid-template-columns: 88px minmax(0, 1fr);
        }

        .mobile-playlist-title {
            font-size: 0.8rem;
        }

        .mobile-playlist-meta {
            font-size: 0.68rem;
        }
    }
    @media (max-width: 600px) {
        .paste-wrap input::placeholder { font-size: 0.72rem; }
        .tb-btn span { display: none; }
        .tb-btn { padding: 5px 8px; }
    }

    @keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
    @keyframes slideUp { from { opacity: 0; transform: translateX(-50%) translateY(16px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }

/* ── SYLLABUS CHECKPOINT ITEMS ── */
.sb-checkpoint {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    margin: 3px 6px;
    border-radius: 8px;
    border: 1px dashed var(--sr-border);
    background: transparent;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s, border-color 0.15s;
    min-width: 0; /* Allow checkpoint rows to shrink so their text can truncate. */
}
.sb-checkpoint:hover { background: rgba(255, 255, 255, 0.08); border-color: var(--sr-blue); }
.sb-checkpoint.cp-done {
    border-style: solid;
    border-color: var(--sr-green);
    background: rgba(34,197,94,0.05);
}
.sb-checkpoint.cp-locked {
    opacity: 0.5;
    cursor: default;
    pointer-events: none;
}
.sb-checkpoint.cp-generating {
    border-color: var(--sr-gold);
    opacity: 0.75;
}
.sb-cp-icon {
    width: 28px; height: 28px; border-radius: 7px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.8rem;
}
.sb-cp-icon--flashcards { background: rgba(124,106,247,0.15); color: #b5acff; }
.sb-cp-icon--micro_quiz { background: rgba(245,158,11,0.15); color: #f59e0b; }
.sb-cp-icon--notes      { background: rgba(59,130,246,0.15); color: #60a5fa; }
.sb-cp-icon--cheatsheet { background: rgba(16,185,129,0.15); color: #34d399; }
.sb-cp-icon--boss_quiz  { background: rgba(239,68,68,0.15);  color: #f87171; }
.sb-cp-body { flex: 1; min-width: 0; }
.sb-cp-name {
    display: block; /* Keeps the checkpoint title on a single, truncatable line. */
    width: 100%;
    min-width: 0;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--sr-ink);
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sb-cp-meta { font-size: 0.72rem; color: var(--sr-muted); margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-cp-badge {
    font-size: 0.65rem; font-weight: 700; padding: 2px 6px;
    border-radius: 99px; flex-shrink: 0;
    background: rgba(124,106,247,0.15); color: #b5acff;
    letter-spacing: 0.04em; text-transform: uppercase;
}
.sb-cp-badge--premium { background: rgba(245,158,11,0.15); color: #f59e0b; }
.sb-cp-badge--done    { background: rgba(34,197,94,0.15);  color: #4ade80; }

/* ── TAB INDICATORS (spinner / dot / fail) ── */
.tab-generating .room-tab-label::after {
    content: '';
    display: inline-block;
    width: 8px; height: 8px;
    border: 1.5px solid color-mix(in srgb, var(--primary,#4ecdc4) 30%, transparent);
    border-top-color: var(--sr-blue);
    border-radius: 50%;
    margin-left: 6px;
    animation: tab-spin 0.8s linear infinite;
    vertical-align: middle;
}
.tab-ready .room-tab-label::after {
    content: '';
    display: inline-block;
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--sr-blue);
    margin-left: 6px;
    vertical-align: middle;
}
.tab-failed .room-tab-label::after {
    content: '!';
    font-size: 10px;
    color: var(--sr-red);
    margin-left: 4px;
    vertical-align: middle;
}
@keyframes tab-spin {
    to { transform: rotate(360deg); }
}

/* ── FLASHCARD PLAYER ────────────────────────────────────────────────────── */
.fc-shell {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 0;
    padding: 16px 0 16px;
}

.fc-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 100%;
    gap: 20px;
}

@media (max-width: 860px) {
    .fc-content {
        justify-content: flex-start;
        padding-top: 16px;
    }
}

/* When empty state is visible, hide nav and compensate so centered
   empty state sits at the same height as the flashcard tab */
.fc-content:has(.fc-empty[style*="flex"]) {
    padding-bottom: 56px !important;
}

/* ── Round-complete summary overlay (replaces the per-item floating Aura popup) ──
   Positioned absolute against `.fc-shell` (already `position:absolute; inset:0`),
   so it layers on top of the stage/nav/counter instead of swapping into the flow. */
.fc-round-summary {
    position: absolute;
    inset: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: color-mix(in srgb, var(--bg-page) 96%, transparent);
    animation: fcSummaryBackdropIn 200ms ease both;
}
.fc-round-summary__card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    width: 100%;
    max-width: 360px;
    padding: 2rem;
    border-radius: 20px;
    background: var(--bg-card);
    border: 1px solid var(--sr-border);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.30), 0 20px 40px rgba(0, 0, 0, 0.55);
    animation: fcSummaryCardIn 200ms cubic-bezier(0.23, 1, 0.32, 1) both;
}
.fc-round-summary__title {
    font-family: var(--font-display);
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
}
.fc-round-summary__stat-line {
    margin-top: 6px;
    font-size: 0.82rem;
    color: var(--text-secondary);
}
.fc-round-summary__stat-line .fc-round-summary__aura-amount {
    display: inline;
    font-family: inherit;
    font-size: inherit;
    font-weight: 600;
    color: inherit;
}
.fc-round-summary__actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    width: 100%;
}
.fc-round-summary__actions .gen-confirm-btn {
    flex: 1;
    justify-content: center;
    margin-top: 0;
}
.fc-round-summary__actions .gen-confirm-btn--secondary {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--sr-border);
}
.fc-round-summary__actions .gen-confirm-btn--secondary:hover {
    background: var(--bg-surface);
    color: var(--text-primary);
}
.fc-round-summary__score {
    margin-top: 12px;
    text-align: center;
}
.fc-round-summary__score-value {
    display: block;
    font-family: var(--font-display);
    font-size: 2.25rem;
    font-weight: 700;
    color: var(--primary);
    line-height: 1.15;
}
.fc-round-summary__score-value[data-grade="A"] { color: var(--sr-green); }
.fc-round-summary__score-value[data-grade="B"] { color: var(--primary); }
.fc-round-summary__score-value[data-grade="C"] { color: var(--sr-gold); }
.fc-round-summary__score-value[data-grade="D"] { color: var(--text-secondary); }
.fc-round-summary__score-value[data-grade="F"] { color: var(--sr-red); }
.fc-round-summary__score-label {
    display: block;
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

@keyframes fcSummaryBackdropIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}
@keyframes fcSummaryCardIn {
    from { opacity: 0; transform: scale(0.96); }
    to   { opacity: 1; transform: scale(1); }
}

/* Fill-in shell: scrollable, match flashcard/quiz shell positioning */
#tab-more .fc-shell {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    justify-content: flex-start;
    align-items: center;
}

.fc-counter {
    font-size: 0.78rem;
    color: #555555;
    font-weight: 600;
    letter-spacing: 0.04em;
}

/* ── Card stage (flip container) ── */
.fc-stage {
    width: 100%;
    max-width: 760px;
    height: 270px;
    position: relative;
    cursor: pointer;
    perspective: 1200px;
}

/* Both faces share absolute positioning */
.fc-face {
    position: absolute;
    inset: 0;
    background: #1e1e1e;
    border: 1px solid #2c2c2c;
    border-radius: 24px;
    padding: 32px;
    display: flex;
    max-width: 550px; 
    margin: 0 auto;
    flex-direction: column;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                opacity   0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.fc-face-inner {
    display: flex;
    flex-direction: column;
    flex: 1;
    gap: 12px;
}

/* Front — question side */
.fc-face--front { transform: rotateY(0deg); opacity: 1; }
.fc-face--front.flipped { transform: rotateY(180deg); opacity: 0; pointer-events: none; }

/* Back — answer side */
.fc-face--back { transform: rotateY(-180deg); opacity: 0; pointer-events: none; }
.fc-face--back.flipped { transform: rotateY(0deg); opacity: 1; pointer-events: auto; }

/* ── Flashcard slide-in + fade-in on navigation ── */
@keyframes fc-enter-right {
    0%   { opacity: 0; transform: translateX(36px) rotateY(0deg); }
    100% { opacity: 1; transform: translateX(0) rotateY(0deg); }
}
@keyframes fc-enter-left {
    0%   { opacity: 0; transform: translateX(-36px) rotateY(0deg); }
    100% { opacity: 1; transform: translateX(0) rotateY(0deg); }
}
.fc-anim-enter-right {
    animation: fc-enter-right 0.3s ease-out 0.04s backwards;
}
.fc-anim-enter-left {
    animation: fc-enter-left 0.3s ease-out 0.04s backwards;
}

.fc-icon {
    color: #444444;
    flex-shrink: 0;
}

.fc-question {
    font-size: 1.15rem;
    font-weight: 600;
    color: #f5f5f5;
    line-height: 1.5;
    flex: 1;
}

.fc-hint {
    font-size: 0.75rem;
    color: #444444;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: auto;
    flex-shrink: 0;
}
.fc-hint kbd {
    background: #2a2a2a;
    border: 1px solid #3a3a3a;
    border-radius: 5px;
    padding: 1px 7px;
    font-size: 0.7rem;
    color: #666666;
    font-family: monospace;
}

.fc-answer {
    font-size: 1rem;
    color: #e2e2e2;
    line-height: 1.7;
    flex: 1;
    overflow-y: auto;
    scrollbar-width: none;
}

.fc-btn-row {
    display: flex;
    gap: 10px;
    width: 80%;
    margin: 0 auto;
}
.fc-action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex: 1;
    padding: 12px 16px;
    border-radius: 14px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s;
}
.fc-got-it-btn {
    border: 1px solid rgba(34, 197, 94, 0.3);
    background: rgba(34, 197, 94, 0.12);
    color: #4ade80;
}
.fc-got-it-btn:hover { background: rgba(34,197,94,0.2); }
.fc-got-it-btn kbd {
    background: rgba(34,197,94,0.15);
    border: 1px solid rgba(34,197,94,0.25);
    border-radius: 5px;
    padding: 1px 7px;
    font-size: 0.72rem;
    font-family: monospace;
    color: #4ade80;
}
.fc-dont-know-btn {
    border: 1px solid rgba(239, 68, 68, 0.3);
    background: rgba(239, 68, 68, 0.12);
    color: #f87171;
}
.fc-dont-know-btn:hover { background: rgba(239,68,68,0.2); }
.fc-dont-know-btn kbd {
    background: rgba(239,68,68,0.15);
    border: 1px solid rgba(239,68,68,0.25);
    border-radius: 5px;
    padding: 1px 7px;
    font-size: 0.72rem;
    font-family: monospace;
    color: #f87171;
}

/* ── Nav bar (bottom bar with prev/next and counter) ── */
.fc-nav-bar {
  flex-shrink: 0;
  padding: 0 16px;
  height: 56px;
  width: 100%;
  border-top: 1px solid var(--border);
  background: var(--bg-page);
}

.fc-nav-bar-inner {
  width: 100%;
  height: 100%;
}

.fc-nav-bar-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
}

.fc-nav-bar-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bg-hover);
  color: var(--text-muted);
  border: none;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.fc-nav-bar-btn:hover {
  background: var(--bg-card);
  color: var(--text-primary);
}

.fc-nav-bar-btn:disabled {
  opacity: 0.25;
  cursor: not-allowed;
}

.fc-nav-bar-btn svg {
  width: 20px;
  height: 20px;
  transition: transform 0.3s;
}

.fc-nav-bar-btn:not(:disabled):hover svg:first-child {
  transform: translateX(-3px);
}

.fc-nav-bar-btn:last-child:not(:disabled):hover svg {
  transform: translateX(3px);
}

.fc-nav-bar-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  position: relative;
}

.fc-nav-bar-center-row {
  display: flex;
  align-items: center;
  gap: 16px;
}

.fc-nav-bar-counter {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
}

.fc-nav-bar-counter .fc-counter {
  font-size: inherit;
  font-weight: inherit;
  color: inherit;
  letter-spacing: normal;
}

/* Active state (quiz: next button lights up after answering) */
.fc-nav-bar-btn.fc-nav-btn--active {
  background: var(--primary);
  color: #fff;
}

#fcMoreBtn,
#qzMoreBtn,
#fiMoreBtn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  padding: 0;
  flex-shrink: 0;
}
#fcMoreBtn:hover,
#qzMoreBtn:hover,
#fiMoreBtn:hover {
  color: var(--text-primary);
  border-color: var(--text-secondary);
  background: var(--bg-hover);
}
#fcMoreBtn:disabled,
#qzMoreBtn:disabled,
#fiMoreBtn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

#fcMoreBtn svg,
#qzMoreBtn svg,
#fiMoreBtn svg {
  display: block;
}

/* Loading spinner — replaces icon with a border-spin ring */
@keyframes sr-more-spin {
  to { transform: rotate(360deg); }
}
#fcMoreBtn.sr-more-loading,
#qzMoreBtn.sr-more-loading,
#fiMoreBtn.sr-more-loading {
  animation: sr-more-spin 0.65s linear infinite;
  border-color: rgba(255, 255, 255, 0.08);
  border-top-color: var(--primary, #4ecdc4);
  opacity: 1 !important;
  cursor: wait;
}
#fcMoreBtn.sr-more-loading svg,
#qzMoreBtn.sr-more-loading svg,
#fiMoreBtn.sr-more-loading svg {
  opacity: 0;
}

/* Status pill floats above the nav bar, not inside it */
.fc-nav-more-status {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  background: var(--bg-card, rgba(22, 22, 30, 0.94));
  border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.1));
  border-radius: 20px;
  padding: 3px 10px;
  font-size: 0.7rem;
  color: var(--text-muted);
  line-height: 1.4;
  pointer-events: none;
  z-index: 20;
  opacity: 0;
  transition: opacity 0.18s;
}
.fc-nav-more-status:not(:empty) {
  opacity: 1;
}

/* ── FILL IN ── */
.fill-sentence {
    font-size: 15px;
    line-height: 2;
    color: var(--sr-ink);
}
.fill-input {
    border: none;
    border-bottom: 2px solid var(--sr-blue);
    background: transparent;
    color: var(--sr-blue);
    font-size: 15px;
    width: 140px;
    outline: none;
    text-align: center;
    font-family: inherit;
}
.fill-input.correct {
    border-bottom-color: var(--sr-green);
    color: var(--sr-green);
}
.fill-input.wrong {
    border-bottom-color: var(--sr-red);
    color: var(--sr-red);
}
.fill-hint-link:hover {
    color: var(--sr-blue) !important;
    text-decoration: underline !important;
}

/* ── QUIZ MINI SHELL ── */
.qz-mini-shell { display:flex; flex-direction:column; height:100%; overflow:hidden; }
.qz-card-mini {
    background:var(--sr-surface); border:1px solid var(--sr-border); border-radius:14px; overflow:hidden;
}
.qz-card-stripe-mini { height:3px; background:linear-gradient(90deg,#8b5cf6,#06b6d4); }
.qz-card-body-mini   { padding:1.125rem 1.25rem 1.25rem; }
.qz-q-text-mini      { font-size:0.93rem; line-height:1.6; color:var(--sr-ink); margin-bottom:1rem; }
.qz-opt-text { flex:1; }
.qz-question { font-size:1.15rem; font-weight:600; color:#f5f5f5; line-height:1.5; flex:1; margin-bottom:16px; }
.qz-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}
.qz-opt-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: #1a1a1a;
  border: 1.5px solid #2e2e2e;
  border-radius: 12px;
  padding: 14px 16px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
  color: #f0f0f0;
  font-size: 0.92rem;
  line-height: 1.5;
}
.qz-opt-card:hover:not(.correct):not(.wrong) {
  border-color: #444;
  background: #222;
  transform: translateY(-1px);
}
.qz-opt-badge {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: var(--sr-blue);
  color: #fff;
  font-weight: 700;
  font-size: 0.82rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
.qz-opt-card.selected {
  border-color: var(--primary,#4ecdc4);
  background: #0f2e2c;
}
.qz-opt-card.selected .qz-opt-badge {
  background: var(--primary,#4ecdc4);
  color: #fff;
}
.qz-opt-card.correct {
  border-color: #4caf50;
  background: #0d2b0f;
  cursor: default;
}
.qz-opt-card.correct .qz-opt-badge {
  background: #4caf50;
  color: #fff;
}
.qz-opt-card.wrong {
  border-color: #e53935;
  background: #2b0d0d;
  cursor: default;
}
.qz-opt-card.wrong .qz-opt-badge {
  background: #e53935;
  color: #fff;
}
.qz-fb-mini { display:none; margin-top:0.75rem; padding:0.625rem 0.875rem; border-radius:8px; font-size:0.82rem; line-height:1.5; }
.qz-fb-mini.-show  { display:block; }
.qz-fb-mini.-ok    { background:rgba(16,185,129,0.10); color:var(--sr-green); border:1px solid rgba(16,185,129,0.2); }
.qz-fb-mini.-err   { background:rgba(239,68,68,0.10); color:var(--sr-red); border:1px solid rgba(239,68,68,0.2); }

@media (max-width: 768px) {
    .qz-options {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .qz-opt-card {
        width: 100%;
        padding: 14px 16px;
    }

    .qz-opt-badge {
        width: 30px;
        height: 30px;
    }
}

/* ── Quiz scrollable shell ── */
.qz-scroll-shell {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 0;
  padding: 0 20px;
  overflow-y: auto;
}

@media (min-width: 1400px) {
  .qz-scroll-shell {
      padding: 0px 50px;

  }
}

@media (max-width: 768px) {
  .qz-scroll-shell {
      padding: 0px;
  }
}

.qz-scroll-inner {
  width: 100%;
  max-width: 740px;
  margin: 0 auto;
  flex-shrink: 0;
  container-type: inline-size;
}

.qz-answer-row {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--sr-green, #10b981);
  padding: 8px 0 4px;
  line-height: 1.5;
}

.qz-explanation-row {
  font-size: 0.88rem;
  color: var(--text-secondary, rgba(240,237,232,0.55));
  padding: 4px 0 12px;
  line-height: 1.65;
}

[data-theme="light"] .qz-answer-row {
  color: var(--sr-green, #16a34a);
}

[data-theme="light"] .qz-explanation-row {
  color: var(--text-secondary, rgba(28,25,23,0.55));
}

/* ── Quiz navigation animations (horizontal slide) ── */
@keyframes qz-exit-left {
  0%   { opacity: 1; transform: translateX(0); }
  100% { opacity: 0; transform: translateX(-36px); }
}
@keyframes qz-exit-right {
  0%   { opacity: 1; transform: translateX(0); }
  100% { opacity: 0; transform: translateX(36px); }
}
@keyframes qz-enter-left {
  0%   { opacity: 0; transform: translateX(36px); }
  100% { opacity: 1; transform: translateX(0); }
}
@keyframes qz-enter-right {
  0%   { opacity: 0; transform: translateX(-36px); }
  100% { opacity: 1; transform: translateX(0); }
}
.qz-anim-exit-left   { animation: qz-exit-left   200ms ease-in forwards; will-change: transform, opacity; }
.qz-anim-exit-right  { animation: qz-exit-right  200ms ease-in forwards; will-change: transform, opacity; }
.qz-anim-enter-left  { animation: qz-enter-left  250ms ease-out forwards; will-change: transform, opacity; }
.qz-anim-enter-right { animation: qz-enter-right 250ms ease-out forwards; will-change: transform, opacity; }

/* ── Quiz "Press Enter to continue" hint ── */
.qz-enter-hint {
  flex-shrink: 0;
  padding: 4px 16px 12px;
  width: 100%;
  text-align: center;
  font-family: var(--font-body);
  font-size: 0.8rem;
  color: var(--text-primary);
  opacity: 0.35;
  pointer-events: none;
}
.qz-enter-hint kbd {
  font-family: inherit;
  padding: 2px 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.75em;
}
.qz-enter-hint.active {
  color: var(--text-primary);
  opacity: 1;
}

.qz-scroll-shell::-webkit-scrollbar { width: 4px; }
.qz-scroll-shell::-webkit-scrollbar-thumb {
  background: var(--sr-border);
  border-radius: 4px;
}

/* Quiz tab: unclip overflow chain so translateX slide animation is not clipped */
#tab-quiz .qz-scroll-shell {
    overflow: visible;
}

/* Hide scrollbar in quiz tab (scrollbar-width preserves overflow for scrollTop) */
#tab-quiz.room-vp {
    scrollbar-width: none;
}
#tab-quiz.room-vp::-webkit-scrollbar {
    display: none;
}

/* On mobile, restore scroll and let the nav bar sit at the bottom fixed */
@media (max-width: 768px) {
    #tab-quiz.room-vp {
        overflow-y: auto;
    }
    #tab-quiz .qz-scroll-shell {
        overflow-y: auto;
    }
    #tab-quiz .fc-nav-bar,
    #tab-flashcards .fc-nav-bar,
    #tab-more .fc-nav-bar {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 10;
        background: var(--bg-page);
        border-top: 1px solid var(--border);
    }
    #fiEnterHintOutside {
        display: none;
    }
    /* prevent outer containers from clipping the fixed nav */
    body:has(#tab-quiz.room-vp--active) .room-viewports,
    body:has(#tab-flashcards.room-vp--active) .room-viewports,
    body:has(#tab-more.room-vp--active) .room-viewports {
        overflow: visible;
    }
}

/* ── Shared mini buttons (fill-in + quiz) ── */
.fi-btn {
    display:inline-flex; align-items:center; gap:6px;
    padding:0.5rem 0.9rem; border-radius:9px; font-size:0.82rem;
    font-weight:700; font-family:inherit; cursor:pointer; transition: background 0.15s, color 0.15s, filter 0.15s, opacity 0.15s; border:none;
}
.fi-btn-p { background:var(--sr-blue); color:var(--sr-ink); }
.fi-btn-p:hover { filter:brightness(1.1); }
.fi-btn-v { background:#7c3aed; color:#fff; }
.fi-btn-v:hover { background:#6d28d9; }
.fi-btn-s { background:var(--sr-hover); border:1px solid var(--sr-border); color:var(--sr-muted); }
.fi-btn-s:hover { background:var(--sr-hover); color:var(--sr-ink); }
.fi-btn:disabled { opacity:0.4; cursor:not-allowed; }

/* ── Chat tool cards ── */
.chat-tool-card {
    background:var(--sr-surface); border:1px solid var(--sr-border); border-radius:12px;
    overflow:hidden; margin:4px 0;
}
.chat-tool-card-header {
    padding:0.65rem 1rem; background:var(--sr-hover);
    border-bottom:1px solid var(--sr-border);
    font-weight:700; color:var(--sr-muted); font-size:0.74rem;
    letter-spacing:0.05em; text-transform:uppercase; display:flex; align-items:center; gap:6px;
}
.chat-tool-card-section { padding:0.875rem 1rem 1rem; border-bottom:1px solid var(--sr-border); }

/* ── Thinking dots ── */
.fi-thinking-dots { display:flex; gap:6px; justify-content:center; }
.fi-thinking-dots span {
    width:8px; height:8px; border-radius:50%; background:#8b5cf6;
    animation:fiDotBounce 1.2s infinite;
}
.fi-thinking-dots span:nth-child(2) { animation-delay:0.2s; }
.fi-thinking-dots span:nth-child(3) { animation-delay:0.4s; }
@keyframes fiDotBounce { 0%,80%,100%{transform:scale(1);opacity:0.4} 40%{transform:scale(1.3);opacity:1} }

/* ── NOTES EDITOR ── */
.notes-shell {
    display: flex; flex-direction: column; height: 100%;
}
.notes-save-bar {
    display: flex; justify-content: flex-end;
    padding: 4px 20px; flex-shrink: 0;
}
.notes-save-status {
    font-size: 0.72rem; color: var(--sr-muted); min-width: 48px;
    text-align: right;
}
.tiptap-toolbar {
    position: relative; display: flex; align-items: center; justify-content: center;
    width: 100%; padding: 18px 24px; flex-shrink: 0; margin: 0 auto; max-width: 970px;
}
.tiptap-toolbar > .group {
    position: sticky; top: 0; z-index: 20;
    display: inline-flex; max-width: 100%; align-items: center; overflow: hidden;
    border-radius: 0.5rem; border: 1px solid var(--border);
    background: var(--bg-card); backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.tiptap-toolbar .scrollbar-hide {
    display: inline-flex; width: 100%; flex-wrap: nowrap; align-items: center;
    gap: 0.25rem; overflow-x: auto; padding: 2px 8px;
    scrollbar-width: none; -ms-overflow-style: none;
}
.tiptap-toolbar .scrollbar-hide::-webkit-scrollbar { display: none; }
.tiptap-toolbar .scrollbar-hide > * { flex-shrink: 0; }
.tiptap-toolbar button {
    display: flex;
    width: 2.5rem;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0.5rem;
    border: none;
    border-radius: 0.25rem;
    background: transparent;
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.12s, color 0.12s, transform 0.12s;
    font-family: inherit;
    white-space: nowrap;
    flex-shrink: 0;
    line-height: 1.5;
}
.tiptap-toolbar button:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}
.tiptap-toolbar button:active {
    transform: scale(0.96);
}
.tiptap-toolbar .h-6.w-px.bg-gray-700 {
    width: 1px; height: 1.5rem; background: var(--border);
    flex-shrink: 0;
}
.tiptap-toolbar > button[aria-label="Scroll right"] {
    position: absolute; right: 0; top: 0; z-index: 10; display: flex;
    height: 100%; width: 3rem; align-items: center; justify-content: flex-end;
    padding-right: 0.5rem; border: 0; border-radius: 0 0.5rem 0.5rem 0;
    color: var(--text-muted); opacity: 1;
    background: linear-gradient(to left, var(--bg-card) 40%, transparent);
}
.tiptap-divider {
    width: 1px; height: 20px;
    background: rgba(255,255,255,0.1);
    margin: 0 4px; flex-shrink: 0;
}
.notes-editor-wrap {
    flex: 1; overflow: hidden;
    display: flex; flex-direction: column;
}
.notes-search-bar {
    display: none;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: color-mix(in srgb, var(--bg-card) 95%, transparent);
    border-bottom: 1px solid rgba(255,255,255,0.08);
    position: sticky;
    top: 0;
    z-index: 10;
}
.notes-search-bar.open { display: flex; }
.notes-search-input {
    flex: 1;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 6px;
    padding: 5px 10px;
    color: var(--sr-ink, #e2e2e2);
    font-size: 0.85rem;
    outline: none;
    max-width: 260px;
}
.notes-search-input:focus { border-color: var(--sr-blue, #5b4cdb); }
.notes-search-count {
    font-size: 0.78rem;
    color: rgba(255,255,255,0.45);
    min-width: 60px;
    text-align: center;
    white-space: nowrap;
}
.notes-search-btn {
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 4px;
    color: rgba(255,255,255,0.7);
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.85rem;
    line-height: 1;
    padding: 0;
}
.notes-search-btn:hover { background: rgba(255,255,255,0.12); color: #fff; }
.notes-search-close { font-size: 1rem; }
.notes-search-match { background: rgba(255, 200, 0, 0.3); border-radius: 2px; }
.notes-search-match.active { background: rgba(255, 140, 0, 0.55); }
[data-theme="light"] .notes-search-bar { background: rgba(255,255,255,0.95); border-bottom-color: rgba(0,0,0,0.08); }
[data-theme="light"] .notes-search-input { background: rgba(0,0,0,0.04); border-color: rgba(0,0,0,0.15); color: #1a1a1a; }
[data-theme="light"] .notes-search-count { color: rgba(0,0,0,0.4); }
[data-theme="light"] .notes-search-btn { background: rgba(0,0,0,0.04); border-color: rgba(0,0,0,0.12); color: rgba(0,0,0,0.6); }
[data-theme="light"] .notes-search-btn:hover { background: rgba(0,0,0,0.08); color: #000; }
[data-theme="light"] .notes-search-match { background: rgba(255, 200, 0, 0.35); }
[data-theme="light"] .notes-search-match.active { background: rgba(255, 140, 0, 0.5); }
.notes-word-count {
    padding: 4px 25px;
    font-size: 0.72rem;
    color: rgba(255,255,255,0.3);
    text-align: right;
    user-select: none;
    min-height: 22px;
}
[data-theme="light"] .notes-word-count { color: rgba(0,0,0,0.3); }
/* #tab-notes.room-vp .notes-editor-wrap {
    padding: 16px 0;
} */
.notes-prosemirror {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
    outline: none;
    font-size: 1.0625rem;
    line-height: 1.75;
    font-family: sans-serif;
    color: var(--sr-ink);
    caret-color: var(--sr-blue);
    padding: 0px 25px 80px;
    margin: 0 auto;
    max-width: 910px;
    width: 100%;
    box-sizing: border-box;
}
.notes-prosemirror,
.notes-prosemirror * {
    user-select: text;
    -webkit-user-select: text;
}
.notes-prosemirror mjx-container.mjx-in-sel,
#chatThread mjx-container.mjx-in-sel {
    background: color-mix(in srgb, var(--primary) 28%, transparent) !important;
    border-radius: 2px;
}
/* MathJax CHTML: fully text-like selection in both chat and notes.
   - user-select: text on the container AND every descendant (mjx-math, mjx-mi, mjx-mo…
     all get user-select:none from MathJax's own stylesheet — must override each).
   - display:inline-block overrides the block MathJax assigns to $$...$$ math so
     formulas flow with prose instead of breaking to their own line.
   - The inner *::selection suppresses the browser's own patchy glyph-level highlight
     so only our mjx-in-sel container background is visible. */
#chatThread mjx-container,
#chatThread mjx-container *,
.notes-prosemirror mjx-container,
.notes-prosemirror mjx-container * {
    user-select: text !important;
    -webkit-user-select: text !important;
}
#chatThread mjx-container,
.notes-prosemirror mjx-container {
    display: inline-block !important;
    vertical-align: middle;
}
.notes-prosemirror mjx-container *::selection,
#chatThread mjx-container *::selection {
    background: transparent;
    color: inherit;
}
.notes-prosemirror:empty::before {
    content: attr(data-placeholder);
    color: var(--text-muted);
    pointer-events: none;
}
.notes-prosemirror h1,
.notes-prosemirror h2,
.notes-prosemirror h3,
.notes-prosemirror h4 {
    font-family: 'Inter', 'DM Sans', system-ui, -apple-system, sans-serif;
    letter-spacing: -0.02em;
}
.notes-prosemirror h1 {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.2;
    margin: 28px 0 10px;
    color: var(--text-primary);
}
.notes-prosemirror h2 {
    font-size: 1.45rem;
    font-weight: 700;
    line-height: 1.3;
    margin: 28px 0 10px;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}
.notes-prosemirror h3 {
    font-size: 1.2rem;
    font-weight: 600;
    line-height: 1.35;
    margin: 18px 0 6px;
    color: var(--text-secondary);
    letter-spacing: 0;
    padding-left: 4px;
}
.notes-prosemirror h4 {
    font-size: 1rem;
    font-weight: 600;
    margin: 14px 0 4px;
    color: var(--text-secondary);
    letter-spacing: 0;
}
.notes-prosemirror p {
    font-size: 1.0625rem;
    margin: 0 0 14px;
}
@media (max-width: 767px) {
    .notes-prosemirror {
        font-size: 1rem;
        line-height: 1.7;
        padding: 0 16px 80px;
    }
    .notes-prosemirror p {
        font-size: 1rem;
    }
    .notes-prosemirror h1 { font-size: 1.45rem; }
    .notes-prosemirror h2 { font-size: 1.25rem; }
    .notes-prosemirror h3 { font-size: 1.07rem; }
    .notes-prosemirror h4 { font-size: 0.95rem; }
}
.notes-prosemirror ul, .notes-prosemirror ol {
    padding-left: 1.6rem; margin: 6px 0 14px;
}
.notes-prosemirror li {
    margin-bottom: 6px;
    line-height: 1.7;
}
.notes-prosemirror li::marker {
    color: var(--sr-blue);
}
.notes-prosemirror blockquote {
    background: rgba(99, 102, 241, 0.07);
    border-left: 4px solid var(--sr-blue, #6366f1);
    border-radius: 0 8px 8px 0;
    padding: 12px 16px;
    margin: 16px 0;
    color: var(--text-primary);
    font-style: normal;
}
.notes-prosemirror blockquote strong {
    display: block;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--sr-blue, #6366f1);
    margin-bottom: 4px;
}
.notes-prosemirror hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 28px 0;
}
.notes-prosemirror strong { color: var(--text-primary); font-weight: 700; }
.notes-prosemirror em { color: var(--text-secondary); }
.font-family-option:hover {
    background: rgba(255,255,255,0.08) !important;
}
.font-family-option:active {
    background: rgba(255,255,255,0.12) !important;
}

.notes-prosemirror pre {
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--sr-border);
    border-radius: 8px; padding: 12px 14px;
    font-family: monospace; font-size: 0.82rem;
    white-space: pre-wrap; margin: 10px 0;
}
.notes-prosemirror code {
    background: rgba(255,255,255,0.08);
    padding: 2px 6px; border-radius: 4px;
    font-family: monospace; font-size: 0.82rem;
}
.notes-prosemirror table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0 20px;
    font-size: 0.9rem;
}
.notes-prosemirror th {
    background: rgba(99, 102, 241, 0.12);
    color: var(--text-primary);
    font-weight: 700;
    text-align: left;
    padding: 9px 12px;
    border: 1px solid rgba(255,255,255,0.1);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.notes-prosemirror td {
    padding: 8px 12px;
    border: 1px solid rgba(255,255,255,0.07);
    color: var(--text-secondary);
    line-height: 1.5;
}
.notes-prosemirror tr:nth-child(even) td {
    background: rgba(255,255,255,0.025);
}
.notes-prosemirror a {
    color: var(--sr-blue); text-decoration: underline;
}
.notes-prosemirror ::selection {
    background: rgba(130, 140, 255, 0.35);
    color: inherit;
}
.notes-prosemirror mark {
    background: rgba(91, 76, 219, 0.18);
    color: inherit;
    padding: 1px 4px;
    border-radius: 3px;
    font-weight: 500;
}
[data-theme="light"] .notes-prosemirror mark {
    background: rgba(91, 76, 219, 0.12);
    color: rgb(91, 76, 219);
}
[data-theme="dark"] .notes-prosemirror mark {
    background: rgba(125, 119, 252, 0.2);
    color: rgb(125, 119, 252);
}
 /* ══════════════════════════════════════════════════════════════════════════
   STUDY ROOM — LAYOUT PATCH  (2025 sidebar refactor)
   ══════════════════════════════════════════════════════════════════════════
   Drop this AFTER study_room.css in your <head> (or append to that file).
   These rules override the old .pane-ai / .room-viewports / .panel-inner
   patterns with the new three-section sidebar stack.
   ══════════════════════════════════════════════════════════════════════════ */


/* ── ROOM WRAP  ─────────────────────────────────────────────────────────── */
:root {
    --ai-sidebar-w: 380px;
}

.room-wrap {
    position: fixed;
    top: 0;
    left: var(--sidebar-w, 220px);
    right: var(--ai-sidebar-w);
    bottom: 0;
    overflow: hidden;
    background: #0a0a0a;
    display: flex;
    flex-direction: row;
    align-items: stretch;
    justify-content: flex-start;
    transition: left 0.22s cubic-bezier(0.4, 0, 0.2, 1), right 0.25s ease;
}

.room-wrap.ai-pane-hidden {
    right: 0;
}

/* ── LEFT COLUMN: pane-main  ────────────────────────────────────────────── */

.pane-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-page);
    align-items: stretch;
    position: relative;
    padding-top: 52px;
    padding-right: 0 !important;
}

/* ── TOPBAR ──────────────────────────────────────────────────────────────── */
.sr-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  height: 52px;
  min-height: 52px;
  padding: 0 16px;
  background: var(--bg-page);
  border-bottom: 1px solid var(--border);
  box-sizing: border-box;
  position: fixed;
  top: 0;
  left: var(--sidebar-w, 220px);
  right: 0;
    z-index: 12000;
    isolation: isolate;
}

@media (min-width: 1025px) {
    .sr-topbar,
    .room-topbar {
        display: none !important;
    }
}

.sr-topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.sr-back-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  color: var(--text-secondary);
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
  text-decoration: none;
}

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

.sr-topbar-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 420px;
}

.sr-topbar-vid-row {
  display: flex;
    justify-content: space-between;
    align-items: center;
    flex: 1;
    min-width: 0;
    margin-right: 5px;

}

.sr-topbar-vid-label {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--sr-light);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
  flex-shrink: 0;
}
.sr-topbar-vid-left {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.vid-nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--sr-light);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}
.vid-nav-btn:hover {
  background: var(--sr-hover);
  color: var(--sr-ink);
}
.vid-nav-btn:disabled {
  opacity: 0.25;
  cursor: default;
  pointer-events: none;
}
.vid-counter {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--sr-muted);
  white-space: nowrap;
  flex-shrink: 0;
  min-width: 28px;
  text-align: center;
}

.sr-topbar-right {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
    position: relative;
        z-index: 12005;
}

.sr-topbar-menu-anchor {
    position: relative;
    display: flex;
    align-items: center;
    z-index: 12006;
}

.sr-topbar-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 224px;
    max-width: 320px;
    padding: 6px;
    border-radius: 12px;
    border: 1px solid var(--sr-border, rgba(0,0,0,0.09));
    background: var(--sr-surface);
    box-shadow:
        0 4px 6px -1px rgba(0,0,0,0.08),
        0 10px 28px -4px rgba(0,0,0,0.14),
        0 0 0 0.5px rgba(0,0,0,0.04);
    z-index: 12010;
    font-family: inherit;
    font-size: 0.875rem;
    /* slide-down reveal */
    transform-origin: top right;
    animation: srMenuReveal 140ms cubic-bezier(0.16,1,0.3,1) both;
}

[data-theme="dark"] .sr-topbar-menu {
    border-color: rgba(255,255,255,0.08);
    box-shadow:
        0 4px 6px -1px rgba(0,0,0,0.30),
        0 12px 32px -4px rgba(0,0,0,0.45),
        0 0 0 0.5px rgba(255,255,255,0.04);
}

@keyframes srMenuReveal {
    from { opacity: 0; transform: scale(0.95) translateY(-4px); }
    to   { opacity: 1; transform: scale(1)    translateY(0); }
}

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

.sr-topbar-menu__item {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 12px;
    border-radius: 8px;
    background: transparent;
    color: var(--sr-ink);
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    letter-spacing: 0.01em;
    text-align: left;
    cursor: pointer;
    width: 100%;
    border: none;
    transition: background 140ms ease, color 140ms ease;
    white-space: nowrap;
}

.sr-topbar-menu__item:hover {
    background: var(--primary-soft, rgba(91,76,219,0.07));
    color: var(--primary, #5b4cdb);
    outline: none;
}

.sr-topbar-menu__item:hover .sr-topbar-menu__icon {
    color: var(--primary, #5b4cdb);
}

.sr-topbar-menu__item:focus-visible {
    outline: 2px solid var(--primary, #5b4cdb);
    outline-offset: -2px;
}

.sr-topbar-menu__item[disabled] {
    opacity: 0.45;
    cursor: default;
    pointer-events: none;
}

.sr-topbar-menu__icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border-radius: 7px;
    background: var(--primary-soft, rgba(91,76,219,0.07));
    color: var(--primary, #5b4cdb);
    transition: background 140ms ease, color 140ms ease;
}

.sr-topbar-menu__icon svg {
    width: 15px;
    height: 15px;
    stroke-width: 2;
    flex-shrink: 0;
}

.sr-topbar-menu__item:hover .sr-topbar-menu__icon {
    background: color-mix(in srgb, var(--primary, #5b4cdb) 15%, transparent);
}

.sr-topbar-menu__label {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.sr-topbar-menu__divider {
    height: 1px;
    background: var(--sr-border, rgba(0,0,0,0.08));
    margin: 4px 2px;
}

[data-theme="dark"] .sr-topbar-menu__divider {
    background: rgba(255,255,255,0.07);
}

.sr-topbar-icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.sr-topbar-icon-btn:hover {
  background: var(--sr-hover);
  color: var(--text-primary);
}

.sr-topbar-badge {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  font-size: 0;
  color: transparent;
  pointer-events: none;
  box-shadow: 0 0 0 1.5px var(--sr-bg, #1a1a2e);
}

/* Desktop: hide mobile chat icon/label, show pane toggle icons */
.sr-ai-toggle-mobile-icon,
.sr-ai-toggle-mobile-label {
    display: none;
}

/* ── RIGHT COLUMN: pane-ai  ─────────────────────────────────────────────── */
.pane-ai {
    position: fixed;
    top: 52px;
    right: 0;
    bottom: 0;
    width: var(--ai-sidebar-w);

    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 100;
    transition: width 0.25s ease;

    background: #111111;
    border-left: 1px solid #1a1a1a;
}

/* ── AI pane collapsed states ────────────────────────────────────────── */
.pane-ai.ai-collapsed {
    width: 0 !important;
    border-left: none;
    overflow: visible;
}

.pane-main.ai-pane-hidden {
    flex: 1 1 auto;
    width: 100% !important;
    max-width: 100% !important;
    padding-right: 0 !important;
    right: 0 !important;
}

/* ── Study room mount spinner ─────────────────────────────────────────── */
/* Inserted by sr-spinner.js into the active .room-vp during async waits. */
/* Never lives in template HTML — see app/static/js/study-room/sr-spinner.js */

.sr-mount-spinner {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    z-index: 5;
    pointer-events: none;
    background: transparent;
    opacity: 0;
    transition: opacity 180ms ease;
}

.sr-mount-spinner--visible {
    opacity: 1;
}

.sr-mount-spinner__ring {
    width: 26px;
    height: 26px;
    border: 2.5px solid rgba(255, 255, 255, 0.12);
    border-top-color: var(--primary, #4ecdc4);
    border-radius: 50%;
    animation: sr-mount-spin 0.7s linear infinite;
}

@media (max-width: 860px) {
    .sr-mount-spinner {
        position: fixed;
        top: var(--sr-topbar-h, 52px);
        left: 0;
        right: 0;
        bottom: 0;
        inset: unset;
    }
}

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

.pane-main .room-viewports,
.pane-main .room-vp,
.pane-main #tab-upload {
    min-height: 0;
    height: 100%;
    overflow-y: auto;
    scrollbar-width: none;
}

.app-shell.with-desktop-side-nav #main-content.with-ai-panel.ai-panel-is-open {
    margin-right: var(--ai-sidebar-w) !important;
    padding-right: 0 !important;
}

.app-shell.with-desktop-side-nav #main-content:not(.ai-panel-is-open) {
    margin-right: 0 !important;
}

/* ── AI pane drag-to-resize handle ──────────────────────── */
.ai-resize-handle {
    position: fixed;
    top: 52px;
    right: var(--ai-sidebar-w);
    width: 20px;
    height: calc(100vh - 52px);
    cursor: col-resize;
    z-index: 200;
    /* Center the 20px strip on the pane border */
    transform: translateX(50%);
}

.ai-resize-grip {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 38px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    opacity: 0.2;
    transition: opacity 0.18s ease, color 0.18s, background 0.18s, border-color 0.18s,
                box-shadow 0.18s;
    pointer-events: none;
    box-shadow: 0 1px 4px rgba(0,0,0,0.12);
}

.ai-resize-handle:hover .ai-resize-grip,
body.is-resizing .ai-resize-grip {
    opacity: 1;
    color: var(--text-primary);
    background: var(--bg-secondary);
    border-color: var(--border-hover);
    box-shadow: 0 2px 8px rgba(0,0,0,0.18);
}

.ai-resize-handle.is-hidden,
.pane-ai.ai-collapsed ~ .ai-resize-handle {
    display: none;
}

body.is-resizing .pane-ai {
    transition: none !important;
}

body.is-resizing .room-wrap {
    transition: none !important;
}

body.is-resizing * {
    user-select: none !important;
}
/* ── end resize handle ───────────────────────────────────── */

/* ── Floating collapse tab on left edge of pane-ai ───────────────────── */
#aiToggleTab {
    position: fixed;
    right: var(--ai-sidebar-w);
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 64px;
    background: #111111;
    border: 1px solid #1a1a1a;
    border-right: none;
    border-radius: 8px 0 0 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    cursor: pointer;
    color: #666;
    z-index: 101;
    transition: color 0.15s, background 0.15s, right 0.25s ease;
    padding: 0;
}

#aiToggleTab:hover {
    color: #ccc;
    background: #1a1a1a;
}

.ai-toggle-label {
    font-size: 0.6rem;
    letter-spacing: 0.05em;
    writing-mode: vertical-rl;
    text-orientation: mixed;
    transform: rotate(180deg);
    font-weight: 600;
    color: inherit;
    display: none;
}

.pane-ai.ai-collapsed + #aiToggleTab {
    right: 0;
    border-right: 1px solid #1a1a1a;
    border-radius: 8px 0 0 8px;
}

.pane-ai.ai-collapsed + #aiToggleTab .ai-toggle-label {
    display: block;
}


/* ══ SECTION A – Navigation Header  ═════════════════════════════════════ */
.ai-sidebar-header {
    flex-shrink: 0;
    padding: 0;
    background: #111111;
}

/* Pill-track that holds the three tab buttons */
.ai-tab-track {
    display: flex;
    align-items: center;
    gap: 4px;
    background: transparent;
    border: 1px solid var(--ai-border);
    border-radius: 10px;
    padding: 2px;
    margin: 15px 10px;
}

/* Individual tab pills */
.ai-tab-btn {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 12px;
    border: none;
    border-radius: 0;
    background: transparent;
    color: #6b6b6b;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: color 0.15s, background 0.15s;
    white-space: nowrap;
    user-select: none;
    border-bottom: 2px solid transparent;
}
.ai-tab-btn svg { flex-shrink: 0; }
.ai-tab-btn:hover { color: #cccccc; background: rgba(255,255,255,0.03); border-radius:8px;}

/* Active state — matches Image 2: filled background highlight + white text */
.ai-tab-btn.active {
    background: #2a2a2a;
    color: #ffffff;
    border: 0px solid;
    border-radius: 8px;
    box-shadow: none;
}


/* ══ SECTION B – Active Window Display Pane  ════════════════════════════ */
.ai-viewports {
    flex: 1;
    min-height: 0;          /* crucial — lets flex-1 actually shrink */
    position: relative;
    overflow: hidden;
}

/* Each panel fills the container absolutely */
.ai-vp {
    position: absolute;
    inset: 0;
    display: none;          /* hidden by default */
    flex-direction: column;
    overflow: hidden;
}

/* Active panel is shown */
.ai-vp.ai-vp--active {
    display: flex;
}

/* ── Chat panel inner layout ────────────────────────────────────── */
#vp-chat {
    display: none;
    flex-direction: column;
    background: #111111;
}
#vp-chat.ai-vp--active {
    display: flex;
}

/* Scroll container for chat messages */
/* ── Chat suggestions ── */
/* ── Chat empty state ─────────────────────────────────────────────────────── */
.chat-empty-state {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0;
    padding: 28px 20px;
    text-align: center;
    pointer-events: none;
    animation: chatIdleFadeIn 0.35s ease both;
}
@keyframes chatIdleFadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}
.chat-empty-state > * { pointer-events: auto; }

.chat-empty-icon {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: color-mix(in srgb, var(--primary, #818cf8) 14%, transparent);
    border: 1px solid color-mix(in srgb, var(--primary, #818cf8) 22%, transparent);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary, #818cf8);
    margin-bottom: 14px;
    flex-shrink: 0;
}

.chat-empty-headline {
    margin: 0 0 5px;
    font-size: 0.97rem;
    font-weight: 650;
    color: var(--sr-ink);
    line-height: 1.35;
    font-family: var(--font-display, inherit);
    letter-spacing: -0.01em;
}
.chat-empty-sub {
    margin: 0 0 20px;
    font-size: 0.76rem;
    color: var(--sr-muted);
    line-height: 1.5;
}
.chat-empty-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 7px;
    width: 100%;
    max-width: 270px;
}
.chat-empty-btn {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    padding: 10px 11px;
    border: 1px solid var(--sr-border);
    border-radius: 11px;
    background: color-mix(in srgb, var(--sr-hover, rgba(255,255,255,.04)) 60%, transparent);
    color: var(--sr-muted);
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.14s, color 0.14s, border-color 0.14s, transform 0.12s;
    font-family: inherit;
    text-align: left;
    width: 100%;
}
.chat-empty-btn:hover {
    color: var(--sr-ink);
    border-color: color-mix(in srgb, var(--primary, #818cf8) 35%, var(--sr-border));
    transform: translateY(-1px);
}
.chat-empty-btn:active { transform: translateY(0); }
.chat-empty-btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 7px;
    color: color-mix(in srgb, var(--primary, #818cf8) 80%, var(--sr-ink));
    flex-shrink: 0;
    transition: background 0.14s;
}
.chat-empty-btn:hover .chat-empty-btn-icon {
    background: color-mix(in srgb, var(--primary, #818cf8) 20%, transparent);
}
.chat-empty-btn-label {
    line-height: 1.2;
}

.chat-messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 14px 12px 16px;
    display: flex;
    flex-direction: column;
    }
.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 2px; }
[data-theme="light"] .chat-messages::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.15);
}

/* chat-thread is the direct parent of message nodes */
.chat-thread {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-height: min-content;
    padding-bottom: 28px;
}

/* ── New message layout (flex wrappers with prose) ── */
.cmsg-user-wrap,
.cmsg-ai-wrap,
.cmsg-system-wrap {
    line-height: 1.6;
    font-size: 0.9rem;
}

/* ── Quota wall bubble ── */
.cmsg-quota-bubble {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px 8px;
    padding: 9px 14px;
    border-radius: 12px;
    border: 1px solid color-mix(in srgb, var(--primary, #818cf8) 35%, transparent);
    background: color-mix(in srgb, var(--primary, #818cf8) 8%, var(--bg-card, #1e1e2e));
    max-width: 420px;
    font-size: 0.82rem;
}
.cmsg-quota-icon {
    flex-shrink: 0;
    color: var(--primary, #818cf8);
    opacity: 0.8;
}
.cmsg-quota-text {
    color: var(--text-secondary, #aaa);
    line-height: 1.4;
}
.cmsg-quota-upgrade-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 20px;
    border: none;
    background: var(--primary, #818cf8);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    cursor: pointer;
    transition: filter 0.12s, transform 0.1s;
    white-space: nowrap;
}
.cmsg-quota-upgrade-btn:hover { filter: brightness(1.15); transform: translateY(-1px); }
.cmsg-quota-upgrade-btn:active { transform: translateY(0); }
.cmsg-quota-sub {
    color: var(--text-muted, #666);
    font-size: 0.75rem;
    width: 100%;
    padding-left: 23px; /* align under text, past icon+gap */
}

/* Prose defaults inside chat messages */
.cmsg-ai-wrap .prose,
.cmsg-system-wrap .prose {
    line-height: 1.65;
    font-size: 1rem;
}
.cmsg-ai-wrap .prose p,
.cmsg-system-wrap .prose p {
    margin: 0.8em 0;
}
.cmsg-ai-wrap .prose p:first-child,
.cmsg-system-wrap .prose p:first-child {
    margin-top: 0;
}
.cmsg-ai-wrap .prose p:last-child,
.cmsg-system-wrap .prose p:last-child {
    margin-bottom: 0;
}
.cmsg-ai-wrap .prose ul,
.cmsg-system-wrap .prose ul {
    margin: 0.7em 0;
    padding-left: 1.3em;
    list-style: disc;
}
.cmsg-ai-wrap .prose li,
.cmsg-system-wrap .prose li {
    margin: 0.35em 0;
}
.cmsg-ai-wrap .prose h2,
.cmsg-system-wrap .prose h2 {
    font-size: 1.1rem;
    font-weight: 700;
    margin: 1em 0 0.35em;
    color: #FCF6F5;
}
.cmsg-ai-wrap .prose h3,
.cmsg-system-wrap .prose h3 {
    font-size: 1rem;
    font-weight: 700;
    margin: 0.9em 0 0.3em;
    color: #FCF6F5;
}
.cmsg-ai-wrap .prose code,
.cmsg-system-wrap .prose code {
    background: rgba(255,255,255,0.1);
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 0.85em;
}
.cmsg-ai-wrap .prose a,
.cmsg-system-wrap .prose a {
    color: #7dd3fc;
    text-decoration: underline;
    text-underline-offset: 2px;
}


/* ── Legacy cmsg styles (kept for backward compat) ── */
.cmsg {
    position: relative;
    width: fit-content;
    max-width: min(85%, 28rem);
    padding: 12px 14px;
    border-radius: 18px;
    line-height: 1.55;
    font-size: 1.1rem;
    color: #f5f7fb;
    border: 1px solid transparent;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.16);
    word-break: break-word;
    white-space: normal;
}
.cmsg::before {
    content: '';
    position: absolute;
    width: 10px;
    height: 10px;
    bottom: 10px;
    transform: rotate(45deg);
    background: inherit;
    border-radius: 2px;
    z-index: -1;
}
.cmsg-user {
    margin-left: auto;
    background: linear-gradient(135deg, color-mix(in srgb, var(--primary,#4ecdc4) 95%, transparent), rgba(56,189,248,0.9));
    color: #071216;
    border-color: rgba(255,255,255,0.22);
    border-bottom-right-radius: 8px;
}
.cmsg-user::before {
    right: -4px;
    background: color-mix(in srgb, var(--primary,#4ecdc4) 95%, transparent);
}
.cmsg-ai,
.cmsg-system {
    margin-right: auto;
    background: rgba(17, 17, 17, 0.88);
    border-color: rgba(255,255,255,0.08);
    border-bottom-left-radius: 8px;
}
.cmsg-ai::before,
.cmsg-system::before {
    left: -4px;
    background: rgba(17, 17, 17, 0.88);
}
.cmsg-system {
    background: rgba(17, 17, 17, 0.62);
    color: #cbd5e1;
    font-size: 0.84rem;
    padding: 10px 12px;
}
.cmsg-system strong,
.cmsg-ai strong,
.cmsg-user strong {
    font-weight: 800;
}
.cmsg-system code,
.cmsg-ai code,
.cmsg-user code {
    background: rgba(255,255,255,0.12);
    padding: 2px 6px;
    border-radius: 6px;
    font-family: monospace;
    font-size: 0.85em;
}
.cmsg-system a,
.cmsg-ai a,
.cmsg-user a {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 2px;
}
.cmsg--streaming {
    border-color: color-mix(in srgb, var(--primary,#4ecdc4) 26%, transparent);
}
.cmsg-cursor {
    display: inline-block;
    margin-left: 4px;
    color: var(--primary,#4ecdc4);
    animation: cmsgBlink 1.1s steps(1) infinite;
}



@keyframes cmsgBlink {
    0%, 49% { opacity: 1; }
    50%, 100% { opacity: 0; }
}

.cmsg-card {
    width: min(100%, 30rem);
    padding: 0;
    overflow: hidden;
    border-radius: 18px;
    background: rgba(17, 17, 17, 0.9);
    border: 1px solid rgba(255,255,255,0.08);
}

.cmsg-card--pack,
.cmsg-card--quiz,
.cmsg-card--flashcard {
    box-shadow: 0 18px 34px rgba(0, 0, 0, 0.2);
}

.cmsg-card .cc-pack-title,
.cmsg-card .cc-q,
.cmsg-card .cc-fc-front {
    padding: 14px 16px;
    font-weight: 800;
    color: #ffffff;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0));
}

.cmsg-card .cc-pack-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    color: #e2e8f0;
    text-decoration: none;
    border-top: 1px solid rgba(255,255,255,0.04);
    transition: background 0.15s, transform 0.15s;
}

.cmsg-card .cc-pack-item:hover {
    background: rgba(255,255,255,0.04);
    transform: translateX(2px);
}

.cmsg-card .cc-pack-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--primary,#4ecdc4) 14%, transparent);
    color: var(--primary,#4ecdc4);
    flex-shrink: 0;
}

.cmsg-card .cc-opts {
    display: grid;
    gap: 8px;
    padding: 14px 16px 16px;
}

.cmsg-card .cc-opt {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 12px;
    background: rgba(255,255,255,0.03);
    color: #e2e8f0;
    text-align: left;
}

.cmsg-card .cc-opt:hover:not(:disabled) {
    background: rgba(255,255,255,0.07);
}

.cmsg-card .cc-opt--correct {
    background: rgba(34,197,94,0.18);
    border-color: rgba(34,197,94,0.36);
    color: #d1fae5;
}

.cmsg-card .cc-opt--wrong {
    background: rgba(239,68,68,0.16);
    border-color: rgba(239,68,68,0.30);
    color: #fee2e2;
}

.cmsg-card .cc-divider {
    margin: 0;
    border: 0;
    border-top: 1px solid rgba(255,255,255,0.06);
}

.cmsg-card .cc-fc-back {
    padding: 14px 16px;
    color: #e2e8f0;
}

.cmsg-card .cc-fc-reveal {
    width: calc(100% - 32px);
    margin: 0 16px 16px;
    padding: 10px 12px;
    border: 1px solid color-mix(in srgb, var(--primary,#4ecdc4) 26%, transparent);
    border-radius: 12px;
    background: color-mix(in srgb, var(--primary,#4ecdc4) 12%, transparent);
    color: var(--primary,#4ecdc4);
    font-weight: 700;
}

.cmsg-card .cc-fc-reveal:hover:not(:disabled) {
    background: color-mix(in srgb, var(--primary,#4ecdc4) 18%, transparent);
}

.cmsg-card .cc-fc-reveal:disabled {
    opacity: 0.55;
}

.cmsg-card .cc-fc-back[hidden] {
    display: none;
}

/* ── Content panel ──────────────────────────────────────────────── */
#vp-content {
    display: none;
    flex-direction: column;
}
#vp-content.ai-vp--active {
    display: flex;
}
.ai-vp-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 0px 8px 8px 8px;
}
.ai-vp-scroll::-webkit-scrollbar { width: 4px; }
.ai-vp-scroll::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 2px; }

/* ── Reference attachment (Content tab) — separate from the pack's own
   document, which stays in the Slides tab. No border/header chrome: the
   "Content" tab label already says what this is. ── */
#aiContentScroll {
    padding: 0;
    display: flex;
    flex-direction: column;
}
.ai-ref-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 32px 24px;
    text-align: center;
    color: var(--sr-light, #6b6b6b);
}
.ai-ref-empty-title {
    margin: 4px 0 0;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--sr-ink, #e5e5e5);
}
.ai-ref-empty-sub {
    margin: 0;
    font-size: 0.78rem;
    line-height: 1.5;
    color: var(--sr-muted, #888);
    max-width: 240px;
}
.ai-ref-attach-btn {
    margin-top: 10px;
    padding: 8px 16px;
    border: none;
    border-radius: 8px;
    background: var(--primary, #7c6cfa);
    color: #fff;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
}
.ai-ref-attach-btn:hover { opacity: 0.9; }

.ai-ref-viewer {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}
.ai-ref-toolbar {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 8px;
}
.ai-ref-tb-btn {
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    border-radius: 6px;
    color: var(--sr-muted, #888);
    cursor: pointer;
}
.ai-ref-tb-btn:hover:not(:disabled) { color: var(--sr-ink, #e5e5e5); background: rgba(255,255,255,0.06); }
.ai-ref-tb-btn:disabled { opacity: 0.35; cursor: default; }
.ai-ref-page-info, .ai-ref-zoom-label {
    font-size: 0.74rem;
    color: var(--sr-muted, #888);
    white-space: nowrap;
}
.ai-ref-tb-spacer { flex: 1; }
.ai-ref-canvas-wrap {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0 8px 8px;
    scrollbar-width: none;  
}
.ai-ref-pages {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}
.ai-ref-page {
    position: relative;
    background: rgba(255,255,255,0.03);
    border-radius: 8px;
    overflow: hidden;
    user-select: text;
    -webkit-user-select: text;
}
.ai-ref-page canvas {
    display: block;
    width: 100%;
    height: 100%;
}
.ai-ref-page .textLayer {
    position: absolute;
    top: 0; left: 0;
    overflow: hidden;
    line-height: 1;
    text-size-adjust: none;
    forced-color-adjust: none;
    pointer-events: auto;
    user-select: text;
    -webkit-user-select: text;
    z-index: 1;
}
.ai-ref-page .textLayer span,
.ai-ref-page .textLayer br {
    color: transparent;
    position: absolute;
    white-space: pre;
    cursor: text;
    transform-origin: 0% 0%;
    pointer-events: auto;
    user-select: text;
    -webkit-user-select: text;
}
.ai-ref-page .textLayer ::selection {
    background: rgba(130,140,255,0.35);
    color: transparent;
}
.ai-ref-page .textLayer .highlight { background: rgba(255,220,0,0.25); border-radius: 2px; }
.ai-ref-page .textLayer .endOfContent {
    display: block;
    position: absolute;
    inset: 100% 0 0;
    z-index: -1;
    cursor: default;
    user-select: none;
}
.ai-ref-image {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
}
[data-theme="light"] .ai-ref-page { background: rgba(0,0,0,0.03); }
[data-theme="light"] .ai-ref-tb-btn:hover:not(:disabled) { background: rgba(0,0,0,0.06); }

/* ── Notes panel ────────────────────────────────────────────────── */
#vp-notes {
    display: none;
    flex-direction: column;
}
#vp-notes.ai-vp--active {
    display: flex;
}

/* Notes shell already defined in study_room.css; ensure scroll wrapper grows */
#vp-notes .notes-shell {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
#vp-notes .notes-editor-wrap {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}


/* ══ SECTION C – Input Footer Zone  ════════════════════════════════════ */
.ai-footer {
    flex-shrink: 0;
    padding: 10px 12px 14px;
    border-top: 1px solid #1a1a1a;
    background: #111111;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .ai-footer {
        padding-bottom: calc(14px + env(safe-area-inset-bottom));
    }
}

/* Finish Lesson button (shown by JS when appropriate) */
.finish-lesson-btn {
    display: none;          /* JS toggles visibility */
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 9px 16px;
    border: none;
    border-radius: 10px;
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s;
}
.finish-lesson-btn:hover { background: rgba(16, 185, 129, 0.25); }

/* ── CHAT INPUT ────────────────────────────────────────────────────── */
.chat-input-wrap {
    display: flex;
    flex-direction: column;
    background: #1a1a1a;
    border: 1px solid #2a2a2a;
    border-radius: 24px;
    padding: 0;
    transition: border-color 0.18s;
    overflow: hidden;
}
.chat-input-wrap:focus-within {
    border-color: #555;
}

.chat-context-bar {
    display: inline-flex; flex-direction: column;
    gap: 4px; padding: 8px 10px;
    margin: 4px 12px 0;
    background: var(--bg-card);
    border: 1px solid var(--text-secondary);
    border-radius: 10px; width: fit-content; height: 100px; max-width: 120px;
}
.chat-context-label {
    font-weight: 700; color: var(--primary, #818cf8);
    text-transform: uppercase; letter-spacing: 0.04em;
    font-size: 0.62rem; line-height: 1;
}
.chat-context-text {
    font-size: 0.75rem; color: var(--text-secondary, #aaa);
    line-height: 1.5; overflow: hidden;
    display: -webkit-box; -webkit-line-clamp: 3;
    -webkit-box-orient: vertical; word-break: break-word;
}
.chat-context-clear {
    position: absolute; top: 4px; right: 6px;
    background: none; border: none;
    color: var(--text-muted, #666);
    font-size: 0.85rem; line-height: 1;
    cursor: pointer; padding: 2px; border-radius: 4px;
    opacity: 0; transition: opacity 0.12s;
}
.chat-context-bar { position: relative; }
.chat-context-bar:hover .chat-context-clear { opacity: 1; }
.chat-context-clear:hover { color: var(--text-primary, #fff); }

#chatInput {
    width: 100%;
    background: transparent;
    border: none;
    outline: none;
    color: #e5e7eb;
    font-size: 1rem;
    font-family: inherit;
    resize: none;
    line-height: 1.5;
    max-height: 320px;
    min-height: 60px;
    padding: 16px 20px 0;
    caret-color: #fff;
    -webkit-appearance: none;
    appearance: none;
    scrollbar-width: none;
    display: block;
}
#chatInput::-webkit-scrollbar { display: none; }
#chatInput::placeholder { color: #585858; }
#chatInput:disabled { opacity: 0.5; }

@media (max-width: 768px) {
    #chatInput { font-size: 1rem; }
}
@media (min-width: 769px) {
    .cmsg-user-wrap,
    .cmsg-ai-wrap,
    .cmsg-system-wrap { font-size: 1rem; }
    .cmsg-ai-wrap .prose,
    .cmsg-system-wrap .prose { font-size: 1rem; }
    .cmsg { font-size: 1rem; }
}


    @media (max-width: 1024px) {
        .sr-topbar-menu-anchor,
        .sr-topbar-menu {
            display: none !important;
        }
    }
#chatInput:focus { outline: none !important; border: none !important; box-shadow: none !important; }

/* Typewriter styling for AI replies */
.ai-typewriter { white-space: pre-wrap; display: block; width: 100%; }
.ai-tw-live { display: block; white-space: pre-wrap; }
.ai-tw-streaming-partial { opacity: 0.6; }

/* Input actions row (bottom bar with reset + send) */
.chat-input-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px 12px;
}

.chat-input-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-input-right {
    display: flex;
    align-items: center;
    gap: 4px;
}

.chat-reset-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: none;
    background: transparent;
    color: #9ca3af;
    font-size: 0.75rem;
    font-weight: 500;
    padding: 6px 12px;
    border-radius: 9999px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.chat-reset-btn:hover {
    background: #2a2a2a;
    color: #e5e7eb;
}
.chat-reset-icon {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.chat-send-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 9999px;
    background: #ffffff;
    color: #000000;
    cursor: pointer;
    transition: background 0.15s, box-shadow 0.15s;
    flex-shrink: 0;
    padding: 0;
    touch-action: manipulation;
}
.chat-send-btn:hover:not(:disabled):not(.is-disabled) {
    background: #f3f4f6;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.chat-send-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.chat-send-btn.is-disabled { opacity: 0.5; cursor: not-allowed; }
.chat-send-icon {
    width: 20px;
    height: 20px;
}
.chat-send-btn--stop,
.chat-send-btn--stop.is-disabled,
.chat-send-btn--stop:disabled {
    opacity: 1;
    cursor: pointer;
    background: color-mix(in srgb, #111111 14%, #ffffff);
}
.chat-send-btn--stop:hover {
    background: color-mix(in srgb, #111111 22%, #ffffff);
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

/* ── Chat tool toolbar ── */
.chat-tool-bar {
    display: flex;
    gap: 4px;
    padding: 4px 14px;
    overflow-x: auto;
    scrollbar-width: none;
}
.chat-tool-bar::-webkit-scrollbar { display: none; }

.chat-tool-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border: 1px solid var(--sr-line, #282a2e);
    border-radius: 6px;
    background: var(--sr-card, #1a1c1e);
    color: var(--sr-muted, #8a8f98);
    font-size: 11px;
    font-family: var(--font-body);
    cursor: pointer;
    white-space: nowrap;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.chat-tool-btn:hover {
    border-color: var(--primary);
    color: var(--sr-light, #e4e5e7);
    background: color-mix(in srgb, var(--primary) 8%, var(--sr-card, #1a1c1e));
}
.chat-tool-btn svg { opacity: 0.7; }
.chat-tool-btn:hover svg { opacity: 1; }

[data-theme="light"] .chat-tool-btn {
    border-color: var(--sr-line, #d8d9dd);
    background: var(--sr-card, #fff);
    color: var(--sr-muted, #6b7280);
}
[data-theme="light"] .chat-tool-btn:hover {
    border-color: var(--primary);
    color: var(--sr-light, #1a1c1e);
    background: color-mix(in srgb, var(--primary) 8%, var(--sr-card, #fff));
}

/* ── Mic input button ── */
.chat-mic-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 9999px;
    background: transparent;
    color: #9ca3af;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    flex-shrink: 0;
    padding: 0;
    touch-action: manipulation;
}
.chat-mic-btn:hover {
    background: #2a2a2a;
    color: #e5e7eb;
}
.chat-mic-btn.is-recording {
    color: #ef4444;
    background: rgba(239,68,68,0.12);
    animation: chat-mic-pulse 1.2s ease-in-out infinite;
}
.chat-mic-btn.is-recording:hover {
    background: rgba(239,68,68,0.2);
}
@keyframes chat-mic-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,0.3); }
    50% { box-shadow: 0 0 0 6px rgba(239,68,68,0); }
}
[data-theme="light"] .chat-mic-btn {
    color: #9ca3af;
}
[data-theme="light"] .chat-mic-btn:hover {
    background: #f3f4f6;
    color: #374151;
}
[data-theme="light"] .chat-mic-btn.is-recording {
    color: #ef4444;
    background: rgba(239,68,68,0.1);
}
[data-theme="light"] .chat-mic-btn.is-recording:hover {
    background: rgba(239,68,68,0.18);
}


/* ══ SUPPRESS OLD LAYOUT FRAGMENTS  ════════════════════════════════════ */
/*
 * These selectors target legacy room-wrap internals that have now been removed.
 * The rules stay as a safety net in case older markup still emits them.
 */
.room-layout        { display: contents !important; }
.chat-main          { display: contents !important; }
.chat-sidebar       { display: none !important; }
.room-backdrop      { display: none !important; }

/* Old .room-viewports / .room-vp — now replaced by .ai-viewports / .ai-vp */
/* keep suppression for legacy markup but allow our replacement container by using a
    negation selector so elements that also have .room-viewports-replacement remain visible */
.room-viewports:not(.room-viewports-replacement) { display: none !important; }

/* ── Chat image attachment ──────────────────────────────────────────── */
.chat-img-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 36px; height: 36px; border: none; border-radius: 9999px;
    background: transparent; color: #9ca3af; cursor: pointer;
    flex-shrink: 0; padding: 0;
    transition: background 0.15s, color 0.15s; touch-action: manipulation;
}
.chat-img-btn:hover { background: #2a2a2a; color: #e5e7eb; }
[data-theme="light"] .chat-img-btn { color: #9ca3af; }
[data-theme="light"] .chat-img-btn:hover { background: #f3f4f6; color: #374151; }

.chat-img-preview {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 6px 12px; margin: 0 0 4px;
    border-radius: 20px; width: fit-content; max-width: 100%;
}
.chat-img-preview-items {
    display: flex; align-items: center; gap: 4px; flex-wrap: wrap;
}
.chat-img-preview-item {
    position: relative; display: inline-flex; align-items: center;
    border-radius: 8px; overflow: hidden; flex-shrink: 0;
    border: 1px solid color-mix(in srgb, var(--primary, #818cf8) 25%, transparent);
    transition: border-color 0.12s;
    width: 95px; height: 80px;
}
.chat-img-preview-item img {
    width: 100%; height: 100%; object-fit: cover; display: block;
}
.chat-img-item-name {
    display: none;
}
.chat-img-item-remove {
    position: absolute; top: 0; right: 0;
    width: 18px; height: 18px; display: flex;
    align-items: center; justify-content: center;
    background: rgba(0,0,0,0.65); border: none;
    color: #fff; font-size: 0.8rem; line-height: 1;
    cursor: pointer; border-radius: 0 6px 0 6px;
    opacity: 0; transition: opacity 0.12s;
    padding: 0;
}
.chat-img-preview-item:hover .chat-img-item-remove { opacity: 1; }

.chat-img-status {
    font-size: 0.72rem; color: var(--text-secondary, #aaa);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    opacity: 0; transition: opacity 0.12s; flex-shrink: 0;
}
.chat-img-preview:hover .chat-img-status { opacity: 1; }

.chat-attached-images {
    display: grid; grid-template-columns: repeat(2, 1fr);
    gap: 4px; margin-bottom: 6px;
    max-width: 320px; border-radius: 10px; overflow: hidden;
}
.chat-attached-images--single {
    grid-template-columns: 1fr;
}
.chat-attached-image {
    border-radius: 8px; overflow: hidden;
    background: #1a1a1a; aspect-ratio: 1;
}
.chat-attached-image img {
    width: 100%; height: 100%; display: block;
    object-fit: cover;
}
.chat-attached-images--single {
    grid-template-columns: minmax(0, 260px);
}
[data-theme="light"] .chat-attached-image { background: #f0f0f0; }

/* ── Drop overlay ─────────────────────────────────────────────── */
.chat-drop-overlay {
    display: none;
    position: absolute; inset: 0;
    z-index: 10;
    flex-direction: column; align-items: center; justify-content: center; gap: 6px;
    background: rgba(91, 76, 219, 0.12);
    border: 2px dashed var(--primary, #818cf8);
    border-radius: 16px;
    color: var(--primary, #818cf8);
    font-size: 0.82rem; font-weight: 600;
    pointer-events: none;
    transition: opacity 0.15s;
}
.chat-drop-active {
    position: relative;
}
.chat-drop-active .chat-drop-overlay {
    display: flex;
}
.chat-doc-btn { margin-left: 2px; }

/* ── Document preview chips (in the preview strip) ────────────── */
.chat-doc-preview-item {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 4px 8px 4px 6px;
    background: #1e1e1e;
    border: 1px solid color-mix(in srgb, var(--primary, #818cf8) 20%, transparent);
    border-radius: 8px;
    font-size: 0.72rem; color: #d1d5db;
    max-width: 200px; flex-shrink: 0;
    transition: border-color 0.12s;
}
.chat-doc-preview-item:hover {
    border-color: color-mix(in srgb, var(--primary, #818cf8) 50%, transparent);
}
[data-theme="light"] .chat-doc-preview-item {
    background: #f3f4f6; color: #374151;
}
.chat-doc-icon {
    flex-shrink: 0; color: var(--primary, #818cf8);
}
.chat-doc-preview-name {
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    max-width: 120px;
}
.chat-doc-preview-size {
    color: #6b7280; font-size: 0.65rem; flex-shrink: 0;
}
.chat-doc-preview-remove {
    width: 16px; height: 16px; display: flex;
    align-items: center; justify-content: center;
    background: transparent; border: none;
    color: #6b7280; font-size: 0.75rem; line-height: 1;
    cursor: pointer; border-radius: 4px; padding: 0;
    opacity: 0; transition: opacity 0.12s, background 0.12s, color 0.12s;
    flex-shrink: 0;
}
.chat-doc-preview-item:hover .chat-doc-preview-remove { opacity: 1; }
.chat-doc-preview-remove:hover { background: rgba(239,68,68,0.15); color: #ef4444; }

/* ── Document chips in user bubbles ───────────────────────────── */
.chat-attached-docs {
    display: flex; flex-wrap: wrap; gap: 4px;
    margin-bottom: 6px;
}
.chat-attached-doc {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 4px 8px;
    background: rgba(255,255,255,0.06);
    border-radius: 6px;
    font-size: 0.72rem; color: #d1d5db;
    max-width: 220px;
}
.chat-attached-doc svg {
    flex-shrink: 0; color: var(--primary, #818cf8);
}
.chat-attached-doc span {
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
[data-theme="light"] .chat-attached-doc {
    background: rgba(0,0,0,0.05); color: #374151;
}

.chat-reset-label {
    display: inline-block; overflow: hidden; white-space: nowrap;
    max-width: 0; opacity: 0;
    transition: max-width 0.15s, opacity 0.12s;
    vertical-align: middle;
}
.chat-reset-btn:hover .chat-reset-label {
    max-width: 80px; opacity: 1;
}

/* Old .chat-input-area / .chat-input-row (from study_room.html v1) */
.chat-input-area,
.chat-input-row { display: none !important; }


/* ══ RESPONSIVE: right-side AI overlay on mobile  ═══════════════════ */
@media (max-width: 768px) {
    .pane-ai {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        z-index: 1060;
        transform: translateY(100%);
        transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1);
        background: var(--bg-page);
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
        box-shadow: none;
        display: flex;
        flex-direction: column;
        border-left: none;
    }
    .pane-ai.show {
        transform: translateY(0);
    }
    .pane-ai.ai-collapsed {
        transform: translateY(100%);
        width: 100% !important;
        border-left: none !important;
        overflow: hidden;
    }

    #aiToggleTab {
        position: fixed;
        right: 0;
        top: 50%;
        transform: translateY(-50%);
        z-index: 1061;
        left: auto !important;
        width: 20px;
        height: 46px;
        border-radius: 6px 0 0 6px;
        background: var(--bg-card, #1a1a1a);
        border: 1px solid var(--border, rgba(255,255,255,0.07));
        border-right: none;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 1px;
        cursor: pointer;
        color: var(--text-muted);
        padding: 4px 0;
    }

    #aiToggleTab svg {
        width: 10px;
        height: 10px;
    }

    .ai-toggle-label {
        display: block;
        font-size: 0.45rem;
        font-weight: 600;
        letter-spacing: 0.03em;
        writing-mode: initial;
        text-orientation: initial;
        transform: none;
    }

    .close-ai-btn {
        display: block !important;
    }

    .pane-main {
        padding-right: 0;
    }

    .fab-ai {
        display: flex;
        bottom: calc(56px + env(safe-area-inset-bottom, 0px) + 12px);
    }
    #aiToggleTab {
        display: none;
    }

    /* ── room-wrap: full viewport, no side nav offset, no AI column reservation ── */
    .room-wrap {
        left: 0 !important;
        right: 0 !important;
        top: 0 !important;
        bottom: 0 !important;
        flex-direction: column;
    }

    /* ── pane-main fills full room-wrap ── */
    .pane-main {
        flex: 1;
        width: 100% !important;
        max-width: 100% !important;
        padding-right: 0 !important;
        flex-direction: column;
    }

    /* Variant A capsule rules live in the canonical base block. */

    /* ── Restore topbar on mobile (keeps it fixed alongside tab bar) ── */
    .sr-topbar {
        display: flex !important;
        position: fixed !important;
        top: 0;
        left: 0 !important;
        right: 0;
        height: 52px;
        min-height: 52px;
        z-index: 100;
    }

    /* ── Mobile AI toggle: chat icon only ── */
    .sr-ai-toggle-mobile-icon,
    .sr-ai-toggle-mobile-label {
        display: none;
    }
    #srAiToggleBtn .sr-ai-toggle-mobile-icon {
        display: inline;
    }
    #srAiToggleBtn .sr-ai-toggle-mobile-label {
        display: none !important;
    }
    #srAiToggleBtn #srAiToggleIcon-open,
    #srAiToggleBtn #srAiToggleIcon-collapsed {
        display: none !important;
    }
    #srAiToggleBtn {
        display: none !important;
    }

    /* ── Remove the 52px padding-top from pane-main since topbar is gone ── */
    .pane-main { padding-top: 0 !important; }

    /* All tab styling for this breakpoint lives in the canonical base block. */

    /* ── Fill-in tab: highlight next chevron ── */
    #tab-more .fi-gotit-row {
        display: none !important;
    }
    #tab-more #fiNext.fi-has-input {
        background: var(--sr-blue, #4ecdc4) !important;
        color: #fff !important;
        border-radius: 50%;
        box-shadow: 0 2px 10px color-mix(in srgb, var(--sr-blue, #4ecdc4) 50%, transparent);
    }
    #tab-more #fiNext.fi-has-input svg {
        stroke: #fff !important;
    }

    /* ── Push room-wrap below the fixed tab bar ── */
    .room-wrap {
        top: 104px !important;
    }

    /* ── room-viewports fills remaining height below tab bar ── */
    .room-viewports {
        flex: 1;
        min-height: 0;
        width: 100% !important;
        max-width: 100% !important;
    }

    /* ── Each vp scrolls independently on mobile ── */
    .room-vp {
        overflow-y: auto;
        padding-bottom: calc(56px + env(safe-area-inset-bottom, 0px));
    }

    /* ── mys-shell (upload/PDF tab) fills its vp ── */
    .mys-shell {
        position: absolute;
        inset: 0;
    }

    /* ── room-wrap collapse state does nothing on mobile (AI is overlay) ── */
    .room-wrap.ai-pane-hidden {
        right: 0 !important;
    }
}

/* ── BACK TO HOME BUTTON ─────────────────────────────────────────────── */
.dsn-back-home {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    margin: 0 6px 6px;
    border-radius: 10px;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-muted);
    text-decoration: none;
    transition: color 0.15s, background 0.15s;
    border: none;
    background: transparent;
    cursor: pointer;
}
.dsn-back-home:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

/* ── LIGHT MODE OVERRIDES FOR AI SIDEBAR ────────────────────────────── */
[data-theme="light"] .room-wrap { background: var(--bg); }

[data-theme="light"] .pane-ai {
    background: var(--bg-page);
    border-left-color: var(--border);
}

[data-theme="light"] #aiToggleTab {
    background: var(--bg-card);
    border-color: var(--border);
    color: var(--text-muted);
}
[data-theme="light"] #aiToggleTab:hover {
    color: var(--text-secondary);
    background: var(--bg-hover);
}
[data-theme="light"] .pane-ai.ai-collapsed + #aiToggleTab {
    border-right-color: var(--border);
}

[data-theme="light"] .sr-topbar {
  background: #ffffff;
  border-bottom-color: #e5e5e5;
}

[data-theme="light"] .ai-sidebar-header {
    background: var(--bg-page);
}

[data-theme="light"] .ai-tab-track {
    background: var(--bg-secondary);
    border-color: var(--border);
}
[data-theme="light"] .ai-tab-btn { color: var(--text-muted); }
[data-theme="light"] .ai-tab-btn:hover { color: var(--text-secondary); background: var(--bg-hover); }
[data-theme="light"] .ai-tab-btn.active {
    background: var(--bg-card);
    color: var(--text-primary);
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

[data-theme="light"] #vp-chat { background: transparent; }

[data-theme="light"] .chat-messages::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.12); }
[data-theme="light"] .ai-vp-scroll::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.12); }

[data-theme="light"] .cmsg-ai-wrap .prose h2,
[data-theme="light"] .cmsg-system-wrap .prose h2,
[data-theme="light"] .cmsg-ai-wrap .prose h3,
[data-theme="light"] .cmsg-system-wrap .prose h3 { color: var(--text-primary); }

[data-theme="light"] .cmsg-ai-wrap .prose code,
[data-theme="light"] .cmsg-system-wrap .prose code { background: rgba(0,0,0,0.06); }

[data-theme="light"] .cmsg-ai-wrap .prose a,
[data-theme="light"] .cmsg-system-wrap .prose a { color: var(--primary); }

[data-theme="light"] .ai-footer {
    background: transparent;
    border-top-color: rgba(0,0,0,0.08);
}
[data-theme="light"] .chat-drop-overlay {
    background: rgba(91, 76, 219, 0.06);
    border-color: color-mix(in srgb, var(--primary, #5b4cdb) 50%, transparent);
    color: var(--primary, #5b4cdb);
}

[data-theme="light"] .chat-input-wrap {
    background: #ffffff;
    border-color: #e5e5e5;
}
[data-theme="light"] .chat-input-wrap:focus-within {
    border-color: #999;
}

[data-theme="light"] #chatInput {
    color: #1f2937;
    caret-color: #1f2937;
}
[data-theme="light"] #chatInput::placeholder { color: #9ca3af; }

[data-theme="light"] .chat-reset-btn {
    color: #9ca3af;
}
[data-theme="light"] .chat-reset-btn:hover {
    background: #f3f4f6;
    color: #374151;
}

[data-theme="light"] .chat-send-btn {
    background: #111111;
    color: #ffffff;
}
[data-theme="light"] .chat-send-btn:hover:not(:disabled) {
    background: #333333;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
[data-theme="light"] .chat-send-btn--stop {
    background: color-mix(in srgb, #111111 16%, #ffffff);
}
[data-theme="light"] .chat-send-btn--stop:hover {
    background: color-mix(in srgb, #111111 26%, #ffffff);
}

#chatScrollBtn:hover {
    background: #f3f4f6;
    box-shadow: 0 2px 10px rgba(0,0,0,.3);
}
[data-theme="light"] #chatScrollBtn {
    background: #111111;
    color: #ffffff;
}
[data-theme="light"] #chatScrollBtn:hover {
    background: #333333;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

[data-theme="light"] .cmsg { color: var(--text-primary); }

[data-theme="light"] .cmsg-ai,
[data-theme="light"] .cmsg-system {
    background: var(--bg-card);
    border-color: var(--border);
    box-shadow: 0 8px 20px rgba(0,0,0,0.06);
}
[data-theme="light"] .cmsg-ai::before,
[data-theme="light"] .cmsg-system::before { background: var(--bg-card); }

[data-theme="light"] .cmsg-system {
    background: var(--bg-secondary);
    color: var(--text-secondary);
}

[data-theme="light"] .cmsg-code-inline,
[data-theme="light"] .cmsg-ai code,
[data-theme="light"] .cmsg-system code,
[data-theme="light"] .cmsg-user code { background: rgba(0,0,0,0.06); }

[data-theme="light"] .cmsg-card {
    background: var(--bg-card);
    border-color: var(--border);
}

[data-theme="light"] .cmsg-card .cc-pack-title,
[data-theme="light"] .cmsg-card .cc-q,
[data-theme="light"] .cmsg-card .cc-fc-front {
    color: var(--text-primary);
    border-bottom-color: var(--border);
    background: var(--bg-secondary);
}

[data-theme="light"] .cmsg-card .cc-pack-item {
    color: var(--text-secondary);
    border-top-color: var(--border);
}
[data-theme="light"] .cmsg-card .cc-pack-item:hover { background: var(--bg-hover); }

[data-theme="light"] .cmsg-card .cc-opt {
    border-color: var(--border);
    background: var(--bg-secondary);
    color: var(--text-secondary);
}
[data-theme="light"] .cmsg-card .cc-opt:hover:not(:disabled) { background: var(--bg-hover); }

[data-theme="light"] .cmsg-card .cc-divider { border-top-color: var(--border); }

[data-theme="light"] .cmsg-card .cc-fc-back { color: var(--text-secondary); }

[data-theme="light"] .cmsg-card .cc-opt--correct {
    background: rgba(34,197,94,0.08);
    border-color: rgba(34,197,94,0.25);
    color: #166534;
}

[data-theme="light"] .cmsg-card .cc-opt--wrong {
    background: rgba(239,68,68,0.06);
    border-color: rgba(239,68,68,0.2);
    color: #991b1b;
}

[data-theme="light"] .finish-lesson-btn {
    background: rgba(16,185,129,0.08);
    color: #059669;
}
[data-theme="light"] .finish-lesson-btn:hover { background: rgba(16,185,129,0.16); }

/* ── NEW bubble system light mode ── */
[data-theme="light"] .cmsg-bubble--user {
    background: var(--border);
    border-color: var(--border);
    color: #0f172a;
}

[data-theme="light"] .cmsg-text--ai,
[data-theme="light"] .cmsg-text--system {
    color: #1e293b;
    padding: 10px 13px;
}
[data-theme="light"] .cmsg-text--ai strong,
[data-theme="light"] .cmsg-text--system strong { color: var(--text-primary); }
[data-theme="light"] .cmsg-text--ai h2,
[data-theme="light"] .cmsg-text--system h2,
[data-theme="light"] .cmsg-text--ai h3,
[data-theme="light"] .cmsg-text--system h3 { color: var(--text-primary); }
[data-theme="light"] .cmsg-text--ai code,
[data-theme="light"] .cmsg-text--system code {
    background: rgba(0,0,0,0.06);
    color: var(--text-primary);
}
[data-theme="light"] .cmsg-text--ai pre,
[data-theme="light"] .cmsg-text--system pre {
    background: var(--bg-secondary);
    border-color: var(--border);
}
[data-theme="light"] .cmsg-text--ai pre code,
.cmsg-text--system pre code { color: var(--text-primary); }

[data-theme="light"] .cmsg-text--ai h1,
[data-theme="light"] .cmsg-text--system h1,
[data-theme="light"] .cmsg-text--ai h4,
[data-theme="light"] .cmsg-text--system h4 { color: var(--text-primary); }
[data-theme="light"] .cmsg-text--ai h5,
[data-theme="light"] .cmsg-text--system h5,
[data-theme="light"] .cmsg-text--ai h6,
[data-theme="light"] .cmsg-text--system h6 { color: var(--text-muted); }
[data-theme="light"] .cmsg-text--ai blockquote,
[data-theme="light"] .cmsg-text--system blockquote { color: var(--text-muted); }
[data-theme="light"] .cmsg-text--ai hr,
[data-theme="light"] .cmsg-text--system hr { border-top-color: var(--border); }
[data-theme="light"] .cmsg-text--ai th,
[data-theme="light"] .cmsg-text--system th {
    background: rgba(0,0,0,0.04);
    color: var(--text-primary);
    border-bottom-color: var(--border);
}
[data-theme="light"] .cmsg-text--ai td,
[data-theme="light"] .cmsg-text--system td {
    color: var(--text-secondary);
    border-bottom-color: var(--border);
}

[data-theme="light"] .cmsg-actions {
    background: var(--bg-card);
    border-color: var(--border);
}
[data-theme="light"] .cmsg-action-btn { color: var(--text-muted); }
[data-theme="light"] .cmsg-action-btn:hover { color: var(--text-primary); background: var(--bg-hover); }


[data-theme="light"] .fi-blank-placeholder,
[data-theme="light"] .fill-underline,
[data-theme="light"] .fc-face .border-b-2 {
    border-bottom-color: var(--border);
    background: var(--bg-secondary);
    color: var(--text-muted);
}
[data-theme="light"] .fc-face .border-b-2:hover,
[data-theme="light"] .fi-blank-placeholder:focus {
    border-bottom-color: var(--text-secondary);
    background: var(--bg-hover);
}

/* ── Tiptap/notes editor light mode ── */
[data-theme="light"] .notes-prosemirror {
    color: var(--text-primary);
    caret-color: var(--primary);
}
[data-theme="light"] .notes-prosemirror blockquote {
    border-left-color: var(--primary);
    color: var(--text-secondary);
}
[data-theme="light"] .notes-prosemirror pre {
    background: rgba(0,0,0,0.04);
    border-color: var(--border);
}
[data-theme="light"] .notes-prosemirror code {
    background: rgba(0,0,0,0.06);
}
[data-theme="light"] .notes-prosemirror ::selection {
    background: rgba(91,76,219,0.18);
}
[data-theme="light"] .notes-prosemirror:empty::before {
    color: var(--text-muted);
}

/* ── Flashcards tab light mode ── */
[data-theme="light"] .fc-counter { color: var(--text-muted); }
[data-theme="light"] .fc-face {
    background: var(--bg-card);
    border-color: var(--border);
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
[data-theme="light"] .fc-icon { color: var(--text-muted); }
[data-theme="light"] .fc-question { color: var(--text-primary); }
[data-theme="light"] .fc-hint { color: var(--text-muted); }
[data-theme="light"] .fc-hint kbd {
    background: var(--bg-secondary);
    border-color: var(--border);
    color: var(--text-muted);
}
[data-theme="light"] .fc-answer { color: var(--text-primary); }

/* ── Quiz tab light mode ── */
[data-theme="light"] .qz-question { color: var(--text-primary); }
[data-theme="light"] .qz-opt-card {
    background: var(--bg-card);
    border-color: var(--border);
    color: var(--text-primary);
}
[data-theme="light"] .qz-opt-card:hover:not(.correct):not(.wrong) {
    border-color: var(--text-secondary);
    background: var(--bg-hover);
}
[data-theme="light"] .qz-opt-card.selected {
    border-color: var(--primary);
    background: var(--primary-soft, rgba(99,102,241,0.08));
}
[data-theme="light"] .qz-opt-card.correct {
    border-color: #22c55e;
    background: rgba(34,197,94,0.08);
}
[data-theme="light"] .qz-opt-card.wrong {
    border-color: #ef4444;
    background: rgba(239,68,68,0.06);
}

/* ── Fill-in tab light mode ── */
[data-theme="light"] .fc-face input[type="text"].fi-blank,
[data-theme="light"] #fiStage input[type="text"].fi-blank {
    border-bottom-color: var(--border);
    color: var(--text-primary);
}
[data-theme="light"] #fiSentence { color: var(--text-primary); }
[data-theme="light"] .fi-blank {
    border-bottom-color: var(--border);
    color: var(--text-primary);
}
[data-theme="light"] #fiGotIt,
[data-theme="light"] #fiGotItInner {
    box-shadow: none;
}

/* ── Podcast tab light mode ── */
[data-theme="light"] .podcast-empty-title { color: var(--text-primary); }
[data-theme="light"] .podcast-empty-sub { color: var(--text-secondary); }
[data-theme="light"] .podcast-gen-status { color: var(--text-muted); }
[data-theme="light"] .podcast-ep-title { color: var(--text-primary); }
[data-theme="light"] .pc-convo { scrollbar-color: rgba(0,0,0,0.12) transparent; }
[data-theme="light"] .pc-ctrl-btn {
    background: transparent;
    color: var(--text-muted);
}
[data-theme="light"] .pc-ctrl-btn:hover { color: var(--text-primary); background: var(--bg-hover); }
[data-theme="light"] .pc-progress-track { background: var(--border); }
[data-theme="light"] .pc-progress-handle { box-shadow: 0 0 0 2px var(--bg-card); }
[data-theme="light"] .pc-progress-fill { background: var(--primary); }
[data-theme="light"] .pc-volume-fill { background: var(--primary); }
[data-theme="light"] .podcast-play-btn { background: var(--primary); color: #fff; box-shadow: 0 3px 12px color-mix(in srgb, var(--primary) 25%, transparent); }
[data-theme="light"] .podcast-regen-btn { color: var(--text-muted); }
[data-theme="light"] .podcast-regen-btn:hover { color: var(--text-secondary); }
[data-theme="light"] .pc-hero {
    background: var(--bg-card);
    border-color: var(--border);
}
[data-theme="light"] .pc-raise-hand {
    background: color-mix(in srgb, var(--primary) 8%, transparent);
    border-color: color-mix(in srgb, var(--primary) 25%, transparent);
    color: var(--primary);
}
[data-theme="light"] .pc-raise-hand:hover {
    background: color-mix(in srgb, var(--primary) 15%, transparent);
    border-color: color-mix(in srgb, var(--primary) 40%, transparent);
}
[data-theme="light"] .pc-convo-wrap {
    border-color: var(--border);
    background: var(--bg-card);
}
[data-theme="light"] .pc-bubble-body--tutor .pc-bubble-text {
    background: var(--bg-hover);
}
[data-theme="light"] .pc-bubble-body--student .pc-bubble-text {
    background: color-mix(in srgb, var(--primary) 8%, var(--bg-card));
}
[data-theme="light"] .pc-bubble-name { color: var(--text-muted); }
[data-theme="light"] .podcast-play-btn { box-shadow: 0 3px 12px rgba(0,0,0,0.08); }


/* ── Video placeholder light mode ── */
[data-theme="light"] .video-placeholder {
    background: var(--bg-secondary);
    color: var(--text-muted);
}

@media (max-width: 768px) {
    [data-theme="light"] .pane-ai { border-top-color: var(--border); }
}

/* ── NOTES DOCUMENT RENDERER ─────────────────────────────────────────────── */
.notes-doc-wrap {
    position: absolute;
    inset: 0;
    overflow-y: auto;
    padding: 40px 48px;
}
.notes-doc {
    max-width: 720px;
    margin: 0 auto;
    color: var(--sr-ink);
    font-size: 0.92rem;
    line-height: 1.8;
}
.notes-doc-title {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--sr-ink);
    margin: 0 0 6px;
    line-height: 1.2;
}
.notes-doc-meta {
    font-size: 0.78rem;
    color: var(--sr-muted);
    margin-bottom: 32px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
}
.notes-section {
    margin-bottom: 36px;
}
.notes-section-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--sr-blue);
    margin: 0 0 14px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--sr-border);
}
.notes-p {
    margin: 0 0 12px;
    color: var(--sr-ink);
}
.notes-definition {
    background: var(--sr-hover);
    border-left: 3px solid var(--sr-blue);
    border-radius: 0 8px 8px 0;
    padding: 10px 14px;
    margin: 12px 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.notes-definition-term {
    font-weight: 700;
    color: var(--sr-blue);
    font-size: 0.88rem;
}
.notes-definition-body {
    color: var(--sr-ink);
    font-size: 0.88rem;
}
.notes-formula {
    background: color-mix(in srgb, var(--primary,#4ecdc4) 6%, transparent);
    border: 1px solid color-mix(in srgb, var(--primary,#4ecdc4) 20%, transparent);
    border-radius: 8px;
    padding: 12px 16px;
    margin: 12px 0;
}
.notes-formula-label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--sr-blue);
    margin-bottom: 4px;
}
.notes-formula-text {
    font-family: 'Courier New', monospace;
    font-size: 0.95rem;
    color: var(--sr-ink);
    display: block;
    white-space: pre-wrap;
}
.notes-list {
    margin: 8px 0 12px 0;
    padding-left: 1.4rem;
}
.notes-list li {
    margin-bottom: 6px;
    color: var(--sr-ink);
}
.notes-example {
    background: rgba(245, 158, 11, 0.06);
    border: 1px solid rgba(245, 158, 11, 0.2);
    border-radius: 8px;
    padding: 14px 16px;
    margin: 12px 0;
}
.notes-example-label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--sr-gold);
    margin-bottom: 6px;
}
.notes-steps {
    margin: 8px 0 0 0;
    padding-left: 1.4rem;
}
.notes-steps li {
    margin-bottom: 4px;
    color: var(--sr-ink);
}
.notes-callout {
    background: rgba(148, 163, 184, 0.08);
    border-left: 3px solid var(--sr-muted);
    border-radius: 0 8px 8px 0;
    padding: 10px 14px;
    margin: 12px 0;
    color: var(--sr-muted);
    font-style: italic;
    font-size: 0.88rem;
}
.notes-table-wrap {
    overflow-x: auto;
    margin: 12px 0;
}
.notes-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}
.notes-table th {
    background: var(--sr-hover);
    color: var(--sr-ink);
    font-weight: 700;
    padding: 8px 12px;
    text-align: left;
    border-bottom: 2px solid var(--sr-border);
}
.notes-table td {
    padding: 7px 12px;
    border-bottom: 1px solid var(--sr-border);
    color: var(--sr-ink);
}
.notes-summary {
    background: color-mix(in srgb, var(--primary,#4ecdc4) 4%, transparent);
    border: 1px solid color-mix(in srgb, var(--primary,#4ecdc4) 15%, transparent);
    border-radius: 12px;
    padding: 20px 24px;
}
.notes-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--sr-muted);
    font-size: 0.88rem;
    text-align: center;
    padding: 48px 24px;
}

/* ── CHAT MESSAGE BUBBLES ────────────────────────────────────────────────── */
.cmsg-user-wrap {
    display: flex;
    justify-content: flex-end;
    position: relative;
    padding-bottom: 22px; /* room for absolutely-positioned cmsg-actions */
}
.cmsg-ai-wrap,
.cmsg-system-wrap {
    display: flex;
    justify-content: flex-start;
    position: relative;
    padding-bottom: 22px;
}

/* ── User: pill bubble, right-aligned ── */
.cmsg-bubble--user {
    max-width: 78%;
    background: #2a2a2a;;
    border:#2a2a2a;
    border-radius: 18px 18px 4px 18px;
    padding: 10px 14px;
    font-size: 1rem;
    line-height: 1.6;
    word-break: break-word;
    margin-left: auto;
}

.cmsg-context-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: color-mix(in srgb, var(--primary, #4ecdc4) 80%, #fff);
    opacity: 0.75;
    margin-bottom: 4px;
    cursor: pointer;
    transition: opacity 0.12s;
}
.cmsg-context-chip:hover { opacity: 1; }

/* ── Chat lightbox (image + context viewer) ── */
.chat-lightbox {
    position: absolute;
    inset: 0;
    z-index: 200;
    background: rgba(0, 0, 0, 0.82);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    animation: chatLbFadeIn 0.18s ease;
}
@keyframes chatLbFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}
.chat-lightbox-close {
    position: absolute;
    top: 12px; right: 14px;
    background: rgba(255,255,255,0.12);
    border: none;
    color: #fff;
    font-size: 1.35rem;
    line-height: 1;
    width: 32px; height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background 0.12s;
    z-index: 1;
}
.chat-lightbox-close:hover { background: rgba(255,255,255,0.24); }

.chat-lightbox-inner {
    max-width: 100%;
    max-height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

/* Image viewer */
.chat-lightbox-img-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    max-width: 100%;
    max-height: calc(100vh - 96px);
}
.chat-lightbox-img-wrap img {
    max-width: 100%;
    max-height: calc(100vh - 96px);
    border-radius: 10px;
    object-fit: contain;
    box-shadow: 0 8px 40px rgba(0,0,0,0.6);
    user-select: none;
    -webkit-user-select: none;
}

/* Context text viewer */
.chat-lightbox-ctx-wrap {
    background: var(--bg-card, #1e1e2e);
    border: 1px solid color-mix(in srgb, var(--primary, #818cf8) 30%, transparent);
    border-radius: 14px;
    padding: 20px 24px;
    max-width: min(520px, 90vw);
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    box-shadow: 0 8px 40px rgba(0,0,0,0.5);
}
.chat-lightbox-ctx-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: color-mix(in srgb, var(--primary, #818cf8) 80%, #fff);
    margin-bottom: 14px;
    opacity: 0.85;
}
.chat-lightbox-ctx-text {
    font-size: 0.875rem;
    line-height: 1.65;
    color: var(--text-primary, #e2e8f0);
    white-space: pre-wrap;
    word-break: break-word;
}

/* Make preview-bar thumbnails and context bar clickable */
.chat-img-preview-item { cursor: pointer; }
.chat-context-bar { cursor: default; }
.chat-context-text { cursor: pointer; }
.chat-context-text:hover { text-decoration: underline; text-underline-offset: 2px; }
.chat-attached-image { cursor: zoom-in; }

[data-theme="light"] .chat-lightbox-ctx-wrap {
    background: #fff;
    border-color: color-mix(in srgb, var(--primary, #5b4cdb) 25%, transparent);
}
[data-theme="light"] .chat-lightbox-ctx-text { color: #1e1e2e; }

/* ── AI / system: no bubble, plain text ── */
.cmsg-text--ai,
.cmsg-text--system {
    max-width: 92%;
    font-size: 0.875rem;
    line-height: 1.65;
    color: #d4d4d4;
    word-break: break-word;
}
.cmsg-text--ai,
.cmsg-text--system,
.cmsg-text--ai *,
.cmsg-text--system *,
.cmsg-user-wrap,
.cmsg-user-wrap * {
    user-select: text;
    -webkit-user-select: text;
}
.cmsg-text--ai mjx-container,
.cmsg-text--system mjx-container,
.cmsg-text--ai .MathJax,
.cmsg-text--system .MathJax,
.cmsg-text--ai .MathJax_SVG,
.cmsg-text--system .MathJax_SVG {
    user-select: text;
    -webkit-user-select: text;
}

/* Display-mode math rows: horizontally scrollable, scrollbar hidden */
.cmsg-text--ai mjx-container[display="true"],
.cmsg-text--system mjx-container[display="true"] {
    display: block;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 4px 0;
    max-width: 100%;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.cmsg-text--ai mjx-container[display="true"]::-webkit-scrollbar,
.cmsg-text--system mjx-container[display="true"]::-webkit-scrollbar {
    display: none;
}
.cmsg-text--ai p,
.cmsg-text--system p { margin: 0.8em 0; }
.cmsg-text--ai p:first-child,
.cmsg-text--system p:first-child { margin-top: 0; }
.cmsg-text--ai p:last-child,
.cmsg-text--system p:last-child  { margin-bottom: 0; }
.cmsg-text--ai strong,
.cmsg-text--system strong { font-weight: 700; color: #ffffff; }
.cmsg-text--ai ul,
.cmsg-text--ai ol,
.cmsg-text--system ul,
.cmsg-text--system ol { margin: 0.7em 0; padding-left: 1.3em; }
.cmsg-text--ai ul { list-style: disc; }
.cmsg-text--ai ol { list-style: decimal; }
.cmsg-text--ai li,
.cmsg-text--system li { margin: 0.35em 0; }
.cmsg-text--ai h2,
.cmsg-text--system h2 { font-size: 1.05rem; font-weight: 700; margin: 1em 0 0.35em; color: #ffffff; }
.cmsg-text--ai h3,
.cmsg-text--system h3 { font-size: 1rem; font-weight: 700; margin: 0.9em 0 0.3em; color: #ffffff; }
.cmsg-text--ai code,
.cmsg-text--system code {
    background: rgba(255,255,255,0.08);
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 0.82em;
    font-family: 'Courier New', monospace;
    color: var(--primary,#4ecdc4);
}
.cmsg-text--ai pre,
.cmsg-text--system pre {
    background: #0d0d0d;
    border: 1px solid #2a2a2a;
    border-radius: 8px;
    padding: 10px 12px;
    overflow-x: auto;
    margin: 0.5em 0;
}
.cmsg-text--ai pre code,
.cmsg-text--system pre code { background: none; padding: 0; color: #e2e8f0; }

.cmsg-text--ai h1,
.cmsg-text--system h1 { font-size: 1.15rem; font-weight: 800; margin: 1em 0 0.35em; color: #ffffff; }
.cmsg-text--ai h4,
.cmsg-text--system h4 { font-size: 0.92rem; font-weight: 600; margin: 0.8em 0 0.25em; color: #ffffff; }
.cmsg-text--ai h5,
.cmsg-text--system h5,
.cmsg-text--ai h6,
.cmsg-text--system h6 { font-size: 0.85rem; font-weight: 600; margin: 0.7em 0 0.2em; color: #9ca3af; }
.cmsg-text--ai hr,
.cmsg-text--system hr { border: none; border-top: 1px solid #333; margin: 0.8em 0; }
.cmsg-text--ai blockquote,
.cmsg-text--system blockquote {
    border-left: 3px solid var(--primary,#7c6cfa);
    padding: 0.4em 0 0.4em 14px;
    margin: 0.7em 0;
    color: #9ca3af;
    font-style: italic;
    background: rgba(255,255,255,0.03);
    border-radius: 0 6px 6px 0;
}
.cmsg-text--ai .md-table-wrap,
.cmsg-text--system .md-table-wrap { overflow-x: auto; margin: 0.5em 0; }
.cmsg-text--ai table,
.cmsg-text--system table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
.cmsg-text--ai th,
.cmsg-text--system th {
    background: rgba(255,255,255,0.06);
    padding: 10px 14px;
    text-align: left;
    font-weight: 700;
    border-bottom: 2px solid #333;
    color: #e2e8f0;
}
.cmsg-text--ai td,
.cmsg-text--system td {
    padding: 10px 14px;
    border-bottom: 1px solid #2a2a2a;
    color: #d1d5db;
}

/* ── system greeting: slightly dimmer ── */
.cmsg-text--system { font-size: 1rem; }

/* ── Actions (copy/edit) — absolutely positioned, never affect bubble height ── */
.cmsg-actions {
    position: absolute;
    bottom: -4px;
    display: flex;
    align-items: center;
    gap: 2px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s;
    z-index: 10;
    background: #1a1a1a;
    border: 1px solid #2a2a2a;
    border-radius: 7px;
    padding: 2px 3px;
}
.cmsg-actions--user { right: 12px; }
.cmsg-ai-wrap    .cmsg-actions,
.cmsg-system-wrap .cmsg-actions { left: 12px; }
.cmsg-user-wrap:hover .cmsg-actions,
.cmsg-ai-wrap:hover .cmsg-actions,
.cmsg-system-wrap:hover .cmsg-actions {
    opacity: 1;
    pointer-events: auto;
}
.cmsg-action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    border: none;
    border-radius: 5px;
    background: transparent;
    color: #666666;
    cursor: pointer;
    transition: color 0.12s, background 0.12s;
}
.cmsg-action-btn:hover { color: #ffffff; background: rgba(255,255,255,0.08); }

/* ── THINKING BUBBLE ─────────────────────────────────────────────────────── */
.cmsg-thinking {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 0;
    min-height: 44px;
    width: fit-content;
}

/* ── Animated ring ── */
.cmsg-thinking-ring {
    flex-shrink: 0;
    animation: cmsgRingSpin 1s linear infinite;
}
@keyframes cmsgRingSpin {
    to { transform: rotate(360deg); }
}
.cmsg-ring-bg { stroke: color-mix(in srgb, var(--primary, #7c6cfa) 20%, transparent); stroke-width: 4; fill: none; }
.cmsg-ring-fg { stroke: var(--primary, #7c6cfa); stroke-width: 4; fill: none; stroke-linecap: round; stroke-dasharray: 80, 140; }
[data-theme="light"] .cmsg-ring-bg { stroke: color-mix(in srgb, var(--primary, #5b4cdb) 20%, transparent); }
[data-theme="light"] .cmsg-ring-fg { stroke: var(--primary, #5b4cdb); }

/* ── Shimmering text ── */
.cmsg-thinking-text {
    font-size: 0.88rem;
    font-weight: 500;
    line-height: 1.4;
    color: var(--text-secondary, #a0a0a8);
}
.cmsg-thinking-text--shimmer {
    background: linear-gradient(
        90deg,
        color-mix(in srgb, var(--text-secondary, #a0a0a8) 88%, #c7ced8 12%) 0%,
        color-mix(in srgb, #ffffff 78%, var(--text-primary, #f1f1f3) 22%) 28%,
        #ffffff 50%,
        color-mix(in srgb, #ffffff 78%, var(--text-primary, #f1f1f3) 22%) 72%,
        color-mix(in srgb, var(--text-secondary, #a0a0a8) 88%, #c7ced8 12%) 100%
    );
    background-size: 200% auto;
    color: transparent;
    -webkit-background-clip: text;
    background-clip: text;
    animation: cmsgShimmer 3s linear infinite;
}
@keyframes cmsgShimmer {
    to { background-position: 200% center; }
}

/* ── Inline post-response suggestion pills ─────────────────────────────── */
.chat-inline-suggestions {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 7px;
    padding: 6px 0 4px;
    /* Animate in */
    animation: chatSuggestFadeIn 0.25s ease both;
}

@keyframes chatSuggestFadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.chat-suggestion-pill {
    display: inline-flex;
    align-items: center;
    padding: 7px 13px;
    border: 1px solid var(--sr-border);
    border-radius: 20px;
    background: transparent;
    color: var(--sr-muted);
    font-size: 0.82rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    line-height: 1.3;
    /* Width naturally matches text content — no fixed width */
    white-space: nowrap;
    transition: background 0.14s, color 0.14s, border-color 0.14s, transform 0.1s;
    user-select: none;
}
.chat-suggestion-pill:hover {
    background: var(--sr-hover);
    color: var(--sr-ink);
    border-color: var(--sr-border-hover);
}
.chat-suggestion-pill:active { transform: translateY(0); }

/* Light mode overrides */
[data-theme="light"] .chat-suggestion-pill {
    background: #ffffff;
    border-color: rgba(0,0,0,0.1);
    color: #475569;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
[data-theme="light"] .chat-suggestion-pill:hover {
    background: #f8fafc;
    border-color: rgba(0,0,0,0.18);
    color: #0f172a;
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}

.fi-blank-placeholder, .fill-underline, .fc-face .border-b-2 {
    display: inline-block;
    min-width: 120px;
    border-bottom: 2px solid rgba(255,255,255,0.12);
    padding: 6px 10px;
    border-radius: 6px;
    background: rgba(255,255,255,0.02);
    color: var(--sr-light);
    vertical-align: middle;
    transition: border-color 0.15s, background 0.15s;
}
.fc-face .border-b-2:hover, .fi-blank-placeholder:focus {
    border-bottom-color: rgba(255,255,255,0.18);
    background: rgba(255,255,255,0.03);
}

/* Input inside the Fill-In card — let .fi-blank handle all inline styling */
.fc-face input[type="text"].fi-blank, #fiStage input[type="text"].fi-blank {
    all: unset;
    display:        inline-block;
    min-width:      100px;
    max-width:      260px;
    border-bottom:  2px solid #555;
    background:     transparent;
    color:          #FCF6F5;
    font-size:      1.25rem;
    font-family:    inherit;
    font-weight:    700;
    padding:        2px 8px;
    text-align:     center;
    vertical-align: baseline;
    margin:         0 4px;
    box-sizing:     border-box;
    transition:     border-color 0.18s, color 0.18s;
    cursor:         text;
}
.fc-face input[type="text"].fi-blank:focus {
    outline: none;
    border-bottom-color: #8b5cf6;
    background: rgba(139, 92, 246, 0.06);
}
.fc-face input[type="text"].fi-blank.-filled { border-bottom-color: #8b5cf6; }
.fc-face input[type="text"].fi-blank.correct,
#fiStage input[type="text"].fi-blank.correct  { border-bottom-color: #4ade80; color: #4ade80; background: rgba(34, 197, 94, 0.12); }
.fc-face input[type="text"].fi-blank.wrong,
#fiStage input[type="text"].fi-blank.wrong    { border-bottom-color: #f87171; color: #f87171; text-decoration: line-through; background: rgba(239, 68, 68, 0.12); }
.fc-face input[type="text"]::placeholder      { color: transparent; }
    
/* Make the Fill-In card visually match the screenshot */
.fc-face {
    box-shadow: 0 8px 24px rgba(0,0,0,0.6);
}

#fiStage #fiSentence {
    font-size: 1rem
}

@media (max-height: 760px) {
    .fc-shell {
        padding: 8px 0 8px;
    }

    .fc-content {
        gap: 12px;
    }

    .fc-stage {
        height: clamp(180px, 40vh, 270px);
    }

    .fc-face {
        padding: 20px;
        border-radius: 20px;
    }

    .fc-question {
        font-size: 1rem;
    }

    .fc-hint {
        font-size: 0.7rem;
    }

    .fc-nav-bar-btn {
        width: 36px;
        height: 36px;
    }

    .fc-nav-bar-btn svg {
        width: 18px;
        height: 18px;
    }

    #fiStage .fc-face {
        height: 100%;
    }

    #fiStage .fc-face-inner {
        gap: 8px;
    }

    #fiStage .fc-face .fi-hint-btn,
    #fiStage .fc-face #fiGotIt {
        padding: 8px 12px;
    }

    #fiStage #fiSentence {
        font-size: 1.2rem;
        line-height: 1.7;
    }

    .fc-empty .vp-gate {
        min-height: 0 !important;
        padding: 24px 18px !important;
    }

    .fc-empty .vp-gate > div:first-child {
        width: 40px !important;
        height: 40px !important;
        min-width: 40px !important;
        min-height: 40px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        font-size: 0 !important;
        margin-bottom: 8px !important;
    }

    .fc-empty .vp-gate > div:first-child svg {
        width: 40px !important;
        height: 40px !important;
        display: block !important;
        flex: none !important;
    }

    .fc-empty .vp-gate button {
        padding: 8px 16px !important;
        font-size: 0.82rem !important;
    }

    .fc-empty .vp-gate > div:nth-of-type(2) {
        font-size: 0.95rem !important;
        margin-bottom: 4px !important;
    }

    .fc-empty .vp-gate > div:nth-of-type(3),
    .fc-empty .vp-gate > div:nth-of-type(4) {
        font-size: 0.74rem !important;
        margin-top: 8px !important;
    }
}

/* ── Mobile: narrow viewport flashcard sizing ── */
@media (max-width: 640px) {
    .fc-shell {
        padding: 0 16px;
    }

    .podcast-shell {
        padding: 0;
    }

    .podcast-player {
        max-width: 400px;
        padding: 12px 12px 0;
    }

    .pc-hero-body {
        padding: 14px 14px;
    }

    .pc-hero { border-radius: 12px; }

    .fc-content,
    .podcast-content {
        gap: 10px;
    }

    .fc-face {
        width: 100%;
        max-width: 100%;
        padding: 20px 18px;
        border-radius: 18px;
    }

    .fc-stage {
        height: auto;
        min-height: 300px;
        max-height: unset;
    }

    .fc-nav-bar-btn {
        width: 36px;
        height: 36px;
    }

    .fc-nav-bar-btn svg {
        width: 18px;
        height: 18px;
    }

    #tab-quiz .fc-content {
        justify-content: center;
        padding-bottom: 40px;
    }

    #tab-flashcards .fc-content {
        justify-content: center;
        padding-bottom: 10rem;
    }

    #tab-quiz .qz-question {
        font-size: 1.05rem;
        margin-bottom: 16px;
    }

    #tab-quiz .qz-opt-card {
        padding: 16px;
        font-size: 0.9rem;
        border-radius: 14px;
    }

    #tab-quiz .qz-answer-row {
        font-size: 0.88rem;
        padding: 10px 0 4px;
    }

    #tab-quiz .qz-explanation-row {
        font-size: 0.85rem;
        padding: 4px 0 16px;
    }

    #tab-more .fc-content {
        justify-content: center;
        padding-bottom: 16px;
    }
    .fc-btn-row {
        width: 100%;
        flex-direction: column;
    }
    .fc-action-btn kbd {
        display: none;
    }

    #fiStage #fiSentence {
        font-size: 1.05rem;
        line-height: 1.6;
    }

    .fc-face input[type="text"].fi-blank, #fiStage input[type="text"].fi-blank {
        font-size: 1.05rem;
    }

}

/* Fill-in tab: let .fc-content center naturally like other tabs */

/* Fill-in stage: no flip, height with clamp, wider to match reference */
#fiStage {
    position: relative;
    inset: auto;
    width: 100%;
    height: clamp(320px, 55vh, 560px);
    max-width: 720px;
    cursor: default;
    perspective: none;
}

/* Fill-in face: fill stage height so card chain stretches correctly */
#fiStage .fc-face {
    position: relative;
    inset: auto;
    width: 100%;
    height: 100%;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 0;
    box-shadow: none;
    max-width: none;
    margin: 0;
    display: flex;
    flex-direction: column;
    backface-visibility: visible;
    -webkit-backface-visibility: visible;
    transition: none;
}

/* Fill-in face-inner: cardless container */
#fiStage .fc-face-inner {
    display: flex;
    flex-direction: column;
    height: 100%;
    align-items: stretch;
    text-align: center;
    gap: 0;
    flex: 1;
    min-height: 0;
    padding: 32px 28px;
}

/* #fiSentence: inline-flex so text and blank sit on the same baseline */
#fiSentence {
    font-size:       clamp(1.3rem, 3vw, 1.8rem);
    line-height:     1.9;
    text-align:      center;
    display:         inline-flex;
    flex-wrap:       wrap;
    align-items:     baseline;
    justify-content: center;
    gap:             4px;
    font-weight:     700;
    color:           #FCF6F5;
    word-break:      break-word;
}

/* The prose fragment divs inside #fiSentence must display inline */
#fiSentence > div,
#fiSentence > div > div,
#fiSentence > div > div > p,
#fiSentence > div p {
    display: inline !important;
    margin: 0 !important;
    padding: 0 !important;
    gap: 0 !important;
}
#fiSentence .space-y-4 {
    display: inline !important;
}

/* ════════════════════════════════════════════════════════════════════════════
   fill_in_additions.css
   Append to  app/static/css/pages/library/study_room.css  (or import it).

   These rules complement the existing .fi-blank / .fi-sentence rules.
   They do NOT override anything that was already correct — only fill gaps
   exposed by the new engine (dynamic width, multi-blank flow, hint toggle).
   ════════════════════════════════════════════════════════════════════════════ */

/* #fiSentence — defined above in fill-in overrides section */

/* ── Inline blank inputs ─────────────────────────────────────────────────── */
/*
  Width is set dynamically (via style="width:Npx") by the JS engine.
  These rules cover everything else.
*/
.fi-blank {
  display:          inline-block;
  /* width driven by JS — do not set min-width here or it overrides the calc */
  min-width:        80px;
  max-width:        260px;
  border:           none;
  border-bottom:    2px solid #444;
  border-radius:    0;
  background:       transparent;
  color:            #f5f5f5;
  font-size:        1.25rem;
  font-family:      inherit;
  font-weight:      600;
  padding:          2px 6px;
  text-align:       center;
  outline:          none;
  vertical-align:   middle;
  margin:           0 4px;
  transition:       border-color 0.18s, color 0.18s, background 0.18s;
  /* Prevent layout shift when border-bottom colour changes */
  box-sizing:       border-box;
}

/* Focus ring — purple accent to match the design system */
.fi-blank:focus {
  border-bottom-color: #8b5cf6;
  background:          rgba(139, 92, 246, 0.06);
}

/* Live typing (at least one char) */
.fi-blank.-filled {
  border-bottom-color: #8b5cf6;
}

/* Evaluated states */
.fi-blank.correct {
  border-bottom-color: var(--sr-green, #22c55e);
  color:               var(--sr-green, #22c55e);
  background:          rgba(34, 197, 94, 0.12);
}
.fi-blank.wrong {
  border-bottom-color: var(--sr-red, #ef4444);
  color:               var(--sr-red, #ef4444);
  text-decoration:     line-through;
  background:          rgba(239, 68, 68, 0.12);
}

/* Disabled (post-evaluation) — keep colour, remove pointer */
.fi-blank:disabled {
  cursor: default;
  opacity: 1; /* don't fade — the answer is now the primary content */
}

/* ── Hint ─────────────────────────────────────────────────────────────────── */
.fi-hint-btn {
  display:     inline-flex;
  align-items: center;
  gap:         5px;
  font-size:   0.78rem;
  color:       var(--primary);
  background:  transparent;
  border:      none;
  cursor:      pointer;
  padding:     4px 0;
  opacity:     0.75;
  transition:  opacity 0.15s;
}
.fi-hint-btn:hover {
  opacity: 1;
}

.fi-hint-text {
  max-height:    0;
  overflow:      hidden;
  opacity:       0;
  /* transform:     translateY(-4px); */
  font-size:     0.80rem;
  color:         var(--sr-light, #aaa);
  font-style:    italic;
  margin:        0;
  line-height:   1.5;
  text-align:    center;
  flex-shrink:   0;
  transition:    max-height 0.2s ease-out,
                 opacity    0.2s ease-out,
                 transform  0.2s ease-out,
                 padding    0.2s ease-out,
                 margin     0.2s ease-out;
}
.fi-hint-text.-visible {
  max-height: 120px;
  opacity:    1;
  transform:  translateY(0);
  padding:    8px 14px;
  margin:     8px 0;
}

/* ── Feedback wrap ───────────────────────────────────────────────────────── */
#fiFeedbackWrap {
  margin-top:   1rem;
  text-align:   center;
}

.fi-answer-line {
  font-size:   0.95rem;
  color:       #4ade80;
  font-weight: 700;
  margin-bottom: 4px;
}

.fi-explanation-line {
  font-size:   0.82rem;
  color:       #888;
  line-height: 1.6;
}

/* ── Fixed button row ──────────────────────────────────────────────────── */
.fi-btn-row {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-top: 16px;
}

#fiFeedbackWrap.fi-feedback-wrap {
  flex-shrink: 0;
  padding-top: 16px;
}

.fi-gotit-row {
  flex-shrink: 0;
  display: flex;
  justify-content: flex-end;
  padding-top: 16px;
}

/* cardless: fill-in stage content sits flush on tab background */

#fiStage .fi-sentence-wrap {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px 0;
}

/* ── Enter hint (matches quiz tab style) ──────────────────────────────────── */
#fiEnterHintOutside {
    flex-shrink: 0;
    padding: 4px 16px 12px;
    width: 100%;
    text-align: center;
    font-family: var(--font-body);
    font-size: 0.8rem;
    color: var(--text-primary);
    opacity: 0.35;
    pointer-events: none;
}

#fiEnterHintOutside kbd {
    font-family: inherit;
    padding: 2px 6px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.75em;
}

#fiEnterHintOutside.fi-enter-slide {
    animation: fiEnterSlideIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes fiEnterSlideIn {
    0%   { transform: translateY(-8px); }
    100% { transform: translateY(0); }
}

/* ── Result card (correct/wrong) ───────────────────────────────────────── */
.fi-result-badge {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  animation: fiBadgePop 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) 0.15s both;
}
.fi-result-badge.-success { background: #22c55e; }
.fi-result-badge.-wrong   { background: #ef4444; }

.fi-result-title {
  font-size: 1.15rem;
  font-weight: 700;
  margin-top: 0.75rem;
  animation: fiCopyRise 0.35s ease-out 0.3s both;
}
.fi-result-title.-success { color: #22c55e; }
.fi-result-title.-wrong   { color: #ef4444; }

.fi-result-desc {
  font-size: 0.85rem;
  color: #999;
  line-height: 1.5;
  max-width: 340px;
  margin-top: 0.5rem;
  animation: fiCopyRise 0.35s ease-out 0.4s both;
}

/* ── Next button (inside result) ───────────────────────────────────────── */
#fiGotItInner {
  background: #ffffff;
  color: #0a0a0a;
  border: none;
  border-radius: 8px;
  padding: 10px 18px;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.15s;
}
#fiGotItInner:hover {
  background: #f0f0f0;
}

/* ── "Got It / Next" button ────────────────────────────────────────────── */
#fiGotIt {
  background: #8b5cf6;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 22px;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.15s;
}
#fiGotIt:hover {
  background: #7c3aed;
}

@keyframes fiBadgePop {
  0%   { opacity: 0; transform: scale(0.25) rotate(-10deg); }
  60%  { opacity: 1; transform: scale(1.15) rotate(3deg); }
  100% { opacity: 1; transform: scale(1) rotate(0deg); }
}
@keyframes fiCopyRise {
  0%   { opacity: 0; transform: translateY(10px); }
  100% { opacity: 1; transform: translateY(0); }
}

/* ── Responsive tweaks for narrow viewports ─────────────────────────────── */
@media (max-width: 480px) {
  #fiStage .fc-face-inner {
    padding: 20px 16px;
    margin-bottom: 70px;
  }
  .fi-blank {
    min-width:  60px;
    max-width:  180px;
    font-size:  1rem;
  }
  #fiSentence {
    font-size: 1.15rem;
  }

  #tab-quiz .qz-scroll-inner {
    padding: 0 15px;
  }
  #tab-quiz .qz-question {
    font-size: 1.1rem;
    margin-top: 10px;
    margin-bottom: 14px;
  }
  #tab-quiz .qz-opt-card {
    padding: 14px;
    font-size: 1rem;
    border-radius: 12px;
  }
  #tab-quiz .qz-answer-row {
    font-size: 0.85rem;
    padding: 8px 0 3px;
  }
  #tab-quiz .qz-explanation-row {
    font-size: 0.82rem;
    padding: 3px 0 12px;
  }
}


.pane-main.ai-pane-hidden #qzInner {
    max-width: 1100px;
}

.pane-main.ai-pane-hidden .qz-question {
    font-size: 1.25rem;
    margin-bottom: 28px;
}

.pane-main.ai-pane-hidden .qz-options {
    gap: 12px;
    margin-bottom: 24px;
}

.pane-main.ai-pane-hidden .qz-opt-card {
    padding: 18px 22px;
    font-size: 1rem;
    border-radius: 14px;
}

.pane-main.ai-pane-hidden .qz-opt-badge {
    width: 34px;
    height: 34px;
    font-size: 0.9rem;
    border-radius: 8px;
}

.pane-main.ai-pane-hidden #qzAnswer,
.pane-main.ai-pane-hidden #qzExplanation {
    font-size: 1rem;
    max-width: 860px;
    margin-left: auto;
    margin-right: auto;
}

/* Extra width when side navs are collapsed */
.app-shell.with-desktop-side-nav #main-content:not(.nav-expanded) .vt-shell,
.pane-main.ai-pane-hidden .vt-shell {
    max-width: 1000px;
}

/* ── Notes tab: horizontal indeterminate loading bar ── */
.notes-loading-bar-wrap {
  padding: 40px 32px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.notes-loading-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.notes-loading-bar-wrap .notes-gen-phase {
  font-size: 0.82rem;
  color: var(--sr-light, #888);
  font-weight: 500;
}
.notes-gen-pct {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--primary, #5b4cdb);
  letter-spacing: -0.03em;
  line-height: 1;
}
.notes-loading-track {
  height: 3px;
  background: rgba(255,255,255,0.06);
  border-radius: 2px;
  overflow: hidden;
  position: relative;
}
.notes-loading-fill {
  position: absolute;
  top: 0; left: -60%;
  width: 50%;
  height: 100%;
  background: var(--sr-blue, #6366f1);
  border-radius: 2px;
  animation: notes-bar-slide 1.4s ease-in-out infinite;
}
@keyframes notes-bar-slide {
  0%   { left: -60%; }
  100% { left: 110%; }
}

.gen-thinking-dots { display:flex; gap:6px; justify-content:center; }
.gen-thinking-dots span {
    width:8px; height:8px; border-radius:50%; background:var(--primary,#4ecdc4);
    animation:fiDotBounce 1.2s infinite;
}
.gen-thinking-dots span:nth-child(2) { animation-delay:0.2s; }
.gen-thinking-dots span:nth-child(3) { animation-delay:0.4s; }

/* ══ PODCAST TAB ══════════════════════════════════════════════════════════ */
/* ── Podcast Tab: Redesigned Chat Layout ─────────────────────────────────── */

/* Shell */
.podcast-shell {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.podcast-content {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

/* ── Empty state ── */
.podcast-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 40px 24px;
    flex: 1;
}

.podcast-empty-icon { font-size: 1.6rem; margin-bottom: 8px; color: var(--primary); }

.fc-empty .vp-gate > div:first-child,
.qz-empty .vp-gate > div:first-child,
.fi-empty .vp-gate > div:first-child { color: var(--primary); }
.podcast-empty-title { font-size: 0.95rem; font-weight: 700; color: var(--sr-ink); margin-bottom: 8px; }
.podcast-empty-sub   { font-size: 0.74rem; color: var(--sr-muted); line-height: 1.6; margin-bottom: 20px; max-width: 320px; }

.podcast-gen-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 20px;
    border-radius: 10px;
    border: none;
    background: var(--primary);
    color: #fff;
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    transition: opacity 0.15s;
}
.podcast-gen-btn:hover { opacity: 0.85; }
.podcast-gen-status { font-size: 0.78rem; color: var(--sr-muted); min-height: 1.2em; }

/* ── Loading state ── */
.podcast-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    padding: 40px 24px;
}
.podcast-loading-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    text-align: center;
}
.podcast-stage-icon { font-size: 2rem; }
.podcast-stage-label { font-size: 0.92rem; font-weight: 600; color: var(--sr-ink); }
.podcast-stage .gen-thinking-dots { margin-top: 0.75rem; }

@keyframes podcast-spin { to { transform: rotate(360deg); } }
.podcast-spinner { animation: podcast-spin 0.8s linear infinite; transform-origin: center; }

/* ── Player ── */
.podcast-player {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    padding: 12px 16px 0;
    gap: 8px;
    overflow: hidden;
}

/* ── Hero Card ── */
.pc-hero {
    position: relative;
    flex-shrink: 0;
    border-radius: 16px;
    overflow: hidden;
    background: linear-gradient(135deg, color-mix(in srgb, var(--primary) 3%, var(--sr-surface)), var(--sr-surface));
    border: 1px solid var(--sr-border);
    box-shadow: 0 4px 24px rgba(0,0,0,0.06);
}

.pc-hero-bg {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
}
.pc-hero-bg::before {
    content: '';
    position: absolute;
    width: 140px; height: 140px;
    border-radius: 50%;
    top: -40px; right: -30px;
    background: color-mix(in srgb, var(--primary) 10%, transparent);
    filter: blur(28px);
}
.pc-hero-bg::after {
    content: '';
    position: absolute;
    width: 110px; height: 110px;
    border-radius: 50%;
    bottom: -30px; left: -20px;
    background: color-mix(in srgb, #a78bfa 8%, transparent);
    filter: blur(24px);
}

.pc-hero-body {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    z-index: 1;
}

/* Avatar stack */
.pc-avatar-stack {
    position: relative;
    width: 44px;
    height: 44px;
    flex-shrink: 0;
}
.pc-avatar {
    position: absolute;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.75rem;
    color: #fff;
    border: 2px solid var(--sr-surface);
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
    user-select: none;
}
.pc-avatar--tutor {
    background: var(--primary);
    top: 0; left: 0;
    z-index: 2;
}
.pc-avatar--student {
    background: #a78bfa;
    bottom: 0; right: 0;
    z-index: 1;
}

.pc-hero-info { min-width: 0; flex: 1; }
.podcast-ep-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--sr-ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}
.pc-hero-meta {
    display: flex;
    align-items: center;
    gap: 3px;
    margin-top: 1px;
}
.pc-meta-icon { color: var(--sr-muted); flex-shrink: 0; }
.pc-meta-time { font-size: 0.7rem; color: var(--sr-muted); font-weight: 500; }

/* Raise Hand button */
.pc-raise-hand {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 10px;
    border: 1px solid color-mix(in srgb, var(--primary) 25%, transparent);
    background: color-mix(in srgb, var(--primary) 8%, transparent);
    color: var(--primary);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    white-space: nowrap;
    flex-shrink: 0;
}
.pc-raise-hand:hover {
    background: color-mix(in srgb, var(--primary) 15%, transparent);
    border-color: color-mix(in srgb, var(--primary) 40%, transparent);
}
.pc-raise-hand svg { flex-shrink: 0; }
.pc-raise-hand span { display: none; }
@media (min-width: 480px) {
    .pc-raise-hand span { display: inline; }
}

/* ── Progress bar ── */
.pc-progress-area {
    padding: 0 16px 6px;
    flex-shrink: 0;
}
.pc-progress-track {
    position: relative;
    height: 5px;
    border-radius: 4px;
    background: var(--sr-border);
    cursor: pointer;
    overflow: visible;
}
.pc-progress-buffer {
    position: absolute;
    inset: 0;
    border-radius: 4px;
    background: color-mix(in srgb, var(--sr-muted) 15%, transparent);
    transition: width 0.2s;
}
.pc-progress-fill {
    position: absolute;
    inset: 0;
    border-radius: 4px;
    background: var(--sr-ink);
    transition: width 0.1s linear;
    width: 0%;
}
.pc-progress-handle {
    position: absolute;
    top: 50%;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: var(--sr-ink);
    transform: translate(-50%, -50%) scale(0);
    transition: transform 0.15s ease;
    box-shadow: 0 0 0 2px var(--sr-surface);
    pointer-events: none;
    z-index: 2;
}
.pc-progress-track:hover .pc-progress-handle {
    transform: translate(-50%, -50%) scale(1);
}
.pc-progress-time {
    display: flex;
    justify-content: space-between;
    margin-top: 3px;
}
.podcast-time {
    font-size: 0.65rem;
    font-variant-numeric: tabular-nums;
    color: var(--sr-muted);
    font-weight: 500;
}

/* ── Controls ── */
.pc-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px 8px;
    flex-shrink: 0;
}
.pc-controls-left,
.pc-controls-right {
    display: flex;
    align-items: center;
    gap: 4px;
    min-width: 80px;
}
.pc-controls-right { justify-content: flex-end; }
.pc-controls-center {
    display: flex;
    align-items: center;
    gap: 2px;
}

.pc-ctrl-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: var(--sr-light);
    cursor: pointer;
    transition: color 0.15s, background 0.15s;
    flex-shrink: 0;
    padding: 0;
}
.pc-ctrl-btn:hover {
    color: var(--sr-ink);
    background: color-mix(in srgb, var(--sr-ink) 6%, transparent);
}
.pc-ctrl-btn:disabled { opacity: 0.4; cursor: default; }

.volume-slider-wrap {
    width: 60px;
    flex-shrink: 0;
}
.pc-volume-track {
    position: relative;
    height: 4px;
    border-radius: 3px;
    background: var(--sr-border);
    cursor: pointer;
    width: 60px;
}
.pc-volume-fill {
    position: absolute;
    inset: 0;
    border-radius: 3px;
    background: var(--sr-ink);
}

.podcast-play-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: none;
    background: var(--sr-ink);
    color: var(--sr-surface);
    cursor: pointer;
    transition: opacity 0.15s, transform 0.15s;
    flex-shrink: 0;
    padding: 0;
    box-shadow: 0 3px 12px rgba(0,0,0,0.12);
}
.podcast-play-btn:hover { opacity: 0.85; transform: scale(1.04); }
.podcast-play-btn:active { transform: scale(0.96); }

.pc-speed-btn {
    padding: 2px 8px;
    border-radius: 6px;
    border: none;
    background: transparent;
    color: var(--sr-muted);
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
    transition: color 0.15s, background 0.15s;
}
.pc-speed-btn:hover {
    color: var(--sr-ink);
    background: color-mix(in srgb, var(--sr-ink) 6%, transparent);
}

/* ── Conversation ── */
.pc-convo-wrap {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    border-radius: 12px;
    border: 1px solid var(--sr-border);
    background: color-mix(in srgb, var(--sr-surface) 50%, transparent);
}
.pc-convo {
    height: 100%;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
    scrollbar-width: thin;
    scrollbar-color: transparent transparent;
}
.pc-convo:hover,
.pc-convo:focus-within {
    scrollbar-color: var(--sr-border) transparent;
}
.pc-convo::-webkit-scrollbar { width: 5px; }
.pc-convo::-webkit-scrollbar-track { background: transparent; }
.pc-convo::-webkit-scrollbar-thumb { background: transparent; border-radius: 3px; }
.pc-convo:hover::-webkit-scrollbar-thumb,
.pc-convo:focus-within::-webkit-scrollbar-thumb { background: var(--sr-border); }
.pc-convo--expanded {
    background: color-mix(in srgb, var(--primary) 4%, transparent);
}
.pc-convo-wrap:has(.pc-convo--expanded) {
    border-color: color-mix(in srgb, var(--primary) 30%, transparent);
}

/* Raise-hand listening state */
@keyframes pc-mic-pulse {
    0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--primary) 40%, transparent); }
    50%       { box-shadow: 0 0 0 6px color-mix(in srgb, var(--primary) 0%, transparent); }
}
.pc-raise-hand--listening {
    background: color-mix(in srgb, var(--primary) 15%, transparent) !important;
    border-color: color-mix(in srgb, var(--primary) 50%, transparent) !important;
    color: var(--primary) !important;
    animation: pc-mic-pulse 1.2s ease-in-out infinite;
}

/* ── Bubble rows ── */
.pc-bubble-wrap {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    opacity: 0.5;
    transition: opacity 0.3s ease;
}
.pc-bubble-wrap--reverse {
    flex-direction: row-reverse;
}
.pc-bubble-wrap--active {
    opacity: 1;
}
.pc-bubble-wrap--active .pc-bubble-text {
    outline: 1.5px solid var(--primary);
}

.pc-bubble-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
    margin-top: 2px;
    border: 1.5px solid var(--sr-surface);
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
.pc-bubble-avatar--tutor { background: var(--primary); }
.pc-bubble-avatar--student { background: #a78bfa; }

.pc-bubble-body {
    max-width: 82%;
    display: flex;
    flex-direction: column;
}
.pc-bubble-body--tutor { align-items: flex-start; }
.pc-bubble-body--student { align-items: flex-end; }

.pc-bubble-name {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--sr-muted);
    margin-bottom: 2px;
    padding: 0 2px;
}

.pc-bubble-text {
    font-size: 0.82rem;
    line-height: 1.55;
    padding: 8px 12px;
    border-radius: 12px;
    word-wrap: break-word;
    color: var(--sr-ink);
}
.pc-bubble-body--tutor .pc-bubble-text {
    background: color-mix(in srgb, var(--sr-ink) 6%, transparent);
    border-bottom-left-radius: 3px;
}
.pc-bubble-body--student .pc-bubble-text {
    background: color-mix(in srgb, var(--primary) 10%, transparent);
    border-bottom-right-radius: 3px;
}

.pc-bubble-body--typing .pc-bubble-text {
    padding: 10px 16px;
    background: color-mix(in srgb, var(--sr-ink) 6%, transparent);
    border-bottom-left-radius: 3px;
}

/* ── Regen ── */
.podcast-regen-btn {
    background: none;
    border: none;
    color: var(--sr-muted);
    font-size: 0.7rem;
    cursor: pointer;
    transition: color 0.15s;
    flex-shrink: 0;
    padding: 6px 0 2px;
    width: 100%;
    text-align: center;
}
.podcast-regen-btn:hover { color: var(--sr-ink); }

/* ── Fallback input ── */
.pc-fallback-btn {
    padding: 6px 14px;
    border: none;
    border-radius: 8px;
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    background: var(--primary);
    color: #fff;
}
.pc-fallback-btn--cancel {
    background: transparent;
    color: var(--sr-muted);
}

/* ── End Podcast Tab ── */

/* ══════════════════════════════════════════════════════════════════════════
   ONBOARDING ENTRY ANIMATION
   Applied via `.room-app-entry` when user just completed onboarding.
   ══════════════════════════════════════════════════════════════════════════ */

@keyframes room-app-fade-in {
  0%   { opacity: 0; }
  100% { opacity: 1; }
}

.room-app-entry {
  animation: room-app-fade-in 400ms ease-in both;
}
body.room-app-entry #main-content {
  animation: room-app-fade-in 400ms ease-in 100ms both;
}
.room-wrap.room-app-entry .pane-main,
.room-wrap.room-app-entry .pane-ai {
  animation: room-app-fade-in 400ms ease-in 100ms both;
}

/* ── Panel-inner (active content area) ── */
.room-vp .panel-inner {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* ── Two-step generation options ───────────────────────────── */
.gen-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  width: 100%;
}

.gen-step-1,
.gen-step-2 {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.gen-step-2 {
  display: none;
  gap: 18px;
}

.gen-step-2.gen-step-2--visible {
  display: flex;
}

.gen-step-title {
  font-size: 0.78rem;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-weight: 600;
  margin-bottom: 14px;
}

.gen-tier-grid {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  width: 100%;
  max-width: 340px;
  margin-bottom: 20px;
}

.gen-tier-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 14px 16px;
  min-width: 88px;
  flex: 1;
  border-radius: 12px;
  border: 1.5px solid var(--sr-border);
  background: var(--sr-surface);
  color: var(--sr-muted);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  user-select: none;
}

.gen-tier-card:hover {
  border-color: var(--sr-border-hover);
  color: var(--sr-ink);
  background: var(--sr-hover);
}
.gen-tier-card:focus-visible {
  outline: 2px solid var(--sr-blue);
  outline-offset: 2px;
}

.gen-tier-card--selected {
  border-color: var(--sr-blue);
  color: var(--sr-blue);
  background: var(--sr-blue-bg);
}

.gen-tier-card--selected:hover {
  border-color: var(--sr-blue);
  color: var(--sr-blue);
  background: var(--sr-blue-bg);
}

.gen-tier-card--popular {
  border-color: color-mix(in srgb, var(--primary,#4ecdc4) 30%, transparent);
  background: color-mix(in srgb, var(--primary,#4ecdc4) 4%, transparent);
}

.gen-tier-badge {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--sr-blue);
  color: #fff;
  font-size: 0.6rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  padding: 2px 8px;
  border-radius: 999px;
  text-transform: uppercase;
  white-space: nowrap;
}

.gen-tier-value {
  font-size: 1.3rem;
  font-weight: 700;
  line-height: 1;
}

.gen-tier-label {
  font-size: 0.7rem;
  color: var(--sr-light);
  font-weight: 500;
}

.gen-tier-card--selected .gen-tier-label {
  color: var(--sr-blue);
}

.gen-confirm-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 28px;
  border: none;
  border-radius: 10px;
  background: var(--primary,#4ecdc4);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
  margin-top: 4px;
}

.gen-confirm-btn:hover {
  opacity: 0.88;
}

.gen-confirm-btn:active {
  transform: scale(0.97);
}

.gen-confirm-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.gen-confirm-status {
  margin-top: 12px;
  font-size: 0.78rem;
  color: var(--sr-muted, #666);
  min-height: 1.2em;
  text-align: center;
}

.gen-loading {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  gap: 14px;
  padding: 2rem;
  text-align: center;
}

.gen-loading div {
  font-size: 0.82rem;
  color: var(--sr-muted, #666);
}

.gen-phase-text {
  font-size: 0.8rem;
  color: var(--sr-muted, #888);
}

.gen-pct {
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--primary, #5b4cdb);
  letter-spacing: -0.03em;
  line-height: 1;
}

.gen-back-btn {
  background: none;
  border: none;
  color: #444;
  font-size: 0.75rem;
  cursor: pointer;
  margin-top: 2px;
  padding: 4px 8px;
  transition: color 0.15s;
}

.gen-back-btn:hover {
  color: #888;
}

/* ── NOTES SELECTION TOOLBAR ── removed — replaced by mys-sel-toolbar at bottom of study_room.html */

/* ── Status Badge Bar ──────────────────────────────────── */

.sr-badge-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  width: 100%;
  background: var(--bg-page);
  flex-shrink: 0;
  position: relative;
  z-index: 90;
}

.sr-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px 4px 8px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

.sr-badge__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.sr-badge__label {
  opacity: 0.85;
}

.sr-badge__count {
  font-weight: 700;
  min-width: 16px;
  text-align: center;
}

/* Unfamiliar — red */
.sr-badge--unfamiliar {
  background: rgba(239, 68, 68, 0.12);
  color: #ef4444;
}
.sr-badge--unfamiliar .sr-badge__dot {
  background: #ef4444;
}

/* Learning — orange */
.sr-badge--learning {
  background: rgba(249, 115, 22, 0.12);
  color: #f97316;
}
.sr-badge--learning .sr-badge__dot {
  background: #f97316;
}

/* Familiar — blue */
.sr-badge--familiar {
  background: rgba(99, 102, 241, 0.12);
  color: var(--sr-blue, #6366f1);
}
.sr-badge--familiar .sr-badge__dot {
  background: var(--sr-blue, #6366f1);
}

/* Mastered — green */
.sr-badge--mastered {
  background: rgba(34, 197, 94, 0.12);
  color: #22c55e;
}
.sr-badge--mastered .sr-badge__dot {
  background: #22c55e;
}

/* Count bump animation triggered by JS after answer event */
@keyframes badge-bump {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.18); }
  100% { transform: scale(1); }
}

.sr-badge.badge-bumping {
  animation: badge-bump 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

/* Mobile: compress labels on narrow screens */
@media (max-width: 640px) {
  .sr-badge__label { display: none; }
  .sr-badge { padding: 4px 10px; gap: 4px; }
  .sr-badge-bar { gap: 6px; }
}

/* ── Shared section/topic indicator — lives in .sr-topbar-right (mobile + desktop) ── */
.sr-topbar-topic { margin-right: 2px; }
.sr-topbar-topic .topic-picker-dropdown { left: auto; right: 0; }
@media (max-width: 480px) {
  .sr-topbar-topic .topic-picker-btn { max-width: 90px; }
}

/* Ensure the study-room topbar is not visible on desktop widths. */
@media (min-width: 1025px) {
    .sr-topbar {
        display: none !important;
        visibility: hidden !important;
        height: 0 !important;
        min-height: 0 !important;
        pointer-events: none !important;
        top: auto !important;
        left: auto !important;
    }
}

/* ── Backdrop strip behind the floating capsule (mobile only) ─────────
   Extends the topbar's visible surface from y=52 down to y=104 so the
   12px side gutters and 8px top gap around the capsule sit on the same
   colour as the topbar, instead of whatever page-bg shows through. */
@media (max-width: 1024px) {
    .sr-topbar::after {
        content: '';
        position: fixed;
        top: 52px;
        left: 0;
        right: 0;
        height: 52px;
        background: var(--bg-hover);
        z-index: 98;
        pointer-events: none;
    }
}

/* Hide the room tabs bar on desktop to remove the tab-row from wider layouts */
@media (min-width: 1025px) {
    .room-tabs-bar {
        display: none !important;
        visibility: hidden !important;
        height: 0 !important;
        min-height: 0 !important;
        pointer-events: none !important;
    }
    .room-wrap {
        top: 0 !important;
    }
}

/* Ensure desktop still shows the topbar; revert prior hide for desktop-only while
     keeping the mobile tab rail collapsed on wide screens. */
@media (min-width: 1025px) {
    .sr-topbar {
        display: flex !important;
        visibility: visible !important;
        height: 52px !important;
        min-height: 52px !important;
        pointer-events: auto !important;
        top: 0 !important;
        left: var(--sidebar-w, 220px) !important;
        right: 0 !important;
    }
}

/* Study room: hide the base template's mobile drawer */
html.study-room-shell #mobileDrawer,
html.study-room-shell .mobile-sheet-overlay {
    display: none !important;
}

/* ── No-uploads placeholder ── */
.room-noupload {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 300px;
  gap: 12px;
  text-align: center;
  padding: 32px 24px;
  color: var(--text-muted);
}
.room-noupload svg {
  opacity: 0.5;
}
.room-noupload__title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}
.room-noupload__text {
  font-size: 13px;
  line-height: 1.5;
  max-width: 280px;
  margin: 0;
}
.room-noupload__btn {
  margin-top: 8px;
  padding: 8px 18px;
  background: var(--accent-dim);
  border: 0.5px solid var(--accent-border);
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
  font-family: inherit;
  transition: background 150ms var(--anim-ease-out), color 150ms ease;
}
.room-noupload__btn:hover {
  background: var(--accent);
  color: var(--text-primary);
}

/* ── Quota gating ── */
.gen-tier-card--locked {
    opacity: 0.38;
    cursor: not-allowed;
    pointer-events: none;
    position: relative;
}
.gen-tier-lock {
    position: absolute;
    top: 4px;
    right: 4px;
    font-size: 0.65rem;
    color: var(--text-muted);
    line-height: 1;
}

/* ── Upgrade banner ── */
.quota-upgrade-banner {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-card);
    border: 1px solid var(--primary);
    border-radius: 12px;
    padding: 10px 16px;
    font-size: 0.82rem;
    color: var(--text-primary);
    z-index: 9000;
    box-shadow: 0 8px 32px rgba(0,0,0,0.24);
    max-width: calc(100vw - 2rem);
    animation: fadeInUp 0.2s ease;
}
.quota-upgrade-link {
    color: var(--primary);
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 4px;
}
.quota-upgrade-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1rem;
    padding: 0 2px;
    line-height: 1;
    flex-shrink: 0;
}

/* ── Mobile topbar: recommended-videos row layout fixes ──────────────────
   On narrow screens the "Recommended Videos" label, nav buttons, counter,
   and search toggle all fight for the same 52 px strip alongside the
   right-side action buttons.  Fix: hide the text label (context is clear
   from the nav arrows), tighten gaps, and prevent the vid-row from
   growing into the right-button zone. */
@media (max-width: 860px) {
    /* Hide the verbose label — nav arrows make context obvious */
    .sr-topbar-vid-label {
        display: none;
    }

    /* Tighter gaps in the nav cluster */
    .sr-topbar-vid-left {
        gap: 4px;
    }

    /* Contain the vid-row so it can't overflow into sr-topbar-right */
    .sr-topbar-vid-row {
        margin-right: 0;
        overflow: hidden;
        min-width: 0;
    }

    /* Shrink the search (paste) toggle slightly so it doesn't crowd the right buttons */

    /* Reduce topbar side padding on narrow phones to recover more space */
    .sr-topbar {
        padding: 0 10px;
    }
}

#srTopicLabelBar {
    white-space: nowrap; max-width: 160px; overflow: hidden; text-overflow: ellipsis
}
/* ── Topic Picker ───────────────────────────────────────────────────────── */
.topic-picker-wrap { position: relative; display: inline-flex; align-items: center;}
    
.topic-picker-btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 10px; border-radius: 7px; border: 1px solid var(--sr-border, rgba(0,0,0,0.1));
  background: var(--sr-surface); color: var(--sr-ink);
  font-size: 0.8rem; font-weight: 500; cursor: pointer;
  white-space: nowrap; max-width: 160px; overflow: hidden; text-overflow: ellipsis;
  transition: background 140ms ease;
}
.topic-picker-btn:hover { background: var(--primary-soft, rgba(91,76,219,0.07)); color: var(--primary, #5b4cdb); }
.topic-picker-dropdown {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 9000;
  min-width: 220px; max-width: 320px; max-height: 280px; overflow-y: auto;
  background: var(--app-surface); border: 1px solid var(--sr-border, rgba(0,0,0,0.09));
  border-radius: 10px; padding: 4px; scrollbar-width: thin; scrollbar-color: transparent transparent;
  box-shadow: 0 4px 6px -1px rgba(0,0,0,0.08), 0 10px 28px -4px rgba(0,0,0,0.14);
}
.topic-picker-item {
  display: block; width: 100%; text-align: left;
  padding: 8px 12px; border: none; background: transparent;
  color: var(--sr-ink); font-size: 0.825rem; cursor: pointer; border-radius: 6px;
  transition: background 120ms ease;
  
}
.topic-picker-item:hover { background: var(--bg-hover)}
.topic-picker-item--auto { font-style: italic; color: var(--sr-muted, #475569); }
.topic-picker-divider { height: 1px; background: rgba(0,0,0,0.07); margin: 3px 4px; }

.topic-picker-status {
  display: inline-flex; align-items: center; justify-content: center;
  width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0;
}
.topic-picker-status--ok { color: #22c55e; }
.topic-picker-status--fail { background: #ef4444; }
.topic-picker-btn--empty { opacity: 0.7; cursor: pointer; }
.topic-picker-btn--empty:hover { opacity: 1; background: var(--sr-hover, rgba(255,255,255,0.06)); }
.topic-picker-btn--empty:disabled { opacity: 0.55; cursor: default; }
.topic-picker-btn--empty:disabled:hover { background: transparent; }

/* ═══════════════════════════════════════════════════════════════════════════
   STUDY ROOM SHELL LAYOUT OVERRIDES (was inline in study_room.html)
   ═══════════════════════════════════════════════════════════════════════════ */
html.study-room-shell,
body.study-room-shell {
  overflow-x: hidden !important;
}

html.study-room-shell #main-content,
html.study-room-shell .main-content {
  width: 100vw !important;
  max-width: 100vw !important;
  min-width: 0 !important;
  overflow-x: hidden !important;
  box-sizing: border-box !important;
}

html.study-room-shell #paneAi {
  max-width: 100vw !important;
  min-width: 0 !important;
}

html.study-room-shell #tab-flashcards .fc-shell,
html.study-room-shell #tab-quiz .fc-shell,
html.study-room-shell #tab-more .fc-shell,
html.study-room-shell #tab-flashcards .fc-content,
html.study-room-shell #tab-quiz .fc-content,
html.study-room-shell #tab-more .fc-content,
html.study-room-shell #tab-flashcards .fc-stage,
html.study-room-shell #tab-quiz .fc-stage,
html.study-room-shell #tab-more .fc-stage,
html.study-room-shell #tab-flashcards .fc-empty,
html.study-room-shell #tab-quiz .fc-empty,
html.study-room-shell #tab-more .fc-empty,
html.study-room-shell #tab-flashcards .vp-gate,
html.study-room-shell #tab-quiz .vp-gate,
html.study-room-shell #tab-more .vp-gate,
html.study-room-shell #qzStage,
html.study-room-shell #qzInner,
html.study-room-shell #fiStage,
html.study-room-shell #fiStage .fc-face,
html.study-room-shell #fiStage .fc-face-inner {
  width: 100% !important;
  min-width: 0 !important;
  box-sizing: border-box !important;
}

@media (max-height: 760px) {
  .fc-empty .vp-gate {
    min-height: 0 !important;
    padding: 18px 16px !important;
  }
  .fc-empty .vp-gate > div:first-child {
    width: 40px !important;
    height: 40px !important;
    min-width: 40px !important;
    min-height: 40px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 0 !important;
    margin-bottom: 6px !important;
  }
  .fc-empty .vp-gate > div:first-child svg {
    width: 40px !important;
    height: 40px !important;
    display: block !important;
    flex: none !important;
  }
  .fc-empty .vp-gate button {
    padding: 7px 14px !important;
    font-size: 0.82rem !important;
  }
  .fc-empty .vp-gate > div:nth-of-type(2) {
    font-size: 0.9rem !important;
    margin-bottom: 2px !important;
  }
  .fc-empty .vp-gate > div:nth-of-type(3),
  .fc-empty .vp-gate > div:nth-of-type(4) {
    font-size: 0.74rem !important;
    margin-top: 6px !important;
  }
}

@media (max-width: 768px) {
  .fc-empty .vp-gate {
    min-height: 0 !important;
    padding: 18px 16px !important;
  }
  .fc-empty .vp-gate > div:first-child {
    width: 40px !important;
    height: 40px !important;
    min-width: 40px !important;
    min-height: 40px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 0 !important;
    margin-bottom: 6px !important;
  }
  .fc-empty .vp-gate > div:first-child svg {
    width: 40px !important;
    height: 40px !important;
    display: block !important;
    flex: none !important;
  }
  .fc-empty .vp-gate button {
    padding: 7px 14px !important;
    font-size: 0.82rem !important;
  }
  .fc-empty .vp-gate > div:nth-of-type(2) {
    font-size: 0.9rem !important;
    margin-bottom: 2px !important;
  }
  .fc-empty .vp-gate > div:nth-of-type(3),
  .fc-empty .vp-gate > div:nth-of-type(4) {
    font-size: 0.74rem !important;
    margin-top: 6px !important;
  }
}

@media (max-width: 860px) {
  .sr-topbar {
    display: flex !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    height: 52px !important;
    min-height: 52px !important;
    z-index: 100 !important;
  }
  .room-tabs-bar {
    display: flex !important;
    position: fixed !important;
    top: 52px !important;
    left: 0 !important;
    right: 0 !important;
    height: 52px !important;
    min-height: 52px !important;
    z-index: 99 !important;
  }
  .room-wrap {
    top: 104px !important;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   TIER CARD LOCKED + NOTES STATES (was inline in study_room.html)
   ═══════════════════════════════════════════════════════════════════════════ */
.gen-tier-card--locked {
  opacity: 0.5;
  cursor: default;
  pointer-events: auto;
  position: relative;
}
.gen-tier-card--locked::after {
  content: 'Upgrade';
  position: absolute;
  bottom: -7px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.58rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--primary, #6366f1);
  background: color-mix(in srgb, var(--primary, #6366f1), transparent 88%);
  border: 1px solid color-mix(in srgb, var(--primary, #6366f1), transparent 70%);
  border-radius: 99px;
  padding: 1px 6px;
  white-space: nowrap;
  pointer-events: none;
}
.gen-tier-card--locked:hover {
  opacity: 0.75;
}
.notes-generating {
  padding: 48px 24px;
  text-align: center;
  color: var(--text-muted, #888);
  font-size: 1rem;
  user-select: none;
  pointer-events: none;
}
.notes-generating-error {
  padding: 48px 24px;
  text-align: center;
  color: var(--danger, #e74c3c);
  font-size: 0.9rem;
  user-select: none;
  pointer-events: none;
}

/* ═══════════════════════════════════════════════════════════════════════════
   ONBOARDING TOUR STYLES (was inline in study_room.html)
   ═══════════════════════════════════════════════════════════════════════════ */
#obSpotlightHole{position:fixed;z-index:9001;pointer-events:none;box-shadow:0 0 0 9999px rgba(0,0,0,0);outline:2px solid transparent;outline-offset:2px;transition:box-shadow 320ms ease,outline-color 320ms ease}
#obSpotlightHole.ob-hl--on{box-shadow:0 0 0 9999px rgba(0,0,0,.62),0 0 0 1px color-mix(in srgb,var(--primary) 30%,transparent);outline-color:color-mix(in srgb,var(--primary) 22%,transparent)}
.sr-ob-tip{position:fixed;z-index:900;width:232px;background:color-mix(in srgb,var(--primary) 9%,var(--bg-card));border:1px solid color-mix(in srgb,var(--primary) 28%,transparent);border-radius:12px;padding:13px 15px 14px;box-shadow:0 8px 28px rgba(0,0,0,.18);opacity:0;pointer-events:none;transition:opacity 280ms ease,transform 280ms ease}
.sr-ob-tip--spotlight{z-index:9002}
.sr-ob-tip--above{transform:translateY(7px)}
.sr-ob-tip--below{transform:translateY(-7px)}
.sr-ob-tip--visible{opacity:1;pointer-events:auto;transform:translateY(0)}
.sr-ob-tip__head{display:flex;align-items:center;justify-content:space-between;margin-bottom:5px}
.sr-ob-tip__title{display:flex;align-items:center;gap:7px;font-family:var(--font-display,inherit);font-size:.82rem;font-weight:600;color:var(--primary)}
.sr-ob-tip__title::before{content:'';width:6px;height:6px;border-radius:50%;background:var(--primary);flex-shrink:0}
.sr-ob-tip__count{font-size:.68rem;color:var(--text-muted);font-variant-numeric:tabular-nums;white-space:nowrap}
.sr-ob-tip__body{margin:0 0 10px;font-size:.74rem;line-height:1.5;color:var(--text-secondary)}
.sr-ob-tip__foot{display:flex;align-items:center;justify-content:space-between;gap:8px}
.sr-ob-tip__skip{background:none;border:none;padding:0;font-size:.72rem;color:var(--text-muted);cursor:pointer;line-height:1}
.sr-ob-tip__skip:hover{color:var(--text-secondary)}
.sr-ob-tip__next{background:var(--primary);color:#fff;border:none;border-radius:7px;padding:5px 13px;font-size:.75rem;font-weight:600;cursor:pointer;line-height:1.4;transition:opacity 120ms ease}
.sr-ob-tip__next:hover{opacity:.88}
.sr-ob-tip--above::after{content:'';position:absolute;top:100%;left:22px;border:7px solid transparent;border-top-color:color-mix(in srgb,var(--primary) 9%,var(--bg-card))}
.sr-ob-tip--below::after{content:'';position:absolute;bottom:100%;left:var(--sr-ob-arrow-left,22px);border:7px solid transparent;border-bottom-color:color-mix(in srgb,var(--primary) 9%,var(--bg-card))}
@media(max-width:480px){.sr-ob-tip{width:calc(100vw - 32px)}}
