/*
  The design tokens of Abukahey: the one token source of every surface (Admin, Web, Kita course, the static sites).
  Only custom properties stand here; base.css holds the element base, theme.css the Tailwind registration and
  fonts.css the faces.

  Three tiers, after the W3C Design Tokens model (primitive → semantic → component):

  1. Primitive: every raw value, named once. Only this tier writes a colour; a brand colour keeps its name
     (`--raw-ocean`), every other colour is named by hue and tone, the OKLCH lightness × 1000 (`--raw-teal-857`), so a
     name tells how light a colour is. A colour seen through is a primitive of its own with its alpha in percent
     (`--raw-white-a28`), written as rgba() or hex, so a gradient that reads it keeps interpolating in sRGB. The
     faces and every single number belong here too: the type, leading, space, size, share, radius, opacity and
     motion scales and the layers. A step a scale does not name is named by its value (`--size-44`, `--text-22`).
     The tiers above write no single literal; only a composite (shadow, gradient, calc()) keeps its own offsets.
  2. Semantic: what a value is for (text, surface, line, control, status). A role reads primitives or other roles,
     never a component token. The roles both tones share stand in `:root`; the two tones are two token sets on the
     same roles, `[data-tone="admin"]` (airy and white, framed by the grey shell) and `[data-tone="product"]`
     (playful colour on tinted surfaces). Each app sets its tone on <html>; both sets declare the same roles.
  3. Component: the tokens of one component family (run shell, activity stage, coach, gamification, course); they
     read roles or primitives.

  Scopes that redraw roles for one part of a page stay with their tier: `[data-theme="dark"]` and `.dark` (semantic),
  `[data-run-tone="dark"]` and `[data-atmosphere]` (component). foundations/tiers.test.ts holds the tiers together.
*/

/* ========================================================================================================
 * TIER 1 · PRIMITIVE
 * ======================================================================================================== */

