:root {
  color-scheme: dark;
  --font: "Manrope Variable", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

  --clay: #c66346;
  --clay-light: #e3957a;
  --clay-bright: #f08a62;
  --clay-soft: rgba(198, 99, 70, 0.18);

  --ink: #0d0f14;
  --surface-1: #12151c;
  --surface-2: rgba(22, 26, 34, 0.94);
  --surface-3: #232836;
  --fg: #eceae4;
  --muted: #9a978f;
  --border: #2b303d;
  --border-strong: #3b4252;
  --warn: #f0b429;

  --accent: var(--clay);
  --accent-strong: var(--clay-light);
  --accent-soft: var(--clay-soft);
  --select: var(--clay-bright);

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-6: 24px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 14px;
  --text-xs: 11px;
  --text-sm: 12px;
  --text-md: 13px;
  --text-base: 14px;
  --text-lg: 17px;
  --text-xl: 20px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--ink);
  color: var(--fg);
  font: 400 var(--text-md)/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-strong); }
input, button { font: inherit; }

input[type="text"] {
  background: var(--surface-1);
  color: var(--fg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-3);
  outline: none;
}
input[type="text"]:focus { border-color: var(--accent); }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); margin: 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  border-radius: var(--radius-md); padding: var(--space-2) var(--space-4);
  font-size: var(--text-md); font-weight: 500; cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .15s, border-color .15s;
}
.btn-primary { background: var(--accent-soft); color: var(--accent-strong); border: 1px solid var(--accent); }
.btn-secondary { background: transparent; color: var(--fg); border: 1px solid var(--border-strong); }
.btn-secondary:hover { background: var(--surface-3); border-color: var(--accent); }
.btn-small { padding: var(--space-1) var(--space-3); font-size: var(--text-sm); }
:focus-visible { outline: 2px solid var(--accent-strong); outline-offset: 2px; }

.land { position: fixed; inset: 0; }
.land #map { position: absolute; inset: 0; }
.land #left { position: absolute; top: var(--space-3); left: var(--space-3); width: 340px; max-height: calc(100% - 260px);
  display: flex; flex-direction: column; gap: var(--space-2); z-index: 2; }
.land .map-card, .land #parcel { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-lg);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); box-shadow: 0 8px 28px rgba(0, 0, 0, .35); }
.land #search-card { display: flex; flex-direction: column; flex-shrink: 0; overflow: hidden; }
.land .brand { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); padding: var(--space-3) var(--space-3) 0; }
.land .brand a { color: var(--fg); text-decoration: none; font-size: var(--text-lg); font-weight: 700; letter-spacing: -.01em; }
.land .brand .name { display: inline-flex; align-items: center; gap: var(--space-2); }
.land .brand .name img { width: 26px; height: 26px; }
.land a.by { color: var(--muted); font-size: var(--text-xs); text-decoration: none; background: var(--surface-2);
  padding: 2px var(--space-2); border-radius: 0 var(--radius-md) 0 0; margin: var(--space-2) 0 0 calc(-1 * var(--space-3)); }
.land a.by:hover { color: var(--accent-strong); }
.land #map-tools { position: absolute; left: var(--space-3); bottom: 0; z-index: 1;
  display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-2); max-width: 340px; }
.land #map-tools .legend { margin: 0; padding: var(--space-2) var(--space-3); }
/* The overlay boxes span empty map; only their cards and buttons take touches. */
.land #left, .land #map-tools { pointer-events: none; }
.land #left > *, .land #map-tools > *, .land #map-buttons > * { pointer-events: auto; }
.land #map-buttons { pointer-events: none; }
.land #map-buttons { display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-2); }
.map-button { width: 40px; height: 40px; padding: 0; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.map-button.btn-secondary { background: var(--surface-2); }
.map-button.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.land #toggle-settings { margin-top: var(--space-2); }
.land #contours-status { background: var(--surface-2); border-radius: var(--radius-md); padding: 2px var(--space-2); }
.land #contours-status:empty { display: none; }
.land #settings { overflow-y: auto; min-height: 0; }
.land #parcel { position: absolute; top: var(--space-3); right: var(--space-3); width: 360px; max-height: calc(100% - var(--space-6));
  z-index: 2; display: flex; flex-direction: column; overflow-y: auto; padding: var(--space-4); gap: var(--space-4); }
.land #parcel[hidden], .land #settings[hidden] { display: none; }
.land #search { display: flex; gap: var(--space-2); padding: var(--space-2) var(--space-3) var(--space-3); }
.land #q { flex: 1; min-width: 0; }
.land #results { max-height: 50vh; overflow-y: auto; border-top: 1px solid var(--border); }
.land #results:empty { display: none; }
.land .section { padding: var(--space-3); border-bottom: 1px solid var(--border); }
.land .section:last-child { border-bottom: 0; }
.land h3 { display: block; margin: 0 0 var(--space-2); font-size: var(--text-xs); text-transform: uppercase;
  letter-spacing: .08em; color: var(--muted); font-weight: 600; }
.land h3 span { float: right; text-transform: none; letter-spacing: 0; color: var(--fg); font-size: var(--text-sm); }
.land .hint { color: var(--muted); font-size: var(--text-sm); }
.land .result { display: block; width: 100%; text-align: left; padding: var(--space-2); border: 0; border-radius: var(--radius-sm);
  background: none; color: var(--fg); cursor: pointer; }
