/* =========================================================
   Free Tools page — overrides main site's scroll-snap and
   defines the gate + workspace layout.
   ========================================================= */

/* Disable scroll-snap on this page (workspace, not scrolling site) */
html {
  scroll-snap-type: none !important;
  height: 100%;
  overflow: hidden;
}
body.tools-body {
  height: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  margin: 0;
}

/* The floating "Free Tools" button doesn't appear on this page */
.tools-body .free-tools-btn { display: none; }

/* =========================================================
   Gate (name + phone + OTP) — covers everything until verified
   ========================================================= */
.gate {
  position: fixed;
  inset: 0;
  /* Must sit above Leaflet/Geoman controls (which use z-index ~1000) and the
     studio modal (~10000). 100000 leaves headroom for any future overlay. */
  z-index: 100000;
  background: rgba(44, 62, 80, 0.78);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow-y: auto;
}
.gate.is-hidden { display: none; }

.gate__panel {
  background: var(--bg);
  border: 4px solid var(--ink);
  border-radius: var(--radius-lg);
  box-shadow: 0 10px 0 var(--ink);
  padding: 32px 30px 28px;
  width: 100%;
  max-width: 460px;
  position: relative;
}
.gate__brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--display);
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 18px;
}
.gate__brand .logo-mark {
  width: 40px;
  height: 40px;
  font-size: 16px;
}

.gate__step { display: none; }
.gate__step.is-active { display: block; }
.gate__step h2 {
  font-family: var(--display);
  font-size: 28px;
  font-weight: 700;
  line-height: 1.15;
  margin: 0 0 8px;
  color: var(--ink);
}
.gate__lede {
  color: var(--ink-soft);
  font-size: 15px;
  margin: 0 0 20px;
  font-weight: 500;
}
.gate__step .field { margin-bottom: 14px; display: block; }
.gate__step .field > span {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 6px;
  font-family: var(--display);
}
.gate__step .field input {
  width: 100%;
  padding: 14px 16px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 500;
  color: var(--ink);
  background: var(--white);
  border: 3px solid var(--ink);
  border-radius: var(--radius);
  transition: box-shadow var(--transition), border-color var(--transition);
}
.gate__step .field input:focus {
  outline: none;
  border-color: var(--orange);
  box-shadow: 0 0 0 4px var(--yellow);
}
.gate__error {
  color: #d33;
  font-size: 13px;
  font-weight: 700;
  margin: 0 0 12px;
  text-align: center;
  background: #FEE;
  padding: 8px 12px;
  border: 2px solid #fbb;
  border-radius: var(--radius);
}
.gate__cta {
  width: 100%;
  margin-top: 16px;
}
.gate__cancel, .gate__back {
  display: block;
  text-align: center;
  margin: 16px auto 0;
  font-size: 14px;
  font-weight: 600;
}
.gate__step .otp {
  margin: 18px 0 12px;
}

/* =========================================================
   Tools header (top bar)
   ========================================================= */
.tools-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 20px;
  background: var(--white);
  border-bottom: 4px solid var(--ink);
  flex: 0 0 auto;
  z-index: 10;
}
.tools-logo {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--ink);
  font-family: var(--display);
  font-weight: 700;
  font-size: 18px;
}
.tools-logo .logo-mark { width: 40px; height: 40px; font-size: 15px; }
.tools-title {
  font-family: var(--display);
  font-size: 20px;
  font-weight: 700;
  margin: 0;
  color: var(--ink);
}
.tools-back {
  padding: 10px 18px;
  font-size: 14px;
  box-shadow: 0 3px 0 var(--ink);
}
.tools-back:hover { box-shadow: 0 5px 0 var(--ink); }

