:root {
    --bg-main: #0d0d12;
    --bg-sidebar: #12121a;
    --bg-input: #1e1e2e;
    --text-primary: #f0f0f5;
    --text-secondary: #a0a0b8;
    --border-color: #2d2d44;
    --accent-color: #a855f7;
    --accent-hover: #9333ea;
    --accent-secondary: #ec4899;
    --accent-light: rgba(168, 85, 247, 0.15);
    --message-user-bg: #1e1e2e;
    --message-bot-bg: #151520;
    --scrollbar-bg: #1a1a28;
    --scrollbar-thumb: #4a4a6a;
    --hover-bg: #1f1f32;
    --glow-color: rgba(168, 85, 247, 0.4);
    --glow-secondary: rgba(236, 72, 153, 0.3);
    --error-color: #f87171;
    --error-bg: rgba(248, 113, 113, 0.1);
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    --gradient-accent: linear-gradient(135deg, #a855f7 0%, #ec4899 100%);
    --gradient-subtle: linear-gradient(135deg, rgba(168, 85, 247, 0.1) 0%, rgba(236, 72, 153, 0.1) 100%);
}

[data-theme="light"] {
    --bg-main: #faf8ff;
    --bg-sidebar: #f3f0fa;
    --bg-input: #ffffff;
    --text-primary: #1a1a2e;
    --text-secondary: #64648c;
    --border-color: #e0ddf0;
    --accent-light: rgba(168, 85, 247, 0.1);
    --message-user-bg: #f0ecfa;
    --message-bot-bg: #ffffff;
    --scrollbar-bg: #f0ecfa;
    --scrollbar-thumb: #c5c0d8;
    --hover-bg: #ebe7f5;
    --glow-color: rgba(168, 85, 247, 0.25);
    --glow-secondary: rgba(236, 72, 153, 0.2);
    --shadow-sm: 0 2px 8px rgba(100, 80, 150, 0.08);
    --shadow-md: 0 4px 16px rgba(100, 80, 150, 0.12);
    --shadow-lg: 0 8px 32px rgba(100, 80, 150, 0.18);
    --gradient-subtle: linear-gradient(135deg, rgba(168, 85, 247, 0.08) 0%, rgba(236, 72, 153, 0.06) 100%);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg-main);
    color: var(--text-primary);
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
}

/* Improved focus styles */
:focus-visible {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}

button:focus:not(:focus-visible) {
    outline: none;
}

/* Layout */
.app-container {
    display: flex;
    height: 100vh;
    height: 100dvh;
    width: 100%;
    position: relative;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background: var(--bg-sidebar);
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-color);
    transition: transform var(--transition-normal), width var(--transition-normal);
    z-index: 100;
    flex-shrink: 0;
}

.sidebar.hidden {
    transform: translateX(-100%);
    width: 0;
    border-right: none;
    overflow: hidden;
}

.sidebar.hidden * {
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.1s, visibility 0.1s;
}

.sidebar-header {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
}

.new-chat-btn {
    width: 100%;
    padding: 14px 16px;
    background: var(--accent-color);
    border: none;
    color: white;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-size: 14px;
    font-weight: 600;
    transition: all var(--transition-fast);
    box-shadow: 0 4px 12px var(--glow-color);
}

.new-chat-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(25, 195, 125, 0.35);
}

.new-chat-btn:active {
    transform: translateY(0);
}

.chat-history {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb) transparent;
}

.chat-history::-webkit-scrollbar {
    width: 6px;
}

.chat-history::-webkit-scrollbar-track {
    background: transparent;
}

.chat-history::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 3px;
}

.chat-history::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

