/*! CubifyIt City. Copyright (c) 2026 Cubic It Studio. All rights reserved.
No permission is granted to copy, modify or redistribute this code. See LICENSE. */
:root {
  --bg: #fafaf9;
  --surface: #ffffff;
  --field: #f4f4f2;
  --ink: #111111;
  --muted: #8a8a86;
  --line: #ececea;
  --danger: #c0392b;
  --radius: 14px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; } /* even where a class sets display */

html, body {
  margin: 0;
  height: 100%;
}
body {
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.5 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; color: inherit; }
input[type=range] { accent-color: var(--ink); }

button {
  border: 0;
  background: var(--field);
  border-radius: 999px;
  padding: 8px 18px;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s;
}
button:hover { background: #ebebe8; }
button.primary { background: var(--ink); color: #fff; }
button.primary:hover { background: #333; }

/* ---------- Top bar ---------- */

.topbar {
  min-height: 60px;
  flex: none;
  flex-wrap: wrap;
  display: flex;
  align-items: center;
  gap: 10px 24px;
  padding: 10px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.brand { font-size: 17px; font-weight: 700; letter-spacing: -.02em; white-space: nowrap; }
.search { display: flex; gap: 8px; flex: 1 1 240px; min-width: 0; max-width: 380px; }
.search input {
  flex: 1;
  min-width: 0;
  padding: 8px 16px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--field);
  outline: none;
  transition: border-color .15s, background .15s;
}
.search input:focus { background: var(--surface); border-color: var(--ink); }
.search-field { position: relative; flex: 1; min-width: 0; display: flex; }
.search-btn { flex: none; width: 38px; height: 38px; padding: 0; display: grid; place-items: center; }

/* Icon settings: checkbox, shapes and color on one row, the address under them */
.icon-setting { display: flex; flex-direction: column; gap: 8px; }
.icon-row { display: flex; align-items: center; gap: 8px; }
.icon-row .palette { margin-left: auto; } /* the icon color sits at the right, like Line color */
.settings .check { flex-direction: row; align-items: center; }
.settings .check input { flex: none; width: 16px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; cursor: pointer; white-space: nowrap; }
.check input { width: 16px; height: 16px; margin: 0; accent-color: var(--ink); }
/* Shown but grayed out while the Icon box is unticked */
.icon-opt.is-off { opacity: .4; filter: grayscale(1); pointer-events: none; }
.seg { display: flex; gap: 2px; padding: 3px; background: var(--field); border-radius: 999px; flex: none; }
.seg button { width: 32px; height: 32px; padding: 0; border-radius: 999px; background: transparent; display: grid; place-items: center; color: var(--muted); }
.seg button:hover { background: #e8e8e5; }
.seg button.active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.1); }

.address-field { position: relative; min-width: 0; display: flex; }
.address-field input[type=text] {
  flex: 1;
  min-width: 0;
  height: 38px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--field);
  outline: none;
}
.address-field input[type=text]:focus { background: var(--surface); border-color: var(--ink); }
.address-field input[type=text].invalid { border-color: var(--danger); color: var(--danger); background: #fbeeec; }
/* Address problems show right under the address field */
.field-error {
  position: absolute;
  z-index: 1000;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  padding: 8px 14px;
  border-radius: 12px;
  background: #fbeeec;
  color: var(--danger);
  font-size: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,.08);
}
.field-error[hidden] { display: none; }

.suggestions {
  position: absolute;
  z-index: 1000;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 12px 32px rgba(0,0,0,.1);
}
.suggestions li {
  display: flex;
  flex-direction: column;
  padding: 8px 12px;
  border-radius: 10px;
  cursor: pointer;
}
.suggestions li:hover, .suggestions li.active { background: var(--field); }
.suggestions .name { font-weight: 500; }
.suggestions .where { font-size: 12px; color: var(--muted); }
/* A suggestion that cannot be used here, e.g. an address outside the selected area */
.suggestions li.noted .name { color: var(--muted); }
.suggestions li.noted .where { color: var(--danger); }

/* ---------- Three columns: map | 3D model | settings ---------- */

.layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) 280px;
}
.col { min-width: 0; min-height: 0; }

