/*
 * UI v2 — the decluttered chrome (owner-approved 4 Oct 2026; design and measurements in
 * qa/ui-declutter/). Every rule is scoped to body[data-ui="v2"], so ?ui=classic (or
 * UI_MODE = 'classic' in js/data/display-policy.js) renders the previous chrome untouched.
 *
 * body attributes (js/ui/shell/v2/chrome.js):
 *   data-layout   desk (≥1100 wide) · tablet · portrait (<760 wide) · compact (≤499 tall, a phone on its side)
 *   data-v2-nav   top · tabbar · rail
 *   data-v2-show  the visible pieces for the current view (controlsFor(), layout.js)
 *   data-chrome-idle  touch layouts while the visitor drags the 3D (chrome fades out)
 * Colours come from tokens.css only.
 */

/* ------------------------------------------------------------------ tokens */
body[data-ui="v2"] {
  --v2-gap: 12px;
  --v2-chip: 44px;
  --v2-top: calc(var(--safe-top) + var(--v2-gap));
  --v2-nav-space: 0px;            /* bottom tab bar (portrait / tablet) */
  --v2-rail-space: 0px;           /* left edge rail (compact) */
  --topbar-h: var(--v2-chip);
  --context-h: 0px;
  --chrome-top: calc(var(--v2-top) + var(--v2-chip) + var(--v2-gap));
  --chrome-bottom: calc(var(--safe-bottom) + var(--v2-gap) + var(--v2-nav-space));
  --stage-inset-top: var(--chrome-top);
}

body[data-ui="v2"][data-v2-nav="tabbar"] {
  --v2-nav-space: 72px;
}

body[data-ui="v2"][data-layout="portrait"],
body[data-ui="v2"][data-layout="compact"] {
  --v2-gap: 8px;
}

body[data-ui="v2"][data-layout="compact"] {
  --v2-rail-space: 60px;
  --chrome-top: calc(var(--v2-top) + var(--v2-chip) + var(--v2-gap));
}

/* Tour on touch screens is immersive: no tab bar. */
body[data-ui="v2"][data-v2-nav="tabbar"]:not([data-v2-show~="nav"]) {
  --v2-nav-space: 0px;
}

body[data-ui="v2"][data-layout="compact"]:not([data-v2-show~="nav"]) {
  --v2-rail-space: 0px;
}

/* --------------------------------------------- the classic chrome steps aside */
body[data-ui="v2"] #topbar,
body[data-ui="v2"] #context,
body[data-ui="v2"] #stage-credit,
body[data-ui="v2"] .res-rail__tab,
body[data-ui="v2"] .phv-sound-zone,
body[data-ui="v2"] .st-tod,
body[data-ui="v2"] [data-sales].topbar__share {
  display: none !important;
}

/* The adopted Ajustes content lives in Más; the empty popover never opens. */
body[data-ui="v2"] #settings {
  display: none !important;
}

/* Residences list: closed unless asked for (owner, 4 Oct), no collapsed tab. */
body[data-ui="v2"]:not([data-rail-open]) #rail {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

/* ------------------------------------------------------------ shared atoms */
body[data-ui="v2"] .v2 {
  position: fixed;
  inset: 0;
  z-index: var(--z-chrome);
  pointer-events: none;
  font-family: var(--font-ui);
  color: var(--ink);
}

body[data-ui="v2"] .v2 > *,
body[data-ui="v2"] .v2-tl > *,
body[data-ui="v2"] .v2-tr > * {
  pointer-events: auto;
}

.v2 [hidden],
.v2-sheet [hidden],
.v2-tourbar [hidden] {
  display: none !important;
}

.v2-glass,
.v2-sheet {
  border: 1px solid var(--border);
  background: var(--surface-glass);
  -webkit-backdrop-filter: var(--glass-filter);
  backdrop-filter: var(--glass-filter);
  box-shadow: var(--elev-1);
}

.v2-round {
  position: relative;
  display: inline-grid;
  flex: none;
  place-items: center;
  width: var(--v2-chip);
  height: var(--v2-chip);
  margin: 0;
  padding: 0;
  border-radius: 50%;
  color: var(--ink);
  cursor: pointer;
}

.v2-pill {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 8px;
  height: var(--v2-chip);
  margin: 0;
  padding: 0 16px 0 14px;
  border-radius: var(--r-pill);
  color: var(--ink);
  font: var(--fw-semibold) var(--fs-14, 14px) / 1 var(--font-ui);
  white-space: nowrap;
  cursor: pointer;
}

