/* ═══════════════════════════════════════════════════════════════
   智聊助手 — 全局样式 v1.0
   设计语言：深蓝紫渐变 | 毛玻璃交互 | 现代卡片 | 流体动效
   仿豆包核心体验，针对中文用户优化
════════════════════════════════════════════════════════════════ */

:root {
    /* 基础令牌 */
    --font-base: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-xl: 30px;
    --radius-circle: 50%;

    --sidebar-w: 280px;
    --sidebar-w-collapsed: 0px;
    --header-h: 64px;
    --input-max-w: 840px;

    --ease-out: cubic-bezier(0.19, 1, 0.22, 1);
    --transition: 0.3s var(--ease-out);
    --transition-fast: 0.15s var(--ease-out);
}

/* ══════════════════════
   暗色主题 (默认)
══════════════════════ */
[data-theme="dark"] {
    --bg-page: #0d0e12;
    --bg-sidebar: #16181d;
    --bg-content: #0d0e12;
    --bg-surface: #1e2025;
    --bg-surface-elevated: #282a30;
    --bg-hover: rgba(255, 255, 255, 0.06);
    --bg-active: rgba(255, 255, 255, 0.1);

    --border: rgba(255, 255, 255, 0.08);
    --border-strong: rgba(255, 255, 255, 0.15);

    --text-pri: #f5f5f7;
    --text-sec: #a1a1aa;
    --text-muted: #71717a;
    --text-invert: #000000;

    --accent: #8b5cf6;
    --accent-light: rgba(139, 92, 246, 0.15);
    --accent-glow: rgba(139, 92, 246, 0.3);
    --gradient-pri: linear-gradient(135deg, #8b5cf6 0%, #d946ef 100%);
    --gradient-surface: linear-gradient(135deg, rgba(30, 32, 37, 0.9) 0%, rgba(22, 24, 29, 0.9) 100%);

    --msg-user-bg: #8b5cf6;
    --msg-user-text: #ffffff;
    --msg-ai-bg: #1e2025;
    --msg-ai-text: #f5f5f7;

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.5);

    --glass-bg: rgba(22, 24, 29, 0.75);
    --glass-border: rgba(255, 255, 255, 0.1);

    --bg-code: #1e1e2e;
    --text-code: #e1e1e6;
}