.land .result:hover, .land .result:focus { background: var(--surface-3); outline: none; }
.land .result small { color: var(--muted); }
.land .head { display: flex; align-items: flex-start; gap: var(--space-2); }
.land .head > div { flex: 1; min-width: 0; }
.land .close { border: 0; background: none; color: var(--muted); font-size: 22px; line-height: 1; cursor: pointer; padding: 0 2px; }
.land .close:hover { color: var(--fg); }
.land .title { font-size: var(--text-lg); font-weight: 650; margin-bottom: 2px; }
.land .sub { color: var(--muted); font-size: var(--text-sm); }
.land .stats { display: grid; gap: var(--space-2); }
.land .stat { background: var(--surface-1); border-radius: var(--radius-md); padding: var(--space-2) var(--space-3); }
.land .stat span { display: block; font-size: var(--text-xs); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; }
.land .stat b { display: block; font-size: var(--text-xl); font-weight: 650; font-variant-numeric: tabular-nums; margin: 1px 0; }
.land .stat small { color: var(--muted); font-size: var(--text-sm); }
.land .obj { display: flex; justify-content: space-between; gap: var(--space-3); padding: var(--space-2) 0; border-bottom: 1px solid var(--border); }
.land .obj:last-child { border-bottom: 0; }
.land .obj > div:last-child { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.land .obj b { font-size: var(--text-base); }
.land .obj small { display: block; color: var(--muted); font-size: var(--text-sm); }
.land .zone-main { font-size: var(--text-base); font-weight: 600; }
.land .swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: var(--space-1); vertical-align: -1px; }
.land .facts { display: flex; flex-wrap: wrap; gap: 2px var(--space-3); margin-top: var(--space-1); font-size: var(--text-sm); font-variant-numeric: tabular-nums; }
.land .facts span { color: var(--muted); }
.land dl { display: grid; grid-template-columns: auto 1fr; gap: 3px var(--space-3); margin: 0; }
.land dt { color: var(--muted); }
.land dd { margin: 0; font-variant-numeric: tabular-nums; }
.land .warn { color: var(--warn); }
.land .links { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.land .toggles { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-1) var(--space-3); }
.land .toggles label, .land .bases label { display: flex; align-items: center; gap: var(--space-2); cursor: pointer; }
.land .bases { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-3); }
.land .legend[hidden] { display: none; }
.land .legend { display: flex; flex-wrap: wrap; gap: 3px var(--space-3); margin-top: var(--space-2); font-size: var(--text-sm); color: var(--muted); }
.land .zt { width: 100%; border-collapse: collapse; font-size: var(--text-sm); font-variant-numeric: tabular-nums; margin: var(--space-1) 0; }
.land .zt th { text-align: left; font-weight: 600; color: var(--muted); font-size: var(--text-xs); }
.land .zt th, .land .zt td { padding: 3px var(--space-1); border-bottom: 1px solid var(--border); }
.land details summary { cursor: pointer; margin: var(--space-2) 0; }
.land .spinner { display: inline-block; width: 11px; height: 11px; margin-right: var(--space-2); vertical-align: -1px;
  border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.land #measure-out { margin-top: var(--space-2); font-variant-numeric: tabular-nums; }
.maplibregl-ctrl-bottom-right .maplibregl-ctrl-attrib { background: var(--surface-2); color: var(--muted);
  font-size: var(--text-xs); padding: 2px var(--space-2); border-radius: var(--radius-md) 0 0 0; }
.maplibregl-ctrl-attrib a { color: var(--muted); }
/* MapLibre's controls take the same 40 px map-button style as ours, one button per box. */
.maplibregl-ctrl-bottom-right .maplibregl-ctrl:not(.maplibregl-ctrl-attrib) { margin: 0 var(--space-3) var(--space-2) 0; }
.maplibregl-ctrl-group { background: none; border: 0; box-shadow: none; display: flex; flex-direction: column; gap: var(--space-2); }
.maplibregl-ctrl-group:not(:empty) { box-shadow: none; }
.maplibregl-ctrl-group button { width: 40px; height: 40px; color: var(--fg); background: var(--surface-2);
  border: 1px solid var(--border-strong) !important; border-radius: var(--radius-md) !important;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.maplibregl-ctrl-group button:not(:disabled):hover { background-color: var(--surface-3); border-color: var(--accent) !important; }
.maplibregl-ctrl-group button { display: flex; align-items: center; justify-content: center; padding: 0; }
.maplibregl-ctrl-group button .maplibregl-ctrl-icon { background-image: none !important; width: 20px; height: 20px; display: block; }
.maplibregl-ctrl-group .maplibregl-ctrl-icon svg { display: block; }
.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-active, .maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-background { color: var(--accent-strong); }
.maplibregl-ctrl-group button:disabled .maplibregl-ctrl-icon { opacity: .4; }
.maplibregl-ctrl-scale { background: var(--surface-2); color: var(--muted); border-color: var(--muted); }

@media (pointer: coarse) {
  .maplibregl-ctrl-zoom-in, .maplibregl-ctrl-zoom-out { display: none !important; }
}

@media (max-width: 640px) {
  .land #left { left: var(--space-2); right: var(--space-2); top: var(--space-2); width: auto; max-height: calc(100% - 260px); align-items: flex-start; }
  .land #settings { width: 100%; }
  .land .brand { justify-content: flex-start; gap: var(--space-3); padding: var(--space-2) var(--space-3) var(--space-2) var(--space-2); }
  .land #parcel { left: var(--space-2); right: var(--space-2); top: auto; bottom: var(--space-2); width: auto; max-height: 50%; }
  .land #map-tools { left: var(--space-2); right: 56px; }
  .land #legend { display: none !important; }
  .maplibregl-ctrl-bottom-right .maplibregl-ctrl:not(.maplibregl-ctrl-attrib) { margin-right: var(--space-2); }
  .land a.by { margin-left: calc(-1 * var(--space-2)); }
}
