/* ============================================
   HexAI — Premium Dark UI (lolz.live × Claude.ai)
   Cyberpunk-neon dark with purple glow accents
   ============================================ */

/* === Variables === */
:root {
    /* Premium light palette */
    --bg: #f4f2ee;
    --bg-alt: #e8e5df;
    --bg-card: #ffffff;
    --bg-card-hover: #f7f6f4;
    --bg-sidebar: #f9f8f6;
    --bg-input: #ffffff;
    --bg-code: #f8f8f8;

    --text: #18161a;
    --text-secondary: #6e6a78;
    --text-muted: #9d98a8;
    --text-faint: #d0ccda;

    --border: #ddd9e6;
    --border-light: #eae6f0;
    --border-hover: #c5c0d2;

    --accent: #8b5cf6;
    --accent-light: #a78bfa;
    --accent-bg: rgba(139, 92, 246, 0.08);
    --accent-glow: rgba(139, 92, 246, 0.18);

    --glow-color: rgba(139, 92, 246, 0.06);
    --glow-color-strong: rgba(139, 92, 246, 0.14);

    --success: #10b981;
    --error: #ef4444;
    --neon-pulse: rgba(139, 92, 246, 0.4);

    /* Layout */
    --sidebar-w: 260px;
    --topbar-h: 54px;
    --chat-max-w: 740px;
    --input-radius: 24px;

    --r-xs: 6px;
    --r-sm: 10px;
    --r-md: 14px;
    --r-lg: 20px;
    --r-xl: 28px;
    --r-full: 9999px;

    /* Font */
    --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --font-mono: "JetBrains Mono", "Cascadia Code", monospace;
    --fs-xs: 0.6875rem;
    --fs-sm: 0.8125rem;
    --fs-base: 0.9375rem;
    --fs-md: 1rem;
    --fs-lg: 1.125rem;
    --fs-xl: 1.375rem;
    --fs-hero: 1.75rem;

    --ease: cubic-bezier(0.16, 1, 0.3, 1);
    --t-fast: 150ms;
    --t-mid: 250ms;
    --t-slow: 400ms;
}

/* === Dark theme (PRIMARY — lolz.live × Claude.ai fusion) === */
[data-theme="dark"] {
    --bg: #08070b;
    --bg-alt: #0e0d14;
    --bg-card: #13121a;
    --bg-card-hover: #1a1826;
    --bg-sidebar: #0b0a10;
    --bg-input: #13121a;
    --bg-code: #0e0d14;

    --text: #e8e4f0;
    --text-secondary: #8a84a0;
    --text-muted: #524d68;
    --text-faint: #2a2740;

    --border: #221f38;
    --border-light: #1a1830;
    --border-hover: #352f58;

    --accent: #a78bfa;
    --accent-light: #c4b5fd;
    --accent-bg: rgba(167, 139, 250, 0.1);
    --accent-glow: rgba(167, 139, 250, 0.2);

    --glow-color: rgba(139, 92, 246, 0.06);
    --glow-color-strong: rgba(139, 92, 246, 0.12);
    --neon-pulse: rgba(167, 139, 250, 0.5);
}

/* === Reset === */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font);
    font-size: var(--fs-base);
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
    display: flex;
    height: 100dvh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    position: relative;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
    color: inherit;
    -webkit-tap-highlight-color: transparent;
}

.hidden {
    display: none !important;
}

textarea {
    font-family: inherit;
    resize: none;
}

a {
    color: var(--accent);
    text-decoration: none;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 4px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--text-faint);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* === Animated background orbs === */
.ambient-bg {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.35;
    will-change: transform;
    animation-timing-function: ease-in-out;
    animation-iteration-count: infinite;
    animation-direction: alternate;
}

.orb-1 {
    width: 350px;
    height: 350px;
    background: radial-gradient(
        circle,
        rgba(109, 92, 255, 0.3),
        transparent 70%
    );
    top: -80px;
    right: -60px;
    animation: orbFloat1 18s infinite alternate;
}

.orb-2 {
    width: 280px;
    height: 280px;
    background: radial-gradient(
        circle,
        rgba(168, 85, 247, 0.25),
        transparent 70%
    );
    bottom: 10%;
    left: -40px;
    animation: orbFloat2 22s infinite alternate;
}

.orb-3 {
    width: 200px;
    height: 200px;
    background: radial-gradient(
        circle,
        rgba(59, 130, 246, 0.2),
        transparent 70%
    );
    top: 40%;
    right: 15%;
    animation: orbFloat3 15s infinite alternate;
}

.orb-4 {
    width: 160px;
    height: 160px;
    background: radial-gradient(
        circle,
        rgba(236, 72, 153, 0.15),
        transparent 70%
    );
    top: 20%;
    left: 25%;
    animation: orbFloat4 20s infinite alternate;
}

.orb-5 {
    width: 120px;
    height: 120px;
    background: radial-gradient(
        circle,
        rgba(16, 185, 129, 0.15),
        transparent 70%
    );
    bottom: 20%;
    right: 30%;
    animation: orbFloat5 17s infinite alternate;
}

@keyframes orbFloat1 {
    0% {
        transform: translate(0, 0) scale(1);
    }
    33% {
        transform: translate(-60px, 40px) scale(1.1);
    }
    66% {
        transform: translate(30px, 80px) scale(0.95);
    }
    100% {
        transform: translate(-40px, 30px) scale(1.05);
    }
}

@keyframes orbFloat2 {
    0% {
        transform: translate(0, 0) scale(1);
    }
    33% {
        transform: translate(50px, -30px) scale(1.08);
    }
    66% {
        transform: translate(-20px, -60px) scale(0.92);
    }
    100% {
        transform: translate(40px, -20px) scale(1.03);
    }
}

@keyframes orbFloat3 {
    0% {
        transform: translate(0, 0) scale(1);
    }
    50% {
        transform: translate(-40px, 30px) scale(1.15);
    }
    100% {
        transform: translate(20px, -40px) scale(0.9);
    }
}

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

@keyframes orbFloat5 {
    0% {
        transform: translate(0, 0) scale(1);
    }
    50% {
        transform: translate(-30px, -40px) scale(1.2);
    }
    100% {
        transform: translate(40px, 30px) scale(0.85);
    }
}

/* Dark theme — richer neon purple orbs */
[data-theme="dark"] .orb {
    opacity: 0.22;
}
[data-theme="dark"] .orb-1 {
    background: radial-gradient(
        circle,
        rgba(139, 92, 246, 0.45),
        transparent 70%
    );
}
[data-theme="dark"] .orb-2 {
    background: radial-gradient(
        circle,
        rgba(167, 139, 250, 0.35),
        transparent 70%
    );
}
[data-theme="dark"] .orb-3 {
    background: radial-gradient(
        circle,
        rgba(124, 58, 237, 0.30),
        transparent 70%
    );
}
[data-theme="dark"] .orb-4 {
    background: radial-gradient(
        circle,
        rgba(196, 181, 253, 0.18),
        transparent 70%
    );
}
[data-theme="dark"] .orb-5 {
    background: radial-gradient(
        circle,
        rgba(139, 92, 246, 0.20),
        transparent 70%
    );
}

/* === Telegram Banner === */
.tg-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 40px 10px 16px;
    background: linear-gradient(135deg, #7c3aed 0%, #8b5cf6 40%, #a78bfa 100%);
    color: white;
    font-size: var(--fs-sm);
    font-weight: 500;
    animation: bannerSlide 0.4s var(--ease);
}

.tg-banner.hidden {
    display: none;
}

@keyframes bannerSlide {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.tg-banner-icon {
    font-size: 16px;
}

.tg-banner-text {
    text-align: center;
}

.tg-banner-text a {
    color: white;
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.tg-banner-text a:hover {
    opacity: 0.85;
}

.tg-banner-close {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    border-radius: var(--r-full);
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.7);
    transition: all var(--t-fast);
    cursor: pointer;
    border: none;
    background: none;
}

.tg-banner-close:hover {
    background: rgba(255, 255, 255, 0.15);
    color: white;
}

/* When banner is visible, push content down */
body:has(.tg-banner:not(.hidden)) .main {
    padding-top: 40px;
}

body:has(.tg-banner:not(.hidden)) .sidebar {
    top: 40px;
    height: calc(100dvh - 40px);
}

/* Sidebar TG link */
.sidebar-tg-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
    margin-bottom: 8px;
    font-size: var(--fs-xs);
    color: var(--accent);
    font-weight: 500;
    transition: opacity var(--t-fast);
    text-decoration: none;
}

.sidebar-tg-link:hover {
    opacity: 0.8;
    text-decoration: none;
}

.sidebar-tg-link svg {
    color: var(--accent);
    flex-shrink: 0;
}

/* ============================================
   SIDEBAR
   ============================================ */
.sidebar {
    width: var(--sidebar-w);
    height: 100dvh;
    background: rgba(250, 249, 247, 0.85);
    backdrop-filter: blur(24px) saturate(1.5);
    -webkit-backdrop-filter: blur(24px) saturate(1.5);
    border-right: 1px solid rgba(236, 234, 230, 0.6);
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0;
    top: 0;
    z-index: 200;
    transform: translateX(-100%);
    transition: transform var(--t-slow) var(--ease);
}

[data-theme="dark"] .sidebar {
    background: rgba(11, 10, 16, 0.9);
    border-right-color: rgba(34, 31, 56, 0.6);
    box-shadow: 4px 0 30px rgba(139, 92, 246, 0.03);
}

.sidebar.open {
    transform: translateX(0);
}

