/* suite/static/css/chat.css */

:root {
    --bg-page: #0a0a0a;
    --dot-color: #4a4a4d;
    --text-primary: #f4f5f7;
    --nav-bg: #2c2c2e;
    --radius-large: 24px;
    --transition-theme: 0.3s ease;
    --glow-pink: #e100ff;
    --glow-blue: #00d0ff;
    --glow-purple: #ffffff;
    --status-green: #84cc16;
    --sidebar-width: 280px;
    --sidebar-bg: rgba(20, 20, 22, 0.7);
    --sidebar-border: rgba(255, 255, 255, 0.06);
    --sidebar-text: #c8c8d0;
    --accent-purple: #8b5cf6;
}

body.light-mode {
    --bg-page: #f4f5f7;
    --dot-color: #c0c4ce;
    --text-primary: #000000;
    --nav-bg: #e6e8ea;
    --sidebar-bg: rgba(230, 232, 234, 0.7);
    --sidebar-border: rgba(0, 0, 0, 0.06);
    --sidebar-text: #1a1a1e;
    --accent-purple: #6d28d9;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-page);
    color: var(--text-primary);
    position: relative;
    display: flex;
    height: 100vh;
    padding: 0;
    overflow: hidden;
    transition: background-color 0.3s, color 0.3s;
}

/* ===== DOTS ===== */
#dot-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 0;
}

.dot {
    position: absolute;
    width: 2px;
    height: 2px;
    background-color: var(--dot-color);
    border-radius: 50%;
    transition: background-color var(--transition-theme), transform 1.5s cubic-bezier(0.22, 0.61, 0.36, 1);
    will-change: transform;
}

/* ===== SIDEBAR ===== */
.sidebar {
    position: fixed;
    left: 20px;
    top: 20px;
    bottom: 20px;
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--sidebar-border);
    border-radius: 28px;
    z-index: 200;
    display: flex;
    flex-direction: column;
    padding: 24px 20px;
    transition: transform 0.35s cubic-bezier(0.22, 0.61, 0.36, 1), background 0.3s, border-color 0.3s, opacity 0.3s;
    transform: translateX(0);
    opacity: 1;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: transparent transparent;
    box-shadow: 0 25px 60px rgba(0,0,0,0.4);
}

.sidebar.hidden {
    transform: translateX(calc(-100% - 40px));
    opacity: 0;
    pointer-events: none;
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: transparent; }

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 28px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--sidebar-border);
}

.logo-text {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: var(--text-primary);
}

.sidebar-toggle-btn {
    background: transparent;
    border: none;
    color: var(--sidebar-text);
    font-size: 22px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 8px;
    transition: 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.sidebar-toggle-btn:hover {
    background: rgba(255,255,255,0.05);
}
body.light-mode .sidebar-toggle-btn:hover {
    background: rgba(0,0,0,0.05);
}

.sidebar-footer {
    border-top: 1px solid var(--sidebar-border);
    padding-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: auto;
}

/* ===== CUSTOM SELECT ===== */
.custom-select-wrapper {
    position: relative;
    user-select: none;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.custom-select-wrapper label {
    font-size: 12px;
    font-weight: 600;
    color: var(--sidebar-text);
    opacity: 0.7;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}
.custom-select-trigger {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-page);
    border: 1px solid var(--sidebar-border);
    border-radius: 14px;
    padding: 10px 14px;
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: 0.2s;
}
.custom-select-trigger:hover {
    border-color: rgba(255, 255, 255, 0.3);
}
.custom-select-trigger .arrow {
    transition: transform 0.3s ease;
    font-size: 12px;
}
.custom-select-trigger.open .arrow {
    transform: rotate(180deg);
}

.custom-options {
    position: absolute;
    bottom: calc(100% + 6px);
    top: auto;
    left: 0;
    right: 0;
    background: var(--bg-page);
    border: 1px solid var(--sidebar-border);
    border-radius: 16px;
    padding: 6px;
    display: none;
    flex-direction: column;
    gap: 4px;
    z-index: 300;
    max-height: 180px;
    overflow-y: auto;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
}
.custom-options.open {
    display: flex;
}
.custom-option {
    padding: 10px 14px;
    border-radius: 10px;
    cursor: pointer;
    transition: 0.15s;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.custom-option:hover {
    background: rgba(255, 255, 255, 0.08);
}
.custom-option.selected {
    background: rgba(255, 255, 255, 0.15);
    color: #ffffff;
}
body.light-mode .custom-option.selected {
    background: rgba(0, 0, 0, 0.08);
    color: #000000;
}
.custom-option .opt-title {
    font-weight: 500;
    font-size: 14px;
}
.custom-option .opt-desc {
    font-size: 12px;
    color: var(--sidebar-text);
    opacity: 0.7;
}

.settings-btn {
    background: transparent;
    border: none;
    color: var(--sidebar-text);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: 14px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: 0.2s;
    width: 100%;
}
.settings-btn:hover {
    background: rgba(255,255,255,0.04);
}
body.light-mode .settings-btn:hover {
    background: rgba(0,0,0,0.04);
}
.settings-btn svg {
    width: 22px;
    height: 22px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex-shrink: 0;
}

/* ===== SETTINGS MODAL ===== */
.settings-modal {
    position: fixed;
    inset: 0;
    z-index: 300;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}
.settings-modal.open {
    display: flex;
}
.settings-modal-content {
    background: #141416;
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 28px;
    padding: 32px;
    max-width: 400px;
    width: 90%;
    color: #ffffff;
    box-shadow: 0 40px 80px rgba(0,0,0,0.6);
    transition: background 0.3s;
}
.settings-modal-content h2 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.settings-modal-content h2 svg {
    width: 24px;
    height: 24px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
}
.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 0;
    border-bottom: 1px solid var(--sidebar-border);
}
.settings-row:last-child {
    border-bottom: none;
}
.settings-row label {
    font-weight: 500;
    font-size: 15px;
}
.settings-row .toggle {
    width: 44px;
    height: 24px;
    background: #3a3a42;
    border-radius: 40px;
    cursor: pointer;
    transition: 0.3s;
    position: relative;
    flex-shrink: 0;
}
.settings-row .toggle.active {
    background: #ffffff;
}
.settings-row .toggle::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    background: #141416;
    border-radius: 50%;
    transition: 0.3s;
}
.settings-row .toggle.active::after {
    left: 23px;
    background: #000000;
}
body.light-mode .settings-row .toggle {
    background: #c0c4ce;
}
body.light-mode .settings-row .toggle.active {
    background: #ffffff;
}
.settings-close {
    margin-top: 20px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #ffffff;
    padding: 10px 20px;
    border-radius: 16px;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    transition: 0.2s;
}
.settings-close:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
}

