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

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--bg-main);
    overflow: hidden;
    height: 100vh;
    height: 100dvh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
ul, ol { list-style: none; }
img { max-width: 100%; display: block; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea, select { font-family: inherit; font-size: inherit; }

/* ── Dark (default) ── */
:root {
    --bg-main: #171717;
    --bg-sidebar: #0f0f0f;
    --bg-input: #262626;
    --bg-hover: #2a2a2a;
    --bg-card: #1c1c1c;
    --bg-message-user: #262626;
    --text-primary: #f0f0f0;
    --text-secondary: #a1a1a1;
    --text-muted: #666;
    --accent: #4D82F0;
    --accent-hover: #3b6fd9;
    --accent-glow: rgba(77,130,240,.2);
    --accent-gradient: linear-gradient(135deg, rgba(77,130,240,.3), rgba(90,138,165,.3));
    --accent-border: rgba(160,212,255,.3);
    --border: #2a2a2a;
    --danger: #ef4444;
    --premium: #f5a623;
    --success: #22c55e;
    --radius: 16px;
    --radius-sm: 10px;
    --sidebar-width: 260px;
    --topbar-height: 56px;
    --code-bg: #111;
    --code-header-bg: rgba(255,255,255,.04);
}

/* ── Light ── */
body.theme-light {
    --bg-main: #ffffff;
    --bg-sidebar: #f8f9fa;
    --bg-input: #f0f1f3;
    --bg-hover: #e9eaed;
    --bg-card: #f5f6f8;
    --bg-message-user: #f0f1f3;
    --text-primary: #111;
    --text-secondary: #555;
    --text-muted: #999;
    --accent: #2e62cd;
    --accent-hover: #2454b5;
    --accent-glow: rgba(46,98,205,.12);
    --accent-gradient: linear-gradient(135deg, rgba(77,130,240,.15), rgba(90,138,165,.15));
    --accent-border: rgba(77,130,240,.25);
    --border: #e5e5e5;
    --code-bg: #f5f5f5;
    --code-header-bg: rgba(0,0,0,.04);
}

.hidden { display: none !important; }

/* Scrollbar */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ============================================================
   Loading
   ============================================================ */
.loading-screen {
    position: fixed; inset: 0;
    display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 16px;
    background: var(--bg-main);
    z-index: 9999;
    transition: opacity .3s;
}
.loading-screen.fade-out { opacity: 0; pointer-events: none; }

.spinner {
    width: 32px; height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}
.loading-screen p { color: var(--text-muted); font-size: .85rem; font-weight: 600; letter-spacing: 1px; }

/* ============================================================
   App Container
   ============================================================ */
.app-container { display: flex; height: 100vh; height: 100dvh; width: 100%; }

/* ============================================================
   Sidebar
   ============================================================ */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    height: 100vh; height: 100dvh;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column;
    transition: transform .25s ease;
    z-index: 100;
}

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

.sidebar-logo {
    font-size: .85rem; font-weight: 800; letter-spacing: 1.5px;
    color: var(--accent);
}

.sidebar-close {
    width: 30px; height: 30px;
    display: flex; align-items: center; justify-content: center;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    transition: background .15s, color .15s;
}
.sidebar-close:hover { background: var(--bg-hover); color: var(--text-primary); }

.sidebar-new-chat { padding: 4px 10px 8px; }

.new-chat-btn {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    width: 100%;
    padding: 9px 14px;
    border: 1px solid var(--border);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    font-size: .85rem; font-weight: 500;
    transition: background .15s;
}
.new-chat-btn:hover { background: var(--bg-hover); text-decoration: none; }

/* Sidebar nav (Галерея) */
.sidebar-nav {
    padding: 0 10px 6px;
    display: flex; flex-direction: column; gap: 2px;
}

.sidebar-nav-btn {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    font-size: .85rem; color: var(--text-secondary);
    transition: background .15s, color .15s;
    text-align: left; width: 100%;
}
.sidebar-nav-btn:hover { background: var(--bg-hover); color: var(--text-primary); text-decoration: none; }
.sidebar-nav-btn.active { background: var(--bg-hover); color: var(--accent); }

/* Chat list */
.sidebar-chats {
    flex: 1; overflow-y: auto;
    padding: 2px 10px;
    scrollbar-width: thin; scrollbar-color: var(--border) transparent;
}
.sidebar-chats::-webkit-scrollbar { width: 4px; }
.sidebar-chats::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.sidebar-section-title {
    font-size: .72rem; font-weight: 600;
    color: var(--text-muted);
    padding: 10px 10px 4px;
    text-transform: uppercase;
    letter-spacing: .5px;
}

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

.chat-list-item {
    display: flex; align-items: center; gap: 8px;
    padding: 9px 10px;
    border-radius: var(--radius-sm);
    font-size: .84rem; color: var(--text-secondary);
    cursor: pointer; width: 100%;
    text-align: left; white-space: nowrap; overflow: hidden;
    transition: background .15s, color .15s;
    position: relative;
    text-decoration: none;
}
.chat-list-item:hover { background: var(--bg-hover); color: var(--text-primary); text-decoration: none; }
.chat-list-item.active { background: var(--bg-hover); color: var(--text-primary); font-weight: 500; }

.chat-list-item .chat-delete {
    display: flex; align-items: center; justify-content: center;
    width: 28px; height: 100%;
    position: absolute; right: 0; top: 0;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    color: var(--text-muted);
    opacity: 0;
    background: linear-gradient(to right, transparent, var(--bg-hover) 40%);
    transition: opacity .15s, color .15s;
    padding-right: 6px;
}
.chat-list-item:hover .chat-delete { opacity: 1; }
.chat-delete:hover { color: var(--danger); }

/* Sidebar articles (unauthenticated users) */
.sidebar-articles {
    flex: 1; overflow-y: auto;
    padding: 2px 10px;
    scrollbar-width: thin; scrollbar-color: var(--border) transparent;
}
.sidebar-articles::-webkit-scrollbar { width: 4px; }
.sidebar-articles::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

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

.article-list-item {
    display: flex; align-items: center; gap: 8px;
    padding: 9px 10px;
    border-radius: var(--radius-sm);
    font-size: .84rem; color: var(--text-secondary);
    cursor: pointer; width: 100%;
    text-align: left; white-space: nowrap; overflow: hidden;
    transition: background .15s, color .15s;
    text-decoration: none;
}
.article-list-item:hover { background: var(--bg-hover); color: var(--text-primary); text-decoration: none; }
.article-list-item svg { flex-shrink: 0; }

/* Sidebar footer */
.sidebar-footer {
    padding: 0 10px 10px;
}

.sidebar-bottom-section {
    display: flex; flex-direction: column; gap: 1px;
    max-height: 0; overflow: hidden; opacity: 0;
    transition: max-height .3s cubic-bezier(.4,0,.2,1), opacity .2s ease, padding .3s ease, margin .3s ease;
    background: #313131;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    padding: 0 4px;
    margin-bottom: 0;
}
body.theme-light .sidebar-bottom-section {
    background: #fff;
}
.sidebar-footer.menu-open .sidebar-bottom-section {
    max-height: 400px; opacity: 1;
    border-color: var(--border);
    box-shadow: 0 4px 16px rgba(0,0,0,.10);
    padding: 4px 4px;
    margin-bottom: 6px;
}

.sidebar-menu-item {
    display: flex; align-items: center; gap: 10px;
    width: 100%;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    font-size: .84rem; color: var(--text-secondary);
    text-align: left;
    transition: background .15s, color .15s;
}
.sidebar-menu-item:hover { background: var(--bg-hover); color: var(--text-primary); text-decoration: none; }
.sidebar-menu-item.logout:hover { color: var(--danger); }

/* Documents popup menu */
.docs-menu-wrapper { position: relative; }

.docs-popup {
    position: absolute;
    bottom: 100%;
    left: 8px;
    margin-bottom: 6px;
    min-width: 240px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: 0 4px 16px rgba(0,0,0,.18);
    padding: 4px 0;
    z-index: 100;
}

.docs-popup-item {
    display: block;
    padding: 10px 16px;
    font-size: .84rem;
    color: var(--text-secondary);
    text-decoration: none;
    transition: background .15s, color .15s;
}

.docs-popup-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    text-decoration: none;
}

