* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg: #1F2127; /* Anthrazit */
    --panel: #252730;
    --bubble: #2B2D35;
    --bubble-2: #32343d; /* leicht heller für Verlauf */
    --text: #ffffff;
    --muted: #9EA2AD;
    --turquoise: #11B5A4; /* Sekundär */
    --turquoise-600: #0FA090;
    --gold: #D4AF37; /* Akzent */
    --gold-soft: #E1C565;
    --border: #4d4d4f;
    --ring: 0 0 0 2px var(--turquoise);
    /* Themeable glow + rail colors (defaults = Executive) */
    --glow1: rgba(17, 181, 164, 0.10);
    --glow2: rgba(212, 175, 55, 0.06);
    --rail1: rgba(0,255,210,0.60);          /* assistant rails */
    --rail1-shadow-1: rgba(0,255,210,0.35);
    --rail1-shadow-2: rgba(0,255,210,0.18);
    --rail2: rgba(212,175,55,0.55);         /* user rails */
    --rail2-shadow-1: rgba(212,175,55,0.35);
    --rail2-shadow-2: rgba(212,175,55,0.18);
    --rail-thickness: 2px;
    /* Glow radii (typing + pulse) */
    --glow-const-small: 10px;
    --glow-const-large: 20px;
    --glow-rest-small: 8px;
    --glow-rest-large: 16px;
    --glow-peak-small: 14px;
    --glow-peak-large: 26px;
    --header-rail-thickness: 3px;
    --header-rails-height: 56px;
    /* Grid line color for background (used in repeating-linear-gradients) */
    --grid-line: rgba(255,255,255,0.03);
}

/* Local Satoshi font (weights: 300, 400, 500, 700, 900; normal & italic) */
@font-face {
    font-family: 'Satoshi';
    src: url('fonts/Satoshi-Light.otf') format('opentype');
    font-weight: 300;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Satoshi';
    src: url('fonts/Satoshi-LightItalic.otf') format('opentype');
    font-weight: 300;
    font-style: italic;
    font-display: swap;
}
@font-face {
    font-family: 'Satoshi';
    src: url('fonts/Satoshi-Regular.otf') format('opentype');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Satoshi';
    src: url('fonts/Satoshi-Italic.otf') format('opentype');
    font-weight: 400;
    font-style: italic;
    font-display: swap;
}
@font-face {
    font-family: 'Satoshi';
    src: url('fonts/Satoshi-Medium.otf') format('opentype');
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Satoshi';
    src: url('fonts/Satoshi-MediumItalic.otf') format('opentype');
    font-weight: 500;
    font-style: italic;
    font-display: swap;
}
@font-face {
    font-family: 'Satoshi';
    src: url('fonts/Satoshi-Bold.otf') format('opentype');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Satoshi';
    src: url('fonts/Satoshi-BoldItalic.otf') format('opentype');
    font-weight: 700;
    font-style: italic;
    font-display: swap;
}
@font-face {
    font-family: 'Satoshi';
    src: url('fonts/Satoshi-Black.otf') format('opentype');
    font-weight: 900;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Satoshi';
    src: url('fonts/Satoshi-BlackItalic.otf') format('opentype');
    font-weight: 900;
    font-style: italic;
    font-display: swap;
}

/* Cormorant Garamond (local) */
@font-face {
    font-family: 'Cormorant Garamond';
    src: url('fonts/CormorantGaramond-Regular.ttf') format('truetype');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Cormorant Garamond';
    src: url('fonts/CormorantGaramond-Medium.ttf') format('truetype');
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Cormorant Garamond';
    src: url('fonts/CormorantGaramond-SemiBold.ttf') format('truetype');
    font-weight: 600;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Cormorant Garamond';
    src: url('fonts/CormorantGaramond-Bold.ttf') format('truetype');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Cormorant Garamond';
    src: url('fonts/CormorantGaramond-Italic.ttf') format('truetype');
    font-weight: 400;
    font-style: italic;
    font-display: swap;
}
html {
    height: -webkit-fill-available; /* iOS Safari: dyn. Viewport */
}

