/* ============================================================
   Semester HQ — design tokens
   Every text/background pair passes WCAG AA (checked at design
   time); course colors validated for CVD separation.
   ============================================================ */
:root {
  --bg: #f4f1ea;
  --surface: #ffffff;
  --surface-2: #f1efe9;
  --text: #1c2422;
  --ink: #14231d;
  --muted: #51615b;
  --accent: #17604a;
  --on-accent: #faf9f6;
  --accent-soft: rgba(23, 96, 74, 0.10);
  --danger: #b42318;
  --danger-soft: rgba(180, 35, 24, 0.08);
  --border: rgba(28, 36, 34, 0.14);
  --border-soft: rgba(28, 36, 34, 0.08);
  --hairline: rgba(28, 36, 34, 0.12);
  --shadow: 0 2px 16px rgba(28, 36, 34, 0.06);
  --shadow-lift: 0 6px 28px rgba(28, 36, 34, 0.10);
  --row-shadow: 0 1px 2px rgba(28, 36, 34, 0.05);
  --check-border: rgba(28, 36, 34, 0.2);

  --rail-bg: #14231d;
  --rail-text: #e9e7df;
  --rail-muted: #8fa79a;
  --rail-accent: #6fcfa5;
  --rail-track: #3a4a42;
  --spine-empty: #dcd8ce;

  --c-green: #0d8a5f;
  --c-ochre: #b45309;
  --c-violet: #7c3aed;
  --c-cyan: #0888ae;
  --c-rose: #be123c;
  --c-indigo: #4f46e5;

  --font-display: "Space Grotesk", system-ui, sans-serif;
  --font-body: "Inter", system-ui, sans-serif;
  --font-serif: "Instrument Serif", Georgia, serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;

  --radius: 16px;
  --radius-sm: 10px;
  --pill: 999px;
  --speed: 0.22s;

  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #12171a;
  --surface: #1b2226;
  --surface-2: #232c31;
  --text: #edf1ef;
  --ink: #edf1ef;
  --muted: #9cab9f;
  --accent: #6fcfa5;
  --on-accent: #12171a;
  --accent-soft: rgba(111, 207, 165, 0.13);
  --danger: #f28b7d;
  --danger-soft: rgba(242, 139, 125, 0.12);
  --border: rgba(237, 241, 239, 0.16);
  --border-soft: rgba(237, 241, 239, 0.09);
  --hairline: rgba(237, 241, 239, 0.14);
  --shadow: 0 2px 16px rgba(0, 0, 0, 0.35);
  --shadow-lift: 0 6px 28px rgba(0, 0, 0, 0.45);
  --row-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  --check-border: rgba(237, 241, 239, 0.25);

  --rail-bg: #0d1113;
  --rail-text: #edf1ef;
  --rail-muted: #9cab9f;
  --rail-accent: #6fcfa5;
  --rail-track: #2a3a33;
  --spine-empty: rgba(237, 241, 239, 0.14);

  --c-green: #37a97d;
  --c-ochre: #c98136;
  --c-violet: #9678ea;
  --c-cyan: #2ea3c6;
  --c-rose: #d95c7d;
  --c-indigo: #7385e6;

  color-scheme: dark;
}

/* ============================================================
   Base
   ============================================================ */
* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  /* Landscape on notched iPhones: keep content clear of the sensor housing */
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15.5px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background var(--speed) ease, color var(--speed) ease;
  display: flex;
  min-height: 100vh;
  flex-direction: column;
}

h1, h2, h3 {
  font-family: var(--font-display);
  line-height: 1.2;
  margin: 0 0 0.5em;
  letter-spacing: -0.01em;
}
h1 { font-size: 1.7rem; font-weight: 700; }
h2 { font-size: 1.15rem; font-weight: 600; }

a { color: var(--accent); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }

.shell {
  width: min(1060px, 100% - 2.5rem);
  margin-inline: auto;
}

main.shell { flex: 1; padding: 2rem 0 3.5rem; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  clip: rect(0 0 0 0); clip-path: inset(50%);
  overflow: hidden; white-space: nowrap;
}

