:root {
  --ink:        #08080a;
  --marble:     #101013;
  --marble-2:   #16161a;
  --marble-3:   #1d1d22;
  --inset:      #0b0b0e;

  --gold:       #c8a951;
  --gold-bright:#e6cf8f;
  --gold-deep:  #8a6f2c;
  --gold-glow:  rgba(200,169,81,.16);

  --ivory:      #f4efe6;
  --stone:      #9a978f;
  --stone-dim:  #6a6862;
  --hairline:   rgba(200,169,81,.20);
  --hairline-2: rgba(244,239,230,.08);

  --ok:   #7ea87a;
  --warn: #c8a951;
  --bad:  #b5654f;

  --c1: #2b2317;
  --c2: #45371f;
  --c3: #614c26;
  --c4: #80652e;
  --c5: #a08039;
  --c6: #bfa055;
  --c7: #d8c184;
  --c8: #f0e4bd;

  --nodata: #2c2c33;

  --serif: "Cormorant Garamond", Georgia, "Times New Roman", serif;
  --sans:  "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono:  ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;

  --radius: 3px;
  --shadow: 0 18px 48px rgba(0,0,0,.62);

  --field-fill: rgba(8,8,10,.62);
  --panel-fill: rgba(15,15,18,.96);
  --scrim:      rgba(4,4,6,.82);
  --line-soft:  rgba(244,239,230,.12);
  --line-faint: rgba(244,239,230,.07);
  --wash:       rgba(244,239,230,.04);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0; height: 100%;
  background: var(--ink);
  color: var(--ivory);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

body { display: flex; flex-direction: column; }
.topbar { flex: 0 0 auto; }
.layout { flex: 1 1 auto; min-height: 0; }

.marble {
  position: relative;
  background-color: var(--marble);
  background-image:
    linear-gradient(118deg, transparent 38%, rgba(244,239,230,.055) 39.2%, transparent 40.4%),
    linear-gradient(118deg, transparent 51%, rgba(244,239,230,.032) 52.4%, transparent 53%),
    linear-gradient(122deg, transparent 66%, rgba(200,169,81,.05) 67.4%, transparent 68.6%),
    linear-gradient(97deg,  transparent 21%, rgba(244,239,230,.028) 22.2%, transparent 23%),
    radial-gradient(120% 90% at 12% 0%,  rgba(200,169,81,.075), transparent 62%),
    radial-gradient(90% 70% at 88% 100%, rgba(244,239,230,.04), transparent 60%);
}

.marble::before {
  content: "";
  position: absolute; inset: 0;
  pointer-events: none;
  opacity: .5;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='220' height='220' filter='url(%23g)' opacity='.32'/%3E%3C/svg%3E");
}

.marble > * { position: relative; z-index: 1; }

.topbar {
  display: flex; align-items: center; gap: 26px;
  height: 66px; padding: 0 24px;
  border-bottom: 1px solid var(--hairline);
  position: relative; z-index: 40;
}

.brand {
  display: flex; align-items: baseline; gap: 12px; flex-shrink: 0;
  text-decoration: none; border-radius: 3px; transition: opacity .15s ease;
}
.brand:hover { opacity: .78; }
.brand:focus-visible { outline: 1px solid var(--gold); outline-offset: 6px; }
.brand-mark {
  font-family: var(--serif);
  font-size: 25px; letter-spacing: .16em;
  color: var(--ivory); text-transform: uppercase;
}
.brand-sub {
  font-size: 10px; letter-spacing: .22em; text-transform: uppercase;
  color: var(--gold);
  padding-left: 12px; border-left: 1px solid var(--hairline);
}

.search-wrap { position: relative; flex: 1; max-width: 440px; }

#search {
  width: 100%; height: 38px; padding: 0 15px;
  background: var(--field-fill);
  border: 1px solid var(--hairline-2);
  border-radius: var(--radius);
  color: var(--ivory); font-size: 13.5px; font-family: inherit;
  letter-spacing: .01em;
  transition: border-color .18s, box-shadow .18s;
}
#search::placeholder { color: var(--stone-dim); }
#search:focus {
  outline: none; border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-glow);
}

