/* ===================== 通用 ===================== */
:root {
    --bg-primary: #1a1a1d;
    --bg-secondary: #2a2a2e;
    --bg-tertiary: #323237;
    --bg-hover: #3a3a40;
    --text-primary: #e0e0e0;
    --text-secondary: #a0a0a8;
    --text-muted: #707078;
    --accent: #7b68ee;
    --accent-hover: #9683f5;
    --accent-glow: rgba(123, 104, 238, 0.3);
    --border: #404048;
    --danger: #e05050;
    --success: #50c878;
    --sidebar-w: 220px;
    --right-w: 280px;
    --header-h: 48px;
    --input-h: 36px;
    --radius: 6px;
    --shadow: 0 2px 12px rgba(0,0,0,0.4);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.6);
}

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

body.app-page {
    font-family: 'Noto Sans', 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    display: flex !important;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    padding: 10px 24px;
    border-radius: var(--radius);
    z-index: 10000;
    box-shadow: var(--shadow);
    font-size: 14px;
}
.form-msg { margin-top: 8px; font-size: 13px; color: var(--text-secondary); }
.form-msg.error { color: var(--danger); }
.form-msg.success { color: var(--success); }

/* App Loader */
.app-loader {
    position: fixed;
    inset: 0;
    background: var(--bg-primary);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    gap: 12px;
    color: var(--text-secondary);
}
.loader-spinner {
    width: 40px; height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    z-index: 9000;
    display: flex;
    align-items: center;
    justify-content: center;
}
.modal-content {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    padding: 24px;
    max-width: 90vw;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: var(--shadow);
    width: 480px;
}
.modal-close {
    position: absolute;
    top: 10px; right: 12px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 22px;
    cursor: pointer;
    line-height: 1;
}
.modal-close:hover { color: var(--text-primary); }

/* 通用按钮 */
.menu_button {
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    padding: 8px 20px;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s;
    min-height: var(--input-h);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}
.menu_button:hover { background: var(--accent-hover); }
.menu_button.secondary { background: var(--bg-tertiary); color: var(--text-secondary); }
.menu_button.secondary:hover { background: var(--bg-hover); color: var(--text-primary); }
.menu_button.small { padding: 5px 12px; font-size: 12px; min-height: 28px; }
.menu_button:disabled { opacity: 0.6; cursor: not-allowed; }
.menu_button.danger { background: var(--danger); }
.menu_button.danger:hover { background: #f06060; }

.text_pole {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    padding: 8px 12px;
    font-size: 14px;
    width: 100%;
    outline: none;
    min-height: var(--input-h);
}
.text_pole:focus { border-color: var(--accent); }
.text_pole::placeholder { color: var(--text-muted); }

/* ===================== 左边栏 ===================== */
.sidebar {
    width: var(--sidebar-w);
    min-width: var(--sidebar-w);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}
.sidebar-header {
    padding: 16px 12px;
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}
.user-avatar-wrap { position: relative; cursor: pointer; }
.user-avatar {
    width: 56px; height: 56px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border);
}
.user-info { text-align: center; width: 100%; }
.user-nickname {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.user-credits {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
}
.user-credits i { color: #f0c040; }
#sidebarCreditsNum { font-weight: 600; color: #f0c040; }

.sidebar-nav { flex: 1; padding: 12px 8px; overflow-y: auto; }
.sidebar-menu { display: flex; flex-direction: column; gap: 4px; }
.sidebar-menu-btn {
    width: 100%;
    background: transparent;
    border: none;
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-size: 14px;
    padding: 10px 12px;
    cursor: pointer;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.15s;
    text-decoration: none;
}
.sidebar-menu-btn i { width: 16px; text-align: center; }
.sidebar-menu-btn:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.sidebar-menu-btn.active { background: var(--accent); color: #fff; }

.sidebar-footer {
    padding: 12px 8px;
    border-top: 1px solid var(--border);
}
.sidebar-logout {
    width: 100%;
    background: transparent;
    border: none;
    border-radius: var(--radius);
    color: var(--text-muted);
    font-size: 13px;
    padding: 8px 12px;
    cursor: pointer;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: color 0.15s;
}
.sidebar-logout:hover { color: var(--danger); }

/* ===================== 主内容区 ===================== */
.main-content {
    flex: 1;
    height: 100vh;
    overflow-y: auto;
    background: var(--bg-primary);
}

.view-section { height: 100%; display: flex; flex-direction: column; }
.view-section.active { display: flex; }
.view-header {
    padding: 16px 20px 12px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
}
.view-title { font-size: 16px; font-weight: 600; color: var(--text-primary); }
.view-loading, .view-empty {
    padding: 40px 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
}

/* ===================== 角色卡列表 ===================== */
.char-list-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
    padding: 16px 20px;
    overflow-y: auto;
    flex: 1;
}
.char-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}
.char-card:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow); }
.char-card-avatar {
    width: 80px; height: 80px;
    border-radius: var(--radius);
    object-fit: cover;
    border: 1px solid var(--border);
}
.char-card-name { font-size: 14px; font-weight: 600; color: var(--text-primary); text-align: center; }
.char-card-desc { font-size: 12px; color: var(--text-muted); text-align: center; line-height: 1.4; }
.char-card-tags { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; }
.tag {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 4px;
}

