/* Study MCP web UI. Built from Redo Queue's stylesheet (redo-tracker-v2, apps/web/src):
   styles/tokens.css + fonts.css + base.css, App.module.css (header, tabs, badge, chips),
   components/Blocks.module.css (grouped lists with the left stripe, rows, rating buttons),
   features/today/Today.module.css (status line), features/agent/Agent.module.css (connect steps,
   activity rows), features/settings/Settings.module.css. CSS-module names are translated to plain
   class names; the comments say where each block came from.

   Redo is light only ("Paper" tokens; text colours darkened so every text/background pair meets
   WCAG AA 4.5:1), and so is this page. */

/* ------------------------------------------------------------------ fonts (styles/fonts.css) */
/* Self-hosted variable fonts, Latin subset (@fontsource-variable 5.3.0, SIL OFL 1.1: see fonts/OFL-*.txt). */
@font-face {
  font-family: 'Space Grotesk';
  font-style: normal;
  font-display: swap;
  font-weight: 300 700;
  src: url('fonts/space-grotesk-latin-wght-normal.woff2') format('woff2-variations'),
    url('fonts/space-grotesk-latin-wght-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
    U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-display: swap;
  font-weight: 100 800;
  src: url('fonts/jetbrains-mono-latin-wght-normal.woff2') format('woff2-variations'),
    url('fonts/jetbrains-mono-latin-wght-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
    U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ------------------------------------------------------------------ tokens (styles/tokens.css) */
:root {
  --bg: #fbfbf9;
  --surface: #fff;
  --surface-2: #f4f4f0;
  --ink: #1a1c22;
  --muted: #5f636c;
  --faint: #6b6f78;
  --rule: #e6e6e1;
  --bad: #bf2f26;
  --bad-soft: #fbeae8;
  --good: #2b7353;
  --good-soft: #e8f3ee;
  --mid: #935f0f;
  --mid-soft: #f8f0e2;
  --link: #1f5fa8;
  --accent: #1a1c22;
  --on-accent: #fbfbf9;
  --focus: #1a1c22;
  --hover: #f4f4f0;
  --display: 'Space Grotesk', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --body: 'Space Grotesk', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --radius: 3px;
  color-scheme: light;
}

/* ------------------------------------------------------------------ base (styles/base.css) */
* {
  box-sizing: border-box;
}
[hidden] {
  display: none !important;
}
html {
  background: var(--bg);
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--body);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  line-height: 1.45;
}
button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
a {
  color: inherit;
}
a:hover {
  text-underline-offset: 2px;
}
p {
  margin: 0;
}
form {
  margin: 0;
}
code {
  font-family: var(--mono);
}
.wrap {
  max-width: 680px;
  margin: 0 auto;
  padding-block: calc(28px + env(safe-area-inset-top, 0px)) 120px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Text colours (base.css .r1 / .r2 / .r3, .late) */
.red {
  color: var(--bad);
}
.amber {
  color: var(--mid);
}
.green {
  color: var(--good);
}
.muted {
  color: var(--muted);
}

/* ------------------------------------------------------------------ header (App.module.css .top, .tools) */
.banner {
  /* App.module.css .sync.offline */
  font-family: var(--mono);
  font-size: 10.5px;
  border-radius: 2px;
  padding: 3px 8px;
  margin-bottom: 14px;
  background: var(--mid-soft);
  color: var(--mid);
}
.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.title {
  font-family: var(--display);
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0;
  line-height: 1.1;
}
.title a {
  text-decoration: none;
}
.chips {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
/* App.module.css .find (the header's Activity link) */
.chip {
  font-family: var(--mono);
  font-size: 10.5px;
  line-height: 1.45;
  border: 1px solid var(--rule);
  border-radius: 2px;
  padding: 2px 7px;
  text-decoration: none;
  white-space: nowrap;
  color: var(--muted);
  background: none;
  cursor: pointer;
}
.chip:hover {
  color: var(--ink);
  border-color: var(--ink);
}
/* App.module.css .account (the signed-in user) */
.chip.account {
  border-radius: var(--radius);
  padding: 3px 8px;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: default;
}
.chip.account:hover {
  border-color: var(--rule);
}

/* ------------------------------------------------------------------ tabs + badge (App.module.css) */
/* Not a scroll container: at high zoom the tabs wrap instead of growing a scrollbar. */
.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0 4px;
  margin: 0 0 24px;
  border-bottom: 2px solid var(--ink);
}
.tabs a {
  padding: 8px 10px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  text-decoration: none;
}
.tabs a:first-child {
  padding-left: 0;
}
.tabs a:hover {
  color: var(--ink);
}
.tabs a[aria-current='page'] {
  color: var(--ink);
  font-weight: 700;
}
.count {
  display: inline-block;
  min-width: 17px;
  padding: 0 5px;
  margin-left: 5px;
  border-radius: 9px;
  background: var(--bad);
  color: #fff;
  font-size: 10px;
  font-weight: 400;
  line-height: 16px;
  text-align: center;
}

/* ------------------------------------------------------------------ status line (Today.module.css .summary) */
.statusline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 8px;
  margin-bottom: 14px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
}
.statusline b {
  color: var(--ink);
  font-weight: 700;
}
.sep {
  color: var(--faint);
}

/* ------------------------------------------------------------------ section label (base.css) */
.section-label {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 30px 0 10px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
}
.section-label > span:last-child {
  text-align: right;
}

/* ------------------------------------------------------------------ groups (Blocks.module.css .exam, .ehead, .card, .row) */
.group {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-left: 3px solid var(--good);
  border-radius: var(--radius);
  margin-bottom: 8px;
  scroll-margin-top: 16px;
}
.group.bad {
  border-left-color: var(--bad);
}
.group.warn {
  border-left-color: var(--mid);
}
.group.off {
  border-left-color: var(--rule);
}
.ghead {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 8px;
  padding: 9px 12px;
  font-family: var(--mono);
  font-size: 12px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--rule);
}
.ghead h2 {
  font-size: inherit;
  font-weight: 700;
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}
.ghead h2 span {
  font-weight: 400;
  color: var(--muted);
}
.ghead .right {
  margin-left: auto;
  display: flex;
  gap: 4px 10px;
  align-items: center;
  flex-wrap: wrap;
  color: var(--muted);
}

/* One row of a group: what it is on the left (Blocks .q + .meta), the controls on the right. */
.item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr);
  gap: 8px 18px;
  padding: 10px 12px;
  border-top: 1px solid var(--rule);
  align-items: start;
}
.ghead + .item,
.group > .item:first-child {
  border-top: 0;
}
.item.wide {
  grid-template-columns: minmax(0, 1fr);
}
.item:focus-within {
  background: color-mix(in srgb, var(--surface-2) 40%, var(--surface));
}
.name {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 500;
  overflow-wrap: anywhere;
}
.sub {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--muted);
  margin-top: 1px;
}
.sub a {
  color: var(--link);
}
.sub code,
.hint code {
  font-size: inherit;
  color: var(--ink);
  overflow-wrap: anywhere;
}
.ctl {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  font-size: 13.5px;
}
.inline {
  display: flex;
  gap: 6px 8px;
  align-items: center;
  flex-wrap: wrap;
}

