/* UMS Map — registry UI, FAB, sheet, mobile-safe */

*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  --text: #0f172a;
  --muted: #64748b;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --accent-soft: rgba(37, 99, 235, 0.1);
  --success: #059669;
  --danger: #dc2626;
  --glass: rgba(255, 255, 255, 0.82);
  --glass-border: rgba(255, 255, 255, 0.92);
  --shadow: 0 12px 40px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 -12px 48px rgba(15, 23, 42, 0.12);
  --font: "DM Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --tap: 44px;
  --radius: 20px;
  --radius-sm: 12px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  /* Set on desktop sidebar layout (see @media min-width 1024px) */
  --sidebar-w: 0px;
}

html {
  height: 100%;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overscroll-behavior: none;
}

body {
  margin: 0;
  min-height: 100%;
  min-height: 100dvh;
  max-width: 100vw;
  font-family: var(--font);
  color: var(--text);
  background: linear-gradient(165deg, #e8eef7 0%, #dbe7f3 45%, #e5edf8 100%);
  overflow: hidden;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

.gate {
  min-height: 100vh;
  min-height: 100dvh;
  min-height: 100svh;
  min-height: -webkit-fill-available;
  display: grid;
  place-items: center;
  padding: max(1rem, var(--safe-top)) max(1rem, var(--safe-right)) max(1rem, var(--safe-bottom))
    max(1rem, var(--safe-left));
  color: var(--muted);
  font-size: 0.95rem;
}

.gate-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 2rem 1.5rem;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.gate-text {
  margin: 0;
  font-weight: 500;
}

.gate-spinner {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 3px solid rgba(37, 99, 235, 0.15);
  border-top-color: var(--accent);
  animation: gate-spin 0.75s linear infinite;
}

@keyframes gate-spin {
  to {
    transform: rotate(360deg);
  }
}

.hidden {
  display: none !important;
}

.app {
  position: relative;
  width: 100%;
  max-width: 100vw;
  min-height: 100vh;
  min-height: 100dvh;
  min-height: 100svh;
  min-height: -webkit-fill-available;
  height: 100vh;
  height: 100dvh;
  height: 100svh;
  overflow: hidden;
}

.ambient {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: radial-gradient(ellipse 120% 80% at 50% -20%, rgba(147, 197, 253, 0.4), transparent 55%),
    radial-gradient(ellipse 80% 50% at 100% 50%, rgba(196, 181, 253, 0.25), transparent 50%),
    radial-gradient(ellipse 60% 40% at 0% 80%, rgba(165, 243, 252, 0.18), transparent 50%);
}

.ambient-grid {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image: linear-gradient(rgba(255, 255, 255, 0.4) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.4) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(ellipse 90% 70% at 50% 30%, black 15%, transparent 65%);
  opacity: 0.45;
}

.site-header {
  position: fixed;
  top: 0;
  right: 0;
  left: 0;
  z-index: 200;
  padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) 0
    max(10px, env(safe-area-inset-left));
  pointer-events: none;
}

.map-chrome {
  max-width: 1200px;
  margin: 0 auto;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.65);
  pointer-events: auto;
  overflow: hidden;
}

@media (max-width: 520px) {
  .map-chrome {
    border-radius: 16px;
  }
}

.chrome-divider {
  height: 1px;
  margin: 0 14px;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(148, 163, 184, 0.35) 20%,
    rgba(148, 163, 184, 0.35) 80%,
    transparent 100%
  );
}

