:root {
    /* ═══ SAGE design tokens — dark is the native default ═══ */
    /* Surfaces (single neutral ramp, deduped from 5 near-identical grays) */
    --bg-color: #0f1115;
    --sidebar-bg: #161920;
    --sidebar-hover: #1e2330;
    --input-bg: #1a1e28;
    --surface-raised: #232a38;      /* cards, code blocks, raised chips */
    --code-bg: var(--code-bg);
    /* Text */
    --text-primary: #e6ebf2;
    --text-secondary: #9fb0c4;      /* was #a8c7fa — decoupled from the accent */
    --text-muted: #6b7686;
    /* Accent — now a distinct, more saturated hue (was == text-secondary) */
    --accent-color: #6e9df5;
    --accent-hover: #85adf7;
    --accent-soft: rgba(110, 157, 245, 0.12);   /* accent-tinted surface */
    --on-accent: #0b1220;           /* text/icon sitting on an accent fill */
    /* Messages */
    --user-msg-bg: #1e293b;
    --bot-msg-bg: transparent;
    /* Borders */
    --border-color: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(255, 255, 255, 0.15);
    --hover-overlay: var(--hover-overlay);
    /* Semantic status (success/warning were referenced in code but never defined) */
    --success-color: #34d399;
    --warning-color: #fbbf24;
    --danger-color: #f87171;
    /* Elevation */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.5);

    /* ── Type scale (7 steps, replaces ~20 ad-hoc sizes) ── */
    --f-xs: 0.75rem;
    --f-sm: 0.875rem;
    --f-base: 1rem;
    --f-md: 1.125rem;
    --f-lg: 1.375rem;
    --f-xl: 1.75rem;
    --f-2xl: 2.5rem;
    --font-ui: 'Inter', 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'Fira Code', 'Consolas', monospace;

    /* ── Radius (4, down from 8) + 4px spacing grid ── */
    --r-sm: 6px;
    --r-md: 10px;
    --r-lg: 16px;
    --r-pill: 999px;
    --sp-1: 4px;
    --sp-2: 8px;
    --sp-3: 12px;
    --sp-4: 16px;
    --sp-6: 24px;
    --sp-8: 32px;
    --sp-12: 48px;
}

/* ═══ Light theme — the mirror of the dark palette. ═══
   Follows the viewer's OS preference automatically; a manual data-theme
   always wins (data-theme="dark" opts back out of the light media query,
   data-theme="light" forces light regardless of OS). */
@media (prefers-color-scheme: light) {
    :root:not([data-theme="dark"]) {
        --bg-color: #f6f8fb;
        --sidebar-bg: #ffffff;
        --sidebar-hover: #eef1f6;
        --input-bg: #eef1f6;
        --surface-raised: #e3e8f0;
        --code-bg: #f3f5f9;
        --text-primary: #12151c;
        --text-secondary: #48546a;
        --text-muted: #7a869c;
        --accent-color: #2f6bd8;
        --accent-hover: #2359bf;
        --accent-soft: rgba(47, 107, 216, 0.10);
        --on-accent: #ffffff;
        --user-msg-bg: #eef1f6;
        --border-color: rgba(16, 19, 26, 0.10);
        --border-hover: rgba(16, 19, 26, 0.20);
        --hover-overlay: rgba(16, 19, 26, 0.05);
        --success-color: #0f9d63;
        --warning-color: #b7791f;
        --danger-color: #d64545;
        --shadow-sm: 0 1px 2px rgba(16, 19, 26, 0.06);
        --shadow-lg: 0 8px 24px rgba(16, 19, 26, 0.10);
    }
}

:root[data-theme="light"] {
    --bg-color: #f6f8fb;
    --sidebar-bg: #ffffff;
    --sidebar-hover: #eef1f6;
    --input-bg: #eef1f6;
    --surface-raised: #e3e8f0;
    --code-bg: #f3f5f9;
    --text-primary: #12151c;
    --text-secondary: #48546a;
    --text-muted: #7a869c;
    --accent-color: #2f6bd8;
    --accent-hover: #2359bf;
    --accent-soft: rgba(47, 107, 216, 0.10);
    --on-accent: #ffffff;
    --user-msg-bg: #eef1f6;
    --border-color: rgba(16, 19, 26, 0.10);
    --border-hover: rgba(16, 19, 26, 0.20);
    --hover-overlay: rgba(16, 19, 26, 0.05);
    --success-color: #0f9d63;
    --warning-color: #b7791f;
    --danger-color: #d64545;
    --shadow-sm: 0 1px 2px rgba(16, 19, 26, 0.06);
    --shadow-lg: 0 8px 24px rgba(16, 19, 26, 0.10);
}

body {
    font-family: 'Inter', 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-color);
    margin: 0;
    display: flex;
    height: 100vh;
    color: var(--text-primary);
    overflow: hidden;
    font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
    -webkit-font-smoothing: antialiased;
    transition: background-color 0.25s ease, color 0.25s ease;
}

@media (prefers-reduced-motion: reduce) {
    body { transition: none; }
}

/* --- ACCESSIBILITY CLASSES --- */

/* Dyslexia Friendly: Irregular weighting, distinct letter shapes, wider tracking */
body.a11y-dyslexia * {
    font-family: "Comic Sans MS", "Lexend Deca", "OpenDyslexic", sans-serif !important;
    letter-spacing: 0.05em !important;
}

/* Extra Spacing: Reduces visual crowding for ADHD/Cognitive Overload */
body.a11y-spacing .message {
    line-height: 2.0 !important;
    margin-bottom: 25px !important;
}
body.a11y-spacing .message p {
    margin-bottom: 1.2em !important;
}

