/* Bench Map – Material Design 3 inspired, mobile first.
   Compact (< 840 px): bottom navigation bar + bottom sheets.
   Expanded (>= 840 px): navigation rail + side panel + bench side sheet. */

:root {
  color-scheme: light;
  --primary: #006c4c; --on-primary: #ffffff; --primary-container: #8bf8c6; --on-primary-container: #002114;
  --secondary: #4c6358; --secondary-container: #cee9da; --on-secondary-container: #092017;
  --tertiary-container: #c2e8fc; --on-tertiary-container: #001f2a;
  --error: #ba1a1a; --error-container: #ffdad6; --on-error-container: #410002;
  --warn-container: #ffdeac; --on-warn-container: #281900;
  --surface: #f5fbf5; --on-surface: #171d1a; --on-surface-variant: #404944;
  --surface-container-lowest: #ffffff; --surface-container-low: #eff5ef; --surface-container: #e9efe9;
  --surface-container-high: #e4eae4; --surface-container-highest: #dee4de;
  --outline: #707974; --outline-variant: #bfc9c2;
  --inverse-surface: #2c322f; --inverse-on-surface: #ecf2ec; --inverse-primary: #6edbab;
  --elev1: 0 1px 2px rgba(0,0,0,.3), 0 1px 3px 1px rgba(0,0,0,.15);
  --elev2: 0 1px 2px rgba(0,0,0,.3), 0 2px 6px 2px rgba(0,0,0,.15);
  --elev3: 0 4px 8px 3px rgba(0,0,0,.15), 0 1px 3px rgba(0,0,0,.3);
  --t0: #0b6e4f; --t1: #c2571a; --t2: #3b5bdb; --t3: #8a5a9e;
  --route: #1a73e8; --pin-a: #2b8a3e; --pin-b: #c92a2a;
  --nav-h: calc(80px + env(safe-area-inset-bottom, 0px));
  --ease: cubic-bezier(.2, 0, 0, 1);
  --font: Roboto, system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --primary: #6edbab; --on-primary: #003826; --primary-container: #005139; --on-primary-container: #8bf8c6;
    --secondary: #b3ccbf; --secondary-container: #354b41; --on-secondary-container: #cee9da;
    --tertiary-container: #254b5b; --on-tertiary-container: #c2e8fc;
    --error: #ffb4ab; --error-container: #93000a; --on-error-container: #ffdad6;
    --warn-container: #5c4200; --on-warn-container: #ffdeac;
    --surface: #0f1512; --on-surface: #dee4de; --on-surface-variant: #bfc9c2;
    --surface-container-lowest: #0a0f0d; --surface-container-low: #171d1a; --surface-container: #1b211e;
    --surface-container-high: #252b28; --surface-container-highest: #303633;
    --outline: #89938d; --outline-variant: #404944;
    --inverse-surface: #dee4de; --inverse-on-surface: #2c322f; --inverse-primary: #006c4c;
    --route: #4c9bff;
  }
}

/* ---- Base --------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font: 400 14px/20px var(--font); letter-spacing: .25px; color: var(--on-surface); background: var(--surface);
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
  height: 100dvh; overflow: hidden; display: grid; grid-template-rows: minmax(0, 1fr) auto; grid-template-columns: 100%;
}
[hidden] { display: none !important; }
button, input, select, textarea { font-family: inherit; }
a { color: var(--primary); }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
h2, h3, h4, p { margin: 0; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--on-surface-variant); }
.row { display: flex; gap: 8px; align-items: center; }
.row.end { justify-content: flex-end; }
.ms {
  font-family: "Material Symbols Outlined"; font-weight: normal; font-style: normal; font-size: 24px; line-height: 1;
  letter-spacing: normal; text-transform: none; white-space: nowrap; direction: ltr; display: inline-block; flex: none;
  font-feature-settings: "liga"; -webkit-font-smoothing: antialiased; user-select: none; overflow: hidden;
  width: 1em; height: 1em; font-variation-settings: "FILL" 0, "wght" 400, "GRAD" 0, "opsz" 24;
}
.msg { margin: 8px 0 0; font-size: 13px; color: var(--on-surface-variant); }
.msg:empty { display: none; }
.msg.ok { color: var(--primary); }
.msg.err { color: var(--error); }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }

/* State layer: an inset shadow tinted with the content colour */
.btn, .icon-btn, .chip, .dest .ind, .list-item, .fab, .colour-pick button, .segmented label > span {
  transition: box-shadow .15s var(--ease), background-color .2s var(--ease);
}
:is(.btn, .icon-btn, .chip, .list-item, .fab, .colour-pick button, .segmented label > span):not(:disabled):hover {
  box-shadow: inset 0 0 0 100vmax color-mix(in srgb, currentColor 8%, transparent);
}
:is(.btn, .icon-btn, .chip, .list-item, .fab, .colour-pick button):not(:disabled):active {
  box-shadow: inset 0 0 0 100vmax color-mix(in srgb, currentColor 12%, transparent);
}

/* ---- Layout: compact (mobile first) ------------------------------------------- */
#stage { grid-row: 1; grid-column: 1; position: relative; min-height: 0; overflow: hidden; }
#map { position: absolute; inset: 0; background: var(--surface-container); }

