/* C1 Prep: shared styles for C1 (root), A2 (a2/), B1 (b1/), B2 (b2/) and C2 (c2/). Tokens and rules: DESIGN.md. */

/* Fonts, served from this site (latin subset, variable weight; from Google Fonts, SIL Open Font License). */
@font-face { font-family: "Inter"; font-style: normal; font-weight: 400 800; font-display: swap; src: url("fonts/inter-latin.woff2?v=1") format("woff2"); }
@font-face { font-family: "Source Serif 4"; font-style: normal; font-weight: 400 700; font-display: swap; src: url("fonts/source-serif-4-latin.woff2?v=1") format("woff2"); }
@font-face { font-family: "Source Serif 4"; font-style: italic; font-weight: 400 700; font-display: swap; src: url("fonts/source-serif-4-italic-latin.woff2?v=1") format("woff2"); }
/* Only the Kids and Whimsical themes use these two; browsers download them only then. */
@font-face { font-family: "Poppins"; font-style: normal; font-weight: 700; font-display: swap; src: url("fonts/poppins-bold-latin.woff?v=1") format("woff"); }
@font-face { font-family: "Lora"; font-style: italic; font-weight: 400 700; font-display: swap; src: url("fonts/lora-italic-latin.woff?v=1") format("woff"); }

/* ================= Tokens ================= */
:root {
  color-scheme: light;
  --bg: #f6f6f3;
  --surface: #ffffff;
  --surface-2: #efefeb;
  --border: #e2e1dc;
  --border-strong: #8f8e87;
  --text: #17191c;
  --muted: #5a606a;
  --primary: #1f4e79;
  --primary-hover: #173d60;
  --primary-soft: #e7eef6;
  --on-primary: #ffffff;
  --ok: #17784b;
  --ok-soft: #e5f3ec;
  --bad: #b42318;
  --bad-soft: #fcebe9;
  --warn: #8a5300;
  --warn-soft: #fdf3e2;
  --shadow-sm: 0 1px 2px rgba(23, 25, 28, .05), 0 1px 3px rgba(23, 25, 28, .04);
  --shadow-lg: 0 2px 6px rgba(23, 25, 28, .06), 0 12px 32px rgba(23, 25, 28, .12);

  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px; --s8: 64px;
  --r-sm: 6px; --r-md: 10px; --r-lg: 14px;
  --header-h: 60px;
  --side-w: 460px;
  --ease: cubic-bezier(.2, .7, .3, 1);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #111316; --surface: #191c20; --surface-2: #22262c;
    --border: #2d3239; --border-strong: #6b737e;
    --text: #ebecee; --muted: #a3a9b3;
    --primary: #8fb8e3; --primary-hover: #a9c9eb; --primary-soft: #1c2938; --on-primary: #0f1720;
    --ok: #62cf95; --ok-soft: #15291f; --bad: #f08b84; --bad-soft: #371d1c; --warn: #f0c46b; --warn-soft: #33280f;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-lg: 0 2px 6px rgba(0, 0, 0, .3), 0 12px 32px rgba(0, 0, 0, .45);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111316; --surface: #191c20; --surface-2: #22262c;
  --border: #2d3239; --border-strong: #6b737e;
  --text: #ebecee; --muted: #a3a9b3;
  --primary: #8fb8e3; --primary-hover: #a9c9eb; --primary-soft: #1c2938; --on-primary: #0f1720;
  --ok: #62cf95; --ok-soft: #15291f; --bad: #f08b84; --bad-soft: #371d1c; --warn: #f0c46b; --warn-soft: #33280f;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-lg: 0 2px 6px rgba(0, 0, 0, .3), 0 12px 32px rgba(0, 0, 0, .45);
}

/* ================= Themes (theme.js: the Themes menu sets data-skin on <html>) =================
   One palette per theme, no light/dark pair: theme.js also sets data-theme to the theme's own brightness.
   Each theme: the colour tokens, a faint pattern behind the page, a band along the top and the confetti colours. */
