:root {
  --blue: #1a73e8; --text: #202124; --muted: #5f6368; --line: #e8eaed; --bg: #fff; --hover: #f1f3f4;
  --live: #188038; --late: #c5221f; --shadow: 0 2px 4px rgba(0,0,0,.2), 0 -1px 0 rgba(0,0,0,.02);
  --panel-w: 408px;
  font-family: "Segoe UI", Arial, "Noto Sans Hebrew", "Noto Sans", sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
#nogl { position: fixed; inset: 0; display: grid; place-items: center; text-align: center; padding: 80px 24px 24px; color: var(--muted); font-size: 15px; line-height: 1.6; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); overflow: hidden; }
#map { position: fixed; inset: 0; }
button { font: inherit; color: inherit; }
svg { width: 24px; height: 24px; fill: currentColor; }
.icon-btn { border: 0; background: none; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; cursor: pointer; color: var(--muted); flex: none; }
.icon-btn:hover { background: var(--hover); }

/* ------------------------------------------------ חיפוש */
#searchbox { position: fixed; top: 12px; right: 12px; z-index: 5; width: min(392px, calc(100vw - 24px)); background: var(--bg);
  border-radius: 24px; box-shadow: var(--shadow); display: flex; align-items: center; padding: 0 4px; height: 48px; }
#searchbox:focus-within, #searchbox.open { border-radius: 24px 24px 0 0; }
#searchbox:not(.open):focus-within { border-radius: 24px; }
#q { flex: 1; border: 0; outline: 0; font-size: 16px; height: 100%; background: none; color: var(--text); min-width: 0; padding: 0 4px; }
#q::-webkit-search-cancel-button { display: none; }
#results { position: absolute; top: 48px; right: 0; left: 0; margin: 0; padding: 0 0 8px; list-style: none; background: var(--bg);
  border-top: 1px solid var(--line); border-radius: 0 0 24px 24px; box-shadow: 0 4px 6px rgba(0,0,0,.2); max-height: 60vh; overflow-y: auto; }
#results li { display: flex; gap: 12px; align-items: center; padding: 8px 16px; cursor: pointer; min-height: 48px; }
#results li:hover, #results li.sel { background: var(--hover); }
#results .ri { width: 32px; height: 32px; border-radius: 50%; background: var(--hover); display: grid; place-items: center; flex: none; color: var(--muted); }
#results .ri svg { width: 18px; height: 18px; }
#results .rt { min-width: 0; }
#results .r1 { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#results .r2 { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#results .empty { color: var(--muted); cursor: default; }

/* ------------------------------------------------ לוח צד (מחשב) / גיליון תחתון (נייד) */
#panel { position: fixed; z-index: 4; background: var(--bg); display: flex; flex-direction: column; }
#panelBody { overflow-y: auto; flex: 1; overscroll-behavior: contain; }
#closePanel { position: absolute; top: 8px; left: 8px; z-index: 2; background: rgba(255,255,255,.9); }
#grab { display: none; }
@media (min-width: 760px) {
  #panel { top: 0; right: 0; bottom: 0; width: var(--panel-w); box-shadow: 0 0 20px rgba(0,0,0,.3); padding-top: 72px; }
  #closePanel { top: 80px; }
  body.has-panel .maplibregl-ctrl-bottom-right { margin-right: var(--panel-w); }
  body.has-panel #fabs { left: 12px; }
}
@media (max-width: 759.98px) {
  #panel { left: 0; right: 0; bottom: 0; height: 46vh; border-radius: 16px 16px 0 0; box-shadow: 0 -2px 12px rgba(0,0,0,.25); transition: height .2s; }
  #panel.full { height: calc(100vh - 72px); height: calc(100dvh - 72px); }
  #grab { display: flex; justify-content: center; padding: 8px 0 4px; cursor: grab; touch-action: none; }
  #grab span { width: 36px; height: 4px; border-radius: 2px; background: #dadce0; }
  body.has-panel #fabs { bottom: calc(46vh + 110px); }
  body.has-panel.panel-full #fabs { display: none; }
  body.has-panel .maplibregl-ctrl-bottom-left, body.has-panel .maplibregl-ctrl-bottom-right { bottom: 46vh; }
}

