* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    /* Prevent zoom on mobile devices - touch-action only */
    touch-action: manipulation;
}

:root {
    --bg-primary: #121218;
    --bg-secondary: #1a1a24;
    --bg-tertiary: #22222e;
    --border: #2e2e3a;
    --text-primary: #f5f5f7;
    --text-secondary: #9898a6;
    --accent: #f5f5f7;
    --accent-hover: #ffffff;
    --gradient-1: linear-gradient(135deg, #7c3aed 0%, #db2777 100%);
    --gradient-2: linear-gradient(135deg, #ec4899 0%, #8b5cf6 100%);
    --gradient-subtle: linear-gradient(180deg, rgba(255,255,255,0.05) 0%, transparent 100%);
    --shadow-glow: 0 0 40px rgba(124, 58, 237, 0.15);
}

:root[data-theme="light"] {
    --bg-primary: #ffffff;
    --bg-secondary: #fafafa;
    --bg-tertiary: #f5f5f5;
    --border: #e5e5e5;
    --text-primary: #000000;
    --text-secondary: #666666;
    --accent: #000000;
    --accent-hover: #333333;
    --gradient-1: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-2: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --gradient-subtle: linear-gradient(180deg, rgba(0,0,0,0.02) 0%, transparent 100%);
    --shadow-glow: 0 0 40px rgba(102, 126, 234, 0.08);
}

html, body {
    /* Prevent zoom on mobile - Force 1x scale */
    width: 100%;
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

.header {
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border);
    padding: 0 2rem;
    height: 60px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.logo {
    display: flex;
    align-items: center;
    font-size: 0.9375rem;
    font-weight: 500;
    letter-spacing: -0.01em;
    text-decoration: none;
    color: var(--text-primary);
    cursor: pointer;
    transition: opacity 0.15s;
}

.logo:hover {
    opacity: 0.7;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.chat-sidebar {
    position: fixed;
    left: -300px;
    top: 60px;
    width: 300px;
    height: calc(100vh - 60px);
    background: var(--bg-primary);
    border-right: 1px solid var(--border);
    transition: left 0.2s;
    z-index: 100;
    display: flex;
    flex-direction: column;
}

.chat-sidebar.open {
    left: 0;
}

.sidebar-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    font-weight: 500;
}

.new-chat-btn {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 0.5rem 1rem;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.15s;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 500;
    border-radius: 12px;
}

.new-chat-btn:hover {
    background: var(--bg-primary);
    color: var(--text-primary);
    border-color: var(--text-secondary);
}

.chats-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

.chats-list::-webkit-scrollbar {
    width: 1px;
}

.chats-list::-webkit-scrollbar-track {
    background: transparent;
}

.chats-list::-webkit-scrollbar-thumb {
    background: var(--border);
}

.chat-item {
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.15s;
    position: relative;
    border-radius: 12px;
}

.chat-item:hover {
    background: var(--bg-tertiary);
    border-color: var(--text-secondary);
}

.chat-item.active {
    background: var(--bg-tertiary);
    border-color: var(--text-primary);
}

.chat-item-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
}

.chat-item-title {
    font-size: 0.875rem;
    color: var(--text-primary);
    font-weight: 500;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-item-description {
    font-size: 0.75rem;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-item-actions {
    display: flex;
    gap: 0.25rem;
    flex-shrink: 0;
    opacity: 0;
    transition: opacity 0.15s;
}

.chat-item:hover .chat-item-actions {
    opacity: 1;
}

.chat-item-rename,
.chat-item-delete {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 0.875rem;
    cursor: pointer;
    padding: 0.25rem;
    transition: color 0.15s;
}

.chat-item-rename:hover,
.chat-item-delete:hover {
    color: var(--text-primary);
}

.status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8125rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.status::before {
    content: '';
    width: 6px;
    height: 6px;
    background: var(--text-primary);
}

.icon-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    width: 30px;
    height: 30px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.8125rem;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    text-decoration: none;
    flex-shrink: 0;
    border-radius: 12px;
}

.icon-btn:hover {
    background: var(--bg-secondary);
    border-color: var(--text-secondary);
    color: var(--text-primary);
}

.icon-btn.websearch-active {
    background: var(--text-primary);
    color: var(--bg-primary);
    border-color: var(--text-primary);
}

.icon-btn.companies-active {
    background: var(--text-primary);
    color: var(--bg-primary);
    border-color: var(--text-primary);
}

.icon-btn.social-active {
    background: var(--text-primary);
    color: var(--bg-primary);
    border-color: var(--text-primary);
}

.stats-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
}

.stat-display {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0 0.75rem;
    height: 32px;
    border: 1px solid var(--border);
    font-size: 0.75rem;
    font-family: 'Monaco', 'Courier New', monospace;
    color: var(--text-secondary);
    letter-spacing: 0.05em;
    position: relative;
    border-radius: 12px;
}


#users-display {
    border-color: #22c55e !important;
}

.stat-label {
    font-weight: 500;
    text-transform: uppercase;
}

.stat-value {
    color: var(--text-primary);
}

.vram-display {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    margin-top: 0.25rem;
    font-size: 0.65rem;
}

.vram-label {
    color: var(--text-secondary);
    font-size: 0.6rem;
    text-transform: uppercase;
    font-weight: 500;
    min-width: 30px;
}

.vram-bar-container {
    width: 40px;
    height: 4px;
    background: var(--bg-tertiary);
    border-radius: 12px;
    overflow: hidden;
}

.vram-bar {
    height: 100%;
    width: 0%;
    background: #22c55e;
    border-radius: 12px;
    transition: width 0.3s ease, background-color 0.3s ease;
}

.vram-value {
    color: var(--text-primary);
    font-size: 0.65rem;
    min-width: 32px;
    text-align: right;
}

.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    width: 100%;
}

.messages {
    flex: 1;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    max-width: 1000px;
    margin: 0 auto;
    width: 100%;
}

.chat-container::-webkit-scrollbar {
    width: 2px;
}

.chat-container::-webkit-scrollbar-track {
    background: transparent;
}

.chat-container::-webkit-scrollbar-thumb {
    background: var(--border);
}

.message {
    display: grid;
    grid-template-columns: 32px 1fr;
    gap: 1.5rem;
    align-items: flex-start; /* Ensure top alignment */
}

.message-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    line-height: 1.6;
    /* Profile picture style */
    width: 32px;
    height: 32px;
    border: 1px solid var(--border);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.5rem;
    position: relative;
}

/* Hide default text for AI labels (animation will show via ::after) */
.message:not(.user) .message-label {
    color: transparent;
}

.message-content {
    color: var(--text-primary);
    line-height: 1.6;
    font-size: 0.9375rem;
    text-align: justify;
    overflow-x: auto;
    overflow-y: visible;
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
}

