/* ═══════════════════════════════════════════════════════════
   QueryCafe — editorial, but loud

   Print design that grabs you: solid colour blocks, big type,
   dramatic scale jumps. The quiet hairlines are still here —
   they're what makes the loud parts read as deliberate.
   ═══════════════════════════════════════════════════════════ */
/* ── Fonts, served from fonts/ rather than Google: nothing about a visitor
   goes to a third party just to draw the type. Fraunces and IBM Plex, under
   the SIL Open Font License (fonts/OFL-*.txt); latin and latin-ext only,
   which covers every character the lessons use. Fraunces and Plex Sans are
   variable fonts, one file for every weight. ── */
@font-face {
  font-family: 'Fraunces';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(../fonts/fraunces-latin-ext.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Fraunces';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(../fonts/fraunces-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Fraunces';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url(../fonts/fraunces-latin-ext.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Fraunces';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url(../fonts/fraunces-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(../fonts/ibm-plex-mono-400-latin-ext.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(../fonts/ibm-plex-mono-400-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url(../fonts/ibm-plex-mono-500-latin-ext.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url(../fonts/ibm-plex-mono-500-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'IBM Plex Sans';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(../fonts/ibm-plex-sans-latin-ext.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'IBM Plex Sans';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(../fonts/ibm-plex-sans-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'IBM Plex Sans';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url(../fonts/ibm-plex-sans-latin-ext.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'IBM Plex Sans';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url(../fonts/ibm-plex-sans-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'IBM Plex Sans';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url(../fonts/ibm-plex-sans-latin-ext.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'IBM Plex Sans';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url(../fonts/ibm-plex-sans-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}


:root {
  /* The cafe's own colours: crema paper and ink, matcha green for
     the accent, and nude for the warm details (the streak, the loyalty
     card, spare days). At night the green goes almost black and nude
     takes the lead. (Its token is still --caramel, the colour it was.) The red of a coffee cherry is kept for what can't be
     undone. Loud blocks stay loud. */
  --paper:     #f8f3ea;   /* crema */
  --paper-2:   #fffcf6;   /* steamed milk */
  --paper-3:   #efe8db;   /* latte */
  --ink:       #1b1a17;
  --ink-2:     #4f4c45;
  --ink-3:     #625e56;   /* ≥4.5:1 on all three papers - small labels use it */
  --rule:      #dcd4c5;
  --rule-soft: #ebe5d9;

  --accent:     #4f6b26;   /* matcha */
  --on-accent:  #f8f3ea;   /* type reversed out of an accent block */
  --caramel:    #8c5e4d;   /* nude, deep enough for crema type on it */
  --on-caramel: #f8f3ea;
  --danger:     #b23a26;   /* coffee cherry: deleting, starting over */
  --good:       #3f6420;   /* dark enough that the faded text on a win block still clears 4.5:1 */
  --on-good:    #f2f9f2;
  --folio:      #d9cfbd;
  --btn-bg:     #1b1a17;
  --btn-fg:     #f8f3ea;
  /* coffee beans, for the confetti: dark, medium and light roast */
  --bean-1:     #3b2416;
  --bean-2:     #6f4a2e;
  --bean-3:     #b07a4a;

  --t-pandas:   #9e3b2e;
  --t-wrangle:  #7a5c3e;
  --t-ts:       #55613f;
  --t-mpl:      #35586b;
  --t-sns:      #824f62;
  --t-analysis: #3f5a4c;
  --t-sandbox:  #2c6675;
  --t-messy:    #7a6420;
  --t-sql:      #4b4f7a;
  --t-dax:      #a14a00;
  --t-projects: #6a3f8e;
  --t-pbi:      #2456a4;
  --t-stats:    #9b2d6b;
  --t-basics:   #4b6824;   /* matcha, like the app: the course everyone starts on */
  --t-ai:       #5a3fb0;
  --t-algo:     #0e6b8c;
  --t-numpy:    #4d4a46;
  --t-metrics:  #a3243f;
  --t-fc:       #5c6800;
  --t-ml:       #86318f;
  --t-excel:    #1d6f42;
  --t-r:        #35608f;
  --t-etl:      #18695f;

  /* Fraunces is variable on opsz 9..144, so the browser picks display forms
     for the big headlines and text forms for the small ones on its own. */
  --serif: "Fraunces", "Iowan Old Style", Georgia, "Times New Roman", serif;
  --sans:  "IBM Plex Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono:  "IBM Plex Mono", ui-monospace, "SF Mono", Consolas, monospace;

  --tap: 52px;
  --gut: 20px;
  --safe-top:    env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* Dark: from the device, unless You → Display picked light. The same values
   again under [data-theme="dark"] for picking dark on a light device -
   change one block, change both. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper:     #12150d;   /* the cafe at night: matcha so dark it reads as black */
    --paper-2:   #181c12;
    --paper-3:   #1e2317;
    --ink:       #f1eadf;   /* crema */
    --ink-2:     #b7bba8;
    --ink-3:     #9a9e8a;   /* ≥4.5:1 on all three papers */
    --rule:      #2e3326;
    --rule-soft: #20251a;

    --accent:     #dcae9a;   /* nude */
    --on-accent:  #12150d;
    --caramel:    #dcae9a;
    --on-caramel: #12150d;
    --danger:     #f07050;
    --good:       #a8cc72;
    --on-good:    #12160c;
    --folio:      #2b3324;
    --btn-bg:     #f1eadf;
    --btn-fg:     #12150d;
    --bean-1:     #c08a5a;
    --bean-2:     #8f6040;
    --bean-3:     #e2bf93;

    --t-pandas:   #ef7a63;
    --t-wrangle:  #d9a874;
    --t-ts:       #adbd84;
    --t-mpl:      #7cb2cc;
    --t-sns:      #dd94ab;
    --t-analysis: #83c39c;
    --t-sandbox:  #6cc0d4;
    --t-messy:    #d4b45c;
    --t-sql:      #a3a8e0;
    --t-dax:      #f0a35a;
    --t-projects: #c39be3;
    --t-pbi:      #8fb3f0;
    --t-stats:    #f08cc0;
    --t-basics:   #b0cf7e;
    --t-ai:       #b3a3f5;
    --t-algo:     #7fcbe6;
    --t-numpy:    #d3cabf;
    --t-metrics:  #f2879d;
    --t-fc:       #c5d46a;
    --t-ml:       #e09be8;
    --t-excel:    #7fd39f;
    --t-r:        #9dbbe0;
    --t-etl:      #74d1c2;
  }
}
:root[data-theme="dark"] {
  --paper:     #12150d;
  --paper-2:   #181c12;
  --paper-3:   #1e2317;
  --ink:       #f1eadf;
  --ink-2:     #b7bba8;
  --ink-3:     #9a9e8a;
  --rule:      #2e3326;
  --rule-soft: #20251a;

  --accent:     #dcae9a;
  --on-accent:  #12150d;
  --caramel:    #dcae9a;
  --on-caramel: #12150d;
  --danger:     #f07050;
  --good:       #a8cc72;
  --on-good:    #12160c;
  --folio:      #2b3324;
  --btn-bg:     #f1eadf;
  --btn-fg:     #12150d;
  --bean-1:     #c08a5a;
  --bean-2:     #8f6040;
  --bean-3:     #e2bf93;

  --t-pandas:   #ef7a63;
  --t-wrangle:  #d9a874;
  --t-ts:       #adbd84;
  --t-mpl:      #7cb2cc;
  --t-sns:      #dd94ab;
  --t-analysis: #83c39c;
  --t-sandbox:  #6cc0d4;
  --t-messy:    #d4b45c;
  --t-sql:      #a3a8e0;
  --t-dax:      #f0a35a;
  --t-projects: #c39be3;
  --t-pbi:      #8fb3f0;
  --t-stats:    #f08cc0;
  --t-basics:   #b0cf7e;
  --t-ai:       #b3a3f5;
  --t-algo:     #7fcbe6;
  --t-numpy:    #d3cabf;
  --t-metrics:  #f2879d;
  --t-fc:       #c5d46a;
  --t-ml:       #e09be8;
  --t-excel:    #7fd39f;
    --t-r:        #9dbbe0;
  --t-etl:      #74d1c2;
}
:root[data-theme="dark"] { color-scheme: dark; }
:root[data-theme="light"] { color-scheme: light; }

/* ── Colour themes (You → Settings → Display) ─────────────────
   Each is a pair, like the house colours: one colour by day, and a partner
   that leads at night (and shows by day, deeper, in the warm details: the
   streak, the loyalty card, spare days), on a night paper tinted by the day
   colour. Each sets the base tokens above, light and dark, and pairs with
   the light-or-dark setting. [data-palette] goes on the root for the whole
   app, and on a swatch in Settings, which shows both halves of the pair
   (--sw-*) whichever mode is on. Matcha is the default and repeats the tokens
   above, for its swatch. The dark values appear twice, as above: for a dark
   device, and for Dark picked on a light one. Every pair clears 4.5:1, track
   inks on these papers included. js/display.js keeps each theme's two paper
   colours too, for the browser's bar. */
/* matcha */
[data-palette="matcha"] {
  --paper: #f8f3ea;
  --paper-2: #fffcf6;
  --paper-3: #efe8db;
  --ink: #1b1a17;
  --ink-2: #4f4c45;
  --ink-3: #625e56;
  --rule: #dcd4c5;
  --rule-soft: #ebe5d9;
  --accent: #4f6b26;
  --on-accent: #f8f3ea;
  --caramel: #8c5e4d;
  --on-caramel: #f8f3ea;
  --folio: #d9cfbd;
  --btn-bg: #1b1a17;
  --btn-fg: #f8f3ea;
  --sw-day: #4f6b26;
  --sw-day-paper: #f8f3ea;
  --sw-night: #dcae9a;
  --sw-night-paper: #12150d;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"])[data-palette="matcha"],
  :root:not([data-theme="light"]) [data-palette="matcha"] {
    --paper: #12150d;
    --paper-2: #181c12;
    --paper-3: #1e2317;
    --ink: #f1eadf;
    --ink-2: #b7bba8;
    --ink-3: #9a9e8a;
    --rule: #2e3326;
    --rule-soft: #20251a;
    --accent: #dcae9a;
    --on-accent: #12150d;
    --caramel: #dcae9a;
    --on-caramel: #12150d;
    --folio: #2b3324;
    --btn-bg: #f1eadf;
    --btn-fg: #12150d;
  }
}
:root[data-theme="dark"][data-palette="matcha"],
:root[data-theme="dark"] [data-palette="matcha"] {
  --paper: #12150d;
  --paper-2: #181c12;
  --paper-3: #1e2317;
  --ink: #f1eadf;
  --ink-2: #b7bba8;
  --ink-3: #9a9e8a;
  --rule: #2e3326;
  --rule-soft: #20251a;
  --accent: #dcae9a;
  --on-accent: #12150d;
  --caramel: #dcae9a;
  --on-caramel: #12150d;
  --folio: #2b3324;
  --btn-bg: #f1eadf;
  --btn-fg: #12150d;
}
/* espresso */
[data-palette="espresso"] {
  --paper: #f7f1e8;
  --paper-2: #fffbf5;
  --paper-3: #ede4d6;
  --ink: #1d1712;
  --ink-2: #51473e;
  --ink-3: #62574c;
  --rule: #ddd2c2;
  --rule-soft: #ece4d8;
  --accent: #6b4226;
  --on-accent: #f7f1e8;
  --caramel: #99561c;
  --on-caramel: #fff8ee;
  --folio: #dccdb8;
  --btn-bg: #1d1712;
  --btn-fg: #f7f1e8;
  --sw-day: #6b4226;
  --sw-day-paper: #f7f1e8;
  --sw-night: #e0a35e;
  --sw-night-paper: #15110e;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"])[data-palette="espresso"],
  :root:not([data-theme="light"]) [data-palette="espresso"] {
    --paper: #15110e;
    --paper-2: #1c1713;
    --paper-3: #241d18;
    --ink: #f2e8dc;
    --ink-2: #c2b5a6;
    --ink-3: #a6998a;
    --rule: #3a3029;
    --rule-soft: #261f1a;
    --accent: #e0a35e;
    --on-accent: #15110e;
    --caramel: #e0a35e;
    --on-caramel: #15110e;
    --folio: #3a2f27;
    --btn-bg: #f2e8dc;
    --btn-fg: #15110e;
  }
}
:root[data-theme="dark"][data-palette="espresso"],
:root[data-theme="dark"] [data-palette="espresso"] {
  --paper: #15110e;
  --paper-2: #1c1713;
  --paper-3: #241d18;
  --ink: #f2e8dc;
  --ink-2: #c2b5a6;
  --ink-3: #a6998a;
  --rule: #3a3029;
  --rule-soft: #261f1a;
  --accent: #e0a35e;
  --on-accent: #15110e;
  --caramel: #e0a35e;
  --on-caramel: #15110e;
  --folio: #3a2f27;
  --btn-bg: #f2e8dc;
  --btn-fg: #15110e;
}
/* blueberry */
[data-palette="blueberry"] {
  --paper: #f4f6fa;
  --paper-2: #fbfcfe;
  --paper-3: #e8edf5;
  --ink: #161a22;
  --ink-2: #474e5c;
  --ink-3: #56606f;
  --rule: #d3dae6;
  --rule-soft: #e5eaf2;
  --accent: #2d55a0;
  --on-accent: #f4f6fa;
  --caramel: #765a00;
  --on-caramel: #fffbea;
  --folio: #cdd5e3;
  --btn-bg: #161a22;
  --btn-fg: #f4f6fa;
  --sw-day: #2d55a0;
  --sw-day-paper: #f4f6fa;
  --sw-night: #f2d36b;
  --sw-night-paper: #0f131b;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"])[data-palette="blueberry"],
  :root:not([data-theme="light"]) [data-palette="blueberry"] {
    --paper: #0f131b;
    --paper-2: #151a24;
    --paper-3: #1b212d;
    --ink: #e8edf5;
    --ink-2: #b0b8c7;
    --ink-3: #939cad;
    --rule: #2a3241;
    --rule-soft: #1c2230;
    --accent: #f2d36b;
    --on-accent: #0f131b;
    --caramel: #f2d36b;
    --on-caramel: #0f131b;
    --folio: #263042;
    --btn-bg: #e8edf5;
    --btn-fg: #0f131b;
  }
}
:root[data-theme="dark"][data-palette="blueberry"],
:root[data-theme="dark"] [data-palette="blueberry"] {
  --paper: #0f131b;
  --paper-2: #151a24;
  --paper-3: #1b212d;
  --ink: #e8edf5;
  --ink-2: #b0b8c7;
  --ink-3: #939cad;
  --rule: #2a3241;
  --rule-soft: #1c2230;
  --accent: #f2d36b;
  --on-accent: #0f131b;
  --caramel: #f2d36b;
  --on-caramel: #0f131b;
  --folio: #263042;
  --btn-bg: #e8edf5;
  --btn-fg: #0f131b;
}
/* hibiscus */
[data-palette="hibiscus"] {
  --paper: #fbf4f3;
  --paper-2: #fffafa;
  --paper-3: #f3e6e5;
  --ink: #1f1517;
  --ink-2: #57464a;
  --ink-3: #67555a;
  --rule: #e6d3d3;
  --rule-soft: #f1e4e3;
  --accent: #a3264f;
  --on-accent: #fbf4f3;
  --caramel: #2a6a52;
  --on-caramel: #f3fbf7;
  --folio: #e5cccc;
  --btn-bg: #1f1517;
  --btn-fg: #fbf4f3;
  --sw-day: #a3264f;
  --sw-day-paper: #fbf4f3;
  --sw-night: #8fdcb8;
  --sw-night-paper: #170f12;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"])[data-palette="hibiscus"],
  :root:not([data-theme="light"]) [data-palette="hibiscus"] {
    --paper: #170f12;
    --paper-2: #1e1418;
    --paper-3: #261a1f;
    --ink: #f5e8eb;
    --ink-2: #c9b1b8;
    --ink-3: #ad959c;
    --rule: #3d2a31;
    --rule-soft: #281b20;
    --accent: #8fdcb8;
    --on-accent: #170f12;
    --caramel: #8fdcb8;
    --on-caramel: #170f12;
    --folio: #3a2730;
    --btn-bg: #f5e8eb;
    --btn-fg: #170f12;
  }
}
:root[data-theme="dark"][data-palette="hibiscus"],
:root[data-theme="dark"] [data-palette="hibiscus"] {
  --paper: #170f12;
  --paper-2: #1e1418;
  --paper-3: #261a1f;
  --ink: #f5e8eb;
  --ink-2: #c9b1b8;
  --ink-3: #ad959c;
  --rule: #3d2a31;
  --rule-soft: #281b20;
  --accent: #8fdcb8;
  --on-accent: #170f12;
  --caramel: #8fdcb8;
  --on-caramel: #170f12;
  --folio: #3a2730;
  --btn-bg: #f5e8eb;
  --btn-fg: #170f12;
}
/* earlgrey */
[data-palette="earlgrey"] {
  --paper: #f5f4f2;
  --paper-2: #fcfbfa;
  --paper-3: #eae8e4;
  --ink: #1a1a1c;
  --ink-2: #4a4a50;
  --ink-3: #5a5a61;
  --rule: #d8d6d2;
  --rule-soft: #e8e6e2;
  --accent: #46586b;
  --on-accent: #f5f4f2;
  --caramel: #66579a;
  --on-caramel: #faf8ff;
  --folio: #d6d3ce;
  --btn-bg: #1a1a1c;
  --btn-fg: #f5f4f2;
  --sw-day: #46586b;
  --sw-day-paper: #f5f4f2;
  --sw-night: #c7bcf0;
  --sw-night-paper: #131315;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"])[data-palette="earlgrey"],
  :root:not([data-theme="light"]) [data-palette="earlgrey"] {
    --paper: #131315;
    --paper-2: #19191c;
    --paper-3: #202024;
    --ink: #ebeae7;
    --ink-2: #b3b2b0;
    --ink-3: #97969a;
    --rule: #2f2f34;
    --rule-soft: #222226;
    --accent: #c7bcf0;
    --on-accent: #131315;
    --caramel: #c7bcf0;
    --on-caramel: #131315;
    --folio: #2c2c31;
    --btn-bg: #ebeae7;
    --btn-fg: #131315;
  }
}
:root[data-theme="dark"][data-palette="earlgrey"],
:root[data-theme="dark"] [data-palette="earlgrey"] {
  --paper: #131315;
  --paper-2: #19191c;
  --paper-3: #202024;
  --ink: #ebeae7;
  --ink-2: #b3b2b0;
  --ink-3: #97969a;
  --rule: #2f2f34;
  --rule-soft: #222226;
  --accent: #c7bcf0;
  --on-accent: #131315;
  --caramel: #c7bcf0;
  --on-caramel: #131315;
  --folio: #2c2c31;
  --btn-bg: #ebeae7;
  --btn-fg: #131315;
}
/* contrast */
[data-palette="contrast"] {
  --paper: #ffffff;
  --paper-2: #ffffff;
  --paper-3: #f0f0f0;
  --ink: #000000;
  --ink-2: #1f1f1f;
  --ink-3: #333333;
  --rule: #767676;
  --rule-soft: #bdbdbd;
  --accent: #0b3fa8;
  --on-accent: #ffffff;
  --caramel: #6b5000;
  --on-caramel: #ffffff;
  --folio: #d0d0d0;
  --btn-bg: #000000;
  --btn-fg: #ffffff;
  --sw-day: #0b3fa8;
  --sw-day-paper: #ffffff;
  --sw-night: #ffd84a;
  --sw-night-paper: #000000;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"])[data-palette="contrast"],
  :root:not([data-theme="light"]) [data-palette="contrast"] {
    --paper: #000000;
    --paper-2: #0a0a0a;
    --paper-3: #161616;
    --ink: #ffffff;
    --ink-2: #e6e6e6;
    --ink-3: #cccccc;
    --rule: #8a8a8a;
    --rule-soft: #444444;
    --accent: #ffd84a;
    --on-accent: #000000;
    --caramel: #ffd84a;
    --on-caramel: #000000;
    --folio: #333333;
    --btn-bg: #ffffff;
    --btn-fg: #000000;
  }
}
:root[data-theme="dark"][data-palette="contrast"],
:root[data-theme="dark"] [data-palette="contrast"] {
  --paper: #000000;
  --paper-2: #0a0a0a;
  --paper-3: #161616;
  --ink: #ffffff;
  --ink-2: #e6e6e6;
  --ink-3: #cccccc;
  --rule: #8a8a8a;
  --rule-soft: #444444;
  --accent: #ffd84a;
  --on-accent: #000000;
  --caramel: #ffd84a;
  --on-caramel: #000000;
  --folio: #333333;
  --btn-bg: #ffffff;
  --btn-fg: #000000;
}

/* Text size (You → Display). The sizes here are px, so the screen's content
   is zoomed as a whole: type, spacing and touch targets stay in proportion. */
:root[data-size="small"] .screen > .stack { zoom: .9; }
:root[data-size="large"] .screen > .stack { zoom: 1.15; }

* { box-sizing: border-box; }
/* The page itself scrolls, not a box inside it: a phone browser only tucks
   its address bar away as you scroll down (and brings it back as you scroll
   up) when the page is what scrolls. The top bar and tab bar stick to the
   edges (.top-chrome, .tabbar); scrolling to something stops it just under
   the top bar (its height, --chrome-top, kept by main.js) and clear of the
   tab bar. Overscroll is left alone, so pulling down at the top still
   refreshes on a phone (drafts are saved as you type). */
html {
  min-height: 100%;
  scroll-padding-top: var(--chrome-top, 58px);
  scroll-padding-bottom: calc(56px + var(--safe-bottom));
}
body { min-height: 100%; }

body {
  margin: 0;
  /* Plain paper. The faint grid that matched the portfolio is gone: in light
     mode it was the same colour as the hairline rules that do real work, and
     it ran behind everything you read. The grain below is the only texture. */
  background-color: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16.5px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  font-variant-numeric: tabular-nums;
}

/* paper grain — lifts the whole thing off flat colour */
body::after {
  content: ""; position: fixed; inset: 0; z-index: 99; pointer-events: none;
  opacity: .035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
}
/* a touch more grain at night, or it vanishes on the near-black ground */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) body::after { opacity: .05; }
}
:root[data-theme="dark"] body::after { opacity: .05; }

