:root {
  color-scheme: light;
  --ink: #17241f;
  --muted: #66736d;
  --paper: #f5f1e8;
  --surface: #fffdf8;
  --line: #d9d4c8;
  --forest: #194f3d;
  --mint: #dfeee5;
  --coral: #e86d4a;
  --gold: #e7b84b;
  --blue: #397f91;
  --shadow: 0 16px 40px rgb(23 36 31 / 10%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; overflow: hidden; color: var(--ink); background: var(--paper); }
button, input, select { font: inherit; }
button, select { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible { outline: 3px solid #1673a2; outline-offset: 3px; }
.skip-link { position: fixed; z-index: 100; top: 1rem; left: 1rem; padding: .75rem 1rem; color: white; background: var(--ink); transform: translateY(-200%); }
.skip-link:focus { transform: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }

.topbar { height: 68px; display: flex; align-items: center; gap: 1rem; padding: 0 clamp(1rem, 4vw, 4.5rem); border-bottom: 1px solid var(--line); background: var(--paper); position: sticky; top: 0; z-index: 1100; }
.brand { display: flex; align-items: center; gap: .7rem; color: var(--ink); font-weight: 800; text-decoration: none; letter-spacing: -.03em; font-size: 1.15rem; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; color: white; background: var(--forest); border-radius: 50% 50% 44% 56%; font-size: .68rem; letter-spacing: .03em; }
.scope { display: flex; align-items: center; gap: .5rem; color: var(--muted); font-size: .82rem; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #36a36e; box-shadow: 0 0 0 4px rgb(54 163 110 / 14%); }
.topbar-button { border: 0; background: transparent; color: var(--ink); font-size: .82rem; }
.filters-toggle { margin-left: auto; display: inline-flex; align-items: center; gap: .4rem; min-height: 38px; padding: .35rem .8rem; border: 1px solid var(--line); border-radius: 3px; }
.filters-toggle::before { content: "⚙"; font-size: .95rem; }
.filters-toggle[aria-expanded="false"] { color: white; background: var(--forest); border-color: var(--forest); }
.about-button { padding: .3rem 0; border-bottom: 1px solid var(--ink); }

main { width: 100%; }
.eyebrow { margin: 0 0 .55rem; color: var(--coral); font-weight: 800; font-size: .68rem; text-transform: uppercase; letter-spacing: .16em; }
.sidebar-summary { margin-top: 1.25rem; padding-top: 1.1rem; border-top: 1px solid var(--line); }
.sidebar-summary .eyebrow { color: var(--muted); }
.hero-stats { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; margin: 0; }
.hero-stats div { min-width: 0; padding: .55rem .65rem; border: 1px solid var(--line); background: #faf8f2; }
.hero-stats div:last-child { grid-column: 1 / -1; }
.hero-stats dt { color: var(--muted); font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; }
.hero-stats dd { margin: .25rem 0 0; font-family: Georgia, serif; font-size: 1.05rem; }

.workspace { display: grid; grid-template-columns: 250px minmax(420px, 1fr) minmax(320px, 410px); height: calc(100dvh - 69px); min-height: 0; border-top: 1px solid var(--line); background: var(--surface); }
body.filters-collapsed .workspace { grid-template-columns: minmax(420px, 1fr) minmax(320px, 410px); }
body.filters-collapsed .filters { display: none; }
.filters, .map-panel, .results { min-width: 0; padding: 1.5rem; }
.filters { overflow-y: auto; border-right: 1px solid var(--line); }
.results { height: 100%; overflow: auto; border-left: 1px solid var(--line); }
.section-heading, .map-toolbar { display: flex; align-items: start; justify-content: space-between; gap: 1rem; }
h2 { margin: 0; font-family: Georgia, serif; font-size: 1.65rem; font-weight: 400; }
.text-button { border: 0; padding: .2rem 0; color: var(--forest); background: none; font-size: .8rem; text-decoration: underline; }
.filters-heading-actions { display: flex; align-items: center; gap: .75rem; }
.filters-close { display: none; place-items: center; width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 50%; background: transparent; font-size: 1.5rem; line-height: 1; color: var(--ink); }
form { display: grid; gap: .5rem; margin-top: 1.5rem; }
form > label, legend { margin-top: .75rem; color: var(--muted); font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
input, select { width: 100%; min-height: 42px; border: 1px solid var(--line); border-radius: 2px; padding: .65rem .7rem; color: var(--ink); background: white; }
fieldset { margin: 0; padding: 0; border: 0; }
legend { padding: 0 0 .5rem; }
.split-inputs { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.split-inputs label { color: var(--muted); font-size: .7rem; }
.split-inputs input { margin-top: .25rem; }
.score-filter { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: .5rem; }
.score-filter span { color: var(--muted); font-size: .78rem; }
.checkbox-filter { display: flex; align-items: center; gap: .55rem; margin-top: 1.1rem; font-size: .84rem; color: var(--ink); cursor: pointer; }
.checkbox-filter input { width: 1.05rem; height: 1.05rem; accent-color: var(--forest); flex: none; }
.area-field { position: relative; }
.area-field input { padding-right: 2.2rem; }
.field-clear { position: absolute; top: 0; right: 0; width: 2.2rem; height: 42px; display: grid; place-items: center; border: 0; background: transparent; color: var(--muted); font-size: 1.35rem; line-height: 1; }
.area-listbox { position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 2px); max-height: 240px; overflow-y: auto; margin: 0; padding: .25rem 0; list-style: none; border: 1px solid var(--line); border-radius: 3px; background: white; box-shadow: var(--shadow); }
.area-listbox li { padding: .55rem .7rem; font-size: .85rem; cursor: pointer; }
.area-listbox li:hover, .area-listbox li.active { background: var(--mint); }
.filter-note { display: flex; gap: .65rem; margin-top: 1.5rem; padding: .8rem; color: #36584c; background: var(--mint); font-size: .72rem; line-height: 1.45; }
.filter-note p { margin: 0; }

.map-panel { display: flex; flex-direction: column; background: #e7ece6; }
.map-modes { display: inline-flex; flex: 0 0 auto; gap: 2px; padding: 2px; border: 1px solid #aebdb7; border-radius: 3px; background: rgb(255 253 248 / 75%); }
.map-mode { min-height: 32px; border: 0; padding: .4rem .55rem; color: var(--muted); background: transparent; font-size: .68rem; }
.map-mode.active { color: white; background: var(--forest); }
.map-stage { position: relative; flex: 1; min-height: 0; margin-top: 1.25rem; overflow: hidden; border: 1px solid #b9c9cb; background: #dce9ed; }
#map { width: 100%; height: 100%; min-height: 420px; background: #dce9ed; }
.map-empty { position: absolute; inset: 45% 15% auto; padding: 1rem; text-align: center; color: var(--muted); background: rgb(255 253 248 / 90%); }
.map-legend { position: absolute; z-index: 800; right: .8rem; bottom: .8rem; display: flex; align-items: center; gap: .4rem; padding: .45rem .6rem; color: var(--ink); background: rgb(255 253 248 / 94%); box-shadow: var(--shadow); border-radius: 3px; font-size: .68rem; pointer-events: none; }
.map-legend .legend-unit { font-weight: 700; }
.map-legend .gradient { width: 78px; height: 8px; border-radius: 2px; background: linear-gradient(90deg, #82c7b0, #e7b84b, #e86d4a, #7b2542); }
.map-help { margin: 1rem 0 0; color: var(--muted); font-size: .72rem; line-height: 1.5; }

.sticky-heading { position: sticky; z-index: 2; top: -1.5rem; margin: -1.5rem -1.5rem 0; padding: 1.5rem; border-bottom: 1px solid var(--line); background: var(--surface); }
.sort-label { color: var(--muted); font-size: .68rem; }
.sort-label select { min-height: 32px; width: auto; display: block; margin-top: .25rem; padding: .3rem; font-size: .72rem; }
.listing-list { display: grid; }
.listing-card { border-bottom: 1px solid var(--line); }
.listing-open { width: 100%; border: 0; padding: 1.25rem .2rem; text-align: left; color: var(--ink); background: transparent; }
.listing-open:hover { background: #faf7ef; }
.listing-topline { display: flex; justify-content: space-between; color: var(--muted); font-size: .66rem; text-transform: uppercase; letter-spacing: .08em; }
.listing-accuracy.approximate::before { content: "◌ "; }
.listing-accuracy.precise::before { content: "● "; color: #2d8c67; }
.listing-title { margin: .55rem 0 .2rem; font-family: Georgia, serif; font-size: 1.15rem; font-weight: 400; }
.listing-price { margin: .4rem 0; font-weight: 800; font-size: 1.15rem; }
.listing-facts { display: flex; flex-wrap: wrap; gap: .65rem; margin: .8rem 0; color: var(--muted); font-size: .75rem; }
.listing-facts div { display: flex; gap: .2rem; }
.listing-facts dt { font-weight: 700; }
.listing-facts dd { margin: 0; }
.opportunity-line { display: flex; align-items: center; gap: .65rem; margin: .8rem 0; }
.score { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; color: white; background: var(--forest); font-weight: 800; }
.score.unavailable { color: var(--muted); background: #e2e2dc; }
.score-copy { font-size: .75rem; color: var(--muted); }
.listing-meta { margin: 0; color: var(--muted); font-size: .68rem; }
.load-more { width: 100%; margin: 1rem 0; border: 1px solid var(--forest); padding: .75rem; color: var(--forest); background: white; }
.skeleton { height: 160px; border-bottom: 1px solid var(--line); background: linear-gradient(90deg, transparent, #f0ece3, transparent); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

dialog { width: min(680px, calc(100% - 2rem)); max-height: calc(100% - 2rem); border: 0; padding: clamp(1.5rem, 5vw, 3rem); color: var(--ink); background: var(--surface); box-shadow: var(--shadow); }
dialog::backdrop { background: rgb(10 25 20 / 55%); backdrop-filter: blur(3px); }
.dialog-close { position: absolute; top: 1rem; right: 1rem; width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 50%; background: transparent; font-size: 1.4rem; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin: 1.5rem 0; }
.detail-grid div, .explanation { padding: 1rem; background: #f3efe6; }
.detail-grid dt { color: var(--muted); font-size: .7rem; text-transform: uppercase; }
.detail-grid dd { margin: .35rem 0 0; font-weight: 700; }
.quality-badge { display: inline-block; padding: .3rem .55rem; border: 1px solid currentColor; font-size: .7rem; }
.about-content { line-height: 1.6; }
.about-content h3 { margin: 1.5rem 0 .25rem; font-family: Georgia, serif; }

@media (max-width: 1120px) {
  body { overflow: auto; }
  .workspace { height: auto; min-height: calc(100dvh - 69px); grid-template-columns: 230px 1fr; }
  body.filters-collapsed .workspace { grid-template-columns: 1fr; }
  .results { grid-column: 1 / -1; max-height: none; border-top: 1px solid var(--line); border-left: 0; }
  .listing-list { grid-template-columns: repeat(2, 1fr); gap: 0 1.5rem; }
}

@media (max-width: 720px) {
  .topbar { padding-inline: 1rem; gap: .5rem; }
  .scope { display: none; }
  .workspace { display: flex; flex-direction: column; height: auto; }
  .map-panel { order: 1; padding-top: 1rem; }
  .results { order: 2; border-left: 0; }
  .filters { position: fixed; inset: 69px 0 0; z-index: 1050; overflow-y: auto; border: 0; box-shadow: 0 -1px 0 var(--line); background: var(--surface); }
  .filters-close { display: grid; }
  .map-toolbar { display: grid; }
  .map-stage, #map { min-height: 66vh; }
  .listing-list { display: block; }
  .detail-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; }
}