.history-item {
    padding: 12px 14px;
    margin-bottom: 4px;
    border-radius: 10px;
    cursor: pointer;
    color: var(--text-primary);
    font-size: 14px;
    transition: all var(--transition-fast);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.history-item:hover {
    background: var(--hover-bg);
}

.history-item.active {
    background: var(--accent-light);
    border: 1px solid var(--accent-color);
}

.history-item .title {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-item .delete-btn {
    opacity: 0;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.history-item:hover .delete-btn {
    opacity: 1;
}

.history-item .delete-btn:hover {
    color: var(--error-color);
    background: var(--error-bg);
}

.history-empty {
    text-align: center;
    padding: 24px 16px;
    color: var(--text-secondary);
    font-size: 14px;
}

.history-empty svg {
    margin-bottom: 12px;
    opacity: 0.5;
}

.sidebar-footer {
    padding: 12px;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sidebar-btn {
    width: 100%;
    padding: 12px 14px;
    background: transparent;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    border-radius: 10px;
    transition: all var(--transition-fast);
}

.sidebar-btn:hover {
    background: var(--hover-bg);
}

.sidebar-btn svg {
    flex-shrink: 0;
}

/* Sidebar Overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
    backdrop-filter: blur(2px);
}

.sidebar-overlay.visible {
    display: block;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    min-width: 0;
}

.chat-header {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    gap: 12px;
    background: var(--bg-main);
    z-index: 10;
}

.sidebar-toggle {
    background: transparent;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.sidebar-toggle:hover {
    background: var(--hover-bg);
}

.chat-model-info {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.model-badge {
    padding: 6px 14px;
    background: var(--accent-color);
    color: white;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
    box-shadow: var(--shadow-sm);
    letter-spacing: 0.3px;
}

.feature-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 12px;
    background: var(--bg-input);
    color: var(--text-primary);
    border-radius: 16px;
    font-size: 12px;
    border: 1px solid var(--border-color);
    font-family: 'Inter', sans-serif;
    font-weight: 500;
}

.feature-badge svg {
    flex-shrink: 0;
}

.feature-badge.rethink-badge {
    background: var(--bg-input);
    border-color: rgba(59, 130, 246, 0.5);
    color: #3b82f6;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.theme-toggle {
    background: transparent;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.theme-toggle:hover {
    background: var(--hover-bg);
}

/* Theme toggle icons */
.theme-toggle .moon-icon {
    display: none;
}

[data-theme="light"] .theme-toggle .sun-icon {
    display: none;
}

[data-theme="light"] .theme-toggle .moon-icon {
    display: block;
}

/* Chat Container */
.chat-container {
    flex: 1;
    overflow-y: auto;
    position: relative;
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb) transparent;
}

.chat-container::-webkit-scrollbar {
    width: 8px;
}

.chat-container::-webkit-scrollbar-track {
    background: transparent;
}

.chat-container::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 4px;
}

.chat-container::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

.chat-messages {
    max-width: 850px;
    margin: 0 auto;
    padding: 24px 16px;
}

/* Welcome Screen */
.welcome-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    text-align: center;
    padding: 20px;
    animation: fadeIn 0.5s ease;
}

.welcome-icon {
    margin-bottom: 24px;
    color: var(--accent-color);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.05);
        opacity: 0.8;
    }
}

.welcome-screen h1 {
    font-size: 32px;
    margin-bottom: 12px;
    color: var(--text-primary);
    font-weight: 700;
}

.welcome-subtitle {
    color: var(--text-secondary);
    font-size: 16px;
    margin-bottom: 32px;
}

.suggestion-cards {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    width: 100%;
    max-width: 600px;
}

.suggestion-card {
    padding: 16px 18px;
    background: var(--gradient-subtle);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    gap: 12px;
    text-align: left;
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
}

.suggestion-card:hover {
    background: var(--hover-bg);
    transform: translateY(-3px);
    box-shadow: var(--shadow-md), 0 0 20px var(--glow-color);
    border-color: var(--accent-color);
}

.suggestion-card:active {
    transform: translateY(-1px);
}

.suggestion-icon {
    font-size: 24px;
    flex-shrink: 0;
}

/* Messages */
.message {
    display: flex;
    gap: 16px;
    padding: 24px 16px;
    animation: slideIn 0.3s ease;
    border-radius: 12px;
    margin-bottom: 8px;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.message.user {
    background: var(--accent-color);
    color: white;
    flex-direction: row;
    margin-left: auto;
    max-width: 75%;
    padding: 12px 18px;
    border-radius: 20px 20px 4px 20px;
}

.message.bot {
    background: transparent;
    border: none;
    margin-right: auto;
    max-width: 95%;
    padding: 8px 0;
}

.message-avatar {
    display: none;
}

.message.user .message-avatar {
    display: none;
}

.message.bot .message-avatar {
    display: none;
}

.message-content {
    flex: 1;
    line-height: 1.7;
    color: var(--text-primary);
    min-width: 0;
    overflow-wrap: break-word;
}

.message.user .message-content {
    text-align: left;
    color: white;
}

.message-content p {
    margin-bottom: 12px;
}

.message-content p:last-child {
    margin-bottom: 0;
}

.message-content pre {
    background: #0d0d0d;
    padding: 16px;
    border-radius: 12px;
    overflow-x: auto;
    margin: 16px 0;
    border: 1px solid var(--border-color);
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.3);
    position: relative;
}

[data-theme="light"] .message-content pre {
    background: #f6f8fa;
    border-color: #d0d7de;
    box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.05);
}

.message-content code {
    background: var(--bg-input);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'JetBrains Mono', 'SF Mono', 'Fira Code', 'Courier New', monospace;
    font-size: 13px;
}

.message-content pre code {
    background: transparent;
    padding: 0;
    font-family: 'JetBrains Mono', 'SF Mono', 'Fira Code', 'Courier New', monospace;
    font-size: 14px;
}

.message-content ul,
.message-content ol {
    margin: 12px 0;
    padding-left: 24px;
}

.message-content li {
    margin: 6px 0;
}

.message-content blockquote {
    border-left: 3px solid var(--accent-color);
    padding-left: 16px;
    margin: 16px 0;
    color: var(--text-secondary);
    font-style: italic;
}

.message-content a {
    color: var(--accent-color);
    text-decoration: none;
}

.message-content a:hover {
    text-decoration: underline;
}

.message-content table {
    border-collapse: collapse;
    width: 100%;
    margin: 16px 0;
}