:root[data-skin="christmas"] {
  color-scheme: light;
  --bg: #f6f1e6; --surface: #fffdf7; --surface-2: #efe6d4;
  --border: #e2d6bf; --border-strong: #8a7b60;
  --text: #1d1a15; --muted: #5b5346;
  --primary: #1c5b39; --primary-hover: #144a2d; --primary-soft: #e1ede3; --on-primary: #ffffff;
  --ok: #17784b; --ok-soft: #e5f3ec; --bad: #b42318; --bad-soft: #fcebe9; --warn: #8a5300; --warn-soft: #fdf3e2;
  --skin-pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160' viewBox='0 0 160 160'%3E%3Cpath d='M30.0 34.0L43.0 34.0 M37.1 34.0L40.6 31.7 M37.1 34.0L40.6 36.3 M30.0 34.0L36.5 45.3 M33.6 40.2L37.3 42.0 M33.6 40.2L33.3 44.3 M30.0 34.0L23.5 45.3 M26.4 40.2L26.7 44.3 M26.4 40.2L22.7 42.0 M30.0 34.0L17.0 34.0 M22.9 34.0L19.4 36.3 M22.9 34.0L19.4 31.7 M30.0 34.0L23.5 22.7 M26.4 27.8L22.7 26.0 M26.4 27.8L26.7 23.7 M30.0 34.0L36.5 22.7 M33.6 27.8L33.3 23.7 M33.6 27.8L37.3 26.0' stroke='%231c5b39' stroke-opacity='0.16' stroke-width='1.6' stroke-linecap='round' fill='none'/%3E%3Cpath d='M118.0 108.0L127.0 108.0 M123.0 108.0L125.3 106.4 M123.0 108.0L125.3 109.6 M118.0 108.0L122.5 115.8 M120.5 112.3L123.1 113.5 M120.5 112.3L120.3 115.2 M118.0 108.0L113.5 115.8 M115.5 112.3L115.7 115.2 M115.5 112.3L112.9 113.5 M118.0 108.0L109.0 108.0 M113.0 108.0L110.7 109.6 M113.0 108.0L110.7 106.4 M118.0 108.0L113.5 100.2 M115.5 103.7L112.9 102.5 M115.5 103.7L115.7 100.8 M118.0 108.0L122.5 100.2 M120.5 103.7L120.3 100.8 M120.5 103.7L123.1 102.5' stroke='%231c5b39' stroke-opacity='0.13' stroke-width='1.6' stroke-linecap='round' fill='none'/%3E%3Cpath d='M96.0 26.0L102.0 26.0 M99.3 26.0L100.9 24.9 M99.3 26.0L100.9 27.1 M96.0 26.0L99.0 31.2 M97.7 28.9L99.4 29.7 M97.7 28.9L97.5 30.8 M96.0 26.0L93.0 31.2 M94.3 28.9L94.5 30.8 M94.3 28.9L92.6 29.7 M96.0 26.0L90.0 26.0 M92.7 26.0L91.1 27.1 M92.7 26.0L91.1 24.9 M96.0 26.0L93.0 20.8 M94.3 23.1L92.6 22.3 M94.3 23.1L94.5 21.2 M96.0 26.0L99.0 20.8 M97.6 23.1L97.5 21.2 M97.6 23.1L99.4 22.3' stroke='%231c5b39' stroke-opacity='0.12' stroke-width='1.6' stroke-linecap='round' fill='none'/%3E%3Ccircle cx='62' cy='120' r='3.2' fill='%23b3262c' fill-opacity='0.25'/%3E%3Ccircle cx='68' cy='124' r='3.2' fill='%23b3262c' fill-opacity='0.25'/%3E%3Ccircle cx='61' cy='127' r='3.2' fill='%23b3262c' fill-opacity='0.25'/%3E%3Ccircle cx='140' cy='58' r='2' fill='%231c5b39' fill-opacity='0.18'/%3E%3Ccircle cx='18' cy='96' r='2' fill='%23b3262c' fill-opacity='0.2'/%3E%3C/svg%3E");
  --skin-band: repeating-linear-gradient(45deg, #b3262c 0 10px, #fffdf7 10px 20px, #1c5b39 20px 30px, #fffdf7 30px 40px);
  --confetti: #b3262c #1c5b39 #d4a531;
}
:root[data-skin="newyear"] {
  color-scheme: dark;
  --bg: #0b1130; --surface: #131a3d; --surface-2: #1b244f;
  --border: #283268; --border-strong: #6672ac;
  --text: #f5f2ea; --muted: #b6bbd6;
  --primary: #e8c36a; --primary-hover: #f3d68f; --primary-soft: #2a2f52; --on-primary: #1a1406;
  --ok: #6fd8a0; --ok-soft: #12302a; --bad: #ff9b91; --bad-soft: #3c1d27; --warn: #f3cd72; --warn-soft: #322a14;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-lg: 0 2px 6px rgba(0, 0, 0, .3), 0 12px 32px rgba(0, 0, 0, .45);
  --skin-pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='170' height='170' viewBox='0 0 170 170'%3E%3Cpath d='M36 30Q38.2 37.8 46 40Q38.2 42.2 36 50Q33.8 42.2 26 40Q33.8 37.8 36 30Z' fill='%23e8c36a' fill-opacity='0.42'/%3E%3Cpath d='M128 111Q129.54 116.46 135 118Q129.54 119.54 128 125Q126.46 119.54 121 118Q126.46 116.46 128 111Z' fill='%23e8c36a' fill-opacity='0.35'/%3E%3Cpath d='M110 26Q110.88 29.12 114 30Q110.88 30.88 110 34Q109.12 30.88 106 30Q109.12 29.12 110 26Z' fill='%23f5f2ea' fill-opacity='0.35'/%3E%3Cpath d='M40 129Q41.1 132.9 45 134Q41.1 135.1 40 139Q38.9 135.1 35 134Q38.9 132.9 40 129Z' fill='%23f5f2ea' fill-opacity='0.28'/%3E%3Ccircle cx='80' cy='82' r='1.6' fill='%23f5f2ea' fill-opacity='0.4'/%3E%3Ccircle cx='150' cy='70' r='1.4' fill='%23e8c36a' fill-opacity='0.5'/%3E%3Ccircle cx='14' cy='90' r='1.2' fill='%23f5f2ea' fill-opacity='0.35'/%3E%3C/svg%3E");
  --skin-band: linear-gradient(90deg, #8a6d2a, #e8c36a 25%, #fff3c9 50%, #e8c36a 75%, #8a6d2a);
  --confetti: #e8c36a #f5f2ea #9fb0ff;
}
:root[data-skin="thanksgiving"] {
  color-scheme: light;
  --bg: #f7eee1; --surface: #fffaf2; --surface-2: #f0e2cd;
  --border: #e4d1b6; --border-strong: #927457;
  --text: #2a1c11; --muted: #67503b;
  --primary: #a03f1a; --primary-hover: #803112; --primary-soft: #f6e1d3; --on-primary: #ffffff;
  --ok: #2f6f2a; --ok-soft: #e7f1e2; --bad: #b42318; --bad-soft: #fcebe9; --warn: #7f5100; --warn-soft: #fbefd8;
  --skin-pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='170' height='170' viewBox='0 0 170 170'%3E%3Cg transform='translate(36 40) rotate(-30) scale(1.0)' fill='%23c8611f' fill-opacity='0.2'%3E%3Cpath d='M0-14C9-9 11 3 0 14C-11 3-9-9 0-14Z'/%3E%3Cpath d='M0 12L0 20' stroke='%23c8611f' stroke-opacity='0.2' stroke-width='1.6'/%3E%3C/g%3E%3Cg transform='translate(130 116) rotate(40) scale(0.8)' fill='%239a3412' fill-opacity='0.18'%3E%3Cpath d='M0-14C9-9 11 3 0 14C-11 3-9-9 0-14Z'/%3E%3Cpath d='M0 12L0 20' stroke='%239a3412' stroke-opacity='0.18' stroke-width='1.6'/%3E%3C/g%3E%3Cg transform='translate(116 32) rotate(110) scale(0.6)' fill='%23d9a21b' fill-opacity='0.26'%3E%3Cpath d='M0-14C9-9 11 3 0 14C-11 3-9-9 0-14Z'/%3E%3Cpath d='M0 12L0 20' stroke='%23d9a21b' stroke-opacity='0.26' stroke-width='1.6'/%3E%3C/g%3E%3Cg transform='translate(44 128) rotate(200) scale(0.7)' fill='%236b4f2a' fill-opacity='0.16'%3E%3Cpath d='M0-14C9-9 11 3 0 14C-11 3-9-9 0-14Z'/%3E%3Cpath d='M0 12L0 20' stroke='%236b4f2a' stroke-opacity='0.16' stroke-width='1.6'/%3E%3C/g%3E%3Ccircle cx='88' cy='84' r='2' fill='%23c8611f' fill-opacity='0.2'/%3E%3C/svg%3E");
  --skin-band: linear-gradient(90deg, #6b4f2a, #9a3412 25%, #c8611f 50%, #d9a21b 75%, #6b4f2a);
  --confetti: #c8611f #9a3412 #d9a21b #6b4f2a;
}
:root[data-skin="halloween"] {
  color-scheme: dark;
  --bg: #130f1a; --surface: #1d1726; --surface-2: #282034;
  --border: #392d49; --border-strong: #76638f;
  --text: #f3eef7; --muted: #bcaecb;
  --primary: #ff9440; --primary-hover: #ffad6e; --primary-soft: #3a2417; --on-primary: #1b0d03;
  --ok: #7fdca0; --ok-soft: #16301f; --bad: #ff908b; --bad-soft: #3e1c1f; --warn: #ffd36e; --warn-soft: #382c10;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-lg: 0 2px 6px rgba(0, 0, 0, .3), 0 12px 32px rgba(0, 0, 0, .45);
  --skin-pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180' viewBox='0 0 180 180'%3E%3Cpath transform='translate(40 44) scale(1.3)' d='M0 2C-2-1-4-1-5 1C-8-3-13-3-16 0C-13 0-11 2-11 5C-9 3-6 3-5 5C-4 3-2 3 0 6C2 3 4 3 5 5C6 3 9 3 11 5C11 2 13 0 16 0C13-3 8-3 5 1C4-1 2-1 0 2Z' fill='%238f5bd6' fill-opacity='0.42'/%3E%3Cpath transform='translate(132 120) scale(0.9)' d='M0 2C-2-1-4-1-5 1C-8-3-13-3-16 0C-13 0-11 2-11 5C-9 3-6 3-5 5C-4 3-2 3 0 6C2 3 4 3 5 5C6 3 9 3 11 5C11 2 13 0 16 0C13-3 8-3 5 1C4-1 2-1 0 2Z' fill='%238f5bd6' fill-opacity='0.36'/%3E%3Cpath transform='rotate(0 126 34)' d='M126.0 30.0L127.1 32.5L129.8 32.8L127.7 34.6L128.4 37.2L126.0 35.8L123.6 37.2L124.3 34.6L122.2 32.8L124.9 32.5Z' fill='%23ff9440' fill-opacity='0.4'/%3E%3Cpath transform='rotate(0 38 138)' d='M38.0 135.0L38.8 136.9L40.9 137.1L39.3 138.4L39.8 140.4L38.0 139.3L36.2 140.4L36.7 138.4L35.1 137.1L37.2 136.9Z' fill='%23c7f05a' fill-opacity='0.35'/%3E%3Ccircle cx='90' cy='90' r='1.5' fill='%23f3eef7' fill-opacity='0.3'/%3E%3Ccircle cx='160' cy='74' r='1.2' fill='%23ff9440' fill-opacity='0.45'/%3E%3C/svg%3E");
  --skin-band: repeating-linear-gradient(-45deg, #ff9440 0 10px, #130f1a 10px 20px, #8f5bd6 20px 30px, #130f1a 30px 40px);
  --confetti: #ff9440 #8f5bd6 #c7f05a;
}
:root[data-skin="valentines"] {
  color-scheme: light;
  --bg: #fdf0f3; --surface: #fffafb; --surface-2: #f9e2e9;
  --border: #f0cfd9; --border-strong: #a57685;
  --text: #2a1017; --muted: #6c4450;
  --primary: #ad1f4d; --primary-hover: #8c173d; --primary-soft: #fbdfe8; --on-primary: #ffffff;
  --ok: #17784b; --ok-soft: #e5f3ec; --bad: #b42318; --bad-soft: #fcebe9; --warn: #8a5300; --warn-soft: #fdf3e2;
  --skin-pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160' viewBox='0 0 160 160'%3E%3Cpath transform='translate(34 30) rotate(-12) scale(1.1)' d='M0 6C-6-1-14 3-10 9L0 18L10 9C14 3 6-1 0 6Z' fill='%23e0386b' fill-opacity='0.16'/%3E%3Cpath transform='translate(120 104) rotate(14) scale(0.8)' d='M0 6C-6-1-14 3-10 9L0 18L10 9C14 3 6-1 0 6Z' fill='%23ad1f4d' fill-opacity='0.14'/%3E%3Cpath transform='translate(104 24) rotate(6) scale(0.5)' d='M0 6C-6-1-14 3-10 9L0 18L10 9C14 3 6-1 0 6Z' fill='%23f59ab5' fill-opacity='0.4'/%3E%3Cpath transform='translate(40 118) rotate(-8) scale(0.6)' d='M0 6C-6-1-14 3-10 9L0 18L10 9C14 3 6-1 0 6Z' fill='%23f59ab5' fill-opacity='0.36'/%3E%3Ccircle cx='80' cy='76' r='2' fill='%23e0386b' fill-opacity='0.2'/%3E%3C/svg%3E");
  --skin-band: linear-gradient(90deg, #f59ab5, #e0386b 30%, #ad1f4d 50%, #e0386b 70%, #f59ab5);
  --confetti: #e0386b #ad1f4d #f59ab5;
}
:root[data-skin="whimsical"] {
  color-scheme: light;
  --bg: #f6f3ff; --surface: #ffffff; --surface-2: #efe9ff;
  --border: #e1d9fa; --border-strong: #8b80b3;
  --text: #1e1736; --muted: #5b5376;
  --primary: #6739cc; --primary-hover: #522aaa; --primary-soft: #ece4ff; --on-primary: #ffffff;
  --ok: #16774a; --ok-soft: #e3f4ea; --bad: #b42318; --bad-soft: #fcebe9; --warn: #8a5300; --warn-soft: #fdf3e2;
  --skin-pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180' viewBox='0 0 180 180'%3E%3Ccircle cx='30' cy='32' r='5' fill='%23ff6f91' fill-opacity='0.35'/%3E%3Cpath transform='translate(120 40) rotate(-15)' d='M-12 0Q-8-6-4 0T4 0T12 0' fill='none' stroke='%2322b8a6' stroke-opacity='0.4' stroke-width='3' stroke-linecap='round'/%3E%3Cpath transform='rotate(12 140 128)' d='M140.0 120.0L142.1 125.1L147.6 125.5L143.4 129.1L144.7 134.5L140.0 131.6L135.3 134.5L136.6 129.1L132.4 125.5L137.9 125.1Z' fill='%23ffc23c' fill-opacity='0.45'/%3E%3Cpath transform='translate(50 128) rotate(20)' d='M0 -8L7.0 4.0L-7.0 4.0Z' fill='%234b9dff' fill-opacity='0.35'/%3E%3Ccircle cx='96' cy='96' r='3' fill='%239b6bff' fill-opacity='0.4'/%3E%3Cpath transform='translate(40 80) rotate(30)' d='M-12 0Q-8-6-4 0T4 0T12 0' fill='none' stroke='%239b6bff' stroke-opacity='0.3' stroke-width='3' stroke-linecap='round'/%3E%3Ccircle cx='160' cy='80' r='3.5' fill='%23ffc23c' fill-opacity='0.4'/%3E%3Cpath transform='translate(100 160) rotate(-15)' d='M0 -5L4.3 2.5L-4.3 2.5Z' fill='%23ff6f91' fill-opacity='0.35'/%3E%3C/svg%3E");
  --skin-band: linear-gradient(90deg, #ff6f91, #ffc23c 25%, #22b8a6 50%, #4b9dff 75%, #9b6bff);
  --confetti: #ff6f91 #22b8a6 #ffc23c #4b9dff #9b6bff;
}
:root[data-skin="kids"] {
  color-scheme: light;
  --bg: #fff7dc; --surface: #ffffff; --surface-2: #fff0c2;
  --border: #f1df9f; --border-strong: #94793a;
  --text: #1b2333; --muted: #4c5768;
  --primary: #1565c8; --primary-hover: #0f50a3; --primary-soft: #e1eeff; --on-primary: #ffffff;
  --ok: #14773f; --ok-soft: #e1f5e7; --bad: #c0262d; --bad-soft: #fdeaea; --warn: #8a5300; --warn-soft: #fff0d4;
  --skin-pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180' viewBox='0 0 180 180'%3E%3Ccircle cx='32' cy='30' r='9' fill='%23ef4444' fill-opacity='0.2'/%3E%3Cpath transform='rotate(8 132 40)' d='M132.0 29.0L134.9 36.0L142.5 36.6L136.7 41.5L138.5 48.9L132.0 45.0L125.5 48.9L127.3 41.5L121.5 36.6L129.1 36.0Z' fill='%23f59e0b' fill-opacity='0.3'/%3E%3Cpath transform='translate(46 130) rotate(-12)' d='M0 -11L9.6 5.5L-9.6 5.5Z' fill='%2322c55e' fill-opacity='0.22'/%3E%3Cpath transform='translate(128 132) rotate(10)' d='M-12 0Q-8-6-4 0T4 0T12 0' fill='none' stroke='%233b82f6' stroke-opacity='0.3' stroke-width='3' stroke-linecap='round'/%3E%3Ccircle cx='92' cy='88' r='5' fill='%23a855f7' fill-opacity='0.22'/%3E%3Ccircle cx='160' cy='96' r='4' fill='%233b82f6' fill-opacity='0.25'/%3E%3Cpath transform='rotate(-10 90 160)' d='M90.0 154.0L91.6 157.8L95.7 158.1L92.6 160.8L93.5 164.9L90.0 162.7L86.5 164.9L87.4 160.8L84.3 158.1L88.4 157.8Z' fill='%23ef4444' fill-opacity='0.25'/%3E%3C/svg%3E");
  --skin-band: repeating-linear-gradient(90deg, #ef4444 0 48px, #f59e0b 48px 96px, #22c55e 96px 144px, #3b82f6 144px 192px, #a855f7 192px 240px);
  --confetti: #ef4444 #f59e0b #22c55e #3b82f6 #a855f7;
}
:root[data-skin] body { background-image: var(--skin-pattern); }
@media (min-width: 700px) { :root[data-skin] body { background-attachment: fixed; } }
:root[data-skin] body::before {
  content: ""; position: fixed; inset: 0 0 auto 0; height: 4px; z-index: 35; pointer-events: none;
  background: var(--skin-band);
}
/* Kids: rounder corners and a friendly rounded face for headings. Whimsical: storybook italics for page titles. */
:root[data-skin="kids"] { --r-sm: 8px; --r-md: 14px; --r-lg: 20px; }
:root[data-skin="kids"] :is(h1, h2, h3, header.site a.brand, .tile .name) { font-family: "Poppins", var(--sans); font-weight: 700; letter-spacing: 0; font-synthesis: none; }
:root[data-skin="whimsical"] :is(h1, h2) { font-family: "Lora", var(--serif); font-style: italic; font-weight: 600; letter-spacing: 0; }

/* ================= Base ================= */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-underline-offset: 3px; }
a:hover { color: var(--primary-hover); }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
[hidden] { display: none !important; }
b, strong { font-weight: 650; }

.wrap { max-width: 760px; margin: 0 auto; padding: 0 var(--s4) var(--s8); }
@media (min-width: 600px) { .wrap { padding: 0 var(--s5) var(--s8); } }
@media (min-width: 1100px) { .wrap.wide { max-width: 1240px; } }

/* ================= Header ================= */
header.site {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s3);
  min-height: var(--header-h); margin-bottom: var(--s6);
  border-bottom: 1px solid var(--border); background: var(--bg);
}
@media (min-width: 600px) {
  header.site { position: sticky; top: 0; z-index: 30; }
}
header.site a.brand {
  display: inline-flex; align-items: center; gap: 10px;
  font-size: 17px; font-weight: 700; letter-spacing: -.01em;
  color: var(--text); text-decoration: none; white-space: nowrap;
}
header.site a.brand img { width: 28px; height: 28px; border-radius: 7px; display: block; }
@media (max-width: 359px) { header.site a.brand { font-size: 15px; gap: 8px; letter-spacing: -.02em; } :root[data-skin="kids"] header.site a.brand { font-size: 14px; } }   /* the name and the theme buttons fit at 320 px */
header.site nav { display: flex; align-items: center; gap: var(--s2); min-width: 0; }
/* The "All exercises" link becomes the back link above the page title (theme.js). */
header.site nav > a { display: none; }

/* Level buttons next to the brand (theme.js): the level's logo; on a computer the name slides out on hover or keyboard focus. */
.level-switch { display: flex; align-items: center; gap: 6px; margin-right: auto; min-width: 0; }
.level-switch .lvl {
  display: inline-flex; align-items: center; gap: 0; height: 38px; padding: 4px;
  border: 1px solid transparent; border-radius: var(--r-md);
  color: var(--text); text-decoration: none; white-space: nowrap;
  transition: gap .25s var(--ease), padding .25s var(--ease), background-color .2s var(--ease), border-color .2s var(--ease);
}
.level-switch .lvl img { width: 28px; height: 28px; border-radius: 7px; display: block; flex: none; transition: transform .25s var(--ease); }
.level-switch .lvl-name {
  display: inline-block; max-width: 0; overflow: hidden; opacity: 0; transform: translateX(-4px);
  font-size: 14px; font-weight: 600;
  transition: max-width .3s var(--ease), opacity .2s var(--ease), transform .3s var(--ease);
}
.level-switch .lvl[aria-current="page"] { border-color: var(--border-strong); background: var(--surface); }
@media (min-width: 700px) {
  .level-switch .lvl:focus-visible { gap: 8px; padding-right: 12px; background: var(--surface); border-color: var(--border-strong); }
  .level-switch .lvl:focus-visible .lvl-name { max-width: 160px; opacity: 1; transform: none; }
}
@media (min-width: 700px) and (hover: hover) and (pointer: fine) {
  .level-switch .lvl:hover { gap: 8px; padding-right: 12px; background: var(--surface); border-color: var(--border-strong); }
  .level-switch .lvl:hover .lvl-name { max-width: 160px; opacity: 1; transform: none; }
  .level-switch .lvl:hover img { transform: scale(1.08) rotate(-4deg); }
}
/* Phones and small tablets: the level buttons get their own row, with room between them for fingers. */
@media (max-width: 699px) {
  header.site { flex-wrap: wrap; row-gap: 0; padding-top: var(--s2); }
  header.site nav { flex: 1 1 0; justify-content: flex-end; }
  .level-switch { order: 3; flex: 1 0 100%; gap: var(--s3); margin: 0; padding: 2px 0 var(--s3); }
  .level-switch .lvl { width: 44px; height: 44px; padding: 0; justify-content: center; }
  .level-switch .lvl img { width: 32px; height: 32px; border-radius: 8px; }
}
/* Six buttons are wider than the narrowest phones allow with 12px gaps: spread them over the row instead. */
@media (max-width: 379px) {
  .level-switch { gap: 4px; justify-content: space-between; }
}

.backlink {
  display: inline-flex; align-items: center; gap: 6px; margin: 0 0 var(--s4);
  font-size: 14px; font-weight: 500; color: var(--muted); text-decoration: none;
}
.backlink svg { width: 16px; height: 16px; transition: transform .15s var(--ease); }
.backlink:hover { color: var(--primary); }
.backlink:hover svg { transform: translateX(-2px); }

.icon-btn, .theme-toggle {
  width: 40px; height: 40px; padding: 0; flex: none;
  display: inline-grid; place-items: center;
  background: transparent; color: var(--muted);
  border: 1px solid transparent; border-radius: var(--r-md); box-shadow: none;
}
.theme-toggle:hover { background: var(--surface-2); color: var(--text); }
.icon-btn svg, .theme-toggle svg {
  width: 20px; height: 20px; display: block;
  fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round;
}

/* Themes menu (theme.js), next to light/dark mode. */
.skin-picker { position: relative; flex: none; }
.skin-btn { position: relative; cursor: pointer; }
.skin-btn:hover, .skin-btn[aria-expanded="true"] { background: var(--surface-2); color: var(--text); }
.skin-btn svg circle { fill: currentColor; stroke: none; }
.skin-dot { position: absolute; right: 7px; bottom: 7px; width: 9px; height: 9px; border-radius: 50%; background: var(--dot, transparent); box-shadow: 0 0 0 2px var(--bg); display: none; }
.skin-btn.on .skin-dot { display: block; }
.skin-menu {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 45;
  width: 232px; max-width: calc(100vw - 32px); padding: 6px;
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  animation: fadein .12s ease;
}
.skin-item {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 40px; padding: 6px 10px;
  background: transparent; color: var(--text); border: 0; border-radius: var(--r-md);
  font-size: 15px; font-weight: 500; text-align: left; white-space: nowrap;
}
.skin-item:hover, .skin-item:focus-visible { background: var(--surface-2); color: var(--text); }
.skin-item:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.skin-item[aria-checked="true"] { font-weight: 650; }
.skin-sw { display: inline-flex; flex: none; }
.skin-sw i { width: 14px; height: 14px; border-radius: 50%; box-shadow: 0 0 0 1.5px var(--surface), 0 0 0 2.5px var(--border); }
.skin-sw i + i { margin-left: -4px; }
.skin-name { flex: 1; }
.skin-check { display: inline-grid; width: 18px; height: 18px; color: var(--primary); visibility: hidden; }
.skin-check svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.25; stroke-linecap: round; stroke-linejoin: round; }
.skin-item[aria-checked="true"] .skin-check { visibility: visible; }
@media (max-width: 699px) { .skin-item { min-height: 44px; } }

/* ================= Type ================= */
h1 { font-size: 32px; line-height: 1.15; font-weight: 700; letter-spacing: -.02em; margin: 0 0 var(--s3); }
h2 { font-size: 22px; line-height: 1.25; font-weight: 650; letter-spacing: -.01em; margin: var(--s7) 0 var(--s4); }
h3 { font-size: 18px; line-height: 1.35; font-weight: 600; margin: var(--s5) 0 var(--s3); }
.kicker {
  margin: 0 0 var(--s2);
  font-size: 12px; line-height: 1.3; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  color: var(--primary);
}
.lead { color: var(--muted); font-size: 17px; margin: 0 0 var(--s5); max-width: 62ch; }
#exercise .lead { font-size: 16px; margin-bottom: var(--s4); }
footer {
  margin-top: var(--s8); padding-top: var(--s5); border-top: 1px solid var(--border);
  color: var(--muted); font-size: 14px;
}
@media (max-width: 599px) {
  h1 { font-size: 28px; }
  h2 { font-size: 20px; margin-top: var(--s6); }
  header.site { margin-bottom: var(--s5); }
}

/* ================= Cards and callouts ================= */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: var(--s5); margin: var(--s4) 0;
}
.card > h3:first-child, .card > p:first-child { margin-top: 0; }
.card > :last-child { margin-bottom: 0; }
@media (min-width: 600px) { .card { padding: 28px; } }
@media (max-width: 599px) { .card { padding: 18px var(--s4); } }

.instructions {
  background: var(--surface-2); border: 0; border-left: 3px solid var(--primary);
  border-radius: var(--r-md); padding: var(--s3) var(--s4); margin: var(--s4) 0 var(--s5);
}
.instructions p { margin: 0; max-width: 75ch; }

/* ================= Home: part tiles ================= */
.grid { display: grid; grid-template-columns: 1fr; gap: var(--s3); }
@media (min-width: 640px) { .grid { grid-template-columns: 1fr 1fr; } }
.grid a.tile {
  position: relative; display: block; min-height: 100%;
  padding: 18px 48px 18px 20px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  color: var(--text); text-decoration: none;
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.grid a.tile::after {
  content: ""; position: absolute; right: 18px; top: 50%; width: 9px; height: 9px; margin-top: -5px;
  border-right: 2px solid var(--muted); border-top: 2px solid var(--muted); transform: rotate(45deg);
  transition: transform .15s var(--ease), border-color .15s var(--ease);
}
.grid a.tile:hover { border-color: var(--primary); box-shadow: var(--shadow-sm); }
.grid a.tile:hover::after { border-color: var(--primary); transform: translateX(3px) rotate(45deg); }
.tile .part { font-size: 12px; line-height: 1.3; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--primary); }
.tile .name { font-size: 17px; line-height: 1.35; font-weight: 650; margin: 4px 0 4px; }
.tile .desc { font-size: 14px; line-height: 1.5; color: var(--muted); }

/* ================= Home: jump bar and topic rows (generator/homelayout.py) ================= */
/* Jump bar: one link per section. Sticks to the top on phones and under the header from 700px. */
.jump {
  position: sticky; top: 0; z-index: 25;
  display: flex; gap: var(--s2); overflow-x: auto; scrollbar-width: none; overscroll-behavior-x: contain;
  margin: var(--s5) calc(-1 * var(--s4)) 0; padding: var(--s2) var(--s4);
  background: var(--bg); border-bottom: 1px solid var(--border);
}
.jump::-webkit-scrollbar { display: none; }
.jump a {
  flex: none; display: inline-flex; align-items: center; min-height: 40px; padding: 0 14px;
  background: var(--surface); color: var(--text); text-decoration: none; white-space: nowrap;
  border: 1px solid var(--border); border-radius: 999px;
  font-size: 14px; font-weight: 600;
  transition: border-color .15s var(--ease), background-color .15s var(--ease);
}
.jump a:hover { border-color: var(--primary); color: var(--text); }
@media (min-width: 600px) {
  .jump { position: relative; flex-wrap: wrap; gap: 6px; margin: var(--s5) 0 0; padding: var(--s2) 0; }
  .jump a { min-height: 36px; padding: 0 11px; }
}
@media (min-width: 700px) { .jump { position: sticky; top: var(--header-h); } }
.wrap > h2[id], .wrap > h3.grp { scroll-margin-top: 76px; }
@media (min-width: 600px) { .wrap > h2[id], .wrap > h3.grp { scroll-margin-top: 136px; } }
@media (min-width: 700px) { .wrap > h2[id], .wrap > h3.grp { scroll-margin-top: calc(var(--header-h) + 68px); } }
/* seven or more links (C1, C2) wrap the bar onto a second row: land the headings under both rows */
@media (min-width: 700px) { .wrap:has(.jump > a:nth-child(7)) > h2[id] { scroll-margin-top: calc(var(--header-h) + 112px); } }

/* "5 sets of 10 sentences", said once under a section heading; group headings (A2 grammar) */
.sec-note { margin: calc(-1 * var(--s2)) 0 var(--s4); font-size: 14px; color: var(--muted); }
h3.grp { font-size: 16px; font-weight: 650; margin: var(--s5) 0 var(--s2); }
.sec-note + h3.grp { margin-top: 0; }

/* Topic rows: Grammar, Vocabulary and Games. One list, two columns from 640px. */
.grid.rows {
  gap: 0 var(--s5); padding: var(--s1) var(--s2);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
}
.grid.rows a.tile {
  display: grid; grid-template-columns: 1.75em minmax(0, 1fr); column-gap: var(--s2); align-content: center;
  min-height: 0; padding: 10px 30px 10px var(--s2);
  background: none; border: 0; border-top: 1px solid var(--border); border-radius: 0;
}
.grid.rows a.tile:first-child { border-top: 0; }
@media (min-width: 640px) { .grid.rows a.tile:nth-child(2) { border-top: 0; } }
.grid.rows a.tile:hover { background: var(--surface-2); border-color: var(--border); box-shadow: none; }
.grid.rows a.tile::after { right: 12px; width: 7px; height: 7px; margin-top: -4px; }
.grid.rows .part {
  grid-row: 1 / span 3; padding-top: 1px;
  font-size: 14px; line-height: 1.4; font-weight: 650; letter-spacing: 0; text-transform: none;
  font-variant-numeric: tabular-nums; color: var(--primary);
}
.grid.rows .part .pk { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.grid.rows .name { grid-column: 2; margin: 0; font-size: 15.5px; line-height: 1.4; font-weight: 600; }
.grid.rows .desc { grid-column: 2; font-size: 13.5px; line-height: 1.45; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.grid.rows .desc .sets { display: none; }
.grid.rows .tile-progress { grid-column: 2; margin-top: var(--s1); font-size: 12.5px; }
.grid.rows.nonum a.tile { grid-template-columns: minmax(0, 1fr); }
.grid.rows.nonum .part { display: none; }
.grid.rows.nonum :is(.name, .desc, .tile-progress) { grid-column: 1; }

/* Other levels: one button per level (home pages) */
.levels { display: flex; flex-wrap: wrap; gap: var(--s3); }
.level-btn {
  display: inline-flex; align-items: center; gap: var(--s3);
  min-height: 52px; padding: var(--s2) var(--s5) var(--s2) var(--s2);
  background: var(--surface); color: var(--text); text-decoration: none;
  border: 1px solid var(--border-strong); border-radius: var(--r-md);
  font-size: 15px; font-weight: 600;
  transition: border-color .15s var(--ease), background-color .15s var(--ease);
}
.level-btn img { width: 36px; height: 36px; border-radius: 8px; display: block; flex: none; }
.level-btn::after {
  content: ""; width: 7px; height: 7px; margin-left: var(--s1);
  border-right: 2px solid var(--muted); border-top: 2px solid var(--muted); transform: rotate(45deg);
  transition: transform .15s var(--ease), border-color .15s var(--ease);
}
.level-btn:hover { border-color: var(--primary); background: var(--surface-2); color: var(--text); }
.level-btn:hover::after { border-color: var(--primary); transform: translateX(2px) rotate(45deg); }
@media (max-width: 479px) { .level-btn { flex: 1 1 100%; } .level-btn::after { margin-left: auto; } }

/* name banner on home pages (log.js) */
.hello {
  margin: calc(-1 * var(--s2)) 0 var(--s5); padding: var(--s3) var(--s4);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
  font-size: 15px;
}
.hello::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 10px; border-radius: 50%; background: var(--ok); vertical-align: 1px; }
.hello:not(:has(b))::before { background: var(--warn); }
.linkish {
  background: none; border: 0; padding: 0; min-height: 0; box-shadow: none;
  color: var(--primary); font: inherit; font-weight: 600;
  text-decoration: underline; text-underline-offset: 3px; cursor: pointer;
}
.linkish:hover { background: none; color: var(--primary-hover); }

/* ================= Buttons ================= */
button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 0 18px;
  font: inherit; font-size: 15px; font-weight: 600; line-height: 1.2; white-space: nowrap;
  color: var(--on-primary); background: var(--primary);
  border: 1px solid var(--primary); border-radius: var(--r-md);
  cursor: pointer;
  transition: background-color .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease);
}
button:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.secondary { background: var(--surface); color: var(--primary); border-color: var(--border-strong); }
button.secondary:hover { background: var(--surface-2); color: var(--primary-hover); border-color: var(--border-strong); }
button.secondary:disabled:hover { background: var(--surface); }
button svg { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }

/* ================= Set navigation (quiz.js) ================= */
.setnav { display: flex; align-items: center; gap: var(--s2); margin: 0 0 var(--s4); }
.setnav .icon-btn { border-color: var(--border-strong); background: var(--surface); color: var(--text); width: 42px; height: 42px; }
.setnav .icon-btn:hover { background: var(--surface-2); color: var(--primary); }
.setnav .icon-btn:disabled { background: var(--surface); color: var(--muted); }
.select-wrap { position: relative; flex: 1 1 auto; min-width: 0; max-width: 520px; }
.select-wrap::after {
  content: ""; position: absolute; right: 16px; top: 50%; width: 7px; height: 7px; margin-top: -6px;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); pointer-events: none;
}
select.setselect {
  width: 100%; height: 42px; padding: 0 40px 0 14px;
  -webkit-appearance: none; appearance: none;
  font: inherit; font-size: 15px; font-weight: 600; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-md);
  text-overflow: ellipsis; cursor: pointer;
}
select.setselect:hover { border-color: var(--primary); }
.setcount { font-size: 14px; color: var(--muted); white-space: nowrap; }
@media (max-width: 599px) { .setcount { display: none; } }

