/* Additive comparison controls; original Grand River styles and tokens remain. */
#overview-view {
  position: absolute;
  inset: 0;
}
#overview-view .mapboxgl-ctrl-bottom-left {
  bottom: 22px;
}
#overview-view .mapboxgl-ctrl-bottom-right {
  bottom: 22px;
}
#overview-view .mapboxgl-ctrl-attrib {
  font-size: 10px;
}
#overview-view .mapboxgl-canvas:focus-visible {
  outline: 2px solid var(--brass-600);
  outline-offset: -2px;
}
#replay-view {
  font-size: 11px;
}
.subset-camera {
  border: 0;
  background: none;
  padding: 0;
  text-align: left;
  cursor: pointer;
}
.subset-camera:hover {
  text-decoration: underline;
}
.continuous-placement label {
  display: block;
  font-size: 11px;
}
.continuous-placement input {
  width: 100%;
  accent-color: var(--brass-600);
}
#error-panel {
  z-index: 110;
  max-width: 420px;
  background: var(--surface, white);
  color: var(--text-primary);
  padding: 24px;
  border-radius: 16px;
}
#error-panel button {
  margin: 8px 8px 0 0;
}
body[data-renderer="mapbox"] .movement-hint,
body[data-renderer="mapbox"] .touch-controls {
  display: none;
}
@media (max-width: 760px) {
  .header .brand-place {
    display: none;
  }
  .header .top-actions {
    gap: 4px;
  }
  .header .top-actions button {
    padding: 8px;
    min-height: 40px;
  }
  #replay-view {
    max-width: 68px;
    white-space: normal;
  }
  .community-layout .lot-explorer {
    max-height: calc(100dvh - 250px);
    overflow: auto;
  }
  .community-layout .lot-inspector {
    max-height: calc(100dvh - 270px);
    overflow: auto;
  }
  #overview-view .mapboxgl-ctrl-attrib {
    max-width: 240px;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

@media (max-width: 900px) {
  .header .save-view {
    display: block;
  }
}
@media (max-width: 760px) {
  .header {
    gap: 8px;
    left: 15px;
    right: 15px;
  }
  .header .brand > img {
    width: 124px;
  }
  .header .top-actions {
    gap: 3px;
  }
  .header .top-actions button {
    padding: 6px;
    font-size: 10px;
  }
  .header #save-view {
    width: 40px;
    white-space: normal;
  }
  .header #replay-view {
    width: 48px;
  }
  .header #fullscreen {
    width: 26px;
  }
  .community-layout .lot-inspector {
    top: auto;
    bottom: 126px;
    left: 15px;
    right: 15px;
    width: auto;
    max-height: min(360px, 46dvh);
  }
}

@media (max-width: 760px) {
  .touch-controls {
    bottom: 112px;
  }
}

.navigation-help {
  position: absolute;
  z-index: 5;
  top: 84px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--white);
  font-size: 11px;
  padding: 6px 12px;
  background: rgba(20, 32, 29, 0.76);
  border-radius: 18px;
  backdrop-filter: blur(12px);
  white-space: nowrap;
}
.navigation-help > span {
  font-size: 10px;
  opacity: 0.8;
}
.navigation-help summary {
  cursor: pointer;
}
.navigation-help details {
  margin: 0;
}
.navigation-help details p {
  position: absolute;
  top: 30px;
  left: 0;
  right: 0;
  background: var(--ink);
  white-space: normal;
  padding: 16px;
  border-radius: 14px;
  font-size: 12px;
  line-height: 1.6;
}
.navigation-help button {
  padding: 5px 9px;
  font-size: 10px;
}
/* Extend the existing phone selection pattern to the narrow tablet canvas. */
@media (max-width: 1099px) {
  body[data-preview="cesium-navigation"][data-activity="walk"] .lot-inspector {
    display: none;
  }
}
@media (min-width: 761px) and (max-width: 1099px) {
  body[data-preview="cesium-navigation"]
    .community-layout:has(.lot-inspector)
    .lot-explorer {
    display: none;
  }
  body[data-preview="cesium-navigation"] .navigation-help {
    left: 24px;
    transform: none;
  }
  body[data-preview="cesium-navigation"] .navigation-help > span {
    display: none;
  }
}
@media (max-width: 760px) {
  .navigation-help {
    top: 72px;
    gap: 8px;
    font-size: 10px;
  }
  .navigation-help > span {
    display: none;
  }
  .navigation-help details p {
    min-width: 220px;
    left: -20px;
  }
  body[data-preview="cesium-navigation"] .community-layout .lot-explorer {
    top: 118px;
    max-height: calc(100dvh - 280px);
  }
  body[data-preview="cesium-navigation"] .walk-label {
    bottom: 176px;
    max-width: 190px;
  }
}