#nav {
  grid-row: 2; grid-column: 1; z-index: 1200; display: flex; height: var(--nav-h);
  padding-bottom: env(safe-area-inset-bottom, 0px); background: var(--surface-container);
}
.rail-brand { display: none; }
.dest {
  flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  padding: 12px 0 16px; border: 0; background: none; color: var(--on-surface-variant); cursor: pointer;
  font: 500 12px/16px var(--font); letter-spacing: .5px;
}
.dest .ind { width: 64px; height: 32px; border-radius: 16px; display: grid; place-items: center; }
.dest:hover .ind { box-shadow: inset 0 0 0 100vmax color-mix(in srgb, var(--on-surface) 8%, transparent); }
.dest[aria-current="page"] { color: var(--on-surface); font-weight: 700; }
.dest[aria-current="page"] .ind { background: var(--secondary-container); color: var(--on-secondary-container); }
.dest[aria-current="page"] .ms { font-variation-settings: "FILL" 1, "wght" 400, "GRAD" 0, "opsz" 24; }
.dest:focus-visible { outline: none; }
.dest:focus-visible .ind { outline: 3px solid var(--primary); }

/* Floating top bar */
#topbar {
  position: absolute; z-index: 1000; top: max(12px, env(safe-area-inset-top)); left: 12px; max-width: calc(100% - 24px);
  display: flex; align-items: center; gap: 10px; height: 48px; padding: 0 20px 0 14px; border-radius: 24px;
  background: var(--surface-container-high); box-shadow: var(--elev2); pointer-events: none;
}
#topbar .brand { color: var(--primary); font-variation-settings: "FILL" 1, "wght" 400, "GRAD" 0, "opsz" 24; }
#topbar b { font: 500 16px/24px var(--font); letter-spacing: .15px; white-space: nowrap; }
#count { color: var(--on-surface-variant); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#count::before { content: "·"; margin-right: 10px; }

/* FAB */
.fab {
  position: absolute; z-index: 1000; right: 16px; bottom: 28px; width: 56px; height: 56px; border-radius: 16px; border: 0;
  display: grid; place-items: center; cursor: pointer;
  background: var(--primary-container); color: var(--on-primary-container); box-shadow: var(--elev3);
}
body:not([data-dest="map"]) .fab, body.bench-open .fab { display: none; }

/* ---- Sheets ------------------------------------------------------------------- */
.sheet { display: flex; flex-direction: column; min-height: 0; background: var(--surface-container-low); --field-bg: var(--surface-container-low); }
.sheet-head { flex: none; padding: 0 8px 8px 24px; }
.grab { display: flex; justify-content: center; padding: 16px 0 8px; margin-left: -16px; cursor: grab; }
.handle { width: 32px; height: 4px; border-radius: 2px; background: var(--on-surface-variant); opacity: .4; }
.head-row { display: flex; align-items: center; gap: 12px; min-height: 48px; }
.sheet h2 { font: 400 22px/28px var(--font); letter-spacing: 0; }
.sheet .sub { color: var(--on-surface-variant); margin-top: 2px; }
.sub:empty { display: none; }
.head-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 8px 16px 4px 0; }
.sheet-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 4px 24px 32px; }
.sheet-body h3 { font: 500 14px/20px var(--font); letter-spacing: .1px; color: var(--on-surface-variant); margin: 20px 0 12px; display: flex; align-items: center; gap: 8px; }
.pane > h3:first-child, .pane > p:first-child { margin-top: 4px; }
.pane > p.muted { margin-bottom: 16px; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin: 20px 0 12px; }
.section-head h3 { margin: 0; }

@media (max-width: 839.98px) {
  .sheet {
    position: fixed; left: 0; right: 0; bottom: var(--nav-h); z-index: 1100;
    border-radius: 28px 28px 0 0; box-shadow: var(--elev1);
    height: 50dvh; max-height: calc(100dvh - var(--nav-h) - 64px);
    transition: height .3s var(--ease);
    animation: sheet-in .3s var(--ease);
  }
  #bench { position: absolute; bottom: 0; z-index: 1150; }
  .sheet[data-state="full"] { height: calc(100dvh - var(--nav-h) - 64px); }
  .sheet[data-state="peek"] { height: var(--peek, 120px); }
  .sheet[data-state="peek"] .sheet-body { overflow: hidden; }
  .sheet-head { touch-action: none; }
  .leaflet-control-zoom { display: none; }
  #snackbar { bottom: 16px; }
  body.sheet-open #snackbar, body.bench-open #snackbar { bottom: calc(50dvh + 8px); }
}
@keyframes sheet-in { from { transform: translateY(40%); opacity: 0; } }

/* ---- Layout: expanded (desktop) ----------------------------------------------- */
@media (min-width: 840px) {
  body { grid-template-columns: 80px auto minmax(0, 1fr); grid-template-rows: 100%; }
  #nav {
    grid-row: 1; grid-column: 1; height: auto; flex-direction: column; align-items: center; gap: 12px;
    padding: 16px 0; background: var(--surface);
  }
  .rail-brand {
    display: grid; place-items: center; width: 56px; height: 56px; border-radius: 16px; margin-bottom: 28px;
    background: var(--primary-container); color: var(--on-primary-container);
  }
  .rail-brand .ms { font-variation-settings: "FILL" 1, "wght" 400, "GRAD" 0, "opsz" 24; }
  .dest { flex: none; width: 80px; padding: 0; }
  .dest .ind { width: 56px; }
  #sheet { grid-row: 1; grid-column: 2; width: 360px; border-radius: 0 16px 16px 0; margin-right: 0; }
  #stage { grid-row: 1; grid-column: 3; }
  .grab { display: none; }
  .sheet-head { padding-top: 16px; }
  #bench {
    position: absolute; z-index: 1100; top: 12px; right: 12px; bottom: 12px; width: 384px;
    border-radius: 16px; box-shadow: var(--elev3);
  }
  #topbar { top: 12px; left: 12px; }
  body.bench-open .leaflet-right { right: 396px; }
  #snackbar { bottom: 24px; }
}

