:root {
  color-scheme: light;
  --ink: #17324a;
  --muted: #6d7f8f;
  --accent: #e05252;
  --border: #e2e8ed;
  --panel: rgb(255 255 255 / 96%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; -webkit-tap-highlight-color: transparent; }
body { color: var(--ink); background: #f4f7f8; }
button, input { font: inherit; }

#map { position: fixed; inset: 0; width: 100%; height: 100%; background: #f4f7f8; z-index: 0; }
.leaflet-container { font: inherit; background: #f4f7f8; }
.leaflet-control-attribution {
  margin: 0 8px 5px 0 !important;
  padding: 3px 6px !important;
  border-radius: 5px;
  background: rgb(255 255 255 / 82%) !important;
  color: #667887 !important;
  font-size: 9px !important;
}
.leaflet-control-attribution a { color: #536a7b !important; }
.leaflet-bottom { bottom: max(3px, env(safe-area-inset-bottom)); }
.leaflet-right { right: 5px; }
.leaflet-control-zoom { border: 0 !important; box-shadow: 0 3px 14px rgb(23 50 74 / 12%) !important; }
.leaflet-control-zoom a { color: var(--ink) !important; }

.map-brand, .map-info { position: fixed; z-index: 1000; top: max(14px, env(safe-area-inset-top)); }
.map-brand { left: max(14px, env(safe-area-inset-left)); }
.map-info { right: max(14px, env(safe-area-inset-right)); display: flex; align-items: center; gap: 8px; }
.brand {
  display: inline-flex;
  min-height: 48px;
  align-items: center;
  gap: 10px;
  padding: 6px 15px 6px 7px;
  border: 1px solid rgb(226 232 237 / 88%);
  border-radius: 15px;
  background: var(--panel);
  box-shadow: 0 4px 18px rgb(23 50 74 / 10%);
  color: var(--ink);
  text-decoration: none;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.brand img { display: block; width: 34px; height: 34px; overflow: hidden; border-radius: 10px; }
.brand span { font-size: 15px; font-weight: 750; letter-spacing: -.025em; }
.theme-button, .info-button {
  position: relative;
  z-index: 1003;
  display: grid;
  place-items: center;
  border: 1px solid rgb(226 232 237 / 88%);
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  box-shadow: 0 4px 18px rgb(23 50 74 / 10%);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.theme-button, .info-button { width: 48px; height: 48px; border-radius: 15px; transition: background .15s, transform .15s; }
.theme-button:hover, .info-button:hover { background: #fff; transform: translateY(-1px); }
.theme-button[aria-pressed="true"] { background: #17324a; color: #fff; }
.theme-button:focus-visible, .info-button:focus-visible, .line-toggle:focus-visible { outline: 3px solid #4d9bbb; outline-offset: 2px; }
.theme-button svg, .info-button svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.info-panel {
  position: fixed;
  z-index: 1001;
  top: max(12px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  bottom: max(12px, env(safe-area-inset-bottom));
  width: min(370px, calc(100vw - max(12px, env(safe-area-inset-left)) - max(12px, env(safe-area-inset-right))));
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 20px;
  border: 1px solid rgb(220 228 234 / 95%);
  border-radius: 20px;
  background: var(--panel);
  box-shadow: 0 16px 48px rgb(23 50 74 / 18%);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  scrollbar-color: #c5d0d8 transparent;
  scrollbar-width: thin;
}
.info-panel[hidden] { display: none; }
.panel-heading { display: flex; align-items: center; justify-content: flex-start; gap: 12px; min-height: 48px; padding-bottom: 17px; }
.panel-kicker { margin: 0 0 3px; color: var(--accent); font-size: 10px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.panel-heading h1 { margin: 0; font-size: 22px; line-height: 1.2; letter-spacing: -.04em; }
.update-section, .lines-section { padding: 16px 0; border-top: 1px solid var(--border); }
.update-section h2, .lines-section h2, .source-section h2 { margin: 0; font-size: 13px; font-weight: 750; letter-spacing: -.01em; }
.update-time-row { display: flex; align-items: center; gap: 9px; margin-top: 12px; }
.update-time-row strong { font-size: 20px; font-variant-numeric: tabular-nums; letter-spacing: -.035em; }
.update-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: #d0a33d; }
.update-dot.is-live { background: #38a77a; box-shadow: 0 0 0 3px rgb(56 167 122 / 12%); }
.update-source { margin: 3px 0 15px 17px; color: var(--muted); font-size: 11px; overflow-wrap: anywhere; }
.countdown-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 11px; border-radius: 10px; background: #f2f6f8; color: #536a7b; font-size: 12px; }
.countdown-row strong { color: var(--ink); font-size: 13px; font-variant-numeric: tabular-nums; }
.section-heading { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 10px; }
.hint { color: #8795a1; font-size: 10px; }
.line-list { display: grid; gap: 5px; }
.line-item {
  display: grid;
  grid-template-columns: 4px 34px minmax(0, 1fr) auto 34px;
  align-items: center;
  column-gap: 10px;
  min-height: 43px;
  padding: 5px 7px;
  border-radius: 10px;
  cursor: pointer;
  transition: background .12s;
}
.line-item:hover { background: #f2f6f8; }
.line-swatch { width: 4px; height: 25px; border-radius: 9px; background: var(--line-color); }
.line-number { display: grid; min-width: 30px; height: 28px; place-items: center; padding: 0 4px; border-radius: 8px; background: var(--line-color); color: #fff; font-size: 11px; font-weight: 800; font-variant-numeric: tabular-nums; }
.line-name { overflow: hidden; color: #304b61; font-size: 12px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.line-count-wrap { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; text-align: right; }
.line-count { min-width: 26px; color: var(--ink); font-size: 13px; font-weight: 750; font-variant-numeric: tabular-nums; text-align: right; }
.line-count-wrap small { color: var(--muted); font-size: 9px; line-height: 1; white-space: nowrap; }
.line-toggle { justify-self: end; width: 17px; height: 17px; margin: 0 2px 0 0; accent-color: var(--line-color); cursor: pointer; }
.empty-state { margin: 8px 2px; color: var(--muted); font-size: 12px; }
.stops-toggle-row { display: flex; align-items: center; gap: 10px; margin-top: 12px; padding: 10px 9px; border: 1px solid var(--border); border-radius: 11px; background: rgb(242 246 248 / 70%); cursor: pointer; }
.stops-toggle-row img { flex: none; object-fit: contain; }
.stops-toggle-copy { display: flex; flex: 1; flex-direction: column; gap: 2px; }
.stops-toggle-copy strong { color: var(--ink); font-size: 12px; font-weight: 700; }
.stops-toggle-copy small { color: var(--muted); font-size: 10px; }
.stops-toggle-row input { flex: none; width: 17px; height: 17px; margin: 0 2px 0 0; accent-color: var(--ink); cursor: pointer; }
.source-section { padding: 15px 0 2px; border-top: 1px solid var(--border); }
.source-section h2 { margin-bottom: 9px; }
.source-section p { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin: 0; padding: 6px 0; color: var(--muted); font-size: 10px; }
.source-section a { color: #425e73; font-size: 11px; font-weight: 650; text-decoration: none; }
.source-section a:hover { text-decoration: underline; }
.source-section span { flex: none; text-align: right; }

.tram-div-icon { background: transparent; border: 0; }
.tram-marker { position: relative; width: 44px; height: 44px; filter: drop-shadow(0 2px 3px rgb(23 50 74 / 30%)); }
.tram-art { position: absolute; top: 1px; left: 1px; width: 42px; height: 42px; }
.tram-number { position: absolute; z-index: 2; top: 0; right: -2px; display: grid; min-width: 19px; height: 19px; place-items: center; padding: 0 3px; border: 2px solid #fff; border-radius: 999px; background: var(--route); color: #fff; font-size: 9px; font-weight: 850; line-height: 1; }
.tram-marker.cancelled .tram-art { filter: grayscale(1); opacity: .72; }
.tram-marker.cancelled .tram-number { background: #6b7280; }
.tram-cancel-mark { position: absolute; z-index: 3; top: 18px; left: -2px; display: grid; width: 16px; height: 16px; place-items: center; border: 2px solid #fff; border-radius: 50%; background: #6b7280; color: #fff; font-size: 12px; font-weight: 900; line-height: 1; }
.user-location-div-icon { border: 0; background: transparent; }
.user-location-art { display: block; width: 32px; height: 32px; filter: drop-shadow(0 1px 3px rgb(23 50 74 / 35%)); }
.stop-div-icon { border: 0; background: transparent; }
.stop-art { display: block; width: 16px; height: 20px; filter: drop-shadow(0 1px 2px rgb(23 50 74 / 28%)); }
.leaflet-popup-content { line-height: 1.6; }
.leaflet-popup-content span { color: #627d98; font-size: 12px; }
.leaflet-popup-content .popup-detail { display: flex; align-items: center; gap: 6px; margin-top: 5px; }
.leaflet-popup-content .popup-icon { flex: none; width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

body.dark-mode {
  --ink: #e6edf2;
  --muted: #a3b4bf;
  --border: #344955;
  --panel: rgb(22 37 48 / 96%);
  color: var(--ink);
  background: #172630;
}
body.dark-mode .leaflet-control-attribution { background: rgb(22 37 48 / 86%) !important; color: #b5c2cb !important; }
body.dark-mode .leaflet-control-attribution a { color: #d1dce3 !important; }
body.dark-mode .leaflet-control-zoom a { border-color: #344955 !important; background: #1d323f !important; color: #e6edf2 !important; }
body.dark-mode .leaflet-control-zoom a:hover { background: #294250 !important; }
body.dark-mode .theme-button[aria-pressed="true"] { background: #e6edf2; color: #17324a; }
body.dark-mode .countdown-row, body.dark-mode .line-item:hover { background: #253a47; color: #d5e0e6; }
body.dark-mode .stops-toggle-row { border-color: var(--border); background: rgb(37 58 71 / 72%); }
body.dark-mode .countdown-row strong, body.dark-mode .line-name { color: #e6edf2; }
body.dark-mode .source-section a { color: #d1dce3; }
body.dark-mode .leaflet-popup-content-wrapper, body.dark-mode .leaflet-popup-tip { background: #203541; color: #e6edf2; }
body.dark-mode .leaflet-popup-content span { color: #afc0cb; }

@media (max-width: 600px) {
  .map-brand, .map-info { top: max(10px, env(safe-area-inset-top)); }
  .map-brand { left: max(10px, env(safe-area-inset-left)); }
  .map-info { right: max(10px, env(safe-area-inset-right)); }
  .brand { min-height: 44px; gap: 8px; padding: 5px 11px 5px 5px; border-radius: 13px; }
  .brand img { width: 32px; height: 32px; border-radius: 9px; }
  .brand span { font-size: 14px; }
  .theme-button, .info-button { width: 44px; height: 44px; border-radius: 13px; }
  .info-panel { padding-right: 16px; padding-left: 16px; }
  .source-section p { gap: 7px; }
  .source-section a { max-width: 64%; }
}

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