:root {
  --bg: #f2f4f3;
  --card: #ffffff;
  --text: #121614;
  --muted: #6a736e;
  --line: #e3e8e5;
  --soft: #eef2f0;
  --l35: #1f8a4c;          /* line 35 - Egged green */
  --l36: #2563c9;          /* line 36 - blue */
  --hero-a: #2fb36a;
  --hero-b: #137a43;
  --hero-ink: #ffffff;
  --live: #16a34a;
  --missed-bg: #f0f1f2;
  --missed-text: #9aa0a6;
  --warn: #b45309;
  --warn-bg: #fff6e6;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1110;
    --card: #181c1a;
    --text: #eef2f0;
    --muted: #94a09a;
    --line: #262c29;
    --soft: #1f2422;
    --l35: #2fb36a;
    --l36: #4f8df0;
    --hero-a: #1f8a4c;
    --hero-b: #0c4d2a;
    --live: #3ddc84;
    --missed-bg: #141716;
    --missed-text: #5c6460;
    --warn: #f5b041;
    --warn-bg: #2a2114;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", "Arial Hebrew", Arial, sans-serif;
  padding: calc(env(safe-area-inset-top) + 12px) 16px calc(env(safe-area-inset-bottom) + 20px);
  max-width: 560px;
  margin-inline: auto;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; }
a { color: var(--l35); }
.muted { color: var(--muted); margin: 0; }
.small { font-size: 13px; }
.center { text-align: center; }

/* header */
.top { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.logo { width: 44px; height: 44px; border-radius: 11px; flex: none; box-shadow: 0 2px 6px rgba(0,0,0,.18); }
.title { flex: 1; min-width: 0; }
h1 { font-size: 22px; margin: 0; letter-spacing: -0.01em; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 50%; flex: none;
  border: 1px solid var(--line); background: var(--card);
  display: grid; place-items: center; cursor: pointer;
}
.icon-btn:active { transform: scale(0.94); }
.icon-btn.spin svg { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(-360deg); } }

/* direction switch */
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; background: var(--soft); padding: 4px; border-radius: 14px; border: 1px solid var(--line); }
.seg button { border: 0; background: transparent; padding: 10px 6px; border-radius: 10px; font-weight: 700; font-size: 15px; color: var(--muted); cursor: pointer; }
.seg button[aria-selected="true"] { background: var(--card); color: var(--text); box-shadow: 0 1px 4px rgba(0,0,0,.12); }
#dir-note { margin: 7px 0 14px; min-height: 18px; }

/* hero - next bus */
.hero {
  position: relative; overflow: hidden;
  background: linear-gradient(135deg, var(--hero-a), var(--hero-b));
  color: var(--hero-ink); border-radius: 22px; padding: 16px 18px;
  box-shadow: 0 8px 24px rgba(19, 122, 67, .25);
}
.hero::after { content: ""; position: absolute; inset: -40% -20% auto auto; width: 70%; height: 120%; background: radial-gradient(circle, rgba(255,255,255,.18), transparent 60%); pointer-events: none; }
.hero .kicker { font-size: 13px; font-weight: 600; opacity: .92; display: flex; align-items: center; gap: 6px; }
.hero .main { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 6px 0 10px; }
.hero .line { display: flex; align-items: center; gap: 10px; font-size: 22px; font-weight: 800; }
.hero .line .badge { background: rgba(255,255,255,.95); color: var(--hero-b); width: 56px; height: 46px; font-size: 26px; border-radius: 12px; }
.hero .count { text-align: center; line-height: 1; }
.hero .count b { font-size: 54px; font-weight: 800; letter-spacing: -0.02em; display: block; }
.hero .count span { font-size: 15px; font-weight: 600; opacity: .9; }
.hero .count.now b { font-size: 36px; }
.hero .where { font-size: 14px; display: flex; align-items: flex-start; gap: 8px; background: rgba(0,0,0,.14); border-radius: 12px; padding: 9px 11px; line-height: 1.45; }
.hero .where svg { flex: none; margin-top: 2px; }
.hero .where b { font-size: 15px; }
.hero .alt { margin-top: 10px; font-size: 14px; font-weight: 600; }
.hero.missed { background: var(--missed-bg); color: var(--missed-text); box-shadow: none; border: 1px solid var(--line); }
.hero.missed .badge { background: var(--missed-text); color: var(--missed-bg); }
.hero.missed .where { background: var(--soft); }
.hero.missed .alt { color: var(--text); }
.pill { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: rgba(255,255,255,.22); }
.hero.missed .pill { background: var(--line); color: var(--text); }

/* notices */
#notices:empty { display: none; }
.notice { background: var(--warn-bg); color: var(--warn); font-size: 13px; border-radius: 12px; padding: 9px 12px; margin: 12px 0 0; }

/* full-day list */
.day { margin-top: 22px; }
.day-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin: 0 4px 10px; }
.day-head h2 { font-size: 18px; margin: 0; }
.legend { font-size: 12px; color: var(--muted); white-space: nowrap; }
.past-toggle { width: 100%; border: 1px dashed var(--line); background: transparent; color: var(--muted); border-radius: 12px; padding: 9px; font-size: 14px; margin-bottom: 10px; cursor: pointer; }

.list { list-style: none; margin: 0; padding: 0; background: var(--card); border-radius: 18px; overflow: hidden; border: 1px solid var(--line); }
.list:empty { display: none; }
.row { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-top: 1px solid var(--line); }
.row:first-child { border-top: 0; }
.row .time { flex: none; width: 54px; text-align: center; line-height: 1.15; font-variant-numeric: tabular-nums; }
.row .time b { font-size: 19px; font-weight: 800; display: block; }
.row .time s { font-size: 12px; color: var(--muted); }
.badge { flex: none; width: 44px; height: 34px; border-radius: 10px; display: grid; place-items: center; font-weight: 800; font-size: 17px; color: #fff; }
.badge.l35 { background: var(--l35); }
.badge.l36 { background: var(--l36); }
.row .info { flex: 1; min-width: 0; }
.row .stop { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .meta { color: var(--muted); font-size: 13px; }
.row .status { flex: none; text-align: center; min-width: 50px; line-height: 1.1; }
.row .status b { display: block; font-size: 18px; }
.row .status span { font-size: 12px; color: var(--muted); }
.row.next { background: var(--soft); }
.row.next .time b { color: var(--l35); }
.row.missed { background: var(--missed-bg); }
.row.missed, .row.missed .meta, .row.missed .status span { color: var(--missed-text); }
.row.missed .badge, .row.past .badge { background: var(--missed-text); }
.row.past { opacity: .55; }
.row.past .time b { text-decoration: line-through; font-weight: 600; }
.tag { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 999px; background: var(--line); color: var(--text); white-space: nowrap; }
.live { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--live); margin-inline-end: 5px; vertical-align: 1px; }
.hero .live { background: #fff; animation: pulse 1.6s ease-in-out infinite; }
.missed .live { background: var(--missed-text); animation: none; }
@keyframes pulse { 50% { opacity: .35; } }

/* messages */
.message { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 22px 18px; text-align: center; margin-top: 14px; }
.message h2 { margin: 0 0 6px; font-size: 19px; }
.message p { margin: 0 0 12px; color: var(--muted); }
.message .btns { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.message button { border: 0; border-radius: 10px; padding: 10px 16px; background: var(--l35); color: #fff; font-weight: 600; cursor: pointer; }
.message button.secondary { background: var(--soft); color: var(--text); border: 1px solid var(--line); }

footer { margin-top: 24px; }
