/* Nule's Workshop: class dashboard, variant D.
   Graphite chrome and white sheets carry the interface. Each module owns one colour, used only as a mark:
   its S-code chip, the step numbers, the timer bar and the progress map. No surface is ever filled with it.
   DESIGN.md explains the system; tools/palette.mjs generates the module colours. */

/* tokens:start */
:root {
  color-scheme: light;
  --canvas: #eceef2;      /* window ground: rail, docked panel, around the sheet */
  --sheet: #ffffff;       /* content surface */
  --raised: #f5f7fa;      /* cards and panels on the sheet */
  --sunk: #f1f2f6;        /* login art ground */
  --ink: #15171d;         /* text, primary buttons, selected states, focus ring */
  --ink-2: #575b63;       /* secondary text */
  --ink-3: #6e7279;       /* placeholders, on the sheet only */
  --line: #e1e3e7;        /* hairlines */
  --line-strong: #83868e; /* field, checkbox and chip borders */
  --danger: #be2323;
  --live: #d42325;        /* the live dot */
  --on-ink: #ffffff;      /* text on ink */
  --on-m: #ffffff;        /* text on a module mark */
  --fill-1: #f1f2f5;      /* quiet buttons, tracks */
  --fill-2: #e5e7eb;      /* their hover, empty bar segments */
  --hover: rgba(21, 23, 29, 0.055);
  --press: rgba(21, 23, 29, 0.1);
  --ink-hover: #2c2f37;
  --sheet-edge: rgba(21, 23, 29, 0.075);
  --sel: rgba(58, 111, 189, 0.22);
  --scrim: rgba(8, 9, 12, 0.42);
  --shadow-1: 0 1px 2px rgba(21, 23, 29, 0.07), 0 0 0 1px rgba(21, 23, 29, 0.05);
  --shadow-sheet: 0 1px 2px rgba(21, 23, 29, 0.05), 0 18px 44px -26px rgba(21, 23, 29, 0.32);
  --shadow-pop: 0 2px 6px rgba(21, 23, 29, 0.08), 0 18px 40px -12px rgba(21, 23, 29, 0.3);
  --shadow-bar: 0 10px 18px -16px rgba(21, 23, 29, 0.45);
  --tick: url("data:image/svg+xml,%3Csvg xmlns=%27http://www.w3.org/2000/svg%27 viewBox=%270 0 16 16%27%3E%3Cpath d=%27M3.6 8.3l2.9 2.9 5.9-6.2%27 fill=%27none%27 stroke=%27%23ffffff%27 stroke-width=%272.1%27 stroke-linecap=%27round%27 stroke-linejoin=%27round%27/%3E%3C/svg%3E");
  --chev: url("data:image/svg+xml,%3Csvg xmlns=%27http://www.w3.org/2000/svg%27 viewBox=%270 0 16 16%27%3E%3Cpath d=%27M4.5 6.5 8 10l3.5-3.5%27 fill=%27none%27 stroke=%27%23575b63%27 stroke-width=%271.6%27 stroke-linecap=%27round%27 stroke-linejoin=%27round%27/%3E%3C/svg%3E");
  /* Module marks. One lightness per role across all eight, hues 150 to 354 in OKLCH, no orange or yellow.
     mark: chips, emblem, bars, done cells; text: module-coloured text; soft: tint behind step numbers;
     ring: in-progress outline; sel: text selection. */
  /* S1 green */ --m1: #218543; --m1-text: #21763c; --m1-soft: #e9f7eb; --m1-ring: #3b9555; --m1-sel: #c3eac9;
  /* S2 teal */ --m2: #078370; --m2-text: #007463; --m2-soft: #e4f8f3; --m2-ring: #039580; --m2-sel: #b4ecde;
  /* S3 azure */ --m3: #067ba0; --m3-text: #066d8e; --m3-soft: #e4f6ff; --m3-ring: #068db6; --m3-sel: #b5e7fe;
  /* S4 blue */ --m4: #3a6fbd; --m4-text: #3463a6; --m4-soft: #ecf3fe; --m4-ring: #4c80cd; --m4-sel: #cbe0fe;
  /* S5 indigo */ --m5: #6862bb; --m5-text: #5c57a4; --m5-soft: #f1f1ff; --m5-ring: #7873ca; --m5-sel: #d9daff;
  /* S6 violet */ --m6: #8657ac; --m6-text: #764e97; --m6-soft: #f7efff; --m6-ring: #9669bb; --m6-sel: #e9d4fd;
  /* S7 magenta */ --m7: #9b4f95; --m7-text: #884783; --m7-soft: #fceefa; --m7-ring: #ab61a5; --m7-sel: #f6d0f1;
  /* S8 raspberry */ --m8: #aa4a75; --m8-text: #964268; --m8-soft: #ffeef4; --m8-ring: #ba5c85; --m8-sel: #fecfe1;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --canvas: #0b0c0f;
  --sheet: #141619;
  --raised: #1c1e22;
  --sunk: #0f1013;
  --ink: #eff0f3;
  --ink-2: #aeb1b8;
  --ink-3: #95989f;
  --line: #26282c;
  --line-strong: #696c72;
  --danger: #fb817a;
  --live: #fc5950;
  --on-ink: #141619;
  --on-m: #0e1015;
  --fill-1: #1f2125;
  --fill-2: #2a2c31;
  --hover: rgba(239, 240, 243, 0.07);
  --press: rgba(239, 240, 243, 0.12);
  --ink-hover: #d5d7dc;
  --sheet-edge: rgba(255, 255, 255, 0.075);
  --sel: rgba(134, 182, 253, 0.3);
  --scrim: rgba(0, 0, 0, 0.6);
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.06);
  --shadow-sheet: 0 0 0 1px rgba(255, 255, 255, 0.02), 0 24px 56px -28px rgba(0, 0, 0, 0.9);
  --shadow-pop: 0 0 0 1px rgba(255, 255, 255, 0.07), 0 20px 44px -12px rgba(0, 0, 0, 0.8);
  --shadow-bar: 0 12px 20px -16px rgba(0, 0, 0, 0.9);
  --tick: url("data:image/svg+xml,%3Csvg xmlns=%27http://www.w3.org/2000/svg%27 viewBox=%270 0 16 16%27%3E%3Cpath d=%27M3.6 8.3l2.9 2.9 5.9-6.2%27 fill=%27none%27 stroke=%27%23141619%27 stroke-width=%272.1%27 stroke-linecap=%27round%27 stroke-linejoin=%27round%27/%3E%3C/svg%3E");
  --chev: url("data:image/svg+xml,%3Csvg xmlns=%27http://www.w3.org/2000/svg%27 viewBox=%270 0 16 16%27%3E%3Cpath d=%27M4.5 6.5 8 10l3.5-3.5%27 fill=%27none%27 stroke=%27%23aeb1b8%27 stroke-width=%271.6%27 stroke-linecap=%27round%27 stroke-linejoin=%27round%27/%3E%3C/svg%3E");
  /* S1 green */ --m1: #7cc98d; --m1-text: #97d6a4; --m1-soft: #1b2c1f; --m1-ring: #69b27a; --m1-sel: #2f5838;
  /* S2 teal */ --m2: #51ccb4; --m2-text: #7bd9c4; --m2-soft: #132d28; --m2-ring: #3eb59e; --m2-sel: #13594d;
  /* S3 azure */ --m3: #58c2ee; --m3-text: #7ed1f5; --m3-soft: #142b35; --m3-ring: #46abd4; --m3-sel: #19546b;
  /* S4 blue */ --m4: #86b6fd; --m4-text: #a0c6fe; --m4-soft: #1d2838; --m4-ring: #73a0e2; --m4-sel: #344e73;
  /* S5 indigo */ --m5: #abaafb; --m5-text: #bcbcff; --m5-soft: #252538; --m5-ring: #9695e0; --m5-sel: #484772;
  /* S6 violet */ --m6: #c9a0ed; --m6-text: #d5b4f4; --m6-soft: #2c2335; --m6-ring: #b18bd3; --m6-sel: #58426b;
  /* S7 magenta */ --m7: #de99d7; --m7-text: #e8aee2; --m7-soft: #312230; --m7-ring: #c585bf; --m7-sel: #633f5f;
  /* S8 raspberry */ --m8: #ee95b9; --m8-text: #f6abc8; --m8-soft: #352129; --m8-ring: #d481a3; --m8-sel: #6b3c50;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --canvas: #0b0c0f;
    --sheet: #141619;
    --raised: #1c1e22;
    --sunk: #0f1013;
    --ink: #eff0f3;
    --ink-2: #aeb1b8;
    --ink-3: #95989f;
    --line: #26282c;
    --line-strong: #696c72;
    --danger: #fb817a;
    --live: #fc5950;
    --on-ink: #141619;
    --on-m: #0e1015;
    --fill-1: #1f2125;
    --fill-2: #2a2c31;
    --hover: rgba(239, 240, 243, 0.07);
    --press: rgba(239, 240, 243, 0.12);
    --ink-hover: #d5d7dc;
    --sheet-edge: rgba(255, 255, 255, 0.075);
    --sel: rgba(134, 182, 253, 0.3);
    --scrim: rgba(0, 0, 0, 0.6);
    --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.06);
    --shadow-sheet: 0 0 0 1px rgba(255, 255, 255, 0.02), 0 24px 56px -28px rgba(0, 0, 0, 0.9);
    --shadow-pop: 0 0 0 1px rgba(255, 255, 255, 0.07), 0 20px 44px -12px rgba(0, 0, 0, 0.8);
    --shadow-bar: 0 12px 20px -16px rgba(0, 0, 0, 0.9);
    --tick: url("data:image/svg+xml,%3Csvg xmlns=%27http://www.w3.org/2000/svg%27 viewBox=%270 0 16 16%27%3E%3Cpath d=%27M3.6 8.3l2.9 2.9 5.9-6.2%27 fill=%27none%27 stroke=%27%23141619%27 stroke-width=%272.1%27 stroke-linecap=%27round%27 stroke-linejoin=%27round%27/%3E%3C/svg%3E");
    --chev: url("data:image/svg+xml,%3Csvg xmlns=%27http://www.w3.org/2000/svg%27 viewBox=%270 0 16 16%27%3E%3Cpath d=%27M4.5 6.5 8 10l3.5-3.5%27 fill=%27none%27 stroke=%27%23aeb1b8%27 stroke-width=%271.6%27 stroke-linecap=%27round%27 stroke-linejoin=%27round%27/%3E%3C/svg%3E");
    /* S1 green */ --m1: #7cc98d; --m1-text: #97d6a4; --m1-soft: #1b2c1f; --m1-ring: #69b27a; --m1-sel: #2f5838;
    /* S2 teal */ --m2: #51ccb4; --m2-text: #7bd9c4; --m2-soft: #132d28; --m2-ring: #3eb59e; --m2-sel: #13594d;
    /* S3 azure */ --m3: #58c2ee; --m3-text: #7ed1f5; --m3-soft: #142b35; --m3-ring: #46abd4; --m3-sel: #19546b;
    /* S4 blue */ --m4: #86b6fd; --m4-text: #a0c6fe; --m4-soft: #1d2838; --m4-ring: #73a0e2; --m4-sel: #344e73;
    /* S5 indigo */ --m5: #abaafb; --m5-text: #bcbcff; --m5-soft: #252538; --m5-ring: #9695e0; --m5-sel: #484772;
    /* S6 violet */ --m6: #c9a0ed; --m6-text: #d5b4f4; --m6-soft: #2c2335; --m6-ring: #b18bd3; --m6-sel: #58426b;
    /* S7 magenta */ --m7: #de99d7; --m7-text: #e8aee2; --m7-soft: #312230; --m7-ring: #c585bf; --m7-sel: #633f5f;
    /* S8 raspberry */ --m8: #ee95b9; --m8-text: #f6abc8; --m8-soft: #352129; --m8-ring: #d481a3; --m8-sel: #6b3c50;
  }
}
/* tokens:end */

