/* 
 * Lia Chat - Styles
 * ChatGPT-inspired dark theme
 */

:root {
    --bg-primary: #212121;
    --bg-secondary: #171717;
    --bg-tertiary: #2f2f2f;
    --bg-hover: #3a3a3a;
    --text-primary: #ececec;
    --text-secondary: #9b9b9b;
    --text-muted: #6b6b6b;
    --accent: #10a37f;
    --accent-hover: #0d8c6d;
    --border-color: #3a3a3a;
    --message-user: transparent;
    --message-assistant: #2f2f2f;
    --scrollbar-thumb: #4a4a4a;
    --scrollbar-track: transparent;
    --danger: #ef4146;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    height: 100%;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    /* Cosmic Background: Stars + Deep Gradient */
    background-color: #000000;
    background-image:
        /* Stars Layer */
        radial-gradient(white, rgba(255, 255, 255, .2) 2px, transparent 3px),
        radial-gradient(white, rgba(255, 255, 255, .15) 1px, transparent 2px),
        radial-gradient(white, rgba(255, 255, 255, .1) 2px, transparent 3px),
        radial-gradient(rgba(255, 255, 255, .4), rgba(255, 255, 255, .1) 2px, transparent 3px),
        /* Cosmic Gradient */
        linear-gradient(to bottom, #000000 0%, #020617 40%, #0f172a 100%);
    background-size: 550px 550px, 350px 350px, 250px 250px, 150px 150px, 100% 100%;
    background-position: 0 0, 40px 60px, 130px 270px, 70px 100px, 0 0;
    background-attachment: scroll;
    /* 'fixed' causes full repaint on every scroll frame on mobile */
    color: var(--text-primary);
    overflow: hidden;
}


/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
}

::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #5a5a5a;
}

/* App Container */
.app-container {
    display: flex;
    height: 100vh;
    width: 100%;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background-color: var(--bg-secondary);
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-color);
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 12px;
    display: flex;
    gap: 8px;
}

.new-chat-btn {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background-color: transparent;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s;
}

.new-chat-btn:hover {
    background-color: var(--bg-tertiary);
}

.settings-btn {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: transparent;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.settings-btn:hover {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

/* Admin and logout buttons in sidebar footer */
.admin-btn,
.logout-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: transparent;
    border: none;
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.admin-btn:hover {
    background-color: var(--bg-tertiary);
    color: #8b5cf6;
}

.logout-btn:hover {
    background-color: var(--bg-tertiary);
    color: var(--danger);
}

.conversations-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.conversation-item {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.15s;
    margin-bottom: 2px;
    position: relative;
    group: true;
}

.conversation-item:hover {
    background-color: var(--bg-tertiary);
}

.conversation-item.active {
    background-color: var(--bg-tertiary);
}

.conversation-item .title {
    flex: 1;
    font-size: 14px;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-right: 8px;
}

.conversation-item .delete-btn {
    opacity: 0;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s;
}

.conversation-item:hover .delete-btn {
    opacity: 1;
}

.conversation-item .delete-btn:hover {
    background-color: var(--bg-hover);
    color: var(--danger);
}

/* Main Chat Area */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: transparent;
    /* Allow cosmic background to show */
    min-width: 0;
}

.mobile-header {
    display: none;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background-color: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
}

.menu-toggle {
    background: transparent;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
}

.menu-toggle:hover {
    background-color: var(--bg-tertiary);
}

.chat-title {
    font-size: 16px;
    font-weight: 500;
}

/* Messages Container */
.messages-container {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    /* Smooth momentum scrolling on iOS/Android */
    overscroll-behavior: contain;
    /* Prevent scroll chaining to parent */
    will-change: scroll-position;
    padding: 0;
}

.messages-wrapper {
    max-width: 768px;
    margin: 0 auto;
    padding: 20px;
}

/* Welcome Message */
.welcome-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 60px 20px;
    min-height: 50vh;
}

.welcome-icon {
    font-size: 48px;
    margin-bottom: 20px;
}

