:root {
  color-scheme: light;
  --ink: #1a1a1a;
  --ink-2: #5f6368;
  --ink-3: #8c9196;
  --bg: #ffffff;
  --soft: #f6f7f8;
  --line: #e3e5e8;
  --line-2: #c9cdd2;
  --free: #1e7a4f;
  --free-bg: #e7f3ec;
  --busy: #6b7075;
  --focus: #1a5fd0;
  --spot: #5b3fa3;
  --spot-bg: #efebf8;
  --warn: #9a6b00;
  --warn-bg: #fdf6e3;
  --flag: #ffd21f;
  --r: 6px;
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --panel-w: 26rem;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 400 14px/1.5 var(--font);
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  background: var(--bg);
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr) auto;
  height: 100dvh;
}
body > .demo-banner { grid-row: 1; }
body > .top { grid-row: 2; }
body > .when { grid-row: 3; }
body > .stage { grid-row: 4; }
body > .foot { grid-row: 5; }
h1, h2, h3, p, ul, ol { margin: 0; padding: 0; }
ul, ol { list-style: none; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---- demo banner ---- */
.demo-banner {
  position: sticky; top: 0; z-index: 2000;
  display: flex; flex-wrap: wrap; justify-content: center; gap: 0.25rem 0.5rem;
  padding: 0.45rem 1rem; background: var(--flag); color: #000; text-align: center; border-bottom: 1px solid #000;
}
.demo-banner[hidden] { display: none; }

/* ---- top bar ---- */
.top {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem 1.5rem;
  padding: 0.7rem 1rem; border-bottom: 1px solid var(--line);
}
.brand { font-size: 1rem; font-weight: 600; letter-spacing: -0.005em; white-space: nowrap; }
.brand a { text-decoration: none; }

.search { position: relative; flex: 1 1 18rem; max-width: 30rem; }
.search input {
  width: 100%; padding: 0.45rem 0.7rem; border-radius: var(--r);
  border: 1px solid var(--line-2); background: var(--bg);
}
.search input:focus { border-color: var(--ink-2); outline: none; }
.search input::placeholder { color: var(--ink-3); }
.results {
  position: absolute; z-index: 1500; left: 0; right: 0; top: calc(100% + 4px);
  background: var(--bg); border: 1px solid var(--line-2); border-radius: var(--r);
  box-shadow: 0 4px 16px rgb(0 0 0 / 0.08); overflow: hidden;
}
.results[hidden] { display: none; }
.results li { padding: 0.45rem 0.7rem; cursor: pointer; }
.results li.active, .results li:hover { background: var(--soft); }
.results li.none { color: var(--ink-2); cursor: default; background: none; }
.r-kind { display: inline-block; min-width: 4rem; font-size: 0.8rem; color: var(--ink-3); }

.views { display: flex; gap: 1.1rem; margin-left: auto; }
.views button {
  background: none; border: 0; padding: 0.3rem 0; color: var(--ink-2);
  border-bottom: 2px solid transparent; white-space: nowrap;
}
.views button:hover { color: var(--ink); }
.views button[aria-pressed="true"] { color: var(--ink); border-bottom-color: var(--ink); font-weight: 500; }

/* ---- time + filter bar ---- */
.when {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.6rem 1.75rem;
  padding: 0.7rem 1rem; border-bottom: 1px solid var(--line);
}
.clock { display: flex; flex-direction: column; min-width: 10rem; }
.clock-time { font-size: 1.15rem; font-weight: 600; line-height: 1.2; }
.clock-sub { font-size: 0.78rem; color: var(--ink-3); }
.pick { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.5rem 0.8rem; flex: 1 1 26rem; }
.now {
  padding: 0.35rem 0.85rem; border-radius: var(--r);
  border: 1px solid var(--line-2); background: var(--bg); color: var(--ink-2);
}
.now[aria-pressed="true"] { border-color: var(--ink); background: var(--ink); color: #fff; }
.field { display: flex; flex-direction: column; gap: 0.15rem; font-size: 0.75rem; color: var(--ink-3); }
.field input[type="date"], .field input[type="time"] {
  padding: 0.3rem 0.45rem; border: 1px solid var(--line-2); border-radius: var(--r); background: var(--bg); color: var(--ink); font-size: 0.9rem;
}
.field.slider { flex: 1 1 12rem; min-width: 10rem; }
.slider input[type="range"] { width: 100%; accent-color: var(--ink); height: 1.4rem; margin: 0; }
.scale { display: flex; justify-content: space-between; font-size: 0.7rem; color: var(--ink-3); padding: 0 0.2rem; }
.scale i { font-style: normal; }

.filters { flex-basis: 100%; min-width: 0; max-width: 100%; display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 2rem; }
.filter { border: 0; margin: 0; padding: 0; min-width: 0; min-inline-size: 0; display: flex; flex-wrap: wrap; gap: 0.3rem; align-items: center; }
.filter legend { float: left; margin-right: 0.4rem; padding: 0; font-size: 0.78rem; color: var(--ink-3); }
.filter label { position: relative; }
.filter input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.filter span {
  display: inline-block; padding: 0.2rem 0.6rem; border-radius: var(--r);
  border: 1px solid var(--line-2); background: var(--bg); font-size: 0.84rem;
}
.filter label:hover span { border-color: var(--ink-2); }
.filter input:checked + span { background: var(--ink); color: #fff; border-color: var(--ink); }
.filter input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }
.note { flex-basis: 100%; font-size: 0.84rem; color: var(--warn); }
.note[hidden], .filter[hidden] { display: none; }

.layerbar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 1.5rem; }
.layer-status { font-size: 0.84rem; color: var(--warn); }
.layer-status:empty { display: none; }
.filter span.tf-n { display: inline; padding: 0; border: 0; border-radius: 0; background: none; font-size: 0.85em; color: inherit; opacity: 0.7; }

/* ---- stage: panel + map ---- */
.time-toggle { display: none; }
.stage { display: grid; grid-template-columns: var(--panel-w) minmax(0, 1fr); min-height: 0; }
.panel { overflow-y: auto; border-right: 1px solid var(--line); padding: 1rem 1rem 2rem; }
.panel:focus { outline: none; }
.map { min-height: 0; background: #eceeef; }
.leaflet-tile-pane { filter: grayscale(1) contrast(0.9) brightness(1.06); }
.leaflet-container { font-family: var(--font); }

.panel-title { font-size: 1.15rem; font-weight: 600; line-height: 1.3; }
.panel-title .code { font-weight: 700; margin-right: 0.15rem; }
.panel-sub { margin: 0.25rem 0 0.9rem; color: var(--ink-2); }
.back, .linkish {
  background: none; border: 0; padding: 0; margin-bottom: 0.6rem; color: var(--ink);
  text-decoration: underline; text-decoration-color: var(--line-2); text-underline-offset: 3px;
}
.back { text-decoration: none; color: var(--ink-2); }
.back:hover, .linkish:hover { color: var(--ink); text-decoration-color: currentColor; }
.more {
  display: block; margin: 0.9rem auto 0; padding: 0.4rem 0.9rem; border: 1px solid var(--line-2); border-radius: var(--r); background: var(--bg);
}
.more:hover { border-color: var(--ink-2); }
.empty { padding: 0.8rem 0; color: var(--ink-2); }

.legend { margin: 0 0 1rem; }
.legend-bar { height: 8px; border-radius: 2px; }
.legend-lbl { display: flex; justify-content: space-between; font-size: 0.76rem; color: var(--ink-2); margin-top: 0.25rem; }
.legend-note { font-size: 0.78rem; color: var(--ink-3); margin-top: 0.3rem; }

/* ---- room list ---- */
.axis { position: relative; height: 1rem; margin: 0.2rem 0.75rem 0.1rem; font-size: 0.68rem; color: var(--ink-3); }
.axis span { position: absolute; transform: translateX(-50%); }
.rooms { display: grid; border-top: 1px solid var(--line); }
.room { position: relative; padding: 0.65rem 0.75rem 0.7rem; border-bottom: 1px solid var(--line); }
.room.is-busy .room-id, .room.is-busy .room-detail { color: var(--ink-2); }
.room.clickable { cursor: pointer; }
.room.clickable:hover { background: var(--soft); }
.room-head { display: flex; align-items: baseline; justify-content: space-between; gap: 0.5rem; }
.room-id { font-size: 1rem; font-weight: 600; }
.badge { display: inline-flex; align-items: center; gap: 0.3rem; font-size: 0.8rem; white-space: nowrap; }
.badge-ico { display: none; }
.badge::before { content: ''; width: 7px; height: 7px; border-radius: 50%; }
.is-free .badge { color: var(--free); }
.is-free .badge::before { background: var(--free); }
.is-busy .badge { color: var(--busy); }
.is-busy .badge::before { background: var(--line-2); }
.room-bldg { font-size: 0.8rem; color: var(--ink-2); }
.room-detail { margin-top: 0.1rem; }
.room-class { font-size: 0.8rem; color: var(--ink-3); }
.room.flash { animation: flash 1.6s ease-out 1; }
@keyframes flash { 0%, 40% { background: #fff6d6; } 100% { background: transparent; } }

.strip { position: relative; height: 6px; margin-top: 0.5rem; border-radius: 2px; background: var(--free-bg); }
.seg { position: absolute; top: 0; bottom: 0; background: #9aa0a6; }
.tick { position: absolute; top: -3px; bottom: -3px; width: 2px; margin-left: -1px; background: var(--ink); }

.cap-est { margin-left: 0.4rem; font-size: 0.76rem; font-weight: 400; color: var(--ink-3); white-space: nowrap; cursor: help; }

/* ---- room photos ---- */
.room.has-photo { display: grid; grid-template-columns: minmax(0, 1fr) 5rem; column-gap: 0.75rem; align-items: start; }
.room.has-photo > * { grid-column: 1; }
.room.has-photo > .room-photo { grid-column: 2; grid-row: 1 / span 5; }
.room-photo {
  position: relative; width: 5rem; height: 3.75rem; padding: 0; border: 1px solid var(--line); border-radius: 4px;
  overflow: hidden; background: var(--soft); cursor: zoom-in;
}
.room-photo img { display: block; width: 100%; height: 100%; object-fit: cover; }
.room-photo-n { display: none; }
.photo-dialog {
  width: min(94vw, 60rem); max-height: 94dvh; padding: 0.9rem 1rem 1rem; border: 0; border-radius: 8px;
  background: var(--bg); color: var(--ink);
}
.photo-dialog::backdrop { background: rgb(0 0 0 / 0.7); }
.photo-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 0.6rem; }
.photo-head h2 { font-size: 1.1rem; font-weight: 600; }
.photo-close { flex: none; background: none; border: 0; width: 2rem; height: 2rem; font-size: 1.4rem; line-height: 1; color: var(--ink-2); }
.photo-close:hover { color: var(--ink); }
.photo-stage { background: #000; border-radius: 4px; display: grid; place-items: center; overflow: hidden; }
.photo-big { display: block; max-width: 100%; max-height: min(68dvh, 44rem); object-fit: contain; }
.photo-cap { margin-top: 0.5rem; font-size: 0.85rem; color: var(--ink-2); }
.photo-tabs { display: flex; gap: 1rem; margin-top: 0.3rem; }
.photo-tab { padding: 0.15rem 0; border: 0; border-bottom: 2px solid transparent; background: none; color: var(--ink-2); }
.photo-tab[aria-pressed="true"] { color: var(--ink); border-bottom-color: var(--ink); }
.photo-src { margin-top: 0.5rem; font-size: 0.75rem; color: var(--ink-3); }

/* ---- satellite buildings ---- */
.offcampus { margin-top: 1.4rem; }
.offcampus h3, .layer-sec h3, .lib-sec h3, .zones h3 { font-size: 0.9rem; font-weight: 600; }
.offcampus p { font-size: 0.8rem; color: var(--ink-3); margin: 0.1rem 0 0.4rem; }
.offcampus ul { border-top: 1px solid var(--line); }
.off-btn {
  display: block; width: 100%; text-align: left; padding: 0.5rem 0.1rem; background: none;
  border: 0; border-bottom: 1px solid var(--line);
}
.off-btn:hover { background: var(--soft); }
.off-btn b { font-weight: 600; }
.off-n { display: block; font-size: 0.8rem; color: var(--ink-3); }
.far-note { font-size: 0.84rem; color: var(--warn); margin-bottom: 0.7rem; }

/* ---- map labels ---- */
.bl-wrap { width: 0 !important; height: 0 !important; background: none; border: 0; }
.bl-wrap:focus { outline: none; }
.bl-wrap:focus-visible .bl { outline: 2px solid var(--focus); }
.bl {
  position: absolute; transform: translate(-50%, -50%); white-space: nowrap;
  display: inline-flex; gap: 0.25rem; align-items: baseline;
  background: rgb(255 255 255 / 0.95); border: 1px solid var(--ink-2); border-radius: 3px;
  padding: 0 0.25rem; font: 11px/1.45 var(--font); color: var(--ink); cursor: pointer;
}
.bl-wrap.pt .bl { transform: translate(-50%, calc(-100% - 13px)); } /* point marker: label sits above the dot so the dot's colour stays visible */
.bl b { font-weight: 600; }
.bl-n { color: var(--ink-2); }
.bl-wrap.none .bl { border-style: dashed; color: var(--ink-3); }
.bl-wrap.sel .bl { border: 2px solid var(--ink); padding: 0 0.2rem; }
.zoom-far .bl-n { display: none; }
.leaflet-tooltip { font-family: var(--font); }

/* ---- map markers: libraries and study spots ---- */
.lm-wrap, .sm-wrap { width: 0 !important; height: 0 !important; background: none; border: 0; }
.lm-wrap:focus, .sm-wrap:focus { outline: none; }
.lm, .sm { position: absolute; white-space: nowrap; display: inline-flex; align-items: center; gap: 0.3rem; font-size: 11px; line-height: 1.45; cursor: pointer; }
.lm {
  transform: translate(-50%, calc(-100% - 11px));
  padding: 0 0.3rem; border-radius: 3px; border: 1px solid var(--ink); background: var(--ink); color: #fff;
}
.lm-closed, .lm-unknown { background: #fff; color: var(--ink); border-style: dashed; }
.lm-ico { display: inline-flex; }
.lm b { font-weight: 600; }
.lm-b { display: inline-flex; align-items: center; gap: 0.25rem; padding-left: 0.3rem; border-left: 1px solid currentColor; }
.lm-b.is-est { font-style: italic; }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.sm { transform: translate(-50%, 11px); padding: 0 0.4rem; border-radius: 3px; background: var(--spot); color: #fff; }
.sm b { font-weight: 600; }
.pos-pt .lm { transform: translate(-50%, calc(-100% - 36px)); }
.pos-pt .sm { transform: translate(-50%, 15px); }
.pos-none .lm { transform: translate(-50%, calc(-100% - 3px)); }
.pos-none .sm { transform: translate(-50%, 3px); }
.lm-wrap:focus-visible .lm, .sm-wrap:focus-visible .sm, .lm-wrap.sel .lm { outline: 2px solid var(--focus); outline-offset: 1px; }
.sm-t { display: none; }
.zoom-near .sm-t { display: inline; }
.zoom-far .lm-b { display: none; }

/* ---- layer sections in the side panel ---- */
.layer-sec, .lib-sec, .zones { margin-top: 1.4rem; }
.lib-sec { margin-top: 0.9rem; }
.layer-note { font-size: 0.8rem; color: var(--ink-3); margin: 0.1rem 0 0.45rem; }
.credit { font-size: 0.76rem; color: var(--ink-3); margin-top: 0.4rem; }
.credit a, .spot-src a, .strong-link { color: var(--ink); text-underline-offset: 3px; }
.lib-list { border-top: 1px solid var(--line); }
.lib-btn { display: block; width: 100%; text-align: left; padding: 0.5rem 0.1rem; background: none; border: 0; border-bottom: 1px solid var(--line); }
.lib-btn:hover { background: var(--soft); }
.lib-btn b { font-weight: 600; display: block; }
.lib-line { display: block; margin-top: 0.1rem; }
.lib-line .busy-main { font-size: 0.82rem; }
.pill { display: inline-flex; align-items: center; gap: 0.2rem; font-size: 0.78rem; color: var(--busy); }
.pill-open { color: var(--free); }
.pill-unknown { color: var(--warn); }
.busy { margin: 0.3rem 0 0.2rem; }
.busy-main { font-weight: 500; display: flex; align-items: center; gap: 0.4rem; }
.busy.is-est .busy-main { font-style: italic; }
.busy-sub { font-size: 0.78rem; color: var(--ink-3); margin-top: 0.25rem; }
.busy.is-live .dot { color: var(--free); }
.meter { height: 6px; margin-top: 0.3rem; border-radius: 2px; background: var(--soft); border: 1px solid var(--line); overflow: hidden; }
.meter i { display: block; height: 100%; }
.meter.live i { background: var(--free); }
.meter.est { border-style: dashed; }
.meter.est i { background: repeating-linear-gradient(135deg, var(--ink-3) 0 3px, #fff 3px 6px); }
.zones ul { display: grid; gap: 0.5rem; margin-top: 0.4rem; }
.zones li { display: grid; grid-template-columns: 1fr auto; column-gap: 0.5rem; font-size: 0.84rem; }
.zones .meter { grid-column: 1 / -1; margin-top: 0.15rem; }
.z-pct { font-weight: 500; }
.hours-warn { color: var(--warn); font-weight: 500; margin-bottom: 0.4rem; }
.hours-note { font-size: 0.84rem; color: var(--ink-2); margin-bottom: 0.4rem; }
.more-info { font-size: 0.84rem; }
.more-info summary, .sgroup summary { cursor: pointer; font-weight: 500; }
.hours-table { border-collapse: collapse; margin: 0.4rem 0; }
.hours-table th { text-align: left; font-weight: 500; padding: 0.1rem 1rem 0.1rem 0.25rem; }
.hours-table td { padding: 0.1rem 0.25rem 0.1rem 0; }
.hours-table tr.today th, .hours-table tr.today td { background: var(--soft); }
.exc { list-style: disc; padding-left: 1.1rem; color: var(--ink-2); display: grid; gap: 0.2rem; margin-top: 0.3rem; }

.sgroup { margin-top: 0.5rem; border: 1px solid var(--line); border-radius: var(--r); }
.sgroup > summary { display: flex; align-items: baseline; gap: 0.5rem; padding: 0.45rem 0.65rem; list-style: none; }
.sgroup > summary::-webkit-details-marker { display: none; }
.sgroup > summary::before { content: '\25B8'; flex: none; color: var(--ink-3); }
.sgroup[open] > summary::before { content: '\25BE'; }
.sg-name { flex: 1; }
.sg-n { color: var(--ink-3); white-space: nowrap; }
.sgroup > .linkish { margin: 0 0.65rem 0.5rem; }
.bspots { margin: 0 0 0.9rem; }
.spots { display: grid; }
.spot { padding: 0.5rem 0.65rem; border-top: 1px solid var(--line); }
.spot-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 0.5rem; }
.spot-name { font-weight: 500; line-height: 1.3; }
.spot-where { font-size: 0.82rem; color: var(--ink-2); }
.spot-note { font-size: 0.8rem; color: var(--ink-3); }
.spot-src { font-size: 0.78rem; margin-top: 0.1rem; }
.spot-sn { color: var(--ink-3); }
.conf { flex: none; font-size: 0.72rem; color: var(--free); }
.conf-anecdotal { color: var(--warn); }
.tags { display: flex; flex-wrap: wrap; gap: 0.25rem; margin: 0.25rem 0; }
.tags li { font-size: 0.72rem; padding: 0 0.4rem; color: var(--spot); border-radius: 3px; background: var(--spot-bg); }

/* ---- footer ---- */
.foot {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.2rem 1.25rem;
  padding: 0.45rem 1rem; border-top: 1px solid var(--line); font-size: 0.78rem; color: var(--ink-2);
}
.foot a { color: var(--ink); text-underline-offset: 2px; }
.about summary { cursor: pointer; color: var(--ink-2); }
.about summary:hover { color: var(--ink); }
.about[open] { flex-basis: 100%; order: 2; }
.about p { max-width: 80ch; margin-top: 0.25rem; color: var(--ink-3); }

/* ---- phone / narrow ---- */
@media (max-width: 819px) {
  body { display: block; height: auto; min-height: 100dvh; }
  .stage { display: flex; flex-direction: column; }
  .map { order: -1; height: 52dvh; min-height: 300px; }
  .wide-only { display: none; }
  .time-toggle {
    display: inline-block; margin-left: auto; padding: 0.3rem 0.7rem; border-radius: var(--r);
    background: var(--bg); border: 1px solid var(--line-2);
  }
  .time-toggle[aria-expanded="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
  .pick { display: none; }
  .when.open .pick { display: flex; }
  .panel { border-right: 0; overflow: visible; }
  [data-view="list"] .map { display: none; }
  .top { gap: 0.5rem 1rem; }
  .search { order: 3; flex-basis: 100%; max-width: none; }
  .when { gap: 0.5rem 1rem; align-items: center; }
  .clock { min-width: 0; }
  .pick { flex-basis: 100%; }
  .field.slider { flex-basis: 100%; }
  .pick .field:not(.slider) { flex: 1 1 7rem; }
  .pick .field input { width: 100%; }
  .filters { gap: 0.4rem; }
  .filter { overflow-x: auto; flex-wrap: nowrap; padding-bottom: 0.15rem; flex: 1 1 100%; max-width: 100%; scrollbar-width: none; }
  .filter span { white-space: nowrap; }
  .layerbar { flex: 1 1 100%; flex-direction: column; align-items: stretch; gap: 0.3rem; }
  .foot { padding: 0.8rem 1rem 1rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; scroll-behavior: auto !important; }
}