.message-content th,
.message-content td {
    border: 1px solid var(--border-color);
    padding: 8px 12px;
    text-align: left;
}

.message-content th {
    background: var(--bg-input);
}

/* Copy button for code blocks */
.code-copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 6px 10px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 12px;
    cursor: pointer;
    opacity: 0;
    transition: all var(--transition-fast);
}

.message-content pre:hover .code-copy-btn {
    opacity: 1;
}

.code-copy-btn:hover {
    background: var(--hover-bg);
    color: var(--text-primary);
}

.code-copy-btn.copied {
    background: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
}

/* KaTeX / LaTeX styles */
.message-content .katex {
    font-size: 1.1em;
}

.message-content .katex-display {
    margin: 16px 0;
    padding: 16px;
    background: var(--bg-input);
    border-radius: 8px;
    overflow-x: auto;
    border: 1px solid var(--border-color);
}

.message-content .katex-display > .katex {
    text-align: center;
}

/* Fix KaTeX colors for dark theme */
.message-content .katex .mord,
.message-content .katex .mbin,
.message-content .katex .mrel,
.message-content .katex .mopen,
.message-content .katex .mclose,
.message-content .katex .mpunct,
.message-content .katex .minner {
    color: var(--text-primary);
}

[data-theme="light"] .message-content .katex-display {
    background: var(--bg-sidebar);
}

/* Thinking Indicator */
.thinking-indicator {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    background: var(--bg-input);
    border-radius: 10px;
    margin: 8px 0;
    font-size: 14px;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.thinking-dots {
    display: flex;
    gap: 5px;
}

.thinking-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-color);
    animation: bounce 1.4s infinite ease-in-out;
}

.thinking-dot:nth-child(1) {
    animation-delay: -0.32s;
}

.thinking-dot:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes bounce {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1.2);
        opacity: 1;
    }
}

/* Reasoning Panel (AI Thinking) */
.reasoning-panel {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    margin-bottom: 16px;
    overflow: hidden;
    transition: all var(--transition-normal);
}

.reasoning-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: var(--accent-color);
    user-select: none;
}

.reasoning-header span:first-child {
    color: var(--accent-color);
}

.reasoning-header:hover {
    background: var(--hover-bg);
}

.reasoning-toggle {
    font-size: 10px;
    transition: transform var(--transition-fast);
    color: var(--text-secondary);
}

.reasoning-panel.collapsed .reasoning-toggle {
    transform: rotate(-90deg);
}

.reasoning-content {
    padding: 12px 16px;
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-secondary);
    white-space: pre-wrap;
    max-height: 300px;
    overflow-y: auto;
    border-top: 1px solid var(--border-color);
}

.reasoning-panel.collapsed .reasoning-content {
    display: none;
}

[data-theme="light"] .reasoning-panel {
    background: var(--bg-input);
}

[data-theme="light"] .reasoning-header {
    color: var(--accent-color);
}

/* Rethink Panel */
.rethink-panel {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    margin-bottom: 16px;
    overflow: hidden;
    transition: all var(--transition-normal);
}

.rethink-panel.thinking {
    border-color: rgba(59, 130, 246, 0.5);
}

.rethink-panel.completed {
    border-color: rgba(34, 197, 94, 0.5);
}

.rethink-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    cursor: pointer;
    user-select: none;
    background: transparent;
}

.rethink-header:hover {
    background: var(--hover-bg);
}

.rethink-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.rethink-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    color: #3b82f6;
}

.rethink-icon .icon-thinking {
    display: block;
    animation: rethink-spin 2s ease-in-out infinite;
}

.rethink-icon .icon-check {
    display: none;
    color: #22c55e;
}

.rethink-panel.completed .rethink-icon .icon-thinking {
    display: none;
}

.rethink-panel.completed .rethink-icon .icon-check {
    display: block;
}

@keyframes rethink-spin {
    0%, 100% { transform: rotate(0deg); }
    50% { transform: rotate(180deg); }
}

.rethink-title {
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    font-weight: 600;
    color: #3b82f6;
}

.rethink-panel.completed .rethink-title {
    color: #22c55e;
}

.rethink-toggle {
    color: var(--text-secondary);
    transition: transform var(--transition-fast);
    display: flex;
    align-items: center;
}

.rethink-panel.collapsed .rethink-toggle {
    transform: rotate(-90deg);
}

.rethink-content {
    padding: 14px 16px;
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    line-height: 1.7;
    color: var(--text-secondary);
    white-space: pre-wrap;
    max-height: 350px;
    overflow-y: auto;
    border-top: 1px solid var(--border-color);
    background: transparent;
}

.rethink-panel.collapsed .rethink-content {
    display: none;
}

[data-theme="light"] .rethink-panel {
    background: var(--bg-input);
}

/* Search Panel */
.search-panel {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    margin-bottom: 16px;
    overflow: hidden;
    transition: all var(--transition-normal);
}

.search-panel.searching {
    border-color: var(--accent-color);
}

.search-panel.deep-research.searching {
    border-color: #f59e0b;
}

.search-panel.completed {
    border-color: rgba(34, 197, 94, 0.5);
}

