:root {
  --primary: #075985;
  --primary-press: #0c4a6e;
  --on-primary: #fff;
  --go: #15803d;
  --go-press: #166534;
  --bg: #f0f9ff;
  --card: #ffffff;
  --fg: #0b2537;
  --muted: #3f5466;
  --line: #9fb6c7;
  --soft: #e3eef6;
  --focus: #f59e0b;
  --s-unchecked: #075985;
  --s-confirmed: #15803d;
  --s-notfound: #b91c1c;
  --s-noaccess: #b45309;
  --s-unsure: #6d28d9;
  --radius: 14px;
  --shadow: 0 6px 24px rgba(4, 30, 50, .18);
  color-scheme: light;
}
html { font-size: 18px; }
html[data-size="2"] { font-size: 21px; }
html[data-size="3"] { font-size: 24px; }
* { box-sizing: border-box; }
body {
  margin: 0; height: 100dvh; display: flex; flex-direction: column; overflow: hidden;
  font-family: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 1rem; line-height: 1.5; color: var(--fg); background: var(--bg);
}
h1, h2, h3 { margin: 0; line-height: 1.2; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.15rem; margin-top: 1.2rem; }
p { margin: .4rem 0; }
svg { flex: none; }
button, input, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 4px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
.skip { position: absolute; left: -999px; top: 0; background: #fff; padding: .6rem 1rem; z-index: 3000; }
.skip:focus { left: .5rem; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: 56px; padding: .6rem 1rem; border-radius: var(--radius); border: 2px solid transparent;
  font-weight: 700; font-size: 1rem; text-decoration: none; cursor: pointer; text-align: center;
  transition: background-color .15s ease, transform .1s ease;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(.98); }
.btn svg { width: 1.4em; height: 1.4em; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.btn-primary { background: var(--go); color: #fff; }
.btn-primary:hover { background: var(--go-press); }
.btn-secondary { background: var(--card); color: var(--primary); border-color: var(--primary); }
.btn-secondary:hover { background: var(--soft); }
.btn-ghost { background: transparent; color: inherit; border-color: currentColor; }
.btn-icon { min-width: 56px; padding: .5rem; }
.btn-big { min-height: 64px; font-size: 1.15rem; }
.btn[disabled] { opacity: .6; cursor: wait; }

/* Header */
.top { background: var(--primary); color: var(--on-primary); padding: .6rem 1rem .5rem; padding-top: max(.6rem, env(safe-area-inset-top)); z-index: 1000; }
.top-row { display: flex; align-items: center; justify-content: space-between; gap: .75rem; }
.brand { display: flex; align-items: center; gap: .6rem; color: #fff; }
.brand svg { color: #0c4a6e; }
.brand h1 { font-size: 1.3rem; }
.hello { margin: 0; font-size: .9rem; opacity: .95; }
.top .btn-ghost { min-height: 48px; color: #fff; }
.progress { margin-top: .4rem; }
.progress p { margin: .2rem 0 0; font-size: .95rem; font-weight: 700; }
.bar { height: 14px; border-radius: 99px; background: rgba(255, 255, 255, .25); overflow: hidden; }
.bar span { display: block; height: 100%; width: 0; background: #86efac; border-radius: 99px; transition: width .4s ease; }

/* Map */
main { position: relative; flex: 1; min-height: 0; }
#map { position: absolute; inset: 0; background: #dfe9ef; }
.leaflet-container { font: inherit; }
.leaflet-control-zoom a { width: 48px !important; height: 48px !important; line-height: 46px !important; font-size: 26px !important; }
.legend-toggle {
  position: absolute; top: .75rem; left: .75rem; z-index: 800; min-height: 48px; padding: .4rem .9rem;
  background: var(--card); color: var(--fg); border: 2px solid var(--fg); border-radius: 99px; font-weight: 700; cursor: pointer; box-shadow: var(--shadow);
}
.legend {
  position: absolute; top: 4.2rem; left: .75rem; z-index: 800; background: var(--card); border-radius: var(--radius);
  padding: .6rem .9rem; box-shadow: var(--shadow); list-style: none; margin: 0; max-width: calc(100% - 1.5rem);
}
.legend div { display: flex; align-items: center; gap: .6rem; padding: .2rem 0; }
.net {
  position: absolute; bottom: .75rem; left: 50%; transform: translateX(-50%); z-index: 800; background: #fef3c7; color: #713f12;
  border: 2px solid #b45309; border-radius: 99px; padding: .4rem 1rem; font-weight: 700; white-space: nowrap; max-width: calc(100% - 1.5rem); overflow: hidden; text-overflow: ellipsis;
}

/* Pins */
.pin {
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--c); color: #fff;
  border: 3px solid #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, .45); transition: transform .15s ease;
}
.pin svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.pin.todo { background: #fff; color: var(--s-unchecked); border-color: var(--s-unchecked); }
.pin.stop { border-radius: 10px; }
.pin.sel { transform: scale(1.35); box-shadow: 0 0 0 5px var(--focus), 0 2px 8px rgba(0, 0, 0, .5); }
.pin-num { font-weight: 700; font-size: 13px; letter-spacing: -.02em; }
.swatch { width: 30px; height: 30px; border-width: 2px; box-shadow: none; }
.swatch svg { width: 16px; height: 16px; }
.me { width: 22px; height: 22px; border-radius: 50%; background: #2563eb; border: 4px solid #fff; box-shadow: 0 0 0 3px rgba(37, 99, 235, .35); }

/* Bottom action bar */
.actions {
  display: grid; grid-template-columns: 1fr 1.4fr 1fr; gap: .6rem; padding: .7rem;
  padding-bottom: max(.7rem, env(safe-area-inset-bottom)); background: var(--card); border-top: 2px solid var(--line); z-index: 1000;
}
.actions .btn { flex-direction: column; gap: .15rem; font-size: .95rem; line-height: 1.15; padding: .5rem .3rem; }
.actions .btn-big { font-size: 1.1rem; }

/* Bench card */
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; max-height: 66dvh; z-index: 1500; display: flex; flex-direction: column;
  background: var(--card); border-radius: 22px 22px 0 0; box-shadow: 0 -8px 30px rgba(4, 30, 50, .3);
  animation: up .25s ease-out;
}
@keyframes up { from { transform: translateY(30px); opacity: 0; } }
.sheet-head { display: flex; justify-content: space-between; align-items: flex-start; gap: .75rem; padding: 1rem 1rem .6rem; border-bottom: 2px solid var(--soft); }
.sheet-head h2 { font-size: 1.9rem; }
.sheet-head .btn-ghost { color: var(--fg); }
.eyebrow { margin: 0; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; font-size: .85rem; }
.meta { margin: .2rem 0 0; color: var(--muted); }
.sheet-body { overflow-y: auto; padding: .8rem 1rem; padding-bottom: max(1rem, env(safe-area-inset-bottom)); overscroll-behavior: contain; }
.hint { border-left: 6px solid var(--s-noaccess); background: #fff7ed; padding: .6rem .8rem; border-radius: 8px; margin: 0 0 .8rem; }
.hint.info { border-color: var(--primary); background: var(--soft); }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.q { border: 0; padding: 0; margin: 1.1rem 0 0; min-width: 0; }
.q legend, .legend-like { display: block; font-weight: 700; font-size: 1.15rem; padding: 0; margin-bottom: .5rem; }
.opt { font-weight: 400; color: var(--muted); font-size: .95rem; }
.help { color: var(--muted); margin-top: -.2rem; }
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.choices.three { grid-template-columns: 1fr 1fr 1fr; }
.choice {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .25rem; min-height: 72px;
  border: 3px solid var(--line); border-radius: var(--radius); background: var(--card); padding: .5rem; cursor: pointer;
  font-weight: 700; text-align: center; line-height: 1.2;
}
.choice small { font-weight: 400; color: var(--muted); font-size: .85rem; }
.choice svg { width: 1.7em; height: 1.7em; fill: none; stroke: var(--c, var(--primary)); stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.choice[aria-pressed="true"] { border-color: var(--c, var(--primary)); background: var(--c, var(--primary)); color: #fff; }
.choice[aria-pressed="true"] small { color: #fff; }
.choice[aria-pressed="true"] svg { stroke: #fff; }
.chips { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: .6rem; }
.chip { min-height: 48px; padding: .3rem .9rem; border-radius: 99px; border: 2px solid var(--line); background: var(--soft); cursor: pointer; font-weight: 700; }
.chip:hover { border-color: var(--primary); }
.notes-wrap { display: flex; gap: .5rem; align-items: stretch; }
textarea, input[type="text"], input[type="search"] {
  width: 100%; min-height: 56px; padding: .7rem .8rem; border: 2px solid var(--muted); border-radius: 10px; background: #fff; font-size: 1rem;
}
textarea { resize: vertical; }
.mic { align-self: flex-start; }
.mic.on { background: var(--s-notfound); color: #fff; border-color: var(--s-notfound); }
.last { color: var(--muted); font-size: .95rem; }
.error { color: var(--s-notfound); font-weight: 700; margin: .3rem 0; }
.error:empty { display: none; }
.save-row { display: grid; gap: .6rem; margin-top: .6rem; }

/* Overlays */
.overlay { position: fixed; inset: 0; z-index: 2000; background: rgba(4, 22, 36, .55); display: flex; align-items: flex-end; justify-content: center; }
.overlay-box {
  background: var(--card); width: 100%; max-width: 640px; max-height: 92dvh; overflow-y: auto; border-radius: 22px 22px 0 0;
  padding: 1.2rem 1rem; padding-bottom: max(1.2rem, env(safe-area-inset-bottom)); animation: up .25s ease-out;
}
.overlay-box.narrow { max-width: 520px; }
.overlay-box.center { text-align: center; }
.overlay-head { display: flex; justify-content: space-between; align-items: center; gap: .75rem; margin-bottom: .8rem; }
.overlay-head .btn-ghost { color: var(--fg); }
#nameForm { display: grid; gap: .6rem; margin-top: 1rem; }
.tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; margin: .7rem 0; }
.tab { min-height: 52px; border: 2px solid var(--primary); border-radius: 12px; background: #fff; color: var(--primary); font-weight: 700; cursor: pointer; padding: .3rem; }
.tab[aria-pressed="true"] { background: var(--primary); color: #fff; }
.tab-lg { font-size: 1.15rem; }
.tab-xl { font-size: 1.3rem; }
.menu-list { display: grid; gap: .6rem; margin-top: 1rem; }
.mine { margin-top: 1rem; color: var(--muted); }
.bench-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.bench-list button {
  width: 100%; display: flex; align-items: center; gap: .8rem; min-height: 64px; padding: .5rem .8rem; text-align: left;
  border: 2px solid var(--line); border-radius: var(--radius); background: #fff; cursor: pointer;
}
.bench-list button:hover { border-color: var(--primary); }
.bench-list .pin { width: 36px; height: 36px; flex: none; }
.bench-list .t { flex: 1; min-width: 0; }
.bench-list .t strong { display: block; font-size: 1.1rem; }
.bench-list .t span { color: var(--muted); font-size: .92rem; }
.bench-list .d { font-weight: 700; color: var(--primary); white-space: nowrap; }
.steps { padding-left: 1.4rem; display: grid; gap: .6rem; margin: .5rem 0 1.2rem; }
.steps.plain { list-style: disc; }
.done-icon { width: 96px; height: 96px; fill: none; stroke: var(--go); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; margin: .5rem auto; display: block; }
.toast {
  position: fixed; left: 50%; top: 7.5rem; transform: translateX(-50%); z-index: 3000; background: var(--fg); color: #fff;
  padding: .8rem 1.3rem; border-radius: 14px; font-weight: 700; box-shadow: var(--shadow); max-width: calc(100% - 2rem); text-align: center;
}
.toast.ok { background: var(--go-press); }

/* Larger screens: card becomes a side panel so the map stays visible */
@media (min-width: 900px) {
  .sheet { left: auto; top: 0; width: 460px; max-height: none; border-radius: 0; box-shadow: -8px 0 30px rgba(4, 30, 50, .25); }
  .overlay { align-items: center; }
  .overlay-box { border-radius: 22px; }
  .actions { grid-template-columns: repeat(3, minmax(0, 260px)); justify-content: center; }
}
@media (max-width: 360px) {
  .choices.three { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
/* Zoomed out: smaller pins so the whole neighbourhood stays readable */
#map.far .pin:not(.swatch) { width: 22px; height: 22px; border-width: 2px; }
#map.far .pin .pin-num, #map.far .pin svg { display: none; }
#map.far .pin.sel { width: 40px; height: 40px; }
.pin-wrap { display: grid; place-items: center; }
.pin-input { font-size: 1.4rem; letter-spacing: .3em; }
