/* 
   ==========================================================================
   GALACTIC MODERN DESIGN SYSTEM (AURORA DARK) - REFINED
   Aligned with Hostgalaxy AI Chat Design Guidelines
   ==========================================================================
*/

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=Outfit:wght@400;600;800&display=swap');

:root {
    /* Premium Aurora Design System (Light Aurora - Aligned with hostgalaxy.ch) */
    --bg-deep: #f5f7fb;
    --bg-surface: #ffffff;
    --bg-sidebar: rgba(255, 255, 255, 0.92);
    --bg-header: rgba(255, 255, 255, 0.85);
    
    --primary: #7c3aed; /* Friendly brand violet */
    --primary-glow: rgba(124, 58, 237, 0.15);
    --accent: #06b6d4;  /* Friendly brand cyan */
    --accent-glow: rgba(6, 182, 212, 0.15);
    --accent-secondary: #7c3aed;
    
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    
    --border-subtle: rgba(15, 23, 42, 0.08);
    --border-active: rgba(6, 182, 212, 0.3);
    --border-glass: rgba(15, 23, 42, 0.08);
    
    --shadow-soft: 0 10px 30px -5px rgba(15, 23, 42, 0.06), 0 0 1px rgba(15, 23, 42, 0.08);
    --shadow-glow: 0 10px 30px -5px rgba(124, 58, 237, 0.12), 0 0 25px rgba(124, 58, 237, 0.08);
    
    --radius-lg: 20px;
    --radius-md: 14px;
    --radius-sm: 8px;
    --radius-full: 9999px;

    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Base Reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
}

body, html {
    margin: 0;
    padding: 0;
    font-family: 'Outfit', 'Inter', sans-serif;
    background: linear-gradient(rgba(245, 247, 251, 0.94), rgba(245, 247, 251, 0.98)),
                radial-gradient(circle at top right, #c7d2fe, #ddd6fe, #fecdd3, #fed7aa) !important;
    background-attachment: fixed !important;
    background-size: 400% 400% !important;
    animation: gradientBG 15s ease infinite !important;
    color: var(--text-primary);
    min-height: 100vh;
    height: 100vh;
    overflow: hidden;
}

@keyframes gradientBG {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* Background Aurora Blobs */
.bg-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -2;
    background: radial-gradient(circle at 10% 20%, rgba(124, 58, 237, 0.15) 0%, transparent 40%),
                radial-gradient(circle at 90% 80%, rgba(0, 242, 254, 0.15) 0%, transparent 40%),
                #080b11;
}

.aurora-blob {
    position: fixed;
    border-radius: 50%;
    filter: blur(120px);
    z-index: -1;
    pointer-events: none;
    opacity: 0.4;
    animation: float 20s ease-in-out infinite alternate;
}

.blob-1 {
    top: -10%;
    right: 10%;
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(124, 58, 237, 0.4) 0%, transparent 70%);
}

.blob-2 {
    bottom: -10%;
    left: 10%;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(0, 242, 254, 0.4) 0%, transparent 70%);
    animation-delay: -5s;
}

@keyframes float {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(50px, 30px) scale(1.1); }
}

/* App Container Layout */
.app-container {
    display: flex;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    position: relative;
}

/* Sidebar Styling */
.sidebar {
    width: 280px;
    height: 100%;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: var(--transition-smooth);
    backdrop-filter: blur(20px);
    box-shadow: var(--shadow-soft);
}

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

.sidebar-brand {
    font-family: 'Outfit', sans-serif;
    font-size: 20px;
    font-weight: 800;
    color: var(--text-primary);
    text-decoration: none;
    letter-spacing: -0.5px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.sidebar-brand span {
    color: var(--accent);
}

.btn-new-chat {
    margin: 16px 20px;
    padding: 12px 16px;
    background: linear-gradient(135deg, var(--accent-secondary) 0%, var(--primary) 100%);
    border: none;
    border-radius: var(--radius-md);
    color: #ffffff;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: var(--transition-smooth);
    box-shadow: 0 4px 15px rgba(124, 58, 237, 0.25);
}

.btn-new-chat:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 25px rgba(124, 58, 237, 0.35);
}