.search-panel.deep-research.completed {
    border-color: rgba(245, 158, 11, 0.7);
}

.search-panel.deep-research.searching {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.05), rgba(217, 119, 6, 0.03));
}

.search-panel.deep-research .search-icon .icon-search {
    animation: deep-research-pulse 2s ease-in-out infinite;
}

@keyframes deep-research-pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.5;
        transform: scale(1.1);
    }
}

/* Deep research progress steps */
.deep-research-progress {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 16px 20px;
    gap: 8px;
}

.progress-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    position: relative;
}

.step-indicator {
    display: flex;
    align-items: center;
    width: 100%;
    position: relative;
}

.step-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.3);
    z-index: 1;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.step-line {
    flex: 1;
    height: 2px;
    background: rgba(255, 255, 255, 0.15);
    margin-left: 4px;
    transition: background 0.3s ease;
}

.progress-step:last-child .step-line {
    display: none;
}

.step-label {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.4);
    margin-top: 8px;
    text-align: center;
    transition: color 0.3s ease;
    white-space: nowrap;
}

.progress-step.active .step-dot {
    background: #f59e0b;
    border-color: #f59e0b;
    box-shadow: 0 0 12px rgba(245, 158, 11, 0.5);
    animation: step-pulse 1.5s ease-in-out infinite;
}

.progress-step.active .step-label {
    color: #f59e0b;
    font-weight: 500;
}

.progress-step.completed .step-dot {
    background: #22c55e;
    border-color: #22c55e;
}

.progress-step.completed .step-line {
    background: #22c55e;
}

.progress-step.completed .step-label {
    color: rgba(255, 255, 255, 0.6);
}

@keyframes step-pulse {
    0%, 100% {
        box-shadow: 0 0 8px rgba(245, 158, 11, 0.4);
    }
    50% {
        box-shadow: 0 0 16px rgba(245, 158, 11, 0.7);
    }
}

.search-panel.error {
    border-color: var(--error-color);
}

.search-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: transparent;
}

.search-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.search-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    color: var(--accent-color);
}

.search-icon .icon-search {
    display: block;
}

.search-icon .icon-check {
    display: none;
    color: #22c55e;
}

.search-panel.searching .search-icon .icon-search {
    animation: search-pulse 1.5s ease-in-out infinite;
}

.search-panel.completed .search-icon .icon-search {
    display: none;
}

.search-panel.completed .search-icon .icon-check {
    display: block;
}

@keyframes search-pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.6;
        transform: scale(0.9);
    }
}

.search-status {
    font-size: 13px;
    font-weight: 600;
    color: var(--accent-color);
}

.search-panel.deep-research .search-status {
    color: #f59e0b;
}

.search-panel.deep-research .search-icon {
    color: #f59e0b;
}

.search-panel.deep-research.completed .search-status {
    color: #d97706;
}

.search-panel.deep-research.completed .search-icon .icon-check {
    color: #d97706;
}

.search-panel.completed .search-status {
    color: #22c55e;
}

.search-panel.error .search-status {
    color: var(--error-color);
}

.search-toggle {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
}

.search-toggle:hover {
    background: var(--hover-bg);
}

.search-panel.collapsed .search-toggle svg {
    transform: rotate(-90deg);
}

.search-body {
    padding: 12px 16px;
    border-top: 1px solid var(--border-color);
}

.search-panel.collapsed .search-body {
    display: none;
}

/* Search mode indicator (simple) */
.search-mode-indicator {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--accent-light);
    border: 1px solid var(--accent-color);
    border-radius: 8px;
    font-size: 12px;
    color: var(--accent-color);
    margin-bottom: 8px;
    animation: pulse-glow 2s infinite;
}

@keyframes pulse-glow {
    0%, 100% {
        box-shadow: 0 0 0 0 transparent;
    }
    50% {
        box-shadow: 0 0 12px var(--glow-color);
    }
}

.search-queries {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}

.search-query-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.15);
    border-radius: 8px;
}

.query-number {
    width: 20px;
    height: 20px;
    background: var(--accent-color);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    flex-shrink: 0;
}

.query-text {
    font-size: 13px;
    color: var(--text-primary);
    font-style: italic;
}

.search-results-container {
    margin-top: 8px;
}

.search-results-header {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    font-weight: 600;
}

.search-results-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.search-result-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 10px 12px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    text-decoration: none;
    transition: all var(--transition-fast);
    border: 1px solid transparent;
}

.search-result-item:hover {
    background: rgba(0, 0, 0, 0.2);
    border-color: var(--accent-color);
}

.result-number {
    font-size: 11px;
    color: var(--accent-color);
    font-weight: 600;
    flex-shrink: 0;
}

.result-title {
    font-size: 13px;
    color: var(--text-primary);
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.result-url {
    font-size: 11px;
    color: var(--accent-color);
}

.result-snippet {
    font-size: 11px;
    color: var(--text-secondary);
    line-height: 1.4;
}

.search-error {
    font-size: 12px;
    color: var(--warning-color, #f97316);
    background: rgba(249, 115, 22, 0.12);
    padding: 10px 12px;
    border-radius: 8px;
}

[data-theme="light"] .search-panel {
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.08), rgba(236, 72, 153, 0.06));
}