/* ===== TOGGLE SIDEBAR BUTTON ===== */
.toggle-sidebar-btn {
    position: fixed;
    left: max(12px, env(safe-area-inset-left, 0px));
    top: max(12px, env(safe-area-inset-top, 0px));
    z-index: 150;
    background: var(--sidebar-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--sidebar-border);
    color: var(--text-primary);
    width: 48px;
    height: 48px;
    border-radius: 16px;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: 0.3s;
    font-size: 22px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.2);
}
.toggle-sidebar-btn:hover {
    transform: scale(1.05);
    border-color: rgba(255, 255, 255, 0.3);
}
body.light-mode .toggle-sidebar-btn {
    background: rgba(230, 232, 234, 0.7);
}

/* ===== MAIN CONTENT ===== */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    transition: margin-left 0.35s cubic-bezier(0.22, 0.61, 0.36, 1);
    padding-left: 20px;
}
.main-content.sidebar-hidden {
    margin-left: 0;
    padding-left: 0;
}

/* ===== PRICE DISPLAY (закомментирован) ===== */
.price-display {
    display: none;
}

/* ===== TOP ACTIONS ===== */
.top-actions {
    position: fixed;
    top: max(12px, env(safe-area-inset-top, 0px));
    right: max(12px, env(safe-area-inset-right, 0px));
    z-index: 100;
    display: flex;
    gap: 12px;
}
.top-btn {
    background: #1c1c1e;
    border: 1px solid #3a3a42;
    outline: none !important;
    color: #fff;
    padding: 10px 20px;
    border-radius: 30px;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.2);
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    position: relative;
    box-shadow: none;
    -webkit-tap-highlight-color: transparent;
}
.top-btn:focus,
.top-btn:active,
.top-btn:focus-visible {
    outline: none !important;
    border: 1px solid #3a3a42 !important;
}
.top-btn:hover {
    transform: scale(1.05);
    background: #1c1c1e;
    border: 1px solid rgba(180, 123, 243, 0.5);
    box-shadow: none;
}
.top-btn.home-btn:hover {
    border: 1px solid rgba(255, 255, 255, 0.3);
}
.top-btn.login-btn:hover {
    border: 1px solid rgba(255, 255, 255, 0.3);
}
body.light-mode .top-btn {
    background: #e6e8ea;
    color: #000;
    border: 1px solid #c0c4ce;
    box-shadow: none;
}
body.light-mode .top-btn:hover {
    background: #e6e8ea;
    border: 1px solid rgba(180, 123, 243, 0.5);
    box-shadow: none;
}
body.light-mode .top-btn.login-btn:hover {
    border: 1px solid rgba(132, 204, 22, 0.5);
}

/* ===== CHAT WRAPPER ===== */
.chat-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column-reverse;
    max-width: 800px;
    width: 100%;
    margin: 0 auto;
    height: 100%;
    position: relative;
    z-index: 1;
    padding-top: 60px;
    padding-bottom: 10px;
}