/* ===================== 聊天视图 ===================== */
.chat-header {
    padding: 10px 16px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: var(--header-h);
}
.chat-back-btn {
    background: none; border: none;
    color: var(--text-secondary); font-size: 18px;
    cursor: pointer; padding: 4px;
}
.chat-back-btn:hover { color: var(--text-primary); }
.chat-char-avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid var(--border);
}
.chat-char-info { flex: 1; min-width: 0; }
.chat-char-name { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-model-name { font-size: 11px; color: var(--text-muted); }
.chat-header-right { display: flex; gap: 6px; }
.icon-btn {
    background: var(--bg-tertiary); border: none;
    color: var(--text-secondary); font-size: 16px;
    width: 32px; height: 32px; border-radius: var(--radius);
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: all 0.15s;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text-primary); }

/* 聊天消息区 */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: var(--bg-primary);
    background-attachment: fixed;
    background-size: cover;
    background-position: center;
    background-color: var(--bg-primary);
}

/* 消息气泡 */
.chat-bubble {
    display: flex;
    flex-direction: column;
    max-width: 70%;
    animation: bubbleIn 0.2s ease-out;
}
@keyframes bubbleIn { from { opacity: 0; transform: translateY(8px); } }

.chat-bubble.user { align-self: flex-end; align-items: flex-end; }
.chat-bubble.assistant { align-self: flex-start; align-items: flex-start; }
.chat-bubble.assistant .bubble-content { background: var(--bg-secondary); }
.chat-bubble.user .bubble-content { background: var(--accent); color: #fff; }

.bubble-content {
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
    word-break: break-word;
    white-space: pre-wrap;
    border: 1px solid var(--border);
}
.bubble-meta {
    display: flex;
    gap: 8px;
    margin-top: 4px;
    font-size: 11px;
    color: var(--text-muted);
    opacity: 0;
    transition: opacity 0.15s;
}
.chat-bubble:hover .bubble-meta { opacity: 1; }
.bubble-actions-btn {
    background: none; border: none;
    color: var(--text-muted); font-size: 11px;
    cursor: pointer; padding: 2px 4px;
    border-radius: 4px;
}
.bubble-actions-btn:hover { color: var(--text-primary); background: var(--bg-hover); }
.bubble-edited { font-style: italic; }

/* 包含 iframe 的气泡 - 更宽的布局 */
.chat-bubble:has(.html-greeting-iframe) {
    max-width: min(95%, 820px);
    width: 100%;
}

/* HTML iframe 渲染 - 自然填充气泡 */
.html-greeting-iframe {
    display: block;
    width: 100%;
    max-width: 100%;
    height: auto;
    min-height: 300px;
    border: none;
    background: transparent;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

/* 气泡内容中包含 iframe 时，移除额外 padding 影响 */
.bubble-content:has(.html-greeting-iframe) {
    padding: 0;
    overflow: hidden;
    width: 100%;
    max-width: 100%;
    border: none;
    background: transparent;
}

.bubble-content:has(.html-greeting-iframe) .html-greeting-iframe {
    display: block;
    width: 100%;
    max-width: 100%;
    height: auto;
    min-height: 300px;
    border: none;
    background: transparent;
}

/* 气泡操作浮层 */
.bubble-actions {
    position: fixed;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    z-index: 8000;
    display: flex;
    gap: 4px;
    padding: 4px;
}
.bubble-action-btn {
    background: none; border: none;
    color: var(--text-secondary); font-size: 12px;
    padding: 6px 10px; border-radius: 4px;
    cursor: pointer; display: flex; align-items: center; gap: 5px;
    white-space: nowrap;
}
.bubble-action-btn:hover { background: var(--bg-hover); color: var(--text-primary); }

/* 自定义模态框（替代原生 confirm/prompt，避免阻塞宿主 React 渲染） */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    animation: modalFade 0.15s ease-out;
}
@keyframes modalFade { from { opacity: 0; } to { opacity: 1; } }
.modal-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    min-width: 320px;
    max-width: 90vw;
    box-shadow: var(--shadow-lg);
    animation: modalPop 0.18s ease-out;
}
@keyframes modalPop {
    from { transform: scale(0.95); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}
.modal-title {
    padding: 14px 18px;
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border);
}
.modal-body {
    padding: 18px;
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.6;
}
.modal-input {
    width: 100%;
    box-sizing: border-box;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 10px 12px;
    font-size: 13px;
    color: var(--text-primary);
    font-family: inherit;
    resize: vertical;
    outline: none;
}
.modal-input:focus { border-color: var(--accent); }
.modal-actions {
    padding: 12px 18px;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    border-top: 1px solid var(--border);
}
.modal-btn {
    padding: 6px 16px;
    font-size: 13px;
    border-radius: 6px;
    cursor: pointer;
    border: 1px solid transparent;
    font-family: inherit;
    transition: background 0.15s;
}
.modal-btn.primary {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.modal-btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.modal-btn.secondary {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border-color: var(--border);
}
.modal-btn.secondary:hover { background: var(--bg-hover); color: var(--text-primary); }

/* 聊天输入 */
.chat-input-area {
    padding: 12px 16px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
}
.chat-input {
    width: 100%;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    padding: 10px 12px;
    font-size: 14px;
    resize: none;
    outline: none;
    font-family: inherit;
    line-height: 1.5;
    max-height: 150px;
    transition: border-color 0.2s;
}
.chat-input:focus { border-color: var(--accent); }
.chat-input::placeholder { color: var(--text-muted); }
.chat-input-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 10px;
}

