.typing-indicator {
    display: inline-flex;
    gap: 6px;
    align-items: center;
}
.typing-indicator span {
    width: 6px; height: 6px; border-radius: 50%;
    background: currentColor; opacity: .35;
    animation: ti-bounce 1s infinite ease-in-out;
}
.typing-indicator span:nth-child(2) { animation-delay: .15s; }
.typing-indicator span:nth-child(3) { animation-delay: .3s; }

@keyframes ti-bounce {
    0%, 80%, 100% { transform: translateY(0); opacity: .35; }
    40% { transform: translateY(-4px); opacity: .9; }
}


.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px 30px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.chat-header > div {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chat-header h1 {
    margin: 0;
    font-size: 24px;
    font-weight: 600;
}

.status-indicator {
    font-size: 12px;
    font-weight: 500;
    padding: 4px 12px;
    border-radius: 12px;
    display: inline-block;
    background: rgba(255, 255, 255, 0.2);
}

.status-ready {
    background: rgba(76, 175, 80, 0.3);
}

.status-offline {
    background: rgba(244, 67, 54, 0.3);
}

.status-warning {
    background: rgba(255, 152, 0, 0.3);
}

.status-checking {
    background: rgba(255, 255, 255, 0.2);
}

/* ... existing code ... */

.system-message {
    justify-content: center;
}

.system-message .message-content {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
    text-align: center;
    font-size: 14px;
}

/* ... existing code ... */
* {

    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    background: #f5f5f5;
    height: 100vh;
    overflow: hidden;
}

.chat-interface {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 1000px;
    margin: 0 auto;
    background: #f5f5f5;
}

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px 30px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.chat-header h1 {
    margin: 0;
    font-size: 24px;
    font-weight: 600;
}

.clear-button {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    padding: 10px 15px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 18px;
    transition: background 0.3s;
}

.clear-button:hover {
    background: rgba(255, 255, 255, 0.3);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.message {
    display: flex;
    gap: 12px;
    animation: fadeIn 0.3s ease-in;
}

.message-avatar {
    font-size: 32px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.message-content {
    max-width: 70%;
    padding: 15px 20px;
    border-radius: 18px;
    line-height: 1.5;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.user-message {
    flex-direction: row-reverse;
}

.user-message .message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.assistant-message .message-content {
    background: white;
    color: #333;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.typing-indicator {
    display: flex;
    gap: 4px;
    align-items: center;
    padding: 5px 0;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: #999;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

.chat-input {
    background: white;
    padding: 20px 30px;
    border-top: 1px solid #e0e0e0;
    display: flex;
    gap: 15px;
    align-items: flex-end;
}

#messageInput {
    flex: 1;
    padding: 12px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    font-size: 15px;
    font-family: inherit;
    resize: none;
    outline: none;
    transition: border-color 0.3s;
}

#messageInput:focus {
    border-color: #667eea;
}

#messageInput:disabled {
    background: #f5f5f5;
    cursor: not-allowed;
}

.send-button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    white-space: nowrap;
}

.send-button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.send-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.message-content h1 {
    font-size: 1.5em;
    margin: 0.5em 0;
    color: #333;
}

.message-content h2 {
    font-size: 1.3em;
    margin: 0.5em 0;
    color: #555;
}

.message-content h3 {
    font-size: 1.1em;
    margin: 0.5em 0;
    color: #666;
}

.message-content ul,
.message-content ol {
    margin: 0.5em 0;
    padding-left: 1.5em;
}

.message-content li {
    margin: 0.3em 0;
}

.message-content a {
    color: #667eea;
    text-decoration: none;
    border-bottom: 1px solid #667eea;
}

.message-content a:hover {
    color: #764ba2;
    border-bottom-color: #764ba2;
}

.message-content strong {
    font-weight: 600;
    color: #333;
}

.message-content em {
    font-style: italic;
}

.message-content code {
    background: #f4f4f4;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
}

.message-content p {
    margin: 0.5em 0;
}

.message-content p:first-child {
    margin-top: 0;
}

.message-content p:last-child {
    margin-bottom: 0;
}
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    background: #f5f5f5;
    height: 100vh;
    /* WICHTIG für Mobile: verhindert Overflow */
    height: 100dvh; /* Dynamic Viewport Height - berücksichtigt mobile Tastatur */
    overflow: hidden;
    /* Verhindert Bounce-Effekt auf iOS */
    position: fixed;
    width: 100%;
}

.chat-interface {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh; /* Dynamic Viewport Height */
    max-width: 1000px;
    margin: 0 auto;
    background: #f5f5f5;
    /* Verhindert Scrollen des gesamten Interfaces */
    overflow: hidden;
}