[data-theme="light"] .search-query-item,
[data-theme="light"] .search-result-item {
    background: rgba(0, 0, 0, 0.05);
}

[data-theme="light"] .search-result-item:hover {
    background: rgba(0, 0, 0, 0.08);
}

/* Error Message */
.error-message {
    color: var(--error-color);
    padding: 14px 16px;
    background: var(--error-bg);
    border-radius: 10px;
    border: 1px solid rgba(255, 107, 107, 0.3);
}

.error-message strong {
    display: block;
    margin-bottom: 4px;
}

/* Input Area */
.input-area {
    padding: 12px 16px 16px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-main);
}

/* Input Toolbar */
.input-toolbar {
    max-width: 850px;
    margin: 0 auto 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.toolbar-left,
.toolbar-right {
    display: flex;
    align-items: center;
    gap: 4px;
}

.toolbar-btn {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px 10px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all var(--transition-fast);
}

.toolbar-btn .btn-label {
    font-size: 12px;
    font-weight: 500;
    display: none;
}

@media (min-width: 768px) {
    .toolbar-btn.with-label .btn-label {
        display: inline;
    }
}

.toolbar-btn:hover {
    background: var(--hover-bg);
    color: var(--accent-color);
    border-color: var(--accent-color);
}

.toolbar-btn.active {
    background: var(--accent-light);
    color: var(--accent-color);
    border-color: var(--accent-color);
}

.toolbar-btn .lock-icon {
    display: none;
    font-size: 10px;
    margin-left: 2px;
}

.toolbar-btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.toolbar-btn.locked {
    cursor: default;
    pointer-events: auto;
}

.toolbar-btn.locked:hover {
    transform: none;
}

.toolbar-btn.disabled .lock-icon {
    display: inline;
}

/* Custom Select Dropdown */
.custom-select {
    position: relative;
    min-width: 140px;
    width: 280px;
}

.custom-select-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    width: 100%;
}