.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.15);
    backdrop-filter: blur(8px) saturate(1.2);
    -webkit-backdrop-filter: blur(8px) saturate(1.2);
    z-index: 190;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--t-mid);
}

.sidebar-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

.sidebar-inner {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 16px 12px;
    overflow: hidden;
}

.sidebar-top {
    margin-bottom: 20px;
}

.sidebar-new-chat {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 11px 16px;
    border-radius: var(--r-sm);
    font-size: var(--fs-sm);
    font-weight: 500;
    color: white;
    background: linear-gradient(135deg, #8b5cf6, #a78bfa, #7c3aed);
    border: none;
    transition: all var(--t-mid) var(--ease);
    box-shadow: 0 2px 12px rgba(139, 92, 246, 0.3);
}

.sidebar-new-chat svg {
    color: white;
}

.sidebar-new-chat:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 20px rgba(139, 92, 246, 0.45);
}

.sidebar-section {
    flex: 1;
    overflow-y: auto;
}

.sidebar-section-label {
    font-size: var(--fs-xs);
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    padding: 0 12px 8px;
}

.sidebar-chat-list {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.chat-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 12px;
    border-radius: var(--r-xs);
    cursor: pointer;
    transition: background var(--t-fast);
    font-size: var(--fs-sm);
    color: var(--text-secondary);
    position: relative;
}

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

.chat-item.active {
    background: linear-gradient(
        135deg,
        rgba(109, 92, 255, 0.1),
        rgba(109, 92, 255, 0.05)
    );
    color: var(--accent);
    font-weight: 500;
    border-left: 3px solid var(--accent);
    padding-left: 9px;
}

.chat-item-icon {
    font-size: 13px;
    flex-shrink: 0;
}

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

.chat-item-delete {
    opacity: 0;
    width: 22px;
    height: 22px;
    border-radius: var(--r-xs);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: all var(--t-fast);
    flex-shrink: 0;
}

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

.chat-item-delete:hover {
    background: rgba(239, 68, 68, 0.1);
    color: var(--error);
}

.sidebar-bottom {
    padding: 12px 16px;
    border-top: 1px solid var(--border-light);
}

.sidebar-model-badge {
    font-size: var(--fs-xs);
    color: var(--text-muted);
    font-weight: 500;
}

/* ============================================
   MAIN
   ============================================ */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100dvh;
    position: relative;
    z-index: 1;
}

/* === Topbar === */
.topbar {
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    padding: 0 16px;
    gap: 8px;
    flex-shrink: 0;
    z-index: 50;
    background: rgba(245, 243, 239, 0.6);
    backdrop-filter: blur(20px) saturate(1.4);
    -webkit-backdrop-filter: blur(20px) saturate(1.4);
    border-bottom: 1px solid rgba(224, 221, 216, 0.5);
}

[data-theme="dark"] .topbar {
    background: rgba(8, 7, 11, 0.7);
    border-bottom: 1px solid rgba(34, 31, 56, 0.5);
}

.topbar-sidebar-toggle {
    width: 36px;
    height: 36px;
    border-radius: var(--r-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: all var(--t-fast);
}

.topbar-sidebar-toggle:hover {
    background: var(--bg-alt);
    color: var(--text);
}

.topbar-spacer {
    flex: 1;
}

/* Model pill */
.model-selector {
    position: relative;
}

.model-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px 6px 10px;
    border-radius: var(--r-full);
    border: 1px solid rgba(224, 221, 216, 0.6);
    font-size: var(--fs-sm);
    font-weight: 500;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: all var(--t-mid) var(--ease);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.model-pill:hover {
    border-color: var(--accent);
    color: var(--text);
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 2px 8px rgba(109, 92, 255, 0.12);
    transform: translateY(-1px);
}

[data-theme="dark"] .model-pill {
    background: rgba(19, 18, 26, 0.8);
    border-color: rgba(34, 31, 56, 0.6);
}

[data-theme="dark"] .model-pill:hover {
    background: rgba(26, 24, 38, 0.9);
    box-shadow: 0 2px 12px rgba(167, 139, 250, 0.18);
}

.model-pill-icon {
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Model logo images */
.model-logo {
    width: 18px;
    height: 18px;
    object-fit: contain;
    vertical-align: middle;
    display: inline-block;
}

/* Bigger in dropdown */
.model-dropdown-icon .model-logo {
    width: 22px;
    height: 22px;
}

/* In message avatar */
.message-avatar .model-logo {
    width: 20px;
    height: 20px;
}

/* In sidebar chat item */
.chat-item-icon .model-logo {
    width: 16px;
    height: 16px;
}

/* In input model tag */
.input-model-tag .model-logo {
    width: 14px;
    height: 14px;
}

/* Light theme: dark-theme icons need inversion */
:root:not([data-theme="dark"]) .model-logo {
    filter: invert(1) hue-rotate(180deg);
}

.model-pill-name {
    font-weight: 500;
}

.model-pill-arrow {
    color: var(--text-muted);
    transition: transform var(--t-mid) var(--ease);
    margin-left: 2px;
}

.model-selector.open .model-pill-arrow {
    transform: rotate(180deg);
}

/* Dropdown */
.model-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 300px;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(24px) saturate(1.5);
    -webkit-backdrop-filter: blur(24px) saturate(1.5);
    border: 1px solid rgba(224, 221, 216, 0.6);
    border-radius: var(--r-md);
    box-shadow:
        0 12px 48px rgba(0, 0, 0, 0.1),
        0 4px 16px rgba(0, 0, 0, 0.05);
    opacity: 0;
    transform: translateY(-6px) scale(0.98);
    pointer-events: none;
    transition: all var(--t-mid) var(--ease);
    z-index: 200;
    overflow: hidden;
}

[data-theme="dark"] .model-dropdown {
    background: rgba(19, 18, 26, 0.95);
    border-color: rgba(34, 31, 56, 0.7);
    box-shadow:
        0 12px 48px rgba(0, 0, 0, 0.5),
        0 4px 16px rgba(139, 92, 246, 0.06);
}

.model-selector.open .model-dropdown {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.model-dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 14px 16px;
    text-align: left;
    transition: background var(--t-fast);
}

.model-dropdown-item:hover {
    background: var(--bg-alt);
}

.model-dropdown-item.active {
    background: var(--accent-bg);
    border-left: 3px solid var(--accent);
}

.model-dropdown-item + .model-dropdown-item {
    border-top: 1px solid var(--border-light);
}

.model-dropdown-icon {
    font-size: 20px;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--r-sm);
    background: var(--bg-alt);
    flex-shrink: 0;
}

.model-dropdown-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.model-dropdown-name {
    font-size: var(--fs-sm);
    font-weight: 600;
    color: var(--text);
}

.model-dropdown-desc {
    font-size: var(--fs-xs);
    color: var(--text-muted);
}

/* Topbar icon buttons (theme, settings) */
.topbar-icon-btn {
    width: 36px;
    height: 36px;
    border-radius: var(--r-full);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    border: 1px solid rgba(224, 221, 216, 0.6);
    background: rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: all var(--t-mid) var(--ease);
    margin-left: 4px;
}

.topbar-icon-btn:hover {
    color: var(--accent);
    border-color: var(--accent);
    background: rgba(109, 92, 255, 0.08);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(109, 92, 255, 0.12);
}

[data-theme="dark"] .topbar-icon-btn {
    background: rgba(19, 18, 26, 0.6);
    border-color: rgba(34, 31, 56, 0.6);
}

[data-theme="dark"] .topbar-icon-btn:hover {
    background: rgba(167, 139, 250, 0.12);
    box-shadow: 0 2px 10px rgba(167, 139, 250, 0.18);
}

.icon-sun {
    display: none;
}

[data-theme="dark"] .icon-moon {
    display: none;
}

[data-theme="dark"] .icon-sun {
    display: block;
}

/* ============================================
   SETTINGS DRAWER
   ============================================ */
.settings-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.15);
    backdrop-filter: blur(8px) saturate(1.2);
    -webkit-backdrop-filter: blur(8px) saturate(1.2);
    z-index: 290;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--t-mid);
}

.settings-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

.settings-drawer {
    position: fixed;
    top: 0;
    right: 0;
    width: 360px;
    max-width: 90vw;
    height: 100dvh;
    background: rgba(250, 249, 247, 0.9);
    backdrop-filter: blur(24px) saturate(1.5);
    -webkit-backdrop-filter: blur(24px) saturate(1.5);
    border-left: 1px solid rgba(236, 234, 230, 0.6);
    z-index: 300;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform var(--t-slow) var(--ease);
    box-shadow: -8px 0 40px rgba(0, 0, 0, 0.08);
}

[data-theme="dark"] .settings-drawer {
    background: rgba(11, 10, 16, 0.95);
    border-left-color: rgba(34, 31, 56, 0.6);
    box-shadow: -8px 0 40px rgba(0, 0, 0, 0.4);
}

.settings-drawer.open {
    transform: translateX(0);
}

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

.settings-title {
    font-size: var(--fs-md);
    font-weight: 600;
    color: var(--text);
}

.settings-close {
    width: 32px;
    height: 32px;
    border-radius: var(--r-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: all var(--t-fast);
}

.settings-close:hover {
    background: var(--bg-alt);
    color: var(--text);
}

.settings-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
}

.settings-section {
    margin-bottom: 24px;
}

.settings-section-title {
    font-size: var(--fs-sm);
    font-weight: 600;
    color: var(--text);
    margin-bottom: 14px;
}

.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 0;
}

.settings-label {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: var(--fs-sm);
    font-weight: 500;
    color: var(--text);
}

.settings-hint {
    font-size: var(--fs-xs);
    font-weight: 400;
    color: var(--text-muted);
}

