:root {
  --ink: #121813;
  --ink-2: #1c261f;
  --panel: #18211b;
  --cream: #f4eee2;
  --cream-dim: #d8d0c0;
  --gold: #d4a24a;
  --gold-2: #f0d9a0;
  --azulejo: #2b6ea3;
  --sea: #2f8f7a;
  --coral: #c45c4a;
  --line: rgba(244, 238, 226, 0.12);
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  --sans: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  --serif: "Fraunces", "Songti SC", "STSong", serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--sans);
  color: var(--cream);
  background: var(--ink);
  overflow: hidden;
}

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
img { max-width: 100%; display: block; }

.hidden, [hidden] { display: none !important; }

/* —— boot —— */
.boot {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(43, 110, 163, 0.28), transparent 55%),
    radial-gradient(900px 500px at 110% 110%, rgba(212, 162, 74, 0.16), transparent 50%),
    var(--ink);
  transition: opacity 0.5s ease, visibility 0.5s ease;
}
.boot.is-out {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.boot-ornament {
  position: absolute;
  inset: 40px;
  border: 1px solid var(--line);
  pointer-events: none;
}
.boot-ornament::before,
.boot-ornament::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  border: 1px solid var(--gold);
}
.boot-ornament::before { top: -1px; left: -1px; border-right: 0; border-bottom: 0; }
.boot-ornament::after { bottom: -1px; right: -1px; border-left: 0; border-top: 0; }

.boot-card {
  width: min(560px, calc(100vw - 48px));
  padding: 36px 36px 28px;
  background: rgba(18, 24, 19, 0.72);
  border: 1px solid var(--line);
  backdrop-filter: blur(10px);
}
.kicker {
  margin: 0 0 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  font-size: 11px;
  color: var(--gold);
}
.boot-card h1,
.brand strong {
  font-family: var(--serif);
  font-weight: 700;
  letter-spacing: 0.04em;
}
.boot-card h1 {
  margin: 0;
  font-size: clamp(42px, 7vw, 64px);
  line-height: 1;
}
.boot-lead {
  margin: 14px 0 28px;
  color: var(--cream-dim);
  line-height: 1.7;
  font-size: 14px;
}
.boot-bar {
  height: 4px;
  background: rgba(244, 238, 226, 0.1);
  overflow: hidden;
}
.boot-bar i {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--gold), var(--gold-2), var(--sea));
  transition: width 0.18s linear;
}
.boot-meta {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 12px;
  font-size: 12px;
  color: var(--cream-dim);
}
#bootPct { color: var(--gold-2); font-variant-numeric: tabular-nums; }
.boot-drop {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  color: var(--cream-dim);
  font-size: 13px;
  line-height: 1.6;
}
.file-btn {
  display: inline-flex;
  margin-top: 12px;
  padding: 8px 14px;
  border: 1px solid var(--gold);
  color: var(--gold-2);
  cursor: pointer;
}
.file-btn input { display: none; }

/* —— chrome —— */
.topbar {
  height: 64px;
  display: grid;
  grid-template-columns: auto minmax(240px, 1fr) auto auto auto;
  gap: 12px;
  align-items: center;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  background: #101610;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  background:
    linear-gradient(135deg, var(--gold) 0 50%, transparent 50% 100%),
    linear-gradient(315deg, var(--azulejo) 0 50%, var(--sea) 50% 100%);
}
.brand strong {
  display: block;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 0.08em;
}
.brand small {
  color: var(--cream-dim);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.search-wrap input {
  width: 100%;
  height: 40px;
  padding: 0 16px;
  background: var(--ink-2);
  border: 1px solid var(--line);
  outline: none;
  border-radius: 999px;
}
.search-wrap input:focus { border-color: rgba(212, 162, 74, 0.7); }
.top-stats {
  font-size: 12px;
  color: var(--cream-dim);
  white-space: nowrap;
}

.filters-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 18px;
  background: var(--gold);
  color: var(--ink);
  border: 0;
  border-radius: 999px;
  font-weight: 600;
  white-space: nowrap;
}

