[hidden] { display: none !important; }
:root {
  --bg: #f2f2f7; --card: #fff; --text: #111; --muted: #6e6e73; --faint: #a1a1a6; --line: rgba(60, 60, 67, .14);
  --accent: #0a84ff; --late: #ff3b30; --due: #d70015; --seg: rgba(118, 118, 128, .12); --seg-on: #fff; --press: rgba(0, 0, 0, .05);
  --top-pad: env(safe-area-inset-top); --bot-pad: env(safe-area-inset-bottom);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #000; --card: #1c1c1e; --text: #f5f5f7; --muted: #98989f; --faint: #636366; --line: rgba(84, 84, 88, .55);
    --seg: rgba(118, 118, 128, .24); --seg-on: #636366; --press: rgba(255, 255, 255, .06); --due: #ff6961; }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 17px/1.3 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; overscroll-behavior-y: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; text-align: left; }
b { font-weight: 600; }

/* ---------- home ---------- */
.top { position: sticky; top: 0; z-index: 5; padding: calc(var(--top-pad) + 10px) 16px 10px; background: color-mix(in srgb, var(--bg) 86%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(18px); backdrop-filter: saturate(180%) blur(18px); }
.title-row { display: flex; align-items: center; justify-content: space-between; }
h1 { margin: 2px 0 8px; font-size: 32px; font-weight: 800; letter-spacing: -.02em; }
.icon-btn { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%; color: var(--accent); background: var(--seg); }
.icon-btn:active { transform: scale(.94); }
.search { display: flex; align-items: center; gap: 6px; height: 38px; padding: 0 10px; border-radius: 11px; background: var(--seg); color: var(--muted); }
.search input { flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: none; color: var(--text); font: inherit; font-size: 17px; }
.search input::-webkit-search-cancel-button { display: none; }
.q-clear { width: 22px; height: 22px; border-radius: 50%; background: var(--faint); color: var(--card); font-size: 11px; display: grid; place-items: center; }
.seg { display: grid; grid-template-columns: 1fr 1fr; margin-top: 10px; padding: 2px; border-radius: 9px; background: var(--seg); }
.seg button { height: 30px; border-radius: 7px; text-align: center; font-size: 14px; font-weight: 500; }
.seg button.on { background: var(--seg-on); box-shadow: 0 2px 6px rgba(0, 0, 0, .12); font-weight: 600; }
#list { padding: 4px 16px calc(var(--bot-pad) + 28px); }
.sec { margin: 18px 4px 7px; font-size: 13px; font-weight: 600; letter-spacing: .02em; text-transform: uppercase; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.sec .cnt { font-weight: 500; color: var(--faint); }
.msg { margin: 28px 10px; text-align: center; color: var(--muted); font-size: 15px; line-height: 1.45; }
.msg b { color: var(--text); }
.msg .primary { margin-top: 14px; }
.updated { text-align: center; color: var(--faint); font-size: 12px; margin: 18px 0 0; }
.hint { color: var(--muted); font-size: 13px; margin: 10px 6px; text-align: center; }
.primary { display: inline-block; padding: 11px 22px; border-radius: 12px; background: var(--accent); color: #fff; font-weight: 600; text-align: center; }
.spin { width: 22px; height: 22px; margin: 0 auto 12px; border-radius: 50%; border: 2.5px solid var(--line); border-top-color: var(--muted); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- cards ---------- */
.card { background: var(--card); border-radius: 14px; overflow: hidden; margin-bottom: 12px; }
.card.ghost { opacity: .6; }
.card-h { display: flex; align-items: center; padding: 11px 6px 9px 14px; border-bottom: 1px solid var(--line); }
.card-title { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; }
.card-title > span:last-child { display: flex; flex-direction: column; min-width: 0; }
.card-title b { font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-title small { color: var(--muted); font-size: 13px; display: flex; align-items: center; flex-wrap: wrap; gap: 3px; margin-top: 2px; }
.kind { width: 30px; height: 30px; flex: none; display: grid; place-items: center; border-radius: 8px; font-size: 16px; background: var(--seg); }
.fav { width: 40px; height: 40px; display: grid; place-items: center; color: var(--faint); }
.fav.on { color: #ff9f0a; }
.ldot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; }
.rbadge { display: inline-block; min-width: 22px; padding: 0 5px; border-radius: 5px; background: var(--seg); color: var(--text); font-size: 11.5px; line-height: 17px; text-align: center; font-weight: 600; }
.rbadge.more { color: var(--muted); }
.row { width: 100%; display: flex; align-items: center; gap: 10px; min-height: 54px; padding: 8px 10px 8px 14px; border-top: 1px solid var(--line); }
.card-h + .row { border-top: 0; }
.row:active, .res:active, .veh:active, .card-title:active { background: var(--press); }
.pill { flex: none; min-width: 46px; padding: 3px 7px; border-radius: 7px; font-size: 13px; font-weight: 700; text-align: center; color: #fff; background: #565a5c; }
.pill.bus { min-width: 40px; font-variant-numeric: tabular-nums; }
.dest { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.dest b { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dest small { color: var(--muted); font-size: 12.5px; }
.times { display: flex; align-items: baseline; gap: 8px; font-variant-numeric: tabular-nums; }
.t.first { font-size: 22px; font-weight: 700; }
.t.first small { font-size: 12px; font-weight: 500; color: var(--muted); margin-left: 2px; }
.t.later { font-size: 15px; color: var(--muted); }
.t.due { color: var(--due); }
.t.first.due { font-size: 17px; }
.t.dly { color: var(--late); }
.t.sch { opacity: .55; }
.t.none { color: var(--faint); }
.chev { color: var(--faint); font-size: 22px; line-height: 1; margin-left: 2px; }
.empty-row { padding: 14px; color: var(--muted); font-size: 14px; }
.card.list .res { width: 100%; display: flex; align-items: center; gap: 11px; min-height: 50px; padding: 8px 12px 8px 14px; border-top: 1px solid var(--line); }
.card.list .res:first-child { border-top: 0; }
.res b { flex: 1; min-width: 0; font-size: 16px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.res-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.res-main small { display: flex; gap: 3px; flex-wrap: wrap; }
.res .dots { display: flex; gap: 3px; }

/* ---------- panels ---------- */
.panel { position: fixed; inset: 0; z-index: 20; display: flex; flex-direction: column; background: var(--bg);
  transform: translateX(100%); transition: transform .3s cubic-bezier(.2, .8, .2, 1); box-shadow: -8px 0 30px rgba(0, 0, 0, .15); }
.panel.in { transform: none; }
.p-head { flex: none; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px; padding: calc(var(--top-pad) + 6px) 12px 8px;
  background: color-mix(in srgb, var(--bg) 88%, transparent); -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px); border-bottom: 1px solid var(--line); }
.back { color: var(--accent); font-size: 17px; padding: 8px 6px 8px 0; white-space: nowrap; }
.p-title { min-width: 0; display: flex; align-items: center; justify-content: center; gap: 8px; }
.p-title b { font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.p-act { width: 50px; }
.p-body { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 12px 16px calc(var(--bot-pad) + 24px); }
.map-wrap { position: relative; margin: -12px -16px 0; height: 44vh; min-height: 250px; }
.map { position: absolute; inset: 0; background: #dfe3e8; }
@media (prefers-color-scheme: dark) { .map { background: #1b1d21; } }
.map-count { position: absolute; z-index: 500; left: 10px; top: 10px; padding: 5px 10px; border-radius: 9px; font-size: 13px; font-weight: 600;
  background: color-mix(in srgb, var(--card) 88%, transparent); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); box-shadow: 0 1px 4px rgba(0, 0, 0, .15); }
.leaflet-control-attribution { font-size: 9px; }
.here-note { margin: 12px 4px 0; font-size: 13px; color: var(--muted); }
.veh { width: 100%; display: flex; align-items: center; gap: 12px; min-height: 58px; padding: 9px 12px 9px 12px; border-top: 1px solid var(--line); }
.card.list .veh:first-child { border-top: 0; }
.veh.sel { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.vbadge { flex: none; width: 52px; display: flex; flex-direction: column; align-items: center; padding: 3px 0; border-radius: 9px; font-size: 10px; color: var(--muted);
  border: 1.5px solid var(--c); }
.vbadge b { font-size: 15px; color: var(--text); font-variant-numeric: tabular-nums; }
.vmain { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.vnext { font-size: 15px; }
.vmain small { color: var(--muted); font-size: 12.5px; }
.late { color: var(--late); font-style: normal; font-weight: 600; }
.vmy { flex: none; display: flex; flex-direction: column; align-items: flex-end; font-variant-numeric: tabular-nums; }
.vmy b { font-size: 22px; line-height: 1; color: var(--accent); }
.vmy small { font-size: 11px; color: var(--muted); }
.vmy i { font-style: normal; font-size: 10.5px; color: var(--muted); }

/* map markers */
.vmark { position: relative; width: 30px; height: 30px; }
.vmark span { position: absolute; inset: 4px; display: grid; place-items: center; border-radius: 50%; background: var(--c); color: #fff; border: 2px solid #fff;
  font: 700 8.5px/1 -apple-system, system-ui, sans-serif; box-shadow: 0 1px 4px rgba(0, 0, 0, .35); letter-spacing: -.02em; }
.vmark i { position: absolute; inset: 0; }
.vmark i::before { content: ""; position: absolute; left: 50%; top: -3px; margin-left: -5px; border: 5px solid transparent; border-bottom: 7px solid var(--c); border-top: 0; }
.vmark.dly span { box-shadow: 0 0 0 2px #ff3b30, 0 1px 4px rgba(0, 0, 0, .35); }
.vmark.sel span { transform: scale(1.35); box-shadow: 0 0 0 4px rgba(10, 132, 255, .45), 0 2px 8px rgba(0, 0, 0, .4); }
.here-pin { position: relative; }
.here-pin::before { content: ""; position: absolute; left: -8px; top: -8px; width: 16px; height: 16px; border-radius: 50%; background: #fff; border: 4px solid #111; box-shadow: 0 1px 5px rgba(0, 0, 0, .4); }
.here-pin span { position: absolute; left: 12px; top: -12px; white-space: nowrap; padding: 3px 7px; border-radius: 7px; background: #111; color: #fff; font: 600 12px/1.2 -apple-system, system-ui, sans-serif; }

/* ---------- login ---------- */
#login { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; background: var(--bg); padding: 24px; }
.login-card { width: 100%; max-width: 330px; text-align: center; display: flex; flex-direction: column; gap: 10px; }
.login-card h2 { margin: 4px 0 0; font-size: 28px; }
.login-card p { margin: 0; color: var(--muted); }
.login-card input { height: 48px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--text); font: inherit; text-align: center; }
.login-card .err { color: var(--late); min-height: 1.2em; font-size: 14px; }
.logo-mark { width: 74px; height: 74px; margin: 0 auto; border-radius: 18px; background: url(/icons/icon-192.png) center/cover; }
.card-title small .rbadge, .res .rbadge { flex: none; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.vnext .nw { white-space: nowrap; }
.tiles-dark { filter: invert(1) hue-rotate(180deg) brightness(.85) contrast(.9); }
.leaflet-control-layers { border-radius: 10px !important; border: 0 !important; box-shadow: 0 1px 5px rgba(0, 0, 0, .25) !important; font: 14px/1.4 -apple-system, system-ui, sans-serif; }
.leaflet-control-layers-expanded { padding: 8px 12px; background: var(--card); color: var(--text); }
