/* The site's three typefaces, self-hosted from the fontsource packages and declared as
   Google Fonts declared them for the link the pages carried before: one @font-face per
   family, style, requested weight and subset (Bricolage Grotesque 700 and 800; Inter 400,
   500, 600 and 700; Newsreader 400 and 600, and 400 italic), each naming its one weight,
   with font-display: swap and the subset's unicode-range, so a browser fetches only the
   subsets a page uses and paints with the fallback meanwhile. The upright families are
   the packages' variable files, the italic a static instance: the files Google served.
   The family names are the ones the tokens in src/styles/tokens.css name (--sans, --serif,
   --display), whose fallbacks are unchanged. The shell links this file on every page,
   first of all its stylesheets, where the Google Fonts link was (tools/lib/shell.js
   VENDOR_STYLES); the build copies the files beside the bundle.
   WRITTEN BY tools/gen-fonts.js from the packages' own stylesheets: edit that, not this. */

/* bricolage-grotesque-vietnamese-wght-normal, 700 */
@font-face {
  font-family: 'Bricolage Grotesque';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url(./bricolage-grotesque-vietnamese-wght-normal.woff2) format('woff2-variations');
  unicode-range: U+0102-0103,U+0110-0111,U+0128-0129,U+0168-0169,U+01A0-01A1,U+01AF-01B0,U+0300-0301,U+0303-0304,U+0308-0309,U+0323,U+0329,U+1EA0-1EF9,U+20AB;
}

/* bricolage-grotesque-latin-ext-wght-normal, 700 */
@font-face {
  font-family: 'Bricolage Grotesque';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url(./bricolage-grotesque-latin-ext-wght-normal.woff2) format('woff2-variations');
  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-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF;
}

/* bricolage-grotesque-latin-wght-normal, 700 */
@font-face {
  font-family: 'Bricolage Grotesque';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url(./bricolage-grotesque-latin-wght-normal.woff2) format('woff2-variations');
  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;
}

/* bricolage-grotesque-vietnamese-wght-normal, 800 */
@font-face {
  font-family: 'Bricolage Grotesque';
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url(./bricolage-grotesque-vietnamese-wght-normal.woff2) format('woff2-variations');
  unicode-range: U+0102-0103,U+0110-0111,U+0128-0129,U+0168-0169,U+01A0-01A1,U+01AF-01B0,U+0300-0301,U+0303-0304,U+0308-0309,U+0323,U+0329,U+1EA0-1EF9,U+20AB;
}

/* bricolage-grotesque-latin-ext-wght-normal, 800 */
@font-face {
  font-family: 'Bricolage Grotesque';
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url(./bricolage-grotesque-latin-ext-wght-normal.woff2) format('woff2-variations');
  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-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF;
}

/* bricolage-grotesque-latin-wght-normal, 800 */
@font-face {
  font-family: 'Bricolage Grotesque';
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url(./bricolage-grotesque-latin-wght-normal.woff2) format('woff2-variations');
  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;
}

/* inter-cyrillic-ext-wght-normal, 400 */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(./inter-cyrillic-ext-wght-normal.woff2) format('woff2-variations');
  unicode-range: U+0460-052F,U+1C80-1C8A,U+20B4,U+2DE0-2DFF,U+A640-A69F,U+FE2E-FE2F;
}

/* inter-cyrillic-wght-normal, 400 */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(./inter-cyrillic-wght-normal.woff2) format('woff2-variations');
  unicode-range: U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116;
}

/* inter-greek-ext-wght-normal, 400 */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(./inter-greek-ext-wght-normal.woff2) format('woff2-variations');
  unicode-range: U+1F00-1FFF;
}

/* inter-greek-wght-normal, 400 */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(./inter-greek-wght-normal.woff2) format('woff2-variations');
  unicode-range: U+0370-0377,U+037A-037F,U+0384-038A,U+038C,U+038E-03A1,U+03A3-03FF;
}

/* inter-vietnamese-wght-normal, 400 */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(./inter-vietnamese-wght-normal.woff2) format('woff2-variations');
  unicode-range: U+0102-0103,U+0110-0111,U+0128-0129,U+0168-0169,U+01A0-01A1,U+01AF-01B0,U+0300-0301,U+0303-0304,U+0308-0309,U+0323,U+0329,U+1EA0-1EF9,U+20AB;
}

/* inter-latin-ext-wght-normal, 400 */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(./inter-latin-ext-wght-normal.woff2) format('woff2-variations');
  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-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF;
}

/* inter-latin-wght-normal, 400 */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(./inter-latin-wght-normal.woff2) format('woff2-variations');
  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;
}

/* inter-cyrillic-ext-wght-normal, 500 */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url(./inter-cyrillic-ext-wght-normal.woff2) format('woff2-variations');
  unicode-range: U+0460-052F,U+1C80-1C8A,U+20B4,U+2DE0-2DFF,U+A640-A69F,U+FE2E-FE2F;
}

/* inter-cyrillic-wght-normal, 500 */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url(./inter-cyrillic-wght-normal.woff2) format('woff2-variations');
  unicode-range: U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116;
}

/* inter-greek-ext-wght-normal, 500 */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url(./inter-greek-ext-wght-normal.woff2) format('woff2-variations');
  unicode-range: U+1F00-1FFF;
}

/* inter-greek-wght-normal, 500 */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url(./inter-greek-wght-normal.woff2) format('woff2-variations');
  unicode-range: U+0370-0377,U+037A-037F,U+0384-038A,U+038C,U+038E-03A1,U+03A3-03FF;
}

/* inter-vietnamese-wght-normal, 500 */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url(./inter-vietnamese-wght-normal.woff2) format('woff2-variations');
  unicode-range: U+0102-0103,U+0110-0111,U+0128-0129,U+0168-0169,U+01A0-01A1,U+01AF-01B0,U+0300-0301,U+0303-0304,U+0308-0309,U+0323,U+0329,U+1EA0-1EF9,U+20AB;
}

/* inter-latin-ext-wght-normal, 500 */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url(./inter-latin-ext-wght-normal.woff2) format('woff2-variations');
  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-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF;
}

/* inter-latin-wght-normal, 500 */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url(./inter-latin-wght-normal.woff2) format('woff2-variations');
  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;
}

/* inter-cyrillic-ext-wght-normal, 600 */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url(./inter-cyrillic-ext-wght-normal.woff2) format('woff2-variations');
  unicode-range: U+0460-052F,U+1C80-1C8A,U+20B4,U+2DE0-2DFF,U+A640-A69F,U+FE2E-FE2F;
}

/* inter-cyrillic-wght-normal, 600 */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url(./inter-cyrillic-wght-normal.woff2) format('woff2-variations');
  unicode-range: U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116;
}

/* inter-greek-ext-wght-normal, 600 */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url(./inter-greek-ext-wght-normal.woff2) format('woff2-variations');
  unicode-range: U+1F00-1FFF;
}

/* inter-greek-wght-normal, 600 */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url(./inter-greek-wght-normal.woff2) format('woff2-variations');
  unicode-range: U+0370-0377,U+037A-037F,U+0384-038A,U+038C,U+038E-03A1,U+03A3-03FF;
}

/* inter-vietnamese-wght-normal, 600 */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url(./inter-vietnamese-wght-normal.woff2) format('woff2-variations');
  unicode-range: U+0102-0103,U+0110-0111,U+0128-0129,U+0168-0169,U+01A0-01A1,U+01AF-01B0,U+0300-0301,U+0303-0304,U+0308-0309,U+0323,U+0329,U+1EA0-1EF9,U+20AB;
}

/* inter-latin-ext-wght-normal, 600 */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url(./inter-latin-ext-wght-normal.woff2) format('woff2-variations');
  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-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF;
}

/* inter-latin-wght-normal, 600 */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url(./inter-latin-wght-normal.woff2) format('woff2-variations');
  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;
}

/* inter-cyrillic-ext-wght-normal, 700 */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url(./inter-cyrillic-ext-wght-normal.woff2) format('woff2-variations');
  unicode-range: U+0460-052F,U+1C80-1C8A,U+20B4,U+2DE0-2DFF,U+A640-A69F,U+FE2E-FE2F;
}

/* inter-cyrillic-wght-normal, 700 */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url(./inter-cyrillic-wght-normal.woff2) format('woff2-variations');
  unicode-range: U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116;
}

/* inter-greek-ext-wght-normal, 700 */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url(./inter-greek-ext-wght-normal.woff2) format('woff2-variations');
  unicode-range: U+1F00-1FFF;
}

/* inter-greek-wght-normal, 700 */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url(./inter-greek-wght-normal.woff2) format('woff2-variations');
  unicode-range: U+0370-0377,U+037A-037F,U+0384-038A,U+038C,U+038E-03A1,U+03A3-03FF;
}

/* inter-vietnamese-wght-normal, 700 */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url(./inter-vietnamese-wght-normal.woff2) format('woff2-variations');
  unicode-range: U+0102-0103,U+0110-0111,U+0128-0129,U+0168-0169,U+01A0-01A1,U+01AF-01B0,U+0300-0301,U+0303-0304,U+0308-0309,U+0323,U+0329,U+1EA0-1EF9,U+20AB;
}

/* inter-latin-ext-wght-normal, 700 */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url(./inter-latin-ext-wght-normal.woff2) format('woff2-variations');
  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-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF;
}

/* inter-latin-wght-normal, 700 */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url(./inter-latin-wght-normal.woff2) format('woff2-variations');
  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;
}

/* newsreader-vietnamese-400-italic, 400 */
@font-face {
  font-family: 'Newsreader';
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url(./newsreader-vietnamese-400-italic.woff2) format('woff2'), url(./newsreader-vietnamese-400-italic.woff) format('woff');
  unicode-range: U+0102-0103,U+0110-0111,U+0128-0129,U+0168-0169,U+01A0-01A1,U+01AF-01B0,U+0300-0301,U+0303-0304,U+0308-0309,U+0323,U+0329,U+1EA0-1EF9,U+20AB;
}

/* newsreader-latin-ext-400-italic, 400 */
@font-face {
  font-family: 'Newsreader';
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url(./newsreader-latin-ext-400-italic.woff2) format('woff2'), url(./newsreader-latin-ext-400-italic.woff) format('woff');
  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-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF;
}

/* newsreader-latin-400-italic, 400 */
@font-face {
  font-family: 'Newsreader';
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url(./newsreader-latin-400-italic.woff2) format('woff2'), url(./newsreader-latin-400-italic.woff) format('woff');
  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;
}

/* newsreader-vietnamese-wght-normal, 400 */
@font-face {
  font-family: 'Newsreader';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(./newsreader-vietnamese-wght-normal.woff2) format('woff2-variations');
  unicode-range: U+0102-0103,U+0110-0111,U+0128-0129,U+0168-0169,U+01A0-01A1,U+01AF-01B0,U+0300-0301,U+0303-0304,U+0308-0309,U+0323,U+0329,U+1EA0-1EF9,U+20AB;
}

/* newsreader-latin-ext-wght-normal, 400 */
@font-face {
  font-family: 'Newsreader';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(./newsreader-latin-ext-wght-normal.woff2) format('woff2-variations');
  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-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF;
}

/* newsreader-latin-wght-normal, 400 */
@font-face {
  font-family: 'Newsreader';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(./newsreader-latin-wght-normal.woff2) format('woff2-variations');
  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;
}

/* newsreader-vietnamese-wght-normal, 600 */
@font-face {
  font-family: 'Newsreader';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url(./newsreader-vietnamese-wght-normal.woff2) format('woff2-variations');
  unicode-range: U+0102-0103,U+0110-0111,U+0128-0129,U+0168-0169,U+01A0-01A1,U+01AF-01B0,U+0300-0301,U+0303-0304,U+0308-0309,U+0323,U+0329,U+1EA0-1EF9,U+20AB;
}

/* newsreader-latin-ext-wght-normal, 600 */
@font-face {
  font-family: 'Newsreader';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url(./newsreader-latin-ext-wght-normal.woff2) format('woff2-variations');
  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-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF;
}

/* newsreader-latin-wght-normal, 600 */
@font-face {
  font-family: 'Newsreader';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url(./newsreader-latin-wght-normal.woff2) format('woff2-variations');
  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;
}
/* KaTeX's stylesheet, from the npm package (pinned at 0.16.47; it was 0.16.11, the version
   the pages loaded from its CDN, until advisory GHSA-cg87-wmx4-v546 moved it). The build
   inlines it here with its font files written beside the bundle; the shell links this
   file on every page after fonts.css and before the site's own stylesheets, where the
   CDN link was, so site.css's few rules on .katex still come after KaTeX's and win as
   they did (tools/lib/shell.js VENDOR_STYLES). The typesetter itself is
   src/vendor/katex.js. */@font-face{font-display:block;font-family:KaTeX_AMS;font-style:normal;font-weight:400;src:url(./KaTeX_AMS-Regular.woff2) format("woff2"),url(./KaTeX_AMS-Regular.woff) format("woff"),url(./KaTeX_AMS-Regular.ttf) format("truetype")}@font-face{font-display:block;font-family:KaTeX_Caligraphic;font-style:normal;font-weight:700;src:url(./KaTeX_Caligraphic-Bold.woff2) format("woff2"),url(./KaTeX_Caligraphic-Bold.woff) format("woff"),url(./KaTeX_Caligraphic-Bold.ttf) format("truetype")}@font-face{font-display:block;font-family:KaTeX_Caligraphic;font-style:normal;font-weight:400;src:url(./KaTeX_Caligraphic-Regular.woff2) format("woff2"),url(./KaTeX_Caligraphic-Regular.woff) format("woff"),url(./KaTeX_Caligraphic-Regular.ttf) format("truetype")}@font-face{font-display:block;font-family:KaTeX_Fraktur;font-style:normal;font-weight:700;src:url(./KaTeX_Fraktur-Bold.woff2) format("woff2"),url(./KaTeX_Fraktur-Bold.woff) format("woff"),url(./KaTeX_Fraktur-Bold.ttf) format("truetype")}@font-face{font-display:block;font-family:KaTeX_Fraktur;font-style:normal;font-weight:400;src:url(./KaTeX_Fraktur-Regular.woff2) format("woff2"),url(./KaTeX_Fraktur-Regular.woff) format("woff"),url(./KaTeX_Fraktur-Regular.ttf) format("truetype")}@font-face{font-display:block;font-family:KaTeX_Main;font-style:normal;font-weight:700;src:url(./KaTeX_Main-Bold.woff2) format("woff2"),url(./KaTeX_Main-Bold.woff) format("woff"),url(./KaTeX_Main-Bold.ttf) format("truetype")}@font-face{font-display:block;font-family:KaTeX_Main;font-style:italic;font-weight:700;src:url(./KaTeX_Main-BoldItalic.woff2) format("woff2"),url(./KaTeX_Main-BoldItalic.woff) format("woff"),url(./KaTeX_Main-BoldItalic.ttf) format("truetype")}@font-face{font-display:block;font-family:KaTeX_Main;font-style:italic;font-weight:400;src:url(./KaTeX_Main-Italic.woff2) format("woff2"),url(./KaTeX_Main-Italic.woff) format("woff"),url(./KaTeX_Main-Italic.ttf) format("truetype")}@font-face{font-display:block;font-family:KaTeX_Main;font-style:normal;font-weight:400;src:url(./KaTeX_Main-Regular.woff2) format("woff2"),url(./KaTeX_Main-Regular.woff) format("woff"),url(./KaTeX_Main-Regular.ttf) format("truetype")}@font-face{font-display:block;font-family:KaTeX_Math;font-style:italic;font-weight:700;src:url(./KaTeX_Math-BoldItalic.woff2) format("woff2"),url(./KaTeX_Math-BoldItalic.woff) format("woff"),url(./KaTeX_Math-BoldItalic.ttf) format("truetype")}@font-face{font-display:block;font-family:KaTeX_Math;font-style:italic;font-weight:400;src:url(./KaTeX_Math-Italic.woff2) format("woff2"),url(./KaTeX_Math-Italic.woff) format("woff"),url(./KaTeX_Math-Italic.ttf) format("truetype")}@font-face{font-display:block;font-family:"KaTeX_SansSerif";font-style:normal;font-weight:700;src:url(./KaTeX_SansSerif-Bold.woff2) format("woff2"),url(./KaTeX_SansSerif-Bold.woff) format("woff"),url(./KaTeX_SansSerif-Bold.ttf) format("truetype")}@font-face{font-display:block;font-family:"KaTeX_SansSerif";font-style:italic;font-weight:400;src:url(./KaTeX_SansSerif-Italic.woff2) format("woff2"),url(./KaTeX_SansSerif-Italic.woff) format("woff"),url(./KaTeX_SansSerif-Italic.ttf) format("truetype")}@font-face{font-display:block;font-family:"KaTeX_SansSerif";font-style:normal;font-weight:400;src:url(./KaTeX_SansSerif-Regular.woff2) format("woff2"),url(./KaTeX_SansSerif-Regular.woff) format("woff"),url(./KaTeX_SansSerif-Regular.ttf) format("truetype")}@font-face{font-display:block;font-family:KaTeX_Script;font-style:normal;font-weight:400;src:url(./KaTeX_Script-Regular.woff2) format("woff2"),url(./KaTeX_Script-Regular.woff) format("woff"),url(./KaTeX_Script-Regular.ttf) format("truetype")}@font-face{font-display:block;font-family:KaTeX_Size1;font-style:normal;font-weight:400;src:url(./KaTeX_Size1-Regular.woff2) format("woff2"),url(./KaTeX_Size1-Regular.woff) format("woff"),url(./KaTeX_Size1-Regular.ttf) format("truetype")}@font-face{font-display:block;font-family:KaTeX_Size2;font-style:normal;font-weight:400;src:url(./KaTeX_Size2-Regular.woff2) format("woff2"),url(./KaTeX_Size2-Regular.woff) format("woff"),url(./KaTeX_Size2-Regular.ttf) format("truetype")}@font-face{font-display:block;font-family:KaTeX_Size3;font-style:normal;font-weight:400;src:url(./KaTeX_Size3-Regular.woff2) format("woff2"),url(./KaTeX_Size3-Regular.woff) format("woff"),url(./KaTeX_Size3-Regular.ttf) format("truetype")}@font-face{font-display:block;font-family:KaTeX_Size4;font-style:normal;font-weight:400;src:url(./KaTeX_Size4-Regular.woff2) format("woff2"),url(./KaTeX_Size4-Regular.woff) format("woff"),url(./KaTeX_Size4-Regular.ttf) format("truetype")}@font-face{font-display:block;font-family:KaTeX_Typewriter;font-style:normal;font-weight:400;src:url(./KaTeX_Typewriter-Regular.woff2) format("woff2"),url(./KaTeX_Typewriter-Regular.woff) format("woff"),url(./KaTeX_Typewriter-Regular.ttf) format("truetype")}.katex{font:normal 1.21em KaTeX_Main,Times New Roman,serif;line-height:1.2;position:relative;text-indent:0;text-rendering:auto}.katex *{-ms-high-contrast-adjust:none!important;border-color:currentColor}.katex .katex-version:after{content:"0.16.47"}.katex .katex-mathml{border:0;-webkit-clip-path:inset(50%);clip-path:inset(50%);height:1px;overflow:hidden;padding:0;position:absolute;width:1px}.katex .katex-html>.newline{display:block}.katex .base{position:relative;white-space:nowrap;width:-webkit-min-content;width:-moz-min-content;width:min-content}.katex .base,.katex .strut{display:inline-block}.katex .textbf{font-weight:700}.katex .textit{font-style:italic}.katex .textrm{font-family:KaTeX_Main}.katex .textsf{font-family:KaTeX_SansSerif}.katex .texttt{font-family:KaTeX_Typewriter}.katex .mathnormal{font-family:KaTeX_Math;font-style:italic}.katex .mathit{font-family:KaTeX_Main;font-style:italic}.katex .mathrm{font-style:normal}.katex .mathbf{font-family:KaTeX_Main;font-weight:700}.katex .boldsymbol{font-family:KaTeX_Math;font-style:italic;font-weight:700}.katex .amsrm,.katex .mathbb,.katex .textbb{font-family:KaTeX_AMS}.katex .mathcal{font-family:KaTeX_Caligraphic}.katex .mathfrak,.katex .textfrak{font-family:KaTeX_Fraktur}.katex .mathboldfrak,.katex .textboldfrak{font-family:KaTeX_Fraktur;font-weight:700}.katex .mathtt{font-family:KaTeX_Typewriter}.katex .mathscr,.katex .textscr{font-family:KaTeX_Script}.katex .mathsf,.katex .textsf{font-family:KaTeX_SansSerif}.katex .mathboldsf,.katex .textboldsf{font-family:KaTeX_SansSerif;font-weight:700}.katex .mathitsf,.katex .mathsfit,.katex .textitsf{font-family:KaTeX_SansSerif;font-style:italic}.katex .mainrm{font-family:KaTeX_Main;font-style:normal}.katex .vlist-t{border-collapse:collapse;display:inline-table;table-layout:fixed}.katex .vlist-r{display:table-row}.katex .vlist{display:table-cell;position:relative;vertical-align:bottom}.katex .vlist>span{display:block;height:0;position:relative}.katex .vlist>span>span{display:inline-block}.katex .vlist>span>.pstrut{overflow:hidden;width:0}.katex .vlist-t2{margin-right:-2px}.katex .vlist-s{display:table-cell;font-size:1px;min-width:2px;vertical-align:bottom;width:2px}.katex .vbox{align-items:baseline;display:inline-flex;flex-direction:column}.katex .hbox{width:100%}.katex .hbox,.katex .thinbox{display:inline-flex;flex-direction:row}.katex .thinbox{max-width:0;width:0}.katex .msupsub{text-align:left}.katex .mfrac>span>span{text-align:center}.katex .mfrac .frac-line{border-bottom-style:solid;display:inline-block;width:100%}.katex .hdashline,.katex .hline,.katex .mfrac .frac-line,.katex .overline .overline-line,.katex .rule,.katex .underline .underline-line{min-height:1px}.katex .mspace{display:inline-block}.katex .smash{display:inline;line-height:0}.katex .clap,.katex .llap,.katex .rlap{position:relative;width:0}.katex .clap>.inner,.katex .llap>.inner,.katex .rlap>.inner{position:absolute}.katex .clap>.fix,.katex .llap>.fix,.katex .rlap>.fix{display:inline-block}.katex .llap>.inner{right:0}.katex .clap>.inner,.katex .rlap>.inner{left:0}.katex .clap>.inner>span{margin-left:-50%;margin-right:50%}.katex .rule{border:0 solid;display:inline-block;position:relative}.katex .hline,.katex .overline .overline-line,.katex .underline .underline-line{border-bottom-style:solid;display:inline-block;width:100%}.katex .hdashline{border-bottom-style:dashed;display:inline-block;width:100%}.katex .sqrt>.root{margin-left:.2777777778em;margin-right:-.5555555556em}.katex .fontsize-ensurer.reset-size1.size1,.katex .sizing.reset-size1.size1{font-size:1em}.katex .fontsize-ensurer.reset-size1.size2,.katex .sizing.reset-size1.size2{font-size:1.2em}.katex .fontsize-ensurer.reset-size1.size3,.katex .sizing.reset-size1.size3{font-size:1.4em}.katex .fontsize-ensurer.reset-size1.size4,.katex .sizing.reset-size1.size4{font-size:1.6em}.katex .fontsize-ensurer.reset-size1.size5,.katex .sizing.reset-size1.size5{font-size:1.8em}.katex .fontsize-ensurer.reset-size1.size6,.katex .sizing.reset-size1.size6{font-size:2em}.katex .fontsize-ensurer.reset-size1.size7,.katex .sizing.reset-size1.size7{font-size:2.4em}.katex .fontsize-ensurer.reset-size1.size8,.katex .sizing.reset-size1.size8{font-size:2.88em}.katex .fontsize-ensurer.reset-size1.size9,.katex .sizing.reset-size1.size9{font-size:3.456em}.katex .fontsize-ensurer.reset-size1.size10,.katex .sizing.reset-size1.size10{font-size:4.148em}.katex .fontsize-ensurer.reset-size1.size11,.katex .sizing.reset-size1.size11{font-size:4.976em}.katex .fontsize-ensurer.reset-size2.size1,.katex .sizing.reset-size2.size1{font-size:.8333333333em}.katex .fontsize-ensurer.reset-size2.size2,.katex .sizing.reset-size2.size2{font-size:1em}.katex .fontsize-ensurer.reset-size2.size3,.katex .sizing.reset-size2.size3{font-size:1.1666666667em}.katex .fontsize-ensurer.reset-size2.size4,.katex .sizing.reset-size2.size4{font-size:1.3333333333em}.katex .fontsize-ensurer.reset-size2.size5,.katex .sizing.reset-size2.size5{font-size:1.5em}.katex .fontsize-ensurer.reset-size2.size6,.katex .sizing.reset-size2.size6{font-size:1.6666666667em}.katex .fontsize-ensurer.reset-size2.size7,.katex .sizing.reset-size2.size7{font-size:2em}.katex .fontsize-ensurer.reset-size2.size8,.katex .sizing.reset-size2.size8{font-size:2.4em}.katex .fontsize-ensurer.reset-size2.size9,.katex .sizing.reset-size2.size9{font-size:2.88em}.katex .fontsize-ensurer.reset-size2.size10,.katex .sizing.reset-size2.size10{font-size:3.4566666667em}.katex .fontsize-ensurer.reset-size2.size11,.katex .sizing.reset-size2.size11{font-size:4.1466666667em}.katex .fontsize-ensurer.reset-size3.size1,.katex .sizing.reset-size3.size1{font-size:.7142857143em}.katex .fontsize-ensurer.reset-size3.size2,.katex .sizing.reset-size3.size2{font-size:.8571428571em}.katex .fontsize-ensurer.reset-size3.size3,.katex .sizing.reset-size3.size3{font-size:1em}.katex .fontsize-ensurer.reset-size3.size4,.katex .sizing.reset-size3.size4{font-size:1.1428571429em}.katex .fontsize-ensurer.reset-size3.size5,.katex .sizing.reset-size3.size5{font-size:1.2857142857em}.katex .fontsize-ensurer.reset-size3.size6,.katex .sizing.reset-size3.size6{font-size:1.4285714286em}.katex .fontsize-ensurer.reset-size3.size7,.katex .sizing.reset-size3.size7{font-size:1.7142857143em}.katex .fontsize-ensurer.reset-size3.size8,.katex .sizing.reset-size3.size8{font-size:2.0571428571em}.katex .fontsize-ensurer.reset-size3.size9,.katex .sizing.reset-size3.size9{font-size:2.4685714286em}.katex .fontsize-ensurer.reset-size3.size10,.katex .sizing.reset-size3.size10{font-size:2.9628571429em}.katex .fontsize-ensurer.reset-size3.size11,.katex .sizing.reset-size3.size11{font-size:3.5542857143em}.katex .fontsize-ensurer.reset-size4.size1,.katex .sizing.reset-size4.size1{font-size:.625em}.katex .fontsize-ensurer.reset-size4.size2,.katex .sizing.reset-size4.size2{font-size:.75em}.katex .fontsize-ensurer.reset-size4.size3,.katex .sizing.reset-size4.size3{font-size:.875em}.katex .fontsize-ensurer.reset-size4.size4,.katex .sizing.reset-size4.size4{font-size:1em}.katex .fontsize-ensurer.reset-size4.size5,.katex .sizing.reset-size4.size5{font-size:1.125em}.katex .fontsize-ensurer.reset-size4.size6,.katex .sizing.reset-size4.size6{font-size:1.25em}.katex .fontsize-ensurer.reset-size4.size7,.katex .sizing.reset-size4.size7{font-size:1.5em}.katex .fontsize-ensurer.reset-size4.size8,.katex .sizing.reset-size4.size8{font-size:1.8em}.katex .fontsize-ensurer.reset-size4.size9,.katex .sizing.reset-size4.size9{font-size:2.16em}.katex .fontsize-ensurer.reset-size4.size10,.katex .sizing.reset-size4.size10{font-size:2.5925em}.katex .fontsize-ensurer.reset-size4.size11,.katex .sizing.reset-size4.size11{font-size:3.11em}.katex .fontsize-ensurer.reset-size5.size1,.katex .sizing.reset-size5.size1{font-size:.5555555556em}.katex .fontsize-ensurer.reset-size5.size2,.katex .sizing.reset-size5.size2{font-size:.6666666667em}.katex .fontsize-ensurer.reset-size5.size3,.katex .sizing.reset-size5.size3{font-size:.7777777778em}.katex .fontsize-ensurer.reset-size5.size4,.katex .sizing.reset-size5.size4{font-size:.8888888889em}.katex .fontsize-ensurer.reset-size5.size5,.katex .sizing.reset-size5.size5{font-size:1em}.katex .fontsize-ensurer.reset-size5.size6,.katex .sizing.reset-size5.size6{font-size:1.1111111111em}.katex .fontsize-ensurer.reset-size5.size7,.katex .sizing.reset-size5.size7{font-size:1.3333333333em}.katex .fontsize-ensurer.reset-size5.size8,.katex .sizing.reset-size5.size8{font-size:1.6em}.katex .fontsize-ensurer.reset-size5.size9,.katex .sizing.reset-size5.size9{font-size:1.92em}.katex .fontsize-ensurer.reset-size5.size10,.katex .sizing.reset-size5.size10{font-size:2.3044444444em}.katex .fontsize-ensurer.reset-size5.size11,.katex .sizing.reset-size5.size11{font-size:2.7644444444em}.katex .fontsize-ensurer.reset-size6.size1,.katex .sizing.reset-size6.size1{font-size:.5em}.katex .fontsize-ensurer.reset-size6.size2,.katex .sizing.reset-size6.size2{font-size:.6em}.katex .fontsize-ensurer.reset-size6.size3,.katex .sizing.reset-size6.size3{font-size:.7em}.katex .fontsize-ensurer.reset-size6.size4,.katex .sizing.reset-size6.size4{font-size:.8em}.katex .fontsize-ensurer.reset-size6.size5,.katex .sizing.reset-size6.size5{font-size:.9em}.katex .fontsize-ensurer.reset-size6.size6,.katex .sizing.reset-size6.size6{font-size:1em}.katex .fontsize-ensurer.reset-size6.size7,.katex .sizing.reset-size6.size7{font-size:1.2em}.katex .fontsize-ensurer.reset-size6.size8,.katex .sizing.reset-size6.size8{font-size:1.44em}.katex .fontsize-ensurer.reset-size6.size9,.katex .sizing.reset-size6.size9{font-size:1.728em}.katex .fontsize-ensurer.reset-size6.size10,.katex .sizing.reset-size6.size10{font-size:2.074em}.katex .fontsize-ensurer.reset-size6.size11,.katex .sizing.reset-size6.size11{font-size:2.488em}.katex .fontsize-ensurer.reset-size7.size1,.katex .sizing.reset-size7.size1{font-size:.4166666667em}.katex .fontsize-ensurer.reset-size7.size2,.katex .sizing.reset-size7.size2{font-size:.5em}.katex .fontsize-ensurer.reset-size7.size3,.katex .sizing.reset-size7.size3{font-size:.5833333333em}.katex .fontsize-ensurer.reset-size7.size4,.katex .sizing.reset-size7.size4{font-size:.6666666667em}.katex .fontsize-ensurer.reset-size7.size5,.katex .sizing.reset-size7.size5{font-size:.75em}.katex .fontsize-ensurer.reset-size7.size6,.katex .sizing.reset-size7.size6{font-size:.8333333333em}.katex .fontsize-ensurer.reset-size7.size7,.katex .sizing.reset-size7.size7{font-size:1em}.katex .fontsize-ensurer.reset-size7.size8,.katex .sizing.reset-size7.size8{font-size:1.2em}.katex .fontsize-ensurer.reset-size7.size9,.katex .sizing.reset-size7.size9{font-size:1.44em}.katex .fontsize-ensurer.reset-size7.size10,.katex .sizing.reset-size7.size10{font-size:1.7283333333em}.katex .fontsize-ensurer.reset-size7.size11,.katex .sizing.reset-size7.size11{font-size:2.0733333333em}.katex .fontsize-ensurer.reset-size8.size1,.katex .sizing.reset-size8.size1{font-size:.3472222222em}.katex .fontsize-ensurer.reset-size8.size2,.katex .sizing.reset-size8.size2{font-size:.4166666667em}.katex .fontsize-ensurer.reset-size8.size3,.katex .sizing.reset-size8.size3{font-size:.4861111111em}.katex .fontsize-ensurer.reset-size8.size4,.katex .sizing.reset-size8.size4{font-size:.5555555556em}.katex .fontsize-ensurer.reset-size8.size5,.katex .sizing.reset-size8.size5{font-size:.625em}.katex .fontsize-ensurer.reset-size8.size6,.katex .sizing.reset-size8.size6{font-size:.6944444444em}.katex .fontsize-ensurer.reset-size8.size7,.katex .sizing.reset-size8.size7{font-size:.8333333333em}.katex .fontsize-ensurer.reset-size8.size8,.katex .sizing.reset-size8.size8{font-size:1em}.katex .fontsize-ensurer.reset-size8.size9,.katex .sizing.reset-size8.size9{font-size:1.2em}.katex .fontsize-ensurer.reset-size8.size10,.katex .sizing.reset-size8.size10{font-size:1.4402777778em}.katex .fontsize-ensurer.reset-size8.size11,.katex .sizing.reset-size8.size11{font-size:1.7277777778em}.katex .fontsize-ensurer.reset-size9.size1,.katex .sizing.reset-size9.size1{font-size:.2893518519em}.katex .fontsize-ensurer.reset-size9.size2,.katex .sizing.reset-size9.size2{font-size:.3472222222em}.katex .fontsize-ensurer.reset-size9.size3,.katex .sizing.reset-size9.size3{font-size:.4050925926em}.katex .fontsize-ensurer.reset-size9.size4,.katex .sizing.reset-size9.size4{font-size:.462962963em}.katex .fontsize-ensurer.reset-size9.size5,.katex .sizing.reset-size9.size5{font-size:.5208333333em}.katex .fontsize-ensurer.reset-size9.size6,.katex .sizing.reset-size9.size6{font-size:.5787037037em}.katex .fontsize-ensurer.reset-size9.size7,.katex .sizing.reset-size9.size7{font-size:.6944444444em}.katex .fontsize-ensurer.reset-size9.size8,.katex .sizing.reset-size9.size8{font-size:.8333333333em}.katex .fontsize-ensurer.reset-size9.size9,.katex .sizing.reset-size9.size9{font-size:1em}.katex .fontsize-ensurer.reset-size9.size10,.katex .sizing.reset-size9.size10{font-size:1.2002314815em}.katex .fontsize-ensurer.reset-size9.size11,.katex .sizing.reset-size9.size11{font-size:1.4398148148em}.katex .fontsize-ensurer.reset-size10.size1,.katex .sizing.reset-size10.size1{font-size:.2410800386em}.katex .fontsize-ensurer.reset-size10.size2,.katex .sizing.reset-size10.size2{font-size:.2892960463em}.katex .fontsize-ensurer.reset-size10.size3,.katex .sizing.reset-size10.size3{font-size:.337512054em}.katex .fontsize-ensurer.reset-size10.size4,.katex .sizing.reset-size10.size4{font-size:.3857280617em}.katex .fontsize-ensurer.reset-size10.size5,.katex .sizing.reset-size10.size5{font-size:.4339440694em}.katex .fontsize-ensurer.reset-size10.size6,.katex .sizing.reset-size10.size6{font-size:.4821600771em}.katex .fontsize-ensurer.reset-size10.size7,.katex .sizing.reset-size10.size7{font-size:.5785920926em}.katex .fontsize-ensurer.reset-size10.size8,.katex .sizing.reset-size10.size8{font-size:.6943105111em}.katex .fontsize-ensurer.reset-size10.size9,.katex .sizing.reset-size10.size9{font-size:.8331726133em}.katex .fontsize-ensurer.reset-size10.size10,.katex .sizing.reset-size10.size10{font-size:1em}.katex .fontsize-ensurer.reset-size10.size11,.katex .sizing.reset-size10.size11{font-size:1.1996142719em}.katex .fontsize-ensurer.reset-size11.size1,.katex .sizing.reset-size11.size1{font-size:.2009646302em}.katex .fontsize-ensurer.reset-size11.size2,.katex .sizing.reset-size11.size2{font-size:.2411575563em}.katex .fontsize-ensurer.reset-size11.size3,.katex .sizing.reset-size11.size3{font-size:.2813504823em}.katex .fontsize-ensurer.reset-size11.size4,.katex .sizing.reset-size11.size4{font-size:.3215434084em}.katex .fontsize-ensurer.reset-size11.size5,.katex .sizing.reset-size11.size5{font-size:.3617363344em}.katex .fontsize-ensurer.reset-size11.size6,.katex .sizing.reset-size11.size6{font-size:.4019292605em}.katex .fontsize-ensurer.reset-size11.size7,.katex .sizing.reset-size11.size7{font-size:.4823151125em}.katex .fontsize-ensurer.reset-size11.size8,.katex .sizing.reset-size11.size8{font-size:.578778135em}.katex .fontsize-ensurer.reset-size11.size9,.katex .sizing.reset-size11.size9{font-size:.6945337621em}.katex .fontsize-ensurer.reset-size11.size10,.katex .sizing.reset-size11.size10{font-size:.8336012862em}.katex .fontsize-ensurer.reset-size11.size11,.katex .sizing.reset-size11.size11{font-size:1em}.katex .delimsizing.size1{font-family:KaTeX_Size1}.katex .delimsizing.size2{font-family:KaTeX_Size2}.katex .delimsizing.size3{font-family:KaTeX_Size3}.katex .delimsizing.size4{font-family:KaTeX_Size4}.katex .delimsizing.mult .delim-size1>span{font-family:KaTeX_Size1}.katex .delimsizing.mult .delim-size4>span{font-family:KaTeX_Size4}.katex .nulldelimiter{display:inline-block;width:.12em}.katex .delimcenter,.katex .op-symbol{position:relative}.katex .op-symbol.small-op{font-family:KaTeX_Size1}.katex .op-symbol.large-op{font-family:KaTeX_Size2}.katex .accent>.vlist-t,.katex .op-limits>.vlist-t{text-align:center}.katex .accent .accent-body{position:relative}.katex .accent .accent-body:not(.accent-full){width:0}.katex .overlay{display:block}.katex .mtable .vertical-separator{display:inline-block;min-width:1px}.katex .mtable .arraycolsep{display:inline-block}.katex .mtable .col-align-c>.vlist-t{text-align:center}.katex .mtable .col-align-l>.vlist-t{text-align:left}.katex .mtable .col-align-r>.vlist-t{text-align:right}.katex .svg-align{text-align:left}.katex svg{fill:currentColor;stroke:currentColor;display:block;height:inherit;position:absolute;width:100%}.katex svg path{stroke:none}.katex svg{fill-rule:nonzero;fill-opacity:1;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1}.katex img{border-style:none;max-height:none;max-width:none;min-height:0;min-width:0}.katex .stretchy{display:block;overflow:hidden;position:relative;width:100%}.katex .stretchy:after,.katex .stretchy:before{content:""}.katex .hide-tail{overflow:hidden;position:relative;width:100%}.katex .halfarrow-left{left:0;overflow:hidden;position:absolute;width:50.2%}.katex .halfarrow-right{overflow:hidden;position:absolute;right:0;width:50.2%}.katex .brace-left{left:0;overflow:hidden;position:absolute;width:25.1%}.katex .brace-center{left:25%;overflow:hidden;position:absolute;width:50%}.katex .brace-right{overflow:hidden;position:absolute;right:0;width:25.1%}.katex .x-arrow-pad{padding:0 .5em}.katex .cd-arrow-pad{padding:0 .55556em 0 .27778em}.katex .mover,.katex .munder,.katex .x-arrow{text-align:center}.katex .boxpad{padding:0 .3em}.katex .fbox,.katex .fcolorbox{border:.04em solid;box-sizing:border-box}.katex .cancel-pad{padding:0 .2em}.katex .cancel-lap{margin-left:-.2em;margin-right:-.2em}.katex .sout{border-bottom-style:solid;border-bottom-width:.08em}.katex .angl{border-right:.049em solid;border-top:.049em solid;box-sizing:border-box;margin-right:.03889em}.katex .anglpad{padding:0 .03889em}.katex .eqn-num:before{content:"(" counter(katexEqnNo) ")";counter-increment:katexEqnNo}.katex .mml-eqn-num:before{content:"(" counter(mmlEqnNo) ")";counter-increment:mmlEqnNo}.katex .mtr-glue{width:50%}.katex .cd-vert-arrow{display:inline-block;position:relative}.katex .cd-label-left{display:inline-block;position:absolute;right:calc(50% + .3em);text-align:left}.katex .cd-label-right{display:inline-block;left:calc(50% + .3em);position:absolute;text-align:right}.katex-display{display:block;margin:1em 0;text-align:center}.katex-display>.katex{display:block;text-align:center;white-space:nowrap}.katex-display>.katex>.katex-html{display:block;position:relative}.katex-display>.katex>.katex-html>.tag{position:absolute;right:0}.katex-display.leqno>.katex>.katex-html>.tag{left:0;right:auto}.katex-display.fleqn>.katex{padding-left:2em;text-align:left}body{counter-reset:katexEqnNo mmlEqnNo}
