/* ============================================================
   智能咨询顾问 - 深海蓝主调 + 橙色强调色
   支持 浅色 / 深色 双主题（html[data-theme="dark"]）
   ============================================================ */

:root {
    /* 主色调：深海蓝 */
    --deep-blue-900: #081c33;
    --deep-blue-800: #0d2540;
    --deep-blue-700: #123055;
    --deep-blue-600: #1a3d6e;
    --deep-blue-500: #24518f;
    --deep-blue-400: #3a6cb5;
    --deep-blue-300: #5f8fce;
    --deep-blue-200: #8fb3dd;
    --deep-blue-100: #c3d8ef;

    /* 强调色：明亮温暖橙 */
    --orange-primary: #ff7a2f;
    --orange-light: #ff9a4d;
    --orange-dark: #e85d10;
    --orange-bg: #fff2e6;
    --orange-glow: rgba(255, 122, 47, 0.4);

    /* 语义色 */
    --success: #2ecc71;
    --warning: #f39c12;
    --danger: #e74c3c;
    --info: #3498db;

    /* ---------- 浅色主题（聊天区） ---------- */
    --chat-bg: #f0f4f8;
    --panel-bg: #ffffff;
    --panel-border: #e4eaf1;
    --input-bg: #f8fafc;
    --input-border: #dde5ee;
    --input-focus-bg: #ffffff;
    --text-main: #1e2d3d;
    --text-sub: #5d6d7e;
    --text-hint: #a5b6c9;
    --bubble-ai-bg: #ffffff;
    --bubble-ai-border: #e4eaf1;
    --scroll-thumb: #c6d2e0;
    --result-hover: #f0f4f8;
    --tag-bg: #f8fafc;
    --tag-text: var(--deep-blue-600);
    --hint-tag-bg: #f0f4f8;
    --type-dot: #b8c9db;
    --badge-ok-bg: #eaf7ef;
    --badge-ok-border: #c3e8d0;
    --badge-ok-text: #1e8e4e;
    --bubble-error-bg: #fdeaea;
    --bubble-error-border: #f2c4c4;
    --shadow-sm: 0 2px 8px rgba(8, 28, 51, 0.08);
    --shadow-md: 0 4px 16px rgba(8, 28, 51, 0.12);
    --shadow-lg: 0 8px 32px rgba(8, 28, 51, 0.18);
    --shadow-orange: 0 4px 16px rgba(255, 122, 47, 0.35);

    /* 尺寸 */
    --sidebar-width: 340px;
    --header-height: 64px;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    /* 过渡 */
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---------- 深色主题 ---------- */
[data-theme="dark"] {
    --chat-bg: #0b1424;
    --panel-bg: #101d33;
    --panel-border: #1e2d47;
    --input-bg: #0a1526;
    --input-border: #22334f;
    --input-focus-bg: #0d1a2e;
    --text-main: #dde7f3;
    --text-sub: #8ba5c0;
    --text-hint: #5d7492;
    --bubble-ai-bg: #16233a;
    --bubble-ai-border: #22334f;
    --scroll-thumb: #2a3d5c;
    --result-hover: #16233a;
    --tag-bg: #131f36;
    --tag-text: #8fb3dd;
    --hint-tag-bg: #16233a;
    --type-dot: #3a4f6e;
    --badge-ok-bg: rgba(46, 204, 113, 0.1);
    --badge-ok-border: rgba(46, 204, 113, 0.3);
    --badge-ok-text: #6ee7a0;
    --bubble-error-bg: rgba(231, 76, 60, 0.12);
    --bubble-error-border: rgba(231, 76, 60, 0.35);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.35);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.55);
}

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

html, body {
    height: 100%;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
                 "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    color: var(--text-main);
    background: var(--chat-bg);
    transition: background 0.3s ease, color 0.3s ease;
}

/* ============================================================
   主布局
   ============================================================ */
.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
    position: relative;
}

