:root {
  --bg: #EDE8E0;
  --bg-elev: #F5F1EA;
  --bg-card: #FFFFFF;
  --ink: #1A1625;
  --ink-2: #3A3448;       /* body-secondary — 9.6:1 on cream */
  --ink-3: #5E5770;       /* meta/labels — 6.8:1 on cream, passes AA for normal text */
  --ink-muted: #746C87;   /* ONLY for >=18px / >=14px bold text (AA large) */
  --indigo: #362B7C;
  --indigo-2: #4A3D9C;
  --indigo-soft: #E8E4F4;
  --indigo-tint: #F3F0FA;
  --green: #15864C;        /* darkened so white on green passes AA (4.9:1) */
  --green-ink: #0F5C35;    /* green text on green-soft: 7.3:1 */
  --green-soft: #D8F0E4;
  --red: #A3362A;          /* darkened: white on red ~ 5.9:1, red on red-soft ~ 6.2:1 */
  --red-soft: #F4DDD9;
  --amber: #8A6510;        /* warning text on cream: 6.8:1 */
  --line: rgba(54, 43, 124, 0.22);        /* non-text divider — raised to ≥3:1 */
  --line-strong: rgba(54, 43, 124, 0.38); /* focus-borders/input outlines — ≥3:1 */
  --focus-ring: rgba(54, 43, 124, 0.35);
  --shadow-sm: 0 1px 2px rgba(26, 22, 37, 0.04), 0 1px 3px rgba(26, 22, 37, 0.06);
  --shadow-md: 0 4px 12px rgba(26, 22, 37, 0.06), 0 2px 4px rgba(26, 22, 37, 0.04);
  --shadow-lg: 0 12px 32px rgba(54, 43, 124, 0.12), 0 4px 8px rgba(26, 22, 37, 0.04);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv11", "ss01";
}

.mono { font-family: 'JetBrains Mono', ui-monospace, monospace; }

h1, h2, h3, h4 {
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink);
  line-height: 1.15;
}

h1 { font-size: 48px; letter-spacing: -0.035em; font-weight: 600; }
h2 { font-size: 32px; letter-spacing: -0.025em; }
h3 { font-size: 20px; }
h4 { font-size: 16px; }

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea, select { font-family: inherit; font-size: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }

/* ---------- Nav ---------- */
.nav {
  position: sticky; top: 0; z-index: 50;
  background: rgba(237, 232, 224, 0.88);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.nav-inner {
  max-width: 1200px; margin: 0 auto;
  padding: 14px 32px;
  display: flex; align-items: center; gap: 18px;
  flex-wrap: nowrap;
}
.nav-logo {
  display: flex; align-items: center; gap: 10px;
  font-weight: 600; font-size: 15px; letter-spacing: -0.01em;
  cursor: pointer;
}
.nav-logo-mark {
  width: 32px; height: 32px;
  background: var(--indigo);
  border-radius: 6px;
  display: grid; place-items: center;
  color: white; font-weight: 600; font-size: 12px;
  transform: rotate(45deg);
  flex-shrink: 0;
}
.nav-logo-mark span { transform: rotate(-45deg); }
.nav-logo-img {
  display: block;
  flex-shrink: 0;
  object-fit: contain;
}
.nav-links {
  display: flex; gap: 2px; margin-left: auto; align-items: center;
  flex-wrap: nowrap; flex-shrink: 0;
}
.nav-link {
  padding: 8px 12px; border-radius: 8px;
  font-size: 14px; color: var(--ink-2);
  white-space: nowrap;
  transition: background 0.12s, color 0.12s;
}
.nav-link:hover { background: var(--indigo-tint); color: var(--ink); }
.nav-link.active { color: var(--indigo); background: var(--indigo-soft); }

.nav-progress {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 12px 6px 8px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 13px;
}
.nav-progress-ring {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: conic-gradient(var(--green) var(--p, 0%), var(--indigo-soft) 0);
  position: relative;
}
.nav-progress-ring::after {
  content: ''; position: absolute; inset: 3px;
  background: var(--bg-card); border-radius: 50%;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 18px;
  border-radius: 8px;
  font-weight: 500; font-size: 14px;
  transition: transform 0.08s, background 0.12s, box-shadow 0.12s;
  border: 1px solid transparent;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--indigo); color: white;
}
.btn-primary:hover { background: var(--indigo-2); }
.btn-ghost {
  background: transparent; color: var(--ink);
  border-color: var(--line-strong);
}
.btn-ghost:hover { background: var(--bg-elev); border-color: var(--indigo); }
.btn-green {
  background: var(--green); color: white;
}
.btn-green:hover { filter: brightness(1.05); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-lg { padding: 14px 24px; font-size: 15px; }

/* ---------- Cards ---------- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 12px;
  transition: border-color 0.12s, transform 0.12s, box-shadow 0.12s;
}

/* ---------- Page layout ---------- */
.page { max-width: 1200px; margin: 0 auto; padding: 48px 32px 96px; }
.page-narrow { max-width: 880px; }

/* ---------- Hero ---------- */
.hero {
  padding: 72px 0 56px;
  display: grid; grid-template-columns: 1.4fr 1fr; gap: 56px; align-items: center;
}
.hero-eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12px; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--indigo);
  background: var(--indigo-soft);
  padding: 6px 12px; border-radius: 999px;
  margin-bottom: 20px;
}
.hero h1 { margin-bottom: 20px; max-width: 18ch; }
.hero-lede {
  font-size: 17px; color: var(--ink-2); max-width: 52ch;
  margin-bottom: 28px; line-height: 1.6;
}
.hero-cta { display: flex; gap: 12px; align-items: center; margin-bottom: 32px; }
.hero-stats {
  display: flex; gap: 40px; padding-top: 24px;
  border-top: 1px solid var(--line);
}
.hero-stat-n { font-size: 28px; font-weight: 600; color: var(--indigo); letter-spacing: -0.02em; }
.hero-stat-l { font-size: 13px; color: var(--ink-3); margin-top: 2px; }

.hero-visual {
  position: relative;
  display: grid; place-items: center;
}

