/* ─── Reset & base ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --purple:   #7F77DD;
  --purple-lt:#EEEDFE;
  --purple-dk:#3C3489;
  --teal:     #1D9E75;
  --teal-lt:  #E1F5EE;
  --teal-dk:  #085041;
  --amber:    #EF9F27;
  --amber-lt: #FAEEDA;
  --amber-dk: #633806;
  --coral:    #D85A30;
  --coral-lt: #FAECE7;
  --green-lt: #EAF3DE;
  --green-dk: #27500A;
  --red-lt:   #FCEBEB;
  --red-dk:   #791F1F;
  --bg:       #F8F7FC;
  --surface:  #FFFFFF;
  --border:   #E2E0F0;
  --text:     #1A1833;
  --text-2:   #5B5780;
  --text-3:   #9C9AB8;
  --radius:   8px;
  --radius-lg:12px;
  --shadow:   0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --font:     -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono:     'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
}
html { font-size: 16px; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}
a { color: var(--purple); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ─── Navbar ────────────────────────────────────────────── */
.navbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
}
.nav-inner {
  max-width: 1100px; margin: 0 auto;
  padding: 0 1.5rem;
  height: 56px;
  display: flex; align-items: center; gap: 1.5rem;
}
.nav-brand {
  font-size: 1.1rem; font-weight: 600;
  color: var(--text); display: flex; align-items: center; gap:.4rem;
  text-decoration: none;
}
.brand-icon { font-size: 1.3rem; }
.nav-links { display: flex; gap: .25rem; flex: 1; }
.nav-link {
  padding: .4rem .75rem; border-radius: var(--radius);
  color: var(--text-2); font-size: .9rem; text-decoration: none;
  transition: background .15s, color .15s;
}
.nav-link:hover, .nav-link.active {
  background: var(--purple-lt); color: var(--purple-dk);
  text-decoration: none;
}
.nav-user { display: flex; align-items: center; gap: .75rem; }
.nav-username {
  font-size: .85rem; font-weight: 500; color: var(--text-2);
}
.btn-logout {
  font-size: .8rem; padding: .3rem .75rem;
  border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text-2); background: transparent;
  cursor: pointer; text-decoration: none;
  transition: background .15s;
}
.btn-logout:hover { background: var(--bg); text-decoration: none; }