.v2-round:hover,
.v2-pill.v2-glass:hover {
  background: var(--surface-glass-strong);
}

.v2-round:focus-visible,
.v2-pill:focus-visible,
.v2-nav__btn:focus-visible,
.v2-tile:focus-visible,
.v2-brand button:focus-visible,
.v2-lang__btn:focus-visible {
  outline: 2px solid var(--focus-ring-outer);
  outline-offset: 1px;
  box-shadow: 0 0 0 5px var(--focus-ring);
}

.v2 .icon,
.v2-sheet .icon,
.v2-tourbar .icon {
  width: 20px;
  height: 20px;
}

.v2-badge {
  position: absolute;
  top: 3px;
  right: 3px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: var(--r-pill);
  background: var(--timber-ink);
  color: var(--white);
  font: var(--fw-bold) 10px / 17px var(--font-ui);
  text-align: center;
}

/* ---------------------------------------------------------------- top left */
.v2-tl,
.v2-tr {
  position: fixed;
  top: var(--v2-top);
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.v2-tl {
  left: calc(var(--safe-left) + var(--v2-gap));
}

.v2-tr {
  right: calc(var(--safe-right) + var(--v2-gap));
}

.v2-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: var(--v2-chip);
  padding: 0 12px;
  border-radius: var(--r-pill);
}

.v2-brand button {
  display: inline-flex;
  align-items: center;
  height: 100%;
  margin: 0;
  padding: 0;
  border-radius: var(--r-xs);
  cursor: pointer;
}

.v2-brand__home .brand-logo__img {
  height: 30px;
}

.v2-brand__rule {
  width: 1px;
  height: 22px;
  background: var(--border-strong);
}

.v2-brand__mark .brand-mb__img {
  height: 26px;
}

.v2-title {
  display: grid;
  gap: 1px;
  height: var(--v2-chip);
  margin: 0;
  padding: 5px 16px;
  border-radius: var(--r-pill);
  align-content: center;
  line-height: 1.1;
}

.v2-title__main {
  font-weight: var(--fw-bold);
  font-size: var(--fs-14, 14px);
}

.v2-title__sub {
  color: var(--ink-muted);
  font-size: 11.5px;
}

/* --------------------------------------------------------------- top right */
.v2-lang {
  display: inline-flex;
  height: var(--v2-chip);
  padding: 4px;
  gap: 2px;
  border-radius: var(--r-pill);
}

.v2-lang__btn {
  min-width: 38px;
  margin: 0;
  padding: 0 8px;
  border-radius: var(--r-pill);
  color: var(--ink-muted);
  font: var(--fw-bold) var(--fs-13) / 1 var(--font-ui);
  cursor: pointer;
}

.v2-lang__btn[aria-pressed="true"] {
  background: var(--basalt);
  color: var(--mist);
}

.v2-contact {
  border: 0;
  background: var(--pine);
  color: var(--pine-ink);
  box-shadow: var(--elev-1);
}

.v2-contact:hover {
  background: var(--pine-hover);
}

/* ---------------------------------------------------------------------- nav */
.v2-nav {
  position: fixed;
  border-radius: var(--r-pill);
}

.v2-nav__list {
  display: flex;
  gap: 2px;
  padding: 4px;
}

.v2-nav__btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  margin: 0;
  border-radius: var(--r-pill);
  color: var(--ink-muted);
  font: var(--fw-semibold) var(--fs-14, 14px) / 1 var(--font-ui);
  white-space: nowrap;
  cursor: pointer;
}

.v2-nav__btn:hover {
  color: var(--ink);
  background: var(--hover);
}

.v2-nav__btn[aria-current="page"],
.v2-nav__btn[aria-expanded="true"] {
  background: var(--basalt);
  color: var(--mist);
}

/* Desktop: a glass bar in the top row, after the brand. */
body[data-v2-nav="top"] .v2-nav {
  top: var(--v2-top);
  left: 50%;
  transform: translateX(-50%);
}

body[data-v2-nav="top"] .v2-nav__btn {
  height: 36px;
  padding: 0 14px;
}

/* Bottom tab bar (phones in portrait, tablets). */
body[data-v2-nav="tabbar"] .v2-nav {
  left: calc(var(--safe-left) + var(--v2-gap));
  right: calc(var(--safe-right) + var(--v2-gap));
  bottom: calc(var(--safe-bottom) + var(--v2-gap));
  max-width: 600px;
  margin: 0 auto;
  border-radius: 20px;
}