/* ══════════════════════
   亮色主题
══════════════════════ */
[data-theme="light"] {
    --bg-page: #f9f9fb;
    --bg-sidebar: #ffffff;
    --bg-content: #f9f9fb;
    --bg-surface: #ffffff;
    --bg-surface-elevated: #f3f4f6;
    --bg-hover: rgba(0, 0, 0, 0.03);
    --bg-active: rgba(0, 0, 0, 0.06);

    --border: rgba(0, 0, 0, 0.08);
    --border-strong: rgba(0, 0, 0, 0.12);

    --text-pri: #1a1a1c;
    --text-sec: #4b5563;
    --text-muted: #9ca3af;
    --text-invert: #ffffff;

    --accent: #6d28d9;
    --accent-light: rgba(109, 40, 217, 0.1);
    --accent-glow: rgba(109, 40, 217, 0.2);
    --gradient-pri: linear-gradient(135deg, #6d28d9 0%, #c026d3 100%);
    --gradient-surface: linear-gradient(135deg, #ffffff 0%, #f9f9fb 100%);

    --msg-user-bg: #6d28d9;
    --msg-user-text: #ffffff;
    --msg-ai-bg: #ffffff;
    --msg-ai-text: #1a1a1c;

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 8px 20px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.12);

    --glass-bg: rgba(255, 255, 255, 0.8);
    --glass-border: rgba(0, 0, 0, 0.05);

    --bg-code: #f1f1f4;
    --text-code: #1a1a1c;
}

/* ══════════════════════
   全局重置
══════════════════════ */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

html,
body {
    height: 100%;
    width: 100%;
    overflow: hidden;
    font-family: var(--font-base);
    background: var(--bg-page);
    color: var(--text-pri);
    transition: background-color var(--transition), color var(--transition);
}

button {
    border: none;
    background: none;
    cursor: pointer;
    font-family: inherit;
    color: inherit;
    transition: var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

input,
textarea {
    border: none;
    background: none;
    outline: none;
    font-family: inherit;
    color: inherit;
}

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

.hidden {
    display: none !important;
}

/* ══════════════════════
   Auth Layout
══════════════════════ */
.auth-overlay {
    position: fixed;
    inset: 0;
    background: radial-gradient(circle at top left, #2d1b69, #0d0e12 60%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 20px;
    transition: opacity 0.5s ease;
}

.auth-overlay::before {
    content: '';
    position: absolute;
    inset: 0;
    background: url('https://grainy-gradients.vercel.app/noise.svg');
    opacity: 0.05;
    pointer-events: none;
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 40px;
    box-shadow: var(--shadow-lg);
    animation: authIn 0.6s var(--ease-out);
}

@keyframes authIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.auth-logo {
    text-align: center;
    margin-bottom: 30px;
}

.auth-logo-icon {
    font-size: 48px;
    margin-bottom: 12px;
    filter: drop-shadow(0 0 15px var(--accent-glow));
}

.auth-logo-text {
    font-size: 28px;
    font-weight: 800;
    letter-spacing: -0.5px;
    background: var(--gradient-pri);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.auth-logo-sub {
    font-size: 14px;
    color: var(--text-sec);
    margin-top: 4px;
}

.auth-tabs {
    display: flex;
    background: var(--bg-hover);
    padding: 4px;
    border-radius: var(--radius-md);
    margin-bottom: 24px;
}

.auth-tab {
    flex: 1;
    padding: 8px;
    font-size: 14px;
    font-weight: 500;
    border-radius: calc(var(--radius-md) - 2px);
    color: var(--text-sec);
}

.auth-tab.active {
    background: var(--bg-surface);
    color: var(--text-pri);
    box-shadow: var(--shadow-sm);
}

.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-sec);
    margin-bottom: 8px;
    padding-left: 4px;
}

.input-wrap {
    position: relative;
    display: flex;
    align-items: center;
    background: var(--bg-hover);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 0 14px;
    transition: var(--transition-fast);
}

.input-wrap:focus-within {
    background: var(--bg-surface);
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}

.input-icon {
    font-size: 18px;
    margin-right: 12px;
    opacity: 0.7;
}

.form-input {
    width: 100%;
    height: 44px;
    font-size: 15px;
}

.pwd-toggle,
.send-code-btn {
    padding: 0 8px;
    font-size: 14px;
    color: var(--accent);
    font-weight: 600;
    white-space: nowrap;
}

.send-code-btn:hover {
    text-decoration: underline;
}

.form-options {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    font-size: 14px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
    color: var(--text-sec);
}

.checkbox-custom {
    width: 18px;
    height: 18px;
    border: 2px solid var(--border-strong);
    border-radius: 4px;
    margin-right: 8px;
    position: relative;
    transition: var(--transition-fast);
}

input[type="checkbox"]:checked+.checkbox-custom {
    background: var(--accent);
    border-color: var(--accent);
}

input[type="checkbox"]:checked+.checkbox-custom::after {
    content: '✓';
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 12px;
}

.btn-primary {
    width: 100%;
    height: 48px;
    background: var(--gradient-pri);
    color: white;
    font-size: 16px;
    font-weight: 600;
    border-radius: var(--radius-md);
    box-shadow: 0 4px 12px var(--accent-glow);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px var(--accent-glow);
}

.btn-primary:active {
    transform: translateY(0);
}

.auth-divider {
    display: flex;
    align-items: center;
    margin: 24px 0;
    color: var(--text-muted);
    font-size: 13px;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

.auth-divider span {
    padding: 0 12px;
}

.oauth-btns {
    display: flex;
    gap: 12px;
}

.oauth-btn {
    flex: 1;
    height: 44px;
    background: var(--bg-hover);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
}

.oauth-btn:hover {
    background: var(--bg-surface-elevated);
}

.auth-switch {
    text-align: center;
    margin-top: 24px;
    font-size: 14px;
    color: var(--text-sec);
}

.link-btn {
    color: var(--accent);
    font-weight: 600;
}

.link-btn:hover {
    text-decoration: underline;
}

.guest-btn {
    width: 100%;
    margin-top: 16px;
    font-size: 13px;
    color: var(--text-muted);
}

/* ══════════════════════
   Main Layout
══════════════════════ */
.app {
    display: flex;
    width: 100%;
    height: 100%;
    position: relative;
    background: var(--bg-page);
}

.sidebar {
    width: var(--sidebar-w);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: width var(--transition);
}

.sidebar.collapsed {
    width: var(--sidebar-w-collapsed);
    overflow: hidden;
    border-right: none;
}

.sidebar-top {
    height: var(--header-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    flex-shrink: 0;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 8px;
}

.sidebar-logo-icon {
    font-size: 24px;
}

.sidebar-logo-text {
    font-weight: 700;
    font-size: 18px;
    background: var(--gradient-pri);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sidebar-toggle-btn {
    width: 32px;
    height: 32px;
    color: var(--text-muted);
    font-size: 20px;
    border-radius: var(--radius-sm);
}

.sidebar-toggle-btn:hover {
    background: var(--bg-hover);
    color: var(--text-pri);
}

.new-chat-btn {
    margin: 8px 16px;
    height: 48px;
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    gap: 10px;
    font-weight: 600;
    transition: var(--transition-fast);
}

.new-chat-btn:hover {
    border-color: var(--accent);
    background: var(--accent-light);
    color: var(--accent);
    transform: translateY(-1px);
}

.new-chat-icon {
    font-size: 18px;
}

.sidebar-search-wrap {
    padding: 8px 16px;
}

.sidebar-search {
    display: flex;
    align-items: center;
    background: var(--bg-hover);
    border-radius: var(--radius-md);
    padding: 0 12px;
    height: 36px;
}

.sidebar-search-icon {
    font-size: 14px;
    margin-right: 8px;
    opacity: 0.5;
}

.sidebar-search-input {
    width: 100%;
    font-size: 13px;
}

.chat-history-wrap {
    flex: 1;
    overflow-y: auto;
    padding: 12px 0;
}

.chat-history-label {
    padding: 0 20px 8px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.chat-history-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 0 8px;
}

.history-item {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 14px;
    color: var(--text-sec);
}

.history-item.active {
    background: var(--bg-active);
    color: var(--text-pri);
    font-weight: 500;
}

.history-item:hover:not(.active) {
    background: var(--bg-hover);
    color: var(--text-pri);
}

.history-icon {
    margin-right: 12px;
    font-size: 16px;
}

.history-title {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-actions {
    display: none;
    gap: 4px;
}

.history-item:hover .history-actions {
    display: flex;
}

.history-action-btn {
    width: 24px;
    height: 24px;
    font-size: 12px;
    border-radius: 4px;
    color: var(--text-muted);
}

.history-action-btn:hover {
    background: var(--bg-active);
    color: var(--text-pri);
}

.sidebar-bottom {
    padding: 12px 8px;
    border-top: 1px solid var(--border);
    background: var(--bg-sidebar);
}

.sidebar-bottom-actions {
    display: flex;
    justify-content: space-around;
    padding-bottom: 12px;
}

.sidebar-action-btn {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    font-size: 18px;
    color: var(--text-sec);
}

.sidebar-action-btn:hover {
    background: var(--bg-hover);
    color: var(--accent);
}

.user-profile {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition-fast);
    position: relative;
}

.user-profile:hover {
    background: var(--bg-hover);
}

.user-avatar {
    width: 36px;
    height: 36px;
    background: var(--gradient-pri);
    border-radius: var(--radius-circle);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: white;
    margin-right: 10px;
    box-shadow: 0 4px 10px rgba(139, 92, 246, 0.3);
}

.user-info {
    flex: 1;
    overflow: hidden;
}

.user-name {
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-status {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: var(--text-muted);
}

.status-dot {
    width: 6px;
    height: 6px;
    background: #22c55e;
    border-radius: 50%;
}

.user-menu {
    position: absolute;
    bottom: 70px;
    left: 8px;
    right: 8px;
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    padding: 6px;
    box-shadow: var(--shadow-lg);
    z-index: 1100;
    animation: slideUp 0.3s var(--ease-out);
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.user-menu-item {
    width: 100%;
    justify-content: flex-start;
    padding: 10px 12px;
    font-size: 14px;
    border-radius: var(--radius-sm);
    gap: 10px;
}

.user-menu-item:hover {
    background: var(--bg-hover);
}

.user-menu-item.danger {
    color: #ef4444;
}

.user-menu-sep {
    height: 1px;
    background: var(--border);
    margin: 6px 0;
}

/* ══════════════════════
   Main Content
══════════════════════ */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--bg-content);
    position: relative;
}

.chat-header {
    height: var(--header-h);
    display: flex;
    align-items: center;
    padding: 0 20px;
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(10px);
    background: var(--glass-bg);
    z-index: 900;
    gap: 12px;
}

.header-btn {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    color: var(--text-sec);
    font-size: 20px;
}

.header-btn:hover {
    background: var(--bg-hover);
    color: var(--text-pri);
}

.chat-title-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    overflow: hidden;
}

.chat-title {
    font-size: 16px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 4px 8px;
    border-radius: 4px;
}

.chat-title:focus {
    background: var(--bg-active);
    outline: none;
}

.edit-title-btn {
    font-size: 14px;
    opacity: 0.3;
}

.chat-title-wrap:hover .edit-title-btn {
    opacity: 0.7;
}

.header-actions {
    display: flex;
    gap: 8px;
}

.header-action-btn {
    padding: 0 12px;
    height: 38px;
    background: var(--bg-hover);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 600;
    gap: 8px;
}

.header-action-btn:hover {
    background: var(--bg-active);
    border-color: var(--border-strong);
}

.dropdown-arrow {
    font-size: 10px;
    opacity: 0.5;
}

/* Dropdown Panel */
.dropdown-panel {
    position: absolute;
    top: 70px;
    right: 20px;
    width: 280px;
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 12px;
    z-index: 1000;
    animation: dropIn 0.3s var(--ease-out);
}

@keyframes dropIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.dropdown-title {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 8px;
    padding: 0 8px;
    text-transform: uppercase;
}

.model-item,
.style-item {
    display: flex;
    align-items: center;
    padding: 10px;
    border-radius: var(--radius-md);
    cursor: pointer;
    margin-bottom: 4px;
    gap: 12px;
}

.model-item:hover,
.style-item:hover {
    background: var(--bg-hover);
}

.model-item.active,
.style-item.active {
    background: var(--accent-light);
    border: 1px solid var(--accent);
}

.model-item-icon,
.style-emoji {
    font-size: 20px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-surface);
    border-radius: 8px;
}

.model-item-info,
.style-name {
    flex: 1;
}

.model-item-name,
.style-name {
    font-size: 14px;
    font-weight: 600;
}

.model-item-desc,
.style-desc {
    font-size: 11px;
    color: var(--text-muted);
}

.model-badge {
    background: var(--accent);
    color: white;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
}

/* ══════════════════════
   Chat Area & Messages
══════════════════════ */
.chat-area {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    padding: 20px 0;
}

.welcome-screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    max-width: var(--input-max-w);
    margin: 0 auto;
    padding: 40px 20px;
    text-align: center;
}

.welcome-orb {
    position: relative;
    width: 120px;
    height: 120px;
    margin-bottom: 30px;
}

.orb-inner {
    position: absolute;
    inset: 15px;
    background: var(--gradient-pri);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 40px;
    z-index: 2;
    box-shadow: 0 0 30px var(--accent-glow);
}

.orb-ring {
    position: absolute;
    border: 2px solid var(--accent);
    border-radius: 50%;
    opacity: 0;
}

.ring-1 {
    inset: 0;
    animation: pulse 3s infinite;
}

.ring-2 {
    inset: -10px;
    animation: pulse 3s infinite 1s;
}

.ring-3 {
    inset: -20px;
    animation: pulse 3s infinite 2s;
}

@keyframes pulse {
    0% {
        transform: scale(0.8);
        opacity: 0.5;
    }

    100% {
        transform: scale(1.3);
        opacity: 0;
    }
}

.welcome-title {
    font-size: 32px;
    font-weight: 800;
    margin-bottom: 12px;
}

.welcome-sub {
    font-size: 16px;
    color: var(--text-sec);
    margin-bottom: 40px;
}

.welcome-suggestions {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    width: 100%;
}

.suggestion-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition);
}

