/*
 * ubc.events: warm, pastel brutalism. Every page uses this one stylesheet.
 *
 * The rules every part follows:
 * 1. Frames, controls and the selected thing are rectangles with a 2px cocoa border. No rounded corners,
 *    blur or gradients. Boxes that touch share one border (they overlap by 2px), like a printed form.
 *    Content inside them (events, tags, notes) is flat colour and text, with at most a 1px edge.
 * 2. Background guides (hour lines, day cells) are 1px tan lines.
 * 3. Buttons and toggles are outlined boxes. A solid cocoa fill with cream text marks what is selected,
 *    and the one main action on a screen. Hover is a soft latte fill.
 * 4. Links are cocoa text; the current page's link is underlined.
 * 5. Each event kind has a pastel fill and a deeper stripe of the same hue, chosen only through
 *    data-category. Scripts never write a colour.
 * 6. Five text sizes only (13, 15, 17, 20, 24). Mono for labels, buttons, headings and dates; sans for
 *    everything you read (event names, places, notes, descriptions). Capitals only on labels of one to
 *    three words.
 * 7. Things that stand on their own (the open event, cards, pop-ups) get an offset second frame behind them.
 *
 * Dark mode swaps the colour values only (theme.js sets data-theme on <html>); every rule stays the same.
 */

/* IBM Plex (SIL Open Font License, fonts/IBMPlex*-OFL.txt). Each face comes in two files: basic Latin, and
   the extended Latin a name with rarer accents needs; the browser loads the second only for those letters. */