.map-wrap { position: relative; overflow: hidden; }
#map { position: absolute; inset: 0; background: var(--field); }
/* Grayscale basemap with extra contrast so streets read clearly */
.leaflet-tile-pane { filter: grayscale(1) contrast(1.25) brightness(.9); }
/* Map zoom buttons styled like the 3D view's: a horizontal white pill of round buttons in the bottom-right corner */
.leaflet-control-zoom.leaflet-bar {
  display: flex;
  flex-direction: row;
  gap: 2px;
  padding: 3px;
  border: 0 !important;
  border-radius: 999px !important;
  background: var(--surface);
  box-shadow: 0 2px 12px rgba(0,0,0,.08) !important;
}
.leaflet-control-zoom.leaflet-bar a {
  width: 30px !important;
  height: 30px !important;
  line-height: 30px !important;
  border: 0 !important;
  border-radius: 999px !important;
  background: transparent;
  color: var(--ink) !important;
  font: 400 15px/30px Inter, sans-serif !important;
}
.leaflet-control-zoom.leaflet-bar a:hover { background: var(--field); }
.leaflet-right .leaflet-control-zoom { margin: 0 10px 10px 0; }
.leaflet-control-attribution { background: rgba(255,255,255,.7) !important; font-size: 10px; }

.frame {
  position: absolute;
  z-index: 500;
  pointer-events: none;
  border: 1.5px solid var(--ink);
  box-shadow: 0 0 0 9999px rgba(17, 17, 17, .28);
}
.frame-info {
  position: absolute;
  left: 0;
  bottom: 100%;
  margin-bottom: 8px;
  padding: 3px 10px;
  background: var(--ink);
  color: #fff;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .01em;
  white-space: nowrap;
}

/* ---------- 3D model ---------- */

.model {
  display: flex;
  border-left: 1px solid var(--line);
}

.view3d-wrap {
  position: relative;
  flex: 1 1 0;
  min-height: 320px;
  background: var(--field);
}
/* The 3D canvas leaves a strip on the right for the zoom buttons, so they never cover the model */
.view3d { position: absolute; inset: 0 0 52px 0; } /* clear of the zoom bar along the bottom */
.view3d canvas { display: block; cursor: grab; }
.view3d-wrap:focus { outline: none; } /* focusable for the + / − keys; no ring around the whole view */
.view3d canvas:active { cursor: grabbing; }
.zoom3d {
  position: absolute;
  bottom: 10px;
  right: 10px;
  display: flex;
  flex-direction: row;
  gap: 2px;
  padding: 3px;
  background: var(--surface);
  border-radius: 999px;
  box-shadow: 0 2px 12px rgba(0,0,0,.08);
}
.zoom3d button { width: 30px; height: 30px; padding: 0; background: transparent; font-size: 15px; }
.zoom3d button:hover { background: var(--field); }
.zoom3d #zoom-fit { font-size: 10px; }

.status {
  position: absolute;
  z-index: 2;
  left: 12px;
  bottom: 12px;
  max-width: calc(100% - 76px);
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 2px 12px rgba(0,0,0,.08);
  color: var(--muted);
  font-size: 12px;
}
.status.error { background: #fbeeec; color: var(--danger); }

/* ---------- Settings panel: every control stacked on the right of the model ---------- */

.settings {
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 20px;
  overflow-y: auto;
  background: var(--surface);
  border-left: 1px solid var(--line);
}
.settings label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  white-space: nowrap;
}
/* The control takes the rest of the row */
.settings label > select,
.settings label > input { flex: 1 1 0; }
.settings .line-width output { flex: none; font-weight: 500; font-variant-numeric: tabular-nums; }

.settings input, .settings select { width: 100%; min-width: 0; font-weight: 400; }
.settings input[type=text], .settings select {
  height: 38px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: var(--field);
  color: var(--ink);
  font-size: 13px;
  outline: none;
  transition: border-color .15s, background .15s;
}
.settings input:focus, .settings select:focus { background: var(--surface); border-color: var(--ink); }
.settings input[type=range] { height: 24px; margin: 0; }


/* The icon on the map: drawn at its printed 8 mm size relative to the frame */
.map-icon { background: none; border: 0; cursor: grab; filter: drop-shadow(0 1px 2px rgba(0,0,0,.35)); }
.map-icon svg { display: block; }

/* Color pickers: a square swatch of the current color; tapping it opens a row of the five colors under it */
.settings .swatch { display: flex; align-items: center; gap: 10px; font-size: 13px; font-weight: 500; }
.palette { position: relative; display: inline-flex; flex: none; }
.settings .swatch .palette { margin-left: auto; }
.palette-current, .palette-menu button {
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid rgba(0,0,0,.15); /* keeps white visible */
  border-radius: 6px;
  cursor: pointer;
}
.palette-current:hover { box-shadow: 0 0 0 3px var(--field); }
.palette-menu {
  position: absolute;
  z-index: 1000;
  top: calc(100% + 6px);
  right: 0;
  display: flex;
  gap: 6px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0,0,0,.12);
}
.palette-menu[hidden] { display: none; }
.palette-menu button { width: 26px; height: 26px; }
.palette-menu button[aria-selected="true"] { outline: 2px solid var(--ink); outline-offset: 2px; }