:root {
  /* Brand colours, the master colours of DESIGN.md#colors, and black. Ground: white, dark and blue; Pop: six full
     surfaces with dark text; helpers: deep blue, red, the muted text and the one line. */
  --raw-white: #FFFFFF;
  --raw-black: #000000;
  --raw-earth: #272321;
  --raw-ocean: #0776A9;       /* 5.03:1 on white */
  --raw-ocean-deep: #05618C;  /* 6.79:1 on white */
  --raw-jungle: #14B8A6;
  --raw-sun: #FACC15;
  --raw-tiger: #F97316;
  --raw-sky: #38BDF8;
  --raw-berry: #F15BA6;
  --raw-purple: #B57CF6;
  --raw-red: #C53D43;
  --raw-muted: #5F686E;       /* 5.66:1 on white */
  --raw-line: #E1E9ED;
  --raw-stone: #334155;
  --raw-soft: #94A3B8;

  /* Every other colour, by hue and tone (OKLCH lightness × 1000), light to dark. */
  --raw-grey-993: #FFFDF5;
  --raw-grey-985: #FAFAF9;
  --raw-grey-979: #F7F8F9;
  --raw-grey-970: #F1F6F9;
  --raw-grey-962: #F0F3F5;
  --raw-grey-959: #EEF2F4;
  --raw-grey-928: #E5E7EB;
  --raw-grey-922: #E5E5E5;
  --raw-grey-869: #D6D3D1;
  --raw-grey-858: #D0D0D0;
  --raw-grey-783: #B8B8B8;
  --raw-grey-683: #999999;
  --raw-grey-444: #57534E;
  --raw-grey-275: #25282B;

  --raw-rose-715: #E878AD;

  --raw-red-885: #FECACA;
  --raw-red-808: #FCA5A5;
  --raw-red-712: #FF6B6B;
  --raw-red-444: #991B1B;

  --raw-orange-922: #FCDFCB;
  --raw-orange-762: #FF922B;
  --raw-orange-727: #EE8A2E;
  --raw-orange-666: #D97706;
  --raw-orange-646: #EA580C;
  --raw-orange-555: #B45309;
  --raw-orange-408: #7C2D12;
  --raw-orange-315: #3F2D22;
  --raw-orange-283: #3A2410;

  --raw-amber-980: #FFF7ED;
  --raw-amber-769: #F59E0B;
  --raw-amber-717: #E58C05;
  --raw-amber-461: #6D532F;

  --raw-yellow-986: #FEFBEA;
  --raw-yellow-982: #FFF9E6;
  --raw-yellow-974: #FDF6E3;
  --raw-yellow-973: #FEF9C3;
  --raw-yellow-966: #FFF4CC;
  --raw-yellow-962: #FEF3C7;
  --raw-yellow-958: #FFF3B0;
  --raw-yellow-957: #FDF0CF;
  --raw-yellow-940: #FDEBAE;
  --raw-yellow-916: #FFE27A;
  --raw-yellow-906: #F0DFB0;
  --raw-yellow-854: #F7C948;
  --raw-yellow-837: #FBBF24;
  --raw-yellow-767: #D4AF37;

  --raw-lime-807: #94D82D;

  --raw-green-820: #5CE65C;
  --raw-green-569: #2E8B57;
  --raw-green-488: #476B3D;
  --raw-green-373: #2C4A1A;

  --raw-teal-921: #CDEDE7;
  --raw-teal-910: #99F6E4;
  --raw-teal-855: #5EEAD4;
  --raw-teal-791: #5AD2C1;
  --raw-teal-779: #56CEBE;
  --raw-teal-744: #20C997;
  --raw-teal-620: #079B8E;
  --raw-teal-600: #0D9488;
  --raw-teal-596: #0E9384;
  --raw-teal-510: #01766F;
  --raw-teal-400: #07534E;
  --raw-teal-386: #134E4A;
  --raw-teal-349: #06443F;

  --raw-cyan-917: #A5F3FC;
  --raw-cyan-865: #67E8F9;
  --raw-cyan-715: #06B6D4;
  --raw-cyan-609: #0891B2;

  --raw-sky-970: #EDF7FC;
  --raw-sky-935: #D6EEFB;
  --raw-sky-889: #CFDDE5;
  --raw-sky-861: #C9D3D9;
  --raw-sky-754: #75B9DD;
  --raw-sky-721: #9AA7B0;
  --raw-sky-685: #0EA5E9;
  --raw-sky-625: #5F8FA8;
  --raw-sky-450: #155E75;
  --raw-sky-398: #164E63;
  --raw-sky-391: #0C4A6E;
  --raw-sky-345: #0B3D5C;
  --raw-sky-312: #143449;
  --raw-sky-219: #0C1C28;

  --raw-blue-970: #EFF6FF;
  --raw-blue-714: #60A5FA;
  --raw-blue-669: #339AF0;
  --raw-blue-623: #7E8896;
  --raw-blue-554: #64748B;
  --raw-blue-551: #6B7280;
  --raw-blue-546: #2563EB;

  --raw-indigo-919: #E0E2FB;
  --raw-indigo-870: #C7D2FE;
  --raw-indigo-785: #A5B4FC;
  --raw-indigo-680: #818CF8;
  --raw-indigo-585: #6366F1;
  --raw-indigo-359: #312E81;
  --raw-indigo-257: #1E1B4B;
  --raw-indigo-231: #1A1C29;
  --raw-indigo-180: #0F111A;

  --raw-violet-912: #E4DDFB;
  --raw-violet-812: oklab(81.1% 0.041 -0.093);
  --raw-violet-811: #C4B5FD;
  --raw-violet-780: #B9B2D4;
  --raw-violet-725: #A99FC8;
  --raw-violet-658: #9775FA;
  --raw-violet-607: oklab(60.6% 0.085 -0.202);
  --raw-violet-606: #8B5CF6;
  --raw-violet-603: #845EF7;
  --raw-violet-541: #7C3AED;
  --raw-violet-300: #2D2A43;
  --raw-violet-283: #2E1065;
  --raw-violet-239: oklab(23.9% 0.04 -0.086);
  --raw-violet-189: oklab(18.9% 0.03 -0.062);
  --raw-violet-154: oklab(15.4% 0.022 -0.049);

  --raw-purple-977: #FAF5FF;
  --raw-purple-722: #C084FC;
  --raw-purple-558: #9333EA;
  --raw-purple-477: #6F3FA6;
  --raw-purple-453: #6E2FA4;
  --raw-purple-357: oklab(35.7% 0.071 -0.12);

  /* Colours seen through: each one with its alpha in percent, as written where it is used. */
  --raw-white-a98: rgba(255, 255, 255, 0.98);
  --raw-white-a96: rgba(255, 255, 255, 0.96);
  --raw-white-a95: rgba(255, 255, 255, 0.95);
  --raw-white-a88: rgba(255, 255, 255, 0.88);
  --raw-white-a82: rgba(255, 255, 255, 0.82);
  --raw-white-a80: rgba(255, 255, 255, 0.80);
  --raw-white-a72: rgba(255, 255, 255, 0.72);
  --raw-white-a70: rgba(255, 255, 255, 0.7);
  --raw-white-a60: rgba(255, 255, 255, 0.60);
  --raw-white-a55: rgba(255, 255, 255, 0.55);
  --raw-white-a50: rgba(255, 255, 255, 0.5);
  --raw-white-a45: rgba(255, 255, 255, 0.45);
  --raw-white-a40: rgba(255, 255, 255, 0.4);
  --raw-white-a30: rgba(255, 255, 255, 0.3);
  --raw-white-a28: rgba(255, 255, 255, 0.28);
  --raw-white-a20: rgba(255, 255, 255, 0.2);
  --raw-white-a18: rgba(255, 255, 255, 0.18);
  --raw-white-a15: rgba(255, 255, 255, 0.15);
  --raw-white-a12: rgba(255, 255, 255, 0.12);
  --raw-white-a10: rgba(255, 255, 255, 0.1);
  --raw-white-a8: rgba(255, 255, 255, 0.08);
  --raw-white-a5: rgba(255, 255, 255, 0.05);

  --raw-black-a50: rgba(0, 0, 0, 0.5);
  --raw-black-a30: rgba(0, 0, 0, 0.3);
  --raw-black-a22: #00000038;
  --raw-black-a20: rgba(0, 0, 0, 0.2);

  --raw-earth-a15: rgba(39, 35, 33, 0.15);
  --raw-earth-a12: rgba(39, 35, 33, 0.12);
  --raw-earth-a8: rgba(39, 35, 33, 0.08);

  --raw-ocean-a70: rgba(7, 118, 169, 0.7);
  --raw-ocean-a25: rgba(7, 118, 169, 0.25);

  --raw-jungle-a34: rgba(20, 184, 166, 0.34);
  --raw-jungle-a30: rgba(20, 184, 166, 0.30);
  --raw-jungle-a26: rgba(20, 184, 166, 0.26);
  --raw-jungle-a16: rgba(20, 184, 166, 0.16);

  --raw-sun-a35: rgba(250, 204, 21, 0.35);

  --raw-tiger-a34: rgba(249, 115, 22, 0.34);
  --raw-tiger-a26: rgba(249, 115, 22, 0.26);
  --raw-tiger-a16: rgba(249, 115, 22, 0.16);

  --raw-grey-984-a84: rgba(248, 250, 252, 0.84);

  --raw-red-808-a30: rgba(252, 165, 165, 0.30);
  --raw-red-808-a25: rgba(252, 165, 165, 0.25);

  --raw-orange-970-a95: rgba(255, 242, 238, 0.95);
  --raw-orange-758-a36: rgba(251, 146, 60, 0.36);

  --raw-amber-980-a94: rgba(255, 247, 237, 0.94);
  --raw-amber-954-a98: rgba(255, 237, 213, 0.98);
  --raw-amber-954-a94: rgba(255, 237, 213, 0.94);
  --raw-amber-954-a76: rgba(255, 237, 213, 0.76);
  --raw-amber-769-a35: rgba(245, 158, 11, 0.35);
  --raw-amber-769-a34: rgba(245, 158, 11, 0.34);
  --raw-amber-769-a18: rgba(245, 158, 11, 0.18);
  --raw-amber-769-a14: rgba(245, 158, 11, 0.14);
  --raw-amber-769-a12: rgba(245, 158, 11, 0.12);

  --raw-yellow-990-a96: rgba(255, 252, 239, 0.96);
  --raw-yellow-977-a98: rgba(255, 248, 220, 0.98);
  --raw-yellow-977-a92: rgba(255, 248, 220, 0.92);
  --raw-yellow-972-a68: rgba(255, 247, 204, 0.68);
  --raw-yellow-924-a62: rgba(253, 230, 138, 0.62);
  --raw-yellow-855-a6: oklab(85.5% 0.018 0.11 / 6%);
  --raw-yellow-854-a32: rgba(247, 201, 72, 0.32);
  --raw-yellow-854-a24: rgba(247, 201, 72, 0.24);
  --raw-yellow-854-a18: rgba(247, 201, 72, 0.18);
  --raw-yellow-854-a16: rgba(247, 201, 72, 0.16);
  --raw-yellow-850-a36: rgba(243, 200, 93, 0.36);
  --raw-yellow-837-a40: rgba(251, 191, 36, 0.4);
  --raw-yellow-820-a12: rgba(232, 189, 113, 0.12);

  --raw-lime-978-a95: rgba(241, 252, 234, 0.95);
  --raw-lime-978-a94: rgba(241, 252, 234, 0.94);
  --raw-lime-768-a28: rgba(132, 204, 22, 0.28);
  --raw-lime-768-a8: rgba(132, 204, 22, 0.08);

  --raw-green-820-a40: rgba(92, 230, 92, 0.4);

  --raw-teal-984-a95: rgba(240, 253, 250, 0.95);
  --raw-teal-984-a94: rgba(240, 253, 250, 0.94);
  --raw-teal-961-a82: #E9F5F3D1;
  --raw-teal-953-a74: rgba(204, 251, 241, 0.74);
  --raw-teal-855-a34: rgba(94, 234, 212, 0.34);
  --raw-teal-855-a19: rgba(94, 234, 212, 0.19);
  --raw-teal-322-a28: #083C3647;
  --raw-teal-286-a84: rgba(3, 50, 45, 0.84);
  --raw-teal-286-a82: rgba(3, 50, 45, 0.82);
  --raw-teal-286-a55: rgba(3, 50, 45, 0.55);

  --raw-cyan-984-a95: rgba(236, 254, 255, 0.95);
  --raw-cyan-984-a94: rgba(236, 254, 255, 0.94);
  --raw-cyan-956-a98: rgba(207, 250, 254, 0.98);
  --raw-cyan-956-a76: rgba(207, 250, 254, 0.76);
  --raw-cyan-865-a40: rgba(103, 232, 249, 0.40);
  --raw-cyan-865-a32: rgba(103, 232, 249, 0.32);
  --raw-cyan-865-a26: rgba(103, 232, 249, 0.26);
  --raw-cyan-715-a34: rgba(6, 182, 212, 0.34);
  --raw-cyan-715-a28: rgba(6, 182, 212, 0.28);
  --raw-cyan-715-a16: rgba(6, 182, 212, 0.16);

  --raw-sky-685-a34: rgba(14, 165, 233, 0.34);
  --raw-sky-685-a17: rgba(14, 165, 233, 0.17);
  --raw-sky-403-a9: rgb(29 78 103 / 0.09);
  --raw-sky-345-a22: rgb(11 61 92 / 0.22);

  --raw-blue-208-a48: rgba(15, 23, 42, 0.48);
  --raw-blue-208-a42: rgba(15, 23, 42, 0.42);

  --raw-indigo-963-a94: rgba(239, 242, 255, 0.94);
  --raw-indigo-962-a92: rgba(238, 242, 255, 0.92);
  --raw-indigo-930-a98: rgba(224, 231, 255, 0.98);
  --raw-indigo-930-a74: rgba(224, 231, 255, 0.74);
  --raw-indigo-930-a72: rgba(224, 231, 255, 0.72);
  --raw-indigo-785-a42: rgba(165, 180, 252, 0.42);
  --raw-indigo-785-a32: rgba(165, 180, 252, 0.32);
  --raw-indigo-785-a30: rgba(165, 180, 252, 0.30);
  --raw-indigo-785-a24: rgba(165, 180, 252, 0.24);
  --raw-indigo-785-a18: rgba(165, 180, 252, 0.18);
  --raw-indigo-680-a34: rgba(129, 140, 248, 0.34);
  --raw-indigo-680-a32: rgba(129, 140, 248, 0.32);
  --raw-indigo-680-a28: rgba(129, 140, 248, 0.28);
  --raw-indigo-680-a16: rgba(129, 140, 248, 0.16);
  --raw-indigo-511-a15: rgba(79, 70, 229, 0.15);

  --raw-violet-709-a22: rgb(167 139 250 / 0.22);
  --raw-violet-606-a90: rgb(139 92 246 / 0.9);
  --raw-violet-606-a34: rgba(139, 92, 246, 0.34);

  /* The two faces of every surface, named only here; fonts.css loads them. A swapped face changes its token here and
     its faces in fonts.css, nothing else (DESIGN.md#typography). */
  --font-display: 'Baloo Bhai 2', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-body: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  /* The book face of story moments, a system serif that fonts.css does not load. */
  --font-story: Georgia, 'Times New Roman', serif;

  /* Type scale: Tailwind's named steps, then the further steps the roles read, named by their pixel size. */
  --text-3xs: 0.5rem;    /* 8px */
  --text-2xs: 0.625rem;  /* 10px */
  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 1.875rem;
  --text-4xl: 2.25rem;
  --text-5xl: 3rem;
  --text-6xl: 3.75rem;
  --text-7xl: 4.5rem;
  --text-13: 0.8125rem;
  --text-22: 1.375rem;
  --text-26: 1.625rem;
  --text-28: 1.75rem;
  --text-32: 2rem;
  --text-38: 2.375rem;
  --text-56: 3.5rem;

  /* Leading and tracking, in Tailwind's namespaces */
  --leading-108: 1.08;
  --leading-130: 1.3;
  --leading-155: 1.55;
  --tracking-display: -0.027em;

  /* Space scale */
  --space-0: 0;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 28px;
  --space-8: 32px;
  --space-12: 48px;
  --space-16: 64px;

  /* Sizes: every further length a role or component names, by its pixel size; printed lengths in millimetres
     (`--size-mm-2-5` is 2.5mm). */
  --size-2: 2px;
  --size-3: 3px;
  --size-4: 4px;
  --size-22: 22px;
  --size-32: 32px;
  --size-40: 40px;
  --size-44: 44px;
  --size-48: 48px;
  --size-52: 52px;
  --size-56: 56px;
  --size-64: 64px;
  --size-72: 72px;
  --size-96: 96px;
  --size-104: 104px;
  --size-112: 112px;
  --size-152: 152px;
  --size-160: 160px;
  --size-208: 208px;
  --size-280: 280px;
  --size-300: 300px;
  --size-360: 360px;
  --size-420: 420px;
  --size-760: 760px;
  --size-1040: 1040px;
  --size-1140: 1140px;
  --size-mm-2-5: 2.5mm;
  --size-mm-70: 70mm;
  --size-mm-205: 205mm;
  --size-mm-292: 292mm;

  /* Shares of a containing box */
  --percent-10: 10%;
  --percent-46: 46%;
  --percent-84: 84%;
  --percent-300: 300%;
  --percent-minus-24: -24%;
  --percent-minus-45: -45%;
  --percent-minus-58: -58%;
  --percent-minus-142: -142%;

  /* Radius: the base radius (the Tailwind scale in theme.css derives from it), the further steps by pixel size and
     the pill. */
  --radius: 1.25rem;
  --radius-8: 0.5rem;
  --radius-12: 0.75rem;
  --radius-16: 1rem;
  --radius-full: 9999px;

  --opacity-50: 0.5;

  /* Motion */
  --dur-instant: 100ms;
  --dur-fast: 150ms;
  --dur-base: 250ms;
  --dur-slow: 350ms;
  --dur-slower: 500ms;
  --dur-180: 180ms;
  --dur-700: 700ms;

  --ease-out: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-in-out: cubic-bezier(0.4, 0, 0.6, 1);
  --ease-bounce: cubic-bezier(0.68, -0.55, 0.265, 1.55);
  --ease-out-soft: cubic-bezier(.2, .7, .2, 1);

  /* Layers */
  --z-below: -1;
  --z-base: 0;
  --z-elevated: 10;
  --z-dropdown: 100;
  --z-sticky: 200;
  /* The scrim (--surface-scrim) behind a layer over the page: above the page and its sticky parts, below the layer. */
  --z-scrim: 250;
  --z-modal: 300;
  --z-toast: 400;
  --z-tooltip: 500;
  --z-overlay: 600;
}