/* AI 模型选择器 */
.chat-model-selector {
    display: flex;
    align-items: center;
    gap: 6px;
}
.chat-model-label {
    color: var(--text-muted);
    font-size: 14px;
    display: flex;
    align-items: center;
}
.chat-model-select {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    padding: 6px 10px;
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    outline: none;
    min-width: 120px;
    max-width: 180px;
    transition: border-color 0.2s;
}
.chat-model-select:hover { border-color: var(--accent); }
.chat-model-select:focus { border-color: var(--accent); }

/* 流式传输开关 */
.chat-stream-toggle {
    display: flex;
    align-items: center;
}
.chat-stream-label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    user-select: none;
}
.chat-stream-label input[type="checkbox"] {
    display: none;
}
.stream-switch {
    position: relative;
    width: 36px;
    height: 20px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 10px;
    transition: all 0.2s;
}
.stream-switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 14px;
    height: 14px;
    background: var(--text-muted);
    border-radius: 50%;
    transition: all 0.2s;
}
.chat-stream-label input:checked + .stream-switch {
    background: var(--accent);
    border-color: var(--accent);
}
.chat-stream-label input:checked + .stream-switch::after {
    left: 18px;
    background: #fff;
}
.stream-text {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
}

/* 发送按钮 */
.chat-send-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    background: var(--accent);
    border: none;
    border-radius: var(--radius);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 10px var(--accent-glow);
}
.chat-send-btn:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 15px var(--accent-glow);
}
.chat-send-btn:active {
    transform: translateY(0);
}
.chat-send-btn i {
    font-size: 12px;
}