.site-nav {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(min-content, auto);
  grid-template-areas: "brand primary trail";
  align-items: center;
  column-gap: 12px;
  row-gap: 10px;
  padding: 12px 14px 10px;
  margin: 0;
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

@media (max-width: 900px) {
  .site-nav {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "brand trail"
      "primary primary";
  }
}

/* Map page: registry search & tools always appear above primary nav links */
.site-nav.site-nav--with-toolbar {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  row-gap: 12px;
  column-gap: 0;
}

.site-nav.site-nav--with-toolbar .nav-brand {
  grid-area: unset;
  width: 100%;
}

.site-nav.site-nav--with-toolbar .map-search-panel {
  grid-area: unset;
  width: 100%;
  max-width: none;
  padding: 0;
  margin: 0;
}

.site-nav.site-nav--with-toolbar .chrome-divider--nav {
  margin: 2px 0;
  flex-shrink: 0;
}

.site-nav.site-nav--with-toolbar .nav-links--primary {
  grid-area: unset;
  width: 100%;
}

.site-nav.site-nav--with-toolbar .nav-trail {
  grid-area: unset;
  width: 100%;
}

.nav-brand {
  grid-area: brand;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  text-decoration: none;
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}

.nav-brand:hover {
  color: var(--accent);
}

.nav-brand-stack {
  display: flex;
  flex-direction: column;
  gap: 0;
  min-width: 0;
}

.nav-page-title {
  font-size: clamp(1rem, 3.5vw, 1.2rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.nav-page-sub {
  margin: 2px 0 0;
  font-size: 0.72rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: min(46vw, 240px);
}

.badge {
  flex-shrink: 0;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.14);
  color: var(--accent);
}

.nav-links--primary {
  grid-area: primary;
  display: flex;
  align-items: stretch;
  justify-content: center;
  flex-wrap: nowrap;
  gap: 6px;
  list-style: none;
  margin: 0;
  padding: 0;
  min-width: 0;
}

@media (max-width: 900px) {
  .nav-links--primary {
    justify-content: stretch;
    width: 100%;
  }

  .nav-links--primary li {
    flex: 1;
    min-width: 0;
  }

  .nav-links--primary .nav-link {
    width: 100%;
    justify-content: center;
  }
}

.nav-trail {
  grid-area: trail;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
}

.nav-link-text--short {
  display: none;
}

@media (max-width: 400px) {
  .nav-link-text--full {
    display: none;
  }

  .nav-link-text--short {
    display: inline;
  }
}

.nav-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  min-width: var(--tap);
  padding: 0 12px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  border-radius: var(--radius-sm);
  transition: color 0.2s, background 0.2s, transform 0.12s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.nav-link:hover {
  color: var(--accent);
  background: rgba(37, 99, 235, 0.1);
}

@media (hover: none) {
  .nav-link:active {
    color: var(--accent);
    background: rgba(37, 99, 235, 0.16);
    transform: scale(0.98);
  }
}

.nav-link[aria-current="page"] {
  color: var(--accent);
  background: rgba(37, 99, 235, 0.12);
}

.nav-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.stats-pill {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(5, 150, 105, 0.1);
  color: var(--success);
  font-size: 0.75rem;
  font-weight: 600;
}

@media (min-width: 400px) {
  .stats-pill {
    padding: 6px 12px;
    font-size: 0.8rem;
  }
}

.stats-num {
  font-variant-numeric: tabular-nums;
  font-size: 1rem;
}

.stats-label {
  font-weight: 500;
  opacity: 0.85;
}

.user {
  display: none;
  font-size: 0.76rem;
  color: var(--muted);
  max-width: min(120px, 28vw);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (min-width: 520px) {
  .user {
    display: block;
  }
}

@media (max-width: 360px) {
  .user {
    display: none;
  }
}

.nav-signout {
  flex-shrink: 0;
  white-space: nowrap;
}

@media (max-width: 380px) {
  .nav-trail .nav-signout {
    padding: 0 12px;
    font-size: 0.8rem;
    min-height: var(--tap);
  }
}

@media (max-width: 420px) {
  .nav-page-sub {
    display: none;
  }
}

/* Search (inside .map-chrome) */
.map-search-panel {
  position: relative;
  z-index: 251;
  padding: 0 14px 12px;
  margin: 0;
  max-width: none;
}

.map-tools-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px 18px;
  margin-bottom: 10px;
}

.map-tools-row .map-line-draw-wrap {
  margin: 0;
}

.map-base-layer-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.map-base-layer-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.map-base-layer-toggle {
  display: inline-flex;
  border-radius: 999px;
  border: 1px solid rgba(226, 232, 240, 0.95);
  overflow: hidden;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 4px 18px rgba(15, 23, 42, 0.06);
}

.map-base-layer-btn {
  margin: 0;
  padding: 8px 14px;
  min-height: var(--tap);
  min-width: 88px;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
  background: transparent;
  border: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: background 0.15s, color 0.15s;
}

.map-base-layer-btn + .map-base-layer-btn {
  box-shadow: inset 1px 0 0 rgba(226, 232, 240, 0.95);
}

.map-base-layer-btn:hover {
  background: rgba(37, 99, 235, 0.06);
}

.map-base-layer-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  z-index: 1;
}

.map-base-layer-btn[aria-pressed="true"] {
  color: #fff;
  background: linear-gradient(135deg, #0d9488, #0f766e);
}

.map-base-layer-btn[aria-pressed="true"]:hover {
  filter: brightness(1.03);
}

.map-live-location-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.map-live-location-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.map-live-location-btn {
  margin: 0;
  padding: 8px 14px;
  min-height: var(--tap);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(226, 232, 240, 0.95);
  border-radius: 999px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  box-shadow: 0 4px 18px rgba(15, 23, 42, 0.06);
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.map-live-location-btn:hover {
  border-color: rgba(37, 99, 235, 0.35);
  background: rgba(37, 99, 235, 0.06);
}

.map-live-location-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.map-live-location-btn.is-active {
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  border-color: rgba(37, 99, 235, 0.5);
  box-shadow: 0 4px 20px rgba(37, 99, 235, 0.35);
}

.map-live-location-btn.is-active:hover {
  filter: brightness(1.03);
}

.map-live-location-center-btn {
  margin: 0;
  padding: 8px 12px;
  min-height: var(--tap);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--accent);
  background: rgba(37, 99, 235, 0.1);
  border: 1px solid rgba(37, 99, 235, 0.22);
  border-radius: 999px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.map-live-location-center-btn:hover {
  background: rgba(37, 99, 235, 0.16);
}

.map-live-location-center-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.map-line-draw-wrap {
  margin: 0;
  padding: 0;
}

.map-line-draw-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  min-height: var(--tap);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(226, 232, 240, 0.95);
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 18px rgba(15, 23, 42, 0.06);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.map-line-draw-btn svg {
  flex-shrink: 0;
  color: #d97706;
}

.map-line-draw-btn:hover {
  border-color: rgba(245, 158, 11, 0.45);
  box-shadow: 0 4px 20px rgba(245, 158, 11, 0.12);
}

.map-line-draw-btn:focus-visible {
  outline: 2px solid rgba(245, 158, 11, 0.55);
  outline-offset: 2px;
}

.map-line-draw-btn.is-active {
  color: #92400e;
  background: rgba(254, 243, 199, 0.95);
  border-color: rgba(245, 158, 11, 0.55);
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.2);
}

.map-search-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 8px 20px;
  margin-bottom: 10px;
}

.map-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  flex-shrink: 0;
  padding-top: 2px;
}