/* User badge in header (account name + logout button) */
.tools-user {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px 6px 12px;
  background: var(--yellow);
  border: 2px solid var(--ink);
  border-radius: var(--radius-pill);
  font-family: var(--display);
  font-weight: 700;
  font-size: 13px;
  color: var(--ink);
  box-shadow: 0 2px 0 var(--ink);
}
.tools-user[hidden] { display: none; }
.tools-user__icon { font-size: 14px; }
.tools-user__name {
  max-width: 140px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.tools-user__logout {
  width: 24px;
  height: 24px;
  border: 2px solid var(--ink);
  background: var(--white);
  border-radius: 50%;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  color: var(--ink);
}
.tools-user__logout:hover {
  background: var(--orange);
  color: var(--white);
}

@media (max-width: 720px) {
  .tools-title { display: none; }
  .tools-header { padding: 8px 12px; }
  .tools-back { padding: 8px 14px; font-size: 13px; }
  .tools-user__name { max-width: 90px; }
}

/* =========================================================
   Talk-to-studio modal
   ========================================================= */
.studio-modal {
  position: fixed;
  inset: 0;
  /* Above Leaflet/Geoman (≈1000) but below the auth gate (100000). */
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.studio-modal[hidden] { display: none; }
.studio-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(44, 62, 80, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.studio-modal__panel {
  position: relative;
  width: 100%;
  max-width: 540px;
  background: var(--bg);
  border: 4px solid var(--ink);
  border-radius: var(--radius-lg);
  box-shadow: 0 10px 0 var(--ink);
  padding: 28px 28px 24px;
  max-height: 90vh;
  overflow-y: auto;
}
.studio-modal__close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid var(--ink);
  background: var(--orange);
  color: var(--white);
  font-size: 20px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 3px 0 var(--ink);
  line-height: 1;
}
.studio-modal__close:hover { background: var(--orange-dark); }
.studio-modal h2 {
  font-family: var(--display);
  font-size: 24px;
  font-weight: 700;
  margin: 0 0 8px;
  color: var(--ink);
}
.studio-modal__lede {
  font-size: 14px;
  color: var(--ink-soft);
  margin: 0 0 18px;
  font-weight: 500;
}
.studio-modal__fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 14px;
  margin-bottom: 6px;
}
.studio-modal__fields .field:first-child { grid-column: 1 / -1; }   /* name spans both columns */
.studio-modal__fields input[type="text"],
.studio-modal__fields input[type="tel"],
.studio-modal__fields input[type="email"] {
  width: 100%;
  padding: 10px 12px;
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  background: var(--white);
}
.studio-modal__fields input:focus {
  outline: none;
  border-color: var(--orange);
  box-shadow: 0 0 0 3px var(--yellow);
}
.studio-modal .field {
  display: block;
  margin-bottom: 14px;
}
.studio-modal .field > span {
  display: block;
  font-family: var(--display);
  font-weight: 700;
  font-size: 13px;
  margin-bottom: 6px;
  color: var(--ink);
}
.studio-modal textarea {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  font-family: var(--sans);
  font-size: 15px;
  font-weight: 500;
  color: var(--ink);
  background: var(--white);
  resize: vertical;
  min-height: 120px;
}
.studio-modal textarea:focus {
  outline: none;
  border-color: var(--orange);
  box-shadow: 0 0 0 3px var(--yellow);
}
.studio-modal__attached {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-soft);
  background: var(--bg-blue);
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin: 0 0 16px;
}
.studio-modal__actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}
.studio-modal__actions .btn {
  padding: 10px 16px;
  font-size: 14px;
}

/* =========================================================
   Workspace (split layout)
   ========================================================= */
.tools-main {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  padding: 14px;
  min-height: 0;
  background: var(--bg);
}
@media (max-width: 980px) {
  .tools-main {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 1fr;
    overflow-y: auto;
  }
}

.tools-panel {
  background: var(--white);
  border: 3px solid var(--ink);
  border-radius: var(--radius-lg);
  box-shadow: 0 5px 0 var(--ink);
  padding: 14px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.tools-panel--map { background: var(--bg-blue); }
.tools-panel--build { background: var(--bg-alt); }

.tools-panel__head {
  flex: 0 0 auto;
  margin-bottom: 10px;
}
.tools-panel__head h2 {
  font-family: var(--display);
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 4px;
  color: var(--ink);
}
.tools-panel__head p {
  font-size: 13px;
  color: var(--ink-soft);
  margin: 0;
  font-weight: 500;
}

/* =========================================================
   Map viewport + stats
   ========================================================= */
.map-viewport {
  flex: 1 1 auto;
  min-height: 200px;
  border: 3px solid var(--ink);
  border-radius: var(--radius);
  overflow: hidden;
  background: #aad3df;
  box-shadow: inset 0 2px 0 rgba(0, 0, 0, 0.1);
}
.map-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 10px;
  flex: 0 0 auto;
}
.map-stat {
  background: var(--white);
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  padding: 8px 10px;
  text-align: center;
}
.map-stat span {
  display: block;
  font-size: 10px;
  font-weight: 700;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 2px;
}
.map-stat strong {
  display: block;
  font-family: var(--display);
  font-size: 16px;
  font-weight: 700;
  color: var(--orange);
}

