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

:root, [data-theme="indigo"] {
    /* Indigo (default) — cool neutral dark + indigo accent */
    --bg-primary: #0f1115;
    --bg-secondary: #16181d;
    --bg-tertiary: #1c1f25;
    --bg-elevated: #23262e;
    --bg-glass: rgba(22, 24, 29, 0.72);
    --text-primary: #e7e8ed;
    --text-secondary: #9da2af;
    --text-muted: #5f6573;
    --accent: #7d8ee8;
    --accent-hover: #6678dc;
    --accent-soft: rgba(125, 142, 232, 0.13);
    --accent-fg: #0f1115;
    --border: #262932;
    --border-soft: rgba(38, 41, 50, 0.6);
    --success: #6ba37d;
    --error: #d06a5a;
    --warning: #d4a55a;
    --code-bg: #0a0c10;
    --code-border: #262932;
}

[data-theme="forest"] {
    /* Forest — neutral dark + sage-green accent */
    --bg-primary: #0f1311;
    --bg-secondary: #161a17;
    --bg-tertiary: #1c211d;
    --bg-elevated: #232925;
    --bg-glass: rgba(22, 26, 23, 0.72);
    --text-primary: #e6eae6;
    --text-secondary: #9ea69e;
    --text-muted: #5f675f;
    --accent: #6ba37d;
    --accent-hover: #558a66;
    --accent-soft: rgba(107, 163, 125, 0.13);
    --accent-fg: #0f1311;
    --border: #262b27;
    --border-soft: rgba(38, 43, 39, 0.6);
    --success: #6ba37d;
    --error: #d06a5a;
    --warning: #d4a55a;
    --code-bg: #0a0d0b;
    --code-border: #262b27;
}

[data-theme="brass"] {
    /* Brass — warm charcoal + muted brass/gold accent */
    --bg-primary: #14110d;
    --bg-secondary: #1b1813;
    --bg-tertiary: #221e18;
    --bg-elevated: #2a261f;
    --bg-glass: rgba(27, 24, 19, 0.72);
    --text-primary: #ece6da;
    --text-secondary: #a59c8c;
    --text-muted: #6b6457;
    --accent: #c79850;
    --accent-hover: #b0823c;
    --accent-soft: rgba(199, 152, 80, 0.13);
    --accent-fg: #14110d;
    --border: #2c281f;
    --border-soft: rgba(44, 40, 31, 0.6);
    --success: #6ba37d;
    --error: #d06a5a;
    --warning: #d4a55a;
    --code-bg: #0f0d09;
    --code-border: #2c281f;
}

[data-theme="light"] {
    /* Light — warm paper white + indigo accent */
    --bg-primary: #f6f5f1;
    --bg-secondary: #fbfaf6;
    --bg-tertiary: #eeece5;
    --bg-elevated: #ffffff;
    --bg-glass: rgba(251, 250, 246, 0.82);
    --text-primary: #18191c;
    --text-secondary: #555864;
    --text-muted: #8e90a0;
    --accent: #4f5fd8;
    --accent-hover: #3e4ec8;
    --accent-soft: rgba(79, 95, 216, 0.09);
    --accent-fg: #ffffff;
    --border: #e3e1d6;
    --border-soft: rgba(227, 225, 214, 0.7);
    --success: #5a8a57;
    --error: #b54a3d;
    --warning: #b88a3f;
    --code-bg: #efece2;
    --code-border: #e3e1d6;
}

[data-theme="blossom"] {
    /* Blossom — тёплая пудровая палитра */
    --bg-primary: #f0e8e0;
    --bg-secondary: #f7e1d7;
    --bg-tertiary: #edafb8;
    --bg-elevated: #fdf5f0;
    --bg-glass: rgba(247, 225, 215, 0.82);
    --text-primary: #2a3133;
    --text-secondary: #4a5759;
    --text-muted: #7a9091;
    --accent: #4a5759;
    --accent-hover: #3a4446;
    --accent-soft: rgba(74, 87, 89, 0.12);
    --accent-fg: #f7e1d7;
    --border: #dedbd2;
    --border-soft: rgba(222, 219, 210, 0.6);
    --success: #6a8f6b;
    --error: #c0544a;
    --warning: #b88a3f;
    --code-bg: #ede0d8;
    --code-border: #dedbd2;
}

/* ============================================================
   APILAUNCHER — PREMIUM REDESIGN (aurum + neural)
   Эстетика: Linear / Raycast. Тихое стекло, AI как свет.
   ============================================================ */

[data-theme="aurum"] {
    --bg-primary:        #F4F5F8;
    --bg-secondary:      #FFFFFF;
    --bg-surface:        #FCFCFD;
    --bg-glass:          rgba(255,255,255,0.72);
    --bg-glass-strong:   rgba(255,255,255,0.86);
    --text-primary:      #0C0F16;
    --text-secondary:    #4B5263;
    --text-muted:        #8A92A2;
    --text-faint:        #B5BAC5;
    --border-faint:      rgba(15,20,35,0.05);
    --border-subtle:     rgba(15,20,35,0.08);
    --border-strong:     rgba(15,20,35,0.14);
    --accent:            #3858E9;
    --accent-hover:      #2D49D4;
    --accent-soft:       rgba(56,88,233,0.08);
    --accent-soft-2:     rgba(56,88,233,0.14);
    --accent-glow:       rgba(56,88,233,0.18);
    --shadow-1: 0 1px 2px rgba(15,20,35,0.04), 0 1px 3px rgba(15,20,35,0.03);
    --shadow-2: 0 4px 12px rgba(15,20,35,0.06), 0 2px 4px rgba(15,20,35,0.04);
    --shadow-3: 0 12px 32px rgba(15,20,35,0.08), 0 4px 12px rgba(15,20,35,0.05);
    --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
    --bg-tertiary:       #ECEEF2;
    --border:            rgba(15,20,35,0.10);
    --accent-fg:         #FFFFFF;
    --input-bg:          #F4F5F8;
    --modal-bg:          #FFFFFF;
    /* Дополнительные переменные для tool-card / code-блоков (светлая тема) */
    --bg-elevated:       #FFFFFF;
    --border-soft:       rgba(15,20,35,0.08);
    --code-bg:           #F0F2F6;
    --code-border:       rgba(15,20,35,0.10);
    --success:           #1F8A4C;
    --error:             #C0392B;
}
[data-theme="aurum"] body::before {
    background:
        radial-gradient(ellipse 60% 40% at 15% -5%, rgba(56,88,233,0.05), transparent 60%),
        radial-gradient(ellipse 50% 35% at 85% 100%, rgba(120,140,200,0.04), transparent 60%);
}
[data-theme="aurum"] .sidebar {
    background: var(--bg-glass);
    backdrop-filter: blur(24px) saturate(140%);
    -webkit-backdrop-filter: blur(24px) saturate(140%);
    border-right: 1px solid var(--border-faint);
    box-shadow: inset -1px 0 0 rgba(255,255,255,0.6);
}
[data-theme="aurum"] .sidebar-header {
    padding: 18px 16px 14px; border-bottom: 1px solid var(--border-faint);
    background: transparent; display: flex; flex-direction: column;
    align-items: flex-start; gap: 6px;
}
[data-theme="aurum"] .sidebar-header .brand-name {
    font-size: 15px; font-weight: 600; color: var(--text-primary);
}
[data-theme="aurum"] #userBadge {
    background: transparent; color: var(--text-muted); font-size: 11px; font-weight: 500;
    letter-spacing: 0.02em; padding: 0; border-radius: 0; align-self: flex-start;
}
[data-theme="aurum"] #newChatBtn {
    margin: 14px 12px 8px; padding: 11px 14px; border-radius: 12px;
    background: var(--bg-secondary); border: 1px solid var(--border-subtle);
    color: var(--text-primary); font-size: 13.5px; font-weight: 500;
    box-shadow: var(--shadow-1), inset 0 1px 0 rgba(255,255,255,0.8);
    transition: all 180ms var(--ease); display: flex; align-items: center; justify-content: center; gap: 8px; width: calc(100% - 24px);
}
[data-theme="aurum"] #newChatBtn:hover {
    border-color: var(--border-strong);
    box-shadow: var(--shadow-2), 0 0 0 4px var(--accent-soft), inset 0 1px 0 rgba(255,255,255,0.8);
    transform: translateY(-1px);
}
[data-theme="aurum"] #newChatBtn svg { width: 14px; height: 14px; opacity: 0.7; }
[data-theme="aurum"] #syncBtn {
    margin: 0 12px 12px; padding: 8px 12px; border-radius: 10px;
    background: transparent; border: 1px solid transparent; color: var(--text-muted);
    font-size: 12.5px; font-weight: 500; transition: all 180ms var(--ease);
    display: flex; align-items: center; gap: 8px; width: calc(100% - 24px);
}
[data-theme="aurum"] #syncBtn:hover { background: rgba(15,20,35,0.04); color: var(--text-secondary); }
[data-theme="aurum"] #syncBtn svg { width: 13px; height: 13px; }

[data-theme="aurum"] .chat-item {
    position: relative; padding: 9px 12px 9px 14px; margin: 1px 0; border-radius: 8px;
    background: transparent; color: var(--text-secondary); font-size: 13px;
    transition: background 160ms var(--ease), color 160ms var(--ease);
}
[data-theme="aurum"] .chat-item::before {
    content: ''; position: absolute; left: 4px; top: 50%;
    transform: translateY(-50%) scaleY(0); width: 2px; height: 18px;
    background: var(--accent); border-radius: 2px; transition: transform 200ms var(--ease);
}
[data-theme="aurum"] .chat-item:hover { background: rgba(15,20,35,0.04); color: var(--text-primary); }
[data-theme="aurum"] .chat-item.active {
    background: var(--accent-soft); color: var(--text-primary); font-weight: 500;
}
[data-theme="aurum"] .chat-item.active::before { transform: translateY(-50%) scaleY(1); }

[data-theme="aurum"] .sidebar-footer {
    padding: 10px 12px; border-top: 1px solid var(--border-faint);
    background: transparent; display: flex; align-items: center;
    justify-content: center; gap: 8px;
}
[data-theme="aurum"] {
    --brand-mark-top: #5673F0;
    --brand-mark-bot: #2A3FC9;
}
[data-theme="aurum"] .sidebar-footer-btn,
[data-theme="aurum"] #openSettingsBtn {
    padding: 6px 10px; border-radius: 8px; background: transparent; border: none;
    color: var(--text-muted); font-size: 12px; transition: all 160ms var(--ease);
    display: inline-flex; align-items: center; gap: 6px;
}
[data-theme="aurum"] #openSettingsBtn:hover { background: rgba(15,20,35,0.04); color: var(--text-primary); }
[data-theme="aurum"] .sidebar-footer .badge { font-size: 11px; color: var(--text-faint); margin-right: auto; }

[data-theme="aurum"] .chat-header {
    height: 64px; padding: 0 20px; background: var(--bg-glass);
    backdrop-filter: blur(22px) saturate(140%); -webkit-backdrop-filter: blur(22px) saturate(140%);
    border-bottom: 1px solid var(--border-faint);
    box-shadow: inset 0 -1px 0 rgba(255,255,255,0.4);
    display: flex; align-items: center; gap: 16px;
}
[data-theme="aurum"] .header-left {
    display: flex; align-items: center; gap: 10px; min-width: 0; flex: 0 0 auto;
}
[data-theme="aurum"] #chatTitle {
    font-size: 15px; font-weight: 600; color: var(--text-primary);
    max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
[data-theme="aurum"] .header-right {
    margin-left: auto; display: flex; align-items: center; gap: 14px;
}
[data-theme="aurum"] .model-selector {
    appearance: none; -webkit-appearance: none;
    padding: 7px 32px 7px 14px; border-radius: 999px;
    background-color: var(--bg-glass-strong); border: 1px solid var(--border-subtle);
    color: var(--text-primary); font-size: 13px; font-weight: 500;
    box-shadow: var(--shadow-1), inset 0 1px 0 rgba(255,255,255,0.7);
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'><path d='M2 4l3 3 3-3' stroke='%238A92A2' stroke-width='1.4' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>");
    background-repeat: no-repeat; background-position: right 12px center;
    transition: all 160ms var(--ease); cursor: pointer; font-family: inherit;
}
[data-theme="aurum"] .model-selector:hover {
    border-color: var(--border-strong); box-shadow: var(--shadow-2), inset 0 1px 0 rgba(255,255,255,0.7);
}
[data-theme="aurum"] .header-utility { display: flex; align-items: center; gap: 4px; }
[data-theme="aurum"] .header-status {
    margin-left: 16px; padding-left: 0; border-left: none;
    display: flex; align-items: center;
}
[data-theme="aurum"] #statusDot {
    width: 6px; height: 6px; border-radius: 50%;
    background: #34C77B; box-shadow: 0 0 8px rgba(52,199,123,0.4);
}

[data-theme="aurum"] .icon-btn {
    width: 32px; height: 32px; padding: 0; border-radius: 10px;
    background: transparent; border: 1px solid transparent; color: var(--text-muted);
    display: inline-flex; align-items: center; justify-content: center;
    cursor: pointer; transition: all 160ms var(--ease); font-size: 0;
}
[data-theme="aurum"] .icon-btn:hover { background: rgba(15,20,35,0.05); color: var(--text-primary); }
[data-theme="aurum"] .icon-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-glow); }
[data-theme="aurum"] .icon-btn svg, [data-theme="aurum"] .input-action-btn svg { width: 16px; height: 16px; }
[data-theme="aurum"] #compareToggle.active { background: var(--accent-soft); color: var(--accent); }

[data-theme="aurum"] .empty-state {
    max-width: 640px; margin: 0 auto; padding: 80px 24px 60px; text-align: center;
    flex-direction: column; align-items: center; gap: 10px;
}
[data-theme="aurum"] .empty-state .empty-icon {
    width: auto; height: auto; margin-bottom: 22px;
    background: none; border: none; border-radius: 0; box-shadow: none;
    color: var(--accent); opacity: 0.55;
    display: inline-flex; align-items: center; justify-content: center; position: relative;
}
[data-theme="aurum"] .empty-state .empty-icon svg { width: 42px; height: 42px; }
[data-theme="aurum"] .empty-state .empty-icon::after {
    content: ''; position: absolute; inset: -50px;
    background: radial-gradient(circle, var(--accent-glow), transparent 65%);
    z-index: -1; pointer-events: none; opacity: 0.35;
}
[data-theme="aurum"] .empty-title {
    font-size: 24px; font-weight: 600; letter-spacing: -0.02em;
    color: var(--text-primary); line-height: 1.2;
    max-width: none; min-width: max-content; white-space: nowrap;
}
[data-theme="aurum"] .empty-hint {
    font-size: 14px; line-height: 1.5; color: var(--text-muted); max-width: 420px;
}
[data-theme="aurum"] #starterPrompts {
    display: flex; flex-wrap: wrap; justify-content: center; gap: 8px;
    margin-top: 28px; max-width: 560px;
}
[data-theme="aurum"] #starterPrompts > * {
    padding: 10px 16px; border-radius: 999px;
    background: var(--bg-glass-strong); border: 1px solid var(--border-subtle);
    color: var(--text-secondary); font-size: 13px; cursor: pointer;
    transition: all 180ms var(--ease); box-shadow: var(--shadow-1);
    white-space: nowrap;
}
[data-theme="aurum"] #starterPrompts > *:hover {
    background: #FFFFFF; border-color: var(--border-strong); color: var(--text-primary);
    transform: translateY(-1px); box-shadow: var(--shadow-2);
}

[data-theme="aurum"] .input-section {
    padding: 16px 24px 20px;
    background: linear-gradient(to top, var(--bg-primary) 50%, rgba(244,245,248,0));
}
[data-theme="aurum"] .input-wrapper {
    max-width: 820px; margin: 0 auto; padding: 14px 16px 10px; border-radius: 18px;
    background: var(--bg-secondary); border: 1px solid var(--border-subtle);
    box-shadow:
        0 1px 2px rgba(15,20,35,0.04),
        0 8px 24px rgba(15,20,35,0.06),
        inset 0 1px 0 rgba(255,255,255,0.9);
    transition: border-color 180ms var(--ease), box-shadow 180ms var(--ease);
}
[data-theme="aurum"] .input-wrapper:focus-within {
    border-color: rgba(56,88,233,0.35);
    box-shadow:
        0 0 0 4px var(--accent-soft),
        0 12px 32px rgba(56,88,233,0.10),
        inset 0 1px 0 rgba(255,255,255,0.9);
}
[data-theme="aurum"] #messageInput {
    background: transparent; border: none; color: var(--text-primary);
    font-size: 14.5px; line-height: 1.55; padding: 4px 6px;
}
[data-theme="aurum"] #messageInput::placeholder { color: var(--text-faint); }
[data-theme="aurum"] .input-row, [data-theme="aurum"] .input-actions {
    display: flex; align-items: center; gap: 4px; margin-top: 6px;
}
[data-theme="aurum"] .input-action-btn {
    width: 32px; height: 32px; padding: 0; border-radius: 10px;
    background: transparent; border: none; color: var(--text-muted);
    display: inline-flex; align-items: center; justify-content: center;
    cursor: pointer; transition: all 160ms var(--ease); font-size: 0;
}
[data-theme="aurum"] .input-action-btn:hover { background: rgba(15,20,35,0.05); color: var(--text-primary); }
[data-theme="aurum"] .input-action-btn.active { background: var(--accent-soft); color: var(--accent); }
[data-theme="aurum"] #sendBtn {
    width: 36px; height: 36px; margin-left: auto; padding: 0; border-radius: 12px;
    border: 1px solid transparent; background: transparent; color: var(--text-faint);
    box-shadow: none;
    display: inline-flex; align-items: center; justify-content: center;
    cursor: pointer; transition: background 180ms var(--ease), color 180ms var(--ease), box-shadow 180ms var(--ease), transform 180ms var(--ease); font-size: 0;
}
[data-theme="aurum"] #sendBtn:hover { background: rgba(15,20,35,0.04); color: var(--text-muted); }
[data-theme="aurum"] .input-wrapper:has(#messageInput:not(:placeholder-shown)) #sendBtn {
    background: linear-gradient(180deg, #4566EE, #2D49D4); color: #FFFFFF;
    box-shadow:
        0 1px 0 rgba(255,255,255,0.25) inset,
        0 0 0 1px rgba(20,40,160,0.18),
        0 4px 12px rgba(56,88,233,0.22);
}
[data-theme="aurum"] .input-wrapper:has(#messageInput:not(:placeholder-shown)) #sendBtn:hover {
    transform: translateY(-1px);
    box-shadow:
        0 1px 0 rgba(255,255,255,0.25) inset,
        0 0 0 1px rgba(20,40,160,0.22),
        0 8px 20px rgba(56,88,233,0.32);
}
[data-theme="aurum"] #sendBtn:disabled {
    background: transparent; color: rgba(15,20,35,0.20); box-shadow: none; cursor: not-allowed; transform: none;
}
[data-theme="aurum"] #sendBtn svg { width: 16px; height: 16px; }
[data-theme="aurum"] .input-footer {
    max-width: 820px; margin: 10px auto 0; padding: 0 6px;
    display: flex; justify-content: space-between; align-items: center; gap: 16px;
    font-size: 11.5px; color: var(--text-faint);
}
[data-theme="aurum"] .input-hint { font-size: 11.5px; color: var(--text-faint); letter-spacing: 0.01em; }
[data-theme="aurum"] #sessionStats {
    font-family: 'JetBrains Mono', monospace; font-size: 11px;
    color: var(--text-faint); letter-spacing: 0.02em;
}
[data-theme="aurum"] .message.assistant .message-content {
    background: transparent;
    border: none;
    border-radius: 0;
    box-shadow: none;
    color: var(--text-primary);
}
[data-theme="aurum"] .message.user .message-content {
    background: rgba(15,20,35,0.05);
    color: var(--text-primary);
    border: 1px solid var(--border-subtle);
    border-radius: 14px 4px 14px 14px;
    box-shadow: none;
    min-width: 0;
    width: 100%;
}
[data-theme="aurum"] .sidebar-brand-mark {
    filter: drop-shadow(0 2px 4px rgba(56,88,233,0.25)) drop-shadow(0 1px 1px rgba(15,20,35,0.10));
}


