:root {
  color-scheme: dark;
  --bg: oklch(20% .016 220); --surface: oklch(25% .02 220); --raised: oklch(30% .022 220);
  --line: oklch(42% .025 220); --text: oklch(95% .008 220); --muted: oklch(78% .018 220);
  --accent: oklch(82% .1 200); --ink: oklch(19% .025 220); --error: oklch(82% .12 35);
  --radius: 12px; --small-radius: 8px; --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s6: 24px;
  --header-height: 80px; --panel-width: 360px; --motion: 180ms; --ease: cubic-bezier(.25,1,.5,1);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-family: var(--font); font-size: 16px; background: var(--bg); color: var(--text);
}
* { box-sizing: border-box; }
body { margin: 0; }
[hidden] { display: none !important; }
button, input, select, summary { font: inherit; }
button, input, select { border: 1px solid var(--line); border-radius: var(--small-radius); }
button, select, summary { cursor: pointer; }
button { min-height: 44px; padding: var(--s2) var(--s3); background: var(--raised); color: var(--text); font-size: .875rem; font-weight: 600; transition: background var(--motion) var(--ease), transform var(--motion) var(--ease); }
button:hover:not(:disabled) { background: var(--line); transform: translateY(-1px); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { cursor: wait; color: var(--muted); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
input:not([type=checkbox]), select { width: 100%; min-width: 0; min-height: 44px; padding: var(--s2) var(--s3); background: var(--bg); color: var(--text); font-size: 1rem; }
input::placeholder { color: var(--muted); }
input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--accent); flex: none; }
label { font-size: .875rem; font-weight: 600; }
h1, h2, p { margin: 0; }
h1 { font-size: 1.2rem; line-height: 1.2; }
h2 { font-size: 1.1rem; line-height: 1.3; }
p { line-height: 1.5; }
.full { width: 100%; }
.primary { background: var(--accent); color: var(--ink); border-color: var(--accent); }
.primary:hover:not(:disabled) { background: oklch(88% .09 200); }
.muted, .field-hint { color: var(--muted); font-size: .8125rem; line-height: 1.5; }
.status { font-size: .875rem; line-height: 1.5; color: var(--accent); overflow-wrap: anywhere; }
.status:empty { display: none; }
.error { color: var(--error) !important; }
.app-header { position: fixed; inset: 0 0 auto; height: var(--header-height); z-index: 1100; display: flex; align-items: center; justify-content: space-between; gap: var(--s4); padding: var(--s3) var(--s6); background: var(--bg); }
.brand-row { display: flex; align-items: baseline; gap: var(--s3); flex-wrap: wrap; }
.brand .tagline { margin-top: var(--s1); color: var(--muted); font-size: .8125rem; }
.maker { color: var(--accent); font-size: .8125rem; font-weight: 600; text-decoration: none; min-height: 44px; display: inline-flex; align-items: center; }
.maker:hover { text-decoration: underline; }
.app-header nav { display: flex; align-items: center; gap: var(--s2); }
.city-select { display: flex; align-items: center; gap: var(--s2); color: var(--muted); font-size: .8125rem; }
.city-select select { min-width: 7.5rem; }
.app-header button[aria-expanded=true] { color: var(--accent); border-color: var(--accent); }
.refresh-toggle { display: flex; align-items: center; gap: var(--s2); min-height: 44px; padding: var(--s2); font-size: .8125rem; white-space: nowrap; }
#map { position: fixed; inset: var(--header-height) 0 0; z-index: 0; background: var(--bg); }
.panel { position: fixed; top: calc(var(--header-height) + var(--s3)); bottom: var(--s3); width: var(--panel-width); z-index: 1000; display: flex; flex-direction: column; background: var(--surface); border-radius: var(--radius); overflow: hidden; }
.route-panel { left: var(--s3); }
.camera-panel { right: var(--s3); }
.panel-head, .viewer-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); padding: var(--s3) var(--s4); flex: none; background: var(--raised); }
.panel-head button { font-size: .8125rem; }
.panel-body { overflow: auto; padding: var(--s4); }
.intro { margin-bottom: var(--s4); }
.source-status { margin-bottom: var(--s4); }
.source-status button { margin-top: var(--s2); }
.place-field { margin-bottom: var(--s4); }
.input-row { display: flex; gap: var(--s2); margin-top: var(--s2); }
.field-tools { display: flex; align-items: center; gap: var(--s2); justify-content: space-between; margin-top: var(--s1); }
.field-tools .field-hint { flex: 1; }
.field-tools button { flex: none; font-size: .75rem; padding-inline: var(--s2); background: transparent; border-color: transparent; color: var(--accent); }
.place-results { padding: 0; margin: var(--s2) 0 0; list-style: none; border: 1px solid var(--line); border-radius: var(--small-radius); }
.place-results li + li { border-top: 1px solid var(--line); }
.place-results button { display: block; width: 100%; text-align: left; border: 0; border-radius: 0; background: transparent; }
.place-results span { display: block; }
.place-results .place-address { color: var(--muted); font-weight: 400; font-size: .8125rem; margin-top: var(--s1); }
#routeStatus { margin-top: var(--s3); }
#routeInfo { margin-top: var(--s4); border-top: 1px solid var(--line); padding-top: var(--s4); }
.route-endpoints { font-weight: 600; font-size: .875rem; margin-bottom: var(--s2); overflow-wrap: anywhere; }
.route-options { display: grid; margin-block: var(--s3); gap: var(--s2); }
.route-option { text-align: left; display: grid; gap: var(--s1); }
.route-option[aria-pressed=true] { border-color: var(--accent); background: var(--bg); }
.route-option strong { color: var(--accent); font-size: 1rem; font-variant-numeric: tabular-nums; }
.route-option small { color: var(--muted); font-weight: 400; line-height: 1.5; }
#routeCameraCount, #alternativesNote { margin-top: var(--s2); }
.action-row { display: flex; gap: var(--s2); align-items: center; margin-block: var(--s3); }
.action-row > button { flex: 1; }
#saveFavBtn { margin-bottom: var(--s3); }
details { margin-top: var(--s4); border-top: 1px solid var(--line); }
summary { min-height: 44px; padding-block: var(--s3); font-size: .875rem; }
.favorite-row { display: flex; gap: var(--s2); padding-block: var(--s2); }
.favorite-row .favorite-open { flex: 1; text-align: left; min-width: 0; overflow-wrap: anywhere; }
.favorite-row button:last-child { flex: none; }
.catalog-status { padding: var(--s3) var(--s4); font-size: .8125rem; color: var(--muted); border-bottom: 1px solid var(--line); }
.catalog-status button { margin-top: var(--s2); }
.camera-filters { padding: var(--s3) var(--s4); flex: none; }
.camera-filters input:not([type=checkbox]), .camera-filters select { margin-block: var(--s1) var(--s2); }
.camera-filters .action-row { margin-block: 0 var(--s2); }
.check-label { display: flex; align-items: center; gap: var(--s2); min-height: 44px; font-size: .8125rem; }
.camera-list { overflow: auto; min-height: 100px; flex: 1; }
.camera-row { display: flex; align-items: center; border-top: 1px solid var(--line); gap: var(--s2); padding: var(--s2) var(--s4); }
.camera-open { border: 0; background: transparent; padding: var(--s2) 0; text-align: left; flex: 1; min-width: 0; }
.camera-open span, .camera-open small { display: block; }
.camera-open small { color: var(--muted); font-weight: 400; margin-top: var(--s1); line-height: 1.5; }
.pin-button { min-width: 44px; padding-inline: var(--s2); }
.pin-button[aria-pressed=true] { color: var(--accent); border-color: var(--accent); }
.empty { padding: var(--s4); color: var(--muted); font-size: .875rem; line-height: 1.5; }
.more-button { flex: none; margin: var(--s2) var(--s4) var(--s3); }
.map-notice, .map-pick { position: fixed; z-index: 1050; top: calc(var(--header-height) + var(--s3)); left: 50%; transform: translateX(-50%); width: min(480px, calc(100% - 32px)); padding: var(--s3) var(--s4); background: var(--surface); border-radius: var(--radius); font-size: .875rem; }
.map-pick button { margin-top: var(--s2); margin-right: var(--s2); }
#map.picking { cursor: crosshair; }
.camera-marker { background: var(--surface); color: var(--text); border: 2px solid var(--text); border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 700; }
.camera-marker.along { background: var(--accent); color: var(--ink); border-color: var(--ink); }
.endpoint-marker { background: var(--bg); color: var(--accent); border: 2px solid var(--accent); border-radius: var(--small-radius); display: grid; place-items: center; font-weight: 700; }
.here-marker { background: var(--accent); border: 3px solid var(--text); border-radius: 50%; }
.locate-control { width: 44px; min-height: 44px; padding: var(--s1); font-size: .6875rem; line-height: 1.15; white-space: normal; background: var(--surface); color: var(--text); border: 0; border-radius: 2px; }
.locate-control:hover:not(:disabled) { background: var(--raised); color: var(--accent); transform: none; }
.here-popup p { margin-bottom: var(--s2); font-size: .875rem; }
.leaflet-container { font-family: var(--font); }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--surface); color: var(--text); box-shadow: none; }
.leaflet-popup-content-wrapper { border-radius: var(--radius); }
.leaflet-popup-content { margin: var(--s4); width: 280px !important; max-height: calc(100dvh - var(--header-height) - 96px); overflow: auto; }
.leaflet-container a.leaflet-popup-close-button { color: var(--text); width: 36px; height: 36px; padding: var(--s1); }
.leaflet-control-zoom a { background: var(--surface); color: var(--text); width: 44px; height: 44px; line-height: 44px; }
.leaflet-control-zoom a:hover { background: var(--raised); color: var(--accent); }
@media (min-width: 761px) { .camera-panel-open .leaflet-top.leaflet-right { margin-right: calc(var(--panel-width) + 24px); } }
.camera-view h3 { margin: 0 var(--s6) var(--s1) 0; font-size: .9375rem; line-height: 1.4; }
.camera-view .snapshot-frame { margin-top: var(--s3); background: var(--bg); border-radius: var(--small-radius); overflow: hidden; min-height: 160px; display: grid; place-items: center; }
.snapshot-frame img { display: block; width: 100%; max-height: 220px; object-fit: contain; }
.snapshot-frame .empty { text-align: center; }
.camera-view .status { margin-top: var(--s2); font-size: .8125rem; }
.camera-view .capture-note { margin-top: var(--s1); }
.camera-actions { display: flex; flex-wrap: wrap; gap: var(--s2); margin-top: var(--s3); }
.camera-actions button { flex: 1; font-size: .8125rem; }
#imageDialog { width: min(1000px, calc(100% - 32px)); max-height: calc(100dvh - 32px); padding: 0; background: var(--surface); color: var(--text); border: 0; border-radius: var(--radius); overflow: auto; }
#imageDialog::backdrop { background: oklch(12% .02 220 / .85); }
#imageContent { padding: var(--s4); }
#imageDialog .snapshot-frame img { max-height: 60dvh; }
#imageDialog .snapshot-frame { min-height: 200px; }
#liveDialog { width: min(1000px, calc(100% - 32px)); max-height: calc(100dvh - 32px); padding: 0; background: var(--surface); color: var(--text); border: 0; border-radius: var(--radius); overflow: auto; }
#liveDialog::backdrop { background: oklch(12% .02 220 / .85); }
#liveContent { padding: var(--s4); }
.live-frame { background: #000; border-radius: var(--small-radius); overflow: hidden; min-height: 200px; }
.live-frame video { display: block; width: 100%; max-height: 70dvh; background: #000; }
.skip-link { position: fixed; top: -100px; left: var(--s3); padding: var(--s3); background: var(--accent); color: var(--ink); z-index: 1200; }
.skip-link:focus { top: var(--s3); }
@media (max-width: 760px) {
  :root { --header-height: 120px; }
  .app-header { flex-direction: column; align-items: stretch; justify-content: center; gap: var(--s2); padding: var(--s2) var(--s4); }
  .brand h1 { font-size: 1.1rem; }
  .brand .tagline { display: none; }
  .app-header nav { justify-content: space-between; }
  .app-header nav > button { flex: 1; }
  .refresh-toggle { padding-inline: var(--s1); }
  .panel { inset: auto var(--s2) var(--s2); width: auto; max-height: min(65dvh, calc(100dvh - var(--header-height) - 24px)); }
  .camera-panel { overflow: auto; }
  .camera-list { overflow: visible; flex: none; }
  .panel-head { position: sticky; top: 0; z-index: 1; }
  .panel-body { overscroll-behavior: contain; }
  .leaflet-popup-content { width: 252px !important; }
  #imageDialog, #liveDialog { width: calc(100% - 16px); max-height: calc(100dvh - 16px); }
}
@media (max-height: 560px) {
  :root { --header-height: 64px; }
  .app-header { flex-direction: row; padding-block: var(--s2); }
  .brand .tagline { display: none; }
  .panel { top: calc(var(--header-height) + var(--s2)); bottom: var(--s2); max-height: none; }
  .camera-panel { overflow: auto; }
  .camera-list { overflow: visible; flex: none; }
  .snapshot-frame img { max-height: 140px; }
  .camera-view .snapshot-frame { min-height: 80px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; } }
