/* Shared phone browser support, including Safari; no platform or payment capability is inferred. */
@media (max-width: 800px) {
  body {
    padding-top: env(safe-area-inset-top);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }
  .ep-header, .za-header {
    top: env(safe-area-inset-top);
    left: env(safe-area-inset-left);
    right: env(safe-area-inset-right);
  }
  /* Keep the five primary destinations within thumb reach on phones. */
  :root { --za-phone-nav-height: calc(72px + env(safe-area-inset-bottom, 0px)); }
  html {
    scroll-padding-top: calc(130px + env(safe-area-inset-top, 0px));
    scroll-padding-bottom: calc(var(--za-phone-nav-height) + 16px);
  }
  .ep-mobile-tabs {
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--za-phone-nav-height);
    padding: 0 env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    align-items: stretch;
    border-top: 1px solid var(--line);
    box-shadow: 0 -3px 16px #0000000a;
    z-index: 35;
  }
  .ep-mobile-tabs > button {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 0;
    min-height: 64px;
    gap: 5px;
    padding: 9px 2px;
    font-size: 13px;
    line-height: 1.5;
  }
  .ep-mobile-tabs > button svg { display: block; width: 22px; height: 22px; }
  .ep-mobile-tabs > button span { white-space: nowrap; }
  .ep-mobile-tabs > button.active::after { top: 0; bottom: auto; height: 3px; }
  .ep-main {
    padding-top: calc(118px + env(safe-area-inset-top, 0px));
    padding-bottom: calc(var(--za-phone-nav-height) + 16px);
  }
  .ep-sidebar {
    top: calc(118px + env(safe-area-inset-top, 0px));
    bottom: var(--za-phone-nav-height);
    left: env(safe-area-inset-left, 0px);
  }
  .ep-scrim {
    top: calc(118px + env(safe-area-inset-top, 0px));
    bottom: var(--za-phone-nav-height);
  }
  #toast { bottom: calc(var(--za-phone-nav-height) + 12px); }
  /* Existing viewport detection distinguishes the software keyboard from zoom. */
  html[data-keyboard-visible] .ep-mobile-tabs { visibility: hidden; pointer-events: none; }
  .za-bottom-nav { left: env(safe-area-inset-left); right: env(safe-area-inset-right); }
  input, select, textarea { font-size: max(16px, 1em); }
  .modal-backdrop {
    box-sizing: border-box;
    padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  }
  .modal-backdrop .modal {
    max-height: calc(100dvh - max(12px, env(safe-area-inset-top)) - max(12px, env(safe-area-inset-bottom)));
  }
  .modal-body { scroll-padding-block: 16px; }
  html[data-keyboard-visible] .modal-backdrop {
    top: var(--za-keyboard-viewport-top);
    bottom: auto;
    height: var(--za-keyboard-viewport-height);
    padding-top: 12px;
    padding-bottom: 12px;
  }
  html[data-keyboard-visible] .modal-backdrop .modal { max-height: 100%; }
}