body {
    font-family: 'Satoshi', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    height: 100vh;
    height: 100dvh; /* Dynamic viewport height für mobile */
    min-height: -webkit-fill-available; /* iOS Safari fallback */
    overflow: hidden;
    position: fixed; /* Verhindert Scrollen des Body */
    width: 100%;
    -webkit-text-size-adjust: 100%; /* iOS Zoom-Verhalten stabilisieren */
    background-image:
        radial-gradient(600px 400px at 50% -10%, var(--glow1), rgba(0,0,0,0) 60%),
        radial-gradient(700px 500px at 80% 120%, var(--glow2), rgba(0,0,0,0) 55%),
        linear-gradient(to bottom, rgba(255,255,255,0.02), rgba(255,255,255,0.00)),
        repeating-linear-gradient(0deg, var(--grid-line) 0 1px, transparent 1px 22px),
        repeating-linear-gradient(90deg, var(--grid-line) 0 1px, transparent 1px 22px);
    background-attachment: fixed, fixed, fixed, fixed, fixed;
}

/* Subtile SVG-Noise-Overlay */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='60' height='60' viewBox='0 0 60 60'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix type='saturate' values='0'/><feComponentTransfer><feFuncA type='table' tableValues='0 0.04'/></feComponentTransfer></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
    background-size: 300px 300px;
    background-repeat: repeat;
    opacity: 0.08;
}

.chat-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh; /* Dynamic viewport height für mobile */
    min-height: -webkit-fill-available; /* iOS Safari */
    max-width: 768px;
    margin: 0 auto;
    background-color: var(--bg);
    position: relative;
    z-index: 1; /* über Noise-Layer */
}

.chat-header {
    padding: 20px 20px 48px 20px;
    margin-bottom: 10px;
    border-bottom: 2px solid var(--border);
    background-color: var(--panel);
    text-align: left;
    position: relative; /* für Theme-UI */
    display: flex;
    align-items: center;
    justify-content: flex-start;
    min-height: 92px;
}

.chat-header h1 {
    font-size: 36px;
    font-weight: 700;
    font-family: 'Cormorant Garamond', 'Satoshi', serif;
    color: var(--text);
    margin: 0;
    line-height: 1.0;
    position: relative;
    z-index: 1;
    letter-spacing: 0.4px;
    text-decoration: underline;
    text-decoration-thickness: 2px;
    text-underline-offset: 3px;
}

/* Branding: kein goldener Mittel-Glow mehr */
.chat-header::before { display: none; }

/* Branding block */
.brand { position: relative; z-index: 1; }
.brand { margin-top: 6px; }
.brand-subtitle { margin-top: 3px; font-size: 14px; color: var(--muted); }

.mode-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
}

.mode-name {
    font-size: 14px;
    color: #8e8ea0;
}

.mode-badge {
    background-color: var(--turquoise);
    color: #ffffff;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.mode-badge.pro {
    background-color: #ff6b35;
}

.mode-badge.enterprise {
    background-color: #8b5cf6;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling auf iOS */
}

.message {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.user-message {
    justify-content: flex-end;
}

.assistant-message {
    justify-content: flex-start;
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
    background-color: #10a37f;
    overflow: hidden;
    display: none;
}

.avatar-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.user-message .message-avatar {
    background-color: #5436da;
}

.message-content {
    max-width: 70%;
    padding: 12px 16px;
    border-radius: 12px;
    background-color: transparent;
    word-wrap: break-word;
    line-height: 1.5;
    position: relative;
}

.user-message .message-content {
    background: transparent;
    box-shadow: none;
    color: var(--text);
}
.assistant-message .message-content {
    background: transparent;
    box-shadow: none;
}

/* Technical parallel rails (open ends) */
.assistant-message .message-content::before,
.assistant-message .message-content::after {
    content: "";
    position: absolute;
    left: -6px;
    right: -6px;
    height: var(--rail-thickness, 2px);
    background: linear-gradient(to right, rgba(0,0,0,0) 0, rgba(0,0,0,0) 10px, var(--rail1) 26px, var(--rail1) calc(100% - 26px), rgba(0,0,0,0) calc(100% - 10px), rgba(0,0,0,0) 100%);
    box-shadow: 0 0 10px var(--rail1-shadow-1), 0 0 18px var(--rail1-shadow-2);
    border-radius: 2px;
    pointer-events: none;
}
.assistant-message .message-content::before { top: 6px; }
.assistant-message .message-content::after  { bottom: 6px; }

.user-message .message-content::before,
.user-message .message-content::after {
    content: "";
    position: absolute;
    left: -6px;
    right: -6px;
    height: var(--rail-thickness, 2px);
    background: linear-gradient(to right, rgba(0,0,0,0) 0, rgba(0,0,0,0) 10px, var(--rail2) 26px, var(--rail2) calc(100% - 26px), rgba(0,0,0,0) calc(100% - 10px), rgba(0,0,0,0) 100%);
    box-shadow: 0 0 10px var(--rail2-shadow-1), 0 0 18px var(--rail2-shadow-2);
    border-radius: 2px;
    pointer-events: none;
}
.user-message .message-content::before { top: 6px; }
.user-message .message-content::after  { bottom: 6px; }

/* Enable backdrop blur only when supported (mobile-friendly) */
@supports ((-webkit-backdrop-filter: blur(6px)) or (backdrop-filter: blur(6px))) {
    .assistant-message .message-content {
        -webkit-backdrop-filter: saturate(160%) blur(8px);
        backdrop-filter: saturate(160%) blur(8px);
    }
    .user-message .message-content {
        -webkit-backdrop-filter: saturate(140%) blur(6px);
        backdrop-filter: saturate(140%) blur(6px);
    }
}

.message-content p {
    margin: 0;
    white-space: pre-wrap;
}

/* Markdown Grundstile */
.message-content strong { font-weight: 700; }
.message-content em { font-style: italic; }
.message-content code {
    background: #2f3138;
    padding: 0 6px;
    border-radius: 6px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 0.95em;
}
.message-content a {
    color: var(--turquoise);
    text-decoration: underline;
}
.message-content ul {
    padding-left: 20px;
    margin: 8px 0;
}
.message-content li {
    margin: 4px 0;
}

.chat-input-container {
    padding: 20px;
    border-top: 1px solid var(--border);
    background-color: var(--bg);
}

.chat-input-wrapper {
    position: relative;
    display: flex;
    align-items: flex-end;
    background-color: var(--panel);
    border-radius: 24px;
    padding: 12px 16px;
    border: 1px solid var(--border);
    transition: border-color 0.2s;
}

.chat-input-wrapper:focus-within { border-color: var(--turquoise); box-shadow: var(--ring); }

#messageInput {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: var(--text);
    font-size: 16px;
    line-height: 1.5;
    resize: none;
    min-height: 24px;
    max-height: 120px;
    font-family: inherit;
}