/* ============================================================
   左侧边栏（深浅主题下均为深海蓝，深色模式下更深）
   ============================================================ */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    height: 100%;
    background: linear-gradient(180deg, var(--deep-blue-900) 0%, var(--deep-blue-800) 60%, var(--deep-blue-700) 100%);
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 100;
    transition: width 0.35s cubic-bezier(0.4, 0, 0.2, 1), min-width 0.35s cubic-bezier(0.4, 0, 0.2, 1), transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 2px 0 20px rgba(8, 28, 51, 0.25);
    overflow: hidden;
}

[data-theme="dark"] .sidebar {
    background: linear-gradient(180deg, #060f1d 0%, #0a1628 60%, #0d1d35 100%);
    box-shadow: 2px 0 20px rgba(0, 0, 0, 0.5);
}

.sidebar.collapsed {
    width: 0;
    min-width: 0;
    margin-left: calc(-1 * var(--sidebar-width));
}

/* ---------- 侧边栏顶部 ---------- */
.sidebar-header {
    padding: 20px 16px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    position: relative;
    flex-shrink: 0;
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}

.logo-icon {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--orange-primary), var(--orange-light));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    box-shadow: 0 4px 14px var(--orange-glow);
    flex-shrink: 0;
}

.logo-title {
    font-size: 17px;
    font-weight: 700;
    color: #ffffff;
    letter-spacing: 0.5px;
    margin-bottom: 3px;
}

.logo-subtitle {
    font-size: 11px;
    color: var(--orange-light);
    font-weight: 600;
    letter-spacing: 0.3px;
}

.status-bar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    padding: 4px 10px;
    border-radius: 20px;
    font-weight: 500;
    letter-spacing: 0.2px;
}

.status-pill .dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
}

.status-pill.online {
    background: rgba(46, 204, 113, 0.15);
    color: #6ee7a0;
    border: 1px solid rgba(46, 204, 113, 0.3);
}
.status-pill.online .dot {
    background: var(--success);
    animation: pulse-green 2s infinite;
}

.status-pill.model {
    background: rgba(255, 122, 47, 0.12);
    color: var(--orange-light);
    border: 1px solid rgba(255, 122, 47, 0.3);
}
.status-pill.model .dot {
    background: var(--orange-primary);
    animation: pulse-orange 2s infinite;
}

.status-pill.offline {
    background: rgba(231, 76, 60, 0.15);
    color: #ff8a80;
    border: 1px solid rgba(231, 76, 60, 0.3);
}
.status-pill.offline .dot {
    background: var(--danger);
}

@keyframes pulse-green {
    0%, 100% { box-shadow: 0 0 0 0 rgba(46, 204, 113, 0.5); }
    50% { box-shadow: 0 0 0 5px rgba(46, 204, 113, 0); }
}

@keyframes pulse-orange {
    0%, 100% { box-shadow: 0 0 0 0 rgba(255, 122, 47, 0.5); }
    50% { box-shadow: 0 0 0 5px rgba(255, 122, 47, 0); }
}

/* 折叠按钮 */
.collapse-btn {
    position: absolute;
    top: 20px;
    right: 12px;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-muted, #8ba5c0);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.collapse-btn:hover {
    background: rgba(255, 122, 47, 0.2);
    color: var(--orange-light);
    border-color: rgba(255, 122, 47, 0.4);
}

/* 展开按钮（侧边栏折叠后显示） */
.expand-btn {
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 101;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    border: none;
    background: linear-gradient(135deg, var(--deep-blue-700), var(--deep-blue-500));
    color: #ffffff;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-md);
    transition: var(--transition);
}

.expand-btn:hover {
    background: linear-gradient(135deg, var(--orange-primary), var(--orange-light));
    transform: scale(1.05);
}

.expand-btn.visible {
    display: flex;
}

/* ---------- 侧边栏内容区 ---------- */
.sidebar-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}