.settings-prompt-wrap {
    margin-top: 10px;
}

.settings-textarea {
    width: 100%;
    padding: 12px;
    border-radius: var(--r-sm);
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text);
    font-size: var(--fs-sm);
    font-family: var(--font);
    line-height: 1.5;
    resize: vertical;
    min-height: 80px;
    outline: none;
    transition: border-color var(--t-fast);
}

.settings-textarea:focus {
    border-color: var(--accent);
}

.settings-textarea::placeholder {
    color: var(--text-muted);
}

.settings-save-btn {
    display: block;
    width: 100%;
    margin-top: 8px;
    padding: 9px 16px;
    border-radius: var(--r-sm);
    background: linear-gradient(135deg, var(--accent), var(--accent-light));
    color: white;
    font-size: var(--fs-sm);
    font-weight: 600;
    transition: all var(--t-mid) var(--ease);
    box-shadow: 0 2px 8px rgba(109, 92, 255, 0.2);
}

.settings-save-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(109, 92, 255, 0.35);
}

/* Toggle switch */
.toggle {
    position: relative;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

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

.toggle-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: var(--text-faint);
    border-radius: 24px;
    transition: background var(--t-mid);
}

.toggle-slider::before {
    content: "";
    position: absolute;
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: transform var(--t-mid) var(--ease);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
}

.toggle input:checked + .toggle-slider {
    background: linear-gradient(135deg, var(--accent), var(--accent-light));
}

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

/* Pill option group */
.pill-group {
    display: flex;
    gap: 4px;
    background: var(--bg-alt);
    border-radius: var(--r-full);
    padding: 3px;
}

.pill-option {
    padding: 5px 14px;
    border-radius: var(--r-full);
    font-size: var(--fs-xs);
    font-weight: 600;
    color: var(--text-muted);
    transition: all var(--t-fast);
}

.pill-option:hover {
    color: var(--text-secondary);
}

.pill-option.active {
    background: var(--bg-card);
    color: var(--accent);
    box-shadow: 0 1px 6px rgba(109, 92, 255, 0.12);
    font-weight: 700;
}

/* Image options in input toolbar */
.input-img-opts {
    display: flex;
    gap: 4px;
}

.input-img-opts.hidden {
    display: none;
}

.input-opt-pill {
    padding: 3px 10px;
    border-radius: var(--r-full);
    background: var(--accent-bg);
    color: var(--accent);
    font-size: var(--fs-xs);
    font-weight: 600;
    transition: all var(--t-fast);
    border: 1px solid transparent;
}

.input-opt-pill:hover {
    background: var(--accent-glow);
}

/* Image in messages */
.message-text img {
    max-width: 100%;
    border-radius: var(--r-sm);
    margin: 8px 0;
    border: 1px solid var(--border-light);
    cursor: pointer;
    transition: transform var(--t-fast);
}

.message-text img:hover {
    transform: scale(1.01);
}

/* Attachment preview */
.attach-preview {
    display: flex;
    gap: 8px;
    padding: 8px 12px;
    max-width: var(--chat-max-w);
    margin: 0 auto 6px;
    overflow-x: auto;
}

.attach-preview.hidden {
    display: none;
}

.attach-thumb {
    position: relative;
    width: 64px;
    height: 64px;
    flex-shrink: 0;
    border-radius: var(--r-sm);
    overflow: hidden;
    border: 1px solid var(--border);
}

.attach-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.attach-thumb-remove {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    cursor: pointer;
    border: none;
    line-height: 1;
}

.attach-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    padding: 3px 8px !important;
}

.attach-btn svg {
    color: var(--accent);
}

/* Attachment preview */
.attach-preview {
    display: flex;
    gap: 8px;
    padding: 8px 12px;
    max-width: var(--chat-max-w);
    margin: 0 auto 6px;
    overflow-x: auto;
}

.attach-preview.hidden {
    display: none;
}

.attach-thumb {
    position: relative;
    width: 64px;
    height: 64px;
    flex-shrink: 0;
    border-radius: var(--r-sm);
    overflow: hidden;
    border: 1px solid var(--border);
}

.attach-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.attach-thumb-remove {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.65);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    cursor: pointer;
    border: none;
    line-height: 1;
}

.attach-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    padding: 4px 10px !important;
    font-size: 13px;
}

.attach-btn.hidden {
    display: none;
}

.attach-btn svg {
    color: var(--accent);
}

.attach-btn:hover {
    background: var(--accent-glow);
}

.attach-file,
.user-file-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text);
    border-radius: var(--r-sm);
    padding: 8px 10px;
    font-size: var(--fs-xs);
    box-shadow: var(--shadow-sm);
}

.attach-file {
    max-width: 280px;
    flex-shrink: 0;
    position: relative;
    padding-right: 30px;
}

.attach-file-icon,
.user-file-icon {
    flex: 0 0 auto;
    width: 24px;
    height: 24px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    background: var(--accent-bg);
}

.attach-file-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 600;
}

.attach-file-size {
    color: var(--text-muted);
    white-space: nowrap;
}

.attach-file-remove {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    border: none;
    border-radius: 50%;
    color: white;
    background: rgba(0, 0, 0, 0.6);
    cursor: pointer;
    display: grid;
    place-items: center;
    line-height: 1;
    font-size: 11px;
}

.user-msg-files {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.user-file-chip {
    max-width: 100%;
    background: var(--bg-alt);
}

.user-file-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.user-file-info strong,
.user-file-info small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-file-info small {
    color: var(--text-muted);
    margin-top: 2px;
}

/* Media loader (image/video generation) */
.media-loader {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 24px;
    border-radius: var(--r-lg);
    background: rgba(109, 92, 255, 0.08);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(109, 92, 255, 0.15);
    animation: mediaLoaderFadeIn 0.4s var(--ease);
}

@keyframes mediaLoaderFadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Icon wrapper: ring + logo */
.media-loader-icon-wrap {
    position: relative;
    width: 56px;
    height: 56px;
    flex-shrink: 0;
}

.media-loader-ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 2.5px solid var(--border);
    border-top-color: var(--accent);
    animation: mediaLoaderSpin 1.2s linear infinite;
}

.media-loader-logo {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--bg-card);
}

.media-loader-logo .model-logo {
    width: 28px;
    height: 28px;
}

@keyframes mediaLoaderSpin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* Text info */
.media-loader-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.media-loader-model {
    font-size: var(--fs-base);
    font-weight: 700;
    color: var(--text);
}

.media-loader-text {
    font-size: var(--fs-sm);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 2px;
}

.media-loader-dots {
    display: inline-flex;
    gap: 1px;
    margin-left: 2px;
}

.media-loader-dots span {
    font-size: 18px;
    font-weight: 700;
    color: var(--accent);
    animation: mediaLoaderDot 1.4s ease-in-out infinite;
    line-height: 1;
}

.media-loader-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.media-loader-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

.media-loader-warning {
    font-size: var(--fs-xs);
    color: var(--text-muted);
    margin-top: 4px;
    opacity: 0;
    animation: mediaWarningFadeIn 0.6s ease 2s forwards;
}

@keyframes mediaWarningFadeIn {
    to {
        opacity: 1;
    }
}

@keyframes mediaLoaderDot {
    0%,
    60%,
    100% {
        opacity: 0.3;
        transform: translateY(0);
    }

    30% {
        opacity: 1;
        transform: translateY(-4px);
    }
}

/* Research loader variant */
.research-loader {
    background: linear-gradient(
        135deg,
        rgba(16, 185, 129, 0.1),
        transparent 60%
    );
}

.research-loader .media-loader-ring {
    border-top-color: var(--success);
}

.research-loader .media-loader-dots span {
    color: var(--success);
}

/* Clickable links in messages */
.message-text a,
.message-text a.msg-link {
    color: var(--accent);
    text-decoration: underline;
    text-decoration-color: rgba(109, 92, 255, 0.3);
    text-underline-offset: 2px;
    transition: all var(--t-fast);
    word-break: break-all;
}

.message-text a:hover,
.message-text a.msg-link:hover {
    color: var(--accent-light);
    text-decoration-color: var(--accent);
}

.message-text a:visited {
    color: var(--accent);
    opacity: 0.85;
}

/* Inline citation links [1], [2] etc. */
.message-text a.msg-link[href]:not([href=""]) {
    word-break: break-all;
}

/* Sources section styling */
.message-text hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 16px 0;
}

/* Collapsible sources block */
.message-text details.sources-block {
    margin-top: 12px;
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    overflow: hidden;
}

.message-text details.sources-block summary {
    padding: 10px 14px;
    font-size: var(--fs-sm);
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    background: var(--bg-alt);
    user-select: none;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 6px;
}

.message-text details.sources-block summary::-webkit-details-marker {
    display: none;
}

.message-text details.sources-block summary::before {
    content: "▶";
    font-size: 10px;
    transition: transform var(--t-fast);
    color: var(--text-muted);
}

.message-text details.sources-block[open] summary::before {
    transform: rotate(90deg);
}

.message-text details.sources-block summary:hover {
    color: var(--text);
    background: var(--bg-card-hover);
}

.message-text details.sources-block > ol,
.message-text details.sources-block > p {
    padding: 10px 14px;
    margin: 0;
    font-size: var(--fs-sm);
}

.message-text details.sources-block a {
    word-break: break-all;
}

/* Generation stopped */
.generation-stopped {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border-radius: var(--r-md);
    background: rgba(255, 152, 0, 0.08);
    border: 1px solid rgba(255, 152, 0, 0.2);
    color: var(--text-muted);
    font-size: var(--fs-sm);
    font-style: italic;
}