.results {
  position: absolute; top: 46px; left: 0; right: 0;
  margin: 0; padding: 5px; list-style: none;
  background: var(--marble-2);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-height: 350px; overflow-y: auto; z-index: 50;
}
.results li {
  padding: 10px 12px; cursor: pointer;
  display: flex; align-items: baseline; gap: 10px;
  border-bottom: 1px solid rgba(244,239,230,.045);
}
.results li:last-child { border-bottom: none; }
.results li:hover { background: rgba(200,169,81,.11); }
.results .r-group {
  display: block; padding: 8px 12px 4px; cursor: default; border-bottom: none;
  font-size: 10px; text-transform: uppercase; letter-spacing: .14em; color: var(--stone-dim);
}
.results .r-group:hover { background: none; }
.r-name { font-size: 13.5px; }
.r-val  { font-family: var(--mono); font-size: 12px; color: var(--gold); }
.r-ctx  {
  font-size: 10px; color: var(--stone-dim); margin-left: auto;
  text-transform: uppercase; letter-spacing: .12em;
}

.topbar-meta { display: flex; align-items: center; gap: 14px; margin-left: auto; flex-shrink: 0; }

.badge {
  font-size: 10px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--gold);
  border: 1px solid var(--hairline);
  padding: 6px 12px; border-radius: var(--radius);
}

.ghost-btn {
  background: none; border: 1px solid var(--hairline-2);
  color: var(--stone); font-family: inherit;
  font-size: 10px; letter-spacing: .14em; text-transform: uppercase;
  padding: 8px 14px; border-radius: var(--radius); cursor: pointer;
  transition: color .18s, border-color .18s;
}
.ghost-btn:hover { color: var(--gold); border-color: var(--hairline); }

.layout { display: flex; }
.map-pane { position: relative; flex: 1; min-width: 0; background: var(--ink); }
#map { position: absolute; inset: 0; }

.map-controls {
  position: absolute; top: 18px; left: 18px; z-index: 10;
  display: flex; flex-direction: column; gap: 10px;
}

.control-group {
  background: var(--panel-fill);
  backdrop-filter: blur(14px);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 10px 12px;
}
.control-label {
  display: block; font-size: 9px; text-transform: uppercase;
  letter-spacing: .2em; color: var(--stone-dim); margin-bottom: 8px;
}

.segmented { display: flex; gap: 2px; }
.segmented button {
  background: none; border: 1px solid transparent;
  color: var(--stone); font-family: inherit; font-size: 11.5px;
  letter-spacing: .06em;
  padding: 6px 11px; border-radius: 2px; cursor: pointer;
  transition: color .16s, background .16s, border-color .16s;
}
.segmented button:hover { color: var(--ivory); }
.segmented button.active {
  color: var(--gold-bright);
  border-color: var(--hairline);
  background: rgba(200,169,81,.12);
}

.legend {
  position: absolute; bottom: 40px; left: 18px; z-index: 10;
  background: var(--panel-fill);
  backdrop-filter: blur(14px);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 11px 13px;
}
.legend-title {
  font-size: 9px; text-transform: uppercase; letter-spacing: .2em;
  color: var(--stone-dim); margin-bottom: 9px;
}
.legend-scale { display: flex; width: 232px; }
.legend-swatch { height: 7px; flex: 1; }
.legend-swatch:first-child { border-radius: 2px 0 0 2px; }
.legend-swatch:last-child  { border-radius: 0 2px 2px 0; }
.legend-ticks { position: relative; height: 14px; margin-top: 6px; width: 232px; }
.legend-tick {
  position: absolute; transform: translateX(-50%);
  font-size: 9px; font-family: var(--mono); color: var(--stone-dim);
  white-space: nowrap;
}
.legend-nodata {
  display: flex; align-items: center; gap: 7px;
  margin-top: 9px; padding-top: 8px;
  border-top: 1px solid var(--hairline-2);
  font-size: 9.5px; color: var(--stone-dim);
  text-transform: uppercase; letter-spacing: .12em;
}
.legend-nodata i {
  width: 11px; height: 7px; background: var(--nodata);
  border: 1px solid rgba(244,239,230,.14); display: inline-block;
}