/* ---- Buttons ------------------------------------------------------------------ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 24px;
  border-radius: 20px; border: 0; cursor: pointer; text-decoration: none; white-space: nowrap;
  font: 500 14px/20px var(--font); letter-spacing: .1px; position: relative;
}
.btn .ms { font-size: 18px; margin-left: -8px; }
.btn.filled { background: var(--primary); color: var(--on-primary); }
.btn.filled:not(:disabled):hover { box-shadow: var(--elev1), inset 0 0 0 100vmax color-mix(in srgb, var(--on-primary) 8%, transparent); }
.btn.tonal { background: var(--secondary-container); color: var(--on-secondary-container); }
.btn.outlined { background: none; border: 1px solid var(--outline); color: var(--primary); }
.btn.text { background: none; color: var(--primary); padding: 0 12px; }
.btn.text .ms { margin-left: -4px; }
.btn.small { height: 32px; padding: 0 12px; }
.btn.block { width: 100%; }
.btn:disabled { cursor: default; background: color-mix(in srgb, var(--on-surface) 12%, transparent); color: color-mix(in srgb, var(--on-surface) 38%, transparent); box-shadow: none; }
.btn.text:disabled { background: none; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 20px; border: 0; padding: 0; flex: none; cursor: pointer;
  display: inline-grid; place-items: center; background: none; color: var(--on-surface-variant);
}
.icon-btn.filled { background: var(--primary); color: var(--on-primary); }
.icon-btn:disabled { color: color-mix(in srgb, var(--on-surface) 38%, transparent); cursor: default; }
.icon-btn .ms { font-size: 24px; }

/* ---- Chips -------------------------------------------------------------------- */
.chip-set { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; border: 0; min-width: 0; }
.chip-set legend { padding: 0; margin-bottom: 8px; font: 500 14px/20px var(--font); color: var(--on-surface-variant); float: left; width: 100%; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 16px; border-radius: 8px;
  border: 1px solid var(--outline-variant); background: none; color: var(--on-surface-variant); position: relative;
  font: 500 14px/20px var(--font); letter-spacing: .1px; cursor: pointer; white-space: nowrap; text-decoration: none; user-select: none;
}
.chip .ms { font-size: 18px; margin-left: -8px; }
.chip input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.chip .chk { display: none; }
.chip:has(input:checked), .chip.on {
  background: var(--secondary-container); color: var(--on-secondary-container); border-color: transparent;
}
.chip:has(input:checked) .chk, .chip.on .chk { display: inline-block; }
.chip:has(input:focus-visible) { outline: 3px solid var(--primary); outline-offset: 2px; }
.chip .dot { width: 10px; height: 10px; }
.chip .n { color: var(--on-surface-variant); font-weight: 400; font-size: 12px; margin-right: -4px; }
.chip.cat.on { background: color-mix(in srgb, var(--c) 22%, var(--surface-container-low)); color: var(--on-surface); }
.chip:disabled { opacity: .6; cursor: default; }
.chip.assist { color: var(--on-surface); flex: none; }
.chip.assist .ms { color: var(--primary); }
/* chips wrap onto more lines: a hidden-scrollbar strip hid the last chips (unreachable with a mouse) */
.assist-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 0; padding: 4px 0; }
.dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; flex: none; }

/* Segmented button */
.segmented { display: flex; }
.segmented label { flex: 1; position: relative; }
.segmented input { position: absolute; opacity: 0; }
.segmented label > span {
  display: flex; align-items: center; justify-content: center; gap: 8px; height: 40px; cursor: pointer;
  border: 1px solid var(--outline); color: var(--on-surface); font: 500 14px/20px var(--font); letter-spacing: .1px;
}
.segmented label:first-child > span { border-radius: 20px 0 0 20px; }
.segmented label:last-child > span { border-radius: 0 20px 20px 0; }
.segmented label + label > span { margin-left: -1px; }
.segmented input:checked + span { background: var(--secondary-container); color: var(--on-secondary-container); }
.segmented .chk { display: none; font-size: 18px; }
.segmented input:checked + span .chk { display: inline-block; }
.segmented input:focus-visible + span { outline: 3px solid var(--primary); outline-offset: 2px; position: relative; z-index: 1; }

/* ---- Text fields (outlined) --------------------------------------------------- */
.field { position: relative; display: block; margin: 16px 0 8px; }
.field > span {
  position: absolute; z-index: 1; left: 12px; top: -8px; padding: 0 4px; pointer-events: none;
  font: 400 12px/16px var(--font); color: var(--on-surface-variant); background: var(--field-bg, var(--surface));
}
.field input, .field select, .field textarea {
  display: block; width: 100%; min-height: 56px; margin: 0; padding: 15px 16px; appearance: none; -webkit-appearance: none;
  border: 1px solid var(--outline); border-radius: 4px; background: transparent; color: var(--on-surface);
  font: 400 16px/24px var(--font); letter-spacing: .5px; outline: none;
}
.field textarea { resize: vertical; min-height: 80px; }
.field select { padding-right: 48px; cursor: pointer; }
.field select option { background: var(--surface-container-high); color: var(--on-surface); }
.field.select::after {
  content: "expand_more"; font-family: "Material Symbols Outlined"; font-size: 24px; line-height: 1; font-feature-settings: "liga";
  position: absolute; right: 12px; top: 16px; pointer-events: none; color: var(--on-surface-variant);
  width: 1em; height: 1em; overflow: hidden;   /* never spill text if the icon font lacks the glyph */
}
.field :is(input, select, textarea):hover { border-color: var(--on-surface); }
.field :is(input, select, textarea):focus { border: 2px solid var(--primary); padding: 14px 15px; }
.field:focus-within > span { color: var(--primary); }
.field ::placeholder { color: var(--on-surface-variant); opacity: .7; }
.field :disabled { opacity: .5; }

