/* Home-screen app only. Keep the established Safari tab layout and theme. */
@media (display-mode: standalone) {
  :root {
    /* The opaque native status bar reserves its own space. Use the remaining
       reported inset; a guessed 24/44px would add a second status-bar gap. */
    --app-safe-top: env(safe-area-inset-top, 0px);
    --app-safe-bottom: env(safe-area-inset-bottom, 0px);
    --app-safe-left: env(safe-area-inset-left, 0px);
    --app-safe-right: env(safe-area-inset-right, 0px);
  }

  /* Keep the web content's remaining safe region aligned with its theme. */
  html { background: var(--bg-primary); }
  /* Keep scrolling content out of the native status bar, independently of the
     sticky header's filtered surface. This layer must not sit inside .header. */
  html::before {
    content: "";
    position: fixed;
    inset: 0 0 auto;
    height: var(--app-safe-top);
    background: var(--bg-primary);
    z-index: 101;
    pointer-events: none;
  }
  body {
    min-height: 100dvh;
    padding-inline: var(--app-safe-left) var(--app-safe-right);
    padding-top: var(--app-safe-top);
    padding-bottom: var(--app-safe-bottom);
  }
  .header { top: var(--app-safe-top); padding-top: 0; }
  /* Native status-bar opacity is declared in HTML. Header material, light blur
     and reduced-effects fallbacks remain owned by the selected theme. */

  .auth-gate,
  .modal-overlay,
  #billDialogOverlay {
    padding: max(24px, var(--app-safe-top)) max(20px, var(--app-safe-right))
      max(24px, var(--app-safe-bottom)) max(20px, var(--app-safe-left));
  }
  .auth-gate { overflow-y: auto; }
  .auth-filing { padding-bottom: max(18px, var(--app-safe-bottom)); }
  .modal-overlay .modal {
    max-height: calc(100dvh - max(24px, var(--app-safe-top)) - max(24px, var(--app-safe-bottom)));
  }
  .toast-container {
    bottom: calc(20px + var(--app-safe-bottom));
    right: calc(20px + var(--app-safe-right));
  }
  .demo-mode::after {
    bottom: calc(17px + var(--app-safe-bottom));
    right: calc(18px + var(--app-safe-right));
  }
}

