/* Viewer styles. No framework, no build step — one file, read top to bottom. */

:root {
  color-scheme: light dark;
  --bg: #f7f7f5;
  --card: #ffffff;
  --ink: #1a1a19;
  --muted: #75736e;
  --faint: #a3a099;
  --line: #e3e1db;
  --line-soft: #efedea;
  --accent: #0f7b6c;
  --accent-soft: #e3f2ef;
  --warn: #b4690e;
  --bad: #d43f3a;
  --shadow: 0 1px 2px rgba(0, 0, 0, .05), 0 8px 24px rgba(0, 0, 0, .06);
  --shadow-lift: 0 2px 6px rgba(0, 0, 0, .07), 0 16px 40px rgba(0, 0, 0, .12);
  --radius: 14px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131417;
    --card: #1c1e22;
    --ink: #e9e7e2;
    --muted: #96938c;
    --faint: #6d6b66;
    --line: #2c2f35;
    --line-soft: #24272c;
    --accent: #3aa891;
    --accent-soft: #14312c;
    --warn: #d99b3f;
    --bad: #e2706a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);
    --shadow-lift: 0 2px 6px rgba(0, 0, 0, .5), 0 16px 40px rgba(0, 0, 0, .5);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}

/* ------------------------------------------------------------------- top bar */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--card) 88%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line);
  padding: 10px 20px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.topbar .row { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.topbar h1 { margin: 0; font-size: 17px; font-weight: 660; letter-spacing: -0.015em; white-space: nowrap; }

/*
 * The open shop window: what this is, and where the rest of it lives.
 *
 * The map button is hidden rather than removed from the markup, so that nothing in
 * app.mjs has to check whether the element exists before wiring it — the mode already
 * keeps the page out of map mode, and one CSS rule is cheaper than guards on every
 * use. Written here rather than served conditionally for the same reason.
 */
body[data-mode="open"] #toggle-map { display: none; }
.open-note {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}
.open-note a { color: var(--accent); }
.count { color: var(--muted); font-weight: 400; font-size: 13px; margin-left: 4px; }
.spacer { flex: 1 1 auto; }

.search {
  flex: 1 1 240px;
  max-width: 420px;
  padding: 8px 13px;
  font-size: 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg);
  color: var(--ink);
}
.search:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.btn {
  padding: 7px 12px;
  font-size: 13px;
  font-family: inherit;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { background: var(--bg); border-color: var(--muted); }
.select { padding-right: 8px; }

.heart-btn .heart { color: var(--bad); }
.heart-btn.on { background: var(--bad); border-color: var(--bad); color: #fff; }
.heart-btn.on .heart { color: #fff; }

/* -------------------------------------------------------------- filter menus */

.filters { gap: 7px; }
/* `contents` so the chips join the filter row directly instead of being boxed into
   one flex item that refuses to wrap. */
.facets { display: contents; }
.filter { position: relative; }

/* The sort control is a chip like the rest, and sits with them rather than off in
   the header — it answers the same question the filters do. */
.sort { padding-right: 8px; font-family: inherit; }

.filter-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px;
  font-size: 13px;
  font-family: inherit;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--ink);
  cursor: pointer;
}
.filter-btn:hover { border-color: var(--muted); }
.filter-btn[aria-expanded="true"] { border-color: var(--accent); }
.filter-btn.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.filter-btn .caret { color: var(--faint); font-size: 9px; }
.filter-btn.active .caret { color: inherit; }

.panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 30;
  min-width: 230px;
  max-width: 320px;
  max-height: 60vh;
  overflow: auto;
  padding: 7px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow-lift);
}
.panel[hidden] { display: none; }
.panel .find {
  width: 100%;
  margin-bottom: 6px;
  padding: 6px 9px;
  font-size: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--ink);
}
.panel label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
}
.panel label:hover { background: var(--bg); }
.panel label.hidden { display: none; }
.panel input[type="checkbox"] { accent-color: var(--accent); margin: 0; }
.panel .name { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.panel .n { color: var(--faint); font-variant-numeric: tabular-nums; font-size: 12px; }
.panel .none { padding: 8px; color: var(--muted); font-size: 13px; }

/* --------------------------------------------------------------- the cards */

main { padding: 20px; }

/* Fills whatever width the window has: one column on a phone, as many as fit on a
   desktop. The minimum is the point below which a photo stops being worth looking
   at, which is what decides the count rather than a breakpoint list. */
/* `hidden` has to win over the `display: grid` below it — the attribute only carries
   `display: none` from the browser's own sheet, and any rule of ours outranks it. The
   split leans on this: the panel and the list take turns in the same column. */
.cards[hidden] { display: none; }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 26px 20px;
  max-width: 1800px;
  margin: 0 auto;
}