/* ---------- Learning goals ---------- */
.goals {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px;
  margin: 16px 0 56px;
}
.goal {
  padding: 24px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.goal-n {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px; color: var(--indigo); margin-bottom: 14px;
}
.goal h4 { margin-bottom: 6px; font-size: 15px; }
.goal p { font-size: 14px; color: var(--ink-2); line-height: 1.55; }

/* ---------- App loading / error ---------- */
.app-loading {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: var(--bg);
}
.app-loading-box {
  text-align: center;
  padding: 32px 28px;
  max-width: 360px;
}
.app-loading-spinner {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 3px solid var(--indigo-soft);
  border-top-color: var(--indigo);
  margin: 0 auto 14px;
  animation: app-spin 0.9s linear infinite;
}
.app-loading-label {
  font-size: 13px; color: var(--ink-3);
  letter-spacing: 0.02em;
}
@keyframes app-spin { to { transform: rotate(360deg); } }

/* ---------- Quiz image (student view) ---------- */
.quiz-image {
  margin: 14px 0 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg-elev);
  display: flex; justify-content: center;
}
.quiz-image img {
  display: block;
  max-width: 100%;
  max-height: 420px;
  height: auto;
  object-fit: contain;
}

/* ---------- Quiz image picker (admin) ---------- */
.quiz-image-selected {
  display: flex; align-items: center; gap: 12px;
  padding: 10px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.quiz-image-selected img {
  width: 72px; height: 72px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--line);
  flex-shrink: 0;
  background: var(--bg-elev);
}

/* ---------- Certificate page ---------- */
.cert-head { margin-bottom: 28px; }
.cert-head .chip { margin-bottom: 14px; }
.cert-head h1 { font-size: 32px; margin-bottom: 8px; }
.cert-head p { color: var(--ink-3); max-width: 600px; }

