:root {
  --navy: #0c1b2e;
  --indigo: #2d2a9e;
  --teal: #2aa8a3;
  --teal-dark: #1e8a85;
  --light: #f4f8fa;
  --text: #1a2e3b;
  --muted: #5a7080;
  --border: #dde8ed;
  --white: #ffffff;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: "Roboto", -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--text);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ===== TOP BAR ===== */
.topbar {
  background: var(--teal);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 18px;
  z-index: 1200;
}
.brand img { height: 48px; display: block; }
.guide {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  color: var(--white);
  font-size: 15px;
  font-weight: 500;
}
.guide .gstep { opacity: .7; transition: opacity .2s; white-space: nowrap; }
.guide .gstep.on { opacity: 1; font-weight: 800; }
.guide .gstep.done { opacity: .9; }
.guide .gstep.done::after { content: " ✓"; font-weight: 800; }
.guide .gsep { opacity: .5; }

/* ===== STAGE / MAP ===== */
.stage { flex: 1; position: relative; }
#map { position: absolute; inset: 0; background: #0b1622; }

/* ===== SEARCH ===== */
.search-box {
  position: absolute;
  top: 14px; left: 14px;
  width: 400px;
  max-width: calc(100vw - 28px);
  z-index: 1000;
}
.search-box input {
  width: 100%;
  padding: 14px 44px 14px 16px;
  font-size: 16px;
  border: none;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,.35);
  outline: none;
}
.search-box input:focus { box-shadow: 0 4px 16px rgba(0,0,0,.35), 0 0 0 2px var(--teal); }
#clearAddress {
  position: absolute;
  right: 8px; top: 8px;
  width: 32px; height: 32px;
  border: none; background: none;
  font-size: 22px; color: var(--muted);
  cursor: pointer;
}
.suggestions {
  background: var(--white);
  border-radius: 8px;
  margin-top: 6px;
  box-shadow: 0 6px 20px rgba(0,0,0,.3);
  overflow: hidden;
}
.suggestions div {
  padding: 11px 14px;
  cursor: pointer;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
}
.suggestions div:last-child { border-bottom: none; }
.suggestions div:hover { background: var(--light); }
.suggestions .sg-note {
  color: var(--muted);
  cursor: default;
  font-style: italic;
}
.suggestions .sg-note:hover { background: var(--white); }

/* ===== SIDEBAR ===== */
.sidebar {
  position: absolute;
  top: 78px; left: 14px; bottom: 14px;
  width: 400px;
  max-width: calc(100vw - 28px);
  z-index: 999;
  display: flex;
}
.panel {
  background: var(--white);
  border-radius: 10px;
  box-shadow: 0 6px 24px rgba(0,0,0,.35);
  display: flex;
  flex-direction: column;
  width: 100%;
  overflow: hidden;
}
.panel.hidden { display: none; }
.panel-header {
  background: var(--navy);
  color: var(--white);
  font-size: 18px;
  font-weight: 700;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.back-btn {
  background: rgba(255,255,255,.12);
  border: none;
  color: var(--white);
  width: 38px; height: 38px;
  border-radius: 8px;
  font-size: 20px;
  cursor: pointer;
}
.back-btn:hover { background: rgba(255,255,255,.25); }

.pool-list { overflow-y: auto; padding: 10px; }
.pool-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: border-color .2s, box-shadow .2s;
  position: relative;
}
.pool-card:hover { border-color: var(--teal); box-shadow: 0 2px 10px rgba(42,168,163,.25); }
.pool-card img { width: 110px; height: 74px; object-fit: contain; }
.pool-card .pc-name { font-weight: 800; font-size: 16px; color: var(--navy); }
.pool-card .pc-sizes { font-size: 13px; color: var(--muted); margin-top: 3px; }
.pool-card .pc-tag {
  position: absolute;
  top: 8px; right: 8px;
  background: var(--teal);
  color: var(--white);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 999px;
}