/* Search row above the map */
.map-search {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}
.map-search input {
  flex: 1;
  padding: 8px 12px;
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  font-family: var(--display);
  font-weight: 600;
  font-size: 13px;
  background: var(--white);
  color: var(--ink);
}
.map-search input:focus {
  outline: none;
  border-color: var(--orange);
  box-shadow: 0 0 0 3px var(--yellow);
}
.map-search button {
  padding: 8px 16px;
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  background: var(--orange);
  color: var(--white);
  font-family: var(--display);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  box-shadow: 0 2px 0 var(--ink);
  transition: all var(--transition);
}
.map-search button:hover {
  background: var(--orange-dark);
  transform: translateY(-1px);
  box-shadow: 0 3px 0 var(--ink);
}
.map-search button:active {
  transform: translateY(1px);
  box-shadow: 0 1px 0 var(--ink);
}

/* Theme Leaflet to match brand */
.leaflet-container {
  font-family: var(--sans);
  background: #aad3df;
}
.leaflet-control-zoom a,
.leaflet-pm-toolbar a {
  border: 2px solid var(--ink) !important;
  border-radius: 8px !important;
  background: var(--white) !important;
  color: var(--ink) !important;
  font-weight: 700;
}
.leaflet-control-zoom a:hover,
.leaflet-pm-toolbar a:hover {
  background: var(--yellow) !important;
}
.leaflet-pm-toolbar .leaflet-pm-icon-polygon,
.leaflet-pm-toolbar .leaflet-pm-icon-line,
.leaflet-pm-toolbar .leaflet-pm-icon-rectangle {
  filter: drop-shadow(0 1px 0 var(--ink));
}

/* =========================================================
   3D viewport
   ========================================================= */
.threed-viewport {
  flex: 1 1 auto;
  min-height: 220px;
  border: 3px solid var(--ink);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-blue);
  cursor: grab;
  position: relative;
}
/* Empty state shown until the user draws a lot */
.threed-empty {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  background: rgba(224, 244, 251, 0.96);
  pointer-events: none;
  transition: opacity 240ms ease;
}
.threed-viewport.has-lot .threed-empty {
  opacity: 0;
  visibility: hidden;
}
.threed-empty__icon {
  font-size: 44px;
  margin-bottom: 14px;
  line-height: 1;
}
.threed-empty h3 {
  font-family: var(--display);
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 8px;
  color: var(--ink);
}
.threed-empty p {
  font-size: 14px;
  color: var(--ink-soft);
  max-width: 320px;
  margin: 0;
  font-weight: 500;
}
.threed-viewport:active { cursor: grabbing; }
.threed-viewport canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

/* =========================================================
   Build layout — controls on the LEFT, 3D viewport on the RIGHT
   ========================================================= */
.build-layout {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 14px;
  min-height: 0;
}
.build-side-controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  padding-right: 4px;
  min-height: 0;
}
.build-layout > .threed-viewport {
  min-width: 0;
}
@media (max-width: 980px) {
  .build-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }
  .build-side-controls { max-height: 280px; }
}