.map-eyebrow-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

.map-search-hint {
  flex: 1 1 200px;
  margin: 0;
  min-width: 0;
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--muted);
}

@media (max-width: 560px) {
  .map-search-hint {
    display: none;
  }

  .map-search-toolbar {
    margin-bottom: 8px;
  }
}

.search-bar-wrap {
  position: relative;
  z-index: 251;
  margin: 0;
  padding: 0;
}

.search-combo {
  position: relative;
}

.search-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 0 14px;
  min-height: var(--tap);
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(226, 232, 240, 0.95);
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 20px rgba(15, 23, 42, 0.06);
}

.search-bar:focus-within {
  border-color: rgba(37, 99, 235, 0.35);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.search-icon {
  flex-shrink: 0;
  color: var(--muted);
  display: grid;
  place-items: center;
}

.search-bar input[type="search"] {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  padding: 10px 0;
  border: none;
  background: transparent;
  font: inherit;
  font-size: 16px;
  color: var(--text);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

.search-bar input[type="search"]::placeholder {
  color: #94a3b8;
}

.search-clear {
  flex-shrink: 0;
  width: var(--tap);
  height: var(--tap);
  min-width: var(--tap);
  min-height: var(--tap);
  padding: 0;
  border: none;
  border-radius: 10px;
  font-size: 1.35rem;
  line-height: 1;
  color: var(--muted);
  background: rgba(15, 23, 42, 0.06);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  display: grid;
  place-items: center;
}

.search-clear:hover {
  background: rgba(15, 23, 42, 0.1);
  color: var(--text);
}

@media (hover: none) {
  .search-clear:active {
    background: rgba(15, 23, 42, 0.14);
    transform: scale(0.96);
  }
}

.search-clear.hidden {
  display: none;
}

.search-dropdown {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 6px);
  max-height: min(50vh, 320px);
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(226, 232, 240, 0.98);
  border-radius: var(--radius-sm);
  box-shadow: 0 16px 48px rgba(15, 23, 42, 0.14);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.search-dropdown.hidden {
  display: none !important;
}

.search-dd-empty {
  padding: 14px 16px;
  font-size: 0.88rem;
  color: var(--muted);
  text-align: center;
}

.search-dd-item {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  margin: 0;
  border: none;
  border-bottom: 1px solid rgba(241, 245, 249, 0.95);
  background: transparent;
  font: inherit;
  text-align: left;
  cursor: pointer;
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s;
  touch-action: manipulation;
}

.search-dd-item:last-child {
  border-bottom: none;
}

.search-dd-item:hover,
.search-dd-item:focus-visible {
  background: rgba(37, 99, 235, 0.08);
  outline: none;
}

.search-dd-item:focus-visible {
  box-shadow: inset 0 0 0 2px rgba(37, 99, 235, 0.35);
}

.search-dd-primary {
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.3;
  word-break: break-word;
}

.search-dd-meta {
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.35;
  word-break: break-word;
}

.btn-ghost {
  min-height: var(--tap);
  padding: 0 12px;
  font: inherit;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text);
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.95);
  border-radius: var(--radius-sm);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.2s, transform 0.12s;
  touch-action: manipulation;
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.9);
}

@media (hover: none) {
  .btn-ghost:active {
    background: rgba(255, 255, 255, 0.95);
    transform: scale(0.98);
  }
}

.btn-ghost:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Full-viewport map layer (under header / footer overlays) */
.map-wrap {
  position: fixed;
  inset: 0;
  z-index: 1;
  padding: 0;
  pointer-events: none;
}