.chat-messages-area {
    flex: 1;
    display: flex;
    flex-direction: column-reverse;
    gap: 12px;
    padding-bottom: 120px;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
    padding-right: 8px;
    scrollbar-width: thin;
    scrollbar-color: transparent transparent;
    -webkit-mask-image: linear-gradient(to bottom, transparent 0%, black 6%, black 70%, transparent 100%);
    mask-image: linear-gradient(to bottom, transparent 0%, black 3%, black 70%, transparent 100%);
}
.chat-messages-area::-webkit-scrollbar { width: 6px; }
.chat-messages-area::-webkit-scrollbar-track { background: transparent; }
.chat-messages-area::-webkit-scrollbar-thumb {
    background: transparent;
    border-radius: 10px;
    transition: background 0.3s ease, opacity 0.4s ease;
    opacity: 0;
}
.chat-messages-area.scrolling::-webkit-scrollbar-thumb {
    background: #3a3a3c;
    opacity: 1;
}
.chat-messages-area.scrolling::-webkit-scrollbar-thumb:hover {
    background: #555;
}
.chat-messages-area.scrolling {
    scrollbar-color: #3a3a3c transparent;
}
body.light-mode .chat-messages-area.scrolling::-webkit-scrollbar-thumb {
    background: #c0c4ce;
    opacity: 1;
}
body.light-mode .chat-messages-area.scrolling::-webkit-scrollbar-thumb:hover {
    background: #a0a4ae;
}
body.light-mode .chat-messages-area.scrolling {
    scrollbar-color: #c0c4ce transparent;
}

/* ============================================================ */
/* КРАСИВАЯ РАЗМЕТКА ДЛЯ ОТВЕТОВ AI (Markdown)                 */
/* ============================================================ */

/* Общие отступы для контента внутри сообщения бота */
.msg-wrapper.bot .msg {
    padding: 20px 24px;
    line-height: 1.7;
}

/* --- Заголовки --- */
.md-h1 {
    font-size: 24px;
    font-weight: 700;
    margin: 20px 0 12px 0;
    color: #ffffff;
    letter-spacing: -0.5px;
    border-bottom: 2px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 8px;
}
.md-h2 {
    font-size: 20px;
    font-weight: 700;
    margin: 16px 0 10px 0;
    color: #f0f0f0;
}
.md-h3 {
    font-size: 17px;
    font-weight: 600;
    margin: 12px 0 8px 0;
    color: #e0e0e0;
}

