/* Vitruvian — "laboratory notebook" theme.
   Warm paper, ink-navy text, one Prussian-blue accent (the pigment is itself a chemical — iron(III)
   hexacyanoferrate(II)), serif headings (Source Serif 4) over a clean sans (Inter), hairline rules and
   quiet shadows. Fonts are self-hosted from /fonts (SIL Open Font License); no third-party requests.
   Text colour pairs meet WCAG AA contrast. */
@font-face {
  font-family: "Inter Variable"; font-style: normal; font-display: swap; font-weight: 100 900;
  src: url(/fonts/inter.woff2) format("woff2-variations"), url(/fonts/inter.woff2) format("woff2");
}
@font-face {
  font-family: "Source Serif 4 Variable"; font-style: normal; font-display: swap; font-weight: 200 900;
  src: url(/fonts/source-serif-4.woff2) format("woff2-variations"), url(/fonts/source-serif-4.woff2) format("woff2");
}
@font-face {
  font-family: "Source Serif 4 Variable"; font-style: italic; font-display: swap; font-weight: 200 900;
  src: url(/fonts/source-serif-4-italic.woff2) format("woff2-variations"), url(/fonts/source-serif-4-italic.woff2) format("woff2");
}

:root {
  --paper: #f7f6f2;
  --surface: #ffffff;
  --surface-2: #fbfaf7;
  --ink: #14202e;
  --ink-2: #2b3746;
  --muted: #5a6472;
  --line: #e5e1d8;
  --line-strong: #d2ccbf;
  --accent: #1f4e79;
  --accent-dark: #163a5b;
  --accent-wash: #e8f0f6;
  --accent-soft: #c9dcea;
  --gold: #8a6416;
  --gold-wash: #f6edd8;
  --green: #2e6a3a;
  --green-wash: #e6f1e4;
  --red: #a2322a;
  --red-wash: #f9e7e4;
  --amber-wash: #f8eed4;
  --deep: #121c28;

  /* Tints and fixed colours that change with the theme (dark values further down). */
  --on-accent: #ffffff;
  --red-dark: #87271f;
  --red-line: #e6b8b2;
  --red-ink: #6e1f19;
  --green-line: #bcd8b8;
  --green-ink: #1f4a28;
  --amber: #a87a17;
  --amber-line: #e7d29e;
  --amber-ink: #5c410c;
  --gold-line: #e3cf9f;
  --link-line: rgba(31, 78, 121, 0.4);
  --code-bg: #f1eee7;
  --header-bg: rgba(247, 246, 242, 0.9);
  --hover-tint: rgba(20, 32, 46, 0.05);
  --input-hover: #b9b2a3;
  --focus-ring: rgba(31, 78, 121, 0.16);
  --invalid-bg: #fffaf9;
  --chip-bg: #efece5;
  --track: var(--track);
  --sticky-bg: rgba(255, 255, 255, 0.94);
  --tile-group: #f3f6f9;
  --row-bad: #fdf6f5;
  --row-hover: #fcfbf8;
  --tabs-bg: #ece9e1;
  --tab-hover: rgba(255, 255, 255, 0.55);
  --on-ink-muted: #c3ccd6;
  --podium-1: #fbf5e6;
  --podium-2: #f3f5f7;
  --podium-3: #f9efe6;
  --pt-border: rgba(20, 32, 46, 0.12);
  --pt-border-hover: rgba(20, 32, 46, 0.35);
  --pt-swatch-border: rgba(20, 32, 46, 0.15);
  --pos-wash: #fdf6f4;
  --pos-wash-2: #fbefec;
  --neg-wash: #f4f8fb;
  --cat-alkali-metal: #f6d4cf;
  --cat-alkaline-earth: #f7e0c6;
  --cat-transition: #d6e6f2;
  --cat-post-transition: #d3ebe5;
  --cat-metalloid: #d9ecef;
  --cat-nonmetal: #dcebd5;
  --cat-halogen: #f3ecc4;
  --cat-noble-gas: #e3dcef;
  --cat-lanthanide: #f1dbe6;
  --cat-actinide: #ecd0df;
  --cat-unknown: #eeece6;
  --stage-bg: radial-gradient(circle at 50% 42%, #ffffff 0%, #f1f4f6 58%, #e2e9ef 100%);
  --model-btn-bg: rgba(255, 255, 255, 0.88);

  /* Older names, mapped onto the palette above. */
  --bg: var(--paper);
  --line-soft: var(--line);
  --glass: var(--surface);
  --glass-strong: var(--surface);
  --glass-border: var(--line);
  --sky-50: #f3f7fa;
  --sky-100: var(--accent-wash);
  --sky-200: var(--accent-soft);
  --sky-300: #9fc0da;
  --sky-400: #5d8bb3;
  --sky-500: #2f6496;
  --sky-700: var(--accent);
  --sky-800: var(--accent-dark);
  --indigo: var(--accent-dark);
  --violet: #5b4a86;
  --night: var(--deep);
  --night-2: #1b2836;
  --green-soft: var(--green-wash);
  --red-soft: var(--red-wash);
  --amber-soft: var(--amber-wash);
  --focus: #2f6496;
  --grad: linear-gradient(var(--accent), var(--accent));

  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(20, 32, 46, 0.05), 0 0 0 1px rgba(20, 32, 46, 0.01);
  --shadow-lift: 0 14px 30px -18px rgba(20, 32, 46, 0.3), 0 2px 5px rgba(20, 32, 46, 0.05);
  --font: "Inter Variable", "Segoe UI", system-ui, -apple-system, Roboto, "Noto Sans", Arial, sans-serif;
  --font-serif: "Source Serif 4 Variable", "Iowan Old Style", "Sitka Text", Cambria, Georgia, serif;
  --font-mono: "Cascadia Code", "JetBrains Mono", "SF Mono", Consolas, "Courier New", monospace;
  font-size: 100%;
  color-scheme: light;
}

/* Dark theme: theme-init.js / theme.js set <html data-theme="dark"> from the device setting or the
   learner's choice. Same structure as the light palette: deep blue-grey paper, light ink, a lighter
   Prussian blue so links and buttons keep WCAG AA contrast. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #10161e;
  --surface: #18212c;
  --surface-2: #1c2632;
  --ink: #e6ebf0;
  --ink-2: #c9d2dc;
  --muted: #9aa6b4;
  --line: #2a3542;
  --line-strong: #3a4757;
  --accent: #8dbbe3;
  --accent-dark: #b2d2ee;
  --accent-wash: #1a2c3e;
  --accent-soft: #2c4a66;
  --gold: #e2b65e;
  --gold-wash: #2c2414;
  --green: #86c992;
  --green-wash: #15261a;
  --red: #f0948a;
  --red-wash: #331a1a;
  --amber-wash: #2c2513;
  --deep: #0a0f15;

  --sky-50: #16202b;
  --sky-300: #3f6688;
  --sky-400: #6d9ac2;
  --sky-500: #8dbbe3;
  --violet: #a796d4;
  --night-2: #141d27;
  --focus: #8dbbe3;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(0, 0, 0, 0.05);
  --shadow-lift: 0 14px 30px -18px rgba(0, 0, 0, 0.7), 0 2px 5px rgba(0, 0, 0, 0.3);

  --on-accent: #0b1520;
  --red-dark: #f5aea6;
  --red-line: #6b3330;
  --red-ink: #f6b8b1;
  --green-line: #2f5236;
  --green-ink: #a9dcb1;
  --amber: #d9a640;
  --amber-line: #5c4a1f;
  --amber-ink: #ecc97a;
  --gold-line: #5c4a1f;
  --link-line: rgba(141, 187, 227, 0.45);
  --code-bg: #222c38;
  --header-bg: rgba(16, 22, 30, 0.88);
  --hover-tint: rgba(255, 255, 255, 0.06);
  --input-hover: #4c5a6b;
  --focus-ring: rgba(141, 187, 227, 0.3);
  --invalid-bg: #2a1718;
  --chip-bg: #26303c;
  --track: #2a3542;
  --sticky-bg: rgba(24, 33, 44, 0.94);
  --tile-group: #1c2836;
  --row-bad: #2a1819;
  --row-hover: #1d2733;
  --tabs-bg: #0d1218;
  --tab-hover: rgba(255, 255, 255, 0.06);
  --on-ink-muted: #3a4757;
  --podium-1: #2b2414;
  --podium-2: #222a33;
  --podium-3: #2d2119;
  --pt-border: rgba(255, 255, 255, 0.1);
  --pt-border-hover: rgba(255, 255, 255, 0.35);
  --pt-swatch-border: rgba(255, 255, 255, 0.2);
  --pos-wash: #291c1b;
  --pos-wash-2: #301f1d;
  --neg-wash: #17222e;
  --cat-alkali-metal: #4d2b28;
  --cat-alkaline-earth: #4a3620;
  --cat-transition: #213a50;
  --cat-post-transition: #1e3d36;
  --cat-metalloid: #1f3b41;
  --cat-nonmetal: #263f20;
  --cat-halogen: #47401c;
  --cat-noble-gas: #352c4b;
  --cat-lanthanide: #4a2a3a;
  --cat-actinide: #47243a;
  --cat-unknown: #2a2f36;
  --stage-bg: radial-gradient(circle at 50% 42%, #24303e 0%, #18212c 58%, #111821 100%);
  --model-btn-bg: rgba(24, 33, 44, 0.86);
}
/* The wordmark is drawn in ink on paper; invert its lightness (keeping hues) on the dark theme. */
:root[data-theme="dark"] .wordmark, :root[data-theme="dark"] .wordmark-lg { filter: invert(0.92) hue-rotate(180deg); }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column;
  color: var(--ink); background: var(--paper);
  font-family: var(--font); font-size: 1rem; line-height: 1.62;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-rendering: optimizeLegibility;
}
body > main { flex: 1 0 auto; width: 100%; }
::selection { background: var(--accent-soft); color: var(--ink); }
img, svg { max-width: 100%; height: auto; }
a { color: var(--accent); text-underline-offset: 3px; text-decoration-thickness: 1px; text-decoration-color: var(--link-line); }
a:hover { color: var(--accent-dark); text-decoration-color: currentColor; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; border-radius: 6px; }
h1, h2, h3, .h3 { font-family: var(--font-serif); line-height: 1.15; margin: 0 0 0.5em; color: var(--ink); font-weight: 600; letter-spacing: -0.012em; font-optical-sizing: auto; }
h1 { font-size: clamp(2rem, 4.2vw, 2.7rem); font-weight: 600; letter-spacing: -0.02em; }
h2 { font-size: 1.5rem; }
h3, .h3 { font-size: 1.2rem; }
p { margin: 0 0 0.9em; }
strong { font-weight: 600; }
code { font-family: var(--font-mono); background: var(--code-bg); padding: 0.08em 0.4em; border-radius: 5px; font-size: 0.9em; }
hr { border: none; border-top: 1px solid var(--line); margin: 24px 0; }
.wrap { max-width: 1160px; margin: 0 auto; padding: 0 18px; }
@media (min-width: 900px) { .wrap { padding: 0 32px; } }
.muted { color: var(--muted); }
.small { font-size: 0.9rem; }
.warn { color: var(--red); }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 100; border-radius: 8px; border: 1px solid var(--line); }
.skip-link:focus { left: 8px; }
.display { font-family: var(--font-serif); font-size: clamp(2.6rem, 6.4vw, 4.3rem); font-weight: 500; letter-spacing: -0.03em; line-height: 1.02; }
.display em { font-style: italic; font-weight: 400; }
.bg-orbs { display: none; }

/* ------------------------------------------------------------ header */
.site-header {
  position: sticky; top: 0; z-index: 30;
  background: var(--header-bg); -webkit-backdrop-filter: saturate(1.2) blur(10px); backdrop-filter: saturate(1.2) blur(10px);
  border-bottom: 1px solid var(--line);
}
.header-inner {
  max-width: 1160px; margin: 0 auto; min-height: 68px; padding: 8px 18px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
}
@media (min-width: 900px) { .header-inner { padding: 8px 32px; } }
.brand { display: inline-flex; align-items: center; color: var(--ink); text-decoration: none; margin-right: auto; }
.brand:hover { color: var(--ink); }
/* Wordmark: chemistry lettering drawn as lab kit and element tiles (scripts/build-wordmark.js). */
.wordmark { display: block; height: 40px; width: auto; }
@media (max-width: 380px) { .wordmark { height: 32px; } }
/* Larger annotated version on the About page. */
.wordmark-lg { display: block; width: 100%; max-width: 720px; height: auto; margin: 4px 0 28px; }
.nav-toggle { display: none; background: var(--surface); color: var(--ink); border: 1px solid var(--line-strong); border-radius: 8px; padding: 8px 14px; font: inherit; font-size: 0.92rem; font-weight: 600; cursor: pointer; }
.site-nav { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; }
/* Theme switch: a sun on the light theme, a moon on the dark one. */
.theme-toggle {
  order: 3; flex: none; display: inline-grid; place-items: center; width: 38px; height: 38px; padding: 0;
  border-radius: 8px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink-2); cursor: pointer;
}
.theme-toggle:hover { background: var(--hover-tint); color: var(--ink); }
.theme-toggle svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.theme-toggle .theme-icon-moon, :root[data-theme="dark"] .theme-toggle .theme-icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .theme-icon-moon { display: block; }
.theme-setting { display: flex; align-items: center; gap: 8px; margin: 0; flex-basis: 100%; }
.theme-setting label { color: #b8c1cc; font-weight: 500; }
.theme-setting select { width: auto; min-height: 0; padding: 4px 28px 4px 10px; font-size: 0.84rem; background-color: #1b2836; color: #e6ebf0; border-color: #33435a; }
.site-nav a, .site-nav .linklike, .site-nav .nav-pt {
  position: relative; color: var(--ink-2); text-decoration: none; padding: 8px 11px; border-radius: 8px; font-weight: 500; font-size: 0.92rem;
  background: none; border: none; cursor: pointer; display: inline-flex; align-items: center; gap: 7px; font-family: var(--font); line-height: 1.4;
}
.site-nav a:hover, .site-nav .linklike:hover, .site-nav .nav-pt:hover { background: var(--hover-tint); color: var(--ink); }
.site-nav a[aria-current="page"] { color: var(--accent); font-weight: 600; }
.site-nav a[aria-current="page"]::after { content: ""; position: absolute; left: 11px; right: 11px; bottom: 2px; height: 2px; border-radius: 2px; background: var(--accent); }
.site-nav .btn-small { background: var(--accent); color: var(--on-accent); padding: 8px 16px; margin-left: 6px; font-weight: 600; }
.site-nav .btn-small:hover { background: var(--accent-dark); color: var(--on-accent); }
.nav-pt-tile { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 4px; background: var(--accent-wash); border: 1px solid var(--accent-soft); color: var(--accent); font-size: 0.62rem; font-weight: 700; }
@media (min-width: 1080px) and (max-width: 1240px) {
  .site-nav a, .site-nav .linklike, .site-nav .nav-pt { padding: 8px 8px; font-size: 0.9rem; }
  .site-nav a[aria-current="page"]::after { left: 8px; right: 8px; }
}
@media (max-width: 1079px) {
  .nav-toggle { display: inline-block; order: 2; }
  .theme-toggle { order: 1; }
  .site-nav { order: 4; display: none; width: 100%; flex-direction: column; align-items: stretch; padding: 8px 0 12px; border-top: 1px solid var(--line); margin-top: 6px; }
  .site-nav.open { display: flex; }
  .site-nav a, .site-nav .linklike, .site-nav .nav-pt { padding: 11px 10px; font-size: 1rem; }
  .site-nav a[aria-current="page"] { background: var(--accent-wash); }
  .site-nav a[aria-current="page"]::after { display: none; }
  .site-nav .btn-small { margin: 6px 0 0; justify-content: center; }
}
/* Account button: profile / account page and Log out in one small panel. */
.nav-account { position: relative; }
.nav-account-btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 10px; border-radius: 8px; border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--ink); font: inherit; font-size: 0.92rem; font-weight: 600; line-height: 1.4; cursor: pointer; margin-left: 4px;
}
.nav-account-btn:hover { background: var(--hover-tint); }
.nav-account.is-current .nav-account-btn { border-color: var(--accent); color: var(--accent); }
.nav-account-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav-account-caret { display: inline-flex; transition: transform 0.15s; }
.nav-account-caret svg { width: 14px; height: 14px; }
.nav-account.open .nav-account-caret { transform: rotate(180deg); }
.nav-account-menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 40; min-width: 200px; padding: 6px;
  display: flex; flex-direction: column; background: var(--paper); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-lift);
}
.nav-account-menu[hidden] { display: none; }
.nav-account-who { margin: 0 0 4px; padding: 6px 10px 8px; border-bottom: 1px solid var(--line); font-size: 0.82rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; }
.site-nav .nav-account-menu a, .site-nav .nav-account-menu .linklike { width: 100%; justify-content: flex-start; text-align: left; }
.site-nav .nav-account-menu a[aria-current="page"]::after { display: none; }
@media (max-width: 1079px) {
  .nav-account { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 8px; }
  .nav-account-btn { width: 100%; margin: 0; padding: 10px; font-size: 1rem; }
  .nav-account-caret { margin-left: auto; }
  .nav-account-menu { position: static; box-shadow: none; border: none; padding: 4px 0 0 18px; min-width: 0; }
}
@media (min-width: 1080px) and (max-width: 1359px) {
  .site-nav.nav-long .nav-account { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 8px; }
  .site-nav.nav-long .nav-account-btn { width: 100%; margin: 0; padding: 10px; font-size: 1rem; }
  .site-nav.nav-long .nav-account-caret { margin-left: auto; }
  .site-nav.nav-long .nav-account-menu { position: static; box-shadow: none; border: none; padding: 4px 0 0 18px; min-width: 0; }
}