/* ---------- Non-colour tokens ---------- */
:root {
  --font: "Segoe UI Variable Text", system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  --font-display: "Segoe UI Variable Display", system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  --focus: var(--ink);
  --dir: 1; /* -1 in Hebrew: slide-in panels come from the other side */

  /* type roles (rem, so present mode scales the whole ramp) */
  --fs-xs: .75rem;      /* 12  counters, tiny meta */
  --fs-sm: .8125rem;    /* 13  meta, labels, chips */
  --fs-ui: .875rem;     /* 14  nav, buttons, fields */
  --fs-body: .9375rem;  /* 15  running text */
  --fs-read: 1rem;      /* 16  lesson steps, notes */
  --fs-lead: 1.0625rem; /* 17  module idea */
  --fs-h3: 1rem;        /* 16  group titles */
  --fs-h2: 1.1875rem;   /* 19  section titles */
  --fs-h1: 1.875rem;    /* 30  page titles */
  --fs-display: 2.5rem; /* 40  module title */

  /* spacing, 4px base */
  --s1: .25rem; --s2: .5rem; --s3: .75rem; --s4: 1rem; --s5: 1.25rem; --s6: 1.5rem; --s7: 2rem; --s8: 2.5rem; --s9: 3.5rem;

  /* radii: concentric, outer surfaces round more than what sits inside them */
  --r-xs: 6px; --r-sm: 9px; --r-md: 12px; --r-lg: 16px; --r-xl: 20px;

  --h-ctl: 2.25rem;     /* 36 control height on desktop */
  --h-sm: 1.875rem;     /* 30 small controls */
  --rail-w: 272px;      /* rail, open */
  --rail-min: 64px;     /* rail, collapsed to icons and module codes */
  --panel-w: 21rem;     /* docked class panel on the module page */
  --inset: 10px;
  --rail-cur: var(--rail-w);
  --pad: clamp(1.25rem, 3.2vw, 3rem); /* inline padding of everything on the sheet */
  --ease: cubic-bezier(.2, .8, .2, 1);
}
:root[dir="rtl"] { --dir: -1; }
:root[data-rail="closed"] { --rail-cur: var(--rail-min); }