/* Messages inside a group (App.module.css .sync.error / .saving, as full-width rows) */
.errors,
.notice {
  font-family: var(--mono);
  font-size: 11px;
  padding: 7px 12px;
  border-top: 1px solid var(--rule);
}
.ghead + .errors,
.ghead + .notice,
.group > .errors:first-child,
.group > .notice:first-child {
  border-top: 0;
}
.errors {
  background: var(--bad-soft);
  color: var(--bad);
}
.errors p + p {
  margin-top: 2px;
}
.notice.green {
  background: var(--good-soft);
}
.notice.red {
  background: var(--bad-soft);
}
.notice.muted {
  background: var(--surface-2);
}

/* ------------------------------------------------------------------ inputs (base.css input.f) */
input[type='text'],
input[type='password'],
input[type='time'],
input[type='number'],
input[type='file'],
select {
  width: 100%;
  min-width: 0;
  font-family: var(--mono);
  font-size: 13px;
  padding: 8px 10px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--ink);
}
input[type='file'] {
  padding: 5px 8px;
  font-size: 11px;
}
input::placeholder {
  color: var(--faint);
}
input:focus,
select:focus {
  outline: 2px solid var(--focus);
  outline-offset: -1px;
}
input[type='checkbox'] {
  accent-color: var(--ink);
  margin: 0;
}
.w-auto {
  width: auto !important;
}
.w-num {
  width: 80px !important;
  text-align: center;
}
.grow {
  flex: 1 1 140px;
  width: auto !important;
}

