/* ═══════════════════════════════════════════════════════════
   Axo AI — Dark theme CSS
   ═══════════════════════════════════════════════════════════ */

:root {
    --bg:         #1a1a1a;
    --sidebar:    #212121;
    --surface:    #2d2d2d;
    --surface2:   #383838;
    --border:     #3a3a3a;
    --accent:     #6b8cff;
    --accent-dim: #3a4d99;
    --text:       #e8e8e8;
    --text-dim:   #888;
    --text-muted: #555;
    --danger:     #e05252;
    --success:    #52c87a;
    --sidebar-w:  260px;
    --radius:     12px;
    --radius-sm:  8px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.6;
    overflow: hidden;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }

/* ════════════════════════════════ LAYOUT ════════════════════════════════ */

body { display: flex; height: 100vh; height: var(--vh, 100vh); overflow-x: hidden; }

.sidebar {
    width: var(--sidebar-w);
    min-width: var(--sidebar-w);
    background: var(--sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    transition: transform 0.25s ease, min-width 0.25s ease, width 0.25s ease;
    z-index: 100;
    overflow: hidden;
}

.sidebar.collapsed {
    width: 48px;
    min-width: 48px;
    border-right: 1px solid var(--border);
    overflow: visible;
}

/* ── Sidebar open/close staged animation ── */
/* Keep overflow clipped during any transition so content doesn't spill */
.sidebar[data-animating] {
    overflow: hidden !important;
}
/* During either phase: hide the bulk content that causes layout jumps */
.sidebar[data-animating] .chat-list,
.sidebar[data-animating] .sidebar-recents-label,
.sidebar[data-animating] #token-usage-wrap {
    opacity: 0;
    pointer-events: none;
}
/* Smooth fade-in after expand, smooth fade-out before collapse */
.chat-list,
.sidebar-recents-label,
#token-usage-wrap {
    transition: opacity 0.18s ease;
}

/* ── Hide labels & non-icon elements when collapsed ── */
/* Block/button nav-labels that affect layout: hide instantly */
.sidebar.collapsed div.nav-label,
.sidebar.collapsed button.nav-label { display: none; }
/* Inline nav-label spans: fade + slide out smoothly */
.sidebar.collapsed span.nav-label {
    max-width: 0 !important;
    opacity: 0;
    margin: 0;
    pointer-events: none;
}
/* Base transition for inline nav-label spans */
span.nav-label {
    overflow: hidden;
    max-width: 200px;
    white-space: nowrap;
    transition: max-width 0.25s ease, opacity 0.15s ease;
}

.sidebar.collapsed .sidebar-collapse-btn {
    display: none;
}

/* nav/buttons: no overrides when collapsed — icons stay in place, sidebar width drives the change */

.sidebar.collapsed #search-wrap { display: none !important; }
.sidebar.collapsed .chat-list   { display: none; }

.sidebar.collapsed .sidebar-footer {
    border-top: 1px solid var(--border);
    margin-top: auto;
}
.sidebar.collapsed #token-usage-wrap { display: none; }
.sidebar.collapsed .sidebar-footer-user {
    justify-content: center;
    padding: 10px 0;
    margin: 4px 6px;
}
.sidebar.collapsed .sidebar-footer-user:hover { background: var(--surface); }

/* Tooltip anchors for icon-only mode */
.sidebar-nav-btn,
.sidebar-section-link,
.sidebar-collapse-btn {
    position: relative;
}

.main {
    flex: 1;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative; /* anchor for btn-sidebar-open */
}

/* ════════════════════════════════ SIDEBAR ═══════════════════════════════ */

/* ════════════════════════════════ SIDEBAR NEW (Claude-style) ═══════════ */

/* ── Top: logo + collapse btn ── */
.sidebar-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 14px 8px;
    flex-shrink: 0;
    min-height: 50px; /* collapse btn is 28px + 22px padding — pin height so buttons never shift */
    box-sizing: border-box;
}

.sidebar-logo {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 8px;
    letter-spacing: -0.2px;
    transition: gap 0.25s ease;
}
.sidebar.collapsed .sidebar-logo { gap: 0; }

.sidebar-logo-img {
    width: 20px;
    height: 20px;
    object-fit: contain;
    flex-shrink: 0;
}

.sidebar-collapse-btn {
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    padding: 5px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.12s, color 0.12s;
    flex-shrink: 0;
}
.sidebar-collapse-btn:hover { background: var(--surface); color: var(--text); }

/* ── Nav buttons (New chat, Search) ── */
.sidebar-nav {
    padding: 4px 6px 4px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar-nav-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 10px;
    background: none;
    border: none;
    border-radius: 8px;
    color: var(--text-dim);
    font-size: 14px;
    font-family: inherit;
    font-weight: 400;
    cursor: pointer;
    text-align: left;
    transition: background 0.12s, color 0.12s;
    white-space: nowrap;
}
.sidebar-nav-btn:hover { background: var(--surface); color: var(--text); }
.sidebar-nav-btn svg { flex-shrink: 0; opacity: 0.75; }
.sidebar-nav-btn:hover svg { opacity: 1; }

