/* Shared styles for every page. No external fonts or CDNs (school web filters). */

:root {
  /* "Bold and chunky": cream background, white cards with thick dark outlines
     and a solid offset shadow, so everything looks like a button you can press */
  --bg: #fff8e7;
  --surface: #ffffff;
  --text: #1d1442;
  --muted: #554a7a;
  --border: #d8cfe8;          /* thin inner lines: tables, empty drop slots */
  --edge: #1d1442;            /* thick outline on cards and buttons */
  --edge-w: 3px;
  --pop-colour: #1d1442;      /* the offset shadow behind cards and buttons */
  --pop: 4px 4px 0 var(--pop-colour);
  --pop-sm: 3px 3px 0 var(--pop-colour);
  --lift: var(--pop-colour);
  --grid: rgba(29, 20, 66, 0.06);
  --accent: #5b2bd6;
  --accent-text: #ffffff;
  --radius: 16px;
  --tap: 44px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  /* Avenir Next ships with every iPad; other devices fall back to their system font */
  --font-head: "Avenir Next", Avenir, "Segoe UI Variable Display", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;

  /* Header bar: purple in both themes */
  --ink: #5b2bd6;
  --ink-2: #4520b0;
  --ink-text: #ffffff;
  --ink-muted: #ddd3ff;

  /* Feedback: blue-green vs amber stays distinct for red/green colour blindness,
     and always comes with words, so colour is never the only cue */
  --good: #0f766e;
  --good-bg: #e6f4f1;
  --bad: #b45309;
  --bad-bg: #fdf1e3;

  /* One colour per level, all paired with a text label so colour is never the only cue */
  --bge: #0f766e;
  --n4: #6d28d9;
  --n5: #1f4fd1;
  --higher: #b45309;
  --ah: #be185d;
  --on-level: #ffffff;        /* text on a filled level colour */

  /* Brighter level colours for the dark header bar (same in both themes) */
  --bge-bright: #2dd4bf;
  --n4-bright: #b49cfc;
  --n5-bright: #8fb0ff;
  --higher-bright: #fbbf24;
  --ah-bright: #f68cc4;
  --starters-bright: #a3e635;   /* the Starters tab, which is no one level */
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14102a;
    --surface: #211b3f;
    --text: #f3efff;
    --muted: #b7aee0;
    --border: #3a3266;
    --edge: #7d6ee0;
    --pop-colour: #05030d;
    --grid: rgba(243, 239, 255, 0.05);
    --accent: #b8a6ff;
    --accent-text: #14102a;
    --ink: #3a22a0;
    --ink-2: #2a1878;
    --good: #2dd4bf;
    --good-bg: #10302d;
    --bad: #fbbf24;
    --bad-bg: #3a2a0c;
    --bge: #2dd4bf;
    --n4: #b49cfc;
    --n5: #8fb0ff;
    --higher: #fbbf24;
    --ah: #f68cc4;
    --on-level: #10131d;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 1.125rem;
  line-height: 1.5;
}

h1, h2, h3 { font-family: var(--font-head); font-weight: 700; }
h1 { font-weight: 800; }

a { color: var(--accent); }

.wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Level colour lookup: any element with data-level sets --level-colour for its children */
[data-level="bge"]    { --level-colour: var(--bge);    --level-bright: var(--bge-bright); }
[data-level="n4"]     { --level-colour: var(--n4);     --level-bright: var(--n4-bright); }
[data-level="n5"]     { --level-colour: var(--n5);     --level-bright: var(--n5-bright); }
[data-level="higher"] { --level-colour: var(--higher); --level-bright: var(--higher-bright); }
[data-level="ah"]     { --level-colour: var(--ah);     --level-bright: var(--ah-bright); }

/* Header: brand on the left, one big button per level on the right */
.site-header {
  background: var(--ink);
  color: var(--ink-text);
  border-bottom: var(--edge-w) solid var(--pop-colour);
}
.site-header .wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 24px;
  padding-top: 12px;
  padding-bottom: 12px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: var(--tap);
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 1.35rem;
  color: var(--ink-text);
  text-decoration: none;
  letter-spacing: -0.01em;
}
.brand span { color: var(--ink-muted); font-weight: 500; }
.brand svg { width: 34px; height: 22px; flex: none; }

