:root {
  --brand: #0b7a5f;
  --brand-ink: #075744;
  --brand-soft: #e3f4ee;
  --accent: #ff5a36;
  --start: #0b7a5f;
  --end: #e5484d;
  --via: #3b5bdb;
  --bg: #ffffff;
  --bg-2: #f5f6f4;
  --bg-3: #eceee9;
  --ink: #17201c;
  --ink-2: #4a5550;
  --ink-3: #7c8781;
  --line: #e1e4df;
  --shadow: 0 1px 2px rgba(16, 24, 20, .06), 0 6px 20px rgba(16, 24, 20, .10);
  --radius: 12px;
  --c-pcn: #16a34a;
  --c-cycle: #2563eb;
  --c-road: #e8590c;
  --c-major: #c92a2a;
  --c-pavement: #8b97a3;
  --c-trail: #a16207;
  --c-steps: #7c3aed;
  --c-dismount: #db2777;
  --c-ferry: #0891b2;
  --panel-w: 400px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --brand: #34c69a;
    --brand-ink: #7be0c0;
    --brand-soft: #123a30;
    --bg: #141a18;
    --bg-2: #1b2320;
    --bg-3: #24302b;
    --ink: #e9efec;
    --ink-2: #b2bdb8;
    --ink-3: #85918b;
    --line: #2c3833;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  font: 14px/1.45 "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
svg:not(.leaflet-zoom-animated) { width: 18px; height: 18px; flex: none; }
a { color: var(--brand); }

#app { position: fixed; inset: 0; display: flex; }
#map { flex: 1; height: 100%; background: var(--bg-3); }

/* ------------------------------------------------------------ panel */
.panel {
  width: var(--panel-w);
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border-right: 1px solid var(--line);
  z-index: 1000;
  position: relative;
}
.sheet-handle { display: none; }
.brand {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 2px 12px;
  padding: 16px 18px 10px;
}
.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--brand);
  text-decoration: none;
  font-weight: 800;
  font-size: 22px;
  letter-spacing: -.02em;
}
.logo svg { width: 32px; height: 32px; }
.tagline { margin: 0; color: var(--ink-3); font-size: 12.5px; grid-column: 2; grid-row: 1; align-self: center; padding-top: 4px; }
.icon-btn {
  border: 0; background: transparent; color: var(--ink-3);
  width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center;
}
.icon-btn:hover { background: var(--bg-2); color: var(--ink); }

.tabs { display: flex; gap: 4px; padding: 0 14px; border-bottom: 1px solid var(--line); }
.tab {
  border: 0; background: none; padding: 10px 10px 11px; font-weight: 600; color: var(--ink-3);
  border-bottom: 2.5px solid transparent; margin-bottom: -1px;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); }

.panel-body { flex: 1; overflow-y: auto; overscroll-behavior: contain; }
.tab-pane { display: none; padding: 14px 16px 24px; }
.tab-pane.active { display: block; }
.panel-foot { padding: 8px 16px 10px; font-size: 11px; color: var(--ink-3); border-top: 1px solid var(--line); }
.panel-foot a { color: inherit; }

