.app-shell {
  position: relative;
  width: 100%;
}

.app-shell__frame {
  display: block;
  width: 100%;
  border: 1px solid var(--color-muted);
  border-radius: 0.5rem;
  background-color: var(--color-surface);
}

.app-shell__fullscreen {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  cursor: pointer;
  color: #f4f6fb;
  font-size: 1.1rem;
  line-height: 1;
  background: rgba(11, 16, 32, 0.6);
  border: 1px solid rgba(244, 246, 251, 0.25);
  border-radius: 0.5rem;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: background-color 0.15s ease, transform 0.15s ease;
}

.app-shell__fullscreen:hover {
  background: rgba(11, 16, 32, 0.85);
  transform: translateY(-1px);
}

.app-shell__fullscreen-exit {
  display: none;
}

/* Mobile-only controls — hidden on desktop (desktop uses __fullscreen). */
.app-shell__open {
  position: absolute;
  display: none;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.85rem;
  cursor: pointer;
  color: #f4f6fb;
  font: inherit;
  font-size: 0.85rem;
  line-height: 1;
  background: rgba(11, 16, 32, 0.72);
  border: 1px solid rgba(244, 246, 251, 0.25);
  border-radius: 999px;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.app-shell__open-icon {
  font-size: 1rem;
}

.app-shell__close {
  position: absolute;
  display: none;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  cursor: pointer;
  color: #f4f6fb;
  font-size: 1.2rem;
  line-height: 1;
  background: rgba(11, 16, 32, 0.82);
  border: 1px solid rgba(244, 246, 251, 0.3);
  border-radius: 999px;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* Native Fullscreen API */
.app-shell:fullscreen {
  display: flex;
  width: 100vw;
  height: 100vh;
  background: #0b1020;
}

.app-shell:fullscreen .app-shell__frame {
  width: 100%;
  height: 100%;
  min-height: 0 !important;
  border: none;
  border-radius: 0;
}

/* Fallback / class-toggled fullscreen (Fullscreen API unavailable, e.g. iOS) */
.app-shell--fullscreen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  background: #0b1020;
}

/* Lock background scroll while the CSS fallback overlay is open. */
.app-shell-locked,
.app-shell-locked body {
  overflow: hidden;
  overscroll-behavior: none;
}

.app-shell--fullscreen .app-shell__frame {
  width: 100%;
  height: 100%;
  min-height: 0 !important;
  border: none;
  border-radius: 0;
}

.app-shell:fullscreen .app-shell__fullscreen-enter,
.app-shell--fullscreen .app-shell__fullscreen-enter {
  display: none;
}

.app-shell:fullscreen .app-shell__fullscreen-exit,
.app-shell--fullscreen .app-shell__fullscreen-exit {
  display: inline;
}

/* Mobile: open + close share the same bottom-right spot inside the app-shell. */
@media (max-width: 768px) {
  .app-shell__fullscreen {
    display: none;
  }

  .app-shell__open,
  .app-shell__close {
    bottom: max(0.6rem, env(safe-area-inset-bottom));
    right: max(0.6rem, env(safe-area-inset-right));
    z-index: 2;
  }

  .app-shell__open {
    display: inline-flex;
  }

  .app-shell--fullscreen .app-shell__open,
  .app-shell:fullscreen .app-shell__open {
    display: none;
  }

  .app-shell--fullscreen .app-shell__close,
  .app-shell:fullscreen .app-shell__close {
    display: inline-flex;
  }
}
