/* The device draws its own status bar. Never add a fabricated status-bar height. */
html.app-mode, .app-mode body { height:100%; overflow:hidden; background:var(--app-surface,var(--dark)); }
.app-mode .review-bar,
.app-mode .review-panel,
.app-mode .reference { display:none!important; }
.app-mode .workspace { display:block; padding:0; margin:0; height:100%; }
.app-mode .phone {
 width:100%; max-width:430px; min-height:0;
 height:100vh; height:100dvh;
 margin:0 auto; box-shadow:none;
}
.app-mode .scroll { overscroll-behavior-y:contain; }
/* Scrolling a long authentication form must not move content under the status bar. */
.app-mode .auth { overflow:hidden; }
.app-mode .auth-inner { min-height:0; overflow:auto; scrollbar-width:none; }
.app-mode .auth-content { position:relative; min-height:667px; height:100%; }
.app-mode dialog { max-height:calc(100% - var(--safe-top) - var(--safe-bottom) - 32px); }

/* Match the solid native bar across the entire top edge, then reveal the
   original diagonal gradient. Background layers never cover page content. */
.app-mode .screen.dark,
.app-mode .auth:not(.register) {
 background-image:
  linear-gradient(to bottom,
   var(--dark) 0,
   var(--dark) calc(var(--safe-top) + 10px),
   transparent calc(var(--safe-top) + 58px)),
  linear-gradient(209.3455deg,var(--dark),var(--brown));
}

/* Keep text entry at a readable size to avoid iOS WebKit focus zoom. */
@media (hover: none) and (pointer: coarse) {
 html.app-mode #phone input:not([type]),
 html.app-mode #phone input[type="text"],
 html.app-mode #phone input[type="email"],
 html.app-mode #phone input[type="password"],
 html.app-mode #phone input[type="search"],
 html.app-mode #phone input[type="tel"],
 html.app-mode #phone input[type="url"],
 html.app-mode #phone input[type="number"],
 html.app-mode #phone input[type="date"],
 html.app-mode #phone textarea,
 html.app-mode #phone select {
  font-size:16px;
 }

 /* Leave enough room for the longer password confirmation placeholder. */
 .app-mode .register .auth-field input { padding-inline-start:calc(16 * var(--u)); }
}

@media (hover: none) and (pointer: coarse) and (max-width: 375px) {
 .app-mode .register :is(.auth-field,.auth-submit) { left:14%; width:72%; }
}

@media (hover: none) and (pointer: coarse) and (max-width: 600px) {
 .app-mode .phone { max-width:none; }
}

@media (hover: none) and (pointer: coarse) and (orientation: landscape) and (max-height: 540px) {
 .app-mode .phone { max-width:none; }
}

/* WebKit can pan the visual viewport when the on-screen keyboard opens. */
html.app-mode.ios-viewport,
html.app-mode.ios-viewport body {
 overflow:hidden;
 overscroll-behavior:none;
}
.ios-viewport body {
 position:fixed;
 inset:0;
 width:100%;
}
.app-mode.ios-viewport .phone {
 position:absolute;
 inset-inline:0;
 top:0;
 overflow:clip;
}
.app-mode.ios-viewport .phone :is(.scroll,.auth-inner,dialog) {
 overscroll-behavior:contain;
}

/* Keep the home-indicator inset inside the dock, without adding a second gap. */
.app-mode.ios-viewport .screen > .nav {
 padding-bottom:max(4px,env(safe-area-inset-bottom,0px));
}

/* Only the keyboard needs the visual viewport. Keep scrolling inside the app. */
.app-mode.ios-viewport.ios-keyboard-open .phone {
 top:var(--ios-keyboard-top,0px);
 height:var(--ios-keyboard-height,100dvh);
 --safe-bottom:0px;
}
.app-mode.ios-viewport.ios-keyboard-open .screen > .nav {
 position:absolute;
 bottom:calc(var(--ios-keyboard-top) + var(--ios-keyboard-height) - var(--ios-dock-bottom));
 visibility:hidden;
}

/* Use the full display when launched from an iPhone Home Screen.
   The keyboard state retains its measured visual viewport and dock position. */
html.app-mode.ios-viewport.ios-standalone:not(.ios-keyboard-open),
html.app-mode.ios-viewport.ios-standalone:not(.ios-keyboard-open) body,
html.app-mode.ios-viewport.ios-standalone:not(.ios-keyboard-open) .phone {
 height:100vh;
}
