:root {
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
  --bg: #f5f5f7;
  --glass: rgba(255, 255, 255, 0.72);
  --glass-strong: rgba(255, 255, 255, 0.86);
  --glass-border: rgba(255, 255, 255, 0.6);
  --hairline: rgba(60, 60, 67, 0.14);
  --fill: rgba(120, 120, 128, 0.12);
  --fill-2: rgba(120, 120, 128, 0.2);
  --label: #1d1d1f;
  --label-2: rgba(60, 60, 67, 0.62);
  --label-3: rgba(60, 60, 67, 0.36);
  --accent: #007aff;
  --accent-press: #0062cc;
  --danger: #ff3b30;
  --green: #34c759;
  --seg-on: #ffffff;
  --shadow: 0 0 0 0.5px rgba(0, 0, 0, 0.06), 0 8px 32px rgba(0, 0, 0, 0.12), 0 2px 6px rgba(0, 0, 0, 0.05);
  --radius: 22px;
  --gap: 16px;
  --side: 372px;
  --side-space: calc(var(--side) + var(--gap));
  --ss: 1; /* stat card scale, set by layout.js */
  --elev-h: 196px;
  color-scheme: light;
}
body.side-collapsed { --side-space: 54px; }
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000;
    --glass: rgba(28, 28, 30, 0.7);
    --glass-strong: rgba(36, 36, 38, 0.88);
    --glass-border: rgba(255, 255, 255, 0.08);
    --hairline: rgba(84, 84, 88, 0.5);
    --fill: rgba(118, 118, 128, 0.24);
    --fill-2: rgba(118, 118, 128, 0.36);
    --label: #f5f5f7;
    --label-2: rgba(235, 235, 245, 0.6);
    --label-3: rgba(235, 235, 245, 0.3);
    --accent: #0a84ff;
    --accent-press: #409cff;
    --danger: #ff453a;
    --green: #30d158;
    --seg-on: #636366;
    --shadow: 0 0 0 0.5px rgba(255, 255, 255, 0.06), 0 10px 40px rgba(0, 0, 0, 0.5);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--label);
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
  letter-spacing: -0.01em;
  overflow: hidden;
}
button, input { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; }
svg { display: block; }
[hidden] { display: none !important; }

#map { position: fixed; inset: 0; }

.panel {
  background: var(--glass);
  -webkit-backdrop-filter: saturate(180%) blur(28px);
  backdrop-filter: saturate(180%) blur(28px);
  border: 0.5px solid var(--glass-border);
  box-shadow: var(--shadow);
  border-radius: var(--radius);
}

.subtle { color: var(--label-2); margin: 0; font-size: 13px; }

/* ---------- Sidebar ---------- */
.sidebar {
  position: fixed;
  top: var(--gap); left: var(--gap); bottom: var(--gap);
  width: var(--side);
  display: flex; flex-direction: column;
  overflow: hidden;
  z-index: 10;
  transition: transform .45s cubic-bezier(.2, .9, .3, 1);
}
body.side-collapsed .sidebar { transform: translateX(calc(-100% - var(--gap) - 12px)); pointer-events: none; }
.side-open { position: fixed; z-index: 9; top: var(--gap); left: var(--gap); display: none; }
body.side-collapsed .side-open { display: grid; animation: rise .4s cubic-bezier(.2, .9, .3, 1) both; }
.brand { display: flex; align-items: center; gap: 12px; padding: 20px 14px 14px 20px; }
.brand > div:not(.brand-icon) { flex: 1; min-width: 0; }
.collapse-btn { align-self: flex-start; margin-top: 2px; }