/* Sources Section */
.sources-section {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.sources-title {
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.sources-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.source-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 12px;
    text-decoration: none;
    transition: all 0.15s;
}

.source-item:hover {
    background: var(--bg-secondary);
    border-color: var(--text-secondary);
}

.source-favicon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    border: 1px solid var(--border);
    background: var(--bg-primary);
}

.source-title {
    flex: 1;
    font-size: 0.8125rem;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* YouTube Sources Section */
.youtube-sources-section {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.youtube-sources-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.youtube-source-item {
    display: flex;
    gap: 1rem;
    padding: 1rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 12px;
    text-decoration: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    align-items: flex-start;
}

.youtube-source-item:hover {
    background: var(--bg-secondary);
    border-color: var(--text-secondary);
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15);
}

.youtube-thumbnail {
    position: relative;
    flex-shrink: 0;
    width: 168px;
    height: 94px;
    border-radius: 12px;
    overflow: hidden;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
}

.youtube-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.youtube-duration {
    position: absolute;
    bottom: 4px;
    right: 4px;
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    padding: 2px 4px;
    border-radius: 12px;
    font-size: 0.6875rem;
    font-weight: 500;
}

.youtube-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    min-width: 0;
}

.youtube-title {
    font-size: 0.9375rem;
    color: var(--text-primary);
    font-weight: 500;
    line-height: 1.4;
    /* Display full text without truncation */
    display: block;
    overflow: visible !important;
    white-space: normal !important;
    text-overflow: unset !important;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
    max-width: 100%;
}

.youtube-channel {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    font-weight: 400;
    margin-top: 0.25rem;
    /* Remove text truncation - show full text */
    overflow: visible;
    white-space: normal;
    word-wrap: break-word;
}

.youtube-meta {
    display: flex;
    gap: 0.75rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
}

.youtube-views,
.youtube-date {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-weight: 400;
}

/* YouTube Channel Profile - Clean Design */
.youtube-channel-profile-compact {
    display: flex;
    gap: 1rem;
    padding: 1.25rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 12px;
    text-decoration: none;
    transition: all 0.2s ease;
    align-items: center;
    margin-bottom: 1rem;
}

.youtube-channel-profile-compact:hover {
    background: var(--bg-secondary);
    border-color: var(--text-secondary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.youtube-channel-avatar-compact {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    border: 2px solid var(--border);
    flex-shrink: 0;
    object-fit: cover;
    background: var(--bg-secondary);
    transition: all 0.2s ease;
}

.youtube-channel-profile-compact:hover .youtube-channel-avatar-compact {
    border-color: var(--text-secondary);
    transform: scale(1.03);
}

.youtube-channel-info-compact {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-width: 0;
}

.youtube-channel-name-compact {
    font-size: 1.375rem;
    color: var(--text-primary);
    font-weight: 600;
    line-height: 1.3;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    /* Remove text truncation - show full text */
    overflow: visible;
    white-space: normal;
    word-wrap: break-word;
}

.youtube-channel-name-compact svg {
    flex-shrink: 0;
    color: var(--text-secondary);
    width: 20px;
    height: 20px;
}

.youtube-channel-handle-compact {
    font-size: 1rem;
    color: var(--text-secondary);
    /* Remove text truncation - show full text */
    overflow: visible;
    white-space: normal;
    word-wrap: break-word;
    font-weight: 400;
    margin-top: 0.25rem;
}

.youtube-channel-stats-compact {
    display: flex;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
    align-items: center;
    margin-top: 0.25rem;
}

.youtube-channel-stats-compact span {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-weight: 400;
}

/* Message Actions - Only for AI messages */
.message:not(.user) .message-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
}

.message-action-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s;
    width: 24px;
    height: 24px;
}

.message-action-btn:hover {
    color: var(--text-primary);
}

.message-action-btn svg {
    width: 16px;
    height: 16px;
}

/* Scrollbar für message-content (wie bei anderen) */
.message-content::-webkit-scrollbar {
    height: 6px;
}

.message-content::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

.message-content::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 12px;
}

.message-content::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* Desktop: Center content, labels completely outside center calculation */
@media (min-width: 1025px) {
    .message {
        position: relative;
        width: 100%;
        display: block;
    }

    .message-label {
        position: absolute;
        /* Position label left of centered content:
           50% = viewport center
           -400px = half of content width (800px / 2)
           -32px = label width
           -1.5rem = gap between label and content
        */
        left: calc(50% - 400px - 32px - 1.5rem);
        top: 0.125rem; /* Slight offset to align with text baseline */
        margin-top: 0;
    }

    .message-content {
        max-width: 800px;
        width: 800px;
        margin: 0 auto;
    }
}

.message.user .message-content {
    color: var(--text-secondary);
}

.message-content strong {
    color: var(--text-primary);
    font-weight: 500;
}

.message-content code {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    padding: 0.125rem 0.375rem;
    font-size: 0.875em;
    font-family: 'Monaco', 'Courier New', monospace;
}

/* Markdown headings */
.message-content h1,
.message-content h2,
.message-content h3,
.message-content h4,
.message-content h5,
.message-content h6 {
    color: var(--text-primary);
    font-weight: 600;
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
    line-height: 1.3;
}

.message-content h1 { font-size: 1.75rem; }
.message-content h2 { font-size: 1.5rem; }
.message-content h3 { font-size: 1.25rem; }
.message-content h4 { font-size: 1.125rem; }
.message-content h5 { font-size: 1rem; }
.message-content h6 { font-size: 0.875rem; }

/* Markdown lists */
.message-content ul,
.message-content ol {
    margin: 0.75rem 0;
    padding-left: 1.5rem;
    color: var(--text-primary);
}

.message-content li {
    margin: 0.375rem 0;
    line-height: 1.6;
}

/* Markdown blockquotes */
.message-content blockquote {
    border-left: 3px solid var(--border);
    padding-left: 1rem;
    margin: 1rem 0;
    color: var(--text-secondary);
    font-style: italic;
}

/* Markdown links */
.message-content a {
    color: var(--text-primary);
    text-decoration: underline;
    text-decoration-style: dotted;
    text-underline-offset: 2px;
}

.message-content a:hover {
    text-decoration-style: solid;
}

/* Markdown horizontal rule */
.message-content hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 1.5rem 0;
}

/* Markdown tables */
.message-content table {
    border-collapse: collapse;
    width: 100%;
    margin: 1rem 0;
    max-width: 100%;
    display: block;
    overflow-x: auto;
}

/* Scrollbar für tables */
.message-content table::-webkit-scrollbar {
    height: 6px;
}

.message-content table::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

.message-content table::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 12px;
}

.message-content table::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

.message-content th,
.message-content td {
    border: 1px solid var(--border);
    padding: 0.5rem;
    text-align: left;
}

.message-content th {
    background: var(--bg-tertiary);
    font-weight: 600;
}

/* Markdown paragraphs */
.message-content p {
    margin: 0.75rem 0;
    line-height: 1.6;
}

/* Markdown emphasis */
.message-content em {
    font-style: italic;
    color: var(--text-primary);
}

/* Markdown strikethrough */
.message-content del {
    text-decoration: line-through;
    color: var(--text-secondary);
    opacity: 0.7;
}

/* Markdown images - Gallery System */
.message-content img {
    max-width: 100%;
    height: auto;
    border-radius: 12px;
    margin: 0.5rem 0;
    border: 1px solid var(--border);
    object-fit: cover;
    cursor: pointer;
    transition: all 0.3s ease;
    display: block;
}

/* Image Gallery Grid - ALWAYS 3 columns */
.message-content .image-gallery {
    display: -ms-grid; /* IE 10-11 fallback */
    display: grid;
    -ms-grid-columns: 1fr 0.75rem 1fr 0.75rem 1fr; /* IE 10-11 with gaps */
    grid-template-columns: 1fr 1fr 1fr;
    gap: 0.75rem;
    grid-gap: 0.75rem; /* Fallback for older browsers */
    margin: 1rem 0;
    width: 100%;
    box-sizing: border-box;
    clear: both;
}

.message-content .image-gallery-item {
    position: relative;
    overflow: hidden;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%;
    min-width: 0;
    /* Fallback for browsers without aspect-ratio support */
    padding-bottom: 100%; /* Creates 1:1 square */
    height: 0;
}

/* Modern browsers with aspect-ratio support */
@supports (aspect-ratio: 1) {
    .message-content .image-gallery-item {
        aspect-ratio: 1 / 1;
        padding-bottom: 0;
        height: auto;
    }
}

.message-content .image-gallery-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
    border-color: var(--text-secondary);
}

.message-content .image-gallery-item img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    margin: 0;
    border: none;
    border-radius: 0;
    transition: transform 0.3s ease;
}

.message-content .image-gallery-item:hover img {
    transform: scale(1.1);
}

.message-content .image-caption {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.9), transparent);
    color: #ffffff;
    padding: 0.75rem 0.5rem 0.5rem;
    font-size: 0.75rem;
    line-height: 1.4;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: 2;
    box-sizing: border-box;
}

.message-content .image-gallery-item:hover .image-caption {
    opacity: 1;
}

/* Lightbox Modal */
.image-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.95);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 999999;
    opacity: 0;
    transition: opacity 0.3s ease;
    overflow: hidden;
}

.image-lightbox.show {
    display: flex !important;
    opacity: 1;
}

.lightbox-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    animation: lightbox-zoom 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

@keyframes lightbox-zoom {
    from {
        transform: scale(0.8);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.lightbox-content img {
    max-width: 90vw;
    max-height: 90vh;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 12px;
    border: none;
    display: block;
}

.lightbox-caption {
    position: absolute;
    bottom: -3rem;
    left: 0;
    right: 0;
    color: #ffffff;
    text-align: center;
    font-size: 0.875rem;
    padding: 0.5rem;
}

.lightbox-counter {
    position: absolute;
    top: -3rem;
    left: 0;
    color: #ffffff;
    font-size: 0.875rem;
    font-weight: 500;
    padding: 0.5rem;
}

.lightbox-close {
    position: absolute;
    top: -3rem;
    right: 0;
    background: none;
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #ffffff;
    width: 40px;
    height: 40px;
    cursor: pointer;
    font-size: 1.5rem;
    transition: all 0.3s ease;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-close:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.6);
}

.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #ffffff;
    width: 50px;
    height: 50px;
    cursor: pointer;
    font-size: 1.5rem;
    transition: all 0.3s ease;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-nav:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.6);
}

.lightbox-prev {
    left: 2rem;
}

.lightbox-next {
    right: 2rem;
}

/* Responsive gallery - ALWAYS 3 columns on desktop, 2 on tablet, 1 on mobile */
@media (min-width: 769px) {
    .message-content .image-gallery {
        grid-template-columns: 1fr 1fr 1fr !important;
    }
}

@media (max-width: 768px) {
    .message-content .image-gallery {
        grid-template-columns: 1fr 1fr !important;
        gap: 0.5rem;
    }

    .lightbox-nav {
        width: 40px;
        height: 40px;
        font-size: 1.25rem;
    }

    .lightbox-prev {
        left: 1rem;
    }

    .lightbox-next {
        right: 1rem;
    }
}

@media (max-width: 480px) {
    .message-content .image-gallery {
        grid-template-columns: 1fr !important;
    }
}

/* Markdown task lists */
.message-content input[type="checkbox"] {
    margin-right: 0.5rem;
    cursor: default;
}

.message-content li > input[type="checkbox"] {
    margin-right: 0.5rem;
}

/* Markdown definition lists */
.message-content dl {
    margin: 0.75rem 0;
}

.message-content dt {
    font-weight: 600;
    color: var(--text-primary);
    margin-top: 0.75rem;
}

.message-content dd {
    margin-left: 1.5rem;
    margin-top: 0.25rem;
    color: var(--text-primary);
}

/* Markdown keyboard keys */
.message-content kbd {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.125rem 0.375rem;
    font-size: 0.875em;
    font-family: 'Monaco', 'Courier New', monospace;
    box-shadow: 0 1px 0 var(--border);
}

/* Markdown highlighted text */
.message-content mark {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    padding: 0.125rem 0.25rem;
}

/* Markdown superscript and subscript */
.message-content sup,
.message-content sub {
    font-size: 0.75em;
    line-height: 0;
}

/* Markdown abbreviations */
.message-content abbr {
    cursor: help;
    text-decoration: underline dotted;
    text-underline-offset: 2px;
}

/* RTL language support */
.message-content[dir="rtl"] {
    text-align: justify;
    direction: rtl;
}

.message-content[dir="rtl"] ul,
.message-content[dir="rtl"] ol {
    padding-right: 1.5rem;
    padding-left: 0;
}

.message-content[dir="rtl"] blockquote {
    border-left: none;
    border-right: 3px solid var(--border);
    padding-left: 0;
    padding-right: 1rem;
}

.message-content[dir="rtl"] code,
.message-content[dir="rtl"] pre {
    direction: ltr;
    text-align: left;
}

/* Thinking section ALWAYS LTR */
.thinking-section {
    direction: ltr !important;
    text-align: left !important;
}

.thinking-text {
    direction: ltr !important;
    text-align: left !important;
    overflow-x: auto;
    max-width: 100%;
}

.response-text {
    overflow-x: auto;
    max-width: 100%;
}

/* Scrollbar für response-text und thinking-text */
.thinking-text::-webkit-scrollbar,
.response-text::-webkit-scrollbar {
    height: 6px;
}

.thinking-text::-webkit-scrollbar-track,
.response-text::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

.thinking-text::-webkit-scrollbar-thumb,
.response-text::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 12px;
}

.thinking-text::-webkit-scrollbar-thumb:hover,
.response-text::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* Nested lists */
.message-content ul ul,
.message-content ul ol,
.message-content ol ul,
.message-content ol ol {
    margin: 0.25rem 0;
}

/* Nested blockquotes */
.message-content blockquote blockquote {
    margin-left: 1rem;
    margin-top: 0.5rem;
    border-left-width: 2px;
}

.code-block-wrapper {
    position: relative;
    margin: 1rem 0;
}

.copy-code-btn,
.run-code-btn {
    position: absolute;
    top: 0.5rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text-secondary);
    padding: 0.25rem 0.5rem;
    font-size: 0.6875rem;
    cursor: pointer;
    transition: all 0.15s;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 500;
}

.copy-code-btn {
    right: 0.5rem;
}

.run-code-btn {
    right: 3.5rem;
}

.copy-code-btn:hover,
.run-code-btn:hover {
    background: var(--bg-primary);
    color: var(--text-primary);
    border-color: var(--text-secondary);
}

.copy-code-btn.copied {
    color: var(--text-primary);
    border-color: var(--text-primary);
}

.run-code-btn.running {
    color: #4CAF50;
    border-color: #4CAF50;
}

/* Code Output Modal */
.code-output-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.code-output-modal.show {
    display: flex;
}

.code-output-content {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 12px;
    width: 90%;
    max-width: 1200px;
    height: 80%;
    display: flex;
    flex-direction: column;
}

.code-output-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid var(--border);
}

.code-output-title {
    font-size: 0.875rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-primary);
}

.code-output-close {
    background: none;
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text-secondary);
    width: 28px;
    height: 28px;
    cursor: pointer;
    font-size: 1.25rem;
    transition: all 0.15s;
}

.code-output-close:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--text-secondary);
}

.code-output-body {
    flex: 1;
    overflow: auto;
    padding: 1rem;
}

.code-output-body iframe {
    width: 100%;
    height: 100%;
    border: none;
    background: white;
}

.code-output-body pre {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem;
    margin: 0;
    overflow: auto;
    font-family: 'Monaco', 'Courier New', monospace;
    font-size: 0.875rem;
    line-height: 1.5;
    color: var(--text-primary);
    white-space: pre-wrap;
    word-wrap: break-word;
}

.code-output-error {
    color: #f44336;
}

.code-output-success {
    color: #4CAF50;
}

.message-content pre {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem;
    padding-top: 1rem;
    padding-right: 7rem;
    margin: 0;
    overflow-x: auto;
    font-size: 0.8125rem;
    line-height: 1.5;
    max-width: 100%;
    box-sizing: border-box;
}

/* Scrollbar für pre code blocks */
.message-content pre::-webkit-scrollbar {
    height: 6px;
}

.message-content pre::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
}

.message-content pre::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 12px;
}

.message-content pre::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

.message-content pre code {
    background: none !important;
    padding: 0;
    color: inherit;
    font-family: 'Monaco', 'Courier New', monospace;
}

/* Override highlight.js background to use our theme colors */
.hljs {
    background: transparent !important;
    padding: 0 !important;
}

/* Ensure highlight.js syntax colors show through */
:root .message-content pre {
    background: #1e1e1e;
}

:root[data-theme="light"] .message-content pre {
    background: #ffffff;
}

.input-area {
    background: var(--bg-primary);
    border-top: 1px solid var(--border);
    padding: 1rem 1.5rem;
    flex-shrink: 0;
    /* Only transition specific properties for smooth slide effect */
    transition: bottom 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                padding 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                max-width 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                background 0.3s ease;
    position: sticky;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 50;
}

/* Centered input for empty chat - Premium Layout */
body.empty-chat .input-area {
    border-top: none;
    bottom: 30%; /* Move up by 30% */
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: transparent; /* Remove gradient from input area */
    z-index: 100;
    max-width: 900px;
    margin: 0 auto;
}

/* Animated background particles - full viewport coverage */
body.empty-chat::before,
body.empty-chat::after {
    content: '';
    position: fixed;
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(102, 126, 234, 0.2) 0%, transparent 70%);
    border-radius: 50%;
    animation: float 15s ease-in-out infinite;
    pointer-events: none;
    z-index: 1;
}

body.empty-chat::before {
    top: 15%;
    left: 10%;
    animation-delay: 0s;
}

body.empty-chat::after {
    top: 45%;
    right: 10%;
    animation-delay: 7s;
    background: radial-gradient(circle, rgba(244, 93, 108, 0.2) 0%, transparent 70%);
}

@keyframes float {
    0%, 100% {
        transform: translate(0, 0) scale(1);
    }
    33% {
        transform: translate(30px, -30px) scale(1.1);
    }
    66% {
        transform: translate(-20px, 20px) scale(0.9);
    }
}

body.empty-chat .input-container {
    max-width: 900px;
    width: 100%;
}

body.empty-chat .chat-container {
    display: flex;
    flex: 1;
    align-items: center;
    justify-content: center;
    height: 100vh;
    padding-bottom: 0; /* No padding needed anymore */
    background: linear-gradient(to bottom, transparent 0%, rgba(10, 10, 10, 0.3) 50%, var(--bg-primary) 100%);
    position: relative;
}

/* Modern empty chat styling - Premium Design */
body.empty-chat .chat-container .logo-container {
    text-align: center;
    /* Removed animation - display immediately centered */
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    max-width: 600px;
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Floating orb background effect */
body.empty-chat .logo-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(124, 58, 237, 0.08) 0%, transparent 60%);
    transform: translateX(-50%);
    animation: pulse 6s ease-in-out infinite;
    pointer-events: none;
    z-index: -1;
}

@keyframes pulse {
    0%, 100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0.5;
    }
    50% {
        transform: translate(-50%, -50%) scale(1.1);
        opacity: 0.8;
    }
}

body.empty-chat .logo-text {
    font-size: 4.5rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 1rem;
    letter-spacing: -0.04em;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', sans-serif;
    position: relative;
    display: block; /* Changed from inline-block for proper centering */
    text-align: center;
    /* Removed animation - show immediately */
}

@keyframes titleReveal {
    from {
        opacity: 0;
        transform: translateY(30px);
        filter: blur(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
        filter: blur(0);
    }
}

body.empty-chat .logo-subtitle {
    font-size: 1.125rem;
    color: var(--text-secondary);
    font-weight: 400;
    letter-spacing: 0.02em;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', sans-serif;
    opacity: 0.8; /* Direct opacity without animation */
    /* Removed animation - show immediately */
}

@keyframes subtitleFade {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 0.8;
        transform: translateY(0);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

body.empty-chat .input-wrapper-flex {
    max-width: 900px;
    animation: floatUp 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    animation-delay: 0.4s;
    animation-fill-mode: both;
    position: relative;
}

/* Glassmorphism container */
body.empty-chat .input-wrapper-flex::before {
    content: '';
    position: absolute;
    inset: -1px;
    background: linear-gradient(45deg, rgba(102, 126, 234, 0.2), rgba(244, 93, 108, 0.2));
    border-radius: 12px;
    opacity: 0;
    animation: borderGlow 0.8s ease-out 0.6s forwards;
    z-index: -1;
    filter: blur(20px);
}

@keyframes borderGlow {
    to {
        opacity: 0.5;
    }
}

@keyframes floatUp {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

body.empty-chat .input-wrapper-flex .message-input {
    min-height: 50px;
    max-height: 146px;
    font-size: 0.9375rem;
    padding: 0.8125rem 1rem;
    padding-right: 100px;
    line-height: 1.6;
}

body.empty-chat .input-actions-bottom .input-action-btn,
body.empty-chat .input-actions-bottom .send-button-new {
    width: 31px;
    height: 31px;
}

body.empty-chat .input-actions-bottom .input-action-btn svg,
body.empty-chat .input-actions-bottom .send-button-new svg {
    width: 20px;
    height: 20px;
}

.input-container {
    max-width: 1000px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 1fr auto;
    /* gap: 1rem; */
}

.input-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}


/* Button group - always side by side */
.input-wrapper .button-group {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-shrink: 0;
}

.input-wrapper #websearch-btn {
    height: 44px;
    width: 44px;
    flex-shrink: 0;
}

.input-wrapper .send-button {
    flex-shrink: 0;
}

/* Logo container - Hidden when chat has messages */
.logo-container {
    display: none;
}

/* Show logo only in empty chat state */
body.empty-chat .chat-container .logo-container {
    display: block;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.input-container .message-input {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 0.75rem 1rem;
    font-size: 0.9375rem;
    resize: none;
    min-height: 46px;
    height: 50px;
    max-height: 50px;
    font-family: inherit;
    transition: border-color 0.2s ease;
    /* overflow-y: scroll; */
    overflow-x: hidden;
    scrollbar-width: 0px;
    border-radius: 12px 0px 0px 12px;
    line-height: 1.5;
}

.input-container .message-input:focus {
    outline: none;
    /* border-color: var(--text-secondary); */
}

.message-input::placeholder {
    color: var(--text-secondary);
}

.send-button {
    background: var(--accent);
    color: var(--bg-primary);
    border: 1px solid var(--accent);
    padding: 0 2rem;
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
    height: 44px;
    box-sizing: border-box;
}

.send-button:hover:not(:disabled) {
    background: var(--accent-hover);
}

.send-button:disabled {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    cursor: not-allowed;
}

.settings {
    max-width: 1000px;
    margin: 1rem auto 0;
    padding: 1.5rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    display: none;
}

.settings.open {
    display: block;
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 2rem;
}

.setting-group {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* Notification Toggle Switch */
.notification-toggle {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.notification-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.notification-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--border);
    transition: 0.3s;
    border-radius: 24px;
}

.notification-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: var(--bg-primary);
    transition: 0.3s;
    border-radius: 50%;
}

.notification-toggle input:checked + .notification-slider {
    background-color: #22c55e;
}

.notification-toggle input:checked + .notification-slider:before {
    transform: translateX(20px);
}

.notification-toggle input:disabled + .notification-slider {
    opacity: 0.5;
    cursor: not-allowed;
}

.setting-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.setting-input {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text-primary);
    padding: 0.5rem;
    font-size: 0.875rem;
}

.setting-input:focus {
    outline: none;
    border-color: var(--text-secondary);
}

.thinking-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.thinking-section {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.75rem;
    font-size: 0.8125rem;
    line-height: 1.5;
    color: var(--text-secondary);
    font-style: italic;
}

.thinking-label {
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin-bottom: 0.375rem;
    font-weight: 500;
    font-style: normal;
}

.typing-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.typing-dots {
    display: flex;
    gap: 0.25rem;
}

.typing-dot {
    width: 4px;
    height: 4px;
    background: var(--text-secondary);
    animation: typing 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes typing {
    0%, 80%, 100% { opacity: 0.3; }
    40% { opacity: 1; }
}


/* AI Profile Animation - AMAZING VERSION WITHOUT GRADIENTS */

/* Hexagon rotating effect */
@keyframes ai-hexagon-rotate {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

/* Energy wave effect */
@keyframes ai-energy-wave {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.8);
        opacity: 0;
    }
}

/* Neon glow pulse - REDUCED INTENSITY (no bright flash) */
@keyframes ai-neon-glow {
    0%, 100% {
        box-shadow:
            0 0 2px rgba(147, 197, 253, 0.3),
            inset 0 0 2px rgba(147, 197, 253, 0.2);
    }
    50% {
        box-shadow:
            0 0 4px rgba(147, 197, 253, 0.4),
            0 0 6px rgba(147, 197, 253, 0.3),
            0 0 8px rgba(147, 197, 253, 0.2),
            inset 0 0 2px rgba(147, 197, 253, 0.3);
    }
}

/* Morphing shape effect */
@keyframes ai-morph {
    0%, 100% {
        border-radius: 50%;
    }
    25% {
        border-radius: 40% 60% 60% 40% / 60% 40% 60% 40%;
    }
    50% {
        border-radius: 60% 40% 40% 60% / 40% 60% 40% 60%;
    }
    75% {
        border-radius: 40% 60% 60% 40% / 60% 40% 60% 40%;
    }
}

/* Glitch effect */
@keyframes ai-glitch {
    0%, 100% {
        transform: translate(0);
        filter: hue-rotate(0deg);
    }
    20% {
        transform: translate(-1px, 1px);
        filter: hue-rotate(90deg);
    }
    40% {
        transform: translate(-1px, -1px);
        filter: hue-rotate(180deg);
    }
    60% {
        transform: translate(1px, 1px);
        filter: hue-rotate(270deg);
    }
    80% {
        transform: translate(1px, -1px);
        filter: hue-rotate(360deg);
    }
}

/* Lightning flash effect - REMOVED (too bright)
   Keeping animation name for compatibility but with no effect */
@keyframes ai-lightning {
    0%, 100% {
        opacity: 1;
    }
}

/* Text morphing */
@keyframes ai-text-morph {
    0%, 15% { content: 'AI'; opacity: 1; }
    20%, 25% { content: '▣'; opacity: 0.8; }
    30%, 35% { content: '◈'; opacity: 0.9; }
    40%, 45% { content: '⬢'; opacity: 1; }
    50%, 55% { content: '◆'; opacity: 0.9; }
    60%, 65% { content: '○'; opacity: 0.8; }
    70%, 75% { content: '●'; opacity: 0.9; }
    80%, 85% { content: '◉'; opacity: 1; }
    90%, 95% { content: '◎'; opacity: 0.9; }
    100% { content: 'AI'; opacity: 1; }
}

/* Apply amazing animations to latest AI label */
.message:not(.user).latest-ai .message-label {
    /* Keep default positioning from base .message-label */
    animation:
        ai-neon-glow 2s ease-in-out infinite,
        ai-morph 8s ease-in-out infinite;
    border: 1px solid rgba(147, 197, 253, 0.5);
    overflow: visible;
}

/* Add hexagon background */
.message:not(.user).latest-ai .message-label::before {
    content: '';
    position: absolute;
    inset: -8px;
    border: 1px solid rgba(147, 197, 253, 0.2);
    border-radius: inherit;
    animation:
        ai-hexagon-rotate 20s linear infinite,
        ai-energy-wave 3s ease-out infinite;
    pointer-events: none;
    z-index: -1;
}

/* Add secondary energy ring */
.message:not(.user).latest-ai .message-label::after {
    content: 'AI';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(147, 197, 253, 1);
    font-size: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 700;
    animation:
        ai-text-morph 10s ease-in-out infinite,
        ai-glitch 0.3s ease-in-out infinite;
    text-shadow:
        0 0 2px rgba(147, 197, 253, 0.5),
        0 0 4px rgba(147, 197, 253, 0.3);
    z-index: 2;
}

/* Lightning effect overlay REMOVED - too bright */

/* Light theme adjustments */
:root[data-theme="light"] .message:not(.user).latest-ai .message-label {
    animation:
        ai-neon-glow 2s ease-in-out infinite,
        ai-morph 8s ease-in-out infinite;
    border-color: rgba(59, 130, 246, 0.5);
}

:root[data-theme="light"] .message:not(.user).latest-ai .message-label::before {
    border-color: rgba(59, 130, 246, 0.2);
}

:root[data-theme="light"] .message:not(.user).latest-ai .message-label::after {
    color: rgba(59, 130, 246, 1);
    text-shadow:
        0 0 3px rgba(59, 130, 246, 0.5),
        0 0 6px rgba(59, 130, 246, 0.3);
}

/* Add data stream effect for active thinking */
.message:not(.user).latest-ai.thinking .message-label::before {
    animation:
        ai-hexagon-rotate 2s linear infinite,
        ai-energy-wave 0.5s ease-out infinite;
}

.message:not(.user).latest-ai.thinking .message-label::after {
    animation:
        ai-text-morph 1s ease-in-out infinite,
        ai-glitch 0.1s ease-in-out infinite;
}

/* Non-animated AI labels show static "AI" - unhide the text */
.message:not(.user):not(.latest-ai) .message-label {
    color: var(--text-secondary);
}

/* Responsive AI animation adjustments */
@media (max-width: 768px) {
    .message:not(.user).latest-ai .message-label::before {
        inset: -6px;
    }

    .message:not(.user).latest-ai .message-label::after {
        font-size: 0.45rem;
    }
}

@media (max-width: 480px) {
    .message:not(.user).latest-ai .message-label::before {
        inset: -4px;
    }

    .message:not(.user).latest-ai .message-label::after {
        font-size: 0.4rem;
    }
}

@media (max-width: 360px) {
    .message:not(.user).latest-ai .message-label::before {
        inset: -3px;
    }

    .message:not(.user).latest-ai .message-label::after {
        font-size: 0.375rem;
    }
}


/* Responsive empty chat design */
@media (max-width: 768px) {
    body.empty-chat .logo-text {
        font-size: 2.25rem;
    }

    body.empty-chat .logo-subtitle {
        font-size: 1rem;
    }

    body.empty-chat .input-area {
        bottom: 25%; /* Slightly lower on tablets */
        padding: 1.5rem;
        max-width: 800px;
    }

    body.empty-chat .input-wrapper-flex .message-input {
        min-height: 50px;
        font-size: 0.875rem;
        padding: 0.75rem 1rem;
        padding-right: 100px;
    }

    body.empty-chat .input-actions-bottom .input-action-btn,
    body.empty-chat .input-actions-bottom .send-button-new {
        width: 28px;
        height: 28px;
    }

    body.empty-chat .input-actions-bottom .input-action-btn svg,
    body.empty-chat .input-actions-bottom .send-button-new svg {
        width: 18px;
        height: 18px;
    }
}

@media (max-width: 480px) {
    body.empty-chat .logo-text {
        font-size: 1.875rem;
    }

    body.empty-chat .logo-subtitle {
        font-size: 0.9375rem;
    }

    body.empty-chat .input-area {
        bottom: 20%; /* Lower on mobile */
        padding: 1rem;
    }

    body.empty-chat .input-wrapper-flex .message-input {
        min-height: 50px;
        font-size: 0.8125rem;
        padding: 0.75rem 1rem;
        padding-right: 90px;
    }

    body.empty-chat .input-actions-bottom .input-action-btn,
    body.empty-chat .input-actions-bottom .send-button-new {
        width: 26px;
        height: 26px;
    }

    body.empty-chat .input-actions-bottom .input-action-btn svg,
    body.empty-chat .input-actions-bottom .send-button-new svg {
        width: 16px;
        height: 16px;
    }
}

/* Tablet and below */
@media (max-width: 1024px) {
    .header-controls {
        gap: 0.75rem;
    }

    .stat-display {
        padding: 0 0.5rem;
        font-size: 0.6875rem;
    }

    .vram-display {
        font-size: 0.6rem;
        gap: 0.25rem;
    }

    .vram-label {
        font-size: 0.55rem;
        min-width: 28px;
    }

    .vram-bar-container {
        width: 35px;
        height: 3px;
    }

    .vram-value {
        font-size: 0.6rem;
        min-width: 28px;
    }
}

/* Mobile landscape and below */
@media (max-width: 768px) {
    .header {
        padding: 0 1rem;
        height: 60px;
    }

    .logo {
        font-size: 0.875rem;
    }

    .header-controls {
        gap: 0.5rem;
    }

    /* Hide stat displays and stats button on mobile */
    .stat-display {
        display: none;
    }

    #stats-btn {
        display: none;
    }

    .icon-btn {
        width: 28px;
        height: 28px;
        font-size: 0.75rem;
        flex-shrink: 0;
        padding: 0;
    }

    .messages {
        padding: 1rem;
        gap: 1.5rem;
    }

    .message {
        grid-template-columns: 28px 1fr;
        gap: 0.75rem;
    }

    .message-label {
        width: 28px;
        height: 28px;
        font-size: 0.45rem;
    }

    .message:not(.user) .message-label::after {
        font-size: 0.45rem;
    }

    .message-content {
        font-size: 0.875rem;
    }

    .input-area {
        padding: 1rem;
    }

    .input-container {
        grid-template-columns: 1fr auto;
        /* gap: 0.75rem; */
    }

    .message-input {
        font-size: 0.875rem;
        padding: 0.5rem 0.75rem;
        min-height: 40px;
        line-height: 1.4;
    }

    .send-button {
        padding: 0 1.5rem;
        font-size: 0.75rem;
        height: 40px;
    }

    .settings {
        padding: 1rem;
    }

    .settings-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .chat-sidebar {
        width: 280px;
        left: -280px;
    }

    .thinking-section {
        font-size: 0.75rem;
        padding: 0.625rem;
    }

    .copy-code-btn {
        font-size: 0.625rem;
        padding: 0.2rem 0.4rem;
    }

    .message-content pre {
        font-size: 0.75rem;
        padding: 0.875rem;
        padding-top: 0.875rem;
        padding-right: 3.5rem;
    }
}

/* Mobile portrait */
@media (max-width: 480px) {
    .header {
        padding: 0 0.75rem;
    }

    .logo {
        font-size: 0.8125rem;
        gap: 0.5rem;
    }

    .header-controls {
        gap: 0.375rem;
    }

    .icon-btn {
        width: 26px;
        height: 26px;
        font-size: 0.6875rem;
        padding: 0;
    }

    .messages {
        padding: 0.75rem;
        gap: 1.25rem;
    }

    .message {
        grid-template-columns: 24px 1fr;
        gap: 0.5rem;
    }

    .message-label {
        width: 24px;
        height: 24px;
        font-size: 0.4rem;
    }

    .message:not(.user) .message-label::after {
        font-size: 0.4rem;
    }

    .message-content {
        font-size: 0.8125rem;
    }

    .message-content h1 { font-size: 1.375rem; }
    .message-content h2 { font-size: 1.25rem; }
    .message-content h3 { font-size: 1.125rem; }
    .message-content h4 { font-size: 1rem; }
    .message-content h5 { font-size: 0.9375rem; }
    .message-content h6 { font-size: 0.8125rem; }

    .input-area {
        padding: 0.75rem;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 10;
        background: var(--bg-primary);
    }

    .chat-container {
        padding-bottom: 70px; /* Space for fixed input area */
    }

    /* .input-container {
        gap: 0.5rem;
    } */

    .message-input {
        font-size: 0.8125rem;
        padding: 0.5rem 0.625rem;
        min-height: 38px;
        line-height: 1.4;
    }

    .send-button {
        padding: 0 1.25rem;
        font-size: 0.6875rem;
        height: 38px;
    }

    .settings {
        padding: 0.875rem;
    }

    .chat-sidebar {
        width: 260px;
        left: -260px;
    }

    .chat-item {
        padding: 0.625rem;
    }

    .chat-item-title {
        font-size: 0.8125rem;
    }

    .chat-item-description {
        font-size: 0.6875rem;
    }

    .new-chat-btn {
        padding: 0.4rem 0.875rem;
        font-size: 0.6875rem;
    }

    .sidebar-title {
        font-size: 0.6875rem;
    }
}

/* Very small devices */
@media (max-width: 360px) {
    .logo {
        font-size: 0.75rem;
    }

    .icon-btn {
        width: 24px;
        height: 24px;
        font-size: 0.625rem;
        padding: 0;
    }

    .message {
        grid-template-columns: 22px 1fr;
    }

    .message-label {
        width: 22px;
        height: 22px;
        font-size: 0.375rem;
    }

    .message:not(.user) .message-label::after {
        font-size: 0.375rem;
    }

    .chat-sidebar {
        width: 240px;
        left: -240px;
    }
}

input[type="range"] {
    -webkit-appearance: none;
    width: 100%;
    height: 1px;
    background: var(--border);
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    background: var(--text-primary);
    cursor: pointer;
}

input[type="range"]::-moz-range-thumb {
    width: 12px;
    height: 12px;
    background: var(--text-primary);
    border: none;
    cursor: pointer;
}

select {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23888888' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.5rem center;
    padding-right: 2rem;
}

/* YouTube Channel Profile - Responsive */
@media (max-width: 768px) {
    .youtube-channel-profile-compact {
        padding: 1rem;
        gap: 0.875rem;
    }
    
    .youtube-channel-avatar-compact {
        width: 90px;
        height: 90px;
    }
    
    .youtube-channel-name-compact {
        font-size: 1.125rem;
    }
    
    .youtube-channel-handle-compact {
        font-size: 0.875rem;
    }
    
    .youtube-channel-stats-compact {
        font-size: 0.8125rem;
        gap: 0.75rem;
    }
}

@media (max-width: 480px) {
    .youtube-channel-profile-compact {
        padding: 0.875rem;
        gap: 0.75rem;
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
    
    .youtube-channel-avatar-compact {
        width: 80px;
        height: 80px;
    }
    
    .youtube-channel-info-compact {
        align-items: center;
    }
    
    .youtube-channel-name-compact {
        font-size: 1rem;
        justify-content: center;
    }
    
    .youtube-channel-handle-compact {
        font-size: 0.8125rem;
    }
    
    .youtube-channel-stats-compact {
        font-size: 0.75rem;
        gap: 0.625rem;
        justify-content: center;
    }
}

/* Premium floating input design */
.input-wrapper {
    display: flex;
    align-items: stretch;
    gap: 0;
    position: relative;
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
    background: rgba(20, 20, 20, 0.6);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), var(--shadow-glow);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.input-wrapper:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5), var(--shadow-glow);
}

.input-wrapper .message-input {
    flex: 1;
    border-radius: 12px 0 0 12px;
    border: none;
    background: transparent;
    padding-right: 1rem;
    overflow-y: auto;
    resize: none;
    color: var(--text-primary);
    height: 50px;
    max-height: 50px;
    min-height: 50px;
}

.input-wrapper.drag-over {
    position: relative;
}

.input-wrapper.drag-over::before {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(107, 107, 107, 0.1);
    border: 2px dashed var(--text-secondary);
    border-radius: 12px;
    pointer-events: none;
    z-index: 10;
}

/* Ensure drag-over works in empty chat state */
body.empty-chat .input-wrapper-flex.drag-over::before {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(102, 126, 234, 0.1);
    border: 2px dashed rgba(102, 126, 234, 0.5);
    border-radius: 12px;
    pointer-events: none;
    z-index: 100;
    animation: pulse 1s ease-in-out infinite;
}

:root[data-theme="light"] .input-wrapper-flex.drag-over::before {
    background: rgba(153, 153, 153, 0.1);
}

.input-actions {
    display: flex;
    gap: 0;
    align-items: stretch;
    max-height: 50px;
    border: 1px solid var(--border) ;
    border-left: none;
    border-radius: 0px 12px 12px 0px;
    
}

.input-action-btn {
    background: transparent;
    border: none;
    border-left: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    width: 46px;
    height: 50px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    flex-shrink: 0;
}

.input-action-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.send-button-new {
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.9), rgba(219, 39, 119, 0.9));
    color: white;
    border: none;
    border-radius: 0 11px 11px 0;
    width: 46px;
    height: 50px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
}

.send-button-new::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(244, 93, 108, 0.9), rgba(102, 126, 234, 0.9));
    opacity: 0;
    transition: opacity 0.3s ease;
}

.send-button-new:hover:not(:disabled)::before {
    opacity: 1;
}

.send-button-new:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.4);
}

.send-button-new:disabled {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border-color: var(--border);
    cursor: not-allowed;
    opacity: 0.5;
}

.send-button-new.stop-mode {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--border);
    cursor: pointer;
    opacity: 1;
}

.send-button-new.stop-mode:hover {
    background: #ef4444;
    color: white;
    border-color: #ef4444;
}