/* —— filter drawer —— */
.drawer-mask {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(0, 0, 0, 0.45);
}
.filters {
  position: fixed;
  top: 64px;
  bottom: 0;
  left: 0;
  z-index: 61;
  width: min(320px, 92vw);
  overflow: auto;
  padding: 16px 16px 32px;
  background: #141c17;
  border-right: 1px solid var(--line);
  box-shadow: var(--shadow);
  transform: translateX(-104%);
  transition: transform 0.28s ease;
}
body.show-filters .filters { transform: translateX(0); }
body.show-filters .drawer-mask { display: block; }
.filter-head, .list-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.filter-head h2 { margin: 0; font-size: 15px; font-weight: 600; }
.filters h3 {
  margin: 18px 0 8px;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 600;
}
.text-btn {
  background: none;
  border: 0;
  color: var(--cream-dim);
  font-size: 12px;
}
.text-btn:hover { color: var(--gold-2); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip, .map-btn {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--cream-dim);
  padding: 5px 10px;
  font-size: 12px;
  border-radius: 4px;
}
.chip.is-on, .map-btn.is-on {
  background: var(--cream);
  color: var(--ink);
  border-color: var(--cream);
}
.field { display: grid; gap: 6px; margin-bottom: 8px; font-size: 12px; color: var(--cream-dim); }
.field select, .range-row input, .sort select {
  height: 36px;
  width: 100%;
  background: var(--ink);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0 8px;
}
.range-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 8px;
  align-items: center;
}
.range-row span { color: var(--cream-dim); font-size: 12px; }
.hint { margin: 8px 0 0; font-size: 11px; color: var(--cream-dim); line-height: 1.5; }
.checks { display: grid; gap: 8px; margin-top: 16px; font-size: 13px; }
.checks label { display: flex; gap: 8px; align-items: center; color: var(--cream-dim); }

/* —— main —— */
.workspace {
  height: calc(100dvh - 64px);
  display: grid;
  grid-template-columns: var(--list-w, 400px) minmax(0, 1fr);
  min-height: 0;
}

.list-pane {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--ink);
}
.list-toolbar {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
}
.list-toolbar p { margin: 0; font-size: 13px; }
.sort { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--cream-dim); }
.sort select { width: 150px; height: 32px; }