/* NEURAL */
[data-theme="neural"] {
    --bg-primary:        #0A0C12;
    --bg-secondary:      #11141C;
    --bg-surface:        #161A24;
    --bg-glass:          rgba(13,17,24,0.72);
    --bg-glass-strong:   rgba(20,24,33,0.86);
    --text-primary:      #ECEFF6;
    --text-secondary:    #9097A3;
    --text-muted:        #6B7280;
    --text-faint:        #4B5260;
    --border-faint:      rgba(255,255,255,0.04);
    --border-subtle:     rgba(255,255,255,0.07);
    --border-strong:     rgba(255,255,255,0.12);
    --accent:            #7C6CFF;
    --accent-hover:      #8E80FF;
    --accent-soft:       rgba(124,108,255,0.10);
    --accent-soft-2:     rgba(124,108,255,0.18);
    --accent-glow:       rgba(124,108,255,0.30);
    --shadow-1: 0 1px 2px rgba(0,0,0,0.30), 0 1px 3px rgba(0,0,0,0.20);
    --shadow-2: 0 4px 12px rgba(0,0,0,0.35), 0 2px 4px rgba(0,0,0,0.25);
    --shadow-3: 0 16px 40px rgba(0,0,0,0.45), 0 4px 16px rgba(0,0,0,0.30);
    --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
    --bg-tertiary:       #1C2030;
    --border:            rgba(255,255,255,0.08);
    --accent-fg:         #FFFFFF;
    --input-bg:          #1C2030;
    --modal-bg:          #161A24;
    /* Дополнительные переменные для tool-card / code-блоков (тёмная тема) */
    --bg-elevated:       #232838;
    --border-soft:       rgba(255,255,255,0.08);
    --code-bg:           #0E1119;
    --code-border:       rgba(255,255,255,0.10);
    --success:           #4ADE80;
    --error:             #F87171;
}
[data-theme="neural"] body::before {
    background:
        radial-gradient(ellipse 70% 50% at 20% -5%, rgba(124,108,255,0.10), transparent 60%),
        radial-gradient(ellipse 60% 40% at 90% 100%, rgba(80,140,255,0.06), transparent 60%);
}
[data-theme="neural"] .sidebar {
    background: var(--bg-glass);
    backdrop-filter: blur(28px) saturate(120%); -webkit-backdrop-filter: blur(28px) saturate(120%);
    border-right: 1px solid var(--border-faint);
    box-shadow: inset -1px 0 0 rgba(255,255,255,0.03);
}
[data-theme="neural"] .sidebar-header {
    padding: 18px 16px 14px; border-bottom: 1px solid var(--border-faint);
    background: transparent; display: flex; flex-direction: column;
    align-items: flex-start; gap: 6px;
}
[data-theme="neural"] .sidebar-header .brand-name {
    font-size: 15px; font-weight: 600; color: var(--text-primary);
}
[data-theme="neural"] #userBadge {
    background: transparent; color: var(--text-muted); font-size: 11px; font-weight: 500;
    letter-spacing: 0.02em; padding: 0; border-radius: 0; align-self: flex-start;
}
[data-theme="neural"] #newChatBtn {
    margin: 14px 12px 8px; padding: 11px 14px; border-radius: 12px;
    background: rgba(255,255,255,0.03); border: 1px solid var(--border-subtle);
    color: var(--text-primary); font-size: 13.5px; font-weight: 500;
    box-shadow: var(--shadow-1), inset 0 1px 0 rgba(255,255,255,0.05);
    transition: all 180ms var(--ease); display: flex; align-items: center; justify-content: center; gap: 8px; width: calc(100% - 24px);
}
[data-theme="neural"] #newChatBtn:hover {
    background: rgba(255,255,255,0.05); border-color: var(--border-strong);
    box-shadow:
        var(--shadow-2),
        0 0 0 4px var(--accent-soft),
        inset 0 1px 0 rgba(255,255,255,0.06);
    transform: translateY(-1px);
}
[data-theme="neural"] #newChatBtn svg { width: 14px; height: 14px; opacity: 0.7; }
[data-theme="neural"] #syncBtn {
    margin: 0 12px 12px; padding: 8px 12px; border-radius: 10px;
    background: transparent; border: 1px solid transparent; color: var(--text-muted);
    font-size: 12.5px; font-weight: 500; transition: all 180ms var(--ease);
    display: flex; align-items: center; gap: 8px; width: calc(100% - 24px);
}
[data-theme="neural"] #syncBtn:hover { background: rgba(255,255,255,0.04); color: var(--text-secondary); }
[data-theme="neural"] #syncBtn svg { width: 13px; height: 13px; }

[data-theme="neural"] .chat-item {
    position: relative; padding: 9px 12px 9px 14px; margin: 1px 0; border-radius: 8px;
    background: transparent; color: var(--text-secondary); font-size: 13px;
    transition: background 160ms var(--ease), color 160ms var(--ease);
}
[data-theme="neural"] .chat-item::before {
    content: ''; position: absolute; left: 4px; top: 50%;
    transform: translateY(-50%) scaleY(0); width: 2px; height: 18px;
    background: var(--accent); border-radius: 2px;
    transition: transform 200ms var(--ease);
}
[data-theme="neural"] .chat-item:hover { background: rgba(255,255,255,0.035); color: var(--text-primary); }
[data-theme="neural"] .chat-item.active {
    background: var(--accent-soft); color: var(--text-primary); font-weight: 500;
}
[data-theme="neural"] .chat-item.active::before { transform: translateY(-50%) scaleY(1); }

[data-theme="neural"] .sidebar-footer {
    padding: 10px 12px; border-top: 1px solid var(--border-faint);
    background: transparent; display: flex; align-items: center;
    justify-content: center; gap: 8px;
}
[data-theme="neural"] {
    --brand-mark-top: #9C8FFF;
    --brand-mark-bot: #5D4AE8;
}
[data-theme="neural"] #openSettingsBtn {
    padding: 6px 10px; border-radius: 8px; background: transparent; border: none;
    color: var(--text-muted); font-size: 12px; transition: all 160ms var(--ease);
    display: inline-flex; align-items: center; gap: 6px;
}
[data-theme="neural"] #openSettingsBtn:hover { background: rgba(255,255,255,0.05); color: var(--text-primary); }
[data-theme="neural"] .sidebar-footer .badge { font-size: 11px; color: var(--text-faint); margin-right: auto; }

[data-theme="neural"] .chat-header {
    height: 64px; padding: 0 20px; background: var(--bg-glass);
    backdrop-filter: blur(24px) saturate(120%); -webkit-backdrop-filter: blur(24px) saturate(120%);
    border-bottom: 1px solid var(--border-faint);
    box-shadow: inset 0 -1px 0 rgba(255,255,255,0.025);
    display: flex; align-items: center; gap: 16px;
}
[data-theme="neural"] .header-left { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 0 0 auto; }
[data-theme="neural"] #chatTitle {
    font-size: 15px; font-weight: 600; color: var(--text-primary);
    max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
[data-theme="neural"] .header-right { margin-left: auto; display: flex; align-items: center; gap: 14px; }
[data-theme="neural"] .model-selector {
    appearance: none; -webkit-appearance: none;
    padding: 7px 32px 7px 14px; border-radius: 999px;
    background-color: var(--bg-glass-strong); border: 1px solid var(--border-subtle);
    color: var(--text-primary); font-size: 13px; font-weight: 500;
    box-shadow: var(--shadow-1), inset 0 1px 0 rgba(255,255,255,0.04);
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'><path d='M2 4l3 3 3-3' stroke='%239097A3' stroke-width='1.4' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>");
    background-repeat: no-repeat; background-position: right 12px center;
    transition: all 160ms var(--ease); cursor: pointer; font-family: inherit;
}
[data-theme="neural"] .model-selector:hover { border-color: var(--border-strong); background-color: rgba(28,33,46,0.9); }
[data-theme="neural"] .header-utility { display: flex; align-items: center; gap: 4px; }
[data-theme="neural"] .header-status {
    margin-left: 16px; padding-left: 0; border-left: none;
    display: flex; align-items: center;
}
[data-theme="neural"] #statusDot {
    width: 6px; height: 6px; border-radius: 50%;
    background: #34C77B; box-shadow: 0 0 10px rgba(52,199,123,0.5);
}
[data-theme="neural"] .icon-btn {
    width: 32px; height: 32px; padding: 0; border-radius: 10px;
    background: transparent; border: 1px solid transparent; color: var(--text-muted);
    display: inline-flex; align-items: center; justify-content: center;
    cursor: pointer; transition: all 160ms var(--ease); font-size: 0;
}
[data-theme="neural"] .icon-btn:hover { background: rgba(255,255,255,0.06); color: var(--text-primary); }
[data-theme="neural"] .icon-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-glow); }
[data-theme="neural"] .icon-btn svg, [data-theme="neural"] .input-action-btn svg { width: 16px; height: 16px; }
[data-theme="neural"] #compareToggle.active { background: var(--accent-soft-2); color: var(--accent); }

[data-theme="neural"] .empty-state {
    max-width: 640px; margin: 0 auto; padding: 80px 24px 60px; text-align: center;
    flex-direction: column; align-items: center; gap: 10px;
}
[data-theme="neural"] .empty-state .empty-icon {
    width: auto; height: auto; margin-bottom: 22px;
    background: none; border: none; border-radius: 0; box-shadow: none;
    color: var(--accent); opacity: 0.55;
    display: inline-flex; align-items: center; justify-content: center; position: relative;
}
[data-theme="neural"] .empty-state .empty-icon svg { width: 42px; height: 42px; }
[data-theme="neural"] .empty-state .empty-icon::after {
    content: ''; position: absolute; inset: -50px;
    background: radial-gradient(circle, var(--accent-glow), transparent 60%);
    z-index: -1; pointer-events: none; opacity: 0.40;
}
[data-theme="neural"] .empty-title {
    font-size: 24px; font-weight: 600; letter-spacing: -0.02em;
    color: var(--text-primary); line-height: 1.2;
    max-width: none; min-width: max-content; white-space: nowrap;
}
[data-theme="neural"] .empty-hint { font-size: 14px; line-height: 1.5; color: var(--text-muted); max-width: 420px; }
[data-theme="neural"] #starterPrompts {
    display: flex; flex-wrap: wrap; justify-content: center; gap: 8px;
    margin-top: 28px; max-width: 560px;
}
[data-theme="neural"] #starterPrompts > * {
    padding: 10px 16px; border-radius: 999px;
    background: rgba(255,255,255,0.03); border: 1px solid var(--border-subtle);
    color: var(--text-secondary); font-size: 13px; cursor: pointer;
    transition: all 180ms var(--ease);
    white-space: nowrap;
}
[data-theme="neural"] #starterPrompts > *:hover {
    background: rgba(255,255,255,0.05); border-color: var(--border-strong); color: var(--text-primary);
    transform: translateY(-1px); box-shadow: var(--shadow-2);
}

[data-theme="neural"] .input-section {
    padding: 16px 24px 20px;
    background: linear-gradient(to top, var(--bg-primary) 50%, rgba(10,12,18,0));
}
[data-theme="neural"] .input-wrapper {
    max-width: 820px; margin: 0 auto; padding: 14px 16px 10px; border-radius: 18px;
    background: var(--bg-glass-strong); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
    border: 1px solid var(--border-subtle);
    box-shadow:
        0 1px 2px rgba(0,0,0,0.35),
        0 12px 32px rgba(0,0,0,0.30),
        inset 0 1px 0 rgba(255,255,255,0.06);
    transition: border-color 180ms var(--ease), box-shadow 180ms var(--ease);
}
[data-theme="neural"] .input-wrapper:focus-within {
    border-color: rgba(124,108,255,0.45);
    box-shadow:
        0 0 0 4px var(--accent-soft),
        0 0 32px rgba(124,108,255,0.20),
        0 12px 32px rgba(0,0,0,0.40),
        inset 0 1px 0 rgba(255,255,255,0.08);
}
[data-theme="neural"] #messageInput {
    background: transparent; border: none; color: var(--text-primary);
    font-size: 14.5px; line-height: 1.55; padding: 4px 6px;
}
[data-theme="neural"] #messageInput::placeholder { color: var(--text-faint); }
[data-theme="neural"] .input-row, [data-theme="neural"] .input-actions {
    display: flex; align-items: center; gap: 4px; margin-top: 6px;
}
[data-theme="neural"] .input-action-btn {
    width: 32px; height: 32px; padding: 0; border-radius: 10px;
    background: transparent; border: none; color: var(--text-muted);
    display: inline-flex; align-items: center; justify-content: center;
    cursor: pointer; transition: all 160ms var(--ease); font-size: 0;
}
[data-theme="neural"] .input-action-btn:hover { background: rgba(255,255,255,0.06); color: var(--text-primary); }
[data-theme="neural"] .input-action-btn.active { background: var(--accent-soft-2); color: var(--accent); }
[data-theme="neural"] #reasoningBtn { font-size: 16px; line-height: 1; }
[data-theme="neural"] .input-action-btn#reasoningBtn { font-size: 16px !important; line-height: 1; }
[data-theme="aurum"] #reasoningBtn { font-size: 16px; line-height: 1; }
[data-theme="aurum"] .input-action-btn#reasoningBtn { font-size: 16px !important; line-height: 1; }
[data-theme="neural"] #sendBtn {
    width: 36px; height: 36px; margin-left: auto; padding: 0; border-radius: 12px;
    border: 1px solid transparent; background: rgba(255,255,255,0.04); color: var(--text-faint);
    box-shadow: none;
    display: inline-flex; align-items: center; justify-content: center;
    cursor: pointer; transition: background 180ms var(--ease), color 180ms var(--ease), box-shadow 180ms var(--ease), transform 180ms var(--ease); font-size: 0;
}
[data-theme="neural"] #sendBtn:hover { background: rgba(255,255,255,0.07); color: var(--text-muted); }
[data-theme="neural"] .input-wrapper:has(#messageInput:not(:placeholder-shown)) #sendBtn {
    background: linear-gradient(180deg, #8E80FF, #6450F0); color: #FFFFFF;
    box-shadow:
        0 1px 0 rgba(255,255,255,0.20) inset,
        0 0 0 1px rgba(80,60,200,0.30),
        0 0 18px rgba(124,108,255,0.28),
        0 3px 10px rgba(0,0,0,0.35);
}
[data-theme="neural"] .input-wrapper:has(#messageInput:not(:placeholder-shown)) #sendBtn:hover {
    transform: translateY(-1px);
    box-shadow:
        0 1px 0 rgba(255,255,255,0.22) inset,
        0 0 0 1px rgba(80,60,200,0.35),
        0 0 26px rgba(124,108,255,0.38),
        0 6px 14px rgba(0,0,0,0.40);
}
[data-theme="neural"] #sendBtn:disabled {
    background: rgba(255,255,255,0.03); color: rgba(255,255,255,0.18); box-shadow: none; cursor: not-allowed; transform: none;
}
[data-theme="neural"] #sendBtn svg { width: 16px; height: 16px; }
[data-theme="neural"] .input-footer {
    max-width: 820px; margin: 10px auto 0; padding: 0 6px;
    display: flex; justify-content: space-between; align-items: center; gap: 16px;
    font-size: 11.5px; color: var(--text-faint);
}
[data-theme="neural"] .input-hint { font-size: 11.5px; color: var(--text-faint); letter-spacing: 0.01em; }
[data-theme="neural"] #sessionStats {
    font-family: 'JetBrains Mono', monospace; font-size: 11px;
    color: var(--text-faint); letter-spacing: 0.02em;
}
[data-theme="neural"] .message.assistant .message-content {
    background: transparent;
    backdrop-filter: none; -webkit-backdrop-filter: none;
    border: none;
    border-radius: 0;
    box-shadow: none;
    color: var(--text-primary);
}
[data-theme="neural"] .message.user .message-content {
    background: rgba(255,255,255,0.06);
    color: var(--text-primary);
    border: 1px solid var(--border-faint);
    border-radius: 14px 4px 14px 14px;
    box-shadow: none;
    backdrop-filter: none; -webkit-backdrop-filter: none;
    min-width: 0;
    width: 100%;
}
[data-theme="neural"] .sidebar-brand-mark {
    filter: drop-shadow(0 0 12px rgba(124,108,255,0.35)) drop-shadow(0 2px 4px rgba(0,0,0,0.40));
}

html, body {
    width: 100%; height: 100%;
    font-family: 'Inter Tight', ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Helvetica, Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    overflow: hidden;
    transition: background 0.25s ease, color 0.25s ease;
    font-feature-settings: "cv11", "ss01", "calt";
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    letter-spacing: -0.005em;
}

/* Тонкая текстура фона — почти незаметная */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse 90% 60% at 20% 0%, var(--accent-soft), transparent 60%),
        radial-gradient(ellipse 70% 50% at 100% 100%, var(--accent-soft), transparent 60%);
    opacity: 0.5;
    pointer-events: none;
    z-index: 0;
}

.container { display: flex; height: 100vh; position: relative; z-index: 1; transition: padding-right 0.25s cubic-bezier(.4,0,.2,1); }
.container.artifact-open { padding-right: 45%; }
@media (max-width: 1200px) { .container.artifact-open { padding-right: 50%; } }
@media (max-width: 900px)  { .container.artifact-open { padding-right: 60%; } }
@media (max-width: 768px)  { .container.artifact-open { padding-right: 0; } }