.attribution {
  position: absolute; bottom: 10px; right: 14px; z-index: 10;
  font-size: 9.5px; color: var(--stone-dim);
  letter-spacing: .1em; text-transform: uppercase;
  text-align: right; pointer-events: none;
}
.attribution strong { color: var(--stone); font-weight: 400; }

.panel {
  width: 412px; flex-shrink: 0;
  border-left: 1px solid var(--hairline);
  overflow-y: auto; position: relative;
}

.panel-empty { padding: 52px 30px; text-align: center; }
.empty-rule {
  width: 46px; height: 1px; margin: 0 auto 22px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}
.panel-empty h2 {
  font-family: var(--serif); font-size: 21px; font-weight: 400;
  letter-spacing: .06em; margin: 0 0 12px;
}
.panel-empty p { font-size: 13px; color: var(--stone); line-height: 1.75; margin: 0; }
.panel-empty p strong { color: var(--gold); font-weight: 400; }

.stat-grid {
  margin: 34px 0 0; padding: 22px 0 0;
  border-top: 1px solid var(--hairline-2);
  display: grid; grid-template-columns: 1fr 1fr; gap: 22px 18px; text-align: left;
}
.stat-grid div { margin: 0; }
.stat-grid dt {
  font-size: 9px; text-transform: uppercase; letter-spacing: .18em;
  color: var(--stone-dim); margin-bottom: 6px;
}
.stat-grid dd {
  margin: 0; font-family: var(--serif); font-size: 22px; color: var(--gold-bright);
  letter-spacing: .02em;
}
.stat-grid dd small {
  font-size: 10.5px; color: var(--stone-dim); font-family: var(--sans);
  letter-spacing: .04em;
}
.stat-grid dd small.sub { display: block; margin-top: 3px; color: var(--stone); }
.stat-grid .span2 { grid-column: 1 / -1; }

.control-group.disabled { opacity: .38; pointer-events: none; }

.panel-body { padding: 26px 30px 52px; }

.close-btn {
  position: absolute; top: 16px; right: 18px;
  background: none; border: none; color: var(--stone-dim);
  font-size: 22px; line-height: 1; cursor: pointer; padding: 4px 8px;
}
.close-btn:hover { color: var(--gold); }

.panel-head { margin-bottom: 24px; padding-right: 32px; }
.eyebrow {
  font-size: 9px; text-transform: uppercase; letter-spacing: .24em;
  color: var(--gold); margin: 0 0 8px;
}
.panel-head h2 {
  font-family: var(--serif); font-size: 27px; font-weight: 400;
  margin: 0; letter-spacing: .015em; line-height: 1.2;
}
.area-parent {
  font-size: 11px; color: var(--stone-dim); margin: 7px 0 0;
  text-transform: uppercase; letter-spacing: .14em;
}
.place-note {
  font-size: 12.5px; color: var(--stone); margin: 10px 0 0; line-height: 1.45;
  padding: 7px 10px; border-left: 2px solid var(--gold); background: rgba(200,169,81,.07);
  border-radius: 0 var(--radius) var(--radius) 0;
}
.place-note[hidden] { display: none; }

.headline {
  border-top: 1px solid var(--hairline);
  border-bottom: 1px solid var(--hairline);
  padding: 20px 0; margin-bottom: 26px;
}
.headline-value { display: flex; align-items: baseline; gap: 3px; font-family: var(--serif); }
.headline-value .euro { font-size: 20px; color: var(--gold-deep); }
.headline-value #headline-num {
  font-size: 44px; color: var(--gold-bright); letter-spacing: .01em; line-height: 1;
}
.headline-value .unit {
  font-size: 13px; color: var(--stone-dim); margin-left: 5px;
  font-family: var(--sans); letter-spacing: .06em;
}
.headline-meta { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }

.chip {
  font-size: 9.5px; padding: 5px 10px; border-radius: 2px;
  border: 1px solid var(--hairline-2); color: var(--stone);
  text-transform: uppercase; letter-spacing: .14em;
}
.chip.confidence[data-level="alta"]  { color: var(--ok);   border-color: rgba(126,168,122,.4); }
.chip.confidence[data-level="media"] { color: var(--gold); border-color: var(--hairline); }
.chip.confidence[data-level="baixa"],
.chip.confidence[data-level="muito baixa"] { color: var(--bad); border-color: rgba(181,101,79,.42); }