/* Things on the paper, never behind the reading itself: two faint coffee-ring
   stains at the screen's edges, scrolling with it the way a mark on a menu
   would, and on a wide screen, beans scattered in the empty side margins. */
:root {
  --rings: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 200'%3E%3Cg fill='none' stroke='%237a4a22'%3E%3Ccircle cx='100' cy='100' r='82' stroke-width='5' stroke-opacity='.11'/%3E%3Ccircle cx='100' cy='100' r='77.5' stroke-width='2' stroke-opacity='.08' stroke-dasharray='150 25 90 40 220'/%3E%3Cpath d='M28 128 A82 82 0 0 0 152 166' stroke-width='11' stroke-opacity='.05' stroke-linecap='round'/%3E%3C/g%3E%3C/svg%3E");
  --beans: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 180 180'%3E%3Cg fill='%237a4a22' fill-opacity='.08'%3E%3Cellipse cx='34' cy='38' rx='9' ry='13' transform='rotate(-25 34 38)'/%3E%3Cellipse cx='128' cy='26' rx='8' ry='12' transform='rotate(40 128 26)'/%3E%3Cellipse cx='86' cy='96' rx='9.5' ry='13.5' transform='rotate(12 86 96)'/%3E%3Cellipse cx='22' cy='142' rx='8' ry='12' transform='rotate(70 22 142)'/%3E%3Cellipse cx='150' cy='132' rx='9' ry='13' transform='rotate(-55 150 132)'/%3E%3C/g%3E%3Cg fill='none' stroke='%23f8f3ea' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M38 27 C30 34 38 42 30 49' /%3E%3Cpath d='M121 20 C129 25 127 31 135 32'/%3E%3Cpath d='M84 83 C80 92 92 100 88 109'/%3E%3Cpath d='M14 140 C20 136 24 148 30 144'/%3E%3Cpath d='M141 126 C150 127 150 138 159 138'/%3E%3C/g%3E%3C/svg%3E");
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --rings: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 200'%3E%3Cg fill='none' stroke='%23e2bf93'%3E%3Ccircle cx='100' cy='100' r='82' stroke-width='5' stroke-opacity='.075'/%3E%3Ccircle cx='100' cy='100' r='77.5' stroke-width='2' stroke-opacity='.055' stroke-dasharray='150 25 90 40 220'/%3E%3Cpath d='M28 128 A82 82 0 0 0 152 166' stroke-width='11' stroke-opacity='.035' stroke-linecap='round'/%3E%3C/g%3E%3C/svg%3E");
    --beans: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 180 180'%3E%3Cg fill='%23e2bf93' fill-opacity='.06'%3E%3Cellipse cx='34' cy='38' rx='9' ry='13' transform='rotate(-25 34 38)'/%3E%3Cellipse cx='128' cy='26' rx='8' ry='12' transform='rotate(40 128 26)'/%3E%3Cellipse cx='86' cy='96' rx='9.5' ry='13.5' transform='rotate(12 86 96)'/%3E%3Cellipse cx='22' cy='142' rx='8' ry='12' transform='rotate(70 22 142)'/%3E%3Cellipse cx='150' cy='132' rx='9' ry='13' transform='rotate(-55 150 132)'/%3E%3C/g%3E%3Cg fill='none' stroke='%2312150d' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M38 27 C30 34 38 42 30 49' /%3E%3Cpath d='M121 20 C129 25 127 31 135 32'/%3E%3Cpath d='M84 83 C80 92 92 100 88 109'/%3E%3Cpath d='M14 140 C20 136 24 148 30 144'/%3E%3Cpath d='M141 126 C150 127 150 138 159 138'/%3E%3C/g%3E%3C/svg%3E");
  }
}
:root[data-theme="dark"] {
  --rings: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 200'%3E%3Cg fill='none' stroke='%23e2bf93'%3E%3Ccircle cx='100' cy='100' r='82' stroke-width='5' stroke-opacity='.075'/%3E%3Ccircle cx='100' cy='100' r='77.5' stroke-width='2' stroke-opacity='.055' stroke-dasharray='150 25 90 40 220'/%3E%3Cpath d='M28 128 A82 82 0 0 0 152 166' stroke-width='11' stroke-opacity='.035' stroke-linecap='round'/%3E%3C/g%3E%3C/svg%3E");
  --beans: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 180 180'%3E%3Cg fill='%23e2bf93' fill-opacity='.06'%3E%3Cellipse cx='34' cy='38' rx='9' ry='13' transform='rotate(-25 34 38)'/%3E%3Cellipse cx='128' cy='26' rx='8' ry='12' transform='rotate(40 128 26)'/%3E%3Cellipse cx='86' cy='96' rx='9.5' ry='13.5' transform='rotate(12 86 96)'/%3E%3Cellipse cx='22' cy='142' rx='8' ry='12' transform='rotate(70 22 142)'/%3E%3Cellipse cx='150' cy='132' rx='9' ry='13' transform='rotate(-55 150 132)'/%3E%3C/g%3E%3Cg fill='none' stroke='%2312150d' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M38 27 C30 34 38 42 30 49' /%3E%3Cpath d='M121 20 C129 25 127 31 135 32'/%3E%3Cpath d='M84 83 C80 92 92 100 88 109'/%3E%3Cpath d='M14 140 C20 136 24 148 30 144'/%3E%3Cpath d='M141 126 C150 127 150 138 159 138'/%3E%3C/g%3E%3C/svg%3E");
}

svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ── Type ─────────────────────────────────────────────────── */

.label {
  font-size: 10.5px; font-weight: 600; letter-spacing: .16em;
  text-transform: uppercase; color: var(--ink-3);
}
/* section heads get a hard accent tick — a full stop before the words */
.label-mark { display: flex; align-items: center; gap: 9px; color: var(--ink); }
.label-mark::before {
  content: ""; width: 20px; height: 4px; background: var(--accent); flex: none;
}

/* Sized down from the Instrument Serif days: Fraunces sets wider and
   heavier, so it holds the page at a smaller size and fits more per line. */
.display {
  font-family: var(--serif); font-weight: 400;
  font-size: clamp(31px, 9.1vw, 45px); line-height: 1.04;
  letter-spacing: -.014em; margin: 0;
  text-wrap: balance;   /* no lone word stranded on the last line */
}
.display-xl {
  font-family: var(--serif); font-weight: 400;
  font-size: clamp(40px, 12.8vw, 62px); line-height: .98; letter-spacing: -.022em; margin: 0;
  text-wrap: balance;
}

.folio {
  font-family: var(--serif); font-size: 46px; line-height: 1;
  color: var(--folio); letter-spacing: -.02em;
}

.muted { color: var(--ink-2); }
.stack > * + * { margin-top: 22px; }

/* Changing screens (main.js, render and fadeAway). A still copy of the
   screen you're leaving stays over the new one for a moment and fades out,
   so there's never a blank frame: a cross-fade. A new page also rises gently
   into place under it, its parts a beat apart, quick enough to read as
   momentum, not delay. A sub-page (the same screen again: You's sections,
   Practice's subjects, the Sandbox's languages) only cross-fades, so the
   parts that didn't change don't move at all. The copy is new to the page,
   so its own animations (this rise, a stamp landing) would start over: they
   start long finished instead, and it fades out looking as it did. */
.app { position: relative; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.screen > .stack > * { animation: rise .34s cubic-bezier(.22, .8, .32, 1) backwards; }
.screen > .stack > *:nth-child(2) { animation-delay: .04s; }
.screen > .stack > *:nth-child(3) { animation-delay: .07s; }
.screen > .stack > *:nth-child(4) { animation-delay: .1s; }
.screen > .stack > *:nth-child(5) { animation-delay: .12s; }
.screen > .stack > *:nth-child(n+6) { animation-delay: .14s; }
.screen.is-sub > .stack > * { animation: none; }
.screen-ghost { z-index: 3; pointer-events: none; overflow: hidden; animation: screen-out .2s ease-out forwards; }
.screen-ghost.is-page { animation-name: screen-out-up; }
.screen-ghost *, .screen-ghost *::before, .screen-ghost *::after { animation-delay: -60s !important; }
@keyframes screen-out { to { opacity: 0; } }
@keyframes screen-out-up { to { opacity: 0; transform: translateY(-6px); } }

/* ── Boot ─────────────────────────────────────────────────── */

.boot {
  position: fixed; inset: 0; z-index: 50;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 40px var(--gut); background: var(--paper); text-align: center;
}
.boot.is-gone { opacity: 0; pointer-events: none; transition: opacity .5s ease; }
.boot-inner { width: min(340px, 100%); }
.boot-kicker {
  margin: 0 0 8px; font-size: 10.5px; font-weight: 600;
  letter-spacing: .2em; text-transform: uppercase; color: var(--accent);
}
.boot-word {
  margin: 0 0 26px; font-family: var(--serif); font-weight: 400;
  font-size: min(58px, 16.5vw); line-height: 1; letter-spacing: -.025em;
}
.boot-word b { font-weight: inherit; color: var(--accent); }
/* The icon, big, its steam brewing bar by bar until the engine is ready. */
.boot .boot-mark {
  display: block; width: 76px; height: 76px; margin: 0 auto 22px; border-radius: 17px;
}
.boot .boot-mark .brand-bar {
  transform-box: fill-box; transform-origin: 50% 100%;
  animation: brew 1.3s ease-in-out var(--d) infinite alternate;
}
@keyframes brew { from { transform: scaleY(.35); } to { transform: scaleY(1); } }
.boot-rule { height: 3px; background: var(--rule); position: relative; overflow: hidden; }
.boot-rule i {
  position: absolute; inset: 0 auto 0 0; width: 4%;
  background: var(--accent); transition: width .5s cubic-bezier(.2,.8,.2,1);
}
.boot-status { margin: 14px 0 0; font-size: 13px; color: var(--ink-2); }
.boot-foot {
  position: absolute; bottom: calc(28px + var(--safe-bottom));
  margin: 0; font-size: 12px; line-height: 1.6; color: var(--ink-3);
}

/* ── Shell ────────────────────────────────────────────────── */

.app { display: flex; flex-direction: column; min-height: 100dvh; }
.top-chrome { position: sticky; top: 0; z-index: 10; }

.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: calc(var(--safe-top) + 13px) var(--gut) 11px;
  border-bottom: 1px solid var(--rule);
  background: var(--paper);
}
.topbar-title {
  flex: 1; font-size: 11px; font-weight: 600; letter-spacing: .16em;
  text-transform: uppercase; color: var(--ink-2);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  line-height: 26px;            /* the brand's height, so the bar doesn't jump leaving Home */
}

/* Home: the brand. The icon as it sits on your home screen, then the name in
   the display serif, its second half in the accent. */
.topbar-title.is-brand {
  display: flex; align-items: center; gap: 9px;
  letter-spacing: 0; text-transform: none; color: var(--ink);
}
/* Tapping the brand reloads the app (main.js). */
.topbar-title.is-brand .brand-mark,
.topbar-title.is-brand .brand-word { cursor: pointer; }
.topbar-title.is-brand:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
.brand-mark {
  flex: none; width: 26px; height: 26px; border-radius: 6px;
  box-shadow: 0 0 0 1px var(--rule);   /* the tile's edge, on the night paper too */
}

.brand-word {
  font-family: var(--serif); font-weight: 600; font-size: 21px; line-height: 1;
  letter-spacing: -.02em; color: var(--ink);
}
.brand-word b { font-weight: 600; color: var(--accent); }
/* Once a session the steam rises, bar by bar, the way the chart it is would. */
.is-rising .brand-bar {
  transform-box: fill-box; transform-origin: 50% 100%;
  animation: steam .6s cubic-bezier(.2, 1.3, .4, 1) var(--d) both;
}
@keyframes steam { from { transform: scaleY(.15); opacity: 0; } to { transform: scaleY(1); opacity: 1; } }
.back {
  display: grid; place-items: center; width: 26px; height: 26px; flex: none;
  margin-left: -3px; border: none; background: none; cursor: pointer; color: var(--ink);
}
.back:active { transform: translateX(-2px); }

/* Background sounds: the headphones in the top bar, nude and moving
   while they play, and the panel they open (js/ambience.js). */