/* generated by tools/gen-icons.js; never edit. Mask images, one per icon of tools/icons.json: the
   shape comes from here, the colour from the background-color of the element that masks with it. */
:root {
  --icon-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 256 256'%3E%3Cpath d='M216.49,104.49l-80,80a12,12,0,0,1-17,0l-80-80a12,12,0,0,1,17-17L128,159l71.51-71.52a12,12,0,0,1,17,17Z' fill='black'/%3E%3C/svg%3E");
  --icon-close: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 256 256'%3E%3Cpath d='M208.49,191.51a12,12,0,0,1-17,17L128,145,64.49,208.49a12,12,0,0,1-17-17L111,128,47.51,64.49a12,12,0,0,1,17-17L128,111l63.51-63.52a12,12,0,0,1,17,17L145,128Z' fill='black'/%3E%3C/svg%3E");
  --icon-cross: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 256 256'%3E%3Cpath d='M208.49,191.51a12,12,0,0,1-17,17L128,145,64.49,208.49a12,12,0,0,1-17-17L111,128,47.51,64.49a12,12,0,0,1,17-17L128,111l63.51-63.52a12,12,0,0,1,17,17L145,128Z' fill='black'/%3E%3C/svg%3E");
  --icon-down: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 256 256'%3E%3Cpath d='M208.49,152.49l-72,72a12,12,0,0,1-17,0l-72-72a12,12,0,0,1,17-17L116,187V40a12,12,0,0,1,24,0V187l51.51-51.52a12,12,0,0,1,17,17Z' fill='black'/%3E%3C/svg%3E");
  --icon-flame: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 256 256'%3E%3Cpath d='M173.79,51.48a221.25,221.25,0,0,0-41.67-34.34,8,8,0,0,0-8.24,0A221.25,221.25,0,0,0,82.21,51.48C54.59,80.48,40,112.47,40,144a88,88,0,0,0,176,0C216,112.47,201.41,80.48,173.79,51.48ZM96,184c0-27.67,22.53-47.28,32-54.3,9.48,7,32,26.63,32,54.3a32,32,0,0,1-64,0Z' fill='black'/%3E%3C/svg%3E");
  --icon-gem: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 256 256'%3E%3Cpath d='M238.16,113.89,142.1,17.83a20,20,0,0,0-28.21,0l-96,96.06a20,20,0,0,0,0,28.22l96.05,96.06h0a20,20,0,0,0,28.21,0l96-96.06a20,20,0,0,0,0-28.22ZM128,218.33,37.68,128,128,37.67,218.32,128Z' fill='black'/%3E%3C/svg%3E");
  --icon-grip: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 256 256'%3E%3Cpath d='M108,60A16,16,0,1,1,92,44,16,16,0,0,1,108,60Zm56,16a16,16,0,1,0-16-16A16,16,0,0,0,164,76ZM92,112a16,16,0,1,0,16,16A16,16,0,0,0,92,112Zm72,0a16,16,0,1,0,16,16A16,16,0,0,0,164,112ZM92,180a16,16,0,1,0,16,16A16,16,0,0,0,92,180Zm72,0a16,16,0,1,0,16,16A16,16,0,0,0,164,180Z' fill='black'/%3E%3C/svg%3E");
  --icon-heart: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 256 256'%3E%3Cpath d='M240,102c0,70-103.79,126.66-108.21,129a8,8,0,0,1-7.58,0C119.79,228.66,16,172,16,102A62.07,62.07,0,0,1,78,40c20.65,0,38.73,8.88,50,23.89C139.27,48.88,157.35,40,178,40A62.07,62.07,0,0,1,240,102Z' fill='black'/%3E%3C/svg%3E");
  --icon-heart-o: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 256 256'%3E%3Cpath d='M178,36c-20.09,0-37.92,7.93-50,21.56C115.92,43.93,98.09,36,78,36a66.08,66.08,0,0,0-66,66c0,72.34,105.81,130.14,110.31,132.57a12,12,0,0,0,11.38,0C138.19,232.14,244,174.34,244,102A66.08,66.08,0,0,0,178,36Zm-5.49,142.36A328.69,328.69,0,0,1,128,210.16a328.69,328.69,0,0,1-44.51-31.8C61.82,159.77,36,131.42,36,102A42,42,0,0,1,78,60c17.8,0,32.7,9.4,38.89,24.54a12,12,0,0,0,22.22,0C145.3,69.4,160.2,60,178,60a42,42,0,0,1,42,42C220,131.42,194.18,159.77,172.51,178.36Z' fill='black'/%3E%3C/svg%3E");
  --icon-lock: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 256 256'%3E%3Cpath d='M208,76H180V56A52,52,0,0,0,76,56V76H48A20,20,0,0,0,28,96V208a20,20,0,0,0,20,20H208a20,20,0,0,0,20-20V96A20,20,0,0,0,208,76ZM100,56a28,28,0,0,1,56,0V76H100ZM204,204H52V100H204Zm-60-52a16,16,0,1,1-16-16A16,16,0,0,1,144,152Z' fill='black'/%3E%3C/svg%3E");
  --icon-menu: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 256 256'%3E%3Cpath d='M228,128a12,12,0,0,1-12,12H40a12,12,0,0,1,0-24H216A12,12,0,0,1,228,128ZM40,76H216a12,12,0,0,0,0-24H40a12,12,0,0,0,0,24ZM216,180H40a12,12,0,0,0,0,24H216a12,12,0,0,0,0-24Z' fill='black'/%3E%3C/svg%3E");
  --icon-mute: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 256 256'%3E%3Cpath d='M56.88,31.93A12,12,0,1,0,39.12,48.07L64.51,76H32A20,20,0,0,0,12,96v64a20,20,0,0,0,20,20H75.88l68.75,53.47A12,12,0,0,0,164,224V185.44l35.12,38.63a12,12,0,0,0,17.76-16.14ZM36,100H68v56H36Zm104,99.46L92,162.13V106.24L140,159Zm-31-134a12,12,0,0,1,2.11-16.84l33.51-26.07A12,12,0,0,1,164,32V94.94a12,12,0,0,1-24,0V56.54l-14.15,11A12,12,0,0,1,109,65.44Zm74,49.35a12,12,0,0,1,18-15.85,44,44,0,0,1,5.55,50.21,12,12,0,0,1-21-11.55A19.67,19.67,0,0,0,188,128,20,20,0,0,0,183,114.79ZM252,128a84.18,84.18,0,0,1-19.11,53.35,12,12,0,1,1-18.53-15.25A60,60,0,0,0,212.73,88a12,12,0,1,1,17.88-16A83.87,83.87,0,0,1,252,128Z' fill='black'/%3E%3C/svg%3E");
  --icon-next: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 256 256'%3E%3Cpath d='M184.49,136.49l-80,80a12,12,0,0,1-17-17L159,128,87.51,56.49a12,12,0,1,1,17-17l80,80A12,12,0,0,1,184.49,136.49Z' fill='black'/%3E%3C/svg%3E");
  --icon-reset: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 256 256'%3E%3Cpath d='M228,128a100,100,0,0,1-98.66,100H128a99.39,99.39,0,0,1-68.62-27.29,12,12,0,0,1,16.48-17.45,76,76,0,1,0-1.57-109c-.13.13-.25.25-.39.37L54.89,92H72a12,12,0,0,1,0,24H24a12,12,0,0,1-12-12V56a12,12,0,0,1,24,0V76.72L57.48,57.06A100,100,0,0,1,228,128Z' fill='black'/%3E%3C/svg%3E");
  --icon-sound: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 256 256'%3E%3Cpath d='M157.27,21.22a12,12,0,0,0-12.64,1.31L75.88,76H32A20,20,0,0,0,12,96v64a20,20,0,0,0,20,20H75.88l68.75,53.47A12,12,0,0,0,164,224V32A12,12,0,0,0,157.27,21.22ZM36,100H68v56H36Zm104,99.46L92,162.13V93.87l48-37.33ZM212,128a44,44,0,0,1-11,29.11,12,12,0,1,1-18-15.88,20,20,0,0,0,0-26.43,12,12,0,0,1,18-15.86A43.94,43.94,0,0,1,212,128Zm40,0a83.87,83.87,0,0,1-21.39,56,12,12,0,0,1-17.89-16,60,60,0,0,0,0-80,12,12,0,1,1,17.88-16A83.87,83.87,0,0,1,252,128Z' fill='black'/%3E%3C/svg%3E");
  --icon-star: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 256 256'%3E%3Cpath d='M234.29,114.85l-45,38.83L203,211.75a16.4,16.4,0,0,1-24.5,17.82L128,198.49,77.47,229.57A16.4,16.4,0,0,1,53,211.75l13.76-58.07-45-38.83A16.46,16.46,0,0,1,31.08,86l59-4.76,22.76-55.08a16.36,16.36,0,0,1,30.27,0l22.75,55.08,59,4.76a16.46,16.46,0,0,1,9.37,28.86Z' fill='black'/%3E%3C/svg%3E");
  --icon-tick: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 256 256'%3E%3Cpath d='M232.49,80.49l-128,128a12,12,0,0,1-17,0l-56-56a12,12,0,1,1,17-17L96,183,215.51,63.51a12,12,0,0,1,17,17Z' fill='black'/%3E%3C/svg%3E");
  --icon-up: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 256 256'%3E%3Cpath d='M208.49,120.49a12,12,0,0,1-17,0L140,69V216a12,12,0,0,1-24,0V69L64.49,120.49a12,12,0,0,1-17-17l72-72a12,12,0,0,1,17,0l72,72A12,12,0,0,1,208.49,120.49Z' fill='black'/%3E%3C/svg%3E");
}
/* ===========================================================================
   Basic Mathematics — design tokens
   The one stylesheet that defines a colour. Every other stylesheet draws from the
   custom properties here (tools/check-static.js `colours` fails a hex, rgb() or
   hsl() literal anywhere else), and the shell links this file first of the site's
   own, on every page (tools/lib/shell.js PAGE_KINDS).

   Two surfaces, set apart on purpose:
     the FRAME   the page around the reading: the top bar, the gutters, the region
                 banner's band, toasts. Dark in both themes; the light/dark theme
                 (html[data-theme], src/boot.js) switches its shades.
     the PANEL   the reading column: prose, worked examples, figures, exercise cards,
                 3D scenes, the course map. Light paper for everyone by default, dark
                 only when the reader chooses it (bm.prefs.v1 panel: "dark", stamped as
                 html[data-panel] by the boot script before first paint).
   So the paper tokens (--bg, --surface, --text, --accent, --part, --plot-* …) follow
   html[data-panel], and the frame tokens (--frame-*, --hud-*, --region-*, --part-frame)
   follow html[data-theme]. The two blocks never set the same name.

   tools/lib/css.js tokens() reads the blocks by their selector shapes: `:root`,
   `:root[data-theme="dark"]`, `:root[data-panel="dark"]`, `[data-part="id"]` and either
   condition before a `[data-part]`, plus @supports blocks, which apply in the browsers
   the site is for. Print, contrast and transparency media blocks restate tokens on
   purpose and are not measured. tools/contrast-pairs.json is measured against every
   theme × panel × Part. WebGL and the 3D scenes read some of these through
   getComputedStyle: those stay plain six-digit hex, as their comments say.
   =========================================================================== */

/* ---------------------------------------------------- the paper: light ---- */

:root {
  --bg: #f6f1e7;
  --surface: #fffdf8;
  --surface-2: #ede6d8;
  --grid-line: #ece5d6;
  --text: #171923;
  --muted: #555a6b;
  --border: #e0d9c9;
  --border-strong: #c2b9a6;
  --tile-border: #c2b9a6;
  --tile-edge: #b0a68f;
  --line-ui: #73788a;
  --accent: #2646d4;
  --accent-deep: #17309f;
  --accent-soft: #e4e9ff;
  --focus: #2646d4;
  --accent-2: #a04608;
  --accent-2-soft: #fdeedd;
  --ok: #14713a;
  --ok-deep: #0d5329;
  --ok-soft: #dcf3e2;
  --bad: #b42318;
  --bad-deep: #861810;
  --bad-soft: #fde7e4;
  --hint-ink: #8a3c06;
  --hint-soft: #fdf3e3;
  --flame: #d4530a;
  --xp: #f6b40e;
  --xp-ink: #855600;
  --on-xp: #171923;
  --heart: #c81e4a;
  --on-accent: #ffffff;
  --on-part: #ffffff;
  /* form controls and scrollbars inside the panel (site.css .wrap) */
  --panel-scheme: light;

  /* elevation means "you can act on this": tiles get a hard edge (--shadow-tile, on
     every element below), panels get none */
  --shadow-float: 0 10px 30px -10px rgba(20, 22, 31, .35);
  --shadow-1: 0 1px 2px rgba(23, 24, 28, .05), 0 2px 6px rgba(23, 24, 28, .04);
  --shadow: 0 1px 2px rgba(23, 24, 28, .05), 0 8px 24px -6px rgba(23, 24, 28, .08);
  --shadow-2: var(--shadow-float);

  /* Mochi's porthole (companion.ts, game.css): brass rim, glass glare, water tint and vignette */
  --porthole-rim-light: #d9b063; --porthole-rim: #b8863b; --porthole-rim-deep: #6e4a1a; --porthole-edge: #2a1d0d;
  --porthole-glare: rgba(255, 255, 255, .30); --water-tint: rgba(28, 140, 172, .16); --water-vignette: rgba(0, 32, 52, .45);

  /* figures and 3D scenes; WebGL reads these, so keep them plain six-digit hex */
  --plot-bg: #fffdf8;
  --plot-grid: #e7e0d0;
  --plot-axis: #777c8c;
  --plot-curve: #2646d4;
  --plot-curve-2: #a04608;
  --plot-curve-3: #1f9456;
  --plot-curve-4: #a3247a;
  --plot-fill: rgba(38, 70, 212, .14);
  --plot-point: #171923;
  --plot-ink: #171923;
  --plot-face-a: #c9d3fb;
  --plot-face-b: #f6d3ae;
  --plot-face-c: #d3efdc;
  --plot-ground: #f1ebdd;
  --plot-hot: #f6b40e;
}

/* A tile's hard edge is the colour its own rule names in --edge (a button's is
   --accent-deep, a solved card's --ok-deep). A var() inside a custom property is read
   where the property is declared, so declared on :root alone this would be the
   default edge on every tile; declared on every element, it reads that element's. */
*, ::before, ::after {
  --shadow-tile: 0 4px 0 var(--edge, var(--tile-edge));
  --shadow-tile-sm: 0 2px 0 var(--edge, var(--tile-edge));
}

/* ----------------------------------------------- the frame: light theme ---- */
/* Dark in both themes; the light theme's is a dusk indigo, the dark theme's (below)
   near black, so the theme button visibly changes the page around the reading. */

:root {
  --frame-bg: #1a1f33;
  --frame-raised: #272d47;
  --frame-line: #7883a9;
  --frame-text: #f4f1e9;
  --frame-muted: #b3b9cd;
  /* the frame's own accent, where a Part's colour is not the one to use (the Arena) */
  --frame-accent: #93a9ff;
  /* the solid backdrop behind a dialog or sheet; text on it is frame text */
  --scrim: #0d0f18;
  /* what a tile's hard edge is mixed down with (color-mix(.., var(--ink-shadow))): the
     edge is its own colour, darker */
  --ink-shadow: #000000;

  /* the scoreboard rail is the frame */
  --hud-bg: var(--frame-bg);
  --hud-text: var(--frame-text);
  --hud-muted: var(--frame-muted);
  --hud-line: #3a415e;
  --hud-chip: var(--frame-raised);
  --hud-track: #3d4566;
  --hud-xp: #ffc83d;
  --hud-flame: #ff9447;
  --hud-heart: #ff6b81;
  --hud-ok: #6fdc98;
  --hud-focus: var(--focus-frame);
  /* the Arena clock's static stripe at critical, see-through over its chip; the clock's
     digits sit on it, so it is measured laid over --hud-chip */
  --hud-stripe: color-mix(in srgb, var(--hud-heart) 16%, transparent);

  /* Translucency, always over a solid fallback: --glass is --glass-solid unless the
     browser can mix colours (the @supports block below) and the reader has not asked
     for less transparency (the media block at the end). An element painted with
     --glass declares a solid background-color of --glass-solid as well. */
  --glass-solid: var(--frame-bg);
  --glass: var(--glass-solid);
  /* the scrim behind the settings sheet when it is modal (a narrow screen): the page
     shows through it dimmed, or it is solid --scrim on the same terms as --glass. No
     text sits on it. */
  --scrim-glass: var(--scrim);

  /* the page's own scrollbar and canvas are the frame's: dark in both themes */
  color-scheme: dark;
}
@supports (color: color-mix(in srgb, red 50%, blue)) {
  :root { --glass: color-mix(in srgb, var(--frame-bg) 88%, transparent); --scrim-glass: color-mix(in srgb, var(--scrim) 72%, transparent); }
}

