:root {
  --bg: #0b0b0c;
  --card: #161618;
  --card-2: #1f1f22;
  --line: #2a2a2e;
  --text: #f4f4f5;
  --muted: #9b9ba1;
  --dim: #6c6c72;
  --accent: #f6c445;
  --good: #3ecf8e;
  --warn: #f6a545;
  --bad: #ff5a5f;
  --radius: 16px;
  --font: "Helvetica Neue", Helvetica, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  --tabs-h: 64px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); -webkit-font-smoothing: antialiased; }
body { min-height: 100dvh; -webkit-tap-highlight-color: transparent; }
button, input { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; padding: 0; }
a { color: inherit; text-decoration: none; }

/* ---------- header ---------- */
.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 8px;
  padding: calc(env(safe-area-inset-top) + 10px) 18px 10px;
  background: rgba(11, 11, 12, 0.86);
  backdrop-filter: saturate(160%) blur(16px);
  -webkit-backdrop-filter: saturate(160%) blur(16px);
  border-bottom: 1px solid transparent;
}
.top.scrolled { border-bottom-color: var(--line); }
.top h1 { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; margin: 0; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top.detail h1 { font-size: 20px; }
.back { width: 36px; height: 36px; margin-left: -10px; display: grid; place-items: center; border-radius: 50%; }
.back:active { background: var(--card); }
.top-actions { display: flex; gap: 6px; }
.icon-btn { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 50%; color: var(--muted); }
.icon-btn:active { background: var(--card); }
.icon-btn.on { color: var(--accent); }
.icon-btn svg { width: 22px; height: 22px; }

main {
  padding: 4px 16px calc(var(--tabs-h) + env(safe-area-inset-bottom) + 24px);
  max-width: 640px; margin: 0 auto;
}

/* ---------- tabs ---------- */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: flex; justify-content: space-around;
  padding: 6px 12px calc(env(safe-area-inset-bottom) + 6px);
  background: rgba(16, 16, 18, 0.9);
  backdrop-filter: saturate(160%) blur(16px);
  -webkit-backdrop-filter: saturate(160%) blur(16px);
  border-top: 1px solid var(--line);
}
.tabs a { flex: 1; max-width: 120px; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 0; color: var(--dim); font-size: 11px; font-weight: 600; }
.tabs a.active { color: var(--text); }
.tabs svg { width: 25px; height: 25px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linejoin: round; stroke-linecap: round; }
.tabs a.active svg { stroke-width: 2.3; }