/* Blossom theme card */
.blossom-card { background: linear-gradient(135deg, #edafb8, #f7e1d7) !important; color: #4a5759 !important; }

/* ===== AUTH SCREEN ===== */
.auth-screen {
    position: fixed;
    inset: 0;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 20px;
}

.auth-screen::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse 80% 60% at 50% 0%, var(--accent-soft), transparent 60%),
        radial-gradient(ellipse 60% 50% at 50% 100%, var(--accent-soft), transparent 60%);
    pointer-events: none;
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 40px 32px;
    position: relative;
    z-index: 1;
    box-shadow: 0 1px 0 rgba(255,255,255,0.04) inset, 0 24px 64px rgba(0, 0, 0, 0.35);
}

.auth-logo {
    width: 56px;
    height: 56px;
    margin: 0 auto 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
}

.auth-logo svg { width: 100%; height: 100%; }

.auth-title {
    font-size: 22px;
    font-weight: 600;
    text-align: center;
    margin-bottom: 6px;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

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

.auth-tabs {
    display: flex;
    gap: 4px;
    background: var(--bg-tertiary);
    padding: 4px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.auth-tab {
    flex: 1;
    padding: 8px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.auth-tab.active {
    background: var(--bg-secondary);
    color: var(--text-primary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.auth-form { display: flex; flex-direction: column; gap: 14px; }

.auth-input {
    width: 100%;
    padding: 12px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 14px;
    transition: all 0.2s ease;
}

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

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

.auth-btn {
    width: 100%;
    padding: 12px;
    background: var(--accent);
    color: var(--accent-fg);
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.15s ease;
    letter-spacing: 0.1px;
}

.auth-btn:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
}

.auth-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 8px 0;
    color: var(--text-muted);
    font-size: 11px;
    text-transform: uppercase;
}

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

.auth-skip {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    width: 100%;
    padding: 11px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s ease;
}

.auth-skip:hover {
    color: var(--text-primary);
    border-color: var(--text-secondary);
}

.auth-error {
    color: var(--error);
    font-size: 12px;
    text-align: center;
    min-height: 16px;
    margin-top: 4px;
}

.auth-info {
    margin-top: 20px;
    padding: 12px;
    background: var(--accent-soft);
    border-radius: 8px;
    font-size: 11px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.auth-info strong { color: var(--text-primary); }

.user-list {
    margin-top: 16px;
    max-height: 140px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.user-list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border-radius: 6px;
    font-size: 12px;
    color: var(--text-secondary);
}

.user-list-item button {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 14px;
    padding: 2px 6px;
}

.user-list-item button:hover { color: var(--error); }

/* ===== SIDEBAR ===== */
.sidebar {
    width: 280px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: width 0.3s ease, margin-left 0.3s ease;
    flex-shrink: 0;
}

.sidebar.collapsed { width: 0; margin-left: -1px; }
#appContainer.mail-fullwidth #sidebar { width: 0; margin-left: -1px; overflow: hidden; }
#appContainer.mail-fullwidth #sidebarBackdrop { display: none; }

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

.sidebar-brand {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.005em;
    display: flex;
    align-items: center;
    gap: 9px;
}

.sidebar-brand-mark {
    width: 22px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
}

.sidebar-brand-mark svg { width: 100%; height: 100%; }

.user-badge {
    font-size: 11px;
    padding: 3px 8px;
    background: var(--accent-soft);
    color: var(--accent);
    border-radius: 4px;
    font-weight: 500;
}

.user-badge.guest {
    background: rgba(251, 191, 36, 0.1);
    color: var(--warning);
}

/* ===== Sync button ===== */
.sync-btn {
    margin: 0 12px;
    padding: 8px 12px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
}
.sync-btn:hover:not(:disabled) {
    background: var(--accent-soft);
    color: var(--accent);
    border-color: var(--accent);
}
.sync-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.sync-btn .sync-icon {
    display: inline-block;
    width: 14px;
    height: 14px;
    line-height: 14px;
    text-align: center;
}
.sync-btn.syncing .sync-icon {
    animation: sync-spin 1s linear infinite;
}
.sync-btn.ok {
    background: rgba(34, 197, 94, 0.1);
    color: #22c55e;
    border-color: rgba(34, 197, 94, 0.3);
}
.sync-btn.error {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border-color: rgba(239, 68, 68, 0.3);
}
@keyframes sync-spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

.new-chat-btn {
    margin: 12px;
    padding: 10px 14px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.new-chat-btn:hover {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--accent);
}

.new-chat-btn span:first-child {
    font-size: 14px;
    color: var(--accent);
    font-weight: 600;
}

.chats-list {
    flex: 1;
    overflow-y: auto;
    padding: 0 8px 8px;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.chat-item {
    padding: 10px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-secondary);
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    position: relative;
}

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

.chat-item.active {
    background: var(--accent-soft);
    color: var(--accent);
}

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

.chat-item-title input {
    width: 100%;
    background: var(--bg-primary);
    border: 1px solid var(--accent);
    color: var(--text-primary);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 13px;
}

.chat-item-actions {
    display: none;
    gap: 4px;
}

.chat-item:hover .chat-item-actions { display: flex; }

.chat-item-actions button {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px 4px;
    font-size: 12px;
    border-radius: 3px;
}

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

.sidebar-tabs { display: none; }
.sidebar-tab { display: none; }
.sidebar-panel { display: none; }

/* ===== SIDEBAR SCROLL + SECTIONS ===== */
.sidebar-scroll {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
}
.sidebar-scroll::-webkit-scrollbar { width: 4px; }
.sidebar-scroll::-webkit-scrollbar-track { background: transparent; }
.sidebar-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.sidebar-section {
    padding: 8px 0 4px;
}
.sidebar-section + .sidebar-section {
    border-top: 1px solid var(--border-faint);
}

.sidebar-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 2px 12px 4px;
}
.sidebar-section-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}
.sidebar-section-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    padding: 0 2px;
    border-radius: 4px;
    transition: color 0.15s, background 0.15s;
}
.sidebar-section-btn:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

.sidebar-empty {
    padding: 6px 14px;
    font-size: 11px;
    color: var(--text-muted);
}

/* ===== PROJECT ITEMS ===== */
.project-item {
    margin: 1px 0;
}
.project-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    cursor: pointer;
    border-radius: 6px;
    font-size: 13px;
    color: var(--text-secondary);
    transition: background 0.15s, color 0.15s;
    user-select: none;
}
.project-header:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}
.project-toggle {
    font-size: 10px;
    color: var(--text-muted);
    width: 10px;
    flex-shrink: 0;
}
.project-emoji { font-size: 14px; flex-shrink: 0; }
.project-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 500;
}
.project-count {
    font-size: 10px;
    color: var(--text-muted);
    background: var(--bg-tertiary);
    border-radius: 8px;
    padding: 1px 5px;
    flex-shrink: 0;
}
.project-settings-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px 5px;
    border-radius: 4px;
    font-size: 13px;
    line-height: 1;
    flex-shrink: 0;
    opacity: 0;
    transition: opacity 0.15s, color 0.15s, background 0.15s;
}
.project-header:hover .project-settings-btn {
    opacity: 1;
}
.project-settings-btn:hover {
    color: var(--accent);
    background: var(--accent-soft);
}
.project-chats {
    padding-left: 16px;
}
.project-new-chat-btn {
    display: block;
    width: 100%;
    background: none;
    border: none;
    text-align: left;
    padding: 5px 12px;
    font-size: 12px;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 5px;
    transition: color 0.15s, background 0.15s;
}
.project-new-chat-btn:hover {
    color: var(--accent);
    background: var(--accent-soft);
}

/* ===== CONTEXT MENU ===== */
.context-menu {
    position: fixed;
    z-index: 9999;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow-2);
    padding: 4px;
    min-width: 180px;
}
.context-menu-item {
    display: block;
    width: 100%;
    background: none;
    border: none;
    text-align: left;
    padding: 7px 12px;
    font-size: 13px;
    color: var(--text-primary);
    cursor: pointer;
    border-radius: 5px;
    transition: background 0.12s;
}
.context-menu-item:hover { background: var(--bg-tertiary); }
.context-menu-item.danger { color: var(--error); }
.context-menu-item.danger:hover { background: rgba(248,113,113,0.08); }
.context-menu-sep {
    height: 1px;
    background: var(--border-faint);
    margin: 3px 0;
}
.context-menu-label {
    padding: 4px 12px;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

/* ===== PROJECT MODAL ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}
.modal-box {
    background: var(--modal-bg);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: var(--shadow-3);
    width: 360px;
    max-width: 94vw;
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 18px 12px;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-faint);
}
.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 16px;
    padding: 2px 6px;
    border-radius: 4px;
}
.modal-close:hover { color: var(--text-primary); background: var(--bg-tertiary); }
.modal-body { padding: 16px 18px; }
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 18px 16px;
    border-top: 1px solid var(--border-faint);
}

.project-emoji-row {
    display: flex;
    align-items: center;
    gap: 10px;
}
.project-emoji-btn {
    font-size: 22px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    width: 44px;
    height: 44px;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s;
}
.project-emoji-btn:hover { background: var(--bg-elevated); }
.project-name-input {
    flex: 1;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 14px;
    padding: 10px 12px;
    outline: none;
    font-family: inherit;
    transition: border-color 0.15s;
}
.project-name-input:focus { border-color: var(--accent); }

.emoji-picker {
    margin-top: 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px;
}
.emoji-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 2px;
}
.emoji-option {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    padding: 4px;
    border-radius: 5px;
    transition: background 0.1s;
}
.emoji-option:hover { background: var(--bg-elevated); }

/* ===== SETTINGS MODAL ===== */
.settings-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 8000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.settings-overlay.visible { display: flex; }

.settings-modal {
    width: 100%;
    max-width: 580px;
    max-height: calc(100vh - 40px);
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 14px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 24px 64px rgba(0,0,0,0.4);
}

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

.settings-header-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.settings-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
}
.settings-close:hover { color: var(--text-primary); background: var(--bg-tertiary); }

.settings-nav {
    display: flex;
    gap: 2px;
    padding: 8px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-tertiary);
    overflow-x: auto;
}

.settings-nav-btn {
    padding: 8px 14px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    border-radius: 6px;
    white-space: nowrap;
    transition: all 0.15s;
}
.settings-nav-btn:hover { color: var(--text-primary); background: var(--bg-secondary); }
.settings-nav-btn.active { color: var(--accent); background: var(--bg-secondary); box-shadow: 0 1px 3px rgba(0,0,0,0.15); }

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

.settings-section { display: none; }
.settings-section.active { display: block; }

.settings-section h3 {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* ===== EXPORT MENU ===== */
.export-menu {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 4px;
    min-width: 180px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.35);
    z-index: 100;
}
.export-menu.visible { display: block; }
.export-menu button {
    display: block;
    width: 100%;
    padding: 8px 12px;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 13px;
    text-align: left;
    cursor: pointer;
    border-radius: 6px;
    transition: background 0.15s;
}
.export-menu button:hover { background: var(--accent-soft); color: var(--accent); }

