
        :root {
            --primary: #00f0ff;
            --primary-light: #66f7ff;
            --primary-dark: #00c4d4;
            --neon-pink: #ff00ff;
            --neon-blue: #0066ff;
            --neon-orange: #ff6600;
            --neon-green: #00ff88;

            /* 纯黑背景，去掉所有动效 */
            --bg: #000000;
            --card-bg: #0a0a0a;
            --card-bg-hover: #111111;
            --text-main: #e0e0e0;
            --text-sub: #808080;
            --text-muted: #505050;
            --border: rgba(0, 240, 255, 0.1);
            --border-light: rgba(0, 240, 255, 0.05);
            --msg-user: linear-gradient(135deg, #00f0ff 0%, #0066ff 100%);
            --msg-ai: #0a0a0a;
            --msg-ai-border: rgba(255, 0, 255, 0.15);
            --danger: #ff3b30;
            --success: #00ff88;
            --warning: #ff6600;
            --btn-danger-bg: rgba(255, 59, 48, 0.12);
            --btn-danger-hover: rgba(255, 59, 48, 0.2);
            --btn-blue-bg: rgba(0, 240, 255, 0.08);
            --btn-blue-hover: rgba(0, 240, 255, 0.15);
            --input-bg: #111111;
            --input-bg-focus: #181818;
            --header-bg: #050505;
            --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.5);
            --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.6);
            --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.7);
            --radius-sm: 8px;
            --radius-md: 14px;
            --radius-lg: 20px;
            --radius-xl: 28px;
        }

        .header {
            background: var(--header-bg) !important;
            border-bottom: 1px solid rgba(0, 240, 255, 0.2) !important;
            box-shadow: 0 1px 0 rgba(0, 240, 255, 0.1), 0 4px 20px rgba(0, 0, 0, 0.3);
        }
        .status-bar {
            background: rgba(10, 10, 20, 0.95) !important;
            backdrop-filter: none;
            -webkit-backdrop-filter: none;
            border-top: 1px solid rgba(0, 240, 255, 0.1);
        }

        html, body {
            font-family: 'Geist', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
            background-color: #000000;
            margin: 0;
            padding: 0;
            height: 100vh;
            height: 100dvh;
            display: flex;
            flex-direction: column;
            color: var(--text-main);
            overflow: hidden;
            -webkit-font-smoothing: antialiased;
            -moz-osx-font-smoothing: grayscale;
        }

        /* 移动端：100% 跟随 WebView 实际高度（adjustResize 缩小时自动适配） */
        @media (max-width: 768px) {
            html, body {
                height: 100%;
                /* 覆盖 100dvh — dvh 取的是设备完整高度，adjustResize 下不会缩小 */
            }
        }

        /* 移除所有装饰性背景特效（网格线、颗粒纹理、粒子画布） */
        #particles-canvas { display: none; }

        /* 登录页面样式 */
        #login-area {
            display: flex;
            flex-direction: row;
            align-items: center;
            justify-content: center;
            height: 100%;
            padding: 20px;
            gap: 40px;
            overflow-y: auto;
        }

        @media (max-width: 768px) {
            #login-area {
                flex-direction: column;
                gap: 0px;
                justify-content: flex-start;
                padding-top: 20px;
            }
            .mascot-container {
                transform: scale(0.6);
                margin-bottom: -40px;
                margin-top: -10px;
            }
            .login-card {
                padding: 20px 16px;
            }
            .login-card h1 {
                margin: 0 0 16px 0;
                font-size: 20px;
            }
            .tabs {
                margin-bottom: 16px;
            }
        }

        /* 人偶样式 - 灵动小熊 */
        .mascot-container {
            width: 160px;
            height: 160px;
            position: relative;
            z-index: 10;
        }
        .mascot-ear {
            width: 44px;
            height: 44px;
            background: #E8E8E8;
            border: 4px solid #2C2C2C;
            border-radius: 50%;
            position: absolute;
            top: 5px;
            z-index: 1;
        }
        .mascot-ear.left { left: 5px; }
        .mascot-ear.right { right: 5px; }
        
        .mascot-head {
            width: 160px;
            height: 150px;
            background: #FFFFFF;
            border: 4px solid #2C2C2C;
            border-radius: 45% 45% 40% 40%;
            position: relative;
            z-index: 2;
            box-sizing: border-box;
            box-shadow: inset 0 -10px 0 rgba(0,0,0,0.05);
            overflow: hidden;
        }
        .mascot-face {
            position: absolute;
            width: 100%;
            height: 100%;
            display: flex;
            flex-direction: column;
            align-items: center;
            transition: transform 0.1s ease-out;
        }
        .mascot-eyes {
            display: flex;
            gap: 30px;
            margin-top: 50px;
            position: relative;
            z-index: 3;
        }
        .mascot-eye {
            width: 24px;
            height: 24px;
            background: #FFFFFF;
            border: 4px solid #2C2C2C;
            border-radius: 50%;
            position: relative;
            transition: background, color, border-color, box-shadow, opacity, transform 0.2s;
        }
        .mascot-pupil {
            width: 14px;
            height: 14px;
            background: #2C2C2C;
            border-radius: 50%;
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            transition: transform 0.1s ease-out;
        }
        .mascot-sparkle {
            width: 4px;
            height: 4px;
            background: #FFFFFF;
            border-radius: 50%;
            position: absolute;
            top: 2px;
            right: 2px;
        }
        .mascot-nose {
            width: 16px;
            height: 10px;
            background: #2C2C2C;
            border-radius: 50% 50% 50% 50% / 40% 40% 60% 60%;
            margin-top: 5px;
            position: relative;
            z-index: 3;
        }
        .mascot-mouth {
            width: 20px;
            height: 10px;
            border-bottom: 3px solid #2C2C2C;
            border-radius: 0 0 20px 20px;
            margin-top: 2px;
            transition: background, color, border-color, box-shadow, opacity, transform 0.2s;
        }
        .mascot-blush {
            width: 24px;
            height: 12px;
            background: rgba(255, 100, 100, 0.3);
            border-radius: 50%;
            position: absolute;
            top: 70px;
        }
        .mascot-blush.left { left: 25px; }
        .mascot-blush.right { right: 25px; }
        
        .mascot-hands {
            position: absolute;
            width: 100%;
            height: 100%;
            top: 0;
            left: 0;
            z-index: 4;
            pointer-events: none;
        }
        .mascot-hand {
            width: 44px;
            height: 44px;
            background: #FFFFFF;
            border: 4px solid #2C2C2C;
            border-radius: 50%;
            position: absolute;
            bottom: -20px;
            transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s;
            opacity: 0;
        }
        .mascot-hand.left {
            left: 10px;
            transform: translateY(40px) rotate(-45deg);
        }
        .mascot-hand.right {
            right: 10px;
            transform: translateY(40px) rotate(45deg);
        }

        /* 捂眼状态 */
        .mascot-container.hide-face .mascot-hand {
            opacity: 1;
        }
        .mascot-container.hide-face .mascot-hand.left {
            transform: translateY(-80px) translateX(25px) rotate(15deg);
        }
        .mascot-container.hide-face .mascot-hand.right {
            transform: translateY(-80px) translateX(-25px) rotate(-15deg);
        }
        .mascot-container.hide-face .mascot-eye {
            height: 8px;
            margin-top: 8px;
            border-radius: 8px;
            background: #2C2C2C;
            border: none;
        }
        .mascot-container.hide-face .mascot-pupil { display: none; }
        .mascot-container.hide-face .mascot-mouth {
            width: 10px;
            height: 10px;
            border: 3px solid #2C2C2C;
            border-radius: 50%;
            border-top-color: transparent;
            border-left-color: transparent;
            border-right-color: transparent;
            transform: translateY(-5px);
        }

        .login-card {
            background: rgba(12, 12, 25, 0.95);
            backdrop-filter: none;
            -webkit-backdrop-filter: none;
            border-radius: var(--radius-lg);
            box-shadow: 0 8px 32px rgba(0,0,0,0.4), inset 0 1px 0 rgba(0, 240, 255, 0.08);
            width: 100%;
            max-width: 360px;
            padding: 36px 28px;
            box-sizing: border-box;
            border: 1px solid rgba(0, 240, 255, 0.15);
            transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s ease;
        }

        .login-card:hover {
            box-shadow: 0 16px 48px rgba(0,0,0,0.5), 0 0 20px rgba(0, 240, 255, 0.1), inset 0 1px 0 rgba(0, 240, 255, 0.12);
            transform: translateY(-2px);
        }

        .login-card h1 {
            text-align: center;
            margin: 0 0 28px 0;
            font-size: 26px;
            font-weight: 700;
            letter-spacing: 1px;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 10px;
            color: var(--primary);
            text-shadow: 0 0 10px rgba(0, 240, 255, 0.5);
        }

        .login-card h1 i {
            font-size: 28px;
        }

        .form-group { margin-bottom: 16px; }
        .form-group input {
            width: 100%;
            padding: 14px 16px;
            border: 1.5px solid rgba(0, 240, 255, 0.15);
            border-radius: var(--radius-md);
            box-sizing: border-box;
            font-size: 16px;
            background: var(--bg);
            transition: background, color, border-color, box-shadow, opacity, transform 0.3s ease;
            color: var(--text-main);
        }
        .form-group input::placeholder {
            color: var(--text-muted);
        }
        .form-group input:focus {
            outline: none;
            border-color: var(--primary);
            background: var(--card-bg);
            box-shadow: 0 0 0 3px rgba(0, 240, 255, 0.15), 0 0 10px rgba(0, 240, 255, 0.1);
        }
        .form-group input:-webkit-autofill {
            -webkit-box-shadow: 0 0 0 30px var(--input-bg) inset !important;
            -webkit-text-fill-color: var(--text-main) !important;
            caret-color: var(--text-main);
        }

        .btn-primary {
            width: 100%;
            padding: 14px;
            background: linear-gradient(135deg, var(--primary) 0%, var(--neon-blue) 100%);
            color: #0a0a12;
            border: none;
            border-radius: var(--radius-md);
            font-size: 16px;
            font-weight: 600;
            cursor: pointer;
            margin-top: 8px;
            transition: background, color, border-color, box-shadow, opacity, transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
            letter-spacing: 1px;
            box-shadow: 0 2px 12px rgba(0, 240, 255, 0.3), inset 0 1px 0 rgba(255,255,255,0.2);
        }
        .btn-primary:hover {
            transform: translateY(-1px) scale(1.02);
            box-shadow: 0 4px 20px rgba(0, 240, 255, 0.4), 0 0 15px rgba(0, 240, 255, 0.2), inset 0 1px 0 rgba(255,255,255,0.2);
        }
        .btn-primary:active {
            transform: translateY(0) scale(0.98);
            box-shadow: 0 1px 8px rgba(0, 240, 255, 0.2);
        }
        .btn-primary:disabled {
            background: var(--text-muted);
            box-shadow: none;
            cursor: not-allowed;
            transform: none;
        }

        /* Tabs 样式 */
        .tabs {
            display: flex;
            margin-bottom: 24px;
            border-bottom: 2px solid var(--border-light);
            gap: 0;
        }
        .tab {
            flex: 1;
            text-align: center;
            padding: 12px 8px;
            cursor: pointer;
            color: var(--text-muted);
            font-weight: 600;
            font-size: 15px;
            transition: background, color, border-color, box-shadow, opacity, transform 0.3s ease;
            position: relative;
            border-radius: 0;
        }
        .tab::after {
            content: '';
            position: absolute;
            bottom: -2px;
            left: 50%;
            transform: translateX(-50%) scaleX(0);
            width: 60%;
            height: 2px;
            background: var(--primary);
            transition: transform 0.3s ease;
        }
        .tab:hover {
            color: var(--text-sub);
        }
        .tab.active {
            color: var(--primary);
        }
        .tab.active::after {
            transform: translateX(-50%) scaleX(1);
        }

        /* 登录方式切换样式 */
        .login-mode-switch {
            display: flex;
            gap: 8px;
            margin-bottom: 16px;
            padding: 4px;
            background: var(--input-bg);
            border-radius: var(--radius-md);
            border: 1px solid var(--border-light);
        }
        .login-mode-btn {
            flex: 1;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 6px;
            padding: 10px 12px;
            border: none;
            border-radius: var(--radius-sm);
            background: transparent;
            color: var(--text-muted);
            font-size: 14px;
            font-weight: 500;
            cursor: pointer;
            transition: background, color, border-color, box-shadow, opacity, transform 0.2s ease;
        }
        .login-mode-btn:hover {
            color: var(--text-sub);
            background: rgba(255, 255, 255, 0.05);
        }
        .login-mode-btn.active {
            background: var(--primary);
            color: white;
            box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
        }
        .login-mode-btn i {
            font-size: 14px;
        }

        .sms-group {
            display: flex;
            gap: 12px;
        }
        .sms-group input { flex: 1; }
        .btn-sms {
            width: 120px;
            background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
            color: white;
            border: none;
            border-radius: var(--radius-md);
            font-size: 14px;
            font-weight: 600;
            cursor: pointer;
            transition: background, color, border-color, box-shadow, opacity, transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
            box-shadow: 0 2px 8px rgba(59, 130, 246, 0.15), inset 0 1px 0 rgba(255,255,255,0.1);
        }
        .btn-sms:hover {
            transform: translateY(-1px);
            box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
        }
        .btn-sms:active {
            transform: translateY(0) scale(0.98);
        }
        .btn-sms:disabled {
            background: var(--text-muted);
            box-shadow: none;
            cursor: not-allowed;
            transform: none;
        }

        /* 主应用页面样式 */
        #app-area {
            display: none;
            flex-direction: column;
            height: 100%;
            max-width: 100%; /* [FULLWIDTH-20261110] 原 800px，已被下方 row 布局规则覆盖，统一放开 */
            margin: 0 auto;
            background-color: transparent;
            box-shadow: 0 0 20px rgba(0,0,0,0.05);
        }

        .header {
            background: var(--header-bg);
            padding: 32px 20px 16px 20px;
            display: flex;
            justify-content: space-between;
            align-items: center;
            border-bottom: 1px solid var(--border);
            z-index: 10;
            box-shadow: 0 2px 12px rgba(0,0,0,0.05);
            position: relative; /* [HEADPOP-20261110] 锚定功能弹出面板 */
        }

        .header-title {
            font-size: 18px;
            font-weight: 600;
            display: flex;
            align-items: center;
            gap: 8px;
        }
        
        .header-title i { color: var(--primary); font-size: 22px; }

        .btn-icon {
            background: none;
            border: 1px solid rgba(255, 59, 48, 0.2);
            color: var(--danger);
            font-size: 15px;
            font-weight: 500;
            padding: 8px 12px;
            border-radius: 16px;
            cursor: pointer;
            transition: background, color, border-color, box-shadow, opacity, transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
            display: flex;
            align-items: center;
            gap: 6px;
            background-color: var(--btn-danger-bg);
        }
        .btn-icon:hover {
            background-color: var(--btn-danger-hover);
            transform: translateY(-1px);
            box-shadow: 0 0 10px rgba(255, 59, 48, 0.15);
        }
        .btn-icon:active {
            transform: translateY(0) scale(0.97);
        }

        /* [NOTIFY-CENTER-20261127] 通知中心 */
        .notify-center-btn { position: relative; }
        .notify-badge {
            position: absolute; top: 2px; right: 2px; min-width: 17px; height: 17px;
            padding: 0 5px; border-radius: 9px;
            background: linear-gradient(135deg, #ff3b6b, #ef4444); color: #fff;
            font-size: 11px; line-height: 17px; text-align: center; font-weight: 700;
            box-shadow: 0 0 0 2px var(--header-bg, #050505), 0 0 8px rgba(255,59,107,.5);
        }
        .nc-panel {
            width: min(960px, 94vw); max-height: 88vh; display: flex; flex-direction: column;
            background: var(--card-bg); border: 1px solid var(--border);
            border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); overflow: hidden;
        }
        .nc-header {
            display: flex; align-items: center; justify-content: space-between;
            padding: 18px 24px; border-bottom: 1px solid var(--border); flex-shrink: 0;
            background: linear-gradient(180deg, rgba(0,240,255,.04), transparent);
        }
        .nc-title { display: flex; align-items: center; gap: 12px; }
        .nc-title-icon {
            width: 38px; height: 38px; border-radius: 11px; flex-shrink: 0;
            display: flex; align-items: center; justify-content: center; font-size: 18px;
            color: var(--primary); background: rgba(0,240,255,.1);
            border: 1px solid rgba(0,240,255,.22);
        }
        .nc-title h3 { margin: 0; font-size: 17px; font-weight: 600; letter-spacing: .3px; }
        .nc-subtitle { display: block; font-size: 12px; color: var(--text-sub); margin-top: 2px; min-height: 15px; }
        .nc-header-actions { display: flex; gap: 8px; align-items: center; }
        .nc-btn {
            padding: 7px 13px; font-size: 12px; border-radius: 8px; cursor: pointer;
            color: var(--primary); background: var(--btn-blue-bg); border: 1px solid rgba(0,240,255,.2);
            transition: background .15s, transform .1s;
        }
        .nc-btn:hover { background: var(--btn-blue-hover); }
        .nc-btn:active { transform: scale(.96); }
        .nc-btn-close { padding: 7px 11px; color: var(--text-sub); background: transparent; border-color: transparent; font-size: 15px; }
        .nc-btn-close:hover { color: var(--danger); background: var(--btn-danger-bg); }
        .nc-list { overflow-y: auto; flex: 1; padding: 16px 20px; display: flex; flex-direction: column; gap: 12px; }
        .nc-empty { padding: 64px 20px; text-align: center; color: var(--text-sub); }
        .nc-empty i { font-size: 42px; opacity: .35; display: block; margin-bottom: 14px; }
        .nc-item {
            border: 1px solid var(--border); border-radius: var(--radius-md); padding: 15px 18px;
            background: var(--card-bg-hover); position: relative; transition: border-color .15s, background .15s;
        }
        .nc-item:hover { border-color: rgba(0,240,255,.3); }
        .nc-item.unread { border-left: 3px solid var(--primary); background: rgba(0,240,255,.035); }
        .nc-meta { display: flex; align-items: center; gap: 10px; margin-bottom: 11px; }
        .nc-source {
            display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 6px;
            font-size: 12px; font-weight: 600; color: var(--primary);
            background: rgba(0,240,255,.1); border: 1px solid rgba(0,240,255,.18);
        }
        .nc-dot { width: 7px; height: 7px; border-radius: 50%; background: #ff3b6b; box-shadow: 0 0 7px rgba(255,59,107,.7); flex-shrink: 0; }
        .nc-time { font-size: 12px; color: var(--text-sub); font-variant-numeric: tabular-nums; }
        .nc-read-btn {
            margin-left: auto; padding: 4px 10px; font-size: 11px; border-radius: 6px; cursor: pointer;
            color: var(--text-sub); background: transparent; border: 1px solid var(--border);
        }
        .nc-read-btn:hover { color: var(--primary); border-color: rgba(0,240,255,.35); }
        .nc-body { font-size: 13.5px; line-height: 1.75; color: var(--text-main); word-break: break-word; user-select: text; -webkit-user-select: text; -webkit-touch-callout: default; }
        .nc-body p { margin: 7px 0; }
        .nc-body h1,.nc-body h2,.nc-body h3,.nc-body h4 { margin: 12px 0 6px; font-size: 14px; color: var(--primary); }
        .nc-body code { background: rgba(0,240,255,.08); padding: 1px 5px; border-radius: 4px; font-size: 12.5px; }
        .nc-body pre { background: rgba(0,0,0,.45); padding: 10px 12px; border-radius: 8px; overflow-x: auto; }
        .nc-body ul,.nc-body ol { margin: 7px 0; padding-left: 22px; }
        .nc-more {
            margin-top: 10px; padding: 5px 0; font-size: 12px; color: var(--primary);
            cursor: pointer; user-select: none; text-align: center; border-top: 1px dashed var(--border);
        }
        .nc-more:hover { color: var(--primary-light); }
        .nc-footer {
            padding: 11px 24px; border-top: 1px solid var(--border); flex-shrink: 0;
            font-size: 12px; color: var(--text-muted); text-align: center;
        }

        /* 手机端：贴合屏幕、收紧间距、正文字号适配 */
        @media (max-width: 768px) {
            .nc-panel { width: 96vw; max-height: 92vh; border-radius: 16px; }
            .nc-header { padding: 13px 15px; }
            .nc-title-icon { width: 34px; height: 34px; font-size: 16px; border-radius: 10px; }
            .nc-title h3 { font-size: 16px; }
            .nc-subtitle { font-size: 11px; }
            .nc-header-actions { gap: 6px; }
            .nc-btn { padding: 7px 10px; font-size: 11px; }
            .nc-list { padding: 12px 12px; gap: 10px; }
            .nc-item { padding: 13px 14px; border-radius: 12px; }
            .nc-meta { gap: 8px; margin-bottom: 9px; flex-wrap: wrap; }
            .nc-source { font-size: 11px; padding: 3px 8px; }
            .nc-time { font-size: 11px; }
            .nc-read-btn { font-size: 11px; padding: 4px 9px; }
            .nc-body { font-size: 13px; line-height: 1.7; }
            .nc-body p { margin: 4px 0; }
            .nc-body h1,.nc-body h2,.nc-body h3,.nc-body h4 { margin: 9px 0 4px; font-size: 13px; }
            .nc-footer { padding: 9px 14px; font-size: 11px; }
        }
        .btn-icon-blue {
            background: var(--btn-blue-bg);
            color: var(--primary);
            border: 1px solid rgba(0, 240, 255, 0.15);
        }
        .btn-icon-blue:hover {
            background: var(--btn-blue-hover);
            box-shadow: 0 0 10px rgba(0, 240, 255, 0.1);
        }

        .btn-tts-active {
            background: var(--primary) !important;
            color: white !important;
        }
        .btn-tts-active:hover {
            background: var(--primary);
            opacity: 0.9;
        }

        /* [HEADPOP-20261110] 功能按钮收纳：默认隐藏，点击「功能」按钮后以面板弹出（桌面端+移动端统一机制） */
        .header-actions {
            display: none;
            position: absolute;
            top: 60px;
            right: 20px;
            grid-template-columns: repeat(2, minmax(128px, max-content));
            gap: 6px 8px;
            padding: 12px;
            background: rgba(10, 10, 22, 0.96);
            border: 1px solid rgba(0, 240, 255, 0.18);
            border-radius: 16px;
            box-shadow: 0 12px 40px rgba(0,0,0,0.5), 0 0 18px rgba(0, 240, 255, 0.12);
            backdrop-filter: blur(10px);
            -webkit-backdrop-filter: blur(10px);
            z-index: 1001;
            transform-origin: top right;
        }

        .header-actions.open {
            display: grid;
            animation: headerActionsPop 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
        }

        /* 面板弹出特效：缩放+上浮+模糊聚合 */
        @keyframes headerActionsPop {
            from { opacity: 0; transform: translateY(-10px) scale(0.85); filter: blur(6px); }
            to   { opacity: 1; transform: translateY(0) scale(1);    filter: blur(0); }
        }

        /* 按钮错峰弹入特效：按钮按序号依次 spring 回弹 */
        .header-actions.open .btn-icon {
            animation: headerBtnPop 0.36s cubic-bezier(0.34, 1.56, 0.64, 1) backwards;
            animation-delay: calc(var(--pop-i, 0) * 30ms);
        }
        @keyframes headerBtnPop {
            from { opacity: 0; transform: translateY(8px) scale(0.6); }
            to   { opacity: 1; transform: translateY(0) scale(1); }
        }
        .header-actions.open .btn-icon:nth-child(1)  { --pop-i: 1; }
        .header-actions.open .btn-icon:nth-child(2)  { --pop-i: 2; }
        .header-actions.open .btn-icon:nth-child(3)  { --pop-i: 3; }
        .header-actions.open .btn-icon:nth-child(4)  { --pop-i: 4; }
        .header-actions.open .btn-icon:nth-child(5)  { --pop-i: 5; }
        .header-actions.open .btn-icon:nth-child(6)  { --pop-i: 6; }
        .header-actions.open .btn-icon:nth-child(7)  { --pop-i: 7; }
        .header-actions.open .btn-icon:nth-child(8)  { --pop-i: 8; }
        .header-actions.open .btn-icon:nth-child(9)  { --pop-i: 9; }
        .header-actions.open .btn-icon:nth-child(10) { --pop-i: 10; }
        .header-actions.open .btn-icon:nth-child(11) { --pop-i: 11; }
        .header-actions.open .btn-icon:nth-child(12) { --pop-i: 12; }
        .header-actions.open .btn-icon:nth-child(13) { --pop-i: 13; }
        /* [POP-FIX-20261113] 协议管理按钮 11-11 移入后成为第 14 个子元素，
           但 --pop-i 只定义到 13 → delay 落到 fallback 0s，跳出错峰序列
           （第一个就出现，视觉上"没有动态效果"）。补第 14 条。 */
        .header-actions.open .btn-icon:nth-child(14) { --pop-i: 14; }

        .header-actions .btn-icon {
            width: 100%;
            justify-content: flex-start;
            box-sizing: border-box;
        }

        .header-actions .btn-text {
            display: inline;
        }

        /* 四宫格按钮文字样式 - 全局生效 */
        .btn-text-grid {
            display: flex !important;
            flex-direction: row;
            align-items: center;
            line-height: 1.2;
            font-size: 12px;
        }

        /* [HEADPOP-20261110] 「功能」触发按钮：桌面端常显，点击弹出功能面板 */
        .btn-more-actions {
            display: flex;
            align-items: center;
            gap: 6px;
            background: var(--btn-blue-bg);
            border: 1px solid rgba(0, 240, 255, 0.15);
            color: var(--primary);
            font-size: 14px;
            font-weight: 500;
            cursor: pointer;
            padding: 8px 14px;
            border-radius: 16px;
            transition: background 0.3s, color 0.3s, box-shadow 0.3s, transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        }
        .btn-more-actions:hover {
            background: var(--btn-blue-hover);
            transform: translateY(-1px);
            box-shadow: 0 0 10px rgba(0, 240, 255, 0.1);
        }
        .btn-more-actions:active {
            transform: translateY(0) scale(0.97);
            background: var(--input-bg);
        }
        /* 面板展开时触发按钮高亮（反色），提示当前状态 */
        .header:has(.header-actions.open) .btn-more-actions {
            background: var(--primary);
            color: #001318;
            box-shadow: 0 0 14px rgba(0, 240, 255, 0.35);
        }

        .chat-container {
            flex: 1;
            overflow-y: auto;
            padding: 20px;
            display: flex;
            flex-direction: column;
            gap: 24px;
            position: relative;
            z-index: 1;
        }

        .session-chat-container {
            display: flex;
            flex-direction: column;
            gap: 24px;
        }

        .msg-wrapper {
            display: flex;
            flex-direction: column;
            max-width: 100%;
            width: 100%;
        }
        .msg-wrapper.user {
            align-items: flex-end;
        }
        .msg-wrapper.ai {
            align-items: flex-start;
        }

        .msg-row {
            display: flex;
            flex-direction: column;
            /* [LAYOUT-20261111] 宽屏下消息不再横贯全屏：限制最大阅读宽度 900px，
               小屏仍回落到 88% 自适应；配合下方 align-self:center 使消息流居中。 */
            max-width: min(88%, 900px);
            animation: msgIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
            /* 🔥 优化：content-visibility 让浏览器跳过视口外渲染，避免全量重排 */
            contain: layout style paint;
            content-visibility: auto;
            contain-intrinsic-size: 120px;
        }

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

        .msg-row.user, .msg-row.ai {
            align-self: center;
            align-items: flex-end;
            width: 100%;
        }

        .msg-bubble {
            padding: 14px 18px;
            border-radius: var(--radius-lg);
            font-size: 15px;
            line-height: 1.5;
            word-break: break-word;
            /* 🔥 修复：不能用 pre-wrap，marked 解析后的 HTML 文本中残留原始 \n 字符，
               会被 pre-wrap 渲染为可见换行，叠加在 <br> 和 <p> margin 之上造成双倍换行。
               <pre> 代码块自身有 white-space:pre 覆盖此设置，不受影响 */
            white-space: normal;
            position: relative;
            max-width: 100%;
            width: 100%;
            box-sizing: border-box;
            transition: box-shadow 0.3s ease;
            overflow-x: auto;
        }

        .msg-row.user .msg-bubble {
            background: var(--msg-user);
            color: #0a0a12;
            border-bottom-right-radius: var(--radius-sm);
            box-shadow: 0 2px 12px rgba(0, 240, 255, 0.25), 0 0 15px rgba(0, 240, 255, 0.1), inset 0 1px 0 rgba(255,255,255,0.2);
            border: 1px solid rgba(0, 240, 255, 0.3);
        }

        .msg-row.ai .msg-bubble {
            background: rgba(15, 15, 30, 0.97);
            color: var(--text-main);
            border-bottom-left-radius: var(--radius-sm);
            border: 1px solid rgba(255, 0, 255, 0.2);
            backdrop-filter: none;
            -webkit-backdrop-filter: none;
            box-shadow: 0 2px 12px rgba(255, 0, 255, 0.1), 0 0 10px rgba(255, 0, 255, 0.05), inset 0 1px 0 rgba(255,255,255,0.05);
        }

        .msg-row.ai.error .msg-bubble {
            background: rgba(255, 59, 48, 0.1);
            color: #fca5a5;
            border: 1px solid rgba(255, 59, 48, 0.25);
            box-shadow: 0 2px 12px rgba(255, 59, 48, 0.1);
        }

        /* ================= 聊天气泡内 markdown <details>/<summary> 适配 =================
           此前 user/ai 气泡里的 <details> 完全靠浏览器默认 + marked 错位解析产生的 wrapper 出现了深色覆盖
           (在 user 蓝青气泡文字 #0a0a12 + 黑色子元素背景下完全看不清)。
           这里用 !important 强力覆盖,确保 details 容器与所有子元素的背景/文字色都是确定的,
           不论 marked 如何错位解析,都能看见文字。 */
        .msg-bubble details,
        .msg-row.user .msg-bubble details,
        .msg-row.ai .msg-bubble details {
            display: block !important;
            background: rgba(255, 255, 255, 0.95) !important;
            color: #000000 !important;
            border: 1px solid rgba(128, 128, 128, 0.5) !important;
            border-left: 3px solid var(--primary) !important;
            border-radius: 6px !important;
            padding: 8px 12px !important;
            margin: 8px 0 !important;
            overflow: hidden !important;
        }
        .msg-row.ai .msg-bubble details {
            background: rgba(0, 0, 0, 0.45) !important;
            color: var(--text-main) !important;
            border-color: rgba(255, 255, 255, 0.12) !important;
        }
        /* 强制 details 内任何子元素背景透明,文字继承详情容器色,避免 marked 错位解析产生
           带未知背景的 wrapper 遮挡文字 */
        .msg-bubble details *,
        .msg-row.user .msg-bubble details *,
        .msg-row.ai .msg-bubble details *,
        .msg-bubble details > p,
        .msg-bubble details > div,
        .msg-bubble details > span,
        .msg-bubble details > pre,
        .msg-bubble details > code {
            background-color: transparent !important;
            background: transparent !important;
            color: inherit !important;
        }
        .msg-bubble summary {
            cursor: pointer !important;
            font-weight: 600 !important;
            user-select: none !important;
            padding: 4px 0 !important;
            outline: none !important;
            list-style: none !important;
        }
        .msg-bubble summary::-webkit-details-marker { display: none !important; }
        .msg-bubble summary::marker { display: none !important; content: '' !important; }
        .msg-bubble details[open] > summary {
            margin-bottom: 6px !important;
            padding-bottom: 6px !important;
            border-bottom: 1px dashed currentColor !important;
            opacity: 0.95 !important;
        }
        .msg-bubble details > :not(summary) {
            padding-left: 4px;
        }

        /* ================= 聊天气泡内 <code>/<pre> 适配 =================
           user-agent 默认 code { background: rgba(0,0,0,0.05) }、pre 在某些浏览器也有浅色背景,
           在 user 蓝青色气泡 + 黑字下叠加形成深色矩形,覆盖 inline code 文字。
           给两种气泡都明确浅色背景 + 字色,确保代码片段清晰可读。 */
        .msg-row.user .msg-bubble code,
        .msg-row.user .msg-bubble pre,
        .msg-row.user .msg-bubble pre code {
            background: rgba(255, 255, 255, 0.6) !important;
            color: #0a0a12 !important;
            border: 1px solid rgba(128, 128, 128, 0.3) !important;
            border-radius: 4px !important;
            padding: 1px 5px !important;
            font-family: "SF Mono","Fira Code","Consolas",monospace !important;
            font-size: 13px !important;
        }
        .msg-row.user .msg-bubble pre {
            padding: 8px 10px !important;
            white-space: pre-wrap !important;
            word-break: break-word !important;
            overflow-x: auto !important;
        }
        .msg-row.user .msg-bubble pre code {
            border: none !important;
            padding: 0 !important;
            background: transparent !important;
        }
        .msg-row.ai .msg-bubble code,
        .msg-row.ai .msg-bubble pre {
            background: rgba(255, 255, 255, 0.06) !important;
            color: var(--text-main) !important;
            border: 1px solid rgba(255, 255, 255, 0.08) !important;
            border-radius: 4px !important;
            padding: 1px 5px !important;
            font-family: "SF Mono","Fira Code","Consolas",monospace !important;
            font-size: 13px !important;
        }
        .msg-row.ai .msg-bubble pre { padding: 8px 10px !important; white-space: pre-wrap !important; word-break: break-word !important; overflow-x: auto !important; }

        .msg-time {
            font-size: 12px;
            color: var(--text-muted);
            margin-top: 6px;
            padding: 0 6px;
            display: flex;
            align-items: center;
            gap: 6px;
            flex-wrap: wrap;
        }

        .msg-time .btn-action {
            cursor: pointer;
            color: var(--text-muted);
            transition: background, color, border-color, box-shadow, opacity, transform 0.25s ease;
            padding: 4px;
            border-radius: 6px;
            font-size: 13px;
        }
        .msg-time .btn-action:hover {
            color: var(--primary);
            background: rgba(59, 130, 246, 0.08);
            transform: translateY(-1px);
        }
        .msg-time img.btn-action {
            display: inline-block;
            object-fit: contain;
            padding: 3px;
            border-radius: 4px;
            vertical-align: middle;
            width: 16px;
            height: 16px;
        }
        .msg-time img.btn-action:hover {
            background: rgba(59, 130, 246, 0.08);
            transform: translateY(-1px);
        }
        .msg-time .btn-action.active {
            color: #FF9500;
        }

        .msg-time .btn-action.quote-btn:hover {
            color: #007AFF;
            background: rgba(0, 122, 255, 0.1);
        }
        
        .quote-indicator {
            background: rgba(0, 240, 255, 0.05);
            border-left: 3px solid var(--primary);
            padding: 8px 12px;
            margin-bottom: 8px;
            border-radius: 4px;
            font-size: 13px;
            color: var(--text-main);
            max-width: 100%;
            overflow: hidden;
            flex-shrink: 0;
            display: flex;
            align-items: flex-start;
            justify-content: space-between;
            gap: 8px;
            box-shadow: 0 0 8px rgba(0, 240, 255, 0.05);
        }
        
        .quote-indicator .quote-label {
            color: var(--text-sub);
            font-size: 11px;
            margin-right: 6px;
        }
        
        /* [FIX-QUOTE-FULL-20261129] 引用内容完整入 DOM，默认折叠 3 行，点击展开滚动查看全文；禁止字符截断 */
        .quote-indicator .quote-content {
            flex: 1;
            min-width: 0;
            cursor: pointer;
            line-height: 1.5;
            word-break: break-word;
            white-space: pre-wrap;
            display: -webkit-box;
            -webkit-line-clamp: 3;
            -webkit-box-orient: vertical;
            overflow: hidden;
        }
        .quote-indicator .quote-content.quote-expanded {
            display: block;
            -webkit-line-clamp: unset;
            max-height: 40vh;
            overflow-y: auto;
        }
        
        .quote-indicator .btn-close-quote {
            cursor: pointer;
            color: var(--text-sub);
            font-size: 14px;
            padding: 2px 6px;
            border-radius: 4px;
            transition: background, color, border-color, box-shadow, opacity, transform 0.2s;
            flex-shrink: 0;
        }
        
        .quote-indicator .btn-close-quote:hover {
            color: var(--danger);
            background: rgba(239, 68, 68, 0.1);
        }

        .msg-quote {
            background: var(--btn-blue-bg);
            border-left: 3px solid var(--primary);
            padding: 6px 10px;
            margin-bottom: 6px;
            border-radius: 4px;
            font-size: 13px;
        }
        .msg-quote .msg-quote-label {
            color: var(--text-sub);
            font-size: 11px;
            margin-bottom: 2px;
        }
        /* [FIX-QUOTE-FULL-20261129] 同上：完整入 DOM，默认 3 行，点击展开滚动查看 */
        .msg-quote .msg-quote-content {
            color: var(--text-sub);
            line-height: 1.5;
            word-break: break-word;
            white-space: pre-wrap;
            cursor: pointer;
            display: -webkit-box;
            -webkit-line-clamp: 3;
            -webkit-box-orient: vertical;
            overflow: hidden;
        }
        .msg-quote .msg-quote-content.quote-expanded {
            display: block;
            -webkit-line-clamp: unset;
            max-height: 40vh;
            overflow-y: auto;
        }

        .input-area {
            background: rgba(12, 12, 25, 0.97);
            backdrop-filter: none;
            -webkit-backdrop-filter: none;
            padding: 12px 16px;
            padding-bottom: calc(12px + env(safe-area-inset-bottom));
            border-top: 1px solid rgba(0, 240, 255, 0.15);
            display: flex;
            flex-direction: column;
            gap: 8px;
            align-items: stretch;
            box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.2), 0 -1px 10px rgba(0, 240, 255, 0.05);
            position: relative;
            z-index: 10;
        }

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

        .input-box {
            flex: 1;
            background: var(--input-bg);
            border: 1.5px solid rgba(0, 240, 255, 0.15);
            border-radius: 22px;
            padding: 11px 18px;
            font-size: 15px;
            outline: none;
            transition: background, color, border-color, box-shadow, opacity, transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
            max-height: 120px;
            resize: none;
            overflow-y: auto;
            line-height: 1.5;
            color: var(--text-main);
            font-family: inherit;
        }
        .input-box:focus {
            border-color: var(--primary);
            background: var(--input-bg-focus);
            box-shadow: 0 0 0 3px rgba(0, 240, 255, 0.15), 0 0 10px rgba(0, 240, 255, 0.1);
        }
        .input-box::placeholder {
            color: var(--text-muted);
        }

        .btn-send {
            background: linear-gradient(135deg, var(--primary) 0%, var(--neon-blue) 100%);
            color: #0a0a12;
            border: none;
            width: 44px;
            height: 44px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            transition: background, color, border-color, box-shadow, opacity, transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
            flex-shrink: 0;
            margin-bottom: 2px;
            box-shadow: 0 2px 12px rgba(0, 240, 255, 0.3), 0 0 10px rgba(0, 240, 255, 0.15), inset 0 1px 0 rgba(255,255,255,0.2);
        }
        .btn-send i { font-size: 18px; margin-left: -1px; }
        .btn-send:hover { transform: scale(1.06); box-shadow: 0 4px 18px rgba(0, 240, 255, 0.4), 0 0 15px rgba(0, 240, 255, 0.2); }
        .btn-send:active { transform: scale(0.92); }
        .btn-send:disabled {
            background: var(--text-muted);
            box-shadow: none;
            cursor: not-allowed;
            transform: none;
        }

        .btn-stop {
            background: linear-gradient(135deg, #ff3b30 0%, #ff2d55 100%);
            color: white;
            border: none;
            width: 44px;
            height: 44px;
            border-radius: 50%;
            display: none;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            transition: background, color, border-color, box-shadow, opacity, transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
            flex-shrink: 0;
            margin-bottom: 2px;
            box-shadow: 0 2px 12px rgba(239, 68, 68, 0.3), inset 0 1px 0 rgba(255,255,255,0.1);
            animation: stopIn 0.3s ease;
        }
        @keyframes stopIn {
            from { transform: scale(0); opacity: 0; }
            to { transform: scale(1); opacity: 1; }
        }
        .btn-stop i { font-size: 18px; }
        .btn-stop:hover { transform: scale(1.06); box-shadow: 0 4px 18px rgba(239, 68, 68, 0.4); }
        .btn-stop:active { transform: scale(0.92); }

        /* ====== 消息状态徽标（回复中断 / Exit）====== */
        /* [FIX-INTERRUPT-BADGE-2026-11-11] 原先「（回复中断）」与 " Exit" 直接拼在正文末尾，
           渲染后与正文混读，也容易让人误以为模型自己说了这句话。现改为正文之外的独立徽标：
           正文只保留真正的回复内容，状态由徽标表达。 */
        .msg-status-badges {
            display: flex;
            flex-wrap: wrap;
            gap: 6px;
            margin-top: 10px;
        }
        .msg-status-badge {
            display: inline-flex;
            align-items: center;
            gap: 5px;
            padding: 2px 9px;
            border-radius: 10px;
            font-size: 11.5px;
            line-height: 1.7;
            font-weight: 500;
            letter-spacing: 0.3px;
            user-select: none;
            border: 1px solid transparent;
        }
        .msg-status-badge::before {
            content: '';
            width: 5px;
            height: 5px;
            border-radius: 50%;
            background: currentColor;
            opacity: 0.85;
        }
        .msg-status-exit {
            color: var(--text-sub, #808080);
            background: rgba(255, 255, 255, 0.06);
            border-color: rgba(255, 255, 255, 0.16);
        }
        .msg-status-interrupted {
            color: #ffb86b;
            background: rgba(255, 165, 0, 0.14);
            border-color: rgba(255, 165, 0, 0.5);
        }

        .alert {
            position: fixed;
            top: 20px;
            left: 50%;
            transform: translateX(-50%);
            padding: 12px 28px;
            border-radius: 30px;
            font-size: 14px;
            font-weight: 500;
            z-index: 10000;
            display: none;
            box-shadow: 0 8px 32px rgba(0,0,0,0.3), 0 0 15px rgba(0, 240, 255, 0.1);
            animation: alertIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
            backdrop-filter: none;
            -webkit-backdrop-filter: none;
            border: 1px solid rgba(0, 240, 255, 0.2);
        }
        @keyframes alertIn {
            from { opacity: 0; transform: translateX(-50%) translateY(-20px) scale(0.9); }
            to { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
        }
        .alert.error { background: linear-gradient(135deg, #ff3b30 0%, #ff2d55 100%); color: white; border-color: rgba(255, 59, 48, 0.3); box-shadow: 0 8px 32px rgba(0,0,0,0.3), 0 0 15px rgba(255, 59, 48, 0.15); }
        .alert.success { background: linear-gradient(135deg, #00ff88 0%, #00cc6a 100%); color: #0a0a12; border-color: rgba(0, 255, 136, 0.3); box-shadow: 0 8px 32px rgba(0,0,0,0.3), 0 0 15px rgba(0, 255, 136, 0.15); }
        .alert.warning { background: linear-gradient(135deg, #ffcc00 0%, #ff9500 100%); color: #1a1a00; border-color: rgba(255, 204, 0, 0.3); box-shadow: 0 8px 32px rgba(0,0,0,0.3), 0 0 15px rgba(255, 204, 0, 0.15); }
        
        .loading-dots { display: inline-block; }
        .loading-dots::after {
            content: '.';
            animation: dots 1.5s steps(5, end) infinite;
        }
        @keyframes dots { 0%, 20% { color: rgba(0,0,0,0); text-shadow: .25em 0 0 rgba(0,0,0,0), .5em 0 0 rgba(0,0,0,0); } 40% { color: inherit; text-shadow: .25em 0 0 rgba(0,0,0,0), .5em 0 0 rgba(0,0,0,0); } 60% { text-shadow: .25em 0 0 inherit, .5em 0 0 rgba(0,0,0,0); } 80%, 100% { text-shadow: .25em 0 0 inherit, .5em 0 0 inherit; } }

        /* ================= 思考过程折叠（<think> 块，赛博朋克风格，默认折叠，与正文分离） ================= */
        .think-block {
            background: rgba(124, 77, 255, 0.04);
            border: 1px solid rgba(124, 77, 255, 0.18);
            border-left: 3px solid rgba(124, 77, 255, 0.5);
            border-radius: 8px;
            margin: 10px 0;
            padding: 0;
            overflow: hidden;
            white-space: normal;
            box-shadow: 0 0 10px rgba(124, 77, 255, 0.05);
        }
        .think-block.open {
            background: rgba(124, 77, 255, 0.06);
            border-color: rgba(124, 77, 255, 0.25);
            box-shadow: 0 0 14px rgba(124, 77, 255, 0.08);
        }
        .think-block:not(.open) .think-body {
            display: none;
        }
        .think-body {
            padding: 4px 12px 10px 12px;
            font-size: 13px;
            line-height: 1.7;
            color: var(--text-sub);
            white-space: pre-wrap;
            border-left: 2px solid rgba(124, 77, 255, 0.2);
            margin: 0 8px 8px 12px;
            font-style: italic;
            opacity: 0.8;
        }
        .think-summary {
            padding: 9px 13px;
            cursor: pointer;
            font-size: 13px;
            font-weight: 600;
            color: #b794ff;
            display: flex;
            align-items: center;
            gap: 7px;
            user-select: none;
            background: rgba(124, 77, 255, 0.06);
            border-radius: 7px;
            transition: background 0.25s ease, color 0.25s ease;
            list-style: none;
            text-shadow: 0 0 8px rgba(124, 77, 255, 0.2);
        }
        .think-summary::-webkit-details-marker {
            display: none;
        }
        .think-summary::marker {
            display: none;
            content: '';
        }
        .think-summary:hover {
            background: rgba(124, 77, 255, 0.12);
            color: #d4bcff;
        }
        .think-summary i {
            font-size: 11px;
            transition: transform 0.2s;
            color: #b794ff;
        }
        .think-block.open .think-summary {
            border-radius: 7px 7px 0 0;
            background: rgba(124, 77, 255, 0.1);
        }
        .think-block.open .think-summary i {
            transform: rotate(90deg);
        }
        /* [LAYOUT-20261111] 思考过程序号徽标 + 字数预览 */
        .think-num {
            font-size: 10px;
            font-weight: 600;
            color: #d4bcff;
            background: rgba(124, 77, 255, 0.16);
            border: 1px solid rgba(124, 77, 255, 0.28);
            border-radius: 8px;
            padding: 0 6px;
            line-height: 1.6;
            flex-shrink: 0;
        }
        .think-len {
            font-size: 11px;
            font-weight: 400;
            color: var(--text-muted);
            opacity: 0.7;
            flex-shrink: 0;
        }

        /* ================= 历史压缩提示横幅（[FIX-A+C] 长会话反幻觉）================= */
        .history-compact-banner {
            margin: 8px 0;
            padding: 8px 12px;
            border-radius: 6px;
            font-size: 12px;
            line-height: 1.6;
            display: flex;
            flex-wrap: wrap;
            align-items: center;
            gap: 6px;
        }
        .history-compact-banner .compact-icon {
            font-size: 14px;
        }
        .history-compact-banner.compacting {
            background: #fff7e6;
            border: 1px solid #ffd591;
            color: #d46b08;
            animation: compact-pulse 1.2s ease-in-out infinite;
        }
        .history-compact-banner.compact-done {
            background: #f6ffed;
            border: 1px solid #b7eb8f;
            color: #389e0d;
        }
        .history-compact-banner.compact-failed {
            background: #fff1f0;
            border: 1px solid #ffa39e;
            color: #cf1322;
        }
        .history-compact-banner .compact-summary-details {
            width: 100%;
            margin-top: 4px;
            font-size: 12px;
        }
        .history-compact-banner .compact-summary-details summary {
            cursor: pointer;
            color: #389e0d;
            user-select: none;
        }
        .history-compact-banner .compact-summary-content {
            padding: 6px 10px;
            background: rgba(0, 0, 0, 0.04);
            border-radius: 4px;
            margin-top: 4px;
            color: #333;
            line-height: 1.5;
            white-space: pre-wrap;
        }
        @keyframes compact-pulse {
            0%, 100% { opacity: 1; }
            50% { opacity: 0.55; }
        }

/* ================= 工具调用折叠块 ================= */
.tool-calls-block {
    background: rgba(0, 240, 255, 0.03);
    border: 1px solid rgba(0, 240, 255, 0.1);
    border-radius: var(--radius-sm);
    margin: 8px 0;
    overflow: hidden;
    white-space: normal;
}
.tool-calls-block[open] {
    background: rgba(0, 240, 255, 0.04);
    border-color: rgba(0, 240, 255, 0.16);
    box-shadow: 0 0 12px rgba(0, 240, 255, 0.05);
}
/* 运行中 — 赛博琥珀 */
.tool-calls-block.state-running {
    background: rgba(255, 193, 7, 0.06);
    border-color: rgba(255, 193, 7, 0.2);
    box-shadow: 0 0 10px rgba(255, 193, 7, 0.06);
}
/* 完成 — 赛博绿 */
.tool-calls-block.state-success {
    background: rgba(0, 255, 136, 0.04);
    border-color: rgba(0, 255, 136, 0.14);
    box-shadow: 0 0 8px rgba(0, 255, 136, 0.04);
}
/* 错误 — 赛博红 */
.tool-calls-block.state-error {
    background: rgba(255, 59, 48, 0.05);
    border-color: rgba(255, 59, 48, 0.18);
    box-shadow: 0 0 8px rgba(255, 59, 48, 0.05);
}
.tool-calls-summary {
    padding: 9px 13px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-sub);
    display: flex;
    align-items: center;
    gap: 7px;
    user-select: none;
    background: rgba(0, 240, 255, 0.03);
    border-radius: var(--radius-sm);
    list-style: none;
    transition: background 0.25s ease, color 0.25s ease;
}
.tool-calls-summary::-webkit-details-marker { display: none; }
.tool-calls-summary::marker { display: none; content: ''; }
.tool-calls-summary:hover {
    background: rgba(0, 240, 255, 0.08);
    color: var(--primary);
}
.tool-calls-summary i { font-size: 11px; transition: transform 0.2s; color: var(--primary); opacity: 0.7; }
.tool-calls-block[open] .tool-calls-summary { border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
.tool-calls-block[open] .tool-calls-summary i { transform: rotate(90deg); }
.tool-calls-list { padding: 5px 10px 9px; }
.tool-call-item {
    padding: 9px 11px;
    border-radius: 6px;
    margin-bottom: 4px;
    font-size: 12.5px;
    line-height: 1.55;
    background: rgba(0, 240, 255, 0.02);
    border: 1px solid rgba(0, 240, 255, 0.07);
    transition: background 0.2s ease, border-color 0.2s ease;
}
.tool-call-item:last-child { margin-bottom: 0; }
.tool-call-item.running {
    background: rgba(255, 193, 7, 0.08);
    border-color: rgba(255, 193, 7, 0.2);
}
.tool-call-item.success {
    background: rgba(0, 255, 136, 0.05);
    border-color: rgba(0, 255, 136, 0.14);
}
.tool-call-item.error {
    background: rgba(255, 59, 48, 0.06);
    border-color: rgba(255, 59, 48, 0.16);
}
        .tool-call-header {
            display: flex;
            align-items: center;
            gap: 6px;
            font-weight: 500;
        }
        .tool-call-item.running .tool-call-header { color: #e65100; }
        .tool-call-item.success .tool-call-header { color: #2e7d32; }
        .tool-call-item.error .tool-call-header { color: #c62828; }
        .tool-call-header .tool-call-time { margin-left: auto; font-weight: bold; font-size: 12px; }
        /* [FIX-2026-08-22] 工具执行状态标签（待执行/执行中/已完成/失败），赛博朋克荧光风 */
        .tool-call-state {
            margin-left: auto;
            font-size: 11px;
            font-weight: 600;
            padding: 1px 8px;
            border-radius: 10px;
            letter-spacing: 0.3px;
            white-space: nowrap;
            flex-shrink: 0;
        }
        .tool-call-state.running {
            color: #ffd740;
            background: rgba(255, 193, 7, 0.12);
            border: 1px solid rgba(255, 193, 7, 0.3);
            text-shadow: 0 0 6px rgba(255, 193, 7, 0.45);
            animation: tool-state-pulse 1.2s ease-in-out infinite;
        }
        .tool-call-state.success {
            color: #00ff88;
            background: rgba(0, 255, 136, 0.08);
            border: 1px solid rgba(0, 255, 136, 0.25);
            text-shadow: 0 0 6px rgba(0, 255, 136, 0.35);
        }
        .tool-call-state.error {
            color: #ff5f52;
            background: rgba(255, 59, 48, 0.08);
            border: 1px solid rgba(255, 59, 48, 0.3);
        }
        @keyframes tool-state-pulse {
            0%, 100% { opacity: 1; }
            50% { opacity: 0.55; }
        }
        .tool-call-meta {
            font-size: 12px;
            color: var(--text-sub);
            padding-left: 22px;
            margin-top: 2px;
        }
.tool-call-item details {
    margin-top: 5px;
    padding-left: 22px;
}
.tool-call-item details summary {
    font-size: 11.5px;
    color: var(--text-muted);
    cursor: pointer;
    user-select: none;
    transition: color 0.2s ease;
}
.tool-call-item details summary:hover { color: var(--primary); }
.tool-call-item details pre {
    margin: 4px 0 0;
    padding: 7px 10px;
    font-size: 11.5px;
    line-height: 1.55;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
    border: 1px solid rgba(0, 240, 255, 0.08);
    overflow-x: auto;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
    user-select: text;
    -webkit-user-select: text;
}
.tool-call-item.error .tool-call-meta { color: #ff6b6b; }

        /* ================= 工具结果中的 think 块（默认折叠，与正文颜色区分） ================= */
        .tool-result-content {
            margin: 4px 0 0;
        }
        /* 正文文本 —— 沿用工具结果 <pre> 的青色系风格 */
        .tool-result-content .tool-result-text {
            margin: 4px 0;
            padding: 7px 10px;
            font-size: 11.5px;
            line-height: 1.55;
            background: rgba(0, 0, 0, 0.3);
            border-radius: 4px;
            border: 1px solid rgba(0, 240, 255, 0.08);
            white-space: pre-wrap;
            word-break: break-word;
            user-select: text;
            -webkit-user-select: text;
            color: var(--text-main);
        }
        /* think 块 —— 紫色系，与正文（青色系）形成明显对比 */
        .tool-result-content .think-block {
            margin: 6px 0;
        }
        .tool-result-content .think-summary {
            font-size: 11.5px;
            padding: 7px 11px;
        }
        .tool-result-content .think-body {
            font-size: 11.5px;
            line-height: 1.6;
        }

        /* 移动端：折叠态隐藏 meta 和 details，只保留 header */
        .tool-call-item.tool-call-details-hidden .tool-call-meta { display: none; }
        .tool-call-item.tool-call-details-hidden details { display: none; }
        /* 折叠态 header 提示可点击 */
        .tool-call-item.tool-call-details-hidden .tool-call-header { position: relative; }
        .tool-call-item.tool-call-details-hidden .tool-call-header::after {
            content: ' ▾';
            font-size: 10px;
            opacity: 0.5;
            margin-left: 4px;
        }
        .tool-call-item:not(.tool-call-details-hidden) .tool-call-header::after {
            content: ' ▴';
            font-size: 10px;
            opacity: 0.5;
            margin-left: 4px;
        }

        /* 底部实时工具栏 */
        .xcrab-tool-bar {
            display: none;
            margin-bottom: 8px;
        }
        /* 展开态 */
        .xcrab-tool-bar.expanded {
            max-height: 200px;
            overflow-y: auto;
            overflow-x: hidden;
        }
        .xcrab-tool-bar-inner {
            padding: 7px 10px;
            border-radius: 6px;
            font-size: 13px;
            word-break: break-word;
        }
        /* 折叠态：隐藏描述行 */
        .xcrab-tool-bar-inner .tool-bar-desc {
            display: none;
        }
        .xcrab-tool-bar.expanded .xcrab-tool-bar-inner .tool-bar-desc {
            display: block;
        }
        /* 折叠态箭头提示 */
        .xcrab-tool-bar-inner .tool-bar-title::after {
            content: ' ▾';
            font-size: 10px;
            opacity: 0.6;
            margin-left: 4px;
        }
        .xcrab-tool-bar.expanded .xcrab-tool-bar-inner .tool-bar-title::after {
            content: ' ▴';
        }
        .xcrab-tool-bar-inner.state-running {
            background: rgba(255, 193, 7, 0.12);
            border: 1px solid rgba(255, 193, 7, 0.3);
            color: #ffd54f;
        }
        .xcrab-tool-bar-inner.state-done {
            background: rgba(76, 175, 80, 0.12);
            border: 1px solid rgba(76, 175, 80, 0.3);
            color: #81c784;
        }
        .xcrab-tool-bar-inner.state-error {
            background: rgba(244, 67, 54, 0.12);
            border: 1px solid rgba(244, 67, 54, 0.3);
            color: #ef9a9a;
        }

        /* ================= AI 回复内容 Markdown 样式 ================= */
        .md-code {
            background: rgba(5, 5, 15, 0.95);
            padding: 14px 16px;
            border-radius: 8px;
            font-size: 13px;
            font-family: 'SF Mono', 'Menlo', 'Consolas', 'Monaco', monospace;
            overflow-x: auto;
            white-space: pre;
            word-break: normal;
            margin: 12px 0;
            border: 1px solid rgba(0, 240, 255, 0.15);
            line-height: 1.6;
            tab-size: 4;
            box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3), 0 0 8px rgba(0, 240, 255, 0.05);
        }

        .md-code code {
            font-family: inherit;
            font-size: inherit;
            line-height: inherit;
        }

        .md-code-inline {
            background: rgba(5, 5, 15, 0.95);
            padding: 2px 8px;
            border-radius: 4px;
            font-size: 13px;
            font-family: 'SF Mono', 'Menlo', 'Consolas', 'Monaco', monospace;
            border: 1px solid rgba(0, 240, 255, 0.15);
        }

        .md-h1, .md-h2, .md-h3 {
            margin: 18px 0 8px;
            font-weight: 600;
            line-height: 1.4;
            color: var(--text-main);
        }
        .md-h1 { font-size: 22px; margin-top: 6px; }
        .md-h2 { font-size: 19px; border-bottom: 1px solid var(--border); padding-bottom: 6px; }
        .md-h3 { font-size: 17px; }
        .md-h4 { font-size: 15px; }
        .md-h5 { font-size: 14px; }
        .md-h6 { font-size: 13px; color: var(--text-muted); }

        .msg-bubble ol { list-style-type: decimal; padding-left: 24px; }
        .msg-bubble ul { list-style-type: disc; padding-left: 24px; }
        .msg-bubble ol ol { list-style-type: lower-alpha; }
        .msg-bubble ul ul { list-style-type: circle; }

        .md-li {
            margin: 6px 0;
            padding-left: 6px;
            line-height: 1.6;
        }

        .md-hr {
            border: none;
            border-top: 1px solid var(--border);
            margin: 18px 0;
        }

        .md-blockquote {
            border-left: 4px solid var(--primary);
            padding: 10px 16px;
            margin: 12px 0;
            background: var(--btn-blue-bg);
            border-radius: 0 8px 8px 0;
            color: var(--text-main);
            line-height: 1.6;
        }

        .msg-bubble a {
            color: var(--primary);
            text-decoration: none;
            font-weight: 500;
        }
        .msg-bubble a:hover {
            text-decoration: underline;
        }

        /* ===== 流式渲染优化：CSS containment 减少重排 ===== */
        .msg-stream-content {
            contain: content;
            content-visibility: auto;
            contain-intrinsic-size: 200px;
        }
        /* 🔥 优化：历史消息懒加载按钮 */
        .load-more-trigger {
            text-align: center;
            padding: 8px;
        }
        .load-more-trigger button {
            background: rgba(0, 240, 255, 0.1);
            border: 1px solid rgba(0, 240, 255, 0.25);
            color: var(--primary);
            padding: 6px 18px;
            border-radius: 20px;
            cursor: pointer;
            font-size: 13px;
            transition: background 0.2s ease;
        }
        .load-more-trigger button:hover {
            background: rgba(0, 240, 255, 0.2);
        }
        /* 流式渲染期间禁用 backdrop-filter，避免 GPU 频繁重绘导致闪烁 */
        .msg-row.ai.msg-streaming .msg-bubble {
            backdrop-filter: none !important;
            -webkit-backdrop-filter: none !important;
        }
        /* 流式渲染时表格用固定布局，防止列宽来回跳动（done 后移除 msg-streaming 自动恢复） */
        .msg-streaming .msg-stream-content .table-wrapper table {
            table-layout: fixed;
        }
        /* 流式渲染时表格单元格内容不换行，用省略号处理以减少高度跳动（done 后自动恢复） */
        .msg-streaming .msg-stream-content .table-wrapper td {
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .table-wrapper {
            overflow-x: auto;
            max-width: 100%;
            margin: 12px 0;
            -webkit-overflow-scrolling: touch;
        }

        .table-wrapper table {
            width: fit-content;
            min-width: 100%;
            border-collapse: collapse;
            font-size: 14px;
            line-height: 1.5;
            margin: 0;
            table-layout: auto;
        }
        .table-wrapper th,
        .table-wrapper td {
            border: 1px solid var(--border);
            padding: 8px 12px;
            text-align: left;
            vertical-align: top;
            white-space: nowrap;
        }
        .table-wrapper thead th {
            background: var(--primary);
            color: #fff;
            font-weight: 600;
            position: sticky;
            top: 0;
            z-index: 1;
        }
        .table-wrapper tbody tr:nth-child(even) {
            background: rgba(128, 128, 128, 0.04);
        }
        .table-wrapper tbody tr:hover {
            background: rgba(128, 128, 128, 0.08);
        }

        /* 单元格展开/折叠（纯文本过长时截断 + 展开按钮） */
        .table-wrapper td.cell-limit {
            white-space: normal;
        }
        .cell-toggle-btn {
            display: inline-block;
            margin-top: 2px;
            border: none;
            background: none;
            color: var(--primary);
            cursor: pointer;
            font-size: 12px;
            padding: 0;
        }
        .cell-toggle-btn:hover {
            text-decoration: underline;
        }

        /* 窄屏下表格保持不换行，启用横向滚动 */
        @media (max-width: 768px) {
            .table-wrapper th,
            .table-wrapper td {
                padding: 5px 6px;
                font-size: 12px;
            }
            .table-wrapper table {
                font-size: 12px;
            }
        }

        /* ================= LaTeX 公式样式 ================= */
        .katex-display-wrapper {
            overflow-x: auto;
            margin: 12px 0;
            padding: 8px 0;
            text-align: center;
        }
        .katex-display-wrapper::-webkit-scrollbar {
            height: 4px;
        }
        .katex-display-wrapper::-webkit-scrollbar-thumb {
            background: var(--border);
            border-radius: 2px;
        }
        .katex-inline-wrapper {
            margin: 0 2px;
        }

        /* ================= 消息搜索栏 ================= */
        .search-bar {
            display: flex;
            align-items: center;
            gap: 6px;
            padding: 8px 12px;
            background: var(--card-bg);
            border-bottom: 1px solid var(--border);
            z-index: 10;
        }
        .search-bar input {
            flex: 1;
            padding: 6px 12px;
            border: 1px solid var(--border);
            border-radius: var(--radius-sm);
            background: var(--input-bg);
            color: var(--text);
            font-size: 14px;
            outline: none;
        }
        .search-bar input:focus {
            border-color: var(--primary);
        }
        .search-count {
            font-size: 12px;
            color: var(--text-muted);
            min-width: 40px;
            text-align: center;
        }
        mark.search-highlight {
            background: rgba(255, 213, 0, 0.35);
            color: inherit;
            border-radius: 2px;
            padding: 0 1px;
        }
        mark.search-highlight.current {
            background: rgba(255, 213, 0, 0.7);
            color: #000;
            box-shadow: 0 0 0 1px rgba(255, 213, 0, 0.9);
        }
        .msg-row.search-active .msg-bubble {
            box-shadow: 0 0 0 2px rgba(255, 213, 0, 0.6), 0 0 12px rgba(255, 213, 0, 0.2);
        }
        .search-input-wrap {
            position: relative;
            flex: 1;
            display: flex;
            align-items: center;
        }
        .search-input-wrap input {
            flex: 1;
            padding-right: 32px;
        }
        .search-clear {
            position: absolute;
            right: 6px;
            top: 50%;
            transform: translateY(-50%);
            width: 20px;
            height: 20px;
            border: none;
            border-radius: 50%;
            background: rgba(127, 127, 127, 0.25);
            color: var(--text);
            font-size: 11px;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            padding: 0;
            line-height: 1;
        }
        .search-clear:hover {
            background: rgba(127, 127, 127, 0.45);
        }
        .search-count.no-result {
            color: var(--danger);
        }

        /* ================= Mermaid 图表 ================= */
        .mermaid-wrapper {
            position: relative;
            margin: 12px 0;
            padding: 12px;
            background: rgba(10, 10, 18, 0.6);
            border-radius: 8px;
            border: 1px solid var(--border);
            overflow-x: auto;
            text-align: center;
        }
        .mermaid-wrapper svg {
            max-width: 100%;
            height: auto;
        }
        .mermaid-error {
            margin: 12px 0;
            padding: 12px;
            background: rgba(255, 59, 48, 0.1);
            border: 1px solid rgba(255, 59, 48, 0.3);
            border-radius: 8px;
            color: #ff6b6b;
            font-size: 13px;
        }
        .mermaid-error pre {
            margin-top: 8px;
            font-size: 12px;
            color: var(--text-muted);
            white-space: pre-wrap;
            word-break: break-all;
        }

        /* ================= 文件预览模态框 ================= */
        .file-preview-overlay {
            position: fixed;
            inset: 0;
            background: rgba(0, 0, 0, 0.7);
            display: flex;
            align-items: center;
            justify-content: center;
            z-index: 9999;
            padding: 20px;
        }
        .file-preview-modal {
            background: var(--card-bg);
            border: 1px solid var(--border);
            border-radius: 12px;
            width: 100%;
            max-width: 800px;
            max-height: 85vh;
            display: flex;
            flex-direction: column;
            overflow: hidden;
        }
        .file-preview-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 12px 16px;
            border-bottom: 1px solid var(--border);
            font-size: 14px;
            font-weight: 500;
            color: var(--text-main);
        }
        .file-preview-body {
            overflow: auto;
            flex: 1;
            padding: 0;
        }
        .file-preview-body .table-wrapper {
            margin: 0;
        }

        /* ================= 消息高亮动画 ================= */
        @keyframes msgHighlight {
            0%, 100% { box-shadow: none; }
            20%, 80% { box-shadow: 0 0 0 3px rgba(0, 240, 255, 0.5), 0 0 20px rgba(0, 240, 255, 0.15); }
        }
        .msg-highlight .msg-bubble {
            animation: msgHighlight 3s ease;
        }

        /* 编辑模式 */
        .edit-textarea {
            width: 100%;
            min-height: 60px;
            max-height: 300px;
            padding: 10px 14px;
            border: 1px solid var(--border);
            border-radius: 12px;
            background: var(--bg-input);
            color: var(--text);
            font-size: 14px;
            font-family: inherit;
            line-height: 1.6;
            resize: vertical;
            outline: none;
            box-sizing: border-box;
        }
        .edit-textarea:focus {
            border-color: var(--accent);
        }
        .edit-bar {
            display: flex;
            gap: 8px;
            margin-top: 6px;
            justify-content: flex-end;
        }
        .btn-edit-confirm {
            padding: 4px 14px;
            border: none;
            border-radius: 6px;
            background: var(--accent);
            color: #fff;
            font-size: 13px;
            cursor: pointer;
        }
        .btn-edit-confirm:hover { opacity: 0.85; }
        .btn-edit-cancel {
            padding: 4px 14px;
            border: 1px solid var(--border);
            border-radius: 6px;
            background: transparent;
            color: var(--text);
            font-size: 13px;
            cursor: pointer;
        }
        .btn-edit-cancel:hover { background: rgba(255,255,255,0.05); }

        .msg-bubble img {
            max-width: 100%;
            border-radius: 8px;
            margin: 10px 0;
            display: block;
        }

        .msg-bubble p {
            margin: 0 0 4px 0;
            line-height: 1.5;
        }
        .msg-bubble p:last-child {
            margin-bottom: 0;
        }
        /* 首尾元素零外边距，避免气泡内上下出现多余空白 */
        .msg-bubble > :first-child { margin-top: 0; }
        .msg-bubble > :last-child { margin-bottom: 0; }

        .msg-bubble ul,
        .msg-bubble ol {
            margin: 6px 0;
            padding-left: 24px;
            line-height: 1.6;
        }
        .msg-bubble li {
            margin: 5px 0;
            line-height: 1.6;
        }

        .msg-bubble strong {
            font-weight: 700;
        }

        .msg-bubble em {
            font-style: italic;
        }

        /* Modal */
        .modal-overlay {
            position: fixed; top: 0; left: 0; width: 100%; height: 100%;
            background: rgba(5, 5, 15, 0.8); z-index: 2000; display: none;
            justify-content: center; align-items: center;
        }
        .modal-card {
            background: var(--card-bg);
            border-radius: var(--radius-lg);
            padding: 28px 24px 24px;
            width: 90%; max-width: 400px;
            box-shadow: 0 16px 48px rgba(0,0,0,0.5), 0 0 20px rgba(0, 240, 255, 0.1), inset 0 1px 0 rgba(0, 240, 255, 0.1);
            color: var(--text-main);
            border: 1px solid rgba(0, 240, 255, 0.2);
            animation: modalCardIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
        }
        @keyframes modalCardIn {
            from { opacity: 0; transform: translateY(20px) scale(0.95); }
            to { opacity: 1; transform: translateY(0) scale(1); }
        }
        .modal-card h3 {
            margin: 0 0 18px 0;
            font-size: 20px;
            font-weight: 600;
            color: var(--primary);
            text-shadow: 0 0 10px rgba(0, 240, 255, 0.3);
        }
        .modal-card textarea {
            width: 100%; padding: 12px 14px;
            border: 1.5px solid rgba(0, 240, 255, 0.15);
            background: var(--input-bg); color: var(--text-main);
            border-radius: var(--radius-sm); box-sizing: border-box;
            resize: none; font-size: 15px; outline: none; font-family: inherit;
            transition: border-color 0.3s;
        }
        .modal-card textarea:focus {
            border-color: var(--primary);
            box-shadow: 0 0 0 3px rgba(0, 240, 255, 0.15), 0 0 10px rgba(0, 240, 255, 0.1);
        }
        .modal-actions {
            display: flex; justify-content: flex-end; gap: 12px; margin-top: 20px;
        }
        .btn-cancel {
            padding: 10px 20px; background: var(--input-bg); border: 1px solid rgba(0, 240, 255, 0.1);
            border-radius: var(--radius-sm); cursor: pointer; font-weight: 500;
            color: var(--text-sub); transition: background, color, border-color, box-shadow, opacity, transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        }
        .btn-cancel:hover {
            background: var(--card-bg-hover);
            color: var(--text-main);
            border-color: rgba(0, 240, 255, 0.2);
        }
        .btn-cancel:active {
            transform: scale(0.98);
        }
        .btn-confirm {
            padding: 10px 20px; background: linear-gradient(135deg, var(--primary) 0%, var(--neon-blue) 100%); border: none;
            border-radius: var(--radius-sm); cursor: pointer; font-weight: 600;
            color: #0a0a12; transition: background, color, border-color, box-shadow, opacity, transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
            box-shadow: 0 2px 8px rgba(0, 240, 255, 0.25), inset 0 1px 0 rgba(255,255,255,0.2);
        }
        .btn-confirm:hover {
            transform: translateY(-1px) scale(1.02);
            box-shadow: 0 4px 12px rgba(0, 240, 255, 0.35), 0 0 10px rgba(0, 240, 255, 0.15);
        }
        .btn-confirm:active {
            transform: translateY(0) scale(0.98);
        }

        .btn-more {
            background: transparent;
            color: var(--text-sub);
            border: none;
            width: 40px;
            height: 40px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            transition: background, color, border-color, box-shadow, opacity, transform 0.25s ease;
            flex-shrink: 0;
            margin-bottom: 2px;
            font-size: 18px;
        }
        .btn-more:hover { color: var(--primary); background: var(--btn-blue-bg); transform: scale(1.1); box-shadow: 0 0 12px rgba(0,240,255,0.25); }
        .btn-more:active { transform: scale(0.9); }
        .btn-more.active { color: var(--primary); background: var(--btn-blue-bg); }

        /* 输入区"..."聚合菜单（上传/拍照/语音） */
        .input-more-wrap {
            position: relative;
            flex-shrink: 0;
            display: flex;
            align-items: flex-end;
        }
        .input-more-menu {
            position: absolute;
            bottom: calc(100% + 10px);
            left: 0;
            min-width: 172px;
            background: rgba(15, 18, 32, 0.97);
            border: 1px solid rgba(0, 240, 255, 0.28);
            border-radius: 12px;
            box-shadow: 0 8px 30px rgba(0, 0, 0, 0.6), 0 0 20px rgba(0, 240, 255, 0.1);
            padding: 6px;
            z-index: 200;
            backdrop-filter: blur(12px);
            animation: input-more-in 0.18s ease;
        }
        @keyframes input-more-in {
            from { opacity: 0; transform: translateY(6px); }
            to { opacity: 1; transform: translateY(0); }
        }
        .input-more-item {
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 10px 12px;
            border-radius: 8px;
            color: var(--text-main);
            font-size: 13px;
            cursor: pointer;
            white-space: nowrap;
            transition: background, color 0.15s ease;
        }
        .input-more-item:hover { background: rgba(0, 240, 255, 0.08); color: var(--primary); }
        .input-more-item:active { background: rgba(0, 240, 255, 0.16); }
        .input-more-item i { width: 18px; text-align: center; font-size: 14px; color: var(--text-sub); }
        .input-more-item:hover i { color: var(--primary); }
        /* 屏蔽语音输入菜单项：功能保留，仅 UI 不显示（恢复时删除此规则 + index.html 的 hidden 类） */
        .input-more-item.hidden { display: none !important; }

        #voice-cancel-hint.cancel-active {
            color: #ff0000 !important;
            background: rgba(255,0,0,0.15);
            border: 1px solid rgba(255,0,0,0.3);
            transform: translate(-50%, -50%) scale(1.1);
        }

        .backend-badge {
            display: inline-block;
            font-size: 10px;
            font-weight: 600;
            padding: 1px 6px;
            border-radius: 4px;
            margin-right: 6px;
            vertical-align: middle;
            line-height: 16px;
        }
        .backend-badge.openclaw {
            background: rgba(59, 130, 246, 0.15);
            color: #3b82f6;
            border: 1px solid rgba(59, 130, 246, 0.25);
        }
        .backend-badge.hermes {
            background: rgba(255, 159, 10, 0.2);
            color: #FF9F0A;
            border: 1px solid rgba(255, 159, 10, 0.3);
        }
        .backend-badge.xcrab {
            background: rgba(16, 185, 129, 0.2);
            color: #10B981;
            border: 1px solid rgba(16, 185, 129, 0.3);
        }

        /* 自定义滚动条 */
        ::-webkit-scrollbar {
            width: 6px;
            height: 6px;
        }
        ::-webkit-scrollbar-track {
            background: transparent;
        }
        ::-webkit-scrollbar-thumb {
            background: var(--border);
            border-radius: 3px;
            transition: background 0.2s;
        }
        ::-webkit-scrollbar-thumb:hover {
            background: var(--text-muted);
        }
        .chat-container::-webkit-scrollbar {
            width: 4px;
        }
        .chat-container::-webkit-scrollbar-thumb {
            background: transparent;
        }
        .chat-container:hover::-webkit-scrollbar-thumb {
            background: var(--border);
        }

        /* 滚动按钮长按切换左右侧 */
        #scroll-buttons {
            transition: left 0.25s ease, right 0.25s ease;
        }

        .favorites-list {
            max-height: 300px;
            overflow-y: auto;
            margin-top: 10px;
            text-align: left;
        }
        .favorite-item {
            background: var(--bg);
            padding: 10px;
            border-radius: 8px;
            margin-bottom: 8px;
            font-size: 14px;
            position: relative;
            border: 1px solid rgba(0, 240, 255, 0.08);
            transition: background, color, border-color, box-shadow, opacity, transform 0.3s ease;
        }
        .favorite-item:hover {
            border-color: rgba(0, 240, 255, 0.15);
            box-shadow: 0 0 8px rgba(0, 240, 255, 0.05);
        }
        .favorite-time {
            font-size: 12px;
            color: var(--text-sub);
            margin-bottom: 4px;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }
        .btn-unfav {
            color: var(--text-sub);
            cursor: pointer;
            padding: 2px 6px;
            transition: background, color, border-color, box-shadow, opacity, transform 0.3s ease;
        }
        .btn-unfav:hover { color: var(--danger); background: rgba(255, 59, 48, 0.1); }

        /* [FAVCOPY-2026-11-27] 收藏条目的操作按钮组 + 可长按节选的正文 */
        .favorite-actions {
            display: inline-flex;
            align-items: center;
            gap: 10px;
        }
        .btn-copy-fav {
            color: var(--text-sub);
            cursor: pointer;
            padding: 2px 6px;
            transition: background, color, border-color, box-shadow, opacity, transform 0.3s ease;
        }
        .btn-copy-fav:hover { color: var(--primary); background: rgba(0, 240, 255, 0.1); }
        /* 正文可选中：Android WebView 长按需 user-select:text 才能显示系统选词手柄 */
        .favorite-body { user-select: text; -webkit-user-select: text; -webkit-touch-callout: default; }
        .mem-card-value, .mem-card-key span { user-select: text; -webkit-user-select: text; -webkit-touch-callout: default; }
        
        /* 状态条样式 */
        .status-bar {
            background: rgba(10, 10, 20, 0.97);
            backdrop-filter: none;
            -webkit-backdrop-filter: none;
            border-top: 1px solid var(--border-light);
            padding: 10px 20px;
            display: none;
            flex-direction: column;
            gap: 8px;
            box-shadow: 0 -2px 12px rgba(0,0,0,0.08);
            z-index: 5;
        }
        .status-info {
            display: flex;
            align-items: center;
            gap: 10px;
            font-size: 14px;
            color: var(--primary);
            font-weight: 500;
        }
        .status-icon {
            font-size: 16px;
            color: var(--primary);
            filter: drop-shadow(0 0 6px rgba(59, 130, 246, 0.35));
        }
        .progress-bar {
            width: 100%;
            height: 3px;
            background: rgba(0, 240, 255, 0.08);
            border-radius: 2px;
            overflow: hidden;
            position: relative;
        }
        .progress-bar-inner {
            height: 100%;
            width: 30%;
            background: linear-gradient(90deg, var(--primary), var(--neon-blue));
            border-radius: 2px;
            position: absolute;
            animation: progress-slide 1.5s infinite ease-in-out;
            box-shadow: 0 0 8px rgba(0, 240, 255, 0.35);
        }
        @keyframes progress-slide {
            0% { left: -30%; }
            100% { left: 100%; }
        }

        /* 当前大模型标签 */
        .model-badge {
            display: inline-flex;
            align-items: center;
            font-size: 11px;
            font-weight: 500;
            padding: 2px 8px;
            border-radius: 10px;
            vertical-align: middle;
            background: rgba(0, 240, 255, 0.1);
            color: var(--primary);
            border: 1px solid rgba(0, 240, 255, 0.2);
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            max-width: 120px;
            text-shadow: 0 0 5px rgba(0, 240, 255, 0.3);
        }

        /* 使用说明按钮样式 */
        .btn-instruction {
            margin-top: 24px;
            padding: 12px 32px;
            background: linear-gradient(135deg, #ff6600, #ff9f0a);
            color: #0a0a12;
            border: none;
            border-radius: 24px;
            font-size: 16px;
            font-weight: bold;
            cursor: pointer;
            box-shadow: 0 4px 20px rgba(255, 102, 0, 0.3), inset 0 1px 0 rgba(255,255,255,0.2);
            transition: background, color, border-color, box-shadow, opacity, transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .btn-instruction:hover {
            transform: translateY(-2px) scale(1.02);
            box-shadow: 0 6px 24px rgba(245, 158, 11, 0.4);
        }

        .btn-instruction:active {
            transform: scale(0.98);
        }

        /* 侧边栏及主区域新布局样式 */
        /* [FULLWIDTH-20261110] 放开 1200px 限制，页面铺满浏览器宽度（高分辨率屏下不再缩在中间） */
        #app-area {
            display: none;
            flex-direction: row;
            height: 100%;
            max-width: 100%;
            width: 100%;
            margin: 0 auto;
            background-color: transparent;
            box-shadow: 0 0 20px rgba(0,0,0,0.05);
            position: relative;
        }

        .sidebar {
            width: 260px;
            background: rgba(12, 12, 25, 0.97);
            backdrop-filter: none;
            -webkit-backdrop-filter: none;
            border-right: 1px solid rgba(0, 240, 255, 0.15);
            display: flex;
            flex-direction: column;
            flex-shrink: 0;
            z-index: 1000;
            transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), padding 0.3s ease, opacity 0.3s ease;
            overflow: hidden;
            white-space: nowrap;
            box-shadow: 1px 0 15px rgba(0, 240, 255, 0.05);
        }

        .sidebar > div:first-child {
            padding: 24px 14px 16px 14px !important;
            border-bottom: 1px solid rgba(0, 240, 255, 0.1) !important;
        }

        .sidebar .btn-sidebar-new {
            width: 100%;
            border-radius: var(--radius-md);
            padding: 13px 16px;
            font-size: 15px;
            font-weight: 600;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 8px;
            margin-top: 0;
            background: linear-gradient(135deg, var(--primary) 0%, var(--neon-blue) 100%);
            box-shadow: 0 2px 12px rgba(0, 240, 255, 0.3), inset 0 1px 0 rgba(255,255,255,0.2);
            transition: background, color, border-color, box-shadow, opacity, transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
            color: #0a0a12;
            border: none;
            cursor: pointer;
            letter-spacing: 0.3px;
        }
        .sidebar .btn-sidebar-new:hover {
            box-shadow: 0 4px 18px rgba(0, 240, 255, 0.45), 0 0 15px rgba(0, 240, 255, 0.2);
            transform: translateY(-1px);
        }
        .sidebar .btn-sidebar-new:active {
            transform: translateY(0) scale(0.98);
        }
        .sidebar .btn-sidebar-new i {
            font-size: 18px;
        }

        .sidebar-header-actions {
            display: flex;
            flex-wrap: wrap;
            gap: 8px;
            margin-top: 10px;
        }
        .sidebar-header-actions .btn-sidebar-action {
            flex: 1 1 calc(50% - 4px);
            min-width: 0;
        }
        .sidebar-header-actions .btn-sidebar-action.full-width {
            flex-basis: 100%;
        }
        .btn-sidebar-action {
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 6px;
            padding: 9px 8px;
            border: 1.5px solid var(--border-light);
            border-radius: var(--radius-md);
            background: var(--input-bg);
            color: var(--text-sub);
            font-size: 13px;
            font-weight: 500;
            cursor: pointer;
            transition: background, color, border-color, box-shadow, opacity, transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
            white-space: nowrap;
        }
        .btn-sidebar-action:hover {
            background: var(--btn-blue-bg);
            border-color: rgba(0, 240, 255, 0.3);
            color: var(--primary);
            transform: translateY(-1px);
        }
        .btn-sidebar-action:active {
            transform: translateY(0) scale(0.97);
        }
        .btn-sidebar-action i {
            font-size: 14px;
        }

        .session-batch-checkbox {
            width: 16px;
            height: 16px;
            cursor: pointer;
            flex-shrink: 0;
            accent-color: var(--primary);
        }

        .sidebar.hidden {
            width: 0;
            border-right: none;
            opacity: 0;
        }

        .sidebar.hidden .session-list,
        .sidebar.hidden > div:first-child,
        .sidebar.hidden #batch-session-bar {
            display: none;
        }

        .main-content {
            flex: 1;
            display: flex;
            flex-direction: column;
            min-width: 0;
            position: relative;
        }

        .session-list {
            flex: 1;
            overflow-y: auto;
            padding: 10px 8px;
        }

        .session-item {
            padding: 12px 14px;
            border-radius: var(--radius-md);
            cursor: pointer;
            margin-bottom: 6px;
            display: flex;
            align-items: center;
            gap: 10px;
            color: var(--text-main);
            transition: background, color, border-color, box-shadow, opacity, transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
            border: 1px solid transparent;
            /* 🔥 优化：减少会话列表 DOM 重排 */
            contain: layout style paint;
            content-visibility: auto;
            contain-intrinsic-size: 48px;
        }

        .session-item:hover {
            background: rgba(0, 240, 255, 0.05);
            border-color: rgba(0, 240, 255, 0.15);
            box-shadow: 0 0 10px rgba(0, 240, 255, 0.05);
        }

        .session-item.active {
            background: linear-gradient(135deg, rgba(0, 240, 255, 0.1) 0%, rgba(0, 102, 255, 0.05) 100%);
            color: var(--primary);
            font-weight: 500;
            border-color: rgba(0, 240, 255, 0.2);
            box-shadow: inset 3px 0 0 var(--primary), 0 0 10px rgba(0, 240, 255, 0.05);
        }

        .session-item i.fa-message {
            font-size: 16px;
            color: var(--text-sub);
            flex-shrink: 0;
        }
        .session-item.active i.fa-message {
            color: var(--primary);
        }

        .session-title {
            flex: 1;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            font-size: 14px;
            line-height: 1.3;
        }

        .btn-delete-session {
            color: var(--text-muted);
            cursor: pointer;
            padding: 4px 6px;
            display: none;
            border-radius: 6px;
            font-size: 14px;
        }
        .session-item:hover .btn-delete-session {
            display: block;
        }
        .btn-delete-session:hover {
            color: var(--danger);
            background: rgba(239, 68, 68, 0.1);
        }



        .btn-menu {
            background: transparent;
            border: none;
            border-radius: 50%;
            cursor: pointer;
            padding: 6px;
            margin-right: 6px;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            transition: background 0.2s ease;
        }
        .btn-menu:hover {
            background: rgba(255,255,255,0.08);
        }
        .btn-menu-icon {
            width: 22px;
            height: 22px;
            display: block;
            pointer-events: none;
        }
        .header-icon-img {
            width: 24px;
            height: 24px;
            display: inline-block;
            vertical-align: middle;
        }
        .dropdown-icon-img {
            width: 18px;
            height: 18px;
            display: inline-block;
            vertical-align: middle;
            margin-right: 2px;
        }

        .header-icon-xcrab, .dropdown-icon-xcrab {
            display: inline-block;
            vertical-align: middle;
            width: 20px;
            height: 20px;
        }
        .dropdown-icon-xcrab {
            width: 18px;
            height: 18px;
            margin-right: 2px;
        }

        .sidebar-overlay {
            display: none;
            position: absolute;
            top: 0; left: 0; right: 0; bottom: 0;
            background: rgba(0,0,0,0.6);
            z-index: 999;
            backdrop-filter: none;
            -webkit-backdrop-filter: none;
        }

        @media (max-width: 768px) {
            #heart-canvas {
                display: none !important;
            }
            .btn-menu {
                background: transparent;
                border: none;
                border-radius: 50%;
                padding: 6px;
                margin-right: 6px;
                display: inline-flex;
                align-items: center;
                justify-content: center;
            }
            .chat-container {
                padding: 0;
                display: flex;
                width: 100%;
                box-sizing: border-box;
                gap: 16px;
            }
            .msg-row {
                display: flex;
                flex-wrap: wrap;
                width: 100%;
                max-width: 100%;
                animation: fadeIn 0.3s ease;
                box-sizing: border-box;
                padding: 0;
            }
            .msg-row .msg-wrapper {
                max-width: 100%;
                width: 100%;
            }
            .msg-bubble {
                font-size: 14px;
                padding: 10px 12px;
                word-wrap: break-word;
                word-break: break-word;
                width: 100%;
                box-sizing: border-box;
                display: block;
                overflow-x: auto;
            }
            .msg-bubble br {
                display: block;
                margin: 4px 0;
                content: "";
            }
            .msg-bubble p,
            .msg-bubble h1,
            .msg-bubble h2,
            .msg-bubble h3,
            .msg-bubble li,
            .msg-bubble pre,
            .msg-bubble blockquote {
                margin: 4px 0;
            }
            .msg-bubble pre {
                padding: 8px;
                font-size: 12px;
            }
            .sidebar {
                position: absolute;
                left: -260px;
                top: 0;
                bottom: 0;
                opacity: 0;
                pointer-events: none;
                transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
                box-shadow: 4px 0 16px rgba(0,0,0,0.15);
                border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
            }
            .sidebar.open {
                left: 0;
                opacity: 1;
                pointer-events: auto;
            }
            .sidebar-overlay.open {
                display: block;
            }
                    #app-area {
                max-width: 100%;
            }
            
            .header {
                padding: 28px 16px 12px 16px;
                position: relative;
            }
            .btn-more-actions {
                display: flex;
                align-items: center;
                justify-content: center;
                padding: 6px 10px;
            }
            /* 移动端触发按钮收成纯图标，避免溢出 */
            .btn-more-text {
                display: none;
            }
            .header-actions {
                display: none;
                position: absolute;
                top: 56px;
                right: 16px;
                background: rgba(12, 12, 25, 0.97);
                backdrop-filter: none;
                -webkit-backdrop-filter: none;
                flex-direction: column;
                padding: 8px;
                border-radius: 16px;
                box-shadow: 0 12px 40px rgba(0,0,0,0.4), 0 0 15px rgba(0, 240, 255, 0.1);
                border: 1px solid rgba(0, 240, 255, 0.15);
                min-width: 100px;
                max-width: 200px;
                z-index: 1001;
                gap: 4px;
                animation: actionsIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
            }
            @keyframes actionsIn {
                from { opacity: 0; transform: translateY(-8px) scale(0.95); }
                to { opacity: 1; transform: translateY(0) scale(1); }
            }
            .header-actions.open {
                display: flex;
            }
            .header-actions .btn-text {
                display: inline;
            }
            .btn-text-grid {
                display: flex !important;
                flex-direction: row;
                align-items: center;
                line-height: 1.2;
                font-size: 12px;
            }
            .btn-icon {
                padding: 10px 16px;
                width: 100%;
                justify-content: flex-start;
                box-sizing: border-box;
            }

            /* 移动端 markdown 适配 */
            .md-code {
                font-size: 12px;
                padding: 10px 12px;
            }
            .md-code-inline {
                font-size: 12px;
            }
            .md-h1 { font-size: 19px; }
            .md-h2 { font-size: 17px; }
            .md-h3 { font-size: 15px; }
            .msg-bubble table {
                font-size: 12px;
            }
            .msg-bubble th,
            .msg-bubble td {
                padding: 6px 8px;
            }
            .msg-bubble p {
                margin: 8px 0;
            }

            /* 移动端优化：输入框区域增强 */
            .input-area {
                padding: 10px 12px;
                padding-bottom: calc(10px + env(safe-area-inset-bottom));
            }
            .input-box {
                padding: 12px 16px;
                font-size: 16px; /* 防止iOS自动缩放 */
                border-radius: 20px;
            }
            .btn-send, .btn-stop {
                width: 48px;
                height: 48px;
            }
            .btn-more {
                width: 44px;
                height: 44px;
            }

            /* 移动端消息气泡优化 */
            .msg-row.user .msg-bubble {
                border-bottom-right-radius: 18px;
                border-bottom-left-radius: 18px;
                border-top-right-radius: 6px;
            }
            .msg-row.ai .msg-bubble {
                border-bottom-left-radius: 18px;
                border-bottom-right-radius: 18px;
                border-top-left-radius: 6px;
            }

            /* 工具状态条渐入动画 */
            @keyframes xcrab-tool-fade-in {
                from { opacity: 0; transform: translateY(-6px); }
                to   { opacity: 1; transform: translateY(0); }
            }
            .xcrab-tool-bar.fade-in {
                animation: xcrab-tool-fade-in 0.25s ease forwards;
            }

            /* 移动端工具执行状态条 - 折叠/展开，防止遮挡输入框和停止按钮 */
            .xcrab-tool-bar {
                max-height: 32px;
                overflow: hidden;
                margin-bottom: 4px;
                cursor: pointer;
                transition: max-height 0.25s ease;
            }
            .xcrab-tool-bar.expanded {
                max-height: 150px;
                overflow-y: auto;
                scrollbar-width: none;
            }
            .xcrab-tool-bar.expanded::-webkit-scrollbar {
                width: 0;
            }
            .xcrab-tool-bar-inner {
                padding: 5px 8px;
                font-size: 12px;
            }
            /* 折叠态：只显示标题行，隐藏描述行 */
            .xcrab-tool-bar-inner .tool-bar-desc {
                display: none;
            }
            .xcrab-tool-bar.expanded .xcrab-tool-bar-inner .tool-bar-desc {
                display: block;
            }
            /* 标题行添加展开提示小箭头 */
            .xcrab-tool-bar-inner .tool-bar-title::after {
                content: ' ▾';
                font-size: 10px;
                opacity: 0.6;
                margin-left: 4px;
            }
            .xcrab-tool-bar.expanded .xcrab-tool-bar-inner .tool-bar-title::after {
                content: ' ▴';
            }

            /* 移动端工具执行状态条 - 换行铺满 */
            .xcrab-tool-status {
                width: 100%;
                box-sizing: border-box;
            }

            /* 移动端消息时间优化 */
            .msg-time {
                padding: 4px 4px;
                font-size: 11px;
                flex-direction: column;
                align-items: flex-start;
                gap: 3px;
            }
            .msg-row.user .msg-time {
                align-items: flex-end;
            }
            .msg-time-text {
                display: flex;
                align-items: center;
                flex-wrap: nowrap;
                gap: 4px;
                line-height: 1.4;
                min-width: 0;
            }
            .msg-actions {
                display: flex;
                flex-wrap: wrap;
                gap: 4px;
                align-items: center;
            }
            .msg-time .btn-action {
                padding: 6px;
                font-size: 14px;
                width: 36px;
                height: 36px;
                display: inline-flex;
                align-items: center;
                justify-content: center;
                border: none;
                background: transparent;
            }
            .msg-time img.btn-action {
                display: inline-block;
                object-fit: contain;
                padding: 4px;
            }

            /* 移动端引用指示器优化 */
            .quote-indicator {
                padding: 10px 12px;
                margin-bottom: 10px;
                border-radius: var(--radius-sm);
                font-size: 13px;
            }

            /* 移动端滚动条隐藏（但保持功能） */
            .chat-container::-webkit-scrollbar {
                width: 0;
            }
            .chat-container::-webkit-scrollbar-thumb {
                display: none;
            }

            /* 移动端 Modal 优化 */
            .modal-card {
                padding: 24px 20px 20px;
                border-radius: var(--radius-xl);
            }
            .modal-card h3 {
                font-size: 18px;
            }
            .modal-card textarea {
                font-size: 16px; /* 防止iOS缩放 */
                padding: 14px 16px;
                border-radius: 12px;
            }
            .modal-actions {
                gap: 10px;
            }
            .btn-cancel, .btn-confirm {
                padding: 12px 20px;
                font-size: 15px;
                min-height: 44px;
                flex: 1;
                border-radius: var(--radius-md);
            }

            /* 移动端侧边栏优化 */
            .sidebar {
                width: 80vw;
                left: -80vw;
                border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
            }
            .sidebar.open {
                left: 0;
                opacity: 1;
                pointer-events: auto;
            }
            .sidebar-overlay.open {
                display: block;
            }
            .session-item {
                padding: 4px 12px;
                min-height: 12px;
                border-radius: var(--radius-md);
            }
            .session-item i.fa-message {
                font-size: 12px;
            }
            .session-title {
                font-size: 13px;
            }
            .btn-delete-session {
                padding: 8px 10px;
                font-size: 16px;
                min-width: 36px;
                min-height: 36px;
                display: inline-flex;
                align-items: center;
                justify-content: center;
            }

            /* 移动端 Header 优化 */
            .header {
                padding: 24px 12px 12px 12px;
            }
            .header-title {
                font-size: 17px;
            }
            .header-title i {
                font-size: 20px;
            }
            .btn-icon {
                padding: 10px 14px;
                font-size: 14px;
                min-height: 40px;
                min-width: 40px;
                display: inline-flex;
                align-items: center;
                gap: 6px;
            }

            /* 移动端登录页优化 */
            #login-area {
                padding: 16px;
            }
            .login-card {
                padding: 24px 20px;
                border-radius: var(--radius-xl);
            }
            .login-card h1 {
                font-size: 20px;
                margin-bottom: 20px;
            }
            .form-group input {
                padding: 14px 16px;
                font-size: 16px;
                border-radius: var(--radius-md);
                min-height: 48px;
            }
            .btn-primary {
                padding: 14px 20px;
                font-size: 16px;
                border-radius: var(--radius-md);
                min-height: 50px;
            }
            .tab {
                padding: 14px 10px;
                font-size: 15px;
            }
            .sms-group {
                gap: 10px;
            }
            .sms-group input {
                min-height: 48px;
            }
            .btn-sms {
                width: 110px;
                min-height: 48px;
                font-size: 13px;
            }

            /* 移动端按钮悬浮效果优化 */
            .btn-send:hover,
            .btn-stop:hover,
            .btn-more:hover {
                transform: none;
            }
            .btn-primary:hover {
                transform: none;
            }

            /* 移动端警告提示优化 */
            .alert {
                top: auto;
                bottom: 100px;
                left: 20px;
                right: 20px;
                transform: none;
                padding: 14px 24px;
                border-radius: var(--radius-lg);
                font-size: 14px;
                text-align: center;
            }
            @keyframes alertIn {
                from { opacity: 0; transform: translateY(20px); }
                to { opacity: 1; transform: translateY(0); }
            }

            /* 移动端状态栏优化 */
            .status-bar {
                padding: 12px 16px;
            }
            .status-info {
                font-size: 13px;
            }

            /* 移动端收藏列表优化 */
            .favorites-list {
                max-height: 250px;
            }
            .favorite-item {
                padding: 12px 14px;
                border-radius: var(--radius-md);
                font-size: 14px;
            }

            /* 移动端图片预览优化 */
            .image-preview-overlay {
                background: rgba(0, 0, 0, 0.95);
            }
            .image-preview-img {
                max-width: 95%;
                max-height: 85%;
                border-radius: var(--radius-md);
            }
            .image-preview-close {
                top: 16px;
                right: 20px;
                font-size: 32px;
            }

            /* 移动端滚动到顶部/底部按钮 */
            #scroll-buttons {
                bottom: 90px !important;
            }


            /* 移动端搜索栏适配 */
            .search-bar {
                padding: 10px 12px;
                gap: 8px;
                flex-wrap: wrap;
            }
            .search-bar input {
                padding: 10px 14px;
                font-size: 16px;
                min-height: 44px;
                border-radius: 12px;
            }
            .search-bar .btn-icon {
                padding: 10px;
                min-width: 44px;
                min-height: 44px;
                display: inline-flex;
                align-items: center;
                justify-content: center;
                border-radius: 12px;
            }
            .search-input-wrap input {
                padding-right: 38px;
            }
            .search-count {
                font-size: 13px;
                min-width: 50px;
            }
        }

        /* 移动端安全区域适配 */
        @supports (padding-bottom: env(safe-area-inset-bottom)) {
            .header {
                padding-top: calc(24px + env(safe-area-inset-top));
            }
        }

        /* 图片预览放大（Lightbox） */
        .image-preview-overlay {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(5, 5, 15, 0.95);
            z-index: 9999;
            justify-content: center;
            align-items: center;
            cursor: pointer;
            touch-action: none; /* 双指缩放手势由 JS 接管，禁用浏览器默认捏合/滚动 */
            user-select: none;
            -webkit-user-select: none;
        }

        .image-preview-img {
            max-width: 90%;
            max-height: 90%;
            object-fit: contain;
            border-radius: 8px;
            box-shadow: 0 4px 30px rgba(0, 0, 0, 0.5), 0 0 20px rgba(0, 240, 255, 0.1);
            border: 1px solid rgba(0, 240, 255, 0.2);
            will-change: transform; /* pinch 缩放/平移走 transform，避免重排 */
            -webkit-user-drag: none;
        }

        .image-preview-close {
            position: absolute;
            top: 20px;
            right: 30px;
            color: #fff;
            font-size: 40px;
            font-weight: 300;
            cursor: pointer;
            transition: opacity 0.2s;
            line-height: 1;
            z-index: 10000;
            /* 扩大触控热区（margin 抵消 padding 偏移，位置不变） */
            padding: 12px;
            margin: -12px;
        }
        .image-preview-close:hover {
            opacity: 0.7;
        }

        /* ========== 移动端消息操作按钮聚合 ========== */
        @media (max-width: 768px) {
            .msg-time {
                position: relative;
                display: flex;
                flex-direction: row;
                align-items: center;
                gap: 6px;
                flex-wrap: nowrap;
            }

            .msg-actions-wrapper {
                display: inline-flex;
                align-items: center;
                margin-left: auto;
            }

            .msg-actions-toggle {
                background: var(--input-bg);
                border: 1px solid var(--border-light);
                border-radius: 6px;
                padding: 4px 10px;
                cursor: pointer;
                color: var(--text-sub);
                font-size: 14px;
                transition: background, color, border-color, box-shadow, opacity, transform 0.2s ease;
                display: inline-flex;
                align-items: center;
            }

            .msg-actions-toggle:hover {
                background: var(--btn-blue-bg);
                color: var(--primary);
                border-color: var(--primary);
            }

            .msg-actions-toggle:active {
                transform: scale(0.95);
            }

            .msg-actions-dropdown {
                display: none;
                position: fixed;
                bottom: 0;
                left: 0;
                width: 100vw;
                max-width: 100vw;
                background: rgba(12, 12, 25, 0.97);
                backdrop-filter: none;
                -webkit-backdrop-filter: none;
                border-top: 1px solid rgba(255,255,255,0.1);
                border-radius: 16px 16px 0 0;
                padding: 8px;
                padding-bottom: calc(8px + env(safe-area-inset-bottom));
                box-shadow: 0 -8px 32px rgba(0,0,0,0.3);
                z-index: 10000;
                flex-direction: column;
                gap: 2px;
                box-sizing: border-box;
                margin: 0;
            }

            .msg-actions-dropdown.open {
                display: flex;
            }

            .msg-action-item {
                padding: 10px 16px;
                border-radius: 8px;
                font-size: 14px;
                display: flex;
                align-items: center;
                justify-content: center;
                gap: 8px;
                cursor: pointer;
                color: var(--text-main);
                transition: background, color, border-color, box-shadow, opacity, transform 0.15s ease;
                white-space: nowrap;
                min-height: 40px;
            }

            .msg-action-item:active {
                background: var(--btn-blue-bg);
                transform: scale(0.95);
            }

            .msg-action-item i {
                width: 18px;
                text-align: center;
            }

            .msg-action-delete:active {
                background: rgba(239, 68, 68, 0.12);
                color: var(--danger);
            }

            .msg-action-item.active {
                color: #FF9500;
            }

            .msg-time > .backend-badge {
                display: inline;
            }

            /* 移动端隐藏单独的按钮，只显示聚合按钮 */
            .msg-time > .btn-action,
            .msg-time > img.btn-action {
                display: none !important;
            }

            /* 确保聚合按钮在移动端显示 */
            .msg-time > .msg-actions-wrapper {
                display: inline-flex;
            }

            /* 居中弹窗的遮罩层 */
            .msg-actions-backdrop {
                position: fixed;
                top: 0; left: 0; right: 0; bottom: 0;
                background: rgba(0,0,0,0.6);
                z-index: 9999;
                -webkit-tap-highlight-color: transparent;
                backdrop-filter: none;
                -webkit-backdrop-filter: none;
            }
        }

/* ========== 系统通知消息样式 ========== */
.notify-msg {
    background: linear-gradient(135deg, #1a1a2e, #16213e) !important;
    border: 1px solid rgba(255, 149, 0, 0.3) !important;
}
.notify-header {
    display: flex;
    align-items: center;
    margin-bottom: 4px;
}

/* 白天模式下通知消息样式 */
.light .notify-msg {
    background: linear-gradient(135deg, #fff7ed, #fffbeb) !important;
    border: 1px solid rgba(255, 149, 0, 0.4) !important;
}

/* ========== 小屏手机适配 (480px 以下) ========== */
@media (max-width: 480px) {
    .header {
        padding: 24px 10px 10px 10px;
    }
    .header-title {
        font-size: 15px;
        gap: 4px;
        overflow: hidden;
    }
    .header-title .header-icon-img,
    .header-title .header-icon-xcrab {
        width: 20px;
        height: 20px;
    }
    #header-backend-label {
        font-size: 14px;
    }
    .model-badge {
        font-size: 10px;
        padding: 1px 6px;
        white-space: nowrap;
        max-width: 100px;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .btn-menu {
        padding: 4px;
        margin-right: 2px;
    }
    .btn-menu-icon {
        width: 22px;
        height: 22px;
    }
    .input-area {
        padding: 8px 8px;
        padding-bottom: calc(8px + env(safe-area-inset-bottom));
        gap: 6px;
    }
    .input-box {
        padding: 10px 14px;
        font-size: 16px;
        border-radius: 18px;
    }
    .btn-send, .btn-stop {
        width: 42px;
        height: 42px;
        min-width: 42px;
    }
    .btn-more {
        width: 38px;
        height: 38px;
        min-width: 38px;
    }
    .btn-more-actions {
        width: 32px;
        height: 32px;
    }
    .header-actions {
        top: 48px;
        right: 8px;
        min-width: 100px;
    }
    .sidebar {
        width: 80vw;
        left: -80vw;
        border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
    }
    #app-area {
        max-width: 100%;
    }
    .chat-container {
        padding: 0 6px;
        gap: 10px;
    }
    .msg-bubble {
        font-size: 13px;
        padding: 8px 10px;
    }
    .msg-row {
        padding: 0;
    }

    /* 弹窗在小屏上铺满 */
    .modal-card {
        padding: 20px 16px;
        width: 94%;
        max-width: 94%;
    }
    .modal-card h3 {
        font-size: 18px;
    }
    .modal-card .modal-actions {
        flex-direction: column;
        gap: 6px;
    }
    .modal-card .modal-actions .btn-confirm,
    .modal-card .modal-actions .btn-cancel {
        width: 100%;
        text-align: center;
    }

    /* 复制确认弹窗操作栏 */
    #copy-modal .modal-card .modal-actions {
        flex-direction: row;
        flex-wrap: wrap;
    }
    #copy-modal .modal-card .modal-actions button {
        flex: 1;
        min-width: 80px;
    }

    /* 图片预览 */
    .image-preview-img {
        max-width: 95%;
        max-height: 80vh;
    }

    /* 右侧滚动按钮 */
    #scroll-buttons {
        right: 10px;
        bottom: 160px;
    }
    #scroll-buttons button {
        width: 34px !important;
        height: 34px !important;
    }
    #scroll-buttons button i {
        font-size: 13px !important;
    }

    /* 状态栏 */
    .status-bar {
        padding: 8px 12px;
        margin: 4px 8px;
    }
    .status-text {
        font-size: 12px;
    }

    /* 使用说明弹窗 */
    #instruction-modal .modal-card {
        max-width: 94%;
    }

}

/* ========== 极窄屏 (360px 以下) 额外优化 ========== */
@media (max-width: 360px) {
    .header {
        padding: 22px 6px 8px 6px;
    }
    .header-title {
        font-size: 13px;
        gap: 2px;
    }
    #header-backend-label {
        display: none;
    }
    .model-badge {
        font-size: 9px;
        padding: 1px 4px;
    }
    .btn-menu-icon {
        width: 20px;
        height: 20px;
    }
    .input-area {
        padding: 6px 6px;
        padding-bottom: calc(6px + env(safe-area-inset-bottom));
        gap: 4px;
        border-radius: 14px;
    }
    .input-box {
        padding: 8px 12px;
        font-size: 15px;
    }
    .btn-send, .btn-stop {
        width: 36px;
        height: 36px;
        min-width: 36px;
    }
    .btn-send i, .btn-stop i {
        font-size: 14px !important;
    }
    .btn-more {
        width: 34px;
        height: 34px;
        min-width: 34px;
    }
    .sidebar {
        width: 80vw;
        left: -80vw;
        border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
    }
    .chat-container {
        padding: 0 4px;
        gap: 8px;
    }
    .msg-bubble {
        font-size: 12px;
        padding: 6px 8px;
    }
}