.skip-link {
  position: absolute;
  left: 1rem; top: -3rem;
  z-index: 100;
  background: var(--accent);
  color: var(--on-accent);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  transition: top var(--speed) ease;
}
.skip-link:focus { top: 1rem; }

:focus-visible {
  outline: 2.5px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ============================================================
   Header
   ============================================================ */
.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-soft);
  /* Installed on iOS (viewport-fit=cover): keep content out of the notch/status bar */
  padding-top: env(safe-area-inset-top, 0px);
}

.header-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.7rem 0;
  flex-wrap: wrap;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.82rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink);
  text-decoration: none;
}
.brand-mark { width: 26px; height: 26px; }
.brand-mark rect { fill: var(--accent); }
.brand-mark path { stroke: var(--on-accent); }

.main-nav {
  display: flex;
  gap: 1.4rem;
  margin-left: auto;
}

.nav-link {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  text-decoration: none;
  transition: color var(--speed) ease;
}
.nav-link:hover { color: var(--text); }
.nav-link[aria-current="page"] {
  color: var(--ink);
  font-weight: 600;
  border-bottom: 2px solid var(--accent);
  padding-bottom: 2px;
}

.theme-toggle {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  width: 38px; height: 38px;
  border-radius: var(--pill);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background var(--speed) ease;
}
.theme-toggle:hover { background: var(--surface-2); }
.theme-toggle svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.icon-moon { display: block; }
.icon-sun { display: none; }
[data-theme="dark"] .icon-moon { display: none; }
[data-theme="dark"] .icon-sun { display: block; }

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.9rem;
  border-radius: var(--pill);
  border: 1px solid transparent;
  padding: 0.52rem 1.15rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: transform var(--speed) ease, background var(--speed) ease, box-shadow var(--speed) ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { box-shadow: var(--shadow-lift); }

.btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}
.btn-ghost:hover { background: var(--surface-2); }

.btn-danger { background: var(--danger); color: var(--surface); }
[data-theme="dark"] .btn-danger { color: var(--bg); }

.btn-danger-quiet {
  background: transparent;
  color: var(--danger);
  border-color: transparent;
}
.btn-danger-quiet:hover { background: var(--danger-soft); }

.btn-sm { font-size: 0.8rem; padding: 0.35rem 0.85rem; }

.btn-icon {
  background: transparent;
  border: none;
  color: var(--muted);
  width: 32px; height: 32px;
  border-radius: var(--pill);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background var(--speed) ease, color var(--speed) ease;
}
.btn-icon:hover { background: var(--surface-2); color: var(--text); }
.btn-icon svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.btn-icon.danger:hover { background: var(--danger-soft); color: var(--danger); }

/* ============================================================
   Views & cards
   ============================================================ */
.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}
.view-header h1 { margin: 0; }

.card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem 1.4rem;
}

/* ---- Week hero band (1b: editorial serif + semester spine) ---- */
.hero-band {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1.5rem;
  flex-wrap: wrap;
  padding: 30px 40px 22px;
  border-bottom: 1px solid var(--border);
}
.hero-eyebrow {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}
.hero-eyebrow .btn-icon { width: 26px; height: 26px; opacity: 0.55; }
.hero-eyebrow .btn-icon:hover, .hero-eyebrow .btn-icon:focus-visible { opacity: 1; }
.hero-week {
  font-family: var(--font-serif);
  font-size: 88px;
  font-weight: 400;
  line-height: 0.82;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.hero-week .hero-total {
  font-family: var(--font-mono);
  font-size: 1rem;
  letter-spacing: 0;
  color: var(--muted);
}

.spine-wrap { text-align: right; }
.spine {
  display: flex;
  gap: 3px;
  align-items: flex-end;
  height: 40px;
  justify-content: flex-end;
}
.spine .tick {
  width: 6px;
  height: 100%;
  border-radius: 2px;
  background: var(--spine-empty);
}
.spine .tick.past { background: var(--accent); }
.spine .tick.current {
  background: var(--accent);
  box-shadow: 0 0 0 2px rgba(23, 96, 74, 0.2);
}
.spine-caption {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 8px;
}

/* ---- Week body: list + dark load rail ---- */
.week-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 288px;
  gap: 0;
  align-items: stretch;
}
.week-list { padding: 20px 40px 34px 40px; min-width: 0; }