body[data-v2-nav="tabbar"] .v2-nav__list {
  display: grid;
  grid-auto-columns: 1fr;
  grid-auto-flow: column;
  height: 60px;
}

body[data-v2-nav="tabbar"] .v2-nav__btn {
  flex-direction: column;
  gap: 4px;
  border-radius: 14px;
  font-size: 11px;
}

body[data-v2-nav="tabbar"] .v2-nav__btn[aria-current="page"],
body[data-v2-nav="tabbar"] .v2-nav__btn[aria-expanded="true"] {
  background: var(--basalt-a08);
  color: var(--ink);
  font-weight: var(--fw-bold);
}

body[data-v2-nav="tabbar"] .v2-nav__btn .icon {
  width: 22px;
  height: 22px;
}

/* Compact (phone on its side): icons on the left edge, clear of the notch. */
body[data-v2-nav="rail"] .v2-nav {
  top: 50%;
  left: calc(var(--safe-left) + var(--v2-gap));
  transform: translateY(-50%);
  border-radius: 22px;
}

body[data-v2-nav="rail"] .v2-nav__list {
  flex-direction: column;
}

body[data-v2-nav="rail"] .v2-nav__btn {
  width: 44px;
  height: 44px;
  border-radius: 14px;
}

body[data-v2-nav="rail"] .v2-nav__label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.v2-nav__more .v2-badge {
  top: 4px;
  right: calc(50% - 22px);
}

/* ----------------------------------------------------------- touch: phones */
body[data-ui="v2"][data-layout="portrait"] .v2-share .v2-label,
body[data-ui="v2"][data-layout="compact"] .v2-share .v2-label,
body[data-ui="v2"][data-layout="tablet"] .v2-share .v2-label,
body[data-ui="v2"][data-layout="compact"] .v2-contact .v2-label {
  display: none;
}

body[data-ui="v2"][data-layout="portrait"] .v2-share,
body[data-ui="v2"][data-layout="compact"] .v2-share,
body[data-ui="v2"][data-layout="tablet"] .v2-share,
body[data-ui="v2"][data-layout="compact"] .v2-contact {
  justify-content: center;
  width: var(--v2-chip);
  padding: 0;
}

body[data-ui="v2"][data-layout="portrait"] .v2-brand,
body[data-ui="v2"][data-layout="compact"] .v2-brand {
  gap: 8px;
  padding: 0 10px;
}

body[data-ui="v2"][data-layout="portrait"] .v2-brand__home .brand-logo__img,
body[data-ui="v2"][data-layout="compact"] .v2-brand__home .brand-logo__img {
  height: 25px;
}

body[data-ui="v2"][data-layout="portrait"] .v2-brand__mark .brand-mb__img,
body[data-ui="v2"][data-layout="compact"] .v2-brand__mark .brand-mb__img {
  height: 19px;
}

/* Small phones (≤ 380 px): the contact pill keeps only its icon. */
@media (max-width: 380px) {
  body[data-ui="v2"] .v2-contact .v2-label {
    display: none;
  }

  body[data-ui="v2"] .v2-contact {
    justify-content: center;
    width: var(--v2-chip);
    padding: 0;
  }
}

/* Desktop below 1500 px: share keeps its icon (its name is the accessible label). */
@media (max-width: 1499px) {
  body[data-ui="v2"][data-layout="desk"] .v2-share .v2-label {
    display: none;
  }

  body[data-ui="v2"][data-layout="desk"] .v2-share {
    justify-content: center;
    width: var(--v2-chip);
    padding: 0;
  }
}

/* Desktop 1100–1299 px: the language moves into Más. */
@media (max-width: 1299px) {
  body[data-ui="v2"][data-layout="desk"] .v2-lang {
    display: none !important;
  }
}

/* The language row in Más is redundant where the top bar has ES|EN. */
@media (min-width: 1300px) {
  body[data-ui="v2"][data-layout="desk"] .v2-more .settings__group:has(#settings-lang-label) {
    display: none;
  }
}

/* Day/dusk is covered by the Sun control. */
body[data-ui="v2"] .v2-more .settings__group:has(#settings-tod-label) {
  display: none;
}

/* ----------------------------------------------- stage insets per layout */
body[data-ui="v2"][data-v2-nav="tabbar"][data-chrome="stage"],
body[data-ui="v2"][data-v2-nav="tabbar"][data-chrome="stage"][data-rail-open],
body[data-ui="v2"][data-v2-nav="tabbar"][data-chrome="stage"][data-drawer-visible] {
  --stage-inset-bottom: calc(var(--safe-bottom) + var(--v2-gap) + var(--v2-nav-space));
}