.set-pager { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); margin: var(--s5) 0 0; }
.set-pager a {
  display: flex; flex-direction: column; gap: 2px; min-width: 0;
  padding: var(--s3) var(--s4); border: 1px solid var(--border); border-radius: var(--r-md);
  background: var(--surface); text-decoration: none; color: var(--text);
  transition: border-color .15s var(--ease);
}
.set-pager a:hover { border-color: var(--primary); color: var(--text); }
.set-pager .dir { font-size: 13px; font-weight: 600; color: var(--primary); }
.set-pager .t { font-size: 15px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.set-pager a.next { grid-column: 2; text-align: right; }

/* ================= Reading split (Parts 5–8) ================= */
@media (min-width: 1100px) {
  .wrap.wide > .instructions, .wrap.wide #exercise > .setnav, .wrap.wide .set-view > .lead { max-width: calc(100% - var(--side-w) - var(--s5)); }
  .split { display: grid; grid-template-columns: minmax(0, 1fr) var(--side-w); gap: var(--s5); align-items: start; }
  .pane-side {
    position: sticky; top: calc(var(--header-h) + var(--s4));
    max-height: calc(100vh - var(--header-h) - 120px); overflow-y: auto; overscroll-behavior: contain;
    margin: var(--s4) 0; border-radius: var(--r-lg);
  }
  .pane-side > .card:first-child { margin-top: 0; }
  .pane-side > .card:last-child { margin-bottom: 0; }
  .pane-side .card { padding: var(--s5); }
}

/* ================= Exam texts ================= */
.text { font-family: var(--serif); font-size: 18px; line-height: 1.75; }
.text p { margin: 0 0 1em; }
.text p:last-child { margin-bottom: 0; }
.text-title { font-family: var(--serif); font-size: 22px; line-height: 1.3; font-weight: 650; margin: 0 0 var(--s1); }
.text-sub { font-family: var(--serif); font-style: italic; color: var(--muted); margin: 0 0 var(--s4); }
.text-title + .text { margin-top: var(--s3); }
@media (max-width: 599px) { .text { font-size: 17px; } .text-title { font-size: 20px; } }

/* inline gaps (Parts 1–3, B2 gapped sentences) */
.gapwrap { white-space: nowrap; }
@media (max-width: 400px) { .gapwrap { white-space: normal; } }   /* a gap plus a long word in capitals is wider than a small phone */
.gapnum {
  display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 5px; margin-right: 4px;
  border-radius: 999px; background: var(--primary-soft); color: var(--primary);
  font-family: var(--sans); font-size: 12px; font-weight: 700; line-height: 1; vertical-align: 2px;
}
select.gap, input.gap, select.choice, input.kwt {
  font: inherit; font-family: var(--sans); font-size: 16px; line-height: 1.3;
  color: var(--text); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--r-sm);
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease), background-color .15s var(--ease);
}
select.gap, input.gap { height: 32px; padding: 0 8px; margin: 0 2px; min-width: 8ch; max-width: 100%; vertical-align: 1px; }
input.gap { width: 13ch; }
select.choice { height: 38px; padding: 0 10px; min-width: 64px; border-radius: var(--r-md); }
input.kwt { height: 40px; padding: 0 12px; width: 28ch; max-width: 100%; border-radius: var(--r-md); }
select.gap:hover, input.gap:hover, select.choice:hover, input.kwt:hover { border-color: var(--primary); }
select.gap:focus, input.gap:focus, select.choice:focus, input.kwt:focus, textarea:focus, .name-card input:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft);
}
.stem { font-family: var(--sans); font-size: 13px; font-weight: 700; letter-spacing: .04em; color: var(--muted); margin-left: 4px; }
.gapwrap > b { font-family: var(--sans); font-size: 16px; padding: 2px 8px; border-radius: var(--r-sm); background: var(--surface-2); }