.chat-history-container {
    flex: 1;
    overflow-y: auto;
    padding: 0 12px 20px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* Custom Scrollbar for Sidebar & Chat */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(15, 23, 42, 0.15);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(15, 23, 42, 0.3);
}

/* Chat Item List */
.chat-item {
    display: flex;
    align-items: center;
    padding: 12px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition-smooth);
    color: var(--text-secondary);
    gap: 12px;
    position: relative;
    font-size: 14px;
}

.chat-item:hover {
    background: rgba(124, 58, 237, 0.06);
    color: var(--text-primary);
}

.chat-item.active {
    background: rgba(124, 58, 237, 0.12);
    border: 1px solid rgba(124, 58, 237, 0.25);
    color: var(--text-primary);
    font-weight: 600;
}

.chat-item-title {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-right: 24px;
}

.chat-item-actions {
    position: absolute;
    right: 8px;
    display: none;
    gap: 6px;
}

.chat-item:hover .chat-item-actions,
.chat-item.active .chat-item-actions {
    display: flex;
}

.chat-item-action-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: var(--transition-smooth);
}

.chat-item-action-btn:hover {
    color: var(--text-primary);
    background: rgba(15, 23, 42, 0.08);
}

.chat-item-action-btn.delete:hover {
    color: #ff4757;
    background: rgba(255, 71, 87, 0.15);
}

.sidebar-footer {
    padding: 16px 20px max(24px, env(safe-area-inset-bottom));
    border-top: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.sidebar-version-badge {
    font-size: 11px;
    font-weight: 700;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    text-align: center;
    padding: 3px 12px;
    background: rgba(124, 58, 237, 0.08);
    border: 1px solid rgba(124, 58, 237, 0.18);
    border-radius: 12px;
    align-self: center;
}

.sidebar-status-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-top: 4px;
}

/* Active Model Quota Bar directly under Model Selector & Buttons */
.active-quota-bar {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    padding: 5px 12px;
    background: rgba(124, 58, 237, 0.05);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(124, 58, 237, 0.16);
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    width: fit-content;
}

.sidebar-key-status {
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}
.status-dot.active {
    background: #2ed573;
    box-shadow: 0 0 8px #2ed573;
}
.status-dot.inactive {
    background: #ff4757;
    box-shadow: 0 0 8px #ff4757;
}

/* Main Chat Area Styling */
.main-chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    position: relative;
}

/* Header Styling */
.main-header {
    height: 70px;
    padding: 0 30px;
    background: var(--bg-header);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 50;
}

.menu-toggle {
    display: none;
    background: #ffffff;
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 20px;
    cursor: pointer;
    min-width: 44px;
    min-height: 44px;
    width: 44px;
    height: 44px;
    align-items: center;
    justify-content: center;
    padding: 0;
    touch-action: manipulation;
    transition: var(--transition-smooth);
    z-index: 100;
    box-shadow: var(--shadow-soft);
}

.menu-toggle:hover,
.menu-toggle:active {
    background: rgba(6, 182, 212, 0.15);
    border-color: var(--accent);
    color: var(--primary);
    transform: scale(1.05);
}

.header-model-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.btn-settings {
    background: #ffffff;
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
    padding: 10px 16px;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition-smooth);
    box-shadow: var(--shadow-soft);
}

.btn-settings:hover {
    background: #f8fafc;
    border-color: var(--primary);
}

/* Chat Messages Viewport */
.chat-messages-viewport {
    flex: 1;
    overflow-y: auto;
    padding: 40px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.chat-messages-content {
    width: 100%;
    max-width: 850px;
    padding: 0 20px;
}

/* Empty State / Welcome Screen */
.welcome-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    height: 100%;
    max-width: 600px;
    margin: auto;
    padding: 20px;
}

.welcome-logo {
    font-family: 'Outfit', sans-serif;
    font-size: 42px;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 16px;
}

.welcome-logo span {
    color: var(--accent);
}

.welcome-subtitle {
    color: var(--text-secondary);
    font-size: 16px;
    margin-bottom: 32px;
    line-height: 1.6;
}

.prompt-suggestions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    width: 100%;
    margin-bottom: 40px;
}

.prompt-card {
    background: #ffffff;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 16px;
    cursor: pointer;
    text-align: left;
    transition: var(--transition-smooth);
    box-shadow: var(--shadow-soft);
}

