:root{
  --bg:#f6f7f9; --panel:#ffffff; --ink:#0f1222; --muted:#6b7180; --line:#e6e8ee;
  --accent:#4f46e5; --accent-ink:#ffffff; --accent-soft:#eef0fe;
  --good:#16a085; --warn:#f39c12; --bad:#c0392b;
  --shadow:0 8px 30px rgba(15,18,34,.10); --shadow-sm:0 2px 10px rgba(15,18,34,.06);
  --r:14px;
}
*{box-sizing:border-box}
html,body{margin:0;height:100%;background:var(--bg);color:var(--ink);
  font-family:"Inter",-apple-system,system-ui,sans-serif;font-size:14px;line-height:1.5;overflow:hidden;
  -webkit-font-smoothing:antialiased}
h1,h2,h3,.brand{font-family:"Space Grotesk","Inter",sans-serif;letter-spacing:-.01em}
#map{position:fixed;inset:0;background:#e9ecf1}
.leaflet-container{background:#e9ecf1;font-family:inherit}
a{color:var(--accent);text-decoration:none} a:hover{text-decoration:underline}
.icon{width:16px;height:16px;stroke:currentColor;fill:none;stroke-width:1.9;stroke-linecap:round;stroke-linejoin:round;flex:none}

/* ---- left panel ---- */
.panel{position:fixed;top:16px;left:16px;z-index:600;width:352px;max-width:calc(100vw - 32px);
  max-height:calc(100vh - 32px);display:flex;flex-direction:column;
  background:var(--panel);border:1px solid var(--line);border-radius:var(--r);box-shadow:var(--shadow)}
.phead{display:flex;align-items:center;justify-content:space-between;padding:15px 17px 12px;flex:0 0 auto}
.brand{display:flex;align-items:center;gap:9px;font-size:16.5px;font-weight:700}
.brand .mark{width:26px;height:26px;border-radius:8px;background:var(--accent);color:#fff;display:flex;align-items:center;justify-content:center}
.brand .mark .icon{width:16px;height:16px;stroke-width:2.2}
.iconbtn{width:30px;height:30px;border:1px solid var(--line);background:#fbfbfd;border-radius:9px;color:var(--muted);
  display:flex;align-items:center;justify-content:center;cursor:pointer;padding:0}
.iconbtn:hover{background:#f2f3f7;color:var(--ink)}
.pbody{padding:0 17px 16px;overflow-y:auto;flex:1 1 auto}
.panel.collapsed .pbody{display:none}

.seg{display:flex;background:#f1f2f6;border-radius:11px;padding:3px;margin-bottom:14px}
.seg button{flex:1;border:0;background:transparent;padding:8px 6px;border-radius:8px;font-size:13px;font-weight:600;
  color:var(--muted);cursor:pointer;display:flex;align-items:center;justify-content:center;gap:6px}
.seg button.on{background:#fff;color:var(--ink);box-shadow:var(--shadow-sm)}
.appnav{display:flex;gap:5px;margin-bottom:14px;background:#f1f2f6;border-radius:11px;padding:3px}
.appnav a{flex:1;display:flex;align-items:center;justify-content:center;gap:5px;padding:8px 4px;border-radius:8px;font-size:12px;font-weight:600;color:var(--muted);text-decoration:none;white-space:nowrap}
.appnav a.on{background:#fff;color:var(--ink);box-shadow:var(--shadow-sm)}
.appnav a:hover:not(.on){color:var(--ink)}
.appnav a .icon{width:15px;height:15px}
.seg.small{margin-bottom:0}
.seg.small button{padding:7px 3px;font-size:12px;gap:4px}
.seg.small button .icon{width:15px;height:15px}
#deparr{flex:0 0 auto}
#deparr button{padding-left:9px;padding-right:9px}

.hint{font-size:12.5px;color:var(--muted);margin:-2px 0 12px}
label.fl{display:block;font-size:11.5px;font-weight:600;color:var(--muted);margin:11px 0 5px;text-transform:uppercase;letter-spacing:.03em}
.field{display:flex;align-items:center;gap:8px}
.field .dot{width:10px;height:10px;border-radius:50%;flex:none}
input,select{width:100%;padding:10px 12px;border:1px solid var(--line);border-radius:10px;font-size:14px;
  font-family:inherit;color:var(--ink);background:#fff}
input:focus,select:focus{outline:none;border-color:var(--accent);box-shadow:0 0 0 3px var(--accent-soft)}
input::placeholder{color:#a2a8b6}

.rows{display:flex;flex-direction:column;gap:7px}
.row{display:flex;align-items:center;gap:7px}
.row .del{width:34px;height:38px;flex:none;border:1px solid var(--line);background:#fbfbfd;border-radius:9px;color:var(--muted);cursor:pointer;display:flex;align-items:center;justify-content:center}
.row .del:hover{color:var(--bad);border-color:#f0c8c2}
.addrow{margin-top:7px;background:transparent;border:1px dashed #cfd4de;color:var(--accent);border-radius:10px;padding:8px;
  font-size:13px;font-weight:600;cursor:pointer;width:100%;display:flex;align-items:center;justify-content:center;gap:6px}
.addrow:hover{background:var(--accent-soft)}
.rowbtns{display:flex;flex-wrap:wrap;gap:8px}
.rowbtns .addrow{margin-top:7px;flex:1 1 auto;white-space:nowrap;padding-left:10px;padding-right:10px}
#pickbtn.on{background:var(--accent);color:#fff;border-style:solid;border-color:var(--accent)}
.acbox{position:fixed;z-index:1200;background:#fff;border:1px solid var(--line);border-radius:10px;
  box-shadow:var(--shadow);overflow:hidden;max-height:230px;overflow-y:auto}
.acitem{padding:9px 12px;font-size:13px;color:var(--ink);cursor:pointer;border-bottom:1px solid #f2f3f6;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.acitem:last-child{border-bottom:0}
.acitem:hover,.acitem.on{background:var(--accent-soft);color:var(--accent)}
.loops{display:flex;flex-direction:column;gap:6px;margin-top:10px}
.loops:empty{margin:0}
.loopcard{display:flex;flex-direction:column;align-items:flex-start;gap:1px;padding:10px 12px;border:1px solid var(--line);border-radius:10px;background:#fbfbfd;cursor:pointer;text-align:left;width:100%}
.loopcard:hover{border-color:var(--accent);background:var(--accent-soft)}
.loopcard b{font-family:"Space Grotesk";font-size:15px;color:var(--ink)}
.loopcard span{font-size:11.5px;color:var(--muted)}
.surfbar{margin-top:13px}
.sbar{display:flex;height:9px;border-radius:5px;overflow:hidden;background:#eef0f4}
.sbar span{display:block;height:100%}
.slabels{display:flex;flex-wrap:wrap;gap:9px;margin-top:6px;font-size:11px;color:var(--muted)}
.slabels i{display:inline-block;width:8px;height:8px;border-radius:2px;margin-right:4px}
.weatherbox{margin-top:13px}
.wxrow{font-size:13.5px}
.wxrow b{font-family:"Space Grotesk";font-size:17px}
.windarr{display:inline-block;color:var(--accent);font-weight:700}
.windmk{text-align:center;pointer-events:none}
.windarrow{line-height:1;font-weight:800;text-shadow:0 0 3px #fff,0 0 3px #fff,0 0 3px #fff}
.windspd{font-size:9px;color:#2a2f3a;font-weight:700;text-shadow:0 0 2px #fff,0 0 2px #fff;margin-top:-3px}
.wxwarn{margin-top:8px;background:var(--accent-soft);border:1px solid var(--accent);border-radius:8px;padding:7px 10px;font-size:12px;display:flex;align-items:center;gap:6px}
.wxwarn .icon{width:15px;height:15px;color:var(--accent);flex:none}
.livecount{font-family:"Space Grotesk";font-size:34px;font-weight:700;margin-bottom:0;line-height:1.1}
.livecount small{font-size:13px;color:var(--muted);font-weight:500;font-family:"Inter"}
.livefoot{font-size:11px;color:var(--muted);margin:16px 0 4px;line-height:1.5}
.cdot{display:inline-block;width:8px;height:8px;border-radius:50%;margin-right:5px;vertical-align:1px}
a.btn{text-decoration:none;display:flex;align-items:center;justify-content:center;gap:7px}
.recent{display:flex;flex-wrap:wrap;gap:5px;align-items:center;margin-top:8px}
.recent:empty{margin:0}
.rlab{font-size:11px;color:var(--muted);font-weight:600}
.rchip{font-size:11.5px;padding:4px 9px;border-radius:7px;border:1px solid var(--line);background:#fbfbfd;color:var(--ink);cursor:pointer;max-width:150px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.rchip:hover{border-color:var(--accent);color:var(--accent)}
.pricebadge{background:var(--accent-soft);border:1px solid var(--accent);border-radius:9px;padding:8px 11px;font-size:12.5px;margin-bottom:11px;line-height:1.4}
.pricebadge b{color:var(--accent);font-family:"Space Grotesk"}
.carcmp{color:#7a8496;font-weight:500;white-space:nowrap}
.carcmp .icon.car{width:13px;height:13px;vertical-align:-2px;margin-right:3px}
.routelookup{display:none;gap:6px;margin-top:9px}
.routelookup.on{display:flex}
.routelookup input{flex:1;min-width:0}
.routelookup button{flex:none;width:44px;padding:0;display:flex;align-items:center;justify-content:center}
.maphint{position:fixed;left:50%;bottom:26px;transform:translateX(-50%) translateY(6px);
  display:none;align-items:center;gap:8px;background:#fff;color:var(--ink);
  padding:9px 15px;border-radius:999px;box-shadow:var(--shadow);font-size:13px;font-weight:600;
  border:1px solid var(--line);pointer-events:none;z-index:600;opacity:0;transition:opacity .3s ease, transform .3s ease;white-space:nowrap}
.maphint.on{display:flex;opacity:1;transform:translateX(-50%) translateY(0)}
.maphint .icon{width:16px;height:16px;color:var(--accent);flex:none}
@media(max-width:560px){.maphint{font-size:11.5px;bottom:14px;max-width:94vw;white-space:normal;text-align:center}}

.chips{display:flex;flex-wrap:wrap;gap:6px}
.chip{font-size:12px;padding:6px 10px;border-radius:8px;border:1px solid var(--line);background:#fbfbfd;color:var(--ink);cursor:pointer;user-select:none}
.chip.off{opacity:.45}
.chip:hover{border-color:#c3c8d4}

.btn{width:100%;margin-top:14px;padding:12px;border:0;border-radius:11px;background:var(--accent);color:#fff;
  font-size:14.5px;font-weight:650;font-family:inherit;cursor:pointer;display:flex;align-items:center;justify-content:center;gap:8px}
.btn:hover{filter:brightness(1.05)} .btn:disabled{opacity:.55;cursor:default}
.btn.ghost{margin-top:8px;background:#fff;color:var(--ink);border:1px solid var(--line)}
.btn.ghost:hover{background:#f5f6f9;filter:none}

.status{font-size:12px;color:var(--muted);margin-top:11px;min-height:16px;display:flex;align-items:center;gap:7px}
.bar{height:4px;background:#eef0f4;border-radius:3px;overflow:hidden;margin-top:8px;display:none}
.bar.on{display:block} .bar>i{display:block;height:100%;width:0;background:var(--accent);transition:width .2s}

/* two-column time row */
.two{display:flex;gap:8px}.two>*{flex:1}

/* results (stats + budget) */
#results{display:none}
#results.on{display:block}
.metrics{margin-top:13px;display:grid;gap:8px;grid-template-columns:1fr 1fr 1fr}
.metric{background:#fbfbfd;border:1px solid var(--line);border-radius:11px;padding:10px 11px}
.metric .k{font-size:10.5px;color:var(--muted);font-weight:600;text-transform:uppercase;letter-spacing:.02em}
.metric .v{font-family:"Space Grotesk";font-size:19px;font-weight:700;margin-top:2px}
.metric .v small{font-size:11px;color:var(--muted);font-weight:500}
.slider{margin-top:12px;display:block}
.slider input[type=range]{padding:0;accent-color:var(--accent)}
.slider .lab{display:flex;justify-content:space-between;font-size:12px;color:var(--muted);margin-bottom:3px}

/* legend — slim strip inside the results panel */
.leg-in{margin-top:13px;border-top:1px solid var(--line);padding-top:11px;font-size:12px}
.leg-in .t{font-weight:600;color:var(--muted);margin-bottom:6px}
.leg-in .grad{height:8px;width:100%;border-radius:5px}
.leg-in .grad.time{background:linear-gradient(90deg,#16a085,#a8d84a,#f4d03f,#f39c12,#c0392b)}
.leg-in .ticks{display:flex;justify-content:space-between;color:var(--muted);margin-top:3px;font-size:11px}

/* route panel */
.routepanel{position:fixed;top:16px;right:16px;z-index:600;width:300px;max-width:calc(100vw - 32px);
  background:var(--panel);border:1px solid var(--line);border-radius:var(--r);box-shadow:var(--shadow);
  padding:15px 16px;display:none;max-height:calc(100vh - 32px);overflow:auto}
.routepanel.on{display:block}
.routepanel h3{margin:0 0 4px;font-size:14px}
.routepanel .addr{font-size:12px;color:var(--muted);margin-bottom:9px}
.trip{margin-bottom:13px}
.trip .tot{font-weight:700;font-size:14px;margin-bottom:6px;display:flex;align-items:center;gap:7px}
.trip .tot .swatch{width:9px;height:9px;border-radius:50%}
.leg{display:flex;align-items:center;gap:9px;font-size:12.5px;padding:3px 0;color:#41485a}
.leg .mode{width:22px;height:22px;border-radius:6px;display:flex;align-items:center;justify-content:center;color:#fff;flex:none}
.leg .mode .icon{width:13px;height:13px;stroke-width:2.2}
.leg .ln{font-weight:700;background:#eef0f4;border-radius:5px;padding:1px 7px}
.routepanel .cls{margin-top:6px;font-size:12.5px;color:var(--accent);cursor:pointer;display:inline-block}

.wp-label{font-family:"Inter";font-weight:600;font-size:11px;color:#12203a;background:#fff;border:1px solid var(--line);
  border-radius:6px;padding:2px 7px;box-shadow:var(--shadow-sm)}
.home-pin{color:var(--accent)}

@media (max-width:560px){
  .panel{width:calc(100vw - 20px);left:10px;top:10px}
  .routepanel{width:calc(100vw - 20px);left:10px;right:auto;top:auto;bottom:10px;max-height:46vh}
}