.sidebar-body::-webkit-scrollbar {
    width: 5px;
}
.sidebar-body::-webkit-scrollbar-track {
    background: transparent;
}
.sidebar-body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 3px;
}
.sidebar-body::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 122, 47, 0.5);
}

/* Tab 切换 */
.sidebar-tabs {
    display: flex;
    padding: 12px 12px 0;
    gap: 6px;
    position: sticky;
    top: 0;
    background: var(--deep-blue-800);
    z-index: 10;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

[data-theme="dark"] .sidebar-tabs {
    background: #0a1628;
}

.tab-btn {
    flex: 1;
    padding: 10px 12px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: #8ba5c0;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.tab-btn:hover {
    color: #dce8f5;
    background: rgba(255, 255, 255, 0.05);
}

.tab-btn.active {
    color: var(--orange-light);
    background: rgba(255, 122, 47, 0.12);
    font-weight: 600;
    box-shadow: inset 0 -2px 0 var(--orange-primary);
}

.tab-content {
    display: none;
    padding: 12px;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.25s ease;
}

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

/* ---------- 设置区块 ---------- */
.settings-section {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: var(--radius-md);
    margin-bottom: 10px;
    overflow: hidden;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    cursor: pointer;
    color: #dce8f5;
    font-size: 13px;
    font-weight: 600;
    transition: var(--transition);
    user-select: none;
}

.section-header:hover {
    background: rgba(255, 122, 47, 0.08);
    color: var(--orange-light);
}

.section-header .chevron {
    transition: transform 0.25s ease;
    color: #8ba5c0;
}

.section-header.collapsed .chevron {
    transform: rotate(-90deg);
}

.section-body {
    padding: 4px 14px 14px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    animation: fadeIn 0.2s ease;
}

.section-body.hidden {
    display: none;
}

.setting-row {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.setting-row > label {
    font-size: 12px;
    color: #8ba5c0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 500;
}

.setting-row .val {
    color: var(--orange-light);
    font-weight: 600;
    font-family: "SF Mono", Consolas, monospace;
    font-size: 12px;
}

.setting-input, .setting-textarea {
    width: 100%;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(0, 0, 0, 0.25);
    color: #dce8f5;
    font-size: 13px;
    font-family: inherit;
    transition: var(--transition);
    outline: none;
}

.setting-input:focus, .setting-textarea:focus {
    border-color: var(--orange-primary);
    background: rgba(0, 0, 0, 0.35);
    box-shadow: 0 0 0 3px rgba(255, 122, 47, 0.15);
}

.setting-input::placeholder, .setting-textarea::placeholder {
    color: rgba(139, 165, 192, 0.5);
}

.setting-textarea {
    resize: vertical;
    min-height: 60px;
    line-height: 1.5;
}

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

.avatar-preview {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--orange-primary), var(--orange-light));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
    box-shadow: 0 3px 10px var(--orange-glow);
    overflow: hidden;
}

.avatar-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* 滑块 */
.slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 5px;
    border-radius: 3px;
    background: linear-gradient(to right, var(--orange-primary) var(--fill, 50%), rgba(255, 255, 255, 0.12) var(--fill, 50%));
    outline: none;
    cursor: pointer;
    transition: background 0.15s;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #ffffff;
    border: 3px solid var(--orange-primary);
    cursor: grab;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    transition: transform 0.15s;
}

.slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.slider::-webkit-slider-thumb:active {
    cursor: grabbing;
    transform: scale(1.1);
    background: var(--orange-light);
}

.slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #ffffff;
    border: 3px solid var(--orange-primary);
    cursor: grab;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.slider-labels {
    display: flex;
    justify-content: space-between;
    font-size: 10px;
    color: #8ba5c0;
    margin-top: 2px;
}

/* 开关组件 */
.toggle-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
}

.toggle {
    display: none;
}