.sidebar-user-info {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 10px 8px;
    margin-top: 4px;
    border-top: 1px solid var(--border);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: background .15s ease;
    user-select: none;
    position: relative;
}
.sidebar-user-info:hover {
    background: var(--bg-hover);
}
.sidebar-user-info .chevron-icon {
    flex-shrink: 0;
    width: 16px; height: 16px;
    color: var(--text-muted);
    transition: transform .25s cubic-bezier(.4,0,.2,1);
}
.sidebar-footer.menu-open .sidebar-user-info .chevron-icon {
    transform: rotate(180deg);
}

.sidebar-profile-avatar {
    width: 28px; height: 28px;
    border-radius: 50%;
    background: #9ca3af;
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: .75rem; font-weight: 700; flex-shrink: 0;
}

.sidebar-user-details {
    flex: 1; min-width: 0;
    display: flex; flex-direction: column;
}
.sidebar-user-details > span:first-child {
    font-size: .82rem; font-weight: 500;
    color: var(--text-primary);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sidebar-user-email {
    font-size: .72rem; color: var(--text-muted);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.sidebar-tariff-badge {
    font-size: .68rem; font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    background: var(--text-muted); color: #fff;
    white-space: nowrap; flex-shrink: 0;
}
.sidebar-tariff-badge.premium { background: var(--premium); color: #000; }

/* Demo footer — push to bottom */
#sidebarFooterDemo {
    margin-top: auto;
}

/* Demo auth block */
.sidebar-demo-auth {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 10px;
    margin-top: 4px;
    border-top: 1px solid var(--border);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: background .15s;
}
.sidebar-demo-auth:hover { background: var(--bg-hover); }

.sidebar-demo-auth-icon {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}

.sidebar-demo-auth-text {
    display: flex; flex-direction: column;
    font-size: .82rem; line-height: 1.3;
}
.sidebar-demo-auth-text strong { color: var(--text-primary); }
.sidebar-demo-auth-text span { color: var(--text-muted); font-size: .75rem; }

.sidebar-auth-btn {
    width: 100%; padding: 10px;
    background: var(--accent); color: #fff;
    border-radius: var(--radius-sm);
    font-size: .85rem; font-weight: 600;
    transition: background .15s;
}
.sidebar-auth-btn:hover { background: var(--accent-hover); }

/* Sidebar overlay */
.sidebar-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 99;
}
.sidebar-overlay.visible { display: block; }

/* ============================================================
   Main Area
   ============================================================ */
.main {
    flex: 1; display: flex; flex-direction: column;
    min-width: 0; height: 100vh; height: 100dvh; position: relative;
}

/* Topbar */
.topbar {
    height: var(--topbar-height);
    display: flex; align-items: center;
    padding: 0 16px; gap: 8px;
    flex-shrink: 0;
    position: sticky; top: 0; z-index: 50;
    background: color-mix(in srgb, var(--bg-main) 85%, transparent);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid color-mix(in srgb, var(--border) 40%, transparent);
}

.topbar-spacer { flex: 1; }

.menu-btn {
    display: none;
    width: 36px; height: 36px;
    align-items: center; justify-content: center;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    transition: background .15s;
}
.menu-btn:hover { background: var(--bg-hover); }

/* Model dropdown */
.model-dropdown-btn {
    display: flex; align-items: center; gap: 6px;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: .88rem; font-weight: 600;
    color: var(--text-primary);
    transition: background .15s;
}
.model-dropdown-btn:hover { background: var(--bg-hover); }

.model-dropdown {
    position: absolute;
    top: calc(var(--topbar-height) - 4px);
    left: 16px;
    width: 320px; max-height: 420px;
    overflow-y: auto;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 8px 32px rgba(0,0,0,.4);
    padding: 6px;
    z-index: 200;
    animation: fadeIn .12s ease;
    scrollbar-width: thin;
}
body.theme-light .model-dropdown { box-shadow: 0 8px 32px rgba(0,0,0,.12); }

.model-category-header {
    font-size: .7rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: .5px;
    color: var(--text-muted);
    padding: 8px 10px 4px;
    display: flex; align-items: center; justify-content: space-between;
}

.model-counter {
    font-size: .65rem; font-weight: 600;
    padding: 1px 7px;
    border-radius: 10px;
    background: var(--accent); color: #fff;
}

.model-item {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background .15s;
}
.model-item:hover { background: var(--bg-hover); }
.model-item.active { background: var(--accent); color: #fff; }
.model-item.active .model-item-desc { color: rgba(255,255,255,.7); }
.model-item.locked { cursor: pointer; }
.model-item.locked:hover { background: var(--bg-hover); }

.model-item-info { flex: 1; min-width: 0; }
.model-item-name { font-size: .86rem; font-weight: 500; }
.model-item-desc {
    font-size: .72rem; color: var(--text-muted);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Premium button in topbar */
.topbar-premium-btn {
    display: flex; align-items: center; gap: 6px;
    padding: 7px 16px;
    background: var(--accent-gradient);
    border: 1px solid var(--accent-border);
    border-radius: 20px;
    font-size: .82rem; font-weight: 600;
    color: var(--accent);
    transition: all .2s;
}
.topbar-premium-btn:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    box-shadow: 0 4px 16px var(--accent-glow);
}

.topbar-theme-btn {
    display: flex; align-items: center; justify-content: center;
    width: 36px; height: 36px;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: all .2s;
    margin-right: 8px;
}
.topbar-theme-btn:hover {
    color: var(--text-primary);
    border-color: var(--text-muted);
    background: var(--bg-hover);
}

/* ============================================================
   Article View (SPA)
   ============================================================ */
.article-view {
    flex: 1; overflow-y: auto;
    padding: 0 20px;
}
.article-view-inner {
    max-width: 780px;
    margin: 0 auto;
    padding: 24px 0 60px;
}
.article-view-back {
    margin-bottom: 20px;
}
.article-view-back a {
    font-size: .88rem;
    color: var(--text-muted);
    text-decoration: none;
    transition: color .15s;
}
.article-view-back a:hover { color: var(--text-primary); }

.article-view-content h1 {
    font-size: 1.7rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.3;
    margin-bottom: 10px;
}
.article-view-meta {
    font-size: .82rem;
    color: var(--text-muted);
    margin-bottom: 24px;
}
.article-view-preview {
    width: 100%;
    max-height: 400px;
    object-fit: cover;
    border-radius: 12px;
    margin-bottom: 24px;
}
.article-view-body {
    font-size: .98rem;
    line-height: 1.7;
    color: var(--text-secondary);
}
.article-view-body * {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif !important;
}
.article-view-body h2 {
    font-size: 1.3rem; font-weight: 600; color: var(--text-primary);
    margin: 28px 0 12px;
}
.article-view-body h3 {
    font-size: 1.1rem; font-weight: 600; color: var(--text-primary);
    margin: 24px 0 10px;
}
.article-view-body p { margin-bottom: 16px; }
.article-view-body ul, .article-view-body ol { margin: 0 0 16px 24px; }
.article-view-body li { margin-bottom: 6px; }
.article-view-body img { max-width: 100%; height: auto !important; border-radius: 8px; margin: 16px 0; }
.article-view-body blockquote {
    border-left: 3px solid var(--border);
    padding: 8px 16px; margin: 16px 0;
    color: var(--text-muted); font-style: italic;
}
.article-view-body pre {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px; overflow-x: auto;
    margin: 16px 0; font-size: .88rem;
}
.article-view-body code { font-family: 'Courier New', monospace; font-size: .9em; }
.article-view-body table { width: 100%; border-collapse: collapse; margin: 16px 0; }
.article-view-body th, .article-view-body td {
    border: 1px solid var(--border); padding: 8px 12px; text-align: left;
}
.article-view-body th { background: var(--bg-secondary); color: var(--text-primary); }

/* Docs catalog (SPA view) */
.doc-catalog-list {
    display: flex; flex-direction: column; gap: 12px;
    margin-top: 20px;
}
.doc-catalog-card {
    display: block; padding: 20px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    text-decoration: none;
    transition: border-color .15s;
}
.doc-catalog-card:hover { border-color: var(--text-muted); text-decoration: none; }
.doc-catalog-title {
    font-size: 1.05rem; font-weight: 600;
    color: var(--text-primary); margin-bottom: 6px;
}
.doc-catalog-desc {
    font-size: .88rem; color: var(--text-muted);
}

/* ============================================================
   Chat Messages
   ============================================================ */
.chat-messages {
    flex: 1; overflow-y: auto;
    padding: 20px 0;
    scrollbar-width: thin; scrollbar-color: var(--border) transparent;
}
.chat-messages::-webkit-scrollbar { width: 5px; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* Welcome */
.welcome-screen {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    height: 100%; padding: 40px 20px; text-align: center; gap: 12px;
}

.welcome-logo-icon {
    width: 64px; height: 64px;
    display: flex; align-items: center; justify-content: center;
    background: var(--accent-gradient);
    border: 1px solid var(--accent-border);
    border-radius: 20px;
    color: var(--accent);
    margin-bottom: 8px;
    transition: transform .3s, box-shadow .3s;
}
.welcome-logo-icon:hover {
    transform: scale(1.05);
    box-shadow: 0 0 24px var(--accent-glow);
}

.welcome-screen h2 {
    font-size: 1.75rem; font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.welcome-subtitle {
    font-size: .95rem; color: var(--text-secondary);
    max-width: 460px; line-height: 1.6;
    margin-bottom: 8px;
}

.welcome-suggestions {
    display: flex; flex-wrap: wrap; justify-content: center;
    gap: 8px; max-width: 600px; margin-top: 12px;
}

.welcome-chip {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 10px 18px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 24px;
    font-size: .84rem; font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all .2s;
}
.welcome-chip:hover {
    background: var(--accent-gradient);
    border-color: var(--accent-border);
    color: var(--text-primary);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,.15);
}
.welcome-chip svg { opacity: .6; flex-shrink: 0; }
.welcome-chip:hover svg { opacity: 1; color: var(--accent); }

/* Message rows */
.message-row {
    display: flex; gap: 14px;
    padding: 12px 24px;
    max-width: 800px; margin: 0 auto;
    animation: fadeIn .2s ease;
}

.message-avatar {
    width: 30px; height: 30px; flex-shrink: 0;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: .72rem; font-weight: 700;
    background: #9ca3af; color: #fff;
}
.message-avatar.ai { background: #22c55e; color: #fff; }

.message-body { max-width: 700px; min-width: 0; overflow-x: hidden; }

.message-role {
    font-size: .7rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: .04em;
    color: var(--text-primary); margin-bottom: 4px;
}

.message-content {
    font-size: .92rem; line-height: 1.7;
    color: var(--text-primary); word-break: break-word;
}

.message-row.user .message-content {
    background: var(--bg-message-user);
    padding: 10px 16px;
    border-radius: var(--radius);
    border-top-right-radius: 4px;
}

/* Markdown */
.message-content p { margin-bottom: .6em; }
.message-content p:last-child { margin-bottom: 0; }
.message-content strong { font-weight: 600; }

.message-content h1, .message-content h2, .message-content h3, .message-content h4 {
    font-weight: 700; margin: 1em 0 .4em;
}
.message-content h1 { font-size: 1.2rem; }
.message-content h2 { font-size: 1.1rem; }
.message-content h3 { font-size: 1rem; }

.message-content ul, .message-content ol { padding-left: 1.5em; margin: .5em 0; }
.message-content ul { list-style: disc; }
.message-content ol { list-style: decimal; }
.message-content li { margin-bottom: .3em; }

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

.message-content blockquote {
    border-left: 3px solid var(--accent);
    padding: 6px 14px; margin: .6em 0;
    background: var(--bg-input);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    color: var(--text-secondary);
}

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

.message-content table { border-collapse: collapse; width: 100%; margin: .6em 0; font-size: .85rem; }
.message-content th, .message-content td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; }
.message-content th { background: var(--bg-input); font-weight: 600; }

.message-content code:not(pre code) {
    background: var(--bg-input); padding: 2px 6px; border-radius: 4px;
    font-size: .84rem; font-family: 'Fira Code','Cascadia Code',Consolas,monospace;
}

.message-content pre { margin: .6em 0; border-radius: var(--radius-sm); overflow: hidden; }

.message-content img, .message-image {
    max-width: min(400px, 100%); border-radius: var(--radius); margin: 8px 0; cursor: pointer;
}

/* Attachments */
.message-attachments { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.message-attachment-img {
    max-width: 200px; max-height: 200px;
    border-radius: var(--radius-sm); object-fit: cover; cursor: pointer;
}
.message-file-card {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 8px 12px; background: var(--bg-input); border: 1px solid var(--border);
    border-radius: var(--radius-sm); font-size: .82rem; color: var(--text-secondary);
}
.message-audio-card {
    display: flex; flex-direction: column; gap: 4px;
    padding: 8px 12px; background: var(--bg-input); border: 1px solid var(--border);
    border-radius: var(--radius-sm); max-width: 320px;
}
.message-audio-label { font-size: .82rem; color: var(--text-secondary); }
.message-audio-card audio { width: 100%; height: 36px; }

/* Code blocks */
.code-block-wrapper {
    position: relative; background: var(--code-bg);
    border-radius: var(--radius-sm); overflow: hidden; margin: .6em 0;
}

.code-block-wrapper .code-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 6px 12px; background: var(--code-header-bg);
    font-size: .72rem; color: var(--text-muted);
}

.code-block-wrapper pre {
    margin: 0; padding: 14px; overflow-x: auto;
    font-size: .84rem; line-height: 1.5; background: transparent;
    font-family: 'Fira Code','Cascadia Code',Consolas,monospace;
}

.code-copy-btn {
    padding: 4px 10px; border-radius: 4px;
    font-size: .72rem; font-weight: 500;
    color: var(--text-muted);
    transition: background .15s, color .15s;
}
.code-copy-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.code-copy-btn.copied { color: var(--success); }

/* Typing */
.typing-indicator {
    display: flex; gap: 5px;
    padding: 12px 24px; max-width: 800px; margin: 0 auto;
}
.typing-indicator span {
    width: 7px; height: 7px;
    background: var(--accent); border-radius: 50%;
    animation: typing 1.2s ease-in-out infinite;
}
.typing-indicator span:nth-child(2) { animation-delay: .2s; }
.typing-indicator span:nth-child(3) { animation-delay: .4s; }

.generating-status { display: flex; align-items: center; gap: 8px; color: var(--text-muted); font-size: .85rem; padding: 12px 0; }
.generating-spinner {
    width: 16px; height: 16px;
    border: 2px solid var(--border); border-top-color: var(--accent);
    border-radius: 50%; animation: spin .8s linear infinite;
}

/* ============================================================
   Chat Input — Two-row layout (like competitor)
   ============================================================ */
.chat-input-area {
    padding: 0 24px 20px;
    max-width: 800px; margin: 0 auto; width: 100%;
}

.attachment-preview {
    display: flex; flex-wrap: wrap; gap: 8px;
    padding: 0 0 8px;
}

.attached-file {
    position: relative;
    width: 64px; height: 64px;
    border-radius: var(--radius-sm);
    overflow: hidden; flex-shrink: 0;
    border: 1px solid var(--border);
}
.attached-file img { width: 100%; height: 100%; object-fit: cover; }
.attached-file.uploading { opacity: .5; }
.attached-file.file-type {
    width: auto; min-width: 64px; max-width: 160px;
    height: auto; padding: 8px;
    display: flex; flex-direction: column;
    align-items: center; gap: 4px;
    background: var(--bg-input);
}
.attached-file-remove, .attached-file .remove-attachment {
    position: absolute; top: 2px; right: 2px;
    width: 20px; height: 20px;
    border-radius: 50%;
    background: rgba(0,0,0,.6); color: #fff;
    border: none; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px; line-height: 1;
    transition: background .15s;
}
.attached-file-remove:hover, .attached-file .remove-attachment:hover {
    background: rgba(0,0,0,.8);
}
.attached-file-icon { font-size: 24px; line-height: 1; }
.attached-file-name {
    font-size: 10px; color: var(--text-secondary);
    text-align: center; overflow: hidden;
    text-overflow: ellipsis; white-space: nowrap; width: 100%;
}
.attached-file-spinner {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
}
.attached-file-spinner::after {
    content: ''; width: 20px; height: 20px;
    border: 2px solid rgba(255,255,255,.4);
    border-top-color: #fff; border-radius: 50%;
    animation: spin .8s linear infinite;
}

/* Drag-and-drop overlay */
body.drag-over::after {
    content: ''; position: fixed; inset: 0; z-index: 9999;
    background: rgba(var(--accent-rgb, 99,102,241), .08);
    border: 3px dashed var(--accent);
    border-radius: var(--radius);
    pointer-events: none;
}

.input-wrapper {
    display: flex; flex-direction: column;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 12px 16px 6px;
    transition: border-color .2s, box-shadow .2s;
}
.input-wrapper:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.input-wrapper.pulse-highlight {
    animation: inputPulse .8s ease-out;
}
@keyframes inputPulse {
    0%   { box-shadow: 0 0 0 0 var(--accent), 0 0 0 0 var(--accent-glow); border-color: var(--accent); }
    40%  { box-shadow: 0 0 0 4px var(--accent-glow), 0 0 24px 4px var(--accent-glow); border-color: var(--accent); }
    100% { box-shadow: 0 0 0 0 transparent, 0 0 0 0 transparent; border-color: var(--border); }
}

.input-wrapper textarea {
    width: 100%; resize: none;
    border: none; outline: none; background: transparent;
    color: var(--text-primary);
    font-size: .92rem; line-height: 1.5;
    max-height: 160px; padding: 0;
    min-height: 24px;
}
.input-wrapper textarea::placeholder { color: var(--text-muted); }

.input-actions {
    display: flex; align-items: center; gap: 4px;
    padding-top: 4px;
}

.input-spacer { flex: 1; }

.input-btn {
    display: flex; align-items: center; justify-content: center;
    width: 32px; height: 32px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    transition: background .15s, color .15s;
    flex-shrink: 0;
}
.input-btn:hover { background: var(--bg-hover); color: var(--text-primary); }

.send-btn {
    width: 34px; height: 34px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    background: var(--accent); color: #fff;
    transition: all .2s;
    box-shadow: 0 2px 8px var(--accent-glow);
}
.send-btn:hover {
    background: var(--accent-hover);
    box-shadow: 0 4px 16px var(--accent-glow);
    transform: scale(1.05);
}
.send-btn:disabled { opacity: .3; cursor: default; box-shadow: none; transform: none; }

.stop-btn {
    width: 32px; height: 32px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    background: var(--danger); color: #fff;
    transition: background .15s;
}
.stop-btn:hover { background: #dc2626; }

.voice-btn.recording { color: var(--danger); animation: pulse-recording 1.4s infinite; }
.voice-btn.recording::after {
    content: ''; position: absolute; inset: -4px;
    border: 2px solid var(--danger); border-radius: 50%;
    animation: pulse-recording 1.4s infinite;
}

.web-search-btn {
    position: relative; overflow: hidden;
    width: auto; min-width: 32px; max-width: 32px;
    padding: 0;
    border-radius: var(--radius-sm);
    transition: max-width .3s cubic-bezier(.4,0,.2,1), padding .3s cubic-bezier(.4,0,.2,1),
                background .2s ease, color .2s ease, border-radius .2s ease;
}
.web-search-label {
    max-width: 0; opacity: 0; overflow: hidden;
    font-size: .75rem; font-weight: 600; white-space: nowrap;
    transition: max-width .3s cubic-bezier(.4,0,.2,1), opacity .15s ease .05s, margin .3s cubic-bezier(.4,0,.2,1);
    margin-left: 0;
}
.web-search-btn.active {
    max-width: 160px; padding: 0 10px;
    color: var(--accent); background: var(--accent-glow);
    border-radius: 16px;
}
.web-search-btn.active .web-search-label {
    max-width: 100px; opacity: 1; margin-left: 4px;
}

.image-gen-btn {
    position: relative; overflow: hidden;
    width: auto; min-width: 32px; max-width: 32px;
    padding: 0;
    border-radius: var(--radius-sm);
    transition: max-width .3s cubic-bezier(.4,0,.2,1), padding .3s cubic-bezier(.4,0,.2,1),
                background .2s ease, color .2s ease, border-radius .2s ease;
}
.image-gen-label {
    max-width: 0; opacity: 0; overflow: hidden;
    font-size: .75rem; font-weight: 600; white-space: nowrap;
    transition: max-width .3s cubic-bezier(.4,0,.2,1), opacity .15s ease .05s, margin .3s cubic-bezier(.4,0,.2,1);
    margin-left: 0;
}
.image-gen-btn.active {
    max-width: 180px; padding: 0 10px;
    color: var(--accent); background: var(--accent-glow);
    border-radius: 16px;
}
.image-gen-btn.active .image-gen-label {
    max-width: 120px; opacity: 1; margin-left: 4px;
}

.input-footer {
    text-align: center; font-size: .72rem;
    color: var(--text-muted); margin-top: 8px;
}

/* ============================================================
   Modals
   ============================================================ */
.modal {
    position: fixed; inset: 0; z-index: 1000;
    display: flex; align-items: center; justify-content: center;
}

.modal-backdrop {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.6); z-index: 1;
}
body.theme-light .modal-backdrop { background: rgba(0,0,0,.3); }

.modal-content {
    position: relative; z-index: 2;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 16px 48px rgba(0,0,0,.35);
    padding: 28px;
    width: 90%; max-width: 440px;
    max-height: 90vh; overflow-y: auto;
    text-align: center;
    animation: fadeIn .15s ease;
}
body.theme-light .modal-content { box-shadow: 0 16px 48px rgba(0,0,0,.1); }

.modal-content h2, .modal-content h3 { margin: 12px 0 8px; font-size: 1.1rem; }
.modal-content p { color: var(--text-secondary); margin-bottom: 20px; font-size: .88rem; }

.modal-close {
    position: absolute; top: 12px; right: 12px;
    width: 30px; height: 30px;
    display: flex; align-items: center; justify-content: center;
    border-radius: var(--radius-sm);
    color: var(--text-muted); font-size: 1.2rem;
    transition: background .15s, color .15s;
}
.modal-close:hover { background: var(--bg-hover); color: var(--text-primary); }

.premium-btn {
    display: inline-block; padding: 10px 20px;
    background: var(--accent); color: #fff;
    border-radius: var(--radius-sm);
    font-weight: 600; font-size: .85rem;
    text-decoration: none; border: none; cursor: pointer;
    transition: background .15s;
}
.premium-btn:hover { background: var(--accent-hover); text-decoration: none; }

/* Plans modal */
.plans-modal {
    position: fixed; inset: 0; z-index: 1000;
    display: flex; align-items: center; justify-content: center;
}
.plans-modal-backdrop {
    position: fixed; inset: 0; z-index: 1;
    background: rgba(0,0,0,.45);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}
body.theme-light .plans-modal-backdrop { background: rgba(0,0,0,.2); }

.plans-modal-content {
    position: relative; z-index: 2;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 24px 64px rgba(0,0,0,.4);
    padding: 32px;
    width: 94%; max-width: 960px;
    max-height: 90vh;
    overflow-y: auto;
    animation: fadeIn .2s ease;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}
.plans-modal-content::-webkit-scrollbar { width: 6px; }
.plans-modal-content::-webkit-scrollbar-track { background: transparent; }
.plans-modal-content::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.plans-modal-content::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

.plans-modal-content .plans-grid {
    grid-template-columns: repeat(4, 1fr);
}
body.theme-light .plans-modal-content { box-shadow: 0 24px 64px rgba(0,0,0,.12); }

.plans-modal-title {
    font-size: 1.3rem; font-weight: 700;
    text-align: center; margin-bottom: 24px;
}

.plans-modal-content .modal-close {
    position: absolute; top: 12px; right: 16px;
    background: none; border: none; color: var(--text-muted);
    font-size: 24px; cursor: pointer; padding: 4px 8px;
    border-radius: var(--radius-sm); line-height: 1;
}
.plans-modal-content .modal-close:hover { background: var(--bg-hover); color: var(--text-primary); }

.plans-modal-content .plan-card { padding: 20px 16px; }
.plans-modal-content .plan-icon { font-size: 1.3rem; margin-bottom: 4px; }
.plans-modal-content .plan-name { font-size: .95rem; }
.plans-modal-content .plan-price { font-size: 1.3rem; margin-bottom: 2px; }
.plans-modal-content .plan-description { font-size: .78rem; margin-bottom: 8px; }
.plans-modal-content .plan-limit { font-size: .78rem; }
.plans-modal-content .plan-feature-item { font-size: .78rem; }
.plans-modal-content .plan-features { margin-bottom: 12px; gap: 4px; }
.plans-modal-content .plan-btn { padding: 8px; font-size: .82rem; }

@media (max-width: 900px) {
    .plans-modal-content .plans-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 540px) {
    .plans-modal-content { padding: 20px 16px; }
    .plans-modal-content .plans-grid { grid-template-columns: 1fr; }
}

/* ============================================================
   Profile Modal
   ============================================================ */
.profile-modal-content {
    max-width: 480px; text-align: left;
    padding: 24px;
}

.profile-header {
    display: flex; flex-direction: column; align-items: center;
    gap: 6px; margin-bottom: 20px; text-align: center;
}

.profile-avatar {
    width: 56px; height: 56px; border-radius: 50%;
    background: #9ca3af; color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem; font-weight: 700;
}

.profile-header h2 { margin: 0; font-size: 1.05rem; }
.profile-username, .profile-email { color: var(--text-muted); font-size: .82rem; margin: 0; }

.profile-tabs {
    display: flex; gap: 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 16px;
}

.profile-tab {
    padding: 8px 14px;
    font-size: .84rem; font-weight: 500;
    color: var(--text-muted);
    border: none; background: none;
    border-bottom: 2px solid transparent;
    cursor: pointer; transition: color .15s;
}
.profile-tab:hover { color: var(--text-primary); }
.profile-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.profile-tab-content { animation: fadeIn .2s ease; }

.profile-card {
    background: var(--bg-input); border-radius: var(--radius-sm);
    overflow: hidden; margin-bottom: 12px;
}

.profile-card-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 14px; font-weight: 600; font-size: .82rem;
    border-bottom: 1px solid var(--border);
}

.profile-badge { font-size: .7rem; padding: 2px 8px; border-radius: 4px; font-weight: 700; }
.profile-badge.free { background: var(--bg-hover); color: var(--text-secondary); }
.profile-badge.premium { background: var(--premium); color: #000; }

.profile-card-body { padding: 10px 14px; font-size: .85rem; color: var(--text-secondary); }

.profile-card .premium-btn { display: block; margin: 10px 14px 14px; text-align: center; }

.profile-input {
    width: 100%; padding: 8px 12px;
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-sm); color: var(--text-primary);
    font-size: .85rem; outline: none; margin-bottom: 8px;
    transition: border-color .15s;
}
.profile-input:focus { border-color: var(--accent); }

.btn-small {
    padding: 6px 14px; background: var(--accent); color: #fff;
    border: none; border-radius: var(--radius-sm);
    font-size: .82rem; font-weight: 500; cursor: pointer;
    transition: background .15s;
}
.btn-small:hover { background: var(--accent-hover); }

/* Progress bars */
.usage-item { margin-bottom: 12px; }
.progress-bar-label { display: flex; justify-content: space-between; font-size: .75rem; color: var(--text-muted); margin-bottom: 4px; }
.progress-bar { width: 100%; height: 6px; background: var(--bg-card); border-radius: 3px; overflow: hidden; }
.progress-bar-fill { height: 100%; background: var(--accent); border-radius: 3px; transition: width .4s ease; }
.progress-bar-fill.warning { background: var(--premium); }
.progress-bar-fill.danger { background: var(--danger); }

/* Payment history */
.payment-item {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 14px; background: var(--bg-input);
    border-radius: var(--radius-sm); margin-bottom: 8px; font-size: .84rem;
}
.payment-item-info { display: flex; flex-direction: column; gap: 2px; }
.payment-item-name { font-weight: 500; color: var(--text-primary); }
.payment-item-date { font-size: .75rem; color: var(--text-muted); }
.payment-item-right { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.payment-item-amount { font-weight: 600; color: var(--text-primary); }
.payment-item-status { font-size: .7rem; font-weight: 500; }
.payment-item-status.paid { color: var(--success); }
.payment-item-status.unpaid { color: var(--danger); }

/* ============================================================
   Settings
   ============================================================ */
.settings-textarea {
    width: 100%; min-height: 120px; padding: 12px;
    background: var(--bg-input); border: 1px solid var(--border);
    border-radius: var(--radius-sm); color: var(--text-primary);
    font-size: .88rem; line-height: 1.5; resize: vertical; outline: none;
    transition: border-color .2s;
}
.settings-textarea:focus { border-color: var(--accent); }
.settings-textarea::placeholder { color: var(--text-muted); }
.text-muted { color: var(--text-muted); font-size: .75rem; }

/* ============================================================
   Documents modal
   ============================================================ */
.docs-modal-content {
    max-width: 400px; text-align: left;
}
.docs-modal-content h2 { text-align: center; }
.docs-modal-list {
    display: flex; flex-direction: column; gap: 4px;
    margin-top: 8px;
}
.docs-modal-item {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: .88rem;
    text-decoration: none;
    transition: background .15s, color .15s;
}
.docs-modal-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    text-decoration: none;
}

/* ============================================================
   Coupon modal
   ============================================================ */
.coupon-modal-content {
    max-width: 400px;
}
.coupon-modal-icon {
    width: 56px; height: 56px;
    margin: 0 auto 8px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 50%;
    background: var(--accent-glow, rgba(77,130,240,.12));
    color: var(--accent);
}
.coupon-input-row {
    margin-bottom: 12px;
}
.coupon-code-field {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 1.5px;
    text-align: center;
    text-transform: uppercase;
    outline: none;
    transition: border-color .2s;
}
.coupon-code-field:focus {
    border-color: var(--accent);
}
.coupon-code-field::placeholder {
    color: var(--text-muted);
    font-weight: 400;
    letter-spacing: 0;
    text-transform: none;
}
.coupon-submit-btn {
    width: 100%;
    margin-bottom: 4px;
}
.coupon-result {
    font-size: .82rem;
    min-height: 20px;
}

/* ============================================================
   Auth Screens
   ============================================================ */
.auth-screen {
    display: flex; align-items: center; justify-content: center;
    position: fixed; inset: 0;
    z-index: 500;
}

.auth-backdrop {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.5);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 1;
}
body.theme-light .auth-backdrop {
    background: rgba(255,255,255,.5);
}

.auth-form {
    width: 100%; max-width: 380px; padding: 24px;
    position: relative; z-index: 2;
}

.auth-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: 20px; padding: 36px 32px;
    box-shadow: 0 16px 48px rgba(0,0,0,.35);
    position: relative;
    animation: fadeIn .2s ease;
}
body.theme-light .auth-card { box-shadow: 0 16px 48px rgba(0,0,0,.08); }