/* ---- Day groups & items ---- */
.day-group { margin-bottom: 1.1rem; }
.day-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 6px 0 12px;
  font-weight: 400;
}
.day-head .day-name {
  font-family: var(--font-serif);
  font-size: 1.35rem;
  color: var(--ink);
}
.day-head .day-date {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.day-head .today-tag {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 2px 8px;
  border-radius: 3px;
}
.day-head .day-rule { flex: 1; height: 1px; background: var(--hairline); align-self: center; }
.day-head.overdue-head .overdue-label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--danger);
}
.day-head.overdue-head .day-rule { background: rgba(180, 35, 24, 0.25); }
.day-head.overdue-head .overdue-count {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--danger);
}

.item-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.5rem; }

.item-row {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border-left: 3px solid var(--row-spine, var(--border));
  border-radius: 4px;
  box-shadow: var(--row-shadow);
  padding: 12px 14px;
  transition: opacity var(--speed) ease, transform var(--speed) ease;
}
.item-list { gap: 8px; }
/* Done items de-emphasize via muted color (still AA), never via opacity */
.item-row.done-item {
  background: var(--surface-2);
  box-shadow: none;
  border-left-color: color-mix(in srgb, var(--row-spine, var(--border)) 40%, transparent);
}
.item-row.done-item .item-title {
  color: var(--muted);
  text-decoration: line-through;
  text-decoration-thickness: 1.5px;
}
.item-row.done-item .course-chip { color: var(--muted) !important; }
.item-row.done-item .item-check:checked { background: var(--muted); border-color: var(--muted); }
.item-row.just-done { animation: settle 0.45s ease; }
@keyframes settle {
  0% { transform: scale(1); }
  35% { transform: scale(0.985); }
  100% { transform: scale(1); }
}

.item-check {
  appearance: none;
  width: 20px; height: 20px;
  flex: none;
  border: 2px solid var(--check-border);
  border-radius: 50%;
  cursor: pointer;
  display: grid;
  place-items: center;
  background: transparent;
  transition: background var(--speed) ease, border-color var(--speed) ease;
}
.item-check:hover { border-color: var(--accent); }
.item-check:checked {
  background: var(--accent);
  border-color: var(--accent);
}
.item-check:checked::after {
  content: "";
  width: 9px; height: 5px;
  border: 2.2px solid var(--on-accent);
  border-top: none; border-right: none;
  transform: rotate(-45deg) translateY(-1px);
}

.item-main { min-width: 0; flex: 1; }
.item-title { font-weight: 500; overflow-wrap: anywhere; color: var(--ink); }
.item-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.78rem;
  color: var(--muted);
  flex-wrap: wrap;
  margin-top: 2px;
}

.course-chip {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
}
.dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  flex: none;
  background: var(--dot-color, var(--muted));
}