.toggle-label {
    width: 44px;
    height: 24px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.15);
    position: relative;
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.toggle-label::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #ffffff;
    transition: var(--transition);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.toggle:checked + .toggle-label {
    background: linear-gradient(90deg, var(--orange-dark), var(--orange-primary));
    border-color: var(--orange-primary);
    box-shadow: 0 0 12px var(--orange-glow);
}

.toggle:checked + .toggle-label::after {
    left: 22px;
}

.toggle-text {
    font-size: 11px;
    color: #8ba5c0;
}

/* 锁定徽章 */
.locked-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    border-radius: var(--radius-sm);
    background: rgba(255, 122, 47, 0.1);
    border: 1px dashed rgba(255, 122, 47, 0.4);
    color: var(--orange-light);
    font-size: 12px;
    font-weight: 600;
    cursor: not-allowed;
}

/* 高级操作按钮 */
.advanced-row {
    flex-direction: row !important;
    gap: 8px;
}

.btn-danger-outline {
    flex: 1;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(231, 76, 60, 0.5);
    background: rgba(231, 76, 60, 0.08);
    color: #ff8a80;
    font-size: 12px;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    font-weight: 500;
}

.btn-danger-outline:hover {
    background: rgba(231, 76, 60, 0.2);
    border-color: var(--danger);
    transform: translateY(-1px);
}

.btn-danger-outline:active {
    transform: translateY(0);
}

/* ---------- 历史记录面板 ---------- */
.history-toolbar {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 12px;
}

.history-filter {
    display: flex;
    align-items: center;
    gap: 8px;
}

.date-input {
    flex: 1;
    padding: 7px 8px;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(0, 0, 0, 0.25);
    color: #dce8f5;
    font-size: 12px;
    font-family: inherit;
    outline: none;
    transition: var(--transition);
}

.date-input:focus {
    border-color: var(--orange-primary);
}

.date-input::-webkit-calendar-picker-indicator {
    filter: invert(0.8);
    cursor: pointer;
}

.date-sep {
    color: #8ba5c0;
    font-size: 12px;
}

.history-actions-top {
    display: flex;
    gap: 8px;
}

.btn-sm {
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.06);
    color: #dce8f5;
    font-size: 12px;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

.btn-sm:hover {
    background: rgba(255, 122, 47, 0.2);
    border-color: var(--orange-primary);
    color: var(--orange-light);
}

.btn-sm.btn-danger {
    border-color: rgba(231, 76, 60, 0.4);
    color: #ff8a80;
}

.btn-sm.btn-danger:hover {
    background: rgba(231, 76, 60, 0.2);
    border-color: var(--danger);
}

.btn-sm.btn-fav-only.active {
    background: rgba(255, 122, 47, 0.25);
    border-color: var(--orange-primary);
    color: var(--orange-light);
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.history-item {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-md);
    padding: 12px;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}

.history-item:hover {
    background: rgba(255, 122, 47, 0.08);
    border-color: rgba(255, 122, 47, 0.3);
    transform: translateX(2px);
}

.history-item.active {
    background: rgba(255, 122, 47, 0.12);
    border-color: var(--orange-primary);
}

.history-item.favorited::before {
    content: '⭐';
    position: absolute;
    top: 8px;
    right: 36px;
    font-size: 12px;
}

.history-summary {
    font-size: 12px;
    color: #dce8f5;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 6px;
    padding-right: 24px;
}

.history-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.history-time {
    font-size: 11px;
    color: #8ba5c0;
}

.history-msg-count {
    font-size: 10px;
    color: var(--orange-light);
    background: rgba(255, 122, 47, 0.12);
    padding: 2px 8px;
    border-radius: 10px;
}

.history-item-actions {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: var(--transition);
}

.history-item:hover .history-item-actions {
    opacity: 1;
}