.fallback-note {
  font-size: 11.5px; color: var(--stone); line-height: 1.65;
  margin: 14px 0 0; padding-left: 12px;
  border-left: 2px solid var(--gold-deep);
}

.block { margin-bottom: 30px; }
.block h3 {
  font-size: 9px; text-transform: uppercase; letter-spacing: .22em;
  color: var(--stone-dim); margin: 0 0 14px; font-weight: 400;
  display: flex; align-items: center; gap: 10px;
}
.block h3::after {
  content: ""; flex: 1; height: 1px; background: var(--hairline-2);
}
.block h3 .muted { color: var(--stone-dim); letter-spacing: .1em; }

.typology-list { list-style: none; margin: 0; padding: 0; }

.typology-list {
  display: grid;
  grid-template-columns: max-content minmax(40px, 1fr) max-content;
  column-gap: 12px;
  align-items: center;
}
.typology-list li { display: contents; }
.t-label {
  font-size: 11px; color: var(--stone);
  text-transform: uppercase; letter-spacing: .1em;
  white-space: nowrap; padding: 7px 0;
}
.t-bar { height: 2px; background: var(--line-soft); overflow: hidden; }
.t-bar span {
  display: block; height: 100%;
  background: linear-gradient(90deg, var(--gold-deep), var(--gold-bright));
}
.t-value {
  font-family: var(--mono); font-size: 12px; text-align: right;
  white-space: nowrap; color: var(--ivory); padding: 7px 0;
}
.t-value.absent {
  color: var(--stone-dim); font-size: 9.5px;
  text-transform: uppercase; letter-spacing: .1em; font-family: var(--sans);
}

.chart-wrap { border: 1px solid var(--hairline-2); padding: 14px; }
#chart { width: 100%; height: 118px; display: block; overflow: visible; }
.trend-summary { font-size: 11.5px; color: var(--stone); margin: 11px 0 0; letter-spacing: .04em; }
.trend-summary strong { font-family: var(--mono); font-size: 12.5px; }
.trend-up   { color: var(--gold-bright); }
.trend-down { color: var(--bad); }

.estimator .field { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.estimator .field span {
  font-size: 9px; color: var(--stone-dim);
  text-transform: uppercase; letter-spacing: .18em;
}
.estimator input {
  flex: 1; height: 38px; padding: 0 13px;
  background: var(--field-fill); border: 1px solid var(--hairline-2);
  border-radius: var(--radius); color: var(--ivory);
  font-family: var(--mono); font-size: 14px;
}
.estimator input:focus {
  outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-glow);
}

.estimate-out {
  display: flex; align-items: baseline; justify-content: space-between;
  border-top: 1px solid var(--hairline);
  border-bottom: 1px solid var(--hairline);
  padding: 16px 0;
}
.estimate-label {
  font-size: 9px; color: var(--stone-dim);
  text-transform: uppercase; letter-spacing: .18em;
}
#estimate { font-family: var(--serif); font-size: 27px; color: var(--gold-bright); }

.disclaimer { font-size: 10.5px; color: var(--stone-dim); line-height: 1.7; margin: 14px 0 0; }

.report-btn {
  display: block; margin-top: 30px; padding: 15px 18px;
  border: 1px solid var(--gold-deep);
  background: linear-gradient(180deg, rgba(200,169,81,.15), rgba(200,169,81,.05));
  color: var(--gold-bright); text-decoration: none; text-align: center;
  font-size: 11.5px; letter-spacing: .16em; text-transform: uppercase;
  transition: background .18s, border-color .18s;
}
.report-btn:hover { background: rgba(200,169,81,.24); border-color: var(--gold); }
.report-btn span {
  display: block; margin-top: 6px;
  font-size: 9px; letter-spacing: .12em; color: var(--stone-dim);
}