/* Product and 3D print sizes, then the download button at the bottom of the panel */
.sizes { margin: 6px 0 0; padding-top: 16px; border-top: 1px solid var(--line); display: grid; gap: 6px; font-size: 13px; }
.sizes div { display: flex; justify-content: space-between; gap: 8px; white-space: nowrap; }
.sizes dt { color: var(--muted); }
.sizes dd { margin: 0; font-weight: 500; font-variant-numeric: tabular-nums; }

.settings .primary { height: 44px; width: 100%; margin-top: auto; flex: none; }
.legal { margin: -6px 0 0; font-size: 11px; color: var(--muted); text-align: center; }

/* ---------- Phones: the settings sit in a full-width panel along the bottom with large, touch-friendly controls;
   above it the map (left) and the 3D model (right) share the space, side by side and the same size. app.js sets
   --sheet-h, the panel's height ---------- */
@media (max-width: 760px) {
  body { height: 100dvh; }

  .topbar { gap: 8px 10px; padding: 8px 12px; }
  .brand { font-size: 15px; }
  .search { flex: 1 1 0; max-width: none; }
  .search input { font-size: 16px; } /* 16px or more, or iPhone Safari zooms the page when it is focused */

  .layout { display: block; position: relative; overflow: hidden; }
  .map-wrap, .model { position: absolute; top: 0; bottom: var(--sheet-h, 45%); border: 0; }
  .map-wrap { left: 0; right: 50%; }
  .model { left: 50%; right: 0; border-left: 1px solid var(--line); overflow: hidden; }
  .view3d-wrap { flex: 1; }
  .view3d { inset: 0 0 56px 0; }
  .zoom3d { top: auto; bottom: 10px; right: 10px; }
  .zoom3d button { width: 36px; height: 36px; font-size: 17px; }
  .leaflet-control-zoom.leaflet-bar a { width: 36px !important; height: 36px !important; line-height: 36px !important; font-size: 17px !important; }
  .status { top: 10px; bottom: auto; left: 10px; right: 10px; }

  /* Settings panel: two columns of large controls; the icon row, the address and Text on base / Line color follow */
  .settings {
    position: absolute;
    z-index: 5;
    left: 0;
    right: 0;
    bottom: 0;
    max-height: 55%;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    align-content: start;
    gap: 10px 16px;
    padding: 14px 16px calc(14px + env(safe-area-inset-bottom));
    border: 0;
    border-top: 1px solid var(--line);
    box-shadow: 0 -6px 24px rgba(0,0,0,.06);
  }
  .settings .icon-setting { grid-column: 1 / -1; }
  .settings label, .settings .swatch { gap: 10px; font-size: 14px; }
  /* Menus and the text box get the cell's full width, with their label above */
  .settings .density, .settings .wood, .settings .text { flex-direction: column; align-items: stretch; gap: 4px; font-size: 12px; color: var(--muted); }
  .settings .density > select, .settings .wood > select, .settings .text > input { flex: none; width: 100%; color: var(--ink); }
  .settings .swatch { align-self: end; min-height: 44px; }
  .settings select,
  .settings input[type=text] { height: 44px; padding: 0 12px; font-size: 16px; } /* 16px: no zoom on focus */
  .settings .check input { width: 24px; height: 24px; }
  .icon-row { gap: 12px; }
  .seg { padding: 3px; gap: 4px; }
  .seg button { width: 40px; height: 40px; }
  .seg button svg { width: 20px; height: 20px; }
  .palette-current { width: 44px; height: 44px; border-radius: 10px; }
  .palette-menu { gap: 8px; padding: 8px; bottom: calc(100% + 8px); top: auto; } /* opens upward from the bottom panel */
  .palette-menu button { width: 40px; height: 40px; }
  .settings .sizes { align-self: center; gap: 4px; margin: 0; padding: 0; border: 0; font-size: 12px; }
  .settings .sizes div { gap: 6px; justify-content: flex-start; }
  .settings .primary { height: 48px; margin: 0; padding: 0; font-size: 15px; }
  .legal { grid-column: 1 / -1; margin: -4px 0 0; }
}