.level-nav ul {
  display: flex;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.level-nav a {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 64px;
  min-height: 48px;
  padding: 6px 16px;
  border: var(--edge-w) solid var(--pop-colour);
  border-radius: var(--radius);
  background: var(--ink-2);
  box-shadow: inset 0 -5px 0 var(--level-bright), var(--pop-sm);
  color: var(--ink-text);
  font-family: var(--font-head);
  font-size: 1.05rem;
  font-weight: 700;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.level-nav a[aria-current="page"] {
  background: var(--level-bright);
  box-shadow: var(--pop-sm);
  color: #1d1442;
}
.level-nav a:active { transform: translate(3px, 3px); box-shadow: none; }
/* The Starters tab (the question bank, every level), set apart from the levels */
.level-nav .nav-starters { --level-bright: var(--starters-bright); margin-left: 8px; }
@media (max-width: 640px) {
  .level-nav { flex: 1 1 100%; }
  .level-nav a { min-width: 0; padding: 6px 4px; }
  .level-nav li { flex: 1; }
  .level-nav .nav-starters { flex: 1.6; margin-left: 0; }
}

/* Tools at the end of the header (toolbar.js): the level buttons and tools sit together on the right.
   On a phone the level buttons take a row of their own, so the tools go up beside the brand. */
.site-header .wrap.has-tools { column-gap: 12px; }
.site-header .wrap.has-tools .level-nav { margin-left: auto; }
.site-tools { display: flex; gap: 8px; }
.site-tool {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 48px;
  min-height: 48px;
  padding: 6px 12px;
  border: var(--edge-w) solid var(--pop-colour);
  border-radius: var(--radius);
  background: var(--ink-2);
  box-shadow: var(--pop-sm);
  color: var(--ink-text);
  font-family: var(--font-head);
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.site-tool svg { width: 22px; height: 22px; flex: none; }
.site-tool:active { transform: translate(3px, 3px); box-shadow: none; }
/* iPad portrait: icons only, so the header stays on one line */
@media (max-width: 960px) {
  .site-tool { padding: 6px 10px; }
  .site-tool span { display: none; }
}
@media (min-width: 641px) and (max-width: 960px) {
  .has-tools .level-nav a { min-width: 52px; padding: 6px 11px; }
}
@media (max-width: 640px) {
  .site-header .wrap.has-tools .level-nav { order: 2; margin-left: 0; }
  .site-tools { order: 1; margin-left: auto; }
}
@media print { .site-tools { display: none; } }
/* A QR link to a part of the page scrolls its heading near the top, with a little room above it */
main h2 { scroll-margin-top: 28px; }

/* The QR box for the page (toolbar.js): big enough to scan from the back of the room */
.page-qr {
  width: min(600px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  padding: 20px 22px;
  border: var(--edge-w) solid var(--edge);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--pop);
  color: var(--text);
}
.page-qr::backdrop { background: rgba(29, 20, 66, 0.55); }
.page-qr-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.page-qr-head h2 { margin: 0; font-size: 1.4rem; }
.page-qr-code {
  display: block;
  width: min(100%, calc(100vh - 330px));
  min-width: 220px;
  height: auto;
  margin: 14px auto 10px;
  border-radius: 8px;
}
.page-qr-at { display: flex; align-items: center; gap: 10px; margin: 0 0 6px; font-weight: 700; }
.page-qr-at[hidden] { display: none; }
.page-qr-at select {
  flex: 1;
  min-width: 0;
  min-height: var(--tap);
  padding: 0 10px;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 400;
}
.page-qr-where { margin: 0 0 12px; padding: 0; border: 0; }
.page-qr-where legend { padding: 0; margin-bottom: 4px; font-weight: 700; }
.page-qr-where label { display: flex; align-items: center; gap: 10px; min-height: var(--tap); cursor: pointer; }
.page-qr-where input { width: 20px; height: 20px; margin: 0; accent-color: var(--accent); }
.page-qr-link { display: flex; flex-wrap: wrap; gap: 10px; }
.page-qr-link input {
  flex: 1 1 200px;
  min-width: 0;
  min-height: var(--tap);
  padding: 0 12px;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  font: inherit;
  font-size: 0.9rem;
  color: var(--muted);
}
.page-qr-btn {
  min-height: var(--tap);
  padding: 8px 16px;
  border: var(--edge-w) solid var(--edge);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--pop-sm);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.page-qr-btn:active { transform: translate(3px, 3px); box-shadow: none; }
.page-qr-note { margin: 10px 0 0; font-size: 0.9rem; color: var(--muted); }
/* A wide screen (an iPad in landscape, the board): the choices sit beside the code, so it all fits without scrolling */
@media (min-width: 760px) and (min-aspect-ratio: 1/1) {
  .page-qr { width: min(980px, calc(100vw - 32px)); }
  .page-qr-body { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 24px; margin-top: 14px; }
  .page-qr-code { width: min(calc(100vh - 140px), 500px); min-width: 0; margin: 0; }
  .page-qr-at { flex-direction: column; align-items: stretch; gap: 4px; }
  .page-qr-at select { flex: none; width: 100%; }
  .page-qr-link input { flex-basis: 100%; }
}

/* The calculator (calc.js): a pop-out panel laid out like the class Casio. The screen is an LCD in both themes. */
.calc {
  position: fixed;
  z-index: 50;
  top: 84px;
  right: 16px;
  width: 340px;
  max-height: calc(100vh - 16px);
  overflow-y: auto;
  padding: 0 12px 12px;
  border: var(--edge-w) solid var(--edge);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--pop);
  color: var(--text);
  font-family: var(--font);
  -webkit-user-select: none;
  user-select: none;
}
.calc[hidden] { display: none; }
.calc:focus { outline: none; }
.cx-bar { display: flex; align-items: center; gap: 10px; min-height: 44px; cursor: grab; touch-action: none; }
.cx-bar:active { cursor: grabbing; }
.cx-bar h2 { flex: 1; margin: 0; font-size: 1.05rem; }
.cx-grip { width: 28px; height: 6px; border-radius: 3px; background: var(--border); }
.cx-close {
  min-height: 40px;
  padding: 0 14px;
  border: 2px solid var(--edge);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.cx-screen {
  position: relative;
  margin-bottom: 10px;
  padding: 6px 10px 8px;
  border: 3px solid #1d1442;
  border-radius: 10px;
  background: #d9e2cc;
  color: #14180f;
  cursor: text;
}
.cx-flags { display: flex; gap: 10px; min-height: 1em; font-size: 0.75rem; font-weight: 700; line-height: 1; }
.cx-flags [hidden] { display: none; }
.cx-sum {
  min-height: 2.4rem;
  overflow-x: auto;
  overflow-y: hidden;
  white-space: nowrap;
  font-size: 1.3rem;
  line-height: 2.4rem;
  scrollbar-width: none;
}
.cx-sum::-webkit-scrollbar { display: none; }
.cx-out { min-height: 2.4rem; text-align: right; white-space: nowrap; overflow-x: auto; font-size: 1.75rem; font-weight: 700; line-height: 2.4rem; scrollbar-width: none; }
.cx-error { font-size: 1.3rem; }
.cx-said { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); margin: 0; }
.cx-op { margin: 0 0.12em; }
.cx-frac { display: inline-flex; flex-direction: column; align-items: center; vertical-align: middle; margin: 0 0.12em; line-height: 1.15; font-size: 0.85em; }
.cx-frac > span { padding: 0 0.15em; }
.cx-frac > span:first-child { border-bottom: 2px solid currentColor; }
.cx-sum sup, .cx-out sup { font-size: 0.62em; line-height: 1; vertical-align: 0.75em; }
.cx-idx { margin-right: -0.35em; }
.cx-sqrt { display: inline-flex; align-items: stretch; vertical-align: middle; line-height: 1.3; }
.cx-rad { padding-right: 1px; }
.cx-under { border-top: 2px solid currentColor; padding: 0 0.1em; }
.cx-slot { display: inline-block; width: 0.62em; height: 0.85em; vertical-align: middle; border: 2px dotted currentColor; opacity: 0.55; position: relative; }
.cx-slot.is-here { opacity: 1; }
.cx-slot .cx-cur { position: absolute; left: 1px; top: 0; height: 100%; margin: 0; }
.cx-cur { display: inline-block; width: 2px; height: 1.1em; margin: 0 -1px; vertical-align: middle; background: currentColor; }
@media (prefers-reduced-motion: no-preference) {
  .cx-cur { animation: cx-blink 1s steps(1) infinite; }
  @keyframes cx-blink { 50% { opacity: 0; } }
}

.cx-key, .cx-arrows button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 0;
  padding: 2px 2px 4px;
  border: 2px solid var(--edge);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 3px 0 var(--pop-colour);
  color: var(--text);
  font: inherit;
  font-weight: 700;
  line-height: 1.1;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.cx-key:active, .cx-arrows button:active { transform: translateY(3px); box-shadow: none; }
.cx-main { font-size: 0.95rem; }
.cx-main sup { font-size: 0.7em; }
.cx-sh { font-size: 0.66rem; font-weight: 700; color: var(--accent); min-height: 0.8rem; }
.cx-key.is-shifted .cx-sh { background: var(--accent); color: var(--accent-text); border-radius: 4px; padding: 0 3px; }
.cx-key-frac { font-size: 1em; line-height: 1; }
.cx-key-frac > span:first-child { border-bottom-width: 1.5px; }
.cx-top { display: grid; grid-template-columns: 1fr 1.4fr 1fr; grid-template-rows: 48px 48px; gap: 6px 8px; margin-bottom: 8px; }
.cx-top > .cx-key:nth-of-type(1) { grid-area: 1 / 1; }
.cx-top > .cx-key:nth-of-type(2) { grid-area: 2 / 1; }
.cx-top > .cx-key:nth-of-type(3) { grid-area: 1 / 3; }
.cx-top > .cx-key:nth-of-type(4) { grid-area: 2 / 3; }
.cx-shift { background: var(--accent); color: var(--accent-text); }
.cx-shift[aria-pressed="true"] { box-shadow: none; transform: translateY(3px); outline: 3px solid var(--text); }
.cx-drg .cx-main { font-size: 0.8rem; }
.cx-arrows {
  grid-area: 1 / 2 / 3 / 3;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 2px;
}
.cx-arrows button { padding: 0; font-size: 0.8rem; border-radius: 8px; box-shadow: 0 2px 0 var(--pop-colour); }
.cx-arrows [data-k="up"] { grid-area: 1 / 2; }
.cx-arrows [data-k="left"] { grid-area: 2 / 1; }
.cx-arrows [data-k="right"] { grid-area: 2 / 3; }
.cx-arrows [data-k="down"] { grid-area: 3 / 2; }
.cx-fns { display: grid; grid-template-columns: repeat(12, 1fr); gap: 6px; margin-bottom: 10px; }
.cx-fns .cx-key { grid-column: span 2; min-height: 44px; background: var(--bg); }
.cx-fns .cx-wide { grid-column: span 3; }
.cx-pad { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.cx-pad .cx-key { min-height: 46px; }
.cx-pad .cx-main { font-size: 1.25rem; }
.cx-pad [data-k="e10"] .cx-main, .cx-pad [data-k="Ans"] .cx-main { font-size: 0.95rem; }
.cx-red { background: var(--bad-bg); color: var(--bad); border-color: var(--bad); }
.cx-red .cx-main { font-size: 1rem !important; }
.cx-eq { background: var(--accent); color: var(--accent-text); }

/* A phone: the calculator sits along the bottom of the screen, full width */
@media (max-width: 560px) {
  .calc { top: auto !important; left: 0 !important; right: 0; bottom: 0; width: auto; max-height: 82vh; border-radius: var(--radius) var(--radius) 0 0; }
  .cx-bar { cursor: default; }
  .cx-grip { display: none; }
}
@media print { .calc, .calc-fab { display: none !important; } }

/* The round calculator button once the header has scrolled away (pages with sums) */
.calc-fab {
  position: fixed;
  z-index: 40;
  right: 16px;
  bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border: var(--edge-w) solid var(--pop-colour);
  border-radius: 50%;
  background: var(--ink);
  box-shadow: var(--pop-sm);
  color: var(--ink-text);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.calc-fab[hidden] { display: none; }
.calc-fab svg { width: 26px; height: 26px; }
.calc-fab:active { transform: translate(3px, 3px); box-shadow: none; }

/* Page title panel, on faint squared paper */
.hero {
  margin: 24px 0 8px;
  padding: 32px 28px;
  border: var(--edge-w) solid var(--edge);
  border-radius: var(--radius);
  background-color: var(--surface);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 24px 24px;
  background-position: -1px -1px;
  border-left: 8px solid var(--level-colour, var(--ink));
}
.hero h1 {
  font-size: clamp(2rem, 5vw, 3rem);
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin: 0 0 10px;
}
.hero p {
  color: var(--muted);
  font-size: 1.25rem;
  max-width: 40em;
  margin: 0;
}

/* Cards and buttons share a solid bottom edge, so they look pressable */
.level,
.unit,
.starter-link {
  border: var(--edge-w) solid var(--edge);
  box-shadow: var(--pop);
}

/* Level cards (home page) */
.levels {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 18px;
  padding: 24px 0 56px;
  margin: 0;
  list-style: none;
}
.level {
  display: flex;
  align-items: stretch;
  gap: 18px;
  height: 100%;
  min-height: var(--tap);
  padding: 18px;
  background: var(--surface);
  border-radius: var(--radius);
  color: var(--text);
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}
a.level:active { transform: translate(4px, 4px); box-shadow: none; }
.level-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 76px;
  border-radius: 8px;
  background: var(--level-colour, var(--accent));
  color: var(--on-level);
  font-family: var(--font-head);
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.level-badge svg { width: 44px; height: 44px; }   /* icon badges on a level page */
.level-body { display: flex; flex-direction: column; gap: 4px; }
.level h2 { margin: 0; font-size: 1.45rem; line-height: 1.2; }
.level .stage { color: var(--muted); font-size: 1.05rem; }
.level .status {
  margin-top: auto;
  padding-top: 8px;
  font-size: 1rem;
  font-weight: 700;
  color: var(--level-colour, var(--accent));
}

/* Breadcrumb (starter pages): each step is a button-sized link */
.crumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 20px 0 0;
  padding: 0;
  list-style: none;
  font-size: 1rem;
}
.crumbs li { display: flex; align-items: center; gap: 8px; min-height: var(--tap); color: var(--muted); }
.crumbs li + li::before { content: "›"; font-size: 1.3rem; line-height: 1; }
.crumbs a {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  padding: 6px 14px;
  border: var(--edge-w) solid var(--edge);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--pop-sm);
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
}
.crumbs a:active { transform: translate(3px, 3px); box-shadow: none; }

/* Starters list: one section per unit */
.unit {
  margin: 0 0 20px;
  padding: 22px;
  background: var(--surface);
  border-radius: var(--radius);
}
.unit h2 { margin: 0; font-size: 1.5rem; }
.unit-num {
  display: table;
  margin-bottom: 6px;
  padding: 2px 10px;
  border-radius: 6px;
  background: var(--level-colour, var(--accent));
  color: var(--on-level);
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.unit-topics { margin: 6px 0 0; color: var(--muted); font-size: 1rem; }
.unit .empty { margin: 14px 0 0; color: var(--muted); font-style: italic; }
.units { padding: 16px 0 48px; }
/* A unit with starters is a <details>: closed until its header is tapped */
details.unit { padding: 0; }
.unit-summary {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 22px;
  cursor: pointer;
  list-style: none;
  -webkit-tap-highlight-color: transparent;
}
.unit-summary::-webkit-details-marker { display: none; }
.unit-summary:focus-visible { outline: 3px solid var(--level-colour, var(--accent)); outline-offset: 4px; border-radius: var(--radius); }
details.unit:has(> .unit-summary:active) { transform: translate(4px, 4px); box-shadow: none; }
.unit-head { flex: 1; min-width: 0; }
.unit-head .unit-topics { display: block; }
.unit-count {
  flex-shrink: 0;
  padding: 4px 12px;
  border: 2px solid var(--level-colour, var(--accent));
  border-radius: 999px;
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 700;
  white-space: nowrap;
}
/* Arrow drawn with two borders: points down when closed, up when open */
.unit-summary::after {
  content: "";
  flex-shrink: 0;
  width: 12px;
  height: 12px;
  margin: 0 6px 6px 0;
  border-right: 4px solid var(--text);
  border-bottom: 4px solid var(--text);
  transform: rotate(45deg);
  transition: transform 0.2s;
}
details[open] > .unit-summary::after { margin-top: 6px; margin-bottom: 0; transform: rotate(-135deg); }
details.unit > .starter-list { margin: 0; padding: 0 22px 22px; }
@media (max-width: 540px) {
  .unit-summary { flex-wrap: wrap; gap: 10px 16px; }
  .unit-head { flex-basis: 100%; }
  .unit-summary::after { margin-left: auto; }
}
@media (prefers-reduced-motion: reduce) {
  .unit-summary::after { transition: none; }
}

/* Tools section: sits above the units, marked with the level colour */

.starter-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
  margin: 16px 0 0;
  padding: 0;
  list-style: none;
}
.starter-link {
  display: flex;
  flex-direction: column;
  gap: 2px;
  height: 100%;
  min-height: var(--tap);
  padding: 14px 16px;
  border-left: 6px solid var(--level-colour, var(--accent));
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}
.starter-link:active { transform: translate(4px, 4px); box-shadow: none; }
.starter-link strong { font-family: var(--font-head); font-size: 1.2rem; }
.starter-link span { color: var(--muted); font-size: 0.95rem; }

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 1rem;
  padding: 24px 0 40px;
}

/* Generic centred message page (404 etc.) */
.message {
  padding: 80px 0;
  text-align: center;
}
.message h1 { font-size: 2.5rem; margin: 0 0 12px; }
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  min-width: var(--tap);
  padding: 10px 22px;
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
  text-decoration: none;
}
