/* Flatfinder viewer + modal styles */
:root {
  --ff-free: #22c55e;
  --ff-reserved: #f59e0b;
  --ff-sold: #9ca3af;
  --ff-accent: #2563eb;
  --ff-brand: #2563eb;
  --ff-secondary: #64748b;
  --ff-bg: #0f172a;
  --ff-panel: #ffffff;
  --ff-text: #0f172a;
  --ff-muted: #64748b;

  /* Unit popup — kept in step with packages/design-system/src/tokens/tokens.css
     (that package is the design source of truth until the React migration). */
  --ff-fav: #e11d48;
  --ff-border: #e2e8f0;
  --ff-chip-bg: #f1f5f9;
  --ff-chip-text: #475569;
  --ff-plan-bg: #f8fafc;
  --ff-glass-bg: rgba(255, 255, 255, 0.6);
  --ff-glass-border: rgba(255, 255, 255, 0.4);
  --ff-glass-blur: 10px;
  --ff-glass-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  /* The dark frosted panel shared by the unit popup and the gallery. */
  --ff-glass-panel-bg: rgba(15, 23, 42, 0.55);
  --ff-glass-panel-border: rgba(255, 255, 255, 0.16);
  --ff-glass-icon-bg: rgba(15, 23, 42, 0.55);
  --ff-glass-icon-blur: 6px;
  --ff-glass-icon-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  --ff-radius-sm: 3px;
  --ff-radius: 6px;
  --ff-radius-lg: 8px;
  --ff-radius-xl: 16px;
  --ff-radius-pill: 999px;
  /* One padding for every modal panel — the unit sheet, the gallery, the
     compare table, the Flats modal and its compare strip all share it. The
     panorama modal is the deliberate exception: it keeps a 1px hairline frame
     because its stage is edge-to-edge WebGL. */
  --ff-modal-pad: 16px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ff-text);
  background: #f1f5f9;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100%;
}

/* Top bar: back + breadcrumb */
.ff-topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background: var(--ff-panel);
  border-bottom: 1px solid #e2e8f0;
  flex: 0 0 auto;
}

/* TEMPORARY — the admin shortcut in the topbar (see buildAdminLink() in
   src/web/viewer.js). `margin-left: auto` is what pins it right; the breadcrumb
   keeps the rest of the row. */
.ff-admin-link {
  margin-left: auto;
  flex: 0 0 auto;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  color: var(--ff-brand, #0f172a);
  border: 1px solid #e2e8f0;
  border-radius: 999px;
  padding: 4px 12px;
  background: #fff;
}

.ff-admin-link:hover,
.ff-admin-link:focus-visible {
  border-color: currentColor;
}

.ff-breadcrumb-area {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1 1 auto;
}

/* Scene switcher: stacked icon buttons (layers + rotate) with popup menus,
   inside the frame top-right. */
.ff-scene-switcher {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 50;
  line-height: normal;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

/* Each icon + its popup menu; menu is positioned relative to its own group. */
.ff-scene-group {
  position: relative;
}

.ff-scene-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: none;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.55);
  color: #fff;
  cursor: pointer;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  transition: background 150ms ease, transform 150ms ease;
}

.ff-scene-toggle:hover {
  background: var(--ff-brand);
}

.ff-scene-toggle[aria-expanded='true'] {
  background: var(--ff-brand);
}

/* Whole-widget fullscreen toggle: top-left of the frame, mirroring the
   scene-switcher glass button on the right. Built only in embed mode and only
   when a fullscreen mechanism exists (src/web/fullscreen.js). */
.ff-fs-toggle {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 50;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: none;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.55);
  color: #fff;
  cursor: pointer;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  transition: background 150ms ease, transform 150ms ease;
}

.ff-fs-toggle:hover,
.ff-fs-toggle:focus-visible {
  background: var(--ff-brand);
}

.ff-fs-toggle svg {
  width: 20px;
  height: 20px;
  display: block;
}

.ff-scene-menu {
  position: absolute;
  /* Open to the LEFT of the icon, vertically aligned with its toggle. */
  top: 0;
  right: calc(100% + 8px);
  min-width: 180px;
  max-height: 60vh;
  overflow-y: auto;
  margin: 0;
  padding: 6px;
  list-style: none;
  /* The same dark frosted panel as every modal — background, border, radius,
     shadow, blur — so the pop-up lists off the top-right icons match. */
  color: #fff;
  background: var(--ff-glass-panel-bg);
  backdrop-filter: blur(var(--ff-glass-blur));
  -webkit-backdrop-filter: blur(var(--ff-glass-blur));
  border: 1px solid var(--ff-glass-panel-border);
  border-radius: var(--ff-radius-xl);
  box-shadow: var(--ff-glass-shadow);
}

.ff-scene-item {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  color: inherit;
  font-family: inherit;
  font-size: 14px;
  padding: 9px 12px;
  border-radius: var(--ff-radius-lg);
  cursor: pointer;
}

.ff-scene-item:hover {
  background: rgba(255, 255, 255, 0.12);
}

.ff-scene-item.is-active {
  background: var(--ff-brand);
  color: #fff;
  font-weight: 600;
}

.ff-back-btn {
  border: 1px solid #cbd5e1;
  background: #fff;
  color: var(--ff-text);
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
}

.ff-back-btn:hover:not(:disabled) {
  background: #f8fafc;
  border-color: var(--ff-accent);
}

.ff-back-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.ff-breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  flex-wrap: wrap;
}

.ff-crumb {
  background: none;
  border: none;
  color: var(--ff-accent);
  cursor: pointer;
  padding: 2px 4px;
  font-size: 14px;
}

.ff-crumb:hover {
  text-decoration: underline;
}

.ff-crumb--current {
  color: var(--ff-muted);
  cursor: default;
  font-weight: 600;
}

.ff-crumb-sep {
  color: var(--ff-muted);
}

/* Stage */
.ff-stage {
  position: relative;
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 3rem 0;
  background: var(--ff-bg);
}

.ff-stage-frame {
  position: relative;
  /* z-index (even 0) is what turns `position: relative` into a stacking
     context — without it the blurred background's negative z-index below
     could escape this frame instead of just sitting behind its content. */
  z-index: 0;
  width: 100%;
  max-width: 1280px;
  max-height: 90vh;
  border: 3px solid var(--ff-brand);
  border-radius: 30px;
  overflow: hidden;
  line-height: 0;
}

/* Blurred, scaled-up copy of the scene image, filling the frame behind
   everything else. Only visible in the gap when the sharp image (in
   .ff-stage-content) does not itself cover the frame — no measurement, pure
   CSS: when the sharp image fully covers it, this is 100% occluded. */
.ff-stage-bg {
  position: absolute;
  inset: 0;
  z-index: -1;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  filter: blur(6px) brightness(0.75);
  transform: scale(1.15);
}

.ff-stage-content {
  display: block;
  width: 100%;
}

.ff-svg {
  display: block;
  width: 100%;
  height: auto;
  max-height: 90vh;
}

/* Embed mode (/embed/<project>): size to the image's natural aspect ratio
   instead of the viewport, so the host iframe can auto-resize to content via
   postMessage. The viewport (vh) caps would otherwise collapse the widget to
   the iframe's default height. */