/* High Contrast Code: Better readability for Astigmatism/Visual Processing */
body.a11y-contrast pre[class*="language-"] {
    background: #000000 !important;
    border: 2px solid #ffff00 !important; /* High contrast yellow border */
}
body.a11y-contrast code {
    color: #ffffff !important;
    font-weight: bold !important;
}
body.a11y-contrast .message.bot {
    color: #ffffff !important;
}

/* --- SIDEBAR --- */
.sidebar {
    width: 260px;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-color);
    transition: width 0.3s ease;
    flex-shrink: 0;
}

.sidebar.collapsed {
    width: 0;
    overflow: hidden;
    border: none;
}

.new-chat-btn {
    margin: 15px;
    padding: 12px;
    background: var(--surface-raised);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    cursor: pointer;
    text-align: left;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: background 0.2s;
}

.new-chat-btn:hover {
    background: var(--sidebar-hover);
}

.new-chat-btn svg {
    width: 18px;
    fill: currentColor;
}

.history-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    margin-bottom: 3px;
    cursor: pointer;
    border-radius: 10px;
    color: var(--text-muted);
    font-size: 0.85rem;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
}

.history-item span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.history-item:hover {
    background: var(--sidebar-hover);
    color: var(--text-primary);
}

.history-item.active {
    background: var(--accent-soft);
    border-left-color: var(--accent-color);
    color: var(--text-primary);
}

/* Delete Button (Hidden by default, shown on hover) */
.delete-chat-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    opacity: 0;
    transition: opacity 0.2s;
    margin-left: 8px;
}

.delete-chat-btn:hover {
    color: var(--danger-color);
    background: var(--hover-overlay);
}

.history-item:hover .delete-chat-btn {
    opacity: 1;
}

/* --- AUTH SCREEN --- */
#auth-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-color);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.auth-card {
    background: var(--sidebar-bg);
    padding: 40px;
    border-radius: 24px;
    width: 90%;
    max-width: 400px;
    text-align: center;
    border: 1px solid var(--border-color);
    box-sizing: border-box;
}

.auth-card h2 {
    margin-top: 0;
    color: var(--text-primary);
    font-weight: 400;
}

.auth-input {
    width: 100%;
    padding: 14px;
    margin: 10px 0;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: 8px;
    box-sizing: border-box;
    font-size: 1rem;
}

.auth-btn {
    width: 100%;
    padding: 14px;
    background: var(--accent-color);
    color: var(--on-accent);
    border: none;
    border-radius: 24px;
    cursor: pointer;
    font-weight: 600;
    margin-top: 15px;
    font-size: 1rem;
}

.toggle-link {
    color: var(--accent-color);
    cursor: pointer;
    margin-top: 20px;
    display: block;
    font-size: 0.9rem;
}

.error-msg {
    color: var(--danger-color);
    font-size: 0.9rem;
    margin-top: 10px;
    display: none;
}

.hidden {
    display: none;
}

/* --- APP LAYOUT --- */
#app-screen {
    display: none;
    width: 100%;
    height: 100%;
}

.main-container {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.content-row {
    display: flex;
    flex: 1;
    overflow: hidden;
    position: relative;
}

/* --- CHAT SECTION --- */
.chat-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    height: 100%;
}

/* ═══ REDESIGNED TOP BAR ═══ */
.top-bar {
    padding: 0 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    z-index: 200;
    background: var(--sidebar-bg);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
    height: 52px;
    gap: 8px;
}

.top-bar-left,
.top-bar-center,
.top-bar-right {
    display: flex;
    align-items: center;
    gap: 4px;
}

.top-bar-left { gap: 10px; }
.top-bar-center { gap: 2px; }
.top-bar-right { gap: 2px; }

/* Brand Mark */
/* The brand is a link to home. It must not inherit the default anchor underline or
   link colour — the name carries its own gradient fill. */
.brand-mark {
    display: flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    color: inherit;
    border-radius: 6px;
    padding: 2px 4px;
    margin-left: -4px;
    transition: opacity 0.15s ease, background 0.15s ease;
}

.brand-mark:hover {
    opacity: 0.82;
    background: rgba(255, 255, 255, 0.05);
}

.brand-mark:focus-visible {
    outline: 2px solid #6e9df5;
    outline-offset: 2px;
}

.brand-icon {
    font-size: 1.3rem;
}

.brand-name {
    font-weight: 700;
    font-size: 1rem;
    background: linear-gradient(135deg, #6e9df5, #a78bfa);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.3px;
}

.role-badge {
    font-size: 0.65rem;
    background: var(--accent-soft);
    color: var(--accent-color);
    padding: 3px 8px;
    border-radius: 10px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

/* ── Toolbar Buttons (shared style for all nav) ── */
.toolbar-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
    position: relative;
}

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

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

.toolbar-btn.active::after {
    content: '';
    position: absolute;
    bottom: -7px;
    left: 50%;
    transform: translateX(-50%);
    width: 70%;
    height: 2px;
    background: var(--accent-color);
    border-radius: 1px;
}

.toolbar-btn.icon-only {
    padding: 6px 8px;
}

.toolbar-btn.icon-only span {
    display: none;
}

.toolbar-btn svg {
    flex-shrink: 0;
}

.toolbar-divider {
    width: 1px;
    height: 24px;
    background: var(--border-color);
    margin: 0 4px;
}

.toolbar-btn.logout-btn:hover {
    color: #f87171;
    background: rgba(248, 113, 113, 0.08);
}

/* Hide text on small screens */
.hide-mobile {
    display: inline;
}

/* ── Quick Access Cards on Welcome Screen ── */
.quick-access-cards {
    display: flex;
    justify-content: center;
    gap: 14px;
    margin-top: 28px;
    flex-wrap: wrap;
    padding: 0 20px;
    pointer-events: auto;
}

.quick-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    min-width: 200px;
    font-family: inherit;
    color: var(--text-primary);
}