/* Sliders */
.slider { margin: 20px 0 8px; }
.slider-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.slider-head label { color: var(--on-surface-variant); }
.slider-head b { font: 500 14px/20px var(--font); color: var(--primary); }
input[type="range"] {
  --p: 50%; -webkit-appearance: none; appearance: none; display: block; width: 100%; height: 28px; margin: 4px 0 0;
  background: none; cursor: pointer;
}
input[type="range"]:focus-visible { outline: none; }
input[type="range"]::-webkit-slider-runnable-track {
  height: 4px; border-radius: 2px; background: linear-gradient(to right, var(--primary) var(--p), var(--secondary-container) var(--p));
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 20px; height: 20px; margin-top: -8px; border: 0; border-radius: 50%;
  background: var(--primary); box-shadow: 0 0 0 0 color-mix(in srgb, var(--primary) 20%, transparent); transition: box-shadow .15s;
}
input[type="range"]:hover::-webkit-slider-thumb { box-shadow: 0 0 0 10px color-mix(in srgb, var(--primary) 10%, transparent); }
input[type="range"]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 10px color-mix(in srgb, var(--primary) 20%, transparent); }
input[type="range"]::-moz-range-track { height: 4px; border-radius: 2px; background: var(--secondary-container); }
input[type="range"]::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--primary); }
input[type="range"]::-moz-range-thumb { width: 20px; height: 20px; border: 0; border-radius: 50%; background: var(--primary); }

/* ---- Cards, lists, notes ------------------------------------------------------ */
.card { border-radius: 12px; padding: 16px; margin: 0 0 12px; }
.card.filled { background: var(--surface-container-highest); }
.card.outlined { border: 1px solid var(--outline-variant); }
.card h4 { font: 500 16px/24px var(--font); letter-spacing: .15px; margin: 8px 0 4px; }
.card p { color: var(--on-surface-variant); margin-bottom: 16px; }
.card p:last-child { margin-bottom: 0; }
.card-icon { color: var(--primary); }

.list { list-style: none; margin: 8px -24px 0; padding: 0; }
.list-item {
  display: flex; align-items: center; gap: 16px; width: 100%; min-height: 72px; padding: 8px 24px;
  border: 0; background: none; color: inherit; text-align: left; cursor: pointer; font: inherit;
}
.li-lead { width: 40px; height: 40px; border-radius: 20px; display: grid; place-items: center; flex: none;
  background: var(--primary-container); color: var(--on-primary-container); }