/* Print styles for PDF export */
@media print {
    body { background: white !important; color: #111 !important; overflow: visible !important; }
    body::before, .auth-screen, .sidebar, .chat-header, .input-section, .attachments-bar,
    .auto-login-banner, .toast, .settings-overlay, .modal-overlay, .particles-canvas,
    .drop-overlay, .compare-column { display: none !important; }
    .container, .main, .messages-wrapper, .messages-column { display: block !important; height: auto !important; overflow: visible !important; }
    .messages-container { padding: 0 !important; overflow: visible !important; }
    .message { page-break-inside: avoid; margin-bottom: 16px !important; }
    .message-content { color: #111 !important; }
    pre, code { background: #f4f4f4 !important; color: #111 !important; border: 1px solid #ddd; }
    #printHeader { display: block !important; padding: 0 0 20px; border-bottom: 1px solid #ccc; margin-bottom: 20px; }
    #printHeader h1 { font-size: 20px; margin-bottom: 6px; color: #111; }
    #printHeader .meta { font-size: 11px; color: #666; }
}
#printHeader { display: none; }

/* Sidebar footer with settings btn */
.sidebar-footer {
    padding: 10px 12px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 8px;
}

.sidebar-footer-btn {
    flex: 1;
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.15s;
}
.sidebar-footer-btn:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }

.config-group { margin-bottom: 12px; }

.config-label {
    display: block;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.5px;
    margin-bottom: 5px;
}

.config-input {
    width: 100%;
    padding: 8px 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 12px;
    font-family: 'JetBrains Mono', 'Courier New', monospace;
    transition: all 0.2s ease;
}

select.config-input {
    font-family: inherit;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23a0a6b8' d='M1 4l5 4 5-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 30px;
    cursor: pointer;
}

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

textarea.config-input {
    font-family: inherit;
    min-height: 70px;
    resize: vertical;
}

.range-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.range-row input[type="range"] {
    flex: 1;
    accent-color: var(--accent);
}

.range-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    color: var(--accent);
    min-width: 36px;
    text-align: right;
}

.btn {
    padding: 9px 12px;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn-primary {
    background: var(--accent);
    color: var(--bg-primary);
}

.btn-primary:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
}

.btn-secondary {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.btn-secondary:hover { color: var(--text-primary); border-color: var(--text-secondary); }

.btn-row { display: flex; gap: 6px; margin-top: 12px; }
.btn-row .btn { flex: 1; }

.preset-list { display: flex; flex-direction: column; gap: 4px; }

.preset-item {
    padding: 8px 10px;
    background: var(--bg-tertiary);
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid transparent;
}

.preset-item:hover { border-color: var(--accent); }
.preset-item.active { border-color: var(--accent); background: var(--accent-soft); }

.preset-item-name { font-weight: 500; color: var(--text-primary); }
.preset-item-meta { font-size: 10px; color: var(--text-muted); }

.theme-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.theme-card {
    padding: 12px 8px;
    border-radius: 8px;
    cursor: pointer;
    text-align: center;
    border: 2px solid transparent;
    transition: all 0.2s ease;
    font-size: 11px;
    font-weight: 500;
}

.theme-card.active { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.theme-card.indigo-card { background: linear-gradient(135deg, #0f1115, #1c1f25); color: #e7e8ed; }
.theme-card.indigo-card::after { content: ''; display:block; width: 16px; height: 4px; background: #7d8ee8; border-radius: 2px; margin: 6px auto 0; }
.theme-card.forest-card { background: linear-gradient(135deg, #0f1311, #1c211d); color: #e6eae6; }
.theme-card.forest-card::after { content: ''; display:block; width: 16px; height: 4px; background: #6ba37d; border-radius: 2px; margin: 6px auto 0; }
.theme-card.brass-card { background: linear-gradient(135deg, #14110d, #221e18); color: #ece6da; }
.theme-card.brass-card::after { content: ''; display:block; width: 16px; height: 4px; background: #c79850; border-radius: 2px; margin: 6px auto 0; }
.theme-card.light-card { background: linear-gradient(135deg, #f6f5f1, #eeece5); color: #18191c; }
.theme-card.light-card::after { content: ''; display:block; width: 16px; height: 4px; background: #4f5fd8; border-radius: 2px; margin: 6px auto 0; }

/* ===== FOCUS MODE ===== */
.focus-mode .sidebar { width: 0 !important; margin-left: -1px !important; }
.focus-mode-btn.active { color: var(--accent) !important; background: var(--accent-soft) !important; }

/* ===== PROFILES ===== */
.profiles-list { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }

.profile-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    background: var(--bg-tertiary);
    border-radius: 6px;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.15s;
    font-size: 12px;
}
.profile-item:hover { border-color: var(--accent); }
.profile-item.active { border-color: var(--accent); background: var(--accent-soft); }
.profile-item-dot {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--border);
    flex-shrink: 0;
}
.profile-item.active .profile-item-dot { background: var(--accent); }
.profile-item-name { flex: 1; font-weight: 500; color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-item-note { font-size: 10px; color: var(--text-muted); }
.profile-item-del { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 13px; padding: 2px 4px; }
.profile-item-del:hover { color: var(--error); }

.profile-form {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.profile-form input {
    width: 100%;
    padding: 7px 10px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 12px;
    font-family: inherit;
}
.profile-form input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.profile-form input::placeholder { color: var(--text-muted); }
.profile-form-row { display: flex; gap: 6px; }
.profile-form-row .btn { flex: 1; font-size: 11px; padding: 7px 8px; }

/* Профиль-dropdown в конфиг-панели */
.profile-select-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}
.profile-select-row select.config-input { flex: 1; }
.profile-select-row .btn { padding: 8px 10px; font-size: 11px; flex-shrink: 0; }

/* ===== COST LOG ===== */
.cost-log-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 8px;
    background: var(--bg-tertiary);
    border-radius: 5px;
    font-size: 11px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}
.cost-log-row .clr-model { color: var(--accent); font-weight: 500; }
.cost-log-row .clr-cost { color: var(--success); font-family: 'JetBrains Mono', monospace; }
.cost-log-total {
    display: flex;
    justify-content: space-between;
    padding: 8px 8px 0;
    font-size: 12px;
    color: var(--text-primary);
    font-weight: 600;
    border-top: 1px solid var(--border);
    margin-top: 6px;
}


/* ===== MAIN ===== */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: transparent;
    min-width: 0;
}

.chat-header {
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-glass);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    gap: 12px;
}

.header-left, .header-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    max-width: 400px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.icon-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 16px;
    padding: 6px 8px;
    border-radius: 6px;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    gap: 4px;
}

.icon-btn:hover { color: var(--accent); background: var(--accent-soft); }
.icon-btn.danger:hover { color: var(--error); background: rgba(248, 113, 113, 0.1); }

.icon-btn span.label { font-size: 11px; }

.compare-toggle {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 5px 10px;
    color: var(--text-secondary);
    font-size: 11px;
    cursor: pointer;
}

.compare-toggle.active {
    background: var(--accent-soft);
    color: var(--accent);
    border-color: var(--accent);
}

.header-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: var(--text-secondary);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    animation: pulse 2s ease-in-out infinite;
}

.status-dot.connected { background: var(--success); animation: none; }

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

/* ===== MESSAGES ===== */
.messages-wrapper {
    flex: 1;
    display: flex;
    overflow: hidden;
}

.messages-column {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

.messages-column + .messages-column {
    border-left: 1px solid var(--border);
}

.column-header {
    padding: 8px 16px;
    font-size: 11px;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-soft);
    background: var(--bg-tertiary);
    display: none;
}

.compare-mode .column-header { display: block; }

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    scroll-behavior: smooth;
    align-items: center;
}

/* Ограничиваем ширину контента и центрируем */
.messages-container > * {
    max-width: 768px;
    width: 100%;
    box-sizing: border-box;
}

.messages-container::-webkit-scrollbar { width: 6px; }
.messages-container::-webkit-scrollbar-track { background: transparent; }
.messages-container::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.messages-container::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    color: var(--text-secondary);
    gap: 16px;
    padding: 40px;
}

.empty-state-icon {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    background: var(--accent-soft);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    font-weight: 700;
}

.empty-state-text {
    font-size: 15px;
    text-align: center;
    max-width: 400px;
    line-height: 1.5;
}

.starter-prompts {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    max-width: 500px;
    width: 100%;
    margin-top: 8px;
}

.starter-prompt {
    padding: 12px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    font-size: 12px;
    color: var(--text-secondary);
    text-align: left;
    transition: all 0.2s ease;
}

.starter-prompt:hover {
    border-color: var(--accent);
    color: var(--text-primary);
    transform: translateY(-1px);
}

.starter-prompt-title {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
    font-size: 13px;
}

.message {
    display: flex;
    animation: slideIn 0.25s ease;
    max-width: 768px;
    width: 100%;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.message.user { flex-direction: row-reverse; }

.message-avatar { display: none; }

.message-body {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
    flex: 1;
}

.message.assistant .message-body {
    max-width: 100%;
}

.message.user .message-body {
    align-items: flex-end;
    flex: 0 1 auto;
    max-width: 62%;
}

.message-content {
    padding: 18px 22px;
    border-radius: 12px;
    word-wrap: break-word;
    font-size: 16px;
    line-height: 1.8;
    letter-spacing: 0.01em;
    overflow-wrap: break-word;
}

.message.user .message-content {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 14px 4px 14px 14px;
    white-space: pre-wrap;
    word-break: break-word;
    min-width: 0;
    width: 100%;
}

.message.assistant .message-content {
    background: transparent;
    color: var(--text-primary);
    border: none;
    border-radius: 0;
    padding: 0;
    font-size: 16px;
    line-height: 1.6;
}

.message.error .message-content {
    background: rgba(248, 113, 113, 0.08);
    color: var(--error);    border: 1px solid var(--error);
    border-radius: 8px;
}

/* ──────────────────────────────────────────────────────────────
   TOOL USE — карточки tool_use / tool_result в сообщениях
   ────────────────────────────────────────────────────────────── */
.tool-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin: 10px 0;
    overflow: hidden;
    font-size: 13px;
    transition: border-color 0.15s;
}
.tool-card:hover { border-color: var(--accent); }
.tool-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    cursor: pointer;
    user-select: none;
    background: var(--bg-tertiary);
}
.tool-card-header:hover { background: var(--bg-elevated); }
.tool-card .tool-icon { font-size: 14px; line-height: 1; }
.tool-card .tool-name {
    font-weight: 600;
    color: var(--accent);
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 12.5px;
}
.tool-card .tool-query {
    font-style: italic;
    color: var(--text-secondary);
    font-size: 12px;
    max-width: 380px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.tool-card .tool-status {
    margin-left: auto;
    font-size: 11.5px;
    opacity: 0.85;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 4px;
}
.tool-card .tool-status-done    { color: var(--success); opacity: 1; }
.tool-card .tool-status-error   { color: var(--error);   opacity: 1; }
.tool-card .tool-status-running { color: var(--accent);  opacity: 1; }
.tool-card .tool-toggle {
    transition: transform 0.2s;
    opacity: 0.4;
    font-size: 10px;
    margin-left: 2px;
}
.tool-card.expanded .tool-toggle { transform: rotate(180deg); opacity: 0.8; }
.tool-card-body {
    display: none;
    padding: 10px 12px;
    border-top: 1px solid var(--border-soft);
    background: var(--bg-primary);
    color: var(--text-primary);
}
.tool-card-body * { color: inherit; }
.tool-card-body .tool-section-label { color: var(--text-muted); }
.tool-card.expanded .tool-card-body { display: block; }
.tool-card pre.tool-input,
.tool-card pre.tool-result {
    margin: 0;
    padding: 8px 10px;
    background: var(--code-bg);
    border: 1px solid var(--code-border);
    border-radius: 4px;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 11.5px;
    line-height: 1.5;
    max-height: 320px;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-word;
    color: var(--text-primary);
}
.tool-card pre.tool-result { margin-top: 8px; border-color: var(--accent-soft); }
.tool-card .tool-section-label {
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin: 6px 0 4px;
    font-weight: 600;
}
.tool-card .tool-section-label:first-child { margin-top: 0; }
.tool-card.web-search-card .tool-name { color: var(--text-secondary); }
.tool-card .tool-round { font-size:11px; color:var(--text-muted); opacity:.85; font-family:'JetBrains Mono',monospace; margin-left:2px; }
/* Download-кнопка под tool_use карточкой */
.tool-download-row { display:flex; align-items:center; gap:8px; margin:-2px 0 10px; }
.tool-download-btn { display:inline-flex; align-items:center; gap:6px; text-decoration:none; font-size:12.5px; padding:6px 12px; }
.tool-download-btn:hover { text-decoration:none; }
.tool-limit-notice { margin-top:8px; padding-top:8px; border-top:1px dashed var(--border-soft); }
/* ═══════════ SKILL PROGRESS CARD ═══════════ */
.skill-progress-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin: 10px 0;
    overflow: hidden;
    font-size: 13px;
    transition: border-color 0.2s;
}
.skill-progress-card--done  { border-color: var(--success); }
.skill-progress-card--error { border-color: var(--error); }

.skill-progress-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: var(--bg-tertiary);
}
.skill-file-icon { font-size: 16px; line-height: 1; flex-shrink: 0; }
.skill-file-name {
    font-weight: 600;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 12.5px;
    color: var(--accent);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.skill-status-label { font-size: 12px; color: var(--text-muted); flex-shrink: 0; }
.skill-done-check   { font-size: 13px; color: var(--success); font-weight: 700; flex-shrink: 0; }
.skill-error-label  { font-size: 12px; color: var(--error); font-weight: 600; flex-shrink: 0; }

.skill-details-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 18px;
    padding: 0 2px;
    line-height: 1;
    opacity: 0.5;
    transition: opacity 0.15s;
    flex-shrink: 0;
    letter-spacing: 1px;
}
.skill-details-btn:hover { opacity: 1; }

/* Прогресс-бар */
.skill-progress-bar-wrap {
    height: 3px;
    background: var(--border-soft);
    margin: 0 14px 10px;
    border-radius: 2px;
    overflow: hidden;
}
.skill-progress-bar {
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
}
.skill-progress-bar--anim {
    width: 40%;
    animation: skill-bar-slide 1.4s ease-in-out infinite;
}
@keyframes skill-bar-slide {
    0%   { transform: translateX(-150%); }
    100% { transform: translateX(400%); }
}

/* Детали (скрыты по умолчанию) */
.skill-details-body {
    display: none;
    padding: 10px 14px;
    border-top: 1px solid var(--border-soft);
    background: var(--bg-primary);
}
.skill-progress-card.details-open .skill-details-body { display: block; }

/* ═══════════ THINKING (claude.ai style) ═══════════ */
/* Никаких карточек/рамок — просто заголовок и курсивный поток мысли */
.thinking-block {
    margin: 6px 0 12px;
    font-size: 14px;
    color: var(--text-muted);
}
.thinking-block .thinking-header {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: transparent;
    border: none;
    padding: 2px 0;
    color: var(--text-muted);
    font-size: 13.5px;
    font-weight: 500;
    cursor: pointer;
    user-select: none;
    font-family: inherit;
}
.thinking-block.working-indicator .thinking-header,
.thinking-block.streaming .thinking-header { cursor: default; }
.thinking-block .thinking-header:hover { color: var(--text-secondary); }
.thinking-block .thinking-label { letter-spacing: 0.1px; }
.thinking-block .thinking-chevron {
    display: inline-block;
    font-size: 10px;
    opacity: 0.7;
    transition: transform 0.18s ease;
}
.thinking-block.done.expanded .thinking-chevron { transform: rotate(90deg); }

/* Пульсирующая точка для активного thinking */
.thinking-block .thinking-pulse {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--text-secondary);
    opacity: 0.65;
    animation: thinking-pulse 1.4s ease-in-out infinite;
}
@keyframes thinking-pulse {
    0%, 100% { opacity: 0.25; transform: scale(0.85); }
    50%      { opacity: 0.9;  transform: scale(1.15); }
}

/* Живой поток мысли — курсив, мягкий цвет, фейд снизу как у claude.ai */
.thinking-block .thinking-stream {
    margin-top: 6px;
    padding-left: 14px;
    border-left: 2px solid var(--border-soft);
    font-style: italic;
    color: var(--text-muted);
    font-size: 13.5px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 160px;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: none;
    position: relative;
    -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 28px, #000 calc(100% - 36px), transparent 100%);
            mask-image: linear-gradient(to bottom, transparent 0, #000 28px, #000 calc(100% - 36px), transparent 100%);
}
.thinking-block .thinking-stream::-webkit-scrollbar { width: 0; height: 0; }

/* Свёрнутый thinking после завершения */
.thinking-block.done .thinking-collapsed {
    display: none;
    margin-top: 8px;
    padding-left: 14px;
    border-left: 2px solid var(--border-soft);
    font-style: italic;
    color: var(--text-muted);
    font-size: 13.5px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
}
.thinking-block.done.expanded .thinking-collapsed { display: block; }
/* crop_image pill */
.crop-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin: 4px 0 2px;
    padding: 3px 10px 3px 7px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-faint);
    user-select: none;
}
.crop-pill__icon {
    font-size: 13px;
    line-height: 1;
    opacity: 0.7;
}
.crop-pill--active {
    color: var(--accent);
    border-color: var(--accent-soft);
    background: var(--accent-soft);
    animation: crop-pill-pulse 1.6s ease-in-out infinite;
}
.crop-pill--active .crop-pill__icon { opacity: 1; }
@keyframes crop-pill-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}
/* Citations / web search */
.tool-query { font-style:italic; color:var(--text-secondary); font-size:12px; max-width:380px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
sup.cite-ref a { color:var(--accent); background:var(--accent-soft); padding:1px 4px; border-radius:3px; font-size:10px; text-decoration:none; font-weight:600; }
.citations-block { margin-top:14px; padding-top:10px; }
.citations-divider { height:1px; background:var(--border); margin-bottom:8px; }
.citations-header { font-size:11px; text-transform:uppercase; letter-spacing:.5px; color:var(--text-muted); font-weight:600; margin-bottom:6px; }
.citations-list { margin:0; padding-left:0; list-style:none; }
.cite-item { display:flex; align-items:center; gap:6px; padding:3px 0; font-size:12px; }
.cite-num { color:var(--text-muted); font-size:10px; min-width:24px; font-family:monospace; }
.cite-favicon { width:14px; height:14px; flex-shrink:0; }
.cite-link { color:var(--accent); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; max-width:300px; }
.cite-domain { color:var(--text-muted); font-size:10px; flex-shrink:0; }

/* ──────────────────────────────────────────────────────────────
   ARTIFACTS
   ────────────────────────────────────────────────────────────── */
.artifact-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 10px;
    margin: 10px 0;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}
.artifact-card:hover { border-color: var(--accent); background: var(--bg-elevated); }
.artifact-card-preview {
    width: 200px;
    height: 120px;
    overflow: hidden;
    border-radius: 6px;
    border: 1px solid var(--border-soft);
    flex-shrink: 0;
    background: var(--bg-tertiary);
    position: relative;
}
.artifact-card-preview .preview-iframe {
    width: 800px;
    height: 480px;
    transform: scale(0.25);
    transform-origin: top left;
    pointer-events: none;
    border: none;
    display: block;
}
.artifact-card-preview .preview-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    font-size: 36px;
}
.artifact-card-preview svg {
    max-width: 100%;
    max-height: 100%;
    display: block;
}
.artifact-card-info { flex: 1; min-width: 0; }
.artifact-card-name { font-size: 13px; font-weight: 500; margin-bottom: 4px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.artifact-card-meta { display:flex; align-items:center; gap:6px; font-size:11px; color:var(--text-muted); }
.lang-badge { background:var(--accent-soft); color:var(--accent); padding:1px 6px; border-radius:3px; font-family:monospace; font-size:10px; font-weight:600; }
.artifact-card-open { background:transparent; border:1px solid var(--border); color:var(--accent); border-radius:6px; padding:5px 10px; font-size:12px; cursor:pointer; flex-shrink:0; white-space:nowrap; }
.artifact-card-open:hover { background:var(--accent-soft); }

/* Правая панель артефакта */
.artifact-panel {
    position: fixed;
    top: 0; right: 0; bottom: 0;
    width: 45%;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 800;
    transform: translateX(100%);
    transition: transform 0.25s cubic-bezier(.4,0,.2,1);
    box-shadow: -4px 0 24px rgba(0,0,0,0.18);
}
.artifact-panel.open { transform: translateX(0); }
.artifact-panel-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0);
    z-index: 799;
    pointer-events: none;
    transition: background 0.25s;
}
.artifact-panel-backdrop.open { background: rgba(0,0,0,0.18); pointer-events: auto; }
.artifact-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-tertiary);
    flex-shrink: 0;
    gap: 10px;
}
.artifact-panel-title { display:flex; align-items:center; gap:6px; flex:1; min-width:0; font-size:13px; font-weight:500; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.artifact-panel-icon { font-size:16px; }
.artifact-panel-actions { display:flex; align-items:center; gap:4px; flex-shrink:0; }
.artifact-tabs { display:flex; gap:2px; background:var(--bg-elevated); padding:2px; border-radius:6px; margin-right:6px; }
.artifact-tab { padding:4px 10px; border:none; background:transparent; color:var(--text-secondary); font-size:12px; cursor:pointer; border-radius:4px; }
.artifact-tab.active { background:var(--bg-secondary); color:var(--text-primary); }
.artifact-version-switcher { display:flex; gap:2px; }
.artifact-version-btn { padding:2px 7px; border:1px solid var(--border); background:transparent; color:var(--text-muted); font-size:11px; cursor:pointer; border-radius:4px; }
.artifact-version-btn.active { background:var(--accent-soft); color:var(--accent); border-color:var(--accent); }
.artifact-panel-body { flex:1; overflow:hidden; display:flex; flex-direction:column; }
.artifact-preview { flex:1; overflow:auto; }
.artifact-preview iframe { width:100%; height:100%; border:none; display:block; }
.artifact-preview > div { padding:16px; }
.artifact-code { flex:1; overflow:auto; padding:12px; }
.artifact-code pre { margin:0; font-family:'JetBrains Mono',monospace; font-size:12px; line-height:1.6; white-space:pre-wrap; word-break:break-word; }

@media (max-width: 1200px) { .artifact-panel { width: 50%; } }
@media (max-width: 900px)  { .artifact-panel { width: 60%; } }
@media (max-width: 768px) {
    .artifact-panel {
        width: 100%;
        top: auto;
        height: 92vh;
        transform: translateY(100%);
        border-radius: 12px 12px 0 0;
        border-left: none;
        border-top: 1px solid var(--border);
    }
    .artifact-panel.open { transform: translateY(0); }
}


/* Artifact: Markdown body */
.artifact-markdown-body {
    padding: 20px 24px;
    line-height: 1.7;
    font-size: 14px;
    max-width: 720px;
    margin: 0 auto;
    overflow-y: auto;
    height: 100%;
    box-sizing: border-box;
}
.artifact-markdown-body h1,
.artifact-markdown-body h2,
.artifact-markdown-body h3 {
    margin: 1.2em 0 0.4em;
    border-bottom: 1px solid var(--border);
    padding-bottom: 4px;
    font-weight: 600;
}
.artifact-markdown-body h1 { font-size: 20px; }
.artifact-markdown-body h2 { font-size: 17px; }
.artifact-markdown-body h3 { font-size: 15px; }
.artifact-markdown-body pre { background: var(--bg-elevated); border-radius: 6px; padding: 12px; overflow-x: auto; margin: 12px 0; }
.artifact-markdown-body code { background: var(--bg-elevated); padding: 2px 5px; border-radius: 3px; font-size: 12px; font-family: 'JetBrains Mono', monospace; }
.artifact-markdown-body pre code { background: none; padding: 0; }
.artifact-markdown-body table { border-collapse: collapse; width: 100%; margin: 12px 0; }
.artifact-markdown-body th,
.artifact-markdown-body td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; }
.artifact-markdown-body th { background: var(--bg-elevated); font-weight: 600; }
.artifact-markdown-body blockquote { border-left: 3px solid var(--accent); margin: 12px 0; padding: 4px 12px; color: var(--text-muted); }
.artifact-markdown-body ul, .artifact-markdown-body ol { padding-left: 20px; margin: 8px 0; }
.artifact-markdown-body li { margin: 4px 0; }
.artifact-markdown-body p { margin: 0 0 12px; }
.artifact-markdown-body p:last-child { margin-bottom: 0; }
.artifact-markdown-body a { color: var(--accent); text-decoration: none; }
.artifact-markdown-body a:hover { text-decoration: underline; }