.welcome-message h1 {
    font-size: 28px;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.welcome-message p {
    font-size: 16px;
    color: var(--text-secondary);
    max-width: 400px;
}

/* Messages */
.message {
    display: flex;
    gap: 16px;
    padding: 16px 0;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    flex-shrink: 0;
}

.message.user .message-avatar {
    background-color: #5436da;
    color: white;
}

.message.assistant .message-avatar {
    background-color: transparent;
    /* Remove blue square to show orb clearly */
    color: white;
    overflow: visible;
    /* Allow orb glow to spill out */
}

.message-content {
    flex: 1;
    min-width: 0;
    line-height: 1.6;
    font-size: 15px;
}

.message-content p {
    margin-bottom: 12px;
}

.message-content p:last-child {
    margin-bottom: 0;
}

.message-content code {
    background-color: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 14px;
}

.message-content pre {
    background-color: var(--bg-secondary);
    padding: 16px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 12px 0;
}

.message-content pre code {
    background: none;
    padding: 0;
}

/* Typing indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 8px 0;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background-color: var(--text-muted);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-indicator span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes bounce {

    0%,
    80%,
    100% {
        transform: scale(0);
    }

    40% {
        transform: scale(1);
    }
}

/* Input Area */
.input-container {
    padding: 16px 20px 24px;
    background-color: transparent;
    /* Transparent to show stars */
    background-image: linear-gradient(to top, rgba(0, 0, 0, 0.8) 0%, transparent 100%);
    /* Subtle fading gradient */
}

.input-wrapper {
    max-width: 768px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 0;
    background-color: rgba(30, 41, 59, 0.4);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 12px 16px 8px;
    transition: all 0.2s;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.input-wrapper:focus-within {
    border-color: var(--accent);
}

#messageInput {
    width: 100%;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 15px;
    font-family: inherit;
    resize: none;
    max-height: 200px;
    line-height: 1.5;
    padding: 0 0 8px 0;
}

#messageInput::placeholder {
    color: var(--text-muted);
}

/* Input toolbar (Row 2) */
.input-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 4px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.input-toolbar-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Toolbar buttons (attach, etc.) */
.toolbar-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.toolbar-btn:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

/* Send button — stylized */
.send-btn {
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--text-muted);
    border: none;
    border-radius: 50%;
    color: var(--bg-primary);
    cursor: not-allowed;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.send-btn:not(:disabled) {
    background: linear-gradient(135deg, #22d3ee 0%, #3b82f6 100%);
    color: #ffffff;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(34, 211, 238, 0.35);
}

.send-btn:not(:disabled):hover {
    transform: scale(1.08);
    box-shadow: 0 4px 16px rgba(34, 211, 238, 0.45);
}

.send-btn:not(:disabled):active {
    transform: scale(0.95);
}

.send-btn.stop-btn {
    background: linear-gradient(135deg, #ef4444 0%, #f97316 100%) !important;
    color: #ffffff !important;
    cursor: pointer !important;
    box-shadow: 0 2px 10px rgba(239, 68, 68, 0.4);
    animation: pulse-stop 1.5s ease-in-out infinite;
}

.send-btn.stop-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 4px 16px rgba(239, 68, 68, 0.5);
}

@keyframes pulse-stop {

    0%,
    100% {
        box-shadow: 0 2px 10px rgba(239, 68, 68, 0.4);
    }

    50% {
        box-shadow: 0 2px 16px rgba(239, 68, 68, 0.7);
    }
}

.disclaimer {
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 12px;
    max-width: 768px;
    margin-left: auto;
    margin-right: auto;
}

/* Modal */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.7);
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background-color: var(--bg-secondary);
    border-radius: 16px;
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: modalSlide 0.2s ease;
}

@keyframes modalSlide {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
    font-size: 18px;
    font-weight: 600;
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 28px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 12px 14px;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent);
}

.form-group textarea {
    resize: vertical;
    min-height: 150px;
}

.form-group small {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 6px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
}

.btn-secondary,
.btn-primary {
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary {
    background-color: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background-color: var(--bg-tertiary);
}

.btn-primary {
    background-color: var(--accent);
    border: none;
    color: white;
}

.btn-primary:hover {
    background-color: var(--accent-hover);
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        z-index: 100;
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .mobile-header {
        display: flex;
    }

    .messages-wrapper {
        padding: 16px;
    }

    .input-container {
        padding: 12px 16px 20px;
    }
}

/* Loading state */
.loading {
    opacity: 0.7;
    pointer-events: none;
}

/* Sidebar Footer */
.sidebar-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    border-top: 1px solid var(--border-color);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: #5436da;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
}