#app.ff-embed {
  height: auto;
}

.ff-embed .ff-stage {
  flex: 0 0 auto;
  padding: 0;
  background: transparent;
}

.ff-embed .ff-stage-frame {
  max-height: none;
  /* No 1280px cap here: the iframe itself is already sized by plano.js to
     min(host container, a share of the host viewport), so the widget should
     fill it. Capping again would leave the box stuck small inside a correctly
     sized frame. The standalone viewer keeps the 1280px cap above. */
  max-width: none;
}

.ff-embed .ff-svg {
  max-height: none;
}

/* Whole-widget fullscreen. `.ff-fs` on <html> is set for BOTH paths — the
   native Fullscreen API and the plano.js postMessage fallback (iPhone) — so
   these rules never need to spell `:fullscreen` or its prefixed variants. They
   undo the embed-mode content sizing above and fill the viewport instead. */
:root.ff-fs #app.ff-embed {
  height: 100vh;
}

:root.ff-fs .ff-embed .ff-stage {
  flex: 1 1 auto;
  padding: 2.5vh 0;
  background: var(--ff-bg);
}

:root.ff-fs .ff-embed .ff-stage-frame {
  max-height: 95vh;
  /* In fullscreen the iframe fills the screen, so `vw` here IS the real
     viewport — the widget's own values apply, container-independent, and
     `.ff-stage`'s flex centring puts the box in the middle with the dark
     background as a backdrop. Same breakpoints as plano.js. */
  max-width: 95vw;
}

@media (min-width: 768px) {
  :root.ff-fs .ff-embed .ff-stage-frame {
    max-width: 90vw;
  }
}

@media (min-width: 1024px) {
  :root.ff-fs .ff-embed .ff-stage-frame {
    max-width: 75vw;
  }
}

/* Same clamp the standalone viewer uses (.ff-svg max-height above): the SVG's
   viewBox gives it an aspect ratio, so capping height shrinks it
   proportionally and .ff-stage-bg fills the letterbox. */
:root.ff-fs .ff-embed .ff-svg {
  max-height: 95vh;
}

/* Product credit, bottom-right inside the frame.
   White with a soft shadow rather than a fixed grey: it sits over whatever the
   scene image happens to be, and the shadow is what keeps it readable on a pale
   floor plan as well as on a dark render. Faint by intent — it is a signature,
   not a label. `line-height: normal` because the frame zeroes it to shrink-wrap
   the image. */
.ff-credit {
  position: absolute;
  right: 14px;
  bottom: 12px;
  z-index: 40;
  line-height: normal;
  pointer-events: none;
  user-select: none;
  font-size: 11px;
  letter-spacing: 0.02em;
  color: #fff;
  opacity: 0.45;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.65);
}

/* Loading screen: blurred backdrop + centered logo, fades in/out.
   Sits inside .ff-stage-frame so the blur is clipped to the rounded border. */
.ff-loader {
  position: absolute;
  inset: 0;
  z-index: 60;
  line-height: normal;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.45);
  /* Blur starts at 0 and ramps up with opacity so the blur, backdrop and logo
     appear/disappear in sync. */
  backdrop-filter: blur(0px);
  -webkit-backdrop-filter: blur(0px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 250ms ease, backdrop-filter 250ms ease,
    -webkit-backdrop-filter 250ms ease, visibility 0s linear 250ms;
}

.ff-loader.is-visible {
  opacity: 1;
  visibility: visible;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: opacity 250ms ease, backdrop-filter 250ms ease,
    -webkit-backdrop-filter 250ms ease;
}

.ff-loader-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  color: #fff;
  transform: scale(0.92);
  transition: transform 250ms ease;
}

.ff-loader.is-visible .ff-loader-logo {
  transform: scale(1);
  animation: ff-logo-pulse 1.2s ease-in-out infinite;
}

.ff-loader-text {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.3em;
  opacity: 0.9;
}

.ff-loader-img {
  display: block;
  width: min(40vw, 200px);
  height: auto;
  max-height: 40vh;
  object-fit: contain;
  /* Always sharp — the backdrop blur never affects the logo itself. */
  filter: none;
}

@keyframes ff-logo-pulse {

  0%,
  100% {
    opacity: 0.85;
  }

  50% {
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ff-loader.is-visible .ff-loader-logo {
    animation: none;
  }
}

/* Hotspots */
.ff-hotspot {
  --ff-flash: 37, 99, 235;
  /* per-state flash color (neutral = accent blue) */
  fill: rgba(37, 99, 235, 0.0);
  stroke: rgba(37, 99, 235, 0);
  stroke-width: 2;
  cursor: pointer;
  transition: fill 0.15s ease, stroke 0.15s ease, filter 0.15s ease;
}

.ff-hotspot--free {
  --ff-flash: 34, 197, 94;
}

/* Reserved and sold both stay visibly marked, not just on hover — a visitor
   should see what is gettable without touching anything. Amber reads as "on
   hold" next to the green, and is far enough from the grey to survive a busy
   render behind it. */
/* The fill is a diagonal hatch, set inline by the viewer so the SVG pattern's
   id stays next to the pattern (src/web/availability.js). The amber below it
   lives inside the pattern; this rule keeps only the outline. Colour alone does
   not separate amber from grey for every visitor — the hatch is what makes
   `reserved` legible without hue. */
.ff-hotspot--reserved {
  fill: rgba(245, 158, 11, 0.32);
  stroke: rgba(245, 158, 11, 0.9);
}

.ff-hotspot--sold {
  fill: rgba(156, 163, 175, 0.4);
  stroke: rgba(156, 163, 175, 0.9);
}

/* One-time attention flash on scene load (delayed until the loader fades). */
.ff-hotspot--intro {
  animation: ff-hotspot-flash 0.85s ease-in-out 0.45s 2;
}

@keyframes ff-hotspot-flash {

  0%,
  100% {
    fill: rgba(var(--ff-flash), 0);
    stroke: rgba(var(--ff-flash), 0);
    filter: drop-shadow(0 0 0 rgba(var(--ff-flash), 0));
  }

  50% {
    fill: rgba(var(--ff-flash), 0.28);
    stroke: rgba(var(--ff-flash), 0.95);
    filter: drop-shadow(0 0 7px rgba(var(--ff-flash), 0.85));
  }
}

@media (prefers-reduced-motion: reduce) {
  .ff-hotspot--intro {
    animation: none;
  }
}

/* `:focus-visible`, never `:focus`: a polygon keeps DOM focus after a mouse
   click, so plain `:focus` left the flat lit up long after its modal was
   closed — until the visitor clicked somewhere else. Keyboard focus still shows
   (the fill and glow ARE the focus indicator, which is why `outline: none` is
   allowed here), and a modal returning focus to its trigger after a click does
   not re-light it, because the browser only matches `:focus-visible` on a
   programmatic focus when the last interaction was a keyboard one. */
.ff-hotspot:hover,
.ff-hotspot:focus-visible {
  fill: rgba(37, 99, 235, 0.35);
  stroke: var(--ff-accent);
  outline: none;
  /* little blurred (soft glow) border */
  filter: drop-shadow(0 0 5px rgba(37, 99, 235, 0.75));
}

.ff-hotspot--free:hover,
.ff-hotspot--free:focus-visible {
  fill: rgba(34, 197, 94, 0.35);
  stroke: var(--ff-free);
  filter: drop-shadow(0 0 5px rgba(34, 197, 94, 0.75));
}

.ff-hotspot--reserved:hover,
.ff-hotspot--reserved:focus-visible {
  fill: rgba(245, 158, 11, 0.5);
  stroke: var(--ff-reserved);
  filter: drop-shadow(0 0 5px rgba(245, 158, 11, 0.75));
}

.ff-hotspot--sold:hover,
.ff-hotspot--sold:focus-visible {
  fill: rgba(156, 163, 175, 0.55);
  stroke: var(--ff-sold);
  filter: drop-shadow(0 0 5px rgba(156, 163, 175, 0.75));
}

/* Favourited by this visitor. At rest: a dashed rose outline plus a very faint
   rose wash (0.1) — enough to read as "picked" without fighting the
   green/amber/grey availability colours, and it overrides the reserved/sold
   fill so the mark stays consistent. A stronger fill comes in on hover. It is a
   channel of its own, not another hue for a colour-blind visitor to separate,
   and it is persistent (not hover-only) so the shortlist reads at a glance. */
.ff-hotspot--fav {
  fill: rgba(236, 72, 153, 0.1);
  stroke: rgba(236, 72, 153, 0.95);
  stroke-dasharray: 7 4;
}

.ff-hotspot--fav:hover,
.ff-hotspot--fav:focus-visible {
  fill: rgba(236, 72, 153, 0.35);
  stroke: rgba(236, 72, 153, 1);
  filter: drop-shadow(0 0 5px rgba(236, 72, 153, 0.75));
}

/* --- Favourites bar (favourites module) -------------------------------------
   Bottom-left glass pill mirroring the scene switcher / fullscreen toggle, plus
   a panel that lists the shortlist and hands over a shareable link. Built only
   when the module is on, and hidden entirely while the shortlist is empty.
   See docs/FAVORITES.md. */
.ff-fav-bar {
  position: absolute;
  left: 12px;
  bottom: 12px;
  z-index: 50;
  line-height: normal;
}

.ff-fav-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 40px;
  padding: 0 14px 0 12px;
  border: none;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.55);
  color: #fff;
  cursor: pointer;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  transition: background 150ms ease;
}

