/* Wamikas läxor
   ------------------------------------------------------------------
   Neutrals are cool, not warm — deliberately off the cream/espresso
   default. There is no global accent colour: the SUBJECT colour is the
   accent, contextually, because it carries information (which subject
   this is), while primary actions use ink. One rule, applied everywhere.

   Radius scale (the documented rule): containers 14px · rows and
   controls 10px · chips and small marks 6px. Nothing else.
   Shadows are tinted with the ink hue; never pure black.
   Print overrides live in print.css, which flattens all of this.
   ------------------------------------------------------------------ */

:root {
  --paper: #f2f4f7;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --ink: #14171c;
  --ink-2: #576070;
  --ink-3: #6b7482;
  --line: #dfe3ea;
  --line-2: #eef1f5;

  --ok: #157048;   --ok-bg: #e4f3ec;   --ok-line: #b6ddc9;
  --bad: #b03a26;  --bad-bg: #fbeae6;  --bad-line: #f0c3b8;
  --focus: #14171c;

  /* Subject = semantic colour. `-bg` is the tint, `-ink` the readable text. */
  --math-ink: #1f4f8f;  --math-bg: #e8eff9;  --math-solid: #2c5fa8;
  --sv-ink:   #94441a;  --sv-bg:   #fbeadf;  --sv-solid:   #9c4718;
  --en-ink:   #5b3590;  --en-bg:   #efe9f9;  --en-solid:   #6a3fa0;
  --no-ink:   #1d6340;  --no-bg:   #e4f2ea;  --no-solid:   #256440;
  --so-ink:   #7a5209;  --so-bg:   #f8efd9;  --so-solid:   #855a0d;

  --r-container: 14px;
  --r-row: 10px;
  --r-chip: 6px;
  --shadow-1: 0 1px 2px rgba(20, 23, 28, .05), 0 2px 8px rgba(20, 23, 28, .04);
  --shadow-2: 0 2px 4px rgba(20, 23, 28, .06), 0 10px 26px rgba(20, 23, 28, .07);

  --sheet: 46rem;

  /* Motion, by role. --m-fast is touch feedback: anything slower stops reading
     as a response to the tap. --m-base is every other transition. --m-curve is
     deceleration-heavy and one-directional; --m-symmetric exists for changes
     that run BOTH ways, where the signature curve played backwards accelerates
     into rest and reads as a snap. */
  --m-fast: .14s;
  --m-base: .24s;
  --m-curve: cubic-bezier(.2, .8, .3, 1);
  --m-symmetric: cubic-bezier(.4, 0, .2, 1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #101319;
    --surface: #181c23;
    --surface-2: #1e232b;
    --ink: #e9edf3;
    --ink-2: #9aa3b2;
    --ink-3: #8b95a4;
    --line: #2b313b;
    --line-2: #232830;
    --ok: #6cc396;   --ok-bg: #16281f;   --ok-line: #2c4b3a;
    --bad: #e5907a;  --bad-bg: #2c1d19;  --bad-line: #4d3229;
    --focus: #e9edf3;
    --math-ink: #8fb6ec;  --math-bg: #182233;  --math-solid: #2c5fa8;
    --sv-ink:   #e9a077;  --sv-bg:   #2a1e17;  --sv-solid:   #9c4718;
    --en-ink:   #bda3e8;  --en-bg:   #221d2e;  --en-solid:   #6a3fa0;
    --no-ink:   #83c69e;  --no-bg:   #172619;  --no-solid:   #256440;
    --so-ink:   #d8b464;  --so-bg:   #282112;  --so-solid:   #855a0d;
    --shadow-1: 0 1px 2px rgba(0, 0, 0, .3), 0 2px 8px rgba(0, 0, 0, .24);
    --shadow-2: 0 2px 4px rgba(0, 0, 0, .34), 0 10px 26px rgba(0, 0, 0, .3);
  }
}