/* Educators have nine menu items: give the header more room, and below 1360px (where they no
   longer fit on one line beside the logo) use the Menu button, as on smaller screens. */
.header-inner:has(.nav-long) { max-width: 1440px; }
@media (min-width: 1080px) and (max-width: 1359px) {
  .header-inner:has(.nav-long) .nav-toggle { display: inline-block; order: 2; }
  .header-inner:has(.nav-long) .theme-toggle { order: 1; }
  .site-nav.nav-long { order: 4; display: none; width: 100%; flex-direction: column; align-items: stretch; padding: 8px 0 12px; border-top: 1px solid var(--line); margin-top: 6px; }
  .site-nav.nav-long.open { display: flex; }
  .site-nav.nav-long a, .site-nav.nav-long .linklike, .site-nav.nav-long .nav-pt { padding: 11px 10px; font-size: 1rem; }
  .site-nav.nav-long a[aria-current="page"] { background: var(--accent-wash); }
  .site-nav.nav-long a[aria-current="page"]::after { display: none; }
}
@media (min-width: 1360px) {
  .site-nav.nav-long a, .site-nav.nav-long .linklike, .site-nav.nav-long .nav-pt { padding: 8px 9px; }
  .site-nav.nav-long a[aria-current="page"]::after { left: 9px; right: 9px; }
}

/* .wrap sets padding with a shorthand, so main needs the higher-specificity selector to keep its top gap. */
main.wrap { padding-top: 36px; padding-bottom: 72px; outline: none; }
@media (min-width: 900px) { main.wrap { padding-top: 48px; } }

/* ------------------------------------------------------------ footer */
.site-footer { background: var(--deep); color: #b8c1cc; padding: 56px 0 36px; font-size: 0.9rem; }
.footer-cols { display: grid; gap: 28px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); padding-bottom: 32px; border-bottom: 1px solid #263446; }
.footer-cols h2 { font-family: var(--font); color: #fff; font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.14em; margin-bottom: 14px; }
.footer-cols ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 9px; }
.footer-cols a { color: #b8c1cc; text-decoration: none; }
.footer-cols a:hover { color: #fff; text-decoration: underline; }
.footer-base { padding-top: 22px; color: #8a96a5; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; font-size: 0.84rem; }
.footer-base p { margin: 0; max-width: 62ch; }

/* ------------------------------------------------------------ cards and layout */
.card {
  position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 28px; margin-bottom: 24px;
}
@media (max-width: 600px) { .card { padding: 20px; } }
.card.narrow, .form.narrow { max-width: 540px; margin-left: auto; margin-right: auto; }
.narrow-wide { max-width: 760px; margin-left: auto; margin-right: auto; }
.grid-2, .grid-3 { display: grid; gap: 20px; margin-bottom: 24px; }
@media (min-width: 760px) { .grid-2 { grid-template-columns: 1fr 1fr; } .grid-3 { grid-template-columns: repeat(3, 1fr); } }
.grid-2 > .card, .grid-3 > .card { margin-bottom: 0; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 16px 0; align-items: center; }
.prose { max-width: 60em; }
.prose p, .prose li { max-width: 72ch; }
.prose li { margin-bottom: 0.5em; }
.prose h2 { margin-top: 1.6em; }
.eyebrow { font-family: var(--font); font-size: 0.72rem; font-weight: 600; letter-spacing: 0.16em; text-transform: uppercase; color: var(--accent); margin-bottom: 10px; }
.band-dark .eyebrow { color: #9fc0da; }
.lead { font-size: 1.14rem; line-height: 1.6; max-width: 40em; color: var(--ink-2); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
/* Page headers: typography on the paper rather than another box. */
.hero-panel, .card.lab-hero,
#app > div > .card:first-child:not(.narrow):not(.prose):not(:has(form, textarea, select, input:not([type="search"]))):has(> h1) { background: transparent; border: none; box-shadow: none; border-radius: 0; padding: 0 0 26px; margin-bottom: 30px; border-bottom: 1px solid var(--line); }
.hero-panel h1, .lab-hero h1 { margin-bottom: 0.35em; }
#app > div > .card:first-child:not(.narrow):not(.prose):not(:has(form, textarea, select, input:not([type="search"]))):has(> h1) { padding-left: 0; padding-right: 0; }
.hero-panel > p:not(.eyebrow) { max-width: 70ch; }

/* Dark hero band: ink with a faint graph-paper grid. */
.band-dark {
  position: relative; overflow: hidden; color: #d9e0e8; border-radius: 18px; padding: 44px 28px; margin: 0 0 32px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px) 0 0 / 28px 28px,
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px) 0 0 / 28px 28px,
    radial-gradient(ellipse at 78% 40%, rgba(95, 145, 190, 0.28), transparent 60%),
    var(--deep);
  box-shadow: 0 30px 60px -36px rgba(18, 28, 40, 0.8);
}
.band-dark h1, .band-dark h2 { color: #fff; }
.band-dark .lead, .band-dark p { color: #c3ccd6; }
.band-dark a:not(.btn) { color: #b9d3e8; }
.hero-grid { display: grid; gap: 18px; align-items: center; }
@media (min-width: 900px) { .hero-grid { grid-template-columns: 1.1fr 1fr; } .band-dark { padding: 64px 56px; } }
.hero-atom .model-host { height: 360px; background: transparent; border: none; }
.hero-atom .model-caption { color: #8d9aab; text-align: center; font-family: var(--font-serif); font-style: italic; }
.hero-stats { display: flex; flex-wrap: wrap; gap: 0; margin: 30px 0 0; padding-top: 22px; border-top: 1px solid rgba(255, 255, 255, 0.12); }
.hero-stats div { padding: 0 26px 0 0; margin-right: 26px; border-right: 1px solid rgba(255, 255, 255, 0.12); }
.hero-stats div:last-child { border-right: none; margin-right: 0; }
.hero-stats dt { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.14em; color: #8d9aab; margin-top: 4px; }
.hero-stats dd { margin: 0; font-family: var(--font-serif); font-size: 1.9rem; color: #fff; line-height: 1.1; }
.hero-stats div { display: flex; flex-direction: column-reverse; }

/* Contents list: a ruled table of contents with dotted leaders */
.contents-list { list-style: none; padding: 0; margin: 4px 0 16px; border-top: 1px solid var(--line); }
.contents-list li { display: flex; align-items: baseline; gap: 14px; padding: 14px 4px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.contents-num { width: 38px; flex: none; font-family: var(--font-serif); font-style: italic; color: var(--accent); font-size: 1.05rem; }
.contents-title { font-family: var(--font-serif); font-weight: 600; font-size: 1.1rem; }
.contents-leader { flex: 1; border-bottom: 1px dotted var(--line-strong); transform: translateY(-4px); min-width: 20px; }
.contents-sub { color: var(--muted); font-size: 0.93rem; }
@media (max-width: 600px) { .contents-leader { display: none; } .contents-sub { width: 100%; padding-left: 52px; } }
.feature { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.feature-icon { font-family: var(--font-serif); font-style: italic; font-size: 1.1rem; color: var(--accent); padding-bottom: 10px; margin-bottom: 6px; border-bottom: 1px solid var(--accent-soft); min-width: 36px; }
.feature h2 { margin-bottom: 0.4em; }
.feature p { margin: 0; color: var(--ink-2); }

/* ------------------------------------------------------------ buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 20px;
  border-radius: var(--radius-sm); border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  font-family: var(--font); font-size: 0.95rem; font-weight: 600; line-height: 1.2; text-decoration: none; cursor: pointer;
  box-shadow: 0 1px 1px rgba(20, 32, 46, 0.04); transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
}
.btn:hover { border-color: var(--ink-2); color: var(--ink); background: var(--surface); }
.btn:active { box-shadow: none; transform: translateY(1px); }
.btn-primary { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); color: var(--on-accent); }
.btn-accent { background: var(--red); border-color: var(--red); color: var(--on-accent); }
.btn-accent:hover { background: var(--red-dark); border-color: var(--red-dark); color: var(--on-accent); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--accent); box-shadow: none; }
.btn-ghost:hover { background: var(--accent-wash); border-color: transparent; color: var(--accent-dark); }
.band-dark .btn { background: #fff; color: var(--ink); border-color: #fff; }
.band-dark .btn:hover { background: #e9eef3; }
.band-dark .btn-primary { background: #d9e8f4; border-color: #d9e8f4; color: var(--deep); }
.band-dark .btn-primary:hover { background: #fff; }
.band-dark .btn:not(.btn-primary):not(.btn-ghost) { background: transparent; color: #fff; border-color: rgba(255, 255, 255, 0.35); }
.band-dark .btn:not(.btn-primary):not(.btn-ghost):hover { border-color: #fff; background: rgba(255, 255, 255, 0.06); }
.band-dark .btn-ghost { background: transparent; color: #d9e8f4; border-color: transparent; }
.band-dark .btn-ghost:hover { background: rgba(255, 255, 255, 0.06); }
.btn:disabled, .btn[aria-busy="true"] { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-small { min-height: 36px; padding: 6px 14px; font-size: 0.87rem; border-radius: 8px; }
.linklike { background: none; border: none; padding: 0; color: var(--accent); text-decoration: underline; cursor: pointer; font: inherit; }
.chip-btn { border: 1px solid var(--line-strong); background: var(--surface); border-radius: 8px; padding: 6px 12px; cursor: pointer; font: inherit; font-size: 0.9rem; color: var(--ink); text-decoration: none; display: inline-flex; align-items: center; }
.chip-btn:hover, .chip-btn.is-on { border-color: var(--accent); background: var(--accent-wash); color: var(--ink); }
.chip-btn .chem { white-space: normal; }
.example-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }

/* ------------------------------------------------------------ forms */
/* Label, box, then a one-line hint underneath; sections are thin rules with a small serif title.
   Forms size their columns to their own width (container queries), not the window's. */
.form { container-type: inline-size; }
.form fieldset { border: none; border-top: 1px solid var(--line); padding: 14px 0 0; margin: 0 0 6px; min-width: 0; }
.form legend { font-family: var(--font-serif); font-weight: 600; font-size: 1.05rem; padding-right: 10px; }
.field { margin-bottom: 14px; min-width: 0; }
.field label { display: block; font-weight: 600; font-size: 0.9rem; margin-bottom: 5px; color: var(--ink); }
.field .optional { font-weight: 400; color: var(--muted); }
.field .help { font-size: 0.82rem; line-height: 1.45; color: var(--muted); margin: 5px 0 0; }
.form-grid { display: grid; grid-template-columns: minmax(0, 1fr); column-gap: 18px; }
@container (min-width: 560px) {
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid > .span-2 { grid-column: 1 / -1; }
}
.form-wide { max-width: 860px; margin-left: auto; margin-right: auto; }
.form-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 16px; margin-bottom: 14px; }
.form-head h1 { margin: 0; }
.form-head p { margin: 0; }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin-top: 6px; }
.form-actions p { margin: 0; flex: 1 1 260px; font-size: 0.88rem; }
.btn-block { width: 100%; justify-content: center; }
/* Log in: one compact column. */
.auth-card { max-width: 440px; margin-left: auto; margin-right: auto; }
.auth-card h1 { margin-bottom: 14px; }
.auth-card .seg { margin-bottom: 0; }
.auth-card .auth-lead { font-size: 0.9rem; margin: 12px 0 16px; }
.auth-card .btn-block { margin-top: 4px; }
.auth-foot { margin: 18px 0 0; padding-top: 14px; border-top: 1px solid var(--line); font-size: 0.9rem; text-align: center; color: var(--ink-2); }
.label-row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 5px; }
.label-row label { margin: 0; }
.label-link { font-size: 0.85rem; }
/* Password boxes: a Show / Hide button inside the box. */
.input-reveal { position: relative; }
.input-reveal input { padding-right: 88px; }
.reveal-btn {
  position: absolute; top: 50%; right: 5px; transform: translateY(-50%); display: inline-flex; align-items: center; gap: 6px;
  height: 34px; padding: 0 10px; border: none; border-radius: 7px; background: transparent; color: var(--accent);
  font: inherit; font-size: 0.84rem; font-weight: 600; cursor: pointer;
}
.reveal-btn:hover { background: var(--hover-tint); }
.reveal-btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 0; }
.reveal-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
/* Edge draws its own eye button in password boxes; ours replaces it. */
input[type="password"]::-ms-reveal, input[type="password"]::-ms-clear { display: none; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="search"], input[type="url"], input[type="datetime-local"], select, textarea {
  width: 100%; font: inherit; font-size: 1rem; padding: 10px 14px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); min-height: 44px;
  box-shadow: inset 0 1px 1px rgba(20, 32, 46, 0.03); transition: border-color 0.15s, box-shadow 0.15s;
}
input::placeholder, textarea::placeholder { color: #8b93a0; }
input:hover, select:hover, textarea:hover { border-color: var(--input-hover); }
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--focus-ring); }
input[aria-invalid="true"], select[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--red); background: var(--invalid-bg); }
input[type="range"] { width: 100%; accent-color: var(--accent); }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); }
.field-error { color: var(--red); font-weight: 600; font-size: 0.88rem; margin: 6px 0 0; }
.field.checkbox { display: flex; gap: 10px; align-items: flex-start; flex-wrap: wrap; }
.field.checkbox input { width: 18px; height: 18px; margin-top: 3px; flex: none; }
.field.checkbox label { font-weight: 400; flex: 1; font-size: 0.95rem; }
.field.checkbox .field-error { width: 100%; }
.inline-field { display: flex; gap: 8px; }
.inline-field input { flex: 1; }
.link-form { margin: 18px 0 12px; max-width: 560px; }
.link-form label { display: block; font-weight: 600; font-size: 0.92rem; margin-bottom: 6px; }

/* ------------------------------------------------------------ alerts, chips, toasts */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); border: 1px solid; border-left-width: 3px; margin-bottom: 14px; font-size: 0.95rem; }
.alert-error { background: var(--red-wash); border-color: var(--red-line); border-left-color: var(--red); color: var(--red-ink); }
.alert-success { background: var(--green-wash); border-color: var(--green-line); border-left-color: var(--green); color: var(--green-ink); }
.alert-warn { background: var(--amber-wash); border-color: var(--amber-line); border-left-color: var(--amber); color: var(--amber-ink); }
.chip { display: inline-flex; align-items: center; font-size: 0.74rem; padding: 3px 9px; border-radius: 6px; background: var(--chip-bg); color: var(--ink-2); font-weight: 600; letter-spacing: 0.01em; margin-left: 6px; line-height: 1.5; }
.chips .chip { margin-left: 0; }
.chip-success { background: var(--green-wash); color: var(--green-ink); }
.chip-warn { background: var(--amber-wash); color: var(--amber-ink); }
.chip-info { background: var(--accent-wash); color: var(--accent-dark); }
.chip-muted { background: var(--chip-bg); color: var(--muted); }
.chips .countdown { font-size: 0.76rem; font-weight: 600; align-self: center; font-variant-numeric: tabular-nums; }
.valued-badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 6px; background: var(--gold-wash); color: var(--gold); font-weight: 700; font-size: 0.76rem; }
.toasts { position: fixed; bottom: 20px; left: 16px; right: 16px; display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 60; pointer-events: none; }
.toast { background: var(--deep); color: #f3f5f7; padding: 12px 18px; border-radius: var(--radius-sm); max-width: 540px; box-shadow: 0 18px 40px -18px rgba(18, 28, 40, 0.7); pointer-events: auto; font-weight: 500; font-size: 0.95rem; }
.toast-error { background: var(--red); }
.toast-success { background: var(--green); }
.toast-warn { background: #7a5410; }
.loading { display: flex; align-items: center; gap: 10px; color: var(--muted); padding: 24px 0; }
.spinner { width: 20px; height: 20px; border: 2px solid var(--accent-soft); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty { color: var(--muted); }
p.empty.card { text-align: center; padding: 40px 24px; font-family: var(--font-serif); font-style: italic; font-size: 1.05rem; background: var(--surface-2); border-style: dashed; box-shadow: none; }

/* ------------------------------------------------------------ chemistry text */
.chem { font-family: "Cambria Math", Cambria, var(--font-serif); font-size: 1.08em; white-space: nowrap; }
.chem sub, .chem sup { font-size: 0.72em; line-height: 0; }
.chem-answer { font-weight: 700; color: var(--green); }
.prompt { font-size: 1.15rem; }
.prompt .chem { white-space: normal; }
.big-formula { font-size: clamp(2.3rem, 6vw, 3.4rem); margin: 0; font-weight: 600; }
.big-equation { font-size: clamp(1.3rem, 3.4vw, 1.9rem); margin: 6px 0 10px; line-height: 1.5; }
.big-equation .chem, .mid-equation .chem { white-space: normal; }
.mid-equation { font-size: 1.2rem; margin: 4px 0; }
.word-eq { color: var(--muted); margin: 0; font-style: italic; font-family: var(--font-serif); }
.result-name { font-family: var(--font-serif); font-size: 1.3rem; font-weight: 600; margin: 2px 0 6px; }

/* ------------------------------------------------------------ progress, topics, exams */
.progress-wrap { margin: 14px 0; }
.progress-wrap label { display: block; font-weight: 600; font-size: 0.92rem; margin-bottom: 8px; }
progress { -webkit-appearance: none; appearance: none; width: 100%; height: 6px; border: none; border-radius: 999px; background: var(--track); overflow: hidden; }
progress::-webkit-progress-bar { background: var(--track); border-radius: 999px; }
progress::-webkit-progress-value { background: var(--accent); border-radius: 999px; }
progress::-moz-progress-bar { background: var(--accent); }
.topic-grid, .exam-grid { list-style: none; padding: 0; margin: 0; display: grid; gap: 20px; }
@media (min-width: 700px) { .topic-grid, .exam-grid { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1040px) { .topic-grid, .exam-grid { grid-template-columns: repeat(3, 1fr); } }
.exam-grid > .card { margin-bottom: 0; display: flex; flex-direction: column; }
.exam-card h3 { margin-bottom: 0.25em; }
.exam-card .btn { margin-top: auto; align-self: flex-start; }
.topic-card, .test-card {
  position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px;
  box-shadow: var(--shadow); display: flex; flex-direction: column; transition: box-shadow 0.2s ease, border-color 0.2s ease;
}
.topic-card:hover, .test-card:hover, .exam-card:hover { box-shadow: var(--shadow-lift); border-color: var(--line-strong); }
.topic-card .btn { margin-top: auto; align-self: flex-start; }
.topic-card.is-complete { border-top: 3px solid var(--green); }
.topic-head { display: grid; grid-template-columns: auto 1fr; align-items: center; column-gap: 14px; row-gap: 6px; margin-bottom: 10px; }
.topic-head .chip { grid-column: 2; justify-self: start; margin-left: 0; }
.topic-head .topic-num { grid-row: span 2; }
.topic-head h2 { margin: 0; }
.topic-num {
  width: 46px; height: 46px; border-radius: 50%; display: inline-grid; place-items: center;
  border: 1px solid var(--accent-soft); background: var(--accent-wash); color: var(--accent);
  font-family: var(--font-serif); font-style: italic; font-weight: 600; font-size: 1rem;
}
.is-complete .topic-num { border-color: var(--green-line); background: var(--green-wash); color: var(--green); }
.mini-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0; margin: 10px 0 18px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.mini-stats div { padding: 10px 10px 10px 0; }
.mini-stats div + div { padding-left: 12px; border-left: 1px solid var(--line); }
.mini-stats dt { font-size: 0.68rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em; }
.mini-stats dd { margin: 0; font-family: var(--font-serif); font-weight: 600; font-size: 1.15rem; }
.valued-list { padding-left: 0; list-style: none; display: grid; gap: 0; border-top: 1px solid var(--line); }
.valued-list li { display: flex; flex-wrap: wrap; gap: 10px; align-items: baseline; padding: 12px 2px; border-bottom: 1px solid var(--line); }

/* Insights: most failed questions */
.insights { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.insight { padding: 16px 18px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--line); }
.insight-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 8px; }
.insight-head .chip { margin-left: 0; }
.fail-rate { margin-left: auto; font-weight: 700; color: var(--red); font-size: 0.88rem; font-variant-numeric: tabular-nums; }
.bar { height: 4px; border-radius: 999px; background: var(--track); overflow: hidden; margin-bottom: 10px; }
.bar-fill { display: block; height: 100%; width: 0; border-radius: 999px; background: var(--red); }

/* Educator exam editor & community */
.q-list { display: grid; gap: 16px; margin-bottom: 8px; }
.q-list > .card { margin-bottom: 0; }
.q-editor-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.q-editor-head .actions { margin: 0; }
.prompt-preview { margin-top: 6px; }
.sticky-actions { position: sticky; bottom: 14px; z-index: 5; padding: 10px 12px; border-radius: 12px; background: var(--sticky-bg); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); border: 1px solid var(--line-strong); box-shadow: var(--shadow-lift); width: fit-content; max-width: 100%; }
.share-link { display: grid; gap: 8px; margin: 12px 0; padding: 14px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--line); }
.share-link code { word-break: break-all; background: none; padding: 0; }
.share-link .btn { justify-self: start; }
.learner-rows { display: grid; gap: 8px; margin: 10px 0; }
.learner-row { display: grid; gap: 8px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .learner-row { grid-template-columns: 1fr 1.4fr 1fr; } }
.allowed-list { padding-left: 1.2em; }
.community-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.community-questions { padding-left: 1.3em; display: grid; gap: 10px; }
.community-questions li { padding: 12px 14px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--line); display: flex; gap: 12px; justify-content: space-between; align-items: flex-start; }
.cq-text p { margin: 0 0 4px; }
.vote-btn { flex: none; min-width: 60px; min-height: 36px; border-radius: 8px; border: 1px solid var(--gold-line); background: var(--surface); color: var(--gold); font: inherit; font-size: 0.9rem; font-weight: 700; cursor: pointer; }
.vote-btn:hover { background: var(--gold-wash); }
.vote-btn.is-on { background: var(--gold-wash); border-color: var(--gold); }

/* ------------------------------------------------------------ answering + Model it */
.session-head h1 { margin-bottom: 6px; }
.answer-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.answer-head label { margin: 0; }
.question .answer-input, #retry, #bal-input { font-size: 1.2rem; font-family: var(--font-mono); }
.preview { min-height: 1.8em; margin-top: 10px; font-size: 1.05rem; }
.preview:empty { min-height: 0; margin-top: 0; }
.preview .chem-preview { font-size: 1.5rem; }
.preview .warn { font-size: 0.9rem; }
.cube-icon { width: 13px; height: 13px; display: inline-block; border: 1.5px solid currentColor; border-radius: 3px; transform: rotate(45deg); }
.model-panel { margin-top: 14px; padding: 18px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--line); }
.model-hint { font-size: 0.9rem; color: var(--muted); }
.model-hint p { margin: 0 0 4px; color: var(--ink); }
.model-hint ol { margin: 0 0 12px; padding-left: 1.3em; }
.model-hint li + li { margin-top: 2px; }
/* The answer box: a plain-font placeholder (a code font makes "l" look like "1"), and a short typing guide. */
.answer-input::placeholder { font-family: var(--font); font-size: 1rem; }
.answer-help { margin-top: 6px; }
.typing-help { margin: 0; padding-left: 1.1em; font-size: 0.88rem; color: var(--muted); }
.typing-help li + li { margin-top: 3px; }
.typing-help .chem { color: var(--ink); }
kbd.typed { font-family: var(--font); font-variant-ligatures: none; font-feature-settings: "calt" 0, "liga" 0; font-weight: 600; font-size: 0.95em; color: var(--ink); background: var(--surface-2); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; white-space: nowrap; }
.palette { display: grid; gap: 8px; margin-bottom: 12px; }
.pal-row { display: flex; flex-wrap: wrap; gap: 6px; }
.ctile, .ckey {
  position: relative; min-width: 44px; min-height: 44px; padding: 3px 6px; border-radius: 8px; border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--ink); font: inherit; cursor: pointer; display: inline-grid; place-items: center;
  box-shadow: 0 1px 0 rgba(20, 32, 46, 0.06); transition: border-color 0.1s, background 0.1s;
}
.ctile:hover, .ckey:hover { border-color: var(--accent); background: var(--accent-wash); }
.ctile:active, .ckey:active { transform: translateY(1px); }
.ctile-sym { font-weight: 700; font-size: 1rem; }
.ctile-z { position: absolute; top: 2px; left: 5px; font-size: 0.55rem; color: var(--muted); }
.ctile-group { background: var(--tile-group); }
.ctile-wide { min-width: 56px; }
.ckey { font-weight: 700; }
.ckey-charge { background: var(--accent-wash); }
.ckey-op { background: var(--ink); color: var(--surface); border-color: var(--ink); font-size: 1.1rem; }
.ckey-op:hover { background: var(--ink-2); color: var(--surface); }
.ckey-act { background: var(--red-wash); padding: 3px 12px; }
.model-grid { display: grid; gap: 14px; }
@media (min-width: 800px) { .model-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); align-items: start; } }
.model-stage { margin-top: 6px; }
.model-host {
  position: relative; height: 300px; border-radius: var(--radius); border: 1px solid var(--line); overflow: hidden;
  background: var(--stage-bg);
}
.lab-output .model-host { height: 380px; }
.model-canvas { width: 100% !important; height: 100% !important; display: block; cursor: grab; touch-action: none; }
.model-canvas:active { cursor: grabbing; }
.model-canvas:focus-visible { outline-offset: -4px; }
/* Zoom in / zoom out / reset view, in the model's top-right corner, out of the way of the model. */
.model-controls {
  position: absolute; top: 10px; right: 10px; z-index: 2; display: flex; gap: 2px; padding: 3px;
  border-radius: 10px; background: var(--model-btn-bg); border: 1px solid var(--line); box-shadow: var(--shadow);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.model-btn {
  display: inline-grid; place-items: center; width: 34px; height: 34px; padding: 0; border: none; border-radius: 7px;
  background: transparent; color: var(--ink-2); cursor: pointer;
}
.model-btn:hover:not(:disabled) { background: var(--hover-tint); color: var(--ink); }
.model-btn:disabled { opacity: 0.4; cursor: default; }
.model-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.model-reset { margin-left: 3px; position: relative; }
.model-reset::before { content: ""; position: absolute; left: -3px; top: 7px; bottom: 7px; width: 1px; background: var(--line); }
@media (pointer: coarse) { .model-btn { width: 40px; height: 40px; } }
.model-wheel-hint {
  position: absolute; left: 50%; bottom: 14px; z-index: 2; margin: 0; padding: 6px 12px; border-radius: 8px;
  transform: translateX(-50%); background: var(--deep); color: #f3f5f7; font-size: 0.82rem; white-space: nowrap;
  opacity: 0; pointer-events: none; transition: opacity 0.2s;
}
.model-wheel-hint.is-on { opacity: 0.92; }
.model-unavailable { display: grid; place-items: center; padding: 18px; text-align: center; color: var(--muted); }
.model-caption { font-size: 0.85rem; color: var(--muted); margin: 8px 0 0; }
.ledger-table { border-collapse: separate; border-spacing: 0; width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; font-variant-numeric: tabular-nums; }
.ledger-table caption { text-align: left; color: var(--muted); padding-bottom: 6px; font-weight: 600; font-size: 0.9rem; }
.ledger-table th, .ledger-table td { padding: 7px 10px; text-align: center; border-bottom: 1px solid var(--line); }
.ledger-table thead th { font-size: 0.7rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; background: var(--surface-2); }
.ledger-table tr.ok td:last-child { color: var(--green); font-weight: 800; }
.ledger-table tr.bad { background: var(--row-bad); }
.ledger-table tr.bad td:last-child { color: var(--red); font-weight: 800; }
.ledger-verdict { font-weight: 700; margin: 8px 0 0; }
.ledger-verdict.ok { color: var(--green); }
.ledger-verdict.bad { color: var(--red); }

/* Feedback */
.feedback { border-left: 3px solid var(--accent); outline: none; }
.feedback-correct { border-left-color: var(--green); }
.feedback-reconsider { border-left-color: var(--amber); }
.diagnosis { background: var(--amber-wash); border: 1px solid var(--amber-line); border-radius: var(--radius-sm); padding: 12px 16px; margin: 14px 0; }
.diag-title { font-weight: 700; margin-bottom: 2px; color: var(--amber-ink); }
.retry { border-top: 1px solid var(--line); padding-top: 14px; margin-top: 10px; }
.countdown { color: var(--muted); font-variant-numeric: tabular-nums; }
.radio-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin: 6px 0; }
.radio-row input[type="radio"] { width: auto; margin: 0; }
.radio-row input[type="datetime-local"] { width: auto; flex: 1 1 220px; max-width: 280px; }
[hidden] { display: none !important; }
.schedule-card fieldset { border: none; padding: 0; margin: 0 0 16px; }
.schedule-card legend { font-weight: 600; padding: 0; margin-bottom: 4px; }
.schedule-card .inline-field { margin-top: 8px; align-items: center; }
.schedule-card .inline-field input[type="number"] { max-width: 110px; }
.schedule-card .inline-field select { width: auto; }
.exam-timer { display: inline-flex; align-items: center; gap: 8px; padding: 5px 12px; border-radius: 8px; background: var(--accent-wash); color: var(--accent-dark); font-weight: 700; font-variant-numeric: tabular-nums; }
.exam-timer.urgent { background: var(--red-wash); color: var(--red-ink); }
.explanation { padding: 16px 20px; margin: 16px 0; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--line); border-left: 3px solid var(--green); }
.explanation h3 { margin: 0 0 6px; }
.explanation ol { margin: 0; padding-left: 1.3em; }
.notes { color: var(--muted); }
.big-score { font-family: var(--font-serif); font-size: 3.2rem; font-weight: 600; letter-spacing: -0.03em; margin: 4px 0 10px; line-height: 1; }
.review { padding-left: 1.3em; }
.review > li { padding: 12px 0; border-bottom: 1px solid var(--line); }
.review > li.ok::marker { color: var(--green); font-weight: 700; }
.review > li.bad::marker { color: var(--red); font-weight: 700; }
details > summary { cursor: pointer; font-weight: 600; padding: 6px 0; }