/* ========== 移动端触摸优化 ========== */
@media (hover: none) and (pointer: coarse) {
    .btn-send:active,
    .btn-stop:active,
    .btn-more:active,
    .btn-menu:active,
    .btn-more-actions:active,
    .btn-icon:active,
    .btn-confirm:active,
    .btn-cancel:active {
        transform: scale(0.94) !important;
        transition: transform 0.08s ease;
    }

    .session-item:active {
        background: var(--btn-blue-bg);
        transform: scale(0.98);
    }

    input, textarea, select, button {
        -webkit-tap-highlight-color: transparent;
    }

    /* 增加消息气泡触摸反馈 */
    .msg-action-item:active {
        transform: scale(0.95);
        opacity: 0.7;
    }
}

/* ================= 移除所有动画特效（纯黑背景，无动画） ================= */

/* ========== 代码块增强：复制按钮 + 语言标签 ========== */
.md-code {
    position: relative;
}
.code-lang-label {
    position: absolute;
    top: 6px;
    left: 12px;
    font-size: 11px;
    font-weight: 600;
    color: rgba(0, 240, 255, 0.5);
    background: rgba(0, 240, 255, 0.06);
    padding: 1px 8px;
    border-radius: 4px;
    pointer-events: none;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.code-copy-btn {
    position: absolute;
    top: 6px;
    right: 8px;
    background: rgba(0, 240, 255, 0.08);
    border: 1px solid rgba(0, 240, 255, 0.15);
    border-radius: 6px;
    color: var(--text-sub);
    cursor: pointer;
    padding: 4px 8px;
    font-size: 13px;
    transition: background, color, border-color, box-shadow, opacity, transform 0.2s ease;
    z-index: 2;
    line-height: 1;
}
.code-copy-btn:hover {
    background: rgba(0, 240, 255, 0.18);
    color: var(--primary);
    border-color: rgba(0, 240, 255, 0.3);
    transform: scale(1.05);
}
.code-copy-btn:active {
    transform: scale(0.92);
}
/* 代码块有语言标签时，内容下移避免重叠 */
.md-code:has(.code-lang-label) code {
    display: block;
    padding-top: 22px;
}
/* 图片点击预览提示 */
.img-preview-wrapper {
    display: inline-block;
    position: relative;
    cursor: pointer;
}
.img-preview-wrapper:hover img {
    box-shadow: 0 0 0 2px var(--primary), 0 4px 16px rgba(0, 240, 255, 0.2);
}
.img-alt-hint {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    text-align: center;
    margin-top: 4px;
}

/* ========== 表格首列固定（移动端横向滚动时保留行头） ========== */
@media (max-width: 768px) {
    .table-wrapper table td:first-child,
    .table-wrapper table th:first-child {
        position: sticky;
        left: 0;
        z-index: 2;
        background: var(--msg-ai);
        box-shadow: 2px 0 4px rgba(0, 0, 0, 0.15);
    }
    .table-wrapper table thead th:first-child {
        background: var(--primary);
    }
}

/* ========== 自定义工具管理列表项 ========== */
/* 统一布局：名称+状态徽章同行、描述、徽章行、按钮区（桌面/移动均一致） */
.tool-item {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 10px;
    border-bottom: 1px solid var(--border-light);
}
.tool-item:last-child { border-bottom: none; }
.tool-item-info {
    flex: 1;
    min-width: 0;
}
/* ★ 2026-10-17：名称与状态徽章同行（名称左、状态右） */
.tool-item-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
}
.tool-item-name {
    font-size: 13px;
    color: var(--text-main);
    font-weight: 600;
    word-break: break-all;
    line-height: 1.4;
    flex: 1 1 auto;
    min-width: 0;
}
.tool-item-desc {
    font-size: 11px;
    color: var(--text-sub);
    margin-top: 2px;
    word-break: break-all;
    white-space: pre-wrap;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    cursor: pointer;
    line-height: 1.5;
}
.tool-item-meta {
    font-size: 11px;
    color: var(--text-tertiary);
    margin-top: 4px;
}
/* ★ 2026-10-17：meta 小徽章（v2 / imports / 文件数 / hooks） */
.tool-chip {
    display: inline-flex;
    align-items: center;
    padding: 1px 8px;
    border-radius: 10px;
    font-size: 11px;
    line-height: 1.6;
    white-space: nowrap;
}
.tool-chip-meta {
    background: rgba(158,158,158,0.12);
    color: var(--text-tertiary);
}
/* ===== 技能管理面板布局优化（2026-11-07）：描述默认 3 行钳制 + 展开/收起 =====
   修复：超长 SKILL.md 描述（如 create-tool-doc）把卡片撑成文字墙，按钮/meta 被推出视野 */