:root[data-theme="dark"] {
  --paper: #101319;
  --surface: #181c23;
  --surface-2: #1e232b;
  --ink: #e9edf3;
  --ink-2: #9aa3b2;
  --ink-3: #8b95a4;
  --line: #2b313b;
  --line-2: #232830;
  --ok: #6cc396;   --ok-bg: #16281f;   --ok-line: #2c4b3a;
  --bad: #e5907a;  --bad-bg: #2c1d19;  --bad-line: #4d3229;
  --focus: #e9edf3;
  --math-ink: #8fb6ec;  --math-bg: #182233;  --math-solid: #2c5fa8;
  --sv-ink:   #e9a077;  --sv-bg:   #2a1e17;  --sv-solid:   #9c4718;
  --en-ink:   #bda3e8;  --en-bg:   #221d2e;  --en-solid:   #6a3fa0;
  --no-ink:   #83c69e;  --no-bg:   #172619;  --no-solid:   #256440;
  --so-ink:   #d8b464;  --so-bg:   #282112;  --so-solid:   #855a0d;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .3), 0 2px 8px rgba(0, 0, 0, .24);
  --shadow-2: 0 2px 4px rgba(0, 0, 0, .34), 0 10px 26px rgba(0, 0, 0, .3);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 1.75rem 1.15rem 4rem;
  background: var(--paper);
  color: var(--ink);
  font: 400 17px/1.65 Geist, "Helvetica Neue", -apple-system, BlinkMacSystemFont, sans-serif;
  -webkit-text-size-adjust: 100%;
}

/* A whisper of grain, so large flat fields don't read as sterile. */
body::before {
  content: "";
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  opacity: .35;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='.045'/%3E%3C/svg%3E");
}
.sheet { position: relative; z-index: 1; }

.sheet { max-width: var(--sheet); margin: 0 auto; }

h1 {
  font-family: Chivo, Geist, sans-serif;
  font-size: clamp(1.9rem, 5vw, 2.35rem); font-weight: 900;
  line-height: 1.04; letter-spacing: -.025em; margin: 0 0 .3rem;
  text-wrap: balance;
}
h2 { font-family: Chivo, Geist, sans-serif; font-size: 1.1rem; font-weight: 700; letter-spacing: -.012em; margin: 0; }
h3 { font-size: 1rem; font-weight: 600; margin: 0 0 .4rem; }
h4 { font-size: 1rem; font-weight: 600; margin: 0 0 .5rem; }
a { color: var(--ink); }
.icon { flex: none; }

/* ---------- Page heads ---------- */

.site-head, .day-head { margin-bottom: 1.5rem; }
.tagline, .day-meta { color: var(--ink-2); margin: 0; font-size: .96rem; }
.back {
  display: inline-flex; align-items: center; gap: .3rem;
  font-size: .88rem; font-weight: 500; color: var(--ink-2);
  text-decoration: none; margin-bottom: .85rem;
}
.back:hover { color: var(--ink); }
.page-badge {
  display: inline-flex; align-items: center; gap: .4rem;
  font-size: .76rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  padding: .28rem .55rem .28rem .45rem; border-radius: var(--r-chip);
  margin-bottom: .6rem;
}
.subject-page--math .page-badge { background: var(--math-bg); color: var(--math-ink); }
.subject-page--sv   .page-badge { background: var(--sv-bg);   color: var(--sv-ink); }
.subject-page--en   .page-badge { background: var(--en-bg);   color: var(--en-ink); }
.subject-page--no   .page-badge { background: var(--no-bg);   color: var(--no-ink); }
.subject-page--so   .page-badge { background: var(--so-bg);   color: var(--so-ink); }

.day-note {
  margin: 1rem 0 0; padding: .85rem 1rem;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-container); box-shadow: var(--shadow-1);
  font-size: .94rem; color: var(--ink-2);
}

/* ---------- Home: hero, doors, subject strip ---------- */

.hero {
  display: grid; gap: .55rem;
  padding: 1.6rem 1.6rem 1.4rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-container);
  box-shadow: var(--shadow-2);
  text-decoration: none; color: inherit;
  margin-bottom: 1rem;
  transition: transform .18s ease, box-shadow .18s ease;
}
.hero:hover { transform: translateY(-2px); }
.hero:active { transform: translateY(0); }
.hero-eyebrow { font-size: .78rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); }
.hero-title {
  font-family: Chivo, Geist, sans-serif; font-size: clamp(1.45rem, 4vw, 1.85rem);
  font-weight: 900; line-height: 1.1; letter-spacing: -.022em; text-wrap: balance;
}
.hero-go {
  display: inline-flex; align-items: center; gap: .4rem;
  margin-top: .3rem; font-size: .93rem; font-weight: 600; color: var(--ink-2);
}
.hero:hover .hero-go { color: var(--ink); }
.hero--empty { color: var(--ink-2); }