.modal {
  position: fixed; inset: 0; z-index: 100;
  background: var(--scrim);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; padding: 28px;
}
.modal-card {
  position: relative; max-width: 580px; max-height: 84vh; overflow-y: auto;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 38px 42px; box-shadow: var(--shadow);
}
.modal-card h2 {
  font-family: var(--serif); font-weight: 400; font-size: 24px;
  letter-spacing: .06em; margin: 0 0 6px;
}
.modal-rule {
  width: 44px; height: 1px; margin-bottom: 22px;
  background: linear-gradient(90deg, var(--gold), transparent);
}
.modal-card h3 {
  margin: 26px 0 9px; font-size: 9px; color: var(--gold);
  text-transform: uppercase; letter-spacing: .2em; font-weight: 400;
}
.modal-card p, .modal-card li {
  font-size: 13px; line-height: 1.8; color: var(--stone);
}
.modal-card p { margin: 0 0 12px; }
.modal-card ul { margin: 0; padding-left: 18px; }
.modal-card strong { color: var(--ivory); font-weight: 400; }
.modal-card em { color: var(--gold); font-style: normal; }
.build-stamp {
  margin-top: 24px !important; padding-top: 16px;
  border-top: 1px solid var(--hairline-2);
  font-size: 10.5px !important; color: var(--stone-dim) !important;
  letter-spacing: .04em;
}

.maplibregl-popup-content {
  background: var(--marble-2); color: var(--ivory);
  border: 1px solid var(--hairline); border-radius: var(--radius);
  padding: 9px 13px; font-family: var(--sans); font-size: 12px;
  box-shadow: var(--shadow);
}
.maplibregl-popup-tip { display: none; }
.pop-name { letter-spacing: .04em; }
.pop-val  { font-family: var(--mono); color: var(--gold-bright); margin-top: 3px; }
.pop-none {
  color: var(--stone-dim); font-size: 9.5px; margin-top: 3px;
  text-transform: uppercase; letter-spacing: .12em;
}

.maplibregl-ctrl-group {
  background: var(--panel-fill) !important;
  border: 1px solid var(--hairline) !important;
  border-radius: var(--radius) !important;
}
.maplibregl-ctrl-group button + button { border-top: 1px solid var(--hairline-2) !important; }
.maplibregl-ctrl-group button span { filter: invert(88%) sepia(18%) saturate(420%) hue-rotate(2deg); }

.loading {
  position: absolute; inset: 0; z-index: 20;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 16px; background: var(--ink);
  transition: opacity .5s; pointer-events: none;
}
.loading[hidden] { display: none !important; }
.loading-mark {
  font-family: var(--serif); font-size: 27px; letter-spacing: .3em;
  color: var(--gold); text-transform: uppercase; padding-left: .3em;
}
.loading-bar { width: 148px; height: 1px; background: rgba(244,239,230,.1); overflow: hidden; }
.loading-bar i {
  display: block; height: 100%; width: 34%;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  animation: sweep 1.15s ease-in-out infinite;
}
@keyframes sweep { 0% { transform: translateX(-120%);} 100% { transform: translateX(420%);} }

@media (max-width: 940px) {
  .layout { flex-direction: column; }
  .map-pane { height: 54vh; flex: none; }

  .map-controls {
    flex-direction: row; flex-wrap: nowrap; gap: 6px;
    top: 10px; left: 10px; right: 10px;
    overflow-x: auto; overflow-y: hidden;
    padding-bottom: 4px;
    scrollbar-width: none;
  }
  .map-controls::-webkit-scrollbar { display: none; }
  .control-group { padding: 5px 7px; flex: 0 0 auto; }
  .control-label { display: none; }
  .segmented button { padding: 6px 9px; font-size: 11px; }
  .panel { width: 100%; border-left: none; border-top: 1px solid var(--hairline); }
  .brand-sub { display: none; }
  .topbar { gap: 14px; padding: 0 14px; height: 58px; }
}
@media (max-width: 580px) {
  .topbar {
    height: auto; flex-wrap: wrap; padding: 10px 12px 12px; gap: 10px;
  }
  .brand { order: 1; }
  .topbar-meta { order: 2; margin-left: auto; }
  .search-wrap { order: 3; flex: 0 0 100%; max-width: none; }

  .brand-mark { font-size: 20px; }
  .topbar-meta .ghost-btn { padding: 7px 10px; }
  .badge { padding: 5px 9px; }

  .legend { display: none; }
  .panel-body { padding: 22px 20px 42px; }
  .headline-value #headline-num { font-size: 36px; }

  .segmented button { padding: 11px 13px; font-size: 12px; }
  .results li { padding: 12px 11px; }
  .report-btn { padding: 17px 18px; }
}