/* Artifact: File info card (docx/xlsx/pptx) */
/* ── File preview with iframe (docx/xlsx/pptx) ── */
.file-preview-wrap {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}
.file-preview-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    min-height: 44px;
}
.fpt-icon { font-size: 18px; flex-shrink: 0; }
.fpt-name {
    font-size: 13px;
    font-weight: 500;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-primary);
}
.fpt-size { font-size: 11px; color: var(--text-muted); flex-shrink: 0; }
.fpt-actions { display: flex; gap: 8px; flex-shrink: 0; }
.fpt-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 12px;
    background: var(--accent);
    color: #fff;
    border-radius: 5px;
    text-decoration: none;
    font-size: 12px;
    font-weight: 500;
    transition: opacity 0.15s;
    white-space: nowrap;
}
.fpt-btn:hover { opacity: 0.85; }
.fpt-expired { font-size: 12px; color: var(--error, #e55); }
.file-preview-iframe {
    flex: 1;
    border: none;
    width: 100%;
    min-height: 0;
    background: #fff;
}
.file-preview-expired {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 14px;
    padding: 32px;
    text-align: center;
}

.artifact-file-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 32px 24px;
    gap: 16px;
    box-sizing: border-box;
    text-align: center;
}
.afi-icon-big { font-size: 64px; line-height: 1; }
.afi-icon { font-size: 32px; flex-shrink: 0; }
.afi-name { font-size: 16px; font-weight: 600; word-break: break-all; max-width: 320px; }
.afi-meta { font-size: 13px; color: var(--text-muted); }
.afi-size { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.afi-expired { font-size: 13px; color: var(--error, #e55); }
.afi-download {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 24px;
    background: var(--accent);
    color: #fff;
    border-radius: 8px;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: opacity 0.15s;
    margin-top: 8px;
}
.afi-download:hover { opacity: 0.85; }
.afi-open-new {
    font-size: 13px;
    color: var(--text-muted);
    text-decoration: none;
}
.afi-open-new:hover { color: var(--accent); text-decoration: underline; }

/* Markdown */
.message-content p { margin: 0 0 16px 0; }
.message-content p:last-child { margin-bottom: 0; }
.message-content h1, .message-content h2, .message-content h3 {
    margin: 28px 0 14px;
    font-weight: 600;
    line-height: 1.35;
}
.message-content h1 { font-size: 22px; }
.message-content h2 { font-size: 19px; }
.message-content h3 { font-size: 17px; }
.message-content > h1:first-child,
.message-content > h2:first-child,
.message-content > h3:first-child { margin-top: 4px; }
.message-content ul, .message-content ol {
    margin: 0 0 16px 0;
    padding-left: 26px;
}
.message-content li { margin-bottom: 10px; line-height: 1.8; }
.message-content li:last-child { margin-bottom: 0; }
.message-content li > p { margin: 0 0 8px 0; }
.message-content code:not(pre code) {
    background: var(--accent-soft);
    color: var(--accent);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'JetBrains Mono', ui-monospace, 'SF Mono', 'Courier New', monospace;
    font-size: 0.88em;
}
.message.user .message-content code:not(pre code) {
    background: rgba(0, 0, 0, 0.18);
    color: var(--accent-fg);
}
.message-content pre {
    background: var(--code-bg);
    border: 1px solid var(--code-border);
    border-radius: 8px;
    padding: 16px 18px;
    overflow-x: auto;
    margin: 18px 0;
    position: relative;
}
.message-content pre code {
    color: var(--text-primary);
    font-family: 'JetBrains Mono', ui-monospace, 'SF Mono', 'Courier New', monospace;
    font-size: 12.5px;
    line-height: 1.55;
    background: none;
    padding: 0;
}
.code-actions {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    gap: 6px;
    opacity: 0;
    transition: opacity 0.15s ease;
}
.message-content pre:hover .code-actions { opacity: 1; }
.code-lang-label {
    font-size: 10px;
    color: var(--text-muted);
    margin-bottom: 6px;
    font-family: 'JetBrains Mono', monospace;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.code-copy-btn,
.code-artifact-btn {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 4px 10px;
    font-size: 10px;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.15s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
    line-height: 1;
}
.code-copy-btn:hover,
.code-artifact-btn:hover { background: var(--bg-elevated); color: var(--text-primary); border-color: var(--accent); }
.code-copy-btn.copied { color: var(--success); border-color: var(--success); }
.code-artifact-btn { color: var(--accent); border-color: rgba(124,108,255,0.3); }
/* На мобиле всегда видны */
@media (max-width: 640px) {
    .code-actions { opacity: 1; }
}

.message-content blockquote {
    border-left: 3px solid var(--accent);
    padding: 4px 0 4px 16px;
    margin: 18px 0;
    color: var(--text-secondary);
    font-style: italic;
    line-height: 1.8;
}

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

.message-content table {
    border-collapse: collapse;
    margin: 20px 0;
    width: 100%;
    max-width: 100%;
    font-size: 14.5px;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    display: table;
}
.message-content thead { background: var(--accent-soft); }
.message-content th, .message-content td {
    border: 1px solid var(--border);
    padding: 14px 18px;
    text-align: left;
    vertical-align: top;
    line-height: 1.7;
}
.message-content th {
    background: var(--accent-soft);
    color: var(--text-primary);
    font-weight: 600;
    letter-spacing: 0.2px;
}
.message-content tbody tr:nth-child(even) td {
    background: var(--bg-tertiary);
}
.message-content tbody tr:hover td {
    background: var(--accent-soft);
}
/* Горизонтальный скролл для широких таблиц на мобиле */
@media (max-width: 640px) {
    .message-content table { display: block; overflow-x: auto; white-space: nowrap; }
}

/* Вложенные списки */
.message-content ul ul,
.message-content ul ol,
.message-content ol ul,
.message-content ol ol {
    margin: 10px 0 10px 0;
    padding-left: 24px;
}
.message-content ol { list-style: decimal; }
.message-content ul { list-style: disc; }

.message-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 10px;
    color: var(--text-muted);
    opacity: 0;
    transition: opacity 0.2s ease;
}

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

.message-tokens {
    background: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 9px;
}

.message-actions {
    display: flex;
    gap: 2px;
}

.message-action {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px 5px;
    font-size: 11px;
    border-radius: 3px;
    transition: all 0.15s ease;
}

.message-action:hover { color: var(--accent); background: var(--bg-tertiary); }

.typing-indicator {
    display: inline-flex;
    gap: 4px;
    align-items: center;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 4px 14px 14px 14px;
}

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

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

@keyframes typing {
    0%, 60%, 100% { opacity: 0.3; transform: scale(0.8); }
    30% { opacity: 1; transform: scale(1); }
}

/* Attachments */
.attachments-bar {
    display: flex;
    gap: 6px;
    padding: 8px 16px;
    flex-wrap: wrap;
}

.attachment-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: var(--accent-soft);
    border: 1px solid var(--accent);
    color: var(--accent);
    border-radius: 12px;
    font-size: 11px;
    font-family: 'JetBrains Mono', monospace;
    max-width: 240px;
}

.attachment-chip .ac-icon { font-size: 13px; }
.attachment-chip .ac-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 140px;
}
.attachment-chip .ac-size { opacity: 0.7; font-size: 10px; }
.attachment-chip .ac-lang {
    font-size: 9px;
    font-family: 'JetBrains Mono', monospace;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    opacity: 0.65;
    background: var(--accent);
    color: var(--bg-primary);
    border-radius: 3px;
    padding: 1px 4px;
    flex-shrink: 0;
}
.attachment-chip.image-chip {
    padding: 4px 8px 4px 4px;
}
.attachment-chip .ac-thumb {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    object-fit: cover;
    display: block;
}

.attachment-chip button {
    background: none;
    border: none;
    color: var(--accent);
    cursor: pointer;
    font-size: 13px;
    line-height: 1;
    padding: 0;
}

/* Прикрепления внутри сообщения */
.message-attachments {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}
.message-attachment {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 12px;
    color: var(--text-secondary);
    max-width: 280px;
}
.message-attachment .ma-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.message-attachment img.ma-img {
    max-width: 200px;
    max-height: 200px;
    border-radius: 6px;
    display: block;
}
.message-attachment.image-only {
    padding: 0;
    background: none;
    border: none;
}
.message-attachment.image-attachment {
    flex-direction: column;
    align-items: stretch;
    padding: 6px;
    max-width: 260px;
}
.message-attachment.image-attachment .ma-thumb {
    max-width: 100%;
    max-height: 240px;
    border-radius: 6px;
    display: block;
    object-fit: contain;
    cursor: zoom-in;
}
.message-attachment.image-attachment .ma-info {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-top: 4px;
}

/* Drag-and-drop overlay */
.drop-overlay {
    position: fixed;
    inset: 0;
    background: rgba(99, 102, 241, 0.12);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    border: 3px dashed var(--accent);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}
.drop-overlay.visible { display: flex; }
.drop-overlay-text {
    font-size: 24px;
    font-weight: 600;
    color: var(--accent);
    background: var(--bg-secondary);
    padding: 20px 40px;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
}

/* ===== INPUT ===== */
.input-section {
    padding: 12px 20px 16px;
    background: var(--bg-glass);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.input-section > * {
    max-width: 768px;
    width: 100%;
}

.input-wrapper {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 8px;
    transition: all 0.2s ease;
}

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

.input-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.input-field {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    resize: none;
    outline: none;
    padding: 6px 8px;
    max-height: 200px;
    line-height: 1.5;
}

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

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

.input-action-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    font-size: 16px;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.input-action-btn:hover { background: var(--bg-secondary); color: var(--accent); }
.input-action-btn.active { background: var(--accent-soft); color: var(--accent); }
.input-action-btn.active:hover { background: var(--accent-soft); color: var(--accent-hover); }

/* Generated image in chat */
.generated-image-wrap { margin-top: 8px; }
.generated-image-wrap img { max-width: 100%; max-height: 512px; border-radius: 10px; border: 1px solid var(--border); display: block; cursor: pointer; transition: opacity 0.15s; }
.generated-image-wrap img:hover { opacity: 0.9; }
.generated-image-wrap .img-caption { font-size: 11px; color: var(--text-muted); margin-top: 6px; }
.img-download-btn { font-size: 11px; color: var(--accent); cursor: pointer; background: none; border: none; padding: 0; margin-left: 8px; text-decoration: underline; }

/* Web search source chips */
.search-sources { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 10px; }
.search-source-chip { font-size: 10px; padding: 2px 8px; background: var(--accent-soft); color: var(--accent); border-radius: 10px; text-decoration: none; border: 1px solid rgba(125,142,232,0.2); white-space: nowrap; overflow: hidden; max-width: 200px; text-overflow: ellipsis; }
.search-source-chip:hover { background: var(--accent); color: var(--accent-fg); }

.send-btn {
    background: var(--accent);
    color: var(--accent-fg);
    border: none;
    border-radius: 10px;
    padding: 10px 14px;
    cursor: pointer;
    font-size: 15px;
    transition: background 0.15s ease, transform 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.send-btn:hover:not(:disabled) {
    background: var(--accent-hover);
    transform: translateY(-1px);
}

.send-btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

/* ===== Remember Me row ===== */
.remember-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 2px;
}

.remember-check {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
}

.remember-check input { accent-color: var(--accent); cursor: pointer; }

.remember-select {
    padding: 6px 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 12px;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 12 12'%3E%3Cpath fill='%239da2af' d='M1 4l5 4 5-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    padding-right: 26px;
    font-family: inherit;
}

.remember-select:focus { outline: none; border-color: var(--accent); }

/* ===== Auto-login splash ===== */
.auto-login-banner {
    position: fixed;
    inset: 0;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 16px;
    z-index: 10000;
    color: var(--text-secondary);
    font-size: 14px;
}

.auto-login-spinner {
    width: 28px;
    height: 28px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ===== Streaming caret ===== */
.streaming-caret {
    display: inline-block;
    width: 7px;
    height: 1em;
    background: var(--accent);
    margin-left: 2px;
    vertical-align: text-bottom;
    animation: blink 1s steps(2) infinite;
    border-radius: 1px;
    opacity: 0.85;
}

@keyframes blink { 50% { opacity: 0.15; } }

.message.streaming .message-content {
    border-color: var(--accent-soft);
    background: linear-gradient(180deg, var(--bg-tertiary), color-mix(in srgb, var(--accent) 4%, var(--bg-tertiary)));
}

/* Stop state for send button */
.send-btn.stopping {
    background: var(--error);
    color: #fff;
}

.send-btn.stopping:hover { background: var(--error); opacity: 0.85; }

/* ===== Particles canvas ===== */
.particles-canvas {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 9998;
}

/* ===== Token meter ===== */


/* Session info block в Settings */
.session-info-block {
    font-size: 11px;
    color: var(--text-muted);
    line-height: 1.5;
    padding: 10px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-soft);
    border-radius: 6px;
}

.session-info-block strong { color: var(--text-primary); }

.input-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 6px;
    padding: 0 6px;
    font-size: 10px;
    color: var(--text-muted);
}

.input-hint kbd {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 1px 5px;
    font-family: inherit;
    font-size: 10px;
}

.session-stats {
    font-family: 'JetBrains Mono', monospace;
    display: flex;
    gap: 12px;
}

/* Статистика сессии скрыта */
#sessionStats { display: none !important; }

/* Slash commands */
.slash-menu {
    position: absolute;
    bottom: 100%;
    left: 16px;
    right: 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.3);
    margin-bottom: 8px;
    max-height: 240px;
    overflow-y: auto;
    z-index: 100;
    display: none;
}

.slash-menu.visible { display: block; }

.slash-item {
    padding: 10px 14px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-soft);
    transition: background 0.15s ease;
}

.slash-item:last-child { border-bottom: none; }
.slash-item:hover, .slash-item.selected { background: var(--accent-soft); }

.slash-cmd { font-family: 'JetBrains Mono', monospace; color: var(--accent); font-size: 12px; font-weight: 600; }
.slash-desc { font-size: 11px; color: var(--text-secondary); margin-top: 2px; }

/* ════════════════════════════════════════════════════════════════════════
   ASK USER — блок уточняющих вопросов (над полем ввода)
   ════════════════════════════════════════════════════════════════════════ */
/* ════════════════════════════════════════════════════════════════════════
   ASKU — уточняющие вопросы в стиле claude.ai
   Один вопрос за раз, навигация ‹ ›, строки-варианты на всю ширину.
   ════════════════════════════════════════════════════════════════════════ */

@keyframes askuSlideUp {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Обёртка — центрирует карточку, прижата к полю ввода */
.asku-wrap {
    max-width: 768px;
    margin: 0 auto 10px;
    padding: 0 24px;
    animation: askuSlideUp 0.18s var(--ease) both;
}

/* Карточка */
.asku-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px 16px 14px;
    box-shadow: var(--shadow-2);
}

/* ── Верхняя строка: навигация + крестик ── */
.asku-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.asku-nav {
    display: flex;
    align-items: center;
    gap: 4px;
}

.asku-nav-btn {
    width: 26px;
    height: 26px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-secondary);
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 120ms var(--ease), color 120ms var(--ease);
    padding: 0;
    font-family: inherit;
}

.asku-nav-btn:hover:not(:disabled) {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.asku-nav-btn:disabled {
    opacity: 0.3;
    cursor: default;
}

.asku-counter {
    font-size: 12px;
    color: var(--text-muted);
    min-width: 36px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.asku-close {
    width: 26px;
    height: 26px;
    border-radius: 6px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 13px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 120ms var(--ease), color 120ms var(--ease);
    padding: 0;
    font-family: inherit;
    flex-shrink: 0;
}

.asku-close:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

/* ── Текст вопроса ── */
.asku-question {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.45;
    margin-bottom: 10px;
}

/* ── Список вариантов ── */
.asku-options {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-bottom: 10px;
}

.asku-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 120ms var(--ease);
    user-select: none;
    outline: none;
}

.asku-option:hover {
    background: var(--bg-tertiary);
}

.asku-option:focus-visible {
    background: var(--bg-tertiary);
    box-shadow: 0 0 0 2px var(--accent);
}

.asku-option.selected {
    background: var(--accent-soft);
}

.asku-option.selected .asku-opt-num {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.asku-option.selected .asku-opt-text {
    color: var(--text-primary);
    font-weight: 500;
}

.asku-option.selected .asku-opt-arrow {
    color: var(--accent);
}

/* Кружок с номером */
.asku-opt-num {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 1px solid var(--border-strong);
    background: var(--bg-tertiary);
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 120ms var(--ease), color 120ms var(--ease), border-color 120ms var(--ease);
    font-variant-numeric: tabular-nums;
}

/* Текст варианта */
.asku-opt-text {
    flex: 1;
    font-size: 13.5px;
    color: var(--text-primary);
    line-height: 1.4;
}

/* Стрелка */
.asku-opt-arrow {
    font-size: 14px;
    color: var(--text-faint);
    flex-shrink: 0;
    transition: color 120ms var(--ease);
}

.asku-option:hover .asku-opt-arrow {
    color: var(--text-secondary);
}

/* ── Нижняя строка: "Something else" + Skip/Готово ── */
.asku-footer {
    border-top: 1px solid var(--border-faint);
    padding-top: 10px;
}

.asku-else-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.asku-else-input {
    flex: 1;
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--border);
    border-radius: 0;
    color: var(--text-primary);
    font-size: 13px;
    font-family: inherit;
    padding: 4px 2px;
    line-height: 1.5;
    transition: border-color 150ms var(--ease);
    outline: none;
}

.asku-else-input::placeholder {
    color: var(--text-faint);
}

.asku-else-input:focus {
    border-bottom-color: var(--accent);
}

.asku-skip-btn,
.asku-done-btn {
    padding: 4px 12px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-muted);
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    transition: background 120ms var(--ease), color 120ms var(--ease), border-color 120ms var(--ease);
}

.asku-skip-btn:hover,
.asku-done-btn:hover:not(:disabled) {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--border-strong);
}

.asku-done-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

/* ── Мобильная адаптация ── */
@media (max-width: 600px) {
    .asku-wrap {
        padding: 0 10px;
        margin-bottom: 6px;
    }

    .asku-card {
        padding: 13px 13px 12px;
        border-radius: 12px;
    }

    .asku-question {
        font-size: 13.5px;
    }

    .asku-option {
        padding: 10px 12px;
        gap: 10px;
    }

    .asku-opt-text {
        font-size: 13px;
    }
}

/* ════════════════════════════════════════════════════════════════════════
   ASK-ANSWER — визуальный пузырь с ответами пользователя на ask_user
   ════════════════════════════════════════════════════════════════════════ */

.ask-answer-block {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.ask-answer-row {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px 6px;
    line-height: 1.45;
}

.ask-answer-label {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.55);
    white-space: nowrap;
    flex-shrink: 0;
}

/* В светлой теме label темнее */
[data-theme="aurum"] .ask-answer-label {
    color: rgba(12, 15, 22, 0.45);
}

.ask-answer-value {
    font-size: 13.5px;
    font-weight: 500;
    color: inherit;
    word-break: break-word;
}

/* Разделитель между label и value — двоеточие уже в тексте, добавляем визуально */
.ask-answer-label::after {
    content: ':';
}

/* Search modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: none;
    align-items: flex-start;
    justify-content: center;
    z-index: 9000;
    padding-top: 100px;
}

.modal-overlay.visible { display: flex; }

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 14px;
    width: 90%;
    max-width: 600px;
    max-height: 70vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-search-input {
    width: 100%;
    padding: 16px 20px;
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
    font-size: 15px;
    outline: none;
}

.modal-results {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.search-result {
    padding: 10px 14px;
    border-radius: 8px;
    cursor: pointer;
    margin-bottom: 4px;
}

.search-result:hover { background: var(--bg-tertiary); }

.search-result-title { font-size: 13px; color: var(--text-primary); font-weight: 500; margin-bottom: 3px; }
.search-result-snippet { font-size: 12px; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-result-match { background: var(--accent-soft); color: var(--accent); padding: 0 3px; border-radius: 3px; font-weight: 500; }

/* Toast */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 13px;
    z-index: 10000;
    transition: transform 0.3s ease;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.toast.visible { transform: translateX(-50%) translateY(0); }
.toast.success { border-color: var(--success); }
.toast.error { border-color: var(--error); }

/* ===== MOBILE BACKDROP ===== */
.sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

/* Responsive — Tablet */
@media (max-width: 900px) {
    .sidebar { width: 260px; }
    .message.user .message-body { max-width: 72%; }
}