/* ===== DETAIL ===== */
.detail-body { padding: 14px 16px; overflow-y: auto; flex: 1; }
.detail-body img { width: 70%; display: block; margin: 0 auto 10px; }
.size-title { font-weight: 700; margin-bottom: 8px; color: var(--navy); }
.size-options { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.size-btn {
  border: 2px solid var(--border);
  background: var(--white);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  color: var(--text);
}
.size-btn.selected { border-color: var(--teal); background: var(--teal); color: var(--white); }
.detail-specs {
  background: var(--light);
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 14px;
  line-height: 1.7;
}
.detail-specs b { color: var(--navy); }
.cta {
  margin: 12px 16px 16px;
  background: var(--indigo);
  color: var(--white);
  border: none;
  border-radius: 8px;
  padding: 15px;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
}
.cta:hover { filter: brightness(1.12); }

/* ===== POOL OVERLAY ON MAP ===== */
.pool-overlay {
  position: absolute;
  cursor: grab;
  touch-action: none;
  z-index: 500;
}
.pool-overlay:active { cursor: grabbing; }
.pool-overlay img {
  width: 100%; height: 100%;
  object-fit: fill;
  display: block;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,.5));
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}
.pool-dims {
  position: absolute;
  left: 50%;
  top: -26px;
  transform: translateX(-50%);
  background: rgba(255,255,255,.95);
  color: var(--navy);
  font-size: 12px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  white-space: nowrap;
  pointer-events: none;
}
.pool-overlay.unselected .pool-dims,
.pool-overlay.unselected .rotate-handle { display: none; }
.rotate-handle {
  position: absolute;
  left: 50%;
  bottom: -34px;
  transform: translateX(-50%);
  width: 24px; height: 24px;
  background: var(--white);
  border: 3px solid var(--teal);
  border-radius: 50%;
  cursor: crosshair;
}

/* ===== MAP BUTTONS / DISCLAIMER ===== */
.map-btn {
  position: absolute;
  bottom: 24px; right: 60px;
  background: var(--white);
  border: none;
  border-radius: 999px;
  box-shadow: 0 4px 16px rgba(0,0,0,.35);
  padding: 10px 16px;
  font-family: inherit;
  font-weight: 700;
  font-size: 14px;
  color: var(--navy);
  cursor: pointer;
  z-index: 1000;
}
.map-btn:hover { background: var(--light); }
.maptype {
  position: absolute;
  bottom: 24px; left: 14px;
  background: var(--white);
  border-radius: 999px;
  box-shadow: 0 4px 16px rgba(0,0,0,.35);
  padding: 4px;
  display: flex;
  gap: 4px;
  z-index: 1000;
}
.maptype button {
  border: none;
  background: none;
  font-family: inherit;
  font-weight: 700;
  font-size: 13px;
  color: var(--muted);
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
}
.maptype button.on { background: var(--teal); color: var(--white); }
.maptype button:not(.on):hover { background: var(--light); }
.map-disclaimer {
  position: absolute;
  bottom: 4px; left: 8px;
  color: rgba(255,255,255,.85);
  text-shadow: 0 1px 2px rgba(0,0,0,.8);
  font-size: 11px;
  z-index: 900;
  pointer-events: none;
}

