/* ============================================
   QUANTUM AI — Premium Chat Interface
   Created by Protkarsh
   ============================================ */

/* === CSS Variables / Design Tokens === */
:root {
    --bg-primary: #0A0A0A;
    --bg-secondary: #111111;
    --bg-tertiary: #181818;
    --bg-card: rgba(24, 24, 24, 0.75);
    --bg-card-hover: rgba(32, 32, 32, 0.85);
    --bg-glass: rgba(255, 255, 255, 0.04);
    --bg-glass-hover: rgba(255, 255, 255, 0.08);

    --border-primary: rgba(255, 255, 255, 0.08);
    --border-secondary: rgba(255, 255, 255, 0.12);
    --border-accent: rgba(59, 130, 246, 0.25);

    --text-primary: #FFFFFF;
    --text-secondary: #A1A1AA;
    --text-tertiary: #71717A;
    --text-inverse: #0A0A0A;

    --accent-primary: #3B82F6;
    --accent-secondary: #2563EB;
    --accent-gradient: linear-gradient(135deg, #3B82F6 0%, #2563EB 100%);
    --accent-gradient-hover: linear-gradient(135deg, #60A5FA 0%, #3B82F6 100%);
    --accent-glow: rgba(59, 130, 246, 0.15);
    --accent-glow-cyan: rgba(37, 99, 235, 0.12);

    --danger: #ef4444;
    --success: #22C55E;
    --warning: #f59e0b;

    --font-primary: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-full: 9999px;

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 24px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 48px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 30px var(--accent-glow);

    --transition-fast: 150ms ease;
    --transition-base: 250ms ease;
    --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);

    --sidebar-width: 280px;
    --content-max: 820px;
    --topbar-height: 60px;
}

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

html {
    height: 100%;
    height: 100dvh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow: hidden;
    overscroll-behavior-y: none;
}

body {
    font-family: var(--font-primary);
    background: var(--bg-primary);
    color: var(--text-primary);
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    overflow-x: hidden;
    line-height: 1.6;
    width: 100%;
    -webkit-text-size-adjust: 100%;
    overscroll-behavior-y: none;
}

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

a:hover {
    color: #3B82F6;
    text-decoration: underline;
}

/* === Animated Background === */
.bg-grid {
    position: fixed;
    inset: 0;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
    background-size: 60px 60px;
    z-index: 0;
    pointer-events: none;
}

.bg-glow {
    position: fixed;
    border-radius: 50%;
    filter: blur(120px);
    opacity: 0.15;
    z-index: 0;
    pointer-events: none;
    animation: floatGlow 20s ease-in-out infinite;
}

.bg-glow-1 {
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(59, 130, 246, 0.08), transparent 70%);
    top: -200px;
    left: -100px;
    animation-delay: 0s;
}

.bg-glow-2 {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(37, 99, 235, 0.05), transparent 70%);
    bottom: -150px;
    right: -100px;
    animation-delay: -7s;
}

.bg-glow-3 {
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(59, 130, 246, 0.04), transparent 70%);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation-delay: -14s;
}

@keyframes floatGlow {

    0%,
    100% {
        transform: translate(0, 0) scale(1);
    }

    33% {
        transform: translate(30px, -40px) scale(1.1);
    }

    66% {
        transform: translate(-20px, 30px) scale(0.95);
    }
}

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

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

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* === App Container === */
.app-container {
    display: flex;
    height: 100vh;
    height: 100dvh;
    position: relative;
    z-index: 1;
    overflow: hidden;
}

/* === Sidebar === */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-primary);
    display: flex;
    flex-direction: column;
    transition: transform var(--transition-slow), opacity var(--transition-slow);
    z-index: 100;
}

.sidebar.collapsed {
    transform: translateX(-100%);
    position: absolute;
    height: 100%;
    opacity: 0;
    pointer-events: none;
}

.sidebar-header {
    padding: 20px 16px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: #0A0A0A;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    cursor: pointer;
}

.logo-icon .logo-img {
    width: 34px;
    height: 34px;
    object-fit: contain;
    border-radius: 6px;
    filter: drop-shadow(0 0 6px rgba(59, 130, 246, 0.4));
}

.logo-icon .logo-ring {
    position: absolute;
    inset: -2px;
    border-radius: 14px;
    border: 2px solid transparent;
    background: var(--accent-gradient) border-box;
    -webkit-mask: linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0);
    mask: linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    animation: spin 4s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.logo-text h1 {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.02em;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.logo-subtitle {
    font-size: 11px;
    color: var(--text-tertiary);
    letter-spacing: 0.02em;
}

.sidebar-close {
    display: none;
}

.new-chat-btn {
    margin: 0 12px 12px;
    padding: 12px 16px;
    background: var(--bg-glass);
    border: 1px dashed var(--border-secondary);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-family: var(--font-primary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all var(--transition-base);
}

.new-chat-btn:hover {
    background: var(--bg-glass-hover);
    border-color: var(--accent-primary);
    color: var(--text-primary);
    box-shadow: var(--shadow-glow);
}

.chat-history {
    flex: 1;
    overflow-y: auto;
    padding: 0 12px;
}

.history-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-tertiary);
    padding: 8px 8px 12px;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.history-item {
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all var(--transition-fast);
    position: relative;
    font-size: 13px;
    color: var(--text-secondary);
}

.history-item:hover {
    background: var(--bg-glass-hover);
    color: var(--text-primary);
}

.history-item.active {
    background: rgba(59, 130, 246, 0.1);
    color: var(--text-primary);
    border: 1px solid var(--border-accent);
}

.history-item-icon {
    flex-shrink: 0;
    opacity: 0.5;
}

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

.history-item-delete {
    opacity: 0;
    flex-shrink: 0;
    background: none;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all var(--transition-fast);
    display: flex;
}

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

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

.sidebar-footer {
    padding: 12px;
    border-top: 1px solid var(--border-primary);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.btn-icon {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

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

.btn-icon-text {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: var(--font-primary);
    font-size: 13px;
    transition: all var(--transition-fast);
    width: 100%;
}

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

.btn-icon-text.danger:hover {
    background: rgba(239, 68, 68, 0.08);
    color: var(--danger);
}

/* === Main Content === */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    position: relative;
}

/* === Top Bar === */
.top-bar {
    height: calc(var(--topbar-height) + env(safe-area-inset-top));
    min-height: calc(var(--topbar-height) + env(safe-area-inset-top));
    padding: env(safe-area-inset-top) 20px 0 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    border-bottom: 1px solid var(--border-primary);
    background: rgba(10, 10, 10, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    z-index: 10;
}

.top-bar-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    font-weight: 500;
    flex: 1;
    min-width: 0;
}

.top-bar-title span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.5);
    flex-shrink: 0;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

.top-bar-model {
    font-size: 11px;
    font-weight: 500;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    background: var(--bg-glass);
    border: 1px solid var(--border-primary);
    color: var(--text-tertiary);
    white-space: nowrap;
}

/* === Messages Container === */
.messages-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

/* === Welcome Screen === */
.welcome-screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
    animation: fadeInUp 0.8s ease;
}

.welcome-screen.hidden {
    display: none;
}

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

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

.welcome-orb {
    position: relative;
    width: 120px;
    height: 120px;
    margin-bottom: 32px;
}

.welcome-orb-core {
    position: absolute;
    inset: 20px;
    background: radial-gradient(circle, #141414 0%, #0A0A0A 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 40px var(--accent-glow), 0 0 80px rgba(59, 130, 246, 0.1);
    z-index: 1;
    overflow: hidden;
}

.welcome-logo-img {
    width: 60px;
    height: 60px;
    object-fit: contain;
    border-radius: 50%;
    filter: drop-shadow(0 0 10px rgba(59, 130, 246, 0.5));
    animation: welcomeLogoPulse 3s ease-in-out infinite;
}

@keyframes welcomeLogoPulse {
    0%, 100% {
        transform: scale(1);
        filter: drop-shadow(0 0 10px rgba(59, 130, 246, 0.5));
    }
    50% {
        transform: scale(1.05);
        filter: drop-shadow(0 0 20px rgba(59, 130, 246, 0.7)) drop-shadow(0 0 40px rgba(37, 99, 235, 0.3));
    }
}

.welcome-orb-ring {
    position: absolute;
    border-radius: 50%;
    border: 1.5px solid;
    animation: orbRing 6s linear infinite;
}

.ring-1 {
    inset: 0;
    border-color: rgba(59, 130, 246, 0.15);
    animation-duration: 8s;
}

.ring-2 {
    inset: 8px;
    border-color: rgba(37, 99, 235, 0.1);
    animation-direction: reverse;
    animation-duration: 6s;
}

.ring-3 {
    inset: 14px;
    border-color: rgba(59, 130, 246, 0.08);
    animation-duration: 10s;
}

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

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

.welcome-title {
    font-size: 32px;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 8px;
}

.gradient-text {
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

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

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

.suggestion-chip {
    padding: 10px 18px;
    background: var(--bg-glass);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-full);
    color: var(--text-secondary);
    font-family: var(--font-primary);
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all var(--transition-base);
    white-space: nowrap;
}

.suggestion-chip:hover {
    background: var(--bg-glass-hover);
    border-color: var(--border-accent);
    color: var(--text-primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}

/* === Messages === */
.messages {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 24px 20px 16px;
    max-width: var(--content-max, 820px);
    width: 100%;
    margin: 0 auto;
    overflow-x: hidden;
    word-break: break-word;
}

.message {
    display: flex;
    gap: 14px;
    animation: messageIn 0.3s ease;
    padding: 4px 0;
}

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

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

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 14px;
    font-weight: 700;
    margin-top: 2px;
}

.message.user .message-avatar {
    background: rgba(59, 130, 246, 0.15);
    color: #3B82F6;
}

.message.assistant .message-avatar {
    background: #0A0A0A;
    padding: 2px;
    overflow: hidden;
}

.message.assistant .message-avatar img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 8px;
}

.message-content {
    flex: 1;
    min-width: 0;
}

.message-role {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.message.user .message-role {
    color: #60a5fa;
}

.message.assistant .message-role {
    color: var(--accent-secondary);
}

.message-body {
    font-size: 14.5px;
    line-height: 1.7;
    color: var(--text-primary);
    word-break: break-word;
}

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

/* Message body markdown */
.message-body p {
    margin-bottom: 10px;
}

.message-body p:last-child {
    margin-bottom: 0;
}

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

.message-body em {
    font-style: italic;
    color: var(--text-secondary);
}

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

.message-body li {
    margin-bottom: 4px;
}

.message-body code {
    font-family: var(--font-mono);
    font-size: 13px;
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.15);
    padding: 2px 6px;
    border-radius: 4px;
    color: #93C5FD;
}

.message-body pre {
    margin: 12px 0;
    border-radius: var(--radius-md);
    overflow: hidden;
    position: relative;
    max-width: 100%;
}

.message-body pre code {
    display: block;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border-primary);
    padding: 16px;
    overflow-x: auto;
    font-size: 13px;
    line-height: 1.5;
    color: var(--text-primary);
    max-width: 100%;
    -webkit-overflow-scrolling: touch;
}

.code-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid var(--border-primary);
    border-bottom: none;
    padding: 8px 16px;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-tertiary);
}

.copy-code-btn {
    background: none;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-family: var(--font-primary);
    display: flex;
    align-items: center;
    gap: 4px;
    transition: all var(--transition-fast);
}

.copy-code-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.message-body blockquote {
    border-left: 3px solid var(--accent-primary);
    margin: 12px 0;
    padding: 8px 16px;
    background: rgba(59, 130, 246, 0.05);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    color: var(--text-secondary);
}

.message-body h1,
.message-body h2,
.message-body h3 {
    margin: 16px 0 8px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.message-body h1 {
    font-size: 20px;
}

.message-body h2 {
    font-size: 17px;
}

.message-body h3 {
    font-size: 15px;
}

.message-body hr {
    border: none;
    border-top: 1px solid var(--border-primary);
    margin: 16px 0;
}

.message-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 12px 0;
    font-size: 13px;
}

.message-body th,
.message-body td {
    padding: 8px 12px;
    border: 1px solid var(--border-primary);
    text-align: left;
}

.message-body th {
    background: rgba(59, 130, 246, 0.08);
    font-weight: 600;
}

/* Typing Indicator — Claude-style logo pulse */
.typing-indicator {
    display: flex;
    gap: 8px;
    padding: 6px 0;
    align-items: center;
}

.typing-logo {
    width: 24px;
    height: 24px;
    object-fit: contain;
    border-radius: 4px;
    animation: typingLogoPulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
    filter: drop-shadow(0 0 6px rgba(59, 130, 246, 0.5));
}

@keyframes typingLogoPulse {
    0%, 100% {
        opacity: 0.4;
        transform: scale(0.92);
        filter: drop-shadow(0 0 4px rgba(59, 130, 246, 0.3));
    }
    50% {
        opacity: 1;
        transform: scale(1.08);
        filter: drop-shadow(0 0 12px rgba(59, 130, 246, 0.7)) drop-shadow(0 0 24px rgba(37, 99, 235, 0.4));
    }
}

.typing-text {
    font-size: 13px;
    color: var(--text-tertiary);
    animation: typingTextFade 2s ease-in-out infinite;
}

@keyframes typingTextFade {
    0%, 100% {
        opacity: 0.4;
    }
    50% {
        opacity: 0.8;
    }
}

/* Legacy dot styles for backwards compat */
.typing-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent-primary);
    animation: typingBounce 1.4s ease-in-out infinite;
}

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

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

@keyframes typingBounce {

    0%,
    60%,
    100% {
        transform: translateY(0);
        opacity: 0.4;
    }

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

/* === Input Area === */
.input-area {
    padding: 16px 20px 20px;
    padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
    background: linear-gradient(to top, var(--bg-primary) 60%, transparent);
    flex-shrink: 0;
}

.input-wrapper {
    max-width: var(--content-max, 820px);
    margin: 0 auto;
    position: relative;
    display: flex;
    align-items: flex-end;
    background: var(--bg-card);
    border: 1px solid var(--border-secondary);
    border-radius: var(--radius-lg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    transition: border-color var(--transition-base), box-shadow var(--transition-base);
}

.input-wrapper:focus-within {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-glow), var(--shadow-md);
}

.input-wrapper textarea {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-family: var(--font-primary);
    font-size: 14.5px;
    padding: 14px 16px;
    resize: none;
    max-height: 160px;
    line-height: 1.5;
}

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

.send-btn,
.stop-btn {
    width: 40px;
    height: 40px;
    margin: 6px 8px 6px 0;
    border: none;
    border-radius: var(--radius-md);
    background: var(--accent-gradient);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all var(--transition-base);
    opacity: 1;
}

.send-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.send-btn:not(:disabled):hover {
    box-shadow: var(--shadow-glow);
    transform: scale(1.05);
}

.stop-btn {
    background: var(--danger);
}

.stop-btn:hover {
    background: #dc2626;
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.3);
}

.hidden {
    display: none !important;
}

/* === Image Upload === */
.attach-btn {
    width: 40px;
    height: 40px;
    margin: 6px 0 6px 8px;
    border: none;
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--text-tertiary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all var(--transition-base);
}

.attach-btn:hover {
    color: var(--accent-secondary);
    background: var(--bg-glass-hover);
}

.image-preview-container {
    max-width: var(--content-max, 820px);
    margin: 0 auto 8px;
    padding: 0 4px;
}

.image-preview {
    position: relative;
    display: inline-block;
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--border-secondary);
    max-width: 200px;
}

.image-preview img {
    display: block;
    max-width: 200px;
    max-height: 150px;
    object-fit: cover;
    border-radius: var(--radius-md);
}

.remove-image-btn {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.7);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.remove-image-btn:hover {
    background: var(--danger);
}

.message-image {
    max-width: min(300px, 100%);
    max-height: 250px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-primary);
    margin-bottom: 8px;
    display: block;
}

.input-footer {
    text-align: center;
    font-size: 11px;
    color: var(--text-tertiary);
    margin-top: 10px;
    letter-spacing: 0.01em;
}

/* === Settings Modal === */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.2s ease;
    padding: 20px;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border-secondary);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: modalIn 0.3s ease;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(10px);
    }

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

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

.modal-header h3 {
    font-size: 18px;
    font-weight: 600;
}

.modal-body {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

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

.setting-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.setting-input-wrapper {
    position: relative;
    display: flex;
}

.setting-input {
    flex: 1;
    padding: 10px 44px 10px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 13px;
    outline: none;
    transition: border-color var(--transition-fast);
}

.setting-input:focus {
    border-color: var(--accent-primary);
}

.toggle-visibility {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
}

.setting-hint {
    font-size: 12px;
    color: var(--text-tertiary);
}

.setting-select {
    padding: 10px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-primary);
    font-size: 13px;
    outline: none;
    cursor: pointer;
    transition: border-color var(--transition-fast);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239090b0' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.setting-select:focus {
    border-color: var(--accent-primary);
}

.setting-textarea {
    padding: 10px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-primary);
    font-size: 13px;
    outline: none;
    resize: vertical;
    line-height: 1.5;
    transition: border-color var(--transition-fast);
}

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

.modal-footer {
    padding: 16px 24px 20px;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    border-top: 1px solid var(--border-primary);
}

.btn-primary {
    padding: 10px 20px;
    background: var(--accent-gradient);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    font-family: var(--font-primary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-base);
}

.btn-primary:hover {
    box-shadow: var(--shadow-glow);
    transform: translateY(-1px);
}

.btn-secondary {
    padding: 10px 20px;
    background: var(--bg-glass);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-family: var(--font-primary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-base);
}

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

/* === Toast === */
.toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    padding: 12px 24px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border-secondary);
    font-size: 13px;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    z-index: 2000;
    animation: toastIn 0.3s ease forwards;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.toast.hiding {
    animation: toastOut 0.3s ease forwards;
}

@keyframes toastOut {
    from {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }

    to {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
}

/* === Streaming cursor === */
.streaming-cursor::after {
    content: '▋';
    animation: cursorBlink 0.8s step-end infinite;
    color: var(--text-secondary);
    margin-left: 2px;
}

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

/* === Error message === */
.error-message {
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    color: #fca5a5;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.error-message svg { flex-shrink: 0; }

/* === Sidebar overlay === */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 199;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

.sidebar-overlay.active {
    display: block;
    animation: fadeIn 0.2s ease;
}

/* Removed -webkit-fill-available hacks as they glitch with 100dvh on iOS 15+ */

/* === Voice Input Button === */
.voice-btn {
    width: 40px; height: 40px; margin: 6px 0;
    border: none; border-radius: var(--radius-md);
    background: transparent; color: var(--text-tertiary);
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; transition: all var(--transition-base); position: relative;
}
.voice-btn:hover { color: var(--accent-secondary); background: var(--bg-glass-hover); }
.voice-btn.recording { color: var(--danger); background: rgba(239, 68, 68, 0.1); }
.voice-btn .voice-pulse {
    position: absolute; inset: -4px; border-radius: var(--radius-md);
    border: 2px solid var(--danger); opacity: 0; pointer-events: none; transition: opacity 0.2s;
}
.voice-btn.recording .voice-pulse { opacity: 1; animation: voicePulse 1.2s ease-in-out infinite; }
@keyframes voicePulse {
    0%, 100% { transform: scale(1); opacity: 0.6; }
    50% { transform: scale(1.15); opacity: 0; }
}

/* === Message Actions === */
.message-actions { display: flex; gap: 4px; margin-top: 8px; opacity: 0; transition: opacity var(--transition-fast); flex-wrap: wrap; }
.message:hover .message-actions { opacity: 1; }
.msg-action-btn {
    background: var(--bg-glass); border: 1px solid var(--border-primary); color: var(--text-tertiary);
    cursor: pointer; padding: 5px 10px; border-radius: var(--radius-sm);
    font-family: var(--font-primary); font-size: 11px;
    display: flex; align-items: center; gap: 4px; transition: all var(--transition-fast); white-space: nowrap;
}
.msg-action-btn:hover { background: var(--bg-glass-hover); border-color: var(--border-secondary); color: var(--text-primary); }
.msg-action-btn.speaking { color: var(--accent-secondary); border-color: rgba(37, 99, 235, 0.3); background: rgba(37, 99, 235, 0.08); }

/* === Edit Message === */
.edit-textarea {
    width: 100%; min-height: 60px; padding: 10px 14px;
    background: var(--bg-tertiary); border: 1px solid var(--accent-primary);
    border-radius: var(--radius-md); color: var(--text-primary);
    font-family: var(--font-primary); font-size: 14px; line-height: 1.6;
    resize: vertical; outline: none; box-shadow: 0 0 0 3px var(--accent-glow);
}
.edit-actions { display: flex; gap: 8px; margin-top: 8px; }
.edit-save-btn { padding: 6px 16px; background: var(--accent-gradient); border: none; border-radius: var(--radius-sm); color: white; font-family: var(--font-primary); font-size: 12px; font-weight: 500; cursor: pointer; transition: all var(--transition-fast); }
.edit-save-btn:hover { box-shadow: var(--shadow-glow); }
.edit-cancel-btn { padding: 6px 16px; background: var(--bg-glass); border: 1px solid var(--border-primary); border-radius: var(--radius-sm); color: var(--text-secondary); font-family: var(--font-primary); font-size: 12px; cursor: pointer; transition: all var(--transition-fast); }
.edit-cancel-btn:hover { background: var(--bg-glass-hover); color: var(--text-primary); }

/* === Export Modal === */
.export-options { display: flex; flex-direction: column; gap: 10px; }
.export-option-btn { display: flex; align-items: center; gap: 14px; padding: 14px 18px; background: var(--bg-glass); border: 1px solid var(--border-primary); border-radius: var(--radius-md); color: var(--text-primary); cursor: pointer; font-family: var(--font-primary); transition: all var(--transition-base); text-align: left; }
.export-option-btn:hover { background: var(--bg-glass-hover); border-color: var(--accent-primary); box-shadow: var(--shadow-glow); transform: translateY(-1px); }
.export-option-btn svg { color: var(--accent-secondary); flex-shrink: 0; }
.export-option-btn div { display: flex; flex-direction: column; }
.export-option-btn strong { font-size: 14px; font-weight: 600; }
.export-option-btn span { font-size: 12px; color: var(--text-tertiary); }

/* === Toggle Switch === */
.setting-toggle-row { display: flex; align-items: center; justify-content: space-between; padding: 8px 0; }
.setting-toggle-label { font-size: 13px; color: var(--text-secondary); }
.toggle-switch { position: relative; width: 44px; height: 24px; display: inline-block; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; cursor: pointer; inset: 0; background: var(--bg-tertiary); border: 1px solid var(--border-secondary); border-radius: var(--radius-full); transition: all var(--transition-base); }
.toggle-slider::before { content: ''; position: absolute; width: 18px; height: 18px; border-radius: 50%; background: var(--text-tertiary); left: 2px; top: 2px; transition: all var(--transition-base); }
.toggle-switch input:checked+.toggle-slider { background: var(--accent-primary); border-color: var(--accent-primary); }
.toggle-switch input:checked+.toggle-slider::before { background: white; transform: translateX(20px); }

/* === Highlight.js Overrides === */
.message-body pre code.hljs { background: rgba(0, 0, 0, 0.5) !important; border-radius: 0 0 var(--radius-md) var(--radius-md); padding: 16px !important; }
.message-body pre { position: relative; }
.message-body pre code { border-top: none; border-radius: 0 0 var(--radius-md) var(--radius-md); }
.code-header+code { border-top: none !important; }

/* === Call Button === */
.call-btn { width: 36px; height: 36px; border: none; border-radius: 50%; background: var(--accent-gradient); color: white; cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; transition: all var(--transition-base); box-shadow: 0 0 12px var(--accent-glow); }
.call-btn:hover { transform: scale(1.1); box-shadow: 0 0 24px var(--accent-glow), var(--shadow-glow); }
.call-btn:active { transform: scale(0.95); }

/* === Call Overlay === */
.call-overlay { position: fixed; inset: 0; z-index: 5000; background: var(--bg-primary); display: flex; flex-direction: column; align-items: center; justify-content: center; animation: callFadeIn 0.5s ease; overflow: hidden; }
.call-overlay.hidden { display: none !important; }
@keyframes callFadeIn { from { opacity: 0; transform: scale(1.05); } to { opacity: 1; transform: scale(1); } }
.call-bg-grid { position: absolute; inset: 0; background-image: linear-gradient(rgba(124,58,237,0.04) 1px, transparent 1px), linear-gradient(90deg, rgba(124,58,237,0.04) 1px, transparent 1px); background-size: 50px 50px; pointer-events: none; }
.call-bg-glow { position: absolute; border-radius: 50%; filter: blur(150px); pointer-events: none; animation: callGlowFloat 15s ease-in-out infinite; }
.call-glow-1 { width: 500px; height: 500px; background: radial-gradient(circle, rgba(124,58,237,0.2), transparent 70%); top: -100px; right: -100px; }
.call-glow-2 { width: 400px; height: 400px; background: radial-gradient(circle, rgba(6,182,212,0.15), transparent 70%); bottom: -50px; left: -50px; animation-delay: -7s; }
@keyframes callGlowFloat { 0%, 100% { transform: translate(0,0) scale(1); } 50% { transform: translate(30px,-30px) scale(1.15); } }
.call-content { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; width: 100%; max-width: 480px; padding: 40px 24px; height: 100%; height: 100dvh; }
.call-header { display: flex; flex-direction: column; align-items: center; gap: 4px; margin-bottom: auto; padding-top: 40px; padding-top: calc(40px + env(safe-area-inset-top, 0px)); }
.call-label { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; background: var(--accent-gradient); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.call-timer { font-size: 14px; font-family: var(--font-mono); color: var(--text-tertiary); letter-spacing: 0.05em; }
.call-orb-container { position: relative; display: flex; align-items: center; justify-content: center; margin: auto 0; }
.call-orb { position: relative; width: 200px; height: 200px; display: flex; align-items: center; justify-content: center; }
.call-orb-wave { position: absolute; border-radius: 50%; border: 1.5px solid; opacity: 0.3; transition: all 0.5s ease; }
.wave-1 { inset: -10px; border-color: rgba(124,58,237,0.4); animation: callOrbPulse 3s ease-in-out infinite; }
.wave-2 { inset: -30px; border-color: rgba(6,182,212,0.3); animation: callOrbPulse 3s ease-in-out infinite 0.5s; }
.wave-3 { inset: -50px; border-color: rgba(124,58,237,0.2); animation: callOrbPulse 3s ease-in-out infinite 1s; }
.wave-4 { inset: -75px; border-color: rgba(6,182,212,0.1); animation: callOrbPulse 3s ease-in-out infinite 1.5s; }
@keyframes callOrbPulse { 0%, 100% { transform: scale(1); opacity: 0.3; } 50% { transform: scale(1.08); opacity: 0.6; } }
.call-orb-core { width: 140px; height: 140px; border-radius: 50%; background: var(--accent-gradient); display: flex; align-items: center; justify-content: center; font-size: 48px; font-weight: 800; color: white; box-shadow: 0 0 60px var(--accent-glow), 0 0 120px rgba(124,58,237,0.15), inset 0 0 30px rgba(255,255,255,0.1); position: relative; z-index: 1; transition: all 0.4s ease; }
.call-orb.listening .call-orb-core { box-shadow: 0 0 60px rgba(16,185,129,0.3), 0 0 120px rgba(16,185,129,0.1), inset 0 0 30px rgba(255,255,255,0.1); }
.call-orb.listening .call-orb-wave { animation-duration: 2s; }
.call-orb.listening .wave-1 { border-color: rgba(16,185,129,0.5); }
.call-orb.listening .wave-2 { border-color: rgba(16,185,129,0.35); }
.call-orb.listening .wave-3 { border-color: rgba(16,185,129,0.2); }
.call-orb.listening .wave-4 { border-color: rgba(16,185,129,0.1); }
.call-orb.speaking .call-orb-core { animation: orbSpeak 0.8s ease-in-out infinite; box-shadow: 0 0 80px var(--accent-glow), 0 0 160px rgba(124,58,237,0.2), inset 0 0 30px rgba(255,255,255,0.15); }
.call-orb.speaking .call-orb-wave { animation-duration: 1.2s; opacity: 0.6; }
@keyframes orbSpeak { 0%, 100% { transform: scale(1); } 25% { transform: scale(1.06); } 50% { transform: scale(0.98); } 75% { transform: scale(1.04); } }
.call-orb.thinking .call-orb-core { animation: orbThink 2s linear infinite; }
.call-orb.thinking .call-orb-wave { animation: callOrbSpin 4s linear infinite; }
@keyframes orbThink { 0%, 100% { box-shadow: 0 0 60px var(--accent-glow), 0 0 120px rgba(124,58,237,0.15), inset 0 0 30px rgba(255,255,255,0.1); } 50% { box-shadow: 0 0 80px var(--accent-glow-cyan), 0 0 120px rgba(6,182,212,0.15), inset 0 0 30px rgba(255,255,255,0.1); } }
@keyframes callOrbSpin { from { transform: rotate(0deg) scale(1.05); } to { transform: rotate(360deg) scale(1.05); } }
.call-status { font-size: 16px; font-weight: 500; color: var(--text-secondary); margin-top: 24px; transition: color 0.3s; text-align: center; }
.call-status.active { color: var(--success); }
.call-transcript { font-size: 17px; line-height: 1.6; color: var(--text-primary); margin-top: 16px; text-align: center; max-height: 120px; overflow-y: auto; padding: 0 20px; opacity: 0.9; max-width: 100%; word-break: break-word; }
.call-controls { display: flex; align-items: center; justify-content: center; gap: 24px; margin-top: auto; padding-bottom: 50px; padding-bottom: calc(50px + env(safe-area-inset-bottom, 0px)); }
.call-control-btn { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; background: rgba(255,255,255,0.06); border: 1px solid var(--border-secondary); border-radius: 50%; width: 64px; height: 64px; cursor: pointer; color: var(--text-primary); transition: all var(--transition-base); position: relative; }
.call-control-btn span { font-size: 10px; color: var(--text-tertiary); position: absolute; bottom: -20px; white-space: nowrap; }
.call-control-btn:hover { background: rgba(255,255,255,0.1); border-color: var(--accent-primary); transform: scale(1.05); }
.call-control-btn.active { background: rgba(124,58,237,0.2); border-color: var(--accent-primary); color: var(--accent-primary); }
.call-control-btn.call-end { background: var(--danger); border-color: var(--danger); width: 72px; height: 72px; }
.call-control-btn.call-end:hover { background: #dc2626; transform: scale(1.08); box-shadow: 0 0 30px rgba(239,68,68,0.4); }
.call-control-btn.call-end svg { transform: rotate(135deg); }

/* === Sidebar Search === */
.sidebar-search {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 16px;
    margin-bottom: 12px;
    position: relative;
}
.sidebar-search svg {
    position: absolute;
    left: 26px;
    color: var(--text-tertiary);
    pointer-events: none;
}
.sidebar-search input {
    width: 100%;
    padding: 9px 12px 9px 36px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-primary);
    font-size: 13px;
    outline: none;
    transition: border-color var(--transition-fast);
}
.sidebar-search input::placeholder { color: var(--text-tertiary); }
.sidebar-search input:focus { border-color: var(--accent-primary); }

/* === Auto Smart Context Badge === */
.auto-context-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.2);
    border-radius: var(--radius-full);
    color: var(--accent-primary);
    font-family: var(--font-primary);
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    user-select: none;
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.1);
    animation: autoContextPulse 3s ease-in-out infinite;
}