.user-name {
    font-size: 14px;
    color: var(--text-primary);
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.logout-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.logout-btn:hover {
    background-color: var(--bg-tertiary);
    color: var(--danger);
}

/* Large Modal */
.modal.modal-large {
    max-width: 700px;
    height: 80vh;
}

.modal.modal-small {
    max-width: 450px;
}

/* Settings Tabs */
.settings-tabs {
    display: flex;
    gap: 4px;
    padding: 0 0 20px 0;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 20px;
}

.tab-btn {
    padding: 8px 16px;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.tab-btn:hover {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

.tab-btn.active {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Memories */
.memories-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.memories-header p {
    font-size: 14px;
    color: var(--text-secondary);
}

.memories-list {
    max-height: 350px;
    overflow-y: auto;
    margin-bottom: 16px;
}

.memory-item {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 12px;
    background-color: var(--bg-tertiary);
    border-radius: 8px;
    margin-bottom: 8px;
}

.memory-item p {
    flex: 1;
    font-size: 14px;
    color: var(--text-primary);
    margin-right: 12px;
}

.memory-item .delete-memory-btn {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: var(--text-muted);
    cursor: pointer;
    flex-shrink: 0;
}

.memory-item .delete-memory-btn:hover {
    background-color: var(--bg-hover);
    color: var(--danger);
}

.memories-footer {
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
}

.memories-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
    font-size: 14px;
}

/* Button Variants */
.btn-small {
    padding: 6px 12px;
    font-size: 13px;
}

.btn-danger {
    background-color: transparent;
    border: 1px solid var(--danger);
    color: var(--danger);
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-danger:hover {
    background-color: var(--danger);
    color: white;
}

.btn-danger.btn-small {
    padding: 6px 12px;
    font-size: 13px;
}

/* Mobile overlay for sidebar */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 99;
}

.sidebar-overlay.active {
    display: block;
}

/* Image Upload & Preview */

/* Web Search Toggle — pill button with label */
.web-search-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 30px;
    padding: 0 14px 0 10px;
    background: transparent;
    border: 1.5px solid rgba(255, 255, 255, 0.2);
    border-radius: 50px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.25s ease;
    flex-shrink: 0;
    font-size: 13px;
    font-family: inherit;
    font-weight: 500;
}

.web-search-toggle svg {
    flex-shrink: 0;
}

.web-search-toggle span {
    line-height: 1;
}

.web-search-toggle:hover {
    border-color: rgba(255, 255, 255, 0.35);
    color: var(--text-primary);
}

.web-search-toggle.active {
    color: #22d3ee;
    border-color: rgba(34, 211, 238, 0.5);
    background-color: rgba(34, 211, 238, 0.08);
}

.web-search-toggle.active:hover {
    background-color: rgba(34, 211, 238, 0.14);
}

/* === Chat Links & Citations === */
.chat-link {
    color: #22d3ee;
    text-decoration: none;
    border-bottom: 1px solid rgba(34, 211, 238, 0.3);
    transition: all 0.2s;
    word-break: break-all;
}

.chat-link:hover {
    color: #67e8f9;
    border-bottom-color: #67e8f9;
}

/* Superscript citation references */
.citation-ref {
    display: inline;
    font-size: 11px;
    font-weight: 600;
    color: #22d3ee;
    cursor: default;
    vertical-align: super;
    line-height: 1;
    margin: 0 1px;
}

/* Citations footer section */
.citations-footer {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.citations-header {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
    letter-spacing: 0.02em;
}

.citations-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.citation-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px 4px 8px;
    background-color: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    color: var(--text-secondary);
    font-size: 12px;
    text-decoration: none;
    transition: all 0.2s;
    max-width: 280px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.citation-item:hover {
    background-color: rgba(34, 211, 238, 0.08);
    border-color: rgba(34, 211, 238, 0.3);
    color: #22d3ee;
}

.citation-num {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background-color: rgba(34, 211, 238, 0.15);
    color: #22d3ee;
    font-size: 10px;
    font-weight: 700;
    flex-shrink: 0;
}

.citation-domain {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* === Voice Controls === */
#voiceMicBtn,
.voice-mute-btn {
    transition: all 0.2s;
}

/* Mic recording state */
#voiceMicBtn.recording {
    color: #ef4444;
    background-color: rgba(239, 68, 68, 0.12);
    animation: recording-pulse 1.5s ease-in-out infinite;
}

#voiceMicBtn.recording svg {
    stroke: #ef4444;
}

@keyframes recording-pulse {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
    }

    50% {
        box-shadow: 0 0 0 8px rgba(239, 68, 68, 0);
    }
}

/* Mute toggle — active (unmuted) glow */
.voice-mute-btn:not(.muted) {
    color: #22d3ee;
    background-color: rgba(34, 211, 238, 0.12);
    border-radius: 8px;
}

.voice-mute-btn:not(.muted):hover {
    background-color: rgba(34, 211, 238, 0.2);
}

.voice-mute-btn.muted {
    opacity: 0.4;
}

.voice-mute-btn.muted:hover {
    opacity: 0.7;
}

/* Voice error toast */
.voice-toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(239, 68, 68, 0.9);
    color: white;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 13px;
    z-index: 10000;
    animation: fadeIn 0.3s ease;
    backdrop-filter: blur(10px);
}