/* ---------- Resize handles ---------- */
.resizer { position: absolute; z-index: 4; touch-action: none; }
.resizer::after {
  content: ""; position: absolute; border-radius: 99px; background: var(--accent);
  opacity: 0; transition: opacity .15s;
}
.resizer:hover::after, .resizer.active::after { opacity: .9; }
.resizer-x { top: 18px; bottom: 18px; right: 0; width: 9px; cursor: col-resize; }
.resizer-x::after { top: 50%; right: 2px; width: 4px; height: 44px; transform: translateY(-50%); }
.resizer-y { left: 0; right: 0; height: 12px; cursor: row-resize; }
.resizer-y::after { left: 50%; top: 4px; width: 44px; height: 4px; transform: translateX(-50%); }
.resizer-y:not(.top) { bottom: -10px; }
.resizer-y.top { top: -2px; }
body.resizing, body.resizing * { user-select: none !important; transition: none !important; }
body.resizing.col { cursor: col-resize; }
body.resizing.row { cursor: row-resize; }
.brand-icon {
  width: 44px; height: 44px; border-radius: 11px; flex: none;
  background: linear-gradient(145deg, #5ac8fa 0%, #007aff 55%, #5856d6 100%);
  box-shadow: inset 0 0 0 0.5px rgba(255,255,255,.3), 0 4px 12px rgba(0,122,255,.35);
  display: grid; place-items: center;
}
.brand-icon svg { width: 30px; height: 30px; }
.brand h1 { font-size: 22px; font-weight: 700; letter-spacing: -0.025em; margin: 0 0 1px; }
.sheet-toggle { display: none; }

.sidebar-scroll { flex: 1; overflow-y: auto; padding: 4px 16px 16px; scrollbar-width: thin; }

.dropzone {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  padding: 26px 16px 22px;
  border-radius: 18px;
  border: 1.5px dashed var(--fill-2);
  background: var(--fill);
  cursor: pointer;
  transition: background .2s, border-color .2s, transform .2s;
}
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 9%, transparent); }
.dropzone:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 2px; }
.dropzone.compact { flex-direction: row; gap: 12px; padding: 12px 14px; text-align: left; }
.dropzone.compact .dz-icon { width: 34px; height: 34px; margin: 0; border-radius: 9px; }
.dropzone.compact .dz-icon svg { width: 18px; height: 18px; }
.dropzone.compact .dz-title { font-size: 14px; }
.dz-icon {
  width: 52px; height: 52px; border-radius: 14px; margin-bottom: 12px;
  display: grid; place-items: center;
  background: var(--accent); color: #fff;
  box-shadow: 0 4px 14px color-mix(in srgb, var(--accent) 40%, transparent);
}
.dz-icon svg { width: 26px; height: 26px; }
.dz-icon.big { width: 72px; height: 72px; border-radius: 20px; margin: 0 auto 16px; }
.dz-icon.big svg { width: 36px; height: 36px; }
.dz-title { font-weight: 600; font-size: 15px; }
.dz-sub { color: var(--label-2); font-size: 13px; margin-top: 2px; }
.dz-formats { color: var(--label-3); font-size: 11px; margin-top: 8px; letter-spacing: 0.01em; line-height: 1.5; }
.dropzone.compact .dz-formats { display: none; }
.fmt {
  display: inline-block; font-size: 9.5px; font-weight: 700; letter-spacing: 0.03em; line-height: 1;
  padding: 2px 5px 2px; border-radius: 5px; margin-right: 5px; vertical-align: 1px;
  background: color-mix(in srgb, var(--c) 16%, transparent); color: color-mix(in srgb, var(--c) 75%, var(--label));
}
.link { color: var(--accent); }

.text-btn {
  background: none; border: 0; padding: 8px 4px; color: var(--accent);
  font-size: 14px; font-weight: 500; border-radius: 8px;
}
.text-btn:hover { opacity: .75; }
.text-btn.small { font-size: 13px; padding: 4px 6px; }
.text-btn.danger { color: var(--danger); }

.group { margin-top: 22px; }
.group-head { display: flex; align-items: baseline; justify-content: space-between; padding: 0 4px 8px; }
.group-head h2 {
  font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.02em;
  color: var(--label-2); margin: 0; display: flex; align-items: center; gap: 6px;
}
.count {
  background: var(--fill-2); color: var(--label); border-radius: 99px;
  font-size: 11px; padding: 1px 7px; letter-spacing: 0; font-weight: 600;
}
.group-actions { display: flex; gap: 4px; }

