/* ========== 77Bot AI 网页端样式 ========== */
:root {
    --bg: #0f1115;
    --bg-panel: #161a22;
    --bg-panel-2: #1c212c;
    --bg-hover: #232937;
    --bg-active: #2a3242;
    --border: #262c3a;
    --text: #e7eaf0;
    --text-dim: #8b93a5;
    --text-faint: #5c6474;
    --accent: #4f8cff;
    --accent-hover: #6ba0ff;
    --accent-soft: rgba(79, 140, 255, 0.15);
    --danger: #ff5c5c;
    --success: #3ecf8e;
    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
    --convbar-w: 280px;
    --mobile-bar-h: 48px;
}

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

html, body {
    height: 100%;
    overflow: hidden;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    font-size: 14px;
    overscroll-behavior: none;
    -webkit-tap-highlight-color: transparent;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; touch-action: manipulation; }
input, textarea, select { font-family: inherit; font-size: inherit; color: var(--text); }
a { color: var(--accent); }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #313848; border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }

/* ========== 通用按钮 ========== */
.btn-icon {
    width: 30px; height: 30px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: var(--radius-sm);
    color: var(--text-dim);
    font-size: 15px;
    flex-shrink: 0;
    transition: background 0.15s, color 0.15s;
}
.btn-icon:hover { background: var(--bg-hover); color: var(--text); }

.btn-primary {
    background: var(--accent);
    color: #fff;
    border-radius: var(--radius-sm);
    padding: 9px 18px;
    font-size: 14px;
    transition: background 0.15s;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-secondary {
    background: var(--bg-hover);
    color: var(--text);
    border-radius: var(--radius-sm);
    padding: 9px 18px;
}
.btn-secondary:hover { background: var(--bg-active); }

.btn-danger {
    background: var(--danger);
    color: #fff;
    border-radius: var(--radius-sm);
    padding: 9px 18px;
}
.btn-danger:hover { filter: brightness(1.1); }

.btn-link { color: var(--text-dim); font-size: 13px; padding: 4px 8px; border-radius: 4px; }
.btn-link:hover { color: var(--danger); background: var(--bg-hover); }
.btn-block { width: 100%; }

.form-group { margin-bottom: 14px; }
.form-group label { display: block; margin-bottom: 6px; color: var(--text-dim); font-size: 13px; }
.form-group .req { color: var(--danger); }
.form-group input, .form-group textarea, .form-group select {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    outline: none;
    transition: border-color 0.15s;
}
.form-group input:focus, .form-group textarea:focus, .form-group select:focus { border-color: var(--accent); }
.form-tip { margin-top: 6px; color: var(--text-dim); font-size: 12px; line-height: 1.6; }
.form-tip a { color: var(--accent); text-decoration: none; }

/* ---------- 图形验证码（登录 / 注册） ---------- */
.captcha-row { display: flex; gap: 10px; align-items: center; }
.captcha-row input {
    flex: 1; min-width: 0;
    letter-spacing: 4px;
}
.captcha-img {
    height: 44px; width: 116px; flex: 0 0 116px;
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    cursor: pointer; background: #f5f7fa; user-select: none;
}
.captcha-tip { margin: 6px 0 0; font-size: 12px; color: var(--text-dim); line-height: 1.5; }
.error-msg { color: var(--danger); font-size: 13px; margin-top: 10px; min-height: 18px; }

/* ========== 登录界面 ========== */
.login-view {
    height: 100vh;
    height: 100dvh;
    display: flex; align-items: center; justify-content: center;
    background: radial-gradient(ellipse at top, #1a2030 0%, var(--bg) 60%);
    padding: 20px;
}
.login-box {
    width: 360px; max-width: 100%;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 36px 32px;
    box-shadow: var(--shadow);
    text-align: center;
}
.login-logo { font-size: 44px; margin-bottom: 8px; }
.login-box h1 { font-size: 24px; margin-bottom: 4px; }
.subtitle { color: var(--text-dim); margin-bottom: 26px; }

/* ========== 主布局 ========== */
/* 关键：行必须显式给定且允许收缩（minmax(0,1fr)），否则隐式行按内容撑高，
   消息一多整个页面就开始滚动，输入框被顶到屏幕外。
   三栏也要 min-height:0 打断 grid 项的自动最小尺寸，
   聊天区内部的「消息区独立滚动、输入框钉在底部」才能成立。 */
.app-view {
    display: grid;
    grid-template-columns: var(--convbar-w) 1fr;
    grid-template-rows: minmax(0, 1fr);
    grid-template-areas: "convbar chat";
    height: 100vh;
    height: var(--app-h, 100dvh);
    overflow: hidden;
}
#conv-bar, #chat-area { min-height: 0; }
#mobile-bar { display: none; }
#mobile-mask { display: none; }
.mobile-only { display: none !important; }

.item-more {
    position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
    width: 24px; height: 24px; border-radius: 4px;
    display: flex; align-items: center; justify-content: center;
    color: var(--text-dim); font-size: 14px;
    opacity: 0; transition: opacity 0.12s;
}
.conv-item:hover .item-more { opacity: 1; }
.item-more:hover { background: var(--bg-active); color: var(--text); }

.list-divider {
    font-size: 11px; color: var(--text-faint);
    padding: 10px 12px 4px; letter-spacing: 1px;
}

.sidebar-footer {
    border-top: 1px solid var(--border);
    padding: 10px 12px;
    display: flex; flex-direction: column; gap: 8px;
}
.user-info {
    min-width: 0; width: 100%;
    display: flex; align-items: center; gap: 9px;
    background: var(--bg-panel-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 10px;
    text-align: left;
    transition: border-color 0.15s, background 0.15s;
}
.user-info:hover { border-color: var(--accent); background: var(--bg-hover); }
a.user-info { text-decoration: none; color: var(--text); cursor: pointer; }
/* .user-avatar 样式已统一收进 css/avatar.css */
.user-text { min-width: 0; flex: 1; display: flex; flex-direction: column; }
.user-name { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-balance { font-size: 11px; color: var(--text-dim); margin-top: 2px; }
.user-gear { color: var(--text-faint); flex: 0 0 auto; display: flex; }
.user-gear .ic { width: 15px; height: 15px; }
/* 侧栏底部操作行：充值 / 退出（文字按钮，居中并排） */
.sidebar-footer-actions {
    display: flex; align-items: center; justify-content: center;
    gap: 10px; padding: 2px 2px 0;
}
.sidebar-footer-actions .btn-link {
    font-size: 12.5px; padding: 4px 8px; border-radius: var(--radius-sm);
}
.sidebar-footer-actions .btn-recharge { color: var(--accent); }
.sidebar-footer-actions .btn-recharge:hover { background: color-mix(in srgb, var(--accent) 14%, transparent); }
.sidebar-footer-actions .sf-sep {
    width: 1px; height: 12px; flex: none;
    background: var(--border);
}

/* ========== 会话栏 ========== */
#conv-bar {
    grid-area: convbar;
    background: var(--bg-panel);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.conv-bar-header {
    display: flex; align-items: center; gap: 6px;
    padding: 12px;
    border-bottom: 1px solid var(--border);
}
.conv-bar-header h3 {
    flex: 1; font-size: 14px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.conv-list { flex: 1; overflow-y: auto; padding: 8px; }

.conv-item {
    position: relative;
    padding: 10px 34px 10px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    margin-bottom: 2px;
    transition: background 0.12s;
}
.conv-item:hover { background: var(--bg-hover); }
.conv-item.active { background: var(--accent-soft); }
.conv-item .item-title {
    font-size: 13.5px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.conv-item .item-meta { font-size: 11px; color: var(--text-faint); margin-top: 3px; }

.empty-tip {
    color: var(--text-faint); text-align: center;
    padding: 30px 10px; font-size: 13px; line-height: 1.8;
}

/* ========== 聊天区 ========== */
#chat-area {
    grid-area: chat;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--bg);
}
#chat-header {
    display: flex; align-items: center; gap: 10px;
    flex-wrap: wrap;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-panel);
}
.chat-title-wrap { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; }
/* 价格提示：独占一行，桌面/移动端都能看到选中模型的价格 */
#price-tip {
    flex-basis: 100%;
    order: 10;
    font-size: 12px;
    color: var(--text-faint);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: -2px;
}
#chat-title {
    font-size: 14px; font-weight: 600;
    min-width: 0;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chat-header-right { display: flex; align-items: center; gap: 8px; }
#model-select {
    background: var(--bg-panel-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 7px 10px;
    outline: none;
    max-width: 220px;
    cursor: pointer;
}
#model-select option { background: var(--bg-panel-2); }
/* 消息区：聊天区里唯一允许滚动的容器。
   min-height:0 是 flex 子项能收缩并触发内部滚动的必要条件。 */
#message-area {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px 0;
    scroll-behavior: smooth;
    overscroll-behavior: contain;
}
.msg-container { max-width: 860px; margin: 0 auto; padding: 0 20px; }