.prompt-card:hover {
    border-color: var(--accent);
    background: rgba(6, 182, 212, 0.05);
    transform: translateY(-2px);
}

.prompt-card h4 {
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 6px;
}

.prompt-card p {
    color: var(--text-secondary);
    font-size: 12px;
    line-height: 1.4;
}

/* Messages Bubbles */
.hg-msg {
    display: flex;
    gap: 20px;
    margin-bottom: 32px;
    animation: fadeIn 0.4s ease;
}

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

.hg-msg.message.user {
    flex-direction: row-reverse;
}

.hg-msg-avatar {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: #ffffff;
    border: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--primary);
    font-size: 18px;
    box-shadow: var(--shadow-soft);
}

.hg-msg.message.user .hg-msg-avatar {
    background: var(--primary-glow);
    border-color: rgba(124, 58, 237, 0.3);
    color: var(--primary);
}

.hg-msg-content-wrapper {
    max-width: calc(100% - 60px);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.hg-msg.message.user .hg-msg-content-wrapper {
    align-items: flex-end;
}

.hg-msg-sender {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.hg-msg-bubble {
    background: #ffffff;
    border: 1px solid var(--border-glass);
    border-radius: 6px 18px 18px 18px;
    padding: 16px 20px;
    color: var(--text-primary);
    box-shadow: var(--shadow-soft);
    position: relative;
    line-height: 1.7;
    font-size: 15px;
    word-break: break-word;
    backdrop-filter: blur(10px);
}

.hg-msg.message.user .hg-msg-bubble {
    border-radius: 18px 6px 18px 18px;
    background: rgba(124, 58, 237, 0.08) !important;
    border-color: rgba(124, 58, 237, 0.25) !important;
}

/* Text & Code formatting inside bubbles */
.hg-msg-bubble p {
    margin-bottom: 12px;
    color: var(--text-primary);
}
.hg-msg-bubble p:last-child {
    margin-bottom: 0;
}
.hg-msg-bubble ol, .hg-msg-bubble ul {
    margin-left: 24px;
    margin-bottom: 12px;
    color: var(--text-primary);
}
.hg-msg-bubble li {
    margin-bottom: 6px;
    color: var(--text-primary);
}
.hg-msg-bubble code {
    background: rgba(124, 58, 237, 0.08);
    padding: 3px 6px;
    border-radius: 4px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 13px;
    color: var(--primary);
}
.hg-msg-bubble pre code {
    background: transparent;
    padding: 0;
    border-radius: 0;
    color: inherit;
}
.hg-msg-bubble pre {
    margin: 16px 0;
    background: #0f172a;
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    padding: 16px;
    overflow-x: auto;
    position: relative;
}

/* Message Bubble Action Buttons (Speech & Copy) */
.hg-msg-actions {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    gap: 6px;
    opacity: 0;
    transition: var(--transition-smooth);
    z-index: 10;
}

.hg-msg-bubble:hover .hg-msg-actions {
    opacity: 1;
}

@media (max-width: 768px) {
    .hg-msg-actions {
        opacity: 1 !important;
    }
}

.hg-bubble-action-btn {
    background: #ffffff;
    border: 1px solid var(--border-glass);
    border-radius: 6px;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition-smooth);
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
}

.hg-bubble-action-btn:hover {
    background: var(--primary);
    color: #ffffff;
    border-color: var(--primary);
    transform: scale(1.05);
}

.hg-bubble-action-btn.speaking {
    background: var(--accent) !important;
    color: #ffffff !important;
    border-color: var(--accent) !important;
    animation: speakingPulse 1.2s infinite alternate;
}

@keyframes speakingPulse {
    0% { box-shadow: 0 0 0 0 rgba(6, 182, 212, 0.6); }
    100% { box-shadow: 0 0 0 10px rgba(6, 182, 212, 0); }
}

.hg-code-copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 11px;
    font-weight: 600;
    color: #cbd5e1;
    cursor: pointer;
    transition: var(--transition-smooth);
    display: flex;
    align-items: center;
    gap: 4px;
}

.hg-code-copy-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
}

.copied-state {
    background: #2ed573 !important;
    color: #ffffff !important;
    border-color: #2ed573 !important;
}