.headline-pair { display: flex; gap: 26px; flex-wrap: wrap; }
.headline-pair > div { display: flex; flex-direction: column; }
.hp-label {
  font-size: 9px; text-transform: uppercase; letter-spacing: .18em;
  color: var(--stone-dim); margin-bottom: 5px;
}
.hp-value { font-family: var(--serif); font-size: 30px; color: var(--gold-bright); line-height: 1; }
.hp-unit { font-size: 10px; color: var(--stone-dim); letter-spacing: .06em; margin-top: 4px; }

.ghost-btn.accent {
  color: var(--gold-bright); border-color: var(--gold-deep);
  background: rgba(200,169,81,.12); text-decoration: none;
}
.ghost-btn.accent:hover { background: rgba(200,169,81,.22); border-color: var(--gold); }
a.brand-mark { text-decoration: none; }

.modal-lede { font-size: 13px; color: var(--stone); line-height: 1.6; margin-bottom: 20px; }

.chip-ok   { color: var(--ok);   border-color: rgba(126,168,122,.4); }
.chip-warn { color: var(--warn); border-color: var(--hairline); }
.chip-dim  { color: var(--stone-dim); }

.basis-note {
  margin: 8px 0 0; font-size: 9.5px; line-height: 1.4;
  letter-spacing: .06em; text-transform: uppercase; color: var(--stone-dim);
}
.basis-note[data-basis="appraisal"]   { color: var(--warn); }
.basis-note[data-basis="transaction"] { color: var(--ok); }

#country button { min-width: 74px; }

.pop-cta {
  font-size: 11px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--gold-bright); margin-top: 3px;
}
.pop-soon {
  font-size: 10px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--stone); margin-top: 3px;
}
.pop-note {
  font-size: 10px; color: var(--stone-dim); margin-top: 4px;
  max-width: 220px; line-height: 1.4; white-space: normal;
}

.report-btn.is-disabled {
  opacity: .5; cursor: not-allowed; pointer-events: none;
  border-color: var(--hairline-2);
}

:root[data-theme="light"] {
  --ink:        #f7f4ee;
  --marble:     #ffffff;
  --marble-2:   #f2eee5;
  --marble-3:   #e8e2d5;
  --inset:      #efeadf;

  --gold:       #7d611f;
  --gold-bright:#5f4715;
  --gold-deep:  #8f7433;
  --gold-glow:  rgba(138,107,35,.14);

  --ivory:      #1a1815;
  --stone:      #5c574c;
  --stone-dim:  #6f6a5f;
  --hairline:   rgba(138,107,35,.30);
  --hairline-2: rgba(26,24,21,.12);

  --ok:   #416d3c;
  --warn: #8a6b23;
  --bad:  #a04a30;

  --c1: #f6f0de;
  --c2: #ebdfba;
  --c3: #ddc994;
  --c4: #ccb06f;
  --c5: #b8954f;
  --c6: #9d7a37;
  --c7: #7d5f26;
  --c8: #5a4319;

  --nodata: #e2ddd2;

  --shadow: 0 12px 32px rgba(26,24,21,.14);

  --field-fill: rgba(255,255,255,.92);
  --panel-fill: rgba(255,255,255,.96);
  --scrim:      rgba(32,28,22,.55);
  --line-soft:  rgba(26,24,21,.10);
  --line-faint: rgba(26,24,21,.07);
  --wash:       rgba(26,24,21,.03);
}

