/* One continuous page surface from startup to the loaded application.
   Safe-area spacing belongs to controls, never to the page background.
   Punch keeps its existing, independently verified shell. */
@media screen {
  html:root {
    --sg-viewport-height: 100vh;
    --sg-safe-top: env(safe-area-inset-top, 0px);
    --sg-safe-right: env(safe-area-inset-right, 0px);
    --sg-safe-bottom: env(safe-area-inset-bottom, 0px);
    --sg-safe-left: env(safe-area-inset-left, 0px);
    min-height: 100%;
  }
  @supports (height: 100dvh) {
    html:root { --sg-viewport-height: 100dvh; }
  }

  html:root body {
    margin: 0;
    min-height: calc(var(--sg-viewport-height) / var(--sg-ui-scale, 1));
  }

  /* The same opaque base also paints browser-managed overscroll areas.
     Keep the ambient decoration on the root even when no line pattern is
     selected, instead of restarting it inside each screen-sized child. */
  html[data-suite-palette]:root {
    background: var(--liquid-ambient, var(--palette-bg, #0b1710));
    background-color: var(--palette-panel, var(--palette-bg, #0b1710));
    background-attachment: fixed;
  }
  html[data-suite-palette]:root body { background: transparent; }
  html[data-suite-pattern]:not([data-suite-pattern="none"]):root {
    --sg-pattern-frame-height: calc(var(--sg-viewport-height) / var(--sg-ui-scale, 1));
  }
  @media (pointer: coarse) {
    html[data-suite-palette]:root { background-attachment: scroll; }
  }

  /* Match Punch's startup content insets. This also wins over generic
     main/sidebar offsets in Comptabilite, including wide landscape phones. */
  html:root .suite-app-boot {
    box-sizing: border-box;
    width: 100%;
    max-width: none;
    min-height: calc(var(--sg-viewport-height) / var(--sg-ui-scale, 1));
    margin: 0;
    padding: max(32px, var(--sg-safe-top))
      max(24px, var(--sg-safe-right))
      max(32px, var(--sg-safe-bottom))
      max(24px, var(--sg-safe-left));
  }
  html[data-suite-palette]:root .suite-app-boot { background: transparent; }

  /* Keep the calm startup screen while its ambient background covers the
     root. The line artwork and appearance control return when it is ready. */
  html[data-suite-palette]:root:has(.suite-app-boot) body::before,
  html[data-suite-palette]:root:has(.suite-app-boot) body::after {
    display: none;
  }
  body:has(.suite-app-boot) .suite-appearance { display: none; }

  @media (forced-colors: active) {
    html[data-suite-palette]:root {
      background: Canvas !important;
      color: CanvasText;
    }
    html:root .suite-app-boot { background: Canvas !important; color: CanvasText; }
  }
}