.auto-context-icon {
    font-size: 13px;
    animation: iconFloat 4s ease-in-out infinite;
}

@keyframes autoContextPulse {
    0%, 100% {
        box-shadow: 0 0 10px rgba(59, 130, 246, 0.1);
        border-color: rgba(59, 130, 246, 0.2);
    }
    50% {
        box-shadow: 0 0 20px rgba(59, 130, 246, 0.3);
        border-color: rgba(59, 130, 246, 0.4);
    }
}

@keyframes iconFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-1px) scale(1.1); }
}


/* === Pinned Chat Indicator === */
.history-item.pinned { border-left: 2px solid var(--accent-primary); }
.history-item .pin-icon {
    color: var(--accent-primary); flex-shrink: 0;
    opacity: 0; transition: opacity var(--transition-fast);
    width: 14px; height: 14px;
}
.history-item.pinned .pin-icon { opacity: 1; }
.history-item:hover .pin-icon { opacity: 0.6; }
.history-item.pinned:hover .pin-icon { opacity: 1; }
.pin-btn {
    background: none; border: none; cursor: pointer; padding: 2px;
    display: flex; align-items: center; color: inherit;
}
.pinned-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--accent-primary); padding: 4px 16px 2px; font-weight: 600; }

.image-loading {
    display: flex; align-items: center; justify-content: center;
    padding: 40px; background: var(--bg-glass);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md); color: var(--text-tertiary);
    font-size: 13px; gap: 8px; max-width: 400px;
}
.image-loading .spinner {
    width: 20px; height: 20px; border: 2px solid var(--border-secondary);
    border-top-color: var(--accent-primary); border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* === No Search Results === */
.no-results { padding: 20px 16px; text-align: center; color: var(--text-tertiary); font-size: 13px; }

/* === Image Generation Section === */
.imagegen-topbar-btn {
    width: 36px; height: 36px; border: none; border-radius: 50%;
    background: linear-gradient(135deg, #f59e0b, #ef4444);
    color: white; cursor: pointer; display: flex; align-items: center;
    justify-content: center; flex-shrink: 0;
    transition: all var(--transition-base);
    box-shadow: 0 0 12px rgba(245, 158, 11, 0.3);
}
.imagegen-topbar-btn:hover { transform: scale(1.1); box-shadow: 0 0 24px rgba(245, 158, 11, 0.5); }
.imagegen-topbar-btn:active { transform: scale(0.95); }
/* ═══════════════════════════════════════════
   Q-IMAGE ENGINE — Premium UI
   ═══════════════════════════════════════════ */
.qimage-modal {
    max-width: 600px;
    width: 95vw;
    max-height: 88vh;
    padding: 0;
    overflow: hidden;
    border-radius: var(--radius-xl, 20px);
    border: 1px solid rgba(245, 158, 11, 0.15);
}

/* ── Header ── */
.qimage-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: linear-gradient(135deg, rgba(245,158,11,0.08), rgba(239,68,68,0.05));
    border-bottom: 1px solid var(--border-primary, rgba(255,255,255,0.06));
}
.qimage-title-group {
    display: flex;
    align-items: center;
    gap: 12px;
}
.qimage-logo {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #f59e0b, #ef4444);
    border-radius: var(--radius-md, 10px);
    color: white;
    flex-shrink: 0;
}
.qimage-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary, #e2e8f0);
    margin: 0;
}
.qimage-subtitle {
    font-size: 11px;
    color: var(--text-tertiary, rgba(255,255,255,0.4));
    font-weight: 500;
}

/* ── Body ── */
.qimage-body {
    padding: 20px;
    overflow-y: auto;
    max-height: calc(88vh - 72px);
    scrollbar-width: thin;
    scrollbar-color: #f59e0b transparent;
}
.qimage-body::-webkit-scrollbar { width: 4px; }
.qimage-body::-webkit-scrollbar-thumb { background: #f59e0b; border-radius: 2px; }

/* ── Prompt Section ── */
.qimage-prompt-section {
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.qimage-prompt-card {
    background: var(--bg-glass, rgba(255,255,255,0.03));
    border: 1px solid var(--border-primary, rgba(255,255,255,0.06));
    border-radius: var(--radius-lg, 14px);
    padding: 16px;
}
.qimage-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary, rgba(255,255,255,0.6));
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 10px;
}
.qimage-label svg { opacity: 0.5; }

