:root {
  --bg: #eef3f9; --card: #ffffff; --ink: #0f1b2d; --muted: #586579; --line: #e3e9f1;
  --accent: #1d4ed8; --accent-soft: #e6eefc; --sel: #ea580c;
  --obs: #1d4ed8; --cast: #3b82f6; --model: #4f6fa8;
  --radius: 16px; --shadow: 0 1px 2px rgba(15,27,45,.06), 0 4px 14px rgba(15,27,45,.06);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0b1220; --card: #141d2f; --ink: #e8eef8; --muted: #9aa8bc; --line: #24304a;
          --accent: #60a5fa; --accent-soft: #1b2a47; --sel: #fb923c; --obs: #60a5fa; --cast: #93c5fd; --model: #8fa8d6;
          --shadow: 0 1px 2px rgba(0,0,0,.4); }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 16px/1.45 Heebo, system-ui, -apple-system, "Segoe UI", Arial, sans-serif; background: var(--bg); color: var(--ink); }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--sel); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* ---- top bar ---- */
.topbar { position: sticky; top: 0; z-index: 1000; display: flex; align-items: center; gap: 4px;
  padding: 6px max(8px, calc((100% - 560px) / 2 + 10px)); padding-top: max(6px, env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(10px); }
.place-btn { flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; height: 44px; padding: 0 12px;
  border: 0; border-radius: 12px; background: var(--card); box-shadow: var(--shadow); font-weight: 700; font-size: 17px; text-align: start; }
.place-btn bdi { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.place-btn .caret { color: var(--muted); font-size: 14px; }
.icon-btn { width: 44px; height: 44px; flex: none; border: 0; border-radius: 12px; background: transparent; font-size: 22px; line-height: 1; color: var(--accent); }
.icon-btn:active { background: var(--accent-soft); }

main { max-width: 560px; margin: 0 auto; padding: 4px 10px 24px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
main > * { min-width: 0; }

/* ---- hero ---- */
.hero { border-radius: 20px; padding: 16px 16px 14px; box-shadow: var(--shadow); transition: background-color .3s; }
.hero.na    { background: linear-gradient(160deg, #f4f7fb, #e6edf6); }
.hero.dry   { background: linear-gradient(160deg, #fff8e1 0%, #e3efff 100%); }
.hero.maybe { background: linear-gradient(160deg, #fff1cc 0%, #dbe6f6 100%); }
.hero.wet   { background: linear-gradient(160deg, #1e3a8a 0%, #2563eb 100%); color: #fff; }
@media (prefers-color-scheme: dark) {
  .hero.na { background: linear-gradient(160deg, #1a2438, #121a2a); }
  .hero.dry { background: linear-gradient(160deg, #23324d, #14233d); }
  .hero.maybe { background: linear-gradient(160deg, #3a3220, #1c2638); }
}
.hero-top { display: flex; align-items: center; gap: 14px; }
.hero-icon { font-size: 58px; line-height: 1; flex: none; filter: drop-shadow(0 3px 6px rgba(0,0,0,.12)); }
.hero-main { min-width: 0; }
.hero-when { font-size: 14px; font-weight: 500; }
.hero-verdict { font-size: 34px; line-height: 1.1; margin: 2px 0 4px; font-weight: 800; letter-spacing: -.3px; }
.hero-nums { font-size: 17px; font-weight: 500; }
.hero-nums b { font-size: 22px; font-weight: 800; }
.hero-insight { margin: 12px 0 0; font-size: 15px; font-weight: 500; }
.hero-tip { display: inline-block; margin: 10px 0 0; padding: 5px 12px; border-radius: 999px; font-size: 15px; font-weight: 700; background: rgba(255,255,255,.65); }
.hero.wet .hero-tip { background: rgba(255,255,255,.18); }
@media (prefers-color-scheme: dark) { .hero-tip { background: rgba(255,255,255,.1); } }
.hero-insight:empty, .hero-method:empty, .hero-tip:empty { display: none; }
.hero-method { margin: 6px 0 0; font-size: 13px; color: var(--muted); }
.hero.wet .hero-method { color: #e3ebff; }
.hero .err-line { margin-top: 10px; font-size: 14px; }
.hero[aria-busy="true"] .hero-verdict, .hero[aria-busy="true"] .hero-icon { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }

/* ---- time chips ---- */
.time-chips { display: flex; gap: 6px; overflow-x: auto; scroll-padding-inline: 12px; scrollbar-width: none; margin: 0 -10px; padding: 2px 10px; scroll-snap-type: x proximity; }
.time-chips::-webkit-scrollbar { display: none; }
.chip { flex: none; display: inline-flex; align-items: center; gap: 4px; height: 40px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--card); font-size: 15px; font-weight: 500; white-space: nowrap; scroll-snap-align: start; }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip-pick { position: relative; cursor: pointer; }
.chip-pick input { position: absolute; inset: 0; opacity: 0; width: 100%; cursor: pointer; }

/* ---- cards ---- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px; }

/* ---- timeline ---- */
.tabs { display: flex; background: var(--bg); border-radius: 10px; padding: 3px; margin-bottom: 10px; }
.tab { flex: 1; height: 36px; border: 0; border-radius: 8px; background: transparent; font-size: 14px; font-weight: 500; color: var(--muted); }
.tab[aria-selected="true"] { background: var(--card); color: var(--ink); font-weight: 700; box-shadow: var(--shadow); }
.timeline { position: relative; }
.tl-scroll { overflow-x: auto; scrollbar-width: thin; padding-bottom: 2px; }
.bars { display: flex; align-items: flex-end; gap: 0; height: 96px; position: relative; }
.bar { flex: 1 0 auto; min-width: 12px; height: 100%; padding: 0 1px; border: 0; background: transparent; display: flex; flex-direction: column; justify-content: flex-end; align-items: stretch; position: relative; border-radius: 4px; }
.bar .fill { display: block; border-radius: 4px 4px 1px 1px; background: var(--obs); min-height: 3px; }
.bar.zero .fill { background: var(--line); opacity: 1 !important; }
.bar.cast .fill { background: repeating-linear-gradient(135deg, var(--cast) 0 4px, color-mix(in srgb, var(--cast) 70%, transparent) 4px 7px); }
.bar.model .fill { background: var(--model); }
.bar.sel { background: color-mix(in srgb, var(--sel) 14%, transparent); }
.bar.sel .fill { background: var(--sel) !important; opacity: 1 !important; }
.bar .pct { font-size: 10px; color: var(--muted); text-align: center; line-height: 1.2; }
.wide .bar { flex: 0 0 24px; }
.days.tl-scroll { overflow: hidden; }
.days .bar { flex: 1 1 0; min-width: 0; }
.days .axis span { flex: 1 1 0; }
.days .pct { font-size: 9px; letter-spacing: -.3px; white-space: nowrap; margin-inline: -4px; }
.axis { display: flex; gap: 0; font-size: 11px; color: var(--muted); margin-top: 3px; }
.axis span { flex: 1 0 auto; min-width: 10px; text-align: center; white-space: nowrap; overflow: visible; height: 15px; }
.wide .axis span { flex: 0 0 24px; }
.days .axis span { min-width: 0; line-height: 1.15; height: 28px; }
.now-line { position: absolute; top: 0; bottom: 0; width: 0; border-inline-start: 2px dashed var(--muted); opacity: .6; pointer-events: none; }
.now-line::after { content: "עכשיו"; position: absolute; top: -2px; inset-inline-start: 3px; font-size: 10px; color: var(--muted); white-space: nowrap; }
.legend { margin: 8px 0 0; font-size: 12px; color: var(--muted); }
.legend:empty { display: none; }
.tl-empty { color: var(--muted); font-size: 14px; padding: 24px 0; text-align: center; }

/* ---- map ---- */
.map-card { padding: 0; overflow: hidden; }
.map-wrap { position: relative; }
#map { height: 240px; background: #dfe7f0; }
.map-badge { position: absolute; top: 8px; left: 8px; z-index: 500; background: rgba(15,27,45,.78); color: #fff; font-size: 13px; padding: 3px 9px; border-radius: 999px; }
.pin-banner { position: absolute; inset-inline: 8px; bottom: 26px; z-index: 500; background: var(--sel); color: #fff; font-weight: 700; text-align: center; padding: 8px; border-radius: 10px; }
.map-actions { display: flex; gap: 8px; padding: 8px; }
.btn-soft { flex: 1; height: 40px; border: 0; border-radius: 10px; background: var(--accent-soft); color: var(--accent); font-weight: 500; font-size: 15px; }
.btn-soft[aria-pressed="true"] { background: var(--accent); color: #fff; }
.btn-primary { height: 44px; padding: 0 18px; border: 0; border-radius: 12px; background: var(--accent); color: #fff; font-weight: 700; }
.leaflet-container { font: inherit; }
.pinning #map { cursor: crosshair; }

/* ---- details ---- */
.details summary { cursor: pointer; font-weight: 700; padding: 4px 2px; list-style-position: inside; }
.details table { width: 100%; border-collapse: collapse; font-size: 14px; margin-top: 8px; font-variant-numeric: tabular-nums; }
.details th, .details td { text-align: start; padding: 7px 4px; border-bottom: 1px solid var(--line); }
.details th { color: var(--muted); font-weight: 500; font-size: 13px; }

.credits { font-size: 12px; color: var(--muted); text-align: center; padding: 4px 8px; }
.credits a { color: inherit; }

/* ---- sheet ---- */
.backdrop { position: fixed; inset: 0; background: rgba(8,15,30,.45); z-index: 2000; }
.sheet { position: fixed; inset-inline: 0; bottom: 0; z-index: 2001; max-height: 88vh; overflow-y: auto;
  background: var(--card); border-radius: 20px 20px 0 0; padding: 10px 14px calc(16px + env(safe-area-inset-bottom));
  box-shadow: 0 -8px 30px rgba(0,0,0,.2); max-width: 560px; margin: 0 auto; animation: up .2s ease-out; }
@keyframes up { from { transform: translateY(30px); opacity: 0; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; }
.sheet-head h2 { margin: 0; font-size: 20px; }
.search { display: flex; gap: 8px; margin: 8px 0; }
.search input { flex: 1; min-width: 0; height: 44px; padding: 0 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); }
.row-btn { width: 100%; display: flex; align-items: center; gap: 8px; height: 44px; padding: 0 10px; border: 0; border-radius: 12px; background: var(--accent-soft); color: var(--accent); font-weight: 500; }
.list { list-style: none; margin: 6px 0; padding: 0; }
.list li { display: flex; align-items: center; border-bottom: 1px solid var(--line); }
.list li > button.pick { flex: 1; min-width: 0; text-align: start; border: 0; background: transparent; padding: 11px 4px; min-height: 44px; }
.list .sub { display: block; font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .del { width: 44px; height: 44px; border: 0; background: transparent; color: var(--muted); font-size: 18px; }
.list .msg { padding: 10px 4px; color: var(--muted); font-size: 14px; border: 0; }
.list-title { font-size: 14px; color: var(--muted); margin: 14px 0 0; font-weight: 500; }
.sheet-hint { font-size: 12px; color: var(--muted); margin: 10px 0 0; }

/* ---- dialog ---- */
.dlg { border: 0; border-radius: 18px; padding: 18px; width: min(92vw, 380px); background: var(--card); color: var(--ink); box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.dlg::backdrop { background: rgba(8,15,30,.45); }
.dlg h2 { margin: 0 0 10px; font-size: 19px; }
.dlg label { font-size: 13px; color: var(--muted); }
.dlg input { width: 100%; height: 44px; padding: 0 12px; margin-top: 4px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); }
.quick-names { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0 14px; }
.dlg-actions { display: flex; gap: 8px; }
.dlg-actions button { flex: 1; }

/* ---- toast ---- */
.toast { position: fixed; bottom: calc(16px + env(safe-area-inset-bottom)); inset-inline: 16px; z-index: 3000; max-width: 480px; margin: 0 auto;
  background: #0f1b2d; color: #fff; border-radius: 12px; padding: 10px 14px; display: flex; align-items: center; justify-content: space-between; gap: 10px; box-shadow: 0 6px 20px rgba(0,0,0,.25); font-size: 15px; }
.toast button { border: 0; background: transparent; color: #93c5fd; font-weight: 700; min-height: 36px; }

.no-place .time-chips, .no-place .timeline-card, .no-place .map-card, .no-place .details { display: none; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
@media (min-width: 600px) { .time-chips { flex-wrap: wrap; overflow: visible; margin: 0; padding: 0; } }
@media (min-width: 700px) { #map { height: 300px; } .hero-verdict { font-size: 40px; } }