.ff-fav-toggle:hover,
.ff-fav-toggle:focus-visible,
.ff-fav-bar.is-open .ff-fav-toggle {
  background: var(--ff-brand);
}

.ff-fav-toggle svg {
  display: block;
}

.ff-fav-count {
  font-size: 13px;
  font-weight: 700;
  min-width: 1ch;
}

/* Transient cap notice, sits just above the pill. Fades via .is-visible so a
   repeat trigger can restart it (see showFavCapNotice). */
.ff-fav-notice {
  position: absolute;
  left: 0;
  bottom: calc(100% + 8px);
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.7);
  color: #fff;
  font-size: 12px;
  white-space: nowrap;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 180ms ease, transform 180ms ease;
  pointer-events: none;
}

.ff-fav-notice.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.ff-fav-panel {
  position: absolute;
  left: 0;
  bottom: calc(100% + 8px);
  width: 240px;
  max-height: 320px;
  overflow-y: auto;
  padding: 8px;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.82);
  color: #fff;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.ff-fav-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.ff-fav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 6px 6px 10px;
  border-radius: 8px;
}

.ff-fav-item + .ff-fav-item {
  margin-top: 2px;
}

.ff-fav-item:hover {
  background: rgba(255, 255, 255, 0.08);
}

.ff-fav-item-label {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* The label is a button when its flat can be opened (see openFavourite). */
button.ff-fav-item-open {
  border: none;
  background: transparent;
  padding: 0;
  margin: 0;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

button.ff-fav-item-open:hover,
button.ff-fav-item-open:focus-visible {
  text-decoration: underline;
  outline: none;
}

.ff-fav-item-area {
  flex: none;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.6);
  white-space: nowrap;
}

.ff-fav-remove {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: rgba(255, 255, 255, 0.7);
  cursor: pointer;
}

.ff-fav-remove:hover,
.ff-fav-remove:focus-visible {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}

.ff-fav-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

/* .ff-fav-copy / .ff-fav-clear are the icon-only ghost buttons shared with the
   compare tray — see the group in the Flats-modal section. */

/* --- Compare module ------------------------------------------------------------
   The polygon mark, the bottom-centre tray, and the differences table (rendered
   into a `node` modal). Twin of the favourites styling above; built only when
   the module is on. See docs/BACKLOG.md §7. */

/* A flat in the comparison: a solid indigo outline, distinct from the dashed
   rose favourites mark so a flat can carry both at once and stay readable. A
   channel of its own, not a new availability hue. */
.ff-hotspot--compare {
  stroke: rgba(79, 70, 229, 0.95);
  stroke-width: 3;
  stroke-dasharray: none;
}

.ff-hotspot--compare:hover,
.ff-hotspot--compare:focus-visible {
  fill: rgba(79, 70, 229, 0.28);
  stroke: rgba(79, 70, 229, 1);
  filter: drop-shadow(0 0 5px rgba(79, 70, 229, 0.7));
}

/* Floating bottom-centre over the drawing when the Flats modal is closed. It
   wears the same frosted panel as every modal — background, border, radius,
   shadow, blur and --ff-modal-pad — so it and its docked form (below) read as
   one component. */
.ff-compare-bar {
  position: absolute;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  z-index: 50;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px;
  max-width: calc(100% - 24px);
  padding: var(--ff-modal-pad);
  color: #fff;
  background: var(--ff-glass-panel-bg);
  backdrop-filter: blur(var(--ff-glass-blur));
  -webkit-backdrop-filter: blur(var(--ff-glass-blur));
  border: 1px solid var(--ff-glass-panel-border);
  border-radius: var(--ff-radius-xl);
  box-shadow: var(--ff-glass-shadow);
  line-height: normal;
}

/* Only lay it out when shown — a base `display: flex` would beat the UA
   `[hidden]` rule and leave the empty bar on screen (the .ff-fav-bar sets no
   display, which is why it does not hit this). */
.ff-compare-bar:not([hidden]) {
  display: flex;
}

.ff-compare-notice {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(100% + 8px);
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.7);
  color: #fff;
  font-size: 12px;
  white-space: nowrap;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  opacity: 0;
  transition: opacity 180ms ease;
  pointer-events: none;
}

.ff-compare-notice.is-visible {
  opacity: 1;
}

.ff-compare-items {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.ff-compare-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 28px;
  padding: 0 4px 0 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.12);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.ff-compare-chip-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  padding: 0;
  border: none;
  border-radius: 5px;
  background: transparent;
  color: rgba(255, 255, 255, 0.7);
  cursor: pointer;
}

.ff-compare-chip-remove:hover,
.ff-compare-chip-remove:focus-visible {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
}

