/* Shape lock: panels/inputs/buttons 10px, small map controls 8px, dots/handles circular (50%) only.
   Panels/inputs/buttons (10px): details, inputs/select/textarea, buttons, .warp-controls,
   .sites li, .friends-list li, .leaflet-popup-content-wrapper, #toast, .modal-card,
   #align-scan, .align-badge. Small map controls (8px): #panel-toggle (outer corners),
   .locate-btn, .mini-btn, .friend-label. Circular only: #panel-close, #menu-fab,
   .locate-icon (+::after), .gps-dot, .warp-handle, #swipe-line::after, .align-dot,
   .align-map-dot, .friend-dot, .friends-list .fdot. Mobile bottom-sheet top corners 10px. */

:root {
  --bg: #16181d;
  --surface: #1e222b;
  --surface-2: #252b37;
  --border: #343c4b;
  --text: #dce3ec;
  --muted: #8b95a6;
  --accent: #6cb8f0;
  --danger: #ff7a72;
  --ok: #69f0ae;
  /* Back-compat aliases (JS/HTML era names) — same values, not extra tokens */
  --panel: var(--surface);
  --panel-2: var(--surface-2);
  --shadow-soft: rgba(9, 13, 19, 0.35);
  --shadow-strong: rgba(9, 13, 19, 0.5);
  --accent-soft: rgba(108, 184, 240, 0.14);
}

:root[data-theme="night"],
html[data-theme="night"] {
  --bg: #16181d;
  --surface: #1e222b;
  --surface-2: #252b37;
  --border: #343c4b;
  --text: #dce3ec;
  --muted: #8b95a6;
  --accent: #6cb8f0;
  --danger: #ff7a72;
  --ok: #69f0ae;
  --panel: var(--surface);
  --panel-2: var(--surface-2);
  --shadow-soft: rgba(9, 13, 19, 0.35);
  --shadow-strong: rgba(9, 13, 19, 0.5);
  --accent-soft: rgba(108, 184, 240, 0.14);
}

:root[data-theme="day"],
html[data-theme="day"] {
  --bg: #d3d9e0;
  --surface: #e9edf1;
  --surface-2: #dde3e9;
  --border: #b7c1cc;
  --text: #1d2532;
  --muted: #5a6676;
  --accent: #0b6bcb;
  --danger: #b3261e;
  --ok: #14663a;
  --panel: var(--surface);
  --panel-2: var(--surface-2);
  --shadow-soft: rgba(45, 60, 80, 0.16);
  --shadow-strong: rgba(45, 60, 80, 0.28);
  --accent-soft: rgba(11, 107, 203, 0.12);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Liberation Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  font-size: 14px;
  line-height: 1.5;
  font-weight: 400;
  letter-spacing: 0.005em;
  color: var(--text);
  background: var(--bg);
}

/* Tabular numerals for coordinates / counts */
.leaflet-popup-content .scrd,
#gps-status,
#sync-status,
.sites li .smeta,
.friends-list .fmeta,
#align-count,
#opacity-val,
#align-zoom-ctrl {
  font-variant-numeric: tabular-nums;
}

#map {
  position: absolute;
  inset: 0;
  z-index: 1;
}

.leaflet-container { background: #10141a; }
:root[data-theme="day"] .leaflet-container,
html[data-theme="day"] .leaflet-container { background: #c8d0d8; }

.leaflet-control-attribution {
  background: rgba(20, 23, 29, 0.78) !important;
  color: var(--muted) !important;
  font-size: 10px;
}
:root[data-theme="day"] .leaflet-control-attribution,
html[data-theme="day"] .leaflet-control-attribution {
  background: rgba(233, 237, 241, 0.88) !important;
}
.leaflet-control-attribution a { color: var(--muted) !important; }

/* ---------------- panel ---------------- */

#panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 360px;
  max-width: 92vw;
  z-index: 1000;
  background: var(--surface);
  border-left: 1px solid var(--border);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: -6px 0 24px var(--shadow-soft);
  transition: transform 0.28s cubic-bezier(0.32, 0.72, 0, 1);
}

#panel .panel-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 14px 16px 20px;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

#panel.collapsed {
  transform: translateX(calc(100% + 12px));
}

