/* ============================================================
   Automata Theory CS302.1 — dark pastel theme
   ============================================================ */

:root {
  --ink:      #0f1118;
  --ink-2:    #171b27;
  --panel:    rgba(27, 31, 45, 0.94);
  --panel-2:  rgba(34, 39, 56, 0.96);
  --line:     rgba(160, 172, 206, 0.20);
  --line-2:   rgba(160, 172, 206, 0.36);

  --text:     #f2f4fb;
  --text-2:   #c2c8de;
  --text-3:   #8f96b0;

  --mint:     #a6e3c4;
  --lilac:    #c7b8f5;
  --peach:    #f5cda9;
  --sky:      #a9d2f5;
  --rose:     #f2b3c8;
  --butter:   #f0dc9a;

  --display: "Space Grotesk", ui-sans-serif, system-ui, sans-serif;
  --body:    "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;
  --mono:    "IBM Plex Mono", ui-monospace, monospace;

  --rail-w: 252px;
  --r: 12px;
  --pop: cubic-bezier(0.22, 1.1, 0.36, 1);
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  width: 100%; max-width: 100%; overflow-x: clip;
  -webkit-text-size-adjust: 100%; text-size-adjust: 100%;
}

body {
  background: var(--ink);
  color: var(--text);
  font-family: var(--body);
  font-size: 17.5px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: "";
  position: fixed; inset: 0;
  pointer-events: none; z-index: 1;
  background:
    linear-gradient(180deg, rgba(8, 10, 15, 0.94) 0%, rgba(8, 10, 15, 0.82) 14%, rgba(8, 10, 15, 0.5) 30%, transparent 46%),
    radial-gradient(1100px 620px at 18% -10%, rgba(199, 184, 245, 0.10), transparent 70%),
    radial-gradient(900px 520px at 100% 105%, rgba(166, 227, 196, 0.08), transparent 70%);
}

a { color: inherit; }

.skip {
  position: absolute; left: -9999px; top: 0; z-index: 60;
  background: var(--mint); color: #10141c; padding: 10px 16px;
  font-family: var(--mono); font-size: 14px; border-radius: 0 0 var(--r) 0;
}
.skip:focus { left: 0; }

:focus-visible { outline: 2px solid var(--lilac); outline-offset: 3px; border-radius: 5px; }

/* ---------------- Game of Life canvas ---------------- */

#life {
  position: fixed; inset: 0; width: 100%; height: 100%;
  z-index: 0; opacity: 0.26; pointer-events: none;
  transition: opacity 220ms ease;
}
/* while drawing: canvas sits on top, grabs all input, blocks page scroll/selection */
body.is-drawing { overflow: hidden; -webkit-user-select: none; user-select: none; }
body.is-drawing #life {
  z-index: 44; opacity: 0.92; pointer-events: auto;
  cursor: crosshair; touch-action: none;
}
body.is-drawing .main { opacity: 0.12; }

.shell {
  position: relative; z-index: 2;
  display: grid;
  grid-template-columns: var(--rail-w) minmax(0, 1fr);
  min-height: 100vh;
}
.main { transition: opacity 220ms ease; }

