/* ══════════════════════════════════════
   OmniSolver Code — Chat Interface Styles
   Тёмная тема, код-эстетика, звёзды
   ══════════════════════════════════════ */

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

:root {
    --bg: #09090f;
    --bg-card: #0f0f1a;
    --bg-hover: #161625;
    --bg-input: #0c0c18;
    --border: #1a1a2e;
    --border-light: #252540;

    --text: #e2e2f0;
    --text-secondary: #8080a0;
    --text-muted: #4e4e6a;

    --primary: #6366f1;
    --primary-light: #818cf8;
    --primary-dark: #4f46e5;
    --primary-glow: rgba(99, 102, 241, 0.25);

    --accent: #06b6d4;
    --accent-light: #22d3ee;

    --gradient: linear-gradient(135deg, #6366f1, #06b6d4);
    --gradient-text: linear-gradient(135deg, #818cf8, #22d3ee);

    --code-bg: #0a0a16;
    --code-border: #1e1e35;

    --msg-user: #111122;
    --msg-ai: #0d0d1a;

    --sidebar-w: 280px;

    --radius: 12px;
    --radius-lg: 16px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);

    --font-code: 'JetBrains Mono', 'Fira Code', monospace;
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

a { color: var(--primary-light); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ══════════════════════════════════════
   Auth Screen
   ══════════════════════════════════════ */

.auth-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
    position: relative;
    overflow: hidden;
}

.auth-particles {
    position: absolute;
    inset: 0;
    background-image:
        radial-gradient(circle at 20% 30%, rgba(99, 102, 241, 0.08) 0%, transparent 50%),
        radial-gradient(circle at 80% 70%, rgba(6, 182, 212, 0.06) 0%, transparent 50%);
}

.auth-container {
    width: 100%;
    max-width: 400px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 36px;
    position: relative;
    z-index: 2;
    box-shadow: var(--shadow);
}

.auth-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    justify-content: center;
    margin-bottom: 8px;
}

.auth-logo h1 {
    font-size: 22px;
    font-weight: 800;
}

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

.auth-subtitle {
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 28px;
}

/* Auth tabs */
.auth-tabs {
    display: flex;
    gap: 4px;
    background: var(--bg);
    border-radius: 10px;
    padding: 3px;
    margin-bottom: 24px;
}

.auth-tab {
    flex: 1;
    padding: 8px;
    border: none;
    background: none;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border-radius: 8px;
    font-family: inherit;
    transition: var(--transition);
}

.auth-tab.active {
    background: var(--primary);
    color: #fff;
}

/* Forms */
.auth-form { display: flex; flex-direction: column; gap: 16px; }

.input-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.input-group label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
}

.input-group input {
    padding: 10px 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: var(--transition);
}

.input-group input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.auth-error {
    color: #f87171;
    font-size: 13px;
    display: none;
}

.auth-error.show {
    display: block;
}

.auth-footer {
    text-align: center;
    margin-top: 20px;
}

.auth-footer a {
    font-size: 13px;
    color: var(--text-muted);
}

/* ══════════════════════════════════════
   Buttons (shared)
   ══════════════════════════════════════ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 24px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    border: none;
    font-family: inherit;
}

.btn-primary {
    background: var(--gradient);
    color: #fff;
}

.btn-primary:hover {
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
    transform: translateY(-1px);
}

.btn-block { width: 100%; }

/* ══════════════════════════════════════
   Chat Layout
   ══════════════════════════════════════ */

.chat-screen {
    display: flex;
    height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
    width: var(--sidebar-w);
    min-width: var(--sidebar-w);
    height: 100vh;
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    transition: var(--transition);
    overflow: hidden;
}

.sidebar.collapsed {
    width: 0;
    min-width: 0;
    border-right: none;
}

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

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 15px;
}

.sidebar-toggle {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    transition: var(--transition);
}

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