/* ------------------------------------------------------------ waypoints */
.waypoints { display: flex; flex-direction: column; gap: 6px; position: relative; }
.wp {
  display: flex; align-items: center; gap: 8px; position: relative;
}
.wp-dot {
  width: 22px; height: 22px; border-radius: 50%; flex: none;
  display: grid; place-items: center; color: #fff; font-size: 11px; font-weight: 700;
  background: var(--via); cursor: grab; user-select: none;
}
.wp.start .wp-dot { background: var(--start); }
.wp.end .wp-dot { background: var(--end); }
.wp.loopend .wp-dot { background: linear-gradient(135deg, var(--start) 50%, var(--end) 50%); font-size: 9px; letter-spacing: -.03em; }
.loop-banner { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--ink-2); margin-bottom: 4px; }
.loop-banner svg { width: 16px; height: 16px; color: var(--brand); }
.lap-row .wp-dot { background: #a16207; font-size: 13px; cursor: default; }
.lap-box { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px; padding: 6px 6px 6px 12px; min-height: 40px; }
.lap-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.lap-text b { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stepper { display: flex; align-items: center; gap: 2px; background: var(--bg); border: 1px solid var(--line); border-radius: 9px; }
.stepper button { width: 32px; height: 32px; border: 0; background: none; font-size: 18px; font-weight: 700; border-radius: 8px; color: var(--ink); }
.stepper button:hover:not(:disabled) { background: var(--bg-3); }
.stepper button:disabled { opacity: .35; }
.stepper span { min-width: 20px; text-align: center; font-weight: 800; }
.wp:not(:last-child) .wp-dot::after {
  content: ""; position: absolute; left: 10.5px; top: 30px; height: 12px; border-left: 2px dotted var(--ink-3); opacity: .6;
}
.wp.drag-over { outline: 2px dashed var(--brand); outline-offset: 2px; border-radius: 10px; }
.field { position: relative; flex: 1; min-width: 0; }
.field input {
  width: 100%; height: 40px; padding: 0 34px 0 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg-2); outline: none;
  transition: border-color .15s, background .15s;
}
.field input:focus { border-color: var(--brand); background: var(--bg); box-shadow: 0 0 0 3px var(--brand-soft); }
.field input::placeholder { color: var(--ink-3); }
.field .clear-x {
  position: absolute; right: 4px; top: 4px; width: 32px; height: 32px; border: 0; background: none; color: var(--ink-3);
  border-radius: 8px; display: none; place-items: center;
}
.field.has-value .clear-x { display: grid; }
.field .clear-x:hover { color: var(--ink); background: var(--bg-3); }
.wp-remove { border: 0; background: none; color: var(--ink-3); width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; }
.wp-remove:hover { color: var(--end); background: var(--bg-2); }

.suggest {
  position: absolute; left: 0; right: 0; top: 44px; z-index: 50;
  background: var(--bg); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
  padding: 4px; max-height: 320px; overflow-y: auto;
}
.suggest button {
  display: flex; gap: 10px; align-items: flex-start; width: 100%; text-align: left;
  border: 0; background: none; padding: 8px 10px; border-radius: 8px;
}
.suggest button:hover, .suggest button.active { background: var(--bg-2); }
.suggest .s-icon { color: var(--ink-3); margin-top: 1px; }
.suggest .s-name { font-weight: 600; display: block; }
.suggest .s-addr { color: var(--ink-3); font-size: 12px; display: block; }
.suggest .s-empty { padding: 10px; color: var(--ink-3); }

.wp-actions { display: flex; gap: 4px; margin: 8px 0 4px 26px; flex-wrap: wrap; }
.link-btn {
  display: inline-flex; align-items: center; gap: 4px; border: 0; background: none; color: var(--ink-2);
  padding: 5px 8px; border-radius: 8px; font-weight: 600; font-size: 12.5px;
}
.link-btn svg { width: 16px; height: 16px; }
.link-btn:hover { background: var(--bg-2); color: var(--ink); }

/* ------------------------------------------------------------ groups */
.group { margin-top: 16px; }
.group-label { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); margin-bottom: 8px; display: flex; justify-content: space-between; }
.group-label output { text-transform: none; letter-spacing: 0; color: var(--ink); font-size: 13px; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button, .chip {
  border: 1px solid var(--line); background: var(--bg); padding: 7px 11px; border-radius: 999px;
  font-weight: 600; font-size: 12.5px; color: var(--ink-2); display: inline-flex; align-items: center; gap: 6px;
  transition: background .12s, border-color .12s, color .12s;
}
.seg button:hover, .chip:hover { border-color: var(--ink-3); color: var(--ink); }
.seg button.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip svg { width: 15px; height: 15px; }
.chip[aria-pressed="true"] { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-ink); }
.chip .tick { display: none; }
.chip[aria-pressed="true"] .tick { display: inline; }
.chip[aria-pressed="true"] .ico { display: none; }
.hint { color: var(--ink-3); font-size: 12px; margin: 6px 0 0; }
details.more summary { cursor: pointer; font-size: 12.5px; font-weight: 600; color: var(--ink-2); list-style: none; display: flex; gap: 6px; align-items: center; }
details.more summary::-webkit-details-marker { display: none; }
details.more summary::before { content: "▸"; font-size: 10px; transition: transform .15s; }
details.more[open] summary::before { transform: rotate(90deg); }
details.more summary output { color: var(--ink); }
input[type=range] { width: 100%; accent-color: var(--brand); margin: 10px 0 0; }