.generation-stopped svg {
    color: #ff9800;
    flex-shrink: 0;
}

/* === Error retry === */
.error-retry {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--r-md);
    background: var(--bg-alt);
    border: 1px solid var(--border-light);
}

.error-retry-text {
    font-size: var(--fs-sm);
    color: var(--text-muted);
    flex: 1;
}

.retry-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 7px 14px;
    border-radius: var(--r-full);
    font-size: var(--fs-xs);
    font-weight: 500;
    color: var(--text-secondary);
    background: var(--bg);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all var(--t-fast);
    white-space: nowrap;
    flex-shrink: 0;
}

.retry-btn:hover {
    border-color: var(--border-hover);
    color: var(--text);
    background: var(--bg-card-hover);
}

.retry-btn:active {
    transform: scale(0.96);
}

/* === User message images === */
.user-msg-images {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.user-msg-images img {
    max-width: 180px;
    max-height: 180px;
    border-radius: var(--r-sm);
    border: 1px solid var(--border-light);
    object-fit: cover;
    cursor: pointer;
    transition: transform var(--t-fast);
}

.user-msg-images img:hover {
    transform: scale(1.03);
}

/* ============================================
   CHAT AREA
   ============================================ */
.chat-area {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

/* === Welcome === */
.welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100%;
    padding: 40px 24px 120px;
    text-align: center;
    animation: welcomeIn 0.7s var(--ease);
}

.welcome.hidden {
    display: none;
}

@keyframes welcomeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Hexagon canvas */
.hex-container {
    width: 160px;
    height: 160px;
    margin-bottom: 28px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

#hexCanvas {
    width: 160px;
    height: 160px;
}

.welcome-heading {
    font-size: var(--fs-hero);
    font-weight: 600;
    color: var(--text);
    margin-bottom: 8px;
    letter-spacing: -0.03em;
}

.welcome-brand {
    background: linear-gradient(135deg, #8b5cf6, #a78bfa, #c4b5fd);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 800;
    filter: drop-shadow(0 0 20px rgba(139, 92, 246, 0.3));
}

.welcome-sub {
    font-size: var(--fs-base);
    color: var(--text-secondary);
    margin-bottom: 36px;
}

/* Suggestion pills */
.suggestions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    max-width: 600px;
}

.suggestion-pill {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 10px 20px;
    border-radius: var(--r-full);
    border: 1px solid rgba(224, 221, 216, 0.6);
    font-size: var(--fs-sm);
    font-weight: 500;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: all var(--t-mid) var(--ease);
    white-space: nowrap;
}

.suggestion-pill:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(109, 92, 255, 0.06);
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(109, 92, 255, 0.12);
}

[data-theme="dark"] .suggestion-pill {
    background: rgba(19, 18, 26, 0.7);
    border-color: rgba(34, 31, 56, 0.6);
}

[data-theme="dark"] .suggestion-pill:hover {
    background: rgba(167, 139, 250, 0.1);
    box-shadow: 0 4px 20px rgba(167, 139, 250, 0.15);
}

.suggestion-pill:active {
    transform: translateY(0);
}

@keyframes suggestIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.suggestion-pill svg {
    color: var(--accent);
    flex-shrink: 0;
}

/* === Cloud notice (local storage reminder) === */
.cloud-notice {
    margin-top: 32px;
    max-width: 440px;
    width: 100%;
    animation: cloudFloat 0.8s var(--ease) 0.5s both;
}

.cloud-notice.hidden {
    display: none;
}

@keyframes cloudFloat {
    from {
        opacity: 0;
        transform: translateY(16px) scale(0.96);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes cloudFadeOut {
    from {
        opacity: 1;
        transform: translateY(0) scale(1);
    }

    to {
        opacity: 0;
        transform: translateY(-10px) scale(0.96);
    }
}

.cloud-notice-inner {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 18px;
    border-radius: var(--r-md);
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    box-shadow:
        0 4px 24px rgba(109, 92, 255, 0.04),
        0 1px 6px rgba(0, 0, 0, 0.03);
    position: relative;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

[data-theme="dark"] .cloud-notice-inner {
    background: rgba(30, 30, 30, 0.6);
    border-color: rgba(255, 255, 255, 0.06);
    box-shadow:
        0 4px 24px rgba(139, 125, 255, 0.06),
        0 1px 6px rgba(0, 0, 0, 0.15);
}

.cloud-notice-icon {
    flex-shrink: 0;
    color: var(--accent);
    margin-top: 1px;
    opacity: 0.7;
}

.cloud-notice-text {
    font-size: var(--fs-xs);
    line-height: 1.55;
    color: var(--text-secondary);
    text-align: left;
}

.cloud-notice-text strong {
    color: var(--text);
    font-weight: 600;
}

.cloud-notice-close {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    border-radius: var(--r-xs);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: all var(--t-fast);
    cursor: pointer;
    border: none;
    background: none;
    opacity: 0.5;
}

.cloud-notice-close:hover {
    opacity: 1;
    background: var(--bg-alt);
    color: var(--text);
}

/* === Messages === */
.messages {
    padding: 20px;
    max-width: var(--chat-max-w);
    margin: 0 auto;
    width: 100%;
}

.message {
    display: flex;
    gap: 14px;
    padding: 18px 0;
    animation: msgIn 0.35s var(--ease);
}

@keyframes msgIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message + .message {
    border-top: 1px solid var(--border-light);
}

/* Avatar */
.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: var(--r-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 13px;
    font-weight: 700;
}

.message-avatar.user {
    background: linear-gradient(135deg, var(--accent), #a78bfa);
    color: white;
    border-radius: var(--r-full);
    box-shadow: 0 2px 8px rgba(109, 92, 255, 0.25);
}

.message-avatar.assistant {
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid var(--border-light);
    font-size: 16px;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

[data-theme="dark"] .message-avatar.assistant {
    background: rgba(19, 18, 26, 0.9);
    border-color: rgba(34, 31, 56, 0.6);
}

.message-content {
    flex: 1;
    min-width: 0;
    max-width: 100%;
    overflow-wrap: break-word;
    overflow-x: hidden;
}

.message-role {
    font-size: var(--fs-xs);
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.message-text {
    color: var(--text);
    line-height: 1.7;
    font-size: var(--fs-base);
    overflow-wrap: break-word;
    word-break: break-word;
    max-width: 100%;
    overflow-x: auto;
}

/* Markdown */
.message-text h1,
.message-text h2,
.message-text h3,
.message-text h4 {
    margin: 18px 0 8px;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--text);
}

.message-text h1 {
    font-size: 1.35em;
}

.message-text h2 {
    font-size: 1.2em;
}

.message-text h3 {
    font-size: 1.08em;
}

.message-text p {
    margin: 6px 0;
}

.message-text ul,
.message-text ol {
    margin: 8px 0;
    padding-left: 22px;
}

.message-text li {
    margin: 4px 0;
}

.message-text blockquote {
    margin: 12px 0;
    padding: 10px 16px;
    border-left: 3px solid var(--accent);
    background: var(--accent-bg);
    border-radius: 0 var(--r-xs) var(--r-xs) 0;
    color: var(--text-secondary);
}

.message-text a {
    color: var(--accent);
    text-decoration: underline;
    text-underline-offset: 3px;
    text-decoration-color: var(--accent-glow);
}

.message-text a:hover {
    text-decoration-color: var(--accent);
}

.message-text code:not(pre code) {
    background: var(--bg-alt);
    border: 1px solid var(--border-light);
    padding: 1px 6px;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 0.86em;
    color: var(--accent);
}

.message-text pre {
    margin: 14px 0;
    border-radius: var(--r-sm);
    overflow: hidden;
    border: 1px solid var(--border);
    background: var(--bg-code);
    max-width: 100%;
}

.code-block-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 14px;
    background: var(--bg-alt);
    border-bottom: 1px solid var(--border-light);
    font-size: var(--fs-xs);
    color: var(--text-muted);
    font-family: var(--font-mono);
}

.copy-code-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: var(--r-xs);
    font-size: var(--fs-xs);
    color: var(--text-muted);
    transition: all var(--t-fast);
    font-family: var(--font);
}

.copy-code-btn:hover {
    background: var(--bg-card-hover);
    color: var(--text);
}

.copy-code-btn.copied {
    color: var(--success);
}

.message-text pre code {
    display: block;
    padding: 16px;
    font-family: var(--font-mono);
    font-size: 0.84em;
    line-height: 1.6;
    overflow-x: auto;
    background: transparent;
}

.message-text table {
    width: 100%;
    border-collapse: collapse;
    margin: 14px 0;
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    overflow: hidden;
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.message-text th,
.message-text td {
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border-light);
    font-size: var(--fs-sm);
}

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

.message-text tr:hover td {
    background: var(--bg-card-hover);
}

.message-text hr {
    border: none;
    border-top: 1px solid var(--border-light);
    margin: 18px 0;
}

.message-text strong {
    font-weight: 600;
}

/* Message actions */
.message-actions {
    display: flex;
    gap: 4px;
    margin-top: 10px;
    opacity: 0.6;
    transition: opacity var(--t-fast);
}

.message:hover .message-actions {
    opacity: 1;
}

.msg-action-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: var(--r-xs);
    font-size: var(--fs-xs);
    color: var(--text-muted);
    transition: all var(--t-fast);
}

.msg-action-btn:hover {
    background: var(--bg-alt);
    color: var(--text);
}

/* Typing */
.typing-indicator {
    display: inline-flex;
    gap: 5px;
    padding: 4px 0;
}

.typing-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent-light);
    animation: bounce 1.4s ease-in-out infinite;
}

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