/* ------------------------------------------------------------------ buttons (base.css .btn) */
.btn {
  font-family: var(--body);
  font-weight: 700;
  font-size: 13px;
  line-height: 1.45;
  padding: 9px 16px;
  background: var(--accent);
  color: var(--on-accent);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  display: inline-block;
  text-align: center;
}
.btn:disabled {
  opacity: 0.3;
  cursor: default;
}
.btn:active {
  transform: translateY(1px);
}
.btn.ghost {
  background: none;
  color: var(--ink);
  border: 1px solid var(--rule);
  font-weight: 500;
}
.btn.ghost:hover {
  background: var(--hover);
}
.btn.small {
  padding: 4px 10px;
  font-size: 12px;
}
.btn.danger {
  background: none;
  color: var(--bad);
  border: 1px solid var(--bad-soft);
  font-weight: 500;
}
.btn.danger:hover {
  background: var(--bad-soft);
}
.btn.danger.solid {
  background: var(--bad);
  color: #fff;
  border-color: var(--bad);
  font-weight: 700;
}

/* ------------------------------------------------------------------ state tags (Blocks.module.css .rate .b1 / .b2 / .b3) */
/* Blanked = bad, Got there = warn, Nailed it = ok. */
.tag {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  min-width: 64px;
  padding: 4px 8px 3px;
  border-radius: var(--radius);
  font-family: var(--body);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.25;
  white-space: nowrap;
}
.tag small {
  font-family: var(--mono);
  font-size: 9.5px;
  font-weight: 400;
}
.tag.bad {
  background: var(--bad-soft);
  color: var(--bad);
}
.tag.warn {
  background: var(--mid-soft);
  color: var(--mid);
}
.tag.ok {
  background: var(--good-soft);
  color: var(--good);
}
.tag.off {
  background: var(--surface-2);
  color: var(--muted);
}
/* base.css .pill, in the soft colours */
.tag.mini {
  display: inline-block;
  min-width: 0;
  font-family: var(--mono);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.03em;
  border-radius: 2px;
  padding: 1px 6px;
  line-height: 1.6;
  vertical-align: 1px;
}

/* ------------------------------------------------------------------ small text (base.css .hint, .chk) */
.hint {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--muted);
}
.hint .btn {
  margin-left: 4px;
}
.check {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  font-size: 12.5px;
  color: var(--muted);
  cursor: pointer;
}
.result {
  font-family: var(--mono);
  font-size: 11px;
}

/* ------------------------------------------------------------------ lists inside a row (Blocks .card borders, Agent .apps) */
.file {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 12px;
  overflow-wrap: anywhere;
}
.file + .file {
  border-top: 1px solid var(--rule);
  padding-top: 6px;
}
.keybox {
  display: flex;
  gap: 8px;
  align-items: center;
}
.keybox code {
  /* Agent.module.css .url code */
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  white-space: nowrap;
  font-size: 11.5px;
  background: var(--surface-2);
  border-radius: var(--radius);
  padding: 6px 10px;
}
.projects label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-top: 1px solid var(--rule);
  font-size: 13.5px;
  cursor: pointer;
}
.projects label:first-of-type {
  border-top: 0;
  padding-top: 0;
}
.projects .n {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--muted);
}
.courses .course {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 2px 8px;
  padding: 7px 0;
  border-top: 1px solid var(--rule);
  align-items: center;
  font-size: 13.5px;
}
.courses .course:first-child {
  border-top: 0;
  padding-top: 0;
}
.courses .course label {
  cursor: pointer;
}
.courses .meta {
  grid-column: 2 / 4;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--muted);
}