/* The compare-tray buttons all wear the one ghost-button look defined in the
   Flats-modal section (.ff-unit-list-openbtn, …), including the icon-only
   copy/clear and the "link copied" state. Only "open"'s disabled + icon rules
   are specific to it. */
.ff-compare-open:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.ff-compare-open svg {
  display: block;
}

/* The differences table opens in a generic `node` modal, whose base rule is
   tuned for the panorama's hairline frame. Give it the shared dark frosted-glass
   panel instead — every modal wears the same look (memory: modal-glass-
   background). */
.ff-modal--node:has(.ff-compare) {
  padding: var(--ff-modal-pad);
  color: #fff;
  background: var(--ff-glass-panel-bg);
  backdrop-filter: blur(var(--ff-glass-blur));
  -webkit-backdrop-filter: blur(var(--ff-glass-blur));
  border: 1px solid var(--ff-glass-panel-border);
  border-radius: var(--ff-radius-xl);
  box-shadow: var(--ff-glass-shadow);
}

/* The close button would vanish against the dark panel — lift it (same as the
   gallery does). */
.ff-modal--node:has(.ff-compare) .ff-modal-close,
.ff-modal--node:has(.ff-unit-list) .ff-modal-close {
  background: rgba(255, 255, 255, 0.14);
}

.ff-compare {
  color: #fff;
}

.ff-compare-hideident {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 10px;
  font-size: 13px;
  cursor: pointer;
  user-select: none;
}

/* Floorplans across the top, columns matching the table (label column + one per
   flat). The first grid track is the empty corner over the row headers. */
.ff-compare-plans {
  display: grid;
  grid-template-columns: minmax(90px, 0.7fr) repeat(var(--ff-compare-cols, 3), 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.ff-compare-plans::before {
  content: '';
}

.ff-compare-plan {
  aspect-ratio: 4 / 3;
  background: #f1f5f9;
  border-radius: 6px;
  overflow: hidden;
}

.ff-compare-plan-btn {
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  border: none;
  background: none;
  cursor: zoom-in;
}

.ff-compare-plan img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Full-size floorplan over the whole comparison (compare-view.js openZoom). */
.ff-compare-zoom {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.86);
  cursor: zoom-out;
}

.ff-compare-zoom img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.ff-compare-scroll {
  overflow-x: auto;
}

.ff-compare-table {
  border-collapse: collapse;
  width: 100%;
  font-size: 13px;
}

.ff-compare-table th,
.ff-compare-table td {
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
  vertical-align: top;
}

.ff-compare-table thead th {
  border-bottom: 2px solid rgba(255, 255, 255, 0.24);
  font-weight: 700;
}

.ff-compare-table tbody th {
  font-weight: 600;
  color: rgba(255, 255, 255, 0.6);
  white-space: nowrap;
}

.ff-compare-corner {
  background: transparent;
}

.ff-compare-flat {
  min-width: 120px;
}

.ff-compare-flat-head {
  display: flex;
  align-items: center;
  gap: 2px;
}

.ff-compare-flat.is-sold .ff-compare-flat-name,
.ff-compare-flat.is-reserved .ff-compare-flat-name {
  opacity: 0.65;
}

.ff-compare-remove {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  padding: 0;
  border: none;
  border-radius: 5px;
  background: transparent;
  color: rgba(255, 255, 255, 0.65);
  cursor: pointer;
}

.ff-compare-remove:hover,
.ff-compare-remove:focus-visible {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
}

.ff-compare-table td.is-absent {
  color: rgba(255, 255, 255, 0.4);
}

.ff-compare-table td.is-best {
  font-weight: 700;
  color: #4ade80;
}

/* "Hide identical rows": drop every row the flats agree on, leaving the two or
   three lines that actually decide the choice. */
.ff-compare-table.is-hiding-identical tr.is-identical {
  display: none;
}

@media print {
  /* When the comparison modal is open, print only it. */
  body:has(.ff-modal--node .ff-compare) > *:not(.ff-modal-overlay) {
    display: none !important;
  }
  .ff-modal-overlay:has(.ff-compare) {
    position: static;
    background: none;
    padding: 0;
  }
  .ff-modal--node:has(.ff-compare) {
    max-width: none;
    max-height: none;
    box-shadow: none;
    /* Force a readable printout — the on-screen glass panel is dark. */
    background: #fff;
    color: #000;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
  .ff-compare,
  .ff-compare-table tbody th,
  .ff-compare-table td.is-absent {
    color: #000;
  }
  .ff-compare-table th,
  .ff-compare-table td {
    border-color: #ccc;
  }
  .ff-compare-table td.is-best {
    color: #15803d;
  }
  .ff-modal--node:has(.ff-compare) .ff-modal-close,
  .ff-compare-hideident,
  .ff-compare-remove {
    display: none !important;
  }
  .ff-compare-scroll {
    overflow: visible;
  }
}

/* --- Filter module ----------------------------------------------------------
   A glass toggle top-left opening a panel of min/max + checkbox controls; the
   non-matching polygons fade in place (the drawing is kept, not replaced by a
   list). Built only when the `filter` module is on. See docs/BACKLOG.md §7. */

/* Faded by the filter: still drawn (spatial context), but dimmed and inert so a
   visitor cannot open a flat the filter has ruled out. Wins over the
   availability fills and the favourites/compare marks — a filtered-out flat
   reads one way whatever else is on it. */
.ff-hotspot--filtered-out {
  opacity: 0.12;
  pointer-events: none;
  transition: opacity 160ms ease;
}

.ff-filter-bar {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 50;
  line-height: normal;
}

/* In embed mode the fullscreen toggle owns the top-left corner — step aside. */
.ff-stage-frame:has(.ff-fs-toggle) .ff-filter-bar {
  left: 60px;
}

.ff-filter-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.55);
  color: #fff;
  cursor: pointer;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  transition: background 150ms ease;
}

.ff-filter-toggle svg {
  display: block;
}

.ff-filter-toggle:hover,
.ff-filter-toggle:focus-visible,
.ff-filter-bar.is-active .ff-filter-toggle {
  background: var(--ff-brand);
}

/* Count of flats the active filter is hiding, on the button corner. */
.ff-filter-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 16px;
  height: 16px;
  padding: 0 3px;
  border-radius: 8px;
  background: var(--ff-brand);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
  box-shadow: 0 0 0 2px rgba(15, 23, 42, 0.55);
}

.ff-filter-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ff-filter-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin: 0;
  padding: 0;
  border: none;
}

.ff-filter-row--group {
  gap: 4px;
}

.ff-filter-label,
.ff-filter-legend {
  font-size: 12px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.8);
  padding: 0;
}

.ff-filter-rangehead {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.ff-filter-rangeval {
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: rgba(255, 255, 255, 0.75);
}

/* Dual-handle range: two overlapping native range inputs over a shared rail.
   The inputs themselves ignore the pointer; only their thumbs take it, so the
   one with the higher z-index wins where the handles meet (see .is-front). */
.ff-range {
  position: relative;
  height: 24px;
}

.ff-range-rail {
  position: absolute;
  left: 8px;
  right: 8px;
  top: 50%;
  height: 4px;
  transform: translateY(-50%);
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.18);
}