.typing-dot:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes bounce {
    0%,
    60%,
    100% {
        transform: translateY(0);
        opacity: 0.35;
    }

    30% {
        transform: translateY(-7px);
        opacity: 1;
    }
}

/* ============================================
   INPUT AREA
   ============================================ */
.input-area {
    padding: 0 20px 24px;
    flex-shrink: 0;
    position: relative;
    z-index: 10;
}

.input-box {
    max-width: var(--chat-max-w);
    margin: 0 auto;
    background: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(20px) saturate(1.3);
    -webkit-backdrop-filter: blur(20px) saturate(1.3);
    border: 1px solid rgba(224, 221, 216, 0.6);
    border-radius: var(--input-radius);
    padding: 14px 18px 10px;
    transition: all var(--t-mid) var(--ease);
    box-shadow:
        0 4px 24px rgba(0, 0, 0, 0.04),
        0 1px 6px rgba(0, 0, 0, 0.02);
}

[data-theme="dark"] .input-box {
    background: rgba(19, 18, 26, 0.8);
    border-color: rgba(34, 31, 56, 0.6);
    box-shadow:
        0 4px 24px rgba(0, 0, 0, 0.3),
        0 1px 6px rgba(139, 92, 246, 0.04);
}

.input-box:focus-within {
    border-color: var(--accent);
    box-shadow:
        0 0 0 3px var(--accent-glow),
        0 8px 32px rgba(139, 92, 246, 0.1);
    background: rgba(255, 255, 255, 0.9);
}

[data-theme="dark"] .input-box:focus-within {
    background: rgba(19, 18, 26, 0.95);
    box-shadow:
        0 0 0 3px rgba(167, 139, 250, 0.2),
        0 8px 32px rgba(139, 92, 246, 0.12);
}

.input-textarea {
    width: 100%;
    border: none;
    outline: none;
    background: transparent;
    color: var(--text);
    font-size: var(--fs-base);
    line-height: 1.5;
    max-height: 160px;
    min-height: 24px;
    padding: 0;
    scrollbar-width: thin;
}

.input-textarea::placeholder {
    color: var(--text-muted);
}

.input-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 8px;
    padding-top: 4px;
}

.input-toolbar-left {
    display: flex;
    align-items: center;
    gap: 6px;
}

.input-model-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: var(--r-full);
    background: var(--bg-alt);
    font-size: var(--fs-xs);
    color: var(--text-muted);
    font-weight: 500;
    border: 1px solid var(--border-light);
}

.input-send {
    width: 36px;
    height: 36px;
    border-radius: var(--r-full);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--text-faint);
    color: var(--bg);
    transition: all var(--t-mid) var(--ease);
}

.input-send:not(:disabled) {
    background: linear-gradient(135deg, var(--accent), var(--accent-light));
    color: white;
    box-shadow: 0 2px 10px rgba(109, 92, 255, 0.3);
}

.input-send:not(:disabled):hover {
    transform: scale(1.08) translateY(-1px);
    box-shadow: 0 4px 16px rgba(109, 92, 255, 0.4);
}

.input-send:not(:disabled):active {
    transform: scale(0.95);
    box-shadow: 0 1px 6px rgba(109, 92, 255, 0.3);
}

.input-send .hidden {
    display: none;
}

.input-send.streaming .send-icon {
    display: none;
}

.input-send.streaming .stop-icon {
    display: block !important;
}

/* ============================================
   TOASTS
   ============================================ */
.toast-container {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 18px;
    border-radius: var(--r-sm);
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(16px) saturate(1.3);
    -webkit-backdrop-filter: blur(16px) saturate(1.3);
    border: 1px solid rgba(224, 221, 216, 0.5);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    font-size: var(--fs-sm);
    color: var(--text);
    animation: toastIn 0.3s var(--ease);
    max-width: 350px;
    pointer-events: auto;
}