/* ========================================================================================================
 * TIER 2 · SEMANTIC
 * ======================================================================================================== */

/* The roles both tones share. */
:root {
  /* Brand */
  --color-brand-primary: var(--raw-ocean);
  --color-brand-primary-text: var(--raw-ocean-deep);
  --color-brand-secondary: var(--raw-earth);
  --color-brand-accent: var(--raw-sun);
  /* Pop never writes text, so the accent text step is dark. */
  --color-brand-accent-text: var(--raw-earth);
  --color-brand-glow: var(--raw-sun);

  /* Text, WCAG contrast on white */
  --color-text-main: var(--raw-earth);      /* 15.51:1 on white - AAA */
  --color-text-muted: var(--raw-muted);     /* 5.66:1 on white - AA */
  --color-text-soft: var(--raw-muted);
  --color-text-modal: var(--raw-earth);
  --color-text-inverted: var(--raw-white);  /* only on blue and red */

  /* Surface: white only, shapes come from a line. The blue tint (--control-primary-tint) marks hover and selection,
     never a surface. */
  --color-surface-base: var(--raw-white);
  --color-surface-card: var(--raw-white);
  --color-surface-modal: var(--raw-white);
  --color-surface-subtle: var(--raw-white);
  --color-surface-paper: var(--raw-white);
  --color-surface-tint-1: var(--raw-white);
  --color-surface-tint-2: var(--raw-white);
  --color-surface-tint-3: var(--raw-white);
  --color-surface-inverted: var(--raw-earth);

  /* Borders */
  --color-border-default: var(--raw-line);

  /* Feedback */
  --color-success: var(--raw-jungle);
  --color-warning: var(--raw-sun);
  --color-error: var(--raw-red);
  --color-info: var(--raw-sky);

  /* Control Primary: calm control, selected state, focus, confirm. */
  --control-primary: var(--raw-ocean);
  --control-primary-hover: var(--color-brand-primary-text);
  --control-primary-press: var(--control-primary-hover);
  --control-on-primary: var(--raw-white);
  --control-primary-text: var(--color-brand-primary-text);
  --control-primary-tint: color-mix(in srgb, var(--control-primary) 10%, var(--surface-canvas));
  --control-focus-ring: var(--control-primary-text);  /* deep blue draws the focus frame */
  /* Calm keyboard focus: semantic surface tint plus one inner line, no outer frame. */
  --control-focus-line: var(--control-primary-text);
  --control-focus-tint: var(--control-primary-tint);
  /* Inner focus line on a filled control surface, where the fill erases the tint. White measures 5.03:1 on
     --control-primary and 5.09:1 on --destructive (WCAG 1.4.11 needs 3:1); dark would only reach 3.08:1 and 3.04:1.
     White is the one text colour allowed on blue and red, and the primitive stays true inside [data-theme="dark"]. */
  --control-focus-line-on-fill: var(--raw-white);

  /* Action Energy: movement start, quest heat, urgency, streak. Orange is a Pop surface, so text on it is dark. */
  --action-energy: var(--raw-tiger);
  --action-energy-hover: var(--action-energy);
  --action-energy-press: var(--action-energy);
  --action-on-energy: var(--raw-earth);
  --action-energy-text: var(--color-brand-accent-text);
  --action-energy-tint: color-mix(in srgb, var(--action-energy) 10%, var(--surface-canvas));

  /* Content roles: five colours write on white (dark, muted, deep-blue link, blue, red for errors). Blue writes the
     second line of a large heading, and in the product tone a kicker or the children's answer. */
  --content-strong: var(--color-text-main);
  --content-muted: var(--color-text-muted);
  --content-soft: var(--color-text-soft);
  --content-on-dark: var(--color-text-inverted);
  --content-accent: var(--raw-ocean);
  --content-link: var(--raw-ocean-deep);
  --content-on-pop: var(--raw-earth);

  /* Surfaces: every one is white, sunken included. */
  --surface-canvas: var(--color-surface-base);
  --surface-stage: var(--color-surface-paper);
  --surface-raised: var(--color-surface-card);
  --surface-sunken: var(--color-surface-subtle);
  /* The dark surface (earth): white text on it breaks „white text only on blue and red“; whether it stays a written
     exception is open (media stages, celebration and campaign overlays, the landing hero). */
  --surface-inverted: var(--color-surface-inverted);
  /* The scrim: the one dark veil behind a layer over the page (Modal, ContextPanel, Sheet, AlertDialog). It is light,
     so the page beneath stays readable as context. */
  --surface-scrim: color-mix(in srgb, var(--content-strong) 30%, transparent);

  /* Pop surfaces: always full, always with --content-on-pop, never a button, never on grey, never as reading text. */
  --pop-sky: var(--raw-sky);
  --pop-orange: var(--raw-tiger);
  --pop-turquoise: var(--raw-jungle);
  --pop-sun: var(--raw-sun);
  --pop-pink: var(--raw-berry);
  --pop-lilac: var(--raw-purple);

  /* Lines */
  --border-hairline: var(--color-border-default);
  --border-soft: var(--color-border-default);
  /* A stronger line for hover frames, never a fill. */
  --border-strong: color-mix(in srgb, var(--content-soft) 38%, var(--surface-canvas));

  /* Status roles are real state only. --status-* writes the word and draws the line (dark; red for danger).
     --status-*-tint is the light: a full Pop surface (turquoise, sun, sky) with dark text. theme.css derives every
     bg-status-* fill from the light, so a dot or bar shows Pop while text-status-* stays dark. Danger is red text on
     white or the red destructive fill with white text. No pale wash surfaces. --status-success-strong is the one
     green that carries white text: the chip of a done or reached work state (DESIGN.md COL-2, COL-6), 5.5 : 1. */
  --status-success: var(--content-on-pop);
  --status-success-tint: var(--pop-turquoise);
  --status-success-strong: var(--raw-teal-510);
  --status-warning: var(--content-on-pop);
  --status-warning-tint: var(--pop-sun);
  --status-danger: var(--raw-red);
  --status-danger-tint: var(--surface-canvas);
  --status-info: var(--content-on-pop);
  --status-info-tint: var(--pop-sky);
  --status-neutral: var(--content-muted);
  --status-neutral-tint: var(--surface-sunken);

  /* Elevation */
  --shadow-card: 0 8px 24px -18px var(--raw-blue-208-a42);
  --shadow-raised: 0 16px 40px -24px var(--raw-blue-208-a48);
  --shadow-floating: 0 16px 48px -8px var(--raw-earth-a15), 0 8px 16px -4px var(--raw-earth-a8);
  --shadow-brand: 0 8px 16px -2px var(--raw-ocean-a25);
  /* Brand glow: pure glow without offset (0 0) for a lit control or bar. */
  --glow-brand: 0 0 15px var(--raw-ocean-a70);

  /* Type roles. The display face (Baloo 800) carries only the page title, the sheet title and the section heading;
     every heading below 28px is a subsection on the body face at 600. The caption is the floor of the fixed type
     scale (DESIGN.md#typography): no visible text below 13px. */
  --type-page-title: var(--text-38);  /* 38px */
  --type-sheet-title: var(--text-32);  /* 32px */
  --type-section-title: var(--text-28);  /* 28px */
  --type-subsection-title: var(--text-xl);  /* 20px */
  --type-caption: var(--text-13);  /* 13px */
  --heading-tracking: var(--tracking-display);

  /* Bounded section-title surfaces; independent of the global radius scale. */
  --radius-section: var(--radius-12);

  /* Interaction */
  --touch-target-min: var(--size-44);
  --focus-ring-width: var(--size-3);
  --focus-ring-offset: var(--size-2);
  --focus-ring-color: var(--control-focus-ring);
  --disabled-opacity: var(--opacity-50);

  /* The shadcn names the library primitives read, bridged onto the roles. */
  --background: var(--color-surface-base);
  --foreground: var(--color-text-main);
  --card: var(--color-surface-paper);
  --card-foreground: var(--color-text-main);
  --popover: var(--color-surface-paper);
  --popover-foreground: var(--color-text-main);
  /* Primary is the calm control, not the energetic start. */
  --primary: var(--control-primary);
  --primary-foreground: var(--control-on-primary);
  --secondary: var(--color-surface-subtle);
  --secondary-foreground: var(--color-text-main);
  --muted: var(--color-surface-subtle);
  --muted-foreground: var(--color-text-muted);
  /* The shadcn hover and selection surface: the blue tint, never Pop or grey. */
  --accent: var(--control-primary-tint);
  --accent-foreground: var(--color-text-main);
  /* Red with white text */
  --destructive: var(--color-error);
  --destructive-foreground: var(--control-on-primary);
  --border: var(--color-border-default);
  --input: var(--border);  /* an input frame is the one line colour */
  --ring: var(--control-focus-ring);
  /* Chart series of the shadcn chart: quest orange, campaign sky, studio pink, XP sun, streak orange. */
  --chart-1: var(--raw-tiger);
  --chart-2: var(--raw-sky);
  --chart-3: var(--raw-berry);
  --chart-4: var(--raw-sun);
  --chart-5: var(--raw-tiger);
  --sidebar: var(--color-surface-paper);
  --sidebar-foreground: var(--color-text-main);
  --sidebar-primary: var(--control-primary);
  --sidebar-primary-foreground: var(--control-on-primary);
  --sidebar-accent: var(--control-primary-tint);
  --sidebar-accent-foreground: var(--color-text-main);
  --sidebar-border: var(--color-border-default);
  --sidebar-ring: var(--control-focus-ring);
}