/* Reuse the buyer experience's on-demand drawer pattern with retained controls. */
.community-layout .community-toolbar {
  position: absolute;
  top: 124px;
  left: 30px;
  width: min(640px, calc(100% - 60px));
  display: grid;
  grid-template-columns: minmax(0, 1fr) 96px;
  align-items: stretch;
  gap: 8px;
  padding: 6px;
  border-radius: 16px;
  background: var(--warm-paper);
  box-shadow: var(--shadow-card, 0 8px 28px rgb(10 25 12 / 16%));
  pointer-events: auto;
}
.community-layout .phase-filter {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}
.community-layout .phase-button {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  min-height: 44px;
  height: auto;
  padding: 8px 12px;
  gap: 3px;
  text-align: left;
  white-space: normal;
  line-height: 1.3;
  min-width: 0;
}
.community-layout .phase-button-title {
  font-size: 12px;
  font-weight: 600;
}
.community-layout .phase-button-status {
  font-size: 10px;
  font-weight: 400;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.community-layout .explorer-trigger {
  min-width: 0;
  min-height: 44px;
  height: auto;
  padding: 6px 8px;
  white-space: normal;
  line-height: 1.25;
  font-size: 12px;
}
.community-layout .lot-explorer#community-lot-browser {
  top: 194px;
  max-height: calc(100dvh - 306px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.community-layout #community-lot-browser > .p-6:first-child {
  position: relative;
  padding: 14px 60px 14px 16px;
  flex-shrink: 0;
}
.community-layout #community-lot-browser .explorer-topline {
  margin: 0;
}
.community-layout #community-lot-browser .explorer-topline > span {
  display: none;
}
.community-layout #community-lot-browser .explorer-topline button {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 44px;
  height: 44px;
}
.community-layout #community-lot-browser h3 {
  font-size: 22px;
  letter-spacing: -0.6px;
}
.community-layout
  #community-lot-browser
  > .p-6:not(:first-child):not(:last-child) {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0 16px 16px;
}
.community-layout #community-lot-browser > .p-6:last-child {
  flex-shrink: 0;
  padding: 6px 12px;
  min-height: 48px;
}
.community-layout .lot-inspector > .p-6:first-child {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--warm-paper);
}
body[data-activity="walk"] .community-layout .community-toolbar {
  display: none;
}
.community-layout .lot-grid .lot-sold {
  flex-direction: column;
  gap: 1px;
  line-height: 1.1;
}
.community-layout .lot-sold small {
  font-size: 8px;
  font-weight: 400;
}
@media (max-height: 800px) {
  .community-layout .lot-explorer > .p-6:not(:first-child):not(:last-child) {
    overflow-y: auto;
    flex: 1;
    min-height: 0;
  }
}