.welcome {
    max-width: 640px; margin: 8vh auto 0; text-align: center; padding: 0 20px;
}
.welcome-logo { font-size: 52px; }
.welcome h2 { margin: 12px 0 6px; font-size: 26px; }
.welcome p { color: var(--text-dim); margin-bottom: 26px; }
.welcome-tips { display: flex; flex-direction: column; gap: 10px; align-items: center; }
.welcome .tip {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 18px;
    color: var(--text-dim);
    font-size: 13px;
}

/* 单条消息：单列流式，无头像无气泡头 */
.message { padding: 14px 0; }
.message + .message { border-top: 1px solid rgba(38, 44, 58, 0.5); }
/* position:relative 供引用按钮绝对定位（不占布局空间，消除气泡下方空白） */
.message-body { min-width: 0; position: relative; }
/* 用户消息：右对齐淡蓝块 */
.message.user { display: flex; justify-content: flex-end; }
.message.user .message-body {
    max-width: 78%;
    background: rgba(79, 140, 255, 0.12);
    border: 1px solid rgba(79, 140, 255, 0.25);
    border-radius: 12px;
    padding: 10px 14px;
}
/* AI 回复：左对齐全宽平铺，无背景无边框 */
.message.assistant { display: block; }
.message.assistant .message-body { max-width: 100%; }