/* ── Search input (toggled) ── */
.chat-search-wrap {
    padding: 4px 8px 6px;
    flex-shrink: 0;
}

.chat-search {
    width: 100%;
    padding: 8px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 13px;
    outline: none;
    transition: border-color 0.15s;
    box-sizing: border-box;
}
.chat-search::placeholder { color: var(--text-muted); }
.chat-search:focus { border-color: rgba(255,255,255,0.2); }

/* ── Chats section nav ── */
.sidebar-section-nav {
    padding: 2px 6px 2px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar-section-link {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 10px;
    background: none;
    border: none;
    border-radius: 8px;
    color: var(--text-dim);
    font-size: 14px;
    font-family: inherit;
    font-weight: 400;
    cursor: pointer;
    text-align: left;
    transition: background 0.12s, color 0.12s;
}
.sidebar-section-link:hover { background: var(--surface); color: var(--text); }
.sidebar-section-link.active { color: var(--text); }
.sidebar-section-link.active svg { opacity: 1; }
.sidebar-section-link svg { flex-shrink: 0; opacity: 0.75; }

/* ── "Недавние" label ── */
.sidebar-recents-label {
    padding: 10px 18px 4px;
    font-size: 11.5px;
    font-weight: 500;
    color: var(--text-muted);
    letter-spacing: 0.2px;
    flex-shrink: 0;
}

/* ── Chat list ── */
.chat-list {
    flex: 1;
    overflow-y: auto;
    padding: 2px 8px 8px;
}

.chat-group-label {
    padding: 6px 8px 4px;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
    letter-spacing: 0.3px;
}

.chat-item {
    display: flex;
    align-items: center;
    padding: 8px 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.12s;
    gap: 8px;
    position: relative;
    overflow: hidden;
}
.chat-item:hover { background: var(--surface); }
.chat-item.active { background: var(--surface2); }

.chat-item-title {
    flex: 1;
    font-size: 13.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-dim);
    font-weight: 400;
}
.chat-item.active .chat-item-title,
.chat-item:hover .chat-item-title { color: var(--text); }

.chat-item-delete {
    opacity: 0;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 4px;
    transition: opacity 0.15s, color 0.15s;
    flex-shrink: 0;
}
.chat-item:hover .chat-item-delete { opacity: 1; }
.chat-item-delete:hover { color: var(--danger); }

.chat-list-empty {
    padding: 20px 12px;
    color: var(--text-muted);
    font-size: 13px;
    text-align: center;
}

/* ── Sidebar footer ── */
.sidebar-footer {
    border-top: 1px solid var(--border);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
}

.sidebar-footer-user {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 10px;
    border-radius: 8px;
    margin: 4px 8px;
    cursor: pointer;
    transition: background 0.12s, padding 0.25s ease, margin 0.25s ease;
}
.sidebar-footer-user:hover { background: var(--surface); }

.user-info {
    display: flex;
    align-items: center;
    gap: 9px;
    flex: 1;
    min-width: 0;
}

.user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.user-avatar-placeholder {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--accent-dim);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
}

.user-name {
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text);
}

/* ════════════════════════════════ BUTTONS ═══════════════════════════════ */

.icon-btn {
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.12s, color 0.12s;
    flex-shrink: 0;
}
.icon-btn:hover { background: var(--surface); color: var(--text); }

/* Search button active state */
.sidebar-nav-btn.active { background: var(--surface); color: var(--text); }
.sidebar-nav-btn.active svg { opacity: 1; }

/* btn-sidebar-open hidden — collapsed strip with icons replaces it */
.btn-sidebar-open { display: none !important; }

/* ════════════════════════════════ WELCOME ═══════════════════════════════ */

.welcome-screen {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow-y: auto;
    padding: 40px 20px;
}