/* Inverted roles for a dark CMS background (a coach gradient): text turns white, surfaces turn to glass. */
[data-theme="dark"] {
  --color-text-main: var(--raw-white);
  --color-text-muted: var(--raw-white-a70);
  --color-text-soft: var(--raw-white-a50);
  --color-surface-base: var(--raw-white-a15);
  --color-surface-card: var(--raw-white-a18);
  --color-surface-subtle: var(--raw-white-a30); /* the stronger glass of a progress track */
  --color-surface-paper: var(--raw-white-a5);
  --color-surface-tint-1: var(--raw-white-a8);
  --color-surface-tint-2: var(--raw-white-a12);
  --color-surface-tint-3: var(--raw-white-a18);
  --color-border-default: var(--raw-white-a10);
}

/* The shadcn names in the dark colour scheme of the web app (`.dark` on <html>). */
.dark {
  --background: var(--color-surface-inverted);
  --foreground: var(--color-text-inverted);
  --card: var(--raw-stone);
  --card-foreground: var(--color-text-inverted);
  --popover: var(--raw-stone);
  --popover-foreground: var(--color-text-inverted);
  --primary: var(--control-primary);
  --primary-foreground: var(--control-on-primary);
  --secondary: var(--raw-stone);
  --secondary-foreground: var(--color-text-inverted);
  --muted: var(--raw-stone);
  --muted-foreground: var(--raw-soft);
  --accent: var(--color-brand-accent);
  --accent-foreground: var(--color-text-main);
  --destructive: var(--color-error);
  --border: var(--raw-soft);
  --input: var(--border);
  --ring: var(--control-focus-ring);
  --focus-ring-color: var(--control-focus-ring);
  --sidebar: var(--raw-stone);
  --sidebar-foreground: var(--color-text-inverted);
  --sidebar-primary: var(--control-primary);
  --sidebar-primary-foreground: var(--control-on-primary);
  --sidebar-accent: var(--color-brand-accent);
  --sidebar-accent-foreground: var(--color-text-main);
  --sidebar-border: var(--raw-soft);
  --sidebar-ring: var(--control-focus-ring);
}

/* Tone admin: airy and clean, a lot of white, one clear message per page. Every surface is white and draws its shape
   with a line; the grey shell (the only grey, DESIGN.md#colors) frames the white stage. The outer frame and the app
   rail surround navigation and stage; scripts/validate-design-contract.mjs measures their text pairs. */
[data-tone="admin"] {
  --surface-shell-rail: var(--raw-grey-962);
  --surface-shell-navigation: var(--raw-grey-979);
  --surface-accent: var(--surface-canvas);
  --surface-warm: var(--surface-canvas);
  --border-warm: var(--border-hairline);
  --surface-placeholder: var(--surface-canvas);
  --border-placeholder: var(--border-hairline);
  --status-attention: var(--status-warning);
  --status-attention-tint: var(--status-warning-tint);
  --content-voice: var(--content-strong);
}

/* Tone product (Kita course, web app): simpler and more playful in colour. Cards and highlights may stand on a blue
   wash, a character speaks from warm paper, a missing picture keeps a calm frame, the sentences to the children write
   in navy. The product has no shell, so its shell roles are the white canvas. */
[data-tone="product"] {
  --surface-shell-rail: var(--surface-canvas);
  --surface-shell-navigation: var(--surface-canvas);
  --surface-accent: var(--raw-sky-970);
  --surface-warm: var(--raw-yellow-957);
  --border-warm: var(--raw-yellow-906);
  --surface-placeholder: var(--raw-grey-970);
  --border-placeholder: var(--raw-sky-889);
  --status-attention: var(--raw-orange-555);
  --status-attention-tint: var(--raw-amber-980);
  --content-voice: var(--raw-sky-345);
}

/* ========================================================================================================
 * TIER 3 · COMPONENT
 * ======================================================================================================== */

/* Active run shell: one chrome contract across guided and immersive runs. */
:root {
  --run-surface: var(--surface-stage);
  --run-chrome-text: var(--content-strong);
  --run-chrome-muted: var(--content-muted);
  --run-progress-track: color-mix(in srgb, var(--border-soft) 72%, transparent);
  --run-progress-fill: var(--coach-primary);
  --run-progress-glow: var(--coach-glow);
  --run-atmosphere-glow: var(--coach-glow);
  --run-control-surface: color-mix(in srgb, var(--surface-raised) 88%, transparent);
  --run-control-border: var(--border-soft);
  --run-control-text: var(--content-strong);

  /* Coach context defaults; CampaignShell overrides them at runtime. */
  --coach-primary: var(--control-primary);
  --coach-secondary: var(--control-primary-text);
  --coach-accent: var(--color-brand-accent);
  --coach-glow: color-mix(in srgb, var(--coach-primary) 30%, transparent);
  --coach-tint: color-mix(in srgb, var(--coach-primary) 10%, var(--surface-canvas));
  --coach-shadow: color-mix(in srgb, var(--coach-primary) 40%, transparent);

  /* Coach honey family */
  --coach-gold: var(--raw-yellow-854);
  --coach-honey: var(--raw-amber-769);
  --coach-honey-deep: var(--raw-amber-717);
  --coach-honey-light: var(--raw-yellow-973);
  --coach-honey-cream: var(--raw-yellow-962);
  --coach-honey-highlight: var(--raw-yellow-958);
  --coach-honey-paper: var(--raw-yellow-986);
  --coach-honey-glow-soft: var(--raw-amber-769-a12);
  --coach-honey-glow: var(--raw-amber-769-a35);

  /* Bear/Mako identity family */
  --bear-bark: var(--raw-orange-315);
  --bear-bark-honey: var(--raw-orange-283);
  --bear-bark-soft: var(--raw-amber-461);
  --bear-forest: var(--raw-green-488);
  --bear-leaf-ink: var(--raw-green-373);

  /* Mission builder */
  --size-mission-builder-tile: var(--size-160);
}

[data-run-tone="dark"] {
  --run-surface: var(--surface-inverted);
  --run-chrome-text: var(--content-on-dark);
  --run-chrome-muted: color-mix(in srgb, var(--content-on-dark) 72%, transparent);
  --run-progress-track: color-mix(in srgb, var(--content-on-dark) 22%, transparent);
  --run-control-surface: color-mix(in srgb, var(--surface-inverted) 72%, transparent);
  --run-control-border: color-mix(in srgb, var(--content-on-dark) 18%, transparent);
  --run-control-text: var(--content-on-dark);
}

/* Session modes, "Tageszeiten im Dschungel": PREP is always there (quiet, before the mode), FLOW the morning (teal),
   POWER the day (volcano red), FOCUS the night (indigo), FREEZE the cold (cyan), SLEEP the wind-down (amethyst). A
   session changes only from PREP into its mode. */
