@layer base {
  /* Page skeleton
  /* -------------------------------------------------------------------------- */

  /* Signed in: the sidebar beside a card that floats on the window colour,
     8px in from the window's edges. The document scrolls, carrying the card;
     the sidebar stays put. */
  .app {
    --sidebar-width: 280px;
    /* One 28px row plus the 8px window inset either side. A plain length, so
       the sidebar controller can read it. */
    --sidebar-rail-width: 44px;

    background-color: var(--color-window);
    display: flex;
    min-block-size: 100dvh;
  }

  body:has(> .app) {
    background-color: var(--color-window);
  }

  .app__card {
    background-color: var(--color-canvas);
    border-radius: var(--border-radius-large);
    box-shadow: var(--shadow-card);
    flex: 1;
    margin:
      calc(var(--window-inset) + var(--custom-safe-inset-top))
      calc(var(--window-inset) + var(--custom-safe-inset-right))
      calc(var(--window-inset) + var(--custom-safe-inset-bottom))
      0;
    min-block-size: calc(100dvh - var(--window-inset) * 2);
    min-inline-size: 0;
  }

  /* While the sidebar slides, the page is held at the width it will end at
     (see the sidebar controller), and the card clips it until it fits */
  .app__card--sliding {
    overflow: clip;
  }

  :where(.main-content) {
    margin-inline: auto;
    max-inline-size: var(--main-width);
    padding-block: var(--block-space-double);
    padding-inline: var(--main-padding);
  }

  /* Signed out there is no card, so clear the device's safe areas here */
  body > :where(.main-content) {
    min-block-size: 100dvh;
    padding-block:
      calc(var(--block-space-double) + var(--custom-safe-inset-top))
      calc(var(--block-space-double) + var(--custom-safe-inset-bottom));
    padding-inline:
      calc(var(--main-padding) + var(--custom-safe-inset-left))
      calc(var(--main-padding) + var(--custom-safe-inset-right));
  }
}