/* Keep the retained controls reachable without shrinking phone hit targets. */
@media (max-width: 760px),
  (max-width: 960px) and (max-height: 500px) and (pointer: coarse) {
  :root {
    --mobile-top: calc(12px + env(safe-area-inset-top, 0px));
    --mobile-left: max(12px, env(safe-area-inset-left, 0px));
    --mobile-right: max(12px, env(safe-area-inset-right, 0px));
    --mobile-bottom: env(safe-area-inset-bottom, 0px);
    --mobile-header-height: 44px;
    --mobile-panel-top: calc(
      var(--mobile-top) + var(--mobile-header-height) + 60px
    );
  }
  html,
  body {
    width: 100%;
    height: 100%;
    overscroll-behavior: none;
  }
  #experience {
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
  }
  .header {
    top: var(--mobile-top);
    left: var(--mobile-left);
    right: var(--mobile-right);
  }
  .header .brand {
    flex-shrink: 0;
  }
  .header .brand > img {
    width: 124px;
    max-height: 24px;
  }
  .header .brand-place {
    display: none;
  }
  .header .top-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr) minmax(0, 1fr) 44px;
    gap: 6px;
    min-width: 0;
    flex: 1;
  }
  .header .top-actions button,
  .header #save-view,
  .header #replay-view,
  .header #fullscreen {
    width: auto;
    min-width: 44px;
    max-width: none;
    min-height: 44px;
    height: auto;
    padding: 6px;
    font-size: 11px;
    line-height: 1.2;
    white-space: normal;
  }
  .header #fullscreen {
    width: 44px;
  }
  .mode-switch {
    left: var(--mobile-left);
    right: var(--mobile-right);
    bottom: calc(32px + var(--mobile-bottom));
    transform: none;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: auto;
    gap: 4px;
  }
  html[data-export-mode="browser"] .mode-switch {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .mode-switch button,
  .mode-switch > a {
    min-width: 0;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 6px;
    line-height: 1.25;
    text-align: center;
    white-space: normal;
  }
  .navigation-help {
    top: calc(var(--mobile-top) + var(--mobile-header-height) + 8px);
    max-width: calc(100% - var(--mobile-left) - var(--mobile-right));
    padding: 0 10px;
    gap: 8px;
  }
  .navigation-help details {
    margin: 0;
  }
  .navigation-help summary,
  .navigation-help button {
    min-height: 44px;
    display: flex;
    align-items: center;
  }
  .navigation-help details p {
    top: 44px;
    left: 0;
    min-width: 0;
    width: 100%;
    max-height: calc(
      100dvh - var(--mobile-panel-top) - 110px - var(--mobile-bottom)
    );
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  .community-layout .lot-explorer,
  body[data-preview="cesium-navigation"] .community-layout .lot-explorer {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    top: var(--mobile-panel-top);
    left: var(--mobile-left);
    width: min(288px, calc(100% - var(--mobile-left) - var(--mobile-right)));
    max-height: calc(
      100dvh - var(--mobile-panel-top) - 112px - var(--mobile-bottom)
    );
  }
  .community-layout .lot-explorer > .p-6:first-child,
  .community-layout .lot-explorer > .p-6:last-child {
    flex-shrink: 0;
  }
  /* The phase row changes the content's child index; keep the lot list scrollable. */
  .community-layout .lot-explorer > .p-6:not(:first-child):not(:last-child) {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  .community-layout .phase-filter {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 4px;
    padding: 0;
    flex-shrink: 0;
  }
  .community-layout .community-toolbar {
    top: var(--mobile-panel-top);
    left: var(--mobile-left);
    right: var(--mobile-right);
    width: auto;
    grid-template-columns: minmax(0, 1fr) clamp(62px, 20vw, 86px);
    gap: 6px;
  }
  .community-layout .community-toolbar .explorer-trigger {
    min-height: 52px;
    padding: 4px;
    font-size: 10px;
    flex-direction: column;
    gap: 2px;
  }
  .community-layout .community-toolbar .explorer-trigger svg {
    width: 14px;
    height: 14px;
  }
  .community-layout .phase-filter .phase-button {
    min-width: 0;
    min-height: 52px;
    padding: 4px;
    align-items: center;
    text-align: center;
    gap: 3px;
  }
  .community-layout .phase-button-title {
    font-size: 10px;
  }
  .community-layout .phase-button-status {
    font-size: 9px;
  }
  .community-layout .lot-explorer#community-lot-browser {
    top: auto;
    bottom: calc(112px + var(--mobile-bottom));
    left: var(--mobile-left);
    right: var(--mobile-right);
    width: auto;
    max-height: min(
      52dvh,
      calc(100dvh - var(--mobile-panel-top) - 188px - var(--mobile-bottom))
    );
  }
  .community-layout .lot-inspector {
    top: auto;
    bottom: calc(112px + var(--mobile-bottom));
    left: var(--mobile-left);
    right: var(--mobile-right);
    max-height: min(
      34dvh,
      300px,
      calc(100dvh - var(--mobile-panel-top) - 112px - var(--mobile-bottom))
    );
  }
  .community-layout .lot-inspector > .p-6 {
    padding: 16px;
  }
  .community-layout .lot-inspector > .p-6.pt-0 {
    padding-top: 0;
  }
  .community-layout .lot-inspector .home-reference,
  .community-layout .lot-inspector .home-unassigned {
    height: 96px;
  }
  body[data-activity="walk"] .community-layout .lot-explorer,
  body[data-preview="cesium-navigation"][data-activity="walk"]
    .community-layout
    .lot-explorer[data-collapsed] {
    display: none;
  }
  .community-layout .lot-explorer,
  .community-layout .lot-inspector {
    overscroll-behavior: contain;
    overflow-x: hidden;
    scroll-padding-block: 12px;
  }
  .community-layout .lot-inspector > .p-6:first-child {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--warm-paper);
  }
  .community-layout button:not([role="switch"]) {
    min-height: 44px;
    min-width: 44px;
    height: auto;
  }
  .community-layout .lot-grid {
    gap: 6px;
  }
  .community-layout .lot-grid button {
    font-size: 12px;
  }
  .community-layout .inspector-actions button,
  .community-layout .lot-inspector .explorer-footnote button {
    white-space: normal;
    line-height: 1.35;
    padding-block: 8px;
  }
  .community-layout .explorer-footnote,
  .community-layout .site-plan-measurements {
    overflow-wrap: anywhere;
  }
  .community-layout .layer-toggle {
    min-height: 44px;
  }
  .community-layout button[role="switch"]::before {
    content: "";
    position: absolute;
    inset: -12px -4px;
  }
  .community-layout button[role="switch"] {
    position: relative;
  }
  .continuous-placement > label,
  .continuous-placement > .inspector-actions {
    width: 100%;
  }
  .continuous-placement input[type="range"],
  #daylight {
    height: 32px;
  }
  .community-layout input:not([type="range"]),
  .bm-ui .gre-catalog-search input,
  #token-form input {
    font-size: 16px;
  }
  .touch-controls,
  .property-active .touch-controls {
    display: grid;
    right: var(--mobile-right);
    bottom: calc(106px + var(--mobile-bottom));
  }
  .walk-label,
  .property-active .walk-label,
  body[data-preview="cesium-navigation"] .walk-label {
    left: var(--mobile-left);
    bottom: calc(108px + var(--mobile-bottom));
    max-width: calc(100% - var(--mobile-left) - var(--mobile-right) - 162px);
  }
  .walk-label > span {
    font-size: 17px;
  }
  .walk-label button {
    min-height: 44px;
    line-height: 1.4;
  }
  .footer,
  .property-active .footer {
    left: var(--mobile-left);
    right: var(--mobile-right);
    bottom: calc(12px + var(--mobile-bottom));
  }
  #overview-view .mapboxgl-ctrl-bottom-left,
  #overview-view .mapboxgl-ctrl-bottom-right {
    bottom: var(--mobile-bottom);
  }
  #overview-view .mapboxgl-ctrl-attrib {
    max-width: calc(100vw - var(--mobile-left) - var(--mobile-right));
  }
  .toast {
    top: var(--mobile-panel-top);
    max-width: calc(100% - var(--mobile-left) - var(--mobile-right));
    overflow-wrap: anywhere;
  }
  .community-layout .community-notice {
    bottom: calc(112px + var(--mobile-bottom));
    width: max-content;
    max-width: calc(100% - var(--mobile-left) - var(--mobile-right));
  }
  #sources-dialog {
    max-height: calc(100dvh - var(--mobile-top) - var(--mobile-bottom) - 12px);
    overscroll-behavior: contain;
  }
  #sources-dialog .drawer-header {
    position: sticky;
    top: -24px;
    padding-block: 12px;
    background: inherit;
    z-index: 1;
  }
  #sources-dialog .icon-button,
  #sources-dialog summary,
  #sources-dialog .source-links a,
  #sources-dialog .source-links button {
    min-height: 44px;
  }
  #sources-dialog .icon-button {
    min-width: 44px;
  }
  body .bm-ui .gre-catalog-sheet,
  body .bm-ui .gre-exterior-fullscreen {
    top: var(--mobile-top);
    left: var(--mobile-left);
    right: var(--mobile-right);
    bottom: calc(12px + var(--mobile-bottom));
    overscroll-behavior: contain;
  }
  body .bm-ui .gre-catalog-sheet > button:last-child {
    min-width: 44px;
    min-height: 44px;
  }
  #error-panel {
    inset: auto var(--mobile-right) auto var(--mobile-left);
    top: 50%;
    transform: translateY(-50%);
    max-width: none;
    max-height: calc(100dvh - var(--mobile-top) - var(--mobile-bottom) - 24px);
    overflow-y: auto;
  }
  #error-panel button {
    min-height: 44px;
  }
}