/* Responsive — Mobile */
@media (max-width: 640px) {
    /* Sidebar — slide-in overlay */
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        height: 100%;
        width: 86vw;
        max-width: 320px;
        z-index: 1000;
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.4);
        transform: translateX(0);
        transition: transform 0.25s ease;
    }
    .sidebar.collapsed {
        transform: translateX(-100%);
        width: 86vw;
        margin-left: 0;
    }
    .sidebar-backdrop.visible {
        opacity: 1;
        pointer-events: auto;
    }

    /* Header — компактнее */
    .chat-header {
        padding: 10px 12px;
        gap: 6px;
    }
    .header-title {
        font-size: 13px;
        max-width: none;
        flex: 1;
        min-width: 0;
    }
    .header-left, .header-right { gap: 4px; }
    .icon-btn { padding: 8px; font-size: 17px; }
    .icon-btn span.label { display: none; }
    .header-status { display: none; }
    .compare-toggle {
        padding: 6px 8px;
        font-size: 10px;
    }
    .compare-toggle .compare-label { display: none; }

    /* Compare-mode — на мобилке стек, не side-by-side */
    .messages-wrapper { flex-direction: column; }
    .messages-column + .messages-column {
        border-left: none;
        border-top: 1px solid var(--border);
    }

    /* Messages */
    .messages-container {
        padding: 16px 12px;
        gap: 16px;
    }
    .message-body { max-width: 100%; }
    /* Ассистент — без пузыря, текст прямо на фоне */
    .message.assistant .message-content {
        background: transparent;
        border: none;
        border-radius: 0;
        padding: 0;
        font-size: 15px;
        line-height: 1.75;
    }
    /* Пользователь — компактный пузырь */
    .message.user .message-content {
        font-size: 15px;
        line-height: 1.75;
        padding: 14px 16px;
    }
    .message-meta { opacity: 1; }
    .message-content pre {
        padding: 13px 14px;
        font-size: 12px;
    }
    .code-copy-btn { opacity: 1; }

    /* Empty state */
    .empty-state { padding: 24px 16px; gap: 14px; }
    .empty-state-icon { width: 48px; height: 48px; font-size: 22px; }
    .empty-state-text { font-size: 14px; }
    .starter-prompts {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    /* Input — крупнее тапается, без зума на iOS */
    .input-section { padding: 10px 12px 14px; }
    .input-field {
        font-size: 16px; /* iOS не зумит при >=16px */
        padding: 8px 6px;
    }
    .input-wrapper { border-radius: 12px; padding: 6px; }
    .send-btn { padding: 11px 14px; }
    .input-action-btn { padding: 9px; }
    .input-footer {
        font-size: 9.5px;
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
        margin-top: 4px;
    }
    .session-stats { gap: 10px; }
    .input-hint { display: none; }

    /* Slash menu — на всю ширину */
    .slash-menu {
        left: 8px;
        right: 8px;
        max-height: 200px;
    }

    /* Search modal */
    .modal-overlay { padding-top: 40px; padding-bottom: 40px; align-items: stretch; }
    .modal {
        width: 94%;
        max-height: calc(100vh - 80px);
        margin: 0 auto;
    }
    .modal-search-input { font-size: 16px; padding: 14px 16px; }

    /* Auth — поджать на маленьких экранах */
    .auth-screen { padding: 12px; align-items: center; }
    .auth-card {
        padding: 28px 22px;
        border-radius: 14px;
        max-height: calc(100vh - 24px);
        overflow-y: auto;
    }
    .auth-title { font-size: 20px; }
    .auth-input { font-size: 16px; padding: 11px 13px; }
    .auth-btn { padding: 13px; font-size: 15px; }
    .auth-skip { padding: 12px; font-size: 14px; }
    .auth-info { font-size: 11px; }

    /* Attachments */
    .attachments-bar { padding: 6px 12px; }

    /* Sidebar содержимое — поменьше на мобилке */
    .sidebar-panel { padding: 12px; }
    .config-input { font-size: 13px; padding: 10px 12px; } /* >=13 даёт лучше тап-таргет */
    .config-input:not(textarea):not(select) { font-size: 16px; } /* анти-зум iOS */
    .new-chat-btn { padding: 12px 14px; font-size: 14px; }
    .theme-grid { grid-template-columns: repeat(2, 1fr); }
    .theme-card { padding: 14px 8px; font-size: 12px; }

    /* Чат-айтемы — action-кнопки всегда видны (нет hover) */
    .chat-item-actions { display: flex; opacity: 0.6; }
    .chat-item { padding: 11px 12px; }

    /* Toast — выше клавиатуры */
    .toast { bottom: 80px; left: 12px; right: 12px; transform: translateY(150px); max-width: none; }
    .toast.visible { transform: translateY(0); }

    /* Settings modal — fullscreen на мобилке */
    .settings-overlay { padding: 0; align-items: stretch; }
    .settings-modal {
        max-width: 100%;
        max-height: 100%;
        border-radius: 0;
        border: none;
    }
    .settings-header { padding: 14px 16px; }
    .settings-header-title { font-size: 15px; }
    .settings-nav { padding: 6px 10px; gap: 1px; }
    .settings-nav-btn { padding: 7px 10px; font-size: 11px; }
    .settings-body { padding: 16px; }
    .settings-body .config-input { font-size: 16px; } /* анти-зум iOS */
    .settings-body textarea.config-input { font-size: 14px; }

    /* Model select в хедере — компактнее */
    #model {
        min-width: 100px !important;
        max-width: 130px;
        font-size: 11px !important;
        padding: 5px 22px 5px 8px !important;
    }

    /* Profile select row */
    .profile-select-row { flex-direction: column; gap: 8px; }
}

/* Очень узкие — <380px */
@media (max-width: 380px) {
    .compare-toggle { display: none; }
    .header-title { font-size: 12px; }
    .auth-card { padding: 22px 16px; }
    #model { display: none; }
}

/* Высокий DPR fix для статус-бара iOS */
@supports (padding: max(0px)) {
    .input-section {
        padding-bottom: max(16px, env(safe-area-inset-bottom));
    }
    .chat-header {
        padding-top: max(12px, env(safe-area-inset-top));
    }
}

/* ============================================================
   ============== PATH-A FIXES (premium redesign) =============
   Правки, после первого боевого деплоя.
   ============================================================ */

/* --- 1. Бренд: чтобы текст "API Лаунчер" был в одну строку ---- */
/* Структура: .sidebar-brand содержит .sidebar-brand-mark + текстовый узел */
[data-theme="aurum"] .sidebar-brand,
[data-theme="neural"] .sidebar-brand {
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -0.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
    flex: 1 1 auto;
}

/* Размер иконки бренда: компактно, premium */
[data-theme="aurum"] .sidebar-brand-mark,
[data-theme="neural"] .sidebar-brand-mark {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    color: var(--accent);
}
[data-theme="aurum"] .sidebar-brand-mark svg,
[data-theme="neural"] .sidebar-brand-mark svg {
    width: 22px;
    height: 22px;
    display: block;
}
[data-theme="neural"] .sidebar-brand-mark {
    filter: drop-shadow(0 0 12px rgba(124,108,255,0.35));
}
[data-theme="aurum"] .sidebar-brand-mark {
    filter: drop-shadow(0 2px 4px rgba(56,88,233,0.20));
}

/* sidebar-header: вертикальная компоновка, прижим влево */
[data-theme="aurum"] .sidebar-header,
[data-theme="neural"] .sidebar-header {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
}

/* userBadge — мелкий mute-текст под брендом */
[data-theme="aurum"] .sidebar-header #userBadge,
[data-theme="aurum"] .sidebar-header .user-badge {
    background: transparent !important;
    color: var(--text-muted) !important;
    font-size: 11px !important;
    font-weight: 500 !important;
    letter-spacing: 0.02em;
    padding: 0 !important;
    border-radius: 0 !important;
    align-self: flex-start;
}
[data-theme="neural"] .sidebar-header #userBadge,
[data-theme="neural"] .sidebar-header .user-badge {
    background: transparent !important;
    color: var(--text-muted) !important;
    font-size: 11px !important;
    font-weight: 500 !important;
    letter-spacing: 0.02em;
    padding: 0 !important;
    border-radius: 0 !important;
    align-self: flex-start;
}

/* --- 2. Empty-state: реальные классы из ИЗМЕНЁННОГО JS-шаблона - */
/* Glow вокруг spark-иконки — переносим из overflow:hidden контейнера */
/* messages-container имеет overflow-y:auto — glow внутри обрезается */
/* Решение: glow рисуем у самой empty-icon, position:relative + overflow:visible */

[data-theme="aurum"] .empty-state,
[data-theme="neural"] .empty-state {
    overflow: visible;
    padding: 60px 24px 80px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100%;
    gap: 14px;
    max-width: 680px;
    margin: 0 auto;
}

[data-theme="aurum"] .empty-icon,
[data-theme="neural"] .empty-icon {
    width: 56px;
    height: 56px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
    position: relative;
    overflow: visible;
    margin-bottom: 8px;
}

[data-theme="aurum"] .empty-icon svg,
[data-theme="neural"] .empty-icon svg {
    width: 40px;
    height: 40px;
    position: relative;
    z-index: 1;
}

/* Радиальный glow ПОЗАДИ иконки */
[data-theme="aurum"] .empty-icon::before,
[data-theme="neural"] .empty-icon::before {
    content: '';
    position: absolute;
    inset: -32px;
    background: radial-gradient(circle, var(--accent-glow), transparent 65%);
    pointer-events: none;
    z-index: 0;
}

[data-theme="aurum"] .empty-title,
[data-theme="neural"] .empty-title {
    font-size: 26px;
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: 1.2;
    color: var(--text-primary);
    margin: 0;
    max-width: none;
}

[data-theme="aurum"] .empty-hint,
[data-theme="neural"] .empty-hint {
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-muted);
    max-width: 440px;
    margin: 0;
}

/* --- 3. Стартеры — реальная структура .starter-prompt из JS --- */
/* JS рисует: 
   <div class="starter-prompt">
       <div class="starter-prompt-title">📝 Деловое письмо</div>
       <div>Напиши деловое письмо...</div>
   </div>
*/

[data-theme="aurum"] .starter-prompts,
[data-theme="neural"] .starter-prompts {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-top: 16px;
    max-width: 560px;
    width: 100%;
}

[data-theme="aurum"] .starter-prompt {
    background: var(--bg-glass-strong);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    padding: 14px 16px;
    cursor: pointer;
    transition: all 180ms var(--ease);
    box-shadow: var(--shadow-1), inset 0 1px 0 rgba(255,255,255,0.7);
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 4px;
    white-space: normal;
    min-width: 0;
}
[data-theme="aurum"] .starter-prompt:hover {
    background: #FFFFFF;
    border-color: var(--border-strong);
    transform: translateY(-1px);
    box-shadow: var(--shadow-2), inset 0 1px 0 rgba(255,255,255,0.8);
}
[data-theme="aurum"] .starter-prompt-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.005em;
}
[data-theme="aurum"] .starter-prompt > div:not(.starter-prompt-title) {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.45;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

[data-theme="neural"] .starter-prompt {
    background: rgba(255,255,255,0.035);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    padding: 14px 16px;
    cursor: pointer;
    transition: all 180ms var(--ease);
    box-shadow: var(--shadow-1), inset 0 1px 0 rgba(255,255,255,0.04);
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 4px;
    white-space: normal;
    min-width: 0;
}
[data-theme="neural"] .starter-prompt:hover {
    background: rgba(255,255,255,0.06);
    border-color: var(--border-strong);
    transform: translateY(-1px);
    box-shadow: var(--shadow-2), inset 0 1px 0 rgba(255,255,255,0.06);
}
[data-theme="neural"] .starter-prompt-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.005em;
}
[data-theme="neural"] .starter-prompt > div:not(.starter-prompt-title) {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.45;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* --- 4. Перекрытие базового body::before в обеих темах ---------- */
/* В базе живёт правило body::before с opacity 0.5 и accent-soft градиентом */
/* В neural нужен ярче фиолетовый подсвет сверху, в aurum — тоньше */

[data-theme="neural"] body::before {
    background:
        radial-gradient(ellipse 70% 50% at 20% -5%, rgba(124,108,255,0.18), transparent 60%),
        radial-gradient(ellipse 60% 40% at 90% 100%, rgba(80,140,255,0.08), transparent 60%) !important;
    opacity: 1 !important;
}

[data-theme="aurum"] body::before {
    background:
        radial-gradient(ellipse 60% 40% at 15% -5%, rgba(56,88,233,0.08), transparent 60%),
        radial-gradient(ellipse 50% 35% at 85% 100%, rgba(120,140,200,0.05), transparent 60%) !important;
    opacity: 1 !important;
}

/* --- 5. messages-container: разрешаем переполнение для glow --- */
[data-theme="aurum"] .empty-state .empty-icon,
[data-theme="neural"] .empty-state .empty-icon {
    isolation: isolate;
}

/* --- 6. Header селектор модели + compare-toggle — перекрытие .config-input - */
[data-theme="aurum"] .header-right select.config-input,
[data-theme="aurum"] .header-right select#model {
    padding: 7px 32px 7px 14px !important;
    border-radius: 999px !important;
    background-color: rgba(255,255,255,0.86) !important;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'><path d='M2 4l3 3 3-3' stroke='%238A92A2' stroke-width='1.4' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>") !important;
    background-repeat: no-repeat !important;
    background-position: right 12px center !important;
    border: 1px solid rgba(15,20,35,0.08) !important;
    color: var(--text-primary) !important;
    font-size: 13px !important;
    font-family: inherit !important;
    box-shadow: 0 1px 2px rgba(15,20,35,0.04), inset 0 1px 0 rgba(255,255,255,0.7) !important;
}

[data-theme="neural"] .header-right select.config-input,
[data-theme="neural"] .header-right select#model {
    padding: 7px 32px 7px 14px !important;
    border-radius: 999px !important;
    background-color: rgba(20,24,33,0.86) !important;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'><path d='M2 4l3 3 3-3' stroke='%239097A3' stroke-width='1.4' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>") !important;
    background-repeat: no-repeat !important;
    background-position: right 12px center !important;
    border: 1px solid rgba(255,255,255,0.07) !important;
    color: var(--text-primary) !important;
    font-size: 13px !important;
    font-family: inherit !important;
    box-shadow: 0 1px 2px rgba(0,0,0,0.30), inset 0 1px 0 rgba(255,255,255,0.04) !important;
}

/* compare-toggle — secondary в стиле glass pill */
[data-theme="aurum"] .compare-toggle {
    padding: 7px 14px;
    border-radius: 999px;
    background: rgba(255,255,255,0.86);
    border: 1px solid rgba(15,20,35,0.08);
    color: var(--text-primary);
    font-size: 12.5px;
    font-weight: 500;
    box-shadow: 0 1px 2px rgba(15,20,35,0.04), inset 0 1px 0 rgba(255,255,255,0.7);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
[data-theme="aurum"] .compare-toggle:hover {
    background: #FFFFFF;
    border-color: rgba(15,20,35,0.14);
}
[data-theme="neural"] .compare-toggle {
    padding: 7px 14px;
    border-radius: 999px;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.07);
    color: var(--text-primary);
    font-size: 12.5px;
    font-weight: 500;
    box-shadow: 0 1px 2px rgba(0,0,0,0.30), inset 0 1px 0 rgba(255,255,255,0.04);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
[data-theme="neural"] .compare-toggle:hover {
    background: rgba(255,255,255,0.07);
    border-color: rgba(255,255,255,0.12);
}


/* ============================================================
   ============= V3 FIXES (theme switcher, input, header) ============
   ============================================================ */

/* === 1. THEME SWITCHER PILL — общий вид === */
.theme-switcher-pill {
    display: inline-flex;
    align-items: center;
    padding: 3px;
    border-radius: 999px;
    gap: 2px;
    margin-left: 8px;
}
.theme-switcher-pill button {
    appearance: none;
    -webkit-appearance: none;
    border: none;
    background: transparent;
    padding: 5px 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
    transition: all 160ms cubic-bezier(0.2, 0.8, 0.2, 1);
    letter-spacing: -0.005em;
}

/* AURUM theme switcher */
[data-theme="aurum"] .theme-switcher-pill {
    background: rgba(15,20,35,0.04);
    border: 1px solid rgba(15,20,35,0.06);
}
[data-theme="aurum"] .theme-switcher-pill button {
    color: var(--text-muted);
}
[data-theme="aurum"] .theme-switcher-pill button:hover {
    color: var(--text-primary);
}
[data-theme="aurum"] .theme-switcher-pill button.active {
    background: #FFFFFF;
    color: var(--text-primary);
    box-shadow:
        0 1px 2px rgba(15,20,35,0.06),
        0 1px 3px rgba(15,20,35,0.04),
        inset 0 1px 0 rgba(255,255,255,0.9);
}

/* NEURAL theme switcher */
[data-theme="neural"] .theme-switcher-pill {
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.06);
}
[data-theme="neural"] .theme-switcher-pill button {
    color: var(--text-muted);
}
[data-theme="neural"] .theme-switcher-pill button:hover {
    color: var(--text-primary);
}
[data-theme="neural"] .theme-switcher-pill button.active {
    background: rgba(255,255,255,0.08);
    color: var(--text-primary);
    box-shadow:
        0 1px 2px rgba(0,0,0,0.30),
        inset 0 1px 0 rgba(255,255,255,0.06);
}


/* === 2. INPUT AREA — premium, толще, с явным стеклом === */

/* Section вокруг */
[data-theme="aurum"] .input-section {
    padding: 18px 24px 22px !important;
    background: linear-gradient(to top, var(--bg-primary) 60%, rgba(244,245,248,0)) !important;
    border-top: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}

[data-theme="neural"] .input-section {
    padding: 18px 24px 22px !important;
    background: linear-gradient(to top, var(--bg-primary) 60%, rgba(10,12,18,0)) !important;
    border-top: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}

/* Wrapper — главный объект на экране */
[data-theme="aurum"] .input-wrapper {
    max-width: 820px !important;
    margin: 0 auto !important;
    padding: 16px 18px 12px !important;
    border-radius: 20px !important;
    background: #FFFFFF !important;
    border: 1px solid rgba(15,20,35,0.10) !important;
    box-shadow:
        0 1px 2px rgba(15,20,35,0.04),
        0 10px 28px rgba(15,20,35,0.06),
        0 2px 6px rgba(15,20,35,0.04),
        inset 0 1px 0 rgba(255,255,255,0.9) !important;
    transition: all 200ms cubic-bezier(0.2, 0.8, 0.2, 1) !important;
}
[data-theme="aurum"] .input-wrapper:focus-within {
    border-color: rgba(56,88,233,0.40) !important;
    box-shadow:
        0 0 0 4px rgba(56,88,233,0.10),
        0 12px 36px rgba(56,88,233,0.12),
        0 2px 6px rgba(56,88,233,0.06),
        inset 0 1px 0 rgba(255,255,255,0.9) !important;
}

