:root {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --surface-2: #f0f0ed;
  --text: #1c1d1f;
  --muted: #5f6368;
  --border: #e2e2de;
  --accent: #2f5bea;
  --accent-text: #ffffff;
  --accent-soft: #e8eefd;
  --success: #1e7a46;
  --success-soft: #e3f4ea;
  --warn: #8a5a00;
  --warn-soft: #fdf2d8;
  --danger: #b42318;
  --danger-soft: #fde8e6;
  --radius: 10px;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.05), 0 2px 8px rgb(0 0 0 / 0.04);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121314;
    --surface: #1b1c1e;
    --surface-2: #242528;
    --text: #ececea;
    --muted: #a3a6ab;
    --border: #2f3134;
    --accent: #7c9cff;
    --accent-text: #0d1020;
    --accent-soft: #1f2846;
    --success: #6fd29b;
    --success-soft: #16301f;
    --warn: #f0c56a;
    --warn-soft: #33290f;
    --danger: #ff8a7f;
    --danger-soft: #3a1714;
    --shadow: none;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 0.5em; }
h1 { font-size: clamp(1.6rem, 3vw, 2.2rem); }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.1rem; }
p { margin: 0 0 1em; }

.container { width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 16px; }
.narrow { max-width: 560px; }
main { padding: 32px 0 64px; }

/* Header */
.site-header { background: var(--surface); border-bottom: 1px solid var(--border); }
.site-header .container { display: flex; align-items: center; gap: 16px; min-height: 60px; flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 1.1rem; color: var(--text); }
.nav { display: flex; gap: 16px; align-items: center; margin-left: auto; flex-wrap: wrap; }
.nav a { color: var(--text); }
.nav form { margin: 0; }
.linklike { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; cursor: pointer; }
.linklike:hover { text-decoration: underline; }

.site-footer { border-top: 1px solid var(--border); color: var(--muted); font-size: 0.9rem; padding: 24px 0; }

/* Buttons */
.btn, button[type="submit"], .auth button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: 8px; border: 1px solid var(--accent);
  background: var(--accent); color: var(--accent-text); font: inherit; font-weight: 600;
  cursor: pointer; text-decoration: none; line-height: 1.2;
}
.btn:hover, button[type="submit"]:hover { filter: brightness(1.05); text-decoration: none; }
.btn-secondary { background: transparent; color: var(--accent); }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 0.9rem; }
button.linklike { border: 0; background: none; color: var(--accent); padding: 0; font-weight: 400; }

/* Messages */
.messages { list-style: none; padding: 0; margin: 0 0 24px; display: grid; gap: 8px; }
.messages li { padding: 12px 16px; border-radius: 8px; background: var(--accent-soft); }
.messages .success { background: var(--success-soft); color: var(--success); }
.messages .warning { background: var(--warn-soft); color: var(--warn); }
.messages .error { background: var(--danger-soft); color: var(--danger); }