body[data-ui="v2"][data-layout="portrait"][data-chrome="stage"] #sheet[data-unit] {
  --v2-peek: var(--sheet-peek);
}

body[data-ui="v2"][data-layout="portrait"][data-chrome="stage"]:has(#sheet[data-unit]) {
  --stage-inset-bottom: calc(var(--safe-bottom) + var(--v2-gap) + var(--v2-nav-space) + var(--sheet-peek));
}

body[data-ui="v2"][data-layout="portrait"][data-chrome="stage"][data-sheet="half"] {
  --stage-inset-bottom: calc(52dvh + var(--v2-gap));
}

body[data-ui="v2"][data-layout="compact"],
body[data-ui="v2"][data-layout="compact"][data-chrome="stage"][data-drawer-visible] {
  --stage-inset-left: calc(var(--safe-left) + var(--v2-gap) * 2 + var(--v2-rail-space));
  --stage-inset-right: calc(var(--safe-right) + var(--v2-gap));
  --stage-inset-bottom: calc(var(--safe-bottom) + var(--v2-gap));
}

body[data-ui="v2"][data-layout="compact"][data-chrome="stage"][data-rail-open] {
  --stage-inset-left: calc(var(--safe-left) + var(--v2-gap) * 3 + var(--v2-rail-space) + min(340px, 44vw));
}

body[data-ui="v2"][data-layout="compact"][data-chrome="stage"][data-drawer-visible] {
  --stage-inset-right: calc(var(--safe-right) + var(--v2-gap) * 2 + min(340px, 44vw));
}

/* ----------------------------------------------------- portrait: the sheet */
/* The sheet reaches the screen edge; its bottom padding (= tab bar + safe area) keeps every line of
   content above the tab bar. sheet.js reads that padding as the safe area, so the peek sits just
   above the bar and only empty padding is ever behind it. */
body[data-ui="v2"][data-layout="portrait"] #sheet {
  bottom: 0;
  height: calc(var(--vvh, 100dvh) - var(--chrome-top));
  padding-bottom: calc(var(--safe-bottom) + var(--v2-nav-space));
  /* Whatever part of the (translated) sheet lies under the tab bar is clipped, at every snap and
     while dragging (--sheet-y is the sheet's live offset, set by sheet.js). */
  clip-path: inset(0 0 calc(var(--sheet-y, 0px) + var(--safe-bottom) + var(--v2-nav-space)) 0);
}

/* The tab bar stays above the sheet (the sheet slides under it). */
body[data-ui="v2"][data-v2-nav="tabbar"] .v2 {
  z-index: calc(var(--z-sheet) + 1);
}

/* No residence selected: the sheet stays out of the way until "Residencias" raises it. */
body[data-ui="v2"][data-layout="portrait"] #sheet[data-snap="peek"]:not([data-unit]) {
  transform: translateY(calc(100% + var(--v2-nav-space) + 24px)) !important;
  visibility: hidden;
}

body[data-ui="v2"][data-layout="portrait"] #toast-region,
body[data-ui="v2"][data-layout="tablet"] #toast-region {
  bottom: calc(var(--safe-bottom) + var(--v2-nav-space) + var(--v2-gap) + 8px);
}

/* ------------------------------------------- compact: side panels, not sheets */
body[data-ui="v2"][data-layout="compact"] #rail {
  top: calc(var(--chrome-top));
  bottom: calc(var(--safe-bottom) + var(--v2-gap));
  left: calc(var(--safe-left) + var(--v2-gap) * 2 + var(--v2-rail-space));
  width: min(340px, 44vw);
}

body[data-ui="v2"][data-layout="compact"] #drawer {
  top: calc(var(--chrome-top));
  bottom: calc(var(--safe-bottom) + var(--v2-gap));
  right: calc(var(--safe-right) + var(--v2-gap));
  width: min(340px, 44vw);
}

body[data-ui="v2"][data-layout="compact"] #drawer .res-hero {
  display: none;
}

body[data-ui="v2"][data-layout="compact"] #list {
  top: var(--chrome-top);
  left: var(--stage-inset-left);
  right: var(--stage-inset-right);
  max-height: calc(var(--vvh, 100dvh) - var(--chrome-top) - var(--safe-bottom) - var(--v2-gap));
}