[data-theme="neural"] .input-wrapper {
    max-width: 820px !important;
    margin: 0 auto !important;
    padding: 16px 18px 12px !important;
    border-radius: 20px !important;
    background: rgba(20,24,33,0.86) !important;
    backdrop-filter: blur(20px) saturate(140%) !important;
    -webkit-backdrop-filter: blur(20px) saturate(140%) !important;
    border: 1px solid rgba(255,255,255,0.08) !important;
    box-shadow:
        0 1px 2px rgba(0,0,0,0.35),
        0 12px 36px rgba(0,0,0,0.30),
        0 2px 6px rgba(0,0,0,0.20),
        inset 0 1px 0 rgba(255,255,255,0.06) !important;
    transition: all 200ms cubic-bezier(0.2, 0.8, 0.2, 1) !important;
}
[data-theme="neural"] .input-wrapper:focus-within {
    border-color: rgba(124,108,255,0.45) !important;
    box-shadow:
        0 0 0 4px rgba(124,108,255,0.10),
        0 0 36px rgba(124,108,255,0.18),
        0 12px 36px rgba(0,0,0,0.40),
        inset 0 1px 0 rgba(255,255,255,0.08) !important;
}

/* Textarea внутри */
[data-theme="aurum"] .input-field,
[data-theme="neural"] .input-field {
    font-size: 14.5px !important;
    line-height: 1.55 !important;
    padding: 6px 8px !important;
}
[data-theme="aurum"] .input-field::placeholder { color: rgba(15,20,35,0.40) !important; }
[data-theme="neural"] .input-field::placeholder { color: rgba(255,255,255,0.30) !important; }

/* Input actions — secondary, icon-only, без фона в спокое */
[data-theme="aurum"] .input-action-btn,
[data-theme="neural"] .input-action-btn {
    width: 34px !important;
    height: 34px !important;
    padding: 0 !important;
    border-radius: 10px !important;
    background: transparent !important;
    border: none !important;
    font-size: 0 !important;
}
[data-theme="aurum"] .input-action-btn { color: rgba(15,20,35,0.50) !important; }
[data-theme="neural"] .input-action-btn { color: rgba(255,255,255,0.55) !important; }
[data-theme="aurum"] .input-action-btn:hover {
    background: rgba(15,20,35,0.05) !important;
    color: var(--text-primary) !important;
}
[data-theme="neural"] .input-action-btn:hover {
    background: rgba(255,255,255,0.06) !important;
    color: var(--text-primary) !important;
}
[data-theme="aurum"] .input-action-btn.active {
    background: var(--accent-soft) !important;
    color: var(--accent) !important;
}
[data-theme="neural"] .input-action-btn.active {
    background: rgba(124,108,255,0.16) !important;
    color: var(--accent) !important;
}
[data-theme="aurum"] .input-action-btn svg,
[data-theme="neural"] .input-action-btn svg {
    width: 18px !important;
    height: 18px !important;
}

/* SEND-кнопка — primary, фиолетовый squircle, glow при focus-within родителя */
[data-theme="aurum"] .send-btn,
[data-theme="aurum"] #sendBtn {
    width: 36px !important;
    height: 36px !important;
    margin-left: 6px !important;
    padding: 0 !important;
    border-radius: 12px !important;
    background: rgba(15,20,35,0.06) !important;
    color: rgba(15,20,35,0.40) !important;
    border: none !important;
    box-shadow: none !important;
    font-size: 0 !important;
    transition: all 180ms cubic-bezier(0.2, 0.8, 0.2, 1) !important;
}
[data-theme="aurum"] .input-wrapper:focus-within .send-btn,
[data-theme="aurum"] .input-wrapper:focus-within #sendBtn {
    background: linear-gradient(135deg, #4566EE, #6D5EF6) !important;
    color: #FFFFFF !important;
    box-shadow:
        0 0 0 1px rgba(56,88,233,0.20),
        0 4px 12px rgba(56,88,233,0.28),
        inset 0 1px 0 rgba(255,255,255,0.25) !important;
}
[data-theme="aurum"] .send-btn:hover:not(:disabled) { transform: translateY(-1px) !important; }
[data-theme="aurum"] .send-btn svg { width: 18px !important; height: 18px !important; }

[data-theme="neural"] .send-btn,
[data-theme="neural"] #sendBtn {
    width: 36px !important;
    height: 36px !important;
    margin-left: 6px !important;
    padding: 0 !important;
    border-radius: 12px !important;
    background: rgba(255,255,255,0.06) !important;
    color: rgba(255,255,255,0.30) !important;
    border: none !important;
    box-shadow: none !important;
    font-size: 0 !important;
    transition: all 180ms cubic-bezier(0.2, 0.8, 0.2, 1) !important;
}
[data-theme="neural"] .input-wrapper:focus-within .send-btn,
[data-theme="neural"] .input-wrapper:focus-within #sendBtn {
    background: linear-gradient(135deg, #8E80FF, #6450F0) !important;
    color: #FFFFFF !important;
    box-shadow:
        0 0 0 1px rgba(124,108,255,0.30),
        0 4px 14px rgba(124,108,255,0.30),
        0 0 22px rgba(124,108,255,0.20),
        inset 0 1px 0 rgba(255,255,255,0.20) !important;
}
[data-theme="neural"] .send-btn:hover:not(:disabled) { transform: translateY(-1px) !important; }
[data-theme="neural"] .send-btn svg { width: 18px !important; height: 18px !important; }


/* === 3. HEADER ICON BUTTONS — единый кластер, явные 32×32 bbox === */

[data-theme="aurum"] .header-right .icon-btn,
[data-theme="aurum"] .chat-header #searchBtn,
[data-theme="aurum"] .chat-header #exportChatBtn,
[data-theme="aurum"] .chat-header #openSettingsBtn2 {
    width: 34px !important;
    height: 34px !important;
    padding: 0 !important;
    border-radius: 10px !important;
    background: transparent !important;
    border: 1px solid transparent !important;
    color: rgba(15,20,35,0.55) !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 0 !important;
    transition: all 160ms cubic-bezier(0.2, 0.8, 0.2, 1) !important;
}
[data-theme="aurum"] .header-right .icon-btn:hover,
[data-theme="aurum"] .chat-header #searchBtn:hover,
[data-theme="aurum"] .chat-header #exportChatBtn:hover,
[data-theme="aurum"] .chat-header #openSettingsBtn2:hover {
    background: rgba(15,20,35,0.05) !important;
    color: var(--text-primary) !important;
    border-color: rgba(15,20,35,0.08) !important;
}
[data-theme="aurum"] .header-right .icon-btn svg,
[data-theme="aurum"] .chat-header .icon-btn svg {
    width: 16px !important;
    height: 16px !important;
}

[data-theme="neural"] .header-right .icon-btn,
[data-theme="neural"] .chat-header #searchBtn,
[data-theme="neural"] .chat-header #exportChatBtn,
[data-theme="neural"] .chat-header #openSettingsBtn2 {
    width: 34px !important;
    height: 34px !important;
    padding: 0 !important;
    border-radius: 10px !important;
    background: transparent !important;
    border: 1px solid transparent !important;
    color: rgba(255,255,255,0.55) !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 0 !important;
    transition: all 160ms cubic-bezier(0.2, 0.8, 0.2, 1) !important;
}
[data-theme="neural"] .header-right .icon-btn:hover,
[data-theme="neural"] .chat-header #searchBtn:hover,
[data-theme="neural"] .chat-header #exportChatBtn:hover,
[data-theme="neural"] .chat-header #openSettingsBtn2:hover {
    background: rgba(255,255,255,0.06) !important;
    color: var(--text-primary) !important;
    border-color: rgba(255,255,255,0.08) !important;
}
[data-theme="neural"] .header-right .icon-btn svg,
[data-theme="neural"] .chat-header .icon-btn svg {
    width: 16px !important;
    height: 16px !important;
}

/* Гэп между утилитарными кнопками */
[data-theme="aurum"] .header-right,
[data-theme="neural"] .header-right {
    gap: 6px !important;
}

/* Header-status — без border-left, через gap */
[data-theme="aurum"] .header-status,
[data-theme="neural"] .header-status {
    padding-left: 8px !important;
    border-left: none !important;
    margin-left: 4px !important;
    gap: 6px !important;
    display: inline-flex !important;
    align-items: center !important;
}
[data-theme="aurum"] #statusText,
[data-theme="neural"] #statusText {
    font-size: 12px;
    color: var(--text-muted);
    letter-spacing: -0.005em;
}


/* [data-theme="aurum"] .message.assistant .message-content — убрано, перекрыто базовым правилом выше */

[data-theme="aurum"] .model-selector {
    background-color: #FFFFFF !important;
    color: #0C0F16 !important;
    border-color: rgba(15,20,35,0.14) !important;
}

/* ── Custom Model Dropdown ── */
.model-dropdown { position: relative; display: inline-block; }

.model-dropdown-btn {
    display: flex; align-items: center; gap: 8px;
    padding: 7px 14px; border-radius: 999px;
    background: var(--bg-secondary); border: 1px solid var(--border);
    color: var(--text-primary); font-size: 13px; font-weight: 500;
    cursor: pointer; font-family: inherit; white-space: nowrap;
    transition: all 160ms; box-shadow: var(--shadow-1);
}
.model-dropdown-btn:hover { border-color: var(--border-strong); box-shadow: var(--shadow-2); }

.model-dropdown-menu {
    display: none; position: fixed; top: 0; left: 0;
    min-width: 220px; background: var(--bg-secondary);
    border: 1px solid var(--border); border-radius: 12px;
    box-shadow: var(--shadow-3); z-index: 99999;
    padding: 6px; overflow: hidden;
    max-height: 80vh; overflow-y: auto;
}
.model-dropdown-menu.open { display: block; }

.model-dropdown-group {
    font-size: 10px; font-weight: 600; text-transform: uppercase;
    letter-spacing: 0.08em; color: var(--text-faint);
    padding: 8px 10px 4px;
}

.model-dropdown-item {
    padding: 8px 12px; border-radius: 8px; font-size: 13px;
    color: var(--text-primary); cursor: pointer; transition: background 100ms;
}
.model-dropdown-item:hover { background: var(--accent-soft); color: var(--accent); }
.model-dropdown-item.active { background: var(--accent-soft-2); color: var(--accent); font-weight: 500; }

[data-theme="aurum"] .model-dropdown-btn {
    background: #FFFFFF !important; border-color: rgba(15,20,35,0.14) !important;
    color: #0C0F16 !important;
}
[data-theme="aurum"] .model-dropdown-menu {
    background: #FFFFFF !important; border-color: rgba(15,20,35,0.10) !important;
}

/* ── Mobile: Model Dropdown ── */
@media (max-width: 640px) {
    .model-dropdown-btn {
        padding: 5px 10px;
        font-size: 12px;
        max-width: 140px;
    }
    .model-dropdown-btn span { 
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        max-width: 100px;
    }
    .header-right { gap: 2px; }
    .compare-toggle { display: none; }
}

@media (max-width: 380px) {
    .model-dropdown-btn span { max-width: 70px; }
}

/* ── Mobile: скрываем лишнее из хедера ── */
@media (max-width: 640px) {
    #searchBtn { display: none; }
    #compareToggle { display: none; }
    .header-status { display: none; }
    #openSettingsBtn { display: none; }
    .export-wrap { display: none; }
    .Neural, .Aurum { display: none; }
}

/* ── Mobile: хедер — только сэндвич, модель, тема, экспорт ── */
@media (max-width: 640px) {
    #searchBtn { display: none !important; }
    #compareToggle { display: none !important; }
    .header-status { display: none !important; }
    #openSettingsBtn { display: none !important; }
    .export-wrap { display: none !important; }
}

/* ── Mobile: хедер финальный фикс ── */
@media (max-width: 640px) {
    #searchBtn { display: none !important; }
    #compareToggle { display: none !important; }
    #openSettingsBtn2 { display: none !important; }
    .header-status { display: none !important; }
    .export-wrap { display: none !important; }
}

/* ── Mobile 768: скрываем лишнее ── */
@media (max-width: 768px) {
    #searchBtn { display: none !important; }
    #compareToggle { display: none !important; }
    #openSettingsBtn2 { display: none !important; }
    .header-status { display: none !important; }
    .export-wrap { display: none !important; }
}

/* ── Load more messages ── */
.load-more-btn {
    text-align: center;
    padding: 10px 20px;
    margin: 8px auto;
    display: block;
    width: fit-content;
    border-radius: 20px;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 13px;
    cursor: pointer;
    transition: background 150ms;
}
.load-more-btn:hover { background: var(--accent-soft-2); }

/* ============================================================
   MOBILE TAB BAR + MOBILE UX IMPROVEMENTS (v20260528a)
   ============================================================ */

/* ── Tab Bar — скрыт на десктопе ── */
.mobile-tab-bar { display: none; }

@media (max-width: 640px) {

    /* ── Tab Bar ── */
    .mobile-tab-bar {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 900;
        background: var(--bg-glass);
        backdrop-filter: blur(20px) saturate(140%);
        -webkit-backdrop-filter: blur(20px) saturate(140%);
        border-top: 1px solid var(--border-faint, var(--border));
        padding-bottom: env(safe-area-inset-bottom);
        box-shadow: 0 -1px 0 var(--border-faint, var(--border));
    }

    .tab-btn {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        padding: 10px 4px 8px;
        background: none;
        border: none;
        color: var(--text-muted);
        font-size: 10px;
        font-weight: 500;
        font-family: inherit;
        cursor: pointer;
        transition: color 160ms ease;
        -webkit-tap-highlight-color: transparent;
        min-height: 52px;
    }

    .tab-btn svg {
        width: 22px;
        height: 22px;
        transition: transform 160ms ease;
    }

    .tab-btn.active {
        color: var(--accent);
    }

    .tab-btn.active svg {
        transform: scale(1.08);
    }

    .tab-btn:active svg {
        transform: scale(0.92);
    }

    /* Neural theme tab bar */
    [data-theme="neural"] .mobile-tab-bar {
        background: rgba(13,17,24,0.88);
        border-top-color: rgba(255,255,255,0.06);
    }

    /* Aurum theme tab bar */
    [data-theme="aurum"] .mobile-tab-bar {
        background: rgba(255,255,255,0.88);
        border-top-color: rgba(15,20,35,0.08);
    }

    /* ── Отступ снизу для контента — выше tab bar ── */
    .main {
        padding-bottom: calc(52px + env(safe-area-inset-bottom));
    }

    /* Input section — выше tab bar */
    .input-section {
        padding-bottom: calc(10px + env(safe-area-inset-bottom)) !important;
    }

    /* ── Хедер — только сэндвич + заголовок + модель ── */
    /* Убираем всё лишнее (уже скрыто выше, но дублируем для надёжности) */
    #searchBtn,
    #compareToggle,
    #openSettingsBtn2,
    .header-status,
    .export-wrap,
    .theme-switcher-pill {
        display: none !important;
    }

    /* Хедер — компактный, без лишних gap */
    /* !important нужен чтобы перекрыть @supports (padding: max(0px)) блок выше */
    .chat-header {
        padding: 0 12px !important;
        height: 52px !important;
        gap: 8px !important;
    }

    .header-left {
        gap: 8px;
        flex: 1;
        min-width: 0;
    }

    .header-right {
        gap: 4px !important;
        flex-shrink: 0;
    }

    /* Заголовок чата — занимает всё свободное место */
    .header-title {
        flex: 1;
        min-width: 0;
        font-size: 14px;
        font-weight: 600;
    }

    /* Кнопка меню — крупный tap target */
    #toggleSidebar {
        width: 40px !important;
        height: 40px !important;
        padding: 0 !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        flex-shrink: 0;
    }

    /* ── Поле ввода — удобнее ── */
    .input-section {
        padding: 8px 12px 10px !important;
    }

    .input-wrapper {
        border-radius: 16px !important;
        padding: 10px 12px 8px !important;
    }

    .input-field {
        font-size: 16px !important; /* iOS не зумит при >=16px */
        line-height: 1.5 !important;
        padding: 4px 4px !important;
        min-height: 24px;
    }

    /* Кнопки действий — 44px tap target (Apple HIG) */
    .input-action-btn {
        width: 40px !important;
        height: 40px !important;
        padding: 0 !important;
        border-radius: 12px !important;
    }

    .input-action-btn svg {
        width: 20px !important;
        height: 20px !important;
    }

    /* Кнопка отправки — крупнее */
    .send-btn,
    #sendBtn {
        width: 40px !important;
        height: 40px !important;
        border-radius: 12px !important;
        padding: 0 !important;
    }

    #sendBtn svg,
    .send-btn svg {
        width: 18px !important;
        height: 18px !important;
    }

    .message {
        gap: 0;
    }

    .message-body {
        max-width: 100%;
    }

    .message.user .message-body {
        align-items: flex-end;
        max-width: 88%;
        margin-left: auto;
    }

    /* Ассистент — без пузыря, текст прямо на фоне */
    .message.assistant .message-content {
        background: transparent !important;
        border: none !important;
        border-radius: 0 !important;
        padding: 0 !important;
        font-size: 15px !important;
        line-height: 1.7 !important;
    }
    /* Пользователь — компактный пузырь */
    .message.user .message-content {
        font-size: 15px !important;
        line-height: 1.7 !important;
        padding: 12px 14px !important;
    }

    /* ── Empty state — компактнее ── */
    [data-theme="aurum"] .empty-state,
    [data-theme="neural"] .empty-state {
        padding: 32px 16px 24px !important;
    }

    [data-theme="aurum"] .empty-title,
    [data-theme="neural"] .empty-title {
        font-size: 20px !important;
        white-space: normal !important;
        text-align: center;
    }

    [data-theme="aurum"] .starter-prompts,
    [data-theme="neural"] .starter-prompts {
        grid-template-columns: 1fr !important;
        max-width: 100% !important;
    }

    /* ── Toast — выше tab bar ── */
    .toast {
        bottom: calc(60px + env(safe-area-inset-bottom)) !important;
    }

    /* ── Сайдбар — учитываем tab bar ── */
    .sidebar {
        padding-bottom: calc(52px + env(safe-area-inset-bottom));
    }

    /* ── Проекты — кнопка настроек всегда видна на тач ── */
    .project-settings-btn {
        opacity: 1 !important;
    }

    /* ── Название чата в сайдбаре — обрезка на мобильном ── */
    .chat-item-title {
        max-width: 140px;
    }
}