/* min-width:0 because a grid item defaults to min-content, and the min-content of
   a card is its photograph at full intrinsic size — 1500px of it. Without this the
   track grows to fit the image and the whole page scrolls sideways. */
.card { display: flex; flex-direction: column; gap: 10px; cursor: pointer; min-width: 0; }

.shot-wrap {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--line-soft);
  box-shadow: var(--shadow);
  transition: box-shadow .18s ease, transform .18s ease;
}
.card:hover .shot-wrap { box-shadow: var(--shadow-lift); transform: translateY(-2px); }

.shot-wrap img,
.shot-wrap > video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/*
 * The first few photographs, flickable inside the card.
 *
 * Scroll snapping does the whole job: a swipe on a phone and a two-finger sweep on a
 * trackpad both land on a photograph rather than between two. The scrollbar is
 * hidden because the dots below say the same thing more quietly.
 */
.strip {
  display: flex;
  height: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  /*
   * No `-webkit-overflow-scrolling: touch` here. It has been the default since
   * iOS 13, so it buys no momentum that is not already there — but it does force a
   * composited layer per strip, and the grid renders every card at once. A few
   * hundred backing stores is what takes the tab down on a phone.
   */
  /*
   * No `touch-action` here on purpose. The default lets the browser pick the axis
   * from the gesture — a sideways drag scrolls this strip, a vertical one scrolls
   * the page — which is exactly the behaviour wanted. Naming an axis takes the
   * other one away: `pan-y` reads as "keep the page scrolling", and it does, by
   * making the strip unswipeable on a phone. A desktop test never notices, because
   * a trackpad sweep is a wheel event and `touch-action` does not apply to it.
   */
}
.strip::-webkit-scrollbar { display: none; }
/*
 * Reaching the end of the strip is the end of it — nothing carries on to the page
 * behind, and on a trackpad nothing turns into the browser's back gesture.
 */
.strip { overscroll-behavior-x: contain; cursor: grab; }
.strip.dragging { cursor: grabbing; }
.strip > img {
  flex: 0 0 100%;
  scroll-snap-align: center;
  scroll-snap-stop: always;
  background: var(--line-soft);
  /* Or the browser starts dragging the picture itself halfway through the gesture. */
  user-select: none;
  -webkit-user-drag: none;
}