.amb-btn {
  flex: none; position: relative; display: grid; place-items: center;
  width: 32px; height: 30px; margin-right: -4px; padding: 0;
  border: none; border-radius: 6px; background: none; color: var(--ink-3); cursor: pointer;
}
.amb-btn::after { content: ""; position: absolute; inset: -8px -4px; }   /* a fingertip-sized target */
.amb-btn svg { width: 22px; height: 22px; }
.amb-btn.is-on { color: var(--caramel); }
.amb-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.amb-bars rect { fill: currentColor; stroke: none; opacity: 0; transform-box: fill-box; transform-origin: 50% 100%; }
.amb-btn.is-on .amb-bars rect { opacity: 1; animation: amb-eq .9s ease-in-out infinite alternate; }
.amb-btn.is-on .amb-bars rect:nth-child(2) { animation-delay: -.3s; }
.amb-btn.is-on .amb-bars rect:nth-child(3) { animation-delay: -.6s; }
@keyframes amb-eq { from { transform: scaleY(.3); } to { transform: scaleY(1); } }
.amb-panel {
  position: fixed; z-index: 85; padding: 16px 16px 14px;
  border: 1px solid var(--rule); border-radius: 8px;
  background: var(--paper); color: var(--ink); box-shadow: 0 12px 30px rgba(0, 0, 0, .22);
}
.amb-title { margin: 0; font-family: var(--serif); font-size: 19px; font-weight: 600; line-height: 1.2; }
.amb-note { margin: 5px 0 12px; font-size: 13.5px; line-height: 1.45; color: var(--ink-2); }
/* Once sounds have started: pause or play, and stop, as two small round
   buttons right beside the headphones. */
.amb-strip { display: flex; align-items: center; gap: 2px; flex: none; margin-left: -6px; }
.amb-strip[hidden] { display: none; }
.amb-strip-btn {
  flex: none; position: relative; display: grid; place-items: center; width: 28px; height: 28px; padding: 0;
  border: none; border-radius: 50%; background: none; color: var(--caramel); cursor: pointer;
}
.amb-strip-btn::after { content: ""; position: absolute; inset: -6px -2px; }   /* a fingertip-sized target */
.amb-strip-btn:hover { background: var(--paper-2); }
.amb-strip-btn svg { width: 14px; height: 14px; stroke-width: 2; }
.amb-strip-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.amb-strip-x { color: var(--ink-3); }
.amb-strip-x svg { width: 12px; height: 12px; }

/* One row per layer: its on/off chip, then its own volume. */
.amb-mix { display: grid; gap: 8px; margin: 12px 0; }
.amb-row { display: grid; grid-template-columns: 124px minmax(0, 1fr); align-items: center; gap: 12px; }
.amb-row .filter { padding: 0 8px; letter-spacing: .08em; }
.amb-row input { min-width: 0; accent-color: var(--caramel); }
.amb-row:not(.is-on) input { opacity: .45; }   /* still settable, ready for when it's on */
.amb-vol { display: flex; align-items: center; gap: 12px; min-height: 40px; }
.amb-vol .label { margin: 0; }
.amb-vol input { flex: 1; min-width: 0; accent-color: var(--caramel); }

.streak {
  flex: none; display: flex; align-items: baseline; gap: 5px;
  padding: 3px 10px; border-radius: 2px;
  background: var(--caramel); color: var(--on-caramel);
}
.streak span:first-child { font-family: var(--serif); font-size: 19px; line-height: 1; }
.streak-unit { font-size: 9.5px; font-weight: 600; letter-spacing: .13em; text-transform: uppercase; }
.streak.is-cold { background: none; color: var(--ink-3); padding-left: 0; padding-right: 0; }
/* The cup in the chip: cold until something's finished today, then steaming. */
.streak-cup { flex: none; width: 15px; height: 15px; align-self: center; margin-right: 1px; overflow: visible; }
.streak.is-loading .streak-cup { display: none; }
.streak-steam path { opacity: 0; }
.streak.is-warm .streak-steam path { animation: wisp 2.2s ease-in-out var(--d) infinite; }
@keyframes wisp {
  0%   { opacity: 0; transform: translateY(2px); }
  35%  { opacity: .95; }
  100% { opacity: 0; transform: translateY(-3px); }
}
@keyframes flare { 0% { transform: scale(1); } 40% { transform: scale(1.22); } 100% { transform: scale(1); } }
.streak.is-flaring { animation: flare .5s cubic-bezier(.2,1.4,.4,1); }

.screen {
  flex: 1;
  padding: 24px var(--gut) 44px;
  /* two coffee rings, at the edges, moving with the page (see --rings) */
  background-image: var(--rings), var(--rings);
  background-repeat: no-repeat;
  background-size: 230px, 290px;
  background-position: right -104px top 64px, left -150px top 720px;
  background-attachment: local;
}
.screen:focus { outline: none; }

/* ── Scrollbars ───────────────────────────────────────────────
   Desktop draws a chunky system scrollbar that has nothing to do
   with this palette. Phones overlay a thin one that fades out, which
   is the behaviour worth copying: present when you need it, quiet
   otherwise. Still a real scrollbar — hiding it would remove the only
   hint that a long lesson continues below. */
html, .out-body, .editor, .reveal-body pre {
  scrollbar-width: thin;
  scrollbar-color: var(--rule) transparent;
}
html::-webkit-scrollbar,
.out-body::-webkit-scrollbar,
.editor::-webkit-scrollbar,
.reveal-body pre::-webkit-scrollbar { width: 11px; height: 11px; }

html::-webkit-scrollbar-track,
.out-body::-webkit-scrollbar-track,
.editor::-webkit-scrollbar-track,
.reveal-body pre::-webkit-scrollbar-track { background: transparent; }

html::-webkit-scrollbar-thumb,
.out-body::-webkit-scrollbar-thumb,
.editor::-webkit-scrollbar-thumb,
.reveal-body pre::-webkit-scrollbar-thumb {
  background: var(--rule);
  background-clip: content-box;
  border: 3px solid transparent;   /* inset, so the thumb reads as a hairline */
  border-radius: 99px;
}
html:hover::-webkit-scrollbar-thumb,
.out-body:hover::-webkit-scrollbar-thumb,
.editor:hover::-webkit-scrollbar-thumb { background: var(--ink-3); background-clip: content-box; }

html::-webkit-scrollbar-corner { background: transparent; }

.tabbar {
  position: sticky; bottom: 0; z-index: 10; display: grid; grid-template-columns: repeat(5, 1fr);
  border-top: 1px solid var(--rule);
  background: var(--paper); padding-bottom: var(--safe-bottom);
}
.tab {
  position: relative; padding: 14px 4px 13px;
  border: none; background: none; cursor: pointer;
  font-size: 10.5px; font-weight: 600; letter-spacing: .14em;
  text-transform: uppercase; color: var(--ink-3);
}
.tab.is-active { color: var(--ink); transition: color .25s ease; }
.tab:active span { opacity: .5; }
.tab span { display: inline-block; }
/* The accent bar over the tab you're on (index.html), placed by main.js
   (moveTabInk): it glides to the tab you switch to, with a little give at
   the end, and fades on screens without a tab of their own.
   It runs in .tab-track, a strip exactly the tab bar's width that cuts off
   anything past its ends. The give carries the bar a few pixels past the
   tab it's going to; going to You, the last tab, that was past the screen's
   right edge, so for a moment the page was wider than the phone and jumped. */
.tab-track {
  position: absolute; top: -1px; left: 0; right: 0; height: 3px;
  overflow: hidden; pointer-events: none;
}
.tab-ink {
  position: absolute; top: 0; left: 0; width: 0; height: 3px; border-radius: 0 0 2px 2px;
  background: var(--accent);
}
.tab-ink.is-ready { transition: transform .42s cubic-bezier(.3, 1.3, .5, 1), width .42s cubic-bezier(.3, 1.3, .5, 1), opacity .25s ease; }
.tab-ink.is-off { opacity: 0; }
/* The word of the tab you've just switched to lifts and settles. */
@keyframes tab-pop {
  0% { transform: translateY(0); }
  40% { transform: translateY(-3px) scale(1.06); }
  100% { transform: translateY(0) scale(1); }
}
.tab.is-arriving span { animation: tab-pop .45s cubic-bezier(.3, 1.4, .5, 1); }
@media (prefers-reduced-motion: reduce) {
  .tab-ink.is-ready { transition: opacity .2s ease; }
  .tab.is-arriving span { animation: none; }
}

/* ── Buttons ──────────────────────────────────────────────── */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  min-height: var(--tap); padding: 0 24px;
  border: 1px solid transparent; border-radius: 2px; cursor: pointer;
  font-family: var(--sans); font-size: 14.5px; font-weight: 600;
  letter-spacing: .03em; transition: opacity .12s ease, transform .12s ease;
}
.btn:active { transform: scale(.985); opacity: .85; }
.btn:disabled { opacity: .4; pointer-events: none; }
.btn-block { display: flex; width: 100%; }

.btn-primary { background: var(--btn-bg); color: var(--btn-fg); }
.btn-accent  { background: var(--accent); color: var(--on-accent); }
.btn-onblock { background: var(--on-accent); color: var(--accent); }
/* Tinted with whatever ink is in scope — inside a track screen that is the
   track's own colour, so these pick up the surroundings for free. Mixed
   against --paper-2 rather than made translucent, so they stay opaque and
   the page grid never shows through. */
.btn-quiet {
  background: color-mix(in srgb, var(--accent) 10%, var(--paper-2));
  border-color: color-mix(in srgb, var(--accent) 38%, var(--rule));
  color: var(--accent);
}
.btn-text {
  background: none; border: none; min-height: 40px; padding: 0;
  color: var(--ink-2); font-size: 13.5px; font-weight: 500;
  text-decoration: underline; text-underline-offset: 4px; text-decoration-color: var(--rule);
}
.btn-sm { min-height: 42px; padding: 0 16px; font-size: 12.5px; }

/* ── The block: a solid slab of track ink ─────────────────── */

.block {
  display: block; width: 100%; text-align: left; cursor: pointer;
  border: none; border-radius: 3px; padding: 22px 20px 20px;
  background: var(--accent); color: var(--on-accent);
  position: relative; overflow: hidden;
}
.block::after {
  /* oversized folio, ghosted into the corner */
  content: attr(data-folio); position: absolute; right: 10px; bottom: -20px;
  font-family: var(--serif); font-size: 116px; line-height: 1;
  opacity: .16; pointer-events: none;
}
/* Home's block ends in its Continue button, which hid the bottom half of the
   folio: there it sits just above the button instead. (You's level card has
   no button, so its folio keeps the corner.) */
.block:not(.block-static)::after { bottom: 56px; }
.block:active { transform: scale(.99); }
.block-static { cursor: default; }
.block-static:active { transform: none; }
.block-meta {
  display: flex; align-items: center; gap: 10px; margin-bottom: 14px;
  font-size: 10.5px; font-weight: 600; letter-spacing: .16em; text-transform: uppercase;
}
.block-meta .spacer { margin-left: auto; opacity: .9; }   /* .75 dropped it under 4.5:1 */
.block-title {
  font-family: var(--serif); font-weight: 400;
  font-size: clamp(29px, 8.4vw, 42px); line-height: 1.06; letter-spacing: -.015em;
  margin: 0 0 10px; position: relative; text-wrap: balance;
}
.block-sub { margin: 0 0 20px; font-size: 15px; opacity: .88; position: relative; }
.block .btn { position: relative; }

/* ── Figures ──────────────────────────────────────────────── */

.figures {
  display: flex; align-items: stretch;
  border-top: 2px solid var(--ink); border-bottom: 1px solid var(--rule);
  padding: 14px 0;
}
.figure { flex: 1; text-align: center; }
.figure + .figure { border-left: 1px solid var(--rule); }
.figure-n {
  font-family: var(--serif); font-size: 46px; line-height: .95; letter-spacing: -.03em;
  display: block;
}
.figure-l {
  display: block; margin-top: 3px;
  font-size: 9.5px; font-weight: 600; letter-spacing: .15em;
  text-transform: uppercase; color: var(--ink-3);
}

/* ── Tally: progress you can actually see ─────────────────── */

/* Progress as a cafe loyalty card: one stamp per lesson (or per few, past
   tally()'s max), punched in sets of five, with a stamp's ring. */
.tally { --stamp: 13px; --gap: 5px; display: flex; flex-wrap: wrap; gap: var(--gap); }
.tally i {
  flex: none; width: var(--stamp); height: var(--stamp); border-radius: 50%;
  border: 1.5px solid var(--rule); background: var(--paper-2);
  transition: background .3s ease, border-color .3s ease;
}
.tally i:nth-child(5n):not(:last-child) { margin-right: 6px; }
.tally i.on {
  border-color: var(--accent); background: var(--accent);
  box-shadow: inset 0 0 0 2px var(--accent), inset 0 0 0 3.5px var(--paper-2);
}
/* Hover over the stamps, or the card they sit on: the stamped ones pop in
   turn, left to right, and the next one to earn pulses while you stay. */
@keyframes tally-pop {
  0%, 100% { transform: scale(1); }
  40% { transform: scale(1.4) rotate(-14deg); }
  70% { transform: scale(.9); }
}
@keyframes tally-next {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.3); border-color: var(--pulse, var(--accent)); }
}
@media (hover: hover) {
  :hover > .tally i.on,
  .tally:hover i.on { animation: tally-pop .45s ease-out both; animation-delay: calc(min(var(--i, 0), 24) * 30ms); }
  :hover > .tally i.on + i:not(.on), .tally:hover i.on + i:not(.on),
  :hover > .tally i:first-child:not(.on), .tally:hover i:first-child:not(.on) {
    animation: tally-next 1s ease-in-out infinite; animation-delay: calc(min(var(--i, 0), 24) * 30ms + .2s);
  }
}
.block .tally i { --pulse: var(--on-accent); }   /* the next one pulses in the block's own ink */
.tally.tall { --stamp: 17px; --gap: 6px; }
/* a whole card: two rows of ten (each row holds two set-of-five gaps, one
   of them trailing, which still counts towards where the row wraps) */
.tally.card { max-width: calc(var(--stamp) * 10 + var(--gap) * 9 + 13px); }
.tally.tally-sm { --stamp: 7px; --gap: 3px; }
.tally.tally-sm i { border-width: 1px; }
.tally.tally-sm i.on { box-shadow: none; }
.tally.tally-sm i:nth-child(5n):not(:last-child) { margin-right: 0; }
/* on an accent block the stamps must reverse, or "filled" is invisible */
.block .tally i { border-color: color-mix(in srgb, var(--on-accent) 60%, transparent); background: transparent; }
.block .tally i.on {
  border-color: var(--on-accent); background: var(--on-accent);
  box-shadow: inset 0 0 0 2px var(--on-accent), inset 0 0 0 3.5px var(--accent);
}

/* ── Recipe cards: a blank editor is paralysis, so never show one ── */

/* Phones: the recipes are one swipeable strip, so the editor makes the first
   screen. The two-column layout further down turns them back into a grid. */
.recipes {
  display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px;
  scroll-snap-type: x proximity; scrollbar-width: none;
}
.recipes::-webkit-scrollbar { display: none; }
.recipes .recipe { flex: 0 0 auto; min-width: 132px; scroll-snap-align: start; }
.editor-actions { display: flex; align-items: center; gap: 18px; }

/* A label with something on its right: "Keep going … All 12 tracks" */
.section-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 0 0 12px;
}
.section-head .label { margin: 0; }
.section-head .btn-text { font-size: 13px; }
.track-group + .track-group { margin-top: 34px; }

/* You: settings grouped, and starting over kept apart from them */
.settings-label { margin: 0 0 4px; }
.danger { padding-top: 6px; border-top: 2px solid var(--ink); }
.danger summary { color: var(--danger); }
.recipe {
  display: block; text-align: left; cursor: pointer;
  padding: 13px 14px 12px; border: 1px solid var(--rule); border-radius: 3px;
  background: var(--paper-2); color: var(--ink);
  transition: background .12s ease, border-color .12s ease, transform .12s ease;
}
.recipe:active { transform: scale(.97); }
.recipe-n {
  display: block; font-family: var(--serif); font-size: 20px; line-height: 1.1;
  color: var(--accent);
}
.recipe-d {
  display: block; margin-top: 2px; font-size: 11.5px; line-height: 1.35; color: var(--ink-3);
}

/* ── Nudge: a live suggestion, not a static stat ──────────── */

.nudge {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  cursor: pointer; background: none; border: 2px solid var(--accent);
  border-radius: 3px; padding: 14px 16px;
}
.nudge:active { background: var(--accent); color: var(--on-accent); }
.nudge-body { flex: 1; }
.nudge-t { display: block; font-family: var(--serif); font-size: 21px; line-height: 1.1; }
.nudge-s { display: block; margin-top: 2px; font-size: 12.5px; color: var(--ink-2); }
.nudge:active .nudge-s { color: inherit; opacity: .85; }
.nudge-go { flex: none; font-size: 22px; color: var(--accent); line-height: 1; }
.nudge:active .nudge-go { color: inherit; }

/* ── Tracks ───────────────────────────────────────────────── */

.tracklist { border-top: 2px solid var(--ink); }

.track {
  display: block; width: 100%; text-align: left; cursor: pointer;
  background: none; border: none; border-bottom: 1px solid var(--rule);
  padding: 15px 0 17px;
}
.track:active { background: var(--paper-3); }
.track-top { display: flex; align-items: baseline; gap: 10px; }
.track-name {
  font-family: var(--serif); font-size: 26px; line-height: 1.05;
  color: var(--accent); letter-spacing: -.01em;
}
.track-count {
  margin-left: auto; font-size: 12px; font-weight: 600; color: var(--ink-3);
}
.track-blurb { margin: 2px 0 0; font-size: 13.5px; color: var(--ink-2); }
/* The learning path on Tracks: each step numbered, and the one you're on says what's next */
.track-step {
  flex: none; min-width: 2ch; font-size: 12px; font-weight: 600; letter-spacing: .06em;
  color: var(--ink-3); font-variant-numeric: tabular-nums;
}
.track-next { display: flex; align-items: center; gap: 8px; margin: 9px 0 0; font-size: 13px; color: var(--ink); }
.track .tally { margin-top: 13px; }