.auth-close {
    position: absolute; top: 12px; right: 12px;
    width: 30px; height: 30px;
    display: flex; align-items: center; justify-content: center;
    border-radius: var(--radius-sm);
    color: var(--text-muted); font-size: 1.2rem;
    transition: background .15s, color .15s;
}
.auth-close:hover { background: var(--bg-hover); color: var(--text-primary); }

.auth-logo {
    font-size: .82rem; font-weight: 800;
    color: var(--accent); letter-spacing: 2px;
    text-align: center; margin-bottom: 20px;
}

.auth-title {
    font-size: 1.2rem; font-weight: 700;
    color: var(--text-primary); text-align: center; margin-bottom: 20px;
}

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

.auth-field { margin-bottom: 12px; }
.auth-field input {
    width: 100%; padding: 11px 14px;
    background: var(--bg-input); border: 1px solid var(--border);
    border-radius: var(--radius-sm); color: var(--text-primary);
    font-size: .9rem; outline: none;
    transition: border-color .15s;
}
.auth-field input:focus { border-color: var(--accent); }
.auth-field input::placeholder { color: var(--text-muted); }

.auth-remember {
    display: flex; align-items: center; gap: 8px;
    margin-bottom: 14px; font-size: 13px; color: var(--text-secondary);
    cursor: pointer;
}
.auth-remember input { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }

.auth-btn {
    width: 100%; padding: 12px;
    background: var(--accent); color: #fff; border: none;
    border-radius: var(--radius-sm);
    font-size: .92rem; font-weight: 600; cursor: pointer;
    transition: background .15s;
    margin-top: 4px;
}
.auth-btn:hover { background: var(--accent-hover); }
.auth-btn:disabled { opacity: .5; cursor: default; }

.auth-links {
    display: flex; flex-wrap: wrap; justify-content: center;
    gap: 16px; margin-top: 16px; font-size: .82rem;
}
.auth-links a { color: var(--accent); }

.auth-error {
    background: rgba(239,68,68,.1);
    border: 1px solid rgba(239,68,68,.25);
    color: var(--danger);
    padding: 10px 14px; border-radius: var(--radius-sm);
    font-size: .82rem; margin-bottom: 14px; text-align: center;
    animation: fadeIn .2s ease;
}

.auth-code-inputs { display: flex; gap: 8px; justify-content: center; margin-bottom: 20px; }
.auth-code-inputs input, .auth-code-input {
    width: 44px; height: 50px; text-align: center;
    font-size: 1.2rem; font-weight: 700;
    background: var(--bg-input); border: 1px solid var(--border);
    border-radius: var(--radius-sm); color: var(--text-primary); outline: none;
    transition: border-color .15s;
}
.auth-code-inputs input:focus { border-color: var(--accent); }