.list {
  list-style: none; margin: 0; padding: 0;
  background: var(--glass-strong);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 0 0 0.5px var(--hairline);
}
.hint { font-size: 12px; color: var(--label-3); margin: 8px 6px 0; line-height: 1.4; }

/* Track rows */
.track {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 10px 10px 12px;
  position: relative;
  transition: background .15s, opacity .2s;
}
.track + .track::before, .row + .row::before {
  content: ""; position: absolute; top: 0; right: 0; left: 46px;
  border-top: 0.5px solid var(--hairline);
}
.row + .row::before { left: 14px; }
.track:hover { background: var(--fill); }
.track.dragging { opacity: .35; }
.track.drop-before { box-shadow: inset 0 2px 0 var(--accent); }
.track.drop-after { box-shadow: inset 0 -2px 0 var(--accent); }
.track.hidden-track .track-main { opacity: .4; }
.swatch {
  width: 22px; height: 22px; border-radius: 50%; flex: none; border: 0; padding: 0;
  background: var(--c);
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.55), 0 1px 3px rgba(0,0,0,.2);
  position: relative;
}
.swatch input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; border: 0; padding: 0; }
.track-main { flex: 1; min-width: 0; cursor: pointer; }
.track-name {
  font-weight: 500; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  border-radius: 5px; outline: none;
}
.track-name[contenteditable="true"] { background: var(--fill); padding: 0 4px; margin: 0 -4px; text-overflow: clip; }
.track-meta { font-size: 12px; color: var(--label-2); margin-top: 1px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.track-actions { display: flex; gap: 2px; opacity: .55; transition: opacity .15s; }
.track:hover .track-actions, .track:focus-within .track-actions { opacity: 1; }
.icon-sm {
  width: 28px; height: 28px; border-radius: 8px; border: 0; background: none;
  display: grid; place-items: center; color: var(--label-2);
}
.icon-sm:hover { background: var(--fill); color: var(--label); }
.icon-sm svg { width: 17px; height: 17px; }
.handle { cursor: grab; color: var(--label-3); }

/* Form rows */
.form .row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 46px; padding: 7px 12px 7px 14px; position: relative;
}
.form .row > span { white-space: nowrap; }
.form input[type="text"] {
  border: 0; background: none; text-align: right; color: var(--label-2);
  min-width: 0; flex: 1; outline: none; padding: 4px 0;
}
.form input[type="text"]:focus { color: var(--label); }

.segmented {
  display: inline-flex; background: var(--fill); border-radius: 9px; padding: 2px; gap: 0;
}
.segmented button {
  border: 0; background: none; padding: 5px 11px; font-size: 13px; font-weight: 500;
  border-radius: 7px; color: var(--label); white-space: nowrap;
  transition: background .2s, box-shadow .2s;
}
.segmented button:disabled { opacity: .35; cursor: not-allowed; }
.segmented button[aria-checked="true"] {
  background: var(--seg-on);
  box-shadow: 0 3px 8px rgba(0,0,0,.12), 0 0 0 0.5px rgba(0,0,0,.04);
  font-weight: 600;
}

.switch {
  appearance: none; -webkit-appearance: none; margin: 0;
  width: 51px; height: 31px; border-radius: 99px; background: var(--fill-2);
  position: relative; cursor: pointer; flex: none;
  transition: background .25s;
}
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%;
  background: #fff; box-shadow: 0 3px 8px rgba(0,0,0,.15), 0 1px 1px rgba(0,0,0,.16);
  transition: transform .25s cubic-bezier(.3, 1.3, .5, 1);
}
.switch:checked { background: var(--green); }
.switch:checked::after { transform: translateX(20px); }
.switch:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 2px; }