/* Module context: any element with .mc-N speaks in that module's colour. */
.mc-1 { --m: var(--m1); --m-text: var(--m1-text); --m-soft: var(--m1-soft); --m-ring: var(--m1-ring); --m-sel: var(--m1-sel); }
.mc-2 { --m: var(--m2); --m-text: var(--m2-text); --m-soft: var(--m2-soft); --m-ring: var(--m2-ring); --m-sel: var(--m2-sel); }
.mc-3 { --m: var(--m3); --m-text: var(--m3-text); --m-soft: var(--m3-soft); --m-ring: var(--m3-ring); --m-sel: var(--m3-sel); }
.mc-4 { --m: var(--m4); --m-text: var(--m4-text); --m-soft: var(--m4-soft); --m-ring: var(--m4-ring); --m-sel: var(--m4-sel); }
.mc-5 { --m: var(--m5); --m-text: var(--m5-text); --m-soft: var(--m5-soft); --m-ring: var(--m5-ring); --m-sel: var(--m5-sel); }
.mc-6 { --m: var(--m6); --m-text: var(--m6-text); --m-soft: var(--m6-soft); --m-ring: var(--m6-ring); --m-sel: var(--m6-sel); }
.mc-7 { --m: var(--m7); --m-text: var(--m7-text); --m-soft: var(--m7-soft); --m-ring: var(--m7-ring); --m-sel: var(--m7-sel); }
.mc-8 { --m: var(--m8); --m-text: var(--m8-text); --m-soft: var(--m8-soft); --m-ring: var(--m8-ring); --m-sel: var(--m8-sel); }

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-block-start: calc(var(--inset) + 5rem); }
body {
  margin: 0; min-height: 100dvh; background: var(--canvas); color: var(--ink);
  font: 400 var(--fs-body)/1.55 var(--font); font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  font-synthesis-weight: none;
}
h1, h2, h3, h4, p, ol, ul, figure, dl, dd, blockquote, pre, fieldset { margin: 0; }
ol, ul { padding: 0; }
h1, h2, h3, h4 { font-family: var(--font-display); text-wrap: balance; }
p, li, dd { text-wrap: pretty; }
img, svg, video { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: .22em; text-decoration-color: var(--line-strong); }
a:hover { text-decoration-color: currentColor; }
::selection { background: var(--sel); color: var(--ink); }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr-only { position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.offscreen { position: fixed; inset-inline-start: -9999px; inset-block-start: 0; opacity: 0; }
.iso { unicode-bidi: isolate; }
.tnum { font-variant-numeric: tabular-nums; }
* { scrollbar-width: thin; scrollbar-color: var(--fill-2) transparent; }

.skip {
  position: fixed; z-index: 100; inset-inline-start: 12px; inset-block-start: 12px;
  padding: .5rem .875rem; border-radius: var(--r-sm); background: var(--ink); color: var(--on-ink);
  font-weight: 600; text-decoration: none; transform: translateY(-160%); transition: transform .15s var(--ease);
}
.skip:focus-visible { transform: none; }

/* Icons: authored 20px set, one stroke weight. Directional ones mirror in Hebrew. */
.i { width: 1.25em; height: 1.25em; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
[dir="rtl"] .i-dir { transform: scaleX(-1); }

/* ---------- App frame: rail on the canvas, content on an inset sheet, class panel docked on the far side ---------- */
.sheet { position: relative; display: block; min-height: 100dvh; background: var(--sheet); }
.sheet:focus { outline: none; }
.frame { display: none; }
.rail, .topbar, .tabbar { display: none; }
body { --end: var(--inset); }

@media (min-width: 900px) {
  .shell .rail {
    display: flex; flex-direction: column; position: fixed; z-index: 30;
    inset-block: 0; inset-inline-start: 0; inline-size: var(--rail-cur);
    padding-block: 14px 12px; padding-inline: 14px 10px; overflow: hidden;
  }
  .shell .sheet {
    margin-inline: var(--rail-cur) var(--end); margin-block: var(--inset);
    min-height: calc(100dvh - 2 * var(--inset)); border-radius: var(--r-xl);
  }
  /* Fixed mask: paints the canvas around a rounded window, so the sheet keeps its corners while the page scrolls under it. */
  .shell .frame {
    display: block; position: fixed; z-index: 20; pointer-events: none;
    inset-block: var(--inset); inset-inline-start: var(--rail-cur); inset-inline-end: var(--end);
    border-radius: var(--r-xl);
    box-shadow: inset 0 0 0 1px var(--sheet-edge), var(--shadow-sheet), 0 0 0 100vmax var(--canvas);
  }
  /* Only a person's own toggle animates the frame; page loads and route changes snap. */
  .frame-anim .shell .rail { transition: inline-size .26s var(--ease); }
  .frame-anim .shell .sheet { transition: margin .26s var(--ease); }
  .frame-anim .shell .frame { transition: inset-inline-start .26s var(--ease), inset-inline-end .26s var(--ease); }
}
@media (min-width: 1200px) {
  :root:not([data-panel="closed"]) body.has-side { --end: var(--panel-w); }
}

/* ---------- Rail ---------- */
.rail-top { display: flex; align-items: center; gap: 4px; }
.rail-top .brand { flex: 1 1 auto; min-width: 0; }
.rail-toggle { flex: none; color: var(--ink-2); }
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 6px 6px; padding-inline: 6px 8px; border-radius: var(--r-md); text-decoration: none; color: var(--ink); }
.brand:hover { background: var(--hover); }
.brand-text { display: grid; line-height: 1.2; min-width: 0; }
.brand-text b { font: 650 .9375rem/1.2 var(--font-display); letter-spacing: -.012em; white-space: nowrap; }
.brand-text small { font-size: var(--fs-sm); color: var(--ink-2); white-space: nowrap; }
.wheel { width: 30px; height: 30px; flex: none; }
.wheel path { fill: none; stroke-width: 5.2; }
.wheel .w1 { stroke: var(--m1); } .wheel .w2 { stroke: var(--m2); } .wheel .w3 { stroke: var(--m3); } .wheel .w4 { stroke: var(--m4); }
.wheel .w5 { stroke: var(--m5); } .wheel .w6 { stroke: var(--m6); } .wheel .w7 { stroke: var(--m7); } .wheel .w8 { stroke: var(--m8); }

.nav { display: grid; gap: 2px; margin-top: 16px; }
.nav a {
  display: flex; align-items: center; gap: 11px; min-height: 36px; padding: 0 10px; border-radius: var(--r-sm);
  color: var(--ink-2); font-size: var(--fs-ui); font-weight: 560; text-decoration: none; white-space: nowrap;
  transition: background-color .12s, color .12s;
}
.nav a .i { width: 18px; height: 18px; }
.nav a:hover { background: var(--hover); color: var(--ink); }
.nav a[aria-current="page"] { background: var(--sheet); color: var(--ink); box-shadow: var(--shadow-1); }

.rail-mods { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; margin-top: 22px; }
.rail-h { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding: 0 10px 6px; font: 600 var(--fs-sm)/1.3 var(--font); color: var(--ink-2); }
.rail-h span { font-weight: 500; font-variant-numeric: tabular-nums; }
.mod-list { list-style: none; flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 2px 2px 10px; margin: 0 -2px; }
.rail .mod-list.more-below { mask-image: linear-gradient(to bottom, #000 calc(100% - 36px), transparent); }
.rail .mod-list.more-above { mask-image: linear-gradient(to bottom, transparent, #000 28px); }
.rail .mod-list.more-above.more-below { mask-image: linear-gradient(to bottom, transparent, #000 28px, #000 calc(100% - 36px), transparent); }
/* Code chip, title and count share one baseline, so they line up in every script and on two-line titles. */
.mod-row {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: baseline; column-gap: 10px;
  padding: 7px 8px; border-radius: var(--r-sm); text-decoration: none; color: var(--ink);
  font-size: .84375rem; font-weight: 500; line-height: 1.32; transition: background-color .12s;
}
.mod-row:hover { background: var(--hover); }
.mod-row[aria-current="page"] { background: var(--sheet); box-shadow: var(--shadow-1); }
.mod-row .t { overflow-wrap: anywhere; }
.mod-row .end { display: inline-flex; align-items: center; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.mod-row .end::before { content: "\200b"; } /* a text baseline for an icon-only end */
.mod-row .end .i { width: 16px; height: 16px; }

/* Module code chip: outlined until started, ringed in progress, solid when done. */
.mchip {
  display: inline-grid; place-items: center; min-inline-size: 1.75rem; block-size: 1.375rem; padding-inline: 4px; flex: none; border-radius: 7px;
  font: 700 .71875rem/1 var(--font); letter-spacing: .02em; font-variant-numeric: tabular-nums; color: var(--ink-2);
  box-shadow: inset 0 0 0 1.5px var(--line-strong); transition: background-color .45s var(--ease), box-shadow .45s var(--ease), color .45s;
}
.mchip.s-in_progress { background: var(--m-soft); color: var(--m-text); box-shadow: inset 0 0 0 1.5px var(--m-ring); }
.mchip.s-done, .mchip.s-mark { background: var(--m); color: var(--on-m); box-shadow: none; }
.mchip.s-all { background: var(--m-soft); color: var(--m-text); box-shadow: none; }

.rail-foot { display: grid; gap: 10px; padding: 12px 6px 2px; border-top: 1px solid var(--line); margin-top: 6px; }
.me { display: flex; align-items: center; gap: 10px; min-width: 0; }
.me-name { flex: 1; min-width: 0; display: grid; line-height: 1.25; }
.me-name b { font-size: var(--fs-ui); font-weight: 620; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-name small { font-size: var(--fs-xs); color: var(--ink-2); }
.prefs { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.me-btn { display: none; place-items: center; inline-size: 40px; block-size: 40px; margin-inline: auto; padding: 0; border: 0; border-radius: var(--r-md); background: none; }
.me-btn:hover { background: var(--hover); }

/* Collapsed rail: brand mark, icons and the eight module codes. Labels stay readable to screen readers. */
@media (min-width: 900px) {
  :root[data-rail="closed"] .rail { padding-inline: 10px; }
  :root[data-rail="closed"] .rail-top { flex-direction: column; gap: 6px; }
  :root[data-rail="closed"] .rail-top .brand { flex: none; padding: 6px; }
  :root[data-rail="closed"] .rail .brand-text,
  :root[data-rail="closed"] .rail .nav a span,
  :root[data-rail="closed"] .rail .rail-h,
  :root[data-rail="closed"] .rail .mod-row .t,
  :root[data-rail="closed"] .rail .mod-row .end {
    position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0;
  }
  :root[data-rail="closed"] .rail .nav { margin-top: 10px; justify-items: center; }
  :root[data-rail="closed"] .rail .nav a { inline-size: 40px; padding: 0; justify-content: center; }
  :root[data-rail="closed"] .rail .rail-mods { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
  :root[data-rail="closed"] .rail .mod-row { grid-template-columns: auto; justify-content: center; padding: 6px 0; }
  :root[data-rail="closed"] .rail .mod-row .mchip { min-inline-size: 2rem; block-size: 1.625rem; border-radius: 8px; }
  :root[data-rail="closed"] .rail .rail-foot { padding-inline: 0; }
  :root[data-rail="closed"] .rail .rail-foot .me,
  :root[data-rail="closed"] .rail .rail-foot .prefs { display: none; }
  :root[data-rail="closed"] .rail .rail-foot .me-btn { display: grid; }
}

/* ---------- Mobile shell: top bar + bottom tab bar ---------- */
@media (max-width: 899.98px) {
  .shell { background: var(--sheet); }
  .shell .topbar {
    display: flex; align-items: center; justify-content: space-between; gap: 12px; position: sticky; top: 0; z-index: 40;
    min-height: calc(56px + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 12px 0 10px; padding-inline: 10px 12px;
    background: var(--sheet); border-bottom: 1px solid var(--line);
  }
  .shell .tabbar {
    display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; position: fixed; z-index: 40; inset-inline: 0; inset-block-end: 0;
    padding: 4px 4px env(safe-area-inset-bottom); background: var(--sheet); border-top: 1px solid var(--line);
  }
  .shell .sheet { padding-bottom: calc(68px + env(safe-area-inset-bottom)); min-height: calc(100dvh - 56px); }
  html { scroll-padding-block-start: 128px; }
}
/* The top bar's left slot holds the brand, or the module's code and title once its cover has scrolled away. */
.tb-slot { display: grid; flex: 1 1 auto; min-width: 0; }
.tb-slot > * { grid-area: 1 / 1; transition: opacity .2s, translate .26s var(--ease); }
.tb-id { display: flex; align-items: center; gap: 10px; min-width: 0; padding-inline-start: 6px; opacity: 0; translate: 0 6px; pointer-events: none; }
.tb-id b { font: 650 var(--fs-ui)/1.25 var(--font-display); overflow-wrap: anywhere; }
.tb-id .status { flex: none; }
.tb-id .status .lbl { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
body.mod-stuck .tb-id { opacity: 1; translate: 0 0; }
body.mod-stuck .topbar .brand { opacity: 0; translate: 0 -6px; pointer-events: none; }
.topbar .brand { padding-inline-end: 6px; justify-self: start; }
.topbar .brand-text small { display: none; }
.tabbar a, .tabbar button {
  display: grid; justify-items: center; align-content: center; gap: 3px; min-height: 54px; padding: 4px 2px;
  border: 0; background: none; color: var(--ink-2); text-decoration: none; font-size: .6875rem; font-weight: 600; line-height: 1.15; text-align: center;
  border-radius: var(--r-md); -webkit-tap-highlight-color: transparent;
}
.tabbar .i { width: 23px; height: 23px; }
.tabbar [aria-current="page"] { color: var(--ink); }
.tabbar [aria-current="page"] .i { stroke-width: 2; }
.tabbar span { max-width: 100%; overflow-wrap: anywhere; }

/* Drawer: a bottom sheet on phones for the module list and settings; a small card beside a collapsed rail. */
.drawer {
  inline-size: 100%; max-inline-size: 100%; max-block-size: min(86dvh, 720px); margin: auto 0 0; padding: 0;
  border: 0; border-radius: 22px 22px 0 0; background: var(--sheet); color: var(--ink); box-shadow: var(--shadow-pop);
}
.drawer::backdrop { background: var(--scrim); }
.drawer[open] { animation: drawer-in .26s var(--ease); }
@keyframes drawer-in { from { transform: translateY(24px); opacity: .4; } }
.drawer.pop { inline-size: 18.5rem; max-block-size: calc(100dvh - 24px); margin-block: auto 12px; margin-inline: calc(var(--rail-cur) + 6px) auto; border-radius: var(--r-lg); }
.drawer.pop::backdrop { background: transparent; }
.drawer.pop[open] { animation: pop-in .18s var(--ease); }
@keyframes pop-in { from { transform: translateY(6px); opacity: 0; } }
.drawer-head { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-block: 14px 10px; padding-inline: 20px 12px; background: var(--sheet); }
.drawer-head h2 { font-size: 1.0625rem; font-weight: 650; }
.drawer-body { padding: 0 12px calc(20px + env(safe-area-inset-bottom)); }
.drawer.pop .drawer-body { padding-bottom: 14px; }
.drawer .mod-list { overflow: visible; }
.drawer .mod-row { font-size: var(--fs-read); padding: 10px 10px; }
.drawer .settings { display: grid; gap: 18px; padding: 4px 8px 8px; }
.drawer .settings .row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.drawer .settings .row > span { font-weight: 560; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: var(--h-ctl); padding: 0 14px;
  border: 0; border-radius: 10px; background: var(--fill-1); color: var(--ink);
  font-size: var(--fs-ui); font-weight: 600; line-height: 1.1; text-decoration: none; white-space: nowrap;
  transition: background-color .14s, color .14s, box-shadow .14s, transform .1s;
}
.btn:hover { background: var(--fill-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: default; transform: none; }
.btn .i { width: 18px; height: 18px; }
.btn-primary { background: var(--ink); color: var(--on-ink); }
.btn-primary:hover { background: var(--ink-hover); }
.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--hover); color: var(--ink); }
.btn-danger { background: transparent; color: var(--danger); }
.btn-danger:hover { background: var(--hover); }
.btn.is-armed, .btn.is-armed:hover { background: var(--danger); color: var(--sheet); }
.btn-sm { min-height: var(--h-sm); padding: 0 10px; font-size: var(--fs-sm); border-radius: 8px; gap: 6px; }
.btn-sm .i { width: 16px; height: 16px; }
.btn-icon { padding: 0; inline-size: var(--h-ctl); }
.btn-icon.btn-sm { inline-size: var(--h-sm); }
.btn-lg { min-height: 2.75rem; padding: 0 18px; font-size: var(--fs-body); border-radius: 12px; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.link-btn { display: inline-flex; align-items: center; gap: 6px; padding: 0; border: 0; background: none; color: var(--ink); font-weight: 600; font-size: var(--fs-ui); text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: .24em; }
.link-btn:hover { text-decoration-color: currentColor; }
.link-btn .i { width: 16px; height: 16px; }

/* Segmented control: language, theme, override status. The selected segment is ink, so its state reads at a glance. */
.seg { display: inline-flex; align-items: center; gap: 2px; padding: 3px; border-radius: 10px; background: var(--fill-1); }
.rail .seg { background: var(--hover); }
.seg button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 28px; min-width: 34px; padding: 0 9px;
  border: 0; border-radius: 7px; background: transparent; color: var(--ink-2); font-size: var(--fs-sm); font-weight: 650; line-height: 1;
  transition: background-color .14s, color .14s;
}
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--on-ink); }
.seg button .i { width: 16px; height: 16px; }

/* ---------- Fields ---------- */
.field { display: grid; gap: 6px; min-width: 0; align-content: start; }
.field > label, .legend { font-size: var(--fs-sm); font-weight: 600; color: var(--ink-2); }
.input, .select, textarea.input {
  inline-size: 100%; min-height: var(--h-ctl); padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 10px;
  background-color: var(--sheet); color: var(--ink); font-size: var(--fs-ui); line-height: 1.4;
  transition: border-color .14s, box-shadow .14s;
}
.input::placeholder, textarea::placeholder { color: var(--ink-3); opacity: 1; }
.input:hover, .select:hover { border-color: var(--ink-2); }
.input:focus-visible, .select:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; border-color: var(--ink); }
textarea.input { padding: 10px 12px; line-height: 1.55; resize: vertical; min-height: 6.5rem; font-size: var(--fs-body); }
.select { appearance: none; padding-inline-end: 34px; background-image: var(--chev); background-repeat: no-repeat; background-size: 16px; background-position: right 10px center; }
[dir="rtl"] .select { background-position: left 10px center; }
input[type="date"].input, input[type="time"].input { padding-block: 0; }
.hint { font-size: var(--fs-sm); color: var(--ink-2); line-height: 1.45; }
.hw-hint { margin-top: 10px; }
.thread-hint { margin: -6px 0 var(--s4); max-inline-size: 62ch; }
.save-state { color: var(--ink-2); font-variant-numeric: tabular-nums; }
.save-state.err, .err { color: var(--danger); }

input[type="checkbox"] {
  appearance: none; -webkit-appearance: none; inline-size: 20px; block-size: 20px; margin: 0; flex: none;
  border: 1.5px solid var(--line-strong); border-radius: 6px; background: var(--sheet) center / 14px no-repeat;
  transition: background-color .14s, border-color .14s, transform .1s;
}
input[type="checkbox"]:hover { border-color: var(--ink-2); }
input[type="checkbox"]:checked { background-color: var(--ink); border-color: var(--ink); background-image: var(--tick); animation: tick .22s var(--ease); }
input[type="checkbox"]:active { transform: scale(.92); }
@keyframes tick { from { background-size: 4px; } }

.check-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.check-chip { display: inline-flex; align-items: center; gap: 8px; min-height: var(--h-ctl); padding: 0 12px 0 10px; padding-inline: 10px 12px; border-radius: 10px; background: var(--fill-1); font-size: var(--fs-ui); font-weight: 560; cursor: pointer; }
fieldset { border: 0; padding: 0; min-width: 0; }
legend { padding: 0; margin-bottom: 6px; }

/* ---------- Small parts ---------- */
.status { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-sm); font-weight: 600; color: var(--ink-2); white-space: nowrap; }
.status .i { width: 16px; height: 16px; }
.status.st-done, .status.st-in_progress { color: var(--ink); }
.st-icon-done { fill: currentColor; stroke: none; }
.st-icon-done + path { stroke: var(--sheet); stroke-width: 1.9; }

/* A module reference: its code chip, then its title. */
.mtag { display: inline-flex; align-items: baseline; gap: 8px; min-width: 0; color: var(--ink); font-weight: 600; text-decoration: none; }
.mtag .mchip { min-inline-size: 1.625rem; block-size: 1.25rem; border-radius: 6px; font-size: .6875rem; }
.mtag:hover .mtag-t { text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: .22em; }
.mtag-t { overflow-wrap: anywhere; }

.av { display: inline-grid; place-items: center; inline-size: 30px; block-size: 30px; flex: none; border-radius: 9px; background: var(--fill-2); color: var(--ink); font: 700 .75rem/1 var(--font); letter-spacing: .01em; }
.av.t { background: var(--ink); color: var(--on-ink); }
.av-lg { inline-size: 44px; block-size: 44px; border-radius: 13px; font-size: .9375rem; }
.av-stack { display: inline-flex; }
.av-stack .av { inline-size: 26px; block-size: 26px; border-radius: 8px; font-size: .6875rem; box-shadow: 0 0 0 2px var(--av-ring, var(--sheet)); }
.av-stack .av + .av { margin-inline-start: -5px; }

.tag { display: inline-flex; align-items: center; min-height: 22px; padding: 0 8px; border-radius: 6px; background: var(--fill-1); color: var(--ink-2); font-size: var(--fs-xs); font-weight: 650; white-space: nowrap; }
.tag-draft { background: var(--ink); color: var(--on-ink); }

.empty { display: flex; align-items: center; gap: 12px; padding: 16px 18px; border: 1px dashed var(--line-strong); border-radius: var(--r-lg); color: var(--ink-2); font-size: var(--fs-body); }
.empty .i { width: 20px; height: 20px; }
.banner { padding: 12px 16px; border-radius: var(--r-md); background: var(--fill-1); color: var(--danger); font-weight: 560; }
.meta { font-size: var(--fs-sm); color: var(--ink-2); }
.dotsep { color: var(--line-strong); padding-inline: 6px; }

/* ---------- Page scaffolding inside the sheet ---------- */
.view { padding: var(--s8) var(--pad) var(--s9); max-inline-size: 1440px; animation: view-in .22s var(--ease); }
@keyframes view-in { from { opacity: 0; transform: translateY(6px); } }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 24px; margin-bottom: var(--s7); }
.page-head h1 { font-size: var(--fs-h1); font-weight: 700; line-height: 1.12; letter-spacing: -.024em; }
.page-head .sub { margin-top: 6px; color: var(--ink-2); max-width: 62ch; }
.back { display: inline-flex; align-items: center; gap: 6px; margin-bottom: 14px; color: var(--ink-2); font-size: var(--fs-sm); font-weight: 600; text-decoration: none; }
.back:hover { color: var(--ink); }
.back .i { width: 16px; height: 16px; }
.sec + .sec { margin-top: var(--s8); }
.sec-h { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 6px 16px; margin-bottom: var(--s4); }
.sec-h h2 { font-size: var(--fs-h2); font-weight: 660; letter-spacing: -.012em; line-height: 1.25; }
.sec-h p { color: var(--ink-2); font-size: var(--fs-sm); }
.panel { background: var(--raised); border-radius: var(--r-lg); padding: var(--s5); }

.mod-page ::selection, .class-page ::selection, .side ::selection { background: var(--m-sel); color: var(--ink); }
.mod-page textarea, .class-page textarea, .side textarea { caret-color: var(--m-text); }

/* ---------- Home ---------- */
.home-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 18px 32px; margin-bottom: var(--s6); }
.home-head h1 { font-size: 2.125rem; font-weight: 720; letter-spacing: -.03em; line-height: 1.08; }
.home-head .sub { margin-top: 8px; color: var(--ink-2); font-size: var(--fs-read); }
.where { display: grid; gap: 8px; inline-size: min(100%, 400px); }
.where-top { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; font-size: var(--fs-sm); color: var(--ink-2); font-weight: 600; }
.where-top b { color: var(--ink); font-weight: 650; }
/* The course strip: eight codes, solid where the module is done. */
.spectrum { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 4px; }
.spectrum a { position: relative; display: block; block-size: 30px; border-radius: 7px; background: var(--fill-1); overflow: hidden; text-decoration: none; transition: background-color .45s var(--ease); }
.spectrum a i { position: absolute; inset-block-end: 0; inset-inline-start: 0; block-size: 3px; inline-size: 0; background: var(--m-ring); transition: inline-size .5s var(--ease); }
.spectrum a.s-done { background: var(--m); }
.spectrum a.s-done i { display: none; }
.spectrum a span { position: relative; display: grid; place-items: center; block-size: 100%; font: 700 .71875rem/1 var(--font); letter-spacing: .02em; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.spectrum a.s-done span { color: var(--on-m); }
.spectrum a.s-in_progress { background: var(--m-soft); }
.spectrum a.s-in_progress span { color: var(--m-text); }
.spectrum a.is-here { outline: 2px solid var(--ink); outline-offset: 2px; }
.spectrum a:hover { filter: brightness(.97); }

.home-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: 16px; align-items: stretch; }
/* The current module: a calm card that leads with the code emblem, the way the module page does. */
.home-cover { display: flex; flex-direction: column; min-height: 22rem; padding: clamp(1.5rem, 2.6vw, 2.25rem); border-radius: var(--r-xl); background: var(--raised); color: var(--ink); }
.home-cover .emblem { inline-size: 3rem; block-size: 3rem; border-radius: 14px; font-size: 1.125rem; }
.home-cover .cover-title { margin-top: var(--s5); font: 720 2.375rem/1.06 var(--font-display); letter-spacing: -.032em; max-inline-size: 16ch; }
.home-cover .lead { margin-top: var(--s3); max-inline-size: 48ch; font-size: var(--fs-read); line-height: 1.55; color: var(--ink-2); }
.home-cover .cover-meta { margin-top: var(--s4); }
.home-cover .grow { flex: 1; min-height: var(--s5); }
.home-cover .actions { margin-top: var(--s5); }
.home-cover .btn:not(.btn-primary) { background: var(--sheet); box-shadow: var(--shadow-1); }
.home-cover .btn:not(.btn-primary):hover { background: var(--fill-1); }
.cover-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; font-size: var(--fs-sm); font-weight: 600; color: var(--ink-2); }
.cover-meta a { color: var(--ink); }
.cover-meta a .i { display: inline; vertical-align: -.25em; width: 16px; height: 16px; margin-inline-end: 4px; }

.next { display: flex; flex-direction: column; gap: 4px; background: var(--raised); border-radius: var(--r-xl); padding: var(--s6); }
.next h2 { font-size: var(--fs-sm); font-weight: 650; color: var(--ink-2); font-family: var(--font); margin-bottom: var(--s3); }
.next .wday { font-size: var(--fs-read); font-weight: 600; color: var(--ink-2); }
.next .day { font: 720 2.75rem/1 var(--font-display); letter-spacing: -.035em; font-variant-numeric: tabular-nums; }
.next .when { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; margin-top: 8px; font-size: var(--fs-read); font-weight: 600; }
.next .when .rel { padding: 2px 8px; border-radius: 6px; background: var(--m-soft); color: var(--m-text); font-size: var(--fs-sm); font-weight: 650; }
.next .grow { flex: 1; min-height: var(--s5); }
.next-mod { padding-block: var(--s3); border-block: 1px solid var(--line); display: grid; gap: 10px; margin-top: var(--s4); }
.next-who { display: flex; align-items: center; gap: 10px; font-size: var(--fs-sm); color: var(--ink-2); }
.next .actions { margin-top: var(--s4); }
.next .btn { background: var(--sheet); box-shadow: var(--shadow-1); }
.next-none { color: var(--ink-2); }

.home-lower { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: 16px 40px; margin-top: var(--s8); }
.todo-mod + .todo-mod { margin-top: var(--s5); }
.todo-mod h3 { display: flex; align-items: center; gap: 10px; font-size: var(--fs-ui); font-weight: 650; margin-bottom: 6px; }
.last { display: grid; gap: 8px; }
.last-card { display: grid; gap: 10px; padding: var(--s5); border-radius: var(--r-lg); background: var(--raised); text-decoration: none; color: inherit; }
.last-card .d { font-weight: 650; font-size: var(--fs-read); }
.course-list-mobile { display: none; }

/* ---------- Checklist (homework) ---------- */
.checklist { list-style: none; display: grid; gap: 2px; }
.checklist label { display: grid; grid-template-columns: 20px minmax(0, 1fr); gap: 12px; align-items: start; padding: 10px 12px; margin-inline: -12px; border-radius: var(--r-md); cursor: pointer; font-size: var(--fs-read); line-height: 1.5; transition: background-color .12s; }
.checklist label:hover { background: var(--hover); }
.checklist input { margin-top: 2px; }
.checklist .txt { max-inline-size: 76ch; }
.checklist .is-done .txt { color: var(--ink-2); text-decoration: line-through; text-decoration-thickness: 1px; text-decoration-color: var(--line-strong); }
.hw-table { inline-size: 100%; border-collapse: collapse; font-size: var(--fs-body); }
.hw-table th, .hw-table td { text-align: start; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.hw-table th { font-size: var(--fs-sm); color: var(--ink-2); font-weight: 600; }
.hw-table td.c { text-align: center; inline-size: 88px; }

/* ---------- Module page ---------- */
/* Cover: the code emblem, the title and the idea. Short, so the lesson starts above the fold. */
.cover {
  display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-areas: "emb title" ". lead" ". meta";
  column-gap: 1.125rem; padding: 1.375rem var(--pad) 1rem; background: var(--sheet); color: var(--ink);
}
.emblem {
  grid-area: emb; display: grid; place-items: center; inline-size: 2.75rem; block-size: 2.75rem; border-radius: 13px;
  background: var(--m); color: var(--on-m); font: 720 1.0625rem/1 var(--font-display); letter-spacing: -.01em; font-variant-numeric: tabular-nums;
}
.cover .emblem { align-self: start; margin-block-start: -.0625rem; }
.cover .cover-title { grid-area: title; align-self: center; font: 720 var(--fs-display)/1.06 var(--font-display); letter-spacing: -.032em; }
.cover .lead { grid-area: lead; margin-top: .5rem; max-inline-size: 72ch; font-size: var(--fs-lead); line-height: 1.55; color: var(--ink-2); }
.cover .cover-meta { grid-area: meta; margin-top: .75rem; }
.cover .cover-meta:empty { display: none; }

.cover-end { block-size: 0; }
/* Sticky bar: the tabs at the top of the page; once the cover scrolls away it also carries the code, title and status. */
.modbar { position: sticky; top: var(--inset); z-index: 6; background: var(--sheet); box-shadow: inset 0 -1px 0 var(--line); transition: box-shadow .2s; }
.modbar.is-stuck { box-shadow: inset 0 -1px 0 var(--line), var(--shadow-bar); }
.modbar-in { display: flex; align-items: center; min-height: 3.5rem; padding: .625rem var(--pad); container: bar / inline-size; }
.mb-id {
  display: flex; align-items: center; gap: .625rem; flex: 0 1 auto; min-width: 0; max-inline-size: 0; margin-inline-end: 0; opacity: 0; overflow: hidden; white-space: nowrap;
  transition: max-inline-size .32s var(--ease), margin .32s var(--ease), opacity .2s;
}
.modbar.is-stuck .mb-id { max-inline-size: 36rem; margin-inline-end: 1.25rem; opacity: 1; }
.mb-id b { min-width: 0; overflow: hidden; text-overflow: ellipsis; font: 650 var(--fs-body)/1.3 var(--font-display); letter-spacing: -.01em; }
.mb-id .mchip { block-size: 1.5rem; min-inline-size: 2rem; border-radius: 7px; }
.mb-id .status { flex: none; }
.mb-id > [data-progress], .tb-id > [data-progress] { display: flex; flex: none; } /* centre the status with the title, not on its own text line */
@container bar (max-width: 46rem) { .mb-id .status .lbl { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; } }

/* Two tabs: Study and Practice. A sliding ink thumb marks the open one. */
.tabs { position: relative; flex: none; display: inline-grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); padding: 3px; border-radius: 12px; background: var(--fill-1); }
.tab {
  position: relative; z-index: 1; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 2.25rem; padding: 0 1.25rem; border: 0; border-radius: 9px; background: none;
  color: var(--ink-2); font: 650 var(--fs-body)/1 var(--font); white-space: nowrap; transition: color .2s;
}
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--on-ink); }
.tab .i { width: 18px; height: 18px; }
.tab-count { display: inline-flex; align-items: center; min-height: 20px; padding: 0 6px; border-radius: 6px; background: var(--fill-2); color: var(--ink); font-size: var(--fs-xs); font-weight: 700; font-variant-numeric: tabular-nums; transition: background-color .2s, color .2s; }
.tab[aria-selected="true"] .tab-count { background: var(--m, var(--fill-2)); color: var(--on-m); }
.tab-thumb { position: absolute; z-index: 0; inset-block: 3px; inset-inline-start: 3px; inline-size: calc(50% - 3px); border-radius: 9px; background: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .16); transition: transform .3s var(--ease); }
.tabs[data-sel="1"] .tab-thumb { transform: translateX(calc(100% * var(--dir))); }
.tabpanel:focus-visible { outline-offset: 6px; border-radius: 4px; }
.tabpanel[hidden] { display: none; }
.tabpanel:not([hidden]) { animation: panel-in .24s var(--ease); }
@keyframes panel-in { from { opacity: 0; transform: translateY(4px); } }

/* The bar's far end: present mode, then the class-panel switch, which shows the live clock while the panel is folded away. */
.mb-end { display: flex; align-items: center; gap: 6px; flex: none; margin-inline-start: auto; padding-inline-start: 12px; }
.bar-present { min-height: 2.25rem; padding: 0 .75rem; }
@container bar (max-width: 52rem) { .bar-present { inline-size: 2.25rem; padding: 0; } .bar-present .lbl { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; } }
.plan-btn {
  display: inline-flex; align-items: center; gap: .5rem; flex: none; min-height: 2.25rem; padding: 0 .75rem;
  border: 0; border-radius: 10px; background: var(--fill-1); color: var(--ink); font: 650 var(--fs-ui)/1 var(--font); font-variant-numeric: tabular-nums;
  transition: background-color .14s, color .14s;
}
.plan-btn:hover { background: var(--fill-2); }
.plan-btn .i { width: 18px; height: 18px; }
.plan-btn .pb-block { color: var(--ink-2); font-weight: 600; }
.plan-btn .pb-live { inline-size: 7px; block-size: 7px; border-radius: 50%; background: var(--live); animation: pulse 1.8s infinite; }
.plan-btn[aria-expanded="true"] { background: transparent; color: var(--ink-2); padding-inline: .5rem; }
.plan-btn[aria-expanded="true"]:hover { background: var(--hover); color: var(--ink); }
.plan-btn[aria-expanded="true"] :is(.pb-time, .pb-block, .pb-live) { display: none; }
@container bar (max-width: 40rem) { .plan-btn .pb-block { display: none; } }

/* Lesson: fills the sheet at any width; columns appear as the space allows. */
.lesson { container: lesson / inline-size; padding: var(--s7) var(--pad) var(--s9); }
.tabpanel { display: grid; gap: var(--s9); }
.block { container: block / inline-size; min-width: 0; }
.block-h { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 4px; }
.block-h h2 { font-size: var(--fs-h2); font-weight: 670; letter-spacing: -.014em; }
.block-what { color: var(--ink-2); margin-bottom: var(--s4); max-inline-size: 62ch; }
.mins { font-size: var(--fs-sm); color: var(--ink-2); font-weight: 560; font-variant-numeric: tabular-nums; }
.now-pill { display: inline-flex; align-items: center; gap: 6px; min-height: 22px; padding: 0 8px; border-radius: 6px; background: var(--ink); color: var(--on-ink); font-size: var(--fs-xs); font-weight: 700; }
.now-pill::before, .live::before { content: ""; inline-size: 7px; block-size: 7px; border-radius: 50%; background: var(--live); box-shadow: 0 0 0 0 var(--live); animation: pulse 1.8s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--live) 55%, transparent); } 70%, 100% { box-shadow: 0 0 0 6px transparent; } }