.type-tag {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.type-tag.type-exam, .type-tag.type-project { color: var(--accent); font-weight: 600; }

.due-note { font-family: var(--font-mono); font-size: 0.72rem; font-variant-numeric: tabular-nums; }
.due-note.overdue-note { color: var(--danger); font-weight: 600; }

.item-actions { display: flex; gap: 0.15rem; flex: none; }

/* ---- Steps (subtasks) ---- */
.item-row { flex-wrap: wrap; }
.steps-chip {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  color: var(--muted);
  background: var(--surface-2);
  border: none;
  border-radius: 3px;
  padding: 2px 8px;
  cursor: pointer;
  transition: background var(--speed) ease, color var(--speed) ease;
}
.steps-chip:hover { color: var(--text); background: var(--border-soft); }
.steps-chip .chev { font-size: 0.6rem; }

.subtask-list {
  list-style: none;
  flex-basis: 100%;
  margin: 6px 0 0;
  padding: 0 0 0 34px;
  display: grid;
  gap: 6px;
}
.subtask-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.88rem;
}
.subtask-item .item-check { width: 16px; height: 16px; }
.subtask-item .item-check:checked::after { width: 7px; height: 4px; }
.subtask-item.done-sub .subtask-text {
  color: var(--muted);
  text-decoration: line-through;
}
.subtask-due-chip {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

/* Standalone step rows placed on their own due date */
.subtask-row { padding: 8px 14px; }
.subtask-row .item-title { font-size: 0.92rem; }
.subtask-row .item-check { width: 17px; height: 17px; }
.subtask-row .item-check:checked::after { width: 8px; height: 4px; }
.subtask-arrow { color: var(--muted); }

/* Step rows in the assignment dialog */
.subtask-form-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.5rem;
}
.subtask-form-row .subtask-title {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-size: 0.88rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.32rem 0.5rem;
}
.subtask-form-row .subtask-due {
  font: inherit;
  font-size: 0.85rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.3rem 0.4rem;
}

/* ---- Add assignment (dashed, mono) ---- */
.btn-add-dashed {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
  background: transparent;
  border: 1px dashed rgba(23, 96, 74, 0.4);
  border-radius: 4px;
  padding: 8px 14px;
  cursor: pointer;
  transition: background var(--speed) ease;
}
.btn-add-dashed:hover { background: var(--accent-soft); }
[data-theme="dark"] .btn-add-dashed { border-color: rgba(111, 207, 165, 0.4); }

/* ---- Load rail (dark workload panel) ---- */
.load-rail {
  background: var(--rail-bg);
  color: var(--rail-text);
  padding: 26px 28px;
}
.rail-title {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: 400;
  line-height: 1.05;
  color: var(--rail-text);
  margin: 0;
}
.rail-sub {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--rail-muted);
  margin: 8px 0 26px;
}
.rail-rows { display: flex; flex-direction: column; gap: 14px; }
.rail-row { display: flex; align-items: center; gap: 12px; }
.rail-row .rail-day {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  color: var(--rail-muted);
  width: 28px;
  flex: none;
}
.rail-row.is-today .rail-day { color: var(--rail-accent); font-weight: 600; }
.rail-row .rail-barwrap { flex: 1; min-width: 0; }
.rail-row .rail-bar {
  display: block;
  height: 8px;
  border-radius: 2px;
  background: var(--rail-accent);
}
.rail-row .rail-bar.rail-bar-zero { width: 6px; background: var(--rail-track); }
.rail-row .rail-count {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
  color: var(--rail-text);
  flex: none;
}
.rail-row .rail-count.is-zero { color: var(--rail-muted); }
.rail-foot {
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  margin-top: 22px;
  padding-top: 14px;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--rail-muted);
}

/* ---- Courses ---- */
.course-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
}
.course-card { display: flex; flex-direction: column; gap: 0.3rem; position: relative; }
.course-card .course-top {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.course-card .dot { width: 12px; height: 12px; }
.course-card .course-code {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
}
.course-card .course-name { color: var(--muted); font-size: 0.9rem; }
.course-card .course-count { font-size: 0.8rem; color: var(--muted); margin-top: 0.35rem; }
.course-card .item-actions { position: absolute; top: 0.85rem; right: 0.85rem; }

/* ---- Empty states & setup ---- */
.empty {
  text-align: center;
  padding: 3rem 1.5rem;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
  background: transparent;
}
.empty h2 { margin-bottom: 0.35rem; }
.empty p { color: var(--muted); max-width: 42ch; margin: 0 auto 1.2rem; }
.empty .empty-actions { display: flex; gap: 0.6rem; justify-content: center; flex-wrap: wrap; }

.welcome {
  text-align: center;
  padding: 3.5rem 1.5rem 3rem;
}
.welcome .brand-mark { width: 52px; height: 52px; margin-bottom: 1rem; }
.welcome h2 { font-size: 2rem; margin-bottom: 0.5rem; }
.welcome p { color: var(--muted); max-width: 46ch; margin: 0 auto 1.5rem; }
.welcome .empty-actions { display: flex; gap: 0.7rem; justify-content: center; flex-wrap: wrap; }
.welcome .privacy-note { font-size: 0.8rem; margin-top: 1.4rem; margin-bottom: 0; }

.sample-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  background: var(--accent-soft);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 0.6rem 1rem;
  margin-bottom: 1.25rem;
  font-size: 0.88rem;
}
.sample-banner strong { font-family: var(--font-display); }