.doors { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; margin-bottom: 2rem; }
@media (max-width: 560px) { .doors { grid-template-columns: 1fr; } }
.door {
  display: grid; gap: .3rem; align-content: start;
  padding: 1.1rem 1.15rem;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-container); box-shadow: var(--shadow-1);
  text-decoration: none; color: inherit;
  transition: transform .18s ease, border-color .18s ease;
}
.door:hover { transform: translateY(-2px); }
.door:active { transform: translateY(0); }
.door .icon { margin-bottom: .35rem; }
.door--learn { color: var(--math-ink); }
.door--test  { color: var(--so-ink); }
.door-title { font-family: Chivo, Geist, sans-serif; font-size: 1.15rem; font-weight: 700; letter-spacing: -.015em; color: var(--ink); }
.door-sub { font-size: .88rem; line-height: 1.45; color: var(--ink-2); }

.strip { margin-bottom: 2rem; }
.strip-head {
  font-family: Geist, sans-serif; font-size: .78rem; font-weight: 600;
  letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3);
  margin: 0 0 .7rem;
}
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr)); gap: .6rem; }
.subject-tile {
  display: grid; gap: .15rem; align-content: start;
  padding: .85rem .9rem;
  border: 1px solid var(--line); border-radius: var(--r-row);
  background: var(--surface); text-decoration: none; color: inherit;
  transition: transform .16s ease;
}
.subject-tile:hover { transform: translateY(-2px); }
.subject-tile:active { transform: translateY(0); }
.subject-tile .icon { margin-bottom: .3rem; }
.tile-name { font-weight: 600; font-size: .96rem; }
.tile-count { font-size: .82rem; color: var(--ink-3); }
.subject-tile--math { color: var(--math-ink); } .subject-tile--math:hover { background: var(--math-bg); }
.subject-tile--sv   { color: var(--sv-ink); }   .subject-tile--sv:hover   { background: var(--sv-bg); }
.subject-tile--en   { color: var(--en-ink); }   .subject-tile--en:hover   { background: var(--en-bg); }
.subject-tile--no   { color: var(--no-ink); }   .subject-tile--no:hover   { background: var(--no-bg); }
.subject-tile--so   { color: var(--so-ink); }   .subject-tile--so:hover   { background: var(--so-bg); }
.tile-name, .tile-count { color: var(--ink); }
.tile-count { color: var(--ink-3); }

/* ---------- Lists: days, lessons ---------- */

.cards { list-style: none; margin: 0; padding: 0; display: grid; gap: .6rem; }
.card {
  display: flex; align-items: stretch;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-container); box-shadow: var(--shadow-1);
  overflow: hidden;
  transition: transform .16s ease;
}
.card:hover { transform: translateY(-2px); }
.card--today { border-color: var(--no-ink); box-shadow: var(--shadow-2); }
.card-link { flex: 1; display: grid; gap: .28rem; padding: .95rem 1.1rem; text-decoration: none; color: inherit; }
.card-date { font-size: .82rem; color: var(--ink-3); }
.card-date em { color: var(--no-ink); font-style: normal; font-weight: 600; }
.card-title { font-weight: 600; }
.card-sub { font-size: .88rem; color: var(--ink-2); }
.card-pdf {
  display: grid; place-items: center; padding: 0 1rem;
  border-left: 1px solid var(--line);
  font-size: .74rem; font-weight: 600; letter-spacing: .06em;
  color: var(--ink-3); text-decoration: none;
}
.card-pdf:hover { background: var(--surface-2); color: var(--ink); }

/* Lessons are siblings, not a hierarchy — a divided list, not five cards. */
.rows {
  list-style: none; margin: 0; padding: 0;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-container); overflow: hidden; box-shadow: var(--shadow-1);
}
.row + .row { border-top: 1px solid var(--line-2); }
.row-link {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: .9rem;
  padding: .95rem 1.1rem; text-decoration: none; color: inherit;
}
.row-link:hover { background: var(--surface-2); }
.row-num {
  font-family: Chivo, sans-serif; font-size: .82rem; font-weight: 700;
  color: var(--ink-3); font-variant-numeric: tabular-nums;
}
.subject-page--math .row-num { color: var(--math-ink); }
.subject-page--sv   .row-num { color: var(--sv-ink); }
.subject-page--en   .row-num { color: var(--en-ink); }
.subject-page--no   .row-num { color: var(--no-ink); }
.subject-page--so   .row-num { color: var(--so-ink); }
.row-text { display: grid; gap: .12rem; min-width: 0; }
.row-title { font-weight: 600; }
.row-sub { font-size: .88rem; color: var(--ink-2); line-height: 1.45; }
.row-go { color: var(--ink-3); }
.row-link:hover .row-go { color: var(--ink); }

