/* Responsive shell — pairs with js/shell.js. Load AFTER styles.css and the page css. */

html { -webkit-text-size-adjust: 100%; }

/* ---------- frame mode (tablet / desktop): framed device, scaled to fit the window height ---------- */
html.mode-frame body {
  padding: 24px 20px;
  background:
    radial-gradient(900px 600px at 20% 10%, rgba(143,162,255,.08), transparent 60%),
    radial-gradient(800px 600px at 85% 90%, rgba(31,166,166,.07), transparent 60%),
    #0d0f13;
  min-height: 100dvh;
}
html.mode-frame .stage { gap: calc(18px * var(--s, 1)); }
html.mode-frame .phone {
  transform: scale(var(--s, 1));
  transform-origin: 50% 0;
  margin: 0 calc(390px * (var(--s, 1) - 1) / 2) calc(844px * (var(--s, 1) - 1));
}

/* ---------- phone mode (<= 520px): the UI IS the screen ---------- */
html.mode-phone, html.mode-phone body { height: 100%; overflow: hidden; background: var(--surface-2); }
html.mode-phone body { display: block; padding: 0; min-height: 0; }
html.mode-phone .stage { display: block; }
html.mode-phone .caption { display: none; }
html.mode-phone .phone {
  position: fixed; left: 0; top: var(--vv-top, 0px);
  width: 390px; height: var(--H, 844px);
  border-radius: 0; box-shadow: none;
  transform: scale(var(--s, 1)); transform-origin: 0 0;
}
/* the fake iOS status bar + Safari bar are prototype chrome: on a real phone the OS draws them */
html.mode-phone .statusbar { display: none; }
html.mode-phone .safari { background: none; -webkit-backdrop-filter: none; backdrop-filter: none; width: 0; height: 0; top: 0; pointer-events: none; }
html.mode-phone .safari .addr, html.mode-phone .safari .more, html.mode-phone .safari .home { display: none; }
/* in-page back chip: the browser bar is hidden on a real phone, so keep a way out (top-left, below the safe area) */
html.mode-phone .safari .back { display: flex; pointer-events: auto; position: fixed; left: 12px; top: calc(10px + env(safe-area-inset-top, 0px)); width: 40px; height: 40px; z-index: 60;
  background: rgba(20, 26, 34, .55); -webkit-backdrop-filter: blur(20px) saturate(150%); backdrop-filter: blur(20px) saturate(150%); transform: scale(calc(1 / var(--s, 1))); transform-origin: 0 0; }
html.mode-phone.is-home .safari .back { display: none; }
/* floating controls sit above the home indicator, anchored to the bottom whatever the screen height */
html.mode-phone .bottomctl { top: calc(var(--H, 844px) - 44px - 22px - (env(safe-area-inset-bottom, 0px) / var(--s, 1))); }
/* content may scroll under the (hidden) bottom bar: keep the last card clear of the floating controls */
html.mode-phone .scroll { padding-bottom: 96px; }
html.mode-phone .scroll > .content { margin-bottom: 0; }

/* tall screens: the page underlay (map + fade) grows with the viewport */
.fill-h { height: var(--H, 844px) !important; }

/* very small phones (SE, 320px wide): never shrink below 0.82 visually — keep tap targets >= 44px effective */
@media (max-width: 340px) { html.mode-phone .btn { min-width: 44px; min-height: 44px; } }

/* landscape phones: shell goes into frame mode (short viewport) and the whole device scales down */
@media (orientation: landscape) and (max-height: 520px) {
  html.mode-frame body { padding: 8px; }
}

/* phone mode: leave room for the in-page back chip (top-left, 40px + 10px) on pages whose own header starts at the top */
html.mode-phone .rt { --st: 60px; }
html.mode-phone .lines .title { padding-top: 48px; }
html.mode-phone .phone.rt { --st: calc(58px + env(safe-area-inset-top, 0px) / var(--s, 1)); }
html.mode-phone { --to: calc(10px + env(safe-area-inset-top, 0px) / var(--s, 1)); }