@media (max-width: 480px) {
  :root {
    --mobile-header-height: 76px;
  }
  .header {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
  }
  .header .brand {
    min-height: 24px;
  }
  .header .top-actions {
    width: 100%;
  }
}

/* Phone landscape needs a scrollable side panel and a real, uncropped canvas. */
@media (max-width: 960px) and (max-height: 500px) and (pointer: coarse) {
  #experience {
    min-height: 0;
  }
  .community-layout .lot-inspector {
    top: var(--mobile-panel-top, 100px);
    bottom: auto;
    left: auto;
    right: var(--mobile-right, 12px);
    width: min(320px, 46vw);
    max-height: calc(
      100dvh - var(--mobile-panel-top, 100px) - 102px -
        env(safe-area-inset-bottom, 0px)
    );
  }
  .community-layout:has(.lot-inspector) .lot-explorer {
    display: none;
  }
  .community-layout .lot-explorer[data-collapsed="false"],
  body[data-preview="cesium-navigation"]
    .community-layout
    .lot-explorer[data-collapsed="false"] {
    display: flex;
    overflow: hidden;
  }
  .community-layout .lot-explorer > .p-6:not(:first-child):not(:last-child) {
    overflow-y: auto;
  }
  .community-layout .lot-explorer#community-lot-browser {
    top: var(--mobile-panel-top);
    bottom: auto;
    left: auto;
    right: var(--mobile-right);
    width: min(320px, 40vw);
    max-height: calc(
      100dvh - var(--mobile-panel-top) - 102px - var(--mobile-bottom)
    );
  }
  .community-layout:has(#community-lot-browser) .community-toolbar,
  .community-layout:has(.lot-inspector) .community-toolbar {
    right: auto;
    width: calc(100% - 48px - min(320px, 46vw));
  }
  .hero,
  .property-active .hero {
    bottom: calc(106px + env(safe-area-inset-bottom, 0px));
    max-width: 55%;
  }
  .hero h1 {
    font-size: 32px;
  }
  .hero-actions {
    margin-top: 12px;
  }
  .scene-tools {
    top: 80px;
    max-height: calc(100dvh - 182px);
    overflow-y: auto;
  }
}