.map-frame {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  pointer-events: auto;
}

#map {
  flex: 1;
  min-height: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  background: #e2e8f0;
  touch-action: pan-x pan-y pinch-zoom;
}

/* Hide Google’s default map footer (data copyright line, Google logo, Terms / shortcuts links).
   Google Maps Platform terms require attribution to stay visible; hiding it may risk account action. */
#map .gm-style-cc,
#map .gm-style-cc ~ .gmnoprint {
  display: none !important;
}

#map .gm-style .gmnoprint:has(> a[href*="google.com/maps"]),
#map .gm-style .gmnoprint:has(> a[href*="maps.google.com"]),
#map .gm-style .gmnoprint:has(img[alt="Google"]) {
  display: none !important;
}

.map-corner-hint {
  position: absolute;
  left: max(12px, env(safe-area-inset-left));
  bottom: max(48px, calc(40px + env(safe-area-inset-bottom)));
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 14px;
  max-width: min(220px, calc(100% - 100px));
  font-size: 0.72rem;
  line-height: 1.35;
  color: var(--text);
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.95);
  border-radius: var(--radius-sm);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 8px 28px rgba(15, 23, 42, 0.1);
  pointer-events: none;
}

.map-corner-hint-title {
  font-weight: 700;
  font-size: 0.8rem;
  letter-spacing: -0.02em;
}

.map-corner-hint-sub {
  color: var(--muted);
  font-weight: 500;
}

@media (max-width: 480px) {
  .map-corner-hint {
    display: none;
  }
}

#map.map--placing {
  cursor: crosshair;
}

#map.map--line-draw {
  cursor: crosshair;
}

.map-error {
  margin: 0;
  padding: 1rem 1.25rem;
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--text);
  background: rgba(255, 255, 255, 0.95);
  border-radius: var(--radius-sm);
  max-width: 36rem;
}

.map-error code {
  font-size: 0.8rem;
  word-break: break-all;
}

.place-banner {
  position: fixed;
  left: 50%;
  top: calc(env(safe-area-inset-top) + clamp(120px, 30vmin, 220px));
  transform: translateX(-50%);
  z-index: 150;
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  width: min(480px, calc(100vw - 24px - var(--safe-left) - var(--safe-right)));
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: var(--shadow), 0 0 0 1px rgba(37, 99, 235, 0.06);
  animation: banner-in 0.35s ease;
}

@keyframes banner-in {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

.place-banner-icon {
  font-size: 1.1rem;
}

.place-banner-cancel {
  flex-shrink: 0;
  margin-left: 4px;
  padding: 8px 14px;
  min-height: var(--tap);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent);
  background: rgba(37, 99, 235, 0.1);
  border: none;
  border-radius: 999px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.line-draw-banner {
  position: fixed;
  left: 50%;
  top: calc(env(safe-area-inset-top) + clamp(120px, 30vmin, 220px));
  transform: translateX(-50%);
  z-index: 151;
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  padding: 12px 16px;
  width: min(520px, calc(100vw - 24px - var(--safe-left) - var(--safe-right)));
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  background: rgba(255, 251, 235, 0.96);
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: 16px;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: var(--shadow), 0 0 0 1px rgba(217, 119, 6, 0.08);
  animation: banner-in 0.35s ease;
}

.line-draw-banner-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.line-draw-banner-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
}

#line-draw-banner-text {
  flex: 1;
  min-width: 0;
  line-height: 1.35;
}

.line-draw-feeder {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding-top: 6px;
  border-top: 1px solid rgba(245, 158, 11, 0.25);
}

.line-draw-feeder-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #b45309;
  flex-shrink: 0;
}

.line-draw-feeder-input {
  flex: 1 1 200px;
  min-width: 0;
  min-height: var(--tap);
  padding: 8px 14px;
  font: inherit;
  font-size: 16px;
  border-radius: 10px;
  border: 1px solid rgba(226, 232, 240, 0.95);
  background: rgba(255, 255, 255, 0.98);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}

.line-draw-route-mode {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding-top: 8px;
  margin-top: 4px;
  border-top: 1px solid rgba(245, 158, 11, 0.2);
}

.line-draw-route-toggle {
  display: inline-flex;
  border-radius: 999px;
  border: 1px solid rgba(226, 232, 240, 0.95);
  overflow: hidden;
  background: rgba(255, 255, 255, 0.92);
}

.line-draw-route-btn {
  margin: 0;
  padding: 8px 14px;
  min-height: 40px;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
  background: transparent;
  border: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: background 0.15s, color 0.15s;
}

.line-draw-route-btn + .line-draw-route-btn {
  box-shadow: inset 1px 0 0 rgba(226, 232, 240, 0.95);
}

.line-draw-route-btn:hover {
  background: rgba(37, 99, 235, 0.06);
}

