:root {
  --bg: #f6f2ed;
  --ink: #1e1b16;
  --muted: #5a5247;
  --accent-700: #c3541b;
  --accent-500: #d36b2d;
  --accent-300: #e59b6a;
  --accent-100: #f9dfcb;
  --panel: #ffffff;
  --shadow: rgba(30, 27, 22, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: "IBM Plex Sans", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at top, #fff5e6 0%, var(--bg) 60%);
  overflow: hidden;
}

.hidden {
  display: none;
}

.app {
  height: 100%;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-size: 12px;
  color: var(--muted);
  margin: 0 0 8px;
}

h1 {
  font-size: clamp(22px, 2.4vw, 28px);
  margin: 0 0 6px;
}

.lead {
  font-size: 16px;
  color: var(--muted);
  margin: 0 0 8px;
}

.layout {
  display: flex;
  height: 100%;
  position: relative;
}

.map-panel {
  position: relative;
  flex: 1;
  min-width: 0;
  z-index: 0;
  isolation: isolate;
}

.map {
  height: 100%;
  width: 100%;
  position: relative;
  z-index: 0;
}

.leaflet-container {
  font-family: "IBM Plex Sans", sans-serif;
}

.leaflet-overlay-pane .page-rect {
  fill-opacity: 0.3;
}

.map-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1000;
}

.map-toast {
  position: absolute;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 8px);
  background: rgba(255, 255, 255, 0.96);
  color: var(--ink);
  border: 1px solid #e1d8c9;
  border-radius: 14px;
  padding: 14px 18px;
  font-size: 14px;
  line-height: 1.45;
  box-shadow: 0 16px 30px rgba(30, 27, 22, 0.18);
  display: inline-flex;
  align-items: center;
  gap: 10px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 1002;
  max-width: min(520px, calc(100% - 32px));
  text-align: center;
}

.map-toast.visible {
  opacity: 1;
  transform: translate(-50%, 0);
  pointer-events: auto;
  animation: toast-breathe 2.6s ease-in-out 0.6s 2;
}

@keyframes toast-breathe {
  0% {
    box-shadow: 0 16px 30px rgba(30, 27, 22, 0.18);
  }
  50% {
    box-shadow: 0 20px 38px rgba(30, 27, 22, 0.26);
  }
  100% {
    box-shadow: 0 16px 30px rgba(30, 27, 22, 0.18);
  }
}

.map-toast-close {
  border: none;
  background: rgba(30, 27, 22, 0.08);
  color: var(--ink);
  width: 24px;
  height: 24px;
  border-radius: 8px;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.map-toast-close:hover,
.map-toast-close:focus-visible {
  background: rgba(30, 27, 22, 0.16);
}


.map-hint {
  position: fixed;
  inset: 0;
  padding: 24px;
  pointer-events: none;
  z-index: 3000;
}

.map-hint-scrim {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
}

.map-hint-scrim path {
  fill: rgba(25, 22, 18, 0.5);
}

.map-hint-outline {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

.map-hint-outline rect {
  fill: none;
  stroke: rgba(211, 107, 45, 0.95);
  stroke-width: 2.5;
  filter: drop-shadow(0 0 0 rgba(211, 107, 45, 0))
    drop-shadow(0 0 8px rgba(211, 107, 45, 0.25))
    drop-shadow(0 0 18px rgba(211, 107, 45, 0.18));
}

.map-hint-outline #mapHintOutlinePrimary {
  display: block;
}

.map-hint-highlight {
  position: absolute;
  left: var(--hint-x, 0px);
  top: var(--hint-y, 0px);
  width: var(--hint-w, 0px);
  height: var(--hint-h, 0px);
  border-radius: var(--hint-radius, 12px);
  background: transparent;
  border: 2px solid rgba(211, 107, 45, 0.9);
  box-shadow: 0 0 0 6px rgba(211, 107, 45, 0.12);
  z-index: 1;
}

.map-hint-highlight.secondary {
  left: var(--hint2-x, 0px);
  top: var(--hint2-y, 0px);
  width: var(--hint2-w, 0px);
  height: var(--hint2-h, 0px);
  border-radius: var(--hint2-radius, 16px);
  display: none;
}

.map-hint-tip {
  position: absolute;
  left: var(--hint-tip-x, 0px);
  top: var(--hint-tip-y, 0px);
  max-width: min(320px, calc(100% - 32px));
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid #e1d8c9;
  border-radius: 14px;
  padding: 12px 16px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--ink);
  box-shadow: 0 16px 30px rgba(30, 27, 22, 0.2);
  z-index: 2;
  display: grid;
  gap: 4px;
  text-align: center;
}