.quick-card:hover {
    background: rgba(168, 199, 250, 0.06);
    border-color: rgba(168, 199, 250, 0.2);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.quick-card:focus-visible {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}

.quick-card-icon {
    font-size: 1.6rem;
    flex-shrink: 0;
}

.quick-card-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.quick-card-title {
    font-weight: 600;
    font-size: 0.9rem;
}

.quick-card-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ═══ EMBEDDED CLASSROOM VIEW ═══ */
.classroom-view {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.classroom-selector-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    background: var(--sidebar-bg);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.classroom-selector-bar label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    white-space: nowrap;
}

.classroom-selector-bar select {
    flex: 1;
    padding: 8px 12px;
    background: var(--input-bg);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.85rem;
    cursor: pointer;
    outline: none;
}

.classroom-selector-bar select:focus {
    border-color: var(--accent-color);
}

.classroom-split {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Video side */
.classroom-video-side {
    flex: 0 0 55%;
    display: flex;
    flex-direction: column;
    background: #000;
    border-right: 1px solid var(--border-color);
}

.classroom-video-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
    overflow: hidden;
}

.classroom-video-wrapper video {
    width: 100%;
    max-height: 100%;
    border-radius: 10px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
}

.classroom-status-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    background: var(--sidebar-bg);
    border-top: 1px solid var(--border-color);
    font-size: 0.78rem;
    color: var(--text-muted);
}

.classroom-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    background: var(--accent-soft);
    color: var(--accent-color);
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.72rem;
}

.pulse-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent-color);
    animation: pulseDot 2s infinite;
}

@keyframes pulseDot {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 1; }
}

.classroom-transcript-status {
    font-style: italic;
}

/* Chat side */
.classroom-chat-side {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--sidebar-bg);
    min-width: 0;
}

.classroom-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
}

.classroom-chat-header h3 {
    font-size: 0.9rem;
    font-weight: 700;
    margin: 0;
}

.classroom-time-badge {
    padding: 3px 10px;
    background: var(--accent-soft);
    border: 1px solid var(--accent-soft);
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--accent-color);
}

.classroom-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    scroll-behavior: smooth;
}

.classroom-messages::-webkit-scrollbar {
    width: 4px;
}

.classroom-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 10px;
}

/* Classroom welcome */
.classroom-welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    padding: 30px;
}

.classroom-welcome-icon {
    font-size: 2.8rem;
    margin-bottom: 12px;
}

.classroom-welcome h3 {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 6px;
    background: linear-gradient(135deg, #6e9df5, #a78bfa);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.classroom-welcome p {
    color: var(--text-muted);
    font-size: 0.85rem;
    line-height: 1.6;
    max-width: 280px;
}

/* Classroom message bubbles */
.cr-message {
    display: flex;
    gap: 8px;
    animation: fadeSlideIn 0.3s ease-out both;
    max-width: 100%;
}

.cr-message.user {
    flex-direction: row-reverse;
}

.cr-message-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    flex-shrink: 0;
    margin-top: 2px;
}

.cr-message.user .cr-message-avatar {
    background: linear-gradient(135deg, #6e9df5, #818cf8);
}

.cr-message.bot .cr-message-avatar {
    background: linear-gradient(135deg, #34d399, #10b981);
}

.cr-message-content {
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 0.85rem;
    line-height: 1.6;
    max-width: 85%;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.cr-message.user .cr-message-content {
    background: rgba(110, 157, 245, 0.12);
    border: 1px solid rgba(138, 180, 248, 0.1);
    border-top-right-radius: 4px;
}

.cr-message.bot .cr-message-content {
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-top-left-radius: 4px;
}

.cr-timestamp-ref {
    display: inline-block;
    padding: 2px 8px;
    background: var(--accent-soft);
    border-radius: 4px;
    font-size: 0.7rem;
    color: var(--accent-color);
    margin-bottom: 6px;
    font-weight: 600;
}

.cr-message-content strong {
    color: var(--accent-color);
}

.cr-message-content code {
    background: var(--hover-overlay);
    padding: 2px 5px;
    border-radius: 3px;
    font-family: 'Fira Code', monospace;
    font-size: 0.8rem;
}

.cr-message-content pre {
    background: var(--code-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px;
    margin: 6px 0;
    overflow-x: auto;
}

.cr-message-content pre code {
    background: none;
    padding: 0;
}

/* Typing indicator */
.cr-typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 10px;
}

.cr-typing span {
    width: 6px;
    height: 6px;
    background: var(--accent-color);
    border-radius: 50%;
    animation: crBounce 1.4s infinite ease-in-out;
}

.cr-typing span:nth-child(2) { animation-delay: 0.2s; }
.cr-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes crBounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.3; }
    40% { transform: scale(1); opacity: 1; }
}

/* Classroom input */
.classroom-input-area {
    padding: 12px 16px;
    background: var(--sidebar-bg);
    border-top: 1px solid var(--border-color);
}

.classroom-input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 4px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.classroom-input-wrapper:focus-within {
    border-color: var(--accent-color);
    box-shadow: 0 0 12px var(--accent-soft);
}

.classroom-input-wrapper textarea {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.85rem;
    resize: none;
    padding: 8px 10px;
    outline: none;
    max-height: 100px;
    line-height: 1.5;
}

.classroom-input-wrapper textarea::placeholder {
    color: var(--text-muted);
}

.classroom-send-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: linear-gradient(135deg, #6e9df5, #a78bfa);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.15s;
    color: #0f1115;
}

.classroom-send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(138, 180, 248, 0.25);
}