/* Voice selector in settings */
.voice-selector-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.voice-selector-row select {
    flex: 1;
    padding: 8px 12px;
    background: var(--bg-tertiary, #1e293b);
    color: var(--text-primary, #f1f5f9);
    border: 1px solid var(--border, #334155);
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
}

.voice-selector-row select:focus {
    outline: none;
    border-color: #22d3ee;
}

.voice-selector-row .btn-small {
    white-space: nowrap;
    padding: 8px 14px;
    font-size: 13px;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(2px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.image-preview-container {
    max-width: 768px;
    margin: 0 auto 12px;
    padding: 0 20px;
}

.image-preview-wrapper {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 8px;
    max-width: 100%;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

.image-preview-wrapper::-webkit-scrollbar {
    height: 6px;
}

.image-preview-wrapper::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

.preview-thumb {
    position: relative;
    flex-shrink: 0;
    width: 100px;
    height: 100px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.preview-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.remove-thumb-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: rgba(0, 0, 0, 0.7);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    transition: background-color 0.2s;
}

.remove-thumb-btn:hover {
    background-color: var(--danger);
}

.add-more-thumb {
    flex-shrink: 0;
    width: 100px;
    height: 100px;
    border-radius: 8px;
    border: 1px dashed var(--border-color);
    background: transparent;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.add-more-thumb:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(34, 211, 238, 0.05);
}

/* Drag & Drop Zone */
.input-container.drag-over {
    background-color: var(--bg-tertiary);
}

.input-container.drag-over .input-wrapper {
    border-color: var(--accent);
    border-style: dashed;
}

/* Message Images */
.message-image {
    max-width: 100%; /* Fixes mobile horizontal overflow */
    width: auto;
    max-height: 300px;
    border-radius: 12px;
    margin: 8px 0;
    cursor: pointer;
    transition: transform 0.2s;
}

.message-image:hover {
    transform: scale(1.02);
}

/* Multi-image gallery in chat */
.message-images-gallery {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 8px;
    max-width: 100%;
    scrollbar-width: thin;
}

.message-images-gallery .message-image {
    flex-shrink: 0;
    max-width: 85%;
    max-height: 250px;
    margin: 4px 0;
}

/* Image Lightbox */
.lightbox-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.9);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    cursor: zoom-out;
}

.lightbox-overlay.active {
    display: flex;
}

.lightbox-overlay img {
    max-width: 90vw;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 8px;
}

/* Loading indicator for images */
.image-loading {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
    font-size: 14px;
    padding: 8px 0;
}

.image-loading::before {
    content: "";
    width: 16px;
    height: 16px;
    border: 2px solid var(--text-muted);
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Rich Markdown Content Styles */

/* Headers in messages */
.message-content h2 {
    font-size: 1.4em;
    font-weight: 600;
    margin: 20px 0 12px;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 8px;
}

.message-content h3 {
    font-size: 1.2em;
    font-weight: 600;
    margin: 16px 0 10px;
    color: var(--text-primary);
}

.message-content h4 {
    font-size: 1.1em;
    font-weight: 600;
    margin: 14px 0 8px;
    color: var(--text-secondary);
}

/* Blockquotes - ChatGPT style */
.message-content blockquote {
    border-left: 4px solid var(--accent);
    background-color: rgba(16, 163, 127, 0.1);
    padding: 12px 16px;
    margin: 12px 0;
    border-radius: 0 8px 8px 0;
    font-style: italic;
    color: var(--text-secondary);
}

/* Code blocks with header */
.code-block {
    background-color: #1e1e1e;
    border-radius: 8px;
    margin: 12px 0;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background-color: #2d2d2d;
    border-bottom: 1px solid var(--border-color);
}

.code-lang {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: lowercase;
}

.copy-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 12px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s;
}

.copy-btn:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

.copy-btn.copied {
    color: #10a37f;
    /* ChatGPT green for success */
}

.code-block pre {
    margin: 0;
    padding: 16px;
    overflow-x: auto;
}

.code-block code {
    font-family: 'Fira Code', 'Consolas', monospace;
    font-size: 13px;
    line-height: 1.6;
    color: #d4d4d4;
}

/* Inline code */
code.inline {
    background-color: rgba(255, 255, 255, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Fira Code', 'Consolas', monospace;
    font-size: 0.9em;
    color: var(--accent);
}

/* Lists */
.message-content ul,
.message-content ol {
    margin: 12px 0;
    padding-left: 24px;
}

.message-content li {
    margin: 6px 0;
    line-height: 1.6;
}

.message-content ul li::marker {
    color: var(--accent);
}

.message-content ol li::marker {
    color: var(--accent);
    font-weight: 600;
}

/* Horizontal rule */
.message-content hr {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 20px 0;
}

/* Paragraphs in messages */
.message-content p {
    margin: 10px 0;
    line-height: 1.7;
}

.message-content p:first-child {
    margin-top: 0;
}

.message-content p:last-child {
    margin-bottom: 0;
}

/* Strong and emphasis */
.message-content strong {
    color: var(--text-primary);
    font-weight: 600;
}

.message-content em {
    font-style: italic;
    color: var(--text-secondary);
}

/* =====================================================
   AI ORB AVATAR - Animated Welcome Icon
   Inspired by ElevenLabs, with Lia's colors
   ===================================================== */

.welcome-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    height: 100%;
    padding: 40px;
    background: radial-gradient(circle at center, rgba(15, 23, 42, 0.4) 0%, transparent 70%);
}

.welcome-message h1 {
    font-size: 28px;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text-primary);
    text-shadow: 0 0 15px rgba(59, 130, 246, 0.2);
}

.welcome-message p {
    color: var(--text-secondary);
    font-size: 16px;
}

/* Orb Container */
.ai-orb-container {
    width: 120px;
    height: 120px;
    margin-bottom: 32px;
    perspective: 1000px;
    position: relative;
}

/* Cosmic Background behind Orb (Kept purely for depth, very subtle) */
.ai-orb-container::before {
    content: '';
    position: absolute;
    inset: -30px;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.1) 0%, transparent 60%);
    z-index: 0;
    border-radius: 50%;
    filter: blur(20px);
    opacity: 0.6;
}

.ai-orb {
    width: 100%;
    height: 100%;
    position: relative;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.3s ease;
    animation: orbFloat 6s ease-in-out infinite;
    will-change: transform;
}

.ai-orb:hover {
    transform: scale(1.05);
}

/* Core orb - Soul/Neural Essence */
.orb-core {
    position: absolute;
    inset: 10px;
    border-radius: 50%;
    /* Translucent energy cloud, not solid */
    background: radial-gradient(circle at center,
            rgba(18, 174, 198, 0.8) 0%,
            /* Bright Cyan Heart */
            rgba(59, 130, 246, 0.4) 40%,
            /* Blue aura */
            rgba(29, 78, 216, 0.1) 70%,
            /* Faint deep blue */
            transparent 100%);
    /* Soft glow, no hard 3D shadows */
    box-shadow: 0 0 30px rgba(34, 211, 238, 0.4), inset 0 0 20px rgba(255, 255, 255, 0.2);
    animation: orbPulse 4s ease-in-out infinite;
    overflow: hidden;
    /* Keep connection lines inside */
}

/* Neural Network / Nodes Constellation (The "Essence") */
.orb-core::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 2px;
    height: 2px;
    background: #fff;
    border-radius: 50%;
    /* Creating multiple nodes with box-shadow */
    box-shadow:
        -15px -20px 0 rgba(255, 255, 255, 0.9),
        15px -10px 0 rgba(255, 255, 255, 0.8),
        -10px 15px 0 rgba(255, 255, 255, 0.8),
        20px 20px 0 rgba(255, 255, 255, 0.7),
        0 -30px 0 rgba(255, 255, 255, 0.6),
        -25px 0 0 rgba(255, 255, 255, 0.6),
        30px 0 0 rgba(255, 255, 255, 0.6);
    filter: blur(0.5px);
    animation: orbSpin 60s linear infinite;
    opacity: 0.8;
}