/* ============================================================
   Images View
   ============================================================ */
.images-view {
    flex: 1; overflow-y: auto;
    padding: 24px; display: flex; flex-direction: column; gap: 24px;
    max-width: 900px; margin: 0 auto; width: 100%;
}

.images-premium-banner {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 24px; text-align: center;
    display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.images-premium-banner h3 { font-size: 1rem; }
.images-premium-banner p { font-size: .88rem; color: var(--text-secondary); max-width: 400px; }

.images-generate h2 { font-size: 1.05rem; margin-bottom: 12px; }

.images-prompt-wrapper { display: flex; gap: 8px; align-items: flex-end; }
.images-prompt-wrapper textarea, .images-prompt-wrapper input {
    flex: 1; background: var(--bg-input); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 10px 14px;
    font-size: .9rem; font-family: inherit; color: var(--text-primary);
    resize: none; outline: none; transition: border-color .15s;
}
.images-prompt-wrapper textarea:focus, .images-prompt-wrapper input:focus { border-color: var(--accent); }

.images-generate-btn {
    width: 38px; height: 38px; border-radius: 50%;
    background: var(--accent); color: #fff; border: none;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; transition: background .15s;
}
.images-generate-btn:hover { background: var(--accent-hover); }
.images-generate-btn:disabled { opacity: .4; cursor: default; }

.images-generating { display: flex; align-items: center; gap: 8px; color: var(--text-muted); font-size: .85rem; padding: 8px 0; }
.images-hint { font-size: .75rem; color: var(--text-muted); margin-top: 8px; }
.images-gallery h3 { font-size: 1rem; margin-bottom: 12px; }

.images-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
}
.images-grid-item {
    aspect-ratio: 1; border-radius: var(--radius);
    overflow: hidden; cursor: pointer; position: relative;
    border: 1px solid var(--border);
    transition: transform .2s, box-shadow .2s;
}
.images-grid-item:hover { transform: scale(1.02); box-shadow: 0 4px 16px rgba(0,0,0,.2); }
.images-grid-item img { width: 100%; height: 100%; object-fit: cover; }
.images-empty { grid-column: 1/-1; text-align: center; color: var(--text-muted); font-size: .88rem; padding: 32px 0; }

