/* -------------------------------------------------
   1. VARIABLES & THEMING
   ------------------------------------------------- */
:root {
  --bg-color: #030304;
  --card-bg: rgba(255, 255, 255, 0.02);
  --glass-border: rgba(255, 255, 255, 0.08);
  --pill-bg: rgba(10, 10, 12, 0.8);
  --text-main: #f4f4f5;
  --text-muted: #888890;
  --accent: #8b5cf6;
  --aurora-1: rgba(139, 92, 246, 0.08);
  --aurora-2: rgba(59, 130, 246, 0.08);
  --input-bg: rgba(255, 255, 255, 0.03);
  --font-heading: 'Outfit', sans-serif;
  --font-body: 'Inter', sans-serif;
}

[data-theme="light"] {
  --bg-color: #f2f2f5; 
  --card-bg: rgba(255, 255, 255, 0.65);
  --glass-border: rgba(0, 0, 0, 0.06);
  --pill-bg: rgba(255, 255, 255, 0.85);
  --text-main: #18181b; 
  --text-muted: #52525b; 
  --accent: #7c3aed;
  --aurora-1: rgba(139, 92, 246, 0.15); 
  --aurora-2: rgba(59, 130, 246, 0.15);
  --input-bg: rgba(0, 0, 0, 0.04);
}

/* -------------------------------------------------
   2. RESET & BASE
   ------------------------------------------------- */
*, *::before, *::after { margin:0; padding:0; box-sizing:border-box; }

/* FIX: 100dvh für Mobile Browser Adressleisten-Problem */
html, body {
    height: 100%;
    overflow: hidden; /* Scrollen nur im Chat-Fenster */
    overscroll-behavior: none; /* Verhindert "Bounce" auf iOS */
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    font-family: var(--font-body);
    transition: background-color 0.3s ease, color 0.3s ease;
    /* Standard Cursor */
    cursor: default;
}

/* Background Effects */
body::before {
  content: ""; position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)' opacity='0.05'/%3E%3C/svg%3E");
  pointer-events: none; z-index: -1; mix-blend-mode: overlay; 
}
body::after {
  content: ""; position: fixed; top: -20%; left: -10%; width: 70vw; height: 70vw;
  background: radial-gradient(circle, var(--aurora-1), transparent 70%);
  border-radius: 50%; animation: floatAurora 20s infinite alternate ease-in-out;
  z-index: -2; pointer-events: none;
}
.ambient-light {
    position: fixed; bottom: -20%; right: -10%; width: 60vw; height: 60vw;
    background: radial-gradient(circle, var(--aurora-2), transparent 70%);
    border-radius: 50%; animation: floatAurora 25s infinite alternate-reverse ease-in-out;
    z-index: -2; pointer-events: none;
}
@keyframes floatAurora {
  0% { transform: translate(0, 0) scale(1); opacity: 0.8; }
  100% { transform: translate(50px, 50px) scale(1.1); opacity: 1; }
}

/* -------------------------------------------------
   3. HEADER
   ------------------------------------------------- */
.header {
  position:fixed; top:20px; left:50%; transform:translateX(-50%);
  width:90%; max-width:900px; height:60px;
  background:var(--pill-bg);
  backdrop-filter:blur(12px); -webkit-backdrop-filter:blur(12px);
  border:1px solid var(--glass-border); border-radius:100px;
  display:flex; justify-content:space-between; align-items:center;
  padding:0 8px 0 24px; z-index:1000;
}
.logo { font-family: var(--font-heading); font-weight: 600; font-size: 1.1rem; color: var(--text-main); text-decoration: none; }
.header-actions { display: flex; align-items: center; gap: 8px; }
.theme-toggle { background: transparent; border: none; color: var(--text-muted); font-size: 1.1rem; padding: 8px; cursor: pointer; }
.contact-btn-header { background:var(--text-main); color:var(--bg-color); padding:8px 20px; border-radius:50px; font-size:.85rem; font-weight:500; text-decoration: none; }

/* -------------------------------------------------
   4. CHAT INTERFACE
   ------------------------------------------------- */
.app-container {
    height: 100dvh; 
    width: 100%;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding-top: 80px; padding-bottom: 20px;
}
.chat-window {
    width: 95%; max-width: 900px;
    flex: 1; max-height: 100%;
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    display: flex; flex-direction: column;
    overflow: hidden;
    box-shadow: 0 20px 50px rgba(0,0,0,0.2);
    backdrop-filter: blur(10px);
}
#chat-history {
    flex: 1; padding: 20px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    display: flex; flex-direction: column; gap: 15px;
}
.msg {
    max-width: 85%; padding: 12px 18px;
    border-radius: 18px; font-size: 0.95rem; line-height: 1.5;
    word-wrap: break-word;
}
.msg.user {
    align-self: flex-end; background-color: var(--accent);
    color: #fff; border-bottom-right-radius: 4px;
}
.msg.ai {
    align-self: flex-start;
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
    border: 1px solid var(--glass-border);
    border-bottom-left-radius: 4px;
}
[data-theme="light"] .msg.ai {
    background-color: rgba(255, 255, 255, 0.6);
    border-color: rgba(0,0,0,0.05);
}