.map-hint-tip strong {
  font-size: 13px;
}

.map-hint-tip-primary,
.map-hint-tip-secondary {
  max-width: min(320px, calc(100% - 32px));
  background: rgba(255, 255, 255, 0.96);
  color: var(--ink);
}

.map-action {
  position: absolute;
  bottom: 60px;
  right: 18px;
  border: none;
  background: rgba(30, 27, 22, 0.9);
  color: white;
  padding: 12px 18px;
  border-radius: 12px;
  font-size: 14px;
  cursor: pointer;
  pointer-events: auto;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.25);
  z-index: 1001;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.map-action:hover,
.map-action:focus-visible {
  background: rgba(30, 27, 22, 0.75);
}

.map-action-icon {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.16);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  line-height: 1;
}

.selection-bar {
  position: absolute;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  background: rgba(30, 27, 22, 0.85);
  color: white;
  border-radius: 999px;
  font-size: 12px;
  pointer-events: auto;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
  transform: translate(-50%, -100%);
  z-index: 1002;
}

.selection-bar.hidden {
  display: none;
}

.chip {
  border: none;
  background: rgba(255, 255, 255, 0.18);
  color: white;
  padding: 3px 8px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 11px;
}

.chip.hidden {
  display: none;
}

.chip.danger {
  background: rgba(255, 120, 80, 0.2);
  border: 1px solid rgba(255, 120, 80, 0.4);
}

.page-label {
  display: inline-flex;
  align-items: center;
  color: #1e1b16;
  font-size: 13px;
  font-weight: 700;
  font-family: "IBM Plex Mono", monospace;
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8);
  transform: translate(8px, 8px);
}

.selection-select {
  appearance: none;
  border: none;
  background: #efe7df;
  color: #1e1b16;
  padding: 4px 18px 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-family: "IBM Plex Sans", sans-serif;
  cursor: pointer;
  position: relative;
}

.selection-select:focus-visible {
  outline: 1px solid rgba(30, 27, 22, 0.4);
  outline-offset: 2px;
}

.selection-select-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.selection-select-wrap::after {
  content: "▾";
  font-size: 10px;
  color: rgba(30, 27, 22, 0.7);
  pointer-events: none;
  position: absolute;
  right: 8px;
}

.sidebar {
  width: min(36vw, 440px);
  max-width: 520px;
  min-width: 320px;
  height: 100%;
  padding: 24px 22px 32px;
  background: var(--panel);
  border-left: 1px solid #efe4d7;
  overflow-y: auto;
  box-shadow: -12px 0 30px rgba(30, 27, 22, 0.08);
  position: relative;
  z-index: 2;
}

.sidebar-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.sidebar-toggle {
  border: 1px solid #e1d8c9;
  background: #fffaf3;
  border-radius: 10px;
  width: 40px;
  height: 40px;
  cursor: pointer;
  font-size: 18px;
  display: none;
}

.panel {
  margin-top: 18px;
  padding: 20px;
  background: #fffdf9;
  border-radius: 18px;
  box-shadow: 0 10px 28px var(--shadow);
}

.sidebar-footer {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid #efe4d7;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}

.sidebar-footer-title {
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 8px;
}

.source-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11.5px;
  line-height: 1.4;
}

.source-table th,
.source-table td {
  padding: 6px 6px 6px 0;
  vertical-align: top;
  border-bottom: 1px solid rgba(30, 27, 22, 0.08);
}

.source-table th {
  text-align: left;
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(30, 27, 22, 0.55);
  font-weight: 600;
}

.source-table tbody tr:last-child td {
  border-bottom: none;
}

.source-table a {
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px solid rgba(30, 27, 22, 0.25);
}

.source-table a:hover,
.source-table a:focus-visible {
  border-bottom-color: var(--accent-500);
  color: var(--accent-700);
}

.controls {
  display: grid;
  gap: 16px;
}

.upload {
  display: grid;
  gap: 12px;
}

.track-color {
  display: grid;
  gap: 10px;
}

