:root {
    --bg: #0b0d10;
    --bg-elevated: #14171b;
    --bg-hover: #1c2025;
    --border: #262b31;
    --text: #e8eaed;
    --text-muted: #9aa1a9;
    --accent: #6ee7b7;
    --accent-dim: #2f6f56;
    --danger: #f28b82;
    --radius: 10px;
    --font-display: "Space Grotesk", sans-serif;
    --font-body: "Inter", sans-serif;
    --font-mono: "JetBrains Mono", monospace;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.55;
}

h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 600; margin: 0 0 .4em; }
h1 { font-size: 1.7rem; }
p { margin: 0 0 .8em; }
a { color: inherit; text-decoration: none; }
.muted { color: var(--text-muted); font-size: .9em; }

/* Layout */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
    width: 220px; flex-shrink: 0; background: var(--bg-elevated);
    border-right: 1px solid var(--border); padding: 20px 16px; display: flex; flex-direction: column; gap: 24px;
}
.sidebar.collapsed { display: none; }
.brand { font-family: var(--font-display); font-weight: 700; font-size: 1.1rem; }
.brand span { color: var(--accent); }
.sidebar nav { display: flex; flex-direction: column; gap: 4px; }
.sidebar nav a { padding: 8px 10px; border-radius: var(--radius); color: var(--text-muted); }
.sidebar nav a:hover { background: var(--bg-hover); color: var(--text); }

.main-content { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar { display: flex; align-items: center; padding: 12px 24px; border-bottom: 1px solid var(--border); }
.spacer { flex: 1; }
.page { padding: 28px 32px; max-width: 1100px; }

.icon-btn, .link-btn { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 1.1rem; }
.icon-btn:hover, .link-btn:hover { color: var(--text); }

/* Buttons */
.btn-primary {
    display: inline-block; background: var(--accent); color: #06251b; border: none;
    padding: 10px 18px; border-radius: var(--radius); font-weight: 600; cursor: pointer; font-family: var(--font-body);
}
.btn-primary:hover { opacity: .9; }
.btn-ghost {
    display: inline-block; background: transparent; color: var(--text-muted); border: 1px solid var(--border);
    padding: 9px 16px; border-radius: var(--radius); cursor: pointer;
}
.btn-small { background: var(--bg-hover); color: var(--text); border: 1px solid var(--border); padding: 6px 12px; border-radius: 8px; cursor: pointer; font-size: .85em; }

/* Auth */
.auth-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.auth-card { width: 360px; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 14px; padding: 32px; }
.auth-form { display: flex; flex-direction: column; gap: 14px; margin: 18px 0; }
.auth-form label { display: flex; flex-direction: column; gap: 6px; font-size: .85em; color: var(--text-muted); }
input, textarea {
    background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px;
    color: var(--text); font-family: var(--font-body); font-size: .95em;
}
.alert { background: rgba(242,139,130,.12); border: 1px solid var(--danger); color: var(--danger); padding: 10px 14px; border-radius: var(--radius); margin-bottom: 14px; font-size: .9em; }

/* Dashboard */
.continue-card {
    display: flex; align-items: center; justify-content: space-between; gap: 20px;
    background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 14px; padding: 22px 26px; margin: 20px 0 28px;
}
.eyebrow { text-transform: uppercase; letter-spacing: .08em; font-size: .72em; color: var(--accent); }
.progress-bar { background: var(--bg); border-radius: 999px; height: 6px; margin-top: 8px; width: 220px; overflow: hidden; }
.progress-fill { background: var(--accent); height: 100%; }
.section-title { margin-top: 32px; }
.empty-state { background: var(--bg-elevated); border: 1px dashed var(--border); border-radius: 14px; padding: 32px; text-align: center; margin: 20px 0; }

.course-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.course-card { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; display: block; }
.course-card:hover { border-color: var(--accent-dim); }
.course-card img { width: 100%; aspect-ratio: 16/9; object-fit: cover; }
.course-card-body { padding: 12px 14px; }
.course-card-body h4 { font-size: .95rem; margin-bottom: 4px; }

/* Add course */
.add-course-form { display: flex; gap: 10px; max-width: 560px; }
.add-course-form input { flex: 1; }

/* Course detail */
.course-header { display: flex; gap: 20px; margin-bottom: 24px; }
.course-header-thumb { width: 220px; border-radius: 12px; object-fit: cover; aspect-ratio: 16/9; }
.course-description { max-width: 640px; }
.importing-panel { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 14px; padding: 32px; }
.import-steps { list-style: none; padding: 0; margin: 16px 0; display: flex; flex-direction: column; gap: 6px; color: var(--text-muted); }

.lesson-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 4px; }
.lesson-row a { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 10px; }
.lesson-row a:hover { background: var(--bg-hover); }
.lesson-row.is-complete .lesson-status { color: var(--accent); }
.lesson-status { width: 18px; text-align: center; color: var(--text-muted); }
.lesson-index { font-family: var(--font-mono); color: var(--text-muted); font-size: .85em; }
.lesson-title { flex: 1; }
.lesson-duration { font-family: var(--font-mono); color: var(--text-muted); font-size: .85em; }

/* Lesson (distraction-free) page */
.lesson-shell { max-width: 900px; margin: 0 auto; padding: 0 20px 60px; }
.lesson-shell.focus-mode .sidebar,
.lesson-shell.focus-mode ~ * { display: none; }
.lesson-topbar { display: flex; align-items: center; justify-content: space-between; padding: 16px 0; }
.lesson-back { color: var(--text-muted); }
.lesson-counter { font-family: var(--font-mono); font-size: .85em; color: var(--text-muted); }
.video-wrap { position: relative; width: 100%; aspect-ratio: 16/9; background: #000; border-radius: 12px; overflow: hidden; }
.video-wrap #yt-player, .video-wrap iframe { width: 100%; height: 100%; }
.resume-banner { display: flex; align-items: center; gap: 10px; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; margin-top: 12px; font-size: .9em; }

.lesson-body { margin-top: 24px; }
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tab-btn { background: none; border: none; color: var(--text-muted); padding: 8px 4px; margin-right: 16px; cursor: pointer; border-bottom: 2px solid transparent; font-family: var(--font-body); font-size: .95em; }
.tab-btn.active { color: var(--text); border-bottom-color: var(--accent); }

.note-form { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.note-form textarea { resize: vertical; font-family: var(--font-body); }
.notes-list { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.note-item { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; position: relative; }
.note-timestamp { background: var(--bg); border: 1px solid var(--border); color: var(--accent); border-radius: 6px; padding: 2px 8px; font-family: var(--font-mono); font-size: .8em; cursor: pointer; margin-bottom: 4px; }
.note-delete { position: absolute; top: 8px; right: 10px; background: none; border: none; color: var(--text-muted); cursor: pointer; }

.lesson-footer { display: flex; justify-content: space-between; margin-top: 32px; }

@media (max-width: 760px) {
    .sidebar { display: none; }
    .page { padding: 20px; }
    .course-header { flex-direction: column; }
    .course-header-thumb { width: 100%; }
}