body.light-mode .md-h1 { color: #111; border-bottom-color: rgba(0,0,0,0.1); }
body.light-mode .md-h2 { color: #222; }
body.light-mode .md-h3 { color: #333; }

/* --- Цитаты --- */
.md-blockquote {
    margin: 12px 0;
    padding: 12px 18px;
    border-left: 4px solid var(--accent-purple);
    background: rgba(139, 92, 246, 0.08);
    border-radius: 0 8px 8px 0;
    color: #d4d4d8;
    font-style: italic;
}
body.light-mode .md-blockquote {
    background: rgba(139, 92, 246, 0.05);
    color: #333;
}

/* --- Списки (Нумерованные и Маркированные) --- */
.md-ol, .md-ul {
    display: flex;
    align-items: flex-start;
    margin: 4px 0;
    gap: 10px;
}
.md-ol-num {
    font-weight: 600;
    color: var(--accent-purple);
    min-width: 24px;
    text-align: right;
}
.md-ul-dot {
    color: var(--accent-purple);
    font-weight: 700;
    min-width: 20px;
    text-align: center;
}
.md-ol-text, .md-ul-text {
    flex: 1;
    color: #d1d5db;
}
body.light-mode .md-ol-text, body.light-mode .md-ul-text { color: #333; }

.msg .code-block {
    background: #0d0d0f;
    border: 1px solid #2a2a31;
    border-radius: 12px;
    padding: 8px 12px 6px 12px; /* Уменьшенный отступ */
    margin: 10px 0;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 13px;
    line-height: 1.5; /* Чуть плотнее */
    color: #e0e0e0;
    position: relative;
    box-shadow: 0 2px 12px rgba(0,0,0,0.2);
    overflow-x: auto; /* Чтобы длинный код не ломал верстку */
}

.msg .code-block .code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
    padding-bottom: 4px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.msg .code-block .code-lang {
    background: #1a1a20;
    padding: 1px 8px;
    border-radius: 6px;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 10px;
    letter-spacing: 0.8px;
    color: var(--accent-purple);
    border: 1px solid rgba(139, 92, 246, 0.2);
}

.msg .code-block .copy-code-btn {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.08);
    color: #6b6b76;
    cursor: pointer;
    padding: 2px 10px;
    border-radius: 6px;
    font-size: 10px;
    font-family: 'Inter', sans-serif;
    transition: all 0.2s;
}

.msg .code-block .copy-code-btn:hover {
    background: rgba(255,255,255,0.1);
    color: #fff;
    border-color: rgba(139, 92, 246, 0.5);
}

.msg .code-block code {
    color: #e0e0e0;
    white-space: pre-wrap;
    word-break: break-word;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
}
.msg .code-block code .keyword { color: #ff79c6; }
.msg .code-block code .string { color: #f1fa8c; }
.msg .code-block code .comment { color: #6272a4; font-style: italic; }
.msg .code-block code .function { color: #50fa7b; }
.msg .code-block code .number { color: #bd93f9; }

/* Светлая тема  */
body.light-mode .msg .code-block {
    background: #f8f9fa;
    border-color: #e2e8f0;
    color: #1a202c;
    padding: 8px 12px 6px 12px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}
body.light-mode .msg .code-block .code-lang {
    background: #edf2f7;
    color: #4a5568;
    border-color: #e2e8f0;
}
body.light-mode .msg .code-block .copy-code-btn {
    background: rgba(0,0,0,0.05);
    border-color: rgba(0,0,0,0.08);
    color: #4a5568;
}
body.light-mode .msg .code-block .copy-code-btn:hover {
    background: rgba(0,0,0,0.1);
    color: #000;
}
body.light-mode .msg .code-block code {
    color: #1a202c;
}
body.light-mode .msg .code-block code .keyword { color: #d53f8c; }
body.light-mode .msg .code-block code .string { color: #d69e2e; }
body.light-mode .msg .code-block code .comment { color: #718096; }
body.light-mode .msg .code-block code .function { color: #38a169; }
body.light-mode .msg .code-block code .number { color: #6b46c1; }

/* --- Абзацы и переносы --- */
.msg p {
    margin: 8px 0;
}

/* ===== MESSAGES (базовые стили) ===== */
.msg-wrapper {
    display: flex;
    flex-direction: column;
    max-width: 85%;
    animation: fadeInMsg 0.5s cubic-bezier(0.2, 0.9, 0.3, 1.2) forwards;
    opacity: 0;
    transform: translateY(15px);
}
@keyframes fadeInMsg {
    to { opacity: 1; transform: translateY(0); }
}
.msg-wrapper.user { align-self: flex-end; }
.msg-wrapper.bot { align-self: flex-start; }

.msg {
    padding: 14px 20px;
    border-radius: 18px;
    font-size: 15px;
    line-height: 1.6;
    word-break: break-word;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.msg-wrapper.user .msg {
    background: rgba(28, 28, 30, 0.7);
    border: 1px solid rgba(46, 46, 54, 0.5);
    color: #fff;
    border-bottom-right-radius: 4px;
    backdrop-filter: blur(4px);
    padding: 12px 16px;
}
.msg-wrapper.bot .msg {
    background: rgba(42, 42, 49, 0.05);
    border: 1px solid rgba(58, 58, 60, 0.3);
    color: #fff;
    border-bottom-left-radius: 4px;
    backdrop-filter: blur(2px);
}
body.light-mode .msg-wrapper.user .msg {
    background: rgba(230, 232, 234, 0.7);
    border-color: rgba(209, 213, 219, 0.5);
    color: #000;
}
body.light-mode .msg-wrapper.bot .msg {
    background: rgba(209, 213, 219, 0.05);
    border-color: rgba(192, 196, 206, 0.3);
    color: #000;
}

/* ===== THINKING STATUS ===== */
.thinking-status-wrapper {
    align-self: flex-start;
    width: 100%;
    max-width: 100%;
    padding: 10px 16px;
    margin-bottom: 2px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: transparent;
}
.thinking-header {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
}
.thinking-label {
    font-size: 13px;
    font-weight: 500;
    color: #888;
    animation: pulseText 1.2s ease-in-out infinite;
}
body.light-mode .thinking-label { color: #666; }
@keyframes pulseText {
    0% { opacity: 0.4; }
    50% { opacity: 1; }
    100% { opacity: 0.4; }
}
.thinking-arrow {
    color: #6b6b76;
    transition: transform 0.3s ease;
    font-size: 12px;
}
.thinking-status-wrapper.expanded .thinking-arrow {
    transform: rotate(180deg);
}
.thinking-steps {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s cubic-bezier(0.2, 0.9, 0.3, 1.2), opacity 0.3s ease;
    opacity: 0;
    padding-left: 0;
}
.thinking-status-wrapper.expanded .thinking-steps {
    max-height: 150px;
    opacity: 1;
}
.thinking-step {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: #b0b0b0;
    line-height: 1.4;
}
body.light-mode .thinking-step { color: #555; }
.status-dot {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--status-green);
    flex-shrink: 0;
}
.thinking-step.hidden { display: none; }

/* ===== MSG ACTIONS ===== */
.msg-actions {
    display: flex;
    gap: 14px;
    margin-top: 6px;
    padding-left: 4px;
}
.msg-wrapper.user .msg-actions {
    justify-content: flex-end;
    padding-right: 4px;
    padding-left: 0;
}
.action-icon {
    background: transparent;
    border: none;
    color: #6b6b76;
    font-size: 16px;
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}
.action-icon svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    stroke-width: 1.5;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.action-icon:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}
body.light-mode .action-icon:hover {
    background: rgba(0, 0, 0, 0.08);
    color: #000;
}
.action-icon.active {
    color: var(--glow-purple);
}

/* ===== CHAT INPUT ===== */
.chat-input-wrapper {
    position: absolute;
    bottom: max(10px, env(safe-area-inset-bottom, 0px));
    left: 0;
    right: 0;
    z-index: 10;
    background: rgba(10, 10, 10, 0.4);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 28px;
    padding: 6px 10px 6px 6px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
    border-top: 1px solid rgba(255,255,255,0.03);
    margin: 0 20px;
    display: flex;
    align-items: center;
}
body.light-mode .chat-input-wrapper {
    background: rgba(244, 245, 247, 0.5);
    box-shadow: 0 20px 60px rgba(0,0,0,0.08);
}

.chat-input-bar {
    flex: 1;
    background: #1c1c1e;
    border-radius: 24px;
    padding: 12px 16px 12px 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1px solid #2e2e36;
    position: relative;
    transition: opacity 0.3s ease, background 0.3s ease, border-color 0.3s ease;
}
.chat-input-bar.disabled {
    opacity: 0.5;
    pointer-events: none;
}
body.light-mode .chat-input-bar {
    background: #ffffff;
    border-color: #d1d5db;
}

.chat-input-bar::before {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: 26px;
    background: linear-gradient(90deg, rgba(255,255,255,0.8), rgba(255,255,255,0.2), rgba(255, 0, 106, 0.678), rgba(255,255,255,0.8));
    background-size: 300% 100%;
    z-index: -1;
    animation: shimmerGradient 4s ease-in-out infinite, breatheGlow 2.5s ease-in-out infinite;
    filter: blur(4px);
    transition: opacity 0.5s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
@keyframes shimmerGradient {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}
@keyframes breatheGlow {
    0% { opacity: 0.15; filter: blur(4px); }
    50% { opacity: 0.6; filter: blur(10px); }
    100% { opacity: 0.15; filter: blur(4px); }
}

.chat-input-bar.loading {
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0.05));
    border-color: rgba(255, 255, 255, 0.2);
}
.chat-input-bar.loading::before {
    opacity: 0 !important;
    animation: none !important;
}
body.light-mode .chat-input-bar.loading {
    background: linear-gradient(90deg, rgba(180, 123, 243, 0.1), rgba(225, 0, 255, 0.1), rgba(0, 208, 255, 0.1));
}
.chat-input-bar.idle::before {
    opacity: 0 !important;
    animation: none !important;
}

.chat-input-bar textarea {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: #fff;
    font-size: 15px;
    font-weight: 400;
    resize: none;
    height: 24px;
    max-height: 100px;
    line-height: 1.5;
    padding: 0;
    font-family: 'Inter', sans-serif;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #3a3a3c transparent;
    caret-color: transparent;
}
.chat-input-bar textarea::-webkit-scrollbar { width: 3px; }
.chat-input-bar textarea::-webkit-scrollbar-track { background: transparent; }
.chat-input-bar textarea::-webkit-scrollbar-thumb {
    background: #3a3a3c;
    border-radius: 10px;
}
body.light-mode .chat-input-bar textarea {
    color: #000;
}
body.light-mode .chat-input-bar textarea::-webkit-scrollbar-thumb {
    background: #c0c4ce;
}

.typing-placeholder {
    position: absolute;
    left: 18px;
    top: 50%;
    transform: translateY(-50%);
    color: #6b6b76;
    font-size: 15px;
    pointer-events: none;
    white-space: nowrap;
    overflow: hidden;
    border-right: 2px solid #6b6b76;
    animation: blink-caret 0.75s step-end infinite;
    font-weight: 400;
    transition: opacity 0.3s ease;
}
.typing-placeholder.hidden { opacity: 0; }
@keyframes blink-caret {
    50% { border-color: transparent; }
}

.btn-send {
    background: #ffffff;
    border: none;
    border-radius: 50%;
    width: 38px;
    height: 38px;
    color: #000;
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.2);
    flex-shrink: 0;
    box-shadow: 0 0 0 0 rgba(255,255,255,0);
    position: relative;
    margin-left: 20px;
}
.btn-send:hover:not(.loading) {
    transform: scale(1.1);
    box-shadow: 0 0 15px rgba(255,255,255,0.4);
}
.btn-send:hover.loading { transform: scale(1.05); }
body.light-mode .btn-send {
    background: #1c1c1e;
    color: #fff;
}
body.light-mode .btn-send:hover:not(.loading) {
    box-shadow: 0 0 15px rgba(0,0,0,0.3);
}

.btn-send .send-icon,
.btn-send .loading-spinner,
.btn-send .stop-icon {
    position: absolute;
    transition: opacity 0.3s ease, transform 0.3s ease;
}
.btn-send .loading-spinner {
    opacity: 0;
    transform: scale(0.5);
    width: 20px;
    height: 20px;
    animation: spin 1s linear infinite;
}
.btn-send .stop-icon {
    opacity: 0;
    transform: scale(0.5);
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.btn-send.loading .send-icon {
    opacity: 0;
    transform: scale(0.5);
}
.btn-send.loading .loading-spinner {
    opacity: 0;
    transform: scale(0.5);
}
.btn-send.loading .stop-icon {
    opacity: 1;
    transform: scale(1);
}
@keyframes spin {
    100% { transform: rotate(360deg); }
}

/* ===== RESPONSIVE ===== */

@media (max-width: 768px) {
  .sidebar {
    left: 0;
    top: 0;
    bottom: 0;
    width: 85%;
    max-width: 340px;
    border-radius: 0 24px 24px 0;
    padding: 20px 16px;
    transform: translateX(-110%);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.35s cubic-bezier(0.22, 0.61, 0.36, 1),
                opacity 0.3s ease;
    box-shadow: 0 0 40px rgba(0,0,0,0.6);
    z-index: 250;
    border: none;
    border-right: 1px solid var(--sidebar-border);
  }

  .sidebar:not(.hidden) {
    transform: translateX(0);
    opacity: 1;
    pointer-events: all;
  }

  .sidebar.hidden {
    transform: translateX(-110%);
    opacity: 0;
    pointer-events: none;
  }

  .sidebar-header .logo-text {
    font-size: 20px;
  }

  .sidebar-toggle-btn {
    display: flex !important;
    background: rgba(255,255,255,0.05);
    border-radius: 50%;
    width: 36px;
    height: 36px;
    font-size: 18px;
    padding: 0;
    align-items: center;
    justify-content: center;
  }
  body.light-mode .sidebar-toggle-btn {
    background: rgba(0,0,0,0.05);
  }

  .sidebar-footer {
    padding-top: 12px;
    gap: 10px;
  }

  .custom-select-wrapper label {
    font-size: 11px;
  }

  .custom-select-trigger {
    padding: 8px 12px;
    font-size: 13px;
    border-radius: 12px;
  }

  .custom-options {
    max-height: 130px;
    border-radius: 12px;
    padding: 4px;
  }

  .custom-option {
    padding: 6px 10px;
    border-radius: 8px;
  }

  .custom-option .opt-title {
    font-size: 13px;
  }
  .custom-option .opt-desc {
    font-size: 11px;
  }

  .settings-btn {
    padding: 8px 12px;
    font-size: 13px;
    gap: 10px;
    border-radius: 12px;
  }

  .settings-btn svg {
    width: 20px;
    height: 20px;
  }

  .toggle-sidebar-btn {
    left: max(12px, env(safe-area-inset-left, 0px));
    top: max(12px, env(safe-area-inset-top, 0px));
    width: 42px;
    height: 42px;
    font-size: 20px;
    border-radius: 14px;
    display: flex !important;
    z-index: 100;
    background: rgba(20, 20, 22, 0.6);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255,255,255,0.08);
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
  }

  body.light-mode .toggle-sidebar-btn {
    background: rgba(230, 232, 234, 0.7);
    border-color: rgba(0,0,0,0.06);
  }

  .main-content {
    margin-left: 0 !important;
    padding-left: 0 !important;
    height: 100vh;
    overflow: hidden;
    position: relative;
  }

  .main-content.sidebar-hidden {
    margin-left: 0;
    padding-left: 0;
  }

  .top-actions {
    top: max(12px, env(safe-area-inset-top, 0px));
    right: max(12px, env(safe-area-inset-right, 0px));
    gap: 8px;
    z-index: 10;
  }

  .top-btn {
    padding: 6px 14px;
    font-size: 12px;
    border-radius: 20px;
    min-height: 34px;
    backdrop-filter: blur(8px);
    background: rgba(20, 20, 22, 0.6);
    border: 1px solid rgba(255,255,255,0.06);
  }

  body.light-mode .top-btn {
    background: rgba(230, 232, 234, 0.7);
    border-color: rgba(0,0,0,0.06);
  }

  .chat-wrapper {
    max-width: 100%;
    padding: 56px 6px 10px 6px;
    height: 100%;
    position: relative;
  }

  .chat-messages-area {
    padding-bottom: 80px;
    padding-right: 4px;
    -webkit-mask-image: linear-gradient(to bottom, transparent 0%, black 3%, black 80%, transparent 100%);
    mask-image: linear-gradient(to bottom, transparent 0%, black 3%, black 80%, transparent 100%);
  }

  .msg-wrapper {
    max-width: 92%;
  }

  .msg {
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
  }

  .msg-wrapper.bot .msg {
    padding: 16px 18px;
  }

  .msg-wrapper.user .msg {
    border-bottom-right-radius: 4px;
  }

  .msg-wrapper.bot .msg {
    border-bottom-left-radius: 4px;
  }

  .msg-actions {
    gap: 6px;
    margin-top: 4px;
  }

  .action-icon svg {
    width: 16px;
    height: 16px;
  }

  .chat-input-wrapper {
    position: absolute;
    bottom: max(10px, env(safe-area-inset-bottom, 0px));
    left: 6px;
    right: 6px;
    margin: 0;
    padding: 4px 4px 4px 8px;
    border-radius: 18px;
    background: rgba(10, 10, 10, 0.75);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: 0 8px 30px rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    gap: 6px;
    border: 1px solid rgba(255,255,255,0.04);
  }

  body.light-mode .chat-input-wrapper {
    background: rgba(244, 245, 247, 0.85);
    box-shadow: 0 8px 30px rgba(0,0,0,0.08);
    border-color: rgba(0,0,0,0.04);
  }

  .chat-input-bar {
    flex: 1;
    border-radius: 14px;
    padding: 6px 10px 6px 12px;
    gap: 4px;
    background: transparent;
    border: none;
    min-height: 36px;
    display: flex;
    align-items: center;
  }

  .chat-input-bar::before {
    display: none;
  }

  .chat-input-bar textarea {
    font-size: 14px;
    height: 20px;
    max-height: 80px;
    caret-color: #fff;
    color: #fff;
    padding: 0;
    line-height: 1.4;
  }

  body.light-mode .chat-input-bar textarea {
    color: #000;
  }

  .typing-placeholder {
    left: 12px;
    font-size: 14px;
    top: 50%;
    transform: translateY(-50%);
  }

  .btn-send {
    width: 34px;
    height: 34px;
    font-size: 16px;
    border-radius: 50%;
    margin: 0;
    flex-shrink: 0;
    background: #ffffff;
    color: #000;
    border: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
  }

  .btn-send:active {
    transform: scale(0.92);
  }

  body.light-mode .btn-send {
    background: #1c1c1e;
    color: #fff;
  }

  .btn-send .loading-spinner {
    width: 18px;
    height: 18px;
  }

  .btn-send .stop-icon {
    width: 16px;
    height: 16px;
  }

  .settings-modal-content {
    width: 92%;
    max-width: 380px;
    padding: 24px;
    border-radius: 24px;
  }

  .settings-row {
    padding: 12px 0;
  }

  .settings-row label {
    font-size: 14px;
  }

  .sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 200;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.35s ease;
  }

  .sidebar-overlay.active {
    opacity: 1;
    pointer-events: all;
  }
}

@media (max-width: 400px) {
  .sidebar {
    width: 90%;
    max-width: 280px;
    padding: 14px 12px;
  }

  .chat-input-wrapper {
    padding: 2px 2px 2px 6px;
    border-radius: 16px;
    bottom: max(8px, env(safe-area-inset-bottom, 24px));
    left: 4px;
    right: 4px;
  }

  .chat-input-bar {
    padding: 4px 8px 4px 10px;
    min-height: 32px;
  }

  .chat-input-bar textarea {
    font-size: 13px;
    height: 18px;
  }

  .typing-placeholder {
    font-size: 13px;
    left: 10px;
  }

  .btn-send {
    width: 30px;
    height: 30px;
    font-size: 14px;
  }

  .top-btn {
    font-size: 10px;
    padding: 4px 10px;
    min-height: 28px;
  }

  .top-actions {
    top: max(8px, env(safe-area-inset-top, 0px));
    right: max(8px, env(safe-area-inset-right, 0px));
    gap: 6px;
  }

  .msg {
    font-size: 13px;
    padding: 8px 12px;
  }

  .msg-wrapper.bot .msg {
    padding: 12px 14px;
  }
}

/* ===== DESKTOP LOGIN MODAL ===== */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 999;
    justify-content: center;
    align-items: center;
}
.modal-overlay.active {
    display: flex;
}

.modal-content.bottom-sheet {
    width: 100%;
    max-width: 440px;
    padding: 40px;
    border-radius: 32px;
    background: #18181b;
    border: 1px solid #2e2e36;
    position: relative;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
    color: #fff;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

body.light-mode .modal-content.bottom-sheet {
    background: #f4f5f7;
    border-color: #d1d5db;
    color: #000;
}

.modal-content.bottom-sheet .modal-glow {
    position: absolute;
    inset: -2px;
    border-radius: 34px;
    background: linear-gradient(90deg, rgba(255,255,255,0.8), #ff006a, rgba(255,255,255,0.8));
    background-size: 300% 100%;
    z-index: -1;
    opacity: 0;
    transition: opacity 0.4s ease;
}
.modal-overlay.active .modal-content.bottom-sheet .modal-glow {
    opacity: 1;
    animation: shimmerGradient 4s ease-in-out infinite, breatheGlow 2.5s ease-in-out infinite;
}

.modal-content.bottom-sheet .modal-header {
    text-align: center;
    margin-bottom: 24px;
}
.modal-content.bottom-sheet .modal-icon {
    width: 60px;
    height: 60px;
    background: #2a2a31;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    margin: 0 auto 12px auto;
}
body.light-mode .modal-content.bottom-sheet .modal-icon {
    background: #e6e8ea;
}
.modal-content.bottom-sheet .modal-header h2 {
    font-size: 24px;
    font-weight: 600;
}
.modal-content.bottom-sheet .modal-header p {
    color: #888;
    font-size: 14px;
}
body.light-mode .modal-content.bottom-sheet .modal-header p {
    color: #555;
}

.modal-content.bottom-sheet .input-group {
    margin-bottom: 14px;
}
.modal-content.bottom-sheet .input-group label {
    display: block;
    font-size: 13px;
    color: #bbb;
    margin-bottom: 6px;
}
.modal-content.bottom-sheet .input-group input {
    width: 100%;
    background: #2a2a31;
    border: 1px solid #3a3a42;
    border-radius: 14px;
    padding: 14px 16px;
    color: #fff;
    font-size: 14px;
    outline: none;
    transition: border 0.3s;
}
.modal-content.bottom-sheet .input-group input:focus {
    border-color: #888;
}
body.light-mode .modal-content.bottom-sheet .input-group input {
    background: #ffffff;
    border-color: #d1d5db;
    color: #000;
}

.modal-content.bottom-sheet .modal-submit {
    width: 100%;
    background: #f4f5f7;
    color: #000;
    border: none;
    padding: 16px;
    border-radius: 30px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 6px;
    transition: all 0.3s;
}
.modal-content.bottom-sheet .modal-submit:hover {
    background: #fff;
    transform: scale(1.02);
}
body.light-mode .modal-content.bottom-sheet .modal-submit {
    background: #1c1c1e;
    color: #fff;
}
body.light-mode .modal-content.bottom-sheet .modal-submit:hover {
    background: #2c2c2e;
}

.modal-content.bottom-sheet .modal-footer-text {
    text-align: center;
    margin-top: 16px;
    font-size: 14px;
    color: #888;
}
.modal-content.bottom-sheet .modal-footer-text a {
    color: #ffffff;
    text-decoration: none;
    font-weight: 500;
}
body.light-mode .modal-content.bottom-sheet .modal-footer-text a {
    color: #000;
}

.modal-content.bottom-sheet .social-buttons {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-top: 20px;
}
.modal-content.bottom-sheet .social-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #2a2a31;
    border: 1px solid #3a3a42;
    color: #fff;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.modal-content.bottom-sheet .social-btn:hover {
    background: #3a3a42;
    transform: scale(1.1);
}
body.light-mode .modal-content.bottom-sheet .social-btn {
    background: #e6e8ea;
    border-color: #c0c4ce;
    color: #000;
}
body.light-mode .modal-content.bottom-sheet .social-btn:hover {
    background: #d1d5db;
}

/* ===== BOTTOM SHEET MODAL (Mobile) ===== */
@media (max-width: 768px) {
    .modal-overlay {
        align-items: flex-end;
        background: rgba(0, 0, 0, 0.7);
        backdrop-filter: blur(4px);
        -webkit-backdrop-filter: blur(4px);
    }

    .modal-content.bottom-sheet {
        width: 100%;
        max-width: 100%;
        margin: 0;
        border-radius: 28px 28px 0 0;
        padding: 32px 24px 28px 24px;
        background: #18181b;
        border: none;
        border-top: 1px solid rgba(255,255,255,0.06);
        box-shadow: 0 -10px 40px rgba(0,0,0,0.8);
        transform: translateY(100%);
        transition: transform 0.4s cubic-bezier(0.22, 0.61, 0.36, 1);
        position: relative;
        overflow: visible;
    }

    .modal-overlay.active .modal-content.bottom-sheet {
        transform: translateY(0);
    }

    .bottom-sheet-handle {
        width: 40px;
        height: 4px;
        background: rgba(255, 255, 255, 0.2);
        border-radius: 4px;
        margin: 0 auto 16px auto;
        position: absolute;
        top: 8px;
        left: 50%;
        transform: translateX(-50%);
        pointer-events: none;
    }

    .modal-content.bottom-sheet .modal-glow {
        display: none;
    }

    .modal-content.bottom-sheet .modal-header h2 {
        font-size: 22px;
    }
    
    .modal-content.bottom-sheet .modal-icon {
        width: 50px;
        height: 50px;
        font-size: 20px;
        margin-bottom: 12px;
    }

    .modal-content.bottom-sheet .input-group input {
        padding: 12px 14px;
        font-size: 14px;
    }

    .modal-content.bottom-sheet .modal-submit {
        padding: 14px;
        font-size: 15px;
    }

    .modal-content.bottom-sheet .social-buttons {
        gap: 12px;
        margin-top: 20px;
    }
    
    .modal-content.bottom-sheet .social-btn {
        width: 44px;
        height: 44px;
    }
    
    .modal-content.bottom-sheet .social-btn svg {
        width: 20px;
        height: 20px;
    }

    body.light-mode .modal-content.bottom-sheet {
        background: #f4f5f7;
        border-top: 1px solid rgba(0,0,0,0.06);
        box-shadow: 0 -10px 40px rgba(0,0,0,0.1);
    }
    body.light-mode .bottom-sheet-handle {
        background: rgba(0, 0, 0, 0.15);
    }
}




