:root {
  --bg: #eef0f4;
  --sheet: #ffffff;
  --col: #fbfcfd;
  --past: #dfe3e9;
  --ink: #15181c;
  --muted: #6f7883;
  --faint: #9aa2ac;
  --line: #dfe3e9;
  --edge: #c8cfd7;
  --accent: #1f5fd0;
  --on-accent: #ffffff;
  --free: #1f7a4d;
  --busy: #bc4238;
  --warn: #9a6712;
  --warn-bg: #fdf4e3;
  --block: #eceff3;
  --block-edge: #cbd2da;
  --block-ink: #39424c;
  --mine-bg: #e4f2ea;
  --mine-edge: #4c9f74;
  --r1: #2f6fd0;
  --r2: #12857f;
  --ppm: 1.05;
  --pad: 10px;
  --rail: 44px;
  --gap: 8px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0e12;
    --sheet: #14181d;
    --col: #1a1f26;
    --past: #0f1318;
    --ink: #e7eaee;
    --muted: #8e97a2;
    --faint: #69727d;
    --line: #232931;
    --edge: #333b45;
    --accent: #5b8def;
    --on-accent: #0a0d11;
    --free: #4faa79;
    --busy: #e08279;
    --warn: #d3a44f;
    --warn-bg: #2a2214;
    --block: #262d36;
    --block-edge: #3b444f;
    --block-ink: #c2cad3;
    --mine-bg: #17301f;
    --mine-edge: #3f8f61;
    --r1: #6ea0f5;
    --r2: #3fb3ab;
  }
}