/* New chat button */
.btn-new-chat {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 12px 12px 0;
    padding: 10px 14px;
    background: rgba(99, 102, 241, 0.1);
    border: 1px dashed rgba(99, 102, 241, 0.3);
    border-radius: 10px;
    color: var(--primary-light);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: var(--transition);
}

.btn-new-chat:hover {
    background: rgba(99, 102, 241, 0.18);
    border-color: var(--primary);
}

/* Chat list */
.sidebar-section {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

.sidebar-section-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 4px 4px 8px;
}

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

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

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

.chat-list-item.active {
    background: rgba(99, 102, 241, 0.12);
    color: var(--text);
}

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

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

.chat-list-item .chat-item-delete {
    opacity: 0;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px;
    border-radius: 4px;
    transition: var(--transition);
}

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

.chat-list-item .chat-item-delete:hover {
    color: #f87171;
}

/* Settings toggles */
.sidebar-bottom {
    border-top: 1px solid var(--border);
    padding: 12px;
}

.sidebar-settings {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}

.setting-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px 0;
}

.setting-toggle input { display: none; }

.toggle-slider {
    width: 36px;
    height: 20px;
    background: var(--border);
    border-radius: 10px;
    position: relative;
    transition: var(--transition);
}

.toggle-slider::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    background: var(--text-muted);
    border-radius: 50%;
    transition: var(--transition);
}

.setting-toggle input:checked + .toggle-slider {
    background: var(--primary);
}

.setting-toggle input:checked + .toggle-slider::after {
    left: 18px;
    background: #fff;
}

/* Token bar */
.token-bar {
    background: var(--bg);
    border-radius: 10px;
    padding: 10px 12px;
    margin-bottom: 12px;
}

.token-bar-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
}

.token-bar-label {
    font-size: 11px;
    color: var(--text-muted);
}

.token-bar-value {
    font-size: 11px;
    color: var(--text-secondary);
    font-family: var(--font-code);
}

.token-bar-track {
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
}

.token-bar-fill {
    height: 100%;
    background: var(--gradient);
    border-radius: 2px;
    transition: width 0.5s ease;
}

.token-bar-reset {
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* User section */
.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: 10px;
    background: var(--bg);
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
}

.user-info {
    flex: 1;
    min-width: 0;
}

.user-name {
    display: block;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-sub {
    font-size: 11px;
    color: var(--text-muted);
}

.btn-logout {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    transition: var(--transition);
}

.btn-logout:hover {
    color: #f87171;
    background: rgba(248, 113, 113, 0.1);
}

/* ── Main Chat ── */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    height: 100vh;
}

/* Top bar */
.chat-topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
    background: rgba(9, 9, 15, 0.8);
    backdrop-filter: blur(12px);
    min-height: 52px;
}

.sidebar-open-btn {
    display: none;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    transition: var(--transition);
}

.sidebar-open-btn:hover {
    background: var(--bg-hover);
    color: var(--text);
}

/* Show sidebar-open-btn when sidebar collapsed */
.sidebar.collapsed ~ .chat-main .sidebar-open-btn {
    display: block;
}

.chat-topbar-logo {
    display: flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    color: var(--text);
    font-weight: 700;
    font-size: 14px;
    transition: var(--transition);
}

.chat-topbar-logo:hover {
    opacity: 0.8;
    text-decoration: none;
}

.chat-topbar-brand {
    background: linear-gradient(135deg, #818cf8, #22d3ee);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.chat-topbar-title {
    font-size: 14px;
    font-weight: 600;
    flex: 1;
    margin-left: 8px;
}

.chat-topbar-model {
    font-size: 11px;
    color: var(--text-muted);
    font-family: var(--font-code);
}

/* Messages area */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* Scrollbar */
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

.sidebar-section::-webkit-scrollbar {
    width: 4px;
}

.sidebar-section::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 2px;
}

/* Welcome */
.chat-welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    text-align: center;
    padding: 40px 20px;
}

