:root {
    /* Grok xAI Dark Mode Palette */
    --bg-primary: #000000;
    --bg-secondary: #0f0f0f;
    --bg-tertiary: #1a1a1a; /* Für Eingabefeld und Hover-Effekte */
    --text-primary: #f5f5f5;
    --text-secondary: #888888;
    --border-color: #2a2a2a;
    --accent: #ffffff; /* Grok nutzt oft Weiße/Schwarze Kontraste */
    --user-bubble: #1a1a1a;
}

* { 
    box-sizing: border-box; 
    margin: 0; 
    padding: 0; 
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; 
}

body {
    background: var(--bg-primary);
    height: 100dvh; /* Dynamic Viewport Height - passt sich mobilen Browserleisten an */
    width: 100vw;
    color: var(--text-primary);
    overflow: hidden; /* Verhindert Scrollen auf Body-Ebene */
}

/* Vollbild-Container statt Smartphone-Frame */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100dvh; /* Dynamic Viewport Height */
    width: 100vw;
    max-width: 900px; /* Zentriert den Chat wie bei Grok/ChatGPT */
    margin: 0 auto;
    background: var(--bg-primary);
    border-left: 1px solid var(--border-color);
    border-right: 1px solid var(--border-color);
}

/* Minimalistische Kopfzeile */
.app-header {
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-primary);
    flex-shrink: 0; /* Verhindert das Schrumpfen des Headers */
}

.header-title {
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -0.5px;
}

.header-actions {
    display: flex;
    gap: 8px;
}

.header-actions button {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, color 0.2s;
}

.header-actions button:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

/* Chat-Bereich */
.chat-area {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 24px;
    scroll-behavior: smooth;
}

/* Custom Scrollbar (Grok-Style) */
.chat-area::-webkit-scrollbar {
    width: 6px;
}
.chat-area::-webkit-scrollbar-track {
    background: transparent;
}
.chat-area::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: 3px;
}
.chat-area::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* Nachrichten-Styling */
.chat-bubble {
    max-width: 100%;
    line-height: 1.6;
    font-size: 16px;
    animation: fadeIn 0.3s ease;
    word-wrap: break-word;
    white-space: pre-wrap;
}

/* User-Nachrichten: Leicht abgesetzter Block, keine runde Blase */
.chat-bubble.user {
    align-self: flex-end;
    background: var(--user-bubble);
    color: var(--text-primary);
    padding: 12px 16px;
    border-radius: 12px;
    max-width: 75%;
    border: 1px solid var(--border-color);
}

/* KI-Nachrichten: Fließtext ohne Blase (Grok-Typisch) */
.chat-bubble.ai {
    align-self: flex-start;
    background: transparent;
    padding: 0;
    max-width: 85%;
}

/* Eingabebereich unten */
.input-area {
    padding: 12px 24px 16px 24px; /* Optimiertes Padding für mobile Geräte */
    background: var(--bg-primary);
    border-top: 1px solid var(--border-color);
    flex-shrink: 0; /* Verhindert, dass die Box vom Chat-Verlauf weggedrückt wird */
}

.input-wrapper {
    display: flex;
    align-items: flex-end; /* Erlaubt der Textarea nach oben zu wachsen */
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 8px 8px 8px 20px;
    transition: border-color 0.2s;
}

.input-wrapper:focus-within {
    border-color: var(--text-secondary);
}

#userInput {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    resize: none;
    outline: none;
    font-size: 16px;
    max-height: 200px;
    line-height: 1.5;
    padding: 8px 0;
    overflow-y: auto;
}
#userInput::-webkit-scrollbar {
    width: 4px;
}
#userInput::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 2px;
}

#sendBtn {
    background: var(--text-primary);
    border: none;
    width: 36px;
    height: 36px;
    min-width: 36px; /* Verhindert Quetschen */
    border-radius: 50%;
    color: var(--bg-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s, transform 0.1s;
    margin-left: 12px;
}

#sendBtn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

#sendBtn:active {
    transform: scale(0.95);
}

/* Schreibanimation */
.typing-indicator {
    align-self: flex-start;
    padding: 12px 0;
    display: flex;
    gap: 6px;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: var(--text-secondary);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

.hidden { display: none !important; }

/* Animationen */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); opacity: 0.3; }
    40% { transform: scale(1); opacity: 1; }
}