/* ------------------------------------------------------- stage tools (dock) */
/* Exterior modes only; apartment modes keep their classic toolbar (rotate / zoom / overview). */
body[data-ui="v2"] .stage-ui:is([data-mode="exterior"], [data-mode="floor"]) .st-tool:is([data-tool="rotateLeft"], [data-tool="rotateRight"]),
body[data-ui="v2"] .st-toolbar__divider {
  display: none;
}

body[data-ui="v2"] .stage-ui:not(:is([data-mode="exterior"], [data-mode="floor"])) .v2-tool {
  display: none;
}

body[data-ui="v2"] .v2-tool {
  display: inline-flex;
  gap: 6px;
  width: auto;
  min-width: var(--touch, 44px);
  padding: 0 12px;
  border-radius: var(--r-pill);
  font: var(--fw-semibold) var(--fs-13) / 1 var(--font-ui);
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}

body[data-ui="v2"] .v2-tool[hidden] {
  display: none;
}

body[data-ui="v2"] .v2-tool--avail[aria-pressed="true"],
body[data-ui="v2"] .v2-tool--views[aria-expanded="true"] {
  background: var(--basalt);
  color: var(--mist);
}

body[data-ui="v2"] .st-toolbar .phv-sound {
  width: var(--touch, 44px);
  height: var(--touch, 44px);
  box-shadow: none;
}

/* The speaker shows only while the ambient sound plays (one-tap mute); Más has the switch. */
body[data-ui="v2"] .st-toolbar .phv-sound[aria-pressed="false"]:not([data-busy]) {
  display: none;
}

/* Desktop / tablet: one row at the bottom right, next to the compass. */
body[data-ui="v2"]:not([data-layout="portrait"]):not([data-layout="compact"]) .stage-ui:is([data-mode="exterior"], [data-mode="floor"]) .st-dock-zone {
  /* Keep the zone full width (it is an inline-size container): the toolbar aligns right. */
  right: calc(var(--stage-inset-right, 16px) + 60px);
  justify-content: flex-end;
}

body[data-ui="v2"] .stage-ui:is([data-mode="exterior"], [data-mode="floor"]) .st-dock {
  margin-bottom: 0 !important;
}

body[data-ui="v2"]:not([data-layout="portrait"]):not([data-layout="compact"]) .st-toolbar__group {
  margin-left: 6px;
  padding-left: 6px;
  border-left: 1px solid var(--border-strong);
}

/* Touch: a column on the right edge (Sun on top), each tool its own glass circle. */
body[data-ui="v2"]:is([data-layout="portrait"], [data-layout="compact"]) .stage-ui:is([data-mode="exterior"], [data-mode="floor"]) .st-dock-zone {
  right: calc(var(--stage-inset-right, 8px));
  bottom: calc(var(--stage-inset-bottom, 8px) + 56px);
  justify-content: flex-end;
}

body[data-ui="v2"]:is([data-layout="portrait"], [data-layout="compact"]) .stage-ui:is([data-mode="exterior"], [data-mode="floor"]) .st-toolbar {
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  padding: 0;
  border: 0;
  background: none;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  box-shadow: none;
}

body[data-ui="v2"]:is([data-layout="portrait"], [data-layout="compact"]) .stage-ui:is([data-mode="exterior"], [data-mode="floor"]) .st-toolbar > :is(.st-tool, .phv-sound) {
  border: 1px solid var(--st-glass-border, var(--border));
  background: var(--st-glass-bg, var(--surface-glass));
  -webkit-backdrop-filter: var(--glass-filter);
  backdrop-filter: var(--glass-filter);
  box-shadow: var(--elev-1);
}

body[data-ui="v2"]:is([data-layout="portrait"], [data-layout="compact"]) .stage-ui:is([data-mode="exterior"], [data-mode="floor"]) .st-toolbar > .st-sun-btn {
  order: -1;
}

body[data-ui="v2"]:is([data-layout="portrait"], [data-layout="compact"]) .stage-ui:is([data-mode="exterior"], [data-mode="floor"]) :is(.st-toolbar__group, .st-tool[data-tool="home"]) {
  display: none;
}

body[data-ui="v2"]:is([data-layout="portrait"], [data-layout="compact"]) .v2-tool .v2-label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

body[data-ui="v2"]:is([data-layout="portrait"], [data-layout="compact"]) .v2-tool {
  width: var(--touch, 44px);
  padding: 0;
}

body[data-ui="v2"]:is([data-layout="portrait"], [data-layout="compact"]) .v2-tool--avail[aria-pressed="true"],
body[data-ui="v2"]:is([data-layout="portrait"], [data-layout="compact"]) .v2-tool--views[aria-expanded="true"] {
  background: var(--basalt) !important;
}

