/* =========================================================
   ARCHITECT ATLAS — black & white, like a good set of drawings.
   The only color on the page comes from building imagery.
   ========================================================= */

/* ---------- Fonts ----------
   Body: ISOCPEUR. If it is installed on the visitor's computer (it ships with
   AutoCAD) it is used directly. Otherwise drop isocpeur.woff2 / isocpeur.ttf
   into /fonts. Until then, Osifont (an open ISO 3098 lettering font, LGPL with
   font exception) stands in so the look stays consistent. */
@font-face {
  font-family: "ISOCPEUR";
  src: local("ISOCPEUR"), local("isocpeur"),
       url("../fonts/isocpeur.woff2") format("woff2"),
       url("../fonts/isocpeur.ttf") format("truetype");
  font-display: swap;
}
@font-face {
  font-family: "Osifont";
  src: url("../fonts/osifont-lgpl3fe.woff") format("woff"),
       url("../fonts/osifont-lgpl3fe.ttf") format("truetype");
  font-display: swap;
}

:root {
  --ink: #000;
  --paper: #fff;
  --g1: #f4f4f4;
  --g2: #e6e6e6;
  --g3: #bdbdbd;
  --g4: #6f6f6f;
  --g5: #3d3d3d;
  --line: 1px solid var(--ink);
  --hair: 1px solid var(--g2);

  --head: "Montserrat", "Helvetica Neue", Arial, sans-serif;
  --body: "ISOCPEUR", "Osifont", "Arial Narrow", Arial, sans-serif;

  --ad-h: 106px;
  --top-h: 60px;
  --panel-w: 448px;
  --drawer-w: 360px;
  --radius: 2px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  display: grid;
  grid-template-rows: var(--ad-h) var(--top-h) 1fr;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}