/* 正在生成中的占位气泡 */
.bubble-generating .bubble-content {
    background: var(--bg-tertiary);
    color: var(--text-muted);
}
.bubble-generating::after {
    content: '';
    display: inline-block;
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    animation: blink 1s ease-in-out infinite;
    margin-left: 6px;
}
@keyframes blink { 0%,100%{opacity:0.3} 50%{opacity:1} }

/* ===================== 用户中心 ===================== */
.user-center { padding: 16px 20px; overflow-y: auto; height: 100%; }
.user-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 20px;
}
.user-card-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}
.user-card-row:last-child { border-bottom: none; }
.user-card-label { font-size: 13px; color: var(--text-secondary); width: 80px; flex-shrink: 0; }
.user-card-value { font-size: 14px; color: var(--text-primary); flex: 1; }
.credits-value { color: #f0c040 !important; font-weight: 600; }
.user-card-avatar-wrap { display: flex; align-items: center; gap: 10px; flex: 1; }
.user-card-avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; border: 1px solid var(--border); }

.user-section {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 20px;
}
.user-section-title { font-size: 14px; font-weight: 600; margin-bottom: 12px; color: var(--text-primary); }
.user-section-divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
.user-section-subtitle { font-size: 13px; font-weight: 500; margin-bottom: 12px; color: var(--text-secondary); }
.user-form { display: flex; flex-direction: column; gap: 8px; }
.user-form .text_pole { max-width: 300px; }

/* 密码可见性切换 */
.password-field { display: flex; align-items: center; max-width: 300px; position: relative; }
.password-field .text_pole { max-width: 100%; flex: 1; padding-right: 36px; }
.password-toggle { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); background: none; border: none; cursor: pointer; padding: 4px; display: flex; align-items: center; justify-content: center; color: var(--text-secondary); opacity: .6; transition: opacity .15s; }
.password-toggle:hover { opacity: 1; color: var(--text-primary); }
.password-toggle .eye-icon { display: block; }
.password-toggle .eye-off { display: none; }