/* Compass: smaller, under the tools; attribution and data credits compact. */
body[data-ui="v2"] .st-compass {
  width: 48px;
  height: 48px;
}

body[data-ui="v2"] .st-compass__svg {
  width: 42px;
  height: 42px;
}

body[data-ui="v2"] .st-credits__sources {
  display: none;
}

body[data-ui="v2"] .st-credits {
  max-width: none;
  min-height: 24px;
  padding: 2px 8px;
  font-size: 11px;
}

body[data-ui="v2"] .st-attrib {
  max-width: min(30em, 60vw);
  padding: 2px 6px;
  font-size: 10px;
  line-height: 1.3;
}

/* Touch: data credits sit beside the compass, the tools column above both. */
body[data-ui="v2"]:is([data-layout="portrait"], [data-layout="compact"]) .st-corner {
  flex-direction: row;
  align-items: center;
}

/* Touch: the required attribution moves to the bottom-left edge, out of the tools column. */
body[data-ui="v2"]:is([data-layout="portrait"], [data-layout="compact"]) .st-attrib {
  position: fixed;
  left: var(--stage-inset-left, 8px);
  right: auto;
  bottom: var(--stage-inset-bottom, 8px);
  max-width: calc(100vw - var(--stage-inset-left, 8px) - var(--stage-inset-right, 8px) - 130px);
  align-items: flex-start;
  text-align: left;
  font-size: 9px;
}

/* The Sun panel (ui/stage/sun.js): above the tools on desktop, a sheet on touch screens. */
body[data-ui="v2"]:not([data-layout="portrait"]):not([data-layout="compact"]) .st-sun {
  left: auto !important;
  right: calc(var(--stage-inset-right, 16px) + 68px) !important;
  bottom: calc(var(--stage-inset-bottom, 16px) + 60px) !important;
}

body[data-ui="v2"][data-layout="portrait"] .st-sun {
  position: fixed;
  left: 0 !important;
  right: 0 !important;
  bottom: var(--stage-inset-bottom, 0px) !important;
  width: auto;
  border-radius: 20px 20px 0 0;
  padding-bottom: var(--sp-4);
}

body[data-ui="v2"][data-layout="compact"] .st-sun {
  position: fixed;
  top: var(--chrome-top);
  left: auto !important;
  right: calc(var(--safe-right) + 8px) !important;
  bottom: auto !important;
  width: min(360px, 48vw);
  max-height: calc(var(--vvh, 100dvh) - var(--chrome-top) - 8px);
  overflow: auto;
}

/* Touch: the Sun chip keeps its time (the classic narrow-dock rule hid it). */
body[data-ui="v2"]:is([data-layout="portrait"], [data-layout="compact"]) .st-sun-btn__time {
  display: inline !important;
}

/* ------------------------------------------------------------- sheets */
.v2-sheet {
  color: var(--ink);
  font-family: var(--font-ui);
  background: var(--surface-glass-strong);
}

.v2-sheet__grip {
  display: none;
  width: 36px;
  height: 4px;
  margin: 0 auto 8px;
  border-radius: 2px;
  background: var(--basalt-a20);
}

.v2-sheet__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.v2-sheet__title {
  margin: 0;
  font: var(--fw-bold) var(--fs-16, 16px) / 1.2 var(--font-ui);
}

.v2-sheet__eyebrow {
  margin: 14px 0 6px;
  color: var(--ink-muted);
  font-size: 11px;
  font-weight: var(--fw-bold);
  letter-spacing: .08em;
  text-transform: uppercase;
}

body[data-layout="desk"] .v2-sheet__hint,
body[data-layout="tablet"] .v2-sheet__hint {
  display: none;
}

.v2-sheet__hint {
  margin: 10px 0 0;
  color: var(--ink-muted);
  font-size: 12px;
}

.v2-sheet__credit {
  display: grid;
  gap: 6px;
  justify-items: start;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 12px;
}

.v2-link {
  margin: 0;
  padding: 4px 0;
  color: var(--ink-muted);
  font: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

.v2-tiles {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.v2-tiles--cam {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.v2-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 64px;
  margin: 0;
  padding: 8px 6px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-raised, var(--paper));
  color: var(--ink);
  font: var(--fw-semibold) 12.5px / 1.2 var(--font-ui);
  text-align: center;
  cursor: pointer;
}

.v2-tile:hover {
  border-color: var(--border-strong);
}

.v2-presets .st-presets {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
  padding: 0;
  overflow: visible;
  border: 0;
  border-radius: 0;
  background: none;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  box-shadow: none;
}

.v2-presets .st-preset {
  min-height: 52px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-raised, var(--paper));
  color: var(--ink);
  font-size: var(--fs-14, 14px);
}