h1, h2, h3, .btn, .brand-word { font-family: var(--head); font-weight: 700; }
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
a { color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

/* ---------- Ads ---------- */
.ad-bar {
  display: flex; align-items: center; justify-content: center;
  border-bottom: var(--hair);
  background: var(--paper);
  padding: 8px 16px;
  overflow: hidden;
}
.ad-slot { width: 728px; max-width: 100%; height: 90px; }
.ad-placeholder {
  height: 100%;
  display: flex; align-items: center; justify-content: center; gap: 14px;
  border: 1px solid var(--g3);
  background: repeating-linear-gradient(45deg, transparent 0 7px, var(--g2) 7px 8px); /* architectural hatch */
  font-family: var(--body); text-transform: uppercase; letter-spacing: .14em;
  font-size: 12px; color: var(--g4);
}
.ad-placeholder span { background: var(--paper); padding: 2px 8px; }
.panel-ad { margin: 8px auto 0; padding: 18px 22px calc(26px + var(--safe-b)); border-top: var(--hair); display: flex; justify-content: center; }
.ad-rect { width: 300px; max-width: 100%; height: 250px; flex-direction: column; gap: 6px; }

/* ---------- Top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 0 20px;
  border-bottom: var(--line);
  background: var(--paper);
  position: relative; z-index: 30;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; flex-shrink: 0; }
.brand-mark { width: 28px; height: 28px; }
.brand-word { font-weight: 800; letter-spacing: .22em; font-size: 15px; white-space: nowrap; }

.search { position: relative; flex: 1; max-width: 520px; margin-left: auto; min-width: 0; }
.search > svg { position: absolute; left: 12px; top: 50%; width: 16px; height: 16px; transform: translateY(-50%); color: var(--g4); pointer-events: none; }
.search input {
  width: 100%; height: 40px;
  padding: 0 112px 0 36px;
  border: var(--line); border-radius: var(--radius);
  background: var(--paper); color: var(--ink);
  font-family: var(--body); font-size: 16px;
  outline: none; -webkit-appearance: none; appearance: none;
}
.search input:focus { box-shadow: 0 0 0 3px rgba(0,0,0,.12); }
.search input::-webkit-search-cancel-button { filter: grayscale(1) brightness(0); opacity: .5; cursor: pointer; }
.search-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 40;
  padding: 4px 0;
  background: var(--paper); border: var(--line);
  box-shadow: 0 12px 32px rgba(0,0,0,.14);
  max-height: 64vh; overflow: auto; overscroll-behavior: contain;
}
.sr-group { padding: 10px 14px 4px; font-size: 10.5px; letter-spacing: .16em; text-transform: uppercase; color: var(--g4); }
.sr-item { padding: 9px 14px; cursor: pointer; display: grid; gap: 1px; }
.sr-item[aria-selected="true"], .sr-item:hover { background: var(--ink); color: var(--paper); }
.sr-name { font-family: var(--head); font-weight: 700; font-size: 14px; }
.sr-meta { font-size: 13px; opacity: .7; }
.sr-empty { padding: 12px 14px; color: var(--g4); }
.sr-foot { padding: 8px 14px 6px; margin-top: 4px; border-top: var(--hair); font-size: 12px; color: var(--g4); }

.filter-btn {
  position: absolute; right: 4px; top: 4px; bottom: 4px;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 0 10px; border: 0; border-left: var(--hair); background: var(--paper);
  font-family: var(--head); font-weight: 700; font-size: 11px; letter-spacing: .1em; text-transform: uppercase;
}
.filter-btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.filter-btn:hover, .filter-btn[aria-expanded="true"], .filter-btn.is-active { background: var(--ink); color: var(--paper); }
.filter-count {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--paper); color: var(--ink); font-size: 10px; line-height: 18px; text-align: center; letter-spacing: 0;
}

.top-actions { display: flex; align-items: center; gap: 6px; position: relative; flex-shrink: 0; }
.icon-btn {
  display: inline-flex; align-items: center; gap: 7px;
  height: 40px; padding: 0 10px; border: 1px solid transparent; border-radius: var(--radius); background: none;
  font-family: var(--head); font-weight: 700; font-size: 11px; letter-spacing: .1em; text-transform: uppercase;
}
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn:hover { border-color: var(--ink); }
.avatar {
  width: 28px; height: 28px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--head); font-weight: 800; font-size: 13px;
}
.avatar svg { width: 24px; height: 24px; }
.avatar.is-in { background: var(--ink); color: var(--paper); }

.menu {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 45;
  min-width: 240px; background: var(--paper); border: var(--line);
  box-shadow: 0 14px 34px rgba(0,0,0,.18); padding: 6px 0;
}
.menu-who { padding: 10px 16px 10px; border-bottom: var(--hair); margin-bottom: 4px; }
.menu-who strong { display: block; font-family: var(--head); font-size: 14px; }
.menu-who span { font-size: 13px; color: var(--g4); overflow-wrap: anywhere; }
.menu button {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 12px 16px; border: 0; background: none; font-size: 15px;
}
.menu button:hover { background: var(--ink); color: var(--paper); }
.menu-note { padding: 8px 16px 6px; font-size: 12px; color: var(--g4); border-top: var(--hair); margin-top: 4px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px;
  border: var(--line); border-radius: var(--radius);
  background: var(--ink); color: var(--paper);
  font-size: 12px; letter-spacing: .12em; text-transform: uppercase;
  transition: background .15s, color .15s, transform .15s;
  white-space: nowrap; text-decoration: none;
}
.btn:hover { background: var(--g5); }
.btn:active { transform: translateY(1px); }
.btn-outline { background: var(--paper); color: var(--ink); }
.btn-outline:hover { background: var(--ink); color: var(--paper); }
.btn-light { background: var(--paper); color: var(--ink); border-color: var(--paper); }
.btn-light:hover { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.btn-small { height: 34px; padding: 0 14px; font-size: 11px; }
.btn-block { width: 100%; height: 46px; }
.btn-add span[aria-hidden] { font-size: 18px; line-height: 0; }
.btn-google svg { width: 18px; height: 18px; }
.btn-text {
  background: none; border: 0; padding: 6px 0;
  font-family: var(--body); font-size: 13px; letter-spacing: .08em; text-transform: uppercase;
  text-decoration: underline; text-underline-offset: 3px; color: var(--g5);
}
.btn-text:hover { color: var(--ink); }
.btn[disabled] { opacity: .35; pointer-events: none; }
.round-close {
  width: 34px; height: 34px; flex-shrink: 0; border-radius: 50%; border: 0;
  background: var(--ink); color: var(--paper);
  display: inline-flex; align-items: center; justify-content: center;
}
.round-close svg { width: 14px; height: 14px; }
.back-btn { width: 34px; height: 34px; border: 0; background: none; display: inline-flex; align-items: center; justify-content: center; margin-left: -8px; }
.back-btn svg { width: 20px; height: 20px; }

/* ---------- Map stage ---------- */
.stage { position: relative; overflow: hidden; }
.map { position: absolute; inset: 0; background: var(--g1); z-index: 0; isolation: isolate; }
.maplibregl-map { font-family: var(--body); }
.maplibregl-ctrl-attrib { font-family: var(--body); font-size: 10px; color: var(--g4); }
.maplibregl-ctrl-attrib a { color: var(--g5); }
.maplibregl-ctrl-bottom-right { right: 62px; }
.maplibregl-ctrl-attrib.maplibregl-compact { background: rgba(255,255,255,.9); }

.map-legend {
  position: absolute; left: 16px; bottom: 16px; z-index: 10;
  display: grid; gap: 2px; justify-items: start;
  background: var(--paper); border: var(--line);
  padding: 8px 12px;
  font-size: 12px; letter-spacing: .1em; text-transform: uppercase;
  transition: left .45s var(--ease);
}
.legend-hint { color: var(--g4); }
.legend-clear {
  border: 0; background: none; padding: 2px 0 0; font-size: 12px; letter-spacing: .1em; text-transform: uppercase;
  text-decoration: underline; text-underline-offset: 3px;
}

.zoom-ctrl {
  position: absolute; right: 16px; bottom: 16px; z-index: 10;
  display: grid; border: var(--line); background: var(--paper);
}
.zoom-ctrl button {
  width: 40px; height: 40px; border: 0; background: var(--paper);
  font-family: var(--head); font-weight: 700; font-size: 18px;
}
.zoom-ctrl button + button { border-top: var(--line); }
.zoom-ctrl button:hover { background: var(--ink); color: var(--paper); }
.zoom-ctrl .zc-3d { font-size: 12px; letter-spacing: .06em; }
.zoom-ctrl .zc-3d[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.zoom-ctrl, .maplibregl-ctrl-bottom-right { transition: right .45s var(--ease); }
.panel.is-open ~ .zoom-ctrl { right: calc(var(--panel-w) + 32px); }
.stage:has(.panel.is-open) .maplibregl-ctrl-bottom-right { right: calc(var(--panel-w) + 78px); }

/* ---------- Markers ---------- */
.mk {
  position: absolute; left: 0; top: 0; color: inherit; text-decoration: none;
  width: 0; height: 0;
  cursor: pointer;
  z-index: 1;
}
.mk:hover, .mk.is-active { z-index: 1000; }
.mk-inner {
  position: absolute; left: 0; bottom: 0;
  transform: translate(-50%, 0);
  display: flex; flex-direction: column; align-items: center;
  animation: mk-in .35s var(--ease) both;
  transform-origin: 50% 100%;
}
.mk.is-leaving .mk-inner { animation: mk-out .2s ease-in both; }
@keyframes mk-in { from { opacity: 0; transform: translate(-50%, 6px) scale(.55); } to { opacity: 1; transform: translate(-50%, 0) scale(1); } }
@keyframes mk-out { to { opacity: 0; transform: translate(-50%, 4px) scale(.6); } }

.mk-badge {
  --s: 40px;
  width: var(--s); height: var(--s);
  border-radius: 50%;
  background: var(--ink) center / cover no-repeat;
  border: 2px solid var(--ink);
  box-shadow: 0 0 0 2px var(--paper), 0 4px 12px rgba(0,0,0,.35);
  display: flex; align-items: center; justify-content: center;
  color: var(--paper); font-family: var(--head); font-weight: 800; font-size: 15px;
  transition: transform .18s var(--ease), box-shadow .18s;
  overflow: hidden;
}
.mk--lg .mk-badge { --s: 52px; font-size: 18px; }
.mk--sm .mk-badge { --s: 32px; font-size: 12px; }
.mk-badge.has-img { color: transparent; }
.mk-badge.is-custom { background-color: var(--paper); background-size: 78%; }
.mk-stem { width: 2px; height: 9px; background: var(--ink); }
.mk-dot  { width: 6px; height: 6px; border-radius: 50%; background: var(--ink); box-shadow: 0 0 0 2px var(--paper); margin-bottom: -3px; }
.mk:hover .mk-badge { transform: scale(1.1); }
.mk.is-active .mk-badge { box-shadow: 0 0 0 2px var(--paper), 0 0 0 5px var(--ink), 0 6px 16px rgba(0,0,0,.4); transform: scale(1.12); }
/* Demolished: a dashed ring and a faded, grey photo */
.mk.is-lost .mk-badge { border-style: dashed; border-color: var(--paper); box-shadow: 0 0 0 2px var(--ink), 0 4px 12px rgba(0,0,0,.25); filter: grayscale(1) contrast(.9); opacity: .9; }
.mk.is-lost .mk-stem { background: repeating-linear-gradient(var(--ink) 0 2px, transparent 2px 4px); }

.mk-label {
  position: absolute; bottom: calc(100% + 8px); left: 50%;
  transform: translateX(-50%) translateY(4px);
  background: var(--ink); color: var(--paper);
  font-family: var(--head); font-weight: 700; font-size: 11px; letter-spacing: .06em; text-transform: uppercase;
  padding: 5px 9px; white-space: nowrap;
  opacity: 0; pointer-events: none;
  transition: opacity .15s, transform .15s;
}
@media (hover: hover) { .mk:hover .mk-label { opacity: 1; transform: translateX(-50%) translateY(0); } }
.mk:focus-visible .mk-label { opacity: 1; transform: translateX(-50%) translateY(0); }
.mk:focus-visible { outline: none; }
.mk:focus-visible .mk-badge { box-shadow: 0 0 0 2px var(--paper), 0 0 0 5px var(--ink); }

/* ---------- Drawers (filters and lists) ---------- */
.drawer {
  position: absolute; z-index: 22; top: 16px; left: 16px; bottom: 16px;
  width: var(--drawer-w); max-width: calc(100% - 32px);
  background: var(--paper); border: var(--line);
  box-shadow: 0 18px 50px rgba(0,0,0,.18);
  display: flex; flex-direction: column;
  transform: translateX(calc(-100% - 40px));
  transition: transform .45s var(--ease), visibility 0s .45s;
  visibility: hidden;
}
.drawer.is-open { transform: none; visibility: visible; transition: transform .45s var(--ease), visibility 0s; }
.stage:has(.drawer.is-open) .map-legend { left: calc(var(--drawer-w) + 32px); }
.drawer-head { display: flex; align-items: center; gap: 12px; padding: 12px 14px 12px 20px; border-bottom: var(--line); min-height: 58px; }
.drawer-head h2 { margin: 0; font-size: 16px; letter-spacing: .04em; margin-right: auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drawer-scroll { overflow-y: auto; overscroll-behavior: contain; flex: 1; -webkit-overflow-scrolling: touch; }
.drawer-foot { padding: 12px 16px calc(12px + var(--safe-b)); border-top: var(--hair); display: none; }

.filters { padding: 16px 20px 6px; display: grid; gap: 18px; }
.filters fieldset, fieldset.field { border: 0; margin: 0; padding: 0; min-width: 0; }
.filters legend, fieldset.field legend { padding: 0; margin-bottom: 8px; font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--g4); }
.chip-set { display: flex; flex-wrap: wrap; gap: 7px; }
.chip-toggle {
  min-height: 36px; padding: 6px 13px; border: var(--line); border-radius: 99px; background: var(--paper);
  font-family: var(--body); font-size: 15px; letter-spacing: .02em;
}
@media (hover: hover) { .chip-toggle:hover { background: var(--g1); } }
.chip-toggle[aria-pressed="true"] { background: var(--ink); color: var(--paper); }

.year-readout { display: flex; gap: 8px; align-items: baseline; font-size: 15px; }
.year-readout output { font-family: var(--head); font-weight: 700; font-size: 14px; }
.year-readout span { color: var(--g4); font-size: 13px; }
.range2 { position: relative; height: 34px; margin-top: 2px; }
.range2-track { position: absolute; left: 11px; right: 11px; top: 16px; height: 2px; background: var(--g2); }
.range2-fill { position: absolute; top: 0; bottom: 0; background: var(--ink); }
.range2 input[type=range] {
  position: absolute; inset: 0; width: 100%; margin: 0; background: none;
  -webkit-appearance: none; appearance: none; pointer-events: none;
}
.range2 input[type=range]::-webkit-slider-runnable-track { height: 34px; background: none; }
.range2 input[type=range]::-moz-range-track { height: 34px; background: none; }
.range2 input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; pointer-events: auto; cursor: grab;
  width: 22px; height: 22px; margin-top: 6px; border-radius: 50%;
  background: var(--paper); border: 2px solid var(--ink); box-shadow: 0 1px 4px rgba(0,0,0,.25);
}
.range2 input[type=range]::-moz-range-thumb {
  pointer-events: auto; cursor: grab; width: 18px; height: 18px; border-radius: 50%;
  background: var(--paper); border: 2px solid var(--ink);
}
.range2-ticks { position: relative; height: 14px; margin: 0 11px; font-size: 10.5px; color: var(--g4); letter-spacing: .04em; }
.range2-ticks span { position: absolute; top: 0; transform: translateX(-50%); white-space: nowrap; }
.range2-ticks span:first-child { transform: none; left: -11px !important; }
.range2-ticks span:last-child { transform: none; left: auto !important; right: -11px; }
#lostHint { margin-top: 8px; }
select { font-family: var(--body); }

.results-head { padding: 14px 20px 8px; border-top: var(--hair); margin-top: 14px; font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--g4); }
.results { list-style: none; margin: 0; padding: 0 8px 16px; }
.result { display: flex; gap: 12px; align-items: center; padding: 9px 12px; text-decoration: none; color: var(--ink); min-height: 60px; }
@media (hover: hover) { .result:hover { background: var(--ink); color: var(--paper); } }
.result:active { background: var(--g1); }
.result-thumb {
  flex: 0 0 44px; height: 44px; border-radius: 50%;
  background: var(--ink) center / cover no-repeat; border: 2px solid var(--ink);
  color: var(--paper); display: flex; align-items: center; justify-content: center;
  font-family: var(--head); font-weight: 800;
}
.result-text { display: grid; min-width: 0; flex: 1; }
.result-name { font-family: var(--head); font-weight: 700; font-size: 14px; }
.result-meta { font-size: 13px; opacity: .7; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.results-empty { padding: 12px; color: var(--g4); }
.result-row { display: flex; align-items: center; }
.result-row .result { flex: 1; min-width: 0; }
.row-remove { flex: 0 0 40px; height: 40px; border: 0; background: none; color: var(--g4); font-size: 22px; line-height: 1; }
.row-remove:hover { color: var(--ink); }

/* Lists */
.lists-intro { padding: 16px 20px 4px; font-size: 14px; color: var(--g5); }
.list-rows { list-style: none; margin: 0; padding: 8px; }
.list-row {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 12px; border: 0; background: none; min-height: 56px;
}
@media (hover: hover) { .list-row:hover { background: var(--g1); } }
.list-icon { flex: 0 0 36px; height: 36px; border: var(--line); border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; }
.list-icon svg { width: 18px; height: 18px; }
.list-icon .ic-heart path { fill: var(--ink); }
.list-name { font-family: var(--head); font-weight: 700; font-size: 15px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-count { font-size: 12px; line-height: 1; color: var(--g5); border: var(--hair); border-radius: 99px; padding: 5px 9px 4px; min-width: 28px; text-align: center; }
.new-list-row { display: flex; gap: 10px; align-items: center; padding: 8px 20px 18px; }
.new-list-row input {
  flex: 1; min-width: 0; height: 40px; border: 0; border-bottom: var(--line); font-family: var(--body); font-size: 16px; outline: none; background: none;
}
.list-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 14px 20px; border-bottom: var(--hair); }
.seg { display: inline-flex; border: var(--line); border-radius: var(--radius); overflow: hidden; }
.seg button { border: 0; background: var(--paper); padding: 0 14px; height: 36px; font-family: var(--head); font-weight: 700; font-size: 11px; letter-spacing: .1em; text-transform: uppercase; }
.seg button + button { border-left: var(--line); }
.seg button[aria-selected="true"], .seg button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.list-tools .btn-text { margin-left: auto; }

/* Save-to-list picker */
.pick-name { margin: 16px 22px 4px; font-family: var(--head); font-weight: 700; font-size: 15px; }
.pick-list { list-style: none; margin: 0; padding: 6px 12px; }
.pick-list label { display: flex; align-items: center; gap: 12px; padding: 10px; min-height: 48px; cursor: pointer; font-size: 16px; }
.pick-list input { width: 20px; height: 20px; accent-color: #000; }
.pick-list .ic-heart { width: 16px; height: 16px; }
.pick-list .ic-heart path { fill: var(--ink); }

/* ---------- Add-building search ---------- */
.find-row { display: flex; gap: 14px; align-items: flex-start; }
.find-row .btn { flex-shrink: 0; }
.candidates { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.cand-note { font-size: 14px; color: var(--g5); }
.cand {
  width: 100%; display: flex; gap: 12px; align-items: center; text-align: left;
  padding: 8px 10px; border: var(--line); background: var(--paper); min-height: 56px;
}
.cand:hover:not([disabled]), .cand.is-picked { background: var(--ink); color: var(--paper); }
.cand[disabled] { opacity: .45; cursor: not-allowed; border-style: dashed; }
.cand-thumb { flex: 0 0 40px; height: 40px; border-radius: 50%; background: var(--g2) center / cover no-repeat; }
.cand-text { display: grid; min-width: 0; }
.cand-title { font-family: var(--head); font-weight: 700; font-size: 14px; }
.cand-desc { font-size: 13px; opacity: .75; }
.style-trio { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }

/* ---------- Building panel ---------- */
.panel {
  position: absolute; z-index: 20;
  top: 16px; right: 16px; bottom: 16px;
  width: var(--panel-w); max-width: calc(100% - 32px);
  background: var(--paper);
  border: var(--line);
  box-shadow: 0 18px 50px rgba(0,0,0,.22);
  transform: translateX(calc(100% + 40px));
  transition: transform .45s var(--ease), visibility 0s .45s;
  visibility: hidden;
  display: flex; flex-direction: column;
}
.panel.is-open { transform: none; visibility: visible; transition: transform .45s var(--ease), visibility 0s; }
.panel-scroll { overflow-y: auto; overscroll-behavior: contain; flex: 1; -webkit-overflow-scrolling: touch; }
.sheet-grip { display: none; }
.panel-close {
  position: absolute; top: 12px; right: 12px; z-index: 5;
  width: 36px; height: 36px; border-radius: 50%;
  border: 0; background: rgba(0,0,0,.55); color: var(--paper);
  display: flex; align-items: center; justify-content: center;
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.panel-close svg { width: 14px; height: 14px; }
.panel-close:hover { background: var(--ink); }
/* Once the photo scrolls away, a slim bar keeps the name in view and keeps text clear of the close button. */
.panel-mini {
  position: absolute; top: 0; left: 0; right: 0; z-index: 4; height: 60px;
  display: flex; align-items: center; padding: 0 60px 0 22px;
  background: var(--paper); border-bottom: var(--hair);
  font-family: var(--head); font-weight: 700; font-size: 16px;
  opacity: 0; transform: translateY(-6px); pointer-events: none;
  transition: opacity .18s, transform .18s;
}
.panel-mini span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.panel.is-scrolled .panel-mini { opacity: 1; transform: none; pointer-events: auto; }
.panel.is-scrolled .panel-close { background: var(--ink); }

.hero { position: relative; margin: 0; height: 340px; background: var(--ink); overflow: hidden; }
.hero img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; display: block;
  opacity: 0; transition: opacity .5s ease;
}
.hero img.is-loaded { opacity: 1; }
.hero.is-lost img { filter: grayscale(1); }
.hero-shade {
  position: absolute; inset: 0; pointer-events: none;
  background:
    linear-gradient(160deg, rgba(0,0,0,.55) 0%, rgba(0,0,0,0) 45%),
    linear-gradient(0deg, rgba(0,0,0,.55) 0%, rgba(0,0,0,0) 30%);
}
.hero-title {
  position: absolute; top: 22px; left: 22px; right: 64px;
  color: var(--paper);
  text-shadow: 0 2px 14px rgba(0,0,0,.6), 0 1px 2px rgba(0,0,0,.7);
}
.hero-title h1 { margin: 0; font-weight: 800; font-size: 30px; line-height: 1.05; letter-spacing: -.01em; text-wrap: balance; }
.hero-architect { margin: 10px 0 0; font-size: 17px; letter-spacing: .02em; }
.hero-firm { margin: 3px 0 0; font-size: 12px; letter-spacing: .14em; text-transform: uppercase; opacity: .92; }
.hero-coords {
  position: absolute; left: 14px; bottom: 14px;
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px;
  background: none; border: 0; padding: 4px 6px;
  color: var(--paper); font-family: var(--body); font-size: 12px; letter-spacing: .08em;
  text-shadow: 0 1px 6px rgba(0,0,0,.8);
}
.hero-coords svg { width: 12px; height: 12px; opacity: .85; }
.hero-coords:hover { text-decoration: underline; text-underline-offset: 3px; }
.hero-directions { position: absolute; right: 16px; bottom: 16px; }
.directions-menu {
  position: absolute; right: 0; bottom: calc(100% + 8px);
  min-width: 210px; background: var(--paper); border: var(--line);
  box-shadow: 0 12px 28px rgba(0,0,0,.25); display: grid; z-index: 3;
}
.hero { overflow: visible; }
.hero > img, .hero-shade { border-radius: inherit; }
.directions-menu a {
  padding: 13px 14px; text-decoration: none;
  font-family: var(--head); font-weight: 700; font-size: 12px; letter-spacing: .08em; text-transform: uppercase;
}
.directions-menu a + a { border-top: var(--hair); }
.directions-menu a:hover { background: var(--ink); color: var(--paper); }
.hero-credit {
  margin: 4px 10px 0; min-height: 14px;
  font-size: 10px; color: var(--g4); letter-spacing: .04em;
  text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.panel-actions { display: grid; grid-template-columns: repeat(3, 1fr); margin: 12px 22px 0; border: var(--line); }
.pa-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 46px; border: 0; background: var(--paper);
  font-family: var(--head); font-weight: 700; font-size: 11px; letter-spacing: .1em; text-transform: uppercase;
}
.pa-btn + .pa-btn { border-left: var(--line); }
.pa-btn svg { width: 19px; height: 19px; flex-shrink: 0; }
.ic-heart path { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; transition: fill .2s; }
.pa-fav[aria-pressed="true"] .ic-heart path { fill: currentColor; }
.pa-fav.pop .ic-heart { animation: pop .35s var(--ease); }
@keyframes pop { 40% { transform: scale(1.35); } }
@media (hover: hover) { .pa-btn:hover { background: var(--g1); } }

.stats {
  margin: 14px 22px 0;
  display: grid; grid-template-columns: 1fr 1fr;
  border-top: var(--line); border-left: var(--line);
}
.stat { border-right: var(--line); border-bottom: var(--line); padding: 10px 12px 11px; min-width: 0; }
.stat dt { font-size: 10.5px; letter-spacing: .16em; text-transform: uppercase; color: var(--g4); margin-bottom: 4px; }
.stat dd { margin: 0; font-size: 16px; line-height: 1.25; overflow-wrap: anywhere; }
.stat dd .muted, .muted { color: var(--g3); }
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip {
  display: inline-block; padding: 3px 10px; border: var(--line); border-radius: 99px;
  font-size: 13px; letter-spacing: .03em; text-decoration: none; color: var(--ink); background: var(--paper);
  transition: background .15s, color .15s;
}
a.chip:hover { background: var(--ink); color: var(--paper); }
.access-pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border: var(--line); border-radius: 99px;
  font-size: 13px; letter-spacing: .06em; text-transform: uppercase; text-decoration: none;
}
.access-pill.is-private { border-color: var(--g3); color: var(--g4); }
a.access-pill { background: var(--ink); color: var(--paper); }
a.access-pill:hover { background: var(--g5); }

.body-text { margin: 20px 22px 0; font-size: 16.5px; line-height: 1.6; }
.body-text p { margin: 0 0 .9em; }
.body-text .pending-note { font-size: 13px; color: var(--g5); border-left: 2px solid var(--ink); padding-left: 10px; }

/* Comments */
.comments { margin: 10px 22px 0; padding-top: 16px; border-top: var(--line); }
.comments-title { margin: 0 0 10px; font-size: 13px; letter-spacing: .14em; text-transform: uppercase; }
.comments-count { color: var(--g4); font-weight: 500; }
.comment-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.comment-empty { color: var(--g4); font-size: 14px; }
.comment-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; font-size: 12px; color: var(--g4); letter-spacing: .04em; }
.comment-head strong { font-family: var(--head); font-size: 13px; color: var(--ink); letter-spacing: 0; }
.comment-body { margin: 3px 0 0; font-size: 15.5px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.tag { display: inline-block; padding: 1px 7px; border: 1px solid var(--g3); border-radius: 99px; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--g4); }
.comment-del { border: 0; background: none; padding: 0; font-size: 12px; color: var(--g4); text-decoration: underline; margin-left: auto; }
.comment-form { margin-top: 14px; }
.comment-form textarea {
  width: 100%; border: var(--line); border-radius: 0; padding: 10px 12px; resize: vertical; min-height: 48px;
  font-family: var(--body); font-size: 16px; line-height: 1.45; background: var(--paper); color: var(--ink); outline: none;
}
.comment-form textarea:focus { box-shadow: 0 0 0 2px var(--ink) inset; }
.comment-form-foot { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.comment-hint { font-size: 12px; color: var(--g4); flex: 1; line-height: 1.35; }
.comment-count-chars { font-size: 12px; color: var(--g4); }

.panel-foot { display: flex; justify-content: flex-end; align-items: center; gap: 12px; margin: 18px 22px 0; padding-top: 10px; border-top: var(--hair); }

/* ---------- Dialogs and forms ---------- */
.dialog {
  width: min(640px, calc(100vw - 24px));
  max-height: calc(100dvh - 40px);
  padding: 0; border: var(--line); border-radius: var(--radius);
  box-shadow: 0 30px 80px rgba(0,0,0,.35);
  color: var(--ink); background: var(--paper);
}
.dialog-small { width: min(440px, calc(100vw - 24px)); }
.dialog::backdrop { background: rgba(0,0,0,.45); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); }
.dialog form { display: flex; flex-direction: column; max-height: inherit; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px 14px 22px; border-bottom: var(--line); }
.dialog-head h2 { margin: 0; font-size: 18px; letter-spacing: .02em; }
.dialog-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.fields, .wiki-check { border: 0; margin: 0; padding: 18px 22px 0; display: grid; gap: 16px; min-width: 0; }
.fields[disabled] { opacity: .35; }
.field { display: grid; gap: 5px; min-width: 0; }
.field > span { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--g4); }
.field em { font-style: normal; text-transform: none; letter-spacing: 0; }
.field input, .field select, .field textarea {
  width: 100%; min-height: 40px;
  border: 0; border-bottom: var(--line); border-radius: 0;
  padding: 7px 0; background: transparent; color: var(--ink);
  font-family: var(--body); font-size: 16px; outline: none;
  -webkit-appearance: none; appearance: none;
}
.field select {
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M5 8l5 5 5-5' fill='none' stroke='black' stroke-width='1.6'/%3E%3C/svg%3E") right 2px center / 16px no-repeat;
  padding-right: 24px;
}
.field textarea { border: var(--line); padding: 10px; resize: vertical; line-height: 1.5; }
.field input:focus, .field select:focus { border-bottom-width: 2px; padding-bottom: 6px; }
.field textarea:focus { box-shadow: 0 0 0 2px var(--ink) inset; }
.field-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.hint { margin: 0; font-size: 13px; color: var(--g4); line-height: 1.45; }
.review-hint { padding: 14px 22px 18px; }
.checklist { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 14px; }
.checklist li { display: flex; gap: 8px; align-items: baseline; }
.checklist li::before { content: "○"; font-family: var(--head); }
.checklist li.ok::before { content: "●"; }
.checklist li.fail { text-decoration: line-through; text-decoration-thickness: 1px; }
.checklist li.fail::before { content: "×"; text-decoration: none; display: inline-block; }
.checklist li.note { color: var(--g4); }
.checklist li.note::before { content: "—"; }
.dialog-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 22px calc(14px + var(--safe-b)); border-top: var(--hair); }