.list {
  flex: 1 1 0;
  height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  padding-bottom: 20px;
}
.list-spacer { width: 100%; }
.card {
  display: grid;
  grid-template-columns: 112px 1fr;
  gap: 12px;
  height: 112px;
  padding: 8px 12px;
  margin: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(244, 238, 226, 0.02);
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.card:hover { background: rgba(244, 238, 226, 0.05); border-color: rgba(212, 162, 74, 0.4); }
.card.is-on { background: rgba(212, 162, 74, 0.08); border-color: var(--gold); }
.thumb {
  height: 96px;
  background: #223028;
  position: relative;
  overflow: hidden;
  border-radius: 6px;
}
.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.thumb.no-photo {
  display: grid;
  place-items: center;
  color: var(--cream-dim);
  font-size: 11px;
}
.badge {
  position: absolute;
  top: 6px;
  left: 6px;
  padding: 2px 6px;
  font-size: 10px;
  border-radius: 3px;
  background: var(--gold);
  color: var(--ink);
}
.badge.rent { background: var(--sea); color: #fff; }
.badge.both { background: var(--azulejo); color: #fff; }
.badge.contract { background: var(--coral); color: #fff; }
.card h4 {
  margin: 2px 0 4px;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card p { margin: 0; font-size: 12px; color: var(--cream-dim); line-height: 1.45; }
.price { margin-top: 6px !important; color: var(--gold-2) !important; font-weight: 600; }
.price .unit {
  margin-left: 8px;
  color: var(--cream-dim);
  font-weight: 400;
  font-size: 11px;
}

.map-pane { position: relative; min-width: 0; min-height: 0; }
#map { position: absolute; inset: 0; }

.splitter {
  position: absolute;
  top: 0;
  bottom: 0;
  left: -7px;
  width: 14px;
  z-index: 5;
  cursor: col-resize;
}
.splitter::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 6px;
  width: 2px;
  background: transparent;
  transition: background 0.15s ease;
}
.splitter:hover::after,
body.dragging .splitter::after {
  background: var(--gold);
}
body.dragging { cursor: col-resize; user-select: none; }
.map-tools {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 2;
  display: flex;
  gap: 6px;
}
.maplibre-ctrl-attrib { font-size: 10px; }

.pin {
  width: 22px;
  height: 22px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  background: var(--coral);
  border: 2px solid var(--cream);
  box-shadow: 0 0 0 4px rgba(196, 92, 74, 0.25);
}
.pin::after {
  content: "";
  position: absolute;
  inset: 5px;
  border-radius: 50%;
  background: var(--cream);
}

.detail {
  position: fixed;
  top: 64px;
  right: 0;
  bottom: 0;
  width: min(460px, 100vw);
  background: #101610;
  border-left: 1px solid var(--line);
  z-index: 20;
  overflow: auto;
  box-shadow: var(--shadow);
}
.detail-close, .lb-close, .lb-nav {
  background: rgba(18, 24, 19, 0.7);
  border: 1px solid var(--line);
  color: var(--cream);
  width: 36px;
  height: 36px;
  font-size: 22px;
  line-height: 1;
  border-radius: 4px;
}
.detail-close {
  position: sticky;
  top: 10px;
  float: right;
  margin: 10px 10px 0 0;
  z-index: 3;
}
.gallery {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 3px;
  background: #000;
}
.gallery img, .gallery .g-empty {
  height: 108px;
  object-fit: cover;
  width: 100%;
  cursor: pointer;
  background: #1a1a1a;
}
.gallery img:first-child {
  grid-column: 1 / -1;
  height: 240px;
}
.g-empty { display: grid; place-items: center; color: var(--cream-dim); font-size: 13px; height: 180px; grid-column: 1 / -1; cursor: default; }
.detail-body { padding: 18px 20px 40px; clear: both; }
.detail-body h2 {
  font-family: var(--serif);
  font-size: 28px;
  margin: 0 0 8px;
  line-height: 1.2;
}
.detail-price { font-size: 20px; color: var(--gold-2); margin: 0 0 16px; }
.meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 14px;
  margin: 0 0 18px;
}
.meta-grid div {
  border-top: 1px solid var(--line);
  padding-top: 8px;
}
.meta-grid small { display: block; color: var(--cream-dim); font-size: 11px; }
.gmap-wrap {
  height: 220px;
  margin: 8px 0 18px;
  border: 1px solid var(--line);
  overflow: hidden;
  background: #223028;
}
.gmap-wrap iframe { width: 100%; height: 100%; border: 0; }
.gmap-fallback {
  height: 100%;
  display: grid;
  place-items: center;
  padding: 16px;
  text-align: center;
  color: var(--cream-dim);
  font-size: 13px;
}
.prose { white-space: pre-wrap; color: var(--cream-dim); font-size: 13px; line-height: 1.7; }
.detail-body h3 { font-size: 13px; margin: 18px 0 8px; color: var(--gold); letter-spacing: 0.08em; }
.contact a, .ext-link {
  color: var(--gold-2);
  text-decoration: none;
}
.ext-link {
  display: inline-block;
  margin-top: 8px;
  border-bottom: 1px solid var(--gold);
  padding-bottom: 2px;
  font-size: 13px;
}
.pill {
  display: inline-block;
  padding: 2px 8px;
  margin: 0 6px 8px 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 11px;
}

.lightbox:not([hidden]) {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(0, 0, 0, 0.92);
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  padding: 48px 20px 56px;
}
.lightbox img {
  max-height: 80dvh;
  max-width: min(1100px, 100%);
  margin: 0 auto;
  object-fit: contain;
}
.lb-close { position: absolute; top: 16px; right: 16px; }
#lbCap {
  position: absolute;
  bottom: 16px;
  left: 0;
  right: 0;
  text-align: center;
  color: var(--cream-dim);
  font-size: 12px;
}

.maplibregl-popup-content {
  background: #101610;
  color: var(--cream);
  border: 1px solid var(--line);
  padding: 10px 12px;
  font-family: var(--sans);
  font-size: 12px;
}
.maplibregl-popup-anchor-bottom .maplibregl-popup-tip { border-top-color: #101610; }

@media (max-width: 980px) {
  .topbar { grid-template-columns: auto 1fr auto; }
  .top-stats { display: none; }
  .workspace { grid-template-columns: 1fr; }
  .splitter { display: none; }
  .list-pane { border-right: 0; }
  .map-pane { display: none; }
  .workspace.show-map { grid-template-columns: 1fr; }
  .workspace.show-map .list-pane { display: none; }
  .workspace.show-map .map-pane { display: block; }
}
@media (max-width: 760px) {
  .brand small { display: none; }
}