@font-face { font-family: "Plex Mono"; font-weight: 400; src: url("/fonts/ibm-plex-mono-latin-400-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: "Plex Mono"; font-weight: 400; src: url("/fonts/ibm-plex-mono-latin-ext-400-normal.woff2") format("woff2"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Plex Mono"; font-weight: 600; src: url("/fonts/ibm-plex-mono-latin-600-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: "Plex Mono"; font-weight: 600; src: url("/fonts/ibm-plex-mono-latin-ext-600-normal.woff2") format("woff2"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Plex Mono"; font-weight: 600; font-style: italic; src: url("/fonts/ibm-plex-mono-latin-600-italic.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: "Plex Mono"; font-weight: 600; font-style: italic; src: url("/fonts/ibm-plex-mono-latin-ext-600-italic.woff2") format("woff2"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Plex Sans"; font-weight: 400; src: url("/fonts/ibm-plex-sans-latin-400-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: "Plex Sans"; font-weight: 400; src: url("/fonts/ibm-plex-sans-latin-ext-400-normal.woff2") format("woff2"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Plex Sans"; font-weight: 600; src: url("/fonts/ibm-plex-sans-latin-600-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: "Plex Sans"; font-weight: 600; src: url("/fonts/ibm-plex-sans-latin-ext-600-normal.woff2") format("woff2"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }

/* ---------- colours, sizes, type ---------- */

:root {
  color-scheme: light;
  /* paper and ink */
  --paper: #f7f0e6;
  --sand: #efe2cf;
  --stripe-a: #ece0cf;
  --stripe-b: #f3e9dc;
  --hair: #e2cfb6;
  --today: #f1e5d4;
  --latte: #ead8c2;
  --cocoa: #7a5236;
  --on-cocoa: #fbf6ef;
  --ink: #3f2c20;
  --muted: #66503f;
  --error: #a33a24;
  --scrim: rgba(63, 44, 32, 0.25);
  /* event kinds: a pastel fill (text on it stays --ink) and a deeper stripe of the same hue */
  --kind-other: #ecdfcb;   --kind-other-deep: #b49a7e;
  --kind-food: #c9dcae;    --kind-food-deep: #7f9a5c;
  --kind-faculty: #bdd0e4; --kind-faculty-deep: #6f8fb3;
  --kind-career: #dcc4e6;  --kind-career-deep: #9a76ab;
  --kind-social: #f3c4ad;  --kind-social-deep: #c97d5d;
  --kind-class: #f2d98f;   --kind-class-deep: #c49a2e;

  /* the five text sizes */
  --text-small: 13px;
  --text-body: 15px;
  --text-large: 17px;
  --text-title: 20px;
  --text-display: 24px;

  --line: 2px solid var(--cocoa);
  --hairline: 1px solid var(--hair);
  --offset-frame: 10px 10px 0 -2px var(--paper), 10px 10px 0 0 var(--cocoa);
  --mono: "Plex Mono", ui-monospace, monospace;
  --sans: "Plex Sans", system-ui, sans-serif;
}

/* dark: espresso paper, cream ink, and tan where light mode has cocoa */
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #241a14;
  --sand: #2f241c;
  --stripe-a: #2a2019;
  --stripe-b: #30251d;
  --hair: #4a3a2e;
  --today: #2e231b;
  --latte: #3a2d23;
  --cocoa: #d8b48f;
  --on-cocoa: #241a14;
  --ink: #f1e6d8;
  --muted: #c3ab95;
  --error: #f2a48c;
  --scrim: rgba(0, 0, 0, 0.45);
  --kind-other: #3b3026;   --kind-other-deep: #8c7660;
  --kind-food: #2f3a25;    --kind-food-deep: #8fae6a;
  --kind-faculty: #26323f; --kind-faculty-deep: #7f9fc4;
  --kind-career: #352a3d;  --kind-career-deep: #a98bbb;
  --kind-social: #44291f;  --kind-social-deep: #d48c6b;
  --kind-class: #3f3315;   --kind-class-deep: #d1a94a;
}

/* rule 5: the only place a kind becomes a colour */
[data-category="other"] { --kind: var(--kind-other); --kind-deep: var(--kind-other-deep); }
[data-category="food"] { --kind: var(--kind-food); --kind-deep: var(--kind-food-deep); }
[data-category="faculty"] { --kind: var(--kind-faculty); --kind-deep: var(--kind-faculty-deep); }
[data-category="career"] { --kind: var(--kind-career); --kind-deep: var(--kind-career-deep); }
[data-category="social"] { --kind: var(--kind-social); --kind-deep: var(--kind-social-deep); }
[data-category="class"] { --kind: var(--kind-class); --kind-deep: var(--kind-class-deep); }

/* ---------- page ---------- */

* { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--ink);
  font: 400 var(--text-body)/1.45 var(--sans);
  background: repeating-linear-gradient(-45deg, var(--stripe-a) 0 12px, var(--stripe-b) 12px 24px);
}
h1, h2, h3, p { margin: 0; }
[hidden] { display: none !important; }
:focus-visible { outline: var(--line); outline-offset: 2px; }

/* The visible window's height. dvh leaves out the toolbars a phone browser shows: on an iPhone, 100vh reaches under
   Safari's bottom toolbar, where a full-screen pop-up's buttons can't be tapped. vh where dvh is unknown. */
:root { --screen: 100vh; }
@supports (height: 100dvh) { :root { --screen: 100dvh; } }

/* The sheet every page sits on. The calendar fills the window and scrolls inside;
   plain pages (.plain) grow with their content and scroll the whole window. */
.app {
  display: grid;
  grid-template-rows: auto 1fr;
  height: calc(var(--screen) - 40px);
  margin: 20px;
  border: var(--line);
  background: var(--paper);
}
.app.plain { height: auto; min-height: calc(var(--screen) - 40px); }
/* Invisible until shell.js has added the shared top bar, so nothing jumps down when it arrives.
   If shell.js never runs (no connection), the page shows anyway after two seconds. */
.app:not(.framed) { visibility: hidden; animation: show-anyway 0s 2s forwards; }
@keyframes show-anyway { to { visibility: visible; } }
.scroll { min-height: 0; overflow: auto; padding: 20px; }
.app.plain .scroll { overflow: visible; }

/* ---------- buttons, links, fields (rules 3 and 4) ---------- */

.box {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: var(--line);
  background: var(--paper);
  color: var(--cocoa);
  max-width: 100%;
  font: 600 var(--text-body)/1.2 var(--mono);
  text-decoration: none;
  overflow-wrap: break-word; /* a long name or address wraps rather than pushing the page wider than a phone */
  cursor: pointer;
}
/* a crowded toolbar wraps whole boxes onto the next line, never the words inside one */
.toolbar .box, .joined .box { white-space: nowrap; }
.box:hover { background: var(--latte); }
.box[aria-pressed="true"], .box.primary { background: var(--cocoa); color: var(--on-cocoa); }

/* a button that deletes or cancels: error-coloured; pressed once, it fills and asks to be pressed again */
.box.danger { border-color: var(--error); color: var(--error); }
.box.danger[aria-pressed="true"] { background: var(--error); color: var(--paper); }
.box:disabled { opacity: 0.45; cursor: default; }
.box:disabled:hover { background: var(--paper); }

/* boxes side by side share their border */
.joined { display: flex; }
.joined > * + * { margin-left: -2px; }

.link { padding: 6px 2px; color: var(--cocoa); font: 600 var(--text-body)/1 var(--mono); text-decoration: none; }
.link[aria-current="page"] { text-decoration: underline 2px; text-underline-offset: 6px; }

.field {
  min-width: 0; /* a date field's natural width mustn't push it out of a narrow column */
  padding: 8px 12px;
  border: var(--line);
  background: var(--paper);
  color: var(--ink);
  font: 400 var(--text-body)/1 var(--mono);
}
.field::placeholder { color: var(--muted); }

.swatch { width: 16px; height: 16px; border: 2px solid var(--kind-deep); background: var(--kind); }
.spacer { flex: 1; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }
.toggles { display: flex; flex-wrap: wrap; gap: 8px; }
.toggles .box { padding: 10px 12px; font-weight: 400; }
.kicker { color: var(--cocoa); font: 600 var(--text-small)/1.4 var(--mono); }
.hint { color: var(--muted); font: 400 var(--text-small)/1.5 var(--sans); }
.label { color: var(--muted); font: 600 var(--text-small)/1 var(--mono); letter-spacing: 0.06em; text-transform: uppercase; }
.form-error { color: var(--error); font: 600 var(--text-small)/1.4 var(--sans); }
.form-error:empty { display: none; }
.check { display: flex; align-items: center; gap: 8px; }

/* forms: a label above its field; links inside sentences */
.form { display: grid; gap: 14px; }
.form-field { display: grid; gap: 6px; font: 600 var(--text-small)/1.3 var(--mono); }
.form-field .hint { font-weight: 400; }
.form-field .field { width: 100%; }
textarea.field { min-height: 7em; line-height: 1.45; font-family: var(--sans); resize: vertical; }
select.field { line-height: 1.2; }
.text-link, .link-button { padding: 0; border: 0; background: none; color: var(--cocoa); font: inherit; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }

/* ---------- the shared top bar (frame.html, put on every page by shell.js) ---------- */

.topbar { display: flex; align-items: center; gap: 20px; padding: 14px 20px; border-bottom: var(--line); }
.brand {
  padding: 8px 14px;
  background: var(--cocoa);
  color: var(--on-cocoa);
  font: italic 600 var(--text-display)/1 var(--mono);
  text-decoration: none;
}
.pages { display: flex; gap: 16px; }
.topbar [data-account] { display: block; max-width: 240px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; } /* a long name or email ends in "…" */

/* ---------- the menu: dark mode, sign out, the fine print; on phones also the page links ---------- */

.menu {
  width: 340px;
  max-width: calc(100vw - 40px);
  margin: 80px 30px auto auto;
  padding: 0;
  border: var(--line);
  background: var(--paper);
  color: var(--ink);
  box-shadow: var(--offset-frame);
}
.menu::backdrop { background: var(--scrim); }
.menu[open] { display: grid; }
.menu-head, .menu-body, .menu-foot { display: grid; gap: 14px; padding: 14px 16px; }
.menu-head { display: flex; align-items: center; justify-content: space-between; border-bottom: var(--line); }
.menu-body { align-content: start; } /* on a phone the menu fills the screen; its contents stay at the top */
.menu-foot { border-top: var(--line); }
.menu-links { display: none; gap: 18px; }
.menu-links .link { font-size: var(--text-large); }

/* ---------- plain pages: a title, then cards or prose ---------- */

.page { display: grid; gap: 24px; }
.page-title {
  justify-self: start;
  padding: 8px 14px;
  background: var(--cocoa);
  color: var(--on-cocoa);
  font: 600 var(--text-display)/1.15 var(--mono);
}

/* cards read like the open event: a small date-style line, a big title, an offset frame */
.card {
  display: grid;
  gap: 14px;
  max-width: 760px;
  padding: 18px 20px;
  border: var(--line);
  background: var(--paper);
  box-shadow: var(--offset-frame);
}
.card-head { display: grid; gap: 6px; }
.card :is(h1, h2) { font: 600 var(--text-display)/1.25 var(--sans); }

/* long text: the terms and privacy pages */
.prose { max-width: 760px; gap: 14px; }
.prose h2 { margin-top: 14px; font: 600 var(--text-title)/1.25 var(--mono); }
.prose ul { display: grid; gap: 8px; margin: 0; padding-left: 22px; }
.prose a { color: var(--cocoa); font-weight: 600; text-underline-offset: 3px; }
.card.narrow { max-width: 560px; }
.prose code { font: 400 var(--text-small)/1 var(--mono); }

/* two columns side by side on a wide screen, one under the other on a phone (Personalize) */
.page-intro { max-width: 760px; color: var(--muted); }
.page-columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; align-items: start; }
.page-columns .card { max-width: none; }
.page-column { display: grid; gap: 24px; }

/* ---------- pop-ups (the first-visit interests): a framed panel; full screen on a phone ---------- */

.popup {
  width: 580px;
  max-width: calc(100vw - 40px);
  max-height: calc(var(--screen) - 80px);
  padding: 0;
  border: var(--line);
  background: var(--paper);
  color: var(--ink);
  box-shadow: var(--offset-frame);
}
.popup[open] { display: grid; grid-template-rows: auto 1fr auto; }
.popup::backdrop { background: var(--scrim); }
.popup-head { padding: 14px 16px; border-bottom: var(--line); }
.popup-title { font: 600 var(--text-title)/1.2 var(--mono); }
.popup-body { display: grid; align-content: start; gap: 12px; overflow: auto; padding: 16px; }
.popup-foot { display: flex; gap: 10px; padding: 12px 16px; border-top: var(--line); }
.popup-foot .primary { flex: 1; justify-content: center; }

/* the interest picker (picker.js), in the pop-up and on Personalize */
.picker { display: grid; gap: 12px; }
.picker .label { margin-top: 10px; }
.picker .label:first-child { margin-top: 0; }

/* ---------- the calendar (index.html, calendar.js) ---------- */

.app.calendar {
  grid-template-rows: auto auto 1fr;
  /* read by calendar.js: the height of an hour, how many overlapping events a day shows side by side,
     and whether tapping a month cell opens its day (on phones, where events are thin bars) */
  --hour: 48px;
  --day-lanes: 3;
  --cell-opens-day: 0;
}

.toolbar { display: flex; align-items: center; gap: 12px; padding: 12px 20px; border-bottom: var(--line); }
.menu-button { display: none; }
.range { font: 600 var(--text-title)/1 var(--mono); white-space: nowrap; }
.scope .box { font-weight: 400; }

/* search looks at all events; quick picks open under it while it has focus */
.search-box { position: relative; }
.search-field { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; width: 260px; padding: 6px 10px; }
.search-field input { flex: 1; min-width: 6ch; padding: 2px 0; border: 0; background: none; color: var(--ink); font: inherit; outline: none; }
.search-field input::placeholder { color: var(--muted); }
.search-field:has(.token) input::placeholder { color: transparent; } /* a pick already says what's searched */
.search-field:focus-within { outline: var(--line); outline-offset: 2px; }
.tokens { display: contents; }
.token {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  border: 0;
  border-left: 5px solid var(--kind-deep, var(--cocoa));
  background: var(--kind, var(--sand));
  color: var(--ink);
  font: 600 var(--text-small)/1.4 var(--sans);
  white-space: nowrap;
  cursor: pointer;
}
.token-x { font-weight: 400; }
.suggest {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  z-index: 5;
  display: none;
  gap: 10px;
  width: 470px;
  padding: 14px 16px;
  border: var(--line);
  background: var(--paper);
  box-shadow: var(--offset-frame);
}
.search-box:focus-within .suggest { display: grid; }

/* the view, and the event panel beside it once an event is open */
.content { display: grid; grid-template-columns: minmax(0, 1fr); min-height: 0; }
.content[data-panel-state="open"] { grid-template-columns: minmax(0, 1fr) 400px; }
.results-note { margin-bottom: 20px; color: var(--muted); }
.load-error { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 20px; padding: 12px 14px; border: var(--line); background: var(--sand); }

/* List and search results */
.day + .day { margin-top: 28px; }
.day-head { display: flex; align-items: end; }
.day-label { padding: 8px 12px; background: var(--cocoa); color: var(--on-cocoa); font: 600 var(--text-small)/1 var(--mono); }
.day-note { padding: 0 12px 6px; color: var(--muted); font: 400 var(--text-small)/1 var(--sans); }
.events { margin: 0; padding: 0; list-style: none; }
.event {
  display: grid;
  grid-template-columns: 8px 130px 1fr;
  width: 100%;
  margin-top: -2px;
  padding: 0;
  border: var(--line);
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.events li:first-child .event { margin-top: 0; }
.event:hover { background: var(--latte); }
.event-kind { background: var(--kind-deep); }
.event-time { padding: 13px 14px; color: var(--cocoa); font: 400 var(--text-small)/1.45 var(--mono); }
.event-what { padding: 10px 14px 12px 0; }
.event-title { display: block; font: 600 var(--text-large)/1.3 var(--sans); }
.event-meta { display: block; margin-top: 3px; color: var(--muted); font: 400 var(--text-small)/1.45 var(--sans); }
.event[aria-expanded="true"] { background: var(--cocoa); color: var(--on-cocoa); }
.event[aria-expanded="true"] .event-time, .event[aria-expanded="true"] .event-meta { color: var(--on-cocoa); }
.empty { padding: 12px 14px; border: var(--line); color: var(--muted); }

/* Day and Week: an hour grid. The day headers stick at the top while the hours scroll; they would stop at the
   scroll area's padding and leave a strip for events to show through, so the gap above is a margin instead. */
.week-scroll { padding-top: 0; }
.week-scroll .tg, .day-empty { margin-top: 20px; }
.tg { display: grid; grid-template-columns: 58px repeat(7, minmax(0, 1fr)); }
.tg[data-days="1"] { grid-template-columns: 58px minmax(0, 1fr); }
.tg-day + .tg-day { margin-left: -2px; }
.tg-head {
  position: sticky;
  top: -2px; /* once stuck, its top border tucks under the toolbar's, so the two read as one line */
  z-index: 3;
  display: grid;
  align-content: start;
  gap: 2px;
  width: 100%;
  height: 80px;
  padding: 8px 10px;
  border: var(--line);
  background: var(--paper);
  color: var(--ink);
  font: 600 var(--text-small)/1.2 var(--mono);
  text-align: left;
  text-transform: uppercase;
  cursor: pointer;
}
.tg-head:hover { background: var(--latte); }
.tg-head[aria-current="date"] { background: var(--cocoa); color: var(--on-cocoa); }
.tg-date { font-size: var(--text-title); }
.tg-note { overflow: hidden; color: var(--muted); font: 400 var(--text-small)/1.2 var(--sans); text-transform: none; white-space: nowrap; text-overflow: ellipsis; }
.tg-head[aria-current="date"] .tg-note { color: var(--on-cocoa); }
.tg-gutter .tg-head { border: 0; align-content: end; color: var(--muted); font: 400 var(--text-small)/1.2 var(--sans); text-transform: none; cursor: default; }
.tg-gutter .tg-head:hover { background: var(--paper); }

.tg-col {
  position: relative;
  height: calc(24 * var(--hour));
  border-left: var(--hairline);
  background-image: linear-gradient(var(--hair) 1px, transparent 1px);
  background-size: 100% var(--hour);
}
.tg-day:last-child .tg-col { border-right: var(--hairline); }
.tg-day.today .tg-col { background-color: var(--today); }
.tg-gutter .tg-col { border: 0; background: none; }
.tg-hour { position: absolute; right: 8px; top: calc(var(--start) * var(--hour) - 9px); color: var(--muted); font: 400 var(--text-small)/1 var(--sans); white-space: nowrap; }

/* calendar.js sets each block's --start and --length (hours) and its --lane of --lanes */
.tg-event {
  --strip-room: 0px;
  position: absolute;
  top: calc(var(--start) * var(--hour) + 1px);
  left: calc(4px + (100% - 8px - var(--strip-room)) * var(--lane) / var(--lanes));
  width: calc((100% - 8px - var(--strip-room)) / var(--lanes) - 3px);
  height: calc(var(--length) * var(--hour) - 3px);
  min-height: 20px;
  display: flex; /* a button centres its text; events read from the top */
  flex-direction: column;
  justify-content: flex-start;
  overflow: hidden;
  padding: 3px 6px;
  border: 1px solid var(--kind-deep);
  border-left: 5px solid var(--kind-deep);
  background: var(--kind);
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.tg-event.squeezed { --strip-room: 31px; } /* room for the "+N" strip beside it */
.tg-event:hover, .tg-event[aria-expanded="true"] { z-index: 1; outline: var(--line); }
/* a narrow column breaks a long word at a syllable ("Soc-cer") rather than cutting it off */
.tg-title { font: 600 var(--text-small)/1.3 var(--sans); overflow-wrap: break-word; hyphens: auto; }
.tg-time { font: 400 var(--text-small)/1.3 var(--sans); overflow-wrap: break-word; hyphens: auto; }
.tg-event.short .tg-time { display: none; } /* an hour or less: the name gets the room */
.clamped { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: var(--lines); overflow: hidden; } /* calendar.js sets --lines */
.tg-hidden { display: none; } /* no lane left; the "+N" strip lists it */
.tg-empty { display: none; } /* the stacked phone week says it; the grid shows it */
.tg-more {
  position: absolute;
  top: calc(var(--start) * var(--hour) + 1px);
  right: 4px;
  width: 28px;
  height: calc(var(--hour) - 3px);
  padding: 0;
  border: var(--line);
  background: var(--latte);
  color: var(--cocoa);
  font: 600 var(--text-small)/1 var(--mono);
  cursor: pointer;
}
.more-list { width: 300px; padding: 12px; border: var(--line); background: var(--paper); color: var(--ink); box-shadow: var(--offset-frame); }
.more-list:popover-open { display: grid; gap: 4px; }
.more-list::backdrop { background: var(--scrim); }
.now { position: absolute; left: 0; right: 0; z-index: 2; top: calc(var(--start) * var(--hour)); border-top: 2px solid var(--cocoa); pointer-events: none; }
.now::before { content: ""; position: absolute; left: -1px; top: -6px; width: 10px; height: 10px; background: var(--cocoa); }

/* Month: a week row never gets shorter than a date, two events and "+N more"; a short window scrolls instead */
.month {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  grid-template-rows: auto repeat(var(--weeks), minmax(106px, 1fr));
  height: 100%; /* a set height, so rows share it instead of growing to fit every event; calendar.js shows what fits */
  border: var(--line);
}
.month-dow { padding: 8px; border-bottom: var(--line); color: var(--muted); font: 600 var(--text-small)/1 var(--mono); text-align: center; text-transform: uppercase; }
.cell { display: flex; flex-direction: column; gap: 3px; min-height: 0; overflow: hidden; padding: 6px; border-right: var(--hairline); border-bottom: var(--hairline); }
.cell:nth-child(7n) { border-right: 0; } /* the seven day names come first, so every seventh child ends a week */
.cell.outside { background: var(--sand); }
.cell-top { display: flex; align-items: center; gap: 6px; min-width: 0; }
.cell-num { padding: 2px 6px; border: 2px solid transparent; background: none; color: var(--ink); font: 600 var(--text-small)/1.2 var(--mono); cursor: pointer; }
.cell-num:hover { border-color: var(--cocoa); }
.cell-num[aria-current="date"] { background: var(--cocoa); color: var(--on-cocoa); }
.cell-note { overflow: hidden; color: var(--muted); font: 400 var(--text-small)/1.2 var(--sans); white-space: nowrap; text-overflow: ellipsis; }
.cell-events { display: grid; gap: 3px; }
.chip {
  padding: 1px 6px;
  overflow: hidden;
  border: 1px solid var(--kind-deep);
  border-left: 5px solid var(--kind-deep);
  background: var(--kind);
  color: var(--ink);
  font: 600 var(--text-small)/1.35 var(--sans);
  text-align: left;
  white-space: nowrap;
  text-overflow: ellipsis;
  cursor: pointer;
}
.chip:hover, .chip[aria-expanded="true"] { outline: var(--line); }
.chip-time { font-weight: 400; }
.more { align-self: start; padding: 0 2px; border: 0; background: none; color: var(--cocoa); font: 600 var(--text-small)/1.3 var(--mono); text-decoration: underline; cursor: pointer; }

/* ---------- the open event (rule 7): beside the view; over it on narrow screens ---------- */

.panel {
  display: flex;
  flex-direction: column;
  margin: 20px 30px 30px 0;
  overflow: auto;
  border: var(--line);
  background: var(--paper);
  box-shadow: var(--offset-frame);
}
.panel-body { display: grid; gap: 14px; padding: 18px 20px; }
.panel-top { display: flex; align-items: start; justify-content: space-between; gap: 12px; }
.panel h2 { font: 600 var(--text-display)/1.25 var(--sans); }
.facts { display: grid; gap: 6px; margin: 0; }
.facts > div { display: grid; grid-template-columns: 64px 1fr; gap: 10px; }
.facts dt { color: var(--muted); font: 400 var(--text-small)/1.6 var(--mono); }
.facts dd { margin: 0; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { padding: 3px 8px; background: var(--sand); font: 400 var(--text-small)/1.3 var(--mono); }
.tag[data-category] { border-left: 5px solid var(--kind-deep); background: var(--kind); }
.panel-description { white-space: pre-wrap; }
.panel-photo { display: block; width: 100%; max-height: 360px; object-fit: contain; background: var(--sand); }
.rsvp, .rsvp-form { display: grid; gap: 10px; }
.rsvp-form fieldset { display: grid; gap: 6px; margin: 0; padding: 10px 12px; border: var(--hairline); }
.rsvp-form legend { padding: 0 4px; font: 600 var(--text-small)/1.3 var(--mono); }
.rsvp-form > .box { justify-self: start; }
.map-box { margin-top: auto; border-top: var(--line); }

/* the campus map (campus-map.js) */
.campus-screen { position: relative; aspect-ratio: 4 / 3; overflow: hidden; background: var(--sand); }
.campus-svg { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; }
.campus-svg.dragging { cursor: grabbing; }
.campus-road { fill: none; stroke: var(--paper); stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; }
.campus-walk { fill: none; stroke: var(--hair); stroke-width: 1.4; stroke-dasharray: 3 2; stroke-linecap: round; }
.campus-around { fill: var(--latte); stroke: var(--kind-other-deep); stroke-width: 0.6; stroke-linejoin: round; }
.campus-target { fill: var(--kind-class); stroke: var(--cocoa); stroke-width: 2; stroke-linejoin: round; }
.campus-code { position: absolute; top: 10px; left: 50%; z-index: 1; transform: translateX(-50%); padding: 3px 8px; border: var(--line); background: var(--paper); color: var(--ink); font: 600 var(--text-small)/1 var(--mono); pointer-events: none; }
.campus-credit { position: absolute; right: 8px; bottom: 6px; z-index: 1; color: var(--muted); font: 400 var(--text-small)/1 var(--sans); }
.campus-idle { display: grid; place-items: center; align-content: center; gap: 12px; height: 100%; margin: 0; padding: 24px; color: var(--muted); text-align: center; }
.campus-tools { position: absolute; left: 8px; bottom: 8px; z-index: 2; display: flex; flex-direction: column; gap: 6px; }
.campus-tool { display: grid; place-items: center; width: 34px; height: 34px; padding: 0; border: var(--line); background: var(--paper); cursor: pointer; }
.campus-tool:hover { background: var(--latte); }
.campus-tool-icon { width: 16px; height: 16px; fill: none; stroke: var(--cocoa); stroke-width: 2; }
.campus-screen.maximized { position: fixed; inset: 24px; z-index: 50; aspect-ratio: auto; border: var(--line); box-shadow: var(--offset-frame), 0 0 0 100vmax var(--scrim); }

/* ---------- Personalize (personalize.html) ---------- */

.card-part { display: grid; gap: 14px; }
.card-part:empty { display: none; } /* a status line with nothing to say leaves no gap */
.steps { display: grid; gap: 6px; margin: 0; padding-left: 22px; }
.class-list .event { cursor: default; }
.class-list .event:hover { background: var(--paper); }
.class-list .event-time { white-space: pre-line; } /* the days, then the hours below */
.drop-zone { display: grid; justify-items: start; gap: 10px; padding: 18px; background: var(--sand); }
.drop-zone[data-dragging] { outline: var(--line); outline-offset: -2px; }

/* ---------- lists of things on plain pages (groups, events, members): one row each, sharing borders ---------- */

.rows { display: grid; margin: 0; padding: 0; list-style: none; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-top: -2px; padding: 12px 14px; border: var(--line); }
.row:first-child { margin-top: 0; }
.row-text { display: grid; flex: 1 1 220px; gap: 2px; min-width: 0; }
.row-panel { display: grid; flex-basis: 100%; gap: 10px; } /* opened under a row: an RSVP list, a group's members (admin) */

/* the admin page: a title with its own action beside it, and a card as wide as the page */
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.card.wide { max-width: none; }

/* ---------- Organize (organize.html) ---------- */

.form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.form-row > * { min-width: 0; }
.form-section { display: grid; gap: 12px; margin: 0; padding: 14px; border: var(--hairline); }
.form-section legend { padding: 0 6px; }
.photo-preview { display: block; max-width: 100%; max-height: 240px; object-fit: contain; border: var(--line); }
.questions { display: grid; gap: 10px; }
.question { display: grid; gap: 8px; padding: 12px; background: var(--sand); }
.question-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.group-list { display: grid; gap: 18px; }
.group { display: grid; gap: 10px; padding-bottom: 18px; border-bottom: var(--hairline); }
.invite { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; gap: 14px; }
.invite-text { display: grid; gap: 10px; }
.invite .field { width: 100%; font-size: var(--text-small); }
.invite .ticket-qr { width: 120px; height: 120px; }

/* ---------- the door: guest list and check-in (guests.html, checkin.html) ---------- */

.row-text > span:not(.hint) { font-size: var(--text-small); } /* a guest's answers under their name */
.checkin-video { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; border: var(--line); background: var(--ink); }
.checkin-result { display: grid; gap: 4px; padding: 14px 16px; border: var(--line); }
.checkin-result strong { font: 600 var(--text-large)/1.3 var(--sans); }
.checkin-result[data-result="ok"] { background: var(--kind-food); }
.checkin-result[data-result="warn"] { background: var(--kind-class); }
.checkin-result[data-result="bad"] { border-color: var(--error); color: var(--error); }

/* ---------- My tickets (tickets.html) ---------- */

.ticket-list { display: grid; gap: 28px; }
.card.ticket { grid-template-columns: minmax(0, 1fr) auto; align-items: start; gap: 20px; }
.ticket-text { display: grid; gap: 12px; }
.ticket-qr { display: block; width: 180px; height: 180px; border: var(--line); } /* site.js draws it, on white so any camera reads it */

/* ---------- a file dragged over the page, and short messages ---------- */

.drop-overlay { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; background: var(--scrim); pointer-events: none; }
.drop-box { display: grid; gap: 8px; padding: 40px 48px; border: var(--line); background: var(--paper); text-align: center; box-shadow: var(--offset-frame); }
.drop-title { font: 600 var(--text-title)/1.2 var(--mono); }
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 70;
  max-width: calc(100vw - 40px);
  padding: 12px 16px;
  transform: translateX(-50%);
  border: var(--line);
  background: var(--paper);
  box-shadow: var(--offset-frame);
}

/* ---------- narrow laptops and tablets: two toolbar rows, and the open event over the view ---------- */

@media (min-width: 721px) and (max-width: 1200px) {
  .toolbar { flex-wrap: wrap; }
  /* row one: Today, arrows, dates, views; row two: search beside For you / All */
  .toolbar .views { order: 5; }
  .search-box { order: 6; flex: 1 1 60%; } /* too wide to fit on row one, so it starts row two */
  .search-field { width: 100%; }
  .scope { order: 7; }
}
@media (min-width: 721px) and (max-width: 1000px) {
  /* the top bar keeps the logo, the account and the menu; the page links move into the menu, as on phones */
  .pages { display: none; }
  .menu-links { display: grid; }
  /* two cards side by side would each be too narrow for their forms */
  .page-columns { grid-template-columns: minmax(0, 1fr); }
  .content[data-panel-state="open"] { grid-template-columns: minmax(0, 1fr); }
  .panel { position: fixed; top: 30px; right: 30px; bottom: 30px; z-index: 30; width: 400px; margin: 0; }
}

/* iPhone Safari zooms into a text field under 16px when it's tapped, and stays zoomed: phones, and touch screens
   wider than the phone layout (an iPhone held sideways) */
@media (max-width: 720px), (pointer: coarse) {
  .field, .invite .field, .search-field input { font-size: var(--text-large); }
}

/* ---------- phones ---------- */

@media (max-width: 720px) {
  body { background: var(--paper); }
  .app { height: var(--screen); margin: 0; border: 0; }
  .app.plain { min-height: var(--screen); }
  .scroll { padding: 14px; }

  /* the top bar keeps the logo and the menu button; the page links move into the menu */
  .topbar { padding: 10px 14px; }
  .pages, .topbar [data-account] { display: none; }
  .menu { width: 100vw; max-width: none; height: var(--screen); max-height: none; margin: 0; border: 0; box-shadow: none; grid-template-rows: auto 1fr auto; }
  .menu-links { display: grid; }
  .popup { width: 100vw; max-width: none; height: var(--screen); max-height: none; margin: 0; border: 0; box-shadow: none; }
  .card.ticket, .invite, .form-row { grid-template-columns: minmax(0, 1fr); }
  .ticket-code { justify-self: center; }
  .page-columns { grid-template-columns: minmax(0, 1fr); }

  /* the calendar: its own toolbar takes the top bar's place, in three rows:
     menu, dates, arrows and Today / the views / search beside For you or All */
  .app.calendar { grid-template-rows: auto 1fr; --day-lanes: 2; --cell-opens-day: 1; }
  .app.calendar .topbar { display: none; }
  .toolbar { position: relative; flex-wrap: wrap; gap: 10px; padding: 10px 14px; }
  .menu-button { display: inline-flex; order: 0; padding: 8px 10px; }
  .range { order: 1; font-size: var(--text-large); }
  .range-year { display: none; }
  .toolbar .spacer { order: 2; }
  .toolbar .arrows { order: 3; }
  .toolbar .today { order: 4; }
  .toolbar .views { order: 5; width: 100%; }
  .toolbar .views .box { flex: 1; justify-content: center; padding: 8px 4px; }
  .search-box { position: static; order: 6; flex: 1 1 0; min-width: 0; } /* a text box asks for ~20 characters; let it shrink so the switch fits beside it */
  .search-field { width: 100%; }
  .scope { order: 7; }
  .wide-only { display: none; }
  .suggest { top: calc(100% + 6px); left: 14px; right: 24px; width: auto; } /* across the screen, under the toolbar */

  .event { grid-template-columns: 8px 92px 1fr; }
  .event-time { padding: 11px 10px; }
  .event-what { padding: 9px 10px 10px 0; }
  .event-title { font-size: var(--text-body); }

  /* an open event covers the screen; × goes back */
  .content[data-panel-state="open"] { grid-template-columns: minmax(0, 1fr); }
  .panel { position: fixed; inset: 0; z-index: 30; margin: 0; border: 0; box-shadow: none; }

  /* Day keeps the hour grid with its pinned header (so no top padding, as above); Week stacks the days,
     each a short list in time order, and scrolls like a list */
  .week-scroll { padding-top: 0; }
  .week-scroll .tg, .day-empty { margin-top: 14px; }
  .week-scroll[data-view="week"] { padding-top: 14px; }
  .week-scroll[data-view="week"] .tg { margin-top: 0; }
  .tg[data-days="7"] { display: block; }
  .tg[data-days="7"] :is(.tg-gutter, .tg-more, .now) { display: none; }
  .tg[data-days="7"] .tg-day + .tg-day { margin: 20px 0 0; }
  .tg[data-days="7"] .tg-head { position: static; display: flex; align-items: baseline; gap: 10px; height: auto; }
  .tg[data-days="7"] .tg-date { font-size: var(--text-small); }
  .tg[data-days="7"] .tg-col { display: grid; gap: 4px; height: auto; margin-top: 4px; border: 0; background: none; }
  .tg[data-days="7"] .tg-event { position: static; width: 100%; height: auto; padding: 7px 10px 8px; }
  .tg[data-days="7"] .tg-hidden { display: flex; }
  .tg[data-days="7"] .tg-event.short .tg-time { display: block; }
  .tg[data-days="7"] .tg-title { font-size: var(--text-body); }
  .tg[data-days="7"] .tg-empty { display: block; padding: 8px 10px; border: var(--line); color: var(--muted); font: 400 var(--text-small)/1.3 var(--sans); }
  .tg[data-days="7"] .clamped { display: block; -webkit-line-clamp: none; }

  /* Month: each event is a thin bar; tapping a day opens it */
  .month { grid-template-rows: auto repeat(var(--weeks), minmax(88px, 1fr)); }
  .cell { padding: 3px; }
  .cell-num { padding: 1px 4px; }
  .cell :is(.cell-note, .cell-month, .chip-time, .more-word) { display: none; }
  .chip { height: 9px; padding: 0; border-left-width: 3px; font-size: 0; }
  .more { font-size: 10px; } /* the one size outside the five: it has to fit a cell a seventh of a phone wide */
}