.select-value {
    display: flex;
    align-items: center;
    gap: 6px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.select-value svg {
    flex-shrink: 0;
    color: var(--accent-color);
}

.custom-select-trigger:hover {
    border-color: var(--accent-color);
    background: var(--hover-bg);
}

.custom-select.open .custom-select-trigger {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px var(--accent-light);
}

.select-arrow {
    transition: transform var(--transition-fast);
    opacity: 0.6;
    flex-shrink: 0;
}

.custom-select.open .select-arrow {
    transform: rotate(180deg);
}

.custom-select-options {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 0;
    width: 280px;
    background: var(--bg-sidebar);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 6px;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all var(--transition-fast);
    z-index: 1000;
    max-height: 400px;
    overflow-y: auto;
}

.custom-select.open .custom-select-options {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.select-group-label {
    padding: 8px 12px 4px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-top: 1px solid var(--border-color);
    margin-top: 4px;
}

.select-group-label:first-child {
    border-top: none;
    margin-top: 0;
}

.select-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.select-option:hover {
    background: var(--hover-bg);
}

.select-option.selected {
    background: var(--accent-light);
}

.option-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    color: var(--accent-color);
}

.option-content {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.option-title {
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
}

.option-title-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.option-title-row .option-title {
    flex-shrink: 0;
}

.option-desc {
    font-size: 11px;
    color: var(--text-secondary);
}

/* Locked models (subscription) */
.select-option.locked {
    opacity: 0.5;
    cursor: not-allowed;
    position: relative;
}

.select-option.locked:hover {
    background: transparent;
}

.lock-badge {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
}

/* Locked due to trial exhaustion - visually similar but with accent hint */
.select-option.locked-trial {
    opacity: 0.6;
    cursor: pointer;
    box-shadow: inset 0 0 0 1px rgba(245, 158, 11, 0.06);
}

.select-option.locked-trial .lock-badge {
    color: #f59e0b;
}

.trial-exhausted-label {
    margin-top: 6px;
    font-size: 11px;
    color: #f59e0b;
    font-weight: 600;
}

/* Subscription-locked label (different from trial exhaustion) */
.subscription-locked-label {
    margin-top: 6px;
    font-size: 11px;
    color: var(--text-secondary);
    font-weight: 600;
    background: rgba(255,255,255,0.02);
    padding: 4px 8px;
    border-radius: 6px;
    display: inline-block;
}

.select-option.locked-subscription {
    opacity: 0.6;
}

.select-option.locked-subscription .lock-badge {
    color: var(--text-secondary);
}

.trial-badge {
    margin-left: auto;
    font-size: 10px;
    padding: 3px 8px;
    background: rgba(34, 197, 94, 0.15);
    color: #22c55e;
    border-radius: 6px;
    font-weight: 600;
    white-space: nowrap;
}

/* Legacy model-quick-select - hidden but keep for fallback */
.model-quick-select {
    display: none;
}

/* Attached Files */
.attached-files {
    max-width: 850px;
    margin: 0 auto 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.attached-file {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    background: var(--accent-light);
    border: 1px solid var(--accent-color);
    border-radius: 8px;
    font-size: 12px;
    color: var(--text-primary);
}

.attached-file.image-file {
    padding: 4px 8px;
    background: var(--bg-input);
    border-color: var(--border-color);
}

.attached-file .file-icon {
    color: var(--accent-color);
    flex-shrink: 0;
}

.attached-file .file-preview {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 6px;
    flex-shrink: 0;
}

.attached-file .file-name {
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.attached-file .remove-file {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 2px;
    display: flex;
    border-radius: 4px;
    transition: all var(--transition-fast);
}

.attached-file .remove-file:hover {
    color: var(--error-color);
    background: var(--error-bg);
}

.input-container {
    max-width: 850px;
    margin: 0 auto;
    background: var(--bg-input);
    border: 2px solid var(--border-color);
    border-radius: 16px;
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px 14px;
    transition: all var(--transition-fast);
}

.input-container:focus-within {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 4px var(--glow-color);
}

#user-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 16px;
    resize: none;
    max-height: 200px;
    min-height: 24px;
    font-family: inherit;
    line-height: 1.5;
    padding: 4px 0;
}

#user-input::placeholder {
    color: var(--text-secondary);
}

.send-btn {
    background: var(--bg-input);
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 10px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.send-btn .stop-icon {
    display: none;
}

.send-btn.generating .send-icon {
    display: none;
}

.send-btn.generating .stop-icon {
    display: block;
}

.send-btn:not(:disabled) {
    background: var(--accent-color);
    color: white;
    box-shadow: var(--shadow-sm);
}

.send-btn:not(:disabled):hover {
    transform: scale(1.05);
    box-shadow: 0 4px 20px var(--glow-color), 0 4px 20px var(--glow-secondary);
}

.send-btn:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

.send-btn.generating {
    background: var(--error-color) !important;
    opacity: 1 !important;
}

.send-btn.generating:hover {
    background: #ff5252 !important;
}

.input-footer {
    max-width: 850px;
    margin: 12px auto 0;
    text-align: center;
}

.input-footer small {
    color: var(--text-secondary);
    font-size: 12px;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
    backdrop-filter: blur(4px);
}

.modal.open {
    display: flex;
    animation: fadeIn 0.2s ease;
}

.modal-content {
    background: var(--bg-sidebar);
    border-radius: 16px;
    width: 100%;
    max-width: 550px;
    max-height: 85vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease;
    border: 1px solid var(--border-color);
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb) transparent;
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-content::-webkit-scrollbar {
    width: 8px;
}

.modal-content::-webkit-scrollbar-track {
    background: transparent;
}

.modal-content::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 4px;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    background: var(--bg-sidebar);
    z-index: 10;
}

.modal-header h2 {
    color: var(--text-primary);
    font-size: 22px;
    font-weight: 700;
}

.close-btn {
    background: transparent;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.close-btn:hover {
    background: var(--hover-bg);
}

.modal-body {
    padding: 24px;
}

.settings-section {
    margin-bottom: 28px;
}

.settings-section:last-child {
    margin-bottom: 0;
}

.settings-section h3 {
    color: var(--text-primary);
    font-size: 16px;
    margin-bottom: 16px;
    font-weight: 600;
}

.form-group {
    margin-bottom: 20px;
}

.form-group:last-child {
    margin-bottom: 0;
}

.form-group label {
    display: block;
    color: var(--text-primary);
    font-size: 14px;
    margin-bottom: 8px;
    font-weight: 500;
}

.slider-value {
    display: inline-block;
    background: var(--accent-light);
    color: var(--accent-color);
    padding: 2px 8px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 13px;
    margin-left: 4px;
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="number"],
.form-group select {
    width: 100%;
    padding: 12px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 14px;
    transition: all var(--transition-fast);
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px var(--glow-color);
}

.form-group select {
    cursor: pointer;
}

.form-group small {
    display: block;
    color: var(--text-secondary);
    font-size: 12px;
    margin-top: 8px;
    line-height: 1.5;
}

.form-group small a {
    color: var(--accent-color);
    text-decoration: none;
}

.form-group small a:hover {
    text-decoration: underline;
}

.form-group input[type="range"] {
    width: 100%;
    height: 6px;
    background: var(--bg-input);
    border-radius: 3px;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    margin-top: 4px;
}

.form-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    background: var(--accent-color);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-fast);
}

.form-group input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

.form-group input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: var(--accent-color);
    border-radius: 50%;
    cursor: pointer;
    border: none;
    box-shadow: var(--shadow-sm);
}

.toggle-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.toggle-item {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    cursor: pointer;
    padding: 12px 14px;
    border-radius: 10px;
    transition: all var(--transition-fast);
    border: 1px solid transparent;
}

.toggle-item:hover {
    background: var(--hover-bg);
}

.toggle-item input[type="checkbox"] {
    width: 48px;
    height: 26px;
    appearance: none;
    -webkit-appearance: none;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 13px;
    position: relative;
    cursor: pointer;
    transition: all var(--transition-fast);
    flex-shrink: 0;
    margin-top: 2px;
}