/* ------------------------------------------------ כותרת לוח */
.ph { padding: 16px 20px 12px 56px; border-bottom: 1px solid var(--line); }
.ph h1 { font-size: 22px; font-weight: 500; margin: 0 0 4px; line-height: 1.3; }
.ph .sub { color: var(--muted); font-size: 14px; display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; }
.ph .chips { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.chip { border: 1px solid #dadce0; background: var(--bg); color: var(--blue); border-radius: 18px; padding: 6px 14px; font-size: 14px; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; }
.chip:hover { background: #f6fafe; }
.chip svg { width: 18px; height: 18px; }
.section-t { font-size: 13px; color: var(--muted); padding: 14px 20px 6px; display: flex; justify-content: space-between; align-items: center; }
.updated { font-size: 12px; color: var(--muted); }

/* ------------------------------------------------ שורת קו בתחנה */
.dep { display: flex; gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--line); cursor: pointer; align-items: flex-start; }
.dep:hover { background: #f8f9fa; }
.badge { min-width: 44px; height: 28px; padding: 0 8px; border-radius: 6px; color: #fff; font-weight: 700; font-size: 15px; display: inline-grid; place-items: center; flex: none; direction: ltr; }
.badge.sm { min-width: 34px; height: 22px; font-size: 13px; border-radius: 4px; }
.dep .mid { flex: 1; min-width: 0; }
.dep .dest { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dep .ag { font-size: 12px; color: var(--muted); margin-top: 2px; }
.dep .times { text-align: left; flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; min-width: 76px; }
.t1 { font-size: 16px; font-weight: 500; display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.t1.live { color: var(--live); }
.t2 { font-size: 12px; color: var(--muted); white-space: nowrap; }
.late { color: var(--late); }
.livei { width: 14px; height: 14px; display: inline-block; position: relative; flex: none; }
.livei::before, .livei::after { content: ""; position: absolute; border: 2px solid var(--live); border-color: var(--live) var(--live) transparent transparent; border-radius: 0 100% 0 0; }
.livei::before { width: 6px; height: 6px; left: 2px; bottom: 2px; }
.livei::after { width: 11px; height: 11px; left: 0; bottom: 0; animation: blink 1.6s infinite; }
@keyframes blink { 50% { opacity: .25; } }
.skel { display: inline-block; width: 52px; height: 14px; background: linear-gradient(90deg, #eee, #f6f6f6, #eee); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: 4px; }
@keyframes sk { to { background-position: -200% 0; } }
.none { color: var(--muted); font-size: 13px; }

/* ------------------------------------------------ מסלול הקו */
.stops { list-style: none; margin: 0; padding: 8px 0 24px; }
.stops li { display: flex; align-items: stretch; gap: 14px; padding: 0 20px; cursor: pointer; min-height: 40px; }
.stops li:hover { background: #f8f9fa; }
.stops .rail { width: 14px; position: relative; flex: none; }
.stops .rail::before { content: ""; position: absolute; top: 0; bottom: 0; right: 5px; width: 4px; background: var(--c, var(--blue)); }
.stops li:first-child .rail::before { top: 50%; }
.stops li:last-child .rail::before { bottom: 50%; }
.stops .rail::after { content: ""; position: absolute; top: calc(50% - 6px); right: 1px; width: 8px; height: 8px; border-radius: 50%; background: #fff; border: 2px solid var(--c, var(--blue)); }
.stops li.cur .rail::after { width: 12px; height: 12px; top: calc(50% - 8px); right: -1px; background: var(--c); }
.stops .sn { padding: 10px 0; font-size: 14px; flex: 1; border-bottom: 1px solid #f1f3f4; }
.stops li.cur .sn { font-weight: 700; }
.stops .sc { color: var(--muted); font-size: 12px; margin-inline-start: 6px; }

.near { padding: 10px 20px; border-bottom: 1px solid var(--line); cursor: pointer; display: flex; gap: 12px; align-items: center; }
.near:hover { background: #f8f9fa; }
.near .nm { flex: 1; min-width: 0; }
.near .n1 { font-size: 15px; }
.near .n2 { font-size: 12px; color: var(--muted); margin-top: 3px; display: flex; gap: 4px; flex-wrap: wrap; }
.near .dist { color: var(--muted); font-size: 13px; flex: none; }
.stopi { width: 32px; height: 32px; border-radius: 50%; background: #e8f0fe; color: var(--blue); display: grid; place-items: center; flex: none; }
.stopi svg { width: 18px; height: 18px; }

.note { margin: 12px 20px; padding: 10px 12px; font-size: 13px; color: var(--muted); background: #f8f9fa; border-radius: 8px; line-height: 1.5; }
.foot { padding: 16px 20px 28px; font-size: 12px; color: var(--muted); line-height: 1.6; }

/* ------------------------------------------------ כפתורים צפים, הודעה */
#fabs { position: fixed; left: 12px; bottom: 120px; z-index: 3; display: flex; flex-direction: column; gap: 10px; }
.fab { width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--bg); box-shadow: var(--shadow); display: grid; place-items: center; cursor: pointer; color: var(--muted); }
.fab:hover { color: var(--text); }
.fab.on { color: var(--blue); }
#toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: #323232; color: #fff; padding: 10px 18px; border-radius: 6px; z-index: 9; font-size: 14px; max-width: 90vw; }
.maplibregl-ctrl-attrib { font-size: 11px; }
.maplibregl-ctrl-attrib a { color: #444; }
.maplibregl-popup-content { font-family: inherit; padding: 8px 12px; border-radius: 8px; font-size: 13px; }
.mypos { width: 18px; height: 18px; border-radius: 50%; background: var(--blue); border: 3px solid #fff; box-shadow: 0 0 0 6px rgba(26,115,232,.2), 0 1px 3px rgba(0,0,0,.4); }

/* ------------------------------------------------ תכנון מסלול */
.dirbtn { color: var(--blue); }
body.dir-mode #searchbox { display: none; }
@media (min-width: 760px) { body.dir-mode #panel { padding-top: 0; } }
.chip.primary { background: var(--blue); color: #fff; border-color: var(--blue); }
.chip.primary:hover { background: #1765cc; }
.dirform { position: relative; padding: 8px 12px 12px; border-bottom: 1px solid var(--line); background: var(--bg); }
.dir-head { display: flex; align-items: center; gap: 6px; font-size: 16px; padding-bottom: 6px; }
.dir-fields { display: flex; align-items: center; gap: 8px; }
.dir-dots { display: flex; flex-direction: column; align-items: center; gap: 3px; width: 18px; flex: none; }
.dir-dots span { width: 12px; height: 12px; border-radius: 50%; }
.dir-dots .o { border: 2.5px solid #202124; background: #fff; }
.dir-dots .d { background: #d93025; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); }
.dir-dots i { width: 3px; height: 3px; border-radius: 50%; background: #9aa0a6; }
.dir-inputs { flex: 1; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.dir-inputs input { height: 40px; border: 1px solid #dadce0; border-radius: 8px; padding: 0 12px; font: inherit; font-size: 15px; color: var(--text); background: #fff; outline: 0; min-width: 0; }
.dir-inputs input:focus { border-color: var(--blue); box-shadow: 0 0 0 1px var(--blue); }
.dir-time { display: flex; gap: 8px; margin: 10px 26px 0 48px; flex-wrap: wrap; }
.dir-time select, .dir-time input { font: inherit; font-size: 14px; color: var(--blue); border: 1px solid #dadce0; border-radius: 18px; padding: 5px 12px; background: #fff; }
.dsug { position: absolute; right: 38px; left: 50px; z-index: 6; margin: 0; padding: 4px 0; list-style: none; background: #fff; border-radius: 8px; box-shadow: 0 4px 16px rgba(0,0,0,.22); max-height: 50vh; overflow-y: auto; }
.dsug li { display: flex; gap: 10px; align-items: center; padding: 8px 12px; cursor: pointer; }
.dsug li:hover, .dsug li.sel { background: var(--hover); }
.dsug .ri { width: 28px; height: 28px; border-radius: 50%; background: var(--hover); display: grid; place-items: center; flex: none; color: var(--muted); }
.dsug .ri svg { width: 16px; height: 16px; }
.dsug .r1 { font-size: 14px; } .dsug .r2 { font-size: 12px; color: var(--muted); }
.dsug .rt { min-width: 0; }

.it { padding: 14px 20px; border-bottom: 1px solid var(--line); cursor: pointer; border-inline-start: 4px solid transparent; }
.it:hover { background: #f8f9fa; }
.it.on { border-inline-start-color: var(--blue); background: #f6fafe; }
.it.broken { opacity: .78; }
.it-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.it-time { font-size: 16px; font-weight: 500; direction: ltr; unicode-bidi: isolate; }
.it-dur { font-size: 16px; font-weight: 500; color: var(--text); white-space: nowrap; }
.it-top.big .it-time, .it-top.big .it-dur { font-size: 20px; }
.it-legs { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.it-legs .walk { display: inline-flex; align-items: flex-end; color: var(--muted); }
.it-legs .walk svg { width: 20px; height: 20px; }
.it-legs .walk small { font-size: 11px; margin-inline-start: -2px; }
.it-legs .sep { color: #9aa0a6; font-size: 14px; margin: 0 2px; }
.it-sub { font-size: 13px; color: var(--muted); margin-top: 6px; display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.lv { color: var(--live); }
.it-warn { font-size: 13px; color: var(--late); margin-top: 6px; }
.it-warn.soft { color: #b06000; }
.it-note { font-size: 13px; color: var(--blue); margin-top: 6px; }
.note.warn { background: #fce8e6; color: #a50e0e; }
.skel-it { display: flex; flex-direction: column; gap: 8px; cursor: default; }
.it-detail { padding: 12px 20px 8px; }
.it-detail .chip { margin-bottom: 12px; }
.tl { list-style: none; margin: 14px 0 0; padding: 0; }
.tl li { display: grid; grid-template-columns: 48px 18px 1fr; column-gap: 10px; align-items: stretch; }
.tl-t { font-size: 13px; color: var(--text); padding-top: 9px; text-align: left; direction: ltr; white-space: nowrap; }
.tl-x { padding: 8px 0; font-size: 14px; min-width: 0; }
.tl-x a { color: var(--text); text-decoration: none; font-weight: 500; }
.tl-x a:hover { text-decoration: underline; }
.tl-x .sc { color: var(--muted); }
.tl-x svg { width: 18px; height: 18px; vertical-align: -4px; color: var(--muted); }
.tl-meta { font-size: 12px; color: var(--muted); margin-top: 4px; display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.tl-dot { position: relative; }
.tl-dot::after { content: ""; position: absolute; top: 11px; right: 2px; width: 10px; height: 10px; border-radius: 50%; background: #fff; border: 2.5px solid var(--c, #202124); }
.tl-dot.d::after { background: #d93025; border-color: #d93025; }
.tl-line { position: relative; }
.tl-line::before { content: ""; position: absolute; top: 0; bottom: 0; right: 6px; width: 6px; border-radius: 3px; background: var(--c, #9aa0a6); }
.tl-line.walk::before { width: 0; right: 8px; border-right: 3px dotted #9aa0a6; background: none; }
.tl-bus .tl-x { padding: 10px 0 14px; }
.ctxpop .maplibregl-popup-content { padding: 4px 0; border-radius: 8px; }
.ctxmenu button { display: block; width: 100%; border: 0; background: none; padding: 8px 16px; text-align: right; cursor: pointer; font-size: 14px; }
.ctxmenu button:hover { background: var(--hover); }