.v2-presets .st-preset[hidden] {
  display: none;
}

/* Vistas: a popover above the tools (desktop) / a bottom sheet (touch). */
.v2-views {
  position: fixed;
  width: 380px;
  padding: 14px 16px 16px;
  border-radius: 20px;
  pointer-events: auto;
}

body[data-v2-nav="top"] .v2-views,
body[data-layout="tablet"] .v2-views {
  right: calc(var(--stage-inset-right, 16px) + 68px);
  bottom: calc(var(--stage-inset-bottom, 16px) + 60px);
}

body[data-layout="portrait"] .v2-views {
  left: 0;
  right: 0;
  bottom: 0;
  width: auto;
  padding-bottom: calc(var(--safe-bottom) + 16px);
  border-radius: 22px 22px 0 0;
}

body[data-layout="compact"] .v2-views {
  top: var(--chrome-top);
  right: calc(var(--safe-right) + 8px);
  width: min(380px, 50vw);
  max-height: calc(var(--vvh, 100dvh) - var(--chrome-top) - 8px);
  overflow: auto;
}

body[data-layout="portrait"] .v2-sheet__grip {
  display: block;
}

/* Más: a <dialog> (modal: focus trap, Escape, backdrop). */
.v2-more {
  width: min(420px, calc(100vw - 24px));
  max-height: calc(var(--vvh, 100dvh) - 24px);
  margin: 0;
  padding: 14px 16px 16px;
  overflow: auto;
  border-radius: 20px;
}

.v2-more::backdrop {
  background: var(--basalt-a20);
}

body[data-layout="desk"] .v2-more,
body[data-layout="tablet"] .v2-more {
  position: fixed;
  top: calc(var(--v2-top) + var(--v2-chip) + 8px);
  right: calc(var(--safe-right) + var(--v2-gap));
  left: auto;
}

body[data-layout="portrait"] .v2-more {
  position: fixed;
  top: auto;
  right: 0;
  bottom: 0;
  left: 0;
  width: auto;
  max-width: none;
  max-height: 86dvh;
  padding-bottom: calc(var(--safe-bottom) + 16px);
  border-radius: 22px 22px 0 0;
}

body[data-layout="compact"] .v2-more {
  position: fixed;
  top: calc(var(--safe-top) + 8px);
  right: calc(var(--safe-right) + 8px);
  bottom: calc(var(--safe-bottom) + 8px);
  left: auto;
  width: min(420px, 52vw);
  max-height: none;
}

/* The adopted Ajustes content, laid out as rows. */
.v2-more .settings {
  display: grid;
  gap: 2px;
}