.cert-progress-card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 22px;
  margin-bottom: 24px;
}
.cert-progress-row {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 16px; margin-bottom: 14px;
}
.cert-progress-label { font-size: 12px; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.04em; }
.cert-progress-value { font-size: 36px; font-weight: 700; color: var(--ink); margin: 4px 0 2px; }
.cert-progress-sub { font-size: 13px; color: var(--ink-3); }
.cert-progress-status {
  font-size: 13px; font-weight: 500; padding: 8px 14px; border-radius: 999px;
  display: inline-flex; align-items: center; gap: 6px;
}
.cert-progress-status.ok   { background: var(--green-soft, #DCEFE0); color: var(--green, #2A8C5C); }
.cert-progress-status.wait { background: var(--indigo-soft); color: var(--indigo); }

.cert-locked, .cert-success {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 22px;
}
.cert-locked h3, .cert-success h3 { font-size: 18px; margin-bottom: 6px; display: flex; align-items: center; gap: 8px; }
.cert-locked p, .cert-success p { color: var(--ink-3); margin-bottom: 14px; }
.cert-success { border-color: var(--green, #2A8C5C); }
.cert-success h3 { color: var(--green, #2A8C5C); }

.cert-form {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 26px;
}
.cert-form h3 { font-size: 18px; margin-bottom: 4px; }

.cert-gdpr {
  background: var(--indigo-tint);
  border: 1px solid var(--indigo-soft);
  border-radius: 8px;
  padding: 14px 16px;
  margin: 16px 0;
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.cert-gdpr--error {
  border-color: var(--red, #C2462E);
  background: #FBE9E5;
  box-shadow: 0 0 0 3px rgba(194, 70, 46, 0.12);
}
.cert-gdpr--error .cert-gdpr-row input[type="checkbox"] {
  outline: 2px solid var(--red, #C2462E);
  outline-offset: 2px;
  border-radius: 2px;
}
.cert-gdpr-row {
  display: flex; gap: 10px; align-items: flex-start;
  font-size: 13px; line-height: 1.55; color: var(--ink-2); cursor: pointer;
}
.cert-gdpr-row input[type="checkbox"] { margin-top: 3px; flex-shrink: 0; }
.cert-gdpr-required {
  display: inline-block;
  font-size: 11px; font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--red, #C2462E);
  background: #FBE9E5;
  border: 1px solid #F2C5BB;
  border-radius: 4px;
  padding: 1px 6px;
  margin-right: 4px;
  vertical-align: 1px;
}
.cert-gdpr-warning {
  display: flex; align-items: center; gap: 8px;
  margin-top: 12px;
  padding: 10px 12px;
  background: #FBE9E5;
  border: 1px solid #F2C5BB;
  border-radius: 6px;
  color: var(--red, #C2462E);
  font-size: 13px;
  font-weight: 500;
}

.cert-error {
  color: var(--red, #C2462E);
  background: #FBE9E5;
  border: 1px solid #F2C5BB;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 14px;
}
.cert-actions { display: flex; gap: 8px; margin-top: 6px; flex-wrap: wrap; }

.cert-cta {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 16px 22px; margin: 16px 0 28px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-card);
  cursor: pointer;
  transition: border-color .15s, transform .15s;
}
.cert-cta:hover { transform: translateY(-1px); }
.cert-cta.ready { border-color: var(--green, #2A8C5C); background: var(--green-soft, #DCEFE0); }
.cert-cta-title { font-size: 15px; font-weight: 600; color: var(--ink); }
.cert-cta-sub   { font-size: 13px; color: var(--ink-3); margin-top: 2px; }

/* ---------- Admin: front page editor ---------- */
.home-editor { max-width: 920px; }
.home-editor-head { margin-bottom: 18px; }
.home-editor-head h2 { font-size: 22px; margin-bottom: 4px; }
.markdown-hint {
  margin-top: 10px;
  padding: 8px 12px;
  background: var(--indigo-tint);
  border: 1px solid var(--indigo-soft);
  border-radius: 6px;
  font-size: 12px;
  color: var(--ink-2);
  line-height: 1.7;
}
.markdown-hint code { font-size: 11px; padding: 1px 4px; }
.home-editor-section {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 22px;
  margin-bottom: 18px;
}
.home-editor-section h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}
.home-editor-list {
  display: flex; flex-direction: column; gap: 12px;
  margin: 12px 0;
}
.home-editor-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--bg-elev);
}
.home-editor-item-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 10px;
}

/* ---------- Admin: tabs + certificates view ---------- */
.admin-tabs {
  display: flex; gap: 4px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 18px;
}
.admin-tab {
  background: none; border: none; cursor: pointer;
  padding: 10px 18px;
  font: inherit; font-size: 14px; color: var(--ink-3);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.admin-tab.active { color: var(--indigo); border-bottom-color: var(--indigo); font-weight: 500; }
.admin-tab:hover  { color: var(--ink); }

.cert-admin-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 16px; margin-bottom: 16px;
}
.cert-admin-head h2 { font-size: 22px; margin-bottom: 4px; }
.cert-admin-empty {
  background: var(--bg-card);
  border: 1px dashed var(--line);
  border-radius: 10px;
  padding: 24px; text-align: center;
  color: var(--ink-3); font-size: 14px;
}
.cert-admin-table {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}
.cert-admin-row {
  display: grid;
  grid-template-columns: 110px 1.2fr 1.4fr 1.4fr 100px 50px;
  gap: 12px;
  padding: 12px 16px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.cert-admin-row:last-child { border-bottom: none; }
.cert-admin-row--head {
  background: var(--indigo-tint);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-3);
  font-weight: 500;
}

/* ---------- Partners ---------- */
.partners-section { margin-top: 56px; margin-bottom: 0; }
.partners-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  align-items: stretch;
}
.partner-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 28px 32px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-card);
  transition: border-color .15s, box-shadow .15s;
  flex: 1 1 0;
  min-width: 220px;
  text-decoration: none;
}
.partner-card:hover {
  border-color: var(--indigo-2);
  box-shadow: 0 2px 12px rgba(0,0,0,.07);
}
.partner-card img {
  max-height: 64px;
  max-width: 100%;
  width: auto;
  object-fit: contain;
  display: block;
}
.partner-card-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-2);
  text-align: center;
}

/* ---------- Lecturers ---------- */
.lecturers-section { margin-bottom: 56px; }

.lecturers-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 16px;
  margin: 16px 0;
}

@media (max-width: 1100px) {
  .lecturers-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 640px) {
  .lecturers-grid { grid-template-columns: repeat(2, 1fr); }
}

.lecturer-card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px 16px 18px;
  display: flex; flex-direction: column; align-items: center;
  text-align: center;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.lecturer-card:hover {
  border-color: var(--indigo);
  box-shadow: var(--shadow-md);
}

.lecturer-avatar {
  width: 80px; height: 80px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--indigo-soft);
  display: grid; place-items: center;
  margin-bottom: 12px;
  flex-shrink: 0;
  border: 2px solid var(--line);
}
.lecturer-avatar img {
  width: 100%; height: 100%; object-fit: cover;
}
.lecturer-initials {
  font-family: 'JetBrains Mono', monospace;
  font-size: 20px; font-weight: 600;
  color: var(--indigo);
  letter-spacing: -0.02em;
}

.lecturer-name {
  font-size: 14px; font-weight: 600;
  color: var(--ink);
  line-height: 1.3;
  margin-bottom: 4px;
}
.lecturer-affil {
  font-size: 12px; color: var(--ink-3);
  line-height: 1.4;
}

/* ---------- Modules grid ---------- */
.section-head {
  display: flex; justify-content: space-between; align-items: end;
  margin-bottom: 24px; padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}
.section-head h2 { margin-bottom: 4px; }
.section-head p { color: var(--ink-3); font-size: 14px; }

.modules {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px;
}

.module-card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 24px;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
  display: grid; grid-template-columns: auto 1fr; gap: 20px;
}
.module-card:hover {
  border-color: var(--indigo);
  box-shadow: var(--shadow-md);
}
.module-card-num {
  width: 56px; height: 56px;
  background: var(--indigo);
  color: white;
  border-radius: 10px;
  display: grid; place-items: center;
  font-weight: 600; font-size: 18px;
  font-family: 'JetBrains Mono', monospace;
  position: relative;
}
.module-card-num.done { background: var(--green); }
.module-card-body h3 { margin-bottom: 6px; font-size: 17px; }
.module-card-desc { font-size: 14px; color: var(--ink-2); line-height: 1.55; margin-bottom: 14px; }
.module-card-meta {
  display: flex; gap: 16px; font-size: 12px; color: var(--ink-3);
  align-items: center;
}
.module-card-meta .dot { width: 3px; height: 3px; background: var(--ink-3); border-radius: 50%; }
.module-card-progress {
  margin-top: 14px;
  height: 6px; background: var(--indigo-tint); border-radius: 999px; overflow: hidden;
}
.module-card-progress-bar {
  height: 100%; background: var(--green); border-radius: 999px;
  transition: width 0.4s;
}
.module-card-progress-label {
  font-size: 12px; color: var(--ink-3); margin-top: 6px;
  display: flex; justify-content: space-between;
}

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 8px; border-radius: 4px;
  font-size: 11px; font-weight: 500;
  background: var(--indigo-soft); color: var(--indigo);
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 0.02em;
}
.chip.green { background: var(--green-soft); color: var(--green-ink); }
.chip.gray { background: var(--bg-elev); color: var(--ink-3); border: 1px solid var(--line); }
.chip.red { background: var(--red-soft); color: var(--red); }

/* ---------- Module detail page ---------- */
.module-layout {
  display: grid; grid-template-columns: 300px 1fr; gap: 40px;
  margin-top: 24px;
}
.module-sidebar {
  position: sticky; top: 80px;
  align-self: start;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  padding-right: 8px;
}
.sidebar-back {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--ink-3); margin-bottom: 20px;
  cursor: pointer;
}
.sidebar-back:hover { color: var(--indigo); }
.sidebar-title { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-3); margin-bottom: 12px; font-weight: 600; }

.chunk-list { list-style: none; display: flex; flex-direction: column; gap: 2px; }
.chunk-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 8px;
  cursor: pointer;
  font-size: 13.5px;
  color: var(--ink-2);
  border: 1px solid transparent;
  transition: background 0.1s;
}
.chunk-item:hover { background: var(--bg-elev); }
.chunk-item.active { background: var(--indigo-soft); color: var(--indigo); font-weight: 500; }
.chunk-item-icon {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--bg-elev); border: 1px solid var(--line);
  display: grid; place-items: center;
  flex-shrink: 0;
  color: var(--ink-3);
}
.chunk-item.done .chunk-item-icon { background: var(--green); border-color: var(--green); color: white; }
.chunk-item-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chunk-item-type { font-size: 10px; color: var(--ink-3); font-family: 'JetBrains Mono', monospace; text-transform: uppercase; }