/* ─── Flash messages ────────────────────────────────────── */
.flash {
  max-width: 1100px; margin: 1rem auto; padding: .75rem 1.25rem;
  border-radius: var(--radius); font-size: .9rem; font-weight: 500;
}
.flash-error   { background: var(--red-lt);   color: var(--red-dk);   border-left: 3px solid #E24B4A; }
.flash-success { background: var(--green-lt); color: var(--green-dk); border-left: 3px solid #639922; }

/* ─── Main content wrapper ──────────────────────────────── */
.main-content {
  max-width: 1100px; margin: 0 auto; padding: 2rem 1.5rem;
}

/* ─── Buttons ───────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .5rem 1.1rem; border-radius: var(--radius);
  font-size: .9rem; font-weight: 500; cursor: pointer;
  border: 1px solid transparent; text-decoration: none;
  transition: background .15s, transform .1s;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: scale(.98); }
.btn-primary  { background: var(--purple); color: #fff; border-color: var(--purple); }
.btn-primary:hover { background: var(--purple-dk); border-color: var(--purple-dk); }
.btn-outline  { background: transparent; color: var(--purple); border-color: var(--purple); }
.btn-outline:hover { background: var(--purple-lt); }
.btn-ghost    { background: transparent; color: var(--text-2); border-color: var(--border); }
.btn-ghost:hover { background: var(--bg); }
.btn-done     { background: var(--teal-lt); color: var(--teal-dk); border-color: var(--teal); }
.btn-sm       { padding: .3rem .75rem; font-size: .8rem; }
.btn-lg       { padding: .7rem 1.5rem; font-size: 1rem; }
.btn-full     { width: 100%; justify-content: center; }
.btn-copy, .btn-toggle {
  background: transparent; border: 1px solid var(--border);
  color: var(--text-2); font-size: .78rem; padding: .2rem .6rem;
  border-radius: var(--radius); cursor: pointer;
}
.btn-toggle:hover { background: var(--bg); }
.btn-danger   { border-color: #E24B4A; color: var(--red-dk); }
.btn-danger:hover { background: var(--red-lt); }

/* ─── Badges ────────────────────────────────────────────── */
.badge        { padding: .25rem .75rem; border-radius: 20px; font-size: .78rem; font-weight: 500; }
.badge-gold   { background: var(--amber-lt); color: var(--amber-dk); border: 1px solid var(--amber); }
.mod-badge    { background: var(--purple-lt); color: var(--purple-dk); border: 1px solid #AFA9EC; padding: .15rem .6rem; border-radius: 20px; font-size: .75rem; }
.diff-badge   { padding: .15rem .6rem; border-radius: 20px; font-size: .75rem; font-weight: 500; }
.diff-easy    { background: var(--green-lt); color: var(--green-dk); border: 1px solid #97C459; }
.diff-medium  { background: var(--amber-lt); color: var(--amber-dk); border: 1px solid var(--amber); }
.diff-hard    { background: var(--coral-lt); color: #712B13;          border: 1px solid #F09975; }

/* ─── Landing page ──────────────────────────────────────── */
.landing { max-width: 900px; margin: 0 auto; }
.landing-hero { text-align: center; padding: 4rem 1rem 3rem; }
.hero-badge {
  display: inline-block; margin-bottom: 1rem;
  background: var(--purple-lt); color: var(--purple-dk);
  border: 1px solid #AFA9EC; padding: .3rem 1rem;
  border-radius: 20px; font-size: .85rem; font-weight: 500;
}
.hero-title { font-size: 3rem; font-weight: 700; line-height: 1.15; margin-bottom: 1rem; }
.hero-accent { color: var(--purple); }
.hero-sub { font-size: 1.1rem; color: var(--text-2); max-width: 560px; margin: 0 auto 2rem; }
.hero-actions { display: flex; gap: 1rem; justify-content: center; flex-wrap: wrap; }
.landing-stats {
  display: grid; grid-template-columns: repeat(4,1fr); gap: 1rem;
  margin: 2rem 0;
}
.lstat { background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 1.5rem; text-align: center; }
.lstat-n { font-size: 2rem; font-weight: 700; color: var(--purple); }
.lstat-l { font-size: .85rem; color: var(--text-2); margin-top: .25rem; }
.section-title { font-size: 1.3rem; font-weight: 600; margin-bottom: 1rem; }
.module-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px,1fr)); gap: .75rem; }
.module-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 1rem;
  display: flex; align-items: center; gap: .6rem;
}
.module-icon { font-size: 1.3rem; }
.module-name { font-size: .85rem; font-weight: 500; }

/* ─── Auth pages ────────────────────────────────────────── */
.auth-page {
  display: flex; align-items: center; justify-content: center;
  min-height: 70vh;
}
.auth-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 2.5rem;
  width: 100%; max-width: 420px;
  box-shadow: var(--shadow);
}
.auth-logo { font-size: 2.5rem; text-align: center; margin-bottom: .75rem; }
.auth-title { font-size: 1.4rem; font-weight: 700; text-align: center; margin-bottom: .25rem; }
.auth-sub { color: var(--text-2); text-align: center; font-size: .9rem; margin-bottom: 1.75rem; }
.auth-form { display: flex; flex-direction: column; gap: 1rem; }
.form-group { display: flex; flex-direction: column; gap: .3rem; }
.form-label { font-size: .85rem; font-weight: 500; color: var(--text-2); }
.form-input {
  padding: .6rem .9rem; border: 1px solid var(--border);
  border-radius: var(--radius); font-size: .95rem;
  background: var(--bg); color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
.form-input:focus { outline: none; border-color: var(--purple); box-shadow: 0 0 0 3px rgba(127,119,221,.15); }
.auth-switch { text-align: center; font-size: .85rem; color: var(--text-2); margin-top: 1.25rem; }

/* ─── Dashboard ─────────────────────────────────────────── */
.dash-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 1rem; margin-bottom: 1.5rem; flex-wrap: wrap;
}
.dash-greeting { font-size: 1.6rem; font-weight: 700; }
.dash-sub { color: var(--text-2); font-size: .95rem; margin-top: .2rem; }
.stats-row { display: grid; grid-template-columns: repeat(4,1fr); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 1rem 1.25rem; text-align: center;
}
.stat-val { font-size: 1.8rem; font-weight: 700; color: var(--purple); }
.stat-lbl { font-size: .8rem; color: var(--text-2); margin-top: .15rem; }
.progress-section { margin-bottom: 2rem; }
.progress-bar-track {
  height: 8px; background: var(--border); border-radius: 4px; overflow: hidden;
}
.progress-bar-fill {
  height: 100%; background: linear-gradient(90deg, var(--purple) 0%, var(--teal) 100%);
  border-radius: 4px; transition: width .5s ease;
}
.progress-labels {
  display: flex; justify-content: space-between;
  font-size: .75rem; color: var(--text-3); margin-top: .3rem;
}
.module-section { margin-bottom: 2rem; }
.module-header { display: flex; align-items: center; gap: .75rem; margin-bottom: .75rem; }
.module-title { font-size: 1rem; font-weight: 600; }
.module-count { font-size: .8rem; color: var(--text-3); }
.program-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(140px,1fr)); gap: .5rem; }
.prog-tile {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .6rem .75rem;
  display: flex; flex-direction: column; gap: .2rem;
  text-decoration: none; color: var(--text);
  transition: border-color .15s, background .15s, transform .1s;
  position: relative;
}
.prog-tile:hover { border-color: var(--purple); background: var(--purple-lt); transform: translateY(-1px); text-decoration: none; }
.prog-tile.prog-done { background: var(--teal-lt); border-color: var(--teal); }
.prog-tile.prog-done:hover { background: #c0ede0; }
.prog-num { font-size: .7rem; color: var(--text-3); }
.prog-name { font-size: .8rem; font-weight: 500; line-height: 1.3; }
.prog-check { position: absolute; top:.5rem; right:.5rem; color: var(--teal); font-size:.8rem; }

/* ─── Program page ──────────────────────────────────────── */
.program-page { max-width: 860px; }
.breadcrumb { display: flex; gap: .5rem; align-items: center; color: var(--text-3); font-size: .85rem; margin-bottom: 1.5rem; }
.breadcrumb a { color: var(--text-3); }
.breadcrumb a:hover { color: var(--purple); }
.prog-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.prog-header-left { display: flex; align-items: flex-start; gap: 1rem; }
.prog-num-big { font-size: 2rem; font-weight: 800; color: var(--purple); line-height: 1; padding-top: .1rem; }
.prog-title { font-size: 1.5rem; font-weight: 700; margin-bottom: .3rem; }
.prog-meta-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1.5rem; }
.meta-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1rem 1.25rem; }
.meta-label { font-size: .75rem; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .5px; margin-bottom: .5rem; }
.meta-val { font-size: .9rem; color: var(--text); }
.learns-list { padding-left: 1.1rem; font-size: .9rem; display: flex; flex-direction: column; gap: .2rem; }
.code-section { background: #282C34; border-radius: var(--radius-lg); overflow: hidden; margin-bottom: 1rem; }
.code-header { display: flex; align-items: center; justify-content: space-between; padding: .65rem 1rem; background: #21252B; border-bottom: 1px solid #3a3f4b; }
.code-label { font-size: .78rem; color: #9da5b4; font-family: var(--mono); }
.btn-copy { background: transparent; border: 1px solid #4b5263; color: #9da5b4; padding: .2rem .65rem; border-radius: 4px; font-size: .75rem; cursor: pointer; }
.btn-copy:hover { background: #3a3f4b; color: #abb2bf; }
.code-section pre { margin: 0; padding: .25rem 0; }
.code-section pre code { font-family: var(--mono); font-size: .88rem; background: transparent !important; }
.output-section { margin-bottom: 1.5rem; }
.output-header { font-size: .75rem; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .5px; margin-bottom: .4rem; }
.output-box {
  background: #0C2D1A; color: #5DCAA5;
  border-radius: var(--radius); padding: 1rem 1.25rem;
  font-family: var(--mono); font-size: .85rem; line-height: 1.7;
  white-space: pre-wrap; overflow-x: auto;
}
.exercise-teaser {
  background: var(--purple-lt); border: 1px solid #AFA9EC;
  border-radius: var(--radius-lg); padding: 1.25rem;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  margin-bottom: 1.5rem; flex-wrap: wrap;
}
.teaser-badge { margin-bottom: .4rem; }
.teaser-title { font-size: .95rem; font-weight: 600; margin-bottom: .25rem; }
.teaser-q { font-size: .85rem; color: var(--text-2); }
.prog-nav { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-top: 1.5rem; }

/* ─── Exercises page ────────────────────────────────────── */
.exercises-page {}
.page-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 1rem; flex-wrap: wrap; gap: .75rem; }
.page-title { font-size: 1.6rem; font-weight: 700; }
.page-sub { color: var(--text-2); font-size: .95rem; }
.filter-row { display: flex; gap: .75rem; align-items: center; margin-bottom: 1.25rem; flex-wrap: wrap; }
.filter-select {
  padding: .45rem .75rem; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--surface);
  color: var(--text); font-size: .9rem; cursor: pointer;
}
.ex-list { display: flex; flex-direction: column; gap: .5rem; }
.ex-row {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: .85rem 1.1rem;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  transition: border-color .15s;
}
.ex-row:hover { border-color: var(--purple); }
.ex-row.ex-solved { background: var(--teal-lt); border-color: var(--teal); }
.ex-row-left { display: flex; align-items: center; gap: .6rem; flex: 1; min-width: 0; }
.ex-num { font-size: .8rem; color: var(--text-3); white-space: nowrap; }
.ex-title { font-size: .88rem; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ex-row-right { display: flex; align-items: center; gap: .6rem; white-space: nowrap; }
.solved-check { font-size: .8rem; color: var(--teal-dk); font-weight: 500; }

/* ─── Exercise page ─────────────────────────────────────── */
.exercise-page { max-width: 860px; }
.section-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1.25rem; margin-bottom: 1rem; }
.section-card-title { font-size: .78rem; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .5px; margin-bottom: .75rem; display: flex; align-items: center; justify-content: space-between; }
.challenge-text { font-size: .95rem; line-height: 1.7; color: var(--text); }
.hint-content { background: var(--purple-lt); border-left: 3px solid var(--purple); padding: .75rem 1rem; border-radius: 0 var(--radius) var(--radius) 0; font-size: .9rem; color: var(--text); }

/* ─── Responsive ─────────────────────────────────────────── */
@media (max-width: 700px) {
  .hero-title { font-size: 2rem; }
  .landing-stats, .stats-row { grid-template-columns: repeat(2,1fr); }
  .prog-meta-row { grid-template-columns: 1fr; }
  .prog-header { flex-direction: column; }
  .dash-header { flex-direction: column; }
  .nav-inner { gap: .75rem; }
  .nav-links { display: none; }
}

/* ─── Role pills ─────────────────────────────────────────── */
.role-pill {
  font-size:.7rem; font-weight:600; padding:.15rem .55rem;
  border-radius:20px; text-transform:uppercase; letter-spacing:.5px;
}
.role-admin   { background:#FDE8E8; color:#7B1C1C; border:1px solid #F5A5A5; }
.role-teacher { background:#E6F1FB; color:#0C447C; border:1px solid #85B7EB; }
.role-student { background:var(--purple-lt); color:var(--purple-dk); border:1px solid #AFA9EC; }

/* ─── Admin / Teacher pages ──────────────────────────────── */
.admin-page { max-width:1100px; }
.admin-grid { display:grid; grid-template-columns:1fr; gap:1.5rem; }
.form-page  { max-width:480px; }
.form-actions { display:flex; gap:.75rem; margin-top:.5rem; }
.section-block { background:var(--surface); border:1px solid var(--border); border-radius:var(--radius-lg); padding:1.5rem; margin-bottom:1.5rem; }
.alert-block   { border-color:#EF9F27; background:var(--amber-lt); }
.section-heading { font-size:1rem; font-weight:600; margin-bottom:.75rem; }
.section-sub    { font-size:.85rem; color:var(--text-2); }
.quick-actions  { display:flex; gap:.6rem; flex-wrap:wrap; }
.empty-note     { font-size:.9rem; color:var(--text-2); }
.text-muted     { color:var(--text-3); font-size:.8rem; }

/* ─── Tables ─────────────────────────────────────────────── */
.table-wrap { overflow-x:auto; }
.data-table { width:100%; border-collapse:collapse; font-size:.88rem; }
.data-table th { text-align:left; padding:.5rem .75rem; font-size:.75rem; font-weight:600; color:var(--text-3); text-transform:uppercase; letter-spacing:.4px; border-bottom:1px solid var(--border); }
.data-table td { padding:.6rem .75rem; border-bottom:1px solid var(--border); vertical-align:middle; }
.data-table tr:last-child td { border-bottom:none; }
.data-table tr:hover td { background:var(--bg); }
.row-inactive td { opacity:.55; }
.td-rank { font-size:1rem; text-align:center; width:48px; }

/* ─── Status pills ───────────────────────────────────────── */
.status-pill { font-size:.72rem; font-weight:600; padding:.15rem .55rem; border-radius:20px; }
.status-active   { background:var(--green-lt); color:var(--green-dk); border:1px solid #97C459; }
.status-inactive { background:var(--coral-lt); color:#712B13; border:1px solid #F09975; }

/* ─── Mini progress bar ──────────────────────────────────── */
.mini-bar-track { height:6px; background:var(--border); border-radius:3px; overflow:hidden; display:inline-block; width:80px; vertical-align:middle; margin-right:.4rem; }
.mini-bar-track.wide { width:160px; }
.mini-bar-fill  { height:100%; background:linear-gradient(90deg,var(--purple),var(--teal)); border-radius:3px; }
.mini-pct       { font-size:.78rem; color:var(--text-2); }
.pill-num       { font-size:.82rem; font-weight:600; color:var(--purple); }

/* ─── Stat mini row ──────────────────────────────────────── */
.stat-mini-row  { display:flex; gap:.75rem; }
.stat-mini      { background:var(--purple-lt); border:1px solid #AFA9EC; border-radius:var(--radius-lg); padding:.65rem 1rem; text-align:center; min-width:70px; }
.stat-mini-val  { font-size:1.4rem; font-weight:700; color:var(--purple); }
.stat-mini-lbl  { font-size:.72rem; color:var(--text-2); }

/* ─── Teacher cards ──────────────────────────────────────── */
.card-grid      { display:grid; grid-template-columns:repeat(auto-fill,minmax(280px,1fr)); gap:1rem; margin-bottom:1.5rem; }
.info-card      { background:var(--surface); border:1px solid var(--border); border-radius:var(--radius-lg); padding:1.25rem; }
.info-card-header { display:flex; align-items:center; justify-content:space-between; gap:.5rem; margin-bottom:.4rem; }
.info-card-title  { font-size:1rem; font-weight:600; }
.info-card-sub    { font-size:.85rem; color:var(--text-2); margin-bottom:.3rem; }
.info-card-meta   { font-size:.78rem; color:var(--text-3); margin-bottom:.75rem; }
.info-card-actions { display:flex; gap:.5rem; }
.badge-teal     { background:var(--teal-lt); color:var(--teal-dk); border:1px solid var(--teal); }

/* ─── Empty state ────────────────────────────────────────── */
.empty-state    { text-align:center; padding:3rem 1rem; color:var(--text-2); }
.empty-icon     { font-size:2.5rem; margin-bottom:.5rem; }
.empty-title    { font-size:1rem; font-weight:500; margin-bottom:.25rem; }
.empty-sub      { font-size:.85rem; }

/* ─── Module breakdown ───────────────────────────────────── */
.mod-breakdown  { display:flex; flex-direction:column; gap:.5rem; }
.mod-row        { display:grid; grid-template-columns:220px 1fr 60px; align-items:center; gap:.75rem; font-size:.85rem; }
.mod-row-name   { color:var(--text-2); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.mod-row-count  { color:var(--text-3); text-align:right; }

/* ─── Leaderboard ────────────────────────────────────────── */
.dash-body      { display:grid; grid-template-columns:1fr 260px; gap:1.5rem; align-items:start; }
.dash-programs  { min-width:0; }
.dash-sidebar   { position:sticky; top:72px; }
.leaderboard-card { background:var(--surface); border:1px solid var(--border); border-radius:var(--radius-lg); padding:1.25rem; }
.lb-header      { font-size:.95rem; font-weight:600; margin-bottom:.2rem; }
.lb-class       { font-size:.78rem; color:var(--text-3); margin-bottom:.85rem; }
.lb-list        { display:flex; flex-direction:column; gap:.4rem; }
.lb-row         { display:flex; align-items:center; gap:.6rem; padding:.35rem .5rem; border-radius:var(--radius); font-size:.85rem; }
.lb-row.lb-me   { background:var(--purple-lt); font-weight:600; }
.lb-rank        { width:24px; text-align:center; font-size:.95rem; }
.lb-name        { flex:1; color:var(--text); }
.lb-score       { font-size:.78rem; color:var(--text-3); white-space:nowrap; }

/* ─── Heatmap ────────────────────────────────────────────── */
.heatmap-scroll { overflow-x:auto; margin-top:.75rem; }
.heatmap-table  { border-collapse:collapse; font-size:.75rem; }
.hm-student-col { min-width:120px; white-space:nowrap; }
.hm-student-name { padding:.3rem .6rem; white-space:nowrap; font-size:.8rem; }
.hm-student-name a { color:var(--text); }
.hm-mod-header  { text-align:center; padding:.25rem .2rem; color:var(--text-3); font-weight:500; border-left:2px solid var(--border); white-space:nowrap; font-size:.7rem; }
.hm-prog-num    { padding:.15rem .1rem; color:var(--text-3); font-size:.65rem; text-align:center; width:14px; }
.hm-cell        { width:12px; height:12px; }
.hm-done        { background:#1D9E75; }
.hm-todo        { background:#E8E6F0; }
.hm-total       { padding:.3rem .6rem; font-weight:600; color:var(--purple); font-size:.8rem; text-align:center; }
.hm-legend      { display:inline-block; width:12px; height:12px; border-radius:2px; vertical-align:middle; margin-right:3px; }
.done-cell      { background:#1D9E75; }
.todo-cell      { background:#E8E6F0; }

/* ─── prog-tile-sm (teacher student view) ────────────────── */
.prog-tile-sm   { background:var(--surface); border:1px solid var(--border); border-radius:var(--radius); padding:.45rem .6rem; display:flex; flex-direction:column; gap:.15rem; position:relative; }
.prog-tile-sm.prog-done { background:var(--teal-lt); border-color:var(--teal); }

/* ─── Responsive ──────────────────────────────────────────── */
@media (max-width:900px) {
  .dash-body    { grid-template-columns:1fr; }
  .dash-sidebar { position:static; }
  .mod-row      { grid-template-columns:140px 1fr 50px; }
}
@media (max-width:600px) {
  .stat-mini-row { flex-wrap:wrap; }
  .form-actions  { flex-direction:column; }
}

/* ─── Streak tracker ─────────────────────────────────────── */
.streak-banner {
  display: flex; align-items: center; gap: 1.25rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 1.25rem 1.5rem;
  margin-bottom: 1rem; flex-wrap: wrap;
}
.streak-banner.streak-active {
  background: linear-gradient(135deg, #FFF8EC 0%, #FFF3DC 100%);
  border-color: var(--amber);
}
.streak-flame { flex-shrink: 0; }
.flame-emoji {
  font-size: 2.5rem; display: block; line-height: 1;
  filter: grayscale(1); opacity: .35;
  transition: filter .4s, opacity .4s;
}
.flame-on {
  filter: grayscale(0); opacity: 1;
  animation: flamePulse 2s ease-in-out infinite;
}
@keyframes flamePulse {
  0%,100% { transform: scale(1);   }
  50%      { transform: scale(1.12); }
}
.streak-info { flex: 1; min-width: 140px; }
.streak-number {
  font-size: 2rem; font-weight: 800; color: var(--amber-dk); line-height: 1;
}
.streak-label { font-size: .85rem; font-weight: 400; color: var(--text-2); }
.streak-msg   { font-size: .85rem; color: var(--text-2); margin-top: .3rem; }
.streak-stats { display: flex; gap: 1rem; flex-wrap: wrap; }
.streak-stat  { text-align: center; }
.streak-stat-val { font-size: 1.3rem; font-weight: 700; color: var(--purple); }
.streak-stat-lbl { font-size: .72rem; color: var(--text-3); }

/* ─── Nav streak badge ───────────────────────────────────── */
.nav-streak {
  font-size: .85rem; font-weight: 600;
  background: var(--amber-lt); color: var(--amber-dk);
  border: 1px solid var(--amber); border-radius: 20px;
  padding: .15rem .6rem;
}

/* ─── Streak badge on program page ──────────────────────── */
.prog-streak-badge {
  background: var(--amber-lt); border: 1px solid var(--amber);
  color: var(--amber-dk); border-radius: var(--radius);
  padding: .5rem 1rem; font-size: .88rem; font-weight: 500;
  margin-bottom: 1.25rem; display: inline-block;
}

/* ─── 30-day activity calendar ───────────────────────────── */
.activity-cal-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 1rem 1.25rem;
  margin-bottom: 1rem;
}
.cal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: .75rem; flex-wrap: wrap; gap: .5rem;
}
.cal-title { font-size: .85rem; font-weight: 600; color: var(--text-2); }
.cal-legend {
  display: flex; align-items: center; gap: .5rem;
  font-size: .75rem; color: var(--text-3);
}
.cal-dot {
  display: inline-block; width: 12px; height: 12px;
  border-radius: 2px; margin-right: 2px;
}
.cal-0 { background: #EDEAF6; }
.cal-1 { background: #B8AFF0; }
.cal-3 { background: #7F77DD; }
.cal-5 { background: #3C3489; }

.cal-grid {
  display: grid;
  grid-template-columns: repeat(30, 1fr);
  gap: 3px;
}
.cal-cell {
  aspect-ratio: 1; border-radius: 3px;
  cursor: default; position: relative;
  display: flex; align-items: flex-end; justify-content: center;
  padding-bottom: 1px;
}
.cal-cell:hover::after {
  content: attr(title);
  position: absolute; bottom: 120%; left: 50%; transform: translateX(-50%);
  background: #1A1833; color: #fff; font-size: .7rem;
  white-space: nowrap; padding: .25rem .5rem; border-radius: 4px;
  pointer-events: none; z-index: 10;
}
.cal-lvl-0 { background: #EDEAF6; }
.cal-lvl-1 { background: #C8C2F4; }
.cal-lvl-2 { background: #9F96E8; }
.cal-lvl-3 { background: #7F77DD; }
.cal-lvl-4 { background: #3C3489; }

.cal-day-num {
  font-size: .55rem; color: rgba(0,0,0,.3);
  line-height: 1; user-select: none;
}
.cal-months {
  display: flex; justify-content: space-between;
  margin-top: .35rem; padding: 0 2px;
}
.cal-month-label { font-size: .7rem; color: var(--text-3); }

/* ─── Milestone card ─────────────────────────────────────── */
.milestone-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 1.1rem;
}
.milestone-title {
  font-size: .88rem; font-weight: 600; margin-bottom: .75rem;
}
.milestone-list { display: flex; flex-direction: column; gap: .35rem; }
.milestone-row {
  display: flex; align-items: center; gap: .5rem;
  padding: .3rem .4rem; border-radius: var(--radius);
  font-size: .82rem; color: var(--text-3);
  opacity: .5;
}
.milestone-reached {
  opacity: 1; background: var(--amber-lt); color: var(--amber-dk);
}
.milestone-emoji { font-size: 1rem; width: 22px; text-align: center; }
.milestone-label { flex: 1; }
.milestone-days  { font-size: .75rem; color: var(--text-3); }
.milestone-tick  { color: var(--teal); font-weight: 700; }

/* ─── Teacher streak pill ────────────────────────────────── */
.streak-pill {
  font-size: .8rem; padding: .2rem .6rem; border-radius: 20px;
  background: #EDEAF6; color: var(--text-3);
  border: 1px solid var(--border);
}
.streak-pill-on {
  background: var(--amber-lt); color: var(--amber-dk);
  border-color: var(--amber);
}

/* ─── Responsive ─────────────────────────────────────────── */
@media (max-width: 700px) {
  .streak-banner { flex-direction: column; align-items: flex-start; gap: .75rem; }
  .cal-grid { grid-template-columns: repeat(15, 1fr); }
}

/* ─── Enrol page ─────────────────────────────────────────── */
.enrol-current {
  background: var(--teal-lt); border: 1px solid var(--teal);
  border-radius: var(--radius-lg); padding: 1.25rem;
  text-align: center;
}
.enrol-current-label { font-size: .8rem; color: var(--teal-dk); margin-bottom: .3rem; }
.enrol-current-name  { font-size: 1.2rem; font-weight: 700; color: var(--teal-dk); }
.enrol-current-sub   { font-size: .85rem; color: var(--text-2); margin-top: .5rem; }
.form-hint { font-size: .78rem; color: var(--text-3); margin-top: .3rem; }
.enrol-help {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 1rem 1.25rem;
  margin-top: 1.25rem;
}
.enrol-help-title { font-size: .85rem; font-weight: 600; margin-bottom: .5rem; }
.enrol-help-list  { padding-left: 1.2rem; font-size: .82rem; color: var(--text-2); display: flex; flex-direction: column; gap: .25rem; }

/* ─── Dashboard enrol nudge ──────────────────────────────── */
.enrol-nudge {
  display: flex; align-items: center; gap: 1rem;
  background: var(--purple-lt); border: 1px solid #AFA9EC;
  border-radius: var(--radius-lg); padding: 1rem 1.25rem;
  margin-bottom: 1.25rem; flex-wrap: wrap;
}
.enrol-nudge-icon { font-size: 1.5rem; flex-shrink: 0; }
.enrol-nudge-text { flex: 1; font-size: .88rem; color: var(--text); min-width: 200px; }

/* ─── Code display ───────────────────────────────────────── */
.code-display {
  font-family: var(--mono); font-size: 1rem; font-weight: 700;
  letter-spacing: .2em; background: var(--purple-lt);
  color: var(--purple-dk); padding: .2rem .6rem;
  border-radius: var(--radius); border: 1px solid #AFA9EC;
}
.code-inactive {
  background: var(--bg); color: var(--text-3);
  border-color: var(--border); text-decoration: line-through;
}

/* ─── Info box ───────────────────────────────────────────── */
.info-box {
  background: var(--purple-lt); border: 1px solid #AFA9EC;
  border-radius: var(--radius-lg); padding: 1rem 1.25rem;
}
.info-box-title { font-size: .88rem; font-weight: 600; margin-bottom: .5rem; color: var(--purple-dk); }
.info-box-list  { padding-left: 1.2rem; font-size: .85rem; color: var(--text); display: flex; flex-direction: column; gap: .3rem; }

/* ─── Teacher enrol code panel ───────────────────────────── */
.enrol-code-panel {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 1.1rem 1.4rem;
  margin-bottom: .5rem; flex-wrap: wrap; gap: 1rem;
}
.ecp-left  { display: flex; flex-direction: column; gap: .3rem; }
.ecp-right { display: flex; align-items: center; gap: .4rem; }
.ecp-label { font-size: .75rem; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .5px; }
.ecp-code  {
  font-family: var(--mono); font-size: 2rem; font-weight: 800;
  letter-spacing: .25em; color: var(--purple);
}
.ecp-code-off { color: var(--text-3); text-decoration: line-through; }
.ecp-none  { font-size: .9rem; color: var(--text-3); font-style: italic; }
.ecp-status { margin-top: .1rem; }
.ecp-hint  { font-size: .8rem; color: var(--text-3); margin-bottom: 1.5rem; padding: 0 .25rem; }

/* ─── Python Runner & Sandbox ────────────────────────────── */
.sandbox-page   { max-width: 1100px; }
.sandbox-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap;
}
.sandbox-header-right { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.sandbox-title  { font-size: 1.6rem; font-weight: 700; }
.sandbox-sub    { color: var(--text-2); font-size: .95rem; margin-top: .2rem; }

.sandbox-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
  align-items: start;
}

/* ── Editor panel ── */
.sandbox-editor-panel {
  background: #282C34; border-radius: var(--radius-lg); overflow: hidden;
}
.editor-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: .55rem 1rem; background: #21252B;
  border-bottom: 1px solid #3a3f4b;
}
.editor-label   { font-size: .78rem; color: #9da5b4; font-family: var(--mono); }
.editor-actions { display: flex; gap: .4rem; align-items: center; }
.sandbox-editor {
  width: 100%;
  min-height: 300px;
  background: #282C34;
  color: #ABB2BF;
  border: none; outline: none;
  font-family: var(--mono);
  font-size: .88rem;
  line-height: 1.7;
  padding: 1rem;
  resize: none;
  tab-size: 4;
  white-space: pre;
  overflow-x: auto;
  display: block;
}
.sandbox-editor::placeholder { color: #4b5263; }
.editor-footer {
  display: flex; gap: 1rem; padding: .45rem 1rem;
  background: #21252B; border-top: 1px solid #3a3f4b;
  flex-wrap: wrap;
}
.editor-hint { font-size: .72rem; color: #4b5263; }
kbd {
  background: #3a3f4b; color: #9da5b4;
  padding: .1rem .35rem; border-radius: 3px;
  font-size: .72rem; font-family: var(--mono);
  border: 1px solid #5c6370;
}

/* ── Output panel ── */
.sandbox-output-panel {
  background: #0C1F14; border-radius: var(--radius-lg); overflow: hidden;
  display: flex; flex-direction: column;
}
.output-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: .55rem 1rem; background: #0a1a10;
  border-bottom: 1px solid #1a3a20;
}
.output-label { font-size: .78rem; color: #3d9960; font-family: var(--mono); }
.sandbox-output {
  background: #0C1F14; color: #5DCAA5;
  font-family: var(--mono); font-size: .85rem; line-height: 1.7;
  padding: 1rem; margin: 0; white-space: pre-wrap;
  overflow-x: auto; flex: 1; min-height: 300px;
}
.sandbox-output.run-error { color: #E06C75; }

/* ── Run button ── */
.btn-run {
  background: #1D9E75; color: #fff;
  border: none; border-radius: var(--radius);
  padding: .4rem 1rem; font-size: .88rem; font-weight: 600;
  cursor: pointer; transition: background .15s, transform .1s;
  display: inline-flex; align-items: center; gap: .35rem;
}
.btn-run:hover   { background: #17835f; transform: translateY(-1px); }
.btn-run:active  { transform: scale(.97); }
.btn-run:disabled { opacity: .6; cursor: not-allowed; transform: none; }
.btn-run.btn-sm  { padding: .25rem .7rem; font-size: .78rem; }

/* ── Pyodide status ── */
.pyodide-status {
  font-size: .78rem; color: var(--amber-dk);
  font-style: italic;
}

/* ── Inline runner on program page ── */
.runner-section {
  background: #1a1e26; border-radius: var(--radius-lg);
  overflow: hidden; margin-bottom: 1.5rem;
  border: 1px solid #2d3340;
}
.runner-header {
  display: flex; align-items: center; gap: .75rem;
  padding: .6rem 1rem; background: #13161d;
  border-bottom: 1px solid #2d3340; flex-wrap: wrap;
}
.runner-title   { font-size: .82rem; font-weight: 600; color: #7ec89a; font-family: var(--mono); flex: 1; }
.runner-header-actions { display: flex; gap: .4rem; }
.runner-editor  { min-height: 120px; background: #1a1e26; color: #ABB2BF; }
.runner-output-wrap {
  border-top: 1px solid #2d3340;
}
.runner-output-label {
  display: flex; align-items: center; justify-content: space-between;
  padding: .4rem 1rem; background: #13161d;
  font-size: .75rem; color: #3d9960; font-family: var(--mono);
  border-bottom: 1px solid #2d3340;
}
.runner-output  { min-height: 80px; max-height: 300px; overflow-y: auto; margin: 0; }

/* ── Snippet bar ── */
.snippet-section { margin-top: .5rem; }
.snippet-title   { font-size: .8rem; font-weight: 600; color: var(--text-3); margin-bottom: .6rem; }
.snippet-grid    { display: flex; flex-wrap: wrap; gap: .4rem; }
.snippet-btn {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .3rem .75rem;
  font-size: .8rem; color: var(--text-2); cursor: pointer;
  transition: border-color .15s, background .15s;
}
.snippet-btn:hover  { border-color: var(--purple); color: var(--purple); background: var(--purple-lt); }
.snippet-btn.snippet-active { background: var(--purple); color: #fff; border-color: var(--purple); }

/* ─── Responsive ─────────────────────────────────────────── */
@media (max-width: 800px) {
  .sandbox-layout { grid-template-columns: 1fr; }
  .sandbox-output { min-height: 200px; }
}

/* ─── Quiz module badges on dashboard ───────────────────── */
.quiz-mod-badge {
  font-size: .72rem; font-weight: 500; padding: .15rem .6rem;
  border-radius: 20px; text-decoration: none; white-space: nowrap;
  transition: opacity .15s;
}
.quiz-mod-badge:hover { opacity: .8; text-decoration: none; }
.qbadge-pass  { background: var(--amber-lt); color: var(--amber-dk); border: 1px solid var(--amber); }
.qbadge-tried { background: var(--coral-lt); color: #712B13;          border: 1px solid #F09975; }
.qbadge-new   { background: var(--purple-lt); color: var(--purple-dk); border: 1px solid #AFA9EC; }

/* ─── Quiz page ──────────────────────────────────────────── */
.quiz-page { max-width: 760px; }
.quiz-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap;
}
.quiz-title  { font-size: 1.5rem; font-weight: 700; }
.quiz-sub    { font-size: .88rem; color: var(--text-2); margin-top: .2rem; }
.best-score-badge {
  font-size: .82rem; font-weight: 600; padding: .4rem .9rem;
  border-radius: var(--radius-lg); white-space: nowrap;
}
.best-passed { background: var(--amber-lt); color: var(--amber-dk); border: 1px solid var(--amber); }
.best-failed { background: var(--bg); color: var(--text-3); border: 1px solid var(--border); }

/* Quiz progress bar */
.quiz-progress-row {
  display: flex; align-items: center; gap: .75rem; margin-bottom: 1.5rem;
}
.quiz-progress-label { font-size: .82rem; color: var(--text-2); white-space: nowrap; }
.quiz-prog-track {
  flex: 1; height: 6px; background: var(--border); border-radius: 3px; overflow: hidden;
}
.quiz-prog-fill {
  height: 100%; background: linear-gradient(90deg, var(--purple), var(--teal));
  border-radius: 3px; transition: width .3s ease;
}

/* Quiz container */
.quiz-container {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 1.75rem;
}
.q-num  { font-size: .75rem; color: var(--text-3); font-weight: 500; text-transform: uppercase; letter-spacing: .5px; margin-bottom: .6rem; }
.q-text { font-size: 1.05rem; font-weight: 500; color: var(--text); line-height: 1.55; margin-bottom: 1.25rem; }

/* Options */
.q-options { display: flex; flex-direction: column; gap: .5rem; }
.q-opt {
  display: flex; align-items: center; gap: .75rem;
  background: var(--bg); border: 1.5px solid var(--border);
  border-radius: var(--radius-lg); padding: .7rem 1rem;
  cursor: pointer; text-align: left; width: 100%;
  font-size: .92rem; color: var(--text);
  transition: border-color .15s, background .15s, transform .1s;
}
.q-opt:hover:not(:disabled) {
  border-color: var(--purple); background: var(--purple-lt);
  transform: translateX(3px);
}
.q-opt:disabled { cursor: default; }
.q-opt.opt-correct { background: var(--green-lt); border-color: #639922; color: var(--green-dk); }
.q-opt.opt-wrong   { background: var(--red-lt);   border-color: #E24B4A; color: var(--red-dk); }
.opt-letter {
  min-width: 26px; height: 26px; border-radius: 50%;
  background: var(--border); color: var(--text-2);
  display: flex; align-items: center; justify-content: center;
  font-size: .78rem; font-weight: 700; flex-shrink: 0;
}
.q-opt.opt-correct .opt-letter { background: #639922; color: #fff; }
.q-opt.opt-wrong   .opt-letter { background: #E24B4A; color: #fff; }

/* Feedback */
.q-feedback {
  display: flex; align-items: flex-start; gap: .6rem;
  border-radius: var(--radius); padding: .75rem 1rem;
  margin-top: .85rem; font-size: .88rem; line-height: 1.55;
}
.fb-correct { background: var(--green-lt); border-left: 3px solid #639922; color: var(--green-dk); }
.fb-wrong   { background: var(--red-lt);   border-left: 3px solid #E24B4A; color: var(--red-dk); }
.fb-icon    { font-size: 1.1rem; flex-shrink: 0; margin-top: .05rem; }
.fb-verdict { font-weight: 700; margin-right: .4rem; white-space: nowrap; }
.fb-explain { color: var(--text); }

/* ─── Quiz result page ───────────────────────────────────── */
.result-hero {
  border-radius: var(--radius-lg); padding: 2.5rem;
  text-align: center; color: #fff; margin-bottom: 1.5rem;
}
.result-pass { background: linear-gradient(135deg, #1D9E75 0%, #0e7a5a 100%); }
.result-fail { background: linear-gradient(135deg, #7F77DD 0%, #3C3489 100%); }
.result-icon  { font-size: 3rem; margin-bottom: .5rem; }
.result-score { font-size: 3.5rem; font-weight: 800; line-height: 1; }
.result-pct   { font-size: 1.2rem; opacity: .85; margin-bottom: .4rem; }
.result-verdict { font-size: 1.1rem; font-weight: 500; margin-bottom: .25rem; }
.result-module  { font-size: .85rem; opacity: .75; margin-bottom: 1.25rem; }
.result-actions { display: flex; gap: .75rem; justify-content: center; flex-wrap: wrap; }

/* Score breakdown */
.result-breakdown {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 1rem; margin-bottom: 1.5rem;
}
.rb-stat {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 1rem; text-align: center;
}
.rb-val  { font-size: 1.8rem; font-weight: 700; }
.rb-lbl  { font-size: .75rem; color: var(--text-2); margin-top: .2rem; }
.rb-correct .rb-val { color: var(--teal); }
.rb-wrong   .rb-val { color: var(--coral); }
.rb-pct     .rb-val { color: var(--purple); }
.rb-pass    .rb-val { color: var(--amber-dk); }

/* Answer review */
.review-section { display: flex; flex-direction: column; gap: .85rem; }
.review-title   { font-size: 1.1rem; font-weight: 600; margin-bottom: .75rem; }
.review-card    { border-radius: var(--radius-lg); overflow: hidden; border: 1px solid var(--border); }
.review-correct { border-color: #97C459; }
.review-wrong   { border-color: #F09975; }
.review-header  {
  display: flex; align-items: center; justify-content: space-between;
  padding: .5rem 1rem; font-size: .8rem; font-weight: 600;
}
.review-correct .review-header { background: var(--green-lt); color: var(--green-dk); }
.review-wrong   .review-header { background: var(--coral-lt); color: #712B13; }
.review-num     { font-size: .75rem; }
.review-verdict { font-size: .8rem; }
.review-q     { padding: .75rem 1rem; font-size: .92rem; font-weight: 500; border-bottom: 1px solid var(--border); }
.review-opts  { padding: .6rem 1rem; display: flex; flex-direction: column; gap: .35rem; }
.review-opt   {
  display: flex; align-items: center; gap: .6rem;
  font-size: .85rem; padding: .35rem .6rem; border-radius: var(--radius);
  color: var(--text-2);
}
.review-opt-correct { background: var(--green-lt); color: var(--green-dk); font-weight: 500; }
.review-opt-chosen  { background: var(--red-lt);   color: var(--red-dk); }
.opt-tag       { margin-left: auto; font-size: .72rem; font-weight: 600; white-space: nowrap; }
.opt-tag-wrong { color: var(--red-dk); }
.review-explain {
  padding: .6rem 1rem .75rem;
  font-size: .83rem; color: var(--text-2); line-height: 1.55;
  border-top: 1px solid var(--border); background: var(--bg);
}

/* ─── Responsive ─────────────────────────────────────────── */
@media (max-width: 600px) {
  .result-breakdown { grid-template-columns: repeat(2, 1fr); }
  .quiz-container   { padding: 1.1rem; }
  .q-text           { font-size: .95rem; }
}

/* ═══════════════════════════════════════════════════════════
   v7 — DARK MODE + NOTES + SEARCH + BOOKMARKS
   ═══════════════════════════════════════════════════════════ */

/* ─── Dark mode CSS variables ────────────────────────────── */
:root {
  --bg:       #F8F7FC;
  --surface:  #FFFFFF;
  --border:   #E2E0F0;
  --text:     #1A1833;
  --text-2:   #5B5780;
  --text-3:   #9C9AB8;
}
[data-theme="dark"] {
  --bg:       #12111A;
  --surface:  #1C1B28;
  --border:   #2E2C45;
  --text:     #E8E6F8;
  --text-2:   #9C9AB8;
  --text-3:   #5B5780;
  --purple-lt:#1E1A3A;
  --purple-dk:#B0ABEE;
  --teal-lt:  #0D2420;
  --teal-dk:  #5DCAA5;
  --amber-lt: #241A08;
  --amber-dk: #EFC87A;
  --green-lt: #0F1E0A;
  --green-dk: #8DCF60;
  --red-lt:   #200C0C;
  --red-dk:   #F08080;
  --coral-lt: #201008;
  color-scheme: dark;
}
[data-theme="dark"] body {
  background: var(--bg);
  color: var(--text);
}
[data-theme="dark"] .navbar {
  background: var(--surface);
  border-color: var(--border);
}
[data-theme="dark"] .code-section { background: #1C2026; }
[data-theme="dark"] .code-header  { background: #161A1F; border-color: #2A2F38; }
[data-theme="dark"] .output-box   { background: #0A1A10; }
[data-theme="dark"] .sandbox-editor-panel { background: #1C2026; }
[data-theme="dark"] .editor-toolbar       { background: #161A1F; border-color: #2A2F38; }
[data-theme="dark"] .sandbox-editor       { background: #1C2026; }
[data-theme="dark"] .sandbox-output-panel { background: #0A1A10; }
[data-theme="dark"] .sandbox-output       { background: #0A1A10; }
[data-theme="dark"] .runner-section  { background: #1A1E26; border-color: #2D3340; }
[data-theme="dark"] .runner-header   { background: #13161D; border-color: #2D3340; }
[data-theme="dark"] .runner-editor   { background: #1A1E26; }
[data-theme="dark"] .runner-output-wrap { border-color: #2D3340; }
[data-theme="dark"] .runner-output-label { background: #13161D; border-color: #2D3340; }
[data-theme="dark"] .quiz-container  { background: var(--surface); border-color: var(--border); }
[data-theme="dark"] .q-opt           { background: #1C1B28; border-color: var(--border); color: var(--text); }
[data-theme="dark"] .q-opt:hover:not(:disabled) { background: var(--purple-lt); }
[data-theme="dark"] .opt-letter      { background: var(--border); color: var(--text-2); }
[data-theme="dark"] .data-table th   { border-color: var(--border); }
[data-theme="dark"] .data-table td   { border-color: var(--border); }
[data-theme="dark"] .data-table tr:hover td { background: var(--bg); }
[data-theme="dark"] .filter-select   { background: var(--surface); color: var(--text); border-color: var(--border); }
[data-theme="dark"] .form-input      { background: var(--bg); color: var(--text); border-color: var(--border); }
[data-theme="dark"] .prog-tile       { background: var(--surface); border-color: var(--border); color: var(--text); }
[data-theme="dark"] .prog-tile:hover { background: var(--purple-lt); border-color: var(--purple); }
[data-theme="dark"] .snippet-btn     { background: var(--surface); border-color: var(--border); color: var(--text-2); }
[data-theme="dark"] .milestone-card,
[data-theme="dark"] .leaderboard-card,
[data-theme="dark"] .activity-cal-card,
[data-theme="dark"] .streak-banner,
[data-theme="dark"] .section-block,
[data-theme="dark"] .info-card,
[data-theme="dark"] .meta-card,
[data-theme="dark"] .stat-card,
[data-theme="dark"] .section-card    { background: var(--surface); border-color: var(--border); }
[data-theme="dark"] .enrol-code-panel { background: var(--surface); border-color: var(--border); }
[data-theme="dark"] .enrol-nudge     { background: var(--purple-lt); border-color: var(--border); }
[data-theme="dark"] .cal-lvl-0       { background: #2A2840; }
[data-theme="dark"] .hm-todo         { background: #2A2840; }

/* ─── Dark mode toggle button ────────────────────────────── */
.theme-toggle {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .25rem .55rem;
  font-size: 1rem;
  cursor: pointer;
  line-height: 1;
  transition: background .15s;
}
.theme-toggle:hover { background: var(--bg); }

/* ─── Navbar search bar ──────────────────────────────────── */
.nav-search-form {
  display: flex; align-items: center;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  flex: 1; max-width: 320px; min-width: 0;
}
.nav-search-input {
  flex: 1; border: none; background: transparent;
  padding: .35rem .75rem; font-size: .88rem;
  color: var(--text); outline: none;
  min-width: 0;
}
.nav-search-input::placeholder { color: var(--text-3); }
.nav-search-btn {
  background: transparent; border: none;
  padding: .35rem .65rem; cursor: pointer;
  color: var(--text-3); font-size: .9rem;
  transition: color .15s;
}
.nav-search-btn:hover { color: var(--purple); }

/* ─── Search page ────────────────────────────────────────── */
.search-page       { max-width: 860px; }
.search-hero       { margin-bottom: 1.5rem; }
.search-hero-centered {
  min-height: 40vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center;
}
.search-title  { font-size: 1.5rem; font-weight: 700; margin-bottom: 1rem; }
.search-form   { display: flex; gap: .5rem; width: 100%; max-width: 560px; }
.search-input  {
  flex: 1; padding: .65rem 1rem;
  border: 1.5px solid var(--border); border-radius: var(--radius-lg);
  font-size: 1rem; background: var(--surface); color: var(--text);
  outline: none; transition: border-color .15s;
}
.search-input:focus { border-color: var(--purple); }
.search-suggestions {
  display: flex; align-items: center; gap: .5rem;
  flex-wrap: wrap; margin-top: 1rem;
}
.sug-label { font-size: .82rem; color: var(--text-3); }
.sug-chip  {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 20px; padding: .2rem .7rem; font-size: .8rem;
  color: var(--text-2); text-decoration: none;
  transition: border-color .15s, color .15s;
}
.sug-chip:hover { border-color: var(--purple); color: var(--purple); text-decoration: none; }
.search-meta {
  font-size: .9rem; color: var(--text-2);
  margin-bottom: 1rem; padding-bottom: .75rem;
  border-bottom: 1px solid var(--border);
}
.search-results { display: flex; flex-direction: column; gap: .6rem; }
.search-result-card {
  display: flex; align-items: flex-start; gap: 1rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 1rem 1.1rem;
  text-decoration: none; color: var(--text);
  transition: border-color .15s, transform .1s;
}
.search-result-card:hover {
  border-color: var(--purple); transform: translateX(3px);
  text-decoration: none;
}
.sr-left {
  display: flex; flex-direction: column; gap: .3rem;
  align-items: flex-start; min-width: 80px;
}
.sr-num  { font-size: .78rem; color: var(--text-3); font-weight: 600; }
.sr-body { flex: 1; min-width: 0; }
.sr-title { font-size: .98rem; font-weight: 600; color: var(--text); margin-bottom: .25rem; }
.sr-what  { font-size: .85rem; color: var(--text-2); margin-bottom: .4rem; }
.sr-learns { display: flex; flex-wrap: wrap; gap: .3rem; }
.sr-learn-tag {
  font-size: .72rem; background: var(--purple-lt);
  color: var(--purple-dk); border: 1px solid #AFA9EC;
  border-radius: 20px; padding: .1rem .5rem;
}
.sr-arrow { font-size: 1.1rem; color: var(--text-3); align-self: center; flex-shrink: 0; }

/* ─── Bookmark button ────────────────────────────────────── */
.btn-bookmarked {
  background: var(--amber-lt); color: var(--amber-dk);
  border-color: var(--amber);
}
.btn-bookmarked:hover { background: #f5e0b0; }

/* ─── Notes panel on program page ───────────────────────── */
.notes-panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); overflow: hidden;
  margin-bottom: 1.5rem;
}
.notes-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: .65rem 1rem; background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.notes-title     { font-size: .82rem; font-weight: 600; color: var(--text-2); }
.notes-saved-msg { font-size: .75rem; color: var(--teal); font-weight: 500; }
.notes-editor {
  width: 100%; min-height: 100px; max-height: 300px;
  background: var(--surface); color: var(--text);
  border: none; outline: none; resize: vertical;
  font-family: var(--font); font-size: .9rem;
  line-height: 1.65; padding: .85rem 1rem;
  display: block;
}
.notes-editor::placeholder { color: var(--text-3); }
.notes-footer {
  padding: .4rem 1rem; background: var(--bg);
  border-top: 1px solid var(--border);
  font-size: .75rem; color: var(--text-3);
}

/* ─── Bookmarks page ─────────────────────────────────────── */
.bookmarks-page  { max-width: 900px; }
.bm-tabs {
  display: flex; gap: .4rem; margin-bottom: 1.25rem;
  border-bottom: 2px solid var(--border); padding-bottom: 0;
}
.bm-tab {
  background: transparent; border: none; border-bottom: 2px solid transparent;
  margin-bottom: -2px; padding: .5rem 1rem; font-size: .9rem;
  font-weight: 500; color: var(--text-2); cursor: pointer;
  transition: color .15s, border-color .15s;
}
.bm-tab.active { color: var(--purple); border-bottom-color: var(--purple); }
.bm-tab:hover  { color: var(--purple); }
.bm-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(260px,1fr));
  gap: 1rem;
}
.bm-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 1rem 1.1rem;
  display: flex; flex-direction: column; gap: .4rem;
  transition: opacity .3s;
}
.bm-card-top {
  display: flex; align-items: center;
  justify-content: space-between; gap: .5rem;
}
.bm-remove-btn {
  background: transparent; border: none; cursor: pointer;
  color: var(--text-3); font-size: .85rem; padding: .1rem .4rem;
  border-radius: var(--radius); transition: color .15s, background .15s;
}
.bm-remove-btn:hover { color: var(--coral); background: var(--coral-lt); }
.bm-title {
  font-size: .95rem; font-weight: 600; color: var(--text);
  text-decoration: none; line-height: 1.35;
}
.bm-title:hover { color: var(--purple); text-decoration: none; }
.bm-what  { font-size: .82rem; color: var(--text-2); line-height: 1.5; flex: 1; }
.bm-footer {
  display: flex; align-items: center; justify-content: space-between;
  gap: .5rem; margin-top: .25rem;
}
.bm-note-preview {
  background: var(--bg); border-left: 3px solid var(--amber);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: .4rem .6rem; font-size: .78rem; color: var(--text-2);
  line-height: 1.4; margin-top: .25rem;
}
.bm-note-label { margin-right: .3rem; }

/* Notes list tab */
.notes-list { display: flex; flex-direction: column; gap: .85rem; }
.note-card  {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); overflow: hidden;
}
.note-card-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: .75rem; padding: .65rem 1rem; background: var(--bg);
  border-bottom: 1px solid var(--border); flex-wrap: wrap;
}
.note-prog-title {
  font-size: .9rem; font-weight: 600; color: var(--text); margin-left: .3rem;
}
.note-text {
  padding: .85rem 1rem; font-size: .9rem; color: var(--text);
  line-height: 1.65; white-space: pre-wrap;
}

/* ─── Dashboard bookmark count in stat row ───────────────── */
.stat-card.stat-bookmarks { border-top: 2px solid var(--amber); }

/* ─── Responsive extras ──────────────────────────────────── */
@media (max-width: 860px) {
  .nav-search-form { max-width: 180px; }
}
@media (max-width: 640px) {
  .nav-search-form { display: none; }
  .bm-grid { grid-template-columns: 1fr; }
  .search-form { flex-direction: column; }
  .stats-row { grid-template-columns: repeat(3, 1fr); }
}

/* ─── Bookmark dot on program tile ──────────────────────── */
.prog-bookmark-dot {
  position: absolute; top: .3rem; right: 1.3rem;
  font-size: .65rem; line-height: 1;
}

/* Fix stats-row to support 6 columns gracefully */
.stats-row { grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); }