.watch-row { display: grid; gap: var(--s8); align-items: start; }
@container lesson (min-width: 68rem) {
  .watch-row.has-video { grid-template-columns: minmax(0, 1.6fr) minmax(19rem, 1fr); column-gap: 3rem; }
}
.pair { display: grid; gap: var(--s9); align-items: start; }
@container lesson (min-width: 54rem) {
  .pair { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 3rem; }
}

.steps { list-style: none; counter-reset: step; display: grid; }
.steps li { counter-increment: step; display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 14px; padding-block: 12px; font-size: var(--fs-read); line-height: 1.6; max-inline-size: 72ch; break-inside: avoid; }
.steps li + li { border-top: 1px solid var(--line); }
.steps li::before { content: counter(step); display: grid; place-items: center; inline-size: 28px; block-size: 28px; margin-top: -1px; border-radius: 8px; background: var(--m-soft, var(--fill-1)); color: var(--m-text, var(--ink)); font: 700 .8125rem/1 var(--font); font-variant-numeric: tabular-nums; }
@container block (min-width: 46rem) {
  .steps { display: block; columns: 2; column-gap: 3rem; }
  .steps li:first-child { border-top: 1px solid var(--line); }
}
.save-box { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 14px; align-items: start; padding: var(--s5); border-radius: var(--r-lg); background: var(--raised); font-size: var(--fs-read); line-height: 1.6; max-inline-size: 72ch; }
.save-box .i { color: var(--m-text); width: 22px; height: 22px; margin-top: 1px; }