.backup-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  background: color-mix(in srgb, var(--c-ochre) 12%, transparent);
  border-radius: 4px;
  border-left: 3px solid var(--c-ochre);
  padding: 0.6rem 1rem;
  margin-bottom: 1.25rem;
  font-size: 0.88rem;
}
.backup-banner strong {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.backup-banner .banner-actions { display: flex; gap: 0.4rem; }

/* ---- Filters ---- */
.filters {
  display: flex;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}
.field-inline {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.85rem;
  color: var(--muted);
}
.field-inline select {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.32rem 0.6rem;
}
.field-check { cursor: pointer; }
.field-check input { accent-color: var(--accent); width: 16px; height: 16px; }

.week-section-head {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  margin: 1.5rem 0 0.6rem 0.2rem;
}
.week-section-head:first-child { margin-top: 0; }

/* ============================================================
   Dialogs & forms
   ============================================================ */
.dialog {
  border: none;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lift);
  padding: 1.6rem 1.7rem;
  width: min(460px, calc(100vw - 2rem));
}
.dialog::backdrop { background: rgba(10, 14, 13, 0.45); backdrop-filter: blur(2px); }
.dialog-sm { width: min(380px, calc(100vw - 2rem)); }
.dialog h2 { margin-bottom: 0.3rem; }
.dialog-hint { color: var(--muted); font-size: 0.85rem; margin: 0 0 1.1rem; }
.dialog p { margin-top: 0; }

.field { margin-bottom: 1rem; }
.field label, .field legend {
  display: block;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.84rem;
  margin-bottom: 0.3rem;
}
.label-soft { color: var(--muted); font-weight: 400; }
.field input[type="text"], .field input[type="date"], .field select, .field textarea {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.7rem;
}
.field textarea { resize: vertical; }
.field input:focus-visible, .field select:focus-visible, .field textarea:focus-visible {
  outline: 2.5px solid var(--accent);
  outline-offset: 1px;
}
.field input[aria-invalid="true"] { border-color: var(--danger); }
.field-error { color: var(--danger); font-size: 0.8rem; margin: 0.3rem 0 0; }
.field fieldset, fieldset.field { border: none; padding: 0; margin: 0 0 1rem; }

.field-pair { display: flex; gap: 0.8rem; }
.field-pair .field { flex: 1; min-width: 0; }
.field-grow { flex: 1.6 !important; }

.swatches { display: flex; gap: 0.55rem; flex-wrap: wrap; }
.swatch {
  position: relative;
  width: 34px; height: 34px;
  border-radius: 50%;
  cursor: pointer;
  display: grid;
  place-items: center;
}
.swatch input {
  appearance: none;
  position: absolute;
  inset: 0;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  margin: 0;
}
.swatch .swatch-fill {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--swatch-color);
  pointer-events: none;
  transition: transform var(--speed) ease;
}
.swatch input:checked + .swatch-fill { transform: scale(1.12); }
.swatch input:checked { border-color: var(--text); }
.swatch input:focus-visible { outline: 2.5px solid var(--accent); outline-offset: 2px; }

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  margin-top: 1.3rem;
}