.ff-range-fill {
  position: absolute;
  top: 0;
  bottom: 0;
  border-radius: 2px;
  background: var(--ff-brand, #2563eb);
}

.ff-range-input {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  background: none;
  pointer-events: none;
  -webkit-appearance: none;
  appearance: none;
}

.ff-range-input--min {
  z-index: 3;
}
.ff-range-input--max {
  z-index: 4;
}
.ff-range-input.is-front {
  z-index: 5;
}

.ff-range-input::-webkit-slider-runnable-track {
  background: none;
  border: none;
}
.ff-range-input::-moz-range-track {
  background: none;
  border: none;
}

.ff-range-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  pointer-events: auto;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--ff-brand, #2563eb);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
  cursor: pointer;
}
.ff-range-input::-moz-range-thumb {
  pointer-events: auto;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--ff-brand, #2563eb);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
  cursor: pointer;
}

.ff-range-input:focus-visible::-webkit-slider-thumb {
  outline: 2px solid #fff;
  outline-offset: 1px;
}
.ff-range-input:focus-visible::-moz-range-thumb {
  outline: 2px solid #fff;
  outline-offset: 1px;
}

.ff-filter-check {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  cursor: pointer;
}

.ff-filter-check input {
  flex: none;
}

.ff-filter-note {
  margin: 0;
  font-size: 11px;
  line-height: 1.35;
  color: rgba(255, 255, 255, 0.65);
}

/* .ff-filter-reset takes the shared ghost-button look below. */

/* --- Flats modal: filter rail + list / table (filter module) -------------
   One full-frame `node` modal holds the filter panel and the sortable table
   of every flat, side by side. Same shared dark frosted-glass panel as every
   other modal (memory: modal-glass-background); the close-button lift is up
   with the compare rules. */
.ff-flats {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  max-width: min(94vw, 1120px);
}

/* The rail stays put while the table scrolls the modal — a long list must not
   scroll the controls out of reach. */
.ff-flats-aside {
  flex: 0 0 230px;
  position: sticky;
  top: 0;
  align-self: flex-start;
}

.ff-flats-head {
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.6);
}

/* Compare tray docked into the Flats-modal overlay (viewer.js dockCompareBar):
   only shed the floating position and re-fit the width; the frosted-panel look
   (background, border, radius, shadow, blur, --ff-modal-pad) already comes from
   .ff-compare-bar and is shared with every modal. */
.ff-compare-bar--docked {
  position: static;
  left: auto;
  bottom: auto;
  transform: none;
  z-index: auto;
  flex: 0 0 auto;
  width: auto;
  max-width: min(94vw, 1160px);
  margin: 0;
}

/* Stack the panel and the strip, with a real gap of scrim between them, and
   trim the panel's max-height so the pair still fits the viewport. Only once
   the strip is actually shown (a selection exists) — an empty tray is hidden
   and must not steal the panel's height. */
.ff-modal-overlay:has(.ff-compare-bar--docked:not([hidden])) {
  flex-direction: column;
  gap: 16px;
}
.ff-modal-overlay:has(.ff-compare-bar--docked:not([hidden])) .ff-modal {
  max-height: min(90vh, calc(100vh - 120px));
}

.ff-flats-main {
  flex: 1 1 auto;
  min-width: 0; /* let the inner scroller, not this column, take the overflow */
}

/* In the combined modal the table no longer dictates the modal width. */
.ff-flats .ff-unit-list {
  min-width: 0;
}

/* Narrow frame (a small embed, a phone): stack the rail above the table.
   align-items flips to stretch so each stacked block fills the modal width —
   otherwise the nowrap table would size the column to its own content and
   push past the frame instead of scrolling inside .ff-unit-list-scroll. */
@media (max-width: 720px) {
  .ff-flats {
    flex-direction: column;
    align-items: stretch;
    max-width: 92vw;
  }
  .ff-flats-aside {
    position: static;
    align-self: stretch;
    flex-basis: auto;
    width: auto;
  }
}

.ff-modal--node:has(.ff-flats) {
  max-width: min(94vw, 1160px);
}
.ff-modal--node:has(.ff-unit-list) {
  padding: var(--ff-modal-pad);
  color: #fff;
  background: var(--ff-glass-panel-bg);
  backdrop-filter: blur(var(--ff-glass-blur));
  -webkit-backdrop-filter: blur(var(--ff-glass-blur));
  border: 1px solid var(--ff-glass-panel-border);
  border-radius: var(--ff-radius-xl);
  box-shadow: var(--ff-glass-shadow);
}

.ff-unit-list {
  color: #fff;
  min-width: min(88vw, 900px);
}

.ff-unit-list-count {
  margin: 0 0 10px;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.6);
}

.ff-unit-list-scroll {
  overflow-x: auto;
}

.ff-unit-list-table {
  border-collapse: collapse;
  width: 100%;
  font-size: 13px;
}

.ff-unit-list-table th,
.ff-unit-list-table td {
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
  white-space: nowrap;
}

.ff-unit-list-table thead th {
  border-bottom: 2px solid rgba(255, 255, 255, 0.24);
}

.ff-unit-list-td--area,
.ff-unit-list-td--price,
.ff-unit-list-td--number,
.ff-unit-list-th--area,
.ff-unit-list-th--price,
.ff-unit-list-th--number {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.ff-unit-list-sort {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: none;
  background: none;
  padding: 0;
  font: inherit;
  font-weight: 700;
  color: inherit;
  cursor: pointer;
}

.ff-unit-list-sort:hover {
  text-decoration: underline;
}

.ff-unit-list-th--area .ff-unit-list-sort,
.ff-unit-list-th--price .ff-unit-list-sort,
.ff-unit-list-th--number .ff-unit-list-sort {
  flex-direction: row-reverse;
}

.ff-unit-list-th.is-sorted-asc .ff-unit-list-sort::after {
  content: '▲';
  font-size: 9px;
}
.ff-unit-list-th.is-sorted-desc .ff-unit-list-sort::after {
  content: '▼';
  font-size: 9px;
}

.ff-unit-list-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.06);
}

.ff-unit-list-td.is-absent {
  color: rgba(255, 255, 255, 0.4);
}

.ff-unit-list-pick {
  width: 1%;
  text-align: center !important;
}

/* One ghost-button look across the Flats modal, the compare tray and the
   favourites bar: the list's "Details", the filter panel's "Reset filters",
   the compare "open", and — as icon-only buttons — "Copy link" and "Clear" in
   BOTH the compare tray and the favourites bar. Width is left to context:
   "Reset" is a full-width flex item, "Details"/"open" hug their label, the
   copy/clear icon buttons are square (rule below). */
.ff-unit-list-openbtn,
.ff-filter-reset,
.ff-compare-open,
.ff-compare-copy,
.ff-compare-clear,
.ff-fav-copy,
.ff-fav-clear {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: var(--ff-radius-lg);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 150ms ease, border-color 150ms ease;
}