* { box-sizing: border-box; }
html, body { overscroll-behavior-y: none; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 ui-sans-serif, -apple-system, "Segoe UI", Inter, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  padding-bottom: 96px;
}
button { font: inherit; cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

.btn {
  padding: 9px 15px; border: 1px solid var(--edge); border-radius: 9px;
  background: var(--sheet); color: var(--ink); font-weight: 570;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* ---------- gate ---------- */

.gate { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.gate form {
  width: min(360px, 100%); display: grid; gap: 10px;
  background: var(--sheet); border: 1px solid var(--line);
  border-radius: 14px; padding: 22px;
}
.gate h1 { margin: 0; font-size: 19px; letter-spacing: -.015em; }
.gate p { margin: -4px 0 4px; color: var(--muted); font-size: 13.5px; }
label.cap { font-size: 11px; font-weight: 620; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
input[type="password"], input[type="text"] {
  width: 100%; padding: 10px 12px; border: 1px solid var(--edge);
  border-radius: 8px; background: var(--sheet); color: var(--ink); font: inherit;
}
.err { color: var(--busy); font-size: 13.5px; margin: 0; }

/* ---------- the sticky stack: app bar + column heads ---------- */

.stick { position: sticky; top: 0; z-index: 10; background: var(--bg); }

.bar {
  display: flex; align-items: center; gap: 10px;
  padding: 8px var(--pad);
  background: var(--sheet); border-bottom: 1px solid var(--line);
}
.mark { font-size: 14.5px; font-weight: 680; letter-spacing: -.015em; white-space: nowrap; }
.mark span { display: block; font-size: 11px; font-weight: 500; color: var(--muted); letter-spacing: 0; }

.floors { display: flex; gap: 2px; padding: 2px; background: var(--bg); border-radius: 9px; }
.floors button {
  border: 0; background: transparent; color: var(--muted);
  font-size: 12.5px; font-weight: 620; padding: 5px 9px; border-radius: 7px;
  white-space: nowrap;
}
.floors button[aria-current="true"] { background: var(--sheet); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.14); }
.floors .off::after { content: ""; display: inline-block; width: 4px; height: 4px; border-radius: 50%; background: var(--faint); margin-left: 5px; vertical-align: 1px; }

.brk { display: none; }
.day { margin-left: auto; display: flex; align-items: center; gap: 2px; }
.day .arw {
  width: 28px; height: 28px; display: grid; place-items: center;
  border: 1px solid var(--edge); border-radius: 8px;
  background: var(--sheet); color: var(--ink); font-size: 14px; line-height: 1;
}
.day .arw:disabled { opacity: .3; cursor: not-allowed; }
.day .lbl {
  position: relative; min-width: 88px; text-align: center;
  font-size: 13.5px; font-weight: 640; font-variant-numeric: tabular-nums;
  border-radius: 7px; padding: 3px 0;
}
.day .lbl .dow { color: var(--muted); font-weight: 500; margin-left: 4px; }
.day .lbl input {
  position: absolute; inset: 0; width: 100%; height: 100%;
  margin: 0; padding: 0; border: 0; opacity: 0; cursor: pointer;
  appearance: none; -webkit-appearance: none;
}
.day .lbl:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }

.me {
  border: 1px solid var(--edge); border-radius: 999px; background: var(--sheet);
  color: var(--muted); font-size: 12px; font-weight: 600;
  padding: 5px 10px; max-width: 116px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* The track list is written out here rather than shared from :root, because --cols is set on
   this element. A custom property substitutes where it is declared, so a --grid built at :root
   would freeze --cols at its fallback and every floor would get two columns. */
.heads {
  display: grid; grid-template-columns: var(--rail) repeat(var(--cols, 2), minmax(0, 1fr)); gap: 0 var(--gap);
  padding: 8px var(--pad) 0;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.head {
  display: grid; grid-template-columns: auto 1fr; align-items: baseline;
  column-gap: 6px; row-gap: 0;
  padding: 7px 9px 6px;
  background: var(--col);
  border: 1px solid var(--line); border-bottom: 0;
  border-top: 2px solid var(--tone);
  border-radius: 9px 9px 0 0;
  min-width: 0;
}
.head .dot { width: 7px; height: 7px; border-radius: 50%; align-self: center; }
.head .dot.free { background: var(--free); }
.head .dot.busy { background: var(--busy); }
.head .nm { font-size: 13px; font-weight: 660; letter-spacing: -.01em; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.head .st { grid-column: 2; font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- board ---------- */

main { padding: 0 var(--pad) 20px; }

.board {
  position: relative;
  display: grid; grid-template-columns: var(--rail) repeat(var(--cols, 2), minmax(0, 1fr)); gap: 0 var(--gap);
}

.rail { position: relative; }
.rail .tk {
  position: absolute; right: 7px; transform: translateY(-.62em);
  font-size: 10.5px; color: var(--faint); font-variant-numeric: tabular-nums;
}
/* The opening hour sits on the very top edge, so lifting it would hide it under the sticky heads. */
.rail .tk:first-child { transform: none; }

.col {
  position: relative; min-width: 0;
  background: var(--col);
  border: 1px solid var(--line); border-top: 0;
  border-radius: 0 0 9px 9px;
  overflow: hidden;
}
.hours {
  position: absolute; inset: 0;
  background-image: repeating-linear-gradient(to bottom, var(--line) 0 1px, transparent 1px calc(60 * var(--ppm) * 1px));
}
.gone {
  position: absolute; left: 0; right: 0; top: 0;
  background:
    repeating-linear-gradient(-45deg, rgba(127,138,152,.09) 0 5px, transparent 5px 10px),
    var(--past);
  border-bottom: 1px solid var(--edge);
}

.slot { position: absolute; left: 0; right: 0; border: 0; background: transparent; padding: 0; }
.slot[data-why] { cursor: default; }
.slot:not([data-why]):hover { background: color-mix(in oklab, var(--tone) 15%, transparent); }

.peek {
  position: absolute; left: 2px; right: 2px; display: none;
  align-items: center; padding: 0 7px;
  border: 1px dashed var(--tone); border-radius: 7px;
  background: color-mix(in oklab, var(--tone) 16%, transparent);
  color: var(--ink); font-size: 11px; font-weight: 640;
  font-variant-numeric: tabular-nums; pointer-events: none; z-index: 3;
}
.peek.on { display: flex; }
.peek.firm { background: var(--tone); border-style: solid; color: #fff; }

.ev {
  position: absolute; left: 2px; right: 2px;
  display: grid; align-content: start; gap: 1px;
  padding: 3px 7px; text-align: left; overflow: hidden; z-index: 2;
  background: var(--block); color: var(--block-ink);
  border: 1px solid var(--block-edge); border-radius: 7px;
}
.ev .t { font-size: 10px; opacity: .8; font-variant-numeric: tabular-nums; }
.ev .w { font-size: 12px; font-weight: 620; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ev.sm { padding: 1px 7px; }
.ev.sm .t { display: none; }
.ev.sm .w { font-size: 11px; }
.ev.mine { background: var(--mine-bg); border-color: var(--mine-edge); box-shadow: inset 3px 0 0 var(--mine-edge); }
.ev.held { background: var(--warn-bg); border-color: var(--warn); color: var(--warn); box-shadow: inset 3px 0 0 var(--warn); }
.ev:hover { filter: brightness(.98); }

.line { position: absolute; left: var(--rail); right: 0; height: 0; z-index: 4; pointer-events: none; }
.line::before { content: ""; display: block; height: 1px; background: var(--busy); }
.line b {
  position: absolute; left: calc(-1 * var(--rail)); top: -8px;
  font-size: 9.5px; font-weight: 700; color: #fff; background: var(--busy);
  border-radius: 4px; padding: 1px 4px; font-variant-numeric: tabular-nums;
}

/* ---------- closed floor ---------- */

.closed {
  display: grid; place-items: center; gap: 8px; text-align: center;
  padding: 64px 22px; margin-top: 10px;
  background: var(--sheet); border: 1px solid var(--line); border-radius: 12px;
}
.closed h2 { margin: 0; font-size: 17px; }
.closed p { margin: 0; color: var(--muted); font-size: 14px; max-width: 300px; }

/* ---------- map at the bottom ---------- */

.plan { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 14px; }
.plan summary {
  cursor: pointer; font-size: 12px; font-weight: 620; color: var(--muted);
  list-style: none; display: flex; align-items: center; gap: 6px;
}
.plan summary::-webkit-details-marker { display: none; }
.plan summary::before { content: "▸"; font-size: 10px; transition: transform .12s; }
.plan[open] summary::before { transform: rotate(90deg); }
.plan .in { max-width: 360px; margin: 12px auto 0; }
.plan svg { width: 100%; height: auto; display: block; }
.plan .key { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; margin-top: 12px; font-size: 11.5px; color: var(--muted); }
.plan .key i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; vertical-align: -1px; margin-right: 5px; border: 1px solid var(--block-edge); }
.plan .key i.k2 { background: var(--mine-bg); border-color: var(--mine-edge); }
.plan .key i.k1 { background: var(--block); }
.plan .key i.k3 { background: var(--warn-bg); border-color: var(--warn); }

/* ---------- dock ---------- */

.dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  transform: translateY(115%); transition: transform .16s ease;
  background: var(--sheet); border-top: 1px solid var(--edge);
  box-shadow: 0 -6px 22px rgba(10,14,20,.14);
  padding-bottom: env(safe-area-inset-bottom);
}
.dock.on { transform: none; }
.dock .in { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px var(--pad); }
.dock .k { font-size: 10.5px; font-weight: 660; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.dock .v { font-size: 15.5px; font-weight: 640; font-variant-numeric: tabular-nums; }
.dock .v .rm { font-weight: 500; color: var(--muted); font-size: 13.5px; }
.dock .lens { display: flex; gap: 5px; flex-wrap: wrap; }
.dock .acts { margin-left: auto; display: flex; gap: 8px; }
.dock.good { border-top-color: var(--free); }
.dock.good .k { color: var(--free); }
.dock.bad { border-top-color: var(--busy); }
.dock.bad .k { color: var(--busy); }
.dock.bad .v { font-size: 14px; font-weight: 540; }

.chip {
  padding: 5px 11px; border: 1px solid var(--edge); border-radius: 999px;
  background: var(--sheet); color: var(--ink);
  font-size: 12.5px; font-weight: 570; font-variant-numeric: tabular-nums;
}
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.chip:disabled { opacity: .3; cursor: not-allowed; }

/* ---------- dialogs ---------- */

dialog {
  border: 1px solid var(--line); border-radius: 14px; padding: 0;
  background: var(--sheet); color: var(--ink);
  max-width: min(380px, calc(100vw - 28px));
}
dialog::backdrop { background: rgba(8,11,15,.5); }
dialog .body { padding: 20px; display: grid; gap: 10px; }
dialog h2 { margin: 0; font-size: 16.5px; }
dialog .meta { font-size: 13.5px; color: var(--muted); display: grid; gap: 2px; }
dialog .warn { font-size: 13.5px; color: var(--warn); margin: 0; }
dialog .row { display: flex; gap: 8px; justify-content: flex-end; margin-top: 6px; }

/* ---------- narrow ---------- */

@media (max-width: 620px) {
  :root { --ppm: 1; --rail: 36px; --gap: 6px; --pad: 8px; }
  .bar { flex-wrap: wrap; row-gap: 7px; padding: 7px var(--pad); }
  .mark { font-size: 13.5px; }
  .mark span { display: none; }
  .day { gap: 1px; }
  .day .lbl { min-width: 74px; font-size: 13px; }
  .brk { display: block; flex-basis: 100%; height: 0; }
  .day { order: 3; margin-left: 0; }
  .me { order: 4; margin-left: auto; }
  .head {
    grid-template-columns: auto 1fr;
    padding: 6px 7px 5px;
  }
  .head .nm { font-size: 12.5px; white-space: normal; }
  .head .st { font-size: 11px; white-space: normal; line-height: 1.25; }
  .dock .in { gap: 8px; }
  .dock .acts { width: 100%; }
  .dock .acts .btn { flex: 1; }
}
@media (min-width: 1100px) {
  .stick > .bar, .heads, main { max-width: 1180px; margin-inline: auto; }
}