#messageInput::placeholder {
    color: #8e8ea0;
}

/* Neon Pulse on wrapper while typing (focus) */
.chat-input-wrapper.typing-active {
    border-color: var(--turquoise);
    box-shadow: 0 0 var(--glow-const-small) var(--rail1-shadow-1), 0 0 var(--glow-const-large) var(--rail1-shadow-2);
    transition: box-shadow 0.3s ease, border-color 0.2s ease;
    animation: pulse-glow 1.8s ease-in-out infinite;
}

@keyframes pulse-glow {
    0%, 100% {
        box-shadow: 0 0 var(--glow-rest-small) var(--rail1-shadow-1), 0 0 var(--glow-rest-large) var(--rail1-shadow-2);
    }
    50% {
        box-shadow: 0 0 var(--glow-peak-small) var(--rail1-shadow-1), 0 0 var(--glow-peak-large) var(--rail1-shadow-2);
    }
}

.send-button {
    background-color: var(--turquoise);
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s;
    margin-left: 8px;
    color: #ffffff;
}

.image-upload-button {
    background-color: var(--panel);
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s;
    margin-left: 8px;
    color: #ffffff;
    font-size: 16px;
}

.image-upload-button:hover { background-color: #3a3b43; }

.image-preview {
    max-width: 200px;
    max-height: 200px;
    border-radius: 8px;
    margin: 8px 0;
    object-fit: cover;
}

/* Attachment previews below input */
.attachment-preview-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.attachment-thumb {
    position: relative;
    width: 72px;
    height: 72px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #4d4d4f;
    background-color: #2f3138;
}

.attachment-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.remove-attachment {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: rgba(0,0,0,0.6);
    color: #fff;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
}

.structured-list {
    background-color: #2d2d30;
    border-radius: 8px;
    padding: 16px;
    margin: 12px 0;
    border-left: 4px solid var(--turquoise);
}

.structured-list h4 {
    color: #10a37f;
    margin-bottom: 12px;
    font-size: 16px;
}

.structured-list ul {
    margin: 0;
    padding-left: 20px;
}

.structured-list li {
    margin-bottom: 6px;
    line-height: 1.4;
}

.priority-high {
    color: #ff6b6b;
    font-weight: 600;
}

.priority-medium {
    color: #ffd93d;
    font-weight: 500;
}

.priority-low {
    color: #6bcf7f;
}

.send-button:hover:not(:disabled) { background-color: var(--turquoise-600); }

.send-button:disabled { background-color: #4d4d4f; cursor: not-allowed; }

.loading-indicator {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    background-color: #40414f;
    padding: 12px 20px;
    border-radius: 18px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.loading-dots {
    display: flex;
    gap: 4px;
    align-items: center;
}

.loading-dots span { width: 8px; height: 8px; background-color: var(--turquoise); border-radius: 50%; animation: loading-bounce 1.4s ease-in-out infinite both; }
.attachment-thumb { border: 1px solid rgba(212, 175, 55, 0.35); box-shadow: 0 2px 8px rgba(0,0,0,0.25); }

.loading-dots span:nth-child(1) {
    animation-delay: -0.32s;
}

.loading-dots span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes loading-bounce {
    0%, 80%, 100% {
        transform: scale(0);
    }
    40% {
        transform: scale(1);
    }
}

/* Upgrade Modal */
.upgrade-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.upgrade-modal-content {
    background-color: #40414f;
    border-radius: 12px;
    padding: 24px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    border: 1px solid #4d4d4f;
}

.upgrade-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.upgrade-header h3 {
    color: #ffffff;
    margin: 0;
    font-size: 20px;
}

.close-modal {
    background: none;
    border: none;
    color: #8e8ea0;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.upgrade-body p {
    color: #ffffff;
    margin-bottom: 16px;
    line-height: 1.5;
}

.upgrade-features {
    list-style: none;
    padding: 0;
    margin: 16px 0;
}

.upgrade-features li {
    color: #ffffff;
    padding: 8px 0;
    padding-left: 20px;
    position: relative;
}

.upgrade-features li::before {
    content: "✓";
    position: absolute;
    left: 0;
    color: #10a37f;
    font-weight: bold;
}

.upgrade-footer {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 24px;
}

.upgrade-btn, .cancel-btn {
    padding: 12px 24px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-weight: 500;
    transition: background-color 0.2s;
}

.upgrade-btn {
    background-color: #10a37f;
    color: #ffffff;
}

.upgrade-btn:hover {
    background-color: #0d8a6b;
}

.cancel-btn {
    background-color: #4d4d4f;
    color: #ffffff;
}

.cancel-btn:hover {
    background-color: #6d6d6f;
}

/* Mode Info Panel */
.mode-info-panel {
    position: fixed;
    top: 80px;
    right: 20px;
    width: 300px;
    background-color: #40414f;
    border-radius: 12px;
    padding: 20px;
    border: 1px solid #4d4d4f;
    z-index: 100;
    display: none;
}

.mode-info-content h4 {
    color: #ffffff;
    margin: 0 0 16px 0;
    font-size: 18px;
}

.mode-info-content h5 {
    color: #10a37f;
    margin: 16px 0 8px 0;
    font-size: 14px;
}

.mode-info-content ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.mode-info-content li {
    color: #ffffff;
    padding: 4px 0;
    padding-left: 16px;
    position: relative;
    font-size: 14px;
}

.mode-info-content li::before {
    content: "•";
    position: absolute;
    left: 0;
    color: #10a37f;
}

.limitations li::before {
    color: #ff6b6b;
}

.upgrade-btn {
    width: 100%;
    margin-top: 16px;
}

/* Scrollbar Styling */
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #4d4d4f;
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #6d6d6f;
}

/* Responsive Design */
@media (max-width: 768px) {
    body {
        height: 100vh;
        height: 100dvh;
        min-height: -webkit-fill-available;
        position: static; /* iOS Safari: verhindert Layoutprobleme */
        width: 100%;
        overflow: hidden;
    }
    
    .chat-container {
        max-width: 100%;
        height: 100vh;
        height: 100dvh;
        min-height: -webkit-fill-available;
        position: relative;
    }
    
    .message-content {
        max-width: 88%;
    }

    .message-avatar { display: none; }
    
    .chat-header {
        padding: 16px 16px 30px 16px;
        padding-top: max(16px, env(safe-area-inset-top));
        flex-shrink: 0;
    }
    .chat-header h1 { font-size: 28px; }
    .brand-subtitle { font-size: 13px; margin-top: 2px; }
    
    .chat-messages {
        padding: 16px;
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        min-height: 0; /* Wichtig für Flexbox */
    }
    
    .chat-input-container {
        padding: 16px;
        padding-bottom: max(16px, env(safe-area-inset-bottom));
        flex-shrink: 0;
        position: sticky;
        bottom: 0;
        background-color: var(--bg);
        border-top: 1px solid var(--border);
    }
    
    /* Input-Focus Verhalten */
    #messageInput:focus {
        transform: translateY(0);
    }
    
    /* Fallback für ältere Browser ohne dvh support */
    @supports not (height: 100dvh) {
        body {
            height: calc(100vh - 60px);
        }
        
        .chat-container {
            height: calc(100vh - 60px);
        }
    }
}

/* Header rails (animated lines in header) */
.header-rails {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 22px;
    height: var(--header-rails-height);
    z-index: 0;
    pointer-events: none;
    color: var(--rail2); /* stroke color via currentColor */
}
.header-rails svg { width: 100%; height: 100%; display: block; }
.header-rails .rail-glow ellipse { fill: var(--rail1); }
.header-rails path {
    stroke-width: var(--header-rail-thickness, 3px);
    vector-effect: non-scaling-stroke;
    shape-rendering: geometricPrecision;
}
.header-rails .rails-svg-mobile { display: none; }
@media (max-width: 768px) {
    :root { --header-rails-height: 44px; }
    .header-rails { height: var(--header-rails-height); bottom: 28px; }
    .header-rails .rails-svg-desktop { display: none; }
    .header-rails .rails-svg-mobile { display: block; }
}
/* ===================== THEMES ===================== */
/* HH-Gastrolution: Dunkelstahl, Rot, Edelstahl/Silber */
[data-theme="hh-gastrolution"] {
    --bg: #1E2329;
    --panel: #252A31;
    --bubble: #2b2f37;
    --bubble-2: #313541;
    --text: #ffffff;
    --muted: #A9B1BB;
    --turquoise: #D95555;        /* Accent 1 = Rot */
    --turquoise-600: #B33F3F;
    --gold: #C0C7CF;             /* Accent 2 = Edelstahl/Silber */
    --gold-soft: #D5DBE1;
    --border: #4a4f57;
    --ring: 0 0 0 2px var(--turquoise);
    --glow1: rgba(217, 85, 85, 0.10);
    --glow2: rgba(192, 199, 207, 0.08);
    --rail1: rgba(217,85,85,0.60);
    --rail1-shadow-1: rgba(217,85,85,0.35);
    --rail1-shadow-2: rgba(217,85,85,0.18);
    --rail2: rgba(192,199,207,0.55);
    --rail2-shadow-1: rgba(192,199,207,0.35);
    --rail2-shadow-2: rgba(192,199,207,0.18);
}

[data-theme="hh-gastrolution"] .chat-header {
    background-image:
        linear-gradient(180deg, rgba(30, 35, 41, 0.82), rgba(37, 42, 49, 0.88)),
        url("steel.png");
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    border-bottom-color: rgba(74, 79, 87, 0.8);
}

[data-theme="hh-gastrolution"] .header-rails {
    z-index: 0;
}

[data-theme="hh-gastrolution"] .chat-input-container {
    background-image:
        linear-gradient(180deg, rgba(30, 35, 41, 0.90), rgba(30, 35, 41, 0.94)),
        url("steel.png");
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    border-top-color: rgba(74, 79, 87, 0.85);
}

/* Bartend: Nachtblau, Kupfer, Champagner */
[data-theme="bartend"] {
    --bg: #0B1220;
    --panel: #111A2A;
    --bubble: #162238;
    --bubble-2: #1B2A44;
    --text: #ffffff;
    --muted: #A7B0C0;
    --turquoise: #B87333;        /* Accent 1 = Kupfer */
    --turquoise-600: #9D5F2C;
    --gold: #E6D8AD;             /* Accent 2 = Champagner */
    --gold-soft: #F2E7C6;
    --border: #3c4457;
    --ring: 0 0 0 2px var(--turquoise);
    --glow1: rgba(184, 115, 51, 0.10);
    --glow2: rgba(230, 216, 173, 0.08);
    --rail1: rgba(184,115,51,0.60);
    --rail1-shadow-1: rgba(184,115,51,0.35);
    --rail1-shadow-2: rgba(184,115,51,0.18);
    --rail2: rgba(230,216,173,0.55);
    --rail2-shadow-1: rgba(230,216,173,0.35);
    --rail2-shadow-2: rgba(230,216,173,0.18);
    /* softer, rounder glow radii */
    --glow-const-small: 14px;
    --glow-const-large: 26px;
    --glow-rest-small: 10px;
    --glow-rest-large: 22px;
    --glow-peak-small: 18px;
    --glow-peak-large: 34px;
}

/* Bartend: fluid overlay + softer bubble shapes */
[data-theme="bartend"] .message-content { border-radius: 18px; }
@supports ((-webkit-backdrop-filter: blur(6px)) or (backdrop-filter: blur(6px))) {
    [data-theme="bartend"] .assistant-message .message-content {
        -webkit-backdrop-filter: saturate(190%) blur(10px);
        backdrop-filter: saturate(190%) blur(10px);
    }
    [data-theme="bartend"] .user-message .message-content {
        -webkit-backdrop-filter: saturate(170%) blur(8px);
        backdrop-filter: saturate(170%) blur(8px);
    }
}
[data-theme="bartend"] body::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background-image:
        radial-gradient(1200px 800px at 22% 8%, rgba(184, 115, 51, 0.10), rgba(0,0,0,0) 60%),
        radial-gradient(900px 700px at 82% 112%, rgba(230, 216, 173, 0.08), rgba(0,0,0,0) 55%);
    filter: blur(18px);
    opacity: 0.10;
    will-change: transform;
    animation: bartend-flow 18s ease-in-out infinite alternate;
}
@keyframes bartend-flow {
    0%   { transform: translate3d(0,0,0) scale(1); }
    50%  { transform: translate3d(0,-1.5%,0) scale(1.015); }
    100% { transform: translate3d(0,0,0) scale(1); }
}

/* Boardroom: Schwarz, Bordeaux, Royal Purple */
[data-theme="boardroom"] {
    --bg: #000000;
    --panel: #0A0A0A;
    --bubble: #111111;
    --bubble-2: #181818;
    --text: #ffffff;
    --muted: #B0B0B0;
    --turquoise: #7A1F2A;        /* Accent 1 = Bordeaux */
    --turquoise-600: #5E1821;
    --gold: #6B2E9B;             /* Accent 2 = Royal Purple */
    --gold-soft: #8A52B8;
    --border: #2A2A2A;
    --ring: 0 0 0 2px var(--turquoise);
    --glow1: rgba(122, 31, 42, 0.10);
    --glow2: rgba(107, 46, 155, 0.08);
    --rail1: rgba(122,31,42,0.60);
    --rail1-shadow-1: rgba(122,31,42,0.35);
    --rail1-shadow-2: rgba(122,31,42,0.18);
    --rail2: rgba(107,46,155,0.55);
    --rail2-shadow-1: rgba(107,46,155,0.35);
    --rail2-shadow-2: rgba(107,46,155,0.18);
    --rail-thickness: 1px; /* eleganter, dünner */
    --header-rail-thickness: 2.5px; /* dezente 10% Reduktion */
}

/* Hibiscus & Basil: Pastell-Flieder Basis, NeonPink (Hibiskus) und Waldgrün (Basilikum) */
[data-theme="hibiscus-basil"] {
    --bg: #201C29;               /* dunkles Flieder */
    --panel: #262033;
    --bubble: #2D2740;
    --bubble-2: #332B4D;
    --text: #ffffff;
    --muted: #B9B3C9;
    --turquoise: #FF2BA6;        /* Accent 1 = NeonPink */
    --turquoise-600: #D42489;
    --gold: #1FB96E;             /* Accent 2 = Waldgrün */
    --gold-soft: #39D488;
    --border: #4A405C;
    --ring: 0 0 0 2px var(--turquoise);
    --glow1: rgba(255, 43, 166, 0.10);
    --glow2: rgba(31, 185, 110, 0.08);
    --rail1: rgba(255,43,166,0.60);
    --rail1-shadow-1: rgba(255,43,166,0.35);
    --rail1-shadow-2: rgba(255,43,166,0.18);
    --rail2: rgba(31,185,110,0.55);
    --rail2-shadow-1: rgba(31,185,110,0.35);
    --rail2-shadow-2: rgba(31,185,110,0.18);
}

/* Pâtisserie (Light): Creme & Leinen, Himbeere (Neon), Waldgrün */
[data-theme="patisserie"] {
    --bg: #FFF8F3;               /* Creme/Backpapier */
    --panel: #FFFFFF;
    --bubble: #FFF2EA;
    --bubble-2: #FDEAE0;
    --text: #2B2B2B;             /* dunkles Grau für Lesbarkeit */
    --muted: #6B7280;
    --turquoise: #E83E8C;        /* Himbeere (Neon-Pink) */
    --turquoise-600: #C22F71;
    --gold: #4A7C59;             /* Waldgrün */
    --gold-soft: #5A8B6A;
    --border: #E5E7EB;
    --ring: 0 0 0 2px var(--turquoise);
    --glow1: rgba(232, 62, 140, 0.10);
    --glow2: rgba(74, 124, 89, 0.08);
    --rail1: rgba(232,62,140,0.60);
    --rail1-shadow-1: rgba(232,62,140,0.35);
    --rail1-shadow-2: rgba(232,62,140,0.18);
    --rail2: rgba(74,124,89,0.55);
    --rail2-shadow-1: rgba(74,124,89,0.35);
    --rail2-shadow-2: rgba(74,124,89,0.18);
    --grid-line: rgba(43,43,43,0.06);
}

/* Chillmonitor: */
[data-theme="chillmonitor"] {
    --bg: #F4F7FF;               /* sehr helles Eisblau */
    --panel: #FFFFFF;
    --bubble: #EEF3FF;
    --bubble-2: #E1E8FF;
    --text: #0C1A3A;             /* sattes Dunkelblau */
    --muted: #5F6B8A;
    --turquoise: #3B82F6;        /* Primär-Blau */
    --turquoise-600: #2563EB;
    --gold: #1D4ED8;             /* Satter Königsblau */
    --gold-soft: #2563EB;
    --border: #C7D2FE;
    --ring: 0 0 0 2px rgba(59,130,246,0.65);
    --glow1: rgba(59, 130, 246, 0.12);
    --glow2: rgba(29, 78, 216, 0.10);
    --rail1: rgba(59,130,246,0.78);
    --rail1-shadow-1: rgba(59,130,246,0.45);
    --rail1-shadow-2: rgba(59,130,246,0.24);
    --rail2: rgba(29,78,216,0.82);
    --rail2-shadow-1: rgba(29,78,216,0.28);
    --rail2-shadow-2: rgba(29,78,216,0.16);
    --grid-line: rgba(12,26,58,0.06); /* leicht sichtbare Grid-Linien */
}

/* Brushed steel overlay for HH-Gastrolution */
[data-theme="hh-gastrolution"] body::after {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    background-image:
        url("assets/brushed-steel.svg"),
        repeating-linear-gradient(100deg, rgba(255,255,255,0.055) 0 1px, rgba(0,0,0,0) 1px 8px),
        repeating-linear-gradient(10deg, rgba(255,255,255,0.035) 0 1px, rgba(0,0,0,0) 1px 12px);
    background-size: 320px 320px, auto, auto;
    background-repeat: repeat, repeat, repeat;
    mix-blend-mode: soft-light;
    opacity: 0.12;
}

/* Theme switcher (header) */
.theme-switcher {
    position: absolute;
    right: 16px;
    bottom: 10px;
    top: auto;
    z-index: 10;
}

.theme-toggle {
    background: var(--panel);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    position: relative;
}

.theme-toggle:hover {
    background: var(--bubble);
    border-color: var(--turquoise);
    box-shadow: 0 0 8px rgba(0,255,210,0.2);
    transform: scale(1.05);
}

.theme-toggle:active {
    transform: scale(0.95);
}

.theme-toggle svg {
    width: 20px;
    height: 20px;
    transition: transform 0.3s ease;
    transform-origin: 50% 50%;
}

.theme-switcher.active .theme-toggle svg {
    transform: scale(1.1);
}

.theme-panel {
    position: absolute;
    top: calc(100% + 12px);
    right: 0;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 16px;
    min-width: 280px;
    max-width: 320px;
    max-height: calc(100vh - 200px);
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4), 0 0 16px rgba(0,255,210,0.1);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px) scale(0.95);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.theme-switcher.active .theme-panel {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

.theme-panel-header {
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.theme-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.theme-card {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    position: relative;
    overflow: hidden;
    color: var(--theme-card-color, var(--text));
}

.theme-card::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 10px;
    padding: 1px;
    background: linear-gradient(135deg, var(--rail1), var(--rail2));
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    mask-composite: exclude;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.theme-card:hover {
    background: var(--bubble);
    border-color: var(--turquoise);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,255,210,0.15);
}

.theme-card:hover::before {
    opacity: 1;
}

.theme-card.active {
    border-color: var(--turquoise);
    background: var(--bubble);
    box-shadow: 0 0 12px rgba(0,255,210,0.25), inset 0 0 8px rgba(0,255,210,0.1);
    color: var(--theme-card-color, var(--text));
}

.theme-card.active::before {
    opacity: 1;
}

.theme-preview {
    width: 100%;
    height: 48px;
    border-radius: 6px;
    overflow: hidden;
    position: relative;
    border: 1px solid rgba(255,255,255,0.1);
}

.theme-color {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 6px;
}

.theme-name {
    font-size: 12px;
    font-weight: 500;
    text-align: center;
    line-height: 1.2;
    color: currentColor;
    text-shadow: var(--theme-card-shadow, none);
}

.theme-switcher[data-context="dark"] .theme-card {
    --theme-card-color: rgba(236, 240, 255, 0.92);
    --theme-card-shadow: 0 1px 3px rgba(0, 0, 0, 0.58);
}

.theme-switcher[data-context="dark"] .theme-card[data-tone="dark"] {
    --theme-card-color: rgba(248, 250, 255, 0.96);
}

.theme-switcher[data-context="light"] .theme-card {
    --theme-card-color: rgba(32, 36, 46, 0.9);
    --theme-card-shadow: 0 1px 2px rgba(0, 0, 0, 0.18);
}

/* Mobile refinements for theme switcher */
@media (max-width: 768px) {
    .theme-switcher {
        right: max(12px, env(safe-area-inset-right));
        bottom: 14px;
        top: auto;
    }
    
    .theme-panel {
        min-width: calc(100vw - 32px);
        max-width: calc(100vw - 32px);
        right: 0;
        top: calc(100% + 8px);
    }
    
    .theme-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
    
    .theme-card {
        padding: 8px;
    }
    
    .theme-preview {
        height: 40px;
    }
    
    .theme-name {
        font-size: 11px;
    }
}

/* ===== Theme transition (cross-fade of colors) ===== */
html.theming body,
html.theming .chat-container,
html.theming .chat-header,
html.theming .chat-input-container,
html.theming .chat-input-wrapper,
html.theming .message-content,
html.theming .mode-info-panel,
html.theming .upgrade-modal-content {
    transition: background-color 360ms ease, color 360ms ease, border-color 360ms ease, box-shadow 360ms ease;
}
html.theming body::before,
html.theming body::after {
    transition: opacity 420ms ease;
}

/* ===== Optional glow shift pulse on theme change ===== */
@keyframes theme-glow-shift {
    0%   { box-shadow: 0 0 0 var(--rail1-shadow-1), 0 0 0 var(--rail1-shadow-2); }
    30%  { box-shadow: 0 0 calc(var(--glow-const-small) + 8px) var(--rail1-shadow-1), 0 0 calc(var(--glow-const-large) + 12px) var(--rail1-shadow-2); }
    60%  { box-shadow: 0 0 calc(var(--glow-const-small) + 4px) var(--rail1-shadow-1), 0 0 calc(var(--glow-const-large) + 6px) var(--rail1-shadow-2); }
    100% { box-shadow: 0 0 0 var(--rail1-shadow-1), 0 0 0 var(--rail1-shadow-2); }
}
.theme-shift .chat-input-wrapper,
.theme-shift .chat-header {
    animation: theme-glow-shift 680ms ease;
}

/* Mobile tuning: slightly shorter transitions and animation */
@media (max-width: 768px) {
    html.theming body,
    html.theming .chat-container,
    html.theming .chat-header,
    html.theming .chat-input-container,
    html.theming .chat-input-wrapper,
    html.theming .message-content {
        transition: background-color 280ms ease, color 280ms ease, border-color 280ms ease, box-shadow 280ms ease;
    }
    html.theming body::before,
    html.theming body::after {
        transition: opacity 320ms ease;
    }
    .theme-shift .chat-input-wrapper,
    .theme-shift .chat-header {
        animation-duration: 540ms;
    }
}

/* Respect reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
    html.theming body,
    html.theming .chat-container,
    html.theming .chat-header,
    html.theming .chat-input-container,
    html.theming .chat-input-wrapper,
    html.theming .message-content,
    html.theming .mode-info-panel,
    html.theming .upgrade-modal-content,
    html.theming body::before,
    html.theming body::after {
        transition: none !important;
    }
    .theme-shift .chat-input-wrapper,
    .theme-shift .chat-header {
        animation: none !important;
    }
}

/* Extra-safe glow overlay for mobile (and desktop) during theme switch */
.theme-shift .chat-header::after,
.theme-shift .chat-input-wrapper::after {
    content: "";
    position: absolute;
    inset: -6px;
    border-radius: inherit;
    pointer-events: none;
    z-index: 2;
    background:
        radial-gradient(120% 120% at 50% 50%, var(--rail1) 0%, rgba(0,0,0,0) 60%);
    filter: blur(10px);
    opacity: 0;
    animation: theme-glow-fade 640ms ease both;
}
@keyframes theme-glow-fade {
    0%   { opacity: 0; filter: blur(8px); }
    35%  { opacity: 0.35; filter: blur(12px); }
    100% { opacity: 0; filter: blur(10px); }
}