.message-content {
    line-height: 1.75;
    font-size: 14.5px;
    word-wrap: break-word;
    overflow-wrap: break-word;
}
.message-content > *:first-child { margin-top: 0; }
.message-content > *:last-child { margin-bottom: 0; }
.message-content p { margin: 8px 0; }
.message-content h1, .message-content h2, .message-content h3,
.message-content h4, .message-content h5 { margin: 16px 0 8px; line-height: 1.4; }
.message-content h1 { font-size: 1.4em; } .message-content h2 { font-size: 1.25em; }
.message-content h3 { font-size: 1.12em; }
.message-content ul, .message-content ol { margin: 8px 0; padding-left: 24px; }
.message-content li { margin: 3px 0; }
.message-content blockquote {
    border-left: 3px solid var(--accent);
    background: var(--bg-panel);
    padding: 8px 14px; margin: 10px 0;
    color: var(--text-dim); border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.message-content table {
    border-collapse: collapse; margin: 12px 0; width: 100%;
    display: block; overflow-x: auto;
}
.message-content th, .message-content td {
    border: 1px solid var(--border); padding: 7px 12px; text-align: left;
}
.message-content th { background: var(--bg-panel-2); }
.message-content hr { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

.message-content code:not(pre code) {
    background: var(--bg-panel-2);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 2px 6px;
    font-family: "SF Mono", Consolas, "Courier New", monospace;
    font-size: 0.88em;
    color: #e5c07b;
}

/* 代码块 */
.code-block {
    margin: 12px 0;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    background: #0b0e14;
}
.code-block-header {
    display: flex; align-items: center; justify-content: space-between;
    background: var(--bg-panel-2);
    padding: 6px 12px;
    font-size: 12px; color: var(--text-dim);
}
.code-copy-btn {
    font-size: 12px; color: var(--text-dim);
    padding: 3px 10px; border-radius: 4px;
}
.code-copy-btn:hover { background: var(--bg-hover); color: var(--text); }
.code-copy-btn.copied { color: var(--success); }
.code-block pre {
    margin: 0; padding: 12px 14px;
    overflow-x: auto;
    font-family: "SF Mono", Consolas, "Courier New", monospace;
    font-size: 13px; line-height: 1.6;
}
.code-block pre code { background: none; border: none; padding: 0; color: #c8d0dc; font-size: inherit; }

/* 消息图片 */
.message-images { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0; }
.message-images img {
    max-width: 220px; max-height: 180px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    cursor: zoom-in;
    object-fit: cover;
}
/* 附件 chip（文档/压缩包等非图片文件） */
.file-chip {
    display: inline-flex; align-items: center; gap: 6px;
    max-width: 240px; padding: 6px 10px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-panel);
    font-size: 12.5px; color: inherit; text-decoration: none;
}
.file-chip .fc-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-chip .fc-size { flex: none; opacity: .55; }
.preview-item.file-chip-box {
    width: auto; min-width: 110px; max-width: 200px; height: 44px;
    display: flex; align-items: center; gap: 6px; padding: 0 26px 0 10px;
    font-size: 12px; overflow: visible;
}
.preview-item.file-chip-box .fc-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.message-footer {
    margin-top: 6px;
    font-size: 11px; color: var(--text-faint);
    display: flex; gap: 12px; align-items: center;
}

/* 流式光标 */
.streaming-cursor {
    display: inline-block;
    width: 8px; height: 15px;
    background: var(--accent);
    vertical-align: -2px;
    margin-left: 2px;
    animation: blink 0.9s infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* 流式正文段（时间线内的一段正文） */
.stream-text { line-height: 1.75; margin: 6px 0; }
.stream-text > *:first-child { margin-top: 0; }
.stream-text > *:last-child { margin-bottom: 0; }

/* 流内提示条（上下文已压缩 / 工具轮数跑满） */
.stream-notice {
    margin: 8px 0;
    padding: 7px 12px;
    border-left: 3px solid var(--accent);
    background: var(--bg-panel);
    border-radius: var(--radius-sm);
    font-size: 12.5px;
    color: var(--text-dim);
    line-height: 1.6;
}
.stream-notice.warn {
    border-left-color: #e0a23c;
    color: #d69a34;
}

/* 思考卡片（默认折叠） */
.thinking-card {
    margin: 8px 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-panel);
    overflow: hidden;
    font-size: 13px;
}
.thinking-card summary {
    padding: 6px 12px;
    cursor: pointer;
    font-weight: 600; font-size: 12.5px;
    color: var(--text-dim);
    background: var(--bg-panel-2);
    user-select: none;
    list-style: none;
}
.thinking-card summary::-webkit-details-marker { display: none; }
.thinking-card[open] summary { border-bottom: 1px solid var(--border); }
.thinking-body {
    padding: 8px 12px;
    font-size: 12.5px;
    color: var(--text-dim);
    white-space: pre-wrap; word-break: break-word;
    max-height: 260px;
    overflow-y: auto;
    line-height: 1.6;
}

/* 工具调用卡片 */
.tool-card {
    margin: 8px 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-panel);
    overflow: hidden;
    font-size: 13px;
}
.tool-card-head {
    padding: 6px 12px;
    font-weight: 600; font-size: 12.5px;
    color: var(--text-dim);
    background: var(--bg-panel-2);
    border-bottom: 1px solid var(--border);
}
.tool-card-args {
    padding: 6px 12px;
    font-family: "SF Mono", Consolas, "Courier New", monospace;
    font-size: 12px;
    color: #e5c07b;
    background: #0b0e14;
    white-space: pre-wrap; word-break: break-all;
    border-bottom: 1px solid var(--border);
}
.tool-card-result {
    padding: 6px 12px;
    font-family: "SF Mono", Consolas, "Courier New", monospace;
    font-size: 12px;
    color: var(--text-dim);
    white-space: pre-wrap; word-break: break-all;
    max-height: 200px;
    overflow-y: auto;
}

/* 思考过程折叠块（默认收起，点击展开查看推理） */
.thinking-card {
    margin: 8px 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-panel);
    overflow: hidden;
    font-size: 13px;
}
.thinking-card summary {
    padding: 6px 12px;
    font-weight: 600; font-size: 12.5px;
    color: var(--text-dim);
    background: var(--bg-panel-2);
    cursor: pointer;
    user-select: none;
    list-style: none;
}
.thinking-card summary::-webkit-details-marker { display: none; }
.thinking-card summary::before {
    content: "▶ ";
    font-size: 10px;
}
.thinking-card[open] summary::before {
    content: "▼ ";
}
.thinking-body {
    padding: 8px 12px;
    font-size: 12px;
    line-height: 1.6;
    color: var(--text-dim);
    white-space: pre-wrap; word-break: break-word;
    max-height: 300px;
    overflow-y: auto;
    border-top: 1px solid var(--border);
}

.load-more-bar { text-align: center; padding: 8px 0; }
.load-more-bar button {
    color: var(--accent); font-size: 13px;
    padding: 6px 16px; border-radius: var(--radius-sm);
    background: var(--bg-panel); border: 1px solid var(--border);
}
.load-more-bar button:hover { background: var(--bg-hover); }

/* ========== 输入区 ========== */
#input-area {
    padding: 10px 16px 12px;
    border-top: 1px solid var(--border);
    background: var(--bg);
}
.input-inner { max-width: 860px; margin: 0 auto; }
.image-preview { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.image-preview:empty { display: none; }
.preview-item {
    position: relative; width: 74px; height: 74px;
    border-radius: var(--radius-sm); overflow: hidden;
    border: 1px solid var(--border);
}
.preview-item img { width: 100%; height: 100%; object-fit: cover; }
.preview-item .remove-btn {
    position: absolute; top: 2px; right: 2px;
    width: 20px; height: 20px;
    background: rgba(0, 0, 0, 0.65); color: #fff;
    border-radius: 50%; font-size: 13px; line-height: 1;
    display: flex; align-items: center; justify-content: center;
}
.preview-item.uploading::after {
    content: "上传中…";
    position: absolute; inset: 0;
    background: rgba(0,0,0,0.55);
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; color: #fff;
}

.input-box {
    display: flex; align-items: flex-end; gap: 8px;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 9px 10px;
    transition: border-color 0.15s;
}
.input-box:focus-within { border-color: var(--accent); }
#chat-input {
    flex: 1;
    background: transparent;
    border: none; outline: none; resize: none;
    max-height: 180px;
    line-height: 1.5;
    padding: 4px 0;
}
.btn-send {
    width: 36px; height: 36px; flex-shrink: 0;
    background: var(--accent);
    color: #fff; border-radius: 10px;
    font-size: 15px;
    display: flex; align-items: center; justify-content: center;
    transition: background 0.15s;
}
.btn-send:hover { background: var(--accent-hover); }
.btn-send.stop { background: var(--danger); }
.btn-send:disabled { opacity: 0.45; cursor: not-allowed; }
.input-hint {
    text-align: center; font-size: 11px; color: var(--text-faint);
    margin-top: 8px;
}