.chips { display: flex; flex-wrap: wrap; gap: .3rem; }
.chip {
  font-size: .76rem; font-weight: 600;
  padding: .18rem .5rem; border-radius: var(--r-chip);
}
.chip--math { background: var(--math-bg); color: var(--math-ink); }
.chip--sv   { background: var(--sv-bg);   color: var(--sv-ink); }
.chip--en   { background: var(--en-bg);   color: var(--en-ink); }
.chip--no   { background: var(--no-bg);   color: var(--no-ink); }
.chip--so   { background: var(--so-bg);   color: var(--so-ink); }

.badge {
  font-size: .74rem; font-weight: 600;
  padding: .18rem .5rem; border-radius: var(--r-chip);
  background: var(--line-2); color: var(--ink-2);
}
.badge--started { background: var(--so-bg); color: var(--so-ink); }
.badge--all { background: var(--ok-bg); color: var(--ok); }

.empty { color: var(--ink-2); }
code { background: var(--line-2); padding: .1rem .35rem; border-radius: var(--r-chip); font-size: .9em; }

/* ---------- Subject sections on a worksheet ---------- */

.subject {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-container);
  box-shadow: var(--shadow-1);
  padding: 1.35rem;
  margin-bottom: 1.1rem;
  overflow: hidden;
}
.subject-head {
  display: flex; align-items: baseline; gap: .6rem; flex-wrap: wrap;
  margin: -1.35rem -1.35rem 1.25rem;
  padding: .8rem 1.35rem;
  border-bottom: 1px solid var(--line);
}
.subject--math .subject-head { background: var(--math-bg); }
.subject--sv   .subject-head { background: var(--sv-bg); }
.subject--en   .subject-head { background: var(--en-bg); }
.subject--no   .subject-head { background: var(--no-bg); }
.subject--so   .subject-head { background: var(--so-bg); }
.subject--math .subject-head h2 { color: var(--math-ink); }
.subject--sv   .subject-head h2 { color: var(--sv-ink); }
.subject--en   .subject-head h2 { color: var(--en-ink); }
.subject--no   .subject-head h2 { color: var(--no-ink); }
.subject--so   .subject-head h2 { color: var(--so-ink); }
.subject-sub { margin: 0; font-size: .88rem; font-weight: 400; color: var(--ink-2); }
.intro { margin: 0 0 1.1rem; color: var(--ink-2); }

/* ---------- Exercises ---------- */

.ex { margin: 0 0 1.7rem; }
.ex:last-child { margin-bottom: 0; }
.q { margin: 0 0 .45rem; }
.qn { font-weight: 700; color: var(--ink-3); margin-right: .2rem; font-variant-numeric: tabular-nums; }
.instruction { margin: 0 0 .6rem; font-weight: 600; }
.gloss { margin: .2rem 0 .5rem; font-size: .86rem; color: var(--ink-3); }

.passage {
  background: var(--surface-2);
  border: 1px solid var(--line-2);
  border-radius: var(--r-row);
  padding: 1.05rem 1.15rem; margin-bottom: 1.35rem;
}
.passage p { margin: 0 0 .7rem; max-width: 62ch; }
.passage p:last-child { margin-bottom: 0; }