.skill-desc {
    font-size: 12px;
    color: var(--text-sub);
    margin: 4px 0 0;
    line-height: 1.6;
    word-break: break-word;
    white-space: pre-wrap;
    min-width: 0;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.skill-desc.expanded {
    display: block;
    -webkit-line-clamp: unset;
}
.skill-desc-toggle {
    margin-top: 2px;
    font-size: 11px;
    color: var(--accent, #4fc3f7);
    cursor: pointer;
    user-select: none;
    width: fit-content;
}
.skill-desc-toggle:hover { text-decoration: underline; }
/* ===== MCP 服务管理面板（2026-11-07 mcpui2 布局优化） =====
   修复：STDIO 超长命令挤在灰 chip 里折 4 行、描述 2 行硬截断无展开、禁用卡虚线只对底边生效 */
.mcp-desc {
    font-size: 11px;
    color: var(--text-sub);
    margin-top: 2px;
    word-break: break-all;
    white-space: pre-wrap;
    min-width: 0;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.mcp-desc.expanded { display: block; -webkit-line-clamp: unset; }
.mcp-cmd-row {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    margin-top: 2px;
    min-width: 0;
}
.mcp-cmd-row .tool-chip { flex-shrink: 0; margin-top: 3px; }
.mcp-cmd-code {
    flex: 1 1 auto;
    min-width: 0;
    font-family: ui-monospace, 'Cascadia Code', 'Consolas', monospace;
    font-size: 11px;
    line-height: 1.6;
    color: var(--text-sub);
    background: var(--input-bg);
    border: 1px solid var(--border-light);
    border-radius: 6px;
    padding: 4px 8px;
    word-break: break-all;
    white-space: pre-wrap;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.mcp-cmd-code.expanded { display: block; -webkit-line-clamp: unset; }
/* 禁用卡：完整虚线边框 + 淡橙底，与启用卡明确区分 */
.mcp-item-disabled {
    opacity: 0.8;
    border: 1px dashed var(--border-light);
    border-radius: var(--radius-sm);
    background: rgba(255,152,0,0.03);
}
/* ★ [2026-11-07 UI-2] 已禁用/残缺分区：去掉原 180px 硬钳导致的下半空白。
   禁用区改为内容自适应（flex:0 1 auto），容器上限 34vh 内部滚动；
   已启用区仍是 flex:1 1 0，占满剩余高度。 */
/* ★ [2026-11-07 UI-3] 修复 UI-2 塌缩：section 放开后，内部 .tool-list-container 仍是
   flex:1 1 0 + min-height:0，在内容自适应父级里贡献 0 高度 → 列表塌成一条缝。
   容器同样改为 flex-basis auto（按内容取高），34vh 上限内滚动。 */
#skill-disabled-section {
    flex: 0 1 auto;
}
#skill-disabled-container {
    flex: 0 1 auto;
    max-height: 34vh;
}
/* ★ Step4（2026-11-06）：工具管理列表客户端分页 */
.tool-pager-btn {
    min-width: 26px;
    height: 24px;
    padding: 0 6px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: transparent;
    color: var(--text-main);
    font-size: 12px;
    cursor: pointer;
    transition: background 0.15s;
}
.tool-pager-btn:hover:not(:disabled) { background: rgba(158,158,158,0.15); }
.tool-pager-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.tool-pager-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.tool-item-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 2px;
    align-items: center;
    /* 桌面端：与 action 列并排时保持视觉对齐 */
}
.tool-item-actions {
    flex-shrink: 0;
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-start;
    gap: 6px;
    max-width: 100%;
    width: 100%;
    padding-top: 6px;
    border-top: 1px dashed var(--border-light);
}
/* ★ 2026-10-17：移动端 2 列网格下，奇数按钮时最后一个独占整行 */
.tool-item-btn-span { grid-column: 1 / -1; }
.tool-item-btn {
    flex-shrink: 0;
    border-radius: 6px;
    padding: 3px 10px;
    font-size: 12px;
    cursor: pointer;
    white-space: nowrap;
    border: 1px solid transparent;
    background: transparent;
    font-family: inherit;
    line-height: 1.4;
    transition: background 0.2s, color 0.2s, border-color 0.2s, transform 0.15s;
}
.tool-item-btn:active { transform: scale(0.96); }
.tool-item-btn-warn {
    background: rgba(255,152,0,0.12);
    border-color: #FF9800;
    color: #FF9800;
}
.tool-item-btn-ghost {
    border-color: var(--border);
    color: var(--text-sub);
}
.tool-item-btn-ok {
    background: rgba(76,175,80,0.12);
    border-color: #4CAF50;
    color: #4CAF50;
}
.tool-item-btn-danger-soft {
    background: rgba(244,67,54,0.10);
    border-color: #F44336;
    color: #F44336;
}
.tool-item-btn-force {
    background: rgba(255,87,34,0.12);
    border-color: #FF5722;
    color: #FF5722;
}
.tool-item-btn-danger {
    border-color: var(--danger);
    color: var(--danger);
}
.tool-item-toggle {
    display: none;
    margin-top: 2px;
    font-size: 11px;
    color: var(--accent, #4fc3f7);
    cursor: pointer;
    user-select: none;
    width: fit-content;
}

/* ========== 自定义工具管理弹窗布局（★ 2026-10-17 语义化 class） ========== */
/* ★ 2026-10-17 第四轮：仿记忆面板模式 —— 卡片固定高度 + overflow:hidden，
   滚动只发生在列表容器内部，杜绝嵌套 flex 高度不确定导致的叠印 */
.tool-modal-card {
    max-width: 640px;
    height: min(96vh, 1000px);
    /* ★ 2026-10-17 第五轮：lvh = 大视口高度，Android 软键盘弹出（adjustResize 压缩视口）时高度不变，
       防止卡片被压扁导致列表内容溢出叠印；不支持 lvh 的旧内核回退到上一行 vh */
    height: min(96lvh, 1000px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 18px 16px 14px;
}
.tool-modal-head {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}
.tool-modal-icon { font-size: 24px; color: var(--primary); flex-shrink: 0; }
.tool-modal-head h3 {
    margin: 0;
    font-size: 20px;
    flex: 1 1 auto;
    min-width: 0;
}
.tool-modal-refresh { font-size: 12px; padding: 4px 12px; flex-shrink: 0; }
/* ★ 2026-10-17 第六轮：键盘弹出时卡片（lvh 高）比可视区高，遮罩是垂直居中布局，
   高出部分向上下双向溢出 → 卡片顶部（搜索框）被顶出屏幕外。
   本弹窗改为顶部对齐 + dvh 跟随键盘收缩（配合第四轮 overflow:hidden 兜底，收缩不再叠印），
   无论键盘是否弹出，搜索框都固定在可视区顶部附近 */
#tool-upload-modal.modal-overlay {
    align-items: flex-start;
    overflow-y: auto;
}
#tool-upload-modal .tool-modal-card {
    height: min(96vh, 1000px);
    height: min(96dvh, 1000px);
    margin-top: 2vh;
}

/* ★ 2026-10-17 第七轮：搜索框聚焦（软键盘弹出）时，自动收起非核心区块，
   搜索框 + 工具列表独占整屏 —— 解决键盘弹出后固定区块挤压、搜索框被裁剪的问题。
   用 :has(.tool-search-input:focus) 精确触发：点共享范围单选/其他控件不会误触发。
   不支持 :has 的旧内核自动跳过本规则（仍有 overflow:hidden 兜底，不叠印）。 */
@media (max-width: 768px) {
    #tool-upload-modal:has(.tool-search-input:focus) .tool-format-note,
    #tool-upload-modal:has(.tool-search-input:focus) .tool-scope-row,
    #tool-upload-modal:has(.tool-search-input:focus) .tool-file-row,
    #tool-upload-modal:has(.tool-search-input:focus) .tool-upload-status {
        display: none;
    }
    #tool-upload-modal:has(.tool-search-input:focus) .tool-modal-card {
        height: 100dvh;
        margin-top: 0;
        border-radius: 0;
    }
}