:root {
  --mode-prep: var(--mode-prep-arc);
  --mode-flow: var(--mode-flow-arc);
  --mode-focus: var(--mode-focus-arc);
  --mode-power: var(--mode-power-arc);
  --mode-freeze: var(--mode-freeze-arc);
  --mode-breath: var(--color-breath-accent);
  --mode-sleep: var(--mode-sleep-arc);

  --mode-prep-bg: var(--raw-white);
  --mode-prep-accent: var(--raw-jungle);
  --mode-prep-text: var(--raw-earth);
  --mode-prep-text-muted: var(--raw-blue-554);

  --mode-flow-bg: var(--raw-sky-450);
  --mode-flow-accent: var(--raw-teal-855);
  --mode-flow-text: var(--raw-white);
  --mode-flow-text-muted: var(--raw-cyan-917);

  --mode-focus-bg: var(--raw-indigo-257);
  --mode-focus-accent: var(--raw-indigo-785);
  --mode-focus-text: var(--raw-white);
  --mode-focus-text-muted: var(--raw-indigo-870);

  --mode-power-bg: var(--raw-red-444);
  --mode-power-accent: var(--raw-red-808);
  --mode-power-text: var(--raw-white);
  --mode-power-text-muted: var(--raw-red-885);

  --mode-transition-duration: var(--dur-700);
  --mode-transition-timing: ease-out;

  --mode-freeze-bg: var(--raw-cyan-609);
  --mode-freeze-accent: var(--raw-cyan-865);
  --mode-freeze-text: var(--raw-white);
  --mode-freeze-text-muted: var(--raw-cyan-917);

  --mode-sleep-bg: var(--raw-violet-283);
  --mode-sleep-accent: var(--raw-violet-811);
  --mode-sleep-text: var(--raw-white);
  --mode-sleep-text-muted: var(--raw-violet-780);

  /* Mode rings: a thin track, a clockwise arc from the top and one leading dot. Light treatment; the colour and dark
     treatments lift arc, track and dot to white or a light tint. */
  --mode-prep-arc: var(--raw-blue-623);
  --mode-prep-track: var(--raw-grey-928);
  --mode-prep-dot: var(--raw-blue-551);
  --mode-prep-deep: var(--raw-blue-623);  /* prep has no deep signature; it mirrors the arc */

  --mode-flow-arc: var(--raw-jungle);
  --mode-flow-track: var(--raw-teal-921);
  --mode-flow-dot: var(--raw-teal-600);
  --mode-flow-glow: var(--raw-jungle-a34);
  --mode-flow-deep: var(--raw-sky-450);

  --mode-focus-arc: var(--raw-indigo-680);
  --mode-focus-track: var(--raw-indigo-919);
  --mode-focus-dot: var(--raw-indigo-585);
  --mode-focus-glow: var(--raw-indigo-680-a34);
  --mode-focus-deep: var(--raw-indigo-257);

  --mode-power-arc: var(--raw-tiger);
  --mode-power-track: var(--raw-orange-922);
  --mode-power-dot: var(--raw-orange-646);
  --mode-power-glow: var(--raw-tiger-a34);
  --mode-power-deep: var(--raw-red-444);

  --mode-freeze-arc: var(--raw-sky);
  --mode-freeze-track: var(--raw-sky-935);
  --mode-freeze-dot: var(--raw-sky-685);
  --mode-freeze-glow: var(--raw-sky-685-a34);
  --mode-freeze-deep: var(--raw-sky-391);

  --mode-sleep-arc: var(--raw-violet-606);
  --mode-sleep-track: var(--raw-violet-912);
  --mode-sleep-dot: var(--raw-violet-541);
  --mode-sleep-glow: var(--raw-violet-606-a34);
  --mode-sleep-deep: var(--raw-violet-283);
}

/* Activity stage: the runtime roles of the flow ring and the breath stage. Geometry stays with the components. */
:root {
  --activity-flow-contrast: var(--raw-white);
  --activity-flow-track: var(--raw-white-a28);
  --activity-flow-dot-glow: var(--raw-white-a55);
  --activity-flow-arc-shadow: drop-shadow(0 0 10px var(--raw-white-a45));
  --activity-flow-ring-halo: radial-gradient(circle farthest-corner at 50% 50%, transparent 35%, var(--raw-white-a28) 48%, var(--raw-white-a8) 58%, transparent 68%);
  --activity-flow-ring-label: var(--raw-white-a82);
  --activity-flow-ring-sublabel: var(--raw-white-a72);
  --activity-flow-cue: var(--raw-white-a88);
  --activity-flow-exhale-glow: var(--raw-white-a60);
  --activity-flow-stage-background: radial-gradient(ellipse 130% 110% at 20% 22%, var(--raw-teal-791) 0%, transparent 52%), radial-gradient(ellipse 120% 130% at 100% 58%, var(--raw-teal-349) 0%, transparent 66%), radial-gradient(ellipse 90% 80% at 58% 96%, var(--raw-yellow-820-a12) 0%, transparent 55%), linear-gradient(155deg, var(--raw-teal-620) 0%, var(--raw-teal-510) 55%, var(--raw-teal-400) 100%);
  --activity-flow-stage-background-mobile: radial-gradient(circle 210px at 50% 47%, var(--raw-teal-286-a84) 0%, var(--raw-teal-286-a55) 36%, transparent 72%), radial-gradient(ellipse 90% 52% at 50% 38%, var(--raw-teal-779) 0%, transparent 62%), radial-gradient(ellipse 120% 60% at 50% 102%, var(--raw-teal-349) 0%, transparent 70%), linear-gradient(165deg, var(--raw-teal-620) 0%, var(--raw-teal-510) 55%, var(--raw-teal-400) 100%);
  --activity-flow-stage-background-desktop: radial-gradient(circle 440px at 38% 54%, var(--raw-teal-286-a82) 0%, var(--raw-teal-286-a55) 34%, transparent 70%), radial-gradient(ellipse 130% 110% at 20% 22%, var(--raw-teal-791) 0%, transparent 52%), radial-gradient(ellipse 120% 130% at 100% 58%, var(--raw-teal-349) 0%, transparent 66%), radial-gradient(ellipse 90% 80% at 58% 96%, var(--raw-yellow-820-a12) 0%, transparent 55%), linear-gradient(155deg, var(--raw-teal-620) 0%, var(--raw-teal-510) 55%, var(--raw-teal-400) 100%);
  --activity-flow-control-label: var(--raw-teal-596);
  --activity-flow-control-shadow: var(--raw-teal-322-a28) 0 8px 22px;
  --activity-flow-skip-label: var(--raw-white-a80);

  --activity-breath-track: var(--raw-violet-709-a22);
  --activity-breath-trace: var(--raw-violet-811);
  --activity-breath-shape-glow: var(--raw-violet-606-a90);
  --activity-breath-seconds: var(--raw-violet-725);
  --activity-breath-eyebrow: var(--raw-violet-811);
  --activity-breath-cue: var(--raw-teal-961-a82);
  --activity-breath-progress-fill: linear-gradient(in oklab 90deg, var(--raw-violet-812) 0%, var(--raw-violet-607) 100%);
  --activity-breath-stage-base: var(--raw-sky-219);
  --activity-breath-stage-background: radial-gradient(ellipse 80% 70% at 34% 48% in oklab, var(--raw-purple-357) 0%, transparent 62%), radial-gradient(ellipse 70% 60% at 30% 50% in oklab, var(--raw-yellow-855-a6) 0%, transparent 55%), radial-gradient(ellipse 140% 120% at 45% 32% in oklab, var(--raw-violet-239) 0%, var(--raw-violet-189) 55%, var(--raw-violet-154) 100%);
  --activity-breath-control-shadow: var(--raw-black-a22) 0 8px 24px;
  --activity-breath-control-label: var(--raw-purple-453);
}

/* World portal atmospheres: components read the generic --atmo-* aliases; the [data-atmosphere] cascade below maps
   them to one family (prep, flow, focus, power, freeze, breath). */
