/*
 * Participant stylesheet: every page a participant sees (sign-in, plans,
 * checkout, orders, exam, result, review). One plain file, custom properties,
 * no framework, no web font, no remote request. Served from /assets/ by the
 * app's static mount; the shared shell that links it is
 * internal/platform/ui/participant. Tokens, components and the way to add a
 * page: docs/design/ui-participant.md.
 *
 * The exam script (internal/platform/engine/static/ujian.js) sets class names
 * and text on #timer, .gnum, #flag, #unsaved and #msg by itself, so those are
 * styled by id/state class and drawn with pseudo-elements, never with children.
 */

/* ---- tokens ------------------------------------------------------------ */
:root {
  color-scheme: light;
  --teal: #0F766E;
  --teal-d: #115E59;
  --teal-50: #F0FDFA;
  --teal-100: #CCFBF1;
  --amber: #F59E0B;
  --amber-50: #FFFBEB;
  --amber-200: #FDE68A;
  --amber-ink: #78350F;
  --ink: #0F172A;
  --ink-2: #334155;
  --muted: #64748B;
  --surface: #FFFFFF;
  --bg: #F8FAFC;
  --line: #E2E8F0;
  --line-input: #7C8BA0;
  --danger: #DC2626;
  --danger-ink: #B91C1C;
  --danger-50: #FEF2F2;
  --ok: #16A34A;
  --ok-ink: #166534;
  --ok-50: #F0FDF4;
  --r-s: 10px;
  --r-m: 14px;
  --r-l: 20px;
  --tap: 44px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 8px 24px -14px rgba(15, 23, 42, .28);
}

/* ---- reset ------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
[hidden] { display: none !important; }
body {
  margin: 0;
  font: 1rem/1.55 var(--font);
  color: var(--ink);
  background: var(--bg);
  overflow-wrap: anywhere;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3, p, ul, dl, dd, figure { margin: 0; }
h1 { font-size: 1.5rem; line-height: 1.2; font-weight: 800; letter-spacing: -.015em; }
h2 { font-size: 1.125rem; line-height: 1.3; font-weight: 700; }
h3 { font-size: 1.0625rem; line-height: 1.3; font-weight: 700; }
a { color: var(--teal); text-underline-offset: .18em; }
a:hover { color: var(--teal-d); }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .9em; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: .05em .35em; }
button, input, select, textarea { font: inherit; color: inherit; }
button { touch-action: manipulation; }
:focus-visible { outline: 3px solid var(--teal-d); outline-offset: 2px; }
.muted { color: var(--muted); font-size: .9375rem; }
.hint { color: var(--muted); font-size: .875rem; margin-top: .375rem; }
.ok { color: var(--ok-ink); font-weight: 700; }
.bad { color: var(--danger-ink); font-weight: 700; }
.row { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; }
.stack-gap > * + * { margin-top: 1rem; }
.ico { width: 1.25rem; height: 1.25rem; flex: none; }

/* ---- shell ------------------------------------------------------------- */
.p-skip { position: absolute; left: .5rem; top: -4rem; z-index: 50; background: var(--ink); color: #fff; padding: .6rem .9rem; border-radius: var(--r-s); }
.p-skip:focus { top: .5rem; }
.p-brand { display: inline-flex; align-items: center; gap: .55rem; color: var(--ink); text-decoration: none; min-height: var(--tap); }
.p-brand:hover { color: var(--ink); }
.p-mark { width: 2rem; height: 2rem; flex: none; }
.p-name { font-size: 1.1875rem; font-weight: 800; letter-spacing: -.02em; }

.p-top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .25rem 1rem; background: var(--surface); border-bottom: 1px solid var(--line); }
.p-out { margin: 0; }
.p-out button { display: inline-flex; align-items: center; gap: .4rem; min-height: var(--tap); padding: 0 .25rem; border: 0; background: none; color: var(--ink-2); font-weight: 600; font-size: .9375rem; cursor: pointer; border-radius: var(--r-s); }
.p-out button:hover { color: var(--ink); }

.p-tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: grid; grid-template-columns: repeat(4, 1fr); background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.p-tabs a { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .1rem; min-height: 3.5rem; padding: .35rem .25rem; color: var(--ink-2); font-size: .8125rem; font-weight: 600; text-decoration: none; }
.p-tabs a[aria-current="page"] { color: var(--teal-d); font-weight: 800; }
.p-tabs a[aria-current="page"]::before { content: ""; position: absolute; top: 0; left: 22%; right: 22%; height: 3px; border-radius: 0 0 3px 3px; background: var(--teal); }