.toggle-item input[type="checkbox"]:checked {
    background: var(--accent-color);
    border-color: var(--accent-color);
}

.toggle-item input[type="checkbox"]::before {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    background: white;
    border-radius: 50%;
    top: 2px;
    left: 2px;
    transition: transform var(--transition-fast);
    box-shadow: var(--shadow-sm);
}

.toggle-item input[type="checkbox"]:checked::before {
    transform: translateX(22px);
}

.toggle-label {
    flex: 1;
}

.toggle-label span:first-child {
    display: block;
    color: var(--text-primary);
    font-size: 14px;
    margin-bottom: 4px;
    font-weight: 500;
}

.toggle-label small {
    color: var(--text-secondary);
    font-size: 12px;
    line-height: 1.4;
}

.modal-footer {
    padding: 20px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    position: sticky;
    bottom: 0;
    background: var(--bg-sidebar);
}

.btn-primary,
.btn-secondary {
    padding: 12px 24px;
    border-radius: 10px;
    font-size: 14px;
    cursor: pointer;
    transition: all var(--transition-fast);
    border: none;
    font-weight: 600;
}

.btn-primary {
    background: var(--accent-color);
    color: white;
    box-shadow: 0 4px 12px var(--glow-color);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px var(--glow-color), 0 4px 16px var(--glow-secondary);
}

.btn-secondary {
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--hover-bg);
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        width: 85%;
        max-width: 320px;
        transform: translateX(-100%);
    }

    .sidebar.visible {
        transform: translateX(0);
    }

    .sidebar.hidden {
        transform: translateX(-100%);
        width: 85%;
    }

    .suggestion-cards {
        grid-template-columns: 1fr;
    }

    .chat-messages {
        padding: 16px 12px;
    }

    .message {
        padding: 16px 12px;
        gap: 12px;
    }

    .message-avatar {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }

    .welcome-screen h1 {
        font-size: 24px;
    }

    .modal-content {
        max-width: 100%;
        max-height: 90vh;
        margin: 0;
        border-radius: 16px 16px 0 0;
        position: absolute;
        bottom: 0;
    }

    .input-container {
        padding: 8px 12px;
    }
}

@media (max-width: 480px) {
    .chat-header {
        padding: 10px 12px;
    }

    .model-badge {
        font-size: 11px;
        padding: 5px 10px;
    }

    .feature-badge {
        font-size: 11px;
        padding: 4px 8px;
    }

    .input-area {
        padding: 12px;
    }

    #user-input {
        font-size: 16px; /* Prevents zoom on iOS */
    }
}

/* Loading animation */
.loading {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--border-color);
    border-top-color: var(--accent-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Keyboard shortcut hint */
.kbd {
    display: inline-block;
    padding: 2px 6px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 11px;
    font-family: inherit;
    color: var(--text-secondary);
}

/* Selection */
::selection {
    background: var(--accent-color);
    color: white;
}

/* Print styles */
@media print {
    .sidebar,
    .input-area,
    .chat-header {
        display: none !important;
    }

    .chat-container {
        overflow: visible;
    }

    .message {
        break-inside: avoid;
    }
}

/* Toast notifications */
.toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    padding: 12px 20px;
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    font-size: 14px;
    font-family: 'Inter', sans-serif;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    transition: all var(--transition-normal);
    z-index: 10000;
    max-width: 400px;
    text-align: center;
}

.toast.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.toast-warning {
    border-color: #f59e0b;
    background: rgba(245, 158, 11, 0.1);
    color: #fbbf24;
}

.toast-info {
    border-color: #3b82f6;
    background: rgba(59, 130, 246, 0.1);
    color: #60a5fa;
}

.toast-error {
    border-color: var(--error-color);
    background: var(--error-bg);
    color: var(--error-color);
}

.toast-success {
    border-color: #22c55e;
    background: rgba(34, 197, 94, 0.1);
    color: #4ade80;
}

/* Usage Indicator in Sidebar */
.usage-indicator {
    padding: 10px 12px;
    background: var(--bg-input);
    border-radius: 10px;
    margin-bottom: 8px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.usage-bar {
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 8px;
}

.usage-fill {
    height: 100%;
    background: var(--accent-color);
    border-radius: 2px;
    transition: width 0.3s ease, background 0.3s ease;
    width: 0%;
}

.usage-fill.warning {
    background: #f59e0b;
}

.usage-fill.danger {
    background: #ef4444;
}

.usage-fill.unlimited {
    background: #22c55e;
    width: 100%;
}

.usage-text {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
}

#usage-count {
    color: var(--text-primary);
    font-weight: 500;
}

.usage-label {
    color: var(--text-secondary);
}

.usage-indicator.hidden {
    display: none;
}

/* Subscription Button in Sidebar */
.subscription-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--gradient-subtle);
    border: 1px solid var(--accent-color);
}

.subscription-btn:hover {
    background: var(--accent-light);
}