/* ------------------------------------------------ the frame: dark theme ---- */
/* src/boot.js always stamps data-theme (the saved choice, else the OS setting) before
   first paint, so the dark frame needs only this one block */

:root[data-theme="dark"] {
  --frame-bg: #0a0c13;
  --frame-raised: #161a28;
  --frame-line: #6d789e;
  --frame-text: #f4f1e9;
  --frame-muted: #aab0c4;
  --frame-accent: #93a9ff;
  --scrim: #05060a;
  --hud-line: #2c3249;
  --hud-track: #313853;
}

/* ------------------------------------------------- the paper: dark panel ---- */
/* Only when the reader asks for it: html[data-panel="dark"] (bm.prefs.v1 panel). */

:root[data-panel="dark"] {
  --bg: #12151d;
  --surface: #1b1f2c;
  --surface-2: #262b3b;
  --grid-line: #171b25;
  --text: #ece9e1;
  --muted: #a8adbf;
  --border: #2d3346;
  --border-strong: #454d66;
  --tile-border: #454d66;
  --tile-edge: #07090e;
  --line-ui: #7f879f;
  --accent: #93a9ff;
  --accent-deep: #5d77e0;
  --accent-soft: #1e2749;
  --focus: #93a9ff;
  --accent-2: #f2a65c;
  --accent-2-soft: #3a2917;
  --ok: #6fdc98;
  --ok-deep: #3fa468;
  --ok-soft: #15311f;
  --bad: #ff938c;
  --bad-deep: #d9605a;
  --bad-soft: #3b1c1d;
  --hint-ink: #f2a65c;
  --hint-soft: #2e2616;
  --flame: #ff9447;
  --xp: #ffc83d;
  --xp-ink: #ffc83d;
  --on-xp: #1a1405;
  --heart: #ff6b81;
  --on-accent: #0c1126;
  --on-part: #10131c;
  --panel-scheme: dark;
  --shadow-float: 0 10px 30px -10px rgba(0, 0, 0, .6);
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 28px -8px rgba(0, 0, 0, .5);
  --porthole-rim-light: #c49a52; --porthole-rim: #8f6a2e; --porthole-rim-deep: #4a3212; --porthole-edge: #0d0a05;
  --porthole-glare: rgba(255, 255, 255, .18); --water-tint: rgba(12, 90, 120, .28); --water-vignette: rgba(0, 16, 30, .6);
  --plot-bg: #1b1f2c;
  --plot-grid: #2b3144;
  --plot-axis: #7b839b;
  --plot-curve: #6f88ee;
  --plot-curve-2: #d07f2a;
  --plot-curve-3: #2bab70;
  --plot-curve-4: #d85fb0;
  --plot-fill: rgba(111, 136, 238, .20);
  --plot-point: #ece9e1;
  --plot-ink: #ece9e1;
  --plot-face-a: #28336a;
  --plot-face-b: #4f3312;
  --plot-face-c: #1c4630;
  --plot-ground: #171b26;
  --plot-hot: #ffc83d;
}

/* State marks for answer blanks. An <input> takes no pseudo-elements, so its tick or
   cross is a background picture, and a background picture cannot read a custom property:
   these carry the --ok and --bad values of each panel (the `colours` check holds them
   to those tokens). */
:root {
  --mark-ok: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M4 10.5l4 4 8-9' fill='none' stroke='%2314713a' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  --mark-bad: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M5 5l10 10M15 5L5 15' fill='none' stroke='%23b42318' stroke-width='3' stroke-linecap='round'/%3E%3C/svg%3E");
}
:root[data-panel="dark"] {
  --mark-ok: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M4 10.5l4 4 8-9' fill='none' stroke='%236fdc98' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  --mark-bad: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M5 5l10 10M15 5L5 15' fill='none' stroke='%23ff938c' stroke-width='3' stroke-linecap='round'/%3E%3C/svg%3E");
}

/* The icons drawn as masks (--icon-*) are src/styles/icons.css, generated by tools/gen-icons.js and
   linked ahead of this file by the shell (tools/lib/shell.js PAGE_KINDS); a CSS @import would make the built tokens.css differ from this one. */

/* ------------------------------------------- type, shape, motion, focus ---- */

:root {
  --sans: "Inter", ui-sans-serif, "Segoe UI", system-ui, Roboto, Helvetica, Arial, sans-serif;
  --serif: "Newsreader", "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --display: "Bricolage Grotesque", "Inter", ui-sans-serif, "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, "Liberation Mono", monospace;
  --measure: 66ch;
  --hud-h: 3.5rem;
  --radius: 16px;
  --radius-sm: 11px;
  --radius-xs: 7px;
  --radius-pill: 999px;

  /* Motion: how long, by what the motion is for. Nothing on the site runs longer than
     --dur-max, and nothing loops (check-static.js `animations`). */
  --dur-press: 80ms;     /* a button or tile sinking under a press */
  --dur-state: 160ms;    /* a colour or state change */
  --dur-reveal: 240ms;   /* something opening */
  --dur-bar: 400ms;      /* a bar filling or draining */
  --dur-move: 700ms;     /* something travelling across the screen */
  --dur-max: 900ms;      /* the ceiling */
  --ease-out: cubic-bezier(.2, .7, .2, 1);
  --ease-in: cubic-bezier(.5, 0, .9, .4);
  --ease-inout: cubic-bezier(.65, 0, .35, 1);
  --ease-spring: cubic-bezier(.34, 1.56, .64, 1);
  /* the names the stylesheets used first, kept */
  --ease: var(--ease-out);
  --t-1: var(--dur-press);
  --t-2: var(--dur-state);
  --t-3: var(--dur-reveal);
  --t-4: var(--dur-bar);
  --t-5: var(--dur-move);

  /* Magnitude: how far feedback scales, by the size of the event. An answer is small,
     a section's ward or a purchase medium, a boss down or a gate opening large. */
  --mag-s: 1.02;
  --mag-m: 1.06;
  --mag-l: 1.12;

  /* Focus: one recipe, `outline: var(--focus-width) solid var(--focus);
     outline-offset: var(--focus-offset)` (site.css :focus-visible). --focus is the
     ring on paper; the frame's surfaces (the top bar, its sheet) set --focus to
     --focus-frame, the ring that stands off the dark frame. Both are measured against
     every surface they can sit on (tools/contrast-pairs.json). */
  --focus-width: 3px;
  --focus-offset: 2px;
  --focus-frame: #ffd24a;
}

/* ------------------------------------------------------ the four Parts ---- */
/* Each Part carries its own hue, so the four read as four places. --part is set
   on <body data-part> (by site.js) and on each Part's section of the contents page.
   --part, --part-soft and --part-deep are paper (they follow the panel);
   --part-frame is the same hue lifted to stand on the dark frame. */