.track-opacity {
  display: grid;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

.track-opacity-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.track-opacity input[type="range"] {
  flex: 1;
  accent-color: var(--accent-500);
}

.track-opacity output {
  min-width: 44px;
  text-align: right;
  color: var(--ink);
  font-weight: 600;
  font-size: 12px;
}

.height-opacity {
  display: grid;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

.height-opacity-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.height-opacity input[type="range"] {
  flex: 1;
  accent-color: var(--accent-500);
}

.height-opacity output {
  min-width: 44px;
  text-align: right;
  color: var(--ink);
  font-weight: 600;
  font-size: 12px;
}

.height-opacity.hidden {
  display: none;
}

.height-mask {
  display: grid;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

.height-mask.hidden {
  display: none;
}

.height-mask-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  color: var(--ink);
}

.height-mask-row {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.height-mask-toggle input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent-500);
}

.height-mask-swatch {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  border: 1px solid rgba(30, 27, 22, 0.2);
  background: var(--mask-color, transparent);
  display: inline-block;
}

.height-mask-swatch[data-color="#92d060"] {
  --mask-color: #92d060;
}

.height-mask-swatch[data-color="#d9f08b"] {
  --mask-color: #d9f08b;
}

.layer-card {
  grid-column: 1 / -1;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid #efe4d7;
  background: #fffaf3;
  display: grid;
  gap: 10px;
}

.layer-card .field {
  gap: 8px;
}

.range-field {
  display: grid;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

.range-row {
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
}

.range-field input[type="range"] {
  flex: 1;
  accent-color: var(--accent-500);
}

.range-field output {
  position: absolute;
  right: 0;
  top: -26px;
  min-width: 44px;
  text-align: center;
  color: var(--ink);
  font-weight: 600;
  font-size: 12px;
  background: #fffaf3;
  border: 1px solid #e1d8c9;
  border-radius: 8px;
  padding: 4px 8px;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
  box-shadow: 0 6px 16px rgba(30, 27, 22, 0.08);
}

.range-field:hover output,
.range-field:focus-within output {
  opacity: 1;
}

.range-field.hidden {
  display: none;
}

.color-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.color-swatch {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
}

.color-swatch.active {
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(30, 27, 22, 0.16);
}

.field-title {
  font-weight: 600;
  font-size: 14px;
}

.dropzone {
  border: 2px dashed #e1d8c9;
  border-radius: 16px;
  padding: 22px;
  display: grid;
  place-items: center;
  text-align: center;
  background: #fffaf3;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.map-hint-active .dropzone {
  background: #fffaf3 !important;
  box-shadow: 0 18px 34px rgba(30, 27, 22, 0.18), 0 0 0 2px rgba(211, 107, 45, 0.2);
  border-color: rgba(211, 107, 45, 0.6);
}

.map-hint-active .dropzone.active {
  background: #fffaf3 !important;
  box-shadow: 0 18px 34px rgba(30, 27, 22, 0.22), 0 0 0 2px rgba(211, 107, 45, 0.3);
  border-color: rgba(211, 107, 45, 0.7);
}

.dropzone strong {
  display: block;
  font-size: 16px;
}

.dropzone span {
  color: var(--muted);
  font-size: 13px;
}

.dropzone input[type="file"] {
  display: none;
}


.dropzone.active {
  border-color: var(--accent-500);
  background: var(--accent-100);
}

.file-meta {
  font-size: 13px;
  color: var(--muted);
  display: grid;
  gap: 4px;
}

.file-meta.hidden {
  display: none;
}

.control-section {
  border: 1px solid #f0e4d7;
  border-radius: 16px;
  padding: 16px;
  background: #fffdf9;
  display: grid;
  gap: 12px;
}

.section-header {
  font-weight: 600;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.advanced {
  display: grid;
  gap: 14px;
}

.advanced summary {
  list-style: none;
  cursor: pointer;
  font-weight: 600;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
}

.advanced summary::before {
  content: "+";
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent-100);
  color: var(--ink);
  font-weight: 700;
}

.advanced[open] summary::before {
  content: "–";
}

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

.section-grid {
  display: grid;
  gap: 12px;
}

@media (min-width: 760px) {
  .section-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
  }
}

.field {
  display: grid;
  gap: 6px;
  font-weight: 600;
  font-size: 14px;
}

.field input[type="file"],
.field input[type="number"],
.field select {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #e1d8c9;
  font-family: "IBM Plex Sans", sans-serif;
  font-size: 14px;
}

.field input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent-500);
}

.tooltip {
  display: inline-grid;
  place-items: center;
  margin-left: 6px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent-100);
  color: var(--muted);
  font-size: 12px;
  cursor: help;
  position: relative;
}