:root {
  /* Prep: quiet neutral before the active mode world opens */
  --atmo-prep-stage-background:
    radial-gradient(circle at 50% -12%, color-mix(in srgb, var(--atmo-prep-progress-start) 46%, transparent), transparent 34rem),
    radial-gradient(circle at 45% 58%, color-mix(in srgb, var(--color-surface-subtle) 72%, transparent), transparent 22rem),
    radial-gradient(circle at 70% 42%, color-mix(in srgb, var(--color-border-default) 28%, transparent), transparent 20rem),
    linear-gradient(180deg, color-mix(in srgb, var(--atmo-prep-progress-start) 12%, var(--color-surface-base)), color-mix(in srgb, var(--color-surface-subtle) 42%, var(--color-surface-base)));
  --atmo-prep-progress-start: color-mix(in srgb, var(--color-border-default) 72%, var(--color-surface-base));
  --atmo-prep-progress-end: color-mix(in srgb, var(--color-text-muted) 28%, var(--color-border-default));
  --atmo-prep-progress-glow: color-mix(in srgb, var(--color-border-default) 34%, transparent);
  --atmo-prep-counter-background: color-mix(in srgb, var(--color-surface-card) 94%, transparent);
  --atmo-prep-counter-border: color-mix(in srgb, var(--color-border-default) 72%, transparent);
  --atmo-prep-counter-text: var(--color-text-muted);
  --atmo-prep-title-text: var(--color-text-main);
  --atmo-prep-cue-background: color-mix(in srgb, var(--color-surface-card) 96%, transparent);
  --atmo-prep-cue-border: color-mix(in srgb, var(--color-border-default) 68%, transparent);
  --atmo-prep-portal-background:
    radial-gradient(circle at 50% 0%, color-mix(in srgb, var(--color-surface-card) 96%, transparent), transparent 42%),
    linear-gradient(160deg, var(--color-surface-base), color-mix(in srgb, var(--color-surface-subtle) 58%, var(--color-surface-base)));
  --atmo-prep-portal-glow: color-mix(in srgb, var(--color-border-default) 28%, transparent);
  --atmo-prep-compass-ring: color-mix(in srgb, var(--color-text-muted) 32%, var(--color-border-default));
  --atmo-prep-compass-ring-muted: color-mix(in srgb, var(--color-border-default) 38%, transparent);
  --atmo-prep-compass-glow: color-mix(in srgb, var(--color-border-default) 24%, transparent);
  --atmo-prep-compass-face:
    radial-gradient(circle at 38% 28%, color-mix(in srgb, var(--color-surface-card) 96%, transparent), color-mix(in srgb, var(--color-surface-subtle) 70%, transparent) 34%, transparent 58%),
    radial-gradient(circle at 50% 62%, color-mix(in srgb, var(--color-surface-base) 95%, transparent) 0%, color-mix(in srgb, var(--color-border-default) 36%, transparent) 100%);

  /* Flow */
  --atmo-flow-stage-background:
    radial-gradient(circle at 50% -12%, var(--raw-yellow-854-a24), transparent 34rem),
    radial-gradient(circle at 42% 64%, var(--raw-yellow-854-a16), transparent 22rem),
    radial-gradient(circle at 70% 54%, var(--raw-yellow-854-a18), transparent 20rem),
    radial-gradient(circle at 36% 38%, var(--raw-lime-768-a8), transparent 19rem),
    linear-gradient(180deg, var(--raw-yellow-977-a98), var(--raw-yellow-990-a96));
  --atmo-flow-progress-start: var(--coach-gold);
  --atmo-flow-progress-end: var(--coach-honey);
  --atmo-flow-progress-glow: var(--coach-honey-glow);
  --atmo-flow-counter-background: var(--raw-lime-978-a95);
  --atmo-flow-counter-border: var(--raw-lime-768-a28);
  --atmo-flow-counter-text: var(--bear-leaf-ink);
  --atmo-flow-title-text: var(--bear-bark-honey);
  --atmo-flow-cue-background:
    radial-gradient(circle at 20% 18%, var(--raw-white-a96), transparent 3.4rem),
    linear-gradient(135deg, var(--raw-yellow-977-a98), var(--raw-lime-978-a94));
  --atmo-flow-cue-border: var(--raw-yellow-854-a32);
  --atmo-flow-portal-background:
    radial-gradient(circle at 50% 0%, var(--raw-white-a95), var(--raw-grey-984-a84)),
    linear-gradient(160deg, var(--coach-honey-light), var(--coach-honey-cream));
  --atmo-flow-portal-glow: var(--raw-yellow-854-a18);
  --atmo-flow-compass-ring: var(--coach-honey);
  --atmo-flow-compass-ring-muted: var(--raw-amber-769-a14);
  --atmo-flow-compass-glow: var(--raw-amber-769-a34);
  --atmo-flow-compass-face:
    radial-gradient(circle at 38% 28%, var(--raw-white-a98), var(--raw-yellow-972-a68) 34%, transparent 58%),
    radial-gradient(circle at 50% 62%, var(--raw-yellow-977-a92) 0%, var(--raw-yellow-924-a62) 54%, var(--raw-yellow-850-a36) 100%);

  /* Focus */
  --atmo-focus-stage-background:
    radial-gradient(circle at 50% -12%, var(--raw-indigo-785-a30), transparent 34rem),
    radial-gradient(circle at 36% 60%, var(--raw-indigo-785-a24), transparent 22rem),
    radial-gradient(circle at 72% 45%, var(--raw-indigo-511-a15), transparent 20rem),
    linear-gradient(180deg, var(--raw-indigo-930-a98), var(--raw-indigo-963-a94));
  --atmo-focus-progress-start: var(--raw-indigo-870);
  --atmo-focus-progress-end: var(--raw-indigo-680);
  --atmo-focus-progress-glow: var(--raw-indigo-680-a34);
  --atmo-focus-counter-background: var(--raw-indigo-963-a94);
  --atmo-focus-counter-border: var(--raw-indigo-680-a28);
  --atmo-focus-counter-text: var(--raw-indigo-359);
  --atmo-focus-compass-ring: var(--raw-indigo-680);
  --atmo-focus-compass-ring-muted: var(--raw-indigo-680-a16);
  --atmo-focus-compass-glow: var(--raw-indigo-680-a32);
  --atmo-focus-compass-face:
    radial-gradient(circle at 38% 28%, var(--raw-white-a98), var(--raw-indigo-930-a72) 34%, transparent 58%),
    radial-gradient(circle at 50% 62%, var(--raw-indigo-962-a92) 0%, var(--raw-indigo-785-a42) 100%);

  /* Power */
  --atmo-power-stage-background:
    radial-gradient(circle at 50% -12%, var(--raw-red-808-a30), transparent 34rem),
    radial-gradient(circle at 34% 62%, var(--raw-red-808-a25), transparent 22rem),
    radial-gradient(circle at 76% 54%, var(--raw-amber-769-a18), transparent 21rem),
    linear-gradient(180deg, var(--raw-amber-954-a98), var(--raw-orange-970-a95));
  --atmo-power-progress-start: var(--raw-red-885);
  --atmo-power-progress-end: var(--raw-tiger);
  --atmo-power-progress-glow: var(--raw-tiger-a34);
  --atmo-power-counter-background: var(--raw-amber-954-a94);
  --atmo-power-counter-border: var(--raw-tiger-a26);
  --atmo-power-counter-text: var(--raw-orange-408);
  --atmo-power-compass-ring: var(--raw-tiger);
  --atmo-power-compass-ring-muted: var(--raw-tiger-a16);
  --atmo-power-compass-glow: var(--raw-tiger-a34);
  --atmo-power-compass-face:
    radial-gradient(circle at 38% 28%, var(--raw-white-a98), var(--raw-amber-954-a76) 34%, transparent 58%),
    radial-gradient(circle at 50% 62%, var(--raw-amber-980-a94) 0%, var(--raw-orange-758-a36) 100%);

  /* Freeze */
  --atmo-freeze-stage-background:
    radial-gradient(circle at 50% -12%, var(--raw-cyan-865-a32), transparent 34rem),
    radial-gradient(circle at 36% 62%, var(--raw-cyan-865-a26), transparent 22rem),
    radial-gradient(circle at 76% 48%, var(--raw-sky-685-a17), transparent 20rem),
    linear-gradient(180deg, var(--raw-cyan-956-a98), var(--raw-cyan-984-a95));
  --atmo-freeze-progress-start: var(--raw-cyan-917);
  --atmo-freeze-progress-end: var(--raw-cyan-715);
  --atmo-freeze-progress-glow: var(--raw-cyan-715-a34);
  --atmo-freeze-counter-background: var(--raw-cyan-984-a94);
  --atmo-freeze-counter-border: var(--raw-cyan-715-a28);
  --atmo-freeze-counter-text: var(--raw-sky-398);
  --atmo-freeze-compass-ring: var(--raw-cyan-715);
  --atmo-freeze-compass-ring-muted: var(--raw-cyan-715-a16);
  --atmo-freeze-compass-glow: var(--raw-cyan-715-a34);
  --atmo-freeze-compass-face:
    radial-gradient(circle at 38% 28%, var(--raw-white-a98), var(--raw-cyan-956-a76) 34%, transparent 58%),
    radial-gradient(circle at 50% 62%, var(--raw-cyan-984-a95) 0%, var(--raw-cyan-865-a40) 100%);

  /* Breath: the progress family stays teal; the breath triangle and firefly use the focus lilac. */
  --atmo-breath-stage-background:
    radial-gradient(circle at 50% -12%, var(--raw-indigo-785-a32), transparent 34rem),
    radial-gradient(circle at 42% 56%, var(--raw-teal-855-a19), transparent 22rem),
    radial-gradient(circle at 70% 45%, var(--raw-indigo-785-a18), transparent 20rem),
    linear-gradient(180deg, var(--raw-indigo-930-a74), var(--raw-teal-984-a95));
  --atmo-breath-progress-start: var(--raw-teal-910);
  --atmo-breath-progress-end: var(--raw-jungle);
  --atmo-breath-progress-glow: var(--raw-jungle-a30);
  --atmo-breath-counter-background: var(--raw-teal-984-a94);
  --atmo-breath-counter-border: var(--raw-jungle-a26);
  --atmo-breath-counter-text: var(--raw-teal-386);
  --atmo-breath-compass-ring: var(--raw-jungle);
  --atmo-breath-compass-ring-muted: var(--raw-jungle-a16);
  --atmo-breath-compass-glow: var(--raw-jungle-a30);
  --atmo-breath-compass-face:
    radial-gradient(circle at 38% 28%, var(--raw-white-a98), var(--raw-teal-953-a74) 34%, transparent 58%),
    radial-gradient(circle at 50% 62%, var(--raw-teal-984-a95) 0%, var(--raw-teal-855-a34) 100%);
  --color-breath-accent: var(--atmo-focus-progress-end);

  /* Generic atmosphere aliases at :root are Flow; components read only these. */
  --atmo-stage-background: var(--atmo-flow-stage-background);
  --atmo-progress-start: var(--atmo-flow-progress-start);
  --atmo-progress-end: var(--atmo-flow-progress-end);
  --atmo-progress-glow: var(--atmo-flow-progress-glow);
  --atmo-counter-background: var(--atmo-flow-counter-background);
  --atmo-counter-border: var(--atmo-flow-counter-border);
  --atmo-counter-text: var(--atmo-flow-counter-text);
  --atmo-title-text: var(--atmo-flow-title-text);
  --atmo-cue-background: var(--atmo-flow-cue-background);
  --atmo-cue-border: var(--atmo-flow-cue-border);
  --atmo-portal-background: var(--atmo-flow-portal-background);
  --atmo-portal-glow: var(--atmo-flow-portal-glow);
  --atmo-compass-ring: var(--atmo-flow-compass-ring);
  --atmo-compass-ring-muted: var(--atmo-flow-compass-ring-muted);
  --atmo-compass-glow: var(--atmo-flow-compass-glow);
  --atmo-compass-face: var(--atmo-flow-compass-face);
}