:root, [data-part="algebra"] { --part: #a04608; --part-soft: #fdeedd; --part-deep: #7d3806; --part-frame: #f2a65c; }
[data-part="geometry"] { --part: #0c736b; --part-soft: #dcf3ef; --part-deep: #07514b; --part-frame: #5fd6c5; }
[data-part="coordinates"] { --part: #5b3fc4; --part-soft: #ebe6fb; --part-deep: #3f2a91; --part-frame: #b9a6ff; }
[data-part="topics"] { --part: #ad2468; --part-soft: #fbe5ef; --part-deep: #7c1849; --part-frame: #f690bd; }
[data-part="packs"] { --part: #455a70; --part-soft: #e6ecf2; --part-deep: #324458; --part-frame: #b4c4d6; }
:root[data-panel="dark"], :root[data-panel="dark"] [data-part="algebra"] { --part: #f2a65c; --part-soft: #3a2917; --part-deep: #b9762f; }
:root[data-panel="dark"] [data-part="geometry"] { --part: #5fd6c5; --part-soft: #12312d; --part-deep: #2f9c8d; }
:root[data-panel="dark"] [data-part="coordinates"] { --part: #b9a6ff; --part-soft: #282145; --part-deep: #8570dd; }
:root[data-panel="dark"] [data-part="topics"] { --part: #f690bd; --part-soft: #3a1c2a; --part-deep: #c95f8e; }
:root[data-panel="dark"] [data-part="packs"] { --part: #b4c4d6; --part-soft: #1d2833; --part-deep: #7f95ad; }

/* The four regions of the 3D world, per theme: sky, ground, rock, fog, a glow, and
   --region-ink for marks that carry meaning (it stands 3:1 off the sky and the
   ground). WebGL reads these, so keep them plain six-digit hex. */
:root, [data-part="algebra"] {
  --region-sky: #f6e7d2; --region-ground: #e9c9a4; --region-rock: #b98a5e; --region-fog: #f3e2cc; --region-glow: #c2410c; --region-ink: #7d3806;
}
[data-part="geometry"] {
  --region-sky: #dff1ec; --region-ground: #bfe3d6; --region-rock: #6fae9f; --region-fog: #e3f2ee; --region-glow: #0c736b; --region-ink: #07514b;
}
[data-part="coordinates"] {
  --region-sky: #e9e6fa; --region-ground: #cfc6f3; --region-rock: #8f7fd6; --region-fog: #ebe8fa; --region-glow: #5b3fc4; --region-ink: #3f2a91;
}
[data-part="topics"] {
  --region-sky: #f8e4ee; --region-ground: #f0c4d8; --region-rock: #c9749b; --region-fog: #f9e8f0; --region-glow: #ad2468; --region-ink: #7c1849;
}
[data-part="packs"] {
  --region-sky: #e8eef4; --region-ground: #cdd8e4; --region-rock: #8097ae; --region-fog: #ebf0f5; --region-glow: #455a70; --region-ink: #324458;
}
:root[data-theme="dark"], :root[data-theme="dark"] [data-part="algebra"] {
  --region-sky: #1a1210; --region-ground: #4a2f1c; --region-rock: #2e2019; --region-fog: #20160f; --region-glow: #ffa34d; --region-ink: #ffa34d;
}
:root[data-theme="dark"] [data-part="geometry"] {
  --region-sky: #0e1c1b; --region-ground: #173b36; --region-rock: #10272a; --region-fog: #0f2220; --region-glow: #5fe8d2; --region-ink: #5fe8d2;
}
:root[data-theme="dark"] [data-part="coordinates"] {
  --region-sky: #14122a; --region-ground: #2a2456; --region-rock: #1a1738; --region-fog: #17142d; --region-glow: #a48bff; --region-ink: #a48bff;
}
:root[data-theme="dark"] [data-part="topics"] {
  --region-sky: #1d0f18; --region-ground: #45203a; --region-rock: #2a1422; --region-fog: #201019; --region-glow: #ff7ab8; --region-ink: #ff7ab8;
}
:root[data-theme="dark"] [data-part="packs"] {
  --region-sky: #10161d; --region-ground: #263544; --region-rock: #172029; --region-fog: #131b23; --region-glow: #a9bdd2; --region-ink: #a9bdd2;
}

/* Each region's motif, as a mask: paint any box with a colour and mask it with --motif.
   I The Foundry: "=" bars. II The Fields: a triangulation mesh. III The Grid: a dot
   lattice. IV The Observatory: concentric arcs. Motifs belong in banner bands, the
   frame and scene stages, never behind prose. --grid-motif is the course's own, the
   graph paper, for pages that belong to no Part. */
:root {
  --grid-motif: linear-gradient(black 1px, transparent 1px), linear-gradient(90deg, black 1px, transparent 1px);
  --grid-motif-size: 24px 24px;
}
:root, [data-part="algebra"] {
  --motif:
    repeating-linear-gradient(0deg, transparent 0 9px, black 9px 12px, transparent 12px 16px, black 16px 19px, transparent 19px 28px),
    repeating-linear-gradient(90deg, transparent 0 7px, black 7px 21px, transparent 21px 28px);
  --motif-size: auto;
  --motif-comp: intersect;
  --motif-wcomp: source-in;
}
[data-part="geometry"] {
  --motif:
    repeating-linear-gradient(0deg, black 0 1.5px, transparent 1.5px 26px),
    repeating-linear-gradient(60deg, black 0 1.5px, transparent 1.5px 26px),
    repeating-linear-gradient(120deg, black 0 1.5px, transparent 1.5px 26px);
  --motif-size: auto;
  --motif-comp: add;
  --motif-wcomp: source-over;
}
[data-part="coordinates"] {
  --motif: radial-gradient(circle, black 0 1.8px, transparent 2.4px);
  --motif-size: 16px 16px;
  --motif-comp: add;
  --motif-wcomp: source-over;
}
[data-part="topics"] {
  --motif: repeating-radial-gradient(circle at 100% 100%, transparent 0 11px, black 11px 13px);
  --motif-size: auto;
  --motif-comp: add;
  --motif-wcomp: source-over;
}
[data-part="packs"] {
  --motif: repeating-linear-gradient(135deg, black 0 1.5px, transparent 1.5px 14px);
  --motif-size: auto;
  --motif-comp: add;
  --motif-wcomp: source-over;
}

/* ------------------------------------------------------- reader settings -- */

/* less transparency asked for, by the device or by the settings sheet's Reduce
   transparency (html[data-transparency], stamped by the boot script): every translucent
   surface goes solid (site.css turns the top bar's blur off, map3d.css the map's labels) */
@media (prefers-reduced-transparency: reduce) {
  :root { --glass: var(--glass-solid); --scrim-glass: var(--scrim); }
}
:root[data-transparency="reduce"] { --glass: var(--glass-solid); --scrim-glass: var(--scrim); }

/* forced colours keep the alpha of an authored background, so glass would let what
   scrolls under the top bar show through: it goes solid, as for less transparency
   (site.css turns the blur off) */
@media (forced-colors: active) {
  :root { --glass: var(--glass-solid); --scrim-glass: var(--scrim); }
}

/* more contrast asked for: lines carry the text colour and the grey goes */
@media (prefers-contrast: more) {
  :root, :root[data-theme="dark"], :root[data-panel="dark"] {
    --border: var(--line-ui);
    --border-strong: var(--text);
    --muted: var(--text);
    --grid-line: transparent;
    --frame-muted: var(--frame-text);
    --hud-muted: var(--frame-text);
  }
}

/* ----------------------------------------------------------------- print -- */

@media print {
  /* paper is light whatever the screen was showing */
  :root, :root[data-theme="dark"], :root[data-panel="dark"] {
    --bg: #ffffff; --surface: #ffffff; --surface-2: #f3f1ec; --grid-line: #ffffff;
    --text: #171923; --muted: #555a6b; --border: #d6d0c2; --border-strong: #8e8778; --line-ui: #73788a;
    --accent: #2646d4; --accent-soft: #ffffff; --accent-2: #a04608; --accent-2-soft: #ffffff;
    --ok: #14713a; --ok-soft: #ffffff; --bad: #b42318; --bad-soft: #ffffff;
    --hint-ink: #8a3c06; --hint-soft: #ffffff; --on-part: #ffffff;
    --tile-border: #c2b9a6; --tile-edge: #b0a68f; --accent-deep: #17309f; --focus: #2646d4;
    --ok-deep: #0d5329; --bad-deep: #861810; --flame: #d4530a; --xp: #f6b40e; --xp-ink: #855600;
    --on-xp: #171923; --heart: #c81e4a; --on-accent: #ffffff;
    --shadow-float: 0 10px 30px -10px rgba(20, 22, 31, .35); --shadow-1: 0 1px 2px rgba(23, 24, 28, .05), 0 2px 6px rgba(23, 24, 28, .04);
    --shadow: 0 1px 2px rgba(23, 24, 28, .05), 0 8px 24px -6px rgba(23, 24, 28, .08);
    --plot-bg: #ffffff; --plot-grid: #e7e0d0; --plot-axis: #777c8c; --plot-curve: #2646d4;
    --plot-curve-2: #a04608; --plot-curve-3: #1f9456; --plot-curve-4: #a3247a; --plot-fill: rgba(38, 70, 212, .14);
    --plot-point: #171923; --plot-ink: #171923; --plot-face-a: #c9d3fb; --plot-face-b: #f6d3ae;
    --plot-face-c: #d3efdc; --plot-ground: #f1ebdd; --plot-hot: #f6b40e;
    --frame-bg: #ffffff; --frame-text: #171923;
    --porthole-rim-light: #d9b063; --porthole-rim: #b8863b; --porthole-rim-deep: #6e4a1a; --porthole-edge: #2a1d0d;
    --porthole-glare: rgba(255, 255, 255, .30); --water-tint: rgba(28, 140, 172, .16); --water-vignette: rgba(0, 32, 52, .45);
    --panel-scheme: light;
    color-scheme: light;
  }
  /* the light panel's answer marks, which carry the light --ok and --bad */
  :root[data-panel="dark"] {
    --mark-ok: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M4 10.5l4 4 8-9' fill='none' stroke='%2314713a' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    --mark-bad: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M5 5l10 10M15 5L5 15' fill='none' stroke='%23b42318' stroke-width='3' stroke-linecap='round'/%3E%3C/svg%3E");
  }
  :root[data-panel="dark"], :root[data-panel="dark"] [data-part="algebra"], [data-part="algebra"] { --part: #a04608; --part-soft: #ffffff; --part-deep: #7d3806; }
  :root[data-panel="dark"] [data-part="geometry"], [data-part="geometry"] { --part: #0c736b; --part-soft: #ffffff; --part-deep: #07514b; }
  :root[data-panel="dark"] [data-part="coordinates"], [data-part="coordinates"] { --part: #5b3fc4; --part-soft: #ffffff; --part-deep: #3f2a91; }
  :root[data-panel="dark"] [data-part="topics"], [data-part="topics"] { --part: #ad2468; --part-soft: #ffffff; --part-deep: #7c1849; }
  :root[data-panel="dark"] [data-part="packs"], [data-part="packs"] { --part: #455a70; --part-soft: #ffffff; --part-deep: #324458; }
}
/* ===========================================================================
   Basic Mathematics — site styles
   Draws every colour, duration and shape from src/styles/tokens.css, which the shell
   links first of the site's stylesheets, and defines no colour of its own. Two
   surfaces: the dark game frame (the body, the top bar, the region banner's band),
   which the light/dark theme shades, and the reading panel (.wrap, .wrap-narrow),
   light paper unless the reader has chosen a dark one (html[data-panel], stamped by
   src/boot.js before first paint). The figures read the --plot-* and --part
   variables, so they follow the panel without knowing about it.
   =========================================================================== */

/* --------------------------------------------------------------- base ---- */

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: calc(var(--hud-h) + 1rem); }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
/* the settings sheet's Reduce motion and Study mode, stamped by the boot script */
html[data-motion="reduce"], html[data-calm] { scroll-behavior: auto; }

/* The frame: dark in both themes, with a faint motif of the page's Part behind the
   panel (the graph paper on a page of no Part). The motif is a fixed layer, so it
   never drifts or doubles down a long chapter, and it is only ever under the frame:
   the panel paints over it, so it is never behind prose. */
body {
  margin: 0;
  background-color: var(--frame-bg);
  color: var(--frame-text);
  font-family: var(--serif);
  font-size: clamp(1.09rem, 1rem + .5vw, 1.1875rem);
  line-height: 1.62;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background-color: color-mix(in srgb, var(--frame-line) 16%, var(--frame-bg));
  -webkit-mask-image: var(--grid-motif); mask-image: var(--grid-motif);
  -webkit-mask-size: var(--grid-motif-size); mask-size: var(--grid-motif-size);
}
body[data-part]::before {
  background-color: color-mix(in srgb, var(--part-frame) 14%, var(--frame-bg));
  -webkit-mask-image: var(--motif); mask-image: var(--motif);
  -webkit-mask-size: var(--motif-size); mask-size: var(--motif-size);
  -webkit-mask-composite: var(--motif-wcomp); mask-composite: var(--motif-comp);
}

img, svg { max-width: 100%; }

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 3px; text-decoration-color: color-mix(in srgb, var(--accent) 45%, transparent); }
a:hover { text-decoration-color: currentColor; }

h1, h2, h3, h4, .ui { font-family: var(--sans); }
h1, h2, h3, h4 { line-height: 1.2; letter-spacing: -.012em; text-wrap: balance; }
h1 {
  font-family: var(--display); font-weight: 800; letter-spacing: -.02em; line-height: 1.05;
  font-size: clamp(2rem, 1.2rem + 3.4vw, 3.1rem); margin: 0 0 .45em;
}
h2 {
  font-family: var(--display); font-weight: 700; letter-spacing: -.01em;
  font-size: clamp(1.4rem, 1.2rem + 1vw, 1.75rem); margin: 2.6em 0 .6em;
}
/* a section heading carries a short flag in its Part's colour */
main > h2::before, .practice > h2::before, .practice-head > h2::before {
  content: ""; display: block; width: 48px; height: 6px; margin-bottom: .55rem;
  border-radius: 2px; background: var(--part);
}
h3 { font-size: 1.12rem; font-weight: 650; margin: 1.8em 0 .5em; }
h4 { font-weight: 650; }
h2 + h3 { margin-top: 1em; }

p { margin: 0 0 1.05em; }
ul, ol { margin: 0 0 1.1em; padding-left: 1.4em; }
li { margin: .3em 0; }
code, kbd, samp { font-family: var(--mono); font-size: .82em; background: var(--surface-2); padding: .12em .4em; border-radius: 5px; }
kbd { border: 1px solid var(--line-ui); border-bottom-width: 2px; }
hr { border: 0; border-top: 1px solid var(--border); margin: 2.5em 0; }

/* the focus recipe (tokens.css): the ring is --focus on paper and --focus-frame on the
   frame's surfaces, each measured against every surface it can sit on */
:focus-visible { outline: var(--focus-width) solid var(--focus); outline-offset: var(--focus-offset); }
[tabindex="-1"]:focus { outline: none; }
canvas:focus-visible { outline-offset: -3px; }
::selection { background: color-mix(in srgb, var(--accent) 24%, transparent); }

/* a paper tile that appears over the dark top bar: its ring sits on the frame, so it
   is the frame's ring */
.skip-link {
  --focus: var(--focus-frame);
  position: absolute; left: -9999px; top: 0; z-index: 60;
  background: var(--surface); color: var(--text); padding: .6em 1em;
  border: 2px solid var(--line-ui); border-radius: 0 0 var(--radius-sm) 0;
  font-family: var(--sans); font-weight: 600;
}
.skip-link:focus { left: 0; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}
.muted { color: var(--muted); }
.fine { font-family: var(--sans); font-size: .82rem; color: var(--muted); }

/* scope.html (tools/gen-scope.js): one table per course band; stacked cards on a narrow screen */
.scope { width: 100%; border-collapse: collapse; margin: .6rem 0 1.6rem; font-family: var(--sans); font-size: .82rem; line-height: 1.4; }
.scope caption { text-align: left; font-weight: 600; color: var(--muted); padding-bottom: .3rem; }
.scope th, .scope td { border: 1px solid var(--border); padding: .4em .55em; text-align: left; vertical-align: top; }
.scope thead th { background: var(--surface-2); }
.scope tbody tr:nth-child(odd) { background: var(--surface); }
.scope tbody tr:nth-child(even) { background: var(--bg); }
@media (max-width: 900px) {
  .scope thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
  .scope, .scope tbody, .scope tr, .scope td { display: block; }
  .scope tr { border: 1px solid var(--border); border-radius: 6px; margin-bottom: .7rem; }
  .scope td { border: 0; border-bottom: 1px solid var(--border); overflow-wrap: anywhere; }
  .scope td:last-child { border-bottom: 0; }
  .scope td::before { content: attr(data-th); display: block; font-size: .72rem; font-variant: small-caps; letter-spacing: .04em; color: var(--muted); }
}

/* a display-face label: eyebrows, block tags, counters */
.eyebrow, .callout .tag, .rule .tag, .puzzle .tag, .puzzle-answer .tag, .warmup .tag,
.chapter-feedback .tag, .goal strong, .recap > h2, .missions-head, .ex-num {
  font-family: var(--display); font-weight: 700; font-size: .72rem; line-height: 1.3;
  text-transform: uppercase; letter-spacing: .08em;
}

/* ------------------------------------------------------- the HUD rail ---- */
/* The scoreboard rail is the frame, in both themes: glass where the browser can blur
   what scrolls under it, the solid frame colour everywhere else and whenever the reader
   asks for less transparency (--glass, tokens.css). Its counters live in game.css. */

.topbar {
  --focus: var(--focus-frame);
  --hud-edge: color-mix(in srgb, var(--hud-bg) 45%, var(--ink-shadow));
  position: sticky; top: 0; z-index: 40;
  display: flex; flex-wrap: wrap; align-items: center; gap: .35rem 1rem;
  min-height: var(--hud-h); padding: .4rem max(16px, 4vw);
  background-color: var(--glass); color: var(--hud-text);
  border-bottom: 2px solid var(--frame-accent);
  font-family: var(--sans);
}
@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .topbar { -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); }
}
@media (prefers-reduced-transparency: reduce) {
  .topbar { -webkit-backdrop-filter: none; backdrop-filter: none; }
}
/* the settings sheet's Reduce transparency, stamped by the boot script */
html[data-transparency="reduce"] .topbar { -webkit-backdrop-filter: none; backdrop-filter: none; }
body[data-part] .topbar { border-bottom-color: var(--part-frame); }
.topbar .brand {
  flex: none; display: flex; align-items: center; gap: .6rem; min-height: 40px;
  font-family: var(--display); font-weight: 800; font-size: 1.05rem; letter-spacing: -.01em;
  color: var(--hud-text); text-decoration: none; white-space: nowrap;
}
.topbar .brand .glyph {
  display: grid; place-items: center; width: 2.25rem; height: 2.25rem; flex: none;
  border-radius: var(--radius-xs); background: var(--hud-xp); color: var(--on-xp);
  box-shadow: 0 3px 0 color-mix(in srgb, var(--hud-xp) 50%, var(--ink-shadow));
  font-family: var(--serif); font-weight: 600; font-size: 1.35rem; line-height: 1;
}
.topbar nav {
  flex: 1 1 0%; min-width: 0;
  display: flex; align-items: center; gap: .35rem;
}
/* pushed right by a margin, not justify-content, so anything too wide spills off the
   right edge (where the overflow checks see it) instead of over the brand. The margin is
   on an empty first item that is always there, not on the first link: the links are
   hidden on a narrow screen (game.css, the collapse), and then the margin went with
   them and the menu button sat mid-bar. Its negative margin takes back the nav's gap. */
.topbar nav::before { content: ""; flex: none; margin: 0 -.35rem 0 auto; }
.topbar nav > a:where(:not(.hud, .hud-level, .acct)) {
  display: inline-flex; align-items: center; min-height: 40px;
  font-size: .88rem; font-weight: 500; color: var(--hud-muted); text-decoration: none;
  padding: 0 .65rem; border-radius: var(--radius-xs); white-space: nowrap;
}
.topbar nav > a:where(:not(.hud, .hud-level, .acct)):hover { color: var(--hud-text); background: var(--hud-chip); }
/* what the top bar drops as it narrows, and when, is game.css's (the collapse) */
@media (max-width: 720px) {
  .topbar { gap: .35rem .5rem; }
}

/* small buttons: a tile on paper, a chip on the rail */
.icon-btn {
  --edge: var(--line-ui);
  font: inherit; font-family: var(--sans); font-size: .85rem; font-weight: 600; line-height: 1.3;
  min-height: 40px; padding: .45rem .75rem; cursor: pointer;
  background: var(--surface); color: var(--text);
  border: 1.5px solid var(--line-ui); border-radius: var(--radius-xs);
  box-shadow: var(--shadow-tile-sm);
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn:active { transform: translateY(2px); box-shadow: none; }
.topbar .icon-btn {
  --edge: var(--hud-edge);
  min-width: 40px; height: 40px; padding: 0 .55rem;
  background: var(--hud-chip); color: var(--hud-text); border: 1px solid var(--hud-line);
}
.topbar .icon-btn:hover { border-color: var(--hud-muted); }

.acct {
  display: inline-flex; align-items: center; min-height: 40px;
  font-size: .86rem; font-weight: 600; text-decoration: none; white-space: nowrap;
  color: var(--hud-text); padding: 0 .8rem; border-radius: var(--radius-xs);
  border: 1px solid var(--hud-line);
}
.acct:hover { background: var(--hud-chip); }
.acct[data-in] { padding: 0; border: 0; }
.acct[data-learner] { gap: .45rem; padding-right: .6rem; border: 1px solid var(--hud-line); }
.acct-name { max-width: 7rem; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 479px) { .acct-name { display: none; } .acct[data-learner] { padding-right: 0; border: 0; } }
.avatar {
  display: grid; place-items: center; width: 2.25rem; height: 2.25rem; border-radius: 50%;
  background: var(--accent); color: var(--on-accent); font-weight: 700; font-size: .9rem;
}

/* --------------------------------------------------------------- page ---- */

/* The reading panel: a sheet of paper set into the frame, with the frame showing round
   it (a few pixels on a phone, more on a wide screen). Everything a page holds is on
   it, in the paper tokens and the paper's colour scheme; it is light unless the reader
   chose a dark panel. Plain: no motif, no gradient, no glow. */
.wrap, .wrap-narrow {
  --panel-gap: clamp(5px, 3vw - 6px, 40px);
  width: calc(100% - 2 * var(--panel-gap));
  min-height: calc(100vh - var(--hud-h) - 2 * var(--panel-gap));
  margin: var(--panel-gap) auto;
  padding: 0 clamp(12px, 4vw - 8px, 48px);
  background-color: var(--bg); color: var(--text); color-scheme: var(--panel-scheme);
  border: 1px solid var(--frame-line); border-radius: var(--radius);
}
.wrap { max-width: 1180px; }
.wrap-narrow { max-width: 780px; }
@media (max-width: 480px) {
  .wrap, .wrap-narrow { border-radius: var(--radius-sm); }
}

.layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 3rem; }
@media (min-width: 1000px) {
  .layout { grid-template-columns: 15rem minmax(0, 1fr); align-items: start; }
}

/* The measure is 66ch of the prose face. Registered as a length, --col is computed
   once on <main>, so a child set in Inter or the display face gets the same width. */
@property --col { syntax: "<length>"; inherits: true; initial-value: 0px; }
main { --col: var(--measure); min-width: 0; padding-block: 2.5rem 5rem; }
main > * { max-width: var(--measure); max-width: var(--col, var(--measure)); }
main > .full { max-width: none; }
main > [data-step] { scroll-margin-top: calc(var(--hud-h) + 1.5rem); }

/* ------------------------------------------------------------ sidebar ---- */
/* A flat log of the chapter: numbered tokens in the Part's colour, the current line filled. */

.sidebar { font-family: var(--sans); font-size: .87rem; padding-block: 2.5rem 0; }
@media (min-width: 1000px) {
  .sidebar { position: sticky; top: calc(var(--hud-h) + .5rem); max-height: calc(100vh - var(--hud-h) - 1rem); display: flex; flex-direction: column; padding-bottom: 2rem; }
  /* the contents list scrolls inside its card; the companion under it stays in view */
  .sidebar-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
}
.sidebar-body {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.1rem .7rem .4rem;
}
.sidebar h2 {
  font-family: var(--display); font-size: .72rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .08em; color: var(--muted); margin: 0 0 .5rem; padding: 0 .5rem;
}
.sidebar ol { list-style: none; padding: 0; margin: 0 0 1.3rem; }
.sidebar li { margin: 1px 0; }
.sidebar a {
  display: flex; align-items: flex-start; gap: .6rem; padding: .38rem .5rem;
  border-radius: var(--radius-xs); color: var(--muted); text-decoration: none; line-height: 1.4;
  transition: color .15s, background-color .15s;
}
.sidebar a:hover { color: var(--text); background: var(--surface-2); }
.sidebar .counter {
  flex: none; display: grid; place-items: center; width: 20px; height: 20px; margin-top: .05rem;
  border-radius: 5px; background: var(--part-soft); color: var(--part);
  font-family: var(--display); font-size: .72rem; font-weight: 700; line-height: 1;
  font-variant-numeric: tabular-nums;
}
.sidebar a[aria-current="true"], .sidebar a[aria-current="page"] { color: var(--text); background: var(--part-soft); font-weight: 600; }
.sidebar a[aria-current="true"] .counter, .sidebar a[aria-current="page"] .counter { background: var(--part); color: var(--on-part); }
.sidebar-body > p { padding: 0 .5rem; margin: 0 0 .8rem; }

.sidebar-toggle { display: block; width: 100%; text-align: left; margin-bottom: 1rem; }
@media (min-width: 1000px) { .sidebar-toggle { display: none; } }
@media (max-width: 999px) {
  .sidebar { padding-block: 1.2rem 0; }
  .sidebar[data-collapsed="true"] .sidebar-body { display: none; }
  .layout { gap: 0; }
  main { padding-top: 1.2rem; }
}

/* ----------------------------------------------------- chapter heading --- */

.eyebrow { color: var(--part); margin: 0 0 .9rem; }
.lede { font-size: 1.25rem; line-height: 1.5; color: var(--muted); margin-bottom: 1.6em; }

/* The region banner: a piece of the game frame set into the top of the panel. The band
   is the frame's raised surface, the region's name in its Part's frame colour and the
   chapter's title in frame text, with the Part's motif at the right and a stripe of the
   Part's colour under it; the lede, which is reading, sits underneath on the Part's
   paper tint, in body text colour. The motif has a column of its own: no text is on it. */
main > header.region-banner {
  --edge: var(--frame-bg);
  display: grid; grid-template-columns: minmax(0, 1fr) clamp(4.5rem, 20%, 9rem);
  margin: 0 0 1.6rem; overflow: hidden;
  background: var(--part-soft); border: 2px solid var(--frame-raised); border-radius: var(--radius);
  box-shadow: var(--shadow-tile);
}
.region-banner > .eyebrow {
  grid-column: 1 / -1; grid-row: 1; margin: 0; padding: 1.15rem 1.4rem .4rem;
  background: var(--frame-raised); color: var(--part-frame);
}
.region-banner > h1 {
  grid-column: 1 / -1; grid-row: 2; margin: 0; padding: 0 calc(clamp(4.5rem, 20%, 9rem) + .6rem) 1.15rem 1.4rem;
  background: var(--frame-raised); color: var(--frame-text);
}
.region-banner::after {
  content: ""; grid-column: 2; grid-row: 1 / span 2; align-self: stretch;
  background-color: color-mix(in srgb, var(--part-frame) 45%, var(--frame-raised));
  -webkit-mask-image: var(--motif); mask-image: var(--motif);
  -webkit-mask-size: var(--motif-size); mask-size: var(--motif-size);
  -webkit-mask-composite: var(--motif-wcomp); mask-composite: var(--motif-comp);
}
.region-banner > .lede {
  grid-column: 1 / -1; margin: 0; padding: 1.05rem 1.4rem .9rem;
  font-size: 1.2rem; color: var(--text); border-top: 4px solid var(--part-frame);
}
.region-banner > .banner-meta { grid-column: 1 / -1; }
@media (max-width: 480px) {
  main > header.region-banner { grid-template-columns: minmax(0, 1fr); }
  .region-banner::after { display: none; }
  .region-banner > h1 { padding-right: 1.1rem; }
  .region-banner > .eyebrow, .region-banner > h1, .region-banner > .lede { padding-left: 1.1rem; }
  .region-banner > .lede { font-size: 1.1rem; }
}

.goal {
  font-family: var(--sans); font-size: .95rem; line-height: 1.6;
  border: 1px solid color-mix(in srgb, var(--accent) 25%, var(--border)); background: var(--accent-soft);
  padding: 1rem 1.2rem; border-radius: var(--radius); margin: 0 0 2rem;
}
.goal strong { display: block; color: var(--accent); margin-bottom: .35rem; }

/* ------------------------------------------------------------ callouts --- */
/* Reading blocks are flat panels: a 1px border, no shadow, text always on paper or a soft tint. */

.callout {
  position: relative; border: 1px solid var(--border-strong); background: var(--surface);
  border-radius: var(--radius); padding: 1.05rem 1.25rem; margin: 1.7em 0;
}
.callout > :last-child { margin-bottom: 0; }
.callout .tag { display: block; color: var(--muted); margin-bottom: .5rem; }
.callout.idea { border-left: 5px solid var(--accent); border-radius: var(--radius-xs) var(--radius) var(--radius) var(--radius-xs); }
.callout.idea .tag { color: var(--accent); }
.callout.warn {
  border-color: color-mix(in srgb, var(--accent-2) 30%, var(--border)); border-left: 3px solid var(--accent-2);
  background: var(--accent-2-soft); border-radius: var(--radius-xs) var(--radius) var(--radius) var(--radius-xs);
}
.callout.warn .tag { color: var(--accent-2); }
.callout.why { background: var(--surface-2); border-color: var(--border); }
.callout.aside { border: 1.5px dashed var(--border-strong); background: transparent; }

.rule {
  position: relative; border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: var(--surface); padding: 1.05rem 1.25rem 1.05rem 1.6rem; margin: 1.7em 0; overflow: hidden;
}
.rule::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 6px; background: var(--part); }
.rule .tag { display: block; color: var(--part); margin-bottom: .5rem; }
.rule > :last-child { margin-bottom: 0; }
.rule ol, .rule ul { margin-bottom: 0; }

/* ------------------------------------------------------ worked example --- */

.worked {
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: var(--surface); margin: 1.9em 0; overflow: hidden;
}
/* An h3, one level below the section's h2, so a screen reader's list of headings has no
   gap (it was an h4); every property h3 sets on its own is set again here, so the level
   does not show */
.worked > h3 {
  margin: 0; padding: .75rem 1.2rem; font-size: .92rem; font-weight: 650;
  background: var(--surface-2); border-bottom: 1px solid var(--border);
  letter-spacing: 0;
}
.worked > h3 .num { font-family: var(--display); font-weight: 700; color: var(--part); margin-right: .4rem; }
.worked .body { padding: 1.1rem 1.2rem; }
.worked .body > :last-child { margin-bottom: 0; }

.steps { list-style: none; padding: 0; margin: 0; counter-reset: step; }
.steps > li {
  counter-increment: step; position: relative;
  padding: .5rem 0 .5rem 2.4rem; margin: 0;
  border-top: 1px dashed var(--border);
}
.steps > li:first-child { border-top: 0; }
.steps > li::before {
  content: counter(step); position: absolute; left: 0; top: .62rem;
  width: 1.55rem; height: 1.55rem; border-radius: var(--radius-xs);
  background: var(--part-soft); color: var(--part);
  font-family: var(--display); font-size: .78rem; font-weight: 700;
  display: grid; place-items: center; font-variant-numeric: tabular-nums;
}
.steps .note { color: var(--muted); font-size: .95em; }

.display { margin: 1.2em 0; text-align: center; overflow-x: auto; padding: .2em 0; }
.display .katex-display { margin: 0; }

/* ------------------------------------------------------------- tables ---- */

.tbl-wrap { overflow-x: auto; margin: 1.5em 0; }
table { border-collapse: collapse; width: 100%; font-family: var(--sans); font-size: .9rem; }
th, td { text-align: left; padding: .6rem .75rem; border-bottom: 1px solid var(--border); }
thead th { font-family: var(--display); font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); border-bottom-color: var(--border-strong); }
tbody tr:hover { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------ figures ---- */

figure { margin: 1.9em 0; }
figcaption { font-family: var(--sans); font-size: .84rem; color: var(--muted); margin-top: .7rem; }
figcaption b { color: var(--text); font-weight: 650; }

.widget {
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: var(--surface); padding: 1.1rem;
}
.widget svg { display: block; width: 100%; height: auto; touch-action: none; }
.widget .controls {
  display: flex; flex-wrap: wrap; gap: .7rem 1.2rem; align-items: center;
  margin-top: .9rem; padding-top: .9rem; border-top: 1px solid var(--border);
  font-family: var(--sans); font-size: .85rem;
}
.widget .ctrl { display: flex; align-items: center; gap: .5rem; }
.widget .ctrl label { color: var(--muted); white-space: nowrap; }
.widget .ctrl output { font-variant-numeric: tabular-nums; font-weight: 650; min-width: 3.2em; }
.widget input[type="range"] { width: clamp(90px, 22vw, 150px); accent-color: var(--accent); }
.widget .readout {
  font-family: var(--mono); font-size: .8rem; background: var(--surface-2);
  border-radius: var(--radius-sm); padding: .6rem .8rem; margin-top: .8rem; line-height: 1.7;
}
.widget .readout b { font-family: var(--sans); font-size: .88rem; }
.widget .chips, .chips { display: flex; flex-wrap: wrap; gap: .45rem; }
.chip {
  --edge: var(--line-ui);
  font: inherit; font-family: var(--sans); font-size: .82rem; font-weight: 600;
  min-height: 2rem; padding: .25rem .75rem; border-radius: var(--radius-xs); cursor: pointer;
  background: var(--surface); color: var(--text); border: 1.5px solid var(--line-ui);
  box-shadow: var(--shadow-tile-sm);
  transition: background-color .15s, color .15s, border-color .15s;
}
.chip:hover { background: var(--surface-2); }
.chip:active { transform: translateY(2px); box-shadow: none; }
.chip[aria-pressed="true"] {
  background: var(--accent); border-color: var(--accent); color: var(--on-accent);
  transform: translateY(2px); box-shadow: none;
}
.hint-drag { font-family: var(--sans); font-size: .78rem; color: var(--muted); margin-top: .5rem; }

/* ----------------------------------------------------------- practice ---- */

.practice { margin-top: 3.5rem; }
.practice-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: .4rem .9rem; }
.practice-head h2 { margin: 0; }
.practice-score { font-family: var(--sans); font-size: .86rem; color: var(--muted); }
.practice-score b { color: var(--ok); font-family: var(--display); font-weight: 700; font-size: 1rem; font-variant-numeric: tabular-nums; }

/* An exercise is something you act on, so it is a tile. Its states are in game.css. */
.ex {
  --edge: var(--tile-edge);
  position: relative;
  border: 2px solid var(--border-strong); border-radius: var(--radius);
  background: var(--surface); padding: 1.1rem 1.3rem 1.25rem; margin: 1.4rem 0;
  box-shadow: var(--shadow-tile);
  transition: border-color .16s;
}
.ex-num { display: inline-block; vertical-align: middle; color: var(--muted); margin: 0 0 .5rem; }
.ex-q { margin: 0 0 .9rem; }
.ex-q > :last-child { margin-bottom: 0; }
.ex-form { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }

/* control boundaries use --line-ui, the 3:1 line */
.ex-form input[type="text"], input.blank, .field input {
  font: inherit; font-family: var(--mono); font-size: .95rem;
  min-height: 2.6rem; padding: .5rem .75rem; min-width: 0;
  background: var(--bg); color: var(--text);
  border: 2px solid var(--line-ui); border-radius: var(--radius-sm);
  transition: border-color .15s;
}
.ex-form input[type="text"] { width: min(16rem, 100%); }
/* phone: the answer box has a row of its own, the buttons follow under it */
@media (max-width: 640px) {
  .ex-form > input[type="text"] { flex-basis: 100%; width: 100%; }
  .ex-form .ex-show { font-size: .9rem; }
  /* when the row wraps, the solution button ends it at the right, away from where a thumb rests on the box */
  .ex-form .ex-show { margin-left: auto; }
}
.ex-form input[type="text"]:focus, input.blank:focus, .field input:focus { border-color: var(--accent); }
.ex-form input::placeholder, .field input::placeholder { color: var(--muted); }

/* Buttons are tiles on a darker edge, and sink into it when pressed. */
.btn {
  --edge: var(--accent-deep);
  display: inline-block; text-decoration: none; text-align: center;
  font: inherit; font-family: var(--display); font-size: .95rem; font-weight: 700; line-height: 1.25;
  min-height: 2.6rem; padding: .62rem 1.15rem; border-radius: var(--radius-sm); cursor: pointer;
  background: var(--accent); color: var(--on-accent); border: 2px solid var(--accent);
  box-shadow: var(--shadow-tile);
  transition: transform var(--t-1), box-shadow var(--t-1), background-color .15s, border-color .15s, color .15s;
}
.btn:hover { background: color-mix(in srgb, var(--accent) 88%, var(--text)); border-color: color-mix(in srgb, var(--accent) 88%, var(--text)); }
.btn:active { transform: translateY(4px); box-shadow: 0 0 0 var(--edge); }
.btn.ghost {
  --edge: var(--tile-edge);
  background: var(--surface); color: var(--text); border-color: var(--line-ui);
}
.btn.ghost:hover { background: var(--surface-2); border-color: var(--text); }
.btn.big { font-size: 1.05rem; padding: .78rem 1.6rem; }
.btn.small { font-size: .82rem; min-height: 2.1rem; padding: .35rem .75rem; }
.btn.danger { color: var(--bad); border-color: var(--bad); }
.btn[disabled] { opacity: .55; cursor: default; transform: none; }
.link {
  font: inherit; font-family: var(--sans); font-size: .86rem; color: var(--accent);
  background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent); text-underline-offset: 3px;
}
.link:hover { text-decoration-color: currentColor; }

/* multiple choice: tiles to tap; the picked one sinks */
.choices { display: grid; gap: .6rem; margin: 0 0 1rem; }
.choice {
  --edge: var(--line-ui);
  display: flex; gap: .7rem; align-items: flex-start;
  border: 2px solid var(--line-ui); border-radius: var(--radius-sm); padding: .65rem .9rem;
  cursor: pointer; background: var(--surface); box-shadow: var(--shadow-tile-sm);
  transition: border-color .15s, background-color .15s, box-shadow var(--t-1), transform var(--t-1);
}
.choice:hover { background: var(--surface-2); }
.choice:active { transform: translateY(2px); box-shadow: none; }
.choice input { margin: .42rem 0 0; accent-color: var(--accent); flex: none; width: 1rem; height: 1rem; }
.choice:has(input:checked) {
  border-color: var(--accent); background: var(--accent-soft);
  transform: translateY(2px); box-shadow: none;
}
.choice:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
.choice input:focus-visible { outline: none; }

/* put-in-order: lines to drag, or to move with their arrows */
.order { list-style: none; padding: 0; margin: 0 0 1rem; display: grid; gap: .55rem; counter-reset: line; }
.order-item {
  --edge: var(--line-ui);
  counter-increment: line; display: flex; align-items: center; gap: .6rem; margin: 0;
  border: 2px solid var(--line-ui); border-radius: var(--radius-sm); padding: .45rem .5rem .45rem .7rem;
  background: var(--surface); box-shadow: var(--shadow-tile-sm); cursor: grab;
}
.order-item.dragging { opacity: .45; }
.order-grip { color: var(--line-ui); font-family: var(--sans); letter-spacing: -.2em; user-select: none; }
.order-text { flex: 1; min-width: 0; }
.order-text::before { content: counter(line) ". "; font-family: var(--display); font-size: .82rem; font-weight: 700; color: var(--muted); }
.order-move {
  font: inherit; font-family: var(--sans); font-size: 1rem; font-weight: 700; line-height: 1; flex: none;
  width: 2.5rem; height: 2.5rem; border-radius: var(--radius-xs); cursor: pointer;
  background: var(--surface-2); color: var(--text); border: 1.5px solid var(--line-ui);
}
.order-move:hover { background: var(--surface); }
.order-item:first-child .order-move:first-of-type, .order-item:last-child .order-move:last-of-type { opacity: .35; }

/* fill-in blanks set inside a sentence or between pieces of an equation */
input.blank { width: auto; min-height: 0; padding: .2rem .45rem; margin: 0 .15em; text-align: center; vertical-align: baseline; }

/* a figure used as the answer sheet */
.ex > .widget { margin: 0 0 1rem; background: var(--bg); }

.ex-solution {
  display: none; margin-top: 1.1rem; padding-top: 1rem;
  border-top: 1px solid var(--border-strong); font-size: 1.05rem;
}
.ex-solution[data-show="true"] { display: block; }
.ex-solution > :last-child { margin-bottom: 0; }
.ex-solution .answer {
  font-family: var(--display); font-size: .78rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .08em; color: var(--muted);
}

/* ------------------------------------------------------- chapter nav ----- */

.recap {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.4rem 1.5rem; margin-top: 3rem;
}
.recap > h2 { margin: 0 0 .8rem; color: var(--part); }
.recap ul { margin-bottom: 0; }

.chapter-nav {
  display: grid; gap: 1rem; margin-top: 3rem;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  font-family: var(--sans);
}
.chapter-nav a {
  --edge: var(--tile-edge);
  display: block; text-decoration: none; color: var(--text);
  border: 2px solid var(--border-strong); border-radius: var(--radius);
  padding: 1rem 1.15rem; background: var(--surface); box-shadow: var(--shadow-tile);
  transition: border-color .15s, transform var(--t-1), box-shadow var(--t-1);
}
.chapter-nav a:hover { border-color: var(--part); --edge: var(--part-deep); }
.chapter-nav a:active { transform: translateY(4px); box-shadow: none; }
.chapter-nav .dir {
  display: block; font-family: var(--display); font-size: .72rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .08em; color: var(--part); margin-bottom: .25rem;
}
.chapter-nav b { font-weight: 650; }
.chapter-nav .next { text-align: right; }

/* ---------------------------------------------------------- home page ---- */

/* The primary call to action stands above the world, in the first screen. */
.hub-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem 1.5rem; }
.hub-head .hub-lede { flex: 1 1 22rem; margin: 0; font-size: 1.1rem; line-height: 1.45; color: var(--text); max-width: var(--measure); }
.hub-head .btn { flex: 0 0 auto; }
/* the List / Map control: a segmented pair of radios on the chip tokens, with the one-time note beside it */
/* its row is kept from the first paint (the module arrives late) and the note takes no height of its own, so nothing moves when they arrive:
   beside the control on a wide screen, a card fixed to the bottom of the screen on a narrow one */
.hub-mode { flex: 1 1 100%; min-height: 2.8rem; display: flex; align-items: center; gap: .6rem 1rem; }
.hub-mode-group { display: inline-flex; border: 1.5px solid var(--line-ui); border-radius: var(--radius-xs); overflow: hidden; background: var(--surface); }
.hub-mode-opt {
  font: inherit; font-family: var(--sans); font-size: .86rem; font-weight: 600;
  min-height: 2.2rem; min-width: 4.5rem; padding: .3rem 1rem; cursor: pointer;
  background: var(--surface); color: var(--text); border: 0; border-radius: 0;
}
.hub-mode-opt + .hub-mode-opt { border-left: 1.5px solid var(--line-ui); }
.hub-mode-opt:hover:not([aria-checked="true"]):not([aria-disabled="true"]) { background: var(--surface-2); }
.hub-mode-opt[aria-checked="true"] { background: var(--accent); color: var(--on-accent); }
.hub-mode-opt[aria-disabled="true"] { color: var(--muted); cursor: default; }
.hub-mode-opt:focus-visible { outline: var(--focus-width) solid var(--focus); outline-offset: calc(-1 * var(--focus-width)); }
.hub-mode-note {
  flex: 1 1 auto; max-width: var(--measure); margin: 0; display: flex; align-items: center; gap: .8rem;
  font-size: .86rem; line-height: 1.4; color: var(--muted);
}
.hub-mode-note .btn { flex: 0 0 auto; }
/* the search: a row of its own below the control; [hidden] on cards, rows and Parts already wins (the reset at the top) */
.hub-search { flex: 1 1 100%; margin: 0; }
.hub-search input {
  display: block; width: 100%; max-width: var(--measure); box-sizing: border-box; margin: 0; min-height: 2.6rem; padding: .4rem .7rem;
  font: inherit; font-family: var(--sans); font-size: 1rem; background: var(--bg); color: var(--text);
  border: 2px solid var(--line-ui); border-radius: var(--radius-sm); transition: border-color .15s;
}
.hub-search-status { margin: .35rem 0 0; font-size: .85rem; color: var(--muted); }
.hub-search-status:empty { display: none; }
.hub-search input::placeholder { color: var(--muted); }
.hub-search input:focus { border-color: var(--accent); }
.hub-search input:focus-visible { outline: var(--focus-width) solid var(--focus); outline-offset: 2px; }
@media (max-width: 900px) {
  .hub-mode { min-height: calc(2.2rem + 3px); }
  /* out of flow, so the control row keeps its height and the hero below never moves when the
     note mounts late (the map suite pins that at 360); anchored to the bottom of the viewport,
     not under the top bar, so it covers neither the control it explains nor the search */
  .hub-mode-note {
    position: fixed; left: .75rem; right: .75rem; top: auto; bottom: calc(.75rem + env(safe-area-inset-bottom, 0px)); z-index: 30;
    max-width: none; padding: .7rem .9rem; color: var(--text);
    background: var(--surface); border: 1.5px solid var(--line-ui); border-radius: var(--radius-sm); box-shadow: var(--shadow-tile-sm);
  }
}
@media (max-width: 600px) {
  .hub-head { flex-direction: column; align-items: stretch; gap: .8rem; }
  .hub-head .hub-lede { flex: 0 0 auto; font-size: 1rem; }
  .hub-head .btn { text-align: center; }
  .hub-mode { flex-basis: auto; flex-direction: column; align-items: stretch; }
  .hub-mode-group { display: flex; }
  .hub-mode-opt { flex: 1 1 0; }
}

.hero { padding-block: 4rem 2.5rem; max-width: 780px; }
.hero h1 { font-size: clamp(2.5rem, 1.4rem + 4.6vw, 4.2rem); }
.hero .lede { font-size: 1.3rem; color: var(--text); }
.hero > p:not(.lede):not(.eyebrow) { color: var(--muted); }
.hero .eyebrow { color: var(--accent-2); }
.hero .actions, .actions { display: flex; flex-wrap: wrap; gap: .8rem; align-items: center; margin-top: 1.6rem; font-family: var(--sans); }
.actions.quiet { margin-top: .9rem; gap: 1.2rem; }

/* The contents page is a quest log: one region per Part, one tile per chapter. */
.part { margin-top: 4.5rem; }
.part-head {
  display: flex; align-items: center; gap: .9rem; flex-wrap: wrap;
  border-bottom: 2px solid var(--part); padding-bottom: .8rem;
}
.part-head .roman {
  display: grid; place-items: center; min-width: 2.7rem; height: 2.7rem; padding: 0 .45rem;
  border-radius: var(--radius-xs); background: var(--part); color: var(--on-part);
  font-family: var(--display); font-size: 1.2rem; font-weight: 800; line-height: 1;
}
.part-head h2 { margin: 0; font-size: clamp(1.3rem, 1.1rem + 1vw, 1.6rem); flex: 1 1 12rem; }
.part-count {
  margin-left: auto; font-family: var(--sans); font-size: .8rem; font-weight: 600; color: var(--muted);
  white-space: nowrap; padding: .25rem .65rem; border: 1px solid var(--border-strong); border-radius: var(--radius-pill);
  background: var(--surface);
}
.part-blurb { color: var(--muted); margin: 1rem 0 2rem; max-width: var(--measure); }

/* The course as a path: one stop per chapter along a line. On a wide screen the stops
   alternate sides of the line; on a narrow one the line runs down the left. */
.path { list-style: none; margin: 0; padding: 0; position: relative; display: grid; gap: 1.1rem; }
.path::before {
  content: ""; position: absolute; left: 26px; top: 30px; bottom: 30px; width: 4px;
  background: repeating-linear-gradient(to bottom, var(--line-ui) 0 6px, transparent 6px 13px);
  opacity: .55;
}
.stop { margin: 0; }
.stop-link {
  display: grid; grid-template-columns: 56px minmax(0, 1fr); gap: 1rem; align-items: start;
  text-decoration: none; color: var(--text);
}
.stop-node {
  --pct: 0; position: relative; z-index: 1; width: 56px; height: 56px; border-radius: 50%; margin-top: .5rem;
  display: grid; place-items: center;
  background: conic-gradient(var(--part) calc(var(--pct) * 1%), var(--border-strong) 0);
  box-shadow: 0 0 0 6px var(--bg);
}
.stop-node > span {
  width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface); color: var(--muted);
  font-family: var(--display); font-size: 1.1rem; font-weight: 800;
}
.stop[data-state="done"] .stop-node { background: var(--part); }
.stop[data-state="done"] .stop-node > span { background: var(--part); color: var(--on-part); }
.stop[data-state="current"] .stop-node > span, .stop[data-state="started"] .stop-node > span { color: var(--part); }
.stop[data-state="current"] .stop-node { box-shadow: 0 0 0 6px var(--bg), 0 0 0 9px var(--part-soft); }
.stop-card {
  --edge: var(--tile-edge);
  display: flex; flex-direction: column; gap: .45rem;
  border: 2px solid var(--border-strong); border-radius: var(--radius);
  background: var(--surface); padding: 1.1rem 1.3rem; box-shadow: var(--shadow-tile);
  transition: border-color .15s, transform var(--t-1), box-shadow var(--t-1);
}
.stop[data-state="current"] .stop-card { border-color: var(--part); --edge: var(--part-deep); }
.stop-link:hover .stop-card { border-color: var(--part); --edge: var(--part-deep); }
/* the contents page's selected chapter (src/ui/hub-select.ts): a quiet mark that outlasts the focus ring */
.stop[data-selected] .stop-card { border-color: var(--part); box-shadow: inset 4px 0 0 var(--part), var(--shadow-tile-sm); }
.stop-link:active .stop-card { transform: translateY(4px); box-shadow: none; }
.stop-card .row { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem; }
.stop-card .label {
  font-family: var(--display); font-size: .72rem; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--part);
}
.stop-card h3 { font-size: 1.2rem; margin: 0; }
.stop-card p { font-size: 1rem; line-height: 1.5; color: var(--muted); margin: 0; }
/* the hub's line sits after the card's link, in the card's column */
.stop-hub { position: relative; z-index: 2; margin: .45rem 0 0 calc(56px + 1rem); padding: 0 1.3rem; font-family: var(--sans); font-size: .85rem; line-height: 1.5; color: var(--text); display: grid; gap: .15rem; }
.stop-hub .stop-mastery { color: var(--muted); font-size: .78rem; }
.stop-hub a { text-decoration: underline; }
/* the Sections list: a disclosure in the hub line's column, rows of glyph, title and advisory state */
.stop-sections { position: relative; z-index: 2; margin: .45rem 0 0 calc(56px + 1rem); padding: 0 1.3rem; font-family: var(--sans); font-size: .85rem; line-height: 1.5; }
.stop-sections > summary { cursor: pointer; color: var(--muted); font-size: .8rem; }
.stop-sections > summary { list-style: none; }
.stop-sections > summary::-webkit-details-marker { display: none; }
.stop-sections > summary::after {
  content: ""; display: inline-block; width: 1.05em; height: 1.05em; margin-left: .3em; vertical-align: -.2em;
  background: currentColor;
  -webkit-mask: var(--icon-chevron) center / contain no-repeat; mask: var(--icon-chevron) center / contain no-repeat;
  transition: transform .15s;
}
.stop-sections[open] > summary::after { transform: rotate(180deg); }
.stop-rows { list-style: none; margin: .35rem 0 0; padding: 0; display: grid; gap: .3rem; }
.stop-row { display: grid; grid-template-columns: 1.25rem minmax(0, 1fr) minmax(0, max-content); gap: .2rem .6rem; align-items: baseline; }
.stop-glyph { color: var(--muted); display: inline-flex; align-self: start; line-height: 1.5; }
.stop-glyph svg { width: 1em; height: 1em; }
.stop-row[data-state="done"] .stop-glyph { color: var(--part); }
.stop-state { color: var(--muted); font-size: .78rem; text-align: right; overflow-wrap: anywhere; max-width: 14rem; white-space: normal; }
.stop-sections a { text-decoration: underline; color: var(--text); }
.stop-state a { color: var(--muted); }
.stop-sections a:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 2px; }
@media (max-width: 900px) {
  .stop-row { grid-template-columns: 1.25rem minmax(0, 1fr); }
  .stop-state { grid-column: 2; text-align: left; max-width: none; }
}
.stop-card .meta { margin-top: .35rem; font-family: var(--sans); font-size: .78rem; color: var(--muted); display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
@media (min-width: 900px) {
  .path { gap: 0; }
  .path::before { left: 50%; margin-left: -2px; }
  .stop-link { grid-template-columns: minmax(0, 1fr) 56px minmax(0, 1fr); gap: 1.6rem; }
  .stop-node { grid-column: 2; grid-row: 1; }
  .stop-card { grid-row: 1; }
  .stop:nth-child(odd) .stop-card { grid-column: 1; }
  .stop:nth-child(even) .stop-card { grid-column: 3; }
  .stop:nth-child(odd) .stop-hub { margin-left: 0; width: calc((100% - 56px - 3.2rem) / 2); box-sizing: border-box; }
  .stop:nth-child(even) .stop-hub { margin-left: calc((100% - 56px - 3.2rem) / 2 + 56px + 3.2rem); }
  .stop + .stop { margin-top: -3rem; }
}

.badge {
  font-family: var(--display); font-size: .68rem; font-weight: 700; letter-spacing: .07em;
  text-transform: uppercase; padding: .15rem .5rem; border-radius: var(--radius-xs);
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--border);
}
.badge.soon { color: var(--accent-2); border-color: color-mix(in srgb, var(--accent-2) 40%, transparent); background: var(--accent-2-soft); }
.badge.done { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, transparent); background: var(--ok-soft); }
.badge.here { color: var(--part); border-color: color-mix(in srgb, var(--part) 40%, transparent); background: var(--part-soft); }

.ring { --pct: 0; width: 26px; height: 26px; border-radius: 50%; flex: none;
  background: conic-gradient(var(--ok) calc(var(--pct) * 1%), var(--surface-2) 0);
  display: grid; place-items: center; position: relative;
}
.ring::after { content: ""; width: 17px; height: 17px; border-radius: 50%; background: var(--surface); }
.ring[data-pct="100"]::after {
  background: var(--ok); width: 14px; height: 14px; border-radius: 0;
  -webkit-mask: var(--icon-tick) center / contain no-repeat; mask: var(--icon-tick) center / contain no-repeat;
}

footer.site {
  margin-top: 5rem; border-top: 1px solid var(--border); padding-block: 2rem 3rem;
  font-family: var(--sans); font-size: .85rem; color: var(--muted);
}
footer.site p { margin: 0 0 .5em; max-width: 62ch; }

/* --------------------------------------------------------- katex tweak --- */

/* A formula keeps its case inside an uppercase label: thead th made the θ and π of
   chapter 11's table Θ and Π, other symbols, on screen and in the header's name */
.katex { font-size: 1em; text-transform: none; }
.katex-display { overflow-x: auto; overflow-y: hidden; padding: .25em 0; }
/* a formula or table wider than the column is a tab stop while it is (src/ui/scroll-regions.ts
   sets data-scrolls), so the arrow keys scroll it; its ring sits just inside the box, where
   neither the box's own overflow nor a card's overflow: hidden clips it */
[data-scrolls]:focus-visible { outline-offset: -3px; }

/* ----------------------------------------------------- opening puzzle ---- */

/* the puzzle asks for a guess, so it is a tile */
.puzzle {
  --edge: var(--part-deep);
  border: 2px solid var(--part); background: var(--part-soft); box-shadow: var(--shadow-tile);
  border-radius: var(--radius); padding: 1.15rem 1.3rem; margin: 0 0 1.8rem;
}
.puzzle > :last-child { margin-bottom: 0; }
.puzzle .tag, .puzzle-answer .tag, .warmup .tag, .chapter-feedback .tag { display: block; color: var(--part); margin-bottom: .45rem; }
.guess { display: flex; flex-wrap: wrap; gap: .55rem; margin: .2rem 0 .9rem; }
.guess-chip {
  --edge: var(--line-ui);
  font: inherit; font-family: var(--sans); font-size: .9rem; font-weight: 600; cursor: pointer;
  min-height: 2.5rem; padding: .45rem 1rem; border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); border: 2px solid var(--line-ui);
  box-shadow: var(--shadow-tile-sm); transition: transform var(--t-1), box-shadow var(--t-1), border-color .15s;
}
.guess-chip:hover { border-color: var(--part); }
.guess-chip:active { transform: translateY(2px); box-shadow: none; }
.guess-chip[aria-pressed="true"] {
  background: var(--part); border-color: var(--part); color: var(--on-part);
  transform: translateY(2px); box-shadow: none;
}
.puzzle-after { font-family: var(--sans); font-size: .88rem; color: var(--text); }
/* keep the line's space while hidden, so the guess does not move what is below */
.puzzle-after[hidden] { display: block !important; visibility: hidden; }
.puzzle-answer { border-left: 4px solid var(--part); padding-left: .9rem; margin-bottom: 1rem; }
.puzzle-answer [data-your-guess] { font-family: var(--sans); font-size: .86rem; color: var(--muted); margin-bottom: .4rem; }

/* ------------------------------------- inline checks, warm-up, reveals ---- */

.warmup { margin: 0 0 2rem; }
.warmup > p { font-family: var(--sans); font-size: .92rem; color: var(--muted); }
.ex[data-inline] {
  --edge: color-mix(in srgb, var(--part) 45%, var(--tile-edge));
  border-color: color-mix(in srgb, var(--part) 50%, var(--border-strong));
  background: color-mix(in srgb, var(--part-soft) 55%, var(--surface)); margin: 1.7em 0;
}
.ex[data-inline] .ex-num { color: var(--part); }

details.reveal {
  border: 2px dashed var(--line-ui);
  border-radius: var(--radius); padding: .85rem 1.1rem; margin: 1.5em 0;
}
details.reveal[open] { border-style: solid; border-color: var(--border-strong); background: var(--surface); }
details.reveal > summary {
  list-style: none; cursor: pointer; font-family: var(--sans); font-size: .9rem; font-weight: 650; color: var(--accent);
}
details.reveal > summary::-webkit-details-marker { display: none; }
details.reveal > summary::after {
  content: ""; display: inline-block; width: 1.05em; height: 1.05em; margin-left: .3em; vertical-align: -.2em;
  background: currentColor;
  -webkit-mask: var(--icon-chevron) center / contain no-repeat; mask: var(--icon-chevron) center / contain no-repeat;
  transition: transform .15s;
}
details.reveal[open] > summary::after { transform: rotate(180deg); }
details.reveal > summary .ask { display: block; font-weight: 400; color: var(--text); margin-bottom: .3rem; font-family: var(--serif); font-size: clamp(1.09rem, 1rem + .5vw, 1.1875rem); }
details.reveal[open] > summary { margin-bottom: .7rem; }
details.reveal > :last-child { margin-bottom: 0; }
.steps details.reveal { margin: .3em 0; }

/* ------------------------------------------------------ static diagrams -- */

figure.diagram svg {
  display: block; width: 100%; height: auto; max-width: 520px; margin: 0 auto;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
}
.dg-line { stroke: var(--text); stroke-width: 2; fill: none; stroke-linejoin: round; stroke-linecap: round; }
.dg-thin { stroke: var(--plot-axis); stroke-width: 1.5; fill: none; }
.dg-dash { stroke: var(--plot-axis); stroke-width: 1.5; fill: none; stroke-dasharray: 6 5; }
.dg-a { fill: var(--plot-curve); fill-opacity: .4; stroke: var(--plot-curve); stroke-width: 1.5; }
.dg-b { fill: var(--plot-curve-2); fill-opacity: .4; stroke: var(--plot-curve-2); stroke-width: 1.5; }
.dg-c { fill: var(--ok); fill-opacity: .4; stroke: var(--ok); stroke-width: 1.5; }
.dg-soft { fill: var(--plot-fill); stroke: var(--plot-curve); stroke-width: 2; stroke-linejoin: round; }
.dg-soft2 { fill: var(--accent-2-soft); stroke: var(--plot-curve-2); stroke-width: 2; stroke-linejoin: round; }
.dg-text { font: 600 15px var(--sans); fill: var(--text); }
.dg-muted { font: 500 13px var(--sans); fill: var(--muted); }

/* ------------------------------------------------------------ missions --- */

.missions {
  margin-top: .9rem; padding: .8rem 1rem; border-radius: var(--radius-sm);
  background: var(--part-soft); font-family: var(--sans); font-size: .88rem;
}
.missions-head { margin: 0 0 .35rem; color: var(--part); }
.missions ol { list-style: none; margin: 0; padding: 0; }
.missions li { display: flex; gap: .55rem; align-items: baseline; margin: .25rem 0; }
.missions .mark {
  flex: none; width: 1.05rem; height: 1.05rem; border-radius: 50%; position: relative; top: .15rem;
  border: 2px solid var(--part); background: var(--surface);
}
.missions li[data-done] .mark { background: var(--part); }
.missions li[data-done] .mark::after {
  content: ""; position: absolute; inset: 1px; background: var(--on-part);
  -webkit-mask: var(--icon-star) center / contain no-repeat; mask: var(--icon-star) center / contain no-repeat;
}
.missions li[data-done] .what { color: var(--muted); }
.stars { margin-left: auto; color: var(--part); font-weight: 650; }

/* ----------------------------------------------- progress and completion -- */

.side-progress { margin: -.6rem .5rem 1.6rem; }
.side-progress .bar { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; box-shadow: inset 0 0 0 1px var(--border); }
.side-progress .bar span { display: block; height: 100%; width: 0; background: var(--ok); border-radius: 3px; }
.side-progress p { margin: .35rem 0 0; font-size: .76rem; color: var(--muted); }

.chapter-done {
  position: relative; margin-top: 2.5rem; padding: 1.2rem 1.4rem; border-radius: var(--radius);
  background: var(--ok-soft); border: 1px solid var(--ok); border-left-width: 5px;
  font-family: var(--sans); font-size: .98rem;
}
.chapter-done b { color: var(--ok); font-family: var(--display); font-weight: 700; }
.chapter-done .burst { position: absolute; left: 50%; top: 0; width: 0; height: 0; pointer-events: none; }
.chapter-done .burst i {
  position: absolute; width: 9px; height: 9px; border-radius: 2px; opacity: 0;
  background: var(--ok);
}
.chapter-done .burst i:nth-child(n + 13) { display: none; }
.chapter-done .burst i:nth-child(3n) { background: var(--part); border-radius: 50%; }
.chapter-done .burst i:nth-child(3n + 1) { background: var(--accent); }

.chapter-feedback {
  margin-top: 2.5rem; padding: 1.1rem 1.3rem; border-radius: var(--radius);
  border: 1px solid var(--border-strong); background: var(--surface);
  font-family: var(--sans); font-size: .92rem;
}
.chapter-feedback p { margin: 0 0 .4em; }
.chapter-feedback > :last-child { margin-bottom: 0; }

/* -------------------------------------------------------- lesson mode ----- */

.lesson-mode {
  display: inline-flex; padding: 3px; gap: 3px; margin: 0 0 1.8rem; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--border-strong);
}
.lesson-mode button {
  font: inherit; font-family: var(--sans); font-size: .82rem; font-weight: 600; cursor: pointer;
  min-height: 2.25rem; padding: .3rem .95rem; border-radius: var(--radius-xs); border: 1.5px solid transparent;
  background: transparent; color: var(--muted);
}
.lesson-mode button:hover { color: var(--text); }
.lesson-mode button[aria-pressed="true"] { background: var(--surface); color: var(--text); border-color: var(--line-ui); }

/* the step-by-step bar stays in the flow, as a tile under the newest step */
.lesson-next {
  --edge: var(--tile-edge);
  display: flex; flex-wrap: wrap; align-items: center; gap: .6rem 1.2rem;
  margin: 2.4rem 0 30vh; padding: 1rem 1.2rem;
  background: var(--surface); border: 2px solid var(--border-strong); border-radius: var(--radius);
  box-shadow: var(--shadow-tile);
}
.lesson-next[data-ready="true"] { border-color: var(--part); --edge: var(--part-deep); }
.lesson-note { flex-basis: 100%; margin: 0; font-size: .88rem; color: var(--muted); }
.lesson-count { margin-left: auto; font-size: .8rem; color: var(--muted); font-variant-numeric: tabular-nums; }
@media (max-width: 480px) {
  .lesson-next .btn { flex: 1 1 100%; }
  .lesson-count { margin-left: 0; }
}
/* progress through the chapter: a line in the Part's colour along the bottom of the rail */
.lesson-progress { position: absolute; left: 0; right: 0; bottom: -2px; height: 4px; background: transparent; pointer-events: none; }
.lesson-progress span { display: block; height: 100%; width: 0; background: var(--part-frame); }
body:not([data-part]) .lesson-progress span { background: var(--frame-accent); }

/* ------------------------------------------------- dashboards and forms --- */

.dashboard { display: grid; gap: 1.4rem; margin-top: 1rem; }
.panel {
  border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface);
  padding: 1.4rem 1.5rem; min-width: 0;
}
.panel h2 { margin: 0 0 .7rem; font-size: 1.2rem; }
.panel > :last-child { margin-bottom: 0; }
.panel p { font-size: 1.05rem; }
.panel p.fine { font-size: .82rem; margin-top: 1rem; }
.panel-head { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem 1rem; margin-bottom: 1rem; }
.panel-head h2 { margin: 0; }
.goal-pick { margin-left: auto; display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; font-size: .8rem; color: var(--muted); }
.account { display: grid; gap: 1.2rem; margin-bottom: 1.5rem; }