.t-basics   { --accent: var(--t-basics); }
.t-r        { --accent: var(--t-r); }
.t-etl      { --accent: var(--t-etl); }
.t-ai       { --accent: var(--t-ai); }
.t-algo     { --accent: var(--t-algo); }
.t-pandas   { --accent: var(--t-pandas); }
.t-wrangle  { --accent: var(--t-wrangle); }
.t-ts       { --accent: var(--t-ts); }
.t-mpl      { --accent: var(--t-mpl); }
.t-sns      { --accent: var(--t-sns); }
.t-analysis { --accent: var(--t-analysis); }
.t-projects { --accent: var(--t-projects); }
.t-pbi { --accent: var(--t-pbi); }
.t-stats { --accent: var(--t-stats); }
.t-sandbox  { --accent: var(--t-sandbox); }
.t-messy    { --accent: var(--t-messy); }
.t-sql      { --accent: var(--t-sql); }
.t-dax      { --accent: var(--t-dax); }
.t-numpy    { --accent: var(--t-numpy); }
.t-metrics  { --accent: var(--t-metrics); }
.t-fc       { --accent: var(--t-fc); }
.t-ml       { --accent: var(--t-ml); }
.t-excel    { --accent: var(--t-excel); }

/* Settings → Display: the colour themes, each with a swatch of its pair:
   the day half on its day paper, the night half on its night paper (its
   [data-palette] sets --sw-*), whichever mode the app is in. */
.theme-picks { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px; }
.theme-pick {
  display: flex; align-items: center; gap: 12px; min-height: 58px; padding: 10px 12px;
  border: 1px solid var(--rule); border-radius: 3px; background: var(--paper-2);
  font: inherit; color: var(--ink); text-align: left; cursor: pointer;
}
.theme-pick:hover { border-color: var(--accent); }
.theme-pick.is-on { border-color: var(--accent); box-shadow: inset 4px 0 0 var(--accent); }
.theme-swatch {
  flex: none; display: flex; width: 58px; height: 36px; overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--ink) 22%, transparent); border-radius: 4px;
}
.theme-swatch i { flex: 1; display: grid; place-items: center; }
.theme-swatch i::after { content: ""; width: 13px; height: 13px; border-radius: 50%; }
.theme-swatch .sw-day { background: var(--sw-day-paper); }
.theme-swatch .sw-day::after { background: var(--sw-day); }
.theme-swatch .sw-night { background: var(--sw-night-paper); }
.theme-swatch .sw-night::after { background: var(--sw-night); }
.theme-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.theme-name { font-size: 14.5px; font-weight: 600; }
.theme-about { font-size: 12.5px; line-height: 1.35; color: var(--ink-3); }

/* The Interview set's start: which job's screen, as four choices. */
.iv-sets { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
.iv-set {
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px; min-height: 64px; padding: 12px 14px;
  border: 1px solid var(--rule); border-radius: 3px; background: var(--paper-2); text-align: left; cursor: pointer;
  font: inherit; color: var(--ink);
}
.iv-set:hover { border-color: var(--accent); }
.iv-set.is-on { border-color: var(--accent); box-shadow: inset 4px 0 0 var(--accent); }
.iv-set-name { font-size: 15px; font-weight: 600; }
.iv-set-langs { font-size: 12.5px; color: var(--ink-3); }

/* ── Courses: find a lesson ───────────────────────────────── */

.search-box { position: relative; display: block; }
.search-icon {
  position: absolute; left: 14px; top: 50%; width: 18px; height: 18px; transform: translateY(-50%);
  fill: none; stroke: var(--ink-3); stroke-width: 2; stroke-linecap: round; pointer-events: none;
}
.search-input {
  width: 100%; min-height: 48px; padding: 12px 14px 12px 42px;
  border: 1px solid var(--rule); border-radius: 3px; background: var(--paper-2);
  font: inherit; font-size: 16px; color: var(--ink);       /* 16px: a phone doesn't zoom in on it */
}
.search-input::placeholder { color: var(--ink-3); }
.search-input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.search-count { margin: 14px 0 2px; font-size: 13px; line-height: 1.45; color: var(--ink-3); }
.search-hit mark { padding: 0 1px; border-radius: 2px; background: color-mix(in srgb, var(--accent) 24%, transparent); color: inherit; }
.search-bit { display: block; margin: 2px 0 1px; font-size: 13px; line-height: 1.4; color: var(--ink-2); }
.search-count.search-group { margin-top: 26px; font-weight: 600; color: var(--ink-2); }
/* A question's tags, each a way to every question with it. */
.tag-link {
  display: inline-flex; align-items: center; min-height: 32px; padding: 0; border: none; background: none;
  font: inherit; letter-spacing: inherit; text-transform: inherit; color: inherit; cursor: pointer;
  text-decoration: underline; text-underline-offset: 4px; text-decoration-color: color-mix(in srgb, currentColor 40%, transparent);
}
.tag-link:hover { text-decoration-color: currentColor; }

/* ── Lesson index ─────────────────────────────────────────── */

.part + .part { margin-top: 28px; }
/* Clear of the sticky top bar when a lesson's link brings a part (or a
   practice difficulty) into view, which then glows for a moment. */
.part, .diff-fold { scroll-margin-top: 84px; }
.part.is-here .part-head,
.diff-fold.is-here > summary { animation: here-glow 1.6s ease-out .2s both; }
@keyframes here-glow {
  0%, 30% { background: color-mix(in srgb, var(--accent) 16%, transparent); }
  100%    { background: transparent; }
}
@media (prefers-reduced-motion: reduce) {
  .part.is-here .part-head,
  .diff-fold.is-here > summary { animation: none; }
}
.part-head {
  display: flex; align-items: center; gap: 10px;
  padding-bottom: 9px; border-bottom: 2px solid var(--ink);
}
.part-head::before {
  content: ""; width: 20px; height: 4px; background: var(--accent); flex: none;
}
.part-name {
  font-size: 10.5px; font-weight: 600; letter-spacing: .16em;
  text-transform: uppercase; color: var(--ink);
}
.part-count {
  margin-left: auto; font-size: 12px; font-weight: 600; color: var(--ink-3);
}
.part.is-done .part-name,
.part.is-done .part-count { color: var(--accent); }

.lesson-row {
  display: flex; align-items: center; gap: 14px; width: 100%;
  padding: 14px 0; text-align: left; cursor: pointer;
  background: none; border: none; border-bottom: 1px solid var(--rule-soft);
}
.lesson-row:active { background: var(--paper-3); }
.lesson-row.is-done .lesson-name {
  color: var(--ink-3); text-decoration: line-through; text-decoration-color: var(--rule);
}
.lesson-n {
  flex: none; width: 24px; font-size: 12px; font-weight: 600; color: var(--ink-3);
}
.lesson-row.is-done .lesson-n { color: var(--accent); }
.lesson-n .stamp-mini { margin-left: -1px; }
.lesson-name { flex: 1; font-size: 15.5px; line-height: 1.35; }
.lesson-mins { flex: none; font-size: 11.5px; color: var(--ink-3); }

/* Menu-board leaders: a dotted line from a name to its number, the way a cafe
   menu runs from a drink to its price. Problem rows carry tags under the name,
   so they keep the name full width instead. */
.lesson-row:not(.problem-row) .lesson-name { flex: 0 1 auto; min-width: 0; }
.lesson-row:not(.problem-row)::after {
  content: ""; order: 2; flex: 1 1 16px; min-width: 16px; align-self: center;
  border-bottom: 2px dotted var(--rule);
}
.lesson-row > .lesson-n { order: 0; }
.lesson-row > .lesson-name { order: 1; }
.lesson-row > .lesson-mins, .lesson-row > .next-tag, .lesson-row > .diff-tag { order: 3; }
.track-top::after { content: ""; order: 2; flex: 1 1 16px; min-width: 16px; border-bottom: 2px dotted var(--rule); }
.track-top > .track-step { order: 0; }
.track-top > .track-name { order: 1; }
.track-top > .track-count { order: 3; margin-left: 0; }

/* you are here — the single most useful mark on a long index */
.lesson-row.is-next {
  background: var(--paper-2);
  box-shadow: inset 4px 0 0 var(--accent);
  padding-left: 13px; padding-right: 10px;
}
.lesson-row.is-next .lesson-name { font-weight: 600; }
.lesson-row.is-next .lesson-n { color: var(--accent); }
.next-tag {
  flex: none; font-size: 8.5px; font-weight: 700; letter-spacing: .14em;
  text-transform: uppercase; background: var(--accent); color: var(--on-accent);
  padding: 3px 7px; border-radius: 2px;
}

/* ── Lesson ───────────────────────────────────────────────── */

/* a thick spine of track ink so every track feels different. It's a strip
   that sticks just under the top bar, so it stays in view as a lesson or a
   practice question scrolls. The screen's own top padding moves under it. */
.screen.lesson-screen { padding-top: 0; }
.screen.lesson-screen::before {
  content: ''; display: block;
  position: sticky; top: var(--chrome-top, 58px); z-index: 6;
  height: 5px; margin: 0 calc(-1 * var(--gut)) 24px;
  background: var(--accent);
}

.lesson-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 18px;
}
.lesson-kicker { margin: 0; color: var(--accent) !important; }
/* Above a lesson's or a question's title: where it sits, as links back up
   (Courses › Excel › Lookups; Practice › Excel › Medium). */
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 0 8px; margin: -11px 0 1px; font-size: 13px; line-height: 1.4; }
.crumb {
  display: inline-flex; align-items: center; min-height: 44px;
  color: var(--ink-2); text-decoration: underline; text-underline-offset: 4px; text-decoration-color: var(--rule);
}
.crumb:hover { color: var(--accent); text-decoration-color: currentColor; }
.crumb-sep { color: var(--ink-3); }
/* "Lesson 3 of 20" (or "9 of 16") opens the whole list, to jump to any of
   them (ui.jumpMenu). It drops over the page, scrolled to where you are. */
.jump { position: relative; }
.jump > summary {
  display: inline-flex; align-items: center; gap: 6px; min-height: 44px; margin: -6px 0;
  list-style: none; cursor: pointer;
}
.jump > summary::-webkit-details-marker { display: none; }
.jump > summary:hover { text-decoration: underline; text-underline-offset: 4px; }
.jump-caret { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; transition: transform .2s ease; }
.jump[open] .jump-caret { transform: rotate(180deg); }
.jump-panel {
  position: absolute; z-index: 30; top: calc(100% + 4px); left: 0;
  width: min(380px, calc(100vw - 2 * var(--gut))); max-height: min(60vh, 460px);
  overflow-y: auto; overscroll-behavior: contain; padding: 6px 0;
  border: 1px solid var(--rule); border-radius: 6px; background: var(--paper-2);
  box-shadow: 0 14px 34px rgba(0, 0, 0, .22);
}
.jump-group {
  margin: 12px 14px 4px; font-size: 10.5px; font-weight: 600; letter-spacing: .14em;
  text-transform: uppercase; color: var(--ink-3);
}
.jump-group:first-child { margin-top: 6px; }
.jump-item {
  display: flex; align-items: baseline; gap: 10px; width: 100%; min-height: 42px; padding: 10px 14px;
  border: none; background: none; text-align: left; font: inherit; font-size: 14px; line-height: 1.35;
  letter-spacing: 0; text-transform: none; color: var(--ink); cursor: pointer;
}
.jump-item:hover { background: var(--paper-3); }
.jump-item.is-here { background: color-mix(in srgb, var(--accent) 13%, transparent); font-weight: 600; cursor: default; }
.jump-n { flex: none; min-width: 2.2em; text-align: right; font-family: var(--mono); font-size: 12px; color: var(--ink-3); }
.jump-item.is-done .jump-n { font-weight: 700; color: var(--good); }
/* Previous and next: two arrows by "3 of 20", and the two either side, by
   name, at the end. */
.lesson-kick { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 14px; }
.lesson-steps { display: inline-flex; gap: 10px; }
.lesson-step {
  position: relative; display: inline-grid; place-items: center; width: 34px; height: 34px; padding: 0;
  border: 1px solid var(--rule); border-radius: 50%; background: var(--paper-2); color: var(--accent); cursor: pointer;
}
.lesson-step::after { content: ""; position: absolute; inset: -5px; }   /* a 44px target */
.lesson-step svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.lesson-step:hover:not(:disabled) { border-color: var(--accent); }
.lesson-step:disabled { color: var(--ink-3); opacity: .45; cursor: default; }
.lesson-pager { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 22px; }
.pager-link {
  display: flex; flex-direction: column; align-items: flex-start; gap: 5px; min-width: 0; min-height: 64px;
  padding: 12px 14px; border: 1px solid var(--rule); border-radius: 3px; background: var(--paper-2);
  color: var(--ink); text-align: left; cursor: pointer;
}
.pager-link.is-next { grid-column: 2; align-items: flex-end; text-align: right; }
.pager-link .label { margin: 0; color: var(--accent); }
.pager-title { font-family: var(--serif); font-size: 16px; line-height: 1.3; }
.pager-link:hover { border-color: var(--accent); }
.lesson-title { margin: 6px 0 20px; }

.concept { list-style: none; margin: 0; padding: 0; }
.concept li {
  position: relative; padding-left: 24px; margin: 0 0 13px;
  font-size: 16px; line-height: 1.56;
}
.concept li::before {
  content: ""; position: absolute; left: 0; top: .62em;
  width: 14px; height: 3px; background: var(--accent);
}

code {
  font-family: var(--mono); font-size: .86em;
  color: var(--ink); background: var(--paper-3);
  padding: 1px 5px; border-radius: 2px; word-break: break-word;
}
b, strong { font-weight: 600; }

.task {
  border-left: 5px solid var(--accent); padding: 3px 0 3px 15px;
}
.task .label { display: block; margin-bottom: 5px; color: var(--accent); }
.task p { margin: 0; font-size: 17px; line-height: 1.45; }

.editor-wrap {
  position: relative;               /* anchors the intellisense popup */
  border: 1px solid var(--rule); border-radius: 3px;
  background: var(--paper-2);       /* not overflow:hidden - the popup has to escape */
}
.editor-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px; border-bottom: 1px solid var(--rule-soft);
}
.editor {
  display: block; width: 100%; min-height: 220px;
  padding: 14px 12px; border: none; resize: vertical;
  background: transparent; color: var(--ink);
  font-family: var(--mono); font-size: 13px; line-height: 1.7;
  tab-size: 4; white-space: pre; overflow-x: auto;
}
.editor:focus { outline: none; }
.editor-tall { min-height: 240px; }   /* the Sandbox: a scratchpad wants room */

/* Syntax colouring (js/highlight.js): the textarea's text goes clear and a
   <pre> in the same place underneath draws it in colour. */
.hl {
  position: absolute; margin: 0; overflow: hidden; pointer-events: none;
  color: var(--ink); background: transparent;
}
.editor.has-hl { position: relative; z-index: 1; color: transparent; caret-color: var(--ink); }
.editor.has-hl::selection { color: transparent; background: rgba(120, 150, 210, .32); }
.t-kw  { color: var(--ink); font-weight: 600; }
.t-fn  { color: var(--accent); }
.t-num { color: var(--accent); }
.t-ref { color: var(--accent); }
.t-str { color: var(--good); }
.t-com { color: var(--ink-3); font-style: italic; }
/* The textarea drops its own outline, so the frame around it shows focus instead. */
.editor-wrap:focus-within { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }

/* Keyboard focus everywhere else: one clear ring in the ink of wherever you are.
   :focus-visible, so a tap or a click never draws it. */