/* right / wrong: colour plus a mark, never colour alone */
.ok { background: var(--ok-soft) !important; border-color: var(--ok) !important; }
.bad { background: var(--bad-soft) !important; border-color: var(--bad) !important; }
.gapwrap:has(> .ok)::after, .slot:has(.ok)::after, .match-row:has(.ok)::after, .kwt-row:has(.ok)::after, .opts label.ok::after {
  content: "✓"; color: var(--ok); font-family: var(--sans); font-weight: 800; margin-left: 5px;
}
.gapwrap:has(> .bad)::after, .slot:has(.bad)::after, .match-row:has(.bad)::after, .kwt-row:has(.bad)::after, .opts label.bad::after {
  content: "✗"; color: var(--bad); font-family: var(--sans); font-weight: 800; margin-left: 5px;
}
.opts label.ok::after, .opts label.bad::after { margin-left: auto; padding-left: var(--s2); }
.reveal { font-family: var(--sans); font-size: 14px; font-weight: 600; color: var(--ok); margin-left: 3px; }

/* ================= Questions (Parts 4, 5) ================= */
.q { padding: var(--s5) 0; border-top: 1px solid var(--border); }
.q:first-child { border-top: 0; padding-top: 0; }
.card > h3 + .q { border-top: 0; padding-top: 0; }
.q:last-child { padding-bottom: 0; }
.q .prompt { display: flex; gap: var(--s3); align-items: flex-start; font-weight: 500; margin: 0 0 var(--s3); }
.q .prompt .n, .match-row .n {
  display: inline-grid; place-items: center; flex: none; min-width: 28px; height: 28px; padding: 0 6px;
  border-radius: 999px; background: var(--primary-soft); color: var(--primary);
  font-size: 13px; font-weight: 700; line-height: 1;
}
.opts { display: grid; gap: var(--s2); }
.opts label {
  display: flex; gap: var(--s3); align-items: flex-start;
  padding: 10px 14px; min-height: 44px;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-md);
  cursor: pointer; transition: border-color .15s var(--ease), background-color .15s var(--ease);
}
.opts label:hover { border-color: var(--primary); }
.opts label:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.opts label:has(input:focus-visible) { outline: 2px solid var(--primary); outline-offset: 2px; }
.opts input { margin: 4px 0 0; accent-color: var(--primary); flex: none; }
.opts .letter { font-weight: 700; min-width: 1.1em; }
.explain { display: none; margin-top: var(--s3); padding: var(--s3) var(--s4); font-size: 15px; color: var(--text); background: var(--surface-2); border-radius: var(--r-md); }
.checked .explain { display: block; }
.also { color: var(--muted); font-size: 14px; }