.tool-list-section {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    min-height: 0;
    margin-bottom: 10px;
    /* ★ 2026-10-17 第五轮：兜底裁剪 —— 即使被键盘挤压到小于内容高度，也只裁剪不外溢叠印 */
    overflow: hidden;
}
.tool-list-label {
    margin-bottom: 6px;
    font-size: 13px;
    color: var(--text-sub);
    flex-shrink: 0;
}
/* ★ 2026-10-17 第三轮：搜索框 + 状态过滤 chips */
.tool-list-toolbar {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    flex-wrap: wrap;
}
.tool-search-input {
    flex: 1 1 140px;
    min-width: 0;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--input-bg);
    color: var(--text-main);
    font-size: 12.5px;
    outline: none;
    transition: border-color 0.2s;
    box-sizing: border-box;
}
.tool-search-input:focus { border-color: var(--primary); }
/* ===== MCP 服务管理（[MCPUI-2026-11-06]） ===== */
.mcp-paste-json {
    width: 100%;
    box-sizing: border-box;
    margin-top: 8px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--input-bg);
    color: var(--text-main);
    font-size: 12px;
    font-family: 'Consolas', 'Monaco', monospace;
    line-height: 1.5;
    outline: none;
    resize: vertical;
    transition: border-color 0.2s;
}
.mcp-paste-json:focus { border-color: var(--primary); }
.mcp-test-result {
    margin-top: 8px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--input-bg);
    font-size: 12.5px;
    line-height: 1.6;
    word-break: break-all;
}
.tool-filter-chips {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}
.tool-filter-chip {
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-sub);
    border-radius: 12px;
    padding: 3px 10px;
    font-size: 11.5px;
    cursor: pointer;
    font-family: inherit;
    white-space: nowrap;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
}
.tool-filter-chip.active {
    background: rgba(59,130,246,0.15);
    border-color: var(--primary);
    color: var(--primary);
    font-weight: 600;
}
/* ★ 2026-10-17 第五轮：min-height 放开为 0 —— 极端挤压时列表先于搜索框收缩，保住搜索框可见 */
.tool-list-container {
    flex: 1 1 0;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 4px;
}
/* ★ 2026-10-17 第二轮：说明改为默认折叠的 details，把纵向空间让给工具列表 */
/* ★ 2026-10-17 第八轮：说明折叠行与共享范围整体压缩一半，让位给工具列表 */
.tool-format-note {
    flex-shrink: 0;
    margin-bottom: 6px;
    padding: 0;
    border: 1px dashed var(--border);
    border-radius: var(--radius-md);
    background: rgba(59,130,246,0.04);
    font-size: 12px;
    color: var(--text-sub);
    line-height: 1.5;
}
.tool-format-note summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 4px 10px;
    cursor: pointer;
    list-style: none;
    user-select: none;
}
.tool-format-note summary::-webkit-details-marker { display: none; }
.tool-format-title {
    flex: 1 1 auto;
    min-width: 0;
    color: var(--text-sub);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.tool-format-title i { color: var(--primary); margin-right: 4px; }
.tool-format-note[open] summary { border-bottom: 1px dashed var(--border); }
.tool-format-text { padding: 6px 10px; }
.tool-format-warn { margin-top: 3px; color: var(--text-main); }
.tool-sample-link {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(59,130,246,0.10);
    border: 1px solid rgba(59,130,246,0.45);
    color: var(--primary);
    border-radius: 5px;
    padding: 2px 10px;
    font-size: 11px;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
}
/* ★ 2026-10-17 第八轮：共享范围压缩 —— 单行小卡片，窄屏也并排 */
.tool-scope-row {
    flex-shrink: 0;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}
.tool-scope-label {
    font-size: 12px;
    color: var(--text-sub);
    flex-shrink: 0;
    align-self: center;
}
.tool-scope-opt {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 3px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--input-bg);
    cursor: pointer;
    font-size: 11.5px;
    color: var(--text-main);
    flex-wrap: nowrap;
    transition: border-color 0.2s, background 0.2s;
}
.tool-scope-opt:hover { border-color: var(--primary); }
.tool-scope-opt:has(input:checked) {
    border-color: var(--primary);
    background: rgba(59,130,246,0.08);
}
.tool-scope-opt input { flex-shrink: 0; margin: 0; width: 14px; height: 14px; }
.tool-scope-opt span { flex-shrink: 0; }
.tool-scope-opt small {
    flex: 1 1 auto;
    min-width: 0;
    color: var(--text-sub);
    font-size: 10px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.tool-file-row {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}
.tool-file-btn { flex: 1 1 180px; min-width: 0; padding: 8px 14px; }
.tool-file-name {
    font-size: 13px;
    color: var(--text-sub);
    flex: 1 1 auto;
    min-width: 0;
    word-break: break-all;
}
.tool-upload-status {
    flex-shrink: 0;
    font-size: 13px;
    line-height: 1.7;
    max-height: 20vh;
    overflow-y: auto;
    margin-bottom: 12px;
    white-space: pre-wrap;
    word-break: break-all;
}

/* 平板及以下：垂直堆叠 + 按钮改 2 列等宽网格（手机端主适配） */
@media (max-width: 768px) {
    .tool-item {
        padding: 10px 8px;
    }
    /* ★ 2026-10-17：按钮网格化 —— 等宽 2 列，杜绝奇数按钮时的参差换行 */
    .tool-item-actions {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 6px;
        padding-top: 6px;
    }
    .tool-item-btn {
        width: 100%;
        padding: 5px 12px;
        font-size: 11.5px;
        min-height: 32px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    /* ★ 2026-10-17 第四轮：本弹窗底部按钮保持横排（全局移动端规则会把 .modal-actions 改纵排，占双倍高度） */
    #tool-upload-modal .modal-actions {
        flex-direction: row;
        gap: 10px;
    }
    #tool-upload-modal .modal-actions .btn-cancel {
        flex: 0 0 auto;
        width: auto;
        min-width: 96px;
    }
    #tool-upload-modal .modal-actions .btn-confirm {
        flex: 1;
    }
}

