:root {
  --purple: #5b2a9d;
  --purple-2: #7c3aed;
  --ink: #15121f;
  --muted: #6b6480;
  --bg: #f4f2fa;
  --card: #ffffff;
  --line: #e9e4f4;
  --good: #16a34a;
  --bad: #dc2626;
  --radius: 18px;
  --shadow: 0 10px 34px rgba(40, 20, 80, .10);
  --shadow-lg: 0 24px 60px rgba(40, 20, 80, .18);
  --subject: var(--purple);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased; line-height: 1.55;
}
h1, h2, h3, .logo { font-family: "Sora", "Inter", sans-serif; letter-spacing: -0.02em; }
a { color: inherit; text-decoration: none; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 22px; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50; backdrop-filter: blur(10px);
  background: rgba(255, 255, 255, .82); border-bottom: 1px solid var(--line);
}
.topbar .row { display: flex; align-items: center; gap: 14px; height: 60px; }
.logo { font-weight: 800; font-size: 19px; }
.logo .sq { color: var(--subject); }
.crumbs { color: var(--muted); font-size: 14px; }
.crumbs a:hover { color: var(--ink); }
.spacer { margin-left: auto; }
.back-pill { font-size: 13px; font-weight: 600; padding: 7px 14px; border-radius: 999px; background: #f0ebfa; color: var(--subject); }
.back-pill:hover { background: #e6dcf7; }

/* ---------- hero ---------- */
.hero {
  position: relative; overflow: hidden; color: #fff; border-radius: 0 0 36px 36px;
  background: linear-gradient(125deg, #4c1d95 0%, #6d28d9 45%, #8b5cf6 100%);
}
.hero::after {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(700px 320px at 85% -10%, rgba(255,255,255,.25), transparent 60%),
              radial-gradient(600px 300px at 5% 120%, rgba(255,216,77,.20), transparent 60%);
  pointer-events: none;
}
.hero .wrap { position: relative; padding: 54px 22px 60px; }
.hero h1 { font-size: clamp(30px, 5vw, 52px); margin: 0 0 10px; font-weight: 800; }
.hero p { font-size: clamp(15px, 2vw, 19px); max-width: 640px; opacity: .92; margin: 0 0 26px; }
.stats { display: flex; gap: 28px; flex-wrap: wrap; }
.stat .n { font-family: "Sora"; font-size: clamp(24px, 4vw, 34px); font-weight: 800; }
.stat .l { font-size: 13px; opacity: .85; text-transform: uppercase; letter-spacing: .08em; }

/* ---------- subject hero (per-subject) ---------- */
.subhero { color: #fff; border-radius: 0 0 32px 32px;
  background: linear-gradient(125deg, var(--subject), color-mix(in srgb, var(--subject) 65%, #fff)); }
.subhero .wrap { padding: 40px 22px 46px; }
.subhero .icon { font-size: 44px; }
.subhero h1 { font-size: clamp(26px, 4vw, 42px); margin: 6px 0 8px; }
.subhero .meta-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; opacity: .95; font-size: 14px; }

/* ---------- search ---------- */
.searchbar { margin: 26px 0 6px; position: relative; }
.searchbar input {
  width: 100%; padding: 14px 18px 14px 46px; border-radius: 14px; border: 1.5px solid var(--line);
  font-size: 15px; background: var(--card); box-shadow: var(--shadow); font-family: inherit;
}
.searchbar input:focus { outline: none; border-color: var(--subject); }
.searchbar::before { content: "🔍"; position: absolute; left: 16px; top: 50%; transform: translateY(-50%); opacity: .5; }

/* ---------- section headers ---------- */
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted);
  font-weight: 700; margin: 34px 0 14px; display: flex; align-items: center; gap: 10px; }
.section-title::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* ---------- grid + cards ---------- */
.grid { display: grid; gap: 18px; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.card {
  position: relative; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow); transition: transform .14s ease, box-shadow .14s ease; overflow: hidden;
}
.card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.card .accent { position: absolute; left: 0; top: 0; height: 5px; width: 100%; background: var(--subject); }
.card .icon { font-size: 34px; line-height: 1; }
.card .name { font-weight: 700; font-size: 19px; margin-top: 10px; font-family: "Sora"; }
.card .sub { color: var(--muted); font-size: 13px; margin-top: 4px; }
.card .counts { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }

/* chips / badges */
.chip { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600;
  padding: 4px 10px; border-radius: 999px; background: #f1edf9; color: var(--subject); white-space: nowrap; }
.chip.muted { background: #f1f0f5; color: var(--muted); }
.chip.ready { background: #e8f8ee; color: #15803d; }
.chip.year { background: #fff4d6; color: #8a6d00; }
.chip.board { background: rgba(255,255,255,.18); color: #fff; }
.chip.soon { background: #f1f0f5; color: #8b8597; }

/* progress bar */
.bar { height: 7px; border-radius: 999px; background: var(--line); margin-top: 14px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--subject); border-radius: 999px; transition: width .5s ease; }

/* ---------- workbook (modules + questions) ---------- */
.module { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); margin-top: 18px; overflow: hidden; }
.module > .head { padding: 18px 22px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  border-bottom: 1px solid var(--line); }
.module > .head h3 { margin: 0; font-size: 18px; }
.module > .head .grow { flex: 1; }
.module .body { padding: 8px 22px 20px; }
.coming { padding: 26px 22px; color: var(--muted); font-size: 14px; text-align: center; }
.coming b { color: var(--ink); }

.q { padding: 16px 0; border-bottom: 1px dashed var(--line); }
.q:last-child { border-bottom: none; }
.q-meta { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.q-text { font-weight: 600; margin-bottom: 12px; white-space: pre-line; }
.opt { display: block; width: 100%; text-align: left; background: #fff; border: 1.5px solid var(--line);
  border-radius: 12px; padding: 11px 14px; margin-bottom: 8px; cursor: pointer; font-size: 15px; font-family: inherit;
  transition: border-color .12s, background .12s; }
.opt:hover:not(:disabled) { border-color: var(--subject); background: #faf8ff; }
.opt.correct { border-color: var(--good); background: #ecfdf3; }
.opt.wrong { border-color: var(--bad); background: #fef2f2; }
.opt:disabled { cursor: default; }
.explain { font-size: 14px; color: var(--muted); margin-top: 2px; display: none; padding-left: 2px; }
.explain.show { display: block; color: #36304a; }
.btn { background: var(--subject); color: #fff; border: none; border-radius: 999px; padding: 10px 18px;
  font-weight: 700; cursor: pointer; font-size: 14px; font-family: inherit; display: inline-block; }
.btn:hover { filter: brightness(1.08); }
.btn.ghost { background: rgba(255,255,255,.18); }
.btn.reveal { background: var(--ink); }
.model-answer { display: none; margin-top: 12px; padding: 14px 16px; border-radius: 12px;
  background: #ecfdf3; border: 1px solid #b7e4c7; color: #14532d; font-size: 15px; line-height: 1.55; }
.model-answer.show { display: block; }

.score { position: sticky; bottom: 16px; margin-top: 24px; background: var(--ink); color: #fff;
  border-radius: 16px; padding: 14px 20px; display: flex; align-items: center; gap: 14px; box-shadow: var(--shadow-lg); }
.score .big { font-size: 22px; font-weight: 800; font-family: "Sora"; }

/* ---------- chrome: stars + student ---------- */
.chrome { display: flex; align-items: center; gap: 8px; }
.star-chip { display: inline-flex; align-items: center; gap: 4px; font-weight: 700; font-size: 14px;
  background: #fff4d6; color: #8a6d00; padding: 6px 12px; border-radius: 999px; }
.star-chip:hover { filter: brightness(.97); }
.stu-chip { font-size: 13px; font-weight: 600; padding: 6px 12px; border-radius: 999px; background: #f0ebfa; color: var(--subject); }
.stu-chip:hover { background: #e6dcf7; }

/* ---------- year filter ---------- */
.yearfilter { display: flex; gap: 8px; flex-wrap: wrap; margin: 14px 0 4px; }
.ypill { border: 1.5px solid var(--line); background: var(--card); color: var(--muted); border-radius: 999px;
  padding: 7px 14px; font-size: 13px; font-weight: 600; cursor: pointer; font-family: inherit; }
.ypill:hover { border-color: var(--subject); color: var(--ink); }
.ypill.on { background: var(--subject); border-color: var(--subject); color: #fff; }

/* ---------- hub ---------- */
.hubcard { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 22px; margin: 24px 0 6px; display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.hubcard h2 { margin: 0 0 8px; font-size: 22px; }
.hubcard p { margin: 0; color: var(--muted); }
.hubmain { flex: 1; min-width: 220px; }
.hubstats { display: flex; gap: 18px; flex-wrap: wrap; }
.hstat { font-size: 15px; color: var(--ink); } .hstat b { font-family: "Sora"; font-size: 20px; }
.hstat.soft { color: var(--muted); font-size: 13px; align-self: center; }
.hubactions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.signin-row { display: flex; gap: 8px; }
.signin-row input { padding: 11px 14px; border-radius: 12px; border: 1.5px solid var(--line); font-size: 15px; font-family: inherit; min-width: 180px; }
.signin-row input:focus { outline: none; border-color: var(--subject); }
.btn.ghost2 { background: #f0ebfa; color: var(--subject); }
.linklike { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 13px; text-decoration: underline; font-family: inherit; }

/* ---------- hints ---------- */
.q-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.hint { background: #fff7e6; color: #8a6d00; border: 1px solid #f5e3b3; border-radius: 999px; padding: 8px 14px;
  font-size: 13px; font-weight: 600; cursor: pointer; font-family: inherit; }
.hint:hover { filter: brightness(.97); }
.opt.dim { opacity: .35; text-decoration: line-through; }
.hint-box { display: none; margin-top: 10px; padding: 10px 14px; border-radius: 12px; background: #fff7e6;
  border: 1px solid #f5e3b3; color: #6b5300; font-size: 14px; }
.hint-box.show { display: block; }

/* ---------- effects ---------- */
.starfloat { position: absolute; z-index: 80; font-weight: 800; color: #d4880a; pointer-events: none;
  animation: floatup 1.1s ease-out forwards; }
@keyframes floatup { 0% { opacity: 0; transform: translateY(6px) scale(.8); } 20% { opacity: 1; } 100% { opacity: 0; transform: translateY(-34px) scale(1.1); } }
.confetti { position: fixed; top: -12px; width: 9px; height: 14px; z-index: 90; border-radius: 2px;
  animation: fall 2.4s linear forwards; }
@keyframes fall { to { transform: translateY(105vh) rotate(720deg); opacity: .9; } }
.complete-banner { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); z-index: 95;
  background: var(--ink); color: #fff; padding: 14px 20px; border-radius: 999px; box-shadow: var(--shadow-lg);
  font-weight: 600; display: flex; align-items: center; gap: 12px; }
.complete-banner .x { background: rgba(255,255,255,.2); border: none; color: #fff; border-radius: 50%; width: 24px; height: 24px; cursor: pointer; }

/* ---------- leaderboard ---------- */
.lb { max-width: 640px; margin: 24px auto 0; }
.lbrow { display: flex; align-items: center; gap: 14px; background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; padding: 14px 18px; margin-bottom: 10px; box-shadow: var(--shadow); }
.lbrow.me { border-color: var(--purple-2); background: #faf7ff; }
.lbrow .rank { font-size: 20px; font-weight: 800; min-width: 34px; text-align: center; }
.lbname { flex: 1; font-weight: 600; }
.lbstars { font-weight: 800; color: #8a6d00; }
.lbnote { color: var(--muted); font-size: 13px; text-align: center; margin-top: 14px; }

.empty { text-align: center; color: var(--muted); padding: 60px 20px; }
.footer { text-align: center; color: var(--muted); font-size: 13px; padding: 44px 0 60px; }
.hidden { display: none !important; }
@media (max-width: 560px) { .hero .wrap { padding: 40px 18px; } .stats { gap: 18px; } }
