/* Planora: shared styles for the sign-in page and the app.

   The idea is the school day in an indigo-violet family: one hue range (indigo ~245 to
   violet ~265) carries the whole interface, so it reads as calm and focused, and the only
   colours outside that family are the two marks that mean something:
   highlighter yellow means "today / now", red pen means "overdue". Yellow is the complement of
   indigo, so "today" is always the highest-contrast mark on the page.
   Proportion is roughly 60/30/10: ~60% soft lavender ground and white sheets (or navy in dark),
   ~30% ink and the deep indigo rail, ~10% saturated indigo/violet for pressable things.
   Subjects are colour-coded like exercise-book covers, in a fixed, colour-blind-checked order.

   One typeface, Archivo, uses its width axis by job: expanded for page titles, normal for
   reading, condensed for times and numbers (the timetable voice).

   Everything is drawn like a stamped exercise book: 2px ink outlines and hard offset shadows,
   no blur and no glass. Buttons press down into their shadow. The focus timer and test
   countdown are split-flap tiles, like a station departure board. */

:root {
  /* Light mode: a lavender-tinted ground (not stark white) so white sheets lift off it, slate
     ink, a deep indigo rail and outlines, indigo #4f46e5 for pressable things, and soft
     periwinkle hard shadows. All text colours pass WCAG AA on --ground, --paper and --paper-2. */
  --ground: #eef0fb;
  --paper: #ffffff;
  --paper-2: #f5f6fd;
  --rule: #e0e4f5;
  --rule-strong: #b3b9dc;
  --ink: #1f2937;
  --ink-2: #4b5563;
  --ink-3: #5f6577;

  --rail: #1e1b4b;
  --rail-2: #312e81;
  --rail-ink: #f8fafc;
  --rail-ink-2: #c7d2fe;

  --hl: #ffd84a;
  --hl-ink: #1f2937;
  --pen: #c0322a;
  --pen-soft: #fde4e1;
  --ok: #1f7a4d;

  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --on-primary: #ffffff;
  --seg-on: #ffffff;
  --focus: #4f46e5;
  --ring: rgba(79, 70, 229, 0.22);
  --scrim: rgba(17, 24, 39, 0.45);
  /* Outlines and hard shadows: --edge draws the line, --drop is the solid shadow under it */
  --edge: #1e1b4b;
  --drop: #bcc3f3;
  --shadow-sm: 2px 2px 0 var(--drop);
  --shadow: 3px 3px 0 var(--drop);
  --lift: 4px 4px 0 var(--drop);
  --lift-lg: 8px 8px 0 var(--drop);
  --flap: #1e1b4b;
  --flap-ink: #f8fafc;
  --hl-blend: multiply;

  /* Subject colours: the validated categorical order (blue, orange, aqua, yellow, pink, green, violet, red) plus a neutral */
  --c-blue: #2a78d6;
  --c-orange: #eb6834;
  --c-aqua: #1baf7a;
  --c-yellow: #eda100;
  --c-magenta: #e87ba4;
  --c-green: #008300;
  --c-violet: #6250d6;
  --c-red: #e34948;
  --c-slate: #7a8399;
  /* Extra covers for bigger timetables. They come after the validated eight, so the defaults stay
     distinguishable; light-dark() picks the variant for the active color-scheme. */
  --c-sky: light-dark(#2f9bd6, #4cb0e6);
  --c-coral: light-dark(#e2685a, #ec7f71);
  --c-teal: light-dark(#0f8a8a, #26a6a6);
  --c-gold: light-dark(#b8901a, #d1a832);
  --c-rose: light-dark(#cc4470, #e06b90);
  --c-lime: light-dark(#6f9a12, #8fbb2a);
  --c-indigo: light-dark(#3b4cc0, #7b88ea);
  --c-brown: light-dark(#8a5a3b, #b5835f);
  --c-plum: light-dark(#8e3f8c, #bb72b8);
  --c-mint: light-dark(#3fb592, #55c9a5);
  --c-olive: light-dark(#6b7a2a, #9aaa4c);
  --c-navy: light-dark(#1d2a52, #6d84c8);

  --font: "Archivo", "Helvetica Neue", Arial, system-ui, sans-serif;
  --wide: 125%;
  --semi-wide: 112%;
  --narrow: 75%;

  --rail-w: 244px;
  --r-sm: 3px;
  --r: 4px;
  --r-lg: 6px;
  --chev: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%234b5563' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  color-scheme: light;
}

/* Dark mode: indigo-navy (lifted from #0f172a so it is not near-black; the rail keeps the
   deepest navy), near-white text, violet #7c3aed buttons (the lighter #8b5cf6 fails AA with
   white text), lavender #a78bfa focus, and indigo #6366f1 outlines. Text passes AA everywhere. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #141b34;
    --paper: #1c2441;
    --paper-2: #232c4d;
    --rule: #2e3860;
    --rule-strong: #4a5585;
    --ink: #f8fafc;
    --ink-2: #cbd5e1;
    --ink-3: #94a3b8;
    --rail: #0f172a;
    --rail-2: #222a4d;
    --rail-ink: #f8fafc;
    --rail-ink-2: #b4bce0;
    --hl: #e8d84e;
    --pen: #ff7d70;
    --pen-soft: #44211e;
    --ok: #4cc58a;
    --primary: #7c3aed;
    --primary-hover: #6d28d9;
    --on-primary: #ffffff;
    --seg-on: #3b3577;
    --focus: #a78bfa;
    --ring: rgba(167, 139, 250, 0.3);
    --scrim: rgba(2, 6, 23, 0.62);
    --edge: #6366f1;
    --drop: #0a0f1f;
    --flap: #0f172a;
    --hl-blend: normal;
    --c-blue: #3987e5;
    --c-orange: #d95926;
    --c-aqua: #199e70;
    --c-yellow: #c98500;
    --c-magenta: #d55181;
    --c-green: #008300;
    --c-violet: #9085e9;
    --c-red: #e66767;
    --c-slate: #7883a0;
    --chev: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23cbd5e1' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --ground: #141b34;
  --paper: #1c2441;
  --paper-2: #232c4d;
  --rule: #2e3860;
  --rule-strong: #4a5585;
  --ink: #f8fafc;
  --ink-2: #cbd5e1;
  --ink-3: #94a3b8;
  --rail: #0f172a;
  --rail-2: #222a4d;
  --rail-ink: #f8fafc;
  --rail-ink-2: #b4bce0;
  --hl: #e8d84e;
  --pen: #ff7d70;
  --pen-soft: #44211e;
  --ok: #4cc58a;
  --primary: #7c3aed;
  --primary-hover: #6d28d9;
  --on-primary: #ffffff;
  --seg-on: #3b3577;
  --focus: #a78bfa;
  --ring: rgba(167, 139, 250, 0.3);
  --scrim: rgba(2, 6, 23, 0.62);
  --edge: #6366f1;
  --drop: #0a0f1f;
  --flap: #0f172a;
  --hl-blend: normal;
  --c-blue: #3987e5;
  --c-orange: #d95926;
  --c-aqua: #199e70;
  --c-yellow: #c98500;
  --c-magenta: #d55181;
  --c-green: #008300;
  --c-violet: #9085e9;
  --c-red: #e66767;
  --c-slate: #7883a0;
  --chev: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23cbd5e1' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  color-scheme: dark;
}

/* Subject colour classes: set --sub, components read it */
.c-blue { --sub: var(--c-blue); }
.c-orange { --sub: var(--c-orange); }
.c-aqua { --sub: var(--c-aqua); }
.c-yellow { --sub: var(--c-yellow); }
.c-magenta { --sub: var(--c-magenta); }
.c-green { --sub: var(--c-green); }
.c-violet { --sub: var(--c-violet); }
.c-red { --sub: var(--c-red); }
.c-slate { --sub: var(--c-slate); }
.c-sky { --sub: var(--c-sky); }
.c-coral { --sub: var(--c-coral); }
.c-teal { --sub: var(--c-teal); }
.c-gold { --sub: var(--c-gold); }
.c-rose { --sub: var(--c-rose); }
.c-lime { --sub: var(--c-lime); }
.c-indigo { --sub: var(--c-indigo); }
.c-brown { --sub: var(--c-brown); }
.c-plum { --sub: var(--c-plum); }
.c-mint { --sub: var(--c-mint); }
.c-olive { --sub: var(--c-olive); }
.c-navy { --sub: var(--c-navy); }
[class*="c-"] { --sub-soft: color-mix(in oklab, var(--sub) 15%, var(--paper)); --sub-edge: color-mix(in oklab, var(--sub) 72%, var(--ink)); }

/* ============================================================
   Base
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--ground);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p { margin: 0; }
h1 {
  font-size: clamp(2rem, 1.5rem + 1.8vw, 2.9rem);
  font-weight: 800;
  font-stretch: var(--wide);
  line-height: 1.02;
  letter-spacing: -0.025em;
  text-wrap: balance;
}
h2 { font-size: 1.06rem; font-weight: 700; font-stretch: var(--semi-wide); letter-spacing: -0.01em; line-height: 1.25; }
h3 { font-size: 0.92rem; font-weight: 650; line-height: 1.3; }
a { color: inherit; text-decoration-color: var(--rule-strong); text-underline-offset: 3px; }
a:hover { text-decoration-color: currentColor; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.55; }
time, .num, kbd, output { font-stretch: var(--narrow); font-variant-numeric: tabular-nums; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.ic { width: 18px; height: 18px; flex: none; }
.ic-xs { width: 13px; height: 13px; vertical-align: -2px; }
.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip { position: absolute; left: 12px; top: -60px; z-index: 100; background: var(--primary); color: var(--on-primary); padding: 8px 14px; border-radius: var(--r); }
.skip:focus { top: 12px; }
.muted { color: var(--ink-3); }
.small { font-size: 12.5px; }
.hint { font-size: 13px; color: var(--ink-3); }
.pad { padding: 12px 0; }
.pad-x { padding-inline: 0; }
.grow { flex: 1; }
.inline { display: inline-flex; align-items: center; gap: 8px; }
kbd {
  display: inline-block; min-width: 1.6em; padding: 1px 6px; font-family: inherit; font-size: 12px; text-align: center;
  color: var(--ink-2); background: var(--paper); border: 1.5px solid var(--edge); border-radius: 3px; box-shadow: 1px 1px 0 var(--drop);
}

/* The two meaningful marks */
.hl {
  padding: 0 0.22em;
  margin: 0 -0.08em;
  color: var(--hl-ink);
  background: linear-gradient(100deg, transparent 0 1.5%, var(--hl) 3% 96%, transparent 98%);
  border-radius: 0.25em 0.5em 0.3em 0.55em;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}
.pen { color: var(--pen); text-decoration: underline wavy var(--pen) 1px; text-underline-offset: 3px; text-decoration-skip-ink: none; }

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 15px;
  font-size: 14px; font-weight: 600; white-space: nowrap; text-decoration: none;
  border: 2px solid transparent; border-radius: var(--r); background: none;
  transition: background-color 0.15s, color 0.15s, transform 0.08s ease-out, box-shadow 0.08s ease-out;
}
/* Outlined buttons sit on a hard shadow, lift a pixel on hover and press flat when clicked */
.btn.primary { background: var(--primary); color: var(--on-primary); border-color: var(--edge); box-shadow: var(--shadow-sm); }
.btn.line { border-color: var(--edge); background: var(--paper); box-shadow: var(--shadow-sm); }
@media (hover: hover) {
  .btn.primary:hover:not(:disabled), .btn.line:hover:not(:disabled) { transform: translate(-1px, -1px); box-shadow: var(--shadow); }
}
.btn.primary:active:not(:disabled), .btn.line:active:not(:disabled) { transform: translate(2px, 2px); box-shadow: none; }
.btn.quiet { color: var(--ink-2); }
.btn.quiet:hover:not(:disabled) { background: var(--paper-2); color: var(--ink); }
.btn.danger { color: var(--pen); }
.btn.danger:hover:not(:disabled) { background: var(--pen-soft); color: var(--pen); }
.btn.sm { height: 32px; padding: 0 11px; font-size: 13px; gap: 6px; }
.btn.sm .ic { width: 16px; height: 16px; }
.btn.lg { height: 46px; padding: 0 22px; font-size: 15px; }
.icon-btn {
  display: inline-grid; place-items: center; flex: none;
  width: 36px; height: 36px; padding: 0;
  color: var(--ink-2); background: none; border: 0; border-radius: var(--r);
  transition: background-color 0.15s, color 0.15s;
}
.icon-btn:hover:not(:disabled) { background: var(--paper-2); color: var(--ink); }
.icon-btn.sm { width: 28px; height: 28px; border-radius: var(--r-sm); }
.icon-btn.sm .ic { width: 15px; height: 15px; }

/* ============================================================
   Form fields: the label sits above, plain and readable
   ============================================================ */
.field { display: grid; gap: 6px; min-width: 0; align-content: start; }
.field > label, .field > .label, .seg-field > legend { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field > label output { float: right; font-weight: 600; color: var(--ink); }
input:not([type="checkbox"], [type="radio"], [type="range"], [type="file"]), select, textarea {
  width: 100%; min-width: 0; height: 40px; padding: 0 12px;
  background: var(--paper); border: 2px solid var(--edge); border-radius: var(--r);
  transition: border-color 0.15s, box-shadow 0.1s;
}
textarea { height: auto; padding: 10px 12px; resize: vertical; line-height: 1.5; }
select { appearance: none; padding-right: 34px; background: var(--paper) var(--chev) no-repeat right 10px center / 16px; }
input::placeholder, textarea::placeholder { color: var(--ink-3); opacity: 0.85; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--edge); box-shadow: var(--shadow); }
.field.invalid input, .field.invalid select, input.invalid { border-color: var(--pen); }
.field-error { font-size: 13px; color: var(--pen); }
.field.big input { height: 48px; font-size: 1.1rem; font-weight: 600; }
.field-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 18px; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--primary); width: 16px; height: 16px; margin: 0; }
input[type="range"] { width: 100%; accent-color: var(--primary); }
.check-row { display: flex; align-items: center; gap: 10px; min-height: 28px; font-size: 14px; cursor: pointer; }
.check-row input { flex: none; width: 18px; height: 18px; margin: 0; }
@media (pointer: coarse) { .check-row { min-height: 40px; } .check-row input { width: 22px; height: 22px; } }
.check-row.small { font-size: 13px; color: var(--ink-2); }
.input-wrap { position: relative; }
.input-wrap input { padding-right: 44px; }
.input-wrap .icon-btn { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); }
.search { position: relative; }
.search > .ic { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--ink-3); pointer-events: none; }
.search input { padding-left: 38px; }
.filter-toggle { display: none; }
.inline-form { display: flex; align-items: end; gap: 10px; }

/* Segmented choices: radios (.seg label) and toggle buttons (.seg-buttons button) share one look */
.seg-field { border: 0; padding: 0; margin: 0; min-width: 0; display: grid; gap: 6px; }
.seg-field > legend { padding: 0; margin-bottom: 6px; }
.seg {
  display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 3px;
  background: var(--paper); border: 2px solid var(--edge); border-radius: var(--r);
}
.seg label { position: relative; flex: 1; cursor: pointer; }
.seg input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; cursor: pointer; }
.seg label span, .seg-buttons button {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  height: 32px; padding: 0 12px; font-size: 13.5px; font-weight: 500; white-space: nowrap;
  color: var(--ink-2); background: none; border: 0; border-radius: var(--r-sm);
  transition: background-color 0.15s, color 0.15s, box-shadow 0.15s;
}
.seg input:checked + span, .seg-buttons [aria-pressed="true"] {
  color: var(--on-primary); font-weight: 650; background: var(--primary);
}
.seg input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 1px; }
.seg label:hover input:not(:checked) + span, .seg-buttons button[aria-pressed="false"]:hover { color: var(--ink); background: var(--paper-2); }
.icon-seg button { width: 36px; padding: 0; }

/* Tabs: an underlined row for filters */
.tabs { display: flex; gap: 22px; overflow-x: auto; border-bottom: 2px solid var(--rule); margin-bottom: 18px; scrollbar-width: none; }
.tabs button {
  display: inline-flex; align-items: center; gap: 7px; flex: none;
  min-width: 32px; justify-content: center; padding: 9px 2px 10px; font-size: 14px; font-weight: 500; color: var(--ink-3);
  background: none; border: 0; box-shadow: inset 0 -2px 0 transparent;
}
.tabs button:hover { color: var(--ink); }
.tabs [aria-pressed="true"] { color: var(--ink); font-weight: 650; box-shadow: inset 0 -3px 0 var(--ink); }
.count { font-size: 12.5px; font-weight: 500; color: var(--ink-3); font-stretch: var(--narrow); font-variant-numeric: tabular-nums; }

/* ============================================================
   App shell: indigo rail with index-tab navigation
   ============================================================ */
.app { min-height: 100vh; }
.rail {
  position: fixed; inset: 0 auto 0 0; z-index: 30;
  width: var(--rail-w);
  display: flex; flex-direction: column;
  padding: 18px 0 16px 14px;
  background: var(--rail); color: var(--rail-ink);
  overflow-y: auto; scrollbar-width: none;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 10px 22px; color: inherit; text-decoration: none;
  font-size: 1.2rem; font-weight: 800; font-stretch: var(--wide); letter-spacing: -0.02em;
}
.logo { width: 30px; height: 30px; flex: none; }
.rail-nav, .rail-foot { display: grid; gap: 2px; }
.rail-gap { height: 14px; }
.rail-nav a, .rail-foot a, .rail-btn {
  position: relative;
  display: flex; align-items: center; gap: 12px;
  height: 40px; padding: 0 12px;
  font-size: 14.5px; font-weight: 500; text-decoration: none;
  color: var(--rail-ink-2); background: none; border: 0; border-radius: var(--r) 0 0 var(--r);
  transition: color 0.15s, background-color 0.15s;
}
.rail-nav a:hover, .rail-foot a:hover, .rail-btn:hover { color: var(--rail-ink); background: var(--rail-2); }
/* The current page is an index tab that joins the page, with inverted corners above and below */
.rail-nav a[aria-current="page"], .rail-foot a[aria-current="page"] { color: var(--ink); background: var(--ground); font-weight: 650; }
.rail-nav a[aria-current="page"]::before, .rail-nav a[aria-current="page"]::after,
.rail-foot a[aria-current="page"]::before, .rail-foot a[aria-current="page"]::after {
  content: ""; position: absolute; right: 0; width: 12px; height: 12px; pointer-events: none;
}
.rail-nav a[aria-current="page"]::before, .rail-foot a[aria-current="page"]::before { top: -12px; background: radial-gradient(circle at 0 0, transparent 11.5px, var(--ground) 12px); }
.rail-nav a[aria-current="page"]::after, .rail-foot a[aria-current="page"]::after { bottom: -12px; background: radial-gradient(circle at 0 100%, transparent 11.5px, var(--ground) 12px); }
.rail .badge {
  margin-left: auto; margin-right: 6px; min-width: 22px; padding: 0 6px; height: 20px;
  display: grid; place-items: center; font-size: 12px; font-weight: 600; font-stretch: var(--narrow);
  color: var(--rail-ink); background: var(--rail-2); border-radius: 10px;
}
.rail .badge.late { color: #fff; background: #c43a30; }
.rail a[aria-current="page"] .badge { color: var(--ink); background: var(--paper); }
.rail a[aria-current="page"] .badge.late { color: #fff; background: var(--pen); }
.rail-foot { margin-top: auto; padding-top: 18px; padding-right: 14px; }
.rail-foot a, .rail-btn { border-radius: var(--r); font-size: 13.5px; height: 36px; }
.rail-foot a[aria-current="page"] { border-radius: var(--r) 0 0 var(--r); margin-right: -14px; }
.profile {
  display: flex; align-items: center; gap: 10px; margin: 10px 0 4px; padding: 8px;
  text-align: left; color: inherit; background: var(--rail-2); border: 0; border-radius: var(--r);
}
.profile:hover { background: color-mix(in oklab, var(--rail-2) 80%, white); }
.profile-text { display: grid; min-width: 0; line-height: 1.25; }
.profile-text b { font-size: 13.5px; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-text small { font-size: 12px; color: var(--rail-ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.avatar { width: 34px; height: 34px; flex: none; border-radius: 50%; object-fit: cover; }
.avatar.default {
  display: grid; place-items: center; font-weight: 800; font-stretch: var(--wide); font-size: 15px;
  color: var(--rail); background: var(--hl); box-shadow: inset 0 0 0 2px var(--rail);
}
.avatar.xl { width: 76px; height: 76px; font-size: 30px; }

.main { margin-left: var(--rail-w); min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 8px;
  height: 60px; padding: 0 40px;
  background: transparent; border-bottom: 2px solid transparent;
  transition: background-color 0.2s, border-color 0.2s;
}
.topbar.scrolled { background: var(--ground); border-color: var(--edge); }
.menu-btn, .crumb { display: none; }
.crumb { font-weight: 650; }
.search-btn {
  display: flex; align-items: center; gap: 10px;
  width: min(300px, 40vw); height: 38px; padding: 0 8px 0 12px;
  color: var(--ink-3); font-size: 14px; text-align: left;
  background: var(--paper); border: 2px solid var(--edge); border-radius: var(--r); box-shadow: var(--shadow-sm);
}
.search-btn:hover { color: var(--ink-2); }
.search-text { flex: 1; }
.timer-chip {
  display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 12px;
  font-size: 13.5px; font-weight: 600; font-stretch: var(--narrow); font-variant-numeric: tabular-nums;
  color: var(--on-primary); background: var(--primary); border: 2px solid var(--edge); border-radius: var(--r); box-shadow: var(--shadow-sm);
}
.timer-chip .ic { width: 16px; height: 16px; }
.timer-chip.paused { color: var(--ink); background: var(--paper); }
.timer-chip.on-break:not(.paused) { color: #fff; background: var(--c-aqua); }
.timer-chip[hidden] { display: none; }
.sync { margin-left: auto; font-size: 12.5px; color: var(--ink-3); }
.sync.error { color: var(--pen); }

.content { max-width: 1200px; padding: 12px 40px 96px; outline: none; }
/* A new page lands in pieces: header first, then each sheet a beat later (see Motion below) */
.scrim { display: none; }

/* ============================================================
   Page structure
   ============================================================ */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px 24px; flex-wrap: wrap; margin: 12px 0 26px; }
.lede { margin-top: 10px; max-width: 64ch; color: var(--ink-2); font-size: 15.5px; }
.lede b { color: var(--ink); }
.head-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.head-search { width: 280px; }

.sheet { background: var(--paper); border: 2px solid var(--edge); border-radius: var(--r-lg); padding: 18px 22px; box-shadow: var(--lift); }
.sheet + .sheet { margin-top: 24px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; min-height: 32px; }
.sheet-head h2 { display: flex; align-items: baseline; gap: 10px; }
.sheet-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.sheet-head h2 .muted { font-size: 13.5px; font-weight: 500; font-stretch: 100%; }
.sheet-head:not(:first-child) { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--rule); }
.list-head {
  display: flex; align-items: center; gap: 8px;
  margin: 16px 0 2px; padding-bottom: 6px;
  font-size: 13px; font-weight: 650; color: var(--ink-2);
}
.list-head:first-child, .sheet-head + .list-head { margin-top: 4px; }
.pen-head { color: var(--pen); }
.empty { padding: 32px 12px; text-align: center; }
.empty p { max-width: 46ch; margin: 0 auto 14px; color: var(--ink-2); }
.empty p:last-child { margin-bottom: 0; }

/* Tags, priority and status */
.tag { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-2); white-space: nowrap; }
.tag i { width: 9px; height: 9px; border-radius: 2px; background: var(--sub); }
.prio { display: inline-flex; align-items: flex-end; gap: 2px; height: 13px; flex: none; }
.prio i { width: 3px; border-radius: 1px; background: var(--rule-strong); }
.prio i:nth-child(1) { height: 5px; }
.prio i:nth-child(2) { height: 9px; }
.prio i:nth-child(3) { height: 13px; }
.prio.p-low i:nth-child(1), .prio.p-medium i:nth-child(-n+2) { background: var(--ink-2); }
.prio.p-high i { background: var(--pen); }
.status {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  height: 26px; padding: 0 10px 0 8px; font-size: 12.5px; font-weight: 550; white-space: nowrap;
  color: var(--ink-2); background: var(--paper); border: 1.5px solid var(--rule-strong); border-radius: var(--r);
}
.status::before { content: ""; width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid currentColor; }
.status.s-doing::before { background: linear-gradient(90deg, currentColor 50%, transparent 50%); }
.status.s-done { color: var(--ok); }
.status.s-done::before { background: currentColor; }
.status:hover { border-color: var(--edge); color: var(--ink); }

/* Task rows: a subject-coloured tab, a check, the task, its priority */
.task-row {
  position: relative;
  display: flex; align-items: center; gap: 12px;
  min-height: 56px; padding: 6px 4px 6px 14px;
  border-top: 1px solid var(--rule);
}
.list-head + .task-row, .sheet-head + .task-row, .task-row:first-child { border-top-color: transparent; }
.task-row::before, .plan-row::before, .card-task::before, .ahead-task::before, .next-test::before, .log li::before, .effort-list li::before, .mini-blocks li::before {
  content: ""; position: absolute; left: 0; top: 50%; width: 10px; height: 10px; margin-top: -5px;
  border-radius: 2px; background: var(--sub); box-shadow: inset 0 0 0 1.5px var(--sub-edge);
}
.task-row:hover { background: var(--paper-2); }
.task-main {
  flex: 1; min-width: 0; display: grid; gap: 1px; padding: 4px 0;
  text-align: left; background: none; border: 0; border-radius: var(--r-sm);
}
.task-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-sub { display: flex; align-items: center; flex-wrap: wrap; gap: 0 2px; font-size: 13px; color: var(--ink-3); }
.task-sub .sep, .ahead-task small .sep { margin: 0 6px; color: var(--rule-strong); }
.meta-bit { display: inline-flex; align-items: center; gap: 3px; margin-left: 10px; font-stretch: var(--narrow); }
.is-done .task-name { color: var(--ink-3); text-decoration: line-through; text-decoration-color: var(--rule-strong); }
.check {
  display: grid; place-items: center; flex: none;
  width: 24px; height: 24px; padding: 0;
  color: transparent; background: var(--paper); border: 2px solid var(--edge); border-radius: 50%;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}
.check .ic { width: 14px; height: 14px; stroke-width: 2.6; }
.check:hover { border-color: var(--ink); color: var(--ink-3); }
.check[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--paper); }

/* ============================================================
   Today
   ============================================================ */
.date-title { display: flex; align-items: baseline; flex-wrap: wrap; gap: 0 0.3em; font-size: clamp(2.5rem, 1.6rem + 3.4vw, 4.4rem); }
.dt-day { font-weight: 850; font-stretch: var(--wide); }
.dt-date { font-weight: 300; font-stretch: var(--narrow); letter-spacing: -0.01em; color: var(--ink-2); }
.today-head { display: block; }

.quick {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 4px 10px;
  margin-bottom: 20px; padding: 6px 6px 6px 14px;
  background: var(--paper); border: 2px solid var(--edge); border-radius: var(--r-lg); box-shadow: var(--shadow);
  transition: box-shadow 0.1s, transform 0.1s;
}
.quick:focus-within { transform: translate(-1px, -1px); box-shadow: var(--lift); }
.quick-ic { color: var(--ink-3); display: grid; }
.quick input:not([type]) { height: 40px; padding: 0; border: 0; background: none; box-shadow: none; font-size: 15.5px; }
.quick-preview {
  grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px;
  min-height: 30px; padding: 6px 0 4px; border-top: 1px dashed var(--rule); font-size: 13px; color: var(--ink-2);
}
.quick-preview > span { display: inline-flex; align-items: center; gap: 5px; }

/* The day ribbon */
.ribbon-sheet { padding: 16px 22px 14px; overflow-x: auto; margin-bottom: 20px; scrollbar-width: thin; }
.ribbon {
  position: relative; min-width: 780px; margin-left: 66px;
  background-image: linear-gradient(to right, var(--rule) 1px, transparent 1px);
  background-size: calc(100% / var(--hours)) calc(100% - 22px);
  background-position: 0 22px;
  background-repeat: repeat-x;
}
.rb-hours { position: relative; height: 22px; }
.rb-hours span { position: absolute; top: 0; transform: translateX(-50%); font-size: 12px; color: var(--ink-3); font-stretch: var(--narrow); font-variant-numeric: tabular-nums; }
.rb-lane { position: relative; height: 46px; border-top: 1px solid var(--rule); }
/* Lane names stay pinned to the left edge while the ribbon scrolls sideways on small screens. */
.rb-label {
  position: sticky; left: 0; z-index: 3; display: flex; align-items: center; width: 62px; height: 100%; margin-left: -66px;
  font-size: 12.5px; font-weight: 600; color: var(--ink-3); background: var(--paper);
  box-shadow: -24px 0 0 var(--paper); /* covers the gap to the edge, so scrolled text can't peek out beside the name */
}
.rb-none { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); font-size: 12.5px; color: var(--ink-3); }
.rb {
  position: absolute; top: 6px; bottom: 6px;
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
  min-width: 6px; padding: 0 8px 0 7px; overflow: hidden;
  font-size: 12.5px; font-weight: 600; text-align: left; color: var(--ink);
  background: var(--sub-soft); border: 1.5px solid var(--sub-edge); border-radius: var(--r-sm); box-shadow: 2px 2px 0 var(--sub-edge);
}
.rb span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* The start time gives way to the name whenever the block is too narrow for both. */
.rb { container-type: inline-size; }
@container (max-width: 104px) { .rb time { display: none; } }
/* Today: finished blocks step back, the one happening now gets the highlighter. */
.rb.past { opacity: 0.5; box-shadow: none; }
.rb.is-now { box-shadow: 3px 3px 0 var(--hl); border-color: var(--ink); }
.rb time { font-size: 11.5px; font-weight: 500; color: var(--ink-2); }
.hatched, .rb.planned, .wk-block.planned {
  background-color: var(--paper);
  background-image: repeating-linear-gradient(135deg, var(--sub-soft) 0 5px, transparent 5px 9px);
}
.rb.planned, .wk-block.planned { border-style: dashed; box-shadow: none; }
.rb.planned:hover { background-color: var(--sub-soft); }
.rb-pin {
  position: absolute; top: 0; bottom: 0; display: flex; align-items: center;
  padding: 0 0 0 9px; margin-left: -1px; max-width: 200px;
  font-size: 12.5px; font-weight: 600; color: var(--ink); background: none; border: 0;
  border-left: 2px solid var(--ink); border-radius: 0;
}
.rb-pin span { padding: 2px 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; background: var(--paper); border-radius: 4px; }
/* Two rows of labels (see dueLayout in views-plan.js); LABEL there matches this max-width. */
.rb-pin { max-width: 22%; }
.rb-lane.rb-due { height: 56px; }
.rb-pin.row-0 { bottom: 50%; }
.rb-pin.row-1 { top: 50%; }
/* Shrunken marker: centred on its time whichever side the label would have gone (beats .flip below). */
.rb-pin.mini, .rb-pin.mini.flip { top: 30%; bottom: 30%; padding: 0; width: 24px; margin-left: -12px; border: 0; justify-content: center; transform: none; }
.rb-pin.mini::before { content: ''; width: 3px; height: 100%; background: currentColor; border-radius: 2px; }
.rb-pin.mini span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
/* A timetable study block with planned sessions inside: a quiet band behind them. */
.rb.band { z-index: 0; padding: 0; background-color: transparent; border-style: dashed; box-shadow: none; opacity: 0.6; pointer-events: none; }
.rb-pin:hover span { background: var(--paper-2); }
.rb-pin.late { border-color: var(--pen); color: var(--pen); }
.rb-pin.flip { padding: 0 9px 0 0; border-left: 0; border-right: 2px solid var(--ink); transform: translateX(-100%); margin-left: 1px; justify-content: flex-end; }
.rb-pin.flip.late { border-right-color: var(--pen); }
.rb-pin.flip.done { border-right-color: var(--rule-strong); }
.rb-pin.done { border-color: var(--rule-strong); color: var(--ink-3); }
.rb-pin.done span { text-decoration: line-through; }
.rb-now {
  position: absolute; top: 18px; bottom: 0; z-index: 2; width: 3px; margin-left: -1.5px; pointer-events: none;
  background: var(--hl); border-radius: 2px;
}
.rb-now span {
  position: absolute; top: -18px; left: 50%; transform: translateX(-50%);
  padding: 0 5px; font-size: 11.5px; font-weight: 700; font-stretch: var(--narrow); color: var(--hl-ink); background: var(--hl); border-radius: 3px;
}

.today-grid { display: grid; grid-template-columns: minmax(0, 1fr) 290px; gap: 28px; align-items: start; }
.plan-row {
  position: relative; display: flex; align-items: center; gap: 14px;
  min-height: 54px; padding: 6px 4px 6px 14px; border-top: 1px solid var(--rule);
}
.list-head + .plan-row, .plan-day > div > .plan-row:first-child { border-top-color: transparent; }
.plan-row time { flex: none; min-width: 44px; font-size: 14px; font-weight: 600; color: var(--ink-2); }
.done-today { margin-top: 10px; border-top: 1px solid var(--rule); }
.done-today summary, .disclose summary {
  display: flex; align-items: center; gap: 8px; padding: 12px 0; list-style: none;
  font-size: 13.5px; font-weight: 600; color: var(--ink-2); cursor: pointer;
}
.done-today summary::-webkit-details-marker, .disclose summary::-webkit-details-marker, .faq summary::-webkit-details-marker { display: none; }
.chev { margin-left: auto; transition: transform 0.2s; }
details[open] > summary .chev { transform: rotate(180deg); }

.today-side { display: grid; gap: 0; }
.side-block { padding: 16px 0 18px; border-top: 2px solid var(--edge); }
.side-block:first-child { padding-top: 2px; border-top: 0; }
.side-block h2 { font-size: 13.5px; font-weight: 600; font-stretch: 100%; color: var(--ink-2); letter-spacing: 0; }
.figure { display: flex; align-items: baseline; flex-wrap: wrap; gap: 0 8px; margin: 2px 0 10px; font-size: 1.9rem; font-weight: 800; font-stretch: var(--wide); letter-spacing: -0.02em; line-height: 1.15; }
.figure span { font-size: 14px; font-weight: 500; font-stretch: 100%; letter-spacing: 0; color: var(--ink-2); }
.bar { height: 12px; background: var(--paper); border: 2px solid var(--edge); border-radius: 3px; overflow: hidden; margin-bottom: 12px; }
.bar i { display: block; height: 100%; background: var(--ink); }
.next-test {
  position: relative; display: flex; align-items: center; gap: 14px; width: 100%; margin-top: 8px; padding: 6px 8px 6px 14px;
  text-align: left; background: none; border: 2px solid transparent; border-radius: var(--r);
}
.next-test:hover { background: var(--paper); border-color: var(--edge); }
.countdown { display: grid; justify-items: center; gap: 3px; min-width: 46px; font-size: 1.7rem; font-weight: 800; line-height: 1; }
.countdown small { font-size: 12px; font-weight: 500; color: var(--ink-3); }
.countdown.is-now { font-size: 1.15rem; font-stretch: var(--semi-wide); color: var(--hl-ink); background: var(--hl); padding: 4px 6px; border-radius: 4px 8px 4px 9px; }
.next-test b { display: block; font-weight: 650; }
.next-test small { color: var(--ink-3); font-size: 13px; }
.streak-dots { display: grid; grid-template-columns: repeat(14, 1fr); gap: 4px; max-width: 280px; }
.streak-dots span { aspect-ratio: 1; border-radius: 3px; background: var(--rule); }
.streak-dots .on { background: var(--ink); }
.streak-dots .is-today { box-shadow: 0 0 0 2px var(--ground), 0 0 0 4px var(--hl); }

/* Left column of Today: the day's list, then what's coming, so it runs as long as the progress column */
.today-main { display: grid; gap: 24px; min-width: 0; }
.today-main > .sheet + .sheet { margin-top: 0; }

/* Coming up: an agenda, each day marked by a tear-off calendar date */
.ahead .sheet-head .count { font-size: 13px; font-weight: 500; color: var(--ink-3); font-stretch: 100%; }
.ahead-day { display: grid; grid-template-columns: 52px minmax(0, 1fr); gap: 14px; align-items: start; padding: 12px 0; border-top: 1px solid var(--rule); }
.sheet-head + .ahead-day { border-top: 0; padding-top: 4px; }
.tear { display: grid; overflow: hidden; text-align: center; background: var(--paper); border: 2px solid var(--edge); border-radius: var(--r); box-shadow: var(--shadow-sm); }
.tear span { padding: 2px 0 1px; font-size: 11px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--rail-ink); background: var(--rail); }
.tear b { padding: 2px 0 3px; font-size: 20px; font-weight: 800; font-stretch: var(--narrow); line-height: 1.15; }
.is-tomorrow .tear span { color: var(--hl-ink); background: var(--hl); }
.ahead-list { display: grid; gap: 6px; min-width: 0; }
.ahead-task {
  position: relative; display: grid; gap: 1px; width: 100%; padding: 7px 10px 7px 26px;
  text-align: left; font: inherit; color: inherit; cursor: pointer; background: var(--paper-2); border: 2px solid transparent; border-radius: var(--r);
}
@media (hover: hover) { .ahead-task:hover { background: var(--paper); border-color: var(--edge); box-shadow: var(--shadow-sm); } }
.ahead-task::before { left: 9px; }
.at-name { font-size: 14.5px; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ahead-task small { font-size: 12.5px; color: var(--ink-3); }
.ahead-study { display: flex; align-items: center; gap: 6px; margin: 0; padding-left: 10px; font-size: 12.5px; color: var(--ink-3); }
.ahead-free { margin: 0; padding: 6px 0 4px; color: var(--ink-3); }

/* ============================================================
   Tasks
   ============================================================ */
.toolbar { display: grid; grid-template-columns: minmax(200px, 1.6fr) repeat(3, minmax(130px, 1fr)); gap: 12px; align-items: end; margin-bottom: 14px; }
.toolbar .field > label:not(.sr-only) { font-size: 12.5px; }
.list-sheet { padding-top: 10px; padding-bottom: 10px; }
.task-row .status { margin-left: 4px; }

.board { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; align-items: start; }
.board-col {
  min-height: 320px; padding: 12px;
  background: color-mix(in oklab, var(--paper) 45%, var(--ground)); border: 2px dashed var(--rule-strong); border-radius: var(--r-lg);
  transition: background-color 0.15s, border-color 0.15s;
}
.board-col h2 { display: flex; align-items: center; gap: 8px; padding: 2px 4px 10px; font-size: 0.95rem; }
.board-cards { display: grid; gap: 8px; }
.card-task {
  position: relative; display: flex; align-items: flex-start; gap: 10px;
  padding: 8px 12px 8px 22px; background: var(--paper); border: 2px solid var(--edge); border-radius: var(--r);
  box-shadow: var(--shadow-sm); cursor: grab;
}
.card-task::before { left: 6px; }
.card-task .prio { margin-top: 8px; }
.card-task .task-name { white-space: normal; }
@media (hover: hover) { .card-task:hover { box-shadow: var(--shadow); transform: translate(-1px, -1px); } }
[data-drag-task] { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
.dragging { opacity: 0.4; }
.drop-over { background: color-mix(in oklab, var(--hl) 28%, var(--paper)) !important; border-color: var(--ink-3) !important; }
.board-empty { padding: 16px 6px; font-size: 13px; color: var(--ink-3); text-align: center; }

/* ============================================================
   Calendar
   ============================================================ */
.stepper { display: flex; align-items: center; gap: 2px; padding: 2px; background: var(--paper); border: 2px solid var(--edge); border-radius: var(--r); box-shadow: var(--shadow-sm); }
.cal-layout { display: grid; grid-template-columns: minmax(0, 1fr) 310px; gap: 22px; align-items: start; }
.month { background: var(--paper); border: 2px solid var(--edge); border-radius: var(--r-lg); box-shadow: var(--lift); overflow: hidden; }
.month-dow, .month-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.month-dow span { padding: 10px 10px 8px; font-size: 12.5px; font-weight: 600; color: var(--ink-3); border-bottom: 2px solid var(--edge); }
.day-cell { position: relative; min-height: 112px; padding: 32px 6px 6px; border-right: 1px solid var(--rule); border-bottom: 1px solid var(--rule); transition: background-color 0.12s; }
.day-cell:nth-child(7n) { border-right: 0; }
.month-grid .day-cell:nth-last-child(-n+7) { border-bottom: 0; }
.day-cell.out { background: var(--paper-2); }
.day-cell.out .day-num { color: var(--ink-3); font-weight: 400; }
.day-hit { position: absolute; inset: 0; display: flex; align-items: flex-start; padding: 7px 9px; text-align: left; background: none; border: 0; border-radius: 0; }
.day-hit:hover { background: color-mix(in oklab, var(--paper-2) 70%, transparent); }
.day-cell.selected .day-hit { box-shadow: inset 0 0 0 2px var(--ink); }
.day-num { font-size: 13.5px; font-weight: 650; font-stretch: var(--narrow); font-variant-numeric: tabular-nums; }
.is-today .day-num { padding: 0 6px; margin-left: -4px; color: var(--hl-ink); background: var(--hl); border-radius: 4px 7px 4px 8px; }
.day-items { position: relative; display: grid; gap: 3px; pointer-events: none; }
.day-chip {
  pointer-events: auto; display: block; padding: 2px 6px 2px 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 12px; font-weight: 550; background: var(--sub-soft); border: 1.5px solid var(--sub-edge); border-radius: 3px; cursor: grab;
}
.day-chip.done { color: var(--ink-3); text-decoration: line-through; }
.day-chip.late { color: var(--pen); }
.day-more { padding-left: 6px; font-size: 12px; color: var(--ink-3); }
.day-study {
  justify-self: start; padding: 1px 6px; font-size: 11.5px; font-weight: 600; font-stretch: var(--narrow); color: var(--ink-2);
  border: 1.5px dashed var(--sub-edge); border-radius: 3px;
}
.day-panel .plan-row time { min-width: 86px; font-size: 13px; }
.plan-row.is-done .task-name { color: var(--ink-3); text-decoration: line-through; }
.day-dots { display: none; }
.day-panel { position: sticky; top: 76px; }
.day-panel .task-row { padding-right: 0; }
.mini-blocks { list-style: none; margin: 0; padding: 0; }
.mini-blocks li { position: relative; display: flex; gap: 10px; align-items: baseline; padding: 6px 0 6px 14px; font-size: 14px; }
.mini-blocks time { font-size: 13px; color: var(--ink-2); min-width: 82px; }
.mini-blocks .muted { margin-left: auto; font-size: 12.5px; }

/* Week grid: the calendar's week view and the timetable */
.week-sheet { padding: 0; overflow-x: auto; }
.week { min-width: 760px; }
.week-head, .week-body { display: grid; grid-template-columns: 56px repeat(7, minmax(0, 1fr)); }
.week-head { position: sticky; top: 0; border-bottom: 2px solid var(--edge); }
.wk-day {
  display: grid; justify-items: center; gap: 0; padding: 10px 4px 8px;
  background: none; border: 0; border-left: 1px solid var(--rule); border-radius: 0;
}
.wk-day span { font-size: 12.5px; font-weight: 600; color: var(--ink-3); }
.wk-day b { font-size: 1.3rem; font-weight: 800; font-stretch: var(--semi-wide); line-height: 1.2; padding: 0 6px; }
.wk-day small { font-size: 12px; color: var(--ink-3); font-stretch: var(--narrow); }
.wk-day.is-today b { color: var(--hl-ink); background: var(--hl); border-radius: 4px 8px 4px 9px; }
.timetable .wk-day.is-today span { color: var(--ink); }
.timetable .wk-day.is-today { box-shadow: inset 0 -3px 0 var(--hl); }
button.wk-day:hover { background: var(--paper-2); }
.week-body { height: calc(var(--rows) * 50px); }
.wk-axis { display: grid; grid-template-rows: repeat(var(--rows), 1fr); }
.wk-axis span { padding: 2px 8px 0 0; font-size: 11.5px; text-align: right; color: var(--ink-3); font-stretch: var(--narrow); font-variant-numeric: tabular-nums; transform: translateY(-8px); }
.wk-axis span:first-child { transform: none; }
.wk-col {
  position: relative; border-left: 1px solid var(--rule);
  background-image: linear-gradient(to bottom, var(--rule) 1px, transparent 1px);
  background-size: 100% calc(100% / var(--rows));
}
.wk-col.is-today { background-color: color-mix(in oklab, var(--hl) 9%, var(--paper)); }
.timetable .wk-col { cursor: cell; }
.wk-block {
  position: absolute; left: 4px; right: 4px; min-height: 18px;
  display: grid; align-content: start; gap: 0; padding: 4px 7px; overflow: hidden;
  font-size: 12.5px; font-weight: 650; text-align: left; line-height: 1.3; color: var(--ink);
  background-color: var(--sub-soft); border: 1.5px solid var(--sub-edge); border-radius: var(--r-sm); box-shadow: 2px 2px 0 var(--sub-edge);
}
.wk-block span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wk-block time, .wk-block small { font-size: 11.5px; font-weight: 500; color: var(--ink-2); }
button.wk-block { cursor: pointer; }
@media (hover: hover) { button.wk-block:hover { transform: translate(-1px, -1px); box-shadow: 3px 3px 0 var(--sub-edge); } }
/* The chosen study plan, pencilled in: dashed and inset so a timetable block underneath still shows its edge */
.wk-block.planned { left: 12px; z-index: 1; }
button.wk-block.planned:hover { background-color: var(--sub-soft); box-shadow: none; transform: none; }
/* Too short for two lines: name and time share one, the name giving way first */
.wk-block.short { display: flex; align-items: center; gap: 6px; padding-block: 0; }
.wk-block.short span { min-width: 0; }
.wk-block.short time { flex: none; }
.wk-block.planned.done { color: var(--ink-3); }
.wk-block.planned.done span { text-decoration: line-through; }
.wk-task {
  position: absolute; left: 6px; right: 6px; z-index: 2; transform: translateY(-50%);
  display: flex; align-items: center; gap: 5px; padding: 2px 6px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
  font-size: 12px; font-weight: 600; text-align: left; color: var(--ink);
  background: var(--paper); border: 2px solid var(--sub-edge); border-radius: 3px; box-shadow: 2px 2px 0 var(--drop); cursor: grab;
}
.wk-task time { font-size: 11px; color: var(--ink-3); }
.wk-task.done { color: var(--ink-3); text-decoration: line-through; border-color: var(--rule-strong); box-shadow: none; }
.wk-task.late { color: var(--pen); border-color: var(--pen); }
/* Deadlines for each day, in a row of their own under the day names */
.week-due { display: grid; grid-template-columns: 56px repeat(7, minmax(0, 1fr)); border-bottom: 2px solid var(--edge); background: var(--paper-2); }
.wk-due-label { padding: 8px 8px 0 0; font-size: 11.5px; font-weight: 600; text-align: right; color: var(--ink-3); }
.wk-due-col { display: grid; align-content: start; gap: 4px; min-width: 0; min-height: 36px; padding: 6px 4px; border-left: 1px solid var(--rule); }
.week-due .wk-task { position: static; transform: none; min-height: 26px; }
.wk-task span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.wk-more { justify-self: start; min-height: 24px; padding: 0 6px; font-size: 12px; font-weight: 600; color: var(--ink-2); background: none; border: 0; text-decoration: underline; cursor: pointer; }
.wk-now { position: absolute; left: 0; right: 0; height: 3px; margin-top: -1px; background: var(--hl); z-index: 3; pointer-events: none; }
.wk-now::before { content: ""; position: absolute; left: -5px; top: -3.5px; width: 10px; height: 10px; border-radius: 50%; background: var(--hl); }
.legend { display: inline-flex; align-items: center; gap: 8px; margin-right: 6px; font-size: 13px; color: var(--ink-2); }
.legend .key { width: 18px; height: 14px; border-radius: 3px; --sub: var(--ink-3); --sub-soft: color-mix(in oklab, var(--ink-3) 30%, var(--paper)); border: 1.5px solid var(--ink-2); }
.legend .key.solid { background: var(--sub-soft); }
.legend .key.planned { border-style: dashed; }
.legend .key + .key, .legend .key:not(:first-child) { margin-left: 8px; }

/* ============================================================
   Planner
   ============================================================ */
.planner { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 22px; align-items: start; }
.plan-settings { position: sticky; top: 76px; display: grid; gap: 16px; max-height: calc(100vh - 96px); overflow-y: auto; }
.sub-h { margin-top: 8px; padding-top: 16px; border-top: 1px solid var(--rule); }
.plan-settings .hint { margin-top: -10px; }
.effort-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.effort-list li { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) 128px; gap: 10px; align-items: center; padding-left: 20px; }
.effort-name { display: grid; min-width: 0; line-height: 1.3; }
.effort-name b { font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.effort-name small { font-size: 12px; color: var(--ink-3); }
.effort-list select { height: 34px; font-size: 13px; }
.plan-total { padding-bottom: 14px; color: var(--ink-2); }
.plan-total b { color: var(--ink); font-weight: 700; }
.notice {
  display: flex; gap: 12px; align-items: flex-start; margin-bottom: 14px; padding: 12px 14px;
  font-size: 14px; background: var(--paper-2); border: 2px solid var(--edge); border-radius: var(--r); box-shadow: var(--shadow-sm);
}
.notice > .ic { flex: none; box-sizing: content-box; padding: 4px; margin-top: -2px; color: var(--hl-ink); background: var(--hl); border-radius: var(--r-sm); }
.notice > div { flex: 1; min-width: 0; }
.short-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; margin: 8px 0 12px; padding: 0; list-style: none; }
.short-list li { display: flex; justify-content: space-between; gap: 12px; padding-top: 4px; border-top: 1px solid var(--rule); }
.short-list span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.short-list small { flex: none; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.notice-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.notice p { flex: 1; }
.notice .btn { flex: none; align-self: center; }
.plan-day { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 16px; padding: 12px 0; border-top: 2px solid var(--edge); }
.plan-day h3 { display: grid; align-content: start; justify-items: start; padding-top: 14px; font-size: 15px; font-weight: 700; }
.plan-day h3 span { font-size: 13px; font-weight: 500; color: var(--ink-3); font-stretch: var(--narrow); }
.plan-day .plan-row time { min-width: 92px; }

/* ============================================================
   Focus
   ============================================================ */
.focus-layout { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 22px; align-items: start; margin-bottom: 20px; }
.focus-layout .sheet + .sheet { margin-top: 0; }
.focus-sheet { display: grid; gap: 18px; padding-top: 10px; }
.focus-sheet .tabs { margin-bottom: 0; }
.clock { display: flex; justify-content: center; margin-top: 8px; font-size: clamp(3.4rem, 2rem + 4.4vw, 6rem); font-weight: 800; line-height: 1; }
.clock-bar { height: 12px; background: var(--paper); border: 2px solid var(--edge); border-radius: 3px; overflow: hidden; }

/* Split-flap tiles: each digit is a card cut at the hinge into two halves (see setFlaps in
   common.js). On a change the old top leaf falls forward, then the new bottom leaf swings
   down and settles. Only transform and filter animate, on small layers, so it stays smooth. */
.flaps { display: inline-flex; align-items: center; gap: 0.06em; }
.flap {
  position: relative; display: inline-block; width: 0.74em; height: 1.12em; vertical-align: middle;
  color: var(--flap-ink); background: var(--flap); border: 1.5px solid var(--edge); border-radius: 0.07em; box-shadow: var(--shadow-sm);
  font-stretch: 100%; font-variant-numeric: tabular-nums; perspective: 3.4em;
}
.flap-h {
  position: absolute; left: 0; right: 0; height: 50%; overflow: hidden; background: var(--flap);
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
}
.flap-t { top: 0; border-radius: 0.05em 0.05em 0 0; transform-origin: 50% 100%; }
.flap-b { bottom: 0; border-radius: 0 0 0.05em 0.05em; transform-origin: 50% 0; }
.flap-h b { position: absolute; left: 0; right: 0; height: 200%; display: grid; place-items: center; font-weight: inherit; line-height: 1; }
.flap-t b { top: 0; }
.flap-b b { bottom: 0; }
.flap-leaf { z-index: 1; will-change: transform; }
.flap::after { content: ""; position: absolute; z-index: 2; left: 0; right: 0; top: 50%; height: max(1px, 0.03em); transform: translateY(-50%); background: var(--paper); opacity: 0.9; pointer-events: none; }
.flap-sep { padding: 0 0.04em; color: var(--ink); }
.countdown .flap { box-shadow: 2px 2px 0 var(--drop); }
.clock-bar i { display: block; height: 100%; background: var(--ink); transform-origin: left; transition: transform 0.3s var(--out); will-change: transform; }
/* While running the bar gets a fresh target once a second, aligned to the tick, so a 1s linear
   transition makes it creep continuously instead of stepping. */
.clock-bar.ticking i { transition-duration: 1s; transition-timing-function: linear; }
.on-break .clock-bar i { background: var(--c-aqua); }
.clock-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.clock-actions .btn.primary { min-width: 140px; }

/* Charts: thin marks, ink text, recessive grid */
.vbars { position: relative; display: flex; align-items: stretch; gap: 8px; height: 210px; padding: 22px 0 26px; margin: 4px 0 10px; border-bottom: 2px solid var(--edge); }
.vb { position: relative; flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; }
.vb i { display: block; width: min(60%, 34px); min-height: 0; background: var(--c-blue); border: 2px solid var(--edge); border-bottom: 0; border-radius: 3px 3px 0 0; }
.vb-val { font-size: 11.5px; font-weight: 600; color: var(--ink-2); font-stretch: var(--narrow); margin-bottom: 3px; white-space: nowrap; }
.vb-day { position: absolute; bottom: -24px; font-size: 12px; color: var(--ink-3); }
.vb-day.is-today { color: var(--hl-ink); background: var(--hl); padding: 0 5px; border-radius: 3px; font-weight: 600; }
.vb:hover i { filter: brightness(1.1); }
.vb-layer { position: absolute; inset: 22px 0 26px; pointer-events: none; }
.vb-goal { position: absolute; left: 0; right: 0; border-top: 1px dashed var(--ink-3); }
.vb-goal span { position: absolute; left: 0; top: -17px; font-size: 11.5px; color: var(--ink-3); background: var(--paper); padding-right: 6px; }
.hbars { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.hbars li { display: grid; grid-template-columns: 150px minmax(0, 1fr) 56px; gap: 12px; align-items: center; }
.hb-label { overflow: hidden; }
.hb-track { height: 12px; background: var(--paper-2); border: 1.5px solid var(--edge); border-radius: 3px; overflow: hidden; }
.hb-track i { display: block; height: 100%; background: var(--sub); box-shadow: 1.5px 0 0 var(--edge); }
.hbars b { font-size: 13px; font-weight: 600; text-align: right; font-stretch: var(--narrow); }
.log { list-style: none; margin: 0; padding: 0; }
.log li { position: relative; display: grid; grid-template-columns: 170px minmax(0, 1fr) auto auto; gap: 14px; align-items: center; min-height: 44px; padding-left: 14px; border-top: 1px solid var(--rule); }
.log li:first-child { border-top: 0; }
.log time { font-size: 13px; color: var(--ink-2); }
.log span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.log b { font-stretch: var(--narrow); font-weight: 650; }

/* ============================================================
   Grades
   ============================================================ */
.gchart { --label: 150px; --val: 56px; --trend: 64px; display: grid; gap: 4px; padding: 6px 0 4px; }
.g-axis { position: relative; height: 18px; margin: 0 calc(var(--val) + var(--trend) + 28px) 0 calc(var(--label) + 14px); }
.g-axis .g-trend-h { left: auto; right: calc(-1 * (var(--val) + var(--trend) + 28px)); width: var(--trend); transform: none; text-align: center; font-stretch: 100%; }
.g-axis span { position: absolute; transform: translateX(-50%); font-size: 11.5px; color: var(--ink-3); font-stretch: var(--narrow); }
.g-row { display: grid; grid-template-columns: var(--label) minmax(0, 1fr) var(--val) var(--trend); gap: 14px; align-items: center; min-height: 36px; }
.g-label { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.g-track {
  position: relative; height: 26px;
  background-image: repeating-linear-gradient(to right, var(--rule) 0 1px, transparent 1px 25%);
  background-size: calc(100% + 1px) 100%;
  border-left: 1px solid var(--rule-strong);
}
.g-track i { position: absolute; left: 0; top: 4px; bottom: 4px; background: var(--sub); border: 1.5px solid var(--sub-edge); border-left: 0; border-radius: 0 3px 3px 0; }
.spark { display: block; width: var(--trend); height: 26px; overflow: visible; }
.spark polyline { fill: none; stroke: var(--ink-2); stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; }
.spark circle { fill: var(--ink); stroke: var(--paper); stroke-width: 1.5; }
.g-val { font-size: 14px; font-weight: 700; text-align: right; font-stretch: var(--narrow); }
.g-row:hover .g-label { text-decoration: underline; text-decoration-color: var(--rule-strong); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { padding: 8px 10px; font-size: 12.5px; font-weight: 600; text-align: left; color: var(--ink-3); border-bottom: 1px solid var(--rule-strong); }
td { padding: 10px; border-bottom: 1px solid var(--rule); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
td b { font-weight: 600; }
.num { text-align: right; }
.row-actions { white-space: nowrap; text-align: right; width: 72px; }

/* ============================================================
   Settings, contact, help
   ============================================================ */
.settings { display: grid; gap: 20px; max-width: 900px; }
.settings .sheet + .sheet { margin-top: 0; }
.subject-list { list-style: none; margin: 12px 0 18px; padding: 0; }
.subject-list li { display: grid; grid-template-columns: 16px minmax(0, 1fr) 130px 90px 28px; gap: 10px; align-items: center; padding: 6px 0; border-top: 1px solid var(--rule); }
.subject-list li:first-child { border-top: 0; }
.subject-list input, .subject-list select { height: 36px; }
.quiet-input:not(:focus) { border-color: transparent; background: transparent; font-weight: 550; }
.quiet-input:not(:focus):hover { border-color: var(--rule); }
.swatch { width: 16px; height: 16px; border-radius: 3px; background: var(--sub); box-shadow: inset 0 0 0 1.5px var(--sub-edge); }

/* Subject colour picker: a select-looking summary that opens a grid of covers */
.color-pick { position: relative; }
.color-pick summary {
  display: flex; align-items: center; gap: 6px; height: 36px; padding: 0 10px 0 12px; list-style: none;
  font-size: 14px; background: var(--paper); border: 2px solid var(--edge); border-radius: var(--r); cursor: pointer;
}
.color-pick summary::-webkit-details-marker { display: none; }
.color-pick summary:focus-visible, .color-pick[open] summary { outline: none; box-shadow: var(--shadow); }
.cp-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cp-panel {
  position: absolute; z-index: 20; right: 0; top: calc(100% + 6px); width: 232px; padding: 12px;
  background: var(--paper); border: 2px solid var(--edge); border-radius: var(--r-lg); box-shadow: var(--lift);
}
.cp-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cp-swatch {
  aspect-ratio: 1; padding: 0; border: 0; border-radius: 3px; background: var(--sub); cursor: pointer;
  box-shadow: inset 0 0 0 1.5px var(--sub-edge);
}
@media (hover: hover) { .cp-swatch:hover { transform: scale(1.08); } }
.cp-swatch[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--paper), 0 0 0 4px var(--ink); }
.cp-swatch:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--paper), 0 0 0 4px var(--focus); }
.cp-custom { display: flex; align-items: center; gap: 10px; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--rule); font-size: 13.5px; color: var(--ink-2); cursor: pointer; }
.cp-custom input[type="color"] { flex: none; width: 30px; height: 30px; padding: 2px; border-radius: 6px; cursor: pointer; }

/* Subject select plus the "Which subject?" field that "Other" opens */
.subject-pick { display: grid; gap: 10px; align-content: start; }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 20px; align-items: end; margin: 10px 0 8px; }
.data-actions { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px 24px; align-items: center; margin-top: 10px; }
.data-actions .hint { margin-top: 2px; }
.data-actions label.btn { cursor: pointer; }
.feed { display: grid; gap: 12px; margin-top: 10px; }
.feed-link { display: flex; gap: 8px; }
.feed-link input { flex: 1; min-width: 0; font-size: 13px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--ink-2); }
.feed-actions { display: flex; flex-wrap: wrap; gap: 8px; }
@media (pointer: coarse) { .feed-link input { font-size: 16px; } }
.data-actions label.btn:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }

.contact { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 32px; align-items: start; }
.form-sheet { display: grid; gap: 18px; padding: 22px; }
.form-foot { display: flex; justify-content: flex-end; }
.contact-side h2 { margin-bottom: 12px; }
.contact-side .hint { margin-top: 18px; }
.facts { display: grid; gap: 0; margin: 0; }
.facts > div { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 14px; align-items: baseline; padding: 11px 0; border-top: 1px solid var(--rule); }
.facts > div:first-child { border-top: 0; }
.facts dt { font-size: 13px; color: var(--ink-3); }
.facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.facts dd.notes { white-space: pre-line; }
.facts dd .muted { margin-left: 6px; }
.facts .seg { margin-top: -4px; }
.ext { display: inline-flex; align-items: center; gap: 6px; font-weight: 550; }

.faq { padding-top: 4px; padding-bottom: 4px; }
.faq details { border-top: 1px solid var(--rule); }
.faq details:first-child { border-top: 0; }
.faq summary { display: flex; align-items: center; gap: 12px; padding: 16px 0; list-style: none; font-weight: 650; cursor: pointer; }
.faq summary:hover { color: var(--ink-2); }
.faq details p { max-width: 70ch; padding: 0 0 18px; color: var(--ink-2); }

/* ============================================================
   Dialogs, palette, toasts, tooltips
   ============================================================ */
.dialog {
  width: min(640px, calc(100vw - 24px)); max-height: calc(100vh - 48px); padding: 0;
  color: var(--ink); background: var(--paper); border: 2px solid var(--edge); border-radius: var(--r-lg); box-shadow: var(--lift-lg);
}
.dialog[open] { display: flex; flex-direction: column; animation: dialog-in 0.28s cubic-bezier(0.25, 1.3, 0.5, 1); }
.dialog::backdrop { background: var(--scrim); }
/* Dialogs are stamped down: they arrive offset toward their shadow and settle onto it */
@keyframes dialog-in { from { opacity: 0; transform: translate(6px, 10px); box-shadow: 0 0 0 var(--drop); } }
.dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 20px 22px 10px; }
.dialog-head h2 { font-size: 1.35rem; font-weight: 800; font-stretch: var(--semi-wide); letter-spacing: -0.02em; }
.dialog-kicker { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 14px; margin-bottom: 6px; font-size: 13px; color: var(--ink-3); }
.dialog-kicker span { display: inline-flex; align-items: center; gap: 4px; }
.dialog-head .icon-btn { margin: -4px -8px 0 0; }
.dialog-body { display: grid; gap: 16px; padding: 6px 22px 20px; overflow-y: auto; }
.dialog-foot { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding: 14px 22px; border-top: 2px solid var(--edge); background: var(--paper-2); }
.steps h3 { display: flex; gap: 10px; margin-bottom: 6px; }
.steps h3 .muted { font-weight: 500; }
.steps ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.steps li .check-row { padding: 6px 0; }
.steps input:checked + span { color: var(--ink-3); text-decoration: line-through; }
.steps-edit { border: 0; margin: 0; padding: 0; display: grid; gap: 6px; }
.steps-edit legend { padding: 0; margin-bottom: 6px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.steps-edit ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.steps-edit li { display: flex; align-items: center; gap: 6px; }
.steps-edit li input { height: 36px; }
.steps-edit .btn { justify-self: start; }
.file-pick {
  display: flex; align-items: center; gap: 10px; height: 40px; padding: 0 12px; overflow: hidden;
  font-size: 14px; color: var(--ink-2); background: var(--paper); border: 2px dashed var(--edge); border-radius: var(--r); cursor: pointer;
}
.file-pick span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-pick.has-file { color: var(--ink); border-style: solid; }
.file-pick:hover { background: var(--paper-2); }
.file-pick:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }

.palette-dialog { margin-top: 12vh; width: min(600px, calc(100vw - 24px)); }
.pal-search { display: flex; align-items: center; gap: 10px; padding: 8px 14px; border-bottom: 2px solid var(--edge); color: var(--ink-3); }
.pal-search input:not([type]) { height: 48px; padding: 0; font-size: 16px; border: 0; background: none; box-shadow: none; color: var(--ink); }
#paletteList { list-style: none; margin: 0; padding: 6px; max-height: min(420px, 60vh); overflow-y: auto; }
.pal-group { padding: 10px 10px 4px; font-size: 12.5px; font-weight: 600; color: var(--ink-3); }
.pal-item { display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: var(--r); cursor: pointer; color: var(--ink-2); }
.pal-item[aria-selected="true"] { background: var(--paper-2); color: var(--ink); box-shadow: inset 0 0 0 2px var(--edge); }
.pal-label { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 10px; font-weight: 550; }
.pal-label small { font-size: 12.5px; font-weight: 400; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pal-empty { padding: 20px 12px; color: var(--ink-3); font-size: 14px; }
.keys { display: grid; margin: 0; }
.keys > div { display: grid; grid-template-columns: 170px 1fr; gap: 12px; align-items: center; padding: 8px 0; border-top: 1px solid var(--rule); }
.keys > div:first-child { border-top: 0; }
.keys dd { margin: 0; color: var(--ink-2); }

/* Profile */
.pfp-row { display: flex; align-items: center; gap: 18px; }
.pfp-pick { position: relative; cursor: pointer; border-radius: 50%; }
.pfp-pick:focus-within { outline: 2px solid var(--focus); outline-offset: 3px; }
.pfp-cam { position: absolute; right: -2px; bottom: -2px; display: grid; place-items: center; width: 28px; height: 28px; color: var(--on-primary); background: var(--primary); border: 2px solid var(--paper); border-radius: 50%; }
.pfp-cam .ic { width: 14px; height: 14px; }
.pfp-name { font-size: 1.15rem; font-weight: 750; font-stretch: var(--semi-wide); }
.pfp-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.tally { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 0; padding: 14px 0; border-block: 1px solid var(--rule); }
.tally dt { font-size: 12.5px; color: var(--ink-3); }
.tally dd { margin: 2px 0 0; font-size: 1.3rem; font-weight: 800; font-stretch: var(--semi-wide); }
.disclose { border-top: 1px solid var(--rule); }
.stack-form { display: grid; gap: 12px; padding-bottom: 6px; }
.stack-form .btn { justify-self: start; }

.toasts { position: fixed; left: 50%; bottom: 22px; z-index: 60; display: grid; gap: 8px; justify-items: center; transform: translateX(-50%); width: max-content; max-width: calc(100vw - 24px); pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px 10px 14px; pointer-events: auto;
  font-size: 14px; color: var(--paper); background: var(--ink); border: 2px solid var(--edge); border-radius: var(--r); box-shadow: var(--lift);
  animation: toast-in 0.34s cubic-bezier(0.25, 1.4, 0.5, 1);
}
.toast.tone-bad .ic { color: #ff9a8f; }
:root[data-theme="dark"] .toast.tone-bad .ic { color: var(--pen); }
.toast.leaving { opacity: 0; transform: translateY(6px); transition: opacity 0.2s, transform 0.2s; }
.toast-btn { margin-left: 6px; padding: 4px 10px; font-size: 13.5px; font-weight: 650; color: var(--hl-ink); background: var(--hl); border: 0; border-radius: 3px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(16px) scale(0.96); } }
.tip {
  position: fixed; z-index: 80; max-width: 260px; padding: 6px 9px; pointer-events: none;
  font-size: 12.5px; line-height: 1.4; color: var(--paper); background: var(--ink); border-radius: 3px;
  opacity: 0; transition: opacity 0.1s;
}
.tip.on { opacity: 1; }
.tip b { font-weight: 650; }

/* ============================================================
   Sign-in page
   ============================================================ */
.auth { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); min-height: 100vh; }
.auth-art {
  display: flex; flex-direction: column; gap: 22px; padding: 40px 56px 48px;
  color: var(--rail-ink); background: var(--rail);
  --paper: var(--rail);
}
.auth-art .brand { padding: 0; }
.auth-title { margin-top: auto; max-width: 13ch; font-size: clamp(2.4rem, 1.4rem + 3vw, 3.9rem); font-weight: 850; font-stretch: var(--wide); line-height: 1; letter-spacing: -0.03em; }
.auth-lede { max-width: 44ch; color: var(--rail-ink-2); font-size: 16px; }
.auth-ribbon { position: relative; margin-top: 14px; padding-top: 22px; }
.ar-hours { position: absolute; top: 0; left: 0; right: 0; display: flex; justify-content: space-between; font-size: 12px; color: var(--rail-ink-2); font-stretch: var(--narrow); }
.ar-lane { position: relative; height: 40px; border-top: 1px solid color-mix(in oklab, var(--rail-ink) 14%, transparent); }
.ar-block {
  position: absolute; top: 6px; bottom: 6px; display: flex; align-items: center; padding: 0 8px; overflow: hidden; white-space: nowrap;
  font-size: 12px; font-weight: 600; color: var(--rail-ink);
  background: color-mix(in oklab, var(--sub) 32%, var(--rail)); border: 1.5px solid var(--sub); border-radius: 3px; box-shadow: 2px 2px 0 var(--drop);
}
.ar-block.hatched { background: repeating-linear-gradient(135deg, color-mix(in oklab, var(--sub) 34%, var(--rail)) 0 5px, var(--rail) 5px 9px); border-style: dashed; box-shadow: none; }
.ar-pin { position: absolute; top: 0; bottom: 0; display: flex; align-items: center; padding-right: 8px; font-size: 12px; font-weight: 600; border-right: 2px solid var(--rail-ink); transform: translateX(-100%); }
.ar-now { position: absolute; top: 18px; bottom: 0; width: 8px; margin-left: -4px; background: var(--hl); opacity: 0.85; border-radius: 3px; }
.ar-now span { position: absolute; top: -18px; left: 50%; transform: translateX(-50%); padding: 0 5px; font-size: 11px; font-weight: 700; font-stretch: var(--narrow); color: var(--hl-ink); background: var(--hl); border-radius: 3px; }
/* The Home link and theme switch sit in their own row above the form (never on top of it). */
.auth-panel { display: grid; grid-template-rows: auto 1fr; justify-items: center; gap: 24px; padding: 18px 24px 48px; background: var(--ground); }
.auth-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; }
.auth-panel > .auth-form { align-self: center; }
.auth-form { display: grid; gap: 18px; width: min(380px, 100%); }
.auth-form h1 { font-size: 2.3rem; }
.auth-form .lede { margin-top: -8px; }
.auth-tabs { display: flex; }
.auth-tabs button { flex: 1; }
.form-alert { padding: 10px 12px; font-size: 14px; color: var(--pen); background: var(--pen-soft); border: 2px solid var(--pen); border-radius: var(--r); }
.auth-submit { width: 100%; margin-top: 4px; }
.back-home { margin-left: -8px; }
.back-home .ic { transition: translate 0.2s; }
@media (hover: hover) { .back-home:hover .ic { translate: -3px 0; } }


/* ============================================================
   Motion
   One voice everywhere: things land like a stamp on paper. They drop a few pixels with a little
   overshoot and settle onto their hard shadow. Entrances run only when a page is opened fresh
   (.view.enter), never when it re-renders after an edit, so typing and ticking stay still.
   Keyframes use the `translate` property so they never fight a component's own transform, and
   `backwards` fill so nothing keeps a transform (and a new containing block) after it lands.
   ============================================================ */
:root { --land: cubic-bezier(0.25, 1.35, 0.5, 1); --out: cubic-bezier(0.2, 0.8, 0.2, 1); }
@keyframes rise-in { from { opacity: 0; translate: 0 12px; } }
@keyframes drop-in { from { opacity: 0; translate: 0 -10px; } }
@keyframes grow-y { from { transform: scaleY(0); } }
@keyframes grow-x { from { transform: scaleX(0); } }
@keyframes pop { 0% { scale: 0.6; } 60% { scale: 1.18; } 100% { scale: 1; } }
@keyframes draw-check { from { stroke-dashoffset: 24; } to { stroke-dashoffset: 0; } }
@keyframes bump { 40% { scale: 1.35; } }
@keyframes shake { 20%, 60% { translate: -5px 0; } 40%, 80% { translate: 5px 0; } }
@keyframes breathe { 50% { opacity: 0.45; } }
@keyframes sway { 0%, 100% { rotate: -8deg; } 50% { rotate: 8deg; } }
@keyframes spin-in { from { rotate: -120deg; scale: 0.4; opacity: 0; } }
@keyframes tab-in { from { clip-path: inset(0 0 0 100%); } to { clip-path: inset(-12px 0 -12px 0); } }
@keyframes slide-in { from { opacity: 0; translate: -14px 0; } }

/* Page sections arrive one after another */
.view.enter > * { animation: rise-in 0.42s var(--out) backwards; }
.view.enter > :nth-child(2) { animation-delay: 50ms; }
.view.enter > :nth-child(3) { animation-delay: 100ms; }
.view.enter > :nth-child(4) { animation-delay: 150ms; }
.view.enter > :nth-child(5) { animation-delay: 200ms; }
.view.enter > :nth-child(n+6) { animation-delay: 240ms; }

/* Rows inside a freshly opened page follow their sheet down */
.view.enter .task-row, .view.enter .plan-row { animation: rise-in 0.36s var(--out) backwards; animation-delay: 160ms; }
.view.enter .task-row:nth-child(2), .view.enter .plan-row:nth-child(2) { animation-delay: 190ms; }
.view.enter .task-row:nth-child(3), .view.enter .plan-row:nth-child(3) { animation-delay: 220ms; }
.view.enter .task-row:nth-child(4), .view.enter .plan-row:nth-child(4) { animation-delay: 250ms; }
.view.enter .task-row:nth-child(5), .view.enter .plan-row:nth-child(5) { animation-delay: 280ms; }
.view.enter .task-row:nth-child(n+6), .view.enter .plan-row:nth-child(n+6) { animation-delay: 310ms; }

/* Day ribbon: blocks drop into their lanes; the "now" highlighter breathes */
.view.enter .rb, .view.enter .rb-pin, .view.enter .wk-block { animation: drop-in 0.45s var(--land) backwards; animation-delay: 220ms; }
.view.enter .rb:nth-child(odd), .view.enter .wk-block:nth-child(odd) { animation-delay: 280ms; }
.view.enter .rb:nth-child(3n), .view.enter .wk-block:nth-child(3n) { animation-delay: 340ms; }
.rb-now { animation: breathe 2.8s ease-in-out infinite; }
.view.enter .rb-now { animation: rise-in 0.4s 0.45s var(--out) backwards, breathe 2.8s 0.85s ease-in-out infinite; }

/* Charts grow from their baseline */
.view.enter .vb i { transform-origin: bottom; animation: grow-y 0.6s var(--out) backwards; animation-delay: 180ms; }
.view.enter .vb:nth-child(2) i { animation-delay: 220ms; }
.view.enter .vb:nth-child(3) i { animation-delay: 260ms; }
.view.enter .vb:nth-child(4) i { animation-delay: 300ms; }
.view.enter .vb:nth-child(5) i { animation-delay: 340ms; }
.view.enter .vb:nth-child(6) i { animation-delay: 380ms; }
.view.enter .vb:nth-child(n+7) i { animation-delay: 420ms; }
.view.enter .hb-track i, .view.enter .clock-bar i { transform-origin: left; animation: grow-x 0.6s 0.2s var(--out) backwards; }
.view.enter .hbars li:nth-child(even) .hb-track i { animation-delay: 0.26s; }

/* Ticking a task off: the circle pops and the tick is drawn in */
.check.pop { animation: pop 0.38s var(--land); }
.check.pop .ic path { stroke-dasharray: 24; animation: draw-check 0.3s 0.05s ease-out backwards; }
.status.pop { animation: pop 0.3s var(--land); }

/* Count badges bump when their number changes */
.rail .badge.bump { animation: bump 0.35s var(--land); }

/* The current page's index tab slides out of the rail */
@media (min-width: 861px) {
  .rail-nav a[aria-current="page"], .rail-foot a[aria-current="page"] { animation: tab-in 0.3s var(--out); }
}
.rail-nav a .ic, .rail-foot a .ic { transition: translate 0.2s var(--out); }
@media (hover: hover) { .rail-nav a:hover:not([aria-current]) .ic, .rail-foot a:hover:not([aria-current]) .ic { translate: 2px 0; } }

/* On phones the menu's links slide in after the rail */
@media (max-width: 860px) {
  .nav-open .rail-nav a { animation: slide-in 0.3s var(--out) backwards; animation-delay: 80ms; }
  .nav-open .rail-nav a:nth-child(2) { animation-delay: 110ms; }
  .nav-open .rail-nav a:nth-child(3) { animation-delay: 140ms; }
  .nav-open .rail-nav a:nth-child(4) { animation-delay: 170ms; }
  .nav-open .rail-nav a:nth-child(5) { animation-delay: 200ms; }
  .nav-open .rail-nav a:nth-child(n+6) { animation-delay: 230ms; }
}

/* A running timer's stopwatch sways in the top bar */
.timer-chip:not(.paused) .ic { animation: sway 2s ease-in-out infinite; transform-origin: 50% 60%; }

/* The theme icon turns over when you switch */
.ic.spin-in { animation: spin-in 0.45s var(--land); }

/* Fields that fail validation shake once; the sign-in alert does too */
.field.invalid input, .field.invalid select { animation: shake 0.32s ease-in-out; }
.form-alert { animation: shake 0.32s ease-in-out; }

/* Sign-in page: the sample ribbon assembles and the form fields arrive in order */
.auth-art > * { animation: rise-in 0.5s var(--out) backwards; }
.auth-art > :nth-child(2) { animation-delay: 80ms; }
.auth-art > :nth-child(3) { animation-delay: 160ms; }
.auth-art > :nth-child(4) { animation-delay: 220ms; }
.ar-block, .ar-pin { animation: drop-in 0.45s var(--land) backwards; animation-delay: 420ms; }
.ar-block:nth-child(2) { animation-delay: 480ms; }
.ar-block:nth-child(3) { animation-delay: 540ms; }
.ar-block:nth-child(4) { animation-delay: 600ms; }
.ar-lane:nth-child(3) .ar-block:nth-child(1) { animation-delay: 680ms; }
.ar-lane:nth-child(3) .ar-block:nth-child(2) { animation-delay: 740ms; }
.ar-pin { animation-delay: 800ms; }
.ar-now { animation: ar-sweep 1.4s 0.5s var(--out) backwards, breathe 2.8s 2s ease-in-out infinite; }
@keyframes ar-sweep { from { left: 0; opacity: 0; } 10% { opacity: 0.85; } }
.auth-form > * { animation: rise-in 0.45s var(--out) backwards; }
.auth-form > :nth-child(2) { animation-delay: 50ms; }
.auth-form > :nth-child(3) { animation-delay: 100ms; }
.auth-form > :nth-child(n+4) { animation-delay: 150ms; }
.auth-form > .form-alert { animation: shake 0.32s ease-in-out; }

/* ============================================================
   Responsive
   ============================================================ */
/* Large monitors: let the pages use the extra width instead of leaving a blank strip */
@media (min-width: 1600px) {
  .content { max-width: 1440px; }
  .today-grid { grid-template-columns: minmax(0, 1fr) 330px; }
}

@media (max-width: 1180px) {
  .today-grid { grid-template-columns: minmax(0, 1fr); }
  .today-side { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 28px; }
  .side-block:nth-child(2) { padding-top: 2px; border-top: 0; }
  .cal-layout, .planner, .focus-layout { grid-template-columns: minmax(0, 1fr); }
  .day-panel, .plan-settings { position: static; max-height: none; }
  .toolbar { grid-template-columns: 1fr 1fr; }
  .toolbar .search { grid-column: 1 / -1; }
}

@media (max-width: 860px) {
  .rail { transform: translateX(-100%); transition: transform 0.25s ease; box-shadow: none; padding-right: 14px; }
  .nav-open .rail { transform: none; box-shadow: var(--lift-lg); }
  .rail-nav a[aria-current="page"], .rail-foot a[aria-current="page"] { border-radius: var(--r); margin-right: 0; }
  .rail-nav a[aria-current="page"]::before, .rail-nav a[aria-current="page"]::after,
  .rail-foot a[aria-current="page"]::before, .rail-foot a[aria-current="page"]::after { display: none; }
  .scrim { position: fixed; inset: 0; z-index: 25; background: var(--scrim); opacity: 0; pointer-events: none; transition: opacity 0.25s; display: block; }
  .nav-open .scrim { opacity: 1; pointer-events: auto; }
  .main { margin-left: 0; }
  .topbar { padding: 0 12px; gap: 4px; }
  .menu-btn, .crumb { display: inline-grid; }
  .crumb { display: block; margin-right: auto; padding-left: 4px; }
  .search-btn { width: 38px; padding: 0; justify-content: center; border-color: transparent; background: none; box-shadow: none; }
  .search-text, .search-btn kbd, .topbar [data-action="shortcuts"] { display: none; }
  .sync { margin-left: 0; }
  .content { padding: 4px 16px 88px; }
  .grid-2, .settings-grid { grid-template-columns: minmax(0, 1fr); }
  .board { grid-template-columns: repeat(3, 82%); overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: 8px; }
  .board-col { scroll-snap-align: start; }
  .day-cell { min-height: 68px; padding: 30px 4px 6px; }
  .day-items { display: none; }
  .day-dots { display: flex; gap: 3px; position: relative; pointer-events: none; padding-left: 4px; }
  .day-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--sub); }
  .contact { grid-template-columns: minmax(0, 1fr); }
  .auth { grid-template-columns: minmax(0, 1fr); }
  .auth-art { padding: 28px 20px 30px; gap: 16px; }
  .auth-title { margin-top: 18px; }
  .auth-ribbon { display: none; }
  .auth-panel { padding: 14px 16px 56px; gap: 18px; }
  .auth-panel > .auth-form { align-self: start; }
  .plan-day { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .plan-day h3 { grid-auto-flow: column; justify-content: start; gap: 10px; align-items: baseline; padding-top: 4px; }
  .log li { grid-template-columns: minmax(0, 1fr) auto auto; }
  .log time { grid-column: 1 / -1; padding-top: 8px; margin-bottom: -10px; }
  .subject-list li { grid-template-columns: 16px minmax(0, 1fr) 110px 28px; }
  .subject-list li .small { display: none; }
}

@media (max-width: 560px) {
  /* Tasks: subject, type and sort fold behind a Filters button so the list starts higher up. */
  .toolbar .search { display: flex; gap: 8px; }
  .toolbar .search input { flex: 1; min-width: 0; }
  .filter-toggle { display: inline-flex; flex: none; height: auto; }
  .filter-toggle .count { min-width: 18px; padding: 0 5px; color: var(--hl-ink); background: var(--hl); border-radius: 9px; text-align: center; }
  .toolbar:not(.filters-open) > .field:not(.search) { display: none; }
  .filter-toggle[aria-expanded="true"] { translate: 2px 2px; box-shadow: none; background: var(--paper-2); }
  /* Grades: each result becomes a two-line row instead of a table that scrolls sideways. */
  .grades-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .grades-table tr {
    display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; column-gap: 10px; align-items: center;
    grid-template-areas: "title title pct act" "sub date score act";
    padding: 10px 0; border-bottom: 1px solid var(--rule);
  }
  .grades-table tbody tr:last-child { border-bottom: 0; }
  .grades-table td { padding: 0; border: 0; }
  .grades-table td:nth-child(1) { grid-area: title; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .grades-table td:nth-child(2) { grid-area: sub; font-size: 13px; }
  .grades-table td:nth-child(3) { grid-area: date; font-size: 13px; color: var(--ink-3); white-space: nowrap; }
  .grades-table td:nth-child(4) { grid-area: score; font-size: 12.5px; color: var(--ink-3); }
  .grades-table td:nth-child(5) { grid-area: pct; font-size: 18px; }
  .grades-table td:nth-child(6) { grid-area: act; width: auto; }
  .today-side { grid-template-columns: minmax(0, 1fr); }
  .side-block:nth-child(2) { padding-top: 16px; border-top: 2px solid var(--edge); }
  .page-head { align-items: stretch; }
  .head-actions { width: 100%; }
  .head-actions .btn.primary { margin-left: auto; }
  .head-search { width: 100%; }
  .sheet { padding: 14px 14px; }
  .task-row .status { display: none; }
  .hbars li, .gchart { --label: 96px; }
  .gchart { --trend: 0px; }
  .gchart .spark, .g-trend-h { display: none; }
  .hbars li { grid-template-columns: 96px minmax(0, 1fr) 48px; }
  .facts > div { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .dialog { max-height: calc(100vh - 16px); }
  .dialog-foot .hint { display: none; }
  .tally { grid-template-columns: 1fr 1fr; }
  .keys > div { grid-template-columns: 1fr; gap: 4px; }
  .data-actions { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .data-actions > div:not(:first-child) { margin-top: 12px; }
}

/* Small phones: the subject name keeps the room; the swatch beside it already shows the colour */
@media (max-width: 420px) {
  .subject-list li { grid-template-columns: 16px minmax(0, 1fr) 56px 36px; gap: 8px; }
  .color-pick .cp-name { display: none; }
  .color-pick summary { justify-content: center; padding: 0 8px; }
  .effort-list li { grid-template-columns: minmax(0, 1fr) 112px; }
}

/* Touch screens: fingers need bigger targets, iOS zooms into any field under 16px,
   and keyboard shortcuts mean nothing without a keyboard */
@media (pointer: coarse) {
  :root input:not([type="checkbox"], [type="radio"], [type="range"], [type="file"]), :root select, :root textarea { font-size: 16px; }
  .btn.sm { height: 38px; }
  .icon-btn { width: 40px; height: 40px; }
  .icon-btn.sm { width: 36px; height: 36px; }
  .seg label span, .seg-buttons button { height: 38px; }
  .check { width: 26px; height: 26px; }
  input[type="checkbox"], input[type="radio"] { width: 20px; height: 20px; }
  .kbd-only, .search-btn kbd, .pal-item kbd, .topbar [data-action="shortcuts"] { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
}

@media (forced-colors: active) {
  .task-row::before, .rb, .wk-block, .day-chip { border: 1px solid CanvasText; }
  .hl, .rb-now { forced-color-adjust: none; }
}

/* "What do I need?" result: a paper slip; the highlighter marks a reachable target, red pen an impossible one. */
.target-result { display: grid; gap: 4px; padding: 14px 16px; background: var(--paper-2); border: 2px solid var(--edge); border-radius: var(--r); box-shadow: var(--shadow-sm); }
.target-result > b { font-size: 30px; font-weight: 800; font-stretch: var(--wide, 112%); line-height: 1.1; justify-self: start; padding: 0 6px; color: var(--hl-ink); background: var(--hl); border-radius: var(--r-sm); }
.target-result > span { font-size: 14px; color: var(--ink-2); }
.target-result.out > b, .target-result.safe > b { font-size: 16px; padding: 0; color: var(--ink); background: none; }
.target-result.out > b { color: var(--pen); }

/* "Open on your phone" */
.phone-dialog { width: min(440px, calc(100vw - 32px)); }
.phone-qr { justify-self: center; padding: 12px; background: #fff; border: 2px solid var(--edge); border-radius: var(--r); box-shadow: var(--shadow-sm); }
.phone-qr img, .phone-qr canvas { display: block; width: 184px; height: 184px; }
.phone-dialog .dialog-body { grid-template-columns: minmax(0, 1fr); }
.phone-cmd { margin: 8px 0; padding: 10px 12px; white-space: pre-wrap; word-break: break-all; font-size: 12.5px; line-height: 1.5; color: var(--ink); background: var(--paper); border: 1px solid var(--rule-strong); border-radius: var(--r-sm); }
/* Already on a phone: the top-bar shortcut has nothing to offer, Settings still has it. */
@media (pointer: coarse), (max-width: 560px) { .phone-btn { display: none; } }

/* Evening review */
.review { gap: 18px; }
.review-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.review-stats div { display: grid; gap: 2px; padding: 10px 12px; background: var(--paper-2); border: 2px solid var(--edge); border-radius: var(--r); }
.review-stats b { font-size: 24px; font-weight: 800; font-stretch: var(--wide); line-height: 1.1; }
.review-stats span { font-size: 12.5px; color: var(--ink-2); }
.review-done { display: flex; flex-wrap: wrap; gap: 6px; }
.review-done span { padding: 2px 8px; font-size: 13px; text-decoration: line-through; text-decoration-color: var(--ink-3); background: var(--sub-soft); border: 1.5px solid var(--sub-edge); border-radius: var(--r-sm); }
.review-row { display: flex; align-items: center; gap: 12px; padding: 10px 0 10px 14px; border-top: 1px solid var(--rule); position: relative; }
.review-row::before { content: ''; position: absolute; left: 0; top: 18px; width: 8px; height: 8px; background: var(--sub); border-radius: 2px; }
.review-row .task-main { flex: 1; min-width: 0; display: grid; gap: 2px; }
.review-seg { flex: none; }
.review-seg button { padding: 0 10px; font-size: 13px; }
.review-warn { display: flex; align-items: center; gap: 6px; color: var(--pen); font-size: 14px; font-weight: 600; }
.today-grid .sheet-head .head-actions { display: flex; flex-wrap: wrap; gap: 4px; justify-content: flex-end; }
@media (max-width: 560px) {
  .review-row { flex-wrap: wrap; }
  .review-seg { width: 100%; }
  .review-seg button { flex: 1; }
  .review-stats b { font-size: 20px; }
}

/* Backups and account deletion */
.btn-pair { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.backup-list { display: grid; margin: 0; padding: 0; list-style: none; }
.backup-list li { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--rule); }
.backup-list li:first-child { border-top: 0; }
.backup-main { flex: 1; min-width: 0; display: grid; gap: 2px; }
.backup-main b { font-weight: 600; }
.backup-main small { font-size: 12.5px; color: var(--ink-2); }
.link-btn { padding: 0; font: inherit; font-weight: 600; color: var(--ink); background: none; border: 0; text-decoration: underline; cursor: pointer; }
.btn.danger-fill { color: #fff; background: var(--pen); border-color: var(--pen); }
@media (max-width: 560px) { .data-actions .btn-pair { justify-content: flex-start; } }

/* Offline fallback page */
.offline-page { display: grid; justify-items: start; gap: 16px; max-width: 480px; margin: 0 auto; padding: max(15vh, 48px) 24px 48px; }
.offline-page h1 { font-size: clamp(2rem, 7vw, 3rem); font-weight: 800; font-stretch: var(--wide); letter-spacing: -0.02em; }

/* Reminders dialog: one section per channel */
.rem-channel { display: grid; gap: 8px; padding-top: 14px; border-top: 1px solid var(--rule); }
.rem-channel h3 { font-size: 15px; font-weight: 700; }
.rem-channel > .btn { justify-self: start; }

/* Admin page */
.admin-state { display: flex; gap: 12px; align-items: flex-start; padding: 12px 0; border-top: 1px solid var(--rule); }
.admin-state:first-of-type { border-top: 0; }
.admin-state > .ic { flex: none; box-sizing: content-box; padding: 4px; border-radius: var(--r-sm); }
.admin-state.ok > .ic { color: var(--hl-ink); background: var(--hl); }
.admin-state.bad > .ic { color: #fff; background: var(--pen); }
.admin-state b { font-weight: 650; }
.admin-state > div { min-width: 0; }
.admin-state .hint { overflow-wrap: anywhere; } /* long folder paths */
.admin-storage { padding-top: 10px; border-top: 1px solid var(--rule); }
.admin-numbers { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.admin-numbers div { display: grid; gap: 2px; padding: 12px; background: var(--paper-2); border: 2px solid var(--edge); border-radius: var(--r); }
.admin-numbers b { font-size: 26px; font-weight: 800; font-stretch: var(--wide); line-height: 1.1; }
.admin-numbers span { font-size: 12.5px; color: var(--ink-2); }
.admin-msg { display: grid; gap: 8px; padding: 14px 0; border-top: 1px solid var(--rule); }
.admin-msg:first-child { border-top: 0; }
.admin-msg header { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; }
.admin-msg.unread header b::before { content: ''; display: inline-block; width: 8px; height: 8px; margin-right: 8px; background: var(--hl); border-radius: 2px; }
.admin-msg p { white-space: normal; overflow-wrap: anywhere; }
.admin-badge { padding: 0 6px; font-size: 11.5px; font-weight: 700; color: var(--hl-ink); background: var(--hl); border-radius: 3px; }
.temp-pass code { display: inline-block; padding: 8px 14px; font-size: 22px; letter-spacing: 0.08em; background: var(--paper-2); border: 2px solid var(--edge); border-radius: var(--r); user-select: all; }

/* Several files and links per task */
.att-list { display: grid; gap: 4px; }
.att-list a { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
.att-list a > span:first-of-type { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#linkList, .file-list { display: grid; gap: 6px; margin: 0 0 8px; padding: 0; list-style: none; }
#linkList li { display: flex; gap: 6px; align-items: center; }
#linkList input { flex: 1; min-width: 0; }
.file-list li { display: flex; gap: 8px; align-items: center; min-height: 36px; padding: 4px 4px 4px 10px; background: var(--paper-2); border: 1px solid var(--rule); border-radius: var(--r-sm); }
.file-list .file-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.file-list .muted { flex: none; font-size: 12.5px; }
.file-add { cursor: pointer; }
.file-add:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }
legend .muted { font-weight: 400; font-size: 12.5px; }

/* Flashcards */
.card-list small { overflow-wrap: anywhere; }

/* Flashcards page: every card in one list, its subject as a coloured tag */
.cards-search { max-width: 420px; margin-bottom: 14px; }
.card-row { position: relative; display: flex; align-items: center; gap: 10px; min-height: 60px; padding: 8px 6px 8px 18px; border-top: 1px solid var(--rule); }
.card-row:first-child { border-top: 0; }
.card-row::before { content: ''; position: absolute; left: 0; top: 10px; bottom: 10px; width: 5px; background: var(--sub); border-radius: 0 3px 3px 0; }
.card-main { flex: 1; min-width: 0; display: grid; gap: 2px; padding: 4px 0; text-align: left; font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
.card-main b { font-size: 15px; overflow-wrap: anywhere; }
.card-main small { font-size: 13.5px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-main:hover b { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 3px; }
.card-tags { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px; max-width: 40%; }
.subj-tag, .test-tag { display: inline-block; max-width: 100%; padding: 2px 8px; font-size: 12px; font-weight: 650; color: var(--ink); border-radius: 999px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.subj-tag { background: color-mix(in srgb, var(--sub, var(--c-slate)) 20%, transparent); }
.test-tag { color: var(--hl-ink); background: var(--hl); }

/* Practising: a progress line, the card (tap it to turn it over), and Previous / Next */
.study { padding-block: 6px 22px; }
.practice-bar { height: 6px; background: var(--rule); border-radius: 3px; overflow: hidden; }
.practice-bar span { display: block; height: 100%; background: var(--primary); border-radius: 3px; transition: width 0.3s; }
.flashcard {
  display: grid; gap: 14px; align-content: center; justify-items: center; width: 100%; min-height: 240px; padding: 22px; font: inherit; color: var(--ink); text-align: center; cursor: pointer;
  background: var(--paper-2); border: 2px solid var(--edge); border-top: 10px solid var(--sub, var(--edge)); border-radius: var(--r-lg); box-shadow: 5px 5px 0 var(--sub, var(--drop));
}
.flashcard .subj-tag { font-size: 11.5px; }
.fc-front { font-size: clamp(1.25rem, 4.5vw, 1.7rem); font-weight: 750; overflow-wrap: anywhere; }
.fc-back { justify-self: stretch; padding-top: 14px; font-size: 1.1rem; color: var(--ink-2); border-top: 2px dashed var(--rule-strong); overflow-wrap: anywhere; }
.fc-tap { font-size: 13px; color: var(--ink-3); }
.practice-foot { gap: 8px; }
.practice-foot .btn:disabled { opacity: 0.4; cursor: default; }
@media (max-width: 560px) {
  .card-row { flex-wrap: wrap; }
  .card-main { flex-basis: calc(100% - 90px); }
  .card-tags { order: 3; flex-basis: 100%; max-width: none; justify-content: flex-start; margin-top: -4px; }
  .flashcard { min-height: 210px; }
}

/* First-run setup guide */
.onboard { gap: 16px; }
.ob-progress { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.ob-progress i { height: 5px; background: var(--rule); border-radius: 3px; }
.ob-progress i.on { background: var(--primary); }
.ob-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.ob-chip { min-height: 36px; padding: 0 12px; font: inherit; font-size: 14px; font-weight: 600; color: var(--ink-2); background: var(--paper); border: 2px solid var(--rule-strong); border-radius: 999px; cursor: pointer; }
.ob-chip[aria-pressed="true"] { color: var(--ink); background: var(--sub-soft); border-color: var(--sub-edge); box-shadow: 2px 2px 0 var(--sub-edge); }
.ob-days { width: 100%; }
.ob-days button { flex: 1; }
.ob-days .count { margin-left: 4px; }
.ob-rows { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.ob-rows li { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) minmax(0, 1fr) auto; gap: 6px; align-items: center; }
.ob-rows li.hint { display: block; }
.ob-added { display: grid; gap: 4px; margin: 0; padding: 0; list-style: none; }
.ob-added li { display: flex; align-items: center; gap: 6px; font-weight: 600; }
.inline-form .grow { flex: 1; }
@media (max-width: 560px) {
  .ob-rows li { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; }
  .ob-rows li select { grid-column: 1 / -1; }
}

/* Language switches */
.lang-seg { width: 100%; max-width: 420px; }
.lang-seg button { flex: 1; }
.auth-bar-end { display: flex; align-items: center; gap: 4px; }
.lang-switch { white-space: nowrap; }
@media (max-width: 560px) { .lp-top .lang-switch { padding-inline: 8px; font-size: 13px; } }
.lang-switch .ls-short { display: none; }
@media (max-width: 560px) { .lp-top .lang-switch .ls-long { display: none; } .lp-top .lang-switch .ls-short { display: inline; } }

/* ============================================================
   Card maker: one card on the table that turns over, a dropdown for the subject, and a pile
   ============================================================ */
.maker { gap: 16px; }
.maker-setup { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.mk-write { display: grid; gap: 12px; }

/* The card: both sides share one spot; turning it over rotates the pair, and the side facing away is hidden */
.flip { display: grid; perspective: 1200px; }
.flip-face {
  grid-area: 1 / 1; display: grid; grid-template-rows: auto 1fr auto; min-height: 210px; padding: 14px 18px 12px;
  background: var(--paper); border: 2px solid var(--edge); border-radius: var(--r-lg); box-shadow: 5px 5px 0 var(--sub, var(--drop));
  backface-visibility: hidden; cursor: text;
  transition: transform 0.45s cubic-bezier(0.3, 1.25, 0.5, 1), visibility 0s 0.2s;
}
.flip-front { border-top: 10px solid var(--sub, var(--edge)); }
.flip-back { transform: rotateY(-180deg); visibility: hidden; border-style: dashed; }
.flip.turned .flip-front { transform: rotateY(180deg); visibility: hidden; }
.flip.turned .flip-back { transform: rotateY(0deg); visibility: visible; transition-delay: 0s, 0s; }
.flip:not(.turned) .flip-front { transition-delay: 0s, 0s; }
.cb-tag { justify-self: start; padding: 1px 8px; margin-bottom: 8px; font-size: 11.5px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink); background: color-mix(in srgb, var(--sub, var(--hl)) 22%, transparent); border-radius: var(--r-sm); }
.flip-face textarea {
  width: 100%; min-height: 96px; padding: 0; resize: none; font: inherit; font-size: 1.3rem; font-weight: 700; line-height: 1.35; text-align: center;
  color: var(--ink); background: transparent; border: 0; outline: 0; box-shadow: none; overflow-wrap: anywhere; align-self: center;
}
.flip-back textarea { font-size: 1.1rem; font-weight: 500; }
.flip-face textarea::placeholder { color: var(--ink-3); opacity: 0.6; font-weight: 500; }
.flip-hint { justify-self: center; font-size: 12.5px; color: var(--ink-3); }
.mk-buttons { display: flex; align-items: center; gap: 8px; }
.mk-buttons .btn .ic { width: 17px; height: 17px; }

/* The pile: one line with a little stack of cards and a count; opens into the list */
.pile-empty { margin: 0; font-size: 13.5px; color: var(--ink-3); text-align: center; }
.pile {
  display: flex; align-items: center; gap: 14px; width: 100%; padding: 10px 12px; font: inherit; color: var(--ink); text-align: left; cursor: pointer;
  background: var(--paper-2); border: 2px solid var(--rule-strong); border-radius: var(--r-lg);
}
.pile:hover { border-color: var(--edge); }
.pile-cards { position: relative; flex: none; width: 42px; height: 32px; }
.pile-cards::before, .pile-cards::after, .pile-cards .count {
  position: absolute; inset: 0; border: 2px solid var(--edge); border-radius: 5px; background: var(--paper);
}
.pile-cards::before, .pile-cards::after { content: ''; display: none; }
.pile.many .pile-cards::before { display: block; transform: rotate(-9deg) translate(-3px, 1px); }
.pile.many .pile-cards::after { display: block; transform: rotate(6deg) translate(3px, 0); }
.pile-cards .count { display: grid; place-items: center; z-index: 1; font-size: 13px; font-weight: 800; font-stretch: var(--narrow); border-left: 5px solid var(--sub, var(--edge)); }
.pile.bump .pile-cards .count { animation: pile-bump 0.45s cubic-bezier(0.2, 1.5, 0.4, 1); }
@keyframes pile-bump { from { transform: translateY(-14px) rotate(-8deg); } }
.pile-text { flex: 1; min-width: 0; display: grid; gap: 1px; }
.pile-text b { font-size: 14.5px; }
.pile-text small { font-size: 12.5px; color: var(--ink-3); }
.pile-chev { flex: none; transition: transform 0.2s; }
.pile[aria-expanded="true"] .pile-chev { transform: rotate(180deg); }
.pile-list { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 8px; max-height: 260px; overflow-y: auto; }
.mini-card { display: flex; align-items: center; min-width: 0; background: var(--paper); border: 2px solid var(--rule-strong); border-radius: var(--r); }
.mini-card.editing { border-color: var(--edge); outline: 3px solid var(--hl); outline-offset: 1px; }
.mc-main { flex: 1; min-width: 0; display: grid; gap: 2px; padding: 8px 6px 8px 12px; text-align: left; font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
.mc-main b, .mc-main small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mc-main b { font-size: 14px; }
.mc-main small { font-size: 12.5px; color: var(--ink-2); }
.mini-card .icon-btn { flex: none; margin-right: 6px; }

/* Studying: the answer turns over like a real card */
.flashcard.shown { animation: card-turn 0.36s cubic-bezier(0.3, 1.3, 0.5, 1); }
@keyframes card-turn { from { transform: perspective(900px) rotateX(-70deg); opacity: 0.4; } }

@media (max-width: 560px) {
  .flip-face { min-height: 180px; }
  .flip-face textarea { font-size: 1.15rem; min-height: 80px; }
}
@media (pointer: coarse) {
  .mini-card .icon-btn { width: 36px; height: 36px; }
}