/* User Input Wrapper */
.hg-input-viewport {
    width: 100%;
    display: flex;
    justify-content: center;
    padding: 0 20px 30px;
}

.hg-input-shell {
    width: 100%;
    max-width: 850px;
    background: #ffffff;
    backdrop-filter: blur(15px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    padding: 16px;
    box-shadow: var(--shadow-soft);
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: var(--transition-smooth);
}

.hg-input-shell:focus-within {
    border-color: var(--accent);
    box-shadow: var(--shadow-glow);
}

.userInput-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

.hg-mic-btn {
    background: rgba(124, 58, 237, 0.08);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    color: var(--primary);
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
    transition: var(--transition-smooth);
    flex-shrink: 0;
}

.hg-mic-btn:hover {
    background: rgba(124, 58, 237, 0.18);
    border-color: var(--primary);
    transform: scale(1.05);
}

.hg-mic-btn.recording {
    background: #ff4757 !important;
    color: #ffffff !important;
    border-color: #ff4757 !important;
    animation: micPulse 1.2s infinite alternate;
}

@keyframes micPulse {
    0% { box-shadow: 0 0 0 0 rgba(255, 71, 87, 0.6); }
    100% { box-shadow: 0 0 0 10px rgba(255, 71, 87, 0); }
}

textarea#userInput {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    font-size: 15px;
    resize: none;
    outline: none;
    min-height: 48px;
    max-height: 200px;
    line-height: 1.5;
    padding: 8px 0;
}

textarea#userInput::placeholder {
    color: var(--text-muted);
}

.hg-input-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid rgba(15, 23, 42, 0.06);
    padding-top: 12px;
}

.model-selector-wrapper {
    position: relative;
}

.hg-model-select {
    background: #ffffff;
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    padding: 8px 30px 8px 12px;
    font-size: 13px;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    transition: var(--transition-smooth);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%2306b6d4' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 14px;
}

.hg-model-select:hover {
    background-color: #f8fafc;
    border-color: var(--accent);
}

.hg-model-select option {
    background: #ffffff;
    color: var(--text-primary);
}

.action-buttons-group {
    display: flex;
    gap: 8px;
}

.hg-btn-secondary {
    background: #ffffff;
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-smooth);
    display: flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
}

.hg-btn-secondary:hover {
    background: #f8fafc;
    color: var(--text-primary);
}

.hg-input-send {
    background: linear-gradient(135deg, var(--accent) 0%, var(--primary) 100%);
    border: none;
    border-radius: var(--radius-sm);
    color: #ffffff;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-weight: 700;
    transition: var(--transition-smooth);
    box-shadow: 0 4px 12px rgba(6, 182, 212, 0.25);
}

.hg-input-send:hover {
    transform: translateY(-1px) scale(1.05);
    box-shadow: 0 6px 15px rgba(0, 242, 254, 0.3);
}

.hg-input-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Modal Popup Settings Layout */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    padding: 16px;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(10px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: var(--transition-smooth);
    overflow-y: auto;
}

.modal-overlay.show {
    opacity: 1;
    pointer-events: all;
}

.modal-container {
    width: 100%;
    max-width: 500px;
    max-height: calc(100vh - 40px);
    max-height: calc(100dvh - 40px);
    display: flex;
    flex-direction: column;
    background: #ffffff;
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 50px rgba(15, 23, 42, 0.15);
    padding: 24px 20px;
    position: relative;
    transform: scale(0.95);
    transition: var(--transition-smooth);
    color: var(--text-primary);
    overflow: hidden;
}