:where(button, a, summary, [tabindex]:not(#screen)):focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

.snips { display: flex; gap: 0; overflow-x: auto; border-top: 1px solid var(--rule-soft); scrollbar-width: none; }
.snips::-webkit-scrollbar { display: none; }
.snip {
  flex: none; padding: 11px 14px; border: none; background: none;
  border-right: 1px solid var(--rule-soft); cursor: pointer;
  color: var(--ink-2); font-family: var(--mono); font-size: 12px; white-space: nowrap;
}
.snip:active { background: var(--accent); color: var(--on-accent); }

.run-row { display: flex; align-items: center; gap: 16px; }
.run-row .btn-accent { flex: 1; }

/* The two shortcuts on Today: equal, centred, and never stretched wide. */
.quick-row {
  display: flex; align-items: center; gap: 12px;
  max-width: 460px; margin-left: auto; margin-right: auto;
}
.quick-row .btn { flex: 1; min-width: 0; padding: 0 12px; }   /* two abreast on a 320px phone */

.needs-note {
  font-size: 12.5px; color: var(--ink-2);
  border-left: 3px solid var(--rule); padding-left: 12px; margin: 0;
}

/* Sync across devices (You): the code, set to be read out and typed. */
.reveal-body .sync-code {
  margin: 6px 0 12px; font-family: var(--mono); font-size: 18px; font-weight: 600;
  letter-spacing: .04em; color: var(--ink); user-select: all; overflow-wrap: anywhere;
}
.reveal-body .sync-status { margin: 12px 0; font-size: 13px; color: var(--ink-2); }
.reveal-body .sync-status.is-bad { color: var(--danger); }
.sync-off { display: flex; flex-wrap: wrap; gap: 8px 12px; margin-top: 12px; }

.out { border: 1px solid var(--rule); border-radius: 3px; overflow: hidden; }
.out + .out { margin-top: 12px; }
.out-head {
  padding: 7px 12px; border-bottom: 1px solid var(--rule-soft);
  font-size: 9.5px; font-weight: 600; letter-spacing: .15em;
  text-transform: uppercase; color: var(--ink-3);
}
.out-body {
  margin: 0; padding: 13px 12px; overflow-x: auto;
  font-family: var(--mono); font-size: 12px; line-height: 1.62;
  color: var(--ink); white-space: pre;
}
/* Errors wrap: the last line - the Tip, or "Did you mean" - is the one that
   matters, and it was running off the side of a phone. */
.out-body.is-err { color: var(--accent); white-space: pre-wrap; overflow-wrap: anywhere; }
/* a variable's name keeps its own spelling inside the capitalised heading */
.out-name { font-family: var(--mono); font-size: 11px; letter-spacing: 0; text-transform: none; color: var(--ink-2); }
.out img { display: block; width: 100%; height: auto; background: #fff; }

/* DAX results: a real matrix, drawn the way Power BI draws one */
.matrix-wrap { overflow-x: auto; }
.out > * + .matrix-wrap,
.matrix-wrap + .out-body { border-top: 1px solid var(--rule); }
.matrix {
  border-collapse: collapse; min-width: 100%;
  font-family: var(--mono); font-size: 12px; line-height: 1.4; color: var(--ink);
}
.matrix th {
  padding: 9px 12px 7px; text-align: left; white-space: nowrap;
  font-family: var(--sans); font-size: 9.5px; font-weight: 600; letter-spacing: .12em;
  text-transform: uppercase; color: var(--ink-2); border-bottom: 2px solid var(--ink);
}
.matrix td { padding: 7px 12px; white-space: nowrap; border-bottom: 1px solid var(--rule-soft); }
.matrix .num { text-align: right; font-variant-numeric: tabular-nums; }
.matrix tr.is-total td { font-weight: 600; border-top: 2px solid var(--ink); border-bottom: none; }
.matrix-note {
  margin: 0; padding: 8px 12px 10px; font-size: 11.5px; color: var(--ink-3);
  border-top: 1px solid var(--rule-soft);
}

/* A DataFrame or an SQL result, as a grid: column names on a shaded row,
   the index (or SQL's row numbers) pinned on the left while it scrolls,
   faint lines between the columns and every other row tinted, the way
   pandas looks in a notebook and SQL Server shows its results. */
/* Lines between the columns, headings included, as in a spreadsheet; the
   heading row's a shade darker so they show on its tint. Mixed from the ink
   so they hold in the dark theme too. */
.matrix.is-frame th, .matrix.is-frame td,
.matrix.is-sheet th, .matrix.is-sheet td { border-right: 1px solid color-mix(in srgb, var(--ink) 11%, transparent); }
.matrix.is-frame thead th,
.matrix.is-sheet thead th { border-right-color: color-mix(in srgb, var(--ink) 20%, transparent); }
.matrix.is-frame tr > :last-child,
.matrix.is-sheet tr > :last-child { border-right: none; }
/* DAX matrices too, lighter, under Power BI's heavy heading rule. */
.matrix:not(.is-frame):not(.is-sheet) th:not(:last-child),
.matrix:not(.is-frame):not(.is-sheet) td:not(:last-child) { border-right: 1px solid color-mix(in srgb, var(--ink) 9%, transparent); }
.matrix.is-frame thead th {
  text-transform: none; letter-spacing: 0; font-family: var(--mono); font-size: 12px; font-weight: 600;
  color: var(--ink); background: var(--paper-3); border-bottom: 1px solid var(--rule);
}
.matrix.is-frame .grid-index, .matrix.is-frame .grid-corner {
  position: sticky; left: 0; z-index: 1; width: 1%;    /* as narrow as its labels; the columns get the room */
  font-family: var(--mono); font-size: 12px; text-transform: none; letter-spacing: 0;
}
.matrix.is-frame .grid-index {
  padding: 7px 12px; font-weight: 600; color: var(--ink-2); background: var(--paper-2); text-align: left;
  border-bottom: 1px solid var(--rule-soft);    /* not the heading's heavy rule */
}
.matrix.is-frame.is-sql .grid-index { font-weight: 400; color: var(--ink-3); text-align: right; }
.matrix.is-frame tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--ink) 4%, transparent); }
.matrix.is-frame .grid-gap, .matrix.is-frame .grid-gaprow td { color: var(--ink-3); text-align: center; }
/* Every table's contents centred: headings, values, numbers and the index
   or row numbers, in results, outputs and examples alike (the sheets too, below). */
.matrix th, .matrix td, .matrix .num,
.matrix.is-frame .grid-index, .matrix.is-frame.is-sql .grid-index { text-align: center; }
.out-body + .matrix-wrap, .matrix-note + .out-body { border-top: 1px solid var(--rule); }

/* Excel results: the sheet itself, with its formula bar */
.fx-bar {
  display: flex; align-items: baseline; gap: 10px; padding: 9px 12px;
  border-bottom: 1px solid var(--rule); font-family: var(--mono); font-size: 12px; overflow-x: auto;
}
.fx-cell { flex: none; min-width: 2.6em; font-weight: 600; color: var(--ink); }
.fx-sign { flex: none; font-family: var(--serif); font-style: italic; color: var(--ink-3); }
.fx-formula { color: var(--ink); white-space: pre; background: none; padding: 0; }
.matrix.is-sheet th.sheet-col,
.matrix.is-sheet .sheet-corner {
  padding: 6px 12px; text-align: center; font-family: var(--mono); font-size: 11px; font-weight: 500;
  letter-spacing: 0; text-transform: none; color: var(--ink-3);
  background: var(--paper-2); border-bottom: 1px solid var(--rule);
}
.matrix.is-sheet .sheet-row {
  width: 1%; padding: 7px 10px; text-align: right; font-family: var(--mono); font-size: 11px; font-weight: 400;
  letter-spacing: 0; text-transform: none; color: var(--ink-3);
  background: var(--paper-2); border-bottom: 1px solid var(--rule-soft); border-right: 1px solid var(--rule);
}
/* The row numbers stay put while a wide sheet scrolls sideways, as in Excel. */
.matrix.is-sheet .sheet-row,
.matrix.is-sheet .sheet-corner { position: sticky; left: 0; z-index: 1; }
.matrix.is-sheet tr.sheet-heads td { font-family: var(--sans); font-weight: 600; color: var(--ink-2); }
/* Every cell centred, headings and numbers too, and an empty column still a
   cell's width, so the one a formula goes in is a box you can see. */
.matrix.is-sheet td,
.matrix.is-sheet td.num { text-align: center; min-width: 64px; }
/* An expected answer is only as big as the answer: one cell, a column, a
   spilled block. The box shrinks round it, and its note wraps to fit. */
.matrix.is-sheet.is-compact { min-width: 0; }
.matrix.is-sheet td.is-mark { background: color-mix(in srgb, var(--accent) 9%, transparent); }
.matrix.is-sheet th.is-mark { color: var(--accent); font-weight: 700; }
/* The cell a formula goes in, in a preview: outlined, waiting. */
.matrix.is-sheet td.is-target {
  outline: 2px dashed var(--accent); outline-offset: -3px;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}
.fx-hint { font-family: var(--sans); font-style: italic; color: var(--ink-3); }
/* Step through it: each step's formula, the newest piece marked, and what it gave. */
.xl-steps { margin-top: 12px; }
.xl-step-intro { margin: 0 0 10px; font-size: 13.5px; line-height: 1.45; color: var(--ink-2); }
.xl-step-list { display: grid; gap: 12px; margin: 0; padding-left: 1.6em; }
.xl-step-list li { padding-left: 4px; }
.xl-step-f {
  display: block; padding: 0; background: none; font-family: var(--mono); font-size: 13px; line-height: 1.5;
  white-space: pre-wrap; overflow-wrap: anywhere; color: var(--ink);
}
.xl-step-f mark { padding: 0 2px; border-radius: 2px; background: color-mix(in srgb, var(--accent) 24%, transparent); color: inherit; }
.xl-step-say { display: block; margin-top: 2px; font-size: 13px; line-height: 1.45; color: var(--ink-3); }
/* Which sheet a preview is: its name, like the tab along the bottom of Excel. */
.sheet-tab {
  margin: 0; padding: 7px 12px; border-bottom: 1px solid var(--rule); background: var(--paper-3);
  font-family: var(--mono); font-size: 12px; font-weight: 600; color: var(--ink);
}
.sheet-tab span { font-family: var(--sans); font-size: 10px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-3); margin-right: 4px; }
* + .sheet-tab { border-top: 1px solid var(--rule); }
/* Under the tab: how many rows of data, and each column's whole range, ready
   to copy into a formula without counting. */
.sheet-span { padding: 9px 12px 10px; border-bottom: 1px solid var(--rule); background: var(--paper-2); }
.sheet-count { margin: 0; font-size: 13px; line-height: 1.45; color: var(--ink-2); }
.sheet-count b { font-weight: 600; color: var(--ink); }
.sheet-ranges { display: flex; flex-wrap: wrap; gap: 5px 6px; margin: 7px 0 0; padding: 0; list-style: none; }
.sheet-ranges li { display: flex; }
.sheet-range {
  display: inline-flex; align-items: baseline; gap: 6px; min-height: 32px; padding: 6px 9px;
  border: 1px solid var(--rule-soft); border-radius: 3px; background: var(--paper);
  font: inherit; font-size: 12px; line-height: 1.4; color: var(--ink-3); cursor: pointer;
}
.sheet-range:hover { border-color: var(--accent); color: var(--ink-2); }
.sheet-range:active { background: color-mix(in srgb, var(--accent) 12%, var(--paper)); }
.sheet-ranges code { padding: 0; background: none; font-family: var(--mono); font-size: 12px; font-weight: 600; color: var(--accent); }
/* A sheet preview on its own (lessons, the Sandbox), framed like the output. */
.xl-peek { border: 1px solid var(--rule); border-radius: 3px; background: var(--paper-2); overflow: hidden; }
.xl-peek + .xl-peek { margin-top: 10px; }
.task .xl-peek { margin-top: 14px; }
/* A lesson's Expected output: a fold in the task, like a practice question's. */
.task .lesson-expect { margin-top: 14px; }
.task .lesson-expect > .reveal-body > .out + .out { margin-top: 10px; }
.task .xl-peek .matrix-note { margin: 0; font-size: 11.5px; line-height: 1.5; color: var(--ink-3); }

.part-test { display: inline-block; margin-top: 12px; font-size: 13px; }

/* PL-300 prep: a question, its options, and the scores by area */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.exam-stem {
  margin: 6px 0 0; font-family: var(--serif); font-weight: 400;
  font-size: clamp(20px, 5.4vw, 25px); line-height: 1.3; letter-spacing: -.005em;
}
.opts { display: grid; gap: 8px; margin: 0; padding: 0; border: none; min-width: 0; }
.opt {
  display: flex; align-items: flex-start; gap: 12px; cursor: pointer;
  padding: 13px 14px; border: 1px solid var(--rule); border-radius: 3px;
  background: var(--paper-2); font-size: 15.5px; line-height: 1.4;
}
.opt input { flex: none; width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--accent); }
.opt:not(.is-right):has(input:checked) { border-color: var(--accent); box-shadow: inset 4px 0 0 var(--accent); }
.opt:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.opt.is-right { border-color: var(--good); box-shadow: inset 4px 0 0 var(--good); }
.opt.is-wrong { border-color: var(--accent); box-shadow: inset 4px 0 0 var(--accent); }
.opt:has(input:disabled) { cursor: default; }
.opt-tag {
  flex: none; align-self: center; font-size: 10px; font-weight: 700; letter-spacing: .12em;
  text-transform: uppercase; color: var(--ink-2);
}
.opt.is-right .opt-tag { color: var(--good); }
.exam-nav .btn:only-child { flex: 1; }
.exam-area { align-items: center; }
/* no menu-board leader here: it sat after the score and pushed it to mid-row */
.lesson-row.exam-area::after { display: none; }
.exam-area .tally { margin-top: 8px; }
/* what an area or case covers is the point of the row: let it wrap on phones */
.exam-area .problem-tags { white-space: normal; }
.exam-score {
  flex: none; text-align: right; font-family: var(--serif); font-size: 26px; line-height: 1; color: var(--accent);
}
.exam-score small { display: block; margin-top: 3px; font-family: var(--sans); font-size: 11px; color: var(--ink-3); }
/* A case study's scenario, above each of its questions */
.case-box {
  padding: 0 14px; background: var(--paper-2);
  border: 1px solid var(--rule); border-left: 5px solid var(--accent); border-radius: 3px;
}
.case-box > summary { font-weight: 600; }
.case-box .case-head { display: block; margin: 14px 0 4px; }
.case-list { margin: 0 0 6px; padding-left: 18px; }
.case-list li { margin: 0 0 6px; font-size: 14.5px; line-height: 1.45; }

/* Put in order: numbered slots, filled from the pool of steps below */
.order-label { display: block; margin: 0 0 8px; }
.order-list + .order-label { margin-top: 16px; }
.order-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; counter-reset: step; }
.order-slot { counter-increment: step; display: flex; align-items: stretch; gap: 10px; }
.order-slot::before {
  content: counter(step); flex: none; width: 24px; padding-top: 11px; text-align: center;
  font-family: var(--serif); font-size: 20px; line-height: 1; color: var(--accent);
}
.order-empty {
  flex: 1; padding: 12px 14px; border: 1px dashed var(--rule); border-radius: 3px;
  font-size: 14px; color: var(--ink-3);
}
.order-pool { display: grid; gap: 8px; }
.order-item, .order-done {
  flex: 1; display: flex; align-items: flex-start; gap: 10px; min-width: 0; text-align: left;
  padding: 12px 14px; border: 1px solid var(--rule); border-radius: 3px;
  background: var(--paper-2); color: var(--ink); font: inherit; font-size: 15px; line-height: 1.4;
}
.order-item { cursor: pointer; }
.order-item:disabled { cursor: default; opacity: .5; }
.order-item.is-placed { border-color: var(--accent); box-shadow: inset 4px 0 0 var(--accent); }
/* a long DAX name such as SAMEPERIODLASTYEAR('Date'[Date]) has nowhere to break */
.order-text, .opt-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.order-x { flex: none; font-size: 20px; line-height: 1; color: var(--ink-2); }
/* marked: the tag goes under the step, so a formula keeps the full width */
.order-done { flex-direction: column; gap: 4px; }
.order-done .opt-tag { align-self: flex-start; }
.order-done.is-right { border-color: var(--good); box-shadow: inset 4px 0 0 var(--good); }
.order-done.is-right .opt-tag { color: var(--good); }
.order-done.is-wrong { border-color: var(--accent); box-shadow: inset 4px 0 0 var(--accent); }

.exam-answers { margin: 10px 0; padding-left: 20px; }
.exam-answers li { margin: 0 0 6px; }
.exam-answers li.is-right b { color: var(--good); }
.exam-answers li.is-wrong b { color: var(--accent); }

/* See another way: the model answer, lines yours didn't have marked */
.another-code span { display: block; padding-left: 10px; }
.another-code .is-new { box-shadow: inset 3px 0 0 var(--accent); background: var(--paper-3); }

/* You: this week, as date stamps. A day you finished something is stamped
   in nude, by hand so never quite straight, with how many under the date
   when it's more than one; a day you didn't is a dashed ring. */
.week {
  display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px;
  margin: 16px 0 22px;
}
.week-day { display: flex; flex-direction: column; align-items: center; gap: 7px; }
.week-stamp {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  width: 100%; max-width: 46px; aspect-ratio: 1; border-radius: 50%;
  border: 1.5px dashed color-mix(in srgb, var(--ink-3) 55%, transparent); color: var(--ink-3);
}
.week-stamp b { font-family: var(--serif); font-size: 16px; font-weight: 600; line-height: 1; }
.week-stamp small { font-size: 10px; font-weight: 600; line-height: 1; letter-spacing: .02em; }
.week-day.is-on .week-stamp {
  border: none; background: var(--caramel); color: var(--on-caramel);
  box-shadow: inset 0 0 0 3px var(--caramel), inset 0 0 0 4.5px var(--on-caramel);   /* the stamp's inner ring */
}
.week-day.is-on .week-stamp { transform: rotate(var(--tilt, 0deg)); }
.week-day.is-on:nth-child(3n+1) .week-stamp { --tilt: -8deg; }
.week-day.is-on:nth-child(3n+2) .week-stamp { --tilt: 6deg; }
.week-letter { font-size: 11px; line-height: 1; color: var(--ink-3); }
.week-day.is-today .week-letter { color: var(--ink); font-weight: 600; }
.week-sum { margin: 0; font-size: 15px; line-height: 1.5; }

/* The keyboard shortcuts dialog */
.keys {
  width: min(440px, calc(100vw - 32px)); padding: 22px;
  border: 1px solid var(--ink); border-radius: 3px;
  background: var(--paper); color: var(--ink); box-shadow: 6px 6px 0 var(--rule);
}
.keys::backdrop { background: rgba(0, 0, 0, .45); }
.keys h2 { margin: 0 0 16px; font-family: var(--serif); font-size: 28px; font-weight: 600; line-height: 1.1; }
.keys dl { display: grid; grid-template-columns: auto 1fr; gap: 10px 14px; margin: 0 0 18px; align-items: baseline; }
.keys dt, .keys dd { margin: 0; }
.keys dd { font-size: 14.5px; line-height: 1.4; }
kbd {
  font-family: var(--mono); font-size: 12px; white-space: nowrap; color: var(--ink);
  padding: 2px 6px; background: var(--paper-2);
  border: 1px solid var(--rule); border-bottom-width: 2px; border-radius: 3px;
}

/* Just 5 minutes, and an interview set in progress: a slim strip on top */
.session-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 10px 14px; background: var(--paper-2);
  border: 1px solid var(--rule); border-left: 5px solid var(--accent); border-radius: 3px;
}
.session-bar .label { margin: 0; color: var(--ink); }
.clock {
  margin: 8px 0 0; font-family: var(--serif); font-size: 72px; line-height: 1;
  font-variant-numeric: tabular-nums; color: var(--accent);
}