.sidebar-foot { padding: 14px 16px 16px; border-top: 0.5px solid var(--hairline); }
.primary {
  width: 100%; height: 50px; border: 0; border-radius: 14px;
  background: var(--accent); color: #fff; font-size: 16px; font-weight: 600;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: background .15s, transform .1s, opacity .2s;
}
.primary svg { width: 20px; height: 20px; }
.primary:hover { background: var(--accent-press); }
.primary:active { transform: scale(.98); }
.primary:disabled { opacity: .45; cursor: default; }
.primary.busy span::after { content: "…"; }
.privacy { display: flex; align-items: center; justify-content: center; gap: 5px; font-size: 12px; color: var(--label-2); margin: 10px 0 0; }
.privacy svg { width: 13px; height: 13px; }

/* ---------- Stats ---------- */
.stats-wrap {
  position: fixed; z-index: 5;
  top: var(--gap); left: calc(var(--gap) + var(--side-space)); right: var(--gap);
  pointer-events: none;
  transition: left .45s cubic-bezier(.2, .9, .3, 1);
}
.stats-wrap > * { pointer-events: auto; }
.stats {
  display: flex; gap: 10px;
  overflow-x: auto; scrollbar-width: none;
  padding-bottom: 4px;
}
.stats::-webkit-scrollbar { display: none; }
.stats-wrap:has(.stats[hidden]) .resizer-y { display: none; }
.stats-toggle {
  flex: none; width: 30px; border-radius: 14px; padding: 0; display: grid; place-items: center;
  color: var(--label-2);
}
.stats-toggle:hover, .stats-pill:hover { color: var(--label); background: var(--glass-strong); }
.stats-toggle svg { width: 18px; height: 18px; }
.stats-pill {
  display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 12px 0 16px;
  border-radius: 99px; font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums;
  animation: rise .35s cubic-bezier(.2, .9, .3, 1) both;
}
.stats-pill svg { width: 16px; height: 16px; color: var(--label-2); }
/* Compact two-row card: label on top, value with its footnote inline below. Scales with --ss. */
.stat {
  flex: 1 0 auto; min-width: calc(112px * var(--ss));
  padding: calc(7px * var(--ss)) calc(14px * var(--ss)) calc(8px * var(--ss)); border-radius: calc(10px + 4px * var(--ss));
  display: grid; grid-template-columns: auto 1fr; align-items: baseline; column-gap: 8px;
  animation: rise .5s cubic-bezier(.2, .9, .3, 1) both;
}
.stat .stat-label { grid-column: 1 / -1; }
.stat:nth-child(2) { animation-delay: .04s; } .stat:nth-child(3) { animation-delay: .08s; }
.stat:nth-child(4) { animation-delay: .12s; } .stat:nth-child(5) { animation-delay: .16s; } .stat:nth-child(6) { animation-delay: .2s; }
.stat.wide { flex: 2 0 calc(270px * var(--ss)); grid-template-columns: auto 1fr; grid-template-areas: "label legend" "share share"; align-items: center; }
.stat.wide .stat-label { grid-area: label; }
.stat.wide .share { grid-area: share; }
.stat.wide .share-legend { grid-area: legend; justify-content: flex-end; margin: 0; }
.stat-label { font-size: calc(8px + 3px * var(--ss)); font-weight: 500; color: var(--label-2); line-height: 1.3; white-space: nowrap; }
.stat-value { font-size: calc(19px * var(--ss)); font-weight: 700; letter-spacing: -0.025em; font-variant-numeric: tabular-nums; line-height: 1.2; white-space: nowrap; }
.stat-value small { font-size: calc(12px * var(--ss)); font-weight: 600; color: var(--label-2); margin-left: 2px; letter-spacing: -0.01em; }
.stat-foot { font-size: calc(8px + 3px * var(--ss)); color: var(--label-2); white-space: nowrap; font-variant-numeric: tabular-nums; }
.share { display: flex; height: calc(8px * var(--ss)); border-radius: 99px; overflow: hidden; margin-top: calc(8px * var(--ss)); gap: 2px; }
.share span { background: var(--c); min-width: 3px; transition: flex-grow .4s; }
.share-legend { display: flex; flex-wrap: nowrap; white-space: nowrap; gap: 8px; font-size: calc(8px + 3px * var(--ss)); color: var(--label-2); }
.share-legend i { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--c); margin-right: 5px; vertical-align: 1px; }