/* Central "Soul" Light / Heartbeat */
.orb-core::after {
    content: '';
    position: absolute;
    inset: 30%;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.9) 0%, rgba(34, 211, 238, 0.5) 50%, transparent 100%);
    filter: blur(5px);
    animation: orbPulseActive 2s ease-in-out infinite;
}

/* Outer glow layer - Neon Aura */
.orb-glow {
    position: absolute;
    inset: -10px;
    border-radius: 50%;
    background: radial-gradient(circle,
            rgba(59, 130, 246, 0.15) 0%,
            rgba(147, 51, 234, 0.1) 40%,
            transparent 70%);
    filter: blur(12px);
    animation: orbGlow 5s ease-in-out infinite alternate;
}

/* Ring - Neon Light Trace */
.orb-ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 1px solid rgba(96, 165, 250, 0.3);
    /* Lighter blue */
    box-shadow: 0 0 10px rgba(96, 165, 250, 0.2);
    animation: orbRing 8s linear infinite;
}

.orb-ring::before {
    content: '';
    position: absolute;
    top: -2px;
    left: 50%;
    width: 6px;
    height: 6px;
    background: #60a5fa;
    /* Neon blue point */
    border-radius: 50%;
    box-shadow: 0 0 8px #60a5fa, 0 0 15px #3b82f6;
}