.welcome-icon {
    margin-bottom: 16px;
    opacity: 0.8;
}

.chat-welcome h2 {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 8px;
}

.chat-welcome p {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 28px;
}

.welcome-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    max-width: 500px;
}

.suggestion-chip {
    padding: 8px 16px;
    border-radius: 100px;
    background: rgba(99, 102, 241, 0.08);
    border: 1px solid rgba(99, 102, 241, 0.15);
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    font-family: inherit;
    transition: var(--transition);
}

.suggestion-chip:hover {
    background: rgba(99, 102, 241, 0.18);
    color: var(--text);
    border-color: var(--primary);
}

/* ── Messages (ChatGPT-style layout) ── */
.message {
    display: flex;
    gap: 12px;
    animation: msg-in 0.3s ease;
    position: relative;
    max-width: 820px;
    width: 100%;
    margin: 0 auto;
    padding: 4px 0;
}

@keyframes msg-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.message-user {
    flex-direction: row-reverse;
    justify-content: flex-start;
    margin-left: auto;
    margin-right: 0;
}

.message-ai {
    flex-direction: row;
    justify-content: flex-start;
    margin-left: 0;
    margin-right: auto;
}

/* Avatars */
.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    flex-shrink: 0;
    margin-top: 2px;
}

.message-avatar.msg-user-avatar {
    background: var(--gradient);
    color: #fff;
}

.message-avatar.msg-ai-avatar {
    background: #1e1e35;
    color: var(--primary-light);
    border: 1px solid var(--border);
}

.msg-ai-avatar svg {
    width: 18px;
    height: 18px;
}

/* User message bubble */
.message-user .message-bubble {
    background: rgba(99, 102, 241, 0.12);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 18px 18px 4px 18px;
    padding: 10px 16px;
    max-width: 70%;
}

/* AI message body */
.message-body {
    flex: 1;
    min-width: 0;
}

/* Action buttons under AI messages */
.message-actions {
    display: flex;
    gap: 4px;
    margin-top: 8px;
    opacity: 0;
    transition: opacity 0.2s;
}
.message:hover .message-actions,
.message-actions.visible { opacity: 1; }

.msg-action {
    background: none;
    border: 1px solid transparent;
    border-radius: 6px;
    padding: 4px 8px;
    cursor: pointer;
    font-size: 14px;
    color: #888;
    transition: all 0.15s;
    line-height: 1;
}
.msg-action:hover { background: rgba(255,255,255,0.06); border-color: rgba(255,255,255,0.1); }
.msg-action.liked { color: #22c55e; }
.msg-action.disliked { color: #ef4444; }
.msg-action.voted { pointer-events: none; opacity: 0.5; }
.message-actions.voted { opacity: 1; }
.feedback-thanks {
    font-size: 11px;
    color: #22c55e;
    margin-left: 8px;
    animation: fadeInThanks 0.3s ease;
}
@keyframes fadeInThanks { from { opacity: 0; transform: translateX(-4px); } to { opacity: 1; transform: translateX(0); } }

.message-tokens {
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 4px;
    font-family: var(--font-code);
}

/* Streaming cursor animation */
.streaming .message-content::after {
    content: '▋';
    animation: cursor-blink 1s step-end infinite;
    color: #6366f1;
    margin-left: 1px;
    font-size: 14px;
}
@keyframes cursor-blink { 50% { opacity: 0; } }

/* Web search indicator */
.search-step {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    margin-bottom: 8px;
    background: rgba(99, 102, 241, 0.06);
    border: 1px solid rgba(99, 102, 241, 0.12);
    border-radius: 10px;
    font-size: 13px;
    color: var(--text-secondary);
    animation: msg-in 0.3s ease;
}
.search-icon { font-size: 16px; }
.search-label { font-weight: 600; color: var(--text); }
.search-query { color: var(--primary-light); font-style: italic; }
.search-status { color: #22c55e; margin-left: auto; }
.search-step.searching .search-status {
    animation: pulse-search 1.2s infinite;
}
@keyframes pulse-search {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.message-content {
    font-size: 14px;
    line-height: 1.65;
    color: var(--text);
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Code blocks in messages */
.message-content pre {
    background: var(--code-bg);
    border: 1px solid var(--code-border);
    border-radius: 10px;
    overflow-x: auto;
    margin: 12px 0;
    position: relative;
}

.message-content pre .code-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 14px;
    background: rgba(255, 255, 255, 0.02);
    border-bottom: 1px solid var(--code-border);
    font-family: var(--font-code);
    font-size: 11px;
    color: var(--text-muted);
}

.code-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.code-actions button {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 11px;
    font-family: inherit;
    padding: 2px 8px;
    border-radius: 4px;
    transition: var(--transition);
}

.code-actions button:hover {
    color: var(--text);
    background: var(--bg-hover);
}

.code-actions button.liked { color: #22c55e; }
.code-actions button.disliked { color: #ef4444; }

.btn-copy {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 11px;
    font-family: inherit;
    padding: 2px 8px;
    border-radius: 4px;
    transition: var(--transition);
}

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

.btn-copy.copied {
    color: #22c55e;
}

.message-content pre code {
    display: block;
    padding: 14px;
    font-family: var(--font-code);
    font-size: 13px;
    line-height: 1.6;
    color: var(--text);
    overflow-x: auto;
}

/* Стилизованный горизонтальный скролл для кода */
.message-content pre code::-webkit-scrollbar { height: 6px; }
.message-content pre code::-webkit-scrollbar-track { background: rgba(255,255,255,0.02); border-radius: 3px; }
.message-content pre code::-webkit-scrollbar-thumb { background: rgba(99,102,241,0.3); border-radius: 3px; }
.message-content pre code::-webkit-scrollbar-thumb:hover { background: rgba(99,102,241,0.5); }
.message-content pre::-webkit-scrollbar { height: 6px; }
.message-content pre::-webkit-scrollbar-track { background: rgba(255,255,255,0.02); border-radius: 3px; }
.message-content pre::-webkit-scrollbar-thumb { background: rgba(99,102,241,0.3); border-radius: 3px; }
.message-content pre::-webkit-scrollbar-thumb:hover { background: rgba(99,102,241,0.5); }

/* Inline code */
.message-content code:not(pre code) {
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.15);
    border-radius: 5px;
    padding: 1px 6px;
    font-family: var(--font-code);
    font-size: 0.9em;
    color: var(--primary-light);
}

/* Syntax highlighting */
.hl-keyword { color: #c792ea; }
.hl-string { color: #c3e88d; }
.hl-comment { color: #546e7a; font-style: italic; }
.hl-number { color: #f78c6c; }
.hl-function { color: #82aaff; }
.hl-builtin { color: #ffcb6b; }
.hl-self { color: #f07178; }
.hl-decorator { color: #c792ea; font-style: italic; }

/* Think mode — collapsible details */
.think-block {
    margin: 12px 0;
    background: rgba(139, 92, 246, 0.08);
    border: 1px solid rgba(139, 92, 246, 0.2);
    border-left: 3px solid #a78bfa;
    border-radius: 0 10px 10px 0;
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.7;
    overflow: hidden;
}

.think-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: #a78bfa;
    user-select: none;
    list-style: none;
    transition: background 0.15s;
}

.think-header:hover {
    background: rgba(139, 92, 246, 0.12);
}

.think-header::-webkit-details-marker { display: none; }
.think-header::marker { display: none; content: ''; }

.think-icon { font-size: 15px; }

.think-chevron {
    margin-left: auto;
    transition: transform 0.2s;
    font-size: 16px;
    font-weight: 700;
}

.think-block[open] .think-chevron {
    transform: rotate(90deg);
}

.think-content {
    padding: 0 16px 14px;
    font-style: italic;
    color: rgba(167, 139, 250, 0.8);
    white-space: pre-wrap;
    border-top: 1px solid rgba(139, 92, 246, 0.15);
    margin-top: 0;
    padding-top: 12px;
    font-size: 12.5px;
    line-height: 1.7;
}

/* Loading dots */
.loading-dots {
    display: flex;
    gap: 4px;
    padding: 8px 0;
}

.loading-dots span {
    width: 6px;
    height: 6px;
    background: var(--primary-light);
    border-radius: 50%;
    animation: bounce-dot 1.2s infinite;
}

.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce-dot {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.3; }
    40% { transform: scale(1); opacity: 1; }
}

/* ── Input Area ── */
.chat-input-area {
    padding: 12px 20px 16px;
    border-top: 1px solid var(--border);
    background: var(--bg);
}

.chat-input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px 12px;
    transition: var(--transition);
}

.chat-input-wrapper:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

#chat-input {
    flex: 1;
    background: none;
    border: none;
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    resize: none;
    outline: none;
    max-height: 200px;
    line-height: 1.5;
    padding: 4px 0;
}

#chat-input::placeholder {
    color: var(--text-muted);
}

.btn-voice {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    transition: var(--transition);
}
.btn-voice:hover { color: var(--primary-light); }
.btn-voice.recording {
    color: #ef4444;
    animation: pulse-record 1.5s ease-in-out infinite;
}
@keyframes pulse-record { 0%,100% { opacity: 1; } 50% { opacity: 0.5; } }

.btn-attach, .btn-send {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    transition: var(--transition);
    flex-shrink: 0;
}

.btn-attach:hover { color: var(--text-secondary); }
.btn-send:hover { color: var(--primary-light); }

.btn-send.active {
    color: var(--primary);
}

.btn-stop {
    background: none;
    border: none;
    color: #f87171;
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    transition: var(--transition);
    flex-shrink: 0;
    animation: pulse-stop 1.5s infinite;
}

.btn-stop:hover {
    background: rgba(248, 113, 113, 0.1);
}

@keyframes pulse-stop {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.chat-input-hint {
    font-size: 11px;
    color: var(--text-muted);
    text-align: center;
    margin-top: 6px;
}

/* Attachments preview */
.chat-input-attachments {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    padding: 8px 0;
}

.attachment-preview {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 12px;
    color: var(--text-secondary);
}

.attachment-preview .attachment-remove {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0;
    font-size: 14px;
}

/* ══════════════════════════════════════
   Responsive
   ══════════════════════════════════════ */

/* ── Model Selector ── */
.model-selector {
    margin-bottom: 12px;
    position: relative;
}

.model-selector-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 6px;
}

.model-selector-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 10px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
}

.model-selector-btn:hover {
    border-color: var(--primary);
}

.model-selector-icon { font-size: 14px; }
.model-selector-name { flex: 1; text-align: left; font-weight: 600; }
.model-selector-cost {
    font-size: 10px;
    color: var(--text-muted);
    font-family: var(--font-code);
    background: rgba(99, 102, 241, 0.1);
    padding: 1px 6px;
    border-radius: 4px;
}

.model-dropdown {
    display: none;
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 6px;
    z-index: 60;
    box-shadow: var(--shadow);
    max-height: 320px;
    overflow-y: auto;
    margin-bottom: 4px;
}

.model-dropdown.show { display: block; }

.model-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition);
    border: none;
    background: none;
    width: 100%;
    font-family: inherit;
    text-align: left;
    color: var(--text);
}

.model-option:hover { background: var(--bg-hover); }
.model-option.active { background: rgba(99, 102, 241, 0.12); }

.model-option.locked {
    opacity: 0.4;
    cursor: not-allowed;
}

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

.model-option-info { flex: 1; min-width: 0; }

.model-option-name {
    font-size: 12px;
    font-weight: 600;
    display: block;
}

.model-option-desc {
    font-size: 10px;
    color: var(--text-muted);
    display: block;
}

.model-option-cost {
    font-size: 10px;
    color: var(--text-muted);
    font-family: var(--font-code);
    flex-shrink: 0;
}

.model-option-lock {
    font-size: 12px;
    flex-shrink: 0;
}

/* ── Cost Warning ── */
.cost-warning-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 70;
    backdrop-filter: blur(4px);
}

.cost-warning-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 28px;
    max-width: 420px;
    text-align: center;
    box-shadow: var(--shadow);
}

.cost-warning-icon { font-size: 36px; margin-bottom: 12px; }
.cost-warning-title { font-size: 16px; font-weight: 700; margin-bottom: 8px; }

.cost-warning-text {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 20px;
}

.cost-warning-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.cost-warning-actions .btn {
    padding: 8px 20px;
    font-size: 13px;
}

.btn-ghost {
    background: rgba(99, 102, 241, 0.08);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-ghost:hover {
    background: rgba(99, 102, 241, 0.15);
    border-color: var(--primary);
}

/* ── Suggestion chips updated ── */
.welcome-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    max-width: 600px;
}

.suggestion-chip {
    padding: 8px 16px;
    border-radius: 100px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    font-family: inherit;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 6px;
}

.chip-icon { font-size: 14px; }

.suggestion-chip:hover {
    background: rgba(99, 102, 241, 0.12);
    color: var(--text);
    border-color: rgba(99, 102, 241, 0.3);
}

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        z-index: 50;
        transform: translateX(0);
    }

    .sidebar.collapsed {
        transform: translateX(-100%);
        width: var(--sidebar-w);
        min-width: var(--sidebar-w);
    }

    .sidebar-open-btn {
        display: block !important;
    }

    .chat-messages {
        padding: 12px;
    }

    .message {
        padding: 4px 0;
    }

    .message-user .message-bubble {
        max-width: 85%;
    }

    .message-avatar {
        width: 28px;
        height: 28px;
        font-size: 11px;
    }

    .chat-input-area {
        padding: 8px 12px 12px;
    }
}

/* ══════════════════════════════════════
   Subscription Modal
   ══════════════════════════════════════ */

.modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.modal-content {
    position: relative;
    z-index: 2;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow);
}