/* discreet Game of Life control, tucked at the bottom of the rail */
.life-panel {
  margin-top: 16px; padding-top: 14px;
  border-top: 1px solid var(--line);
}
.life-panel__title {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--text-3);
  cursor: pointer; list-style: none; opacity: 0.6;
  transition: opacity 140ms ease;
}
.life-panel__title::-webkit-details-marker { display: none; }
.life-panel__title::before { content: "▸ "; font-size: 9px; }
.life-panel[open] .life-panel__title::before { content: "▾ "; }
.life-panel__title:hover { opacity: 1; }
.life-panel__row {
  display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px;
}
.life-panel button {
  font-family: var(--mono); font-size: 11.5px;
  background: transparent; color: var(--text-3);
  border: 1px solid var(--line); border-radius: 999px;
  padding: 4px 10px; cursor: pointer;
  transition: color 140ms ease, border-color 140ms ease, background 140ms ease;
}
.life-panel button:hover { color: var(--text); border-color: var(--line-2); }
.life-panel button[aria-pressed="true"] { color: #131722; background: var(--mint); border-color: var(--mint); }
#lifeDraw[aria-pressed="true"] { background: var(--lilac); border-color: var(--lilac); }

.life-hint {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  z-index: 45; margin: 0;
  font-family: var(--mono); font-size: 13px; color: var(--text-2);
  background: var(--panel); border: 1px solid var(--line);
  padding: 8px 15px; border-radius: 999px; backdrop-filter: blur(10px);
  text-align: center; max-width: calc(100% - 24px);
}

/* prominent exit button, only while drawing */
.life-exit {
  position: fixed; top: 16px; left: 50%; transform: translateX(-50%);
  z-index: 46;
  font-family: var(--mono); font-size: 14px; font-weight: 600;
  color: #131722; background: var(--rose);
  border: 1px solid var(--rose); border-radius: 999px;
  padding: 10px 20px; cursor: pointer;
  box-shadow: 0 10px 30px rgba(4, 6, 11, 0.5);
}
.life-exit[hidden] { display: none; }
.life-exit:hover { background: #f6c2d3; }

/* ---------------- Mobile hamburger (hidden on desktop) ---------------- */
.navtoggle { display: none; }
.nav-scrim { display: none; }

/* ---------------- Rail ---------------- */

.rail {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  padding: 32px 20px 22px;
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(16, 19, 28, 0.94), rgba(16, 19, 28, 0.72));
  backdrop-filter: blur(14px);
}
.rail__mark {
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.2em;
  text-transform: uppercase; color: var(--mint); margin: 0 0 32px 11px;
}

.nav { display: flex; flex-direction: column; gap: 3px; }
.nav__link {
  display: flex; align-items: baseline; gap: 11px;
  text-decoration: none;
  font-size: 16px; color: var(--text-2);
  padding: 11px 12px;
  border-radius: 9px;
  border-left: 2px solid transparent;
  transition: color 140ms ease, background 140ms ease, border-color 140ms ease;
}
.nav__sym { font-family: var(--mono); font-size: 11.5px; color: var(--text-3); min-width: 19px; }
.nav__link:hover { color: var(--text); background: rgba(160, 172, 206, 0.08); }
.nav__link.is-active {
  color: var(--text); background: rgba(199, 184, 245, 0.12);
  border-left-color: var(--lilac);
}
.nav__link.is-active .nav__sym { color: var(--lilac); }

.rail__foot {
  margin-top: auto; padding-top: 18px;
  border-top: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 10px;
  font-family: var(--mono); font-size: 12.5px; color: var(--text-3);
}
.rail__mail {
  display: inline-flex; align-items: center; gap: 8px;
  align-self: flex-start;
  font-family: var(--mono); font-size: 12.5px;
  text-decoration: none; color: var(--mint);
  border: 1px solid rgba(166, 227, 196, 0.34); border-radius: 999px;
  padding: 6px 14px;
  transition: background 150ms ease, border-color 150ms ease, color 150ms ease;
}
.rail__mail:hover { background: rgba(166, 227, 196, 0.12); border-color: var(--mint); color: var(--text); }

.dock {
  display: flex; flex-direction: column; align-items: flex-start; gap: 12px;
  margin-top: 12px;
}

/* ---------------- Main + views ---------------- */

.main { padding: 58px 46px 120px; max-width: 1140px; }

.view { display: none; }
.view.is-active { display: block; }

.eyebrow {
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.2em;
  text-transform: uppercase; color: var(--text-3); margin: 0 0 14px;
}

.hero { max-width: 76ch; margin-bottom: 66px; }
.hero__code {
  font-family: var(--mono); font-size: 13px; letter-spacing: 0.24em;
  text-transform: uppercase; color: var(--mint); margin: 0 0 14px;
}
.hero__h {
  font-family: var(--display);
  font-size: clamp(42px, 5.6vw, 66px);
  font-weight: 600; line-height: 1.02; letter-spacing: -0.03em;
  margin: 0 0 16px;
}
.hero__meta {
  font-family: var(--mono); font-size: 14px; color: var(--text-2);
  margin: 0 0 26px;
}
.hero__p { font-size: 18.5px; color: var(--text-2); margin: 0; max-width: 68ch; }

.view__head { margin-bottom: 44px; max-width: 70ch; }
.view__h {
  font-family: var(--display);
  font-size: clamp(32px, 3.8vw, 46px);
  font-weight: 600; letter-spacing: -0.02em; line-height: 1.08;
  margin: 0 0 14px;
}
.view__p { color: var(--text-2); margin: 0; font-size: 17.5px; }

.block { margin-bottom: 58px; }
.block__h {
  font-family: var(--display); font-size: 24px; font-weight: 600;
  letter-spacing: -0.015em; margin: 0 0 22px;
}

/* ---------------- Tutorial card ---------------- */

.tut {
  margin-top: 32px;
  border: 1px solid rgba(166, 227, 196, 0.36);
  border-radius: var(--r);
  background: linear-gradient(180deg, rgba(166, 227, 196, 0.12), rgba(27, 31, 45, 0.94));
  padding: 22px 26px;
  max-width: 620px;
}
.tut__kind {
  font-family: var(--mono); font-size: 11.5px; letter-spacing: 0.2em;
  text-transform: uppercase; color: var(--mint); margin: 0 0 9px;
}
.tut__line { font-size: 19px; margin: 0; }
.tut__line b { font-weight: 600; color: var(--mint); }
.tut__note { font-size: 14.5px; color: var(--text-3); margin: 9px 0 0; }

/* ---------------- Calendar ---------------- */

.cal { display: flex; flex-direction: column; gap: 34px; }

.month {
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--panel);
  padding: 20px 20px 24px;
  backdrop-filter: blur(10px);
}
.month__head {
  display: flex; align-items: baseline; gap: 14px; margin-bottom: 16px;
}
.month__name {
  font-family: var(--display); font-size: 20px; font-weight: 600;
  letter-spacing: -0.01em; margin: 0;
}
.month__year { font-family: var(--mono); font-size: 13px; color: var(--text-3); }
.month__count {
  margin-left: auto; font-family: var(--mono); font-size: 12px; color: var(--text-3);
}

.dow {
  display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px;
  margin-bottom: 8px;
}
.dow span {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--text-3); text-align: center;
}

.days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }

.day {
  position: relative;
  aspect-ratio: 1 / 0.84;
  min-height: 74px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(160, 172, 206, 0.045);
  padding: 9px 10px;
  display: flex; flex-direction: column;
}
.day--void { border-color: transparent; background: transparent; }
.day__n {
  font-family: var(--mono); font-size: 14.5px; color: var(--text-2);
  line-height: 1;
}
.day__blank {
  margin-top: auto; align-self: flex-end;
  font-family: var(--mono); font-size: 14px;
  color: rgba(143, 150, 176, 0.34);
}
.day__dots { margin-top: auto; display: flex; gap: 4px; }
.day__dots i { width: 7px; height: 7px; border-radius: 50%; }
.day__tag {
  font-family: var(--mono); font-size: 11px; color: #221d0c;
  margin-top: auto; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.day--event {
  background: rgba(240, 220, 154, 0.86);
  border-color: rgba(240, 220, 154, 0.95);
  cursor: pointer;
}
.day--event .day__n { color: #2a2409; font-weight: 600; }
.day--event .day__dots i { box-shadow: 0 0 0 1.5px rgba(42, 36, 9, 0.35); }

.day--today { border-color: var(--lilac); box-shadow: inset 0 0 0 1px var(--lilac); }
.day__head {
  position: absolute; left: 50%; bottom: 6px; transform: translateX(-50%);
  font-size: 10px; color: var(--lilac); line-height: 1;
}
.day--today.day--event .day__head { color: #3b2f9a; }

.day--event:hover { border-color: #fff0bd; }

/* transition-function readout */
.tm-readout {
  margin-top: 18px;
  display: inline-flex; align-items: center; gap: 10px;
  font-family: var(--mono); font-size: 13px; color: var(--text-3);
  border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 16px 6px 12px;
  background: rgba(160, 172, 206, 0.05);
}
.tm-readout__label { color: var(--lilac); font-size: 15px; }
.tm-readout__body sub { font-size: 0.72em; }

.legend {
  list-style: none; display: flex; flex-wrap: wrap; gap: 20px;
  margin: 20px 0 0; padding: 0;
  font-family: var(--mono); font-size: 12.5px; color: var(--text-3);
}
.legend li { display: flex; align-items: center; gap: 8px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot--milestone { background: var(--mint); }
.dot--assignment { background: var(--peach); }
.dot--exam { background: var(--rose); }
.dot--class { background: var(--sky); }

/* not-yet-dated list */
.undated { margin-top: 34px; }
.undated__h {
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.18em;
  text-transform: uppercase; color: var(--text-3); margin: 0 0 14px;
}
.undated__list { list-style: none; margin: 0; padding: 0; display: grid; gap: 9px; }
.undated__item {
  display: flex; align-items: baseline; gap: 13px;
  padding: 14px 17px;
  border: 1px dashed var(--line-2); border-radius: 9px;
  background: var(--panel);
  font-size: 16.5px;
}
.undated__item .dot { flex: none; transform: translateY(-2px); }
.undated__item b { font-weight: 500; }
.undated__item span { color: var(--text-3); font-size: 15px; }
.undated__tba {
  margin-left: auto; font-family: var(--mono); font-size: 11.5px;
  letter-spacing: 0.14em; text-transform: uppercase; color: var(--butter); flex: none;
}

/* ---------------- Drawer ---------------- */

.scrim {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(6, 8, 14, 0.6);
  backdrop-filter: blur(2px);
}

.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 41;
  width: min(420px, 92vw);
  background: #191d2a;
  border-left: 1px solid var(--line-2);
  padding: 34px 30px;
  overflow-y: auto;
  box-shadow: -28px 0 60px rgba(4, 6, 11, 0.6);
}

.drawer__close {
  position: absolute; top: 20px; right: 22px;
  background: rgba(160, 172, 206, 0.10); border: 1px solid var(--line);
  color: var(--text-2); border-radius: 999px;
  width: 40px; height: 40px; cursor: pointer; font-size: 16px;
  display: grid; place-items: center;
}
.drawer__close:hover { color: var(--text); border-color: var(--line-2); }
.drawer__weekday {
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.2em;
  text-transform: uppercase; color: var(--butter); margin: 0 0 8px;
}
.drawer__date {
  font-family: var(--display); font-size: 30px; font-weight: 600;
  letter-spacing: -0.02em; margin: 0 0 26px; line-height: 1.1;
}
.drawer__item {
  border-top: 1px solid var(--line);
  padding: 20px 0 4px;
}
.drawer__kind {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--mono); font-size: 11.5px; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--text-3); margin: 0 0 8px;
}
.drawer__label {
  font-family: var(--display); font-size: 20px; font-weight: 600;
  margin: 0 0 8px; letter-spacing: -0.01em;
}
.drawer__note { font-size: 16.5px; color: var(--text-2); margin: 0 0 8px; }
.drawer__detail { font-size: 16px; color: var(--text-3); margin: 0; }
.drawer__foot {
  margin-top: 34px; padding-top: 18px; border-top: 1px solid var(--line);
  font-family: var(--mono); font-size: 12px; color: var(--text-3);
}

/* ---------------- Resource lists ---------------- */

.group { margin-bottom: 46px; }
.group__h { font-family: var(--display); font-size: 19px; font-weight: 600; margin: 0; }
.group__rule {
  display: flex; align-items: baseline; gap: 14px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 11px; margin-bottom: 16px;
}
.group__count { font-family: var(--mono); font-size: 12.5px; color: var(--text-3); margin-left: auto; flex: none; }

.row {
  display: flex; align-items: center; gap: 16px;
  padding: 17px 19px;
  border: 1px solid var(--line); border-radius: 9px;
  background: var(--panel);
  text-decoration: none; margin-bottom: 9px;
  transition: border-color 160ms ease, background 160ms ease;
}
a.row:hover { border-color: var(--line-2); background: var(--panel-2); }
.row__glyph {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.06em;
  color: var(--sky); border: 1px solid rgba(169, 210, 245, 0.4);
  border-radius: 5px; padding: 4px 7px; flex: none;
}
.row__main { min-width: 0; }
.row__title { font-size: 17px; font-weight: 450; }
.row__meta { font-family: var(--mono); font-size: 12.5px; color: var(--text-3); margin-top: 3px; }
.row__arrow { margin-left: auto; color: var(--text-3); font-family: var(--mono); flex: none; }

.book {
  display: grid; grid-template-columns: 46px 1fr; gap: 22px;
  padding: 26px;
  border: 1px solid var(--line); border-radius: var(--r);
  background: var(--panel);
  margin-bottom: 18px;
}
.book__spine {
  border-radius: 3px; min-height: 96px;
  background: linear-gradient(160deg, var(--lilac), rgba(199, 184, 245, 0.25));
}
.book:nth-child(even) .book__spine { background: linear-gradient(160deg, var(--mint), rgba(166, 227, 196, 0.22)); }
.book__tag {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.18em;
  text-transform: uppercase; color: var(--text-3); margin: 0 0 8px;
}
.book__title {
  font-family: var(--display); font-size: 22px; font-weight: 600;
  letter-spacing: -0.015em; margin: 0 0 7px; line-height: 1.2;
}
.book__by { font-size: 16px; color: var(--text-2); margin: 0 0 4px; }
.book__pub { font-family: var(--mono); font-size: 12.5px; color: var(--text-3); margin: 0 0 16px; }
.book__links { display: flex; gap: 10px; flex-wrap: wrap; }

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: var(--mono); font-size: 13px;
  text-decoration: none; color: var(--text);
  border: 1px solid var(--line-2); border-radius: 999px;
  padding: 7px 16px;
  transition: background 150ms ease, color 150ms ease, border-color 150ms ease;
}
.btn:hover { background: rgba(160, 172, 206, 0.12); }
.btn--solid { background: var(--mint); border-color: var(--mint); color: #131722; }
.btn--solid:hover { background: #b9ead1; }

/* extras batches */
.batch { margin-bottom: 54px; }
.batch__head { display: flex; align-items: center; gap: 14px; margin-bottom: 22px; }
.batch__date {
  font-family: var(--mono); font-size: 13px; letter-spacing: 0.06em;
  color: var(--lilac); border: 1px solid rgba(199, 184, 245, 0.42);
  border-radius: 999px; padding: 5px 14px; flex: none;
}
.batch__line { height: 1px; background: var(--line); flex: 1; }
.batch__n { font-family: var(--mono); font-size: 12px; color: var(--text-3); flex: none; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(274px, 1fr)); gap: 17px; }
.card {
  border: 1px solid var(--line); border-radius: var(--r);
  background: var(--panel); overflow: hidden;
  display: flex; flex-direction: column; text-decoration: none;
  transition: border-color 160ms ease;
}
.card:hover { border-color: var(--line-2); }
.card__thumb {
  aspect-ratio: 16 / 9; background: #0c0e14;
  position: relative; overflow: hidden; border-bottom: 1px solid var(--line);
}
.card__thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card__play { position: absolute; inset: 0; display: grid; place-items: center; }
.card__play span {
  width: 42px; height: 42px; border-radius: 50%;
  background: rgba(15, 17, 24, 0.75); border: 1px solid var(--line-2);
  display: grid; place-items: center; color: var(--mint); font-size: 14px; padding-left: 3px;
}
.card__body { padding: 16px 18px 18px; }
.card__kind {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--text-3); margin: 0 0 7px;
}
.card__title { font-size: 17px; font-weight: 450; margin: 0 0 7px; line-height: 1.35; }
.card__note { font-size: 15px; color: var(--text-2); margin: 0; }
.card__by { font-family: var(--mono); font-size: 12px; color: var(--text-3); margin: 10px 0 0; }

/* people */
.people {
  display: flex; flex-wrap: wrap; gap: 22px;
}
.person {
  border: 1px solid var(--line); border-radius: var(--r);
  background: var(--panel); padding: 30px 30px 26px;
  display: flex; flex-direction: column;
  width: max-content; max-width: 100%;
}
.person__role {
  font-family: var(--mono); font-size: 11.5px; letter-spacing: 0.18em;
  text-transform: uppercase; color: var(--text-3); margin: 0 0 12px;
}
.person__name {
  font-family: var(--display); font-size: 24px; font-weight: 600;
  margin: 0 0 14px; letter-spacing: -0.01em;
}
.person__contact {
  display: flex; align-items: center; gap: 10px;
}
.person__mail {
  flex: none; white-space: nowrap;
  font-family: var(--mono); font-size: 15px; color: var(--mint);
  text-decoration: none; line-height: 1.5;
  border-bottom: 1px solid rgba(166, 227, 196, 0.32);
}
.person__mail:hover { border-bottom-color: var(--mint); }
.person__copy {
  flex: none; cursor: pointer;
  display: inline-grid; place-items: center;
  width: 30px; height: 30px; padding: 0;
  color: var(--text-2); background: rgba(160, 172, 206, 0.08);
  border: 1px solid var(--line); border-radius: 8px;
  transition: color 140ms ease, border-color 140ms ease, background 140ms ease;
}
.person__copy svg { display: block; }
.person__copy:hover { color: var(--text); border-color: var(--line-2); }
.person__copy.is-copied { color: #131722; background: var(--mint); border-color: var(--mint); }
.person__hours {
  margin-top: auto; padding-top: 16px;
  font-family: var(--mono); font-size: 12.5px; color: var(--text-3);
}

/* empty states */
.empty {
  border: 1px dashed var(--line-2); border-radius: var(--r);
  padding: 32px 28px; background: var(--panel);
}
.empty h4 { font-family: var(--display); font-size: 18px; font-weight: 600; margin: 0 0 8px; }
.empty p { margin: 0; color: var(--text-2); font-size: 16.5px; max-width: 62ch; }
.empty code {
  font-family: var(--mono); font-size: 14px; color: var(--peach);
  background: rgba(245, 205, 169, 0.12); padding: 1px 6px; border-radius: 5px;
}

.kbd {
  font-family: var(--mono); font-size: 14px;
  background: rgba(160, 172, 206, 0.14); border: 1px solid var(--line);
  padding: 1px 7px; border-radius: 5px;
}

/* ---------------- Responsive ---------------- */

@media (max-width: 960px) {
  .shell { grid-template-columns: minmax(0, 1fr); }

  /* hamburger */
  .navtoggle {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px;
    position: fixed; top: 12px; right: 12px; z-index: 50;
    width: 46px; height: 46px; border-radius: 12px;
    background: var(--panel-2); border: 1px solid var(--line-2);
    cursor: pointer; backdrop-filter: blur(10px);
  }
  .navtoggle span {
    display: block; width: 20px; height: 2px; background: var(--text); border-radius: 2px;
    transition: transform 200ms ease, opacity 150ms ease;
  }
  body.nav-open .navtoggle span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
  body.nav-open .navtoggle span:nth-child(2) { opacity: 0; }
  body.nav-open .navtoggle span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

  .nav-scrim {
    display: block; position: fixed; inset: 0; z-index: 48;
    background: rgba(6, 8, 14, 0.55); backdrop-filter: blur(2px);
  }
  .nav-scrim[hidden] { display: none; }

  /* rail becomes a slide-in pane from the right */
  .rail {
    position: fixed; top: 0; right: 0; bottom: 0; left: auto;
    width: min(300px, 84vw); height: 100%;
    transform: translateX(100%); transition: transform 260ms ease;
    z-index: 49; overflow-y: auto;
    padding: 64px 20px 22px;
    border-right: 0; border-left: 1px solid var(--line-2); border-bottom: 0;
    background: linear-gradient(180deg, rgba(16, 19, 28, 0.99), rgba(16, 19, 28, 0.97));
  }
  body.nav-open .rail { transform: translateX(0); }

  .rail__mark { margin: 0 0 20px 4px; }
  .nav { flex-direction: column; gap: 4px; overflow: visible; padding: 0; }
  .nav__link {
    white-space: normal; flex: none;
    border-left: 2px solid transparent; border-bottom: 0; border-radius: 9px;
  }
  .nav__link.is-active { border-left-color: var(--lilac); border-bottom: 0; }

  .rail__foot { flex-direction: column; align-items: flex-start; gap: 6px; margin-top: 22px; }

  /* Controls + Contact TAs sit at the bottom of the pane */
  .dock { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--line); align-items: stretch; gap: 14px; }
  .dock .rail__mail { align-self: flex-start; }
  .dock .life-panel { position: static; margin: 0; padding: 0; border-top: 0; }
  .dock .life-panel__title { opacity: 1; }
  .dock .life-panel__row {
    position: static; flex-direction: row; flex-wrap: wrap; gap: 6px; margin-top: 10px;
    background: none; border: 0; box-shadow: none; padding: 0; min-width: 0;
  }

  .main { padding: 56px 18px 60px; max-width: 100%; }
  .book { grid-template-columns: 1fr; }
  .book__spine { min-height: 6px; }
  .life-hint { font-size: 12px; max-width: calc(100% - 24px); bottom: 24px; }
}

@media (max-width: 620px) {
  body { font-size: 16.5px; }

  .hero { margin-bottom: 44px; }
  .block { margin-bottom: 40px; }
  .view__head { margin-bottom: 30px; }

  /* calendar: fewer gaps, taller cells that are easy to tap */
  .month { padding: 14px 10px 18px; }
  .days, .dow { gap: 6px; }
  .day {
    aspect-ratio: auto; min-height: 60px;
    padding: 7px 6px; border-radius: 8px;
  }
  .day__n { font-size: 13.5px; }
  .day__tag { display: none; }
  .day__blank { font-size: 12px; }
  .day__dots i { width: 6px; height: 6px; }
  .day--event { min-height: 60px; }

  .tm-readout { font-size: 12px; max-width: 100%; flex-wrap: wrap; }

  .person { width: 100%; padding: 24px 22px 22px; }
  .person__contact { flex-direction: column; align-items: flex-start; gap: 10px; }
  .person__mail { white-space: normal; overflow-wrap: anywhere; max-width: 100%; }
  .grid { grid-template-columns: 1fr; }

  /* day popup: centered, clearly closable card instead of a side drawer */
  .drawer {
    top: 50%; left: 50%; right: auto; bottom: auto;
    transform: translate(-50%, -50%);
    width: min(440px, calc(100% - 28px));
    max-height: calc(100% - 40px);
    border: 1px solid var(--line-2); border-left: 1px solid var(--line-2);
    border-radius: var(--r);
    padding: 30px 22px;
    box-shadow: 0 24px 70px rgba(4, 6, 11, 0.7);
  }
  .drawer__date { font-size: 26px; padding-right: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