.line-draw-route-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  z-index: 1;
}

.line-draw-route-btn[aria-pressed="true"] {
  color: #fff;
  background: linear-gradient(135deg, #f59e0b, #d97706);
}

.line-draw-route-btn[aria-pressed="true"]:hover {
  filter: brightness(1.03);
}

.line-guide-banner {
  position: fixed;
  left: 50%;
  top: calc(env(safe-area-inset-top) + clamp(100px, 26vmin, 200px));
  transform: translateX(-50%);
  z-index: 152;
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px 16px;
  width: min(520px, calc(100vw - 24px - var(--safe-left) - var(--safe-right)));
  font-size: 0.86rem;
  font-weight: 500;
  line-height: 1.45;
  color: var(--text);
  background: rgba(238, 242, 255, 0.97);
  border: 1px solid rgba(99, 102, 241, 0.35);
  border-radius: 16px;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: var(--shadow), 0 0 0 1px rgba(79, 70, 229, 0.1);
}

.line-guide-text {
  margin: 0;
}

.line-guide-text strong {
  font-weight: 700;
}

.line-guide-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.line-guide-btn {
  min-height: var(--tap);
  touch-action: manipulation;
}

#map.map--line-guide {
  cursor: crosshair !important;
}

.line-draw-banner-cancel {
  flex-shrink: 0;
  margin-left: 4px;
  padding: 8px 14px;
  min-height: var(--tap);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  color: #b45309;
  background: rgba(245, 158, 11, 0.15);
  border: none;
  border-radius: 999px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.toast {
  position: fixed;
  bottom: max(152px, calc(148px + var(--safe-bottom)));
  left: 50%;
  transform: translateX(-50%);
  z-index: 160;
  pointer-events: auto;
  padding: 12px 18px;
  font-size: 0.88rem;
  font-weight: 600;
  color: #fff;
  background: rgba(15, 23, 42, 0.9);
  border-radius: 999px;
  box-shadow: var(--shadow);
  max-width: min(calc(100vw - 32px - var(--safe-left) - var(--safe-right)), 380px);
  text-align: center;
  -webkit-tap-highlight-color: transparent;
}

.toast.toast--ok {
  background: rgba(5, 150, 105, 0.95);
}

.toast.toast--err {
  background: rgba(220, 38, 38, 0.95);
}

.map-foot {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
  font-size: 0.68rem;
  color: var(--muted);
  padding: 6px max(12px, var(--safe-right)) max(10px, var(--safe-bottom)) max(12px, var(--safe-left));
  text-align: center;
  line-height: 1.45;
  background: linear-gradient(to top, rgba(232, 238, 247, 0.96) 0%, rgba(232, 238, 247, 0.55) 70%, transparent);
  pointer-events: none;
  -webkit-tap-highlight-color: transparent;
}

.map-foot span,
.map-foot a {
  pointer-events: auto;
}

.map-foot a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.map-iw-btn {
  display: block;
  width: 100%;
  min-height: 40px;
  padding: 8px 14px;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
}

.map-iw-btn:hover {
  filter: brightness(1.05);
}

.map-iw-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.map-iw--dist .map-iw-title {
  color: #047857;
}

.map-iw-box-photo {
  margin: 0 0 10px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid rgba(226, 232, 240, 0.95);
  background: #f8fafc;
}

.map-iw-box-photo img {
  display: block;
  width: 100%;
  max-height: 120px;
  object-fit: contain;
}

.map-iw-btn--dist {
  background: linear-gradient(135deg, #059669, #047857);
  box-shadow: 0 4px 14px rgba(5, 150, 105, 0.35);
}

.map-iw-btn--dist:hover {
  filter: brightness(1.05);
}

.map-iw--infra .map-iw-title {
  color: #4f46e5;
}

.map-iw-btn--infra {
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.35);
  text-decoration: none;
  text-align: center;
  box-sizing: border-box;
}

.map-iw-btn--infra:hover {
  filter: brightness(1.05);
}

.map-iw--line .map-iw-title {
  color: #b45309;
}

.map-iw-btn--line {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  box-shadow: 0 4px 14px rgba(217, 119, 6, 0.35);
}

.map-iw-btn--line:hover {
  filter: brightness(1.05);
}

.map-iw-btn--line-secondary {
  display: block;
  width: 100%;
  min-height: 40px;
  margin-top: 8px;
  padding: 8px 14px;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid rgba(226, 232, 240, 0.95);
  border-radius: var(--radius-sm);
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.06);
}

.map-iw-btn--line-secondary:hover {
  border-color: rgba(245, 158, 11, 0.45);
  background: rgba(254, 243, 199, 0.5);
}

.map-iw-select {
  width: 100%;
  margin-top: 6px;
  min-height: 40px;
  padding: 8px 14px;
  font: inherit;
  font-size: 0.9rem;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(226, 232, 240, 0.95);
  background: rgba(255, 255, 255, 0.98);
  color: var(--text);
}