.input-area {
    padding: 15px; background: rgba(0,0,0,0.02);
    border-top: 1px solid var(--glass-border);
    display: flex; gap: 10px; align-items: center;
    flex-shrink: 0; 
}
input {
    flex: 1; padding: 14px 20px;
    border-radius: 50px; border: 1px solid var(--glass-border);
    background: var(--input-bg); color: var(--text-main);
    font-size: 1rem; outline: none; -webkit-appearance: none;
}
input:focus { border-color: var(--accent); background: var(--card-bg); }
button#send-btn {
    width: 48px; height: 48px; border-radius: 50%;
    border: none; background: var(--text-main);
    color: var(--bg-color); font-size: 1.1rem;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; cursor: pointer;
}

/* Footer (Desktop Only) */
.desktop-footer {
    position: fixed; bottom: 0; width: 100%;
    text-align: center; padding: 10px 0; 
    color: var(--text-muted); font-size: 0.75rem;
    pointer-events: none;
}

/* Mobile Tweaks */
@media (max-width: 768px) {
    .header { width: 95%; top: 10px; padding: 0 15px; }
    .app-container { padding-top: 80px; padding-bottom: 0; }
    .chat-window { 
        width: 100%; border-radius: 20px 20px 0 0; 
        border-bottom: none; border-left: none; border-right: none;
    }
    .desktop-footer { display: none; }
}

/* -------------------------------------------------
   5. MARKDOWN STYLING
   ------------------------------------------------- */
.msg.ai p { margin-bottom: 10px; }
.msg.ai p:last-child { margin-bottom: 0; }
.msg.ai strong { color: var(--accent); font-weight: 600; }
.msg.ai em { font-style: italic; opacity: 0.9; }

/* Code Blocks */
.msg.ai pre {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--glass-border);
    border-radius: 8px; padding: 12px; margin: 10px 0;
    overflow-x: auto;
    font-family: 'Courier New', monospace; font-size: 0.85rem;
}
.msg.ai code {
    background: rgba(255, 255, 255, 0.1);
    padding: 2px 6px; border-radius: 4px;
    font-family: monospace; font-size: 0.9em; color: var(--accent);
}
.msg.ai pre code { background: transparent; padding: 0; color: var(--text-main); }
.msg.ai a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.msg.ai ul, .msg.ai ol { margin: 10px 0 10px 20px; }
.msg.ai li { margin-bottom: 5px; }

/* Light Mode Markdown overrides */
[data-theme="light"] .msg.ai pre { background: rgba(0, 0, 0, 0.05); }
[data-theme="light"] .msg.ai code { background: rgba(0, 0, 0, 0.05); }
[data-theme="light"] .msg.ai pre code { color: #333; }

/* -------------------------------------------------
   6. 404 PAGE STYLES (Restored Design)
   ------------------------------------------------- */
.error-page-body {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    height: 100vh; overflow: hidden; position: relative; background: var(--bg-color);
}
.error-page-body .aurora-bg {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: radial-gradient(circle at 30% 20%, var(--aurora-1), transparent 60%),
                radial-gradient(circle at 70% 80%, var(--aurora-2), transparent 60%);
    z-index: -2; animation: pulseAurora 8s infinite alternate ease-in-out;
}
@keyframes pulseAurora { 0% { opacity: 0.6; } 100% { opacity: 1; } }
.error-page-body .noise-texture {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)' opacity='0.05'/%3E%3C/svg%3E");
    pointer-events: none; z-index: -1; mix-blend-mode: overlay;
}
.error-title {
    font-family: 'Syne', sans-serif; font-size: clamp(6rem, 20vw, 15rem); font-weight: 800;
    background: linear-gradient(135deg, var(--text-main), var(--accent));
    -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
    margin: 0; line-height: 0.9; letter-spacing: -0.05em;
}
.error-subtitle {
    font-family: 'Space Grotesk', sans-serif; font-size: clamp(1rem, 3vw, 1.5rem);
    font-weight: 400; color: var(--text-muted); letter-spacing: 0.3em;
    margin: 20px 0 40px 0; text-transform: uppercase;
}
.btn-link {
    font-family: 'Space Grotesk', sans-serif; display: inline-block; padding: 16px 48px;
    background: var(--text-main); color: var(--bg-color); text-decoration: none;
    border-radius: 50px; font-weight: 500; font-size: 0.95rem; letter-spacing: 0.05em;
    transition: transform 0.3s, opacity 0.3s;
}
.btn-link:hover { transform: translateY(-2px); opacity: 0.9; }