/* ==================================================================
   Cartopress — hand-written CSS, no frameworks.
   ================================================================== */

:root {
  --bg: #0a0c10;
  --surface: #12151b;
  --surface-2: #191d25;
  --surface-3: #212632;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.16);
  --text: #e9ecf1;
  --muted: #8a93a3;
  --muted-dim: #5f6878;
  --accent: #ff8c42;
  --accent-soft: rgba(255, 140, 66, 0.14);
  --accent-line: rgba(255, 140, 66, 0.4);
  --danger: #ff6b6b;

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;

  --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-display: 'Space Grotesk', var(--font-ui);

  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --panel-width: 372px;
  --gutter: 22px;
}

* {
  box-sizing: border-box;
}

/* Author-level `display` beats the UA stylesheet's [hidden] rule, so state it
   explicitly — several panels below are flex containers toggled via `hidden`. */
[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background:
    radial-gradient(1100px 620px at 82% -8%, rgba(255, 140, 66, 0.07), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

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

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px var(--gutter) 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand-mark {
  width: 40px;
  height: 40px;
  flex: none;
  color: var(--accent);
}

.brand-mark .mark-bg {
  fill: var(--surface-2);
  stroke: var(--line);
}

.brand-text h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.brand-text p {
  margin: 1px 0 0;
  color: var(--muted);
  font-size: 12.5px;
}

.icon {
  width: 18px;
  height: 18px;
  flex: none;
}

.ghost-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 15px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.ghost-btn:hover {
  color: var(--text);
  border-color: var(--line-strong);
  background: var(--surface-2);
}

.ghost-btn .icon {
  color: var(--accent);
}

/* ------------------------------------------------------------------
   Layout
   ------------------------------------------------------------------ */

.layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--panel-width);
  gap: var(--gutter);
  padding: 0 var(--gutter) 6px;
}

/* ------------------------------------------------------------------
   Map stage
   ------------------------------------------------------------------ */

.stage {
  position: relative;
  min-height: 0;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
}

#map {
  position: absolute;
  inset: 0;
  background: #0d1015;
}

.leaflet-container {
  font-family: var(--font-ui);
  background: #0d1015;
}

.leaflet-control-attribution {
  background: rgba(10, 12, 16, 0.72) !important;
  color: var(--muted) !important;
  font-size: 10.5px !important;
  padding: 3px 8px !important;
  border-radius: 999px 0 0 0;
}

.leaflet-control-attribution a {
  color: var(--muted) !important;
}

.leaflet-bar a {
  background: rgba(18, 21, 27, 0.94) !important;
  color: var(--text) !important;
  border-bottom-color: var(--line) !important;
}

.leaflet-bar a:hover {
  background: var(--surface-3) !important;
}

/* Export frame overlay ------------------------------------------- */

.frame-layer {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  z-index: 500;
  overflow: hidden;
}

.frame {
  position: relative;
  width: 60%;
  aspect-ratio: 16 / 9;
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 3px;
  box-shadow: 0 0 0 9999px rgba(7, 9, 13, 0.42);
  transition: box-shadow 0.2s;
}

.frame-corner {
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2px solid var(--accent);
}

.frame-corner.tl {
  top: -1px;
  left: -1px;
  border-right: 0;
  border-bottom: 0;
}
.frame-corner.tr {
  top: -1px;
  right: -1px;
  border-left: 0;
  border-bottom: 0;
}
.frame-corner.bl {
  bottom: -1px;
  left: -1px;
  border-right: 0;
  border-top: 0;
}
.frame-corner.br {
  bottom: -1px;
  right: -1px;
  border-left: 0;
  border-top: 0;
}

.frame-badge {
  position: absolute;
  top: -13px;
  left: 50%;
  transform: translateX(-50%);
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(10, 12, 16, 0.9);
  border: 1px solid var(--accent-line);
  color: var(--text);
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.frame.oversized {
  border-style: dashed;
  border-color: var(--accent);
}

/* Stage HUD ------------------------------------------------------ */

.stage-hud {
  position: absolute;
  left: 16px;
  top: 16px;
  z-index: 600;
  max-width: min(58%, 460px);
  padding: 12px 16px;
  border-radius: var(--radius);
  background: rgba(10, 12, 16, 0.72);
  backdrop-filter: blur(10px);
  border: 1px solid var(--line);
  pointer-events: none;
}

.place-name {
  margin: 0;
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 500;
  letter-spacing: -0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.place-meta {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}

.fit-btn {
  position: absolute;
  right: 16px;
  top: 16px;
  z-index: 600;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 13px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(10, 12, 16, 0.78);
  backdrop-filter: blur(10px);
  color: var(--muted);
  font-size: 12.5px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.fit-btn:hover {
  color: var(--text);
  border-color: var(--accent-line);
}

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

.panel {
  min-height: 0;
  overflow-y: auto;
  padding: 22px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 26px;
  scrollbar-width: thin;
  scrollbar-color: var(--surface-3) transparent;
}

.panel::-webkit-scrollbar {
  width: 8px;
}
.panel::-webkit-scrollbar-thumb {
  background: var(--surface-3);
  border-radius: 999px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
}

.field-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--muted-dim);
}

.field-value {
  font-family: var(--font-display);
  font-size: 12.5px;
  letter-spacing: 0;
  text-transform: none;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.label-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.unit-toggle {
  display: inline-flex;
  padding: 2px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-2);
}

.unit-toggle button {
  padding: 2px 8px;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--muted-dim);
  font-size: 10.5px;
  letter-spacing: 0.04em;
  text-transform: none;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}

