:root {
            --primary: #4f5ff5;
            --primary-dark: #4338ca;
            --success: #10b981;
            --warning: #f59e0b;
            --danger: #ef4444;
            --bg: #f0f2f7;
            --card: #ffffff;
            --border: #e5e7eb;
            --text: #1e293b;
            --text-muted: #6b7280;
            --radius: 14px;
            --radius-sm: 10px;
            --shadow: 0 2px 4px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.03);
            --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
            /* 扩展变量 */
            --text-secondary: #94a3b8;
            --card-border: var(--border);
            --card-hover: rgba(79,95,245,0.06);
            --glass-bg: rgba(255,255,255,0.75);
            --glass-border: rgba(0,0,0,0.06);
        }

        [data-theme="dark"] {
            --primary: #818cf8;
            --primary-dark: #6366f1;
            --success: #34d399;
            --warning: #fbbf24;
            --danger: #f87171;
            --bg: #0f172a;
            --card: #1e293b;
            --border: #334155;
            --text: #f1f5f9;
            --text-muted: #94a3b8;
            --shadow: 0 2px 4px rgba(0,0,0,0.2);
            --text-secondary: #94a3b8;
            --card-border: #334155;
            --card-hover: rgba(129,140,248,0.08);
            --glass-bg: rgba(15,23,42,0.75);
            --glass-border: rgba(255,255,255,0.08);
        }

        * { margin:0; padding:0; box-sizing:border-box; }
        
        body {
            background: var(--bg);
            font-family: 'Inter', system-ui, -apple-system, sans-serif;
            color: var(--text);
            line-height: 1.6;
            height: 100vh;
            overflow: hidden;
            transition: background 0.3s ease, color 0.3s ease;
        }

        .app-container {
            display: flex;
            height: 100vh;
            max-width: 1440px;
            margin: 0 auto;
            position: relative;
            z-index: 1;
            padding: 12px;
            gap: 12px;
        }

        .sidebar {
            width: 240px;
            background: var(--glass-bg);
            backdrop-filter: blur(20px);
            -webkit-backdrop-filter: blur(20px);
            border: 1px solid var(--glass-border);
            border-radius: var(--radius);
            padding: 24px 16px;
            display: flex;
            flex-direction: column;
            color: var(--text);
            flex-shrink: 0;
            box-shadow: var(--shadow);
        }

        .sidebar-header {
            padding: 0 4px 20px;
            border-bottom: 1px solid var(--card-border);
            margin-bottom: 16px;
        }

        .brand {
            font-size: 22px;
            font-weight: 800;
            margin-bottom: 2px;
            background: linear-gradient(135deg, #818cf8, #c084fc);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
        }

        .slogan {
            font-size: 12px;
            color: var(--text-muted);
            font-weight: 400;
        }

        .sidebar-menu {
            flex: 1;
            overflow-y: auto;
            display: flex;
            flex-direction: column;
            gap: 2px;
        }

        .menu-item {
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 10px 14px;
            border-radius: var(--radius-sm);
            color: var(--text-secondary);
            font-size: 14px;
            cursor: pointer;
            transition: all var(--transition);
            font-weight: 500;
        }

        .menu-item:hover {
            background: var(--card-hover);
            color: var(--text);
        }

        .menu-item.active {
            background: rgba(99,102,241,0.15);
            color: var(--primary);
            border-left: 2px solid var(--primary);
        }

        .quota-display {
            background: rgba(99,102,241,0.1);
            border: 1px solid rgba(99,102,241,0.15);
            padding: 14px 16px;
            border-radius: var(--radius-sm);
            margin-top: auto;
        }

        .quota-display .label {
            font-size: 11px;
            color: var(--text-muted);
            text-transform: uppercase;
            letter-spacing: 0.5px;
            margin-bottom: 4px;
        }

        .quota-display .value {
            font-size: 22px;
            font-weight: 700;
            color: var(--primary);
        }

        .chat-main {
            flex: 1;
            display: flex;
            flex-direction: column;
            min-width: 0;
            background: var(--glass-bg);
            backdrop-filter: blur(20px);
            -webkit-backdrop-filter: blur(20px);
            border: 1px solid var(--glass-border);
            position: relative;
            border-radius: var(--radius);
            box-shadow: var(--shadow);
            overflow: hidden;
        }

        .chat-header {
            padding: 16px 24px;
            border-bottom: 1px solid var(--glass-border);
            display: flex;
            align-items: center;
            gap: 12px;
            flex-shrink: 0;
            background: var(--card);
        }

        .chat-title {
            font-size: 16px;
            font-weight: 700;
            color: var(--text);
        }

        .chat-subtitle {
            font-size: 12px;
            color: var(--text-muted);
            font-weight: 400;
        }

        .chat-messages {
            flex: 1;
            overflow-y: auto;
            padding: 24px;
            min-height: 0;
            scroll-behavior: smooth;
        }

        .chat-messages::-webkit-scrollbar,
        .sidebar-menu::-webkit-scrollbar { width: 4px; }
        .chat-messages::-webkit-scrollbar-track,
        .sidebar-menu::-webkit-scrollbar-track { background: transparent; }
        .chat-messages::-webkit-scrollbar-thumb,
        .sidebar-menu::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }

        .message {
            display: flex;
            gap: 12px;
            margin-bottom: 20px;
            animation: messageIn 0.35s ease;
        }

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

        .message.user { justify-content: flex-end; }

        .avatar {
            width: 36px;
            height: 36px;
            border-radius: 10px;
            background: linear-gradient(135deg, var(--primary), #a78bfa);
            display: flex;
            align-items: center;
            justify-content: center;
            color: white;
            font-weight: 700;
            flex-shrink: 0;
            font-size: 14px;
            box-shadow: 0 0 20px rgba(99,102,241,0.2);
        }

        .message.user .avatar {
            background: linear-gradient(135deg, #4f46e5, #7c3aed);
            order: 2;
        }

        .message-content {
            max-width: 72%;
        }

        .message.user .message-content { text-align: right; }

        .message-bubble {
            background: var(--card);
            border: 1px solid var(--card-border);
            padding: 14px 18px;
            border-radius: 14px 14px 14px 4px;
            display: inline-block;
            text-align: left;
            color: var(--text);
            font-size: 14px;
            line-height: 1.65;
        }

        .message.user .message-bubble {
            background: linear-gradient(135deg, rgba(99,102,241,0.2), rgba(168,85,247,0.15));
            border: 1px solid rgba(99,102,241,0.2);
            border-radius: 14px 14px 4px 14px;
            color: var(--text);
            box-shadow: 0 0 20px rgba(99,102,241,0.08);
        }

        .message-time {
            font-size: 11px;
            color: var(--text-muted);
            margin-top: 6px;
            opacity: 0.7;
        }

        .message.user .message-time { text-align: right; }

        .image-preview {
            margin-top: 10px;
            border-radius: var(--radius-sm);
            overflow: hidden;
        }

        .image-preview img {
            max-width: 100%;
            max-height: 280px;
            height: auto;
            display: block;
            border-radius: 8px;
        }

        .task-card {
            background: rgba(255,255,255,0.03);
            border-radius: var(--radius-sm);
            padding: 14px;
            margin-top: 10px;
            border: 1px solid var(--card-border);
        }

        .task-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 10px;
        }

        .status-badge {
            padding: 3px 10px;
            border-radius: 20px;
            font-size: 11px;
            font-weight: 600;
            display: inline-flex;
            align-items: center;
            gap: 4px;
        }

        .status-processing {
            background: rgba(99,102,241,0.15);
            color: var(--primary);
            border: 1px solid rgba(99,102,241,0.2);
        }

        .status-success {
            background: rgba(34,197,94,0.12);
            color: #4ade80;
            border: 1px solid rgba(34,197,94,0.2);
        }

        .status-error {
            background: rgba(239,68,68,0.12);
            color: #f87171;
            border: 1px solid rgba(239,68,68,0.2);
        }

        .result-container {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 10px;
            margin: 10px 0;
        }

        .result-image {
            border-radius: var(--radius-sm);
            overflow: hidden;
            background: rgba(0,0,0,0.3);
            border: 1px solid var(--card-border);
        }

        .result-image img, .result-image video {
            width: 100%;
            height: auto;
            display: block;
        }

        .result-label {
            font-size: 11px;
            text-align: center;
            padding: 6px;
            color: var(--text-muted);
            background: rgba(0,0,0,0.2);
        }

        .input-area {
            padding: 16px 24px;
            border-top: 1px solid var(--glass-border);
            flex-shrink: 0;
            background: var(--card);
        }

        .input-wrapper {
            display: flex;
            gap: 10px;
            align-items: flex-end;
        }

        .tool-btn {
            width: 42px;
            height: 42px;
            border-radius: 12px;
            border: 1px solid var(--card-border);
            background: var(--bg);
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 20px;
            transition: all var(--transition);
            flex-shrink: 0;
        }

        .tool-btn:hover {
            background: rgba(99,102,241,0.15);
            border-color: rgba(99,102,241,0.3);
            color: var(--text);
        }

        .input-box {
            flex: 1;
            display: flex;
            flex-direction: column;
            gap: 10px;
        }

        .text-input {
            width: 100%;
            padding: 12px 16px;
            border: 1px solid var(--card-border);
            border-radius: 12px;
            font-size: 14px;
            outline: none;
            font-family: inherit;
            resize: none;
            background: rgba(255,255,255,0.04);
            color: var(--text);
            transition: all var(--transition);
        }

        .text-input:focus {
            border-color: rgba(99,102,241,0.4);
            box-shadow: 0 0 0 3px rgba(99,102,241,0.08);
        }

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

        .config-bar {
            display: flex;
            align-items: center;
            gap: 8px;
            flex-wrap: wrap;
        }

        .config-group {
            display: flex;
            align-items: center;
            gap: 6px;
        }

        .config-label {
            font-size: 11px;
            color: var(--text-muted);
            white-space: nowrap;
            font-weight: 500;
            text-transform: uppercase;
            letter-spacing: 0.3px;
        }

        .config-select {
            padding: 5px 26px 5px 10px;
            border: 1px solid var(--card-border);
            border-radius: 8px;
            font-size: 12px;
            outline: none;
            background: var(--bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'%3E%3Cpath fill='%2394a3b8' d='M5 7L1 3h8z'/%3E%3C/svg%3E") no-repeat right 6px center;
            background-size: 10px;
            appearance: none;
            -webkit-appearance: none;
            cursor: pointer;
            color: var(--text);
            min-width: 76px;
            max-width: 140px;
            transition: border-color var(--transition);
        }

        .config-select:focus {
            border-color: rgba(99,102,241,0.4);
        }

        .config-select:hover {
            border-color: rgba(99,102,241,0.25);
        }

        .config-select optgroup {
            font-size: 12px;
            color: var(--text-muted);
            font-weight: 600;
            background: var(--card);
        }

        .config-select option {
            background: var(--card);
            color: var(--text);
        }

        .send-cost-row {
            display: flex;
            align-items: center;
            gap: 10px;
            margin-left: auto;
        }

        .image-preview-bar {
            display: none;
            align-items: center;
            gap: 8px;
            padding: 8px 12px;
            background: rgba(255,255,255,0.04);
            border-radius: var(--radius-sm);
            border: 1px solid var(--card-border);
        }
        .image-preview-bar img {
            width: 36px;
            height: 36px;
            border-radius: 6px;
            object-fit: cover;
            border: 1px solid var(--card-border);
        }
        .preview-label {
            font-size: 12px;
            color: var(--text-secondary);
            flex: 1;
        }
        .preview-remove {
            width: 22px;
            height: 22px;
            border-radius: 50%;
            border: none;
            background: rgba(239,68,68,0.2);
            color: #f87171;
            font-size: 12px;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: 0.15s;
            flex-shrink: 0;
            line-height: 1;
        }
        .preview-remove:hover { background: rgba(239,68,68,0.35); }

        .cost-info {
            font-size: 12px;
            color: var(--text-muted);
            white-space: nowrap;
        }

        .send-btn {
            width: 36px;
            height: 36px;
            border-radius: 10px;
            border: none;
            background: linear-gradient(135deg, var(--primary), #a78bfa);
            color: white;
            cursor: pointer;
            font-size: 16px;
            transition: all var(--transition);
            flex-shrink: 0;
            display: flex;
            align-items: center;
            justify-content: center;
            box-shadow: 0 0 20px rgba(99,102,241,0.2);
        }

        .send-btn:hover {
            transform: scale(1.05);
            box-shadow: 0 0 30px rgba(99,102,241,0.35);
        }

        .send-btn:active { transform: scale(0.95); }

        .typing-indicator {
            display: flex;
            gap: 4px;
            padding: 4px 0;
        }

        .typing-dot {
            width: 7px;
            height: 7px;
            background: var(--text-muted);
            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.4; }
            30% { transform: translateY(-6px); opacity: 1; }
        }

        .login-required {
            display: flex;
            align-items: center;
            justify-content: center;
            height: 100%;
            flex-direction: column;
            gap: 16px;
            text-align: center;
            padding: 40px;
        }

        .login-required .icon {
            font-size: 56px;
            margin-bottom: 8px;
            filter: drop-shadow(0 0 30px rgba(99,102,241,0.3));
        }

        .login-required .title {
            font-size: 22px;
            font-weight: 700;
            color: var(--text);
        }

        .login-required .desc {
            color: var(--text-muted);
            max-width: 360px;
            font-size: 14px;
        }

        .login-btn {
            padding: 12px 32px;
            background: linear-gradient(135deg, var(--primary), #a78bfa);
            color: white;
            border: none;
            border-radius: 12px;
            font-size: 14px;
            font-weight: 600;
            cursor: pointer;
            margin-top: 8px;
            transition: all var(--transition);
            box-shadow: 0 0 20px rgba(99,102,241,0.2);
        }

        .login-btn:hover {
            transform: translateY(-2px);
            box-shadow: 0 0 30px rgba(99,102,241,0.4);
        }

        .welcome-message .message-bubble {
            background: rgba(99,102,241,0.06);
            border: 1px solid rgba(99,102,241,0.12);
        }

        /* ========== 主题切换 & 头像 ========== */
        .theme-toggle {
            position: fixed;
            top: 16px;
            right: 16px;
            width: 40px;
            height: 40px;
            border-radius: 50%;
            background: var(--card);
            border: 1px solid var(--border);
            box-shadow: var(--shadow);
            cursor: pointer;
            display: none;
            align-items: center;
            justify-content: center;
            font-size: 18px;
            z-index: 1001;
            transition: 0.2s;
            color: var(--text);
        }
        .theme-toggle:hover { transform: scale(1.1); }

        /* ========== 移动端汉堡菜单 ========== */
        .menu-toggle {
            display: none;
            width: 38px;
            height: 38px;
            border-radius: 10px;
            border: 1px solid var(--card-border);
            background: var(--bg);
            color: var(--text);
            font-size: 20px;
            cursor: pointer;
            flex-shrink: 0;
            align-items: center;
            justify-content: center;
            transition: all var(--transition);
        }
        .menu-toggle:hover { background: rgba(99,102,241,0.15); border-color: rgba(99,102,241,0.3); }

        .mobile-overlay {
            display: none;
            position: fixed;
            top: 0; left: 0; right: 0; bottom: 0;
            background: rgba(0,0,0,0.5);
            z-index: 99;
            opacity: 0;
            transition: opacity 0.3s ease;
        }
        .mobile-overlay.show {
            display: block;
            opacity: 1;
        }

        .mobile-sidebar {
            display: none;
            position: fixed;
            top: 0; left: 0;
            width: 260px;
            height: 100vh;
            background: var(--bg);
            border-right: 1px solid var(--glass-border);
            z-index: 100;
            padding: 24px 16px;
            flex-direction: column;
            transform: translateX(-100%);
            transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        }
        .mobile-sidebar.open {
            display: flex;
            transform: translateX(0);
        }
        .mobile-sidebar .sidebar-header {
            padding: 0 4px 20px;
            border-bottom: 1px solid var(--card-border);
            margin-bottom: 16px;
        }
        .mobile-sidebar .sidebar-menu {
            flex: 1;
            display: flex;
            flex-direction: column;
            gap: 2px;
        }
        .mobile-sidebar .menu-item {
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 10px 14px;
            border-radius: var(--radius-sm);
            color: var(--text-secondary);
            font-size: 14px;
            cursor: pointer;
            transition: all var(--transition);
            font-weight: 500;
        }
        .mobile-sidebar .menu-item:hover {
            background: var(--card-hover);
            color: var(--text);
        }
        .mobile-sidebar .menu-item.active {
            background: rgba(99,102,241,0.15);
            color: var(--primary);
            border-left: 2px solid var(--primary);
        }
        .mobile-sidebar .quota-display {
            background: rgba(99,102,241,0.1);
            border: 1px solid rgba(99,102,241,0.15);
            padding: 14px 16px;
            border-radius: var(--radius-sm);
            margin-top: auto;
        }

        @media (max-width: 768px) {
            .app-container { padding: 8px; gap: 8px; }
            .sidebar { display: none; }
            .menu-toggle { display: flex; }

            .message-content { max-width: 90%; }
            .config-bar { gap: 6px; flex-wrap: wrap; }
            .config-select { min-width: 56px; max-width: 90px; font-size: 10px; padding: 4px 20px 4px 6px; }
            .config-label { font-size: 9px; }
            .input-area { padding: 8px 10px; }
            .input-wrapper { gap: 6px; align-items: center; }
            .text-input { font-size: 14px; padding: 8px 10px; }
            .image-preview-bar img { width: 30px; height: 30px; }
            .config-group { min-width: 0; flex-shrink: 1; }
            .chat-header { padding: 10px 12px; gap: 8px; }
            .chat-title { font-size: 14px; }
            .chat-subtitle { font-size: 11px; }
            .chat-messages { padding: 12px; }
            .message-bubble { padding: 10px 12px; font-size: 13px; }
            .message { gap: 8px; margin-bottom: 14px; }
            .avatar { width: 30px; height: 30px; font-size: 12px; }
            .send-cost-row { margin-left: auto; width: 100%; gap: 6px; flex-shrink: 0; justify-content: flex-end; padding-top: 4px; border-top: 1px solid var(--border); margin-top: 2px; }
            .send-btn { width: 38px; height: 38px; font-size: 16px; min-width: 38px; }
            .cost-info { font-size: 11px; white-space: nowrap; }
            .login-required .icon { font-size: 42px; }
            .login-required .title { font-size: 18px; }
            .login-required .desc { font-size: 13px; max-width: 280px; }
            .login-btn { padding: 12px 32px; font-size: 14px; min-height: 44px; }
            .tool-btn { width: 40px; height: 40px; font-size: 18px; flex-shrink: 0; min-width: 40px; }
            .menu-toggle { width: 42px; height: 42px; font-size: 22px; min-width: 42px; }
            .result-container { grid-template-columns: 1fr; }
            #durationSelect { min-width: 50px; }
            .fav-btn { min-height: 38px; padding: 8px 16px; }
            .template-chip { min-height: 34px; padding: 6px 14px; }
            .clear-chat-btn { min-height: 36px; padding: 8px 12px; }
            .quick-action-btn { min-height: 40px; padding: 10px 18px; }
            .theme-toggle { width: 44px; height: 44px; font-size: 20px; }
        }

        @media (max-width: 420px) {
            .config-select { min-width: 48px; max-width: 75px; font-size: 9px; padding: 3px 16px 3px 5px; }
            .config-label { font-size: 8px; }
            .config-bar { gap: 4px; }
            .chat-header { padding: 8px 10px; }
            .chat-title { font-size: 13px; }
            .input-area { padding: 6px 8px; }
            .tool-btn { width: 36px; height: 36px; min-width: 36px; font-size: 16px; }
            .send-btn { width: 36px; height: 36px; min-width: 36px; font-size: 15px; }
            .menu-toggle { width: 38px; height: 38px; min-width: 38px; font-size: 20px; }
        }

        /* ========== 快捷操作卡片 ========== */
        .quick-actions {
            display: flex;
            flex-wrap: wrap;
            gap: 8px;
            margin-top: 14px;
            justify-content: center;
        }
        .quick-action-btn {
            display: flex;
            align-items: center;
            gap: 6px;
            padding: 8px 16px;
            border: 1px solid var(--border);
            border-radius: 10px;
            background: var(--card);
            color: var(--text);
            font-size: 13px;
            cursor: pointer;
            transition: all var(--transition);
            font-weight: 500;
        }
        .quick-action-btn:hover {
            border-color: var(--primary);
            background: rgba(79,95,245,0.06);
            transform: translateY(-1px);
        }
        .quick-action-btn .icon { font-size: 18px; }



        /* ========== 收藏按钮 ========== */
        .fav-btn {
            display: inline-flex;
            align-items: center;
            gap: 4px;
            padding: 6px 14px;
            border: 1px solid var(--border);
            border-radius: 8px;
            background: transparent;
            color: var(--text-muted);
            font-size: 12px;
            cursor: pointer;
            transition: all 0.2s;
            margin: 6px 4px 0;
        }
        .fav-btn:hover { border-color: #f59e0b; color: #f59e0b; }
        .fav-btn.active { background: rgba(245,158,11,0.1); border-color: #f59e0b; color: #f59e0b; }

        /* ========== 清除对话按钮 ========== */
        .clear-chat-btn {
            display: none;
            align-items: center;
            gap: 4px;
            padding: 6px 12px;
            border: 1px solid var(--border);
            border-radius: 8px;
            background: transparent;
            color: var(--text-muted);
            font-size: 12px;
            cursor: pointer;
            transition: all 0.2s;
        }
        .clear-chat-btn:hover { border-color: var(--danger); color: var(--danger); }

        /* ========== 模板标签 ========== */
        .template-chips {
            display: flex;
            flex-wrap: wrap;
            gap: 6px;
            margin-top: 10px;
        }
        .template-chip {
            padding: 5px 12px;
            border: 1px solid var(--border);
            border-radius: 16px;
            background: var(--card);
            color: var(--text-muted);
            font-size: 12px;
            cursor: pointer;
            transition: all var(--transition);
        }
        .template-chip:hover {
            border-color: var(--primary);
            color: var(--primary);
            background: rgba(79,95,245,0.06);
        }



        /* ========== 空历史状态 ========== */
        .empty-state {
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 8px;
            padding: 40px 20px;
            color: var(--text-muted);
            font-size: 13px;
        }
        .empty-state .icon { font-size: 40px; opacity: 0.5; }

        /* ========== 历史记录页面 ========== */
        .history-page {
            display: none;
            position: fixed;
            top: 0; left: 0; right: 0; bottom: 0;
            background: var(--bg);
            z-index: 9999;
            flex-direction: column;
        }
        .history-page.active { display: flex; }
        .history-page-header {
            display: flex;
            align-items: center;
            gap: 12px;
            padding: 14px 20px;
            border-bottom: 1px solid var(--card-border);
            background: var(--card);
            font-size: 15px;
            font-weight: 600;
            flex-shrink: 0;
        }
        .history-back-btn {
            width: 32px; height: 32px;
            border: 1px solid var(--card-border);
            border-radius: 8px;
            background: var(--card);
            cursor: pointer; font-size: 16px;
            display: flex; align-items: center; justify-content: center;
            color: var(--text-muted);
            transition: all 0.2s;
        }
        .history-back-btn:hover { background: var(--card-hover); color: var(--text); }
        .history-page-list {
            flex: 1;
            overflow-y: auto;
            -webkit-overflow-scrolling: touch;
            padding: 16px;
            max-width: 720px;
            width: 100%;
            margin: 0 auto;
            scroll-behavior: smooth;
        }
        .history-date-divider {
            font-size: 11px;
            color: var(--text-muted);
            text-align: center;
            padding: 12px 0 6px;
        }
        .history-page-item {
            display: flex;
            gap: 10px;
            padding: 10px 12px;
            border-radius: 10px;
            margin-bottom: 4px;
            cursor: pointer;
            transition: background 0.2s;
        }
        .history-page-item:hover { background: var(--card-hover); }
        .history-page-item-avatar {
            width: 30px; height: 30px;
            border-radius: 8px;
            display: flex; align-items: center; justify-content: center;
            font-size: 12px;
            flex-shrink: 0;
        }
        .history-page-item.user .history-page-item-avatar { background: linear-gradient(135deg, #4f46e5, #7c3aed); color: #fff; }
        .history-page-item.assistant .history-page-item-avatar { background: var(--card); color: var(--primary); border: 1px solid var(--card-border); }
        .history-page-item-content { flex: 1; min-width: 0; }
        .history-page-item-sender { font-size: 11px; font-weight: 600; margin-bottom: 2px; }
        .history-page-item-sender.user { color: #4f46e5; }
        .history-page-item-sender.assistant { color: var(--primary); }
        .history-page-item-text {
            font-size: 13px;
            color: var(--text);
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }
        .history-page-item-time { font-size: 10px; color: var(--text-muted); margin-top: 2px; }
        .history-page-empty {
            display: flex; flex-direction: column; align-items: center; justify-content: center;
            height: 100%; color: var(--text-muted); font-size: 13px; gap: 8px;
        }
        .history-page-empty .icon { font-size: 40px; opacity: 0.5; }

        /* ========== 模型选择器面板 ========== */
        .model-picker-btn {
            display: flex;
            align-items: center;
            gap: 6px;
            padding: 5px 12px;
            border: 1px solid var(--card-border);
            border-radius: 8px;
            font-size: 12px;
            cursor: pointer;
            background: var(--bg);
            color: var(--text);
            min-width: 100px;
            max-width: 160px;
            transition: all var(--transition);
            white-space: nowrap;
        }
        .model-picker-btn:hover {
            border-color: rgba(99,102,241,0.4);
            background: rgba(99,102,241,0.06);
        }
        .model-picker-label {
            flex: 1;
            text-align: left;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            font-weight: 500;
        }
        .model-picker-arrow {
            font-size: 10px;
            color: var(--text-muted);
            transition: transform 0.2s;
            flex-shrink: 0;
        }
        .model-picker-btn.open .model-picker-arrow {
            transform: rotate(180deg);
        }

        /* 遮罩层 */
        .model-panel-overlay {
            display: none;
            position: fixed;
            top: 0; left: 0; right: 0; bottom: 0;
            background: rgba(0,0,0,0.3);
            z-index: 1000;
        }
        .model-panel-overlay.active { display: block; }

        /* 面板 */
        .model-panel {
            display: none;
            position: fixed;
            top: 50%; left: 50%;
            transform: translate(-50%, -50%);
            width: 520px;
            max-width: 92vw;
            max-height: 80vh;
            background: var(--card);
            border: 1px solid var(--card-border);
            border-radius: 16px;
            box-shadow: 0 20px 60px rgba(0,0,0,0.25);
            z-index: 1001;
            flex-direction: column;
            overflow: hidden;
            animation: panelIn 0.25s ease;
        }
        .model-panel.active { display: flex; }
        @keyframes panelIn {
            from { opacity: 0; transform: translate(-50%, -48%) scale(0.95); }
            to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
        }

        .model-panel-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 16px 20px;
            border-bottom: 1px solid var(--card-border);
            font-weight: 700;
            font-size: 15px;
            flex-shrink: 0;
        }
        .model-panel-close {
            width: 28px; height: 28px;
            border: none;
            border-radius: 6px;
            background: transparent;
            color: var(--text-muted);
            font-size: 16px;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: all 0.2s;
        }
        .model-panel-close:hover {
            background: rgba(239,68,68,0.15);
            color: var(--danger);
        }

        /* 分类标签 */
        .model-panel-tabs {
            display: flex;
            gap: 4px;
            padding: 10px 16px;
            border-bottom: 1px solid var(--card-border);
            flex-shrink: 0;
            overflow-x: auto;
        }
        .model-panel-tab {
            padding: 6px 14px;
            border-radius: 20px;
            font-size: 12px;
            border: 1px solid var(--card-border);
            background: transparent;
            color: var(--text-muted);
            cursor: pointer;
            white-space: nowrap;
            transition: all 0.2s;
            font-weight: 500;
        }
        .model-panel-tab:hover {
            border-color: var(--primary);
            color: var(--primary);
        }
        .model-panel-tab.active {
            background: var(--primary);
            color: white;
            border-color: var(--primary);
        }

        /* 搜索 */
        .model-panel-search {
            padding: 8px 16px;
            flex-shrink: 0;
        }
        .model-panel-search input {
            width: 100%;
            padding: 8px 12px;
            border: 1px solid var(--card-border);
            border-radius: 8px;
            font-size: 13px;
            background: var(--bg);
            color: var(--text);
            outline: none;
            transition: border-color 0.2s;
        }
        .model-panel-search input:focus {
            border-color: rgba(99,102,241,0.4);
        }

        /* 模型列表 */
        .model-panel-list {
            flex: 1;
            overflow-y: auto;
            padding: 8px 12px 16px;
            min-height: 0;
        }
        .model-panel-list::-webkit-scrollbar { width: 4px; }
        .model-panel-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }

        .model-card {
            display: flex;
            align-items: center;
            gap: 12px;
            padding: 12px 14px;
            border-radius: 12px;
            cursor: pointer;
            transition: all 0.2s;
            border: 1px solid transparent;
            margin-bottom: 4px;
        }
        .model-card:hover {
            background: var(--card-hover);
            border-color: var(--card-border);
        }
        .model-card.active {
            background: rgba(99,102,241,0.08);
            border-color: rgba(99,102,241,0.3);
        }
        .model-card.hidden { display: none; }

        .model-card-icon {
            width: 40px; height: 40px;
            border-radius: 10px;
            background: linear-gradient(135deg, rgba(99,102,241,0.15), rgba(168,85,247,0.1));
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 20px;
            flex-shrink: 0;
        }

        .model-card-info {
            flex: 1;
            min-width: 0;
        }
        .model-card-name {
            font-size: 13px;
            font-weight: 600;
            color: var(--text);
            margin-bottom: 2px;
        }
        .model-card-name .provider-tag {
            font-size: 10px;
            font-weight: 400;
            color: var(--text-muted);
            margin-left: 6px;
            padding: 1px 6px;
            border-radius: 4px;
            background: rgba(255,255,255,0.04);
            border: 1px solid var(--card-border);
        }
        .model-card-desc {
            font-size: 11px;
            color: var(--text-muted);
            margin-bottom: 4px;
        }

        /* 成功率条 */
        .model-card-rate {
            display: flex;
            align-items: center;
            gap: 6px;
        }
        .rate-bar {
            flex: 1;
            height: 4px;
            border-radius: 2px;
            background: rgba(255,255,255,0.06);
            overflow: hidden;
            max-width: 100px;
        }
        .rate-bar-fill {
            height: 100%;
            border-radius: 2px;
            transition: width 0.6s ease;
        }
        .rate-bar-fill.high { background: linear-gradient(90deg, #10b981, #34d399); }
        .rate-bar-fill.medium { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
        .rate-bar-fill.low { background: linear-gradient(90deg, #ef4444, #f87171); }
        .rate-text {
            font-size: 11px;
            font-weight: 600;
            white-space: nowrap;
        }
        .rate-text.high { color: #10b981; }
        .rate-text.medium { color: #f59e0b; }
        .rate-text.low { color: #ef4444; }

        .model-card-cost {
            font-size: 12px;
            font-weight: 700;
            color: var(--primary);
            white-space: nowrap;
            text-align: right;
            flex-shrink: 0;
            min-width: 50px;
        }
        .model-card-cost .cost-unit {
            font-size: 10px;
            font-weight: 400;
            color: var(--text-muted);
        }

        .model-panel-empty {
            text-align: center;
            padding: 30px;
            color: var(--text-muted);
            font-size: 13px;
        }

        @media (max-width: 768px) {
            .model-panel {
                width: 100%;
                max-width: 100%;
                border-radius: 16px 16px 0 0;
                bottom: 0;
                top: auto;
                left: 0;
                transform: none;
                max-height: 75vh;
                animation: panelInMobile 0.3s ease;
            }
            @keyframes panelInMobile {
                from { transform: translateY(100%); }
                to { transform: translateY(0); }
            }
            .model-picker-btn { min-width: 80px; max-width: 120px; font-size: 11px; }
            .model-picker-label { font-size: 11px; }
        }