/* Legacy alias so old selectors continue to work */
.build-controls {
  flex: 0 0 auto;
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

/* ---------- Building tabs (multi-building) ----------
   Horizontal strip above the form-selector. One tab per building, with a
   rename-on-double-click name + an × delete control. A "+ New" button at
   the end adds a fresh building. */
.building-tabs {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 2px dashed var(--ink);
}
.building-tab {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 4px 5px 10px;
  background: var(--white);
  border: 2px solid var(--ink);
  border-radius: 8px;
  cursor: pointer;
  font-family: var(--display);
  font-weight: 700;
  font-size: 12px;
  color: var(--ink);
  max-width: 180px;
  box-shadow: 0 2px 0 var(--ink);
  transition: transform .08s ease;
}
.building-tab:hover { background: var(--yellow); }
.building-tab.is-active {
  background: var(--orange);
  color: var(--white);
  transform: translateY(1px);
  box-shadow: 0 1px 0 var(--ink);
}
.building-tab__name {
  outline: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 30px;
  max-width: 130px;
  padding: 1px 2px;
}
.building-tab__name[contenteditable="true"] {
  background: var(--white);
  color: var(--ink);
  border-radius: 4px;
}
.building-tab__remove {
  border: none;
  background: transparent;
  color: inherit;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  opacity: 0.6;
}
.building-tab__remove:hover { opacity: 1; }
.building-tab-add {
  border: 2px dashed var(--ink);
  background: transparent;
  border-radius: 8px;
  padding: 5px 10px;
  font-family: var(--display);
  font-weight: 700;
  font-size: 12px;
  color: var(--ink);
  cursor: pointer;
}
.building-tab-add:hover { background: var(--yellow); }

/* Form selector — picks footprint shape */
.form-selector {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.form-btn {
  padding: 8px 12px;
  border: 2px solid var(--ink);
  background: var(--white);
  font-family: var(--display);
  font-weight: 600;
  font-size: 12px;
  color: var(--ink);
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: 0 2px 0 var(--ink);
}
.form-btn:hover:not(:disabled) {
  background: var(--yellow);
  transform: translateY(-1px);
  box-shadow: 0 3px 0 var(--ink);
}
.form-btn.is-active {
  background: var(--orange);
  color: var(--white);
}
.form-btn.is-soon, .form-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  box-shadow: none;
}

/* Number-input rows */
.field-rows {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
}
.field-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
  background: var(--white);
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  padding: 8px 10px;
  position: relative;
}
.field-row__label {
  font-family: var(--display);
  font-weight: 700;
  font-size: 12px;
  color: var(--ink);
  line-height: 1.2;
}
.field-row__input {
  width: 76px;
  padding: 6px 8px;
  font-family: var(--display);
  font-size: 15px;
  font-weight: 700;
  text-align: right;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: var(--bg);
  color: var(--orange);
  -moz-appearance: textfield;
}
.field-row__input::-webkit-outer-spin-button,
.field-row__input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.field-row__input:focus {
  outline: none;
  border-color: var(--orange);
  box-shadow: 0 0 0 3px var(--yellow);
}
.field-row__warning {
  grid-column: 1 / -1;
  font-size: 11px;
  color: #d33;
  font-weight: 700;
  line-height: 1.2;
  font-family: var(--display);
}
.field-row__warning:empty { display: none; }

/* Slider variant of a field row (for rotation, etc.) */
.field-row--slider {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: stretch;
}
.field-row--slider .field-row__label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  width: 100%;
}
.field-row__value {
  font-family: var(--display);
  font-weight: 700;
  font-size: 14px;
  color: var(--orange);
}
.field-row__slider {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  height: 8px;
  background: var(--bg-blue);
  border: 2px solid var(--ink);
  border-radius: var(--radius-pill);
  outline: none;
  margin: 0;
}
.field-row__slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  background: var(--orange);
  border: 2px solid var(--ink);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 2px 0 var(--ink);
  transition: transform var(--transition);
}
.field-row__slider::-webkit-slider-thumb:hover { transform: scale(1.1); }
.field-row__slider::-moz-range-thumb {
  width: 20px;
  height: 20px;
  background: var(--orange);
  border: 2px solid var(--ink);
  border-radius: 50%;
  cursor: pointer;
}

/* Shape-specific parameter blocks (rectangle / L / U / T) */
.form-params {
  background: var(--white);
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  padding: 8px 10px;
}
.form-params[hidden] { display: none; }
.form-params__head {
  font-family: var(--display);
  font-weight: 700;
  font-size: 12.5px;
  color: var(--ink);
  margin-bottom: 6px;
  padding-bottom: 4px;
  border-bottom: 2px dashed var(--ink);
}
.form-params__grid {
  display: grid;
  gap: 6px;
}
.form-params .field-row {
  padding: 6px 10px;
  border-width: 2px;
}

