:root {
    --bg: #0a0a0f;
    --surface: #12121a;
    --surface2: #1a1a25;
    --border: #2a2a3a;
    --text: #e4e4e7;
    --text-dim: #71717a;
    --accent: #7c3aed;
    --accent-light: #a78bfa;
    --green: #22c55e;
    --red: #ef4444;
    --yellow: #eab308;
    --sidebar-w: 260px;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', sans-serif;
    background: var(--bg);
    color: var(--text);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ── Header ─────────────────────────────────── */
header {
    display: flex;
    align-items: center;
    padding: 0.6rem 1rem;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    flex-shrink: 0;
    gap: 0.5rem;
    z-index: 50;
}
.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    font-size: 1.05rem;
}
.logo-icon {
    width: 30px;
    height: 30px;
    background: linear-gradient(135deg, var(--accent), #ec4899);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    color: #fff;
}
.header-controls {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-left: auto;
}

/* Section Tabs */
.section-tabs {
    display: flex;
    gap: 0.25rem;
    margin-left: 1rem;
}
.section-tab {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 0.82rem;
    font-weight: 600;
    padding: 0.35rem 0.7rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
}
.section-tab:hover { color: var(--text); background: var(--surface2); }
.section-tab.active { color: var(--accent-light); background: rgba(124, 58, 237, 0.15); }

/* Common button */
.mode-select {
    background: var(--surface2);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.35rem 0.6rem;
    font-size: 0.82rem;
    cursor: pointer;
    outline: none;
}
.mode-select:focus { border-color: var(--accent); }
.btn-icon {
    background: var(--surface2);
    border: 1px solid var(--border);
    color: var(--text-dim);
    border-radius: 8px;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.95rem;
    transition: all 0.15s;
    flex-shrink: 0;
}
.btn-icon:hover { color: var(--text); border-color: var(--accent); }
.btn-icon.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-icon.speaking { background: var(--red); border-color: var(--red); animation: pulse 1s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.7; } }
.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--green);
}
.status-dot.offline { background: var(--red); }

/* ── App Body (sidebar + main) ──────────────── */
.app-screen {
    display: flex;
    flex-direction: column;
    height: 100vh;
}
.app-body {
    display: flex;
    flex: 1;
    overflow: hidden;
    position: relative;
}

/* ── Sidebar ────────────────────────────────── */
.sidebar {
    width: var(--sidebar-w);
    min-width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    transition: margin-left 0.25s ease;
    flex-shrink: 0;
}
.sidebar.collapsed {
    margin-left: calc(-1 * var(--sidebar-w));
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.sidebar-panel {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow-y: auto;
}

.sidebar-new-chat {
    background: var(--surface2);
    border: 1px dashed var(--border);
    color: var(--text-dim);
    border-radius: 8px;
    padding: 0.6rem;
    margin: 0.75rem;
    cursor: pointer;
    font-size: 0.82rem;
    font-family: inherit;
    font-weight: 600;
    transition: all 0.15s;
}
.sidebar-new-chat:hover { border-color: var(--accent); color: var(--text); }

.conversation-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 0 0.5rem 0.5rem;
}

.conv-item {
    display: flex;
    flex-direction: column;
    padding: 0.55rem 0.65rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.12s;
    position: relative;
}
.conv-item:hover { background: var(--surface2); }
.conv-item.active { background: rgba(124, 58, 237, 0.12); }

.conv-title {
    font-size: 0.82rem;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-right: 1.5rem;
}
.conv-item.active .conv-title { color: var(--accent-light); }

.conv-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 0.15rem;
}
.conv-time {
    font-size: 0.7rem;
    color: var(--text-dim);
}
.conv-delete {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    padding: 2px;
    border-radius: 4px;
    opacity: 0;
    transition: opacity 0.15s;
    font-size: 0.75rem;
}
.conv-item:hover .conv-delete { opacity: 1; }
.conv-delete:hover { color: var(--red); background: rgba(239, 68, 68, 0.1); }

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 199;
}

/* ── Main Content ──────────────────────────── */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}
.section-content {
    display: none;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}
.section-content.active {
    display: flex;
}

