@import url('https://fonts.googleapis.com/css2?family=Geist:wght@300..800&family=Geist+Mono:wght@400;500;600&display=swap');

/* ============================================================
   Zenith dashboard. Dark, Apple-style, Geist + Geist Mono, bento
   cards (spec 6.1). Level palette is fixed (dashboard-decisions.md).
   After sign-off the pages add `night` to <html>: the same tokens go
   warm and dim, so the screen winds down with him.
   ============================================================ */
:root {
  --bg: #0b0b0c; --card: #151517; --card-2: #0f0f10; --card-hi: #1b1b1e;
  --border: #232326; --border-hi: #38383d; --line: #1f1f22;
  --text: #f5f5f7; --soft: #d2d2d7; --muted: #a1a1a6; --dim: #86868b; --faint: #48484a;
  --accent: #2997ff; --accent-hover: #6cb8ff; --accent-soft: rgba(41,151,255,.14);
  --maths: #2997ff; --physics: #ff9f0a; --econ: #bf5af2; --bio: #30d158;
  --lv-ns: #242428; --lv-seen: #3a3470; --lv-getting: #2f6fd6; --lv-nailed: #1fbf9f; --lv-spaced: #b6f36b;
  --ok: #1fbf9f; --warn: #ff9f0a; --bad: #ff6961;
  --sleep: #8b87ff; --energy: #ffd60a; --mood: #ff8ad1; --train: #ff6b5e; --fuel: #5ee0a8; --body: #64d2ff;
  --flag-bg: #1d1710; --flag-border: #4a3312; --flag-text: #ffb340;
  --r-xl: 28px; --r-lg: 22px; --r-md: 16px; --r-sm: 11px;
  --ease: cubic-bezier(.2,.7,.2,1);
  color-scheme: dark;
}
html.night {
  --bg: #0d0b0a; --card: #171310; --card-2: #110e0c; --card-hi: #1e1915;
  --border: #2a221c; --border-hi: #3d3229; --line: #231c17;
  --text: #f3e9dc; --soft: #ddcdb9; --muted: #b5a18c; --dim: #8e7b68; --faint: #4f4337;
  --accent: #ff9f5a; --accent-hover: #ffbe8c; --accent-soft: rgba(255,159,90,.14);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
/* Same left edge on every page, whether or not it scrolls (Windows scrollbars take 10 px). */
html { scrollbar-gutter: stable; }

html, body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: 'Geist', system-ui, -apple-system, 'Segoe UI', sans-serif; -webkit-font-smoothing: antialiased;
  transition: background-color .8s var(--ease), color .8s var(--ease);
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
button { font-family: inherit; }

/* Negative letter-spacing on big headings pulls the first glyph left; a small pad evens it out. */
h1 { padding-left: 4px; }
.mono, .num { font-family: 'Geist Mono', ui-monospace, monospace; font-variant-numeric: tabular-nums; }
.dim { color: var(--dim); }
.muted { color: var(--muted); }
.good { color: var(--ok); }
.late { color: #ffb36b; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 55%, transparent); } 50% { box-shadow: 0 0 0 7px transparent; } }
@keyframes kzdot { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
@keyframes grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes breathe { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }

/* ---------- components ---------- */
.card { background: var(--card-glass, var(--card)); border: 1px solid var(--border); border-radius: var(--r-lg); transition: background-color .8s var(--ease), border-color .3s; }
.card.reveal { animation: rise .6s var(--ease) both; }
a.go { color: inherit; display: flex; flex-direction: column; transition: transform .3s var(--ease), border-color .3s, background-color .3s; }
a.go:hover { color: inherit; transform: translateY(-3px); border-color: var(--border-hi); background: var(--card-hi); }
a.row { color: inherit; border-radius: 10px; transition: background-color .2s; display: grid; }
a.row:hover { color: inherit; background: var(--card-hi); }

.dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; display: inline-block; }
.dot.live { animation: pulse 2s infinite; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 1px solid var(--border-hi); background: transparent; color: var(--text); border-radius: var(--r-sm);
  padding: 8px 14px; font: 600 13px/1.1 'Geist', system-ui, sans-serif; cursor: pointer; white-space: nowrap;
  transition: background-color .2s, border-color .2s, transform .2s, color .2s;
}
.btn:hover { background: var(--card-hi); border-color: var(--faint); transform: translateY(-1px); color: var(--text); }
.btn.primary { background: var(--text); color: var(--bg); border-color: var(--text); }
.btn.primary:hover { background: #fff; color: var(--bg); }
.btn.accent { border-color: color-mix(in srgb, var(--accent) 45%, transparent); color: var(--accent-hover); background: var(--accent-soft); }
.btn.ghost { border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: var(--card-hi); }
.btn.small { padding: 6px 11px; font-size: 12px; border-radius: 9px; }
.btn:disabled { opacity: .45; cursor: default; transform: none; }
.btn svg { flex-shrink: 0; }

.tag { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; line-height: 1; padding: 4px 8px; border-radius: 999px; border: 1px solid var(--border-hi); color: var(--muted); white-space: nowrap; }
.tag.hot { border-color: #6e2b24; color: #ff9086; background: #24110f; }
.tag.retest { border-color: #1b4a80; color: #9ecbff; }
.tag.ask { border-color: #5a3c10; color: #ffc46b; }
.tag.ask.today { background: #2a1d08; }
.tag.date { border-color: #4a4390; color: #c3b6ff; }
.tag.plan { border-color: #24414a; color: #8fd4e8; }
.tag.revisit { border-color: var(--flag-border); color: var(--flag-text); background: var(--flag-bg); }

/* Stacked level bar: one segment per level, widths from the server. */
.lvbar { height: 8px; border-radius: 4px; background: var(--lv-ns); overflow: hidden; display: flex; }
.lvbar span { display: block; height: 100%; transform-origin: left; animation: grow .9s var(--ease) both; }
/* Level squares: one per topic. */
.cells { display: flex; gap: 3px; flex-wrap: wrap; align-content: center; }
.cells span { width: 13px; height: 13px; border-radius: 3px; }

.legend { display: flex; gap: 16px; font-size: 12px; color: var(--dim); flex-wrap: wrap; }
.legend .sw { display: inline-flex; align-items: center; gap: 6px; }
.legend .box { width: 10px; height: 10px; border-radius: 3px; }

.empty { color: var(--dim); font-size: 13px; margin: 0; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; cursor: pointer; }
.linkbtn:hover { color: var(--accent-hover); }

/* Segmented choices (check-in): tap targets, one selected. */
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg button {
  min-width: 38px; height: 36px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--border-hi);
  background: var(--card-2); color: var(--muted); font: 600 13px 'Geist', system-ui, sans-serif; cursor: pointer;
  transition: background-color .15s, color .15s, border-color .15s, transform .15s;
}
.seg button:hover { color: var(--text); border-color: var(--faint); }
.seg button[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.field { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.field > label, .field > .lbl { font-size: 12.5px; color: var(--muted); }
.input {
  height: 40px; min-width: 0; padding: 0 12px; border-radius: 10px; border: 1px solid var(--border-hi);
  background: var(--card-2); color: var(--text); font: 500 15px 'Geist', system-ui, sans-serif;
}
.input[type="time"], .input.numeric { font-family: 'Geist Mono', monospace; font-variant-numeric: tabular-nums; }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input::-webkit-calendar-picker-indicator { filter: invert(.7); }
.tstep { display: inline-flex; align-items: center; gap: 0; border: 1px solid var(--border-hi); border-radius: 10px; background: var(--card-2); height: 40px; overflow: hidden; width: fit-content; }
.tstep:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.tstep button { width: 34px; height: 100%; border: 0; background: transparent; color: var(--muted); font: 600 17px 'Geist', system-ui, sans-serif; cursor: pointer; transition: background-color .15s, color .15s; }
.tstep button:hover { background: var(--card-hi); color: var(--text); }
.tstep .input { border: 0; height: 100%; width: 64px; text-align: center; padding: 0; border-radius: 0; background: transparent; box-shadow: none; font-size: 16px; font-weight: 600; }
.tstep .input:focus { box-shadow: none; }

/* ---------- page chrome ---------- */
.page {
  max-width: 1440px; margin: 0 auto; padding: 26px 56px 20px;
  display: flex; flex-direction: column; gap: 14px; min-height: 100vh; min-height: 100dvh;
}
.topbar { display: flex; justify-content: space-between; align-items: center; height: 34px; gap: 16px; }
.brand { display: flex; align-items: center; gap: 11px; color: var(--text); }
.brand:hover { color: var(--text); }
.brand .mark {
  width: 26px; height: 26px; border-radius: 8px; background: var(--text); color: var(--bg);
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 14px;
  transition: background-color .8s var(--ease);
}
.brand .name { font-size: 16px; font-weight: 650; letter-spacing: -0.01em; }
.status { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--dim); }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 999px; background: var(--card); border: 1px solid var(--border); color: var(--muted); font-size: 12.5px; }
.pill .mono { color: var(--text); }
.pill.warm { color: var(--accent-hover); border-color: color-mix(in srgb, var(--accent) 35%, transparent); }
.clock { font-family: 'Geist Mono', monospace; font-size: 13px; color: var(--dim); }

.subpage-topbar { display: flex; justify-content: space-between; align-items: center; min-height: 36px; flex-wrap: wrap; row-gap: 8px; }
.subpage-topbar .links { display: flex; gap: 22px; font-size: 15px; align-items: center; }
.subpage-topbar .links a.dim { color: var(--dim); }
.subpage-topbar .links a.dim:hover { color: var(--text); }

.title-card { padding: 6px 0 10px; margin-top: 8px; background: transparent; border: 0; border-radius: 0; }
.title-card h1 { margin: 0; font-size: clamp(42px, 6.4vw, 80px); line-height: .95; font-weight: 700; letter-spacing: -0.045em; }
.title-card .sub { font-size: 17px; color: var(--muted); margin-top: 12px; padding-left: 4px; }
.title-card .eyebrow { display: flex; align-items: center; gap: 9px; font-size: 14px; color: var(--muted); padding-left: 4px; margin-bottom: 10px; }
.title-row { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px 24px; flex-wrap: wrap; }

.two-col { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 14px; }
.col-8 { grid-column: span 8; } .col-7 { grid-column: span 7; } .col-6 { grid-column: span 6; }
.col-5 { grid-column: span 5; } .col-4 { grid-column: span 4; } .col-3 { grid-column: span 3; } .col-12 { grid-column: 1 / -1; }
.stack { display: flex; flex-direction: column; gap: 14px; }

.section-box { padding: 24px 26px; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.section-box > h2, .sec-head h2 { margin: 0; font-size: 20px; font-weight: 650; letter-spacing: -0.02em; }
.sec-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.sec-head .aside { font-size: 13px; color: var(--dim); }

/* ============================================================
   HOME (spec 6.2): fits the window (100dvh), no page scroll.
   ============================================================ */
.page.home { height: 100vh; height: 100dvh; overflow: hidden; padding: 14px 48px 12px; gap: 10px; }
.page.home .topbar, .page.home .kz-bar { flex-shrink: 0; }

.home-grid {
  display: grid; gap: 10px; flex: 1 1 auto; min-height: 0;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  grid-template-rows: minmax(0, 1.42fr) minmax(0, .74fr) minmax(0, .9fr);
}
.home-grid > .card, .stat-row > .card { min-height: 0; overflow: hidden; display: flex; flex-direction: column; }
.home-grid .hero { grid-column: 1 / span 5; grid-row: 1; }
.home-grid .upnext { grid-column: 6 / span 3; grid-row: 1; }
.home-grid .todo { grid-column: 9 / span 4; grid-row: 1 / -1; }
.home-grid .stat-row { grid-column: 1 / span 8; grid-row: 2; display: grid; grid-template-columns: 1.25fr .9fr 1.05fr; gap: 10px; min-height: 0; }
.home-grid .subjects { grid-column: 1 / span 8; grid-row: 3; }

.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; padding: 0 2px; }
.card-head h2 { margin: 0; font-size: 18px; font-weight: 650; letter-spacing: -0.02em; }
.card-head .aside { font-size: 12.5px; color: var(--dim); }

/* D-1 Moment */
.hero { padding: 24px 28px 22px; gap: 10px; border-radius: var(--r-xl); position: relative; }
.hero .eyebrow { font-size: 14px; color: var(--muted); padding-left: 4px; display: flex; align-items: center; gap: 8px; }
.hero h1 {
  margin: 0; font-size: clamp(26px, 4.6vh, 48px); line-height: 1.03; font-weight: 700; letter-spacing: -0.04em;
  overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.hero h1 .dim { color: var(--dim); }
.moment-sub { font-size: 15px; color: var(--soft); padding-left: 4px; display: flex; gap: 6px 12px; flex-wrap: wrap; align-items: center; }
.moment-sub .hint { color: var(--accent-hover); }
.moment-sub .subj { display: inline-flex; align-items: center; gap: 7px; color: var(--soft); }
.moment-sub .count { color: var(--muted); font-variant-numeric: tabular-nums; }
.moment-body { margin-top: auto; display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.moment-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.zenith-box {
  display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px;
  background: var(--card-2); border: 1px solid var(--border); border-radius: var(--r-md); min-height: 0;
}
.kmark {
  width: 20px; height: 20px; flex-shrink: 0; border-radius: 6px; background: var(--text);
  color: var(--bg); font-weight: 800; font-size: 11px; display: flex; align-items: center; justify-content: center; margin-top: 1px;
}
.zenith-box p {
  font-size: 14.5px; line-height: 1.4; color: var(--soft); margin: 0;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.zenith-box .when { display: block; font-size: 11px; color: var(--dim); margin-top: 3px; }
.priority-reply { display: flex; gap: 8px; align-items: center; padding: 7px 8px 7px 14px; background: var(--card-2); border: 1px solid var(--border); border-radius: 14px; }
.priority-reply:focus-within { border-color: var(--border-hi); }
.priority-reply input { flex: 1 1 120px; min-width: 0; background: transparent; border: 0; outline: none; color: var(--text); font: 15px 'Geist', system-ui, sans-serif; padding: 6px 0; }
.priority-reply input::placeholder { color: var(--dim); }
.priority-status { font-size: 13px; color: var(--ok); min-height: 0; padding-left: 4px; }
.priority-status.bad { color: var(--bad); }

/* Morning check-in, inline on the Moment card: two rows (bed, up, slept; then energy with Save),
   labels beside their controls, so the whole form and its buttons fit a short laptop window. */
.checkin-inline { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; }
.checkin-inline .field { flex-direction: row; align-items: center; gap: 8px; }
.checkin-inline .field > label, .checkin-inline .field > .lbl { white-space: nowrap; }
.checkin-inline .field > label { min-width: 26px; } /* Bed and Up line up when they stack on a phone */
.checkin-inline .slept { font-size: 13px; color: var(--muted); white-space: nowrap; }
.checkin-inline .slept:empty { display: none; }
.checkin-inline .slept b { color: var(--text); font-weight: 600; font-family: 'Geist Mono', monospace; }
.checkin-inline .ci-row { flex: 1 1 100%; display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap; }
.checkin-inline .ci-row .seg { flex-wrap: nowrap; }
.checkin-inline .ci-row .moment-actions { margin-left: auto; }
/* What sits above the form keeps its size; only the form part may scroll, and only if it truly can't fit. */
.hero .eyebrow, .hero h1, .moment-sub { flex-shrink: 0; }
.moment-body { overflow-y: auto; padding: 3px; margin: auto -3px -3px; } /* the 3 px keep focus rings inside the scroll box */
@media (max-height: 700px) and (min-width: 1181px) { .moment-sub .ci-hint { display: none; } }

/* D-2 Up next + the day line */
.upnext { padding: 22px 22px 18px; gap: 8px; animation-delay: .06s; }
.upnext .label { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.upnext .label .in { margin-left: auto; font-family: 'Geist Mono', monospace; color: var(--text); font-size: 13px; }
.upnext .subject { font-size: clamp(24px, 4vh, 40px); font-weight: 700; letter-spacing: -0.035em; line-height: 1.04; overflow-wrap: anywhere; }
.upnext .who { font-size: 14px; color: var(--muted); display: flex; gap: 10px; flex-wrap: wrap; }
.asks { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; min-height: 0; overflow: hidden; }
.asks .ask { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; line-height: 1.3; color: var(--soft); padding: 8px 10px; border-radius: 10px; background: #1d1608; border: 1px solid #3d2b0c; }
html.night .asks .ask { background: #21170c; }
.asks .ask b { color: #ffc46b; font-weight: 600; white-space: nowrap; }
.dayline { margin-top: auto; padding-top: 8px; }
.dayline .later { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; font-size: 13px; color: var(--soft); }
.dayline .later .it { display: flex; align-items: center; gap: 9px; }
.dayline .later .it .mono { color: var(--dim); font-size: 12.5px; width: 40px; }
.dayline .track { position: relative; height: 18px; border-radius: 9px; background: var(--card-2); border: 1px solid var(--line); overflow: visible; }
.dayline .seg-b { position: absolute; top: 2px; bottom: 2px; border-radius: 4px; transition: opacity .4s; }
.dayline .seg-b.free { border: 1px solid var(--faint); background: transparent; }
.dayline .seg-b.games { background: repeating-linear-gradient(135deg, var(--faint) 0 3px, transparent 3px 6px); }
.dayline .seg-b.past { opacity: .32; }
.dayline .seg-b.sleep { background: color-mix(in srgb, var(--sleep) 30%, transparent); border: 1px dashed color-mix(in srgb, var(--sleep) 70%, transparent); }
.dayline .nowmark { position: absolute; top: -5px; bottom: -5px; width: 2px; margin-left: -1px; border-radius: 1px; background: var(--text); box-shadow: 0 0 10px color-mix(in srgb, var(--text) 60%, transparent); transition: left 1s linear; }
.dayline .ticks { display: flex; justify-content: space-between; font: 11px 'Geist Mono', monospace; color: var(--dim); margin-top: 7px; }

/* D-3 To-do */
.todo { padding: 20px 18px 12px; gap: 6px; animation-delay: .12s; }
.todo .rows { display: flex; flex-direction: column; overflow-y: auto; flex: 1 1 auto; min-height: 0; margin: 0 -6px; padding: 0 6px 6px; scrollbar-width: thin; scrollbar-color: var(--faint) transparent; }
.todo-group { margin-top: 6px; }
.todo-group > summary {
  list-style: none; cursor: pointer; display: flex; align-items: baseline; gap: 8px;
  position: sticky; top: 0; z-index: 2; padding: 8px 2px 6px; font-size: 13px; font-weight: 600; color: var(--soft);
  /* See-through like the card (no darker band); rows passing under it blur. */
  background: transparent; -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
}
.todo-group > summary::-webkit-details-marker { display: none; }
.todo-group > summary .n { font-family: 'Geist Mono', monospace; font-weight: 500; color: var(--dim); font-size: 12px; }
.todo-group > summary .chev { margin-left: auto; color: var(--dim); transition: transform .2s; }
.todo-group[open] > summary .chev { transform: rotate(90deg); }
.todo-group.overdue > summary { color: #ff9086; }
.todo-row { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 10px; align-items: start; padding: 8px 2px; border-top: 1px solid var(--line); transition: opacity .3s; }
.todo-group > summary + .todo-row { border-top: none; }
.todo-row .tick {
  width: 20px; height: 20px; margin-top: 1px; border-radius: 50%; border: 1.5px solid var(--faint); background: transparent;
  cursor: pointer; padding: 0; display: flex; align-items: center; justify-content: center; color: transparent;
  transition: border-color .2s, background-color .2s, transform .2s, color .2s;
}
.todo-row .tick:hover { border-color: var(--ok); transform: scale(1.12); color: var(--ok); }
.todo-row .tick:disabled { cursor: default; transform: none; }
.todo-row .no-tick { width: 20px; height: 20px; display: flex; align-items: center; justify-content: center; }
.todo-row .no-tick::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--warn); }
.todo-row.ticked .tick { background: var(--ok); border-color: var(--ok); color: var(--bg); }
.todo-row.ticked .text { text-decoration: line-through; color: var(--dim); }
.todo-row.ticked { opacity: .55; }
.todo-row .text { font-size: 13.5px; line-height: 1.35; min-width: 0; overflow-wrap: anywhere; }
.todo-row .meta { display: flex; gap: 8px; align-items: center; margin-top: 5px; flex-wrap: wrap; font-size: 12px; color: var(--dim); }
.todo-row .meta .late { color: #ff9086; }
.todo-row .meta .sd { display: inline-flex; align-items: center; gap: 5px; }
.todo-toast { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 13px; color: var(--soft); padding: 8px 12px; background: var(--card-2); border: 1px solid var(--border); border-radius: 12px; flex-shrink: 0; }
.todo-toast.bad { color: #ff9086; border-color: #6e2b24; }

/* Stat row: Trials, Reps, Health */
.stat-row > .card { padding: 16px 20px; gap: 6px; animation-delay: .2s; }
.stat-row .k { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.stat-row .k .r { margin-left: auto; font-family: 'Geist Mono', monospace; color: var(--dim); font-size: 12px; }
.stat-row .big { font-size: clamp(28px, 4.6vh, 44px); font-weight: 700; letter-spacing: -0.045em; line-height: 1; white-space: nowrap; }
.stat-row .big .unit { font-size: 15px; color: var(--dim); font-weight: 500; letter-spacing: 0; margin-left: 5px; }
.stat-row .detail { font-size: 12.5px; color: var(--muted); line-height: 1.35; }
.stat-row .foot { margin-top: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.stat-row .foot.warn { color: #ffb36b; }
/* Big numbers on Home are Geist like every other number on the card (the roll keeps tabular figures). */
.stat-row .big .num { font-family: inherit; }
/* The night score on Home's health card: the Health page's ring, small, in the corner. */
#health-card { position: relative; }
.health-ring { position: absolute; top: 12px; right: 14px; width: 46px; height: 46px; }
.health-ring svg { display: block; }
.health-ring .trk { fill: none; stroke: rgba(255, 255, 255, .08); stroke-width: 4; stroke-linecap: round; }
.health-ring .arc { fill: none; stroke-width: 4; stroke-linecap: round; }
.health-ring .n { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 650; font-variant-numeric: tabular-nums; color: var(--text); }
#health-card .k, #health-card .big { padding-right: 54px; }
/* The rail has nothing in normal flow, so it must not shrink: squeezed to 0 px its ticks drew over the line below. */
.papers { position: relative; height: 22px; margin: 4px 0 2px; flex-shrink: 0; }
/* Trials card: Prep sits beside the countdown, "First up" is the last line, so the card is four short
   rows and fits a short laptop window. */
.trials-row { display: flex; align-items: center; gap: 14px; min-width: 0; flex-shrink: 0; }
.trials-row .big { flex: 0 1 auto; min-width: 0; }
.trials-row .prep { margin-left: auto; flex: 0 1 128px; min-width: 84px; }
.stat-row .trials-next { margin-top: auto; flex-shrink: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.papers .rail { position: absolute; left: 0; right: 0; top: 10px; height: 2px; background: var(--border); border-radius: 1px; }
.papers .p { position: absolute; top: 3px; width: 6px; height: 16px; margin-left: -3px; border-radius: 3px; }
.papers .p.done { opacity: .3; }
.papers .today { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: var(--text); border-radius: 1px; }
.prep { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.prep .bar { flex: 1 1 auto; height: 5px; border-radius: 3px; background: var(--border); overflow: hidden; }
.prep .bar span { display: block; height: 100%; background: var(--ok); border-radius: 3px; transform-origin: left; animation: grow .9s var(--ease) both; }
.ring { width: 46px; height: 46px; flex-shrink: 0; }
.ring circle { fill: none; stroke-width: 6; }
.ring .track { stroke: var(--border); }
.ring .val { stroke-linecap: round; transform: rotate(-90deg); transform-origin: 50% 50%; transition: stroke-dashoffset 1s var(--ease); }
.reps-top { display: flex; align-items: center; gap: 14px; }

/* D-5 Subjects (readiness + papers, merged with Progress) */
.subjects { padding: 18px 20px 14px; gap: 6px; animation-delay: .28s; }
.subject-rows { display: flex; flex-direction: column; gap: 2px; min-height: 0; overflow: hidden; flex: 1 1 auto; justify-content: space-around; }
.subject-row { grid-template-columns: 92px minmax(0, 1fr) 40px 128px 40px; gap: 12px; align-items: center; padding: 6px 8px; }
.subject-row .name { font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.subject-row .pct { text-align: right; font-family: 'Geist Mono', monospace; font-size: 12.5px; color: var(--muted); }
.subject-row .next { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.subject-row .next b { color: var(--text); font-weight: 600; font-family: 'Geist Mono', monospace; }
.subject-row .flags { display: flex; gap: 8px; justify-content: flex-end; font-size: 12px; color: var(--dim); font-family: 'Geist Mono', monospace; }
.subject-row .flags .f { color: var(--flag-text); }

@media (max-height: 780px) {
  .cells span { width: 9px; height: 9px; border-radius: 2px; }
  .cells { gap: 2px; }
  .hero { padding: 18px 22px 16px; }
  .upnext { padding: 16px 18px 14px; }
  .todo, .subjects { padding-top: 14px; padding-bottom: 10px; }
  .subject-row { padding: 3px 8px; }
  .stat-row > .card { padding: 12px 16px; }
  .asks .ask { padding: 6px 9px; }
  .papers { height: 18px; margin: 2px 0 0; }
  .papers .rail { top: 8px; }
  .papers .p { top: 1px; }
}
@media (max-height: 700px) and (min-width: 1181px) {
  .stat-row > .card { gap: 4px; padding: 10px 14px; }
  /* A short laptop window: all four subjects still fit. */
  .subjects { gap: 2px; padding-top: 10px; padding-bottom: 6px; }
  .subjects .card-head h2 { font-size: 16px; }
  .subject-row { padding: 1px 8px; }
  .health-ring { top: 8px; right: 10px; }
}

/* ============================================================
   HEALTH (spec 6.7, 7.2): the page's own look is in health.css.
   The check-in form below is shared with its markup there.
   ============================================================ */

/* Check-in form */
.checkin { padding: 24px 26px; display: flex; flex-direction: column; gap: 18px; border-radius: var(--r-xl); }
.checkin .row { display: flex; gap: 18px 26px; flex-wrap: wrap; align-items: flex-end; }
.checkin .slept { font-size: 14px; color: var(--muted); padding-bottom: 10px; }
.checkin .slept b { font-family: 'Geist Mono', monospace; color: var(--text); font-weight: 600; }
.checkin .scale { display: flex; align-items: center; gap: 10px; }
.checkin .scale .end { font-size: 12px; color: var(--dim); }
.checkin .actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.checkin .status { font-size: 13px; color: var(--ok); }
.checkin .status.bad { color: var(--bad); }
.checkin .input.mins { width: 84px; }
.checkin .input.grams { width: 96px; }
.checkin .input.kg { width: 96px; }
.checkin .input.note { width: min(360px, 100%); }
.checkin .done-line { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.checkin .done-line .dot { background: var(--ok); }

.watch-chip { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--dim); padding: 8px 12px; border-radius: 12px; border: 1px dashed var(--border-hi); }

/* ============================================================
   SUBJECTS / SUBJECT / MASTERCLASS placeholder
   ============================================================ */
.subject-block { border-radius: var(--r-xl); padding: 26px 30px 30px; }
.subject-block .head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; flex-wrap: wrap; gap: 10px 20px; }
.subject-block .head .titles { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
.subject-block .head h2 { margin: 0; font-size: 28px; font-weight: 700; letter-spacing: -0.03em; }
.subject-block .head h2 a { color: var(--text); }
.subject-block .head h2 a:hover { color: var(--accent-hover); }
.subject-block .head .board { font-size: 13.5px; color: var(--dim); }
.subject-block .facts { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.subject-block .facts b { color: var(--text); font-weight: 600; font-family: 'Geist Mono', monospace; }
.subject-block .facts .lvbar { width: 140px; }
.tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; }
.tile { position: relative; min-height: 84px; padding: 12px 14px; border-radius: 14px; display: flex; flex-direction: column; justify-content: space-between; gap: 8px; transition: transform .2s var(--ease), box-shadow .2s, filter .2s; }
.tile:hover { transform: translateY(-2px) scale(1.02); box-shadow: 0 10px 24px rgba(0,0,0,.35); filter: brightness(1.12); }
.tile .code { font-size: 12px; font-family: 'Geist Mono', monospace; }
.tile .name { font-size: 14px; font-weight: 550; line-height: 1.2; }
.tile .flag-dot { position: absolute; top: 12px; right: 12px; width: 8px; height: 8px; border-radius: 50%; background: var(--warn); box-shadow: 0 0 0 3px rgba(255,159,10,.2); }
.group-head { display: flex; justify-content: space-between; align-items: baseline; margin: 6px 0 10px; }
.group-head .name { font-size: 14.5px; font-weight: 600; }
.group-head .count { font-size: 12.5px; color: var(--dim); font-family: 'Geist Mono', monospace; }

.stat-card { padding: 22px 24px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.stat-card .lbl { font-size: 13px; color: var(--muted); }
.stat-card .big { font-size: 48px; font-weight: 700; letter-spacing: -0.045em; line-height: 1; }
.stat-card .big .of { font-size: 20px; color: var(--dim); font-weight: 500; letter-spacing: -0.01em; }
.stat-card .medium { font-size: 26px; font-weight: 700; letter-spacing: -0.03em; line-height: 1.12; }
.stat-card .detail { font-size: 14px; color: var(--muted); }
.paper-list { display: flex; flex-direction: column; gap: 8px; }
.paper-list .pp { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; font-size: 14px; }
.paper-list .pp .d { font-family: 'Geist Mono', monospace; color: var(--dim); font-size: 12.5px; }

.flag-panel { border-radius: var(--r-lg); padding: 24px 28px; background: var(--flag-bg); border: 1px solid var(--flag-border); display: flex; flex-direction: column; gap: 12px; }
.flag-panel .tag-line { display: flex; align-items: center; gap: 9px; font-size: 13px; color: var(--flag-text); }
.flag-panel .tag-line .dot { background: var(--warn); }
.flag-panel h3 { margin: 0; font-size: 26px; font-weight: 700; letter-spacing: -0.03em; }
.flag-panel h3 a { color: var(--text); }
.flag-panel .lines { display: flex; flex-direction: column; gap: 8px; }
.flag-panel .line-row { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 14px; font-size: 15px; line-height: 1.4; }
.flag-panel .line-row .d { font-size: 12.5px; color: var(--dim); font-family: 'Geist Mono', monospace; padding-top: 2px; }
.flag-panel .actions { display: flex; gap: 8px; flex-wrap: wrap; }

.teacher-row { display: flex; gap: 14px; padding: 10px; margin: 0 -10px; border-radius: 14px; align-items: center; }
.teacher-row .name { font-size: 15px; font-weight: 600; }
.teacher-row .meta { font-size: 13px; color: var(--dim); margin-top: 3px; }
.avatar { width: 44px; height: 44px; flex-shrink: 0; border-radius: 12px; background: #2a1d08; border: 1px solid #5a3c10; color: #ffc46b; font-size: 12.5px; font-weight: 700; display: flex; align-items: center; justify-content: center; }

.mistake-row { display: grid; grid-template-columns: 92px 64px minmax(0, 1fr) 84px; gap: 14px; padding: 13px 0; border-top: 1px solid var(--line); font-size: 14.5px; align-items: start; }
.mistake-row:first-child { border-top: none; }
.mistake-row .d { font-family: 'Geist Mono', monospace; font-size: 12.5px; color: var(--dim); padding-top: 2px; }
.mistake-row .code { font-family: 'Geist Mono', monospace; font-size: 12.5px; color: var(--flag-text); padding-top: 2px; }
.mistake-row .fix { display: block; font-size: 13px; color: var(--dim); margin-top: 3px; }
.type-chip { justify-self: end; font-size: 11.5px; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--border-hi); color: var(--soft); height: fit-content; white-space: nowrap; }

.mc-hero { padding: 28px 30px; border-radius: var(--r-xl); display: flex; flex-direction: column; gap: 16px; }
.mc-level { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px; font-size: 13px; font-weight: 600; width: fit-content; }
.mc-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ============================================================
   MISTAKES
   ============================================================ */
.chips { display: flex; gap: 8px; flex-wrap: wrap; background: none; border: 0; }
.chip { padding: 8px 15px; border-radius: 999px; background: transparent; color: var(--muted); border: 1px solid var(--border-hi); font: 14px 'Geist', system-ui, sans-serif; cursor: pointer; transition: background-color .2s, color .2s, border-color .2s; }
.chip:hover { color: var(--text); }
.chip.active { background: var(--text); color: var(--bg); border-color: var(--text); font-weight: 600; }
.chip .n { font-family: 'Geist Mono', monospace; margin-left: 6px; opacity: .7; }
.bar-row { display: grid; grid-template-columns: 88px minmax(0, 1fr) 26px; gap: 12px; align-items: center; }
.bar-row .label { font-size: 14px; color: var(--soft); }
.bar-track { height: 10px; border-radius: 5px; background: var(--border); overflow: hidden; display: block; }
.bar-fill { display: block; height: 100%; border-radius: 5px; background: var(--accent); transform-origin: left; animation: grow .9s var(--ease) both; }
.bar-row .n { font-family: 'Geist Mono', monospace; font-size: 13px; color: var(--dim); text-align: right; }
.pattern-card { border-radius: var(--r-lg); padding: 24px 26px; background: #0e1a2b; border: 1px solid #1b3f6e; display: flex; flex-direction: column; gap: 12px; }
html.night .pattern-card { background: #1d150e; border-color: #4a3420; }
.pattern-card h2 { margin: 0; font-size: 20px; font-weight: 650; letter-spacing: -0.02em; }
.pattern-card .p { display: flex; align-items: baseline; gap: 10px; font-size: 14.5px; color: var(--soft); }
.pattern-card .p .v { font-family: 'Geist Mono', monospace; color: var(--text); font-weight: 600; min-width: 46px; }
.ledger { display: flex; flex-direction: column; }
.ledger-row { display: grid; grid-template-columns: 92px 104px minmax(160px, 220px) minmax(0, 1fr) 96px; gap: 16px; padding: 14px 12px; border-radius: 12px; font-size: 14.5px; align-items: start; border-top: 1px solid var(--line); }
.ledger-row:first-child { border-top: none; }
.ledger-row .d { font-family: 'Geist Mono', monospace; font-size: 12.5px; color: var(--dim); padding-top: 2px; }
.ledger-row .s { display: flex; align-items: center; gap: 8px; }
.ledger-row .t .c { font-family: 'Geist Mono', monospace; font-size: 12.5px; color: var(--dim); margin-right: 6px; }
.ledger-row .src { display: block; font-size: 12.5px; color: var(--dim); margin-top: 3px; }
.ledger-row .fix { display: block; font-size: 13px; color: var(--dim); margin-top: 3px; }

/* ============================================================
   GRADES
   ============================================================ */
.grade-row { display: grid; grid-template-columns: 150px minmax(0, 1fr) 54px 150px 130px; gap: 20px; padding: 16px 12px; border-radius: 12px; align-items: center; border-top: 1px solid var(--line); }
.grade-row:first-of-type { border-top: none; }
.grade-row .name { display: flex; align-items: center; gap: 10px; font-size: 16px; font-weight: 600; }
.grade-row .pct { font-family: 'Geist Mono', monospace; font-size: 13px; color: var(--muted); text-align: right; }
.grade-row .paper { font-size: 14px; color: var(--muted); }
.grade-row .pace { font-size: 13.5px; justify-self: start; }
.grade-row .lvbar { height: 10px; border-radius: 5px; }
.grade-head { display: grid; grid-template-columns: 150px minmax(0, 1fr) 54px 150px 130px; gap: 20px; padding: 0 12px 8px; font-size: 12.5px; color: var(--dim); border-bottom: 1px solid var(--border); }
.pace.ahead { color: var(--ok); }
.pace.behind { color: var(--bad); }
.pace.on-pace { color: var(--muted); }
.big-stat { padding: 26px 28px; display: flex; flex-direction: column; gap: 6px; }
.big-stat .lbl { font-size: 14px; color: var(--muted); }
.big-stat .num { font-size: clamp(44px, 6vw, 84px); font-weight: 700; letter-spacing: -0.05em; line-height: 1; }
.big-stat .num .of { font-size: 30px; color: var(--dim); font-weight: 500; letter-spacing: -0.02em; }
.big-stat .caption { font-size: 14px; color: var(--muted); }

/* ============================================================
   ZENITH chat bar (every page), thread panel and toasts
   ============================================================ */
.kz-bar {
  display: flex; align-items: center; gap: 4px; padding: 6px 6px 6px 16px;
  background: var(--card); border: 1px solid var(--border-hi); border-radius: 999px;
  position: sticky; bottom: 12px; z-index: 30; margin-top: auto; box-shadow: 0 10px 30px rgba(0,0,0,.35);
}
.page.home .kz-bar { position: relative; bottom: auto; margin-top: 0; box-shadow: none; }
.kz-bar .mark { width: 22px; height: 22px; flex-shrink: 0; border-radius: 6px; background: var(--text); color: var(--bg); font-weight: 800; font-size: 11px; display: flex; align-items: center; justify-content: center; margin-right: 4px; }
.kz-bar textarea {
  flex: 1 1 auto; min-width: 0; background: transparent; border: 0; outline: none; color: var(--text);
  font-family: 'Geist', system-ui, sans-serif; font-size: 16px; line-height: 22px; padding: 9px 6px;
  resize: none; overflow-y: auto; display: block;
}
.kz-bar textarea::placeholder { color: var(--dim); }
.kz-icon {
  width: 40px; height: 40px; border-radius: 50%; border: 0; background: transparent; color: var(--muted); padding: 0;
  display: flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0;
  transition: background-color .2s, color .2s, transform .2s;
}
.kz-icon:hover { background: var(--card-hi); color: var(--text); transform: translateY(-1px); }
.kz-icon.on { background: #3a1512; color: #ff6961; }
/* The mic stays on until it is tapped again: a slow pulse says it is still listening. */
.kz-icon.on, .rp-round.on { animation: kz-listening 1.8s ease-out infinite; }
@keyframes kz-listening { 0% { box-shadow: 0 0 0 0 rgba(255, 105, 97, .45); } 70%, 100% { box-shadow: 0 0 0 7px rgba(255, 105, 97, 0); } }
.kz-send {
  width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--text); color: var(--bg); padding: 0;
  display: flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0; transition: transform .2s, background-color .2s;
}
.kz-send:hover { transform: translateY(-1px); background: #fff; }
.kz-send:disabled, .kz-icon:disabled { opacity: .45; cursor: default; transform: none; }
.kz-chip { position: relative; flex-shrink: 0; margin: 0 4px; }
.kz-chip img { width: 34px; height: 34px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border-hi); display: block; }
.kz-chip button { position: absolute; top: -6px; right: -6px; width: 18px; height: 18px; border-radius: 50%; border: 0; background: var(--faint); color: #fff; font-size: 12px; line-height: 18px; padding: 0; cursor: pointer; }
.kz-panel {
  position: fixed; z-index: 40; right: max(16px, calc((100vw - 1440px) / 2 + 56px)); bottom: 84px;
  width: min(560px, calc(100vw - 32px)); max-height: min(64vh, 640px); display: flex; flex-direction: column;
  background: var(--card-2); border: 1px solid var(--border-hi); border-radius: 22px; box-shadow: 0 24px 60px rgba(0,0,0,.55);
  animation: rise .35s var(--ease) both;
}
.kz-panel-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 10px 10px 18px; border-bottom: 1px solid var(--line); font-size: 14px; font-weight: 600; }
.kz-thread { overflow-y: auto; padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 10px; }
.kz-msg { max-width: 88%; padding: 10px 13px; border-radius: 16px; font-size: 14.5px; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
.kz-msg.me { align-self: flex-end; background: var(--card-hi); color: var(--text); border-bottom-right-radius: 6px; }
.kz-msg.zenith { align-self: flex-start; background: var(--card); border: 1px solid var(--border); color: var(--soft); border-bottom-left-radius: 6px; }
.kz-msg img { display: block; max-width: 180px; max-height: 140px; border-radius: 10px; margin-top: 6px; }
.kz-working { display: inline-flex; gap: 4px; align-items: center; color: var(--dim); font-size: 12.5px; white-space: normal; }
.kz-working i { width: 5px; height: 5px; border-radius: 50%; background: currentColor; animation: kzdot 1.2s infinite ease-in-out; }
.kz-working i:nth-child(2) { animation-delay: .15s; }
.kz-working i:nth-child(3) { animation-delay: .3s; }
.kz-working span { margin-left: 4px; }
.kz-fail { margin-top: 8px; display: flex; flex-wrap: wrap; align-items: center; gap: 10px; color: #ff9086; white-space: normal; }
/* Chat history: the bar's clock button reopens the panel; saved messages sit above this page's own. */
.kz-hist { position: relative; }
.kz-hist.new::after { content: ""; position: absolute; top: 7px; right: 7px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent, #2997ff); box-shadow: 0 0 0 2px var(--card); }
.kz-past, .kz-live { display: flex; flex-direction: column; gap: 10px; }
.kz-past:empty, .kz-live:empty { display: none; }
.kz-past .kz-msg { animation: none; }
.kz-h-day { align-self: center; margin-top: 4px; font-size: 11.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--dim); }
.kz-h-note { align-self: center; max-width: 92%; margin: 0; text-align: center; font-size: 12.5px; line-height: 1.45; color: var(--dim); }
.kz-h-note .btn { margin-left: 6px; }
.kz-h-end, .kz-h-img { display: block; margin-top: 6px; font-size: 12.5px; line-height: 1.4; color: var(--dim); white-space: normal; }
.kz-h-img { display: table; padding: 2px 8px; border: 1px solid var(--border-hi); border-radius: 8px; }
.kz-msg.me.unsent { opacity: .55; }  /* Stop came before it went out */
.kz-toast {
  position: fixed; z-index: 45; left: 50%; transform: translateX(-50%); bottom: 84px; max-width: calc(100vw - 32px);
  padding: 9px 14px; border-radius: 12px; background: var(--card-hi); border: 1px solid var(--border-hi); color: var(--soft); font-size: 13px;
  box-shadow: 0 12px 30px rgba(0,0,0,.45);
}

@media (prefers-reduced-motion: reduce) {
  .card.reveal, .dot, .kz-panel, .kz-working i, .kz-icon.on, .rp-round.on, .lvbar span, .bar-fill, .prep .bar span { animation: none !important; }
  html, body, .card, a.go, .btn, .kz-icon, .kz-send, .todo-row .tick, .tile, .dayline .nowmark { transition: none !important; }
  a.go:hover, .btn:hover, .kz-icon:hover, .kz-send:hover, .tile:hover { transform: none; }
}

/* ---------- small screens: Home stacks and scrolls ---------- */
@media (max-width: 1180px) {
  .page { padding: 18px 16px 16px; }
  .page.home { height: auto; min-height: 100dvh; overflow: visible; padding: 16px 16px 12px; }
  .page.home .kz-bar { position: sticky; bottom: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.35); }
  .home-grid { grid-template-columns: minmax(0, 1fr); grid-template-rows: none; }
  .home-grid > *, .home-grid .stat-row { grid-column: 1 / -1 !important; grid-row: auto !important; }
  .home-grid .stat-row { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
  .stat-row > .card { min-height: 150px; }
  .hero { min-height: 250px; }
  .upnext { min-height: 220px; }
  .todo .rows { max-height: 520px; }
  .hero h1 { font-size: 32px; }
  .topbar { flex-wrap: wrap; height: auto; row-gap: 8px; }
  .status { flex-wrap: wrap; row-gap: 6px; }
  .subject-row { grid-template-columns: 82px minmax(0, 1fr) 40px; row-gap: 4px; }
  .subject-row .next, .subject-row .flags { grid-column: 2 / -1; justify-content: flex-start; }
}
/* Windows shorter than any supported laptop viewport: let Home scroll rather than clip. */
@media (max-height: 600px) and (min-width: 1181px) {
  .page.home { height: auto; overflow: visible; }
  .home-grid { grid-template-rows: 300px 160px 210px; }
}
@media (max-width: 1000px) {
  .two-col { grid-template-columns: 1fr; }
  .col-8, .col-7, .col-6, .col-5, .col-4, .col-3 { grid-column: 1 / -1; }
  .grade-head { display: none; }
  .grade-row { grid-template-columns: 1fr 54px; row-gap: 8px; }
  .grade-row .lvbar, .grade-row .paper, .grade-row .pace { grid-column: 1 / -1; }
  .ledger-row { grid-template-columns: 1fr; gap: 6px; }
  .mistake-row { grid-template-columns: 80px minmax(0, 1fr); }
  .mistake-row .code, .mistake-row .type-chip { display: none; }
  .checkin-inline .slept { flex-basis: 100%; }
}
@media (max-width: 520px) {
  .kz-bar { padding-left: 10px; }
  .kz-bar .mark { display: none; }
  .kz-icon { width: 36px; height: 36px; }
  .kz-send { width: 40px; height: 40px; }
  .kz-panel { bottom: 76px; right: 16px; }
  .title-card h1 { font-size: 44px; }
}
/* The narrowest phones (320 px): six controls in the bar still leave room to type. */
@media (max-width: 350px) {
  .kz-bar { gap: 2px; padding-left: 8px; }
  .kz-icon { width: 34px; height: 34px; }
}
html.settled .card.reveal, html.settled .lvbar span, html.settled .bar-fill, html.settled .prep .bar span { animation: none; }
.note-line { font-size: 14px; color: var(--muted); line-height: 1.45; }
.ci-grid { display: flex; flex-wrap: wrap; gap: 18px 26px; align-items: flex-end; }
.ci-group { display: flex; gap: 12px; align-items: flex-end; }
.ci-grid .field.grow { flex: 1 1 220px; }
.ci-grid .field.grow .input { width: 100%; }
.ci-grid .actions { margin-left: auto; }
.checkin .status:empty { display: none; }

/* Topic tiles that lead to a built Masterclass */
.tile .mc-badge { align-self: flex-start; font-size: 10.5px; font-weight: 650; letter-spacing: .04em; text-transform: uppercase; padding: 2px 7px; border-radius: 999px; background: rgba(255,255,255,.12); color: #f5f5f7; box-shadow: inset 0 0 0 1px rgba(255,255,255,.18); }
.tile.has-mc::after { content: ''; position: absolute; inset: 0; border-radius: 14px; pointer-events: none; box-shadow: inset 0 0 0 1px rgba(255,255,255,.22); }
.subjects .card-head #subjects-aside { margin-left: auto; }
/* Subjects' links to the study pages: quiet words, not arrows. */
.subjects .card-head { justify-content: flex-start; }
.subjects .card-head .aside { margin-left: auto; }
.lib-links { display: flex; gap: 16px; margin-left: 18px; font-size: 12.5px; }
.lib-links a { color: var(--muted); white-space: nowrap; transition: color .2s; }
.lib-links a:hover { color: var(--text); }

/* Subject page: its homework (homework.css styles the Homework page itself) */
.hw-mini { display: flex; flex-direction: column; }
.hw-mini:empty { display: none; }
.hw-mini a.row { grid-template-columns: minmax(0, 1fr) auto auto; gap: 14px; padding: 10px 8px; align-items: center; font-size: 15px; }
.hw-mini .meta { font-size: 13px; color: var(--dim); white-space: nowrap; }
.hw-mini .mk { font-size: 13px; color: #ffb36b; white-space: nowrap; }