.map-iw-input {
  width: 100%;
  min-height: 40px;
  padding: 8px 12px;
  font: inherit;
  font-size: 0.9rem;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(226, 232, 240, 0.95);
  background: rgba(255, 255, 255, 0.98);
  color: var(--text);
}

.map-iw-section--feeder-edit {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(226, 232, 240, 0.95);
}

.map-iw-section--feeder-edit .map-iw-btn--line-secondary {
  margin-top: 10px;
}

.map-iw--line .map-iw-btn--line-secondary[id^="power-line-clear-manual"] {
  margin-top: 10px;
}

.map-iw-row--feeder-badge .map-iw-v--feeder {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.feeder-swatch {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1px solid rgba(15, 23, 42, 0.15);
  vertical-align: middle;
}

.feeder-swatch--sm {
  width: 11px;
  height: 11px;
}

/* Feeder cable colors under power house / substation pins (map.js OverlayView) */
.map-infra-feeder-strip {
  position: absolute;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px;
  max-width: min(140px, 42vw);
  pointer-events: none;
  transform: translateX(-50%);
  z-index: 0;
}

.map-infra-feeder-strip__swatch {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1.5px solid rgba(255, 255, 255, 0.95);
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.45);
}

.map-iw-line-feeder {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  max-width: 100%;
}

.map-iw-feeder-txt {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
}

@media (max-width: 560px) {
  .map-iw-row--line-remove {
    flex-wrap: wrap;
  }

  .map-iw-line-feeder {
    flex: 1 1 100%;
    margin-top: 4px;
  }
}

/* Info window (Google Maps popup — styled via page CSS) */
.map-iw {
  font-family: var(--font), system-ui, sans-serif;
  max-width: 300px;
  padding: 4px 2px 2px;
  line-height: 1.45;
  font-size: 13px;
  color: var(--text);
}

.map-iw-title {
  font-weight: 700;
  font-size: 14px;
  letter-spacing: -0.02em;
  margin: 0 0 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(226, 232, 240, 0.95);
  color: var(--text);
}

.map-iw-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.map-iw-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
  align-items: baseline;
}

.map-iw-k {
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  flex-shrink: 0;
  min-width: 4.5rem;
}

.map-iw-v {
  flex: 1;
  min-width: 0;
  word-break: break-word;
  font-weight: 500;
  color: var(--text);
}

.map-iw-footer {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(226, 232, 240, 0.95);
}

.map-iw-section--powerlines {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(226, 232, 240, 0.95);
}

.map-iw-subtitle {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 0 0 8px;
}

.map-iw-row--line-remove {
  align-items: center;
  gap: 8px;
}

.map-iw-row--line-remove .map-iw-v {
  flex: 1;
  min-width: 0;
}

.map-iw-btn--line-mini {
  flex-shrink: 0;
  width: auto;
  min-height: 36px;
  padding: 6px 12px;
  font-size: 0.8rem;
  color: #fff;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  box-shadow: 0 2px 10px rgba(217, 119, 6, 0.3);
  border-radius: var(--radius-sm);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* FAB — house (primary) + distribution box (stacked above) */
.fab.fab--dist {
  bottom: max(120px, calc(120px + var(--safe-bottom)));
  background: linear-gradient(145deg, #059669, #047857);
  box-shadow: 0 12px 32px rgba(5, 150, 105, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.12) inset;
}

.fab.fab--dist:hover {
  box-shadow: 0 14px 38px rgba(5, 150, 105, 0.46), 0 0 0 1px rgba(255, 255, 255, 0.15) inset;
}

.fab.fab--dist:focus-visible {
  outline: 3px solid rgba(5, 150, 105, 0.45);
  outline-offset: 3px;
}

.fab.fab--dist[aria-expanded="true"] .fab-icon-wrap {
  transform: none;
}

.fab {
  position: fixed;
  right: max(14px, var(--safe-right));
  bottom: max(52px, calc(52px + var(--safe-bottom)));
  z-index: 180;
  min-height: 56px;
  min-width: 56px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 0;
  border: none;
  border-radius: 18px;
  color: #fff;
  background: linear-gradient(145deg, var(--accent), var(--accent-dark));
  box-shadow: 0 12px 32px rgba(37, 99, 235, 0.42), 0 0 0 1px rgba(255, 255, 255, 0.12) inset;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.15s ease, box-shadow 0.2s, min-width 0.2s ease;
  touch-action: manipulation;
}

.fab-icon-wrap {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  flex-shrink: 0;
  transition: transform 0.28s cubic-bezier(0.32, 0.72, 0, 1);
}

.fab-label {
  display: none;
  padding-right: 16px;
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

@media (min-width: 640px) {
  .fab {
    border-radius: 999px;
    padding-left: 4px;
    min-width: auto;
  }

  .fab-label {
    display: block;
  }
}

.fab:hover {
  box-shadow: 0 14px 38px rgba(37, 99, 235, 0.48), 0 0 0 1px rgba(255, 255, 255, 0.15) inset;
}

.fab:active {
  transform: scale(0.97);
}

.fab:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.45);
  outline-offset: 3px;
}

.fab[aria-expanded="true"] .fab-icon-wrap {
  transform: rotate(45deg);
}

.fab[aria-expanded="true"] {
  transform: none;
}

/* Sheet */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 210;
  background: rgba(15, 23, 42, 0.35);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.sheet-backdrop.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 220;
  max-height: min(92vh, 720px);
  max-height: min(92dvh, 720px);
  max-height: min(90svh, 720px);
  display: flex;
  flex-direction: column;
  padding: 0 max(12px, var(--safe-right)) max(16px, var(--safe-bottom)) max(12px, var(--safe-left));
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(248, 250, 252, 0.96) 100%);
  border: 1px solid var(--glass-border);
  border-radius: 24px 24px 16px 16px;
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  box-shadow: var(--shadow-lg);
  transform: translateY(110%);
  transition: transform 0.38s cubic-bezier(0.32, 0.72, 0, 1);
  overflow: hidden;
}