/* ---------- Famous-buildings picker ---------- */
.famous-hint {
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--ink-soft);
  margin: 0 0 8px;
}
.famous-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  max-height: 280px;
  overflow-y: auto;
  padding-right: 2px;
}
.famous-btn {
  background: var(--white);
  border: 2px solid var(--ink);
  border-radius: 8px;
  padding: 8px 10px;
  font-family: var(--display);
  font-weight: 700;
  font-size: 12px;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
  line-height: 1.25;
  display: flex;
  flex-direction: column;
  gap: 2px;
  box-shadow: 0 2px 0 var(--ink);
  transition: transform .08s ease;
}
.famous-btn:hover { background: var(--yellow); }
.famous-btn.is-active {
  background: var(--orange);
  color: var(--white);
  transform: translateY(1px);
  box-shadow: 0 1px 0 var(--ink);
}
.famous-btn small {
  font-weight: 500;
  font-size: 10.5px;
  color: var(--ink-soft);
}
.famous-btn.is-active small { color: rgba(255,255,255,.85); }
.famous-selected {
  margin-top: 10px;
  padding: 8px 10px;
  border: 2px dashed var(--ink);
  border-radius: 8px;
  background: var(--bg-alt);
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.famous-selected strong {
  font-family: var(--display);
  font-size: 13px;
  color: var(--ink);
}
.famous-selected small {
  font-size: 11px;
  color: var(--ink-soft);
  line-height: 1.4;
}
.field-row--select .field-row__input {
  width: auto;
  min-width: 110px;
  padding: 4px 8px;
  font-size: 12px;
  font-family: var(--display);
  font-weight: 600;
  background: var(--white);
  border: 2px solid var(--ink);
  color: var(--ink);
}

/* ---------- Build-limit tool (2D map) ---------- */
/* Custom Leaflet control button (top-left of the map) */
.leaflet-control.limit-control {
  background: var(--white);
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: 0 3px 0 var(--ink);
  overflow: hidden;
  margin: 10px 0 0 10px;
}
.leaflet-control.limit-control button {
  background: transparent;
  border: none;
  padding: 7px 14px;
  font-family: var(--display);
  font-weight: 700;
  font-size: 13px;
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
}
.leaflet-control.limit-control button:hover { background: var(--yellow); }
.leaflet-control.limit-control button.is-active {
  background: #C2185B;
  color: var(--white);
}

/* Floating instruction banner over the map */
.map-status {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 600;
  background: var(--orange);
  color: var(--white);
  border: 2px solid var(--ink);
  border-radius: var(--radius-pill);
  padding: 7px 14px;
  font-family: var(--display);
  font-weight: 700;
  font-size: 13px;
  box-shadow: 0 3px 0 var(--ink);
  pointer-events: none;
}
.map-status[hidden] { display: none; }

/* ---------- CSGO-style crosshair while placing points on the map ----------
   Applied to limit picks and any time Geoman is in a draw mode (we toggle
   .is-picking-draw from JS in response to pm:drawstart). The SVG is
   base64-encoded so it parses identically in Chrome / Firefox / Safari.
   We ALSO disable overlay-pane pointer events during pick modes so the
   orange footprint / lot polygon stop swallowing clicks before they reach
   the map's click handler. */
.map-viewport.is-picking-limit,
.map-viewport.is-picking-draw {
  cursor: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnIHdpZHRoPSczMicgaGVpZ2h0PSczMic+PGcgZmlsbD0nbm9uZScgc3Ryb2tlLWxpbmVjYXA9J3NxdWFyZSc+PGcgc3Ryb2tlPScjZmZmZmZmJyBzdHJva2Utd2lkdGg9JzQnPjxsaW5lIHgxPScxNicgeTE9JzInIHgyPScxNicgeTI9JzEyJy8+PGxpbmUgeDE9JzE2JyB5MT0nMjAnIHgyPScxNicgeTI9JzMwJy8+PGxpbmUgeDE9JzInIHkxPScxNicgeDI9JzEyJyB5Mj0nMTYnLz48bGluZSB4MT0nMjAnIHkxPScxNicgeDI9JzMwJyB5Mj0nMTYnLz48L2c+PGcgc3Ryb2tlPScjMjIyYTNhJyBzdHJva2Utd2lkdGg9JzInPjxsaW5lIHgxPScxNicgeTE9JzInIHgyPScxNicgeTI9JzEyJy8+PGxpbmUgeDE9JzE2JyB5MT0nMjAnIHgyPScxNicgeTI9JzMwJy8+PGxpbmUgeDE9JzInIHkxPScxNicgeDI9JzEyJyB5Mj0nMTYnLz48bGluZSB4MT0nMjAnIHkxPScxNicgeDI9JzMwJyB5Mj0nMTYnLz48L2c+PC9nPjxjaXJjbGUgY3g9JzE2JyBjeT0nMTYnIHI9JzIuNycgZmlsbD0nI2ZmZmZmZicvPjxjaXJjbGUgY3g9JzE2JyBjeT0nMTYnIHI9JzEuNScgZmlsbD0nI0MyMTg1QicvPjwvc3ZnPg==") 16 16, crosshair;
}
.map-viewport.is-picking-limit .leaflet-container,
.map-viewport.is-picking-limit .leaflet-container *,
.map-viewport.is-picking-draw  .leaflet-container,
.map-viewport.is-picking-draw  .leaflet-container * {
  cursor: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnIHdpZHRoPSczMicgaGVpZ2h0PSczMic+PGcgZmlsbD0nbm9uZScgc3Ryb2tlLWxpbmVjYXA9J3NxdWFyZSc+PGcgc3Ryb2tlPScjZmZmZmZmJyBzdHJva2Utd2lkdGg9JzQnPjxsaW5lIHgxPScxNicgeTE9JzInIHgyPScxNicgeTI9JzEyJy8+PGxpbmUgeDE9JzE2JyB5MT0nMjAnIHgyPScxNicgeTI9JzMwJy8+PGxpbmUgeDE9JzInIHkxPScxNicgeDI9JzEyJyB5Mj0nMTYnLz48bGluZSB4MT0nMjAnIHkxPScxNicgeDI9JzMwJyB5Mj0nMTYnLz48L2c+PGcgc3Ryb2tlPScjMjIyYTNhJyBzdHJva2Utd2lkdGg9JzInPjxsaW5lIHgxPScxNicgeTE9JzInIHgyPScxNicgeTI9JzEyJy8+PGxpbmUgeDE9JzE2JyB5MT0nMjAnIHgyPScxNicgeTI9JzMwJy8+PGxpbmUgeDE9JzInIHkxPScxNicgeDI9JzEyJyB5Mj0nMTYnLz48bGluZSB4MT0nMjAnIHkxPScxNicgeDI9JzMwJyB5Mj0nMTYnLz48L2c+PC9nPjxjaXJjbGUgY3g9JzE2JyBjeT0nMTYnIHI9JzIuNycgZmlsbD0nI2ZmZmZmZicvPjxjaXJjbGUgY3g9JzE2JyBjeT0nMTYnIHI9JzEuNScgZmlsbD0nI0MyMTg1QicvPjwvc3ZnPg==") 16 16, crosshair !important;
}

/* While picking limit points on the map, the overlay-pane elements (lot
   polygon + orange footprint) must let clicks fall through to the map's
   click handler — otherwise vertices placed inside the building are eaten. */
.map-viewport.is-picking-limit .leaflet-overlay-pane,
.map-viewport.is-picking-limit .leaflet-overlay-pane * {
  pointer-events: none !important;
}

/* ---------- Corner rotation handles (2D map) ----------
   Small dots at the active building's footprint corners. Hovering shows a
   rotate cursor; dragging a corner spins the building about its centre. */
.rotate-handle__glyph {
  display: block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--orange);
  border: 2px solid var(--ink);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .35);
  cursor: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnIHdpZHRoPSczMCcgaGVpZ2h0PSczMCcgdmlld0JveD0nMCAwIDI0IDI0Jz48ZyBmaWxsPSdub25lJyBzdHJva2U9JyNmZmZmZmYnIHN0cm9rZS13aWR0aD0nNCcgc3Ryb2tlLWxpbmVjYXA9J3JvdW5kJyBzdHJva2UtbGluZWpvaW49J3JvdW5kJz48cGF0aCBkPSdNMjEgMTIgYTkgOSAwIDEgMSAtMi42NCAtNi4zNicvPjxwb2x5bGluZSBwb2ludHM9JzIxIDMgMjEgOSAxNSA5Jy8+PC9nPjxnIGZpbGw9J25vbmUnIHN0cm9rZT0nIzJDM0U1MCcgc3Ryb2tlLXdpZHRoPScyLjInIHN0cm9rZS1saW5lY2FwPSdyb3VuZCcgc3Ryb2tlLWxpbmVqb2luPSdyb3VuZCc+PHBhdGggZD0nTTIxIDEyIGE5IDkgMCAxIDEgLTIuNjQgLTYuMzYnLz48cG9seWxpbmUgcG9pbnRzPScyMSAzIDIxIDkgMTUgOScvPjwvZz48L3N2Zz4=") 15 15, grab;
  transition: transform .08s ease;
}
.rotate-handle__glyph:hover { transform: scale(1.35); background: var(--yellow); }

