html,
body {
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

body {
  background: #000;
}

.viewer-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 2000;
  min-height: 54px;
  display: grid;
  grid-template-columns: minmax(100px, 1fr) auto minmax(100px, 1fr);
  align-items: center;
  gap: 16px;
  padding:
    calc(env(safe-area-inset-top) + 8px)
    calc(env(safe-area-inset-right) + 12px)
    8px
    calc(env(safe-area-inset-left) + 12px);
  color: var(--text-bright);
  border-bottom: 1px solid var(--line-strong);
  background: rgba(3, 3, 3, 0.92);
  backdrop-filter: blur(12px);
}

.viewer-brand {
  color: var(--text);
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.view-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 3px;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  background: #090806;
}

.view-toggle-button {
  min-width: 116px;
  padding: 7px 14px;
  border: 0;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
  font: inherit;
  font-size: 13px;
  font-weight: 850;
  letter-spacing: 0.04em;
  cursor: pointer;
}

.view-toggle-button[aria-pressed="true"] {
  color: #f0cf9c;
  background: #332617;
  box-shadow: inset 0 0 0 1px rgba(225, 188, 134, 0.2);
}

.viewer-meta {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 14px;
}

.stream-status {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.stream-status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #6e5032;
}

.stream-status[data-state="live"]::before {
  background: #8da45d;
  box-shadow: 0 0 0 3px rgba(141, 164, 93, 0.12);
}

.stream-status[data-state="error"]::before,
.stream-status[data-state="stale"]::before {
  background: var(--urgent);
}

.viewer-clock {
  min-width: 72px;
  color: var(--text-bright);
  font-size: 18px;
  font-weight: 750;
  text-align: right;
}

.view-panel {
  position: fixed;
  inset: 0;
  min-width: 0;
  min-height: 0;
}

.view-panel[hidden] {
  display: none;
}

.departures-view {
  overflow: auto;
  background: #000;
}

.public-board-shell {
  height: 100%;
  min-height: 0;
  padding: calc(env(safe-area-inset-top) + 62px) 12px 8px;
}

/* The kiosk typography is intentionally very dense at its fixed resolution.
   The public viewer has to survive arbitrary desktop shapes, where the same
   900-weight, tightly tracked numerals crowd both their glyphs and their
   cards. Keep the glanceable scale while giving the public board more air. */
@media (min-width: 901px) {
  .public-board-shell .route-chip {
    font-size: clamp(110px, min(9.7vw, 15vh), 188px);
    font-weight: 720;
    letter-spacing: -0.012em;
    line-height: 0.82;
  }

  body:not(.mobile-page) .public-board-shell .direction-minutes,
  body:not(.mobile-page) .public-board-shell .direction-minutes[data-values="2"],
  .public-board-shell .direction-minutes[data-display="clock"] {
    font-size: clamp(110px, min(9.7vw, 15vh), 188px);
    font-weight: 720;
    letter-spacing: -0.012em;
    line-height: 0.82;
  }

  .public-board-shell .direction-dir {
    font-weight: 720;
    letter-spacing: -0.01em;
  }

  body:not(.mobile-page) .public-board-shell .section-info.has-walk .walk-adjust {
    font-weight: 750;
  }
}

#map {
  position: absolute;
  inset: 0;
  background: #0b0a09;
}

.public-map-status {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 66px);
  left: calc(env(safe-area-inset-left) + 54px);
  z-index: 1000;
  max-width: calc(100% - 64px);
  padding: 6px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  color: var(--text-bright);
  background: rgba(11, 10, 9, 0.86);
  font-size: 12px;
  pointer-events: none;
  backdrop-filter: blur(5px);
}

/* Leaflet's top-left zoom control shares the row below the fixed app bar. */
.map-view .leaflet-top {
  top: calc(env(safe-area-inset-top) + 56px);
}

.leaflet-bar,
.leaflet-bar a {
  color: var(--text-bright);
  border-color: var(--line-strong);
  background: var(--surface);
}

.leaflet-bar a:hover {
  background: var(--surface-raised);
}

.leaflet-container {
  background: #0b0a09;
  font-family: "Noto Sans", sans-serif;
}

.leaflet-control-attribution {
  color: var(--muted) !important;
  background: rgba(11, 10, 9, 0.78) !important;
}

.leaflet-control-attribution a {
  color: var(--text) !important;
}

.public-vehicle-icon {
  background: transparent;
  border: 0;
}

.public-vehicle-wrap {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 34px;
  height: 34px;
  transform: translate(-50%, -50%);
}

.public-vehicle-arrow {
  position: absolute;
  inset: 0;
  transform-origin: 50% 50%;
}

.public-vehicle-arrow::after {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  width: 0;
  height: 0;
  transform: translateX(-50%);
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-bottom: 7px solid #2f8fff;
  filter: drop-shadow(0 0 1px #0b0a09);
}

.public-vehicle-badge {
  position: absolute;
  top: 50%;
  left: 50%;
  min-width: 10px;
  min-height: 10px;
  padding: 2px 6px;
  transform: translate(-50%, -50%);
  border: 1.5px solid #0b0a09;
  border-radius: 10px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
  font-size: 11px;
  font-weight: 800;
  line-height: 1.4;
  text-align: center;
  white-space: nowrap;
}

.public-vehicle-uncertain .public-vehicle-badge {
  opacity: 0.62;
  border-style: dashed;
}

.public-vehicle-uncertain .public-vehicle-arrow {
  opacity: 0.42;
}

@media (max-width: 900px) {
  html,
  body {
    height: 100%;
    min-height: 0;
    overflow: hidden;
  }

  .public-board-shell {
    height: auto;
    min-height: 100%;
    padding-top: calc(env(safe-area-inset-top) + 64px);
  }

  .viewer-bar {
    grid-template-columns: auto 1fr auto;
    gap: 8px;
  }

  .view-toggle-button {
    min-width: 0;
    padding-inline: 10px;
  }

  .viewer-clock {
    min-width: 0;
  }

  .stream-status {
    display: none;
  }
}

@media (max-width: 520px) {
  .viewer-brand {
    width: 28px;
    overflow: hidden;
    font-size: 0;
  }

  .viewer-brand::before {
    content: "NR";
    font-size: 12px;
  }

  .viewer-meta {
    gap: 0;
  }
}

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