.suggestion-card:hover {
    border-color: var(--accent);
    background: var(--accent-light);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.suggestion-icon {
    font-size: 20px;
    flex-shrink: 0;
}

/* Messages List */
.messages-list {
    display: flex;
    flex-direction: column;
    padding: 20px 0;
}

.message {
    display: flex;
    padding: 24px 20px;
    gap: 16px;
    animation: messageIn 0.4s var(--ease-out);
}

@keyframes messageIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.user {
    background: transparent;
}

.message.assistant {
    background: var(--bg-hover);
}

.msg-container {
    max-width: var(--input-max-w);
    margin: 0 auto;
    display: flex;
    gap: 16px;
    width: 100%;
}

.msg-avatar {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

.message.user .msg-avatar {
    background: var(--msg-user-bg);
    color: white;
}

.message.assistant .msg-avatar {
    background: var(--gradient-pri);
    color: white;
}

.msg-content-wrap {
    flex: 1;
    min-width: 0;
}

.msg-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.msg-author {
    font-size: 13px;
    font-weight: 700;
}

.msg-time {
    font-size: 11px;
    color: var(--text-muted);
}

.msg-text {
    font-size: 15px;
    line-height: 1.6;
    word-break: break-word;
}

.msg-text pre {
    background: var(--bg-code);
    color: var(--text-code);
    padding: 16px;
    border-radius: 12px;
    margin: 12px 0;
    overflow-x: auto;
    border: 1px solid var(--border);
}

.msg-text code {
    font-family: var(--font-mono);
    font-size: 0.9em;
    padding: 2px 4px;
    border-radius: 4px;
    background: var(--bg-code);
    color: var(--text-code);
}

.msg-text p {
    margin-bottom: 0.8em;
}

.msg-text p:last-child {
    margin-bottom: 0;
}

.msg-actions {
    display: flex;
    gap: 4px;
    margin-top: 12px;
    opacity: 0;
    transition: opacity 0.2s;
}

.message:hover .msg-actions {
    opacity: 1;
}

.msg-action-btn {
    padding: 6px 10px;
    font-size: 12px;
    color: var(--text-muted);
    border-radius: 6px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
}

.msg-action-btn:hover {
    background: var(--bg-active);
    color: var(--text-pri);
}

/* Typing Indicator */
.typing-indicator {
    display: inline-flex;
    gap: 4px;
    padding: 10px;
    background: var(--bg-surface-elevated);
    border-radius: 12px;
}

.typing-dot {
    width: 6px;
    height: 6px;
    background: var(--accent);
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {

    0%,
    60%,
    100% {
        transform: translateY(0);
        opacity: 0.3;
    }

    30% {
        transform: translateY(-4px);
        opacity: 1;
    }
}

/* ══════════════════════
   Input Area
══════════════════════ */
.input-area {
    padding: 0 20px 20px;
    max-width: var(--input-max-w);
    margin: 0 auto;
    width: 100%;
}

.input-box {
    background: var(--bg-surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: flex-end;
    padding: 10px 14px;
    box-shadow: var(--shadow-md);
    transition: var(--transition);
    position: relative;
}

.input-box:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-light);
}

.input-tools-left,
.input-tools-right {
    display: flex;
    gap: 4px;
    padding-bottom: 4px;
}

.input-tool-btn {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    font-size: 20px;
    color: var(--text-sec);
}

.input-tool-btn:hover {
    background: var(--bg-hover);
    color: var(--accent);
}

.textarea-wrap {
    flex: 1;
    position: relative;
    padding: 8px 12px;
}

.message-textarea {
    width: 100%;
    max-height: 200px;
    font-size: 15px;
    line-height: 1.5;
    resize: none;
    padding: 0;
}

.char-count {
    position: absolute;
    bottom: -15px;
    right: 0;
    font-size: 10px;
    color: var(--text-muted);
}

.send-btn {
    width: 40px;
    height: 40px;
    background: var(--accent);
    color: white;
    border-radius: 10px;
    font-size: 18px;
    box-shadow: 0 4px 10px var(--accent-glow);
}

.send-btn:hover:not(:disabled) {
    background: var(--accent);
    transform: scale(1.05);
}

.stop-btn {
    width: 40px;
    height: 40px;
    border: 2px solid var(--text-muted);
    border-radius: 10px;
    color: var(--text-muted);
}

.stop-btn:hover {
    border-color: #ef4444;
    color: #ef4444;
}

.input-footer {
    display: flex;
    justify-content: center;
    padding-top: 8px;
}

.input-hint {
    font-size: 12px;
    color: var(--text-muted);
}

/* File Preview Bar */
.file-preview-bar {
    background: var(--bg-surface-elevated);
    border-top-left-radius: var(--radius-lg);
    border-top-right-radius: var(--radius-lg);
    padding: 12px;
    border-left: 1px solid var(--border-strong);
    border-right: 1px solid var(--border-strong);
    border-top: 1px solid var(--border-strong);
    display: flex;
    align-items: center;
}

.file-previews {
    flex: 1;
    display: flex;
    gap: 12px;
    overflow-x: auto;
}

.file-pill {
    display: flex;
    align-items: center;
    background: var(--bg-hover);
    padding: 6px 10px;
    border-radius: 10px;
    border: 1px solid var(--border);
    gap: 8px;
    font-size: 12px;
}

.file-pill-img {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    object-fit: cover;
}

.file-remove {
    cursor: pointer;
    font-size: 14px;
    opacity: 0.5;
}

.file-remove:hover {
    opacity: 1;
    color: #ef4444;
}

/* ══════════════════════
   Settings & Profile Panels
══════════════════════ */
.settings-panel,
.profile-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    max-width: 500px;
    max-height: 80vh;
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    z-index: 2100;
}

.settings-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.settings-title {
    font-size: 18px;
    font-weight: 700;
}

.settings-close-btn {
    font-size: 20px;
    color: var(--text-muted);
}

.settings-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.settings-section {
    margin-bottom: 30px;
}

.settings-section-title {
    font-size: 12px;
    font-weight: 700;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 16px;
}

.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    gap: 20px;
}