/* Lightbox */
.image-lightbox {
    display: flex; position: fixed; inset: 0;
    background: rgba(0,0,0,.88); z-index: 2000;
    align-items: center; justify-content: center;
    flex-direction: column; gap: 16px; padding: 24px;
}
.image-lightbox img {
    max-width: 90vw; max-height: calc(90vh - 60px);
    border-radius: var(--radius); object-fit: contain;
}
.image-lightbox .lightbox-controls {
    display: flex; gap: 12px;
}
.image-lightbox .lightbox-btn {
    display: flex; align-items: center; gap: 6px;
    padding: 8px 18px; border-radius: 20px;
    background: rgba(255,255,255,.12); color: #fff;
    font-size: .88rem; cursor: pointer; border: none;
    transition: background .15s; text-decoration: none;
}
.image-lightbox .lightbox-btn:hover { background: rgba(255,255,255,.22); text-decoration: none; }
.image-lightbox .close-lightbox {
    position: absolute; top: 16px; right: 16px;
    width: 40px; height: 40px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 50%; background: rgba(255,255,255,.1);
    color: #fff; font-size: 1.3rem; transition: background .15s;
    cursor: pointer; border: none;
}
.image-lightbox .close-lightbox:hover { background: rgba(255,255,255,.2); }

.image-result { max-width: min(400px, 100%); border-radius: var(--radius); cursor: pointer; }
.image-wrapper { transition: transform .2s; }
.image-wrapper:hover { transform: scale(1.02); }