.stats { display: grid; gap: .9rem; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.stat {
  display: flex; flex-direction: column; gap: .15rem; font-family: var(--sans);
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
  padding: 1rem 1.1rem;
}
.stat-label { font-family: var(--display); font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.stat-value { font-family: var(--display); font-size: 1.9rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.15; font-variant-numeric: tabular-nums; }
.stat-value small { font-family: var(--sans); font-size: .85rem; font-weight: 500; letter-spacing: 0; color: var(--muted); }
.stat-sub { font-size: .8rem; color: var(--muted); }

/* the game layer's tiles and lists on the progress page (assets/insights.js) */
.stat[data-level] { border-color: color-mix(in srgb, var(--xp-ink) 45%, var(--border)); box-shadow: inset 4px 0 0 var(--xp); }
.stat[data-on="true"] { border-color: color-mix(in srgb, var(--flame) 45%, var(--border)); box-shadow: inset 4px 0 0 var(--flame); }
#recall .stats { margin-bottom: 1rem; }
td.cell-medal[data-medal] span { color: var(--xp-ink); letter-spacing: .05em; }
.ach-group { margin: 1.4rem 0 .6rem; font-family: var(--display); font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.ach-group:first-of-type { margin-top: 1rem; }
ul.achievements {
  list-style: none; margin: 0; padding: 0; display: grid; gap: .7rem;
  grid-template-columns: repeat(auto-fill, minmax(min(15rem, 100%), 1fr)); font-family: var(--sans);
}
li.ach {
  display: flex; flex-direction: column; gap: .2rem; margin: 0; padding: .8rem .95rem;
  border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); background: var(--surface);
}
li.ach[data-unlocked] {
  border-style: solid; border-color: color-mix(in srgb, var(--xp-ink) 45%, var(--border));
  box-shadow: inset 4px 0 0 var(--xp);
}
.ach-title { display: flex; align-items: center; gap: .4rem; font-family: var(--display); font-weight: 700; font-size: .98rem; line-height: 1.25; color: var(--text); }
li.ach[data-unlocked] .ach-title::before {
  content: ""; flex: none; width: 1rem; height: 1rem; background: var(--xp-ink);
  -webkit-mask: var(--icon-star) center / contain no-repeat; mask: var(--icon-star) center / contain no-repeat;
}
.ach-text { font-size: .84rem; line-height: 1.4; color: var(--muted); }
.ach-meta {
  display: flex; align-items: center; gap: .6rem; margin-top: auto; padding-top: .35rem;
  font-size: .76rem; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap;
}
.ach-meta .meter { flex: 1 1 auto; height: 6px; }
li.ach[data-unlocked] .ach-meta { color: var(--text); font-weight: 600; }

.meter { display: inline-block; width: 100%; height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; vertical-align: middle; box-shadow: inset 0 0 0 1px var(--border); }
.meter > span { display: block; height: 100%; border-radius: 4px; background: var(--accent); }
.meter[data-tone="weak"] > span { background: var(--accent-2); }
.meter[data-tone="ok"] > span { background: var(--ok); }
.meter[data-tone="part"] > span { background: var(--part); }

/* XP per day: one bar a day, the goal as a dashed line */
.daychart {
  position: relative; display: grid; grid-template-columns: repeat(14, minmax(0, 1fr)); gap: 2px 6px;
  height: 9.5rem; margin-bottom: 1.8rem; font-family: var(--sans);
}
.daychart-goal { position: absolute; left: 0; right: 0; height: 0; border-top: 1px dashed var(--line-ui); pointer-events: none; }
.daychart-goal i { position: absolute; right: 0; bottom: 2px; font-style: normal; font-size: .68rem; color: var(--muted); }
.day { position: relative; display: flex; flex-direction: column; justify-content: flex-end; height: 100%; border-bottom: 1px solid var(--border-strong); }
.day-bar { display: block; width: 100%; max-width: 26px; margin: 0 auto; border-radius: 4px 4px 0 0; background: color-mix(in srgb, var(--accent) 55%, var(--surface)); }
.day[data-met] .day-bar { background: var(--accent); }
.day-name { position: absolute; left: 0; right: 0; top: 100%; margin-top: .3rem; text-align: center; font-size: .7rem; color: var(--muted); }
.day[data-today] .day-name { color: var(--text); font-weight: 700; }
.day::after {
  content: attr(data-tip); position: absolute; left: 50%; bottom: calc(100% + 4px); transform: translateX(-50%);
  white-space: nowrap; font-size: .74rem; padding: .25rem .55rem; border-radius: 6px; z-index: 2;
  background: var(--hud-bg); color: var(--hud-text); opacity: 0; pointer-events: none; transition: opacity .12s;
}
.day:nth-child(-n + 4)::after { left: 0; transform: none; }
.day:nth-last-child(-n + 3)::after { left: auto; right: 0; transform: none; }
.day:hover::after, .day:focus-visible::after { opacity: 1; }
.next-list { font-family: var(--sans); margin-bottom: .4rem; }
.next-list h3 { margin: 0 0 .6rem; font-size: 1rem; }
.next-item { margin: 0 0 .7rem; }
.next-item a { font-weight: 650; }
.next-item p { margin: .1rem 0 0; }
.chart-note { font-family: var(--sans); font-size: .82rem !important; color: var(--muted); margin: .9rem 0 0; }

.areas { list-style: none; margin: 0; padding: 0; font-family: var(--sans); }
.area {
  display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) auto; gap: .2rem 1.2rem; align-items: center;
  padding: .85rem 0; margin: 0; border-top: 1px solid var(--border);
}
.area:first-child { border-top: 0; }
.area-title { grid-column: 1; font-weight: 650; font-size: .98rem; text-decoration: none; color: var(--text); }
.area-title:hover { color: var(--accent); }
.area-label { color: var(--muted); font-weight: 500; font-variant-numeric: tabular-nums; }
.area-chapter { grid-column: 1; font-size: .78rem; color: var(--muted); }
.area-meter { grid-column: 2; grid-row: 1 / span 2; display: grid; gap: .3rem; }
.area-detail { font-size: .78rem; color: var(--muted); }
.area .btn { grid-column: 3; grid-row: 1 / span 2; }
@media (max-width: 640px) {
  .area { grid-template-columns: minmax(0, 1fr) auto; }
  .area-meter { grid-column: 1 / -1; grid-row: auto; }
  .area .btn { grid-column: 2; grid-row: 1 / span 2; }
}

table.chapters .part-row th { background: transparent; color: var(--part); padding-top: 1.3rem; font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; }
table.chapters tbody tr.part-row:hover { background: transparent; }
table.chapters td a { text-decoration: none; font-weight: 500; color: var(--text); }
table.chapters td a:hover { color: var(--accent); }
.cell-meter { white-space: nowrap; }
.cell-meter .meter { width: 6rem; margin-right: .6rem; }
td.cell-meter span:last-child { font-variant-numeric: tabular-nums; }
table.owner th .link { font-size: inherit; font-weight: inherit; letter-spacing: inherit; text-transform: inherit; color: inherit; text-decoration: none; }
table.owner th[aria-sort] .link::after {
  content: ""; display: inline-block; width: .8em; height: .8em; margin-left: .3em; vertical-align: -.05em;
  background-color: currentColor; -webkit-mask: var(--icon-up) center / contain no-repeat; mask: var(--icon-up) center / contain no-repeat;
}
table.owner th[aria-sort="descending"] .link::after { -webkit-mask-image: var(--icon-down); mask-image: var(--icon-down); }
table.owner th[aria-sort="none"] .link::after { content: none; }

.funnel { list-style: none; margin: 0; padding: 0; font-family: var(--sans); font-size: .86rem; display: grid; gap: .45rem; }
.funnel li { display: grid; grid-template-columns: minmax(0, 16rem) minmax(0, 1fr) 8rem; gap: 1rem; align-items: center; margin: 0; }
.funnel-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.funnel-n { color: var(--muted); font-variant-numeric: tabular-nums; }
@media (max-width: 640px) { .funnel li { grid-template-columns: minmax(0, 1fr) 4rem; } .funnel .meter { grid-column: 1 / -1; grid-row: 2; } }

.auth { max-width: 30rem; }
.auth .providers { display: grid; gap: .6rem; margin: 1.3rem 0 0; }
.auth .providers .btn { width: 100%; }
.auth .or { font-family: var(--sans); font-size: .82rem; font-weight: 600; color: var(--muted); margin: 1.4rem 0 .7rem; }
.auth > .form-note { margin: 0 0 1rem; }
.field { display: grid; gap: .3rem; margin: 0 0 .9rem; font-family: var(--sans); }
.field span { font-size: .82rem; font-weight: 600; color: var(--muted); }
.field input { font-family: var(--sans); width: 100%; }
.form-note { font-family: var(--sans); font-size: .88rem !important; margin: 1rem 0 0; padding: .6rem .8rem; border-radius: var(--radius-sm); background: var(--accent-soft); color: var(--text); }
.form-note.bad { background: var(--bad-soft); color: var(--bad); }
.learner-list { list-style: none; margin: 1rem 0 0; padding: 0; display: grid; gap: .6rem; }
.learner-row { border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: .7rem .9rem; min-width: 0; }
.learner-row[aria-current="true"] { border-color: var(--accent); background: var(--accent-soft); }
.learner-row .learner-name { margin: 0; font-family: var(--sans); font-weight: 700; font-size: 1.02rem; overflow-wrap: anywhere; }
.learner-row .actions { margin-top: .6rem; gap: .5rem; }
.learner-row .field { margin: 0 0 .6rem; }
.learner-tagline { margin: 0; }
.learner-tag,
.learner-on { font-family: var(--sans); font-size: .82rem; font-weight: 700; color: var(--accent-deep); padding: .35rem .2rem; }
.learner-tag-stale { color: var(--muted); }
.learner-add-h { margin: 1.6rem 0 .6rem; font-size: 1.05rem; }
.check { display: flex; gap: .6rem; align-items: flex-start; font-family: var(--sans); margin: 0 0 .9rem; min-width: 0; }
.check input { margin-top: .25rem; flex: none; }
.check span { overflow-wrap: anywhere; }
.consent { border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: .8rem 1rem; margin: 0 0 .9rem; }
.consent h4 { margin: 0 0 .4rem; font-size: .95rem; }
.consent p { font-size: .9rem; margin: 0 0 .8rem; }
.learners .btn { max-width: 100%; }
.sync-state { font-family: var(--sans); font-size: .84rem !important; color: var(--muted); }
.sync-state[data-state="error"] { color: var(--bad); }
.sync-state[data-state="synced"]::before {
  content: ""; display: inline-block; width: .95em; height: .95em; margin-right: .3em; vertical-align: -.12em;
  background: var(--ok); -webkit-mask: var(--icon-tick) center / contain no-repeat; mask: var(--icon-tick) center / contain no-repeat;
}

/* The motion for everything above (and the old motion block) lives in the one
   reduced-motion-guarded block at the end of game.css. */

/* -------------------------------------------------------- high contrast -- */

@media (prefers-contrast: more) {
  /* the tokens' own block (tokens.css) puts the text colour on the lines; the frame
     loses its motif */
  .callout.aside, details.reveal { border-style: solid; }
  body::before { display: none; }
}
@media (forced-colors: active) {
  .ex, .btn, .icon-btn, .chip, .choice, .order-item, .guess-chip, .puzzle, .rule, .callout, .worked,
  .widget, .recap, .stop-card, .chapter-nav a, .lesson-next, main > header.region-banner, .panel, .sidebar-body,
  details.reveal, .goal, .ex-form input[type="text"], input.blank {
    border-color: CanvasText; border-style: solid;
  }
  .topbar { border-bottom-color: CanvasText; -webkit-backdrop-filter: none; backdrop-filter: none; }
  .wrap, .wrap-narrow { border-color: CanvasText; }
  body::before { display: none; }
  .rule::before, main > h2::before, .practice > h2::before, .practice-head > h2::before { background: CanvasText; }
  .region-banner::after { display: none; }
  details.reveal > summary::after, .missions li[data-done] .mark::after, .ring[data-pct="100"]::after,
  .sync-state[data-state="synced"]::before, li.ach[data-unlocked] .ach-title::before {
    forced-color-adjust: none; background: CanvasText;
  }
  .choice:has(input:checked), .guess-chip[aria-pressed="true"], .chip[aria-pressed="true"] { border-width: 4px; }
}

/* ----------------------------------------------------------------- print -- */

@media print {
  /* paper is light whatever the screen was showing (tokens.css restates it), and
     there is no frame: no dark page, no motif, no panel edge */
  body { background: none; color: var(--text); }
  body::before { display: none; }
  .wrap, .wrap-narrow { width: auto; min-height: 0; margin: 0 auto; background: none; padding: 0; border: 0; border-radius: 0; }
  .topbar, .sidebar, .lesson-next, .lesson-mode, .lesson-progress, .toasts, .chapter-nav, .skip-link { display: none !important; }
  main > [data-step][hidden] { display: block !important; }
  /* with the sidebar gone, the chapter must not stay in the sidebar's grid column */
  .layout { display: block; }
  main { padding: 0; }
  *, *::before, *::after { box-shadow: none !important; }
  /* the banner becomes a plain heading with a rule */
  main > header.region-banner { display: block; border: 0; border-bottom: 2px solid var(--part); border-radius: 0; background: none; margin-bottom: 1.2rem; }
  .region-banner::after { display: none; }
  .region-banner > .eyebrow, .region-banner > h1, .region-banner > .lede { background: none; color: var(--text); padding: 0; }
  .region-banner > .eyebrow { color: var(--part); margin-bottom: .4rem; }
  .region-banner > h1 { margin-bottom: .4rem; }
  .region-banner > .lede { margin-bottom: .8rem; border-top: 0; }
  .callout, .callout.warn, .callout.why, .recap, .goal, .puzzle, details.reveal[open] { background: none; }
  .rule, .worked, .ex, figure, .callout { break-inside: avoid; }
  h2 { break-after: avoid; }
  a { color: var(--text); }
  /* a chart's data table is its text alternative: on paper the toggle is gone and the table shows */
  .widget[data-widget="chart"] .controls { display: none; }
  .widget[data-widget="chart"] table { display: table !important; }
}

/* the study plan (src/ui/plan.ts) on the progress page; the placement check's own page styles it in diagnostic.css */
#plan .plan-sub { margin: 0 0 .8rem; font-size: .9rem; font-weight: 500; font-family: var(--sans); }
.diag-plan:empty { display: none; }
.diag-plan h4 { margin: 1.1rem 0 .4rem; font-size: 1rem; font-family: var(--sans); }
.diag-plan h5 { margin: .7rem 0 .3rem; font-size: .9rem; font-weight: 650; color: var(--muted); font-family: var(--sans); }
.diag-plan ul { margin: 0 0 .5rem; padding-left: 1.2rem; font-family: var(--sans); }
.diag-plan li { margin: .25rem 0; }
.diag-plan-first { font-weight: 650; }
.diag-plan-group { margin: .4rem 0; }
.diag-plan-hand { margin-top: 1rem; }
.diag-plan-hand > summary { cursor: pointer; }
.diag-plan-hand > summary + h4 { margin-top: .8rem; }
.diag-plan h4 + .diag-plan-hand { margin-top: 0; }
.cnx-list { list-style: none; padding: 0; margin: 0; }
.cnx-row { padding: .6rem 0; border-top: 1px solid var(--border-strong); }
.cnx-row p { margin: 0 0 .3rem; }
.cnx-row .cnx-name { font-family: var(--sans); font-weight: 700; overflow-wrap: anywhere; }
.cnx-steps li { margin-bottom: .4rem; }
code[data-connect-url] { user-select: all; overflow-wrap: anywhere; }
/* ===========================================================================
   Basic Mathematics — game chrome
   HUD rail counters, region banner stats, exercise card states, encounters,
   toasts, the settings sheet, and every animation on the site.
   Consumes src/styles/tokens.css; never defines a colour of its own.
   The grammar is site.css's: anything you can act on is a tile with a hard edge
   (--shadow-tile), anything you read is a flat panel. All keyframes live in the
   one guarded block at the end, so reduced motion and calm mode stop everything.
   =========================================================================== */

/* ---------------------------------------------------------- HUD rail ----- */
/* The rail's markup is the shell's (tools/lib/shell.js): every slot is in the top bar
   from the first byte and filled before first paint, so its boxes are the ones the page
   keeps. Each slot's width is set here in rem and em, never by the digits or the font
   in it (a web font arriving later would otherwise move it), and a game slot the page
   can use (hearts, the clock) is laid out from the start, empty and unseen, so filling
   it moves nothing (the `hud` suite of tools/check-browser.js measures this). */

.hud {
  display: flex; align-items: center; gap: .5rem; min-height: 40px;
  font-family: var(--sans); font-size: .84rem; color: var(--hud-muted);
  white-space: nowrap; text-decoration: none;
}
.hud b {
  font-family: var(--display); font-weight: 700; color: var(--hud-text);
  font-variant-numeric: tabular-nums;
}

/* level: a badge tile and the XP bar, with the XP in words under it */
.hud-level {
  display: inline-flex; align-items: center; gap: .55rem; min-height: 40px;
  padding: 0 0 0 .3rem; border-radius: var(--radius-xs);
  color: var(--hud-muted); text-decoration: none;
}
.hud-level:hover { background: var(--hud-chip); }
.hud-badge {
  display: grid; place-items: center; min-width: 2rem; height: 2rem; padding: 0 .3rem;
  border-radius: var(--radius-xs); background: var(--hud-chip);
  border: 1.5px solid var(--hud-xp); box-shadow: 0 2px 0 var(--hud-edge);
}
.hud-badge b { font-size: 1rem; font-weight: 800; line-height: 1; color: var(--hud-xp); text-align: center; }
.hud > .hud-xp { display: flex; flex-direction: column; gap: .3rem; width: 6.25rem; margin: 0 .55rem 0 .05rem; }
.hud-xpbar {
  display: block; position: relative; width: 100%; height: 6px; border-radius: 3px;
  background: var(--hud-track); overflow: hidden;
}
.hud-xpbar i { display: block; height: 100%; width: 0; border-radius: 3px; background: var(--hud-xp); }
.hud-xptext { display: block; overflow: hidden; font-size: .72rem; line-height: 1; color: var(--hud-muted); }
.hud-xptext b { font-size: .78rem; }

/* streak: today's goal as a ring, then the flame and the day count */
.hud-streak { display: inline-flex; align-items: center; gap: .3rem; min-height: 40px; }
.hud-streak .icon { width: 1rem; height: 1rem; color: var(--hud-muted); flex: none; }
.hud-streak[data-on] .icon { color: var(--hud-flame); }
.hud-streak b { display: inline-block; min-width: 1.4em; }
.hud-facets { display: inline-flex; align-items: center; gap: .3rem; min-height: 40px; }
.hud-facets .icon { width: 1rem; height: 1rem; color: var(--hud-muted); flex: none; }
.hud-facets b { display: inline-block; min-width: 1.4em; }
.goal-ring {
  --pct: 0; width: 1.05rem; height: 1.05rem; border-radius: 50%; flex: none;
  background: conic-gradient(var(--hud-ok) calc(var(--pct) * 1%), var(--hud-track) 0);
  -webkit-mask: radial-gradient(circle, transparent 45%, black 48%);
  mask: radial-gradient(circle, transparent 45%, black 48%);
}
.goal-ring[data-full] { -webkit-mask: none; mask: none; background: var(--hud-ok); }

/* combo: five diamonds; a shield draws a ring round them */
.hud-combo {
  display: inline-flex; align-items: center; gap: 5px; height: 1.75rem; padding: 0 .55rem;
  border-radius: var(--radius-pill);
}
.hud-combo i {
  display: block; width: 9px; height: 9px; transform: rotate(45deg);
  border: 1.5px solid var(--hud-muted); border-radius: 1px;
}
.hud-combo i[data-on] { background: var(--hud-xp); border-color: var(--hud-xp); }
.hud-combo[data-shield="true"] { box-shadow: inset 0 0 0 2px var(--hud-ok); }

/* hearts: filled or outlined, so a lost heart reads without its colour */
.hud-hearts, .encounter-hearts { display: inline-flex; align-items: center; gap: 3px; }
.hud-hearts { color: var(--hud-heart); }
.encounter-hearts { color: var(--heart); }
.hud-hearts i, .encounter-hearts i {
  display: block; width: 1.05rem; height: 1.05rem; background: currentColor;
  -webkit-mask: var(--icon-heart-o) center / contain no-repeat; mask: var(--icon-heart-o) center / contain no-repeat;
}
.hud-hearts i[data-full], .encounter-hearts i[data-full] { -webkit-mask-image: var(--icon-heart); mask-image: var(--icon-heart); }

/* the Arena's clock; at critical a static stripe, never a flash */
.hud-timer {
  display: inline-flex; align-items: center; justify-content: center; min-height: 2.25rem; padding: 0 .55rem;
  border-radius: var(--radius-xs); background: var(--hud-chip); border: 1px solid var(--hud-line);
}
.hud-timer-text {
  font-family: var(--display); font-weight: 700; font-size: 1.2rem; line-height: 1;
  font-variant-numeric: tabular-nums; min-width: 2.6em; text-align: center; color: var(--hud-text);
}
.hud-timer[data-urgency="low"] { border-color: var(--hud-xp); }
.hud-timer[data-urgency="low"] .hud-timer-text { color: var(--hud-xp); }
.hud-timer[data-urgency="critical"] {
  border-color: var(--hud-heart);
  background-image: repeating-linear-gradient(135deg, var(--hud-stripe) 0 5px, transparent 5px 10px);
}
.hud-timer[data-urgency="critical"] .hud-timer-text { color: var(--hud-heart); }

/* a game slot the page can use keeps its place while it is empty: three hearts' width,
   a clock's; filled, it is the same box. site.css hides [hidden] with !important, so
   this has to say it too. Study mode has no hearts, so it keeps no place for them. */
.hud > .hud-timer[data-slot][hidden], html:not([data-calm]) .hud > .hud-hearts[data-slot][hidden] { display: inline-flex !important; visibility: hidden; }
.hud > .hud-hearts[data-slot] { min-width: calc(3 * 1.05rem + 6px); min-height: 1.05rem; }
.hud > .hud-timer[data-slot] { min-width: 4.5rem; }

/* icons drawn by the shell paint in currentColor */
svg.icon { display: inline-block; width: 1em; height: 1em; flex: none; vertical-align: -.125em; overflow: visible; }

/* the sound and menu buttons: the sound icon says on or off from html[data-sound],
   which the boot script stamped before first paint */
.hud-sound, .hud-menu { flex: none; display: grid; place-items: center; }
.icon-btn svg.icon { width: 1.25rem; height: 1.25rem; }
.hud-sound .icon-sound-on, html[data-sound="on"] .hud-sound .icon-sound-off { display: none; }
html[data-sound="on"] .hud-sound .icon-sound-on { display: inline-block; }
html[data-calm] .hud-sound { opacity: .5; cursor: not-allowed; }
.hud-menu[aria-expanded="true"] { background: var(--hud-text); color: var(--hud-bg); border-color: var(--hud-text); }

/* the account chip: one width signed in or out, so turning into the avatar moves nothing */
.topbar nav > .acct { flex: none; justify-content: center; width: 5.25rem; padding: 0; }

/* ------------------------------------- what the HUD parts say (src/ui/hud-pop.ts) -- */
/* A chip under a hovered or focused part and a small popover under the level badge, both
   absolute inside the sticky bar, so neither takes room or moves a thing. The chip is for
   the eye only (aria-hidden; the parts carry the labels) and never takes the pointer. */
.hud-tip {
  position: absolute; z-index: 46; max-width: min(20rem, calc(100vw - 16px)); padding: .35rem .6rem;
  background: var(--hud-bg); color: var(--hud-text); border: 1.5px solid var(--hud-line);
  border-radius: var(--radius-xs); box-shadow: 0 2px 0 var(--hud-edge);
  font-family: var(--sans); font-size: .78rem; font-weight: 500; line-height: 1.35; white-space: normal;
  pointer-events: none;
}
.hud-tip[hidden] { display: none; }
/* The bar is sticky at z-index 40, so the popover (46) only stacks inside it, below the toasts (44).
   While one is open the bar goes above them, so a toast never paints over its words. */
.topbar:has(.hud-pop:not([hidden])) { z-index: 45; }
.hud-pop {
  --focus: var(--hud-focus);
  position: absolute; z-index: 46; width: min(19rem, calc(100vw - 16px)); padding: .7rem .8rem .8rem;
  background: var(--hud-bg); color: var(--hud-text); border: 2px solid var(--hud-line);
  border-radius: var(--radius-sm); box-shadow: 0 4px 0 var(--hud-edge);
  font-family: var(--sans); font-size: .88rem; line-height: 1.4; white-space: normal;
}
.hud-pop p { margin: 0 0 .4rem; }
.hud-pop .pop-title { font-family: var(--display); font-weight: 800; font-size: 1.02rem; }
.hud-pop .pop-line { color: var(--hud-muted); }
.hud-pop .pop-bar { display: block; height: 6px; margin: 0 0 .55rem; border-radius: 3px; background: var(--hud-track); overflow: hidden; }
.hud-pop .pop-bar i { display: block; height: 100%; border-radius: 3px; background: var(--hud-xp); }
.hud-pop .pop-link { display: flex; justify-content: center; align-items: center; width: 100%; margin-top: .6rem; box-sizing: border-box; }

/* -------------------------------------------------- the settings sheet --- */
/* A native <dialog> (src/ui/settings.ts): on a wide screen it hangs from the rail and is
   not modal; on a narrow one it is a modal sheet from the bottom over the scrim. Frame
   colours, solid, in both. */

.hud-sheet {
  --focus: var(--hud-focus);
  position: absolute; inset: calc(100% + 2px) max(16px, 4vw) auto auto; z-index: 45;
  width: min(23rem, calc(100vw - 32px)); max-height: calc(100vh - var(--hud-h) - 1rem); overflow-y: auto;
  margin: 0; padding: .55rem .55rem .8rem; background: var(--hud-bg); color: var(--hud-text);
  border: 2px solid var(--hud-line); border-top: 0; border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  box-shadow: 0 4px 0 var(--hud-edge);
  font-family: var(--sans); font-size: .92rem; white-space: normal;
}
.hud-sheet:not([open]) { display: none; }
.hud-sheet:modal {
  position: fixed; inset: auto 0 0 0; width: 100%; max-width: none; max-height: min(88vh, 44rem);
  padding: .55rem max(16px, 4vw) max(1rem, env(safe-area-inset-bottom));
  border: 2px solid var(--hud-line); border-bottom: 0; border-radius: var(--radius) var(--radius) 0 0;
  box-shadow: none;
}
.hud-sheet::backdrop { background: var(--scrim-glass); }

/* the keyboard layer (src/ui/keys.ts): the cheat sheet "?" opens, a modal on paper, and the
   ring on the card or heading the layer moved to. site.css drops the ring on
   [tabindex="-1"]; this one is more specific and comes later. No motion on either. */
.keys-sheet {
  width: min(32rem, calc(100vw - 32px)); max-width: 32rem; max-height: min(88vh, 44rem); overflow-y: auto;
  padding: 1rem 1.25rem 1.1rem; background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius);
}
.keys-sheet::backdrop { background: var(--scrim-glass); }
.keys-sheet h2 { margin: 0 0 .5rem; font-size: 1.25rem; }
.keys-sheet h3 { margin: 1rem 0 .4rem; font-size: 1rem; }
.keys-sheet dl { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; margin: 0; }
.keys-sheet dt, .keys-sheet dd { margin: 0; }
.keys-sheet dt { white-space: nowrap; }
.keys-sheet [data-keys-close] { margin-top: 1rem; }
/* the first-run guide (src/ui/first-run.ts): five cards in a modal on paper, no motion; the
   part of the bar a card names gets a ring by outline, which moves nothing */