.qimage-textarea {
    width: 100%;
    box-sizing: border-box;
    padding: 12px 14px;
    border-radius: var(--radius-md, 10px);
    background: rgba(0,0,0,0.25);
    border: 1px solid var(--border-primary, rgba(255,255,255,0.06));
    color: var(--text-primary, #e2e8f0);
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    outline: none;
    transition: border-color 0.2s;
    line-height: 1.5;
}
.qimage-textarea::placeholder { color: var(--text-tertiary, rgba(255,255,255,0.25)); }
.qimage-textarea:focus { border-color: #f59e0b; box-shadow: 0 0 0 3px rgba(245,158,11,0.1); }

/* ── Style Chips ── */
.qimage-style-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.qimage-chip {
    padding: 8px 14px;
    border: 1px solid var(--border-primary, rgba(255,255,255,0.08));
    border-radius: 20px;
    background: var(--bg-glass, rgba(255,255,255,0.03));
    color: var(--text-secondary, rgba(255,255,255,0.6));
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    white-space: nowrap;
}
.qimage-chip:hover {
    background: rgba(245,158,11,0.08);
    border-color: rgba(245,158,11,0.3);
    color: var(--text-primary, #e2e8f0);
}
.qimage-chip.active {
    background: linear-gradient(135deg, rgba(245,158,11,0.15), rgba(239,68,68,0.1));
    border-color: rgba(245,158,11,0.4);
    color: #f59e0b;
    font-weight: 600;
}

/* ── Generate Button ── */
.qimage-generate-btn {
    width: 100%;
    padding: 14px 20px;
    border: none;
    border-radius: var(--radius-md, 10px);
    cursor: pointer;
    background: linear-gradient(135deg, #f59e0b, #ef4444);
    color: white;
    font-family: inherit;
    font-size: 15px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.2s ease;
    box-shadow: 0 4px 20px rgba(245, 158, 11, 0.3);
}
.qimage-generate-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 30px rgba(245, 158, 11, 0.4);
}
.qimage-generate-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* ── Result Area ── */
.qimage-result { margin-top: 20px; }

/* ── Loading ── */
.qimage-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 50px 20px;
    background: var(--bg-glass, rgba(255,255,255,0.03));
    border: 1px solid var(--border-primary, rgba(255,255,255,0.06));
    border-radius: var(--radius-lg, 14px);
    gap: 16px;
}
.qimage-loading-orb {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, #f59e0b, #ef4444);
    animation: qimageOrb 1.5s ease-in-out infinite;
    box-shadow: 0 0 30px rgba(245,158,11,0.4);
}
@keyframes qimageOrb {
    0%, 100% { transform: scale(1); opacity: 0.8; }
    50% { transform: scale(1.15); opacity: 1; box-shadow: 0 0 50px rgba(245,158,11,0.6); }
}
.qimage-loading-text {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary, #e2e8f0);
}
.qimage-loading-sub {
    font-size: 12px;
    color: var(--text-tertiary, rgba(255,255,255,0.35));
}

/* ── Output ── */
.qimage-output {
    border-radius: var(--radius-lg, 14px);
    overflow: hidden;
    border: 1px solid var(--border-primary, rgba(255,255,255,0.06));
}
.qimage-preview-wrap {
    position: relative;
    background: rgba(0,0,0,0.3);
}
.qimage-preview-wrap img {
    display: block;
    width: 100%;
    height: auto;
    max-height: 450px;
    object-fit: contain;
}

/* ── Actions ── */
.qimage-actions {
    display: flex;
    gap: 8px;
    padding: 12px;
    background: rgba(0,0,0,0.2);
    border-top: 1px solid var(--border-primary, rgba(255,255,255,0.06));
}
.qimage-action {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--border-primary, rgba(255,255,255,0.08));
    border-radius: var(--radius-md, 10px);
    background: var(--bg-glass, rgba(255,255,255,0.03));
    color: var(--text-primary, #e2e8f0);
    cursor: pointer;
    font-family: inherit;
    font-size: 12px;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.2s;
}
.qimage-action:hover {
    background: rgba(245,158,11,0.1);
    border-color: rgba(245,158,11,0.3);
}
.qimage-action-primary {
    background: linear-gradient(135deg, rgba(245,158,11,0.2), rgba(239,68,68,0.1));
    border-color: rgba(245,158,11,0.3);
    color: #f59e0b;
    font-weight: 600;
}
.qimage-action-primary:hover {
    background: linear-gradient(135deg, rgba(245,158,11,0.3), rgba(239,68,68,0.15));
}

/* ── Q-Image Responsive ── */
@media (max-width: 600px) {
    .qimage-modal { max-width: 100%; border-radius: 0; max-height: 100vh; max-height: 100dvh; }
    .qimage-body { padding: 14px; max-height: calc(100vh - 72px); }
    .qimage-header { padding: 14px 16px; }
    .qimage-logo { width: 36px; height: 36px; }
    .qimage-title { font-size: 15px; }
    .qimage-chip { padding: 6px 10px; font-size: 11px; }
    .qimage-generate-btn { padding: 12px 16px; font-size: 14px; }
    .qimage-actions { flex-direction: column; }
    .qimage-preview-wrap img { max-height: 300px; }
}

/* Light theme */
[data-theme="light"] .qimage-modal { border-color: rgba(245,158,11,0.15); }
[data-theme="light"] .qimage-header { background: linear-gradient(135deg, rgba(245,158,11,0.06), rgba(239,68,68,0.03)); }
[data-theme="light"] .qimage-prompt-card { background: rgba(0,0,0,0.02); border-color: #d2d2d7; }
[data-theme="light"] .qimage-textarea { background: #f5f5f7; border-color: #d2d2d7; color: #1d1d1f; }
[data-theme="light"] .qimage-chip { background: #f5f5f7; border-color: #d2d2d7; color: #6e6e73; }
[data-theme="light"] .qimage-chip.active { background: rgba(245,158,11,0.1); color: #d97706; }
[data-theme="light"] .qimage-action { background: #f5f5f7; border-color: #d2d2d7; color: #1d1d1f; }
[data-theme="light"] .qimage-loading { background: rgba(0,0,0,0.02); border-color: #d2d2d7; }
[data-theme="light"] .qimage-output { border-color: #d2d2d7; }




/* Chat font size variable */
:root { --chat-font-size: 15px; }
.message-body { font-size: var(--chat-font-size) !important; }

/* Font Size Control */
.font-size-control {
    display: flex; align-items: center; gap: 12px;
    background: var(--bg-secondary, #1a1a2e); border-radius: 10px; padding: 6px 12px;
}
.font-btn {
    width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--border-color, #333);
    background: var(--bg-primary, #0d0d1a); color: var(--text-primary, #eee);
    font-size: 14px; font-weight: 700; cursor: pointer; transition: all 0.2s;
}
.font-btn:hover { background: var(--accent, #3B82F6); color: white; border-color: var(--accent, #3B82F6); }
.font-size-label { font-size: 14px; color: var(--text-secondary, #aaa); min-width: 40px; text-align: center; }

/* Memory */
.memories-list { max-height: 200px; overflow-y: auto; margin: 8px 0; }
.memory-item {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    padding: 8px 12px; border-radius: 8px; margin-bottom: 4px;
    background: var(--bg-secondary, #1a1a2e); border: 1px solid var(--border-color, #333);
}
.memory-text { font-size: 13px; color: var(--text-primary, #eee); flex: 1; }
.memory-delete {
    width: 24px; height: 24px; border-radius: 50%; border: none;
    background: rgba(255,59,48,0.15); color: #ff3b30; cursor: pointer;
    font-size: 12px; display: flex; align-items: center; justify-content: center;
    transition: all 0.2s;
}
.memory-delete:hover { background: rgba(255,59,48,0.3); }
.empty-memories { color: var(--text-tertiary, #666); font-size: 13px; padding: 12px; text-align: center; font-style: italic; }
.memory-add-row { display: flex; gap: 8px; margin-top: 8px; }
.setting-input {
    flex: 1; padding: 8px 12px; border-radius: 8px;
    background: var(--bg-primary, #0d0d1a); border: 1px solid var(--border-color, #333);
    color: var(--text-primary, #eee); font-size: 13px; outline: none;
}
.setting-input:focus { border-color: var(--accent, #3B82F6); }
.btn-add {
    padding: 8px 16px; border-radius: 8px; border: none;
    background: var(--accent, #3B82F6); color: white; font-size: 13px;
    font-weight: 600; cursor: pointer; white-space: nowrap; transition: all 0.2s;
}
.btn-add:hover { filter: brightness(1.15); }

/* Prompt Templates */
.templates-grid { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.template-chip {
    padding: 6px 14px; border-radius: 20px; border: 1px solid var(--border-color, #333);
    background: var(--bg-secondary, #1a1a2e); color: var(--text-primary, #eee);
    font-size: 12px; cursor: pointer; transition: all 0.2s; white-space: nowrap;
}
.template-chip:hover { background: var(--accent, #3B82F6); color: white; border-color: var(--accent, #3B82F6); }
.template-add-section {
    margin-top: 8px; font-size: 13px; color: var(--text-secondary, #aaa);
}
.template-add-section summary { cursor: pointer; padding: 6px 0; color: var(--accent, #3B82F6); }
.template-add-section .setting-input,
.template-add-section .setting-textarea { margin-top: 6px; width: 100%; box-sizing: border-box; }
.template-add-section .btn-add { margin-top: 6px; }

/* Keyboard Shortcuts */
.shortcuts-list { display: flex; flex-direction: column; gap: 6px; }
.shortcut-row {
    display: flex; align-items: center; justify-content: space-between;
    padding: 6px 0; border-bottom: 1px solid var(--border-color, #222);
}
.shortcut-row:last-child { border-bottom: none; }
.shortcut-row kbd {
    padding: 3px 8px; border-radius: 6px; font-size: 11px; font-family: monospace;
    background: var(--bg-secondary, #1a1a2e); border: 1px solid var(--border-color, #444);
    color: var(--text-secondary, #aaa);
}
.shortcut-row span { font-size: 13px; color: var(--text-primary, #eee); }

/* Q-Video Engine */
.video-progress { margin-top: 16px; }
.video-progress-bar {
    width: 100%; height: 8px; border-radius: 4px;
    background: var(--bg-secondary, #1a1a2e); overflow: hidden;
}
.video-progress-fill {
    height: 100%; border-radius: 4px; width: 0%;
    background: linear-gradient(90deg, #3B82F6, #60A5FA, #93C5FD);
    transition: width 0.5s ease;
}
.video-progress-text {
    display: block; margin-top: 8px; font-size: 13px;
    color: var(--text-secondary, #aaa); text-align: center;
}

.video-player { margin-top: 16px; }
.video-canvas {
    position: relative; border-radius: 12px; overflow: hidden;
    background: #000; aspect-ratio: 1; display: flex;
    align-items: center; justify-content: center;
}
.video-canvas img {
    width: 100%; height: 100%; object-fit: cover;
    transition: opacity 0.3s ease;
}
.video-frame-counter {
    position: absolute; top: 10px; right: 10px;
    background: rgba(0,0,0,0.7); color: white; padding: 4px 10px;
    border-radius: 20px; font-size: 12px; font-weight: 600;
    backdrop-filter: blur(8px);
}

.video-controls {
    display: flex; align-items: center; justify-content: center;
    gap: 8px; margin-top: 12px;
}
.video-ctrl-btn {
    width: 44px; height: 44px; border-radius: 50%;
    border: 1px solid var(--border-color, #333);
    background: var(--bg-secondary, #1a1a2e);
    color: var(--text-primary, #eee);
    font-size: 16px; cursor: pointer; transition: all 0.2s;
    display: flex; align-items: center; justify-content: center;
}
.video-ctrl-btn:hover { background: var(--accent, #3B82F6); border-color: var(--accent, #3B82F6); }
.video-play-btn {
    width: 56px; height: 56px; font-size: 20px;
    background: linear-gradient(135deg, #3B82F6, #60A5FA);
    border-color: transparent; color: white;
}
.video-play-btn:hover { filter: brightness(1.15); background: linear-gradient(135deg, #3B82F6, #60A5FA); }

/* Theme Toggle */
.topbar-theme-btn, .topbar-share-btn {
    font-size: 16px; width: 36px; height: 36px;
    border: none; border-radius: 8px; cursor: pointer;
    background: transparent; transition: all 0.2s;
}
.topbar-theme-btn:hover, .topbar-share-btn:hover {
    background: rgba(255,255,255,0.1);
}
.theme-toggle-row {
    display: flex; align-items: center; justify-content: space-between;
}
.theme-switch-btn {
    padding: 8px 16px; border-radius: 10px; border: 1px solid var(--border-color, #333);
    background: var(--bg-secondary, #1a1a2e); color: var(--text-primary, #eee);
    cursor: pointer; font-size: 13px; transition: all 0.2s;
}
.theme-switch-btn:hover { background: var(--accent, #3B82F6); border-color: var(--accent, #3B82F6); color: white; }
.theme-icon { margin-right: 4px; }

/* History label for recent section */
.history-label {
    font-size: 11px; color: var(--text-tertiary, #666); padding: 4px 16px;
    text-transform: uppercase; letter-spacing: 1px;
}

/* --- LIGHT THEME --- */
[data-theme="light"] {
    --bg-primary: #f5f5f7;
    --bg-secondary: #ffffff;
    --bg-tertiary: #e8e8ed;
    --text-primary: #1d1d1f;
    --text-secondary: #6e6e73;
    --text-tertiary: #999;
    --border-color: #d2d2d7;
    --accent: #3B82F6;
    --accent-hover: #5a4bd1;
    --sidebar-bg: #ffffff;
    --msg-user-bg: #e3dff8;
    --msg-assistant-bg: #f0f0f5;
    --input-bg: #ffffff;
    --code-bg: #f0f0f5;
}

[data-theme="light"] body {
    background-color: #f5f5f7;
    color: #1d1d1f;
}

[data-theme="light"] .sidebar {
    background: #ffffff;
    border-right-color: #d2d2d7;
}

[data-theme="light"] .chat-header {
    background: rgba(255,255,255,0.85);
    border-bottom-color: #d2d2d7;
}

[data-theme="light"] .message.user .message-content {
    background: #e3dff8;
    color: #1d1d1f;
}

[data-theme="light"] .message.assistant .message-content {
    background: #f0f0f5;
    color: #1d1d1f;
}

[data-theme="light"] .input-area {
    background: rgba(255,255,255,0.9);
    border-top-color: #d2d2d7;
}

[data-theme="light"] .message-input {
    background: #f0f0f5;
    color: #1d1d1f;
    border-color: #d2d2d7;
}

[data-theme="light"] .message-input:focus {
    border-color: #3B82F6;
}

[data-theme="light"] .welcome-screen h2,
[data-theme="light"] .welcome-screen p {
    color: #1d1d1f;
}

[data-theme="light"] .suggestion-chip {
    background: #ffffff;
    color: #1d1d1f;
    border-color: #d2d2d7;
}

[data-theme="light"] .suggestion-chip:hover {
    background: #3B82F6;
    color: white;
}

[data-theme="light"] .history-item {
    color: #1d1d1f;
}

[data-theme="light"] .history-item:hover,
[data-theme="light"] .history-item.active {
    background: #e8e8ed;
}

[data-theme="light"] .modal {
    background: #ffffff;
    border-color: #d2d2d7;
}

[data-theme="light"] .setting-select,
[data-theme="light"] .setting-textarea,
[data-theme="light"] .setting-input {
    background: #f0f0f5;
    color: #1d1d1f;
    border-color: #d2d2d7;
}

[data-theme="light"] pre {
    background: #f0f0f5 !important;
}

[data-theme="light"] .code-header {
    background: #e8e8ed;
    color: #6e6e73;
}

[data-theme="light"] code {
    background: #e8e8ed;
    color: #3B82F6;
}

[data-theme="light"] .topbar-theme-btn:hover,
[data-theme="light"] .topbar-share-btn:hover {
    background: rgba(0,0,0,0.08);
}

[data-theme="light"] .btn-icon {
    color: #1d1d1f;
}

[data-theme="light"] .messages-container {
    background: #f5f5f7;
}

[data-theme="light"] .new-chat-btn {
    background: #f0f0f5;
    color: #1d1d1f;
    border-color: #d2d2d7;
}

[data-theme="light"] .error-message {
    background: rgba(255,59,48,0.08);
    color: #ff3b30;
}

/* Message animation */
.message {
    animation: messageSlideIn 0.3s ease-out;
}
@keyframes messageSlideIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Accent Color Picker */
.accent-picker { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.accent-dot {
    width: 32px; height: 32px; border-radius: 50%; border: 3px solid transparent;
    cursor: pointer; transition: all 0.2s; position: relative;
}
.accent-dot:hover { transform: scale(1.15); }
.accent-dot.active { border-color: var(--text-primary, #eee); box-shadow: 0 0 12px currentColor; }

/* Music Player */
.music-player { margin-top: 16px; text-align: center; }
.music-mood-label {
    font-size: 14px; color: var(--text-secondary, #aaa); margin-bottom: 12px;
    padding: 12px; background: var(--bg-secondary, #1a1a2e); border-radius: 10px;
}
.music-stop-btn {
    padding: 10px 24px; border-radius: 10px; border: 1px solid #d63031;
    background: rgba(214,48,49,0.1); color: #d63031; font-size: 14px;
    cursor: pointer; transition: all 0.2s;
}
.music-stop-btn:hover { background: #d63031; color: white; }

/* Dashboard */
.dashboard-grid {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px;
}
.stat-card {
    background: var(--bg-secondary, #1a1a2e); border-radius: 12px;
    padding: 16px 12px; text-align: center;
    border: 1px solid var(--border-color, #333); transition: all 0.2s;
}
.stat-card:hover { transform: translateY(-2px); border-color: var(--accent, #3B82F6); }
.stat-icon { font-size: 24px; margin-bottom: 6px; }
.stat-value {
    font-size: 22px; font-weight: 700;
    color: var(--accent, #3B82F6); line-height: 1.2;
}
.stat-label {
    font-size: 11px; color: var(--text-tertiary, #666);
    text-transform: uppercase; letter-spacing: 0.5px; margin-top: 4px;
}

/* Focus Mode */
.focus-mode .sidebar { transform: translateX(-100%) !important; }
.focus-mode .sidebar-overlay { display: none !important; }
.focus-mode .chat-header {
    padding: 8px 16px;
}
.focus-mode .input-area { max-width: 100%; }
.focus-mode .messages-container { padding-top: 60px; }

/* Chat Lock — locked title styling */
.history-item.locked .history-item-title {
    color: var(--text-tertiary, #666); font-style: italic;
}

/* ═══════════════════════════════════════════
   PREMIUM SETTINGS — Tabbed Layout
   ═══════════════════════════════════════════ */
.settings-modal {
    max-width: 780px;
    width: 95vw;
    max-height: 85vh;
    padding: 0;
    overflow: hidden;
    border-radius: var(--radius-xl, 20px);
}
.settings-layout {
    display: flex;
    height: 100%;
    max-height: 85vh;
}

/* ── Nav Sidebar ── */
.settings-nav {
    width: 200px;
    min-width: 200px;
    display: flex;
    flex-direction: column;
    background: rgba(0,0,0,0.25);
    border-right: 1px solid var(--border-primary, rgba(255,255,255,0.06));
}
.settings-nav-header {
    padding: 20px 16px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.settings-nav-title {
    font-size: 18px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-primary, #3B82F6), var(--accent-secondary, #2563EB));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.settings-close-mobile { display: none; }
.settings-tabs {
    flex: 1;
    overflow-y: auto;
    padding: 4px 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.settings-tab {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: none;
    border-radius: var(--radius-md, 10px);
    background: transparent;
    color: var(--text-secondary, rgba(255,255,255,0.6));
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    position: relative;
    font-family: inherit;
}
.settings-tab:hover {
    background: rgba(255,255,255,0.05);
    color: var(--text-primary, #e2e8f0);
}
.settings-tab.active {
    background: rgba(59,130,246,0.15);
    color: var(--text-primary, #e2e8f0);
    font-weight: 600;
}
.settings-tab.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 20px;
    border-radius: 0 3px 3px 0;
    background: var(--accent-primary, #3B82F6);
}
.settings-tab-icon { font-size: 16px; flex-shrink: 0; }
.settings-tab-label { flex: 1; }

.settings-nav-footer {
    padding: 12px;
    border-top: 1px solid var(--border-primary, rgba(255,255,255,0.06));
}
.settings-nav-save {
    width: 100%;
    padding: 10px 14px;
    border: none;
    border-radius: var(--radius-md, 10px);
    background: linear-gradient(135deg, var(--accent-primary, #3B82F6), #3B82F6);
    color: white;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s ease;
    font-family: inherit;
}
.settings-nav-save:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(59,130,246,0.35);
}

/* ── Content Area ── */
.settings-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.settings-content-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 24px;
    border-bottom: 1px solid var(--border-primary, rgba(255,255,255,0.06));
    flex-shrink: 0;
}
.settings-content-title {
    font-size: 17px;
    font-weight: 700;
    color: var(--text-primary, #e2e8f0);
    margin: 0;
}
.settings-content-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
    scrollbar-width: thin;
    scrollbar-color: var(--accent-primary, #3B82F6) transparent;
}
.settings-content-body::-webkit-scrollbar { width: 5px; }
.settings-content-body::-webkit-scrollbar-thumb { background: var(--accent-primary, #3B82F6); border-radius: 3px; }
.settings-content-body::-webkit-scrollbar-track { background: transparent; }

/* ── Panels (tab content) ── */
.settings-panel {
    display: none;
    flex-direction: column;
    gap: 16px;
    animation: settingsFadeIn 0.25s ease;
}
.settings-panel.active { display: flex; }
@keyframes settingsFadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ── Cards ── */
.settings-card {
    background: var(--bg-glass, rgba(255,255,255,0.03));
    border: 1px solid var(--border-primary, rgba(255,255,255,0.06));
    border-radius: var(--radius-lg, 14px);
    padding: 16px;
    transition: border-color 0.2s;
}
.settings-card:hover { border-color: rgba(255,255,255,0.1); }
.settings-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}
.settings-card-header:last-child { margin-bottom: 0; }
.settings-card-icon {
    font-size: 24px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(59,130,246,0.1);
    border-radius: var(--radius-md, 10px);
    flex-shrink: 0;
}
.settings-card-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary, #e2e8f0);
}
.settings-card-desc {
    font-size: 12px;
    color: var(--text-tertiary, rgba(255,255,255,0.4));
    margin-top: 2px;
}

/* ── Tools Grid ── */
.settings-tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 10px;
    margin-bottom: 16px;
}
.settings-tool-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 16px 8px;
    border: 1px solid var(--border-primary, rgba(255,255,255,0.06));
    border-radius: var(--radius-lg, 14px);
    background: var(--bg-glass, rgba(255,255,255,0.03));
    color: var(--text-primary, #e2e8f0);
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}
.settings-tool-card:hover {
    background: rgba(59,130,246,0.12);
    border-color: rgba(59,130,246,0.3);
    transform: translateY(-2px);
}
.settings-tool-icon { font-size: 24px; }
.settings-tool-name {
    font-size: 11px;
    font-weight: 500;
    text-align: center;
    line-height: 1.3;
}

/* ── Backup ── */
.settings-backup-row {
    display: flex;
    gap: 10px;
    margin-top: 4px;
}
.settings-backup-btn {
    flex: 1;
    padding: 10px 16px;
    border: 1px solid var(--border-primary, rgba(255,255,255,0.06));
    border-radius: var(--radius-md, 10px);
    background: var(--bg-glass, rgba(255,255,255,0.03));
    color: var(--text-primary, #e2e8f0);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
    font-family: inherit;
}
.settings-backup-btn:hover {
    background: rgba(59,130,246,0.12);
    border-color: rgba(59,130,246,0.3);
}
.settings-backup-btn svg { opacity: 0.7; }

/* ── Persona create row ── */
.persona-create-row {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}
.persona-icon-input { width: 70px !important; flex-shrink: 0; text-align: center; font-size: 18px !important; }
.persona-name-input { flex: 1; }

/* ── Existing shared elements ── */
.settings-action-btn {
    display: block; width: 100%; padding: 10px 16px; margin-bottom: 6px;
    border-radius: 10px; border: 1px solid var(--border-primary, rgba(255,255,255,0.06));
    background: var(--bg-glass, rgba(255,255,255,0.03)); color: var(--text-primary, #eee);
    font-size: 13px; text-align: left; cursor: pointer; transition: all 0.2s;
}
.settings-action-btn:hover { background: rgba(59,130,246,0.15); border-color: rgba(59,130,246,0.3); }
.settings-action-btn:last-child { margin-bottom: 0; }

.setting-textarea {
    width: 100%; box-sizing: border-box; padding: 10px 12px;
    border-radius: var(--radius-md, 10px); background: rgba(0,0,0,0.2);
    border: 1px solid var(--border-primary, rgba(255,255,255,0.06));
    color: var(--text-primary, #eee); font-size: 13px; font-family: inherit;
    resize: vertical; outline: none; transition: border-color 0.2s;
}
.setting-textarea:focus { border-color: var(--accent-primary, #3B82F6); }

/* ── Mobile Save Button (hidden on desktop, shown on mobile) ── */
.settings-mobile-save {
    display: none;
}

/* ═══ SETTINGS RESPONSIVE ═══ */
@media (max-width: 768px) {
    .settings-modal { max-width: 100%; width: 100%; max-height: 90vh; border-radius: var(--radius-lg, 14px) var(--radius-lg, 14px) 0 0; }
    .settings-nav { width: 170px; min-width: 170px; }
    .settings-nav-title { font-size: 16px; }
    .settings-tab { padding: 9px 10px; font-size: 12px; gap: 8px; }
    .settings-tab-icon { font-size: 14px; }
    .settings-content-body { padding: 16px; }
    .settings-tools-grid { grid-template-columns: repeat(3, 1fr); gap: 8px; }
}
@media (max-width: 600px) {
    .settings-modal { border-radius: 0; max-height: 100vh; max-height: 100dvh; }
    .settings-layout { flex-direction: column; }
    .settings-nav { width: 100%; min-width: 100%; border-right: none; border-bottom: 1px solid var(--border-primary, rgba(255,255,255,0.06)); background: transparent; }
    .settings-nav-header { padding: 14px 16px 8px; }
    .settings-close-mobile { display: flex; }
    .settings-content-header { display: none; }
    .settings-tabs { flex-direction: row; overflow-x: auto; overflow-y: hidden; padding: 0 12px 10px; gap: 4px; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
    .settings-tabs::-webkit-scrollbar { display: none; }
    .settings-tab { flex-shrink: 0; flex-direction: column; gap: 4px; padding: 8px 12px; min-width: 60px; text-align: center; font-size: 10px; }
    .settings-tab.active::before { display: none; }
    .settings-tab.active { background: rgba(59,130,246,0.2); }
    .settings-tab-icon { font-size: 18px; }
    .settings-nav-footer { display: none; }
    .settings-content-body { padding: 14px; max-height: calc(100vh - 190px); max-height: calc(100dvh - 190px); }
    .settings-card { padding: 14px; }
    .settings-card-icon { width: 36px; height: 36px; font-size: 20px; }
    .settings-tools-grid { grid-template-columns: repeat(3, 1fr); gap: 8px; }
    .settings-tool-card { padding: 12px 6px; }
    .settings-tool-icon { font-size: 20px; }
    .settings-tool-name { font-size: 10px; }
    .settings-backup-row { flex-direction: column; }

    /* Show mobile save button */
    .settings-mobile-save {
        display: block;
        flex-shrink: 0;
        padding: 12px 14px;
        padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
        border-top: 1px solid var(--border-primary, rgba(255,255,255,0.06));
        background: var(--bg-secondary, #111111);
    }
    .settings-mobile-save-btn {
        width: 100%;
        padding: 12px 16px;
        border: none;
        border-radius: var(--radius-md, 10px);
        background: linear-gradient(135deg, var(--accent-primary, #3B82F6), #3B82F6);
        color: white;
        font-size: 14px;
        font-weight: 600;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        transition: all 0.2s ease;
        font-family: inherit;
        -webkit-tap-highlight-color: transparent;
    }
    .settings-mobile-save-btn:active {
        transform: scale(0.97);
        opacity: 0.9;
    }
}
@media (max-width: 375px) {
    .settings-tab { min-width: 50px; padding: 6px 8px; }
    .settings-tab-label { font-size: 9px; }
    .settings-tools-grid { grid-template-columns: repeat(2, 1fr); }
}

/* Focus mode transition */
body { transition: none; }
body.focus-mode .sidebar { transition: transform 0.3s ease; }

/* Light theme */
[data-theme="light"] .settings-nav { background: rgba(0,0,0,0.03); }
[data-theme="light"] .settings-card { background: rgba(0,0,0,0.02); border-color: #d2d2d7; }
[data-theme="light"] .settings-card:hover { border-color: #bbb; }
[data-theme="light"] .settings-tool-card { background: rgba(0,0,0,0.02); border-color: #d2d2d7; }
[data-theme="light"] .settings-tool-card:hover { background: rgba(59,130,246,0.08); }
[data-theme="light"] .settings-tab.active { background: rgba(59,130,246,0.1); }
[data-theme="light"] .settings-action-btn { background: #f0f0f5; color: #1d1d1f; border-color: #d2d2d7; }
[data-theme="light"] .settings-backup-btn { background: #f5f5f7; border-color: #d2d2d7; color: #1d1d1f; }
[data-theme="light"] .settings-mobile-save { background: #f5f5f7; border-top-color: #d2d2d7; }
[data-theme="light"] .setting-textarea { background: #f5f5f7; border-color: #d2d2d7; color: #1d1d1f; }
[data-theme="light"] .stat-card { background: #f0f0f5; border-color: #d2d2d7; }
[data-theme="light"] .memory-item { background: #f0f0f5; border-color: #d2d2d7; }
[data-theme="light"] .template-chip { background: #f0f0f5; border-color: #d2d2d7; color: #1d1d1f; }
[data-theme="light"] .shortcut-row { border-bottom-color: #d2d2d7; }
[data-theme="light"] .shortcut-row kbd { background: #f0f0f5; border-color: #d2d2d7; color: #6e6e73; }

/* --- NON-SETTINGS RESPONSIVE --- */
@media (max-width: 768px) {
    .dashboard-grid { grid-template-columns: repeat(2, 1fr); }
    .stat-card { padding: 12px 8px; }
    .stat-value { font-size: 18px; }
    .accent-dot { width: 28px; height: 28px; }
    .topbar-theme-btn, .topbar-share-btn { width: 32px; height: 32px; font-size: 14px; }
}
@media (max-width: 480px) {
    .dashboard-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
    .stat-card { padding: 10px 6px; }
    .stat-value { font-size: 16px; }
    .stat-label { font-size: 10px; }
    .font-size-control { gap: 8px; }
    .font-btn { width: 32px; height: 32px; }
    .template-chip { font-size: 11px; padding: 4px 10px; }
    .shortcuts-list { font-size: 12px; }
    .shortcut-row kbd { font-size: 10px; padding: 2px 5px; }
    .shortcut-row span { font-size: 12px; }
    .topbar-theme-btn, .topbar-share-btn { width: 28px; height: 28px; font-size: 12px; }
    .video-controls { gap: 6px; }
    .video-ctrl-btn { width: 38px; height: 38px; font-size: 14px; }
    .video-play-btn { width: 48px; height: 48px; font-size: 18px; }
    .music-stop-btn { width: 100%; }
    .accent-picker { gap: 6px; }
    .accent-dot { width: 26px; height: 26px; }
    .memory-add-row { flex-direction: column; }
    .memory-add-row .setting-input, .memory-add-row .btn-add { width: 100%; }
}
@media (max-width: 360px) {
    .dashboard-grid { grid-template-columns: 1fr 1fr; gap: 6px; }
    .stat-card { padding: 8px 4px; }
    .stat-icon { font-size: 18px; }
    .stat-value { font-size: 14px; }
}

/* Light theme — non-settings */
[data-theme="light"] .music-mood-label { background: #f0f0f5; color: #1d1d1f; }
[data-theme="light"] .video-ctrl-btn { background: #f0f0f5; border-color: #d2d2d7; color: #1d1d1f; }
[data-theme="light"] .video-frame-counter { background: rgba(255,255,255,0.8); color: #1d1d1f; }





















[data-theme="light"] .video-frame-counter { background: rgba(255,255,255,0.8); color: #1d1d1f; }


/* --- TIC-TAC-TOE --- */
.ttt-grid {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px;
    max-width: 240px; margin: 16px auto;
}
.ttt-cell {
    width: 72px; height: 72px; border-radius: 12px;
    border: 2px solid var(--border-color, #333);
    background: var(--bg-primary, #0d0d1a); color: var(--text-primary, #eee);
    font-size: 28px; font-weight: 700; cursor: pointer; transition: all 0.15s;
}
.ttt-cell:hover:not(:disabled) { border-color: var(--accent, #3B82F6); background: rgba(59,130,246,0.1); }
.ttt-cell.x { color: var(--accent, #3B82F6); }
.ttt-cell.o { color: #e17055; }
.ttt-cell:disabled { cursor: default; }
.ttt-status {
    font-size: 16px; font-weight: 600; color: var(--accent, #3B82F6);
    margin-bottom: 8px;
}

/* --- TODO LIST --- */
.todo-add-row {
    display: flex; gap: 8px; margin-bottom: 12px;
}
.todo-add-row .setting-input { flex: 1; }
.todo-list { display: flex; flex-direction: column; gap: 6px; max-height: 300px; overflow-y: auto; }
.todo-item {
    display: flex; align-items: center; gap: 8px; padding: 8px 12px;
    background: var(--bg-primary, #0d0d1a); border-radius: 10px;
    border: 1px solid var(--border-color, #333); transition: all 0.2s;
}
.todo-item.done .todo-text { text-decoration: line-through; opacity: 0.5; }
.todo-check { background: none; border: none; font-size: 16px; cursor: pointer; padding: 0; }
.todo-text { flex: 1; font-size: 13px; color: var(--text-primary, #eee); }
.todo-delete {
    width: 24px; height: 24px; border: none; background: none;
    color: var(--text-tertiary, #666); cursor: pointer; font-size: 14px; border-radius: 4px;
}
.todo-delete:hover { color: #d63031; background: rgba(214,48,49,0.1); }

/* --- QR CODE --- */
.qr-image { margin: 16px auto; display: block; border-radius: 12px; border: 2px solid var(--border-color, #333); }
.qr-download-link {
    display: inline-block; margin-top: 10px; padding: 8px 20px; border-radius: 10px;
    background: var(--accent, #3B82F6); color: white; text-decoration: none;
    font-size: 13px; transition: all 0.2s;
}
.qr-download-link:hover { opacity: 0.8; }

/* --- POMODORO TIMER --- */
.pom-timer {
    font-size: 64px; font-weight: 700; color: var(--accent, #3B82F6);
    font-family: 'Courier New', monospace; letter-spacing: 4px; margin: 16px 0;
}
.pom-mode-label {
    font-size: 16px; font-weight: 600; color: var(--text-secondary, #aaa);
    margin-bottom: 4px;
}
.pom-controls { display: flex; gap: 10px; justify-content: center; }
.pom-btn { padding: 10px 24px; font-size: 14px; }
.pom-reset { background: transparent; border: 1px solid var(--border-color, #555); color: var(--text-primary, #eee); }
.pom-reset:hover { background: rgba(255,255,255,0.05); }

/* --- LIGHT THEME --- */
[data-theme="light"] .followup-chip { background: #fff; border-color: #d2d2d7; color: #1d1d1f; }
[data-theme="light"] .ttt-cell { background: #f0f0f5; border-color: #d2d2d7; color: #1d1d1f; }
[data-theme="light"] .todo-item { background: #f0f0f5; border-color: #d2d2d7; }
[data-theme="light"] .todo-text { color: #1d1d1f; }
[data-theme="light"] .qr-image { border-color: #d2d2d7; }
[data-theme="light"] .pom-reset { border-color: #d2d2d7; color: #1d1d1f; }

/* --- MOBILE --- */
@media (max-width: 480px) {
    .followup-chip { font-size: 11px; padding: 5px 10px; }
    .ttt-cell { width: 60px; height: 60px; font-size: 24px; }
    .pom-timer { font-size: 48px; }
    .pom-btn { padding: 8px 16px; font-size: 13px; }
}

/* --- READING MODE --- */
.reading-mode-overlay {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; z-index: 1000;
    background: var(--bg-primary, #0d0d1a);
    display: flex; flex-direction: column;
    animation: fadeIn 0.25s ease;
}
.reading-mode-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 24px; border-bottom: 1px solid var(--border-color, #222);
    font-size: 16px; font-weight: 600; color: var(--text-primary, #eee);
}
.reading-mode-content {
    flex: 1; overflow-y: auto; padding: 32px; max-width: 720px; margin: 0 auto; width: 100%;
    font-size: 17px; line-height: 1.8; color: var(--text-primary, #eee);
}
.reading-mode-content h1, .reading-mode-content h2, .reading-mode-content h3 {
    color: var(--accent, #3B82F6); margin-top: 24px;
}
.reading-mode-content pre { border-radius: 10px; overflow-x: auto; }
.reading-mode-content code { font-size: 14px; }
.reading-mode-content p { margin-bottom: 16px; }
.reading-mode-content ul, .reading-mode-content ol { padding-left: 24px; margin-bottom: 16px; }
.reading-mode-content li { margin-bottom: 6px; }
.reading-mode-content blockquote {
    border-left: 3px solid var(--accent, #3B82F6); padding-left: 16px;
    margin: 16px 0; opacity: 0.85; font-style: italic;
}

/* --- CHART MODAL --- */
#chartCanvas { max-width: 100%; height: auto; }

/* --- LIGHT THEME --- */
[data-theme="light"] .reading-mode-overlay { background: #fff; }
[data-theme="light"] .reading-mode-content { color: #1d1d1f; }
[data-theme="light"] .reading-mode-header { border-bottom-color: #d2d2d7; color: #1d1d1f; }

/* --- MOBILE --- */
@media (max-width: 480px) {
    .reading-mode-content { padding: 16px; font-size: 15px; }
    .reading-mode-header { padding: 12px 16px; }
}

/* ============================================
   EXTENDED FEATURES STYLES
   ============================================ */

/* --- GLOBAL SEARCH --- */
.global-search-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 9999;
    display: flex;
    justify-content: center;
    padding-top: 12vh;
    animation: fadeIn 0.2s ease;
}
.global-search-box {
    width: 560px;
    max-width: 92vw;
    background: var(--bg-secondary, #111111);
    border: 1px solid var(--border-secondary, rgba(255,255,255,0.1));
    border-radius: var(--radius-lg, 16px);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    max-height: 70vh;
    display: flex;
    flex-direction: column;
}
.global-search-input {
    width: 100%;
    padding: 18px 20px;
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--border-primary, rgba(255,255,255,0.06));
    color: var(--text-primary, #FFFFFF);
    font-family: var(--font-primary);
    font-size: 16px;
    outline: none;
}
.global-search-input::placeholder { color: var(--text-tertiary, #71717A); }
.global-search-results {
    overflow-y: auto;
    max-height: 55vh;
    padding: 8px;
}
.global-search-result {
    padding: 12px 14px;
    border-radius: var(--radius-sm, 8px);
    cursor: pointer;
    transition: background 0.15s ease;
}
.global-search-result:hover {
    background: rgba(59, 130, 246, 0.1);
}
.gs-title {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 3px;
    color: var(--text-primary, #FFFFFF);
}
.gs-preview {
    font-size: 12px;
    color: var(--text-tertiary, #71717A);
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* --- SLASH COMMANDS --- */
.slash-dropdown {
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    background: var(--bg-secondary, #111111);
    border: 1px solid var(--border-secondary, rgba(255,255,255,0.1));
    border-radius: var(--radius-md, 12px);
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.4);
    padding: 6px;
    display: none;
    z-index: 50;
    max-height: 320px;
    overflow-y: auto;
    margin-bottom: 8px;
}
.slash-dropdown.show { display: block; animation: fadeIn 0.15s ease; }
.slash-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm, 8px);
    cursor: pointer;
    font-size: 13px;
    color: var(--text-primary, #FFFFFF);
    transition: background 0.15s ease;
}
.slash-option:hover {
    background: rgba(59, 130, 246, 0.12);
}
.slash-cmd {
    font-family: var(--font-mono, monospace);
    font-weight: 600;
    color: var(--accent-primary, #3B82F6);
}

/* --- DOCUMENT UPLOAD INDICATOR --- */
.doc-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: rgba(59, 130, 246, 0.08);
    border: 1px solid rgba(59, 130, 246, 0.2);
    border-radius: var(--radius-md, 12px);
    font-size: 13px;
    color: var(--text-primary, #FFFFFF);
    margin-bottom: 8px;
}
.doc-indicator button {
    background: none;
    border: none;
    color: var(--text-tertiary, #71717A);
    cursor: pointer;
    font-size: 14px;
    padding: 2px 6px;
    border-radius: 4px;
    transition: all 0.15s;
}
.doc-indicator button:hover { color: var(--danger, #ef4444); }

/* --- OVERFLOW MENU --- */
.overflow-menu {
    position: absolute;
    top: 100%;
    right: 0;
    min-width: 200px;
    background: var(--bg-secondary, #111111);
    border: 1px solid var(--border-secondary, rgba(255,255,255,0.1));
    border-radius: var(--radius-md, 12px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    padding: 6px;
    z-index: 100;
    animation: fadeIn 0.15s ease;
}
.overflow-menu.hidden { display: none; }
.overflow-menu button {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 10px 14px;
    background: none;
    border: none;
    border-radius: var(--radius-sm, 8px);
    color: var(--text-primary, #FFFFFF);
    font-family: var(--font-primary);
    font-size: 13px;
    cursor: pointer;
    transition: background 0.15s ease;
    text-align: left;
}
.overflow-menu button:hover {
    background: rgba(59, 130, 246, 0.1);
}

/* --- IN-CHAT SEARCH --- */
.in-chat-search {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--bg-secondary, #111111);
    border-bottom: 1px solid var(--border-primary, rgba(255,255,255,0.06));
}
.in-chat-search.open { display: flex; }
.in-chat-search input {
    flex: 1;
    padding: 7px 12px;
    background: var(--bg-glass, rgba(255,255,255,0.03));
    border: 1px solid var(--border-secondary, rgba(255,255,255,0.1));
    border-radius: var(--radius-sm, 8px);
    color: var(--text-primary, #FFFFFF);
    font-family: var(--font-primary);
    font-size: 13px;
    outline: none;
}
.in-chat-search input:focus { border-color: var(--accent-primary, #3B82F6); }
.search-count {
    font-size: 12px;
    color: var(--text-tertiary, #71717A);
    white-space: nowrap;
}
.message.search-highlight {
    background: rgba(59, 130, 246, 0.08) !important;
    border-left: 3px solid var(--accent-primary, #3B82F6);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    padding-left: 12px;
}

/* --- MARKDOWN TABLES --- */
.table-wrapper {
    overflow-x: auto;
    margin: 12px 0;
    border-radius: var(--radius-sm, 8px);
    border: 1px solid var(--border-primary, rgba(255,255,255,0.06));
}
.md-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.md-table th {
    padding: 10px 14px;
    background: rgba(59, 130, 246, 0.08);
    border-bottom: 2px solid var(--border-accent, rgba(124,58,237,0.3));
    text-align: left;
    font-weight: 600;
    color: var(--text-primary, #FFFFFF);
    white-space: nowrap;
}
.md-table td {
    padding: 8px 14px;
    border-bottom: 1px solid var(--border-primary, rgba(255,255,255,0.06));
    color: var(--text-secondary, #A1A1AA);
}
.md-table tr:last-child td { border-bottom: none; }
.md-table tr:hover td { background: rgba(255,255,255,0.02); }

/* --- PIN/LOCK BUTTONS --- */
.pin-btn, .lock-btn {
    opacity: 0;
    flex-shrink: 0;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    font-size: 12px;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    color: var(--text-tertiary, #71717A);
}
.history-item:hover .pin-btn,
.history-item:hover .lock-btn { opacity: 0.7; }
.pin-btn:hover, .lock-btn:hover { opacity: 1 !important; }
.history-item.pinned .pin-btn { opacity: 1; color: var(--accent-primary, #3B82F6); }
.history-item.locked .lock-btn { opacity: 1; }
.pinned-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--accent-primary, #3B82F6);
    padding: 8px 8px 6px;
}

/* --- WEBCAM --- */
.webcam-modal { text-align: center; }
.webcam-actions {
    display: flex;
    gap: 10px;
    margin-top: 12px;
    align-items: center;
}

/* --- MESSAGE REACTIONS --- */
.message-reactions {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    flex-wrap: wrap;
}
.reaction-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 3px 8px;
    background: var(--bg-glass, rgba(255,255,255,0.03));
    border: 1px solid var(--border-primary, rgba(255,255,255,0.06));
    border-radius: var(--radius-full, 9999px);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s;
}
.reaction-badge:hover, .reaction-badge.active {
    background: rgba(59, 130, 246, 0.1);
    border-color: var(--border-accent, rgba(124,58,237,0.3));
}
.reaction-add-btn {
    background: none;
    border: 1px dashed var(--border-primary, rgba(255,255,255,0.06));
    border-radius: var(--radius-full, 9999px);
    color: var(--text-tertiary, #71717A);
    cursor: pointer;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    transition: all 0.15s;
}
.reaction-add-btn:hover {
    border-color: var(--accent-primary, #3B82F6);
    color: var(--text-primary, #FFFFFF);
}
.reaction-picker {
    display: flex;
    gap: 4px;
    padding: 6px 8px;
    background: var(--bg-secondary, #111111);
    border: 1px solid var(--border-secondary, rgba(255,255,255,0.1));
    border-radius: var(--radius-full, 9999px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    animation: fadeIn 0.15s ease;
}
.reaction-pick-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 18px;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.15s;
}
.reaction-pick-btn:hover { transform: scale(1.3); }

/* --- MESSAGE ACTIONS --- */
.message-actions {
    display: flex;
    gap: 4px;
    margin-top: 8px;
    opacity: 0;
    transition: opacity 0.2s ease;
}
.message:hover .message-actions { opacity: 1; }
.msg-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: var(--bg-glass, rgba(255,255,255,0.03));
    border: 1px solid var(--border-primary, rgba(255,255,255,0.06));
    border-radius: var(--radius-full, 9999px);
    color: var(--text-tertiary, #71717A);
    font-family: var(--font-primary);
    font-size: 11px;
    cursor: pointer;
    transition: all 0.15s;
}
.msg-action-btn:hover {
    background: rgba(59, 130, 246, 0.1);
    border-color: var(--border-accent, rgba(124,58,237,0.3));
    color: var(--text-primary, #FFFFFF);
}
.msg-action-btn.speaking {
    background: rgba(59, 130, 246, 0.15);
    border-color: var(--accent-primary, #3B82F6);
    color: var(--accent-primary, #3B82F6);
}

/* --- EDIT MESSAGE --- */
.edit-textarea {
    width: 100%;
    padding: 12px;
    background: var(--bg-glass, rgba(255,255,255,0.03));
    border: 1px solid var(--accent-primary, #3B82F6);
    border-radius: var(--radius-sm, 8px);
    color: var(--text-primary, #FFFFFF);
    font-family: var(--font-primary);
    font-size: 14px;
    line-height: 1.6;
    resize: vertical;
    min-height: 60px;
    outline: none;
}
.edit-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}
.edit-save-btn, .edit-cancel-btn {
    padding: 6px 16px;
    border-radius: var(--radius-full, 9999px);
    border: none;
    cursor: pointer;
    font-family: var(--font-primary);
    font-size: 12px;
    font-weight: 600;
    transition: all 0.15s;
}
.edit-save-btn {
    background: var(--accent-gradient, linear-gradient(135deg, #3B82F6, #2563EB));
    color: white;
}
.edit-save-btn:hover { opacity: 0.9; }
.edit-cancel-btn {
    background: var(--bg-glass, rgba(255,255,255,0.03));
    border: 1px solid var(--border-primary, rgba(255,255,255,0.06));
    color: var(--text-secondary, #A1A1AA);
}
.edit-cancel-btn:hover { color: var(--text-primary, #FFFFFF); }

/* --- RESPONSE TIMER --- */
.response-timer {
    font-size: 11px;
    color: var(--text-tertiary, #71717A);
    margin-top: 6px;
    font-weight: 500;
}

/* ── SmartContext Source Pill ── */
.smart-sources {
    max-width: var(--content-max, 820px);
    margin: 0 auto 8px;
    width: 100%;
    padding: 0 20px;
}

.smart-sources-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 14px;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.08), rgba(37, 99, 235, 0.06));
    border: 1px solid rgba(59, 130, 246, 0.15);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.25s ease;
    user-select: none;
}

.smart-sources-header:hover {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.14), rgba(37, 99, 235, 0.1));
    border-color: rgba(59, 130, 246, 0.25);
}

.smart-sources-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.smart-sources-icons {
    font-size: 14px;
    letter-spacing: 2px;
}

.smart-sources-label {
    font-size: 12px;
    font-weight: 600;
    color: rgba(167, 139, 250, 0.9);
    letter-spacing: 0.02em;
}

.smart-sources-chevron {
    color: rgba(167, 139, 250, 0.5);
    transition: transform 0.3s ease;
    flex-shrink: 0;
}

.smart-sources.expanded .smart-sources-chevron {
    transform: rotate(180deg);
}

.smart-sources.expanded .smart-sources-header {
    border-radius: 12px 12px 0 0;
    border-bottom-color: transparent;
}

.smart-sources-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s ease, padding 0.35s ease;
    background: rgba(59, 130, 246, 0.04);
    border: 1px solid rgba(59, 130, 246, 0.15);
    border-top: none;
    border-radius: 0 0 12px 12px;
}

.smart-sources.expanded .smart-sources-body {
    max-height: 300px;
    padding: 6px 8px;
}

.smart-source-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border-radius: 8px;
    transition: background 0.2s;
}

.smart-source-item:hover {
    background: rgba(255, 255, 255, 0.04);
}

.smart-source-icon {
    font-size: 14px;
    width: 22px;
    text-align: center;
    flex-shrink: 0;
}

.smart-source-label {
    font-size: 12px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.7);
}

.smart-source-detail {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.35);
    margin-left: auto;
    text-align: right;
    max-width: 180px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* --- FOLLOW-UP CHIPS CONTAINER --- */
.followup-container {
    display: flex;
    gap: 8px;
    padding: 8px 20px;
    overflow-x: auto;
    max-width: var(--content-max, 820px);
    margin: 0 auto;
    width: 100%;
}
.followup-container.hidden { display: none; }
.followup-chip {
    flex-shrink: 0;
    padding: 8px 16px;
    background: var(--bg-glass, rgba(255,255,255,0.03));
    border: 1px solid var(--border-secondary, rgba(255,255,255,0.1));
    border-radius: var(--radius-full, 9999px);
    color: var(--text-secondary, #A1A1AA);
    font-family: var(--font-primary);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}
.followup-chip:hover {
    background: rgba(59, 130, 246, 0.1);
    border-color: var(--border-accent, rgba(124,58,237,0.3));
    color: var(--text-primary, #FFFFFF);
    transform: translateY(-1px);
}

/* --- NOTES PANEL --- */
.notes-panel {
    display: none;
    padding: 0 20px;
    max-width: var(--content-max, 820px);
    width: 100%;
    margin: 0 auto;
}
.notes-panel.open { display: block; animation: fadeIn 0.2s ease; }
.notes-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary, #FFFFFF);
}
.notes-textarea {
    width: 100%;
    min-height: 100px;
    max-height: 200px;
    padding: 12px;
    background: var(--bg-glass, rgba(255,255,255,0.03));
    border: 1px solid var(--border-secondary, rgba(255,255,255,0.1));
    border-radius: var(--radius-md, 12px);
    color: var(--text-primary, #FFFFFF);
    font-family: var(--font-primary);
    font-size: 13px;
    line-height: 1.6;
    resize: vertical;
    outline: none;
    margin-bottom: 12px;
}
.notes-textarea:focus { border-color: var(--accent-primary, #3B82F6); }

/* --- CUSTOM PERSONA LIST --- */
.custom-personas-list { display: flex; flex-direction: column; gap: 6px; }
.custom-persona-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: var(--bg-glass, rgba(255,255,255,0.03));
    border: 1px solid var(--border-primary, rgba(255,255,255,0.06));
    border-radius: var(--radius-sm, 8px);
}
.persona-item-icon { font-size: 20px; }
.persona-item-name { flex: 1; font-size: 13px; font-weight: 500; }
.persona-use-btn, .persona-del-btn {
    padding: 4px 12px;
    border-radius: var(--radius-full, 9999px);
    border: none;
    cursor: pointer;
    font-family: var(--font-primary);
    font-size: 11px;
    font-weight: 600;
    transition: all 0.15s;
}
.persona-use-btn {
    background: var(--accent-gradient, linear-gradient(135deg, #3B82F6, #2563EB));
    color: white;
}
.persona-use-btn:hover { opacity: 0.9; }
.persona-del-btn {
    background: none;
    border: 1px solid var(--border-primary);
    color: var(--text-tertiary, #71717A);
}
.persona-del-btn:hover { color: var(--danger, #ef4444); border-color: var(--danger); }

/* --- MESSAGE IMAGE --- */
.message-image {
    max-width: 300px;
    max-height: 250px;
    border-radius: var(--radius-md, 12px);
    margin: 8px 0;
    border: 1px solid var(--border-primary, rgba(255,255,255,0.06));
}

/* --- GENERATED IMAGE CONTAINER (for inline AI images) --- */
.generated-image-container {
    position: relative;
    display: inline-block;
    margin: 10px 0;
    border-radius: var(--radius-md, 12px);
    overflow: hidden;
    border: 1px solid var(--border-primary, rgba(255,255,255,0.06));
}
.generated-image-container img {
    display: block;
    max-width: 100%;
    max-height: 400px;
    border-radius: var(--radius-md, 12px);
}
.generated-image-label {
    font-size: 11px;
    color: var(--text-tertiary, #71717A);
    padding: 6px 10px;
    text-align: center;
}
.image-download-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    transition: all 0.15s;
}
.image-download-btn:hover { background: rgba(0,0,0,0.7); }

/* --- SIDEBAR SEARCH --- */
.sidebar-search {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 12px 12px;
    padding: 8px 12px;
    background: var(--bg-glass, rgba(255,255,255,0.03));
    border: 1px solid var(--border-primary, rgba(255,255,255,0.06));
    border-radius: var(--radius-sm, 8px);
    color: var(--text-tertiary, #71717A);
}
.sidebar-search input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary, #FFFFFF);
    font-family: var(--font-primary);
    font-size: 13px;
    outline: none;
}
.sidebar-search input::placeholder { color: var(--text-tertiary, #71717A); }

/* --- TOPBAR SHARE / OVERFLOW --- */
.topbar-share-btn {
    font-size: 16px !important;
    padding: 8px !important;
}

/* --- LIGHT THEME EXTENDED --- */
[data-theme="light"] .global-search-box { background: #fff; border-color: #d2d2d7; }
[data-theme="light"] .global-search-input { color: #1d1d1f; }
[data-theme="light"] .slash-dropdown { background: #fff; border-color: #d2d2d7; }
[data-theme="light"] .slash-option { color: #1d1d1f; }
[data-theme="light"] .overflow-menu { background: #fff; border-color: #d2d2d7; }
[data-theme="light"] .overflow-menu button { color: #1d1d1f; }
[data-theme="light"] .in-chat-search { background: #f5f5f7; }
[data-theme="light"] .in-chat-search input { background: #fff; border-color: #d2d2d7; color: #1d1d1f; }
[data-theme="light"] .md-table th { background: rgba(124,58,237,0.05); }
[data-theme="light"] .md-table td { color: #1d1d1f; }
[data-theme="light"] .doc-indicator { background: rgba(124,58,237,0.05); border-color: rgba(124,58,237,0.15); }
[data-theme="light"] .edit-textarea { background: #fff; border-color: var(--accent-primary); color: #1d1d1f; }
[data-theme="light"] .notes-textarea { background: #fff; border-color: #d2d2d7; color: #1d1d1f; }

/* ══════════════════════════════════════════════════════
   Q-VIDEO ENGINE v3.0 — CINEMATIC GRADE STYLES
   ══════════════════════════════════════════════════════ */
/* ═══════════════════════════════════════════
   Q-VIDEO ENGINE v3.0 — Premium UI
   ═══════════════════════════════════════════ */
.qvideo-modal {
    max-width: 660px;
    width: 95vw;
    max-height: 90vh;
    padding: 0;
    overflow: hidden;
    border-radius: var(--radius-xl, 20px);
    border: 1px solid rgba(59, 130, 246, 0.15);
}

/* ── Header ── */
.qvideo-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: linear-gradient(135deg, rgba(59,130,246,0.08), rgba(37, 99, 235,0.04));
    border-bottom: 1px solid var(--border-primary, rgba(255,255,255,0.06));
}
.qvideo-title-group {
    display: flex;
    align-items: center;
    gap: 12px;
}
.qvideo-logo {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #3B82F6, #3B82F6);
    border-radius: var(--radius-md, 10px);
    color: white;
    flex-shrink: 0;
}
.qvideo-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary, #e2e8f0);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}
.qvideo-badge {
    font-size: 9px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 20px;
    background: linear-gradient(135deg, #3B82F6, #2563EB);
    color: #fff;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}
.qvideo-subtitle {
    font-size: 11px;
    color: var(--text-tertiary, rgba(255,255,255,0.4));
    font-weight: 500;
    display: block;
}

/* ── Body ── */
.qvideo-body {
    padding: 20px;
    overflow-y: auto;
    max-height: calc(90vh - 72px);
    scrollbar-width: thin;
    scrollbar-color: #3B82F6 transparent;
}
.qvideo-body::-webkit-scrollbar { width: 4px; }
.qvideo-body::-webkit-scrollbar-thumb { background: #3B82F6; border-radius: 2px; }

/* ── Prompt Card ── */
.qvideo-prompt-card {
    background: var(--bg-glass, rgba(255,255,255,0.03));
    border: 1px solid var(--border-primary, rgba(255,255,255,0.06));
    border-radius: var(--radius-lg, 14px);
    padding: 16px;
    margin-bottom: 16px;
}
.qvideo-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary, rgba(255,255,255,0.6));
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 10px;
}
.qvideo-label svg { opacity: 0.5; }
.qvideo-textarea {
    width: 100%;
    box-sizing: border-box;
    padding: 12px 14px;
    border-radius: var(--radius-md, 10px);
    background: rgba(0,0,0,0.25);
    border: 1px solid var(--border-primary, rgba(255,255,255,0.06));
    color: var(--text-primary, #e2e8f0);
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    outline: none;
    transition: border-color 0.2s;
    line-height: 1.5;
}
.qvideo-textarea::placeholder { color: var(--text-tertiary, rgba(255,255,255,0.25)); }
.qvideo-textarea:focus { border-color: #3B82F6; box-shadow: 0 0 0 3px rgba(59,130,246,0.1); }

/* ── Controls Grid ── */
.qvideo-controls-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px;
    margin-bottom: 16px;
}
.qvideo-setting-card {
    background: var(--bg-glass, rgba(255,255,255,0.03));
    border: 1px solid var(--border-primary, rgba(255,255,255,0.06));
    border-radius: var(--radius-md, 10px);
    padding: 12px;
}
.qvideo-setting-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary, rgba(255,255,255,0.6));
    margin-bottom: 8px;
    display: block;
}
.qvideo-select {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border-primary, rgba(255,255,255,0.08));
    border-radius: 8px;
    background: rgba(0,0,0,0.2);
    color: var(--text-primary, #e2e8f0);
    font-size: 12px;
    font-family: inherit;
    outline: none;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
}
.qvideo-select:focus { border-color: #3B82F6; }

/* ── Generate Button ── */
.qvideo-generate-btn {
    width: 100%;
    padding: 14px 20px;
    border: none;
    border-radius: var(--radius-md, 10px);
    background: linear-gradient(135deg, #3B82F6 0%, #3B82F6 50%, #2563EB 100%);
    background-size: 200% 100%;
    color: #fff;
    font-family: inherit;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.4s ease;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(59, 130, 246, 0.3);
}
.qvideo-generate-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.15), transparent);
    transform: translateX(-100%);
    transition: transform 0.6s ease;
}
.qvideo-generate-btn:hover {
    background-position: 100% 0;
    transform: translateY(-1px);
    box-shadow: 0 8px 30px rgba(59, 130, 246, 0.4);
}
.qvideo-generate-btn:hover::before { transform: translateX(100%); }
.qvideo-generate-btn:disabled { opacity: 0.6; cursor: wait; transform: none; box-shadow: none; }

/* ── Progress ── */
.qvideo-progress {
    margin-top: 20px;
    padding: 20px;
    background: var(--bg-glass, rgba(255,255,255,0.03));
    border: 1px solid var(--border-primary, rgba(255,255,255,0.06));
    border-radius: var(--radius-lg, 14px);
}
.qvideo-progress-visual {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
}
.qvideo-progress-orb { flex-shrink: 0; }
.qvideo-progress-info { display: flex; flex-direction: column; gap: 4px; }
.qvideo-progress-text { font-size: 14px; font-weight: 600; color: var(--text-primary, #e2e8f0); }
.qvideo-progress-phase { font-size: 12px; color: var(--text-tertiary, rgba(255,255,255,0.4)); }
.qvideo-progress-bar {
    height: 6px;
    background: rgba(59,130,246,0.1);
    border-radius: 3px;
    overflow: hidden;
}
.qvideo-progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #3B82F6, #2563EB);
    border-radius: 3px;
    transition: width 0.4s ease;
}

/* ── Spinner (shared) ── */
.veo-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid rgba(59, 130, 246, 0.2);
    border-top: 3px solid #3B82F6;
    border-right: 3px solid #2563EB;
    border-radius: 50%;
    animation: veoSpin 1s linear infinite;
}
@keyframes veoSpin { to { transform: rotate(360deg); } }

/* ── Player (viewport, timeline, thumbnails — keep veo- prefix for deep JS coupling) ── */
.veo-player {
    margin-top: 20px;
    border-radius: var(--radius-lg, 14px);
    overflow: hidden;
    background: #000;
    border: 1px solid rgba(59, 130, 246, 0.15);
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.4);
}
.veo-player.veo-reveal { animation: veoReveal 0.6s ease-out; }
@keyframes veoReveal {
    from { opacity: 0; transform: scale(0.95) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}
.veo-viewport {
    position: relative;
    background: #0A0A0A;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
}
.veo-viewport canvas { display: block; max-width: 100%; }
.veo-frame-badge {
    position: absolute; top: 10px; left: 10px;
    padding: 4px 10px;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 20px;
    font-size: 11px; font-weight: 600; color: #fff;
    font-family: var(--font-mono, monospace);
}
.veo-fullscreen-btn {
    position: absolute; top: 10px; right: 10px;
    width: 32px; height: 32px;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 8px;
    color: #fff; font-size: 16px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.2s;
}
.veo-fullscreen-btn:hover { background: rgba(59,130,246,0.4); border-color: rgba(59,130,246,0.5); }
.veo-timeline {
    padding: 8px 16px 4px;
    background: rgba(0,0,0,0.3);
    display: flex; align-items: center; gap: 12px;
}
.veo-timeline-slider {
    -webkit-appearance: none; appearance: none;
    flex: 1; height: 4px;
    background: rgba(255,255,255,0.1);
    border-radius: 2px; outline: none; cursor: pointer;
}
.veo-timeline-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px; height: 14px; border-radius: 50%;
    background: linear-gradient(135deg, #3B82F6, #2563EB);
    cursor: pointer; box-shadow: 0 0 8px rgba(59,130,246,0.5);
    transition: transform 0.15s ease;
}
.veo-timeline-slider::-webkit-slider-thumb:hover { transform: scale(1.3); }
.veo-time-display {
    font-size: 11px; font-family: var(--font-mono, monospace);
    color: var(--text-tertiary, rgba(255,255,255,0.4));
    white-space: nowrap; min-width: 80px; text-align: right;
}
.veo-timeline-thumbs {
    display: flex; gap: 4px;
    padding: 8px 16px;
    background: rgba(0,0,0,0.2);
    overflow-x: auto;
}
.veo-timeline-thumbs::-webkit-scrollbar { height: 3px; }
.timeline-thumb {
    width: 48px; height: 32px;
    border-radius: 4px;
    background-size: cover; background-position: center;
    border: 2px solid transparent;
    cursor: pointer; flex-shrink: 0;
    transition: all 0.2s ease; opacity: 0.6;
}
.timeline-thumb:hover { opacity: 1; border-color: rgba(59,130,246,0.5); transform: scale(1.1); }
.timeline-thumb.active { opacity: 1; border-color: #3B82F6; box-shadow: 0 0 10px rgba(59,130,246,0.4); }

/* ── Playback Controls (redesigned) ── */
.qvideo-playback-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: rgba(0,0,0,0.4);
    border-top: 1px solid rgba(255,255,255,0.05);
    gap: 8px;
}
.qvideo-playback-left {
    display: flex;
    align-items: center;
    gap: 6px;
}
.qvideo-playback-right {
    display: flex;
    gap: 6px;
}
.qvideo-ctrl-btn {
    width: 36px; height: 36px;
    border: none; border-radius: 8px;
    background: rgba(255,255,255,0.08);
    color: #fff; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.2s;
}
.qvideo-ctrl-btn:hover { background: rgba(59,130,246,0.3); transform: scale(1.05); }
.qvideo-play-btn {
    width: 44px; height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3B82F6, #3B82F6);
    box-shadow: 0 0 16px rgba(59,130,246,0.4);
}
.qvideo-play-btn:hover { box-shadow: 0 0 24px rgba(59,130,246,0.6); transform: scale(1.1); }

/* Speed */
.qvideo-speed-wrap {
    display: flex; align-items: center; gap: 6px; margin-left: 4px;
}
.qvideo-speed-wrap label {
    font-size: 11px; color: var(--text-tertiary, rgba(255,255,255,0.4)); white-space: nowrap;
}
.qvideo-speed-slider {
    -webkit-appearance: none; appearance: none;
    width: 60px; height: 3px;
    background: rgba(255,255,255,0.1);
    border-radius: 2px; outline: none;
}
.qvideo-speed-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px; height: 12px;
    border-radius: 50%; background: #3B82F6; cursor: pointer;
}

/* Action Buttons */
.qvideo-action-btn {
    padding: 8px 14px;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 8px;
    background: rgba(255,255,255,0.05);
    color: #fff; font-size: 12px; font-weight: 500;
    cursor: pointer;
    display: flex; align-items: center; gap: 6px;
    transition: all 0.2s;
    font-family: inherit;
}
.qvideo-action-btn:hover { background: rgba(59,130,246,0.15); border-color: rgba(59,130,246,0.3); }
.qvideo-action-primary {
    background: linear-gradient(135deg, rgba(59,130,246,0.25), rgba(37, 99, 235,0.1));
    border-color: rgba(59,130,246,0.35);
    color: #60A5FA;
    font-weight: 600;
}
.qvideo-action-primary:hover {
    background: linear-gradient(135deg, rgba(59,130,246,0.35), rgba(37, 99, 235,0.15));
    border-color: rgba(59,130,246,0.5);
}

/* ── Fullscreen ── */
.veo-player.veo-fullscreen {
    position: fixed !important; inset: 0;
    z-index: 99999; margin: 0 !important;
    border-radius: 0 !important; border: none !important;
    max-height: 100vh;
    display: flex; flex-direction: column;
}
.veo-player.veo-fullscreen .veo-viewport {
    flex: 1; display: flex; align-items: center; justify-content: center;
}
.veo-player.veo-fullscreen canvas { max-height: calc(100vh - 140px); max-width: 100vw; }

/* ── Q-Video Responsive ── */
@media (max-width: 640px) {
    .qvideo-modal { max-width: 100%; border-radius: 0; max-height: 100vh; max-height: 100dvh; }
    .qvideo-body { padding: 14px; }
    .qvideo-controls-grid { grid-template-columns: 1fr 1fr; }
    .qvideo-controls-grid .qvideo-setting-card:last-child { grid-column: 1 / -1; }
    .qvideo-playback-controls { flex-wrap: wrap; }
    .qvideo-playback-right { width: 100%; margin-top: 6px; }
    .qvideo-playback-right .qvideo-action-btn { flex: 1; justify-content: center; }
    .qvideo-speed-wrap { min-width: 60px; }
    .qvideo-generate-btn { font-size: 13px; padding: 12px 16px; }
}

/* Light theme */
[data-theme="light"] .qvideo-modal { border-color: rgba(59,130,246,0.12); }
[data-theme="light"] .qvideo-header { background: linear-gradient(135deg, rgba(59,130,246,0.05), rgba(0,180,216,0.03)); }
[data-theme="light"] .qvideo-prompt-card { background: rgba(0,0,0,0.02); border-color: #d2d2d7; }
[data-theme="light"] .qvideo-textarea { background: #f5f5f7; border-color: #d2d2d7; color: #1d1d1f; }
[data-theme="light"] .qvideo-setting-card { background: rgba(0,0,0,0.02); border-color: #d2d2d7; }
[data-theme="light"] .qvideo-select { background: #f5f5f7; border-color: #d2d2d7; color: #1d1d1f; }
[data-theme="light"] .qvideo-progress { background: rgba(0,0,0,0.02); border-color: #d2d2d7; }













/* ============================================
   MULTI-MODEL COMPARE
   ============================================ */

/* Compare Top Bar Button */
.compare-topbar-btn {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(245, 158, 11, 0.25);
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.12), rgba(251, 191, 36, 0.08));
    color: #fbbf24;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-base);
    flex-shrink: 0;
}

.compare-topbar-btn:hover {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.25), rgba(251, 191, 36, 0.15));
    border-color: rgba(245, 158, 11, 0.5);
    box-shadow: 0 0 20px rgba(245, 158, 11, 0.2);
    transform: translateY(-1px);
}

/* Compare Modal */
.compare-modal {
    max-width: 560px !important;
}

.compare-model-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 8px;
}

.compare-model-option {
    padding: 12px 14px;
    background: var(--bg-glass);
    border: 1.5px solid var(--border-primary);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-family: var(--font-primary);
    font-size: 12.5px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-base);
    display: flex;
    align-items: center;
    gap: 8px;
    user-select: none;
}

.compare-model-option:hover {
    background: var(--bg-glass-hover);
    border-color: var(--border-secondary);
    color: var(--text-primary);
}

.compare-model-option.selected {
    background: rgba(245, 158, 11, 0.1);
    border-color: rgba(245, 158, 11, 0.4);
    color: #fbbf24;
    box-shadow: 0 0 12px rgba(245, 158, 11, 0.1);
}

.compare-model-option .model-check {
    width: 18px;
    height: 18px;
    border-radius: 4px;
    border: 1.5px solid var(--border-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all var(--transition-fast);
    font-size: 11px;
}

.compare-model-option.selected .model-check {
    background: linear-gradient(135deg, #f59e0b, #fbbf24);
    border-color: #f59e0b;
    color: #000;
}

.compare-model-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.compare-start-btn {
    width: 100%;
    margin-top: 16px;
    padding: 14px 20px;
    background: linear-gradient(135deg, #f59e0b, #d97706);
    border: none;
    border-radius: var(--radius-md);
    color: #000;
    font-family: var(--font-primary);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all var(--transition-base);
}

.compare-start-btn:hover {
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    box-shadow: 0 4px 20px rgba(245, 158, 11, 0.3);
    transform: translateY(-1px);
}

.compare-start-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Compare Results Overlay */
.compare-results-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: var(--bg-primary);
    display: flex;
    flex-direction: column;
    animation: fadeIn 0.3s ease;
}

.compare-results-overlay.hidden {
    display: none;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.compare-results-header {
    height: 56px;
    min-height: 56px;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-primary);
    background: rgba(6, 6, 15, 0.9);
    backdrop-filter: blur(20px);
    font-size: 15px;
    font-weight: 600;
}

.compare-results-actions {
    display: flex;
    gap: 8px;
}

.compare-header-btn {
    padding: 6px 14px;
    background: var(--bg-glass);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-full);
    color: var(--text-secondary);
    font-family: var(--font-primary);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

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

.compare-prompt-display {
    padding: 14px 20px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-primary);
    font-size: 13px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.compare-prompt-display::before {
    content: '💬';
    font-size: 14px;
}

.compare-columns {
    flex: 1;
    display: grid;
    overflow: hidden;
}

.compare-column {
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-primary);
    overflow: hidden;
}

.compare-column:last-child {
    border-right: none;
}

.compare-column-header {
    padding: 12px 16px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-primary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-shrink: 0;
}

.compare-column-model {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.compare-column-model .model-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.compare-column-status {
    font-size: 11px;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: var(--radius-full);
}

.compare-column-status.streaming {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
    animation: statusPulse 1.5s ease-in-out infinite;
}

.compare-column-status.done {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
}

.compare-column-status.error {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

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

.compare-column-body {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    font-size: 14px;
    line-height: 1.7;
    color: var(--text-primary);
}

.compare-column-body .streaming-cursor::after {
    content: '▋';
    animation: blink 0.8s infinite;
    color: var(--accent-primary);
}

.compare-column-footer {
    padding: 10px 16px;
    border-top: 1px solid var(--border-primary);
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.compare-use-btn {
    padding: 6px 14px;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    border: none;
    border-radius: var(--radius-full);
    color: white;
    font-family: var(--font-primary);
    font-size: 11.5px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.compare-use-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px var(--accent-glow);
}

.compare-stats {
    font-size: 11px;
    color: var(--text-tertiary);
}

/* Responsive */
@media (max-width: 768px) {
    .compare-columns {
        grid-template-columns: 1fr !important;
        grid-template-rows: auto;
    }
    .compare-column {
        border-right: none;
        border-bottom: 1px solid var(--border-primary);
        max-height: 50vh;
    }
    .compare-model-grid {
        grid-template-columns: 1fr;
    }
    .compare-results-actions {
        gap: 4px;
        flex-wrap: wrap;
    }
    .compare-header-btn {
        font-size: 11px;
        padding: 4px 10px;
    }
}

/* ── Compare Footer Actions ── */
.compare-footer-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.compare-copy-btn {
    width: 30px;
    height: 30px;
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-sm);
    background: var(--bg-glass);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    transition: all var(--transition-fast);
}
.compare-copy-btn:hover {
    background: var(--bg-glass-hover);
    border-color: var(--border-secondary);
    transform: scale(1.05);
}

/* ── Star Rating ── */
.cmp-star-rating {
    display: flex;
    gap: 1px;
}
.cmp-star {
    font-size: 16px;
    color: rgba(255, 255, 255, 0.2);
    cursor: pointer;
    transition: color 0.15s ease, transform 0.15s ease;
    user-select: none;
    line-height: 1;
}
.cmp-star:hover {
    color: #fbbf24;
    transform: scale(1.2);
}
.cmp-star.active {
    color: #f59e0b;
    text-shadow: 0 0 8px rgba(245, 158, 11, 0.4);
}

/* Average Rating Badge (in model grid) */
.cmp-avg-badge {
    font-size: 10px;
    color: #f59e0b;
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.2);
    padding: 2px 6px;
    border-radius: var(--radius-full);
    white-space: nowrap;
    margin-left: auto;
    flex-shrink: 0;
}

/* ── Error Box with Retry ── */
.cmp-error-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 24px 16px;
    text-align: center;
}
.cmp-error-msg {
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.5;
    max-width: 280px;
}
.cmp-retry-single-btn {
    padding: 8px 18px;
    background: var(--bg-glass);
    border: 1px solid var(--border-secondary);
    border-radius: var(--radius-full);
    color: var(--text-primary);
    font-family: var(--font-primary);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}
.cmp-retry-single-btn:hover {
    background: rgba(245, 158, 11, 0.15);
    border-color: rgba(245, 158, 11, 0.4);
    color: #fbbf24;
}

/* ── Compare History Overlay ── */
.cmp-history-overlay {
    position: fixed;
    inset: 0;
    z-index: 10001;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}
.cmp-history-panel {
    width: 90%;
    max-width: 580px;
    max-height: 80vh;
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.cmp-history-header {
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-primary);
    flex-shrink: 0;
}
.cmp-history-header h3 {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
}
.cmp-history-actions {
    display: flex;
    gap: 6px;
}
.cmp-history-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}
.cmp-history-item {
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    border: 1px solid transparent;
    margin-bottom: 4px;
}
.cmp-history-item:hover {
    background: var(--bg-glass-hover);
    border-color: var(--border-secondary);
}
.cmp-history-prompt {
    font-size: 13px;
    color: var(--text-primary);
    font-weight: 500;
    margin-bottom: 6px;
    line-height: 1.4;
    font-style: italic;
}
.cmp-history-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-size: 11px;
}
.cmp-history-models {
    color: var(--text-tertiary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}
.cmp-history-time {
    color: var(--text-tertiary);
    white-space: nowrap;
    flex-shrink: 0;
}

/* History Badge in footer */
.cmp-history-badge {
    font-size: 10px;
    color: var(--text-tertiary);
    background: rgba(255, 255, 255, 0.05);
    padding: 3px 8px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border-primary);
}

/* Mobile fix for footer actions */
@media (max-width: 768px) {
    .compare-footer-actions {
        flex-wrap: wrap;
        gap: 6px;
    }
    .cmp-star-rating {
        gap: 0;
    }
    .cmp-star {
        font-size: 14px;
    }
}

/* === Tic-Tac-Toe Game === */
.ttt-cell {
    width: 100%;
    aspect-ratio: 1;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-sm);
    font-size: 1.8rem;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition-fast);
    color: var(--text-primary);
    font-family: var(--font-primary);
}
.ttt-cell:hover:not(:disabled) {
    background: rgba(59, 130, 246, 0.1);
    border-color: rgba(59, 130, 246, 0.3);
}
.ttt-cell.filled { cursor: default; }
.ttt-cell.x { color: var(--accent-primary); }
.ttt-cell.o { color: var(--accent-secondary); }

/* === Todo Items === */
.todo-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-sm);
    margin-bottom: 6px;
    transition: all var(--transition-fast);
}
.todo-item.done { opacity: 0.5; }
.todo-item.done .todo-text { text-decoration: line-through; }
.todo-check {
    background: none;
    border: none;
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}
.todo-text {
    flex: 1;
    font-size: 0.85rem;
    color: var(--text-primary);
    word-break: break-word;
}
.todo-delete {
    background: none;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    font-size: 0.9rem;
    padding: 2px 6px;
    border-radius: 4px;
    transition: all var(--transition-fast);
    opacity: 0;
}
.todo-item:hover .todo-delete { opacity: 1; }
.todo-delete:hover { color: var(--danger); background: rgba(239, 68, 68, 0.1); }

/* === Follow-up Chips === */
.followup-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 20px 4px;
    max-width: var(--content-max, 820px);
    margin: 0 auto;
    width: 100%;
    animation: fadeInUp 0.3s ease;
}
.followup-container.hidden { display: none; }
.followup-chip {
    padding: 8px 16px;
    background: rgba(59, 130, 246, 0.08);
    border: 1px solid rgba(59, 130, 246, 0.2);
    border-radius: var(--radius-full);
    color: var(--text-secondary);
    font-family: var(--font-primary);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all var(--transition-base);
}
.followup-chip:hover {
    background: rgba(59, 130, 246, 0.15);
    border-color: rgba(59, 130, 246, 0.4);
    color: var(--text-primary);
    transform: translateY(-1px);
}

/* === Authentication Overlay === */
.auth-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 20px;
    overflow-y: auto;
}

.auth-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 40px 36px;
    max-width: 420px;
    width: 100%;
    gap: 10px;
    background: var(--bg-card);
    border: 1px solid var(--border-secondary);
    border-radius: var(--radius-xl);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: var(--shadow-lg);
}

.auth-logo {
    width: 72px;
    height: 72px;
    margin-bottom: 6px;
    border-radius: 50%;
    background: var(--bg-glass);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-secondary);
    box-shadow: 0 0 30px var(--accent-glow);
}

.auth-logo .logo-img {
    width: 36px;
    height: 36px;
}

.auth-card h2 {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.auth-card > p {
    font-size: 13px;
    color: var(--text-tertiary);
    margin: 0 0 8px 0;
}

/* Email/Password Form */
.auth-email-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
}

.auth-input {
    width: 100%;
    box-sizing: border-box;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-primary);
    font-size: 14px;
    outline: none;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.auth-input:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.auth-input::placeholder {
    color: var(--text-tertiary);
}

.auth-primary-btn {
    width: 100%;
    padding: 12px 24px;
    background: var(--accent-gradient);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    font-family: var(--font-primary);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-base);
    margin-top: 2px;
}

.auth-primary-btn:hover {
    box-shadow: var(--shadow-glow);
    transform: translateY(-1px);
}

.auth-primary-btn:active {
    transform: translateY(0);
}

.auth-primary-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Toggle Link */
.auth-toggle-link {
    background: none;
    border: none;
    color: var(--text-tertiary);
    font-family: var(--font-primary);
    font-size: 13px;
    cursor: pointer;
    padding: 4px 0;
    transition: color var(--transition-fast);
}

.auth-toggle-link strong {
    color: var(--accent-primary);
}

.auth-toggle-link:hover {
    color: var(--text-secondary);
}

/* Divider */
.auth-divider {
    display: flex;
    align-items: center;
    width: 100%;
    gap: 12px;
    margin: 6px 0;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-primary);
}

.auth-divider span {
    font-size: 12px;
    color: var(--text-tertiary);
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Social Provider Grid */
.auth-social-grid {
    display: flex;
    gap: 10px;
    width: 100%;
    justify-content: center;
}

.auth-social-btn {
    flex: 1;
    max-width: 64px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-glass);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition-base);
}

.auth-social-btn:hover {
    background: var(--bg-glass-hover);
    border-color: var(--border-secondary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.auth-social-btn:active {
    transform: translateY(0);
}

/* Provider-specific hover colors */
#googleSignInBtn:hover { border-color: rgba(66, 133, 244, 0.5); }
#appleSignInBtn:hover  { border-color: rgba(255, 255, 255, 0.3); }
#githubSignInBtn:hover { border-color: rgba(255, 255, 255, 0.2); }
#twitterSignInBtn:hover { border-color: rgba(29, 161, 242, 0.5); }
#facebookSignInBtn:hover { border-color: rgba(24, 119, 242, 0.5); }

/* Error Message */
.auth-error-msg {
    width: 100%;
    padding: 10px 14px;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.25);
    border-radius: var(--radius-md);
    color: #fca5a5;
    font-size: 13px;
    text-align: left;
    margin-top: 4px;
}

.auth-error-msg.hidden {
    display: none;
}

.google-sign-in-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    padding: 12px 24px;
    background: var(--bg-glass);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 15px;
    font-weight: 600;
    font-family: var(--font-primary);
    cursor: pointer;
    transition: all var(--transition-base);
}

.google-sign-in-btn:hover {
    background: var(--bg-glass-hover);
    border-color: rgba(66, 133, 244, 0.5);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    transform: translateY(-1px);
}

.google-sign-in-btn:active {
    transform: translateY(0);
}

/* Support Text */
.auth-support-text {
    margin-top: 16px;
    font-size: 13px;
    color: var(--text-tertiary);
}

.auth-support-text a {
    color: var(--accent-primary);
    text-decoration: none;
    font-weight: 500;
    transition: color var(--transition-fast);
}

.auth-support-text a:hover {
    color: var(--text-primary);
    text-decoration: underline;
}

/* === Toast Notifications === */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 9999;
    pointer-events: none;
}

.toast {
    padding: 12px 20px;
    border-radius: var(--radius-md);
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    border: 1px solid var(--border-primary);
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    gap: 10px;
    transform: translateY(20px);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

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

.toast.success {
    border-left: 4px solid var(--success);
}

.toast.error {
    border-left: 4px solid var(--danger);
}

.toast.info {
    border-left: 4px solid var(--accent-primary);
}
