:root {
  --open: #1faa4b;
  --sched: #f59e0b;
  --closed: #e03131;
  --tw: 2px;
  --lw: 2px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden; overscroll-behavior: none;
  background: #c3dff4; -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

/* ------------------------------------------------------------------ map */
#map {
  position: fixed; inset: 0; overflow: hidden; touch-action: none;
  user-select: none; -webkit-user-select: none; cursor: grab;
}
#world { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
#world img {
  position: absolute; display: block; will-change: transform;
  pointer-events: none; -webkit-user-drag: none;
}
#ov {
  position: absolute; left: 0; top: 0; transform-origin: 0 0;
  will-change: transform; overflow: hidden; pointer-events: none;
}
#geo path {
  fill: none; vector-effect: non-scaling-stroke;
  stroke-linecap: round; stroke-linejoin: round;
}
.t { stroke-width: var(--tw); }
.t.s0 { stroke-width: calc(var(--tw) * .6); stroke-dasharray: 1 5; opacity: .6; }
.t.s2 { stroke-width: calc(var(--tw) * .75); opacity: .6; }
.t.su { opacity: .8; }
.lc { stroke: #fff; stroke-width: calc(var(--lw) + 2.5px); opacity: .85; }
.l { stroke: #16181c; stroke-width: var(--lw); }
.l.s0 { stroke: #5b6470; stroke-dasharray: 5 5; }
#hl {
  stroke: #ffe600; stroke-width: calc(var(--tw) + 10px); opacity: .85;
  filter: drop-shadow(0 0 2px rgba(0, 0, 0, .5));
}

/* --------------------------------------------------------------- labels */
#labels { font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
.lb text { text-anchor: start; dominant-baseline: central; }
.lb.lift rect { fill: #16181c; stroke: #fff; stroke-width: 1; }
.lb.lift .nm { fill: #fff; font-size: 11px; font-weight: 700; letter-spacing: .02em; }
.lb.lift .hr { fill: #c9d1d9; font-size: 9.5px; font-weight: 500; }
.lb.lift circle { fill: #8b949e; stroke: #fff; stroke-width: .8; }
.lb.lift.s1 circle { fill: var(--open); }
.lb.lift.s2 circle { fill: var(--sched); }
.lb.lift.s0 circle { fill: var(--closed); }
.lb.lift.s0 rect { fill: #3d444d; }
/* zoomed out: name + state only */
.compact .lift .hr { display: none; }
.compact .lift rect.two { y: -9px; height: 18px; }
.compact .lift .top { transform: translateY(6.5px); }
.lb.lift.s0 .nm { fill: #d0d7de; text-decoration: line-through; }

.lb.trk rect { fill: #fff; stroke: var(--c); stroke-width: 1.2; }
.lb.trk text { fill: var(--c); font-size: 10.5px; font-weight: 600; }
.lb.trk.s1 rect { fill: var(--c); stroke: #fff; }
.lb.trk.s1 text { fill: #fff; }
.lb.trk.s0 rect { stroke-dasharray: 2 2; fill: rgba(255, 255, 255, .85); }
.lb.trk.s0 text { text-decoration: line-through; opacity: .7; }
.lb.sel rect { stroke: #ffe600; stroke-width: 2.5; stroke-dasharray: none; }

/* ------------------------------------------------------------------- ui */
#top {
  position: fixed; z-index: 5; left: 0; right: 0;
  top: env(safe-area-inset-top, 0); padding: 8px; pointer-events: none;
  display: flex; flex-direction: column; align-items: center;
}
#searchbox { display: flex; gap: 6px; width: 100%; max-width: 520px; pointer-events: auto; }
#q {
  flex: 1; min-width: 0; height: 42px; padding: 0 14px; border: 0; border-radius: 21px;
  font: inherit; font-size: 16px; background: rgba(255, 255, 255, .96); color: #111;
  box-shadow: 0 1px 6px rgba(0, 0, 0, .3); outline: none; -webkit-appearance: none; appearance: none;
}
#legendbtn {
  width: 42px; height: 42px; border: 0; border-radius: 50%; font-size: 18px; font-weight: 700;
  background: rgba(255, 255, 255, .96); color: #333; box-shadow: 0 1px 6px rgba(0, 0, 0, .3);
}
#results {
  list-style: none; margin: 6px 0 0; padding: 4px 0; width: 100%; max-width: 520px;
  max-height: min(60vh, 420px); overflow-y: auto; pointer-events: auto;
  background: rgba(255, 255, 255, .98); border-radius: 14px; box-shadow: 0 2px 10px rgba(0, 0, 0, .3);
  -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
}
#results li { display: flex; align-items: center; gap: 10px; padding: 9px 14px; font-size: 15px; cursor: pointer; }
#results li:active, #results li.act { background: #e7f0fa; }
#results li.none { color: #777; cursor: default; }
#results .sw { flex: none; width: 14px; height: 14px; border-radius: 3px; }
#results .sw.lift { border-radius: 50%; background: #16181c; }
#results .rn { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#results .rn small { color: #777; margin-left: 6px; }
#results .rs { flex: none; font-size: 12.5px; color: #555; text-align: right; white-space: nowrap; }

.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 5px; background: #999; }
.dot.d1 { background: var(--open); }
.dot.d2 { background: var(--sched); }
.dot.d0 { background: var(--closed); }

#stamp {
  position: fixed; z-index: 4; left: 8px; bottom: calc(8px + env(safe-area-inset-bottom, 0px));
  display: flex; align-items: center; gap: 6px; padding: 6px 10px; border: 0; border-radius: 14px;
  font: inherit; font-size: 12px; color: #222; background: rgba(255, 255, 255, .92);
  box-shadow: 0 1px 5px rgba(0, 0, 0, .3); max-width: calc(100vw - 16px); text-align: left;
}
#stamp-dot { flex: none; width: 9px; height: 9px; border-radius: 50%; background: #999; }
#stamp.ok #stamp-dot { background: var(--open); }
#stamp.stale #stamp-dot { background: var(--sched); }
#stamp.off #stamp-dot { background: var(--closed); }
#stamp.busy #stamp-dot { animation: blink .7s infinite alternate; }
@keyframes blink { to { opacity: .2; } }

#card {
  position: fixed; z-index: 6; left: 8px; right: 8px; margin: 0 auto; max-width: 520px;
  bottom: calc(8px + env(safe-area-inset-bottom, 0px));
  padding: 14px 44px 14px 16px; background: #fff; border-radius: 16px;
  box-shadow: 0 2px 14px rgba(0, 0, 0, .35); font-size: 15px; color: #111;
}
#card h2 { margin: 0 0 2px; font-size: 19px; }
#card .sub { color: #555; font-size: 13.5px; display: flex; align-items: center; gap: 6px; }
#card .sub .sw { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
#card .st { margin-top: 8px; font-weight: 700; display: flex; align-items: center; }
#card .hrs { margin-top: 4px; font-variant-numeric: tabular-nums; }
#card .hrs b { font-weight: 600; }
#card-close {
  position: absolute; top: 6px; right: 6px; width: 36px; height: 36px; border: 0; background: none;
  font-size: 26px; line-height: 1; color: #666;
}

#legend {
  position: fixed; z-index: 7; top: calc(58px + env(safe-area-inset-top, 0px)); right: 8px;
  width: min(330px, calc(100vw - 16px)); padding: 12px 14px; background: #fff; border-radius: 14px;
  box-shadow: 0 2px 14px rgba(0, 0, 0, .35); font-size: 13.5px; color: #111;
}
#legend h3 { margin: 0 0 6px; font-size: 15px; }
#legend p { margin: 7px 0; }
#legend .muted { color: #666; font-size: 12.5px; }
.lg-line { display: inline-block; width: 34px; height: 0; vertical-align: middle; margin-right: 6px; border-top: 4px solid #0068a5; }
.lg-line.sched { border-top-width: 3px; opacity: .6; }
.lg-line.closed { border-top: 3px dotted #0068a5; opacity: .6; }
.lg-pill { display: inline-block; padding: 0 6px; border-radius: 8px; border: 1.2px solid #0068a5; color: #0068a5; font-size: 11px; font-weight: 600; }
.lg-pill.full { background: #0068a5; color: #fff; }
.lg-pill.off { border-style: dashed; text-decoration: line-through; opacity: .7; }
.lg-lift { display: inline-flex; align-items: center; gap: 5px; padding: 1px 7px; border-radius: 6px; background: #16181c; color: #fff; font-size: 11px; font-weight: 700; }
.lg-lift i { width: 8px; height: 8px; border-radius: 50%; background: var(--open); }

[hidden] { display: none !important; }