.v2-more .settings__group {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.v2-more .settings__group:last-child {
  border-bottom: 0;
}

.v2-more .settings__group[hidden] {
  display: none;
}

.v2-more .v2-sound-group {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

/* --------------------------------------------------------------- tour bar */
.v2-tourbar {
  position: absolute;
  left: 50%;
  bottom: calc(var(--safe-bottom) + var(--v2-gap, 12px));
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: calc(100vw - 24px);
  padding: 6px;
  border-radius: var(--r-pill);
  transform: translateX(-50%);
}

.v2-tourbar .vw-tour__modes {
  position: static;
  box-shadow: none;
}

.v2-rooms-btn {
  height: 44px;
  background: none;
}

.v2-rooms-btn[aria-expanded="true"] {
  background: var(--basalt);
  color: var(--mist);
}

.v2-rooms-btn[aria-expanded="true"] .v2-rooms-btn__chev {
  transform: rotate(180deg);
}

body[data-ui="v2"] .vw-tour[data-v2-rooms="closed"] .vw-tour__rooms {
  display: none;
}

body[data-ui="v2"] .vw-tour .vw-tour__rooms {
  bottom: calc(var(--safe-bottom) + var(--v2-gap, 12px) + 68px);
}

body[data-ui="v2"] .vw-tour .vw-tour__counter {
  display: none;
}

body[data-ui="v2"] .vw-tour .vw-tour__head {
  top: var(--chrome-top);
}

/* Touch tour: compact header, the minimap only with the rooms. */
body[data-ui="v2"]:is([data-layout="portrait"], [data-layout="compact"]) .vw-tour[data-v2-rooms="closed"] .vw-map {
  display: none;
}

body[data-ui="v2"]:is([data-layout="portrait"], [data-layout="compact"]) .vw-tour .vw-map {
  bottom: calc(var(--safe-bottom) + var(--v2-gap) + 68px + 132px);
}

body[data-ui="v2"]:is([data-layout="portrait"], [data-layout="compact"]) .vw-tour .vw-tour__rooms {
  left: calc(var(--safe-left) + var(--v2-gap));
  right: calc(var(--safe-right) + var(--v2-gap));
}

body[data-ui="v2"]:is([data-layout="portrait"], [data-layout="compact"]) .vw-tour__head {
  left: calc(var(--safe-left) + var(--v2-gap));
  max-width: calc(100vw - var(--safe-left) - var(--safe-right) - 2 * var(--v2-gap));
  padding: 8px 12px !important;
  gap: 4px;
}

body[data-ui="v2"]:is([data-layout="portrait"], [data-layout="compact"]) .vw-tour__title {
  font-size: var(--fs-20) !important;
}

body[data-ui="v2"]:is([data-layout="portrait"], [data-layout="compact"]) .vw-tour__caption {
  display: -webkit-box;
  overflow: hidden;
  font-size: 13px;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

body[data-ui="v2"][data-layout="compact"] .vw-tour__head {
  max-width: min(420px, 50vw);
}

body[data-ui="v2"][data-layout="compact"] .vw-tour__caption {
  -webkit-line-clamp: 1;
}

/* The chips stay: they carry the known-issue badge (PB-3BR bathroom 2), which must remain visible. */
body[data-ui="v2"][data-layout="compact"] .vw-tour__eyebrow {
  display: none;
}

body[data-ui="v2"]:is([data-layout="portrait"], [data-layout="compact"]) .v2-tourbar .vw-tour__mode-label {
  font-size: 13px;
}

body[data-ui="v2"][data-layout="portrait"] .v2-tourbar .vw-tour__mode[data-mode="photos"] .vw-tour__mode-label,
body[data-ui="v2"][data-layout="portrait"] .v2-rooms-btn .v2-label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.v2-tour-more {
  background: none;
}

/* Pages (plan, gallery, location…): their content clears the bottom tab bar. */
body[data-ui="v2"][data-v2-nav="tabbar"] #views .vw:not(.vw-tour) {
  padding-bottom: var(--v2-nav-space);
}

/* ---------------------------------------------------- hide while orbiting */
body[data-ui="v2"] .v2 > *,
body[data-ui="v2"] .st-dock-zone,
body[data-ui="v2"] .st-corner > :not(.st-attrib) {
  transition: opacity var(--dur, 200ms) var(--ease, ease);
}

body[data-ui="v2"][data-chrome-idle] .v2 > *,
body[data-ui="v2"][data-chrome-idle] .st-dock-zone,
body[data-ui="v2"][data-chrome-idle] .st-corner > :not(.st-attrib),
body[data-ui="v2"][data-chrome-idle] #sheet {
  opacity: 0;
  pointer-events: none;
}

/* ------------------------------------------------- splash and presentation */
body[data-ui="v2"][data-splash] .v2 {
  opacity: 0;
}

body[data-ui="v2"][data-presenting] .v2,
body[data-ui="v2"][data-presenting] .v2-tourbar {
  display: none !important;
}

@media (prefers-reduced-motion: reduce) {
  body[data-ui="v2"] .v2 > *,
  body[data-ui="v2"] .st-dock-zone,
  body[data-ui="v2"] .st-corner > * {
    transition: none;
  }
}

@media (pointer: coarse) {
  .v2-lang__btn {
    min-width: 44px;
  }
}

/* Bottom tab bar: a denser glass, so the sheet sliding under it never shows through. */
body[data-ui="v2"][data-v2-nav="tabbar"] .v2-nav {
  background: var(--surface-glass-strong);
}

/* Compact: pages start right of the edge rail. */
body[data-ui="v2"][data-layout="compact"][data-v2-show~="nav"] #views {
  left: calc(var(--safe-left) + var(--v2-gap) + var(--v2-rail-space));
}

/* Short screens: the classic tour hid the room carousel; in v2 "Habitaciones" opens it on demand. */
body[data-ui="v2"] .vw-tour[data-v2-rooms="open"] .vw-tour__rooms {
  display: flex !important;
}