/* 更窄的手机 (480px 以下)：继续强化紧凑感，把纵向空间尽量让给工具列表 */
@media (max-width: 480px) {
    .tool-modal-head h3 {
        font-size: 17px;
    }
    .tool-format-note summary {
        padding: 3px 8px;
        font-size: 11.5px;
    }
    .tool-format-text { padding: 5px 8px; }
    .tool-scope-row { gap: 5px; }
    .tool-scope-opt {
        flex: 1 1 0;
        min-width: 0;
        padding: 3px 6px;
        gap: 4px;
    }
    .tool-file-btn {
        flex: 1 1 100%;
    }
    .tool-item {
        padding: 8px 6px;
    }
    .tool-item-name {
        font-size: 12.5px;
    }
    .tool-item-desc {
        font-size: 10.5px;
    }
    .tool-item-badges {
        margin-top: 4px;
        gap: 3px;
    }
    .tool-item-actions {
        gap: 5px;
    }
    .tool-item-btn {
        padding: 4px 10px;
        font-size: 11px;
        min-height: 30px;
    }
}

/* 代码块包装器样式 */
.code-block-wrapper {
    position: relative;
    display: block;
    margin: 12px 0;
}

/* 调整代码块样式，移除margin（由wrapper处理） */
.code-block-wrapper .md-code {
    margin: 0;
}