.unit-toggle button:hover {
  color: var(--text);
}

.unit-toggle button[aria-checked='true'] {
  background: var(--accent-soft);
  color: var(--accent);
}

.hint {
  margin: 0;
  font-size: 11.5px;
  color: var(--muted-dim);
  font-variant-numeric: tabular-nums;
}

/* Search --------------------------------------------------------- */

.search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 13px;
  color: var(--muted-dim);
  pointer-events: none;
}

.search-wrap input {
  width: 100%;
  padding: 12px 40px 12px 40px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface-2);
  transition: border-color 0.15s, background 0.15s;
}

.search-wrap input::placeholder {
  color: var(--muted-dim);
}

.search-wrap input:focus {
  outline: none;
  border-color: var(--accent-line);
  background: var(--surface-3);
}

.spinner {
  position: absolute;
  right: 14px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--line-strong);
  border-top-color: var(--accent);
  animation: spin 0.7s linear infinite;
}

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

.results {
  list-style: none;
  margin: 0;
  padding: 5px;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 40;
  border-radius: var(--radius);
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  box-shadow: 0 20px 44px rgba(0, 0, 0, 0.55);
  max-height: 290px;
  overflow-y: auto;
}

.results li {
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.results li:hover,
.results li[aria-selected='true'] {
  background: var(--surface-3);
}

.results .r-primary {
  display: block;
  font-weight: 500;
}

.results .r-secondary {
  display: block;
  color: var(--muted);
  font-size: 11.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.results .r-empty {
  padding: 12px;
  color: var(--muted);
  cursor: default;
}

/* Style presets -------------------------------------------------- */

.style-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 9px;
}

.style-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface-2);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, background 0.15s;
}

.style-btn:hover {
  border-color: var(--line-strong);
}

.style-btn[aria-checked='true'] {
  border-color: var(--accent);
  background: var(--accent-soft);
}

/* The swatch shows a live tile from the current view, with the flat gradient
   underneath as a fallback while it loads (or if the request fails). */
.style-swatch {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  flex: none;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background-size: cover;
  background-position: center;
}

.style-name {
  font-size: 12.5px;
  line-height: 1.25;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.style-group {
  grid-column: 1 / -1;
  margin: 6px 0 -2px;
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted-dim);
}

.style-group:first-child {
  margin-top: 0;
}

/* Neon colour ---------------------------------------------------- */

.style-colours {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 12px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface-2);
}

.colour-slot {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.swatch-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.colour-dot {
  width: 26px;
  height: 26px;
  padding: 0;
  border-radius: 50%;
  border: 2px solid transparent;
  box-shadow: 0 0 0 1px var(--line-strong), 0 0 12px -2px currentColor;
  cursor: pointer;
  transition: transform 0.12s, border-color 0.12s;
}

.colour-dot:hover {
  transform: scale(1.12);
}

.colour-dot[aria-checked='true'] {
  border-color: var(--text);
  box-shadow: 0 0 0 1px var(--text), 0 0 16px -1px currentColor;
}

.colour-custom {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
}

.colour-custom input[type='color'] {
  width: 34px;
  height: 26px;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: none;
  cursor: pointer;
}

.colour-custom input[type='color']::-webkit-color-swatch-wrapper {
  padding: 2px;
}

.colour-custom input[type='color']::-webkit-color-swatch {
  border: 0;
  border-radius: 4px;
}

/* Switch --------------------------------------------------------- */

.switch {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}

.switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.switch-track {
  position: relative;
  width: 36px;
  height: 20px;
  flex: none;
  border-radius: 999px;
  background: var(--surface-3);
  border: 1px solid var(--line);
  transition: background 0.16s, border-color 0.16s;
}

.switch-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 0.16s, background 0.16s;
}