/* ========== 弹窗 ========== */
.modal-mask {
    position: fixed; inset: 0; z-index: 100;
    background: rgba(0, 0, 0, 0.6);
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
    animation: fadeIn 0.15s;
}
.modal-mask[hidden] { display: none; }
.modal {
    width: 400px; max-width: 100%;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 22px;
    box-shadow: var(--shadow);
    animation: popIn 0.18s;
    max-height: 84vh; overflow-y: auto;
}
.modal h3 { margin-bottom: 16px; font-size: 16px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.confirm-text { color: var(--text-dim); line-height: 1.7; }

.move-project-list { display: flex; flex-direction: column; gap: 6px; max-height: 320px; overflow-y: auto; }
.move-project-item {
    padding: 11px 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer; text-align: left;
    transition: background 0.12s;
}
.move-project-item:hover { background: var(--bg-hover); border-color: var(--accent); }
.move-project-item.current { opacity: 0.45; cursor: not-allowed; }
.move-project-item .mp-name { font-weight: 600; }
.move-project-item .mp-intro { font-size: 12px; color: var(--text-dim); margin-top: 2px; }

.conv-info-content p { margin: 8px 0; color: var(--text-dim); font-size: 13px; }
.conv-info-content p strong { color: var(--text); margin-right: 6px; }

@keyframes fadeIn { from { opacity: 0; } }
@keyframes popIn { from { opacity: 0; transform: scale(0.95); } }

/* ========== 右键菜单 ========== */
.context-menu {
    position: fixed; z-index: 200;
    background: var(--bg-panel-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 5px;
    min-width: 150px;
    animation: popIn 0.12s;
}
.context-menu[hidden] { display: none; }
.context-menu button {
    display: flex; align-items: center; gap: 8px;
    width: 100%; text-align: left;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--text);
}
.context-menu button:hover { background: var(--bg-hover); }
.context-menu button.danger { color: var(--danger); }
.context-menu .divider { height: 1px; background: var(--border); margin: 4px 6px; }

/* ========== 灯箱 ========== */
#lightbox {
    position: fixed; inset: 0; z-index: 300;
    background: rgba(0, 0, 0, 0.88);
    display: flex; align-items: center; justify-content: center;
    cursor: zoom-out;
}
#lightbox[hidden] { display: none; }
#lightbox img { max-width: 92vw; max-height: 92vh; border-radius: 6px; }

/* ========== Toast ========== */
#toast-wrap {
    position: fixed; top: 18px; left: 50%; transform: translateX(-50%);
    z-index: 400;
    display: flex; flex-direction: column; gap: 8px; align-items: center;
    pointer-events: none;
}
.toast {
    background: var(--bg-panel-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 20px;
    font-size: 13px;
    box-shadow: var(--shadow);
    animation: toastIn 0.2s;
    max-width: 80vw;
}
.toast.error { border-color: var(--danger); color: var(--danger); }
.toast.success { border-color: var(--success); color: var(--success); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-10px); } }

/* ========== 列宽拖拽缩放（桌面端） ========== */
#conv-bar { position: relative; }
.col-resizer {
    position: absolute; top: 0; bottom: 0; right: -3px;
    width: 7px;
    cursor: col-resize;
    z-index: 5;
    touch-action: none;
}
.col-resizer:hover { background: rgba(79, 140, 255, 0.35); }
body.resizing-col { cursor: col-resize; user-select: none; }
body.resizing-col .col-resizer { background: var(--accent); }

/* ========== 输入框上方工具行 ========== */
.composer-tools {
    display: flex;
    align-items: center;
    gap: 6px;
    max-width: 860px;
    margin: 0 auto 8px;
    flex-wrap: wrap;
}
.tool-mini-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: var(--text-dim);
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 4px 10px;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
    position: relative;
}
.tool-mini-btn:hover { color: var(--text); border-color: var(--accent); background: var(--bg-panel-2); }
.tool-mini-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.tool-mini-btn.active { color: var(--accent); border-color: var(--accent); }

/* 上下文弹层（挂在按钮上，向上弹出） */
.ctx-pop {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 0;
    z-index: 60;
    width: 240px;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 12px;
    text-align: left;
    cursor: default;
}
.ctx-pop .ctx-row { display: flex; align-items: center; justify-content: space-between; font-size: 13px; }
.ctx-pop input[type="number"] {
    width: 76px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 6px 8px;
    outline: none;
}
.ctx-pop input[type="number"]:focus { border-color: var(--accent); }
.ctx-pop .ctx-actions { display: flex; justify-content: space-between; margin-top: 10px; gap: 8px; }
.ctx-pop .ctx-note { font-size: 12px; color: var(--text-faint); margin-top: 8px; line-height: 1.5; }

/* ========== 工具开关弹窗 ========== */
/* hidden 属性保护：防止 display 声明覆盖 hidden（修复工具弹窗无法隐藏） */
[hidden] { display: none !important; }