.tooltip::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 130%;
  left: 50%;
  transform: translateX(-50%);
  background: #1f1a14;
  color: #f7f1eb;
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 12px;
  width: max-content;
  max-width: 220px;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.tooltip:hover::after,
.tooltip:focus-visible::after {
  opacity: 1;
  transform: translateX(-50%) translateY(-4px);
}

.segmented {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.segmented button {
  border: 1px solid #e1d8c9;
  background: #fffaf3;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 600;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.segmented button:hover,
.segmented button:focus-visible {
  border-color: var(--accent-300);
  color: var(--ink);
}

.segmented button.active {
  background: var(--accent-500);
  border-color: var(--accent-500);
  color: white;
}


.button-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
}

.sticky-render {
  position: sticky;
  bottom: 0;
  padding: 36px 0 8px;
  background: linear-gradient(
    180deg,
    rgba(255, 253, 249, 0) 0%,
    rgba(255, 253, 249, 0.92) 45%,
    #fffdf9 100%
  );
  z-index: 3;
}

.render-status {
  min-height: 18px;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.sticky-render .render-status {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 54px;
  padding: 0 2px;
}

.render-status.visible {
  opacity: 1;
}

.hidden {
  display: none !important;
}

.secondary {
  border: 1px solid #e1d8c9;
  background: #fffaf3;
  color: var(--ink);
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
  cursor: pointer;
  font-weight: 600;
}

.secondary:hover,
.secondary:focus-visible {
  border-color: var(--accent-300);
  color: var(--ink);
}

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

.primary {
  background: var(--ink);
  color: white;
  border: none;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
  cursor: pointer;
}

.primary.ready {
  background: var(--accent-700);
  box-shadow: 0 12px 24px rgba(195, 84, 27, 0.25);
}

.primary:hover,
.primary:focus-visible {
  background: var(--accent-700);
}

.primary.ready:hover,
.primary.ready:focus-visible {
  background: var(--accent-500);
}

.primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.status {
  margin-top: 16px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 13px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.spinner {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid #e1d8c9;
  border-top-color: var(--accent-500);
  animation: spin 0.8s linear infinite;
}

.spinner.hidden {
  display: none;
}

.render-progress {
  width: 100%;
  max-width: 360px;
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  appearance: none;
}

.sticky-render .render-progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 48px;
}

.render-progress.hidden {
  display: none;
}

.render-progress::-webkit-progress-bar {
  background-color: #f0e4d7;
  border-radius: 999px;
}

.render-progress::-webkit-progress-value {
  background: linear-gradient(90deg, var(--accent-300), var(--accent-500));
  border-radius: 999px;
}

.render-progress::-moz-progress-bar {
  background: linear-gradient(90deg, var(--accent-300), var(--accent-500));
  border-radius: 999px;
}
.progress {
  list-style: none;
  padding: 0;
  margin: 12px 0 0;
  display: grid;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

.progress li::before {
  content: "○";
  display: inline-block;
  width: 18px;
}

.progress li.active {
  color: var(--ink);
  font-weight: 600;
}

.progress li.active::before {
  content: "◐";
  color: var(--accent-500);
}

.progress li.done::before {
  content: "✓";
  color: var(--accent-500);
}

.actions {
  margin-top: 16px;
}

.download {
  display: inline-block;
  padding: 10px 16px;
  border-radius: 12px;
  background: var(--accent-700);
  color: white;
  text-decoration: none;
  font-weight: 600;
}

.download:hover,
.download:focus-visible {
  background: var(--accent-500);
}

.download.disabled {
  background: #c8b7a6;
  pointer-events: none;
}

@media (max-width: 960px) {
  .sidebar {
    position: absolute;
    right: 0;
    top: 0;
    height: 100%;
    width: min(90vw, 460px);
    transform: translateX(100%);
    transition: transform 0.3s ease;
    border-left: none;
    box-shadow: -18px 0 40px rgba(30, 27, 22, 0.18);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
}

@media (max-width: 720px) {
  .panel {
    padding: 18px;
  }

  .section-grid {
    gap: 12px;
  }
}

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

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(30, 27, 22, 0.35);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 3000;
}

.modal-overlay.open {
  display: flex;
}

.modal {
  background: #fffdf9;
  border: 1px solid #efe4d7;
  border-radius: 18px;
  padding: 22px;
  width: min(92vw, 420px);
  box-shadow: 0 18px 40px rgba(30, 27, 22, 0.22);
}

.modal h3 {
  margin: 0 0 8px;
  font-size: 18px;
}

.modal p {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  flex-wrap: wrap;
}