/* key word transformations */
.kwt-key {
  display: inline-block; margin: 0 0 var(--s3) 40px; padding: 3px 12px;
  font-weight: 800; letter-spacing: .1em; font-size: 15px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-sm);
}
.kwt-row { line-height: 2.6; margin-left: 40px; }
.q .explain { margin-left: 40px; }
@media (max-width: 599px) { .kwt-key, .kwt-row, .q .explain { margin-left: 0; } }

/* matching (Parts 6, 8) */
.match-row { display: flex; gap: var(--s3); align-items: center; padding: var(--s3) 0; border-top: 1px solid var(--border); }
.match-row:first-of-type { border-top: 0; }
.match-row .stmt { flex: 1; }
.q-intro { font-size: 15px; color: var(--muted); margin: 0 0 var(--s2); }
.sec-badge {
  display: inline-grid; place-items: center; min-width: 30px; height: 30px; padding: 0 6px; margin-right: 10px; vertical-align: 2px;
  border-radius: var(--r-sm); background: var(--primary); color: var(--on-primary);
  font-family: var(--sans); font-size: 15px; font-weight: 700;
}

/* gapped text (C1 Part 7, B2 Part 6) */
.slot {
  display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap;
  margin: var(--s3) 0 var(--s5); padding: 10px 14px;
  font-family: var(--sans); font-size: 15px; font-weight: 500;
  background: var(--surface-2); border: 1px dashed var(--border-strong); border-radius: var(--r-md);
}
.para-bank .para {
  margin: 0; padding: var(--s4) 0;
  font-family: var(--serif); font-size: 16.5px; line-height: 1.65;
  border-top: 1px solid var(--border);
}
.para-bank h3 + .para { border-top: 0; padding-top: 0; }
.para-bank .para:last-child { padding-bottom: 0; }
.para-bank .para b {
  display: inline-grid; place-items: center; width: 24px; height: 24px; margin-right: 8px; vertical-align: 1px;
  border-radius: var(--r-sm); background: var(--primary-soft); color: var(--primary);
  font-family: var(--sans); font-size: 13px; font-weight: 700;
}

/* answers and explanations */
.notes-list { margin: 0; padding: 0; list-style: none; }
.notes-list li { padding: 10px 0; border-top: 1px solid var(--border); font-size: 15px; line-height: 1.55; }
.notes-list li:first-child { border-top: 0; padding-top: 0; }
.notes-list .n {
  display: inline-grid; place-items: center; min-width: 24px; height: 24px; padding: 0 5px; margin-right: 8px;
  border-radius: 999px; background: var(--primary-soft); color: var(--primary); font-size: 12px; font-weight: 700; vertical-align: 1px;
}
.tick { color: var(--ok); font-weight: 800; margin-right: 6px; }
.cross { color: var(--bad); font-weight: 800; margin-right: 6px; }

/* ================= Action bar ================= */
.bar {
  position: sticky; bottom: var(--s3); z-index: 20;
  display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap;
  margin-top: var(--s5); padding: 10px 10px 10px 18px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
}
.bar .status { margin-right: auto; display: flex; align-items: center; gap: var(--s3); min-width: 0; font-size: 14px; color: var(--muted); }
.bar .progress { white-space: nowrap; }
.bar .meter { width: 72px; height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; flex: none; }
.bar .meter i { display: block; height: 100%; width: 0; background: var(--primary); border-radius: inherit; transition: width .2s var(--ease); }
.score { font-size: 16px; font-weight: 700; color: var(--text); white-space: nowrap; }
.score.perfect { color: var(--ok); }
.score.perfect::after { content: " ✓"; }
.bar .reset { background: transparent; border-color: transparent; color: var(--muted); }
.bar .reset:hover { background: var(--surface-2); border-color: transparent; color: var(--text); }
@media (max-width: 599px) {
  .bar { display: grid; grid-template-columns: 42px 1fr 1fr; bottom: var(--s2); padding: 10px; gap: var(--s2); }
  .bar .status { grid-column: 1 / -1; padding: 0 4px 2px; }
  .bar .meter { flex: 1; }
  .bar button { min-width: 0; padding: 0 8px; }
  .bar .reset { width: 42px; padding: 0; border-color: var(--border-strong); color: var(--text); }
  .bar .reset .label { display: none; }
}

/* ================= Writing ================= */
.tabs {
  display: flex; gap: var(--s1); margin: var(--s3) 0 var(--s4);
  overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--border);
}
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  flex: none; min-height: 44px; padding: 0 14px; margin-bottom: -1px;
  background: transparent; color: var(--muted); font-weight: 600;
  border: 0; border-bottom: 2px solid transparent; border-radius: var(--r-sm) var(--r-sm) 0 0;
}
.tabs button:hover { background: var(--surface-2); color: var(--text); border-color: transparent; border-bottom-color: var(--border-strong); }
.tabs button[aria-selected="true"] { color: var(--primary); border-bottom-color: var(--primary); background: transparent; }
.tabs button:focus-visible { outline-offset: -2px; }
.tabpanel > .card:first-child { margin-top: 0; }