.send-button-new svg {
    transition: transform 0.15s;
}

.send-button-new:hover:not(:disabled) svg {
    transform: translateX(2px);
}

/* Empty chat state adjustments - REMOVED (using same design everywhere) */
/* body.empty-chat .input-wrapper-flex {
    max-width: 900px;
}

body.empty-chat .input-wrapper-flex .message-input {
    min-height: 50px;
    font-size: 0.9375rem;
} */

/* Responsive adjustments */
@media (max-width: 768px) {
    .input-wrapper {
        max-width: 100%;
    }
    
    .input-action-btn,
    .send-button-new {
        width: 40px;
        height: 50px;
    }
    
    .input-wrapper .message-input {
        min-height: 50px;
        font-size: 0.875rem;
    }
     
}

@media (max-width: 480px) {
    .input-action-btn,
    .send-button-new {
        width: 38px;
        height: 50px;
    }
    
    .input-wrapper .message-input {
        min-height: 38px;
        font-size: 0.8125rem;
    }
    
    .input-action-btn svg,
    .send-button-new svg {
        width: 18px;
        height: 18px;
    }


}

/* Remove old button group styles since buttons are removed */
.button-group {
    display: none !important;
}
/* New Flexible Input Design - Icons rechts unten */

.input-wrapper-flex {
    position: relative;
    width: 100%;
    max-width: 1000px;
    margin: 0 auto;
    background: rgba(20, 20, 20, 0.6);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), var(--shadow-glow);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    min-height: 50px;
}


.input-wrapper-flex .message-input {
    width: 100%;
    min-height: 50px;
    max-height: 146px;
    padding: 0.8125rem 1rem;
    padding-right: 100px; /* Platz für Icons rechts */
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 0.9375rem;
    font-family: inherit;
    line-height: 1.6;
    resize: none;
    overflow-y: auto;
    border-radius: 12px;
}

.input-wrapper-flex .message-input:focus {
    outline: none;
}

.input-wrapper-flex .message-input::placeholder {
    color: var(--text-secondary);
}

/* Scrollbar für textarea */
.input-wrapper-flex .message-input::-webkit-scrollbar {
    width: 6px;
}

.input-wrapper-flex .message-input::-webkit-scrollbar-track {
    background: transparent;
}

.input-wrapper-flex .message-input::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 12px;
}

.input-wrapper-flex .message-input::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* Icons rechts unten positioniert */
.input-actions-bottom {
    position: absolute;
    bottom: 10px;
    right: 12px;
    display: flex;
    gap: 8px;
    align-items: center;
}

.input-actions-bottom .input-action-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    width: 31px;
    height: 31px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border-radius: 8px;
}

.input-actions-bottom .input-action-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    border-color: rgba(255, 255, 255, 0.2);
}

.input-actions-bottom .send-button-new {
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.9), rgba(219, 39, 119, 0.9));
    color: white;
    border: none;
    border-radius: 8px;
    width: 31px;
    height: 31px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    position: relative;
    overflow: hidden;
}

.input-actions-bottom .send-button-new::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(244, 93, 108, 0.9), rgba(102, 126, 234, 0.9));
    opacity: 0;
    transition: opacity 0.3s ease;
}

.input-actions-bottom .send-button-new:hover:not(:disabled)::before {
    opacity: 1;
}

.input-actions-bottom .send-button-new:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.4);
}

.input-actions-bottom .send-button-new:disabled {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    cursor: not-allowed;
    opacity: 0.5;
}

.input-actions-bottom .send-button-new.stop-mode {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    cursor: pointer;
    opacity: 1;
}

.input-actions-bottom .send-button-new.stop-mode:hover {
    background: #ef4444;
    color: white;
    border-color: #ef4444;
}

.input-actions-bottom .send-button-new svg {
    transition: transform 0.15s;
    position: relative;
    z-index: 1;
}

.input-actions-bottom .send-button-new:hover:not(:disabled) svg {
    transform: translateX(2px);
}

/* Empty chat adjustments */
/* Removed - using same design for empty chat and active chat */
/* body.empty-chat .input-wrapper-flex {
    max-width: 900px;
    min-height: 150px;
}

body.empty-chat .input-wrapper-flex .message-input {
    min-height: 150px;
    font-size: 1rem;
} */

/* Responsive adjustments */
@media (max-width: 768px) {
    .input-wrapper-flex {
        min-height: 100px;
    }

    .input-wrapper-flex .message-input {
        min-height: 100px;
        max-height: 300px;
        padding: 0.875rem 1rem;
        padding-bottom: 65px;
        padding-right: 110px;
        font-size: 0.875rem;
    }

    .input-actions-bottom {
        bottom: 10px;
        right: 10px;
        gap: 6px;
    }

    .input-actions-bottom .input-action-btn,
    .input-actions-bottom .send-button-new {
        width: 40px;
        height: 40px;
    }
}

@media (max-width: 480px) {
    .input-wrapper-flex {
        min-height: 80px;
    }

    .input-wrapper-flex .message-input {
        min-height: 80px;
        max-height: 250px;
        padding: 0.75rem 0.875rem;
        padding-bottom: 60px;
        padding-right: 100px;
        font-size: 0.8125rem;
    }

    .input-actions-bottom {
        bottom: 8px;
        right: 8px;
        gap: 5px;
    }

    .input-actions-bottom .input-action-btn,
    .input-actions-bottom .send-button-new {
        width: 38px;
        height: 38px;
    }

    .input-actions-bottom .input-action-btn svg,
    .input-actions-bottom .send-button-new svg {
        width: 18px;
        height: 18px;
    }
}

/* Drag-over styling for new input wrapper */
.input-wrapper-flex.drag-over {
    position: relative;
}

.input-wrapper-flex.drag-over::before {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(102, 126, 234, 0.1);
    border: 2px dashed rgba(102, 126, 234, 0.5);
    border-radius: 12px;
    pointer-events: none;
    z-index: 100;
    animation: pulse 1s ease-in-out infinite;
}

/* Light Mode Styling für Input-Wrapper-Flex */
:root[data-theme="light"] .input-wrapper-flex {
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(0, 0, 0, 0.1);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1), var(--shadow-glow);
}

:root[data-theme="light"] .input-wrapper-flex .message-input::-webkit-scrollbar-thumb {
    background: #e5e5e5;
}

:root[data-theme="light"] .input-wrapper-flex .message-input::-webkit-scrollbar-thumb:hover {
    background: #666666;
}

:root[data-theme="light"] .input-actions-bottom .input-action-btn {
    background: rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(0, 0, 0, 0.1);
}

:root[data-theme="light"] .input-actions-bottom .input-action-btn:hover {
    background: rgba(0, 0, 0, 0.1);
    border-color: rgba(0, 0, 0, 0.2);
}

:root[data-theme="light"] .input-wrapper-flex.drag-over::before {
    background: rgba(102, 126, 234, 0.05);
    border: 2px dashed rgba(102, 126, 234, 0.3);
}