#panel-toggle {
  position: absolute;
  top: 12px;
  left: -46px;
  z-index: 1001;
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-right: none;
  color: var(--text);
  border-radius: 8px 0 0 8px;
  cursor: pointer;
  font-size: 18px;
  text-align: center;
  box-shadow: 0 2px 8px var(--shadow-soft);
  touch-action: manipulation;
}

#panel-close {
  display: none;
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 16px;
}

#menu-fab {
  display: none;
  position: fixed;
  right: 14px;
  bottom: 78px;
  z-index: 1002;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent);
  color: #0a1622;
  border: none;
  font-size: 22px;
  box-shadow: 0 4px 16px var(--shadow-strong);
  cursor: pointer;
  touch-action: manipulation;
  align-items: center;
  justify-content: center;
}
#menu-fab.show { display: flex; }

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.panel-header h1 {
  margin: 0;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--text);
}

.subtitle {
  margin: 4px 0 0;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--muted);
}

details {
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 10px;
  background: var(--surface-2);
  overflow: hidden;
}

details[open] > summary {
  border-bottom: 1px solid var(--border);
}

summary {
  cursor: pointer;
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text);
  user-select: none;
  list-style: none;
}

summary::-webkit-details-marker { display: none; }
summary::marker { content: ""; }
summary::before {
  content: "+";
  display: inline-block;
  width: 1.2em;
  color: var(--muted);
  font-weight: 700;
}
details[open] > summary::before { content: "–"; }
summary:hover { background: var(--accent-soft); }

.body {
  padding: 10px 12px 12px;
  border-top: none;
  display: grid;
  gap: 6px;
  align-content: start;
}

/* Sentence-case field labels (uppercase reserved for summary eyebrows only) */
.mini {
  display: block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.01em;
  text-transform: none;
  color: var(--muted);
  margin: 8px 0 4px;
}

.hint { font-size: 12.5px; color: var(--muted); line-height: 1.55; margin: 4px 0 8px; }

.row { display: flex; gap: 6px; align-items: center; margin: 6px 0; }
.row.wrap { flex-wrap: wrap; }
.row input[type="text"] { flex: 1; min-width: 0; }

input[type="text"],
input[type="file"],
select,
textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 7px 9px;
  font-size: 13px;
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
}

:root[data-theme="day"] input[type="text"],
:root[data-theme="day"] input[type="file"],
:root[data-theme="day"] select,
:root[data-theme="day"] textarea,
html[data-theme="day"] input[type="text"],
html[data-theme="day"] input[type="file"],
html[data-theme="day"] select,
html[data-theme="day"] textarea {
  background: var(--surface);
}

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%238b95a6' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
}

:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px var(--accent-soft);
}

select { cursor: pointer; touch-action: manipulation; }

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
  margin: 2px 0;
}

button {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 7px 10px;
  border-radius: 10px;
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: 0.01em;
  cursor: pointer;
  white-space: nowrap;
}

:root[data-theme="day"] button,
html[data-theme="day"] button {
  background: var(--surface);
}

button:hover { border-color: var(--accent); }
button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #0a1622;
  font-weight: 650;
}
button.primary:hover { filter: brightness(1.06); color: #0a1622; border-color: var(--accent); }
button.ghost { background: transparent; }
button.danger:hover { border-color: var(--danger); color: var(--danger); }
button:disabled { opacity: 0.55; cursor: not-allowed; }

/* Segmented compare-mode control (Fade / Swipe / Blink) */
.modes {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 3px;
  gap: 3px;
}
:root[data-theme="day"] .modes,
html[data-theme="day"] .modes {
  background: var(--surface);
}
.modes button {
  flex: 1;
  font-size: 12.5px;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
}
.modes button:hover { color: var(--text); border: none; }
.modes button.active {
  background: var(--accent);
  border: none;
  color: #0a1622;
  font-weight: 700;
}

.warp-controls {
  margin-top: 10px;
  padding: 8px;
  border: 1px dashed var(--accent);
  border-radius: 10px;
  background: var(--accent-soft);
}

/* Bake UX: dirty = glowing outline + glowing Apply + text label (never color alone). */
.warp-controls.is-dirty {
  border-style: solid;
  box-shadow: 0 0 0 2px var(--accent), 0 0 14px var(--accent-soft);
}
#warp-bake.is-dirty {
  box-shadow: 0 0 0 2px var(--accent), 0 0 10px var(--accent-soft);
}
.warp-dirty {
  display: block;
  margin: 6px 0 2px;
  color: var(--text);
  font-weight: 600;
}