/* ---- Meeting-time rows (course dialog) ---- */
.meeting-row {
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.6rem;
  margin-bottom: 0.6rem;
}
.meeting-days { display: flex; gap: 0.3rem; margin-bottom: 0.5rem; flex-wrap: wrap; }
.day-toggle { position: relative; }
.day-toggle input {
  position: absolute;
  inset: 0;
  opacity: 0;
  margin: 0;
  cursor: pointer;
}
.day-toggle span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  padding: 0.2rem 0.3rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--muted);
  cursor: pointer;
  transition: background var(--speed) ease, color var(--speed) ease;
}
.day-toggle input:checked + span {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
}
.day-toggle input:focus-visible + span { outline: 2.5px solid var(--accent); outline-offset: 1px; }
.meeting-fields { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }
.meeting-fields input[type="time"] {
  font: inherit;
  font-size: 0.88rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.32rem 0.45rem;
}
.meeting-dash { color: var(--muted); }
.meeting-fields .meeting-location {
  flex: 1;
  min-width: 110px;
  font: inherit;
  font-size: 0.88rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.32rem 0.45rem;
}

/* ---- Today's classes strip (This Week) ---- */
.today-classes {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 14px 40px 0;
}
.today-classes-label {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}
.class-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  background: var(--surface);
  border-left: 3px solid var(--row-spine, var(--border));
  border-radius: 4px;
  box-shadow: var(--row-shadow);
  padding: 6px 12px;
}
.class-chip-code {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
}
.class-chip-time {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--muted);
}

.course-card .course-schedule {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 0.2rem;
  line-height: 1.7;
}

/* ============================================================
   Import flow
   ============================================================ */
.view-header-actions { display: flex; gap: 0.6rem; flex-wrap: wrap; }

.dialog-lg { width: min(760px, calc(100vw - 2rem)); }

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  text-align: center;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  padding: 1.4rem 1rem;
  margin-bottom: 0.9rem;
  cursor: pointer;
  transition: border-color var(--speed) ease, background var(--speed) ease;
}
.dropzone:hover, .dropzone.dragover { border-color: var(--accent); background: var(--accent-soft); }
.dropzone strong { font-family: var(--font-display); font-size: 0.95rem; }
.dropzone span { font-size: 0.85rem; color: var(--muted); }
.dropzone .dropzone-hint {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.02em;
  margin-top: 0.35rem;
}
.dropzone.busy > * { visibility: hidden; }
.dropzone.busy { position: relative; }
.dropzone.busy::after {
  content: "Reading PDF…";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--muted);
}

.review-scroll {
  overflow: auto;
  max-height: min(55vh, 480px);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
}
.review-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.review-table th {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 500;
  color: var(--muted);
  text-align: left;
  padding: 0.5rem 0.5rem;
  position: sticky;
  top: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  z-index: 1;
}
.review-table td {
  padding: 0.3rem 0.5rem;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: middle;
  white-space: nowrap;
}
.review-table .col-inc { width: 32px; }
.review-table input[type="checkbox"] { accent-color: var(--accent); width: 16px; height: 16px; }
.review-table input[type="text"] {
  width: 100%;
  min-width: 180px;
  font: inherit;
  font-size: 0.85rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  padding: 0.25rem 0.45rem;
}
.review-table input[type="date"], .review-table select {
  font: inherit;
  font-size: 0.82rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  padding: 0.25rem 0.35rem;
}
.review-table tr.row-excluded td:not(.col-inc) { opacity: 0.45; }
.review-course-locked {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--muted);
}
.review-badge {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 3px;
}
.badge-new { background: var(--accent-soft); color: var(--accent); }
.badge-update { background: color-mix(in srgb, var(--c-cyan) 14%, transparent); color: var(--c-cyan); }
.badge-event { background: var(--surface-2); color: var(--muted); }
.badge-check-date { background: color-mix(in srgb, var(--c-ochre) 14%, transparent); color: var(--c-ochre); }

/* ============================================================
   About view
   ============================================================ */
.view-about { max-width: 640px; }
.view-about h2 { margin-top: 1.6rem; }
.about-lede { font-size: 1.05rem; color: var(--muted); }
.about-signoff { margin-top: 2rem; color: var(--muted); }