.module-main { min-width: 0; }
.module-header {
  padding-bottom: 28px; margin-bottom: 32px;
  border-bottom: 1px solid var(--line);
}
.module-header-meta { display: flex; gap: 8px; margin-bottom: 14px; }
.module-header h1 { font-size: 36px; margin-bottom: 10px; }
.module-header p { font-size: 16px; color: var(--ink-2); max-width: 70ch; }

/* ---------- Video chunk ---------- */
.chunk-video {
  background: var(--bg-card); border-radius: 12px; overflow: hidden;
  border: 1px solid var(--line);
}
.video-frame {
  aspect-ratio: 16/9; background: #000;
  position: relative;
}
.video-frame iframe { width: 100%; height: 100%; border: 0; }
/* Two-click consent gate for YouTube videos. No external request fires
   until the user clicks "Load video" — see legal.jsx section 8. */
.video-consent {
  position: absolute; inset: 0;
  background: linear-gradient(180deg, var(--indigo) 0%, var(--indigo-2) 100%);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.video-consent-card {
  text-align: center; color: #fff;
  max-width: 540px;
}
.video-consent-icon {
  width: 60px; height: 60px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  display: grid; place-items: center;
  margin: 0 auto 14px;
}
.video-consent-card h3 {
  font-size: 18px; color: #fff; margin-bottom: 10px;
}
.video-consent-card p {
  font-size: 13.5px; line-height: 1.55; color: rgba(255,255,255,0.92);
  margin-bottom: 10px;
}
.video-consent-card code {
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.25);
  color: #fff;
}
.video-consent-fineprint { font-size: 12px; color: rgba(255,255,255,0.75); }
.video-consent-fineprint a { color: #fff; }
.video-consent-actions {
  display: flex; gap: 8px; justify-content: center; margin-top: 14px;
}
.video-consent-note {
  margin-top: 12px;
  font-size: 11px; color: rgba(255,255,255,0.7);
}

.video-fallback {
  position: absolute; inset: 0;
  background: linear-gradient(180deg, #1a1625 0%, #2a2340 100%);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.video-fallback img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
  opacity: 0.35; filter: blur(1px);
}
.video-fallback-overlay {
  position: relative; z-index: 1;
  text-align: center; color: white;
  padding: 32px; max-width: 480px;
}
.video-fallback-overlay h3 { color: white; margin-bottom: 8px; font-size: 20px; }
.video-fallback-overlay p { font-size: 14px; color: rgba(255,255,255,0.92); line-height: 1.55; }
.video-fallback-badge {
  display: inline-block;
  font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase;
  font-family: 'JetBrains Mono', monospace;
  padding: 4px 10px; border-radius: 999px;
  background: rgba(255,255,255,0.18); color: #ffffff;
  margin-bottom: 14px;
}
.video-footer {
  padding: 20px 24px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
}
.video-footer-meta { font-size: 13px; color: var(--ink-3); }

/* ---------- Text chunk ---------- */
.chunk-text {
  background: var(--bg-card); border: 1px solid var(--line);
  border-radius: 12px; padding: 40px 48px;
  font-size: 16px; line-height: 1.7; color: var(--ink);
}
.chunk-text h3 { font-size: 24px; margin: 28px 0 14px; }
.chunk-text h3:first-child { margin-top: 0; }
.chunk-text p { margin-bottom: 16px; color: var(--ink-2); }
.chunk-text p strong { color: var(--ink); font-weight: 600; }
.chunk-text ul { margin: 8px 0 20px 20px; color: var(--ink-2); }
.chunk-text li { margin-bottom: 6px; }

/* Inline markdown rendering — applies wherever instructor text is shown. */
code {
  background: var(--indigo-tint);
  border: 1px solid var(--indigo-soft);
  border-radius: 4px;
  padding: 1px 5px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.9em;
  color: var(--indigo);
}
del { color: var(--ink-3); text-decoration: line-through; }
em  { font-style: italic; }
.chunk-text a, .hero-lede a, .goal a, .lecturer-affil a, .module-card-desc a {
  color: var(--indigo);
  text-decoration: underline;
  text-decoration-color: var(--indigo-soft);
  text-underline-offset: 2px;
}
.chunk-text a:hover { text-decoration-color: var(--indigo); }
.chunk-text-image {
  margin: 20px 0; border-radius: 10px; overflow: hidden;
  border: 1px solid var(--line);
  aspect-ratio: 16/9;
  background: repeating-linear-gradient(45deg, var(--indigo-tint) 0 10px, var(--indigo-soft) 10px 20px);
  position: relative;
  display: grid; place-items: center;
}
.chunk-text-image .placeholder {
  background: var(--bg-card); padding: 10px 16px; border-radius: 6px;
  font-family: 'JetBrains Mono', monospace; font-size: 12px;
  color: var(--indigo); border: 1px solid var(--line);
}
.chunk-text-figure {
  margin: 20px 0;
}
.chunk-text-figure img {
  display: block; width: 100%; height: auto;
  border-radius: 10px; border: 1px solid var(--line);
}
.chunk-text-figure figcaption {
  text-align: center; font-size: 13px; color: var(--ink-3); margin-top: 8px;
}

/* ---------- Quiz chunk ---------- */
.chunk-quiz {
  background: var(--bg-card); border: 1px solid var(--line);
  border-radius: 12px; padding: 36px 40px;
}
.quiz-head { margin-bottom: 28px; }
.quiz-qnum { font-family: 'JetBrains Mono', monospace; font-size: 12px; color: var(--indigo); margin-bottom: 10px; }
.quiz-question { font-size: 22px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.35; margin-bottom: 10px; }
.quiz-hint { font-size: 13px; color: var(--ink-3); }
.quiz-options { display: flex; flex-direction: column; gap: 10px; margin-bottom: 24px; }
.quiz-option {
  display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: center;
  padding: 16px 18px;
  background: var(--bg-elev);
  border: 1.5px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.12s;
  text-align: left;
  font-size: 15px;
}
.quiz-option:hover:not(:disabled):not(.revealed) { border-color: var(--indigo); background: var(--indigo-tint); }
.quiz-option:disabled { cursor: default; }
.quiz-option-box {
  width: 22px; height: 22px; border-radius: 6px;
  border: 1.5px solid var(--line-strong);
  display: grid; place-items: center;
  background: white;
  color: transparent;
  flex-shrink: 0;
}
.quiz-option.selected .quiz-option-box {
  background: var(--indigo); border-color: var(--indigo); color: white;
}
.quiz-option.revealed-correct {
  background: var(--green-soft); border-color: var(--green);
}
.quiz-option.revealed-correct .quiz-option-box {
  background: var(--green); border-color: var(--green); color: white;
}
.quiz-option.revealed-wrong {
  background: var(--red-soft); border-color: var(--red);
}
.quiz-option.revealed-wrong .quiz-option-box {
  background: var(--red); border-color: var(--red); color: white;
}
.quiz-option.revealed-missed {
  border-color: var(--green); border-style: dashed;
  background: transparent;
}
.quiz-option-letter {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px; color: var(--ink-3); font-weight: 500;
}
.quiz-explanation {
  display: none;
  padding: 18px 22px; border-radius: 10px;
  font-size: 14px; line-height: 1.6;
  margin-top: 12px;
  background: var(--indigo-tint);
  border-left: 3px solid var(--indigo);
}
.quiz-option.revealed-correct .quiz-explanation,
.quiz-option.revealed-wrong .quiz-explanation,
.quiz-option.revealed-missed .quiz-explanation {
  display: block;
  grid-column: 1 / -1;
}
.quiz-option.revealed-correct .quiz-explanation { background: white; border-left-color: var(--green); }
.quiz-option.revealed-wrong .quiz-explanation { background: white; border-left-color: var(--red); }
.quiz-option.revealed-missed .quiz-explanation { background: white; border-left-color: var(--green); }

.quiz-footer {
  display: flex; justify-content: space-between; align-items: center;
  padding-top: 20px; border-top: 1px solid var(--line);
  margin-top: 8px;
}
.quiz-result { font-size: 14px; font-weight: 500; }
.quiz-result.ok { color: var(--green); }
.quiz-result.bad { color: var(--red); }

/* ---------- Chunk nav ---------- */
.chunk-nav {
  margin-top: 32px; display: flex; justify-content: space-between; gap: 12px;
}
.chunk-nav-btn {
  flex: 1; padding: 18px 22px;
  background: var(--bg-card); border: 1px solid var(--line); border-radius: 10px;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.12s;
}
.chunk-nav-btn:hover:not(:disabled) { border-color: var(--indigo); }
.chunk-nav-btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* ---------- Search ---------- */
.search-box { position: relative; flex: 1 1 200px; min-width: 0; max-width: 280px; margin-left: 0; }
.search-input {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px 8px 12px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink-3);
  transition: border-color 0.12s, box-shadow 0.12s;
}
.search-input:focus-within {
  border-color: var(--indigo);
  box-shadow: 0 0 0 3px var(--indigo-soft);
  color: var(--ink);
}
.search-input.open { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.search-input input {
  flex: 1; background: transparent; border: 0; outline: none;
  font-size: 14px; color: var(--ink); min-width: 0;
}
.search-input input::placeholder { color: var(--ink-3); }
.search-kbd {
  font-family: 'JetBrains Mono', monospace; font-size: 11px;
  padding: 2px 6px; border-radius: 4px;
  background: var(--bg-elev); color: var(--ink-3);
  border: 1px solid var(--line);
}
.search-results {
  position: absolute; top: calc(100% - 1px); left: 0; right: 0;
  background: var(--bg-card);
  border: 1px solid var(--indigo);
  border-top-color: var(--line);
  border-radius: 0 0 10px 10px;
  box-shadow: var(--shadow-lg);
  max-height: 480px; overflow-y: auto;
  z-index: 60;
}
.search-results-head {
  padding: 10px 14px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--ink-3); font-weight: 600;
  border-bottom: 1px solid var(--line);
  background: var(--bg-elev);
}
.search-empty { padding: 18px 16px; font-size: 14px; color: var(--ink-2); }
.search-result {
  display: flex; gap: 12px; align-items: flex-start;
  width: 100%;
  padding: 12px 14px;
  border: 0; background: transparent;
  cursor: pointer;
  border-bottom: 1px solid var(--line);
  text-align: left;
}
.search-result:last-child { border-bottom: 0; }
.search-result.focus, .search-result:hover { background: var(--indigo-tint); }
.search-result-icon {
  width: 28px; height: 28px; border-radius: 6px;
  display: grid; place-items: center;
  background: var(--indigo-soft); color: var(--indigo);
  flex-shrink: 0; margin-top: 2px;
}
.search-result-icon.type-quiz { background: var(--green-soft); color: var(--green-ink); }
.search-result-icon.type-text { background: var(--bg-elev); color: var(--ink-2); border: 1px solid var(--line); }
.search-result-title { font-size: 14px; font-weight: 500; margin-bottom: 2px; color: var(--ink); }
.search-result-excerpt { font-size: 13px; color: var(--ink-2); line-height: 1.45; margin-bottom: 4px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.search-result-crumb { font-size: 11px; color: var(--ink-3); display: flex; gap: 6px; align-items: center; }
.search-result mark, .search-empty mark {
  background: #FDE9A8; color: var(--ink);
  padding: 0 2px; border-radius: 3px;
}

@media (max-width: 900px) {
  .search-box { display: none; }
}
button:focus-visible,
a:focus-visible,
[role="button"]:focus-visible,
.quiz-option:focus-visible,
.chunk-item:focus-visible,
.module-card:focus-visible,
.nav-link:focus-visible,
.admin-module-row:focus-visible,
.slides-library-row:focus-visible {
  outline: 2px solid var(--indigo);
  outline-offset: 2px;
}
input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: none;
}
.chunk-nav-btn-dir { font-size: 12px; color: var(--ink-3); margin-bottom: 4px; }
.chunk-nav-btn-title { font-size: 14px; font-weight: 500; }
.chunk-nav-btn.next { text-align: right; }

/* ---------- Admin ---------- */
.admin-login {
  max-width: 420px; margin: 120px auto 0;
  padding: 40px 36px;
  background: var(--bg-card); border: 1px solid var(--line); border-radius: 14px;
}
.admin-login h2 { margin-bottom: 8px; }
.admin-login p { color: var(--ink-3); font-size: 14px; margin-bottom: 24px; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field label { font-size: 13px; font-weight: 500; color: var(--ink-2); }
.field input, .field textarea, .field select {
  padding: 10px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--bg-card);
  font-size: 14px;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.field input:focus, .field textarea:focus, .field select:focus {
  outline: none; border-color: var(--indigo);
  box-shadow: 0 0 0 3px var(--indigo-soft);
}
.field textarea { resize: vertical; min-height: 80px; font-family: inherit; }
.field-hint { font-size: 12px; color: var(--ink-3); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.admin-layout {
  display: grid; grid-template-columns: 280px 1fr; gap: 32px;
  margin-top: 24px;
}
.admin-side {
  background: var(--bg-card); border: 1px solid var(--line); border-radius: 12px;
  padding: 16px; height: fit-content;
  position: sticky; top: 80px;
}
.admin-side-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0 8px 12px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 12px;
}
.admin-side-head-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-3); font-weight: 600; }