@keyframes rise { from { opacity: 0; transform: translateY(-8px) scale(.98); } }

/* ---------- Map controls ---------- */
.map-controls {
  position: fixed; z-index: 8; right: var(--gap); top: var(--gap); /* above stats/profile so the layer menu is never covered */
  display: flex; gap: 8px; align-items: center;
  transition: top .4s cubic-bezier(.2, .9, .3, 1);
}
body.has-data .map-controls { top: calc(var(--gap) + var(--stats-h, 0px)); }
.glassy { border-radius: 12px; padding: 3px; background: var(--glass-strong); }
.glassy button { padding: 6px 13px; }
/* Layer picker */
.layer-picker { position: relative; }
.layer-btn {
  height: 40px; border-radius: 12px; padding: 0 10px 0 12px; border: 0;
  display: flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 600; color: var(--label);
  background: var(--glass-strong);
}
.layer-btn svg { width: 19px; height: 19px; }
.layer-btn .chev { width: 15px; height: 15px; color: var(--label-2); transition: transform .25s; }
.layer-btn[aria-expanded="true"] .chev { transform: rotate(180deg); }
.layer-btn:hover { background: var(--glass-strong); filter: brightness(0.98); }
.layer-pop {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 20;
  width: 348px; max-height: calc(100vh - var(--stats-h, 0px) - 90px); overflow-y: auto;
  padding: 14px; border-radius: 20px; background: var(--glass-strong);
  transform-origin: top right; animation: pop .28s cubic-bezier(.2, 1.2, .4, 1) both;
  scrollbar-width: thin;
}
@keyframes pop { from { opacity: 0; transform: scale(.94) translateY(-6px); } }
.layer-pop h3 { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .02em; color: var(--label-2); margin: 0 2px 8px; }
.layer-pop section + section { margin-top: 14px; }
.layer-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.layer-card {
  position: relative; display: flex; flex-direction: column; align-items: stretch; gap: 2px; text-align: left;
  padding: 4px 4px 7px; border: 0; border-radius: 12px; background: transparent; min-width: 0;
}
.layer-card:hover { background: var(--fill); }
.layer-thumb {
  height: 58px; border-radius: 9px; background-size: cover; background-position: center;
  box-shadow: inset 0 0 0 0.5px rgba(0,0,0,.12); margin-bottom: 4px; transition: box-shadow .15s;
}
.layer-card.on .layer-thumb { box-shadow: 0 0 0 2.5px var(--accent), inset 0 0 0 0.5px rgba(0,0,0,.12); }
.layer-name { font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 2px; }
.layer-card.on .layer-name { color: var(--accent); }
.layer-note { font-size: 10.5px; color: var(--label-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 2px; }
.layer-del {
  position: absolute; top: 0; right: 0; width: 20px; height: 20px; border-radius: 50%;
  display: grid; place-items: center; font-size: 14px; line-height: 1;
  background: var(--glass-strong); color: var(--label-2); box-shadow: var(--shadow); opacity: 0; transition: opacity .15s;
}
.layer-card:hover .layer-del, .layer-del:focus { opacity: 1; }
.layer-del:hover { color: var(--danger); }
.layer-opts { margin-top: 14px; }
.custom-form { margin-top: 14px; }
.custom-form input {
  width: 100%; border: 0; border-radius: 10px; padding: 9px 11px; font-size: 13px; outline: none;
  background: var(--fill); color: var(--label);
}
.custom-form input:focus { box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 55%, transparent); }
.custom-row { display: flex; gap: 8px; align-items: center; margin-top: 6px; }
.custom-row .text-btn { flex: none; font-weight: 600; }
.custom-form code { font-size: 11px; background: var(--fill); padding: 0 3px; border-radius: 4px; }
@media (max-width: 760px) {
  .layer-pop { position: fixed; left: var(--gap); right: var(--gap); width: auto; top: calc(var(--gap) + var(--stats-h, 0px) + 54px); }
  .layer-btn span { display: none; }
}