.notes-box { background: var(--surface-2); border-radius: var(--r-md); padding: var(--s3) var(--s4); margin: var(--s3) 0; }
.notes-box ul { margin: 6px 0 0; padding-left: 20px; }
.small-note { color: var(--muted); font-size: 14px; margin-bottom: 0; }
textarea {
  display: block; width: 100%; min-height: 320px; resize: vertical; margin-top: var(--s4);
  padding: 14px 16px;
  font-family: var(--serif); font-size: 17px; line-height: 1.65; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-md);
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
textarea::placeholder { color: var(--muted); }
.counter { margin-top: var(--s2); font-size: 14px; font-weight: 500; color: var(--muted); }
.counter.in { color: var(--ok); font-weight: 600; }
.counter.out { color: var(--bad); font-weight: 600; }
.counter.in::before { content: "✓ "; }
.counter.out::before { content: "! "; }
.task > button.secondary { margin-top: var(--s3); }
.checklist label { display: flex; gap: var(--s3); align-items: flex-start; padding: 8px 6px; border-radius: var(--r-sm); cursor: pointer; }
.checklist label:hover { background: var(--surface-2); }
.checklist input { width: 18px; height: 18px; margin: 3px 0 0; accent-color: var(--primary); flex: none; }
.checklist label:has(input:checked) span { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--border-strong); }

/* ================= Name chip, dialog, toast (log.js) ================= */
.name-chip {
  min-width: 0; flex: 0 1 auto; justify-content: flex-start;
  min-height: 40px; max-width: 46vw; padding: 0 12px 0 6px; gap: 8px;
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 999px;
  font-size: 14px; font-weight: 600;
}
.name-chip:hover { background: var(--surface-2); border-color: var(--border-strong); color: var(--text); }
.name-chip .avatar {
  display: inline-grid; place-items: center; width: 28px; height: 28px; flex: none; border-radius: 50%;
  background: var(--primary-soft); color: var(--primary); font-size: 13px; font-weight: 700;
}
.name-chip .who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.name-chip .edit { color: var(--primary); font-weight: 500; font-size: 13px; }
.name-chip .who + .edit { color: var(--muted); }
@media (max-width: 599px) { .name-chip .who + .edit { display: none; } }
.name-chip:not(:has(.who)) { padding-left: 12px; }

.name-modal {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: var(--s4);
  background: rgba(17, 19, 22, .45);
  animation: fadein .15s ease;
}
.name-modal.out { animation: fadeout .15s ease forwards; }
.name-card {
  width: min(420px, 100%); padding: var(--s6) 28px 28px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-lg);
}
.name-card .wave { display: none; }
.name-card h2 { margin: 0 0 var(--s2); font-size: 22px; }
.name-card p { color: var(--muted); margin: 0 0 var(--s5); font-size: 15px; }
.name-card label { display: block; font-size: 14px; font-weight: 600; margin: 0 0 6px; }
.name-card input {
  width: 100%; height: 46px; margin-bottom: var(--s4); padding: 0 14px;
  font: inherit; font-size: 16px; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-md);
}
.name-card button { width: 100%; min-height: 46px; font-size: 16px; }
/* Report a problem (log.js, under every set) */
.report-line { margin: var(--s4) 0 0; text-align: center; font-size: 14px; color: var(--muted); }
.report-line .linkish { font-weight: 500; }
.report-card label .opt { font-weight: 400; color: var(--muted); }
.report-card textarea { min-height: 110px; margin: 0 0 var(--s4); padding: 10px 14px; font-family: inherit; font-size: 16px; line-height: 1.5; }
.report-card .report-actions { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s2); }