.admin-module-row {
  padding: 10px 12px; border-radius: 8px; cursor: pointer;
  display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center;
  font-size: 13.5px;
  border: 1px solid transparent;
  transition: background 0.1s;
}
.admin-module-row:hover { background: var(--bg-elev); }
.admin-module-row.active { background: var(--indigo-soft); color: var(--indigo); font-weight: 500; }
.admin-module-row-handle { color: var(--ink-3); cursor: grab; font-family: 'JetBrains Mono', monospace; font-size: 11px; }
.admin-module-row-status { font-size: 10px; }

.visibility-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 500;
  cursor: pointer;
  transition: background 0.1s;
}
.visibility-toggle.visible { background: var(--green-soft); color: var(--green-ink); }
.visibility-toggle.hidden { background: var(--bg-elev); color: var(--ink-3); border: 1px solid var(--line); }
.visibility-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.admin-main {
  background: var(--bg-card); border: 1px solid var(--line); border-radius: 12px;
  padding: 32px 36px;
}
.admin-main-head {
  display: flex; justify-content: space-between; align-items: start;
  padding-bottom: 20px; border-bottom: 1px solid var(--line); margin-bottom: 24px;
  gap: 16px;
}
.admin-main-head h2 { font-size: 22px; margin-bottom: 4px; }
.admin-main-head .subtle { font-size: 13px; color: var(--ink-3); }