.icon-btn { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; padding: 0; color: var(--label); }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn:hover { background: var(--glass-strong); }

/* ---------- Elevation ---------- */
.elevation {
  position: fixed; z-index: 5;
  left: calc(var(--gap) + var(--side-space)); right: var(--gap); bottom: var(--gap);
  height: var(--elev-h); padding: 12px 12px 10px 18px;
  display: flex; flex-direction: column;
  animation: up .5s cubic-bezier(.2, .9, .3, 1) both;
  transition: left .45s cubic-bezier(.2, .9, .3, 1);
}
.elevation.collapsed { height: auto; padding-bottom: 10px; border-radius: 16px; }
.elevation.collapsed .elev-chart, .elevation.collapsed .resizer { display: none; }
.elevation.collapsed #elevCollapse svg { transform: rotate(180deg); }
#elevCollapse svg { transition: transform .3s; }
@keyframes up { from { opacity: 0; transform: translateY(12px); } }
.elev-head { display: flex; align-items: center; gap: 12px; }
.elev-head h2 { font-size: 15px; font-weight: 600; margin: 0; flex: none; }
#elevReadout { flex: 1; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.elev-chart { margin-right: 6px; }
.elev-chart { flex: 1; position: relative; margin-top: 6px; cursor: crosshair; }
.elev-chart svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.elev-chart text { font-size: 10px; fill: var(--label-3); font-family: var(--font); font-variant-numeric: tabular-nums; }
.elev-grid { stroke: var(--hairline); stroke-width: 1; }
.elev-cursor { stroke: var(--label); stroke-width: 1; opacity: .5; }

/* ---------- Overlay + toasts ---------- */
.drop-overlay {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center;
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
.drop-overlay.show { opacity: 1; }
.drop-card {
  background: var(--glass-strong); border-radius: 28px; padding: 36px 48px; text-align: center;
  font-size: 17px; font-weight: 600; box-shadow: var(--shadow);
  transform: scale(.94); transition: transform .3s cubic-bezier(.3, 1.3, .5, 1);
}
.drop-overlay.show .drop-card { transform: none; }

.toasts { position: fixed; z-index: 60; left: 50%; bottom: 28px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  background: var(--glass-strong); -webkit-backdrop-filter: blur(24px); backdrop-filter: blur(24px);
  box-shadow: var(--shadow); border-radius: 99px; padding: 10px 18px; font-size: 13px; font-weight: 500;
  display: flex; align-items: center; gap: 8px; max-width: min(92vw, 480px);
  animation: toast .4s cubic-bezier(.3, 1.3, .5, 1) both;
}
.toast.out { opacity: 0; transform: translateY(8px); transition: all .3s; }
.toast .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); flex: none; }
.toast.error .dot { background: var(--danger); }
@keyframes toast { from { opacity: 0; transform: translateY(14px) scale(.96); } }

/* ---------- Map chrome ---------- */
.maplibregl-ctrl-attrib.maplibregl-compact { background: var(--glass) !important; border-radius: 12px; }
.maplibregl-ctrl-bottom-right { right: var(--gap); bottom: calc(var(--gap) + var(--elev-space, 0px)); transition: bottom .3s; }
.maplibregl-ctrl-group { background: var(--glass) !important; -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); border-radius: 12px !important; box-shadow: var(--shadow) !important; }
.maplibregl-ctrl-group button + button { border-top-color: var(--hairline) !important; }
@media (prefers-color-scheme: dark) {
  .maplibregl-ctrl-group .maplibregl-ctrl-icon { filter: invert(1); }
  .maplibregl-ctrl-attrib a { color: var(--label-2); }
}
.maplibregl-popup-content {
  background: var(--glass-strong); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
  border-radius: 14px; box-shadow: var(--shadow); padding: 10px 14px; font-family: var(--font); color: var(--label);
}
.maplibregl-popup-tip { display: none; }
.popup-title { font-weight: 600; font-size: 13px; }
.popup-sub { font-size: 12px; color: var(--label-2); font-variant-numeric: tabular-nums; }