/* ── Chat Area ──────────────────────────────── */
#chat-area {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    scroll-behavior: smooth;
}
#chat-area::-webkit-scrollbar { width: 6px; }
#chat-area::-webkit-scrollbar-track { background: transparent; }
#chat-area::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.message {
    display: flex;
    gap: 0.75rem;
    max-width: 85%;
    animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.message.user { align-self: flex-end; flex-direction: row-reverse; }
.message.assistant { align-self: flex-start; }

.msg-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
}
.message.user .msg-avatar { background: var(--accent); color: #fff; }
.message.assistant .msg-avatar { background: var(--surface2); border: 1px solid var(--border); }

.msg-body {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.65rem 0.9rem;
    line-height: 1.6;
    font-size: 0.88rem;
    word-wrap: break-word;
    overflow-wrap: break-word;
}
.message.user .msg-body {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.msg-body p { margin-bottom: 0.5rem; }
.msg-body p:last-child { margin-bottom: 0; }
.msg-body strong { color: var(--accent-light); }
.message.user .msg-body strong { color: #fff; }
.msg-body code {
    background: rgba(124, 58, 237, 0.15);
    padding: 0.1rem 0.3rem;
    border-radius: 4px;
    font-size: 0.85em;
}
.msg-body ul, .msg-body ol { padding-left: 1.25rem; margin: 0.5rem 0; }
.msg-body li { margin-bottom: 0.25rem; }
.msg-body hr { border: none; border-top: 1px solid var(--border); margin: 0.75rem 0; }
.msg-body em { color: var(--text-dim); }
.message.user .msg-body em { color: rgba(255,255,255,0.8); }

.sources-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-top: 0.5rem;
}
.source-tag {
    font-size: 0.7rem;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.15rem 0.4rem;
    color: var(--text-dim);
}

/* Typing indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 0.25rem 0;
}
.typing-indicator .typing-label {
    font-size: 0.85rem;
    color: var(--text-dim);
    font-style: italic;
}
.typing-indicator .dot {
    width: 5px;
    height: 5px;
    background: var(--accent-light);
    border-radius: 50%;
    animation: bounce 1.2s infinite;
}
.typing-indicator .dot:nth-child(3) { animation-delay: 0.2s; }
.typing-indicator .dot:nth-child(4) { animation-delay: 0.4s; }
@keyframes bounce {
    0%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-6px); }
}

/* ── Welcome Screen ─────────────────────────── */
.welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    text-align: center;
    gap: 1.5rem;
    padding: 2rem;
}
.welcome h2 {
    font-size: 1.6rem;
    background: linear-gradient(135deg, var(--accent-light), #ec4899);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.welcome p { color: var(--text-dim); max-width: 500px; line-height: 1.6; }
.suggestions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    max-width: 550px;
    width: 100%;
}
.suggestion {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.65rem 0.9rem;
    cursor: pointer;
    text-align: left;
    font-size: 0.82rem;
    color: var(--text-dim);
    transition: all 0.15s;
    line-height: 1.4;
}
.suggestion:hover { border-color: var(--accent); color: var(--text); }
.suggestion strong { color: var(--text); display: block; margin-bottom: 0.2rem; font-size: 0.78rem; }

/* ── Input Area ─────────────────────────────── */
.input-area {
    border-top: 1px solid var(--border);
    padding: 0.65rem 1rem;
    background: var(--surface);
    flex-shrink: 0;
}
.input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    max-width: 900px;
    margin: 0 auto;
}
#msg-input {
    flex: 1;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.55rem 0.9rem;
    color: var(--text);
    font-size: 0.88rem;
    font-family: inherit;
    resize: none;
    outline: none;
    max-height: 150px;
    line-height: 1.5;
}
#msg-input:focus { border-color: var(--accent); }
#msg-input::placeholder { color: var(--text-dim); }
.btn-mic {
    background: var(--surface2);
    border: 1px solid var(--border);
    color: var(--text-dim);
    border-radius: 10px;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.15s;
}
.btn-mic:hover { color: var(--text); border-color: var(--accent); }
.btn-mic.recording {
    background: var(--red);
    border-color: var(--red);
    color: #fff;
    animation: pulse 1s infinite;
}
.btn-send {
    background: var(--accent);
    border: none;
    color: #fff;
    border-radius: 10px;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.1rem;
    flex-shrink: 0;
    transition: all 0.15s;
}
.btn-send:hover { background: #6d28d9; }
.btn-send:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Quiz Panel ─────────────────────────────── */
.quiz-panel {
    display: none;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.25rem;
    margin: 0.5rem 1rem;
    max-height: 50vh;
    overflow-y: auto;
}
.quiz-panel.active { display: block; }
.quiz-question { font-size: 0.92rem; font-weight: 600; margin-bottom: 1rem; line-height: 1.5; }
.quiz-options { display: flex; flex-direction: column; gap: 0.5rem; }
.quiz-option {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.55rem 0.9rem;
    cursor: pointer;
    font-size: 0.88rem;
    transition: all 0.15s;
    display: flex;
    gap: 0.5rem;
}
.quiz-option:hover { border-color: var(--accent); }
.quiz-option.correct { border-color: var(--green); background: rgba(34, 197, 94, 0.1); }
.quiz-option.wrong { border-color: var(--red); background: rgba(239, 68, 68, 0.1); }
.quiz-option.disabled { pointer-events: none; opacity: 0.8; }
.quiz-option .opt-key { font-weight: 700; color: var(--accent-light); min-width: 1.5rem; }
.quiz-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
}
.quiz-score { font-size: 0.82rem; color: var(--text-dim); }
.quiz-score span { color: var(--accent-light); font-weight: 700; }
.btn-next {
    background: var(--accent);
    border: none;
    color: #fff;
    padding: 0.35rem 0.9rem;
    font-size: 0.82rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s;
}
.btn-next:hover { background: #6d28d9; }
.quiz-explanation {
    margin-top: 0.75rem;
    padding: 0.75rem;
    background: var(--surface2);
    border-radius: 8px;
    font-size: 0.82rem;
    line-height: 1.5;
    display: none;
}
.quiz-explanation.visible { display: block; }

/* ── Course Browser (YouTube-style) ────────── */

/* Two-column layout: video left, playlist right */
.course-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
    position: relative;
}
.course-main {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 1.25rem;
    min-width: 0;
}
.course-main::-webkit-scrollbar { width: 5px; }
.course-main::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* Right-side playlist panel */
.course-playlist {
    width: 340px;
    min-width: 340px;
    background: var(--surface);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.playlist-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 0.85rem;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.playlist-title {
    font-weight: 700;
    font-size: 0.88rem;
}
.playlist-count {
    font-size: 0.72rem;
    color: var(--text-dim);
    background: var(--surface2);
    padding: 0.15rem 0.5rem;
    border-radius: 10px;
}
.playlist-list {
    flex: 1;
    overflow-y: auto;
}
.playlist-list::-webkit-scrollbar { width: 4px; }
.playlist-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* Module group in playlist */
.pl-module {
    border-bottom: 1px solid var(--border);
}
.pl-module-header {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.55rem 0.85rem;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.78rem;
    color: var(--text-dim);
    transition: background 0.12s;
    position: sticky;
    top: 0;
    background: var(--surface);
    z-index: 1;
}
.pl-module-header:hover { background: var(--surface2); color: var(--text); }
.pl-chevron { font-size: 0.6rem; width: 0.8rem; transition: transform 0.2s; }
.pl-chevron.open { transform: rotate(90deg); }
.pl-module-count {
    margin-left: auto;
    font-size: 0.65rem;
    font-weight: 500;
}
.pl-lectures { display: none; }
.pl-lectures.open { display: block; }

/* Individual lecture item in playlist */
.pl-item {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.5rem 0.85rem;
    cursor: pointer;
    transition: background 0.12s;
    border-left: 3px solid transparent;
}
.pl-item:hover { background: var(--surface2); }
.pl-item.active {
    background: rgba(124, 58, 237, 0.1);
    border-left-color: var(--accent);
}
.pl-item.playing .pl-num {
    color: var(--accent-light);
}
.pl-num {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-dim);
    min-width: 1.6rem;
    text-align: center;
}
.pl-info {
    flex: 1;
    min-width: 0;
}
.pl-item-title {
    font-size: 0.78rem;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.pl-item.active .pl-item-title { color: var(--accent-light); }
.pl-now-playing {
    font-size: 0.62rem;
    color: var(--accent-light);
    font-weight: 600;
    display: none;
}
.pl-item.active .pl-now-playing { display: block; }

/* ── Course Welcome ─────────────────────────── */
.course-welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 2rem 1rem;
    gap: 1rem;
    height: 100%;
}
.course-welcome h2 {
    font-size: 1.5rem;
    background: linear-gradient(135deg, var(--accent-light), #ec4899);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.course-welcome p { color: var(--text-dim); font-size: 0.88rem; max-width: 500px; }

/* Welcome thumbnail grid */
.cw-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.85rem;
    max-width: 680px;
    width: 100%;
    margin-top: 0.5rem;
}
.cw-card {
    cursor: pointer;
    border-radius: 10px;
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--border);
    transition: all 0.2s;
}
.cw-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(124, 58, 237, 0.2);
}
.cw-thumb {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    background: #000;
}
.cw-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.cw-play-icon {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.35);
    color: #fff;
    font-size: 1.5rem;
    opacity: 0;
    transition: opacity 0.2s;
}
.cw-card:hover .cw-play-icon { opacity: 1; }
.cw-card-info {
    padding: 0.45rem 0.55rem;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}