.ff-unit-list-openbtn:hover,
.ff-unit-list-openbtn:focus-visible,
.ff-filter-reset:hover,
.ff-filter-reset:focus-visible,
.ff-compare-open:hover:not(:disabled),
.ff-compare-open:focus-visible,
.ff-compare-copy:hover,
.ff-compare-copy:focus-visible,
.ff-compare-clear:hover,
.ff-compare-clear:focus-visible,
.ff-fav-copy:hover,
.ff-fav-copy:focus-visible,
.ff-fav-clear:hover,
.ff-fav-clear:focus-visible {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.5);
}

/* "Copy link" and "Clear" are icon-only everywhere they appear — square, and
   the same size in the compare tray and the favourites bar. */
.ff-compare-copy,
.ff-compare-clear,
.ff-fav-copy,
.ff-fav-clear {
  width: 32px;
  padding: 0;
  flex: none;
}

.ff-compare-copy svg,
.ff-compare-clear svg,
.ff-fav-copy svg,
.ff-fav-clear svg {
  display: block;
  width: 16px;
  height: 16px;
}

/* The momentary "link copied" confirmation on the copy button, both bars. */
.ff-fav-copy.is-done,
.ff-fav-copy.is-done:hover,
.ff-fav-copy.is-done:focus-visible,
.ff-compare-copy.is-done,
.ff-compare-copy.is-done:hover,
.ff-compare-copy.is-done:focus-visible {
  background: rgba(34, 197, 94, 0.9);
  border-color: rgba(34, 197, 94, 0.9);
  color: #fff;
}

.ff-unit-list-empty {
  padding: 24px 12px !important;
  text-align: center !important;
  color: rgba(255, 255, 255, 0.6);
}

@media print {
  body:has(.ff-modal--node .ff-unit-list) > *:not(.ff-modal-overlay) {
    display: none !important;
  }
  .ff-modal-overlay:has(.ff-unit-list) {
    position: static;
    background: none;
    padding: 0;
  }
  .ff-modal--node:has(.ff-unit-list) {
    max-width: none;
    max-height: none;
    box-shadow: none;
    /* Force a readable printout — the on-screen glass panel is dark. */
    background: #fff;
    color: #000;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
  .ff-unit-list,
  .ff-unit-list-count,
  .ff-unit-list-td.is-absent {
    color: #000;
  }
  .ff-unit-list-table th,
  .ff-unit-list-table td {
    border-color: #ccc;
  }
  .ff-modal--node:has(.ff-unit-list) .ff-modal-close,
  .ff-unit-list-pick,
  .ff-unit-list-open,
  .ff-flats-aside,
  .ff-compare-bar--docked {
    display: none !important;
  }
  .ff-unit-list-scroll {
    overflow: visible;
  }
  /* Print just the table — drop the two-column row around it. */
  .ff-flats {
    display: block;
    max-width: none;
  }
}

/* North indicator — orientation context, not a control.
   White with a soft dark shadow rather than a brand colour: it has to stay
   readable over a sunlit render and a white floor plan alike, without reading
   as something to click. Kept at partial opacity so it recedes behind the
   hotspots, which are the point of the widget. */
.ff-north {
  pointer-events: none;
  opacity: 0.66;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.55));
}

.ff-north-ring {
  fill: none;
  stroke: #fff;
  stroke-width: 1.25;
  stroke-opacity: 0.85;
  vector-effect: non-scaling-stroke; /* stays a hairline when tilted flat */
}

.ff-north-needle {
  fill: #fff;
}

.ff-north-tail {
  fill: #fff;
  fill-opacity: 0.28;
}

.ff-north-letter {
  fill: #fff;
  font-weight: 600;
  letter-spacing: 0.04em;
}

/* Point markers (camera / 360 panorama) */
.ff-marker {
  cursor: pointer;
  outline: none;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.35));
  transition: filter 0.15s ease;
}

.ff-marker .ff-marker-bg {
  fill: var(--ff-brand);
  fill-opacity: 0.92;
  stroke: #fff;
  stroke-width: 2.5;
  vector-effect: non-scaling-stroke;
  transition: fill-opacity 0.15s ease;
}

.ff-marker .ff-marker-icon {
  color: #fff;
  pointer-events: none;
}

.ff-marker:hover,
.ff-marker:focus {
  filter: drop-shadow(0 3px 7px rgba(0, 0, 0, 0.5));
}

.ff-marker:hover .ff-marker-bg,
.ff-marker:focus .ff-marker-bg {
  fill-opacity: 1;
}

/* Tooltip */
.ff-tooltip {
  position: fixed;
  transform: translate(12px, 12px);
  background: rgba(15, 23, 42, 0.92);
  color: #fff;
  padding: 7px 12px;
  border-radius: 6px;
  font-size: 11px;
  pointer-events: none;
  z-index: 50;
  white-space: nowrap;
}

/* Status messages */
.ff-status {
  color: #e2e8f0;
  font-size: 16px;
  padding: 24px;
}

.ff-status--error {
  color: #fca5a5;
  max-width: 600px;
  text-align: center;
}

/* Modal */
.ff-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 24px;
}

.ff-modal {
  position: relative;
  background: var(--ff-panel);
  border-radius: 10px;
  max-width: min(90vw, 1000px);
  max-height: 90vh;
  overflow: auto;
  padding: var(--ff-modal-pad);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

.ff-modal-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 32px;
  height: 32px;
  border: none;
  background: #f1f5f9;
  border-radius: 50%;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  color: var(--ff-text);
}

.ff-modal-close:hover {
  background: #e2e8f0;
}

.ff-modal-title {
  margin: 0 32px 12px 0;
  font-size: 18px;
}

/* The panorama modal — a hairline frame around a dark WebGL stage, no visible
   heading, close button in the glass icon style (matching .ff-scene-toggle /
   .ff-pano-fs / .ff-gallery-nav). */
.ff-modal--node {
  padding: 1px;
  background: rgba(255, 255, 255, 0.3);
}

/* The gallery sits on the same dark frosted panel as the unit popup
   (.ff-unit-sheet--framed) — one look for every image modal. */
.ff-modal--gallery {
  padding: var(--ff-modal-pad);
  color: #fff;
  background: var(--ff-glass-panel-bg);
  backdrop-filter: blur(var(--ff-glass-blur));
  -webkit-backdrop-filter: blur(var(--ff-glass-blur));
  border: 1px solid var(--ff-glass-panel-border);
  border-radius: var(--ff-radius-xl);
  box-shadow: var(--ff-glass-shadow);
}

/* The unit sheet is its own frosted-glass popup (.ff-unit-sheet--framed) with
   its own header/close — the modal is only the scrim and the centring. It keeps
   the base .ff-modal max-height + overflow so a tall sheet scrolls. */
.ff-modal--unit {
  padding: 0;
  background: transparent;
  box-shadow: none;
  /* the sheet caps its own width (.ff-unit-sheet--side); don't clip it here */
  max-width: 96vw;
}

.ff-modal--node .ff-modal-close,
.ff-modal--gallery .ff-modal-close {
  top: 12px;
  right: 12px;
  /* The stage inside is position:relative and comes after this button in the
     DOM, so without a positive z-index it paints on top and hides it. */
  z-index: 10;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.55);
  color: #fff;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  transition: background 150ms ease;
}