.toast {
  position: fixed; left: 50%; top: var(--s4); transform: translateX(-50%); z-index: 60;
  max-width: calc(100vw - 32px); padding: 10px 16px;
  background: var(--text); color: var(--bg); border-radius: var(--r-md); box-shadow: var(--shadow-lg);
  font-size: 14.5px; font-weight: 600;
  animation: toastin .2s var(--ease);
}
.toast.toast-ok { background: var(--ok); color: #fff; }
:root[data-theme="dark"] .toast.toast-ok { color: #0e1a13; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .toast.toast-ok { color: #0e1a13; } }
.toast.toast-warn { background: var(--warn-soft); color: var(--warn); border: 1px solid var(--warn); }
.toast.out { animation: fadeout .3s ease forwards; }

/* ================= Motion ================= */
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeout { to { opacity: 0; } }
@keyframes toastin { from { opacity: 0; transform: translate(-50%, -6px); } to { opacity: 1; transform: translate(-50%, 0); } }
.set-enter { animation: fadein .15s ease; }
html.theme-anim, html.theme-anim *, html.theme-anim *::before, html.theme-anim *::after {
  transition: background-color .2s ease, color .2s ease, border-color .2s ease !important;
}

/* confetti for a perfect score (theme.js) */
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 70; overflow: hidden; }
.confetti i { position: absolute; top: -14px; width: 9px; height: 13px; border-radius: 2px; animation: fall linear forwards; }
@keyframes fall { to { transform: translate(var(--dx), 105vh) rotate(var(--rot)); opacity: .9; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ================= A2 / B1: sentence sets, word bank, short texts (quiz.js) ================= */
.sentences .q.sent { padding: var(--s4) 0; }
.sentences .q.sent:first-child { padding-top: 0; }
.sentences .q.sent:last-child { padding-bottom: 0; }
.q.sent .prompt { margin: 0; line-height: 2.1; }
.q.sent .prompt .n { margin-top: 4px; }
.q.sent .s { flex: 1; min-width: 0; }
.q.sent .explain { margin-top: var(--s2); }
.blank {
  display: inline-block; min-width: 6ch; padding: 0 8px; margin: 0 2px; line-height: 1.6;
  border-bottom: 2px solid var(--border-strong); color: var(--primary); font-weight: 600; text-align: center;
  border-radius: var(--r-sm) var(--r-sm) 0 0;
}
.blank.filled { background: var(--primary-soft); border-bottom-color: var(--primary); }
.q.sent .blank { white-space: normal; max-width: 100%; }
.blank.ok, .blank.bad { border-width: 0 0 2px; border-style: solid; }
.chips { display: flex; flex-wrap: wrap; gap: var(--s2); margin: var(--s2) 0 0 40px; }
.chips label {
  position: relative; display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 6px 14px;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 999px;
  font-size: 15px; font-weight: 500; cursor: pointer;
  transition: border-color .15s var(--ease), background-color .15s var(--ease);
}
.chips label:hover { border-color: var(--primary); }
.chips label:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.chips label:has(input:focus-visible) { outline: 2px solid var(--primary); outline-offset: 2px; }
.chips input { position: absolute; left: 0; top: 0; opacity: 0; width: 1px; height: 1px; margin: 0; pointer-events: none; }
.chips label.ok::after { content: "✓"; color: var(--ok); font-weight: 800; }
.chips label.bad::after { content: "✗"; color: var(--bad); font-weight: 800; }
@media (max-width: 599px) { .chips { margin-left: 0; } }
.bank { padding: var(--s4) var(--s5); }
.bank-label { margin: 0 0 var(--s2); font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.bank-words { display: flex; flex-wrap: wrap; gap: var(--s2); }
.bank-words span { padding: 4px 12px; font-size: 15px; font-weight: 500; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-sm); }
.short-grid { display: grid; gap: var(--s4); }
@media (min-width: 680px) { .short-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; } }
.short-text { padding: var(--s4); font-family: var(--serif); font-size: 17px; line-height: 1.6; background: var(--surface-2); border-radius: var(--r-md); }
.short-text p { margin: 0 0 .6em; }
.short-text p:last-child { margin-bottom: 0; }
.short-text .st-head { font-family: var(--sans); font-size: 13px; font-weight: 600; color: var(--muted); }
.short-text .st-title { font-weight: 700; }
.st-notice { text-align: center; background: var(--surface); border: 2px solid var(--text); font-family: var(--sans); font-size: 16px; font-weight: 500; }
.st-notice .st-title { font-size: 17px; letter-spacing: .02em; }
.st-message { border-left: 3px solid var(--border-strong); border-radius: 0 var(--r-md) var(--r-md) 0; }
.q.short > .prompt { margin-bottom: var(--s3); }
.q.short .explain { margin-left: 0; }

/* ================= A2 / B1: grammar guide tab (quiz.js wires the tabs) ================= */
.page-tabs { margin: var(--s4) 0 0; }
.page-tabs + [role="tabpanel"] > .instructions { margin-top: var(--s4); }
.guide { padding-top: var(--s4); }
.guide-intro { font-size: 17px; margin: 0 0 var(--s4); max-width: 65ch; }
.guide-sec h2 { font-size: 20px; margin: 0 0 var(--s3); }
.guide-sec h3 { font-size: 16px; margin: var(--s5) 0 var(--s2); }
.guide-sec p { max-width: 68ch; }
.guide .ex-label {
  margin: var(--s4) 0 var(--s1);
  font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted);
}
.guide ul.ex { list-style: none; margin: 0 0 var(--s3); padding: 0; }
.guide ul.ex li { position: relative; padding: 5px 0 5px 20px; font-family: var(--serif); font-size: 17px; line-height: 1.5; }
.guide ul.ex li::before { content: ""; position: absolute; left: 3px; top: 16px; width: 6px; height: 6px; border-radius: 50%; background: var(--border-strong); }
.guide ul.ex b, .guide .form-table b, .guide .eg b { color: var(--primary); font-weight: 650; }
.guide ul.ex .note { display: block; margin-top: 2px; font-family: var(--sans); font-size: 14px; line-height: 1.45; color: var(--muted); }
.guide .eg { font-family: var(--serif); font-size: 17px; }
.guide .muted { color: var(--muted); font-size: 14px; }
.guide .tip {
  margin: var(--s4) 0 0; padding: var(--s3) var(--s4);
  background: var(--surface-2); border-radius: var(--r-md); font-size: 15px; max-width: none;
}
.table-wrap { overflow-x: auto; margin: var(--s3) 0; -webkit-overflow-scrolling: touch; }
.form-table { border-collapse: collapse; width: 100%; font-size: 15px; line-height: 1.45; }
.form-table th, .form-table td { text-align: left; vertical-align: top; padding: 8px 12px 8px 0; border-bottom: 1px solid var(--border); }
.form-table th { font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.form-table tr:last-child td { border-bottom: 0; }
.form-table .nw, .guide .nw { white-space: nowrap; }
.form-table td:last-child, .form-table th:last-child { padding-right: 0; }
@media (max-width: 400px) { .form-table { font-size: 14px; } .form-table th, .form-table td { padding-right: 8px; } }
/* diagrams: inline SVG, coloured with the theme tokens */
.diagram { margin: var(--s4) 0; }
.diagram svg { display: block; width: 100%; max-width: 440px; height: auto; margin: 0 auto; overflow: visible; }
.diagram figcaption { margin: var(--s2) auto 0; max-width: 440px; font-size: 14px; color: var(--muted); text-align: center; }
.dg-axis { stroke: var(--border-strong); stroke-width: 2; fill: none; }
.dg-head { fill: var(--border-strong); }
.dg-now { stroke: var(--muted); stroke-width: 1.5; stroke-dasharray: 4 4; fill: none; }
.dg-acc { stroke: var(--primary); stroke-width: 2.5; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.dg-acc-fill { fill: var(--primary); }
.dg-band { fill: var(--primary-soft); stroke: var(--primary); stroke-width: 1.5; }
.dg-band2 { fill: var(--warn-soft); stroke: var(--warn); stroke-width: 1.5; }
.dg-acc2 { stroke: var(--warn); stroke-width: 2.5; fill: none; stroke-linecap: round; }
.dg-acc2-fill { fill: var(--warn); }
.dg-box { fill: var(--surface); stroke: var(--border-strong); stroke-width: 1.5; }
.dg-box-acc { fill: var(--primary-soft); stroke: var(--primary); stroke-width: 1.5; }
.dg-t { fill: var(--text); font-family: var(--sans); font-size: 14px; font-weight: 500; }
.dg-tb { fill: var(--text); font-family: var(--sans); font-size: 14px; font-weight: 700; }
.dg-ta { fill: var(--primary); font-family: var(--sans); font-size: 14px; font-weight: 700; }
.dg-ta2 { fill: var(--warn); font-family: var(--sans); font-size: 14px; font-weight: 700; }
.dg-s { fill: var(--muted); font-family: var(--sans); font-size: 12.5px; font-weight: 500; }
.dg-h { fill: var(--muted); font-family: var(--sans); font-size: 12px; font-weight: 600; letter-spacing: .05em; }

/* notes on writing prompts (A2/B1 writing pages) */
.wnote { font-family: var(--sans); font-size: 14px; font-weight: 650; color: var(--primary); white-space: nowrap; }

/* ================= Saved progress on the home pages (progress.js) ================= */
.tile-progress {
  display: flex; align-items: center; gap: var(--s2); margin-top: var(--s2);
  font-size: 13px; line-height: 1.4; font-weight: 500; color: var(--muted);
}
.tile-progress .meter, .sk-stat .meter { height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; flex: none; }
.tile-progress .meter { width: 56px; }
.tile-progress .meter i, .sk-stat .meter i { display: block; height: 100%; background: var(--primary); border-radius: inherit; }
.tile-progress.all { color: var(--ok); }
.tile-progress.all .meter i { background: var(--ok); }
.tile-progress.all span:last-child::after { content: " ✓"; font-weight: 800; }
a.continue {
  position: relative; display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px var(--s3);
  margin: 0 0 var(--s5); padding: var(--s3) 44px var(--s3) var(--s4);
  background: var(--primary-soft); border: 1px solid transparent; border-radius: var(--r-md);
  color: var(--text); text-decoration: none; font-size: 15px;
  transition: border-color .15s var(--ease);
}
.hello + a.continue { margin-top: calc(-1 * var(--s3)); }
a.continue::after {
  content: ""; position: absolute; right: 18px; top: 50%; width: 8px; height: 8px; margin-top: -5px;
  border-right: 2px solid var(--primary); border-top: 2px solid var(--primary); transform: rotate(45deg);
}
a.continue:hover { border-color: var(--primary); color: var(--text); }
a.continue .c-k { font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--primary); }
a.continue .c-t { font-weight: 600; }
a.continue .c-s { font-size: 14px; color: var(--muted); }

/* ================= My weak spots (weak.js) ================= */
button.small { min-height: 36px; padding: 0 14px; font-size: 14px; }
a.btn-link {
  display: inline-flex; align-items: center; min-height: 36px; padding: 0 14px;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-md);
  font-size: 14px; font-weight: 600; text-decoration: none; white-space: nowrap;
}
a.btn-link:hover { background: var(--surface-2); }
.skill-list { margin: 0; padding: 0; list-style: none; }
.skill {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: var(--s2) var(--s4);
  padding: var(--s4) 0; border-top: 1px solid var(--border);
}
.skill:first-child { border-top: 0; padding-top: 0; }
.skill:last-child { padding-bottom: 0; }
.sk-name { font-weight: 600; }
.sk-desc { font-size: 14px; line-height: 1.45; color: var(--muted); }
.sk-stat { display: flex; flex-wrap: wrap; align-items: center; gap: 4px var(--s2); margin-top: 6px; font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }
.sk-stat .meter { width: 96px; }
.sk-stat b { color: var(--text); font-weight: 700; }
@media (max-width: 599px) {
  .skill { grid-template-columns: 1fr; }
  .skill > button, .skill > a { justify-self: start; }
}
.focus > button.focus-go { margin-top: var(--s5); }
.focus > .small-note + button.focus-go { margin-top: var(--s4); }
.practice-title { margin-top: 0; }
.task-kind { margin: 0 0 var(--s2); font-size: 14px; line-height: 1.45; color: var(--muted); }
.mixed .q:not(.sent) { padding: var(--s4) 0; }
.mixed .q:not(.sent):first-child { padding-top: 0; }
.mixed .gapwrap { white-space: normal; }
.explain .src { display: block; margin-top: 6px; font-size: 13px; color: var(--muted); }

/* ================= Exam mode (exam.js) ================= */
.plain-list { margin: 0 0 var(--s5); padding-left: 20px; }
.plain-list li { margin: 6px 0; max-width: 68ch; }
.exam-tabs { margin-top: 0; }
.exam-tabs button { flex-direction: column; gap: 1px; min-height: 52px; line-height: 1.2; }
.exam-tabs .cnt { font-size: 12px; font-weight: 500; color: var(--muted); font-variant-numeric: tabular-nums; }
.exam-part > h2 { margin: var(--s5) 0 var(--s3); }
.timer { font-size: 16px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; white-space: nowrap; }
.timer.low { color: var(--bad); }
.exam-result { margin-top: 0; }
.exam-result h2 { margin: 0 0 var(--s2); }
.exam-result .big { margin: 0 0 var(--s3); font-size: 32px; line-height: 1.2; font-weight: 700; letter-spacing: -.02em; }
.exam-result .big span { display: block; margin-top: 2px; font-size: 15px; font-weight: 500; letter-spacing: 0; color: var(--muted); }
.result-table .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.result-table .muted { font-size: 13px; color: var(--muted); }
.name-card .stack { display: grid; gap: var(--s2); }

/* "How to tackle it" tab on Use of English and Reading pages */
.guide-sec .steps { margin: 0; padding-left: 22px; }
.guide-sec .steps li { margin: 0 0 10px; padding-left: 4px; max-width: 70ch; }
.guide-sec .steps li:last-child { margin-bottom: 0; }

/* ================= Move my progress (move.js) ================= */
#move .card > h2:first-child { margin-top: 0; margin-bottom: var(--s2); }
#move .card.move-in { border-color: var(--primary); box-shadow: var(--shadow-sm); }
.move-actions { display: flex; flex-wrap: wrap; gap: var(--s3); margin-top: var(--s4); }
textarea.code-in {
  min-height: 0; height: auto; margin-top: var(--s2); padding: 10px 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 14px; line-height: 1.5;
  word-break: break-all; resize: vertical;
}
.move-msg:empty { display: none; }
.move-msg { margin: var(--s3) 0 0; font-weight: 600; }
.move-msg.ok { color: var(--ok); }
.move-msg.bad { color: var(--bad); }
.move-msg a { font-weight: 600; white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ================= Site footer (every page, sitewide.py) ================= */
footer.site-foot p { margin: 0 0 var(--s3); max-width: 75ch; }
footer.site-foot p:last-child { margin-bottom: 0; }
.foot-links { display: flex; flex-wrap: wrap; gap: 0 var(--s5); }
.foot-links a { display: inline-block; padding: 6px 0; font-weight: 600; text-decoration: none; }
.foot-links a:hover { text-decoration: underline; }
footer.site-foot .legal { font-size: 13px; line-height: 1.5; }

/* Links that look like buttons */
a.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 0 18px;
  font-size: 15px; font-weight: 600; line-height: 1.2; white-space: nowrap; text-decoration: none;
  color: var(--on-primary); background: var(--primary);
  border: 1px solid var(--primary); border-radius: var(--r-md);
  transition: background-color .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease);
}
a.btn:hover { color: var(--on-primary); background: var(--primary-hover); border-color: var(--primary-hover); }
a.btn.secondary { color: var(--primary); background: var(--surface); border-color: var(--border-strong); }
a.btn.secondary:hover { color: var(--primary-hover); background: var(--surface-2); }