[data-theme="dark"] .toast {
    background: rgba(19, 18, 26, 0.9);
    border-color: rgba(34, 31, 56, 0.5);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.toast.removing {
    animation: toastOut 0.25s var(--ease) forwards;
}

.toast-icon {
    font-size: 16px;
    flex-shrink: 0;
}

.toast.error {
    border-color: rgba(239, 68, 68, 0.2);
}

.toast.success {
    border-color: rgba(16, 185, 129, 0.2);
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(30px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes toastOut {
    to {
        opacity: 0;
        transform: translateX(30px);
    }
}

/* ============================================
   RESPONSIVE — MOBILE-FIRST PREMIUM
   Performance: no backdrop-filter on mobile (GPU lag killer)
   ============================================ */

@media (max-width: 900px) {
    .model-dropdown { min-width: 280px; }
}

@media (max-width: 600px) {
    :root {
        --topbar-h: 50px;
        --input-radius: 20px;
        --chat-max-w: 100%;
        --fs-hero: 1.5rem;
    }

    /* PERFORMANCE: Kill ALL blur/backdrop on mobile */
    .sidebar, .topbar, .input-box, .model-pill, .model-dropdown,
    .settings-drawer, .sidebar-overlay, .settings-overlay, .toast,
    .suggestion-pill, .cloud-notice-inner, .message-avatar.assistant {
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
    }

    .orb { filter: blur(60px); opacity: 0.2; }
    [data-theme="dark"] .orb { opacity: 0.15; }
    [data-theme="dark"] .ambient-bg::after { display: none; }

    /* Topbar */
    .topbar {
        padding: 0 10px; gap: 4px;
        background: var(--bg); border-bottom: 1px solid var(--border-light);
    }
    [data-theme="dark"] .topbar { background: var(--bg); border-bottom-color: var(--border); }
    .topbar-sidebar-toggle { width: 42px; height: 42px; }
    .topbar-icon-btn { width: 38px; height: 38px; margin-left: 2px; }

    /* Hex logo mobile */
    .hex-logo-wrap { margin-left: 2px; }
    .hex-logo-icon { width: 18px; height: 18px; }
    .hex-logo-tooltip { right: -10px; font-size: 10px; padding: 8px 12px; }
    .hex-logo-tooltip::before { right: 18px; }

    /* Model pill */
    .model-pill {
        padding: 6px 10px 6px 8px; font-size: var(--fs-xs); gap: 4px;
        background: var(--bg-card);
    }
    [data-theme="dark"] .model-pill { background: var(--bg-card); }
    .model-pill-icon { font-size: 13px; }
    .model-pill-name { max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .model-pill-arrow { width: 12px; height: 12px; }

    /* Model dropdown — BOTTOM SHEET */
    .model-dropdown {
        position: fixed; top: auto; bottom: 0; left: 0; right: 0;
        min-width: 100%; border-radius: 20px 20px 0 0;
        max-height: 75vh; overflow-y: auto;
        transform: translateY(100%); opacity: 0;
        background: var(--bg-card); border: none;
        border-top: 1px solid var(--border);
        box-shadow: 0 -8px 40px rgba(0,0,0,0.2);
        padding-bottom: env(safe-area-inset-bottom, 16px);
    }
    [data-theme="dark"] .model-dropdown {
        background: var(--bg-card);
        box-shadow: 0 -8px 40px rgba(0,0,0,0.5), 0 -2px 20px rgba(139,92,246,0.06);
    }
    .model-dropdown::before {
        content: ""; display: block; width: 36px; height: 4px;
        background: var(--text-faint); border-radius: 4px; margin: 12px auto 8px;
    }
    .model-selector.open .model-dropdown { transform: translateY(0); opacity: 1; }
    .model-dropdown-item { padding: 16px 18px; gap: 14px; min-height: 60px; }
    .model-dropdown-item:active { background: var(--accent-bg); }
    .model-dropdown-icon { width: 44px; height: 44px; font-size: 22px; }
    .model-dropdown-name { font-size: var(--fs-base); font-weight: 600; }
    .model-dropdown-desc { font-size: var(--fs-sm); line-height: 1.4; }

    /* Welcome */
    .welcome { padding: 24px 20px 100px; }
    .hex-container { width: 90px; height: 90px; margin-bottom: 16px; }
    #hexCanvas { width: 90px; height: 90px; }
    .welcome-heading { font-size: var(--fs-hero); margin-bottom: 6px; }
    .welcome-sub { font-size: var(--fs-sm); margin-bottom: 28px; padding: 0 12px; }
    .suggestions { gap: 8px; padding: 0 8px; width: 100%; }
    .suggestion-pill {
        padding: 12px 18px; font-size: var(--fs-xs);
        border-radius: var(--r-md); background: var(--bg-card);
        flex: 1 1 auto; min-width: 0; justify-content: center;
    }
    [data-theme="dark"] .suggestion-pill { background: var(--bg-card); }
    .suggestion-pill:active { transform: scale(0.96); }
    .cloud-notice { margin-top: 20px; max-width: 100%; }
    .cloud-notice-inner { padding: 12px 14px; gap: 10px; }

    /* Messages */
    .messages { padding: 10px 14px; }
    .message { gap: 10px; padding: 14px 0; overflow: hidden; }
    .user-msg-images img { max-width: 140px; max-height: 140px; }
    .message-avatar { width: 30px; height: 30px; font-size: 12px; flex-shrink: 0; }
    .message-content { max-width: calc(100vw - 68px); overflow-x: hidden; min-width: 0; }
    .message-role { font-size: 10px; }
    .message-text { font-size: var(--fs-sm); line-height: 1.65; overflow-wrap: break-word; word-break: break-word; }
    .message-text h1 { font-size: 1.2em; }
    .message-text h2 { font-size: 1.1em; }
    .message-text h3 { font-size: 1.05em; }
    .message-text pre { margin: 8px 0; max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .message-text pre code { font-size: 0.78em; padding: 14px; white-space: pre; display: block; overflow-x: auto; }
    .code-block-header { padding: 6px 12px; font-size: 10px; }
    .message-text table { font-size: var(--fs-xs); display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
    .message-text th, .message-text td { padding: 8px 10px; white-space: nowrap; }
    .message-text blockquote { padding: 10px 14px; margin: 8px 0; }
    .message-text code:not(pre code) { word-break: break-all; font-size: 0.84em; }
    .message-text img { border-radius: var(--r-sm); max-width: 100%; }
    .message-actions { opacity: 1; margin-top: 8px; }
    .msg-action-btn { padding: 6px 12px; min-height: 32px; }

    /* Input area */
    .input-area { padding: 0 10px calc(env(safe-area-inset-bottom, 8px) + 10px); }
    .input-box {
        padding: 12px 14px 10px; border-radius: var(--input-radius);
        background: var(--bg-card); box-shadow: 0 -4px 20px rgba(0,0,0,0.06);
    }
    [data-theme="dark"] .input-box { background: var(--bg-card); box-shadow: 0 -4px 20px rgba(0,0,0,0.2); }
    .input-box:focus-within {
        background: var(--bg-card);
        box-shadow: 0 0 0 2px var(--accent-glow), 0 -4px 20px rgba(0,0,0,0.06);
    }
    [data-theme="dark"] .input-box:focus-within {
        box-shadow: 0 0 0 2px rgba(167,139,250,0.2), 0 -4px 20px rgba(0,0,0,0.2);
    }
    .input-textarea { font-size: 16px; min-height: 24px; }
    .input-toolbar { margin-top: 8px; }
    .input-toolbar-left { gap: 4px; flex-wrap: wrap; }
    .input-model-tag { padding: 4px 10px; font-size: 10px; }
    .input-opt-pill { padding: 4px 10px; font-size: 10px; }
    .input-send { width: 38px; height: 38px; flex-shrink: 0; }

    /* Media loader */
    .media-loader { padding: 18px; gap: 12px; flex-direction: column; text-align: center; }
    .media-loader-icon-wrap { width: 48px; height: 48px; }
    .media-loader-info { align-items: center; }
    .media-loader-model { font-size: var(--fs-sm); }
    .media-loader-warning { font-size: 10px; }

    /* Settings — full screen */
    .settings-drawer { width: 100%; max-width: 100%; background: var(--bg); }
    [data-theme="dark"] .settings-drawer { background: var(--bg); }
    .settings-header { padding: 16px 18px; }
    .settings-body { padding: 16px 18px; }
    .pill-group { gap: 3px; }
    .pill-option { padding: 6px 14px; font-size: 11px; min-height: 32px; }

    /* Sidebar */
    .sidebar { width: 280px; background: var(--bg-sidebar); }
    [data-theme="dark"] .sidebar { background: var(--bg-sidebar); }
    .sidebar-overlay { background: rgba(0,0,0,0.4); }
    .sidebar-new-chat { padding: 13px 16px; }
    .chat-item { padding: 11px 12px; min-height: 42px; }

    /* Toasts */
    .toast-container { right: 8px; left: 8px; top: auto; bottom: calc(env(safe-area-inset-bottom, 8px) + 70px); }
    .toast { max-width: 100%; background: var(--bg-card); border-radius: var(--r-md); }
    [data-theme="dark"] .toast { background: var(--bg-card); }

    /* Banner */
    .tg-banner { font-size: var(--fs-xs); padding: 10px 36px 10px 12px; }

    /* Attach */
    .attach-preview { padding: 6px 10px; }
    .attach-thumb { width: 56px; height: 56px; }

    /* Captcha */
    .captcha-modal-content { padding: 24px; width: 92%; }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* Print */
@media print {
    .sidebar,
    .topbar,
    .input-area,
    .sidebar-overlay,
    .toast-container,
    .message-actions,
    .welcome,
    .ambient-bg {
        display: none !important;
    }

    body {
        background: white;
        color: black;
    }

    .main {
        height: auto;
        overflow: visible;
    }

    .chat-area {
        overflow: visible;
    }
}

/* ============================================
   hCAPTCHA MODAL
   ============================================ */
.captcha-modal {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.captcha-modal.visible {
    opacity: 1;
    pointer-events: auto;
}

.captcha-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.captcha-modal-content {
    position: relative;
    background: var(--card-bg, #fff);
    border-radius: 16px;
    padding: 32px;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.captcha-modal-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary, #1a1a1a);
}

.captcha-modal-desc {
    font-size: 13px;
    color: var(--text-secondary, #666);
    line-height: 1.4;
}

#captchaContainer {
    min-height: 78px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.captcha-modal-cancel {
    background: none;
    border: 1px solid var(--border-color, #e0e0e0);
    border-radius: 8px;
    padding: 8px 24px;
    font-size: 13px;
    color: var(--text-secondary, #666);
    cursor: pointer;
    transition: background 0.15s;
}

.captcha-modal-cancel:hover {
    background: var(--hover-bg, #f5f5f5);
}

/* ============================================
   HEX LOGO WITH TOOLTIP
   ============================================ */
.hex-logo-wrap {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 6px;
    cursor: pointer;
}

.hex-logo-wrap.hidden {
    display: none;
}

.hex-logo-icon {
    transition: all var(--t-mid) var(--ease);
    filter: drop-shadow(0 0 4px rgba(139, 92, 246, 0.3));
}

.hex-logo-wrap:hover .hex-logo-icon {
    transform: scale(1.15) rotate(15deg);
    filter: drop-shadow(0 0 12px rgba(139, 92, 246, 0.6));
}

.hex-logo-tooltip {
    position: absolute;
    top: calc(100% + 10px);
    right: -20px;
    background: rgba(19, 18, 26, 0.96);
    backdrop-filter: blur(20px) saturate(1.5);
    -webkit-backdrop-filter: blur(20px) saturate(1.5);
    border: 1px solid rgba(139, 92, 246, 0.25);
    border-radius: var(--r-sm);
    padding: 10px 16px;
    font-size: var(--fs-xs);
    font-weight: 500;
    color: #c4b5fd;
    white-space: nowrap;
    opacity: 0;
    transform: translateY(-4px);
    pointer-events: none;
    transition: all var(--t-mid) var(--ease);
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.3),
        0 0 20px rgba(139, 92, 246, 0.1);
    z-index: 300;
}

.hex-logo-tooltip::before {
    content: "";
    position: absolute;
    top: -5px;
    right: 28px;
    width: 10px;
    height: 10px;
    background: rgba(19, 18, 26, 0.96);
    border-left: 1px solid rgba(139, 92, 246, 0.25);
    border-top: 1px solid rgba(139, 92, 246, 0.25);
    transform: rotate(45deg);
}

.hex-logo-tooltip a {
    color: #a78bfa;
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.hex-logo-tooltip a:hover {
    color: #c4b5fd;
}

.hex-logo-wrap:hover .hex-logo-tooltip {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

/* Light theme tooltip */
:root:not([data-theme="dark"]) .hex-logo-tooltip {
    background: rgba(255, 255, 255, 0.96);
    border-color: rgba(139, 92, 246, 0.2);
    color: #6d28d9;
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.1),
        0 0 20px rgba(139, 92, 246, 0.06);
}

:root:not([data-theme="dark"]) .hex-logo-tooltip::before {
    background: rgba(255, 255, 255, 0.96);
    border-color: rgba(139, 92, 246, 0.2);
}

:root:not([data-theme="dark"]) .hex-logo-tooltip a {
    color: #7c3aed;
}

/* ============================================
   NEON GLOW EFFECTS & PREMIUM ADDITIONS
   ============================================ */

/* Neon pulse on welcome heading */
[data-theme="dark"] .welcome-brand {
    animation: neonTextPulse 3s ease-in-out infinite alternate;
}

@keyframes neonTextPulse {
    0% {
        filter: drop-shadow(0 0 15px rgba(139, 92, 246, 0.3));
    }
    100% {
        filter: drop-shadow(0 0 30px rgba(167, 139, 250, 0.5));
    }
}

/* Active model dropdown item neon bar */
[data-theme="dark"] .model-dropdown-item.active {
    background: rgba(167, 139, 250, 0.08);
    border-left: 3px solid #a78bfa;
    box-shadow: inset 3px 0 12px rgba(139, 92, 246, 0.1);
}

/* Neon glow on send button */
[data-theme="dark"] .input-send:not(:disabled) {
    background: linear-gradient(135deg, #8b5cf6, #a78bfa);
    box-shadow:
        0 2px 12px rgba(139, 92, 246, 0.4),
        0 0 20px rgba(139, 92, 246, 0.15);
}

[data-theme="dark"] .input-send:not(:disabled):hover {
    box-shadow:
        0 4px 20px rgba(139, 92, 246, 0.5),
        0 0 30px rgba(139, 92, 246, 0.2);
}

/* Premium chat item active indicator */
[data-theme="dark"] .chat-item.active {
    background: linear-gradient(
        135deg,
        rgba(139, 92, 246, 0.1),
        rgba(167, 139, 250, 0.05)
    );
    border-left-color: #a78bfa;
    box-shadow: inset 3px 0 10px rgba(139, 92, 246, 0.08);
}

/* Subtle scan-line overlay on dark theme */
[data-theme="dark"] .ambient-bg::after {
    content: "";
    position: absolute;
    inset: 0;
    background:
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 2px,
            rgba(139, 92, 246, 0.008) 2px,
            rgba(139, 92, 246, 0.008) 4px
        );
    pointer-events: none;
    z-index: 1;
}

/* Model dropdown icon glow on dark */
[data-theme="dark"] .model-dropdown-icon {
    background: rgba(139, 92, 246, 0.08);
    border: 1px solid rgba(139, 92, 246, 0.1);
}

/* Cloud notice dark theme */
[data-theme="dark"] .cloud-notice-inner {
    background: rgba(19, 18, 26, 0.7);
    border-color: rgba(34, 31, 56, 0.6);
    box-shadow:
        0 4px 24px rgba(139, 92, 246, 0.04),
        0 1px 6px rgba(0, 0, 0, 0.2);
}

/* Premium scrollbar on dark */
[data-theme="dark"] ::-webkit-scrollbar-thumb {
    background: rgba(139, 92, 246, 0.2);
}

[data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
    background: rgba(139, 92, 246, 0.35);
}

/* User avatar neon glow */
[data-theme="dark"] .message-avatar.user {
    background: linear-gradient(135deg, #8b5cf6, #a78bfa);
    box-shadow: 0 2px 12px rgba(139, 92, 246, 0.35);
}

/* ============================================
   NANO BANANA 2 — 4x (FEATURED MODEL)
   ============================================ */

/* Featured dropdown item — animated gradient border + glow */
.model-dropdown-item.featured {
    position: relative;
    background: linear-gradient(135deg,
        rgba(255, 213, 79, 0.10) 0%,
        rgba(255, 138, 76, 0.08) 50%,
        rgba(167, 139, 250, 0.10) 100%);
    border-left: 3px solid transparent;
    border-image: linear-gradient(180deg, #ffd54f, #ff8a4c, #a78bfa) 1;
    overflow: hidden;
    isolation: isolate;
}

.model-dropdown-item.featured::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(120deg,
        transparent 0%,
        rgba(255, 213, 79, 0.18) 35%,
        rgba(255, 255, 255, 0.35) 50%,
        rgba(167, 139, 250, 0.18) 65%,
        transparent 100%);
    transform: translateX(-100%);
    animation: featuredShine 4.2s ease-in-out infinite;
    pointer-events: none;
    z-index: 0;
}

.model-dropdown-item.featured > * {
    position: relative;
    z-index: 1;
}

.model-dropdown-item.featured:hover {
    background: linear-gradient(135deg,
        rgba(255, 213, 79, 0.16) 0%,
        rgba(255, 138, 76, 0.14) 50%,
        rgba(167, 139, 250, 0.16) 100%);
}

.model-dropdown-item.featured .model-dropdown-icon {
    background: linear-gradient(135deg, #ffe082 0%, #ff8a4c 60%, #a78bfa 100%);
    color: #fff;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
    box-shadow:
        0 4px 14px rgba(255, 138, 76, 0.35),
        0 0 0 1px rgba(255, 213, 79, 0.45) inset;
    animation: featuredIconBob 3.6s ease-in-out infinite;
}

.model-dropdown-item.featured .model-dropdown-name {
    background: linear-gradient(90deg, #d97706 0%, #b45309 35%, #7c3aed 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

[data-theme="dark"] .model-dropdown-item.featured .model-dropdown-name {
    background: linear-gradient(90deg, #fcd34d 0%, #fb923c 40%, #c4b5fd 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.model-badge-new {
    display: inline-block;
    padding: 2px 8px;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.5px;
    color: #fff;
    background: linear-gradient(90deg, #ff8a4c, #a78bfa);
    border-radius: 999px;
    box-shadow: 0 2px 6px rgba(255, 138, 76, 0.45);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
    -webkit-text-fill-color: #fff;
    animation: badgePulse 2s ease-in-out infinite;
    white-space: nowrap;
}

.model-featured-glow {
    position: absolute;
    inset: -1px;
    border-radius: inherit;
    pointer-events: none;
    background: radial-gradient(120% 60% at 0% 50%,
        rgba(255, 213, 79, 0.18) 0%,
        transparent 60%),
        radial-gradient(120% 60% at 100% 50%,
        rgba(167, 139, 250, 0.18) 0%,
        transparent 60%);
    z-index: 0;
}

@keyframes featuredShine {
    0%, 100% { transform: translateX(-110%); }
    50% { transform: translateX(110%); }
}

@keyframes featuredIconBob {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-2px) rotate(-4deg); }
}

@keyframes badgePulse {
    0%, 100% { box-shadow: 0 2px 6px rgba(255, 138, 76, 0.45); }
    50% { box-shadow: 0 2px 14px rgba(167, 139, 250, 0.6); }
}

/* Sidebar bottom badge — same gradient when 4x is active */
.sidebar-model-badge[data-featured="1"] {
    background: linear-gradient(90deg,
        rgba(255, 213, 79, 0.18),
        rgba(255, 138, 76, 0.16),
        rgba(167, 139, 250, 0.18));
    color: #d97706;
    border: 1px solid rgba(255, 138, 76, 0.35);
    font-weight: 700;
}

[data-theme="dark"] .sidebar-model-badge[data-featured="1"] {
    color: #fcd34d;
    border-color: rgba(252, 211, 77, 0.4);
}

/* Topbar pill — featured state */
.model-pill[data-featured="1"] {
    background: linear-gradient(135deg,
        rgba(255, 213, 79, 0.16),
        rgba(255, 138, 76, 0.14),
        rgba(167, 139, 250, 0.16));
    border-color: rgba(255, 138, 76, 0.4);
    box-shadow: 0 4px 16px rgba(255, 138, 76, 0.18);
}

.model-pill[data-featured="1"] .model-pill-name {
    background: linear-gradient(90deg, #d97706, #7c3aed);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    font-weight: 700;
}

[data-theme="dark"] .model-pill[data-featured="1"] .model-pill-name {
    background: linear-gradient(90deg, #fcd34d, #c4b5fd);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

/* Input model tag — featured state */
.input-model-tag[data-featured="1"] {
    background: linear-gradient(135deg,
        rgba(255, 213, 79, 0.18),
        rgba(167, 139, 250, 0.18));
    border: 1px solid rgba(255, 138, 76, 0.32);
    box-shadow: 0 2px 8px rgba(255, 138, 76, 0.14);
}

/* ============================================
   NANO BANANA 4x — RESULT GRID
   ============================================ */
.nb4x-result {
    position: relative;
    margin: 4px 0;
    padding: 16px;
    border-radius: 18px;
    background: linear-gradient(135deg,
        rgba(255, 213, 79, 0.08) 0%,
        rgba(255, 255, 255, 0.4) 30%,
        rgba(167, 139, 250, 0.08) 100%);
    border: 1px solid rgba(255, 138, 76, 0.18);
    box-shadow:
        0 10px 40px -8px rgba(255, 138, 76, 0.18),
        0 2px 10px rgba(0, 0, 0, 0.04);
    overflow: hidden;
}

.nb4x-result::before {
    content: "";
    position: absolute;
    inset: -2px;
    border-radius: inherit;
    padding: 2px;
    background: linear-gradient(135deg, #ffd54f, #ff8a4c, #a78bfa);
    -webkit-mask:
        linear-gradient(#000 0 0) content-box,
        linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
            mask-composite: exclude;
    opacity: 0.4;
    pointer-events: none;
}

[data-theme="dark"] .nb4x-result {
    background: linear-gradient(135deg,
        rgba(255, 213, 79, 0.06) 0%,
        rgba(19, 18, 26, 0.85) 30%,
        rgba(167, 139, 250, 0.08) 100%);
    border-color: rgba(252, 211, 77, 0.22);
    box-shadow:
        0 10px 40px -8px rgba(167, 139, 250, 0.28),
        0 2px 10px rgba(0, 0, 0, 0.3);
}

.nb4x-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 6px;
    flex-wrap: wrap;
}

.nb4x-title {
    font-size: 14px;
    font-weight: 800;
    letter-spacing: 0.2px;
    background: linear-gradient(90deg, #d97706, #b45309 40%, #7c3aed);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

[data-theme="dark"] .nb4x-title {
    background: linear-gradient(90deg, #fcd34d, #fb923c 40%, #c4b5fd);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.nb4x-meta {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    padding: 3px 8px;
    border-radius: 999px;
    background: rgba(167, 139, 250, 0.10);
    border: 1px solid rgba(167, 139, 250, 0.2);
    white-space: nowrap;
}

.nb4x-prompt {
    margin: 4px 0 14px;
    padding: 10px 12px;
    font-size: 12.5px;
    line-height: 1.5;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.5);
    border-radius: 10px;
    border: 1px solid rgba(255, 138, 76, 0.14);
    font-style: italic;
}

[data-theme="dark"] .nb4x-prompt {
    background: rgba(0, 0, 0, 0.25);
    border-color: rgba(252, 211, 77, 0.14);
}

.nb4x-grid {
    display: grid;
    gap: 8px;
}

.nb4x-grid-1 { grid-template-columns: 1fr; }
.nb4x-grid-2 { grid-template-columns: 1fr 1fr; }
.nb4x-grid-3 { grid-template-columns: 1fr 1fr 1fr; }
.nb4x-grid-4 { grid-template-columns: 1fr 1fr; }

.nb4x-cell {
    position: relative;
    display: block;
    aspect-ratio: 1 / 1;
    border-radius: 12px;
    overflow: hidden;
    cursor: zoom-in;
    background: rgba(167, 139, 250, 0.08);
    border: 1px solid rgba(255, 138, 76, 0.18);
    transition: transform 0.25s var(--ease, ease), box-shadow 0.25s var(--ease, ease);
}

.nb4x-cell:hover {
    transform: translateY(-2px) scale(1.01);
    box-shadow:
        0 12px 28px -8px rgba(255, 138, 76, 0.35),
        0 0 0 2px rgba(167, 139, 250, 0.35);
    z-index: 2;
}

.nb4x-cell img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.5s var(--ease, ease);
}

.nb4x-cell:hover img {
    transform: scale(1.04);
}

.nb4x-cell-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 800;
    color: #fff;
    background: linear-gradient(135deg, #ff8a4c, #a78bfa);
    box-shadow:
        0 2px 8px rgba(0, 0, 0, 0.35),
        0 0 0 1.5px rgba(255, 255, 255, 0.5) inset;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    pointer-events: none;
}

.nb4x-links {
    display: flex;
    gap: 6px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.nb4x-dl {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    font-size: 11.5px;
    font-weight: 700;
    text-decoration: none !important;
    color: var(--accent, #6d5cff);
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(255, 138, 76, 0.25);
    border-radius: 999px;
    transition: all 0.2s var(--ease, ease);
}

.nb4x-dl:hover {
    background: linear-gradient(90deg, rgba(255, 138, 76, 0.18), rgba(167, 139, 250, 0.18));
    border-color: rgba(255, 138, 76, 0.5);
    transform: translateY(-1px);
}

[data-theme="dark"] .nb4x-dl {
    background: rgba(0, 0, 0, 0.3);
    color: #fcd34d;
    border-color: rgba(252, 211, 77, 0.25);
}

[data-theme="dark"] .nb4x-dl:hover {
    background: linear-gradient(90deg, rgba(252, 211, 77, 0.18), rgba(167, 139, 250, 0.18));
}

/* Mobile tweaks */
@media (max-width: 720px) {
    .nb4x-result { padding: 12px; border-radius: 14px; }
    .nb4x-grid { gap: 6px; }
    .nb4x-cell { border-radius: 10px; }
    .nb4x-cell-badge { width: 20px; height: 20px; font-size: 10px; top: 6px; left: 6px; }
    .nb4x-prompt { font-size: 11.5px; padding: 8px 10px; }
    .nb4x-title { font-size: 13px; }
    .nb4x-meta { font-size: 10px; }
    .model-badge-new { font-size: 9px; padding: 2px 6px; }
}

/* ============================================
   BYOK — API Connection Panel
   ============================================ */
.byok-section {
    border-top: 1px solid var(--border-light);
    padding-top: 16px;
    margin-top: 8px;
}

.byok-section-title {
    font-size: var(--fs-sm);
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.byok-field {
    margin-bottom: 12px;
}

.byok-field label {
    display: block;
    font-size: var(--fs-xs);
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.byok-input {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    padding: 10px 12px;
    font-size: var(--fs-sm);
    font-family: var(--font-mono);
    color: var(--text);
    transition: border-color var(--t-fast), box-shadow var(--t-fast);
    -webkit-appearance: none;
}

.byok-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-bg);
}

.byok-input::placeholder {
    color: var(--text-muted);
    font-family: var(--font);
}

.byok-hint {
    font-size: var(--fs-xs);
    color: var(--text-muted);
    margin-top: 4px;
    line-height: 1.4;
}

.byok-btn {
    width: 100%;
    background: linear-gradient(135deg, var(--accent), var(--accent-light));
    color: #fff;
    border: none;
    border-radius: var(--r-sm);
    padding: 11px 16px;
    font-size: var(--fs-sm);
    font-weight: 600;
    cursor: pointer;
    transition: transform var(--t-fast), box-shadow var(--t-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.byok-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px var(--accent-glow);
}

.byok-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.byok-btn.secondary {
    background: var(--bg-card-hover);
    color: var(--text);
    border: 1px solid var(--border);
}

.byok-status {
    font-size: var(--fs-xs);
    padding: 8px 12px;
    border-radius: var(--r-sm);
    margin-top: 8px;
    display: none;
}

.byok-status.visible { display: block; }
.byok-status.success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}
.byok-status.error {
    background: rgba(239, 68, 68, 0.1);
    color: var(--error);
}

/* Model dropdown — динамические модели */
.model-dropdown {
    max-height: 420px;
    overflow-y: auto;
}

.model-dropdown-search {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-light);
    position: sticky;
    top: 0;
    background: var(--bg-card);
    z-index: 1;
}

.model-dropdown-search input {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--r-xs);
    padding: 7px 10px;
    font-size: var(--fs-xs);
    color: var(--text);
    -webkit-appearance: none;
}

.model-dropdown-search input:focus {
    outline: none;
    border-color: var(--accent);
}

/* Reasoning control */
.reasoning-group {
    display: flex;
    gap: 4px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    padding: 3px;
}

.reasoning-pill {
    flex: 1;
    padding: 7px 4px;
    font-size: var(--fs-xs);
    font-weight: 500;
    color: var(--text-muted);
    border-radius: var(--r-xs);
    cursor: pointer;
    text-align: center;
    transition: all var(--t-fast);
    border: none;
    background: none;
}

.reasoning-pill.active {
    background: var(--accent);
    color: #fff;
}

/* Tool calls display */
.tool-call-block {
    background: var(--bg-code);
    border: 1px solid var(--border-light);
    border-radius: var(--r-sm);
    margin: 8px 0;
    overflow: hidden;
}

.tool-call-header {
    padding: 8px 12px;
    background: var(--bg-card-hover);
    font-size: var(--fs-xs);
    font-weight: 600;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}

.tool-call-body {
    padding: 10px 12px;
    font-family: var(--font-mono);
    font-size: var(--fs-xs);
    color: var(--text-secondary);
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 200px;
    overflow-y: auto;
}

.tool-call-body.collapsed { display: none; }

/* API connection badge в топбаре */
.api-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-faint);
    display: inline-block;
    margin-right: 2px;
}
.api-status-dot.connected { background: var(--success); }
.api-status-dot.disconnected { background: var(--error); }

/* Empty API state */
.api-empty-banner {
    position: fixed;
    bottom: 90px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-card);
    border: 1px solid var(--accent);
    border-radius: var(--r-lg);
    padding: 14px 22px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 12px;
    max-width: calc(100vw - 32px);
}

.api-empty-banner-text {
    font-size: var(--fs-sm);
    color: var(--text);
}

.api-empty-banner-btn {
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--r-xs);
    padding: 8px 14px;
    font-size: var(--fs-xs);
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}

/* Model selector custom input (для ручного ввода ID) */
.model-custom-input-wrap {
    padding: 10px 12px;
    border-top: 1px solid var(--border-light);
    background: var(--bg-card);
}

.model-custom-input-wrap input {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--r-xs);
    padding: 8px 10px;
    font-size: var(--fs-xs);
    font-family: var(--font-mono);
    color: var(--text);
    -webkit-appearance: none;
}

.model-custom-input-wrap input:focus {
    outline: none;
    border-color: var(--accent);
}

/* ============================================
   MOBILE-FIRST OVERRIDES
   ============================================ */
@media (max-width: 768px) {
    .settings-body {
        padding: 16px;
    }

    .byok-section {
        padding-top: 14px;
    }

    .byok-input {
        font-size: 16px; /* предотвращает зум на iOS */
        padding: 12px 14px;
    }

    .byok-btn {
        padding: 13px 16px;
        font-size: var(--fs-base);
    }

    .reasoning-pill {
        padding: 9px 4px;
        font-size: var(--fs-sm);
    }

    .model-dropdown {
        max-height: 60vh;
    }

    .model-dropdown-search input {
        font-size: 16px; /* iOS no-zoom */
        padding: 9px 12px;
    }

    .model-custom-input-wrap input {
        font-size: 16px;
    }

    .settings-drawer {
        width: 100%;
        max-width: 100%;
    }

    .topbar {
        padding: 0 8px;
    }

    .model-pill-name {
        max-width: 120px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .input-box {
        padding: 6px;
    }

    .input-textarea {
        font-size: 16px !important; /* iOS no-zoom */
    }
}

@media (max-width: 420px) {
    .model-pill-name {
        max-width: 90px;
    }

    .settings-row {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .pill-group {
        justify-content: stretch;
    }

    .pill-option {
        flex: 1;
        text-align: center;
    }
}

/* ============================================
   THINKING / REASONING BLOCK
   ============================================ */
.thinking-block {
    margin: 8px 0;
    border: 1px solid var(--border-light);
    border-radius: var(--r-sm);
    background: var(--bg-code);
    overflow: hidden;
}

.thinking-summary {
    padding: 8px 12px;
    font-size: var(--fs-xs);
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 6px;
    list-style: none;
}

.thinking-summary::-webkit-details-marker { display: none; }
.thinking-summary::before {
    content: "▶";
    font-size: 9px;
    transition: transform var(--t-fast);
    color: var(--text-muted);
}
.thinking-block[open] .thinking-summary::before {
    transform: rotate(90deg);
}

.thinking-body {
    padding: 10px 12px;
    font-family: var(--font-mono);
    font-size: var(--fs-xs);
    line-height: 1.6;
    color: var(--text-muted);
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 400px;
    overflow-y: auto;
    border-top: 1px solid var(--border-light);
}

[data-theme="dark"] .thinking-block {
    border-color: rgba(139, 92, 246, 0.15);
    background: rgba(139, 92, 246, 0.03);
}
[data-theme="dark"] .thinking-summary {
    color: #a78bfa;
}
[data-theme="dark"] .thinking-body {
    color: #8a84a0;
    border-top-color: rgba(139, 92, 246, 0.1);
}


