/* SpeedGrade web: the inside of an exercise book. Same tokens as the app (mobile/src/ui/theme.ts). */
/* Fonts are served from this site (no third-party requests). Licences: static/fonts/OFL-*.txt */
@font-face { font-family: "Atkinson Hyperlegible Next"; src: url("/static/fonts/atkinson-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Atkinson Hyperlegible Next"; src: url("/static/fonts/atkinson-600.woff2") format("woff2"); font-weight: 500 600; font-display: swap; }
@font-face { font-family: "Atkinson Hyperlegible Next"; src: url("/static/fonts/atkinson-700.woff2") format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Kalam"; src: url("/static/fonts/kalam-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
:root {
  --paper: #F4F6F8;
  --sheet: #FFFFFF;
  --ink: #17263A;
  --pencil: #5B6676;
  --rule: #DDE3EA;
  --rule-strong: #C5CFDA;
  --pen: #2448B8;
  --pen-soft: #E7ECFA;
  --check: #18794E;
  --check-soft: #E3F2EA;
  --flag: #9A5B00;
  --flag-ring: #C7851A;
  --flag-soft: #FBF0DC;
  --error: #B42318;
  --error-soft: #FCE8E6;
  --margin-line: #E7B4B0;
  --hand: #3E4A5C;

  --font: "Atkinson Hyperlegible Next", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-hand: "Kalam", "Comic Neue", cursive;

  /* 1.25 scale from 17px body */
  --t-xs: 0.8125rem;
  --t-sm: 0.9375rem;
  --t-md: 1.0625rem;
  --t-lg: 1.328rem;
  --t-xl: 1.66rem;
  --t-2xl: 2.075rem;
  --t-3xl: clamp(2.1rem, 1.4rem + 2.6vw, 3.1rem);

  --gap: 1rem;
  --radius: 10px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 var(--t-md)/1.55 var(--font);
  font-feature-settings: "kern";
}
img, svg { max-width: 100%; }
a { color: var(--pen); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--pen); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 0.5em; font-weight: 700; letter-spacing: -0.01em; }
h1 { font-size: var(--t-3xl); letter-spacing: -0.02em; }
h2 { font-size: var(--t-xl); margin-top: 0; }
h3 { font-size: var(--t-md); font-weight: 600; margin-bottom: 0.25em; }
p { margin: 0 0 1em; }
code { font-size: 0.9em; background: var(--sheet); border: 1px solid var(--rule); border-radius: 4px; padding: 0.05em 0.3em; }
.vh { 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(--sheet); padding: 0.5rem 1rem; z-index: 10; }
.skip:focus { left: 1rem; }

.wrap { width: 100%; max-width: 72rem; margin: 0 auto; padding: 0 16px; }
@media (min-width: 720px) { .wrap { padding: 0 32px; } }
.narrow { max-width: 50rem; }
.slim { max-width: 40rem; padding-top: 2.5rem; padding-bottom: 3rem; }

/* ---------- header and footer ---------- */
.top { border-bottom: 1px solid var(--rule); background: var(--paper); }
.top-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 64px; flex-wrap: wrap; }
.brand { display: inline-flex; align-items: center; gap: 0.55rem; color: var(--ink); text-decoration: none; font-weight: 700; font-size: var(--t-lg); }
.top nav { display: flex; gap: 1.25rem; align-items: center; flex-wrap: wrap; }
.top nav a { color: var(--ink); text-decoration: none; font-size: var(--t-sm); }
.top nav a:hover { text-decoration: underline; }
.top nav .nav-strong { color: var(--pen); font-weight: 600; }
.foot { border-top: 1px solid var(--rule); }
main { padding-bottom: 1rem; }
.foot-row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; padding-top: 1.5rem; padding-bottom: 2rem; color: var(--pencil); font-size: var(--t-sm); }
.foot-row p { margin: 0; }
.linkish { background: none; border: 0; padding: 0; font: inherit; color: var(--pen); cursor: pointer; text-decoration: underline; text-underline-offset: 0.18em; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 48px; padding: 0 1.4rem;
  border-radius: var(--radius); border: 1.5px solid var(--pen); background: var(--pen); color: #fff;
  font: 600 var(--t-md)/1 var(--font); text-decoration: none; cursor: pointer;
}
.btn:hover { background: #1C3A99; border-color: #1C3A99; }
.btn-quiet { background: var(--sheet); color: var(--pen); }
.btn-quiet:hover { background: var(--pen-soft); border-color: var(--pen); }
.btn-danger { background: var(--sheet); color: var(--error); border-color: var(--error); }
.btn-danger:hover { background: var(--error-soft); border-color: var(--error); }
.actions { display: flex; gap: 0.75rem; flex-wrap: wrap; margin: 1.75rem 0 1rem; }
.fine { color: var(--pencil); font-size: var(--t-sm); }

/* ---------- hero: the marked page ---------- */
.hero { display: grid; gap: 2.5rem; padding-top: 3rem; padding-bottom: 3.5rem; align-items: start; }
@media (min-width: 960px) { .hero { grid-template-columns: 1.05fr 1fr; gap: 4rem; padding-top: 4.5rem; padding-bottom: 5rem; } }
.hero h1 { max-width: 15ch; }
.lede { font-size: var(--t-lg); line-height: 1.5; color: var(--ink); max-width: 36rem; }

.page { margin: 0; }
.page-sheet {
  position: relative;
  line-height: 32px;
  background-color: var(--sheet);
  background-image:
    linear-gradient(to right, transparent 54px, var(--margin-line) 54px, var(--margin-line) 55px, transparent 55px),
    repeating-linear-gradient(to bottom, transparent 0, transparent 31px, #E3E9F1 31px, #E3E9F1 32px);
  background-position: 0 0, 0 26px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 26px 22px 26px 72px;
  box-shadow: 0 1px 0 var(--rule), 0 18px 36px -24px rgba(23, 38, 58, 0.35);
}
.page .q { font-weight: 600; margin: 0; line-height: 32px; padding-right: 84px; }
.page .qn { position: absolute; left: 22px; font-weight: 700; }
.page .pts { color: var(--pencil); font-weight: 400; font-size: var(--t-sm); }
.page .hand {
  font-family: var(--font-hand); color: var(--hand); font-size: 1.25rem; line-height: 32px; margin: 0 0 32px;
  padding-right: 84px;
}
.page .hand sub { font-size: 0.7em; }
.mark {
  position: absolute; right: 18px; top: 58px; width: 66px; height: 66px;
  display: grid; place-items: center; grid-auto-flow: column; align-content: center; justify-content: center;
  color: var(--pen); font-weight: 700; transform: rotate(-6deg);
}
.mark::before {
  content: ""; position: absolute; inset: 0; border: 3px solid var(--pen); border-radius: 50% 46% 52% 48% / 48% 52% 46% 50%;
  transform: rotate(8deg);
}
.mark span { font-size: 1.9rem; line-height: 1; }
.mark small { font-size: 1rem; align-self: end; padding-bottom: 0.2rem; color: var(--pen); }
.read { background: var(--paper); border-radius: 8px; padding: 12px 14px; margin: 0 0 14px; line-height: 1.45; }
.read-label { font-size: var(--t-xs); color: var(--pencil); margin: 0 0 2px; font-weight: 600; }
.read-text { margin: 0; font-size: var(--t-sm); }
.read mark { background: var(--flag-soft); color: var(--ink); border-bottom: 2px solid var(--flag-ring); padding: 0 2px; }
.crit { list-style: none; padding: 0; margin: 0 0 12px; font-size: var(--t-sm); line-height: 1.45; }
.crit li { display: flex; gap: 10px; align-items: baseline; padding: 6px 0; border-bottom: 1px solid var(--rule); }
.crit li:last-child { border-bottom: 0; }
.crit b { margin-left: auto; font-weight: 600; white-space: nowrap; }
.tick { flex: none; width: 14px; height: 8px; border-left: 2.5px solid var(--check); border-bottom: 2.5px solid var(--check); transform: rotate(-45deg) translateY(-3px); }
.flag { line-height: 1.45; margin: 0; color: var(--flag); font-weight: 600; font-size: var(--t-sm); padding-left: 12px; border-left: 3px solid var(--flag-ring); }
.page figcaption { color: var(--pencil); font-size: var(--t-sm); margin-top: 0.9rem; max-width: 34rem; }

/* ---------- sections ---------- */
main > section { padding-top: 3.5rem; padding-bottom: 3.5rem; }
.band { background: var(--sheet); border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.steps { list-style: none; counter-reset: step; padding: 0; margin: 1.5rem 0 0; }
.steps li { counter-increment: step; position: relative; padding: 1.1rem 0 1.1rem 3.25rem; border-top: 1px solid var(--rule); }
.steps li:last-child { border-bottom: 1px solid var(--rule); }
.steps li::before {
  content: counter(step); position: absolute; left: 0; top: 1.05rem; width: 2.1rem; height: 2.1rem;
  display: grid; place-items: center; border: 2px solid var(--pen); border-radius: 50%; color: var(--pen); font-weight: 700;
}
.steps p { margin: 0; color: var(--ink); max-width: 40rem; }
.principles p { max-width: 42rem; padding-left: 1rem; border-left: 3px solid var(--check); margin-bottom: 1.25rem; }
.principles strong { display: block; font-size: var(--t-md); }

/* ---------- tables ---------- */
.ruled { width: 100%; border-collapse: collapse; font-size: var(--t-sm); margin: 1rem 0 1.5rem; background: var(--sheet); }
.ruled th, .ruled td { text-align: left; padding: 0.7rem 0.75rem; border-bottom: 1px solid var(--rule); vertical-align: top; }
.ruled thead th { font-weight: 600; color: var(--pencil); border-bottom: 1.5px solid var(--rule-strong); }
.num { text-align: right !important; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pos { color: var(--check); }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.ledger { width: 100%; max-width: 34rem; border-collapse: collapse; margin: 1.25rem 0; }
.ledger th, .ledger td { padding: 0.7rem 0; border-bottom: 1px dashed var(--rule-strong); }
.ledger th { text-align: left; font-weight: 400; }
.ledger td { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; padding-left: 1rem; }
.ledger.small { font-size: var(--t-sm); }
.ledger .sum th, .ledger .sum td { border-bottom: 0; border-top: 2px solid var(--ink); font-weight: 700; }
.example { margin: 2rem 0; padding: 1.25rem 1.25rem 0.5rem; background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--radius); max-width: 36rem; }
.faq dt { font-weight: 600; margin-top: 1.25rem; }
.faq dd { margin: 0.25rem 0 0; max-width: 42rem; }

/* ---------- notices and forms ---------- */
.notice { padding: 0.85rem 1rem; border-left: 4px solid var(--pen); background: var(--pen-soft); border-radius: 0 8px 8px 0; font-size: var(--t-sm); }
.notice-check { border-color: var(--check); background: var(--check-soft); }
.notice-error { border-color: var(--error); background: var(--error-soft); }
.devbox { margin-top: 2.5rem; padding: 1.25rem; border: 1.5px dashed var(--rule-strong); border-radius: var(--radius); }
.devbox h2 { font-size: var(--t-md); }
.row-buttons { display: flex; gap: 0.75rem; flex-wrap: wrap; }
.row-buttons form { margin: 0; }
fieldset { border: 0; margin: 0 0 1rem; padding: 0; }
legend { font-weight: 600; margin-bottom: 0.5rem; }
.amounts { display: grid; grid-template-columns: repeat(auto-fit, minmax(5.5rem, 1fr)); gap: 0.6rem; }
.amount { position: relative; }
.amount input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.amount span {
  display: grid; place-items: center; min-height: 52px; border: 1px solid var(--rule-strong); border-radius: var(--radius);
  background: var(--sheet); font-weight: 600; font-size: var(--t-lg); font-variant-numeric: tabular-nums;
}
.amount input:checked + span { border: 2px solid var(--pen); background: var(--pen-soft); color: var(--pen); }
.amount input:focus-visible + span { outline: 3px solid var(--pen); outline-offset: 2px; }
.buy .btn { margin-top: 0.5rem; }
.balance { margin: 1.5rem 0 2.5rem; padding: 1.25rem 0; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.balance-label { margin: 0; color: var(--pencil); font-weight: 600; font-size: var(--t-sm); }
.balance-amount { margin: 0.1rem 0 0; font-size: var(--t-2xl); font-weight: 700; font-variant-numeric: tabular-nums; }
.slim h2 { font-size: var(--t-lg); margin-top: 2.25rem; }
input[type="search"], input:not([type]), select {
  font: inherit; font-size: var(--t-sm); min-height: 44px; padding: 0 0.75rem; border: 1px solid var(--rule-strong);
  border-radius: 8px; background: var(--sheet); color: var(--ink); width: 100%;
}
label { display: block; font-size: var(--t-sm); font-weight: 600; }
label input, label select { margin-top: 0.3rem; font-weight: 400; }
.stack { display: grid; gap: 0.9rem; max-width: 26rem; }
.stack .btn { justify-self: start; }
form.inline { display: inline-block; margin: 0 0.5rem 0.75rem 0; }

/* ---------- admin ---------- */
.admin { background: var(--paper); }
.admin-wrap { padding-top: 1.5rem; padding-bottom: 2rem; }
.admin h1 { font-size: var(--t-2xl); margin: 1rem 0 1.25rem; }
.admin h2 { font-size: var(--t-lg); margin-top: 2rem; }
.tabs { display: flex; gap: 0.25rem; border-bottom: 1px solid var(--rule); overflow-x: auto; }
.tabs a { padding: 0.75rem 0.9rem; color: var(--pencil); text-decoration: none; border-bottom: 3px solid transparent; white-space: nowrap; font-weight: 600; font-size: var(--t-sm); }
.tabs a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--pen); }
.tabs a:hover { color: var(--ink); }
.figures { display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: 0; margin: 0 0 1.5rem; border-top: 1px solid var(--rule); border-left: 1px solid var(--rule); background: var(--sheet); }
.figures > div { padding: 1rem 1.1rem; border-right: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.figures dt { color: var(--pencil); font-size: var(--t-sm); font-weight: 600; }
.figures dd { margin: 0.2rem 0 0.1rem; font-size: var(--t-xl); font-weight: 700; font-variant-numeric: tabular-nums; }
.figures p { margin: 0; font-size: var(--t-xs); color: var(--pencil); }
.figures .warn dd, .figures .warn a { color: var(--flag); }
.cols { display: grid; gap: 1rem 2.5rem; }
@media (min-width: 900px) { .cols { grid-template-columns: 1fr 1fr; } }
.log { list-style: none; padding: 0; margin: 0.5rem 0 1rem; font-size: var(--t-sm); }
.log li { padding: 0.55rem 0; border-bottom: 1px solid var(--rule); }
.log .when { color: var(--pencil); margin-right: 0.4rem; font-variant-numeric: tabular-nums; }
.filters { display: grid; gap: 0.75rem; grid-template-columns: 1fr; align-items: end; margin-bottom: 0.75rem; max-width: 46rem; }
@media (min-width: 720px) { .filters { grid-template-columns: 2fr 1.4fr auto; } }
.tag { display: inline-block; font-size: var(--t-xs); font-weight: 600; padding: 0.1rem 0.45rem; border-radius: 999px; background: var(--pen-soft); color: var(--pen); vertical-align: middle; }
.tag-off { background: var(--error-soft); color: var(--error); }
.tag-warn { background: var(--flag-soft); color: var(--flag); }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 0.25rem 2rem; margin: 0 0 1rem; }
.facts > div { padding: 0.5rem 0; border-bottom: 1px solid var(--rule); }
.facts dt { font-size: var(--t-xs); color: var(--pencil); font-weight: 600; }
.facts dd { margin: 0.1rem 0 0; }
.mono-ish { font-variant-numeric: tabular-nums; word-break: break-all; font-size: var(--t-xs); color: var(--pencil); }
.err { color: var(--error); font-size: var(--t-xs); max-width: 28rem; }

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

/* ---------- policies ---------- */
.foot-links { display: flex; gap: 1.25rem; flex-wrap: wrap; }
.legal { padding-top: 2rem; }
.legal h1 { font-size: var(--t-2xl); margin-top: 1.25rem; }
.legal-nav { display: flex; gap: 0.25rem 1.25rem; flex-wrap: wrap; font-size: var(--t-sm); border-bottom: 1px solid var(--rule); padding-bottom: 0.75rem; }
.legal-nav a { color: var(--pencil); text-decoration: none; font-weight: 600; }
.legal-nav a[aria-current="page"] { color: var(--ink); text-decoration: underline; text-decoration-color: var(--pen); text-decoration-thickness: 2px; text-underline-offset: 0.35em; }
.prose { max-width: 44rem; }
.prose h2 { font-size: var(--t-lg); margin-top: 2.25rem; }
.prose ul, .prose ol { padding-left: 1.4rem; }
.prose li { margin-bottom: 0.35rem; }
.prose table { width: 100%; border-collapse: collapse; font-size: var(--t-sm); margin: 1rem 0 1.5rem; background: var(--sheet); display: block; overflow-x: auto; }
.prose th, .prose td { text-align: left; padding: 0.6rem 0.7rem; border-bottom: 1px solid var(--rule); vertical-align: top; min-width: 7rem; }
.prose thead th { color: var(--pencil); border-bottom: 1.5px solid var(--rule-strong); }
mark.tbd { background: var(--flag-soft); color: var(--flag); border-radius: 3px; padding: 0 0.15em; }
.notice-flag { border-color: var(--flag-ring); background: var(--flag-soft); }
.checks { list-style: none; padding: 0; margin: 1rem 0 1.25rem; }
.checks li { padding: 0.55rem 0 0.55rem 1.9rem; position: relative; border-bottom: 1px solid var(--rule); }
.checks li::before { content: ""; position: absolute; left: 0.35rem; top: 0.95rem; width: 12px; height: 7px; border-left: 2.5px solid var(--check); border-bottom: 2.5px solid var(--check); transform: rotate(-45deg); }
.terms-form { max-width: 34rem; margin-top: 1.5rem; padding: 1.25rem; background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--radius); }
.terms-form fieldset { display: grid; gap: 0.5rem; }
label.choice { display: flex; gap: 0.6rem; align-items: flex-start; font-weight: 400; font-size: var(--t-md); cursor: pointer; }
label.choice input { margin-top: 0.3rem; width: 1.1rem; height: 1.1rem; accent-color: var(--pen); flex: none; }
@media print { .top, .foot, .legal-nav, .notice { display: none; } body { background: #fff; } }