/* 邮箱绑定 */
.email-status-row { display: flex; align-items: center; gap: 12px; padding: 8px 0; }
.email-status-value { font-size: 14px; }
.email-status-value.unbound { color: var(--text-muted); }
.email-status-value.bound { color: var(--success); }
.email-status-value.pending { color: #f0a030; }
.email-input-row { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.email-input-row .text_pole { flex: 1; max-width: 300px; }

.record-list { display: flex; flex-direction: column; gap: 8px; max-height: 400px; overflow-y: auto; }
.record-item {
    background: var(--bg-tertiary);
    border-radius: var(--radius);
    padding: 8px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}
.record-item-time { color: var(--text-muted); font-size: 11px; width: 140px; flex-shrink: 0; }
.record-item-desc { color: var(--text-primary); flex: 1; margin: 0 10px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.record-item-amount { font-weight: 600; white-space: nowrap; }
.record-item-amount.deduct { color: var(--danger); }
.record-item-amount.recharge { color: #22c55e; }
.pagination { display: flex; gap: 6px; justify-content: center; margin-top: 10px; }
.pagination button {
    background: var(--bg-tertiary); border: 1px solid var(--border);
    color: var(--text-secondary); font-size: 12px;
    padding: 4px 10px; border-radius: 4px; cursor: pointer;
}
.pagination button:hover { background: var(--bg-hover); }
.pagination button.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ===================== 右边栏 ===================== */
.right-sidebar {
    width: var(--right-w);
    min-width: var(--right-w);
    background: var(--bg-secondary);
    border-left: 1px solid var(--border);
    height: 100vh;
    overflow-y: auto;
}
.right-panel { display: flex; flex-direction: column; height: 100%; }
.right-panel-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.right-panel-header h3 { font-size: 14px; font-weight: 600; }
.panel-close {
    background: none; border: none;
    color: var(--text-muted); font-size: 20px;
    cursor: pointer; line-height: 1;
}
.panel-close:hover { color: var(--text-primary); }
.right-panel-body { padding: 16px; flex: 1; overflow-y: auto; }
.right-panel-avatar {
    width: 100%; border-radius: var(--radius);
    border: 1px solid var(--border);
    margin-bottom: 12px;
    max-height: 200px;
    object-fit: contain;
    background: var(--bg-tertiary);
}
.right-panel-name { font-size: 15px; font-weight: 600; margin-bottom: 8px; }
.right-panel-desc { font-size: 12px; color: var(--text-secondary); line-height: 1.5; margin-bottom: 10px; }
.right-panel-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 10px; }
.right-panel-wb { font-size: 12px; }
.right-panel-wb h4 { font-size: 12px; color: var(--text-muted); margin-bottom: 6px; margin-top: 10px; }
.right-panel-wb .wb-entry { padding: 4px 0; border-bottom: 1px solid var(--border); color: var(--text-secondary); }

/* 聊天参数 */
.param-group { margin-bottom: 14px; }
.param-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}
.param-label span { color: var(--accent); font-weight: 600; }
.param-select {
    width: 100%;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    padding: 7px 10px;
    font-size: 13px;
    outline: none;
    min-height: var(--input-h);
}
.param-select:focus { border-color: var(--accent); }
.param-range {
    width: 100%;
    accent-color: var(--accent);
    cursor: pointer;
}
.param-group label:has(input[type="checkbox"]) { cursor: pointer; }

/* 背景网格 */
.bg-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin: 12px 0;
    max-height: 300px;
    overflow-y: auto;
}
.bg-item {
    aspect-ratio: 16/9;
    border-radius: var(--radius);
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    background-size: cover;
    background-position: center;
    background-color: var(--bg-tertiary);
}
.bg-item:hover, .bg-item.selected { border-color: var(--accent); }
.bg-item.selected::after {
    content: '\f00c';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    color: #fff;
    background: var(--accent);
    width: 20px; height: 20px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    position: absolute; top: 4px; right: 4px;
    font-size: 10px;
}
.bg-upload { display: flex; gap: 8px; margin-top: 10px; }
.bg-upload input { flex: 1; }

/* 角色卡列表页样式 */
.chars-header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
}
.chars-header-inner {
    display: flex; align-items: center; gap: 16px;
    height: 56px; max-width: 1200px; margin: 0 auto;
}
.chars-logo { height: 36px; }
.chars-title { font-size: 18px; font-weight: 600; color: var(--text-primary); flex: 1; }
.chars-nav { display: flex; gap: 8px; }
.chars-nav-btn {
    background: var(--bg-tertiary); border: 1px solid var(--border);
    color: var(--text-secondary); font-size: 13px;
    padding: 6px 16px; border-radius: var(--radius); text-decoration: none;
    display: inline-flex; align-items: center;
}
.chars-nav-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.chars-main { max-width: 1200px; margin: 0 auto; padding: 24px; }
.chars-loading, .chars-empty {
    text-align: center; padding: 60px 0;
    color: var(--text-muted); font-size: 14px;
}
.chars-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
}
.char-card-avatar { width: 100%; height: 200px; }

/* 角色卡详情弹窗 */
.chars-modal { width: 600px; }
.chars-modal-body { display: flex; gap: 16px; padding: 8px 0; }
.chars-modal-left { flex-shrink: 0; }
.chars-modal-avatar {
    width: 160px; height: 160px; border-radius: var(--radius);
    object-fit: cover; border: 1px solid var(--border);
}
.chars-modal-right { flex: 1; overflow-y: auto; max-height: 70vh; }
.chars-modal-name { font-size: 18px; font-weight: 700; margin-bottom: 8px; }
.chars-modal-desc { font-size: 13px; color: var(--text-secondary); line-height: 1.6; margin-bottom: 10px; }
.chars-modal-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 12px; }
.chars-modal-wb { font-size: 12px; color: var(--text-muted); }
.chars-modal-wb h4 { font-size: 12px; color: var(--text-secondary); margin-bottom: 4px; }
.wb-entry { padding: 3px 0; border-bottom: 1px solid var(--border); }
.chars-start-btn { width: 100%; margin-top: 12px; font-size: 15px; padding: 12px; }

/* 注册页 */
#registerForm { max-width: 320px; margin: 0 auto; gap: 10px; }
#registerForm input { max-width: 320px; }

/* ===================== 滚动条美化 ===================== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