.history-action-btn {
    width: 22px;
    height: 22px;
    border-radius: 6px;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    color: #8ba5c0;
    font-size: 11px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.history-action-btn:hover {
    background: var(--danger);
    color: white;
}

.history-action-btn.fav-btn:hover {
    background: var(--orange-primary);
}

.history-action-btn.fav-btn.active {
    color: var(--orange-light);
    opacity: 1;
}

.history-empty {
    text-align: center;
    padding: 40px 20px;
    color: #8ba5c0;
    font-size: 12px;
}

.history-empty .icon {
    font-size: 32px;
    margin-bottom: 10px;
    opacity: 0.5;
}

/* ---------- 侧边栏底部 ---------- */
.sidebar-footer {
    flex-shrink: 0;
    padding: 14px 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(0, 0, 0, 0.2);
}

.footer-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 12px;
    margin-bottom: 12px;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.stat-label {
    font-size: 11px;
    color: #8ba5c0;
}

.stat-value {
    font-size: 11px;
    color: #dce8f5;
    font-weight: 600;
    font-family: "SF Mono", Consolas, monospace;
}

.status-lights {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.light-group {
    display: flex;
    gap: 8px;
}

.light {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    transition: var(--transition);
}

.light-standby.active {
    background: var(--warning);
    box-shadow: 0 0 8px rgba(243, 156, 18, 0.7);
    animation: blink 2s infinite;
}

.light-online.active {
    background: var(--success);
    box-shadow: 0 0 8px rgba(46, 204, 113, 0.7);
    animation: blink 2s infinite;
}

.light-offline.active {
    background: var(--danger);
    box-shadow: 0 0 8px rgba(231, 76, 60, 0.7);
    animation: blink 1s infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.status-text {
    font-size: 11px;
    color: #8ba5c0;
}

/* ============================================================
   右侧聊天区域
   ============================================================ */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    min-width: 0;
    position: relative;
    background: var(--chat-bg);
    transition: background 0.3s ease;
}

/* ---------- 聊天头部 ---------- */
.chat-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 24px;
    background: var(--panel-bg);
    border-bottom: 1px solid var(--panel-border);
    box-shadow: var(--shadow-sm);
    flex-shrink: 0;
    z-index: 50;
    transition: background 0.3s ease, border-color 0.3s ease;
}

.search-wrap {
    flex: 1;
    max-width: 560px;
    position: relative;
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-hint);
    pointer-events: none;
}

.search-input {
    width: 100%;
    padding: 10px 16px 10px 40px;
    border-radius: var(--radius-md);
    border: 1.5px solid var(--input-border);
    background: var(--input-bg);
    font-size: 13px;
    font-family: inherit;
    color: var(--text-main);
    outline: none;
    transition: var(--transition);
}

.search-input:focus {
    border-color: var(--orange-primary);
    background: var(--input-focus-bg);
    box-shadow: 0 0 0 3px rgba(255, 122, 47, 0.12);
}

.search-input::placeholder {
    color: var(--text-hint);
}

.chat-header-right {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-left: auto;
}

/* 主题快捷切换按钮 */
.theme-toggle-btn {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: 1px solid var(--input-border);
    background: var(--input-bg);
    color: var(--text-main);
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    flex-shrink: 0;
}

.theme-toggle-btn:hover {
    border-color: var(--orange-primary);
    background: var(--orange-bg);
    transform: rotate(-15deg) scale(1.08);
}

[data-theme="dark"] .theme-toggle-btn:hover {
    background: rgba(255, 122, 47, 0.15);
}

.model-running-badge {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 6px 14px;
    border-radius: 20px;
    background: var(--badge-ok-bg);
    border: 1px solid var(--badge-ok-border);
    color: var(--badge-ok-text);
    font-size: 12px;
    font-weight: 600;
}

.model-running-badge.error {
    background: var(--bubble-error-bg);
    border-color: var(--bubble-error-border);
    color: var(--danger);
}

.pulse-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
    animation: pulse-green 2s infinite;
}

.model-running-badge.error .pulse-dot {
    background: var(--danger);
}