/* 复制按钮样式调整 */
.code-block-wrapper .code-copy-btn {
    position: absolute;
    top: 6px;
    right: 8px;
    z-index: 10;
    background: rgba(0, 240, 255, 0.08);
    border: 1px solid rgba(0, 240, 255, 0.15);
    border-radius: 6px;
    color: var(--text-sub);
    cursor: pointer;
    padding: 4px 8px;
    font-size: 13px;
    transition: background, color, border-color, box-shadow, opacity, transform 0.2s ease;
    line-height: 1;
}

.code-block-wrapper .code-copy-btn:hover {
    background: rgba(0, 240, 255, 0.18);
    color: var(--primary);
    border-color: rgba(0, 240, 255, 0.3);
    transform: scale(1.05);
}

.code-block-wrapper .code-copy-btn:active {
    transform: scale(0.92);
}

/* 语言标签样式调整 */
.code-block-wrapper .code-lang-label {
    position: absolute;
    top: 6px;
    left: 12px;
    font-size: 11px;
    font-weight: 600;
    color: rgba(0, 240, 255, 0.5);
    background: rgba(0, 240, 255, 0.06);
    padding: 1px 8px;
    border-radius: 4px;
    pointer-events: none;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    z-index: 10;
}

/* 代码块有语言标签时，内容下移避免重叠 */
.code-block-wrapper .md-code:has(.code-lang-label) code {
    display: block;
    padding-top: 22px;
}

/* 授权管理 - 开关样式 */
.auth-toggle {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
    cursor: pointer;
    flex-shrink: 0;
}
.auth-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}
.auth-toggle-slider {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--border);
    border-radius: 13px;
    transition: background 0.3s;
}
.auth-toggle-slider::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 22px;
    height: 22px;
    background: white;
    border-radius: 50%;
    transition: transform 0.3s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.auth-toggle input:checked + .auth-toggle-slider {
    background: var(--primary);
}
.auth-toggle input:checked + .auth-toggle-slider::before {
    transform: translateX(22px);
}

/* ========== 渲染异常提示（赛博朋克风格） ========== */
.render-error-bubble {
    margin: 6px 0;
    padding: 0;
    background: transparent;
    border: none;
    font-size: inherit;
    line-height: inherit;
    color: var(--text-sub);
}
.render-error-bubble {
    margin: 8px 0;
    padding: 0;
    background: rgba(255, 60, 0, 0.06);
    border: 1px solid rgba(255, 120, 50, 0.15);
    border-left: 3px solid #ff6b35;
    border-radius: var(--radius-sm);
    overflow: hidden;
}
.render-error-bubble em {
    display: flex;
    align-items: center;
    gap: 6px;
    font-style: normal;
    color: #ff9f6b;
    font-size: 12px;
    font-weight: 600;
    padding: 7px 12px;
    background: rgba(255, 60, 0, 0.08);
    letter-spacing: 0.3px;
    text-shadow: 0 0 8px rgba(255, 120, 50, 0.25);
}
.render-error-bubble em::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    background: #ff6b35;
    border-radius: 50%;
    box-shadow: 0 0 6px rgba(255, 107, 53, 0.6);
    animation: error-pulse 1.5s ease-in-out infinite;
    flex-shrink: 0;
}
@keyframes error-pulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 6px rgba(255, 107, 53, 0.6); }
    50% { opacity: 0.5; box-shadow: 0 0 10px rgba(255, 107, 53, 0.2); }
}
.render-error-bubble pre {
    margin: 0;
    padding: 10px 12px;
    background: rgba(0, 0, 0, 0.3);
    border-top: 1px solid rgba(255, 120, 50, 0.08);
    white-space: pre-wrap;
    word-break: break-word;
    font-family: "SF Mono","Fira Code","Consolas",monospace;
    font-size: 12px;
    line-height: 1.55;
    color: var(--text-muted);
    max-height: 180px;
    overflow-y: auto;
}
/* 用户消息内的错误气泡：覆盖渐变背景，避免亮色块 */
.msg-row.user .msg-bubble .render-error-bubble {
    background: rgba(20, 15, 30, 0.95);
    border-color: rgba(255, 120, 50, 0.2);
    border-left-color: #ff6b35;
}

/* ============================================
   记忆管理面板（Memory Panel）样式系统
   ============================================ */

#memory-modal .modal-card {
    width: 92%;
    max-width: 680px;
    max-height: 86vh;
    padding: 0;
    display: flex;
    flex-direction: column;
    background: linear-gradient(160deg, rgba(15, 18, 35, 0.98) 0%, rgba(10, 12, 25, 0.98) 100%);
    overflow: hidden;
}

