:root {
  /* Warm neutral palette */
  --bg: #F4F0E8;          /* linen page */
  --surface: #FBF8F2;     /* card / modal */
  --sand: #ECE5D8;        /* chips, tags */
  --sand-2: #E2D9C8;      /* chip borders, hover */
  --line: #E1D9CB;        /* hairlines */
  --ink: #2B2823;         /* warm charcoal */
  --ink-2: #4A443B;
  --muted: #6E665B;       /* warm gray, 4.9:1 on linen */
  --accent: #3D5A36;      /* forest sage */
  --accent-soft: #E1E6D3;
  --clay: #A4522F;        /* terracotta, used only for Price drop */
  --shadow: 0 1px 2px rgba(74, 56, 30, .06), 0 4px 14px rgba(74, 56, 30, .05);
  --radius: 12px;
  --top: 60px;
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --serif: "Instrument Serif", Georgia, "Times New Roman", serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font-family: var(--font); font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: inherit; }
button { font: inherit; color: inherit; }
.muted { color: var(--muted); font-weight: 400; }

/* Header */
.topbar {
  position: sticky; top: 0; z-index: 1000; height: var(--top);
  display: flex; align-items: center; gap: 28px; padding: 0 28px;
  background: rgba(244,240,232,.92); backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: baseline; gap: 8px; white-space: nowrap; }
.logo { width: 14px; height: 14px; border-radius: 4px; background: var(--accent); display: inline-block; transform: translateY(1px); }
.brand .name { font-weight: 650; font-size: 16px; letter-spacing: -0.01em; }
.brand .note { font-size: 12px; color: var(--muted); }
.brand .note:empty { display: none; }
.cities { display: flex; gap: 4px; padding: 3px; background: var(--sand); border-radius: 999px; }
.city { text-decoration: none; font-size: 13.5px; padding: 5px 12px; border-radius: 999px; color: var(--ink-2); white-space: nowrap; }
.city:hover { color: var(--ink); }
.city.active { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(74,56,30,.12); }
.city .soon { font-size: 11px; color: var(--muted); margin-left: 2px; }
.count { margin-left: auto; font-size: 13px; color: var(--muted); white-space: nowrap; }

/* Layout */
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 42%; }
.listpane { padding: 36px 36px 64px; min-width: 0; }
.mappane { position: sticky; top: var(--top); height: calc(100vh - var(--top)); padding: 14px 14px 14px 0; }
#mapcanvas { width: 100%; height: 100%; border-radius: 18px; background: #E9E3D7; border: 1px solid var(--line); }

/* Intro */
.intro h1 { font-size: 36px; line-height: 1.12; letter-spacing: -0.025em; font-weight: 650; margin: 0 0 12px; max-width: 18em; }
.intro h1 em { font-family: var(--serif); font-style: italic; font-weight: 400; color: var(--accent); font-size: 1.12em; letter-spacing: 0; }
.intro .sub { color: var(--muted); margin: 0 0 22px; max-width: 60ch; font-size: 15px; }
.count-mobile { display: none; }

