:root {
  --font-head: "Lexend", sans-serif;
  --bg: #f6f7fb;
  --card: #ffffff;
  --ink: #1e2433;
  --muted: #64748b;
  --line: #e5e9f2;
  --brand: #4f46e5;
  --brand2: #7c3aed;
  --ok: #16a34a;
  --bad: #dc2626;
  --radius: 16px;
  --shadow: 0 10px 30px rgba(30, 41, 59, .08);
  --subject: #4f46e5;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255,255,255,.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1080px; margin: 0 auto; padding: 12px 20px;
  display: flex; align-items: center; justify-content: space-between;
}
.brand { font-family: "Lexend", sans-serif; font-weight: 900; font-size: 1.25rem; text-decoration: none; color: var(--ink); display: flex; gap: 8px; align-items: center; }
.brand-logo { height: 52px; width: auto; display: block; }
.brand-accent { color: var(--brand); }
.nav { display: flex; gap: 8px; }
.nav a {
  text-decoration: none; color: var(--muted); font-weight: 600; font-size: .92rem;
  padding: 8px 14px; border-radius: 999px; transition: all .15s;
}
.nav a:hover { color: var(--ink); background: #eef0f8; }
.nav a.active { background: var(--brand); color: #fff; }

.nav-right { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.who { font-size: .85rem; font-weight: 700; color: var(--muted); }
.navbtn {
  border: 2px solid var(--line); background: #fff; color: var(--ink); cursor: pointer;
  padding: 7px 14px; border-radius: 999px; font-family: inherit; font-size: .85rem; font-weight: 700; transition: all .15s;
}
.navbtn:hover { border-color: var(--brand); color: var(--brand); }
.navbtn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.navbtn.primary:hover { filter: brightness(1.1); }
.nav-right a { text-decoration: none; font-weight: 700; font-size: .85rem; color: var(--muted); padding: 7px 12px; border-radius: 999px; }
.nav-right a:hover { color: var(--ink); background: #eef0f8; }

/* track bar (syllabus switcher) */
#trackbar { background: #eef0f8; border-bottom: 1px solid var(--line); }
.trackbar-inner { max-width: 1080px; margin: 0 auto; padding: 8px 20px; display: flex; gap: 8px; flex-wrap: wrap; }
.tpill {
  border: 2px solid transparent; background: transparent; cursor: pointer; text-align: left;
  padding: 7px 16px; border-radius: 12px; font-family: inherit; transition: all .15s;
  display: flex; flex-direction: column; gap: 1px; line-height: 1.2;
}
.tpill-main { font-weight: 800; font-size: .95rem; color: var(--muted); }
.tpill-sub { font-size: .72rem; color: var(--muted); opacity: .8; }
.tpill:hover { background: #fff; }
.tpill.active { background: var(--brand); border-color: var(--brand); }
.tpill.active .tpill-main, .tpill.active .tpill-sub { color: #fff; }

/* modal */
.overlay {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .55); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 20px; backdrop-filter: blur(4px);
}
.modal {
  background: #fff; border-radius: 20px; max-width: 420px; width: 100%; padding: 28px;
  box-shadow: 0 30px 80px rgba(0,0,0,.3); animation: pop .2s ease;
}
.modal h3 { font-family: "Lexend", sans-serif; font-size: 1.3rem; margin-bottom: 4px; }
.modal .sub { color: var(--muted); font-size: .88rem; margin-bottom: 16px; }
.form-field { margin-bottom: 12px; }
.form-field label { display: block; font-size: .8rem; font-weight: 700; color: var(--muted); margin-bottom: 4px; }
.form-field input, .form-field select, .form-field textarea {
  width: 100%; border: 2px solid var(--line); border-radius: 10px; padding: 10px 12px;
  font-family: inherit; font-size: .9rem; color: var(--ink); background: #fff;
}
.form-field textarea { resize: vertical; min-height: 60px; }
.form-field input:focus, .form-field select:focus, .form-field textarea:focus { outline: none; border-color: var(--brand); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-err { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; border-radius: 10px; padding: 9px 12px; font-size: .85rem; margin-bottom: 12px; }
.modal-actions { display: flex; gap: 10px; margin-top: 16px; }
.modal-switch { margin-top: 14px; font-size: .85rem; color: var(--muted); }
.modal-switch a { color: var(--brand); font-weight: 700; cursor: pointer; }
.hidden { display: none !important; }

/* manage */
.mg-toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.mg-select {
  border: 2px solid var(--line); background: #fff; border-radius: 12px; padding: 10px 14px;
  font-family: inherit; font-size: .92rem; font-weight: 700; color: var(--ink); cursor: pointer;
}
.mg-select:focus { outline: none; border-color: var(--brand); }
.mg-type-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.mg-type {
  border: 2px solid var(--line); background: #fff; color: var(--muted); cursor: pointer;
  padding: 8px 16px; border-radius: 999px; font-family: inherit; font-size: .85rem; font-weight: 700; transition: all .15s;
}
.mg-type:hover { border-color: var(--brand); color: var(--brand); }
.mg-type.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.mg-count { margin-left: auto; align-self: center; color: var(--muted); font-size: .85rem; font-weight: 700; }
.mg-item {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px;
  margin-bottom: 12px; box-shadow: var(--shadow);
}
.mg-item h5 { font-size: .92rem; margin-bottom: 10px; color: var(--ink); }
.mg-add {
  background: #f8faff; border: 2px dashed #c7d2fe; border-radius: 14px; padding: 16px; margin-bottom: 18px;
}
.mg-add h5 { color: var(--brand); margin-bottom: 10px; font-size: .92rem; }
.mg-actions { display: flex; gap: 10px; margin-top: 12px; }
.btn-sm { padding: 8px 16px; font-size: .85rem; border-radius: 10px; }
.btn-danger { background: #fee2e2; color: #b91c1c; }
.btn-danger:hover { background: #fecaca; }
.mg-help { font-size: .78rem; color: var(--muted); margin-top: 3px; }
.mg-flash {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 120;
  background: var(--ink); color: #fff; padding: 10px 20px; border-radius: 999px; font-size: .88rem; font-weight: 600;
  box-shadow: 0 10px 30px rgba(0,0,0,.25); animation: pop .2s ease;
}
.mg-flash.ok { background: #15803d; }
.mg-flash.bad { background: #b91c1c; }
.small { font-size: .8rem; color: var(--muted); }

main { flex: 1; width: 100%; max-width: 1080px; margin: 0 auto; padding: 28px 20px 60px; }

/* ---------- hero / home ---------- */
.hero {
  background: linear-gradient(135deg, #4f46e5, #7c3aed 55%, #a855f7);
  color: #fff; border-radius: 24px; padding: 44px 40px; margin-bottom: 28px;
  box-shadow: 0 20px 50px rgba(79,70,229,.35); position: relative; overflow: hidden;
}
.hero::after {
  content: "✏️"; position: absolute; right: -30px; bottom: -40px; font-size: 190px; opacity: .12; transform: rotate(-12deg);
}
.hero h1 { font-family: "Lexend", sans-serif; font-size: clamp(1.7rem, 4vw, 2.6rem); font-weight: 900; line-height: 1.15; margin-bottom: 10px; }
.hero p { font-size: 1.05rem; opacity: .92; max-width: 620px; }
.hero .chips { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 18px; }
.chip { background: rgba(255,255,255,.16); border: 1px solid rgba(255,255,255,.25); padding: 6px 14px; border-radius: 999px; font-size: .85rem; font-weight: 600; }

.section-title { font-family: "Lexend", sans-serif; font-size: 1.35rem; font-weight: 800; margin: 30px 0 14px; display: flex; align-items: center; gap: 8px; }

/* ---------- subject cards ---------- */
.grid-subjects { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.subject-card {
  background: var(--card); border-radius: var(--radius); padding: 22px; cursor: pointer;
  box-shadow: var(--shadow); border: 1px solid var(--line); border-top: 5px solid var(--subject);
  transition: transform .15s, box-shadow .15s; text-decoration: none; color: inherit; display: block;
}
.subject-card:hover { transform: translateY(-4px); box-shadow: 0 18px 40px rgba(30,41,59,.14); }
.subject-card .emoji { font-size: 2rem; }
.subject-card h3 { font-family: "Lexend", sans-serif; font-size: 1.15rem; margin: 8px 0 2px; }
.subject-card .code { color: var(--muted); font-size: .82rem; font-weight: 600; }
.subject-card .meta { display: flex; gap: 14px; margin-top: 12px; font-size: .8rem; color: var(--muted); font-weight: 600; }
.subject-card .meta span b { color: var(--ink); }

/* ---------- generic cards ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 22px; }

/* ---------- subject page ---------- */
.subject-head {
  border-radius: 24px; padding: 30px; color: #fff; margin-bottom: 22px;
  background: linear-gradient(135deg, var(--subject), color-mix(in srgb, var(--subject) 60%, #7c3aed));
  box-shadow: 0 16px 40px color-mix(in srgb, var(--subject) 35%, transparent);
}
.subject-head h1 { font-family: "Lexend", sans-serif; font-size: 1.9rem; font-weight: 900; }
.subject-head .sub { opacity: .9; margin-top: 4px; font-size: .95rem; }
.subject-head .spec-box { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 16px; }
.subject-head .spec-box .pchip { background: rgba(255,255,255,.15); border: 1px solid rgba(255,255,255,.3); padding: 8px 12px; border-radius: 12px; font-size: .82rem; }

.tabs { display: flex; gap: 6px; background: #eef0f8; padding: 6px; border-radius: 14px; margin-bottom: 20px; flex-wrap: wrap; }

/* year toggle */
.year-row { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.year-label { font-weight: 700; font-size: .88rem; color: var(--muted); }
.ypill {
  border: 2px solid var(--line); background: #fff; color: var(--muted); cursor: pointer;
  padding: 7px 16px; border-radius: 999px; font-family: inherit; font-size: .85rem; font-weight: 700; transition: all .15s;
}
.ypill:hover { border-color: var(--subject); color: var(--ink); }
.ypill.active { background: var(--subject); border-color: var(--subject); color: #fff; }
.ybadge {
  display: inline-block; font-size: .68rem; font-weight: 800; padding: 2px 9px; border-radius: 99px;
  background: #eef0f8; color: #64748b; margin-left: 8px; vertical-align: 2px; flex-shrink: 0;
}
.ybadge.y10 { background: #ecfdf5; color: #047857; }
.ybadge.y11 { background: #eef2ff; color: #4338ca; }
.tab {
  border: 0; background: transparent; padding: 10px 20px; border-radius: 10px; font-family: inherit;
  font-size: .95rem; font-weight: 700; color: var(--muted); cursor: pointer; transition: all .15s; flex: 1; min-width: 120px;
}
.tab:hover { color: var(--ink); }
.tab.active { background: #fff; color: var(--ink); box-shadow: 0 4px 14px rgba(30,41,59,.12); }

/* syllabus */
.syllabus-item { border: 1px solid var(--line); border-radius: 14px; margin-bottom: 12px; overflow: hidden; background: var(--card); }
.syllabus-item summary { cursor: pointer; padding: 16px 20px; font-weight: 700; font-family: "Lexend", sans-serif; list-style: none; display: flex; align-items: center; gap: 10px; }
.syllabus-item summary::-webkit-details-marker { display: none; }
.syllabus-item summary .chev { margin-left: auto; color: var(--muted); transition: transform .15s; }
.syllabus-item[open] summary .chev { transform: rotate(90deg); }
.syllabus-item .body { padding: 4px 20px 16px; }
.subtopic-list { display: flex; flex-wrap: wrap; gap: 8px; }
.subtopic { background: #f1f3fa; border: 1px solid var(--line); color: #3c4461; padding: 6px 12px; border-radius: 999px; font-size: .83rem; font-weight: 500; }

/* learn cards */
.learn-topic { margin-bottom: 22px; }
.learn-topic h3 { font-family: "Lexend", sans-serif; font-size: 1.1rem; margin-bottom: 10px; display: flex; gap: 8px; align-items: center; }
.learn-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.learn-card { background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--subject); border-radius: 12px; padding: 16px; box-shadow: var(--shadow); }
.learn-card h4 { font-size: .95rem; margin-bottom: 6px; color: var(--subject); }
.learn-card .body { font-size: .9rem; color: #374151; }
.learn-card ul { margin: 8px 0 0 18px; font-size: .85rem; color: #4b5563; }
.learn-card li { margin-bottom: 3px; }

/* learn pills (Easy / Detailed) */
.learn-pills { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.lpill {
  border: 2px solid var(--line); background: #fff; color: var(--muted); cursor: pointer;
  padding: 9px 18px; border-radius: 999px; font-family: inherit; font-size: .88rem; font-weight: 700; transition: all .15s;
}
.lpill:hover { border-color: var(--subject); color: var(--ink); }
.lpill.active { background: var(--subject); border-color: var(--subject); color: #fff; }

/* detailed notes */
.det-sections { display: grid; gap: 14px; }
.det-section {
  background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--subject);
  border-radius: 12px; padding: 18px; box-shadow: var(--shadow);
}
.det-section h4 { font-size: 1rem; margin-bottom: 8px; color: var(--subject); }
.det-paras p { font-size: .92rem; color: #374151; margin-bottom: 8px; }
.det-paras p:last-child { margin-bottom: 0; }
.det-bullets { margin: 10px 0 0 18px; font-size: .88rem; color: #4b5563; }
.det-bullets li { margin-bottom: 4px; }
.formula-box {
  margin-top: 12px; background: #eef2ff; border: 1px dashed #c7d2fe; border-radius: 10px;
  padding: 12px 14px; font-size: .95rem; color: #3730a3; font-family: "SF Mono", ui-monospace, Menlo, monospace;
}
.formula-box b { font-family: "Inter", sans-serif; font-size: .78rem; letter-spacing: .03em; display: block; margin-bottom: 2px; color: #4338ca; }
.formula-note { font-family: "Inter", sans-serif; font-size: .82rem; color: #6366f1; margin-top: 4px; }
.example-box {
  margin-top: 12px; background: #fffbeb; border: 1px solid #fde68a; border-radius: 10px;
  padding: 12px 14px; font-size: .9rem; color: #78350f;
}
.example-box b { color: #b45309; }

/* quiz */
.quiz-box { max-width: 760px; margin: 0 auto; }
.quiz-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; font-weight: 700; color: var(--muted); }
.progress { height: 8px; background: #e6e9f2; border-radius: 99px; overflow: hidden; margin-bottom: 18px; }
.progress .fill { height: 100%; background: var(--subject); border-radius: 99px; transition: width .3s; }
.q-card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 24px; box-shadow: var(--shadow); }
.q-text { font-size: 1.06rem; font-weight: 600; margin-bottom: 16px; line-height: 1.5; }
.q-passage { background: #f8f9fd; border-left: 4px solid var(--subject); padding: 12px 14px; border-radius: 8px; font-style: italic; font-size: .92rem; margin-bottom: 14px; color: #374151; }
.opts { display: grid; gap: 10px; }
.opt {
  display: flex; gap: 12px; align-items: flex-start; text-align: left; cursor: pointer;
  border: 2px solid var(--line); background: #fff; border-radius: 12px; padding: 13px 16px;
  font-family: inherit; font-size: .95rem; color: var(--ink); transition: all .15s;
}
.opt:hover:not(:disabled) { border-color: var(--subject); background: #f5f6fd; }
.opt .key { font-weight: 800; color: var(--muted); background: #f1f3fa; border-radius: 8px; padding: 2px 9px; font-size: .85rem; flex-shrink: 0; }
.opt:disabled { cursor: default; }
.opt.correct { border-color: var(--ok); background: #f0fdf4; }
.opt.correct .key { background: var(--ok); color: #fff; }
.opt.wrong { border-color: var(--bad); background: #fef2f2; }
.opt.wrong .key { background: var(--bad); color: #fff; }
.opt.dim { opacity: .55; }

.feedback { margin-top: 16px; border-radius: 12px; padding: 14px 16px; font-size: .92rem; animation: pop .25s ease; }
.feedback.good { background: #f0fdf4; border: 1px solid #bbf7d0; }
.feedback.bad { background: #fef2f2; border: 1px solid #fecaca; }
.feedback h5 { margin-bottom: 6px; font-size: .95rem; }
.feedback .why { margin-top: 8px; color: #374151; }
.feedback .why li { margin-left: 18px; margin-bottom: 4px; }
@keyframes pop { from { transform: translateY(6px); opacity: 0; } to { transform: none; opacity: 1; } }

.btn {
  border: 0; border-radius: 12px; padding: 12px 22px; font-family: inherit; font-weight: 700;
  font-size: .95rem; cursor: pointer; transition: all .15s; display: inline-flex; gap: 8px; align-items: center;
}
.btn-primary { background: var(--subject); color: #fff; }
.btn-primary:hover { filter: brightness(1.08); transform: translateY(-1px); }
.btn-ghost { background: #eef0f8; color: var(--ink); }
.btn-ghost:hover { background: #e2e6f3; }
.btn-block { width: 100%; justify-content: center; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.quiz-actions { display: flex; gap: 10px; margin-top: 16px; }

/* results */
.results { text-align: center; padding: 30px; }
.score-ring {
  width: 150px; height: 150px; border-radius: 50%; margin: 18px auto;
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  background: conic-gradient(var(--subject) calc(var(--pct) * 1%), #e6e9f2 0);
}
.score-ring .inner { width: 126px; height: 126px; border-radius: 50%; background: #fff; display: flex; flex-direction: column; justify-content: center; align-items: center; }
.score-ring .num { font-size: 2.2rem; font-weight: 900; font-family: "Lexend", sans-serif; }
.score-ring .lbl { font-size: .8rem; color: var(--muted); font-weight: 600; }
.grade { font-size: 1.05rem; font-weight: 700; margin-top: 4px; }
.review-list { text-align: left; margin-top: 20px; }
.review-item { border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; margin-bottom: 10px; background: var(--card); font-size: .9rem; }
.review-item .rq { font-weight: 700; margin-bottom: 6px; }
.review-item .tag { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: .75rem; font-weight: 700; margin-left: 8px; }
.tag.yours { background: #fef2f2; color: var(--bad); }
.tag.right { background: #f0fdf4; color: var(--ok); }
.tag.yourans { background: #fff7ed; color: #c2410c; }

/* past papers */
.pp-subject { margin-bottom: 26px; }
.pp-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 10px; }
.pp-head h3 { font-family: "Lexend", sans-serif; font-size: 1.15rem; }
.pp-head .pp-code { color: var(--muted); font-size: .82rem; font-weight: 700; }
.pp-table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 14px; background: var(--card); }
table.pp { width: 100%; border-collapse: collapse; font-size: .88rem; min-width: 560px; }
table.pp th { text-align: left; padding: 10px 14px; background: #f1f3fa; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
table.pp td { padding: 9px 14px; border-top: 1px solid var(--line); }
table.pp tr:hover td { background: #fafbfe; }
a.dl { text-decoration: none; font-weight: 700; padding: 4px 12px; border-radius: 8px; font-size: .8rem; display: inline-block; }
a.dl.qp { background: #eef2ff; color: #4338ca; }
a.dl.ms { background: #f0fdf4; color: #15803d; }
a.dl:hover { filter: brightness(.95); }
button.dl.exam { background: #eef2ff; color: #4338ca; font-size: .78rem; font-weight: 700; padding: 5px 10px; border-radius: 99px; border: none; cursor: pointer; }
button.dl.exam:hover { filter: brightness(.95); }

/* online exam mode */
.exam-overlay { position: fixed; inset: 0; z-index: 200; background: #fff; display: flex; flex-direction: column; }
.exam-bar { display: flex; align-items: center; gap: 14px; padding: 10px 18px; background: #0f1b2d; color: #fff; flex-wrap: wrap; }
.exam-title { font-size: .92rem; flex: 1; min-width: 200px; }
.exam-title b { color: #ffd27d; }
.exam-timer { font-family: ui-monospace, Menlo, monospace; font-size: 1.25rem; font-weight: 700; background: #b8935a; padding: 4px 14px; border-radius: 10px; color: #0f1b2d; }
.exam-flash { background: #22c55e; color: #fff; font-size: .8rem; font-weight: 700; padding: 6px 14px; border-radius: 99px; opacity: 0; transition: opacity .3s; }
.exam-bar .btn { padding: 8px 16px; font-size: .85rem; background: #1e293b; color: #e2e8f0; border: 1px solid #334155; }
.exam-bar .btn-primary { background: #b8935a; color: #0f1b2d; border: none; font-weight: 800; }
.exam-body { display: flex; flex: 1; min-height: 0; }
.exam-pane { display: flex; flex-direction: column; min-height: 0; }
.exam-paper { flex: 1.3; border-right: 1px solid #e5e7eb; background: #f1f3f9; }
.exam-sheet-pane { flex: 1; background: #f9fafb; }
.pane-head { padding: 10px 16px; font-weight: 700; font-size: .9rem; border-bottom: 1px solid #e5e7eb; background: #fff; display: flex; align-items: center; gap: 8px; }
.pane-note { font-weight: 500; color: #6b7280; font-size: .78rem; }
.exam-pdf { flex: 1; width: 100%; border: none; min-height: 0; }
.pane-placeholder { padding: 30px 24px; text-align: center; color: #374151; display: flex; flex-direction: column; gap: 12px; align-items: center; justify-content: center; height: 100%; }

/* mobile: stack panes */
@media (max-width: 900px) {
  .exam-body { flex-direction: column; overflow-y: auto; }
  .exam-paper { border-right: none; border-bottom: 1px solid #e5e7eb; min-height: 55vh; }
  .exam-sheet-pane { min-height: 55vh; }
  .exam-bar { gap: 8px; }
  .exam-title { min-width: 100%; order: -1; }
  .exam-calc { right: 8px; bottom: 8px; width: 92vw; }
}
.exam-sheet { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.exam-q { display: flex; gap: 10px; align-items: flex-start; background: #fff; border: 1px solid #e5e7eb; border-radius: 12px; padding: 8px 10px; }
.exam-q .qnum { font-weight: 800; font-size: .8rem; color: var(--brand); background: #eef2ff; border-radius: 8px; padding: 4px 8px; min-width: 40px; text-align: center; margin-top: 4px; }
.exam-q .qflex { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.exam-q .qmini { font-size: .78rem; color: #6b7280; background: #f8fafc; border: 1px dashed #d1d5db; border-radius: 8px; padding: 5px 8px; }
.exam-q textarea { flex: 1; border: 1px solid #d1d5db; border-radius: 10px; padding: 8px 10px; font: inherit; font-size: .88rem; resize: vertical; min-height: 52px; }

/* questions pane */
.exam-questions-wrap { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.exam-questions { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; background: #f8fafc; }
.exam-questions .exam-sec { font-weight: 800; font-size: .8rem; letter-spacing: .05em; color: #7c3aed; background: #f3e8ff; align-self: flex-start; padding: 4px 12px; border-radius: 99px; margin-top: 6px; }
.exam-question { background: #fff; border: 1px solid #e5e7eb; border-radius: 12px; padding: 10px 12px; }
.exam-question .qhead { display: flex; align-items: center; gap: 8px; margin-bottom: 5px; }
.exam-question .qmarks { font-size: .72rem; font-weight: 700; color: #b45309; background: #fffbeb; border: 1px solid #fde68a; padding: 2px 8px; border-radius: 99px; }
.exam-question .qtext { font-size: .9rem; color: #111827; line-height: 1.5; }
.exam-question .qparts { margin-top: 7px; display: flex; flex-direction: column; gap: 5px; }
.exam-question .qpart { font-size: .85rem; color: #374151; border-left: 3px solid #c7d2fe; padding-left: 8px; line-height: 1.45; }
.exam-qcount { font-size: .72rem; font-weight: 700; color: #0f1b2d; background: #ffd27d; padding: 2px 10px; border-radius: 99px; }
.btn-sm { font-size: .76rem; padding: 5px 10px; }

/* exam tabs (answer sheet / whiteboard) */
.exam-tab { border: none; background: transparent; cursor: pointer; font-weight: 700; font-size: .82rem; color: var(--muted); padding: 6px 12px; border-radius: 10px; }
.exam-tab.active { background: var(--brand); color: #fff; }

/* whiteboard */
#board-wrap { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.board-tools { display: flex; gap: 6px; align-items: center; padding: 8px 10px; border-bottom: 1px solid #e5e7eb; background: #fff; flex-wrap: wrap; }
.bw, .bs { border: 1px solid #d1d5db; background: #fff; border-radius: 9px; padding: 5px 9px; font-size: .85rem; cursor: pointer; line-height: 1; }
.bw.active { background: #eef2ff; border-color: var(--brand); }
.bw-size { display: inline-flex; gap: 4px; align-items: center; margin-left: 4px; }
.board-canvas-wrap { flex: 1; min-height: 0; overflow: hidden; background: #fff; }
.board-canvas { display: block; touch-action: none; cursor: crosshair; }

/* scientific calculator panel */
.exam-calc { position: fixed; right: 20px; bottom: 20px; width: 320px; z-index: 220; background: #0f1b2d; border-radius: 16px; padding: 10px; box-shadow: 0 18px 50px rgba(0,0,0,.45); display: none; }
.calc-head { display: flex; align-items: center; gap: 8px; color: #cbd5e1; font-size: .8rem; font-weight: 700; padding: 2px 4px 8px; }
.calc-deg, .calc-close { margin-left: auto; background: #1e293b; color: #7dd3fc; border: none; border-radius: 8px; padding: 4px 10px; font-weight: 700; font-size: .72rem; cursor: pointer; }
.calc-close { color: #fca5a5; }
.calc-display { background: #1e293b; border-radius: 12px; padding: 10px 14px; text-align: right; min-height: 64px; margin-bottom: 8px; }
.calc-expr { color: #94a3b8; font-size: .95rem; min-height: 20px; word-break: break-all; font-family: ui-monospace, Menlo, monospace; }
.calc-result { color: #fff; font-size: 1.5rem; font-weight: 700; font-family: ui-monospace, Menlo, monospace; }
.calc-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.ck { background: #1e293b; color: #e2e8f0; border: none; border-radius: 10px; padding: 12px 0; font-size: .95rem; font-weight: 600; cursor: pointer; }
.ck:hover { background: #334155; }
.ck[data-k="="] { background: var(--brand); color: #fff; font-weight: 800; }
.ck[data-k="AC"], .ck[data-k="⌫"] { color: #fca5a5; }
.ck[data-k="÷"], .ck[data-k="×"], .ck[data-k="−"], .ck[data-k="+"], .ck[data-k="%"], .ck[data-k="±"], .ck[data-k="("], .ck[data-k=")"] { color: #7dd3fc; }
.ck[data-k="sin"], .ck[data-k="cos"], .ck[data-k="tan"], .ck[data-k="log"], .ck[data-k="ln"], .ck[data-k="√"], .ck[data-k="x²"], .ck[data-k="xʸ"], .ck[data-k="π"], .ck[data-k="e"], .ck[data-k="!"] { font-size: .78rem; }

/* interactive MCQ mode */
.mcq-wrap { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; background: #f1f3f9; min-height: 0; }
.exam-start { margin: auto; max-width: 520px; width: 100%; padding: 22px; display: flex; flex-direction: column; gap: 14px; }
.es-head { display: flex; gap: 14px; align-items: center; }
.es-badge { font-size: 2rem; background: #0f1b2d; color: #b8935a; border-radius: 16px; width: 64px; height: 64px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.es-head h2 { font-family: "Lexend", sans-serif; font-size: 1.15rem; margin: 0 0 4px; }
.es-head p { margin: 0; font-size: .85rem; }
.es-stats { display: flex; gap: 10px; }
.es-stat { flex: 1; background: #fff; border: 1px solid #e5e7eb; border-radius: 14px; text-align: center; padding: 12px 8px; }
.es-stat b { display: block; font-size: 1.35rem; font-family: "Lexend", sans-serif; color: #0f1b2d; }
.es-stat span { font-size: .74rem; color: var(--muted); font-weight: 600; }
.es-stat.es-best b { color: #b8935a; }
.es-settings { background: #fff; border: 1px solid #e5e7eb; border-radius: 14px; padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; }
.es-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: .85rem; }
.es-row label { font-weight: 700; color: #374151; }
.es-row select, .es-settings select { font: inherit; border: 1px solid #d1d5db; border-radius: 9px; padding: 7px 10px; background: #fff; max-width: 60%; }
.es-chk { display: flex; align-items: center; gap: 8px; font-size: .85rem; font-weight: 600; color: #374151; }
.es-go { width: 100%; padding: 13px; font-size: 1rem; }
.es-resume { width: 100%; border: 2px dashed #b8935a; color: #7a5c26; background: #fdf7ec; font-weight: 700; }
.es-alt { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }
.es-alt .dl, .es-alt .linkish { background: none; border: none; cursor: pointer; font: inherit; font-size: .82rem; font-weight: 700; color: var(--brand); text-decoration: none; padding: 4px 8px; }
.es-hint { text-align: center; font-size: .76rem; margin: 0; }
.mcq-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-weight: 700; font-size: .85rem; color: var(--muted); margin-bottom: 8px; }
.mcq-prog { background: #0f1b2d; color: #b8935a; padding: 3px 12px; border-radius: 99px; white-space: nowrap; }
.mcq-top .btn-sm { margin-left: auto; }
#mcq-flag { border: 1px solid #d1d5db; background: #fff; color: #64748b; }
#mcq-flag.flag-on { background: #fdf7ec; border-color: #b8935a; color: #7a5c26; }
.mcq-bar { height: 6px; background: #e2e8f0; border-radius: 99px; overflow: hidden; margin-bottom: 8px; }
.mcq-bar-fill { height: 100%; background: linear-gradient(90deg, #b8935a, #d4af6a); border-radius: 99px; transition: width .25s; }
.mcq-palette { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 10px; }
.pal { width: 26px; height: 26px; border-radius: 8px; border: 1.5px solid #cbd5e1; background: #fff; font-size: .72rem; font-weight: 700; color: #64748b; cursor: pointer; }
.pal.cur { border-color: #0f1b2d; background: #0f1b2d; color: #fff; }
.pal.ans { background: #eef2ff; border-color: #6366f1; color: #4338ca; }
.pal.flg { box-shadow: 0 0 0 2px #b8935a; }
.mcq-card { background: #fff; border: 1px solid #e5e7eb; border-radius: 14px; padding: 14px 16px; margin-bottom: 12px; }
.mcq-opt.sel { border-color: #b8935a; background: #fdf7ec; }
.mcq-opt.sel .ol { background: #b8935a; color: #fff; }
.bw .dot { display: inline-block; width: 13px; height: 13px; border-radius: 50%; vertical-align: middle; }
.bw svg { display: block; }
.mcq-opts { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.mcq-opt { display: flex; align-items: flex-start; gap: 10px; text-align: left; background: #fff; border: 2px solid #e5e7eb; border-radius: 12px; padding: 11px 14px; font: inherit; font-size: .9rem; cursor: pointer; transition: all .12s; }
.mcq-opt:hover { border-color: var(--brand); }
.mcq-opt .ol { font-weight: 800; color: var(--brand); background: #eef2ff; border-radius: 8px; padding: 2px 9px; min-width: 30px; text-align: center; }
.mcq-opt.right { border-color: #22c55e; background: #f0fdf4; }
.mcq-opt.right .ol { background: #22c55e; color: #fff; }
.mcq-opt.wrong { border-color: #ef4444; background: #fef2f2; }
.mcq-opt.wrong .ol { background: #ef4444; color: #fff; }
.mcq-opt.dim { opacity: .55; }
.mcq-fb { border-radius: 12px; padding: 12px 14px; font-size: .88rem; line-height: 1.5; margin-bottom: 12px; }
.mcq-fb.good { background: #f0fdf4; border: 1px solid #bbf7d0; color: #166534; }
.mcq-fb.bad { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }
.mcq-next-row { text-align: right; }
.mcq-done { margin: auto; max-width: 560px; text-align: center; padding: 16px; }
.mcq-done h2 { font-family: "Lexend", sans-serif; font-size: 2rem; margin-bottom: 4px; }
.mcq-review { margin-top: 16px; text-align: left; display: flex; flex-direction: column; gap: 8px; max-height: 46vh; overflow-y: auto; }
.mcq-rv { border-radius: 10px; padding: 9px 12px; font-size: .85rem; line-height: 1.45; }
.mcq-rv.rv-good { background: #f0fdf4; border: 1px solid #bbf7d0; }
.mcq-rv.rv-bad { background: #fef2f2; border: 1px solid #fecaca; }
.mcq-rv .rv-x { margin-top: 4px; color: #374151; }
.exam-pdf-open { padding: 10px 14px; text-align: center; background: #f8fafc; border-top: 1px solid #e5e7eb; }
.sheet-tools { padding: 10px 14px; border-top: 1px solid #e5e7eb; display: flex; gap: 8px; flex-wrap: wrap; background: #fff; }
.sheet-tools .btn { font-size: .78rem; padding: 7px 12px; }
.exam-done { margin: auto; max-width: 560px; text-align: center; padding: 30px; }
.exam-done h2 { font-family: "Lexend", sans-serif; margin-bottom: 8px; }
.done-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin: 18px 0; }
.score-box { background: #fff; border: 1px solid #e5e7eb; border-radius: 14px; padding: 14px; display: flex; gap: 10px; align-items: center; justify-content: center; flex-wrap: wrap; }
.score-box input { width: 90px; padding: 8px; border: 1px solid #d1d5db; border-radius: 8px; font: inherit; }
@media (max-width: 860px) {
  .exam-body { flex-direction: column; }
  .exam-paper { flex: 1; border-right: none; border-bottom: 1px solid #e5e7eb; min-height: 40vh; }
}
.spec-badge { font-size: .7rem; font-weight: 700; padding: 2px 8px; border-radius: 99px; }
.spec-badge.old { background: #fff7ed; color: #c2410c; }
.spec-badge.new { background: #ecfdf5; color: #047857; }
.spec-badge.cbse { background: #eef2ff; color: #4338ca; }
.note { background: #fefce8; border: 1px solid #fde68a; color: #854d0e; border-radius: 12px; padding: 12px 16px; font-size: .86rem; margin-bottom: 18px; }

/* misc */
.muted { color: var(--muted); }
.loading { text-align: center; padding: 80px 0; color: var(--muted); }
.spinner {
  width: 44px; height: 44px; margin: 0 auto 14px; border-radius: 50%;
  border: 4px solid #e6e9f2; border-top-color: var(--brand); animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.backlink { display: inline-flex; gap: 6px; text-decoration: none; color: var(--muted); font-weight: 700; font-size: .88rem; margin-bottom: 14px; }
.backlink:hover { color: var(--ink); }
footer.footer { text-align: center; padding: 26px 20px; color: var(--muted); font-size: .82rem; border-top: 1px solid var(--line); background: #fff; }
.footer-note { margin-top: 4px; opacity: .8; }
.error-box { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; border-radius: 14px; padding: 20px; }

@media (max-width: 640px) {
  .hero { padding: 32px 24px; }
  .tabs { flex-direction: column; }
  .tab { min-width: 100%; }
}

/* practice topic picker */
.dl.real { background: #f5efe4; color: #8a6d3b; border: 1px solid #e5dcc8; margin-top: 6px; }
.dl.real:hover { background: #efe6d2; }
.rt-start { padding: 10px 4px; }
.rt-facts { list-style: none; padding: 0; margin: 14px 0; }
.rt-facts li { padding: 7px 12px; margin-bottom: 8px; background: #f8fafc; border: 1px solid #e5e7eb; border-radius: 10px; font-size: .92rem; }
.rv-opt { padding: 7px 10px; border: 1px solid #e5e7eb; border-radius: 8px; margin: 3px 0; font-size: .9rem; }
.rv-correct { background: #ecfdf5; border-color: #6ee7b7; }
.rv-wrong { background: #fef2f2; border-color: #fca5a5; }
#float-calc-btn { position: fixed; right: 20px; bottom: 20px; width: 58px; height: 58px; border-radius: 50%; border: none; background: #0f1b2d; color: #b8935a; box-shadow: 0 6px 20px rgba(15, 27, 45, .35); cursor: pointer; display: flex; align-items: center; justify-content: center; z-index: 300; transition: transform .15s ease; }
#float-calc-btn:hover { transform: scale(1.07); }
#float-calc-btn:active { transform: scale(.96); }
#float-calc-wrap { position: fixed; right: 20px; bottom: 92px; z-index: 300; }
#float-calc-wrap .exam-calc { width: 300px; border-radius: 14px; box-shadow: 0 12px 40px rgba(15, 27, 45, .3); }
@media (max-width: 640px) { #float-calc-wrap { right: 10px; bottom: 84px; } #float-calc-wrap .exam-calc { width: calc(100vw - 40px); } }
.lfig { margin: 12px 0 4px; }
.lfig svg { width: 100%; height: auto; max-width: 560px; display: block; margin: 0 auto; border: 1px solid #e5e7eb; border-radius: 12px; background: #fff; }
.lfig figcaption { text-align: center; font-size: .78rem; color: #64748b; margin-top: 6px; font-style: italic; }
.pr-head { margin-bottom: 14px; }
.pr-head h3 { font-family: "Lexend", sans-serif; margin-bottom: 4px; }
.pr-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.pr-card { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; background: var(--card); border: 1.5px solid var(--line); border-radius: 16px; padding: 16px; cursor: pointer; text-align: left; font: inherit; transition: all .15s; }
.pr-card:hover { border-color: var(--brand); box-shadow: 0 6px 18px rgba(79, 70, 229, .08); transform: translateY(-2px); }
.pr-emoji { font-size: 1.5rem; }
.pr-name { font-weight: 800; color: var(--ink); font-size: .92rem; }
.pr-count { font-size: .78rem; color: var(--muted); font-weight: 600; background: #f1f3fa; border-radius: 99px; padding: 2px 10px; }
@media (max-width: 640px) { .pr-grid { grid-template-columns: 1fr 1fr; gap: 10px; } .pr-card { padding: 13px; } }
@media (max-width: 400px) { .pr-grid { grid-template-columns: 1fr; } }

/* ================= responsive layer ================= */

/* tablets */
@media (max-width: 1024px) {
  .exam-calc { width: 300px; }
}

/* large phones → tablets */
@media (max-width: 860px) {
  .trackbar-inner { overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; padding: 8px 14px; }
  .trackbar-inner .tpill { flex: 0 0 auto; }
  .topbar-inner { padding: 8px 14px; gap: 8px; }
  .grid-subjects { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
  .exam-body { flex-direction: column; }
  .exam-paper { border-right: none; border-bottom: 1px solid #e5e7eb; min-height: 45vh; }
  .form-row { grid-template-columns: 1fr; }
}

/* phones */
@media (max-width: 640px) {
  .topbar { position: sticky; }
  .brand-logo { height: 38px; }
  .nav { gap: 4px; }
  .nav a { font-size: .8rem; padding: 6px 10px; }
  .nav-right a { font-size: .78rem; padding: 6px 12px; }

  .hero { padding: 26px 16px; text-align: left; }
  .hero h1 { font-size: clamp(1.7rem, 8vw, 2.4rem); }
  .hero p { font-size: .9rem; }
  .hero .btn, .hero-actions .btn { width: 100%; justify-content: center; }
  .chips { justify-content: flex-start; overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; }
  .chip { flex: 0 0 auto; }

  .container { padding: 0 12px; }
  .section-title { font-size: 1.05rem; }
  .subject-head { padding: 18px 14px; flex-wrap: wrap; }
  .subject-head h1 { font-size: 1.2rem; }
  .subject-meta { font-size: .8rem; flex-wrap: wrap; }

  /* subject tabs scroll horizontally instead of stacking */
  .tabs { flex-direction: row; overflow-x: auto; -webkit-overflow-scrolling: touch; gap: 6px; padding: 0 2px; }
  .tab { min-width: auto; white-space: nowrap; }
  .year-row, .mode-row, .ypills { flex-wrap: wrap; }

  .grid-subjects { grid-template-columns: 1fr; gap: 12px; }
  .learn-cards { grid-template-columns: 1fr; }

  /* papers table scrolls inside its card */
  .pp-table-wrap { border-radius: 10px; }
  .pp { min-width: 640px; font-size: .82rem; }
  .pp th, .pp td { padding: 8px 10px; }
  .sheet-tools { gap: 6px; }
  .sheet-tools .btn { flex: 1 1 45%; justify-content: center; }

  /* quiz */
  .opts .opt { padding: 11px 12px; font-size: .9rem; }
  .quiz-top { flex-wrap: wrap; gap: 6px; }

  /* modal → bottom sheet */
  .overlay { align-items: flex-end; padding: 0; }
  .modal { width: 100%; max-width: 100%; border-radius: 20px 20px 0 0; padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); max-height: 88vh; overflow-y: auto; }

  /* manage */
  .mg-toolbar { flex-direction: column; }
  .mg-select { width: 100%; }
  .mg-type-row { gap: 6px; }
  .mg-type-row .btn { flex: 1 1 45%; justify-content: center; font-size: .78rem; padding: 8px 6px; }
  .form-row { grid-template-columns: 1fr; }
  .card-pad { padding: 14px; }

  /* exam desk on phones */
  .exam-bar { gap: 6px; padding: 8px 10px; }
  .exam-bar .btn { padding: 7px 10px; font-size: .78rem; }
  .exam-title { font-size: .8rem; min-width: 100%; }
  .exam-timer { font-size: 1rem; }
  .pane-head { padding: 8px 10px; flex-wrap: wrap; font-size: .82rem; }
  .exam-start { padding: 14px; gap: 10px; }
  .es-head h2 { font-size: 1rem; }
  .es-badge { width: 52px; height: 52px; font-size: 1.6rem; }
  .es-stat b { font-size: 1.1rem; }
  .es-row { flex-direction: column; align-items: stretch; gap: 4px; }
  .es-row select { max-width: 100%; }
  .mcq-top { font-size: .8rem; flex-wrap: wrap; }
  .mcq-palette { gap: 4px; }
  .pal { width: 24px; height: 24px; font-size: .68rem; }
  .mcq-card { padding: 12px; }
  .mcq-card .qtext, .mcq-opt { font-size: .88rem; }
  .mcq-done { padding: 10px; }
  .mcq-done h2 { font-size: 1.6rem; }
  .exam-q .qmini { display: none; } /* hide question preview on tiny screens */
  .exam-calc { right: 6px; bottom: 6px; width: 96vw; }
  .calc-grid { gap: 4px; }
  .ck { padding: 11px 0; font-size: .9rem; }
  .board-tools { gap: 4px; padding: 6px 8px; }
  .bw { padding: 5px 7px; }
  .exam-sheet { padding: 10px; }
  .exam-q textarea { min-height: 44px; }

  footer.footer { padding: 18px 12px; font-size: .76rem; }
}

/* tiny phones */
@media (max-width: 400px) {
  .pal { width: 22px; height: 22px; }
  .exam-sheet-pane { min-height: 50vh; }
  .exam-paper { min-height: 50vh; }
  .tpill-main { font-size: .85rem; }
  .tpill-sub { display: none; }
}