/* ================= Front page (index.html) ================= */
.cta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s4) var(--s5); }
.cta-text { flex: 1 1 300px; min-width: 0; }
.cta h2 { margin: 0 0 var(--s1); font-size: 20px; }
.cta p { margin: 0; color: var(--muted); font-size: 15px; }
.cta p b { color: var(--text); }
.cta-actions { display: flex; flex-wrap: wrap; gap: var(--s3); }
@media (max-width: 599px) { .cta-actions { flex: 1 1 100%; } .cta-actions a.btn { flex: 1 1 auto; } }
.level-cards { display: grid; grid-template-columns: 1fr; gap: var(--s3); }
@media (min-width: 640px) { .level-cards { grid-template-columns: 1fr 1fr; } }
.level-cards a {
  position: relative; display: flex; align-items: flex-start; gap: var(--s4);
  padding: 18px 48px 18px 18px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  color: var(--text); text-decoration: none;
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.level-cards a::after {
  content: ""; position: absolute; right: 18px; top: 50%; width: 9px; height: 9px; margin-top: -5px;
  border-right: 2px solid var(--muted); border-top: 2px solid var(--muted); transform: rotate(45deg);
  transition: transform .15s var(--ease), border-color .15s var(--ease);
}
.level-cards a:hover { border-color: var(--primary); box-shadow: var(--shadow-sm); color: var(--text); }
.level-cards a:hover::after { border-color: var(--primary); transform: translateX(3px) rotate(45deg); }
.level-cards img { width: 48px; height: 48px; border-radius: 11px; display: block; flex: none; }
.lc-name { display: block; margin: 1px 0 4px; font-size: 17px; line-height: 1.35; font-weight: 650; }
.lc-desc { display: block; font-size: 14px; line-height: 1.5; color: var(--muted); }
.lc-badge {
  display: inline-block; margin-left: var(--s2); padding: 2px 8px; vertical-align: 2px;
  font-size: 12px; line-height: 1.4; font-weight: 600; letter-spacing: .02em;
  color: var(--primary); background: var(--primary-soft); border-radius: 999px;
}
.level-cards a.suggested { border-color: var(--primary); }

/* ================= Level test (placement.js) ================= */
.place-steps { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; margin: 0 0 var(--s2); }
.place-steps i { height: 6px; border-radius: 999px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--border); }
.place-steps i.done { background: var(--primary); box-shadow: none; }
.place-steps i.now { background: var(--primary-soft); box-shadow: inset 0 0 0 1px var(--primary); }
.place-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0 var(--s3); margin: 0 0 var(--s3); font-size: 14px; color: var(--muted); }
.place-head b { color: var(--text); }
.place-part { margin-top: 0; }
.place-next { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: var(--s3) var(--s4); margin-top: var(--s4); }
.place-count { margin-right: auto; font-size: 14px; color: var(--muted); }
.place-count.bad { color: var(--bad); font-weight: 600; }
@media (max-width: 599px) { .place-next button { flex: 1 1 100%; } }
.place-result h2 { margin: 0 0 var(--s2); }
.place-result > p { max-width: 62ch; }
.place-result .cta-actions { margin-top: var(--s4); }
.place-break { list-style: none; margin: var(--s5) 0 0; padding: 0; }
.place-break li { display: flex; justify-content: space-between; gap: var(--s3); padding: 10px 0; border-top: 1px solid var(--border); font-size: 15px; }
.place-break li:first-child { border-top: 0; }
.place-break .pts { font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }
.place-break .pass .pts { color: var(--ok); }
.place-break .pass .pts::after { content: " ✓"; font-weight: 800; }
.place-break .skip { color: var(--muted); }
.place-break .skip .pts { font-weight: 500; }
.place-review .chips label { cursor: default; }
.place-review .chips label:hover { border-color: var(--border-strong); }
.place-review .chips label.ok:hover { border-color: var(--ok); }
.place-review .chips label.bad:hover { border-color: var(--bad); }

/* ================= Privacy page ================= */
.prose h2 { margin: var(--s6) 0 var(--s3); font-size: 20px; }
.prose p, .prose li { max-width: 68ch; }
.prose ul { margin: 0 0 var(--s4); padding-left: 20px; }
.prose li { margin: 6px 0; }
.updated { margin: 0 0 var(--s5); font-size: 14px; color: var(--muted); }

/* ================= Search (search.html, search.js; the box also on the home pages) ================= */
.search-box { position: relative; display: flex; gap: var(--s2); margin: 0 0 var(--s5); }
.search-box .sb-icon {
  position: absolute; left: 14px; top: 23px; width: 20px; height: 20px; margin-top: -10px; pointer-events: none;
  fill: none; stroke: var(--muted); stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round;
}
.search-box input[type="search"] {
  flex: 1 1 auto; min-width: 0; height: 46px; margin: 0; padding: 0 14px 0 42px;
  font: inherit; font-size: 16px; color: var(--text); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--r-md); -webkit-appearance: none; appearance: none;
}
.search-box input[type="search"]::placeholder { color: var(--muted); opacity: 1; }
.search-box input[type="search"]:hover { border-color: var(--primary); }
.search-box input[type="search"]:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.search-box button { min-height: 46px; }
@media (max-width: 479px) { .search-box button { padding: 0 14px; } }
.filters { display: flex; flex-wrap: wrap; gap: var(--s3) var(--s5); margin: calc(-1 * var(--s2)) 0 var(--s4); }
.seg { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.seg-label { margin-right: 4px; font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.seg label {
  position: relative; display: inline-flex; align-items: center; min-height: 40px; padding: 0 14px;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 999px;
  font-size: 14px; font-weight: 600; cursor: pointer;
  transition: border-color .15s var(--ease), background-color .15s var(--ease);
}
.seg label:hover { border-color: var(--primary); }
.seg label:has(input:checked) { color: var(--on-primary); background: var(--primary); border-color: var(--primary); }
.seg label:has(input:focus-visible) { outline: 2px solid var(--primary); outline-offset: 2px; }
.seg input { position: absolute; left: 0; top: 0; width: 1px; height: 1px; margin: 0; opacity: 0; pointer-events: none; }
@media (max-width: 599px) { .seg-label { flex: 0 0 100%; margin: 0 0 2px; } .seg label { padding: 0 12px; } }
.search-status { min-height: 1.5em; margin: 0 0 var(--s4); font-size: 15px; color: var(--muted); }
.search-status b { color: var(--text); }
#search-results > h2:first-child { margin-top: var(--s5); }
.search-suggest p, .search-empty p { margin: 0 0 var(--s3); color: var(--muted); }
.suggest-list { display: flex; flex-wrap: wrap; gap: var(--s2); }
.hit-k { display: block; font-size: 12px; line-height: 1.3; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--primary); }
.topic-hits img { width: 36px; height: 36px; border-radius: 8px; }
.topic-hits .lc-name { margin-top: 3px; }
mark { color: var(--text); font-weight: 600; background: var(--primary-soft); border-radius: 3px; box-shadow: 0 0 0 1px var(--primary-soft); }
.fill { border-bottom: 2px solid var(--border-strong); }
.hit-group { margin: 0 0 var(--s3); }
@media (min-width: 600px) { .hit-group { padding: var(--s4) var(--s5); } }
.hg-head { display: flex; align-items: center; gap: var(--s3); color: var(--text); text-decoration: none; }
.hg-head img { width: 28px; height: 28px; border-radius: 7px; display: block; flex: none; }
.hg-t { display: block; font-size: 16px; font-weight: 650; line-height: 1.35; }
.hg-head:hover { color: var(--text); }
.hg-head:hover .hg-t { color: var(--primary); }
.hit-list { margin: var(--s3) 0 0; padding: 0; list-style: none; }
.hit-list li { border-top: 1px solid var(--border); }
.hit-list a { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s4); padding: 10px 0; color: var(--text); text-decoration: none; font-size: 15px; line-height: 1.55; }
.hit-list li:last-child a { padding-bottom: 0; }
.hl-set { flex: none; font-size: 13px; font-weight: 600; color: var(--primary); white-space: nowrap; }
.hl-set::after { content: " ›"; }
.hit-list a:hover .hl-set { color: var(--primary-hover); text-decoration: underline; }
.hg-more { margin-top: var(--s3); font-size: 14px; }
.groups-more { margin-top: var(--s2); }

/* ================= Join the class (class.html) ================= */
.class-card h2 { margin: 0 0 var(--s2); }
.class-card > p:first-child, .class-card h2 + p { margin-top: 0; }
.field-label { display: block; margin: var(--s4) 0 6px; font-size: 14px; font-weight: 600; }
input.text-in {
  width: 100%; max-width: 420px; height: 46px; padding: 0 14px;
  font: inherit; font-size: 16px; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-md);
}
input.text-in:hover { border-color: var(--primary); }
input.text-in:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.class-card .small-note { margin-top: var(--s4); }

/* ================= Writing: model answers and how writing is marked (generator/writing_models.py) ================= */
details.model, details.marking { margin: var(--s4) 0 var(--s5); padding: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); }
details.model > summary, details.marking > summary {
  display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 10px var(--s5);
  font-weight: 600; color: var(--primary); cursor: pointer; list-style: none; border-radius: var(--r-lg);
}
details.model > summary::-webkit-details-marker, details.marking > summary::-webkit-details-marker { display: none; }
details.model > summary::before, details.marking > summary::before {
  content: ""; flex: none; width: 7px; height: 7px; margin: 0 3px 0 1px;
  border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(-45deg);
  transition: transform .15s var(--ease);
}
details.model[open] > summary::before, details.marking[open] > summary::before { transform: rotate(45deg); }
details.model > summary:hover, details.marking > summary:hover { color: var(--primary-hover); background: var(--surface-2); }
details.model[open] > summary, details.marking[open] > summary { margin-bottom: var(--s3); border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.model-body, details.marking > :not(summary) { padding-left: var(--s5); padding-right: var(--s5); }
.model-body { padding-bottom: var(--s5); }
.model-note { margin: 0 0 var(--s3); font-size: 14px; color: var(--muted); }
.model-text { padding: var(--s4) var(--s5); background: var(--surface-2); border-radius: var(--r-md); font-size: 17px; }
.model-text p { margin: 0 0 .8em; }
.model-body h3 { margin: var(--s5) 0 var(--s2); font-size: 16px; }
.model-body .plain-list { margin-bottom: 0; }
details.marking > p { margin: 0 0 var(--s3); font-size: 15px; }
details.marking > p.small-note { margin: var(--s3) 0 var(--s5); font-size: 14px; }
.marking-list { margin: 0; }
.marking-list > div { padding: 10px 0; border-top: 1px solid var(--border); }
.marking-list > div:first-child { border-top: 0; padding-top: 0; }
.marking-list dt { font-weight: 650; }
.marking-list dd { margin: 2px 0 0; font-size: 15px; color: var(--muted); }
@media (max-width: 599px) {
  details.model > summary, details.marking > summary { padding: 10px var(--s4); }
  .model-body, details.marking > :not(summary) { padding-left: var(--s4); padding-right: var(--s4); }
  .model-text { padding: var(--s3) var(--s4); font-size: 16px; }
}
@media print { details.model, details.marking { display: none; } }

/* ================= Print ================= */
@media print {
  :root[data-skin] body::before, .page-tabs, .bar, header.site nav, .level-switch, .jump, .setnav, .set-pager, .backlink, .confetti, .toast, .report-line { display: none !important; }
  header.site { position: static; }
  body { background: #fff; }
  .card { border-color: #ccc; }
  .pane-side { position: static; max-height: none; overflow: visible; }
}
