:root {
  color-scheme: light dark;
  --bg: #faf9f7;
  --bg-surface: #ffffff;
  --bg-surface-translucent: rgba(255, 255, 255, 0.88);
  --bg-elevated: #f1efeb;
  --text: #1c1917;
  --text-muted: #57534e;
  --text-faint: #a8a29e;
  --border: #e7e5e0;
  --border-strong: #d6d3d1;

  --accent: #76925a;
  --accent-hover: #647d4d;
  --accent-text: #ffffff;

  --danger: #a3573b;
  --warn: #b8893f;
  --success: #6f8b56;

  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-8: 3rem;

  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 18px;

  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'Cascadia Code', monospace;
  --fs-xs: 0.75rem;
  --fs-sm: 0.875rem;
  --fs-base: 1rem;
  --fs-lg: 1.125rem;
  --fs-xl: 1.5rem;
  --fs-2xl: 2rem;
  --fs-3xl: 2.5rem;

  --shadow-sm: 0 1px 2px rgba(28, 25, 23, 0.05);
  --shadow-md: 0 4px 16px rgba(28, 25, 23, 0.08);
  --shadow-lg: 0 12px 32px rgba(28, 25, 23, 0.14);

  --motion-fast: 150ms cubic-bezier(0.2, 0.8, 0.2, 1);
  --motion-base: 220ms cubic-bezier(0.2, 0.8, 0.2, 1);

  /* Backdrop / Hintergrund */
  --bg-image: url('/assets/monstera-bg.jpg');
  --bg-overlay: rgba(250, 249, 247, 0.96);
  --bg-overlay-strong: rgba(250, 249, 247, 0.99);
  --topbar-bg: rgba(255, 255, 255, 0.92);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15140e;
    --bg-surface: #1c1a13;
    --bg-surface-translucent: rgba(28, 26, 19, 0.86);
    --bg-elevated: #24211a;
    --text: #f5f1e8;
    --text-muted: #a8a294;
    --text-faint: #7e7670;
    --border: #3a3628;
    --border-strong: #524c47;
    --accent: #a4be88;
    --accent-hover: #b5cc9c;
    --accent-soft: rgba(164, 190, 136, 0.15);
    --danger: #d97c3e;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 6px 20px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 14px 36px rgba(0, 0, 0, 0.55);

    --bg-overlay: rgba(21, 20, 14, 0.92);
    --bg-overlay-strong: rgba(21, 20, 14, 0.98);
    --topbar-bg: rgba(28, 26, 19, 0.92);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { height: 100%; }
body {
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  position: relative;
  isolation: isolate;
}

/* Monstera-Hintergrund mit Overlay (zwei Pseudo-Layer, fixiert) */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: var(--bg-image);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-attachment: fixed;
  /* dezenter — die Hauptlesbarkeit kommt aus den Cards */
  opacity: 0.35;
  filter: saturate(0.6) blur(0.5px);
  z-index: -2;
}
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  z-index: -1;
  /* leichter Vignettieren-Effekt fuer Tiefe */
  background-image: radial-gradient(ellipse at center, transparent 0%, var(--bg-overlay) 70%);
}

/* Reduce-Motion respektieren */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}

/* Phase 5S: Globaler Mobile-Safety-Net gegen horizontal overflow */
html, body { overflow-x: hidden; }
@media (max-width: 880px) {
  .app-main { padding: var(--space-3); }
}

/* Phase 8A: Aggressiver Mobile-Overflow-Guard */
html, body, .app-shell {
  max-width: 100vw;
  overflow-x: hidden;
}
/* app-main + app-topbar: nur horizontal clippen, Dropdowns/Modals dürfen nach unten ausbrechen */
.app-main {
  max-width: 100vw;
  overflow-x: clip;
  overflow-y: visible;
}
.app-main > * { min-width: 0; max-width: 100%; }
.app-topbar {
  max-width: 100vw;
  overflow-x: clip;
  overflow-y: visible;
}
.app-topbar > * { min-width: 0; }