.guide-sheet {
  width: min(28rem, calc(100vw - 32px)); max-width: 28rem; max-height: min(88vh, 44rem); overflow-y: auto;
  padding: 1rem 1.25rem 1.1rem; background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius);
}
.guide-sheet::backdrop { background: var(--scrim-glass); }
.guide-sheet .guide-title { margin: 0 0 .5rem; font-size: 1.25rem; }
.guide-sheet .guide-body { margin: 0 0 .75rem; line-height: 1.5; }
.guide-sheet .guide-step { margin: 0 0 .75rem; font-size: .875rem; opacity: .8; }
.guide-sheet .guide-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.guide-sheet .guide-actions [data-guide-skip] { margin-right: auto; }
.guide-sheet .guide-actions [hidden] { display: none; }
[data-guide-spot] { outline: 3px solid var(--focus); outline-offset: 2px; }
/* in the Comfort group it sits on the switch rows' left edge (their .75rem padding) */
.hud-sheet [data-guide-replay] { margin: .6rem 0 .25rem .75rem; }
@media (max-width: 520px) { .hud-sheet [data-guide-replay] { display: block; width: calc(100% - 1.5rem); } }
/* the go-to palette "/" opens: the same paper, a full-width box and a plain list; the
   selected row as the Arena board marks the reader's own row */
.keys-palette input {
  display: block; width: 100%; box-sizing: border-box; margin: 0 0 .5rem; min-height: 2.6rem; padding: .4rem .6rem;
  font: inherit; font-size: 1rem; background: var(--bg); color: var(--text);
  border: 2px solid var(--line-ui); border-radius: var(--radius-sm);
}
.keys-palette [role=listbox] { list-style: none; margin: 0; padding: 0; }
.keys-palette [role=option] { padding: .35rem .6rem; border-radius: var(--radius-xs); cursor: pointer; }
.keys-palette [role=option][data-selected] { background: var(--accent-soft); color: var(--text); box-shadow: inset 3px 0 0 var(--accent); }
.keys-palette [role=option] small { color: var(--muted); }
.keys-palette-empty { margin: .35rem 0; color: var(--muted); }
[data-keys-cursor]:focus-visible { outline: var(--focus-width) solid var(--focus); outline-offset: var(--focus-offset); }

.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: 0 0 .35rem .75rem; }
.sheet-title {
  margin: 0; color: var(--hud-muted);
  font: 700 .74rem/1.3 var(--display); text-transform: uppercase; letter-spacing: .08em;
}
.hud-sheet .sheet-close { --edge: var(--hud-edge); min-width: 40px; height: 40px; padding: 0; background: var(--hud-chip); color: var(--hud-text); border: 1px solid var(--hud-line); }

.hud-links { list-style: none; margin: 0 0 .5rem; padding: 0 0 .5rem; border-bottom: 1px solid var(--hud-line); }
.hud-links li { margin: 0; }
.hud-links a {
  display: flex; align-items: center; min-height: 44px; padding: 0 .75rem;
  border-radius: var(--radius-xs); color: var(--hud-text); text-decoration: none; font-weight: 600;
}
.hud-links a:hover { background: var(--hud-chip); }
.hud-links a[aria-current] { box-shadow: inset 3px 0 0 var(--hud-xp); }

/* Study mode first, on a raised tile of its own: the one choice that changes the course */
.hud-sheet .sheet-study {
  margin: 0 0 .5rem; padding: .65rem .75rem; background: var(--hud-chip);
  border: 1px solid var(--hud-line); border-left: 4px solid var(--hud-ok);
}
.hud-sheet .sheet-study span { font-family: var(--display); font-size: 1rem; }
.hud-sheet .sheet-study:hover { background: var(--hud-chip); border-color: var(--hud-muted); border-left-color: var(--hud-ok); }

.sheet-group { margin: 0; padding: .45rem 0 .35rem; border: 0; border-top: 1px solid var(--hud-line); min-width: 0; }
.sheet-group legend {
  float: left; width: 100%; padding: .2rem .75rem .25rem; color: var(--hud-muted);
  font: 700 .72rem/1.3 var(--display); text-transform: uppercase; letter-spacing: .08em;
}
.sheet-group legend + * { clear: left; }

/* a choice of a few: a row of pills, the chosen one filled */
.sheet-options { display: flex; flex-wrap: wrap; gap: .4rem; padding: .15rem .75rem .45rem; }
.sheet-options label {
  position: relative; display: inline-flex; align-items: center; gap: .45rem; min-height: 40px;
  padding: 0 .85rem 0 .65rem; border-radius: var(--radius-pill); cursor: pointer;
  background: var(--hud-chip); color: var(--hud-text); border: 1.5px solid var(--hud-line); font-weight: 600;
}
.sheet-options input {
  -webkit-appearance: none; appearance: none; flex: none; margin: 0; width: 1rem; height: 1rem;
  border-radius: 50%; border: 1.5px solid var(--hud-muted); background: transparent; cursor: pointer;
}
/* chosen: a ring and a dot in the pill's ink */
.sheet-options input:checked { border-color: var(--hud-bg); background: var(--hud-bg); box-shadow: inset 0 0 0 2.5px var(--hud-text); }
.sheet-options label:has(input:checked) { background: var(--hud-text); color: var(--hud-bg); border-color: var(--hud-text); }
.sheet-options input:focus-visible { outline: var(--focus-width) solid var(--focus); outline-offset: 3px; }

/* the volume */
.sheet-slider { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; column-gap: .8rem; min-height: 44px; padding: 0 .75rem; }
.sheet-slider span { font-weight: 600; color: var(--hud-text); min-width: 2.75rem; }
.sheet-slider input { width: 100%; margin: 0; accent-color: var(--hud-ok); color-scheme: dark; cursor: pointer; }
.sheet-slider input:disabled { cursor: not-allowed; }
.sheet-slider:has(input:disabled) span { color: var(--hud-muted); }

/* switches: a track and a knob; the knob's side says on or off without colour */
.switch {
  --sw-track: var(--surface-2); --sw-line: var(--line-ui); --sw-on: var(--accent);
  --sw-knob: var(--line-ui); --sw-knob-on: var(--on-accent); --sw-text: var(--text); --sw-muted: var(--muted);
  display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: .8rem; align-items: center;
  min-height: 48px; padding: .4rem .75rem; border-radius: var(--radius-xs); cursor: pointer;
  font-family: var(--sans);
}
.hud-sheet .switch {
  --sw-track: var(--hud-track); --sw-line: var(--hud-muted); --sw-on: var(--hud-ok);
  --sw-knob: var(--hud-muted); --sw-knob-on: var(--hud-bg); --sw-text: var(--hud-text); --sw-muted: var(--hud-muted);
}
.hud-sheet .switch:hover { background: var(--hud-chip); }
.switch input {
  -webkit-appearance: none; appearance: none; position: relative; margin: 0; cursor: pointer;
  grid-row: 1 / span 2; width: 2.75rem; height: 1.6rem; border-radius: var(--radius-pill);
  background: var(--sw-track); border: 1.5px solid var(--sw-line);
}
.switch input::before {
  content: ""; position: absolute; top: 2.5px; left: 2.5px; width: 1.05rem; height: 1.05rem;
  border-radius: 50%; background: var(--sw-knob); transition: transform var(--t-2) var(--ease-out);
}
.switch input:checked { background: var(--sw-on); border-color: var(--sw-on); }
.switch input:checked::before { transform: translateX(1.15rem); background: var(--sw-knob-on); }
.switch input:disabled { cursor: not-allowed; opacity: .55; }
.switch:has(input:disabled) { cursor: not-allowed; }
.switch input:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.switch span { grid-column: 2; font-weight: 600; color: var(--sw-text); }
.switch small { grid-column: 2; font-size: .78rem; line-height: 1.35; color: var(--sw-muted); }

/* narrow screens: the Arena's hearts and clock get a row of their own */
.hud-strip {
  flex: 1 0 100%; display: flex; align-items: center; justify-content: center; gap: 1rem;
  min-height: 40px; padding-top: .35rem; border-top: 1px solid var(--hud-line);
}

/* the shell writes copies of hearts and clock in both places; wide screens show the rail's
   (the collapse below moves them to the strip at the same width) */
@media (min-width: 801px) { .hud-strip { display: none !important; } }

/* the Arena keeps hearts and clock large; its rail is the accent, not a Part. Its top
   bar is the one with a second row (the shell writes it for the Arena alone), which is
   known from the first byte, where body[data-mode] waits for arena.js */
.topbar:has(> .hud-strip) { border-bottom-color: var(--accent); }
.topbar:has(> .hud-strip) .hud-hearts i { width: 1.3rem; height: 1.3rem; }
.topbar:has(> .hud-strip) .hud > .hud-hearts[data-slot] { min-width: calc(3 * 1.3rem + 6px); min-height: 1.3rem; }
.topbar:has(> .hud-strip) .hud-timer-text { font-size: 1.4rem; }

/* Collapse, widest first, so the top bar is never wider than the window and the menu
   button, the way to every setting and link, is always on screen. In this order: the
   brand's name; the page links (the sheet holds every link); the hearts and the clock (a
   chapter shows its hearts in its encounter, the Arena both in its second row); the
   account chip (the sheet links to the account); Sound (the sheet has it); then the HUD's
   own parts grow smaller. A bar with more in it goes sooner: the Arena's (hearts and a
   clock), then a chapter's (a boss's hearts), then the rest. Each width is where that
   kind's widest bar (a three-digit streak, a full combo with its shield, the account
   chip) stops fitting, with room to spare; the slot widths above are fixed in rem, so
   these hold whatever the HUD says. The `hud` suite of tools/check-browser.js sweeps
   widths from 320 to 1280 on every kind of top bar and fails any that overflows. */
@media (max-width: 1240px) { .topbar:has(> .hud-strip) .brand-name { display: none; } }
@media (max-width: 1120px) { .topbar:has(.hud-hearts) .brand-name { display: none; } }
@media (max-width: 1050px) {
  .topbar .brand-name { display: none; }
  .topbar:has(> .hud-strip) nav > a:not(.acct) { display: none; }
}
@media (max-width: 940px) { .topbar:has(.hud-hearts) nav > a:not(.acct) { display: none; } }
@media (max-width: 860px) { .topbar nav > a:not(.acct) { display: none; } }
@media (max-width: 800px) {
  html .topbar:has(> .hud-strip) .hud > .hud-hearts, html:not([data-calm]) .topbar:has(> .hud-strip) .hud > .hud-hearts[data-slot][hidden],
  html .hud > .hud-timer, html .hud > .hud-timer[data-slot][hidden] { display: none !important; }
}
@media (max-width: 690px) {
  html .hud > .hud-hearts, html:not([data-calm]) .hud > .hud-hearts[data-slot][hidden] { display: none !important; }
}
@media (max-width: 615px) { .topbar nav > .acct { display: none; } }
@media (max-width: 520px) { .topbar nav > .hud-sound { display: none; } }
@media (max-width: 480px) {
  .hud-combo[data-pips="0"], .hud-combo[data-pips="1"] { display: none; }
  .hud { gap: .35rem; }
  .hud > .hud-xp { width: 5rem; margin-left: .2rem; }
}
@media (max-width: 440px) {
  .hud-xptext { display: none; }
  .hud > .hud-xp { gap: 0; width: 4rem; }
}
@media (max-width: 420px) {
  .topbar { padding-inline: 12px; }
  .hud { gap: .25rem; }
  .hud > .hud-xp { width: 3rem; margin-left: .3rem; margin-right: .3rem; }
  .hud-combo { gap: 4px; padding: 0 .35rem; }
  .hud-combo i { width: 7px; height: 7px; }
}
/* the narrowest: the level's badge alone; the XP span leaves the row but not the
   accessibility tree, so a screen reader still hears the XP (as .visually-hidden) */
@media (max-width: 359px) {
  .hud > .hud-xp {
    position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0;
    overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
  }
  .hud-level { padding-right: .3rem; }
}
/* ------------------------------------------------- region banner meta ---- */
/* game.js fills the row; its height is reserved so the page does not shift. */

.banner-meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: .45rem;
  min-height: 2.25rem; padding: 0 1.4rem 1.15rem; box-sizing: content-box;
}
.banner-meta:empty { min-height: .4rem; }
.banner-stat {
  display: inline-flex; align-items: baseline; gap: .3rem; min-height: 2.25rem; padding: .35rem .75rem;
  border-radius: var(--radius-xs); background: var(--surface);
  border: 1px solid color-mix(in srgb, var(--part) 35%, var(--border));
  font-family: var(--sans); font-size: .8rem; font-weight: 600; line-height: 1.4; color: var(--muted);
  white-space: nowrap;
}
.banner-stat[data-medal] b { color: var(--xp-ink); letter-spacing: .05em; }
.banner-stat b {
  font-family: var(--display); font-size: .98rem; font-weight: 700; color: var(--text);
  font-variant-numeric: tabular-nums;
}
@media (max-width: 480px) { .banner-meta { padding-inline: 1.1rem; } }

/* ----------------------------------------------------- exercise cards ---- */
/* idle · focused · correct (first, retry, assisted) · wrong (hint 1, 2, 3) · restored · target */

.ex:focus-within { border-color: var(--accent); }

.ex[data-state="correct"] { --edge: var(--ok-deep); border-color: var(--ok); }
/* restored from storage: the green border, flat, no motion */
.ex[data-state="correct"][data-restored] { box-shadow: none; }
/* a miss: the border only, no red wash over the problem */
.ex[data-state="wrong"] { border-color: var(--bad); }

