:root {
  --brand: #0b7a6f;
  --brand-ink: #ffffff;
  --brand-soft: #dff1ee;
  --bg: #f4f6f5;
  --card: #ffffff;
  --ink: #15201e;
  --muted: #61706d;
  --line: #e2e8e6;
  --danger: #c0392b;
  --sea: #1f9d55;
  --sda: #d98a00;
  --lsd: #d64545;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 22, .06), 0 2px 8px rgba(16, 24, 22, .05);
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --brand: #2bb3a3; --brand-ink: #04221f; --brand-soft: #123631;
    --bg: #0f1514; --card: #18201f; --ink: #e8efed; --muted: #93a39f; --line: #26302e;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}
button, input, select { font: inherit; color: inherit; }
a { color: var(--brand); }
[hidden] { display: none !important; }

#app { min-height: 100%; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 16px 10px; background: var(--bg);
}
.brand { display: flex; gap: 10px; align-items: center; font-weight: 700; font-size: 19px; }
.brand img { width: 30px; height: 30px; border-radius: 8px; }
main { flex: 1; padding: 4px 16px calc(84px + var(--safe-b)); max-width: 680px; width: 100%; margin: 0 auto; }
main.full { padding: 0; max-width: none; position: relative; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex;
  background: var(--card); border-top: 1px solid var(--line); padding-bottom: var(--safe-b);
}
.tabbar a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 10px;
  color: var(--muted); text-decoration: none; font-size: 12px; font-weight: 600;
}
.tabbar svg { width: 24px; height: 24px; fill: currentColor; }
.tabbar a.active { color: var(--brand); }

h2 { font-size: 15px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 18px 4px 8px; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--line); }
.card + .card { margin-top: 12px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }

.stop-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding: 12px 14px 4px; }
.stop-head b { font-size: 16px; }
.stop-head .code { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.rule {
  display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-top: 1px solid var(--line);
  cursor: pointer;
}
.stop-head + .rule { border-top: 0; }
.rule .info { flex: 1; min-width: 0; }
.rule .sched { font-size: 14px; }
.rule .eta { font-size: 13px; color: var(--muted); margin-top: 2px; }
.rule.off .badge { opacity: .45; }
.rule.off .info { opacity: .6; }

.badge {
  min-width: 52px; text-align: center; padding: 6px 8px; border-radius: 10px; font-weight: 800; font-size: 17px;
  background: var(--brand); color: var(--brand-ink); font-variant-numeric: tabular-nums;
}
.pill { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 99px;
  background: var(--brand-soft); color: var(--brand); vertical-align: 1px; margin-left: 4px; }

.switch { position: relative; width: 46px; height: 28px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; border-radius: 99px; background: var(--line); transition: .2s; }
.switch span::after {
  content: ""; position: absolute; width: 22px; height: 22px; left: 3px; top: 3px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: .2s;
}
.switch input:checked + span { background: var(--brand); }
.switch input:checked + span::after { transform: translateX(18px); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 12px; padding: 12px 18px; font-weight: 700; cursor: pointer; text-decoration: none;
  background: var(--brand); color: var(--brand-ink);
}
.btn.secondary { background: var(--brand-soft); color: var(--brand); }
.btn.ghost { background: transparent; color: var(--brand); padding: 8px 10px; }
.btn.danger { background: transparent; color: var(--danger); }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; }
.fab {
  position: fixed; right: 18px; bottom: calc(80px + var(--safe-b)); z-index: 25;
  border-radius: 99px; padding: 14px 20px; box-shadow: 0 4px 14px rgba(0,0,0,.2);
}

.empty { padding: 40px 20px; text-align: center; }
.empty .big { font-size: 44px; }