.conv-title {
    font-size: 13px;
    color: var(--text-sub);
    font-weight: 500;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ---------- 搜索结果面板 ---------- */
.search-results-panel {
    position: absolute;
    top: var(--header-height);
    left: 0;
    right: 0;
    max-height: 300px;
    background: var(--panel-bg);
    border-bottom: 1px solid var(--panel-border);
    box-shadow: var(--shadow-md);
    z-index: 40;
    display: flex;
    flex-direction: column;
}

.search-results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 24px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-main);
    border-bottom: 1px solid var(--panel-border);
}

.search-results-list {
    overflow-y: auto;
    padding: 8px 24px 16px;
}

.search-result-item {
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    margin-bottom: 4px;
}

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

.search-result-meta {
    font-size: 11px;
    color: var(--text-sub);
    margin-bottom: 4px;
}

.search-result-text {
    font-size: 13px;
    color: var(--text-main);
    line-height: 1.5;
}

.search-result-text mark {
    background: rgba(255, 122, 47, 0.25);
    color: var(--orange-dark);
    font-weight: 700;
    border-radius: 2px;
    padding: 0 1px;
}

[data-theme="dark"] .search-result-text mark {
    color: var(--orange-light);
}

/* ---------- 消息容器 ---------- */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    scroll-behavior: smooth;
}

.chat-messages::-webkit-scrollbar {
    width: 6px;
}
.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}
.chat-messages::-webkit-scrollbar-thumb {
    background: var(--scroll-thumb);
    border-radius: 3px;
}
.chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--orange-light);
}

/* 欢迎消息 */
.welcome-message {
    margin: auto;
    text-align: center;
    max-width: 560px;
    padding: 30px;
}

.welcome-avatar {
    width: 72px;
    height: 72px;
    border-radius: 22px;
    background: linear-gradient(135deg, var(--orange-primary), var(--orange-light));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 38px;
    margin: 0 auto 18px;
    box-shadow: var(--shadow-orange);
}

.welcome-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 10px;
}

.welcome-text {
    font-size: 14px;
    color: var(--text-sub);
    line-height: 1.7;
    margin-bottom: 24px;
}

.welcome-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
}

.welcome-tag {
    padding: 8px 16px;
    border-radius: 20px;
    background: var(--tag-bg);
    border: 1px solid var(--input-border);
    color: var(--tag-text);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.welcome-tag:hover {
    border-color: var(--orange-primary);
    color: var(--orange-dark);
    background: var(--orange-bg);
    transform: translateY(-2px);
}

[data-theme="dark"] .welcome-tag:hover {
    color: var(--orange-light);
    background: rgba(255, 122, 47, 0.12);
}

/* 消息行 */
.message-row {
    display: flex;
    gap: 12px;
    max-width: 85%;
    animation: messageIn 0.3s ease;
}

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

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

.message-row.assistant {
    align-self: flex-start;
}

.message-avatar {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 19px;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.message-row.assistant .message-avatar {
    background: linear-gradient(135deg, var(--orange-primary), var(--orange-light));
}

.message-row.user .message-avatar {
    background: linear-gradient(135deg, var(--deep-blue-500), var(--deep-blue-300));
    color: #ffffff;
    font-weight: 700;
    font-size: 14px;
}

.message-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.message-content-wrap {
    display: flex;
    flex-direction: column;
    gap: 5px;
    max-width: calc(100% - 50px);
}

.message-row.user .message-content-wrap {
    align-items: flex-end;
}

.message-bubble {
    padding: 12px 16px;
    border-radius: var(--radius-lg);
    font-size: 14px;
    line-height: 1.65;
    word-break: break-word;
    white-space: pre-wrap;
    box-shadow: var(--shadow-sm);
}

.message-row.user .message-bubble {
    background: linear-gradient(135deg, #4a90d9, #5ba0e9);
    color: #ffffff;
    border-top-right-radius: var(--radius-sm);
}

.message-row.assistant .message-bubble {
    background: var(--bubble-ai-bg);
    color: var(--text-main);
    border-top-left-radius: var(--radius-sm);
    border: 1px solid var(--bubble-ai-border);
}

.message-bubble.error {
    background: var(--bubble-error-bg) !important;
    border: 1px solid var(--bubble-error-border) !important;
    color: var(--danger) !important;
}

.message-bubble .highlight {
    background: rgba(255, 122, 47, 0.25);
    border-radius: 2px;
    padding: 0 1px;
}

.message-time {
    font-size: 11px;
    color: var(--text-hint);
    padding: 0 4px;
}

/* 打字中指示器 */
.typing-indicator {
    display: inline-flex;
    gap: 5px;
    padding: 6px 2px;
}

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

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

@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-6px); opacity: 1; }
}