/* Share modal */
.share-modal-overlay {
    position: fixed; inset: 0; z-index: 2100;
    background: rgba(0,0,0,.55);
    display: flex; align-items: center; justify-content: center;
    padding: 16px; animation: fadeIn .15s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.share-modal {
    background: var(--bg-card); border-radius: 16px;
    max-width: 380px; width: 100%;
    padding: 28px 24px 24px; position: relative;
    box-shadow: 0 20px 60px rgba(0,0,0,.35);
    animation: modalSlideUp .2s ease;
}
@keyframes modalSlideUp { from { transform: translateY(20px); opacity: 0; } to { transform: none; opacity: 1; } }
.share-modal-close {
    position: absolute; top: 12px; right: 12px;
    width: 32px; height: 32px; border: none; background: none;
    color: var(--text-muted); font-size: 1.3rem; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    border-radius: 50%; transition: background .15s;
}
.share-modal-close:hover { background: var(--bg-hover); }
.share-modal-preview {
    display: flex; justify-content: center; margin-bottom: 24px;
}
.share-modal-preview img {
    max-width: 100%; max-height: 180px;
    border-radius: 12px; object-fit: contain;
    box-shadow: 0 4px 16px rgba(0,0,0,.12);
}
.share-modal-buttons {
    display: flex; justify-content: center; gap: 16px;
}
.share-btn {
    display: flex; flex-direction: column; align-items: center; gap: 8px;
    padding: 8px; min-width: 64px;
    border: none; background: none; color: var(--text-secondary);
    font-size: .75rem; font-weight: 500; cursor: pointer;
    text-decoration: none; transition: transform .15s; border-radius: 12px;
}
.share-btn:hover { transform: scale(1.08); text-decoration: none; }
.share-btn-icon {
    width: 48px; height: 48px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: #fff; transition: box-shadow .15s;
}
.share-btn:hover .share-btn-icon { box-shadow: 0 4px 12px rgba(0,0,0,.2); }
.share-btn-icon--link { background: #6c63ff; }
.share-btn-icon--vk { background: #0077ff; }
.share-btn-icon--tg { background: #2aabee; }
.share-btn-icon--dl { background: #444; }
.share-btn-label { white-space: nowrap; }

/* Image action bar (ChatGPT style) */
.image-wrapper {
    position: relative; display: inline-block; max-width: min(400px, 100%);
    margin-bottom: 12px;
}
.image-actions {
    display: flex; align-items: center; gap: 2px;
    position: absolute; bottom: 16px; left: 10px; right: 10px;
    opacity: 0; transition: opacity .2s;
}
.image-wrapper:hover .image-actions { opacity: 1; }
.image-actions-left { display: flex; gap: 2px; }
.image-actions-right { margin-left: auto; }
.img-action-btn {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 6px 8px; border: none;
    background: rgba(0,0,0,.55); color: #fff;
    border-radius: 8px; cursor: pointer; font-size: .75rem;
    backdrop-filter: blur(8px); transition: background .15s;
    text-decoration: none;
}
.img-action-btn:hover { background: rgba(0,0,0,.75); text-decoration: none; }
.img-action-btn.liked svg { fill: #fff; stroke: #fff; }
.img-action-btn svg { width: 16px; height: 16px; flex-shrink: 0; }

/* Gallery tabs */
.gallery-tabs {
    display: flex; gap: 0; margin-bottom: 12px;
    border-bottom: 1px solid var(--border);
}
.gallery-tab {
    padding: 8px 16px; font-size: .88rem; font-weight: 500;
    color: var(--text-muted); cursor: pointer; border: none;
    background: none; border-bottom: 2px solid transparent;
    transition: color .15s, border-color .15s;
}
.gallery-tab:hover { color: var(--text-primary); }
.gallery-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ============================================================
   Plans
   ============================================================ */
.plans-view { flex: 1; overflow-y: auto; padding: 24px 16px; }

.plans-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px; max-width: 900px; margin: 0 auto;
}

.plan-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 24px 20px;
    display: flex; flex-direction: column; position: relative;
    transition: transform .2s, box-shadow .2s;
}
.plan-card:hover { transform: translateY(-3px); box-shadow: 0 8px 24px rgba(0,0,0,.2); }
.plan-card.popular { border-color: var(--accent); box-shadow: 0 0 16px var(--accent-glow); }

.plan-badge {
    position: absolute; top: -10px; left: 50%; transform: translateX(-50%);
    padding: 3px 14px; background: var(--accent); color: #fff;
    font-size: .68rem; font-weight: 700; text-transform: uppercase;
    border-radius: 10px; white-space: nowrap;
}

.plan-icon { font-size: 1.6rem; margin-bottom: 8px; }
.plan-name { font-size: 1.05rem; font-weight: 700; margin-bottom: 4px; }
.plan-price { font-size: 1.6rem; font-weight: 800; margin-bottom: 4px; }
.plan-price-period { font-size: .82rem; font-weight: 400; color: var(--text-muted); }
.plan-description { font-size: .82rem; color: var(--text-secondary); margin-bottom: 12px; }

.plan-limits { margin-bottom: 12px; }
.plan-limit { font-size: .82rem; color: var(--text-secondary); padding: 2px 0; }
.plan-limit strong { color: var(--text-primary); }

.plan-features { flex: 1; margin-bottom: 16px; display: flex; flex-direction: column; gap: 6px; }
.plan-feature-item { display: flex; align-items: center; gap: 6px; font-size: .82rem; color: var(--text-secondary); }

.plan-btn {
    width: 100%; padding: 10px; border: none;
    border-radius: var(--radius-sm);
    font-size: .88rem; font-weight: 600; text-align: center;
    background: var(--accent); color: #fff; cursor: pointer;
    transition: background .15s;
}
.plan-btn:hover { background: var(--accent-hover); }
.plan-btn:disabled, .plan-btn.disabled {
    background: var(--bg-input); color: var(--text-muted); cursor: default;
}
.plan-card-sublink {
    display: block; text-align: center; margin-top: 8px;
    font-size: .75rem; color: var(--text-muted); cursor: pointer;
    text-decoration: none;
}
.plan-card-sublink:hover { color: var(--accent); text-decoration: underline; }

/* ============================================================
   Consent Modal
   ============================================================ */
.consent-modal-content {
    max-width: 440px; padding: 28px 28px 24px;
}
.consent-docs-list {
    list-style: none; padding: 0; margin: 0 0 20px;
}
.consent-docs-list li {
    margin-bottom: 8px;
}
.consent-docs-list li a {
    color: var(--accent); font-size: .88rem; font-weight: 500;
}
.consent-docs-list li a:hover { text-decoration: underline; }
.consent-checkbox-label {
    display: flex; align-items: flex-start; gap: 10px;
    cursor: pointer; margin-bottom: 20px;
    font-size: .85rem; color: var(--text-secondary); line-height: 1.5;
}
.consent-checkbox-label input[type="checkbox"] {
    margin-top: 3px; flex-shrink: 0; accent-color: var(--accent);
    width: 18px; height: 18px;
}
.consent-pay-btn {
    width: 100%; text-align: center; padding: 12px;
}
.consent-pay-btn:disabled {
    opacity: .45; cursor: not-allowed;
}

/* ============================================================
   Confirm Modal
   ============================================================ */
#confirmModal { z-index: 1100; }
.confirm-modal-content {
    max-width: 400px; padding: 32px 28px 24px; text-align: center;
}
.confirm-modal-icon {
    font-size: 2.4rem; margin-bottom: 8px; line-height: 1;
}
.confirm-modal-content h3 {
    font-size: 1.05rem; font-weight: 700; margin: 0 0 12px;
    color: var(--text-primary);
}
.confirm-modal-content p {
    font-size: .88rem; line-height: 1.55; color: var(--text-secondary);
    margin: 0 0 24px; white-space: pre-line;
}
.confirm-modal-buttons {
    display: flex; gap: 10px;
}
.confirm-modal-btn {
    flex: 1; padding: 11px 16px; border-radius: 10px;
    font-size: .88rem; font-weight: 600; cursor: pointer;
    border: none; transition: background .15s, transform .1s;
}
.confirm-modal-btn:active { transform: scale(.97); }
.confirm-modal-btn.cancel {
    background: var(--bg-hover); color: var(--text-secondary);
}
.confirm-modal-btn.cancel:hover {
    background: var(--border); color: var(--text-primary);
}
.confirm-modal-btn.confirm {
    background: var(--accent); color: #fff;
}
.confirm-modal-btn.confirm:hover {
    background: var(--accent-hover);
}
.confirm-modal-btn.confirm.danger {
    background: var(--danger, #ef4444);
}
.confirm-modal-btn.confirm.danger:hover {
    background: #dc2626;
}

/* ============================================================
   Danger Button
   ============================================================ */
.danger-btn {
    display: block; width: calc(100% - 28px); margin: 12px 14px 14px;
    background: transparent; color: var(--danger, #ef4444);
    border: 1px solid var(--danger, #ef4444); border-radius: 8px;
    padding: 10px 16px; font-size: .85rem; font-weight: 600;
    cursor: pointer; text-align: center; transition: background .2s, color .2s;
}
.danger-btn:hover {
    background: var(--danger, #ef4444); color: #fff;
}

/* ============================================================
   Landing
   ============================================================ */
.landing-sections {
    flex: 1; overflow-y: auto; padding-bottom: 60px;
    scrollbar-width: thin; scrollbar-color: var(--border) transparent;
}

.landing-section { padding: 48px 24px; max-width: 960px; margin: 0 auto; }

/* Hero */
.landing-hero { text-align: center; padding: 64px 24px 40px; }
.landing-hero h2 {
    font-size: 2rem; font-weight: 800; margin-bottom: 16px;
    letter-spacing: -0.03em;
    background: linear-gradient(135deg, var(--text-primary) 0%, var(--accent) 100%);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    background-clip: text;
}
.landing-hero p {
    font-size: 1rem; color: var(--text-secondary);
    max-width: 560px; margin: 0 auto 28px; line-height: 1.7;
}

.landing-cta-btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 14px 36px;
    background: var(--accent); color: #fff;
    border: none; border-radius: 28px;
    font-size: .95rem; font-weight: 600;
    transition: all .2s; cursor: pointer;
    box-shadow: 0 4px 16px var(--accent-glow);
}
.landing-cta-btn:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 8px 24px var(--accent-glow);
}

/* Section headers */
.landing-section-header {
    text-align: center; margin-bottom: 32px;
}
.landing-section-header h3 {
    font-size: 1.4rem; font-weight: 700;
    letter-spacing: -0.02em; margin-bottom: 8px;
}
.landing-section-header p {
    font-size: .9rem; color: var(--text-secondary);
    max-width: 480px; margin: 0 auto; line-height: 1.6;
}

.landing-features h3, .landing-models h3, .landing-plans-preview h3, .landing-cta h3,
.landing-benefits h3, .landing-usecases h3, .landing-faq h3 {
    font-size: 1.3rem; font-weight: 700; text-align: center; margin-bottom: 24px;
    letter-spacing: -0.02em;
}

/* Features grid */
.landing-features-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}

.landing-feature-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 28px 24px;
    text-align: center;
    transition: all .25s;
    position: relative; overflow: hidden;
}
.landing-feature-card::before {
    content: '';
    position: absolute; inset: 0;
    background: var(--accent-gradient);
    opacity: 0;
    transition: opacity .25s;
}
.landing-feature-card:hover {
    transform: translateY(-4px);
    border-color: var(--accent-border);
    box-shadow: 0 8px 32px rgba(0,0,0,.15);
}
.landing-feature-card:hover::before { opacity: 1; }

.landing-feature-icon {
    font-size: 2.2rem; margin-bottom: 14px;
    position: relative; z-index: 1;
}
.landing-feature-card h4 {
    font-size: .95rem; font-weight: 600; margin-bottom: 8px;
    position: relative; z-index: 1;
}
.landing-feature-card p {
    font-size: .84rem; color: var(--text-secondary); line-height: 1.6;
    position: relative; z-index: 1;
}

/* Benefits section (3-column) */
.landing-benefits-grid {
    display: grid; grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}
.landing-benefit-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 28px 22px;
    transition: all .25s;
}
.landing-benefit-card:hover {
    transform: translateY(-3px);
    border-color: var(--accent-border);
    box-shadow: 0 8px 24px rgba(0,0,0,.12);
}
.landing-benefit-icon {
    width: 44px; height: 44px;
    display: flex; align-items: center; justify-content: center;
    background: var(--accent-gradient);
    border: 1px solid var(--accent-border);
    border-radius: 12px;
    margin-bottom: 16px; font-size: 1.3rem;
}
.landing-benefit-card h4 { font-size: .95rem; font-weight: 600; margin-bottom: 8px; }
.landing-benefit-card p { font-size: .84rem; color: var(--text-secondary); line-height: 1.6; }

/* Use cases grid */
.landing-usecases-grid {
    display: grid; grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}
.landing-usecase-card {
    display: flex; align-items: flex-start; gap: 16px;
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 24px;
    transition: all .2s;
}
.landing-usecase-card:hover {
    border-color: var(--accent-border);
    transform: translateY(-2px);
}
.landing-usecase-icon {
    width: 40px; height: 40px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    background: var(--accent-gradient);
    border: 1px solid var(--accent-border);
    border-radius: 10px; font-size: 1.1rem;
}
.landing-usecase-card h4 { font-size: .9rem; font-weight: 600; margin-bottom: 4px; }
.landing-usecase-card p { font-size: .82rem; color: var(--text-secondary); line-height: 1.5; }

/* FAQ */
.landing-faq-list {
    max-width: 680px; margin: 0 auto;
    display: flex; flex-direction: column; gap: 8px;
}
.landing-faq-item {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); overflow: hidden;
    transition: border-color .2s;
}
.landing-faq-item:hover { border-color: var(--accent-border); }
.landing-faq-q {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px; cursor: pointer;
    font-size: .9rem; font-weight: 600;
    color: var(--text-primary);
    transition: color .15s;
    user-select: none; width: 100%; text-align: left;
}
.landing-faq-q:hover { color: var(--accent); }
.landing-faq-q svg {
    flex-shrink: 0; color: var(--text-muted);
    transition: transform .25s;
}
.landing-faq-item.open .landing-faq-q svg { transform: rotate(180deg); }
.landing-faq-a {
    max-height: 0; overflow: hidden;
    transition: max-height .3s ease, padding .3s ease;
    padding: 0 20px;
    font-size: .86rem; color: var(--text-secondary); line-height: 1.7;
}
.landing-faq-item.open .landing-faq-a {
    max-height: 300px; padding: 0 20px 16px;
}

/* Models */
.landing-model-category { margin-bottom: 16px; }
.landing-model-category-name {
    font-size: .78rem; font-weight: 600;
    color: var(--text-muted); margin-bottom: 10px;
    text-align: center; text-transform: uppercase; letter-spacing: .5px;
}
.landing-model-list { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.landing-model-tag {
    padding: 7px 16px; background: var(--bg-card); border: 1px solid var(--border);
    border-radius: 20px; font-size: .82rem; color: var(--text-secondary);
    transition: all .2s;
}
.landing-model-tag:hover {
    border-color: var(--accent-border);
    background: var(--accent-gradient);
}
.landing-hint { font-size: .82rem; color: var(--text-muted); text-align: center; margin-top: 16px; }

/* Plans */
.landing-plans-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px; max-width: 680px; margin: 0 auto;
}
.landing-plan-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 20px; text-align: center;
    transition: all .2s;
}
.landing-plan-card:hover { transform: translateY(-3px); box-shadow: 0 8px 24px rgba(0,0,0,.12); }
.landing-plan-card.popular {
    border-color: var(--accent);
    box-shadow: 0 0 20px var(--accent-glow);
}
.landing-plan-name { font-size: .92rem; font-weight: 700; margin-bottom: 4px; }
.landing-plan-price { font-size: .84rem; color: var(--text-secondary); }

/* CTA block */
.landing-cta {
    text-align: center;
    background: var(--accent-gradient);
    border: 1px solid var(--accent-border);
    border-radius: var(--radius);
    padding: 48px 24px;
}
.landing-cta h3 { margin-bottom: 8px; }
.landing-cta p { color: var(--text-secondary); font-size: .88rem; margin-bottom: 20px; }

/* Landing footer */
.landing-docs {
    text-align: center;
    padding-bottom: 16px;
}
.landing-docs h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 12px;
}
.landing-docs-links {
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
}
.landing-docs-links a {
    font-size: .85rem;
    color: var(--text-muted);
    text-decoration: none;
    transition: color .15s;
}
.landing-docs-links a:hover {
    color: var(--accent);
}