.tools-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 90;
    animation: fadeIn 0.15s;
}
.tools-pop {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(520px, 92vw);
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    z-index: 91;
    animation: fadeIn 0.15s;
}
.tools-pop-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
}
.tools-pop-close { color: var(--text-dim); font-size: 15px; width: 28px; height: 28px; border-radius: 6px; }
.tools-pop-close:hover { background: var(--bg-hover); color: var(--text); }
.tools-pop-body { overflow-y: auto; padding: 14px 16px; }
.tools-group { margin-bottom: 14px; }
.tools-group-title { font-size: 12px; color: var(--text-faint); margin-bottom: 8px; }
.tools-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 8px; }
.tool-btn {
    font-size: 13px;
    padding: 8px 6px;
    border-radius: var(--radius-sm);
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text-dim);
    text-align: center;
    transition: all 0.15s;
    user-select: none;
}
.tool-btn:hover { border-color: var(--text-faint); }
.tool-btn.on {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--accent);
    font-weight: 600;
}
.tools-pop-foot { padding: 12px 16px; border-top: 1px solid var(--border); text-align: right; }

/* ========== 消息用量行 ========== */
.usage-line {
    font-size: 11.5px;
    color: var(--text-faint);
    margin-top: 6px;
    line-height: 1.6;
    user-select: text;
}

@media (max-width: 900px) {
    .composer-tools { gap: 5px; }
    .tool-mini-btn { font-size: 12px; padding: 4px 8px; }
    .tools-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 900px) {
    .app-view {
        grid-template-columns: 1fr;
        grid-template-rows: var(--mobile-bar-h) 1fr;
        grid-template-areas: "mobilebar" "chat";
    }
    #mobile-bar {
        display: flex;
        grid-area: mobilebar;
        align-items: center; justify-content: space-between;
        padding: 0 10px;
        background: var(--bg-panel);
        border-bottom: 1px solid var(--border);
    }
    #mobile-title { font-weight: 700; font-size: 15px; }
    .mobile-only { display: inline-flex !important; }

    #conv-bar {
        position: fixed;
        top: var(--mobile-bar-h); bottom: 0;
        left: 0; width: min(82vw, 320px);
        z-index: 50;
        transform: translateX(-105%);
        box-shadow: var(--shadow);
        background: var(--bg-panel);
        transition: transform 0.22s ease;
    }
    body.show-convs #conv-bar { transform: translateX(0); }

    /* 抽屉遮罩：真实元素，点击收起抽屉 */
    body.drawer-open #mobile-mask {
        display: block;
        position: fixed; inset: var(--mobile-bar-h) 0 0 0;
        background: rgba(0, 0, 0, 0.45);
        z-index: 49;
        animation: fadeIn 0.2s;
    }

    /* 拖拽手柄手机上没用，藏起来 */
    .col-resizer { display: none; }

    #chat-header { padding: 8px 10px; gap: 6px; }
    #chat-title { font-size: 13px; }
    #model-select { max-width: 130px; font-size: 12px; padding: 6px 8px; }
    .msg-container { padding: 0 12px; }
    #input-area { padding: 8px 10px calc(10px + env(safe-area-inset-bottom)); }
    /* iOS 聚焦字号小于 16px 的输入框会自动放大页面，统一提到 16px */
    #chat-input, .form-group input, .form-group textarea { font-size: 16px; }
    .input-hint { margin-top: 6px; }

    /* 小屏消息和欢迎页收一收 */
    .message { padding: 12px 0; }
    .message.user .message-body { max-width: 88%; }
    .message-content { font-size: 14px; }
    .welcome { margin-top: 4vh; }
    .welcome h2 { font-size: 22px; }
    .modal { padding: 18px; }
    .toast { max-width: 90vw; }
}

/* ========================================================= */
/* SVG 图标基础样式（替代 emoji）                              */
/* ========================================================= */
.ic {
    width: 16px; height: 16px;
    flex: 0 0 auto;
    display: inline-block;
    vertical-align: -3px;
}
.logo { display: flex; align-items: center; gap: 7px; }
.logo .ic { width: 19px; height: 19px; color: var(--accent); }
.btn-icon { display: inline-flex; align-items: center; justify-content: center; }
.btn-icon .ic { width: 17px; height: 17px; }
.welcome-logo { display: flex; justify-content: center; }
.welcome-logo .ic { width: 58px; height: 58px; color: var(--accent); stroke-width: 1.6; }
.login-logo { display: flex; justify-content: center; margin-bottom: 8px; }
.login-logo .ic { width: 44px; height: 44px; color: var(--accent); stroke-width: 1.6; }
.welcome-tips .tip { display: flex; align-items: center; justify-content: center; gap: 7px; }
.welcome-tips .ic { width: 15px; height: 15px; color: var(--text-dim); }
.pin-flag { display: inline-flex; }
.pin-flag .ic { width: 12px; height: 12px; }
.item-more .ic { width: 15px; height: 15px; }
.tool-mini-btn { display: inline-flex; align-items: center; gap: 5px; }
.tool-mini-btn .ic { width: 14px; height: 14px; }
.btn-send { display: flex; align-items: center; justify-content: center; }
.btn-send .ic { width: 18px; height: 18px; }
.tools-pop-close .ic { width: 16px; height: 16px; }
.context-menu button span:first-child { display: inline-flex; }
.context-menu .ic { width: 15px; height: 15px; }

/* ========================================================= */
/* 用户中心弹窗                                               */
/* ========================================================= */
.user-modal { width: min(640px, 100%); }
.user-modal-head {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 14px;
}
.user-modal-head h3 { font-size: 16px; margin: 0; }
.user-tabs {
    display: flex; gap: 4px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 16px;
    overflow-x: auto;
}
.user-tab {
    padding: 9px 14px;
    font-size: 13px;
    color: var(--text-dim);
    border-bottom: 2px solid transparent;
    white-space: nowrap;
    transition: color 0.15s;
}
.user-tab:hover { color: var(--text); }
.user-tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.user-tab-body { min-height: 300px; }
.utab { display: none; }
.utab.active { display: block; }