/* ------------------------------------------------------------------ tables (base.css table) */
.table-wrap {
  overflow-x: auto;
}
table {
  border-collapse: collapse;
  width: 100%;
  font-family: var(--mono);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
th {
  text-align: left;
  font-weight: 500;
  color: var(--muted);
  padding: 4px 6px 6px 0;
  border-bottom: 1px solid var(--rule);
  white-space: nowrap;
}
td {
  padding: 4px 6px 4px 0;
}
td input,
td select {
  padding: 6px 7px;
  font-size: 12px;
}
td.x {
  text-align: center;
}

/* ------------------------------------------------------------------ save bar + form errors */
.savebar {
  position: sticky;
  bottom: 0;
  margin-top: 24px;
  padding-block: 12px calc(12px + env(safe-area-inset-bottom, 0px));
  background: var(--bg);
  border-top: 2px solid var(--ink);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  font-family: var(--mono);
  font-size: 11px;
}
.errbox {
  margin-bottom: 14px;
  border-left: 3px solid var(--bad);
  background: var(--bad-soft);
  color: var(--bad);
  padding: 8px 12px;
  border-radius: var(--radius);
  font-family: var(--mono);
  font-size: 12px;
}

/* ------------------------------------------------------------------ connect (Agent.module.css .steps, .url) */
.kv {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
}
.kv > div {
  padding: 8px 12px;
  border-top: 1px solid var(--rule);
  min-width: 0;
  overflow-wrap: anywhere;
  font-family: var(--mono);
  font-size: 11.5px;
}
.kv > div:nth-child(-n + 2) {
  border-top: 0;
}
.kv .k {
  color: var(--muted);
}
.step {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr);
  padding: 9px 12px;
  border-top: 1px solid var(--rule);
  font-size: 13.5px;
  color: var(--muted);
}
.step:first-child {
  border-top: 0;
}
.step b {
  color: var(--ink);
  font-weight: 600;
}
.step .num {
  font-family: var(--mono);
  font-weight: 700;
  color: var(--ink);
}
.step code,
.step .url {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink);
  background: var(--surface-2);
  border-radius: var(--radius);
  padding: 1px 6px;
  overflow-wrap: anywhere;
}
.below {
  margin-top: 10px;
}