.modal-overlay.show .modal-container {
    transform: scale(1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    flex-shrink: 0;
}

.modal-title {
    font-family: 'Outfit', sans-serif;
    font-size: 22px;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-close-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.modal-close-btn:hover {
    color: var(--text-primary);
}

.modal-body {
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    padding-right: 4px;
    padding-bottom: 8px;
    flex: 1;
}

.setting-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.setting-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.setting-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

.setting-input-wrapper i.input-icon {
    position: absolute;
    left: 14px;
    color: var(--text-muted);
    z-index: 2;
}

.setting-input-wrapper input[type="text"],
.setting-input-wrapper input[type="password"] {
    width: 100%;
    padding: 10px 105px 10px 40px;
    background: #f8fafc;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 13px;
    outline: none;
    transition: var(--transition-smooth);
}

.setting-input-wrapper input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 10px rgba(6, 182, 212, 0.15);
    background: #ffffff;
}

.btn-toggle-visibility {
    position: absolute;
    right: 76px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    font-size: 13px;
    z-index: 2;
    transition: var(--transition-smooth);
}

.btn-toggle-visibility:hover {
    color: var(--text-primary);
}

textarea.setting-textarea {
    width: 100%;
    min-height: 80px;
    padding: 12px;
    background: #f8fafc;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 14px;
    font-family: 'Inter', sans-serif;
    outline: none;
    resize: vertical;
    transition: var(--transition-smooth);
}

textarea.setting-textarea:focus {
    border-color: var(--accent);
    background: #ffffff;
}

.range-slider-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.range-slider {
    flex: 1;
    accent-color: var(--primary);
    cursor: pointer;
}

.range-value {
    font-size: 14px;
    font-weight: 600;
    min-width: 24px;
    text-align: right;
}

.btn-save-settings {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    border: none;
    border-radius: var(--radius-md);
    color: #ffffff;
    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
    transition: var(--transition-smooth);
    margin-top: 10px;
}

.btn-save-settings:hover {
    box-shadow: 0 8px 20px rgba(124, 58, 237, 0.25);
    transform: translateY(-1px);
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: rgba(13, 17, 23, 0.9);
    border: 1px solid #2ed573;
    color: #fff;
    padding: 12px 24px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 2000;
    box-shadow: var(--shadow-soft);
    backdrop-filter: blur(10px);
    opacity: 0;
    transform: translateY(20px);
    transition: var(--transition-smooth);
    pointer-events: none;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast.error {
    border-color: #ff4757;
}

/* Mobile Responsiveness & Edge Padding Fixes */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -280px;
        top: 0;
        bottom: 0;
    }
    
    .sidebar.show {
        left: 0;
    }
    
    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        background: rgba(0, 0, 0, 0.6);
        z-index: 90;
        display: none;
        backdrop-filter: blur(4px);
    }
    
    .sidebar-overlay.show {
        display: block;
    }
    
    .menu-toggle {
        display: inline-flex !important;
    }
    
    .prompt-suggestions {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 600px) {
    .main-header {
        padding-top: max(32px, env(safe-area-inset-top)) !important;
        padding-bottom: 12px !important;
        padding-left: 16px !important;
        padding-right: 16px !important;
        height: auto !important;
        min-height: 85px !important;
        align-items: flex-end !important;
    }

    .sidebar-header {
        padding-top: max(32px, env(safe-area-inset-top)) !important;
    }

    .chat-messages-viewport {
        padding: 16px 0 20px !important;
    }

    .chat-messages-content {
        padding: 0 14px !important;
    }

    .welcome-container {
        padding: 20px 24px !important;
        max-width: 100% !important;
    }

    .welcome-logo {
        font-size: 32px !important;
        margin-bottom: 12px !important;
    }

    .welcome-subtitle {
        font-size: 14px !important;
        padding: 0 12px !important;
        margin-bottom: 24px !important;
    }

    .prompt-suggestions {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
        padding: 0 10px !important;
        margin-bottom: 24px !important;
    }

    .prompt-card {
        padding: 14px 16px !important;
        margin: 0 4px !important;
    }

    .hg-msg {
        gap: 10px !important;
        margin-bottom: 20px !important;
    }

    .hg-msg-avatar {
        width: 34px !important;
        height: 34px !important;
        font-size: 14px !important;
        border-radius: 10px !important;
    }

    .hg-msg-content-wrapper {
        max-width: calc(100% - 46px) !important;
    }

    .hg-msg-bubble {
        padding: 12px 14px !important;
        font-size: 14px !important;
        border-radius: 14px !important;
    }

    .hg-input-viewport {
        padding: 0 12px 16px !important;
        padding-bottom: max(16px, env(safe-area-inset-bottom)) !important;
    }

    .hg-input-shell {
        padding: 12px !important;
        border-radius: 16px !important;
    }

    .hg-input-actions {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 10px !important;
    }

    .model-selector-wrapper {
        width: 100% !important;
    }

    .hg-model-select {
        width: 100% !important;
    }

    .action-buttons-group {
        justify-content: flex-end !important;
        width: 100% !important;
    }

    .modal-container {
        width: 92% !important;
        padding: 20px !important;
        margin: 0 16px !important;
    }
}