.switch input:checked + .switch-track {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.switch input:checked + .switch-track .switch-thumb {
  transform: translateX(16px);
  background: var(--accent);
}

.switch input:focus-visible + .switch-track {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.switch-text {
  font-size: 12.5px;
  color: var(--muted);
}

.switch input:checked ~ .switch-text {
  color: var(--text);
}

.switch.is-disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

/* Select --------------------------------------------------------- */

.select-row {
  display: flex;
  gap: 8px;
}

.select-row .select-wrap {
  flex: 1;
  min-width: 0;
}

.icon-btn {
  flex: none;
  width: 44px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--muted);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.icon-btn:hover {
  color: var(--accent);
  border-color: var(--accent-line);
}

.select-wrap {
  position: relative;
  display: flex;
}

.select-wrap select {
  width: 100%;
  appearance: none;
  padding: 12px 38px 12px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface-2);
  cursor: pointer;
}

.select-wrap select:focus {
  outline: none;
  border-color: var(--accent-line);
}

.select-wrap option {
  background: var(--surface-2);
  color: var(--text);
}

.select-chevron {
  position: absolute;
  right: 13px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted-dim);
  pointer-events: none;
}

.custom-size {
  display: flex;
  align-items: flex-end;
  gap: 9px;
}

.custom-size .mini {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 11px;
  color: var(--muted-dim);
}

.custom-size input {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-variant-numeric: tabular-nums;
}

.custom-size input:focus {
  outline: none;
  border-color: var(--accent-line);
}

.custom-size .times {
  padding-bottom: 11px;
  color: var(--muted-dim);
}

/* Slider --------------------------------------------------------- */

.slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 22px;
  background: transparent;
  cursor: pointer;
}

.slider::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 999px;
  background: var(--surface-3);
}

.slider::-moz-range-track {
  height: 4px;
  border-radius: 999px;
  background: var(--surface-3);
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  margin-top: -6px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--surface);
  box-shadow: 0 0 0 1px var(--accent);
}

.slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--surface);
  box-shadow: 0 0 0 1px var(--accent);
}

/* Chips ---------------------------------------------------------- */

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.chip {
  padding: 7px 13px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12.5px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.chip:hover {
  color: var(--text);
  border-color: var(--line-strong);
}

.chip[aria-checked='true'] {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
}

/* More options --------------------------------------------------- */

.advanced {
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.advanced summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
  list-style: none;
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--muted-dim);
  transition: color 0.15s;
}

.advanced summary::-webkit-details-marker {
  display: none;
}

.advanced summary:hover {
  color: var(--text);
}

.summary-chevron {
  transition: transform 0.18s;
}

.advanced[open] .summary-chevron {
  transform: rotate(180deg);
}

.advanced[open] summary {
  margin-bottom: 18px;
}

.advanced .field + .field {
  margin-top: 18px;
}

.text-input {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface-2);
}

.text-input:focus {
  outline: none;
  border-color: var(--accent-line);
}

/* Actions -------------------------------------------------------- */

.actions {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-top: 4px;
}

.primary-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: 100%;
  padding: 14px 18px;
  border: 0;
  border-radius: var(--radius);
  background: var(--accent);
  color: #17110b;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: filter 0.15s, transform 0.06s;
}

.primary-btn:hover:not(:disabled) {
  filter: brightness(1.08);
}

.primary-btn:active:not(:disabled) {
  transform: translateY(1px);
}

.primary-btn:disabled {
  opacity: 0.55;
  cursor: progress;
}

.progress-track {
  height: 4px;
  border-radius: 999px;
  background: var(--surface-3);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: var(--accent);
  transition: width 0.12s linear;
}

.progress-text {
  margin: 7px 0 0;
  font-size: 11.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.status {
  margin: 0;
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--muted);
}

.status.is-error {
  color: var(--danger);
  border-color: rgba(255, 107, 107, 0.32);
  background: rgba(255, 107, 107, 0.08);
}

.status.is-ok {
  color: var(--accent);
  border-color: var(--accent-line);
  background: var(--accent-soft);
}

/* ------------------------------------------------------------------
   Footer
   ------------------------------------------------------------------ */

.footer {
  padding: 12px var(--gutter) 16px;
  color: var(--muted-dim);
  font-size: 11px;
}

.footer p {
  margin: 0;
}

/* ------------------------------------------------------------------
   Responsive — panel drops under the map
   ------------------------------------------------------------------ */

@media (max-width: 1080px) {
  :root {
    --panel-width: 320px;
  }
  .style-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 860px) {
  body {
    height: auto;
    min-height: 100%;
  }

  .layout {
    grid-template-columns: 1fr;
    height: auto;
  }

  .stage {
    height: 58vh;
    min-height: 340px;
  }

  .panel {
    overflow: visible;
    max-height: none;
  }

  .style-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .stage-hud {
    max-width: calc(100% - 32px);
  }

  .topbar {
    flex-wrap: wrap;
  }
}

@media (max-width: 520px) {
  :root {
    --gutter: 14px;
  }

  .brand-text p {
    display: none;
  }

  .fit-btn span {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}