.p-main { width: 100%; max-width: 40rem; margin: 0 auto; padding: 1.25rem 1rem 1.5rem; }
.p-app .p-main { padding-bottom: calc(5.5rem + env(safe-area-inset-bottom)); }
.p-wide .p-main { max-width: 68rem; }

.p-hero { background: var(--teal); color: #fff; padding: 1.25rem max(1rem, calc((100% - 26rem) / 2)) 3.75rem; }
.p-hero .p-brand, .p-hero .p-brand:hover { color: #fff; }
.p-hero .p-name { font-size: 1.5rem; }
.p-hero .p-mark { width: 2.5rem; height: 2.5rem; }
.p-tagline { margin: .5rem 0 1rem; max-width: 22rem; font-size: 1rem; color: #E6FFFA; }
.p-bubbles { display: block; width: 10.5rem; height: auto; }
.p-auth .p-main { max-width: 26rem; margin-top: -2.5rem; padding: 0 1rem 2.5rem; position: relative; }

@media (min-width: 48rem) {
  .p-top { display: grid; grid-template-columns: 1fr auto 1fr; padding: .25rem max(1.5rem, calc((100% - 68rem) / 2)); }
  .p-top > .p-out { justify-self: end; }
  .p-tabs { position: static; display: flex; gap: .25rem; border: 0; padding: 0; background: none; }
  .p-tabs a { flex-direction: row; gap: .45rem; min-height: var(--tap); padding: 0 .9rem; font-size: .9375rem; border-radius: var(--r-s); }
  .p-tabs a:hover { background: var(--bg); }
  .p-tabs a[aria-current="page"] { background: var(--teal-50); }
  .p-tabs a[aria-current="page"]::before { display: none; }
  .p-main { padding-top: 2rem; }
  .p-app .p-main { padding-bottom: 3rem; }
  .p-hero { padding-bottom: 4.25rem; }
}

/* ---- components ---------------------------------------------------------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-m); padding: 1.125rem; box-shadow: var(--shadow); }
.card + .card, .card + .alert, .alert + .card, .card + .row, .alert + .alert { margin-top: 1rem; }
.p-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); padding: 1.5rem 1.25rem; box-shadow: var(--shadow); }
.p-card > h1 { margin-bottom: .25rem; }
.lead { color: var(--ink-2); margin-bottom: 1.25rem; }
.page-head { margin-bottom: 1.25rem; }
.page-head p { margin-top: .35rem; }
.h-code { font-size: 1.25rem; letter-spacing: 0; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: .5rem; min-height: 3rem; padding: .5rem 1.25rem; border: 2px solid var(--teal); border-radius: 12px; background: var(--teal); color: #fff; font-weight: 700; font-size: 1rem; line-height: 1.2; text-align: center; text-decoration: none; cursor: pointer; transition: background-color .12s; }
.btn:hover { background: var(--teal-d); border-color: var(--teal-d); color: #fff; }
.btn.secondary { background: var(--surface); color: var(--teal-d); }
.btn.secondary:hover { background: var(--teal-50); color: var(--teal-d); }
.btn.block { display: flex; width: 100%; }
.btn[disabled], .btn:disabled { opacity: .45; cursor: default; }
.link { display: inline-flex; align-items: center; min-height: var(--tap); padding: 0 .25rem; border: 0; background: none; color: var(--teal); font-weight: 600; text-decoration: underline; text-underline-offset: .18em; cursor: pointer; }
.linklike { font-size: .9375rem; }
.help { margin-top: 1.25rem; text-align: center; font-size: .9375rem; color: var(--ink-2); }
.help + .help { margin-top: .25rem; }
.help a { display: inline-flex; align-items: center; min-height: var(--tap); font-weight: 600; }
.sep { display: flex; align-items: center; gap: .75rem; margin: 1.25rem 0 1rem; color: var(--muted); font-size: .875rem; }
.sep::before, .sep::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.field { margin-bottom: 1.125rem; }
.field label { display: block; margin-bottom: .375rem; font-weight: 650; font-size: .9375rem; color: var(--ink); }
.field input, .field select, .field textarea { display: block; width: 100%; min-height: 3rem; padding: .6rem .85rem; border: 1.5px solid var(--line-input); border-radius: 12px; background: var(--surface); font-size: 1rem; }
.field input:focus { border-color: var(--teal-d); outline: 3px solid var(--teal-100); outline-offset: 0; box-shadow: 0 0 0 1.5px var(--teal-d); }
.field input::placeholder { color: var(--muted); opacity: 1; }
.field .hint { margin-top: .4rem; }

.alert { display: flex; gap: .6rem; align-items: flex-start; padding: .75rem .9rem; border: 1px solid var(--line); border-left-width: 4px; border-radius: 12px; background: var(--surface); font-size: .9375rem; }
.alert > .ico { margin-top: .1rem; }
.alert p + p { margin-top: .4rem; }
.alert.error { background: var(--danger-50); border-color: #FCA5A5; border-left-color: var(--danger); color: var(--danger-ink); }
.alert.ok, .alert.success { background: var(--ok-50); border-color: #86EFAC; border-left-color: var(--ok); color: var(--ok-ink); font-weight: 400; }
.alert.warn { background: var(--amber-50); border-color: var(--amber-200); border-left-color: var(--amber); color: var(--amber-ink); }
.alert.info { background: var(--teal-50); border-color: var(--teal-100); border-left-color: var(--teal); color: var(--teal-d); }
.alert .alert-body { flex: 1; min-width: 0; }
.alert strong { display: block; }
.p-card > .alert { margin-bottom: 1.125rem; }
.alert.headline { font-size: 1.0625rem; font-weight: 700; padding: 1rem; }

.badge { display: inline-block; align-self: flex-start; padding: .15rem .65rem; border: 1px solid var(--amber-200); border-radius: 999px; background: var(--amber-50); color: var(--amber-ink); font-size: .8125rem; font-weight: 700; line-height: 1.4; }
.badge.solid { background: var(--amber); border-color: var(--amber); color: var(--ink); }
.tag { font-size: .8125rem; font-weight: 700; }

dl.kv { display: grid; grid-template-columns: minmax(6.5rem, max-content) 1fr; margin: 0 0 1.25rem; }
dl.kv dt, dl.kv dd { padding: .6rem 0; border-bottom: 1px solid var(--line); }
dl.kv dt { color: var(--muted); font-size: .9375rem; padding-right: 1rem; }
dl.kv dd { font-weight: 600; }

table { width: 100%; border-collapse: collapse; font-size: .9375rem; }
th, td { padding: .65rem .5rem; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-size: .8125rem; font-weight: 700; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

@media (max-width: 39.99rem) {
  table.stack, table.stack tbody { display: block; }
  table.stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  table.stack tr { display: block; padding: .5rem .85rem; margin-bottom: .75rem; border: 1px solid var(--line); border-radius: var(--r-m); background: var(--surface); }
  table.stack td { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; padding: .4rem 0; border: 0; text-align: right; }
  table.stack td::before { content: attr(data-label); flex: none; color: var(--muted); font-size: .875rem; font-weight: 600; text-align: left; }
  table.stack td[data-label=""]::before { content: none; }
  table.stack td.lead-cell { display: block; padding-bottom: .5rem; margin-bottom: .25rem; border-bottom: 1px solid var(--line); text-align: left; font-weight: 700; }
  table.stack td.lead-cell::before { content: none; }
  table.stack td.action { justify-content: flex-end; }
}
table a { display: inline-flex; align-items: center; min-height: var(--tap); }
.table-card { padding: 0; overflow: hidden; }
@media (max-width: 39.99rem) { .table-card { padding: 0; border: 0; background: none; box-shadow: none; overflow: visible; } }
@media (min-width: 40rem) { .table-card { padding: .25rem .75rem; } }

/* ---- sign-in family ------------------------------------------------------- */
.p-card .btn.block { margin-top: .5rem; }
.g_id_signin { display: flex; justify-content: center; min-height: 44px; }

/* ---- dashboard ---------------------------------------------------------------- */
.tiles { display: grid; gap: .75rem; margin: 1.25rem 0; }
.tile { display: flex; align-items: center; gap: .9rem; min-height: 4rem; padding: .85rem 1rem; border: 1px solid var(--line); border-radius: var(--r-m); background: var(--surface); color: var(--ink); text-decoration: none; box-shadow: var(--shadow); }
.tile:hover { border-color: var(--teal); color: var(--ink); }
.tile .ico { width: 1.75rem; height: 1.75rem; color: var(--teal); }
.tile strong { display: block; }
.tile span.sub { color: var(--muted); font-size: .875rem; }
@media (min-width: 40rem) { .tiles { grid-template-columns: repeat(3, 1fr); } .tile { flex-direction: column; align-items: flex-start; } }

/* ---- plans, checkout, orders ----------------------------------------------------- */
.plans { display: grid; gap: 1rem; margin: 1.25rem 0; grid-template-columns: 1fr; }
@media (min-width: 40rem) { .plans { grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr)); } }
.plan { display: flex; flex-direction: column; gap: .6rem; }
.plan h3 { font-size: 1.25rem; letter-spacing: -.01em; }
.plan .tier { color: var(--teal-d); font-weight: 700; font-size: .875rem; }
.price { font-size: 2rem; line-height: 1.1; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.was { color: var(--muted); font-size: .9375rem; text-decoration: line-through; }
ul.features { list-style: none; padding: 0; flex: 1; font-size: .9375rem; }
ul.features li { position: relative; padding: .3rem 0 .3rem 1.75rem; }
ul.features li::before { content: ""; position: absolute; left: .15rem; top: .62rem; width: .85rem; height: .45rem; border-left: 3px solid var(--teal); border-bottom: 3px solid var(--teal); transform: rotate(-45deg); }
.plan .btn { margin-top: .5rem; }
.total { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; padding-top: .75rem; border-top: 1px solid var(--line); font-weight: 650; }
.total .price { font-size: 1.75rem; }
.fine { margin-top: .5rem; }
.note-end { margin-top: 1.5rem; text-align: center; font-size: .9375rem; }
.note-end a, .note-end .sep-bar { display: inline-flex; align-items: center; min-height: var(--tap); padding: 0 .5rem; font-weight: 600; }
.pay { margin-top: 1.25rem; }
.notice-box { margin-top: 1rem; padding: 1rem; border: 1px solid var(--teal-100); border-radius: var(--r-m); background: var(--teal-50); color: var(--ink); }
.notice-box strong { display: block; margin-bottom: .25rem; color: var(--teal-d); }
.notice-box p + p { margin-top: .4rem; }

/* ---- engine pages: history, result, review, message ------------------------------ */
.flash { display: flex; gap: .6rem; padding: .75rem .9rem; margin-bottom: 1rem; border: 1px solid var(--amber-200); border-left: 4px solid var(--amber); border-radius: 12px; background: var(--amber-50); color: var(--amber-ink); font-size: .9375rem; }
.scoreboard { text-align: left; }
.score { font-size: 3.25rem; line-height: 1; font-weight: 800; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.score .of { margin-left: .25rem; color: var(--muted); font-size: 1.125rem; font-weight: 600; letter-spacing: 0; }
.verdict { display: flex; align-items: flex-start; gap: .5rem; margin-top: .85rem; padding: .6rem .85rem; border-radius: 14px; font-weight: 700; }
.verdict .ico { margin-top: .12rem; }
.verdict.pass { background: var(--ok-50); color: var(--ok-ink); border: 1.5px solid var(--ok); }
.verdict.fail { background: var(--danger-50); color: var(--danger-ink); border: 1.5px solid var(--danger); }
.result-actions { display: grid; gap: .75rem; margin-top: 1.25rem; }
.result-actions form { margin: 0; }
@media (min-width: 40rem) { .result-actions { grid-template-columns: repeat(3, auto); justify-content: start; } }
.verdict-note { margin-top: .6rem; color: var(--ink-2); }

.rv .card { margin-top: 1rem; }
.rv .meta { display: flex; flex-wrap: wrap; gap: .4rem .6rem; align-items: center; margin-bottom: .6rem; }
.explain { margin-top: 1rem; padding: .75rem 1rem; border-left: 4px solid var(--teal); border-radius: 0 var(--r-s) var(--r-s) 0; background: var(--teal-50); }
.explain strong { color: var(--teal-d); }
.explain .qbody { margin-bottom: 0; }
.score-line { margin-top: .75rem; }

.qbody { margin: .5rem 0 1.1rem; font-size: 1.0625rem; line-height: 1.6; white-space: pre-wrap; }
@media (min-width: 40rem) { .qbody { font-size: 1.1875rem; line-height: 1.65; } }
.qbody img, .qimg { display: block; max-width: 100%; height: auto; margin: .75rem 0; border-radius: var(--r-s); }
.choices { list-style: none; padding: 0; display: grid; gap: .65rem; }
.choice { position: relative; display: flex; align-items: center; gap: .85rem; width: 100%; min-height: 3.5rem; padding: .7rem 1rem; border: 1.5px solid var(--line-input); border-radius: 14px; background: var(--surface); color: var(--ink); font-size: 1.0625rem; line-height: 1.5; text-align: left; cursor: pointer; transition: background-color .12s, border-color .12s; }
.choice .lbl { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 2.25rem; height: 2.25rem; border: 2px solid var(--ink-2); border-radius: 50%; background: var(--surface); font-weight: 800; font-size: 1rem; }
.choice .ct { flex: 1; min-width: 0; }
.choice[aria-pressed="true"] { border-color: var(--teal); background: var(--teal-50); box-shadow: inset 0 0 0 1px var(--teal); }
.choice[aria-pressed="true"] .lbl { border-color: var(--teal); background: var(--teal); color: #fff; }
.choice[aria-pressed="true"]::after { content: ""; flex: none; width: 1.05rem; height: .55rem; margin-right: .25rem; border-left: 3px solid var(--teal-d); border-bottom: 3px solid var(--teal-d); transform: rotate(-45deg) translate(1px, -2px); }

.rv .choice { display: grid; grid-template-columns: auto 1fr; align-items: start; column-gap: .85rem; row-gap: .2rem; cursor: default; }
.rv .choice .tag { grid-column: 2; margin: 0; }
.rv .choice.best { border-color: var(--ok); border-width: 2px; background: var(--ok-50); }
.rv .choice.best .lbl { border-color: var(--ok-ink); background: var(--ok-ink); color: #fff; }
.rv .choice.chosen { border-style: dashed; border-width: 2px; border-color: var(--teal-d); }
.rv .choice.chosen.best { border-style: solid; border-color: var(--ok); }
.rv .choice.chosen:not(.best) { background: var(--danger-50); border-color: var(--danger); }
.rv .choice.chosen:not(.best) .lbl { border-color: var(--danger); }

/* ---- exam ---------------------------------------------------------------------------- */
body.exam { padding-bottom: calc(5.5rem + env(safe-area-inset-bottom)); }
.bar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: .75rem; min-height: 3.5rem; padding: .35rem 1rem; background: var(--surface); border-bottom: 1px solid var(--line); }
.bar .ttl { flex: 1 1 auto; min-width: 0; font-weight: 700; font-size: .9375rem; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.clock { display: flex; align-items: center; gap: .5rem; flex: none; }
.clock small { color: var(--muted); font-size: .75rem; font-weight: 600; line-height: 1.1; max-width: 3.5rem; text-align: right; }
#timer { display: inline-block; min-width: 5.25rem; padding: .2rem .6rem; border: 1.5px solid var(--line-input); border-radius: 999px; background: var(--surface); font-size: 1rem; font-weight: 700; text-align: center; font-variant-numeric: tabular-nums; letter-spacing: .02em; }
#timer.low { border-color: var(--danger); background: var(--danger-50); color: var(--danger-ink); }

.status { display: flex; align-items: center; flex-wrap: wrap; gap: .25rem .6rem; min-height: 2rem; padding: .35rem 1rem; max-width: 40rem; margin: 0 auto; font-size: .875rem; color: var(--ink-2); }
.status::before { content: ""; flex: none; width: .5rem; height: .5rem; border-radius: 50%; background: var(--teal); }
.status:has(#unsaved:not([hidden]))::before { background: var(--amber); }
.status .msg { flex: 1 1 12rem; min-width: 0; }
#unsaved { order: 1; }

body.exam .wrap { max-width: 40rem; margin: 0 auto; padding: .75rem 1rem 1rem; }
.q[hidden], #grid[hidden], .qstate[hidden], #unsaved[hidden] { display: none; }
.q > .muted { font-size: .875rem; font-weight: 600; }
.qtools { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-top: .5rem; }
.qtools .badge { margin-left: auto; }
.endrow { max-width: 40rem; margin: 0 auto; padding: 0 1rem; }
.endrow .link { color: var(--ink-2); font-weight: 600; }

.nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .3rem; max-width: 40rem; margin: 0 auto; padding: .45rem .4rem calc(.5rem + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--line); }
@media (min-width: 40rem) { .nav { border-radius: var(--r-l) var(--r-l) 0 0; border: 1px solid var(--line); border-bottom: 0; box-shadow: var(--shadow); } }
.nb { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .15rem; min-height: 3.75rem; padding: .3rem 0; border: 1.5px solid transparent; border-radius: 12px; background: none; color: var(--ink-2); font-size: .8125rem; font-weight: 650; line-height: 1.15; text-align: center; overflow-wrap: normal; cursor: pointer; }
@media (max-width: 23.75rem) { .nb { font-size: .75rem; } }
.nb:hover { background: var(--bg); color: var(--ink); }
.nb .ico { width: 1.4rem; height: 1.4rem; }
.nb.primary { background: var(--teal); border-color: var(--teal); color: #fff; }
.nb.primary:hover { background: var(--teal-d); border-color: var(--teal-d); }
.nb[disabled] { opacity: .4; cursor: default; }
.nb[disabled]:hover { background: none; color: var(--ink-2); }
#flag::before { content: ""; width: 1.4rem; height: 1.4rem; flex: none; background: currentColor; -webkit-mask: var(--i-flag) center / contain no-repeat; mask: var(--i-flag) center / contain no-repeat; }
:root { --i-flag: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5 21V4M5 4h12l-2.5 4L17 12H5' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); }

#grid { position: fixed; inset: 0; z-index: 40; overflow-y: auto; padding: 1rem 1rem 2rem; background: var(--bg); counter-reset: ans 0 fl 0 un 0; }
#grid > * { max-width: 40rem; margin-left: auto; margin-right: auto; }
#grid h1 { margin-bottom: .5rem; }
.legend { display: flex; flex-wrap: wrap; gap: .5rem 1.1rem; margin: .5rem auto 0; color: var(--ink-2); font-size: .875rem; }
.legend span { display: inline-flex; align-items: center; gap: .4rem; }
.legend i, .gnum { position: relative; }
.legend i { display: inline-block; width: 1.4rem; height: 1.4rem; border: 2px solid var(--line-input); border-radius: 7px; background: var(--surface); }
.legend i.a { background: var(--teal); border-color: var(--teal); }
.legend i.f { overflow: hidden; }
.legend i.f::after, .gnum.flagged::after { content: ""; position: absolute; top: 0; right: 0; width: 0; height: 0; border-style: solid; border-width: 0 .8rem .8rem 0; border-color: transparent var(--ink) transparent transparent; }
.legend i.c { border-color: var(--ink); box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--ink); margin: 0 .2rem; }
.gsec { margin: 1.25rem auto .5rem; font-weight: 700; font-size: .9375rem; color: var(--ink-2); }
.gnums { display: grid; grid-template-columns: repeat(5, 1fr); gap: .5rem; }
@media (min-width: 30rem) { .gnums { grid-template-columns: repeat(8, 1fr); } }
.gnum { overflow: hidden; min-height: 3rem; padding: 0; border: 2px solid var(--line-input); border-radius: 12px; background: var(--surface); color: var(--ink); font-size: 1.0625rem; font-weight: 700; font-variant-numeric: tabular-nums; cursor: pointer; }
.gnum.answered { background: var(--teal); border-color: var(--teal); color: #fff; }
/* The tally under the grid is counted by CSS counters, so it follows the classes the script sets. One rule per combination: two rules setting counter-increment on the same element would override each other. */
.gnum:not(.answered):not(.flagged) { counter-increment: un; }
.gnum:not(.answered).flagged { counter-increment: un fl; }
.gnum.answered:not(.flagged) { counter-increment: ans; }
.gnum.answered.flagged { counter-increment: ans fl; }
.gnum.current { outline: 3px solid var(--ink); outline-offset: 2px; }
.gnum.unsaved::before { content: ""; position: absolute; left: .35rem; bottom: .35rem; width: .45rem; height: .45rem; border-radius: 50%; background: var(--amber); box-shadow: 0 0 0 1.5px var(--ink); }
.gtally { display: flex; flex-wrap: wrap; gap: .5rem 1.25rem; margin-top: 1.25rem; padding: .85rem 1rem; border: 1px solid var(--line); border-radius: var(--r-m); background: var(--surface); }
.gtally > div { display: flex; align-items: baseline; gap: .4rem; }
.gtally dt { color: var(--ink-2); font-size: .9375rem; }
.gtally dd { font-size: 1.25rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.gtally dd::before { content: counter(ans); }
.gtally .un dd::before { content: counter(un); }
.gtally .fl dd::before { content: counter(fl); }
.gactions { display: grid; grid-template-columns: 1fr 1.4fr; gap: .65rem; margin-top: 1rem; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }
