/* 模型聚合 - 卡通糖果风格主题 */
:root {
    --ai-primary: #7C5CFF;
    --ai-primary-2: #4FC3F7;
    --ai-primary-grad: linear-gradient(135deg, #7C5CFF 0%, #4FC3F7 100%);
    --ai-accent: #FF8A65;
    --ai-accent-grad: linear-gradient(135deg, #FF8A65 0%, #FFB74D 100%);
    --ai-green: #66BB6A;
    --ai-red: #EF5350;
    --ai-bg: linear-gradient(160deg, #f3edff 0%, #eaf6ff 50%, #fff3ec 100%);
    --ai-card: rgba(255, 255, 255, 0.88);
    --ai-card-solid: #ffffff;
    --ai-text: #3a3a4a;
    --ai-text-2: #7a7a8c;
    --ai-border: #e8e2f7;
    --ai-radius: 20px;
    --ai-shadow: 0 10px 34px rgba(124, 92, 255, 0.12);
    --ai-shadow-hover: 0 16px 44px rgba(124, 92, 255, 0.22);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
    background: var(--ai-bg);
    background-attachment: fixed;
    color: var(--ai-text);
    min-height: 100vh;
}

/* 装饰漂浮气泡 */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background:
        radial-gradient(circle at 12% 18%, rgba(124, 92, 255, 0.14) 0, transparent 26%),
        radial-gradient(circle at 86% 12%, rgba(79, 195, 247, 0.16) 0, transparent 28%),
        radial-gradient(circle at 78% 82%, rgba(255, 138, 101, 0.14) 0, transparent 26%),
        radial-gradient(circle at 20% 86%, rgba(102, 187, 106, 0.10) 0, transparent 22%);
    z-index: 0;
}

.hidden { display: none !important; }

/* ============ 登录视图 ============ */
.login-wrap {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.login-card {
    width: 100%;
    max-width: 400px;
    background: var(--ai-card);
    backdrop-filter: blur(14px);
    border-radius: 28px;
    box-shadow: var(--ai-shadow);
    padding: 40px 36px 32px;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.7);
}
.login-logo {
    font-size: 3.4rem;
    line-height: 1;
    margin-bottom: 10px;
    filter: drop-shadow(0 6px 14px rgba(124, 92, 255, 0.35));
}
.login-title {
    margin: 0 0 6px;
    font-size: 1.55rem;
    font-weight: 800;
    background: var(--ai-primary-grad);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}
.login-sub { color: var(--ai-text-2); font-size: 0.9rem; margin: 0 0 26px; }
.login-input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--ai-border);
    border-radius: 14px;
    font-size: 0.95rem;
    font-family: inherit;
    outline: none;
    background: #fff;
    margin-bottom: 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.login-input:focus {
    border-color: var(--ai-primary);
    box-shadow: 0 0 0 4px rgba(124, 92, 255, 0.15);
}
.btn-primary-ai {
    width: 100%;
    padding: 13px;
    border: none;
    border-radius: 14px;
    background: var(--ai-primary-grad);
    color: #fff;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.2s;
    box-shadow: 0 8px 22px rgba(124, 92, 255, 0.35);
}
.btn-primary-ai:hover { transform: translateY(-2px); box-shadow: 0 12px 28px rgba(124, 92, 255, 0.45); }
.login-err { color: var(--ai-red); font-size: 0.85rem; min-height: 20px; margin-bottom: 8px; }
.login-hint { margin-top: 16px; font-size: 0.8rem; color: var(--ai-text-2); }

/* ============ 主布局 ============ */
.app {
    position: relative;
    z-index: 1;
    display: flex;
    min-height: 100vh;
}
.sidebar {
    width: 232px;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.78);
    backdrop-filter: blur(14px);
    border-right: 1px solid var(--ai-border);
    padding: 14px 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow: hidden;
}
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 10px 12px;
    flex-shrink: 0;
}
.sidebar-brand .brand-logo {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    object-fit: contain;
    flex-shrink: 0;
}
.sidebar-brand .name { font-weight: 800; font-size: 1.05rem; line-height: 1.25; }
.sidebar-brand .sub { font-size: 0.72rem; color: var(--ai-text-2); }
.sidebar-nav {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
    scrollbar-width: thin;
}
.menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 7px 14px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--ai-text-2);
    border: none;
    background: transparent;
    font-family: inherit;
    transition: all 0.18s;
    text-align: left;
    width: 100%;
}
.menu-item .mi { font-size: 1.05rem; }
.menu-item:hover { background: rgba(124, 92, 255, 0.08); color: var(--ai-primary); }
.menu-item.active {
    background: var(--ai-primary-grad);
    color: #fff;
    box-shadow: 0 8px 20px rgba(124, 92, 255, 0.35);
}
.sidebar-foot {
    flex-shrink: 0;
    padding-top: 10px;
    border-top: 1px dashed var(--ai-border);
}
.user-chip {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    padding: 6px 9px; border-radius: 12px;
    background: rgba(124, 92, 255, 0.08);
    font-size: 0.8rem;
}
.user-chip .avatar {
    width: 24px; height: 24px; border-radius: 50%;
    background: var(--ai-accent-grad);
    color: #fff; display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 0.75rem;
}
.logout-btn {
    margin-top: 6px; width: 100%;
    padding: 6px; border-radius: 10px;
    border: 2px solid var(--ai-border); background: #fff;
    color: var(--ai-text-2); cursor: pointer; font-size: 0.8rem;
    transition: all 0.18s; font-family: inherit;
}
.logout-btn:hover { border-color: var(--ai-red); color: var(--ai-red); }
.home-btn { margin-top: 5px; }
.home-btn:hover { border-color: var(--ai-primary); color: var(--ai-primary); }

/* 主内容 */
.main {
    flex: 1;
    padding: 28px 32px 48px;
    max-width: 1200px;
    min-width: 0;
}
/* 模型池面板激活时容器自适应最宽（表格列多） */
.main:has(#panel-models:not(.hidden)) {
    max-width: none;
}
.panel { padding-top: 2px; }

/* 卡片 */
.card {
    background: var(--ai-card);
    backdrop-filter: blur(12px);
    border-radius: var(--ai-radius);
    box-shadow: var(--ai-shadow);
    padding: 22px 24px;
    margin-bottom: 20px;
    border: 1px solid rgba(255, 255, 255, 0.7);
}
.card-title { font-weight: 700; font-size: 1.02rem; margin: 0 0 14px; display: flex; align-items: center; gap: 8px; }

/* 统计卡片 */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}
.stat-card {
    background: var(--ai-card);
    border-radius: var(--ai-radius);
    box-shadow: var(--ai-shadow);
    padding: 18px 20px;
    border: 1px solid rgba(255, 255, 255, 0.7);
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: default;
}
.stat-card:hover { transform: translateY(-4px); box-shadow: var(--ai-shadow-hover); }
.stat-card .stat-emoji { font-size: 1.7rem; }
.stat-card .stat-value { font-size: 1.5rem; font-weight: 800; margin: 6px 0 2px; }
.stat-card .stat-label { font-size: 0.8rem; color: var(--ai-text-2); }
.stat-card.violet { background: linear-gradient(135deg, rgba(124,92,255,0.12), rgba(255,255,255,0.9)); }
.stat-card.blue { background: linear-gradient(135deg, rgba(79,195,247,0.14), rgba(255,255,255,0.9)); }
.stat-card.orange { background: linear-gradient(135deg, rgba(255,138,101,0.14), rgba(255,255,255,0.9)); }
.stat-card.green { background: linear-gradient(135deg, rgba(102,187,106,0.14), rgba(255,255,255,0.9)); }
.stat-card.red { background: linear-gradient(135deg, rgba(239,83,80,0.12), rgba(255,255,255,0.9)); }
.stat-card.cyan { background: linear-gradient(135deg, rgba(38,198,218,0.14), rgba(255,255,255,0.9)); }