/* Sign in */
.auth-body { padding: 18px 22px 22px; display: grid; gap: 14px; }
.auth-reason { margin: 0; font-size: 15px; line-height: 1.45; }
.auth-reason:empty { display: none; }
.or { display: flex; align-items: center; gap: 12px; color: var(--g4); font-size: 12px; letter-spacing: .14em; text-transform: uppercase; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--g2); }
.auth-body .seg { width: 100%; }
.auth-body .seg button { flex: 1; height: 40px; }
.form-error { margin: 0; font-size: 14px; border-left: 2px solid var(--ink); padding-left: 10px; }
.forgot { justify-self: center; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(28px + var(--safe-b)); z-index: 100;
  transform: translate(-50%, 20px); opacity: 0;
  background: var(--ink); color: var(--paper);
  padding: 11px 16px; font-size: 14px; letter-spacing: .03em; line-height: 1.35;
  width: max-content; max-width: calc(100vw - 32px); text-align: center;
  transition: opacity .2s, transform .25s var(--ease);
  pointer-events: none;
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* =========================================================
   PHONES
   ========================================================= */
@media (max-width: 760px) {
  :root { --ad-h: 58px; --top-h: 56px; }
  .ad-bar { padding: 4px 12px; }
  .ad-slot { width: 320px; height: 50px; }
  .ad-size { display: none; }

  .topbar { gap: 8px; padding: 0 10px 0 12px; }
  .brand-word { display: none; }
  .brand-mark { width: 30px; height: 30px; }
  .search input { height: 40px; padding-right: 46px; }
  .filter-btn { padding: 0 9px; }
  .filter-label { display: none; }
  .filter-count { position: absolute; top: -6px; right: -6px; min-width: 17px; height: 17px; line-height: 17px; background: var(--ink); color: var(--paper); box-shadow: 0 0 0 2px var(--paper); }
  .btn-add, .icon-label { display: none; }
  .top-actions { gap: 0; }
  .icon-btn { width: 40px; padding: 0; justify-content: center; }
  .icon-btn:hover { border-color: transparent; }

  /* Account menu becomes a bottom sheet */
  .menu {
    position: fixed; top: auto; left: 0; right: 0; bottom: 0; min-width: 0;
    border: 0; border-top: var(--line); border-radius: 14px 14px 0 0;
    padding: 8px 0 calc(10px + var(--safe-b)); box-shadow: 0 -12px 40px rgba(0,0,0,.25);
    animation: sheet-up .3s var(--ease);
  }
  .menu button { min-height: 52px; font-size: 16px; padding: 14px 22px; }
  .menu-who { padding: 12px 22px; }
  @keyframes sheet-up { from { transform: translateY(100%); } }

  /* Map chrome moves to the top, out of the bottom sheet's way */
  .map-legend {
    top: 10px; bottom: auto; left: 10px; max-width: calc(100% - 70px);
    padding: 6px 10px; font-size: 10.5px; gap: 1px;
  }
  .legend-hint { display: none; }
  .map-legend.is-filtered .legend-hint { display: block; }
  .stage:has(.drawer.is-open) .map-legend { left: 10px; }
  .zoom-ctrl { top: 10px; right: 10px; bottom: auto; border-radius: 50%; overflow: hidden; }
  .zoom-ctrl button:not(.zc-3d) { display: none; }
  .zoom-ctrl .zc-3d { width: 42px; height: 42px; border-top: 0 !important; }
  .panel.is-open ~ .zoom-ctrl { right: 10px; }
  .maplibregl-ctrl-bottom-right, .stage:has(.panel.is-open) .maplibregl-ctrl-bottom-right { right: 0; }

  /* Drawers fill the map area, with a big "show results" button */
  .drawer { top: 0; left: 0; bottom: 0; width: 100%; max-width: none; border: 0; box-shadow: none; transform: translateY(100%); }
  .drawer.is-open { transform: none; }
  .drawer-foot { display: block; }
  .filters { padding: 14px 16px 6px; }
  .results-head { padding: 14px 16px 8px; }
  .chip-toggle { min-height: 40px; }

  /* The building panel becomes a bottom sheet: it opens halfway ("peek"),
     swipes up to full height, and swipes down to close. */
  .panel {
    top: 10px; left: 0; right: 0; bottom: 0;
    width: 100%; max-width: none;
    border: 0; border-top: var(--line); border-radius: 14px 14px 0 0;
    box-shadow: 0 -10px 40px rgba(0,0,0,.25);
    transform: translateY(100%);
    overflow: hidden;
  }
  .panel.is-open { transform: translateY(var(--sheet-y, 0)); }
  .panel.is-open.is-peek { --sheet-y: 46%; }
  .panel.is-peek .panel-scroll { overflow: hidden; }
  .panel.is-dragging { transition: none; }
  .sheet-grip {
    display: flex; justify-content: center; align-items: center;
    position: absolute; top: 0; left: 0; right: 0; height: 22px; z-index: 6; cursor: grab;
  }
  .sheet-grip span { width: 42px; height: 5px; border-radius: 3px; background: rgba(255,255,255,.9); box-shadow: 0 0 4px rgba(0,0,0,.35); }
  .panel.is-scrolled .sheet-grip span { background: var(--g3); box-shadow: none; }
  .panel-mini { height: 66px; padding: 10px 60px 0 16px; }
  .panel-close { top: 14px; right: 12px; width: 38px; height: 38px; }
  .hero { height: 232px; }
  .hero-title { top: 22px; left: 16px; right: 60px; }
  .hero-title h1 { font-size: 24px; }
  .hero-architect { margin-top: 6px; font-size: 15px; }
  .hero-firm { font-size: 11px; }
  .hero-coords { left: 8px; bottom: 8px; font-size: 11px; }
  .hero-directions { right: 12px; bottom: 12px; }
  .hero-directions .btn { height: 36px; padding: 0 12px; font-size: 11px; }
  .panel-actions, .stats, .body-text, .comments, .panel-foot { margin-left: 16px; margin-right: 16px; }
  .panel-actions { margin-top: 10px; }
  .pa-btn { height: 48px; font-size: 10.5px; letter-spacing: .08em; gap: 6px; }
  .stat { padding: 9px 10px 10px; }
  .stat dd { font-size: 15px; }
  .body-text { font-size: 16px; line-height: 1.58; }
  .panel-ad { padding-left: 16px; padding-right: 16px; }

  /* Dialogs: small ones rise from the bottom; the long form fills the screen */
  .dialog-small {
    width: 100%; max-width: none; max-height: 92dvh;
    margin: auto 0 0; border: 0; border-top: var(--line); border-radius: 14px 14px 0 0;
    animation: sheet-up .3s var(--ease);
  }
  #formDialog { width: 100%; max-width: none; height: 100dvh; max-height: 100dvh; margin: 0; border: 0; border-radius: 0; }
  #formDialog form { height: 100%; }
  .dialog-head { padding: 12px 12px 12px 18px; }
  .fields, .wiki-check { padding: 16px 18px 0; }
  .review-hint { padding: 14px 18px 18px; }
  .dialog-foot { padding: 12px 18px calc(12px + var(--safe-b)); }
  .dialog-foot .btn { flex: 1; height: 46px; }
  .auth-body { padding: 16px 18px calc(22px + var(--safe-b)); }
  .field-pair { grid-template-columns: 1fr; }
  .style-trio { grid-template-columns: 1fr; }
  .find-row { flex-direction: column; }

  .toast { bottom: auto; top: calc(var(--ad-h) + var(--top-h) + 12px); transform: translate(-50%, -12px); }
  .toast.is-on { transform: translate(-50%, 0); }
}

/* Very small phones */
@media (max-width: 360px) {
  .pa-btn span { display: none; }
  .hero-coords { display: none; }
  .stat dd { font-size: 14px; }
}

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