[data-atmosphere="prep"] {
  --atmo-stage-background: var(--atmo-prep-stage-background);
  --atmo-progress-start: var(--atmo-prep-progress-start);
  --atmo-progress-end: var(--atmo-prep-progress-end);
  --atmo-progress-glow: var(--atmo-prep-progress-glow);
  --atmo-counter-background: var(--atmo-prep-counter-background);
  --atmo-counter-border: var(--atmo-prep-counter-border);
  --atmo-counter-text: var(--atmo-prep-counter-text);
  --atmo-title-text: var(--atmo-prep-title-text);
  --atmo-cue-background: var(--atmo-prep-cue-background);
  --atmo-cue-border: var(--atmo-prep-cue-border);
  --atmo-portal-background: var(--atmo-prep-portal-background);
  --atmo-portal-glow: var(--atmo-prep-portal-glow);
  --atmo-compass-ring: var(--atmo-prep-compass-ring);
  --atmo-compass-ring-muted: var(--atmo-prep-compass-ring-muted);
  --atmo-compass-glow: var(--atmo-prep-compass-glow);
  --atmo-compass-face: var(--atmo-prep-compass-face);
}

[data-atmosphere="flow"] {
  --atmo-stage-background: var(--atmo-flow-stage-background);
  --atmo-progress-start: var(--atmo-flow-progress-start);
  --atmo-progress-end: var(--atmo-flow-progress-end);
  --atmo-progress-glow: var(--atmo-flow-progress-glow);
  --atmo-counter-background: var(--atmo-flow-counter-background);
  --atmo-counter-border: var(--atmo-flow-counter-border);
  --atmo-counter-text: var(--atmo-flow-counter-text);
  --atmo-title-text: var(--atmo-flow-title-text);
  --atmo-cue-background: var(--atmo-flow-cue-background);
  --atmo-cue-border: var(--atmo-flow-cue-border);
  --atmo-portal-background: var(--atmo-flow-portal-background);
  --atmo-portal-glow: var(--atmo-flow-portal-glow);
  --atmo-compass-ring: var(--atmo-flow-compass-ring);
  --atmo-compass-ring-muted: var(--atmo-flow-compass-ring-muted);
  --atmo-compass-glow: var(--atmo-flow-compass-glow);
  --atmo-compass-face: var(--atmo-flow-compass-face);
}

[data-atmosphere="focus"] {
  --atmo-stage-background: var(--atmo-focus-stage-background);
  --atmo-progress-start: var(--atmo-focus-progress-start);
  --atmo-progress-end: var(--atmo-focus-progress-end);
  --atmo-progress-glow: var(--atmo-focus-progress-glow);
  --atmo-counter-background: var(--atmo-focus-counter-background);
  --atmo-counter-border: var(--atmo-focus-counter-border);
  --atmo-counter-text: var(--atmo-focus-counter-text);
  --atmo-title-text: var(--color-text-main);
  --atmo-cue-background: var(--color-surface-card);
  --atmo-cue-border: var(--atmo-focus-counter-border);
  --atmo-portal-background: var(--color-surface-card);
  --atmo-portal-glow: var(--atmo-focus-progress-glow);
  --atmo-compass-ring: var(--atmo-focus-compass-ring);
  --atmo-compass-ring-muted: var(--atmo-focus-compass-ring-muted);
  --atmo-compass-glow: var(--atmo-focus-compass-glow);
  --atmo-compass-face: var(--atmo-focus-compass-face);
}

[data-atmosphere="power"] {
  --atmo-stage-background: var(--atmo-power-stage-background);
  --atmo-progress-start: var(--atmo-power-progress-start);
  --atmo-progress-end: var(--atmo-power-progress-end);
  --atmo-progress-glow: var(--atmo-power-progress-glow);
  --atmo-counter-background: var(--atmo-power-counter-background);
  --atmo-counter-border: var(--atmo-power-counter-border);
  --atmo-counter-text: var(--atmo-power-counter-text);
  --atmo-title-text: var(--color-text-main);
  --atmo-cue-background: var(--color-surface-card);
  --atmo-cue-border: var(--atmo-power-counter-border);
  --atmo-portal-background: var(--color-surface-card);
  --atmo-portal-glow: var(--atmo-power-progress-glow);
  --atmo-compass-ring: var(--atmo-power-compass-ring);
  --atmo-compass-ring-muted: var(--atmo-power-compass-ring-muted);
  --atmo-compass-glow: var(--atmo-power-compass-glow);
  --atmo-compass-face: var(--atmo-power-compass-face);
}

[data-atmosphere="freeze"] {
  --atmo-stage-background: var(--atmo-freeze-stage-background);
  --atmo-progress-start: var(--atmo-freeze-progress-start);
  --atmo-progress-end: var(--atmo-freeze-progress-end);
  --atmo-progress-glow: var(--atmo-freeze-progress-glow);
  --atmo-counter-background: var(--atmo-freeze-counter-background);
  --atmo-counter-border: var(--atmo-freeze-counter-border);
  --atmo-counter-text: var(--atmo-freeze-counter-text);
  --atmo-title-text: var(--color-text-main);
  --atmo-cue-background: var(--color-surface-card);
  --atmo-cue-border: var(--atmo-freeze-counter-border);
  --atmo-portal-background: var(--color-surface-card);
  --atmo-portal-glow: var(--atmo-freeze-progress-glow);
  --atmo-compass-ring: var(--atmo-freeze-compass-ring);
  --atmo-compass-ring-muted: var(--atmo-freeze-compass-ring-muted);
  --atmo-compass-glow: var(--atmo-freeze-compass-glow);
  --atmo-compass-face: var(--atmo-freeze-compass-face);
}

[data-atmosphere="breath"] {
  --atmo-stage-background: var(--atmo-breath-stage-background);
  --atmo-progress-start: var(--atmo-breath-progress-start);
  --atmo-progress-end: var(--atmo-breath-progress-end);
  --atmo-progress-glow: var(--atmo-breath-progress-glow);
  --atmo-counter-background: var(--atmo-breath-counter-background);
  --atmo-counter-border: var(--atmo-breath-counter-border);
  --atmo-counter-text: var(--atmo-breath-counter-text);
  --atmo-title-text: var(--color-text-main);
  --atmo-cue-background: var(--color-surface-card);
  --atmo-cue-border: var(--atmo-breath-counter-border);
  --atmo-portal-background: var(--color-surface-card);
  --atmo-portal-glow: var(--atmo-breath-progress-glow);
  --atmo-compass-ring: var(--atmo-breath-compass-ring);
  --atmo-compass-ring-muted: var(--atmo-breath-compass-ring-muted);
  --atmo-compass-glow: var(--atmo-breath-compass-glow);
  --atmo-compass-face: var(--atmo-breath-compass-face);
}