.chunk-editor {
  padding: 20px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 10px;
  margin-bottom: 12px;
}
.chunk-editor-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 14px;
}
.chunk-editor-head-left { display: flex; gap: 10px; align-items: center; }
.chunk-editor-head-right { display: flex; gap: 4px; align-items: center; }
.icon-btn {
  width: 30px; height: 30px; border-radius: 6px;
  display: grid; place-items: center;
  color: var(--ink-3);
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
  background: transparent; border: none;
}
.icon-btn:hover { background: var(--indigo-soft); color: var(--indigo); }
.icon-btn.danger:hover { background: var(--red-soft); color: var(--red); }

.add-chunk-tray {
  display: flex; gap: 8px; padding: 14px; border-radius: 10px;
  background: var(--indigo-tint); border: 1px dashed var(--line-strong);
  align-items: center; justify-content: center;
}

.choice-row {
  display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: start;
  padding: 12px; background: var(--bg-card); border-radius: 8px;
  margin-bottom: 8px; border: 1px solid var(--line);
}
.choice-row-check {
  display: flex; align-items: center; gap: 6px;
  padding-top: 10px;
  font-size: 12px; color: var(--ink-3);
}
.choice-row-check input { width: 18px; height: 18px; accent-color: var(--green); }
.choice-inputs { display: flex; flex-direction: column; gap: 6px; }
.choice-inputs input, .choice-inputs textarea {
  padding: 8px 10px; font-size: 13px;
  border: 1px solid var(--line); border-radius: 6px;
  background: var(--bg-elev);
}
.choice-inputs textarea { min-height: 48px; resize: vertical; }

/* ---------- Slides picker (admin) ---------- */
.slides-picker {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  display: flex; flex-direction: column; gap: 12px;
}
.slides-selected {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  background: var(--indigo-tint);
  border: 1px solid var(--indigo-soft);
  border-radius: 8px;
}
.slides-selected-icon {
  width: 36px; height: 36px; border-radius: 6px;
  background: var(--indigo); color: white;
  display: grid; place-items: center;
  flex-shrink: 0;
}
.slides-selected-name {
  font-weight: 500; font-size: 14px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.slides-selected-meta {
  display: flex; gap: 8px; align-items: center;
  font-size: 12px; color: var(--ink-3); margin-top: 3px;
}
.slides-empty {
  padding: 14px;
  background: var(--bg-elev);
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  font-size: 13px; color: var(--ink-3);
  text-align: center;
}
.slides-actions {
  display: flex; gap: 8px; align-items: start; flex-wrap: wrap;
}
.slides-library {
  border-top: 1px solid var(--line);
  padding-top: 12px;
  margin-top: 4px;
}
.slides-library-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 10px;
}
.slides-library-empty {
  padding: 20px;
  background: var(--bg-elev); border-radius: 8px;
  text-align: center; font-size: 13px; color: var(--ink-3);
}
.slides-library-list {
  display: flex; flex-direction: column; gap: 6px;
  max-height: 280px; overflow-y: auto;
}
.slides-library-row {
  display: flex; gap: 12px; align-items: center;
  padding: 10px 12px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 8px;
  transition: border-color 0.1s, background 0.1s;
}
.slides-library-row:hover { border-color: var(--indigo); }
.slides-library-row.active {
  background: var(--indigo-soft);
  border-color: var(--indigo);
}
.slides-library-row-icon {
  width: 28px; height: 28px; border-radius: 5px;
  background: var(--indigo-soft); color: var(--indigo);
  display: grid; place-items: center; flex-shrink: 0;
}
.slides-library-row.active .slides-library-row-icon {
  background: var(--indigo); color: white;
}
.slides-library-row-name {
  font-size: 13.5px; font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.slides-library-row-meta {
  display: flex; gap: 6px; font-size: 11px; color: var(--ink-3); margin-top: 2px;
}

/* ---------- Progress page ---------- */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 40px; }
.stat-card { padding: 24px; background: var(--bg-card); border: 1px solid var(--line); border-radius: 12px; }
.stat-label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-3); margin-bottom: 10px; font-weight: 500; }
.stat-value { font-size: 30px; font-weight: 600; color: var(--indigo); letter-spacing: -0.02em; line-height: 1; }
.stat-sub { font-size: 13px; color: var(--ink-3); margin-top: 6px; }

