.app-boot {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(248, 250, 252, 0.9);
  transition: opacity 0.2s ease;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

.app-boot[hidden] {
  display: none;
}

.app-boot.is-fading {
  opacity: 0;
  pointer-events: none;
}

.app-boot-shell {
  width: min(360px, calc(100% - 28px));
  padding: 14px 16px;
  border: 1px solid rgba(226, 232, 240, 0.98);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 14px 28px -24px rgba(15, 23, 42, 0.34);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.app-boot-spinner {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(62, 107, 140, 0.22);
  border-top-color: var(--preview-primary);
  animation: loader-spin 0.8s linear infinite;
  flex: 0 0 auto;
}

.app-boot-text {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: #475569;
  letter-spacing: 0.01em;
}

.app[hidden] {
  display: none !important;
}

.app {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100dvh;
  min-height: 100dvh;
  margin: 0;
  border-radius: 0;
  overflow: hidden;
  isolation: isolate;
  background: var(--preview-content-bg);
}

.app::before {
  content: none;
}

.app::after {
  content: none;
}

.content-area {
  position: relative;
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  /* Kein z-index hier!
     position:relative reicht als Anker fuer den absolut positionierten
     .content-loader. Ein z-index wuerde einen eigenen Stacking-Context
     erzeugen – Folge: Modale (z-index ~1000) inside der content-area
     waeren im content-area-Stack gefangen, und die Sidebar (z-index 2
     bzw. 100 im Mobile-Drawer) wuerde sie ueberdecken. */
  padding: 0;
  background: var(--preview-content-bg);
}

.content-loader {
  position: absolute;
  inset: 0;
  border-radius: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(248, 250, 252, 0.88);
  z-index: 50;
  opacity: 1;
  transition: opacity 0.22s ease, visibility 0.22s ease;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

.content-loader.hidden {
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}

.content-loader-shell {
  width: min(360px, calc(100% - 28px));
  padding: 14px 16px;
  border: 1px solid rgba(226, 232, 240, 0.98);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 14px 28px -24px rgba(15, 23, 42, 0.34);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.content-loader-spinner {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(62, 107, 140, 0.22);
  border-top-color: var(--preview-primary);
  animation: loader-spin 0.8s linear infinite;
  flex: 0 0 auto;
}

.content-loader-text {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: #475569;
  letter-spacing: 0.01em;
}

@keyframes loader-spin {
  to {
    transform: rotate(360deg);
  }
}

.module-panel {
  display: none;
  flex: 1;
  flex-direction: column;
  min-height: 0;
  position: relative;
  /* Kein z-index!
     Sonst wuerde dieser Wrapper einen Stacking-Context erzeugen und alle
     Modale (z-index 200/1000) waeren darin gefangen – aus .app-Sicht
     stuende die ganze Panel auf z-index 1, waehrend die Sidebar auf
     z-index 2 (Desktop) bzw. 100 (Mobile-Drawer) sitzt – Modal verschwaende
     hinter der Sidebar.
     Auch: opacity-only Animation, damit keine transform-Eigenschaft einen
     Containing-Block fuer position:fixed-Kinder erzeugt waehrend der Fade. */
  margin: 0;
  border-radius: 0;
  overflow: hidden;
  border: 0;
  background: var(--preview-card-bg);
  box-shadow: none;
  animation: panel-fade-in 0.24s ease;
}

.module-panel.active {
  display: flex;
}

.module-panel-lazy {
  background: var(--preview-card-bg);
}

.module {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
}

.module-panel-loading,
.module-panel-error {
  margin: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  max-width: min(540px, calc(100% - 32px));
  text-align: center;
  font-size: 14px;
  color: var(--text2);
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(226, 232, 240, 0.96);
  border-radius: 12px;
  padding: 12px 16px;
  box-shadow: 0 12px 24px -24px rgba(15, 23, 42, 0.34);
}

.module-panel-loading {
  color: #475569;
}

.module-panel-loading::before {
  content: '';
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(62, 107, 140, 0.22);
  border-top-color: var(--preview-primary);
  animation: loader-spin 0.8s linear infinite;
  flex: 0 0 auto;
}

.module-panel-error {
  color: var(--signal-red-deep);
  border-color: var(--signal-red-border);
  background: var(--signal-red-light);
}

.module-panel-error::before {
  content: none;
}

@keyframes panel-fade-in {
  /* Nur opacity – kein transform. transform wuerde fuer die Dauer der
     Animation einen Containing-Block fuer position:fixed-Descendants
     erzeugen und Modale damit relativ zum Panel positionieren. */
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* ── Mobile-Top-Header mit Hamburger ──────────────────────── */
.app-mobile-bar {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--preview-card-bg);
  border-bottom: 1px solid var(--preview-border);
  position: relative;
  z-index: 30;
}

.app-mobile-bar-toggle {
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--preview-border);
  background: #ffffff;
  border-radius: 10px;
  color: #334155;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.14s ease, border-color 0.14s ease, color 0.14s ease;
}

.app-mobile-bar-toggle:hover {
  border-color: rgba(62, 107, 140, 0.42);
  color: #284b63;
  background: rgba(62, 107, 140, 0.08);
}

.app-mobile-bar-toggle .material-icons {
  font-size: 22px;
}

.app-mobile-bar-title {
  font-family: 'Manrope', 'Inter', sans-serif;
  font-size: 15px;
  font-weight: 700;
  color: #0f172a;
  letter-spacing: -0.01em;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 860px) {
  .app-mobile-bar {
    display: flex;
  }

  /* Auf Mobile reicht die App-Shell ueber die volle Breite – kein
     Sidebar-Slot mehr im Flex-Flow, weil der Drawer position:fixed ist. */
  .content-area {
    width: 100%;
  }
}

@media (max-width: 760px) {
  .app-boot-shell {
    width: calc(100% - 24px);
    padding: 12px 14px;
  }

  .content-loader-shell {
    width: calc(100% - 24px);
    padding: 12px 14px;
  }

  .app {
    height: 100dvh;
    min-height: 100dvh;
  }
}

/* Generische Modul-Mobile-Anpassungen, falls einzelne Module keine eigene
   Phone-Behandlung haben – greift nur wenn das Modul den Standard-Container
   nutzt (display: flex via .module). */
@media (max-width: 480px) {
  .module-panel-loading,
  .module-panel-error {
    max-width: calc(100% - 24px);
    font-size: 13px;
    padding: 10px 12px;
  }
}