.matrix-chart { margin: 0; padding: 10px 12px 12px; border-top: 1px solid var(--rule); }
.matrix-chart figcaption {
  margin: 0 0 8px; font-size: 9.5px; font-weight: 600; letter-spacing: .12em;
  text-transform: uppercase; color: var(--ink-2);
}
.matrix-chart svg { display: block; width: 100%; max-width: 520px; height: auto; }
.matrix-chart rect { fill: var(--accent); }
.matrix-chart text { fill: var(--ink); font-family: var(--mono); font-size: 11px; }

.rows-pick { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.rows-pick .label { margin: 0; }
.rows-pick select,
.rows-pick input {
  flex: 1; min-width: 0; min-height: 44px; padding: 8px 10px;
  font-family: var(--mono); font-size: 13px; color: var(--ink);
  background: var(--paper); border: 1px solid var(--rule); border-radius: 3px;
}
/* Excel in the Sandbox: Fill down sits beside the sheet picker. */
.xl-fill { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; font-size: 14px; color: var(--ink-2); cursor: pointer; }
.rows-pick .xl-fill input { flex: none; width: 18px; height: 18px; min-height: 0; padding: 0; accent-color: var(--accent); }

/* ── The reward ───────────────────────────────────────────── */

@keyframes stamp {
  0%   { opacity: 0; transform: scale(1.14) rotate(-1.5deg); }
  60%  { opacity: 1; transform: scale(.985) rotate(.4deg); }
  100% { opacity: 1; transform: scale(1) rotate(0); }
}

@keyframes xp-pop {
  0%   { opacity: 0; transform: scale(.4); }
  55%  { opacity: 1; transform: scale(1.18); }
  100% { opacity: 1; transform: scale(1); }
}

/* One slim row: what happened on the left, the XP on the right. It sits
   under your output, so it mustn't crowd it. */
.won {
  display: flex; align-items: center; gap: 14px;
  border-radius: 3px; padding: 11px 16px; text-align: left;
  background: var(--good); color: var(--on-good);
  animation: stamp .42s cubic-bezier(.2,1.1,.35,1);
}
.won-text { flex: 1; min-width: 0; }
.won-label {
  font-size: 11px; font-weight: 600; letter-spacing: .22em; text-transform: uppercase;
  opacity: .9;
}
.won-xp {
  flex: none; margin: 0;
  font-family: var(--serif); font-size: 36px; line-height: 1; letter-spacing: -.03em;
  transform-origin: right center;
  animation: xp-pop .5s .12s cubic-bezier(.2,1.2,.35,1) both;
}
.won-xp small { font-size: 14px; letter-spacing: .04em; opacity: .85; }
.won-note { margin: 3px 0 0; font-size: 14px; line-height: 1.35; opacity: .95; }
/* Stamps (js/stamps.js): one for every finished lesson, in its track's ink. */
.stamp { display: block; width: 100%; height: auto; color: var(--accent); overflow: visible; }
.stamp-ring { font-family: var(--sans); font-weight: 600; letter-spacing: .06em; fill: currentColor; }
.stamp-n { font-family: var(--serif); font-size: 26px; fill: currentColor; }
.stamp-day { font-family: var(--mono); font-size: 7px; letter-spacing: .14em; fill: currentColor; }
.stamp-mini { display: block; width: 22px; height: 22px; color: var(--accent); }
/* the new stamp lands under the win, with a thunk */
.stamp-drop { display: flex; align-items: center; gap: 16px; margin-top: 16px; }
.stamp-drop .stamp { flex: none; width: 116px; animation: thunk .55s .3s cubic-bezier(.2, 1.3, .4, 1) both; }
.stamp-caption { margin: 0; font-size: 14px; line-height: 1.4; color: var(--ink-2); }
.stamp-caption b { color: var(--ink); }
@keyframes thunk {
  0%   { opacity: 0; transform: scale(1.9); }
  55%  { opacity: 1; transform: scale(.94); }
  100% { opacity: 1; transform: scale(1); }
}

/* ── The café's things (js/cafe.js) ───────────────────────── */

/* Home: today's cup beside the loyalty card; stacked on a phone. */
.cafe-row { display: grid; gap: 14px; }
@media (min-width: 560px) {
  .cafe-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); align-items: center; }
}
.day-cup { display: flex; align-items: center; gap: 14px; }
.day-cup-art { flex: none; width: 58px; height: 58px; overflow: visible; }
.day-cup-line { margin: 4px 0 0; font-size: 14px; line-height: 1.45; color: var(--ink-2); }
.cup-body { fill: var(--paper-2); }
.cup-coffee { fill: var(--bean-2); }
.cup-crema { fill: var(--bean-3); }
.cup-line { fill: none; stroke: var(--ink); stroke-width: 2.4; stroke-linejoin: round; }
.cup-saucer { fill: var(--ink-3); }
.cup-steam path { stroke: var(--ink-3); opacity: 0; }
.day-cup-art.is-full .cup-steam path { animation: wisp 2.4s ease-in-out var(--d) infinite; }
/* Hover today's cup (or tap it): it rocks on its saucer, the coffee sloshes
   (its surface tilts, the rects pivoting on their top edge), and a puff of
   steam goes up even before the cup is full. */
@keyframes cup-rock { 0%, 100% { transform: rotate(0); } 30% { transform: rotate(-7deg); } 65% { transform: rotate(4deg); } }
@keyframes cup-slosh {
  0%, 100% { transform: rotate(0) translateY(0); }
  25% { transform: rotate(10deg) translateY(-2px); }
  55% { transform: rotate(-8deg) translateY(-1px); }
  80% { transform: rotate(3deg); }
}
.day-cup-art { transform-origin: 50% 92%; cursor: default; }
.cup-coffee, .cup-crema { transform-box: fill-box; transform-origin: 50% 0; }
@media (hover: hover) {
  .day-cup-art:hover { animation: cup-rock .8s ease-in-out; }
  .day-cup-art:hover :is(.cup-coffee, .cup-crema) { animation: cup-slosh 1s ease-in-out; }
  .day-cup-art:not(.is-full):hover .cup-steam path { animation: wisp 1.6s ease-in-out var(--d) 1; }
}
.day-cup-art.is-poked { animation: cup-rock .8s ease-in-out; }
.day-cup-art.is-poked :is(.cup-coffee, .cup-crema) { animation: cup-slosh 1s ease-in-out; }
.day-cup-art.is-poked:not(.is-full) .cup-steam path { animation: wisp 1.6s ease-in-out var(--d) 1; }

/* The loyalty card: a real card on the table, a week of days, Monday first. */
.loyalty {
  padding: 13px 16px 12px; border: 1px solid var(--rule); border-radius: 6px;
  background: var(--paper-2);
}
.lc-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 11px; }
.lc-name { font-family: var(--serif); font-size: 17px; font-weight: 600; letter-spacing: -.01em; color: var(--ink); }
.lc-kind { font-size: 9.5px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--accent); }
.lc-cups { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px 4px; justify-items: center; }
.lc-day { display: flex; flex-direction: column; align-items: center; gap: 5px; width: 100%; }
.lc-cup {
  display: grid; place-items: center; width: 100%; max-width: 34px; aspect-ratio: 1; border-radius: 50%;
  border: 1.5px dashed var(--rule); color: var(--ink-3);
}
.lc-cup.is-ahead { opacity: .5; }        /* days still to come this week */
.lc-letter { font-size: 10.5px; line-height: 1; color: var(--ink-3); }
.lc-day.is-today .lc-letter { color: var(--ink); font-weight: 600; }
.lc-note + .lc-note { margin-top: 4px; }
.lc-foot { margin: 6px 0 0; font-size: 11.5px; color: var(--ink-3); }
.lc-cup svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linejoin: round; }
.lc-cup.is-punched { border: none; background: var(--caramel); color: var(--on-caramel); }
.lc-cup.is-punched svg path:first-child { fill: currentColor; }
/* stamped by hand, so never quite straight */
.lc-cup.is-punched { transform: rotate(var(--tilt, 0deg)); }
.lc-day:nth-child(3n+1) .lc-cup.is-punched { --tilt: -9deg; }
.lc-day:nth-child(3n+2) .lc-cup.is-punched { --tilt: 6deg; }
.lc-note { margin: 11px 0 0; font-size: 13px; line-height: 1.45; color: var(--ink-2); }
.lc-note b { color: var(--ink); }

/* Spare days (a voucher) and big days (the fullest cup), and the ? beside them. */
.ic { display: inline-block; flex: none; width: 22px; height: 22px; vertical-align: -6px; }
.ic-spare, .ic-big { color: var(--caramel); }
.ic-spare.is-empty { opacity: .5; }
.spare-tokens { display: inline-flex; gap: 2px; vertical-align: -6px; }
.spare-tokens .ic { vertical-align: 0; }
.day-cup-meta { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 8px 0 0; font-size: 13px; color: var(--ink-2); }
.meta-item { display: inline-flex; align-items: center; gap: 6px; }
.spare-earn { display: block; margin-top: 6px; }
.won-note .ic { margin-right: 6px; color: inherit; }

/* A little life on hover, or a tap on a phone (.is-poked, from cafe.js):
   the big day's steam rises as the cup tips, spare-day vouchers wiggle,
   a stamped day thunks down like the stamp's pressed again, and an empty
   one lifts. The stamps keep their hand-stamped tilt (--tilt) throughout. */
@keyframes ic-steam {
  0% { transform: translateY(1.5px); opacity: .2; }
  45% { opacity: 1; }
  100% { transform: translateY(-3px); opacity: 0; }
}
@keyframes ic-wiggle {
  0%, 100% { transform: rotate(0); }
  25% { transform: rotate(-12deg) scale(1.14); }
  55% { transform: rotate(9deg) scale(1.08); }
  80% { transform: rotate(-4deg); }
}
@keyframes stamp-thunk {
  0% { transform: rotate(var(--tilt, 0deg)) scale(1); }
  30% { transform: rotate(calc(var(--tilt, 0deg) - 10deg)) translateY(-3px) scale(1.16); }
  55% { transform: rotate(var(--tilt, 0deg)) scale(.86); }
  78% { transform: rotate(var(--tilt, 0deg)) scale(1.05); }
  100% { transform: rotate(var(--tilt, 0deg)) scale(1); }
}
.ic-big { transition: transform .35s cubic-bezier(.34, 1.56, .64, 1); }
.ic-big .ic-steam path { transform-box: fill-box; }
.ic-big .ic-steam path:nth-child(2) { animation-delay: .25s; }
.ic-big .ic-steam path:nth-child(3) { animation-delay: .5s; }
.ic-spare { transform-origin: 50% 60%; }
.ic-spare:nth-child(2) { animation-delay: .07s; }
.ic-spare:nth-child(3) { animation-delay: .14s; }
.lc-cup, .week-stamp { transition: transform .25s ease, border-color .2s ease, color .2s ease; }
@media (hover: hover) {
  :is(.meta-item, .spare-earn, .won-note):hover .ic-big { transform: translateY(-2px) rotate(-8deg); }
  :is(.meta-item, .spare-earn, .won-note):hover .ic-big .ic-steam path { animation: ic-steam 1.2s ease-out infinite; }
  :is(.meta-item, .spare-line, .won-note):hover .ic-spare:not(.is-empty) { animation: ic-wiggle .6s ease-in-out; }
  .lc-day:hover .lc-cup.is-punched,
  .week-day.is-on:hover .week-stamp { animation: stamp-thunk .55s ease-out; }
  .lc-day:hover .lc-cup:not(.is-punched),
  .week-day:not(.is-on):hover .week-stamp { transform: translateY(-3px); border-color: var(--caramel); color: var(--caramel); }
}
:is(.meta-item, .spare-line, .won-note).is-poked .ic-big { transform: translateY(-2px) rotate(-8deg); }
:is(.meta-item, .spare-line, .won-note).is-poked .ic-big .ic-steam path { animation: ic-steam 1.2s ease-out; }
:is(.meta-item, .spare-line, .won-note).is-poked .ic-spare:not(.is-empty) { animation: ic-wiggle .6s ease-in-out; }
.lc-day.is-poked .lc-cup.is-punched,
.week-day.is-on.is-poked .week-stamp { animation: stamp-thunk .55s ease-out; }
.lc-day.is-poked .lc-cup:not(.is-punched),
.week-day.is-poked:not(.is-on) .week-stamp { transform: translateY(-3px); border-color: var(--caramel); color: var(--caramel); }
.tip-q {
  position: relative; display: inline-grid; place-items: center; width: 18px; height: 18px;
  margin-left: 2px; padding: 0; border: 1.5px solid currentColor; border-radius: 50%;
  background: none; color: var(--ink-3); font: 700 11px/1 var(--sans); cursor: pointer; vertical-align: 1px;
}
.tip-q::after { content: ""; position: absolute; inset: -11px; }   /* a fingertip-sized target */
.tip-q:hover, .tip-q[aria-expanded="true"] { color: var(--accent); }
.tip-q:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.tip-card {
  position: fixed; z-index: 90; padding: 14px 16px 6px; border: 1px solid var(--rule); border-radius: 8px;
  background: var(--paper); color: var(--ink); box-shadow: 0 12px 30px rgba(0, 0, 0, .22);
  font-size: 14px; line-height: 1.5;
}
.tip-card p { margin: 0 0 8px; color: var(--ink-2); }
.tip-card .tip-title { font-family: var(--serif); font-size: 18px; font-weight: 600; color: var(--ink); }

/* A till receipt: thermal-paper type, dashed rules, a torn bottom edge. */
.receipt {
  position: relative; max-width: 300px; margin: 8px auto 22px; padding: 18px 18px 20px;
  background: var(--paper-2); color: var(--ink);
  font-family: var(--mono); font-size: 12px; line-height: 1.55;
  box-shadow: 0 1px 0 var(--rule), 0 8px 22px rgba(31, 23, 18, .09);
}
.receipt::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -8px; height: 8px;
  background:
    linear-gradient(135deg, var(--paper-2) 50%, transparent 50%) 0 0 / 12px 8px repeat-x,
    linear-gradient(225deg, var(--paper-2) 50%, transparent 50%) 0 0 / 12px 8px repeat-x;
}
.receipt-shop { margin: 0; text-align: center; font-family: var(--serif); font-size: 21px; font-weight: 600; }
.receipt-meta {
  margin: 3px 0 12px; text-align: center; font-size: 10.5px;
  letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3);
}
.receipt-items { list-style: none; margin: 0; padding: 9px 0; border-block: 1px dashed var(--ink-3); }
.receipt-items li { display: grid; grid-template-columns: 2ch minmax(0, 1fr) auto; gap: 8px; padding: 1px 0; }
.ri-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ri-end { color: var(--ink-3); }
.ri-more .ri-name { grid-column: 2 / 4; color: var(--ink-3); }
.receipt-totals { padding-top: 8px; }
.receipt-totals p { display: flex; justify-content: space-between; gap: 12px; margin: 0; padding: 1px 0; }
.receipt-totals .is-total { font-size: 13px; font-weight: 500; }
.receipt-thanks {
  margin: 14px 0 0; text-align: center; font-size: 10.5px;
  letter-spacing: .08em; text-transform: uppercase; color: var(--ink-2);
}
.receipt-dialog { max-width: 360px; }
.receipt-dialog .receipt { margin-bottom: 24px; }
.week-receipt { margin-top: 14px; }

/* A finished track: a flat white from above, the heart poured in. */
.latte-drop { display: flex; align-items: center; gap: 16px; margin-top: 16px; }
.latte-art { flex: none; width: 96px; height: 96px; }
.la-saucer { fill: var(--paper-3); stroke: var(--rule); stroke-width: 1.5; }
.la-cup { fill: #f6ede0; stroke: rgba(31, 23, 18, .18); stroke-width: 1.2; }
.la-heart { transform-box: fill-box; transform-origin: 50% 60%; animation: pour .9s .35s cubic-bezier(.2, 1.3, .4, 1) both; }
@keyframes pour {
  from { opacity: 0; transform: scale(.2) rotate(-14deg); }
  to   { opacity: 1; transform: none; }
}

/* Wide screens: beans in the empty margins either side of the reading column.
   Not beside a lesson, problem or the Sandbox, which use the whole width. */
@media (min-width: 1040px) {
  .app::before,
  .app::after {
    content: ""; position: fixed; top: 0; bottom: 0; z-index: 0; pointer-events: none;
    /* what's left beside a list screen (--wide, its width), less a gap */
    width: max(0px, calc((100vw - var(--wide, 1100px)) / 2 - 40px));
    background: var(--beans) 0 0 / 180px 180px repeat;
  }
  .app::before { left: 0; }
  .app::after { right: 0; background-position: 90px 40px; }
  .app.is-workbench::before,
  .app.is-workbench::after { display: none; }
  .screen { position: relative; z-index: 1; }
}

/* ── First time here (js/screens/welcome.js, js/guide.js) ─── */

.app.is-welcome .tabbar { display: none; }
.welcome-head { text-align: center; }
.welcome-mark { display: block; width: 64px; height: 64px; margin: 4px auto 18px; border-radius: 14px; box-shadow: 0 0 0 1px var(--rule); }
.welcome-lede { margin: 12px auto 0; max-width: 34em; font-size: 16px; line-height: 1.55; color: var(--ink-2); }
.welcome-starts { display: grid; gap: 10px; margin-top: 4px; }
.welcome-start {
  display: grid; gap: 3px; width: 100%; padding: 14px 16px; text-align: left; cursor: pointer;
  border: 1px solid var(--rule); border-radius: 6px; background: var(--paper-2); color: var(--ink);
  font: inherit; transition: border-color .15s ease, transform .1s ease;
}
.welcome-start:hover { border-color: var(--accent); }
.welcome-start:active { transform: scale(.99); }
.welcome-start:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.welcome-start-t { font-family: var(--serif); font-size: 19px; font-weight: 600; line-height: 1.2; }
.welcome-start-n { font-size: 14px; line-height: 1.4; color: var(--ink-2); }
.welcome-small { margin: 12px 0 0; font-size: 13.5px; line-height: 1.5; }

/* The guide: the screen dimmed, one real thing lit, a note beside it. */
.guide { position: fixed; inset: 0; z-index: 80; }
.guide-spot {
  position: fixed; border-radius: 8px; pointer-events: none;
  box-shadow: 0 0 0 200vmax rgba(15, 10, 6, .62);
  transition: left .25s ease, top .25s ease, width .25s ease, height .25s ease;
}
.guide-card {
  position: fixed; padding: 16px 16px 12px; border-radius: 8px;
  background: var(--paper); color: var(--ink); box-shadow: 0 12px 34px rgba(0, 0, 0, .28);
}
.guide-count { margin: 0 0 4px; font-size: 10px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--accent); }
.guide-title { margin: 0; font-family: var(--serif); font-size: 21px; font-weight: 600; line-height: 1.15; }
.guide-text { margin: 6px 0 12px; font-size: 14.5px; line-height: 1.5; color: var(--ink-2); }
.guide-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.guide-nav { display: flex; gap: 8px; }