/* While actively rotating, the whole map shows the rotate cursor. */
.map-viewport.is-rotating,
.map-viewport.is-rotating .leaflet-container,
.map-viewport.is-rotating .leaflet-container * {
  cursor: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnIHdpZHRoPSczMCcgaGVpZ2h0PSczMCcgdmlld0JveD0nMCAwIDI0IDI0Jz48ZyBmaWxsPSdub25lJyBzdHJva2U9JyNmZmZmZmYnIHN0cm9rZS13aWR0aD0nNCcgc3Ryb2tlLWxpbmVjYXA9J3JvdW5kJyBzdHJva2UtbGluZWpvaW49J3JvdW5kJz48cGF0aCBkPSdNMjEgMTIgYTkgOSAwIDEgMSAtMi42NCAtNi4zNicvPjxwb2x5bGluZSBwb2ludHM9JzIxIDMgMjEgOSAxNSA5Jy8+PC9nPjxnIGZpbGw9J25vbmUnIHN0cm9rZT0nIzJDM0U1MCcgc3Ryb2tlLXdpZHRoPScyLjInIHN0cm9rZS1saW5lY2FwPSdyb3VuZCcgc3Ryb2tlLWxpbmVqb2luPSdyb3VuZCc+PHBhdGggZD0nTTIxIDEyIGE5IDkgMCAxIDEgLTIuNjQgLTYuMzYnLz48cG9seWxpbmUgcG9pbnRzPScyMSAzIDIxIDkgMTUgOScvPjwvZz48L3N2Zz4=") 15 15, grabbing !important;
}

