/* The wallpaper fills the viewport; foreground UI respects each system edge.
   WebKit updates these insets when rotating, folding or resizing the window. */
:root {
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-height: calc(100dvh - var(--safe-top) - var(--safe-bottom));
  --safe-width: calc(100vw - var(--safe-left) - var(--safe-right));
}
#root { padding: var(--safe-top) var(--safe-right) var(--safe-bottom) var(--safe-left); }
.shell, .login-page, .startup-error, .workspace-choice-page { min-height: var(--safe-height); }
.workspace-choice { max-height: calc(var(--safe-height) - 48px); }
/* Fixed hosts and top-layer dialogs do not inherit the root's padding. */
.app-host { padding: var(--safe-top) var(--safe-right) var(--safe-bottom) var(--safe-left); }
.dialog, .session-expired {
  inset: var(--safe-top) var(--safe-right) var(--safe-bottom) var(--safe-left);
  max-width: calc(var(--safe-width) - 32px);
  max-height: calc(var(--safe-height) - 32px);
}
.spotlight { max-height: min(76vh, calc(var(--safe-height) - var(--launcher-dialog-top) - 16px)); }
.appearance-dialog { max-height: calc(var(--safe-height) - var(--launcher-dialog-top) - 24px); }
.hub-toasts {
  right: max(16px, var(--safe-right));
  max-width: calc(var(--safe-width) - 32px);
}
/* The root already protects the home indicator. */
.shell > .hub-footer { padding-bottom: 8px; }

:root[data-native-viewport] body { --launcher-gutter: clamp(8px, 2vw, 20px); }
:root[data-native-viewport] .shell { padding-top: 20px; padding-bottom: 12px; }

/* Keep scrolling content inside the usable rectangle so it cannot move under
   the camera/status controls during scrolling. */
:root[data-native-viewport] #root {
  position: fixed;
  inset: var(--safe-top) var(--safe-right) var(--safe-bottom) var(--safe-left);
  overflow: auto;
  padding: 0;
}
:root[data-native-viewport]:has(dialog[open]) #root { overflow: hidden; }

/* Home keeps its toolbar alongside the system indicators. Only the scrolling
   workspace clears their vertical extent, leaving the remaining width usable. */
:root[data-native-regions] #root:has(.shell) { top: var(--native-top); overflow: hidden; }
:root[data-native-regions] .shell {
  display: flex;
  flex-direction: column;
  height: calc(100dvh - var(--native-top) - var(--safe-bottom));
  min-height: 0;
}
:root[data-native-regions] .launcherbar {
  flex-shrink: 0;
  min-height: max(58px, calc(var(--safe-top) - var(--native-top)));
  padding-left: var(--native-left);
  padding-right: var(--native-right);
}
:root[data-native-regions] .shell > .workspace { min-height: 0; flex: 1; overflow: auto; }
:root[data-native-regions] .shell > .hub-footer { flex-shrink: 0; }
:root[data-native-regions]:has(dialog[open]) .shell > .workspace { overflow: hidden; }