/* 流式光标 */
.stream-cursor {
    display: inline-block;
    width: 2px;
    height: 16px;
    background: var(--orange-primary);
    animation: cursorBlink 0.8s infinite;
    vertical-align: middle;
    margin-left: 2px;
}

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

/* ---------- 输入区域 ---------- */
.chat-input-area {
    flex-shrink: 0;
    background: var(--panel-bg);
    border-top: 1px solid var(--panel-border);
    padding: 14px 24px 12px;
    box-shadow: 0 -2px 12px rgba(8, 28, 51, 0.04);
    transition: background 0.3s ease, border-color 0.3s ease;
}

[data-theme="dark"] .chat-input-area {
    box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.3);
}

.quick-buttons {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.quick-btn {
    padding: 6px 14px;
    border-radius: 18px;
    border: 1px solid var(--input-border);
    background: var(--tag-bg);
    color: var(--text-sub);
    font-size: 12px;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    font-weight: 500;
}

.quick-btn:hover {
    border-color: var(--orange-primary);
    color: var(--orange-dark);
    background: var(--orange-bg);
    transform: translateY(-1px);
}

[data-theme="dark"] .quick-btn:hover {
    color: var(--orange-light);
    background: rgba(255, 122, 47, 0.12);
}

.quick-btn:active {
    transform: translateY(0);
}

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

.message-input {
    flex: 1;
    min-height: 46px;
    max-height: 160px;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    border: 1.5px solid var(--input-border);
    background: var(--input-bg);
    font-size: 14px;
    font-family: inherit;
    color: var(--text-main);
    resize: none;
    outline: none;
    line-height: 1.5;
    transition: var(--transition);
}

.message-input:focus {
    border-color: var(--orange-primary);
    background: var(--input-focus-bg);
    box-shadow: 0 0 0 3px rgba(255, 122, 47, 0.12);
}

.message-input::placeholder {
    color: var(--text-hint);
}

/* 发送按钮 */
.send-btn {
    height: 46px;
    min-width: 96px;
    padding: 0 20px;
    border: none;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, var(--orange-primary), var(--orange-dark));
    color: #ffffff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: var(--transition);
    box-shadow: var(--shadow-orange);
    font-family: inherit;
    flex-shrink: 0;
}

.send-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 122, 47, 0.45);
}

.send-btn:active {
    transform: translateY(0);
}