.sheet-accent {
  height: 4px;
  flex-shrink: 0;
  background: linear-gradient(90deg, var(--accent), #38bdf8, #818cf8);
  opacity: 0.85;
}

.sheet--dist-box {
  z-index: 221;
}

.sheet-accent--dist {
  background: linear-gradient(90deg, #059669, #34d399, #10b981);
}

.btn-primary--dist {
  background: linear-gradient(135deg, #059669, #047857);
  box-shadow: 0 8px 24px rgba(5, 150, 105, 0.35);
}

.btn-primary--dist:hover:not(:disabled) {
  box-shadow: 0 10px 28px rgba(5, 150, 105, 0.42);
}

.sheet.is-open {
  transform: translateY(0);
}

.sheet-handle-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 44px;
  padding: 12px 0 8px;
  flex-shrink: 0;
  touch-action: none;
}

.sheet-handle {
  width: 44px;
  height: 5px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.15);
}

.sheet-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 0 8px 12px;
  flex-shrink: 0;
}

.sheet-head h2 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.sheet-sub {
  margin: 4px 0 0;
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.35;
}

.icon-btn {
  flex-shrink: 0;
  width: var(--tap);
  height: var(--tap);
  display: grid;
  place-items: center;
  padding: 0;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.6);
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.95);
  color: var(--text);
}

@media (hover: none) {
  .icon-btn:active {
    background: rgba(255, 255, 255, 0.98);
    color: var(--text);
    transform: scale(0.96);
  }
}

.house-form {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 0 8px 8px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.form-section {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  padding: 12px 12px 14px;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid rgba(226, 232, 240, 0.85);
  border-radius: var(--radius-sm);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.section-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.field-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: var(--tap);
  padding: 10px 14px;
  font: inherit;
  font-size: 16px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(226, 232, 240, 0.95);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  resize: vertical;
}

.field textarea {
  min-height: 72px;
  line-height: 1.45;
}

.field input::placeholder,
.field textarea::placeholder {
  color: #94a3b8;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: rgba(37, 99, 235, 0.45);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

@media (max-width: 420px) {
  .field-row {
    grid-template-columns: 1fr;
  }
}

.pin-status {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: rgba(241, 245, 249, 0.9);
  border: 1px solid rgba(226, 232, 240, 0.8);
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--muted);
}

.pin-status.is-set {
  background: rgba(5, 150, 105, 0.08);
  border-color: rgba(5, 150, 105, 0.25);
  color: var(--success);
}

.pin-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #cbd5e1;
  flex-shrink: 0;
}

.pin-status.is-set .pin-dot {
  background: var(--success);
  box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.2);
}

.form-error {
  margin: 0;
  min-height: 1.25rem;
  font-size: 0.85rem;
  color: var(--danger);
}

.form-error:empty {
  display: none;
}

.form-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 4px;
  padding-bottom: 4px;
}

@media (min-width: 480px) {
  .form-actions {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .form-actions .btn-secondary {
    flex: 1;
    min-width: 140px;
  }

  .form-actions .btn-primary {
    flex: 1;
    min-width: 160px;
  }
}

.btn-secondary,
.btn-primary {
  min-height: var(--tap);
  padding: 0 18px;
  font: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: opacity 0.2s, transform 0.12s;
}

.btn-secondary {
  color: var(--accent);
  background: rgba(37, 99, 235, 0.1);
  border: 1px solid rgba(37, 99, 235, 0.2);
}

.btn-secondary:hover:not(:disabled) {
  background: rgba(37, 99, 235, 0.16);
}

.btn-secondary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  box-shadow: 0 8px 24px rgba(37, 99, 235, 0.35);
}