.ff-modal--node .ff-modal-close svg,
.ff-modal--gallery .ff-modal-close svg {
  width: 20px;
  height: 20px;
  display: block;
}

/* The gallery's close button sits ON the frosted panel (the panorama's sits on
   the dark stage), so lift it off a matching background. Overrides the shared
   rule above — must come after it. */
.ff-modal--gallery .ff-modal-close {
  background: rgba(255, 255, 255, 0.14);
}

.ff-modal--node .ff-modal-close:hover,
.ff-modal--node .ff-modal-close:focus-visible,
.ff-modal--gallery .ff-modal-close:hover,
.ff-modal--gallery .ff-modal-close:focus-visible {
  background: var(--ff-brand, #2563eb);
}

/* In fullscreen the panorama takes the whole screen: no overlay margin, no
   panel radius, and a wider stage. The stage keeps its aspect ratio so any
   variant picker still fits below it. Only ever matches with a panorama modal
   open (nothing else opens one and then goes fullscreen). */
:root.ff-fs .ff-modal-overlay {
  padding: 0;
}

:root.ff-fs .ff-modal--node {
  max-width: 100vw;
  max-height: 100vh;
  border-radius: 0;
}

:root.ff-fs .ff-modal--node .ff-pano {
  width: min(1600px, 96vw);
}

.ff-modal-body--image,
.ff-modal-body--iframe {
  display: flex;
}

.ff-modal-image {
  max-width: 100%;
  max-height: 80vh;
  display: block;
  border-radius: 6px;
}

/* ---- Generated unit data sheet (docs/BACKLOG.md §7) ---------------------- */
/* Kept in step with packages/design-system UnitSheet.tsx/.css — that package is
   the design source of truth; this is its vanilla-DOM twin until the React
   migration. Two layouts: --side (text left, floorplan centred right) and
   --stacked (floorplan on top, narrow); --framed adds the frosted-glass popup
   with a crumb header and a footer. */

.ff-unit-sheet,
.ff-unit-sheet *,
.ff-unit-sheet *::before,
.ff-unit-sheet *::after {
  box-sizing: border-box;
}

.ff-unit-sheet {
  color: var(--ff-text);
}

.ff-unit-sheet--side {
  width: min(94vw, 1000px);
}

.ff-unit-sheet--stacked {
  width: min(90vw, 504px);
}

/* Dark translucent panel, white text. The light-theme tokens are re-pointed on
   this scope so every child rule (which reads var(--ff-*)) follows without
   per-element overrides; the unframed/bare sheet keeps the light defaults. */
.ff-unit-sheet--framed {
  --ff-text: #ffffff;
  --ff-muted: rgba(255, 255, 255, 0.62);
  --ff-border: rgba(255, 255, 255, 0.16);
  --ff-chip-bg: rgba(255, 255, 255, 0.12);
  --ff-chip-text: rgba(255, 255, 255, 0.88);
  --ff-plan-bg: rgba(255, 255, 255, 0.92);

  display: flex;
  flex-direction: column;
  padding: 26px;
  color: #fff;
  background: var(--ff-glass-panel-bg);
  backdrop-filter: blur(var(--ff-glass-blur));
  -webkit-backdrop-filter: blur(var(--ff-glass-blur));
  border: 1px solid var(--ff-glass-panel-border);
  border-radius: var(--ff-radius-xl);
  box-shadow: var(--ff-glass-shadow);
}

/* The close button would vanish against the dark panel — lift it. */
.ff-unit-sheet--framed .ff-unit-close {
  background: rgba(255, 255, 255, 0.14);
}

/* header: crumbs + heart on the left, close on the right */
.ff-unit-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

/* The crumb line is the sheet's title — project, floor and flat number read at
   a glance, so it carries the floor the table no longer repeats. */
.ff-unit-heading {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
  font-size: 17px;
  line-height: 1.2;
  color: var(--ff-muted);
}

.ff-unit-crumb:not(:first-child)::before {
  content: "|";
  margin-right: 6px;
  color: var(--ff-muted);
  opacity: 0.5;
}

.ff-unit-crumb--id {
  color: var(--ff-text);
  font-weight: 600;
}

/* Sized against the crumb line it sits in, not the icon buttons elsewhere. */
.ff-unit-fav {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  margin-left: 2px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--ff-muted);
  cursor: pointer;
  transition: color 150ms ease, transform 150ms ease;
}

.ff-unit-fav:hover,
.ff-unit-fav:focus-visible,
.ff-unit-fav.is-on {
  color: var(--ff-fav);
}

.ff-unit-fav.is-on {
  transform: scale(1.05);
}

.ff-unit-fav svg {
  display: block;
}

.ff-unit-close {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: none;
  border-radius: var(--ff-radius-lg);
  background: var(--ff-glass-icon-bg);
  color: #fff;
  backdrop-filter: blur(var(--ff-glass-icon-blur));
  -webkit-backdrop-filter: blur(var(--ff-glass-icon-blur));
  box-shadow: var(--ff-glass-icon-shadow);
  cursor: pointer;
  transition: background 150ms ease;
}

.ff-unit-close:hover,
.ff-unit-close:focus-visible {
  background: var(--ff-brand);
}

.ff-unit-close svg {
  display: block;
}

/* footer: "Request a callback" left, icon actions right */
.ff-unit-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
}

.ff-unit-footer-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.ff-unit-iconbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--ff-border);
  border-radius: var(--ff-radius-lg);
  background: transparent;
  color: var(--ff-muted);
  cursor: pointer;
  transition: border-color 150ms ease, color 150ms ease;
}

.ff-unit-iconbtn:hover,
.ff-unit-iconbtn:focus-visible {
  border-color: var(--ff-brand);
  color: var(--ff-brand);
}

.ff-unit-iconbtn svg {
  display: block;
}

/* Compare toggle in the selected state — filled with the brand tint so
   reopening a flat already in the comparison reads at a glance, the same
   affordance the header heart gets when favourited. */
.ff-unit-compare.is-on {
  border-color: var(--ff-brand);
  background: color-mix(in srgb, var(--ff-brand) 14%, transparent);
  color: var(--ff-brand);
}