/* Typing Loading Cursor */
.typing-cursor {
    display: inline-block;
    width: 6px;
    height: 15px;
    background: var(--accent);
    margin-left: 4px;
    animation: blink 0.8s infinite;
    vertical-align: middle;
}

@keyframes blink {
    0%, 100% { opacity: 0; }
    50% { opacity: 1; }
}

/* ==========================================================================
   UX ENHANCEMENTS & ADDONS (Version 3.24)
   ========================================================================== */

/* Sidebar Search */
.sidebar-search-wrapper {
    position: relative;
    margin: 0 20px 12px;
}

.sidebar-search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 13px;
    pointer-events: none;
}

.sidebar-search-input {
    width: 100%;
    padding: 8px 12px 8px 34px;
    background: rgba(15, 23, 42, 0.04);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 13px;
    color: var(--text-primary);
    outline: none;
    transition: var(--transition-smooth);
}

.sidebar-search-input:focus {
    background: #ffffff;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.15);
}

/* Header Model Badge */
.header-model-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(124, 58, 237, 0.08);
    border: 1px solid rgba(124, 58, 237, 0.2);
    padding: 6px 14px;
    border-radius: var(--radius-full);
    color: var(--primary);
    font-size: 13px;
    font-weight: 600;
    backdrop-filter: blur(10px);
}

.header-model-badge i {
    color: var(--accent);
}

/* Scroll To Bottom Button */
.scroll-to-bottom-btn {
    position: absolute;
    bottom: 24px;
    right: 24px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #ffffff;
    color: var(--primary);
    border: 1px solid var(--border-glass);
    box-shadow: 0 6px 20px rgba(15, 23, 42, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: var(--transition-smooth);
    z-index: 40;
}

.scroll-to-bottom-btn.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.scroll-to-bottom-btn:hover {
    background: var(--primary);
    color: #ffffff;
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(124, 58, 237, 0.35);
}

/* System Prompt Presets Pills */
.preset-buttons-container {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 10px;
}

.preset-pill {
    background: rgba(124, 58, 237, 0.06);
    border: 1px solid rgba(124, 58, 237, 0.18);
    border-radius: var(--radius-full);
    padding: 5px 12px;
    font-size: 12px;
    font-weight: 600;
    color: var(--primary);
    cursor: pointer;
    transition: var(--transition-smooth);
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.preset-pill:hover {
    background: var(--primary);
    color: #ffffff;
    border-color: var(--primary);
    transform: translateY(-1px);
}

/* Key Test Button */
.btn-test-key {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(6, 182, 212, 0.08);
    border: 1px solid rgba(6, 182, 212, 0.3);
    color: var(--accent);
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    z-index: 2;
    transition: var(--transition-smooth);
}

.btn-test-key:hover {
    background: var(--accent);
    color: #ffffff;
}

.btn-test-key.loading {
    opacity: 0.7;
    pointer-events: none;
}

/* Message Hover Actions Enhancement */
.hg-msg-actions {
    opacity: 0.2;
}

.hg-msg-bubble:hover .hg-msg-actions,
.hg-msg:hover .hg-msg-actions {
    opacity: 1;
}

.hg-bubble-action-btn.edit-btn:hover {
    background: #06b6d4;
    color: #ffffff;
}

.hg-bubble-action-btn.regenerate-btn:hover {
    background: #7c3aed;
    color: #ffffff;
}

.hg-bubble-action-btn.preview-btn {
    background: #ec4899;
    color: #ffffff;
}

.hg-bubble-action-btn.preview-btn:hover {
    background: #db2777;
}

/* Code Header Actions Bar */
.code-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    position: absolute;
    top: 8px;
    right: 8px;
}

.hg-code-preview-btn {
    background: rgba(6, 182, 212, 0.2);
    border: 1px solid rgba(6, 182, 212, 0.4);
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 11px;
    font-weight: 600;
    color: #38bdf8;
    cursor: pointer;
    transition: var(--transition-smooth);
    display: flex;
    align-items: center;
    gap: 4px;
}

.hg-code-preview-btn:hover {
    background: #06b6d4;
    color: #ffffff;
}

/* ==========================================================================
   DARK MODE & ADVANCED FEATURES (Version 3.25)
   ========================================================================== */

[data-theme="dark"] {
    --bg-deep: #090d16;
    --bg-surface: #111827;
    --bg-sidebar: rgba(17, 24, 39, 0.95);
    --bg-header: rgba(17, 24, 39, 0.88);
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #64748b;
    --border-subtle: rgba(255, 255, 255, 0.08);
    --border-glass: rgba(255, 255, 255, 0.1);
    --shadow-soft: 0 10px 30px -5px rgba(0, 0, 0, 0.5);
}

body[data-theme="dark"] {
    background: linear-gradient(rgba(9, 13, 22, 0.96), rgba(9, 13, 22, 0.98)),
                radial-gradient(circle at top right, #1e1b4b, #31104b, #111827, #0f172a) !important;
    color: #f8fafc !important;
}

[data-theme="dark"] .hg-input-shell,
[data-theme="dark"] .prompt-card,
[data-theme="dark"] .modal-container,
[data-theme="dark"] .hg-msg-bubble {
    background: #111827 !important;
    border-color: rgba(255, 255, 255, 0.1) !important;
    color: #f8fafc !important;
}

[data-theme="dark"] .prompt-card h4,
[data-theme="dark"] .setting-label,
[data-theme="dark"] .modal-title {
    color: #f8fafc !important;
}

[data-theme="dark"] textarea#userInput,
[data-theme="dark"] .hg-model-select {
    color: #f8fafc !important;
    background: #1e293b !important;
}

/* Theme Toggle Button */
.btn-theme-toggle {
    background: #ffffff;
    border: 1px solid var(--border-subtle);
    color: var(--primary);
    width: 42px;
    height: 42px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    cursor: pointer;
    transition: var(--transition-smooth);
    box-shadow: var(--shadow-soft);
}

.btn-theme-toggle:hover {
    transform: scale(1.05);
    border-color: var(--accent);
}

[data-theme="dark"] .btn-theme-toggle {
    background: #1e293b;
    color: #f59e0b;
    border-color: rgba(255, 255, 255, 0.15);
}

/* Drag and Drop Overlay */
.drag-drop-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.78);
    backdrop-filter: blur(8px);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: var(--transition-smooth);
}

