/* The SDK reports system insets in CSS px. Bilibili's floating controls sit
   below the status bar, outside those insets, on both sides of the header. */
html.toy-container {
  --toy-capsule-row: 0px;
  --toy-top: calc(var(--toy-safe-top) + var(--toy-capsule-row));
  --toy-right: calc(100vw - min(100vw, var(--toy-viewport-width, 100vw)) + var(--toy-safe-right));
  --toy-bottom: calc(100dvh - min(100dvh, var(--toy-viewport-height, 100dvh)) + var(--toy-safe-bottom));
  --toy-insets: var(--toy-top) var(--toy-right) var(--toy-bottom) var(--toy-safe-left);
  --toy-width: calc(100vw - var(--toy-safe-left) - var(--toy-right));
  --toy-height: calc(100dvh - var(--toy-top) - var(--toy-bottom));
  overflow: hidden;
}

html.toy-container.toy-immersive { --toy-capsule-row: 48px; }

html.toy-container > body {
  position: fixed;
  inset: var(--toy-insets);
  margin: 0;
  width: auto;
  height: auto;
  min-height: 0;
  overflow: auto;
}

html.toy-container body:has(dialog[open]) { overflow: hidden; }

/* Modal dialogs are positioned in the browser's top layer, outside the body. */
html.toy-container dialog:modal {
  inset: var(--toy-insets);
  margin: auto;
  max-width: calc(var(--toy-width) - 16px);
  max-height: calc(var(--toy-height) - 16px);
}