.cw-card-num {
    font-size: 0.62rem;
    color: var(--accent-light);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.cw-card-title {
    font-size: 0.72rem;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Lecture View (left panel) ─────────────── */
.lecture-view { width: 100%; }
.lecture-view h2 { font-size: 1.15rem; margin: 0; }

.lecture-header-bar {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin-bottom: 0.75rem;
}
.lecture-module-tag {
    display: inline-block;
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--accent-light);
    background: rgba(124, 58, 237, 0.12);
    padding: 0.15rem 0.55rem;
    border-radius: 4px;
    width: fit-content;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* Video player (Plyr) */
.lecture-video-wrap {
    position: relative;
    border-radius: 10px;
    overflow: hidden;
    background: #000;
    max-height: 480px;
}
.lecture-video-wrap .plyr {
    border-radius: 10px;
    max-height: 480px;
}
.lecture-video-wrap .plyr__video-wrapper {
    max-height: 480px;
}
.lecture-video-wrap video {
    width: 100%;
    display: block;
    background: #000;
    max-height: 480px;
}
/* Plyr dark theme overrides */
.plyr {
    --plyr-color-main: var(--accent);
    --plyr-video-background: #000;
    --plyr-menu-background: var(--surface);
    --plyr-menu-color: var(--text);
    --plyr-captions-background: rgba(0,0,0,0.75);
    --plyr-captions-text-color: #fff;
    --plyr-font-size-base: 14px;
    --plyr-font-size-small: 12px;
    --plyr-control-icon-size: 16px;
}
.plyr__menu__container {
    background: var(--surface) !important;
    color: var(--text) !important;
    border: 1px solid var(--border);
}
.plyr__menu__container .plyr__control {
    color: var(--text) !important;
}
.plyr__menu__container .plyr__control:hover,
.plyr__menu__container .plyr__control[aria-expanded="true"] {
    background: var(--surface2) !important;
}
.plyr__menu__container label.plyr__control input[type=radio]:checked+span {
    background: var(--accent) !important;
}

/* Bottom bar under video */
.lecture-info-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-top: 0.65rem;
    padding-bottom: 0.65rem;
    border-bottom: 1px solid var(--border);
}
.lecture-pos {
    font-size: 0.75rem;
    color: var(--text-dim);
    font-weight: 600;
}
.lecture-info-bar .btn-primary {
    font-size: 0.78rem;
    padding: 0.35rem 0.75rem;
    border-radius: 6px;
}

/* (Transcript section removed — subtitles are now in-video via Plyr captions) */

/* Sidebar course outline (legacy, kept for sidebar-course panel) */
.course-outline { padding: 0.5rem 0; display: none; }

/* ── AI Mentor Panel (Course view) ──────────── */
.mentor-panel {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 360px;
    background: var(--surface);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 30;
    transition: transform 0.3s ease;
    box-shadow: -4px 0 20px rgba(0,0,0,0.3);
}
.mentor-panel.collapsed {
    transform: translateX(100%);
    pointer-events: none;
}
.mentor-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.65rem 0.85rem;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    background: var(--surface);
}
.mentor-header-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    font-size: 0.88rem;
}
.mentor-avatar {
    width: 28px;
    height: 28px;
    background: linear-gradient(135deg, var(--accent), #ec4899);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    color: #fff;
}
.mentor-close {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 1.3rem;
    cursor: pointer;
    padding: 0.2rem 0.4rem;
    border-radius: 6px;
    transition: all 0.12s;
    line-height: 1;
}
.mentor-close:hover { color: var(--text); background: var(--surface2); }

.mentor-messages {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}
.mentor-messages::-webkit-scrollbar { width: 4px; }
.mentor-messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.mentor-welcome-msg {
    text-align: center;
    color: var(--text-dim);
    font-size: 0.82rem;
    padding: 2rem 1rem;
    line-height: 1.5;
}

.mentor-msg {
    display: flex;
    gap: 0.5rem;
    max-width: 95%;
    animation: fadeIn 0.2s ease;
}
.mentor-msg.user { align-self: flex-end; flex-direction: row-reverse; }
.mentor-msg.assistant { align-self: flex-start; }
.mentor-msg-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    font-weight: 700;
}
.mentor-msg.user .mentor-msg-avatar { background: var(--accent); color: #fff; }
.mentor-msg.assistant .mentor-msg-avatar { background: var(--surface2); border: 1px solid var(--border); }
.mentor-msg-body {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.5rem 0.7rem;
    font-size: 0.82rem;
    line-height: 1.55;
    word-wrap: break-word;
    overflow-wrap: break-word;
}
.mentor-msg.user .mentor-msg-body {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.mentor-msg-body p { margin-bottom: 0.4rem; }
.mentor-msg-body p:last-child { margin-bottom: 0; }
.mentor-msg-body strong { color: var(--accent-light); }
.mentor-msg.user .mentor-msg-body strong { color: #fff; }
.mentor-msg-body ul, .mentor-msg-body ol { padding-left: 1rem; margin: 0.3rem 0; }
.mentor-msg-body li { margin-bottom: 0.15rem; }
.mentor-msg-body code {
    background: rgba(124, 58, 237, 0.15);
    padding: 0.05rem 0.2rem;
    border-radius: 3px;
    font-size: 0.8em;
}

.mentor-input-area {
    display: flex;
    align-items: flex-end;
    gap: 0.4rem;
    padding: 0.6rem 0.75rem;
    border-top: 1px solid var(--border);
    background: var(--surface);
    flex-shrink: 0;
}
#mentor-input {
    flex: 1;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.45rem 0.7rem;
    color: var(--text);
    font-size: 0.82rem;
    font-family: inherit;
    resize: none;
    outline: none;
    max-height: 100px;
    line-height: 1.4;
}
#mentor-input:focus { border-color: var(--accent); }
#mentor-input::placeholder { color: var(--text-dim); }
.mentor-send {
    background: var(--accent);
    border: none;
    color: #fff;
    border-radius: 8px;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.15s;
}
.mentor-send:hover { background: #6d28d9; }
.mentor-send:disabled { opacity: 0.5; cursor: not-allowed; }

/* Floating AI Mentor button */
.mentor-fab {
    position: absolute;
    bottom: 1.25rem;
    right: 1.25rem;
    background: linear-gradient(135deg, var(--accent), #ec4899);
    border: none;
    color: #fff;
    border-radius: 50%;
    width: 52px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.1rem;
    font-weight: 700;
    box-shadow: 0 4px 16px rgba(124, 58, 237, 0.4);
    transition: all 0.2s;
    z-index: 25;
}
.mentor-fab:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 24px rgba(124, 58, 237, 0.5);
}
.mentor-fab.active { display: none; }
.mentor-fab-icon {
    font-size: 1.2rem;
}

/* ── Auth Screen ────────────────────────────── */
.auth-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1rem;
}
.auth-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 2.5rem 2rem;
    width: 100%;
    max-width: 420px;
}
.auth-logo { text-align: center; margin-bottom: 2rem; }
.logo-icon-lg {
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, var(--accent), #ec4899);
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 700;
    color: #fff;
    margin-bottom: 1rem;
}
.auth-logo h1 { font-size: 1.35rem; margin-bottom: 0.4rem; }
.auth-logo p { color: var(--text-dim); font-size: 0.85rem; }
.auth-form { display: flex; flex-direction: column; gap: 1rem; }
.form-group { display: flex; flex-direction: column; gap: 0.35rem; }
.form-group label { font-size: 0.8rem; color: var(--text-dim); font-weight: 600; }
.form-group input {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.6rem 0.75rem;
    color: var(--text);
    font-size: 0.9rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.15s;
}
.form-group input:focus { border-color: var(--accent); }
.form-group input::placeholder { color: var(--text-dim); }
.form-error { color: var(--red); font-size: 0.82rem; min-height: 1.2em; }
.btn-primary {
    background: var(--accent);
    border: none;
    color: #fff;
    border-radius: 8px;
    padding: 0.65rem;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
}
.btn-primary:hover { background: #6d28d9; }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }
.auth-switch { text-align: center; font-size: 0.85rem; color: var(--text-dim); margin-top: 0.5rem; }
.auth-switch a { color: var(--accent-light); text-decoration: none; }
.auth-switch a:hover { text-decoration: underline; }

/* ── User Menu ─────────────────────────────── */
.user-menu { position: relative; }
.user-btn { font-size: 0.85rem; font-weight: 700; }
.user-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 0.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.75rem;
    min-width: 200px;
    z-index: 100;
}
.user-dropdown.open { display: block; }
.user-dropdown hr { border: none; border-top: 1px solid var(--border); margin: 0.5rem 0; }
.user-dropdown button {
    background: none;
    border: none;
    color: var(--red);
    cursor: pointer;
    font-size: 0.85rem;
    padding: 0.25rem 0;
    font-family: inherit;
}
.user-dropdown button:hover { text-decoration: underline; }
.user-info { font-size: 0.85rem; color: var(--text-dim); line-height: 1.5; }
.user-info strong { color: var(--text); display: block; }

/* ── Responsive ─────────────────────────────── */

/* Tablet: stack playlist below video */
@media (max-width: 1024px) {
    .course-layout { flex-direction: column; }
    .course-playlist {
        width: 100%;
        min-width: 100%;
        max-height: 280px;
        border-left: none;
        border-top: 1px solid var(--border);
    }
}

@media (max-width: 768px) {
    .suggestions { grid-template-columns: 1fr; }
    .message { max-width: 95%; }
    .header-controls { gap: 0.35rem; }
    .mode-select { font-size: 0.78rem; padding: 0.25rem 0.4rem; }
    header { padding: 0.5rem 0.6rem; gap: 0.35rem; }
    .logo span { display: none; }
    .section-tabs { margin-left: 0.25rem; }
    .section-tab { font-size: 0.78rem; padding: 0.3rem 0.5rem; }
    .auth-card { padding: 1.5rem 1.25rem; }

    /* Mobile sidebar: overlay drawer */
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        z-index: 200;
        margin-left: calc(-1 * var(--sidebar-w));
        padding-top: 52px;
        transition: margin-left 0.25s ease;
    }
    .sidebar.open {
        margin-left: 0;
    }
    .sidebar:not(.open) {
        margin-left: calc(-1 * var(--sidebar-w));
    }
    .sidebar-overlay.visible {
        display: block;
    }

    /* Course: tighter spacing on mobile */
    .course-main { padding: 0.65rem; }
    .course-playlist { max-height: 240px; }
    .pl-item { padding: 0.45rem 0.6rem; }
    .cw-grid { grid-template-columns: repeat(2, 1fr); gap: 0.6rem; }
    .lecture-video-wrap, .lecture-video-wrap .plyr, .lecture-video-wrap .plyr__video-wrapper, .lecture-video-wrap video {
        max-height: 300px;
    }

    /* Mentor panel: full width on mobile */
    .mentor-panel { width: 100%; }
    .mentor-fab { bottom: 0.75rem; right: 0.75rem; width: 46px; height: 46px; }
}