/* Custom scrollbar */
.modal-content::-webkit-scrollbar { width: 6px; }
.modal-content::-webkit-scrollbar-track { background: transparent; }
.modal-content::-webkit-scrollbar-thumb {
    background: rgba(99, 102, 241, 0.3);
    border-radius: 3px;
}
.modal-content::-webkit-scrollbar-thumb:hover {
    background: rgba(99, 102, 241, 0.6);
}

.modal-wide { max-width: 520px; width: 90%; }

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

.modal-header h3 { font-size: 16px; font-weight: 700; }

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 24px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    transition: var(--transition);
}

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

.modal-body { padding: 18px 22px; }

.modal-divider {
    height: 1px;
    background: var(--border);
    margin: 18px 0;
}

.modal-section-title {
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 10px;
}

.modal-input {
    width: 100%;
    padding: 8px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 13px;
    font-family: inherit;
    outline: none;
    margin-bottom: 8px;
    transition: var(--transition);
}

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

.modal-select {
    padding: 6px 10px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 12px;
    font-family: inherit;
    outline: none;
}

/* ── Account Modal ── */
.acc-body { display: flex; flex-direction: column; gap: 14px; }
.acc-avatar-wrap { display: flex; justify-content: center; }
.acc-avatar {
    width: 64px; height: 64px; font-size: 28px; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    border-radius: 50%; background: var(--gradient); color: #fff;
}
.acc-row { display: flex; gap: 10px; }
.acc-row .acc-field { flex: 1; }
.acc-field { display: flex; flex-direction: column; gap: 4px; }
.acc-field .modal-input { margin-bottom: 0; }
.acc-label { font-size: 11px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; }
.acc-inline { display: flex; gap: 8px; align-items: center; }
.acc-inline .modal-input { flex: 1; margin-bottom: 0; }
.acc-inline .btn { white-space: nowrap; padding: 6px 14px; font-size: 12px; }
.acc-hint { font-size: 11px; color: var(--text-secondary); margin-top: 4px; }
.acc-status-ok { font-size: 11px; color: #22c55e; white-space: nowrap; }
.acc-gh-login { font-size: 13px; font-weight: 500; }
.acc-unlink-btn { margin-left: auto; font-size: 11px; padding: 4px 12px; color: #f66 !important; }
.acc-logout-btn { color: #f66 !important; font-size: 13px; padding: 8px 16px; align-self: flex-start; }

/* Sub current info */
.sub-current {
    padding: 12px;
    background: rgba(99,102,241,0.08);
    border: 1px solid rgba(99,102,241,0.2);
    border-radius: 10px;
    font-size: 13px;
    line-height: 1.6;
}

/* Sub grid */
.sub-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-top: 16px;
}

.sub-card {
    padding: 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
}

.sub-card:hover { border-color: var(--border-light); }
.sub-card.active { border-color: var(--primary); background: rgba(99,102,241,0.08); }
.sub-card.current { opacity: 0.5; cursor: default; }

.sub-card-emoji { font-size: 24px; }
.sub-card-name { font-size: 13px; font-weight: 700; margin: 4px 0; }
.sub-card-price { font-size: 11px; color: var(--text-muted); }
.sub-card-model { font-size: 10px; color: var(--text-muted); margin-top: 4px; }

/* Slider */
.sub-slider-section { margin-top: 20px; }

.sub-selected-name {
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 12px;
    text-align: center;
}

.sub-slider-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 4px;
}

.sub-slider {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    outline: none;
}

.sub-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    background: var(--primary);
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid var(--bg);
}