/* Prompts: one column, then two balanced columns, then a row of equal cards once each can be 19rem wide. */
.prompts { display: grid; gap: 12px; align-items: start; }
@container block (min-width: 44rem) and (max-width: 61.99rem) { .prompts { display: block; columns: 2; column-gap: 12px; } .prompts .prompt { margin-block-end: 12px; } }
@container block (min-width: 62rem) { .prompts { grid-template-columns: repeat(auto-fit, minmax(19rem, 1fr)); } }
.prompt { display: block; border-radius: var(--r-lg); background: var(--raised); overflow: hidden; break-inside: avoid; }
.prompt-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-block: 12px 6px; padding-inline: 18px 12px; }
.prompt-head h3 { font-size: var(--fs-body); font-weight: 650; font-family: var(--font); }
.prompt-text { padding: 0 18px 18px; font-size: var(--fs-body); line-height: 1.62; white-space: pre-wrap; color: var(--ink); max-inline-size: 72ch; }
.prompt-mini { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-block: 10px; padding-inline: 16px 10px; border-radius: var(--r-md); background: var(--raised); }
.prompt-mini span { font-weight: 600; font-size: var(--fs-body); min-width: 0; }
.prompt-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 19rem), 1fr)); gap: 8px; margin-top: var(--s4); }
.copied { color: var(--ink); }

.res-list { list-style: none; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 17rem), 1fr)); gap: 8px; }
.res { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; align-items: center; gap: 12px; padding-block: 10px; padding-inline: 10px 14px; border-radius: var(--r-md); background: var(--raised); text-decoration: none; color: inherit; transition: background-color .12s; }
a.res:hover { background: var(--fill-1); }
.res .ic { display: grid; place-items: center; inline-size: 36px; block-size: 36px; border-radius: 10px; background: var(--sheet); color: var(--ink-2); box-shadow: var(--shadow-1); }
.res .ic .i { width: 18px; height: 18px; }
.res b { display: block; font-weight: 620; font-size: var(--fs-body); overflow-wrap: anywhere; }
.res small { display: block; color: var(--ink-2); font-size: var(--fs-sm); overflow-wrap: anywhere; }
.res .go { color: var(--ink-2); width: 16px; height: 16px; }
.res-list .video { grid-column: 1 / -1; }