.chat-header {
    /* Fixiert den Header */
    flex-shrink: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px 30px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.chat-footer{
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    /* Wichtig: Muss scrollen können */
    -webkit-overflow-scrolling: touch; /* Smooth Scrolling auf iOS */
}

.chat-input {
    /* Fixiert die Input-Box am unteren Rand */
    flex-shrink: 0;
    background: white;
    padding: 20px 30px;
    border-top: 1px solid #e0e0e0;
    display: flex;
    gap: 15px;
    align-items: flex-end;
    /* Verhindert, dass Input mit Tastatur verschwindet */
    position: relative;
    bottom: 0;
}

#messageInput {
    flex: 1;
    padding: 12px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    font-size: 15px;
    font-family: inherit;
    resize: none;
    outline: none;
    transition: border-color 0.3s;
    /* Verhindert Zoom auf iOS beim Fokus */
    font-size: 16px; /* Mindestens 16px auf iOS! */
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-10px);
    }
}

/* Scrollbar Styling */
.chat-messages::-webkit-scrollbar {
    width: 8px;
}

.chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #555;
}

@media (max-width: 768px) {
    body {
        /* iOS Safari fix */
        height: 100vh;
        height: 100dvh;
    }

    .chat-interface {
        /* Nutze volle Höhe auf Mobile */
        max-width: 100%;
        height: 100vh;
        height: 100dvh;
    }

    .chat-header {
        padding: 12px 15px;
        min-height: 60px;
    }

    .chat-header h1 {
        font-size: 18px;
    }

    .chat-header > div {
        gap: 4px;
    }

    .status-indicator {
        font-size: 11px;
        padding: 3px 8px;
    }

    .clear-button {
        padding: 8px 12px;
        font-size: 16px;
    }

    .chat-messages {
        padding: 10px 15px;
        gap: 10px;
        /* Sicherstellen, dass Messages scrollen */
        flex: 1 1 auto;
        min-height: 0;
    }

    .message-avatar {
        font-size: 24px;
        width: 30px;
        height: 30px;
    }

    .message-content {
        max-width: 80%;
        padding: 10px 15px;
        font-size: 14px;
    }

    .chat-input {
        padding: 10px 15px;
        gap: 10px;
        /* Wichtig: An unterer Kante fixieren */
        position: sticky;
        bottom: 0;
        z-index: 100;
        /* Schatten nach oben für bessere Sichtbarkeit */
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    }

    #messageInput {
        font-size: 16px; /* Verhindert Zoom auf iOS */
        padding: 10px 12px;
        max-height: 100px;
        min-height: 44px; /* iOS Touch-Target Minimum */
    }

    .send-button {
        padding: 10px 16px;
        font-size: 14px;
        min-height: 44px; /* iOS Touch-Target Minimum */
        min-width: 44px;
    }

    /* Markdown-Elemente auf Mobile anpassen */
    .message-content h1 {
        font-size: 1.3em;
    }

    .message-content h2 {
        font-size: 1.2em;
    }

    .message-content h3 {
        font-size: 1.1em;
    }

    .message-content ul,
    .message-content ol {
        padding-left: 1.2em;
    }
}

/* Extra klein (sehr kleine Smartphones) */
@media (max-width: 480px) {
    .chat-header h1 {
        font-size: 16px;
    }

    .message-content {
        max-width: 85%;
        font-size: 13px;
    }

    .chat-input {
        padding: 8px 10px;
    }

    #messageInput {
        font-size: 16px;
        padding: 8px 10px;
    }

    .send-button {
        padding: 8px 12px;
        font-size: 24px; /* Nur Icon */
    }

    .send-button {
        /* Nur Emoji auf sehr kleinen Screens */
        font-size: 20px;
    }
}

/* Landscape Mode auf Mobile */
@media (max-width: 768px) and (orientation: landscape) {
    .chat-header {
        padding: 8px 15px;
        min-height: 50px;
    }

    .chat-header h1 {
        font-size: 16px;
    }

    .status-indicator {
        display: none; /* Platz sparen im Landscape */
    }

    .chat-input {
        padding: 8px 15px;
    }

    #messageInput {
        rows: 2;
        max-height: 60px;
    }
}

/* iOS Safari spezifische Fixes */
@supports (-webkit-touch-callout: none) {
    /* iOS Safari */
    body {
        height: -webkit-fill-available;
    }

    .chat-interface {
        height: -webkit-fill-available;
    }
}
