/* Abang — dark, mobile-first commuter UI */
:root {
  --bg: #0B0D10; --surface: #13161B; --surface-2: #1A1E25; --line: rgba(255,255,255,.07);
  --text: #F2F4F7; --muted: #8A93A3; --faint: #5B6372; --accent: #3DDC97;
  --ok: #3DDC97; --warn: #FFB547; --bad: #FF6B6B; --r: 22px;
  --font: 'Plus Jakarta Sans', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: var(--font); -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
svg { display: block; }
.screen { display: none; position: fixed; inset: 0; }
.screen.on { display: block; }

/* ---------- Screen 1: routes ---------- */
#routes { overflow-y: auto; padding: max(18px, env(safe-area-inset-top)) 20px 32px; max-width: 520px; margin: 0 auto;
  background: radial-gradient(120% 60% at 100% 0%, rgba(61,220,151,.10), transparent 60%), radial-gradient(90% 50% at 0% 10%, rgba(110,168,255,.08), transparent 60%), var(--bg); }
.top { display: flex; align-items: center; justify-content: space-between; height: 44px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; letter-spacing: -.02em; }
.logo { width: 28px; height: 28px; border-radius: 9px; background: var(--accent); position: relative; box-shadow: 0 6px 20px rgba(61,220,151,.35); }
.logo::after { content: ''; position: absolute; inset: 7px 8px 6px; background: var(--bg); clip-path: polygon(50% 0, 100% 100%, 50% 76%, 0 100%); }
.demo { font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); border: 1px solid var(--line); padding: 5px 9px; border-radius: 99px; background: rgba(255,255,255,.03); }
h1 { font-size: 40px; line-height: 1.05; letter-spacing: -.035em; margin: 44px 0 8px; font-weight: 800; }
.lede { color: var(--muted); margin: 0 0 28px; font-size: 16px; }
.cards { display: grid; gap: 12px; }
.card { display: grid; grid-template-columns: 48px 1fr auto; gap: 14px; align-items: center; text-align: left; width: 100%;
  background: linear-gradient(180deg, rgba(255,255,255,.035), rgba(255,255,255,.01)); border: 1px solid var(--line); border-radius: var(--r); padding: 16px;
  transition: transform .15s ease, border-color .2s; position: relative; overflow: hidden; }