/* ===== SETBACK ===== */
.setback-control {
  position: absolute;
  top: 14px; right: 14px;
  background: var(--white);
  border-radius: 999px;
  box-shadow: 0 4px 16px rgba(0,0,0,.35);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 1000;
  font-weight: 700;
  font-size: 14px;
  color: var(--navy);
}
.setback-control input {
  width: 58px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-weight: 700;
  text-align: center;
  outline: none;
}
.setback-control input:focus { border-color: var(--teal); }
.setback-warn { color: #b42318; margin-left: 6px; }
.pool-overlay.violation img {
  filter: drop-shadow(0 0 5px #ff2d2d) drop-shadow(0 0 2px #ff2d2d);
}
.pool-overlay.violation .pool-dims { background: #ffe3e3; color: #b42318; }

/* ===== PARCEL EDGE LABELS ===== */
.edge-label {
  position: absolute;
  background: rgba(255,255,255,.95);
  color: #0c1b2e;
  font-family: "Roboto", -apple-system, sans-serif;
  font-size: 12px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  white-space: nowrap;
  box-shadow: 0 1px 5px rgba(0,0,0,.4);
}

/* ===== TOOLBAR / HINT ===== */
.pool-toolbar {
  position: absolute;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--white);
  border-radius: 999px;
  box-shadow: 0 4px 16px rgba(0,0,0,.35);
  padding: 10px 18px;
  display: flex;
  align-items: center;
  gap: 16px;
  z-index: 1000;
  font-weight: 700;
  font-size: 14px;
  color: var(--navy);
}
.pool-toolbar label { display: flex; align-items: center; gap: 10px; }
.pool-toolbar input[type=range] { width: 160px; accent-color: var(--teal); }
.pool-toolbar button {
  border: none;
  background: #fce8e8;
  color: #b42318;
  font-weight: 700;
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
}
.hint {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(12,27,46,.85);
  color: var(--white);
  padding: 8px 18px;
  border-radius: 999px;
  font-size: 13px;
  z-index: 1000;
  pointer-events: none;
}

/* ===== MODAL ===== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8,15,26,.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}
.modal {
  background: var(--white);
  border-radius: 14px;
  width: 440px;
  max-width: calc(100vw - 32px);
  padding: 28px;
  position: relative;
  max-height: 90vh;
  overflow-y: auto;
}
.modal h2 { color: var(--navy); margin-bottom: 4px; }
.modal-sub { color: var(--muted); font-size: 14px; margin-bottom: 16px; }
.modal-close {
  position: absolute;
  top: 12px; right: 14px;
  border: none; background: none;
  font-size: 26px;
  color: var(--muted);
  cursor: pointer;
}
.modal input, .modal textarea {
  width: 100%;
  padding: 12px 14px;
  margin-bottom: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  font-family: inherit;
  outline: none;
}
.modal input:focus, .modal textarea:focus { border-color: var(--teal); }
.modal .cta { margin: 6px 0 0; width: 100%; }
.modal-summary {
  background: var(--light);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  line-height: 1.6;
  margin-bottom: 8px;
  color: var(--text);
}

.hidden { display: none !important; }

/* ===== MOBILE ===== */
@media (max-width: 760px) {
  .topbar { gap: 10px; }
  .brand img { height: 36px; }
  .guide { font-size: 11px; gap: 6px; }
  .guide .gsep { display: none; }
  .search-box { width: calc(100vw - 28px); }
  .sidebar {
    top: auto;
    left: 0; right: 0; bottom: 0;
    width: 100%;
    max-width: none;
    height: 45%;
  }
  .panel { border-radius: 14px 14px 0 0; }
  .pool-toolbar { bottom: 46%; padding: 8px 12px; gap: 8px; }
  .pool-toolbar input[type=range] { width: 90px; }
  .map-btn { bottom: calc(45% + 60px); right: 10px; }
  .maptype { bottom: calc(45% + 60px); left: 10px; }
  .maptype button { padding: 6px 10px; font-size: 11px; }
  .map-disclaimer { bottom: calc(45% + 2px); }
}

/* ===== CSS FULLSCREEN FALLBACK (iOS / blocked embeds) ===== */
body.faux-fs .topbar { display: none; }
body.faux-fs .stage {
  position: fixed;
  inset: 0;
  z-index: 5000;
}

/* Fullscreen: map only — hide the pool panel, in both native
   fullscreen (:fullscreen / -webkit-full-screen) and the CSS fallback */
body.faux-fs .sidebar,
.stage:fullscreen .sidebar,
.stage:-webkit-full-screen .sidebar,
body.faux-fs .search-box,
.stage:fullscreen .search-box,
.stage:-webkit-full-screen .search-box {
  display: none;
}
body.faux-fs .map-btn,
.stage:fullscreen .map-btn,
.stage:-webkit-full-screen .map-btn { bottom: 24px; right: 60px; }
body.faux-fs .maptype,
.stage:fullscreen .maptype,
.stage:-webkit-full-screen .maptype { bottom: 24px; left: 14px; }
body.faux-fs .maptype button,
.stage:fullscreen .maptype button,
.stage:-webkit-full-screen .maptype button { padding: 7px 14px; font-size: 13px; }
body.faux-fs .map-disclaimer,
.stage:fullscreen .map-disclaimer,
.stage:-webkit-full-screen .map-disclaimer { bottom: 4px; }

.pool-toolbar .deg {
  min-width: 38px;
  text-align: right;
  color: var(--teal-dark);
  font-weight: 800;
}

/* Fullscreen: pool panel is hidden, so drop the Rotate bar to the bottom */
body.faux-fs .pool-toolbar,
.stage:fullscreen .pool-toolbar,
.stage:-webkit-full-screen .pool-toolbar { bottom: 84px; }