.setting-row.vertical {
    flex-direction: column;
    align-items: flex-start;
}

.setting-info {
    flex: 1;
}

.setting-name {
    font-size: 15px;
    font-weight: 600;
}

.setting-desc {
    font-size: 13px;
    color: var(--text-muted);
}

/* Theme Switcher */
.theme-switcher {
    display: flex;
    background: var(--bg-hover);
    padding: 4px;
    border-radius: 12px;
}

.theme-btn {
    padding: 6px 12px;
    font-size: 13px;
    border-radius: 8px;
    color: var(--text-sec);
}

.theme-btn.active {
    background: var(--bg-surface);
    color: var(--text-pri);
    box-shadow: var(--shadow-sm);
}

/* Toggle Switch */
.toggle-switch {
    display: inline-block;
    position: relative;
    width: 44px;
    height: 24px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-track {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background-color: var(--border-strong);
    transition: .4s;
    border-radius: 24px;
}

.toggle-thumb {
    position: absolute;
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked+.toggle-track {
    background-color: var(--accent);
}

input:checked+.toggle-track .toggle-thumb {
    transform: translateX(20px);
}

/* Slider Custom */
.slider-control {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 200px;
}

.slider {
    flex: 1;
    height: 4px;
    background: var(--border-strong);
    border-radius: 5px;
    appearance: none;
    outline: none;
}

.slider::-webkit-slider-thumb {
    appearance: none;
    width: 16px;
    height: 16px;
    background: var(--accent);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 10px var(--accent-glow);
}

.slider-value {
    font-size: 13px;
    font-weight: 700;
    color: var(--accent);
    width: 30px;
}

/* ══════════════════════
   Toasts & Modals
══════════════════════ */
.toast-container {
    position: fixed;
    top: 30px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
}

.toast {
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-strong);
    border-radius: 12px;
    padding: 12px 24px;
    box-shadow: var(--shadow-lg);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 12px;
    animation: toastIn 0.3s var(--ease-out), toastOut 0.3s ease forwards 3s;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Confirmation Dialog */
.confirm-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5000;
}

.confirm-dialog {
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-lg);
    padding: 30px;
    width: 90%;
    max-width: 400px;
    text-align: center;
    box-shadow: var(--shadow-lg);
    animation: authIn 0.3s var(--ease-out);
}