/* Courses: every stage open, each with a line on what it covers (the one
   you're on has it in the intro instead, and says "You're here"). */
.stage-note { margin: -4px 0 12px; font-size: 14px; line-height: 1.5; color: var(--ink-2); }
.part-count .next-tag { margin-right: 6px; }

/* a track's stamp card; a hover or a tap stamps one again (js/cafe.js) */
.stamp-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 12px 10px; padding: 4px 2px 16px;
}
@media (hover: hover) {
  .stamp-grid .stamp:hover { animation: stamp-thunk .55s ease-out; }
}
.stamp-grid .stamp.is-poked { animation: stamp-thunk .55s ease-out; }

/* the game layer's news under a win: a quest, a run, a spare day, a level */
.won-extra { font-weight: 600; }
.won-extra + .won-extra { margin-top: 1px; }

/* ── The game layer: quest, achievements, bosses (js/game.js) ── */

.quest .lesson-name { font-weight: 500; text-wrap: balance; }
/* "+40 points" is wider than a price: on a narrow phone the dots give way
   first, and a name that still wraps splits evenly, never leaving one word. */
.quest .lesson-row { gap: 10px; }
.quest .lesson-row::after { flex-basis: 0; min-width: 0; }
/* a plain line under a cafe-named section head, saying what it really is */
.part-sub { margin: 8px 0 2px; font-size: 13px; line-height: 1.4; color: var(--ink-3); }
.quest-tally { margin-top: 10px; }

.ach-list { list-style: none; margin: 4px 0 0; padding: 0; }
.ach {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 0; border-bottom: 1px solid var(--rule-soft);
}
/* Still to earn: the stamp's drawing in a faint dashed ring. */
.stamp-ghost { flex: none; width: 30px; height: 30px; color: var(--ink-3); opacity: .75; }
/* Earned: a sheet of stamps, each in its own ink (js/stamps.js). */
.ach-stamps {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 20px 12px; list-style: none; margin: 16px 0 10px; padding: 0;
}
.ach-got { display: flex; flex-direction: column; align-items: center; gap: 3px; text-align: center; cursor: default; }
.ach-got .ach-stamp { width: min(100px, 100%); margin-bottom: 6px; }
.ach-got .ach-name { font-size: 14px; font-weight: 600; line-height: 1.3; color: var(--ink); text-wrap: balance; }
.ach-new { font-weight: 700; color: var(--accent); }
/* How far along a counted one is: a thin bar and "12 of 25". */
.ach-so { display: flex; align-items: center; gap: 10px; margin-top: 5px; font-size: 12px; font-weight: 600; color: var(--ink-2); white-space: nowrap; }
.ach .ach-text { flex: 1; }
.ach-bar { flex: 0 1 140px; height: 5px; border-radius: 3px; background: var(--rule-soft); overflow: hidden; }
.ach-bar i { display: block; height: 100%; border-radius: inherit; background: var(--accent); }
/* A new achievement under the reward box: its stamp lands after the lesson's. */
.stamp-drop.ach-drop .ach-stamp { width: 104px; animation: thunk .6s calc(.75s + var(--d, 0s)) cubic-bezier(.2, 1.3, .4, 1) both; }
.ink-nude { --accent: var(--caramel); }
.stamp-n.is-word { font-size: 19px; letter-spacing: .02em; }
/* A stamp you haven't seen lands with a thunk, one after another (--d). */
.ach-got.is-new .ach-stamp { animation: thunk .6s calc(.25s + var(--d, 0s)) cubic-bezier(.2, 1.3, .4, 1) both; }
/* And stamps again on a hover, or a tap on a phone (.is-poked, js/cafe.js). */
@media (hover: hover) {
  .ach-got:not(.is-new):hover .ach-stamp { animation: stamp-thunk .55s ease-out; }
}
.ach-got.is-poked:not(.is-new) .ach-stamp { animation: stamp-thunk .55s ease-out; }
.ach-text { display: flex; flex-direction: column; min-width: 0; }
.ach-name { font-size: 15px; color: var(--ink-2); }
.ach.is-got .ach-name { color: var(--ink); font-weight: 600; }
.ach-how { font-size: 12.5px; color: var(--ink-3); }

.boss-note { margin: 12px 0 0; font-size: 13px; line-height: 1.45; color: var(--ink-3); }
.boss-tag {
  display: inline-block; margin-right: 6px; padding: 2px 6px; border: 1px solid currentColor;
  border-radius: 2px; font-size: 9px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase;
}
.boss-go { margin-top: 14px; }

/* The confetti's canvas, over everything and never in the way. */
.confetti { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 60; pointer-events: none; }

.verdict { border-left: 5px solid var(--accent); padding: 3px 0 3px 15px; }
.verdict .label { display: block; margin-bottom: 4px; color: var(--accent); }
.verdict p { margin: 0; font-size: 16px; line-height: 1.45; }
/* Build it from pieces (js/pieces.js): the answer cut up, tapped into order */
.pieces-how { margin: 0 0 10px; font-size: 14.5px; line-height: 1.5; }
.pieces-built, .pieces-tray { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-start; }
.pieces-built { min-height: 64px; padding: 10px; margin-bottom: 12px; border: 1px dashed var(--ink-3); }
.pieces-tray { margin-bottom: 14px; }
.pieces-lines .pieces-built, .pieces-lines .pieces-tray { flex-direction: column; align-items: stretch; }
.pieces-empty { align-self: center; font-size: 14px; color: var(--ink-3); }
.piece {
  min-height: 44px; padding: 9px 12px; border: 1px solid var(--rule); background: var(--paper-2);
  color: var(--ink); font-family: var(--mono); font-size: 13.5px; line-height: 1.45;
  white-space: pre-wrap; overflow-wrap: anywhere; text-align: left; cursor: pointer;
}
.pieces-built .piece { border-color: var(--accent); background: var(--paper); }
.piece:active { background: var(--accent); color: var(--on-accent); }
.piece-br { margin-right: 7px; color: var(--ink-3); }
/* after a part: a practice question that needs only what's been covered */
.ready-q { margin-top: 18px; }
.ready-q .label { margin: 0; }
/* what people most often get wrong here, after a second failed run */
.usual-mistake { border-left-color: var(--caramel); margin-top: 14px; }
.usual-mistake .label { color: var(--caramel); }

/* ── Disclosure ───────────────────────────────────────────── */

.reveal { border-bottom: 1px solid var(--rule-soft); }
.reveal:first-of-type { border-top: 1px solid var(--rule-soft); }
.reveal > summary {
  list-style: none; cursor: pointer; padding: 15px 0;
  display: flex; align-items: center; gap: 10px;
  font-size: 14.5px; font-weight: 500; color: var(--ink);
}
.reveal > summary::-webkit-details-marker { display: none; }
.reveal > summary::after {
  content: "+"; margin-left: auto; font-size: 19px; color: var(--accent); line-height: 1;
}
.reveal[open] > summary::after { content: "\2212"; }
.reveal-body { padding: 0 0 18px; font-size: 15px; color: var(--ink-2); }
.reveal-body p { margin: 0 0 10px; }
.reveal-body pre {
  margin: 0; padding: 13px 12px; border: 1px solid var(--rule); border-radius: 3px;
  background: var(--paper-2); font-family: var(--mono); font-size: 12px;
  line-height: 1.65; color: var(--ink); overflow-x: auto; white-space: pre;
}

/* ── You ──────────────────────────────────────────────────── */

.ledger { width: 100%; border-collapse: collapse; border-top: 2px solid var(--ink); }
.ledger td {
  padding: 14px 0; border-bottom: 1px solid var(--rule-soft); vertical-align: middle;
}
.ledger td:first-child {
  font-family: var(--serif); font-size: 21px; line-height: 1.1; color: var(--accent);
}
.ledger td:last-child {
  text-align: right; color: var(--ink-3); font-size: 12.5px; font-weight: 600; white-space: nowrap;
}
.ledger .bar { width: 40%; padding-left: 14px; padding-right: 14px; }

/* ── Misc ─────────────────────────────────────────────────── */