.progress-module { padding: 20px 24px; background: var(--bg-card); border: 1px solid var(--line); border-radius: 12px; margin-bottom: 10px; }
.progress-module-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.progress-module-head h4 { font-size: 15px; }
.progress-bar { height: 8px; background: var(--indigo-tint); border-radius: 999px; overflow: hidden; }
.progress-bar-fill { height: 100%; background: var(--green); border-radius: 999px; transition: width 0.5s; }
.progress-module-meta { display: flex; gap: 14px; font-size: 12px; color: var(--ink-3); margin-top: 10px; }

/* ---------- Tweaks ---------- */
.tweaks-panel {
  position: fixed; bottom: 20px; right: 20px;
  background: var(--bg-card); border: 1px solid var(--line-strong);
  border-radius: 12px; padding: 18px 20px;
  box-shadow: var(--shadow-lg);
  z-index: 100; width: 280px;
  display: none;
}
.tweaks-panel.open { display: block; }
.tweaks-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.tweaks-head h4 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.08em; }
.tweak-row { margin-bottom: 12px; }
.tweak-row label { display: block; font-size: 12px; color: var(--ink-2); margin-bottom: 6px; }
.tweak-swatches { display: flex; gap: 6px; }
.tweak-swatch {
  width: 28px; height: 28px; border-radius: 6px;
  border: 2px solid transparent;
  cursor: pointer;
}
.tweak-swatch.active { border-color: var(--ink); }

/* ---------- Hero logo visual ---------- */
.logo-viz {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 24px 32px;
  display: grid; place-items: center;
  position: relative;
  overflow: hidden;
  max-width: 100%;
}
.logo-viz img { height: 196px; width: auto; max-width: 100%; object-fit: contain; display: block; position: relative; z-index: 1; }
.logo-viz::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 100%;
  background: radial-gradient(ellipse at top, var(--indigo-tint), transparent 70%);
}

/* ---------- Site footer ---------- */
.site-footer {
  background: var(--bg-elev);
  border-top: 1px solid var(--line);
  margin-top: 40px;
  padding: 36px 0 32px;
}
.site-footer-inner {
  max-width: 1200px; margin: 0 auto; padding: 0 32px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 24px;
  align-items: center;
}
.site-footer-brand {
  display: flex; align-items: center; gap: 12px;
}
.site-footer-brand-title {
  font-size: 14px; font-weight: 600; letter-spacing: -0.01em;
}
.site-footer-brand-sub {
  font-size: 12px; color: var(--ink-3); margin-top: 2px;
}
.site-footer-links {
  display: flex; gap: 6px; justify-content: center; flex-wrap: wrap;
}
.site-footer-links a {
  padding: 8px 14px; border-radius: 8px;
  font-size: 13px; color: var(--ink-2);
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.site-footer-links a:hover { background: var(--indigo-tint); color: var(--indigo); }
.site-footer-links a.active { color: var(--indigo); background: var(--indigo-soft); }
.site-footer-meta {
  font-size: 12px; color: var(--ink-3);
  text-align: right;
}

@media (max-width: 720px) {
  .site-footer-inner { grid-template-columns: 1fr; text-align: center; }
  .site-footer-brand { justify-content: center; }
  .site-footer-meta { text-align: center; }
}

/* ---------- Legal / privacy pages ---------- */
.legal-page h1 { font-size: 40px; margin: 14px 0 12px; letter-spacing: -0.03em; }
.legal-lede {
  font-size: 16px; color: var(--ink-2); line-height: 1.65;
  max-width: 62ch; margin-bottom: 28px;
}
.legal-block {
  margin-bottom: 36px;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--line);
}
.legal-block:last-of-type { border-bottom: none; }
.legal-block h2 {
  font-size: 22px; margin-bottom: 14px; letter-spacing: -0.02em;
  scroll-margin-top: 90px;
}
.legal-block h3 {
  font-size: 16px; margin: 20px 0 8px;
  color: var(--ink);
}
.legal-block p {
  font-size: 15px; line-height: 1.7; color: var(--ink-2);
  margin-bottom: 12px;
}
.legal-block p strong { color: var(--ink); font-weight: 600; }
.legal-block ul {
  margin: 0 0 16px 22px;
  font-size: 15px; line-height: 1.7; color: var(--ink-2);
}
.legal-block ul li { margin-bottom: 4px; }
.legal-block a {
  color: var(--indigo);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
  text-decoration-color: var(--line-strong);
  cursor: pointer;
}
.legal-block a:hover {
  color: var(--indigo-2);
  text-decoration-color: var(--indigo);
}
.legal-block code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12.5px;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--indigo-tint);
  color: var(--indigo);
  border: 1px solid var(--indigo-soft);
}
.legal-meta {
  font-size: 13px !important;
  color: var(--ink-3) !important;
  font-family: 'JetBrains Mono', monospace;
}
.legal-footer-meta {
  margin-top: 32px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: 12px; color: var(--ink-3);
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 0.02em;
}

.legal-toc {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px 24px;
  margin-bottom: 40px;
}
.legal-toc-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em;
  font-weight: 600; color: var(--ink-3); margin-bottom: 12px;
}
.legal-toc ol {
  list-style: none;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 20px;
  padding: 0;
}
.legal-toc li {
  font-size: 13.5px;
}
.legal-toc a {
  color: var(--ink-2);
  text-decoration: none;
  display: block;
  padding: 4px 0;
  border-bottom: 1px dotted transparent;
}
.legal-toc a:hover {
  color: var(--indigo);
  border-bottom-color: var(--indigo);
}

