/* Design system: the CE 341 Water Resources site. Water blue for structure and primary calls, lagoon teal as
 * the second accent, earth green for success, sand for highlights. IBM Plex Sans Arabic throughout; white
 * 16px cards with soft shadows on a mist background; a dark water-to-lagoon gradient for the sidebar and banners.
 * Dark theme: the same palette on deep water surfaces. */
:root {
  --water-50: #eff8ff; --water-100: #dbf0fd; --water-300: #7ccaf6; --water-400: #38aeee; --water-500: #0f92d8;
  --water-600: #0274b6; --water-700: #045d93; --water-800: #084f79; --water-900: #0d4265; --water-950: #082a43;
  --lagoon-50: #effefa; --lagoon-300: #57e8cc; --lagoon-400: #26d0b4; --lagoon-600: #07917e; --lagoon-700: #0a7467; --lagoon-950: #022e2b;
  --earth-50: #f4f9ec; --earth-100: #e5f2d5; --earth-600: #53812a;
  --sand-300: #dcc28b; --sand-400: #cfa865; --sand-500: #c3914a; --sand-600: #ab763d;
  --rose-50: #fff1f2; --rose-100: #ffe4e6; --rose-600: #e11d48;

  --bg: #f2f8f8;
  --surface: #ffffff;
  --surface-2: #eaf3f6;
  --card: var(--surface); /* used by the easy-solution cards; follows every theme */
  --ink: #0b2a3c;
  --muted: #4a6373;
  --line: #dbe6ec;
  --card-line: rgb(255 255 255 / 0.7);
  --brand: var(--water-600);
  --brand-strong: var(--water-700);
  --brand-ink: #ffffff;
  --brand-soft: var(--water-50);
  --brand-ring: var(--water-100);
  --teal: var(--lagoon-600);
  --teal-strong: var(--lagoon-700);
  --signal: var(--sand-500);
  --signal-ink: #2a1d05;
  --ok: var(--earth-600);
  --ok-soft: var(--earth-50);
  --ok-ring: var(--earth-100);
  --bad: var(--rose-600);
  --bad-soft: var(--rose-50);
  --bad-ring: var(--rose-100);
  --focus: var(--water-500);
  --scrim: rgb(8 42 67 / 0.45);

  --shadow-soft: 0 1px 2px rgb(11 42 60 / 0.04), 0 8px 24px -12px rgb(11 42 60 / 0.18);
  --shadow-lift: 0 2px 4px rgb(11 42 60 / 0.05), 0 18px 40px -18px rgb(4 93 147 / 0.35);
  --body-glow: radial-gradient(1200px 500px at 100% -10%, rgb(15 146 216 / 0.07), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgb(13 180 155 / 0.08), transparent 60%);
  --grad-hero: linear-gradient(135deg, var(--water-800), var(--water-600) 55%, var(--lagoon-600));
  --grad-side: linear-gradient(180deg, var(--water-900), var(--water-950) 55%, var(--lagoon-950));
  --grad-mark: linear-gradient(135deg, var(--lagoon-400), var(--water-600));
  --grad-liquid: linear-gradient(90deg, var(--lagoon-400), var(--water-500));
  --grad-soft: linear-gradient(135deg, var(--water-50), var(--lagoon-50));
  --grad-head: linear-gradient(135deg, var(--water-50), #ffffff 55%, var(--lagoon-50));
  --topbar-bg: rgb(255 255 255 / 0.75);
  --topbar-line: rgb(219 240 253 / 0.6);

  --font-display: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, system-ui, sans-serif;
  --font-body: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, system-ui, sans-serif;
  --font-arabic: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, system-ui, sans-serif;
  --radius: 16px;
  --radius-sm: 12px;
  --side-w: 288px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #061b2b;
    --surface: #0b2638;
    --surface-2: #113248;
    --ink: #e4f1f8;
    --muted: #9ab4c4;
    --line: #1c4260;
    --card-line: #163a55;
    --brand: var(--water-400);
    --brand-strong: var(--water-300);
    --brand-ink: #032036;
    --brand-soft: #0d3350;
    --brand-ring: #174b72;
    --teal: var(--lagoon-400);
    --teal-strong: var(--lagoon-300);
    --signal: var(--sand-300);
    --ok: #9ccc6e;
    --ok-soft: #16301f;
    --ok-ring: #284d2e;
    --bad: #fb7185;
    --bad-soft: #3b1420;
    --bad-ring: #5b1f2e;
    --focus: var(--water-400);
    --shadow-soft: 0 1px 2px rgb(0 0 0 / 0.3), 0 8px 24px -12px rgb(0 0 0 / 0.6);
    --shadow-lift: 0 2px 4px rgb(0 0 0 / 0.3), 0 18px 40px -18px rgb(0 0 0 / 0.75);
    --body-glow: radial-gradient(1200px 500px at 100% -10%, rgb(56 174 238 / 0.1), transparent 60%),
      radial-gradient(900px 500px at -10% 110%, rgb(38 208 180 / 0.08), transparent 60%);
    --grad-soft: linear-gradient(135deg, #0d3350, #07302e);
    --grad-head: linear-gradient(135deg, #0d3350, var(--surface) 55%, #07302e);
    --topbar-bg: rgb(11 38 56 / 0.8);
    --topbar-line: rgb(255 255 255 / 0.08);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #061b2b;
  --surface: #0b2638;
  --surface-2: #113248;
  --ink: #e4f1f8;
  --muted: #9ab4c4;
  --line: #1c4260;
  --card-line: #163a55;
  --brand: var(--water-400);
  --brand-strong: var(--water-300);
  --brand-ink: #032036;
  --brand-soft: #0d3350;
  --brand-ring: #174b72;
  --teal: var(--lagoon-400);
  --teal-strong: var(--lagoon-300);
  --signal: var(--sand-300);
  --ok: #9ccc6e;
  --ok-soft: #16301f;
  --ok-ring: #284d2e;
  --bad: #fb7185;
  --bad-soft: #3b1420;
  --bad-ring: #5b1f2e;
  --focus: var(--water-400);
  --shadow-soft: 0 1px 2px rgb(0 0 0 / 0.3), 0 8px 24px -12px rgb(0 0 0 / 0.6);
  --shadow-lift: 0 2px 4px rgb(0 0 0 / 0.3), 0 18px 40px -18px rgb(0 0 0 / 0.75);
  --body-glow: radial-gradient(1200px 500px at 100% -10%, rgb(56 174 238 / 0.1), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgb(38 208 180 / 0.08), transparent 60%);
  --grad-soft: linear-gradient(135deg, #0d3350, #07302e);
  --grad-head: linear-gradient(135deg, #0d3350, var(--surface) 55%, #07302e);
  --topbar-bg: rgb(11 38 56 / 0.8);
  --topbar-line: rgb(255 255 255 / 0.08);
  color-scheme: dark;
}

/* ---------- more themes, chosen in Settings (js/views-settings.js). Each one remaps the palette scales and the
 * role tokens, so every component follows it. Ramadan is a dark theme. ---------- */
/* Taibah: green and gold */
:root[data-theme="taibah"] {
  --water-50:#eef7f1; --water-100:#d5ecdd; --water-300:#7cc49a; --water-400:#3fa56b; --water-500:#1f8a4f; --water-600:#137042; --water-700:#0f5a36; --water-800:#0c4a2d; --water-900:#0a3d26; --water-950:#052617;
  --lagoon-50:#fbf7ea; --lagoon-300:#e8cf8a; --lagoon-400:#d4b25a; --lagoon-600:#a8862e; --lagoon-700:#8a6b1f; --lagoon-950:#3a2c08;
  --bg:#f5f8f3; --surface:#ffffff; --surface-2:#e8f1ea;
  --ink:#10291b; --muted:#4d6455; --line:#d8e6dc;
  --card-line:rgb(255 255 255/.7); --brand:#137042; --brand-strong:#0f5a36;
  --brand-ink:#fff; --brand-soft:#eef7f1; --brand-ring:#d5ecdd;
  --teal:#a8862e; --teal-strong:#8a6b1f; --focus:#1f8a4f;
  --grad-soft:linear-gradient(135deg,#eef7f1,#fbf7ea); --grad-head:linear-gradient(135deg,#eef7f1,#ffffff 55%,#fbf7ea); --topbar-bg:#ffffffcc;
  color-scheme:light; --body-glow:radial-gradient(1200px 500px at 100% -10%,#1f8a4f12,transparent 60%),radial-gradient(900px 500px at -10% 110%,#d4b25a14,transparent 60%);
}
/* Desert: warm sand with a turquoise accent */
:root[data-theme="desert"] {
  --water-50:#fbf4ea; --water-100:#f3e3c9; --water-300:#e0b77a; --water-400:#cf9550; --water-500:#b97834; --water-600:#9c5f24; --water-700:#7f4a1c; --water-800:#673c18; --water-900:#523015; --water-950:#2e1a0b;
  --lagoon-50:#eef8f5; --lagoon-300:#7cc7b4; --lagoon-400:#3fa48d; --lagoon-600:#2b7d6c; --lagoon-700:#226357; --lagoon-950:#0e2b26;
  --bg:#f7f1e3; --surface:#fffaf0; --surface-2:#efe4cc;
  --ink:#3b2a14; --muted:#7a6446; --line:#e6d6b6;
  --card-line:rgb(255 255 255/.7); --brand:#9c5f24; --brand-strong:#7f4a1c;
  --brand-ink:#fff; --brand-soft:#fbf4ea; --brand-ring:#f3e3c9;
  --teal:#2b7d6c; --teal-strong:#226357; --focus:#b97834;
  --grad-soft:linear-gradient(135deg,#fbf4ea,#eef8f5); --grad-head:linear-gradient(135deg,#fbf4ea,#fffaf0 55%,#eef8f5); --topbar-bg:#fffaf0cc;
  color-scheme:light; --body-glow:radial-gradient(1200px 500px at 100% -10%,#b9783412,transparent 60%),radial-gradient(900px 500px at -10% 110%,#3fa48d14,transparent 60%);
}
/* Ramadan: night navy with gold (a dark theme) */
:root[data-theme="ramadan"] {
  --water-50:#f8f1dc; --water-100:#efdfae; --water-300:#e6c977; --water-400:#dcb453; --water-500:#cfa23a; --water-600:#b8892b; --water-700:#966d22; --water-800:#79581d; --water-900:#5f451a; --water-950:#3a2a0f;
  --lagoon-50:#eef2ff; --lagoon-300:#a9b8f0; --lagoon-400:#7f93e6; --lagoon-600:#5367c9; --lagoon-700:#3e4fa6; --lagoon-950:#141c45;
  --bg:#0b1230; --surface:#121b42; --surface-2:#1a2552;
  --ink:#f3ecd8; --muted:#b9b29a; --line:#2a3768;
  --card-line:#2a3768; --brand:#dcb453; --brand-strong:#e6c977;
  --brand-ink:#3a2a0f; --brand-soft:#1a2552; --brand-ring:#2a3768;
  --teal:#7f93e6; --teal-strong:#a9b8f0; --focus:#dcb453;
  --ok:#9ccc6e; --ok-soft:#16301f; --ok-ring:#284d2e;
  --bad:#fb7185; --bad-soft:#3b1420; --bad-ring:#5b1f2e;
  --shadow-soft:0 1px 2px rgb(0 0 0/.3),0 8px 24px -12px rgb(0 0 0/.6); --shadow-lift:0 2px 4px rgb(0 0 0/.3),0 18px 40px -18px rgb(0 0 0/.75); --grad-soft:linear-gradient(135deg,#1a2552,#121b42);
  --grad-head:linear-gradient(135deg,#1a2552,#121b42 55%,#1a2552); --topbar-bg:#121b42cc; --topbar-line:rgb(255 255 255/.08);
  color-scheme:dark; --body-glow:none; --grad-side:linear-gradient(180deg,#141c45,#0b1230 60%,#3a2a0f);
  --grad-hero:linear-gradient(135deg,#141c45,#26336e 55%,#966d22);
}
/* Sepia: warm paper tones for long reading */
:root[data-theme="sepia"] {
  --water-50:#f8efe0; --water-100:#eedcbc; --water-300:#d9b583; --water-400:#c4945a; --water-500:#a8763e; --water-600:#8b5e2f; --water-700:#714b26; --water-800:#5c3d20; --water-900:#4a311b; --water-950:#2b1c0f;
  --lagoon-50:#f1f4ec; --lagoon-300:#a9bb92; --lagoon-400:#7f9866; --lagoon-600:#5d7647; --lagoon-700:#475b36; --lagoon-950:#1c2415;
  --bg:#f4ecd8; --surface:#fbf6ea; --surface-2:#ede2c8;
  --ink:#3a2c1c; --muted:#6f5d47; --line:#e0d2b4;
  --card-line:rgb(255 255 255/.7); --brand:#8b5e2f; --brand-strong:#714b26;
  --brand-ink:#fff; --brand-soft:#f8efe0; --brand-ring:#eedcbc;
  --teal:#5d7647; --teal-strong:#475b36; --focus:#a8763e;
  --grad-soft:linear-gradient(135deg,#f8efe0,#f1f4ec); --grad-head:linear-gradient(135deg,#f8efe0,#fbf6ea 55%,#f1f4ec); --topbar-bg:#fbf6eacc;
  color-scheme:light; --body-glow:radial-gradient(1200px 500px at 100% -10%,#a8763e12,transparent 60%),radial-gradient(900px 500px at -10% 110%,#7f986614,transparent 60%); --grad-side:linear-gradient(180deg,#5c3d20,#3a2715);
  --grad-hero:linear-gradient(135deg,#714b26,#a8763e 60%,#5d7647);
}

/* ---------- Glass, chosen in Settings in three styles: Clear (glass-clear), Smoky (glass-dark) and Purple (glass-purple).
 * Surfaces are translucent and blur the colourful fixed background behind them (--body-glow). ---------- */
:root[data-theme^="glass"] { --glass-blur: blur(18px) saturate(160%); }
:root[data-theme="glass-clear"] {
  --water-50:#eef6ff; --water-100:#d9ecff; --water-300:#8cc8ff; --water-400:#4aa8f5; --water-500:#1f8de6; --water-600:#0b72c9; --water-700:#095ba3; --water-800:#0a4a84; --water-900:#0c3c6a; --water-950:#082642;
  --bg:#dfeefc; --surface:rgb(255 255 255 / 0.55); --surface-2:rgb(255 255 255 / 0.4); --ink:#0b2236; --muted:#3f5a70; --line:rgb(255 255 255 / 0.75);
  --card-line:rgb(255 255 255 / 0.8); --brand:#0b72c9; --brand-strong:#095ba3; --brand-ink:#fff; --brand-soft:rgb(255 255 255 / 0.5); --brand-ring:rgb(11 114 201 / 0.25);
  --teal:#0e8f86; --teal-strong:#0a6e68;
  --body-glow: radial-gradient(700px 520px at 85% 10%, #8fd3ff 0%, transparent 60%), radial-gradient(650px 520px at 10% 90%, #ffc4e1 0%, transparent 60%), radial-gradient(600px 480px at 50% 50%, #b9f3e4 0%, transparent 65%);
  --grad-head: linear-gradient(135deg, rgb(255 255 255 / 0.6), rgb(255 255 255 / 0.35));
  --grad-hero: linear-gradient(135deg, rgb(11 114 201 / 0.85), rgb(14 143 134 / 0.75));
  --grad-side: linear-gradient(180deg, rgb(12 60 106 / 0.72), rgb(8 38 66 / 0.78));
  --topbar-bg: rgb(255 255 255 / 0.5); --shadow-soft: 0 8px 32px -12px rgb(15 50 90 / 0.25); --shadow-lift: 0 12px 40px -14px rgb(15 50 90 / 0.35);
  color-scheme: light;
}
:root[data-theme="glass-dark"] {
  --water-50:#e6f7ff; --water-100:#c6ecff; --water-300:#8bd8ff; --water-400:#4cc2ff; --water-500:#22a8ec; --water-600:#1288cc; --water-700:#0f6ca3; --water-800:#0d567f; --water-900:#0b4364; --water-950:#06263a;
  --bg:#05080d; --surface:rgb(22 28 38 / 0.5); --surface-2:rgb(255 255 255 / 0.06); --ink:#e9f1f8; --muted:#9db0c0; --line:rgb(255 255 255 / 0.12);
  --card-line:rgb(255 255 255 / 0.14); --brand:#4cc2ff; --brand-strong:#8bd8ff; --brand-ink:#04121c; --brand-soft:rgb(76 194 255 / 0.12); --brand-ring:rgb(76 194 255 / 0.3);
  --teal:#3ee0c1; --teal-strong:#7cf0d8; --ok:#9ccc6e; --ok-soft:rgb(156 204 110 / 0.12); --ok-ring:rgb(156 204 110 / 0.3); --bad:#fb7185; --bad-soft:rgb(251 113 133 / 0.12); --bad-ring:rgb(251 113 133 / 0.3);
  --body-glow: radial-gradient(700px 520px at 85% 8%, rgb(34 168 236 / 0.35) 0%, transparent 60%), radial-gradient(650px 520px at 8% 92%, rgb(62 224 193 / 0.22) 0%, transparent 60%), radial-gradient(500px 420px at 55% 55%, rgb(120 90 255 / 0.14) 0%, transparent 65%);
  --grad-head: linear-gradient(135deg, rgb(255 255 255 / 0.08), rgb(255 255 255 / 0.03));
  --grad-hero: linear-gradient(135deg, rgb(18 136 204 / 0.55), rgb(62 224 193 / 0.3));
  --grad-soft: linear-gradient(135deg, rgb(255 255 255 / 0.06), rgb(255 255 255 / 0.02));
  --grad-side: linear-gradient(180deg, rgb(12 16 24 / 0.6), rgb(5 8 13 / 0.7));
  --topbar-bg: rgb(12 16 24 / 0.55); --topbar-line: rgb(255 255 255 / 0.08);
  --shadow-soft: 0 8px 32px -12px rgb(0 0 0 / 0.6); --shadow-lift: 0 14px 44px -14px rgb(0 0 0 / 0.75);
  color-scheme: dark;
}
:root[data-theme="glass-purple"] {
  --water-50:#f5efff; --water-100:#e9dcff; --water-300:#cfb1ff; --water-400:#b58cff; --water-500:#9a66f5; --water-600:#7f47e0; --water-700:#6833bd; --water-800:#532a96; --water-900:#3f2273; --water-950:#24123f;
  --lagoon-300:#ffb3e0; --lagoon-400:#ff8fd0; --lagoon-600:#e05aae; --lagoon-700:#b8418c; --lagoon-950:#3d0f2e;
  --bg:#1b0b33; --surface:rgb(255 255 255 / 0.1); --surface-2:rgb(255 255 255 / 0.07); --ink:#f6efff; --muted:#cbb8e6; --line:rgb(255 255 255 / 0.16);
  --card-line:rgb(255 255 255 / 0.2); --brand:#c9a8ff; --brand-strong:#e3d1ff; --brand-ink:#22103f; --brand-soft:rgb(201 168 255 / 0.15); --brand-ring:rgb(201 168 255 / 0.35);
  --teal:#ff8fd0; --teal-strong:#ffb3e0; --ok:#a7e28a; --ok-soft:rgb(167 226 138 / 0.12); --ok-ring:rgb(167 226 138 / 0.3); --bad:#ff8aa0; --bad-soft:rgb(255 138 160 / 0.12); --bad-ring:rgb(255 138 160 / 0.3);
  --body-glow: radial-gradient(720px 540px at 85% 8%, rgb(154 102 245 / 0.65) 0%, transparent 60%), radial-gradient(650px 520px at 8% 92%, rgb(255 111 199 / 0.45) 0%, transparent 60%), radial-gradient(520px 420px at 50% 50%, rgb(90 70 255 / 0.35) 0%, transparent 65%);
  --grad-head: linear-gradient(135deg, rgb(255 255 255 / 0.14), rgb(255 255 255 / 0.05));
  --grad-hero: linear-gradient(135deg, rgb(127 71 224 / 0.7), rgb(224 90 174 / 0.55));
  --grad-soft: linear-gradient(135deg, rgb(255 255 255 / 0.1), rgb(255 255 255 / 0.04));
  --grad-side: linear-gradient(180deg, rgb(40 16 76 / 0.55), rgb(27 11 51 / 0.65));
  --topbar-bg: rgb(40 16 76 / 0.5); --topbar-line: rgb(255 255 255 / 0.1);
  --shadow-soft: 0 8px 32px -12px rgb(10 0 30 / 0.6); --shadow-lift: 0 14px 44px -14px rgb(10 0 30 / 0.75);
  color-scheme: dark;
}
/* the blur that makes a surface look like glass; where the browser has no blur the surfaces stay translucent */
:root[data-theme^="glass"] :is(.card, .panel, .page-head, .chapter-head, .welcome, .table-wrap, .term, .formula-card, .side, .kpi, .map-group, .role-card, .info-panel, .fig, .entry, .ways, .practice-card, .answer-key, .mistakes, .word-card, .next-card, .btn-quiet, .pick, .tabs, .sidebar, .topbar, .settings-dialog, .jumpbar, .stage-bar, .calc-panel, .lg-card, .set-row, .theme-opt, .cal-day, .cal-grid-wrap, .cal-up-card, .cal-up-empty, .dash-next, .vb-seg, .is-scroll .view-bar) {
  -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur);
}

/* ---------- text size, chosen in Settings (data-font on <html>); Medium is the browser default ---------- */
:root[data-font="small"] { font-size: 87.5%; }
:root[data-font="large"] { font-size: 112.5%; }

/* ---------- motion, chosen in Settings (data-no-anim, data-no-smooth, data-no-blur on <html>; app.js) ----------
 * Study Oasis (.fx and the fx-* parts, such as the timer pill on other pages) keeps its own animation. */
:root[data-no-anim] :not(.fx, .fx *, [class*="fx-"], [class*="fx-"] *),
:root[data-no-anim] :not(.fx, .fx *, [class*="fx-"], [class*="fx-"] *)::before,
:root[data-no-anim] :not(.fx, .fx *, [class*="fx-"], [class*="fx-"] *)::after,
:root[data-no-anim] ::backdrop {
  animation-duration: 0.01ms !important; animation-delay: 0s !important; animation-iteration-count: 1 !important;
}
:root[data-no-smooth] { scroll-behavior: auto !important; }
:root[data-no-smooth] :not(.fx, .fx *, [class*="fx-"], [class*="fx-"] *),
:root[data-no-smooth] :not(.fx, .fx *, [class*="fx-"], [class*="fx-"] *)::before,
:root[data-no-smooth] :not(.fx, .fx *, [class*="fx-"], [class*="fx-"] *)::after { transition: none !important; }
:root[data-no-blur] *, :root[data-no-blur] *::before, :root[data-no-blur] *::after, :root[data-no-blur] ::backdrop {
  -webkit-backdrop-filter: none !important; backdrop-filter: none !important;
}
/* Without the blur, see-through Glass panels would show the page behind them, so they turn solid:
 * each surface below is the style's own surface already laid over its background, and panels drawn with a see-through gradient get the background under it. */
:root[data-no-blur][data-theme="glass-clear"] { --surface: #f1f7fe; --surface-2: #ecf5fd; --topbar-bg: #eff7fe; }
:root[data-no-blur][data-theme="glass-dark"] { --surface: #0e121a; --surface-2: #14171c; --topbar-bg: #090c13; }
:root[data-no-blur][data-theme="glass-purple"] { --surface: #322347; --surface-2: #2b1c41; --topbar-bg: #220e40; }
:root[data-no-blur][data-theme^="glass"] :is(.sidebar, .page-head, .chapter-head, .welcome, .next-card, .set-head) { background-color: var(--bg); }

* { box-sizing: border-box; }

body {
  margin: 0;
  background-color: var(--bg);
  background-image: var(--body-glow);
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Paints the phone's top inset in the surface colour so scrolled content never shows above the bar. */
body::before {
  content: "";
  position: fixed;
  inset: 0 0 auto;
  height: env(safe-area-inset-top, 0px);
  background: var(--surface);
  z-index: 60;
}

a { color: var(--brand); }
::selection { background: rgb(15 146 216 / 0.2); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3, h4 { font-family: var(--font-display); line-height: 1.2; margin: 0; text-wrap: balance; }
h1 { font-size: clamp(1.75rem, 3.2vw, 2.25rem); font-weight: 700; }
h2 { font-size: 1.3rem; font-weight: 700; }
h3 { font-size: 1.05rem; font-weight: 600; }
p { margin: 0.5em 0; }
.muted { color: var(--muted); }
.small { font-size: 0.86rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.icon { width: 20px; height: 20px; flex: none; }

/* ---------- shell: the sidebar menu (beside the page from 1200px, a drawer below) and, on narrower screens,
   a slim frosted top bar with the menu button and the Theory sections ---------- */
.shell { min-height: 100vh; display: flex; flex-direction: column; }
.content { min-width: 0; display: flex; flex-direction: column; flex: 1; }
#app { flex: 1; outline: none; }
.topbar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 50;
  background: var(--topbar-bg); border-bottom: 1px solid var(--topbar-line);
  -webkit-backdrop-filter: blur(16px) saturate(1.2); backdrop-filter: blur(16px) saturate(1.2);
}
.topbar-inner {
  display: flex; align-items: center; gap: 12px; min-height: 62px;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.menu-btn {
  flex: none; width: 42px; height: 42px; display: grid; place-items: center; border: 0; border-radius: var(--radius-sm); cursor: pointer;
  background: var(--surface); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); transition: background-color 0.15s;
}
.menu-btn:hover { background: var(--brand-soft); box-shadow: inset 0 0 0 1px var(--brand-ring); }
.menu-btn svg { width: 22px; height: 22px; }
.topbar-title { margin-left: auto; padding: 4px 12px; border-radius: 999px; background: var(--brand-soft); color: var(--brand-strong); font-size: 0.78rem; font-weight: 600; box-shadow: inset 0 0 0 1px var(--brand-ring); white-space: nowrap; }
.topbar-title:empty { display: none; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--ink); flex: none; min-width: 0; }
.brand-mark { width: 38px; height: 38px; flex: none; border-radius: var(--radius-sm); background: var(--grad-mark); color: #fff; display: grid; place-items: center; box-shadow: var(--shadow-soft); }
.brand-mark svg { width: 20px; height: 20px; }
.brand-text strong { display: block; font-family: var(--font-display); font-size: 1.05rem; font-weight: 700; line-height: 1.15; }
.brand-text small { color: var(--muted); font-size: 0.75rem; }

/* The menu: the CE 341 dark water-to-lagoon sidebar with contour rings */
.sidebar {
  position: fixed; top: 0; bottom: 0; left: 0; z-index: 70; width: var(--side-w); max-width: 86vw;
  display: flex; flex-direction: column; overflow: hidden; isolation: isolate;
  padding-top: env(safe-area-inset-top, 0px); color: #fff; background: var(--grad-side);
  transform: translateX(-100%); visibility: hidden; transition: transform 0.3s ease, visibility 0.3s;
}
.menu-open .sidebar { transform: none; visibility: visible; box-shadow: 0 0 60px rgb(2 20 34 / 0.45); }
.sidebar::before {
  content: ""; position: absolute; z-index: -1; left: -110px; bottom: -110px; width: 400px; height: 400px; border-radius: 50%; pointer-events: none;
  background: repeating-radial-gradient(circle, transparent 0 20px, rgb(255 255 255 / 0.07) 20px 22px);
}
.side-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 22px 14px 16px 20px; }
.side-head .brand { color: #fff; }
.side-head .brand-mark { width: 42px; height: 42px; box-shadow: 0 6px 16px -4px rgb(0 0 0 / 0.4); }
.side-head .brand-text strong { font-size: 1.1rem; }
.side-head .brand-text small { color: rgb(182 225 251 / 0.8); }
.menu-close { flex: none; width: 38px; height: 38px; display: grid; place-items: center; border: 0; border-radius: 10px; background: transparent; color: rgb(255 255 255 / 0.75); cursor: pointer; }
.menu-close:hover { background: rgb(255 255 255 / 0.1); color: #fff; }
.menu-close svg { width: 22px; height: 22px; }
.side-nav { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 4px 12px 14px; scrollbar-width: thin; scrollbar-color: rgb(255 255 255 / 0.2) transparent; }
.side-label { margin: 4px 0 8px; padding: 0 12px; color: rgb(182 225 251 / 0.6); font-size: 0.7rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; }
.side-list, .side-sub { list-style: none; margin: 0; padding: 0; }
.side-list { display: grid; gap: 4px; }
.side-row { display: flex; align-items: center; gap: 4px; }
.side-link {
  position: relative; flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--radius-sm);
  color: rgb(219 240 253 / 0.82); text-decoration: none; font-size: 0.92rem; font-weight: 500; transition: background-color 0.15s, color 0.15s;
}
.side-link .icon { color: rgb(182 225 251 / 0.7); }
.side-link:hover { background: rgb(255 255 255 / 0.06); color: #fff; }
.side-link.active { background: rgb(255 255 255 / 0.12); color: #fff; font-weight: 600; box-shadow: inset 0 1px 2px rgb(0 0 0 / 0.2); }
.side-link.active .icon { color: var(--lagoon-300); }
.side-link.active::before { content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 4px; border-radius: 999px; background: var(--lagoon-300); }
.side-toggle { flex: none; width: 36px; height: 36px; display: grid; place-items: center; border: 0; border-radius: 10px; background: transparent; color: rgb(182 225 251 / 0.7); cursor: pointer; }
.side-toggle:hover { background: rgb(255 255 255 / 0.08); color: #fff; }
.side-toggle .icon { width: 16px; height: 16px; transition: transform 0.2s ease; }
.side-toggle[aria-expanded="true"] .icon { transform: rotate(90deg); }
.side-sub { display: grid; gap: 2px; margin: 4px 0 8px 22px; padding-left: 12px; border-left: 1px solid rgb(255 255 255 / 0.12); }
.side-sublink { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 10px; color: rgb(182 225 251 / 0.8); text-decoration: none; font-size: 0.85rem; line-height: 1.3; transition: background-color 0.15s, color 0.15s; }
.side-sublink .icon { width: 16px; height: 16px; color: rgb(182 225 251 / 0.55); }
.side-sublink:hover { background: rgb(255 255 255 / 0.06); color: #fff; }
.side-sublink.active { background: rgb(255 255 255 / 0.1); color: var(--lagoon-300); font-weight: 600; }
.side-sublink.active .icon { color: var(--lagoon-300); }
.side-num { flex: none; min-width: 2.2em; padding: 1px 6px; border-radius: 6px; background: rgb(255 255 255 / 0.08); color: var(--lagoon-300); font-size: 0.7rem; font-weight: 700; text-align: center; }
.side-foot { display: grid; gap: 12px; padding: 14px 16px calc(16px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid rgb(255 255 255 / 0.08); }
.side-progress { display: grid; gap: 10px; padding: 12px 14px; border-radius: var(--radius); background: rgb(255 255 255 / 0.06); box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.08); }
.side-prog { display: grid; grid-template-columns: 1fr auto; gap: 4px 8px; color: rgb(219 240 253 / 0.85); font-size: 0.78rem; }
.side-prog strong { color: #fff; font-variant-numeric: tabular-nums; }
.side-prog .meter { grid-column: 1 / -1; height: 6px; background: rgb(255 255 255 / 0.12); }
.theme-btn {
  justify-self: start; display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 14px 0 10px; border: 0; border-radius: var(--radius-sm);
  background: rgb(255 255 255 / 0.08); color: #fff; box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.15);
  font: inherit; font-size: 0.82rem; font-weight: 600; cursor: pointer; transition: background-color 0.15s;
}
.theme-btn:hover { background: rgb(255 255 255 / 0.16); }
.scrim { position: fixed; inset: 0; z-index: 65; background: var(--scrim); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); }
@media (min-width: 1200px) {
  .sidebar { transform: none; visibility: visible; transition: none; max-width: none; }
  .topbar { display: none; }
  .content { margin-left: var(--side-w); }
  body.side-hidden .sidebar { transform: translateX(-100%); visibility: hidden; }
  body.side-hidden .content { margin-left: 0; }
  body.side-hidden .topbar { display: block; }
}
@media (prefers-reduced-motion: reduce) { .sidebar, .side-toggle .icon { transition: none; } }

/* ---------- page sections: numbered heads, an "On this page" bar, split layouts ---------- */
.jumpbar {
  display: flex; align-items: center; gap: 4px; margin: 4px 0 30px; padding: 6px; overflow-x: auto; scrollbar-width: none;
  background: var(--surface); border: 1px solid var(--card-line); border-radius: var(--radius); box-shadow: var(--shadow-soft);
}
.jumpbar::-webkit-scrollbar { display: none; }
.jumpbar-label { flex: none; padding: 0 10px; color: var(--muted); font-size: 0.7rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; }
.jump { flex: none; padding: 8px 14px; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--ink); font: inherit; font-size: 0.86rem; font-weight: 600; white-space: nowrap; cursor: pointer; transition: background-color 0.15s, color 0.15s; }
.jump:hover { background: var(--brand-soft); color: var(--brand-strong); }
.sec { scroll-margin-top: 120px; }
.page > .sec + .sec { margin-top: 52px; }
.sec-head { display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 14px; align-items: center; margin-bottom: 18px; }
.sec-num { grid-row: span 2; align-self: start; width: 44px; height: 44px; display: grid; place-items: center; border-radius: 14px; background: var(--grad-mark); color: #fff; font-size: 0.95rem; font-weight: 700; font-variant-numeric: tabular-nums; box-shadow: var(--shadow-soft); }
.sec-head h2 { font-size: 1.4rem; }
.sec-head p { margin: 4px 0 0; color: var(--muted); max-width: 72ch; }
.sec-head h2:focus { outline: none; }
.panel > .sec-head { margin-bottom: 14px; }
.sec-split { display: grid; grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr); gap: 22px; align-items: start; }
.sec-pair { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.page > .sec-pair + .sec, .page > .sec + .sec-pair { margin-top: 52px; }

/* Tiles with an icon: the hub guide and the Theory sections */
.hub-tiles { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.hub-tile { gap: 10px; }
.tile-icon { width: 44px; height: 44px; display: grid; place-items: center; border-radius: var(--radius-sm); background: var(--brand-soft); color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand-ring); transition: background-color 0.2s, color 0.2s; }
.tile-icon .icon { width: 22px; height: 22px; }
a.hub-tile:hover .tile-icon { background: var(--grad-mark); color: #fff; box-shadow: none; }

/* Roles: the jobs as a list beside the selected job */
.roles-split .roles { flex-direction: column; align-items: stretch; margin: 0; }
.roles-split .role-chip { justify-content: flex-start; padding: 0.75rem 1rem; border-radius: var(--radius-sm); font-size: 0.92rem; font-weight: 600; text-align: left; background: var(--surface); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }
.roles-split .role-chip:hover { background: var(--brand-soft); }
.roles-split .role-chip.on { background: var(--brand); color: var(--brand-ink); box-shadow: var(--shadow-soft); }
.roles-split .role-card { max-width: none; }

/* Progress as a band of two figures and the reset control */
.stat-band { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)) auto; gap: 18px 28px; align-items: end; }
.stat { display: grid; gap: 6px; min-width: 0; }
.stat-label { color: var(--muted); font-size: 0.85rem; }
.stat-num { font-family: var(--font-display); font-size: 1.6rem; font-weight: 700; line-height: 1.1; color: var(--brand-strong); }
.stat-foot { display: grid; justify-items: end; gap: 6px; }
.stat-foot p { margin: 0; }

/* The original practical files as a grid of documents */
.file-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.file-link {
  display: flex; align-items: flex-start; gap: 12px; height: 100%; padding: 14px 16px; border-radius: var(--radius-sm);
  background: var(--surface); border: 1px solid var(--card-line); box-shadow: var(--shadow-soft); color: var(--ink); text-decoration: none; line-height: 1.4;
  transition: box-shadow 0.2s, transform 0.2s;
}
.file-link .icon { color: var(--brand); margin-top: 1px; }
.file-link:hover { box-shadow: var(--shadow-lift); transform: translateY(-2px); }
.file-exp { color: var(--brand-strong); }

/* Dashboard: the next step beside the week; icons on the four totals */
.dash-top { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 16px; align-items: stretch; margin-top: 16px; }
.dash-top .panel { margin: 0; }
.dash-two > .panel { margin: 0; }
.dash-chapters { margin-top: 36px; }
.kpi-icon { width: 38px; height: 38px; margin-bottom: 6px; display: grid; place-items: center; border-radius: var(--radius-sm); background: var(--brand-soft); color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand-ring); }

@media (max-width: 959px) {
  .sec-split, .sec-pair, .dash-top { grid-template-columns: minmax(0, 1fr); }
  .stat-band { grid-template-columns: minmax(0, 1fr); }
  .stat-foot { justify-items: start; }
}
@media (min-width: 1200px) { .sec { scroll-margin-top: 24px; } }

.page {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding-block: 32px 64px;
  padding-left: max(36px, env(safe-area-inset-left, 0px));
  padding-right: max(36px, env(safe-area-inset-right, 0px));
}
.section-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 16px; margin: 6px 0 12px; }
.section-head p { margin: 0; }
section + section { margin-top: 36px; }

.site-footer { color: var(--muted); font-size: 0.78rem; opacity: 0.85; }
.footer-inner {
  padding-block: 18px;
  padding-left: max(36px, env(safe-area-inset-left, 0px));
  padding-right: max(36px, env(safe-area-inset-right, 0px));
  max-width: 1120px; margin: 0 auto;
}

/* ---------- buttons, chips, pills ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 0.625rem 1rem; border-radius: var(--radius-sm);
  border: 1px solid transparent; font: inherit; font-size: 0.875rem; font-weight: 600; line-height: 1.25;
  text-decoration: none; cursor: pointer; transition: background-color 0.15s, box-shadow 0.15s, transform 0.12s;
}
.btn-primary { background: var(--brand); color: var(--brand-ink); box-shadow: 0 1px 2px rgb(11 42 60 / 0.08); }
.btn-primary:hover { background: var(--brand-strong); }
.btn-signal { background: var(--teal); color: #fff; box-shadow: 0 1px 2px rgb(11 42 60 / 0.08); }
.btn-signal:hover { background: var(--teal-strong); }
.btn-light { background: rgb(255 255 255 / 0.15); color: #fff; box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.3); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
.btn-light:hover { background: rgb(255 255 255 / 0.25); }
.btn-quiet { background: var(--surface); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }
.btn-quiet:hover { background: var(--brand-soft); box-shadow: inset 0 0 0 1px var(--brand-ring); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 0.25rem 0.65rem; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: 0.78rem; font-weight: 500; text-decoration: none; }
.chip.link { background: var(--brand-soft); color: var(--brand-strong); box-shadow: inset 0 0 0 1px var(--brand-ring); }
.chip.link:hover { background: var(--brand-ring); }
.chip.on { background: var(--brand); color: var(--brand-ink); box-shadow: none; }
.filters { margin: 4px 0 14px; }
.pill { display: inline-block; padding: 0.15rem 0.65rem; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: 0.75rem; font-weight: 600; box-shadow: inset 0 0 0 1px var(--line); }
.pill.ok { background: var(--ok-soft); color: var(--ok); box-shadow: inset 0 0 0 1px var(--ok-ring); }
.pill.bad { background: var(--bad-soft); color: var(--bad); box-shadow: inset 0 0 0 1px var(--bad-ring); }

.panel { background: var(--surface); border: 1px solid var(--card-line); border-radius: var(--radius); padding: 20px; min-width: 0; }
.link-small { font-size: 0.86rem; }

/* ---------- home ---------- */
.home-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 36px; align-items: start; }
.chapter-list { border-top: 1px solid var(--line); }
.chapter-row {
  display: grid; grid-template-columns: 56px minmax(0, 1fr) 150px; gap: 16px; align-items: center;
  padding: 18px 8px; border-bottom: 1px solid var(--line); color: var(--ink); text-decoration: none;
}
a.chapter-row:hover { background: var(--surface); }
.nav-label-soon { margin-top: 12px; }
.soon { margin-top: 30px; }
.soon-list { list-style: none; margin: 10px 0 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 28px; }
.soon-list li { display: flex; gap: 14px; align-items: baseline; padding: 9px 0; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 0.93rem; }
.soon-list b { width: 18px; flex: none; text-align: center; font-family: var(--font-display); color: var(--brand); }
.chapter-num { font-family: var(--font-display); font-weight: 700; font-size: 2.3rem; line-height: 1; color: var(--brand); text-align: center; }
.chapter-num.lg { font-size: 3.4rem; min-width: 56px; }
.chapter-main { display: grid; gap: 4px; min-width: 0; }
.chapter-main strong { font-size: 1.05rem; font-family: var(--font-display); }
.chapter-progress { display: grid; gap: 4px; }
.chapter-progress small { color: var(--muted); font-size: 0.8rem; }
.meter { display: block; height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.meter > span {
  display: block; height: 100%; border-radius: 999px;
  background-image: linear-gradient(135deg, rgb(255 255 255 / 0.22) 25%, transparent 25%, transparent 50%,
    rgb(255 255 255 / 0.22) 50%, rgb(255 255 255 / 0.22) 75%, transparent 75%, transparent), var(--grad-liquid);
  background-size: 24px 24px, 100% 100%;
  animation: shimmer 1.2s linear infinite;
}
@keyframes shimmer { to { background-position: 48px 0, 0 0; } }

.progress { position: sticky; top: 24px; display: grid; gap: 14px; }
.prog-row { display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; align-items: baseline; font-size: 0.92rem; }
.prog-row .meter { grid-column: 1 / -1; }
.prog-row strong { font-variant-numeric: tabular-nums; }
.continue { display: block; padding: 14px; border-radius: var(--radius-sm); background: var(--grad-soft); box-shadow: inset 0 0 0 1px var(--brand-ring); color: var(--ink); text-decoration: none; }
.continue .muted { display: block; font-size: 0.8rem; }
.continue strong { display: block; font-family: var(--font-display); line-height: 1.25; }
.continue:hover { filter: brightness(0.97); }

.method { margin-top: 44px; }
.method ol { list-style: none; margin: 14px 0 0; padding: 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.method li { display: flex; flex-direction: column; gap: 8px; padding-top: 14px; border-top: 2px solid var(--brand); font-size: 0.95rem; }
.method li span { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--grad-mark); color: #fff; font-weight: 700; font-family: var(--font-display); font-size: 0.9rem; box-shadow: var(--shadow-soft); }

/* ---------- chapter pages ---------- */
/* Page and chapter headers are banner cards, as on the CE 341 site */
.page-head, .chapter-head {
  position: relative; overflow: hidden; margin-bottom: 24px; padding: 24px 28px;
  background: var(--grad-head); border: 1px solid var(--card-line); border-radius: 24px; box-shadow: var(--shadow-soft);
}
.page-head:has(> .crumb:only-child) { padding: 0; background: none; border: 0; box-shadow: none; }
.page-head > .muted { max-width: 70ch; margin-bottom: 0; }
.crumb { margin: 0 0 10px; font-size: 0.84rem; color: var(--muted); }
.crumb a { font-weight: 600; text-decoration: none; }
.crumb a:hover { text-decoration: underline; }
.title-row { display: flex; align-items: center; gap: 20px; margin-bottom: 8px; }
.title-row p { margin: 4px 0 0; }
.tabs {
  display: flex; width: fit-content; max-width: 100%; gap: 4px; margin-top: 18px; padding: 4px;
  background: var(--bg); border-radius: var(--radius); box-shadow: inset 0 0 0 1px var(--line); overflow-x: auto; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs a { padding: 8px 14px; border-radius: var(--radius-sm); text-decoration: none; color: var(--muted); white-space: nowrap; font-size: 0.9rem; font-weight: 600; transition: background-color 0.15s, color 0.15s; }
.tabs a:hover { color: var(--ink); background: var(--surface); }
.tabs a.active { color: var(--brand-ink); background: var(--brand); box-shadow: var(--shadow-soft); }

.workbench { display: grid; grid-template-columns: 270px minmax(0, 1fr); gap: 32px; align-items: start; }
.picker { display: flex; flex-direction: column; gap: 4px; position: sticky; top: 120px; }
.pick { position: relative; display: grid; gap: 2px; padding: 10px 14px; border-radius: var(--radius-sm); color: var(--ink); text-decoration: none; font-size: 0.92rem; line-height: 1.3; transition: background-color 0.15s; }
.pick small { color: var(--muted); font-size: 0.76rem; }
.pick:hover { background: var(--surface); box-shadow: var(--shadow-soft); }
.pick.active { background: var(--brand-soft); color: var(--brand-strong); font-weight: 600; box-shadow: inset 3px 0 0 var(--brand), inset 0 0 0 1px var(--brand-ring); }
.work { min-width: 0; }
.work > h2 { margin-bottom: 2px; }

/* ---------- forms ---------- */
.form-panel { margin: 14px 0; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px 16px; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field label { font-size: 0.88rem; color: var(--muted); line-height: 1.35; }
.field label .sym { color: var(--ink); }
.field input, .search input {
  font: inherit; width: 100%; min-height: 44px; padding: 0.55rem 0.85rem;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field input:focus, .search input:focus, .field select:focus, .num-box:focus, .clip-bar select:focus {
  outline: none; border-color: var(--water-400); box-shadow: 0 0 0 4px var(--brand-ring);
}
.field input.is-ok { border-color: var(--ok); background: var(--ok-soft); }
.field input.is-bad { border-color: var(--bad); background: var(--bad-soft); }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.error { color: var(--bad); font-weight: 600; min-height: 1.3em; margin: 10px 0 0; }
.search { display: block; max-width: 440px; margin: 10px 0 14px; }
.search span { display: block; font-size: 0.86rem; color: var(--muted); margin-bottom: 4px; }

/* ---------- solution ---------- */
.result-head { margin: 22px 0 10px; }
.answer { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 10px; margin-bottom: 26px; }
.answer-item { background: var(--grad-soft); box-shadow: inset 0 0 0 1px var(--brand-ring); border-radius: var(--radius-sm); padding: 14px 16px; min-width: 0; }
.answer-label { display: block; font-size: 0.82rem; color: var(--muted); }
.answer-value { display: block; font-size: 1.25rem; overflow-x: auto; }

.timeline { list-style: none; margin: 0; padding: 0; }
.tl-step { position: relative; display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 16px; padding-bottom: 26px; }
.tl-step:not(:last-child)::before { content: ""; position: absolute; left: 16px; top: 36px; bottom: 2px; width: 2px; background: var(--line); }
.tl-num { width: 34px; height: 34px; border-radius: 50%; background: var(--grad-mark); color: #fff; display: grid; place-items: center; font-family: var(--font-display); font-weight: 700; box-shadow: var(--shadow-soft); }
.tl-body { min-width: 0; }
.tl-body h4 { font-size: 1.05rem; margin: 5px 0 10px; }
.tl-body p { margin: 8px 0; }
.plain-list { margin: 6px 0; padding-left: 20px; }
.plain-list li { margin: 4px 0; }
.vars { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 6px 20px; margin: 12px 0 0; font-size: 0.9rem; }
.vars div { display: flex; gap: 10px; min-width: 0; }
.vars dt { min-width: 44px; }
.vars dd { margin: 0; color: var(--muted); }
.slide-check { margin-top: 12px; }

.math-block { overflow-x: auto; overflow-y: hidden; padding: 4px 0; }
.katex-display { margin: 0.5em 0; }
.katex { font-size: 1.06em; }

.table-wrap { overflow-x: auto; margin: 8px 0 14px; background: var(--surface); border: 1px solid var(--card-line); border-radius: var(--radius); box-shadow: var(--shadow-soft); }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.data-table th, .data-table td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.data-table th { background: var(--surface-2); font-weight: 600; font-size: 0.78rem; color: var(--muted); }
.data-table tbody tr:last-child > * { border-bottom: 0; }
.data-table tbody tr:hover > * { background: color-mix(in srgb, var(--brand-soft) 60%, transparent); }
.data-table td:first-child { white-space: nowrap; }
.slide-table td:nth-child(2) { min-width: 240px; }

.practice-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-top: 16px; }
.practice-grid .actions { margin-top: 14px; }
.answer-key { margin-top: 20px; background: var(--surface); border: 1.5px dashed var(--brand); border-radius: var(--radius); padding: 6px 20px 18px; }
.answer-key summary { cursor: pointer; font-weight: 600; color: var(--brand); padding: 12px 0; }

.practice-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.practice-card { display: grid; gap: 6px; align-content: start; padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; color: var(--ink); text-decoration: none; }
.practice-card:hover { border-color: var(--brand); }
.practice-card strong { font-family: var(--font-display); line-height: 1.25; }
.practice-card .pill { justify-self: start; }

/* ---------- formulas and glossary ---------- */
.formula-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 380px), 1fr)); gap: 14px; }
.formula-card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 18px; min-width: 0; }
.formula-card header { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.formula-card .small { margin: 2px 0 8px; }
.src summary { cursor: pointer; color: var(--muted); font-size: 0.85rem; padding-top: 6px; }
.src pre { margin: 8px 0 0; padding: 10px; background: var(--bg); border-radius: 8px; overflow-x: auto; font-size: 0.78rem; }

.glossary { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr)); gap: 14px; margin-top: 8px; }
.term { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 18px; min-width: 0; }
.term header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.term .symbol { color: var(--muted); font-size: 0.95rem; }
.know { display: flex; align-items: center; gap: 6px; font-size: 0.82rem; color: var(--muted); white-space: nowrap; min-height: 44px; }
.know input { width: 18px; height: 18px; accent-color: var(--brand); }
.levels { display: inline-flex; flex-wrap: wrap; gap: 2px; margin: 6px 0 12px; padding: 3px; background: var(--bg); border-radius: var(--radius-sm); box-shadow: inset 0 0 0 1px var(--line); }
.levels button { font: inherit; font-size: 0.85rem; font-weight: 500; min-height: 36px; padding: 0.3rem 0.85rem; border: 0; border-radius: 9px; background: transparent; color: var(--muted); cursor: pointer; }
.levels button:hover { color: var(--ink); background: var(--surface); }
.levels button.active { background: var(--brand); color: var(--brand-ink); font-weight: 600; box-shadow: var(--shadow-soft); }
.term-body { font-size: 0.96rem; overflow-x: auto; }

/* ---------- narrow screens ---------- */
@media (max-width: 959px) {
  .topbar-inner { gap: 10px; min-height: 56px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
  .brand-text small { display: none; }
  .page { padding-block: 22px 48px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
  .footer-inner { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }

  .home-grid { grid-template-columns: minmax(0, 1fr); gap: 28px; }
  .progress { position: static; }
  .chapter-row { grid-template-columns: 44px minmax(0, 1fr); gap: 12px; }
  .chapter-progress { grid-column: 2; }
  .soon-list { grid-template-columns: minmax(0, 1fr); }
  .chapter-num { font-size: 1.9rem; }
  .chapter-num.lg { font-size: 2.6rem; min-width: 44px; }
  .method ol { grid-template-columns: minmax(0, 1fr); }
  .method li { flex-direction: row; align-items: center; border-top: 0; border-left: 2px solid var(--brand); padding: 4px 0 4px 12px; }

  .workbench { grid-template-columns: minmax(0, 1fr); gap: 18px; }
  .picker { flex-direction: row; overflow-x: auto; position: static; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
  .pick { flex: none; width: 220px; }
  .practice-grid { grid-template-columns: minmax(0, 1fr); }
  .title-row { gap: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  .sidebar { transition: none; }
  html { scroll-behavior: auto; }
}

/* ---- home entries, progress strip, nav children ---- */
.nav-child { margin-left: 14px; padding-left: 10px; font-size: 0.92rem; }
.nav-child .icon { width: 16px; height: 16px; }
.entries { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-top: 24px; }
.entry { display: grid; gap: 10px; align-content: start; padding: 26px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; color: var(--ink); text-decoration: none; min-width: 0; }
.entry:hover { border-color: var(--brand); }
.entry:focus-visible { outline: 3px solid var(--signal); outline-offset: 2px; }
.entry-icon { width: 46px; height: 46px; display: grid; place-items: center; border-radius: var(--radius-sm); background: var(--grad-mark); color: #fff; box-shadow: var(--shadow-soft); }
.entry-icon .icon { width: 24px; height: 24px; }
.entry-practical .entry-icon { background: linear-gradient(135deg, var(--sand-400), var(--sand-600)); }
.entry h2 { font-size: 1.8rem; margin: 6px 0 0; }
.entry p { margin: 0; color: var(--muted); max-width: 46ch; }
.entry-cta { margin-top: 6px; font-weight: 700; color: var(--brand); }
.entry:hover .entry-cta { text-decoration: underline; }
.progress-strip { margin-top: 16px; }
.progress-strip h2 { font-size: 1.15rem; margin: 0 0 14px; }
.strip-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; align-items: center; }
.strip-foot { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line); }
.strip-foot p { margin: 0; }
.practice-card.is-disabled { opacity: 0.6; cursor: default; }
.practice-card.is-disabled:hover { border-color: var(--line); }
section + section { margin-top: 28px; }
@media (max-width: 959px) {
  .entries, .strip-grid { grid-template-columns: minmax(0, 1fr); }
  .entry { padding: 20px; }
}

/* ---------- v3: introduction, cards, slides, solution modes, assessment ---------- */
.intro { padding-block: 12px 8px; max-width: 760px; }
.intro h1 { font-size: clamp(2rem, 4.6vw, 3rem); line-height: 1.05; letter-spacing: -0.025em; }
.lead { font-size: 1.15rem; color: var(--muted); margin: 14px 0 22px; max-width: 62ch; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }
.page > section > h2 { margin-bottom: 10px; }
.page > section p { max-width: 70ch; }
.task-list { list-style: none; padding: 0; margin: 12px 0 18px; display: grid; gap: 0; }
.task-list li { display: grid; gap: 2px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.task-list span { color: var(--muted); }
.fact { background: var(--grad-soft); box-shadow: inset 0 0 0 1px var(--brand-ring); border-radius: var(--radius-sm); padding: 14px 16px; max-width: 70ch; }
.map-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 24px; }
.map-group h3 { margin-bottom: 2px; }
.map-list { list-style: none; padding: 0; margin: 10px 0 0; display: grid; }
.map-list li { border-bottom: 1px solid var(--line); }
.map-list a, .map-list .is-soon { display: flex; gap: 12px; padding: 9px 0; text-decoration: none; color: var(--ink); align-items: baseline; }
.map-list a:hover { color: var(--brand); }
.map-list b { width: 18px; text-align: center; font-family: var(--font-display); color: var(--brand); flex: none; }
.map-list .is-soon { color: var(--muted); }
.map-list small { margin-left: auto; font-size: 0.75rem; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.cards.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.card { display: grid; gap: 8px; align-content: start; padding: 20px; background: var(--surface); border: 1px solid var(--card-line); border-radius: var(--radius); color: var(--ink); text-decoration: none; min-width: 0; }
.card strong { font-family: var(--font-display); font-size: 1.05rem; font-weight: 700; line-height: 1.3; }
.card .pill { justify-self: start; }
.file-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.file-actions .btn { min-height: 40px; padding: 0.45rem 0.95rem; font-size: 0.92rem; }
.path { margin: 18px 0 0; padding-left: 1.3rem; color: var(--muted); max-width: 70ch; }
.path li { margin: 4px 0; }
.progress-strip { margin-top: 36px; }
.strip-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.strip-foot { grid-column: 1 / -1; display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; }
.strip-foot p { margin: 0; }
.head-actions { margin: 14px 0 0; }

.slide-list { list-style: none; padding: 0; margin: 0; }
.slide-item { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 18px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.slide-no span { display: block; font-size: 0.78rem; color: var(--muted); }
.slide-no strong { font-family: var(--font-display); font-size: 1.15rem; color: var(--brand); }
.slide-topic { margin: 0 0 8px; font-weight: 500; }
.slide-line { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-top: 6px; }
.slide-line > .small { width: 58px; flex: none; }
button.chip { border: 0; font: inherit; font-size: 0.8rem; cursor: pointer; }
.term-chip { background: var(--brand-soft); color: var(--ink); }
.term-chip:hover { filter: brightness(0.96); }
.term-chip.on { background: var(--brand); color: var(--brand-ink); }
.slide-terms { display: grid; gap: 10px; margin-top: 10px; }
.slide-terms:empty { display: none; }

.sol-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin: 24px 0 14px; }
.mode { display: inline-flex; gap: 2px; padding: 3px; background: var(--bg); border-radius: var(--radius-sm); box-shadow: inset 0 0 0 1px var(--line); }
.mode button { border: 0; border-radius: 9px; background: transparent; color: var(--muted); font: inherit; font-size: 0.875rem; font-weight: 500; padding: 0.45rem 0.9rem; min-height: 36px; cursor: pointer; }
.mode button:hover { color: var(--ink); background: var(--surface); }
.mode button.active { background: var(--brand); color: var(--brand-ink); font-weight: 600; box-shadow: var(--shadow-soft); }
.tl-step.is-locked { opacity: 0.45; }
.tl-step.is-locked .tl-num, .tl-step.is-next .tl-num { background: var(--surface-2); color: var(--muted); }
.tl-step.is-next .tl-num { background: var(--signal); color: var(--signal-ink); }
.tl-body h5 { font-family: var(--font-display); font-size: 0.95rem; margin: 14px 0 6px; }
.law { margin-bottom: 2px; }

.ways { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; margin-bottom: 18px; display: grid; gap: 6px; justify-items: start; }
.ways p, .ways ol { margin: 0; }
.ways ol { padding-left: 1.25rem; color: var(--muted); }
.problem-card strong { font-size: 1.05rem; }

.q-step { border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px 16px; margin: 16px 0 0; background: var(--surface); min-width: 0; }
.q-step legend { font-family: var(--font-display); font-weight: 700; padding: 0 8px; }
.cls-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.cls-row:last-child { border-bottom: 0; }
.cls-name { min-width: 0; flex: 1 1 220px; }
.segs { display: flex; flex-wrap: wrap; gap: 6px; }
.seg input, .opt input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: inline-block; padding: 0.35rem 0.8rem; border: 1px solid var(--line); border-radius: 999px; font-size: 0.88rem; cursor: pointer; }
.seg input:checked + span { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.seg input:focus-visible + span, .opt input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }
.opt { display: block; position: relative; margin: 6px 0; }
.opt span { display: block; padding: 0.65rem 0.95rem; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); cursor: pointer; transition: border-color 0.15s, background-color 0.15s; }
.opt span:hover { border-color: var(--brand-ring); background: var(--brand-soft); }
.opt input:checked + span { border-color: var(--brand); background: var(--brand-soft); box-shadow: inset 0 0 0 1px var(--brand); }
.feedback { margin-top: 18px; }
.verdict { padding: 12px 16px; border-radius: var(--radius-sm); }
.verdict.bad { background: var(--bad-soft); color: var(--ink); box-shadow: inset 0 0 0 1px var(--bad-ring); }
.verdict.ok { background: var(--ok-soft); color: var(--ink); box-shadow: inset 0 0 0 1px var(--ok-ring); }
.fb-list { list-style: none; padding: 0; margin: 14px 0; display: grid; gap: 10px; }
.fb { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 10px; }
.fb p { margin: 4px 0 0; }
.fb-mark { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; color: #fff; }
.fb.is-ok .fb-mark { background: var(--ok); }
.fb.is-bad .fb-mark { background: var(--bad); }
.bars { display: grid; gap: 14px; }
.result-list { list-style: none; padding: 0; margin: 10px 0 0; display: grid; }
.result-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.result-list li span:first-child { flex: 1 1 200px; }
.page > .panel, .page > section.panel { margin-top: 16px; }

@media (max-width: 959px) {
  .map-grid, .cards.three, .strip-grid { grid-template-columns: minmax(0, 1fr); }
  .slide-item { grid-template-columns: minmax(0, 1fr); gap: 6px; }
  .slide-no { display: flex; gap: 8px; align-items: baseline; }
}
[hidden] { display: none !important; }
.intro { margin-bottom: 36px; }
.page > section + section, .page > .chapter-list + section { margin-top: 40px; }

/* ---------- v4: scene tokens, subnav, welcome, slides, labs, quick checks ---------- */
:root { --dio-sky-top: #93c9ec; --dio-sky-bottom: #e6f4fb; --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) { --dio-sky-top: #1d4364; --dio-sky-bottom: #5c8fae; }
}
:root[data-theme="dark"] { --dio-sky-top: #1d4364; --dio-sky-bottom: #5c8fae; }
:root[data-theme="ramadan"] { --dio-sky-top: #1a2552; --dio-sky-bottom: #4a5a92; }
:root[data-theme="glass-dark"] { --dio-sky-top: #0d2236; --dio-sky-bottom: #3d6a8c; }
:root[data-theme="glass-purple"] { --dio-sky-top: #2a1550; --dio-sky-bottom: #7a5cb8; }

.subnav { border-top: 1px solid var(--topbar-line); }
.subnav-inner { display: flex; gap: 4px; max-width: 1120px; margin: 0 auto; overflow-x: auto; scrollbar-width: none;
  padding: 6px max(24px, env(safe-area-inset-right, 0px)) 6px max(24px, env(safe-area-inset-left, 0px)); }
.subnav-inner::-webkit-scrollbar { display: none; }
.sub-link { padding: 0.4rem 0.8rem; border-radius: 10px; color: var(--muted); text-decoration: none; font-size: 0.85rem; font-weight: 600; white-space: nowrap; transition: background-color 0.15s, color 0.15s; }
.sub-link:hover { color: var(--ink); background: var(--brand-soft); }
.sub-link.active { color: var(--brand-ink); background: var(--brand); }

.page.wide { max-width: 1280px; }
.h-sm { font-size: clamp(1.4rem, 2.6vw, 1.9rem); }
.empty { text-align: center; max-width: 460px; margin: 48px auto; padding: 40px 24px; border: 1.5px dashed var(--line); border-radius: var(--radius); background: var(--surface); }
.empty-mark { width: 56px; height: 56px; margin: 0 auto 12px; border-radius: var(--radius); background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; box-shadow: inset 0 0 0 1px var(--brand-ring); }
.empty p { color: var(--muted); margin: 8px 0 0; }
.cards.sections { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }

/* welcome: the hero banner (water-to-lagoon gradient with contour rings), as on the CE 341 dashboard */
.welcome {
  position: relative; isolation: isolate; overflow: hidden;
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 32px; align-items: center;
  margin-bottom: 28px; padding: 36px 40px; border-radius: 24px; background: var(--grad-hero); color: #fff; box-shadow: var(--shadow-lift);
}
.welcome::before, .next-card::before {
  content: ""; position: absolute; z-index: -1; top: -48px; right: -48px; width: 300px; height: 300px; border-radius: 50%;
  background: repeating-radial-gradient(circle, transparent 0 18px, rgb(255 255 255 / 0.1) 18px 20px); pointer-events: none;
}
.welcome h1 { font-size: clamp(2rem, 4.2vw, 2.9rem); line-height: 1.1; color: #fff; }
.welcome .lead { margin: 16px 0 24px; color: rgb(239 248 255 / 0.9); }
.welcome .btn-primary, .next-card .btn-primary { background: #fff; color: var(--water-800); box-shadow: 0 10px 15px -3px rgb(13 66 101 / 0.25); }
.welcome .btn-primary:hover, .next-card .btn-primary:hover { background: var(--water-50); }
.welcome .btn-quiet { background: rgb(255 255 255 / 0.15); color: #fff; box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.3); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
.welcome .btn-quiet:hover { background: rgb(255 255 255 / 0.25); }
.info-panel { background: var(--surface); border: 1px solid var(--card-line); border-radius: var(--radius); padding: 20px 22px; margin-bottom: 8px; box-shadow: var(--shadow-soft); }
.info-panel h2 { font-size: 1.25rem; }
.info-panel p { max-width: 70ch; }

/* 3D water-cycle model (views-diorama.js) */
.dio { margin: 0; min-width: 0; }
.dio-view { position: relative; height: clamp(380px, 56vh, 520px); border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); background: linear-gradient(180deg, var(--dio-sky-top), var(--dio-sky-bottom)); }
.welcome .dio-view { border-color: rgb(255 255 255 / 0.25); box-shadow: 0 18px 40px -18px rgb(2 20 34 / 0.55); }
.welcome .dio-legend { color: rgb(239 248 255 / 0.85); }
.welcome .dio-legend b { color: #fff; }
.welcome .dio-sw { border-color: rgb(255 255 255 / 0.35); }
.dio-canvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; -webkit-user-select: none; user-select: none; }
.dio-canvas:active { cursor: grabbing; }
.dio-labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.dio-tag { position: absolute; left: 0; top: 0; pointer-events: auto; display: inline-flex; align-items: center; gap: 7px; padding: 4px 11px 4px 4px; border-radius: 999px; background: var(--surface); color: var(--ink); border: 1px solid var(--line); font: 700 13px/1 var(--font-body); white-space: nowrap; cursor: pointer; will-change: transform; }
.dio-tag .n { width: 21px; height: 21px; border-radius: 50%; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); font: 600 11px/1 var(--font-mono); }
.dio-tag.on { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); z-index: 2; }
.dio-tag.on .n { background: var(--brand-ink); color: var(--brand); }
.dio-tools { position: absolute; left: 12px; right: 12px; bottom: 12px; display: flex; flex-wrap: wrap; gap: 8px; pointer-events: none; }
.dio-tool { pointer-events: auto; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 999px; padding: 9px 15px; font: 700 14px/1 var(--font-body); cursor: pointer; }
.dio-tool:hover { border-color: var(--brand); }
.dio-tool[aria-pressed="true"] { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.dio-hint { position: absolute; right: 12px; top: 12px; padding: 7px 11px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: 600 12px/1 var(--font-mono); transition: opacity 0.6s; }
.dio-hint.gone { opacity: 0; }
.dio-status { position: absolute; inset: 0; display: grid; place-items: center; padding: 24px; text-align: center; font-weight: 600; color: var(--ink); }
.dio-status[hidden], .dio-hint[hidden], .dio-tools[hidden] { display: none; }
.dio-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; margin-top: 10px; color: var(--muted); }
.dio-legend b { color: var(--ink); }
.dio-sw { display: inline-block; width: 13px; height: 13px; margin-right: 6px; border-radius: 4px; border: 1px solid var(--line); vertical-align: -2px; }
.dio-panel { display: grid; gap: 16px; }
.dio-rail { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; }
.dio-step { width: 100%; min-height: 44px; display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--bg); color: var(--ink); font: 600 0.92rem/1.2 var(--font-display); text-align: left; cursor: pointer; transition: background-color 0.15s, border-color 0.15s; }
.dio-step:hover { border-color: var(--brand-ring); background: var(--brand-soft); }
.dio-step .n { min-width: 1.2em; color: var(--muted); font: 600 12px/1 var(--font-mono); }
.dio-step[aria-current="step"] { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); box-shadow: var(--shadow-soft); }
.dio-step[aria-current="step"] .n { color: var(--brand-ink); }
.dio-card { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 250px); gap: 12px 24px; align-items: start; }
.dio-count { margin: 0 0 4px; color: var(--muted); font: 600 12px/1 var(--font-mono); letter-spacing: 0.09em; text-transform: uppercase; }
.dio-card h2 { margin: 0 0 6px; font-size: 1.5rem; }
.dio-course { margin: 12px 0 8px; }
.dio-fact { display: grid; gap: 4px; padding: 14px 16px; border-radius: var(--radius-sm); background: var(--grad-soft); box-shadow: inset 0 0 0 1px var(--brand-ring); }
.dio-fact-num { color: var(--brand); font: 600 1.5rem/1.1 var(--font-mono); font-variant-numeric: tabular-nums; }
.dio-fact-label { font-size: 0.9rem; line-height: 1.4; }
.dio-nav { display: flex; flex-wrap: wrap; gap: 8px; }
@media (max-width: 959px) { .dio-rail { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 700px) { .dio-card { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 600px) {
  .dio-view { height: clamp(320px, 54vh, 420px); border-radius: 14px; }
  .dio-tag:not(.on) { padding: 4px; }
  .dio-tag:not(.on) .t { display: none; }
}
@media (max-width: 420px) { .dio-rail { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (prefers-reduced-motion: reduce) { .dio-hint { transition: none; } }
.roles { margin: 12px 0; }
.role-chip { padding: 0.4rem 0.9rem; font-size: 0.9rem; }
.role-card { background: var(--surface); border: 1px solid var(--card-line); border-radius: var(--radius); padding: 20px 22px; max-width: 760px; }
.role-q { padding: 12px 16px; border-radius: var(--radius-sm); background: var(--grad-soft); box-shadow: inset 0 0 0 1px var(--brand-ring); margin: 10px 0; }

/* slides */
.slide-cards { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.slide-card img { width: 100%; height: auto; border-radius: var(--radius-sm); border: 1px solid var(--line); background: #fff; }
.viewer { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 24px; align-items: start; }
.slide-frame { position: relative; width: 100%; background: #fff; border: 1px solid var(--card-line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-soft); }
.slide-frame img { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
/* Clicking the right or left half of the slide changes slides; a chevron shows on the half under the mouse */
.slide-frame[data-side="next"], .slide-frame[data-side="prev"] { cursor: pointer; }
.slide-nav {
  position: absolute; top: 50%; width: 46px; height: 46px; margin-top: -23px; display: grid; place-items: center; border-radius: 50%;
  background: rgb(11 42 60 / 0.55); color: #fff; box-shadow: 0 4px 14px rgb(11 42 60 / 0.25);
  opacity: 0; pointer-events: none; transition: opacity 0.15s;
}
.slide-nav .icon { width: 24px; height: 24px; }
.slide-nav-prev { left: 12px; }
.slide-nav-prev .icon { transform: scaleX(-1); }
.slide-nav-next { right: 12px; }
.slide-frame[data-side="prev"] .slide-nav-prev, .slide-frame[data-side="next"] .slide-nav-next { opacity: 1; }
@media (prefers-reduced-motion: reduce) { .slide-nav { transition: none; } }
.spot { position: absolute; border: 0; padding: 0; background: rgb(207 168 101 / 0.28); border-bottom: 2px solid var(--sand-500); border-radius: 3px; cursor: pointer; min-width: 14px; }
.spot-p { background: rgb(15 146 216 / 0.16); border-bottom-color: var(--water-500); }
.spot:hover, .spot:focus-visible { background: rgb(207 168 101 / 0.5); outline: 2px solid var(--focus); }
.spot-p:hover, .spot-p:focus-visible { background: rgb(15 146 216 / 0.32); }
.stage-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; }
.stage-no { font-weight: 600; font-variant-numeric: tabular-nums; }
.btn.is-off { opacity: 0.4; pointer-events: none; }
.stage-hint { margin: 8px 0 0; }
.side { position: sticky; top: 130px; background: var(--surface); border: 1px solid var(--card-line); border-radius: var(--radius); padding: 18px 20px; display: grid; gap: 8px; min-width: 0; max-height: calc(100vh - 150px); overflow-y: auto; }
.side h2 { font-size: 1.1rem; }
.side h3 { font-size: 0.9rem; color: var(--muted); margin-top: 6px; }
.side-topic { margin: 0; font-weight: 500; }
.side-term .term { box-shadow: none; }
.thumbs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 8px; }
.thumb { flex: none; width: 128px; position: relative; border: 2px solid transparent; border-radius: 10px; overflow: hidden; text-decoration: none; box-shadow: var(--shadow-soft); }
.thumb img { display: block; width: 100%; height: auto; background: #fff; }
.thumb span { position: absolute; right: 4px; bottom: 4px; background: var(--surface); color: var(--ink); font-size: 0.72rem; font-weight: 700; padding: 0 6px; border-radius: 6px; }
.thumb.active { border-color: var(--brand); }

/* How to read the slides: Previous / Next or Scroll, and full screen (views-slides.js) */
.view-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 10px; }
.view-bar .stage-no { margin-left: auto; }
.view-bar .full-btn { margin-left: auto; min-height: 40px; }
.view-bar .stage-no + .full-btn { margin-left: 0; }
.full-btn .icon { width: 18px; height: 18px; }
.vb-seg { display: inline-flex; gap: 3px; padding: 3px; border-radius: var(--radius-sm); background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); }
.vb-btn {
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 12px; border: 0; border-radius: calc(var(--radius-sm) - 3px);
  background: transparent; color: var(--ink); font: inherit; font-size: 0.85rem; font-weight: 600; cursor: pointer; transition: background-color 0.15s;
}
.vb-btn .icon { width: 18px; height: 18px; }
.vb-btn:hover { background: var(--brand-soft); }
.vb-btn[aria-pressed="true"] { background: var(--brand); color: var(--brand-ink); }
.is-scroll .view-bar {
  position: sticky; top: var(--vb-top, 8px); z-index: 20; padding: 6px;
  background: var(--surface); border: 1px solid var(--card-line); border-radius: var(--radius); box-shadow: var(--shadow-soft);
}
.stack-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-bottom: 12px; }
.stack-tools .stage-hint { margin: 0; flex: 1 1 260px; }
.slide-stack { display: grid; gap: 22px; }
.stack-cap { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 6px; color: var(--muted); font-size: 0.86rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.stack-card { position: relative; display: grid; gap: 10px; }
.stack-card:not(:empty) { margin-top: 10px; }
.sc-word:empty, .sc-term:empty { display: none; }
.stack-card-x { position: absolute; z-index: 1; top: 8px; right: 8px; width: 34px; height: 34px; display: grid; place-items: center; border: 0; border-radius: 50%; background: var(--surface); color: var(--muted); cursor: pointer; box-shadow: inset 0 0 0 1px var(--line); }
.stack-card-x:hover { background: var(--brand-soft); color: var(--ink); }
.stack-card-x .icon { width: 18px; height: 18px; }
@media (prefers-reduced-motion: reduce) { .vb-btn { transition: none; } }
@media (max-width: 600px) {
  .vb-btn { padding: 0 9px; font-size: 0.8rem; }
  .vb-btn .icon { display: none; }
  .view-bar .stage-no { font-size: 0.85rem; }
  .view-bar .full-btn { padding: 0 10px; }
  .view-bar .full-btn span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .slide-stack { gap: 16px; }
}
/* Full screen: only the slides and their bars, on a dark background, each slide fitted to the screen height */
html.slides-full, html.slides-full body { background: #0e161c; }
html.slides-full :is(.sidebar, .topbar, .scrim, .site-footer, .calc, .page-head, .viewer > .side, .slides-thumbs, .annot-bar, .notes-panel, .stage-hint, .stack-notes, .stack-tools, .case-links) { display: none !important; }
html.slides-full .content { margin-left: 0 !important; }
/* the page's fade-up animation keeps a transform, which would pin the floating bars to the page instead of the screen */
html.slides-full #app > .page { animation: none; }
html.slides-full .page.wide { max-width: none; padding: 10px max(12px, env(safe-area-inset-right, 0px)) 10px max(12px, env(safe-area-inset-left, 0px)); }
html.slides-full .viewer { display: block; }
html.slides-full .viewer:not(.is-scroll) .stage { min-height: calc(100vh - 20px); min-height: calc(100dvh - 20px); display: flex; flex-direction: column; justify-content: center; }
html.slides-full .slide-frame { width: min(100%, calc((100vh - 20px) * var(--ar))); width: min(100%, calc((100dvh - 20px) * var(--ar))); margin-inline: auto; border-color: transparent; }
html.slides-full .stack-cap { justify-content: center; color: #dfe8ee; }
/* the bars float over the slide and stay hidden until the screen is clicked (html.bars-on, views-slides.js) */
html.slides-full :is(.view-bar, .stage-bar) {
  position: fixed; z-index: 30; left: max(12px, env(safe-area-inset-left, 0px)); right: max(12px, env(safe-area-inset-right, 0px)); margin: 0; padding: 6px;
  background: var(--surface); border: 1px solid var(--card-line); border-radius: var(--radius); box-shadow: var(--shadow-lift);
  opacity: 0; visibility: hidden; transition: opacity 0.2s, transform 0.2s, visibility 0s 0.2s;
}
html.slides-full .view-bar { top: max(10px, env(safe-area-inset-top, 0px)); transform: translateY(-8px); }
html.slides-full .stage-bar { bottom: max(10px, env(safe-area-inset-bottom, 0px)); transform: translateY(8px); }
html.slides-full.bars-on :is(.view-bar, .stage-bar) { opacity: 1; visibility: visible; transform: none; transition: opacity 0.2s, transform 0.2s; }
.view-bar .vb-ar { display: none; }
.fs-card { display: none; }
html.slides-full .fs-card:not(:empty) {
  display: grid; position: fixed; z-index: 31; margin: 0; right: max(16px, env(safe-area-inset-right, 0px)); bottom: max(16px, env(safe-area-inset-bottom, 0px));
  width: min(420px, calc(100vw - 32px)); max-height: 60vh; overflow-y: auto; padding-top: 42px;
}
html.slides-full .fs-card .stack-card-x { top: 0; right: 0; box-shadow: var(--shadow-soft); }
html.slides-full .is-scroll .view-bar .vb-ar { display: inline-flex; }
@media (prefers-reduced-motion: reduce) { html.slides-full :is(.view-bar, .stage-bar) { transition: none; } }

/* labs */
.lab { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 22px; align-items: start; }
.lab-controls { display: grid; gap: 14px; align-content: start; }
.lab-controls .field label { display: flex; justify-content: space-between; gap: 8px; font-size: 0.92rem; }
.lab-controls output { font-variant-numeric: tabular-nums; color: var(--brand); font-weight: 600; }
input[type="range"] { width: 100%; accent-color: var(--brand); min-height: 28px; }
.readout { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 14px; margin: 4px 0 0; }
.readout dt { font-size: 0.78rem; color: var(--muted); }
.readout dd { margin: 0; font-family: var(--font-display); font-weight: 700; font-variant-numeric: tabular-nums; }
.fig { background: var(--surface); border: 1px solid var(--card-line); border-radius: var(--radius); padding: 12px; }
.plot, .flow-svg { display: block; width: 100%; height: auto; }
.lab-out { margin-top: 14px; }
.lab-out h2 { font-size: 1.2rem; margin-bottom: 4px; }
.pl-grid { stroke: var(--line); stroke-width: 1; }
.pl-tick { fill: var(--muted); font-size: 12px; font-family: var(--font-body); }
.pl-axis { fill: var(--ink); font-size: 13px; font-family: var(--font-body); }
.pl-lab { fill: var(--muted); font-size: 12px; font-family: var(--font-body); }
.pl-ref { stroke: var(--muted); stroke-width: 1.5; stroke-dasharray: 5 5; }
.pl-crit { stroke: var(--signal); stroke-width: 1.5; stroke-dasharray: 3 5; }
.pl-curve { fill: none; stroke: var(--brand); stroke-width: 3; stroke-linejoin: round; }
.pl-drop { stroke: var(--muted); stroke-width: 1.5; stroke-dasharray: 4 4; fill: none; }
.pl-min { fill: var(--signal); }
.pl-pt { fill: var(--brand); stroke: var(--surface); stroke-width: 2; }
.pl-alt { fill: var(--surface); stroke: var(--brand); stroke-width: 3; }
.fl-water { fill: var(--brand); opacity: 0.28; }
.fl-surface { fill: none; stroke: var(--brand); stroke-width: 3.5; stroke-linecap: round; }
.fl-ghost { fill: none; stroke: var(--brand); stroke-width: 2; stroke-dasharray: 6 5; opacity: 0.6; }
.fl-ghost2 { opacity: 0.35; }
.fl-bed { fill: none; stroke: var(--ink); stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; }
.hump-fill { fill: var(--surface-2); }
.fl-arrows path { fill: none; stroke: var(--brand); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.fl-note { fill: var(--muted); font-size: 12px; font-family: var(--font-body); }
.fl-note-in { fill: var(--ink); font-size: 12px; font-weight: 600; font-family: var(--font-body); }

/* quick checks */
.quiz { display: grid; gap: 14px; margin-top: 8px; }
.quiz-q strong { font-weight: 600; font-family: var(--font-body); font-size: 1.02rem; }
.opts { display: grid; gap: 8px; margin-top: 4px; }
.opt-btn { text-align: left; font: inherit; padding: 0.7rem 0.95rem; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; transition: border-color 0.15s, background-color 0.15s; }
.opt-btn:hover:not(:disabled) { border-color: var(--brand-ring); background: var(--brand-soft); }
.opt-btn:disabled { cursor: default; }
.opt-btn.is-right { border-color: var(--ok); background: var(--ok-soft); }
.opt-btn.is-wrong { border-color: var(--bad); background: var(--bad-soft); }
.quiz-fb { padding: 12px 14px; border-radius: var(--radius-sm); background: var(--surface-2); }
.quiz-fb p { margin: 4px 0; }
.quiz-score { font-weight: 600; margin: 10px 0 0; }

@media (max-width: 959px) {
  .welcome, .viewer, .lab { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; max-height: none; }
  .subnav-inner { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
  .thumb { width: 104px; }
}
@media (min-width: 960px) { .welcome { grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.2fr); } }
.lab-controls .q-step { border: 0; padding: 0; margin: 0; }
.lab-controls .q-step legend { float: left; width: 100%; padding: 0; margin-bottom: 8px; }
.lab-controls .q-step legend + * { clear: both; }

/* ---------- v5: iPad and other touch screens ---------- */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
a, button, summary, label.seg, label.opt, .chip, .spot, .thumb, input[type="range"] { touch-action: manipulation; }
.shell { min-height: 100vh; min-height: 100dvh; }
.site-footer { padding-bottom: env(safe-area-inset-bottom, 0px); }
.field input, .search input, .field select { font-size: max(16px, 1rem); } /* 16px stops Safari zooming in when a field is focused */
.slide-frame, .fig { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.slide-frame img, .thumb img { -webkit-user-drag: none; }
.spot::after { content: ""; position: absolute; inset: -9px -6px; }
input[type="range"] { -webkit-appearance: none; appearance: none; height: 40px; background: transparent; }
input[type="range"]::-webkit-slider-runnable-track { height: 8px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 30px; height: 30px; margin-top: -12px; border-radius: 50%; background: var(--brand); border: 3px solid var(--surface); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35); }
input[type="range"]::-moz-range-track { height: 8px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); }
input[type="range"]::-moz-range-thumb { width: 24px; height: 24px; border-radius: 50%; background: var(--brand); border: 3px solid var(--surface); }
@media (hover: none), (pointer: coarse) {
  .side-link, .side-sublink, .sub-link, .jump, .btn, .chip.link, button.chip, .opt-btn, .mode button, .levels button, .theme-btn { min-height: 44px; }
  .sub-link, .chip.link, button.chip { display: inline-flex; align-items: center; }
  .side-toggle { width: 44px; height: 44px; }
  .seg span { padding: 0.6rem 1rem; min-height: 44px; display: inline-flex; align-items: center; }
  a.card:hover { border-color: var(--line); }
  .spot { background: rgb(207 168 101 / 0.36); }
  .spot-p { background: rgb(15 146 216 / 0.22); }
  .know input { width: 22px; height: 22px; }
  .thumb { width: 120px; }
}
@media (min-width: 700px) and (max-width: 1100px) {
  .page, .page.wide { padding-left: max(24px, env(safe-area-inset-left, 0px)); padding-right: max(24px, env(safe-area-inset-right, 0px)); }
  .viewer { grid-template-columns: minmax(0, 1fr) 300px; gap: 18px; }
  .lab { grid-template-columns: 280px minmax(0, 1fr); }
}
@media (min-width: 700px) and (max-width: 959px) {
  .viewer, .lab { grid-template-columns: minmax(0, 1fr); }
  .welcome { grid-template-columns: minmax(0, 1fr); }
  .cards.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .map-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .side { position: static; max-height: none; }
}
@media (orientation: landscape) and (max-height: 600px) { .side { max-height: none; position: static; } }

/* ---- v6: common mistakes ---- */
.mistakes { margin-top: 20px; border: 1px solid var(--card-line); border-radius: var(--radius); background: var(--surface); }
.mistakes > summary { cursor: pointer; padding: 14px 16px; font-weight: 600; display: flex; gap: 10px; align-items: center; min-height: 44px; }
.mistakes .count { background: var(--brand-soft); color: var(--brand); border-radius: 99px; padding: 1px 9px; font-size: .82rem; }
.mistake-list { margin: 0; padding: 0 16px 8px 36px; display: grid; gap: 14px; }
.mistake-list li::marker { font-weight: 700; color: var(--brand); }
.mistake-list p { margin: 0 0 4px; }
.mistake-list .ar { font-size: 1.02rem; color: var(--muted); line-height: 1.8; }
.src-row { display: flex; gap: 6px; flex-wrap: wrap; }
.src-tag { font-size: .74rem; border-radius: 999px; padding: 2px 9px; color: var(--muted); background: var(--surface-2); }
.src-list { padding: 4px 16px 14px 36px; font-size: .88rem; color: var(--muted); }

/* ---- v6: dashboard ---- */
.next-card {
  position: relative; isolation: isolate; overflow: hidden;
  display: flex; gap: 20px; align-items: center; justify-content: space-between; flex-wrap: wrap;
  background: var(--grad-hero); color: #fff; border-radius: 24px; padding: 26px 28px; box-shadow: var(--shadow-lift);
}
.next-card h2 { margin: 0 0 4px; font-size: 0.95rem; color: rgb(219 240 253 / 0.85); font-weight: 600; }
.next-card .next-title { font-family: var(--font-display); font-size: 1.5rem; font-weight: 700; margin: 0 0 6px; line-height: 1.25; }
.next-card p { margin: 0 0 4px; max-width: 60ch; color: rgb(239 248 255 / 0.9); }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 16px 0 8px; }
.kpi { background: var(--surface); border: 1px solid var(--card-line); border-radius: var(--radius); padding: 16px 18px; display: flex; flex-direction: column; gap: 2px; }
.kpi strong { font-family: var(--font-display); font-size: 1.6rem; font-weight: 700; color: var(--brand-strong); }
.kpi span { color: var(--muted); font-size: .86rem; }
.dash-table td, .dash-table th { vertical-align: middle; }
.dash-table th[scope="row"] { display: flex; flex-direction: column; gap: 2px; font-weight: 600; }
.dash-table td .meter { display: inline-block; width: 90px; vertical-align: middle; margin-right: 8px; }
.dash-two { display: grid; grid-template-columns: 1.2fr 1fr; gap: 16px; margin-top: 16px; }
.step-list, .week { list-style: none; margin: 12px 0 0; padding: 0; }
.step-row { padding: 10px 0; border-top: 1px solid var(--line); }
.step-row:first-child { border-top: 0; }
.step-top { display: flex; justify-content: space-between; margin-bottom: 6px; }
.step-row.is-weak .meter span { background: var(--bad); }
.step-row p { margin: 6px 0 0; color: var(--muted); }
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; align-items: end; }
.day { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.day-bar { width: 100%; max-width: 38px; height: 110px; background: var(--surface-2); border-radius: 10px; display: flex; align-items: flex-end; overflow: hidden; }
.day-bar span { display: block; width: 100%; background: linear-gradient(0deg, var(--water-500), var(--lagoon-400)); border-radius: 10px 10px 0 0; }
.day.today .small:nth-of-type(1) { font-weight: 700; }
@media (max-width: 760px) { .kpis { grid-template-columns: repeat(2, 1fr); } .dash-two { grid-template-columns: 1fr; } .dash-table td .meter { width: 56px; } }

/* ---- v6: Arabic word glosses ---- */
.spot-w { background: rgba(194, 65, 122, 0.10); border-bottom: 2px solid #c2417a; border-radius: 2px; mix-blend-mode: multiply; }
.spot-w:hover, .spot-w:focus-visible, .spot-w.on { background: rgba(194, 65, 122, 0.22); outline: none; }
.word-card { background: var(--surface); border: 1px solid var(--card-line); border-left: 4px solid #c2417a; border-radius: var(--radius); padding: 16px 18px; margin-bottom: 12px; display: grid; gap: 10px; }
.wc-word { margin: 0; font-family: var(--font-display); font-size: 1.35rem; }
.wc-block { display: grid; gap: 4px; }
.wc-label { font-size: .82rem; color: var(--muted); }
.word-card p { margin: 0; }
.wc-ar { font-size: 1.15rem; line-height: 1.9; font-family: var(--font-arabic); }
.wc-en { color: var(--muted); font-size: .92rem; }
.stage-bar { flex-wrap: wrap; gap: 8px; }
.mistake-list .ar { font-family: var(--font-arabic); }

/* ---- v6: chapter map, polish ---- */
.map-rows { list-style: none; margin: 0 0 8px; padding: 0 0 0 14px; border-left: 2px solid var(--line); display: grid; gap: 2px; }
.mr a { display: grid; gap: 2px; padding: 8px 10px; border-radius: 10px; text-decoration: none; color: var(--ink); position: relative; min-height: 44px; }
.mr a::before { content: ""; position: absolute; left: -20px; top: 14px; width: 10px; height: 10px; border-radius: 50%; background: var(--surface); border: 2px solid var(--line); }
.mr.is-done a::before { background: var(--ok); border-color: var(--ok); }
.mr.is-current a { background: var(--brand-soft); }
.mr.is-current a::before { border-color: var(--brand); background: var(--brand); }
.mr a:hover { background: var(--surface-2); }
.mr-range { font-weight: 700; font-size: .82rem; color: var(--brand); }
.mr-topic { font-size: .9rem; line-height: 1.35; }
.mr-meta { font-size: .78rem; color: var(--muted); }
.dash-two { align-items: start; }
.dash-table th[scope="row"] { background: transparent; }
.btn:active { transform: translateY(1px); }
.map-group { background: var(--surface); border: 1px solid var(--card-line); border-radius: var(--radius); padding: 16px 16px 8px; }
.map-list li a:hover { color: var(--brand); }
@media (prefers-reduced-motion: reduce) { .btn { transition: none; } }

.term-ar-name { margin: 2px 0 0; font-family: var(--font-arabic); font-size: 1.05rem; font-weight: 600; color: var(--brand); }
.term-ar { margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--line); font-family: var(--font-arabic); font-size: 1.05rem; line-height: 1.95; }
.term-ar-label { display: block; font-size: .8rem; color: var(--muted); margin-bottom: 2px; }
.term-ar .katex { direction: ltr; unicode-bidi: isolate; }

/* practice tutor */
.opt-btn.is-picked { border-color: var(--brand); background: var(--brand-soft); }
.opt-btn.is-gone { text-decoration: line-through; opacity: 0.45; }
.hint-line { margin: 8px 0 0; padding: 10px 14px; border-left: 3px solid var(--brand); background: var(--brand-soft); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.tutor-actions { margin-top: 14px; display: flex; flex-wrap: wrap; gap: 8px; }
.timer { font-variant-numeric: tabular-nums; }
.bank-table td:nth-child(2) { min-width: 16rem; }
.bank-table td:nth-child(6) { min-width: 14rem; color: var(--muted); }

/* practical hub */
.lab-cards { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.lab-card { gap: 10px; }
.lab-card.is-empty { background: var(--surface-2); border-style: dashed; box-shadow: none; }
.lab-card.is-empty strong, .lab-card.is-empty .chapter-num { color: var(--muted); }
.lab-head { display: grid; grid-template-columns: 2.2rem minmax(0, 1fr); gap: 12px; align-items: start; }
.lab-head > div { display: grid; gap: 4px; min-width: 0; }
.lab-links { margin-top: 2px; }
.lab-stats { display: flex; flex-wrap: wrap; gap: 24px; align-items: center; }
.lab-stats > div { display: grid; gap: 2px; }
.lab-stats strong { font-family: var(--font-display); font-size: 1.5rem; }
.lab-actions { margin-left: auto; display: flex; flex-wrap: wrap; gap: 8px; }
@media (max-width: 640px) { .lab-actions { margin-left: 0; } }

/* course map illustrations */
.map-art { margin: -4px -4px 10px; border-radius: var(--radius-sm); overflow: hidden; background: var(--grad-soft); line-height: 0; }
.map-art svg { width: 100%; height: auto; display: block; }
.map-art .a-soil { fill: var(--surface-2); stroke: var(--line); stroke-width: 1; }
.map-art .a-water, .map-art .a-water2 { fill: var(--brand); fill-opacity: .35; stroke: none; }
.map-art .a-water2 { fill-opacity: .6; }
.map-art .a-line { fill: none; stroke: var(--brand); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.map-art .a-dash { stroke-dasharray: 5 4; }
.map-art .a-river { fill: none; stroke: var(--brand); stroke-width: 5; stroke-linecap: round; opacity: .55; }
.map-art .a-cloud { fill: var(--surface); stroke: var(--brand); stroke-width: 1.5; }
.map-art .a-well { fill: none; stroke: var(--ink); stroke-width: 2.5; stroke-linecap: round; }
.map-art .a-dots circle { fill: var(--brand); opacity: .5; }
.map-art .a-gauge, .map-art .a-flask { fill: var(--surface); stroke: var(--brand); stroke-width: 2.5; stroke-linejoin: round; }
.map-art .a-flask { fill: none; }
.map-list b { width: auto; min-width: 18px; white-space: nowrap; }

/* simulations (views-sims.js) */
.sm-bar { fill: var(--brand); opacity: 0.55; stroke: var(--surface); stroke-width: 2; }
.sm-bar1 { opacity: 0.7; } .sm-bar2 { opacity: 0.85; } .sm-bar3 { opacity: 0.45; }
.sm-loss { fill: var(--muted); opacity: 0.55; }
.sm-exc { fill: var(--brand); opacity: 0.75; }
.sm-sand { fill: var(--signal); opacity: 0.35; }
.cards .card .pill { align-self: flex-start; }
.lab-controls .field { position: relative; }
.num-box { width: 6.5rem; margin-top: 6px; padding: 6px 8px; font: inherit; font-variant-numeric: tabular-nums; direction: ltr; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); }

/* clip player (views-clip.js) */
.clip-stage { position: relative; container-type: inline-size; aspect-ratio: 16 / 9; width: 100%; max-width: 1100px; margin: 0 auto; background: #0f1b21; border-radius: 12px; overflow: hidden; }
.clip-stage svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.clip-cap { position: absolute; left: 2.5%; right: 2.5%; bottom: 3%; display: flex; flex-direction: column; gap: 0.5cqw; align-items: center; text-align: center; pointer-events: none; }
.clip-cap span { background: rgba(8, 16, 20, 0.8); color: #fff; padding: 0.4cqw 1.2cqw; border-radius: 0.8cqw; font-size: 2.05cqw; line-height: 1.35; font-weight: 600; max-width: 100%; }
.clip-cap .ar { font-family: "Noto Sans Arabic", "Geeza Pro", "Segoe UI", Tahoma, "DejaVu Sans", sans-serif; font-size: 2.15cqw; }
.clip-big { position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%); width: 84px; height: 84px; border-radius: 50%; border: 4px solid #1d2b3a; background: #ffd23f; color: #1d2b3a; display: grid; place-items: center; cursor: pointer; }
.clip-big:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
.clip-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; max-width: 1100px; margin: 12px auto; }
.clip-bar input[type=range] { flex: 1 1 200px; min-width: 0; }
.clip-bar select { margin-left: 6px; }
.clip-notes, .clip-script { max-width: 1100px; margin: 12px auto; }
.clip-script ol { padding-left: 1.2em; } .clip-script li { margin: 0 0 10px; }
.chip-clip { font-weight: 700; }

/* theory and practical groups on the home map */
.map-kind { display: inline-block; font-size: 0.75rem; font-weight: 700; padding: 2px 10px; border-radius: 999px; margin-bottom: 6px; background: var(--brand-soft); color: var(--brand); }
.map-group.is-lab { border-top: 4px solid var(--signal); grid-column: 1 / -1; }
.map-group.is-theory { border-top: 4px solid var(--brand); }
.map-group.is-lab .map-kind { background: color-mix(in srgb, var(--signal) 18%, transparent); color: var(--ink); }
.map-group.is-lab .map-list { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); column-gap: 24px; }
.map-group.is-lab .map-list b { width: 34px; color: var(--ink); }
.map-group.is-lab .map-art svg { height: 110px; }
.map-group.is-lab .map-list small { white-space: nowrap; }
.clip-embed { margin: 18px 0 8px; }
.clip-embed h2 { margin-bottom: 4px; }
.clip-embed .clip-stage, .clip-embed .clip-bar { max-width: 960px; margin-left: 0; }

.dio-title { margin: 0 0 10px; font: 700 1.15rem/1.25 var(--font-display, var(--font-body)); color: var(--ink); text-wrap: balance; }
.dio-title span { display: block; margin-top: 3px; font: 500 0.85rem/1.35 var(--font-body); color: var(--muted); }
.welcome .dio-title { color: #fff; }
.welcome .dio-title span { color: rgb(239 248 255 / 0.85); }

/* ---------- design system layer: shared card treatment, motion and the desktop sidebar ---------- */
/* Every card-like surface is the CE 341 card: white, 16px corners, a soft shadow; linked cards lift on hover */
.card, .panel, .entry, .practice-card, .formula-card, .term, .map-group, .role-card, .ways, .q-step, .fig, .side,
.mistakes, .word-card, .kpi, .info-panel { box-shadow: var(--shadow-soft); }
.formula-card, .term, .entry, .practice-card, .ways, .q-step { border-color: var(--card-line); border-radius: var(--radius); }
.lab-controls .q-step { box-shadow: none; }
a.card, .entry, .practice-card { transition: box-shadow 0.2s, transform 0.2s, border-color 0.2s; }
a.card:hover, .entry:hover, .practice-card:hover { border-color: var(--brand-ring); box-shadow: var(--shadow-lift); transform: translateY(-2px); }
.practice-card.is-disabled:hover { border-color: var(--card-line); box-shadow: var(--shadow-soft); transform: none; }
@media (hover: none), (pointer: coarse) {
  a.card:hover, .entry:hover, .practice-card:hover { border-color: var(--card-line); box-shadow: var(--shadow-soft); transform: none; }
}

/* Each view fades up as it opens */
@keyframes fade-up { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
#app > .page { animation: fade-up 0.45s ease-out both; }
@media (prefers-reduced-motion: reduce) {
  #app > .page, .meter > span { animation: none; }
  a.card, .entry, .practice-card { transition: none; }
}

/* With the sidebar beside the page there is no top bar, so sticky panels sit near the top */
@media (min-width: 1200px) {
  .picker { top: 24px; }
}
@media (min-width: 1200px) and (min-height: 601px) {
  .side { top: 24px; max-height: calc(100vh - 48px); }
}

/* ---------- Experiment 2 3D lab (views-lab2game.js) ---------- */
.lg-wrap { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); margin-top: 18px; }
@media (min-width: 1100px) { .lg-wrap { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; } }
.lg-stage { position: relative; height: clamp(380px, 64vh, 640px); border-radius: 20px; overflow: hidden; border: 1px solid var(--line); background: #dcecf2; touch-action: none; -webkit-user-select: none; user-select: none; }
.lg-stage canvas { display: block; width: 100%; height: 100%; cursor: grab; }
.lg-stage.lg-shake { animation: lg-shake 0.35s; }
@keyframes lg-shake { 20% { transform: translateX(-6px); } 40% { transform: translateX(5px); } 60% { transform: translateX(-3px); } 80% { transform: translateX(2px); } }
@media (prefers-reduced-motion: reduce) { .lg-stage.lg-shake { animation: none; } }
.lg-hud { position: absolute; left: 12px; top: 12px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; pointer-events: none; }
.lg-lvl { background: rgb(255 255 255 / 0.92); color: #12303f; border-radius: 999px; padding: 7px 13px; font-weight: 700; font-size: 0.9rem; box-shadow: 0 1px 3px rgb(11 42 60 / 0.15); }
.lg-hearts { background: rgb(255 255 255 / 0.92); border-radius: 999px; padding: 4px 10px; font-size: 1.15rem; letter-spacing: 2px; box-shadow: 0 1px 3px rgb(11 42 60 / 0.15); }
.lg-hearts .on { color: #e4572e; } .lg-hearts .off { color: #b9c7cf; }
.lg-tools { position: absolute; right: 12px; top: 12px; display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; max-width: 60%; }
.lg-btn { background: rgb(255 255 255 / 0.92); color: #12303f; border: 0; border-radius: 999px; padding: 8px 13px; font: 600 0.85rem/1 var(--font-body); cursor: pointer; box-shadow: 0 1px 3px rgb(11 42 60 / 0.15); }
.lg-btn:hover { background: #fff; }
.lg-tip { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); width: max-content; max-width: calc(100% - 28px); background: rgb(18 48 63 / 0.9); color: #fff; border-radius: 14px; padding: 9px 15px; font-weight: 600; font-size: 0.92rem; text-align: center; pointer-events: none; }
.lg-act { position: absolute; right: 14px; bottom: 64px; }
.lg-pour { touch-action: none; padding: 14px 20px; font-size: 1rem; border-radius: 999px; box-shadow: 0 4px 14px rgb(11 42 60 / 0.25); }
.lg-pour:active { transform: scale(0.96); }
.lg-toast { position: absolute; left: 50%; top: 58px; transform: translate(-50%, -8px); max-width: min(520px, calc(100% - 28px)); padding: 10px 15px; border-radius: 12px; background: #fff; color: #12303f; font-weight: 600; font-size: 0.9rem; box-shadow: 0 6px 20px rgb(11 42 60 / 0.18); opacity: 0; pointer-events: none; transition: opacity 0.25s, transform 0.25s; }
.lg-toast.show { opacity: 1; transform: translate(-50%, 0); }
.lg-toast.good { border-left: 5px solid #2bb3a3; } .lg-toast.bad { border-left: 5px solid #e4572e; }
.lg-status { position: absolute; inset: 0; display: grid; place-items: center; padding: 24px; text-align: center; font-weight: 600; color: #12303f; }
.lg-over { position: absolute; inset: 0; display: grid; place-items: center; padding: 16px; background: rgb(16 40 54 / 0.45); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); overflow-y: auto; }
.lg-card { width: min(520px, 100%); max-height: 100%; overflow-y: auto; background: var(--surface); color: var(--ink); border-radius: 20px; padding: 22px; box-shadow: 0 20px 50px rgb(11 42 60 / 0.3); }
.lg-card h2 { margin: 0 0 8px; }
.lg-levels { list-style: none; margin: 14px 0; padding: 0; display: grid; gap: 8px; }
.lg-level { width: 100%; display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; gap: 12px; align-items: center; text-align: left; padding: 11px 13px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface-2, var(--surface)); color: var(--ink); cursor: pointer; font: inherit; }
.lg-level:hover:not(:disabled) { border-color: var(--brand); }
.lg-level.locked { opacity: 0.55; cursor: not-allowed; }
.lg-level .n { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--brand); color: var(--brand-ink); font-weight: 800; }
.lg-level .t { display: grid; gap: 2px; min-width: 0; } .lg-level small { color: var(--muted); }
.lg-level .stars, .lg-big-stars { color: #c9d4da; letter-spacing: 1px; } .lg-level .stars .on, .lg-big-stars .on { color: #f2b705; }
.lg-big-stars { font-size: 2.6rem; text-align: center; line-height: 1; margin-bottom: 6px; }
.lg-win h2, .lg-lose h2 { text-align: center; }
.lg-lose ul { padding-left: 20px; } .lg-lose li { margin: 6px 0; }
.lg-btns { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 14px; }
.lg-side { min-width: 0; }
.lg-side-h { margin: 0 0 8px; font-size: 1.1rem; }
.lg-steps { margin: 0 0 12px; padding-left: 0; list-style: none; counter-reset: s; display: grid; gap: 6px; }
.lg-steps li { counter-increment: s; display: grid; grid-template-columns: 26px 1fr; gap: 8px; align-items: center; padding: 7px 9px; border-radius: 10px; border: 1px solid var(--line); }
.lg-steps li::before { content: counter(s); width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 0.8rem; background: var(--line); }
.lg-steps li.ok::before { content: "✓"; background: var(--ok, #2bb3a3); color: #fff; }
.lg-steps li.ok { color: var(--muted); }
.lg-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; font-variant-numeric: tabular-nums; margin: 6px 0 12px; }
.lg-table th, .lg-table td { padding: 5px 6px; border-bottom: 1px solid var(--line); text-align: right; }
.lg-table th { font-weight: 700; vertical-align: bottom; } .lg-table th small { font-weight: 500; color: var(--muted); }
.lg-table td.warn { color: var(--bad, #e4572e); font-weight: 700; }
.lg-entry { display: grid; gap: 8px; padding: 12px; border-radius: 14px; background: var(--brand-soft); }
.lg-entry p { margin: 0; }
.lg-entry label, .lg-verdict label { display: grid; gap: 4px; font-size: 0.88rem; font-weight: 600; }
.lg-entry input, .lg-verdict input, .lg-inl input { font: inherit; padding: 9px 11px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); min-width: 0; }
.lg-verdict { display: grid; gap: 10px; margin-top: 14px; padding: 12px; border-radius: 14px; border: 1px solid var(--line); }
.lg-vbtns { display: flex; flex-wrap: wrap; gap: 8px; }
.lg-chart { width: 100%; height: auto; display: block; margin: 6px 0 10px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); }
.lg-q { margin: 0 0 12px; } .lg-q p { margin: 0 0 6px; } .lg-q .ok { color: var(--ok, #2bb3a3); font-weight: 600; }
.lg-inl { display: flex; gap: 6px; } .lg-inl input { flex: 1; }
.lg-opt { display: block; width: 100%; text-align: left; margin: 0 0 6px; padding: 9px 11px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; font-size: 0.9rem; cursor: pointer; }
.lg-opt:hover { border-color: var(--brand); }
.lg-foot { margin-top: 18px; }
@media (max-width: 600px) { .lg-stage { height: 62vh; min-height: 360px; } .lg-tools { max-width: 52%; } .lg-btn { padding: 7px 10px; font-size: 0.78rem; } .lg-tip { font-size: 0.85rem; bottom: 10px; } .lg-act { bottom: 70px; right: 10px; } }

/* ---------- 3D flow figure (views-flow3d.js): the flume on a sky gradient, with the shared 3D hint and button ---------- */
.flow3d { position: relative; height: clamp(340px, 54vh, 500px); border-radius: var(--radius-sm); overflow: hidden; background: linear-gradient(180deg, var(--dio-sky-top), var(--dio-sky-bottom)); }
.flow3d-canvas { position: absolute; inset: 0; display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; -webkit-user-select: none; user-select: none; }
.flow3d-canvas:active { cursor: grabbing; }
.flow3d-tags { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.flow3d-tag { position: absolute; left: 0; top: 0; padding: 5px 11px; border-radius: 999px; background: var(--surface); color: var(--ink); border: 1px solid var(--line); font: 700 12.5px/1 var(--font-body); white-space: nowrap; box-shadow: var(--shadow-soft); will-change: transform; }
.flow3d-tools { position: absolute; left: 12px; bottom: 12px; display: flex; gap: 8px; }
@media (max-width: 600px) { .flow3d { height: clamp(250px, 40vh, 330px); } }

/* blue header (Dashboard), matching the Introduction hero */
.page-head.page-head-blue { background: var(--grad-hero); color: #fff; border-color: transparent; box-shadow: var(--shadow-lift); }
.page-head.page-head-blue h1 { color: #fff; }
.page-head.page-head-blue .muted { color: rgb(239 248 255 / 0.88); }

/* ---------- floating scientific calculator (js/views-calc.js) ---------- */
.calc-fab {
  position: fixed; z-index: 58;
  right: calc(20px + env(safe-area-inset-right, 0px)); bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  width: 54px; height: 54px; display: grid; place-items: center; border: 0; border-radius: 50%; cursor: pointer;
  background: var(--grad-mark); color: #fff; box-shadow: var(--shadow-lift); transition: transform 0.15s;
}
.calc-fab svg { width: 26px; height: 26px; }
.calc-fab:hover { transform: translateY(-2px); }
.calc-fab.is-open { transform: scale(0.92); }
.calc-fab:focus-visible, .calc-k:focus-visible, .calc-x:focus-visible, .calc-hist button:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.calc-panel {
  position: fixed; z-index: 59;
  right: calc(20px + env(safe-area-inset-right, 0px)); bottom: calc(86px + env(safe-area-inset-bottom, 0px));
  width: 340px; max-height: calc(100dvh - 120px); overflow-y: auto;
  display: flex; flex-direction: column; gap: 10px; padding: 14px;
  background: var(--surface); color: var(--ink); border: 1px solid var(--card-line); border-radius: var(--radius); box-shadow: var(--shadow-lift);
}
.calc-panel[hidden] { display: none; }
.calc-head { display: flex; align-items: center; gap: 10px; }
.calc-head strong { font-size: 0.95rem; }
.calc-mode { padding: 0.1rem 0.55rem; border-radius: 999px; background: var(--brand-soft); color: var(--brand-strong); font-size: 0.72rem; font-weight: 600; letter-spacing: 0.02em; box-shadow: inset 0 0 0 1px var(--brand-ring); }
.calc-x { margin-left: auto; width: 34px; height: 34px; display: grid; place-items: center; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--muted); cursor: pointer; }
.calc-x:hover { background: var(--surface-2); color: var(--ink); }
.calc-x svg { width: 20px; height: 20px; }
.calc-hist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column-reverse; gap: 2px; max-height: 96px; overflow-y: auto; }
.calc-hist button {
  width: 100%; display: flex; justify-content: space-between; gap: 10px; padding: 3px 8px; border: 0; border-radius: 8px;
  background: transparent; color: var(--muted); font: inherit; font-size: 0.78rem; text-align: left; cursor: pointer; font-variant-numeric: tabular-nums;
}
.calc-hist button:hover { background: var(--surface-2); color: var(--ink); }
.calc-hx { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.calc-hv { flex: none; font-weight: 600; }
.calc-screen { display: grid; gap: 2px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); }
.calc-in {
  width: 100%; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--ink);
  font: inherit; font-size: 1.35rem; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; caret-color: var(--brand);
}
.calc-in::placeholder { color: var(--muted); opacity: 0.6; }
.calc-out { min-height: 1.2em; color: var(--muted); font-size: 0.85rem; text-align: right; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.calc-out.is-err { color: var(--bad); }
.calc-keys { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.calc-k {
  min-height: 42px; padding: 0 2px; border: 0; border-radius: 10px; cursor: pointer;
  font: inherit; font-size: 0.92rem; font-weight: 600; font-variant-numeric: tabular-nums;
  background: var(--surface); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); transition: background-color 0.12s, transform 0.08s;
}
.calc-k:hover { background: var(--brand-soft); box-shadow: inset 0 0 0 1px var(--brand-ring); }
.calc-k:active { transform: scale(0.96); }
.calc-k.k-num { background: var(--surface-2); box-shadow: none; font-size: 1rem; }
.calc-k.k-fn { color: var(--teal-strong); font-size: 0.85rem; }
.calc-k.k-op { color: var(--brand-strong); }
.calc-k.k-mode { color: var(--muted); font-size: 0.8rem; }
.calc-k.is-on { background: var(--brand); color: var(--brand-ink); box-shadow: none; }
.calc-k.k-eq { grid-column: span 2; background: var(--brand); color: var(--brand-ink); box-shadow: none; font-size: 1.05rem; }
.calc-k.k-eq:hover { background: var(--brand-strong); }
@media (max-width: 520px) {
  .calc-fab { right: calc(14px + env(safe-area-inset-right, 0px)); bottom: calc(14px + env(safe-area-inset-bottom, 0px)); width: 50px; height: 50px; }
  .calc-panel {
    left: 0; right: 0; bottom: 0; width: auto; max-height: 88dvh; border-radius: var(--radius) var(--radius) 0 0;
    padding-top: 14px; padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
    padding-left: max(14px, env(safe-area-inset-left, 0px)); padding-right: max(14px, env(safe-area-inset-right, 0px));
  }
  .calc-k { min-height: 48px; }
  .calc-panel:not([hidden]) ~ .calc-fab, .calc-fab.is-open { display: none; }
}
@media (prefers-reduced-motion: reduce) { .calc-fab, .calc-k { transition: none; } .calc-k:active { transform: none; } }

/* ---------- flashcards (js/views-flashcards.js) ---------- */
.fc-decks { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.fc-deck {
  display: flex; flex-direction: column; gap: 2px; min-width: 0; padding: 12px 14px; border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink); text-decoration: none; box-shadow: inset 0 0 0 1px var(--line); transition: background-color 0.15s, box-shadow 0.15s;
}
.fc-deck:hover { background: var(--brand-soft); box-shadow: inset 0 0 0 1px var(--brand-ring); }
.fc-deck strong { font-size: 0.95rem; }
.fc-deck-sub { color: var(--muted); font-size: 0.8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fc-deck-n { margin-top: 4px; color: var(--teal-strong); font-size: 0.75rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.fc-deck.is-mine { background: var(--grad-soft); box-shadow: inset 0 0 0 1px var(--brand-ring); }
.fc-deck.is-on { background: var(--brand); color: var(--brand-ink); box-shadow: none; }
.fc-deck.is-on .fc-deck-sub, .fc-deck.is-on .fc-deck-n { color: var(--brand-ink); opacity: 0.85; }
.fc-deck:focus-visible, .fc-card:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
.fc-opts { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; margin-bottom: 14px; }
.fc-check { display: inline-flex; align-items: center; gap: 8px; font-size: 0.9rem; cursor: pointer; }
.fc-check input { width: 18px; height: 18px; accent-color: var(--brand); }
.fc-opts #fc-reset { margin-left: auto; }
.fc-sm { min-height: 34px; padding: 0.35rem 0.75rem; font-size: 0.8rem; }
.fc-study { max-width: 720px; display: grid; gap: 14px; }
.fc-meter { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 12px; color: var(--muted); font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.fc-card {
  position: relative; display: grid; width: 100%; min-height: 260px; padding: 0; border: 0; cursor: pointer;
  background: none; color: var(--ink); font: inherit; text-align: center; perspective: 1400px;
}
.fc-face {
  grid-area: 1 / 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  min-width: 0; padding: 34px 28px 30px; border-radius: 20px; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  transition: transform 0.45s cubic-bezier(0.3, 0.7, 0.3, 1);
}
.fc-front { background: var(--surface); border: 1px solid var(--card-line); box-shadow: var(--shadow-lift); }
.fc-back { background: var(--grad-head); border: 1px solid var(--brand-ring); box-shadow: var(--shadow-lift); transform: rotateY(180deg); }
.fc-card.is-flipped .fc-front { transform: rotateY(-180deg); }
.fc-card.is-flipped .fc-back { transform: rotateY(0deg); }
.fc-tag { position: absolute; top: 14px; left: 18px; color: var(--muted); font-size: 0.7rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; }
.fc-back .fc-tag { color: var(--teal-strong); }
.fc-text { max-width: 56ch; overflow-wrap: anywhere; line-height: 1.55; }
.fc-front .fc-text { font-size: 1.45rem; font-weight: 700; line-height: 1.35; text-wrap: balance; }
.fc-back .fc-text { font-size: 1.05rem; }
.fc-hint { color: var(--muted); font-size: 0.78rem; }
.fc-actions { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; }
.fc-actions .btn:disabled { opacity: 0.45; cursor: default; }
.fc-actions kbd { padding: 0 5px; border-radius: 4px; font: inherit; font-size: 0.72rem; opacity: 0.7; box-shadow: inset 0 0 0 1px currentColor; }
.fc-again:not(:disabled) { color: var(--bad); box-shadow: inset 0 0 0 1px var(--bad-ring); }
.fc-again:not(:disabled):hover { background: var(--bad-soft); }
.fc-empty, .fc-done { padding: 26px 24px; border-radius: 20px; background: var(--surface); border: 1px dashed var(--line); }
.fc-done { border-style: solid; border-color: var(--ok-ring); background: var(--ok-soft); display: grid; gap: 6px; justify-items: start; }
.fc-done strong { color: var(--ok); font-size: 1.1rem; }
.fc-done p, .fc-empty p { margin: 0 0 6px; }
.fc-manage { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; align-items: start; }
.fc-form { display: grid; gap: 12px; }
.fc-form h3 { margin: 0; font-size: 1rem; }
.fc-form p { margin: 0; }
.fc-form textarea {
  font: inherit; font-size: max(16px, 1rem); width: 100%; min-height: 44px; padding: 0.55rem 0.85rem; resize: vertical;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink);
}
.fc-form textarea:focus { outline: 0; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-ring); }
.fc-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; }
.fc-note { color: var(--ok); }
.fc-note.is-bad { color: var(--bad); }
.fc-list-head { display: flex; align-items: baseline; gap: 10px; margin: 26px 0 8px; }
.fc-list-head h3 { margin: 0; font-size: 1rem; }
.fc-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.fc-list li { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); }
.fc-li-n { flex: none; width: 26px; color: var(--muted); font-size: 0.78rem; font-variant-numeric: tabular-nums; }
.fc-li-body { flex: 1; min-width: 0; display: grid; gap: 2px; font-size: 0.9rem; }
.fc-li-body > * { overflow-wrap: anywhere; }
.fc-li-act { flex: none; display: flex; gap: 6px; }
.fc-del-yes { background: var(--bad); color: #fff; }
@media (max-width: 560px) {
  .fc-card { min-height: 230px; }
  .fc-front .fc-text { font-size: 1.2rem; }
  .fc-actions { grid-template-columns: 1fr 1fr; }
  .fc-actions [data-fc="flip"] { grid-column: 1 / -1; order: -1; }
  .fc-list li { flex-wrap: wrap; }
  .fc-li-act { width: 100%; justify-content: flex-end; }
}
@media (prefers-reduced-motion: reduce) { .fc-face { transition: none; } }
.fc-groups { display: grid; gap: 18px; }
.fc-group { display: grid; gap: 10px; }
.fc-group-label { margin: 0; color: var(--muted); font-size: 0.75rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; }
.fc-group-label span { margin-left: 4px; color: var(--teal-strong); font-variant-numeric: tabular-nums; }
.fc-group-split { padding-top: 18px; border-top: 2px solid var(--line); }
/* ---------- Example lab and Challenge questions (views-exlab.js) ---------- */
.ex-flow { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 18px; padding: 0; }
.ex-flow li { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px 6px 6px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); font-size: 0.86rem; font-weight: 600; }
.ex-flow li + li::before { content: "→"; margin: 0 4px 0 -2px; color: var(--muted); font-weight: 400; }
.ex-flow-n { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--grad-mark); color: #fff; font-size: 0.75rem; }
.ex-cards .ex-card .chips { display: flex; flex-wrap: wrap; gap: 6px; }
.ex-pair { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); align-items: start; }
@media (min-width: 1000px) { .ex-pair { grid-template-columns: minmax(0, 1fr); } }
.ex-pair { max-width: 980px; margin-inline: auto; }
.ex-card-lg { background: var(--surface); border: 1px solid var(--card-line); border-radius: var(--radius); box-shadow: var(--shadow-soft); padding: 20px; min-width: 0; }
.ex-card-lg > header { margin-bottom: 10px; }
.ex-card-lg h3 { margin: 4px 0 0; font-size: 1.15rem; }
.ex-orig { border-top: 4px solid var(--water-500); }
.ex-new { border-top: 4px solid var(--lagoon-400); }
.ex-kicker { display: block; font-size: 0.74rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.ex-thumb { display: block; max-width: 100%; margin: 0 auto 14px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); background: #fff; }
.ex-thumb img { display: block; width: 100%; height: auto; }
.ex-thumb:hover { border-color: var(--brand); }
.ex-idea { background: var(--brand-soft); border-radius: 10px; padding: 10px 12px; }
.ex-note { background: color-mix(in srgb, var(--sand-300) 22%, var(--surface)); border-left: 4px solid var(--sand-500); border-radius: 8px; padding: 10px 12px; }
.ex-answer { font-weight: 500; }
.ex-similar-btn { margin-top: 14px; width: 100%; justify-content: center; }
.ex-steps { margin: 8px 0; padding-left: 22px; }
.ex-steps > li { margin: 6px 0 10px; }
.ex-steps > li > p { margin: 0 0 4px; }
.ex-steps .math-block { overflow-x: auto; overflow-y: hidden; }
.ex-h3 { margin: 22px 0 8px; font-size: 1.05rem; }
.ex-verify li { margin: 6px 0; }
.alt-card { background: var(--surface); border: 1px solid var(--card-line); border-radius: var(--radius); box-shadow: var(--shadow-soft); padding: 18px 20px; margin-bottom: 14px; min-width: 0; }
.alt-card > header { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 10px; margin-bottom: 6px; }
.alt-card h3 { margin: 0; font-size: 1.05rem; flex: 1 1 220px; }
.alt-n { font-size: 0.74rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--brand); }
.alt-vs { margin-bottom: 0; color: var(--muted); }
.tag { display: inline-block; padding: 0.12rem 0.6rem; border-radius: 999px; font-size: 0.72rem; font-weight: 700; background: var(--surface-2); color: var(--muted); }
.tag-exact { background: var(--ok-soft); color: color-mix(in srgb, var(--ok) 80%, var(--ink)); box-shadow: inset 0 0 0 1px var(--ok-ring); }
.tag-approximate { background: color-mix(in srgb, var(--sand-300) 30%, var(--surface)); color: color-mix(in srgb, var(--sand-600) 30%, var(--ink)); }
.tag-check { background: var(--brand-soft); color: var(--brand-strong); box-shadow: inset 0 0 0 1px var(--brand-ring); }
.tag-not { background: var(--bad-soft); color: var(--bad); box-shadow: inset 0 0 0 1px var(--bad-ring); }
.lvl { display: inline-block; padding: 0.15rem 0.65rem; border-radius: 999px; font-size: 0.74rem; font-weight: 700; color: #fff; }
.lvl-easy { background: var(--earth-600); }
.lvl-medium { background: var(--water-600); }
.lvl-hard { background: #8f5f2c; }
.lvl-challenge { background: var(--rose-600); }
.sim-q, .mcq { background: var(--surface); border: 1px solid var(--card-line); border-radius: var(--radius); box-shadow: var(--shadow-soft); padding: 18px 20px; margin-bottom: 14px; min-width: 0; }
.sim-head, .mcq-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 8px; }
.sim-ask { margin: 10px 0; }
.ans-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.ans-in { flex: 1 1 160px; min-width: 0; max-width: 260px; padding: 0.6rem 0.8rem; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); font: inherit; }
.ans-in:focus { border-color: var(--brand); outline: 2px solid var(--brand-ring); outline-offset: 0; }
.ans-fb { min-height: 1.4em; margin: 8px 0 0; font-weight: 600; }
.ans-fb.is-ok, .mcq-verdict.is-ok { color: var(--ok); }
.ans-fb.is-bad, .mcq-verdict.is-bad { color: var(--bad); }
.sim-sol { margin-top: 10px; border-top: 1px dashed var(--line); padding-top: 10px; }
.sim-foot { display: flex; flex-wrap: wrap; gap: 8px; }
.mcq-q { font-weight: 500; }
.mcq-choices { border: 0; margin: 0 0 12px; padding: 0; display: grid; gap: 8px; }
.mcq-choice { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; background: var(--surface); }
.mcq-choice:hover { border-color: var(--brand); background: var(--brand-soft); }
.mcq-choice input { margin-top: 0.3em; accent-color: var(--brand); }
.mcq-choice:has(input:checked) { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }
.mcq-choice:has(input:disabled) { cursor: default; }
.mcq-letter { font-weight: 700; color: var(--brand); min-width: 1.1em; }
.mcq-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.mcq-result:not(:empty) { margin-top: 12px; border-top: 1px dashed var(--line); padding-top: 10px; }
.mcq-result h4 { margin: 14px 0 4px; font-size: 0.95rem; }
.mcq-why { list-style: none; padding: 0; margin: 6px 0; display: grid; gap: 6px; }
.mcq-why li { padding: 8px 10px; border-radius: 8px; background: var(--surface-2); }
.mcq-why li.is-ok { background: var(--ok-soft); box-shadow: inset 0 0 0 1px var(--ok-ring); }
.mcq-links { margin-top: 12px; align-items: center; }
.mcq-filters { display: grid; gap: 10px; margin-bottom: 16px; }
.mcq-filters .chips { display: flex; flex-wrap: wrap; gap: 6px; }
.mcq-filters button.chip { border: 0; cursor: pointer; font: inherit; font-size: 0.78rem; }
.mcq-score { margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.ex-pager { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: 24px; }
@media (max-width: 600px) {
  .ex-card-lg, .alt-card, .sim-q, .mcq { padding: 16px 14px; }
  .ans-in { max-width: none; flex-basis: 100%; }
}

.ex-open{position:absolute;right:2%;z-index:6;padding:.45em .9em;border-radius:999px;background:var(--accent,#0a6e8a);color:#fff;font-weight:600;font-size:clamp(.72rem,1.6vw,.95rem);text-decoration:none;box-shadow:0 2px 8px rgba(0,0,0,.3)}
.ex-open:hover,.ex-open:focus-visible{filter:brightness(1.15);outline:2px solid #fff;outline-offset:2px}

.easy-card{display:grid;gap:1.1rem;padding:1.2rem;border-radius:var(--radius);background:var(--card,#fff);box-shadow:inset 0 0 0 1px var(--card-line)}
.easy-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(260px,1fr));gap:1rem}
.easy-box,.easy-law{padding:.9rem 1rem;border-radius:var(--radius-sm);background:var(--brand-soft);box-shadow:inset 0 0 0 1px var(--brand-ring)}
.easy-box h3,.easy-law h3{margin:0 0 .4rem;font-size:1rem}
.easy-box p,.easy-law p{margin:.3rem 0}
.easy-know{list-style:none;margin:0;padding:0;display:grid;gap:.3rem}
.easy-know li{display:flex;justify-content:space-between;gap:1rem;border-bottom:1px dashed var(--card-line);padding-bottom:.25rem}
.easy-steps{list-style:none;margin:0;padding:0;display:grid;gap:1rem}
.easy-steps li{padding-left:.2rem;min-width:0}
.easy-steps h4{display:flex;align-items:center;gap:.6rem;margin:0 0 .3rem;font-size:1.02rem}
.easy-n{flex:none;width:1.7em;height:1.7em;display:grid;place-items:center;border-radius:50%;background:var(--brand-strong,#0a6e8a);color:#fff;font-size:.85rem}
.easy-mean{margin:.3rem 0;padding:.5rem .8rem;border-left:4px solid var(--brand-ring);background:var(--brand-soft);border-radius:0 8px 8px 0}
.easy-answer{margin:0;padding:.8rem 1rem;border-radius:var(--radius-sm);background:var(--brand-soft);box-shadow:inset 0 0 0 2px var(--brand-ring);font-size:1.05rem}
.easy-tip{margin:0;color:var(--muted,inherit)}
/* ---------- case studies (js/views-cases.js) ---------- */
.cases-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.cases-bar .chips { min-width: 0; }
.cases-ar { min-height: 36px; padding: 0.35rem 0.8rem; font-size: 0.8rem; }
.cases-ar span { font-family: var(--font-arabic); font-weight: 700; color: var(--teal-strong); }
.cases-ar[aria-pressed="false"] span { color: var(--muted); }
.cases-note { margin: -6px 0 16px; }
.cases-list { display: grid; gap: 18px; }
.case {
  min-width: 0; padding: 22px 24px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--card-line); box-shadow: var(--shadow-soft); scroll-margin-top: 80px;
}
.case-tags { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin-bottom: 10px; }
.case-when { color: var(--muted); font-size: 0.8rem; }
.case h2 { margin: 0 0 6px; font-size: 1.3rem; line-height: 1.3; text-wrap: balance; }
.case-hook { margin: 0 0 16px; max-width: 72ch; color: var(--muted); font-size: 1rem; line-height: 1.55; }
.case-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 0 0 14px; }
.case-stat { min-width: 0; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--grad-soft); box-shadow: inset 0 0 0 1px var(--brand-ring); }
.case-stat dt { color: var(--brand-strong); font-size: 1.15rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.25; }
.case-stat dd { margin: 3px 0 0; color: var(--muted); font-size: 0.8rem; line-height: 1.35; }
.case-more > summary {
  display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0.5rem 1rem; border-radius: var(--radius-sm); cursor: pointer;
  list-style: none; background: var(--brand); color: var(--brand-ink); font-size: 0.875rem; font-weight: 600;
}
.case-more > summary::-webkit-details-marker { display: none; }
.case-more > summary::after { content: ""; width: 7px; height: 7px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg) translateY(-2px); transition: transform 0.15s; }
.case-more[open] > summary { background: var(--surface); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }
.case-more[open] > summary::after { transform: rotate(-135deg) translateY(-2px); }
.case-more > summary:hover { background: var(--brand-strong); }
.case-more[open] > summary:hover { background: var(--brand-soft); }
.case-more .case-close, .case-more[open] .case-open { display: none; }
.case-more[open] .case-close { display: inline; }
.case-more summary:focus-visible, .case-think summary:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.case-body { display: grid; gap: 18px; margin-top: 18px; }
.case-body h3 { display: flex; align-items: center; gap: 10px; margin: 0 0 6px; font-size: 1rem; }
.case-body p { margin: 0; max-width: 75ch; line-height: 1.7; }
.case-step { width: 24px; height: 24px; flex: none; display: grid; place-items: center; border-radius: 50%; background: var(--brand-soft); color: var(--brand-strong); font-size: 0.78rem; font-weight: 700; box-shadow: inset 0 0 0 1px var(--brand-ring); }
.case-course ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.case-course li { display: grid; grid-template-columns: minmax(150px, 220px) minmax(0, 1fr); gap: 4px 14px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-2); font-size: 0.9rem; }
.case-course a { color: var(--brand-strong); font-weight: 600; text-decoration: none; }
.case-course a:hover { text-decoration: underline; }
.case-think { padding: 14px 16px; border-radius: var(--radius-sm); background: var(--ok-soft); box-shadow: inset 0 0 0 1px var(--ok-ring); }
.case-think h3 { color: var(--ok); }
.case-think details { margin-top: 10px; }
.case-think summary { cursor: pointer; color: var(--ok); font-weight: 600; font-size: 0.9rem; }
.case-think details p { margin-top: 8px; }
.case-src ol { margin: 0; padding-left: 1.3em; display: grid; gap: 4px; font-size: 0.85rem; }
.case-src a { color: var(--brand-strong); overflow-wrap: anywhere; }
.case sup, .case sub { font-size: 0.7em; line-height: 0; }
/* hard words with an Arabic note */
.gl-en { text-decoration: underline dotted var(--teal); text-underline-offset: 3px; }
.gl-ar {
  display: inline; margin: 0 2px 0 6px; padding: 1px 7px; border-radius: 6px;
  background: var(--brand-soft); color: var(--teal-strong); font-family: var(--font-arabic); font-size: 0.86em; line-height: 1.9;
  box-shadow: inset 0 0 0 1px var(--brand-ring); -webkit-box-decoration-break: clone; box-decoration-break: clone;
}
.no-ar .gl-ar { display: none; }
.no-ar .gl-en { text-decoration: none; }
/* chapter overview: cases for this chapter */
.chapter-cases { margin-top: 32px; }
.chapter-case-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.chapter-case-list a { display: grid; gap: 2px; height: 100%; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); text-decoration: none; box-shadow: inset 0 0 0 1px var(--line); }
.chapter-case-list a:hover { background: var(--brand-soft); box-shadow: inset 0 0 0 1px var(--brand-ring); }
.chapter-case-list span { color: var(--muted); font-size: 0.8rem; }
@media (max-width: 640px) {
  .case { padding: 18px 16px; }
  .case-stats { grid-template-columns: 1fr; }
  .case-stat { display: flex; align-items: baseline; gap: 10px; }
  .case-stat dd { margin: 0; }
  .case-stat dt { white-space: nowrap; }
  .case { scroll-margin-top: 130px; }
  .case-course li { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { .case-more > summary::after { transition: none; } }

/* ---------- Focus: study timer, background sounds and the garden (#/focus) ----------
 * The garden is a small desert oasis: dunes on the horizon, a pond that widens as plants are earned.
 * Daytime colours in the light theme, the same oasis at night in the dark theme. */
:root {
  --fx-sky1: #9fd8f7; --fx-sky2: #e9f7ff; --fx-sun: #f6c453; --fx-cloud: #ffffff;
  --fx-dune: #ead2a0; --fx-dune2: #dfc08a; --fx-ground: #a8d27f; --fx-ground2: #93c46c;
  --fx-water: #38aeee; --fx-shore: #d9c08c; --fx-ripple: rgb(255 255 255 / 0.75);
  --fx-leaf: #3f8f37; --fx-leaf2: #67b24a; --fx-stem: #3a7a2c; --fx-trunk: #9a6b3f; --fx-ring: #7a5230;
  --fx-petal-a: #e4572e; --fx-petal-b: #f2a541; --fx-petal-c: #b05cc8; --fx-petal-w: #ffffff;
  --fx-center-y: #f2c230; --fx-center-b: #6b4423; --fx-berry: #d9364a; --fx-date: #a8551f; --fx-soil: #7b5a3a; --fx-bud: #f28aa0;
  --fx-pill-bg: #0d4265; --fx-pill-ink: #ffffff;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --fx-sky1: #04131f; --fx-sky2: #123a55; --fx-sun: #e8eef5; --fx-cloud: #27475f;
    --fx-dune: #4a5153; --fx-dune2: #3d4446; --fx-ground: #2e5733; --fx-ground2: #274d2c;
    --fx-water: #1d6c9b; --fx-shore: #4f4a3c; --fx-ripple: rgb(200 230 255 / 0.4);
    --fx-leaf: #357a30; --fx-leaf2: #4c9140; --fx-stem: #2f6526; --fx-trunk: #6e4d30; --fx-ring: #523822;
    --fx-petal-a: #c74a28; --fx-petal-b: #d99237; --fx-petal-c: #9450aa; --fx-petal-w: #dfe8ee;
    --fx-center-y: #d6aa2a; --fx-center-b: #4f331c; --fx-berry: #b52c3e; --fx-date: #8a4619; --fx-soil: #5a4229; --fx-bud: #cf6f86;
    --fx-pill-bg: #e4f1f8; --fx-pill-ink: #082a43;
  }
}
:root[data-theme="dark"] {
  --fx-sky1: #04131f; --fx-sky2: #123a55; --fx-sun: #e8eef5; --fx-cloud: #27475f;
  --fx-dune: #4a5153; --fx-dune2: #3d4446; --fx-ground: #2e5733; --fx-ground2: #274d2c;
  --fx-water: #1d6c9b; --fx-shore: #4f4a3c; --fx-ripple: rgb(200 230 255 / 0.4);
  --fx-leaf: #357a30; --fx-leaf2: #4c9140; --fx-stem: #2f6526; --fx-trunk: #6e4d30; --fx-ring: #523822;
  --fx-petal-a: #c74a28; --fx-petal-b: #d99237; --fx-petal-c: #9450aa; --fx-petal-w: #dfe8ee;
  --fx-center-y: #d6aa2a; --fx-center-b: #4f331c; --fx-berry: #b52c3e; --fx-date: #8a4619; --fx-soil: #5a4229; --fx-bud: #cf6f86;
  --fx-pill-bg: #e4f1f8; --fx-pill-ink: #082a43;
}

.fx-vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.fx .page-head { margin-bottom: 18px; }
.fx-msg { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 18px; padding: 14px 16px; border-radius: var(--radius-sm); background: var(--brand-soft); box-shadow: inset 0 0 0 1px var(--brand-ring); }
.fx-msg.plant { background: var(--ok-soft); box-shadow: inset 0 0 0 1px var(--ok-ring); }
.fx-msg p { margin: 0; flex: 1; min-width: 0; }
.fx-msg-x { flex: none; width: 32px; height: 32px; display: grid; place-items: center; border: 0; border-radius: 10px; background: transparent; color: var(--muted); cursor: pointer; }
.fx-msg-x:hover { background: var(--surface); }
.fx-msg-x .icon { width: 18px; height: 18px; }

.fx-top { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr); gap: 20px; align-items: start; }
.fx-top > section + section, .fx-two > section + section { margin-top: 0; }
.fx-timer { display: grid; justify-items: center; gap: 16px; padding: 24px 20px; }
.fx-phase-tabs { display: inline-flex; gap: 4px; padding: 4px; border-radius: 999px; background: var(--surface-2); font-size: 0.85rem; font-weight: 600; }
.fx-phase-tabs span { padding: 0.3rem 0.95rem; border-radius: 999px; color: var(--muted); }
.fx-phase-tabs span.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-soft); }
.fx-ring { position: relative; width: min(280px, 100%); aspect-ratio: 1; max-width: 100%; }
.fx-ring svg { display: block; width: 100%; height: 100%; }
.fx-ring-track { fill: none; stroke: var(--surface-2); stroke-width: 14; }
.fx-ring-bar { fill: none; stroke: var(--brand); stroke-width: 14; stroke-linecap: round; stroke-dasharray: 1000; stroke-dashoffset: 0; transition: stroke-dashoffset 1s linear, stroke 0.3s; }
.fx-timer.is-break .fx-ring-bar { stroke: var(--teal); }
.fx-ring-mid { position: absolute; inset: 14%; display: grid; place-content: center; justify-items: center; text-align: center; gap: 2px; }
.fx-phase { font-size: 0.8rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--brand-strong); }
.fx-timer.is-break .fx-phase { color: var(--teal-strong); }
.fx-time { font-size: clamp(2.6rem, 11vw, 3.6rem); font-weight: 700; line-height: 1.05; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.fx-sub { font-size: 0.82rem; color: var(--muted); max-width: 18ch; line-height: 1.35; text-wrap: balance; }
.fx-controls { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.fx-main { min-width: 9.5rem; }
.fx-controls .btn:disabled { opacity: 0.45; pointer-events: none; }
.fx-next { display: flex; align-items: center; gap: 12px; width: min(340px, 100%); padding: 10px 14px; border-radius: var(--radius-sm); background: var(--ok-soft); }
.fx-next svg { flex: none; width: 40px; height: 44px; }
.fx-next > div { flex: 1; min-width: 0; display: grid; gap: 6px; }
.fx-next strong { font-size: 0.88rem; }
.fx-next .meter > span { background: var(--ok); }
.fx-settings { width: 100%; border-top: 1px solid var(--line); padding-top: 12px; }
.fx-settings summary { cursor: pointer; font-weight: 600; color: var(--brand-strong); width: fit-content; }
.fx-settings[open] summary { margin-bottom: 12px; }
.fx-field { display: grid; gap: 8px; margin-bottom: 14px; }
.fx-label { font-size: 0.85rem; font-weight: 600; }
.fx-custom { display: inline-flex; align-items: center; gap: 8px; }
.fx-custom input, .fx-select { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 0.4rem 0.6rem; }
.fx-custom input { width: 6rem; }
.fx-select { width: 100%; max-width: 100%; }
.fx-checks { gap: 6px; }
.fx-checks label { display: flex; align-items: center; gap: 8px; font-size: 0.92rem; cursor: pointer; }
.fx-checks input { width: 18px; height: 18px; accent-color: var(--brand); }

.fx-sounds h2 { margin-bottom: 2px; }
.fx-sound-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 10px; margin: 14px 0 16px; }
.fx-sound { display: grid; gap: 8px; padding: 10px; border-radius: var(--radius-sm); background: var(--surface-2); transition: background 0.2s, box-shadow 0.2s; }
.fx-sound.on { background: var(--brand-soft); box-shadow: inset 0 0 0 1.5px var(--brand); }
.fx-sound-btn { display: flex; align-items: center; gap: 10px; border: 0; padding: 4px; background: none; color: var(--ink); font: inherit; font-weight: 600; font-size: 0.92rem; cursor: pointer; text-align: start; border-radius: 8px; }
.fx-sound-btn svg { flex: none; width: 28px; height: 28px; color: var(--muted); }
.fx-sound.on .fx-sound-btn svg { color: var(--brand); }
.fx-sound input[type="range"], .fx-master input { width: 100%; accent-color: var(--brand); }
.fx-master { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 12px; font-size: 0.88rem; font-weight: 600; margin-bottom: 12px; }
.fx-sound.on .fx-sound-btn svg { animation: fx-breathe 2.8s ease-in-out infinite; }
@keyframes fx-breathe { 50% { transform: scale(1.12); } }

.fx-garden-sec { margin-top: 32px; }
.fx-garden-head h2 { margin-bottom: 2px; }
.fx-garden-head p { margin: 0 0 12px; }
.fx-garden { border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-soft); border: 1px solid var(--card-line); background: var(--fx-ground); }
.fx-garden svg, .fx-old-card svg { display: block; width: 100%; height: auto; aspect-ratio: 5 / 2; max-width: 100%; }
.fx-sun { fill: var(--fx-sun); }
.fx-cloud { fill: var(--fx-cloud); opacity: 0.85; animation: fx-drift 60s linear infinite alternate; }
.fx-cloud-2 { animation-duration: 80s; animation-direction: alternate-reverse; }
@keyframes fx-drift { to { transform: translateX(90px); } }
.fx-dune { fill: var(--fx-dune); } .fx-dune2 { fill: var(--fx-dune2); }
.fx-ground { fill: var(--fx-ground); } .fx-ground2 { fill: var(--fx-ground2); }
.fx-water { fill: var(--fx-water); } .fx-shore { fill: var(--fx-shore); }
.fx-ripple { fill: none; stroke: var(--fx-ripple); stroke-width: 1.5; animation: fx-ripple 4s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
.fx-ripple-2 { animation-delay: 2s; }
@keyframes fx-ripple { 0%, 100% { transform: scaleX(0.7); opacity: 0.2; } 50% { transform: scaleX(1.1); opacity: 1; } }
.p-leaf { fill: var(--fx-leaf); } .p-leaf2 { fill: var(--fx-leaf2); }
.p-stem { fill: none; stroke: var(--fx-stem); stroke-width: 2.6; stroke-linecap: round; } .p-stem-thick { stroke-width: 4; }
.p-trunk { fill: var(--fx-trunk); } .p-ring { fill: none; stroke: var(--fx-ring); stroke-width: 1.6; stroke-linecap: round; }
.p-petal-a { fill: var(--fx-petal-a); } .p-petal-b { fill: var(--fx-petal-b); } .p-petal-c { fill: var(--fx-petal-c); } .p-petal-w { fill: var(--fx-petal-w); }
.p-center-y { fill: var(--fx-center-y); } .p-center-b { fill: var(--fx-center-b); } .p-berry { fill: var(--fx-berry); } .p-date { fill: var(--fx-date); }
.p-soil { fill: var(--fx-soil); } .p-seed { fill: var(--fx-trunk); } .p-bud { fill: var(--fx-bud); }
.fx-plant, .fx-seedling { transform-box: fill-box; transform-origin: 50% 100%; }
.fx-new { animation: fx-grow 1.4s cubic-bezier(0.2, 1.4, 0.4, 1) both; }
@keyframes fx-grow { from { transform: scale(0.05); } to { transform: scale(1); } }
.fx-seedling { animation: fx-sway 4s ease-in-out infinite; }
@keyframes fx-sway { 50% { transform: rotate(4deg); } }

.fx-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-top: 14px; }
.fx-stat { display: grid; gap: 2px; padding: 14px 16px; border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--card-line); min-width: 0; }
.fx-stat strong { font-size: 1.35rem; line-height: 1.2; color: var(--brand-strong); font-variant-numeric: tabular-nums; }

.fx-two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; margin-top: 28px; align-items: start; }
.fx-badges { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 8px; }
.fx-badges li { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: var(--radius-sm); }
.fx-badges li > span:nth-child(2) { display: grid; min-width: 0; }
.fx-badges li.got { background: var(--ok-soft); }
.fx-badge-mark { flex: none; width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; border: 2px dashed var(--line); color: #fff; }
.fx-badges li.got .fx-badge-mark { border: 0; background: var(--ok); }
.fx-badge-mark .icon { width: 17px; height: 17px; }
.fx-badges li:not(.got) strong { color: var(--muted); }
.fx-goal { display: grid; gap: 6px; margin: 10px 0 14px; }
.fx-goal-bar { display: grid; gap: 6px; margin-bottom: 14px; }
.fx-goal-bar .meter { height: 10px; }
.fx-log { list-style: none; margin: 0; padding: 0; display: grid; }
.fx-log li { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 0.9rem; }
.fx-log-t, .fx-log-m { font-variant-numeric: tabular-nums; }
.fx-log-t { color: var(--muted); }

.fx-old { margin-top: 28px; }
.fx-old:empty { display: none; }
.fx-old-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; margin-top: 10px; }
.fx-old-card { margin: 0; border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); border: 1px solid var(--card-line); }
.fx-old-card figcaption { padding: 8px 12px; font-weight: 600; font-size: 0.9rem; }

.fx-pill { position: fixed; z-index: 57; right: calc(86px + env(safe-area-inset-right, 0px)); bottom: calc(26px + env(safe-area-inset-bottom, 0px));
  display: flex; align-items: center; gap: 4px; padding: 5px 5px 5px 14px; border-radius: 999px; background: var(--fx-pill-bg); color: var(--fx-pill-ink); box-shadow: var(--shadow-lift); }
.fx-pill-link { display: flex; align-items: center; gap: 8px; color: inherit; text-decoration: none; font-size: 0.85rem; font-weight: 600; }
.fx-pill-time { font-variant-numeric: tabular-nums; font-size: 1rem; }
.fx-pill-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--water-400); animation: fx-pulse 2s ease-in-out infinite; }
.fx-pill.is-break .fx-pill-dot { background: var(--lagoon-400); }
.fx-pill.is-paused .fx-pill-dot { animation: none; opacity: 0.4; }
@keyframes fx-pulse { 50% { opacity: 0.35; } }
.fx-pill-btn { width: 36px; height: 36px; display: grid; place-items: center; border: 0; border-radius: 50%; background: rgb(127 127 127 / 0.2); color: inherit; cursor: pointer; }
.fx-pill-btn svg { width: 18px; height: 18px; }
.fx-pill-btn:focus-visible, .fx-pill-link:focus-visible, .fx-sound-btn:focus-visible, .fx-msg-x:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* Focus: the study planner (month calendar + the selected day's tasks) */
.fx-plan { margin-top: 20px; }
.fx-plan-head h2 { margin-bottom: 2px; }
.fx-plan-head p { margin: 0 0 16px; }
.fx-plan-grid { display: grid; grid-template-columns: minmax(0, 300px) minmax(0, 1fr); gap: 24px; align-items: start; }
.fx-cal { padding: 12px; border-radius: var(--radius-sm); background: var(--surface-2); }
.fx-cal-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.fx-cal-top strong { font-size: 0.95rem; }
.fx-cal-nav { width: 32px; height: 32px; display: grid; place-items: center; border: 0; border-radius: 10px; background: var(--surface); color: var(--ink); cursor: pointer; }
.fx-cal-nav[data-cal="prev"] .icon { transform: rotate(180deg); }
.fx-cal-nav .icon { width: 16px; height: 16px; }
.fx-cal-week, .fx-cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; }
.fx-cal-week span { text-align: center; font-size: 0.7rem; font-weight: 600; color: var(--muted); padding-bottom: 4px; }
.fx-cal-day { position: relative; aspect-ratio: 1; max-width: 100%; display: grid; place-items: center; border: 0; border-radius: 10px; background: transparent; color: var(--ink); font: inherit; font-size: 0.85rem; font-variant-numeric: tabular-nums; cursor: pointer; padding: 0; }
.fx-cal-day:hover { background: var(--surface); }
.fx-cal-day i { position: absolute; bottom: 4px; left: 50%; width: 5px; height: 5px; margin-left: -2.5px; border-radius: 50%; }
.fx-cal-day.has i { background: var(--signal); }
.fx-cal-day.is-done i { background: var(--ok); }
.fx-cal-day.is-today span { font-weight: 700; color: var(--brand-strong); }
.fx-cal-day.is-today { box-shadow: inset 0 0 0 1.5px var(--brand-ring); }
.fx-cal-day.is-sel { background: var(--brand); color: var(--brand-ink); box-shadow: none; }
.fx-cal-day.is-sel span { color: var(--brand-ink); }
.fx-cal-day.is-sel i { box-shadow: 0 0 0 1.5px var(--brand); }
.fx-cal-day:focus-visible, .fx-cal-nav:focus-visible, .fx-task-btn:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.fx-cal-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; margin-top: 10px; font-size: 0.75rem; color: var(--muted); }
.fx-cal-key { display: inline-flex; align-items: center; gap: 6px; }
.fx-cal-key i { width: 7px; height: 7px; border-radius: 50%; }
.fx-cal-key .k-has { background: var(--signal); } .fx-cal-key .k-done { background: var(--ok); }
.fx-small { padding: 0.3rem 0.8rem; font-size: 0.82rem; margin-inline-start: auto; }
.fx-day { display: grid; gap: 14px; min-width: 0; }
.fx-day-top { display: grid; gap: 8px; }
.fx-day-top h3 { margin: 0; font-size: 1.1rem; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.fx-today-chip { background: var(--brand-soft); color: var(--brand-strong); }
.fx-day-meter > span { background: var(--ok); }
.fx-add { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 150px) auto; gap: 8px; }
.fx-add input { min-width: 0; font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 0.5rem 0.75rem; }
.fx-add input:focus-visible, .fx-add select:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; }
.fx-tasks { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.fx-task { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 8px 8px 8px 12px; border-radius: var(--radius-sm); background: var(--surface-2); }
.fx-task-main { flex: 1 1 200px; min-width: 0; display: flex; align-items: center; gap: 10px; cursor: pointer; }
.fx-task-main input { flex: none; width: 20px; height: 20px; accent-color: var(--ok); cursor: pointer; }
.fx-task-text { min-width: 0; overflow-wrap: anywhere; }
.fx-task.done .fx-task-text { text-decoration: line-through; color: var(--muted); }
.fx-task.done { background: var(--ok-soft); }
.fx-task-acts { display: flex; gap: 4px; margin-inline-start: auto; }
.fx-task-btn { display: inline-flex; align-items: center; gap: 4px; height: 32px; padding: 0 10px; border: 0; border-radius: 9px; background: var(--surface); color: var(--brand-strong); font: inherit; font-size: 0.8rem; font-weight: 600; cursor: pointer; }
.fx-task-btn .icon { width: 16px; height: 16px; }
.fx-task-del { width: 32px; padding: 0; justify-content: center; color: var(--muted); }
.fx-task-del:hover { color: var(--bad); }
.fx-empty { margin: 0; padding: 14px; border-radius: var(--radius-sm); border: 1.5px dashed var(--line); font-size: 0.9rem; }
.fx-alldone { display: flex; align-items: center; gap: 8px; margin: 0; color: var(--ok); font-weight: 600; }
.fx-alldone .icon { width: 20px; height: 20px; }
.fx-day > .fx-small { justify-self: start; margin: 0; }
@media (max-width: 959px) { .fx-plan-grid { grid-template-columns: minmax(0, 1fr); } .fx-cal { max-width: 420px; } }
@media (max-width: 560px) { .fx-add { grid-template-columns: minmax(0, 1fr) auto; } .fx-add select { grid-column: 1 / -1; grid-row: 2; } }

/* Study Oasis: quick challenges and the toast shown on other pages */
.fx-chal { margin-bottom: 20px; }
.fx-chal-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 6px 16px; margin-bottom: 12px; }
.fx-chal-head h2 { margin-bottom: 2px; }
.fx-chal-head p { margin: 0; }
.fx-chal-count { font-size: 0.85rem; font-weight: 600; color: var(--ok); padding: 0.25rem 0.75rem; border-radius: 999px; background: var(--ok-soft); }
.fx-chal-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.fx-chal-card { display: grid; grid-template-rows: auto 1fr auto auto; gap: 10px; padding: 16px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--card-line); box-shadow: var(--shadow-soft); min-width: 0; }
.fx-chal-card p { margin: 0; }
.fx-chal-card.done { background: var(--ok-soft); border-color: var(--ok-ring); box-shadow: none; }
.fx-chal-top { display: flex; align-items: center; gap: 10px; }
.fx-chal-top h3 { margin: 0; font-size: 1rem; line-height: 1.3; text-wrap: balance; }
.fx-chal-icon { flex: none; width: 36px; height: 36px; display: grid; place-items: center; border-radius: 11px; background: var(--brand-soft); color: var(--brand); }
.fx-chal-card.done .fx-chal-icon { background: var(--ok); color: #fff; }
.fx-chal-icon .icon { width: 19px; height: 19px; }
.fx-chal-prog { display: grid; gap: 4px; }
.fx-chal-prog .small { font-variant-numeric: tabular-nums; color: var(--muted); }
.fx-chal-card.done .meter > span { background: var(--ok); }
.fx-chal-act { display: flex; align-items: center; gap: 8px; }
.fx-chal-act .fx-small { margin: 0; }
.fx-chal-won { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; color: var(--ok); font-size: 0.9rem; }
.fx-chal-won .icon { width: 18px; height: 18px; }
.fx-chal-swap { margin-inline-start: auto; width: 34px; height: 34px; display: grid; place-items: center; border: 0; border-radius: 10px; background: var(--surface-2); color: var(--muted); cursor: pointer; }
.fx-chal-swap svg { width: 18px; height: 18px; }
.fx-chal-swap:hover { color: var(--brand-strong); }
.fx-chal-card.done .fx-chal-swap { display: none; }
.fx-chal-swap:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.fx-chal-more { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; padding: 14px 18px; border-radius: var(--radius); background: var(--grad-hero); color: #fff; }
.fx-chal-more p { margin: 0; }
.fx-toast { position: fixed; z-index: 61; left: 50%; transform: translateX(-50%); bottom: calc(76px + env(safe-area-inset-bottom, 0px)); width: max-content; max-width: calc(100vw - 32px);
  display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-radius: 14px; background: var(--fx-pill-bg); color: var(--fx-pill-ink); font-weight: 600; font-size: 0.9rem; box-shadow: var(--shadow-lift); animation: fx-toast 0.35s ease-out; }
.fx-toast .icon { flex: none; width: 20px; height: 20px; padding: 3px; border-radius: 50%; background: var(--earth-600); color: #fff; }
@keyframes fx-toast { from { opacity: 0; transform: translate(-50%, 10px); } }
@media (max-width: 959px) { .fx-chal-grid { grid-template-columns: minmax(0, 1fr); } .fx-chal-card { grid-template-rows: none; } }
@media (prefers-reduced-motion: reduce) { .fx-toast { animation: none; } }

/* Study Oasis garden: plant details, decoration and the night layer */
.fx-defs { position: absolute; width: 0; height: 0; overflow: hidden; }
:root { --fx-night: rgb(0 0 0 / 0); --fx-star: 0; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --fx-night: rgb(4 18 38 / 0.42); --fx-star: 1; --fx-ground: #3b6e41; --fx-ground2: #305f37; } }
:root[data-theme="dark"] { --fx-night: rgb(4 18 38 / 0.42); --fx-star: 1; --fx-ground: #3b6e41; --fx-ground2: #305f37; }
.fx-night { fill: var(--fx-night); pointer-events: none; }
.fx-stars { fill: #ffffff; opacity: var(--fx-star); }
.p-stem { fill: none; stroke: #4a8a36; stroke-linecap: round; }
.p-vein { fill: none; stroke: rgb(255 255 255 / 0.4); stroke-width: 1; stroke-linecap: round; }
.p-shadow { fill: rgb(20 50 20 / 0.22); }
.p-dot { fill: rgb(255 255 255 / 0.55); }
.p-curl { fill: none; stroke: rgb(90 10 30 / 0.45); stroke-width: 1.1; stroke-linecap: round; }
.p-front { filter: brightness(0.94); }
.p-shine { fill: none; stroke: rgb(255 255 255 / 0.55); stroke-width: 1.5; stroke-linecap: round; }
.p-bark { fill: none; stroke: rgb(70 40 15 / 0.45); stroke-width: 1.4; stroke-linecap: round; }
.p-lilyedge { fill: none; stroke: #c8d6df; stroke-width: 1; }
.p-hl { fill: rgb(255 255 255 / 0.16); }
.p-ribs { fill: none; stroke: rgb(20 70 30 / 0.35); stroke-width: 1; stroke-linecap: round; }
.p-seeddots { fill: none; stroke: rgb(40 20 5 / 0.45); stroke-width: 3; stroke-dasharray: 1.2 2.4; }
.p-blade { fill: none; stroke: rgb(46 110 40 / 0.5); stroke-width: 1.4; stroke-linecap: round; }
.p-stone { fill: #b9ae9b; }
.p-reeds { fill: none; stroke: #4f8a3a; stroke-width: 2; stroke-linecap: round; }
.p-cattail { fill: #7a4f2a; }
.fx-water-hi { fill: rgb(255 255 255 / 0.18); }

@media (max-width: 959px) {
  .fx-top, .fx-two { grid-template-columns: minmax(0, 1fr); }
  .fx-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (prefers-reduced-motion: reduce) {
  .fx-cloud, .fx-ripple, .fx-new, .fx-seedling, .fx-pill-dot, .fx-sound.on .fx-sound-btn svg { animation: none; }
  .fx-ring-bar { transition: none; }
}

/* ---------- Slide notes: writing on the slide, the notes pad and voice notes ---------- */
:root { --nt-paper: #fffdf6; --nt-rule: rgb(28 126 214 / 0.16); --nt-margin: rgb(224 49 49 / 0.25); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --nt-paper: #eef2f4; --nt-rule: rgb(28 126 214 / 0.2); } }
:root[data-theme="dark"] { --nt-paper: #eef2f4; --nt-rule: rgb(28 126 214 / 0.2); }

.annot-bar { display: grid; gap: 8px; margin-bottom: 10px; }
.annot-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; }
.annot-row .btn { display: inline-flex; align-items: center; gap: 8px; }
.annot-row .icon { width: 18px; height: 18px; }
.annot-note { min-width: 0; }
.ink-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; padding: 6px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-soft); width: fit-content; max-width: 100%; }
.ink-toolbar[hidden] { display: none; }
.ink-group { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; }
.ink-sep { width: 1px; height: 26px; background: var(--line); }
.ink-tool, .ink-size { width: 38px; height: 38px; display: grid; place-items: center; border: 0; border-radius: 10px; background: transparent; color: var(--ink); cursor: pointer; padding: 0; }
.ink-tool:hover, .ink-size:hover { background: var(--surface-2); }
.ink-tool .icon { width: 20px; height: 20px; }
.ink-tool[aria-pressed="true"], .ink-size[aria-pressed="true"] { background: var(--brand); color: var(--brand-ink); }
.ink-tool:disabled { opacity: 0.35; cursor: default; background: transparent; }
.ink-clear.armed { background: var(--bad); color: #fff; }
.ink-size i { display: block; border-radius: 50%; background: currentColor; }
.ink-colors { gap: 6px; padding: 0 4px; }
.ink-swatch { width: 26px; height: 26px; border-radius: 50%; padding: 0; border: 2px solid var(--surface); background: var(--sw); box-shadow: 0 0 0 1px rgb(127 127 127 / 0.6); cursor: pointer; }
.ink-swatch[aria-pressed="true"] { box-shadow: 0 0 0 2.5px var(--brand); }
.ink-hint { padding: 0 6px; }
.ink-tool:focus-visible, .ink-size:focus-visible, .ink-swatch:focus-visible, .vn-del:focus-visible, .nt-tabs button:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.slide-frame .ink-layer, .nt-pad .ink-layer { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.ink-hl { mix-blend-mode: multiply; }
.slide-frame .ink-layer { z-index: 2; }
.slide-frame.ink-on { box-shadow: 0 0 0 3px var(--brand), var(--shadow-soft); }
.slide-frame.ink-on .ink-top { pointer-events: auto; touch-action: none; cursor: crosshair; }
.slide-frame.ink-on.tool-text .ink-top { cursor: text; }
.slide-frame.ink-on.tool-eraser .ink-top, .nt-pad.tool-eraser .ink-top { cursor: cell; }
.slide-frame.ink-hidden .ink-layer { display: none; }
.ink-editor { position: absolute; z-index: 3; margin: -5px 0 0 -7px; padding: 3px 6px; border: 1.5px dashed currentColor; border-radius: 6px; background: rgb(255 255 255 / 0.9);
  font-family: var(--font-body); font-weight: 600; line-height: 1.25; resize: none; overflow: hidden; outline: none; box-shadow: 0 4px 14px rgb(0 0 0 / 0.15); }

.notes-panel { margin-top: 18px; padding: 18px; background: var(--surface); border: 1px solid var(--card-line); border-radius: var(--radius); box-shadow: var(--shadow-soft); display: grid; gap: 14px; }
.nt-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px; }
.nt-head h2 { margin: 0; font-size: 1.15rem; }
.nt-head h2 .muted { font-weight: 500; }
.nt-tabs { display: inline-flex; gap: 4px; padding: 4px; border-radius: 999px; background: var(--surface-2); width: fit-content; }
.nt-tabs button { position: relative; border: 0; background: none; padding: 0.35rem 1.1rem; border-radius: 999px; font: inherit; font-weight: 600; font-size: 0.9rem; color: var(--muted); cursor: pointer; }
.nt-tabs button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-soft); }
.nt-tabs button.has::after { content: ""; position: absolute; top: 6px; right: 7px; width: 6px; height: 6px; border-radius: 50%; background: var(--signal); }
.nt-text { display: block; width: 100%; min-height: 140px; resize: vertical; padding: 10px 14px; font: inherit; font-size: 1rem; line-height: 28px; color: #1f2a33; border: 1px solid var(--line); border-radius: 12px;
  background-color: var(--nt-paper); background-image: linear-gradient(to bottom, transparent 27px, var(--nt-rule) 27px); background-size: 100% 28px; background-position: 0 9px; background-attachment: local; }
.nt-text::placeholder { color: #7b8a95; }
.nt-text:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; }
#nt-draw { display: grid; gap: 10px; }
#nt-draw[hidden] { display: none; }
.nt-pad { position: relative; width: 100%; max-width: 100%; aspect-ratio: 3 / 2; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; touch-action: none;
  background-color: var(--nt-paper); background-image: linear-gradient(to right, transparent 46px, var(--nt-margin) 46px, var(--nt-margin) 47px, transparent 47px), linear-gradient(to bottom, transparent calc(100% - 1px), var(--nt-rule) calc(100% - 1px));
  background-size: 100% 100%, 100% 6.25%; }
.nt-pad .ink-top { pointer-events: auto; cursor: crosshair; }
.nt-padhint { margin: 0; }

.voice { border-top: 1px solid var(--line); padding-top: 14px; display: grid; gap: 10px; }
.voice-head h3 { margin: 0; display: flex; align-items: center; gap: 8px; font-size: 1rem; }
.voice-head .icon { width: 18px; height: 18px; color: var(--brand); }
.vn-rec { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; }
.vn-btn { display: inline-flex; align-items: center; gap: 8px; }
.vn-dot { width: 10px; height: 10px; border-radius: 50%; background: currentColor; }
.vn-btn.is-rec { background: var(--bad); color: #fff; }
.vn-btn.is-rec .vn-dot { border-radius: 2px; animation: vn-pulse 1.2s ease-in-out infinite; }
@keyframes vn-pulse { 50% { opacity: 0.35; } }
.vn-time { font-variant-numeric: tabular-nums; font-weight: 700; }
.vn-level { width: 120px; height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.vn-level[hidden] { display: none; }
.vn-level > span { display: block; height: 100%; width: 0; background: var(--bad); transition: width 0.1s linear; }
.vn-blocked { padding: 12px 14px; border-radius: 12px; background: var(--brand-soft); box-shadow: inset 0 0 0 1px var(--brand-ring); display: grid; gap: 10px; }
.vn-blocked[hidden] { display: none; }
.vn-blocked p { margin: 0; }
.vn-attach { display: inline-flex; align-items: center; gap: 8px; width: fit-content; cursor: pointer; }
.vn-attach .icon { width: 18px; height: 18px; }
.vn-attach:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }
.vn-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.vn-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 6px 12px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); }
.vn-meta { display: grid; min-width: 0; }
.vn-item audio { grid-column: 1 / -1; width: 100%; height: 38px; }
.vn-del { min-width: 34px; height: 34px; display: grid; place-items: center; border: 0; border-radius: 10px; background: var(--surface); color: var(--muted); font: inherit; font-size: 0.82rem; font-weight: 600; cursor: pointer; padding: 0 8px; }
.vn-del .icon { width: 17px; height: 17px; }
.vn-del:hover { color: var(--bad); }
.vn-del.armed { background: var(--bad); color: #fff; }
.vn-empty { padding: 4px 0; }

.thumb.has-notes::before { content: ""; position: absolute; z-index: 1; left: 6px; top: 6px; width: 11px; height: 11px; border-radius: 50%; background: var(--signal); box-shadow: 0 0 0 2px var(--surface); }
@media (max-width: 600px) { .ink-sep { display: none; } .notes-panel { padding: 14px; } }
@media (prefers-reduced-motion: reduce) { .vn-btn.is-rec .vn-dot { animation: none; } .vn-level > span { transition: none; } }

/* ---------- 3D simulations of the case studies (js/views-case3d.js) ---------- */
.case-sim-bar { margin: 0 0 12px; }
.case-sim-btn .icon { width: 18px; height: 18px; }
.case-sim { margin: 0 0 16px; }
.c3d { display: grid; gap: 12px; }
.c3d-stage { height: clamp(360px, 60vh, 560px); }
.c3d-read {
  position: absolute; left: 12px; top: 12px; max-width: min(320px, calc(100% - 24px)); padding: 10px 12px; border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--surface) 92%, transparent); color: var(--ink); box-shadow: var(--shadow-soft); font-size: 0.8rem; pointer-events: none;
}
.c3d-read dl { margin: 0; display: grid; gap: 3px; }
.c3d-read dl div { display: flex; justify-content: space-between; gap: 12px; }
.c3d-read dt { color: var(--muted); }
.c3d-read dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }
.c3d-status { margin-bottom: 7px; padding: 4px 9px; border-radius: 8px; font-weight: 700; line-height: 1.35; }
.c3d-status.is-ok { background: var(--ok-soft); color: var(--ok); box-shadow: inset 0 0 0 1px var(--ok-ring); }
.c3d-status.is-warn { background: color-mix(in srgb, var(--signal) 18%, var(--surface)); color: var(--ink); box-shadow: inset 0 0 0 1px var(--signal); }
.c3d-status.is-bad { background: var(--bad-soft); color: var(--bad); box-shadow: inset 0 0 0 1px var(--bad-ring); }
.c3d-controls { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px 18px; padding: 14px 16px; border-radius: var(--radius-sm); background: var(--surface-2); }
.c3d-ctl { min-width: 0; display: grid; gap: 6px; }
.c3d-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.c3d-lab { font-size: 0.85rem; font-weight: 600; }
.c3d-range output { white-space: nowrap; color: var(--brand-strong); font-size: 0.85rem; font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }
.c3d-range input[type="range"] { flex: 1; min-width: 0; }
.c3d-go { flex: none; width: 34px; height: 34px; border: 0; border-radius: 50%; background: var(--brand); color: var(--brand-ink); font-size: 0.8rem; cursor: pointer; }
.c3d-go:hover { background: var(--brand-strong); }
.c3d-toggle { display: flex; align-items: center; gap: 10px; font-size: 0.88rem; font-weight: 600; cursor: pointer; align-self: center; }
.c3d-toggle input { width: 20px; height: 20px; accent-color: var(--brand); flex: none; }
.c3d-seg { display: flex; flex-wrap: wrap; gap: 6px; }
.c3d-seg button { flex: 1 1 auto; min-height: 36px; padding: 0.35rem 0.75rem; border: 0; border-radius: 10px; cursor: pointer; font: inherit; font-size: 0.82rem; font-weight: 600; background: var(--surface); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }
.c3d-seg button[aria-pressed="true"] { background: var(--brand); color: var(--brand-ink); box-shadow: none; }
.c3d-go:focus-visible, .c3d-seg button:focus-visible, .c3d-toggle input:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.c3d-note { margin: 0; max-width: 90ch; }
.c3d-load, .c3d-fail { padding: 18px; border-radius: var(--radius-sm); background: var(--surface-2); }
@media (max-width: 640px) {
  .c3d-stage { height: 420px; }
  .c3d-read { font-size: 0.72rem; padding: 8px 10px; max-width: calc(100% - 24px); }
  .c3d-read dl div:nth-child(n+4) { display: none; }
}
/* 3D stage, on-site version: place caption, view buttons, hint at the bottom right */
.c3d-place {
  position: absolute; right: 12px; top: 12px; max-width: min(46%, 360px); padding: 6px 12px; border-radius: 999px;
  background: rgb(10 25 35 / 0.62); color: #fff; font-size: 0.78rem; font-weight: 600; line-height: 1.35; pointer-events: none;
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.c3d-hint { top: auto; bottom: 12px; right: 12px; }
.c3d-tools { right: 12px; flex-wrap: wrap; pointer-events: none; }
.c3d-tools > *, .c3d-views > * { pointer-events: auto; }
.c3d-views { display: contents; }
.c3d-views .dio-tool[aria-pressed="true"] { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
@media (max-width: 640px) {
  .c3d-place { top: auto; bottom: 58px; right: 12px; left: 12px; max-width: none; text-align: center; border-radius: 12px; }
  .c3d-hint { display: none; }
  .c3d-tools .dio-tool { padding: 8px 11px; font-size: 12.5px; }
}
/* case studies: the solution we would choose */
.case-best { padding: 14px 16px; border-radius: var(--radius-sm); background: var(--brand-soft); box-shadow: inset 0 0 0 1px var(--brand-ring); }
.case-best h3 { flex-wrap: wrap; }
.case-best-ar { color: var(--teal-strong); font-family: var(--font-arabic); font-size: 0.9rem; font-weight: 600; }
.case-best ol { margin: 8px 0 10px; padding-left: 1.3em; display: grid; gap: 6px; max-width: 75ch; line-height: 1.6; }
.case-best-num { padding: 10px 12px; border-radius: 10px; background: var(--surface); font-size: 0.92rem; }
/* case studies: the linked lesson and the laws behind each case */
.case-lesson {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; margin: 0 0 12px; padding: 12px 14px;
  border-radius: var(--radius-sm); background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line);
}
.case-lesson-txt { display: grid; gap: 2px; min-width: 0; }
.case-lesson-k { color: var(--teal-strong); font-size: 0.72rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.case-lesson-k span { margin-left: 6px; font-family: var(--font-arabic); letter-spacing: 0; text-transform: none; }
.case-lesson-txt strong { font-size: 0.95rem; }
.case-lesson-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.btn-sm { min-height: 34px; padding: 0.35rem 0.8rem; font-size: 0.8rem; }
.case-laws { padding: 14px 16px; border-radius: var(--radius-sm); background: var(--surface); box-shadow: inset 0 0 0 1px var(--brand-ring); }
.case-law-list { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 12px; }
.case-law { display: grid; gap: 8px; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--surface-2); min-width: 0; }
.case-law-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.case-law-head h4 { margin: 0; font-size: 0.98rem; }
.case-law-tex { overflow-x: auto; padding: 4px 0; font-size: 1.05rem; }
.case-law-tex .katex-display { margin: 0.2em 0; }
.case-law-tex.is-idea { color: var(--muted); font-size: 0.82rem; font-style: italic; }
.case-law p { margin: 0; }
.case-law-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.case-law-lab { margin: 10px 0 0; font-size: 0.9rem; }
@media (max-width: 640px) { .case-lesson-btns { width: 100%; } .case-lesson-btns .btn { flex: 1; } }
/* links from the lessons to the case studies (js/views-case-links.js) */
.case-links { margin: 14px 0; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--grad-soft); box-shadow: inset 0 0 0 1px var(--brand-ring); }
.case-links h3 { margin: 0 0 10px; font-size: 0.92rem; }
.case-links h3 span { margin-left: 6px; color: var(--teal-strong); font-family: var(--font-arabic); font-weight: 600; }
.case-link-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.case-link-card { display: grid; gap: 3px; min-width: 0; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); text-decoration: none; box-shadow: inset 0 0 0 1px var(--line); transition: box-shadow 0.15s, transform 0.12s; }
.case-link-card:hover { box-shadow: inset 0 0 0 1px var(--brand), var(--shadow-soft); transform: translateY(-1px); }
.case-link-card:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.case-link-k { color: var(--teal-strong); font-size: 0.7rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.case-link-card strong { font-size: 0.92rem; line-height: 1.3; }
.case-link-meta { color: var(--muted); font-size: 0.78rem; }
.case-link-law { color: var(--brand-strong); font-size: 0.78rem; font-weight: 600; }
.case-chip { background: var(--grad-soft); }
.case-side { margin-bottom: 8px; }
.case-laws.is-arrived { animation: case-arrive 1.6s ease-out; }
@keyframes case-arrive { 0% { box-shadow: inset 0 0 0 3px var(--brand); } 100% { box-shadow: inset 0 0 0 1px var(--brand-ring); } }
@media (prefers-reduced-motion: reduce) { .case-laws.is-arrived { animation: none; } }
.case-laws { scroll-margin-top: 90px; }
@media (max-width: 1199px) { .case-laws { scroll-margin-top: 130px; } }
/* ---------- Settings (js/views-settings.js): the gear beside the theme button opens a dialog; a bottom sheet on phones ---------- */
.side-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.settings-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; padding: 0; border: 0; border-radius: var(--radius-sm);
  background: rgb(255 255 255 / 0.08); color: #fff; box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.15); cursor: pointer; transition: background-color 0.15s;
}
.settings-btn svg { width: 20px; height: 20px; transition: transform 0.4s; }
.settings-btn:hover { background: rgb(255 255 255 / 0.16); }
.settings-btn:hover svg { transform: rotate(60deg); }
@media (hover: none), (pointer: coarse) { .settings-btn { width: 44px; height: 44px; } }

.settings-dialog {
  width: min(720px, calc(100vw - 32px)); max-height: min(86vh, 760px); padding: 0; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow-lift); overflow: hidden;
}
.settings-dialog[open] { display: flex; flex-direction: column; animation: set-in 0.18s ease-out; }
.settings-dialog::backdrop { background: var(--scrim); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); }
@keyframes set-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.set-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--line); background: var(--grad-head); }
.set-head h2 { margin: 0; font-size: 1.25rem; }
.set-close { display: inline-grid; place-items: center; width: 40px; height: 40px; border: 0; border-radius: 10px; background: transparent; color: var(--ink); cursor: pointer; }
.set-close:hover { background: var(--surface-2); }
.set-close .icon { width: 20px; height: 20px; }
.set-body { padding: 18px 22px 24px; overflow-y: auto; }
.set-sec > p { margin: 0 0 14px; }
.set-title { display: flex; align-items: center; gap: 6px; min-width: 0; }
.set-back {
  display: inline-grid; place-items: center; width: 40px; height: 40px; margin-left: -8px; border: 0; border-radius: 10px;
  background: transparent; color: var(--ink); cursor: pointer;
}
.set-back:hover { background: var(--surface-2); }
.set-back .icon { width: 20px; height: 20px; transform: scaleX(-1); }
/* the first screen: one row per setting, each opening its own screen */
.set-list { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.motion-list { margin: 12px 0; }
.motion-foot { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.set-row {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 14px; width: 100%; padding: 14px 16px;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink);
  font: inherit; text-align: left; cursor: pointer; transition: border-color 0.15s, background-color 0.15s;
}
.set-row:hover { border-color: var(--brand); background: var(--brand-soft); }
.set-row-icon { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; background: var(--brand-soft); color: var(--brand); }
.set-row-icon .icon { width: 22px; height: 22px; }
.set-row-text { display: grid; gap: 2px; min-width: 0; }
.set-row-text strong { font-size: 1rem; }
.set-row-value { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 0.88rem; }
.set-row-value .icon { width: 18px; height: 18px; }
.set-dot { width: 14px; height: 14px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.15); }
.set-row-icon .set-glyph { font-size: 1.05rem; font-weight: 700; line-height: 1; }
/* a setting that is only on or off: the whole row is the switch */
.set-switch { position: relative; flex: none; width: 46px; height: 26px; border-radius: 13px; background: var(--line); transition: background-color 0.15s; }
.set-switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgb(0 0 0 / 0.3); transition: transform 0.15s;
}
.set-row[aria-checked="true"] .set-switch { background: var(--brand); }
.set-row[aria-checked="true"] .set-switch::after { transform: translateX(20px); }
.set-switch-text { min-width: 2em; text-align: right; }
/* text size: three choices and a sample that grows with the choice */
.size-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.size-opt { justify-items: center; text-align: center; padding: 14px 10px; }
.size-aa { font-weight: 700; line-height: 1; color: var(--brand); }
.size-sample { margin-top: 16px; padding: 16px 18px; border-radius: var(--radius-sm); background: var(--surface-2); }
.size-sample h4 { margin: 0 0 6px; font-size: 1.15rem; }
.size-sample p { margin: 0; }
@media (prefers-reduced-motion: reduce) { .set-switch, .set-switch::after { transition: none; } }
/* the three glass styles, shown under the themes while Glass is chosen */
.glass-styles { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.glass-styles h4 { margin: 0 0 10px; font-size: 0.95rem; }
.glass-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.glass-opt { padding: 8px 8px 10px; }
.glass-swatch { height: 46px; border-radius: 8px; box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.08); }

.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.theme-opt {
  position: relative; display: grid; align-content: start; gap: 8px; padding: 10px 10px 12px; border: 2px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink); font: inherit; text-align: left; cursor: pointer; transition: border-color 0.15s, transform 0.15s;
}
.theme-opt:hover { border-color: var(--brand); transform: translateY(-1px); }
.theme-opt[aria-checked="true"] { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-ring); }
.theme-opt strong { font-size: 0.92rem; }
.theme-opt .muted { line-height: 1.35; }
.theme-check {
  position: absolute; top: 16px; right: 16px; display: none; place-items: center; width: 24px; height: 24px; border-radius: 50%;
  background: var(--brand); color: var(--brand-ink); box-shadow: 0 0 0 2px var(--surface);
}
.theme-check .icon { width: 15px; height: 15px; }
.theme-opt[aria-checked="true"] .theme-check { display: grid; }
/* a small picture of the page in the theme's own colours: menu strip, banner, two cards */
.theme-mini { display: grid; grid-template-columns: 26% 1fr; height: 76px; border-radius: 8px; overflow: hidden; box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.08); }
.theme-mini.is-split { grid-template-columns: 1fr 1fr; }
.theme-mini .tm-pane { display: grid; grid-template-columns: 26% 1fr; }
.tm-side { background: var(--tm-side); }
.tm-main { display: grid; grid-template-rows: 22px 1fr; gap: 6px; padding: 7px; background: var(--tm-bg); }
.tm-hero { border-radius: 4px; background: linear-gradient(135deg, var(--tm-brand), var(--tm-accent)); }
.tm-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.tm-cards span { border-radius: 4px; background: var(--tm-surface); box-shadow: inset 0 -5px 0 -2px var(--tm-brand); }
@media (max-width: 600px) {
  .settings-dialog { width: 100vw; max-width: 100vw; max-height: 88vh; margin: auto 0 0; border-radius: var(--radius) var(--radius) 0 0; border-bottom: 0; }
  .set-head, .set-body { padding-left: 16px; padding-right: 16px; }
  .set-body { padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px)); }
  .theme-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .theme-opt .muted { display: none; }
}
@media (prefers-reduced-motion: reduce) { .settings-dialog[open] { animation: none; } .settings-btn svg, .theme-opt { transition: none; } }

/* ---------- Calendar (js/views-calendar.js): coming up, the week ahead or the month with a day panel ---------- */
.cal-page, .dash-next { --cal-exam: var(--bad); --cal-quiz: var(--signal); --cal-assignment: var(--brand); --cal-lab: var(--teal); --cal-task: var(--ok); --cal-other: var(--muted); }
.cal-h2 { margin: 0 0 12px; font-size: 1.1rem; }
.cal-sec { margin-bottom: 18px; }
.is-exam { --cal-c: var(--cal-exam); } .is-quiz { --cal-c: var(--cal-quiz); } .is-assignment { --cal-c: var(--cal-assignment); } .is-lab { --cal-c: var(--cal-lab); } .is-task { --cal-c: var(--cal-task); } .is-other { --cal-c: var(--cal-other); }
.cal-up { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.cal-up-card {
  display: flex; align-items: center; gap: 14px; padding: 14px 16px; border: 1px solid var(--card-line); border-left: 5px solid var(--cal-c);
  border-radius: var(--radius); background: var(--surface); color: var(--ink); box-shadow: var(--shadow-soft); font: inherit; text-align: left; cursor: pointer;
}
.cal-up-card:hover { box-shadow: var(--shadow-lift); }
.cal-up-n { flex: none; min-width: 3.2em; color: var(--cal-c); font-size: 1.6rem; font-weight: 700; line-height: 1; text-align: center; }
.cal-up-n small { display: block; margin-top: 2px; font-size: 0.72rem; font-weight: 600; color: var(--muted); }
.cal-up-text { display: grid; gap: 2px; min-width: 0; }
.cal-up-text strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-up-text span { color: var(--muted); font-size: 0.82rem; }
.cal-up-empty { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px; border: 1.5px dashed var(--line); border-radius: var(--radius); background: var(--surface); }
.cal-up-empty p { margin: 0; max-width: 560px; }
.cal-due-today { margin: 0 0 16px; padding: 10px 14px; border-radius: var(--radius-sm); background: var(--brand-soft); box-shadow: inset 0 0 0 1px var(--brand-ring); }
.cal-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin: 6px 0 16px; }
.cal-nav { display: flex; align-items: center; gap: 10px; }
.cal-arrow { width: 42px; padding: 0; }
.cal-arrow .icon { width: 20px; height: 20px; }
.cal-arrow[data-step="-1"] .icon { transform: scaleX(-1); }
.cal-title { display: grid; justify-items: center; min-width: 190px; text-align: center; }
.cal-title strong { font-size: 1.05rem; }
.cal-actions { display: flex; gap: 8px; }
/* the week: one card per day */
.cal-week { display: grid; gap: 12px; }
.cal-day { padding: 14px 16px 12px; border: 1px solid var(--card-line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-soft); }
.cal-day.is-today { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-ring), var(--shadow-soft); }
.cal-day.is-past { opacity: 0.85; }
.cal-day-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px; margin-bottom: 8px; }
.cal-day-head h3 { margin: 0; font-size: 1rem; }
.cal-rel { margin-left: 6px; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: 0.75rem; font-weight: 600; vertical-align: middle; }
.cal-day.is-today .cal-rel { background: var(--brand); color: var(--brand-ink); }
.cal-hijri { color: var(--muted); font-size: 0.78rem; }
.cal-items { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.cal-li { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.cal-empty { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; margin: 0; }
.cal-empty .cal-add-here { margin-top: 0; }
.cal-up-n.is-word { min-width: 4.6em; font-size: 1rem; }
.cal-note { flex-basis: 100%; margin: 0 0 0 4px; color: var(--muted); font-size: 0.85rem; }
.cal-ev {
  display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; max-width: 100%; padding: 6px 10px; border: 0; border-radius: 10px;
  background: color-mix(in srgb, var(--cal-c) 14%, transparent); box-shadow: inset 3px 0 0 var(--cal-c); color: var(--ink); font: inherit; font-size: 0.9rem; text-align: left; cursor: pointer;
}
.cal-ev:hover { background: color-mix(in srgb, var(--cal-c) 22%, transparent); }
.cal-ev-type { color: var(--cal-c); font-size: 0.72rem; font-weight: 700; letter-spacing: 0.03em; text-transform: uppercase; }
.cal-ev-time, .cal-ev-when { color: var(--muted); font-size: 0.8rem; }
.link-btn { padding: 2px 0; border: 0; background: none; color: var(--brand); font: inherit; font-size: 0.85rem; font-weight: 600; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.cal-add-here { margin-top: 8px; color: var(--muted); font-weight: 500; text-decoration: none; }
.cal-add-here:hover { color: var(--brand); text-decoration: underline; }
.cal-task { padding: 8px 10px; border-radius: 10px; background: var(--surface-2); }
.cal-task input { width: 18px; height: 18px; margin: 0; accent-color: var(--brand); flex: none; }
.cal-task label { flex: 1 1 220px; cursor: pointer; }
.cal-task.is-done label { color: var(--muted); text-decoration: line-through; }
.cal-links { display: inline-flex; flex-wrap: wrap; gap: 4px 12px; font-size: 0.82rem; }
.cal-rev .cal-rev-n { display: inline-grid; place-items: center; min-width: 26px; height: 26px; padding: 0 6px; border-radius: 13px; background: var(--brand); color: var(--brand-ink); font-size: 0.8rem; font-weight: 700; }
.btn-sm { min-height: 32px; padding: 0.3rem 0.75rem; font-size: 0.8rem; }
.cal-min { color: var(--muted); font-size: 0.85rem; }
.cal-min-bar { width: 28px; height: 8px; border-radius: 4px; background: color-mix(in srgb, var(--teal) calc(var(--lvl) * 22%), var(--surface-2)); }
/* the month: a grid of days and the chosen day beside it */
.cal-month { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
.cal-grid-wrap { padding: 12px; border: 1px solid var(--card-line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-soft); }
.cal-wd, .cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.cal-wd span { padding: 2px 0 6px; color: var(--muted); font-size: 0.75rem; font-weight: 600; text-align: center; }
.cal-cell {
  position: relative; display: grid; grid-template-rows: auto 1fr auto; align-content: start; gap: 2px; min-height: 86px; padding: 6px; border: 1px solid var(--line);
  border-radius: 10px; background: var(--surface); color: var(--ink); font: inherit; text-align: left; cursor: pointer; overflow: hidden;
}
.cal-cell[data-lvl="1"], .cal-sw[data-lvl="1"] { background: color-mix(in srgb, var(--teal) 10%, var(--surface)); }
.cal-cell[data-lvl="2"], .cal-sw[data-lvl="2"] { background: color-mix(in srgb, var(--teal) 20%, var(--surface)); }
.cal-cell[data-lvl="3"], .cal-sw[data-lvl="3"] { background: color-mix(in srgb, var(--teal) 32%, var(--surface)); }
.cal-cell[data-lvl="4"], .cal-sw[data-lvl="4"] { background: color-mix(in srgb, var(--teal) 46%, var(--surface)); }
.cal-cell:hover { border-color: var(--brand); }
.cal-cell.is-out { opacity: 0.45; }
.cal-cell.is-today .cal-num { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--brand); color: var(--brand-ink); }
.cal-cell.is-sel { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand); }
.cal-num { font-size: 0.9rem; font-weight: 700; line-height: 26px; }
.cal-hd { position: absolute; top: 8px; right: 8px; color: var(--muted); font-size: 0.68rem; }
.cal-marks { display: grid; gap: 2px; align-content: start; min-width: 0; }
.cal-pill { overflow: hidden; padding: 1px 5px; border-radius: 5px; background: color-mix(in srgb, var(--cal-c) 18%, transparent); box-shadow: inset 2px 0 0 var(--cal-c); font-size: 0.68rem; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.cal-more { color: var(--muted); font-size: 0.68rem; }
.cal-flags { display: flex; align-items: center; gap: 4px; min-height: 16px; }
.cal-flag.is-plan { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--brand); }
.cal-flag.is-rev { display: inline-grid; place-items: center; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--signal); color: var(--signal-ink); font-size: 0.62rem; font-weight: 700; }
.cal-legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 10px 2px 0; }
.cal-key { display: inline-flex; align-items: center; gap: 6px; }
.cal-sw { display: inline-block; width: 16px; height: 12px; border-radius: 3px; border: 1px solid var(--line); }
.cal-detail { position: sticky; top: 24px; }
.cal-day.is-panel { min-height: 160px; }
/* the date and plan dialogs (they share the Settings dialog look) */
.cal-dialog { width: min(560px, calc(100vw - 32px)); }
/* repeating dates and the student's own tasks */
.cal-rep { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-size: 0.78rem; }
.cal-own { box-shadow: inset 3px 0 0 var(--cal-task); }
.cal-own .cal-edit { margin-left: auto; font-size: 0.8rem; font-weight: 500; }
.cal-own .cal-note { margin-left: 28px; }
.cal-series-note { margin: 0; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--brand-soft); box-shadow: inset 0 0 0 1px var(--brand-ring); }
.cal-wdays { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; border: 0; }
.cal-wdays[hidden], .cal-form .field[hidden] { display: none; }
.cal-wdays legend { width: 100%; margin-bottom: 4px; padding: 0; font-size: 0.9rem; }
.cal-wd-opt input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.cal-wd-opt span { display: inline-grid; place-items: center; min-width: 48px; min-height: 36px; padding: 0 8px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); font-size: 0.85rem; font-weight: 600; cursor: pointer; }
.cal-wd-opt input:checked + span { border-color: var(--brand); background: var(--brand); color: var(--brand-ink); }
.cal-wd-opt input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }
/* editing a study plan: move a task, keep a day free, add a task, choose the order */
.cal-move { font-size: 0.82rem; }
.cal-carried { flex-basis: 100%; margin: 0 0 0 28px; color: var(--muted); font-style: italic; }
.cal-plan-tools { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 16px; margin-top: 10px; padding-top: 8px; border-top: 1px dashed var(--line); }
.cal-plan-tools .link-btn { font-size: 0.82rem; font-weight: 500; }
.cal-skipped { color: var(--muted); font-size: 0.85rem; }
.cal-order { display: grid; gap: 4px; }
.cal-order-h { margin: 0; font-size: 0.95rem; }
.cal-order-list { display: grid; gap: 4px; margin: 4px 0 0; padding: 0 0 0 1.4em; }
.cal-order-list li { padding: 2px 0; }
.cal-order-list li::marker { color: var(--muted); font-weight: 600; }
.cal-order-list li:not(.muted) { display: list-item; }
.cal-order-list li > .cal-order-name { display: inline-block; width: calc(100% - 84px); vertical-align: middle; font-size: 0.9rem; }
.cal-order-btns { display: inline-flex; gap: 4px; vertical-align: middle; }
.cal-order-btns .dp-nav { width: 36px; height: 32px; border: 1px solid var(--line); font-weight: 700; }
.cal-order-btns .dp-nav:disabled { opacity: 0.35; cursor: default; }
/* the English date and time pickers in the date dialog */
.dp { position: relative; }
.dp-label { font-size: 0.9rem; }
.dp-btn {
  display: flex; align-items: center; gap: 8px; width: 100%; min-height: 42px; padding: 0.5rem 0.75rem; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink); font: inherit; font-size: max(16px, 1rem); text-align: left; cursor: pointer;
}
.dp-btn .icon { flex: none; width: 18px; height: 18px; color: var(--muted); }
.dp-btn:hover, .dp-btn[aria-expanded="true"] { border-color: var(--brand); }
.dp-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dp-pop {
  position: absolute; z-index: 5; top: calc(100% + 6px); left: 0; width: min(290px, calc(100vw - 40px)); padding: 10px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-lift);
}
.cal-rep-row .dp-pop { left: auto; right: 0; }
:root[data-theme^="glass"] .dp-pop { background: var(--bg); }
.dp-head { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-bottom: 6px; }
.dp-nav { display: inline-grid; place-items: center; width: 34px; height: 34px; border: 0; border-radius: 8px; background: transparent; color: var(--ink); cursor: pointer; }
.dp-nav:hover { background: var(--surface-2); }
.dp-nav .icon { width: 18px; height: 18px; }
.dp-nav[data-m="-1"] .icon { transform: scaleX(-1); }
.dp-wd, .dp-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.dp-wd span { color: var(--muted); font-size: 0.72rem; font-weight: 600; text-align: center; }
.dp-day { height: 34px; border: 0; border-radius: 8px; background: transparent; color: var(--ink); font: inherit; font-size: 0.88rem; cursor: pointer; }
.dp-day:hover { background: var(--surface-2); }
.dp-day.is-out { color: var(--muted); opacity: 0.6; }
.dp-day.is-today { box-shadow: inset 0 0 0 1.5px var(--brand); font-weight: 700; }
.dp-day.is-sel { background: var(--brand); color: var(--brand-ink); font-weight: 700; }
.dp-day:disabled, .dp-foot .link-btn:disabled { opacity: 0.3; cursor: default; background: none; text-decoration: line-through; }
.dp-foot .link-btn:disabled { text-decoration: none; }
.dp-foot { display: flex; justify-content: space-between; gap: 10px; margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--line); }
.tp-row { display: flex; align-items: center; gap: 4px; }
.cal-form .tp-row select { flex: 1 1 0; min-width: 0; padding: 0.5rem 0.15rem 0.5rem 0.45rem; }
.tp-row select:disabled { opacity: 0.5; }
.tp-colon { font-weight: 700; }
.cal-del-group { display: inline-flex; flex-wrap: wrap; gap: 8px; margin-left: auto; }
.cal-del-group .cal-del { margin-left: 0; }
.cal-flag.is-todo { display: inline-grid; place-items: center; height: 16px; padding: 0 5px; border-radius: 8px; background: color-mix(in srgb, var(--cal-task, var(--ok)) 18%, transparent); color: var(--ink); font-size: 0.62rem; font-weight: 700; }
.cal-flag.is-todo.is-all { background: var(--ok); color: #fff; }
.cal-form { display: grid; gap: 12px; }
.cal-form .field { display: grid; gap: 4px; }
.cal-form input:not([type="checkbox"]), .cal-form select, .cal-form textarea {
  width: 100%; min-height: 42px; padding: 0.5rem 0.75rem; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink); font: inherit; font-size: max(16px, 1rem);
}
.cal-form textarea { resize: vertical; }
.cal-form-row { display: grid; grid-template-columns: 1fr 1.3fr 1.3fr; gap: 10px; }
.cal-form-row.cal-rep-row { grid-template-columns: 1fr 1fr; }
.cal-form .error:empty { display: none; }
.cal-form-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.cal-del { margin-left: auto; color: var(--bad); }
.cal-chs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; margin: 0; padding: 10px 12px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.cal-chs legend { padding: 0 6px; font-weight: 700; font-size: 0.9rem; }
.cal-ch { display: flex; align-items: flex-start; gap: 8px; font-size: 0.88rem; cursor: pointer; }
.cal-ch input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--brand); flex: none; }
.cal-ch b { color: var(--brand); }
.cal-plan-sum { margin: 0; }
/* the next date on the dashboard */
.dash-next { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin: 0 0 16px; padding: 12px 16px; border: 1px solid var(--card-line); border-left: 5px solid var(--cal-c, var(--brand)); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-soft); color: var(--ink); text-decoration: none; }
.dash-next strong { font-size: 1.05rem; }
.dash-next .dash-next-n { color: var(--cal-c, var(--brand)); font-weight: 700; }
.dash-next:hover { box-shadow: var(--shadow-lift); }
@media (max-width: 959px) {
  .cal-month { grid-template-columns: 1fr; }
  .cal-detail { position: static; }
}
@media (max-width: 600px) {
  .cal-bar { justify-content: center; }
  .cal-nav { order: -1; width: 100%; justify-content: space-between; }
  .cal-title { min-width: 0; }
  .cal-grid-wrap { padding: 8px; }
  .cal-wd, .cal-grid { gap: 3px; }
  .cal-cell { min-height: 58px; padding: 4px; border-radius: 8px; }
  .cal-hd { display: none; }
  .cal-pill { width: 8px; height: 8px; padding: 0; border-radius: 50%; background: var(--cal-c); box-shadow: none; font-size: 0; }
  .cal-marks { display: flex; flex-wrap: wrap; gap: 3px; }
  .cal-form-row { grid-template-columns: 1fr 1fr; }
  .cal-form-row .field:first-child { grid-column: 1 / -1; }
  .cal-chs { grid-template-columns: 1fr; }
  .cal-dialog { width: 100vw; }
  .cal-rep-row .dp-pop { left: 0; right: auto; }
  .cal-form-row .tp { grid-column: 1 / -1; }
}

.exp-video { display: block; width: 100%; max-width: 960px; aspect-ratio: 16 / 9; border-radius: var(--radius); background: #000; }

.exp-vctl{display:flex;flex-wrap:wrap;gap:.6rem;align-items:center;margin-top:.6rem}.exp-vctl label{display:flex;gap:.4rem;align-items:center;font-size:.9rem}.exp-vctl select{font:inherit;padding:.3rem .5rem;border-radius:8px;border:1px solid var(--line,#8886);background:var(--surface,transparent);color:inherit}

/* ---------- study assistant (js/views-ask.js) ---------- */
.ask-fab {
  position: fixed; z-index: 58;
  right: calc(86px + env(safe-area-inset-right, 0px)); bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  width: 54px; height: 54px; display: grid; place-items: center; border: 0; border-radius: 50%; cursor: pointer;
  background: var(--surface); color: var(--brand-strong); box-shadow: var(--shadow-lift), inset 0 0 0 2px var(--brand-ring); transition: transform 0.15s;
}
.ask-fab svg { width: 26px; height: 26px; }
.ask-fab:hover { transform: translateY(-2px); }
.ask-fab.is-open { transform: scale(0.92); }
.ask-fab:focus-visible, .ask-x:focus-visible, .ask-link:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.ask-panel {
  position: fixed; z-index: 59;
  right: calc(20px + env(safe-area-inset-right, 0px)); bottom: calc(86px + env(safe-area-inset-bottom, 0px));
  width: 380px; max-width: calc(100vw - 32px); height: min(560px, calc(100dvh - 120px));
  display: flex; flex-direction: column; gap: 10px; padding: 14px;
  background: var(--surface); color: var(--ink); border: 1px solid var(--card-line); border-radius: var(--radius); box-shadow: var(--shadow-lift);
}
.ask-panel[hidden] { display: none; }
.ask-head { display: flex; align-items: center; gap: 10px; }
.ask-head strong { font-size: 0.95rem; }
.ask-mode { padding: 0.1rem 0.55rem; border-radius: 999px; background: var(--brand-soft); color: var(--brand-strong); font-size: 0.72rem; font-weight: 600; box-shadow: inset 0 0 0 1px var(--brand-ring); }
.ask-x { margin-left: auto; width: 34px; height: 34px; display: grid; place-items: center; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--muted); cursor: pointer; }
.ask-x:hover { background: var(--surface-2); color: var(--ink); }
.ask-x svg { width: 20px; height: 20px; }
.ask-log { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding-right: 2px; }
.ask-msg { max-width: 92%; padding: 8px 12px; border-radius: 14px; font-size: 0.92rem; line-height: 1.5; overflow-wrap: anywhere; }
.ask-msg p { margin: 0 0 6px; } .ask-msg p:last-child { margin-bottom: 0; }
.ask-msg.is-me { align-self: flex-end; background: var(--brand-soft); color: var(--brand-strong); }
.ask-msg.is-bot { align-self: flex-start; background: var(--surface-2); }
.ask-msg.is-wait { color: var(--muted); }
.ask-term { padding: 6px 0; border-top: 1px solid var(--line); }
.ask-term:first-of-type { border-top: 0; }
.ask-term a { font-size: 0.82rem; }
.ask-ar { color: var(--muted); }
.ask-list { margin: 4px 0 0; padding-left: 18px; }
.ask-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.ask-form { display: flex; gap: 8px; }
.ask-form input { flex: 1; min-width: 0; padding: 8px 12px; border: 1px solid var(--card-line); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); font: inherit; }
.ask-note { margin: 0; font-size: 0.76rem; color: var(--muted); }
.ask-link { border: 0; background: none; padding: 0; color: var(--brand-strong); text-decoration: underline; cursor: pointer; font: inherit; }
@media (max-width: 560px) {
  .ask-panel { right: 12px; left: 12px; width: auto; max-width: none; bottom: calc(86px + env(safe-area-inset-bottom, 0px)); }
}
html.slides-full .ask { display: none !important; }