/* ---------- Mobile: sidebar becomes a bottom sheet ---------- */
@media (max-width: 760px) {
  :root { --gap: 10px; }
  .sidebar {
    top: auto; left: 0; right: 0; bottom: 0; width: auto;
    max-height: 62vh; border-radius: 24px 24px 0 0;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .sidebar.collapsed { transform: translateY(calc(100% - 84px - env(safe-area-inset-bottom))); }
  .sheet-toggle {
    display: block; position: absolute; top: 0; left: 0; right: 0; height: 22px;
    background: none; border: 0;
  }
  .sheet-toggle span { display: block; width: 38px; height: 5px; border-radius: 99px; background: var(--fill-2); margin: 7px auto 0; }
  .brand { padding-top: 24px; }
  /* Desktop-only chrome: side collapse and resize handles. The sheet handles collapse on phones. */
  .collapse-btn, .side-open, .resizer { display: none !important; }
  body.side-collapsed .sidebar { transform: none; pointer-events: auto; }
  .stats-wrap { left: var(--gap); top: calc(var(--gap) + env(safe-area-inset-top)); }
  .stat { min-width: 100px; padding: 6px 12px 7px; }
  .stat-value { font-size: 17px; }
  .stat.wide { display: none; }
  body.has-data .map-controls { top: calc(var(--gap) + var(--stats-h, 0px) + env(safe-area-inset-top)); }
  .elevation { display: none; }
  .maplibregl-ctrl-bottom-right { display: none; }
}
.track.hl { background: color-mix(in srgb, var(--c) 12%, transparent); }

.group-actions { align-items: center; }
.vis-all { width: 26px; height: 26px; }

/* Merge selection mode: the route list itself becomes the picker. */
.pick-bar, .pick-foot, .track .check { display: none; }
body.picking .pick-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin: 0 0 8px; padding: 9px 10px 9px 14px; border-radius: 12px;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 30%, transparent);
  animation: rise .3s cubic-bezier(.2, .9, .3, 1) both;
}
.pick-bar-text { display: flex; flex-direction: column; min-width: 0; }
.pick-bar-text strong { font-size: 13px; font-weight: 600; color: var(--accent); }
.pick-bar-text span { font-size: 12px; color: var(--label-2); font-variant-numeric: tabular-nums; }
body.picking .track .check { display: grid; }
body.picking .track { cursor: pointer; }
body.picking .track-actions, body.picking .group-actions { display: none; }
body.picking #trackList { box-shadow: 0 0 0 1.5px color-mix(in srgb, var(--accent) 55%, transparent); }
body.picking .track:not(.unselected) { background: color-mix(in srgb, var(--accent) 7%, transparent); }
body.picking .track.unselected .track-main, body.picking .track.unselected .swatch { opacity: .38; }
body.picking .track + .track::before { left: 78px; }
body.picking .pick-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; }
body.picking .privacy { display: none; }
#pickSummary { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.check {
  appearance: none; -webkit-appearance: none; margin: 0; flex: none; cursor: pointer;
  width: 22px; height: 22px; border-radius: 50%;
  border: 1.5px solid var(--label-3); background: transparent;
  display: grid; place-items: center; transition: background .15s, border-color .15s;
}
.check::after {
  content: ""; width: 6px; height: 11px; margin-top: -2px;
  border: solid #fff; border-width: 0 2.2px 2.2px 0; transform: rotate(45deg) scale(0);
  transition: transform .2s cubic-bezier(.3, 1.4, .5, 1);
}
.check:checked { background: var(--accent); border-color: var(--accent); }
.check:checked::after { transform: rotate(45deg) scale(1); }
.check:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 2px; }
.day-row { margin-top: 10px; }
