:root {
  --bg: #0b0e14;
  --panel: rgba(18, 22, 32, 0.85);
  --panel-border: rgba(255, 255, 255, 0.08);
  --text: #e8ecf2;
  --muted: #8b94a5;
  --accent: #4f8cff;
  --train: #3b82f6;
  --tram: #e5593c;
  --vline: #8b5cf6;
  --bus: #22c55e;
  --glass: 12px 24px 40px rgba(0,0,0,.45);
  --radius: 12px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "SF Pro Display", "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
  touch-action: none;
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#gl { position: fixed; inset: 0; }

/* ---------- Top bar ---------- */
#topbar {
  position: fixed; top: 0; left: 0; right: 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: env(safe-area-inset-top) 14px 0;
  padding-top: calc(10px + env(safe-area-inset-top));
  z-index: 20;
  pointer-events: none;
}
#topbar > * { pointer-events: auto; }

.brand { display: flex; align-items: center; gap: 10px; }
.logo {
  width: 34px; height: 34px; border-radius: 9px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--train), var(--vline));
  font-size: 19px; color: #fff;
  box-shadow: var(--glass);
}
.title h1 { font-size: 17px; font-weight: 700; letter-spacing: .2px;
  text-shadow: 0 1px 8px rgba(0,0,0,.6); }
.title span { font-size: 11px; color: var(--muted); display: block; margin-top: 1px;
  text-transform: uppercase; letter-spacing: 1px; }

.controls { display: flex; align-items: center; gap: 8px; }

.icon-btn {
  width: 38px; height: 38px; border-radius: 10px;
  border: 1px solid var(--panel-border);
  background: var(--panel); color: var(--text);
  font-size: 18px; cursor: pointer;
  display: grid; place-items: center;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  box-shadow: var(--glass);
  transition: transform .1s, background .2s;
}
.icon-btn:active { transform: scale(.92); }
.icon-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* type toggle chips */
.type-toggle { display: flex; flex-direction: column; gap: 4px; }
.tt-label { font-size: 10px; color: var(--muted); text-align: right; text-transform: uppercase; letter-spacing: 1px; }
.chips { display: flex; gap: 5px; }
.chip {
  padding: 6px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 600;
  border: 1px solid var(--panel-border);
  background: var(--panel); color: var(--muted);
  cursor: pointer; backdrop-filter: blur(10px); box-shadow: var(--glass);
  transition: all .15s;
}
.chip.on { color: #fff; border-color: transparent; }
.chip[data-type="0"].on { background: var(--train); }
.chip[data-type="1"].on { background: var(--tram); }
.chip[data-type="3"].on { background: var(--vline); }
.chip[data-type="2"].on { background: var(--bus); }

/* ---------- Pill status ---------- */
#status {
  position: fixed; top: calc(76px + env(safe-area-inset-top)); left: 50%;
  transform: translateX(-50%);
  background: var(--panel); border: 1px solid var(--panel-border);
  padding: 7px 14px; border-radius: 999px;
  font-size: 12px; color: var(--text);
  backdrop-filter: blur(10px); z-index: 20;
  box-shadow: var(--glass);
  white-space: nowrap;
}
.pill.hidden { display: none; }

/* ---------- Toolbar ---------- */
#toolbar {
  position: fixed; left: 0; right: 0;
  bottom: calc(12px + env(safe-area-inset-bottom));
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 14px; z-index: 20; pointer-events: none;
}
#toolbar > * { pointer-events: auto; }
.tool-group { display: flex; align-items: center; gap: 10px;
  background: var(--panel); border: 1px solid var(--panel-border);
  padding: 8px 14px; border-radius: 999px; backdrop-filter: blur(10px);
  box-shadow: var(--glass); }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot.train { background: var(--train); }
.dot.tram  { background: var(--tram); }
.dot.vline { background: var(--vline); }
.dot.bus   { background: var(--bus); }
.tlabel { font-size: 11px; color: var(--muted); margin-right: 2px; }
.mono { font-family: "SF Mono", ui-monospace, monospace; font-size: 11px; color: var(--accent); }

/* ---------- Modal ---------- */
.modal {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0,0,0,.55);
  display: grid; place-items: center;
  backdrop-filter: blur(4px);
  padding: 20px;
}
.modal.hidden { display: none; }
.modal-card {
  background: #151a26; border: 1px solid var(--panel-border);
  border-radius: 16px; padding: 22px; max-width: 340px; width: 100%;
  box-shadow: var(--glass);
}
.modal-card h2 { font-size: 18px; margin-bottom: 8px; }
.modal-card p { font-size: 13px; color: var(--muted); line-height: 1.5; margin-bottom: 18px; }
.modal-actions { display: flex; gap: 10px; }
.btn {
  flex: 1; padding: 11px; border-radius: 10px; border: none;
  font-size: 14px; font-weight: 600; cursor: pointer;
}
.btn.primary { background: var(--accent); color: #fff; }
.btn.ghost { background: rgba(255,255,255,.08); color: var(--text); }

/* ---------- Popup ---------- */
.popup {
  position: fixed; bottom: calc(64px + env(safe-area-inset-bottom)); left: 14px; right: 14px;
  max-width: 400px; margin: 0 auto;
  background: var(--panel); border: 1px solid var(--panel-border);
  border-radius: 14px; padding: 14px 16px; z-index: 40;
  backdrop-filter: blur(12px); box-shadow: var(--glass);
}
.popup.hidden { display: none; }
.popup h3 { font-size: 15px; margin-bottom: 6px; }
.popup .dep { display: flex; justify-content: space-between; align-items: center;
  padding: 5px 0; font-size: 13px; border-bottom: 1px solid rgba(255,255,255,.05); }
.popup .dep:last-child { border-bottom: none; }
.popup .dep .t { color: var(--muted); }
.popup .dep .time { font-weight: 700; font-variant-numeric: tabular-nums; }
.popup .dep .time.soon { color: var(--accent); }
.popup .close { float: right; background: none; border: none; color: var(--muted);
  font-size: 16px; cursor: pointer; }

@media (max-width: 600px) {
  .title h1 { font-size: 15px; }
  .tt-label { display: none; }
  .chip { padding: 5px 9px; font-size: 10px; }
}