.li-text { flex: 1; min-width: 0; }
.li-text b { display: block; font: 400 16px/24px var(--font); letter-spacing: .5px; }
.li-text small { display: block; font-size: 14px; color: var(--on-surface-variant); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.li-trail { font: 500 12px/16px var(--font); color: var(--on-surface-variant); white-space: nowrap; }

.note { display: flex; gap: 12px; align-items: flex-start; padding: 12px 16px; border-radius: 12px; margin: 0 0 12px;
  background: var(--secondary-container); color: var(--on-secondary-container); }
.note .ms { font-size: 20px; }
.note.warn { background: var(--warn-container); color: var(--on-warn-container); }
.note.err { background: var(--error-container); color: var(--on-error-container); }
.hint { display: flex; gap: 8px; align-items: flex-start; margin: 12px 0 0; font-size: 12px; line-height: 16px; color: var(--on-surface-variant); }
.hint .ms { font-size: 16px; }
.badge { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px;
  background: var(--secondary-container); color: var(--on-secondary-container); font: 500 11px/1 var(--font); }
.badge:empty { display: none; }

/* ---- Filters pane ------------------------------------------------------------- */
#cat-manager { margin: 12px 0 0; padding: 8px 16px 12px; }
#cat-edit { list-style: none; margin: 0; padding: 0; }
#cat-edit li { display: flex; align-items: center; gap: 8px; padding: 8px 0; flex-wrap: wrap; border-bottom: 1px solid var(--outline-variant); }
#cat-edit .field { margin: 8px 0 0; flex: 1 1 100%; order: 3; }
#cat-edit .field input { min-height: 40px; padding: 8px 12px; font-size: 14px; }
#cat-edit .field input:focus { padding: 7px 11px; }
#cat-add { align-items: center; }
#cat-add .field { margin: 16px 0 0; }
#cat-add .btn { margin-top: 16px; height: 56px; border-radius: 28px; }
.swatches { display: flex; gap: 6px; flex: 1; }
.swatch { width: 28px; height: 28px; border-radius: 50%; border: 0; padding: 0; cursor: pointer; display: grid; place-items: center; color: #fff; }
.swatch .ms { font-size: 18px; }
.swatch:disabled { opacity: .18; cursor: default; }

/* ---- Nearby pane -------------------------------------------------------------- */
#nearest-note { margin-top: 12px; }

/* ---- Route pane --------------------------------------------------------------- */
.route-ends { display: grid; grid-template-columns: 1fr auto; gap: 12px 8px; align-items: center; padding: 12px 8px 12px 16px; position: relative; }
.route-ends .end { grid-column: 1; display: flex; align-items: center; gap: 12px; min-width: 0; }
.route-ends .end small { display: block; font-size: 12px; line-height: 16px; color: var(--on-surface-variant); }
.route-ends .end span:not(.pin) { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 16px; line-height: 24px; }
.route-ends .end span.muted { font-size: 14px; }
.route-ends #route-swap { grid-column: 2; grid-row: 1 / span 2; }
.route-ends::before { content: ""; position: absolute; left: 27px; top: 38px; bottom: 38px; border-left: 2px dotted var(--outline); }
.pin {
  display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; flex: none; position: relative; z-index: 1;
  font: 700 11px/1 var(--font); letter-spacing: 0; color: #fff; background: var(--route);
}
.pin.a { background: var(--pin-a); } .pin.b { background: var(--pin-b); }
.row:has(#route-go) { margin-top: 20px; }
#route-result { margin-top: 20px; }
#route-result:empty { display: none; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.stat { background: var(--surface-container-highest); border-radius: 12px; padding: 12px; }
.stat .ms { color: var(--primary); font-size: 20px; }
.stat b { display: block; font: 400 22px/28px var(--font); margin-top: 4px; }
.stat small { color: var(--on-surface-variant); font-size: 12px; line-height: 16px; }
.timeline { list-style: none; margin: 8px -24px 0; padding: 0; }
.timeline li { position: relative; }
.timeline li::before { content: ""; position: absolute; left: 35px; top: 0; bottom: 0; border-left: 2px solid var(--outline-variant); }
.timeline li:first-child::before { top: 50%; }
.timeline li:last-child::before { bottom: 50%; }
.timeline .list-item { min-height: 48px; padding: 4px 24px; gap: 12px; }
.timeline .t { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.timeline .d { font: 500 12px/16px var(--font); color: var(--on-surface-variant); white-space: nowrap; }
.route-pin { display: grid; place-items: center; border-radius: 50%; color: #fff; border: 2px solid #fff;
  font: 700 11px/1 var(--font); box-shadow: 0 1px 4px rgba(0,0,0,.4); }

/* ---- Bench sheet -------------------------------------------------------------- */
.b-icon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; flex: none;
  background: var(--primary-container); color: var(--on-primary-container); }
.b-icon .ms { font-variation-settings: "FILL" 1, "wght" 400, "GRAD" 0, "opsz" 24; }
.colour-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
#b-colour-val { display: inline-flex; align-items: center; gap: 8px; }
.sw { width: 20px; height: 20px; border-radius: 50%; border: 1px solid var(--outline-variant); flex: none; }
.colour-pick { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin: 12px 0 0; }
.colour-pick button {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 2px; border-radius: 12px;
  border: 1px solid var(--outline-variant); background: none; color: var(--on-surface); font: 400 11px/14px var(--font); cursor: pointer;
}
.colour-pick .sw { width: 28px; height: 28px; }
.colour-pick .n { color: var(--primary); font-weight: 500; }
#b-info { display: grid; grid-template-columns: auto 1fr; gap: 0; margin: 0; border-radius: 12px; overflow: hidden; background: var(--surface-container-highest); }
#b-info dt, #b-info dd { padding: 10px 16px; border-bottom: 1px solid var(--surface-container-low); }
#b-info dt { color: var(--on-surface-variant); padding-right: 8px; }
#b-info dd { margin: 0; overflow-wrap: anywhere; }
#b-info dt:nth-last-child(2), #b-info dd:last-child { border-bottom: 0; }
#b-info:empty { display: none; }
.src { color: var(--on-surface-variant); font-size: 12px; line-height: 16px; margin-top: 8px; }

.photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; border-radius: 12px; overflow: hidden; }
.photos figure { position: relative; margin: 0; aspect-ratio: 1; background: var(--surface-container-highest); }
.photos img { width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; display: block; }
.photos .icon-btn { position: absolute; top: 4px; right: 4px; width: 32px; height: 32px; background: rgba(0,0,0,.55); color: #fff; }
.photos .icon-btn .ms { font-size: 18px; }
.photos:empty { display: none; }
#b-photos:empty + #b-upload::before { content: "No photos yet."; display: block; color: var(--on-surface-variant); margin-bottom: 12px; }
#b-upload { margin-top: 12px; }
label.file { cursor: pointer; }
label.file input { position: absolute; opacity: 0; width: 1px; height: 1px; }
label.file:focus-within { outline: 3px solid var(--primary); outline-offset: 2px; }

#b-comments { list-style: none; margin: 0; padding: 0; }
#b-comments:empty::before { content: "No comments yet – be the first."; color: var(--on-surface-variant); }
#b-comments li { display: flex; gap: 12px; padding: 8px 0; }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--tertiary-container); color: var(--on-tertiary-container); font: 500 14px/1 var(--font); }
#b-comments .who { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--on-surface-variant); }
#b-comments .who b { color: var(--on-surface); font: 500 14px/20px var(--font); }
#b-comments .who .icon-btn { margin-left: auto; width: 32px; height: 32px; margin-top: -6px; }
#b-comments .who .icon-btn .ms { font-size: 18px; }
#b-comments .text { white-space: pre-wrap; overflow-wrap: anywhere; }
.comment-box { display: flex; align-items: flex-end; gap: 8px; }
.comment-box .field { margin-bottom: 0; }
.comment-box .icon-btn { width: 48px; height: 48px; border-radius: 24px; margin-bottom: 4px; }

/* ---- Snackbar, dialog, lightbox ----------------------------------------------- */
#snackbar {
  position: absolute; z-index: 1300; left: 50%; bottom: 16px; transform: translate(-50%, 16px); opacity: 0; pointer-events: none;
  width: max-content; max-width: min(560px, calc(100% - 32px)); min-height: 48px; display: flex; align-items: center; gap: 8px;
  padding: 14px 16px; border-radius: 4px; background: var(--inverse-surface); color: var(--inverse-on-surface);
  box-shadow: var(--elev3); transition: opacity .2s var(--ease), transform .25s var(--ease), bottom .3s var(--ease);
}
#snackbar.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
#snackbar.err .text::before { content: "warning"; font-family: "Material Symbols Outlined"; font-size: 20px; vertical-align: -5px; margin-right: 8px; color: var(--error); font-feature-settings: "liga"; }

dialog#confirm {
  border: 0; padding: 24px; border-radius: 28px; width: min(400px, calc(100% - 48px));
  background: var(--surface-container-high); color: var(--on-surface); box-shadow: var(--elev3);
}
dialog#confirm::backdrop { background: rgba(0,0,0,.32); }
dialog#confirm .dlg-icon { display: block; margin: 0 auto 16px; color: var(--primary); }
dialog#confirm h2 { font: 400 24px/32px var(--font); text-align: center; margin-bottom: 16px; }
dialog#confirm p { color: var(--on-surface-variant); margin-bottom: 24px; }
dialog#confirm .row { margin-right: -12px; }

#lightbox { position: fixed; inset: 0; z-index: 2000; background: rgba(0,0,0,.9); display: flex;
  flex-direction: column; align-items: center; justify-content: center; padding: 24px; }
