/* StudyExam — answer-sheet visual system
   ink navy + HB-pencil yellow, green for right, red for wrong */
:root {
  --ink: #1D2B53;
  --ink-2: #34426C;
  --paper: #FAFBFD;
  --white: #FFFFFF;
  --rule: #DCE4F2;
  --line: #E4E9F2;
  --pencil: #F5C542;
  --pencil-soft: #FFF6D9;
  --right: #1E8A4A;
  --right-bg: #E3F4EA;
  --wrong: #CF3A2C;
  --wrong-bg: #FCE8E5;
  --muted: #5E6883;
  --ui: Inter, "Noto Sans Sinhala", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --display: Inter, "Noto Sans Sinhala", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --si: Inter, "Noto Sans Sinhala", "Iskoola Pota", system-ui, sans-serif;
  --r-sm: 6px;
  --r-md: 12px;
}
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 80px; font-size: 100%; }
html[data-fs=sm] { font-size: 90%; }
html[data-fs=lg] { font-size: 115%; }
html[data-fs=xl] { font-size: 130%; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } * { transition: none !important; animation: none !important; } }
body { margin: 0; font: 1.0625rem/1.55 var(--ui); color: var(--ink); background: var(--paper); display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; }
img { max-width: 100%; height: auto; }
a { color: var(--ink); text-underline-offset: 3px; }
/* Only plain links change colour on hover; styled buttons and cards keep their own colours */
a:not([class]):hover { color: var(--ink-2); }
:focus-visible { outline: 3px solid var(--pencil); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3 { font-family: var(--display); line-height: 1.15; letter-spacing: -0.01em; margin: 0 0 .5em; }
h1 { font-size: clamp(1.8rem, 3.5vw, 2.4rem); font-weight: 800; }
h2 { font-size: 1.4rem; font-weight: 600; margin-top: 1.6em; }
h3 { font-size: 1.1rem; font-weight: 600; }
p { margin: 0 0 1em; }
code { background: var(--line); padding: 1px 5px; border-radius: 4px; font-size: .9em; }
.si { font-family: var(--si); line-height: 1.75; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 0; background: var(--pencil); padding: 8px 12px; z-index: 99; }
.skip:focus { left: 8px; }
.wrap { width: min(1280px, 100% - 32px); margin-inline: auto; }
.narrow { width: min(780px, 100% - 32px); }
.inline { display: inline; margin: 0; }
main { flex: 1 0 auto; width: 100%; padding-bottom: 56px; }
.yr { font-weight: 600; color: var(--muted); }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 18px; border: 2px solid var(--ink);
  border-radius: 999px; background: var(--white); color: var(--ink); font: 700 1rem var(--ui); text-decoration: none; cursor: pointer; }