/* Gamification and rewards stay distinct from the brand and control blue. */
:root {
  --reward-gold: var(--raw-sun);
  --reward-streak: var(--raw-tiger);
  --reward-pink: var(--raw-berry);
  --reward-on-dark: var(--color-celebration-end);

  --gami-xp: var(--raw-sun);
  --gami-streak: var(--raw-tiger);
  --gami-coins: var(--raw-sky);
  --gami-level: var(--raw-purple);

  --color-game-xp: var(--raw-sun);
  --color-game-streak: var(--raw-tiger);
  --color-game-coins: var(--raw-sky);
  --color-game-level: var(--raw-jungle);
  --color-game-vorrat: var(--raw-amber-769);  /* carry-over gold */

  /* Gradient builders of the session and streak UI */
  --color-session: var(--raw-jungle);
  --color-streak: var(--raw-tiger);

  /* Feature icon backgrounds */
  --color-feature-quest: var(--raw-tiger);
  --color-feature-campaign: var(--raw-sky);
  --color-feature-studio: var(--raw-berry);
  --color-feature-profile: var(--raw-jungle);
  --color-feature-group: var(--raw-purple);
  --color-feature-family: var(--raw-jungle);

  /* Rarity of a card */
  --color-rarity-common: var(--raw-grey-444);
  --color-rarity-common-border: var(--raw-grey-869);
  --color-rarity-common-bg: var(--raw-grey-985);
  --color-rarity-rare: var(--raw-blue-546);
  --color-rarity-rare-border: var(--raw-blue-714);
  --color-rarity-rare-bg: var(--raw-blue-970);
  --color-rarity-epic: var(--raw-purple-558);
  --color-rarity-epic-border: var(--raw-purple-722);
  --color-rarity-epic-bg: var(--raw-purple-977);
  --color-rarity-legendary: var(--raw-orange-666);
  --color-rarity-legendary-border: var(--raw-yellow-837);
  --color-rarity-legendary-bg: var(--raw-yellow-962);

  /* Celebration */
  --color-celebration-end: var(--raw-yellow-916);
  --color-celebration-bg-start: var(--raw-grey-993);
  --color-celebration-bg-mid: var(--raw-yellow-982);
  --color-celebration-bg-end: var(--raw-yellow-966);

  /* Reward card: card flip, stamp, trophy-gold CTA */
  --color-reward-stamp: var(--raw-green-820);
  --shadow-reward-stamp: 0 0 40px var(--raw-green-820-a40);
  --color-reward-cta-text: var(--raw-violet-300);
  --color-reward-cta-start: var(--raw-yellow-940);
  --color-reward-cta-end: var(--raw-yellow-767);

  --shadow-xp: 0 8px 16px -2px var(--raw-sun-a35);
  --shadow-celebration: 0 0 30px var(--raw-yellow-837-a40);
  /* Campaign card glow and dot indicator */
  --shadow-glow-reward: 0 0 50px var(--raw-white-a20);
  --shadow-dot-indicator: 0 0 15px currentColor;

  /* Locked journey node, the gray fallback of the state gradients; the other states come from coachColors.ts. */
  --node-locked-light: var(--raw-grey-922);
  --node-locked-mid: var(--raw-grey-858);
  --node-locked-dark: var(--raw-grey-783);
  --node-locked-shadow: var(--raw-grey-683);
}

/* Story and campaign moments */
:root {
  /* Reward before the reveal: cold-blue suspense */
  --bg-moment-reward: linear-gradient(135deg, var(--raw-indigo-231) 0%, var(--raw-indigo-180) 100%);
  /* Book layouts: warm paper cream */
  --bg-moment-story: var(--raw-yellow-974);
  /* The MagicBook spread */
  --shadow-page-turn-right: 20px 0 50px var(--raw-black-a50);
  --shadow-page-turn-left: -20px 0 50px var(--raw-black-a50);
  /* HUD and overlay text */
  --shadow-text-md: 0 2px 8px var(--raw-black-a30);
  --shadow-text-lg: 0 4px 12px var(--raw-black-a20);

  /* Exercise categories in admin overview cards and pills */
  --color-category-mobility: var(--raw-blue-669);
  --color-category-cardio: var(--raw-orange-762);
  --color-category-kraft: var(--raw-red-712);
  --color-category-yoga: var(--raw-violet-658);
  --color-category-neuro: var(--raw-teal-744);
  --color-category-atmung: var(--raw-lime-807);
  --color-category-spezial: var(--raw-violet-603);

  /* Landing world tour: passport and map */
  --landing-passport-bg: var(--raw-earth);
  --landing-passport-cover: var(--raw-earth);
  --landing-passport-paper: var(--raw-white);
  --landing-map-bg: var(--raw-sky);

  /* Admin analytics: two stacked series, both clear 3:1 against the canvas as graphics. */
  --chart-series-1: var(--control-primary-text);
  --chart-series-2: var(--color-brand-accent-text);
}

/* Mobile shell: safe areas of the device, the mobile header and the bottom navigation. */
:root {
  --safe-area-top: env(safe-area-inset-top, 0px);
  --safe-area-bottom: env(safe-area-inset-bottom, 0px);
  --safe-area-left: env(safe-area-inset-left, 0px);
  --safe-area-right: env(safe-area-inset-right, 0px);
  --header-offset: calc(var(--safe-area-top) + var(--size-56));  /* safe area and the 56px mobile header */
  --shadow-mobile-nav: 0 -10px 30px color-mix(in srgb, var(--raw-earth) 8%, transparent);
}

/* Course (the Kita course): the sizes of its lesson pages, printed sheets and their type, read in the product tone.
   The course reads larger than the apps (nothing on a course screen is smaller than 16px); phone values here, wider
   screens below. */
:root {
  /* Ink, the strong line of a control, the write line and the desk behind a printed sheet. */
  --course-ink: var(--raw-grey-275);
  --course-line-strong: var(--raw-sky-861);
  --course-rule: var(--raw-sky-721);
  --course-print-desk: var(--raw-grey-959);
  --course-number-badge: var(--raw-sky-345);
  --course-shadow-card: 0 12px 32px var(--raw-sky-403-a9);
  --course-shadow-badge: 0 4px 10px var(--raw-sky-345-a22);

  /* Module colours of the printed cards; the lesson sheet uses one as its strip. */
  --course-module-m1: var(--raw-sky-625);
  --course-module-m2: var(--raw-sky-754);
  --course-module-m3: var(--raw-red);
  --course-module-m4: var(--raw-green-569);
  --course-module-m5: var(--raw-sky-721);
  --course-module-m6: var(--raw-orange-727);
  --course-module-m7: var(--raw-rose-715);
  --course-module-m8: var(--raw-purple-477);
  --course-module-m9: var(--raw-sky-312);

  /* Type: the display face carries titles, section headings, number badges and the sentences to the children. */
  --course-type-display: var(--text-4xl);  /* 36px page title */
  --course-type-title: var(--text-28);  /* 28px section heading */
  --course-type-say: var(--text-22);  /* 22px sentence to the children */
  --course-type-lead: var(--text-xl);  /* 20px lead and game description */
  --course-type-heading: var(--text-xl);  /* 20px group and card heading */
  --course-type-number: var(--text-22);  /* 22px number badge */
  --course-type-body: var(--text-lg);  /* 18px reading text */
  --course-type-meta: var(--text-base);  /* 16px navigation, gestures, minutes */
  --course-leading-tight: var(--leading-108);
  --course-leading-snug: var(--leading-130);
  --course-leading-body: var(--leading-155);

  /* Rhythm steps beyond the shared space scale */
  --course-space-10: var(--size-40);
  --course-space-14: var(--size-56);

  /* Shape and focus */
  --course-radius-control: var(--radius-16);
  --course-radius-small: var(--radius-12);
  --course-focus-offset: var(--size-3);
  --course-focus-radius: var(--radius-8);

  /* Controls and bars */
  --course-button-height: var(--size-56);
  --course-button-height-small: var(--size-48);
  --course-button-edge: var(--size-4);
  --course-bar-height: var(--size-56);
  --course-bar-width: var(--size-4);
  --course-rail: var(--size-2);

  /* Page layout */
  --course-gutter: var(--space-5);
  --course-content: var(--size-1040);
  --course-reading: var(--size-760);
  --course-home: var(--size-1140);
  --course-sidebar: var(--size-300);
  --course-thumb: var(--size-112);
  --course-head-thumb: var(--size-208);
  --course-media: var(--size-280);
  --course-head-media: var(--size-420);
  --course-tip: var(--size-360);
  --course-nav-cover: var(--size-64);
  --course-row-thumb: var(--size-104);
  --course-say-thumb: var(--size-152);
  --course-slide: var(--percent-84);
  --course-badge: var(--size-44);
  --course-badge-small: var(--size-32);
  --course-icon: var(--size-22);
  --course-icon-large: var(--size-48);
  --course-portrait: var(--size-96);
  --course-sign: var(--size-72);
  --course-artwork-inset: var(--percent-10);

  /* Motion */
  --course-motion: var(--dur-180);
  --course-ease: var(--ease-out-soft);

  /* Printed material */
  --course-pin-print-size: var(--size-mm-70);
  --course-print-art-width: var(--size-mm-205);
  --course-print-art-height: var(--size-mm-292);
  --course-print-art-padding: var(--size-mm-2-5);

  /* Round crops of the Harry-and-Siggi master for the tip card: offset and zoom per character. */
  --course-portrait-zoom: var(--percent-300);
  --course-portrait-harry-x: var(--percent-minus-142);
  --course-portrait-harry-y: var(--percent-minus-24);
  --course-portrait-siggi-x: var(--percent-minus-45);
  --course-portrait-siggi-y: var(--percent-minus-58);
}

@media (min-width: 640px) {
  :root { --course-gutter: var(--space-8); --course-slide: var(--percent-46); }
}

@media (min-width: 1024px) {
  :root {
    --course-gutter: var(--space-12);
    --course-type-display: var(--text-56);  /* 56px */
    --course-type-title: var(--text-4xl);  /* 36px */
    --course-type-say: var(--text-26);  /* 26px */
    --course-type-lead: var(--text-22);  /* 22px */
    --course-type-number: var(--text-2xl);  /* 24px */
    --course-slide: calc((100% - 2 * var(--space-6)) / 3);
    --course-badge: var(--size-52);
  }
}
