/* Layout: planner column (search, preferences, alternatives) beside the map and the route sheet; one column on phones. */
:root {
  --bg: #f3f6f4; --surface: #ffffff; --sunken: #e3e9e6; --ink: #14201c; --muted: #586863; --rule: #d3dcd8;
  --accent: #0b6a4c; --accent-ink: #ffffff; --accent-soft: #d8ece4;
  --bus: #1d8a4e; --lrt: #c8243a; --rail: #1c5ba8; --taxi: #8a5a12; --walk: #7d8a85; --wait: #c98a00;
  --est-soft: #f5ecd6; --plan-soft: #e1ebf5; --warn-soft: #fbeedd; --warn-ink: #7a4a00;
  --font-display: "Rubik", "Heebo", "Arial Hebrew", sans-serif;
  --font-body: "IBM Plex Sans Hebrew", "Heebo", "Arial Hebrew", system-ui, sans-serif;
  --font-num: "IBM Plex Mono", ui-monospace, "SFMono-Regular", monospace;
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1412; --surface: #161f1c; --sunken: #1f2a26; --ink: #e6eeea; --muted: #97a8a2; --rule: #2b3833;
    --accent: #3cbf8c; --accent-ink: #06150f; --accent-soft: #173a2d;
    --bus: #3dbd74; --lrt: #ff5b6f; --rail: #5c9cf0; --taxi: #d9a24a; --walk: #8d9b96; --wait: #f0b62e;
    --est-soft: #3a3016; --plan-soft: #1a2a3d; --warn-soft: #3a2a10; --warn-ink: #f6c97a;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1412; --surface: #161f1c; --sunken: #1f2a26; --ink: #e6eeea; --muted: #97a8a2; --rule: #2b3833;
  --accent: #3cbf8c; --accent-ink: #06150f; --accent-soft: #173a2d;
  --bus: #3dbd74; --lrt: #ff5b6f; --rail: #5c9cf0; --taxi: #d9a24a; --walk: #8d9b96; --wait: #f0b62e;
  --est-soft: #3a3016; --plan-soft: #1a2a3d; --warn-soft: #3a2a10; --warn-ink: #f6c97a;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font-family: var(--font-body); font-size: 15px; line-height: 1.5; }
a { color: var(--accent); }
.app { max-width: 1280px; margin: 0 auto; padding-block: 16px 40px;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.num { font-family: var(--font-num); font-variant-numeric: tabular-nums; }

header.top { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 16px; margin-bottom: 14px; }
header.top h1 { font-family: var(--font-display); font-weight: 700; font-size: 1.5rem; margin: 0; }
header.top h1 .sub { font-weight: 500; font-size: 1rem; color: var(--muted); margin-inline-start: 6px; }
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 0.8rem; font-weight: 600; color: var(--accent); background: var(--accent-soft); border-radius: 999px; padding: 3px 10px; }
.badge.warn { color: var(--warn-ink); background: var(--warn-soft); }

.layout { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 980px) {
  .layout { grid-template-columns: minmax(360px, 440px) 1fr; align-items: start; }
  .side { position: sticky; top: 12px; max-height: calc(100vh - 24px); overflow: auto; }
}
.col { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.col > * { flex-shrink: 0; } /* the side column scrolls; its map and sheet keep their height */
.panel { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); padding: 16px; min-width: 0; }
.panel h2 { font-family: var(--font-display); font-weight: 500; font-size: 1rem; margin: 0 0 12px; }

/* search */
.od { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; }
.od-fields { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.field { display: grid; grid-template-columns: 30px 1fr; align-items: center; gap: 8px; }
.field .pin { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-weight: 600; font-size: 0.8rem; color: var(--accent-ink); background: var(--accent); }
.field .pin.to { background: var(--ink); color: var(--surface); }
.combo { position: relative; min-width: 0; }
input.place, select, input[type="time"] { font: inherit; color: var(--ink); background: var(--sunken); border: 1px solid transparent; border-radius: 8px; padding: 10px; width: 100%; min-width: 0; }
input.place::-webkit-search-cancel-button { cursor: pointer; }
select:focus-visible, input:focus-visible, button:focus-visible, summary:focus-visible, .route:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.suggest { position: absolute; inset-inline: 0; top: calc(100% + 4px); z-index: 1000; list-style: none; margin: 0; padding: 4px; background: var(--surface); border: 1px solid var(--rule); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.16); max-height: 320px; overflow: auto; }
.suggest li { display: grid; grid-template-columns: 22px 1fr; gap: 8px; align-items: center; padding: 8px; border-radius: 6px; cursor: pointer; }
.suggest li[aria-selected="true"], .suggest li:hover { background: var(--sunken); }
.suggest li svg { width: 18px; height: 18px; color: var(--muted); }
.suggest li .n { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.suggest li .d { font-size: 0.8rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.suggest li.info { display: block; color: var(--muted); font-size: 0.85rem; cursor: default; }
.swap { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--rule); background: var(--surface); color: var(--ink); cursor: pointer; display: grid; place-items: center; }
.swap:hover { background: var(--sunken); }
.when { display: grid; grid-template-columns: auto 1fr 1fr; gap: 8px; margin-top: 12px; align-items: center; }
@media (max-width: 440px) { .when { grid-template-columns: 1fr 1fr; } .when .seg { grid-column: 1 / -1; } }
.seg { display: inline-flex; background: var(--sunken); border-radius: 8px; padding: 3px; }
.seg button { font: inherit; font-size: 0.88rem; border: 0; background: transparent; color: var(--muted); padding: 6px 10px; border-radius: 6px; cursor: pointer; white-space: nowrap; flex: 1; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.12); }
.row-actions { display: flex; gap: 14px; margin-top: 10px; }
.link-btn { font: inherit; font-size: 0.85rem; border: 0; background: none; color: var(--accent); cursor: pointer; padding: 0; }

details.prefs summary { cursor: pointer; font-family: var(--font-display); font-weight: 500; list-style: none; display: flex; justify-content: space-between; align-items: center; }
details.prefs summary::-webkit-details-marker { display: none; }
details.prefs summary .hint { font-family: var(--font-body); font-size: 0.82rem; color: var(--muted); font-weight: 400; }
.pref-grid { display: grid; gap: 14px; margin-top: 14px; }
.pref-row .lbl { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 6px; }
.pref-row .seg { width: 100%; }

/* results */
.results-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin: 2px 2px 0; }
.results-head h2 { font-family: var(--font-display); font-weight: 500; font-size: 1rem; margin: 0; }
.results-head span { font-size: 0.82rem; color: var(--muted); }
.routes { display: flex; flex-direction: column; gap: 10px; }
.route { text-align: start; font: inherit; color: inherit; width: 100%; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); padding: 14px; cursor: pointer; display: flex; flex-direction: column; gap: 10px; }
.route:hover { border-color: var(--muted); }
.route[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.route .row1 { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.tags { display: flex; flex-wrap: wrap; gap: 5px; }
.tag { font-size: 0.75rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--sunken); color: var(--muted); }
.tag.rec { background: var(--accent); color: var(--accent-ink); }
.total { text-align: end; white-space: nowrap; }
.total .big { font-family: var(--font-num); font-weight: 600; font-size: 1.45rem; line-height: 1; }
.total .unit { font-size: 0.8rem; color: var(--muted); margin-inline-start: 2px; }
.times { font-size: 0.88rem; color: var(--muted); }
.times b { color: var(--ink); font-weight: 600; }
.bar { display: flex; height: 10px; border-radius: 5px; overflow: hidden; gap: 2px; }
.bar i { display: block; min-width: 3px; }
.bar i.walk, .bar i.transfer { background: repeating-linear-gradient(90deg, var(--walk) 0 4px, transparent 4px 7px); }
.bar i.wait { background: var(--wait); opacity: .55; }
.lines { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 0.85rem; color: var(--muted); }
.line-chip { display: inline-flex; align-items: center; gap: 4px; color: #fff; font-weight: 600; border-radius: 6px; padding: 1px 7px 1px 6px; font-size: 0.82rem; }
.line-chip svg { width: 14px; height: 14px; }
.why { font-size: 0.85rem; background: var(--accent-soft); border-radius: 6px; padding: 6px 10px; }
.conf { font-size: 0.8rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; }
.lvl { font-weight: 600; border-radius: 999px; padding: 0 7px; }
.lvl.high { background: var(--accent-soft); color: var(--accent); }
.lvl.medium { background: var(--est-soft); color: var(--warn-ink); }
.lvl.low { background: var(--warn-soft); color: var(--warn-ink); }
.live-note { color: var(--accent); font-weight: 600; }
.live-note.warn { color: var(--warn-ink); }

.notice { border-radius: var(--radius); padding: 16px; background: var(--warn-soft); display: flex; flex-direction: column; gap: 10px; }
.notice h3 { margin: 0; font-family: var(--font-display); font-weight: 500; font-size: 1.05rem; }
.notice p { margin: 0; }
.btn { font: inherit; font-weight: 600; border: 0; border-radius: 8px; padding: 9px 14px; background: var(--accent); color: var(--accent-ink); cursor: pointer; align-self: flex-start; }
.empty { color: var(--muted); font-size: 0.9rem; margin: 0; }
.loading { color: var(--muted); font-size: 0.9rem; }

/* map */
.map-wrap { border-radius: var(--radius); overflow: hidden; border: 1px solid var(--rule); background: var(--sunken); }
#map { height: 340px; width: 100%; }
@media (min-width: 980px) { #map { height: 420px; } }
.leaflet-container { font-family: var(--font-body); }
.map-pin { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 12px; border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.4); font-family: var(--font-body); }
.map-pin.from { background: #0b6a4c; color: #fff; }
.map-pin.to { background: #14201c; color: #fff; }
.map-pop { direction: rtl; text-align: right; font-family: var(--font-body); display: flex; flex-direction: column; gap: 6px; }
.map-pop button { font: inherit; font-weight: 600; border: 0; border-radius: 6px; padding: 6px 10px; background: #0b6a4c; color: #fff; cursor: pointer; }
.map-pop button.to { background: #14201c; }

/* sheet */
.sheet-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 6px 12px; margin-bottom: 6px; }
.sheet-head h2 { margin: 0; }
.leave { font-size: 0.9rem; }
.leave b { font-family: var(--font-num); font-size: 1.05rem; }
.steps { list-style: none; margin: 8px 0 0; padding: 0; }
.step { display: grid; grid-template-columns: 52px 28px 1fr; gap: 0 10px; }
.step .clock { font-family: var(--font-num); font-size: 0.85rem; padding-top: 10px; color: var(--muted); }
.step .rail { display: flex; flex-direction: column; align-items: center; }
.step .rail .dot { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; margin-top: 8px; flex: none; color: #fff; }
.step .rail .dot svg { width: 14px; height: 14px; }
.step .rail .stem { flex: 1; width: 3px; min-height: 12px; margin-top: 2px; border-radius: 2px; }
.step .rail .stem.walk { background: repeating-linear-gradient(180deg, var(--walk) 0 4px, transparent 4px 8px); }
.step .rail .stem.wait { background: var(--wait); opacity: .5; }
.step .body { padding: 8px 0 14px; border-bottom: 1px solid var(--rule); min-width: 0; }
.step:last-child .body { border-bottom: 0; }
.step .t { font-weight: 600; }
.step .s { font-size: 0.85rem; color: var(--muted); }
.step .meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 4px; }
.step details { font-size: 0.82rem; color: var(--muted); margin-top: 4px; }
.step details summary { cursor: pointer; color: var(--accent); }
.step details ol { margin: 4px 0 0; padding-inline-start: 18px; }
.dur { font-family: var(--font-num); font-size: 0.85rem; font-weight: 600; }
.src { font-size: 0.72rem; font-weight: 600; padding: 1px 7px; border-radius: 999px; }
.src.plan { background: var(--plan-soft); color: var(--rail); }
.src.est { background: var(--est-soft); color: var(--warn-ink); }
.src.calc { background: var(--sunken); color: var(--muted); }
.src.live { background: var(--accent-soft); color: var(--accent); }
.src.warn { background: var(--warn-soft); color: var(--warn-ink); }
.sumcheck { margin-top: 10px; font-size: 0.85rem; color: var(--muted); }
.legend { display: flex; flex-wrap: wrap; gap: 8px 14px; font-size: 0.8rem; color: var(--muted); margin-top: 12px; align-items: center; }

footer.note { margin-top: 24px; font-size: 0.82rem; color: var(--muted); max-width: 80ch; }
footer.note p { margin: 0 0 6px; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--surface); padding: 8px 16px; border-radius: 8px; font-size: 0.9rem; z-index: 2000; }
@media (prefers-reduced-motion: no-preference) { .route { transition: border-color .15s, box-shadow .15s; } }