.landing-footer {
    text-align: center; padding: 24px;
    font-size: .78rem; color: var(--text-muted);
    border-top: 1px solid var(--border);
    max-width: 960px; margin: 0 auto;
}

/* ============================================================
   Status / Notifications
   ============================================================ */
.status-message { text-align: center; padding: 10px; font-size: .85rem; color: var(--text-secondary); animation: fadeIn .2s; }
.error-message {
    text-align: left; padding: 10px 14px;
    font-size: .85rem; color: #b91c1c;
    background: rgba(239,68,68,.07);
    border: 1px solid rgba(239,68,68,.15);
    border-radius: var(--radius-sm); margin: 4px 0;
}
.error-message a {
    color: var(--accent); font-weight: 600;
    text-decoration: underline; cursor: pointer;
}
.error-message a:hover { color: var(--accent-hover); }

.notification {
    position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
    padding: 10px 24px; background: var(--accent); color: #fff;
    border-radius: var(--radius-sm); font-size: .85rem;
    z-index: 9999; animation: fadeIn .3s;
    box-shadow: 0 4px 16px rgba(0,0,0,.3); white-space: nowrap;
}
.notification.error { background: var(--danger); }
.notification.fade-out { opacity: 0; transition: opacity .3s; }

/* ============================================================
   Animations
   ============================================================ */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes typing {
    0%, 80%, 100% { transform: scale(.6); opacity: .4; }
    40% { transform: scale(1); opacity: 1; }
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse-recording {
    0% { opacity: 1; transform: scale(1); }
    50% { opacity: .5; transform: scale(1.15); }
    100% { opacity: 1; transform: scale(1); }
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 768px) {
    .sidebar {
        position: fixed; left: 0; top: 0;
        transform: translateX(-100%);
        box-shadow: 4px 0 20px rgba(0,0,0,.3);
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar-overlay.visible { display: block; }
    .menu-btn { display: flex; }

    .topbar { padding: 0 12px; }
    .chat-input-area { padding: 0 12px 14px; }
    .message-row { padding: 10px 14px; }

    .model-dropdown { width: calc(100vw - 24px); left: 12px; }

    .images-view { padding: 16px 12px; }
    .images-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }

    .plans-grid { grid-template-columns: 1fr; }

    .landing-hero h2 { font-size: 1.35rem; }
    .landing-features-grid { grid-template-columns: 1fr 1fr; }
    .landing-benefits-grid { grid-template-columns: 1fr; }
    .landing-usecases-grid { grid-template-columns: 1fr; }
    .welcome-screen h2 { font-size: 1.3rem; }
    .welcome-suggestions { gap: 6px; }
    .welcome-chip { padding: 8px 14px; font-size: .8rem; }

    .auth-code-inputs input { width: 38px; height: 44px; font-size: 1.1rem; }

    .topbar-premium-btn { padding: 5px 10px; font-size: .75rem; }

    /* Hide text labels on input action buttons — icons only on mobile */
    .image-gen-btn.active,
    .web-search-btn.active { max-width: 32px; padding: 0; border-radius: var(--radius-sm); }
    .image-gen-btn.active .image-gen-label,
    .web-search-btn.active .web-search-label { max-width: 0; opacity: 0; margin-left: 0; }
}

@media (max-width: 480px) {
    .landing-features-grid { grid-template-columns: 1fr; }
    .landing-hero h2 { font-size: 1.15rem; }
    .landing-hero { padding: 40px 16px 28px; }
    .auth-card { padding: 24px 20px; }
    .auth-code-inputs { gap: 6px; }
    .auth-code-inputs input { width: 34px; height: 40px; font-size: 1rem; }
    .welcome-chip { font-size: .78rem; padding: 8px 12px; }
}

@media (min-width: 769px) {
    .sidebar-close { display: none; }
    .sidebar-overlay { display: none !important; }
}

@media print {
    .sidebar, .topbar, .chat-input-area, .sidebar-overlay { display: none !important; }
    .main { height: auto; overflow: visible; }
    .chat-messages { overflow: visible; height: auto; }
}

/* ── SEO articles section (visible to crawlers, shown on landing) ── */
.seo-articles-nav {
    background: var(--bg-primary);
    border-top: 1px solid var(--border);
    padding: 40px 20px;
}
.seo-articles-list {
    max-width: 800px;
    margin: 0 auto;
}
.seo-articles-list h2 {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 20px;
}
.seo-articles-list ul {
    list-style: none;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-bottom: 20px;
}
.seo-articles-list li a {
    font-size: .95rem;
    font-weight: 500;
    color: var(--accent);
    text-decoration: none;
}
.seo-articles-list li a:hover { text-decoration: underline; }
.seo-articles-list li p {
    font-size: .82rem;
    color: var(--text-muted);
    margin-top: 2px;
    line-height: 1.4;
}
.seo-articles-list > a {
    font-size: .88rem;
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
}
.seo-articles-list > a:hover { text-decoration: underline; }
.seo-articles-list img { max-width: 100%; height: auto !important; }