/* Video guide */
.video { margin: 0; min-width: 0; }
.video-frame { position: relative; border-radius: var(--r-lg); overflow: hidden; background: #08090b; aspect-ratio: 16 / 9; }
.video-frame video { inline-size: 100%; block-size: 100%; object-fit: contain; background: #08090b; }
.vplay {
  position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: flex-end; align-items: flex-start; padding: clamp(1rem, 2.6vw, 1.5rem);
  border: 0; background: linear-gradient(to top, rgba(8, 9, 12, .55), transparent 38%); cursor: pointer;
}
.vplay .pb { display: inline-flex; align-items: center; gap: 10px; min-height: 2.75rem; padding-inline: 8px 18px; border-radius: 999px; background: #fff; color: #15171d; font: 650 var(--fs-ui)/1 var(--font); box-shadow: 0 10px 28px -10px rgba(0, 0, 0, .7); transition: transform .2s var(--ease); }
.vplay .pb .pi { display: grid; place-items: center; inline-size: 30px; block-size: 30px; border-radius: 50%; background: #15171d; color: #fff; }
.vplay .pb .i { width: 16px; height: 16px; margin-inline-start: 2px; }
.vplay .pb .dur { font-variant-numeric: tabular-nums; color: #575b63; }
.vplay:hover .pb { transform: translateY(-1px); }
.vplay:focus-visible { outline: 3px solid #fff; outline-offset: -6px; }
.video figcaption { display: grid; gap: 2px; margin-top: 12px; }
.video .vc-h { display: flex; align-items: center; gap: 8px; }
.video .vc-h b { font-weight: 650; font-size: var(--fs-read); }
.video .vc-h .i { width: 18px; height: 18px; color: var(--m-text, var(--ink-2)); }
.video .vc-t { color: var(--ink-2); font-size: var(--fs-body); padding-inline-start: 26px; max-inline-size: 64ch; }
.video-missing { color: var(--danger); }

/* ---------- Listening and reading: audio explainer, slides, course media ---------- */
/* Study tab: the audio player and the slides share one row under the video guide once there is room. */
.study-media { container: media / inline-size; display: grid; gap: var(--s5); align-content: start; min-width: 0; }
.listen { display: grid; gap: 8px; }
@container media (min-width: 36rem) { .listen { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); } }
.ap-head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; min-width: 0; }
.ap-head b { font-weight: 650; font-size: var(--fs-body); line-height: 1.3; overflow-wrap: anywhere; }
.ap-head .meta { font-weight: 560; }

/* Audio player: play, seek bar, time, speed. The bar fills in the module colour, like the class timer. */
.aplayer {
  display: grid; grid-template-columns: 2.5rem minmax(0, 1fr) auto; grid-template-areas: "play head speed" "play track speed";
  align-items: center; align-content: center; gap: 4px 12px; padding-block: 12px; padding-inline: 12px 8px;
  border-radius: var(--r-lg); background: var(--raised);
}
.aplayer .ap-head { grid-area: head; }
.ap-play {
  grid-area: play; display: grid; place-items: center; inline-size: 2.5rem; block-size: 2.5rem; padding: 0; border: 0; border-radius: 50%;
  background: var(--ink); color: var(--on-ink); transition: background-color .14s, transform .1s;
}
.ap-play:hover { background: var(--ink-hover); }
.ap-play:active { transform: scale(.95); }
.ap-play .i { width: 18px; height: 18px; }
.ap-play .ic-play { translate: 1px 0; } /* optical centre of the triangle */
.aplayer.is-playing .ic-play, .aplayer:not(.is-playing) .ic-pause { display: none; }
.ap-track { grid-area: track; display: flex; align-items: center; gap: 10px; min-width: 0; }
.ap-time { flex: none; font-size: var(--fs-sm); font-weight: 560; color: var(--ink-2); }
.ap-speed { grid-area: speed; min-inline-size: 3.25rem; color: var(--ink); }
.ap-seek { --p: 0%; flex: 1 1 auto; min-width: 0; block-size: 1.25rem; margin: 0; padding: 0; background: transparent; cursor: pointer; -webkit-appearance: none; appearance: none; }
.ap-seek::-webkit-slider-runnable-track { block-size: 4px; border-radius: 2px; background: linear-gradient(to right, var(--m, var(--ink)) var(--p), var(--fill-2) var(--p)); }
.ap-seek::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; inline-size: 14px; block-size: 14px; margin-block-start: -5px; border: 0; border-radius: 50%; background: var(--ink); box-shadow: 0 0 0 2px var(--raised); transition: transform .12s; }
.ap-seek:active::-webkit-slider-thumb { transform: scale(1.15); }
.ap-seek::-moz-range-track { block-size: 4px; border-radius: 2px; background: var(--fill-2); }
.ap-seek::-moz-range-progress { block-size: 4px; border-radius: 2px; background: var(--m, var(--ink)); }
.ap-seek::-moz-range-thumb { inline-size: 14px; block-size: 14px; border: 0; border-radius: 50%; background: var(--ink); box-shadow: 0 0 0 2px var(--raised); }
.ap-seek:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; border-radius: 6px; }
@media (pointer: coarse) { /* a finger needs a taller bar and a bigger thumb to aim at */
  .ap-seek { block-size: 2rem; }
  .ap-seek::-webkit-slider-thumb { inline-size: 18px; block-size: 18px; margin-block-start: -7px; }
  .ap-seek::-moz-range-thumb { inline-size: 18px; block-size: 18px; }
}

/* Slides: open the PDF in a new tab, or download it. Narrow cards keep only the download icon. */
.slides-card {
  container: sc / inline-size; display: grid; grid-template-columns: 2.25rem minmax(0, 1fr); grid-template-areas: "ic head" "ic act";
  align-items: center; align-content: center; gap: 8px 12px; padding: 12px; border-radius: var(--r-lg); background: var(--raised);
}
.slides-card .ic { grid-area: ic; display: grid; place-items: center; inline-size: 2.25rem; block-size: 2.25rem; border-radius: 10px; background: var(--sheet); color: var(--m-text, var(--ink-2)); box-shadow: var(--shadow-1); }
.slides-card .ic .i { width: 18px; height: 18px; }
.slides-card .ap-head { grid-area: head; }
.slides-card .actions { grid-area: act; gap: 4px; }
@container sc (max-width: 17rem) {
  .sc-dl { inline-size: var(--h-sm); padding: 0; }
  .sc-dl .sc-dl-t { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
}

/* Course media on home and the dashboard: video cards side by side; a lone card sets its words beside the picture. */
.home .ov-sec { margin-top: var(--s8); }
.ov-list { list-style: none; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr)); gap: var(--s6) 16px; align-items: start; }
.ov { container: ov / inline-size; display: grid; gap: 8px; min-width: 0; }
.ov-list > .ov:only-child { max-inline-size: 60rem; }
.video .ov-cap { gap: 6px; }
.ov-t { font-weight: 650; font-size: var(--fs-read); line-height: 1.35; }
.ov-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.ov-note { color: var(--ink-2); font-size: var(--fs-body); line-height: 1.5; max-inline-size: 62ch; }
@container ov (min-width: 44rem) {
  .ov .video { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(15rem, 1fr); column-gap: var(--s6); align-items: center; }
  .ov .video .ov-cap { margin-top: 0; }
}
.ov-missing { display: grid; gap: 8px; padding: var(--s5); border: 1px dashed var(--line-strong); border-radius: var(--r-lg); }
.tag-aud { gap: 5px; }
.tag .i { width: 14px; height: 14px; }

/* ---------- Class panel: timer, class plan and my notes, docked at the far edge of the window ---------- */
.side { display: none; }
body.has-side .side {
  display: flex; flex-direction: column; gap: 12px; position: fixed; z-index: 35;
  overflow-y: auto; overscroll-behavior: contain; --card: var(--raised);
}
.side-h { display: flex; align-items: center; gap: 10px; min-height: 2.25rem; padding-inline: 10px 2px; }
.side-h h2 { flex: 1 1 auto; font: 650 var(--fs-ui)/1.2 var(--font); }
.side-h .live { flex: none; }
.side-close .i { width: 18px; height: 18px; }
@media (min-width: 1200px) { .side-close .ic-overlay { display: none; } }
@media (max-width: 1199.98px) { .side-close .ic-docked { display: none; } }
.session { background: var(--card); border-radius: var(--r-lg); padding: var(--s5); }
.live { display: inline-flex; align-items: center; gap: 7px; font-size: var(--fs-xs); font-weight: 700; color: var(--ink); }
.clock-row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.clock { font: 700 2.875rem/1 var(--font-display); letter-spacing: -.035em; font-variant-numeric: tabular-nums; }
.clock.over { color: var(--danger); }
.clock-state { font-size: var(--fs-sm); color: var(--ink-2); font-weight: 600; text-align: end; }
.clock-block { margin-top: 6px; font-weight: 650; font-size: var(--fs-body); }
.bar { display: flex; gap: 3px; block-size: 8px; margin: var(--s4) 0 var(--s3); }
.bar span { position: relative; overflow: hidden; border-radius: 3px; background: var(--fill-2); flex-basis: 0; }
.bar span i { position: absolute; inset-block: 0; inset-inline-start: 0; inline-size: 0; background: var(--m); transition: inline-size .5s linear; }
.bar span.past i { inline-size: 100%; }
.agenda { list-style: none; display: grid; gap: 1px; }
.agenda button {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 8px; inline-size: 100%; min-height: 34px; padding: 0 10px;
  border: 0; border-radius: 9px; background: none; color: var(--ink); font-size: var(--fs-ui); font-weight: 560; text-align: start;
}
.agenda button:hover { background: var(--hover); }
.agenda button[aria-current="step"] { background: var(--ink); color: var(--on-ink); }
.agenda button[aria-current="step"] .mins { color: var(--on-ink); }
.agenda .total { display: flex; justify-content: space-between; padding: 8px 10px 0; font-size: var(--fs-sm); color: var(--ink-2); }
.timer-ctl { display: grid; grid-template-columns: 1fr auto auto; gap: 6px; margin-top: var(--s4); }
.my-notes { display: flex; flex-direction: column; gap: 8px; flex: 1 0 auto; min-block-size: 15rem; padding-inline: 2px; }
.my-notes h2 { font: 650 var(--fs-ui)/1.3 var(--font); padding-inline: 8px; }
.my-notes textarea { flex: 1 1 auto; min-block-size: 9rem; resize: none; background: var(--sheet); }
.my-notes .hint { padding-inline: 8px; }

/* Docked, from 1200px: on the canvas, the mirror of the rail. */
@media (min-width: 1200px) {
  body.has-side .side {
    inset-block: 0; inset-inline-end: 0; inline-size: var(--panel-w); padding-block: 14px 12px; padding-inline: 10px 12px; background: var(--canvas); --card: var(--sheet);
    transition: opacity .2s, translate .26s var(--ease), visibility 0s;
  }
  body.has-side .session { box-shadow: var(--shadow-1); }
  :root[data-panel="closed"] body.has-side .side { visibility: hidden; opacity: 0; translate: calc(24px * var(--dir)) 0; transition: opacity .16s, translate .26s var(--ease), visibility 0s linear .26s; }
  .side-scrim { display: none !important; }
}
/* Below 1200px: an overlay drawer from the far side, and a bottom sheet on phones. */
@media (max-width: 1199.98px) {
  body.has-side .side { transition: translate .28s var(--ease), visibility 0s; }
  :root:not(.side-open) body.has-side .side { visibility: hidden; transition: translate .24s var(--ease), visibility 0s linear .24s; }
  :root.side-open .side-scrim { display: block; position: fixed; inset: 0; z-index: 34; background: var(--scrim); animation: fade-in .2s; }
}
@keyframes fade-in { from { opacity: 0; } }
@media (min-width: 900px) and (max-width: 1199.98px) {
  body.has-side .side {
    inset-block: var(--inset); inset-inline-end: var(--inset); inline-size: min(22rem, calc(100vw - 2 * var(--inset)));
    padding: 12px; border-radius: var(--r-xl); background: var(--sheet); box-shadow: var(--shadow-pop);
  }
  :root:not(.side-open) body.has-side .side { translate: calc((100% + 2 * var(--inset)) * var(--dir)) 0; }
}
@media (max-width: 899.98px) {
  body.has-side .side {
    z-index: 60; inset-inline: 0; inset-block: auto 0; max-block-size: 88dvh;
    padding: 12px 14px calc(18px + env(safe-area-inset-bottom)); border-radius: 22px 22px 0 0; background: var(--sheet); box-shadow: var(--shadow-pop);
  }
  :root:not(.side-open) body.has-side .side { translate: 0 calc(100% + 24px); }
  :root.side-open .side-scrim { z-index: 55; }
  .my-notes { min-block-size: 0; flex: none; }
  .my-notes textarea { min-block-size: 8rem; }
}

/* Live class on small screens: a "now playing" bar that opens the class panel. */
.livebar { display: none; }
@media (max-width: 1199.98px) {
  .livebar:not([hidden]) {
    position: fixed; z-index: 33; inset-inline: 16px; inset-block-end: 16px; display: flex; align-items: center; gap: 10px; justify-content: space-between;
    min-height: 3rem; padding-inline: 16px 8px; border: 0; border-radius: 14px; background: var(--ink); color: var(--on-ink);
    font-weight: 650; font-size: var(--fs-ui); box-shadow: var(--shadow-pop); text-align: start;
  }
  .livebar .lb-clock { font: 700 1.0625rem/1 var(--font-display); font-variant-numeric: tabular-nums; padding: 8px 10px; border-radius: 10px; background: var(--sheet); color: var(--ink); }
  .livebar .live { color: var(--on-ink); }
}
@media (max-width: 899.98px) { .shell .livebar:not([hidden]) { inset-block-end: calc(70px + env(safe-area-inset-bottom)); } }
.present .livebar { display: none !important; }

/* ---------- Classes ---------- */
.class-list { list-style: none; display: grid; gap: 8px; }
.class-row { display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; align-items: center; gap: 16px; padding-block: 10px; padding-inline: 10px 16px; border-radius: var(--r-lg); background: var(--raised); text-decoration: none; color: inherit; transition: background-color .12s; }
a.class-row:hover { background: var(--fill-1); }
/* Date tile: a small calendar page, its top edge in the module's colour. */
.date-tile { display: grid; justify-items: center; align-content: center; gap: 2px; inline-size: 64px; block-size: 64px; padding-top: 3px; border-radius: 14px; background: var(--sheet); color: var(--ink); box-shadow: inset 0 4px 0 var(--m), var(--shadow-1); }
.date-tile small { font-size: .6875rem; font-weight: 700; line-height: 1; color: var(--ink-2); }
.date-tile b { font: 720 1.5rem/1 var(--font-display); letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.class-row .main { display: grid; gap: 4px; min-width: 0; }
.class-row .when { font-weight: 650; font-size: var(--fs-body); }
.class-row .end { display: flex; align-items: center; gap: 12px; }
.class-row .av-stack .av { --av-ring: var(--raised); }
.list-h { font: 650 var(--fs-sm)/1.2 var(--font); color: var(--ink-2); margin-bottom: 10px; }

/* Class page */
.class-cover { display: grid; gap: 14px; padding: var(--s8) var(--pad) var(--s6); background: var(--sheet); box-shadow: inset 0 -1px 0 var(--line); }
.class-cover h1 { font-size: 2.25rem; font-weight: 720; line-height: 1.08; letter-spacing: -.03em; }
.class-cover .row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 22px; color: var(--ink-2); font-size: var(--fs-ui); }
.class-body { display: grid; gap: var(--s8); padding: var(--s6) var(--pad) var(--s9); }
@media (min-width: 1200px) { .class-body { grid-template-columns: minmax(0, 1fr) 21rem; align-items: start; } .class-body .companion { position: sticky; top: calc(var(--inset) + var(--s5)); } }
.companion { display: grid; gap: var(--s5); align-content: start; min-width: 0; }
.companion .my-notes { min-block-size: 0; padding-inline: 0; }
.companion .my-notes :is(h2, .hint) { padding-inline: 0; }
.companion .my-notes textarea { min-block-size: 11rem; resize: vertical; }

.thread { list-style: none; display: grid; gap: 2px; margin-bottom: var(--s4); }
.note { display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 12px; padding: 12px; margin-inline: -12px; border-radius: var(--r-lg); transition: background-color .12s; }
.note:hover, .note:focus-within { background: var(--hover); }
.note.editing { background: var(--raised); }
.note-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; }
.note-head b { font-weight: 650; font-size: var(--fs-ui); }
.note-head time, .note-head .ed { font-size: var(--fs-sm); color: var(--ink-2); font-variant-numeric: tabular-nums; }
.note-text { margin-top: 2px; font-size: var(--fs-read); line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; max-inline-size: 80ch; }
.note-actions { display: flex; gap: 2px; margin-inline-start: auto; margin-block: -6px; }
@media (hover: hover) and (pointer: fine) { .note-actions { opacity: 0; transition: opacity .12s; } .note:hover .note-actions, .note:focus-within .note-actions { opacity: 1; } }
.note .note-form { margin-top: 6px; }
.composer { display: grid; gap: 10px; padding: 12px; border-radius: var(--r-lg); background: var(--raised); }
.composer textarea { min-height: 5.5rem; background: var(--sheet); }
.composer .row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.kbd { font-size: var(--fs-xs); color: var(--ink-2); }