:root[data-theme="light"] .maplibregl-canvas-container,
:root[data-theme="light"] #map { background: var(--ink); }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.prefs { display: inline-flex; align-items: center; gap: 4px; }
.prefs-field { display: inline-flex; }
.prefs select {
  appearance: none; -webkit-appearance: none;
  background-color: transparent; border: 1px solid transparent; cursor: pointer;
  color: var(--stone-dim); font-family: var(--mono); font-size: 10.5px;
  letter-spacing: .08em; padding: 5px 16px 5px 7px; border-radius: 3px;
  flex: 0 0 auto; width: auto; min-width: 48px; line-height: 1.5;
  background-image:
    linear-gradient(45deg, transparent 50%, currentColor 50%),
    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: right 7px top 50%, right 4px top 50%;
  background-size: 3px 3px, 3px 3px;
  background-repeat: no-repeat;
}
.prefs select:hover { color: var(--ivory); background-color: var(--marble-2); }
.prefs select option { background: var(--marble-2); color: var(--ivory); }
.prefs-theme {
  background: none; border: 1px solid transparent; cursor: pointer;
  color: var(--stone-dim); line-height: 0; padding: 5px 7px; border-radius: 3px;
  display: inline-flex; align-items: center;
}
.prefs-theme:hover { color: var(--gold-bright); background: var(--marble-2); }
@media (max-width: 1100px) { .prefs #pref-cur { display: none; } }

@media (max-width: 1200px) {
  .brand-sub { display: none; }
}

@media (max-width: 580px) {
  .topbar-meta { display: contents; }
  .topbar #lang-switch { order: 2; margin-left: auto; }
  .topbar .ghost-btn.accent { order: 4; }
  .topbar #about-btn { order: 5; }
  .topbar #period-badge { order: 6; margin-left: auto; }
  .topbar .ghost-btn { padding: 10px; letter-spacing: .1em; }
  .topbar .badge { padding: 6px 8px; letter-spacing: .1em; }
  #search { font-size: 16px; height: 42px; }
  .prefs select { font-size: 15px; }
}

.filters-btn, .mc-head { display: none; }

@media (max-width: 940px) {
  .filters-btn {
    display: inline-flex; align-items: center; gap: 10px;
    position: absolute; top: 10px; left: 10px; z-index: 11;
    max-width: calc(100% - 74px); min-height: 44px; padding: 0 16px;
    background: var(--panel-fill); backdrop-filter: blur(14px);
    border: 1px solid var(--hairline); border-radius: var(--radius);
    color: var(--ivory); font-family: inherit; font-size: 13px; letter-spacing: .04em; cursor: pointer;
  }
  .filters-btn .burger, .filters-btn .burger::before, .filters-btn .burger::after {
    display: block; width: 16px; height: 2px; border-radius: 1px; background: currentColor;
  }
  .filters-btn .burger { position: relative; flex-shrink: 0; }
  .filters-btn .burger::before, .filters-btn .burger::after { content: ''; position: absolute; left: 0; }
  .filters-btn .burger::before { top: -5px; }
  .filters-btn .burger::after { top: 5px; }
  .filters-label { flex-shrink: 0; }
  .filters-sum {
    min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    color: var(--gold-bright); font-size: 12px;
  }
  .filters-sum:empty { display: none; }

  .map-controls {
    display: none; flex-direction: column; flex-wrap: nowrap; gap: 18px;
    top: 10px; left: 10px; right: 10px; bottom: 10px; z-index: 12;
    padding: 14px 16px 18px; overflow-x: hidden; overflow-y: auto;
    background: var(--marble-2); border: 1px solid var(--hairline); border-radius: var(--radius);
    box-shadow: var(--shadow); overscroll-behavior: contain;
  }
  .map-controls.open { display: flex; }
  .mc-head { display: flex; align-items: center; justify-content: space-between; }
  .mc-title { font-family: var(--serif); font-size: 20px; color: var(--ivory); }
  .mc-close {
    width: 40px; height: 40px; padding: 0; cursor: pointer;
    background: none; border: 1px solid var(--hairline-2); border-radius: var(--radius);
    color: var(--ivory); font-size: 20px; line-height: 1;
  }
  .control-group { padding: 0; background: none; border: 0; backdrop-filter: none; flex: 0 0 auto; }
  .control-label { display: block; margin-bottom: 9px; }
  .segmented { flex-wrap: wrap; gap: 6px; }
  .segmented button {
    padding: 10px 14px; font-size: 13px;
    border-color: var(--hairline-2);
  }
  .basis-note { margin-top: 8px; }
}