/* Controls */
.controls { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.listbar { display: flex; align-items: center; justify-content: space-between; gap: 10px 16px; flex-wrap: wrap; margin: 14px 0 20px; }
.seg { display: inline-flex; align-items: center; gap: 2px; padding: 3px; border: 1px solid var(--sand-2); background: var(--surface); border-radius: 999px; }
.seg-label { font-size: 12.5px; color: var(--muted); padding: 0 8px 0 10px; }
.seg-btn { border: 0; background: transparent; padding: 4px 11px; border-radius: 999px; font-size: 13.5px; cursor: pointer; color: var(--ink-2); }
.seg-btn.active { background: var(--ink); color: #FBF8F2; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1px solid var(--sand-2); background: var(--sand); padding: 6px 12px; border-radius: 999px; font-size: 13.5px; cursor: pointer; color: var(--ink-2); white-space: nowrap; }
.chip:hover { background: var(--sand-2); }
.chip .n { color: var(--muted); margin-left: 4px; font-size: 12.5px; }
.chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 550; }
.chip.on .n { color: var(--accent); }
.result-line { font-size: 13px; color: var(--muted); margin: 0; }

/* Grid + cards */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 22px 20px; }
.card { cursor: pointer; border-radius: 18px; padding: 8px 8px 14px; outline: none; min-width: 0; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); transition: box-shadow .2s ease, transform .2s ease; }
.card:hover { box-shadow: 0 2px 4px rgba(74,56,30,.08), 0 10px 24px rgba(74,56,30,.08); }
.card .photo { position: relative; aspect-ratio: 4 / 3; border-radius: var(--radius); overflow: hidden; background: var(--sand); }
.card .photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
/* Photo carousel: native horizontal scroll with snap. pan-x pan-y keeps vertical page scroll working. */
.photo .car {
  position: absolute; inset: 0; display: flex; overflow-x: auto; overflow-y: hidden;
  scroll-snap-type: x mandatory; scroll-behavior: auto; overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch; touch-action: pan-x pan-y; scrollbar-width: none;
}
.photo .car::-webkit-scrollbar { display: none; }
.photo .slide { flex: 0 0 100%; height: 100%; scroll-snap-align: start; scroll-snap-stop: always; }
.photo .slide img { width: 100%; height: 100%; object-fit: cover; display: block; -webkit-user-drag: none; user-select: none; }
.photo .dots { position: absolute; left: 50%; bottom: 11px; transform: translateX(-50%); display: flex; gap: 5px; pointer-events: none; }
.photo .dots i { width: 6px; height: 6px; border-radius: 50%; background: rgba(251,248,242,.55); box-shadow: 0 0 2px rgba(43,40,35,.35); transition: background .15s, transform .15s; }
.photo .dots i.on { background: #FBF8F2; transform: scale(1.15); }
.photo .carr {
  position: absolute; top: 50%; transform: translateY(-50%); width: 30px; height: 30px; border-radius: 50%;
  border: 0; background: rgba(251,248,242,.92); color: var(--ink); font-size: 20px; line-height: 28px; padding: 0;
  cursor: pointer; box-shadow: 0 1px 4px rgba(43,40,35,.22); opacity: 0; transition: opacity .15s;
}
.photo .carr.prev { left: 10px; }
.photo .carr.next { right: 10px; }
.photo:hover .carr { opacity: .92; }
.photo .carr:hover { opacity: 1; }
.photo.at-start .carr.prev, .photo.at-end .carr.next { visibility: hidden; }
@media (hover: none) { .photo .carr { display: none; } }
.card.selected { box-shadow: 0 0 0 2px var(--ink), var(--shadow); border-color: var(--ink); }
.card:focus-visible { box-shadow: 0 0 0 3px var(--accent); }
.score {
  position: absolute; top: 10px; right: 10px; background: var(--surface); border-radius: 999px;
  padding: 4px 10px 4px 9px; font-size: 13px; font-weight: 650; color: var(--accent);
  box-shadow: 0 1px 4px rgba(43,40,35,.18); display: flex; align-items: baseline; gap: 4px; line-height: 1.3;
}
.score .word { font-weight: 500; color: var(--ink-2); font-size: 12px; }
.pills { position: absolute; top: 10px; left: 10px; display: flex; flex-direction: column; align-items: flex-start; gap: 5px; max-width: 60%; pointer-events: none; }
.pill.dom { display: inline-flex; align-items: center; gap: 4px; color: var(--ink-2); font-weight: 600; }
.pill.dom .ico { width: 12px; height: 12px; flex: none; color: var(--muted); }
.pill.dom em { font-style: normal; font-weight: 450; color: var(--muted); margin-left: 2px; }
.pill { background: rgba(251,248,242,.95); color: var(--ink); font-size: 11.5px; font-weight: 550; padding: 3px 8px; border-radius: 999px; box-shadow: 0 1px 3px rgba(43,40,35,.15); white-space: nowrap; }
.pill.drop { color: var(--clay); }
.nphotos { position: absolute; bottom: 10px; right: 10px; background: rgba(43,40,35,.62); color: #FBF8F2; font-size: 11.5px; padding: 2px 8px; border-radius: 999px; }
.card .info { padding: 12px 6px 0; }
.price-row { display: flex; align-items: baseline; gap: 6px; }
.price { font-size: 22px; font-weight: 650; letter-spacing: -0.02em; }
.price small { font-size: 13px; color: var(--muted); font-weight: 450; letter-spacing: 0; }
.reason { font-size: 14px; color: var(--accent); margin: 2px 0 6px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.facts { font-size: 14px; color: var(--ink); }
.where { font-size: 14px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.tag { background: var(--sand); color: var(--ink-2); font-size: 12px; padding: 3px 8px; border-radius: 6px; white-space: nowrap; }
.tag.dom { display: inline-flex; align-items: center; gap: 5px; background: transparent; color: var(--muted); box-shadow: inset 0 0 0 1px var(--line); }
.tag.dom .ico { width: 13px; height: 13px; flex: none; }
.kv .sub { color: var(--muted); font-size: 13px; }
.view-seg { display: inline-flex; }
.bar-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.empty { color: var(--muted); padding: 40px 0; text-align: center; }

/* Status watch */
.watch { margin-top: 56px; border-top: 1px solid var(--line); padding-top: 20px; }
.watch summary { cursor: pointer; list-style: none; display: flex; flex-direction: column; gap: 2px; }
.watch summary::-webkit-details-marker { display: none; }
.watch-title { font-weight: 600; font-size: 17px; }
.watch-title::before { content: "+"; display: inline-block; width: 18px; color: var(--muted); font-weight: 400; }
.watch[open] .watch-title::before { content: "\2212"; }
.watch-sub { font-size: 13.5px; color: var(--muted); padding-left: 18px; }
.watch .grid { margin-top: 22px; }
.watch .card .photo img { filter: saturate(.6) sepia(.1); }

/* How it works */
.howto { margin-top: 56px; border-top: 1px solid var(--line); padding-top: 24px; color: var(--ink-2); font-size: 14px; }
.howto h2 { font-size: 17px; margin: 0 0 10px; color: var(--ink); }
.rules { padding-left: 18px; margin: 0 0 12px; max-width: 75ch; }
.rules li { margin: 4px 0; }
.fine { color: var(--muted); font-size: 13px; max-width: 75ch; }
.brandline { margin-top: 22px; font-size: 13px; font-weight: 600; color: var(--ink); display: flex; align-items: center; gap: 8px; }
.brandline .muted { font-weight: 400; }

/* Map pins */
.pin-wrap { background: none; border: 0; }
.ppin {
  display: inline-block; transform: translate(-50%, -50%); background: var(--surface); color: var(--ink);
  font: 600 11.5px/1 var(--font); padding: 5px 7px; border-radius: 999px; white-space: nowrap;
  box-shadow: 0 1px 4px rgba(43,40,35,.28); border: 1px solid var(--sand-2); cursor: pointer;
}
.ppin.approx { border: 1px dashed #9C9284; }
.ppin.watch { color: var(--muted); background: var(--sand); }
.ppin.active, .ppin:hover { background: var(--ink); color: #FBF8F2; border-color: var(--ink); }
.ppin.active { transform: translate(-50%, -50%) scale(1.12); }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--surface); color: var(--ink); }
.leaflet-popup-content-wrapper { border-radius: 12px; }
.leaflet-popup-content { margin: 10px 12px; font-family: var(--font); }
.pop { display: flex; gap: 10px; align-items: center; min-width: 220px; }
.pop img { width: 72px; height: 54px; object-fit: cover; border-radius: 8px; }
.pop b { font-size: 14px; display: block; }
.pop .s { color: var(--accent); font-weight: 600; font-size: 12.5px; }
.pop .a { color: var(--muted); font-size: 12.5px; }
.pop button { margin-top: 4px; border: 0; background: none; padding: 0; color: var(--ink); text-decoration: underline; cursor: pointer; font-size: 12.5px; }
.leaflet-container { font-family: var(--font); }
.leaflet-tile-pane { filter: sepia(.08) saturate(.72) brightness(1.03) contrast(.94); }
.leaflet-control-zoom a, .leaflet-control-attribution { background: rgba(251,248,242,.92) !important; color: var(--ink-2) !important; }

/* Map toggle (mobile) */

/* Modal */
.modal { position: fixed; inset: 0; z-index: 2000; display: flex; align-items: center; justify-content: center; padding: 24px; }
.modal[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(43,36,26,.5); }
.modal-card { position: relative; background: var(--surface); border-radius: 20px; width: min(1040px, 100%); max-height: calc(100vh - 48px); display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 20px 60px rgba(43,36,26,.3); }
.modal-body { overflow: auto; -webkit-overflow-scrolling: touch; }
.modal-close { position: absolute; top: 12px; right: 12px; z-index: 3; width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--surface); color: var(--ink); box-shadow: 0 1px 4px rgba(43,40,35,.25); font-size: 22px; line-height: 1; cursor: pointer; }
.m-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 28px; padding: 24px 64px 28px 28px; }
.gallery .main { position: relative; aspect-ratio: 4 / 3; border-radius: var(--radius); overflow: hidden; background: var(--sand); }
.gallery .main img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gnav { position: absolute; top: 50%; transform: translateY(-50%); width: 36px; height: 36px; border-radius: 50%; border: 0; background: rgba(251,248,242,.94); color: var(--ink); box-shadow: 0 1px 4px rgba(43,40,35,.25); cursor: pointer; font-size: 18px; }
.gnav.prev { left: 10px; } .gnav.next { right: 10px; }
.gcount { position: absolute; bottom: 10px; right: 10px; background: rgba(43,40,35,.62); color: #FBF8F2; font-size: 12px; padding: 2px 8px; border-radius: 999px; }
.thumbs { display: flex; gap: 8px; margin-top: 10px; overflow-x: auto; }
.thumbs img { width: 84px; height: 63px; object-fit: cover; border-radius: 8px; cursor: pointer; opacity: .65; flex: none; }
.thumbs img.on { opacity: 1; box-shadow: 0 0 0 2px var(--ink); }
.m-side h2 { margin: 0; font-size: 28px; letter-spacing: -0.02em; }
.m-side h2 small { font-size: 15px; color: var(--muted); font-weight: 450; }
.m-score { display: inline-flex; align-items: baseline; gap: 6px; background: var(--accent-soft); color: var(--accent); border-radius: 999px; padding: 4px 12px; font-weight: 650; font-size: 15px; margin-bottom: 10px; }
.m-reason { color: var(--accent); font-weight: 500; margin: 2px 0 8px; }
.m-addr { color: var(--muted); margin: 4px 0 14px; }
.m-pills { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.m-pills .pill { box-shadow: none; background: var(--sand); }
.btn { display: inline-block; background: var(--accent); color: #FBF8F2; text-decoration: none; padding: 10px 16px; border-radius: 10px; font-weight: 550; font-size: 14px; }
.src { font-size: 12.5px; color: var(--muted); margin-top: 8px; word-break: break-all; }
.src .full { display: block; font-size: 11.5px; margin-top: 2px; opacity: .8; }
.src a { color: var(--muted); }
.m-sec { margin-top: 22px; }
.m-sec h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 8px; font-weight: 600; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 6px 14px; font-size: 14px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.bd { width: 100%; border-collapse: collapse; font-size: 14px; }
.bd td { padding: 6px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.bd td.pts { text-align: right; white-space: nowrap; width: 60px; font-variant-numeric: tabular-nums; color: var(--ink-2); }
.bd tr.total td { font-weight: 650; border-bottom: 0; color: var(--accent); }
.bd tr.start td { color: var(--muted); }
.notes { font-size: 14px; color: var(--ink-2); }
.notes p { margin: 0 0 8px; }
.dnote { font-size: 13px; background: var(--sand); border-radius: 10px; padding: 8px 12px; color: var(--ink-2); }
.m-full { padding: 0 28px 28px; }

/* Tablet */
@media (max-width: 1100px) {
  .layout { grid-template-columns: minmax(0, 1fr) 38%; }
  .listpane { padding: 28px 24px 56px; }
  .intro h1 { font-size: 30px; }
}

/* Map mode (List | Map toggle), all widths */
body.mode-map { overflow: hidden; }
body.mode-map .layout { display: block; }
body.mode-map .listpane { padding-bottom: 0; }
body.mode-map .mappane { display: block; position: fixed; top: var(--maptop, var(--top)); left: 0; right: 0; bottom: 0; height: auto; padding: 0 14px 14px; z-index: 900; background: var(--bg); }
body.mode-map .intro, body.mode-map .grid, body.mode-map .watch, body.mode-map .howto, body.mode-map .empty { display: none !important; }
body.mode-map .listbar { margin-bottom: 0; }
/* Bottom sheet for the selected pin */
.sheet {
  display: block; position: fixed; left: 8px; right: 8px; bottom: calc(8px + env(safe-area-inset-bottom)); z-index: 1200;
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 6px 12px 10px;
  box-shadow: 0 10px 34px rgba(43,36,26,.28); transform: translateY(calc(100% + 24px)); transition: transform .22s ease;
  touch-action: none; cursor: pointer;
}
.sheet[hidden] { display: none; }
.sheet.open { transform: none; }
.sheet .grab { width: 38px; height: 4px; border-radius: 4px; background: var(--sand-2); margin: 2px auto 8px; }
.sh-row { display: grid; grid-template-columns: 124px minmax(0, 1fr); gap: 12px; align-items: start; }
.sh-photo { position: relative; height: 104px; border-radius: 12px; overflow: hidden; background: var(--sand); }
.sh-photo .score { top: 6px; right: 6px; left: auto; padding: 2px 7px; font-size: 12px; }
.sh-photo .score .word { display: none; }
.sh-photo .dots { bottom: 7px; }
.sh-info { min-width: 0; }
.sh-info .price { font-size: 19px; }
.sh-info .reason { margin: 1px 0 3px; font-size: 13.5px; }
.sh-info .facts, .sh-info .where { font-size: 13px; }
.sh-info .tags { margin-top: 6px; }
.sh-nav { display: flex; align-items: center; gap: 8px; margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--line); }
.sh-nav button { font: inherit; cursor: pointer; }
.sh-prev, .sh-next { width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--sand-2); background: var(--surface); color: var(--ink); font-size: 20px; line-height: 28px; padding: 0; }
.sh-prev:disabled, .sh-next:disabled { opacity: .35; }
.sh-pos { font-size: 12.5px; color: var(--muted); }
.sh-open { margin-left: auto; border: 0; background: var(--accent); color: #FBF8F2; padding: 8px 14px; border-radius: 999px; font-weight: 600; font-size: 13.5px; }
@media (min-width: 821px) {
  .sheet { left: 28px; right: auto; bottom: 28px; width: 460px; }
  .sheet .grab { display: none; }
  .sheet .sh-row { grid-template-columns: 150px minmax(0, 1fr); }
  .sheet .sh-photo { height: 116px; }
}

/* Mobile */
@media (max-width: 820px) {
  :root { --top: 54px; }
  .topbar { padding: 0 16px; gap: 12px; }
  .brand .note { display: none; }
  .count { display: none; }
  .cities { margin-left: auto; }
  .city { padding: 5px 10px; font-size: 13px; }
  .city .soon { display: none; }
  .layout { display: block; }
  .listpane { padding: 22px 16px 96px; }
  .intro h1 { font-size: 27px; }
  .intro .sub { font-size: 14.5px; margin-bottom: 6px; }
  .count-mobile { display: block; font-size: 13px; color: var(--muted); margin: 0 0 16px; }
  .controls { flex-direction: column; flex-wrap: nowrap; align-items: stretch; gap: 10px; }
  .listbar { flex-direction: column-reverse; align-items: flex-start; margin: 12px 0 18px; }
  .chips { flex-wrap: nowrap; overflow-x: auto; margin: 0 -16px; padding: 0 16px 2px; scrollbar-width: none; min-width: 0; max-width: calc(100% + 32px); }
  .chips::-webkit-scrollbar { display: none; }
  .grid { grid-template-columns: 1fr; gap: 28px; }
  .bar-right { width: 100%; justify-content: space-between; flex-wrap: nowrap; gap: 6px; }
  .seg-label { padding: 0 4px 0 8px; }
  .seg-btn { padding: 5px 10px; }
  .mappane { display: none; }
  body.mode-map .mappane { padding: 0; border-top: 1px solid var(--line); }
  body.mode-map #mapcanvas { border-radius: 0; border: 0; }
  .modal { padding: 0; align-items: stretch; }
  .modal-card { border-radius: 0; max-height: none; height: 100%; }
  .modal-close { top: 10px; right: 10px; background: rgba(251,248,242,.95); }
  .m-grid { grid-template-columns: 1fr; padding: 12px 16px 20px; gap: 18px; }
  .m-side { padding-top: 0; }
  .m-full { padding: 0 16px 24px; }
  .gallery .main { border-radius: 12px; }
  .kv { grid-template-columns: 96px 1fr; }
}
