/* Detailed sections use the document scroller on compact screens. The desktop
   panel and the mobile home retain their existing layout. Load after panels.css. */
.mobile-page-toolbar { display: none; }

@media (max-width: 1024px), (max-width: 1100px) and (max-height: 550px) {
  html:has(body[data-view]:not([data-view="home"])) {
    height: auto;
    min-height: 100%;
    overflow-x: clip;
    overflow-y: auto;
    scroll-padding-top: calc(104px + env(safe-area-inset-top, 0px));
    scroll-padding-bottom: var(--bottom-nav-clearance);
  }

  body[data-view]:not([data-view="home"]) {
    --mobile-page-inset: clamp(18px, 5vw, 32px);
    height: auto;
    min-height: 100dvh;
    overflow: visible;
    padding-bottom: 0;
    background: var(--paper);
  }

  /* Keep the full document height while covered, including in the 3D tour.
     Restoring the page therefore never clamps its saved scroll position. */
  html:has(body[data-view]:not([data-view="home"]):is(.tour-mode, .menu-open, .mobile-menu-present)),
  html:has(body[data-view]:not([data-view="home"]) dialog[open]),
  body[data-view]:not([data-view="home"]):is(.tour-mode, .menu-open, .mobile-menu-present),
  body[data-view]:not([data-view="home"]):has(dialog[open]) {
    overflow: hidden;
  }

  body[data-view]:not([data-view="home"]) #content-view {
    position: relative;
    inset: auto;
    display: block;
    width: 100%;
    max-width: none;
    height: auto;
    min-height: calc(100dvh - 88px - env(safe-area-inset-top, 0px));
    max-height: none;
    margin: 0;
    padding: 8px max(var(--mobile-page-inset), env(safe-area-inset-right, 0px))
      calc(var(--bottom-nav-clearance) + 12px)
      max(var(--mobile-page-inset), env(safe-area-inset-left, 0px));
    overflow: visible;
    overscroll-behavior: auto;
    background: var(--paper);
    border: 0;
    border-radius: 0;
    box-shadow: none;
    scrollbar-width: auto;
    -webkit-overflow-scrolling: auto;
  }

  /* The live panorama remains mounted for immediate tour entry. All outer
     leaf wrappers disappear so reading surfaces fill the phone edge to edge. */
  body[data-view]:not([data-view="home"]):not(.tour-mode) .panorama {
    opacity: 0;
    filter: none;
  }

  body[data-view]:not([data-view="home"]) > .panorama-shade,
  body[data-view]:not([data-view="home"]) > .foliage-edges,
  body[data-view]:not([data-view="home"]) > .foliage-corners,
  body[data-view]:not([data-view="home"]) > .decorations {
    display: none;
  }

  .mobile-page-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-width: 0;
    margin: 0 0 22px;
  }

  .mobile-page-toolbar [data-action="mobile-back"] {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    gap: 7px;
    min-width: 44px;
    min-height: 44px;
    padding: 10px 15px 10px 11px;
    border: 1px solid #dce9c8;
    border-radius: 999px;
    background: #edf5df;
    color: #287a1c;
    font: inherit;
    font-size: 14px;
    font-weight: 900;
    line-height: 1.2;
    text-decoration: none;
  }

  .mobile-page-toolbar [data-action="mobile-back"] .icon {
    width: 20px;
    height: 20px;
  }

  .mobile-page-title {
    min-width: 0;
    color: #687452;
    font-size: 12px;
    font-weight: 800;
    line-height: 1.35;
    text-align: right;
  }
}