#lightbox img { max-width: 100%; max-height: calc(100% - 60px); object-fit: contain; border-radius: 4px; }
#lightbox p { color: #eee; margin: 12px 0 0; text-align: center; }
#lightbox .icon-btn { position: absolute; top: 12px; right: 12px; color: #fff; }

/* ---- Leaflet overrides -------------------------------------------------------- */
.leaflet-container { font: inherit; }
.leaflet-bar { border: 0 !important; border-radius: 12px !important; overflow: hidden; box-shadow: var(--elev2) !important; }
.leaflet-bar a, .leaflet-bar a:hover {
  width: 40px !important; height: 40px !important; line-height: 40px !important; font-size: 20px !important;
  background: var(--surface-container-high); color: var(--on-surface); border-color: var(--outline-variant) !important;
}
.leaflet-bar a:hover { background: var(--surface-container-highest); }
.leaflet-control-attribution { font-size: 10px; background: color-mix(in srgb, var(--surface) 85%, transparent) !important; color: var(--on-surface-variant); }
.leaflet-control-attribution a { color: var(--primary); }
.leaflet-tooltip { background: var(--inverse-surface); color: var(--inverse-on-surface); border: 0; border-radius: 4px; box-shadow: var(--elev1); font-size: 12px; }
.leaflet-tooltip-top::before { border-top-color: var(--inverse-surface); }
.leaflet-tooltip-bottom::before { border-bottom-color: var(--inverse-surface); }
.leaflet-tooltip-left::before { border-left-color: var(--inverse-surface); }
.leaflet-tooltip-right::before { border-right-color: var(--inverse-surface); }
.leaflet-right { transition: right .3s var(--ease); }
.marker-cluster-small, .marker-cluster-medium, .marker-cluster-large { background: color-mix(in srgb, var(--primary) 30%, transparent); }
.marker-cluster-small div, .marker-cluster-medium div, .marker-cluster-large div { background: var(--primary); color: var(--on-primary); font: 500 12px/30px var(--font); }
@media (prefers-color-scheme: dark) { .leaflet-tile-pane { filter: brightness(.75) contrast(1.1) saturate(.8); } }
.picking { cursor: crosshair !important; }