/* Side-panel list of restrictions */
.limit-block {
  background: var(--white);
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  padding: 8px 10px;
}
.limit-block__head {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 6px;
}
.limit-block__head strong {
  font-family: var(--display);
  font-weight: 700;
  font-size: 12.5px;
  color: var(--ink);
}
.limit-block__head small {
  font-size: 11px;
  font-weight: 500;
  color: var(--ink-soft);
}
.limit-list {
  display: grid;
  gap: 4px;
  max-height: 130px;
  overflow-y: auto;
}
.limit-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border: 1.5px solid var(--ink);
  border-radius: 8px;
  background: #F8D7E6;
  font-family: var(--display);
  font-weight: 700;
  font-size: 12px;
  color: var(--ink);
}
.limit-row__remove {
  width: 22px;
  height: 22px;
  background: #C2185B;
  color: var(--white);
  border: 2px solid var(--ink);
  border-radius: 50%;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 1;
  box-shadow: 0 2px 0 var(--ink);
}
.limit-row__remove:hover { background: #8E1147; }

/* Per-side block (pick-on-3D style) */
.per-side-block {
  background: var(--white);
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  padding: 8px 10px;
}
.per-side-block__head {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 6px;
}
.per-side-block__head strong {
  font-family: var(--display);
  font-weight: 700;
  font-size: 12.5px;
  color: var(--ink);
}
.per-side-pick-btn {
  font-family: var(--display);
  font-size: 12px;
  font-weight: 700;
  background: var(--yellow);
  border: 2px solid var(--ink);
  border-radius: var(--radius-pill);
  padding: 6px 10px;
  cursor: pointer;
  color: var(--ink);
  box-shadow: 0 2px 0 var(--ink);
  transition: all var(--transition);
}
.per-side-pick-btn:hover {
  background: var(--orange);
  color: var(--white);
  transform: translateY(-1px);
  box-shadow: 0 3px 0 var(--ink);
}
.per-side-pick-btn.is-active {
  background: var(--orange);
  color: var(--white);
}
.per-side-pick-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: none;
}
.sides {
  display: grid;
  gap: 4px;
  padding: 4px 0 0;
  max-height: 160px;
  overflow-y: auto;
}
.sides__hint {
  margin: 0;
  font-size: 12px;
  color: var(--ink-soft);
  text-align: center;
  padding: 8px 0;
  font-weight: 500;
}
.side-row {
  display: grid;
  grid-template-columns: 1fr 70px auto;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  padding: 4px 6px;
  border: 1.5px solid var(--ink);
  border-radius: 8px;
  background: var(--bg-blue);
}
.side-row__label {
  font-family: var(--display);
  font-weight: 700;
}
.side-row__hint {
  color: var(--ink-soft);
  font-size: 10px;
  font-weight: 500;
  display: block;
}
.side-row__input {
  width: 70px;
  padding: 4px 6px;
  font-family: var(--display);
  font-size: 13px;
  font-weight: 700;
  text-align: right;
  border: 2px solid var(--ink);
  border-radius: 6px;
  background: var(--white);
  color: var(--orange);
}
.side-row__input:focus {
  outline: none;
  border-color: var(--orange);
  box-shadow: 0 0 0 2px var(--yellow);
}
.side-row__remove {
  width: 24px;
  height: 24px;
  background: var(--orange);
  color: var(--white);
  border: 2px solid var(--ink);
  border-radius: 50%;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 1;
  box-shadow: 0 2px 0 var(--ink);
}
.side-row__remove:hover { background: var(--orange-dark); }

