/* ============================================================
   CoursePapa — design system (dark, Udemy-style classroom)
   ============================================================ */
:root {
    --bg: #10121a;
    --bg-raise: #171a24;
    --bg-panel: #1c2030;
    --line: rgba(255, 255, 255, 0.08);
    --line-strong: rgba(255, 255, 255, 0.14);
    --text: #e8eaf0;
    --text-dim: #9aa1b2;
    --text-faint: #6b7280;
    --accent: #6366f1;
    --accent-2: #8b5cf6;
    --grad: linear-gradient(90deg, #7c3aed, #6366f1);
    --green: #34d399;
    --red: #f87171;
    --amber: #fbbf24;
    --radius: 14px;
    --shadow: 0 18px 50px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
    background:
        radial-gradient(1100px 700px at 85% -10%, rgba(99, 102, 241, 0.14) 0%, transparent 60%),
        radial-gradient(900px 600px at -10% 110%, rgba(139, 92, 246, 0.10) 0%, transparent 55%),
        var(--bg);
    background-attachment: fixed;
    color: var(--text);
    min-height: 100vh;
    font-size: 15px;
    line-height: 1.55;
}

a { color: var(--accent); }
h1, h2, h3 { line-height: 1.25; letter-spacing: -0.01em; }

/* ---------- buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 11px 20px; border-radius: 11px; border: 1px solid transparent;
    font: inherit; font-weight: 600; font-size: 14.5px; cursor: pointer;
    color: var(--text); background: var(--bg-panel);
    transition: transform 0.12s ease, filter 0.12s ease, background 0.12s ease;
    text-decoration: none; white-space: nowrap;
}
.btn:hover { filter: brightness(1.12); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--grad); color: #fff; box-shadow: 0 8px 24px rgba(99, 102, 241, 0.35); }
.btn-ghost { background: transparent; border-color: var(--line-strong); color: var(--text-dim); }
.btn-ghost:hover { color: var(--text); }
.btn-sm { padding: 8px 14px; font-size: 13.5px; border-radius: 9px; }
.btn-block { width: 100%; }
.btn-danger:hover { color: var(--red); border-color: rgba(248, 113, 113, 0.4); }

/* ---------- cards / misc ---------- */
.card {
    background: var(--bg-raise);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.muted { color: var(--text-dim); font-size: 14px; }

.form-error {
    background: rgba(248, 113, 113, 0.1);
    border: 1px solid rgba(248, 113, 113, 0.35);
    color: #fecaca; border-radius: 10px; padding: 10px 14px;
    font-size: 14px; margin-bottom: 14px;
}

/* ---------- progress ---------- */
.progress-line { display: flex; align-items: center; gap: 10px; min-width: 0; }
.progress {
    flex: 1; height: 7px; border-radius: 99px; overflow: hidden;
    background: rgba(255, 255, 255, 0.09);
}
.progress-fill {
    height: 100%; border-radius: 99px; background: var(--grad);
    transition: width 0.5s ease;
}
.progress-lg { height: 11px; }
.progress-label { font-size: 13px; color: var(--text-dim); white-space: nowrap; }

/* ============================================================
   Auth pages
   ============================================================ */
.auth-body { display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth-wrap { width: 100%; max-width: 420px; }
.auth-logo {
    display: block; text-align: center; font-size: 28px; font-weight: 800;
    letter-spacing: -0.6px; color: var(--text); text-decoration: none; margin-bottom: 22px;
}
.auth-logo span, .logo span {
    background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.auth-card { padding: 34px 30px; }
.auth-card h1 { font-size: 23px; margin-bottom: 4px; }
.auth-sub { color: var(--text-dim); font-size: 14px; margin-bottom: 22px; }
.field { display: block; margin-bottom: 15px; }
.field span {
    display: block; font-size: 13px; font-weight: 600; color: var(--text-dim); margin-bottom: 6px;
}
.field input {
    width: 100%; padding: 12px 14px; border-radius: 10px; font: inherit;
    background: var(--bg-panel); border: 1px solid var(--line-strong); color: var(--text);
    outline: none; transition: border-color 0.12s ease;
}
.field input:focus { border-color: var(--accent); }
.auth-alt { text-align: center; margin-top: 18px; font-size: 14px; color: var(--text-dim); }
.auth-alt a { font-weight: 600; }

/* ============================================================
   Topbar + dashboard
   ============================================================ */
.topbar {
    display: flex; align-items: center; justify-content: space-between;
    max-width: 1080px; margin: 0 auto; padding: 20px 24px 6px;
}
.logo { font-weight: 800; font-size: 22px; letter-spacing: -0.4px; color: var(--text); text-decoration: none; }
.logo-sm { font-size: 18px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.user-chip {
    font-size: 13.5px; font-weight: 600; color: var(--text-dim);
    background: var(--bg-panel); border: 1px solid var(--line);
    padding: 7px 13px; border-radius: 99px;
}

.container { max-width: 1080px; margin: 0 auto; padding: 22px 24px 70px; }

/* generator */
.generator { padding: 30px 32px; margin-bottom: 38px; position: relative; overflow: hidden; }
.generator::before {
    content: ''; position: absolute; inset: -1px;
    background: radial-gradient(500px 220px at 15% 0%, rgba(139, 92, 246, 0.16), transparent 70%);
    pointer-events: none;
}
.generator-copy { position: relative; margin-bottom: 20px; }
.generator h1 { font-size: 26px; margin-bottom: 6px; }
.generator p { color: var(--text-dim); max-width: 560px; }
.generator-row { position: relative; display: flex; gap: 10px; flex-wrap: wrap; }
.generator-row input[type='text'] {
    flex: 1 1 320px; padding: 13px 16px; font: inherit; border-radius: 11px;
    background: var(--bg-panel); border: 1px solid var(--line-strong); color: var(--text); outline: none;
}
.generator-row input[type='text']:focus { border-color: var(--accent); }
.generator-row select {
    padding: 13px 12px; font: inherit; font-size: 14px; border-radius: 11px; cursor: pointer;
    background: var(--bg-panel); border: 1px solid var(--line-strong); color: var(--text); outline: none;
}
.generator-status { margin-top: 12px; font-size: 14px; color: var(--text-dim); min-height: 21px; }
.generator-status.err { color: var(--red); }
.spinner {
    display: inline-block; width: 14px; height: 14px; vertical-align: -2px; margin-right: 7px;
    border: 2px solid rgba(255, 255, 255, 0.25); border-top-color: #fff; border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* section head */
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 16px; }
.section-head h2 { font-size: 19px; }

/* empty state */
.empty { text-align: center; padding: 54px 20px; }
.empty-icon { font-size: 40px; margin-bottom: 10px; }
.empty h3 { margin-bottom: 4px; }
.empty p { color: var(--text-dim); }

/* course grid */
.course-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(285px, 1fr)); gap: 20px;
}
.course-card { overflow: hidden; display: flex; flex-direction: column; transition: transform 0.15s ease, border-color 0.15s ease; }
.course-card:hover { transform: translateY(-3px); border-color: var(--line-strong); }
.course-thumb { position: relative; display: block; aspect-ratio: 16 / 9; background: #0b0d13; }
.course-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.course-thumb-placeholder {
    width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; font-size: 38px;
}
.badge {
    position: absolute; top: 10px; left: 10px; padding: 4px 10px; border-radius: 99px;
    font-size: 11.5px; font-weight: 700; backdrop-filter: blur(6px);
}
.badge-setup { background: rgba(251, 191, 36, 0.2); color: #fde68a; border: 1px solid rgba(251, 191, 36, 0.4); }
.badge-done { background: rgba(52, 211, 153, 0.18); color: #a7f3d0; border: 1px solid rgba(52, 211, 153, 0.4); }
.course-body { padding: 15px 17px 17px; display: flex; flex-direction: column; gap: 9px; flex: 1; }
.course-body h3 { font-size: 15.5px; }
.course-body h3 a { color: var(--text); text-decoration: none; }
.course-body h3 a:hover { color: #c7cbff; }
.course-desc { color: var(--text-dim); font-size: 13.5px; flex: 1; }
.course-actions { display: flex; gap: 8px; margin-top: 2px; }

/* ============================================================
   Generation progress view
   ============================================================ */
.gen-container { max-width: 860px; }
.gen-head { margin: 26px 0 26px; }
.gen-head h1 { font-size: 26px; margin-bottom: 8px; }
.gen-head p { color: var(--text-dim); margin-bottom: 18px; }
.gen-progress-line { display: flex; align-items: center; gap: 14px; margin-bottom: 10px; }
.gen-progress-line .progress { flex: 1; }
.gen-status { font-size: 13.5px; color: var(--text-faint); }
.gen-status.warn { color: var(--amber); }
.gen-status.good { color: var(--green); }

.gen-outline { display: flex; flex-direction: column; gap: 16px; }
.gen-module { padding: 20px 22px; }
.gen-module h3 { font-size: 15.5px; margin-bottom: 12px; color: #c7cbff; }
.gen-lessons { list-style: none; }
.gen-lesson {
    display: flex; align-items: center; gap: 12px; padding: 9px 0;
    border-bottom: 1px solid var(--line); font-size: 14px;
}
.gen-lesson:last-child { border-bottom: 0; }
.gen-state-icon {
    flex: 0 0 20px; width: 20px; height: 20px; border-radius: 50%;
    border: 2px solid var(--line-strong); position: relative;
}
.gen-lesson[data-state='matched'] .gen-state-icon {
    border-color: var(--green); background: rgba(52, 211, 153, 0.12);
}
.gen-lesson[data-state='matched'] .gen-state-icon::after {
    content: '✓'; position: absolute; inset: 0; display: flex; align-items: center;
    justify-content: center; color: var(--green); font-size: 11px; font-weight: 800;
}
.gen-lesson[data-state='working'] .gen-state-icon {
    border-color: var(--accent); border-top-color: transparent; animation: spin 0.7s linear infinite;
}
.gen-lesson[data-state='error'] .gen-state-icon { border-color: var(--red); }
.gen-lesson[data-state='error'] .gen-state-icon::after {
    content: '!'; position: absolute; inset: 0; display: flex; align-items: center;
    justify-content: center; color: var(--red); font-size: 12px; font-weight: 800;
}
.gen-lesson-title { flex: 1; min-width: 0; }
.gen-lesson[data-state='pending'] .gen-lesson-title { color: var(--text-dim); }
.gen-lesson-meta { font-size: 12.5px; color: var(--text-faint); max-width: 42%; text-align: right; }
.gen-lesson[data-state='matched'] .gen-lesson-meta { color: var(--green); font-weight: 600; }
.gen-lesson[data-state='error'] .gen-lesson-meta { color: var(--red); }
.gen-retry {
    margin-left: 8px; font: inherit; font-size: 12px; font-weight: 600; cursor: pointer;
    background: rgba(248, 113, 113, 0.1); color: var(--red);
    border: 1px solid rgba(248, 113, 113, 0.35); border-radius: 7px; padding: 3px 9px;
}

/* ============================================================
   Classroom
   ============================================================ */
.classroom-body { background: #0b0d13; overflow: hidden; }

/* Generation progress page. Unlike the classroom it is a normal scrolling
   document — `overflow: hidden` on <body> propagates to the viewport, which is
   what used to clip the lower modules. The scrollbar itself is hidden on
   WebKit/Blink, Firefox and legacy Edge while scrolling keeps working. */
.gen-body {
    background: #0b0d13;
    min-height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: none;          /* Firefox */
    -ms-overflow-style: none;       /* legacy Edge / IE */
}
.gen-body::-webkit-scrollbar { width: 0; height: 0; display: none; }
html:has(.gen-body)::-webkit-scrollbar { width: 0; height: 0; display: none; }
.classroom { display: flex; flex-direction: row-reverse; gap: 8px; height: 100vh; }

/* sidebar */
.sidebar {
    flex: 0 0 400px; width: 400px; background: #12141d; border-left: 1px solid var(--line);
    display: flex; flex-direction: column; height: 100vh;
    position: sticky; top: 0;
}
.sidebar-top {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 18px 10px;
}
.sidebar-back { color: var(--text-dim); text-decoration: none; font-size: 13.5px; font-weight: 600; }
.sidebar-back:hover { color: var(--text); }
.sidebar-course { padding: 6px 18px 16px; border-bottom: 1px solid var(--line); }
.sidebar-course h2 {
    font-size: 16px; margin-bottom: 10px; display: -webkit-box;
    -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.sidebar-edit {
    display: inline-block; margin-top: 10px; font-size: 12.5px; font-weight: 600;
    color: var(--text-dim); text-decoration: none;
}
.sidebar-edit:hover { color: var(--accent-2); }
.lesson-nav {
    flex: 1; overflow-y: auto; overflow-x: hidden; padding: 6px 9px 24px;
    scrollbar-width: none;            /* Firefox */
    -ms-overflow-style: none;         /* old Edge/IE */
    overscroll-behavior: contain;
}
.lesson-nav::-webkit-scrollbar { width: 0; height: 0; display: none; }

.nav-module { margin-top: 13px; }
.nav-module-title {
    font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em;
    color: var(--text-faint); padding: 0 3px 7px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* lesson card: YouTube thumbnail with the title underneath */
.nav-lesson {
    display: block; width: 100%; padding: 0; margin: 0 0 11px; text-align: left;
    background: none; border: 0; font: inherit; color: var(--text-dim); cursor: pointer;
}
.nav-thumb {
    position: relative; display: block; width: 100%; aspect-ratio: 16 / 9;
    border-radius: 9px; overflow: hidden; background: #0b0d13;
    border: 1px solid var(--line); transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.nav-thumb img {
    width: 100%; height: 100%; object-fit: cover; display: block;
    opacity: 0.8; transition: opacity 0.15s ease;
}
.nav-thumb-placeholder {
    width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; font-size: 20px;
}
/* hover overlay: dark scrim with the lesson number */
.nav-overlay {
    position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
    background: rgba(8, 10, 16, 0.72);
    opacity: 0; transition: opacity 0.18s ease; pointer-events: none;
}
.nav-overlay .nav-num {
    font-size: 27px; font-weight: 800; color: #fff; letter-spacing: -0.02em;
    text-shadow: 0 2px 12px rgba(0, 0, 0, 0.65);
}
.nav-lesson:hover .nav-overlay,
.nav-lesson:focus-visible .nav-overlay { opacity: 1; }
.nav-lesson:hover .nav-thumb { border-color: var(--line-strong); }
.nav-lesson:hover .nav-thumb img { opacity: 1; }

.nav-title {
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
    font-size: 12.5px; line-height: 1.35; margin-top: 7px; padding: 0 2px;
}
.nav-lesson:hover .nav-title { color: var(--text); }

/* completion check — only rendered for finished lessons */
.nav-check {
    display: none; position: absolute; top: 7px; right: 7px; z-index: 1;
    width: 21px; height: 21px; border-radius: 50%; font-size: 12px; font-weight: 800;
    align-items: center; justify-content: center;
    background: var(--green); color: #06281d; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
}
.nav-lesson[data-completed='1'] .nav-check { display: inline-flex; }
/* hovering an unfinished lesson shows an empty ring in the same slot */
.nav-lesson[data-completed='0']:hover .nav-check,
.nav-lesson[data-completed='0']:focus-visible .nav-check {
    display: inline-flex; background: rgba(11, 13, 19, 0.75);
    border: 1.5px solid rgba(255, 255, 255, 0.4); color: transparent;
}

/* active lesson */
.nav-lesson.active .nav-thumb {
    border-color: rgba(99, 102, 241, 0.85); box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.35);
}
.nav-lesson.active .nav-thumb img { opacity: 1; }
.nav-lesson.active .nav-title { color: #dfe2ff; font-weight: 600; }

.sidebar-toggle {
    display: none; position: sticky; top: 0; z-index: 30; width: 100%;
    background: var(--bg-panel); color: var(--text); border: 0; border-bottom: 1px solid var(--line);
    padding: 13px; font: inherit; font-weight: 600; cursor: pointer;
}

/* stage */
.stage { flex: 1; min-width: 0; display: flex; flex-direction: column; height: 100vh; overflow: hidden; }
.player-wrap {
    position: relative; background: #000;
    flex: 1 1 auto; min-height: 200px; width: 100%;
}
.player-wrap iframe,
.player-wrap #player { width: 100%; height: 100%; display: block; border: 0; }
.player-fallback {
    position: absolute; inset: 0; display: flex; flex-direction: column; gap: 12px;
    align-items: center; justify-content: center; color: var(--text-dim); padding: 20px; text-align: center;
    background: rgba(11, 13, 19, 0.92);
}
.player-fallback[hidden] { display: none; }

/* transient note over the video (e.g. "Resuming from 5:19") */
.player-toast {
    position: absolute; left: 14px; bottom: 14px; z-index: 3;
    padding: 8px 14px; border-radius: 9px;
    background: rgba(8, 10, 16, 0.86); border: 1px solid var(--line-strong);
    color: var(--text); font-size: 13px; font-weight: 600;
    backdrop-filter: blur(6px); pointer-events: none;
    opacity: 1; transition: opacity 0.4s ease;
}
.player-toast[hidden] { display: none; }
.player-toast.fading { opacity: 0; }
.fallback-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

.stage-body {
    flex: 0 0 auto; width: 100%; padding: 9px 18px;
    background: #0e1017; border-top: 1px solid var(--line);
}
.stage-controls { display: flex; align-items: center; gap: 12px; }
.stage-controls .btn { flex: 0 0 auto; padding: 8px 15px; font-size: 13.5px; }

/* custom player controls — the YouTube chrome itself is left untouched */
.player-controls {
    flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 4px;
}
.pc-btn {
    position: relative;
    flex: 0 0 auto; width: 34px; height: 34px; padding: 0;
    border: 0; border-radius: 9px; background: transparent; color: var(--text-dim);
    display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
}
.pc-btn:hover:not(:disabled) { background: rgba(255, 255, 255, 0.08); color: var(--text); }
.pc-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.pc-btn svg { width: 17px; height: 17px; fill: currentColor; display: block; }
.pc-btn .ic-pause,
.pc-btn .ic-muted,
.pc-btn .ic-fs-exit { display: none; }
.pc-btn.playing .ic-play { display: none; }
.pc-btn.playing .ic-pause { display: block; }
.pc-btn.muted .ic-vol { display: none; }
.pc-btn.muted .ic-muted { display: block; }
#pc-fullscreen[aria-pressed='true'] .ic-fs-enter { display: none; }
#pc-fullscreen[aria-pressed='true'] .ic-fs-exit { display: block; }
.pc-complete.done { color: var(--green); background: rgba(52, 211, 153, 0.14); }

/* volume group */
.pc-volume-group { flex: 0 0 auto; display: flex; align-items: center; }

/* shared range styling for seek + volume */
.pc-range {
    -webkit-appearance: none; appearance: none;
    height: 4px; margin: 0 6px; border-radius: 99px;
    background: rgba(255, 255, 255, 0.14); cursor: pointer; outline: none;
}
.pc-range::-webkit-slider-thumb {
    -webkit-appearance: none; width: 12px; height: 12px; border: 0; border-radius: 50%;
    background: var(--accent); cursor: pointer;
}
.pc-range::-moz-range-thumb {
    width: 12px; height: 12px; border: 0; border-radius: 50%;
    background: var(--accent); cursor: pointer;
}
.pc-range:disabled { opacity: 0.4; cursor: not-allowed; }
.pc-range:disabled::-webkit-slider-thumb { background: var(--text-faint); }
.pc-range:disabled::-moz-range-thumb { background: var(--text-faint); }

.pc-seek { flex: 1 1 auto; min-width: 90px; }
.pc-volume { flex: 0 0 76px; width: 76px; margin: 0 2px 0 0; }

/* elapsed / total time */
.pc-time {
    flex: 0 0 auto; white-space: nowrap;
    font-size: 11.5px; font-weight: 600; color: var(--text-dim);
    font-variant-numeric: tabular-nums;
    font-feature-settings: 'tnum' 1;
    padding: 0 8px 0 4px;
}

/* ============================================================
   Course editor
   ============================================================ */
.editor-head { margin: 24px 0 10px; }
.editor-head h1 { font-size: 24px; margin-bottom: 6px; }
.editor-hint {
    font-size: 13.5px; color: var(--text-dim); line-height: 1.6;
    background: var(--bg-raise); border: 1px solid var(--line);
    border-radius: 11px; padding: 12px 16px; margin-bottom: 28px;
}
.editor-hint strong { color: var(--text); }

.el-freshness {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    margin-top: 14px; font-size: 13px; color: var(--text-dim);
}
.el-freshness select {
    padding: 7px 10px; font: inherit; font-size: 13px; border-radius: 9px; cursor: pointer;
    background: var(--bg-panel); border: 1px solid var(--line-strong); color: var(--text); outline: none;
}
.el-freshness-note { font-size: 12.5px; color: var(--text-faint); }

.editor-module { margin-bottom: 30px; }
.editor-module h2 {
    font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em;
    color: var(--text-faint); margin-bottom: 12px;
}
.editor-lesson {
    display: flex; gap: 16px; align-items: flex-start;
    padding: 14px; margin-bottom: 12px; position: relative;
}
.el-thumb {
    flex: 0 0 168px; aspect-ratio: 16 / 9; border-radius: 9px; overflow: hidden;
    background: #0b0d13; border: 1px solid var(--line);
}
.el-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.el-thumb-empty {
    width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
    font-size: 22px; color: var(--text-faint);
}
.el-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.el-lesson { display: flex; gap: 8px; align-items: baseline; }
.el-num { font-size: 12px; color: var(--text-faint); }
.el-title { font-size: 15px; font-weight: 600; }
.el-video { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.el-video-title { font-size: 13.5px; color: var(--text); }
.el-video-meta { font-size: 12.5px; color: var(--text-dim); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.el-video-error { font-size: 12.5px; color: var(--red); }
.el-age-stale { color: var(--amber); font-weight: 600; }
.el-video-missing { font-size: 12.5px; color: var(--text-faint); }
.el-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.el-status { font-size: 12.5px; color: var(--text-dim); }
.el-status:empty { display: none; }
.el-status.good { color: var(--green); }
.el-status.bad { color: var(--red); }

@media (max-width: 640px) {
    .editor-lesson { flex-direction: column; }
    .el-thumb { flex: 0 0 auto; width: 100%; }
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 900px) {
    .classroom-body { overflow: auto; }
    .classroom { flex-direction: column; gap: 0; height: auto; }
    .sidebar {
        position: fixed; z-index: 40; right: 0; top: 0; bottom: 0;
        width: min(340px, 88vw);            /* a 400px drawer is wider than a phone */
        transform: translateX(100%); transition: transform 0.22s ease;
        box-shadow: -20px 0 60px rgba(0, 0, 0, 0.5);
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar-toggle { display: block; }
    .stage { height: auto; overflow: visible; }
    .player-wrap { flex: 0 0 auto; aspect-ratio: 16 / 9; min-height: 0; }
    .stage-body { padding: 9px 12px; }
    .gen-lesson-meta { max-width: 50%; }
}
@media (max-width: 560px) {
    .generator { padding: 22px 18px; }
    .generator h1 { font-size: 21px; }
    .stage-controls { gap: 7px; }
    .stage-controls .btn { padding: 8px 10px; font-size: 12.5px; }
    .pc-btn { width: 30px; height: 30px; }
    .pc-seek { min-width: 48px; margin: 0 2px; }
    .pc-volume { display: none; }   /* keep the bar usable on narrow screens */
}

/* ============================================================
   Certificate of completion
   Designed as an A4 landscape sheet: the on-screen element is the true
   sheet size (297mm x 210mm), and print puts exactly that on the page.
   The background is a single flat colour on purpose — a solid dark page
   soaks up toner and prints patchy, while a light sheet comes out crisp on
   any printer and reads as an official document.
   ============================================================ */
.cert-body {
    /* swap these four for a dark, branded certificate:
       --cert-bg: #101a33;  --cert-ink: #ffffff;  --cert-frame: #c9a86a; */
    --cert-bg:     #fdfcf9;   /* the one flat background colour */
    --cert-ink:    #16213e;   /* deep navy text */
    --cert-accent: #8a6d3b;   /* muted gold for the small print */
    --cert-frame:  #1b2a4a;   /* frame line */
    --cert-soft:   rgba(27, 42, 74, 0.35);

    background: #e6e4de;
    margin: 0;
    padding: 22px 18px 40px;
    overflow-x: auto;         /* a true A4 sheet can be wider than a phone */
}

.cert-actions {
    width: 297mm; max-width: 100%; margin: 0 auto 14px;
    display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.cert-actions-right { display: flex; gap: 8px; }

/* ---- the sheet ---- */
.cert-sheet {
    width: 297mm;
    height: 210mm;            /* exact A4 landscape, so it never spills to page 2 */
    box-sizing: border-box;
    margin: 0 auto;
    padding: 11mm;
    background: var(--cert-bg);
    box-shadow: 0 26px 70px rgba(0, 0, 0, .3);
    position: relative;
}
.cert-inner {
    height: 100%;
    box-sizing: border-box;
    border: 0.7mm solid var(--cert-frame);
    padding: 13mm 15mm 11mm;
    display: flex; flex-direction: column; align-items: center; justify-content: space-evenly;
    text-align: center;
    position: relative;
}
/* inner hairline for the classic double-rule frame */
.cert-inner::before {
    content: '';
    position: absolute; inset: 2.4mm;
    border: 0.25mm solid var(--cert-soft);
    pointer-events: none;
}

.cert-brand {
    font-size: 16pt; font-weight: 800; letter-spacing: -.01em;
    color: var(--cert-ink);
}
.cert-brand span { color: var(--cert-frame); }
.cert-rule {
    width: 26mm; height: 0.9mm; margin: 4mm auto 7mm;
    background: var(--cert-accent);
}
.cert-kicker {
    font-size: 10.5pt; font-weight: 700; letter-spacing: .34em;
    text-transform: uppercase; color: var(--cert-accent);
    margin-bottom: 7mm;
}
.cert-lead {
    font-size: 10.5pt; color: var(--cert-ink); opacity: .7;
    margin-bottom: 2mm;
}
.cert-name {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 33pt; font-weight: 700; line-height: 1.12;
    color: var(--cert-ink);
    margin: 0 0 7mm;
    max-width: 210mm;
}
.cert-course {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 16.5pt; font-weight: 600; line-height: 1.3;
    color: var(--cert-ink);
    margin: 0 auto 5mm;
    max-width: 195mm;
}
.cert-detail {
    font-size: 9.5pt; letter-spacing: .04em; color: var(--cert-ink); opacity: .6;
    padding-top: 4mm; border-top: 0.25mm solid var(--cert-soft);
}

/* ---- footer: signature, seal, verification ---- */
.cert-foot {
    width: 100%; margin-top: 8mm;
    display: flex; align-items: flex-end; justify-content: space-between; gap: 12mm;
}
.cert-sig { flex: 1 1 0; text-align: center; }
.cert-sig-line { height: 0.25mm; background: var(--cert-soft); margin-bottom: 2.5mm; }
.cert-sig-label { font-size: 8pt; line-height: 1.5; color: var(--cert-ink); opacity: .75; }
.cert-sig-label strong { letter-spacing: .08em; opacity: 1; }

.cert-seal {
    flex: 0 0 auto; width: 24mm; height: 24mm; border-radius: 50%;
    background: rgba(138, 109, 59, .08);
    border: 0.6mm solid var(--cert-accent);
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.5mm;
}
.cert-seal-mark { font-size: 15pt; line-height: 1; color: var(--cert-accent); font-weight: 800; }
.cert-seal-note {
    font-size: 5.5pt; letter-spacing: .12em; text-transform: uppercase; color: var(--cert-accent);
}

.cert-hint {
    width: 297mm; max-width: 100%; margin: 16px auto 0; text-align: center;
    font-size: 12.5px; color: #6f6c64;
}
.cert-hint strong { color: #3f3d38; }

/* ---- print: exactly one A4 landscape sheet ---- */
@media print {
    /* margin 0 + a sheet of exactly 297x210mm means no second blank page */
    @page { size: A4 landscape; margin: 0; }

    html, body { margin: 0 !important; padding: 0 !important; background: #fff !important; }
    .cert-body { padding: 0 !important; background: #fff !important; overflow: visible !important; }
    .cert-actions, .cert-hint { display: none !important; }

    .cert-sheet {
        width: 297mm !important; height: 210mm !important;
        margin: 0 !important; box-shadow: none !important; border-radius: 0 !important;
    }
    /* browsers drop background colours when printing unless told otherwise */
    .cert-sheet, .cert-inner, .cert-seal, .cert-rule, .cert-kicker, .cert-sig-line, .cert-detail {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
}

/* certificate records on the dashboard */
.cert-list { display: flex; flex-direction: column; gap: 12px; }
.cert-card { display: flex; align-items: center; gap: 16px; padding: 16px 18px; }
.cert-card-medal { font-size: 28px; line-height: 1; }
.cert-card-body { flex: 1; min-width: 0; }
.cert-card-body h3 { font-size: 15.5px; margin-bottom: 3px; }
.cert-code { font-variant-numeric: tabular-nums; letter-spacing: .04em; color: var(--text-faint); }
.cert-card-actions { flex: 0 0 auto; }
@media (max-width: 560px) {
    .cert-card { flex-wrap: wrap; }
    .cert-card-actions { width: 100%; }
}
.sidebar-cert {
    display: block; margin-top: 10px; padding: 8px 12px; border-radius: 9px;
    font-size: 12.5px; font-weight: 700; text-decoration: none;
    color: #a7f3d0; background: rgba(52, 211, 153, .12); border: 1px solid rgba(52, 211, 153, .4);
}
.sidebar-cert:hover { background: rgba(52, 211, 153, .2); }

/* ============================================================
   Preferences popup
   ============================================================ */
.modal-backdrop {
    position: fixed; inset: 0; z-index: 90;
    background: rgba(6, 8, 13, .72); backdrop-filter: blur(4px);
    display: flex; align-items: center; justify-content: center; padding: 22px;
}
.modal-backdrop[hidden] { display: none; }
.modal {
    width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto;
    background: var(--bg-raise); border: 1px solid var(--line-strong);
    border-radius: 16px; padding: 26px 28px 22px;
    box-shadow: 0 30px 80px rgba(0, 0, 0, .6);
    scrollbar-width: none;
}
.modal::-webkit-scrollbar { width: 0; display: none; }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.modal-head h2 { font-size: 19px; }
.modal-close {
    background: none; border: 0; color: var(--text-dim); font-size: 16px;
    cursor: pointer; padding: 2px 4px; line-height: 1;
}
.modal-close:hover { color: var(--text); }
.modal-sub { font-size: 13px; color: var(--text-dim); margin: 6px 0 20px; line-height: 1.5; }
.prefs-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.prefs-grid .field { margin-bottom: 0; }
.prefs-grid select {
    width: 100%; padding: 10px 12px; font: inherit; font-size: 13.5px; border-radius: 10px; cursor: pointer;
    background: var(--bg-panel); border: 1px solid var(--line-strong); color: var(--text); outline: none;
}
.modal-note { font-size: 12.5px; color: var(--text-faint); line-height: 1.55; margin: 18px 0 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.prefs-summary { font-weight: 500; color: var(--text-faint); font-size: 12.5px; }

@media (max-width: 560px) {
    .prefs-grid { grid-template-columns: 1fr; }
}

/* course allowance line */
.quota-line {
    margin-top: 10px; font-size: 12.5px; color: var(--text-faint);
    display: flex; align-items: center; gap: 6px;
}
.quota-line.quota-out { color: var(--amber); }

/* ============================================================
   Profile
   ============================================================ */
a.user-chip { text-decoration: none; }
a.user-chip:hover { color: var(--text); border-color: var(--line-strong); }

.notice-ok {
    background: rgba(52, 211, 153, .1); border: 1px solid rgba(52, 211, 153, .35);
    color: #a7f3d0; border-radius: 10px; padding: 11px 15px; font-size: 14px; margin-bottom: 16px;
}

.profile-head { display: flex; align-items: center; gap: 18px; padding: 22px 24px; margin: 22px 0 30px; }
.profile-avatar {
    flex: 0 0 62px; width: 62px; height: 62px; border-radius: 50%;
    background: var(--grad); color: #fff; font-size: 26px; font-weight: 800;
    display: flex; align-items: center; justify-content: center;
}
.profile-ident h1 { font-size: 22px; display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.profile-ident .muted { font-size: 13.5px; }
.profile-locked { color: var(--text-faint); font-size: 12.5px; }
.badge-admin {
    font-size: 10.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
    padding: 3px 9px; border-radius: 99px;
    background: rgba(139, 92, 246, .18); color: #d8b4fe; border: 1px solid rgba(139, 92, 246, .45);
}

.profile-section { margin-bottom: 34px; }
.profile-sub { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-faint); margin: 24px 0 12px; }
.profile-empty { padding: 24px; text-align: center; }
.profile-empty p { color: var(--text-dim); font-size: 14px; margin-bottom: 14px; }
.profile-list { display: flex; flex-direction: column; gap: 10px; }
.profile-row { display: flex; align-items: center; gap: 16px; padding: 14px 18px; }
.profile-row-body { flex: 1; min-width: 0; }
.profile-row-body strong { display: block; font-size: 14.5px; margin-bottom: 7px; }

.profile-panel { padding: 20px 22px; margin-bottom: 14px; }
.profile-panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.profile-panel-head h3 { font-size: 15.5px; margin-bottom: 4px; }
.profile-panel-head .muted { font-size: 13.5px; max-width: 60ch; }
.pill { font-size: 11.5px; font-weight: 700; padding: 4px 11px; border-radius: 99px; white-space: nowrap; }
.pill-on { background: rgba(52, 211, 153, .14); color: #a7f3d0; border: 1px solid rgba(52, 211, 153, .4); }
.pill-off { background: rgba(255,255,255,.06); color: var(--text-dim); border: 1px solid var(--line-strong); }

.profile-actions { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin-top: 16px; }
.inline-confirm { display: flex; gap: 8px; align-items: center; }
.inline-confirm input {
    padding: 8px 12px; font: inherit; font-size: 13.5px; border-radius: 9px;
    background: var(--bg-panel); border: 1px solid var(--line-strong); color: var(--text); outline: none; width: 180px;
}

.totp-setup { margin-top: 16px; font-size: 14px; }
.totp-setup p { margin-bottom: 8px; }
.totp-secret {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 17px; letter-spacing: .12em;
    background: var(--bg-panel); border: 1px solid var(--line-strong); border-radius: 10px;
    padding: 12px 16px; color: #dfe2ff; word-break: break-all;
}
.totp-uri { font-size: 11.5px; word-break: break-all; font-family: ui-monospace, monospace; }
.totp-form { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 6px; }
.totp-input {
    width: 140px; padding: 11px 14px; font: inherit; font-size: 20px; letter-spacing: .28em; text-align: center;
    border-radius: 10px; background: var(--bg-panel); border: 1px solid var(--line-strong); color: var(--text); outline: none;
}
.totp-input:focus { border-color: var(--accent); }

.codes-box {
    margin-top: 16px; padding: 16px 18px; border-radius: 11px;
    background: rgba(251, 191, 36, .07); border: 1px solid rgba(251, 191, 36, .35);
}
.codes-box strong { display: block; margin-bottom: 4px; color: #fde68a; }
.codes-box .muted { font-size: 12.5px; margin-bottom: 12px; }
.codes-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 8px; }
.codes-grid code {
    background: rgba(0,0,0,.3); border: 1px solid var(--line-strong); border-radius: 7px;
    padding: 7px 10px; font-size: 13.5px; text-align: center; letter-spacing: .06em; color: var(--text);
}

.password-form { margin-top: 16px; display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; align-items: end; }
.password-form .field { margin-bottom: 0; }
.password-form button { justify-self: start; }

@media (max-width: 560px) {
    .profile-head { flex-direction: column; align-items: flex-start; }
    .profile-row { flex-wrap: wrap; }
}