/* Reverted ring styling (simple rotation) */
.orb-ring::after {
    content: none;
}

/* Floating particles - Subtle energy motes */
.orb-particles {
    position: absolute;
    inset: -10px;
    pointer-events: none;
    animation: orbFloat 6s ease-in-out infinite reverse;
}

.orb-particles span {
    position: absolute;
    width: 3px;
    height: 3px;
    background: #60a5fa;
    border-radius: 50%;
    box-shadow: 0 0 5px #60a5fa;
    opacity: 0.6;
    animation: particleFloat 4s ease-in-out infinite;
}

/* Positioning particles */
.orb-particles span:nth-child(1) {
    top: 10%;
    left: 50%;
    animation-delay: 0s;
}

.orb-particles span:nth-child(2) {
    top: 30%;
    left: 10%;
    animation-delay: 1.5s;
    width: 2px;
    height: 2px;
    background: #a78bfa;
}

.orb-particles span:nth-child(3) {
    top: 70%;
    right: 10%;
    animation-delay: 0.5s;
}

.orb-particles span:nth-child(4) {
    bottom: 20%;
    left: 20%;
    animation-delay: 2s;
    width: 2px;
    height: 2px;
}

.orb-particles span:nth-child(5) {
    top: 20%;
    right: 20%;
    animation-delay: 1s;
    background: #22d3ee;
}

.orb-particles span:nth-child(6) {
    bottom: 5%;
    left: 60%;
    animation-delay: 2.5s;
}

/* Active state - when typing */
.ai-orb.active {
    animation: orbVibrate 0.1s linear infinite;
}

.ai-orb.active .orb-core {
    animation: orbPulseActive 0.5s ease-in-out infinite;
    box-shadow:
        0 0 40px rgba(59, 130, 246, 0.7),
        0 0 80px rgba(59, 130, 246, 0.5),
        inset 0 0 30px rgba(255, 255, 255, 0.3);
}

.ai-orb.active .orb-particles span {
    animation: particleActive 0.3s ease-in-out infinite alternate;
}

/* Keyframe Animations */
@keyframes orbFloat {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

@keyframes orbPulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(0.98);
    }
}

@keyframes orbPulseActive {

    0%,
    100% {
        transform: scale(1.05);
    }

    50% {
        transform: scale(0.98);
    }
}

@keyframes orbGlow {
    0% {
        opacity: 0.6;
        transform: scale(1);
    }

    100% {
        opacity: 0.9;
        transform: scale(1.05);
    }
}