.poi-pin { border-radius: 50%; border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.35); display: grid; place-items: center; font-size: 12px; line-height: 1; color: #fff; font-weight: 800; }
.poi-dot { width: 20px; height: 20px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 10.5px; color: #fff; font-weight: 800; flex: none; line-height: 1; }
.along-chips .chip { padding: 5px 10px 5px 5px; gap: 6px; }
.along-chips .chip .count { color: var(--ink-3); font-weight: 600; }
.along-chips .chip[aria-pressed="true"] .count { color: var(--brand-ink); }
.along-chips .chip:disabled { opacity: .45; cursor: default; }
.along-chips .chip .tick { display: none !important; }
.along-list { display: grid; gap: 4px; margin-top: 8px; max-height: 320px; overflow-y: auto; }
.along-list:empty { display: none; }
.along-item { display: grid; grid-template-columns: 1fr auto; gap: 6px; align-items: center; }
.along-main { display: flex; align-items: center; gap: 10px; text-align: left; border: 0; background: var(--bg-2); border-radius: 10px; padding: 8px 10px; min-width: 0; }
.along-main:hover { background: var(--bg-3); }
.along-text { display: flex; flex-direction: column; min-width: 0; }
.along-text b { font-weight: 700; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.along-text .small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.add-btn { padding: 8px 10px; font-size: 12.5px; white-space: nowrap; }
.kom-hill { display: flex; align-items: center; gap: 8px; background: var(--bg-2); border-radius: 10px; padding: 8px 10px; font-size: 13px; }
.kom-hill b { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kom-hill .muted { font-size: 12px; }
.check { display: flex; align-items: center; gap: 8px; margin-top: 14px; font-weight: 600; font-size: 13px; cursor: pointer; }
.check input { accent-color: var(--brand); width: 16px; height: 16px; margin: 0; }
.climbs { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.climbs li { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 10px; background: var(--bg-2); cursor: pointer; font-size: 12.5px; }
.climbs li:hover { outline: 1.5px solid var(--brand); }
.climbs .c-badge { font-weight: 800; font-size: 11px; color: #fff; border-radius: 6px; padding: 3px 6px; }
.climbs .c-main b { font-weight: 700; }
.climbs .c-gain { font-weight: 700; }
.grade-key { display: flex; gap: 10px; flex-wrap: wrap; font-size: 11px; color: var(--ink-3); margin-top: 4px; }
.grade-key span { display: inline-flex; align-items: center; gap: 4px; }
.summit-icon { background: var(--bg); color: var(--ink); border-radius: 999px; box-shadow: var(--shadow); padding: 2px 7px 2px 5px; font-size: 11px; font-weight: 700; white-space: nowrap; display: inline-flex; align-items: center; gap: 3px; }
.far .summit-icon.minor { display: none; }
.summit-icon i { color: #a16207; font-style: normal; }
.intro { color: var(--ink-2); margin: 0 0 12px; }
.btn-row { display: flex; gap: 8px; margin-top: 18px; flex-wrap: wrap; }
.btn-row.end { justify-content: flex-end; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); background: var(--bg); padding: 9px 14px; border-radius: 10px; font-weight: 600;
  cursor: pointer; transition: background .12s, border-color .12s;
}
.btn:hover:not(:disabled) { border-color: var(--ink-3); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--brand-ink); border-color: var(--brand-ink); }
.btn svg { width: 16px; height: 16px; }

/* ------------------------------------------------------------ result */
.empty { text-align: center; color: var(--ink-2); padding: 22px 10px 6px; }
.empty svg { width: 150px; height: 70px; color: var(--ink-3); }
.empty p { margin: 8px 0 0; }
.result:empty { display: none; }
.result { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 16px; }
.summary { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
.summary .big { font-size: 28px; font-weight: 800; letter-spacing: -.02em; }
.summary .big small { font-size: 15px; font-weight: 600; color: var(--ink-2); margin-left: 2px; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 12px 0; }
.stat { background: var(--bg-2); border-radius: 10px; padding: 8px 8px 7px; }
.stat b { display: block; font-size: 16px; font-weight: 700; }
.stat span { font-size: 11px; color: var(--ink-3); display: block; line-height: 1.25; }
.bar { display: flex; height: 10px; border-radius: 6px; overflow: hidden; background: var(--bg-3); margin: 6px 0 8px; }
.bar i { display: block; height: 100%; }
.bar i + i { box-shadow: -1px 0 0 var(--bg); }
.legend-rows { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; color: var(--ink-2); }
.legend-rows span { display: inline-flex; align-items: center; gap: 5px; cursor: default; }
.sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.ele { margin-top: 14px; }
.ele-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-weight: 700; font-size: 12.5px; margin-bottom: 4px; flex-wrap: wrap; }
.ele-head > span:first-child { display: inline-flex; align-items: center; gap: 6px; }
.ele-head svg { width: 16px; height: 16px; color: var(--ink-3); }
svg.ele-svg { width: 100%; height: auto; display: block; touch-action: pan-y; overflow: visible; }
.ele-svg text { font-size: 9.5px; fill: var(--ink-3); }
.ele-svg .grid { stroke: var(--line); stroke-width: 1; }
.ele-svg .ele-hit { cursor: crosshair; }
.ele-cursor line { stroke: var(--ink-2); stroke-width: 1; stroke-dasharray: 2 2; }
.ele-cursor circle { fill: var(--accent); stroke: var(--bg); stroke-width: 1.5; }
.ele-svg .ele-label { fill: var(--ink); font-weight: 700; font-size: 10.5px; }
.ele-note { margin-top: 2px; font-size: 11px; }
.notes { margin: 12px 0 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.notes li { display: flex; gap: 8px; align-items: flex-start; background: var(--bg-2); border-radius: 10px; padding: 8px 10px; font-size: 12.5px; color: var(--ink-2); }
.notes li.warn { background: color-mix(in srgb, var(--accent) 12%, var(--bg)); color: var(--ink); }
.notes li svg { width: 16px; height: 16px; margin-top: 1px; }
.actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 14px; }
.actions .btn { padding: 9px 6px; font-size: 12.5px; flex-direction: column; gap: 3px; }
.actions .btn svg { width: 18px; height: 18px; }
.section-title { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); margin: 18px 0 8px; display: flex; align-items: center; justify-content: space-between; }
.compare { display: grid; gap: 6px; }
.alt {
  display: grid; grid-template-columns: 1fr auto auto auto; gap: 10px; align-items: center; text-align: left;
  border: 1px solid var(--line); background: var(--bg); border-radius: 10px; padding: 8px 10px; font-size: 12.5px;
}
.alt:hover { border-color: var(--ink-3); }
.alt.active { border-color: var(--brand); background: var(--brand-soft); }
.alt b { font-weight: 700; }
.alt .muted { color: var(--ink-3); }
.directions { list-style: none; margin: 0; padding: 0; counter-reset: dir; }
.directions li {
  display: grid; grid-template-columns: 24px 1fr auto; gap: 8px; align-items: start; padding: 7px 4px; border-radius: 8px; cursor: pointer;
  border-bottom: 1px solid var(--line); font-size: 13px;
}
.directions li:last-child { border-bottom: 0; }
.directions li:hover { background: var(--bg-2); }
.directions .d-ico { color: var(--ink-3); display: grid; place-items: center; }
.directions .d-dist { color: var(--ink-3); font-size: 12px; white-space: nowrap; }
.muted { color: var(--ink-3); }
.small { font-size: 12px; }

.saved-list { display: grid; gap: 8px; }
.saved-item { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; align-items: center; }
.saved-item .name { font-weight: 700; cursor: pointer; }
.saved-item .name:hover { color: var(--brand); }
.saved-item .meta { color: var(--ink-3); font-size: 12px; grid-column: 1; }
.saved-item .row-actions { grid-row: 1 / span 2; grid-column: 2; display: flex; gap: 2px; }
.import { margin-top: 16px; }
.import .btn { cursor: pointer; }

/* ------------------------------------------------------------ map ui */
.map-tools { position: absolute; top: 12px; right: 12px; z-index: 1000; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.map-btn {
  width: 40px; height: 40px; border-radius: 10px; border: 0; background: var(--bg); color: var(--ink);
  box-shadow: var(--shadow); display: grid; place-items: center;
}
.map-btn:hover { color: var(--brand); }
.map-btn.on { color: var(--brand); }
.layers-pop {
  background: var(--bg); border-radius: 14px; box-shadow: var(--shadow); padding: 12px; width: 260px;
  max-height: calc(100vh - 120px); overflow-y: auto;
}
.pop-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); margin: 2px 0 8px; }
.pop-title:not(:first-child) { margin-top: 14px; }
.basemaps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.basemaps button {
  border: 2px solid transparent; border-radius: 10px; padding: 0; background: var(--bg-2); overflow: hidden; font-size: 11px; font-weight: 600;
  display: flex; flex-direction: column; align-items: stretch;
}
.basemaps button img { width: 100%; height: 46px; object-fit: cover; display: block; background: var(--bg-3); }
.basemaps button span { padding: 4px 2px; }
.basemaps button.active { border-color: var(--brand); }
.overlay-list label { display: flex; align-items: center; gap: 9px; padding: 6px 4px; border-radius: 8px; cursor: pointer; font-weight: 500; }
.overlay-list label:hover { background: var(--bg-2); }
.overlay-list input { accent-color: var(--brand); width: 16px; height: 16px; margin: 0; }
.overlay-list .ov-sw { width: 14px; height: 14px; border-radius: 50%; flex: none; }

.busy {
  position: absolute; left: calc(var(--panel-w) + (100% - var(--panel-w)) / 2); transform: translateX(-50%); top: 14px; z-index: 1000; white-space: nowrap;
  background: var(--bg); box-shadow: var(--shadow); border-radius: 999px; padding: 8px 14px; font-weight: 600; font-size: 12.5px;
  display: flex; align-items: center; gap: 8px;
}
.busy span { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--brand-soft); border-top-color: var(--brand); animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.map-legend {
  position: absolute; left: calc(var(--panel-w) + 12px); bottom: 24px; z-index: 900; background: var(--bg); box-shadow: var(--shadow);
  border-radius: 10px; padding: 8px 10px; font-size: 11.5px; display: flex; gap: 10px; flex-wrap: wrap; max-width: calc(100vw - var(--panel-w) - 24px);
}
.map-legend span { display: inline-flex; gap: 5px; align-items: center; }

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-weight: 600; z-index: 3000;
  transition: opacity .2s, transform .2s; max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.dialog { border: 0; border-radius: 16px; padding: 0; max-width: 520px; width: calc(100vw - 32px); background: var(--bg); color: var(--ink); box-shadow: var(--shadow); }
.dialog::backdrop { background: rgba(10, 16, 14, .45); }
.dialog form { padding: 22px 24px 20px; }
.dialog h2 { margin: 0 0 8px; font-size: 20px; }
.dialog h3 { margin: 16px 0 6px; font-size: 14px; }
.about-list { padding-left: 18px; margin: 8px 0; display: grid; gap: 4px; }
kbd { background: var(--bg-2); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; font-size: 12px; }

/* ------------------------------------------------------------ leaflet tweaks */
.leaflet-container { font: inherit; background: var(--bg-3); }
.leaflet-control-zoom { border: 0 !important; box-shadow: var(--shadow) !important; border-radius: 10px !important; overflow: hidden; }
.leaflet-control-zoom a { background: var(--bg) !important; color: var(--ink) !important; border-color: var(--line) !important; width: 40px !important; height: 40px !important; line-height: 40px !important; }
.leaflet-popup-content-wrapper { border-radius: 12px; background: var(--bg); color: var(--ink); box-shadow: var(--shadow); }
.leaflet-popup-tip { background: var(--bg); }
.leaflet-popup-content { margin: 12px 14px; font-size: 13px; }
.leaflet-control-attribution { font-size: 10px; background: color-mix(in srgb, var(--bg) 85%, transparent) !important; color: var(--ink-3); }
.leaflet-control-attribution a { color: var(--ink-2); }
.pin { position: relative; }
.pin-body {
  width: 30px; height: 30px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); background: var(--via);
  border: 2.5px solid #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, .35); display: grid; place-items: center;
}
.pin-body b { transform: rotate(45deg); color: #fff; font-size: 12px; font-weight: 800; }
.pin.start .pin-body { background: var(--start); }
.pin.end .pin-body { background: var(--end); }
.pin.startend .pin-body { background: linear-gradient(135deg, var(--start) 50%, var(--end) 50%); }
.pin.startend .pin-body b { font-size: 10px; letter-spacing: -.02em; }
.dir-arrow { width: 12px; height: 12px; display: grid; place-items: center; }
.dir-arrow svg { width: 12px; height: 12px; filter: drop-shadow(0 0 1px rgba(0,0,0,.6)); }
.ghost { width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 3px solid var(--via); box-shadow: 0 1px 4px rgba(0, 0, 0, .35); }
.ghost.dragging { width: 18px; height: 18px; }
.tl-icon { width: 14px; height: 14px; border-radius: 4px; background: #222; border: 1.5px solid #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .4); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; }
.tl-icon i { width: 3px; height: 3px; border-radius: 50%; display: block; }
.far .tl-icon { transform: scale(.6); opacity: .85; }
.me-dot { width: 16px; height: 16px; border-radius: 50%; background: #2f80ff; border: 3px solid #fff; box-shadow: 0 0 0 6px rgba(47, 128, 255, .25); }
.wx-icon { background: var(--bg); color: var(--ink); border-radius: 999px; box-shadow: var(--shadow); padding: 3px 8px 3px 5px; font-size: 11px; font-weight: 600; white-space: nowrap; display: inline-flex; align-items: center; gap: 4px; }
.wx-icon svg { width: 16px; height: 16px; }
/* Close (X) on popups: a proper tap target in the top-right corner */
.leaflet-container a.leaflet-popup-close-button {
  top: 8px; right: 8px; width: 28px; height: 28px; border-radius: 8px;
  display: grid; place-items: center; font: 400 22px/1 system-ui, sans-serif; color: var(--ink-3);
}
.leaflet-container a.leaflet-popup-close-button:hover { background: var(--bg-2); color: var(--ink); }
.leaflet-popup-content { padding-right: 22px; }
.popup-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.popup-actions button { border: 1px solid var(--line); background: var(--bg); border-radius: 8px; padding: 5px 9px; font-weight: 600; font-size: 12px; }
.popup-actions button:hover { border-color: var(--brand); color: var(--brand); }
.popup-title { font-weight: 700; }
.popup-sub { color: var(--ink-3); font-size: 12px; }
.ctx-menu { display: grid; gap: 2px; min-width: 170px; }
.ctx-menu button { border: 0; background: none; text-align: left; padding: 7px 8px; border-radius: 8px; font-weight: 600; display: flex; gap: 8px; align-items: center; }
.ctx-menu button:hover { background: var(--bg-2); }
.ctx-menu .sw { width: 12px; height: 12px; border-radius: 50%; }

/* ------------------------------------------------------------ mobile: bottom sheet */
@media (max-width: 760px) {
  :root { --panel-w: 0px; }
  #app { display: block; }
  #map { position: absolute; inset: 0; }
  .panel {
    position: absolute; left: 0; right: 0; bottom: 0; width: auto; height: 88dvh;
    border-right: 0; border-radius: 18px 18px 0 0; box-shadow: 0 -6px 24px rgba(0, 0, 0, .18);
    transform: translateY(calc(88dvh - var(--sheet-visible, 46dvh)));
    transition: transform .28s cubic-bezier(.2, .8, .2, 1);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .panel.dragging { transition: none; }
  .sheet-handle { display: grid; place-items: center; border: 0; background: none; height: 22px; width: 100%; flex: none; touch-action: none; }
  .sheet-handle span { width: 40px; height: 5px; border-radius: 3px; background: var(--line); }
  .brand { padding: 0 16px 6px; }
  .logo { font-size: 19px; }
  .logo svg { width: 26px; height: 26px; }
  .tagline { display: none; }
  .tab-pane { padding: 12px 14px 20px; }
  .map-tools { top: max(12px, env(safe-area-inset-top)); }
  .leaflet-top.leaflet-left { top: max(0px, env(safe-area-inset-top)); }
  .busy { left: 50%; transform: translateX(-50%); top: max(12px, env(safe-area-inset-top)); }
  .map-legend { display: none !important; }
  .leaflet-control-zoom { display: none; }
  .leaflet-bottom { bottom: var(--sheet-visible, 46dvh); transition: bottom .28s cubic-bezier(.2, .8, .2, 1); }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .panel-foot { display: none; }
  .toast { bottom: calc(var(--sheet-visible, 46dvh) + 12px); }
  .layers-pop { max-height: max(220px, calc(100dvh - var(--sheet-visible, 46dvh) - 110px)); width: min(280px, calc(100vw - 70px)); }
  /* iOS zooms into inputs under 16px on focus */
  .field input { font-size: 16px; height: 44px; }
  .field .clear-x { top: 6px; }
  .suggest { top: 48px; }
  /* comfortable touch targets */
  .link-btn { min-height: 38px; padding: 8px 10px; }
  .seg button, .chip { min-height: 36px; }
  input[type=range] { height: 32px; }
  details.more summary, .dir-details summary { min-height: 40px; }
  .check { min-height: 40px; }
  .check input { width: 20px; height: 20px; }
  .tab { padding: 12px 12px 13px; }
  .directions li { padding: 10px 4px; }
  .leaflet-popup-content { font-size: 14px; }
  .popup-actions button, .ctx-menu button { min-height: 38px; }
}