/* MFA */
.steps li { margin-bottom: 12px; }
.qr { margin: 10px 0; background: #fff; display: block; width: fit-content; padding: 10px; border-radius: var(--radius-sm); border: 1px solid var(--line); }
.qr img { display: block; }
.setup-key { font-size: 1.05rem; letter-spacing: 0.08em; word-break: break-all; display: inline-block; margin: 6px 0; user-select: all; }
.codes { columns: 2; font-size: 1.05rem; font-family: var(--font-mono); }
@media print { .site-header, .site-footer, .actions, .btn, .field, .bg-orbs { display: none !important; } body { background: #fff; } }

/* ------------------------------------------------------------ tests */
.test-card { border-top: 3px solid var(--accent); }
.test-card.test-advanced { border-top-color: var(--violet); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 1px; margin: 16px 0 18px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--line); overflow: hidden; }
.stats div { padding: 14px 16px; background: var(--surface); }
.stats dt { font-size: 0.68rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em; font-weight: 600; }
.stats dd { margin: 2px 0 0; font-family: var(--font-serif); font-weight: 600; font-size: 1.6rem; letter-spacing: -0.01em; line-height: 1.2; }
.test-layout { display: grid; gap: 20px; }
@media (min-width: 900px) { .test-layout { grid-template-columns: 1fr 280px; align-items: start; } }
.qnav-list { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin: 8px 0 14px; }
.qnav-btn { width: 100%; min-height: 42px; border: 1px solid var(--line-strong); background: var(--surface); font: inherit; font-weight: 600; cursor: pointer; border-radius: 8px; color: var(--ink); font-variant-numeric: tabular-nums; }
.qnav-btn:hover { border-color: var(--accent); }
.qnav-btn.answered { background: var(--accent-wash); border-color: var(--sky-300); color: var(--accent-dark); }
.qnav-btn.current { outline: 2px solid var(--accent); outline-offset: 2px; }
.qnav .btn { width: 100%; }
.question-title { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.question-title .chip { margin-left: 0; }

/* Check your answers, before submitting */
.answer-check h2:focus { outline: none; }
.check-list { list-style: none; padding: 0; margin: 16px 0 0; }
.check-list > li { display: grid; grid-template-columns: 1fr auto; gap: 6px 16px; align-items: start; padding: 14px 0; border-top: 1px solid var(--line); }
.check-list > li > :not(.btn) { grid-column: 1; }
.check-list > li > .btn { grid-column: 2; grid-row: 1 / span 3; align-self: center; }
.check-list > li.is-missing { background: linear-gradient(90deg, var(--amber-wash), transparent 70%); padding-left: 10px; margin-left: -10px; border-radius: 4px; }
.check-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.check-head h3 { font-size: 1rem; margin: 0 4px 0 0; }
.check-head .chip { margin-left: 0; }
.check-prompt { margin: 0; color: var(--ink-2); }
.check-answer { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; font-size: 1.15rem; }
.check-label { font-size: 0.78rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.check-missing { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.check-submit { margin-top: 18px; padding-top: 16px; border-top: 2px solid var(--line-strong); }
@media (max-width: 520px) {
  .check-list > li { grid-template-columns: 1fr; }
  .check-list > li > .btn { grid-column: 1; grid-row: auto; justify-self: start; }
}

/* Exam editor: marks per question */
.q-editor-row { display: grid; grid-template-columns: 1fr 9rem; gap: 12px; align-items: start; }
.marks-input { max-width: 9rem; }
.marks-total { font-weight: 600; margin: 4px 0 12px; }
@media (max-width: 520px) { .q-editor-row { grid-template-columns: 1fr; } }

/* ------------------------------------------------------------ tabs / segmented control */
.tabs, .seg { display: inline-flex; gap: 2px; flex-wrap: wrap; margin-bottom: 22px; padding: 3px; background: var(--tabs-bg); border-radius: 10px; max-width: 100%; }
.tabs a, .seg a, .seg-radio label {
  padding: 7px 14px; background: transparent; border: 1px solid transparent; border-radius: 8px; text-decoration: none;
  font-weight: 500; font-size: 0.9rem; color: var(--ink-2); cursor: pointer; display: inline-block; line-height: 1.4;
}
.tabs a:hover, .seg a:hover, .seg-radio label:hover { color: var(--ink); background: var(--tab-hover); }
.tabs a[aria-current="page"], .seg a[aria-current="page"], .seg-radio input:checked + label { background: var(--surface); color: var(--ink); font-weight: 600; border-color: var(--line); box-shadow: 0 1px 2px rgba(20, 32, 46, 0.08); }
.seg-radio { border: none; padding: 0; margin: 0 0 18px; }
.seg-radio input:focus-visible + label { outline: 2px solid var(--focus); outline-offset: 2px; }
.seg button { padding: 7px 14px; border-radius: 8px; border: 1px solid transparent; background: transparent; font: inherit; font-size: 0.9rem; font-weight: 500; cursor: pointer; color: var(--ink-2); }
.seg button.seg-on, .seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); font-weight: 600; border-color: var(--line); box-shadow: 0 1px 2px rgba(20, 32, 46, 0.08); }
.hero-panel .seg { margin: 16px 0 0; }

/* ------------------------------------------------------------ rankings and tables */
.live-status { color: var(--muted); }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius-sm); border: 1px solid var(--line); }
.table { width: 100%; border-collapse: collapse; font-size: 0.95rem; background: var(--surface); }
.table caption { text-align: left; color: var(--muted); padding: 0 0 8px; font-size: 0.88rem; }
.table-wrap .table caption { padding: 12px 14px 8px; }
.table th, .table td { padding: 12px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.table tbody tr:last-child th, .table tbody tr:last-child td { border-bottom: none; }
.table thead th { font-size: 0.68rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.1em; background: var(--surface-2); }
.table tbody tr:hover { background: var(--row-hover); }
.table tbody th { font-weight: 600; }
.table .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.table tr.is-you, .table tr.is-you:hover { background: var(--accent-wash); }
.badge-honour { display: inline-flex; align-items: center; gap: 4px; background: var(--gold-wash); color: var(--gold); border: 1px solid var(--gold-line); padding: 1px 8px; font-size: 0.74rem; font-weight: 700; white-space: nowrap; border-radius: 6px; }
.podium { list-style: none; padding: 0; margin: 0; display: grid; gap: 14px; align-items: end; }
@media (min-width: 700px) { .podium { grid-template-columns: repeat(3, 1fr); } }
.podium li { padding: 22px; display: flex; flex-direction: column; gap: 2px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow); border-top-width: 3px; }
.podium-1 { border-top-color: #b8902f !important; background: linear-gradient(180deg, var(--podium-1), var(--surface) 70%) !important; }
.podium-2 { border-top-color: #9aa3ad !important; background: linear-gradient(180deg, var(--podium-2), var(--surface) 70%) !important; }
.podium-3 { border-top-color: #b07a4c !important; background: linear-gradient(180deg, var(--podium-3), var(--surface) 70%) !important; }
.podium li.is-you { outline: 2px solid var(--accent); outline-offset: 3px; }
.podium-rank { font-family: var(--font-serif); font-style: italic; font-weight: 600; font-size: 1.6rem; color: var(--muted); }
.podium-name { font-family: var(--font-serif); font-weight: 600; font-size: 1.2rem; }
.podium-school { color: var(--ink-2); font-size: 0.9rem; }
.podium-score { font-weight: 700; font-variant-numeric: tabular-nums; }
.standing .stats dd { font-size: 1.6rem; }

/* Map + county status */
.map-layout { display: grid; gap: 18px; }
@media (min-width: 860px) { .map-layout { grid-template-columns: minmax(0, 1fr) 280px; } }
.map-figure { margin: 0; }
.kenya-map { width: 100%; max-width: 560px; display: block; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.kenya-map .county { cursor: pointer; }
.kenya-map .shape { stroke: var(--surface); stroke-width: 1.1; transition: filter 0.15s; }
.kenya-map .county:hover .shape, .kenya-map .county:focus .shape { stroke: var(--ink); stroke-width: 2.2; filter: brightness(1.05); }
.kenya-map .county:focus { outline: none; }
.kenya-map .county.selected .shape { stroke: var(--accent); stroke-width: 1.8; filter: drop-shadow(0 0 3px rgba(31, 78, 121, 0.7)); }
.kenya-map .county.mine .shape { stroke-dasharray: 4 2; }
.map-picker .shape { stroke: var(--sky-300); }
.map-label { font-size: 11px; font-weight: 700; font-family: var(--font); }
.map-boundaries .map-label { font-size: var(--map-label, 11px); }
.map-label[hidden] { display: none; }
/* Zoomable map (map-zoom.js): controls in the top-right corner; borders keep their width. */
.map-zoomable { position: relative; }
.map-zoomable .kenya-map { touch-action: pan-y; -webkit-user-select: none; user-select: none; }
.map-zoomable .kenya-map.is-zoomed { touch-action: none; cursor: grab; }
.map-zoomable .kenya-map.is-zoomed:active { cursor: grabbing; }
.map-zoomable .kenya-map .shape { vector-effect: non-scaling-stroke; }
.map-controls { top: 8px; right: 8px; }
.small-label { font-size: 8px; }
.legend { list-style: none; padding: 0; margin: 0 0 12px; }
.legend li { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; font-size: 0.92rem; }
.swatch { width: 20px; height: 12px; border-radius: 3px; display: inline-block; }
.swatch-nodata { background: repeating-linear-gradient(45deg, var(--chip-bg), var(--chip-bg) 3px, var(--line-strong) 3px, var(--line-strong) 5px); }
.status-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; margin-right: 6px; background: #cbd5e1; }
.status-top { background: #2e7d3f; }
.status-declining { background: #b3392f; }
.status-steady { background: #95a0ad; }
.abbr-list { columns: 2; padding-left: 0; list-style: none; }
.county-detail { border-left: 3px solid var(--accent); }
.county-picker { margin: -4px 0 16px; }
.county-picker .actions { margin: 6px 0; }
/* Inside a form field (enrol): the buttons sit right under the county list. */
.field .county-picker { margin: 6px 0 0; }
.field .county-picker .actions { margin: 0; gap: 6px 10px; }
.field .county-picker .picker-status:empty { display: none; }
.field .county-picker > p { margin: 4px 0 0; font-size: 0.82rem; }
.picker-map { max-width: 460px; margin: 8px 0; }
.picker-status { color: var(--accent-dark); font-weight: 600; min-height: 1.2em; }

/* ------------------------------------------------------------ periodic table
   One screen, no scrollbars: cell size comes from the container width (cqi) and the viewport height
   (dvh), whichever is tighter. The details panel fills the empty block above the transition metals
   (groups 3–12, periods 1–3); in a narrow container it drops below the f-block instead. */
.periodic { container-type: inline-size; --pt-chrome: 250px; }
.pt-dialog .periodic { --pt-chrome: 292px; }
.pt-tools { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 16px; margin-bottom: 16px; }
.pt-tools h2 { margin: 0; font-size: 1.3rem; flex: 1 1 auto; }
.pt-search { position: relative; flex: 0 1 340px; min-width: 220px; }
.pt-search input { min-height: 38px; padding: 7px 12px; font-size: 0.92rem; }
.pt-search-msg { position: absolute; left: 2px; top: calc(100% + 1px); margin: 0; font-size: 0.74rem; line-height: 1.2; color: var(--muted); white-space: nowrap; }

.pt-grid {
  --gap: 3px;
  --cw: calc((100cqi - 17 * var(--gap)) / 18);
  --ch: clamp(var(--pt-min, 24px), calc((100dvh - var(--pt-chrome)) / 9.3), calc(var(--cw) * 1.1));
  --cell: min(var(--cw), calc(var(--ch) * 1.3));
  --s: min(var(--cell), var(--ch));
  display: grid; justify-content: center; gap: var(--gap);
  grid-template-columns: repeat(18, var(--cell));
  grid-template-rows: 16px repeat(7, var(--ch)) calc(var(--ch) * 0.3) repeat(2, var(--ch)) auto;
}
.pt-group { align-self: end; text-align: center; font-size: 0.66rem; line-height: 1; color: var(--muted); font-variant-numeric: tabular-nums; }
.pt-cell, .pt-big {
  display: grid; grid-template-rows: auto 1fr auto; justify-items: center; align-items: center; min-width: 0; min-height: 0;
  border: 1px solid var(--pt-border); border-radius: 4px; color: var(--ink); font: inherit; line-height: 1;
}
.pt-cell { padding: 3px 2px 3px; cursor: pointer; overflow: hidden; transition: transform 0.1s, box-shadow 0.1s, opacity 0.15s; }
.pt-cell:hover { transform: translateY(-1px); box-shadow: 0 8px 16px -10px rgba(20, 32, 46, 0.5); z-index: 1; border-color: var(--pt-border-hover); }
.pt-cell[aria-pressed="true"] { outline: 2px solid var(--ink); outline-offset: 1px; z-index: 2; }
.pt-cell.pt-dim { opacity: 0.18; }
.pt-z { justify-self: start; padding-left: 2px; font-size: clamp(7px, calc(var(--s) * 0.19), 12px); font-variant-numeric: tabular-nums; }
.pt-sym { font-weight: 700; font-size: clamp(9px, calc(var(--s) * 0.37), 24px); letter-spacing: -0.01em; }
.pt-mass { font-size: clamp(7px, calc(var(--s) * 0.165), 11px); color: var(--ink-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.pt-placeholder { display: grid; place-items: center; font-size: clamp(7px, calc(var(--s) * 0.17), 11px); color: var(--muted); border: 1px dashed var(--line-strong); border-radius: 4px; }

/* Details panel inside the table */
.pt-detail { grid-column: 3 / 13; grid-row: 2 / 5; margin: 0 8px 6px; min-width: 0; min-height: 0; overflow: hidden;
  display: flex; align-items: center; padding: 6px 14px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; }
.pt-detail-inner { display: flex; align-items: center; gap: 16px; width: 100%; min-width: 0; }
.pt-big { flex: none; height: clamp(72px, calc(var(--ch) * 3 - 30px), 150px); aspect-ratio: 0.9; padding: 6px 8px; border: 2px solid var(--ink); border-radius: 6px; box-shadow: var(--shadow-lift); }
.pt-big .pt-z { font-size: clamp(0.7rem, calc(var(--ch) * 0.24), 1rem); }
.pt-big .pt-sym { font-size: clamp(1.6rem, calc(var(--ch) * 0.85), 3rem); }
.pt-big .pt-mass { font-size: clamp(0.66rem, calc(var(--ch) * 0.22), 0.95rem); }
.pt-detail-text { min-width: 0; flex: 1; }
.pt-detail-text h3 { margin: 0 0 4px; font-size: clamp(1.05rem, calc(var(--ch) * 0.4), 1.65rem); }
.pt-3d { font-family: var(--font); font-size: 0.8rem; font-weight: 500; margin-left: 6px; white-space: nowrap; }
.pt-facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px 18px; margin: 0; }
.pt-facts dt { font-size: clamp(0.6rem, calc(var(--ch) * 0.16), 0.7rem); color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; line-height: 1.3; }
.pt-facts dd { margin: 0; font-size: clamp(0.8rem, calc(var(--ch) * 0.29), 1.08rem); font-weight: 600; line-height: 1.3; }
.pt-facts dd .muted { font-weight: 400; font-size: 0.85em; }
.pt-detail-empty { width: 100%; text-align: center; }
.pt-detail-empty p { margin: 0 auto; max-width: 52ch; font-size: 0.85rem; }
.pt-detail-title { font-family: var(--font-serif); font-style: italic; font-size: 1.2rem !important; color: var(--ink); margin-bottom: 4px !important; }

/* Colour key (doubles as a filter) and notes */
.pt-legend { list-style: none; padding: 0; margin: 14px 0 8px; display: flex; flex-wrap: wrap; justify-content: center; gap: 2px 4px; }
.pt-key { display: inline-flex; align-items: center; gap: 6px; padding: 3px 8px; border-radius: 6px; border: 1px solid transparent; background: transparent; color: var(--ink-2); font: inherit; font-size: 0.78rem; cursor: pointer; }
.pt-key:hover { background: var(--hover-tint); }
.pt-key[aria-pressed="true"] { background: var(--surface); border-color: var(--ink); color: var(--ink); font-weight: 600; }
.pt-swatch { width: 14px; height: 12px; border-radius: 3px; display: inline-block; border: 1px solid var(--pt-swatch-border); }
.pt-foot { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 2px 20px; font-size: 0.78rem; color: var(--muted); }
.pt-foot p { margin: 0; max-width: 78ch; }
.pt-note-in { display: none; font-size: 0.78rem; color: var(--muted); margin: 0 0 8px !important; }
.pt-ions summary { font-size: 0.85rem; padding: 2px 0; color: var(--accent); }
.pt-ions[open] { flex-basis: 100%; }
.pt-ions .ion-list { font-size: 0.9rem; color: var(--ink); margin: 6px 0 10px; }
.ion-list { columns: 2; list-style: none; padding: 0; }
.ion-list li { padding: 3px 0; }
@media (min-width: 700px) { .ion-list { columns: 4; } }

/* Short screens: drop the small masses from the cells (the details panel still shows them). */
@media (max-height: 760px) { .pt-cell .pt-mass { display: none; } .pt-cell { grid-template-rows: auto 1fr; } }
/* Narrow containers: masses go, then numbers; the details panel moves below the f-block. */
@container (max-width: 760px) {
  .pt-cell .pt-mass { display: none; }
  .pt-cell { grid-template-rows: auto 1fr; }
  .pt-grid > .pt-detail { grid-column: 1 / -1; grid-row: 12; margin: 10px 0 0; padding: 12px; }
  .pt-big { height: 104px; }
  .pt-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@container (max-width: 520px) {
  .pt-tools { gap: 8px 10px; margin-bottom: 12px; }
  .pt-tools > h2 { flex: 1 1 0; font-size: 1.1rem; }
  .pt-tools > .btn { order: 2; }
  .pt-search { order: 3; flex: 1 1 100%; min-width: 0; }
  .pt-legend { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; margin: 10px 0 4px; }
  .pt-key { font-size: 0.68rem; padding: 3px 4px; gap: 4px; text-align: left; line-height: 1.2; width: 100%; }
  .pt-swatch { width: 10px; height: 10px; flex: none; }
  .pt-note-out { display: none; }
  .pt-note-in { display: block; }
  .pt-detail-text h3 { font-size: 1.05rem; }
  .pt-facts dt { letter-spacing: 0.03em; }
  .pt-grid { --gap: 2px; }
  .pt-cell { padding: 0; border-radius: 3px; grid-template-rows: 1fr; }
  .pt-cell .pt-z, .pt-placeholder { font-size: 0; }
  .pt-group { font-size: 0.5rem; }
  .pt-detail-inner { gap: 12px; }
  .pt-big { height: 80px; }
}

/* Phones held upright (set by periodic-table.js when the table is under 600px wide): 18 columns
   cannot fit at a readable size, so the cells keep a fixed, tappable size and the table scrolls
   sideways. The details panel sits under the table instead of inside it. */
.pt-swipe { display: none; }
.pt-narrow .pt-swipe { display: block; margin: -4px 0 6px; font-size: 0.76rem; color: var(--muted); text-align: right; }
.pt-narrow .pt-swipe::after { content: " →"; }
.pt-narrow .pt-scroll {
  position: relative; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: thin;
  padding: 3px 3px 8px; margin: 0 -3px;
}
.periodic.pt-narrow .pt-grid {
  --gap: 3px; --cell: 36px; --ch: 40px; --s: 40px;
  justify-content: start; width: max-content;
  grid-template-rows: 14px repeat(7, var(--ch)) 10px repeat(2, var(--ch));
}
.periodic.pt-narrow .pt-cell { grid-template-rows: auto 1fr; padding: 2px 1px 1px; border-radius: 4px; }
.periodic.pt-narrow .pt-cell .pt-z { display: block; font-size: 9px; }
.periodic.pt-narrow .pt-cell .pt-sym { font-size: 15px; }
.periodic.pt-narrow .pt-cell .pt-mass { display: none; }
.periodic.pt-narrow .pt-placeholder { font-size: 8px; }
.periodic.pt-narrow .pt-group { font-size: 0.62rem; }
.periodic.pt-narrow .pt-detail { margin: 8px 0 0; padding: 10px 12px; }
.periodic.pt-narrow .pt-big { height: 84px !important; }
.periodic.pt-narrow .pt-big .pt-sym { font-size: 1.7rem; }
.periodic.pt-narrow .pt-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 12px; }
.periodic.pt-narrow .pt-facts dt { font-size: 0.6rem; }
.periodic.pt-narrow .pt-facts dd { font-size: 0.86rem; }

/* Category colours: soft watercolour washes, matching the logo's tiles. */
.cat-alkali-metal { background: var(--cat-alkali-metal); }
.cat-alkaline-earth { background: var(--cat-alkaline-earth); }
.cat-transition { background: var(--cat-transition); }
.cat-post-transition { background: var(--cat-post-transition); }
.cat-metalloid { background: var(--cat-metalloid); }
.cat-nonmetal { background: var(--cat-nonmetal); }
.cat-halogen { background: var(--cat-halogen); }
.cat-noble-gas { background: var(--cat-noble-gas); }
.cat-lanthanide { background: var(--cat-lanthanide); }
.cat-actinide { background: var(--cat-actinide); }
.cat-unknown { background: var(--cat-unknown); }
.pt-dialog {
  width: min(1320px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); padding: 18px 24px 14px; overflow: auto; border: 1px solid var(--line); border-radius: 16px;
  background: var(--paper); color: var(--ink); box-shadow: 0 40px 90px -30px rgba(18, 28, 40, 0.6);
}
@media (max-width: 520px) { .pt-dialog { width: calc(100vw - 16px); max-height: calc(100dvh - 16px); padding: 14px 12px 10px; } }
/* Confirmation dialog (confirmDialog in dom.js) */
.confirm-dialog {
  width: min(440px, calc(100vw - 32px)); padding: 22px 24px 18px; border: 1px solid var(--line); border-radius: 14px;
  background: var(--paper); color: var(--ink); box-shadow: 0 40px 90px -30px rgba(18, 28, 40, 0.6);
}
.confirm-dialog::backdrop { background: rgba(18, 28, 40, 0.45); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.confirm-dialog h2 { margin: 0 0 8px; font-size: 1.2rem; }
.confirm-msg { color: var(--ink-2); font-size: 0.94rem; line-height: 1.5; }
.confirm-msg p { margin: 0 0 8px; }
.confirm-msg > :last-child { margin-bottom: 0; }
.confirm-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; margin-top: 20px; }
@media (max-width: 420px) { .confirm-actions .btn { flex: 1 1 0; } }
.pt-dialog::backdrop { background: rgba(18, 28, 40, 0.45); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }

/* ------------------------------------------------------------ Formula Lab */
.lab-hero { overflow: hidden; }
.lab-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 22px; align-items: start; }
@media (min-width: 980px) { .lab-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); } .lab-output { position: sticky; top: 92px; } }
.lab-grid > .card { margin-bottom: 0; }
.ion-picker { border: none; padding: 0; margin: 0 0 18px; }
.ion-picker legend { font-family: var(--font-serif); font-weight: 600; font-size: 1.15rem; margin-bottom: 8px; }
.ion-group { display: grid; grid-template-columns: 38px 1fr; gap: 8px; align-items: start; margin-bottom: 8px; }
.ion-group-label { margin: 8px 0 0; font-weight: 700; color: var(--muted); text-align: center; font-size: 0.85rem; }
.ion-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.ion-chip {
  display: inline-flex; flex-direction: column; align-items: center; min-width: 64px; padding: 7px 9px 6px; border-radius: 8px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line-strong); transition: border-color 0.1s, background 0.1s; line-height: 1.15;
}
.ion-chip.pos { background: var(--pos-wash); }
.ion-chip.neg { background: var(--neg-wash); }
.ion-chip-f { font-size: 1.05rem; font-weight: 700; }
.ion-chip-n { font-size: 0.66rem; color: var(--muted); }
.ion-chip:hover { border-color: var(--accent); }
.ion-chip-wrap input:checked + .ion-chip { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.ion-chip-wrap input:checked + .ion-chip .ion-chip-n { color: var(--on-ink-muted); }
.ion-chip-wrap input:focus-visible + .ion-chip { outline: 2px solid var(--focus); outline-offset: 2px; }
.result-head { margin-bottom: 10px; }
.criss { display: grid; grid-template-columns: 1fr 120px 1fr; align-items: center; justify-items: center; gap: 2px 6px; margin: 8px 0 12px; padding: 14px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); }
.criss-ion { font-size: 1.45rem; font-weight: 700; padding: 4px 14px; border-radius: 8px; background: var(--surface); border: 1px solid var(--line); }
.criss-ion.pos { background: var(--pos-wash-2); }
.criss-ion.neg { background: var(--accent-wash); }
.criss-x { width: 120px; height: 70px; }
.criss-path { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; stroke-dasharray: 160; stroke-dashoffset: 0; }
@media (prefers-reduced-motion: no-preference) { .criss-path { animation: draw 1.1s ease-out both; } @keyframes draw { from { stroke-dashoffset: 160; } } }
.criss-sub { color: var(--muted); font-size: 0.88rem; }
.steps-list { padding-left: 1.3em; margin: 0 0 12px; }
.steps-list li { margin-bottom: 6px; }
.rx-controls .field { margin-bottom: 10px; }
.rx-row { display: grid; gap: 10px; margin-bottom: 8px; }
@media (min-width: 600px) { .rx-row { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); } }
.rx-label { color: var(--accent); font-weight: 700; margin: 0; align-self: center; }
.ionic-box { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 14px; margin: 10px 0; }
.rx-note { color: var(--ink-2); }
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; animation: none !important; } }
/* Headings receive focus after each page change (for screen readers); no ring needed for that. */
h1[tabindex="-1"]:focus { outline: none; }

/* ------------------------------------------------------------ access codes, followers */
.access-code { margin: 16px 0; padding: 18px 20px; border-radius: var(--radius); background: var(--surface-2); border: 1px dashed var(--line-strong); }
.access-code .eyebrow { margin: 0; }
.access-code .code-value { margin: 6px 0; font-family: var(--font-mono); font-size: clamp(1.6rem, 6vw, 2.2rem); font-weight: 700; letter-spacing: 0.14em; color: var(--ink); }
.access-code.is-expired .code-value { color: var(--muted); text-decoration: line-through; }
.access-code .actions { margin-bottom: 0; }
.pick-list, .follower-list { list-style: none; margin: 0 0 8px; padding: 0; display: grid; gap: 0; max-height: 420px; overflow-y: auto; border-top: 1px solid var(--line); }
.follower-list { max-height: none; }
.pick-row { display: flex; align-items: center; gap: 12px; padding: 12px 6px; border-bottom: 1px solid var(--line); }
.pick-row:hover { background: var(--surface-2); }
.pick-row input[type="checkbox"] { width: 18px; height: 18px; flex: none; margin: 0; }
.pick-row label { cursor: pointer; flex: 1; min-width: 0; }
.follower-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; padding: 14px 4px; border-bottom: 1px solid var(--line); }
.follower-row .actions { margin: 0; }
.follow-ctl { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.exam-card .follow-ctl { margin-top: auto; }
.card > p.empty:only-child { text-align: center; margin: 0; padding: 14px 0; font-family: var(--font-serif); font-style: italic; font-size: 1.05rem; }

/* ------------------------------------------------------------ Formula Lab header and atom view */
.lab-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 24px; padding-bottom: 16px; margin-bottom: 20px; border-bottom: 1px solid var(--line); }
.lab-head .eyebrow { margin-bottom: 4px; }
.lab-head h1 { margin: 0; font-size: clamp(1.6rem, 3vw, 2.15rem); }
.lab-head .seg { margin: 0; }
main.wrap:has(.lab-atom) { padding-top: 24px; padding-bottom: 32px; }

/* The atom view fills the rest of the screen: model on the left, a compact panel on the right. */
.atom-lab { display: grid; gap: 18px; grid-template-columns: minmax(0, 1fr) clamp(290px, 28vw, 360px); height: clamp(400px, calc(100dvh - var(--lab-chrome)), 900px); }
.atom-stage { position: relative; margin: 0; padding: 0; overflow: hidden; display: flex; flex-direction: column; min-height: 0; }
.atom-stage .model-stage { flex: 1; display: flex; flex-direction: column; min-height: 0; margin: 0; }
.atom-stage .model-host { flex: 1; height: auto; min-height: 0; border: none; border-radius: 0; }
.atom-stage .model-caption { margin: 0; padding: 9px 16px; border-top: 1px solid var(--line); background: var(--surface); font-size: 0.8rem; }
.atom-label { position: absolute; top: 18px; left: 22px; z-index: 1; pointer-events: none; }
.atom-label p { margin: 0; }
.atom-label .eyebrow { margin-bottom: 2px; }
.atom-symbol { font-size: clamp(2.6rem, 5.2vw, 4rem); font-weight: 600; line-height: 1.05; }
.atom-name { font-family: var(--font-serif); font-size: 1.2rem; font-weight: 600; color: var(--ink-2); }
.atom-panel { margin: 0; padding: 16px 18px; min-height: 0; overflow-y: auto; scrollbar-width: thin; display: flex; flex-direction: column; gap: 12px; }
.atom-panel > *, .atom-facts > * { margin: 0; }
.atom-panel .field { margin: 0; }
.atom-quick { gap: 5px; }
.atom-quick .chip-btn { padding: 3px 9px; font-size: 0.82rem; min-width: 34px; justify-content: center; }
.atom-facts { display: flex; flex-direction: column; gap: 10px; }
.atom-facts .stats { grid-template-columns: 1fr 1fr; }
.atom-facts .stats div { padding: 8px 12px; }
.atom-facts .stats dd { font-size: 1.3rem; }
.atom-facts .example-chips { margin: 0; }
.atom-note { font-size: 0.86rem; color: var(--ink-2); line-height: 1.5; }
@media (max-width: 899px) {
  .atom-lab { grid-template-columns: minmax(0, 1fr); height: auto; }
  .atom-stage { height: clamp(300px, 52dvh, 520px); }
  .atom-panel { overflow: visible; }
  .lab-head .seg { width: 100%; }
}
/* Phones: shorter header and model, counts in one row, quick picks left to the element list. */
@media (max-width: 600px) {
  main.wrap:has(.lab-atom) { padding-top: 14px; }
  .lab-atom .lab-head .eyebrow { display: none; }
  .lab-head { gap: 8px; padding-bottom: 10px; margin-bottom: 12px; }
  .lab-head h1 { font-size: 1.45rem; }
  .lab-head .seg a { padding: 6px 10px; font-size: 0.84rem; }
  .atom-lab { gap: 12px; }
  .atom-stage { height: 36dvh; min-height: 240px; }
  .atom-label { top: 12px; left: 14px; }
  .atom-symbol { font-size: 2.2rem; }
  .atom-name { font-size: 1rem; }
  .atom-stage .model-caption { font-size: 0.72rem; padding: 6px 12px; line-height: 1.35; }
  .atom-panel { padding: 14px; gap: 10px; }
  .atom-panel .field label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .atom-quick { display: none; }
  .atom-facts .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .atom-facts .stats div { padding: 6px 6px; }
  .atom-facts .stats dt { font-size: 0.62rem; letter-spacing: 0; text-transform: none; }
  .atom-facts .stats dd { font-size: 1.1rem; }
}

/* ------------------------------------------------------------ Lab workbench (compound, reaction, balance)
   Fills the screen: controls | result + 3D model | working. Panels fall back to a thin inner scroll
   only if a very short window can't hold them. */
main.wrap:has(.lab-bench) { padding-top: 24px; padding-bottom: 32px; }
.lab { --lab-chrome: 206px; }
@media (max-height: 760px) { .lab { --lab-chrome: 186px; } .lab-head .eyebrow { display: none; } }
.lab-bench {
  display: grid; gap: 16px; height: clamp(420px, calc(100dvh - var(--lab-chrome)), 900px);
  grid-template-columns: minmax(300px, 360px) minmax(0, 1fr) minmax(260px, 320px);
}
.lab-bench.bench-balance { grid-template-columns: minmax(340px, 420px) minmax(0, 1fr) minmax(250px, 300px); }
.lab-bench.bench-compound { grid-template-columns: minmax(320px, 390px) minmax(0, 1fr) minmax(260px, 320px); }
/* The Lab tools use more of a wide screen than ordinary pages. */
main.wrap:has(.lab-bench), main.wrap:has(.atom-lab) { max-width: 1480px; }
.bench-controls, .bench-readout { margin: 0; padding: 16px 18px; min-height: 0; overflow-y: auto; scrollbar-width: thin; }
.bench-stage, .atom-stage { margin: 0; padding: 0; display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.bench-stage .model-stage { flex: 1; display: flex; flex-direction: column; min-height: 0; margin: 0; }
.bench-stage .model-host { flex: 1; height: auto; min-height: 0; border: none; border-radius: 0; }
.bench-stage .model-caption { margin: 0; padding: 8px 16px; border-top: 1px solid var(--line); background: var(--surface); font-size: 0.78rem; }
.bench-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px 16px; padding: 14px 18px 12px; border-bottom: 1px solid var(--line); background: var(--surface); }
.bench-head p { margin: 0; }
.bench-head .alert { margin: 0; flex: 1; }
.bench-head .btn { flex: none; }
.bench-title { min-width: 0; }
.bench-title .eyebrow { margin-bottom: 2px; }
.bench-formula { font-size: clamp(1.9rem, 3.2vw, 2.6rem); font-weight: 600; line-height: 1.1; }
.bench-head .result-name { margin: 2px 0 0; font-size: 1.05rem; }
.bench-head .big-equation { font-size: clamp(1.1rem, 1.9vw, 1.55rem); line-height: 1.35; margin: 2px 0 0; }
.bench-head .word-eq { font-size: 0.88rem; }
.bench-readout .eyebrow { margin: 0 0 8px; }
.bench-body { display: flex; flex-direction: column; gap: 10px; }
.bench-body > * { margin: 0; }
.bench-fact { font-size: 0.86rem; color: var(--ink-2); line-height: 1.5; margin: 0; }
.bench-readout .steps-list { font-size: 0.85rem; line-height: 1.45; padding-left: 1.2em; }
.bench-readout .steps-list li { margin-bottom: 4px; }
.bench-readout .criss { grid-template-columns: 1fr 84px 1fr; padding: 8px; margin: 0; }
.bench-readout .criss-x { width: 84px; height: 50px; }
.bench-readout .criss-ion { font-size: 1.1rem; padding: 2px 10px; }
.bench-readout .criss-sub { font-size: 0.78rem; }
.bench-readout .ledger-table { font-size: 0.86rem; }
.bench-readout .ledger-table th, .bench-readout .ledger-table td { padding: 4px 8px; }
.bench-readout .ledger-verdict { font-size: 0.88rem; margin-top: 6px; }
.bench-readout .ionic-box { margin: 0; padding: 8px 12px; }
.bench-readout .mid-equation { font-size: 1rem; }
.bench-readout .rx-note, .bench-readout .small { font-size: 0.84rem; }
.bench-try { margin-top: 16px !important; }
.bench-examples { margin: 0; }
.bench-examples select { min-height: 38px; padding: 6px 10px; font-size: 0.86rem; }

/* Compact ion picker: formula only (the name is in the tooltip and read out by screen readers). */
.bench-controls .ion-picker { margin: 0 0 12px; }
.bench-controls .ion-picker legend { font-size: 1rem; margin-bottom: 6px; }
.bench-controls .ion-group { grid-template-columns: 28px 1fr; gap: 6px; margin-bottom: 4px; }
.bench-controls .ion-group-label { margin: 6px 0 0; font-size: 0.78rem; }
.bench-controls .ion-chips { gap: 4px; }
.bench-controls .ion-chip { min-width: 40px; padding: 4px 4px; }
.bench-controls .ion-chip-f { font-size: 0.88rem; }
.bench-controls .ion-chip-n { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Reaction controls: the six kinds as a 2-column grid, selects side by side. */
.bench-controls .seg-radio { display: grid; grid-template-columns: 1fr 1fr; width: 100%; margin: 0 0 14px; }
.bench-controls .seg-radio label { display: block; text-align: center; font-size: 0.82rem; padding: 7px 6px; }
.bench-controls .rx-row { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px 10px; margin-bottom: 10px; }
.bench-controls .rx-row .rx-label { grid-column: 1 / -1; font-size: 0.85rem; }
.bench-controls .field { margin-bottom: 0; }
.bench-controls .field label { font-size: 0.8rem; margin-bottom: 4px; }
.bench-controls select { min-height: 38px; padding: 6px 10px; font-size: 0.88rem; }

/* Balance: compact input and keypad. */
.bench-controls .help { font-size: 0.76rem; margin-bottom: 4px; }
.bench-controls #bal-input { font-size: 1.05rem; min-height: 42px; }
.bench-controls > .field { margin-bottom: 12px; }
.bench-controls .palette { gap: 6px; margin: 0; }
.bench-controls .pal-row { gap: 4px; }
.bench-controls .ctile, .bench-controls .ckey { min-width: 34px; min-height: 34px; padding: 2px 4px; border-radius: 6px; }
.bench-controls .ctile-sym { font-size: 0.9rem; }
.bench-controls .ctile-z { font-size: 0.48rem; top: 1px; left: 3px; }
.bench-controls .ctile-wide { min-width: 46px; }

body:has(.lab-bench, .atom-lab) .header-inner { max-width: 1480px; }
.bench-try label.eyebrow { font-size: 0.72rem; font-weight: 600; margin-bottom: 6px; }
/* Sideways atom count (one column per element) for the Lab panels. */
.ledger-scroll { overflow-x: auto; }
.ledger-compact .ledger-table th, .ledger-compact .ledger-table td { padding: 4px 6px; text-align: center; }
.ledger-compact .ledger-table tbody th { text-align: left; font-size: 0.72rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
.ledger-compact .ledger-match td.ok { color: var(--green); font-weight: 800; }
.ledger-compact .ledger-match td.bad { color: var(--red); font-weight: 800; background: var(--row-bad); }
.bench-foot { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.bench-foot p { margin: 0; font-size: 0.84rem; }
/* Below 1024px wide there is no room for three columns: the model sits on top, and the controls and
   the working share the space under it, switched with two buttons. The whole tool still fits. */
.tab-short, .bench-switch { display: none; }
@media (max-width: 1023px) {
  .lab { --lab-chrome: 196px; }
  .tab-long { display: none; }
  .tab-short { display: inline; }
  .lab-bench, .lab-bench.bench-balance, .lab-bench.bench-compound {
    grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(170px, 1fr) auto auto;
    height: calc(100dvh - var(--lab-chrome)); gap: 10px;
  }
  .bench-stage { order: 1; }
  .bench-switch { display: inline-flex; order: 2; justify-self: center; margin: 0; }
  .bench-switch button { font-size: 0.86rem; padding: 6px 18px; }
  .bench-controls, .bench-readout { order: 3; overflow: visible; padding: 14px 16px; }
  .lab-bench[data-pane="controls"] .bench-readout, .lab-bench[data-pane="readout"] .bench-controls { display: none; }
}
@media (max-width: 600px) {
  .lab { --lab-chrome: 146px; }
  main.wrap:has(.lab-bench), main.wrap:has(.atom-lab) { padding-top: 12px; padding-bottom: 12px; }
  .lab-head { padding-bottom: 0; margin-bottom: 10px; border-bottom: none; }
  .lab-head > div { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .lab-head .seg { width: 100%; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .lab-head .seg a { text-align: center; padding: 6px 2px; font-size: 0.84rem; }
  .bench-head { padding: 8px 12px 6px; gap: 8px; }
  .bench-head .btn-small { min-height: 32px; padding: 4px 10px; font-size: 0.8rem; }
  .bench-formula { font-size: 1.5rem; }
  .bench-head .result-name { font-size: 0.92rem; }
  .bench-head .big-equation { font-size: 1rem; }
  .bench-head .word-eq { display: none; }
  .bench-stage .model-caption { display: none; }
  .bench-controls, .bench-readout { padding: 12px; }
  /* Denser ion buttons: seven to a row. */
  .bench-controls .ion-picker { margin-bottom: 8px; }
  .bench-controls .ion-picker legend { font-size: 0.9rem; margin-bottom: 4px; }
  .bench-controls .ion-group { grid-template-columns: 24px 1fr; gap: 4px; margin-bottom: 3px; }
  .bench-controls .ion-chips { gap: 3px; }
  .bench-controls .ion-chip { min-width: 36px; padding: 3px 3px; }
  .bench-controls .ion-chip-f { font-size: 0.8rem; }
  /* Keypad: ten keys to a row. */
  .bench-controls > .field label, .bench-controls .help { display: none; }
  .bench-controls > .field { margin-bottom: 8px; }
  .bench-controls #bal-input { min-height: 38px; font-size: 0.98rem; padding: 6px 10px; }
  .bench-controls .palette { gap: 4px; }
  .bench-controls .pal-row { gap: 3px; }
  .bench-controls .ctile, .bench-controls .ckey { min-width: 28px; min-height: 30px; padding: 1px 2px; font-size: 0.82rem; }
  .bench-controls .ctile-sym { font-size: 0.8rem; }
  .bench-controls .ctile-z { display: none; }
  .bench-controls .ctile-wide { min-width: 38px; }
  /* Reaction: kinds in three columns. */
  .bench-controls .seg-radio { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-bottom: 10px; }
  .bench-controls .seg-radio label { font-size: 0.74rem; padding: 6px 2px; line-height: 1.2; }
  .bench-controls .rx-row { grid-template-columns: 1fr 1fr; margin-bottom: 6px; }
  .bench-foot { margin-top: 8px; padding-top: 8px; }
  .bench-foot p { font-size: 0.78rem; }
}
/* Periodic table page: everything in one screen, like the pop-up. */
main.wrap:has(.pt-page) { padding-top: 20px; padding-bottom: 16px; }
.pt-page .periodic { --pt-chrome: 330px; }
.pt-title { flex: 1 1 auto; }
.pt-title .eyebrow { margin-bottom: 2px; }
.pt-title h1 { margin: 0; font-size: clamp(1.45rem, 2.6vw, 2rem); }
@media (max-height: 760px) { .pt-title .eyebrow { display: none; } .pt-page .periodic { --pt-chrome: 300px; } }
@media (max-width: 600px) {
  main.wrap:has(.pt-page) { padding-top: 12px; }
  .pt-title .eyebrow { display: none; }
  .pt-title h1 { font-size: 1.25rem; }
  .atom-stage { height: 44dvh; }
}
@media (max-width: 600px) {
  /* Result on one line above the model, so the model gets the room. */
  .bench-head { align-items: center; }
  .bench-head .eyebrow { display: none; }
  .bench-title { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 10px; }
  .bench-head .result-name { margin: 0; }
  .bench-readout .eyebrow { margin-bottom: 6px; }
  .bench-readout .steps-list { font-size: 0.8rem; }
  .bench-readout .steps-list li { margin-bottom: 2px; }
  .bench-readout .criss { padding: 4px; }
  .bench-readout .criss-x { height: 40px; }
  .bench-fact { font-size: 0.8rem; }
  .bench-body { gap: 8px; }
}
.note-narrow { display: none; }
@media (max-width: 600px) {
  .note-wide { display: none; }
  .note-narrow { display: block; }
  .bench-controls .rx-row .rx-label { margin-bottom: -4px; }
}
@media (max-width: 600px) {
  .bench-readout .ionic-box { padding: 6px 10px; }
  .bench-readout .ionic-box .eyebrow { margin-bottom: 2px; }
  .bench-readout .mid-equation { font-size: 0.92rem; margin: 0; }
  .bench-readout .ionic-box .small, .bench-readout .rx-note { font-size: 0.78rem; }
  .bench-readout .ledger-verdict { margin-top: 4px; font-size: 0.8rem; }
}
/* Atom view on narrow screens: same fitted height as the other tools, the model taking what's left. */
@media (max-width: 899px) {
  .atom-lab { height: calc(100dvh - var(--lab-chrome)); grid-template-rows: minmax(220px, 1fr) auto; }
  .atom-stage { height: auto !important; min-height: 0; }
}
/* Tablets (601–1023px): keep the Lab tabs beside the title, the six reaction kinds in three columns. */
@media (min-width: 601px) and (max-width: 1023px) {
  .lab-head .seg { width: auto; }
  .bench-controls .seg-radio { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
/* 1024–1279px wide (small laptops, landscape tablets), and short landscape screens: two columns —
   the controls or the working on the left (switched), the result and model filling the right. */
@media (min-width: 1024px) and (max-width: 1279px), (max-width: 1023px) and (min-width: 601px) and (orientation: landscape) and (max-height: 600px) {
  .lab-bench, .lab-bench.bench-balance, .lab-bench.bench-compound {
    grid-template-columns: minmax(300px, 380px) minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr);
    height: clamp(300px, calc(100dvh - var(--lab-chrome)), 900px);
  }
  .bench-switch { display: inline-flex; grid-column: 1; grid-row: 1; justify-self: start; order: 0; }
  .bench-controls, .bench-readout { grid-column: 1; grid-row: 2; order: 0; overflow-y: auto; }
  .bench-stage { grid-column: 2; grid-row: 1 / span 2; order: 0; }
  .lab-bench[data-pane="controls"] .bench-readout, .lab-bench[data-pane="readout"] .bench-controls { display: none; }
}
@media (min-width: 1024px) and (max-width: 1279px) {
  .tab-long { display: none; }
  .tab-short { display: inline; }
  .bench-controls, .bench-readout { padding: 14px 16px; }
  .bench-controls .ion-picker { margin-bottom: 8px; }
  .bench-controls > .field { margin-bottom: 8px; }
}
/* Narrow screens: the panel under the model takes its natural height when there's room; on very
   short screens it scrolls inside itself rather than pushing the model off or spilling past. */
@media (max-width: 1023px) {
  .lab-bench, .lab-bench.bench-balance, .lab-bench.bench-compound { grid-template-rows: minmax(150px, 1fr) auto minmax(0, max-content); }
  .bench-controls, .bench-readout { min-height: 0; overflow-y: auto; scrollbar-width: thin; }
}
/* Short phones: smaller minimum cells, a compact details panel and a swatch-only colour key (each
   swatch still highlights its type; the details panel names the type of the chosen element). */
@media (max-width: 600px) and (max-height: 720px) {
  .periodic { --pt-min: 19px; }
  .pt-tools { margin-bottom: 8px; }
  .pt-search input { min-height: 34px; padding: 5px 10px; }
  .pt-grid > .pt-detail { margin-top: 6px; padding: 8px 10px; }
  .pt-big { height: 64px !important; }
  .pt-big .pt-sym { font-size: 1.5rem; }
  .pt-detail-text h3 { font-size: 0.98rem; margin-bottom: 2px; }
  .pt-facts { gap: 2px 12px; }
  .pt-facts dt { font-size: 0.56rem; }
  .pt-facts dd { font-size: 0.76rem; }
  .pt-detail-empty p { font-size: 0.76rem; }
  .pt-legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 2px; margin: 6px 0 2px; }
  .pt-key { padding: 4px; font-size: 0; gap: 0; }
  .pt-swatch { width: 18px; height: 14px; }
  .pt-key[aria-pressed="true"] { border-color: var(--ink); }
  .pt-foot { font-size: 0.72rem; }
  .pt-dialog { padding: 10px 10px 8px; }
}
/* (Keep the two-column split on short landscape screens; the rule above would otherwise stack it.) */
@media (max-width: 1023px) and (min-width: 601px) and (orientation: landscape) and (max-height: 600px) {
  .lab-bench, .lab-bench.bench-balance, .lab-bench.bench-compound { grid-template-rows: auto minmax(0, 1fr); }
}
/* Short phones: guarantee the model a usable size (the panel under it scrolls), icon-only Play. */
@media (max-width: 600px) and (max-height: 720px) {
  .lab-bench, .lab-bench.bench-balance, .lab-bench.bench-compound { grid-template-rows: minmax(230px, 1fr) auto minmax(0, max-content); gap: 8px; }
  .bench-head .btn-small { font-size: 0; padding: 4px 12px; min-height: 30px; }
  .bench-head .btn-small span { font-size: 0.9rem; }
  .bench-switch button { padding: 4px 14px; font-size: 0.8rem; }
}
/* Phones held sideways: the tools are only ~220px tall, so the panels sit beside the model and
   scroll inside themselves if they must. */
@media (max-width: 1023px) and (orientation: landscape) and (max-height: 600px) {
  .lab-bench, .lab-bench.bench-balance, .lab-bench.bench-compound { height: clamp(180px, calc(100dvh - var(--lab-chrome)), 900px); }
  .atom-lab { grid-template-columns: minmax(0, 1fr) minmax(240px, 300px); grid-template-rows: minmax(0, 1fr); }
  .atom-panel { overflow-y: auto; }
  .atom-label { top: 10px; left: 14px; }
  .atom-symbol { font-size: 2rem; }
  .bench-stage .model-caption, .atom-stage .model-caption { display: none; }
  .bench-head { padding: 8px 12px 6px; }
  .bench-head .eyebrow, .bench-head .word-eq { display: none; }
  .bench-formula { font-size: 1.4rem; }
  .bench-head .big-equation { font-size: 1rem; }
}
/* Periodic table on a phone held sideways (~390px tall): small rows, details on one line in the
   gap, swatch-only colour key, notes inside the polyatomic-ions drawer. */
@media (orientation: landscape) and (max-height: 500px) {
  main.wrap:has(.pt-page) { padding-top: 6px; padding-bottom: 6px; }
  .periodic { --pt-min: 15px; }
  .pt-tools { margin-bottom: 6px; gap: 6px 12px; }
  .pt-title h1, .pt-tools h2 { font-size: 1.05rem; }
  .pt-search input { min-height: 30px; padding: 3px 10px; font-size: 0.85rem; }
  .pt-search-msg { display: none; }
  .pt-group { font-size: 0.55rem; }
  .pt-cell .pt-z { display: none; }
  .pt-cell { grid-template-rows: 1fr; padding: 0; }
  .pt-grid > .pt-detail { padding: 2px 8px; margin: 0 4px 2px; }
  .pt-detail-inner { gap: 8px; }
  .pt-big { height: calc(var(--ch) * 3 - 6px) !important; min-height: 40px; padding: 2px 4px; border-width: 1.5px; box-shadow: none; }
  .pt-big .pt-z, .pt-big .pt-mass { font-size: 0.55rem; }
  .pt-big .pt-sym { font-size: 1.1rem; }
  .pt-detail-text h3 { font-size: 0.85rem; margin: 0; }
  .pt-3d { font-size: 0.68rem; }
  .pt-facts { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0 8px; }
  .pt-facts dt { font-size: 0.5rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .pt-facts dd { font-size: 0.7rem; }
  .pt-facts dd .muted { display: none; }
  .pt-detail-empty p { font-size: 0.68rem; }
  .pt-detail-title { font-size: 0.85rem !important; margin-bottom: 0 !important; }
  .pt-legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 2px; margin: 4px 0 0; }
  .pt-key { padding: 2px; font-size: 0; gap: 0; }
  .pt-swatch { width: 16px; height: 12px; }
  .pt-foot { font-size: 0.7rem; }
  .pt-note-out { display: none; }
  .pt-note-in { display: block; }
  .pt-ions summary { font-size: 0.72rem; padding: 0; }
  .pt-dialog { padding: 8px 12px 6px; max-height: calc(100dvh - 8px); width: calc(100vw - 16px); }
}
@media (orientation: landscape) and (max-height: 500px) {
  .pt-grid { --cell: min(var(--cw), calc(var(--ch) * 2.4)); }
  .pt-facts { display: flex; flex-wrap: wrap; gap: 0 12px; }
  .pt-facts dt, .pt-facts > div:nth-child(1), .pt-facts > div:nth-child(4) { display: none; }
  .pt-facts dd { font-size: 0.74rem; white-space: nowrap; }
  .pt-detail-text h3 { font-size: 0.92rem; }
}

/* ------------------------------------------------------------ fitted boards (dashboards, rankings)
   board.js sizes .board to the window via --board-chrome; panels scroll inside themselves only when
   a list is genuinely longer than the screen. */
main.wrap:has(.board) { padding-top: 24px; padding-bottom: 16px; }
.board { --board-chrome: 200px; display: grid; gap: 18px; height: clamp(340px, calc(100dvh - var(--board-chrome)), 1000px); grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); }
.board-panel { margin: 0; min-height: 0; overflow-y: auto; scrollbar-width: thin; padding: 20px 22px; display: flex; flex-direction: column; gap: 12px; }
.board-panel > * { margin: 0; }
.board-switch { display: none; }
.board-title { font-size: 1.25rem; margin: 0; }
.board-dash { grid-template-columns: minmax(300px, 0.85fr) minmax(0, 1.6fr); grid-auto-flow: row; }
.board-rank { grid-template-columns: minmax(300px, 0.8fr) minmax(0, 1.6fr); grid-auto-flow: row; }
.board-map { grid-template-columns: minmax(0, 1.15fr) minmax(320px, 1fr); grid-auto-flow: row; }

/* Page header for fitted pages: title on the left, tabs on the right. */
.screen-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 10px 24px; padding-bottom: 14px; margin-bottom: 18px; border-bottom: 1px solid var(--line); }
.screen-head h1 { margin: 0; font-size: clamp(1.6rem, 3vw, 2.15rem); }
.screen-sub { margin: 4px 0 0; font-size: 0.88rem; color: var(--muted); }
.screen-head .seg { margin: 0; }
.live-status { color: var(--muted); }

/* Dashboards */
.dash-hello { font-size: clamp(1.6rem, 2.6vw, 2.1rem); margin: 0; }
.dash-progress .eyebrow { margin-bottom: -6px; }
.dash-meter { display: flex; flex-direction: column; gap: 8px; }
.dash-count { margin: 0; font-size: 0.95rem; color: var(--ink-2); }
.dash-count strong { font-family: var(--font-serif); font-size: 2rem; color: var(--ink); margin-right: 4px; }
.dash-note { font-size: 0.88rem; color: var(--ink-2); line-height: 1.5; }
.dash-progress .alert { margin: 0; }
.dash-next { margin-top: auto; padding: 16px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.dash-next > * { margin: 0; }
.dash-next-title { font-family: var(--font-serif); font-size: 1.15rem; font-weight: 600; display: flex; align-items: baseline; gap: 8px; }
.dash-num { font-style: italic; color: var(--accent); }
.dash-next-sub { font-size: 0.86rem; color: var(--muted); line-height: 1.5; }
.dash-stats { margin: 0; grid-template-columns: 1fr 1fr; }
.dash-progress .actions { margin: 0; }
.topic-rows, .exam-rows { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); flex: 1; display: flex; flex-direction: column; }
.topic-row { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto auto; align-items: center; gap: 4px 16px; padding: 10px 2px; border-bottom: 1px solid var(--line); flex: 1; max-height: 92px; }
.topic-row .topic-num { width: 36px; height: 36px; font-size: 0.9rem; }
.topic-row.is-complete .topic-num { border-color: var(--green-line); background: var(--green-wash); color: var(--green); }
.topic-row-text { min-width: 0; }
.topic-row-text p { margin: 0; }
.topic-row-title { font-family: var(--font-serif); font-weight: 600; font-size: 1.05rem; display: flex; flex-wrap: wrap; align-items: center; gap: 2px 8px; }
.topic-row-title .chip { margin: 0; }
.topic-row-sub { font-size: 0.84rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topic-row-stat { margin: 0; font-size: 0.84rem; color: var(--ink-2); white-space: nowrap; text-align: right; }
.topic-row-stat strong { font-family: var(--font-serif); font-size: 1.05rem; }
.topic-row .btn { min-width: 112px; }
.exam-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; padding: 12px 2px; border-bottom: 1px solid var(--line); }
.exam-row-text { min-width: 0; flex: 1 1 320px; }
.exam-row-text > * { margin: 0; }
.exam-row-text .chips { margin-bottom: 4px; }
.exam-row-title { font-family: var(--font-serif); font-weight: 600; font-size: 1.08rem; }
.exam-row-sub { font-size: 0.82rem; color: var(--muted); line-height: 1.45; }
.exam-row-actions { display: flex; gap: 6px; }

/* Rankings */
.rank-tabs a { white-space: nowrap; }
.stats-2 { grid-template-columns: 1fr 1fr; margin: 0; }
.stats-2 div { padding: 10px 14px; }
.stats-2 dd { font-size: 1.35rem; }
.standing { display: flex; flex-direction: column; gap: 10px; }
.standing > * { margin: 0; }
.rank-side .standing { padding-top: 14px; border-top: 1px solid var(--line); }
.board .podium { grid-template-columns: 1fr !important; gap: 6px; }
.board .podium li { display: grid; grid-template-columns: 46px minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 10px 14px; border-top-width: 1px; border-left-width: 3px; }
.board .podium-1 { border-left-color: #b8902f !important; }
.board .podium-2 { border-left-color: #9aa3ad !important; }
.board .podium-3 { border-left-color: #b07a4c !important; }
.board .podium-rank { font-size: 1.2rem; }
.podium-who { display: flex; flex-direction: column; min-width: 0; }
.board .podium-name { font-size: 1.05rem; }
.board .podium-school { font-size: 0.8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.board .rank-table th, .board .rank-table td { padding: 7px 12px; }
.rank-sub { display: none; font-weight: 400; font-size: 0.78rem; color: var(--muted); }
.board .table-wrap { flex: 0 1 auto; }
.rank-scoring { max-width: none; }
.scoring-list { columns: 2 380px; column-gap: 36px; padding-left: 1.2em; margin: 0; font-size: 0.94rem; line-height: 1.55; }
.scoring-list li { break-inside: avoid; margin-bottom: 10px; }

/* County map tab: the map fills its panel's height. */
.map-panel { overflow: hidden; }
.map-tools { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 20px; }
.map-tools .field { margin: 0; flex: 0 1 240px; }
.map-tools .legend { display: flex; flex-wrap: wrap; gap: 4px 12px; margin: 0; font-size: 0.8rem; }
.map-tools .legend li { margin: 0; }
.board .map-figure { flex: 1; min-height: 0; display: flex; justify-content: center; align-items: center; }
.board .kenya-map { width: auto; max-width: 100%; height: 100%; max-height: 100%; box-shadow: none; }
.map-note { font-size: 0.76rem; color: var(--muted); line-height: 1.45; }
.county-toggle { align-self: flex-start; margin: 0; }
.county-side { display: flex; flex-direction: column; gap: 10px; }
.county-side > * { margin: 0; }
.county-side h3 { font-size: 1rem; margin: 4px 0 0; }
.county-side .status-dot { margin-right: 8px; }

/* Narrow screens: panels stack (dashboards) or switch (rankings). */
@media (max-width: 899px) {
  .board, .board-dash, .board-rank, .board-map { grid-template-columns: minmax(0, 1fr); grid-auto-flow: row; gap: 12px; }
  .board-narrow-stack { grid-template-rows: auto minmax(0, 1fr); }
  .board-narrow-switch { grid-template-rows: auto minmax(0, 1fr); }
  .board-narrow-switch .board-switch { display: inline-flex; justify-self: center; margin: 0; }
  .board-switch button { font-size: 0.86rem; padding: 6px 16px; }
  .board-narrow-switch .board-panel:not(.is-active) { display: none; }
  .board-panel { padding: 16px; }
  .screen-head .seg { width: 100%; }
  .dash-next-sub { display: none; }
  .map-panel { overflow-y: auto; }
}
@media (max-width: 600px) {
  main.wrap:has(.board) { padding-top: 12px; padding-bottom: 12px; }
  .screen-head { padding-bottom: 10px; margin-bottom: 12px; }
  .screen-head h1 { font-size: 1.45rem; }
  .screen-sub { font-size: 0.78rem; }
  .rank-tabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .rank-tabs a { text-align: center; padding: 6px 2px; font-size: 0.8rem; }
  .board-panel { padding: 14px; gap: 10px; }
  .board-title { font-size: 1.1rem; }
  .dash-hello { font-size: 1.35rem; }
  .dash-count strong { font-size: 1.5rem; }
  .dash-progress { gap: 8px; }
  .dash-progress .dash-note:not(.muted) { display: none; }
  .dash-next { display: none; }
  .topic-row { grid-template-columns: 32px minmax(0, 1fr) auto; gap: 2px 10px; padding: 8px 0; }
  .topic-row .topic-num { width: 30px; height: 30px; font-size: 0.8rem; }
  .topic-row-title { font-size: 0.95rem; }
  .topic-row-sub { font-size: 0.76rem; }
  .topic-row-stat { display: none; }
  .topic-row .btn { min-width: 0; padding: 4px 10px; }
  .dash-stats dd { font-size: 1.2rem; }
  .dash-stats div { padding: 8px 10px; }
  .dash-progress .actions .btn { flex: 1 1 auto; }
  .exam-row-text { flex-basis: 100%; }
  /* Tables: rank, name (with school/county underneath) and score only. */
  .board .rank-table .col-wide { display: none; }
  .board .rank-table th, .board .rank-table td { padding: 6px 8px; }
  .rank-sub { display: block; }
  .scoring-list { font-size: 0.85rem; }
  .map-tools .legend { font-size: 0.72rem; }
}

/* Rank tables in boards: one line per learner; the badge shrinks to a star (its name stays for
   screen readers and as a tooltip); long school names are cut with an ellipsis. */
.board .rank-table th, .board .rank-table td { white-space: nowrap; padding: 6px 12px; }
.board .rank-table td.col-wide { max-width: 170px; overflow: hidden; text-overflow: ellipsis; }
.board .rank-table .badge-honour { padding: 0 6px; margin-left: 4px; }
.board .rank-table .badge-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.board .rank-table .chip { margin-left: 6px; }
.board .table-wrap { overflow: visible; }
.board-panel > p.small { font-size: 0.8rem; margin-top: -6px; }
.board-panel { padding: 16px 20px; }

/* Kenya: tighter podium and standing. */
.board .podium li { padding: 7px 12px; }
.stats-2 div { padding: 7px 12px; }
.stats-2 dd { font-size: 1.15rem; }
.rank-side .standing { padding-top: 10px; gap: 8px; }

/* Dashboard list: slightly tighter rows. */
.topic-row { padding: 8px 2px; }
.topic-row .topic-num { width: 34px; height: 34px; }
.topic-row-title { font-size: 1rem; }

/* Scoring: a little smaller so both columns fit. */
.scoring-list { font-size: 0.9rem; line-height: 1.5; }
.scoring-list li { margin-bottom: 8px; }

/* Map tab: the map takes the panel's full height; picker, key and notes sit in a column beside it. */
.board .map-panel { display: grid; grid-template-columns: minmax(0, 1fr) minmax(150px, 200px); grid-template-rows: auto minmax(0, 1fr); gap: 12px 16px; align-content: stretch; }
.board .map-panel .map-figure { grid-column: 1; grid-row: 1 / span 3; height: 100%; }
.board .map-panel .map-tools { grid-column: 2; grid-row: 1; flex-direction: column; align-items: stretch; gap: 10px; }
.board .map-panel .map-tools .field { flex: none; }
.board .map-panel .map-tools .legend { flex-direction: column; gap: 4px; }
.board .map-panel .map-note, .board .map-panel .map-hint, .board .map-panel > details { grid-column: 2; }
.map-hint { font-size: 0.78rem; color: var(--ink-2); line-height: 1.4; }
.board .map-panel .map-note { align-self: end; }
.county-side .stats-2 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.county-side .stats-2 dt { font-size: 0.6rem; }
.county-side .stats-2 dd { font-size: 1rem; }
@media (max-width: 899px) {
  .board .map-panel { display: flex; flex-direction: column; }
  /* The map takes the panel's full width (the panel scrolls), not whatever height is left over. */
  .board .map-panel .map-figure { height: auto; flex: none; align-self: center; width: min(100%, 64dvh); }
  .board .map-panel .kenya-map { width: 100%; height: auto; max-height: none; }
  .board .map-panel .map-tools { flex-direction: row; flex-wrap: wrap; align-items: flex-end; }
  .board .map-panel .map-tools .legend { flex-direction: row; flex-wrap: wrap; }
  .county-side .stats-2 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 600px) {
  .board .rank-table th, .board .rank-table td { padding: 6px 8px; }
  .board .rank-table th[scope="row"] { white-space: normal; }
}

/* Tables adapt to their panel's width: test columns go first, then school/county (which then show
   under the learner's name). Rows are compact so a top 10 fits a laptop screen. */
.board-panel { container-type: inline-size; }
.board .rank-table { font-size: 0.88rem; }
.board .rank-table th, .board .rank-table td { padding: 5px 10px; }
.board .rank-table thead th { padding-top: 7px; padding-bottom: 7px; }
.board .rank-table td.col-wide { max-width: 140px; }
@container (max-width: 640px) {
  .rank-table .col-test { display: none; }
}
@container (max-width: 430px) {
  .rank-table .col-wide { display: none; }
  .rank-table .rank-sub { display: block; }
  .rank-table th[scope="row"] { white-space: normal; }
}
/* A little tighter so a top 10 fits a 650px-high window. */
main.wrap:has(.board) { padding-top: 16px; }
.screen-head { padding-bottom: 10px; margin-bottom: 12px; }
.board-panel { padding-top: 14px; padding-bottom: 14px; gap: 10px; }
.board .rank-table th, .board .rank-table td { padding-top: 4px; padding-bottom: 4px; }
.board .podium li { padding: 5px 12px; }
.board .podium-name { font-size: 1rem; }
/* How scores work: headings that open (all open on wide screens). */
.scoring-list li { list-style-position: outside; }
.scoring-list summary { font-weight: 600; padding: 2px 0; }
.scoring-list details p { margin: 2px 0 0; }
.scoring-list details[open] summary { color: var(--ink); }
@media (min-width: 900px) { .scoring-list summary { cursor: default; list-style: none; pointer-events: none; } .scoring-list summary::-webkit-details-marker { display: none; } }
/* Phones: one line per learner (name + star), school/county cut to one line underneath. */
.rank-table th[scope="row"] { white-space: nowrap; }
.rank-sub { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 600px) {
  .board .rank-table th[scope="row"] { white-space: nowrap; }
  .board-panel > p.small { display: none; }
  .topic-row-sub { display: none; }
  .scoring-list { columns: 1; padding-left: 1.3em; }
  .scoring-list li { margin-bottom: 4px; }
}
@media (max-width: 600px) {
  .board .rank-table { font-size: 0.84rem; }
  .board .rank-table th, .board .rank-table td { padding: 4px 6px; line-height: 1.25; }
  .board .rank-table thead th { padding-top: 6px; padding-bottom: 6px; }
  .rank-sub { font-size: 0.72rem; line-height: 1.2; max-width: 190px; }
  .board .rank-table .badge-honour { font-size: 0.66rem; padding: 0 4px; }
}
@media (max-width: 600px) {
  .screen-sub .sub-long { display: none; }
  .county-side > .board-title { display: none; }
  .board .rank-table th, .board .rank-table td { padding-top: 3px; padding-bottom: 3px; }
}
/* Short phones (under ~720px tall): one line per ranked learner, compact podium/standing,
   a slimmer progress panel and topic list. */
@media (max-width: 600px) and (max-height: 720px) {
  .rank-table .rank-sub { display: none !important; }
  .board .podium li { padding: 3px 10px; }
  .board .podium-school { display: none; }
  .rank-side .standing > p.small { display: none; }
  .stats-2 div { padding: 4px 10px; }
  .stats-2 dd { font-size: 1rem; }
  .stats-2 dt { font-size: 0.56rem; }
  .board-title { font-size: 1rem; }
  .board-panel { gap: 8px; padding: 12px; }
  .dash-progress .eyebrow { display: none; }
  .dash-hello { font-size: 1.2rem; }
  .dash-count strong { font-size: 1.25rem; }
  .dash-meter { gap: 4px; }
  .topic-row { padding: 4px 0; }
  .topic-row .topic-num { width: 26px; height: 26px; font-size: 0.72rem; }
  .topic-row-title { font-size: 0.88rem; }
  .topic-row .btn { min-height: 30px; padding: 2px 10px; font-size: 0.8rem; }
  .board-switch button { padding: 4px 14px; font-size: 0.8rem; }
}
@media (max-width: 600px) and (max-height: 720px) { .rank-side .standing { padding-top: 6px; gap: 6px; } .board .podium { gap: 4px; } }
/* Educator overview on phones: compact stats and buttons so the exam list gets the room. */
@media (max-width: 600px) {
  .dash-stats div { padding: 6px 10px; }
  .dash-stats dt { font-size: 0.56rem; letter-spacing: 0.04em; }
  .dash-stats dd { font-size: 1.05rem; }
  .dash-progress .actions { gap: 6px; }
  .dash-progress .actions .btn { flex: 1 1 auto; min-height: 34px; padding: 5px 10px; font-size: 0.8rem; }
  .dash-progress .alert { padding: 8px 10px; font-size: 0.82rem; }
  .exam-row { padding: 8px 0; gap: 6px; }
  .exam-row-title { font-size: 0.98rem; }
  .exam-row-sub { font-size: 0.76rem; }
  .exam-row-actions .btn { min-height: 32px; padding: 4px 10px; font-size: 0.8rem; }
}

/* ---------------------------------------------------------------- session ending warning */
.session-warning { border-top: 1px solid var(--amber-line); background: var(--amber-wash); color: var(--amber-ink); }
.sw-inner { max-width: 1160px; margin: 0 auto; padding: 10px 18px; display: flex; align-items: center; gap: 12px 18px; flex-wrap: wrap; }
.sw-inner p { margin: 0; flex: 1 1 320px; font-size: 0.95rem; }
.sw-time { font-variant-numeric: tabular-nums; }
.sw-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.header-inner:has(.nav-long) + .session-warning .sw-inner { max-width: 1440px; }
@media (max-width: 520px) {
  .sw-inner { padding: 8px 16px; gap: 8px 12px; }
  .sw-inner p { flex-basis: 100%; }
  .sw-more { display: none; }
}

/* ---------------------------------------------------------------- signed-in devices */
.device-list { list-style: none; margin: 14px 0; padding: 0; display: grid; gap: 10px; }
.device { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; align-items: center; gap: 12px 14px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2); }
.device-current { border-color: var(--accent-soft); }
.device-icon { width: 32px; height: 32px; fill: none; stroke: var(--muted); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; justify-self: center; }
.device-current .device-icon { stroke: var(--accent); }
.device-main { min-width: 0; }
.device-main p { margin: 0; }
.device-name { font-weight: 600; overflow-wrap: anywhere; }
.device-meta { overflow-wrap: anywhere; }
.device-meta + .device-meta { margin-top: 2px; }
.device-ip { font-variant-numeric: tabular-nums; }
.device-here { white-space: nowrap; }
@media (max-width: 520px) {
  .device { grid-template-columns: 32px minmax(0, 1fr); }
  .device-icon { width: 26px; height: 26px; }
  .device > :last-child { grid-column: 2; justify-self: start; }
}

/* ---------------------------------------------------------------- My account: login details */
.login-change { border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2); padding: 4px 16px; margin-top: 10px; }
.login-change > summary { padding: 10px 0; }
.login-change[open] { padding-bottom: 16px; }
.login-change .form { margin-top: 4px; }

/* ---------------------------------------------------------------- notifications */
.nav-bell {
  order: 3; flex: none; position: relative; display: inline-grid; place-items: center; width: 38px; height: 38px;
  border-radius: 8px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink-2); text-decoration: none;
}
.nav-bell[hidden] { display: none; }
.nav-bell:hover { background: var(--hover-tint); color: var(--ink); }
.nav-bell[aria-current="page"] { color: var(--accent); border-color: var(--accent-soft); }
.nav-bell svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav-bell-badge {
  position: absolute; top: -6px; right: -6px; min-width: 19px; height: 19px; padding: 0 5px; border-radius: 10px;
  background: var(--red); color: #fff; font-size: 0.7rem; font-weight: 700; line-height: 19px; text-align: center; box-shadow: 0 0 0 2px var(--surface);
}
@media (max-width: 1079px) { .nav-bell { order: 1; } }
@media (min-width: 1080px) and (max-width: 1359px) { .header-inner:has(.nav-long) .nav-bell { order: 1; } }

.notif-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.notif-head h1 { margin: 0; }
.notif-count { margin: 6px 0 14px; }
.notif-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.notif {
  display: grid; grid-template-columns: 12px minmax(0, 1fr); gap: 12px; width: 100%; text-align: left; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); text-decoration: none; font: inherit; cursor: pointer;
}
a.notif:hover, button.notif:hover { background: var(--hover-tint); color: var(--ink); }
.notif-dot { width: 9px; height: 9px; border-radius: 50%; margin-top: 7px; background: transparent; }
.notif.unread { background: var(--accent-wash); border-color: var(--accent-soft); }
.notif.unread .notif-dot { background: var(--accent); }
.notif-text { display: grid; gap: 2px; min-width: 0; }
.notif-meta { font-size: 0.8rem; color: var(--muted); }
.notif-type { font-weight: 600; }
.notif-title { font-weight: 500; overflow-wrap: anywhere; }
.notif.unread .notif-title { font-weight: 700; }
.notif-body { font-size: 0.92rem; color: var(--ink-2); overflow-wrap: anywhere; }
.notif-empty { padding: 14px 0; }
.check-row { display: flex; align-items: flex-start; gap: 10px; margin: 10px 0; }
.check-row input { width: 18px; height: 18px; margin-top: 3px; flex: none; }
.check-row label { display: grid; gap: 1px; font-weight: 500; cursor: pointer; }
.notif-types { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 6px 16px 8px; margin: 12px 0; }
.notif-types legend { padding: 0 6px; font-weight: 600; font-size: 0.9rem; }
.notif-types input:disabled + label { opacity: 0.55; }
/* Phones: logo, bell, theme switch and Menu on one line. */
@media (max-width: 440px) {
  .header-inner { gap: 6px; padding-left: 14px; padding-right: 14px; }
  .wordmark { height: 30px; }
  .nav-bell, .theme-toggle { width: 36px; height: 36px; }
  .nav-toggle { padding: 8px 12px; }
}
@media (max-width: 350px) { .wordmark { height: 25px; } }

/* ------------------------------------------------------------ learner home: ranking, top learners, trending exams */
/* A topic row never squeezes below its content (a long title wrapped onto three lines overlapped the next row). */
.topic-row { min-height: min-content; }
.board-dash3 { grid-template-columns: minmax(260px, 0.75fr) minmax(0, 1.4fr) minmax(280px, 0.9fr); }
/* Three columns: the topic list drops its "best %" column so titles have room (the chip shows completion). */
@media (min-width: 1280px) {
  .board-dash3 .topic-row { grid-template-columns: 34px minmax(0, 1fr) auto; }
  .board-dash3 .topic-row-stat { display: none; }
  .board-dash3 .topic-row .btn { min-width: 0; }
}
.dash-standing { display: flex; flex-direction: column; gap: 8px; padding-top: 12px; border-top: 1px solid var(--line); }
.dash-standing > * { margin: 0; }
.dash-standing .eyebrow { margin: 0; }
.dash-standing-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.dash-ranks { margin: 0; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.dash-ranks div { padding: 8px 10px; min-width: 0; }
.dash-ranks dd { font-size: 1.4rem; white-space: nowrap; }
.dash-rank-sub { margin: 2px 0 0; font-size: 0.72rem; line-height: 1.3; color: var(--muted); overflow-wrap: anywhere; }
.dash-score { font-size: 0.86rem; color: var(--ink-2); }
.dash-score strong { font-family: var(--font-serif); font-size: 1.05rem; color: var(--ink); }
.dash-community { gap: 18px; }
.dash-block { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.dash-block > * { margin: 0; }
.dash-block-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.dash-block-head a { white-space: nowrap; }
.dash-top, .dash-exams { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.dash-top li { display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 7px 2px; border-bottom: 1px solid var(--line); }
.dash-top li.is-you { background: var(--accent-wash); border-radius: 6px; padding-left: 6px; padding-right: 6px; }
.dash-top-rank { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; border: 1px solid var(--line-strong); font-weight: 700; font-size: 0.82rem; font-variant-numeric: tabular-nums; }
.dash-top-rank.top-1 { background: var(--gold-wash); border-color: var(--gold-line); color: var(--gold); }
.dash-top-rank.top-2, .dash-top-rank.top-3 { background: var(--surface-2); }
.dash-top-who { min-width: 0; }
.dash-top-who p { margin: 0; }
.dash-top-name { font-weight: 600; display: flex; flex-wrap: wrap; align-items: center; gap: 2px 6px; }
.dash-top-name .chip { margin: 0; }
.dash-top-sub { font-size: 0.78rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dash-top-score { font-family: var(--font-serif); font-weight: 600; font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.dash-exams li { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 9px 2px; border-bottom: 1px solid var(--line); }
.dash-exam-text { min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 3px; }
.dash-exam-text > * { margin: 0; }
.dash-exam-text .chip { margin: 0; }
.dash-exam-title { font-family: var(--font-serif); font-weight: 600; line-height: 1.3; }
.dash-exam-sub { font-size: 0.78rem; color: var(--muted); }
.dash-foot { font-size: 0.76rem; }

/* Below 1280px the home page scrolls instead of fitting the window: progress and topics side by side,
   rankings and exams underneath. Phones: one column. */
@media (max-width: 1279px) {
  .board.board-dash3 { height: auto; grid-template-columns: minmax(270px, 0.85fr) minmax(0, 1.6fr); }
  .board-dash3 .board-panel { overflow: visible; }
  .board-dash3 .dash-community { grid-column: 1 / -1; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px 32px; align-items: start; }
  .board-dash3 .topic-row { flex: none; max-height: none; }
}
@media (max-width: 899px) {
  .board.board-dash3 { grid-template-columns: minmax(0, 1fr); grid-template-rows: none; }
  .board-dash3 .dash-community { grid-template-columns: minmax(0, 1fr); }
  .board-dash3 .dash-next { display: flex; }
}
@media (max-width: 600px) {
  .board-dash3 .dash-progress .dash-note:not(.muted) { display: block; }
  .dash-ranks dd { font-size: 1.15rem; }
  .dash-ranks div { padding: 6px 8px; }
  .board-dash3 .topic-row .btn { white-space: nowrap; }
}

/* ---------------------------------------------------------------- messages */
.nav-msg { order: 3; }
@media (max-width: 1079px) { .nav-msg { order: 1; } }
.follow-ctl, .follow-back { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.follower-row .chip { margin-left: 8px; }
.msg-layout { display: grid; grid-template-columns: minmax(260px, 340px) minmax(0, 1fr); gap: 16px; align-items: start; }
.msg-list { position: sticky; top: 84px; max-height: calc(100vh - 110px); overflow: auto; }
.msg-list h1 { font-size: 1.5rem; margin: 2px 0 4px; }
.msg-convs { list-style: none; margin: 12px -8px 0; padding: 0; }
.msg-conv {
  display: grid; gap: 2px; padding: 10px 12px; border-radius: 8px; color: var(--ink); text-decoration: none; border: 1px solid transparent;
}
.msg-conv:hover { background: var(--hover-tint); }
.msg-conv.is-current { background: var(--accent-wash); border-color: var(--accent-soft); }
.msg-conv-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.msg-conv-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-conv-when { font-size: 0.78rem; color: var(--muted); flex: none; }
.msg-conv-about { font-size: 0.8rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-conv-last { display: flex; gap: 8px; align-items: center; justify-content: space-between; font-size: 0.88rem; color: var(--ink-2); }
.msg-conv-last > :first-child, .msg-conv-last { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-conv.is-unread .msg-conv-last { font-weight: 600; color: var(--ink); }
.msg-unread {
  flex: none; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--accent); color: var(--on-accent);
  font-size: 0.72rem; font-weight: 700; line-height: 20px; text-align: center;
}
.msg-empty { margin-top: 14px; display: grid; gap: 6px; justify-items: start; }
.msg-empty p { margin: 0; }
.msg-thread { display: flex; flex-direction: column; min-height: min(640px, calc(100vh - 110px)); padding-bottom: 14px; }
.msg-pick { margin: auto; text-align: center; display: grid; gap: 10px; justify-items: center; padding: 40px 10px; }
.msg-head { border-bottom: 1px solid var(--line); padding-bottom: 10px; margin-bottom: 6px; }
.msg-head h2 { margin: 0; font-size: 1.25rem; }
.msg-head p { margin: 2px 0 0; }
.msg-back { display: none; }
.msg-body { flex: 1; display: flex; min-height: 0; }
.msg-scroll { flex: 1; overflow-y: auto; max-height: calc(100vh - 330px); min-height: 260px; padding: 6px 2px; }
.msg-earlier { display: block; margin: 0 auto 8px; }
.msg-earlier[hidden] { display: none; }
.msg-items { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.msg-day { align-self: center; margin: 10px 0 4px; font-size: 0.78rem; color: var(--muted); }
.msg-day span { background: var(--chip-bg); padding: 2px 10px; border-radius: 10px; }
.msg { max-width: min(78%, 560px); padding: 8px 12px 6px; border-radius: 14px; }
.msg.theirs { align-self: flex-start; background: var(--surface-2); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg.mine { align-self: flex-end; background: var(--accent); color: var(--on-accent); border-bottom-right-radius: 4px; }
.msg-text { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-meta { margin: 2px 0 0; font-size: 0.72rem; opacity: 0.75; text-align: right; }
.msg-compose { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 6px; display: grid; gap: 6px; }
.msg-compose textarea { width: 100%; resize: vertical; min-height: 64px; max-height: 240px; }
.msg-compose-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
.msg-compose-foot > :first-child { flex: 1 1 220px; }
.msg-compose-foot .btn { margin-left: auto; }
.msg-closed { margin: 10px 0 0; }
@media (max-width: 899px) {
  .msg-layout { grid-template-columns: minmax(0, 1fr); }
  .msg-list { position: static; max-height: none; }
  .msg-layout.has-thread .msg-list { display: none; }
  .msg-layout:not(.has-thread) .msg-thread { display: none; }
  .msg-back { display: inline-block; margin-bottom: 4px; }
  .msg-thread { min-height: 0; }
  .msg-scroll { max-height: calc(100vh - 340px); min-height: 220px; }
  .msg { max-width: 86%; }
}
.msg-list-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.msg-direct { margin: 0 6px 0 0; padding: 1px 6px; font-size: 0.68rem; }
.msg-head-row { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 8px 12px; }
.msg-head-row .actions { margin: 0; }
.msg-people { border-bottom: 1px solid var(--line); padding: 4px 0 10px; margin-bottom: 6px; }
.msg-people[hidden] { display: none; }
.msg-people .follower-list { list-style: none; margin: 0; padding: 0; max-height: 240px; overflow: auto; }
.msg-people .follower-row { padding: 8px 2px; }
.msg-pins[hidden] { display: none; }
.msg-pins-box { background: var(--gold-wash); border: 1px solid var(--gold-line); border-radius: 8px; padding: 6px 10px; margin-bottom: 6px; }
.msg-pins-box summary { cursor: pointer; font-weight: 600; font-size: 0.88rem; }
.msg-pins-box ul { list-style: none; margin: 6px 0 2px; padding: 0; display: grid; gap: 4px; }
.msg-pin-go { background: none; border: 0; padding: 0; text-align: left; color: var(--ink); cursor: pointer; font: inherit; font-size: 0.88rem; }
.msg-pin-go:hover { text-decoration: underline; }
.msg-from { margin: 0 0 2px; font-size: 0.76rem; font-weight: 700; color: var(--accent); }
.msg-from .chip { font-size: 0.64rem; padding: 0 5px; }
.msg-flag { margin: 0 0 3px; font-size: 0.74rem; font-weight: 600; color: var(--amber-ink); }
.msg.mine .msg-flag { color: inherit; }
.msg.is-pinned.theirs { border-color: var(--gold-line); }
.msg.flash { outline: 3px solid var(--gold-line); outline-offset: 2px; }
.msg-pin-ctl { display: inline-flex; align-items: center; gap: 6px; margin-left: 6px; }
.msg-pin-ctl select { font-size: 0.75rem; padding: 2px 4px; min-height: 0; width: auto; }
.msg-pin-ctl .btn-small { padding: 2px 8px; font-size: 0.72rem; }
.msg .linklike { color: inherit; opacity: 0.85; }
.msg-notes:empty { display: none; }
.msg-notes .alert { margin: 0; }
.msg-moderation .actions { margin: 6px 0 0; }
.msg-label { font-weight: 600; font-size: 0.92rem; }
.msg-learners { border: 0; padding: 0; margin: 0; }
.msg-learners legend { font-weight: 600; font-size: 0.92rem; margin-bottom: 4px; }
.msg-pick-list { list-style: none; margin: 6px 0; padding: 4px; max-height: 260px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
.msg-pick-list li[hidden] { display: none; }
.msg-pick-row { display: flex; gap: 10px; align-items: center; padding: 6px 8px; border-radius: 6px; cursor: pointer; font-weight: 400; }
.msg-pick-row:hover { background: var(--hover-tint); }
.msg-pick-row input { width: auto; margin: 0; }
.msg-add { margin-top: 8px; }
.msg-add summary { cursor: pointer; font-weight: 600; }
.msg-thread .msg-compose .field { margin-bottom: 4px; }
.msg-list { overflow-x: hidden; }
.msg-convs { margin-left: -6px; margin-right: -6px; }
.msg-conv, .msg-conv > span, .msg-conv-last > span:first-child { min-width: 0; }
.msg-conv-last > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* A message the moderation check held back: only its sender sees it, until they rewrite or delete it. */
.msg.is-held { background: var(--surface-2); color: var(--ink); border: 1.5px dashed var(--red); }
.msg.is-held .msg-meta { color: var(--muted); }
.msg-held { background: var(--red-wash); color: var(--red-ink); border-radius: 8px; padding: 6px 10px; margin: 2px 0 6px; font-size: 0.84rem; }
.msg-held p { margin: 0 0 4px; }
.msg-held .actions { margin: 4px 0 0; }
.msg-held-title { font-weight: 700; }
.msg-edit { display: grid; gap: 6px; min-width: min(420px, 70vw); }
.msg-edit textarea, .msg-edit input { width: 100%; }
.msg-edit .actions { margin: 0; }
.msg-head .linklike { margin-top: 2px; }
/* Archived chats, deleted messages, and your own message actions. */
.msg-archived-toggle { display: block; margin: 10px 0 2px; }
.msg-archived-label { margin: 6px 0 0; }
.msg.is-deleted { opacity: 0.75; font-style: italic; }
.msg.mine.is-deleted { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.msg-own-ctl { display: inline-flex; gap: 8px; margin-left: 8px; }
.msg-head-actions { flex-wrap: wrap; gap: 6px; }
.msg-head-actions .msg-danger { color: var(--red); }

/* ---------------------------------------------------------------- sharing exams */
.share-box { display: grid; gap: 10px; margin-top: 8px; }
.share-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.share-btn { text-decoration: none; }
.share-whatsapp { border-color: #1f8a4c; color: #17683a; }
.share-telegram { border-color: #2a87c4; color: #1d6a9d; }
.share-facebook { border-color: #3b5fae; color: #2f4d8f; }
.share-url { width: 100%; font-size: 0.85rem; color: var(--muted); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .share-whatsapp { color: #6fd39a; }
  :root:not([data-theme="light"]) .share-telegram { color: #7cc3f0; }
  :root:not([data-theme="light"]) .share-facebook { color: #9db5ec; }
}
:root[data-theme="dark"] .share-whatsapp { color: #6fd39a; }
:root[data-theme="dark"] .share-telegram { color: #7cc3f0; }
:root[data-theme="dark"] .share-facebook { color: #9db5ec; }
.share-landing { max-width: 640px; margin: 40px auto; padding: 0 16px; }
.shared-exam-note { margin: 8px 0 12px; }

/* Checking an exam-result PDF (/v, /v/<serial>), a page served without the app around it. */
.verify-page { max-width: 640px; margin: 0 auto; padding: 24px 16px 48px; }
.verify-brand { margin: 0 0 20px; }
.verify-brand .wordmark { width: 150px; height: auto; display: block; }
.verify-result { border-width: 2px; }
.verify-result h1 { font-size: 1.45rem; margin-top: 4px; }
.verify-ok { border-color: var(--green-line); }
.verify-warn { border-color: var(--amber-line); }
.verify-bad { border-color: var(--red-line); }
.verify-badge { display: inline-block; margin: 0; padding: 3px 12px; border-radius: 999px; font-weight: 700; font-size: .9rem; }
.verify-ok .verify-badge { background: var(--green-wash); color: var(--green-ink); }
.verify-warn .verify-badge { background: var(--amber-wash); color: var(--amber-ink); }
.verify-bad .verify-badge { background: var(--red-wash); color: var(--red-ink); }
.verify-facts { display: grid; gap: 0; margin: 16px 0; border-top: 1px solid var(--line); }
.verify-facts div { display: grid; grid-template-columns: minmax(88px, 30%) 1fr; gap: 12px; padding: 9px 2px; border-bottom: 1px solid var(--line); }
.verify-facts dt { color: var(--muted); font-size: .9rem; }
.verify-facts dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.verify-form { margin-top: 16px; }
.verify-form label { font-weight: 700; }
.verify-form input { text-transform: uppercase; letter-spacing: .04em; }
.verify-facts dd.verify-serial { white-space: nowrap; overflow-wrap: normal; font-size: .95rem; }

/* Shown over a 3D model when the browser took its graphics away (model3d.js). */
.model-lost { position: absolute; inset: 0; z-index: 3; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 16px; text-align: center; background: var(--surface); color: var(--ink); border-radius: inherit; }
.model-lost p { margin: 0; max-width: 30ch; }