input.ans, select.ans, textarea.free {
  font: inherit; color: inherit;
  background: var(--surface-2);
  border: 1.5px solid var(--line);
  border-radius: var(--r-chip);
  padding: .42rem .6rem;
  transition: border-color .14s ease;
}
input.ans:hover, select.ans:hover { border-color: var(--ink-3); }
input.ans:focus, select.ans:focus, textarea.free:focus,
.opt:focus-visible, .btn:focus-visible, .themebtn:focus-visible,
.row-link:focus-visible, .subject-tile:focus-visible, .hero:focus-visible, .door:focus-visible {
  outline: 2.5px solid var(--focus); outline-offset: 2px;
}
input.ans { width: 6.5rem; }
input.ans-num { width: 5rem; text-align: center; font-variant-numeric: tabular-nums; }
input.ans-inline { width: 8rem; }
input.ans-ord { width: 2.75rem; text-align: center; }
select.ans-select { max-width: 100%; }
textarea.free { width: 100%; resize: vertical; }
.unit { color: var(--ink-3); margin-left: .35rem; font-size: .9rem; }

input.ans.is-ok, select.ans.is-ok { border-color: var(--ok-line); background: var(--ok-bg); }
input.ans.is-bad, select.ans.is-bad { border-color: var(--bad-line); background: var(--bad-bg); }
.spellhint { margin-left: .5rem; font-size: .84rem; color: var(--ok); }
.spellhint strong { font-weight: 700; }

/* The answer key, once a parent has opened it for the day. Deliberately quiet:
   it sits beside the box she typed in, not in place of her answer. */
.facit { margin-left: .5rem; font-size: .84rem; color: var(--ink-2); }
.facit strong { font-weight: 700; color: var(--ink); }
.opt.is-facit { border-color: var(--ok-line); }
.facit-note {
  margin: 0 0 1rem; padding: .7rem .9rem; border-radius: 12px;
  background: var(--ok-bg); color: var(--ok); font-size: .92rem;
}

.calc-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr));
  gap: .85rem 1rem; margin: 0; padding-left: 1.4rem;
}
.calc-item { padding-left: .2rem; }
.calc-q { font-variant-numeric: tabular-nums; margin-right: .3rem; }

.options { list-style: none; margin: 0; padding: 0; display: grid; gap: .4rem; }
.opt {
  font: inherit; text-align: left; width: 100%;
  padding: .62rem .85rem;
  background: var(--surface-2); color: inherit;
  border: 1.5px solid var(--line); border-radius: var(--r-row);
  cursor: pointer;
  transition: border-color .14s ease, transform .1s ease;
}
.opt:hover { border-color: var(--ink-3); }
.opt:active { transform: scale(.99); }
.opt.picked { border-color: var(--ink); background: var(--surface); font-weight: 600; }
.opt.is-ok { border-color: var(--ok-line); background: var(--ok-bg); }
.opt.is-bad { border-color: var(--bad-line); background: var(--bad-bg); }
.verdict { font-size: .86rem; font-weight: 600; }
.verdict.ok { color: var(--ok); }
.verdict.bad { color: var(--bad); }

.match-web { margin: 0; padding-left: 1.4rem; display: grid; gap: .5rem; }
.match-row { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.m-term { min-width: 7rem; font-weight: 600; }
.order-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.order-row { display: flex; align-items: center; gap: .7rem; }

/* ---------- Teaching blocks ---------- */

.teach {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-left: 3px solid var(--ink-3);
  border-radius: var(--r-row);
  padding: 1.15rem 1.25rem;
  margin: 0 0 1.5rem;
}
.teach h4 { margin: 0 0 .75rem; display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; font-size: 1.02rem; }
.teach-tag {
  font-size: .68rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
  background: var(--ink); color: var(--paper);
  padding: .2rem .5rem; border-radius: var(--r-chip);
}
.teach-steps { margin: 0; padding-left: 1.25rem; display: grid; gap: .35rem; }
.teach-steps li { padding-left: .15rem; max-width: 60ch; }

.fig-wrap { margin: 1rem 0 .3rem; }
.fig-wrap--multi { display: grid; gap: .5rem; }
svg.fig { display: block; width: auto; max-width: 100%; height: auto; color: var(--ink); }
svg.fig .shade { fill: var(--surface); }
svg.fig .shade-on { fill: var(--ink); }
svg.fig .fig-label { fill: currentColor; font-size: 13px; font-family: inherit; }
svg.fig .fig-num { fill: currentColor; font-size: 15px; font-weight: 600; font-family: inherit; }
svg.fig .fig-num--filled { fill: var(--paper); }

.worked {
  margin-top: 1rem; padding: .8rem .95rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-row);
}
.worked-q { margin: 0 0 .4rem; font-weight: 600; }
.worked-steps { margin: 0; padding-left: 1.25rem; display: grid; gap: .25rem; }