.drag-drop-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.drag-drop-content {
    background: var(--bg-surface);
    border: 2px dashed var(--accent);
    border-radius: 24px;
    padding: 40px 60px;
    text-align: center;
    color: var(--text-primary);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
    transform: scale(0.9);
    transition: var(--transition-smooth);
}

.drag-drop-overlay.active .drag-drop-content {
    transform: scale(1);
}

.drag-drop-content i {
    font-size: 52px;
    color: var(--accent);
    margin-bottom: 16px;
    animation: bounce 1.5s infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

/* Attachment Preview Container & Badges */
.attachment-preview-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding-bottom: 10px;
    margin-bottom: 8px;
    border-bottom: 1px solid var(--border-subtle);
}

.attachment-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(6, 182, 212, 0.1);
    border: 1px solid rgba(6, 182, 212, 0.3);
    border-radius: 12px;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
    max-width: 240px;
    overflow: hidden;
}

.attachment-badge img {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    object-fit: cover;
}

.attachment-remove-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 13px;
    padding: 2px;
    transition: var(--transition-smooth);
}

.attachment-remove-btn:hover {
    color: #ff4757;
}

/* Performance Stats Badge */
.stats-badge {
    font-size: 11px;
    font-weight: 600;
    color: var(--accent);
    background: rgba(6, 182, 212, 0.12);
    border: 1px solid rgba(6, 182, 212, 0.25);
    padding: 2px 8px;
    border-radius: 8px;
    margin-left: 8px;
}

/* Mobile Touch & WebView Enhancements */
* {
    -webkit-tap-highlight-color: transparent;
}

button, a, .icon-btn, .hg-bubble-action-btn, .send-btn {
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
}

.messages-list, .chat-viewport, .chat-history {
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 768px) {
    .icon-btn, .hg-bubble-action-btn {
        min-width: 42px;
        min-height: 42px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
}