/* ---------- sections ---------- */
.section-h { display: flex; align-items: baseline; justify-content: space-between; margin: 22px 4px 10px; }
.section-h h2 { margin: 0; font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.section-h .meta { font-size: 13px; color: var(--dim); }
.empty { color: var(--muted); background: var(--card); border-radius: var(--radius); padding: 18px; line-height: 1.45; font-size: 15px; }
.empty b { color: var(--text); }
.btn { display: inline-flex; align-items: center; gap: 8px; background: var(--card-2); border-radius: 999px; padding: 10px 16px; font-weight: 600; font-size: 15px; }
.btn:active { opacity: 0.7; }
.btn.primary { background: var(--text); color: #000; }
.err { color: var(--bad); font-size: 14px; padding: 6px 4px; }

/* ---------- route bullets ---------- */
.bullet {
  --c: #808183; --t: #fff;
  display: inline-grid; place-items: center; flex: none;
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--c); color: var(--t);
  font-weight: 700; font-size: 15px; line-height: 1; letter-spacing: -0.02em;
}
.bullet.sm { width: 20px; height: 20px; font-size: 12px; }
.bullet.lg { width: 34px; height: 34px; font-size: 20px; }
.bullet.diamond { border-radius: 3px; transform: rotate(45deg) scale(0.86); }
.bullet.diamond > span { transform: rotate(-45deg); }
.bullet.pill { width: auto; min-width: 26px; padding: 0 7px; border-radius: 6px; font-size: 13px; }
.bullet.sm.pill { font-size: 11px; padding: 0 5px; border-radius: 5px; }
.bullets { display: flex; flex-wrap: wrap; gap: 3px; }
.rail-tag { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.rail-tag i { width: 10px; height: 10px; border-radius: 3px; background: var(--c); display: inline-block; }
.mode-tag { font-size: 11px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--dim); }

/* ---------- station cards (home) ---------- */
.card { background: var(--card); border-radius: var(--radius); padding: 14px 14px 10px; margin-bottom: 10px; display: block; }
.card:active { background: var(--card-2); }
.card-h { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.card-h .stack { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.card-h .stack .name { flex: none; }
.card-h .name { font-size: 17px; font-weight: 700; letter-spacing: -0.01em; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-h .dist { color: var(--dim); font-size: 13px; flex: none; }
.card .alert-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); flex: none; }
.mini-group { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-top: 1px solid var(--line); }
.mini-group .lbl { flex: 1; min-width: 0; font-size: 14px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-group .next { display: flex; gap: 12px; align-items: center; flex: none; }
.mini-group .next span.t { display: inline-flex; align-items: center; gap: 5px; font-variant-numeric: tabular-nums; font-weight: 700; font-size: 16px; }
.mini-group .next span.t small { font-weight: 500; color: var(--muted); font-size: 12px; }
.skeleton { height: 14px; border-radius: 6px; background: linear-gradient(90deg, var(--card-2), #29292d, var(--card-2)); background-size: 200% 100%; animation: shimmer 1.2s infinite; margin: 10px 0; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- list rows (search / nearby) ---------- */
.list { background: var(--card); border-radius: var(--radius); overflow: hidden; }
.row { display: flex; align-items: center; gap: 12px; padding: 13px 14px; border-top: 1px solid var(--line); }
.row:first-child { border-top: 0; }
.row:active { background: var(--card-2); }
.row .main { flex: 1; min-width: 0; }
.row .name { font-size: 16px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .sub { margin-top: 5px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row .right { color: var(--dim); font-size: 13px; flex: none; text-align: right; }

/* ---------- search ---------- */
.search-box { position: sticky; top: calc(env(safe-area-inset-top) + 58px); z-index: 4; background: var(--bg); padding: 4px 0 10px; }
.search-box input {
  width: 100%; border: 0; outline: 0; border-radius: 12px; padding: 13px 14px 13px 40px; font-size: 17px;
  background: var(--card) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239b9ba1' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='6.5'/%3E%3Cpath d='M16 16l4.5 4.5'/%3E%3C/svg%3E") no-repeat 12px center / 20px;
}
.chips { display: flex; gap: 8px; margin-top: 10px; overflow-x: auto; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; padding: 7px 13px; border-radius: 999px; background: var(--card); color: var(--muted); font-size: 14px; font-weight: 600; }
.chip.on { background: var(--text); color: #000; }

/* ---------- station detail ---------- */
.station-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 2px 4px 6px; color: var(--muted); font-size: 13px; }
.updated { color: var(--dim); font-size: 12px; margin: 14px 4px 0; text-align: center; }
.group { margin-top: 18px; }
.group h3 { margin: 0 4px 8px; font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.arr { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-top: 1px solid var(--line); }
.arr:first-child { border-top: 0; }
.arr .dest { flex: 1; min-width: 0; }
.arr .dest .d { font-size: 16px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.arr .dest .s { font-size: 13px; color: var(--muted); margin-top: 3px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.arr .when { text-align: right; flex: none; font-variant-numeric: tabular-nums; }
.arr .when .m { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
.arr .when .m small { font-size: 13px; font-weight: 600; color: var(--muted); margin-left: 2px; }
.arr .when .m.now { color: var(--good); }
.arr .when .c { font-size: 12px; color: var(--dim); margin-top: 2px; }
.track { display: inline-flex; align-items: center; gap: 4px; background: var(--card-2); border-radius: 6px; padding: 2px 7px; color: var(--text); font-weight: 600; font-size: 12px; }
.late { color: var(--warn); font-weight: 600; }
.ontime { color: var(--good); }

/* ---------- alerts ---------- */
.alert { background: var(--card); border-radius: var(--radius); padding: 14px; margin-bottom: 10px; border-left: 4px solid var(--warn); }
.alert.planned { border-left-color: #5b8def; }
.alert.info { border-left-color: var(--dim); }
.alert .type { font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--warn); margin-bottom: 6px; }
.alert.planned .type { color: #8fb0f5; }
.alert.info .type { color: var(--muted); }
.alert .h { font-size: 15px; line-height: 1.45; font-weight: 600; white-space: pre-line; }
.alert .d { margin-top: 10px; color: var(--muted); font-size: 14px; line-height: 1.5; white-space: pre-line; display: none; }
.alert.open .d { display: block; }
.alert .more { margin-top: 8px; font-size: 13px; color: var(--dim); font-weight: 600; }
.alert .bullet { vertical-align: -5px; margin: 0 1px; }
.alert-summary { display: flex; align-items: center; gap: 10px; background: rgba(246, 165, 69, 0.12); color: var(--warn); border-radius: 12px; padding: 11px 14px; font-weight: 600; font-size: 14px; margin-top: 12px; width: 100%; text-align: left; }
.alert-summary svg { width: 18px; height: 18px; flex: none; }

.footer-note { text-align: center; color: var(--dim); font-size: 12px; margin-top: 26px; line-height: 1.5; }
.footer-note a { text-decoration: underline; }

.toast { position: fixed; left: 50%; bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 16px); transform: translateX(-50%); background: var(--text); color: #000; padding: 10px 16px; border-radius: 999px; font-weight: 600; font-size: 14px; z-index: 10; animation: fade 2.2s forwards; }
@keyframes fade { 0%, 80% { opacity: 1; } 100% { opacity: 0; } }

@media (min-width: 700px) {
  .top h1 { font-size: 32px; }
}

/* ---------- directions ---------- */
.plan-box { background: var(--card); border-radius: var(--radius); padding: 14px; margin-top: 6px; }
.plan-fields { display: flex; align-items: center; gap: 10px; }
.dots { display: flex; flex-direction: column; align-items: center; gap: 3px; width: 12px; }
.dots .d1 { width: 10px; height: 10px; border-radius: 50%; background: var(--good); }
.dots .d2 { width: 10px; height: 10px; border-radius: 3px; background: var(--bad); }
.dots .dline { width: 2px; height: 26px; background: repeating-linear-gradient(var(--dim) 0 3px, transparent 3px 6px); }
.plan-inputs { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.field { width: 100%; text-align: left; background: var(--card-2); border-radius: 10px; padding: 12px; font-size: 16px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.field .ph { color: var(--dim); font-weight: 500; }
.swap svg { width: 22px; height: 22px; }
.plan-when { margin-top: 12px; flex-wrap: wrap; overflow: visible; }
.plan-when .chip { background: var(--card-2); }
.plan-when .chip.on { background: var(--text); }
.time-input { margin-top: 10px; width: 100%; background: var(--card-2); border: 0; border-radius: 10px; padding: 11px 12px; font-size: 16px; color-scheme: dark; }
.go-btn { width: 100%; justify-content: center; margin-top: 12px; padding: 13px; font-size: 16px; }
.go-btn:disabled { opacity: 0.6; }
.btn:disabled { opacity: 0.6; }

.picker { position: fixed; inset: 0; z-index: 20; background: var(--bg); display: flex; flex-direction: column; padding-top: env(safe-area-inset-top); }
body.picker-open { overflow: hidden; }
.picker-top { display: flex; gap: 10px; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.picker-top input { flex: 1; border: 0; outline: 0; background: var(--card); border-radius: 12px; padding: 12px 14px; font-size: 17px; }
.picker-cancel { color: var(--accent); font-weight: 600; font-size: 16px; padding: 6px 2px; }
.picker-list { flex: 1; overflow-y: auto; padding: 4px 6px calc(env(safe-area-inset-bottom) + 20px); }
.prow { width: 100%; text-align: left; border-radius: 12px; border-top: 0 !important; }
.pico { width: 34px; height: 34px; border-radius: 50%; background: var(--card); display: grid; place-items: center; color: var(--muted); flex: none; }
.psub { color: var(--muted); font-size: 13px; margin-top: 3px; display: block; }
.plist-loading { color: var(--dim); font-size: 13px; padding: 10px 14px; }

.chain { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; }
.chev { color: var(--dim); font-size: 14px; margin: 0 1px; }
.walk-chip { display: inline-flex; align-items: center; gap: 1px; color: var(--muted); font-size: 12px; font-weight: 600; }
.walk-ico { width: 16px; height: 16px; }
.itin { padding: 14px; }
.itin-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.itin-dur { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
.itin-times { color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }
.itin-sub { color: var(--muted); font-size: 13px; margin-top: 10px; }
.row .chain { margin-top: 2px; }

/* trip detail */
body.trip-mode main { padding-top: 0; }
.trip-map { position: relative; height: 42vh; min-height: 260px; margin: 0 -16px; background: #111113; }
.trip-map .maplibregl-ctrl-attrib { font-size: 10px; }
.map-loading { position: absolute; inset: 0; display: grid; place-items: center; color: var(--dim); font-size: 14px; text-align: center; padding: 20px; }
.trip-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 16px 4px 4px; }
.save-btn.on { background: rgba(62, 207, 142, 0.15); color: var(--good); }
.saved-note { background: var(--card); color: var(--muted); font-size: 13px; line-height: 1.45; border-radius: 12px; padding: 10px 12px; margin-top: 10px; }
.timeline { list-style: none; margin: 14px 0 0; padding: 0; }
.timeline > li { position: relative; display: flex; gap: 12px; padding: 0 0 18px; }
.timeline > li::before { content: ''; position: absolute; left: 16px; top: 34px; bottom: 0; width: 4px; border-radius: 2px; background: var(--line); }
.timeline > li.tl-ride::before { background: var(--rc); }
.timeline > li.tl-walk::before { background: repeating-linear-gradient(var(--dim) 0 4px, transparent 4px 9px); width: 3px; left: 16.5px; }
.timeline > li.tl-end::before { display: none; }
.tl-dot { flex: none; width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%; background: var(--card); color: var(--muted); z-index: 1; }
.tl-dot.ride { background: transparent; }
.tl-dot.ride .bullet { width: 34px; height: 34px; font-size: 19px; }
.tl-dot.ride .rail-tag { font-size: 0; gap: 0; }
.tl-dot.ride .rail-tag i { width: 26px; height: 26px; border-radius: 8px; }
.tl-dot.end { background: var(--bad); width: 20px; height: 20px; margin: 8px; border-radius: 6px; }
.tl-body { flex: 1; min-width: 0; padding-top: 6px; }
.tl-title { font-size: 16px; font-weight: 700; line-height: 1.3; }
.tl-meta { color: var(--muted); font-size: 13px; margin-top: 5px; }
.tl-board { font-size: 15px; margin-top: 8px; }
.tl-board b { font-variant-numeric: tabular-nums; margin-right: 6px; }
.tl-live { font-size: 13px; color: var(--good); margin-top: 6px; display: flex; align-items: center; gap: 6px; }
.tl-live:empty { display: none; }
.tl-live b { font-size: 14px; }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--good); animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { opacity: 0.3; } }
.rt { font-size: 11px; font-weight: 700; color: var(--good); background: rgba(62, 207, 142, 0.14); border-radius: 5px; padding: 1px 5px; margin-left: 4px; }
.link { color: var(--accent); font-weight: 600; font-size: 13px; }
.steps { list-style: none; margin: 8px 0 0; padding: 0; display: none; background: var(--card); border-radius: 12px; }
li.open .steps { display: block; }
.steps li { display: flex; justify-content: space-between; gap: 12px; padding: 9px 12px; font-size: 14px; border-top: 1px solid var(--line); }
.steps li:first-child { border-top: 0; }
.steps .sd { color: var(--dim); flex: none; font-variant-numeric: tabular-nums; }
.steps.via li { color: var(--muted); }
.maplibregl-ctrl-group { background: var(--card-2) !important; }
.maplibregl-ctrl-group button .maplibregl-ctrl-icon { filter: invert(1); }

/* ---------- account ---------- */
.acct-btn svg { width: 24px; height: 24px; }
.acct-btn.on { color: var(--text); background: var(--card); }
.acct-hero { text-align: center; background: var(--card); border-radius: var(--radius); padding: 26px 20px 20px; margin-top: 8px; }
.acct-hero h2 { margin: 14px 0 8px; font-size: 21px; }
.acct-hero p { color: var(--muted); line-height: 1.5; margin: 0 0 6px; font-size: 15px; }
.acct-hero .go-btn + .go-btn { margin-top: 10px; }
.acct-small { font-size: 13px !important; margin-top: 14px !important; color: var(--dim) !important; }
.acct-ico { width: 56px; height: 56px; border-radius: 50%; background: var(--card-2); display: inline-grid; place-items: center; color: var(--muted); }
.acct-ico svg { width: 28px; height: 28px; }
.acct-ico.sm { width: 42px; height: 42px; flex: none; }
.acct-ico.sm svg { width: 22px; height: 22px; }
.acct-card { display: flex; align-items: center; gap: 12px; background: var(--card); border-radius: var(--radius); padding: 14px; margin-top: 8px; }
.acct-card .main { flex: 1; min-width: 0; }
.acct-card .name { font-weight: 700; font-size: 16px; overflow: hidden; text-overflow: ellipsis; }
.acct-action { width: 100%; text-align: left; font-size: 16px; font-weight: 600; }
.acct-action.danger { color: var(--bad); }