/* Picker banner shown when picker mode is active */
.picker-banner {
  position: absolute;
  top: 12px; left: 12px; right: 12px;
  z-index: 6;
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--yellow);
  border: 3px solid var(--ink);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-family: var(--display);
  font-weight: 700;
  font-size: 14px;
  color: var(--ink);
  box-shadow: 0 4px 0 var(--ink);
}
.threed-viewport.is-picking .picker-banner { display: flex; }
.threed-viewport.is-picking { cursor: crosshair; }
.threed-viewport.is-picking canvas { cursor: crosshair; }
.picker-banner button {
  background: var(--white);
  border: 2px solid var(--ink);
  border-radius: var(--radius-pill);
  padding: 4px 12px;
  font-family: var(--display);
  font-weight: 700;
  font-size: 12px;
  cursor: pointer;
  box-shadow: 0 2px 0 var(--ink);
}
.picker-banner button:hover { background: var(--orange); color: var(--white); }

/* Readouts — 3 metric pills in a row, with the permit-ease pill on its own
   row below so the score has space to breathe and read at a glance. */
.readouts {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.readouts .readout--permit { grid-column: 1 / -1; }
.readout {
  background: var(--white);
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  padding: 6px 8px;
  text-align: center;
}
.readout span {
  display: block;
  font-size: 10px;
  font-weight: 700;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 2px;
}
.readout strong {
  display: block;
  font-family: var(--display);
  font-size: 15px;
  font-weight: 700;
  color: var(--orange);
}
.readout__pct {
  display: block;
  font-size: 10px;
  font-weight: 700;
  color: var(--ink-soft);
  margin-top: 2px;
  letter-spacing: 0;
  text-transform: none;
  line-height: 1.1;
}
/* Permit-ease pill — colour is set inline from JS via a red→green HSL gradient
   (--permit-bg) so the readout block tints itself to match the score. */
.readout--permit {
  background: var(--permit-bg, var(--white));
  border-color: var(--ink);
  cursor: help;
}
.readout--permit strong {
  color: var(--ink);
  font-size: 18px;
}
.readout--permit span,
.readout--permit .readout__pct {
  color: var(--ink);
}

/* =========================================================
   Action buttons (Reset / Save)
   ========================================================= */
.tools-actions {
  flex: 0 0 auto;
  display: flex;
  gap: 10px;
  margin-top: 14px;
}
.tools-actions .btn {
  flex: 1;
  padding: 12px 18px;
  font-size: 14px;
  box-shadow: 0 4px 0 var(--ink);
}
.tools-actions .btn:hover { box-shadow: 0 6px 0 var(--ink); }
.tools-actions .btn:active { box-shadow: 0 2px 0 var(--ink); }