/* ------------------------------------------------------------------ activity rows (Agent.module.css .row, .time, .summary) */
.log {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  gap: 2px 10px;
  align-items: start;
  padding: 8px 12px;
  border-top: 1px solid var(--rule);
}
.log:first-child {
  border-top: 0;
}
.log .t {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  padding-top: 2px;
  font-variant-numeric: tabular-nums;
}
.log .tool {
  font-family: var(--mono);
  font-size: 13px;
  overflow-wrap: anywhere;
}
.log .args {
  grid-column: 2 / 3;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

/* base.css .empty (a dashed box on its own; a plain row inside a group) */
.empty {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  border: 1px dashed var(--rule);
  border-radius: var(--radius);
  padding: 18px;
  text-align: center;
}
.group > .empty {
  border: 0;
}

/* ------------------------------------------------------------------ logged out (App.module.css .gateBox) */
.hero {
  margin-top: 40px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.hero .big {
  font-family: var(--display);
  font-size: 20px;
  font-weight: 500;
  line-height: 1.35;
}
.hero ul {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 13.5px;
  color: var(--muted);
}
.hero li::before {
  content: '· ';
  color: var(--faint);
}

/* ------------------------------------------------------------------ mobile (Blocks @560, App @480, Agent @520) */
@media (max-width: 560px) {
  .item {
    grid-template-columns: minmax(0, 1fr);
  }
  .kv {
    grid-template-columns: minmax(0, 1fr);
  }
  .kv > div.k {
    padding-bottom: 0;
  }
  .kv > div.k + div {
    border-top: 0;
    padding-top: 2px;
  }
  .kv > div:nth-child(2) {
    border-top: 0;
  }
}
@media (max-width: 520px) {
  .log {
    grid-template-columns: minmax(0, 1fr) auto;
  }
  .log .t {
    grid-column: 1 / -1;
    padding: 0;
  }
  .log .args {
    grid-column: 1 / -1;
  }
}
@media (max-width: 480px) {
  .tabs {
    gap: 0;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .tabs::-webkit-scrollbar {
    display: none;
  }
  .tabs a {
    padding: 8px 5px;
    font-size: 11px;
  }
  .tabs a:first-child {
    padding-left: 0;
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
  .btn:active {
    transform: none;
  }
}

/* ================================================================== Study MCP components
   On top of Redo's foundations above (tokens, type, rule, groups). Sources = a status board: one
   line per source, details open on demand. Calendar = a week grid in the same paper/mono language.
   No inline styles anywhere (CSP): the calendar's positions and course colours come from a nonce'd
   <style> block with per-element classes (server/webcal.py). */

/* ---------- status dot + word (replaces Redo's two-line rating chips) */
.state { display: inline-flex; align-items: center; gap: 6px; font-family: var(--mono); font-size: 11.5px; white-space: nowrap; }
.state::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; }
.state.ok { color: var(--good); }
.state.bad { color: var(--bad); }
.state.warn { color: var(--mid); }
.state.off { color: var(--faint); }

/* ---------- source board */
details.src { background: var(--surface); border: 1px solid var(--rule); border-left: 3px solid var(--good); border-radius: var(--radius); margin-bottom: 6px; }
details.src.bad { border-left-color: var(--bad); }
details.src.warn { border-left-color: var(--mid); }
details.src.off { border-left-color: var(--rule); }
details.src > summary {
  list-style: none; cursor: pointer;
  display: grid; grid-template-columns: 120px minmax(0, 1fr) auto 16px;
  align-items: center; gap: 2px 14px; padding: 13px 14px;
}
details.src > summary::-webkit-details-marker { display: none; }
details.src > summary:hover { background: var(--hover); }
details.src[open] > summary { border-bottom: 1px solid var(--rule); background: var(--surface-2); }
.sname { font-family: var(--mono); font-size: 14px; font-weight: 700; }
.swhat { font-size: 13.5px; color: var(--ink); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.swhat.red { color: var(--bad); }
.swhen { font-family: var(--mono); font-size: 11px; color: var(--muted); text-align: right; }
.chev { color: var(--faint); font-family: var(--mono); font-size: 11px; text-align: center; }
details[open] > summary .chev { transform: rotate(180deg); }
details.src .item { padding: 13px 14px; }
details.src > .notice, details.src > .errors { margin: 10px 14px 0; }
.howto { font-family: var(--mono); font-size: 10.5px; color: var(--muted); }
.howto > summary { cursor: pointer; color: var(--link); list-style: none; }
.howto > summary::-webkit-details-marker { display: none; }
.howto[open] > summary { margin-bottom: 2px; }
.gactions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 10px 14px; border-top: 1px solid var(--rule); }
.gactions .result { margin-left: auto; }
.gactions .result + .result { margin-left: 0; }
.courses .course { grid-template-columns: auto minmax(0, 1fr) auto; }
.savenote { margin: 0 0 10px; }

@media (max-width: 560px) {
  details.src > summary { grid-template-columns: minmax(0, 1fr) auto; }
  .swhat { grid-column: 1 / -1; grid-row: 2; white-space: normal; font-size: 12.5px; }
  .chev { display: none; }
}

/* ---------- Calendar tab: deadlines you can ignore / hide from Claude */
.dues .due-row {
  display: grid; grid-template-columns: 84px minmax(0, 1fr) auto auto;
  align-items: center; gap: 4px 12px; padding: 11px 14px; border-top: 1px solid var(--rule);
}
.dues .due-row:first-child { border-top: 0; }
.when { font-family: var(--mono); font-size: 11.5px; line-height: 1.3; }
.when small { display: block; color: var(--muted); font-size: 10px; }
.when.soon { color: var(--bad); font-weight: 700; }
.what { min-width: 0; }
.what b { font-weight: 600; font-size: 13.5px; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.what .sub { margin-top: 1px; }
.cdot { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; vertical-align: 0; background: var(--c, var(--faint)); }

/* the ⋯ menu (works without JS: a details with a form of submit buttons) */
details.menu { position: relative; }
details.menu > summary {
  list-style: none; cursor: pointer; font-family: var(--mono); font-size: 14px; line-height: 1;
  width: 32px; height: 32px; display: grid; place-items: center; border-radius: var(--radius); color: var(--muted);
}
details.menu > summary::-webkit-details-marker { display: none; }
details.menu > summary:hover, details.menu[open] > summary { background: var(--hover); color: var(--ink); }
details.menu .pop {
  position: absolute; right: 0; top: 36px; z-index: 5; min-width: 230px;
  background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius);
  box-shadow: 0 8px 28px rgba(26, 28, 34, 0.14), 0 1px 3px rgba(26, 28, 34, 0.08); padding: 4px;
}
.pop button {
  display: block; width: 100%; text-align: left; background: none; border: 0; border-radius: 2px;
  padding: 9px 10px; cursor: pointer; font: inherit; font-size: 13px; color: var(--ink);
}
.pop button:hover { background: var(--hover); }
.pop button small { display: block; font-family: var(--mono); font-size: 10px; color: var(--muted); margin-top: 1px; }

details.parked { border-top: 1px solid var(--rule); }
details.parked > summary { list-style: none; cursor: pointer; padding: 9px 14px; font-family: var(--mono); font-size: 11px; color: var(--muted); }
details.parked > summary::-webkit-details-marker { display: none; }
details.parked .due-row { opacity: .6; }
details.parked .due-row:focus-within, details.parked .due-row:hover { opacity: 1; }
details.parked .due-row .what b { text-decoration: line-through; text-decoration-color: var(--faint); }
.tag.mini.off { background: var(--surface-2); color: var(--muted); }

/* ---------- week toolbar */
.weekbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin: 26px 0 10px; }
.weekbar h2 { font-family: var(--display); font-size: 18px; margin: 0; letter-spacing: -.01em; }
.weekbar h2 small { font-family: var(--mono); font-size: 11px; color: var(--muted); font-weight: 400; margin-left: 6px; }
.seg { display: inline-flex; border: 1px solid var(--rule); border-radius: var(--radius); overflow: hidden; }
.seg a { padding: 7px 12px; font-family: var(--mono); font-size: 12px; text-decoration: none; color: var(--ink); background: var(--surface); }
.seg a + a { border-left: 1px solid var(--rule); }
.seg a:hover { background: var(--hover); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-family: var(--mono); font-size: 10.5px; color: var(--muted); margin: 0 0 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.legend .l-free { background: repeating-linear-gradient(135deg, var(--good-soft) 0 4px, #fff 4px 7px); border: 1px solid var(--good-soft); }
.legend .l-due { background: var(--bad); }
.legend .l-out { background: var(--faint); }

/* ---------- week grid: same layout on every screen; narrow screens scroll by day.
   --hour: height of one hour; --hours (set per page) and the p<N> classes (top/height as
   calc(var(--hour) * n)) come from the page's nonce'd <style>. */
.weekwrap {
  border: 1px solid var(--rule); border-radius: var(--radius); background: var(--surface);
  overflow-x: auto; overscroll-behavior-x: contain; scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch; scrollbar-width: thin;
}
.week {
  --hour: 40px; --hours: 13; --days: 5;
  display: grid; grid-template-columns: 40px repeat(var(--days), minmax(124px, 1fr));
  min-width: 100%;
}
.week.d6 { --days: 6; }
.week.d7 { --days: 7; }
.week > * { scroll-snap-align: start; }
.week .corner, .week .hours { position: sticky; left: 0; z-index: 3; background: var(--surface); scroll-snap-align: none; }
.week .corner { border-bottom: 1px solid var(--rule); }
.week .dh { padding: 8px 8px 7px; border-bottom: 1px solid var(--rule); border-left: 1px solid var(--rule); }
.week .dh b { display: block; font-family: var(--mono); font-size: 12px; }
.week .dh span { font-family: var(--mono); font-size: 10px; color: var(--muted); }
.week .dh.today { background: var(--ink); color: var(--on-accent); }
.week .dh.today span { color: color-mix(in srgb, var(--on-accent) 75%, transparent); }
.hours { height: calc(var(--hour) * var(--hours)); border-right: 1px solid var(--rule); }
.hours span { position: absolute; right: 5px; font-family: var(--mono); font-size: 9.5px; color: var(--faint); transform: translateY(-50%); }
.hours span:first-child { transform: none; }
.day {
  position: relative; height: calc(var(--hour) * var(--hours)); border-left: 1px solid var(--rule);
  background-image: linear-gradient(to bottom, var(--rule) 1px, transparent 1px);
  background-size: 100% var(--hour);
}
.day.today { background-color: color-mix(in srgb, var(--surface-2) 55%, var(--surface)); }

.ev { position: absolute; left: 4px; right: 4px; border-radius: 3px; overflow: hidden; }
.ev.class {
  background: var(--surface); border: 1px solid var(--rule); border-left: 3px solid var(--c, var(--ink));
  padding: 4px 6px; font-size: 11px; line-height: 1.25; box-shadow: 0 1px 2px rgba(26, 28, 34, 0.06); z-index: 1;
}
.ev.class b { display: block; font-size: 11.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev.class span { font-family: var(--mono); font-size: 9.5px; color: var(--muted); white-space: nowrap; }
.ev.class.lane0of2 { right: calc(50% + 1px); }
.ev.class.lane1of2 { left: calc(50% + 1px); }
.ev.class.lane0of3 { right: calc(66.6% + 1px); }
.ev.class.lane1of3 { left: calc(33.3% + 1px); right: calc(33.3% + 1px); }
.ev.class.lane2of3 { left: calc(66.6% + 1px); }
.ev.free {
  left: 50%; right: 4px; border-radius: 2px;
  background: repeating-linear-gradient(135deg, var(--good-soft) 0 5px, transparent 5px 9px);
  color: var(--good); font-family: var(--mono); font-size: 9px; padding: 2px 4px; text-align: right;
}
.ev.mark { left: 0; right: 0; height: 0; overflow: visible; border-top: 2px solid var(--bad); z-index: 2; }
.ev.mark.out { border-top: 1px dashed var(--faint); }
.ev.mark span {
  position: absolute; top: -10px; left: 4px; max-width: calc(100% - 8px);
  background: var(--bad); color: #fff; font-family: var(--mono); font-size: 9.5px; line-height: 16px;
  padding: 0 5px; border-radius: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ev.mark.out span { background: var(--surface-2); color: var(--muted); }
.now { position: absolute; left: 0; right: 0; height: 0; border-top: 2px solid var(--link); z-index: 4; }
.now::before { content: ''; position: absolute; left: -4px; top: -5px; width: 8px; height: 8px; border-radius: 50%; background: var(--link); }

.swipehint { display: none; font-family: var(--mono); font-size: 10.5px; color: var(--muted); margin: 6px 0 0; }

@media (max-width: 560px) {
  .dues .due-row { grid-template-columns: 62px minmax(0, 1fr) auto; padding: 11px 10px 11px 12px; }
  .dues .due-row .state, .dues .due-row .tag { grid-column: 2; grid-row: 2; justify-self: start; }
  .dues .due-row details.menu { grid-column: 3; grid-row: 1 / 3; }
  .week { --hour: 44px; grid-template-columns: 36px repeat(var(--days), calc((100vw - 36px - 34px) / 2.15)); }
  .ev.class { font-size: 10.5px; }
  .weekbar h2 { font-size: 16px; }
  .swipehint { display: block; }
}
@media (prefers-reduced-motion: no-preference) { .weekwrap { scroll-behavior: smooth; } }

/* ---------- course colours (user-chosen; red is reserved for deadlines) */
details.colours { margin: -2px 0 10px; }
details.colours > summary { list-style: none; cursor: pointer; display: inline-block; font-family: var(--mono); font-size: 10.5px; color: var(--link); }
details.colours > summary::-webkit-details-marker { display: none; }
.colours .group { margin-top: 8px; }
.crow { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 8px 12px; padding: 10px 14px; border-top: 1px solid var(--rule); }
.crow:first-of-type { border-top: 0; }
.crow .cname { font-size: 13.5px; font-weight: 600; }
.swatches { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.swatches label { position: relative; cursor: pointer; }
.swatches input[type='radio'] { position: absolute; opacity: 0; width: 1px; height: 1px; }
.swatches .sw { display: block; width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--rule); }
.swatches input:checked + .sw { box-shadow: 0 0 0 2px var(--ink); }
.swatches input:focus-visible + .sw { outline: 2px solid var(--focus); outline-offset: 2px; }
.swatches input[type='color'] { width: 30px; height: 30px; padding: 0; border: 1px solid var(--rule); border-radius: 50%; background: none; cursor: pointer; }
.sw.s-blue { background: #1f5fa8; }
.sw.s-green { background: #2b7353; }
.sw.s-amber { background: #935f0f; }
.sw.s-purple { background: #7a3f99; }
.sw.s-magenta { background: #a83a72; }
.sw.s-teal { background: #0f7c86; }
.sw.s-slate { background: #5f636c; }
@media (max-width: 560px) { .crow { grid-template-columns: minmax(0, 1fr); } .swatches .sw { width: 30px; height: 30px; } }