/* ---------- Homework page ---------- */
.hw-total { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.hw-total b { font: 720 2rem/1 var(--font-display); letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.hw-mods { display: grid; gap: 12px; }
.hw-mod { padding: var(--s5) var(--s5) var(--s3); border-radius: var(--r-lg); background: var(--raised); }
.hw-mod-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 4px; }
.hw-mod-h a { display: inline-flex; align-items: baseline; gap: 10px; font-weight: 650; font-size: var(--fs-read); text-decoration: none; }
.hw-mod-h a:hover bdi { text-decoration: underline; text-decoration-color: var(--line-strong); }
.hw-mod.is-later { background: transparent; box-shadow: inset 0 0 0 1px var(--line); }

/* ---------- Library ---------- */
.add-link { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1.2fr) auto; gap: 12px; align-items: end; padding: var(--s5); border-radius: var(--r-lg); background: var(--raised); }
.add-link .input, .add-link .select { background-color: var(--sheet); }
.add-link + .sec, .sec + .add-link { margin-top: var(--s8); }
.res-player { grid-column: 1 / -1; margin-top: 4px; }
.res-player .video-frame { max-inline-size: 48rem; }
.filters { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: var(--s4); }
.filters button { display: inline-flex; align-items: center; gap: 7px; min-height: var(--h-sm); padding: 0 11px 0 6px; padding-inline: 6px 11px; border: 0; border-radius: 8px; background: var(--fill-1); color: var(--ink-2); font-size: var(--fs-sm); font-weight: 650; }
.filters button:first-child { padding-inline: 11px; }
.filters button:hover { color: var(--ink); }
.filters button[aria-pressed="true"] { background: var(--ink); color: var(--on-ink); }
.filters .mchip { min-inline-size: 1.5rem; block-size: 1.125rem; border-radius: 5px; font-size: .65625rem; }
.lib-list { list-style: none; display: grid; gap: 8px; }
.lib-row { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; gap: 14px; align-items: start; padding-block: 12px; padding-inline: 12px 14px; border-radius: var(--r-lg); background: var(--raised); }
.lib-row .ic { display: grid; place-items: center; inline-size: 40px; block-size: 40px; border-radius: 11px; background: var(--sheet); color: var(--ink); box-shadow: var(--shadow-1); }
.lib-row .t { font-weight: 640; font-size: var(--fs-read); line-height: 1.35; overflow-wrap: anywhere; text-decoration: none; }
.lib-row a.t:hover { text-decoration: underline; text-decoration-color: var(--line-strong); }
.lib-row .meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin-top: 4px; }
.lib-row .side-btns { display: flex; align-items: center; gap: 6px; }
.transcript { grid-column: 1 / -1; display: grid; gap: 10px; margin-top: 4px; }
.transcript pre { max-block-size: 22rem; overflow: auto; padding: 14px 16px; border-radius: var(--r-md); background: var(--sheet); font: 400 var(--fs-ui)/1.6 var(--font); white-space: pre-wrap; overflow-wrap: anywhere; box-shadow: inset 0 0 0 1px var(--line); }

/* ---------- Admin: dashboard ---------- */
.upcoming { list-style: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: 10px; }
.upcoming li { display: grid; }
.up { display: grid; grid-template-columns: 52px minmax(0, 1fr); gap: 12px; align-items: center; padding: 10px; border-radius: var(--r-lg); background: var(--raised); text-decoration: none; color: inherit; }
.up:hover { background: var(--fill-1); }
.up .date-tile { inline-size: 52px; block-size: 52px; border-radius: 12px; }
.up .date-tile b { font-size: 1.25rem; }
.up .main { display: grid; gap: 3px; min-width: 0; font-size: var(--fs-sm); }
.up .main .when { font-weight: 650; font-size: var(--fs-ui); }