/* Bake progress: dim the draft canvas while baking (button :disabled already dims it).
   !important beats the inline canvas opacity set by setOpacity(). */
#map .leaflet-pane.is-baking canvas {
  opacity: 0.4 !important;
}

/* ---------------- sites ---------------- */

.sites {
  list-style: none;
  margin: 6px 0;
  padding: 0;
  display: grid;
  gap: 6px;
}

.sites li {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  margin-bottom: 0;
  background: var(--surface-2);
  font-size: 12.5px;
}

:root[data-theme="day"] .sites li,
html[data-theme="day"] .sites li {
  background: var(--surface);
}

.sites li .sname { font-weight: 650; }
.sites li .smeta { color: var(--muted); font-size: 11px; margin-top: 2px; }
.sites li .del {
  float: right;
  background: none;
  border: none;
  color: var(--danger);
  padding: 0 4px;
  font-size: 14px;
  line-height: 1;
}
.sites li.empty,
.friends-list li.empty { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.site-form label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin: 6px 0 2px; }
.site-form textarea { resize: vertical; }
.site-form button { margin-top: 8px; }

.leaflet-popup-content { margin: 10px 12px; line-height: 1.5; }
.leaflet-popup-content-wrapper {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 6px 20px var(--shadow-strong);
}
.leaflet-popup-tip { background: var(--surface); box-shadow: none; border: none; }
.leaflet-bar { border: 1px solid var(--border) !important; box-shadow: 0 2px 8px var(--shadow-soft) !important; border-radius: 8px !important; overflow: hidden; }
.leaflet-bar a { background: var(--surface) !important; color: var(--text) !important; border-bottom: 1px solid var(--border) !important; }
.leaflet-bar a:hover { background: var(--surface-2) !important; color: var(--text) !important; }
.leaflet-tooltip { background: var(--surface) !important; color: var(--text) !important; border: 1px solid var(--border) !important; border-radius: 8px !important; box-shadow: 0 2px 8px var(--shadow-soft) !important; }
.leaflet-tooltip-top::before { border-top-color: var(--surface) !important; }
.leaflet-control-scale-line { background: var(--surface) !important; color: var(--text) !important; border: 1px solid var(--border) !important; font-size: 10px; }
.leaflet-popup-content .skind { color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: 0.04em; }
.leaflet-popup-content .sname { font-size: 15px; font-weight: 700; margin: 2px 0; letter-spacing: 0; }
.leaflet-popup-content .snotes { font-size: 12.5px; color: var(--muted); margin: 4px 0; }
.leaflet-popup-content .scrd { font-size: 11px; color: var(--muted); }
.leaflet-popup-content button { margin-top: 6px; }

/* ---------------- GPS ---------------- */

.locate-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  margin: 10px 0 0 10px;
  box-shadow: 0 2px 8px var(--shadow-soft);
}
.locate-btn:hover { border-color: var(--accent); }
.locate-btn.active { border-color: var(--accent); background: var(--surface-2); }

.locate-icon {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--muted);
  position: relative;
}
.locate-icon::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 5px;
  height: 5px;
  margin: -2.5px 0 0 -2.5px;
  border-radius: 50%;
  background: var(--muted);
}
.locate-btn:hover .locate-icon { border-color: var(--accent); }
.locate-btn:hover .locate-icon::after { background: var(--accent); }
.locate-btn.active .locate-icon {
  border-color: var(--accent);
  background: transparent;
}
.locate-btn.active .locate-icon::after { background: var(--accent); }

.gps-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #e8ecf1;
  box-sizing: border-box;
}

#gps-status {
  display: block;
  margin-top: 6px;
  color: var(--muted);
}

#sync-status {
  color: var(--muted);
}

/* ---------------- warp handles ---------------- */

.warp-handle {
  width: 16px;
  height: 16px;
  border: 3px solid;
  border-radius: 50%;
  background: rgba(20, 23, 29, 0.55);
  box-sizing: border-box;
  box-shadow: 0 1px 4px var(--shadow-strong);
}

.warp-guide {
  stroke: #e8ecf1;
  stroke-dasharray: 4 4;
  stroke-width: 1.5;
  fill: rgba(232, 236, 241, 0.06);
  pointer-events: none;
}

/* ---------------- swipe divider ---------------- */

#swipe-line {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--accent);
  z-index: 900;
  cursor: ew-resize;
  display: none;
}