.card::before { content: ''; position: absolute; left: 0; top: 18px; bottom: 18px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.card:active { transform: scale(.985); }
.card:hover { border-color: rgba(255,255,255,.14); }
.sketch { width: 48px; height: 48px; background: rgba(255,255,255,.03); border-radius: 14px; }
.card-kind { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; display: flex; gap: 8px; align-items: center; }
.card-kind b { color: var(--bg); background: var(--accent); padding: 2px 6px; border-radius: 6px; font-size: 10px; }
.card-title { font-size: 17px; font-weight: 700; letter-spacing: -.01em; margin: 6px 0 7px; }
.card-title span { color: var(--faint); font-weight: 500; }
.card-meta { display: flex; gap: 10px; font-size: 12.5px; color: var(--muted); flex-wrap: wrap; }
.live { color: var(--text); display: inline-flex; align-items: center; gap: 6px; }
.live em { font-style: normal; }
.live i, .chip.t-ok i { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 0 rgba(61,220,151,.6); animation: pulse 1.8s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 7px rgba(61,220,151,0); } 100% { box-shadow: 0 0 0 0 rgba(61,220,151,0); } }
.card-eta { text-align: right; display: grid; gap: 3px; max-width: 92px; }
.card-eta small { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-eta strong { font-size: 15px; font-weight: 700; color: var(--accent); white-space: nowrap; font-variant-numeric: tabular-nums; }
.foot { color: var(--faint); font-size: 12px; text-align: center; margin-top: 28px; }

/* ---------- Screen 2: live map ---------- */
#map { position: absolute; inset: 0; background: #0E1013; }
.leaflet-container { background: #0E1013; font-family: var(--font); }
.leaflet-control-attribution { background: rgba(11,13,16,.6) !important; color: var(--faint) !important; font-size: 9px; }
.leaflet-control-attribution a { color: var(--muted) !important; }
.leaflet-top.leaflet-right, .leaflet-bottom.leaflet-right { z-index: 400; }
#live-ui { position: absolute; inset: 0; pointer-events: none; z-index: 500; }
#live-ui > * { pointer-events: auto; }
.bar { position: absolute; top: max(12px, env(safe-area-inset-top)); left: 12px; right: 12px; height: 52px; display: flex; align-items: center; gap: 10px; padding: 0 12px 0 6px;
  background: rgba(19,22,27,.82); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border: 1px solid var(--line); border-radius: 18px; }
.bar-title { flex: 1; font-weight: 700; font-size: 15px; display: flex; gap: 8px; align-items: baseline; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-title b { font-size: 12px; }
.icon-btn { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px; }
.icon-btn:hover { background: rgba(255,255,255,.06); }
.icon-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

/* stops + buses on the map */
.stop { position: relative; }
.stop i { position: absolute; left: -4px; top: -4px; width: 8px; height: 8px; border-radius: 50%; background: #0B0D10; border: 2px solid var(--accent); }
.stop.end i { left: -6px; top: -6px; width: 12px; height: 12px; border-width: 3px; }
.stop span { position: absolute; left: 10px; top: -10px; white-space: nowrap; font-size: 11px; font-weight: 600; color: var(--text); background: rgba(11,13,16,.75); padding: 2px 6px; border-radius: 6px; }
.stop.mine i { left: -9px; top: -9px; width: 18px; height: 18px; background: #fff; border: 5px solid var(--accent); box-shadow: 0 0 0 6px rgba(255,255,255,.08); }
.stop.mine span { left: 14px; top: -12px; background: #fff; color: #0B0D10; font-weight: 700; }
.bus { position: relative; transition: opacity .3s; }
.bus-dot { position: absolute; left: -16px; top: -16px; width: 32px; height: 32px; border-radius: 50%; background: var(--accent); display: grid; place-items: center;
  box-shadow: 0 0 0 4px rgba(11,13,16,.85), 0 8px 18px rgba(0,0,0,.5); transition: transform .2s; }
.bus-dot .arrow { width: 16px; height: 16px; fill: #0B0D10; transform: rotate(var(--rot, 0deg)); }
.bus-tag { position: absolute; left: 20px; top: -11px; white-space: nowrap; font-size: 11px; font-weight: 700; color: var(--text); background: rgba(19,22,27,.92); border: 1px solid var(--line); padding: 3px 7px; border-radius: 8px; }
.bus-tag::before { content: '→ '; color: var(--accent); }
.bus.stopped .bus-dot { box-shadow: 0 0 0 4px rgba(11,13,16,.85), 0 0 0 8px rgba(255,255,255,.12); }
.bus.sel .bus-dot { transform: scale(1.25); box-shadow: 0 0 0 4px rgba(11,13,16,.9), 0 0 0 10px color-mix(in srgb, var(--accent) 30%, transparent); }
.bus.dim { opacity: .35; }
.bus.rev .bus-dot { background: #fff; }
.no-tags .bus-tag, .no-tags .bus.rev .bus-tag { display: none; }
.no-tags .bus.sel .bus-tag { display: block; }
.no-tags .bus-dot { left: -13px; top: -13px; width: 26px; height: 26px; }
.no-tags .bus-dot .arrow { width: 13px; height: 13px; }
#map.raster .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(.85) contrast(.9) saturate(.25); }
.seg i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-right: 7px; vertical-align: 1px; }
.seg button + button i { background: #fff; }
.row-ico.rev { background: rgba(255,255,255,.08); }
.row-ico.rev svg { fill: #fff; }

/* bottom sheet */
.sheet { position: absolute; left: 0; right: 0; bottom: 0; max-width: 560px; margin: 0 auto; background: rgba(19,22,27,.96); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--line); border-bottom: 0; border-radius: 26px 26px 0 0; padding: 8px 18px max(18px, env(safe-area-inset-bottom)); box-shadow: 0 -20px 50px rgba(0,0,0,.45);
  animation: up .35s cubic-bezier(.2,.9,.3,1); }
@keyframes up { from { transform: translateY(30px); opacity: 0; } }
.grab { width: 38px; height: 4px; border-radius: 4px; background: rgba(255,255,255,.14); margin: 0 auto 12px; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.sheet-head small { color: var(--muted); font-size: 12px; font-weight: 600; }
.sheet-head h2 { margin: 2px 0 0; font-size: 24px; letter-spacing: -.025em; font-weight: 800; }
.pill-btn { display: flex; gap: 6px; align-items: center; font-size: 13px; font-weight: 700; padding: 9px 13px; border-radius: 99px; background: rgba(255,255,255,.06); border: 1px solid var(--line); }
.pill-btn svg { width: 16px; height: 16px; fill: var(--accent); stroke: var(--accent); stroke-width: 2; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 14px 0 6px; padding: 4px; background: rgba(255,255,255,.04); border-radius: 14px; }
.seg button { padding: 9px 6px; border-radius: 10px; font-size: 13px; font-weight: 600; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seg button.on { background: var(--surface-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--line); }
.rows { display: grid; }
.row { display: grid; grid-template-columns: 40px 1fr auto; gap: 12px; align-items: center; text-align: left; padding: 11px 2px; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.row-ico { width: 40px; height: 40px; border-radius: 13px; background: color-mix(in srgb, var(--accent) 14%, transparent); display: grid; place-items: center; }
.row-ico svg { width: 17px; height: 17px; fill: var(--accent); transform: rotate(var(--rot)); transition: transform .5s; }
.row-main { display: grid; gap: 3px; min-width: 0; }
.row-main b { font-size: 15px; }
.row-main span { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-main em, .chip em { font-style: normal; }
.t-ok { color: var(--ok); } .t-warn { color: var(--warn); } .t-bad { color: var(--bad); }
.row-eta { font-size: 24px; font-weight: 800; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.row-eta small { font-size: 12px; color: var(--muted); font-weight: 600; margin-left: 2px; letter-spacing: 0; }
.empty, .hint { color: var(--muted); font-size: 13px; text-align: center; }
.hint { color: var(--faint); font-size: 12px; margin: 8px 0 0; }

/* bus sheet */
.chips { display: flex; gap: 8px; margin: 12px 0 14px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 700; padding: 6px 11px; border-radius: 99px; background: rgba(255,255,255,.05); border: 1px solid var(--line); color: var(--text); }
.chip.t-ok { color: var(--ok); } .chip.t-warn { color: var(--warn); } .chip.t-bad { color: var(--bad); }
.chip.t-warn i, .chip.t-bad i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { background: rgba(255,255,255,.04); border: 1px solid var(--line); border-radius: 16px; padding: 12px 13px; display: grid; gap: 3px; min-width: 0; }
.stat small { color: var(--muted); font-size: 11.5px; font-weight: 600; }
.stat b { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat span { font-size: 13px; color: var(--accent); font-weight: 700; }
.stat.mine { background: color-mix(in srgb, var(--accent) 10%, transparent); border-color: color-mix(in srgb, var(--accent) 30%, transparent); }
.load { margin: 14px 0 4px; }
.load-top { display: flex; justify-content: space-between; color: var(--muted); font-size: 11.5px; font-weight: 600; margin-bottom: 7px; }
.bar-track { height: 6px; border-radius: 6px; background: rgba(255,255,255,.07); overflow: hidden; }
.bar-track div { height: 100%; border-radius: 6px; background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent) 60%, #fff)); transition: width .6s; }
.timeline { list-style: none; margin: 14px 0 4px; padding: 0; }
.timeline li { display: grid; grid-template-columns: 18px 1fr auto; align-items: center; gap: 10px; font-size: 14px; padding: 6px 0; position: relative; }
.timeline li i { width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--accent); background: var(--bg); justify-self: center; z-index: 1; }
.timeline li:not(:last-child)::after { content: ''; position: absolute; left: 8px; top: 22px; bottom: -8px; width: 2px; background: color-mix(in srgb, var(--accent) 35%, transparent); }
.timeline li em { font-style: normal; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.timeline li.mine { font-weight: 800; }
.timeline li.mine i { background: var(--accent); }
.timeline li.mine em { color: var(--accent); }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.btn { height: 50px; border-radius: 15px; font-weight: 800; font-size: 15px; background: var(--accent); color: #0B0D10; }
.btn.on { background: #fff; }
.btn.ghost { background: rgba(255,255,255,.06); color: var(--text); border: 1px solid var(--line); }

#toast { position: fixed; left: 50%; top: 80px; transform: translate(-50%, -10px); opacity: 0; pointer-events: none; z-index: 900; background: #fff; color: #0B0D10; font-weight: 700; font-size: 13px; padding: 10px 14px; border-radius: 12px; transition: .25s; white-space: nowrap; }
#toast.on { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 700px) {
  .sheet { left: 24px; right: auto; bottom: 24px; width: 400px; border-radius: 26px; border-bottom: 1px solid var(--line); }
  .bar { right: auto; width: 400px; left: 24px; }
}
