/* A quiet property-search interface: neutral surfaces, blue actions, clear numbers. */
:root {
  --ink: #20272c;
  --ink-2: #4c565f;
  --muted: #626b73;
  --sea: #315d80;
  --sea-deep: #244462;
  --sea-wash: #edf3f7;
  --sand: #f7f8f9;
  --paper: #ffffff;
  --line: #dde1e5;
  --control: #87929c;
  --gold: #315d80;
  --gold-ink: #ffffff;
  --cut: #a43c38;
  --rise: #347149;
  --radius: 6px;
  --shadow: 0 2px 8px rgba(25, 35, 45, .06);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--sand);
  line-height: 1.5;
}
h1, h2, h3 { font-family: inherit; font-weight: 650; letter-spacing: -.025em; line-height: 1.2; }
a { color: var(--sea-deep); }
img { max-width: 100%; }
.wrap { max-width: 1040px; margin: 0 auto; padding: 20px 16px 64px; }
.muted { color: var(--muted); font-size: .9rem; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- site header ---------- */
header.site {
  background: var(--paper); border-bottom: 1px solid var(--line);
  padding: 16px 24px; display: flex; align-items: center; gap: 32px; flex-wrap: wrap;
}
header.site .brand {
  display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none;
  font-size: 1.25rem; font-weight: 750; letter-spacing: -.035em; line-height: 1.1; white-space: nowrap;
}
.brand-mark { width: 32px; height: 36px; fill: none; stroke: var(--sea-deep); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
header.site .brand small { display: block; margin-top: 4px; font-size: .75rem; font-weight: 500; letter-spacing: .015em; color: var(--muted); }
header.site form.addr { flex: 1 1 240px; display: flex; max-width: 380px; }
header.site form.addr input {
  flex: 1; min-width: 0; padding: 10px 12px; font: inherit; font-size: .875rem;
  background: var(--sand); border: 1px solid var(--control); border-right: 0; border-radius: 5px 0 0 5px;
}
header.site form.addr button {
  padding: 10px 14px; font: inherit; font-size: .875rem; font-weight: 600;
  border: 1px solid var(--sea-deep); cursor: pointer;
  background: var(--sea-deep); color: #fff; border-radius: 0 5px 5px 0;
}
header.site nav { display: flex; gap: 24px; margin-left: auto; }
header.site nav a { color: var(--ink-2); text-decoration: none; font-weight: 500; font-size: .875rem; padding: 8px 0; }
header.site nav a:hover { color: var(--sea-deep); }
header.site nav a[aria-current="page"] { color: var(--sea-deep); text-decoration: underline; text-underline-offset: 10px; text-decoration-thickness: 2px; }
:where(a, button, input, select, summary):focus-visible { outline: 3px solid var(--sea); outline-offset: 3px; }
button:hover { filter: brightness(.97); }
footer.site { text-align: center; font-size: .8rem; color: var(--muted); padding: 24px 16px; }

/* ---------- shared bits ---------- */
.searchbar { display: flex; gap: 8px; margin: 20px 0; }
.searchbar input[type="text"] {
  flex: 1; min-width: 0; padding: 14px 16px; font-size: 1rem;
  border: 1px solid var(--control); border-radius: 10px; font-family: inherit;
}
.searchbar button {
  padding: 14px 20px; font-size: 1rem; font-weight: 700; font-family: inherit;
  background: var(--gold); color: var(--gold-ink); border: none; border-radius: 10px; cursor: pointer;
}
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin: 16px 0; }
.card h2, .card h3, .h3 { margin: 0 0 10px; font-size: 1.3rem; }
.pill { display: inline-block; background: var(--sea); color: #fff; border-radius: 999px; padding: 3px 12px; font-size: .8rem; font-weight: 500; }
.pill.delisted { background: #5f5f55; }
.pill.neutral { background: #eef0f2; color: var(--ink); }
.pill.warn { background: var(--gold); color: var(--gold-ink); }
.pill.intl { background: var(--sea-wash); color: var(--sea-deep); }
.badges { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 2px; }
.chip { display: inline-block; border-radius: 6px; padding: 2px 8px; font-size: .8rem; font-weight: 500; background: #eef0f2; }
.chip.listed { background: var(--sea); color: #fff; }
.chip.price_cut { background: var(--cut); color: #fff; }
.chip.price_increase { background: var(--rise); color: #fff; }
.chip.delisted { background: #5f5f55; color: #fff; }
.chip.relisted { background: var(--gold); color: var(--gold-ink); }
.down { color: var(--cut); font-weight: 700; }
.up { color: var(--rise); font-weight: 700; }
.price-big { font-family: inherit; font-weight: 650; letter-spacing: -.03em; font-variant-numeric: tabular-nums; font-size: 2.2rem; line-height: 1.1; color: var(--ink); }
.sale-row { display: flex; justify-content: space-between; border-top: 1px dashed var(--line); padding: 8px 0; }
.sale-row:first-child { border-top: none; }
table.history { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.history th, table.history td { text-align: left; padding: 7px 4px; border-bottom: 1px solid var(--line); }
table.history tr.total td { font-weight: 700; border-top: 2px solid var(--line); }
table.timeline td:first-child { white-space: nowrap; }
.table-scroll { overflow-x: auto; }
.chart-wrap { position: relative; padding-left: 56px; }
svg.chart { width: 100%; height: 200px; display: block; overflow: visible; }
.chart-y { position: absolute; left: 0; top: 0; bottom: 0; width: 50px; }
.chart-y span { position: absolute; right: 0; transform: translateY(-50%); font-size: .78rem; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.chart-x { display: flex; justify-content: space-between; padding: 4px 8px 6px 56px; font-size: .82rem; }
.card.estimate { border-left: 5px solid var(--sea); }
.range-bar { display: flex; align-items: center; gap: 10px; margin: 8px 0 4px; font-size: .85rem; color: var(--muted); }
.range-track { flex: 1; height: 6px; border-radius: 3px; background: linear-gradient(90deg, #dcd6c8, var(--sea), #dcd6c8); position: relative; }
.range-dot { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 14px; height: 14px; border-radius: 50%; background: var(--sea-deep); border: 2px solid #fff; }
.desc-text { white-space: pre-line; font-size: .95rem; }
.desc-text.clamped { max-height: 11.5em; overflow: hidden; -webkit-mask-image: linear-gradient(#000 70%, transparent); mask-image: linear-gradient(#000 70%, transparent); }
button.linkish { background: none; border: none; padding: 0; color: var(--sea-deep); font: inherit; font-weight: 700; cursor: pointer; text-decoration: underline; }

/* ---------- home cards (map list + similar homes) ---------- */
.hcard {
  display: flex; flex-direction: column; background: var(--paper); border-radius: 6px;
  overflow: hidden; text-decoration: none; color: inherit; box-shadow: none;
  border: 1px solid var(--line); transition: border-color .12s;
}
.hcard:hover, .hcard.hot { border-color: var(--sea); }
.hcard:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
/* The image is absolutely placed so a tall photo can't stretch the 3:2 box
   (aspect-ratio yields to content height): every card's photo is the same height. */
.hcard-photo { position: relative; aspect-ratio: 8 / 5; background: #dfe7e6; overflow: hidden; }
.hcard-photo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.hcard-photo .nophoto { position: absolute; inset: 0; display: grid; place-items: center; color: var(--ink-2); font-size: .85rem; }
.hcard-photo .flag {
  position: absolute; top: 12px; left: 12px; border-radius: 3px; padding: 4px 8px;
  font-size: .75rem; font-weight: 700; background: #fff; color: var(--ink);
}
.flag.new { background: #fff; color: var(--ink); }
.flag.price_cut { background: var(--cut); color: #fff; }
.flag.relisted { background: var(--gold); color: var(--gold-ink); }
.flag.contract { background: var(--ink); color: #fff; }
.pill.contract { background: var(--ink); }
.hcard-body { padding: 14px 14px 16px; display: grid; gap: 5px; }
.hcard-price { font-size: 1.4rem; font-weight: 700; letter-spacing: -.035em; font-variant-numeric: tabular-nums; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.hcard-price .delta { font-size: .75rem; font-weight: 600; letter-spacing: 0; }
.hcard-facts { font-size: .9rem; }
.hcard-facts b { font-weight: 700; }
.hcard-loc { font-size: .88rem; color: var(--ink-2); }
.hcard-trail { font-size: .78rem; color: var(--muted); }
.hcard-trail .cut { color: var(--cut); }
.hcard-trail .up { color: var(--rise); }
.hcard-meta { margin-top: 5px; padding-top: 8px; border-top: 1px solid var(--line); font-size: .76rem; color: var(--muted); display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.elig { display: inline-block; border-radius: 4px; padding: 0 6px; font-size: .72rem; font-weight: 700; }
.elig.intl { background: var(--sea-wash); color: var(--sea-deep); }
.elig.bda { background: #f0f2f4; color: var(--ink-2); }

/* ---------- property detail ---------- */
.gallery { display: grid; gap: 6px; grid-template-columns: 2fr 1fr 1fr; grid-template-rows: 180px 180px; border-radius: var(--radius); overflow: hidden; margin: 16px 0; position: relative; }
.gallery button { padding: 0; border: none; background: #dfe7e6; cursor: zoom-in; overflow: hidden; }
.gallery img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gallery button:first-child { grid-row: span 2; }
.gallery .more { position: absolute; right: 12px; bottom: 12px; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px; font: inherit; font-weight: 700; cursor: pointer; }
.gallery.n1 { grid-template-columns: 1fr; grid-template-rows: 360px; }
.gallery.n1 button:first-child { grid-row: auto; }
.gallery.n2 { grid-template-columns: 2fr 1fr; grid-template-rows: 360px; }
.gallery.n2 button:first-child { grid-row: auto; }
.gallery.n3 { grid-template-columns: 2fr 1fr; }
.lightbox { position: fixed; inset: 0; background: rgba(10, 20, 24, .94); display: none; z-index: 2000; align-items: center; justify-content: center; }
.lightbox.open { display: flex; }
.lightbox img { max-width: 92vw; max-height: 84vh; border-radius: 8px; }
.lightbox button { position: absolute; background: rgba(255,255,255,.12); color: #fff; border: none; font-size: 1.6rem; width: 48px; height: 48px; border-radius: 50%; cursor: pointer; }
.lightbox .lb-close { top: 16px; right: 16px; }
.lightbox .lb-prev { left: 16px; top: 50%; }
.lightbox .lb-next { right: 16px; top: 50%; }
.lightbox .lb-count { position: absolute; bottom: 18px; color: #d9e6e5; font-size: .9rem; }

.detail { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 24px; align-items: start; }
.detail aside { position: sticky; top: 16px; }
.headline h1 { font-size: 1.7rem; margin: 6px 0 2px; }
.facts { display: flex; flex-wrap: wrap; gap: 6px 22px; margin: 12px 0 4px; }
.facts div { font-size: .9rem; color: var(--ink-2); }
.facts strong { display: block; font-size: 1.25rem; color: var(--ink); }
.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px 18px; margin: 0; }
.kv div { border-bottom: 1px solid var(--line); padding-bottom: 6px; }
.kv dt { font-size: .8rem; color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; }
.approx-note { font-size: .82rem; color: var(--muted); margin-top: 6px; }
#minimap { height: 220px; border-radius: 10px; border: 1px solid var(--line); }
.src-links a { display: block; margin: 6px 0; font-weight: 700; }
.calc label { display: grid; grid-template-columns: 1fr 120px; align-items: center; gap: 8px; margin: 8px 0; font-size: .9rem; }
.calc input { width: 100%; padding: 7px 9px; border: 1px solid var(--control); border-radius: 8px; font: inherit; text-align: right; }
.calc .result { font-family: inherit; font-weight: 650; letter-spacing: -.03em; font-variant-numeric: tabular-nums; font-size: 1.9rem; margin: 6px 0 0; }
.similar-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }

@media (max-width: 860px) {
  .detail { grid-template-columns: minmax(0, 1fr); }
  .detail aside { position: static; }
  .gallery { grid-template-columns: 1fr 1fr; grid-template-rows: 220px 110px; }
  .gallery button:first-child { grid-column: span 2; grid-row: auto; }
  .gallery button:nth-child(n+4):not(.more) { display: none; }
  .gallery.n1, .gallery.n2 { grid-template-columns: 1fr; grid-template-rows: 240px; }
  .gallery.n2 button:nth-child(2):not(.more) { display: none; }
}
@media (max-width: 600px) {
  header.site { gap: 14px 16px; padding: 14px 16px; }
  header.site .brand { font-size: 1.15rem; }
  header.site nav { display: flex; gap: 16px; width: 100%; order: 4; justify-content: space-between; }
  header.site nav a { font-size: .8rem; min-height: 36px; }
  header.site form.addr { flex-basis: 100%; max-width: none; }
  header.site form.addr input, header.site form.addr button { padding-top: 7px; padding-bottom: 7px; }
  .price-big { font-size: 1.9rem; }
  /* Timeline rows stack on phones: date + event, then price, change and source. */
  table.timeline thead { display: none; }
  table.timeline tr { display: grid; grid-template-columns: auto 1fr auto; gap: 2px 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
  table.timeline td { border: none; padding: 0; }
  table.timeline .t-date { grid-column: 1; }
  table.timeline .t-event { grid-column: 2; }
  table.timeline .t-price { grid-column: 3; text-align: right; font-weight: 700; }
  table.timeline .t-source { grid-column: 1 / 3; font-size: .8rem; color: var(--muted); }
  table.timeline .t-change { grid-column: 3; text-align: right; font-size: .85rem; }
  table.timeline .t-change:empty { display: none; }
}
.units { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.units a { font-weight: 600; }
.est-gap { margin: 6px 0 4px; }
.elig-note { display: block; font-size: .8rem; margin-top: 2px; }
.skip { position: absolute; left: 8px; top: -60px; z-index: 3000; background: var(--ink); color: #fff; padding: 10px 14px; border-radius: 8px; font-weight: 700; }
.skip:focus { top: 8px; }
.trust { margin: 0; padding: 8px 24px; font-size: .75rem; color: var(--muted); background: var(--paper); border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 16px; }
@media (max-width: 860px) { .trust { padding: 8px 16px; font-size: .7rem; display: block; } .trust a { display: none; } }
.trust a { color: var(--sea-deep); font-weight: 700; }
.prose { max-width: 68ch; }
.prose h1 { margin-top: 8px; }
.prose li { margin-bottom: 8px; }
.calc-hint { margin: -4px 0 6px; font-size: .8rem; }
.calc-break { margin: 2px 0 8px; font-size: .88rem; color: var(--ink-2); }
/* Phones: 44px touch targets (WCAG 2.5.5) */
@media (max-width: 860px) {
  .calc input, .searchbar input[type="text"], .linkish, .gallery .more { min-height: 44px; }
}

/* ---------- saved homes: heart on every card ---------- */
.hcard-wrap { position: relative; display: flex; flex-direction: column; }
.hcard-wrap > .hcard { flex: 1; }
.save {
  position: absolute; top: 8px; right: 8px; z-index: 2; width: 44px; height: 44px; border-radius: 50%;
  border: none; background: rgba(255, 255, 255, .92); box-shadow: none;
  display: grid; place-items: center; cursor: pointer; padding: 0;
}
.save svg { width: 22px; height: 22px; fill: none; stroke: var(--ink); stroke-width: 2; }
.save[aria-pressed="true"] svg { fill: var(--cut); stroke: var(--cut); }
.save:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.price-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.save.save-big {
  position: static; width: auto; height: 44px; border-radius: 5px; padding: 0 16px 0 12px;
  display: inline-flex; gap: 6px; border: 1px solid var(--control); box-shadow: none; background: var(--paper);
  font: inherit; font-weight: 700; color: var(--ink);
}
.since { font-size: .85rem; color: var(--ink-2); margin-bottom: 6px; }
.since-new { color: var(--ink); background: var(--sea-wash); border-radius: 8px; padding: 6px 8px; }
.saved-search { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.saved-search .new-count { color: var(--cut); }
.saved-search .remove-search { margin-left: auto; }
.empty-state { color: var(--ink-2); padding: 8px 0 16px; }
.lede { font-size: 1.1rem; margin: 4px 0; }
.nav-saved-count:not(:empty) {
  display: inline-block; min-width: 1.4em; padding: 0 5px; margin-left: 2px; border-radius: 999px;
  background: var(--gold); color: var(--gold-ink); font-size: .75rem; font-weight: 700; text-align: center; line-height: 1.4;
}

/* ---------- off market (never "sold") ---------- */
.flag.off { background: #5f5f55; color: #fff; }
.hcard.off .hcard-photo img { filter: grayscale(.85); opacity: .85; }
.hcard.off .hcard-price { color: var(--ink-2); }
.last-asked { font-size: .75rem; font-weight: 500; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }

/* ---------- price position ---------- */
.card.position { border-left: 5px solid var(--gold); }
.position-lead { font-size: 1.05rem; margin: 0 0 10px; }
.position-bar { display: flex; align-items: center; gap: 10px; font-size: .85rem; color: var(--muted); margin: 6px 0 12px; }
.position-track { flex: 1; height: 6px; border-radius: 3px; background: linear-gradient(90deg, var(--rise), #dcd6c8, var(--cut)); position: relative; }
.position-dot { position: absolute; top: 50%; transform: translate(-50%, -50%); width: 16px; height: 16px; border-radius: 50%; background: var(--ink); border: 2px solid #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.position-kv { margin-top: 4px; }
.peers { margin: 4px 0 8px; font-size: .9rem; }
.peers summary { cursor: pointer; font-weight: 700; color: var(--sea-deep); min-height: 32px; }
.peers ul { margin: 6px 0 0; padding-left: 18px; display: grid; gap: 4px; }
.since .when { color: var(--muted); font-size: .8rem; }
.since .dismiss { margin-left: 4px; font-size: .8rem; }
.chip.under_contract { background: var(--ink); color: #fff; }
.chip.contract_ended { background: var(--gold); color: var(--gold-ink); }