/* ============================================================
   Sync dialog
   ============================================================ */
.sync-status { font-weight: 600; }
.sync-help { font-size: 0.85rem; color: var(--muted); }

/* ============================================================
   Calendar view
   ============================================================ */
.cal-toolbar { margin-bottom: 0.75rem; }
.cal-title { margin: 0; }
.cal-nav { display: flex; gap: 0.4rem; }
.cal-head {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-bottom: 4px;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.cal-head span { padding: 0 6px; }

.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-cell {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  min-height: 96px;
  min-width: 0;
  padding: 4px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.cal-outside { opacity: 0.45; }
.cal-out-sem { background: transparent; }
.cal-cell.is-today { outline: 2px solid var(--accent); outline-offset: -2px; }

.cal-cell-top { display: flex; align-items: center; gap: 4px; }
.cal-daynum {
  background: transparent;
  border: none;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--muted);
  width: 24px;
  height: 24px;
  border-radius: var(--pill);
  cursor: pointer;
  flex: none;
}
.cal-daynum:hover { background: var(--surface-2); color: var(--text); }
.is-today .cal-daynum { background: var(--accent); color: var(--on-accent); font-weight: 600; }
.cal-sem-tag {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}
.cal-dots { margin-left: auto; display: inline-flex; gap: 3px; }
.cal-dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }

.cal-event {
  --row-spine: var(--border);
  display: block;
  width: 100%;
  min-width: 0;
  text-align: left;
  background: var(--surface-2);
  border: none;
  border-left: 3px solid var(--row-spine);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 0.72rem;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cal-event:hover { background: color-mix(in srgb, var(--row-spine) 14%, var(--surface-2)); }
.cal-event.done-item { opacity: 0.55; }
.cal-event.done-item .cal-event-title { text-decoration: line-through; }
.cal-event.cal-overdue .cal-event-title { color: var(--danger); }
.cal-more {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  color: var(--muted);
  padding-left: 6px;
}

/* ============================================================
   Footer
   ============================================================ */
.app-footer {
  border-top: 1px solid var(--border-soft);
  padding: 1.1rem 0;
  /* Installed on iOS: keep the last row above the home indicator */
  padding-bottom: calc(1.1rem + env(safe-area-inset-bottom, 0px));
  font-size: 0.82rem;
  color: var(--muted);
}
.footer-row {
  display: flex;
  align-items: center;
  gap: 0.75rem 1.5rem;
  flex-wrap: wrap;
  justify-content: space-between;
}
.footer-note, .footer-credit { margin: 0; }
.footer-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.footer-credit a { color: var(--muted); }
.footer-credit a:hover { color: var(--text); }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 640px) {
  main.shell { padding-top: 1.25rem; }
  .header-row { gap: 0.6rem; }
  .main-nav { order: 3; width: 100%; justify-content: space-between; gap: 0.75rem; }
  .nav-link { text-align: center; }
  .week-body { grid-template-columns: 1fr; }
  .load-rail { order: -1; }
  .hero-band { padding: 20px 8px 16px; }
  .week-list { padding: 16px 8px 24px; }
  .today-classes { padding: 14px 8px 0; }
  .hero-week { font-size: 56px; }
  .spine-wrap { text-align: left; }
  .spine { justify-content: flex-start; }
  .field-pair { flex-direction: column; gap: 0; }
  .footer-row { flex-direction: column; align-items: flex-start; }
  .cal-cell { min-height: 56px; padding: 3px; }
  .cal-daynum { width: 20px; height: 20px; font-size: 0.68rem; }
  .cal-head span { padding: 0 2px; }
  .cal-sem-tag { display: none; }
  .cal-event {
    height: 8px;
    padding: 0;
    border-radius: 3px;
    border-left: none;
    background: var(--row-spine);
  }
  .cal-event .cal-event-title, .cal-event .subtask-arrow { display: none; }
  .cal-more { padding-left: 2px; }
}

/* ============================================================
   Reduced motion
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  html { scroll-behavior: auto; }
}