/* The compare toggle under the data table, left-aligned with it. */
.ff-unit-body-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* main: the two layouts */
.ff-unit-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.ff-unit-sheet--stacked .ff-unit-main {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ff-unit-sheet--side .ff-unit-main {
  display: grid;
  /* the floorplan gets the lion's share of the (wider) popup */
  grid-template-columns: minmax(0, 1fr) minmax(0, 3fr);
  gap: 20px;
  align-items: center;
}

.ff-unit-sheet--side .ff-unit-body {
  order: 1;
}

.ff-unit-sheet--side .ff-unit-media {
  order: 2;
}

.ff-unit-sheet--side .ff-unit-plan {
  max-height: 82vh;
}

@media (max-width: 560px) {
  .ff-unit-sheet--framed {
    padding: 20px;
  }

  .ff-unit-header {
    margin-bottom: 12px;
  }

  /* Still the largest thing on the sheet, but a phone-width crumb line at the
     desktop size wraps to several rows before the floorplan gets a pixel. */
  .ff-unit-heading {
    font-size: 14px;
  }

  .ff-unit-sheet--side {
    width: min(90vw, 504px);
  }

  .ff-unit-sheet--side .ff-unit-main {
    grid-template-columns: 1fr;
    gap: 12px;
    align-items: stretch;
  }

  .ff-unit-sheet--side .ff-unit-media {
    order: 1;
  }

  .ff-unit-sheet--side .ff-unit-body {
    order: 2;
  }
}

.ff-unit-plan {
  width: 100%;
  max-height: 54vh;
  object-fit: contain;
  border-radius: var(--ff-radius);
  background: var(--ff-plan-bg);
}

.ff-unit-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.ff-unit-table th,
.ff-unit-table td {
  padding: 7px 0;
  border-bottom: 1px solid var(--ff-border);
  text-align: left;
  vertical-align: baseline;
}

.ff-unit-table th {
  font-weight: 500;
  color: var(--ff-muted);
}

/* Numbers right-aligned and tabular so areas and prices line up down the
   column — the comparison a buyer makes is vertical. */
.ff-unit-table td {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.ff-unit-features {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.ff-unit-features li {
  font-size: 12px;
  padding: 3px 10px;
  border-radius: var(--ff-radius-pill);
  background: var(--ff-chip-bg);
  color: var(--ff-chip-text);
}

.ff-unit-empty {
  margin: 0;
  color: var(--ff-muted);
  font-size: 14px;
}

/* ---- Enquiry (leads module) ------------------------------------------- */

.ff-unit-enquire {
  padding: 8px 16px;
  border: 1px solid transparent;
  border-radius: var(--ff-radius-lg);
  background: var(--ff-brand);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.ff-unit-enquire:hover,
.ff-unit-enquire:focus-visible {
  filter: brightness(0.95);
}

.ff-enquiry {
  width: min(88vw, 380px);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ff-enquiry-intro {
  margin: 0;
  color: var(--ff-muted);
  font-size: 14px;
}

.ff-enquiry-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ff-enquiry-field label {
  font-size: 13px;
  font-weight: 600;
}

.ff-enquiry-opt {
  font-weight: 400;
  color: var(--ff-muted);
}

.ff-enquiry-field input,
.ff-enquiry-field textarea {
  font: inherit;
  padding: 8px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #fff;
  color: var(--ff-text);
}

.ff-enquiry-field input:focus-visible,
.ff-enquiry-field textarea:focus-visible {
  outline: 2px solid var(--ff-brand);
  outline-offset: -1px;
}

.ff-enquiry-field textarea {
  resize: vertical;
}

.ff-enquiry-error {
  font-size: 12px;
  color: #dc2626;
}

.ff-enquiry-formerror {
  margin: 0;
  font-size: 13px;
  color: #dc2626;
}

/* Off-screen, not display:none — a bot that skips hidden fields still sees it,
   and screen readers skip it via aria-hidden + tabindex=-1. */
.ff-enquiry-hp {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.ff-enquiry-submit {
  padding: 10px 16px;
  border: none;
  border-radius: 8px;
  background: var(--ff-brand);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.ff-enquiry-submit:disabled {
  opacity: 0.6;
  cursor: default;
}

.ff-enquiry-done {
  width: min(88vw, 360px);
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: center;
}

.ff-enquiry-done-title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}

.ff-enquiry-done p {
  margin: 0;
  color: var(--ff-muted);
  font-size: 14px;
}

.ff-modal-iframe {
  width: min(85vw, 900px);
  height: min(70vh, 600px);
  border: 0;
  border-radius: 6px;
}

.ff-modal-embed {
  width: min(85vw, 900px);
}

.ff-modal-embed iframe {
  display: block;
  width: 100%;
  max-width: 100%;
  border: 0;
  border-radius: 6px;
}

.ff-modal-text {
  max-width: 600px;
  line-height: 1.5;
}

/* --- Gallery modal ------------------------------------------------------ */

.ff-gallery {
  width: min(85vw, 900px);
}

.ff-gallery-stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  /* Transparent so the image sits straight on the frosted panel
     (.ff-modal--gallery), the same look as the unit popup. */
  background: transparent;
  border-radius: 10px;
  overflow: hidden;
}

.ff-gallery-image {
  display: block;
  max-width: 100%;
  max-height: 65vh;
  border-radius: 10px;
}

.ff-gallery-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: none;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.55);
  color: #fff;
  cursor: pointer;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  transition: background 150ms ease;
}

.ff-gallery-nav svg {
  width: 22px;
  height: 22px;
  display: block;
}

.ff-gallery-nav:hover,
.ff-gallery-nav:focus-visible {
  background: var(--ff-brand, #2563eb);
}

.ff-gallery-nav--prev {
  left: 8px;
}

.ff-gallery-nav--next {
  right: 8px;
}

.ff-gallery-counter {
  position: absolute;
  right: 10px;
  bottom: 8px;
  padding: 3px 9px;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.55);
  color: #fff;
  font-size: 12px;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.ff-gallery-caption {
  margin: 10px 2px 2px;
  font-size: 14px;
  line-height: 1.4;
  color: #e2e8f0;
}

.ff-gallery-thumbs {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.ff-gallery-thumb {
  flex: 0 0 auto;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 4px;
  background: none;
  cursor: pointer;
  line-height: 0;
  opacity: 0.65;
}

.ff-gallery-thumb.is-active,
.ff-gallery-thumb:hover {
  opacity: 1;
}

.ff-gallery-thumb.is-active {
  border-color: var(--ff-brand);
}

.ff-gallery-thumb img {
  width: 84px;
  height: 56px;
  object-fit: cover;
  border-radius: 2px;
}

.ff-gallery--empty {
  padding: 24px;
  color: #cbd5e1;
}

/* ---------------------------------------------------------------------------
   Availability key
   Above the drawing, so the vocabulary arrives before the colours do. Only the
   states actually present in the scene appear — see src/web/availability.js.
   --------------------------------------------------------------------------- */
.ff-legend-area:empty {
  display: none;
}

.ff-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1rem;
  align-items: center;
  margin: 0 0 0.6rem;
  font-size: 0.85rem;
  line-height: 1.4;
  color: #4b5563;
}

.ff-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.ff-legend-swatch {
  width: 0.9rem;
  height: 0.9rem;
  border-radius: 3px;
  flex: none;
  border: 1px solid rgba(0, 0, 0, 0.15);
}

.ff-legend-swatch--free {
  background: rgba(34, 197, 94, 0.35);
  border-color: var(--ff-free);
}

/* The same 45° hatch the polygon carries, so the key teaches the pattern and
   not just the colour. */
.ff-legend-swatch--reserved {
  background: repeating-linear-gradient(
    45deg,
    rgba(245, 158, 11, 0.75) 0,
    rgba(245, 158, 11, 0.75) 2px,
    rgba(245, 158, 11, 0.26) 2px,
    rgba(245, 158, 11, 0.26) 5px
  );
  border-color: var(--ff-reserved);
}

.ff-legend-swatch--sold {
  background: rgba(156, 163, 175, 0.45);
  border-color: var(--ff-sold);
}