@keyframes orbRing {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

@keyframes particleFloat {

    0%,
    100% {
        transform: translateY(0) scale(1);
        opacity: 0.5;
    }

    50% {
        transform: translateY(-10px) scale(1.2);
        opacity: 0.9;
    }
}

@keyframes orbVibrate {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-2px);
    }

    75% {
        transform: translateX(2px);
    }
}

@keyframes orbVibrate {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-2px);
    }

    75% {
        transform: translateX(2px);
    }
}

/* Small Orb for Chat Messages */
.ai-orb-container.small-orb {
    width: 100%;
    height: 100%;
    margin: 0;
    pointer-events: none;
    /* Disable interaction in messages */
}

.ai-orb-container.small-orb .ai-orb {
    animation: none;
    /* Disable float animation for small orb to keep it centered */
}

.ai-orb-container.small-orb .orb-core,
.ai-orb-container.small-orb .orb-glow,
.ai-orb-container.small-orb .orb-ring {
    inset: 0;
    /* Fill container */
}

.ai-orb-container.small-orb .orb-ring {
    border-width: 1px;
}

.ai-orb-container.small-orb .orb-particles {
    display: none;
    /* Hide particles for small version to reduce noise */
}

/* Performance: isolate small orbs so their animations don't affect scroll paint */
.ai-orb-container.small-orb .orb-core {
    animation: orbPulse 4s ease-in-out infinite;
    filter: none;
    /* Remove blur from pseudo-elements via simplified rendering */
}

.ai-orb-container.small-orb .orb-core::before {
    filter: none;
    /* Remove blur for performance on mobile */
}

.ai-orb-container.small-orb .orb-core::after {
    filter: blur(3px);
    /* Reduced from 5px */
}

.ai-orb-container.small-orb .orb-glow {
    filter: blur(8px);
    /* Reduced from 12px */
    animation: none;
    /* Disable glow animation on small orbs */
}

.ai-orb-container.small-orb .orb-ring {
    animation: orbRing 12s linear infinite;
    /* Slower rotation = less GPU work */
}

.ai-orb-container.small-orb::before {
    display: none;
    /* Remove background blur pseudo-element */
}

/* Mouse follow effect (via JS) */
.ai-orb-container.interactive .ai-orb {
    transition: transform 0.1s ease-out;
}

/* PWA Install Button */
.install-btn {
    background: transparent;
    border: 1px solid var(--accent);
    color: var(--accent);
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    margin-right: 8px;
}

.install-btn:hover {
    background: var(--accent);
    color: white;
    box-shadow: 0 0 10px var(--accent-glow);
}

/* PWA Install Button */
.install-btn {
    background: transparent;
    border: 1px solid var(--accent);
    color: var(--accent);
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    margin-right: 8px;
}

.install-btn:hover {
    background: var(--accent);
    color: white;
    box-shadow: 0 0 10px var(--accent-glow);
}

/* === Voice Tuning Controls === */
.voice-tuning-row {
    display: flex;
    gap: 16px;
    align-items: flex-start;
}

.voice-tuning-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.voice-tuning-item label {
    font-size: 12px;
    color: var(--text-secondary, #94a3b8);
    display: flex;
    justify-content: space-between;
}

.voice-tuning-item label span {
    color: var(--accent, #22d3ee);
    font-weight: 600;
}

.voice-tuning-item input[type="range"] {
    width: 100%;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--bg-tertiary, #1e293b);
    border-radius: 3px;
    outline: none;
    cursor: pointer;
}

.voice-tuning-item input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent, #22d3ee);
    cursor: pointer;
    box-shadow: 0 0 6px rgba(34, 211, 238, 0.4);
}

.voice-tuning-item input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent, #22d3ee);
    cursor: pointer;
    border: none;
}

/* === Mobile Responsive: Voice Settings === */
@media (max-width: 600px) {
    .voice-selector-row {
        flex-direction: column;
        gap: 6px;
    }

    .voice-selector-row select {
        width: 100%;
        font-size: 12px;
    }

    .voice-selector-row .btn-small {
        width: 100%;
        text-align: center;
    }

    .voice-tuning-row {
        flex-direction: column;
        gap: 8px;
    }

    .modal-large {
        width: 95vw !important;
        max-width: 95vw !important;
        margin: 10px;
    }
}