/* 工具栏 */
.toolbar {
    display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
    margin-bottom: 16px;
}
.toolbar .grow { flex: 1; }
.btn {
    padding: 9px 16px;
    border: none; border-radius: 12px;
    cursor: pointer; font-size: 0.9rem; font-weight: 600;
    font-family: inherit;
    display: inline-flex; align-items: center; gap: 6px;
    transition: all 0.18s;
}
.btn-ai { background: var(--ai-primary-grad); color: #fff; box-shadow: 0 6px 16px rgba(124,92,255,0.3); }
.btn-ai:hover { transform: translateY(-2px); }
.btn-ghost { background: #fff; border: 2px solid var(--ai-border); color: var(--ai-text); }
.btn-ghost:hover { border-color: var(--ai-primary); color: var(--ai-primary); }
.btn-danger { background: var(--ai-red); color: #fff; }
.btn-danger:hover { opacity: 0.9; }
.btn-sm { padding: 6px 12px; font-size: 0.82rem; border-radius: 10px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* 分段选择器（时间过滤） */
.seg {
    display: inline-flex; gap: 4px;
    background: rgba(255,255,255,0.8);
    border: 1px solid var(--ai-border);
    border-radius: 12px; padding: 4px;
}
.seg button {
    border: none; background: transparent; padding: 7px 14px;
    border-radius: 9px; cursor: pointer; font-size: 0.85rem;
    font-family: inherit; color: var(--ai-text-2); transition: all 0.15s;
}
.seg button.active { background: var(--ai-primary-grad); color: #fff; box-shadow: 0 4px 12px rgba(124,92,255,0.3); }

/* 表格 */
.table-wrap { overflow-x: auto; border-radius: 14px; }
table.ai-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.ai-table th {
    text-align: left; padding: 11px 12px;
    background: rgba(124, 92, 255, 0.08);
    color: var(--ai-text); font-weight: 700;
    white-space: nowrap;
}
.ai-table td { padding: 10px 12px; border-bottom: 1px solid var(--ai-border); vertical-align: middle; }
.ai-table tbody tr:nth-child(even) { background: rgba(124, 92, 255, 0.03); }
.ai-table tbody tr:hover { background: rgba(79, 195, 247, 0.08); }
.ai-table .mono { font-family: "SF Mono", Consolas, monospace; font-size: 0.82rem; }

/* 模型池 · 上游分组折叠板块 */
#models-groups { display: flex; flex-direction: column; gap: 10px; }
.model-group {
    border: 1px solid var(--ai-border);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.55);
    overflow: hidden;
    transition: box-shadow 0.2s;
}
.model-group:hover { box-shadow: var(--ai-shadow-hover); }
.model-group[open] { background: var(--ai-card-solid); }
.model-group summary {
    list-style: none; cursor: pointer;
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    padding: 13px 16px;
    user-select: none;
}
.model-group summary::-webkit-details-marker { display: none; }
.model-group summary:hover { background: rgba(124, 92, 255, 0.05); }
.model-group .mg-name {
    font-weight: 700; font-size: 0.98rem;
    background: var(--ai-primary-grad);
    -webkit-background-clip: text; background-clip: text;
    -webkit-text-fill-color: transparent;
}
.model-group .mg-stats { display: inline-flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.model-group .mg-actions { display: inline-flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.model-group .mg-chev {
    margin-left: auto; color: var(--ai-text-2);
    transition: transform 0.2s; font-size: 0.9rem;
}
.model-group[open] .mg-chev { transform: rotate(90deg); }
.model-group .mg-body { border-top: 1px dashed var(--ai-border); overflow-x: auto; }
.model-group .mg-body .ai-table { min-width: 940px; }
.model-group .mg-body .ai-table th { background: rgba(79, 195, 247, 0.1); }
.model-group .mg-body .ai-table td:last-child,
.model-group .mg-body .ai-table th:last-child { white-space: nowrap; }
.model-group .mg-empty { padding: 18px; text-align: center; color: var(--ai-text-2); font-size: 0.85rem; }

/* 多选批量删除 */
.ai-table tr.sel-row { background: rgba(124, 92, 255, 0.10) !important; }
.ai-table .model-sel, .ai-table .uniq-sel, .ai-table .group-sel-all, #uniq-sel-all {
    width: 16px; height: 16px; cursor: pointer; accent-color: #7c5cff;
}
#model-batch-del, #uniq-batch-del { display: inline-flex; align-items: center; gap: 4px; }

/* Key 文本右侧的内联复制图标 */
.copy-ico {
    border: none; background: transparent; cursor: pointer;
    font-size: 0.85rem; padding: 0 2px;
    opacity: 0.55; transition: opacity 0.15s;
    vertical-align: middle;
}
.copy-ico:hover { opacity: 1; }

/* Key 允许模型：默认折叠只显示第一个 */
.key-models {
    display: flex; align-items: flex-start; gap: 6px;
    max-width: 300px;
}
.key-models-list { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.key-models-list[data-collapsed="1"] .key-models-rest { display: none; }
.key-models-toggle {
    border: none; background: transparent; cursor: pointer;
    font-size: 0.8rem; color: var(--ai-text-2);
    padding: 2px 3px; border-radius: 6px; line-height: 1;
    flex-shrink: 0; margin-top: 3px;
}
.key-models-toggle:hover { background: rgba(124, 92, 255, 0.12); color: #5b3fd4; }

/* 所属上游徽章 */
.up-badge {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 6px 14px; border-radius: 999px;
    background: rgba(124, 92, 255, 0.12); color: #5b3fd4;
    font-weight: 600; font-size: 0.88rem;
}

/* 拉取模型多选工具栏 */
.fetch-toolbar {
    display: flex; align-items: center; gap: 8px;
    margin-bottom: 8px;
}
.fetch-toolbar #f-cnt { margin-left: auto; }

/* 拉取模型列表项（统一ID选择） */
.fetch-item {
    display: flex; align-items: flex-start; gap: 8px;
    padding: 7px 4px; border-bottom: 1px dashed var(--ai-border);
}
.fetch-item-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.fetch-item-uniq {
    display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.fetch-item-uniq select {
    min-width: 160px; max-width: 240px;
    padding: 4px 8px; border-radius: 8px;
    border: 1px solid var(--ai-border);
    font-size: 0.82rem; font-family: "SF Mono", Consolas, monospace;
    background: var(--ai-card-solid);
}
.fetch-item-warn {
    background: rgba(255, 138, 101, 0.08);
    border-left: 3px solid var(--ai-warn, #ff8a65);
}
.tag-red { background: rgba(239, 83, 80, 0.14); color: #c62828; }

/* 标签 */
.tag {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 10px; border-radius: 999px;
    font-size: 0.75rem; font-weight: 600;
    margin: 1px 2px;
}
.tag-violet { background: rgba(124,92,255,0.14); color: #5b3fd4; }
.tag-purple { background: rgba(171,71,188,0.14); color: #8e24aa; }
.tag-blue { background: rgba(79,195,247,0.16); color: #1273a8; }
.tag-orange { background: rgba(255,138,101,0.16); color: #c05a33; }
.tag-green { background: rgba(102,187,106,0.16); color: #2f7d33; }
.tag-gray { background: rgba(120,120,140,0.12); color: #666; }
.tag-cyan { background: rgba(38,198,218,0.16); color: #0e7f8e; }

/* 开关 */
.switch { position: relative; display: inline-block; width: 44px; height: 24px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
    position: absolute; inset: 0; border-radius: 999px;
    background: #d5d2e4; transition: 0.2s; cursor: pointer;
}
.switch .slider::before {
    content: ""; position: absolute; width: 18px; height: 18px;
    border-radius: 50%; left: 3px; top: 3px; background: #fff;
    transition: 0.2s; box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}
.switch input:checked + .slider { background: var(--ai-primary-grad); }
.switch input:checked + .slider::before { transform: translateX(20px); }

/* 弹窗 */
.modal-mask {
    position: fixed; inset: 0; z-index: 100;
    background: rgba(50, 40, 90, 0.4);
    backdrop-filter: blur(6px);
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
}
.modal {
    background: #fff; border-radius: 24px;
    box-shadow: 0 24px 70px rgba(50, 40, 90, 0.35);
    width: 100%; max-width: 620px; max-height: 88vh;
    overflow-y: auto; padding: 28px 30px;
}
.modal-title { font-size: 1.15rem; font-weight: 800; margin: 0 0 18px; display: flex; align-items: center; gap: 8px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.form-item { display: flex; flex-direction: column; gap: 5px; }
.form-item.full { grid-column: 1 / -1; }
.form-item label { font-size: 0.82rem; font-weight: 600; color: var(--ai-text-2); }
.form-item input, .form-item select, .form-item textarea {
    padding: 9px 12px; border: 2px solid var(--ai-border);
    border-radius: 11px; font-size: 0.9rem; font-family: inherit;
    outline: none; transition: border-color 0.2s; background: #fbfaff;
}
.form-item input:focus, .form-item select:focus { border-color: var(--ai-primary); }
.form-item .hint { font-size: 0.75rem; color: var(--ai-text-2); }

/* 上游多 Key 编辑行 */
.u-key-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    border: 2px solid var(--ai-border);
    border-radius: 11px;
    margin-bottom: 8px;
    background: #fbfaff;
    transition: border-color 0.2s, background 0.2s;
}
.u-key-row.active {
    border-color: var(--ai-primary);
    background: rgba(124, 92, 255, 0.06);
}
.u-key-active {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--ai-text-2);
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
}
.u-key-active input[type="radio"] {
    width: 15px;
    height: 15px;
    accent-color: var(--ai-primary);
    cursor: pointer;
    margin: 0;
}
.u-key-row.active .u-key-active { color: var(--ai-primary); }
.u-key-row .u-key-input,
.u-key-row .u-key-note {
    padding: 7px 10px;
    border: 2px solid var(--ai-border);
    border-radius: 9px;
    font-size: 0.85rem;
    outline: none;
    transition: border-color 0.2s;
    background: #fbfaff;
}
.u-key-input {
    flex: 1.6;
    min-width: 140px;
    font-family: "SF Mono", Consolas, monospace;
}
.u-key-note { flex: 1; min-width: 90px; font-family: inherit; }
.u-key-row input:focus { border-color: var(--ai-primary); }
.u-key-del {
    flex-shrink: 0;
    width: 30px;
    height: 30px;
    border: none;
    border-radius: 8px;
    background: transparent;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.15s;
}
.u-key-del:hover { background: rgba(239, 83, 80, 0.12); }
/* Key 行图标按钮：复制 / 显示明文 */
.u-key-ico {
    flex-shrink: 0;
    width: 30px;
    height: 30px;
    border: none;
    border-radius: 8px;
    background: transparent;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.15s;
}
.u-key-copy:hover { background: rgba(96, 165, 250, 0.15); }
.u-key-eye:hover { background: rgba(124, 92, 255, 0.12); }
.u-key-add-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 2px;
}
.u-key-count { font-size: 0.75rem; color: var(--ai-text-2); }
[data-theme="dark"] .u-key-row {
    background: rgba(255, 255, 255, 0.04);
    border-color: var(--ai-border);
}
[data-theme="dark"] .u-key-row.active {
    border-color: var(--ai-primary);
    background: rgba(124, 92, 255, 0.12);
}

/* 能力开关组 */
.caps-row { display: flex; flex-wrap: wrap; gap: 14px; padding: 4px 0; }
.cap-item { display: flex; align-items: center; gap: 7px; font-size: 0.86rem; }

/* Key 权限弹窗 · 按上游分组 */
.perm-group {
    border: 1px solid var(--ai-border);
    border-radius: 12px;
    padding: 8px 12px 10px;
    background: rgba(255, 255, 255, 0.5);
}
.perm-group-title {
    display: flex; align-items: center; gap: 6px;
    font-weight: 700; font-size: 0.86rem;
    color: #5b3fd4;
    margin-bottom: 8px; padding-bottom: 6px;
    border-bottom: 1px dashed var(--ai-border);
}
.perm-group-title .tag { color: #5b3fd4; }
.perm-group .cap-item {
    padding: 5px 4px; border-radius: 8px;
    transition: background 0.15s;
}
.perm-group .cap-item:hover { background: rgba(79, 195, 247, 0.08); }
.modal-actions { display: flex; flex-wrap: wrap; gap: 12px; justify-content: flex-end; margin-top: 22px; }
.modal-actions .btn { white-space: nowrap; }

/* 统一提示弹窗（覆盖层：位于普通弹窗之上，关闭后下层弹窗保留） */
#alert-modal-layer { z-index: 200; }
.alert-modal { max-width: 420px; padding: 24px 26px; }
.alert-modal .modal-title { margin-bottom: 10px; font-size: 1.05rem; }
.alert-modal-body {
    font-size: 0.9rem; line-height: 1.7; color: var(--ai-text);
    margin: 0 0 4px; word-break: break-word;
}

/* Key 明文弹窗 */
.key-reveal {
    background: linear-gradient(135deg, rgba(124,92,255,0.1), rgba(79,195,247,0.12));
    border: 2px dashed var(--ai-primary);
    border-radius: 12px; padding: 14px 16px;
    font-family: "SF Mono", Consolas, monospace;
    font-size: 0.95rem; word-break: break-all;
    margin: 6px 0 4px; color: var(--ai-text);
}

/* Copilot 导出配置：其它平台 / 直连模型 两个开关同行 */
.extra-toggles { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.extra-toggles label { font-size: 0.86rem; color: var(--ai-text); }
.warn-box {
    background: rgba(255, 138, 101, 0.14);
    border: 1px solid rgba(255, 138, 101, 0.4);
    border-radius: 12px; padding: 10px 14px;
    font-size: 0.82rem; color: #b25a33;
    margin: 8px 0;
}

/* 上游配置：key 导出直连模型列表（勾选 / 导出 Key / 模型列表按钮） */
.u-export-models-row {
    display: flex; align-items: center; gap: 10px;
    margin-top: 10px;
}
.u-export-models-cnt {
    font-size: 0.8rem; color: var(--ai-primary);
    font-weight: 600;
}
/* 模型选择叠加层（位于普通弹窗之上、alert 提示之下） */
#export-models-layer { z-index: 150; }

/* 空状态 / 消息 */
.empty { text-align: center; padding: 40px 20px; color: var(--ai-text-2); font-size: 0.9rem; }
.empty .e { font-size: 2.6rem; margin-bottom: 8px; }
.msg { padding: 10px 14px; border-radius: 12px; font-size: 0.85rem; margin-bottom: 12px; }
.msg-ok { background: rgba(102,187,106,0.16); color: #2f7d33; }
.msg-err { background: rgba(239,83,80,0.12); color: #c0392b; }

/* Tabs */
.ai-tabs { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.ai-tabs .tab {
    padding: 8px 16px; border-radius: 999px; cursor: pointer;
    background: #fff; border: 2px solid var(--ai-border);
    font-size: 0.85rem; font-weight: 600; color: var(--ai-text-2);
    transition: all 0.15s; font-family: inherit;
}
.ai-tabs .tab.active { background: var(--ai-primary-grad); color: #fff; border-color: transparent; box-shadow: 0 5px 14px rgba(124,92,255,0.3); }

/* 日期输入 */
.date-input {
    padding: 8px 12px; border: 2px solid var(--ai-border);
    border-radius: 11px; font-size: 0.85rem; font-family: inherit;
    outline: none; background: #fff; color: var(--ai-text);
}

/* 滚动条 */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: rgba(124, 92, 255, 0.3); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: rgba(124, 92, 255, 0.5); }
::-webkit-scrollbar-track { background: transparent; }

/* ============ 面板直连 · 共用 ============ */
.pg-select {
    padding: 8px 12px; border: 2px solid var(--ai-border);
    border-radius: 11px; font-size: 0.85rem; font-family: inherit;
    outline: none; background: #fff; color: var(--ai-text);
    cursor: pointer; max-width: 260px;
}
.pg-select:focus { border-color: var(--ai-primary); }
.pg-select-vision { border-color: rgba(255, 138, 101, 0.7); background: #fff8f4; }
.pg-msg { margin-top: 10px; }
.pg-msg .msg { padding: 9px 14px; border-radius: 11px; font-size: 0.85rem; margin-top: 8px; }
.pg-msg .msg-ok { background: rgba(102, 187, 106, 0.16); color: #2f7d33; }
.pg-msg .msg-err { background: rgba(239, 83, 80, 0.14); color: #c62828; }
/* 聊天提示条：悬浮于消息窗口内底部（不随消息滚动、不占文档流） */
#chat-msg {
    position: absolute; left: 50%; transform: translateX(-50%);
    bottom: 10px; z-index: 5;
    margin: 0; width: auto; max-width: 92%;
    pointer-events: none;
}
#chat-msg .msg { margin: 0; box-shadow: 0 6px 18px rgba(50, 40, 90, 0.14); pointer-events: auto; }

/* 参数问号图标（hover 显示说明） */
.q-mark {
    display: inline-flex; align-items: center; justify-content: center;
    width: 16px; height: 16px; border-radius: 50%;
    background: var(--ai-primary-grad); color: #fff;
    font-size: 0.68rem; font-weight: 800; cursor: help;
    position: relative; vertical-align: middle; line-height: 1;
}
.q-mark:hover::after {
    content: attr(data-tip);
    position: absolute; left: 50%; bottom: calc(100% + 8px);
    transform: translateX(-50%);
    width: 230px; max-width: 60vw;
    background: #3a3a4a; color: #fff;
    font-size: 0.75rem; font-weight: 400; line-height: 1.5;
    padding: 8px 11px; border-radius: 10px;
    white-space: normal; text-align: left;
    z-index: 60; box-shadow: 0 8px 22px rgba(0,0,0,0.28);
    pointer-events: none;
}
.q-mark:hover::before {
    content: ""; position: absolute; left: 50%; bottom: calc(100% + 1px);
    transform: translateX(-50%);
    border: 5px solid transparent; border-top-color: #3a3a4a;
    z-index: 61; pointer-events: none;
}

/* ============ 聊天对话 ============ */
/* 聊天面板激活时：主内容区纵向 flex 且高度锁定视口，聊天卡片自适应顶满 */
.main:has(#panel-chat:not(.hidden)) {
    display: flex;
    flex-direction: column;
    height: 100vh;
    min-height: 0;
    overflow: hidden;
    padding: 0;            /* 完全占满，无 padding */
    max-width: none;       /* 宽度自适应占满 */
}
.main:has(#panel-chat:not(.hidden)) #panel-chat {
    flex: 1; min-height: 0;
    display: flex; flex-direction: column;
    padding: 0;
}
/* 纯图标按钮 */
.btn-icon {
    width: 32px; height: 32px; padding: 0;
    justify-content: center;
    background: #fff; border: 2px solid var(--ai-border);
    color: var(--ai-text); border-radius: 10px;
    font-size: 0.95rem; flex-shrink: 0;
}
.btn-icon:hover { border-color: var(--ai-primary); color: var(--ai-primary); background: rgba(124, 92, 255, 0.06); }
/* 左上角返回箭头 */
.chat-back { font-size: 1rem; }
/* 聊天卡片顶部栏：返回箭头（左） / 新对话（右）——纯图标无外框，行高约 2/5 */
.chat-head {
    display: flex; align-items: center; gap: 8px;
    padding: 2px 14px;
    border-bottom: 1px solid var(--ai-border);
    background: rgba(255, 255, 255, 0.5);
    flex-shrink: 0;
    min-height: 48px;
}
/* 顶栏内两个图标：无边框无背景，仅图标 */
.chat-head .btn-icon {
    width: 28px; height: 28px;
    background: transparent; border: none;
    color: var(--ai-text-2);
    font-size: 1.15rem;
}
.chat-head .btn-icon:hover {
    background: transparent; border: none;
    color: var(--ai-primary);
}
.chat-head .grow { flex: 1; }
.chat-card { display: flex; flex-direction: column; flex: 1; min-height: 0; padding: 0; overflow: hidden; margin-bottom: 0; border-radius: 0; border: none; box-shadow: none; }
.chat-box {
    flex: 1; overflow-y: auto; padding: 22px 22px 8px;
    display: flex; flex-direction: column; gap: 14px;
    min-height: 0;
    position: relative;   /* 提示条悬浮定位基准 */
}
.chat-empty {
    margin: auto; text-align: center; color: var(--ai-text-2);
    display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.chat-empty .ce-emoji { font-size: 3rem; }
.chat-empty .ce-title { font-size: 1.1rem; font-weight: 700; color: var(--ai-text); }
.chat-empty .ce-sub { font-size: 0.83rem; line-height: 1.7; }

.chat-msg-row { display: flex; gap: 10px; max-width: 88%; }
.chat-msg-row.user { align-self: flex-end; flex-direction: row-reverse; }
.chat-msg-row .cm-avatar {
    width: 34px; height: 34px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.95rem; flex-shrink: 0;
    box-shadow: 0 3px 10px rgba(0,0,0,0.12);
}
.chat-msg-row.user .cm-avatar { background: var(--ai-primary-grad); color: #fff; }
.chat-msg-row.assistant .cm-avatar { background: linear-gradient(135deg, #66BB6A, #4FC3F7); color: #fff; }
.chat-msg-row.error .cm-avatar { background: var(--ai-red); color: #fff; }
.chat-msg-row.system { align-self: center; max-width: 90%; }
.chat-msg-row.system .cm-avatar { display: none; }
.chat-msg-row .cm-body { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.chat-msg-row .cm-meta { font-size: 0.72rem; color: var(--ai-text-2); }
.chat-msg-row .cm-bubble {
    padding: 11px 15px; border-radius: 16px;
    font-size: 0.9rem; line-height: 1.7;
    white-space: pre-wrap; word-break: break-word;
    background: #fff; border: 1px solid var(--ai-border);
    box-shadow: 0 3px 12px rgba(124, 92, 255, 0.08);
}
.chat-msg-row.user .cm-bubble {
    background: var(--ai-primary-grad); color: #fff;
    border: none; border-bottom-right-radius: 5px;
}
.chat-msg-row.assistant .cm-bubble { border-bottom-left-radius: 5px; }
/* 错误行：气泡保持常规底色，红色提示由内部 .cm-err 块呈现（避免双重红色边框） */
.chat-msg-row.error .cm-bubble { color: var(--ai-text-1); }
.chat-msg-row.system .cm-bubble { background: rgba(124, 92, 255, 0.08); border: none; font-size: 0.8rem; color: var(--ai-text-2); }

/* 消息内附件（图片/文件） */
.cm-files { display: flex; flex-wrap: wrap; gap: 8px; }
.cm-file {
    display: inline-flex; align-items: center; gap: 7px;
    max-width: 260px; padding: 7px 11px;
    background: rgba(124, 92, 255, 0.08);
    border-radius: 10px; font-size: 0.8rem; color: #5b3fd4;
    text-decoration: none; overflow: hidden;
}
.cm-file:hover { background: rgba(124, 92, 255, 0.16); }
.cm-file .cf-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cm-file.cf-img { padding: 3px; background: rgba(255,255,255,0.5); border: 1px solid var(--ai-border); }
.cm-file.cf-img img { width: 130px; height: 130px; object-fit: cover; border-radius: 8px; display: block; }
/* 图片/文件处理中占位（转圈） */
.cm-file.cf-img.cf-loading {
    width: 130px; height: 130px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.4rem; color: var(--ai-text-2);
    background: rgba(124, 92, 255, 0.08);
    border: 1px dashed var(--ai-border);
    animation: cf-spin 1.2s linear infinite;
}
@keyframes cf-spin { 0%, 100% { transform: rotate(0deg); } 50% { transform: rotate(180deg); } }
.chat-msg-row.user .cm-file { background: rgba(255,255,255,0.2); color: #fff; }
.chat-msg-row.user .cm-file.cf-img { background: rgba(255,255,255,0.15); border-color: rgba(255,255,255,0.35); }

/* markdown 粗体/代码 */
.cm-bubble strong { font-weight: 700; }
.cm-bubble em { font-style: italic; }
.cm-bubble del { text-decoration: line-through; color: var(--ai-text-2); }
.cm-bubble code {
    background: rgba(124, 92, 255, 0.1); color: #5b3fd4;
    padding: 1px 5px; border-radius: 5px; font-size: 0.83em;
    font-family: "SF Mono", Consolas, monospace;
}
.cm-bubble pre {
    background: #2d2d3d; color: #e8e8f0; border-radius: 10px;
    padding: 12px 14px; overflow-x: auto; margin: 8px 0;
    font-size: 0.82rem; line-height: 1.55;
}
.cm-bubble pre code { background: transparent; color: inherit; padding: 0; }

/* 代码块：默认折叠 + 复制按钮 */
.cm-code-wrap {
    margin: 8px 0; border-radius: 10px; overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: #2d2d3d;
}
.cm-code-head {
    display: flex; align-items: center; gap: 8px;
    padding: 5px 10px;
    background: rgba(255, 255, 255, 0.07);
    cursor: pointer; user-select: none;
    font-size: 0.75rem; color: #a8a8c0;
}
.cm-code-head .cm-code-lang { font-weight: 700; color: #7fd4a8; text-transform: lowercase; }
.cm-code-head .cm-code-toggle { flex: 1; }
.cm-code-wrap.collapsed .cm-code-body { display: none; }
.cm-code-wrap .cm-code-body pre { margin: 0; border-radius: 0; }
.cm-copy {
    border: none; background: rgba(124, 92, 255, 0.25);
    color: #d9d0ff; border-radius: 6px;
    padding: 3px 8px; font-size: 0.75rem;
    cursor: pointer; font-family: inherit; flex-shrink: 0;
    line-height: 1.6;
}
.cm-copy:hover { background: rgba(124, 92, 255, 0.45); color: #fff; }

/* 表格：右上角复制按钮 */
.cm-table-wrap { position: relative; margin: 8px 0; }
.cm-table-wrap .cm-copy-tbl {
    position: absolute; top: 4px; right: 4px; z-index: 2;
    background: rgba(124, 92, 255, 0.14); color: #5b3fd4;
    padding: 2px 8px; font-size: 0.72rem;
}
.cm-table-wrap .cm-copy-tbl:hover { background: rgba(124, 92, 255, 0.3); }

/* :::copy 可复制内容块 */
.cm-copyblock {
    margin: 8px 0; border: 1px dashed var(--ai-primary);
    border-radius: 10px; overflow: hidden;
    background: rgba(124, 92, 255, 0.05);
}
.cm-copyblock-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 5px 10px; font-size: 0.75rem; color: #5b3fd4;
    background: rgba(124, 92, 255, 0.1); font-weight: 600;
}
.cm-copyblock-body { padding: 4px 12px 8px; }
/* :::copy 块内容按纯文本展示（保留 #、> 等原始字符，不做 Markdown 解析） */
.cm-copyblock-body.cm-plain {
    white-space: pre-wrap; word-break: break-word;
    font-size: 0.85rem; line-height: 1.6; color: inherit;
}

/* 顶部提示（如正在联网搜索…） */
.pg-msg-info {
    padding: 6px 12px; font-size: 0.78rem; color: #8f8fb0;
    background: rgba(124, 92, 255, 0.08); border-radius: 8px; margin: 6px 0;
}
.chat-msg-row.user .cm-code-wrap { border-color: rgba(255, 255, 255, 0.2); }
.cm-bubble .cm-blinking { display: inline-block; width: 8px; height: 15px; background: var(--ai-primary); vertical-align: -2px; animation: cm-blink 1s infinite; border-radius: 2px; }
@keyframes cm-blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.2; } }

/* markdown 块级元素 */
.cm-bubble h1, .cm-bubble h2, .cm-bubble h3,
.cm-bubble h4, .cm-bubble h5, .cm-bubble h6 {
    margin: 12px 0 6px; font-weight: 800; line-height: 1.4;
}
.cm-bubble h1 { font-size: 1.3rem; }
.cm-bubble h2 { font-size: 1.16rem; border-bottom: 1px solid var(--ai-border); padding-bottom: 4px; }
.cm-bubble h3 { font-size: 1.05rem; }
.cm-bubble h4, .cm-bubble h5, .cm-bubble h6 { font-size: 0.98rem; }
.cm-bubble p { margin: 6px 0; }
.cm-bubble ul, .cm-bubble ol { margin: 6px 0; padding-left: 22px; }
.cm-bubble li { margin: 3px 0; line-height: 1.7; }
.cm-bubble blockquote {
    margin: 8px 0; padding: 6px 12px;
    border-left: 3px solid var(--ai-primary);
    background: rgba(124, 92, 255, 0.06);
    border-radius: 0 8px 8px 0;
    color: var(--ai-text-2);
}
.cm-bubble hr { border: none; border-top: 1px dashed var(--ai-border); margin: 10px 0; }
.cm-bubble a { color: #5b3fd4; text-decoration: underline; word-break: break-all; }
.cm-bubble table {
    border-collapse: collapse; margin: 8px 0;
    font-size: 0.84rem; width: 100%;
}
.cm-bubble table th, .cm-bubble table td {
    border: 1px solid var(--ai-border);
    padding: 6px 10px; text-align: left;
}
.cm-bubble table th { background: rgba(124, 92, 255, 0.1); font-weight: 700; }
.cm-bubble table tr:nth-child(even) td { background: rgba(124, 92, 255, 0.04); }
.chat-msg-row.user .cm-bubble table th { background: rgba(255, 255, 255, 0.22); }
.chat-msg-row.user .cm-bubble table td, .chat-msg-row.user .cm-bubble table th { border-color: rgba(255, 255, 255, 0.3); }

/* 等待动画：三个跳动圆点 */
.cm-typing { display: inline-flex; align-items: center; gap: 5px; padding: 3px 2px; }
/* 气泡内错误提示（视觉识别失败 / 未选辅助模型等） */
.cm-err {
    font-size: 0.86rem; line-height: 1.6;
    color: #c0392b; background: rgba(231, 76, 60, 0.08);
    border: 1px solid rgba(231, 76, 60, 0.28);
    border-radius: 10px; padding: 10px 12px;
    word-break: break-word;
}
.cm-typing i {
    width: 7px; height: 7px; border-radius: 50%;
    background: var(--ai-primary);
    opacity: 0.35; animation: cm-typing 1.2s infinite;
}
.cm-typing i:nth-child(2) { animation-delay: 0.2s; }
.cm-typing i:nth-child(3) { animation-delay: 0.4s; }
@keyframes cm-typing {
    0%, 100% { opacity: 0.35; transform: translateY(0); }
    40% { opacity: 1; transform: translateY(-3px); }
}

/* 上传进度显示（助手气泡内）：文字 + 进度条 */
.up-txt { font-size: 0.8rem; color: var(--ai-text-2); margin-bottom: 6px; }
.up-bar {
    height: 6px; border-radius: 4px;
    background: rgba(124, 92, 255, 0.15);
    overflow: hidden;
}
.up-fill {
    height: 100%; border-radius: 4px;
    background: linear-gradient(90deg, var(--ai-primary), #a78bfa);
    transition: width 0.25s ease;
}

/* 视觉辅助下拉框高亮（添加图片被拒时引导用户选择） */
.pg-select-vision.vision-flash {
    border-color: var(--ai-red);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.25);
    animation: vision-flash-pulse 0.5s ease 3;
}
@keyframes vision-flash-pulse {
    0%, 100% { box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.25); }
    50% { box-shadow: 0 0 0 6px rgba(239, 68, 68, 0.45); }
}

/* 思考块：默认折叠一行，点击展开 */
.cm-thinking {
    border: 1px dashed rgba(124, 92, 255, 0.45);
    border-radius: 10px;
    background: rgba(124, 92, 255, 0.05);
    overflow: hidden;
}
.cm-thinking.collapsed .cm-thinking-body {
    max-height: 1.6em;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}
.cm-thinking.open .cm-thinking-body {
    max-height: 40vh;
    overflow-y: auto;
    white-space: pre-wrap;
    text-overflow: unset;
}
.cm-thinking-head {
    display: flex; align-items: center; gap: 6px;
    padding: 6px 11px;
    cursor: pointer; user-select: none;
    font-size: 0.78rem; color: var(--ai-text-2);
}
.cm-thinking-head:hover { background: rgba(124, 92, 255, 0.08); }
.cm-thinking-head .ct-icon { font-size: 0.85rem; }
.cm-thinking-head .ct-label { flex: 1; font-weight: 600; }
.cm-thinking-head .ct-chev {
    transition: transform 0.2s; font-size: 0.75rem;
}
.cm-thinking.open .ct-chev { transform: rotate(180deg); }
.cm-thinking-body {
    padding: 0 11px 8px;
    font-size: 0.8rem; line-height: 1.6;
    color: var(--ai-text-2);
    white-space: pre-wrap; word-break: break-word;
    max-height: 40vh; overflow-y: auto;
}

/* 输入栏 */
.chat-input-bar {
    display: flex; align-items: center; gap: 8px;
    padding: 10px 14px;
    border-top: 1px solid var(--ai-border);
    background: rgba(255, 255, 255, 0.6);
}
.chat-input {
    flex: 1; resize: none;
    padding: 10px 13px; border: 2px solid var(--ai-border);
    border-radius: 13px; font-size: 0.9rem; font-family: inherit;
    outline: none; max-height: 140px; line-height: 1.5;
    background: #fff; color: var(--ai-text);
}
.chat-input:focus { border-color: var(--ai-primary); box-shadow: 0 0 0 3px rgba(124, 92, 255, 0.12); }

/* 停止生成按钮：简约灰底 + 中间白色方块；仅在对话生成途中显示 */
.chat-stop-btn {
    flex-shrink: 0;
    width: 40px; height: 40px;
    padding: 0;
    border: none;
    border-radius: 10px;
    background: #d0d0da;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background 0.15s;
}
.chat-stop-btn::after {
    content: '';
    width: 13px; height: 13px;
    background: #fff;
    border-radius: 2px;
    display: block;
}
.chat-stop-btn:hover { background: #b9b9c6; }
.chat-stop-btn:active { transform: scale(0.94); }
.chat-stop-btn[hidden] { display: none; }

/* 消息操作按钮（复制/修改）：PC 悬停显示；移动端点击消息行切换显示 */
.cm-actions {
    display: flex; align-items: center; gap: 6px;
    opacity: 0;
    transition: opacity 0.15s;
    margin-top: 3px;
}
.chat-msg-row:hover .cm-actions { opacity: 1; }
.cm-actions .cm-act {
    border: none; background: rgba(124, 92, 255, 0.10);
    color: #5b3fd4; border-radius: 8px;
    padding: 3px 9px; font-size: 0.78rem;
    cursor: pointer; font-family: inherit; line-height: 1.6;
    transition: background 0.15s, transform 0.1s;
}
.cm-actions .cm-act:hover { background: rgba(124, 92, 255, 0.25); transform: translateY(-1px); }
.cm-actions .cm-act:active { transform: scale(0.94); }

/* 输入框下方选项栏：附件 / 模型 / 思考 / 联网 ... 历史 / 新对话 */
.chat-optbar {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 14px 10px;
    background: rgba(255, 255, 255, 0.6);
    flex-wrap: wrap;
}
.chat-optbar .pg-select {
    padding: 5px 9px; font-size: 0.8rem; border-radius: 9px;
    max-width: 220px;
}
.chat-optbar .chat-attach { display: inline-flex; }
.chat-optbar .chat-attach .btn-icon { width: 30px; height: 30px; }
.chat-optbar .grow { flex: 1; }
/* 选项栏右侧重试设置按钮：与附件按钮同尺寸 */
.chat-optbar #chat-retry-btn {
    width: 30px; height: 30px; padding: 0; flex-shrink: 0;
    font-size: 0.95rem; border-radius: 9px;
}

/* 错误气泡内的手动重试按钮条 */
.cm-retry-bar {
    margin-top: 8px;
    display: flex; justify-content: flex-end;
}
.cm-retry-btn {
    border: 1px solid rgba(124, 92, 255, 0.35);
    background: rgba(124, 92, 255, 0.10);
    border-radius: 9px;
    padding: 5px 16px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--ai-primary);
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s, transform 0.1s;
}
.cm-retry-btn:hover { background: rgba(124, 92, 255, 0.22); transform: translateY(-1px); }
.cm-retry-btn:active { transform: scale(0.95); }
.chat-msg-row.error .cm-retry-btn { color: #c62828; border-color: rgba(239, 83, 80, 0.45); background: rgba(239, 83, 80, 0.10); }
.chat-msg-row.error .cm-retry-btn:hover { background: rgba(239, 83, 80, 0.20); }
[data-theme="dark"] .cm-retry-btn { color: #b7a4ff; }
[data-theme="dark"] .chat-msg-row.error .cm-retry-btn { color: #ff8a80; }

/* 弹窗内"开关+文字"一行（重试设置等） */
.switch-inline {
    display: flex; align-items: center; justify-content: space-between;
    gap: 10px; width: 100%;
    font-size: 0.85rem; font-weight: 600; color: var(--ai-text-1);
    cursor: pointer;
}

/* 联网搜索图标开关：打开后背景高亮 */
.chat-web-label {
    display: inline-flex; align-items: center; justify-content: center;
    width: 30px; height: 30px; flex-shrink: 0;
    border: 2px solid var(--ai-border); border-radius: 9px;
    background: #fff; cursor: pointer; user-select: none;
    font-size: 0.95rem; transition: all 0.18s;
}
.chat-web-label input { display: none; }
.chat-web-label:hover { border-color: var(--ai-primary); }
.chat-web-label:has(input:checked) {
    border-color: var(--ai-primary);
    background: rgba(124, 92, 255, 0.2);
    box-shadow: 0 0 0 3px rgba(124, 92, 255, 0.15);
}

/* 待发送附件列表 */
.attach-list {
    display: flex; flex-wrap: wrap; gap: 8px;
    padding: 8px 14px 0; border-top: 1px dashed var(--ai-border);
}
.attach-item {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 5px 8px 5px 5px; border-radius: 10px;
    background: rgba(124, 92, 255, 0.08);
    font-size: 0.78rem; max-width: 200px;
}
.attach-item img { width: 26px; height: 26px; object-fit: cover; border-radius: 6px; }
.attach-item .at-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach-item .at-status { font-size: 0.7rem; color: var(--ai-text-2); flex-shrink: 0; }
.attach-item .at-status.at-err { color: #c62828; }
.attach-item .at-x {
    border: none; background: transparent; cursor: pointer;
    color: var(--ai-text-2); font-size: 0.9rem; padding: 0 2px; line-height: 1;
}
.attach-item .at-x:hover { color: var(--ai-red); }

/* 无打开对话时的历史列表视图（聊天面板内） */
.chat-history-view {
    flex: 1; overflow-y: auto;
    padding: 22px 24px 16px;
    display: flex; flex-direction: column; gap: 14px;
    min-height: 0;
}
.chat-history-view .chv-head {
    display: flex; align-items: center; justify-content: space-between;
    gap: 10px; flex-shrink: 0;
}
.chat-history-view .chv-label {
    font-size: 1rem; font-weight: 700; color: var(--ai-text);
}
.chat-history-view .chv-clear {
    border: 1px solid var(--ai-border); background: transparent;
    color: var(--ai-text-2); font-size: 0.82rem;
    padding: 6px 12px; border-radius: 10px; cursor: pointer;
    transition: all 0.15s; flex-shrink: 0;
}
.chat-history-view .chv-clear:hover {
    color: var(--ai-red); border-color: rgba(239, 83, 80, 0.45);
    background: rgba(239, 83, 80, 0.08);
}
.chat-history-view .chv-list { display: flex; flex-direction: column; gap: 10px; }
.chat-history-view .chv-item {
    display: flex; align-items: center; gap: 10px;
    padding: 13px 16px;
    border: 1px solid var(--ai-border); border-radius: 14px;
    background: var(--ai-card-solid);
    cursor: pointer;
    transition: box-shadow 0.18s, transform 0.18s, border-color 0.18s;
}
.chat-history-view .chv-item:hover {
    border-color: var(--ai-primary);
    box-shadow: var(--ai-shadow-hover);
    transform: translateY(-2px);
}
.chat-history-view .chv-info {
    flex: 1; min-width: 0;
    display: flex; flex-direction: column; gap: 4px;
}
.chat-history-view .chv-title {
    font-weight: 700; font-size: 0.95rem;
    background: none; -webkit-text-fill-color: var(--ai-text); background-clip: unset;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chat-history-view .chv-time { font-size: 0.78rem; color: var(--ai-text-2); }
.chat-history-view .chv-open {
    color: var(--ai-primary); font-size: 0.85rem; font-weight: 700;
    flex-shrink: 0;
}
.chat-history-view .chv-del {
    border: none; background: transparent; cursor: pointer;
    font-size: 0.9rem; color: var(--ai-text-2);
    padding: 5px 7px; border-radius: 8px; flex-shrink: 0;
    opacity: 0.55; transition: all 0.15s; line-height: 1;
}
.chat-history-view .chv-del:hover {
    opacity: 1; color: var(--ai-red);
    background: rgba(239, 83, 80, 0.12);
}
.chat-history-view .chv-empty {
    margin: auto; text-align: center; color: var(--ai-text-2);
    line-height: 1.9; font-size: 0.9rem;
}
.chat-history-view .chv-empty .e { font-size: 2.6rem; }

/* ============ 管理用户模型（仅管理员） ============ */
.toolbar .tb-title {
    font-size: 0.95rem; font-weight: 700; color: var(--ai-text);
}
.adminm-banner {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    margin: 0 0 12px; padding: 10px 14px;
    background: rgba(139, 92, 246, 0.08); border: 1px solid rgba(139, 92, 246, 0.35);
    border-radius: 12px; flex-wrap: wrap;
}
.adminm-banner .ab-txt { font-size: 0.88rem; color: var(--ai-text); }
.admin-user-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
}
.admin-user-card {
    display: flex; align-items: center; gap: 12px;
    padding: 14px 16px;
    border: 1px solid var(--ai-border); border-radius: 14px;
    background: var(--ai-card-solid); cursor: pointer;
    transition: box-shadow 0.18s, transform 0.18s, border-color 0.18s;
}
.admin-user-card:hover {
    border-color: var(--ai-primary);
    box-shadow: var(--ai-shadow-hover);
    transform: translateY(-2px);
}
.admin-user-card .auc-avatar {
    width: 40px; height: 40px; border-radius: 50%;
    background: var(--ai-primary); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 1.1rem; flex-shrink: 0;
}
.admin-user-card .auc-info {
    flex: 1; min-width: 0;
    display: flex; flex-direction: column; gap: 3px;
}
.admin-user-card .auc-name {
    font-weight: 700; font-size: 0.95rem;
    display: flex; align-items: center; gap: 6px;
}
.admin-user-card .auc-sub { font-size: 0.78rem; color: var(--ai-text-2); }
.admin-user-card .btn { flex-shrink: 0; }

/* ============ 工具权限管理（仅管理员） ============ */
.tp-user-bar {
    display: flex; align-items: center; gap: 8px;
    flex-wrap: wrap; margin: 10px 0 14px;
    padding: 10px 14px;
    border: 1px solid var(--ai-border); border-radius: 12px;
    background: var(--ai-card-solid);
}
.tp-user-label { font-size: 0.85rem; font-weight: 700; color: var(--ai-text-2); }
.tp-user-btn {
    border: 1px solid var(--ai-border); background: transparent;
    border-radius: 9px; padding: 6px 12px;
    font-size: 0.82rem; font-family: inherit; cursor: pointer;
    color: var(--ai-text-2); transition: all 0.15s;
}
.tp-user-btn:hover { border-color: var(--ai-primary); color: var(--ai-text); }
.tp-user-btn.active {
    background: var(--ai-primary-grad); color: #fff;
    border-color: transparent; font-weight: 600;
}
.tp-group {
    margin-bottom: 16px;
    border: 1px solid var(--ai-border); border-radius: 14px;
    overflow: hidden; background: var(--ai-card-solid);
}
.tp-group-title {
    padding: 10px 16px; font-weight: 700; font-size: 0.9rem;
    color: #5b3fd4;
    background: rgba(124, 92, 255, 0.07);
    border-bottom: 1px dashed var(--ai-border);
}
.tp-row {
    display: flex; align-items: center; justify-content: space-between;
    gap: 14px; flex-wrap: wrap;
    padding: 12px 16px;
    border-bottom: 1px solid var(--ai-border);
}
.tp-row:last-child { border-bottom: none; }
.tp-info { flex: 1; min-width: 220px; }
.tp-name { font-weight: 700; font-size: 0.9rem; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tp-name code {
    background: rgba(124, 92, 255, 0.1); color: #5b3fd4;
    border-radius: 6px; padding: 1px 7px; font-size: 0.75rem;
}
.tp-desc { font-size: 0.78rem; color: var(--ai-text-2); margin-top: 4px; line-height: 1.5; }
.tp-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.tp-perm-btn {
    border: 1px solid var(--ai-border); background: transparent;
    border-radius: 8px; padding: 5px 10px;
    font-size: 0.76rem; font-family: inherit; cursor: pointer;
    color: var(--ai-text-2); transition: all 0.15s;
}
.tp-perm-btn:hover { border-color: var(--ai-primary); }
.tp-perm-btn.active { border-color: transparent; font-weight: 700; color: #fff; }
.tp-perm-btn.perm-off.active { background: #6b7280; }
.tp-perm-btn.perm-user.active { background: #22a06b; }
.tp-perm-btn.perm-admin.active { background: #7c5cff; }
.tp-reset-btn {
    border: none; background: rgba(124, 92, 255, 0.1); color: #5b3fd4;
    border-radius: 8px; padding: 5px 10px;
    font-size: 0.76rem; font-family: inherit; cursor: pointer;
}
.tp-reset-btn:hover { background: rgba(124, 92, 255, 0.2); }

/* ============ 凡凡（仅管理员） ============ */
.sa-cfg-row {
    display: flex; align-items: center; gap: 14px;
    padding: 12px 0; flex-wrap: wrap;
    border-bottom: 1px dashed var(--ai-border);
}
.sa-cfg-row:last-child { border-bottom: none; }
.sa-cfg-label { font-weight: 700; font-size: 0.88rem; min-width: 84px; color: var(--ai-text); }
.sa-cfg-note { font-size: 0.76rem; color: var(--ai-text-2); }
.sa-cfg-top { padding-top: 14px; }
.sa-switch { position: relative; display: inline-block; width: 44px; height: 24px; flex-shrink: 0; }
.sa-switch input { opacity: 0; width: 0; height: 0; }
.sa-switch-slider {
    position: absolute; inset: 0; cursor: pointer;
    background: #cbd0dd; border-radius: 24px; transition: 0.2s;
}
.sa-switch-slider::before {
    content: ''; position: absolute; left: 3px; top: 3px;
    width: 18px; height: 18px; border-radius: 50%;
    background: #fff; transition: 0.2s; box-shadow: 0 1px 3px rgba(0,0,0,0.25);
}
.sa-switch input:checked + .sa-switch-slider { background: var(--ai-primary-grad, #7c5cff); }
.sa-switch input:checked + .sa-switch-slider::before { transform: translateX(20px); }
.sa-greeting {
    flex: 1; min-width: 240px; max-width: 460px;
    border: 1.5px solid var(--ai-border); border-radius: 10px;
    padding: 8px 12px; font-size: 0.86rem; font-family: inherit;
    background: var(--ai-card-solid); color: var(--ai-text);
    outline: none;
}
.sa-greeting:focus { border-color: var(--ai-primary); }

/* ============ 使用文档 ============ */
#panel-doc {
    height: calc(100vh - 90px);   /* 面板自身滚动，便于目录高亮监听 */
    overflow-y: auto;
}
.doc-wrap {
    display: flex; gap: 22px; align-items: flex-start;
    max-width: 1080px; margin: 0 auto;
}
.doc-toc {
    width: 196px; flex-shrink: 0;
    position: sticky; top: 4px;
    display: flex; flex-direction: column; gap: 2px;
    max-height: calc(100vh - 120px); overflow-y: auto;
    padding: 10px 8px;
    border: 1px solid var(--ai-border); border-radius: 12px;
    background: var(--ai-card-solid);
}
.doc-toc-item {
    border: none; background: transparent; cursor: pointer;
    text-align: left; font-family: inherit;
    font-size: 0.83rem; color: var(--ai-text-2);
    padding: 6px 10px; border-radius: 8px;
    line-height: 1.4; transition: all 0.15s;
}
.doc-toc-item:hover { background: rgba(124, 92, 255, 0.1); color: var(--ai-text); }
.doc-toc-item.active {
    background: var(--ai-primary-grad); color: #fff; font-weight: 600;
}
.doc-content {
    flex: 1; min-width: 0;
    padding: 4px 6px 40px;
    font-size: 0.92rem; line-height: 1.75;
    color: var(--ai-text);
}
.doc-content h1, .doc-content h2, .doc-content h3,
.doc-content h4, .doc-content h5, .doc-content h6 {
    margin: 20px 0 8px; font-weight: 800; line-height: 1.4;
}
.doc-content h1 {
    font-size: 1.5rem;
    background: var(--ai-primary-grad);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    background-clip: text;
}
.doc-content h2 {
    font-size: 1.18rem;
    border-bottom: 2px solid var(--ai-border);
    padding-bottom: 6px; margin-top: 34px;
    scroll-margin-top: 12px;
}
.doc-content h3 { font-size: 1.05rem; }
.doc-content h4, .doc-content h5, .doc-content h6 { font-size: 0.98rem; }
.doc-content p { margin: 8px 0; }
.doc-content ul, .doc-content ol { margin: 8px 0; padding-left: 24px; }
.doc-content li { margin: 4px 0; line-height: 1.75; }
.doc-content blockquote {
    margin: 10px 0; padding: 8px 14px;
    border-left: 3px solid var(--ai-primary);
    background: rgba(124, 92, 255, 0.07);
    border-radius: 0 10px 10px 0;
    color: var(--ai-text-2); font-size: 0.88rem;
}
.doc-content hr { border: none; border-top: 1px dashed var(--ai-border); margin: 16px 0; }
.doc-content a { color: var(--ai-primary); text-decoration: underline; word-break: break-all; }
.doc-content strong { font-weight: 700; }
.doc-content em { font-style: italic; }
.doc-content del { text-decoration: line-through; color: var(--ai-text-2); }
.doc-content code {
    background: rgba(124, 92, 255, 0.1); color: #5b3fd4;
    padding: 1px 6px; border-radius: 5px; font-size: 0.85em;
    font-family: "SF Mono", Consolas, monospace;
}
.doc-content pre { background: #2d2d3d; color: #e8e8f0; border-radius: 10px; padding: 12px 14px; overflow-x: auto; margin: 10px 0; font-size: 0.82rem; line-height: 1.55; }
.doc-content pre code { background: transparent; color: inherit; padding: 0; }
.doc-content table {
    border-collapse: collapse; margin: 10px 0;
    font-size: 0.86rem; width: 100%;
}
.doc-content table th, .doc-content table td {
    border: 1px solid var(--ai-border);
    padding: 7px 12px; text-align: left;
}
.doc-content table th { background: rgba(124, 92, 255, 0.1); font-weight: 700; }
.doc-content table tr:nth-child(even) td { background: rgba(124, 92, 255, 0.04); }
.doc-content .cm-code-wrap,
.doc-content .cm-copyblock,
.doc-content .cm-table-wrap { margin: 10px 0; }
.doc-err {
    padding: 20px; text-align: center; color: var(--ai-red);
    font-size: 0.9rem;
}

/* 移动端：目录改为顶部横向滚动条，内容全宽 */
@media (max-width: 900px) {
    #panel-doc { height: calc(100vh - 120px); }
    .doc-wrap { flex-direction: column; gap: 10px; }
    .doc-toc {
        width: 100%; position: static;
        flex-direction: row; overflow-x: auto; overflow-y: hidden;
        max-height: none; padding: 6px;
        gap: 6px; flex-wrap: nowrap;
    }
    .doc-toc-item { white-space: nowrap; flex-shrink: 0; padding: 6px 12px; }
    .doc-content { padding: 4px 2px 40px; }
    .doc-content h2 { scroll-margin-top: 8px; }
}

/* ============ 生图 ============ */
.img-grid {
    display: grid; grid-template-columns: 400px 1fr;
    gap: 16px; align-items: start;
}
.img-left .card-title { margin-bottom: 16px; }

/* 文生图 / 图生图 模式切换 */
.img-mode {
    display: flex; gap: 8px; margin-bottom: 14px;
    background: rgba(124, 92, 255, 0.07);
    border: 1px solid var(--ai-border);
    border-radius: 12px; padding: 4px;
}
.img-mode-btn {
    flex: 1; padding: 8px 10px; border: none; border-radius: 9px;
    background: transparent; color: var(--ai-text-2);
    font-size: 0.85rem; font-weight: 600; cursor: pointer;
    transition: all 0.2s; font-family: inherit;
}
.img-mode-btn:hover { color: var(--ai-text); }
.img-mode-btn.active {
    background: var(--ai-primary); color: #fff;
    box-shadow: 0 2px 8px rgba(124, 92, 255, 0.35);
}

.img-form-row {
    display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px;
    margin-bottom: 14px;
}
.img-form-row .form-item label { display: flex; align-items: center; gap: 5px; }
.img-form-row input, .img-form-row select, .img-left textarea {
    width: 100%; padding: 9px 12px; border: 2px solid var(--ai-border);
    border-radius: 11px; font-size: 0.9rem; font-family: inherit;
    outline: none; background: #fbfaff; transition: border-color 0.2s;
}
.img-form-row input:focus, .img-form-row select:focus, .img-left textarea:focus {
    border-color: var(--ai-primary);
}
.img-left .form-item { margin-bottom: 14px; }
.img-left .form-item.full { margin-bottom: 14px; }
.img-left .form-item label { display: flex; align-items: center; gap: 5px; font-size: 0.82rem; font-weight: 600; color: var(--ai-text-2); }

/* 参考图上传 */
.ref-upload { display: flex; flex-direction: column; gap: 8px; }
.ref-list { display: flex; flex-wrap: wrap; gap: 8px; }
.ref-item {
    position: relative; border-radius: 10px; overflow: hidden;
    border: 1px solid var(--ai-border);
}
.ref-item img { width: 72px; height: 72px; object-fit: cover; display: block; }
.ref-item .ref-x {
    position: absolute; top: 3px; right: 3px;
    width: 18px; height: 18px; border-radius: 50%;
    border: none; background: rgba(0,0,0,0.55); color: #fff;
    font-size: 0.75rem; cursor: pointer; line-height: 1;
}
.ref-item .ref-x:hover { background: var(--ai-red); }

/* 生成按钮行 */
.img-actions { display: flex; gap: 10px; margin-top: 4px; }

/* 结果区 */
.img-right { min-height: 420px; }
.img-result { display: flex; flex-wrap: wrap; gap: 14px; }
.img-result-empty {
    margin: auto; text-align: center; color: var(--ai-text-2);
    padding: 80px 0;
}
.img-result-empty .e { font-size: 2.6rem; margin-bottom: 10px; }
.img-card {
    border: 1px solid var(--ai-border); border-radius: 14px;
    overflow: hidden; background: var(--ai-card-solid);
    box-shadow: 0 6px 18px rgba(124, 92, 255, 0.10);
    width: 280px;
}
.img-card img { width: 100%; display: block; }
.img-card-foot {
    display: flex; align-items: center; gap: 6px;
    padding: 8px 10px; border-top: 1px dashed var(--ai-border);
    font-size: 0.8rem;
}
.img-card-foot .grow { flex: 1; }
.img-dl {
    border: none; background: rgba(124, 92, 255, 0.12); color: #5b3fd4;
    border-radius: 8px; padding: 5px 10px; font-size: 0.78rem;
    font-family: inherit; cursor: pointer; font-weight: 600;
    text-decoration: none; display: inline-block;
}
.img-dl:hover { background: rgba(124, 92, 255, 0.22); }
.img-card img { cursor: zoom-in; }
.img-zoom-tip { color: var(--ai-text-2); font-weight: 400; }

/* 生图结果 · 大图预览（双击打开） */
.img-lightbox {
    position: fixed; inset: 0; z-index: 300;
    display: flex; align-items: center; justify-content: center;
    padding: 24px;
}
.img-lightbox-mask {
    position: absolute; inset: 0;
    background: rgba(12, 8, 30, 0.9);
    backdrop-filter: blur(8px);
}
.img-lb-body {
    position: relative; z-index: 1;
    display: flex; flex-direction: column; align-items: center;
    gap: 12px; max-width: 94vw; max-height: 92vh;
}
.img-lb-img {
    max-width: 94vw; max-height: 82vh;
    object-fit: contain; border-radius: 12px;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
    background: #0b0719;
    transition: opacity 0.2s;
}
.img-lb-img.loading { opacity: 0.35; }
.img-lb-info {
    display: flex; align-items: center; gap: 14px;
    color: #fff; font-size: 0.9rem;
}
.img-lb-count { opacity: 0.85; }
.img-lb-info .img-dl {
    color: #fff; background: rgba(124, 92, 255, 0.35);
}
.img-lb-info .img-dl:hover { background: rgba(124, 92, 255, 0.55); }
.img-lb-close, .img-lb-nav {
    position: absolute; z-index: 2;
    border: none; cursor: pointer; font-family: inherit;
    display: flex; align-items: center; justify-content: center;
    color: #fff; background: rgba(255, 255, 255, 0.14);
    border-radius: 50%;
    transition: background 0.2s, transform 0.2s;
    padding: 0;
}
.img-lb-close:hover, .img-lb-nav:hover { background: rgba(255, 255, 255, 0.3); }
.img-lb-close:active, .img-lb-nav:active { transform: scale(0.92); }
.img-lb-close {
    top: 18px; right: 18px;
    width: 42px; height: 42px; font-size: 1.1rem;
}
.img-lb-nav {
    top: 50%; transform: translateY(-50%);
    width: 48px; height: 48px; font-size: 1.9rem; line-height: 1;
}
.img-lb-nav:active { transform: translateY(-50%) scale(0.92); }
.img-lb-prev { left: 16px; }
.img-lb-next { right: 16px; }
@media (max-width: 600px) {
    .img-lb-nav { width: 38px; height: 38px; font-size: 1.4rem; }
    .img-lb-close { width: 36px; height: 36px; }
}

/* 视频生成 */
.vid-player {
    width: 100%; display: block;
    max-height: 340px; background: #000;
    aspect-ratio: 16 / 9; object-fit: contain;
}
.img-card .vid-player + .img-card-foot { margin-top: 0; }
.vid-loading {
    margin: auto; text-align: center; color: var(--ai-text-2);
    padding: 70px 0;
}
.vid-loading-spin {
    width: 42px; height: 42px; margin: 0 auto 14px;
    border: 3px solid rgba(124, 92, 255, 0.2);
    border-top-color: var(--ai-primary);
    border-radius: 50%;
    animation: cf-spin 1s linear infinite;
}
.vid-loading-txt { font-size: 0.88rem; }

/* 新增模型弹窗：统一ID匹配按钮 */
.uniq-match-row {
    display: flex; gap: 8px; align-items: center;
}
.uniq-match-row select { flex: 1; min-width: 0; }
.uniq-match-row .btn { flex-shrink: 0; white-space: nowrap; min-width: 76px; justify-content: center; }
.uniq-match-row .btn.uniq-matched {
    background: rgba(74, 222, 128, 0.15); color: #16a34a;
    border-color: rgba(74, 222, 128, 0.5);
}

/* 响应式 */
@media (max-width: 1100px) {
    .img-grid { grid-template-columns: 1fr; }
    .chat-card { height: 60vh; flex: none; }
}
@media (max-width: 860px) {
    .chat-msg-row { max-width: 96%; }
}

/* ============================================================
   移动端适配（≤900px）：顶部标题行 + 抽屉式侧边栏
   PC 端（>900px）完全不受影响
   ============================================================ */
.m-topbar { display: none; }
.m-mask { display: none; }

@media (max-width: 900px) {
    /* ---- 顶部标题行 ---- */
    .m-topbar {
        display: flex;
        align-items: center;
        gap: 6px;
        position: sticky;
        top: 0;
        z-index: 80;
        height: 50px;
        padding: 0 10px;
        background: rgba(255, 255, 255, 0.92);
        backdrop-filter: blur(14px);
        border-bottom: 1px solid var(--ai-border);
        flex-shrink: 0;
    }
    .m-menu-btn {
        width: 38px; height: 38px;
        border: none; background: transparent;
        border-radius: 10px;
        cursor: pointer;
        display: flex; align-items: center; justify-content: center;
        font-family: inherit;
        flex-shrink: 0;
    }
    .m-menu-btn { font-size: 1.45rem; color: var(--ai-text); }
    .m-menu-btn:active { transform: scale(0.92); }
    #m-back-btn { font-size: 1.2rem; }
    /* flex display 会覆盖 [hidden] 的 UA 样式，必须显式处理 */
    .m-menu-btn[hidden], .m-top-btn[hidden] { display: none !important; }
    .m-title {
        position: absolute;
        left: 50%;
        transform: translateX(-50%);
        max-width: 55%;
        text-align: center;
        font-weight: 800; font-size: 1rem;
        overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
        color: var(--ai-text);
    }

    /* 导航条右侧面板操作按钮（纯图标、无背景），靠右对齐 */
    .m-top-actions {
        display: flex; align-items: center; gap: 2px;
        flex-shrink: 0;
        margin-left: auto;
    }
    .m-top-btn {
        width: 38px; height: 38px;
        border: none; background: transparent;
        border-radius: 10px;
        cursor: pointer;
        display: flex; align-items: center; justify-content: center;
        font-family: inherit;
        font-size: 1.2rem;
        color: var(--ai-text);
        flex-shrink: 0;
        transition: background 0.15s, color 0.15s;
    }
    .m-top-btn:active { transform: scale(0.9); }
    .m-top-btn:hover { background: rgba(124, 92, 255, 0.1); color: var(--ai-primary); }
    /* 聊天顶栏控制图标（📎🌐💭）：点击/悬停/聚焦均无背景变色 */
    .m-top-btn.chat-ctrl:hover,
    .m-top-btn.chat-ctrl:active,
    .m-top-btn.chat-ctrl:focus {
        background: transparent;
        color: var(--ai-text);
    }
    /* 联网搜索激活态：深色背景 + 白色光晕，让蓝色 🌐 图标清晰可见 */
    .m-top-btn.websearch-on,
    .m-top-btn.websearch-on:hover,
    .m-top-btn.websearch-on:active,
    .m-top-btn.websearch-on:focus {
        background: linear-gradient(135deg, #5b4a8a, #34344a);
        color: #fff;
        box-shadow: 0 4px 14px rgba(80, 60, 140, 0.5);
        text-shadow: 0 0 3px rgba(255, 255, 255, 0.9), 0 0 8px rgba(255, 255, 255, 0.5);
    }
    /* 思考档位浮层 */
    .m-thinking-pop {
        position: fixed;
        top: 52px;
        right: 10px;
        z-index: 92;
        background: rgba(255, 255, 255, 0.98);
        backdrop-filter: blur(14px);
        border: 1px solid var(--ai-border);
        border-radius: 14px;
        box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
        padding: 6px;
        display: flex;
        flex-direction: column;
        gap: 2px;
        min-width: 160px;
    }
    .m-thinking-pop .tp-item {
        border: none; background: transparent;
        padding: 10px 14px; border-radius: 10px;
        font-family: inherit; font-size: 0.9rem;
        cursor: pointer; text-align: left;
        color: var(--ai-text);
        display: flex; align-items: center; gap: 8px;
        transition: background 0.15s;
    }
    .m-thinking-pop .tp-item:hover { background: rgba(124, 92, 255, 0.08); }
    .m-thinking-pop .tp-item.active {
        background: var(--ai-primary-grad);
        color: #fff;
    }

    /* 面板内被移到导航条的操作按钮：移动端隐藏 */
    #refresh-stats,
    #new-key-btn, #preset-copilot-btn, #new-upstream-btn, #new-uniq-btn, #new-user-btn,
    #toggle-upstreams,
    .chat-head {
        display: none !important;
    }
    /* 上传/联网/思考 移入顶栏：选项栏只保留模型/视觉选择 */
    .chat-optbar .chat-attach,
    .chat-optbar .chat-web-label,
    .chat-optbar #chat-thinking,
    .chat-optbar #chat-retry-btn {
        display: none !important;
    }
    /* 操作按钮全被移走的面板：隐藏空工具栏 */
    #panel-keys .toolbar,
    #panel-models .toolbar,
    #panel-uniqids .toolbar,
    #panel-users .toolbar {
        display: none !important;
    }

    /* ---- 布局：顶栏在上，内容在下 ---- */
    .app { flex-direction: column; min-height: var(--m-vh, 100vh); }
    /* 聊天面板激活时锁定视口高度，防止内容撑开容器导致无法全屏
       --m-vh 由 JS 用 window.innerHeight 实时设置：手机浏览器地址栏显示/隐藏时自动跟随，避免内容超出窗口 */
    .app:has(#panel-chat:not(.hidden)) {
        height: var(--m-vh, 100vh);
        overflow: hidden;
    }

    /* ---- 侧边栏：抽屉式 ---- */
    .sidebar {
        position: fixed;
        left: 0; top: 0; bottom: 0;
        width: 272px;
        z-index: 100;
        height: var(--m-vh, 100vh);
        transform: translateX(-105%);
        transition: transform 0.28s ease, box-shadow 0.28s ease;
        background: rgba(255, 255, 255, 0.98);
        box-shadow: none;
        padding: 14px 14px;
    }
    .sidebar.open {
        transform: translateX(0);
        box-shadow: 14px 0 42px rgba(0, 0, 0, 0.20);
    }
    .sidebar-brand { padding: 2px 6px 10px; }
    .sidebar-brand .brand-logo { width: 38px; height: 38px; border-radius: 11px; }
    .sidebar-brand .name { font-size: 1.1rem; }
    .menu-item { padding: 8px 14px; font-size: 0.95rem; }
    .menu-item .mi { font-size: 1.1rem; }

    /* ---- 遮罩 ---- */
    .m-mask {
        display: block;
        position: fixed; inset: 0;
        z-index: 90;
        background: rgba(0, 0, 0, 0.45);
        backdrop-filter: blur(2px);
    }

    /* ---- 主内容 ---- */
    .main {
        padding: 16px 14px 40px;
        max-width: none;
        width: 100%;
        min-width: 0;
    }

    /* ---- 聊天面板：全屏（扣除顶栏高度） ---- */
    .main:has(#panel-chat:not(.hidden)) {
        height: calc(var(--m-vh, 100vh) - 50px);
        padding: 0;
    }
    .chat-card { height: auto; flex: 1; }   /* 覆盖 1100px 断点的 60vh，移动端真正全屏 */
    .chat-box { padding: 14px 12px 6px; }
    .chat-input-bar { padding: 8px 10px; }
    /* 输入框：隐藏占位提示文字；最多撑高 5 行（行高21.6px×5 + padding20 + border4 = 132px）；隐藏滚动条 */
    .chat-input { max-height: 132px; scrollbar-width: none; }
    .chat-input::-webkit-scrollbar { display: none; }
    .chat-input::placeholder { opacity: 0; }
    .chat-optbar { padding: 6px 10px 10px; gap: 6px; }
    .chat-optbar .pg-select {
        flex: 1 1 0;
        max-width: none;
        min-width: 0;
        padding: 6px 6px;
        font-size: 0.78rem;
    }
    .chat-optbar #chat-thinking { flex: 0 1 auto; }   /* 宽度随内容自适应 */
    .chat-optbar .grow { display: none; }
    .chat-msg-row { max-width: 96%; gap: 8px; }
    .chat-msg-row .cm-avatar { width: 30px; height: 30px; font-size: 0.85rem; }
    .chat-msg-row .cm-bubble { padding: 9px 12px; font-size: 0.88rem; }
    .chat-history-view { padding: 16px 12px 12px; }
    .attach-list { padding: 8px 10px 0; }
    /* 移动端消息操作按钮：点击消息行切换显示（无 hover） */
    .chat-msg-row .cm-actions { opacity: 0; }
    .chat-msg-row.act-open .cm-actions { opacity: 1; }
    .cm-actions .cm-act { padding: 6px 12px; font-size: 0.85rem; }   /* 触控加大 */

    /* ---- 仪表盘 ---- */
    .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 14px; }
    .stat-card { padding: 12px 14px; }
    .stat-card .stat-emoji { font-size: 1.3rem; }
    .stat-card .stat-value { font-size: 1.15rem; margin: 4px 0 2px; }
    .stat-card .stat-label { font-size: 0.72rem; }
    .toolbar { gap: 8px; margin-bottom: 12px; }
    .seg { flex-wrap: nowrap; overflow-x: auto; max-width: 100%; }
    .seg button { padding: 6px 11px; white-space: nowrap; }
    .date-input { max-width: 130px; }

    /* ---- 通用卡片/表格 ---- */
    .card { padding: 14px 12px; }
    .ai-table { font-size: 0.82rem; }
    .ai-table th, .ai-table td { padding: 8px 10px; }
    .img-form-row { grid-template-columns: 1fr; }
    .img-card { width: 100%; }
    .img-right { min-height: 320px; }
    .img-result-empty { padding: 50px 0; }
    .img-result { gap: 12px; }

    /* ---- 弹窗 ---- */
    .modal { max-width: calc(100vw - 28px); max-height: 84vh; }
    .modal-actions .btn { flex: 1; justify-content: center; }

    /* ---- 登录页 ---- */
    .login-card { padding: 28px 20px 24px; border-radius: 22px; }

    /* ---- 通用小按钮触控加大 ---- */
    .btn { padding: 10px 14px; }
    .btn-sm { padding: 8px 12px; }
    .btn-icon { width: 36px; height: 36px; }
}
@media (max-width: 420px) {
    .chat-optbar .pg-select { flex-basis: 45%; }
    .chat-optbar #chat-thinking { flex: 0 1 auto; }   /* 思考档位保持内容自适应 */
}

/* ============================================================
 * 深色模式（配合 main_page/css/theme.css，由 <html data-theme> 触发）
 * ============================================================ */

/* 登录卡片需要相对定位以容纳右上角主题切换按钮 */
.login-card { position: relative; }

/* 登录卡片右上角主题切换按钮 */
.login-theme-toggle {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid var(--ai-border);
    background: var(--ai-card);
    color: var(--ai-text-2);
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.18s;
    z-index: 2;
    padding: 0;
}
.login-theme-toggle:hover {
    border-color: var(--ai-primary);
    color: var(--ai-primary);
}

[data-theme="dark"] .login-card,
[data-theme="dark"] .card,
[data-theme="dark"] .stat-card {
    border-color: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .login-input {
    background: #131c2c;
    color: var(--ai-text);
}

[data-theme="dark"] .sidebar {
    background: rgba(19, 23, 35, 0.85);
}

/* 统计卡片渐变 → 深色底 */
[data-theme="dark"] .stat-card.violet { background: linear-gradient(135deg, rgba(124, 92, 255, 0.28), rgba(30, 34, 50, 0.9)); }
[data-theme="dark"] .stat-card.blue { background: linear-gradient(135deg, rgba(79, 195, 247, 0.20), rgba(30, 34, 50, 0.9)); }
[data-theme="dark"] .stat-card.orange { background: linear-gradient(135deg, rgba(255, 138, 101, 0.20), rgba(30, 34, 50, 0.9)); }
[data-theme="dark"] .stat-card.green { background: linear-gradient(135deg, rgba(102, 187, 106, 0.20), rgba(30, 34, 50, 0.9)); }
[data-theme="dark"] .stat-card.red { background: linear-gradient(135deg, rgba(239, 83, 80, 0.22), rgba(30, 34, 50, 0.9)); }
[data-theme="dark"] .stat-card.cyan { background: linear-gradient(135deg, rgba(38, 198, 218, 0.20), rgba(30, 34, 50, 0.9)); }

/* 白底按钮/控件 → 深色 */
[data-theme="dark"] .btn-ghost,
[data-theme="dark"] .logout-btn,
[data-theme="dark"] .btn-icon,
[data-theme="dark"] .ai-tabs .tab,
[data-theme="dark"] .date-input,
[data-theme="dark"] .pg-select {
    background: #1a1e2c;
    color: var(--ai-text);
}

[data-theme="dark"] .seg { background: rgba(255, 255, 255, 0.06); }
[data-theme="dark"] .model-group { background: rgba(255, 255, 255, 0.04); }
[data-theme="dark"] .model-group[open] { background: var(--ai-card-solid); }
[data-theme="dark"] .perm-group { background: rgba(255, 255, 255, 0.04); }

/* 弹窗 */
[data-theme="dark"] #modal-root .modal {
    background: #1a1e2c;
    border: 1px solid var(--ai-border);
}
[data-theme="dark"] #modal-root .form-item input,
[data-theme="dark"] #modal-root .form-item select,
[data-theme="dark"] #modal-root .form-item textarea {
    background: #131c2c;
    color: var(--ai-text);
}

/* 标签 / 提示文字 → 深色下提亮 */
.ml-count { font-size: 0.85rem; font-weight: 600; color: var(--ai-primary); background: rgba(124,92,255,0.1); border-radius: 999px; padding: 2px 10px; margin-left: 4px; }
[data-theme="dark"] .tag-violet { color: #b9a8ff; }
[data-theme="dark"] .tag-purple { color: #e0a0e8; }
[data-theme="dark"] .tag-blue { color: #7cc8f0; }
[data-theme="dark"] .tag-orange { color: #ffb08a; }
[data-theme="dark"] .tag-green { color: #8fd99a; }
[data-theme="dark"] .tag-gray { color: #a0a0b4; }
[data-theme="dark"] .tag-cyan { color: #6fd4e0; }
[data-theme="dark"] .msg-ok { color: #7ed48b; }
[data-theme="dark"] .msg-err { color: #ff8a80; }
[data-theme="dark"] .warn-box { color: #ffb08a; }
[data-theme="dark"] .pg-select-vision {
    background: #241c18;
    border-color: rgba(255, 138, 101, 0.6);
}
[data-theme="dark"] .up-badge,
[data-theme="dark"] .key-models-toggle:hover,
[data-theme="dark"] .cm-file,
[data-theme="dark"] .cm-bubble code,
[data-theme="dark"] .cm-copyblock-head,
[data-theme="dark"] .cm-table-wrap .cm-copy-tbl,
[data-theme="dark"] .perm-group-title { color: #b9a8ff; }

[data-theme="dark"] .switch .slider { background: #3a3550; }

/* 聊天 */
[data-theme="dark"] .chat-head { background: rgba(255, 255, 255, 0.04); }
/* 聊天输入区：浅色半透明白底在深色下刺眼，统一为深色面板 */
[data-theme="dark"] .chat-input-bar,
[data-theme="dark"] .chat-optbar {
    background: #141926;
    border-top-color: var(--ai-border);
}
[data-theme="dark"] .chat-input {
    background: #131c2c;
    color: var(--ai-text);
    border-color: var(--ai-border);
}
[data-theme="dark"] .chat-input::placeholder { color: var(--ai-text-2); opacity: 0.7; }
[data-theme="dark"] .chat-web-label { background: #1a1e2c; }
[data-theme="dark"] .chat-stop-btn { background: #3a3550; }
[data-theme="dark"] .chat-stop-btn:hover { background: #4a4560; }
[data-theme="dark"] .chat-msg-row .cm-bubble {
    background: #1f2436;
    color: var(--ai-text);
    border-color: var(--ai-border);
}
[data-theme="dark"] .chat-msg-row.user .cm-bubble {
    background: var(--ai-primary-grad);
    color: #fff;
}
[data-theme="dark"] .chat-msg-row.error .cm-bubble { color: var(--ai-text-1); }
[data-theme="dark"] .cm-file.cf-img { background: rgba(255, 255, 255, 0.06); }

/* 深色模式错误块：更亮的红色文字 + 深红背景 */
[data-theme="dark"] .cm-err {
    color: #ff8a80;
    background: rgba(239, 83, 80, 0.12);
    border-color: rgba(239, 83, 80, 0.35);
}

/* 移动端顶栏 */
[data-theme="dark"] .m-topbar {
    background: rgba(19, 23, 35, 0.92);
}

/* ============ 网页模型（webchat） ============ */
.tb-title { font-weight: 800; font-size: 1.02rem; display: flex; align-items: center; gap: 8px; }
.wc-tip {
    background: rgba(124, 92, 255, 0.08);
    border: 1px dashed rgba(124, 92, 255, 0.4);
    border-radius: 14px;
    padding: 12px 16px;
    font-size: 0.85rem;
    line-height: 1.7;
    color: var(--ai-text);
    margin-bottom: 18px;
}
.wc-tip code {
    font-family: "SF Mono", Consolas, monospace;
    background: rgba(124, 92, 255, 0.12);
    color: #5b3fd4;
    padding: 1px 6px;
    border-radius: 5px;
    font-size: 0.8rem;
}
#webchat-list { display: flex; flex-direction: column; gap: 14px; }
.wc-card { margin-bottom: 0; }
.wc-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding-bottom: 14px;
    border-bottom: 1px dashed var(--ai-border);
    margin-bottom: 16px;
}
.wc-title { font-weight: 800; font-size: 1.05rem; display: flex; align-items: center; gap: 8px; }
.wc-tag {
    font-size: 0.68rem;
    font-weight: 600;
    background: rgba(79, 195, 247, 0.14);
    color: #2c7fb8;
    padding: 2px 9px;
    border-radius: 999px;
    letter-spacing: 0.3px;
}
.wc-body .form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.wc-opts { display: flex; gap: 18px; flex-wrap: wrap; padding: 8px 0; }
.wc-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 16px;
}
.wc-test-out {
    margin-top: 12px;
    padding: 10px 14px;
    border-radius: 12px;
    background: rgba(124, 92, 255, 0.06);
    border: 1px solid var(--ai-border);
    font-size: 0.85rem;
    line-height: 1.6;
    word-break: break-word;
}
[data-theme="dark"] .wc-tag { color: #7cc8f0; }
[data-theme="dark"] .wc-tip { background: rgba(124, 92, 255, 0.10); }
[data-theme="dark"] .wc-tip code { background: rgba(124, 92, 255, 0.22); color: #b9a8ff; }
@media (max-width: 640px) {
    .wc-body .form-grid { grid-template-columns: 1fr; }
}