.classroom-send-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

.classroom-paused-hint {
    text-align: center;
    font-size: 0.72rem;
    color: var(--text-muted);
    padding-top: 4px;
    opacity: 0;
    transition: opacity 0.2s;
}

.classroom-paused-hint.visible {
    opacity: 1;
}

/* ═══ SYNCED TRANSCRIPT PANEL ═══ */
.classroom-video-side {
    overflow-y: auto;  /* Allow scrolling for video + transcript */
}

.transcript-panel {
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    max-height: 260px;
    transition: max-height 0.3s ease;
}

.transcript-panel.collapsed {
    max-height: 38px;
    overflow: hidden;
}

.transcript-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 14px;
    background: rgba(255, 255, 255, 0.02);
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    flex-shrink: 0;
}

.transcript-panel-title {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 0.3px;
}

.transcript-toggle-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    transition: all 0.15s;
}

.transcript-toggle-btn:hover {
    color: var(--text-primary);
    background: var(--hover-overlay);
}

.transcript-panel.collapsed .transcript-toggle-btn svg {
    transform: rotate(-90deg);
}

.transcript-segments {
    overflow-y: auto;
    flex: 1;
    padding: 8px 0;
    scroll-behavior: smooth;
}

.transcript-segments::-webkit-scrollbar {
    width: 4px;
}

.transcript-segments::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.transcript-segment {
    display: flex;
    gap: 10px;
    padding: 6px 14px;
    cursor: pointer;
    border-left: 3px solid transparent;
    transition: all 0.15s ease;
    align-items: flex-start;
}

.transcript-segment:hover {
    background: rgba(255, 255, 255, 0.03);
}

.transcript-segment.active {
    background: rgba(110, 157, 245, 0.08);
    border-left-color: var(--accent-color);
}

.transcript-segment.active .transcript-seg-text {
    color: var(--text-primary);
}

.transcript-segment.active .transcript-seg-time {
    color: var(--accent-color);
}

.transcript-seg-time {
    font-size: 0.68rem;
    color: var(--text-muted);
    font-family: 'SF Mono', 'Monaco', 'Cascadia Code', 'Courier New', monospace;
    white-space: nowrap;
    min-width: 40px;
    padding-top: 2px;
    opacity: 0.7;
    transition: all 0.15s;
}

.transcript-seg-text {
    font-size: 0.82rem;
    line-height: 1.5;
    color: var(--text-secondary);
    transition: color 0.15s;
}

.transcript-loading {
    text-align: center;
    padding: 20px;
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* ═══ VIDEO PICKER SCREEN ═══ */
.classroom-picker {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 30px;
}

.picker-header {
    text-align: center;
    margin-bottom: 28px;
}

.picker-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0 0 6px 0;
    background: linear-gradient(135deg, #6e9df5, #a78bfa);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.picker-header p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin: 0;
}

.picker-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
}

/* Chapter-grouped lecture list. The grid becomes a single column of chapter
   blocks, each holding its own card row, so the course structure is visible
   instead of one flat alphabetical wall of videos. */
.picker-grid.by-chapter {
    display: block;
    max-width: 1100px;
}

.chapter-block { margin-bottom: 30px; }
.chapter-block:last-child { margin-bottom: 8px; }

.chapter-head {
    display: flex;
    align-items: baseline;
    gap: 12px;
    padding-bottom: 8px;
    margin-bottom: 14px;
    border-bottom: 1px solid var(--border, rgba(255, 255, 255, 0.08));
}

.chapter-title {
    display: flex;
    align-items: baseline;
    gap: 10px;
    flex: 1;
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary, #e2e8f0);
}

.chapter-num {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #8b9dc9;
    background: rgba(110, 157, 245, 0.12);
    border: 1px solid rgba(110, 157, 245, 0.22);
    border-radius: 999px;
    padding: 3px 9px;
    white-space: nowrap;
}