.welcome-content {
    width: 100%;
    max-width: 700px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.welcome-title {
    font-size: 32px;
    font-weight: 700;
    text-align: center;
    background: linear-gradient(135deg, #fff 0%, var(--accent) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.welcome-subtitle {
    font-size: 17px;
    color: var(--text-dim);
    text-align: center;
    margin-top: -10px;
}

.quick-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin-top: 4px;
}

.chip {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 99px;
    color: var(--text-dim);
    font-size: 13px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.chip:hover {
    background: var(--surface2);
    border-color: var(--accent);
    color: var(--text);
}

/* ════════════════════════════════ CHAT SCREEN ═══════════════════════════ */

.chat-screen {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.chat-header {
    padding: 16px 20px 14px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.chat-title-display {
    flex: 1;
    text-align: center;
    font-size: 15px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.messages-wrap {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 24px 0 130px;
}

.messages {
    max-width: 760px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* ── Message bubbles ── */
.msg {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.msg.user { flex-direction: row-reverse; }

.msg-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    font-weight: 700;
    background: var(--accent-dim);
    color: #fff;
}

.msg.user .msg-avatar {
    background: var(--surface2);
}

.msg-body {
    max-width: 82%;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.msg.user .msg-body { align-items: flex-end; }

.msg-bubble {
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 14.5px;
    line-height: 1.65;
    word-break: break-word;
}

.msg.user .msg-bubble {
    background: var(--surface2);
    color: var(--text);
    border-bottom-right-radius: 4px;
}

.msg.assistant .msg-bubble {
    background: transparent;
    color: var(--text);
    padding: 4px 0;
    border-radius: 0;
}

/* Markdown inside bubbles */
.msg-bubble p { margin: 0 0 0.6em; }
.msg-bubble p:last-child { margin-bottom: 0; }
.msg-bubble ul, .msg-bubble ol { margin: 0.4em 0 0.4em 1.4em; }
.msg-bubble li { margin: 0.2em 0; }
.msg-bubble h1, .msg-bubble h2, .msg-bubble h3 { margin: 0.8em 0 0.4em; font-size: 1em; font-weight: 700; }
.msg-bubble blockquote { border-left: 3px solid var(--accent); padding-left: 10px; color: var(--text-dim); margin: 0.4em 0; }
.msg-bubble code {
    background: rgba(0,0,0,0.3);
    padding: 1px 5px;
    border-radius: 4px;
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 13px;
}
.msg-bubble pre {
    background: #0d0d0d;
    border-radius: 8px;
    padding: 12px 14px;
    overflow-x: auto;
    margin: 0.6em 0;
    position: relative;
}
.msg-bubble pre code {
    background: none;
    padding: 0;
    font-size: 13px;
}
.msg-bubble a { color: var(--accent); }
.msg-bubble table { border-collapse: collapse; margin: 0.6em 0; font-size: 13px; }
.msg-bubble th, .msg-bubble td { border: 1px solid var(--border); padding: 6px 10px; }
.msg-bubble th { background: var(--surface2); }
.msg-bubble hr { border: none; border-top: 1px solid var(--border); margin: 0.8em 0; }

/* ── Collapsible messages ── */
.msg-bubble.collapsible {
    position: relative;
    padding-right: 34px;
}
.msg-collapse-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    padding: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 5px;
    transition: color 0.15s, background 0.15s;
    line-height: 1;
    flex-shrink: 0;
}
.msg-collapse-btn:hover {
    color: var(--text);
    background: rgba(255,255,255,0.08);
}

/* ── Typing indicator ── */
.typing-indicator {
    display: flex;
    gap: 12px;
    align-items: center;
}

.typing-dots {
    display: flex;
    gap: 5px;
    padding: 14px 16px;
    background: var(--surface);
    border-radius: 16px;
    border-bottom-left-radius: 4px;
}

.typing-dot {
    width: 7px;
    height: 7px;
    background: var(--text-muted);
    border-radius: 50%;
    animation: typing-bounce 1.2s infinite ease-in-out;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-bounce {
    0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
    40% { transform: translateY(-6px); opacity: 1; }
}

/* ════════════════════════════════ INPUT AREA ════════════════════════════ */

.input-area { width: 100%; max-width: 700px; }
.welcome-content .input-area { width: 100%; }

.input-area-wrap {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 28px 20px 20px;
    display: flex;
    justify-content: center;
    background: linear-gradient(to bottom, transparent 0%, var(--bg) 38%);
    pointer-events: none;
}
.input-area-wrap > * { pointer-events: auto; }

.input-box {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(32px) saturate(180%);
    -webkit-backdrop-filter: blur(32px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-bottom-color: rgba(255, 255, 255, 0.05);
    border-radius: 16px;
    padding: 12px 12px 10px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: border-color 0.15s, box-shadow 0.15s;
    width: 100%;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255,255,255,0.08);
}

.input-box:focus-within {
    border-color: rgba(107, 140, 255, 0.4);
    box-shadow: 0 0 0 3px rgba(107,140,255,0.10), 0 8px 32px rgba(0,0,0,0.35), inset 0 1px 0 rgba(255,255,255,0.07);
}

.msg-input {
    background: none;
    border: none;
    color: var(--text);
    font-size: 15px;
    resize: none;
    outline: none;
    width: 100%;
    max-height: 200px;
    overflow-y: auto;
    line-height: 1.6;
    font-family: inherit;
}
.msg-input::placeholder { color: var(--text-muted); }

.input-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.input-left {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

/* ── Model picker ── */
.model-wrap {
    position: relative;
}

.model-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    background: none;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-dim);
    font-size: 12px;
    padding: 4px 8px;
    cursor: pointer;
    transition: border-color 0.12s, color 0.12s;
}
.model-btn:hover { border-color: var(--accent); color: var(--text); }
.model-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.model-btn:disabled:hover { border-color: var(--border); color: var(--text-dim); }

.model-dropdown {
    position: absolute;
    bottom: calc(100% + 6px);
    left: 0;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    min-width: 200px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    z-index: 200;
    overflow: hidden;
}

.model-group-label {
    padding: 8px 12px 4px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.model-option {
    display: block;
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 13px;
    padding: 8px 14px;
    cursor: pointer;
    transition: background 0.12s, color 0.12s;
}
.model-option:hover { background: var(--border); color: var(--text); }
.model-option.active { color: var(--accent); }
.model-option-local { color: #7ec88a; }
.model-option-local:hover { color: #7ec88a; }
.model-divider { height: 1px; background: var(--border); margin: 4px 8px; }

/* ── Send button ── */
.send-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent);
    border: none;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, opacity 0.15s;
    flex-shrink: 0;
}
.send-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.send-btn:not(:disabled):hover { background: #5a7ae8; }
.send-btn.stop { background: var(--danger); }
.send-btn.stop:hover { background: #c94444; }

/* ════════════════════════════════ MODAL ═════════════════════════════════ */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    backdrop-filter: blur(2px);
}

.modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px 16px;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 { font-size: 17px; font-weight: 700; }

.modal-body { padding: 20px 24px 24px; }

.settings-section { margin-bottom: 28px; }
.settings-section h3 { font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.settings-hint { font-size: 12px; color: var(--text-muted); margin-bottom: 16px; line-height: 1.5; }

.key-row { margin-bottom: 16px; }
.key-row label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 8px; color: var(--text-dim); }

.key-input-wrap { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.key-masked {
    font-size: 13px;
    color: var(--text-muted);
    font-family: monospace;
    background: var(--surface2);
    padding: 6px 10px;
    border-radius: 6px;
    border: 1px solid var(--border);
    flex: 1;
}

.key-input {
    flex: 1;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 13px;
    padding: 6px 10px;
    outline: none;
    font-family: monospace;
    transition: border-color 0.15s;
}
.key-input:focus { border-color: var(--accent); }

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 500;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-dim);
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.12s, color 0.12s;
    flex-shrink: 0;
}
.btn-sm:hover { background: var(--border); color: var(--text); }
.btn-sm.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-sm.btn-primary:hover { background: #5a7ae8; }
.btn-sm.btn-danger { color: var(--danger); border-color: transparent; }
.btn-sm.btn-danger:hover { background: rgba(224,82,82,0.1); }

/* ════════════════════════════════ SIDEBAR OVERLAY ══════════════════════ */

.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 50;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}
.sidebar-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

/* ════════════════════════════════ RESPONSIVE ════════════════════════════ */

/* ════════════════════════════════ RESPONSIVE ════════════════════════════ */

@media (max-width: 768px) {
    .msg-body { max-width: 88%; }
    .agent-activity,
    .thinking-block { max-width: 92%; }
}

@media (max-width: 640px) {
    /* ── Sidebar ── */
    .sidebar {
        position: fixed;
        top: 0; left: 0; bottom: 0;
        transform: translateX(-100%);
        min-width: var(--sidebar-w) !important;
        width: var(--sidebar-w) !important;
    }
    .sidebar.mobile-open { transform: translateX(0); }
    /* On mobile, show the open button since sidebar slides out completely */
    .btn-sidebar-open { display: flex !important; position: fixed; top: 12px; left: 12px; z-index: 101; background: var(--sidebar); border-radius: 8px; padding: 6px; border: 1px solid var(--border); }

    /* ── Welcome ── */
    .welcome-screen { padding: 20px 12px; }
    .welcome-content { gap: 14px; }
    .welcome-title { font-size: 22px; }
    .welcome-subtitle { font-size: 15px; }
    .quick-chips { gap: 6px; }
    .chip { font-size: 12px; padding: 7px 12px; }

    /* ── Chat ── */
    .chat-header { padding: 13px 16px 13px 56px; }
    .chat-title-display { font-size: 14px; }
    .messages { padding: 0 10px; }
    .messages-wrap { padding: 16px 0 70px; }
    .msg-body { max-width: 90%; }
    .msg-bubble { font-size: 14px; padding: 10px 13px; }
    .agent-activity,
    .thinking-block { max-width: 94%; }

    /* ── Input area ── */
    .input-area-wrap { padding: 16px 10px 14px; }
    .messages-wrap { padding-bottom: 110px; }
    .input-area { max-width: 100%; }
    .model-label { max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; vertical-align: middle; }

    /* ── Modal ── */
    .modal { max-width: 100%; }
    .modal-body { padding: 16px 18px 20px; }
    .modal-header { padding: 16px 18px 14px; }
}

@media (max-width: 400px) {
    .agent-btn-text { display: none; }
    .agent-btn { padding: 4px 7px; }
    .model-label { max-width: 72px; }
}


/* ── Settings button ── */
.settings-btn {
    color: var(--text-muted);
    flex-shrink: 0;
    transition: color 0.15s;
}
.settings-btn:hover { color: var(--text); }

/* ── Plan badge ── */
.plan-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 20px;
    letter-spacing: 0.04em;
}
.plan-free   { background: var(--surface2); color: var(--text-muted); border: 1px solid var(--border); }
.plan-plus   { background: linear-gradient(135deg,rgba(107,140,255,0.2),rgba(160,107,255,0.2)); color: #a06bff; border: 1px solid rgba(107,140,255,0.3); }
.plan-admin  { background: rgba(245,158,11,0.15); color: #f59e0b; border: 1px solid rgba(245,158,11,0.3); }

/* ── Settings modal — token bar ── */
.settings-account-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}
.settings-account-info { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 0; }
.settings-account-name { font-size: 14px; font-weight: 600; }

.settings-usage-nums {
    display: flex;
    align-items: baseline;
    gap: 6px;
    margin-bottom: 10px;
}
.settings-used-val  { font-size: 28px; font-weight: 700; color: var(--text); }
.settings-usage-sep { font-size: 16px; color: var(--text-muted); }
.settings-limit-val { font-size: 16px; color: var(--text-dim); }
.settings-pct-val   { margin-left: auto; font-size: 22px; font-weight: 700; color: var(--accent); }
.settings-pct-val.warn   { color: #f59e0b; }
.settings-pct-val.danger { color: #ef4444; }

.settings-usage-bar {
    height: 8px;
    background: var(--surface2);
    border-radius: 99px;
    overflow: hidden;
    margin-bottom: 8px;
    border: 1px solid var(--border);
}
.settings-usage-fill {
    height: 100%;
    border-radius: 99px;
    background: var(--accent);
    transition: width 0.5s ease;
}
.settings-usage-fill.warn   { background: #f59e0b; }
.settings-usage-fill.danger { background: #ef4444; }

.settings-usage-hint {
    font-size: 11.5px;
    color: var(--text-muted);
}

.settings-admin-msg {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    background: rgba(245,158,11,0.07);
    border: 1px solid rgba(245,158,11,0.2);
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: #f59e0b;
    font-weight: 500;
}

/* ── Model costs table ── */
.model-costs-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.model-costs-table tr { border-bottom: 1px solid var(--border); }
.model-costs-table tr:last-child { border-bottom: none; }
.model-costs-table td { padding: 9px 4px; vertical-align: middle; }
.model-costs-table td:last-child { text-align: right; }
.model-mult {
    display: inline-block;
    font-size: 12px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 20px;
    background: var(--surface2);
    border: 1px solid var(--border);
    color: var(--text-dim);
}
.model-mult.expensive { background: rgba(107,140,255,0.12); border-color: rgba(107,140,255,0.25); color: var(--accent); }

/* ── Error toast ── */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--surface2);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    z-index: 2000;
    box-shadow: 0 4px 20px rgba(0,0,0,0.4);
    animation: toast-in 0.2s ease;
    max-width: 90vw;
    text-align: center;
}
.toast.error { border-color: var(--danger); color: var(--danger); }
.toast.success { border-color: var(--success); color: var(--success); }
@keyframes toast-in { from { opacity: 0; transform: translateX(-50%) translateY(10px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }

/* ── Stopped generation label ── */
.stopped-label {
    text-align: center;
    font-size: 11px;
    color: var(--text-muted);
    opacity: 0.45;
    margin: 4px 0 12px;
    user-select: none;
}

/* ── Streaming cursor ── */
@keyframes blink { 0%,100% { opacity:1; } 50% { opacity:0; } }
.streaming-cursor::after {
    content: '▌';
    display: inline;
    animation: blink 0.7s step-end infinite;
    color: var(--accent);
    margin-left: 1px;
}

/* ── Title loading shimmer ── */
@keyframes title-shimmer {
    0%   { background-position: 150% center; }
    100% { background-position: -150% center; }
}
.title-loading {
    background: linear-gradient(90deg,
        var(--text-muted) 0%,
        var(--text-dim)   35%,
        var(--text)       50%,
        var(--text-dim)   65%,
        var(--text-muted) 100%);
    background-size: 300% auto;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: title-shimmer 1.8s linear infinite;
}

/* ── Title typewriter cursor ── */
.title-typing::after {
    content: '|';
    animation: blink 0.5s step-end infinite;
    color: var(--accent);
    font-weight: 300;
    -webkit-text-fill-color: var(--accent);
}

/* ── Thinking block (QwQ reasoning) ── */
.thinking-block {
    margin-bottom: 8px;
    max-width: 82%;
}

.thinking-header {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 8px 3px 2px;
    cursor: pointer;
    user-select: none;
    font-size: 13px;
    color: var(--text-dim);
    border-radius: 6px;
    transition: color 0.12s;
}
.thinking-header:hover { color: var(--text); }

.thinking-icon {
    color: var(--accent);
    display: inline-flex;
    animation: thinking-spin 2s linear infinite;
    flex-shrink: 0;
}
@keyframes thinking-spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}
.thinking-icon.done { animation: none; color: var(--text-dim); }

.thinking-chevron {
    font-size: 10px;
    transition: transform 0.2s;
    opacity: 0.6;
    margin-left: 2px;
}
.thinking-block.collapsed .thinking-chevron { transform: rotate(-90deg); }

.thinking-body {
    margin-top: 6px;
    padding: 6px 14px;
    font-size: 13.5px;
    color: var(--text-dim);
    line-height: 1.75;
    max-height: 420px;
    overflow-y: auto;
    border-left: 2px solid var(--border);
    word-break: break-word;
}
.thinking-body p { margin: 0 0 0.75em; }
.thinking-body p:last-child { margin-bottom: 0; }
.thinking-body ul, .thinking-body ol { margin: 0.4em 0 0.4em 1.4em; }
.thinking-body li { margin: 0.2em 0; }
/* During streaming: pre-wrap for raw text */
.thinking-body.streaming { white-space: pre-wrap; font-size: 12.5px; }

.thinking-block.collapsed .thinking-body { display: none; }

/* ── Token usage bar (sidebar) ── */
.token-bar-wrap {
    padding: 10px 14px 4px;
}
.token-bar-label {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 5px;
}
.token-bar {
    height: 3px;
    background: var(--surface2);
    border-radius: 99px;
    overflow: hidden;
}
.token-bar-fill {
    height: 100%;
    border-radius: 99px;
    background: var(--accent);
    transition: width 0.5s ease;
}
.token-bar-fill.warn   { background: #f59e0b; }
.token-bar-fill.danger { background: #ef4444; }

/* ── Copy button for code blocks ── */
.code-copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(255,255,255,0.07);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 5px;
    color: var(--text-dim);
    font-size: 11px;
    padding: 3px 8px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s, background 0.15s, color 0.15s, border-color 0.15s;
    font-family: inherit;
    line-height: 1.4;
    white-space: nowrap;
}
.msg-bubble pre:hover .code-copy-btn { opacity: 1; }
.code-copy-btn:hover { background: rgba(255,255,255,0.14); color: var(--text); }
.code-copy-btn.copied { color: var(--success); border-color: var(--success); opacity: 1; }

/* ── Message copy button ── */
.msg-copy-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 11px;
    padding: 2px 6px 2px 4px;
    border-radius: 5px;
    cursor: pointer;
    font-family: inherit;
    line-height: 1.4;
    white-space: nowrap;
    opacity: 0;
    transition: color 0.12s, opacity 0.12s;
    flex-shrink: 0;
}
.msg-body:hover .msg-copy-btn { opacity: 1; }
.msg-copy-btn:hover { color: var(--text); }
.msg-copy-btn.copied { color: var(--success); opacity: 1; }
@media (max-width: 640px) { .msg-copy-btn { opacity: 0.6; } }

/* ── KaTeX math rendering ── */
.msg-bubble .katex { font-size: 1.15em; }
.msg-bubble .katex-display {
    margin: 0.8em 0;
    overflow-x: auto;
    overflow-y: hidden;
}
.msg-bubble .katex-display .katex { font-size: 1.3em; }

/* ── Agent mode toggle button ── */
.agent-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    background: none;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-dim);
    font-size: 12px;
    padding: 4px 9px;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
    font-family: inherit;
}
.agent-btn:hover { border-color: var(--accent); color: var(--text); }
.agent-btn.active {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(107,140,255,0.1);
}
.agent-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.agent-btn:disabled:hover {
    border-color: var(--border);
    color: var(--text-dim);
    background: none;
}

/* ── Agent activity block ── */
@keyframes agent-dot-bounce {
    0%, 80%, 100% { transform: translateY(0);    opacity: 0.4; }
    40%            { transform: translateY(-4px); opacity: 1;   }
}

.agent-activity {
    margin-bottom: 8px;
    max-width: 82%;
}

.agent-activity-header {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 8px 3px 2px;
    font-size: 13px;
    color: var(--text-dim);
    border-radius: 6px;
    user-select: none;
}

.agent-activity-spinner {
    display: inline-flex;
    color: var(--text-dim);
    animation: thinking-spin 2s linear infinite;
    flex-shrink: 0;
}
.agent-activity-spinner.done { animation: none; }

/* Steps + thinking container — left border strip */
.agent-steps {
    margin-top: 6px;
    padding: 6px 14px;
    border-left: 2px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.agent-step {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 3px 0;
    font-size: 12.5px;
    cursor: pointer;
    flex-wrap: wrap;
}
.agent-step:hover { opacity: 0.75; }
.agent-step-icon { font-size: 12px; flex-shrink: 0; color: var(--text-muted); }
.agent-step-name {
    color: var(--text-dim);
    font-weight: 500;
    font-family: 'SF Mono','Fira Code',monospace;
    font-size: 12px;
    flex-shrink: 0;
}
.agent-step-arg {
    color: var(--text-muted);
    font-size: 12px;
    font-family: 'SF Mono','Fira Code',monospace;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.agent-step-status { flex-shrink: 0; font-size: 11px; }
.agent-step-status.pending { color: var(--text-muted); }
.agent-step-status.done    { color: var(--success); }
.agent-step-status.error   { color: var(--danger); }

/* Animated pending dots */
.agent-dots {
    display: inline-flex;
    gap: 3px;
    align-items: center;
    vertical-align: middle;
}
.agent-dots span {
    display: inline-block;
    width: 4px; height: 4px;
    border-radius: 50%;
    background: currentColor;
    animation: agent-dot-bounce 1.2s ease-in-out infinite;
}
.agent-dots span:nth-child(2) { animation-delay: 0.2s; }
.agent-dots span:nth-child(3) { animation-delay: 0.4s; }

.agent-step-output {
    display: none;
    width: 100%;
    padding: 6px 8px;
    margin-top: 4px;
    font-size: 11.5px;
    color: var(--text-muted);
    white-space: pre-wrap;
    word-break: break-all;
    font-family: 'SF Mono','Fira Code',monospace;
    background: rgba(0,0,0,0.2);
    border-radius: 6px;
    max-height: 200px;
    overflow-y: auto;
}
.agent-step.expanded .agent-step-output { display: block; }

/* ── Agent thinking inside activity — same style as main thinking block ── */
.agent-thinking { }

.agent-thinking-header {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 8px 3px 2px;
    font-size: 13px;
    color: var(--text-dim);
    cursor: pointer;
    user-select: none;
    border-radius: 6px;
    transition: color 0.12s;
}
.agent-thinking-header:hover { color: var(--text); }
.agent-thinking-icon {
    color: var(--accent);
    display: inline-flex;
    animation: thinking-spin 2s linear infinite;
    flex-shrink: 0;
}
.agent-thinking-icon.done { animation: none; color: var(--text-dim); }
.agent-thinking-chevron {
    font-size: 10px; opacity: 0.6;
    transition: transform 0.2s; margin-left: 2px;
}
.agent-thinking.collapsed .agent-thinking-chevron { transform: rotate(-90deg); }
.agent-thinking-body {
    margin-top: 4px;
    padding: 6px 14px;
    font-size: 13px;
    color: var(--text-dim);
    line-height: 1.75;
    max-height: 300px;
    overflow-y: auto;
    border-left: 2px solid var(--border);
    word-break: break-word;
    white-space: pre-wrap;
}
.agent-thinking.collapsed .agent-thinking-body { display: none; }

/* ── Agent mode top notice ── */
@keyframes agent-notice-in {
    0%   { transform: translateX(-50%) translateY(-100%); opacity: 0; }
    60%  { transform: translateX(-50%) translateY(6px);   opacity: 1; }
    100% { transform: translateX(-50%) translateY(0);     opacity: 1; }
}
@keyframes agent-notice-out {
    0%   { transform: translateX(-50%) translateY(0);      opacity: 1; }
    100% { transform: translateX(-50%) translateY(-120%);  opacity: 0; }
}
.agent-notice {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-120%);
    z-index: 9999;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 18px;
    background: rgba(30, 30, 40, 0.92);
    border: 1px solid rgba(107, 140, 255, 0.45);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.45), 0 0 0 1px rgba(107,140,255,0.1);
    backdrop-filter: blur(14px);
    font-size: 13px;
    color: var(--text-dim);
    white-space: nowrap;
    pointer-events: none;
}
.agent-notice-icon {
    color: var(--accent);
    flex-shrink: 0;
    display: flex;
}
.agent-notice-text strong {
    color: var(--text);
    font-weight: 600;
}
.agent-notice.show {
    animation: agent-notice-in 0.45s cubic-bezier(0.34, 1.4, 0.64, 1) forwards;
}
.agent-notice.hide {
    animation: agent-notice-out 0.35s ease-in forwards;
}

/* ── Search badge ────────────────────────────────────────────────────────── */

.search-step .agent-step-output { display: block !important; }

.search-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: rgba(255,255,255,.06);
    border: 1px solid rgba(255,255,255,.12);
    border-radius: 20px;
    padding: 4px 12px 4px 8px;
    font-size: 12px;
    color: #aaa;
    cursor: pointer;
    margin-top: 4px;
    transition: background .15s, color .15s, border-color .15s;
    user-select: none;
}
.search-badge:hover { background: rgba(255,255,255,.11); color: #fff; border-color: rgba(255,255,255,.22); }

.search-badge-favs {
    display: flex;
    align-items: center;
    gap: 2px;
    margin-right: 2px;
}
.search-fav {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    object-fit: contain;
}

/* ── Sources panel ───────────────────────────────────────────────────────── */

.sources-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 360px;
    height: 100dvh;
    background: #161616;
    border-left: 1px solid #252525;
    z-index: 300;
    transform: translateX(100%);
    transition: transform .25s cubic-bezier(.4,0,.2,1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.sources-panel.open { transform: translateX(0); }

.sources-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid #252525;
    flex-shrink: 0;
    gap: 10px;
}
.sources-panel-title {
    font-size: 13px;
    font-weight: 600;
    color: #e8e8e8;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.sources-panel-close {
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    transition: color .15s, background .15s;
    flex-shrink: 0;
}
.sources-panel-close:hover { color: #fff; background: rgba(255,255,255,.08); }

.sources-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.source-card {
    display: flex;
    gap: 10px;
    padding: 10px 12px;
    background: #1e1e1e;
    border-radius: 8px;
    text-decoration: none;
    border: 1px solid #282828;
    transition: background .12s, border-color .12s;
}
.source-card:hover { background: #232323; border-color: #333; }

.source-card-num {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    background: rgba(255,255,255,.07);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    color: #777;
    font-weight: 600;
    margin-top: 1px;
}
.source-card-body { flex: 1; min-width: 0; }
.source-card-title {
    font-size: 12.5px;
    font-weight: 500;
    color: #e0e0e0;
    line-height: 1.4;
    margin-bottom: 2px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.source-card-url {
    font-size: 11px;
    color: #6b8cff;
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.source-card-desc {
    font-size: 11.5px;
    color: #666;
    line-height: 1.45;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ── Guest wall overlay ───────────────────────────────────── */
.guest-wall {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.65);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}
.guest-wall-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 36px 32px 32px;
    text-align: center;
    max-width: 360px;
    width: calc(100% - 32px);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}
.guest-wall-logo {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    margin-bottom: 4px;
}
.guest-wall-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
}
.guest-wall-sub {
    font-size: 13.5px;
    color: var(--text-dim);
    line-height: 1.5;
    margin-bottom: 4px;
}
.guest-wall-btn {
    display: block;
    width: 100%;
    padding: 11px 20px;
    background: var(--accent);
    color: #fff;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    transition: opacity .15s;
}
.guest-wall-btn:hover { opacity: .85; }
.guest-wall-btn-google {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 11px 20px;
    background: var(--surface2);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    transition: background .15s;
}
.guest-wall-btn-google:hover { background: #3f3f3f; }

/* Guest sidebar hint */
.guest-sidebar-hint {
    font-size: 12px;
    color: var(--text-muted);
    padding: 8px 14px 6px;
    text-align: center;
    line-height: 1.5;
}

/* Guest sign-in button — top-right corner */
.btn-guest-topbar {
    position: fixed;
    top: 14px;
    right: 16px;
    z-index: 200;
    background: #fff;
    color: #111;
    border: none;
    border-radius: 20px;
    padding: 7px 16px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.25);
    transition: opacity .15s;
}
.btn-guest-topbar:hover { opacity: .85; }

/* Guest sign-in button in sidebar footer */
.btn-guest-signin {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 10px 16px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: opacity .15s;
}
.btn-guest-signin:hover { opacity: .85; }

@media (max-width: 600px) {
    .sources-panel { width: 100vw; border-left: none; }
}

/* ════════════════════ THINKING INLINE LABEL ════════════════════ */

.thinking-inline-label,
.thinking-done-label {
    padding: 0;
    /* Sits between messages — no extra margin needed */
}

@keyframes thinking-shimmer {
    0%   { background-position: 100% center; }
    100% { background-position: -100% center; }
}

.thinking-shimmer-text {
    display: inline-block;
    background: linear-gradient(
        90deg,
        #666 0%,
        #666 25%,
        #ffffff 50%,
        #666 75%,
        #666 100%
    );
    background-size: 200% 100%;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: thinking-shimmer 1.8s linear infinite;
    font-size: 18px;
    font-weight: 500;
}

.thinking-done-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 13px;
    cursor: pointer;
    padding: 3px 8px 3px 4px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: color .15s, background .15s;
    font-family: inherit;
}
.thinking-done-btn:hover {
    color: var(--text-dim);
    background: var(--surface2);
}

/* ════════════════════ THINKING PANEL ════════════════════ */
.thinking-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 340px;
    height: 100dvh;
    background: var(--sidebar);
    border-left: 1px solid var(--border);
    z-index: 200;
    transform: translateX(100%);
    transition: transform .25s cubic-bezier(.4,0,.2,1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.thinking-panel.open { transform: translateX(0); }

.tp-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.tp-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}
.tp-timer {
    font-size: 12px;
    color: var(--text-dim);
    font-weight: 400;
}
.tp-close {
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    font-size: 14px;
    padding: 4px 6px;
    border-radius: 4px;
    line-height: 1;
    transition: color .15s, background .15s;
    display: flex;
    align-items: center;
}
.tp-close:hover { color: var(--text); background: rgba(255,255,255,.06); }

.tp-body {
    flex: 1;
    overflow-y: auto;
    padding: 10px 0;
    display: flex;
    flex-direction: column;
}

.tp-section { padding: 6px 16px; }
.tp-section-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .06em;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
    border-radius: 4px;
    padding: 2px 4px;
    margin-left: -4px;
    transition: color .15s;
}
.tp-section-label:hover { color: var(--text-dim); }
.tp-sec-icon {
    display: inline-flex;
    animation: thinking-spin 2s linear infinite;
    color: var(--accent);
}
.tp-sec-icon.done { animation: none; color: var(--text-dim); }
.tp-section-time {
    font-size: 11px;
    color: var(--text-muted);
    margin-left: auto;
    font-weight: 400;
    letter-spacing: normal;
    text-transform: none;
}
.tp-section-text {
    font-size: 12px;
    color: var(--text-dim);
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.7;
    overflow: hidden;
}
.tp-sep {
    height: 1px;
    background: var(--border);
    margin: 6px 16px;
}

@media (max-width: 600px) {
    .thinking-panel { width: 100vw; border-left: none; }
}