/* ═══════════ ASSISTANT FILE CHIPS (вложения в теле ответа) ═══════════ */
.assistant-file-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}
.assistant-file-chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 10px;
    text-decoration: none;
    color: var(--text-primary);
    font-size: 13px;
    transition: border-color 0.15s, background 0.15s;
    max-width: 100%;
    cursor: pointer;
}
.assistant-file-chip:hover {
    border-color: var(--accent);
    background: var(--bg-secondary);
    text-decoration: none;
    color: var(--text-primary);
}
.afc-icon { font-size: 16px; flex-shrink: 0; }
.afc-name {
    font-weight: 500;
    font-family: 'JetBrains Mono', monospace;
    font-size: 12.5px;
    color: var(--accent);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 220px;
}
.afc-size {
    font-size: 11px;
    color: var(--text-muted);
    flex-shrink: 0;
}
.afc-expired {
    font-size: 10px;
    color: var(--error);
    flex-shrink: 0;
}
.assistant-file-chip--expired {
    opacity: 0.55;
}

/* ═══════════ FILE BOTTOM SHEET (мобильный iOS-стиль) ═══════════ */
.file-sheet-overlay {
    position: fixed;
    inset: 0;
    z-index: 9000;
    background: rgba(0, 0, 0, 0);
    display: flex;
    align-items: flex-end;
    transition: background 0.28s ease;
}
.file-sheet-overlay--visible {
    background: rgba(0, 0, 0, 0.45);
}
.file-sheet {
    width: 100%;
    background: var(--bg-secondary);
    border-radius: 20px 20px 0 0;
    padding: 12px 16px calc(16px + env(safe-area-inset-bottom, 0px));
    transform: translateY(100%);
    transition: transform 0.28s cubic-bezier(0.32, 0.72, 0, 1);
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.file-sheet-overlay--visible .file-sheet {
    transform: translateY(0);
}
.file-sheet-handle {
    width: 36px;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin: 0 auto 6px;
    flex-shrink: 0;
}
.file-sheet-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-align: center;
    font-family: 'JetBrains Mono', monospace;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding: 0 8px;
}
.file-sheet-actions {
    display: flex;
    gap: 10px;
}
.file-sheet-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 16px 12px;
    border: none;
    border-radius: 14px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: opacity 0.15s, transform 0.1s;
    -webkit-tap-highlight-color: transparent;
}
.file-sheet-btn:active {
    opacity: 0.7;
    transform: scale(0.97);
}
.file-sheet-btn--share {
    color: var(--accent);
}
.file-sheet-btn--share svg {
    stroke: var(--accent);
}
.file-sheet-btn--view svg {
    stroke: var(--text-primary);
}
.file-sheet-close {
    width: 100%;
    padding: 15px;
    border: none;
    border-radius: 14px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.15s;
    -webkit-tap-highlight-color: transparent;
}
.file-sheet-close:active {
    opacity: 0.7;
}

/* ===== PROJECT SETTINGS PAGE ===== */
.project-settings-page {
    flex: 1;
    overflow-y: auto;
    padding: 32px 24px 48px;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.project-settings-inner {
    width: 100%;
    max-width: 640px;
    display: flex;
    flex-direction: column;
    gap: 28px;
}
.ps-header-row {
    display: flex;
    align-items: center;
    gap: 14px;
}
.ps-emoji-btn {
    font-size: 28px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px 12px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    flex-shrink: 0;
    line-height: 1;
}
.ps-emoji-btn:hover {
    background: var(--bg-elevated);
    border-color: var(--border-strong);
}
.ps-name-input {
    flex: 1;
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    background: transparent;
    border: none;
    border-bottom: 2px solid var(--border);
    padding: 4px 0;
    outline: none;
    transition: border-color 0.15s;
    font-family: inherit;
}
.ps-name-input:focus {
    border-bottom-color: var(--accent);
}
.ps-name-input::placeholder {
    color: var(--text-muted);
    font-weight: 400;
}
.ps-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.ps-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.ps-knowledge-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-height: 0;
}
.ps-knowledge-empty {
    font-size: 13px;
    color: var(--text-muted);
    padding: 12px 0;
    text-align: center;
}
.ps-knowledge-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    transition: border-color 0.15s;
}
.ps-knowledge-item:hover {
    border-color: var(--border-strong);
}
.ps-knowledge-icon {
    font-size: 16px;
    flex-shrink: 0;
    color: var(--text-muted);
}
.ps-knowledge-item-name {
    flex: 1;
    font-size: 13px;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ps-knowledge-item-size {
    font-size: 11px;
    color: var(--text-muted);
    flex-shrink: 0;
}
.ps-knowledge-item-del {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 15px;
    line-height: 1;
    flex-shrink: 0;
    transition: color 0.15s, background 0.15s;
}
.ps-knowledge-item-del:hover {
    color: var(--error);
    background: rgba(248, 113, 113, 0.1);
}
.ps-knowledge-stats {
    font-size: 11px;
    color: var(--text-muted);
    padding-top: 2px;
}
.ps-knowledge-warn {
    color: var(--error);
}
.ps-footer {
    display: flex;
    justify-content: flex-end;
    padding-top: 4px;
    border-top: 1px solid var(--border-faint);
}
.ps-system-prompt {
    min-height: 120px;
    resize: vertical;
}

/* ═══════════════════════════════════════════════════════════════
   MAIL AGENT — Этап 1
   ═══════════════════════════════════════════════════════════════ */

/* sidebar badge */
.mail-sidebar-header {
    display: flex;
    align-items: center;
    padding: 8px 14px;
    gap: 6px;
    user-select: none;
    transition: background 0.15s;
    border-radius: 8px;
    margin: 0 4px;
}
.mail-sidebar-header:hover { background: var(--accent-soft); }
.mail-sidebar-header .sidebar-section-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--text-muted);
}
.mail-sidebar-header.active .sidebar-section-label { color: var(--accent); }
.mail-unread-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--accent);
    color: var(--accent-fg);
    font-size: 10px;
    font-weight: 700;
    margin-left: auto;
    line-height: 1;
}

/* ── mail page layout ──────────────────────────────────────────── */
.mail-page {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.mail-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
    height: 100%;
}

/* ── folders column ───────────────────────────────────────────── */
.mail-folders-col {
    width: 160px;
    min-width: 140px;
    flex-shrink: 0;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    background: var(--bg-secondary);
}
.mail-folders-list {
    padding: 8px 0;
    display: flex;
    flex-direction: column;
}
.mail-folder-item {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-secondary);
    transition: background .12s, color .12s;
    white-space: nowrap;
    overflow: hidden;
    user-select: none;
}
.mail-folder-item:hover  { background: var(--accent-soft); color: var(--text-primary); }
.mail-folder-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.mail-folder-icon  { font-size: 12px; flex-shrink: 0; width: 14px; text-align: center; opacity: .75; }
.mail-folder-label { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.mail-folder-unread {
    font-size: 10px;
    padding: 1px 5px;
    border-radius: 8px;
    background: var(--accent);
    color: #fff;
    min-width: 16px;
    text-align: center;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
}
.mail-folder-select { display: none; }

/* ── list column ───────────────────────────────────────────────── */
.mail-list-col {
    width: 320px;
    min-width: 260px;
    max-width: 380px;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border);
    flex-shrink: 0;
    overflow: hidden;
}
.mail-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.mail-back-btn { flex-shrink: 0; display: inline-flex; align-items: center; gap: 5px; }
.mail-back-label { font-size: 12px; }
.mail-toolbar .btn-sm {
    padding: 6px 12px;
    font-size: 12px;
    white-space: nowrap;
    flex-shrink: 0;
}
.mail-search {
    flex: 1;
    min-width: 0;
    background: var(--input-bg, var(--bg-tertiary));
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 12px;
    padding: 6px 10px;
    outline: none;
    transition: border-color 0.15s;
}
.mail-search:focus { border-color: var(--accent); }
.mail-refresh-btn { flex-shrink: 0; }
.mail-list {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
}
.mail-list-empty, .mail-list-loading {
    padding: 32px 16px;
    text-align: center;
    font-size: 13px;
    color: var(--text-muted);
}
.mail-list-error { color: var(--error); }

/* ── mail item ─────────────────────────────────────────────────── */
.mail-item {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-faint, var(--border));
    cursor: pointer;
    transition: background 0.12s;
    position: relative;
}
.mail-item:hover { background: var(--accent-soft); }
.mail-item.active {
    background: var(--accent-soft);
    border-left: 3px solid var(--accent);
    padding-left: 11px;
}
.mail-item.unread .mail-item-from,
.mail-item.unread .mail-item-subject {
    font-weight: 700;
    color: var(--text-primary);
}
.mail-item-from {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}
.mail-item-subject {
    font-size: 13px;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 3px;
}
.mail-item-meta {
    display: flex;
    align-items: baseline;
    gap: 8px;
}
.mail-item-preview {
    font-size: 11px;
    color: var(--text-muted);
    flex: 1;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}
.mail-item-date {
    font-size: 10px;
    color: var(--text-faint, var(--text-muted));
    flex-shrink: 0;
}

/* ── pagination ────────────────────────────────────────────────── */
.mail-pagination { padding: 8px 12px; border-top: 1px solid var(--border); flex-shrink: 0; }
.mail-pager { display: flex; align-items: center; gap: 10px; justify-content: center; }
.mail-pager-btn {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 13px;
    padding: 4px 10px;
    cursor: pointer;
    transition: background 0.12s;
}
.mail-pager-btn:hover { background: var(--accent-soft); }
.mail-pager-info { font-size: 12px; color: var(--text-muted); }

/* ── view column ───────────────────────────────────────────────── */
.mail-view-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}
.mail-view-empty {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: var(--text-muted);
}
.mail-view-msg {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}
.mail-view-header {
    padding: 18px 20px 12px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.mail-view-subject {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
    word-break: break-word;
}
.mail-view-from, .mail-view-date {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 2px;
}
.mail-header-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 2px;
}
.mail-header-field {
    display: flex;
    align-items: baseline;
    gap: 5px;
    font-size: 12px;
    margin-bottom: 2px;
    min-width: 0;
    overflow: hidden;
}
.mail-header-label {
    color: var(--text-muted);
    flex-shrink: 0;
    font-size: 11px;
    min-width: 38px;
}
.mail-header-value {
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}
.mail-header-date {
    color: var(--text-muted);
    font-size: 11px;
    flex-shrink: 0;
    white-space: nowrap;
}
.mail-attachments {
    padding: 7px 20px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    flex-shrink: 0;
}
.mail-attach-item {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: var(--text-secondary);
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 3px 9px;
    max-width: 240px;
    overflow: hidden;
    cursor: pointer;
    transition: background .15s, border-color .15s;
    user-select: none;
}
.mail-attach-item:hover {
    background: var(--bg-secondary);
    border-color: var(--accent);
    color: var(--text-primary);
}
.mail-attach-item[data-loading] {
    opacity: .65;
    cursor: wait;
}
.mail-attach-icon { flex-shrink: 0; opacity: .55; }
.mail-attach-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}
.mail-attach-size {
    color: var(--text-muted);
    font-size: 11px;
    flex-shrink: 0;
}
#mailSignatureBlock {
    position: relative;
    border-top: 1px dashed var(--border);
    margin-top: 8px;
    padding-top: 6px;
    max-height: 140px;
    overflow: hidden;
    pointer-events: none;
    flex-shrink: 0;
}
#mailSignatureBlock::after {
    content: '';
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 40px;
    background: linear-gradient(transparent, var(--bg-primary));
    pointer-events: none;
}
.mail-signature-label {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 4px;
    padding: 0 2px;
}
.mail-signature-iframe {
    width: 100%;
    min-height: 80px;
    border: none;
    display: block;
    background: transparent;
}
.mail-view-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    min-height: 0;
}
.mail-view-body iframe {
    width: 100%;
    border: none;
    min-height: 200px;
    display: block;
}
.mail-body-text {
    font-family: inherit;
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-primary);
    white-space: pre-wrap;
    word-break: break-word;
    margin: 0;
}
.mail-view-actions {
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}
.mail-loading, .mail-error {
    padding: 16px;
    font-size: 13px;
    color: var(--text-muted);
}
.mail-error { color: var(--error); }

/* ── compose ───────────────────────────────────────────────────── */
.mail-compose {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.mail-compose-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px 10px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.mail-compose-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}
.mail-compose-input {
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--border-faint, var(--border));
    color: var(--text-primary);
    font-size: 13px;
    padding: 10px 20px;
    outline: none;
    transition: border-color 0.15s;
}
.mail-compose-input:focus { border-bottom-color: var(--accent); }
.mail-compose-input::placeholder { color: var(--text-muted); }
.mail-compose-body {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 13px;
    font-family: inherit;
    line-height: 1.6;
    padding: 14px 20px;
    outline: none;
    resize: none;
    min-height: 0;
}
.mail-compose-body::placeholder { color: var(--text-muted); }
.mail-compose-footer {
    display: flex;
    gap: 10px;
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

/* ── settings: test result ─────────────────────────────────────── */
.mail-test-result {
    margin-top: 10px;
    font-size: 12px;
    padding: 8px 12px;
    border-radius: 8px;
    display: none;
}
.mail-test-result:not(:empty) { display: block; }
.mail-test-result.success { background: rgba(74,222,128,.12); color: var(--success); }
.mail-test-result.error   { background: rgba(248,113,113,.12); color: var(--error); }

/* ── mobile ────────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .mail-list-col {
        width: 100%;
        max-width: 100%;
        border-right: none;
    }
    .mail-view-col {
        display: none;
        position: absolute;
        inset: 0;
        z-index: 10;
        background: var(--bg-primary);
    }
    .mail-page.mail-show-view .mail-list-col  { display: none; }
    .mail-page.mail-show-view .mail-view-col  { display: flex; position: relative; }
    .mail-view-actions::before {
        content: '← Назад';
        cursor: pointer;
        font-size: 12px;
        color: var(--accent);
        padding: 0 4px;
    }
    .mail-back-label { display: none; }
    .mail-page.mail-show-view #mailBackBtn { display: none; }
    /* На мобайле folders-col скрыта, вместо неё select в тулбаре */
    .mail-folders-col { display: none; }
    .mail-folder-select {
        display: block;
        flex: 1;
        min-width: 0;
        background: var(--bg-secondary);
        border: 1px solid var(--border);
        border-radius: 8px;
        color: var(--text-primary);
        font-size: 13px;
        padding: 5px 8px;
        cursor: pointer;
    }
}

/* ── Mail AI: triage badge ─────────────────────────────────────── */
.mail-triage-badge {
    display: inline-block;
    margin-top: 6px;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 500;
    background: var(--bg-secondary);
    color: var(--text-muted);
    cursor: default;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.mail-triage-badge.loading { opacity: .6; }
.mail-triage-badge.zone-in  { background: rgba(74,222,128,.15); color: var(--success); }
.mail-triage-badge.zone-out { background: rgba(248,113,113,.12); color: var(--error); }
.mail-triage-badge.zone-unknown { background: var(--bg-secondary); color: var(--text-muted); }

/* ── Mail AI: summary callout ──────────────────────────────────── */
.mail-summary-callout {
    margin: 8px 16px 0;
    padding: 10px 14px;
    border-left: 3px solid var(--accent);
    background: var(--accent-soft);
    border-radius: 0 8px 8px 0;
    font-size: 13px;
    line-height: 1.55;
    color: var(--text-primary);
    white-space: pre-wrap;
    flex-shrink: 0;
}

/* ── Mail contact card ─────────────────────────────────────────── */
.mail-contact-card {
    margin: 8px 16px 0;
    padding: 10px 14px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 12px;
    flex-shrink: 0;
}
.mail-contact-loading { color: var(--text-muted); font-size: 12px; }
.mail-contact-name    { font-weight: 600; font-size: 13px; color: var(--text-primary); }
.mail-contact-company { color: var(--text-muted); margin-top: 1px; }
.mail-contact-meta    { color: var(--text-muted); margin-top: 4px; }
.mail-contact-deals   { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.mail-contact-deal-chip {
    padding: 2px 8px;
    border-radius: 10px;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 11px;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── Deal link modal ───────────────────────────────────────────── */
.mail-deal-modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    border-radius: inherit;
}
.mail-deal-modal {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    width: min(380px, 90%);
    display: flex;
    flex-direction: column;
    gap: 10px;
    box-shadow: 0 8px 32px rgba(0,0,0,.25);
}
.mail-deal-modal-title {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
}
.mail-deal-modal-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 280px;
    overflow-y: auto;
}
.mail-deal-modal-item {
    text-align: left;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 13px;
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background .15s;
}
.mail-deal-modal-item:hover { background: var(--accent-soft); border-color: var(--accent); }
.mail-deal-kind {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 6px;
    background: var(--accent-soft);
    color: var(--accent);
    flex-shrink: 0;
}
.mail-deal-modal-footer {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    padding-top: 4px;
}

/* ===== AI mail blast preview ===== */
#mailBlastPreview.mail-blast-card {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    margin: 12px auto;
    max-width: 720px;
    box-sizing: border-box;
}
.mail-blast-card .mbp-title {
    font-weight: 600;
    margin-bottom: 12px;
    font-size: 1.05em;
}
.mail-blast-card .mbp-recipients {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 14px;
    margin-bottom: 12px;
}
.mail-blast-card .mbp-rec,
.mail-blast-card .mbp-file {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 0.92em;
}
.mail-blast-card .mbp-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 12px;
}
.mail-blast-card .mbp-field > label {
    font-size: 0.82em;
    color: var(--text-secondary);
}
.mail-blast-card .mbp-field input[type="text"],
.mail-blast-card .mbp-field textarea {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 7px 9px;
    color: var(--text-primary);
    font: inherit;
    resize: vertical;
}
.mail-blast-card .mbp-files {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 12px;
}
.mail-blast-card .mbp-size {
    color: var(--text-muted);
    font-size: 0.85em;
}
.mail-blast-card .mbp-warn {
    color: var(--warning);
    margin-bottom: 12px;
    font-size: 0.92em;
}
.mail-blast-card .mbp-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}
.mail-blast-card .mbp-actions button {
    padding: 7px 14px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--bg-primary);
    color: var(--text-primary);
    font: inherit;
    cursor: pointer;
}
.mail-blast-card .mbp-actions button:hover {
    background: var(--bg-tertiary);
}
.mail-blast-card .mbp-actions .mbp-send {
    background: var(--accent);
    color: var(--accent-fg);
    border-color: transparent;
}
.mail-blast-card .mbp-actions .mbp-send:hover {
    background: var(--accent-hover);
}
.mail-blast-card .mbp-spinner {
    color: var(--text-secondary);
    font-size: 0.92em;
}
.mail-blast-card .mbp-result {
    margin-top: 4px;
    line-height: 1.4;
}
.mail-blast-card .mbp-result.mbp-err {
    color: var(--error);
}
