html.capsule-pending body {
  visibility: hidden;
}

body.capsule-active,
html:has(body.capsule-active) {
  height: 100%;
  overflow: hidden;
}

body.capsule-active {
  display: block;
  min-height: 0;
}

body.capsule-active .page-capsule {
  position: fixed;
  top: 10px;
  left: 10px;
  right: 10px;
  bottom: 10px;

  border-radius: 0.9rem;
  border: 1px solid rgba(20, 23, 30, 0.06);
  background-color: rgb(245, 247, 250);
  background-color: rgb(var(--bg));
  background-color: rgb(var(--background));
  box-shadow:
    0 12px 32px rgba(15, 23, 42, 0.10),
    0 4px 10px rgba(15, 23, 42, 0.05);

  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;

  display: flex;
  flex-direction: column;
}

html.dark body.capsule-active .page-capsule {
  border-color: rgba(255, 255, 255, 0.06);
}

@media (hover: hover) and (pointer: fine) {
  body.capsule-active .page-capsule::-webkit-scrollbar-track {
    margin-block: 1rem;
  }
}

@media (max-width: 900px) {
  body.capsule-active .page-capsule {
    top: 5px;
    left: 5px;
    right: 5px;
    bottom: 5px;
    border-radius: 0.75rem;
  }
}

body.capsule-active .page-capsule>.grain {
  position: absolute !important;
  inset: 0 !important;
  z-index: 0;
  border-radius: inherit;
  overflow: hidden;
}

body.capsule-active .page-capsule>.header,
body.capsule-active .page-capsule>.main,
body.capsule-active .page-capsule>footer {
  position: relative;
}

body.capsule-active .page-capsule>.header {
  position: sticky;
  top: 0;
  z-index: 50;
  border-top-left-radius: 0.9rem;
  border-top-right-radius: 0.9rem;
}

@media (max-width: 900px) {
  body.capsule-active .page-capsule>.header {
    border-top-left-radius: 0.75rem;
    border-top-right-radius: 0.75rem;
  }
}

body.capsule-active .page-capsule>.main {
  flex: 1;
}

body.capsule-active .page-capsule>.app-shell {
  height: 100%;
  min-height: 0;
  flex: 1;
}

@media (min-width: 861px) {
  body.capsule-active .page-capsule>.app-shell>.sidebar {
    position: relative;
    height: 100%;
  }
}

@media (max-width: 860px) {
  body.capsule-active .page-capsule>.app-shell>.sidebar {
    top: 5px;
    bottom: 5px;
    left: 0;
    height: auto;
    visibility: hidden;
    transition: transform .2s ease, visibility 0s linear .2s;
  }

  body.capsule-active .page-capsule>.app-shell>.sidebar.open {
    left: 5px;
    border-top-left-radius: 0.75rem;
    border-bottom-left-radius: 0.75rem;
    visibility: visible;
    transition: transform .2s ease, visibility 0s linear 0s;
  }

  body.capsule-active .page-capsule>.app-shell>.sidebar-backdrop {
    top: 5px;
    left: 5px;
    right: 5px;
    bottom: 5px;
    height: auto;
    border-radius: 0.75rem;
  }
}

body.capsule-active .page-capsule>.app-shell>.main-col {
  flex: 1;
  min-width: 0;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
}

body.capsule-active .page-capsule>.app-shell>.main-col>.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
}

body.capsule-active::before,
body.capsule-active::after {
  opacity: 0 !important;
}

body.capsule-active .page-capsule>.page-capsule-bg-line {
  position: absolute !important;
  z-index: 0;
  overflow: hidden;
  pointer-events: none !important;
}

body.capsule-active .page-capsule {
  isolation: isolate;
}
body.capsule-active .page-capsule > :is(#bg-fx-glow, #bg-fx-vignette, #bg-fx-canvas, #bg-shapes, .bg-host) {
  position: fixed !important;
  inset: 10px !important;
  width: auto !important;
  height: auto !important;
  border-radius: 0.9rem;
  overflow: hidden;
}

@media (max-width: 900px) {
  body.capsule-active .page-capsule > :is(#bg-fx-glow, #bg-fx-vignette, #bg-fx-canvas, #bg-shapes, .bg-host) {
    inset: 5px !important;
    border-radius: 0.75rem;
  }
}

body.capsule-active .page-capsule > :is(#bg-fx-canvas, #bg-shapes) {
  width: calc(100vw - 20px) !important;
  height: calc(100vh - 20px) !important;
  height: calc(100dvh - 20px) !important;
}

@media (max-width: 900px) {
  body.capsule-active .page-capsule > :is(#bg-fx-canvas, #bg-shapes) {
    width: calc(100vw - 10px) !important;
    height: calc(100vh - 10px) !important;
    height: calc(100dvh - 10px) !important;
  }
}