.toast {
  position: fixed; left: 50%; bottom: calc(88px + var(--safe-bottom));
  transform: translate(-50%, 12px);
  padding: 12px 20px; border-radius: 2px;
  background: var(--ink); color: var(--paper);
  font-size: 13.5px; font-weight: 500; opacity: 0; pointer-events: none;
  transition: opacity .22s, transform .22s; z-index: 40; max-width: 84vw; text-align: center;
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

.note { font-size: 14px; color: var(--ink-2); }

/* ═══════════════════════ Practice ═══════════════════════ */

/* Difficulty is an ink like the tracks are: set it on a container and the
   spine, labels, tallies and buttons inside all follow. */
/* Light values darkened so the ink still clears 4.5:1 on its own 10% tint (quiet buttons). */
:root { --easy: #3f6420; --medium: #7a5d0f; --hard: #b23a26; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --easy: #a8cc72; --medium: #e0b35a; --hard: #f07050; }
}
:root[data-theme="dark"] { --easy: #a8cc72; --medium: #e0b35a; --hard: #f07050; }
.d-easy   { --accent: var(--easy); }
.d-medium { --accent: var(--medium); }
.d-hard   { --accent: var(--hard); }

.figure-n small { font-size: .42em; letter-spacing: 0; color: var(--ink-3); }

.filters { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.filter {
  min-height: 40px; padding: 0 15px; cursor: pointer;
  border: 1px solid var(--rule); border-radius: 2px; background: var(--paper-2);
  font-size: 11px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase;
  color: var(--ink-2);
}
.filter.is-on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }

/* Tabs within a screen (Practice's subjects, the Sandbox's languages, You's
   sections): separate buttons, every one the same width, in a row. A row
   that can't fit on a phone says so with a class: .seg-wrap (Practice's six;
   ALGORITHMS won't fit in a sixth) becomes two even rows of three below
   560px, and .seg-wrap-narrow (the Sandbox's five) the same below 360px.
   On those narrowest phones the words also get a little less room round
   them, so the longest, ACHIEVEMENTS, still fits a third of the width. */
.filters.seg { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 6px; margin-bottom: 0; }
.seg .filter { min-width: 0; padding: 0 6px; letter-spacing: .08em; }
@media (max-width: 559px) {
  .filters.seg.seg-wrap { grid-auto-flow: row; grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 359px) {
  .filters.seg.seg-wrap-narrow { grid-auto-flow: row; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .seg .filter { padding: 0 3px; font-size: 10px; letter-spacing: .04em; }
}

.problems { border-top: 2px solid var(--ink); }

/* DAX: the tables a formula works on (ui.js daxTables), like an Excel
   lesson's sheet: each folded, with its row count beside its name. */
.dax-peek { margin-top: 14px; }
.dax-peek > .label { margin: 0 0 4px; }
.dax-table .dax-count { margin-left: 8px; font-size: 12px; font-weight: 400; color: var(--ink-3); }
.dax-table .sheet-count { margin: 0 0 6px; }
.dax-table .sheet-ranges { margin-bottom: 10px; }

/* Practice: topics that cut across the subjects (Data cleaning), and on a
   question, the same question in its other languages. */
.p-topics { display: flex; flex-direction: column; gap: 8px; }
.p-topics .label { margin: 0; }
.topic-link {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 48px; padding: 0 16px; cursor: pointer; text-align: left;
  border: 1px solid var(--rule); border-left: 3px solid var(--accent); border-radius: 2px;
  background: var(--paper-2); font: inherit; color: var(--ink);
}
.topic-link:hover { border-color: var(--accent); }
.topic-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.topic-name { font-weight: 600; }
.topic-count { font-size: 13px; color: var(--ink-3); white-space: nowrap; }
.also-in { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin: 12px 0 18px; }
.also-in .label { margin: 0 2px 0 0; }
.also-link {
  min-height: 32px; padding: 0 12px; cursor: pointer;
  border: 1px solid var(--rule); border-radius: 16px; background: var(--paper-2);
  font: inherit; font-size: 13px; font-weight: 600; color: var(--ink-2);
}
.also-link:hover { border-color: var(--accent); color: var(--ink); }
.also-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.also-link.is-done { color: var(--accent); }

/* Practice: one subject's problems, folded by difficulty and set like the
   menu on Tracks (serif name, dotted leader, count). */
.diff-fold > summary { align-items: baseline; padding: 16px 0; }
.level-name {
  font-family: var(--serif); font-size: 24px; font-weight: 400; line-height: 1.05;
  color: var(--accent); letter-spacing: -.01em;
}
.level-dots { flex: 1 1 16px; min-width: 16px; border-bottom: 2px dotted var(--rule); }
.level-count { font-size: 12px; font-weight: 600; color: var(--ink-3); }
.diff-fold > summary::after { margin-left: 4px; }
.diff-fold > .problems { margin-bottom: 18px; }
.problem-main { flex: 1; min-width: 0; }
.problem-main .lesson-name { display: block; }
.problem-tags {
  display: block; margin-top: 2px; font-size: 11.5px; color: var(--ink-3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.diff-tag {
  flex: none; font-size: 10px; font-weight: 700; letter-spacing: .12em;
  text-transform: uppercase; color: var(--accent);
}
/* a solved problem stays readable — unlike a lesson, you'll come back to it */
.problem-row.is-done .lesson-name { text-decoration: none; color: var(--ink-2); }

.prompt p { margin: 0 0 12px; font-size: 16px; line-height: 1.58; }
/* A practice question's situation (practice/stories.js): who's asking and
   why, set apart above the instructions so the task itself stays plain. */
.story { margin: 4px 0 18px; padding: 2px 0 2px 14px; border-left: 3px solid var(--accent); }
.story .label { display: block; margin-bottom: 4px; color: var(--accent); }
.story p { margin: 0; font-size: 15.5px; line-height: 1.55; color: var(--ink-2); font-style: italic; }
/* A question as a brief (practice.js briefHTML): the situation, what you're
   given with each column on its own line, what they want, what to return. */
.brief .brief-story { color: var(--ink); }
.brief-head { margin: 16px 0 6px; font-weight: 600; font-size: 15px; color: var(--ink); }
.brief-cols, .brief-list { margin: 0 0 14px; padding-left: 20px; }
.brief-cols li, .brief-list li { margin: 0 0 6px; font-size: 15.5px; line-height: 1.5; }
.brief-cols li code { margin-right: 8px; }
.brief-cols li span { color: var(--ink-2); }
.brief-out { padding: 10px 12px; border: 1px solid var(--rule); border-radius: 4px; background: var(--paper-2); }
.brief + .brief-head { margin-top: 4px; }
.task .brief-story { margin-top: 6px; }
/* A lesson's worked example (lesson.js, detail/): a fold like Go deeper,
   holding its code coloured like the editor, its result drawn the way a
   Run's is, then the code explained piece by piece. */
.worked .reveal-body > p { margin: 8px 0; font-size: 15.5px; line-height: 1.55; }
.worked-code {
  margin: 10px 0; padding: 12px; border: 1px solid var(--rule-soft); border-radius: 4px; background: var(--paper);
  font-family: var(--mono); font-size: 13.5px; line-height: 1.6; color: var(--ink); overflow-x: auto; white-space: pre;
}
.worked-out { margin: 0 0 6px; }
.worked-lines { margin: 0 0 8px; padding-left: 20px; }
.worked-lines li { margin: 0 0 8px; font-size: 15px; line-height: 1.5; }
.worked-lines li code { margin-right: 8px; }
.worked-lines li span { color: var(--ink-2); }
.p-example { grid-area: task; }
.p-example > .label { display: block; margin-bottom: 8px; color: var(--accent); }

.io { display: grid; gap: 10px; }
.io-block { border: 1px solid var(--rule); border-radius: 3px; background: var(--paper-2); overflow: hidden; }
.io-block.is-bad { border-color: var(--accent); }
.io-l {
  display: block; padding: 6px 12px; border-bottom: 1px solid var(--rule-soft);
  font-size: 9.5px; font-weight: 600; letter-spacing: .15em; text-transform: uppercase;
  color: var(--ink-3);
}
.io-block.is-bad .io-l { color: var(--accent); }
.io-name {
  display: block; padding: 8px 12px 6px;
  font-family: var(--mono); font-size: 12px; font-weight: 600; color: var(--ink-2);
}
/* The example, folded like Nudge me: a table under its own name, a short
   value on its row. Tables inside fill the width. */
.io-folds { border-top: 1px solid var(--rule-soft); }
.io-folds > .reveal:first-of-type { border-top: none; }
.judge .io-folds { margin-top: 12px; }
.io-fold-name { font-family: var(--mono); font-size: 14px; font-weight: 600; }
.io-row {
  display: flex; align-items: baseline; gap: 14px; padding: 15px 0;
  border-bottom: 1px solid var(--rule-soft); font-size: 14.5px; font-weight: 500; color: var(--ink);
}
.io-val {
  margin-left: auto; min-width: 0; overflow-x: auto; white-space: pre;
  font-family: var(--mono); font-size: 13px; color: var(--ink); background: none; padding: 0;
}
.io-note { margin: 0 0 12px; font-size: 14px; line-height: 1.5; color: var(--ink-2); }
.io-fold-label { margin: 14px 0 6px !important; font-family: var(--mono); font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.io-fold-label:first-child { margin-top: 0 !important; }
.io-fold .matrix.is-sheet.is-compact { min-width: 100%; }
.io-fold .matrix-note { margin: 0; }
.io-block .matrix-wrap + .io-name,
.io-block .matrix-note + .io-name,
.io-block pre + .io-name { border-top: 1px solid var(--rule); }
.io-block pre {
  margin: 0; padding: 10px 12px; overflow-x: auto;
  font-family: var(--mono); font-size: 12px; line-height: 1.55; color: var(--ink); white-space: pre;
}

.judge { border-left: 5px solid var(--accent); padding: 4px 0 4px 15px; }
.judge.is-ok { --accent: var(--good); }
.judge > .label { display: block; margin-bottom: 6px; color: var(--accent); }
.judge > p { margin: 0 0 12px; font-size: 15.5px; line-height: 1.45; }
.judge > .tally { margin: 0 0 12px; }
.judge-note { font-size: 12.5px !important; color: var(--ink-3); margin: 12px 0 0 !important; }

/* five tabs has to fit a 320px phone */
@media (max-width: 380px) {
  .tab { font-size: 9.5px; letter-spacing: .06em; padding-left: 2px; padding-right: 2px; }
}

/* ── Intellisense ──────────────────────────────────────────
   A printed index, not a floating card: hairline box, mono labels, the
   active row set in reverse. The signature is a solid ink slug. */
.isense {
  position: absolute; z-index: 30;
  background: var(--paper); color: var(--ink);
  border: 1px solid var(--ink); border-radius: 2px;
  box-shadow: 4px 4px 0 var(--rule);
  user-select: none; -webkit-user-select: none;   /* a long press must not select a label */
  -webkit-tap-highlight-color: transparent;
}
.isense-items {
  position: relative;               /* item offsetTop is measured from here */
  list-style: none; margin: 0; padding: 0;
  max-height: 222px; overflow-y: auto; overscroll-behavior: contain;
  scrollbar-width: thin;
}
.isense-item {
  display: flex; align-items: center; gap: 10px;
  min-height: 36px; padding: 0 10px;
  font-family: var(--mono); font-size: 13px; line-height: 1.2;
  cursor: pointer; border-bottom: 1px solid var(--rule-soft);
}
.isense-item:last-child { border-bottom: none; }
.isense-item.is-active { background: var(--ink); color: var(--paper); }
.isense-kind {
  flex: none; width: 34px; text-align: center;
  font-size: 9.5px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink-3);
}
.isense-kind.k-column { color: var(--accent); font-weight: 600; }
.isense-kind.k-method, .isense-kind.k-function, .isense-kind.k-builtin { color: var(--ink-2); }
.isense-item.is-active .isense-kind { color: inherit; opacity: .75; }
.isense-label { flex: none; font-weight: 500; }
.isense-detail {
  flex: 1 1 auto; min-width: 0; text-align: right;
  font-size: 11px; color: var(--ink-3);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.isense-item.is-active .isense-detail { color: inherit; opacity: .7; }
.isense-doc {
  margin: 0; padding: 8px 10px 9px; border-top: 1px solid var(--ink);
  font-size: 12px; line-height: 1.45; color: var(--ink-2);
}
.isense-doc[hidden] { display: none; }
.isense-sig {
  position: absolute; z-index: 29; max-width: min(460px, 100%);
  padding: 6px 10px 7px; border-radius: 2px;
  background: var(--ink); color: var(--paper);
  font-family: var(--mono); font-size: 12px; line-height: 1.4;
  pointer-events: none;
}
.isense-sig-call { overflow-wrap: anywhere; }
.isense-sig-call b { font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.isense-sig-doc { margin-top: 3px; font-family: var(--sans); font-size: 11.5px; opacity: .78; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  /* A looping animation cut to .01ms would flicker, so the brewing steam stops instead. */
  .boot-mark .brand-bar { animation: none !important; }
  /* Steam stays, standing still, wherever it means something. */
  .streak.is-warm .streak-steam path,
  .day-cup-art.is-full .cup-steam path { animation: none !important; opacity: .85; }
  .ic-big .ic-steam path { animation: none !important; }
  .ic-big, .ic-spare, .lc-cup, .week-stamp, .ach-stamp, .stamp-grid .stamp { animation: none !important; transition: none !important; }
  .tally i { animation: none !important; }
  .day-cup-art, .day-cup-art .cup-coffee, .day-cup-art .cup-crema { animation: none !important; }
  .guide-spot { transition: none; }
}

/* ═══════════════════════ Responsive ═══════════════════════ */

/* ── Very small phones ────────────────────────────────────── */
@media (max-width: 359px) {
  :root { --gut: 15px; }
  .figure-n { font-size: 37px; }
  .figure-l { font-size: 9px; letter-spacing: .1em; }
  .figure + .figure { padding-left: 12px; }
  .recipes { gap: 7px; }
  .recipe { padding: 11px 11px 10px; }
  .recipe-n { font-size: 18px; }
  .block { padding: 18px 16px 16px; }
}

/* ── Short viewports: landscape phones, small laptop windows ──
   Measured at 812x375 the content area is only ~274px tall, and a
   50px headline was eating a fifth of it. Trade display size for
   something you can actually work in. */
@media (max-height: 620px) {
  .display    { font-size: clamp(25px, 5.6vw, 33px); }
  .display-xl { font-size: clamp(30px, 7vw, 40px); }
  .block-title { font-size: clamp(25px, 5.4vw, 33px); }
  .boot-word  { font-size: 38px; }
  .boot .boot-mark { width: 52px; height: 52px; margin-bottom: 14px; border-radius: 12px; }
  .folio      { font-size: 30px; }
  .figure-n   { font-size: 32px; }
  .level-n    { font-size: 54px; }
  .track-name { font-size: 21px; }

  .screen { padding-top: 16px; padding-bottom: 28px; }
  .screen.lesson-screen::before { margin-bottom: 16px; }
  .stack > * + * { margin-top: 14px; }
  .editor { min-height: 112px; }
  .lesson-title { margin: 4px 0 14px; }
  .concept li { margin-bottom: 8px; }
  .tab { padding: 10px 4px 9px; }
  .topbar { padding-top: calc(var(--safe-top) + 9px); padding-bottom: 8px; }
}

/* ── Tablet and up ────────────────────────────────────────────
   The shell always spans the full window; the reading column is
   created by padding instead. That keeps the scrollbar on the
   window edge where it belongs, rather than floating at the edge
   of a centred box with page either side of it. */
@media (min-width: 700px) {
  :root { --gut: 32px; --col: 660px; }
  .screen, .topbar, .tabbar {
    max-width: none; margin-left: 0; margin-right: 0; width: 100%;
    padding-inline: max(var(--gut), calc((100% - var(--col)) / 2));
  }
}

/* ── Read on the left, work on the right ──────────────────────
   Two conditions want this. Wide screens: stacking the editor under
   the prose wastes half the width and makes you scroll between the
   task and your answer. Short-and-wide (a phone in landscape): there
   is no vertical room to stack anything, but plenty sideways. */
@media (min-width: 1040px),
       (orientation: landscape) and (min-width: 780px),
       (min-width: 720px) and (max-height: 620px) {
  .lesson-screen > .stack {
    display: grid;
    /* the reading holds a readable width; the editor and its output take
       the rest, which is what you want more of on a big monitor */
    grid-template-columns: minmax(0, min(50ch, 44%)) minmax(0, 1fr);
    /* min(50ch, 44%): on a desktop 44% is about 50ch anyway, but on a
       740px landscape phone a flat 50ch took most of it and left the editor little. */
    grid-template-areas:
      "bar   bar"
      "intro work"
      "task  work"
      "help  work";
    align-items: start;
    column-gap: 44px;
    row-gap: 22px;
  }
  /* row-gap replaces stack margins. min-width: 0 so a wide table or result
     scrolls inside its own box instead of widening its column. */
  .lesson-screen > .stack > * { margin-top: 0; min-width: 0; }
  .session-bar { grid-area: bar; }
  .l-intro   { grid-area: intro; }
  .task      { grid-area: task; }
  .l-help    { grid-area: help; }
  .l-work    { grid-area: work; }
  .s-intro   { grid-area: intro; }
  .s-recipes { grid-area: task; }

  .recipes { display: grid; grid-template-columns: 1fr 1fr; overflow: visible; padding-bottom: 0; }
  .recipes .recipe { min-width: 0; }

  /* A track index is a list — it stays one column at every width. */
  .lesson-screen > .stack:has(.lessons) { display: block; }
  .lesson-screen > .stack:has(.lessons) > * + * { margin-top: 22px; }
}

/* On a laptop or bigger, the work side stays in view. The reading side
   (the lesson, its example, the task) scrolls with the page, while the
   editor and its output stay pinned beside it, capped to the window, so you
   never scroll the editor away to read what to do. A long output scrolls
   inside the work side. --chrome-top and --tabbar-h are the pinned bars'
   heights (main.js). On lessons, practice and the Sandbox alike. */
@media (min-width: 1040px) and (min-height: 640px),
       (orientation: landscape) and (min-width: 780px) and (min-height: 640px) {
  .lesson-screen > .stack > .l-work,
  :root[data-layout="beside"] .lesson-screen > .stack > .l-work > #result {
    position: sticky; top: calc(var(--chrome-top, 58px) + 16px);
    max-height: calc(100dvh - var(--chrome-top, 58px) - var(--tabbar-h, 50px) - 32px);
    overflow-y: auto; overscroll-behavior: contain;
  }
  :root[data-layout="beside"] .lesson-screen > .stack > .l-work { position: static; max-height: none; overflow: visible; }
  .l-work .editor { min-height: clamp(200px, 32dvh, 380px); }
  /* Before the first run, the output's place says what will appear there. */
  .l-work > #result:empty::before {
    content: "Run your code, and what it gives back shows up here.";
    display: block; padding: 22px 18px; border: 1px dashed var(--rule); border-radius: 6px;
    font-size: 14px; line-height: 1.5; color: var(--ink-3);
  }
}

/* ── The other layout: code and output side by side ──────────
   Chosen with the editor bar's switch or in You → Settings → Display
   (data-layout="beside" on the root, per device). Two columns with the
   output pinned on the right while the reading and the editor share the
   left; three on a laptop, the editor in the middle and widest. The work
   column becomes display: contents, so its editor and output are laid out
   as two separate things. Phones always stack, so the switch hides there. */
.layout-switch { display: none; font-size: 12px; }
@media (min-width: 1040px),
       (orientation: landscape) and (min-width: 780px),
       (min-width: 720px) and (max-height: 620px) {
  .layout-switch { display: inline; }
  :root[data-layout="beside"] .lesson-screen > .stack {
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
    grid-template-areas:
      "bar   bar"
      "intro out"
      "task  out"
      "code  out"
      "help  out";
    column-gap: 32px;
  }
  :root[data-layout="beside"] .l-work { display: contents; }
  :root[data-layout="beside"] .l-work > * { margin-top: 0; min-width: 0; }
  :root[data-layout="beside"] .l-code { grid-area: code; }
  :root[data-layout="beside"] .s-take { grid-area: help; }
  :root[data-layout="beside"] .l-work > #result { grid-area: out; }
  :root[data-layout="beside"] .l-work > #result:empty::before {
    content: "Run your code, and what it gives back shows up here.";
    display: block; padding: 22px 18px; border: 1px dashed var(--rule); border-radius: 6px;
    font-size: 14px; line-height: 1.5; color: var(--ink-3);
  }
}
@media (min-width: 1200px) {
  :root[data-layout="beside"] .lesson-screen > .stack {
    grid-template-columns: minmax(0, .72fr) minmax(0, 1.3fr) minmax(0, 1fr);   /* reading, editor, output */
    grid-template-areas:
      "bar   bar  bar"
      "intro code out"
      "task  code out"
      "help  code out";
  }
  :root[data-layout="beside"] .l-code .editor { min-height: max(380px, calc(100dvh - 300px)); font-size: 14px; }
}


/* Roomy desktop */
@media (min-width: 1040px) {
  /* --wide: how wide a list screen gets. It grows with the window, so a big
     monitor isn't mostly margin: 1100px up to a 1375px window, then four
     fifths of it, up to 1560px. The beans in the margins size from it too. */
  :root { --col: 1100px; --wide: clamp(1100px, 80vw, 1560px); }
  .editor { min-height: 340px; }

  /* The shell fills the window, but list-shaped screens don't benefit from
     unlimited width — a row spanning 1900px puts a lesson title and its
     duration a whole screen apart. The workbench is deliberately excluded:
     that one should take everything it can get. */
  .screen:not(.lesson-screen) > .stack,
  .lesson-screen > .stack:has(.lessons) {
    max-width: var(--wide); margin-inline: auto;
  }
}

/* Landscape phone: keep the chrome tight */
@media (min-width: 720px) and (max-height: 620px) {
  .editor { min-height: 170px; }
  .lesson-screen > .stack { column-gap: 30px; row-gap: 14px; }
}

/* ── Landscape: a rotated device is asking for width, so use it ──
   Last block in the file so it wins over the narrower reading column
   set above. A landscape tablet at 1024 was previously boxed into 660px
   with 182px of dead gutter each side. */
@media (orientation: landscape) and (min-width: 700px) {
  /* --col: 100% collapses the centring padding to a plain gutter, so the
     app fills the window edge to edge. On a wide monitor the read pane
     stays at a readable width and the editor absorbs the extra space. */
  :root { --col: 100%; }

  /* rotated phones put the notch in a side gutter */
  .screen, .topbar {
    padding-left:  max(var(--gut), env(safe-area-inset-left));
    padding-right: max(var(--gut), env(safe-area-inset-right));
  }

  /* filling the screen must not turn prose into 100-character lines */
  .l-intro, .s-intro, .task, .block-sub, .note, .track-blurb { max-width: 62ch; }
  .concept li { max-width: 60ch; }

}

/* ── Big monitors ─────────────────────────────────────────────
   From 1300px a list screen has room for two things side by side, which
   beats one long column of rows with a title at one end and its number a
   screen away at the other. */
@media (min-width: 1300px) {
  /* .cols: two stacks, one under the other until here (Café, You) */
  .cols { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); column-gap: 56px; align-items: start; }
  .cols > * + * { margin-top: 0; }

  /* A course's page: its parts in two columns, read down the left then the
     right, so a lesson's name and its minutes aren't a screen apart. */
  .lesson-screen .lessons { columns: 2; column-gap: 56px; }
  .lesson-screen .lessons > .part { break-inside: avoid; }
  .lesson-screen .lessons > .part + .part { margin-top: 0; padding-top: 28px; }
  .lesson-screen .lessons > .part:first-child { padding-top: 28px; }

  /* Practice: what to look at on the left, the questions on the right. The
     browse wrapper steps aside (display: contents) so its parts can sit in
     either column; while a search is on it's hidden, and the results get
     the full width back. */
  .practice-list:not(:has(#practice-browse[hidden])) {
    display: grid; grid-template-columns: minmax(0, 400px) minmax(0, 1fr);
    grid-template-rows: repeat(7, auto) 1fr;      /* the left's seven things, then slack */
    column-gap: 56px; row-gap: 22px; align-items: start;
  }
  .practice-list:not(:has(#practice-browse[hidden])) > *,
  .practice-list #practice-browse:not([hidden]) > * { grid-column: 1; margin-top: 0; min-width: 0; }
  .practice-list #practice-browse:not([hidden]) { display: contents; }
  .practice-list #practice-browse:not([hidden]) > .levels { grid-column: 2; grid-row: 1 / -1; }
  .practice-list:not(:has(#practice-browse[hidden])) > .quick-row { width: 100%; max-width: none; }
  /* half a screen is too narrow for the cup beside the card */
  .cols .cafe-row { grid-template-columns: minmax(0, 1fr); }
  .practice-list .seg-wrap { grid-auto-flow: row; grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
/* Bigger again: everything on a list screen a size up, since the same text
   that suits a laptop looks small across a 1920px page. The width is divided
   by the zoom so the page still ends where --wide says (the beans rely on it). */
@media (min-width: 1600px) {
  .screen:not(.lesson-screen) > .stack,
  .lesson-screen > .stack:has(.lessons) {
    zoom: 1.08; max-width: calc(var(--wide) / 1.08);
  }
}

/* Two tracks abreast as soon as there is room for them */
@media (min-width: 1040px), (orientation: landscape) and (min-width: 900px) {
  .tracklist { display: grid; grid-template-columns: 1fr 1fr; column-gap: 40px; }
}
/* and three on a big monitor, where the page is wide enough to hold them */
@media (min-width: 1600px) {
  .tracklist { grid-template-columns: 1fr 1fr 1fr; }
}
/* inside one half of a two-column screen there's room for one */
@media (min-width: 1300px) {
  .cols .tracklist { grid-template-columns: 1fr; }
}