/* 面板头部 */
.mem-panel-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 22px 14px;
    border-bottom: 1px solid rgba(0, 240, 255, 0.12);
    background: linear-gradient(180deg, rgba(0, 240, 255, 0.04), transparent);
}
.mem-panel-head-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, rgba(0, 240, 255, 0.2), rgba(120, 80, 255, 0.2));
    color: var(--primary, #00f0ff);
    font-size: 18px;
    box-shadow: 0 4px 16px rgba(0, 240, 255, 0.15);
    border: 1px solid rgba(0, 240, 255, 0.25);
    flex-shrink: 0;
}
.mem-panel-head-title {
    flex: 1;
    min-width: 0;
}
.mem-panel-head-title h3 {
    margin: 0;
    font-size: 17px;
    font-weight: 600;
    color: var(--text-main, #e8e8f0);
    letter-spacing: 0.3px;
}
.mem-panel-head-title p {
    margin: 2px 0 0;
    font-size: 12px;
    color: var(--text-sub, #8888a0);
}
.mem-panel-close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-sub, #8888a0);
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}
.mem-panel-close:hover {
    background: rgba(255, 80, 80, 0.15);
    color: #ff5e5e;
    transform: rotate(90deg);
}

/* 工具栏（搜索 + 添加） */
.mem-toolbar {
    display: flex;
    gap: 10px;
    padding: 14px 22px 10px;
    align-items: center;
}
.mem-search {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
}
.mem-search i {
    position: absolute;
    left: 12px;
    color: var(--text-sub, #8888a0);
    font-size: 13px;
    pointer-events: none;
}
.mem-search input {
    width: 100%;
    padding: 10px 14px 10px 36px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(0, 240, 255, 0.12);
    border-radius: 10px;
    color: var(--text-main, #e8e8f0);
    font-size: 13.5px;
    outline: none;
    transition: all 0.25s ease;
}
.mem-search input::placeholder {
    color: var(--text-sub, #8888a0);
}
.mem-search input:focus {
    border-color: rgba(0, 240, 255, 0.4);
    background: rgba(0, 240, 255, 0.04);
    box-shadow: 0 0 0 3px rgba(0, 240, 255, 0.08);
}
.mem-search input:focus + i,
.mem-search:focus-within i {
    color: var(--primary, #00f0ff);
}
.mem-btn-add {
    padding: 10px 18px;
    border: none;
    border-radius: 10px;
    background: linear-gradient(135deg, #00f0ff 0%, #7850ff 100%);
    color: #0a0a12;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 8px rgba(0, 240, 255, 0.25);
}
.mem-btn-add:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(0, 240, 255, 0.4), 0 0 12px rgba(0, 240, 255, 0.15);
}
.mem-btn-add:active {
    transform: translateY(0) scale(0.98);
}

/* Tabs 区域 */
.mem-tabs {
    display: flex;
    gap: 6px;
    padding: 0 22px 14px;
    overflow-x: auto;
    scrollbar-width: none;
}
.mem-tabs::-webkit-scrollbar {
    display: none;
}
.mem-tab {
    padding: 6px 14px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-sub, #8888a0);
    font-size: 12.5px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
    white-space: nowrap;
    flex-shrink: 0;
}
.mem-tab i {
    font-size: 11px;
    opacity: 0.85;
}
.mem-tab:hover {
    background: rgba(0, 240, 255, 0.08);
    border-color: rgba(0, 240, 255, 0.25);
    color: var(--text-main, #e8e8f0);
}
.mem-tab-active {
    background: linear-gradient(135deg, rgba(0, 240, 255, 0.25), rgba(120, 80, 255, 0.25)) !important;
    border-color: rgba(0, 240, 255, 0.4) !important;
    color: var(--primary, #00f0ff) !important;
    box-shadow: 0 0 8px rgba(0, 240, 255, 0.15);
}
.mem-tab .mem-tab-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 16px;
    padding: 0 5px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    font-size: 10.5px;
    font-weight: 600;
    color: var(--text-main, #e8e8f0);
}
.mem-tab-active .mem-tab-count {
    background: rgba(0, 240, 255, 0.3);
    color: #0a0a12;
}

/* 列表区域 */
#memory-list {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden; /* ★ FIX-2026-10-17：禁止横向滚动，防止分页器等内容撑宽 */
    padding: 4px 14px 14px;
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 240, 255, 0.2) transparent;
}
#memory-list::-webkit-scrollbar {
    width: 6px;
}
#memory-list::-webkit-scrollbar-thumb {
    background: rgba(0, 240, 255, 0.2);
    border-radius: 3px;
}
#memory-list::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 240, 255, 0.35);
}

/* 列表头部（信息条 + 操作按钮） */
.mem-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    margin-bottom: 10px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.04);
    flex-wrap: wrap;
    gap: 8px;
}
.mem-list-info {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-sub, #8888a0);
}
.mem-list-info i {
    color: var(--primary, #00f0ff);
    font-size: 12px;
}
.mem-list-info b {
    color: var(--text-main, #e8e8f0);
    font-weight: 700;
    margin: 0 2px;
}
.mem-list-tab {
    display: inline-block;
    padding: 1px 6px;
    margin: 0 4px;
    border-radius: 4px;
    background: rgba(0, 240, 255, 0.12);
    color: var(--primary, #00f0ff);
    font-size: 11.5px;
    font-weight: 500;
}
.mem-list-actions {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.mem-checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    font-size: 12.5px;
    color: var(--text-sub, #8888a0);
    user-select: none;
}
.mem-checkbox-label input {
    accent-color: var(--primary, #00f0ff);
    width: 14px;
    height: 14px;
    cursor: pointer;
}

.mem-btn {
    padding: 6px 12px;
    border: none;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: all 0.2s ease;
}
.mem-btn-primary {
    background: linear-gradient(135deg, rgba(0, 240, 255, 0.2), rgba(120, 80, 255, 0.2));
    color: var(--primary, #00f0ff);
    border: 1px solid rgba(0, 240, 255, 0.3);
}
.mem-btn-primary:hover {
    background: linear-gradient(135deg, rgba(0, 240, 255, 0.3), rgba(120, 80, 255, 0.3));
    box-shadow: 0 0 8px rgba(0, 240, 255, 0.25);
}
.mem-btn-danger {
    background: rgba(255, 90, 90, 0.12);
    color: #ff6b6b;
    border: 1px solid rgba(255, 90, 90, 0.25);
}
.mem-btn-danger:hover {
    background: rgba(255, 90, 90, 0.22);
    color: #ff8585;
    box-shadow: 0 0 8px rgba(255, 90, 90, 0.18);
}
.mem-btn-warning {
    background: rgba(255, 165, 0, 0.15);
    color: #ffa500;
    border: 1px solid rgba(255, 165, 0, 0.3);
}
.mem-btn-warning:hover {
    background: rgba(255, 165, 0, 0.25);
}

/* 记忆卡片 */
.mem-list-body {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.mem-card {
    display: block;
    position: relative;
    padding: 12px 14px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.025);
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}
.mem-card:hover {
    background: rgba(255, 255, 255, 0.045);
    border-color: rgba(0, 240, 255, 0.18);
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.2), 0 0 12px rgba(0, 240, 255, 0.04);
}
/* checkbox 绝对定位在左上角,完全脱离文档流,不参与宽度计算 */
.mem-card-check {
    position: absolute;
    left: 12px;
    top: 12px;
    z-index: 2;
    cursor: pointer;
    padding: 2px;
    margin: 0;
}
.mem-card-check input {
    accent-color: var(--primary, #00f0ff);
    width: 15px;
    height: 15px;
    cursor: pointer;
}

/* body 只给 checkbox 预留左侧空间;actions 绝对定位在右上角,文本铺满卡片右侧 */
.mem-card-body {
    display: block;
    width: auto;
    margin-left: 26px;   /* checkbox ~19px + gap */
    margin-right: 0;
    box-sizing: border-box;
}
.mem-card-body > * {
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
}

/* 操作按钮绝对定位在右上角,完全脱离文档流 */
.mem-card-actions {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 2;
    display: flex;
    align-items: center;
    gap: 4px;
}

.mem-card-key {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text-main, #e8e8f0);
    line-height: 1.5;
    display: flex;
    align-items: flex-start;
    gap: 6px;
    word-break: break-word;
    overflow-wrap: anywhere;
    max-width: 100%;
    min-width: 0;
    width: 100%;
}
.mem-card-key span {
    flex: 1;
    min-width: 0;
    width: 100%;
    max-width: 100%;
    word-break: break-all;
    overflow: hidden;
    box-sizing: border-box;
    /* max-height 由 JS autoCollapseMemoryValues 根据 line-height * 2 + 0.5 设置 */
}
.mem-card-value {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
    font-size: 12.5px;
    color: var(--text-sub, #b0b0c0);
    line-height: 1.6;
    word-break: break-word;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}
.mem-card-value-collapsed {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
    overflow: hidden;
    /* 折叠预览时忽略原始文本中的换行符，按容器宽度自然换行，避免右侧留白 */
    white-space: normal;
    /* max-height 由 JS autoCollapseMemoryValues 根据 line-height * 3 + 0.5 设置 */
}

.mem-card-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-top: 2px;
    max-width: 100%;
}
.mem-card-meta > * {
    max-width: 100%;
}
.mem-card-meta-top {
    margin-top: 0;
    margin-bottom: 6px;
}

/* Level 徽章 */
.mem-level {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 500;
    line-height: 1.5;
}
.mem-level i {
    font-size: 10px;
}
.mem-level em {
    font-style: normal;
    opacity: 0.7;
    margin-left: 2px;
}
.mem-level-long {
    background: rgba(255, 149, 0, 0.12);
    color: #ff9500;
    border: 1px solid rgba(255, 149, 0, 0.2);
}
.mem-level-mid {
    background: rgba(0, 240, 255, 0.1);
    color: var(--primary, #00f0ff);
    border: 1px solid rgba(0, 240, 255, 0.22);
}
.mem-level-short {
    background: rgba(142, 142, 147, 0.15);
    color: #b0b0c0;
    border: 1px solid rgba(142, 142, 147, 0.25);
}

.mem-cat {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-sub, #8888a0);
    font-size: 11px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}
.mem-cat i {
    font-size: 9px;
    opacity: 0.7;
}

.mem-time {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--text-sub, #8888a0);
    font-size: 11px;
    font-weight: 500;
}
.mem-time i {
    font-size: 10px;
    opacity: 0.7;
}

/* 卡片右侧操作按钮(absolute 定位已定义在 .mem-card 区块,这里只保留按钮本身样式) */
.mem-action-btn {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.04);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    transition: all 0.2s ease;
}
.mem-action-edit {
    color: var(--primary, #00f0ff);
    border: 1px solid rgba(0, 240, 255, 0.12);
}
.mem-action-edit:hover {
    background: rgba(0, 240, 255, 0.15);
    border-color: rgba(0, 240, 255, 0.4);
    transform: scale(1.1);
}
.mem-action-delete {
    color: #ff6b6b;
    border: 1px solid rgba(255, 90, 90, 0.12);
}
.mem-action-delete:hover {
    background: rgba(255, 90, 90, 0.15);
    border-color: rgba(255, 90, 90, 0.4);
    transform: scale(1.1);
}

/* 展开/收起按钮 */
.mem-expand-btn {
    align-self: flex-start;
    padding: 2px 4px;
    margin: 2px 0 0;
    background: none;
    border: none;
    color: var(--primary, #00f0ff);
    font-size: 11.5px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: all 0.2s ease;
    opacity: 0.8;
}
.mem-expand-btn:hover {
    opacity: 1;
}
.mem-expand-btn i {
    font-size: 10px;
    transition: transform 0.3s ease;
}
.mem-expand-btn-active i {
    transform: rotate(180deg);
}

/* 回收站卡片样式（meta 在顶部，操作按钮在底部，不遮挡正文） */
.mem-card-recycle {
    /* 无 checkbox,不需要预留左侧 */
}
.mem-card-recycle .mem-card-body {
    margin-left: 0;
    margin-right: 0;
    padding-bottom: 44px; /* 为底部操作按钮预留空间 */
}
.mem-card-recycle .mem-card-actions {
    position: absolute;
    top: auto;
    left: 12px;
    right: 12px;
    bottom: 10px;
    display: flex;
    justify-content: flex-end;
    gap: 6px;
}
.mem-card-recycle .mem-action-btn {
    width: auto;
    height: auto;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
}

/* 加载骨架屏 */
.mem-skeleton {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 14px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.025);
    border: 1px solid rgba(255, 255, 255, 0.04);
    margin-bottom: 8px;
}
.mem-skeleton-check {
    width: 15px;
    height: 15px;
    border-radius: 3px;
    background: linear-gradient(90deg, rgba(255,255,255,0.05) 0%, rgba(255,255,255,0.1) 50%, rgba(255,255,255,0.05) 100%);
    background-size: 200% 100%;
    animation: mem-skeleton-shimmer 1.4s infinite;
    margin-top: 3px;
    flex-shrink: 0;
}
.mem-skeleton-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.mem-skeleton-line {
    height: 12px;
    border-radius: 4px;
    background: linear-gradient(90deg, rgba(255,255,255,0.05) 0%, rgba(255,255,255,0.1) 50%, rgba(255,255,255,0.05) 100%);
    background-size: 200% 100%;
    animation: mem-skeleton-shimmer 1.4s infinite;
}
.mem-skeleton-line-md { width: 35%; }
.mem-skeleton-line-lg { width: 85%; }
.mem-skeleton-line-sm { width: 25%; }
@keyframes mem-skeleton-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* 空状态 */
.mem-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    text-align: center;
    color: var(--text-sub, #8888a0);
}
.mem-empty-icon {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(0, 240, 255, 0.08), rgba(120, 80, 255, 0.08));
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
    font-size: 30px;
    color: var(--primary, #00f0ff);
    opacity: 0.5;
    border: 1px solid rgba(0, 240, 255, 0.15);
}
.mem-empty-title {
    font-size: 15px;
    font-weight: 500;
    color: var(--text-main, #e8e8f0);
    margin-bottom: 6px;
}
.mem-empty-hint {
    font-size: 12.5px;
    color: var(--text-sub, #8888a0);
    opacity: 0.8;
    max-width: 280px;
    line-height: 1.5;
}

/* 错误状态 */
.mem-error {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 30px 20px;
    color: #ff6b6b;
    font-size: 13px;
    text-align: center;
}
.mem-error i {
    font-size: 16px;
}

/* 移动端响应式（记忆管理面板） */
@media (max-width: 640px) {
    /* 模态:全屏底部抽屉 */
    #memory-modal .modal-card {
        width: 100%;
        max-width: 100%;
        border-radius: 16px 16px 0 0;
        max-height: 94vh;
        margin-top: 6vh;
    }

    /* 头部紧凑 */
    .mem-panel-head {
        padding: 12px 14px 10px;
        gap: 10px;
    }
    .mem-panel-head-icon {
        width: 34px;
        height: 34px;
        font-size: 16px;
        border-radius: 9px;
    }
    .mem-panel-head-title h3 {
        font-size: 16px;
    }
    .mem-panel-head-title p {
        font-size: 11.5px;
        line-height: 1.4;
        margin-top: 2px;
    }
    .mem-panel-close {
        width: 28px;
        height: 28px;
        font-size: 13px;
    }

    /* 工具栏 */
    .mem-toolbar {
        padding: 10px 14px 8px;
        gap: 8px;
    }
    .mem-search i {
        left: 11px;
        font-size: 12px;
    }
    .mem-search input {
        padding: 9px 12px 9px 32px;
        font-size: 13px;
    }
    .mem-btn-add {
        padding: 9px 14px;
        font-size: 12.5px;
    }

    /* Tabs - 紧凑 padding + 字号,可横向滚动 */
    .mem-tabs {
        padding: 0 14px 10px;
        gap: 5px;
        flex-wrap: nowrap;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    .mem-tabs::-webkit-scrollbar {
        display: none;
    }
    .mem-tab {
        padding: 5px 10px;
        font-size: 12px;
        flex-shrink: 0;
    }
    .mem-tab i {
        font-size: 10px;
    }
    .mem-tab .mem-tab-count {
        min-width: 16px;
        height: 15px;
        font-size: 10px;
        padding: 0 4px;
    }

    /* 列表 */
    #memory-list {
        padding: 4px 6px 10px;
    }

    /* 列表头部垂直堆叠,操作按钮全宽 */
    .mem-list-header {
        flex-direction: column;
        align-items: stretch;
        padding: 8px 10px;
        gap: 8px;
    }
    .mem-list-info {
        font-size: 12px;
        justify-content: space-between;
    }
    .mem-list-info b {
        font-size: 13px;
    }
    .mem-list-tab {
        font-size: 11px;
        margin: 0 2px;
    }
    .mem-list-actions {
        justify-content: stretch;
        gap: 6px;
        flex-wrap: wrap;
    }
    .mem-list-actions .mem-checkbox-label {
        font-size: 12px;
        flex: 0 0 auto;
    }
    .mem-list-actions .mem-btn {
        flex: 1;
        justify-content: center;
        padding: 6px 8px;
        font-size: 11.5px;
        min-width: 0;
    }
    .mem-list-actions .mem-btn i {
        font-size: 10px;
    }

    /* 卡片紧凑 */
    .mem-card {
        padding: 10px;
    }
    .mem-card-check {
        left: 8px;
        top: 10px;
    }
    .mem-card-check input {
        width: 16px;
        height: 16px;
    }
    .mem-card-body {
        margin-left: 24px;   /* checkbox 16 + gap 8 */
        margin-right: 0;     /* actions 绝对定位,文本铺满右侧 */
    }
    .mem-card-key {
        font-size: 13px;
        line-height: 1.45;
        gap: 5px;
        /* 下移避开右上角编辑/删除按钮(按钮 top:8px + 高 30px = 38px,卡片 padding-top 10px,需下移约 30px) */
        margin-top: 30px;
    }
    .mem-card-key span {
        word-break: break-all;
    }
    .mem-key-icon {
        font-size: 10px;
        margin-top: 3px;
    }
    .mem-card-value {
        font-size: 12px;
        line-height: 1.55;
    }
    .mem-card-value-collapsed {
        /* max-height 由 JS 控制 */
    }
    .mem-card-meta {
        gap: 5px;
    }
    .mem-card-actions {
        top: 8px;
        right: 6px;
        gap: 3px;
    }
    .mem-action-btn {
        width: 30px;
        height: 30px;
        font-size: 12px;
        border-radius: 7px;
    }

    /* 回收站卡片:操作按钮在底部水平铺开 */
    .mem-card-recycle .mem-card-body {
        gap: 5px;
        margin-left: 0;
        margin-right: 0;
        padding-bottom: 44px;
    }
    .mem-card-recycle .mem-card-meta-top {
        margin-bottom: 4px;
    }
    .mem-card-recycle .mem-card-actions {
        position: absolute;
        top: auto;
        left: 10px;
        right: 10px;
        bottom: 8px;
        display: flex;
        flex-direction: row;
        justify-content: stretch;
        gap: 6px;
    }
    .mem-card-recycle .mem-action-btn {
        flex: 1;
        width: auto;
        padding: 7px 10px;
        height: auto;
        border-radius: 8px;
    }
    .mem-card-recycle .mem-action-btn i {
        font-size: 11px;
    }

    /* meta 徽章紧凑 */
    .mem-level, .mem-cat {
        font-size: 10.5px;
        padding: 1px 6px;
    }
    .mem-level em {
        font-size: 10px;
    }
    .mem-time {
        font-size: 10.5px;
    }
    .mem-time i {
        font-size: 9px;
    }

    /* 展开按钮 */
    .mem-expand-btn {
        font-size: 11px;
        margin-top: 1px;
    }

    /* 底部全宽 */
    .mem-panel-foot {
        padding: 10px 14px 14px;
    }
    .mem-panel-foot .btn-cancel {
        min-width: 100%;
        padding: 10px;
    }

    /* 空状态紧凑 */
    .mem-empty {
        padding: 36px 16px;
    }
    .mem-empty-icon {
        width: 60px;
        height: 60px;
        font-size: 26px;
        margin-bottom: 12px;
    }
    .mem-empty-title {
        font-size: 14px;
    }
    .mem-empty-hint {
        font-size: 12px;
        max-width: 240px;
    }

    /* 错误状态紧凑 */
    .mem-error {
        padding: 24px 16px;
        font-size: 12px;
    }
    .mem-error i {
        font-size: 14px;
    }
}

/* 极小屏(< 380px)适配 */
@media (max-width: 380px) {
    .mem-panel-head-title p {
        display: none;
    }
    .mem-tab {
        padding: 4px 9px;
        font-size: 11.5px;
    }
    .mem-btn-add span {
        display: none;
    }
    .mem-btn-add {
        padding: 9px 12px;
    }
    .mem-card-key {
        font-size: 12.5px;
    }
}

/* 中等屏(641-900px)适配 */
@media (min-width: 641px) and (max-width: 900px) {
    #memory-modal .modal-card {
        width: 92%;
        max-width: 560px;
    }
}

/* 面板底部关闭按钮区 */
.mem-panel-foot {
    padding: 12px 22px 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    background: rgba(0, 0, 0, 0.15);
    display: flex;
    justify-content: flex-end;
    flex-shrink: 0;
}
.mem-panel-foot .btn-cancel {
    min-width: 100px;
}

/* ====== 2026-08-28：移动端 #app-area 用 flex:1 撑满 body 高度 ======
   原仅靠 height:100%（嵌套百分比），部分 Android WebView 下解析失败，
   导致空内容时页面高度塌陷、收到 AI 回复后才占满。改用 flex 填充更可靠。 */
@media (max-width: 768px) {
    #app-area {
        flex: 1 1 0;
    }
}

/* ===== ```app 沙箱应用块（2026-10-11） ===== */
.app-block {
    margin: 10px 0;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--input-bg);
    overflow: hidden;
}
.app-block-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 10px;
    background: rgba(127, 127, 127, 0.08);
    border-bottom: 1px solid var(--border);
}
.app-block-title {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-sub);
}
.app-block-actions {
    display: inline-flex;
    gap: 6px;
}
.app-block-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    font-size: 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--input-bg);
    color: var(--text-main);
    cursor: pointer;
}
.app-block-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}
.app-block-btn.active {
    border-color: var(--primary);
    color: var(--primary);
}
.app-btn-run {
    color: #34C759;
    border-color: rgba(52, 199, 89, 0.4);
}
.app-btn-run:hover {
    color: #34C759;
    border-color: #34C759;
}
.app-btn-stop {
    color: #FF3B30;
    border-color: rgba(255, 59, 48, 0.4);
}
.app-btn-stop:hover {
    color: #FF3B30;
    border-color: #FF3B30;
}
.app-block-code {
    max-height: 240px;
    overflow: auto;
    border-bottom: 1px solid var(--border);
}
.app-block-mount:empty {
    display: none;
}
.app-frame {
    display: block;
    width: 100%;
    height: 420px;
    border: 0;
    background: #fff;
}
.app-block:fullscreen {
    display: flex;
    flex-direction: column;
    border-radius: 0;
    background: var(--input-bg);
}
.app-block:fullscreen .app-block-header {
    flex: 0 0 auto;
}
.app-block:fullscreen .app-frame {
    flex: 1 1 auto;
    height: auto;
}