/* ---------- Buttons, status, sticky bar ---------- */

.actions { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: 1.6rem; }
.btn {
  font: inherit; font-weight: 600;
  padding: .6rem 1.05rem; border-radius: var(--r-row); cursor: pointer;
  background: var(--ink); color: var(--paper); border: 1.5px solid var(--ink);
  text-decoration: none; display: inline-block;
  transition: transform .12s ease, opacity .14s ease;
}
.btn:hover { opacity: .88; }
.btn:active { transform: translateY(1px); }
.btn-ghost { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: var(--surface-2); opacity: 1; border-color: var(--ink-3); }
.btn-sm { padding: .5rem .85rem; font-size: .9rem; }

.score {
  margin-top: 1.3rem; padding: 1rem 1.15rem;
  border-radius: var(--r-container); background: var(--surface);
  border: 1px solid var(--line); box-shadow: var(--shadow-1); font-weight: 600;
}
.score.all-right { border-color: var(--ok-line); background: var(--ok-bg); color: var(--ok); }
.score-note { display: block; font-weight: 400; color: var(--ink-2); margin-top: .3rem; font-size: .9rem; }
.score.all-right .score-note { color: inherit; }
.sync { margin: .5rem 0 0; font-size: .82rem; color: var(--ink-3); }
.sync--bad { color: var(--bad); font-weight: 600; }

.resume {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-container);
  box-shadow: var(--shadow-1);
  padding: 1.05rem 1.15rem;
  margin: 0 0 1.5rem;
}
.resume-text { margin: 0 0 .8rem; }
.resume-actions { display: flex; gap: .6rem; flex-wrap: wrap; }

.stickybar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; align-items: center; gap: .75rem;
  padding: .65rem 1rem calc(.65rem + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--surface) 97%, transparent);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.stickybar-status { font-size: .86rem; font-weight: 500; color: var(--ink-2); min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stickybar-status.is-saved { color: var(--ok); }
.stickybar-buttons { display: flex; gap: .5rem; flex: none; order: -1; }
body:has(.stickybar:not([hidden])) { padding-bottom: 6rem; }

.pooled { margin-bottom: 1.6rem; }
.pooled:last-child { margin-bottom: 0; }

/* ---------- Answer key, parent links, theme ---------- */

.answer-key { margin-top: 2rem; }
.key-note { font-weight: 400; font-size: .85rem; color: var(--ink-3); }
.key-block { margin-top: 1rem; }
.key-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .3rem; font-size: .9rem; }

.parent-links { margin-top: 2.5rem; font-size: .8rem; color: var(--ink-3); }
.parent-links a { color: var(--ink-3); margin-right: .1rem; }
.parent-links a:hover { color: var(--ink); }
#backup-status { display: block; margin-top: .4rem; color: var(--ok); }
#backup-status.backup-status--bad { color: var(--bad); font-weight: 600; }

.themebar { display: flex; gap: .3rem; }
.note-text { color: var(--ink-2); line-height: 1.6; }
.themebtn {
  font: inherit; font-size: .78rem; font-weight: 500;
  padding: .3rem .6rem;
  color: var(--ink-3); background: transparent;
  border: 1px solid transparent; border-radius: var(--r-chip); cursor: pointer;
  transition: color .14s ease;
}
.themebtn:hover { color: var(--ink); background: var(--surface); }
.themebtn[aria-pressed="true"] { background: var(--surface); color: var(--ink); border-color: var(--line); font-weight: 600; }

/* An answer waiting on a second opinion. It has already been marked red by the
   strict check, so this only says "still looking" — it must not read as a new
   verdict, and if the request never returns the red simply stays. */
.ans.is-checking {
  border-color: var(--ink-3);
  background-image: linear-gradient(90deg, transparent 0%, var(--surface-2) 50%, transparent 100%);
  background-size: 200% 100%;
  animation: checking 1.1s var(--m-symmetric) infinite;
}
@keyframes checking { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .ans.is-checking { animation: none; } }

/* ------------------------------------------------------------------
   Bottom navigation
   ------------------------------------------------------------------ */

.navbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  padding: 0 1rem calc(.65rem + env(safe-area-inset-bottom));
  pointer-events: none;
}
.navpill {
  pointer-events: auto;
  position: relative;
  max-width: var(--sheet); margin: 0 auto;
  height: 64px;
  display: flex; align-items: stretch;
  background: var(--surface);
  /* The border is what keeps the pill's edge visible in dark mode, where a
     shadow alone disappears into the background. */
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow-2);
}

/* One highlight, owned by the bar rather than by an item. An item can only
   fade its own background in and out; travelling from one slot to another is
   something only the parent can express — and with a cross-document view
   transition it does travel, because this element keeps its identity across
   the navigation. Without that support it simply appears in the right place. */
.navhl {
  position: absolute; top: 6px; bottom: 6px;
  left: 0; width: 25%;
  transform: translateX(calc(var(--slot) * 100%));
  padding: 0 6px;                 /* tracks the slot instead of guessing a width */
  background-clip: content-box;
  background: color-mix(in srgb, var(--math-ink) 12%, transparent);
  border-radius: var(--r-row);
  view-transition-name: navhl;
}

.navitem {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px;
  font: inherit; font-size: .7rem; font-weight: 600;
  color: var(--ink-3);
  text-decoration: none;
  background: transparent; border: 0; cursor: pointer;
  border-radius: var(--r-row);
  transition: color var(--m-fast) var(--m-curve);
}
.navitem .icon { width: 22px; height: 22px; }
.navlabel { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.navitem:hover { color: var(--ink-2); }
.navitem.is-active { color: var(--math-ink); font-weight: 800; }
 /* Framsteg is not built yet, but it IS tappable, so it has to be readable.
    The sister app dims this tab's label and icon to 45% — measured on our
    palette that lands at 2.11:1 in light mode, and no alpha below 100% reaches
    4.5:1 there at all. So the label keeps full inactive contrast and only the
    icon is de-emphasised, to 80% (3.22:1 light / 4.10:1 dark, clearing the 3:1
    minimum for non-text). What it is comes from the tap, not from being too
    faint to read. */
.navitem--soon { color: var(--ink-3); }
.navitem--soon .icon { opacity: .8; }

/* The pop fires on arrival at the active tab. Colour and weight carry the
   selection on their own, so suppressing this loses nothing but the flourish. */
.navitem.is-active .icon { animation: navpop calc(var(--m-fast) + var(--m-base)) var(--m-curve); }
@keyframes navpop {
  0%   { transform: scale(1); }
  35%  { transform: scale(1.18); }
  /* Settles just under 1 before coming to rest — an overshoot on the way down
     is what reads as a settle rather than a stop. */
  70%  { transform: scale(.97); }
  100% { transform: scale(1); }
}

/* Clear the bar. Without this the last row of any list sits under it. */
body.has-nav { padding-bottom: calc(64px + 2.4rem + env(safe-area-inset-bottom)); }

.navtoast {
  position: fixed; left: 50%; z-index: 50;
  bottom: calc(64px + 1.6rem + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  max-width: min(22rem, calc(100vw - 2rem));
  padding: .6rem .9rem;
  font-size: .85rem; line-height: 1.4;
  color: var(--surface); background: var(--ink);
  border-radius: var(--r-row); box-shadow: var(--shadow-2);
  animation: toastin var(--m-base) var(--m-curve);
}
@keyframes toastin { from { opacity: 0; transform: translate(-50%, 6px); } }

/* The worksheets print from their own pages, which never carry the bar — but a
   browse page can still reach a printer, and a floating pill across the bottom
   of the paper is nobody's idea of a homework sheet. */
@media print {
  .navbar { display: none; }
  body.has-nav { padding-bottom: 0; }
}

@view-transition { navigation: auto; }
::view-transition-group(navhl) {
  animation-duration: var(--m-base);
  animation-timing-function: var(--m-symmetric);
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  .hero:hover, .door:hover, .card:hover, .subject-tile:hover { transform: none; }
  @view-transition { navigation: none; }
}

@media (max-width: 480px) {
  body { padding: 1.1rem .8rem 3rem; }
  .subject { padding: 1.1rem; }
  .subject-head { margin: -1.1rem -1.1rem 1.1rem; padding: .7rem 1.1rem; }
  .calc-grid { grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr)); }
  .stickybar { padding-left: .8rem; padding-right: .8rem; }
  .hero { padding: 1.3rem 1.2rem 1.15rem; }
}