.matrix { display: grid; gap: 6px; }
.mx-row { display: grid; grid-template-columns: 9.5rem repeat(8, minmax(0, 1fr)); gap: 6px; align-items: stretch; }
.mx-head .mx-mod { display: grid; justify-items: start; gap: 6px; padding: 0 4px 6px; font-size: var(--fs-xs); font-weight: 600; color: var(--ink-2); line-height: 1.25; text-decoration: none; min-width: 0; }
.mx-head .mx-mod span:last-child { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
.mx-head .mx-mod:hover { color: var(--ink); }
.mx-who { display: flex; align-items: center; gap: 10px; min-width: 0; padding-inline-end: 6px; font-weight: 650; text-decoration: none; }
.mx-who:hover b { text-decoration: underline; text-decoration-color: var(--line-strong); }
.mx-who b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell {
  position: relative; display: grid; align-content: center; justify-items: start; gap: 4px; min-height: 4.25rem; padding: 10px 10px;
  border: 0; border-radius: var(--r-md); background: var(--fill-1); color: var(--ink-2); text-align: start;
  font-size: var(--fs-xs); font-weight: 650; transition: transform .12s, box-shadow .12s;
}
.cell:hover { transform: translateY(-1px); box-shadow: var(--shadow-1); }
.cell .n { display: none; font: 700 .75rem/1 var(--font); letter-spacing: .02em; }
.cell .status { font-size: var(--fs-xs); color: inherit; }
.cell .hw { font-variant-numeric: tabular-nums; font-weight: 600; }
.cell.s-in_progress { background: var(--sheet); color: var(--m-text); box-shadow: inset 0 0 0 1.5px var(--m-ring); }
.cell.s-done { background: var(--m); color: var(--on-m); }
.cell.s-done .st-icon-done + path { stroke: var(--m); }
.cell .manual { position: absolute; inset-block-start: 8px; inset-inline-end: 8px; inline-size: 7px; block-size: 7px; border-radius: 50%; background: currentColor; }
.cell[aria-expanded="true"] { outline: 2px solid var(--ink); outline-offset: 2px; }
.override { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin-top: 10px; padding: 12px 14px; border-radius: var(--r-lg); background: var(--raised); }
.override p { font-size: var(--fs-ui); }
.legend-row { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 12px; font-size: var(--fs-sm); color: var(--ink-2); }
.legend-row span { display: inline-flex; align-items: center; gap: 7px; }
.legend-row i { inline-size: 14px; block-size: 14px; border-radius: 4px; background: var(--fill-1); }
.legend-row i.lp { background: var(--sheet); box-shadow: inset 0 0 0 1.5px var(--ink-2); }
.legend-row i.ld { background: var(--ink-2); }
.legend-row i.lm { inline-size: 7px; block-size: 7px; border-radius: 50%; background: var(--ink-2); }

.students { display: grid; grid-template-columns: repeat(auto-fit, minmax(22rem, 1fr)); gap: 16px; }
.student { display: grid; gap: var(--s4); align-content: start; padding: var(--s5); border-radius: var(--r-xl); background: var(--raised); }
.student-h { display: flex; align-items: center; gap: 12px; }
.student-h .who { flex: 1; min-width: 0; display: grid; }
.student-h .who a { font: 680 1.125rem/1.2 var(--font-display); text-decoration: none; }
.student-h .who a:hover { text-decoration: underline; text-decoration-color: var(--line-strong); }
.student-h .who span { font-size: var(--fs-sm); color: var(--ink-2); }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.stats div { padding: 10px 12px; border-radius: var(--r-md); background: var(--sheet); box-shadow: var(--shadow-1); }
.stats dt { font-size: var(--fs-xs); color: var(--ink-2); font-weight: 600; }
.stats dd { font: 700 1.25rem/1.2 var(--font-display); letter-spacing: -.02em; font-variant-numeric: tabular-nums; margin-top: 2px; }
.sub-h { font: 650 var(--fs-sm)/1.3 var(--font); color: var(--ink-2); margin-bottom: 6px; }
.feed { list-style: none; display: grid; gap: 0; font-size: var(--fs-sm); }
.feed li { display: grid; grid-template-columns: 6.75rem minmax(0, 1fr); gap: 10px; padding-block: 6px; }
.feed li + li { border-top: 1px solid var(--line); }
.feed time { color: var(--ink-2); font-variant-numeric: tabular-nums; }
.feed .what { overflow-wrap: anywhere; }
.tnote textarea { background: var(--sheet); min-height: 7rem; }

/* Student detail */
.split { display: grid; gap: var(--s8); }
.split .panel + .sec { margin-top: var(--s7); }
@media (min-width: 1100px) { .split { grid-template-columns: minmax(0, 1fr) minmax(0, 22rem); align-items: start; } }
.pnote { padding: var(--s4) var(--s5); border-radius: var(--r-lg); background: var(--raised); }
.pnote + .pnote { margin-top: 10px; }
.pnote .note-text { margin-top: 8px; }

/* ---------- Admin: manage ---------- */
.manage { display: grid; gap: var(--s8); }
@media (min-width: 1280px) { .manage { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); align-items: start; } }
.form-card { display: grid; gap: 14px; padding: var(--s5); border-radius: var(--r-xl); background: var(--raised); }
.form-card h3 { font: 650 var(--fs-read)/1.3 var(--font-display); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr)); gap: 12px; }
.form-grid .wide { grid-column: 1 / -1; }
.form-card .input, .form-card .select { background-color: var(--sheet); }
.form-card .check-chip { background: var(--sheet); box-shadow: var(--shadow-1); }
.rows { list-style: none; display: grid; gap: 8px; margin-top: var(--s4); }
.row-item { display: grid; gap: 8px; padding: 12px 14px; border-radius: var(--r-lg); box-shadow: inset 0 0 0 1px var(--line); }
.row-item .top { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.row-item .title { display: flex; align-items: center; gap: 10px; font-weight: 650; min-width: 0; }
.row-item .title a { text-decoration: none; }
.row-item .title a:hover { text-decoration: underline; text-decoration-color: var(--line-strong); }
.row-item form { display: grid; gap: 12px; }
.manage-side > section + section { margin-top: var(--s8); }
.present-launch { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; }
.present-launch .field { flex: 1 1 14rem; }

/* ---------- Login ---------- */
.login { min-height: 100dvh; display: grid; grid-template-rows: auto 1fr; background: var(--canvas); }
.login-top { display: flex; align-items: center; justify-content: flex-end; gap: 12px; padding: 18px clamp(16px, 3vw, 28px); }
.login-top .prefs { gap: 8px; }
.login-stage { display: grid; place-items: center; padding: 8px clamp(16px, 3vw, 28px) 48px; }
.login-card { inline-size: min(100%, 940px); display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); border-radius: 26px; overflow: hidden; background: var(--sheet); box-shadow: var(--shadow-sheet), 0 0 0 1px var(--sheet-edge); }
.login-art { position: relative; display: flex; flex-direction: column; background: var(--sunk); min-height: 30rem; }
.login-brand { position: absolute; inset-block-start: 32px; inset-inline-start: 32px; z-index: 1; display: grid; gap: 6px; }
.login-brand .wheel { width: 40px; height: 40px; margin-bottom: 14px; }
.login-brand b { font: 720 2rem/1.05 var(--font-display); letter-spacing: -.03em; }
.login-brand span { color: var(--ink-2); font-size: var(--fs-read); }
/* Eight columns rising like a level meter at rest: white bars, each lit only at its tip in its module colour. */
.eq { position: relative; flex: 1; display: flex; align-items: flex-end; gap: 6px; padding: 28px 28px 0; }
.eq span { position: relative; flex: 1; display: flex; align-items: flex-end; justify-content: center; padding-bottom: 14px; border-radius: 14px 14px 0 0; background: var(--sheet); color: var(--ink-2); box-shadow: inset 0 5px 0 var(--m), 0 0 0 1px var(--sheet-edge); font: 700 .75rem/1 var(--font); letter-spacing: .02em; font-variant-numeric: tabular-nums; transform-origin: bottom; animation: rise .7s var(--ease) both; }
.eq span:nth-child(1) { block-size: 30%; } .eq span:nth-child(2) { block-size: 40%; animation-delay: .04s; } .eq span:nth-child(3) { block-size: 50%; animation-delay: .08s; } .eq span:nth-child(4) { block-size: 60%; animation-delay: .12s; }
.eq span:nth-child(5) { block-size: 70%; animation-delay: .16s; } .eq span:nth-child(6) { block-size: 80%; animation-delay: .2s; } .eq span:nth-child(7) { block-size: 90%; animation-delay: .24s; } .eq span:nth-child(8) { block-size: 100%; animation-delay: .28s; }
@keyframes rise { from { transform: scaleY(.04); } }
.login-form { display: flex; flex-direction: column; justify-content: center; gap: 0; padding: clamp(28px, 5vw, 56px); }
.login-form h1 { font: 720 2.25rem/1.05 var(--font-display); letter-spacing: -.032em; }
.login-form .sub { margin-top: 8px; color: var(--ink-2); font-size: var(--fs-read); }
.login-form form { display: grid; gap: 8px; margin-top: 32px; }
.login-form label { font-weight: 600; font-size: var(--fs-ui); }
.login-form .input { min-height: 2.875rem; font-size: 1rem; border-radius: 12px; }
.login-form .btn { margin-top: 10px; min-height: 2.875rem; font-size: var(--fs-body); border-radius: 12px; }
.login-form .err { min-height: 1.4em; font-size: var(--fs-sm); font-weight: 560; }

/* ---------- Toast and present-mode exit ---------- */
.flash {
  position: fixed; z-index: 90; inset-block-end: 20px; inset-inline-start: 50%; translate: -50% 0; max-inline-size: min(560px, calc(100vw - 32px));
  padding: 12px 18px; border-radius: 12px; background: var(--ink); color: var(--on-ink); font-weight: 560; font-size: var(--fs-ui);
  box-shadow: var(--shadow-pop); animation: flash-in .22s var(--ease);
}
[dir="rtl"] .flash { translate: 50% 0; }
.flash.err { background: var(--danger); color: var(--sheet); }
@keyframes flash-in { from { opacity: 0; transform: translateY(8px); } }
@media (max-width: 899.98px) { .shell .flash { inset-block-end: calc(76px + env(safe-area-inset-bottom)); } }
.exit-present { display: none; }
.present .exit-present {
  display: inline-flex; align-items: center; gap: 10px; position: fixed; z-index: 60; inset-block-end: 22px; inset-inline-end: 26px;
  min-height: 2.5rem; padding: 0 16px; border: 0; border-radius: 12px; background: var(--ink); color: var(--on-ink);
  font-size: var(--fs-sm); font-weight: 650; box-shadow: var(--shadow-pop);
}
.exit-present kbd { font: inherit; padding: 1px 6px; border-radius: 5px; background: rgba(127, 127, 127, .28); }

/* ---------- Present mode: the module full window, larger, without the rail ---------- */
html.present { font-size: 20px; --inset: 8px; --rail-cur: var(--inset); }
.present .rail, .present .topbar, .present .tabbar, .present .no-present { display: none !important; }
@media (max-width: 899.98px) { .present .shell .sheet { padding-bottom: 0; } }
.present .modbar { top: var(--inset); }

/* ---------- Narrow screens ---------- */
@media (max-width: 1099.98px) {
  .home-grid, .home-lower { grid-template-columns: minmax(0, 1fr); }
  .next { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 24px; }
  .next h2, .next .actions { grid-column: 1 / -1; }
  .next .grow { display: none; }
  .next-mod { margin-top: 0; grid-column: 2; grid-row: 2 / span 3; align-self: start; border-block: 0; padding-block: 0; }
  .add-link { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .add-link .url { grid-column: 1 / -1; }
}
@media (max-width: 899.98px) {
  :root { --fs-body: 1rem; --fs-ui: .9375rem; --fs-read: 1.0625rem; --h-ctl: 2.75rem; --h-sm: 2.375rem; --fs-display: 1.75rem; --fs-h1: 1.75rem; --pad: 16px; }
  .input, .select, textarea.input { font-size: 1rem; }
  .view { padding: var(--s6) 16px var(--s8); }
  .page-head { margin-bottom: var(--s6); }
  .home-head h1 { font-size: 1.75rem; }
  .where { inline-size: 100%; }
  .home-cover { min-height: 0; border-radius: var(--r-lg); padding: 1.25rem 16px; }
  .home-cover .emblem { inline-size: 2.5rem; block-size: 2.5rem; border-radius: 12px; font-size: 1rem; }
  .home-cover .cover-title { font-size: 1.875rem; margin-top: var(--s4); }
  .cover { grid-template-areas: "emb title" "lead lead" "meta meta"; column-gap: .875rem; padding: 1.25rem 16px 1rem; }
  .bar-present { display: none; }
  .cover .emblem { inline-size: 2.375rem; block-size: 2.375rem; border-radius: 11px; font-size: .9375rem; margin-block-start: 0; }
  .cover .lead { margin-top: .75rem; }
  .modbar { top: calc(56px + env(safe-area-inset-top)); }
  .modbar-in { gap: 8px; padding: .5rem 16px; min-height: 3.5rem; }
  .mb-id { display: none; }
  .tabs { flex: 1 1 auto; }
  .tab { padding: 0 .5rem; gap: 6px; min-height: 2.5rem; }
  .tab .i { display: none; }
  .mb-end { padding-inline-start: 0; }
  .plan-btn { min-height: 2.5rem; padding: 0 .625rem; }
  .plan-btn[aria-expanded="true"] { padding-inline: .625rem; }
  .lesson { padding: var(--s6) 16px var(--s8); }
  .course-list-mobile { display: block; margin-top: var(--s8); }
  .course-list-mobile .mod-list { overflow: visible; }
  .course-list-mobile .mod-row { padding: 10px 10px; font-size: var(--fs-body); }
  .next { padding: var(--s5); }
  .class-cover { padding: var(--s6) 16px var(--s5); }
  .class-cover h1 { font-size: 1.75rem; }
  .class-body { padding: var(--s5) 16px var(--s8); }
  .class-row { grid-template-columns: 56px minmax(0, 1fr); padding-inline-end: 12px; }
  .class-row .end { grid-column: 2; }
  .date-tile { inline-size: 56px; block-size: 56px; }
  .lib-row { grid-template-columns: 36px minmax(0, 1fr); }
  .lib-row .ic { inline-size: 36px; block-size: 36px; }
  .lib-row .side-btns { grid-column: 2; }
  .add-link { grid-template-columns: minmax(0, 1fr); }
  .mx-head { display: none !important; }
  .mx-row { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .mx-row .mx-who { grid-column: 1 / -1; padding-block: 8px 2px; }
  .cell .n { display: block; }
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .students { grid-template-columns: minmax(0, 1fr); }
  .feed li { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .login-art { min-height: 0; }
  .login-brand { position: static; padding: 22px 22px 0; }
  .login-brand .wheel { display: none; }
  .login-brand b { font-size: 1.5rem; }
  .eq { min-height: 8.5rem; padding: 14px 18px 0; gap: 4px; }
  .eq span { padding-bottom: 8px; border-radius: 9px 9px 0 0; font-size: .625rem; box-shadow: inset 0 4px 0 var(--m), 0 0 0 1px var(--sheet-edge); }
  .login-card { grid-template-columns: minmax(0, 1fr); border-radius: 22px; }
  .login-form h1 { font-size: 1.875rem; }
  .login-form form { margin-top: 24px; }
  .note-actions .btn { min-height: 2.25rem; }
}
@media (max-width: 420px) {
  .seg button { min-width: 30px; padding: 0 7px; }
  .next { grid-template-columns: minmax(0, 1fr); }
  .next-mod { grid-column: auto; grid-row: auto; border-top: 1px solid var(--line); padding-top: var(--s3); margin-top: var(--s3); }
  .stats dd { font-size: 1.0625rem; }
}

/* ---------- Motion preferences ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; transition-delay: 0s !important; scroll-behavior: auto !important; }
}