/* ===== ```audio 语音消息块（2026-10-12） ===== */
.audio-msg {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin: 8px 0;
    padding: 10px 14px;
    min-width: 230px;
    max-width: 340px;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: 18px;
    border-bottom-left-radius: 4px;
}
.audio-play-btn {
    flex: 0 0 auto;
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 50%;
    background: var(--primary, #4a9eff);
    color: #fff;
    font-size: 12px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.audio-play-btn:active {
    transform: scale(0.94);
}
.audio-wave {
    flex: 1 1 auto;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    height: 24px;
}
.audio-wave span {
    width: 3px;
    border-radius: 2px;
    background: var(--text-sub, #888);
    opacity: 0.5;
    height: 30%;
}
.audio-wave span:nth-child(1) { height: 40%; }
.audio-wave span:nth-child(2) { height: 70%; }
.audio-wave span:nth-child(3) { height: 100%; }
.audio-wave span:nth-child(4) { height: 65%; }
.audio-wave span:nth-child(5) { height: 35%; }
.audio-msg.playing .audio-wave span {
    background: var(--primary, #4a9eff);
    opacity: 0.9;
    animation: audioWaveBounce 0.9s ease-in-out infinite;
}
.audio-msg.playing .audio-wave span:nth-child(2) { animation-delay: 0.15s; }
.audio-msg.playing .audio-wave span:nth-child(3) { animation-delay: 0.3s; }
.audio-msg.playing .audio-wave span:nth-child(4) { animation-delay: 0.45s; }
.audio-msg.playing .audio-wave span:nth-child(5) { animation-delay: 0.6s; }
@keyframes audioWaveBounce {
    0%, 100% { transform: scaleY(0.4); }
    50% { transform: scaleY(1); }
}
.audio-meta {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}
.audio-title {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.audio-title i {
    font-size: 10px;
    color: var(--text-sub);
    margin-right: 2px;
}
.audio-status {
    font-size: 11px;
    color: var(--text-sub);
}
.audio-msg.error .audio-status {
    color: #FF3B30;
}
.audio-msg.loading .audio-wave span {
    animation: audioWaveBounce 0.6s ease-in-out infinite;
}

/* ===== ```video 视频消息块（2026-10-12，仅 URL） ===== */
.video-msg {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 8px 0;
    padding: 8px;
    max-width: 360px;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: 18px;
    border-bottom-left-radius: 4px;
}
.video-player {
    display: block;
    width: 100%;
    max-height: 240px;
    border-radius: 12px;
    background: #000;
    outline: none;
}
.video-meta {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-main);
    padding: 0 4px 2px;
    /* [NOTRUNC-2026-12-03] 标题不允许截断（姚哥铁律）：自动换行完整展示 */
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
    line-height: 1.5;
}
.video-meta i {
    font-size: 11px;
    color: var(--text-sub);
    margin-right: 4px;
}
.video-msg-error {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    font-size: 12.5px;
    font-weight: 400;
    color: #FF3B30;
}

/* ===== ```image 图片消息块（2026-10-12，仅 URL） ===== */
.image-msg {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 8px 0;
    padding: 8px;
    max-width: 360px;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: 18px;
    border-bottom-left-radius: 4px;
}
.image-player {
    display: block;
    width: 100%;
    max-height: 320px;
    object-fit: contain;
    border-radius: 12px;
    background: var(--input-bg);
    cursor: pointer;
    outline: none;
}
.image-meta {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-main);
    padding: 0 4px 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.image-meta i {
    font-size: 11px;
    color: var(--text-sub);
    margin-right: 4px;
}
.image-msg-error {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    font-size: 12.5px;
    font-weight: 400;
    color: #FF3B30;
}

/* ===== ★ 2026-10-17：用户消息导航（悬浮计数按钮 + 历史消息弹窗 + 跳转高亮） ===== */
.msg-nav-fab {
    position: fixed;
    right: 16px;
    bottom: 270px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(28, 28, 46, 0.2); /* ★ 2026-10-17：仅 20% 淡底，去除 backdrop blur——模糊会把背后文字糊掉，保留边框提供可视性 */
    border: 1px solid rgba(0, 240, 255, 0.35);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 100;
    transition: all 0.2s ease;
    color: var(--primary, #00f0ff);
    font-size: 16px;
}
.msg-nav-fab:hover {
    border-color: var(--primary, #00f0ff);
    box-shadow: 0 4px 20px rgba(0, 240, 255, 0.25);
    transform: translateY(-2px);
}
.msg-nav-count {
    position: absolute;
    top: -5px;
    right: -5px;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    border-radius: 9px;
    background: var(--primary, #00f0ff);
    color: #06111c;
    font-size: 11px;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
    font-variant-numeric: tabular-nums;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}
.user-msg-history-list {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    margin: 12px 0;
    padding: 4px 2px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.user-msg-item {
    padding: 9px 12px;
    border-radius: var(--radius-sm, 8px);
    background: var(--input-bg, rgba(255, 255, 255, 0.04));
    border: 1px solid transparent;
    cursor: pointer;
    text-align: right;
    transition: all 0.15s ease;
}
.user-msg-item:hover {
    border-color: var(--primary, #00f0ff);
    background: rgba(0, 240, 255, 0.06);
}
.user-msg-item-text {
    color: var(--text-main, #eee);
    font-size: 13.5px;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-all;
}
.user-msg-item-time {
    margin-top: 4px;
    color: var(--text-muted, #888);
    font-size: 11px;
    font-variant-numeric: tabular-nums;
}
.user-msg-history-empty {
    text-align: center;
    color: var(--text-sub, #999);
    padding: 30px 0;
    font-size: 14px;
}
/* 跳转定位高亮：仅用 box-shadow 描边光晕闪烁，不动画 background
   （★ FIX-2026-10-17：原版关键帧带 background: transparent，会覆盖气泡自身
   背景色导致闪烁期间气泡发黑、文字看不清；box-shadow 不影响气泡底色） */
@keyframes msgJumpFlash {
    0%, 100% { box-shadow: 0 0 0 0 rgba(0, 240, 255, 0); }
    20%, 60% { box-shadow: 0 0 0 3px var(--primary, #00f0ff), 0 0 20px rgba(0, 240, 255, 0.45); }
}
.msg-row.msg-jump-flash .msg-bubble {
    animation: msgJumpFlash 2.2s ease;
    border-radius: 12px;
}

/* ★ 2026-10-17 补充：悬浮按钮长按拖动 */
.msg-nav-fab {
    touch-action: none;          /* 阻止触摸设备上拖动时触发页面滚动 */
    cursor: grab;
    -webkit-touch-callout: none; /* 阻止 Android/iOS 长按弹出系统菜单 */
    -webkit-user-select: none;
    user-select: none;
}
.msg-nav-fab.dragging {
    transition: none;            /* 拖动中关闭过渡，保证实时跟手 */
    cursor: grabbing;
    transform: none;             /* 覆盖 :hover 的 translateY 位移 */
    opacity: 0.92;
    border-color: var(--primary, #00f0ff);
    box-shadow: 0 8px 28px rgba(0, 240, 255, 0.35);
}

/* ===== ★ 2026-10-17：记忆列表分页器（每页 10 条防卡顿） ===== */
.mem-pager {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 10px 0 2px;
    flex-wrap: wrap;      /* ★ FIX-2026-10-17：窄屏允许换行，防止 5 个按钮撑出横向滚动条 */
    row-gap: 6px;
    max-width: 100%;
    overflow-x: hidden;
}
.mem-pager-info {
    color: var(--text-sub, #9aa7b8);
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.mem-btn-page {
    padding: 5px 14px;
    font-size: 12.5px;
    border-radius: 8px;
    background: rgba(0, 240, 255, 0.06);
    border: 1px solid rgba(0, 240, 255, 0.25);
    color: var(--primary, #00f0ff);
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
    flex-shrink: 0;
}
.mem-btn-page:hover:not(:disabled) {
    border-color: var(--primary, #00f0ff);
    background: rgba(0, 240, 255, 0.12);
}
.mem-btn-page:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}
/* ★ 移动端：按钮去图标 + 压缩尺寸，保证 五按钮+页码 一行放得下（末页不再单独折行） */
@media (max-width: 640px) {
    .mem-pager {
        gap: 4px;
        padding: 8px 0 2px;
    }
    .mem-btn-page {
        padding: 3px 6px;
        font-size: 11px;
    }
    .mem-btn-page i {
        display: none; /* 图标占位约 14px/个，移动端纯文字足够表达 */
    }
    .mem-pager-info {
        font-size: 10.5px;
    }
    .mem-pager-extra {
        display: none; /* "本页 N 条"属次要信息，移动端隐藏进一步缩宽 */
    }
}

/* ===== LLM 笔记折叠列表（仅面板内，避免影响聊天气泡 details） ===== */
#llm-prompt-list details {
    background: var(--input-bg) !important;
}
#llm-prompt-list summary {
    list-style: none !important;
}
#llm-prompt-list summary::-webkit-details-marker {
    display: none !important;
}
#llm-prompt-list details > div {
    background: transparent !important;
    color: var(--text) !important;
}

/* ===== LLM 笔记折叠列表（仅面板内，避免影响聊天气泡 details） ===== */
#llm-prompt-list details {
    background: var(--input-bg) !important;
}
#llm-prompt-list summary {
    list-style: none !important;
}
#llm-prompt-list summary::-webkit-details-marker {
    display: none !important;
}
#llm-prompt-list details > div {
    background: transparent !important;
    color: var(--text) !important;
}

/* ===== [ATTACH-2026-11-30] 输入框 + 选择器：工具/技能/MCP（选中即随消息强制送 LLM） ===== */
.btn-attach {
    background: transparent;
    color: var(--text-sub);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    margin-bottom: 2px;
    font-size: 20px;
    transition: background, color, box-shadow, transform 0.2s ease;
}
.btn-attach:hover { color: var(--primary); background: var(--btn-blue-bg); transform: rotate(90deg); }
.btn-attach:active { transform: rotate(90deg) scale(0.9); }
.btn-attach.active { color: var(--primary); background: var(--btn-blue-bg); transform: rotate(45deg); }
.input-attach-wrap { position: relative; flex-shrink: 0; display: flex; align-items: flex-end; }

.attach-panel {
    position: absolute;
    /* [ATTACH-MERGE-2026-11-30] 已并入「...」菜单：面板浮在该菜单上方 */
    bottom: calc(100% + 8px);
    left: 0;
    width: 460px;
    max-width: calc(100vw - 32px);
    background: rgba(15, 18, 32, 0.98);
    border: 1px solid rgba(0, 240, 255, 0.28);
    border-radius: 14px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.65), 0 0 24px rgba(0,240,255,0.1);
    padding: 10px;
    z-index: 210;
    backdrop-filter: blur(14px);
    animation: attach-in 0.18s ease;
}
@keyframes attach-in { from { opacity:0; transform: translateY(8px); } to { opacity:1; transform: translateY(0); } }
.attach-tabs { display: flex; gap: 6px; margin-bottom: 10px; border-bottom: 1px solid var(--border); padding-bottom: 8px; }
.attach-tab {
    flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px;
    padding: 8px 6px; background: transparent; color: var(--text-sub);
    border: 1px solid transparent; border-radius: 8px; cursor: pointer; font-size: 13px;
    transition: background, color, border-color 0.15s ease;
}
.attach-tab i { font-size: 14px; }
.attach-tab:hover { color: var(--primary); background: rgba(0,240,255,0.06); }
.attach-tab.active { color: var(--primary); background: var(--btn-blue-bg); border-color: rgba(0,240,255,0.25); }
.attach-search { position: relative; margin-bottom: 8px; }
.attach-search i { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-sub); font-size: 12px; pointer-events: none; }
.attach-search input {
    width: 100%; box-sizing: border-box; background: var(--input-bg);
    border: 1px solid var(--border-light); border-radius: 8px;
    padding: 7px 10px 7px 30px; font-size: 12.5px; color: var(--text-main); outline: none;
}
.attach-search input:focus { border-color: var(--primary); }
.attach-list { max-height: 300px; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.attach-empty { text-align: center; color: var(--text-sub); padding: 18px; font-size: 12px; }
.attach-item {
    display: flex; align-items: center; gap: 10px; padding: 8px 10px;
    border-radius: 8px; cursor: pointer; transition: background 0.15s ease;
}
.attach-item:hover { background: rgba(0,240,255,0.08); }
.attach-item.chosen { background: rgba(0,240,255,0.12); }
.attach-item-icon { width: 30px; height: 30px; flex-shrink: 0; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 13px; }
.attach-item-icon.tool { background: rgba(33,150,243,0.16); color: #42A5F5; }
.attach-item-icon.skill { background: rgba(233,30,99,0.16); color: #F06292; }
.attach-item-icon.mcp { background: rgba(156,39,176,0.16); color: #BA68C8; }
.attach-item-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.attach-item-name { font-size: 13px; color: var(--text-main); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach-item-desc { font-size: 11px; color: var(--text-sub); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach-item-check { width: 18px; flex-shrink: 0; text-align: center; color: var(--primary); font-size: 14px; }
.attach-foot { display: flex; align-items: center; gap: 6px; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); font-size: 11px; color: var(--text-sub); }
.attach-foot i { color: var(--primary); }

.attach-chip-bar { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 4px 8px; }
.attach-chip {
    display: inline-flex; align-items: center; gap: 6px; padding: 4px 8px;
    border-radius: 12px; font-size: 11.5px; border: 1px solid var(--border-light);
    background: var(--card-bg); color: var(--text-main); max-width: 220px;
}
.attach-chip.tool { border-color: rgba(66,165,245,0.5); }
.attach-chip.skill { border-color: rgba(240,98,146,0.5); }
.attach-chip.mcp { border-color: rgba(186,104,200,0.5); }
.attach-chip.tool > i:first-child { color: #42A5F5; }
.attach-chip.skill > i:first-child { color: #F06292; }
.attach-chip.mcp > i:first-child { color: #BA68C8; }
.attach-chip-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach-chip > .fa-xmark { color: var(--text-sub); cursor: pointer; font-size: 12px; }
.attach-chip > .fa-xmark:hover { color: var(--danger); }

@media (max-width: 640px) {
    .attach-panel { width: calc(100vw - 24px); left: 0; }
}

/* ===== [ATTACH-2026-11-30 fix] 消息气泡内附件标记（发出后可见技能/工具/MCP 已附加） ===== */
.msg-attach-badges { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 6px; }
.msg-attach-badge {
    display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px;
    border-radius: 10px; font-size: 11px; line-height: 1.4;
    border: 1px solid var(--border-light); background: rgba(0,0,0,0.22);
    color: var(--text-main); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.msg-attach-badge i { flex-shrink: 0; }
.msg-attach-badge.tool { border-color: rgba(66,165,245,0.55); color: #8CC9FF; }
.msg-attach-badge.skill { border-color: rgba(240,98,146,0.55); color: #FFA6C6; }
.msg-attach-badge.mcp { border-color: rgba(186,104,200,0.55); color: #DDA6EA; }

/* ===== [ATTACH-2026-11-30 fix] 消息气泡内附件标记（发出后可见技能/工具/MCP 已附加） ===== */
.msg-attach-badges { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 6px; }
.msg-attach-badge {
    display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px;
    border-radius: 10px; font-size: 11px; line-height: 1.4;
    border: 1px solid var(--border-light); background: rgba(0,0,0,0.22);
    color: var(--text-main); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.msg-attach-badge i { flex-shrink: 0; }
.msg-attach-badge.tool { border-color: rgba(66,165,245,0.55); color: #8CC9FF; }
.msg-attach-badge.skill { border-color: rgba(240,98,146,0.55); color: #FFA6C6; }
.msg-attach-badge.mcp { border-color: rgba(186,104,200,0.55); color: #DDA6EA; }

/* ===== [BGVIDEO-20261204] 全屏背景视频轮播 =====
   视频层固定在最底层；主内容容器仅在 body.bgvideo-on 时局部透明化。
   JS 关闭时不注入 DOM 也不加 class，以下覆盖规则自动失效，页面恢复原纯黑背景。 */
#bg-video-layer {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
    background: #000;
}
#bg-video-layer video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    opacity: 0;
    transition: opacity 0.7s ease;
}
#bg-video-layer video.bgvideo-active { opacity: 1; }
/* 暗化遮罩：保证白色/浅色文字在任意视频画面上都有足够对比度 */
#bg-video-layer::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(0,0,0,.28) 0%, rgba(0,0,0,.42) 100%);
}
body.bgvideo-on .header { background: rgba(5,5,5,.28) !important; }
body.bgvideo-on .status-bar { background: rgba(10,10,20,.72) !important; }
body.bgvideo-on .sidebar { background: rgba(12,12,25,.28) !important; }
body.bgvideo-on .input-area { background: rgba(12,12,25,.76) !important; }
body.bgvideo-on .msg-row.ai .msg-bubble { background: rgba(15,15,30,.80) !important; }
body.bgvideo-on .input-box { background: rgba(17,17,17,.84) !important; }
body.bgvideo-on .input-box:focus { background: rgba(24,24,24,.92) !important; }

/* ===== [UIHIDE-20261204] 侧栏切换按钮同时隐藏顶栏与侧栏 =====
   隐藏后顶栏收起为仅保留 .btn-menu 的小入口，点击即可恢复 */
body.ui-hidden .sidebar { display: none !important; }
body.ui-hidden .header {
    position: fixed !important;
    left: 12px;
    top: 12px;
    z-index: 9998 !important;
    width: auto !important;
    height: auto !important;
    padding: 5px 8px !important;
    border: 1px solid rgba(0,240,255,.35) !important;
    border-radius: 10px !important;
    background: rgba(5,5,5,.28) !important;
    box-shadow: 0 2px 10px rgba(0,0,0,.45) !important;
}
body.ui-hidden .header > *:not(.header-title) { display: none !important; }
body.ui-hidden .header-title > *:not(.btn-menu) { display: none !important; }

/* ===== [GLASS-20261204] 全界面半透明化（仅背景开启时生效） =====
   覆盖按钮/气泡/容器/弹窗等所有可见 UI 元素的背景为半透明，让背景透出。
   只改背景 alpha（必要时加轻微毛玻璃），不动文字颜色与边框；
   关闭背景视频时 body 无 bgvideo-on，整块规则自动失效，页面恢复原样。
   流式气泡沿用既有防闪烁策略：只降 alpha，不启用 backdrop-filter。 */
body.bgvideo-on .header { background: rgba(5,5,5,.30) !important; }
body.bgvideo-on .status-bar { background: rgba(10,10,20,.58) !important; }
body.bgvideo-on .sidebar { background: rgba(12,12,25,.32) !important; }
body.bgvideo-on .input-area { background: rgba(12,12,25,.55) !important; }
body.bgvideo-on .input-box { background: rgba(17,17,17,.60) !important; }
body.bgvideo-on .input-box:focus { background: rgba(24,24,24,.72) !important; }

/* 用户气泡：半透明青蓝渐变 + 轻微毛玻璃，深色文字加浅色阴影保证暗背景下可读 */
body.bgvideo-on .msg-row.user .msg-bubble {
    background: linear-gradient(135deg, rgba(0,240,255,.10) 0%, rgba(0,102,255,.10) 100%) !important;
    backdrop-filter: none !important; -webkit-backdrop-filter: none !important;
    color: #fff !important;
    text-shadow: 0 1px 3px rgba(0,0,0,.85), 0 0 2px rgba(0,0,0,.7);
}
/* AI 气泡：只降 alpha，不启用 blur（流式渲染防闪烁） */
body.bgvideo-on .msg-row.ai .msg-bubble { background: rgba(15,15,30,.42) !important; }
body.bgvideo-on .msg-row.ai.error .msg-bubble { background: rgba(255,59,48,.10) !important; }

/* 思考块 / 工具卡片（含思考过程标题条，再降 10 个百分点） */
body.bgvideo-on .think-block { background: rgba(124,77,255,.05) !important; }
body.bgvideo-on .think-block.open { background: rgba(124,77,255,.08) !important; }
body.bgvideo-on .think-summary { background: rgba(124,77,255,.03) !important; }
body.bgvideo-on .think-block.open .think-summary { background: rgba(124,77,255,.05) !important; }
body.bgvideo-on .think-summary:hover { background: rgba(124,77,255,.08) !important; }
body.bgvideo-on .think-num { background: rgba(124,77,255,.10) !important; }
body.bgvideo-on .tool-call-item { background: rgba(0,240,255,.05) !important; }
body.bgvideo-on .tool-call-item.running { background: rgba(255,193,7,.10) !important; }
body.bgvideo-on .tool-call-item.success { background: rgba(0,255,136,.07) !important; }
body.bgvideo-on .tool-call-item.error { background: rgba(255,59,48,.08) !important; }

/* 会话列表项 */
body.bgvideo-on .session-item { background: rgba(12,12,25,.30) !important; }
body.bgvideo-on .session-item.active { background: linear-gradient(135deg, rgba(0,240,255,.16) 0%, rgba(0,102,255,.08) 100%) !important; }

/* 侧栏按钮 */
body.bgvideo-on .btn-sidebar-new { background: linear-gradient(135deg, rgba(0,240,255,.10) 0%, rgba(0,102,255,.10) 100%) !important; color: #fff !important; text-shadow: 0 1px 3px rgba(0,0,0,.85), 0 0 2px rgba(0,0,0,.7); }
body.bgvideo-on .btn-sidebar-action { background: rgba(17,17,17,.55) !important; }
body.bgvideo-on .btn-sidebar-action:hover { background: rgba(0,240,255,.20) !important; }

/* 输入区按钮 */
body.bgvideo-on .btn-send { background: linear-gradient(135deg, rgba(0,240,255,.82) 0%, rgba(0,102,255,.82) 100%) !important; }
body.bgvideo-on .btn-stop { background: rgba(255,59,48,.70) !important; }
body.bgvideo-on .btn-menu { background: rgba(12,12,25,.45) !important; }

/* 弹窗卡片 + 通用操作按钮（弹窗不与流式渲染叠加，可加毛玻璃） */
body.bgvideo-on .modal-card { background: rgba(10,10,20,.82) !important; backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); }
body.bgvideo-on .btn-cancel { background: rgba(17,17,17,.65) !important; }
body.bgvideo-on .btn-confirm { background: linear-gradient(135deg, rgba(0,240,255,.8) 0%, rgba(0,102,255,.8) 100%) !important; }
body.bgvideo-on .btn-primary { background: linear-gradient(135deg, rgba(0,240,255,.8) 0%, rgba(0,102,255,.8) 100%) !important; }