/* arrivals */
.arr { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-top: 1px solid var(--line); }
.arr:first-child { border-top: 0; }
.arr .times { flex: 1; display: flex; gap: 14px; flex-wrap: wrap; font-variant-numeric: tabular-nums; }
.t { display: inline-flex; align-items: center; gap: 5px; font-weight: 700; }
.t .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.t .dot.SEA { background: var(--sea); } .t .dot.SDA { background: var(--sda); } .t .dot.LSD { background: var(--lsd); }
.t.sched { font-weight: 500; color: var(--muted); }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--muted); padding: 8px 14px 12px; }

/* forms */
.field { margin: 18px 0; }
.field > label, .label { display: block; font-weight: 700; margin: 0 2px 8px; }
.input {
  width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--card);
  outline: none;
}
.input:focus { border-color: var(--brand); }
.row { display: flex; gap: 10px; align-items: center; }
.row > * { flex: 1; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line); background: var(--card); border-radius: 99px; padding: 8px 14px;
  font-weight: 700; cursor: pointer; font-variant-numeric: tabular-nums;
}
.chip.on { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.seg { display: flex; background: var(--line); border-radius: 12px; padding: 3px; }
.seg button { flex: 1; border: 0; background: transparent; padding: 9px; border-radius: 10px; font-weight: 700; cursor: pointer; }
.seg button.on { background: var(--card); box-shadow: var(--shadow); }
.results { margin-top: 8px; }
.result { padding: 11px 14px; border-top: 1px solid var(--line); cursor: pointer; }
.result:first-child { border-top: 0; }
.result small { color: var(--muted); display: block; }
.picked { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; }
.hint { font-size: 13px; color: var(--muted); margin: 6px 2px 0; }
.error { color: var(--danger); font-weight: 600; margin: 10px 2px; }

/* sheets */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 50; animation: fade .15s; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 51; max-height: 92vh; overflow: auto;
  background: var(--bg); border-radius: 20px 20px 0 0; padding: 8px 16px calc(20px + var(--safe-b));
  animation: up .2s ease-out; max-width: 680px; margin: 0 auto;
}
.sheet .grab { width: 40px; height: 5px; border-radius: 9px; background: var(--line); margin: 4px auto 10px; }
.sheet-title { display: flex; justify-content: space-between; align-items: center; }
.sheet-title h3 { margin: 4px 0; font-size: 19px; }
@keyframes up { from { transform: translateY(40px); opacity: .4; } }
@keyframes fade { from { opacity: 0; } }

/* map */
#map { position: absolute; inset: 0; bottom: calc(60px + var(--safe-b)); }
.map-btn {
  position: absolute; z-index: 500; right: 14px; bottom: calc(80px + var(--safe-b));
  border-radius: 99px; box-shadow: 0 3px 10px rgba(0,0,0,.25);
}
.map-note {
  position: absolute; z-index: 500; left: 50%; transform: translateX(-50%); top: 10px;
  background: var(--card); padding: 6px 12px; border-radius: 99px; font-size: 13px; box-shadow: var(--shadow);
}
.leaflet-container { background: var(--bg); font: inherit; }

/* login */
.login { padding: 30px 8px; text-align: center; }
.login img { width: 84px; height: 84px; border-radius: 20px; }
.login h1 { margin: 16px 0 6px; }
.login p { color: var(--muted); }
.spinner {
  width: 26px; height: 26px; border: 3px solid var(--line); border-top-color: var(--brand); border-radius: 50%;
  animation: spin .8s linear infinite; margin: 18px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

.list-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; border-top: 1px solid var(--line); }
.list-row:first-child { border-top: 0; }

#toast {
  position: fixed; left: 50%; bottom: calc(150px + var(--safe-b)); transform: translateX(-50%) translateY(20px);
  background: #1d2725; color: #fff; padding: 10px 16px; border-radius: 12px; font-weight: 600;
  opacity: 0; pointer-events: none; transition: .2s; z-index: 80; max-width: 90vw;
}
#toast.show { opacity: 1; transform: translateX(-50%); }

.banner { padding: 14px; margin-bottom: 12px; border-color: var(--brand); }
.banner p { margin: 4px 0 10px; }
.banner p:last-child { margin-bottom: 0; }
