:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --card: #f8f9fb;
  --text: #16181d;
  --muted: #6b7180;
  --line: #e3e6ec;
  --accent: #0a84ff;
  --accent-soft: #e5f1ff;
  --route: #33b3ff;
  --start: #1fae5b;
  --end: #e5484d;
  --via: #0a84ff;
  --warn: #ff9f0a;
  --shadow: 0 8px 30px rgba(15, 20, 30, .14);
  --radius: 12px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0e1014;
  --panel: #16191f;
  --card: #1d2129;
  --text: #eef0f4;
  --muted: #9097a6;
  --line: #2a2f39;
  --accent: #3d9bff;
  --accent-soft: #1a2a40;
  --shadow: 0 8px 30px rgba(0, 0, 0, .55);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  font: 14px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--text);
}
button { font: inherit; color: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
kbd { font: 11px ui-monospace, Menlo, monospace; padding: 1px 5px; border: 1px solid var(--line); border-radius: 4px; background: var(--card); }
.muted { color: var(--muted); }
.tiny { font-size: 11px; }
.row { display: flex; align-items: center; gap: 8px; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }

.app { display: grid; grid-template-columns: clamp(380px, 25vw, 480px) 1fr; height: 100vh; }

/* ---------- Panel ---------- */
.panel {
  display: flex; flex-direction: column; gap: 10px; padding: 14px;
  overflow-y: auto; background: var(--panel); border-right: 1px solid var(--line); z-index: 2;
}
.brand { display: flex; align-items: center; gap: 8px; }
.brand-text { margin-right: auto; }
.brand h1 { font-size: 17px; margin: 0; letter-spacing: -.01em; }
.brand p { margin: 0; color: var(--muted); font-size: 12px; }
.logo { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center;
  background: linear-gradient(135deg, #ff6a00, #ee0979); font-size: 19px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.card.grow { flex: 1 0 380px; display: flex; flex-direction: column; min-height: 380px; }

.btn { border: 1px solid var(--line); background: var(--panel); padding: 7px 11px; border-radius: 8px; white-space: nowrap; }
.btn:hover:not(:disabled) { border-color: var(--accent); }
.btn.ghost { background: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn:disabled { opacity: .45; cursor: default; }
.icon-btn { width: 32px; height: 32px; border-radius: 9px; border: 1px solid var(--line); background: var(--panel);
  display: grid; place-items: center; font-size: 15px; flex: none; }
.icon-btn:disabled { opacity: .35; cursor: default; }
.icon-btn.small { width: 24px; height: 24px; font-size: 11px; }

/* Waypoints */
.waypoints { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.wp { display: grid; grid-template-columns: 20px 1fr auto; align-items: center; gap: 6px; position: relative; }
.wp.dragging { opacity: .4; }
.wp.drop-before::before { content: ""; position: absolute; left: 26px; right: 0; top: -3px; height: 2px; background: var(--accent); }
.wp .dot { width: 14px; height: 14px; border-radius: 50%; border: 3px solid var(--via); background: var(--panel); cursor: grab; justify-self: center; }
.wp.start .dot { border-color: var(--start); }
.wp.end .dot { border-color: var(--end); background: var(--end); }
.wp.fuel .dot { border-color: var(--warn); }
.wp .field { position: relative; }
.wp input[type=text] { width: 100%; padding: 7px 9px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); outline: none; }
.wp input[type=text]:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.wp .acts { display: flex; gap: 2px; }
.wp .acts button { border: 0; background: none; color: var(--muted); padding: 3px 5px; border-radius: 6px; visibility: hidden; font-size: 12px; }
.wp:hover .acts button, .wp .acts button.on { visibility: visible; }
.wp .acts button:hover { background: var(--line); color: var(--text); }
.wp .acts button.on { color: var(--warn); }
.wp.shape .dot { width: 10px; height: 10px; border: 2px solid var(--muted); border-radius: 2px; transform: rotate(45deg); }
.wp.shape .label { color: var(--muted); font-size: 12px; padding: 2px 9px; cursor: pointer; }
.wp.shape .label:hover { color: var(--text); }
.wp-group { color: var(--muted); font-size: 12px; padding: 1px 0 1px 26px; cursor: pointer; user-select: none; list-style: none; }
.wp-group:hover { color: var(--text); }

.suggest { position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 20; list-style: none; margin: 0; padding: 4px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); max-height: 300px; overflow: auto; }
.suggest li { padding: 7px 9px; border-radius: 7px; cursor: pointer; }
.suggest li small { display: block; color: var(--muted); font-size: 12px; }
.suggest li.active, .suggest li:hover { background: var(--accent-soft); }

.wp-actions { display: flex; gap: 4px; margin-top: 8px; flex-wrap: wrap; }
.wp-actions .btn { padding: 6px 9px; }
.depart { display: grid; grid-template-columns: auto 1fr; gap: 6px 10px; align-items: center; margin-top: 8px; font-size: 13px; color: var(--muted); }
.depart input[type=datetime-local] { padding: 5px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
.check { display: flex; gap: 6px; align-items: center; cursor: pointer; }
.depart .check { grid-column: 1 / -1; color: var(--text); }

/* Moto options */
.modes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 3px; padding: 3px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; }
.modes button { border: 0; background: none; padding: 6px 0 5px; border-radius: 7px; font-size: 12px; line-height: 1.2; }
.modes button span { display: block; font-size: 16px; }
.modes button.active { background: var(--accent); color: #fff; }
.mode-hint { margin: 6px 2px 10px; font-size: 12px; color: var(--muted); min-height: 16px; }
.offroad-row { align-items: flex-start; gap: 12px; padding: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; }
.offroad-row input[type=range] { width: 100%; accent-color: #c08a4a; margin: 4px 0 0; }
.offroad-row.off .grow { opacity: .45; }
.switch { position: relative; width: 44px; height: 26px; flex: none; margin-top: 2px; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.slider-ui { position: absolute; inset: 0; background: var(--line); border-radius: 999px; transition: .2s; cursor: pointer; }
.slider-ui::before { content: ""; position: absolute; width: 20px; height: 20px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.switch input:checked + .slider-ui { background: #c08a4a; }
.switch input:checked + .slider-ui::before { transform: translateX(18px); }
.switch input:focus-visible + .slider-ui { outline: 2px solid var(--accent); outline-offset: 2px; }
.avoid { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 10px; font-size: 13px; }
.chip { cursor: pointer; }
.chip input { position: absolute; opacity: 0; width: 0; height: 0; }
.chip span { display: inline-block; padding: 4px 9px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel); }
.chip input:checked + span { border-color: var(--end); background: color-mix(in srgb, var(--end) 18%, var(--panel)); }
.chip input:focus-visible + span { outline: 2px solid var(--accent); }
.tank { margin-top: 10px; font-size: 13px; flex-wrap: wrap; }
.tank input[type=number] { width: 70px; padding: 4px 6px; border: 1px solid var(--line); border-radius: 7px; background: var(--panel); }
.tank input[type=number]:disabled { opacity: .45; }

/* Summary */
.alts { display: flex; gap: 6px; margin-bottom: 10px; flex-wrap: wrap; }
.alts button { flex: 1; min-width: 100px; text-align: left; border: 1px solid var(--line); background: var(--panel); border-radius: 9px; padding: 6px 9px; font-size: 12px; color: var(--muted); }
.alts button b { display: block; color: var(--text); font-size: 14px; }
.alts button .tag { color: var(--warn); }
.alts button.active { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px 6px; }
.stats .k { display: block; font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
.stats .v { font-size: 18px; font-weight: 650; letter-spacing: -.02em; white-space: nowrap; }
.fuel-warn { margin-top: 10px; padding: 8px 10px; border-radius: 9px; font-size: 13px;
  background: color-mix(in srgb, var(--warn) 16%, var(--panel)); border: 1px solid color-mix(in srgb, var(--warn) 50%, transparent); }
.fuel-warn button { margin: 4px 4px 0 0; padding: 3px 8px; font-size: 12px; }
.legs { margin-top: 8px; font-size: 12px; color: var(--muted); display: flex; flex-direction: column; gap: 2px; }
.legs div { display: flex; justify-content: space-between; gap: 8px; }
.legs span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 12px; }
.row-actions .btn { padding: 7px 2px; font-size: 13px; }

/* Tabs */
/* five tabs must fit the narrowest panel (380 px); if not, the bar scrolls instead of hiding a tab */
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--line); margin: -4px -4px 8px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { flex: 1 0 auto; border: 0; background: none; padding: 6px 3px; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; font-size: 13px; }
.tabs button.active { color: var(--text); border-bottom-color: var(--accent); }
.badge { display: inline-block; min-width: 16px; padding: 0 4px; border-radius: 9px; background: var(--line); font-size: 11px; text-align: center; }
.tab-body { overflow: auto; flex: 1; min-height: 0; }
.empty { color: var(--muted); padding: 12px 8px; margin: 0; font-size: 13px; }
.empty p { margin: 0; }
.empty ul { padding-left: 18px; margin: 6px 0 0; display: grid; gap: 4px; }

.steps { list-style: none; margin: 0; padding: 0; }
.steps li { display: grid; grid-template-columns: 26px 1fr auto; gap: 8px; align-items: start; padding: 6px; border-radius: 8px; cursor: pointer; }
.steps li:hover { background: var(--accent-soft); }
.steps .ico { font-size: 16px; text-align: center; }
.steps .d { color: var(--muted); font-size: 12px; white-space: nowrap; }
.steps li.leg-head { cursor: default; font-weight: 600; padding-top: 12px; grid-template-columns: 26px 1fr; }
.steps li.leg-head:hover { background: none; }

.poi-list, .saved { list-style: none; margin: 0; padding: 0; }
.poi-list li, .saved li { display: flex; align-items: center; gap: 8px; padding: 7px 6px; border-radius: 8px; }
.poi-list li:hover, .saved li:hover { background: var(--accent-soft); }
.poi-list .ico { font-size: 18px; width: 24px; text-align: center; }
.poi-list .meta, .saved .meta { flex: 1; cursor: pointer; min-width: 0; }
.poi-list .meta b, .saved .meta b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.poi-list .meta small, .saved .meta small { color: var(--muted); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.poi-list .km { color: var(--muted); font-size: 12px; white-space: nowrap; }
.poi-list button, .saved button { border: 0; background: none; color: var(--muted); }

/* ---------- Map ---------- */
.map-wrap { position: relative; overflow: hidden; }
#map { position: absolute; inset: 0; }
#map.tool-shape .maplibregl-canvas, #map.tool-poi .maplibregl-canvas { cursor: crosshair; }
#map.grab-route .maplibregl-canvas { cursor: grab; }
#map.dragging-route .maplibregl-canvas { cursor: grabbing; }

/* wraps instead of sliding under the zoom buttons in a narrow window; --tb-bottom (set from app.js) keeps
   the hint and the float panels just below it */
.toolbar { position: absolute; top: 12px; left: 12px; z-index: 3; display: flex; flex-wrap: wrap; gap: 4px; padding: 4px; max-width: calc(100% - 76px);
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); }
.toolbar .tool { width: 38px; height: 36px; border: 0; background: none; border-radius: 8px; font-size: 17px; }
.toolbar .tool:hover { background: var(--card); }
.toolbar .tool.active { background: var(--accent); color: #fff; }
.toolbar .sep { width: 1px; background: var(--line); margin: 4px 2px; }
.tool-hint { position: absolute; top: var(--tb-bottom, 62px); left: 12px; max-width: calc(100% - 76px); z-index: 3; background: var(--accent); color: #fff;
  padding: 6px 12px; border-radius: 8px; font-size: 13px; box-shadow: var(--shadow); }
.drag-tip { position: fixed; z-index: 30; pointer-events: none; background: rgba(0,0,0,.78); color: #fff; padding: 3px 8px; border-radius: 6px; font-size: 12px; }
/* right side: the left column belongs to the toolbar and the float panels */
.legend { position: absolute; right: 12px; bottom: 40px; z-index: 3; background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 10px; font-size: 12px; box-shadow: var(--shadow); display: grid; gap: 3px; }
.legend i { display: inline-block; width: 18px; height: 4px; border-radius: 2px; margin-right: 6px; vertical-align: middle; }
.map-wrap.with-elev .legend { bottom: 196px; }
.map-wrap.with-elev .float-panel { max-height: calc(100% - var(--tb-bottom, 62px) - 180px); }
.map-wrap.with-elev .maplibregl-ctrl-bottom-left, .map-wrap.with-elev .maplibregl-ctrl-bottom-right { bottom: 160px; }

.elev { position: absolute; left: 12px; right: 12px; bottom: 12px; height: 150px; z-index: 3;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 6px 10px 4px; }
.elev-head { display: flex; align-items: center; gap: 12px; font-size: 13px; }
.elev-head .icon-btn { margin-left: auto; }
.elev-chart { position: relative; height: 112px; }
.elev-chart svg { display: block; width: 100%; height: 100%; }
.elev-chart text { fill: var(--muted); font-size: 10px; }
.elev-chart .grid { stroke: var(--line); stroke-width: 1; }
.elev-chart .cursor { stroke: var(--text); stroke-width: 1; stroke-dasharray: 3 3; }
.elev-chart .dot { fill: #fff; stroke: var(--route); stroke-width: 2; }
.elev-tip { position: absolute; top: 0; background: var(--text); color: var(--panel); font-size: 11px; padding: 2px 6px; border-radius: 5px; pointer-events: none; white-space: nowrap; }

.loading, .toast { position: absolute; left: 50%; transform: translateX(-50%); z-index: 4; background: var(--panel); color: var(--text);
  border: 1px solid var(--line); border-radius: 999px; padding: 8px 16px; box-shadow: var(--shadow); font-size: 13px; }
.loading { top: 14px; }
.toast { bottom: 28px; }
.map-wrap.with-elev .toast { bottom: 180px; }

/* Markers */
.marker-wrap { width: 28px; height: 38px; cursor: grab; }
.marker { width: 28px; height: 28px; margin-top: 1px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg);
  background: var(--via); border: 3px solid #fff; box-shadow: 0 2px 8px rgba(0,0,0,.4); display: grid; place-items: center; }
.marker span { transform: rotate(45deg); color: #fff; font-weight: 700; font-size: 12px; }
.marker.start { background: var(--start); }
.marker.end { background: var(--end); }
.marker.fuel { background: var(--warn); }
.shape-pt { width: 14px; height: 14px; background: #fff; border: 3px solid #0b0d10; border-radius: 3px; transform: rotate(45deg);
  box-shadow: 0 1px 4px rgba(0,0,0,.5); cursor: grab; }
.shape-pt:hover { background: var(--route); }
.poi-pin { width: 32px; height: 32px; border-radius: 50%; background: var(--panel); border: 2px solid var(--warn);
  display: grid; place-items: center; font-size: 17px; box-shadow: 0 2px 8px rgba(0,0,0,.45); cursor: pointer; }
.poi-pin.danger, .poi-pin.police { border-color: var(--end); }
.fuel-alert { width: 30px; height: 30px; border-radius: 50%; background: var(--end); color: #fff; display: grid; place-items: center;
  font-size: 15px; border: 2px solid #fff; box-shadow: 0 0 0 4px rgba(229,72,77,.35); cursor: pointer; animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 9px rgba(229,72,77,0); } }
.station-pin { width: 26px; height: 26px; border-radius: 50%; background: #1fae5b; display: grid; place-items: center; font-size: 13px;
  border: 2px solid #fff; cursor: pointer; box-shadow: 0 2px 6px rgba(0,0,0,.4); }

/* Popups */
.maplibregl-popup-content { background: var(--panel); color: var(--text); border-radius: 12px; box-shadow: var(--shadow); padding: 12px; }
.maplibregl-popup-anchor-bottom .maplibregl-popup-tip, .maplibregl-popup-anchor-bottom-left .maplibregl-popup-tip, .maplibregl-popup-anchor-bottom-right .maplibregl-popup-tip { border-top-color: var(--panel); }
.maplibregl-popup-anchor-top .maplibregl-popup-tip, .maplibregl-popup-anchor-top-left .maplibregl-popup-tip, .maplibregl-popup-anchor-top-right .maplibregl-popup-tip { border-bottom-color: var(--panel); }
.maplibregl-popup-anchor-left .maplibregl-popup-tip { border-right-color: var(--panel); }
.maplibregl-popup-anchor-right .maplibregl-popup-tip { border-left-color: var(--panel); }
.maplibregl-popup-close-button { color: var(--muted); font-size: 18px; padding: 0 6px; }
.poi-form { width: 280px; display: grid; gap: 8px; }
.poi-types { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.poi-types button { border: 1px solid var(--line); background: var(--card); border-radius: 7px; font-size: 16px; padding: 3px 0; }
.poi-types button.active { border-color: var(--accent); background: var(--accent-soft); }
.poi-form .type-label { font-size: 12px; color: var(--muted); }
.poi-form input, .poi-form textarea { width: 100%; padding: 6px 8px; border: 1px solid var(--line); border-radius: 7px; background: var(--card); }
.poi-form textarea { resize: vertical; min-height: 54px; }
.poi-form .row { flex-wrap: wrap; gap: 5px; }
.poi-form .row .btn { padding: 5px 8px; font-size: 12px; }
.pop-title { font-weight: 600; margin-bottom: 6px; padding-right: 16px; }
.pop-list { display: grid; gap: 4px; max-height: 220px; overflow: auto; min-width: 220px; }
.pop-list button { text-align: left; border: 1px solid var(--line); background: var(--card); border-radius: 7px; padding: 5px 8px; font-size: 12px; }
.pop-list button:hover { border-color: var(--accent); }

/* Context menu */
.ctx { position: fixed; z-index: 50; min-width: 230px; padding: 5px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); }
.ctx button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 7px 10px; border-radius: 7px; }
.ctx button:hover { background: var(--accent-soft); }
.ctx hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }

dialog { border: 1px solid var(--line); border-radius: 16px; background: var(--panel); color: var(--text); box-shadow: var(--shadow); padding: 20px; max-width: 480px; width: calc(100% - 32px); }
dialog::backdrop { background: rgba(0,0,0,.45); }
dialog h2 { margin: 0 0 12px; font-size: 17px; }
/* buttons stay visible when a long dialog (help, ride import) scrolls in a low window */
dialog menu { position: sticky; bottom: -20px; padding: 10px 0 0; margin: 16px 0 0; display: flex; justify-content: flex-end; gap: 8px; background: var(--panel); }
dialog input[type=text] { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); }
#qr { display: grid; place-items: center; padding: 14px; background: #fff; border-radius: 12px; margin: 10px 0; }

@media (min-width: 2200px) { body { font-size: 15px; } .stats .v { font-size: 22px; } }
@media (max-width: 800px) {
  .app { grid-template-columns: 1fr; height: auto; }
  .panel { overflow: visible; border-right: 0; }
  .map-wrap { height: 65vh; order: -1; }
}

/* ---------- Ride plan, weather, roads ---------- */
.alerts { display: grid; gap: 4px; margin-top: 10px; }
.alerts:empty { display: none; }
.alert { display: flex; gap: 8px; align-items: flex-start; font-size: 12.5px; padding: 5px 8px; border-radius: 8px;
  background: var(--panel); border: 1px solid var(--line); cursor: pointer; }
.alert:hover { border-color: var(--accent); }
.alert.l2 { border-color: color-mix(in srgb, var(--end) 60%, transparent); background: color-mix(in srgb, var(--end) 12%, var(--panel)); }
.alert .i { font-size: 15px; line-height: 1.1; }
.ride-opts { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: 12.5px; color: var(--muted); padding: 2px 2px 10px; border-bottom: 1px solid var(--line); margin-bottom: 8px; }
.ride-opts input { width: 54px; padding: 3px 5px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); }
h3.sec { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 14px 2px 6px; }
.day { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; margin-bottom: 8px; background: var(--panel); }
.day-head { display: flex; justify-content: space-between; gap: 8px; font-weight: 600; }
.day-head span { color: var(--muted); font-weight: 400; font-size: 12px; }
.day ol { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 2px; font-size: 12.5px; }
.day li { display: grid; grid-template-columns: 22px 44px 1fr auto; gap: 6px; align-items: center; padding: 3px 4px; border-radius: 6px; cursor: pointer; }
.day li:hover { background: var(--accent-soft); }
.day li .t { color: var(--muted); font-variant-numeric: tabular-nums; }
.day li .km { color: var(--muted); font-size: 11.5px; white-space: nowrap; }
.day li .btn { padding: 2px 7px; font-size: 11.5px; }
.wx-strip { display: flex; gap: 2px; overflow-x: auto; padding-bottom: 4px; }
.wx { flex: 1 0 44px; text-align: center; font-size: 11px; padding: 4px 2px; border-radius: 7px; background: var(--panel); border: 1px solid var(--line); cursor: pointer; }
.wx:hover { border-color: var(--accent); }
.wx .e { font-size: 17px; display: block; }
.wx .tp { font-weight: 650; font-size: 12px; }
.wx .rn { color: #3d9bff; }
.wx.wet { background: color-mix(in srgb, #3d9bff 16%, var(--panel)); }
.wx .km { color: var(--muted); display: block; }
.wx-note { font-size: 12px; color: var(--muted); margin: 6px 2px 0; }
.bar { display: flex; height: 12px; border-radius: 6px; overflow: hidden; margin: 4px 0 6px; background: var(--line); }
.bar i { display: block; height: 100%; }
.bar-legend { display: grid; grid-template-columns: 1fr auto; gap: 1px 10px; font-size: 12px; margin-bottom: 10px; }
.bar-legend span:nth-child(odd) i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 6px; }
.bar-legend span:nth-child(even) { color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.ride-pin { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; background: var(--panel);
  border: 2px solid var(--muted); box-shadow: 0 1px 5px rgba(0,0,0,.45); cursor: pointer; }
.ride-pin.night { width: 28px; height: 28px; border-color: #b26bff; font-size: 15px; }
.wx-pin { font-size: 20px; filter: drop-shadow(0 1px 2px rgba(0,0,0,.7)); cursor: pointer; }
.lodge-pin { width: 26px; height: 26px; border-radius: 50%; background: #b26bff; display: grid; place-items: center; font-size: 13px; border: 2px solid #fff; cursor: pointer; }

/* Loop generator */
.float-panel { position: absolute; top: var(--tb-bottom, 62px); left: 12px; z-index: 4; width: min(340px, calc(100% - 76px)); max-height: calc(100% - var(--tb-bottom, 62px) - 28px); overflow: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 10px 12px; }
.fp-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.loop-form { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 8px; margin: 8px 0; font-size: 12.5px; }
.loop-form label { display: grid; gap: 2px; color: var(--muted); }
.loop-form select { padding: 5px; border: 1px solid var(--line); border-radius: 7px; background: var(--card); }
.loop-form .btn { align-self: end; }
.loop-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.loop-list li { border: 2px solid var(--line); border-radius: 10px; padding: 7px 9px; cursor: pointer; display: grid; grid-template-columns: 14px 1fr auto; gap: 8px; align-items: center; }
.loop-list li:hover, .loop-list li.hot { border-color: var(--accent); }
.loop-list .sw { width: 14px; height: 14px; border-radius: 4px; }
.loop-list b { display: block; }
.loop-list small { color: var(--muted); }
.loop-list .btn { padding: 4px 9px; font-size: 12px; }
#map.tool-avoid .maplibregl-canvas { cursor: crosshair; }
.help-grid { display: grid; grid-template-columns: auto 1fr; gap: 5px 14px; font-size: 13px; }
.help-grid kbd { justify-self: start; }
.ride-opts input[type=time] { width: 84px; }

/* ---------- Ridden trips ---------- */
.row.wrap { flex-wrap: wrap; }
.rides-summary { font-size: 12.5px; color: var(--muted); margin: 0 2px 6px; }
.rides-summary b { color: var(--text); }
.rides { list-style: none; margin: 6px 0 0; padding: 0; }
.rides li { display: grid; grid-template-columns: 14px 1fr auto; gap: 8px; align-items: center; padding: 7px 6px; border-radius: 8px; }
.rides li:hover, .rides li.hot { background: var(--accent-soft); }
.rides li.off { opacity: .5; }
.rides .sw { width: 12px; height: 12px; border-radius: 50%; background: #ff4fd8; }
.rides .meta { cursor: pointer; min-width: 0; }
.rides .meta b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rides .meta small { color: var(--muted); display: block; }
.rides .acts { display: flex; gap: 2px; }
.rides .acts button { border: 0; background: none; color: var(--muted); padding: 3px 5px; border-radius: 6px; }
.rides .acts button:hover { background: var(--line); color: var(--text); }
.novelty-line { margin-top: 8px; font-size: 12.5px; display: flex; align-items: center; gap: 8px; }
.novelty-line .bar { flex: 1; margin: 0; height: 8px; }
.loop-new { grid-column: 1 / -1; color: var(--text) !important; display: flex !important; }
.ride-pop { min-width: 240px; }
.ride-pop small { color: var(--muted); display: block; margin-bottom: 8px; }
.ride-pop .row { flex-wrap: wrap; gap: 5px; }
.ride-pop .btn { padding: 5px 8px; font-size: 12px; }
#map.tool-pick .maplibregl-canvas { cursor: crosshair; }

/* ---------- Itinerary ---------- */
.itin-head { display: grid; gap: 6px; margin-bottom: 10px; }
.itin-head input, .itin-head textarea, .stop-form input, .stop-form textarea, .day-notes textarea, .day-title {
  width: 100%; padding: 6px 8px; border: 1px solid var(--line); border-radius: 7px; background: var(--panel); }
.itin-title { font-size: 15px; font-weight: 650; }
.itin-head textarea, .day-notes textarea, .stop-form textarea { resize: vertical; min-height: 40px; }
.itin-total { font-size: 12.5px; color: var(--muted); }
.itin-total b { color: var(--text); }
.day-title { font-weight: 600; margin: 4px 0 2px; border-color: transparent; background: transparent; padding: 3px 4px; }
.day-title:hover, .day-title:focus { border-color: var(--line); background: var(--panel); }
.day li.has-form { grid-template-columns: 22px 66px 1fr auto; }
.day li .t2 { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 11.5px; }
.day li .xp { border: 0; background: none; color: var(--muted); padding: 3px 6px; font-size: 13px; min-width: 24px; min-height: 24px; }
.day li .sub { grid-column: 3 / -1; color: var(--muted); font-size: 11.5px; white-space: pre-line; }
.stop-form { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; gap: 5px 8px; padding: 8px; margin: 2px 0 6px;
  background: var(--card); border: 1px solid var(--line); border-radius: 8px; font-size: 12px; cursor: default; }
.stop-form label { display: grid; gap: 2px; color: var(--muted); }
.stop-form .full { grid-column: 1 / -1; }
.stop-form h4 { grid-column: 1 / -1; margin: 6px 0 0; font-size: 12px; }
.day-notes { margin-top: 6px; }
.day-notes summary { cursor: pointer; font-size: 12px; color: var(--muted); }
.day-cost { margin-top: 6px; font-size: 12px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 10px; }
.day-cost b { color: var(--text); }
.checklist { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; font-size: 13px; }
.checklist li { display: flex; align-items: center; gap: 8px; padding: 3px 4px; border-radius: 6px; }
.checklist li:hover { background: var(--accent-soft); }
.checklist li.done span { color: var(--muted); text-decoration: line-through; }
.checklist li span { flex: 1; }
.checklist li button { border: 0; background: none; color: var(--muted); visibility: hidden; }
.checklist li:hover button { visibility: visible; }
.checklist .add input { flex: 1; padding: 4px 7px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); }
.modes.vehicles { grid-template-columns: repeat(2, 1fr); margin-bottom: 6px; }
.modes.vehicles button { display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 13px; padding: 5px 0; }
.modes.vehicles button span { display: inline; font-size: 15px; }
.routing-src { display: block; width: 100%; margin-top: 10px; text-align: left; border: 0; background: none; padding: 2px; font-size: 11.5px; color: var(--muted); }
.routing-src.local { color: var(--start); }

/* long unbroken notes / URLs must not push the panel wider */
.day li .nm, .day li .sub, .poi-list .meta, .alert span, .stop-form, .itin-total { overflow-wrap: anywhere; }
.poi-pin.mark { width: 26px; height: 26px; font-size: 14px; border-color: #ff4fd8; }
.routing { margin-top: 10px; display: grid; gap: 4px; font-size: 12.5px; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; padding: 3px; background: var(--panel); border: 1px solid var(--line); border-radius: 9px; }
.seg button { border: 0; background: none; padding: 5px 0; border-radius: 6px; font-size: 12px; }
.seg button.active { background: var(--accent); color: #fff; }
.seg button:disabled { opacity: .5; }
.routing .routing-src { margin-top: 0; }
dialog code { background: var(--card); padding: 1px 5px; border-radius: 4px; font-size: 12px; }

/* instant tooltips for icon buttons */
.tip { position: fixed; z-index: 100; max-width: 260px; padding: 5px 9px; border-radius: 7px; font-size: 12px; line-height: 1.35;
  background: var(--text); color: var(--panel); box-shadow: var(--shadow); pointer-events: none; white-space: normal; }

/* ---------- Base map picker ---------- */
.basemap-panel { width: min(318px, calc(100% - 76px)); }
.basemap-list { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 8px 0; }
.basemap { display: grid; gap: 2px; padding: 5px; border: 2px solid transparent; border-radius: 10px; background: var(--card); text-align: left; color: var(--text); cursor: pointer; }
.basemap:hover { border-color: var(--line); }
.basemap.active { border-color: var(--accent); }
.basemap img { width: 100%; height: auto; aspect-ratio: 132 / 84; object-fit: cover; border-radius: 6px; background: var(--line); display: block; margin-bottom: 3px; }
.basemap b { font-size: 13px; }
.basemap span { font-size: 11px; color: var(--muted); line-height: 1.25; }