/* the next problem in an encounter: a chevron and the word, in the Part's colour */
.ex[data-target="true"]:not([data-state="correct"]) { --edge: var(--part-deep); }
.ex[data-target="true"]:not([data-state]) { border-color: var(--part); }
.ex[data-target="true"]:not([data-state="correct"])::before {
  content: "Next"; content: "Next" / "";
  position: absolute; top: -.8rem; right: 1.1rem; z-index: 1;
  padding: .2rem 1.5rem .2rem .6rem; border-radius: var(--radius-xs);
  background: var(--part); color: var(--on-part);
  font: 700 .72rem/1.3 var(--display); text-transform: uppercase; letter-spacing: .08em;
}
.ex[data-target="true"]:not([data-state="correct"])::after {
  content: ""; position: absolute; top: -.56rem; right: 1.5rem; z-index: 2;
  width: .85rem; height: .85rem; background: var(--on-part);
  -webkit-mask: var(--icon-next) center / contain no-repeat; mask: var(--icon-next) center / contain no-repeat;
}

/* feedback: the verdict is a short line; after a miss the hint is the big thing */
.ex-feedback { display: none; margin-top: .95rem; font-family: var(--sans); font-size: .95rem; }
.ex-feedback[data-show="true"] { display: block; }
.ex-verdict {
  display: flex; align-items: center; gap: .35rem; margin: 0 0 .55rem;
  font-family: var(--display); font-weight: 700; line-height: 1.3;
}
.ex-verdict.ok { color: var(--ok); font-size: 1.05rem; }
.ex-verdict.no { color: var(--bad); font-size: .86rem; }
.ex-verdict.nudge { color: var(--muted); font-family: var(--sans); font-weight: 500; font-size: .92rem; }
/* the right value in a form the key does not take: a hint's ink, no cross and no tick */
.ex-verdict.form { color: var(--hint-ink); font-family: var(--sans); font-weight: 500; font-size: .92rem; }
.ex-verdict .tick, .ex-feedback .tick { width: 1.15em; height: 1.15em; flex: none; }

.ex-hint {
  margin: 0 0 .6rem; padding: .85rem 1.1rem .95rem;
  background: var(--hint-soft); border-left: 4px solid var(--accent-2);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.ex-hint-label {
  display: block; margin-bottom: .3rem;
  font-family: var(--display); font-weight: 700; font-size: .74rem; line-height: 1.3;
  text-transform: uppercase; letter-spacing: .08em; color: var(--hint-ink);
}
.ex-feedback .ex-hint-text {
  display: block; margin: 0; font-family: var(--sans); font-size: 1.0625rem; line-height: 1.55; color: var(--text);
}
/* an earlier hint stays, quieter */
.ex-hint[data-prev] { background: transparent; border-left-color: var(--border-strong); padding-block: .15rem; }
.ex-hint[data-prev] .ex-hint-label, .ex-feedback .ex-hint[data-prev] .ex-hint-text { color: var(--muted); }
.ex-feedback .ex-hint[data-prev] .ex-hint-text { font-size: .9rem; }
.ex-feedback .ex-next { display: block; margin: .3rem 0 0; font-size: .88rem; color: var(--muted); }

/* hint level 3 (no hints left): the solution button is the suggestion */
.btn.ghost[data-suggested="true"] { --edge: var(--accent-deep); border-color: var(--accent); color: var(--accent); }

/* how it was solved, stamped in the corner after a correct answer */
.ex-stamp {
  position: absolute; top: .8rem; right: 1rem; pointer-events: none;
  padding: .3rem .55rem; border-radius: var(--radius-xs); transform: rotate(-3deg);
  font: 800 .72rem/1.1 var(--display); text-transform: uppercase; letter-spacing: .08em;
  color: var(--ok); background: var(--surface); border: 2px solid var(--ok);
}
.ex[data-result="first"] .ex-stamp { color: var(--surface); background: var(--ok); }

/* the XP just earned, a gold chip beside the label */
.ex-reward {
  display: inline-block; vertical-align: middle; margin: 0 0 .5rem .55rem; padding: .12rem .5rem;
  border-radius: var(--radius-pill); background: var(--xp); color: var(--on-xp); border: 1px solid var(--xp-ink);
  font: 700 .74rem/1.25 var(--display); font-variant-numeric: tabular-nums; white-space: nowrap;
}

/* right and wrong on the answer itself: an icon as well as a colour */
.ex[data-state="correct"] .choice:has(input:checked) { border-color: var(--ok); background: var(--ok-soft); }
.ex[data-kind="choice"][data-state="wrong"] .choice:has(input:checked) { border-color: var(--bad); background: var(--surface); }
.ex[data-state="correct"] .choice:has(input:checked)::after,
.ex[data-kind="choice"][data-state="wrong"] .choice:has(input:checked)::after {
  content: ""; flex: none; align-self: center; margin-left: auto; width: 1.15rem; height: 1.15rem;
  background: var(--ok);
  -webkit-mask: var(--icon-tick) center / contain no-repeat; mask: var(--icon-tick) center / contain no-repeat;
}
.ex[data-kind="choice"][data-state="wrong"] .choice:has(input:checked)::after {
  background: var(--bad); -webkit-mask-image: var(--icon-cross); mask-image: var(--icon-cross);
}
.ex[data-state="correct"] .order-item { border-color: var(--ok); --edge: var(--ok-deep); cursor: default; }
input.blank[data-ok="true"], input.blank[data-ok="false"] {
  padding-right: 1.35em; background-repeat: no-repeat; background-position: right .3em center; background-size: .8em;
}
input.blank[data-ok="true"] { border-color: var(--ok); background-color: var(--ok-soft); background-image: var(--mark-ok); }
input.blank[data-ok="false"] { border-color: var(--bad); background-image: var(--mark-bad); }

/* the inline checks keep their Part tint in every state */
.ex[data-inline][data-state="correct"] { border-color: var(--ok); }
.ex[data-inline][data-state="wrong"] { border-color: var(--bad); }

/* ---------------------------------------------------------- encounters --- */
/* encounter.js turns each practice set into a boss: health is the count of unsolved problems. */

.encounter {
  --edge: var(--part-deep);
  position: relative; display: grid; grid-template-columns: 5.5rem minmax(0, 1fr); gap: 1.1rem;
  align-items: start; margin: 0 0 1.8rem; padding: 1.1rem 1.2rem 1.15rem;
  background: var(--surface); border: 2px solid var(--part); border-radius: var(--radius);
  box-shadow: var(--shadow-tile);
  font-family: var(--sans);
}
.practice-head + .encounter, h2 + .encounter { margin-top: 1rem; }
.practice > .encounter:first-child { margin-top: 0; }
.encounter-main { min-width: 0; }

/* the sigil: the region's solid on a scene-stage square with the motif behind it */
.encounter-sigil {
  position: relative; display: grid; place-items: center; aspect-ratio: 1;
  border-radius: var(--radius-sm); background: var(--part-soft);
}
.encounter-sigil::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit;
  background-color: color-mix(in srgb, var(--part) 22%, var(--part-soft));
  -webkit-mask-image: var(--motif); mask-image: var(--motif);
  -webkit-mask-size: var(--motif-size); mask-size: var(--motif-size);
  -webkit-mask-composite: var(--motif-wcomp); mask-composite: var(--motif-comp);
}
.sigil { position: relative; width: 78%; height: auto; overflow: visible; }
/* encounter.js draws one .sigil-face per visible face; a face empties as a problem is solved */
.sigil-face, .sigil > polygon {
  fill: var(--part-soft); stroke: var(--part); stroke-width: 2; stroke-linejoin: round;
}
.sigil-face:nth-child(2n), .sigil > polygon:nth-child(2n) { fill: color-mix(in srgb, var(--part) 24%, var(--part-soft)); }
.sigil-face:nth-child(3n), .sigil > polygon:nth-child(3n) { fill: color-mix(in srgb, var(--part) 42%, var(--part-soft)); }
.sigil-face[data-on="false"], .sigil[data-left="0"] .sigil-face, .sigil[data-left="0"] > polygon {
  fill: transparent; stroke-dasharray: 4 3; stroke-opacity: .7;
}
.sigil .sigil-check { display: none; fill: none; stroke: var(--ok); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
/* beaten: a wireframe and a check */
.sigil[data-left="0"] .sigil-check { display: inline; }
.encounter-sigil:has(.sigil[data-left="0"]):not(:has(.sigil-check))::after {
  content: ""; position: absolute; right: 8%; bottom: 8%; width: 36%; height: 36%;
  border-radius: 50%; background: var(--ok);
  -webkit-mask: var(--icon-tick) center / 80% no-repeat; mask: var(--icon-tick) center / 80% no-repeat;
}

.encounter-kicker {
  margin: 0 0 .15rem; color: var(--part);
  font: 700 .72rem/1.3 var(--display); text-transform: uppercase; letter-spacing: .08em;
}
.encounter-boss { margin: 0 0 .75rem; font-size: .95rem; line-height: 1.35; color: var(--muted); }
.encounter-boss b {
  display: block; font: 800 clamp(1.2rem, 1.05rem + .7vw, 1.45rem)/1.15 var(--display);
  letter-spacing: -.01em; color: var(--text);
}
.encounter-taunt { display: block; margin-top: .25rem; font-family: var(--serif); font-style: italic; font-size: 1.02rem; }

/* the health bar: one segment per problem, its fill saying how it was solved */
.encounter-bar { position: relative; display: flex; gap: 3px; height: .85rem; margin: 0 0 .55rem; }
.encounter-seg {
  flex: 1 1 0; min-width: 4px; border-radius: 3px;
  background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line-ui);
}
.encounter-seg[data-how="first"] { background: var(--ok); box-shadow: none; }
.encounter-seg[data-how="solved"] {
  background-color: var(--ok); box-shadow: none;
  background-image: repeating-linear-gradient(135deg, transparent 0 3px, color-mix(in srgb, var(--surface) 55%, transparent) 3px 5.5px);
}
.encounter-seg[data-how="opened"] { background: var(--accent-2); box-shadow: none; }
.encounter-seg[data-how="unknown"] { background: var(--muted); box-shadow: none; }

.encounter-status {
  display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .5rem; margin: 0 0 .65rem;
  font-size: .88rem; font-weight: 600; color: var(--muted);
}
.encounter-status > b {
  font-family: var(--display); font-size: 1.1rem; font-weight: 700; color: var(--text);
  font-variant-numeric: tabular-nums; min-width: 1.5ch; text-align: right;
}

/* wards: one chip per section, filled when its problems are all solved */
.encounter-wards { list-style: none; display: flex; flex-wrap: wrap; gap: .35rem; margin: 0; padding: 0; }
.encounter-wards li {
  display: inline-flex; align-items: center; gap: .3rem; margin: 0; padding: .2rem .55rem;
  border-radius: var(--radius-xs); border: 1px solid var(--line-ui); background: var(--surface);
  font-size: .76rem; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums;
}
.encounter-wards li[data-done="true"] { background: var(--part); border-color: var(--part); color: var(--on-part); }
.encounter-wards li[data-done="true"]::before {
  content: ""; width: .8rem; height: .8rem; flex: none; background: currentColor;
  -webkit-mask: var(--icon-tick) center / contain no-repeat; mask: var(--icon-tick) center / contain no-repeat;
}

/* the line under the wards when a section's problems are all solved */
.encounter-cue {
  margin: .6rem 0 0; padding-top: .55rem; border-top: 1px solid var(--border);
  font-size: .88rem; line-height: 1.45; color: var(--text);
}
.encounter-cue b { color: var(--part); font-weight: 700; }

/* cleared */
.practice[data-encounter="won"] .encounter { --edge: var(--ok-deep); border-color: var(--ok); }
.practice[data-encounter="won"] .encounter-status > b { min-width: 0; color: var(--ok); }
/* coming back to a cleared set: nothing left to act on, so the banner lies flat */
.encounter[data-revisit] { box-shadow: none; }
.encounter[data-medal="1"]::after, .encounter[data-medal="2"]::after, .encounter[data-medal="3"]::after {
  position: absolute; top: -.8rem; right: 1.1rem; padding: .2rem .6rem; border-radius: var(--radius-xs);
  font: 700 .72rem/1.3 var(--display); text-transform: uppercase; letter-spacing: .08em;
}
.encounter[data-medal="3"]::after { content: "Gold"; content: "Gold" / ""; background: var(--xp); color: var(--on-xp); border: 1px solid var(--xp-ink); }
.encounter[data-medal="2"]::after { content: "Silver"; content: "Silver" / ""; background: var(--surface-2); color: var(--text); border: 1px solid var(--line-ui); }
.encounter[data-medal="1"]::after { content: "Bronze"; content: "Bronze" / ""; background: var(--accent-2-soft); color: var(--accent-2); border: 1px solid var(--accent-2); }

@media (max-width: 480px) {
  .encounter { grid-template-columns: 3.75rem minmax(0, 1fr); gap: .8rem; padding: .95rem 1rem 1rem; }
}

/* zero hearts: calm advice, never a wall */
.encounter-regroup {
  margin: 1.4rem 0; padding: 1rem 1.2rem;
  background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--border));
  border-left: 4px solid var(--accent); border-radius: var(--radius-xs) var(--radius) var(--radius) var(--radius-xs);
  font-family: var(--sans); font-size: 1rem; line-height: 1.55; color: var(--text);
}
.encounter-regroup > :last-child { margin-bottom: 0; }
.encounter-regroup p { margin: 0 0 .5em; }
.encounter-regroup > p:first-child > b:first-child { font-family: var(--display); font-weight: 700; color: var(--accent); }
.encounter-regroup-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .7rem; margin: .9rem 0 0 !important; }
.encounter-regroup .tag, .encounter-regroup > strong:first-child, .encounter-regroup > b:first-child {
  display: block; margin-bottom: .3rem; color: var(--accent);
  font: 700 .74rem/1.3 var(--display); text-transform: uppercase; letter-spacing: .08em;
}

/* the finale, inside the practice set */
.encounter-result {
  margin: 2rem 0 0; padding: 1.4rem 1.4rem 1.5rem;
  background: var(--surface); border: 2px solid var(--ok); border-radius: var(--radius);
  font-family: var(--sans); font-size: .95rem;
}
.encounter-result > :last-child { margin-bottom: 0; }
.encounter-result :is(h2, h3, .encounter-title, .encounter-result-title) {
  margin: 0 0 .5rem; font: 800 clamp(1.4rem, 1.2rem + 1vw, 1.8rem)/1.1 var(--display); letter-spacing: -.01em;
}
.encounter-result h2::before { display: none; }
.encounter-result p { margin: 0 0 .7rem; }
.encounter-result ul { margin: 0 0 .9rem; padding-left: 1.2rem; }
.encounter-result-title b { font-weight: 800; }
.encounter-result-title:focus { outline: none; }
.encounter-result [data-skip] { margin: 0 0 .8rem; }
.encounter-medal { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .55rem; margin: 0 0 1rem; font-weight: 600; }
.encounter-medal .encounter-stars {
  font-family: var(--display); font-size: 1.5rem; line-height: 1; letter-spacing: .08em; color: var(--xp-ink);
}
.encounter-medal[data-medal="0"] .encounter-stars { display: none; }
.encounter-stars:has(i) { display: flex; gap: .3rem; }
.encounter-guess, .encounter-look { color: var(--text); }
.encounter-guess a, .encounter-look a { font-weight: 600; }
.encounter-ach::before {
  content: ""; display: inline-block; width: 1rem; height: 1rem; margin-right: .4rem; vertical-align: -.15em; background: var(--xp-ink);
  -webkit-mask: var(--icon-star) center / contain no-repeat; mask: var(--icon-star) center / contain no-repeat;
}
.encounter-medal i, .encounter-stars i {
  position: relative; display: block; width: 1.6rem; height: 1.6rem; background: var(--line-ui);
  -webkit-mask: var(--icon-star) center / contain no-repeat; mask: var(--icon-star) center / contain no-repeat;
}
/* gold is a fill with an ink outline */
.encounter-medal i[data-on], .encounter-stars i[data-on] { background: var(--xp-ink); }
.encounter-medal i[data-on]::after, .encounter-stars i[data-on]::after {
  content: ""; position: absolute; inset: 3px; background: var(--xp);
  -webkit-mask: var(--icon-star) center / contain no-repeat; mask: var(--icon-star) center / contain no-repeat;
}
.encounter-stats, .encounter-result .stats {
  display: grid; gap: .6rem; margin: 0 0 1rem; grid-template-columns: repeat(auto-fit, minmax(7.5rem, 1fr));
}
.encounter-result .stat {
  display: flex; flex-direction: column; gap: .1rem; padding: .75rem .9rem;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.encounter-result .stat > b {
  font: 800 1.6rem/1.1 var(--display); font-variant-numeric: tabular-nums; color: var(--text);
}
.encounter-result .stat > span {
  font: 700 .72rem/1.3 var(--display); text-transform: uppercase; letter-spacing: .08em; color: var(--muted);
}
.encounter-actions, .encounter-result .actions { display: flex; flex-wrap: wrap; gap: .7rem; margin: 1.1rem 0 0 !important; }
/* on a revisit, one line and no motion */
.encounter-result[data-revisit] { padding: .7rem 1rem; border-width: 1px; font-weight: 500; font-size: .9rem; }
.encounter-result[data-revisit] > p span[aria-hidden] { color: var(--xp-ink); letter-spacing: .05em; }
.encounter-result[data-revisit] > * { margin: 0; }

/* ------------------------------------------------------------ boss bar --- */
/* The fight in one line, fixed under the HUD while the set is in view and its card is not
   (assets/encounter.js). A dark frame surface; its classes are its own, outside the reading column. */

/* while the bar shows, the sticky sidebar and a top toast stack start below it (the bar sits under
   the top bar's stacking context, so the settings sheet paints over it) */
html[data-bossbar] .sidebar { top: calc(var(--hud-h) + 2.75rem + .5rem); max-height: calc(100vh - var(--hud-h) - 2.75rem - 1rem); }
html[data-bossbar] .toasts { top: calc(var(--hud-h) + 2.75rem + .75rem); }
.bossbar {
  position: fixed; top: var(--hud-h); left: 0; right: 0; z-index: 39; height: 2.75rem;
  background: var(--hud-bg); color: var(--hud-text); border-bottom: 1px solid var(--hud-line);
  font-family: var(--sans); font-size: .84rem; pointer-events: none;
}
.bossbar[hidden] { display: none; }
.bossbar-in {
  display: flex; align-items: center; gap: .75rem; height: 100%; max-width: 1180px; margin: 0 auto; padding: 0 1rem;
}
.bossbar-name { flex: none; max-width: 30%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--display); font-weight: 700; }
.bossbar-bar { display: flex; flex: 1 1 8rem; gap: 3px; height: .6rem; min-width: 5rem; }
.bossbar-seg { display: block; flex: 1 1 0; min-width: 3px; border-radius: 2px; background: var(--hud-track); }
.bossbar-seg[data-how="first"], .bossbar-seg[data-how="solved"] { background: var(--hud-ok); }
.bossbar-seg[data-how="opened"] { background: var(--hud-xp); }
.bossbar-seg[data-how="unknown"] { background: var(--hud-muted); }
.bossbar-hearts { display: inline-flex; flex: none; gap: 3px; color: var(--hud-heart); }
.bossbar-hearts i {
  display: block; width: 1.05rem; height: 1.05rem; background: currentColor;
  -webkit-mask: var(--icon-heart-o) center / contain no-repeat; mask: var(--icon-heart-o) center / contain no-repeat;
}
.bossbar-hearts i[data-full] { -webkit-mask-image: var(--icon-heart); mask-image: var(--icon-heart); }
.bossbar-say { flex: 0 1 auto; min-width: 0; max-width: 45%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--hud-muted); font-style: italic; }
.bossbar-say:empty { display: none; }
@media (max-width: 640px) { .bossbar[data-say] .bossbar-name { display: none; } .bossbar-say { max-width: none; } }

/* -------------------------------------------------------------- toasts --- */
/* toasts are ink cards, like the rail; game.js hides them from screen readers */

.toasts {
  position: fixed; top: calc(var(--hud-h) + .75rem); right: 1rem; left: auto; bottom: auto; z-index: 44;
  width: max-content; max-width: calc(100vw - 32px);
  display: flex; flex-direction: column; align-items: flex-end; gap: .5rem; pointer-events: none;
}
@media (max-width: 479px) {
  .toasts { left: 1rem; right: 1rem; width: auto; max-width: none; align-items: stretch; }
}
.toast {
  display: block; max-width: 100%;
  padding: .6rem 1.05rem; border-radius: var(--radius-sm);
  background: var(--hud-bg); color: var(--hud-text);
  border: 2px solid var(--hud-line); box-shadow: 0 4px 0 color-mix(in srgb, var(--hud-bg) 45%, var(--ink-shadow));
  font-family: var(--sans); font-size: .92rem; font-weight: 500; line-height: 1.35;
}
.toast b { font-family: var(--display); font-weight: 700; color: var(--hud-xp); font-variant-numeric: tabular-nums; }
.toast.goal { border-color: var(--hud-ok); }
.toast.goal b { color: var(--hud-ok); }
.toast-combo {
  display: inline-block; margin-left: .35rem; padding: .1rem .45rem; border-radius: var(--radius-xs); background: var(--hud-xp); color: var(--on-xp);
  font: 700 .78rem/1.3 var(--display); font-variant-numeric: tabular-nums; white-space: nowrap;
}
/* achievement and level cards: a badge, a title, a line */
/* achievement and level cards: a gold badge drawn beside kicker, title, line */
.toast.ach, .toast.level {
  display: grid; grid-template-columns: 3rem minmax(0, 1fr); column-gap: .8rem; align-items: start;
  max-width: min(26rem, 100%); padding: .75rem 1.05rem .75rem .75rem;
}
.toast.ach { border-color: var(--hud-xp); }
.toast.ach::before, .toast.level::before {
  content: ""; grid-column: 1; grid-row: 1 / span 4; width: 3rem; height: 3rem; align-self: center;
  border-radius: var(--radius-xs); background: var(--hud-xp);
  box-shadow: 0 3px 0 color-mix(in srgb, var(--hud-xp) 50%, var(--ink-shadow));
}
.toast.ach::after, .toast.level::after {
  content: ""; grid-column: 1; grid-row: 1 / span 4; justify-self: center; align-self: center;
  width: 1.6rem; height: 1.6rem; background: var(--on-xp);
  -webkit-mask: var(--icon-star) center / contain no-repeat; mask: var(--icon-star) center / contain no-repeat;
}
.toast.level::after { transform: rotate(-90deg); -webkit-mask-image: var(--icon-next); mask-image: var(--icon-next); }
.toast.ach > *, .toast.level > * { grid-column: 2; }
.toast-kicker { display: block; font: 700 .7rem/1.3 var(--display); text-transform: uppercase; letter-spacing: .08em; color: var(--hud-muted); }
.toast.ach > b, .toast.level > b, .toast-title { display: block; font: 700 1.05rem/1.25 var(--display); color: var(--hud-text); }
.toast-text, .toast-more { display: block; font-size: .84rem; color: var(--hud-muted); }
.toast-more { font-style: italic; }

/* ------------------------------------------------------------- effects --- */
/* BMFx.burst(el): twelve particles from the middle of the host; game.js sets each
   one's colour and throws it with the Web Animations API (skipped when still). */
.fx-burst { position: absolute; left: 50%; top: 50%; width: 0; height: 0; pointer-events: none; z-index: 2; }
.fx-burst i { position: absolute; left: 0; top: 0; width: 6px; height: 6px; border-radius: 1px; background: var(--part); }
.fx-burst i:nth-child(n + 13) { display: none; }
/* the chapter banner's own particles, animated by the motion block: at most twelve */

.burst { position: absolute; left: 50%; top: 50%; width: 0; height: 0; pointer-events: none; }
.burst i { position: absolute; width: 8px; height: 8px; border-radius: 2px; opacity: 0; background: var(--ok); }
.burst i:nth-child(n + 13) { display: none; }
.burst i:nth-child(3n) { background: var(--part); border-radius: 50%; }
.burst i:nth-child(3n + 1) { background: var(--accent); }

/* ------------------------------------------------------------ companion --- */
/* Mochi in a porthole (src/ui/companion.ts). .companion-pic keeps the box and the label. .companion-window fills
   it: the round opening with the pixel-art water strip (eight 64 px frames, stepped from JS, never a CSS
   animation), so the water draws at whole pixels, 2x at 8rem and 1x at 4rem; in it .companion-still (the pose
   sheet, nine squares side by side, so the inline background-size is 900% 100%) and the 3D canvas (src/mochi/)
   once it is ready, both smooth again (image-rendering inherits); the window's ::after is the glass, over the
   canvas on purpose so Mochi reads as in the water. The brass rim is the pic's ::after, a ring of inset shadows
   over the window's edge (--porthole-w wide). Sidebar scroll box on a wide screen, a small fixed figure with a
   bubble on a narrow one */

.companion { margin: 1rem 0 0; font-family: var(--sans); font-size: .82rem; line-height: 1.35; }
.companion-pic { display: block; position: relative; width: 8rem; height: 8rem; margin: 0 auto; --porthole-w: 8px; }
button.companion-pic { appearance: none; border: 0; padding: 0; background: none; font: inherit; color: inherit; cursor: pointer; border-radius: 50%; }
.companion-window {
  position: absolute; inset: 0; border-radius: 50%; overflow: hidden;
  background-repeat: no-repeat; background-size: 800% 100%; background-position: 0 0; image-rendering: pixelated;
  box-shadow: inset 0 2px 6px var(--water-vignette);
}
.companion-window::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%; pointer-events: none;
  background: linear-gradient(155deg, var(--porthole-glare), transparent 30%),
    radial-gradient(circle at 50% 50%, transparent 55%, var(--water-vignette) 100%), var(--water-tint);
}
/* the decor layer (public/models/mochi/decor.png, eight 32 px cells, tools/gen-water.js): a cell-sized box, half the
   window, so a cell draws at 2x at 8rem and 1x at 4rem; a later card places it, sets its background-image from
   JS as the water strip's is (a url() here would be rewritten by the build) and sets [data-decor] */
.companion-decor {
  display: none; position: absolute; width: 50%; height: 50%; pointer-events: none;
  background-repeat: no-repeat; background-size: 800% 100%; background-position: 0 0;
  image-rendering: pixelated;
}
.companion-decor[data-decor] { display: block; }
.companion-still { position: absolute; inset: 0; background-repeat: no-repeat; }
.companion-still, .companion-canvas { image-rendering: auto; }
/* the rim: a dark line, a light bevel, the brass, a deep bevel, a dark line, then the page shadow outside */
.companion-pic::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%; pointer-events: none;
  box-shadow: inset 0 0 0 1px var(--porthole-edge), inset 0 0 0 3px var(--porthole-rim-light),
    inset 0 0 0 calc(var(--porthole-w) - 1px) var(--porthole-rim), inset 0 0 0 var(--porthole-w) var(--porthole-rim-deep),
    inset 0 0 0 calc(var(--porthole-w) + 1px) var(--porthole-edge), 0 0 0 1px var(--porthole-edge), var(--shadow);
}
.companion-canvas { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; transition: opacity .4s; pointer-events: none; }
.companion[data-3d] .companion-canvas { opacity: 1; }
html[data-motion="reduce"] .companion-canvas { transition: none; }
.companion figcaption { display: block; text-align: center; color: var(--text); }
.companion-name { display: block; font-family: var(--display); font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.companion-line {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden;
}
.companion-line:empty { display: none; }
.companion-line a { color: var(--text); text-decoration: underline; }
/* in flow after the chapter's contents, never over them: the contents scroll inside the sidebar, the figure stays pinned under them */
@media (min-width: 1000px) {
  .companion { width: 11rem; max-width: 100%; margin-inline: auto; padding-block: .5rem; }
  .sidebar .companion { flex: none; }
}
@media (max-width: 999px) {
  .companion { position: fixed; right: max(12px, 4vw); bottom: 12px; z-index: 38; margin: 0; width: 4rem; }
  /* the picture is Mochi's button (it opens the pool) and takes the taps; the bubble keeps its link */
  .companion-pic { width: 4rem; height: 4rem; --porthole-w: 6px; }
  .companion-name { display: none; }
  .companion figcaption { position: absolute; right: 0; bottom: 100%; margin-bottom: .35rem; width: max-content; max-width: min(15rem, calc(100vw - 24px)); }
  .companion-line {
    padding: .45rem .7rem; text-align: left; background: var(--surface); color: var(--text);
    border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow);
  }
}
/* the Arena has no sidebar (arena.js marks its body data-mode="arena" once the generators are up): the same small docked figure at every width, and the page's own controls
   scroll to clear it (scroll-margin) rather than lie under it */