#swipe-line::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 34px;
  height: 34px;
  background: var(--accent);
  border-radius: 50%;
  box-shadow: 0 2px 8px var(--shadow-strong);
}

#swipe-line::before {
  content: "\2194";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #0a1622;
  font-weight: 700;
  z-index: 1;
}

/* ---------------- toast / modal ---------------- */

#toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  z-index: 2000;
  background: var(--surface-2);
  border: 1px solid var(--accent);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 13px;
  box-shadow: 0 4px 16px var(--shadow-strong);
  max-width: 80vw;
}
#toast.error { border-color: var(--danger); }
#toast.ok { border-color: var(--ok); }

/* Blink compare: CSS animation on the overlay pane (no setInterval) */
.om-blink { animation: om-blink 1.1s infinite; }
@keyframes om-blink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0.15; }
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 3000;
  background: rgba(20, 25, 34, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

:root[data-theme="day"] .modal,
html[data-theme="day"] .modal {
  background: rgba(45, 60, 80, 0.45);
}

.modal-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  max-width: 640px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 22px 26px;
  box-shadow: 0 10px 40px var(--shadow-strong);
}

.modal-card h2 { color: var(--text); margin-top: 0; font-size: 18px; letter-spacing: 0.01em; }
.modal-card h3 { margin: 16px 0 6px; font-size: 13px; font-weight: 700; color: var(--text); }
.modal-card ol, .modal-card ul { margin: 4px 0 0; padding-left: 20px; font-size: 13px; line-height: 1.6; }
.modal-card .close {
  position: absolute;
  top: 10px;
  right: 12px;
  border: none;
  font-size: 16px;
  color: var(--muted);
}