/* ---------- Bench QR code ---------- */
.row.wrap { flex-wrap: wrap; }
.qr-card { display: flex; gap: 16px; align-items: flex-start; padding: 16px; border-radius: 12px; background: var(--surface-container-highest); }
.qr { flex: none; width: 128px; height: 128px; padding: 8px; border-radius: 8px; background: #fff; box-sizing: content-box; }
.qr svg { display: block; width: 100%; height: 100%; }
.qr-side { min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.qr-text { margin: 0; color: var(--on-surface-variant); font-size: 14px; line-height: 20px; }
.qr-link { font-size: 12px; line-height: 16px; color: var(--primary); overflow-wrap: anywhere; }
.qr-side .row { margin-left: -4px; }
@media (max-width: 380px) {
  .qr-card { flex-direction: column; align-items: center; text-align: center; }
  .qr-side .row { justify-content: center; margin-left: 0; }
}

/* ---------- Grouped benches ---------- */
.gm-icon { background: none; border: 0; }
.gm {
  width: 100%; height: 100%; box-sizing: border-box; border-radius: 50%;
  display: grid; place-items: center; cursor: pointer;
  background: var(--f); border: 3px solid var(--r); box-shadow: 0 1px 4px rgb(0 0 0 / .35);
  color: #fff; font: 700 12px/1 var(--font); text-shadow: 0 0 2px rgb(0 0 0 / .6);
  transition: opacity .15s;
}
.gm.open { opacity: .25; }
.gm-icon:has(> .gm.open) { pointer-events: none; }
.b-group { margin-top: 4px; padding: 12px 16px; border-radius: 12px; background: var(--secondary-container); color: var(--on-secondary-container); }
.b-group p { margin: 0 0 10px; display: flex; gap: 8px; align-items: flex-start; font-size: 14px; line-height: 20px; }
.b-group p .ms { font-size: 20px; }
.gnums { display: flex; flex-wrap: wrap; gap: 6px; }
.gnum {
  min-width: 32px; height: 32px; padding: 0 8px; border-radius: 16px; cursor: pointer;
  border: 1px solid var(--outline); background: transparent; color: inherit; font: 500 14px/1 var(--font);
}
.gnum:hover { box-shadow: inset 0 0 0 100vmax color-mix(in srgb, currentColor 8%, transparent); }
.gnum[aria-current="true"] { background: var(--primary); color: var(--on-primary); border-color: transparent; }

/* ---------- Route types ---------- */
.route-profiles { margin-top: 16px; }
.route-profiles .chip .ms:not(.chk) { color: var(--primary); }
.route-profiles .chip:has(input:checked) .ms { color: inherit; }
.profile-desc { margin: 8px 0 0; color: var(--on-surface-variant); font-size: 12px; line-height: 16px; }
.mix { background: var(--surface-container-highest); border-radius: 12px; padding: 12px 16px; margin-bottom: 12px; }
.mix-title { margin: 0 0 8px; font: 500 14px/20px var(--font); }
.mix-row { display: grid; grid-template-columns: 20px 1fr 72px 40px; gap: 8px; align-items: center; font-size: 13px; line-height: 24px; }
.mix-row .ms { font-size: 18px; color: var(--primary); }
.mix-row .bar { height: 6px; border-radius: 3px; background: var(--surface-container-low); overflow: hidden; }
.mix-row .bar i { display: block; height: 100%; border-radius: 3px; background: var(--primary); }
.mix-row b { text-align: right; font-weight: 500; }
.sub-h { font: 500 14px/20px var(--font); color: var(--on-surface-variant); margin: 16px 0 8px; }
.li-lead.sight .ms { color: #b8860b; }

/* ---------- Sun & shade ---------- */
:root { --sun: #b87400; --sun-wash: #f6d48a; --shade: #c3c8c1; --grid: #e2e6e0; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --sun: #f0b44a; --sun-wash: #6b4b0f; --shade: #4a524c; --grid: #2c3430; }
}
:root[data-theme="dark"] { --sun: #f0b44a; --sun-wash: #6b4b0f; --shade: #4a524c; --grid: #2c3430; }
.sun-card { position: relative; padding: 12px 16px 12px; border-radius: 12px; background: var(--surface-container-highest); }
.sun-days { margin-bottom: 8px; }
.sun-days .chip { height: 32px; }
.sun-summary { margin: 0 0 12px; font-size: 14px; line-height: 20px; }
.sun-summary b { font-weight: 500; }
.sun-title { margin: 0 0 4px; font-size: 12px; line-height: 16px; color: var(--on-surface-variant); }
.sun-chart { position: relative; min-height: 150px; }
.sun-chart svg { display: block; width: 100%; overflow: visible; }
.sun-chart text { font: 400 11px var(--font); fill: var(--on-surface-variant); }
.sun-chart .grid { stroke: var(--grid); stroke-width: 1; }
.sun-chart .col { fill: var(--sun); }
.sun-chart .hit { fill: transparent; cursor: pointer; }
.sun-chart .hit:hover + .col, .sun-chart .col.on { fill: color-mix(in srgb, var(--sun) 80%, var(--on-surface)); }
.sun-chart .strip-up { fill: var(--shade); }
.sun-chart .strip-sun { fill: var(--sun); }
.sun-chart .now { stroke: var(--on-surface); stroke-width: 1; }
.sun-chart .now-lbl { fill: var(--on-surface); font-weight: 500; }
.sun-tip {
  position: absolute; top: 0; z-index: 2; pointer-events: none; transform: translateX(-50%);
  background: var(--inverse-surface, #2e312f); color: var(--inverse-on-surface, #eff1ed);
  border-radius: 8px; padding: 6px 10px; font-size: 12px; line-height: 16px; white-space: nowrap;
}
.sun-legend { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 8px; font-size: 12px; line-height: 16px; color: var(--on-surface-variant); }
.sun-legend .sw { display: inline-block; width: 12px; height: 6px; border-radius: 3px; margin-right: 6px; vertical-align: middle; }
.sun-legend .sw.sun { background: var(--sun); }
.sun-legend .sw.shade { background: var(--shade); }
.sun-table { margin-top: 8px; font-size: 12px; }
.sun-table summary { cursor: pointer; color: var(--primary); font-weight: 500; }
.sun-table table { width: 100%; border-collapse: collapse; margin-top: 6px; }
.sun-table th, .sun-table td { text-align: right; padding: 3px 4px; border-bottom: 1px solid var(--grid); }
.sun-table th:first-child, .sun-table td:first-child { text-align: left; }
.sun-table th { color: var(--on-surface-variant); font-weight: 500; }

/* ---------- Point-of-interest layers ---------- */
/* Street level (zoom >= 15): 24 px emoji badge. Further out: 8 px dot in the layer colour. */
.poi-icon { background: none; border: 0; width: 24px; height: 24px; margin: -12px 0 0 -12px; }
.poi-pin {
  --poi: #c2571a;
  display: grid; place-items: center; width: 100%; height: 100%; border-radius: 50%; box-sizing: border-box;
  background: #fff; border: 2px solid var(--poi); box-shadow: 0 1px 3px rgb(0 0 0 / .3);
  font-size: 13px; line-height: 1; cursor: pointer;
}
.poi-pin.fire { --poi: #8a5a9e; }
.poi-pin.toilets { --poi: #1a73e8; }
.poi-far .poi-icon { width: 8px; height: 8px; margin: -4px 0 0 -4px; }
.poi-far .poi-icon::after { content: ""; position: absolute; inset: -6px; }   /* bigger tap target */
.poi-far .poi-pin { font-size: 0; background: var(--poi); border: 1.5px solid #fff; box-shadow: 0 0 2px rgb(0 0 0 / .4); }
.amen-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 12px; }
.amen-row .chip .emoji { margin-left: -6px; }
.chip .emoji { font-size: 16px; margin-left: -4px; }
.poi-pop .t { margin: 0; font: 500 15px/20px var(--font); }
.poi-pop .w { margin: 2px 0 6px; color: var(--on-surface-variant); font-size: 13px; }
.poi-pop ul { margin: 0 0 10px; padding-left: 18px; font-size: 13px; line-height: 18px; }
.poi-pop .s { margin: 8px 0 0; color: var(--on-surface-variant); font-size: 11px; line-height: 15px; }
.leaflet-popup-content-wrapper { background: var(--surface-container-high, #fff); color: var(--on-surface); border-radius: 16px; }
.leaflet-popup-tip { background: var(--surface-container-high, #fff); }
.leaflet-popup-content { margin: 14px 16px; }

/* ---------- My start & saved routes ---------- */
.chip.assist.on { background: var(--secondary-container); color: var(--on-secondary-container); border-color: transparent; }
.chip.assist.on .ms { font-variation-settings: "FILL" 1, "wght" 400, "GRAD" 0, "opsz" 24; }
.saved-routes h3 { margin-top: 4px; }
.saved-item { display: flex; align-items: center; gap: 4px; }
.saved-item .list-item { flex: 1; min-width: 0; }
.saved-item .list-item:disabled { opacity: .6; }
.saved-item .li-text small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.save-row { margin-bottom: 12px; }
#route-save.on .ms { font-variation-settings: "FILL" 1, "wght" 400, "GRAD" 0, "opsz" 24; }
.rename-form { display: flex; align-items: center; gap: 4px; width: 100%; padding: 4px 0; }
.rename-form .field { margin: 0; }

/* ---------- Loading indicators ---------- */
.progress { position: absolute; top: 0; left: 0; right: 0; height: 4px; z-index: 1100; overflow: hidden;
  background: color-mix(in srgb, var(--primary) 24%, transparent); pointer-events: none; }
.progress .bar { position: absolute; top: 0; bottom: 0; width: 40%; background: var(--primary); border-radius: 2px;
  animation: progress-slide 1.1s cubic-bezier(.4, 0, .2, 1) infinite; }
@keyframes progress-slide { from { left: -40%; } to { left: 100%; } }
.spin-icon { background: none; border: 0; }
.spinner { display: block; width: 28px; height: 28px; box-sizing: border-box; border-radius: 50%;
  border: 3px solid color-mix(in srgb, var(--primary) 25%, #fff); border-top-color: var(--primary);
  background: color-mix(in srgb, var(--surface) 70%, transparent); box-shadow: 0 1px 4px rgb(0 0 0 / .3);
  animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .progress .bar { animation-duration: 3s; }
  .spinner { animation-duration: 2.4s; }
}

/* ---------- Language switcher ---------- */
.lang-btn { display: inline-flex; align-items: center; gap: 4px; height: 32px; padding: 0 8px 0 6px; margin-left: 4px;
  border: 0; border-radius: 16px; background: none; color: var(--on-surface-variant); font: 500 12px/1 var(--font);
  cursor: pointer; pointer-events: auto; }
.lang-btn .ms { font-size: 18px; }
.lang-btn:hover { box-shadow: inset 0 0 0 100vmax color-mix(in srgb, currentColor 8%, transparent); }
.lang-menu { position: absolute; top: calc(100% + 6px); right: 0; min-width: 160px; padding: 8px 0; z-index: 1200;
  border-radius: 4px; background: var(--surface-container); color: var(--on-surface); pointer-events: auto;
  box-shadow: 0 2px 6px rgb(0 0 0 / .15), 0 1px 2px rgb(0 0 0 / .3); }
.lang-menu button { display: flex; align-items: center; gap: 12px; width: 100%; height: 48px; padding: 0 16px 0 12px;
  border: 0; background: none; color: inherit; font: 400 14px/20px var(--font); text-align: left; cursor: pointer; }
.lang-menu button:hover, .lang-menu button:focus-visible { background: color-mix(in srgb, var(--on-surface) 8%, transparent); outline: 0; }
.lang-menu .ms { font-size: 20px; width: 20px; color: var(--primary); }

/* ---------- My settings ---------- */
.me-btn { margin-left: 0; padding: 0 6px; }
.prefs { display: grid; gap: 16px; margin: 4px 0 8px; }
.prefs .field { margin: 0; }
.muted.small, .small { font-size: 13px; line-height: 18px; }
.btn.danger { color: var(--error); border-color: var(--error); }
.switch { display: flex; align-items: center; gap: 12px; cursor: pointer; font-size: 14px; position: relative; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { position: relative; width: 52px; height: 32px; border-radius: 16px; background: var(--surface-container-highest);
  border: 2px solid var(--outline); box-sizing: border-box; transition: background .15s; flex: none; }
.switch .track::after { content: ""; position: absolute; top: 6px; left: 6px; width: 16px; height: 16px; border-radius: 50%;
  background: var(--outline); transition: transform .15s, width .15s, height .15s, background .15s; }
.switch input:checked + .track { background: var(--primary); border-color: var(--primary); }
.switch input:checked + .track::after { transform: translate(18px, -4px); width: 24px; height: 24px; background: var(--on-primary); }
.switch input:focus-visible + .track { outline: 3px solid var(--primary); outline-offset: 2px; }
/* plain text lines inside edge-to-edge lists (empty states) line up with the rest of the panel */
.list > li:not(:has(.list-item)) { padding: 4px 24px; }

/* ---------- Walking directions card ---------- */
.walk-card {
  position: absolute; z-index: 1000; left: 12px; top: calc(max(12px, env(safe-area-inset-top)) + 56px);
  display: flex; align-items: center; gap: 12px; max-width: min(420px, calc(100% - 24px)); box-sizing: border-box;
  padding: 6px 4px 6px 14px; border-radius: 16px; background: var(--surface-container-high); color: var(--on-surface);
  box-shadow: var(--elev2);
}
.walk-card .emoji { font-size: 22px; line-height: 1; }
.walk-card .title { display: block; font: 500 14px/20px var(--font); }
.walk-card .sub { display: block; color: var(--on-surface-variant); font-size: 12px; line-height: 16px; }