.sub-days-label {
    font-size: 14px;
    font-weight: 700;
    min-width: 75px;
    text-align: right;
}

.sub-price-row {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 10px;
    margin: 14px 0;
}

.sub-price { font-size: 28px; font-weight: 800; letter-spacing: -1px; }
.sub-price-per-day { font-size: 12px; color: var(--text-muted); }
.sub-model-info { font-size: 12px; color: var(--text-secondary); text-align: center; margin-bottom: 14px; }

/* Gift tabs */
.gift-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 10px;
}

.gift-tab {
    padding: 5px 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-muted);
    font-family: inherit;
    font-size: 12px;
    cursor: pointer;
    transition: var(--transition);
}

.gift-tab.active {
    border-color: var(--primary);
    color: var(--primary-light);
}

.gift-sub-row {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
}

.gift-sub-row .modal-input {
    flex: 1;
    min-width: 100px;
    margin-bottom: 0;
}

/* Sidebar sub button */
.sub-sidebar-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 0;
    background: none;
    border: none;
    color: var(--text);
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    margin-bottom: 8px;
}

.sub-sidebar-btn:hover { color: var(--primary-light); }
.sub-arrow { margin-left: auto; color: var(--text-muted); font-size: 14px; }

/* ── Markdown in messages ── */
.message-content h1,
.message-content h2,
.message-content h3 {
    margin: 16px 0 8px;
    font-weight: 700;
}

.message-content h1 { font-size: 18px; }
.message-content h2 { font-size: 16px; }
.message-content h3 { font-size: 15px; }

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

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

.message-content li {
    margin: 4px 0;
    list-style: disc;
}

.message-content ol li {
    list-style: decimal;
}

.message-content blockquote {
    border-left: 3px solid var(--border-light);
    padding-left: 14px;
    margin: 8px 0;
    color: var(--text-secondary);
}

.message-content strong { font-weight: 700; }
.message-content em { font-style: italic; }

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

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

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

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