.send-btn:disabled {
    background: linear-gradient(135deg, #95a5b6, #7f8fa0);
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

.send-btn.sending {
    background: linear-gradient(135deg, #95a5b6, #7f8fa0);
    animation: sendPulse 1.5s infinite;
}

@keyframes sendPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* 输入区底部 */
.input-bottom-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
}

.input-hints {
    display: flex;
    gap: 8px;
}

.hint-tag {
    font-size: 10px;
    color: var(--text-hint);
    background: var(--hint-tag-bg);
    padding: 3px 8px;
    border-radius: 4px;
}

.input-actions {
    display: flex;
    gap: 10px;
}

.btn-ghost {
    padding: 7px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--input-border);
    background: transparent;
    color: var(--text-sub);
    font-size: 12px;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    font-weight: 500;
}

.btn-ghost:hover {
    border-color: var(--deep-blue-400);
    color: var(--tag-text);
    background: var(--result-hover);
}

.btn-ghost.btn-warn:hover {
    border-color: var(--danger);
    color: var(--danger);
    background: var(--bubble-error-bg);
}

.btn-ghost:active, .btn-sm:active, .quick-btn:active {
    transform: scale(0.97);
}

/* ============================================================
   浮动组件
   ============================================================ */

/* 重连遮罩 */
.reconnect-overlay {
    position: fixed;
    inset: 0;
    background: rgba(8, 28, 51, 0.75);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.reconnect-box {
    background: var(--deep-blue-800);
    border: 1px solid rgba(255, 122, 47, 0.3);
    border-radius: var(--radius-lg);
    padding: 40px 60px;
    text-align: center;
    box-shadow: var(--shadow-lg);
}

.reconnect-box p {
    color: #dce8f5;
    font-size: 15px;
    margin-top: 16px;
    font-weight: 500;
}

.reconnect-progress {
    font-size: 12px !important;
    color: var(--orange-light) !important;
    margin-top: 8px !important;
    font-family: "SF Mono", Consolas, monospace;
}

.reconnect-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(255, 122, 47, 0.2);
    border-top-color: var(--orange-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

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

/* Toast 通知 */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1100;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    padding: 12px 20px;
    border-radius: var(--radius-md);
    background: var(--panel-bg);
    box-shadow: var(--shadow-lg);
    border-left: 4px solid var(--info);
    font-size: 13px;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 240px;
    animation: toastIn 0.3s ease;
}

.toast.success { border-left-color: var(--success); }
.toast.warning { border-left-color: var(--warning); }
.toast.error { border-left-color: var(--danger); }
.toast.info { border-left-color: var(--info); }

@keyframes toastIn {
    from { opacity: 0; transform: translateX(40px); }
    to { opacity: 1; transform: translateX(0); }
}

.toast.hide {
    animation: toastOut 0.3s ease forwards;
}

@keyframes toastOut {
    to { opacity: 0; transform: translateX(40px); }
}

/* 模态对话框 */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(8, 28, 51, 0.6);
    backdrop-filter: blur(2px);
    z-index: 1200;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-box {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius-lg);
    padding: 28px 32px;
    min-width: 360px;
    max-width: 440px;
    box-shadow: var(--shadow-lg);
}

.modal-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 12px;
}

.modal-message {
    font-size: 13px;
    color: var(--text-sub);
    line-height: 1.6;
    margin-bottom: 22px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.btn-danger {
    padding: 9px 22px;
    border: none;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    color: #ffffff;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

.btn-danger:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(231, 76, 60, 0.4);
}

/* 输入框无效提交抖动 */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-6px); }
    40%, 80% { transform: translateX(6px); }
}

/* ============================================================
   响应式适配
   ============================================================ */
@media (max-width: 1400px) {
    .message-row { max-width: 90%; }
}

@media (max-width: 1100px) {
    :root { --sidebar-width: 300px; }
    .chat-header { padding: 0 16px; }
    .chat-messages { padding: 16px; }
    .chat-input-area { padding: 12px 16px 10px; }
    .message-row { max-width: 95%; }
    .conv-title { display: none; }
}

@media (max-width: 800px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        z-index: 200;
        width: 300px;
    }
    .sidebar.collapsed {
        margin-left: -300px;
    }
    .expand-btn.visible {
        display: flex;
    }
    .welcome-title { font-size: 18px; }
    .quick-buttons { gap: 6px; }
    .quick-btn { padding: 5px 10px; font-size: 11px; }
    .send-btn { min-width: 70px; padding: 0 14px; }
    .send-btn span { display: none; }
    .input-hints { display: none; }
}