/* Cards & grids */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.grid { display: grid; gap: 20px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.course-card { padding: 0; overflow: hidden; display: flex; flex-direction: column; color: var(--text); }
.course-card:hover { text-decoration: none; border-color: var(--accent); }
.course-card .body { padding: 16px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.cover { aspect-ratio: 16 / 9; width: 100%; object-fit: cover; background: linear-gradient(135deg, var(--accent-soft), var(--surface-2)); }
.cover-placeholder { display: flex; align-items: center; justify-content: center; color: var(--accent); font-weight: 700; font-size: 1.2rem; padding: 16px; text-align: center; }
.muted { color: var(--muted); }
.small { font-size: 0.9rem; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 0.78rem; font-weight: 600; background: var(--surface-2); color: var(--muted); }
.badge-accent { background: var(--accent-soft); color: var(--accent); }
.badge-success { background: var(--success-soft); color: var(--success); }

.hero { padding: 24px 0 40px; }
.hero p { font-size: 1.15rem; color: var(--muted); max-width: 640px; }
.section-title { margin: 40px 0 16px; }

/* Pricing */
.plans { display: grid; gap: 20px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.plan .price { font-size: 2rem; font-weight: 700; }
.plan .price small { font-size: 1rem; font-weight: 400; color: var(--muted); }
.plan form { margin-top: 16px; }

/* Course page */
.course-layout { display: grid; gap: 32px; grid-template-columns: minmax(0, 1fr) 320px; align-items: start; }
.sticky { position: sticky; top: 16px; }
.syllabus { list-style: none; padding: 0; margin: 0 0 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.syllabus .section-head { padding: 12px 16px; background: var(--surface-2); font-weight: 600; }
.syllabus li.lesson { display: flex; gap: 12px; align-items: center; padding: 10px 16px; border-top: 1px solid var(--border); }
.syllabus li.lesson.current { background: var(--accent-soft); }
.syllabus .title { flex: 1; min-width: 0; }
.syllabus .icon { width: 20px; text-align: center; color: var(--muted); flex: none; }
.syllabus .done { color: var(--success); }
.progress { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin: 8px 0; }
.progress > span { display: block; height: 100%; background: var(--success); }
.description { white-space: normal; }

/* Lesson page */
.lesson-layout { display: grid; gap: 24px; grid-template-columns: minmax(0, 1fr) 300px; align-items: start; }
.player { aspect-ratio: 16 / 9; width: 100%; background: #000; border-radius: var(--radius); overflow: hidden; display: block; }
mux-player { --media-object-fit: contain; width: 100%; aspect-ratio: 16 / 9; display: block; }
.player-empty { display: flex; align-items: center; justify-content: center; color: #d1d5db; aspect-ratio: 16 / 9; background: #111; border-radius: var(--radius); }
.lesson-actions { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: center; margin: 16px 0; }
.lesson-actions form { margin: 0; }
.resources { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }

/* Tables */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table-wrap { overflow-x: auto; }

/* Forms (also styles allauth's plain markup) */
form p { margin: 0 0 16px; }
label { display: block; font-weight: 600; margin-bottom: 4px; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="url"], textarea, select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text); font: inherit;
}
input:focus-visible, textarea:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
input[type="checkbox"] + label, input[type="radio"] + label { display: inline; font-weight: 400; margin-left: 6px; }
.errorlist { color: var(--danger); list-style: none; padding: 0; margin: 0 0 8px; }
.helptext, form p > span { display: block; color: var(--muted); font-size: 0.88rem; margin-top: 4px; }
.auth { max-width: 460px; margin: 0 auto; }
.auth .card > h1 { font-size: 1.6rem; }
.auth hr { border: 0; border-top: 1px solid var(--border); margin: 24px 0; }
.auth ul { padding-left: 1.2em; }
.socialaccount_providers, .auth ul.provider-list { list-style: none; padding: 0; }

/* Quiz */
.question { margin-bottom: 20px; }
.question legend { font-weight: 600; margin-bottom: 8px; }
.question fieldset { border: 0; padding: 0; margin: 0; }
.choice { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border-radius: 8px; }
.choice label { font-weight: 400; margin: 0; display: inline; }
.choice.correct { background: var(--success-soft); }
.choice.wrong { background: var(--danger-soft); }

.stack > * + * { margin-top: 16px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }

@media (max-width: 860px) {
  .course-layout, .lesson-layout { grid-template-columns: 1fr; }
  .sticky { position: static; }
}

.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.nav a.btn { color: var(--accent-text); }
.nav .linklike { color: var(--text); }

/* Cohorts */
.schedule { padding-left: 1.2em; margin: 0 0 16px; }
.schedule li { margin-bottom: 6px; }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.checkbox-row { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; align-items: start; }
.checkbox-row input { margin: 4px 0 0; }
.checkbox-row label { font-weight: 400; margin: 0; }
.checkbox-row .helptext { grid-column: 2; margin-top: 0; }
.mobile-only { display: none; }
@media (max-width: 860px) { .mobile-only { display: inline-flex; } }