.dots {
  position: absolute;
  left: 0; right: 0; bottom: 10px;
  display: flex;
  justify-content: center;
  gap: 6px;
  /* The strip beneath must stay swipeable; the dots themselves opt back in. */
  pointer-events: none;
}
.dots > i {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .55);
  box-shadow: 0 0 3px rgba(0, 0, 0, .45);
  transition: background .15s ease, transform .15s ease;
  pointer-events: auto;
  cursor: pointer;
}
.dots > i.on { background: #fff; transform: scale(1.25); }
/* A 6px target is fine to look at and far too small to hit. */
.dots > i::after {
  content: '';
  position: absolute;
  width: 22px; height: 22px;
  margin: -8px 0 0 -8px;
}
/* Reads as a video rather than as a photograph that failed to load. */
.shot-wrap .play {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 46px; height: 46px;
  display: grid; place-items: center;
  border-radius: 50%;
  /* Opaque enough to read on any photograph without a blur behind it. These sit one
     per card and the grid renders every card at once, so a backdrop-filter here is
     not one blurred circle, it is hundreds of composited backdrop layers — enough to
     kill the whole tab on iOS Safari. Same reason on .badge and .fav below; .sheet
     and the sticky header keep theirs, there is only ever one of each. */
  background: rgba(0, 0, 0, .55);
  color: #fff;
  font-size: 17px;
  padding-left: 3px; /* the glyph is optically left-heavy inside a circle */
  pointer-events: none;
}
.shot-wrap .none {
  width: 100%; height: 100%;
  display: grid; place-items: center;
  color: var(--faint); font-size: 30px;
}

.badge {
  position: absolute;
  left: 10px; bottom: 10px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  color: #fff;
  background: rgba(0, 0, 0, .62);
}

.fav {
  position: absolute;
  top: 9px; right: 9px;
  width: 34px; height: 34px;
  display: grid; place-items: center;
  padding: 0;
  border: 0; border-radius: 50%;
  background: rgba(0, 0, 0, .45);
  color: #fff;
  cursor: pointer;
  transition: transform .12s ease;
}
.fav:hover { transform: scale(1.12); background: rgba(0, 0, 0, .5); }
.fav.on { color: var(--bad); }
.fav.on:hover { color: #fff; }

/* The one heart on the page, wherever it hangs — on a photograph, or in the corner of
   the villa's window. Hollow until it is starred, and then filled with whatever colour
   its button is already carrying. */
.heart-svg {
  display: block;
  width: 19px; height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.on > .heart-svg { fill: currentColor; }

.card-body { display: flex; flex-direction: column; gap: 3px; }
.card-top { display: flex; align-items: baseline; gap: 8px; }
.card-title {
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.01em;
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.card-where { color: var(--muted); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-where .none { color: var(--faint); }
.card-meta { color: var(--muted); font-size: 13px; }
.card-price { margin-top: 3px; font-size: 15px; }
/* Both quoted periods stack, so the second must not read as an afterthought. */
.card-price .price-line + .price-line { margin-top: 1px; }
.card-price b { font-weight: 640; }
/* The unit, and the figure derived from it — never a quoted number itself. */
.card-price .per,
.sheet .per { color: var(--muted); font-weight: 400; }
.card-price .none { color: var(--faint); font-weight: 400; }

.card-added { color: var(--faint); font-size: 12px; margin-top: 2px; }

.empty { padding: 60px 16px; text-align: center; color: var(--muted); }

/*
 * The pager. Present because the grid holds one page at a time — see PAGE_SIZE in
 * app.mjs — so it is load-bearing, not decoration, and it stays reachable rather
 * than sticky: it belongs after the last card, where someone who has scrolled the
 * page arrives at it.
 */
.pager[hidden] { display: none; }

.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px 16px;
  padding: 20px 16px 40px;
}
.pager .btn[disabled] { opacity: .38; cursor: default; }
.pager-at {
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
/* On a narrow screen the range alone carries it; the page number is the first thing
   worth dropping to keep the two buttons on one line. */
@media (max-width: 430px) {
  .pager-of { display: none; }
}

/* ------------------------------------------------------- one villa, in a window */

/*
 * Two panes, one villa: what it is on the left, every photograph of it on the right.
 *
 * It replaces a details sheet and a separate full-screen gallery that could not be
 * open at once — so reading the terms and looking at the rooms meant closing one to
 * see the other. The window is sized rather than grown: a fixed height with each pane
 * scrolling inside it, because the column of photographs is far the longer of the two
 * and letting it set the height would push the facts off the screen.
 */
.sheet {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(10, 10, 12, .5);
  backdrop-filter: blur(3px);
  display: grid;
  place-items: center;
  padding: 20px;
}
.sheet[hidden] { display: none; }

.sheet-card {
  position: relative;
  display: flex;
  width: min(1180px, 100%);
  height: min(88dvh, 940px);
  overflow: hidden;
  background: var(--card);
  border-radius: 18px;
  box-shadow: var(--shadow-lift);
}

/* A band, not a share of the window — the same reason the split's card column has
   one. The facts read at a comfortable measure whatever the monitor is, and the
   photographs take everything left over. */
.sheet-info {
  flex: 0 0 clamp(320px, 34%, 430px);
  min-width: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 26px 28px 30px;
  scrollbar-width: thin;
}

.sheet-media {
  flex: 1 1 auto;
  min-width: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 16px 16px 40px;
  background: var(--bg);
  border-left: 1px solid var(--line);
  scrollbar-width: thin;
}

/* Floats over the photographs in the corner rather than taking a strip of the window
   for itself: it is reached once, at the end, and the room it would cost is room a
   photograph is using the whole time. */
.sheet-close {
  position: absolute;
  top: 12px; right: 12px;
  z-index: 5;
  width: 34px; height: 34px;
  border: 1px solid var(--line); border-radius: 50%;
  background: var(--card);
  color: var(--ink);
  font-size: 14px;
  cursor: pointer;
  box-shadow: var(--shadow);
}
.sheet-close:hover { background: var(--bg); border-color: var(--muted); }

.sheet-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 18px; }
.sheet-head-text { flex: 1 1 auto; min-width: 0; }
.sheet h2 { margin: 0; font-size: 19px; letter-spacing: -0.02em; }
.sheet .sub { margin: 4px 0 0; color: var(--muted); font-size: 14px; }

/* Starring and copying a link, as icons in the corner. Quiet on purpose: the one
   control in this column that is a decision is the contact button, and a second
   filled button beside the title would take that away from it. */
.icon-actions { display: flex; gap: 6px; flex: none; }
.icon-btn {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  padding: 0;
  border: 1px solid var(--line); border-radius: 50%;
  background: var(--card);
  color: var(--muted);
  cursor: pointer;
  transition: color .12s ease, border-color .12s ease, transform .12s ease;
}
.icon-btn:hover { color: var(--ink); border-color: var(--muted); transform: scale(1.06); }
.icon-btn svg {
  display: block;
  width: 17px; height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
/* Starred: the outline fills in, exactly as it does on the card. */
.icon-btn.on { color: var(--bad); border-color: var(--bad); }
/*
 * The facts about one villa, laid out once.
 *
 * Both places that show them — the window and the panel beside the map — build the
 * list from the same factsHtml(), and used to style it twice over. Two copies of a
 * layout for one piece of markup is two things to keep in step; what actually differs
 * between the two is the width of the term column and the type size, so that is all
 * either of them now says.
 */
.facts {
  margin: 0;
  display: grid;
  grid-template-columns: var(--term-col, 132px) 1fr;
  gap: var(--facts-gap, 9px 16px);
  font-size: var(--facts-size, inherit);
}
.facts dt {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding-top: 2px;
}
.facts dd { margin: 0; overflow-wrap: anywhere; }
.sheet a { color: var(--accent); }
/*
 * The contact block — the one control on this page that reaches out of it.
 *
 * Styled here rather than under .sheet because it is used twice: in the villa's window
 * and in the panel the map opens beside the list.
 *
 * It used to sit in a tinted box, inherited from the address note it replaced. The box
 * was doing nothing the button was not already doing better: a green panel around a
 * green button is the same emphasis said twice, and it made the one thing on the page
 * that reaches out of it look like a notice. Centred and on its own, with the sentence
 * under it as a caption rather than as the other half of a panel.
 */
.contact {
  margin: 24px 0 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
/*
 * One rule for both shapes of the same control: a <button> on the closed site, which
 * posts, and an <a> on the open one, which walks the visitor into the bot. Only the
 * element differs, so only the properties an anchor does not get by default are
 * spelled out — the two must look identical or the open site reads as a lesser page.
 */
.contact .contact-btn {
  display: inline-block;
  padding: 10px 18px;
  border: 0; border-radius: 999px;
  background: var(--accent); color: #fff;
  font: inherit; font-size: 14px; font-weight: 560;
  text-decoration: none;
  cursor: pointer;
}
.contact .contact-btn:hover { filter: brightness(1.08); }
.contact .contact-btn[disabled] { opacity: .55; cursor: default; }
.contact .note {
  margin: 10px 0 0; padding: 0;
  max-width: 34em;
  font-size: 13px; color: var(--muted);
}
.contact a { color: var(--accent); }

/* ------------------------------------------------------------------- toast */

/*
 * "Link copied", and nothing more demanding than that. Sits above the villa's
 * window, because copying is possible from inside it as well as from the list.
 */
.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  z-index: 120;
  transform: translate(-50%, 12px);
  max-width: min(520px, calc(100vw - 32px));
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg);
  font-size: 14px;
  text-align: center;
  overflow-wrap: anywhere;
  box-shadow: var(--shadow-lift);
  opacity: 0;
  transition: opacity .18s ease, transform .18s ease;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast[hidden] { display: none; }

/* --------------------------------------------------- the photographs, in the window */

/*
 * The square is a ceiling, not a frame.
 *
 * A realtor's album mixes wide shots with portrait phone ones, and nothing may be
 * cropped — so the picture is fitted, never filled. What changed is what happens to
 * the room it does not use: a wide photograph now takes only the height its own
 * proportions ask for, instead of sitting in the middle of a square with a band of
 * grey above and below it. Down a column those bands were most of what you scrolled
 * past.
 *
 * A tall one still stops at the square — that is the ceiling — and keeps its margins
 * left and right, because a portrait shot allowed its full height would be a metre of
 * photograph per villa and two of them impossible to compare. Those margins are left
 * uncoloured, so they read as space rather than as frame.
 *
 * The square is also what the browser is given before the image arrives, which is
 * what makes `loading="lazy"` actually defer: with zero-high frames they all stack at
 * the top of the viewport and the whole gallery downloads at once. The real
 * proportions are written onto the frame on `load` — see wireMediaShape() — so the
 * square is a starting guess that only ever shrinks.
 *
 * The width is capped rather than left to the pane: past about 560px a phone
 * snapshot is being enlarged, not shown, and the column reads better narrow than a
 * blurred one reads wide.
 */
.shot { margin: 0; width: 100%; max-width: 560px; }
.shot .frame {
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border-radius: 10px;
  background: var(--line-soft);
  touch-action: pan-y;
  cursor: zoom-in;
}
/* Loaded: the picture itself is the only thing with a colour. Until then the tint is
   what says a photograph is on its way. */
.shot .frame.shaped { background: none; }
.shot .frame.zoomed { cursor: grab; touch-action: none; }
.shot .frame.zoomed.dragging { cursor: grabbing; }
.shot img {
  display: block;
  width: 100%;
  height: 100%;
  /* contain, not cover: whatever room the frame has left over stays empty rather
     than being taken out of the photograph. */
  object-fit: contain;
  transform-origin: 0 0;
  will-change: transform;
  -webkit-user-select: none;
  user-select: none;
  -webkit-user-drag: none;
}
/* Same rule for a clip, from its own dimensions — a landscape walkthrough had the
   same two bands of black. */
.shot video {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  border-radius: 10px;
  background: #000;
}
.shot video.shaped { background: none; }
.shot figcaption { padding: 5px 3px 0; font-size: 12px; color: var(--faint); }
.shot a.download { color: var(--accent); font-size: 13px; }

/* "Загружаю…", "медиа не найдено", and what went wrong — where the photographs
   would have been. */
.media-note { color: var(--muted); font-size: 13px; padding: 30px 16px; text-align: center; }

.only-narrow { display: none; }

@media (max-width: 620px) {
  main { padding: 14px; }
  .topbar { padding: 10px 14px; }

  /* Eight filter chips take half a phone screen before a single villa is visible,
     so they fold behind one button and the list starts at the top. */
  /* Scoped to .topbar because `.topbar .row` sets display:flex and outranks a bare
     `.filters` — the row would stay open no matter what this said. */
  .only-narrow { display: inline-block; }
  .topbar .filters { display: none; }
  .topbar .filters.open { display: flex; }
  /* minmax(0, 1fr), never a bare 1fr — see the note on .card above. */
  .cards { grid-template-columns: minmax(0, 1fr); gap: 22px; }

  /*
   * No room for two panes, so they become one column: the facts, then the album
   * under them. Full screen rather than a sheet lifted off the bottom — the
   * photographs are half of what this window is for, and a strip of listing showing
   * above them buys nothing.
   *
   * One scroller for the pair, on the card itself. Two panes each scrolling inside a
   * screen-high box would mean the facts stop dead a third of the way down while the
   * album goes on beneath them, and a finger cannot tell which of the two it is in.
   */
  .sheet { padding: 0; place-items: stretch; }
  .sheet-card {
    width: 100%;
    height: 100dvh;
    flex-direction: column;
    border-radius: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  /* Fixed, not absolute: the card is the scroller now, and an absolute cross would
     scroll off the top with the title. The `.sheet` above is fixed and full-screen,
     so this lands in the corner of the window either way. */
  .sheet-close { position: fixed; }
  /* Clear of the cross, which now floats over this pane rather than over the photos. */
  .sheet-info { flex: none; overflow: visible; padding: 56px 18px 22px; }
  .sheet-media {
    flex: none;
    overflow: visible;
    border-left: 0;
    border-top: 1px solid var(--line);
    padding: 16px 14px 40px;
  }
  .facts { grid-template-columns: 1fr; gap: 2px 0; }
  .facts dt { margin-top: 10px; }
}

/* ----------------------------------------------------------------------- map */

/* The map fills what is left under the header, and the page stops scrolling: two
   scrollable things, one inside the other, is how a pinch ends up moving the page. */
body.map-mode { overflow: hidden; }
body.map-mode main { padding: 0; }

/*
 * `z-index: 0` is load-bearing, not tidying.
 *
 * Leaflet gives its panes z-index 400 and its controls 800, and without a stacking
 * context of their own those numbers are counted against the whole page — the map
 * then paints over the villa's window (90) and the photographs in it. Everything inside
 * here is sealed into this one layer instead, and the sheet comes back on top.
 */
.map-wrap {
  position: relative;
  z-index: 0;
  height: calc(100dvh - var(--topbar-h, 120px));
}
.map { position: absolute; inset: 0; }
.leaflet-container { background: var(--line-soft); font: inherit; }

/* OSM tiles are drawn for a white page; at night they glare next to everything
   else here. Only the tiles are dimmed — pins and outlines keep their colour. */
@media (prefers-color-scheme: dark) {
  .leaflet-tile-pane { filter: brightness(.72) contrast(1.08) saturate(.9); }
}

/* What the map is not showing, said out loud rather than left to be noticed. */
.map-note {
  position: absolute;
  z-index: 500;
  left: 12px;
  bottom: 12px;
  max-width: min(340px, calc(100% - 24px));
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
  padding: 8px 11px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--card) 92%, transparent);
  backdrop-filter: saturate(180%) blur(10px);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  font-size: 12px;
  color: var(--muted);
}
#map-note-text { font-weight: 600; color: var(--ink); }
.map-legend { display: flex; align-items: center; gap: 5px; flex-basis: 100%; }
.map-key { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.map-key + .map-key { margin-left: 8px; }
.map-key-exact { background: var(--accent); }
.map-key-approx { background: var(--warn); opacity: .55; }

/* A price, standing on the point. Exact pins are solid; a point worked out from a
   description is hollow and dashed, and reads as an outline rather than an address. */
.map-pin {
  display: inline-block;
  transform: translate(-50%, -100%);
  padding: 2px 7px;
  border-radius: 11px;
  font-size: 12px;
  font-weight: 650;
  line-height: 1.5;
  white-space: nowrap;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .3);
}
.map-pin-exact { background: var(--accent); color: #fff; }

/* What a pin becomes when its price has nowhere to go. The point is unchanged — only
   the label stepped aside — so one more zoom brings the number back. */
.map-dot {
  display: block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .35);
}
.map-dot-exact { background: var(--accent); border: 2px solid var(--card); }
.map-dot-approx { background: color-mix(in srgb, var(--warn) 45%, transparent); border: 1px dashed var(--warn); }
.map-pin-approx {
  background: color-mix(in srgb, var(--card) 88%, transparent);
  color: var(--warn);
  border: 1px dashed var(--warn);
  font-weight: 550;
}

/* The uncertainty a text-derived point really carries, drawn to scale. */
.map-blur {
  fill: var(--warn);
  fill-opacity: .07;
  stroke: var(--warn);
  stroke-opacity: .3;
  stroke-width: 1;
  stroke-dasharray: 4 4;
}

/* Zoomed out, one of these per district instead of a smear of pins. */
.map-bubble {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  transform: translate(-50%, -50%);
  padding: 5px 10px;
  border-radius: 14px;
  background: color-mix(in srgb, var(--card) 94%, transparent);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  color: var(--ink);
  white-space: nowrap;
  cursor: pointer;
}
.map-bubble b { font-size: 13px; font-weight: 640; }
.map-bubble i { font-style: normal; font-size: 12px; color: #fff; background: var(--accent); border-radius: 9px; padding: 0 6px; }
.map-bubble u { text-decoration: none; font-size: 12px; color: var(--muted); }

@media (max-width: 620px) {
  .map-note { left: 8px; right: 8px; bottom: 8px; max-width: none; }
}
.map-bubble-dot { padding: 2px 7px; font-size: 12px; font-weight: 640; color: var(--muted); }

/* ------------------------------------------------------------- split: list + map */

/*
 * List on the left, map on the right, one choice lit on both.
 *
 * The header stays put and the two columns scroll independently — the cards in their
 * own overflow, the map not at all. Only wide windows get this: at 900px a column of
 * cards beside a map is two things too narrow to read, so below that the toggle keeps
 * showing one at a time.
 */
body.map-mode.split main {
  display: grid;
  /* Placed by name rather than by document order: the map comes first in the markup
     (it is built empty and hidden, before the cards exist), and left to itself the
     grid would put it on the left. */
  /*
   * A band, not a share of the window. At 30vw the same card was 312px wide on a
   * laptop and 740 on a big monitor — one cramped, the other a poster — and the size
   * changing with the window is what reads as "the cards keep shrinking". The column
   * now settles between 360 and 480, and the map takes whatever is left.
   */
  grid-template-columns: clamp(360px, 30vw, 480px) 1fr;
  grid-template-rows: 1fr auto;
  height: calc(100dvh - var(--topbar-h, 120px));
  overflow: hidden;
}
body.map-mode.split .map-wrap { grid-column: 2; grid-row: 1 / -1; }
body.map-mode.split .cards {
  grid-column: 1;
  grid-row: 1;
  /* Both of these come from the full-width listing, and both have to go here. An auto
     margin turns off a grid item's stretch — the column then shrank to its content and
     sat centred in its own track, which is why the cards looked a different size from
     one window to the next. */
  margin: 0;
  max-width: none;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 14px;
  scrollbar-width: thin;
}
body.map-mode.split .map-wrap { height: 100%; }
body.map-mode.split .pager[hidden] { display: none; }

.pager {
  grid-column: 1;
  grid-row: 2;
  margin: 0;
  padding: 8px 14px 12px;
  border-top: 1px solid var(--line);
}

/* Squatter photographs in the column: at 1:1 barely two cards fit beside the map, and
   the list stops being a list. */
body.map-mode.split .shot-wrap { aspect-ratio: 4 / 3; }

/*
 * The panel: one villa where the list was.
 *
 * It borrows `.cards` so the card inside it is laid out, sized and lazily loaded by
 * exactly the same rules — it is the same card, not a copy that will drift.
 */
body.map-mode.split .picked {
  grid-column: 1;
  grid-row: 1 / -1;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  margin: 0;
  max-width: none;
  padding: 14px;
  overflow-y: auto;
  overscroll-behavior: contain;
  align-content: start;
}
.picked[hidden] { display: none; }
.picked-bar { display: flex; }
/* Only the link: the heart lives on the card just above, and one villa with two
   hearts on one screen is two things to keep in step for no gain. */
.picked-facts .icon-actions { justify-content: flex-end; margin-bottom: 8px; }
/* Narrower than the window's: the column is 360–480px wide and a fixed term column
   would leave the values nowhere to go. */
.picked-facts { --term-col: auto; --facts-gap: 6px 14px; --facts-size: 14px; }
.picked-facts .facts { margin-bottom: 12px; }

/* Beside a map, a card is also a pointer at a pin: it says so on hover. */
body.map-mode.split .card { cursor: pointer; }
body.map-mode.split .card:hover { border-color: var(--muted); }

/*
 * The chosen one, on the list side.
 *
 * An outline rather than a fill: the card is mostly photograph, and a tinted card
 * changes what the photograph looks like — which is the one thing on it that has to
 * stay honest.
 */
.card.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft), var(--shadow-lift);
}

/* And on the map side. Bigger, lifted, and never a bare dot. */
.map-pin-on {
  background: var(--ink) !important;
  color: var(--bg) !important;
  border-color: var(--ink) !important;
  font-weight: 700;
  transform: translate(-50%, -100%) scale(1.12);
  box-shadow: 0 2px 10px rgba(0, 0, 0, .45);
}