.subscription-label {
    padding: 2px 8px;
    background: var(--accent-color);
    color: white;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.subscription-label.pro {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}

.subscription-label.ultimate {
    background: linear-gradient(135deg, #a855f7 0%, #7c3aed 100%);
}

/* Modal Overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-normal);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Subscription Modal */
.subscription-modal {
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    max-width: 900px;
    width: 95%;
    max-height: 90vh;
    overflow-y: auto;
    padding: 24px;
    transform: scale(0.9) translateY(20px);
    transition: transform var(--transition-normal);
}

.modal-overlay.active .subscription-modal {
    transform: scale(1) translateY(0);

}

/* Framed meta info inside the usage indicator (reset time, deep-search quota) */
.usage-indicator .usage-meta {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
}

.usage-indicator .usage-reset,
.usage-indicator .usage-deep {
    font-size: 11px;
    color: var(--muted-color, #9ca3af);
    padding: 8px 10px;
    border: 1px solid rgba(255,255,255,0.04);
    background: linear-gradient(180deg, rgba(255,255,255,0.01), transparent);
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
}

.usage-indicator .usage-deep.muted {
    opacity: 0.8;
}

/* Subscription info below plan cards */
.subscription-info.below-plans {
    margin: 12px 0 0 0;
    padding: 10px 14px;
    border-top: 1px solid rgba(255,255,255,0.04);
    background: linear-gradient(180deg, rgba(255,255,255,0.01), transparent);
    border-radius: 8px;
    grid-column: 1 / -1;
    width: 100%;
}
.subscription-info.below-plans p {
    margin: 0;
    font-size: 13px;
    color: var(--muted-color, #9ca3af);
    line-height: 1.4;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.modal-header h2 {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: all var(--transition-fast);
}

.modal-close:hover {
    background: var(--hover-bg);
    color: var(--text-primary);
}

/* Subscription Plans Grid */
.subscription-plans {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

/* Plan Card */
.plan-card {
    position: relative;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    transition: all var(--transition-normal);
}

.plan-card:hover {
    border-color: var(--accent-color);
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.plan-card.featured {
    border-color: var(--accent-color);
    background: var(--gradient-subtle);
}

.plan-card.active {
    border-color: #22c55e;
    box-shadow: 0 0 20px rgba(34, 197, 94, 0.2);
}

/* Plan Badge */
.plan-badge {
    position: absolute;
    top: -10px;
    right: 16px;
    padding: 4px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.plan-badge.popular {
    background: var(--accent-color);
    border-color: var(--accent-color);
    color: white;
}

/* Plan Icon */
.plan-icon {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    background: var(--gradient-subtle);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
    color: var(--accent-color);
}

.plan-card.featured .plan-icon {
    background: var(--accent-color);
    color: white;
}

/* Plan Name & Price */
.plan-name {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 8px 0;
}

.plan-price {
    margin-bottom: 20px;
}

.plan-price .price {
    font-size: 32px;
    font-weight: 700;
    color: var(--text-primary);
}

.plan-price .period {
    font-size: 14px;
    color: var(--text-secondary);
}

/* Plan Features */
.plan-features {
    list-style: none;
    padding: 0;
    margin: 0 0 24px 0;
    flex-grow: 1;
}

.plan-features li {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    font-size: 14px;
    color: var(--text-primary);
}

.plan-features li svg {
    flex-shrink: 0;
    color: #22c55e;
}

.plan-features li.disabled {
    color: var(--text-secondary);
    opacity: 0.6;
}

.plan-features li.disabled svg {
    color: var(--text-secondary);
}

/* Plan Button */
.plan-btn {
    width: 100%;
    padding: 12px 20px;
    border: 1px solid var(--accent-color);
    border-radius: 10px;
    background: transparent;
    color: var(--accent-color);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.plan-btn:hover:not(:disabled) {
    background: var(--accent-color);
    color: white;
}

.plan-btn.current {
    background: var(--bg-input);
    border-color: var(--border-color);
    color: var(--text-secondary);
    cursor: default;
}

.plan-card.featured .plan-btn {
    background: var(--accent-color);
    color: white;
}

.plan-card.featured .plan-btn:hover {
    background: var(--accent-hover);
}

/* Subscription Note */
.subscription-note {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px;
    background: var(--bg-input);
    border-radius: 10px;
    font-size: 13px;
    color: var(--text-secondary);
    text-align: center;
}

.subscription-note {
    grid-column: 1 / -1;
    width: 100%;
}

.subscription-note svg {
    flex-shrink: 0;
    color: var(--accent-color);
}

/* Framed warning for subscription info (below plans) */
.subscription-warning {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--bg-input);
    border-radius: 10px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}
.subscription-warning svg {
    flex-shrink: 0;
    color: var(--accent-color);
    margin-top: 2px;
}
.subscription-warning p {
    margin: 0;
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* Responsive */
@media (max-width: 768px) {
    .subscription-modal {
        padding: 16px;
        border-radius: 12px;
    }
    
    .subscription-plans {
        grid-template-columns: 1fr;
    }
    
    .plan-card {
        padding: 20px;
    }
}