.btn:hover { background: var(--pencil-soft); color: var(--ink); }
.btn-primary { background: var(--ink); color: var(--white); }
.btn-primary:hover { background: var(--ink-2); color: var(--white); }
.btn-small { padding: 6px 14px; font-size: .92rem; }
.btn-big { padding: 14px 26px; font-size: 1.1rem; }
.btn-block { width: 100%; }
.linkbtn { background: none; border: 0; padding: 0; font: inherit; color: var(--ink); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.linkbtn.danger, .danger { color: var(--wrong); }

/* ---------- top bar ---------- */
.topbar { background: var(--white); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 30; }
.topbar-in { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 64px; flex-wrap: wrap; }
.logo { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.logo-mark { width: 26px; height: 26px; border-radius: 50%; border: 3px solid var(--ink); background: radial-gradient(circle, var(--pencil) 0 42%, transparent 44%); }
.logo-word { font: 800 1.35rem var(--display); letter-spacing: -0.02em; }
.logo-word span { color: var(--muted); font-weight: 600; }
.nav { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.nav > a:not(.btn) { text-decoration: none; font-weight: 700; }
.nav > a:not(.btn):hover { text-decoration: underline; }
.subbar { background: var(--ink); }
.subbar .wrap { display: flex; gap: 22px; overflow-x: auto; padding: 8px 0; scrollbar-width: none; }
.subbar a { color: var(--white); text-decoration: none; font-weight: 700; white-space: nowrap; font-size: .95rem; }
.subbar a:hover { color: var(--pencil); }

/* ---------- flash ---------- */
.flash { padding: 12px 16px; border-radius: var(--r-sm); margin: 16px 0; border-left: 5px solid; }
.flash-ok { background: var(--right-bg); border-color: var(--right); }
.flash-err { background: var(--wrong-bg); border-color: var(--wrong); }
.flash-warn { background: var(--pencil-soft); border-color: var(--pencil); }

/* ---------- ads ---------- */
.ad { margin: 20px auto; text-align: center; width: min(1160px, 100% - 32px); overflow: hidden; }
.ad-label { display: block; font-size: .72rem; color: var(--muted); margin-bottom: 4px; }
.papers-side .ad { width: 100%; position: sticky; top: 84px; margin-top: 0; }

/* ---------- hero ---------- */
.hero { background:
    repeating-linear-gradient(to bottom, transparent 0 35px, var(--rule) 35px 36px),
    var(--white);
  border-bottom: 1px solid var(--line); }
.hero-in { display: grid; grid-template-columns: 1.25fr .75fr; gap: 48px; align-items: center; padding: 56px 0; }
.hero h1 { font-size: clamp(2.1rem, 5vw, 3.6rem); max-width: 16ch; line-height: 1.05; }
.lead { font-size: 1.15rem; max-width: 52ch; color: var(--ink-2); }
.hero-cta { display: flex; gap: 12px; flex-wrap: wrap; }
.hero-sheet { background: var(--white); border: 2px solid var(--ink); border-radius: var(--r-md); padding: 18px 22px; box-shadow: 8px 8px 0 var(--pencil); transform: rotate(1.5deg); max-width: 300px; justify-self: center; }
.hs-title { font-weight: 700; margin-bottom: 8px; border-bottom: 1px dashed var(--rule); padding-bottom: 6px; }
.hs-row { display: flex; align-items: center; gap: 10px; padding: 4px 0; }
.hs-n { width: 1.6em; font-weight: 700; color: var(--muted); text-align: right; }
.hs-b { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--rule); display: grid; place-items: center; font-size: .8rem; color: var(--muted); }
.hs-b.ok { background: var(--right); border-color: var(--right); color: var(--white); }
.hs-b.ok.ghost { background: var(--right-bg); color: var(--right); }
.hs-b.bad { background: var(--wrong); border-color: var(--wrong); color: var(--white); }
.hs-score { margin: 10px 0 0; display: flex; align-items: baseline; justify-content: flex-end; gap: 6px; font: 700 1.1rem var(--display); }
.hs-num { font-size: 2rem; }
.hs-grade { margin-right: auto; width: 38px; height: 38px; border-radius: 8px; display: grid; place-items: center; background: var(--pencil); font: 800 1.3rem var(--display); transform: rotate(-4deg); }

/* ---------- paper list ---------- */
.papers-wrap { display: grid; grid-template-columns: 1fr 300px; gap: 32px; padding-top: 32px; }
.papers-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.papers-head h2 { margin: 0; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 12px 0; }
select, input, textarea { font: inherit; color: var(--ink); border: 2px solid var(--rule); border-radius: var(--r-sm); padding: 8px 10px; background: var(--white); max-width: 100%; }
select:focus, input:focus, textarea:focus { border-color: var(--ink); outline: none; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0 20px; }
.chip { padding: 6px 14px; border: 2px solid var(--rule); border-radius: 999px; text-decoration: none; font-weight: 700; font-size: .92rem; background: var(--white); }
.chip .si { font-weight: 400; color: var(--muted); font-size: .85rem; }
.chip.on { border-color: var(--ink); background: var(--ink); color: var(--white); }
.chip.on .si { color: var(--rule); }
.paper-list { list-style: none; padding: 0; margin: 0; border-top: 2px solid var(--ink); }
.paper-row { display: grid; grid-template-columns: 92px 1fr auto auto; gap: 18px; align-items: center; padding: 16px 4px; border-bottom: 1px solid var(--line); }
.pr-year { font: 800 2rem var(--display); letter-spacing: -0.03em; color: var(--ink); }
.pr-main h3 { margin: 0 0 2px; font-size: 1.15rem; }
.pr-main h3 a { text-decoration: none; }
.pr-main h3 a:hover { text-decoration: underline; }
.pr-main p { margin: 0; font-size: .92rem; }
.pr-best { font-weight: 700; color: var(--right); white-space: nowrap; display: grid; text-align: right; line-height: 1.2; }
.pr-best small { font-weight: 400; color: var(--muted); font-size: .8rem; }
.pr-si { font-weight: 400; font-size: .85rem; color: var(--muted); }
.empty { padding: 32px; border: 2px dashed var(--rule); border-radius: var(--r-md); text-align: center; background: var(--white); margin: 16px 0; }

/* ---------- exam ---------- */
.crumbs { font-size: .92rem; color: var(--muted); margin: 20px 0 8px; }
.crumbs a { color: var(--muted); }
.exam-head h1 { margin-bottom: 12px; }
.instructions { background: var(--pencil-soft); border-left: 5px solid var(--pencil); padding: 12px 16px; border-radius: var(--r-sm); max-width: 760px; }
.exam { display: grid; grid-template-columns: 1fr 290px; gap: 32px; align-items: start; margin-top: 20px; }
.q { display: grid; grid-template-columns: 52px 1fr; gap: 14px; background: var(--white); border: 1px solid var(--line); border-radius: var(--r-md); padding: 20px 20px 20px 14px; margin-bottom: 16px; }
.q-no { width: 42px; height: 42px; border-radius: 50%; border: 2px solid var(--ink); display: grid; place-items: center; font: 800 1.05rem var(--display); }
.q.is-answered .q-no { background: var(--ink); color: var(--white); }
.q-main { min-width: 0; }
.q-text { font-size: 1.08rem; margin-bottom: 12px; }
.q-img { display: block; margin: 8px 0 14px; border: 1px solid var(--line); border-radius: var(--r-sm); }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.opts { display: grid; gap: 8px; }
.opt { display: flex; align-items: center; gap: 12px; padding: 8px 12px; border: 2px solid var(--line); border-radius: var(--r-sm); cursor: pointer; background: var(--white); }
.opt input { position: absolute; opacity: 0; pointer-events: none; }
.bubble { flex: none; width: 34px; height: 34px; border-radius: 50%; border: 2px solid var(--ink); display: grid; place-items: center; font-weight: 700; background: var(--white); }
.opt:hover { border-color: var(--rule); background: #F5F8FD; }
.opt:has(input:focus-visible) { outline: 3px solid var(--pencil); outline-offset: 2px; }
.opt:has(input:checked) { border-color: var(--ink); background: var(--pencil-soft); }
.opt:has(input:checked) .bubble { background: var(--ink); color: var(--white); box-shadow: 0 0 0 3px var(--pencil); }
.opt-text { flex: 1; }
.clear-answer { margin-top: 10px; font-size: .9rem; color: var(--muted); }
.exam-end { text-align: center; padding: 28px; border: 2px dashed var(--rule); border-radius: var(--r-md); background: var(--white); }
.sheet { position: sticky; top: 84px; }
.sheet-in { background: var(--white); border: 1px solid #e2e8f0; box-shadow: 0 1px 3px rgba(15,23,42,.06); border-radius: var(--r-md); padding: 16px; max-height: calc(100vh - 110px); overflow: auto; }
.timer { display: flex; justify-content: space-between; align-items: baseline; margin: 0 0 6px; }
.timer-label { font-size: .9rem; color: var(--muted); }
.timer-val { font: 800 1.8rem var(--display); font-variant-numeric: tabular-nums; }
.timer.low .timer-val { color: var(--wrong); }
.sheet-count { margin: 0 0 12px; font-size: .95rem; }
.sheet-grid { list-style: none; padding: 0; margin: 0 0 14px; display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.sheet-grid a { display: flex; flex-direction: column; align-items: center; gap: 2px; text-decoration: none; padding: 4px 0; border-radius: var(--r-sm); font-size: .75rem; color: var(--muted); }
.sheet-grid a:hover { background: var(--pencil-soft); }
.sheet-grid b { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--rule); display: grid; place-items: center; font-size: .8rem; color: var(--white); }
.sheet-grid a.done b { background: var(--ink); border-color: var(--ink); }
dialog.confirm { border: 2px solid var(--ink); border-radius: var(--r-md); padding: 24px; max-width: 440px; width: calc(100% - 32px); }
dialog.confirm::backdrop { background: rgba(29, 43, 83, .45); }
dialog.confirm h2 { margin-top: 0; }
.confirm-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }

/* ---------- results ---------- */
.score-card { display: grid; grid-template-columns: 1.2fr 1fr; gap: 24px 40px; background: var(--white); border: 2px solid var(--ink); border-radius: var(--r-md); padding: 28px; box-shadow: 8px 8px 0 var(--pencil); }
.score-paper { font-weight: 700; margin: 0; color: var(--muted); }
.score-big { font-family: var(--display); margin: 0; line-height: 1; }
.score-big span { font-size: clamp(4rem, 12vw, 6.5rem); font-weight: 800; letter-spacing: -0.04em; }
.score-big small { font-size: 1.8rem; font-weight: 600; color: var(--muted); margin-left: 6px; }
.score-verdict { font-size: 1.15rem; font-weight: 700; margin: 10px 0 4px; }
.score-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 0; align-content: center; }
.score-stats div { border-left: 5px solid var(--rule); padding: 4px 12px; }
.score-stats .st-ok { border-color: var(--right); }
.score-stats .st-bad { border-color: var(--wrong); }
.score-stats dt { font-size: .88rem; color: var(--muted); }
.score-stats dd { margin: 0; font: 800 1.8rem var(--display); }
.score-actions { grid-column: 1 / -1; display: flex; gap: 12px; flex-wrap: wrap; }
.omr { list-style: none; padding: 0; margin: 24px 0; display: flex; flex-wrap: wrap; gap: 8px; }
.omr a { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; text-decoration: none; font-weight: 700; font-size: .9rem; border: 2px solid; }
.omr-ok { background: var(--right); border-color: var(--right); color: var(--white) !important; }
.omr-bad { background: var(--wrong); border-color: var(--wrong); color: var(--white) !important; }
.omr-blank { background: var(--white); border-color: var(--rule); color: var(--muted) !important; border-style: dashed !important; }
.review-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin: 12px 0 16px; }
.review-head h2 { margin: 0; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tab { font: 700 .92rem var(--ui); padding: 6px 14px; border-radius: 999px; border: 2px solid var(--rule); background: var(--white); color: var(--ink); cursor: pointer; }
.tab.on { border-color: var(--ink); background: var(--ink); color: var(--white); }
.q-review.q-ok { border-left: 6px solid var(--right); }
.q-review.q-bad { border-left: 6px solid var(--wrong); }
.q-review.q-blank { border-left: 6px dashed var(--rule); }
.q-review.q-ok .q-no { border-color: var(--right); color: var(--right); }
.q-review.q-bad .q-no { border-color: var(--wrong); color: var(--wrong); }
.q-status { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-size: .92rem; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-weight: 700; font-size: .85rem; white-space: nowrap; }
.pill-ok { background: var(--right-bg); color: var(--right); }
.pill-bad { background: var(--wrong-bg); color: var(--wrong); }
.pill-blank { background: var(--line); color: var(--muted); }
.opts-review .opt { cursor: default; }
.opts-review .opt:hover { background: var(--white); border-color: var(--line); }
.opt-tag { font-size: .82rem; font-weight: 700; white-space: nowrap; }
.opt.is-right { border-color: var(--right); background: var(--right-bg); }
.opt.is-right .bubble { background: var(--right); border-color: var(--right); color: var(--white); }
.opt.is-right .opt-tag { color: var(--right); }
.opt.is-wrong { border-color: var(--wrong); background: var(--wrong-bg); }
.opt.is-wrong .bubble { background: var(--wrong); border-color: var(--wrong); color: var(--white); }
.opt.is-wrong .opt-tag { color: var(--wrong); }
.opts-review .opt.is-right:hover { background: var(--right-bg); border-color: var(--right); }
.opts-review .opt.is-wrong:hover { background: var(--wrong-bg); border-color: var(--wrong); }
.solve-link { display: inline-block; margin-top: 14px; font-weight: 700; }

/* ---------- solution ---------- */
.solution-box { background: var(--white); border: 2px solid var(--ink); border-radius: var(--r-md); padding: 22px 24px; margin: 8px 0 24px; }
.solution-box h2 { margin-top: 0; }
.answer-line { background: var(--right-bg); color: var(--right); padding: 8px 12px; border-radius: var(--r-sm); display: inline-block; }
.sol-text { font-size: 1.05rem; }
.sol-nav { display: flex; justify-content: space-between; gap: 12px; }

/* ---------- forms & auth ---------- */
.form { display: grid; gap: 14px; }
.form label { display: grid; gap: 4px; font-weight: 700; }
.form label .muted { font-weight: 400; font-size: .88rem; }
.form label.check { display: flex; align-items: center; gap: 8px; font-weight: 400; }
.form input[type=checkbox] { width: 18px; height: 18px; }
.card-flat { background: var(--white); border: 1px solid var(--line); border-radius: var(--r-md); padding: 22px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 110px auto; gap: 14px; align-items: end; }
.fs { border: 1px solid var(--line); border-radius: var(--r-sm); padding: 14px; display: grid; gap: 12px; }
.fs legend { font: 600 1.05rem var(--display); padding: 0 6px; }
.opt-edit { display: grid; grid-template-columns: 80px 1fr; gap: 10px; align-items: center; }
.opt-edit .bubble { width: 30px; height: 30px; }
.img-prev { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.img-prev img { max-height: 140px; border: 1px solid var(--line); border-radius: var(--r-sm); }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; }
textarea.code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .85rem; }
.auth-wrap { display: grid; place-items: center; padding: 40px 0; }
.auth-card { width: min(440px, 100%); background: var(--white); border: 2px solid var(--ink); border-radius: var(--r-md); padding: 28px; box-shadow: 8px 8px 0 var(--pencil); }
.auth-alt { margin: 16px 0 0; text-align: center; }
.google-box { display: grid; justify-items: center; gap: 8px; margin-bottom: 8px; }
.or { width: 100%; display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: .9rem; margin: 8px 0; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* ---------- tables & admin ---------- */
.table-wrap { overflow-x: auto; background: var(--white); border: 1px solid var(--line); border-radius: var(--r-md); }
.table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { background: #F3F6FB; font-weight: 700; white-space: nowrap; }
.table tr:last-child td { border-bottom: 0; }
.table .actions { white-space: nowrap; }
.table .actions > * + * { margin-left: 12px; }
.qtable td.si { max-width: 420px; }
.pct { font-weight: 700; }
.pct-ok { color: var(--right); }
.pct-bad { color: var(--wrong); }
.admin-title { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 24px; }
.admin-title h1 { margin: 0; }
.admin-title > div { display: flex; gap: 8px; flex-wrap: wrap; }
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 20px 0; }
.stat-row div { background: var(--white); border: 1px solid var(--line); border-radius: var(--r-md); padding: 14px 16px; }
.stat-row dt { color: var(--muted); font-size: .9rem; }
.stat-row dd { margin: 0; font: 800 2rem var(--display); }
.bulk { margin-top: 24px; background: var(--white); border: 1px solid var(--line); border-radius: var(--r-md); padding: 16px 20px; }
.bulk summary { font: 600 1.1rem var(--display); cursor: pointer; }
.bulk form { margin-top: 12px; }


/* ---------- responsive (v1) ---------- */
@media (max-width: 960px) {
  .hero-in { grid-template-columns: 1fr; padding: 36px 0; gap: 28px; }
  .hero-sheet { justify-self: start; transform: rotate(0); }
  .papers-wrap { grid-template-columns: 1fr; }
  .papers-side .ad { position: static; }
  .exam { grid-template-columns: 1fr; }
  .sheet { position: sticky; top: 0; order: -1; z-index: 10; }
  .sheet-in { max-height: none; padding: 10px 14px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
  .sheet-grid { display: none; }
  .timer, .sheet-count { margin: 0; }
  .sheet .btn-block { width: auto; margin-left: auto; }
  .score-card { grid-template-columns: 1fr; }
  .stat-row { grid-template-columns: 1fr 1fr; }
  .grid3 { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  body { font-size: 1rem; }
  .paper-row { grid-template-columns: 64px 1fr; }
  .pr-year { font-size: 1.5rem; }
  .paper-row .btn, .pr-best { grid-column: 2; justify-self: start; }
  .q { grid-template-columns: 1fr; padding: 16px; }
  .grid2 { grid-template-columns: 1fr; }
  .timer-val { font-size: 1.4rem; }
}

/* =====================================================================
   v2 additions
   ===================================================================== */
.small { font-size: .88rem; }
.mt { margin-top: 20px; }
.w-small { max-width: 130px; }
.w-tiny { max-width: 80px; }
.btn-pencil { background: var(--pencil); border-color: var(--pencil); color: var(--ink); }
.btn-pencil:hover { background: #F0B92A; color: var(--ink); }
.btn-danger { border-color: var(--wrong); color: var(--wrong); }
.btn-danger:hover { background: var(--wrong-bg); color: var(--wrong); }
.pill-pencil { background: var(--pencil-soft); color: #7A5A00; }
.count { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--wrong); color: #fff; font-size: .75rem; }
.up { color: var(--right); font-weight: 700; }
.down { color: var(--wrong); font-weight: 700; }
.empty-page { padding: 64px 0; }
.page-head { padding-top: 28px; }
.page-head h1 { margin-bottom: 6px; }
.block-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.block-head h2 { margin: 0; font-size: 1.7rem; }
.block-head a { font-weight: 700; }
.plain-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.todo { padding-left: 20px; }
.todo li { margin-bottom: 6px; }

/* ---------- top bar, menu ---------- */
.menu { display: block; }
.menu > summary { display: none; }
.menu > summary::-webkit-details-marker { display: none; }
.nav { gap: 20px; }
.usermenu { position: relative; }
.usermenu > summary { list-style: none; display: flex; align-items: center; gap: 8px; cursor: pointer; padding: 4px 10px 4px 4px; border: 2px solid var(--line); border-radius: 999px; font-weight: 700; }
.usermenu > summary::-webkit-details-marker { display: none; }
.usermenu > summary:hover, .usermenu[open] > summary { border-color: var(--ink); }
.um-pop { position: absolute; right: 0; top: calc(100% + 8px); width: 280px; background: var(--white); border: 2px solid var(--ink); border-radius: var(--r-md); box-shadow: 6px 6px 0 var(--pencil); padding: 8px; display: grid; z-index: 40; }
.um-head { display: flex; gap: 10px; align-items: center; padding: 8px; margin: 0 0 6px; border-bottom: 1px solid var(--line); font-size: .9rem; line-height: 1.35; word-break: break-word; }
.um-pop a, .um-pop button { display: block; padding: 9px 10px; border-radius: var(--r-sm); text-decoration: none; font: 700 .95rem var(--ui); color: var(--ink); background: none; border: 0; text-align: left; width: 100%; cursor: pointer; }
.um-pop a:hover, .um-pop button:hover { background: var(--pencil-soft); }
.um-pop form { margin: 0; }
.burger, .burger::before, .burger::after { display: block; width: 22px; height: 2.5px; background: var(--ink); border-radius: 2px; position: relative; }
.burger::before, .burger::after { content: ""; position: absolute; left: 0; }
.burger::before { top: -7px; } .burger::after { top: 7px; }

/* ---------- avatars ---------- */
.avatar { border-radius: 50%; object-fit: cover; flex: none; display: inline-grid; place-items: center; color: #fff; font-weight: 700; background: var(--ink-2); }
.av-sm { width: 30px; height: 30px; font-size: .8rem; }
.av-md { width: 44px; height: 44px; font-size: 1rem; }
.av-lg { width: 72px; height: 72px; font-size: 1.5rem; }
.av-xl { width: 104px; height: 104px; font-size: 2.2rem; border: 3px solid var(--white); box-shadow: 0 0 0 2px var(--ink); }
.who { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; }

/* ---------- footer (always at the bottom) ---------- */
.foot { flex-shrink: 0; background: var(--ink); color: #D8DEEE; font-size: .95rem; }
.foot a { color: #fff; text-decoration: none; }
.foot a:hover { color: var(--pencil); text-decoration: underline; }
.foot-grid { display: grid; grid-template-columns: 1.5fr 1fr 1fr 1fr; gap: 28px; padding: 40px 0 28px; }
.foot h2 { font: 600 1rem var(--display); color: var(--pencil); margin: 0 0 10px; }
.foot nav { display: grid; gap: 6px; align-content: start; }
.foot-brand p { margin: 12px 0 0; max-width: 34ch; }
.foot .logo-mark { border-color: #fff; }
.foot .logo-word { color: #fff; }
.foot .logo-word span { color: #AAB3CC; }
.foot-bottom { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; border-top: 1px solid rgba(255,255,255,.14); padding: 16px 0 22px; font-size: .85rem; }
.foot-bottom p { margin: 0; }
.foot .muted { color: #AAB3CC; }

/* ---------- landing ---------- */
.hero-in { min-height: min(560px, calc(100vh - 64px)); }
.hero-note { margin-top: 14px; color: var(--muted); font-size: .95rem; }
.levels { display: grid; grid-template-columns: 5fr 4fr 2.2fr 2.2fr; gap: 14px; }
.level { background: var(--white); border: 1px solid var(--line); border-radius: var(--r-md); padding: 18px; }
.level h3 { margin: 0 0 12px; }
.level h3 .si { font-size: .85rem; font-weight: 400; display: block; }
.level-grades { display: grid; grid-template-columns: repeat(var(--n, 4), minmax(0, 1fr)); gap: 8px; }
.level { padding: 16px 14px; }
.gtile { display: grid; justify-items: center; padding: 10px 6px; border: 2px solid var(--rule); border-radius: var(--r-md); text-decoration: none; background: var(--paper); transition: transform .12s, border-color .12s; }
.gtile:hover { border-color: var(--ink); transform: translateY(-2px); background: var(--pencil-soft); }
.gtile.mine { border-color: var(--ink); box-shadow: 3px 3px 0 var(--pencil); }
.gt-n { font: 800 1.9rem/1 var(--display); }
.gt-l { font-size: .75rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.gt-c { font-size: .75rem; color: var(--muted); margin-top: 2px; }
.lab-band { background: var(--white); border-block: 1px solid var(--line); margin-top: 48px; padding-bottom: 40px; }
.lab-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.lab-card { display: grid; gap: 4px; padding: 16px; border: 2px solid var(--ink); border-radius: var(--r-md); background: var(--white); text-decoration: none; transition: transform .12s, box-shadow .12s; }
.lab-card:hover { transform: translate(-2px, -2px); box-shadow: 6px 6px 0 var(--pencil); color: var(--ink); }
.lab-card .pill { justify-self: start; margin-top: 4px; }
.lab-art { height: 120px; border-radius: var(--r-sm); margin-bottom: 8px; background: var(--paper); border: 1px solid var(--line); position: relative; overflow: hidden; }
.lab-art-magnet { background:
  radial-gradient(ellipse 70% 60% at 50% 50%, transparent 38%, rgba(52,66,108,.25) 39%, transparent 41%, transparent 50%, rgba(52,66,108,.2) 51%, transparent 53%, transparent 64%, rgba(52,66,108,.15) 65%, transparent 67%),
  linear-gradient(90deg, transparent 30%, #2F6FD0 30% 50%, var(--wrong) 50% 70%, transparent 70%) center / 100% 28px no-repeat, var(--paper); }
.lab-art-reaction { background:
  radial-gradient(circle at 44% 58%, #fff 0 4px, transparent 5px), radial-gradient(circle at 56% 48%, #fff 0 3px, transparent 4px), radial-gradient(circle at 50% 70%, #fff 0 5px, transparent 6px),
  linear-gradient(to top, #4696E6 0 55%, transparent 55%) 50% 85% / 90px 90px no-repeat, var(--paper); }
.lab-art-reaction::after { content: ""; position: absolute; left: calc(50% - 48px); bottom: 12px; width: 90px; height: 92px; border: 3px solid var(--ink); border-top: 0; border-radius: 0 0 8px 8px; }
.lab-art-custom { background: repeating-linear-gradient(45deg, var(--paper) 0 12px, var(--pencil-soft) 12px 24px); }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; }
.split h2 { margin-top: 0; }

/* ---------- plans ---------- */
.plans { display: grid; grid-template-columns: repeat(2, minmax(0, 360px)); gap: 20px; }
.plan { background: var(--white); border: 2px solid var(--rule); border-radius: var(--r-md); padding: 24px; display: grid; gap: 10px; align-content: start; }
.plan h3 { margin: 0; font-size: 1.3rem; }
.plan-best { border-color: var(--ink); box-shadow: 8px 8px 0 var(--pencil); }
.plan-price { font: 800 2.4rem/1 var(--display); margin: 0; }
.plan-price small { font-size: 1rem; font-weight: 600; color: var(--muted); }
.plan ul { padding-left: 20px; margin: 0 0 8px; }
.plan li { margin-bottom: 4px; }
.bank-note { background: var(--pencil-soft); border-radius: var(--r-sm); padding: 14px 16px; margin-top: 16px; }
.paywall { padding: 56px 0; }
.paywall-cta { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- grade picker ---------- */
.grades { display: flex; gap: 6px; overflow-x: auto; padding: 8px 2px 12px; margin: 12px 0 0; scrollbar-width: thin; }
.gr { flex: none; display: grid; justify-items: center; min-width: 58px; padding: 6px 8px; border: 2px solid var(--rule); border-radius: var(--r-md); background: var(--white); text-decoration: none; font: 800 1.35rem/1.1 var(--display); }
.gr small { font: 700 .62rem var(--ui); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.gr:hover { border-color: var(--ink); }
.gr.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.gr.on small { color: var(--rule); }
.gr.mine:not(.on) { box-shadow: inset 0 -4px 0 var(--pencil); }
.gr:first-child { font-size: 1rem; align-content: center; }
.check-inline { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-size: .95rem; }
.papers-wrap { padding-top: 12px; }
.pr-tag { display: flex; align-items: center; }
.ad-li { list-style: none; }

/* ---------- result ---------- */
.score-card { grid-template-columns: 1.3fr 1fr; align-items: center; }
.score-row { display: flex; align-items: flex-end; gap: 22px; flex-wrap: wrap; }
.grade-badge { margin: 0 0 8px; display: grid; justify-items: center; width: 108px; padding: 8px 6px 10px; border-radius: var(--r-md); border: 3px solid currentColor; transform: rotate(-3deg); }
.grade-badge span { font: 800 3.4rem/1 var(--display); }
.grade-badge small { font-size: .74rem; font-weight: 700; text-align: center; }
.g-a { color: var(--right); } .g-b { color: #2F7D6D; } .g-c { color: #2F6FD0; } .g-s { color: #9A6B00; } .g-w { color: var(--wrong); }
.grade-badge.g-a { background: var(--right-bg); } .grade-badge.g-b { background: #E1F2EE; } .grade-badge.g-c { background: #E5EEFB; } .grade-badge.g-s { background: var(--pencil-soft); } .grade-badge.g-w { background: var(--wrong-bg); }
.score-chart { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.donut { width: 150px; height: 150px; flex: none; }
.donut circle { transition: stroke-dasharray .6s; }
.donut-big { font: 800 20px var(--display); fill: var(--ink); }
.donut-sub { font: 700 9px var(--ui); fill: var(--muted); }
.legend { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.legend li { display: flex; align-items: center; gap: 8px; }
.legend i { width: 14px; height: 14px; border-radius: 50%; display: inline-block; }
.legend b { margin-left: auto; padding-left: 12px; }
.k-ok { background: var(--right); } .k-bad { background: var(--wrong); } .k-blank { background: var(--rule); }
.score-compare { display: grid; gap: 6px; }
.score-compare p { display: grid; grid-template-columns: 120px 1fr 44px; align-items: center; gap: 10px; margin: 0; font-size: .95rem; }
.bar { display: block; height: 12px; border-radius: 999px; background: var(--line); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: inherit; background: var(--ink); }
.bar-you > span { background: var(--pencil); }
.bar-all > span { background: var(--ink-2); }
.bar-e1 > span { background: var(--right); } .bar-e2 > span { background: #2F7D6D; } .bar-e3 > span { background: #D39B00; } .bar-e4 > span { background: var(--wrong); }
.history { margin-top: 24px; }
.history h2 { margin-top: 0; }
.line-chart { width: 100%; height: auto; display: block; }
.line-chart .gl { stroke: var(--line); stroke-width: 1; }
.line-chart .gl-mark { stroke: var(--rule); stroke-dasharray: 5 5; stroke-width: 1.5; }
.line-chart .ln { fill: none; stroke: var(--ink); stroke-width: 3; stroke-linejoin: round; stroke-linecap: round; }
.line-chart .dot { stroke: #fff; stroke-width: 2; }
.line-chart .d-a { fill: var(--right); } .line-chart .d-p { fill: var(--ink); } .line-chart .d-w { fill: var(--wrong); }
.line-chart .ax { font: 11px var(--ui); fill: var(--muted); text-anchor: end; }
.line-chart .ax-l { text-anchor: start; } .line-chart .ax-r { text-anchor: end; }

/* ---------- profile ---------- */
.profile-head { display: flex; align-items: center; gap: 22px; padding: 28px 0 8px; flex-wrap: wrap; }
.profile-head h1 { margin: 0 0 4px; }
.profile-head p { margin: 0 0 8px; }
.stat-row div span { font-size: .85rem; }
.stat-6 { grid-template-columns: repeat(6, 1fr); }
.stat-6 dd { font-size: 1.6rem; }
.two-col { display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px; align-items: start; }
.two-col .card-flat h2 { margin-top: 0; }
.letter-bars { list-style: none; padding: 0; margin: 0 0 10px; display: grid; gap: 10px; }
.letter-bars li { display: grid; grid-template-columns: 34px 1fr 30px; align-items: center; gap: 10px; }
.gl-letter { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 7px; border: 2px solid currentColor; font: 800 .95rem var(--display); background: var(--white); }
.strength { display: grid; gap: 2px; background: var(--white); border: 1px solid var(--line); border-radius: var(--r-md); padding: 6px 16px; }
.str-row { display: grid; grid-template-columns: minmax(160px, 1.1fr) minmax(140px, 1fr) 2fr auto; gap: 14px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.str-row:last-child { border-bottom: 0; }
.str-name .si { display: block; font-size: .85rem; line-height: 1.3; }
.str-bar { display: grid; grid-template-columns: 1fr 44px; gap: 8px; align-items: center; }
.str-effort { font-size: .9rem; }
.str-meta { font-size: .82rem; white-space: nowrap; }
.strength.compact .str-row { grid-template-columns: 1fr 1fr auto; }
.effort-e1 { background: var(--right-bg); color: var(--right); }
.effort-e2 { background: #E1F2EE; color: #2F7D6D; }
.effort-e3 { background: var(--pencil-soft); color: #7A5A00; }
.effort-e4 { background: var(--wrong-bg); color: var(--wrong); }

/* ---------- account, tabs ---------- */
.tabs-line { border-bottom: 2px solid var(--line); gap: 0; margin: 12px 0 20px; flex-wrap: nowrap; overflow-x: auto; }
.tabs-line .tab { border: 0; border-radius: 0; background: none; color: var(--muted); padding: 10px 16px; text-decoration: none; border-bottom: 3px solid transparent; margin-bottom: -2px; white-space: nowrap; }
.tabs-line .tab.on { color: var(--ink); border-bottom-color: var(--ink); background: none; }
.avatar-edit { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.form hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; width: 100%; }
.otp-input { font: 800 2rem var(--display); letter-spacing: .4em; text-align: center; padding: 10px; }
.code-input { font: 800 1.4rem var(--display); letter-spacing: .25em; text-transform: uppercase; text-align: center; }

/* ---------- groups ---------- */
.invite { border: 2px solid var(--pencil); background: var(--pencil-soft); margin-bottom: 12px; }
.invite p { margin-bottom: 10px; }
.joincode { margin: 16px 0; display: grid; gap: 8px; }
.joincode-row { display: flex; gap: 8px; }
.joincode-row input { flex: 1; min-width: 0; }
.group-card { margin-top: 16px; }
.gc-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.gc-head h2 { margin: 0; }
.task-list { list-style: none; padding: 0; margin: 12px 0 0; }
.task-list li { display: grid; grid-template-columns: 1fr auto auto; gap: 12px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); }
.group-link { display: block; text-decoration: none; margin-bottom: 12px; transition: box-shadow .12s; }
.group-link:hover { box-shadow: 5px 5px 0 var(--pencil); border-color: var(--ink); }
.group-link h2 { margin: 0 0 4px; }
.group-link p { margin: 0 0 4px; }
.joinbox { display: grid; justify-items: end; margin: 0; }
.code-big { font: 800 1.8rem var(--display); letter-spacing: .15em; background: var(--pencil-soft); padding: 2px 12px; border-radius: var(--r-sm); }
.matrix td, .matrix th { text-align: center; white-space: nowrap; }
.matrix td:first-child, .matrix th:first-child { text-align: left; }
.matrix tfoot th { background: #F3F6FB; }
.mcell { text-decoration: none; font-weight: 700; display: inline-flex; gap: 6px; align-items: center; }
.narrow-form { max-width: 560px; }

/* ---------- lab ---------- */
.lab-intro { background: var(--pencil-soft); border-left: 5px solid var(--pencil); padding: 12px 16px; border-radius: var(--r-sm); max-width: 820px; margin-bottom: 16px; }
.lab-box { background: var(--white); border: 1px solid #e2e8f0; box-shadow: 0 1px 3px rgba(15,23,42,.06); border-radius: var(--r-md); padding: 14px; }
.lab-tools { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; }
.lab-select { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-size: .92rem; }
.lab-select select { padding: 5px 8px; }
.lab-msg { min-height: 2.8em; background: var(--paper); border-radius: var(--r-sm); padding: 8px 12px; margin: 0 0 10px; }
.lab-canvas { display: block; width: 100%; border: 1px solid var(--line); border-radius: var(--r-sm); touch-action: none; }
.lab-grid { display: grid; grid-template-columns: 260px auto 1fr; gap: 20px; align-items: start; }
.lab-controls { display: grid; gap: 12px; }
.lab-controls label { display: grid; gap: 4px; font-weight: 700; }
.lab-buttons { display: flex; gap: 8px; flex-wrap: wrap; }
.lab-beaker { width: auto; border: 0; }
.lab-result { background: var(--paper); border-radius: var(--r-md); padding: 16px; min-height: 200px; }
.lab-result h3 { margin: 0 0 6px; }
.lab-result h4 { margin: 12px 0 2px; font-size: .9rem; color: var(--muted); }
.lab-result p { margin: 0 0 6px; }
.lab-result .eq { font: 700 1.15rem var(--ui); }
.lab-safety { margin: 14px 0 0; padding: 10px 14px; background: var(--wrong-bg); border-radius: var(--r-sm); font-size: .92rem; }
.lab-frame { width: 100%; height: 640px; border: 2px solid var(--ink); border-radius: var(--r-md); background: #fff; }

/* ---------- rich text (editor output) ---------- */
.rich p { margin: 0 0 .7em; }
.rich p:last-child { margin-bottom: 0; }
.rich img { display: block; margin: 8px 0 12px; border: 1px solid var(--line); border-radius: var(--r-sm); }
.rich ol, .rich ul { padding-left: 1.5em; margin: 0 0 .7em; }
.rich li[data-list=bullet] { list-style-type: disc; }
.rich li[data-list=ordered] { list-style-type: decimal; }
.rich .ql-ui { display: none; }
.rich .ql-align-center { text-align: center; } .rich .ql-align-right { text-align: right; } .rich .ql-align-justify { text-align: justify; }
.rich .ql-align-center img { margin-inline: auto; }
.rich blockquote { margin: 0 0 .7em; padding: 6px 14px; border-left: 4px solid var(--pencil); background: var(--pencil-soft); }
.rich h2, .rich h3 { margin: .8em 0 .4em; }
.rich table { border-collapse: collapse; } .rich td, .rich th { border: 1px solid var(--rule); padding: 4px 8px; }

/* ---------- admin editor ---------- */
.editor-layout { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.field { display: grid; gap: 6px; }
.field-label { font-weight: 700; }
.field-label .muted { font-weight: 400; font-size: .88rem; }
.editor { background: var(--white); min-height: 150px; font-size: 1.05rem; }
.ql-toolbar.ql-snow { border: 2px solid var(--rule); border-radius: var(--r-sm) var(--r-sm) 0 0; background: #F3F6FB; }
.ql-container.ql-snow { border: 2px solid var(--rule); border-top: 0; border-radius: 0 0 var(--r-sm) var(--r-sm); font-family: var(--si); font-size: 1.05rem; }
.ql-editor { min-height: 150px; line-height: 1.75; }
.ql-editor img { max-width: 100%; }
.editor-actions { display: flex; gap: 10px; flex-wrap: wrap; position: sticky; bottom: 0; background: var(--paper); padding: 12px 0; border-top: 1px solid var(--line); }
.preview { position: sticky; top: 84px; max-height: calc(100vh - 100px); overflow: auto; }
.preview-label { font-weight: 700; color: var(--muted); font-size: .88rem; text-transform: uppercase; letter-spacing: .06em; margin: 0 0 8px; }
.opt-edit { grid-template-columns: 70px 1fr; }
.opt-edit .check { display: flex; align-items: center; gap: 6px; }
.gboxes { display: flex; flex-wrap: wrap; gap: 4px; }
.gboxes label { display: inline-flex; cursor: pointer; }
.gboxes input { position: absolute; opacity: 0; }
.gboxes span { display: grid; place-items: center; width: 30px; height: 30px; border: 2px solid var(--rule); border-radius: 50%; font-size: .8rem; font-weight: 700; background: var(--white); }
.gboxes input:checked + span { background: var(--ink); border-color: var(--ink); color: #fff; }
.gboxes input:focus-visible + span { outline: 3px solid var(--pencil); }
.subj-list { display: grid; gap: 8px; }
.subj-row { display: grid; grid-template-columns: 1fr 1fr 70px auto auto auto; gap: 10px; align-items: center; padding: 10px 14px; }
.users-table .grant { margin-top: 4px; }
.users-table .grant form { margin-top: 8px; min-width: 200px; }
tr.is-blocked td { opacity: .55; }
fieldset.card-flat { display: grid; gap: 12px; margin-bottom: 18px; border: 1px solid var(--line); }
fieldset.card-flat legend { font: 600 1.2rem var(--display); padding: 0 6px; }
fieldset.card-flat h3 { margin: 8px 0 0; }
.jump { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; font-weight: 700; }
.sticky-save { position: sticky; bottom: 0; background: var(--paper); padding: 12px 0; margin: 0; border-top: 1px solid var(--line); }
.page-editor .ad, .page-editor .foot { display: none; }

/* ---------- v2 responsive ---------- */
@media (max-width: 1100px) {
  .levels { grid-template-columns: 1fr 1fr; }
  .level-grades { grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); }
  .stat-6 { grid-template-columns: repeat(3, 1fr); }
  .lab-grid { grid-template-columns: 1fr 1fr; }
  .lab-result { grid-column: 1 / -1; }
  .str-row { grid-template-columns: 1fr 1fr; }
  .str-meta { white-space: normal; }
}
@media (max-width: 860px) {
  .menu { display: block; margin-left: auto; }
  .menu > summary { display: grid; place-items: center; width: 44px; height: 44px; border: 2px solid var(--line); border-radius: var(--r-sm); cursor: pointer; list-style: none; }
  .menu[open] > summary { border-color: var(--ink); }
  .menu .nav { position: absolute; left: 0; right: 0; top: 100%; background: var(--white); border-bottom: 2px solid var(--ink); flex-direction: column; align-items: stretch; gap: 0; padding: 8px 16px 16px; box-shadow: 0 12px 24px rgba(29,43,83,.12); }
  .menu .nav > a:not(.btn) { padding: 12px 4px; border-bottom: 1px solid var(--line); }
  .menu .nav > .btn { margin-top: 10px; }
  .topbar-in { position: relative; flex-wrap: nowrap; }
  .usermenu > summary { margin-top: 10px; justify-content: flex-start; }
  .um-pop { position: static; width: auto; box-shadow: none; margin-top: 8px; }
  .foot-grid { grid-template-columns: 1fr 1fr; }
  .foot-brand { grid-column: 1 / -1; }
  .split, .two-col, .editor-layout { grid-template-columns: 1fr; }
  .preview { position: static; max-height: none; }
  .plans { grid-template-columns: 1fr; }
  .subj-row { grid-template-columns: 1fr 1fr; }
  .hero-in { min-height: 0; }
}
@media (max-width: 600px) {
  .levels { grid-template-columns: 1fr; }
  .stat-row, .stat-6 { grid-template-columns: 1fr 1fr; }
  .score-compare p { grid-template-columns: 90px 1fr 40px; }
  .task-list li { grid-template-columns: 1fr auto; }
  .task-list li .btn { grid-column: 1 / -1; justify-self: start; }
  .lab-grid { grid-template-columns: 1fr; }
  .lab-beaker { justify-self: center; }
  .str-row { grid-template-columns: 1fr; gap: 6px; }
  .foot-grid { grid-template-columns: 1fr; }
  .grade-badge { width: 92px; }
  .grade-badge span { font-size: 2.8rem; }
  .joinbox { justify-items: start; }
  .paper-row .pr-tag { grid-column: 2; }
}

/* ---------- print (mark sheet) ---------- */
@media print {
  .topbar, .foot, .ad, .score-actions, .review-head .tabs, .solve-link, .skip, .crumbs { display: none !important; }
  body { background: #fff; display: block; }
  .score-card { box-shadow: none; }
  .q { break-inside: avoid; }
  .q-review[hidden] { display: grid !important; }
}


/* =====================================================================
   v2.1 — logo, text size, sidebars, groups, rankings, alarms
   ===================================================================== */
:root { --brand: #1A6FE6; --navy: #0B2A5B; }
.logo-img { height: 44px; width: auto; display: block; }
.topbar-in { gap: 12px; }
.foot { background: var(--navy); }
.foot-logo { display: inline-flex; align-items: center; gap: 10px; }
.foot-logo img { width: 44px; height: 44px; background: #fff; border-radius: 10px; padding: 3px; }

/* ---------- layout with sidebar ---------- */
.with-side { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 28px; align-items: start; padding-top: 16px; }
.with-side.side-right { grid-template-columns: minmax(0, 1fr) 300px; }
.with-side.side-right > .side { order: 2; }
.side { display: grid; gap: 14px; align-content: start; min-width: 0; }
.side .ad { width: 100%; margin: 0; }
.side-card { background: var(--white); border: 1px solid var(--line); border-radius: var(--r-md); padding: 16px; display: grid; gap: 8px; }
.side-label { font: 700 .78rem var(--ui); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0; cursor: default; }
details.side-card > summary { cursor: pointer; list-style: none; }
details.side-card > summary::after { content: "+"; float: right; font-weight: 800; }
details.side-card[open] > summary::after { content: "−"; }
details.side-card[open] > summary { margin-bottom: 8px; }
.filters-side input:not([type=checkbox]), .filters-side select { width: 100%; }
.filters-side .check-inline { font-weight: 400; margin: 4px 0; }
.filters-side .check-inline input { width: 18px; height: 18px; }
.side-reset { font-size: .9rem; text-align: center; }
.side-list { gap: 2px; padding: 10px; }
.side-list .side-label { padding: 4px 8px 6px; }
.side-list a { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding: 7px 10px; border-radius: var(--r-sm); text-decoration: none; font-weight: 700; font-size: .95rem; }
.side-list a small { font-weight: 400; color: var(--muted); font-size: .78rem; text-align: right; }
.side-list a:hover { background: var(--pencil-soft); }
.side-list a.on { background: var(--ink); color: #fff; }
.side-list a.on small { color: var(--rule); }
.side-user { display: flex; gap: 10px; align-items: center; padding: 6px 8px 12px; margin-bottom: 4px; border-bottom: 1px solid var(--line); word-break: break-word; }
.main-col { min-width: 0; }
.narrow-col { max-width: 760px; }
.result-count { margin: 0 0 8px; font-size: .92rem; }
.page-head + .with-side { padding-top: 8px; }

/* ---------- profile sidebar ---------- */
.profile-card { justify-items: center; text-align: center; }
.profile-card h1 { font-size: 1.4rem; margin: 6px 0 0; }
.facts { width: 100%; margin: 6px 0; display: grid; gap: 0; text-align: left; }
.facts div { display: flex; justify-content: space-between; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: .92rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-weight: 700; text-align: right; }

/* ---------- alarms ---------- */
.alarm-info { margin: 12px 0 0; color: var(--muted); }
.alarm-toast { position: fixed; left: 50%; top: 78px; pointer-events: none; transform: translateX(-50%); z-index: 60; background: var(--pencil); color: var(--ink); border: 2px solid var(--ink);
  border-radius: 999px; padding: 12px 22px; font: 800 1.1rem var(--ui); box-shadow: 0 10px 30px rgba(11,42,91,.3); animation: alarm-pop .4s ease; max-width: calc(100% - 24px); text-align: center; }
.alarm-toast.final { background: var(--wrong); color: #fff; }
@keyframes alarm-pop { 0% { transform: translateX(-50%) scale(.8); } 60% { transform: translateX(-50%) scale(1.06); } 100% { transform: translateX(-50%) scale(1); } }
.sheet .ad { margin-top: 14px; width: 100%; }

/* ---------- editor image tools ---------- */
.img-tools { position: absolute; z-index: 50; display: flex; flex-wrap: wrap; align-items: center; gap: 4px; background: var(--ink); color: #fff; padding: 6px 8px; border-radius: 10px; box-shadow: 0 8px 20px rgba(0,0,0,.25); }
.img-tools button { border: 0; background: rgba(255,255,255,.12); color: #fff; font: 700 .85rem var(--ui); min-width: 30px; height: 28px; border-radius: 6px; cursor: pointer; }
.img-tools button:hover { background: var(--pencil); color: var(--ink); }
.img-tools input { width: 70px; height: 28px; padding: 2px 6px; font-size: .85rem; border: 0; border-radius: 6px; }
.it-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; opacity: .7; margin: 0 2px 0 6px; }
.ql-editor img.img-selected { outline: 3px solid var(--pencil); outline-offset: 2px; }
.ql-editor img { cursor: pointer; }
.rich img[width] { height: auto; }
.rich .ql-align-right img, .ql-editor .ql-align-right img { margin-left: auto; margin-right: 0; }
.ql-editor .ql-align-center img { display: block; margin-inline: auto; }

/* ---------- groups ---------- */
.group-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.gcard { display: grid; grid-template-rows: auto 1fr; border: 2px solid var(--line); border-radius: var(--r-md); overflow: hidden; background: var(--white); text-decoration: none; transition: transform .12s, box-shadow .12s, border-color .12s; }
.gcard:hover { transform: translateY(-2px); border-color: var(--ink); box-shadow: 6px 6px 0 var(--pencil); color: var(--ink); }
.gcard-img { display: block; height: 120px; background-size: cover; background-position: center; position: relative; }
.gcard-img .pill { position: absolute; left: 12px; top: 12px; }
.gcard-body { display: grid; gap: 6px; padding: 14px 16px 16px; align-content: start; }
.gcard-body .pill { justify-self: start; }
.gcard-name { font: 700 1.2rem var(--display); }
.gcard-owner { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: .92rem; }
.gcard-meta { font-size: .88rem; }
.create-group .form { gap: 10px; }
.group-hero { background-size: cover; background-position: center; color: #fff; padding: 4px 0 28px; }
.group-hero .crumbs a, .group-hero .crumbs { color: rgba(255,255,255,.8); }
.group-hero h1 { margin: 10px 0 4px; font-size: clamp(1.8rem, 4vw, 2.8rem); }
.group-hero p { margin: 0 0 12px; opacity: .9; }
.owner-head { display: flex; gap: 12px; align-items: center; }
.member-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; max-height: 280px; overflow: auto; }
.member-list li { display: flex; align-items: center; gap: 8px; font-size: .92rem; }
.side .code-big { display: inline-block; justify-self: start; margin: 0; }
.rank-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 4px; }
.rank-list li { display: grid; grid-template-columns: 40px 30px 1fr auto 64px; gap: 10px; align-items: center; padding: 8px 10px; border-radius: var(--r-sm); }
.rank-list li:nth-child(odd) { background: var(--paper); }
.rank-list li.me, .rank-table tr.me td { background: var(--pencil-soft); }
.rk { font: 800 1.1rem var(--display); text-align: center; }
.rk-name { font-weight: 700; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rk-meta { font-size: .85rem; }
.rk-score { font: 800 1.2rem var(--display); text-align: right; }
.gpaper { margin-bottom: 12px; }
.gp-head { display: flex; justify-content: space-between; gap: 12px; align-items: center; flex-wrap: wrap; }
.gp-head h3 { margin: 0 0 2px; }
.gp-head p { margin: 0; }
.gp-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.gp-rank { margin-top: 12px; }
.gp-rank > summary { cursor: pointer; font-weight: 700; color: var(--brand); }
.gp-rank .table-wrap { margin-top: 10px; }
.rank-table td.rk { width: 48px; }
.group-img-edit { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.group-img-edit .gcard-img { width: 220px; height: 90px; border-radius: var(--r-sm); }
.bar-chart .bc { fill: var(--ink); }
.bar-chart .bc-a { fill: var(--right); } .bar-chart .bc-c { fill: #2F6FD0; } .bar-chart .bc-s { fill: #D39B00; } .bar-chart .bc-w { fill: var(--wrong); }
.bar-chart .bv { font: 700 11px var(--ui); fill: var(--ink); text-anchor: middle; }
.bar-chart .bl { font: 10px var(--ui); fill: var(--muted); text-anchor: middle; }

/* ---------- contact & legal ---------- */
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.contact-card p { margin: 0; display: flex; gap: 8px; align-items: baseline; word-break: break-word; }
.ci { width: 22px; flex: none; text-align: center; }
.legal { padding: 28px 32px; }
.legal h2 { font-size: 1.2rem; margin: 1.4em 0 .4em; }
.legal ul { padding-left: 1.3em; }
.legal li { margin-bottom: 6px; }
.legal > p.si:first-child { background: var(--pencil-soft); padding: 12px 16px; border-radius: var(--r-sm); }
.msg { margin-bottom: 12px; border-left: 5px solid var(--brand); }
.msg.is-read { border-left-color: var(--line); opacity: .85; }
.msg-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.msg-body { margin: 10px 0 0; }

@media (max-width: 960px) {
  .with-side, .with-side.side-right { grid-template-columns: 1fr; }
  .with-side.side-right > .side { order: 0; }
  .side { position: static; max-height: none; overflow: visible; }
  .side-list { max-height: 260px; overflow: auto; }
  .side .ad { display: none; } /* phones: top, between and footer ads still show */
}
@media (max-width: 860px) {
    .menu { margin-left: 0; }
  .logo-img { height: 36px; }
}
@media (max-width: 640px) {
  .group-grid { grid-template-columns: 1fr; }
  .rank-list li { grid-template-columns: 34px 30px 1fr 56px; }
  .rk-meta { display: none; }
    .legal { padding: 18px; }
}
@media print { .fs-control, .side, .alarm-toast { display: none !important; } .with-side { display: block; } }
.side .joincode-row input { min-width: 0; width: 100%; letter-spacing: .12em; font-size: 1.1rem; }
.side .joincode-row .btn { flex: none; }

/* =====================================================================
   v2.2 — plans, checkout, slips, donations, admin sidebar, dashboard
   ===================================================================== */
.plan-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.plan-card { position: relative; display: grid; gap: 6px; align-content: start; padding: 22px 20px; border: 2px solid var(--line); border-radius: var(--r-md); background: var(--white); text-decoration: none; transition: border-color .12s, transform .12s, box-shadow .12s; }
a.plan-card:hover { border-color: var(--ink); transform: translateY(-2px); color: var(--ink); }
.plan-card.popular { border-color: var(--brand); }
.plan-card.on { border-color: var(--ink); box-shadow: 8px 8px 0 var(--pencil); }
.plan-card ul { padding-left: 18px; margin: 6px 0; font-size: .92rem; }
.plan-card .btn { justify-self: start; margin-top: 6px; }
.pc-badge { position: absolute; top: -12px; right: 14px; background: var(--brand); color: #fff; font: 700 .75rem var(--ui); padding: 3px 10px; border-radius: 999px; }
.pc-name { font: 700 1.15rem var(--display); }
.pc-price { font: 800 2.1rem/1.1 var(--display); }
.pc-desc { color: var(--right); font-weight: 700; font-size: .92rem; }
.checkout { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 20px; margin-top: 28px; align-items: start; scroll-margin-top: 90px; }
.co-summary h2, .pay-method h2 { margin-top: 0; font-size: 1.2rem; }
.co-lines { margin: 0 0 14px; }
.co-lines div { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.co-lines dd { margin: 0; font-weight: 700; white-space: nowrap; }
.co-disc { color: var(--right); }
.co-total { font: 800 1.3rem var(--display); border-bottom: 0 !important; }
.coupon-form { display: grid; gap: 6px; }
.coupon-form input { text-transform: uppercase; letter-spacing: .08em; min-width: 0; flex: 1; }
.field-err { color: var(--wrong); font-weight: 700; margin: 0; font-size: .92rem; }
.field-ok { color: var(--right); font-weight: 700; margin: 0; font-size: .92rem; }
.co-methods { display: grid; gap: 16px; }
.bank-details { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 8px 16px; background: var(--paper); border: 1px dashed var(--rule); border-radius: var(--r-sm); padding: 12px 14px; margin: 4px 0; }
.bank-details dt { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.bank-details dd { margin: 0; font-weight: 700; font-size: 1.05rem; word-break: break-word; }
.amount-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.amount-chips label { cursor: pointer; }
.amount-chips input { position: absolute; opacity: 0; }
.amount-chips span { display: inline-block; padding: 8px 16px; border: 2px solid var(--rule); border-radius: 999px; font-weight: 700; background: var(--white); }
.amount-chips input:checked + span { background: var(--ink); border-color: var(--ink); color: #fff; }
.amount-chips input:focus-visible + span { outline: 3px solid var(--pencil); }
.pay-choice { display: flex; gap: 10px; flex-wrap: wrap; }
.bank-box { border: 1px solid var(--line); border-radius: var(--r-sm); padding: 12px 14px; display: grid; gap: 10px; }
.bank-box > summary { cursor: pointer; font-weight: 700; }
.bank-box[open] { gap: 12px; }
.donate-total { font: 800 1.8rem var(--display); margin: 0; display: grid; }
.donate-total small { font: 400 .85rem var(--ui); color: var(--muted); }
.donor-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.slip-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); gap: 16px; }
.slip-card { display: grid; grid-template-columns: 150px 1fr; gap: 16px; }
.slip-thumb { display: grid; place-items: center; background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-sm); min-height: 150px; overflow: hidden; text-decoration: none; }
.slip-thumb img { width: 100%; height: 170px; object-fit: cover; }
.slip-pdf { font: 800 1.1rem var(--display); text-align: center; }
.slip-info p { margin: 0 0 6px; }
.slip-amount { font: 800 1.5rem var(--display); }
.slip-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-start; margin-top: 8px; }
.slip-actions details { display: grid; gap: 6px; }
.slip-actions details summary { list-style: none; }
.slip-actions details[open] { flex-basis: 100%; }
.tag-form { display: flex; gap: 6px; margin-top: 6px; }
.tag-form input { font-size: .82rem; padding: 3px 6px; width: 150px; }

/* ---------- admin shell ---------- */
.admin-shell { display: grid; grid-template-columns: 230px minmax(0, 1fr); flex: 1 0 auto; width: 100%; }
.admin-nav { background: var(--navy); color: #fff; padding: 14px 10px 24px; }
.admin-nav .an-wrap > summary { display: none; }
.an-group { font: 700 .7rem var(--ui); letter-spacing: .08em; text-transform: uppercase; color: #8FA2CC; margin: 16px 10px 6px; }
.an-group:first-of-type { margin-top: 4px; }
.admin-nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; color: #E6ECF8; text-decoration: none; border-radius: 8px; font-weight: 700; font-size: .95rem; }
.admin-nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.admin-nav a.on { background: var(--pencil); color: var(--ink); }
.admin-nav .count { margin-left: auto; }
.an-ic { width: 22px; text-align: center; }
.admin-main { padding: 8px 28px 56px; min-width: 0; background: var(--paper); }
.admin-main .wrap, .admin-main .narrow { width: 100%; max-width: 1200px; margin-inline: 0; }
.admin-main .narrow { max-width: 820px; }
.admin-main > .admin-title:first-child, .admin-main > .wrap:first-child .admin-title { margin-top: 20px; }
.dash-filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 12px 16px; margin: 16px 0; }
.seg { display: inline-flex; border: 2px solid var(--line); border-radius: 999px; overflow: hidden; }
.seg a { padding: 6px 14px; text-decoration: none; font-weight: 700; font-size: .9rem; }
.seg a + a { border-left: 1px solid var(--line); }
.seg a.on { background: var(--ink); color: #fff; }
.todo-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 12px; }
.todo-chip { padding: 6px 14px; border-radius: 999px; background: var(--white); border: 1px solid var(--line); text-decoration: none; font-weight: 700; font-size: .9rem; }
.todo-chip.warn { background: var(--pencil-soft); border-color: var(--pencil); }
.todo-chip.bad { background: var(--wrong-bg); border-color: var(--wrong); color: var(--wrong); }
.kpis dd a { text-decoration: none; }
.dash-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.dash-grid .span2 { grid-column: span 2; }
.dash-grid h2 { margin: 0 0 10px; font-size: 1.1rem; }
.series .bc { fill: var(--brand); }
.hbars { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.hbars li { display: grid; grid-template-columns: minmax(80px, 38%) 1fr 44px; gap: 8px; align-items: center; font-size: .9rem; }
.hb-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbars b { text-align: right; }
.hbars .bar > span { background: var(--brand); }
.recent-list { max-height: none; }
.admin-nav + .admin-main .flash { margin-top: 16px; }
@media (max-width: 1100px) { .dash-grid { grid-template-columns: 1fr 1fr; } .checkout { grid-template-columns: 1fr; } }
@media (max-width: 860px) {
  .admin-shell { grid-template-columns: 1fr; }
  .admin-nav { padding: 8px 12px; }
  .admin-nav .an-wrap > summary { display: block; cursor: pointer; font-weight: 700; padding: 8px 4px; }
  .admin-main { padding: 8px 14px 40px; }
  .dash-grid { grid-template-columns: 1fr; } .dash-grid .span2 { grid-column: auto; }
  .slip-grid { grid-template-columns: 1fr; } .slip-card { grid-template-columns: 110px 1fr; }
}
/* Sinhala text needs a little more line height */
html[lang=si] body { font-family: var(--si); }
html[lang=si] h1, html[lang=si] h2, html[lang=si] h3 { font-family: var(--display); line-height: 1.3; letter-spacing: 0; }
html[lang=si] .hero h1 { line-height: 1.2; font-size: clamp(1.9rem, 4.2vw, 3rem); max-width: 20ch; }
html[lang=si] .btn, html[lang=si] .chip, html[lang=si] .tab { font-family: var(--si); }
.lang-switch + 
.coupon-form .joincode-row input { min-width: 0; width: 100%; }
.coupon-form .joincode-row .btn { flex: none; }

/* ---------- v3.0: pages, layouts, AI import, solutions ---------- */
.frac { display: inline-flex; flex-direction: column; vertical-align: middle; text-align: center; line-height: 1; font-size: .85em; margin: 0 .15em; }
.frac > span:first-child { border-bottom: 1px solid currentColor; padding-bottom: 1px; }
.frac > span:last-child { padding-top: 1px; }
.exam-page[hidden] { display: none !important; }
.page-label { font-size: .8rem; font-weight: 700; color: var(--muted); margin: 0 0 10px; }
.page-nav { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 8px 0 24px; }
.pages-rows { list-style: none; padding: 0; margin: 0 0 10px; display: grid; gap: 6px; }
.pages-rows li { display: flex; align-items: center; gap: 10px; }
.pages-rows li > span:first-child { min-width: 64px; font-weight: 600; font-size: .9rem; }
.pages-rows input { width: 90px; }
.pages-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pages-actions input { width: 80px; }
.layout-editor { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 20px; align-items: start; }
.layout-editor textarea.code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; line-height: 1.5; white-space: pre; tab-size: 2; }
.layout-preview { position: sticky; top: 84px; background: #fff; border: 1px solid #e2e8f0; border-radius: 12px; overflow: hidden; }
.lp-prev-bar { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid #e2e8f0; flex-wrap: wrap; }
.lp-prev-tabs { margin-left: auto; display: flex; gap: 4px; }
#lp-frame { width: 100%; height: calc(100vh - 170px); min-height: 480px; border: 0; background: #f1f5f9; display: block; }
.token-list { list-style: none; padding: 0; margin: 8px 0 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 4px 14px; }
@media (max-width: 1100px) { .layout-editor { grid-template-columns: 1fr; } .layout-preview { position: static; } }
.ai-step { margin-top: 18px; }
.ai-progress { height: 10px; background: #e2e8f0; border-radius: 99px; overflow: hidden; margin: 6px 0 10px; }
.ai-progress span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #0284c7, #7c3aed); transition: width .4s; }
.ai-actions { display: flex; gap: 8px; margin-top: 14px; }
.sol-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 12px; }
.sol-inline { margin: 12px 0 0; }
.sol-dialog { width: min(760px, 94vw); max-height: 86vh; }
.sol-dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.sol-dialog-head h2 { margin: 0; }
.sol-dialog-body { overflow: auto; max-height: 60vh; margin: 12px 0; }
.layout-editor > * { min-width: 0; }
.layout-editor input, .layout-editor textarea, .layout-editor select { max-width: 100%; box-sizing: border-box; }
.layout-editor .grid2 > * { min-width: 0; }

/* ---------- v3.1: answer layouts in the normal look, two statements, intros ---------- */
.opts-grid2, .opts-pics2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.opts-grid3, .opts-pics3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.opts-grid4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.opts-row, .opts-pics5 { grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); }
.opts-nums { display: flex; flex-wrap: wrap; gap: 8px; }
.opts-nums .opt-text { display: none; }
.opts-review.opts-nums { display: grid; grid-template-columns: 1fr; }
.opts-review.opts-nums .opt-text { display: inline; }
.opts-pics2 .opt, .opts-pics3 .opt, .opts-pics5 .opt { flex-direction: column; text-align: center; }
.opt-text img { max-width: 100%; max-height: 220px; height: auto; display: block; margin: 0 auto 4px; }
.q-intro { background: #f8fafc; border: 1px solid #cbd5e1; border-radius: 8px; padding: 10px 14px; margin-bottom: 12px; font-size: .92rem; }
.q-intro table { border-collapse: collapse; } .q-intro td, .q-intro th { border: 1px solid #94a3b8; padding: 3px 8px; }
.q-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.q-pair > div { border: 1px solid #cbd5e1; border-radius: 8px; padding: 10px 12px; }
.q-pair-l { display: block; font-size: .72rem; font-weight: 700; color: #64748b; margin-bottom: 4px; }
@media (max-width: 640px) { .q-pair { grid-template-columns: 1fr; } .opts-grid3, .opts-grid4, .opts-pics3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.xs-list.xs-float { position: fixed; margin: 0; z-index: 90; }
/* v3.5: visitors can look at a paper */
.guest-bar { max-width: 1280px; margin: 12px auto 0; padding: 12px 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; background: #fffbeb; border: 1px solid #fde68a; border-radius: 12px; color: #78350f; font-size: 14px; }
.guest-bar-btns { display: flex; gap: 8px; }
.is-guest .lp-opt, .is-guest .opt { cursor: not-allowed; opacity: .85; }
@media (max-width: 1312px) { .guest-bar { margin: 12px 16px 0; } }
.guest-bar.is-ping { animation: guest-ping .9s ease-out; }
@keyframes guest-ping { 0% { box-shadow: 0 0 0 0 rgba(245, 158, 11, .7); } 100% { box-shadow: 0 0 0 14px rgba(245, 158, 11, 0); } }

/* v4.1: paper page preview (all parts of the paper in one viewer) */
.pv-dialog { width: min(1280px, 100vw - 24px); height: min(92vh, 1100px); max-width: none; max-height: none; padding: 0; border: 0; border-radius: 18px; background: #0f172a; overflow: hidden; box-shadow: 0 30px 80px -20px rgba(0,0,0,.6); }
.pv-dialog[open] { display: flex; flex-direction: column; }
.pv-dialog::backdrop { background: rgba(2, 6, 23, .72); backdrop-filter: blur(3px); }
.pv-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; background: #0f172a; color: #e2e8f0; flex-wrap: wrap; }
.pv-tabs { display: flex; gap: 6px; overflow-x: auto; }
.pv-tabs button { font: 600 13px/1.2 Inter, "Noto Sans Sinhala", sans-serif; padding: 9px 14px; border-radius: 10px; border: 1px solid rgba(255,255,255,.12); background: transparent; color: #cbd5e1; cursor: pointer; white-space: nowrap; }
.pv-tabs button:hover { background: rgba(255,255,255,.06); color: #fff; }
.pv-tabs button[aria-selected="true"] { background: #2563eb; border-color: #2563eb; color: #fff; }
.pv-actions { display: flex; align-items: center; gap: 6px; }
.pv-actions a, .pv-actions button { display: inline-flex; align-items: center; gap: 6px; font: 600 13px/1 Inter, sans-serif; padding: 9px 12px; border-radius: 10px; color: #e2e8f0; background: rgba(255,255,255,.06); border: 0; cursor: pointer; text-decoration: none; }
.pv-actions a:hover, .pv-actions button:hover { background: rgba(255,255,255,.14); color: #fff; }
.pv-body { flex: 1; min-height: 0; background: #334155; display: flex; align-items: center; justify-content: center; overflow: auto; }
.pv-body iframe { width: 100%; height: 100%; border: 0; background: #fff; }
.pv-body img { max-width: 100%; height: auto; display: block; margin: auto; background: #fff; }
@media (max-width: 640px) { .pv-dialog { width: 100vw; height: 100dvh; border-radius: 0; } .pv-actions span { display: none; } }

/* v4.1: Science lab hero (dark grid, full width under the header) */
.lab-hero { position: relative; overflow: hidden; background-color: #0b132b; background-image: linear-gradient(to right, rgba(255,255,255,.06) 1px, transparent 1px), linear-gradient(to bottom, rgba(255,255,255,.06) 1px, transparent 1px); background-size: 32px 32px; border-bottom: 1px solid rgba(30,58,138,.4); color: #fff; }
.lab-hero .lh-orb { pointer-events: none; position: absolute; top: -3rem; right: -3rem; width: 16rem; height: 16rem; border-radius: 9999px; background: rgba(219,225,255,.4); filter: blur(64px); }
/* hero search bar (Lab, Activity, Dhamma): dark at rest, white while you type */
.hero-search input.lh-search { background: transparent !important; border: 0 !important; box-shadow: none !important; color: #fff; min-width: 0; margin: 0; padding-left: 0; padding-right: 0; }
.hero-search input.lh-search::placeholder { color: #94a3b8; }
.hero-search:focus-within { background: #fff; border-color: #fff; box-shadow: 0 0 0 4px rgba(245,158,11,.25); }
.hero-search:focus-within input.lh-search { color: #0f172a; }
.hero-search:focus-within input.lh-search::placeholder { color: #94a3b8; }
.hero-search:focus-within .hs-icon { color: #64748b; }
.hero-search:focus-within button[type="submit"] { background: #0f172a; color: #fff; }
/* no blue autofill box inside the bar */
.hero-search input.lh-search:-webkit-autofill, .hero-search input.lh-search:-webkit-autofill:hover, .hero-search input.lh-search:-webkit-autofill:focus { -webkit-text-fill-color: #0f172a; -webkit-box-shadow: 0 0 0 40px #fff inset !important; caret-color: #0f172a; border-radius: 8px; }
.hero-search input.lh-search::-webkit-search-cancel-button { filter: invert(.5); }
/* Activity (Explore and learn) hero: dark blueprint with dots, full width under the header */
.act-hero { position: relative; overflow: hidden; background: #0f172a; color: #fff; }
.act-hero .ah-dots { position: absolute; inset: 0; pointer-events: none; opacity: .09; background-image: radial-gradient(circle at 1px 1px, #fff 1px, transparent 0); background-size: 32px 32px; }
.act-hero .ah-glow1 { position: absolute; top: -6rem; left: -6rem; width: 24rem; height: 24rem; border-radius: 9999px; background: rgba(254,147,44,.15); filter: blur(64px); pointer-events: none; }
.act-hero .ah-glow2 { position: absolute; bottom: -6rem; right: 25%; width: 24rem; height: 24rem; border-radius: 9999px; background: rgba(0,74,198,.2); filter: blur(64px); pointer-events: none; }

/* v4.1: one width for the header, every page, every hero and the footer: 1280px of content */
.site-w { width: 100%; max-width: 1344px; margin-inline: auto; padding-inline: 16px; box-sizing: border-box; }
@media (min-width: 640px) { .site-w { padding-inline: 24px; } }
@media (min-width: 1024px) { .site-w { padding-inline: 32px; } }
/* Olympiad hero: navy blueprint grid, full width */
.oly-hero { background-color: #0b132b; background-image: linear-gradient(to right, rgba(255,255,255,.06) 1px, transparent 1px), linear-gradient(to bottom, rgba(255,255,255,.06) 1px, transparent 1px); background-size: 32px 32px; }
/* All papers hero: blueprint with dots */
.papers-hero { background-color: #0b132b; background-image: linear-gradient(to right, rgba(255,255,255,.06) 1px, transparent 1px), linear-gradient(to bottom, rgba(255,255,255,.06) 1px, transparent 1px); background-size: 24px 24px, 48px 48px, 48px 48px; }
/* Paper page title band */
.pv-head { background: linear-gradient(90deg, #fff7e6 0%, #ffffff 42%, #f4f7ff 100%); }
/* Support us page hero */
.support-hero { background: radial-gradient(circle at 85% 20%, rgba(255,255,255,.12), transparent 40%), linear-gradient(120deg, #9f1239 0%, #be123c 45%, #dc2626 100%); }
/* Admin > Paper settings: the three paper page card texts */
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.grid-3 .stack { display: grid; gap: 8px; align-content: start; }
@media (max-width: 900px) { .grid-3 { grid-template-columns: 1fr; } }
/* IQ test hero */
.iq-hero { background-color: #0b132b; background-image: radial-gradient(rgba(59,130,246,.12) 1px, transparent 1px), linear-gradient(to right, rgba(255,255,255,.03) 1px, transparent 1px), linear-gradient(to bottom, rgba(255,255,255,.03) 1px, transparent 1px); background-size: 24px 24px, 48px 48px, 48px 48px; }
.iq-q[hidden] { display: none !important; }
/* "Type DELETE" confirmation window (assets/app.js) */
.ep-del-dlg { border: 0; padding: 0; border-radius: 18px; width: min(420px, calc(100vw - 32px)); box-shadow: 0 30px 80px -20px rgba(15,23,42,.45); }
.ep-del-dlg::backdrop { background: rgba(15,23,42,.55); backdrop-filter: blur(2px); }
.ep-del-box { padding: 24px; display: grid; gap: 12px; margin: 0; font-family: Inter, "Noto Sans Sinhala", system-ui, sans-serif; }
.ep-del-ic { width: 44px; height: 44px; border-radius: 12px; background: #fee2e2; color: #b91c1c; display: grid; place-items: center; font: 800 22px/1 Inter, sans-serif; }
.ep-del-box h2 { margin: 0; font-size: 18px; font-weight: 800; color: #0f172a; }
.ep-del-msg { margin: 0; font-size: 14px; color: #475569; }
.ep-del-box label { display: grid; gap: 6px; font-size: 13px; color: #334155; }
.ep-del-in { border: 1px solid #cbd5e1; border-radius: 10px; padding: 10px 12px; font: 600 15px/1.2 Inter, sans-serif; letter-spacing: .08em; text-transform: uppercase; }
.ep-del-in:focus { outline: none; border-color: #dc2626; box-shadow: 0 0 0 4px rgba(220,38,38,.15); }
.ep-del-row { display: flex; justify-content: flex-end; gap: 8px; padding-top: 4px; }
.ep-del-row button { border: 0; border-radius: 10px; padding: 10px 16px; font: 700 14px/1 Inter, sans-serif; cursor: pointer; }
.ep-del-no { background: #f1f5f9; color: #334155; }
.ep-del-yes { background: #dc2626; color: #fff; }
.ep-del-yes:disabled { background: #fca5a5; cursor: not-allowed; }

/* ad boxes: a light card with the "Advertisement" label (inc/ads.php ad_wrap) */
.ad:not(.ad-preview) { background: #fff; border: 1px solid #e2e8f0; border-radius: 16px; padding: 10px 12px 12px; box-shadow: 0 1px 2px rgba(15,23,42,.04); }
.ad-label { text-transform: uppercase; letter-spacing: .08em; font-weight: 600; font-size: .66rem; color: #94a3b8; }
aside .ad, .side .ad { width: 100%; }
.site-w > .ad { width: 100%; margin-left: 0; margin-right: 0; }

/* lab: full screen button (activity.php) */
.lab-wrap { position: relative; }
.lab-tools-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.lab-fs-title { display: none; font-weight: 800; color: #0f172a; font-size: 1rem; }
.lab-fs-btn { display: inline-flex; align-items: center; gap: 8px; margin-left: auto; padding: 8px 14px; border-radius: 12px; border: 1px solid #e2e8f0; background: #fff; color: #0f172a; font-weight: 700; font-size: .85rem; cursor: pointer; box-shadow: 0 1px 2px rgba(15,23,42,.05); }
.lab-fs-btn:hover { background: #f8fafc; border-color: #cbd5e1; }
.lab-fs-btn > span { display: inline-flex; align-items: center; gap: 8px; }
.lab-fs-btn > span[hidden] { display: none; }
.lab-wrap.is-full { background: #f8fafc; padding: 14px 18px 18px; overflow: auto; display: flex; flex-direction: column; }
.lab-wrap.is-full .lab-fs-title { display: block; }
.lab-wrap.is-full .lab-frame { flex: 1; height: auto; min-height: 0; }
.lab-wrap.is-full > .lab-box { flex: 1; }
.lab-wrap.is-fs { position: fixed; inset: 0; z-index: 100; }
html.lab-fs-lock, html.lab-fs-lock body { overflow: hidden; }

/* IQ age stepper: no browser spin buttons */
.iq-age-in::-webkit-inner-spin-button, .iq-age-in::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.iq-age-in { -moz-appearance: textfield; appearance: textfield; }

/* Olympiad grade buttons */
.oly-g { background: #eff4ff; color: #0f172a; box-shadow: 0 1px 2px rgba(15, 23, 42, .05); }
.oly-g:hover { background: #dce9ff; }
.oly-g .oly-g-k { color: #64748b; }
.oly-g .oly-g-n { color: #64748b; }
.oly-g.is-on { background: #213145; color: #fff; box-shadow: 0 0 0 2px #004ac6, 0 6px 14px -4px rgba(15, 23, 42, .35); }
.oly-g.is-on .oly-g-k { color: #cbd5e1; }
.oly-g.is-on .oly-g-n { color: #94a3b8; }

/* v4.2 comments: a new or linked comment glows for a moment */
.cm-new > div { animation: cm-glow 2s ease-out; border-radius: .75rem; }
@keyframes cm-glow { 0% { background: #dbeafe; box-shadow: 0 0 0 6px #dbeafe; } 100% { background: transparent; box-shadow: 0 0 0 6px transparent; } }
.cm-body { overflow-wrap: anywhere; }