.sw-1 { color: #ff5252; font-weight: 700; }
.sw-2 { color: #ffab40; font-weight: 700; }
.sw-3 { color: #40c4ff; font-weight: 700; }
.sw-4 { color: #69f0ae; font-weight: 700; }
:root[data-theme="day"] .sw-1,
html[data-theme="day"] .sw-1 { color: #b3261e; }
:root[data-theme="day"] .sw-2,
html[data-theme="day"] .sw-2 { color: #7a4a00; }
:root[data-theme="day"] .sw-3,
html[data-theme="day"] .sw-3 { color: #0b6bcb; }
:root[data-theme="day"] .sw-4,
html[data-theme="day"] .sw-4 { color: #14663a; }

/* ---------------- auto-align modal ---------------- */

#align-modal {
  pointer-events: none;
  background: transparent;
  justify-content: flex-start;
  align-items: flex-start;
  padding: 12px;
}
#align-modal .modal-card { pointer-events: auto; }
.align-card {
  max-width: 340px;
  max-height: calc(100vh - 24px);
}
.align-card p.mini { margin-top: 4px; }
#align-scan {
  position: relative;
  margin: 10px 0 4px;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: #141a22;
  max-height: 40vh;
  cursor: crosshair;
  user-select: none;
  touch-action: none;
}
#align-viewport {
  position: relative;
  transform-origin: 0 0;
  will-change: transform;
}
#align-scan img {
  display: block;
  width: 100%;
  height: auto;
  pointer-events: none;
}
.align-zoom {
  gap: 6px;
  align-items: center;
  margin-bottom: 4px;
}
.mini-btn {
  width: 26px;
  height: 26px;
  line-height: 1;
  font-size: 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
}
.mini-btn:hover { background: var(--accent-soft); border-color: var(--accent); }
.align-dot {
  position: absolute;
  width: 22px;
  height: 22px;
  margin: -11px 0 0 -11px;
  border-radius: 50%;
  background: #ff5252;
  color: #f2f4f6;
  font-size: 12px;
  font-weight: 700;
  line-height: 22px;
  text-align: center;
  border: 2px solid #e8ecf1;
  box-shadow: 0 1px 4px var(--shadow-strong);
  pointer-events: none;
}
.align-badge {
  padding: 2px 10px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
}
.align-badge.wait { color: #0a1622; border-color: var(--accent); background: var(--accent); }
/* Day accent (#0b6bcb) is dark: on-accent text must be white (5.28:1, AA).
   Night accent (#6cb8f0) keeps the dark text above (8.47:1, AA). */
:root[data-theme="day"] #menu-fab,
html[data-theme="day"] #menu-fab,
:root[data-theme="day"] button.primary,
html[data-theme="day"] button.primary,
:root[data-theme="day"] button.primary:hover,
html[data-theme="day"] button.primary:hover,
:root[data-theme="day"] .modes button.active,
html[data-theme="day"] .modes button.active,
:root[data-theme="day"] #swipe-line::before,
html[data-theme="day"] #swipe-line::before,
:root[data-theme="day"] .align-badge.wait,
html[data-theme="day"] .align-badge.wait { color: #ffffff; }
.align-actions { justify-content: flex-end; margin-top: 10px; }
.align-map-dot {
  display: inline-block;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #40c4ff;
  color: #10222c;
  font-size: 12px;
  font-weight: 700;
  line-height: 22px;
  text-align: center;
  border: 2px solid #e8ecf1;
  box-shadow: 0 1px 4px var(--shadow-strong);
}

.friends-list { list-style: none; margin: 6px 0; padding: 0; display: grid; gap: 6px; }
.friends-list li {
  display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--border); border-radius: 10px;
  padding: 6px 8px; margin-bottom: 0; background: var(--surface-2); font-size: 12.5px;
}
:root[data-theme="day"] .friends-list li,
html[data-theme="day"] .friends-list li {
  background: var(--surface);
}
.friends-list .fdot { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 10px; }
.friends-list .fname { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.friends-list .fmeta { color: var(--muted); font-size: 11px; }
.friend-dot {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid #e8ecf1;
  display: flex; align-items: center; justify-content: center;
  font-size: 9px; font-weight: 800; color: #f2f4f6; line-height: 1;
}
.friend-dot.live { animation: pulse-live 1.6s infinite; }
@keyframes pulse-live {
  0% { opacity: 1; }
  50% { opacity: 0.55; }
  100% { opacity: 1; }
}
.friend-label {
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 2px 6px; font-size: 11px; font-weight: 600; white-space: nowrap;
}

.sheet-grabber { display: none; }

.panel-footer {
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--muted);
  line-height: 1.55;
}

@media (prefers-reduced-motion: reduce) {
  #panel { transition: none; }
  .friend-dot.live { animation: none; }
  .om-blink { animation: none; }
}

@media (max-width: 640px) {
  html, body { overscroll-behavior: none; }
  #panel {
    width: 100vw;
    max-width: 100vw;
    height: 78vh;
    max-height: 78vh;
    top: auto;
    bottom: 0;
    right: 0;
    left: 0;
    border-left: none;
    border-top: 1px solid var(--border);
    border-radius: 10px 10px 0 0;
    overflow: hidden;
    transform: translateY(0);
    overscroll-behavior: contain;
  }
  #panel.collapsed {
    transform: translateY(calc(100% - 52px));
    box-shadow: none;
  }
  #panel.collapsed .panel-scroll { pointer-events: none; }
  .sheet-grabber { display: block; width: 40px; height: 4px; border-radius: 2px; background: var(--border); margin: 8px auto 0; cursor: pointer; touch-action: manipulation; }
  #panel .panel-scroll {
    height: 100%;
    margin-top: 0;
    padding-top: 12px;
    padding-bottom: 24px;
  }
  #panel-toggle { display: none !important; }
  #panel-close { display: flex !important; align-items: center; justify-content: center; }
  #panel .panel-header { padding-right: 44px; }
  #map .leaflet-top { top: 10px; right: 10px; }
  #map .leaflet-bottom { bottom: 62px; }
  body.sheet-open #map .leaflet-bottom { bottom: calc(78vh + 8px); }
  body.sheet-open #menu-fab { bottom: calc(78vh + 16px); }
  .locate-btn { margin: 10px 0 0 10px; }
  #menu-fab { display: none; bottom: 68px; }
  #panel.collapsed ~ #menu-fab { display: flex; }
  /* Prevent iOS auto-zoom on select/input focus */
  input[type="text"], select, textarea { font-size: 16px !important; }
  /* Make selects easier to tap */
  select { min-height: 44px; padding: 10px 36px 10px 12px; background-position: right 12px center; }
  .row { gap: 8px; }
  button { min-height: 40px; padding: 10px 14px; }
  .modes button { min-height: 44px; }
  details summary { padding: 14px 12px; font-size: 13px; }
  /* Ensure dropdowns are above map */
  #panel { isolation: isolate; }
  select, input[type="text"] { position: relative; z-index: 1; }
}