.chapter-count {
    font-size: 12px;
    color: var(--text-muted, #64748b);
    white-space: nowrap;
}

.chapter-videos {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
}

/* "Video 7" marker on the thumbnail — the plan numbers lectures, and that number
   is how students and the syllabus refer to them. */
.video-card-num {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 2;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: #cbd5e1;
    background: rgba(15, 17, 21, 0.78);
    border: 1px solid rgba(255, 255, 255, 0.10);
    border-radius: 5px;
    padding: 2px 7px;
}

.video-card-slides {
    display: block;
    font-size: 11px;
    color: var(--text-muted, #64748b);
    margin-top: 2px;
}

/* Video Thumbnail Card */
.video-card {
    background: rgba(255, 255, 255, 0.025);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.25s ease;
    display: flex;
    flex-direction: column;
}

.video-card:hover {
    border-color: rgba(168, 199, 250, 0.3);
    transform: translateY(-3px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
}

.video-card:focus-visible {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}

.video-card-thumb {
    height: 130px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.video-card-thumb-bg {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3.5rem;
    opacity: 0.15;
}

.video-card-play-icon {
    position: relative;
    z-index: 2;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(168, 199, 250, 0.15);
    border: 2px solid rgba(168, 199, 250, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.video-card:hover .video-card-play-icon {
    background: rgba(168, 199, 250, 0.25);
    border-color: var(--accent-color);
    transform: scale(1.1);
}

.video-card-play-icon svg {
    color: var(--accent-color);
    margin-left: 2px;
}

.video-card-body {
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}

.video-card-title {
    font-weight: 700;
    font-size: 0.92rem;
    color: var(--text-primary);
    line-height: 1.3;
}

.video-card-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.video-card-topic {
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.3px;
    text-transform: uppercase;
}

/* Topic color palette */
.topic-variables     { background: rgba(110, 157, 245, 0.12); color: #6e9df5; }
.topic-control-flow  { background: rgba(167, 139, 250, 0.12); color: #a78bfa; }
.topic-functions     { background: rgba(52, 211, 153, 0.12);  color: #34d399; }
.topic-arrays        { background: rgba(251, 191, 36, 0.12);  color: #fbbf24; }
.topic-strings       { background: rgba(248, 113, 113, 0.12); color: #f87171; }
.topic-pointers      { background: rgba(236, 72, 153, 0.12);  color: #ec4899; }
.topic-structures    { background: rgba(139, 92, 246, 0.12);  color: #8b5cf6; }
.topic-general       { background: rgba(148, 163, 184, 0.12); color: #94a3b8; }

.video-card-duration {
    font-size: 0.72rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 4px;
}

.video-card-size {
    font-size: 0.68rem;
    color: var(--text-muted);
    opacity: 0.7;
}

.video-card-transcript-badge {
    margin-left: auto;
    font-size: 0.65rem;
    color: var(--success-color);
    font-weight: 600;
}

/* Classroom Player (wraps split view) */
.classroom-player {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.classroom-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    padding: 5px 12px;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}

.classroom-back-btn:hover {
    background: var(--hover-overlay);
    color: var(--text-primary);
    border-color: rgba(168, 199, 250, 0.2);
}

.classroom-active-title {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* --- Pending Challenges Dropdown --- */
.pending-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 12px;
    width: 320px;
    background: var(--sidebar-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.6);
    z-index: 1000;
    animation: fadeSlideIn 0.2s ease-out;
}

.pending-dropdown-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255,255,255,0.02);
}

.pending-item {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.2s;
}

.pending-item:last-child {
    border-bottom: none;
}

.pending-item:hover {
    background: rgba(255,255,255,0.04);
}

.pending-item-btn {
    background: var(--accent-color);
    color: var(--on-accent);
    border: none;
    padding: 5px 12px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.1s;
}

.pending-item-btn:active {
    transform: scale(0.95);
}

/* Empty state for picker */
.picker-empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.picker-empty-icon {
    font-size: 3rem;
    margin-bottom: 12px;
    opacity: 0.5;
}

.picker-empty p {
    font-size: 0.9rem;
    max-width: 320px;
    margin: 0 auto;
    line-height: 1.6;
}

/* Welcome View */
#welcome-view {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 5;
    pointer-events: none;
    /* Passes clicks through the invisible background */
}

#welcome-view .suggestions-area {
    pointer-events: auto;
    /* Restores clicking specifically for the buttons */
    z-index: 15;
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
    padding: 0 20px;
}

.welcome-text {
    font-size: 3.5rem;
    font-weight: 500;
    margin: 0;
    background: linear-gradient(90deg, #4285F4, #9B72CB, #F889A7);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sub-welcome {
    font-size: 1.5rem;
    color: var(--text-muted);
    margin-top: 10px;
    font-weight: 400;
}

/* Messages */
.messages-container {
    flex: 1;
    padding: 20px 6%;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding-bottom: 120px;
    z-index: 10;
    /* Must be higher than the background */
    pointer-events: none;
}

.message {
    max-width: 95%;
    padding: 12px 16px;
    border-radius: 12px;
    line-height: 1.7;
    font-size: 0.95rem;
    color: var(--text-primary);
    pointer-events: auto;
    animation: fadeSlideIn 0.3s ease-out both;
}

.msg-sender {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.msg-sender.bot {
    color: var(--accent-color);
}

@keyframes fadeSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.user {
    align-self: flex-end;
    background-color: var(--user-msg-bg);
    border: 1px solid var(--accent-soft);
    border-bottom-right-radius: 4px;
    max-width: 75%;
}

.message.bot {
    align-self: flex-start;
    background-color: transparent;
    padding-left: 0;
}

.message.bot strong {
    color: var(--accent-color);
    font-weight: 600;
}

.message.bot em {
    color: var(--text-primary);
    font-style: italic;
}

.message.bot h1,
.message.bot h2,
.message.bot h3,
.message.bot h4,
.message.bot h5 {
    color: var(--text-primary);
    border-left: 3px solid var(--accent-color);
    padding-left: 10px;
    margin-top: 20px;
    margin-bottom: 8px;
}

.message.bot a {
    color: var(--accent-color);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color 0.2s;
}

.message.bot a:hover {
    border-bottom-color: var(--accent-color);
}

.message.bot code:not([class*="language-"]) {
    background: var(--accent-soft);
    color: var(--accent-color);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.9em;
}

.message.bot ul,
.message.bot ol {
    padding-left: 20px;
}

.message.bot li {
    margin-bottom: 4px;
}

.message.bot li::marker {
    color: var(--accent-color);
}

.message.bot blockquote {
    border-left: 3px solid #1abc9c;
    margin: 12px 0;
    padding: 8px 14px;
    background: rgba(26, 188, 156, 0.06);
    border-radius: 0 8px 8px 0;
    color: var(--text-secondary);
}

/* Code Blocks — VS Code inspired */
pre[class*="language-"] {
    background: var(--code-bg) !important;
    border: 1px solid var(--hover-overlay);
    border-radius: 10px;
    margin: 16px 0;
    padding: 16px !important;
    position: relative;
}

pre[class*="language-"]::before {
    content: attr(data-lang);
    position: absolute;
    top: 0;
    left: 12px; /* <-- CHANGED FROM RIGHT TO LEFT */
    background: var(--hover-overlay);
    color: var(--text-muted);
    font-size: 0.7rem;
    font-family: 'Inter', sans-serif;
    padding: 2px 8px;
    border-radius: 0 0 6px 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

code {
    font-family: 'Fira Code', 'Consolas', monospace;
    font-size: 0.88rem;
}

/* New Copy Code Button Styles */
.copy-code-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 0.75rem;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
    z-index: 10;
}

.copy-code-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: var(--text-primary);
    border-color: var(--border-hover);
}

.copy-code-btn svg {
    width: 14px;
    height: 14px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.input-wrapper {
    position: absolute;
    bottom: 30px;
    left: 15%;
    right: 15%;
    background: var(--input-bg);
    border-radius: 24px;
    padding: 10px 20px;
    display: flex;
    align-items: flex-end;
    gap: 10px;
    z-index: 20;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border-color);
    transition: border-color 0.2s;
}

.input-wrapper:focus-within {
    border-color: var(--border-hover);
}

textarea {
    flex: 1;
    background: transparent;
    border: none;
    color: white;
    font-size: 1rem;
    padding: 12px 0;
    resize: none;
    max-height: 150px;
    outline: none;
    font-family: inherit;
}

.send-icon-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 10px;
    color: var(--text-secondary);
}

.send-icon-btn svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
}

/* Suggestions */
.suggestions-area {
    position: absolute;
    bottom: 150px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    gap: 12px;
    z-index: 15;
    flex-wrap: wrap;
    padding: 0 20px;
}

.suggestion-chip {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    padding: 12px 24px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.9rem;
}

.suggestion-chip:hover {
    background: var(--hover-overlay);
    border-color: var(--border-hover);
    color: var(--text-primary);
}

/* Resources Side (Collapsible) */
.resources-section {
    width: 350px;
    background: var(--sidebar-bg);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    height: 100%;
    transition: width 0.3s ease, padding 0.3s ease, border 0.3s ease;
    overflow: hidden;
    flex-shrink: 0;
}

.res-header {
    padding: 20px;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
}

.sources-list {
    padding: 15px;
    overflow-y: auto;
    flex: 1;
}

.source-card {
    background: var(--surface-raised);
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 15px;
    border: 1px solid transparent;
}

.source-card:hover {
    border-color: var(--border-hover);
}

.source-title {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.source-content {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* --- Fix overflow inside source cards --- */
.source-card {
    overflow: hidden;
}

.source-content {
    max-width: 100%;
    overflow-x: auto;
    box-sizing: border-box;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.source-content pre {
    margin: 0;
    max-width: 100%;
    overflow-x: auto;
    white-space: pre;
    box-sizing: border-box;
}

.source-content code {
    display: block;
    max-width: 100%;
    box-sizing: border-box;
}

/* this adds an option to toggle the resources and context menu */
/* Header layout (so title + button can sit on one row) */
.res-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Small icon button for collapsing panels */
.panel-toggle-btn {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: var(--text-secondary);
    border-radius: 10px;
    padding: 6px 10px;
    cursor: pointer;
    font-size: 14px;
}

.panel-toggle-btn:hover {
    border-color: rgba(255, 255, 255, 0.35);
    color: var(--text-primary);
}

/* Collapse the right resources panel on desktop */
body.hide-resources .resources-section {
    width: 0 !important;
    min-width: 0 !important;
    padding: 0 !important;
    border-left: none !important;
    overflow: hidden !important;
}

/* Hide the text and list on desktop collapse */
body.hide-resources .res-header,
body.hide-resources .sources-list {
    display: none !important;
}

body.hide-resources .resources-section * {
    pointer-events: none;
}

/* ─── Classroom view: Sources & Settings do not apply here ───
   RAG sources produce nothing in the classroom (by design) and the tutor settings are
   chat-only, so collapse the Sources panel and hide the Sources/Settings toolbar
   buttons. Toggled by body.in-classroom (chat.js switchToClassroom / switchToChat);
   removing the class restores the panel to its previous chat state. */
body.in-classroom .resources-section {
    width: 0 !important;
    min-width: 0 !important;
    padding: 0 !important;
    border-left: none !important;
    overflow: hidden !important;
}
body.in-classroom .resources-section * {
    display: none !important;
    pointer-events: none;
}
body.in-classroom #navSources,
body.in-classroom #navSettings {
    display: none !important;
}

/* Top Bar Toggle Button (visible on all screen sizes) */
.top-toggle {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    padding: 4px 10px;
    cursor: pointer;
    font-size: 14px;
    margin-right: 10px;
}

.top-toggle:hover {
    border-color: rgba(255, 255, 255, 0.35);
    color: var(--text-primary);
}


/* Progress Bar */
.progress-step-container {
    background: var(--surface-raised);
    border-radius: 8px;
    padding: 10px;
    width: 250px;
}

.progress-step-text {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.progress-step-track {
    height: 4px;
    background: var(--border-hover);
    border-radius: 2px;
    margin-top: 5px;
}

.progress-step-fill {
    height: 100%;
    background: var(--accent-color);
    border-radius: 2px;
    width: 0%;
    transition: width 0.3s;
}

/* BOT SUGGESTION CHIPS (New) */
.bot-suggestions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 15px;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.suggestion-btn {
    background: var(--surface-raised);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
    font-family: inherit;
}

.suggestion-btn:hover {
    background: var(--sidebar-hover);
    border-color: var(--accent-color);
    color: var(--text-primary);
}

.suggestion-btn.challenge {
    border-color: #e67e22;
    color: #e67e22;
}

.suggestion-btn.challenge:hover {
    background: rgba(230, 126, 34, 0.1);
}

.loading-container {
    width: 100%;
    max-width: 600px;
    padding: 10px 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* The Status Text (e.g. "Reading documents...") */
.loading-status {
    font-size: 0.85rem;
    color: var(--accent-color);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    animation: fadeIn 0.5s ease;
}

/* The Spinner Icon */
.spinner {
    width: 14px;
    height: 14px;
    border: 2px solid rgba(168, 199, 250, 0.3);
    border-top: 2px solid var(--accent-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* The "Ghost" Lines (Skeleton Text) */
.skeleton-line {
    height: 12px;
    border-radius: 6px;
    background: var(--surface-raised);
    background-image: linear-gradient(90deg,
            var(--surface-raised) 0%,
            var(--sidebar-hover) 50%,
            var(--surface-raised) 100%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

.feedback-bar {
    display: flex;
    gap: 12px;
    margin-top: 15px;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    opacity: 0.9;
}

.feedback-bar:hover {
    opacity: 1;
}

.feedback-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    border-radius: 8px;
    padding: 6px 12px;
    font-size: 0.8rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
}

.feedback-btn:hover {
    background: rgba(168, 199, 250, 0.15);
    border-color: rgba(168, 199, 250, 0.3);
    color: var(--accent-color);
}

.feedback-btn.active {
    background: rgba(52, 211, 153, 0.15);
    border-color: rgba(52, 211, 153, 0.3);
    color: var(--success-color);
}

.feedback-btn.active.downvote {
    background: rgba(248, 113, 113, 0.15);
    border-color: rgba(248, 113, 113, 0.3);
    color: #f87171;
}

/* Different widths to look like real text paragraphs */
.w-100 {
    width: 100%;
}

.w-80 {
    width: 80%;
}

.w-60 {
    width: 60%;
}

/* Animations */
@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }

    100% {
        background-position: 200% 0;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 900px) {

    /* Hide toolbar text labels */
    .hide-mobile {
        display: none !important;
    }

    .top-bar-center .toolbar-btn span {
        display: none;
    }

    .brand-name {
        display: none;
    }

    .toolbar-divider {
        display: none;
    }

    /* Classroom stacks vertically on mobile */
    .classroom-split {
        flex-direction: column;
    }

    .classroom-video-side {
        flex: 0 0 40%;
    }

    .classroom-chat-side {
        flex: 1;
    }

    .quick-access-cards {
        flex-direction: column;
        align-items: center;
    }

    .quick-card {
        width: 100%;
        max-width: 300px;
    }

    /* Right panel hidden by default on mobile */
    .resources-section {
        position: absolute;
        right: 0;
        top: 0;
        height: 100%;
        z-index: 100;
        box-shadow: -2px 0 10px rgba(0, 0, 0, 0.5);
        transform: translateX(100%);
        transition: transform 0.3s ease;
        width: 320px;
        max-width: 85%;
        background: var(--sidebar-bg);
    }

    body.show-resources-mobile .resources-section {
        transform: translateX(0) !important;
        width: 320px !important;
        min-width: 320px !important;
        overflow: visible !important;
    }

    body.show-resources-mobile .resources-section * {
        pointer-events: auto !important;
    }

    body.show-resources-mobile .res-header,
    body.show-resources-mobile .sources-list {
        display: block !important;
    }

    body.show-resources-mobile .res-header {
        display: flex !important;
    }

    .sidebar {
        position: absolute;
        z-index: 100;
        height: 100%;
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.5);
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        width: 280px;
        max-width: 85%;
        background: var(--sidebar-bg);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 99;
        display: none;
    }

    .sidebar-overlay.open {
        display: block;
    }

    .input-wrapper {
        left: 5%;
        right: 5%;
        bottom: 20px;
    }

    .messages-container {
        padding: 20px 5%;
        padding-bottom: 100px;
    }

    .welcome-text {
        font-size: 2.8rem;
    }

    .sub-welcome {
        font-size: 1.3rem;
    }
}

@media (max-width: 600px) {
    .auth-card {
        padding: 30px 20px;
    }

    .sidebar {
        width: 280px;
        max-width: 85%;
    }

    .input-wrapper {
        left: 10px;
        right: 10px;
        bottom: 10px;
        padding: 8px 15px;
    }

    textarea {
        font-size: 0.95rem;
        max-height: 100px;
    }

    .welcome-text {
        font-size: 2.2rem;
    }

    .sub-welcome {
        font-size: 1.1rem;
    }

    #dynamicGreeting {
        font-size: 1rem !important;
    }

    .suggestion-chip {
        padding: 10px 16px;
        font-size: 0.85rem;
    }

    .messages-container {
        padding-bottom: 80px;
    }

    .message {
        max-width: 100%;
    }

    .top-bar {
        padding: 10px 15px;
    }
}

/* ── Bot message header row (Tutor label + Listen button inline) ── */
.msg-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
}
.msg-header .msg-sender {
    margin-bottom: 0;
}
.msg-header .speak-btn {
    margin-left: auto;
    font-size: 0.75rem;
    padding: 4px 12px;
}

/* ── TTS Speak Button — teal pill, always visible ────── */
.feedback-btn.speak-btn {
    background: rgba(45, 212, 191, 0.1);
    border: 1px solid rgba(45, 212, 191, 0.35);
    color: #2dd4bf;
    border-radius: 20px;
    font-weight: 600;
    letter-spacing: 0.3px;
    gap: 5px;
}
.feedback-btn.speak-btn:hover {
    background: rgba(45, 212, 191, 0.2);
    border-color: rgba(45, 212, 191, 0.6);
    color: #5eead4;
    box-shadow: 0 0 12px rgba(45, 212, 191, 0.2);
}
.speak-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    box-shadow: none;
}
.speak-btn.active {
    background: rgba(251, 191, 36, 0.15);
    border-color: rgba(251, 191, 36, 0.5);
    color: var(--warning-color);
    box-shadow: 0 0 12px rgba(251, 191, 36, 0.2);
}

/* Loading animation */
.speak-loading {
    font-style: italic;
    opacity: 0.85;
}
.speak-dots span {
    animation: speak-blink 1.4s infinite both;
}
.speak-dots span:nth-child(2) { animation-delay: 0.2s; }
.speak-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes speak-blink {
    0%, 80%, 100% { opacity: 0; }
    40%           { opacity: 1; }
}

/* ── Classroom speak bar (below .cr-message-content) ── */
.cr-speak-bar {
    display: flex;
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}
.cr-speak-bar .speak-btn {
    font-size: 0.75rem;
    padding: 4px 12px;
}
/* ═══ CLASSROOM CHECKPOINT / SRL / PRELAB MODALS ═══ */
.cp-modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.75); backdrop-filter: blur(4px);
    display: none; align-items: center; justify-content: center; z-index: 3000; padding: 20px; }
.cp-modal-overlay.visible { display: flex; }
.cp-modal { background: var(--sidebar-bg); border: 1px solid rgba(255,255,255,0.08); border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.5); max-width: 560px; width: 100%; padding: 28px;
    max-height: 90vh; overflow-y: auto; color: var(--text-primary); animation: cpPop 0.2s ease-out; }
@keyframes cpPop { from { transform: scale(0.96); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.cp-title { font-size: 1.2rem; margin: 0 0 12px; font-weight: 600; }
.cp-badge { display: inline-block; background: rgba(138,180,248,0.15); color: #8ab4f8; padding: 3px 12px;
    border-radius: 999px; font-size: 0.78rem; font-weight: 600; margin-bottom: 8px; }
.cp-instruction { color: var(--text-muted); font-size: 0.85rem; margin: 4px 0 14px; }
.cp-question { font-size: 1.02rem; font-weight: 500; line-height: 1.5; margin: 14px 0; padding: 14px;
    background: var(--input-bg); border-radius: 10px; border-left: 3px solid #8ab4f8; }
.cp-options { display: flex; flex-direction: column; gap: 8px; margin: 14px 0; }
.cp-option { display: flex; align-items: center; gap: 10px; text-align: left; background: var(--input-bg);
    border: 1px solid rgba(255,255,255,0.08); color: var(--text-primary); padding: 12px 14px; border-radius: 10px;
    cursor: pointer; font-size: 0.9rem; font-family: inherit; transition: all 0.15s; }
.cp-option:hover { border-color: rgba(138,180,248,0.4); }
.cp-option.selected { border-color: #8ab4f8; background: rgba(138,180,248,0.12); }
.cp-letter { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px;
    border-radius: 50%; background: var(--sidebar-bg); font-weight: 700; font-size: 0.8rem; flex-shrink: 0; color: #8ab4f8; }
.cp-confidence { display: flex; align-items: center; justify-content: space-between; gap: 10px;
    font-size: 0.82rem; color: var(--text-muted); margin: 8px 0; }
.cp-conf-btns { display: flex; gap: 6px; }
.cp-conf { width: 32px; height: 32px; border-radius: 8px; border: 1px solid rgba(255,255,255,0.08);
    background: var(--input-bg); color: var(--text-muted); cursor: pointer; font-weight: 600; }
.cp-conf.selected { border-color: #8ab4f8; background: rgba(138,180,248,0.12); color: #8ab4f8; }
.cp-feedback { margin: 10px 0; font-size: 0.88rem; }
.cp-correct { color: #34d399; padding: 10px; background: rgba(52,211,153,0.08); border-radius: 8px; }
.cp-wrong { color: #f87171; padding: 10px; background: rgba(248,113,113,0.08); border-radius: 8px; }
.cp-submit, .cp-submit-inline { width: 100%; margin-top: 10px;
    background: linear-gradient(135deg, #6e9df5, #a78bfa); color: #0f1117; border: none; padding: 12px;
    border-radius: 10px; font-weight: 700; font-size: 0.92rem; cursor: pointer; font-family: inherit; }
.cp-submit:disabled { opacity: 0.5; cursor: not-allowed; }
.cp-textarea { width: 100%; box-sizing: border-box; background: var(--input-bg); border: 1px solid rgba(255,255,255,0.08);
    border-radius: 10px; color: var(--text-primary); padding: 12px; font-family: inherit; font-size: 0.9rem; resize: vertical; margin-top: 10px; }
.cp-modal-actions { display: flex; gap: 10px; margin-top: 14px; }
.cp-modal-actions .cp-submit-inline { flex: 1; margin-top: 0; }
.cp-skip { background: var(--input-bg); border: 1px solid rgba(255,255,255,0.08); color: var(--text-muted);
    padding: 12px 20px; border-radius: 10px; cursor: pointer; font-family: inherit; }
.prelab-actions { display: flex; gap: 10px; margin-top: 16px; }
.prelab-actions .cp-submit-inline { flex: 1; margin-top: 0; }
.prelab-shuffle { width: 100%; margin-top: 10px; background: transparent; border: 1px dashed rgba(255,255,255,0.08);
    color: var(--text-muted); padding: 8px; border-radius: 8px; cursor: pointer; font-family: inherit; font-size: 0.82rem; }