.btn-primary:hover:not(:disabled) {
  box-shadow: 0 10px 28px rgba(37, 99, 235, 0.4);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-primary:active:not(:disabled),
.btn-secondary:active:not(:disabled) {
  transform: scale(0.99);
}

@media (prefers-reduced-motion: reduce) {
  .sheet,
  .sheet-backdrop,
  .place-banner,
  .line-draw-banner {
    transition: none;
    animation: none;
  }

  .gate-spinner {
    animation: none;
    border-top-color: var(--accent);
    opacity: 0.6;
  }

  .fab:active {
    transform: none;
  }

  .fab[aria-expanded="true"] .fab-icon-wrap {
    transform: none;
  }

  .nav-link:active,
  .btn-ghost:active,
  .search-clear:active,
  .icon-btn:active {
    transform: none;
  }
}

/* —— Desktop: left sidebar (nav + tools) —— */
@media (min-width: 1024px) {
  :root {
    --sidebar-w: clamp(268px, 22vw, 320px);
  }

  .app {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    max-width: none;
  }

  .ambient,
  .ambient-grid {
    left: var(--sidebar-w);
  }

  .site-header {
    position: relative;
    top: auto;
    right: auto;
    left: auto;
    order: -1;
    flex: 0 0 var(--sidebar-w);
    width: var(--sidebar-w);
    max-width: var(--sidebar-w);
    align-self: stretch;
    min-height: 0;
    padding: max(12px, env(safe-area-inset-top)) 10px max(12px, env(safe-area-inset-bottom))
      max(10px, env(safe-area-inset-left));
    display: flex;
    flex-direction: column;
    pointer-events: none;
    z-index: 220;
    border-right: 1px solid rgba(148, 163, 184, 0.22);
    background: linear-gradient(180deg, rgba(248, 250, 252, 0.5) 0%, rgba(241, 245, 249, 0.35) 100%);
  }

  .map-chrome {
    flex: 1;
    min-height: 0;
    width: 100%;
    max-width: none;
    margin: 0;
    display: flex;
    flex-direction: column;
    border-radius: 0 var(--radius) var(--radius) 0;
    box-shadow: 4px 0 32px rgba(15, 23, 42, 0.06), var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.65);
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    pointer-events: auto;
  }

  .site-nav {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
    padding: 14px 12px 12px;
    flex: 0 0 auto;
  }

  .nav-brand {
    padding-bottom: 4px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.18);
  }

  .nav-page-sub {
    max-width: none;
    white-space: normal;
    line-height: 1.35;
  }

  .nav-links--primary {
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: stretch;
    gap: 4px;
    width: 100%;
  }

  .nav-links--primary li {
    flex: 0 0 auto;
    width: 100%;
  }

  .nav-links--primary .nav-link {
    width: 100%;
    justify-content: flex-start;
    padding: 0 12px 0 14px;
    min-height: 42px;
    border-radius: 10px;
  }

  .nav-trail {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    margin-top: 4px;
    padding-top: 14px;
    border-top: 1px solid rgba(148, 163, 184, 0.2);
  }

  .nav-trail .stats-pill {
    align-self: flex-start;
  }

  .nav-trail .user {
    display: block;
    max-width: none;
    white-space: normal;
    word-break: break-word;
    font-size: 0.78rem;
    line-height: 1.35;
  }

  .nav-trail .nav-signout {
    width: 100%;
    justify-content: center;
  }

  .chrome-divider {
    margin: 0 12px;
    flex-shrink: 0;
  }

  .map-search-panel,
  .infra-toolbar {
    flex: 1 1 auto;
    min-height: 0;
    padding-top: 4px;
  }

  .map-wrap {
    position: relative;
    flex: 1;
    min-width: 0;
    min-height: 0;
    width: auto;
    height: auto;
    align-self: stretch;
    z-index: 1;
    pointer-events: none;
  }

  .map-frame {
    position: absolute;
    inset: 0;
  }

  .place-banner,
  .line-draw-banner,
  .line-guide-banner {
    left: calc(var(--sidebar-w) + (100vw - var(--sidebar-w)) * 0.5);
    width: min(520px, calc(100vw - var(--sidebar-w) - 24px - var(--safe-left) - var(--safe-right)));
  }

  .toast {
    left: calc(var(--sidebar-w) + (100vw - var(--sidebar-w)) * 0.5);
    max-width: min(calc(100vw - var(--sidebar-w) - 32px - var(--safe-left) - var(--safe-right)), 380px);
  }

  .map-foot {
    left: var(--sidebar-w);
  }
}

/* Google Maps MarkerLabel.className for distribution box pins */
.map-dist-box-marker-label {
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(15, 23, 42, 0.78);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
  white-space: nowrap;
  max-width: min(44vw, 12rem);
  overflow: hidden;
  text-overflow: ellipsis;
}