body[data-mode="arena"] .companion { position: fixed; right: max(12px, 4vw); bottom: 12px; z-index: 38; margin: 0; padding: 0; width: 4rem; max-width: none; }
body[data-mode="arena"] .companion-pic { width: 4rem; height: 4rem; --porthole-w: 6px; }
body[data-mode="arena"] .companion-name { display: none; }
body[data-mode="arena"] .companion figcaption { position: absolute; right: 0; bottom: 100%; margin-bottom: .35rem; width: max-content; max-width: min(15rem, calc(100vw - 24px)); }
body[data-mode="arena"] .companion-line { pointer-events: none;
  padding: .45rem .7rem; text-align: left; background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow);
}
body[data-mode="arena"] [data-arena] input, body[data-mode="arena"] [data-arena] button { scroll-margin-bottom: 7rem; }
body[data-mode="arena"] .wrap { padding-bottom: 6.5rem; }
html:has(#hud-sheet:modal) .companion { display: none; }
.companion[data-hidden] { display: none; }
@media (forced-colors: active) {
  button.companion-pic { border: 1px solid ButtonText; border-radius: 50%; }
  .companion-window { display: none; }
}
/* ------------------------------------------------------------------ pool --- */
/* Mochi's pool (src/ui/pet/pool.ts, the lazy chunk): a dialog (or the same shell inline) with a 20rem porthole built as the
   companion's is (the water strip is set from JS, the stage steps it), four rows of hearts, the facets line and Close.
   Nothing here animates; the stage is the only thing that moves, and it holds still under reduced motion. */
dialog.pet-dialog {
  width: min(28rem, calc(100vw - 32px)); max-width: 28rem; max-height: min(92vh, 48rem); overflow-y: auto;
  padding: 1rem 1.25rem 1.1rem; background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
dialog.pet-dialog::backdrop { background: var(--scrim-glass); }
.pet-pool { font-family: var(--sans); text-align: center; }
.pet-title { margin: 0 0 .75rem; font-size: 1.25rem; }
.pet-porthole { position: relative; width: min(20rem, 100%); aspect-ratio: 1; margin: 0 auto; --porthole-w: 14px; }
.pet-window {
  position: absolute; inset: 0; border-radius: 50%; overflow: hidden;
  background-repeat: no-repeat; background-size: 800% 100%; background-position: 0 0; image-rendering: pixelated;
  box-shadow: inset 0 2px 6px var(--water-vignette);
}
.pet-window::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%; pointer-events: none;
  background: linear-gradient(155deg, var(--porthole-glare), transparent 30%),
    radial-gradient(circle at 50% 50%, transparent 55%, var(--water-vignette) 100%), var(--water-tint);
}
.pet-porthole::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%; pointer-events: none;
  box-shadow: inset 0 0 0 1px var(--porthole-edge), inset 0 0 0 3px var(--porthole-rim-light),
    inset 0 0 0 calc(var(--porthole-w) - 1px) var(--porthole-rim), inset 0 0 0 var(--porthole-w) var(--porthole-rim-deep),
    inset 0 0 0 calc(var(--porthole-w) + 1px) var(--porthole-edge), 0 0 0 1px var(--porthole-edge), var(--shadow);
}
.pet-porthole[data-3d] .companion-canvas { opacity: 1; }
.pet-line { margin: .9rem 0 .6rem; font-size: .92rem; }
.pet-needs { list-style: none; margin: 0 0 .6rem; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(5.5rem, 1fr)); gap: .5rem; }
.pet-needs li { display: flex; flex-wrap: wrap; justify-content: center; gap: 2px; align-items: center; font-size: .8rem; }
.pet-need-name { flex-basis: 100%; font-weight: 700; color: var(--muted); }
.pet-needs i { display: inline-block; width: .7rem; height: .7rem; border-radius: 50%; background: var(--hud-track); }
.pet-needs i[data-on] { background: var(--hud-flame); }
.pet-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: .5rem; margin: 0 0 .75rem; }
.pet-porthole { cursor: pointer; }
.pet-facets { margin: 0 0 .9rem; font-size: .9rem; }
.pet-porthole:focus-visible { outline: var(--focus-width) solid var(--focus); outline-offset: var(--focus-offset); border-radius: 50%; }
.pet-line:focus { outline: none; }
.pet-actions [aria-disabled="true"] { opacity: .55; cursor: default; }
/* the pool and shop tabs, and the shop's rows (X-7); nothing here animates */
.pet-tabs { display: flex; flex-wrap: wrap; justify-content: center; gap: .25rem; margin: 0 0 .75rem; border-bottom: 1px solid var(--border); }
.pet-tab {
  font: inherit; font-weight: 700; padding: .4rem .75rem; background: transparent; color: var(--muted);
  border: 0; border-bottom: 3px solid transparent; cursor: pointer;
}
.pet-tab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
.pet-tab:focus-visible { outline: var(--focus-width) solid var(--focus); outline-offset: var(--focus-offset); }
.pet-panel[hidden] { display: none; }
.pet-group { margin: .9rem 0 .35rem; font-size: .95rem; text-align: left; }
.pet-items { list-style: none; margin: 0; padding: 0; }
.pet-item {
  display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: .25rem .75rem;
  padding: .35rem 0; border-bottom: 1px solid var(--border); text-align: left; font-size: .9rem;
}
.pet-item-name { font-weight: 700; }
.pet-item-price { color: var(--muted); font-size: .8rem; }
.pet-owned { color: var(--muted); font-weight: 700; font-size: .85rem; }
.pet-item .btn[hidden], .pet-owned[hidden] { display: none; }
.pet-item .btn:disabled { opacity: .55; }
.pet-item-note { grid-column: 1 / -1; color: var(--muted); font-size: .8rem; }
.pet-item-note[hidden] { display: none; }
/* the Wardrobe tab (X-7b-b): a fieldset per slot, a row of chips; the checked chip takes the accent border; nothing animates */
.pet-slots[hidden], .pet-wardrobe-empty[hidden] { display: none; }
.pet-slot { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; margin: .6rem 0; padding: 0; border: 0; text-align: left; }
.pet-slot legend { width: 100%; padding: 0; font-weight: 700; font-size: .9rem; }
/* every chip has the same border width so a change moves nothing; the checked one is told apart by colour and a double line,
   and beats .btn.ghost:hover (site.css) by being more specific */
.pet-slot .pet-wear { border-width: 3px; border-style: solid; border-color: var(--border); }
.pet-slot .pet-wear[aria-checked="true"], .pet-slot .pet-wear[aria-checked="true"]:hover { border-color: var(--accent); border-style: double; font-weight: 700; }
/* the Growth tab (X-8b): the stage, the five-step path and the 28-day calendar; nothing here animates */
.pet-growth-stage { margin: .5rem 0 .15rem; font-weight: 700; }
.pet-growth-next { margin: 0 0 .75rem; font-size: .9rem; color: var(--muted); }
.pet-path { list-style: none; margin: 0 0 .9rem; padding: 0; display: grid; grid-template-columns: repeat(5, 1fr); gap: .25rem; font-size: .8rem; }
.pet-path li { display: flex; flex-direction: column; align-items: center; gap: .1rem; padding: .35rem .1rem; color: var(--muted); border-top: 3px solid var(--hud-track); }
.pet-path li[data-reached] { color: var(--text); border-top-color: var(--accent); }
.pet-path li[aria-current="step"] { font-weight: 700; border-top-color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, var(--surface)); }
.pet-path-at { font-size: .72rem; }
.pet-days { list-style: none; margin: 0 0 .6rem; padding: 0; display: grid; grid-template-columns: repeat(7, 1fr); gap: .2rem; }
.pet-days li { aspect-ratio: 1; border-radius: var(--radius-sm); background: var(--hud-track); }
.pet-days li[data-points="1"] { background: color-mix(in srgb, var(--accent) 25%, var(--surface)); }
.pet-days li[data-points="2"] { background: color-mix(in srgb, var(--accent) 50%, var(--surface)); }
.pet-days li[data-points="3"] { background: color-mix(in srgb, var(--accent) 75%, var(--surface)); }
.pet-days li[data-points="4"] { background: var(--accent); }
@media (forced-colors: active) {
  .pet-days li { border: 1px solid CanvasText; background: Canvas; }
  .pet-days li:not([data-points="0"]) { background: Highlight; }
  .pet-path li[aria-current="step"] { text-decoration: underline; }
}
@media (forced-colors: active) {
  .pet-needs i { border: 1px solid CanvasText; background: Canvas; }
  .pet-needs i[data-on] { background: CanvasText; }
}
@media print { dialog.pet-dialog, #mochi { display: none; } }
/* the pool inline on the progress page (X-9): no dialog chrome, the porthole 16rem, centred */
#mochi .pet-pool { max-width: 32rem; margin: 0 auto; }
#mochi .pet-porthole { width: min(16rem, 100%); }
/* Mochi's still in the level popover (src/ui/hud-pop.ts): decorative, 4rem square */
.hud-pop .pop-mochi { position: relative; display: block; width: 4rem; height: 4rem; margin: 0 0 .4rem; background-repeat: no-repeat; image-rendering: auto; }
@media print { .pop-mochi { display: none; } }
@media (forced-colors: active) { .pop-mochi { display: none; } }
@media (forced-colors: active) { .pet-path li[data-reached] { border-top-style: double; } }
/* the dev-only QA panel (src/mochi/qa.ts, ?mochi=qa on a dev server) */
.companion-qa { position: fixed; left: 8px; bottom: 8px; z-index: 60; display: flex; flex-wrap: wrap; gap: 4px; max-width: 22rem; padding: 6px; font: .75rem var(--sans); background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.companion-qa button { font: inherit; padding: 2px 6px; }
.companion-qa output { flex-basis: 100%; }

/* ------------------------------------------------------- calm mode ------- */
/* one switch: no hearts, combo, sigil, taunt or reward chip; the encounter bar becomes a
   plain progress bar with its count written out; and no motion at all */

html[data-calm] .hud-combo, html[data-calm] .hud-hearts, html[data-calm] .encounter-hearts,
html[data-calm] .encounter-sigil, html[data-calm] .encounter-kicker, html[data-calm] .encounter-taunt,
html[data-calm] .ex-reward, html[data-calm] .encounter-status, html[data-calm] .encounter::after,
html[data-calm] .burst, html[data-calm] .fx-burst, html[data-calm] .fx-canvas, html[data-calm] .companion { display: none !important; }
html[data-calm] .encounter { grid-template-columns: minmax(0, 1fr); }
html[data-calm] .encounter-bar {
  gap: 0; height: .6rem; margin-bottom: 2rem; border-radius: var(--radius-pill); overflow: visible;
  background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line-ui);
}
html[data-calm] .encounter-seg { border-radius: 0; background: transparent; background-image: none; box-shadow: none; }
html[data-calm] .encounter-seg:not([data-how="open"]) { background: var(--ok); }
html[data-calm] .encounter-seg:first-child { border-radius: var(--radius-pill) 0 0 var(--radius-pill); }
html[data-calm] .encounter-seg:last-child { border-radius: 0 var(--radius-pill) var(--radius-pill) 0; }
html[data-calm] .encounter-bar::after {
  content: attr(aria-valuenow) " of " attr(aria-valuemax) " solved";
  content: attr(aria-valuenow) " of " attr(aria-valuemax) " solved" / "";
  position: absolute; left: 0; top: 100%; margin-top: .4rem;
  font-family: var(--sans); font-size: .88rem; font-weight: 600; color: var(--muted); white-space: nowrap;
}
html[data-calm], html[data-calm] *, html[data-calm] *::before, html[data-calm] *::after {
  transition: none !important; animation: none !important; scroll-behavior: auto !important;
}

/* ------------------------------------------------------- accessibility --- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0s !important; animation: none !important; }
}
html[data-motion="reduce"] *, html[data-motion="reduce"] *::before, html[data-motion="reduce"] *::after {
  transition-duration: 0s !important; animation: none !important;
}

@media (prefers-contrast: more) {
  .ex-hint { border-left-width: 6px; }
  .ex-hint[data-prev] { border-left-color: var(--text); }
  .banner-stat, .encounter-wards li, .encounter-result .stat { border-color: var(--text); }
  .hud-xptext, .hud-streak, .hud-facets, .toast-text { color: var(--hud-text); }
}
@media (forced-colors: active) {
  /* the count-up overlay cannot be drawn over transparent text here; the real number shows */
  [data-seq="play"] .bm-count { display: none; }
  .ex[data-state="correct"], .ex[data-state="wrong"], .encounter, .encounter-result, .encounter-regroup,
  .ex-hint, .banner-stat, .encounter-wards li, .toast, .hud-sheet, .hud-badge, .hud-timer {
    border-color: CanvasText; border-style: solid;
  }
  .ex[data-state="wrong"] { border-style: dashed; }
  .ex-hint { border-left-width: 6px; }
  /* every state icon keeps its shape */
  .choice:has(input:checked)::after, .hud-hearts i, .encounter-hearts i, .encounter-wards li[data-done="true"]::before,
  .encounter-sigil::after, .encounter-medal i, .encounter-stars i, .encounter-medal i::after, .encounter-stars i::after,
  .toast.ach::after, .toast.level::after, .encounter-ach::before,
  .ex[data-target="true"]::after {
    forced-color-adjust: none; background: CanvasText;
  }
  .hud-combo i { border-color: CanvasText; }
  .hud-combo i[data-on] { forced-color-adjust: none; background: CanvasText; }
  .bossbar { border-bottom-color: CanvasText; }
  .bossbar-seg { forced-color-adjust: none; background: Canvas; box-shadow: inset 0 0 0 1px CanvasText; }
  .bossbar-seg:not([data-how="open"]) { background: CanvasText; }
  .encounter-seg { forced-color-adjust: none; background: Canvas; box-shadow: inset 0 0 0 1px CanvasText; }
  .encounter-seg:not([data-how="open"]) { background: CanvasText; }
  .encounter-seg[data-how="solved"], .encounter-seg[data-how="opened"] {
    background-image: repeating-linear-gradient(135deg, transparent 0 3px, Canvas 3px 5px);
  }
  .hud-xpbar, .goal-ring { forced-color-adjust: none; background: Canvas; box-shadow: inset 0 0 0 1px CanvasText; }
  .hud-xpbar i { forced-color-adjust: none; background: CanvasText; }
  .ex[data-target="true"]::before, .encounter::after { border: 1px solid CanvasText; }
}

/* ---------------------------------------------------------------- print -- */

@media print {
  .hud, .hud-level, .hud-streak, .hud-facets, .hud-combo, .hud-hearts, .hud-timer, .hud-sheet, .hud-strip,
  .hud-sound, .hud-menu, .hud-tip, .hud-pop, .toasts, .ex-form .btn, .ex-reward, .ex-stamp, .s3d-canvas,
  .bossbar, .encounter-sigil, .encounter-kicker, .encounter-boss, .encounter-bar, .encounter-wards,
  .encounter-hearts, .encounter-regroup, .encounter-result .actions, .encounter-actions,
  .banner-meta:empty, .burst, .fx-burst, .fx-canvas, .companion { display: none !important; }
  /* the encounter shrinks to its one-line status */
  .encounter { display: block; padding: 0; margin: .4rem 0 1rem; border: 0; background: none; }
  .encounter::after { display: none; }
  .encounter-status { margin: 0; color: var(--text); }
  .banner-meta { padding: 0 0 .6rem; min-height: 0; }
  .banner-stat { background: none; border-color: var(--border-strong); }
  .ex-hint { background: none; }
  .ex[data-target="true"]::before, .ex[data-target="true"]::after { display: none; }
  .encounter-result { break-inside: avoid; }
}

/* ============================================================== motion === */
/* Every keyframe animation on the site, and the transitions that are motion rather
   than feedback, live in this one block. Reduced motion or calm mode: none of it runs.
   Nothing here lasts more than 900ms, and nothing loops. */

@media (prefers-reduced-motion: no-preference) {
  /* a correct answer: the card pops, the tick pops in, the stamp lands, the XP rises */
  html:not([data-calm]):not([data-motion="reduce"]) .ex[data-state="correct"]:not([data-restored]) { animation: pop 320ms var(--ease-spring); }
  html:not([data-calm]):not([data-motion="reduce"]) .ex[data-state="correct"]:not([data-restored]) .tick {
    animation: pop 320ms 100ms var(--ease-spring) both;
  }
  html:not([data-calm]):not([data-motion="reduce"]) .ex[data-state="correct"]:not([data-restored]) .ex-stamp { animation: stamp 280ms 120ms var(--ease-spring) both; }
  html:not([data-calm]):not([data-motion="reduce"]) .ex[data-state="correct"]:not([data-restored]) .ex-reward { animation: rise 600ms var(--ease-out) both; }

  /* a miss: the form nudges; the hint only fades in, it does not move */
  html:not([data-calm]):not([data-motion="reduce"]) .ex[data-state="wrong"] .ex-form { animation: nudge 240ms var(--ease-out); }
  html:not([data-calm]):not([data-motion="reduce"]) .ex[data-state="wrong"] .ex-hint:not([data-prev]) { animation: fade 160ms ease-out; }
  html:not([data-calm]):not([data-motion="reduce"]) .btn.ghost[data-suggested="true"] { animation: pop 320ms var(--ease-spring); }

  /* things that open */
  html:not([data-calm]):not([data-motion="reduce"]) .ex-solution[data-show="true"],
  html:not([data-calm]):not([data-motion="reduce"]) details.reveal[open] > :not(summary),
  html:not([data-calm]):not([data-motion="reduce"]) .step-in,
  html:not([data-calm]):not([data-motion="reduce"]) .hud-sheet,
  html:not([data-calm]):not([data-motion="reduce"]) .encounter-result:not([data-revisit]) { animation: reveal 220ms var(--ease-out) both; }
  html:not([data-calm]):not([data-motion="reduce"]) .encounter-regroup { animation: fade 220ms ease-out both; }
  /* the HUD chip fades in (src/ui/hud-pop.ts); it has no state of its own without this */
  html:not([data-calm]):not([data-motion="reduce"]) .hud-tip { opacity: 0; transition: opacity var(--dur-state) ease-out; }
  html:not([data-calm]):not([data-motion="reduce"]) .hud-tip[data-show] { opacity: 1; }
  html:not([data-calm]):not([data-motion="reduce"]) details.reveal > summary::after { transition: transform var(--t-2) var(--ease-out); }

  /* step-by-step reading: the bar pops once when Continue is ready */
  html:not([data-calm]):not([data-motion="reduce"]) .lesson-next[data-ready="true"] { animation: pop 320ms var(--ease-spring); }

  /* figures: missions, and handles that announce they can be moved */
  html:not([data-calm]):not([data-motion="reduce"]) .missions li[data-fresh] { animation: pop 320ms var(--ease-spring); }
  html:not([data-calm]):not([data-motion="reduce"]) .missions li[data-fresh] .mark { animation: stamp 280ms var(--ease-spring); }
  html:not([data-calm]):not([data-motion="reduce"]) .widget[data-inview] svg[tabindex] { animation: handle-pulse 800ms ease 2; }
  html:not([data-calm]):not([data-motion="reduce"]) .widget[data-inview] svg [tabindex] { animation: handle-dim 800ms ease 2; }
  html:not([data-calm]):not([data-motion="reduce"]) .widget[data-inview] input[type="range"] { animation: slider-nudge 800ms ease 1; }

  /* bars drain and fill; the XP bar only once the game layer has the HUD (.hud[data-live],
     game.js), so the fill the HUD script gave it before first paint is never played */
  html:not([data-calm]):not([data-motion="reduce"]) .hud[data-live] .hud-xpbar i,
  html:not([data-calm]):not([data-motion="reduce"]) .lesson-progress span,
  html:not([data-calm]):not([data-motion="reduce"]) .side-progress .bar span { transition: width 400ms var(--ease-out); }
  html:not([data-calm]):not([data-motion="reduce"]) .encounter-seg { transition: background-color var(--t-2); }
  html:not([data-calm]):not([data-motion="reduce"]) .encounter[data-hit] .encounter-sigil { animation: hit 360ms var(--ease-out); }
  html:not([data-calm]):not([data-motion="reduce"]) .sigil-face[data-fresh] { animation: face-break 600ms var(--ease-out); }
  html:not([data-calm]):not([data-motion="reduce"]) .encounter-wards li[data-fresh] { --mag: var(--mag-m); animation: pop 320ms var(--ease-spring); }
  html:not([data-calm]):not([data-motion="reduce"]) .encounter-cue:not([hidden]) { animation: fade 220ms ease-out; }
  html:not([data-calm]):not([data-motion="reduce"]) .bossbar[data-hit] .bossbar-name { animation: hit 360ms var(--ease-out); }
  html:not([data-calm]):not([data-motion="reduce"]) .bossbar-seg[data-fresh],
  html:not([data-calm]):not([data-motion="reduce"]) .encounter-seg[data-fresh],
  html:not([data-calm]):not([data-motion="reduce"]) [data-flash] { animation: flash 180ms ease-out; }
  html:not([data-calm]):not([data-motion="reduce"]) .hud-hearts i[data-break],
  html:not([data-calm]):not([data-motion="reduce"]) .encounter-hearts i[data-break],
  html:not([data-calm]):not([data-motion="reduce"]) .bossbar-hearts i[data-break] { animation: heart-break 360ms var(--ease-out); }

  /* the chapter's finish, the contents page, the progress page */
  html:not([data-calm]):not([data-motion="reduce"]) .burst i { --a: calc(var(--i, 0) * 30deg); animation: burst 800ms var(--ease-out) forwards; }
  html:not([data-calm]):not([data-motion="reduce"]) :not([data-map="3d"]) > .part .stop[data-state="current"] .stop-node { animation: here 700ms ease-in-out 3; }
  html:not([data-calm]):not([data-motion="reduce"]) .ring { animation: ring-in 600ms var(--ease-out) both; }

  /* the companion: the bubble arrives (a pose swap is a cut) */
  html:not([data-calm]):not([data-motion="reduce"]) .companion-line:not(:empty) { animation: fade 220ms ease-out both; }

  /* toasts */
  html:not([data-calm]):not([data-motion="reduce"]) .toast { animation: toast-in 280ms var(--ease-out) both; }
  html:not([data-calm]):not([data-motion="reduce"]) .toast[data-out] { animation: toast-out 280ms ease-in both; }
  /* the XP pill that flies from the solved card to the HUD bar (game.js flyXp; never made when still) */
  html:not([data-calm]):not([data-motion="reduce"]) .xp-fly {
    position: fixed; z-index: 44; margin: 0; pointer-events: none; transform-origin: center;
    padding: .15rem .55rem; border-radius: var(--radius-xs); background: var(--hud-xp); color: var(--on-xp);
    font: 700 .85rem/1.3 var(--display); font-variant-numeric: tabular-nums; white-space: nowrap;
  }

  /* a result screen's reveal (src/ui/results.ts): rows fade in one after another, the
     numbers count up under an aria-hidden overlay, the medal stamps once. The module sets
     data-seq only when motion is allowed and takes it off when the sequence ends or is
     skipped. The rows stay in the accessibility tree (opacity only) and the real numbers
     keep their width: the host's own text is transparent while the overlay draws over it. */
  [data-seq="play"] [data-step] { opacity: 0; animation: bm-seq-in var(--dur-reveal) var(--ease-out) var(--seq-delay, 0ms) both; }
  [data-seq="play"] [data-step][data-medal] {
    animation: bm-seq-in var(--dur-reveal) var(--ease-out) var(--seq-delay, 0ms) both, bm-seq-stamp 240ms ease-out 1;
    animation-delay: var(--seq-delay, 0ms), calc(var(--seq-delay, 0ms) + var(--dur-reveal));
  }
  [data-seq="play"] [data-counting] { position: relative; color: transparent; }
  [data-seq="play"] .bm-count { position: absolute; left: 0; top: 0; white-space: nowrap; font-variant-numeric: tabular-nums; }

  /* Between pages. Every navigation is a full page load; where the browser has
     cross-document view transitions (README, "Between pages"), every page opts in (the
     inline <style> tools/lib/shell.js writes after the boot script, under this same
     media rule) and the new page fades in under a top bar that does not move (and the
     HUD in it holds still: its order, tools/lib/shell.js hud()). Only the top bar is
     named, and the settings sheet while it hangs open from it: everything else is the
     root's snapshot, which is the viewport as the reader sees it, so a page left half-way
     down fades out where it was and nothing slides or stretches. The old page goes in --dur-state, eased in; the new one comes
     in --dur-reveal, eased out, laid over the old with plain alpha (the default
     plus-lighter would brighten the frame wherever two fades of different lengths do
     not sum to one), with the frame colour behind both. No group moves, and the top bar
     is the new page's at once. Study mode and Reduce motion skip the transition from the
     boot script (src/boot.js: pageswap, pagereveal), since an at-rule cannot read
     html[data-calm]. A navigation that takes more than four seconds skips the
     transition (Chrome's timeout), and the new page shows as it would have without one;
     nothing here holds the first paint back (no render-blocking), so a transition never
     makes a navigation wait. While it runs the page takes no click, the top bar's
     included (captured elements are not hit-tested), so the fades stay short: the
     transitions suite holds the longest to 250ms. */
  .topbar { view-transition-name: hud; }
  ::view-transition { background-color: var(--frame-bg); }
  ::view-transition-group(*) { animation: none; }
  ::view-transition-old(hud) { animation: none; opacity: 0; }
  ::view-transition-new(hud) { animation: none; }
  ::view-transition-old(root) { animation: fade-out var(--dur-state) var(--ease-in) both; mix-blend-mode: normal; }
  ::view-transition-new(root) { animation: fade var(--dur-reveal) var(--ease-out) both; mix-blend-mode: normal; }
  /* the sheet, open and not modal (a wide screen), hangs from the top bar and so would be
     in its capture, which is hidden at once: a link followed from it took the whole sheet
     away in one frame. Named while it is open, it fades out with the page from where it
     hung. Modal (a narrow screen), it is in the top layer, which is in the root's capture
     and fades with it already. The page arriving has it closed, so there is no new one. */
  .hud-sheet[open]:not(:modal) { view-transition-name: hud-sheet; }
  ::view-transition-old(hud-sheet) { animation: fade-out var(--dur-state) var(--ease-in) both; }

  /* how far it swells is the size of the event: --mag-s for an answer unless the rule
     says more (tokens.css, magnitude) */
  @keyframes pop { 0% { transform: scale(1); } 45% { transform: scale(var(--mag, var(--mag-s))); } 100% { transform: scale(1); } }
  @keyframes nudge {
    0%, 100% { transform: translateX(0); } 25% { transform: translateX(-4px); }
    55% { transform: translateX(4px); } 80% { transform: translateX(-2px); }
  }
  @keyframes bm-seq-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
  @keyframes bm-seq-stamp { 0%, 100% { transform: scale(1); } 50% { transform: scale(var(--mag-l)); } }
  @keyframes reveal { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
  @keyframes fade { from { opacity: 0; } to { opacity: 1; } }
  @keyframes fade-out { to { opacity: 0; } }
  @keyframes rise { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
  @keyframes stamp { 0% { opacity: 0; transform: scale(1.5) rotate(-8deg); } 100% { opacity: 1; transform: scale(1) rotate(-3deg); } }
  @keyframes flash { 0% { filter: brightness(1.35); } 100% { filter: none; } }
  @keyframes burst {
    0% { opacity: 1; transform: rotate(var(--a)) translateY(0) scale(1); }
    100% { opacity: 0; transform: rotate(var(--a)) translateY(-120px) scale(.4); }
  }
  @keyframes hit { 0%, 100% { transform: none; } 30% { transform: translateX(-3px) scale(.97); } 65% { transform: translateX(2px); } }
  @keyframes face-break { from { fill: var(--part); stroke-opacity: 1; } }
  @keyframes heart-break {
    0% { transform: scale(1.25); opacity: 1; } 40% { transform: scale(.85) rotate(-8deg); } 100% { transform: none; }
  }
  @keyframes handle-pulse { 0%, 100% { outline: 3px solid transparent; outline-offset: 4px; } 50% { outline: 3px solid var(--accent); outline-offset: 4px; } }
  @keyframes handle-dim { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }
  @keyframes slider-nudge { 0%, 100% { transform: translateX(0); } 30% { transform: translateX(5px); } 60% { transform: translateX(-3px); } }
  @keyframes ring-in { from { transform: scale(.5); opacity: 0; } to { transform: scale(1); opacity: 1; } }
  @keyframes here {
    0%, 100% { box-shadow: 0 0 0 6px var(--bg), 0 0 0 9px var(--part-soft); }
    50% { box-shadow: 0 0 0 6px var(--bg), 0 0 0 13px var(--part-soft); }
  }
  @keyframes toast-in { from { opacity: 0; transform: translateY(-12px); } to { opacity: 1; transform: none; } }
  @keyframes toast-out { to { opacity: 0; transform: translateY(8px); } }
}