/* 概览页 */
.uc-balance-card {
    display: flex; align-items: center; gap: 16px;
    background: linear-gradient(135deg, rgba(79,140,255,0.14), rgba(79,140,255,0.04));
    border: 1px solid rgba(79,140,255,0.3);
    border-radius: var(--radius);
    padding: 18px 20px;
    margin-bottom: 14px;
}
.uc-balance-label { font-size: 12px; color: var(--text-dim); margin-bottom: 4px; }
.uc-balance-value { font-size: 28px; font-weight: 700; flex: 1; }
.uc-balance-card .btn-primary { display: inline-flex; align-items: center; gap: 6px; }
.uc-balance-card .ic { width: 15px; height: 15px; }
.uc-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 16px; }
.uc-stat {
    background: var(--bg-panel-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px;
    text-align: center;
}
.uc-stat-v { font-size: 17px; font-weight: 700; }
.uc-stat-k { font-size: 11px; color: var(--text-faint); margin-top: 3px; }
.uc-section-title {
    font-size: 12px; color: var(--text-faint);
    margin: 14px 0 8px; letter-spacing: 1px;
}
.uc-section-head {
    display: flex; align-items: center; justify-content: space-between;
    gap: 10px; margin-bottom: 12px; font-size: 12px; color: var(--text-dim);
}
.uc-section-head .btn-primary { display: inline-flex; align-items: center; gap: 4px; flex: 0 0 auto; }
.uc-section-head .ic { width: 13px; height: 13px; }

/* 余额记录条目（概览简版 + 完整列表共用） */
.log-item {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 6px;
    background: var(--bg-panel-2);
}
.log-main { min-width: 0; }
.log-type { font-size: 13px; font-weight: 500; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.log-note { font-size: 11px; color: var(--text-faint); font-weight: 400; }
.log-time { font-size: 11px; color: var(--text-faint); margin-top: 2px; }
.log-amount { font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.log-amount.plus { color: var(--success); }
.log-amount.minus { color: var(--danger); }
.uc-mini-logs { max-height: 240px; overflow-y: auto; }
.uc-log-list { max-height: 340px; overflow-y: auto; margin-bottom: 10px; }
.uc-log-pager { display: flex; align-items: center; justify-content: center; gap: 12px; }
.uc-log-pager .page-info { font-size: 12px; color: var(--text-dim); }

/* 密钥列表 */
.key-result {
    background: rgba(62, 207, 142, 0.08);
    border: 1px solid rgba(62, 207, 142, 0.4);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    margin-bottom: 12px;
}
.key-result-tip { font-size: 12px; color: var(--success); margin-bottom: 8px; display: flex; align-items: center; gap: 6px; }
.key-result-tip .ic { width: 14px; height: 14px; }
.key-result-row { display: flex; align-items: center; gap: 8px; }
.key-result-row code {
    flex: 1; min-width: 0;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px; word-break: break-all;
    background: var(--bg); border-radius: 4px; padding: 7px 9px;
    user-select: all;
}
.key-result-row .btn-sm { display: inline-flex; align-items: center; gap: 4px; flex: 0 0 auto; }
.key-result-row .ic { width: 13px; height: 13px; }
.key-item {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    background: var(--bg-panel-2);
}
.key-main { min-width: 0; }
.key-name { font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.key-name .ic { width: 14px; height: 14px; color: var(--accent); }
.key-meta { font-size: 11px; color: var(--text-faint); margin-top: 3px; }
.key-actions { display: flex; gap: 6px; flex: 0 0 auto; }

/* 个人资料 */
.uc-info-rows { border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.uc-row {
    display: flex; justify-content: space-between; gap: 10px;
    padding: 9px 12px; font-size: 13px;
    background: var(--bg-panel-2);
}
.uc-row + .uc-row { border-top: 1px solid var(--border); }
.uc-row span { color: var(--text-dim); }
.uc-form { display: flex; flex-direction: column; gap: 4px; max-width: 380px; }
.uc-form .btn-primary { align-self: flex-start; }

/* ========================================================= */
/* 充值弹窗                                                   */
/* ========================================================= */
.recharge-modal { width: min(520px, 100%); }
.recharge-notice {
    background: var(--accent-soft, rgba(64,128,255,.08));
    border: 1px solid var(--accent-soft, rgba(64,128,255,.25));
    color: var(--text-main);
    border-radius: 10px;
    padding: 10px 12px;
    margin-bottom: 14px;
    font-size: 13px;
    line-height: 1.6;
    white-space: pre-line;
}
.amount-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 10px;
    margin-bottom: 14px;
}
.amount-item {
    position: relative;
    background: var(--bg-panel-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 10px;
    text-align: center;
    transition: border-color 0.15s, background 0.15s;
}
.amount-item:hover { border-color: var(--accent); }
.amount-item.selected {
    border-color: var(--accent);
    background: var(--accent-soft);
}
.amount-credit { font-size: 17px; font-weight: 700; }
.amount-pay { font-size: 12px; color: var(--text-dim); margin-top: 3px; }
.amount-rate { font-size: 11px; color: var(--warning); margin-top: 3px; min-height: 14px; }
.recharge-summary {
    font-size: 13px; color: var(--text-dim);
    min-height: 22px;
    margin-bottom: 6px;
}
.recharge-summary b { color: var(--text); }
.qr-wrap { text-align: center; padding: 12px 0; }
.qr-canvas {
    display: inline-block;
    background: #fff;
    border-radius: 10px;
    padding: 14px;
    line-height: 0;
}
.qr-canvas svg { width: 210px; height: 210px; }
.qr-fallback { max-width: 240px; word-break: break-all; font-size: 12px; line-height: 1.5; color: #333; }
.qr-amount { margin-top: 10px; font-size: 14px; font-weight: 600; }
.qr-tip { text-align: center; font-size: 12px; color: var(--text-dim); margin: 8px 0 12px; }

@media (max-width: 600px) {
    .user-modal, .recharge-modal { padding: 16px; }
    .uc-stats { grid-template-columns: repeat(3, 1fr); gap: 6px; }
    .uc-stat { padding: 9px 6px; }
    .uc-balance-value { font-size: 22px; }
    .amount-grid { grid-template-columns: repeat(2, 1fr); }
    .key-item { flex-direction: column; align-items: stretch; }
    .key-actions { justify-content: flex-end; }
}

/* ---------- 注册表单 ---------- */
.ok-msg { color: var(--ok, #16a34a); font-size: 13px; margin-top: 10px; }
.reg-code-row { display: flex; gap: 8px; }
.reg-code-row input { flex: 1; }
.btn-send-code { flex: 0 0 auto; white-space: nowrap; padding: 0 12px; font-size: 13px; }
.btn-send-code:disabled { opacity: 0.6; cursor: not-allowed; }
.reg-agree {
    display: flex; align-items: flex-start; gap: 6px;
    font-size: 12px; color: var(--text-dim); margin: 4px 0 12px; line-height: 1.5;
}
.reg-agree input { margin-top: 3px; }
.reg-agree a { color: var(--accent); text-decoration: none; }
.reg-agree a:hover { text-decoration: underline; }
.auth-switch { font-size: 13px; color: var(--text-dim); margin-top: 14px; text-align: center; }
.auth-switch a { color: var(--accent); text-decoration: none; font-weight: 600; }
.auth-switch a:hover { text-decoration: underline; }

/* 消息收藏按钮（悬停 AI 回答显示，☆ 收藏 / ★ 已收藏） */
.msg-fav-btn {
    display: inline-block;
    margin: 8px 0 0;
    font-size: 13px;
    padding: 2px 10px;
    border-radius: 10px;
    background: var(--bg, #14161a);
    border: 1px solid var(--border, #2a2d33);
    color: var(--text-faint, #6b7280);
    cursor: pointer;
    line-height: 1.5;
    opacity: 0;
    transition: opacity 0.15s;
}
.message.assistant:hover .msg-fav-btn { opacity: 1; }
.msg-fav-btn:hover { color: var(--accent); border-color: var(--accent); }
.msg-fav-btn.on { color: #f5a623; border-color: #f5a623; opacity: 1; }
.msg-fav-btn.on:hover { color: #e09000; }

/* 管理员代登横幅：以用户身份登入时顶部吸顶提示，点击一键切回管理员 */
#impersonate-banner {
    position: sticky; top: 0; z-index: 1200;
    display: flex; align-items: center; justify-content: center; gap: 12px;
    padding: 8px 16px; font-size: 13px; color: #fff;
    background: linear-gradient(90deg, #1e3a5f, #2563eb); box-shadow: 0 1px 6px rgba(0,0,0,.25);
}
#impersonate-banner button {
    border: 1px solid rgba(255,255,255,.6); background: rgba(255,255,255,.16);
    color: #fff; padding: 4px 14px; border-radius: 999px; font-size: 13px; cursor: pointer;
}
#impersonate-banner button:hover { background: rgba(255,255,255,.3); }

/* ========== 工作进度弹窗（WORKSTATE 快照渲染） ========== */
.ws-md { max-height: 60vh; overflow: auto; font-size: 13px; line-height: 1.7; color: var(--text-dim); }
.ws-md h1, .ws-md h2 { margin: 12px 0 6px; font-size: 15px; color: var(--text); }
.ws-md h3 { margin: 10px 0 4px; font-size: 13.5px; color: var(--text); }
.ws-md ul, .ws-md ol { padding-left: 20px; margin: 4px 0; }
.ws-md li { margin: 2px 0; }
.ws-md strong { color: var(--text); }
.ws-md code { background: var(--bg-soft, rgba(127,127,127,.15)); padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.ws-md hr { border: none; border-top: 1px solid var(--border, rgba(127,127,127,.25)); margin: 10px 0; }

/* 全局确认/输入弹窗永远压在其他弹窗之上（DOM 在前，需显式提升 z-index） */
#confirm-modal, #prompt-modal { z-index: 120; }

/* ========== 进度同步：可选对话列表 ========== */
.ws-sync-empty { padding: 14px 0; color: var(--text-dim, #8b93a5); font-size: 13px; }
.ws-sync-list { max-height: 46vh; overflow: auto; }
.ws-sync-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 0; border-top: 1px solid var(--border, rgba(127,127,127,.2)); }
.ws-sync-item:first-child { border-top: none; }
.ws-sync-info { min-width: 0; font-size: 13px; overflow: hidden; text-overflow: ellipsis; }
.ws-sync-meta { font-size: 12px; opacity: .6; margin-top: 2px; }
.ws-sync-item .btn-primary { flex: none; padding: 5px 12px; font-size: 12px; }

/* ========== 引用回复 + 提示音 ========== */
.quote-bar {
    display: flex; align-items: center; gap: 8px;
    margin: 0 0 6px; padding: 6px 10px;
    border-left: 3px solid var(--accent, #4f8cff);
    background: rgba(127,127,127,.08);
    border-radius: 6px;
    font-size: 12px; color: var(--text-dim, #8b93a5);
}
.quote-bar-label { flex: none; font-weight: 600; }
#quote-bar-text { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#quote-bar-close {
    flex: none; background: none; border: none; color: inherit;
    cursor: pointer; font-size: 16px; line-height: 1; padding: 0 2px;
}
#quote-bar-close:hover { color: var(--text, #e7eaf0); }
.msg-quote-btn {
    position: absolute;
    right: 8px;
    bottom: 2px;
    margin: 0;
    font-size: 12px;
    padding: 1px 9px;
    border-radius: 10px;
    background: var(--bg, #14161a);
    border: 1px solid var(--border, #2a2d33);
    color: var(--text-faint, #6b7280);
    cursor: pointer;
    line-height: 1.5;
    opacity: 0;
    transition: opacity 0.15s;
}
.message:hover .msg-quote-btn { opacity: 1; }
.msg-quote-btn:hover { color: var(--accent, #4f8cff); border-color: var(--accent, #4f8cff); }
.quote-bar[hidden] { display: none; } /* 防止 display:flex 覆盖 hidden 属性导致空引用条常驻 */
blockquote.msg-quote, .message-content blockquote {
    margin: 6px 0; padding: 4px 10px;
    border-left: 3px solid var(--accent, #4f8cff);
    background: rgba(127,127,127,.08);
    border-radius: 4px;
    color: var(--text-dim, #8b93a5);
    font-size: 12.5px;
}
.tool-mini-btn.off { opacity: .45; }

/* 顶栏提示音按钮：窄屏只留图标 */
@media (max-width: 760px) {
    #btn-sound .btn-label { display: none; }
    #btn-sound { padding: 4px 8px; }
}

/* 上下文占用环形进度（顶栏提示音旁）：圆环为进度条，中心显示百分比整数 */
.ctx-ring { position: relative; width: 34px; height: 34px; flex: 0 0 auto; margin: 0 6px; }
.ctx-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); display: block; }
.ctx-ring-bg { stroke: rgba(120, 130, 160, .25); }
.ctx-ring-fg { stroke: var(--accent, #4f8cff); transition: stroke-dasharray .3s ease, stroke .3s ease; }
.ctx-ring.warn .ctx-ring-fg { stroke: #f5a623; }
.ctx-ring.danger .ctx-ring-fg { stroke: #e5484d; }
.ctx-ring-num {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 11px; font-weight: 600; line-height: 1;
    color: var(--text, #22263a);
}

/* 进度快照分区：AI 快照（结论）在上，运行流水（过程）在下，可各自处理 */
.ws-sec { margin-top: 12px; }
.ws-sec:first-of-type { margin-top: 2px; }
.ws-sec-title { display: flex; align-items: center; gap: 8px; margin: 0 0 6px;
    font-size: 12px; font-weight: 600; color: var(--text-dim); }
.ws-sec-body { border-top: 1px solid var(--border); padding-top: 8px; }
.ws-sec-body > blockquote { margin: 4px 0; }
.ws-sec-empty { padding: 8px 10px; border: 1px dashed var(--border); border-radius: 8px;
    font-size: 12.5px; color: var(--text-dim); opacity: .75; }

/* ========================================================= */
/* 充值弹窗：页签 + 套餐订阅                                  */
/* ========================================================= */
.recharge-tabs { display: flex; gap: 6px; margin-bottom: 14px;
    border-bottom: 1px solid var(--border); }
.recharge-tab {
    appearance: none; background: transparent; border: 0;
    border-bottom: 2px solid transparent; margin-bottom: -1px;
    padding: 8px 12px; font-size: 14px; color: var(--text-dim); cursor: pointer;
}
.recharge-tab:hover { color: var(--text); }
.recharge-tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

.plan-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 10px; margin-bottom: 14px; max-height: 320px; overflow-y: auto; }
.plan-item {
    appearance: none; text-align: left; cursor: pointer;
    background: var(--bg-panel-2); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 12px;
    transition: border-color 0.15s, background 0.15s;
}
.plan-item:hover { border-color: var(--accent); }
.plan-item.selected { border-color: var(--accent); background: var(--accent-soft); }
.plan-name { font-size: 15px; font-weight: 700; margin-bottom: 4px; }
.plan-models { font-size: 12px; color: var(--text-dim); line-height: 1.5; margin-bottom: 6px;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.plan-meta { font-size: 12px; color: var(--text-dim); }
.plan-rates { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.plan-price { margin-top: 6px; font-size: 16px; font-weight: 700; color: var(--accent); }
.plan-empty { grid-column: 1 / -1; text-align: center; color: var(--text-faint);
    font-size: 13px; padding: 24px 0; }
/* 兑换码支付下套餐禁用态：置灰但保留点击提示 */
.plan-grid-off { opacity: 0.45; }
.plan-grid-off .plan-item { cursor: not-allowed; }
.plan-grid-off .plan-item:hover { border-color: var(--border); }

/* 兑换码信息提示条 */
.redeem-info { margin-top: 8px; font-size: 12px; line-height: 1.6; padding: 8px 12px;
    border-radius: var(--radius-sm); }
.redeem-info-ok { color: var(--text-dim); background: var(--bg-panel-2); border: 1px solid var(--border); }
.redeem-info-err { color: var(--danger); background: var(--bg-panel-2); border: 1px solid var(--danger); }

.pay-methods { display: flex; gap: 8px; flex-wrap: wrap; }
.pay-method {
    appearance: none; cursor: pointer; padding: 7px 14px; font-size: 13px;
    background: var(--bg-panel-2); border: 1px solid var(--border);
    border-radius: var(--radius-sm); color: var(--text-dim);
}
.pay-method:hover { border-color: var(--accent); }
.pay-method.active { border-color: var(--accent); background: var(--accent-soft); color: var(--text); font-weight: 600; }

/* ========================================================= */
/* 个人中心：折叠卡片 + 我的订阅                              */
/* ========================================================= */
.pg-card-head.collapsible { cursor: pointer; user-select: none; }
.pg-card-head.collapsible::after {
    content: '›'; margin-left: auto; font-size: 18px; line-height: 1;
    color: var(--text-dim); transition: transform 0.15s;
}
.pg-card:not(.collapsed) > .pg-card-head.collapsible::after { transform: rotate(90deg); }
.pg-card.collapsed > .pg-card-body { display: none; }

.sub-item { border: 1px solid var(--border); border-radius: var(--radius-sm);
    padding: 12px; margin-bottom: 10px; background: var(--bg-panel-2); }
.sub-item:last-child { margin-bottom: 0; }
.sub-item-top { display: flex; align-items: center; justify-content: space-between;
    gap: 8px; margin-bottom: 6px; }
.sub-item-top b { font-size: 14px; }
.sub-item-top-right { display: flex; align-items: center; gap: 8px; flex: none; }
.sub-item-top-right .pg-btn-sm { padding: 3px 10px; font-size: 12px; }
.sub-state { font-size: 12px; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.sub-state-ok { color: var(--ok, #16a34a); background: rgba(22, 163, 74, .12); }
.sub-state-warn { color: var(--warning, #f5a623); background: rgba(245, 166, 35, .12); }
.sub-state-dim { color: var(--text-dim); background: rgba(120, 130, 160, .12); }
.sub-item-line { font-size: 12.5px; color: var(--text); line-height: 1.7; word-break: break-all; }
.sub-item-line.dim { color: var(--text-dim); }
.sub-item-ops { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 8px;
    padding-top: 8px; border-top: 1px dashed var(--border); }
.sub-item-ops label { font-size: 12.5px; color: var(--text-dim);
    display: flex; align-items: center; gap: 6px; }
.sub-item-ops select { font-size: 12.5px; padding: 3px 6px; background: var(--bg);
    color: var(--text); border: 1px solid var(--border); border-radius: var(--radius-sm);
    outline: none; cursor: pointer; }
.sub-item-ops select:focus { border-color: var(--accent); }
.sub-item-ops select option { background: var(--bg); color: var(--text); }
.sub-empty-link { color: var(--primary, #4f7cff); text-decoration: none; font-size: 13px;
    border-bottom: 1px dashed currentColor; cursor: pointer; }
.sub-empty-link:hover { opacity: .8; }