.legal-table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0 20px;
  font-size: 13.5px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}
.legal-table thead {
  background: var(--indigo-tint);
}
.legal-table th {
  text-align: left;
  padding: 10px 14px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--indigo);
  font-weight: 600;
  border-bottom: 1px solid var(--indigo-soft);
}
.legal-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  color: var(--ink-2);
  line-height: 1.55;
}
.legal-table tr:last-child td { border-bottom: none; }
.legal-table td:first-child { white-space: nowrap; }

@media (max-width: 720px) {
  .legal-toc ol { grid-template-columns: 1fr; }
  .legal-table { font-size: 12.5px; }
  .legal-table th, .legal-table td { padding: 8px 10px; }
  .legal-table td:first-child { white-space: normal; }
}

/* ---------- Cookie banner (GDPR) ---------- */
.cookie-banner {
  position: fixed; bottom: 20px; left: 20px; right: 20px;
  max-width: 960px; margin: 0 auto;
  background: var(--bg-card);
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  z-index: 300;
  overflow: hidden;
  animation: cookieRise 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes cookieRise {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: translateY(0); }
}
.cookie-banner-head {
  display: grid; grid-template-columns: auto 1fr; gap: 18px;
  padding: 24px 28px 20px;
  align-items: start;
}
.cookie-banner-mark {
  width: 40px; height: 40px;
  background: var(--indigo-soft); color: var(--indigo);
  border-radius: 10px;
  display: grid; place-items: center;
  flex-shrink: 0;
}
.cookie-banner-body h3 {
  font-size: 17px; margin-bottom: 6px;
  letter-spacing: -0.01em;
}
.cookie-banner-body p {
  font-size: 14px; color: var(--ink-2); line-height: 1.6;
  max-width: 72ch;
}
.cookie-banner-body p a {
  color: var(--indigo); text-decoration: underline;
  text-underline-offset: 2px; text-decoration-thickness: 1px;
}
.cookie-banner-body p a:hover { color: var(--indigo-2); }
.cookie-banner-actions {
  display: flex; gap: 10px; flex-wrap: wrap;
  padding: 0 28px 24px;
  justify-content: flex-end;
  align-items: center;
}
.cookie-banner-actions .btn { min-width: 128px; justify-content: center; }
.cookie-banner-actions .link-btn {
  font-size: 13px; color: var(--ink-3);
  padding: 8px 4px;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--line-strong);
  margin-right: auto;
}
.cookie-banner-actions .link-btn:hover { color: var(--indigo); text-decoration-color: var(--indigo); }

/* Preferences (expanded) panel */
.cookie-prefs {
  border-top: 1px solid var(--line);
  background: var(--bg-elev);
  padding: 22px 28px 4px;
  max-height: 420px;
  overflow-y: auto;
}
.cookie-prefs-intro {
  font-size: 13px; color: var(--ink-3);
  margin-bottom: 14px;
}
.cookie-cat {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px 18px;
  margin-bottom: 10px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: start;
}
.cookie-cat-title {
  display: flex; align-items: center; gap: 10px;
  font-size: 14.5px; font-weight: 600; margin-bottom: 4px;
}
.cookie-cat-tag {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px; letter-spacing: 0.04em;
  padding: 2px 7px; border-radius: 4px;
  background: var(--bg-elev); color: var(--ink-3);
  border: 1px solid var(--line);
  text-transform: uppercase;
}
.cookie-cat-tag.required {
  background: var(--green-soft); color: var(--green-ink);
  border-color: transparent;
}
.cookie-cat-desc {
  font-size: 13px; color: var(--ink-2); line-height: 1.55;
  margin-bottom: 8px;
}
.cookie-cat-detail {
  font-size: 11.5px; color: var(--ink-3);
  font-family: 'JetBrains Mono', monospace;
  display: flex; flex-wrap: wrap; gap: 4px 12px;
}
.cookie-cat-detail span::before {
  content: '·'; margin-right: 10px; color: var(--line-strong);
}
.cookie-cat-detail span:first-child::before { content: ''; margin-right: 0; }

/* Toggle switch */
.toggle {
  position: relative;
  width: 40px; height: 24px;
  background: var(--bg-elev);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.18s, border-color 0.18s;
  flex-shrink: 0;
  padding: 0;
}
.toggle::after {
  content: '';
  position: absolute; top: 2px; left: 2px;
  width: 18px; height: 18px;
  background: white;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
  transition: transform 0.18s;
}
.toggle.on { background: var(--indigo); border-color: var(--indigo); }
.toggle.on::after { transform: translateX(16px); }
.toggle.locked {
  background: var(--green); border-color: var(--green);
  cursor: not-allowed; opacity: 0.9;
}
.toggle.locked::after { transform: translateX(16px); }

/* Tiny "Cookies" bubble to reopen prefs */
.cookie-reopen {
  position: fixed; bottom: 18px; left: 18px;
  background: var(--bg-card);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 8px 14px 8px 10px;
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--ink-2);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  z-index: 90;
  transition: border-color 0.12s, color 0.12s, background 0.12s;
}
.cookie-reopen:hover { border-color: var(--indigo); color: var(--indigo); background: var(--indigo-tint); }
.cookie-reopen-dot {
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--indigo-soft); color: var(--indigo);
  display: grid; place-items: center;
}

@media (max-width: 720px) {
  .cookie-banner { left: 12px; right: 12px; bottom: 12px; }
  .cookie-banner-head { padding: 20px 20px 16px; }
  .cookie-banner-actions { padding: 0 20px 20px; }
  .cookie-banner-actions .btn { flex: 1; min-width: 0; }
  .cookie-banner-actions .link-btn { margin-right: 0; width: 100%; text-align: center; order: -1; }
}

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(80px);
  background: var(--ink); color: white; padding: 12px 20px; border-radius: 10px;
  font-size: 14px; box-shadow: var(--shadow-lg);
  transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
  z-index: 200;
}
.toast.show { transform: translateX(-50%) translateY(0); }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; }
  .modules { grid-template-columns: 1fr; }
  .module-layout, .admin-layout { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .goals { grid-template-columns: 1fr; }
}