.confirm-icon {
    font-size: 40px;
    margin-bottom: 16px;
}

.confirm-title {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 8px;
}

.confirm-msg {
    font-size: 15px;
    color: var(--text-sec);
    margin-bottom: 24px;
}

.confirm-actions {
    display: flex;
    gap: 12px;
}

.confirm-actions button {
    flex: 1;
    height: 44px;
    font-weight: 600;
    border-radius: var(--radius-md);
}

.btn-secondary {
    background: var(--bg-hover);
    color: var(--text-pri);
}

.btn-danger {
    background: #ef4444;
    color: white;
}

/* Voice Overlay */
.voice-overlay {
    position: fixed;
    inset: 0;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3000;
}

.voice-modal {
    text-align: center;
}

.voice-wave {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    height: 60px;
    margin-bottom: 20px;
}

.wave-bar {
    width: 4px;
    height: 20px;
    background: var(--accent);
    border-radius: 10px;
    animation: wave 1s infinite ease-in-out;
}

@keyframes wave {

    0%,
    100% {
        height: 20px;
    }

    50% {
        height: 60px;
    }
}

.wave-bar:nth-child(2) {
    animation-delay: 0.1s;
}

.wave-bar:nth-child(3) {
    animation-delay: 0.2s;
}

.wave-bar:nth-child(4) {
    animation-delay: 0.3s;
}

.wave-bar:nth-child(5) {
    animation-delay: 0.4s;
}

.wave-bar:nth-child(6) {
    animation-delay: 0.5s;
}

.wave-bar:nth-child(7) {
    animation-delay: 0.6s;
}

.voice-tip {
    font-size: 16px;
    font-weight: 500;
    margin-bottom: 20px;
}

.voice-stop-btn {
    padding: 10px 30px;
    background: #ef4444;
    color: white;
    border-radius: var(--radius-xl);
    font-weight: 600;
}

@keyframes toastOut {
    to {
        opacity: 0;
        transform: translateY(-20px);
    }
}

/* ══════════════════════
   Mobile Responsive
══════════════════════ */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        width: 280px;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }

    .sidebar.mobile-open {
        transform: translateX(0);
        box-shadow: 0 0 50px rgba(0, 0, 0, 0.5);
    }

    .main-content {
        width: 100%;
    }

    .welcome-suggestions {
        grid-template-columns: 1fr;
    }

    .auth-card {
        padding: 24px;
    }

    .header-action-btn span:not(.model-icon):not(.style-icon) {
        display: none;
    }
}