/* ==========================================================================
   主题令牌层 —— 所有颜色只在此处定义，组件规则一律引用变量。
   切主题 = 换 <html data-theme="…">，组件样式一行不动。
   由 .workbuddy/tools/tokenize_css.py 生成，手改请同步该脚本的映射表。
   ========================================================================== */

/* ── 天蓝简约（浅色 · 干净留白 · 默认） ── */
:root,
[data-theme="sky"] {
    --color-bg:                  #F4F9FD;
    --color-surface:             #FFFFFF;
    --color-surface-2:           #FBFDFF;
    --color-surface-3:           #EEF5FB;
    --color-text:                #1B2A38;
    --color-muted:               #5A6B7B;
    --color-faint:               #95A6B6;
    --color-border:              #E4EEF6;
    --color-border-strong:       #C7DAEA;
    --color-accent:              #2E79C0;
    --color-accent-hover:        #2568A8;
    --color-accent-soft:         #E3F0FB;
    --color-accent-tint:         #F2F8FD;
    --color-accent-line:         #ADCCE9;
    --color-on-accent:           #FFFFFF;
    --color-success:             #2E9E6B;
    --color-success-soft:        #E4F6ED;
    --color-success-solid:       #2E9E6B;
    --color-info:                #1F6F8B;
    --color-info-soft:           #E0F0F7;
    --color-warning:             #8A5300;
    --color-warning-soft:        #F3EEDB;
    --color-danger:              #B3261E;
    --color-danger-soft:         #F5E3E2;
    --color-danger-solid:        #C0392B;
    --color-on-danger:           #FFFFFF;
    --accent-rgb:                46, 121, 192;
    --shadow-rgb:                30,70,110;
    --glow-1:                    rgba(46, 121, 192, .08);
    --glow-2:                    rgba(43, 163, 214, .06);
    --noise:                     .04;
    --select-arrow:              url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%235A6B7B' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    color-scheme:                light;
}

/* ── 深空工业（暗色 · 长时间盯屏） ── */
[data-theme="dark"] {
    --color-bg:                  #0F1620;
    --color-surface:             #16202C;
    --color-surface-2:           #131C27;
    --color-surface-3:           #1B2836;
    --color-text:                #EAF2FA;
    --color-muted:               #93A7BC;
    --color-faint:               #5E748A;
    --color-border:              #2A3A4C;
    --color-border-strong:       #3B4F63;
    --color-accent:              #4FA6E8;
    --color-accent-hover:        #66B4EE;
    --color-accent-soft:         #143247;
    --color-accent-tint:         #152838;
    --color-accent-line:         #265577;
    --color-on-accent:           #08182A;
    --color-success:             #4FBF8A;
    --color-success-soft:        #173326;
    --color-success-solid:       #4FBF8A;
    --color-info:                #57C7E8;
    --color-info-soft:           #123340;
    --color-warning:             #E4B558;
    --color-warning-soft:        #3C3622;
    --color-danger:              #E56A57;
    --color-danger-soft:         #372C33;
    --color-danger-solid:        #7A2A20;
    --color-on-danger:           #FFFFFF;
    --accent-rgb:                79, 166, 232;
    --shadow-rgb:                0,0,0;
    --glow-1:                    rgba(79, 166, 232, .12);
    --glow-2:                    rgba(87, 199, 232, .08);
    --noise:                     .03;
    --select-arrow:              url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%2393A7BC' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    color-scheme:                dark;
}

/* ── 与配色无关的公共令牌 ── */
:root {
    /* 纯系统字体栈：不依赖任何在线/外部字体文件，离线、内网、无外网部署都一致 */
    /* 西文字体在前、中文字体在后，避免西文被中文字形接管（项目铁律） */
    --font-display: system-ui, -apple-system, "Segoe UI", Roboto,
                    "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", sans-serif;
    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial,
                 "PingFang SC", "HarmonyOS Sans SC", "Source Han Sans SC", "Microsoft YaHei", sans-serif;
    --font-mono: ui-monospace, "SFMono-Regular", "Cascadia Mono", "JetBrains Mono", Consolas, monospace;
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}
/* ── 展示字（system-ui）：用于主要标题，正文仍走 --font-sans ── */
.nav-brand, .list-head h2, .detail-header h2, .page-header h1, .split-left .page-header h1 {
    font-family: var(--font-display); letter-spacing: -0.01em;
}
/* ==========================================================================
   以下为组件规则：颜色一律引用上方令牌
   ========================================================================== */

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

body {
    font-family: var(--font-sans);
    /* 氛围层：底色 + 两束低透明散射，替掉原来的纯色平铺 */
    background-color: var(--color-bg);
    background-image:
        radial-gradient(1200px 620px at 10% -10%, var(--glow-1), transparent 62%),
        radial-gradient(1000px 520px at 94% 2%, var(--glow-2), transparent 58%);
    background-attachment: fixed;
    background-repeat: no-repeat;
    color: var(--color-text);
    line-height: 1.6;
}

/* Navbar */
.navbar {
    background: var(--color-surface);
    box-shadow: 0 2px 4px rgba(var(--shadow-rgb), 0.08);
    padding: 0 24px;
    display: flex;
    align-items: center;
    /* 这里**不能**开 flex-wrap：导航整行换行会把「配色」开关单独甩到第二行。
       窗口窄时只让链接区自己内部换行（见 .nav-links），右侧用户区/配色开关始终在同一行。
       高度用 min-height 而不是固定 height —— 链接折成两行时要把第二行显示出来。 */
    min-height: 56px;
}

.nav-brand {
    font-size: 18px;
    font-weight: 600;
    color: var(--color-accent);
    /* 右侧用户区是 flex-shrink:0，收缩压力全落在链接上；品牌名不参与收缩也不折行 */
    margin-right: 20px;
    flex: 0 0 auto;
    white-space: nowrap;
}

/* 链接区是会变窄的那一段（右侧用户区/配色开关都不缩）。
   装不下时**整条链接**折到下一行 —— 不能让它横向滚动：滚动条是隐藏的，
   被推到视野外的「邮箱账号」「用户管理」就点不到了（窗口 1024 时正好会这样）。
   也绝不能让中文标签在链接**内部**折字：那样链接会从 42px 高变成 67px，把导航撑变形。 */
.nav-links {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    flex: 1 1 auto;
    min-width: 0;
}

.nav-link {
    padding: 8px 14px;
    text-decoration: none;
    color: var(--color-muted);
    border-radius: 6px;
    transition: all 0.2s;
    white-space: nowrap;
    flex: 0 0 auto;
}

.nav-link:hover {
    background: var(--color-accent-soft);
    color: var(--color-accent);
}

/* Container */
.container {
    max-width: 100%;
    margin: 0;
    padding: 0;
}

/* Split Layout */
.split-layout {
    display: flex;
    height: calc(100vh - 56px);
    overflow: hidden;
}

.split-left {
    width: 340px;
    min-width: 340px;
    border-right: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.split-left .page-header {
    padding: 16px;
    margin-bottom: 0;
    border-bottom: 1px solid var(--color-border);
    flex-shrink: 0;
}

.split-left .page-header h1 {
    font-size: 18px;
    margin-bottom: 8px;
}

.conversation-list {
    flex: 1;
    overflow-y: auto;
}

/* 滚动加载的列表尾注：加载中 / 已显示 N/M / 已加载全部 */
.list-footer {
    text-align: center;
    font-size: 12px;
    color: var(--color-muted);
    padding: 10px 0 14px;
    user-select: none;
}

.conv-item {
    padding: 12px 16px;
    border-bottom: 1px solid var(--color-border);
    cursor: pointer;
    transition: background 0.15s, transform 0.16s cubic-bezier(0.16, 1, 0.3, 1);
}

.conv-item:hover {
    background: var(--color-bg);
    transform: translateX(2px);
}

.conv-item.active {
    background: var(--color-accent-soft);
    border-left: 3px solid var(--color-accent);
}

.conv-item.unread {
    border-left: 3px solid var(--color-accent);
}

.conv-item.unread .conv-item-subject {
    font-weight: 600;
    color: var(--color-accent);
}

.unread-dot {
    width: 8px;
    height: 8px;
    background: var(--color-accent);
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.unread-badge {
    background: var(--color-accent);
    color: var(--color-on-accent);
    font-size: 11px;
    padding: 1px 6px;
    border-radius: 10px;
    margin-left: 4px;
}

/* 垃圾邮件标记（与 reply-badge 同款胶囊，视觉量级保持一致）：
   「含垃圾」= 中性淡字，只是告知会话里有被服务器判垃圾的邮件；
   「已知客户」= 琥珀警示，提示可能是误判、需要人工去垃圾视图确认 */
.junk-chip {
    flex: none;
    font-size: 11px;
    line-height: 1.6;
    padding: 1px 6px;
    border-radius: 10px;
    white-space: nowrap;
    background: var(--color-surface-3);
    color: var(--color-muted);
}

.junk-customer-chip {
    flex: none;
    font-size: 11px;
    line-height: 1.6;
    padding: 1px 6px;
    border-radius: 10px;
    white-space: nowrap;
    background: var(--color-warning-soft);
    color: var(--color-warning);
}

/* 会话回复状态徽章：待回复=琥珀（需要处理），已回复=绿（我方最后发言） */
.reply-badge {
    flex: none;
    font-size: 11px;
    line-height: 1.6;
    padding: 1px 6px;
    border-radius: 10px;
    white-space: nowrap;
}

.reply-pending {
    background: var(--color-warning-soft);
    color: var(--color-warning);
}

.reply-done {
    background: var(--color-success-soft);
    color: var(--color-success);
}

.conv-item-header {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 4px;
}

/* 列表项上的「会话来自哪个邮箱」。放在第一行 #id 与日期之间的空档里，
 * 不占用客户邮箱/未读/风险徽章的位置；margin-right:auto 让它贴着 #id、日期仍然靠右。
 * 无框淡字、**整串同色**（与详情会话头 `.mb-quiet` 一致）：靠更淡的颜色跟 `#id`/日期拉开层级。
 * 别在地址内部再按「本地名/域名」调明度 —— 本系统本地名高度重复（一堆 support@），
 * 区分点全在 @ 之后，压淡域名等于把唯一有辨识度的那半段压掉（侧栏「域名优先省略」同理）。
 * ⚠️ 自然高度必须 ≤ 第一行的行盒（`#id`/日期 12px → 19.2px），否则会顶高整个会话项。
 * 真机量过：shots/check_mb_restyle.js（零增高）、shots/check_align_header.js（基线对齐）。 */
.conv-mb {
    flex: 0 1 auto;
    min-width: 0;
    margin-right: auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    /* ⚠️ 字号**必须**与同行的 `#id`/日期（12px）一模一样，且**不要**另外钉 line-height。
     * 这一行是 flex 行，三个文本段靠 stretch 撑到同一高度，但文字落在行盒里的位置由
     * line-height 决定：行盒一旦比兄弟窄，多出来的半个行距就是肉眼可见的基线错位
     * （实测钉死 1.2 时邮箱整体比 `#id` 高 3px，用户截图反馈「有一点没对齐」）。
     * 同字号 + 都继承 body 的 1.6 ⇒ 行盒同为 19.2px，基线天然齐平，也不顶高。
     * 淡化只靠颜色/字重，不要靠缩小字号。 */
    font-size: 12px;
    color: var(--color-faint);
}

/* 信封图标。`vertical-align:-1px` 只是为了跟文字视觉对齐（svg 默认坐基线，看着偏高）。
 * ⚠️ 别以为靠它就能防顶高 —— 真机量过：`.conv-mb` 是 flex 子项，被 `align-items:stretch`
 * 撑成第一行的高度（19.2px），内容只要 ≤ 该值就顶不高，去掉这行 `vertical-align` 行高一模一样。
 * 真正决定上限的是上面的字号 / line-height。 */
.conv-mb .mail-ico {
    width: 11px;
    height: 11px;
    flex: none;
    vertical-align: -0.5px;
    margin-right: 4px;
}

.conv-mb .addr {
    font-variant-numeric: tabular-nums;
}


.conv-item-id {
    font-size: 12px;
    color: var(--color-faint);
}

.conv-item-date {
    flex: none;
    font-size: 12px;
    color: var(--color-faint);
}

.conv-item-subject {
    font-size: 14px;
    font-weight: 500;
    color: var(--color-text);
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conv-item-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--color-muted);
}

.conv-item-email {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.conv-item-count {
    color: var(--color-faint);
}

.split-right {
    flex: 1;
    overflow-y: auto;
    background: var(--color-bg);
}

.empty-hint {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--color-faint);
    font-size: 16px;
}

.detail-header {
    padding: 16px 24px;
    /* 淡蓝底：与左侧栏同一手法（强调色混 6%），头部信息区有了「面板感」也不突兀 */
    background: color-mix(in srgb, var(--color-accent) 6%, var(--color-surface));
    border-bottom: 1px solid var(--color-border);
}

.detail-header h2 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 4px;
}

/* 头部信息行。flex + wrap 是为了让末尾的邮箱能整段折行，而不是把地址从中间截断 */
.detail-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    font-size: 13px;
    color: var(--color-muted);
}

.detail-meta .meta-sep {
    color: var(--color-border-strong);
}

/* 会话涉及的邮箱（跨邮箱会话并列多个）。放在 meta 行末尾而不是另起一行：
 * 单邮箱会话能省掉一整行，头部从 5 行回落到 4 行。
 * 无框淡字 —— 实心胶囊在本系统代表「可选中」，拿来标身份会跟下面的「其他」标签糊成两块。 */
.mb-quiet {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12.5px;
    font-weight: 500;
    white-space: nowrap;
}

.mb-quiet .mail-ico {
    width: 13px;
    height: 13px;
    flex: none;
    color: var(--color-faint);
}

.mb-quiet .addr {
    font-variant-numeric: tabular-nums;
}

.detail-content {
    padding: 16px 24px;
}

/* Page Header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.page-header h1 {
    font-size: 24px;
    font-weight: 600;
}

.filter {
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter select {
    padding: 8px 12px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-size: 14px;
    background: var(--color-surface);
    cursor: pointer;
}

/* Stats Summary（仅统计页 / 搜索统计用；列表页顶部那条统计栏已删） */
.stats-overview {
    display: flex;
    gap: 24px;
    margin-bottom: 20px;
}

.stat-item {
    padding: 12px 20px;
    background: var(--color-surface);
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(var(--shadow-rgb), 0.06);
}

.stat-item strong {
    color: var(--color-accent);
}

/* Table */
.data-table {
    width: 100%;
    background: var(--color-surface);
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(var(--shadow-rgb), 0.06);
    border-collapse: collapse;
}

.data-table th, .data-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
}

.data-table th {
    background: var(--color-surface-2);
    font-weight: 600;
    font-size: 13px;
    color: var(--color-muted);
}

.data-table tr:hover {
    background: var(--color-surface-2);
}

.data-table tr.clickable {
    cursor: pointer;
}

/* Badges */
.risk-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

.risk-low { background: var(--color-success-soft); color: var(--color-success); }
.risk-medium { background: var(--color-warning-soft); color: var(--color-warning); }
.risk-high { background: var(--color-danger-soft); color: var(--color-danger); }
.risk-critical { background: var(--color-danger-solid); color: var(--color-on-danger); }

.status-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

.status-analyzed { background: var(--color-success-soft); color: var(--color-success); }
.status-pending { background: var(--color-surface-2); color: var(--color-muted); }

/* Buttons */
/* 按钮体系（全站统一胶囊语言）：主操作=实心蓝 CTA；次操作=淡调无边框；
   危险操作=淡红底红字。三级字号/内边距对齐，杜绝"描边方块+大实心"混排 */
.btn {
    padding: 7px 16px;
    border-radius: 999px;
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    border: none;
    cursor: pointer;
    transition: background 0.16s var(--ease-out), color 0.16s var(--ease-out);
}

.btn:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

.btn-back {
    background: var(--color-surface-2);
    color: var(--color-muted);
}

.btn-back:hover {
    background: var(--color-surface-3);
    color: var(--color-text);
}

.btn-back:hover {
    background: var(--color-surface-3);
}

/* Detail Layout */
.detail-layout {
    display: grid;
    grid-template-columns: 400px 1fr;
    gap: 24px;
}

@media (max-width: 900px) {
    .detail-layout {
        grid-template-columns: 1fr;
    }
}

/* Info Card */
.info-card {
    background: var(--color-surface);
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(var(--shadow-rgb), 0.06);
    padding: 20px;
    margin-bottom: 16px;
}

.info-card h3 {
    font-size: 16px;
    margin-bottom: 16px;
    color: var(--color-text);
}

.info-row {
    display: flex;
    margin-bottom: 12px;
}

.info-label {
    width: 70px;
    color: var(--color-faint);
    font-size: 14px;
}

.info-value {
    flex: 1;
    font-size: 14px;
}

/* Analysis */
.analysis-grid {
    display: grid;
    /* 窄栏自动折行，写死 1fr 1fr 在侧栏收窄时会横向溢出 */
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 12px;
    margin-bottom: 12px;
}

.analysis-item {
    display: flex;
    flex-direction: column;
}

.analysis-label {
    font-size: 12px;
    color: var(--color-faint);
    margin-bottom: 4px;
}

.analysis-value {
    font-size: 14px;
    font-weight: 500;
}

.analysis-summary {
    margin-top: 12px;
}

.analysis-summary p {
    margin-top: 4px;
    font-size: 14px;
    color: var(--color-muted);
}

.no-analysis {
    color: var(--color-faint);
    font-style: italic;
}

/* ── AI 分析卡片（按需触发）─────────────────────────────────────────────
   高度封顶是这个卡片的硬约束：AI 输出篇幅不可控，.an-body 一旦不限高，
   它就会把下面的「邮件记录」整块顶出首屏。改这里前先想清楚这一点。 */
.an-card.stale {
    /* 描边与淡底都用令牌混出来，切换主题自动跟着走（别写死 #F3EEDB 那类浅色值） */
    border-color: color-mix(in srgb, var(--color-warning) 35%, var(--color-surface));
    background: color-mix(in srgb, var(--color-warning-soft) 60%, var(--color-surface));
}

.an-head {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.an-title {
    font-size: 15px;
    font-weight: 600;
}

.an-spacer {
    flex: 1;
}

.an-badge {
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 99px;
    font-weight: 500;
}

.an-badge.ok {
    background: var(--color-success-soft);
    color: var(--color-success);
}

.an-badge.stale {
    background: var(--color-warning-soft);
    color: var(--color-warning);
}

.an-badge.none {
    background: var(--color-surface-3);
    color: var(--color-faint);
}

.an-when {
    font-size: 12px;
    color: var(--color-faint);
}

/* 过时提示：单行，不额外占高度 */
.stale-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    padding: 8px 12px;
    border-radius: 6px;
    background: var(--color-warning-soft);
    color: var(--color-warning);
    font-size: 13px;
}

.stale-bar svg {
    flex: none;
}

/* ⚠️ 高度封顶 + 内部滚动：这是「AI 结果篇幅大也不影响布局」的关键一条 */
.an-body {
    max-height: 38vh;
    overflow-y: auto;
    margin-top: 14px;
    padding-right: 4px;
}

.an-body.folded {
    display: none;
}

/* 还有内容没滚出来时给底部渐隐。不加的话最后一行正好被截在半个字上，
   看着像渲染坏了而不是「可以往下滚」。到底后由 syncAnalysisOverflow() 摘掉。 */
.an-body.has-more {
    -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 26px), transparent);
    mask-image: linear-gradient(to bottom, #000 calc(100% - 26px), transparent);
}

.an-body::-webkit-scrollbar {
    width: 8px;
}

.an-body::-webkit-scrollbar-thumb {
    background: var(--color-border-strong);
    border-radius: 4px;
}

.an-divider {
    height: 1px;
    background: var(--color-border);
    margin: 2px 0 12px;
}

/* AI 常输出分段/列表，pre-wrap 保住换行，别挤成一坨 */
.summary-body {
    margin-top: 4px;
    font-size: 14px;
    color: var(--color-muted);
    white-space: pre-wrap;
    word-break: break-word;
}

.an-foot {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--color-border);
    font-size: 12px;
    color: var(--color-faint);
}

.an-empty {
    color: var(--color-faint);
    font-size: 13px;
    line-height: 1.8;
}

.an-fold {
    font: inherit;
    background: none;
    border: none;
    color: var(--color-faint);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    padding: 4px;
}

.an-fold:hover {
    color: var(--color-accent);
}

.an-fold .chev {
    transition: transform 0.18s;
    display: inline-block;
}

.an-fold[aria-expanded="false"] .chev {
    transform: rotate(-90deg);
}

/* 分析中的骨架屏 + 不确定进度条（同步 LLM 调用拿不到真实进度，别编百分比） */
.an-skeleton {
    height: 12px;
    border-radius: 6px;
    background: linear-gradient(90deg, var(--color-surface-3),
                color-mix(in srgb, var(--color-border-strong) 70%, var(--color-surface-3)),
                var(--color-surface-3));
    background-size: 200% 100%;
    animation: an-sk 1.2s infinite;
    margin-bottom: 10px;
}

@keyframes an-sk {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.an-progress {
    height: 3px;
    background: var(--color-accent-soft);
    border-radius: 99px;
    overflow: hidden;
    margin-top: 14px;
}

.an-progress i {
    display: block;
    height: 100%;
    width: 38%;
    background: var(--color-accent);
    border-radius: 99px;
    animation: an-indet 1.4s ease-in-out infinite;
}

@keyframes an-indet {
    0%   { transform: translateX(-100%); }
    100% { transform: translateX(320%); }
}

/* 「重新分析」按钮的样式定义在文件下方的按钮变体区（.btn.btn-warn.btn-small）——
   必须放在 .btn-small 之后，否则 background 会被它盖掉。别挪回这里。 */
.btn .spin {
    width: 11px;
    height: 11px;
    border: 2px solid color-mix(in srgb, currentColor 45%, transparent);
    border-top-color: currentColor;
    border-radius: 50%;
    display: inline-block;
    vertical-align: -1px;
    animation: an-sp 0.8s linear infinite;
    margin-right: 5px;
}

@keyframes an-sp {
    to { transform: rotate(360deg); }
}

/* Email List */
.detail-emails {
    background: var(--color-surface);
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(var(--shadow-rgb), 0.06);
    padding: 20px;
}

.detail-emails h3 {
    font-size: 16px;
    margin-bottom: 16px;
    color: var(--color-text);
}

.email-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.email-item {
    border: 1px solid var(--color-border);
    border-radius: 8px;
    margin-bottom: 16px;
    overflow: hidden;
}

.email-item.incoming {
    border-left: 4px solid var(--color-accent);
}

.email-item.outgoing {
    border-left: 4px solid var(--color-success);
}

.email-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: var(--color-surface-2);
    border-bottom: 1px solid var(--color-border);
}

/* 翻译按钮：靠右对齐，译文态高亮 */
.translate-btn {
    margin-left: auto;
    flex-shrink: 0;
}
.translate-btn.active {
    color: var(--color-accent);
    border-color: var(--color-accent);
    background: var(--color-accent-soft);
}
.translate-btn:disabled {
    opacity: 0.6;
    cursor: wait;
}

.email-direction {
    font-size: 12px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 12px;
    white-space: nowrap;
}

.email-direction.incoming {
    background: var(--color-accent-soft);
    color: var(--color-accent);
}

.email-direction.outgoing {
    background: var(--color-success-soft);
    color: var(--color-success);
}

.email-sender {
    font-size: 13px;
    color: var(--color-text);
    font-weight: 500;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.email-date {
    font-size: 12px;
    color: var(--color-faint);
    white-space: nowrap;
}

.email-subject {
    padding: 10px 16px;
    font-size: 13px;
    color: var(--color-muted);
    background: var(--color-surface-2);
    border-bottom: 1px solid var(--color-border);
}

.email-subject span {
    color: var(--color-faint);
}

/* ── 折叠态邮件：单行卡片 —— 头像 + 名字 + 一行预览 + 附件图标 + 时间 + 箭头，点整行取正文 ── */
.email-item.collapsed {
    border-left: 1px solid var(--color-border);   /* 卡片风：盖掉方向色条，方向由头像颜色区分 */
    opacity: 1;
}

.email-fold {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 14px;
    cursor: pointer;
    background: var(--color-surface);
    transition: background 0.15s;
}

.email-fold:hover {
    background: color-mix(in srgb, var(--color-accent) 7%, var(--color-surface));
}

.email-fold:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: -2px;
}

.email-avatar {
    flex-shrink: 0;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    background: var(--color-accent-soft);
    color: var(--color-accent);
}

.email-item.outgoing .email-avatar {
    background: var(--color-success-soft);
    color: var(--color-success);
}

.email-fold-name {
    flex-shrink: 0;
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text);
    white-space: nowrap;
}

.email-fold-preview {
    flex: 1;
    min-width: 0;
    font-size: 13px;
    color: var(--color-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.email-att-ico {
    flex-shrink: 0;
    color: var(--color-faint);
}

.email-chev {
    flex-shrink: 0;
    color: var(--color-faint);
    transition: color 0.15s;
}

.email-fold:hover .email-chev {
    color: var(--color-accent);
}

/* 展开态标题栏：点一下收起（翻译按钮自己 stopPropagation，不触发收起） */
.email-header.email-unfold {
    cursor: pointer;
    transition: background 0.15s;
}

.email-header.email-unfold:hover {
    background: color-mix(in srgb, var(--color-accent) 8%, var(--color-surface));
}

.email-header.email-unfold:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: -2px;
}

.email-header.email-unfold:hover .email-chev-up {
    color: var(--color-accent);
}

.email-item.loading-body {
    opacity: 0.6;
}

.email-item.loading-body .email-fold {
    cursor: wait;
}

.email-body {
    padding: 16px;
}

/* `.email-text` 是邮件正文的**宿主**（正文本体在它的 shadow root 里）。
 * 这里只留宿主自己要的继承源（字号/行高/颜色/断词），下面那些给正文内部元素用的
 * 「阅读样式」（img / a / blockquote / p）连同引用折叠的样式，全都在 shadow 内重放一份，
 * 唯一副本在 static/js/conversations/core.js 的 EMAIL_BODY_CSS —— 改正文观感改那边。
 * 为什么非得住 shadow：邮件自带的 `<style>` 一进主文档就是全页生效的样式表（见 HANDOFF）。 */
.email-text {
    font-size: 14px;
    line-height: 1.7;
    color: var(--color-text);
    word-break: break-word;
}

/* 邮件正文：被回复的原文默认收起（点「展开引用」才显示）。
 * 折叠按钮是**长在正文中间**的，跟着正文一起住进 shadow root —— 样式同 EMAIL_BODY_CSS。 */

.email-divider {
    text-align: center;
    color: var(--color-faint);
    font-size: 12px;
    padding: 8px 0;
}

/* Attachments */
.email-attachments {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px dashed var(--color-border);
}

.attachment-images {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 8px;
}

.attachment-images a {
    display: block;
}

.attachment-images img {
    max-width: 200px;
    max-height: 150px;
    border-radius: 4px;
    border: 1px solid var(--color-border);
    cursor: pointer;
    transition: transform 0.2s;
}

.attachment-images img:hover {
    transform: scale(1.05);
}

.attachment-files {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.attachment-label {
    font-size: 12px;
    color: var(--color-faint);
}

.attachment-link {
    display: inline-block;
    padding: 4px 10px;
    background: var(--color-surface-2);
    border-radius: 4px;
    font-size: 12px;
    color: var(--color-accent);
    text-decoration: none;
}

.attachment-link:hover {
    background: var(--color-accent-soft);
}

/* 以附件形式发来的图片（非内嵌）：缩略图卡片 + 文件名，点开灯箱预览。
   比 .attachment-images img 更具体，压掉它的 200×150 与 hover 放大。

   卡片带状态机（见 detail.js 的「附件预取」段），由 data-st 驱动：
   idle 未处理 / pending 排队 / fetch 取原图中(不确定) / xfer 传输中(真实百分比)
   / ready 可预览 / manual 超上限待手动 / fail 失败可重试。
   **ready 态的外观与改造前逐像素一致**（40px 缩略图 + 名字 + 大小），不影响老观感。 */
.attachment-images .att-inline-card {
    position: relative;   /* .att-bar 贴底用的定位基准 */
    overflow: hidden;     /* 让底部进度条跟着卡片圆角裁掉 */
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 10px 5px 5px;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    background: var(--color-surface);
    cursor: zoom-in;
    max-width: 230px;
    transition: border-color .15s, background .15s, opacity .2s;
}

.attachment-images .att-inline-card:hover {
    border-color: var(--color-accent-line);
}

/* 缩略图位：40×40，内部按状态叠三层（真图 / 骨架微光 / 占位图标）。
   ⚠️ 名字必须带 -box：文件下面还有一条给回复编辑器附件卡用的 `.att-thumb`（.att-card 里），
   同权重时后者靠位置赢 —— 一开始就叫 .att-thumb 的话缩略图会被压成 38px、整张卡片矮 2px。 */
.att-thumb-box {
    position: relative;
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border: 1px solid var(--color-border);
    border-radius: 5px;
    background: var(--color-surface-3);
    color: var(--color-faint);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.att-thumb-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    object-fit: cover;
    border: 0;
    border-radius: 0;
    opacity: 0;
    transition: opacity .22s ease-out;
}

.att-thumb-img.on { opacity: 1; }

.attachment-images .att-inline-card img:hover {
    transform: none;   /* 卡片整体是点击区，缩略图不再单独放大 */
}

.att-thumb-ico { display: none; }

.attachment-images .att-inline-card[data-st="idle"] .att-thumb-ico,
.attachment-images .att-inline-card[data-st="pending"] .att-thumb-ico,
.attachment-images .att-inline-card[data-st="manual"] .att-thumb-ico,
.attachment-images .att-inline-card[data-st="fail"] .att-thumb-ico { display: block; }

/* 取回阶段：缩略图位走骨架微光，表示「这儿在动」 */
.att-skel {
    position: absolute;
    inset: 0;
    display: none;
    background: linear-gradient(100deg, var(--color-surface-3) 28%, var(--color-surface) 50%, var(--color-surface-3) 72%);
    background-size: 220% 100%;
    animation: att-shimmer 1.35s linear infinite;
}

.attachment-images .att-inline-card[data-st="fetch"] .att-skel,
.attachment-images .att-inline-card[data-st="xfer"] .att-skel { display: block; }

@keyframes att-shimmer {
    from { background-position: 130% 0; }
    to   { background-position: -130% 0; }
}

/* ── 卡片底边的进度条（--p 由 JS 写，0~100）──
   fetch 段后端在响应前阻塞、前端拿不到任何字节，只能走不确定的滚动条纹；
   xfer 段有 Content-Length，才是真实百分比。不编假数字。 */
.att-bar {
    position: absolute;
    left: 0;
    bottom: 0;
    height: 2px;
    width: calc(var(--p, 0) * 1%);
    background: var(--color-accent);
    border-radius: 0 2px 2px 0;
    display: none;
    transition: width .12s linear;
}

.attachment-images .att-inline-card[data-st="fetch"] .att-bar {
    display: block;
    width: 45%;
    background: linear-gradient(90deg, transparent, var(--color-accent), transparent);
    animation: att-bar-slide 1.1s ease-in-out infinite;
}

.attachment-images .att-inline-card[data-st="xfer"] .att-bar { display: block; }

@keyframes att-bar-slide {
    from { left: -45%; }
    to   { left: 100%; }
}

/* 各状态的「还不能点」表达 */
.attachment-images .att-inline-card[data-st="pending"] { opacity: .72; cursor: default; }
.attachment-images .att-inline-card[data-st="pending"]:hover { border-color: var(--color-border); }
.attachment-images .att-inline-card[data-st="fetch"],
.attachment-images .att-inline-card[data-st="xfer"] { cursor: progress; }
.attachment-images .att-inline-card[data-st="fetch"]:hover,
.attachment-images .att-inline-card[data-st="xfer"]:hover { border-color: var(--color-border); }
.attachment-images .att-inline-card[data-st="manual"] { border-style: dashed; }
.attachment-images .att-inline-card[data-st="fail"] { border-color: var(--color-danger); }
.attachment-images .att-inline-card[data-st="fail"] .att-thumb-ico { color: var(--color-danger); }

.att-meta {
    min-width: 0;
}

.att-name {
    display: block;
    font-size: 12px;
    color: var(--color-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 150px;
}

/* 附件卡片第二行：平时是文件大小，取回期间变成状态文字 */
.att-state {
    display: block;
    font-size: 11px;
    color: var(--color-faint);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 150px;
}

.attachment-images .att-inline-card[data-st="fetch"] .att-state,
.attachment-images .att-inline-card[data-st="xfer"] .att-state { color: var(--color-muted); }
.attachment-images .att-inline-card[data-st="manual"] .att-state { color: var(--color-accent); }
.attachment-images .att-inline-card[data-st="fail"] .att-state { color: var(--color-danger); }

.att-pct { color: var(--color-accent); font-weight: 600; font-variant-numeric: tabular-nums; }
.att-hint { color: var(--color-accent); }

/* 回复编辑器附件区复用它（reply.js 的 .att-card 里仍是「名字 + 大小」两行） */
.att-size {
    display: block;
    font-size: 11px;
    color: var(--color-faint);
}

/* 回复编辑器附件区的图片附件卡（缩略图 + 名字 + 大小 + 移除） */
.att-card {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    padding: 5px 8px 5px 5px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    max-width: 280px;
}

.att-card:hover {
    border-color: var(--color-border-strong);
}

/* 回复编辑器附件卡的缩略图位。**必须限定在 .att-card 下** —— 写成裸 .att-thumb 会变成
   全站通用类，跟详情页附件卡的缩略图（.att-thumb-box 的前身）互相覆盖（09-21 实测踩到）。 */
.att-card .att-thumb {
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    border-radius: 6px;
    overflow: hidden;
    background: var(--color-surface-3);
    border: 1px solid var(--color-border);
    cursor: zoom-in;
    display: flex;
    align-items: center;
    justify-content: center;
}

.att-card .att-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.att-card .att-name.link {
    cursor: zoom-in;
}

.att-card .att-name.link:hover {
    color: var(--color-accent);
}

/* ── 回复正文内嵌图片：选中 + 四角缩放 ──
   覆盖层挂在 .reply-rich 上（不在 contenteditable 里，避免脏草稿/脏邮件） */
.reply-rich {
    position: relative;
}

.rsz-overlay {
    position: absolute;
    inset: 0;
    display: none;
    pointer-events: none;   /* 只有手柄本身接管点击 */
    z-index: 6;
}

.rsz-overlay.on {
    display: block;
}

.rsz-h {
    position: absolute;
    width: 10px;
    height: 10px;
    border-radius: 2px;
    background: var(--color-accent);
    border: 2px solid #fff;
    box-shadow: 0 1px 3px rgba(var(--shadow-rgb), .35);
    pointer-events: auto;
}

.rsz-nw, .rsz-se { cursor: nwse-resize; }
.rsz-ne, .rsz-sw { cursor: nesw-resize; }

.rsz-badge {
    position: absolute;
    background: rgba(27, 42, 56, .9);
    color: #fff;
    font-size: 11px;
    padding: 1px 7px;
    border-radius: 5px;
    white-space: nowrap;
    pointer-events: none;
}

.reply-inline-img.rsz-sel {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

/* Image Lightbox */
.lightbox {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.9);
    z-index: 9999;
    justify-content: center;
    align-items: center;
    cursor: pointer;
}

.lightbox.active {
    display: flex;
}

.lightbox img {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
    border-radius: 4px;
}

.lightbox-close {
    position: absolute;
    top: 20px;
    right: 30px;
    color: #fff;
    font-size: 36px;
    cursor: pointer;
    line-height: 1;
}

.lightbox-close:hover {
    color: var(--color-faint);
}

/* ── 灯箱的加载 / 失败态 ──
   状态节点（转圈 / 文案 / 重试 / 下载原图）由 core.js 的 lbStateEl() 幂等插入，
   所以改这里不用动模板、不用重启进程。
   .lb-state 铺满遮罩并居中，pointer-events:none 让点击照旧穿透到遮罩（点空白关闭）——
   只有「重试」和「下载原图」自己开 pointer-events。
   这里的白色是写死的：遮罩底色是固定的 rgba(0,0,0,.9)，与深浅主题无关。 */
.lightbox img { display: none; }
.lightbox img.on { display: block; }

.lb-state {
    position: absolute;
    inset: 0;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 11px;
    padding: 0 24px;
    text-align: center;
    pointer-events: none;
}

.lb-state.on { display: flex; }

.lb-spin {
    width: 26px;
    height: 26px;
    border: 2px solid rgba(255, 255, 255, .25);
    border-top-color: #fff;
    border-radius: 50%;
    animation: lb-spin .9s linear infinite;
}

@keyframes lb-spin {
    to { transform: rotate(360deg); }
}

.lb-msg { font-size: 13px; color: rgba(255, 255, 255, .9); }

.lb-name {
    font-size: 12px;
    color: rgba(255, 255, 255, .5);
    max-width: 62vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 失败态：图标顶掉加载圈，多一行说明 + 一个可点的重试 */
.lb-err-ico { display: none; color: rgba(255, 255, 255, .7); }
.lb-hint { display: none; font-size: 12.5px; color: rgba(255, 255, 255, .6); max-width: 380px; }

.lb-state.err .lb-spin { display: none; }
.lb-state.err .lb-err-ico,
.lb-state.err .lb-hint { display: block; }

.lb-retry { display: none; }

.lb-state.err .lb-retry {
    display: inline-block;
    pointer-events: auto;
    margin-top: 3px;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, .38);
    color: #fff;
    font: inherit;
    font-size: 12.5px;
    padding: 5px 15px;
    border-radius: 6px;
    cursor: pointer;
}

.lb-state.err .lb-retry:hover { background: rgba(255, 255, 255, .12); }

/* 加载成功后才出现的「下载原图」 */
.lb-dl {
    position: absolute;
    right: 28px;
    bottom: 26px;
    display: none;
    border: 1px solid rgba(255, 255, 255, .35);
    color: #fff;
    font-size: 12.5px;
    padding: 6px 15px;
    border-radius: 7px;
    text-decoration: none;
    pointer-events: auto;
}

.lb-dl.on { display: block; }
.lb-dl:hover { background: rgba(255, 255, 255, .14); }

/* Sync Page */
.sync-card, .sync-status-card {
    background: var(--color-surface);
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(var(--shadow-rgb), 0.06);
    padding: 24px;
    margin-bottom: 20px;
}

.sync-card h3, .sync-status-card h3 {
    font-size: 16px;
    margin-bottom: 16px;
    color: var(--color-text);
}

.sync-form {
    display: flex;
    gap: 16px;
    align-items: flex-end;
    margin-bottom: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.form-group label {
    font-size: 13px;
    color: var(--color-muted);
}

.form-group input,
.form-group select {
    padding: 8px 12px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-size: 14px;
    background: var(--color-surface);
    color: var(--color-text);
    transition: border-color .15s, box-shadow .15s;
}

.form-group input:hover,
.form-group select:hover {
    border-color: var(--color-border-strong);
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(var(--accent-rgb), .12);
}

/* 下拉框与日期框等高、同风格：去系统默认外观，画自定义箭头 */
.form-group select {
    appearance: none;
    -webkit-appearance: none;
    padding-right: 32px;
    min-width: 180px;
    background-image: var(--select-arrow);
    background-repeat: no-repeat;
    background-position: right 12px center;
    cursor: pointer;
}

.btn-primary {
    background: var(--color-accent);
    color: var(--color-on-accent);
    padding: 7px 18px;
}

.btn-primary:hover {
    background: var(--color-accent-hover);
}

.btn-primary:disabled {
    background: var(--color-accent-line);
    cursor: not-allowed;
}

/* ====== 回复编辑器 ====== */
.reply-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 14px;
    margin-bottom: 12px;
    border: 1px solid var(--color-accent-line);
    background: var(--color-accent-tint);
    border-radius: 8px;
    cursor: pointer;
    transition: border-color .15s, background .15s;
}

.reply-bar:hover {
    border-color: var(--color-accent);
    background: var(--color-accent-tint);
}

.reply-bar.has-draft {
    border-color: var(--color-warning);
    background: var(--color-warning-soft);
}

.reply-bar-icon {
    color: var(--color-accent);
    font-size: 14px;
}

.reply-bar.has-draft .reply-bar-icon {
    color: var(--color-warning);
}

.reply-bar-text {
    font-size: 13.5px;
    color: var(--color-accent);
    font-weight: 500;
}

.reply-bar.has-draft .reply-bar-text {
    color: var(--color-warning);
}

.reply-bar-hint {
    margin-left: auto;
    font-size: 12px;
    color: var(--color-faint);
}

.reply-composer {
    border: 1px solid var(--color-accent);
    border-radius: 8px;
    background: var(--color-surface);
    margin-bottom: 16px;
    overflow: hidden;
}

.reply-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    border-bottom: 1px solid var(--color-border);
}

.reply-modes {
    display: flex;
    gap: 4px;
    background: var(--color-surface-2);
    border-radius: 6px;
    padding: 3px;
}

.reply-mode {
    border: none;
    background: transparent;
    border-radius: 5px;
    padding: 4px 14px;
    font-size: 12.5px;
    color: var(--color-muted);
    cursor: pointer;
}

.reply-mode.active {
    background: var(--color-surface);
    color: var(--color-accent);
    font-weight: 500;
}

.reply-collapse {
    font-size: 12px;
    color: var(--color-faint);
    cursor: pointer;
}

.reply-collapse:hover {
    color: var(--color-muted);
}

.reply-field {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 12px;
    border-bottom: 1px solid var(--color-border);
}

.reply-label {
    width: 42px;
    flex: none;
    font-size: 12.5px;
    color: var(--color-muted);
}

.reply-field input[type="text"],
.reply-field select {
    flex: 1;
    border: none;
    font-size: 13px;
    color: var(--color-text);
    background: transparent;
    padding: 2px 0;
    min-width: 0;
}

.reply-field input[type="text"]:focus,
.reply-field select:focus {
    outline: none;
}

.reply-field input[readonly] {
    color: var(--color-muted);
}

/* 主题（以及收件人）可编辑：给一点视觉提示，和纯文本展示区分开 */
#reply-subject {
    border-bottom: 1px solid transparent;
    transition: border-color .15s;
}

#reply-subject:hover,
#reply-subject:focus {
    border-bottom-color: var(--color-border);
}

.reply-account-hint {
    font-size: 11.5px;
    color: var(--color-faint);
    flex: none;
}

/* 富文本正文编辑区 */
.reply-rich {
    display: flex;
    flex-direction: column;
    background: var(--color-surface);
}

.reply-toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 2px;
    padding: 6px 8px;
    border-bottom: 1px solid var(--color-border);
    background: var(--color-surface-2);
    position: relative;
}

.rtb {
    border: none;
    background: transparent;
    font-size: 12.5px;
    font-family: inherit;
    color: var(--color-muted);
    padding: 4px 9px;
    border-radius: 6px;
    cursor: pointer;
    line-height: 1.4;
}

.rtb:hover {
    background: var(--color-surface-2);
    color: var(--color-text);
}

.rtb-sep {
    width: 1px;
    height: 16px;
    background: var(--color-surface-2);
    margin: 0 5px;
}

.rtb-tpl-menu {
    position: absolute;
    top: 34px;
    right: 8px;
    min-width: 190px;
    max-width: 300px;
    max-height: 280px;
    overflow: auto;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(var(--shadow-rgb), 0.12);
    padding: 4px;
    z-index: 30;
}

.rtb-tpl-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    border-radius: 6px;
    font-size: 12.5px;
}

.rtb-tpl-item:hover {
    background: var(--color-surface-2);
}

.rtb-tpl-title {
    flex: 1;
    cursor: pointer;
    color: var(--color-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rtb-tpl-del,
.rtb-tpl-edit {
    color: var(--color-faint);
    cursor: pointer;
    padding: 0 3px;
    flex: none;
    font-size: 13px;
    line-height: 1;
}

.rtb-tpl-edit:hover {
    color: var(--color-accent);
}

.rtb-tpl-del:hover {
    color: var(--color-danger);
}

/* ====== 回复模板编辑弹窗 ====== */
.modal-tpl {
    width: 560px;
    max-width: 92vw;
}

/* 模板弹窗是从写邮件弹窗里的「模板 ▾ → 新建模板」开出来的，必须叠在它上面。
   两个 overlay 默认都是 z-index:10000，谁在 DOM 里靠后就压住谁 —— 而 #tpl-modal
   排在 #compose-modal **前面**，所以新建框会被写邮件弹窗整个盖住（点不到）。
   层级约定与 .confirm-overlay(11000) 保持一致：越晚弹出的层越高。 */
#tpl-modal {
    z-index: 10100;
}

.tpl-editor {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    overflow: hidden;
    background: var(--color-surface);
}

.tpl-editor .reply-toolbar {
    border-bottom: 1px solid var(--color-border);
}

/* 模板正文沿用 .reply-body-rich 的排版，仅覆盖尺寸 */
.modal-tpl .tpl-body {
    min-height: 200px;
    max-height: 46vh;
    padding: 12px 14px;
}

.rtb-tpl-add,
.rtb-tpl-empty {
    padding: 7px 8px;
    font-size: 12.5px;
    color: var(--color-accent);
    cursor: pointer;
    border-top: 1px solid var(--color-border);
}

.rtb-tpl-empty {
    color: var(--color-faint);
    cursor: default;
}

.reply-body-rich {
    min-height: 120px;
    max-height: 420px;
    overflow: auto;
    padding: 12px;
    font-size: 13.5px;
    line-height: 1.7;
    font-family: inherit;
    color: var(--color-text);
    outline: none;
}

.reply-body-rich:empty::before {
    content: attr(data-placeholder);
    color: var(--color-faint);
}

.reply-body-rich ul,
.reply-body-rich ol {
    margin: 6px 0;
    padding-left: 22px;
}

.reply-body-rich a {
    color: var(--color-accent);
}

.reply-inline-img {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
    margin: 6px 0;
    display: block;
}

/* 回复正文译文面板：只读副本，用来核对 AI 生成的英文草稿，不改动正文本身 */
.reply-trans {
    border-top: 1px solid var(--color-border);
    background: var(--color-surface-2);
    padding: 8px 12px 10px;
}

.reply-trans-head {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.reply-trans-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--color-muted);
    letter-spacing: 0.04em;
}

.reply-trans-lang {
    font-size: 11.5px;
    line-height: 1.6;
    color: var(--color-accent);
    background: var(--color-accent-soft);
    border-radius: 10px;
    padding: 1px 8px;
}

.reply-trans-lang:empty {
    display: none;
}

.reply-trans-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 4px;
}

.reply-trans-btn {
    font-family: inherit;
    font-size: 12px;
    color: var(--color-muted);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 6px;
    padding: 2px 8px;
    cursor: pointer;
}

.reply-trans-btn:hover:not(:disabled) {
    color: var(--color-text);
    border-color: var(--color-border-strong);
}

.reply-trans-btn:disabled {
    opacity: 0.55;
    cursor: default;
}

/* 正文改过、译文过期：高亮「更新译文」，把用户的下一步说清楚 */
.reply-trans-btn.is-dirty {
    color: var(--color-warning);
    background: var(--color-warning-soft);
    border-color: var(--color-warning);
    font-weight: 600;
}

.reply-trans-btn.is-dirty:hover:not(:disabled) {
    color: var(--color-warning);
    border-color: var(--color-warning);
}

.reply-trans-close {
    font-size: 12px;
    color: var(--color-faint);
    cursor: pointer;
    padding: 2px;
}

.reply-trans-close:hover {
    color: var(--color-text);
}

.reply-trans-body {
    max-height: 260px;
    overflow: auto;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    /* 左侧永远留出 3px 空位，过期时只换颜色不动几何（避免面板抖动） */
    border-left-width: 3px;
    border-left-color: transparent;
    border-radius: 8px;
    padding: 10px 12px 10px 10px;
    font-size: 13px;
    line-height: 1.75;
    color: var(--color-text);
    word-break: break-word;
}

/* 译文已过期（正文改过但还没点「更新译文」）：不加遮罩影响阅读，只留一条提示色 */
.reply-trans-body.is-stale {
    border-left-color: var(--color-warning);
}

.reply-trans-body div,
.reply-trans-body p {
    margin: 0 0 6px;
}

.reply-trans-body ul,
.reply-trans-body ol {
    margin: 6px 0;
    padding-left: 22px;
}

.reply-trans-body a {
    color: var(--color-accent);
}

.reply-trans-body img {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
    display: block;
    margin: 6px 0;
}

.reply-trans-empty {
    font-size: 12.5px;
    color: var(--color-faint);
}

.reply-trans-note {
    margin-top: 6px;
    font-size: 12px;
    color: var(--color-warning);
}

.rtb-trans.active {
    color: var(--color-accent);
    background: var(--color-accent-soft);
}

/* 附件区 */
.reply-attach {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 9px 12px;
    border-top: 1px dashed var(--color-border);
}

.reply-attach-label {
    font-size: 12px;
    color: var(--color-muted);
    flex: none;
    padding-top: 4px;
}

.reply-attach-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.reply-attach-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--color-text);
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 6px;
    padding: 4px 8px;
    max-width: 260px;
}

.reply-attach-size {
    color: var(--color-faint);
    flex: none;
}

.reply-attach-x {
    color: var(--color-faint);
    cursor: pointer;
    flex: none;
    font-size: 14px;
    line-height: 1;
}

.reply-attach-x:hover {
    color: var(--color-danger);
}

.reply-quote-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    border-top: 1px dashed var(--color-border);
    font-size: 12px;
    color: var(--color-muted);
    cursor: pointer;
}

.reply-quote-toggle:hover {
    color: var(--color-muted);
}

.reply-quote-preview {
    color: var(--color-faint);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 引用行右侧的「删除引用」 */
.reply-quote-del {
    margin-left: auto;
    flex: none;
    font-size: 12px;
    color: var(--color-faint);
    padding: 1px 6px;
    border-radius: 4px;
}

.reply-quote-del:hover {
    color: var(--color-danger);
    background: var(--color-danger-soft);
}

/* 引用被删除后的占位行 */
.reply-quote-deleted {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 12px;
    border-top: 1px dashed var(--color-border);
    font-size: 12px;
    color: var(--color-faint);
}

.reply-quote-deleted-text::before {
    content: '⌫';
    margin-right: 5px;
}

.reply-quote-restore {
    color: var(--color-accent);
    cursor: pointer;
}

.reply-quote-restore:hover {
    text-decoration: underline;
}

.reply-quote-full {
    padding: 10px 12px;
    border-top: 1px dashed var(--color-border);
    background: var(--color-surface-2);
    max-height: 180px;
    overflow: auto;
}

.reply-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 9px 12px;
    border-top: 1px solid var(--color-border);
    background: var(--color-surface-2);
}

.reply-foot-left,
.reply-foot-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.reply-draft-hint {
    font-size: 11.5px;
    color: var(--color-faint);
}

.reply-kbd {
    font-size: 11.5px;
    color: var(--color-faint);
}

/* 已发送邮件中的引用块 */
.reply-quote {
    margin-top: 12px;
    padding: 10px 12px;
    border-left: 2px solid var(--color-border);
    background: var(--color-surface-2);
    border-radius: 4px;
}

.reply-quote-head {
    font-size: 12px;
    color: var(--color-muted);
    margin-bottom: 6px;
}

.reply-quote-body {
    margin: 0;
    font-family: inherit;
    font-size: 12.5px;
    color: var(--color-muted);
    white-space: pre-wrap;
    word-break: break-word;
}

.quick-select {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--color-muted);
}

.btn-small {
    padding: 5px 14px;
    font-size: 12.5px;
    background: var(--color-surface-2);
    border: none;
    border-radius: 999px;
    cursor: pointer;
}

.btn-small:hover {
    background: var(--color-surface-3);
}

.status-info {
    margin-bottom: 12px;
    font-size: 14px;
    color: var(--color-text);
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--color-surface-3);
}

.status-dot.running {
    background: var(--color-accent);
    animation: pulse 1s infinite;
}

.status-dot.success {
    background: var(--color-success-solid);
}

.status-dot.error {
    background: var(--color-danger-solid);
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.status-progress {
    font-size: 12px;
    color: var(--color-muted);
    max-height: 300px;
    overflow-y: auto;
    white-space: pre-wrap;
    font-family: monospace;
    background: var(--color-surface-2);
    padding: 12px;
    border-radius: 4px;
}

/* Charts */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
    gap: 20px;
}

.chart-card {
    background: var(--color-surface);
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(var(--shadow-rgb), 0.06);
    padding: 20px;
}

.chart-card h3 {
    font-size: 16px;
    margin-bottom: 16px;
    color: var(--color-text);
}

.chart {
    width: 100%;
    height: 300px;
}

/* 图表无数据时的占位（与 .chart 同高，避免卡片塌陷） */
.chart-empty {
    height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 24px;
    text-align: center;
    font-size: 13px;
    color: var(--color-faint);
    line-height: 1.8;
}

/* Loading & Error */
.loading, .error {
    text-align: center;
    padding: 40px;
    color: var(--color-faint);
}

.error {
    color: var(--color-danger);
}

/* Attachments Management Page */
.stats-info {
    font-size: 13px;
    color: var(--color-muted);
    margin-left: 8px;
}

.inline-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    background: var(--color-accent-soft);
    color: var(--color-accent);
}

.row-inline {
    background: var(--color-surface-2);
}

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

.batch-actions {
    margin-top: 16px;
    padding: 12px 16px;
    background: var(--color-surface);
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(var(--shadow-rgb), 0.06);
    display: flex;
    align-items: center;
    gap: 12px;
}

.btn-danger {
    background: color-mix(in srgb, var(--color-danger) 11%, var(--color-surface));
    color: var(--color-danger);
    padding: 7px 16px;
    border-radius: 999px;
    border: none;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: background 0.16s var(--ease-out), color 0.16s var(--ease-out);
}

.btn-danger:hover {
    background: color-mix(in srgb, var(--color-danger) 21%, var(--color-surface));
}

/* ====== Tag Tabs ====== */
.tag-tabs {
    display: flex;
    gap: 4px;
    padding: 8px 16px;
    border-bottom: 1px solid var(--color-border);
    overflow-x: auto;
    overflow-y: hidden;
    flex-shrink: 0;
    background: var(--color-surface);
}

/* ==========================================================================
   全局滚动条：细圆角 + 透明轨道，颜色从主题令牌调出（随深浅档自适应），
   替换 Windows/浏览器默认的灰色大块，与天蓝简约统一
   ========================================================================== */
* {
    scrollbar-width: thin;   /* Firefox */
    scrollbar-color: color-mix(in srgb, var(--color-accent) 28%, var(--color-border)) transparent;
}

::-webkit-scrollbar {
    width: 9px;
    height: 9px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    /* 中间细条：上下留 2px 透明边，视觉宽度 5px 的圆角胶囊 */
    background: color-mix(in srgb, var(--color-accent) 28%, var(--color-border));
    background-clip: padding-box;
    border: 2px solid transparent;
    border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
    background: color-mix(in srgb, var(--color-accent) 48%, var(--color-border));
    background-clip: padding-box;
    border: 2px solid transparent;
}

::-webkit-scrollbar-corner {
    background: transparent;
}

/* 标签栏滚动条（可见，细条样式） */
.tag-tabs::-webkit-scrollbar {
    height: 6px;
}

.tag-tabs::-webkit-scrollbar-track {
    background: transparent;
}

.tag-tabs::-webkit-scrollbar-thumb {
    background: var(--color-surface-3);
    border-radius: 3px;
}

.tag-tabs::-webkit-scrollbar-thumb:hover {
    background: var(--color-surface-3);
}

.tag-tabs {
    scrollbar-width: thin;
    scrollbar-color: var(--color-surface-3) transparent;
}

.tag-tab {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 16px;
    font-size: 12px;
    cursor: pointer;
    white-space: nowrap;
    border: 1px solid var(--color-border);
    transition: all 0.15s;
    user-select: none;
    flex-shrink: 0;
}

.tag-tab:hover {
    background: var(--color-surface-2);
}

.tag-tab.active {
    background: var(--tag-color, var(--color-accent));
    color: #fff;
    border-color: var(--tag-color, var(--color-accent));
}

.tag-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.tag-tab.active .tag-dot {
    background: var(--color-surface) !important;
}

.tag-count {
    font-size: 11px;
    color: var(--color-faint);
}

.tag-tab.active .tag-count {
    color: rgba(255,255,255,0.8);
}

/* 标签未读数角标 */
.tag-unread {
    min-width: 18px;
    text-align: center;
    font-size: 11px;
    font-weight: 600;
    line-height: 16px;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--color-accent);
    color: var(--color-on-accent);
    flex-shrink: 0;
}

.tag-tab.active .tag-unread {
    background: rgba(255,255,255,0.95);
    color: var(--tag-color, var(--color-accent));
}

/* ====== 左右分栏拖拽条 ====== */
.split-resizer {
    width: 5px;
    min-width: 5px;
    cursor: col-resize;
    background: transparent;
    transition: background 0.15s;
    flex-shrink: 0;
}

.split-resizer:hover,
.split-resizer.dragging {
    background: var(--color-accent);
}

.tag-delete {
    margin-left: 2px;
    font-size: 14px;
    color: var(--color-faint);
    cursor: pointer;
    line-height: 1;
}

.tag-delete:hover {
    color: var(--color-danger);
}

.tag-add {
    border-style: dashed;
    color: var(--color-faint);
}

.tag-add:hover {
    color: var(--color-accent);
    border-color: var(--color-accent);
}

/* ====== Tag Badges ====== */
.tag-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    margin-right: 4px;
    margin-bottom: 4px;
}

.detail-tags {
    margin-top: 8px;
}

/* 会话涉及的邮箱已并入 `.detail-meta`（见该处注释），这里不再有独立一行的胶囊。
 * ⚠️ 邮件行上也不逐封标（`.email-to-chip` 已删）——「属于哪个邮箱」只在会话头标一次。 */

/* ====== Detail Actions ====== */
.detail-actions {
    display: flex;
    gap: 8px;
    margin-top: 14px;
}

/* 色调胶囊：三颗同形状同字号，普通操作浅蓝底蓝字（与主题同源），
   危险操作浅红底红字——不再是一块深红实心，整组安静统一 */
.detail-actions .btn {
    padding: 6px 14px;
    font-size: 12px;
    font-weight: 500;
    border: none;
    border-radius: 999px;
    background: color-mix(in srgb, var(--color-accent) 10%, var(--color-surface));
    color: var(--color-accent);
    transition: background 0.16s var(--ease-out), transform 0.16s var(--ease-out);
}

.detail-actions .btn:hover {
    background: color-mix(in srgb, var(--color-accent) 19%, var(--color-surface));
    transform: translateY(-1px);
}

.detail-actions .btn:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

.detail-actions .btn-danger {
    background: color-mix(in srgb, var(--color-danger) 11%, var(--color-surface));
    color: var(--color-danger);
}

.detail-actions .btn-danger:hover {
    background: color-mix(in srgb, var(--color-danger) 21%, var(--color-surface));
}

.detail-actions .btn-danger:focus-visible {
    outline-color: var(--color-danger);
}

@media (prefers-reduced-motion: reduce) {
    .detail-actions .btn {
        transition: none;
    }

    .detail-actions .btn:hover {
        transform: none;
    }
}

/* ====== Modal ====== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal {
    background: var(--color-surface);
    border-radius: 8px;
    padding: 24px;
    min-width: 320px;
    box-shadow: 0 4px 20px rgba(var(--shadow-rgb), 0.15);
    /* 内容多的弹窗（如编辑标签）限高内部滚动，不许撑出视口 */
    max-height: calc(100vh - 48px);
    overflow-y: auto;
}

.modal h3 {
    margin-bottom: 16px;
    font-size: 16px;
}

/* ⚠️ 必须排除写邮件弹窗：里面的编辑器有自己的字段样式（.reply-field input），
   而这两条与它**特异性相同**（都是 0,2,1），靠文件位置分胜负 —— 本文件里这两条更靠后，
   于是发件/收件人/抄送/主题全被套上边框、8px 内边距和 12px 下边距，行高被撑歪、
   占位文字挤在框顶。用 :not() 把它们挡在 .modal-compose 之外，别再靠调位置解决。 */
.modal input[type="text"]:not(.modal-compose *) {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-size: 14px;
    margin-bottom: 12px;
}

.modal input[type="text"]:not(.modal-compose *):focus {
    outline: none;
    border-color: var(--color-accent);
}

.color-picker-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.color-picker-row label {
    font-size: 14px;
    color: var(--color-muted);
}

.color-picker-row input[type="color"] {
    width: 40px;
    height: 32px;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    cursor: pointer;
    padding: 2px;
}

.move-select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-size: 14px;
    margin-bottom: 12px;
    background: var(--color-surface);
}

/* Multi-select tag list */
.move-tag-list {
    max-height: 240px;
    overflow-y: auto;
    margin-bottom: 12px;
}

.move-tag-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 4px;
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.15s;
}

.move-tag-item:hover {
    background: var(--color-surface-2);
}

.move-tag-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.no-tags-hint {
    color: var(--color-faint);
    font-size: 13px;
    padding: 16px 0;
    text-align: center;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 16px;
}

/* 按钮不许被挤扁：flex 子项默认 flex-shrink:1，一旦窄了按钮会断字
 * （「取消」竖成两列、「保存并推进」折成两行，用户截图报过）。
 * 让按钮保持自然宽度、不换行，把可压缩的空间留给左边的提示文字。 */
.modal-actions .btn {
    flex: 0 0 auto;
    white-space: nowrap;
}

/* ====== 新邮件提醒 Toast ====== */
#toast-box {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    pointer-events: auto;
    background: var(--color-accent);
    color: var(--color-on-accent);
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 14px;
    box-shadow: 0 4px 16px rgba(var(--shadow-rgb), 0.25);
    cursor: pointer;
    opacity: 0;
    transform: translateX(30px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    /* 多行提示（服务器侧漏删那条）不限制宽度会拉成 900px 的一整行，读不动 */
    max-width: min(520px, calc(100vw - 32px));
    line-height: 1.5;
}

.toast.show {
    opacity: 1;
    transform: translateX(0);
}

/* 「服务器侧没删掉」的提醒：独立一条，别混在蓝色成功提示里被读漏。
   复合选择器（.toast.toast-warn）——单类同权重靠后定义才生效，别写成一串单类。 */
.toast.toast-warn {
    background: var(--color-warning-soft);
    color: var(--color-warning);
    border-left: 3px solid var(--color-warning);
}

/* ====== 系统通知按钮（状态胶囊：默认灰调，已开启绿调，禁用淡化） ====== */
#notify-btn {
    font-size: 12.5px;
    padding: 5px 14px;
    border: none;
    border-radius: 999px;
    background: var(--color-surface-2);
    color: var(--color-muted);
    transition: background 0.16s var(--ease-out), color 0.16s var(--ease-out);
}

#notify-btn:hover {
    background: var(--color-surface-3);
}

#notify-btn[data-state="granted"] {
    background: color-mix(in srgb, var(--color-success) 12%, var(--color-surface));
    color: var(--color-success);
}

#notify-btn[data-state="granted"]:hover {
    background: color-mix(in srgb, var(--color-success) 20%, var(--color-surface));
}

#notify-btn[data-state="denied"] {
    opacity: 0.55;
    cursor: not-allowed;
}

#notify-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ====== 邮箱账号管理 ====== */
.account-form .form-row {
    margin-bottom: 12px;
}

.account-form label {
    display: block;
    font-size: 13px;
    color: var(--color-text);
    margin-bottom: 4px;
}

.account-form input {
    width: 100%;
    max-width: 420px;
    padding: 8px 10px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-size: 14px;
    box-sizing: border-box;
}

.form-row-inline {
    display: flex;
    gap: 16px;
}

.form-row-inline .form-row {
    flex: 1;
}

.form-row-inline input {
    max-width: 220px;
}

.account-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.account-table th,
.account-table td {
    text-align: left;
    padding: 8px 10px;
    border-bottom: 1px solid var(--color-border);
}

.account-table th {
    color: var(--color-muted);
    font-weight: 500;
}

/* ---- 邮箱名 / 备注名：点名字就地改名 ----
   备注名是「给这个邮箱起的好认名字」，输入框的初始值就是邮箱地址本身（accounts.html
   accEmailCellHtml）—— 拿地址当草稿比拿空框当草稿好改，改坏了也一眼看得到原文。

   ⚠️ 为什么不做成表格里的独立一列：这张表是 100% 宽、列宽自动分配的，真机量过 ——
   多一列会把每一格都压窄，行高 48px → 74px、「已启用」「添加时间」全部折成两行。
   所以改名做成「点名字变输入框」，不动列结构。

   有备注名时，真实地址降成下面一行灰色小字：管理页必须让真实地址看得见（别的页面
   顶替显示没问题，因为在那里地址只是个身份标签；这里是配置页，认错地址就改错账号）。 */
.acc-mail-top {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.acc-mail-name {
    display: flex;
    align-items: center;
    gap: 4px;
    min-width: 0;
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.acc-mail-text {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 铅笔：平时淡、悬停变亮变蓝。不做成只在悬停时才出现 —— 那样没人知道这行能点 */
.acc-mail-pen {
    flex: none;
    font-size: 11px;
    opacity: 0.35;
}

.acc-mail-name:hover .acc-mail-text {
    color: var(--color-accent);
}

.acc-mail-name:hover .acc-mail-pen {
    opacity: 1;
    color: var(--color-accent);
}

.acc-mail-addr {
    margin-top: 2px;
    font-size: 11.5px;
    color: var(--color-faint);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 编辑态：名字那行让位给输入框，地址行留着当参照。
   用祖先的 .editing 切显示，而不是靠 [hidden] —— `.acc-mail-top` 是 display:flex，
   会盖掉 UA 给 [hidden] 的 display:none，越是「顺手加个 hidden」越容易踩。 */
.acc-email-cell .acc-remark-input {
    display: none;
}

.acc-email-cell.editing .acc-mail-top {
    display: none;
}

.acc-email-cell.editing .acc-remark-input {
    display: block;
    width: 100%;
    max-width: 260px;
    padding: 4px 8px;
    border: 1px solid var(--color-accent);
    border-radius: 6px;
    background: var(--color-surface);
    color: var(--color-text);
    font-size: 13px;
    box-sizing: border-box;
    box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.12);
}

.acc-msg {
    font-size: 13px;
    margin-right: 12px;
}

.acc-hint {
    font-size: 12px;
    color: var(--color-faint);
    margin-top: 12px;
}

/* ====== 三栏布局：左侧邮箱导航栏 ====== */
.app-layout {
    display: flex;
    height: calc(100vh - 56px);
    overflow: hidden;
}

.app-layout .split-layout {
    flex: 1;
    min-width: 0;
}

.nav-sidebar {
    /* 宽度抽成局部令牌：拖拽手柄（.nav-resizer）要改它，别的规则只读。
       240 是「账号行能完整放下 support@voltset.com」的最小值——
       190 时固定开销（箭头+状态点+徽章+间距）就吃掉约 80px，邮箱只剩 100px 出头。 */
    --nav-sidebar-w: 240px;
    width: var(--nav-sidebar-w);
    min-width: var(--nav-sidebar-w);
    /* 拖拽手柄用绝对定位贴右边缘 */
    position: relative;
    /* 侧栏底色抽成局部令牌：底部那颗「添加邮箱账号」是 sticky 的，需要自带不透明底色
       盖住从它下面滚过去的条目 —— 两处必须是同一个值，所以只写一次 */
    --nav-sidebar-bg: color-mix(in srgb, var(--color-accent) 6%, var(--color-surface));
    background: var(--nav-sidebar-bg);
    border-right: 1px solid var(--color-border);
    overflow-y: auto;
    /* 底部不留内边距：那段留白交给末尾那颗「添加邮箱账号」自己。
       否则它「贴底」会有两个不同落点 —— margin-top:auto 时离底 12px、
       sticky 吸底时离底 0，滚动前后会跳一下。 */
    padding: 12px 8px 0;
    box-sizing: border-box;
    /* 纵向排列：末尾那颗「添加邮箱账号」靠 margin-top:auto 沉到最底下 */
    display: flex;
    flex-direction: column;
}

/* 宽度拖拽手柄。
   为什么必须贴在侧栏「内部」右边缘：.nav-sidebar 有 overflow-y:auto，
   用 right:-3px 这种外扩写法会被 overflow 直接裁掉，鼠标根本碰不到。
   代价是底部那颗「添加邮箱账号」最右侧 6px 被盖住 —— 按钮文字居中，不影响点击。 */
.nav-resizer {
    position: absolute;
    top: 0;
    right: 0;
    width: 6px;
    height: 100%;
    cursor: col-resize;
    z-index: 5;
    background: transparent;
    transition: background 0.14s var(--ease-out);
}

.nav-resizer:hover,
.nav-resizer.active {
    background: color-mix(in srgb, var(--color-accent) 35%, transparent);
}

/* 拖拽中：整页禁止选中，否则会把侧栏文字一路刷成蓝色 */
body.nav-resizing,
body.nav-resizing * {
    user-select: none !important;
    cursor: col-resize !important;
}

/* 写邮件：侧栏左上角的主操作（参考腾讯邮箱大师——最高频的动作永远在最顺手的位置）。
   原先它是会话列表页头的一颗胶囊按钮，但它并不是「针对当前列表」的动作，是全站动作。 */
.btn-compose-side {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    flex: 0 0 auto;
    padding: 9px 10px;
    margin-bottom: 8px;
    background: var(--color-accent);
    color: var(--color-on-accent);
    border: none;
    border-radius: 6px;
    font-size: 13.5px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
}

.btn-compose-side:hover {
    background: var(--color-accent-hover);
}

.compose-side-icon {
    flex: 0 0 auto;
    /* 图标比文字矮一点，靠上抬 1px 让两者视觉居中，而不是被基线拖着往下沉 */
    margin-top: -1px;
}

/* 添加邮箱账号：低频动作，沉到侧栏底部。
   位置变了，视觉分量也跟着降 —— 它还留在顶部当实心主按钮时，
   会跟「写邮件」抢注意力。现在是安静的文字行，只留一条上分隔线。 */
.btn-add-account {
    display: block;
    width: 100%;
    /* 吃掉剩余空间 → 内容不满时钉在侧栏底部 */
    margin-top: auto;
    /* 账号/标签多到把侧栏撑满时，让它始终贴在可视区下沿，
       不用滚到底部才能找到（底色必须盖住滚过去的条目） */
    position: sticky;
    bottom: 0;
    flex: 0 0 auto;
    padding: 10px 10px 12px;
    background: var(--nav-sidebar-bg);
    border: none;
    border-top: 1px solid var(--color-border);
    font-size: 12.5px;
    font-family: inherit;
    color: var(--color-muted);
    text-align: center;
    cursor: pointer;
}

.btn-add-account:hover {
    color: var(--color-accent);
}

.nav-section-title {
    font-size: 11px;
    color: var(--color-faint);
    padding: 10px 8px 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 6px 8px;
    border-radius: 6px;
    font-size: 13px;
    color: var(--color-text);
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

.nav-item:hover {
    background: var(--color-surface-2);
}

.nav-item.active {
    background: var(--color-accent-soft);
    color: var(--color-accent);
    font-weight: 500;
}

.nav-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* 账号同步失败标记：⚠ 跟在小圆点那一行，原因另起一行（见 .nav-reason）。
   为什么要有这两条：光靠小圆点变色，用户根本不知道发生了什么——
   2026-09-20 用户的反馈原话是「我都不知道你这个绿的小圆点代表什么意思」。 */
.nav-flag {
    font-size: 11px;
    color: var(--color-danger);
    flex-shrink: 0;
    margin-right: 2px;
}

.nav-reason {
    margin: 1px 8px 4px 37px;      /* 37px = toggle + dot + gap，与账号名左对齐 */
    padding: 3px 7px;
    font-size: 11px;
    line-height: 1.5;
    border-radius: 5px;
    background: var(--color-danger-soft);
    color: var(--color-danger);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nav-label {
    flex: 1;
    /* min-width:0 是 flex item 能真正收缩的前提；少了它，里面的邮箱名会把整行撑破，
       ellipsis 永远不生效（表现为徽章被挤出侧栏外）。 */
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── 邮箱名：本地名先缩、域名最后缩 ──
   用户的账号本地名高度重复（多个 support@），区分点全在 @ 之后：
   砍本地名 → sup…@voltset.com（一眼分清品牌）；砍域名 → support@vo…（等于没显示）。 */
.nav-mail {
    display: flex;
    min-width: 0;
    overflow: hidden;
}

.nav-mail-local {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    /* 远大于 .nav-mail-domain，确保收缩量几乎全落在本地名上 */
    flex-shrink: 999;
}

.nav-mail-domain {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex-shrink: 1;
    /* 两侧都放不下时（极端窄屏 + 超长域名）也不换行，交给 ellipsis */
    direction: ltr;
}

/* ── 备注名：整串一个名字，不按 @ 拆两段 ──
   备注是用户自己写的一句话（「powoxi 售后主邮箱」这种），没有「域名才是辨识点」这回事，
   所以只有一段、正常收缩即可；上限也由服务端拦在 40 字（REMARK_MAX）。 */
.nav-mail-remark {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nav-badge {
    background: var(--color-accent);
    color: var(--color-on-accent);
    font-size: 11px;
    padding: 1px 6px;
    border-radius: 8px;
    flex-shrink: 0;
}

.nav-item.active .nav-badge {
    background: var(--color-accent);
}

.nav-delete {
    color: var(--color-faint);
    font-size: 14px;
    padding: 0 2px;
    flex-shrink: 0;
}

/* 侧栏标签上的「免回复」提示：该标签的会话不显示待回复/已回复标志 */
.nav-noreply {
    font-size: 10px;
    opacity: 0.7;
    margin-left: 3px;
    flex-shrink: 0;
}

.nav-delete:hover {
    color: var(--color-danger);
}

.nav-add {
    color: var(--color-accent);
    font-size: 12px;
}

.nav-empty {
    font-size: 12px;
    color: var(--color-faint);
    padding: 4px 8px;
}

/* ── 品牌分区 ──
   品牌名做分组横条，账号挂在下面。刻意**不给账号加缩进**：
   层级已经由横条表达，再加一级缩进会把「账号 → 收件箱 → 标签」的
   三级子项推到 50px 开外，240px 的侧栏直接放不下标签名。 */
.nav-brandgroup {
    margin-top: 2px;
}

.nav-brand-head {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 7px 8px 5px;
    border-radius: 6px;
    cursor: pointer;
    user-select: none;
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: 0.05em;
    color: var(--color-muted);
    text-transform: uppercase;
}

.nav-brand-head:hover {
    background: var(--color-surface-2);
    color: var(--color-text);
}

.nav-brand-caret {
    width: 10px;
    flex-shrink: 0;
    font-size: 9px;
    line-height: 1;
    color: var(--color-faint);
    text-align: center;
}

/* 品牌首字母色块。色值由 sidebar.js 的 brandColorOf() 算（名称哈希取固定色板），
   不走主题令牌：品牌之间要能区分，全都跟着 accent 变色就失去了意义。
   色板一律取中明度，浅色/深色主题下配白字对比度都够。 */
.brand-chip {
    width: 16px;
    height: 16px;
    border-radius: 5px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 600;
    color: #FFFFFF;
    letter-spacing: 0;
}

.nav-brand-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 品牌行的未读汇总（该品牌下所有账号之和） */
.nav-brand-count {
    font-size: 11px;
    font-weight: 500;
    color: var(--color-faint);
    letter-spacing: 0;
    flex-shrink: 0;
}

.nav-brand-count.hot {
    color: var(--color-accent);
    font-weight: 600;
}

.nav-brandgroup.collapsed .nav-brand-body {
    display: none;
}

.nav-brand-body {
    padding-bottom: 2px;
}

/* 「未分组」横条：不是真品牌，视觉上降一档（不加粗、不转大写） */
.nav-brand-head.nav-ungrouped {
    text-transform: none;
    font-weight: 500;
    letter-spacing: 0.02em;
    color: var(--color-faint);
}

/* 标签按邮箱账号分组的子标题 */
.nav-group-label {
    font-size: 11px;
    color: var(--color-faint);
    padding: 8px 8px 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 邮箱账号树节点的展开/收起箭头 */
.nav-toggle {
    width: 14px;
    flex-shrink: 0;
    font-size: 10px;
    color: var(--color-faint);
    text-align: center;
    line-height: 1;
}

.nav-toggle:hover {
    color: var(--color-accent);
}

/* 账号树下的子项（收件箱/未读/已发送/最近活跃），缩进一级 */
.nav-item.nav-sub {
    padding-left: 26px;
    font-size: 12.5px;
}

/* 视图行的小图标（📨📥 等） */
.nav-icon {
    width: 16px;
    flex-shrink: 0;
    font-size: 12px;
    text-align: center;
    line-height: 1;
}

/* 账号树下的三级子项（标签分类），缩进两级挂在收件箱下 */
.nav-item.nav-sub2 {
    padding-left: 50px;
    font-size: 12.5px;
}


/* ============================================================
   修：btn-small 与 btn-primary 组合时被浅灰底覆盖，白字浅底不可见
   （.btn-small 定义在 .btn-primary 之后，同权重后者胜出）
   ============================================================ */
.btn.btn-primary.btn-small {
    background: var(--color-accent);
    color: var(--color-on-accent);
    border: 1px solid transparent;
}
.btn.btn-primary.btn-small:hover {
    background: var(--color-accent-hover);
}
.btn.btn-primary.btn-small:disabled {
    background: var(--color-accent-line);
    cursor: not-allowed;
}

/* 「重新分析」用的警示按钮。**必须写成 .btn.btn-warn.btn-small 三段**：
   .btn-small 里那条 `background: var(--color-surface-2)` 与单段的 .btn-warn 同优先级、
   且在文件更后面 —— 单段写法会被它盖成「白底 + 近白字」，按钮直接看不见
   （09-21 实际踩到，靠截图才发现，断言只查类名是查不出来的）。
   取色跟主题走：浅色主题 warning 是深棕、暗色是亮琥珀，文字用背景色反着来，两边都有对比度。 */
.btn.btn-warn.btn-small {
    background: var(--color-warning);
    color: var(--color-bg);
    border: 1px solid transparent;
}
.btn.btn-warn.btn-small:hover {
    background: color-mix(in srgb, var(--color-warning) 85%, #000);
}
.btn.btn-warn.btn-small:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

/* ============================================================
   内容型页面统一留白（会话三栏 / 分栏布局保持通栏）
   ============================================================ */
/* ⚠️ 全屏 fixed 层（遮罩 / 浮层）必须全部排除：**margin 对 fixed 元素照样生效**，
   会把盒子从视口边缘往里推 —— 左侧漏出一条没遮住、右侧反而溢出视口。
   .modal-overlay 09-15 踩过，.lightbox 09-21 又踩一次（实测 rect.x=24、宽=1440）。
   以后新增全屏层，记得同步加进这两个 :not() 列表。
   注意这与「祖先 transform 劫持 containing block」是两个不同的坑（见文件末尾动效系统注释）。 */
main.container > :not(.app-layout):not(.split-layout):not(.modal-overlay):not(.lightbox):not(.ai-rw-layer) {
    margin-left: 24px;
    margin-right: 24px;
}
main.container > :first-child:not(.app-layout):not(.split-layout):not(.modal-overlay):not(.lightbox) {
    margin-top: 24px;
}

/* ====== 通用小件 ====== */
.btn-sm {
    padding: 5px 14px;
    font-size: 12.5px;
}

.btn-ghost {
    background: transparent;
    color: var(--color-muted);
    border: none;
    padding: 7px 16px;
    font-size: 13px;
    font-weight: 500;
}

.btn-ghost:hover {
    background: color-mix(in srgb, var(--color-accent) 8%, var(--color-surface));
    color: var(--color-accent);
}

.pill {
    display: inline-block;
    font-size: 11px;
    line-height: 18px;
    padding: 0 8px;
    border-radius: 999px;
    white-space: nowrap;
    vertical-align: middle;
}

.pill-on {
    background: var(--color-success-soft);
    color: var(--color-success);
}

.pill-off {
    background: var(--color-surface-2);
    color: var(--color-muted);
}

.link-btn {
    background: none;
    border: none;
    padding: 2px 6px;
    border-radius: 4px;
    color: var(--color-accent);
    font-size: 12.5px;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s;
}

.link-btn:hover {
    background: var(--color-accent-soft);
}

.link-btn.muted {
    color: var(--color-muted);
}

.link-btn.muted:hover {
    background: var(--color-surface-2);
}

.link-btn.danger {
    color: var(--color-danger);
}

.link-btn.danger:hover {
    background: var(--color-danger-soft);
}

.btn-ghost.danger {
    color: var(--color-danger);
}

.btn-ghost.danger:hover {
    background: color-mix(in srgb, var(--color-danger) 11%, var(--color-surface));
    color: var(--color-danger);
}

.empty-state {
    padding: 40px 20px;
    text-align: center;
}

.empty-state svg {
    display: block;
    margin: 0 auto 10px;
}

.empty-title {
    font-size: 13.5px;
    color: var(--color-muted);
    margin-bottom: 4px;
}

.empty-desc {
    font-size: 12.5px;
    color: var(--color-faint);
    line-height: 1.7;
}

/* 右栏整体空态时垂直居中 */
.brand-pane > .empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.badge {
    display: inline-block;
    font-size: 11px;
    line-height: 1.5;
    padding: 0 6px;
    border-radius: 4px;
    vertical-align: middle;
}

.badge-off {
    background: var(--color-surface-2);
    color: var(--color-muted);
}

/* 页面底部说明提示 */
.page-note {
    margin-top: 14px;
    padding: 12px 16px;
    background: var(--color-accent-tint);
    border: 1px solid var(--color-accent-line);
    border-radius: 8px;
    font-size: 12.5px;
    color: var(--color-muted);
    line-height: 1.8;
}

.page-note strong {
    color: var(--color-accent-hover);
    font-weight: 600;
}

/* ====== 品牌与产品管理 ====== */
.brand-panel {
    display: grid;
    grid-template-columns: 264px minmax(0, 1fr);
    /* 撑满可视区但把页头与底部说明也算进去，避免整页出现滚动条 */
    height: calc(100vh - 262px);
    min-height: 420px;
    background: var(--color-surface);
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(var(--shadow-rgb), 0.06);
    overflow: hidden;
}

/* 左栏：品牌列表 */
.brand-rail {
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: var(--color-surface-2);
    border-right: 1px solid var(--color-border);
}

.rail-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 16px 10px;
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: 0.4px;
    color: var(--color-muted);
}

.rail-count {
    background: var(--color-surface-2);
    color: var(--color-muted);
    border-radius: 9px;
    padding: 0 7px;
    font-size: 11px;
    font-weight: 500;
    line-height: 18px;
}

.brand-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 0 8px 12px;
}

.brand-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 9px 10px;
    margin-bottom: 2px;
    border: none;
    border-radius: 8px;
    background: transparent;
    font-family: inherit;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s;
}

.brand-item:hover {
    background: var(--color-surface-2);
}

.brand-item.active {
    background: var(--color-accent-soft);
}

.brand-item:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: -2px;
}

.brand-avatar {
    flex-shrink: 0;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.brand-item-main {
    flex: 1;
    min-width: 0;
}

.brand-item-name {
    display: block;
    font-size: 13.5px;
    font-weight: 500;
    color: var(--color-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.brand-item.active .brand-item-name {
    color: var(--color-accent-hover);
}

.brand-item-meta {
    display: block;
    font-size: 11.5px;
    color: var(--color-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.brand-item-count {
    flex-shrink: 0;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 9px;
    padding: 0 7px;
    font-size: 11px;
    line-height: 18px;
    color: var(--color-muted);
}

.brand-item.active .brand-item-count {
    border-color: var(--color-accent-line);
}

.rail-empty {
    padding: 26px 14px;
    text-align: center;
    font-size: 12.5px;
    color: var(--color-faint);
    line-height: 2;
}

/* 右栏：品牌详情 */
.brand-pane {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    overflow-y: auto;
}

.pane-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    padding: 18px 24px 16px;
    border-bottom: 1px solid var(--color-border);
}

.pane-title-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.pane-title {
    font-size: 17px;
    font-weight: 600;
    color: var(--color-text);
}

.pane-sub {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 7px;
    font-size: 12.5px;
    color: var(--color-muted);
}

.pane-sub-label {
    color: var(--color-faint);
}

.pane-head-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.mail-chip {
    display: inline-block;
    background: var(--color-accent-tint);
    color: var(--color-muted);
    border-radius: 999px;
    padding: 1px 10px;
    font-size: 12px;
    line-height: 20px;
}

.mail-chip.warn {
    background: var(--color-danger-soft);
    color: var(--color-danger);
}

.pane-section {
    padding: 16px 24px 24px;
}

.section-head {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.section-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text);
}

.count-badge {
    background: var(--color-surface-2);
    color: var(--color-muted);
    border-radius: 9px;
    padding: 0 7px;
    font-size: 11px;
    font-weight: 500;
    line-height: 18px;
}

.prod-add {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.prod-add input {
    padding: 7px 11px;
    border: 1px solid var(--color-border);
    border-radius: 7px;
    background: var(--color-surface);
    color: var(--color-text);
    font-size: 13px;
    font-family: inherit;
    box-sizing: border-box;
}

.prod-add input:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.12);
}

.prod-add input::placeholder {
    color: var(--color-faint);
}

.prod-add .in-name {
    width: 250px;
}

.prod-add .in-note {
    width: 150px;
}

.prod-add .btn {
    flex: 0 0 auto;
    white-space: nowrap;
}

/* 产品表格 */
.prod-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.prod-table th {
    padding: 0 12px 8px;
    border-bottom: 1px solid var(--color-border);
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: 0.3px;
    color: var(--color-muted);
    text-align: left;
}

.prod-table td {
    padding: 11px 12px;
    border-bottom: 1px solid var(--color-border);
    vertical-align: middle;
}

.prod-table tbody tr:last-child td {
    border-bottom: none;
}

.prod-table tbody tr:hover {
    background: var(--color-surface-2);
}

.prod-table th:first-child,
.prod-table td:first-child {
    padding-left: 4px;
}

.prod-table th.col-actions,
.prod-table td.cell-actions {
    text-align: right;
    white-space: nowrap;
}

.prod-name {
    font-weight: 500;
    color: var(--color-text);
}

.prod-note-cell {
    color: var(--color-muted);
}

.prod-table input.editing {
    width: 100%;
    padding: 6px 9px;
    border: 1px solid var(--color-accent);
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    box-sizing: border-box;
}

.prod-table input.editing:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.12);
}

.brand-modal {
    min-width: 420px;
    max-width: 480px;
}

.brand-modal .account-form input {
    max-width: none;
}

.checkbox-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-height: 220px;
    overflow-y: auto;
    padding: 8px;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    background: var(--color-surface-2);
}

/* label.checkbox-row：提高特异度（0,1,1 同级但靠后），否则被 .account-form label
   的 display:block 压过，flex 失效、勾选框退化为行内基线对齐（视觉上高一块） */
label.checkbox-row {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 7px 8px;
    border-radius: 6px;
    font-size: 13px;
    color: var(--color-text);
    cursor: pointer;
}

.checkbox-row:hover {
    background: var(--color-surface-2);
}

.checkbox-row input {
    width: auto;
    max-width: none;
    margin: 0;
    cursor: pointer;
}

/* ====== 会话产品标记弹窗 ====== */
.product-modal {
    min-width: 420px;
    max-width: 520px;
}

.modal-hint {
    margin: -8px 0 14px;
    font-size: 12.5px;
    color: var(--color-faint);
    line-height: 1.7;
}

/* 编辑标签弹窗：回复判定开关 */
.modal-check {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin: 4px 0 8px;
    font-size: 13.5px;
    color: var(--color-text);
    line-height: 1.6;
    cursor: pointer;
}

.modal-check input[type="checkbox"] {
    /* 旧的原生时代规则（width:auto + accent-color）会把全局自绘框压成一条竖线；
       尺寸与外观一律交给下面的全局自绘规则，这里只保留与首行文字的对齐偏移 */
    margin-top: 3px;
}

/* ---- 全局自绘复选框：原生勾选框是系统画的（默认蓝方块），与天蓝简约不搭。
        appearance:none 自绘：选中后天蓝底白勾，hover 描边变蓝，disabled 淡化。
        全站所有 input[type=checkbox] 统一生效；各处的尺寸规则只改宽高不冲突 ---- */
input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 15px;
    height: 15px;
    /* 表单规则（如 .account-form input 的 8px/10px padding）会把它撑成长方形，这里归零 */
    padding: 0;
    margin: 0;
    /* 非 flex 场景（行内/块级 label）按中线对齐，不跟文字基线走 */
    vertical-align: middle;
    flex: none;
    border: 1px solid var(--color-border-strong);
    border-radius: 4px;
    background: var(--color-surface);
    cursor: pointer;
    transition: background 0.14s var(--ease-out), border-color 0.14s var(--ease-out);
}

input[type="checkbox"]:hover {
    border-color: var(--color-accent);
}

input[type="checkbox"]:checked {
    background: var(--color-accent)
                url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 6.5l2.5 2.5 4.5-5' stroke='white' stroke-width='1.8' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E")
                center / 10px no-repeat;
    border-color: var(--color-accent);
}

input[type="checkbox"]:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

input[type="checkbox"]:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.modal-check-sub {
    color: var(--color-muted);
    font-size: 12.5px;
}

.modal-check + .modal-hint {
    margin: 0 0 4px;
}

.prod-option-list {
    max-height: 320px;
    overflow-y: auto;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 8px;
    background: var(--color-surface-2);
    margin-bottom: 12px;
}

.prod-group + .prod-group {
    margin-top: 10px;
}

.prod-group-title {
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: 0.3px;
    color: var(--color-muted);
    padding: 5px 8px 3px;
}

.prod-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 10px;
    border-radius: 7px;
    font-size: 13.5px;
    color: var(--color-text);
    cursor: pointer;
}

.prod-option:hover {
    background: var(--color-surface-2);
}

.prod-option.selected {
    background: var(--color-accent-soft);
    box-shadow: inset 0 0 0 1px var(--color-accent-line);
}

.prod-option input {
    width: auto;
    max-width: none;
    margin: 0;
    cursor: pointer;
}

.prod-note {
    color: var(--color-faint);
    font-size: 12px;
}

.prod-empty {
    padding: 14px 10px;
    font-size: 13px;
    color: var(--color-faint);
    line-height: 1.7;
}

/* 图表标题下的小注解（如「手工标记」） */
.chart-hint {
    font-size: 11.5px;
    font-weight: 400;
    color: var(--color-faint);
    margin-left: 4px;
}

/* ====== AI 助手 ====== */
.page-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ro-badge {
    font-size: 11.5px;
    color: var(--color-success);
    background: var(--color-success-soft);
    border-radius: 999px;
    padding: 4px 11px;
    white-space: nowrap;
}

.assistant-panel {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 202px);
    min-height: 420px;
    margin-top: 16px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(var(--shadow-rgb), 0.06);
    overflow: hidden;
}

.chat-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 22px 24px 8px;
    background: var(--color-surface-2);
}

/* --- 空态 --- */
.chat-empty {
    text-align: center;
    padding: 44px 20px;
}

.chat-empty-title {
    font-size: 14.5px;
    color: var(--color-text);
    margin-bottom: 6px;
}

.chat-empty-desc {
    font-size: 12.5px;
    color: var(--color-faint);
    margin-bottom: 20px;
}

.chat-samples {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    max-width: 660px;
    margin: 0 auto;
}

.sample-chip {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 999px;
    padding: 7px 14px;
    font-size: 12.5px;
    color: var(--color-text);
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s;
}

.sample-chip:hover {
    border-color: var(--color-accent);
    color: var(--color-accent);
    background: var(--color-accent-tint);
}

/* --- 消息气泡 --- */
.msg-user {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 18px;
}

.msg-user .bubble {
    max-width: 72%;
    background: var(--color-accent);
    color: var(--color-on-accent);
    padding: 10px 14px;
    border-radius: 12px 12px 2px 12px;
    font-size: 13.5px;
    line-height: 1.65;
    word-break: break-word;
}

.msg-ai {
    display: flex;
    gap: 10px;
    margin-bottom: 22px;
    align-items: flex-start;
}

.msg-avatar {
    flex: 0 0 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--color-accent-soft);
    color: var(--color-accent);
    font-size: 11px;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
}

.msg-main {
    flex: 1;
    min-width: 0;
}

.msg-body {
    font-size: 13.5px;
    color: var(--color-text);
    line-height: 1.75;
    word-break: break-word;
}

/* --- 回答内容的轻量排版 --- */
.md-p {
    margin: 3px 0 8px;
}

.md-h {
    font-size: 14px;
    font-weight: 500;
    color: var(--color-text);
    margin: 14px 0 6px;
}

.md-ul {
    margin: 4px 0 9px;
    padding-left: 20px;
}

.md-ul li {
    margin: 3px 0;
}

.md-quote {
    border-left: 3px solid var(--color-border);
    padding: 2px 0 2px 10px;
    margin: 7px 0;
    color: var(--color-muted);
    font-size: 12.5px;
}

.md-table {
    border-collapse: collapse;
    width: auto;
    min-width: 260px;
    max-width: 100%;
    margin: 9px 0 13px;
    font-size: 12.5px;
}

.md-table th,
.md-table td {
    border: 1px solid var(--color-border);
    padding: 6px 10px;
    text-align: left;
}

.md-table th {
    background: var(--color-bg);
    font-weight: 500;
    color: var(--color-text);
}

.msg-body code {
    background: var(--color-surface-2);
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 12px;
}

.msg-error {
    display: inline-block;
    color: var(--color-danger);
    background: var(--color-danger-soft);
    border-radius: 7px;
    padding: 8px 12px;
    font-size: 12.5px;
}

/* --- 查询步骤时间线 --- */
.msg-steps {
    margin-bottom: 10px;
}

.steps-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 7px;
    padding: 5px 11px;
    font-size: 12px;
    color: var(--color-muted);
    font-family: inherit;
    cursor: pointer;
}

.steps-toggle:hover {
    background: var(--color-surface-2);
}

.steps-caret {
    color: var(--color-faint);
    font-size: 10px;
}

.steps-count {
    color: var(--color-faint);
}

.steps-body {
    display: none;
    margin-top: 9px;
    padding-left: 13px;
    border-left: 2px solid var(--color-border);
}

.msg-steps.open .steps-body {
    display: block;
}

.step-line {
    position: relative;
    padding: 4px 0 4px 4px;
    font-size: 12.5px;
    color: var(--color-text);
}

.step-dot {
    position: absolute;
    left: -17px;
    top: 9px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--color-surface-3);
}

.step-think .step-text {
    color: var(--color-faint);
}

.step-ok .step-dot {
    background: var(--color-success-solid);
}

.step-fail .step-dot {
    background: var(--color-danger-solid);
}

.step-run .step-dot.spin {
    background: var(--color-accent);
    animation: stepPulse 1s ease-in-out infinite;
}

@keyframes stepPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.step-meta {
    margin-left: 7px;
    color: var(--color-faint);
    font-size: 12px;
}

.step-preview {
    display: none;
    margin-top: 7px;
    padding: 8px 10px;
    background: var(--color-surface-2);
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-family: ui-monospace, Menlo, Consolas, monospace;
    font-size: 11.5px;
    color: var(--color-muted);
    white-space: pre-wrap;
    max-height: 160px;
    overflow: auto;
}

.step-line.expanded .step-preview {
    display: block;
}

.step-line.step-ok,
.step-line.step-fail {
    cursor: pointer;
}

/* --- 等待动画 --- */
.thinking {
    display: inline-flex;
    gap: 4px;
    padding: 7px 0;
}

.thinking span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--color-surface-3);
    animation: thinkBlink 1.2s infinite;
}

.thinking span:nth-child(2) { animation-delay: 0.2s; }
.thinking span:nth-child(3) { animation-delay: 0.4s; }

@keyframes thinkBlink {
    0%, 80%, 100% { opacity: 0.3; }
    40% { opacity: 1; }
}

/* --- 输入栏 --- */
.chat-input-bar {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding: 13px 18px;
    border-top: 1px solid var(--color-border);
    background: var(--color-surface);
}

.chat-input-bar textarea {
    flex: 1 1 auto;
    width: auto;
    min-width: 0;
    resize: none;
    max-height: 140px;
    padding: 9px 12px;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    font-family: inherit;
    font-size: 13.5px;
    line-height: 1.6;
    color: var(--color-text);
    outline: none;
}

.chat-input-bar textarea:focus {
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.1);
}

.chat-input-bar textarea:disabled {
    background: var(--color-bg);
    color: var(--color-faint);
}

.chat-input-bar .btn {
    flex: 0 0 auto;
}

/* ====== AI 提示词管理（邮箱账号页） ====== */
.modal-prompt {
    width: 620px;
    max-width: 92vw;
    max-height: 86vh;
    overflow-y: auto;
}

.prompt-list {
    border: 1px solid var(--color-border);
    border-radius: 8px;
    max-height: 30vh;
    overflow-y: auto;
    background: var(--color-surface-2);
    margin-bottom: 14px;
}

.prompt-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 10px 12px;
}

.prompt-item + .prompt-item {
    border-top: 1px solid var(--color-border);
}

.prompt-item:hover {
    background: var(--color-bg);
}

.prompt-item-main {
    flex: 1;
    min-width: 0;
}

.prompt-item-name {
    font-size: 13px;
    color: var(--color-text);
    margin-bottom: 3px;
}

.prompt-item-preview {
    font-size: 12px;
    color: var(--color-muted);
    line-height: 1.5;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.prompt-item-actions {
    display: flex;
    gap: 2px;
    flex-shrink: 0;
}

.prompt-editor {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.prompt-editor input[type="text"],
.prompt-editor textarea {
    width: 100%;
    box-sizing: border-box;
    padding: 9px 12px;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    font-size: 13px;
    font-family: inherit;
    line-height: 1.6;
    color: var(--color-text);
}

.prompt-editor textarea {
    resize: vertical;
    min-height: 120px;
}

.prompt-editor input[type="text"]:focus,
.prompt-editor textarea:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.12);
}

.modal-prompt .acc-msg {
    margin-right: auto;
}

/* ============================================================
   邮件搜索（会话列表左侧：搜索入口 + 邮件级结果列表）
   ============================================================ */
.split-left .search-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px 10px;
    border-bottom: 1px solid var(--color-border);
    flex-shrink: 0;
}

/* 左侧栏窄（340px）：「月份 + 通知」放不下时整块换到第二行，标题不折字（超长省略号）；
   搜索时收起「月份」筛选（月份对搜索结果不生效），标题与通知按钮回到同一行 */
.split-left .page-header {
    flex-wrap: wrap;
    row-gap: 8px;
}

.split-left .page-header h1 {
    flex: 1 1 auto;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.split-left .filter {
    flex: 0 0 auto;
    margin-left: auto;
}

.split-left .filter button,
.split-left .filter select {
    white-space: nowrap;
}

.split-left .filter.searching label,
.split-left .filter.searching select,
.split-left .filter.searching .month-dd {
    display: none;
}

/* ---- 月份自绘下拉：原生 select 的弹出列表是操作系统画的、CSS 管不着，
        所以 UI 自绘；select 仍留在 DOM（hidden）当唯一数据源，旧代码照常读写 ---- */
.month-dd {
    position: relative;
}

.month-dd-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 5px 10px 5px 12px;
    font-size: 12.5px;
    font-family: inherit;
    color: var(--color-text);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 999px;
    cursor: pointer;
    transition: border-color 0.16s var(--ease-out), box-shadow 0.16s var(--ease-out);
}

.month-dd-btn:hover {
    border-color: var(--color-border-strong);
}

.month-dd-btn .chev {
    width: 10px;
    height: 6px;
    flex-shrink: 0;
    transition: transform 0.16s var(--ease-out);
}

.month-dd.is-open .month-dd-btn {
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(var(--accent-rgb), .12);
}

.month-dd.is-open .month-dd-btn .chev {
    transform: rotate(180deg);
}

.month-dd-list {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 132px;
    max-height: 268px;
    overflow-y: auto;
    padding: 4px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(var(--shadow-rgb), .16);
    z-index: 60;
    display: none;
}

.month-dd.is-open .month-dd-list {
    display: block;
    animation: month-dd-in 0.14s var(--ease-out);
}

@keyframes month-dd-in {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }
}

.month-dd-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: 7px 12px;
    font-size: 12.5px;
    font-family: inherit;
    color: var(--color-text);
    background: none;
    border: none;
    border-radius: 8px;
    cursor: pointer;
}

.month-dd-item:hover,
.month-dd-item.is-hover {
    background: color-mix(in srgb, var(--color-accent) 10%, var(--color-surface));
}

.month-dd-item.is-active {
    background: var(--color-accent-soft);
    color: var(--color-accent);
    font-weight: 600;
}

@media (prefers-reduced-motion: reduce) {
    .month-dd-btn .chev,
    .month-dd-list {
        transition: none;
        animation: none;
    }
}

/* ---- 列表顶栏控件组：标题收敛 + 月份/通知统一为小胶囊，高度对齐 ---- */
.split-left .page-header {
    padding: 12px 16px 10px;
    margin-bottom: 10px;
}

.split-left .page-header h1 {
    font-size: 17px;
}

.split-left .filter {
    gap: 8px;
}

.split-left .filter label {
    font-size: 12px;
    color: var(--color-muted);
}

.split-left .filter select {
    appearance: none;
    -webkit-appearance: none;
    padding: 5px 30px 5px 12px;
    font-size: 12.5px;
    border: 1px solid var(--color-border);
    border-radius: 999px;
    background-color: var(--color-surface);
    background-image: var(--select-arrow);
    background-repeat: no-repeat;
    background-position: right 11px center;
    transition: border-color 0.16s var(--ease-out), box-shadow 0.16s var(--ease-out);
}

.split-left .filter select:hover {
    border-color: var(--color-border-strong);
}

.split-left .filter select:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(var(--accent-rgb), .12);
}

.search-input {
    flex: 1;
    min-width: 0;
    padding: 8px 12px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-size: 13.5px;
    font-family: inherit;
    color: var(--color-text);
    background: var(--color-surface);
}

.search-input:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.1);
}

/* 高级筛选开关的选中态（.btn-ghost 基础上加深色描边） */
.btn-ghost.active {
    background: var(--color-accent-soft);
    color: var(--color-accent);
}

.search-advanced {
    display: none;
    grid-template-columns: 1fr 1fr;
    gap: 8px 10px;
    margin: 0 16px 12px;
    padding: 12px;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    background: var(--color-surface-2);
    flex-shrink: 0;
}

.search-advanced.open {
    display: grid;
}

.search-advanced label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
    font-size: 12px;
    color: var(--color-muted);
}

.search-advanced input {
    width: 100%;
    box-sizing: border-box;
    padding: 6px 8px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-size: 12.5px;
    font-family: inherit;
    color: var(--color-text);
    background: var(--color-surface);
}

.search-advanced input:focus {
    outline: none;
    border-color: var(--color-accent);
}

.search-advanced-actions {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: 2px;
}

.search-hint {
    font-size: 11.5px;
    color: var(--color-faint);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.search-summary {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 16px;
    flex-shrink: 0;
}

.split-left .search-summary .stat-item {
    padding: 6px 12px;
    font-size: 12.5px;
}

.search-results {
    flex: 1;
    overflow-y: auto;
}

.search-result {
    padding: 12px 16px;
    border-bottom: 1px solid var(--color-border);
    cursor: pointer;
    transition: background 0.15s;
}

.search-result:hover {
    background: var(--color-bg);
}

.search-result.active {
    background: var(--color-accent-soft);
    border-left: 3px solid var(--color-accent);
}

.search-result.unread {
    border-left: 3px solid var(--color-accent);
}

.search-result-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
    font-size: 12px;
}

.sr-dir {
    flex-shrink: 0;
    padding: 0 6px;
    border-radius: 999px;
    font-size: 11px;
    line-height: 18px;
}

.sr-dir.incoming {
    background: var(--color-accent-soft);
    color: var(--color-accent);
}

.sr-dir.outgoing {
    background: var(--color-success-soft);
    color: var(--color-success);
}

.sr-who {
    flex: 1;
    min-width: 0;
    color: var(--color-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sr-date {
    flex-shrink: 0;
    color: var(--color-faint);
}

.search-result-subject {
    font-size: 14px;
    font-weight: 500;
    color: var(--color-text);
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.search-snippet {
    font-size: 12.5px;
    color: var(--color-muted);
    line-height: 1.6;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
}

.search-snippet mark,
.search-result-subject mark {
    background: var(--color-warning-soft);
    color: var(--color-warning);
    padding: 0 1px;
    border-radius: 2px;
}

.search-result-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
    font-size: 11.5px;
    color: var(--color-faint);
}

.sr-field {
    padding: 0 7px;
    border-radius: 999px;
    background: var(--color-surface-2);
    color: var(--color-muted);
}

.search-empty {
    padding: 40px 20px;
    text-align: center;
    color: var(--color-faint);
    font-size: 14px;
    line-height: 2;
}

.search-empty-hint {
    font-size: 12px;
    color: var(--color-faint);
}

/* 从搜索结果点进来时，定位到的那封邮件闪一下 */
.email-item.flash {
    box-shadow: 0 0 0 2px var(--color-accent);
    transition: box-shadow 0.3s;
}

/* ==========================================================================
   深浅色切换器（导航栏右侧）—— 全站共用，sky / dark 两档一键切换
   拇指位置：浅色靠左（灰），深色靠右（强调色），只动 transform，reduced-motion 下关闭
   ========================================================================== */
.theme-toggle {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 10px;
    border: 1px solid var(--color-border);
    border-radius: 999px;
    background: var(--color-surface-2);
    flex-shrink: 0;
}

.theme-toggle-label {
    font-size: 11px;
    color: var(--color-faint);
    letter-spacing: 0.3px;
    white-space: nowrap;
}

.theme-toggle-btn {
    position: relative;
    width: 40px;
    height: 22px;
    padding: 0;
    border: 1px solid var(--color-border-strong);
    border-radius: 999px;
    background: var(--color-surface-3);
    cursor: pointer;
    flex-shrink: 0;
}

.theme-toggle-thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--color-faint);
    box-shadow: inset 0 0 0 1px rgba(var(--shadow-rgb), 0.2);
    transition: transform 0.3s var(--ease-out), background 0.3s var(--ease-out);
}

/* 深色档：拇指滑到右侧、变强调色，一眼区分两档 */
[data-theme="dark"] .theme-toggle-thumb {
    transform: translateX(18px);
    background: var(--color-accent);
}

.theme-toggle-btn:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    .theme-toggle-thumb {
        transition: none;
    }
}

/* 暗色下投影几乎不可见，改用一条发丝线划分导航栏 */
[data-theme="dark"] .navbar {
    box-shadow: none;
    border-bottom: 1px solid var(--color-border);
}

/* ==========================================================================
   数字排版：等宽数字，计数变化时不跳动、右对齐更整齐
   ========================================================================== */
.conv-item-date,
.conv-item-count,
.conv-item-id,
.count-badge,
.nav-badge,
.unread-badge,
.tag-count,
.tag-unread,
.stat-item strong,
.stats-overview strong {
    font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   动效系统：入场序列 / 列表错峰 / 弹窗 / 微交互
   --------------------------------------------------------------------------
   三条硬约束（都是踩过或推演过的坑，别改回去）：
   1. 只动 opacity 与 transform —— 两者走合成层，不触发重排。颜色过渡平时全站
      不挂常驻 transition，只在切主题那一瞬开启（见 .theme-anim）。
   2. 绝不给 body / main.container 加 transform 或 filter。.modal-overlay 与
      .lightbox 是它们的 fixed 子元素，祖先一旦建立 containing block，全屏遮罩
      的定位基准就被劫持（09-15 真实故障：遮罩被推右 24px、左边漏出一条）。
      所以入场动画一律加在 main 的"直接子块"上，并把这两个全屏层排除。
      ⚠️ 09-21 又出了一模一样的症状，但根因不同：是「内容型页面统一留白」那条
      margin 规则漏排除了 .lightbox（margin 对 fixed 元素同样生效）。两处都要保住，
      见 `main.container > :not(...)` 那段的注释。
   3. animation 一律用 backwards 而不是 both：both 会把最终值锁死在动画上，
      而动画优先级高于普通声明，会让元素 hover 的 transform 彻底失效（悬停
      位移就没了）。backwards 只在延迟期生效，播完自然回落到元素的声明值。
   ========================================================================== */

/* ── 关键帧（只写 from，to 缺省即元素自然态，与 backwards 配合最干净）──
   nav-in 已删（用户反馈：顶栏每次切页都下滑一下很怪，导航栏不参与入场） */

@keyframes page-in {
    from { opacity: 0; transform: translateY(10px); }
}

@keyframes item-in {
    from { opacity: 0; transform: translateY(7px); }
}

@keyframes overlay-in {
    from { opacity: 0; }
}

@keyframes modal-in {
    from { opacity: 0; transform: translateY(12px) scale(0.97); }
}

/* ── 1. 页面入场：主内容块错峰上浮（顶栏不加动画，别加回去） ── */
main.container > :not(.modal-overlay):not(.lightbox) {
    animation: page-in 0.44s cubic-bezier(0.16, 1, 0.3, 1) backwards;
}

main.container > :not(.modal-overlay):not(.lightbox):nth-child(2) { animation-delay: 0.08s; }
main.container > :not(.modal-overlay):not(.lightbox):nth-child(3) { animation-delay: 0.14s; }
main.container > :not(.modal-overlay):not(.lightbox):nth-child(n+4) { animation-delay: 0.18s; }

/* ── 2. 列表错峰：会话 / 搜索结果逐条上浮
   只给前 9 条排期，之后同步出现，长列表不会拖出一条越来越慢的尾巴 ── */
.conversation-list .conv-item,
.search-results .search-result {
    animation: item-in 0.3s cubic-bezier(0.16, 1, 0.3, 1) backwards;
}

.conversation-list .conv-item:nth-child(2),
.search-results .search-result:nth-child(2) { animation-delay: 0.03s; }
.conversation-list .conv-item:nth-child(3),
.search-results .search-result:nth-child(3) { animation-delay: 0.06s; }
.conversation-list .conv-item:nth-child(4),
.search-results .search-result:nth-child(4) { animation-delay: 0.09s; }
.conversation-list .conv-item:nth-child(5),
.search-results .search-result:nth-child(5) { animation-delay: 0.12s; }
.conversation-list .conv-item:nth-child(6),
.search-results .search-result:nth-child(6) { animation-delay: 0.15s; }
.conversation-list .conv-item:nth-child(7),
.search-results .search-result:nth-child(7) { animation-delay: 0.18s; }
.conversation-list .conv-item:nth-child(8),
.search-results .search-result:nth-child(8) { animation-delay: 0.21s; }
.conversation-list .conv-item:nth-child(n+9),
.search-results .search-result:nth-child(n+9) { animation-delay: 0.24s; }

/* ── 3. 会话详情：邮件逐条淡入，切换会话时形成层次 ── */
.email-item {
    animation: item-in 0.32s cubic-bezier(0.16, 1, 0.3, 1) backwards;
}

.email-item:nth-child(2) { animation-delay: 0.05s; }
.email-item:nth-child(3) { animation-delay: 0.10s; }
.email-item:nth-child(4) { animation-delay: 0.15s; }
.email-item:nth-child(n+5) { animation-delay: 0.18s; }

/* ── 4. 弹窗与灯箱：遮罩淡入 + 面板轻微放大回弹
   弹窗是 JS 用 style.display 切换的（不是加 class），元素从 none 变可见时
   animation 会自动重播 —— 所以这里零 JS 改动就有出入场 ── */
.modal-overlay {
    animation: overlay-in 0.18s ease-out backwards;
}

.modal {
    animation: modal-in 0.26s cubic-bezier(0.34, 1.3, 0.64, 1) backwards;
    animation-delay: 0.03s;
}

.lightbox {
    animation: overlay-in 0.2s ease-out backwards;
}

.lightbox img {
    animation: modal-in 0.3s cubic-bezier(0.34, 1.3, 0.64, 1) backwards;
    animation-delay: 0.04s;
}

/* ── 5. 导航：悬停时下划线从左侧扫出，比单纯变底色更有"意图感" ── */
.nav-link {
    position: relative;
}

.nav-link::after {
    content: '';
    position: absolute;
    /* 跟着 .nav-link 的左右 padding 走，改了 padding 记得一起改，否则下划线不对齐文字 */
    left: 14px;
    right: 14px;
    bottom: 4px;
    height: 2px;
    border-radius: 2px;
    background: var(--color-accent);
    transform: scaleX(0);
    transform-origin: left center;
    transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

.nav-link:hover::after {
    transform: scaleX(1);
}

/* ── 6. 按压反馈：点下去有回缩，消除"死按钮"感 ── */
.btn:active,
.btn-small:active,
.btn-sm:active,
.nav-sidebar button:active {
    transform: scale(0.97);
}

/* ── 7. 侧栏条目：悬停右移 2px，暗示可点 ── */
#quick-view-list > *,
#account-list > * {
    transition: transform 0.16s cubic-bezier(0.16, 1, 0.3, 1),
                background 0.16s var(--ease-out),
                color 0.16s var(--ease-out);
}

#quick-view-list > *:hover,
#account-list > *:hover {
    transform: translateX(2px);
}

/* ── 8. 切主题那一瞬的全局颜色过渡
   只在切换的 300ms 内挂上（由 theme.js 加/摘 .theme-anim），
   平时全站不背这个 transition ── */
html.theme-anim,
html.theme-anim *,
html.theme-anim *::before,
html.theme-anim *::after {
    transition: background-color 0.3s ease,
                border-color 0.3s ease,
                color 0.3s ease,
                fill 0.3s ease,
                box-shadow 0.3s ease !important;
}

/* ── 9. 无障碍：系统开了"减少动态效果"就全部关掉 ── */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.001ms !important;
        animation-delay: 0ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
}

/* ====== 通用确认弹窗（替代原生 confirm，见 static/js/confirm.js） ====== */
.confirm-overlay {
    /* 叠在其它弹窗之上（比如"清除产品标记"是在产品弹窗开着时触发的） */
    z-index: 11000;
}

.confirm-modal {
    max-width: 420px;
    min-width: 300px;
}

.confirm-msg {
    margin: 0 0 4px;
    font-size: 14px;
    line-height: 1.7;
    color: var(--color-text);
    white-space: pre-line;   /* 消息里带的 \n 正常换行 */
}

/* 危险确认键：红实心（.btn-danger 的淡红底在"不可恢复"场景不够重） */
.btn-danger-solid {
    background: var(--color-danger-solid) !important;
    color: var(--color-on-danger) !important;
}

.btn-danger-solid:hover {
    background: var(--color-danger-solid) !important;
    filter: brightness(1.08);
}

/* ====== 待回复「不需回复」豁免 ====== */

/* 已豁免会话的安静标记（列表里可见，方便找回） */
.reply-badge.reply-exempt {
    background: var(--color-surface-3);
    color: var(--color-faint);
}

/* 多选态的勾选框：平时不出现（右键 →「批量选择…」才进这个态） */
.conv-check {
    display: none;
    flex: none;
    width: 16px;
    height: 16px;
    line-height: 15px;
    text-align: center;
    font-size: 10px;
    border-radius: 4px;
    border: 1px solid var(--color-border-strong);
    color: transparent;
    cursor: pointer;
    user-select: none;
    background: var(--color-surface);
    margin-right: 2px;
}

body.batch-mode .conv-check {
    display: block;
}

.conv-check.on,
.conv-check:hover {
    background: var(--color-accent);
    border-color: var(--color-accent);
    color: var(--color-on-accent);
}

/* 多选态底部操作条 */
#exempt-bar {
    position: fixed;
    bottom: 22px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 16px;
    background: var(--color-surface);
    border: 1px solid var(--color-border-strong);
    border-radius: 12px;
    box-shadow: 0 6px 24px rgba(var(--shadow-rgb), 0.18);
    z-index: 80;
}

#exempt-bar .exm-hint {
    font-size: 13px;
    color: var(--color-muted);
}

#exempt-bar .exm-hint b {
    color: var(--color-text);
}

#exempt-bar .exm-btn {
    border: 1px solid var(--color-accent);
    background: var(--color-accent);
    color: var(--color-on-accent);
    font-size: 13px;
    padding: 4px 14px;
    border-radius: 8px;
    cursor: pointer;
}

#exempt-bar .exm-btn:hover {
    background: var(--color-accent-hover);
    border-color: var(--color-accent-hover);
}

#exempt-bar .exm-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

#exempt-bar .exm-btn-ghost {
    background: var(--color-surface);
    color: var(--color-accent);
}

#exempt-bar .exm-btn-ghost:hover {
    background: var(--color-accent-soft);
}

/* ====== 会话列表右键菜单 ====== */
.conv-menu {
    position: fixed;
    z-index: 90;
    min-width: 172px;
    padding: 5px;
    background: var(--color-surface);
    border: 1px solid var(--color-border-strong);
    border-radius: 10px;
    box-shadow: 0 8px 28px rgba(var(--shadow-rgb), 0.22);
    font-size: 13px;
}

.conv-menu-item {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding: 7px 10px;
    border-radius: 6px;
    color: var(--color-text);
    cursor: pointer;
    white-space: nowrap;
}

#email-menu .conv-menu-item {
    width: 100%;
    border: 0;
    background: transparent;
    font: inherit;
    text-align: left;
}
#email-menu .conv-menu-item:hover { background: var(--color-accent-soft); }
#email-menu .conv-menu-item.is-danger:hover { background: var(--color-danger-soft); }
#email-menu .conv-menu-item:disabled { opacity: 0.5; cursor: default; }
.email-customer {
    color: var(--color-muted);
    font-size: 12px;
    max-width: 240px;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.email-fold .email-customer { max-width: 180px; }
#email-customer-modal .modal { width: 420px; max-width: calc(100vw - 48px); }
#email-customer-input {
    box-sizing: border-box;
    width: 100%;
    margin: 8px 0;
    padding: 10px 12px;
    border: 1px solid var(--color-border-strong);
    border-radius: 6px;
    background: var(--color-surface);
    color: var(--color-text);
    font: inherit;
}
#email-customer-input:focus { outline: none; border-color: var(--color-accent); }
#email-customer-hint { min-height: 20px; }

.conv-menu-item:hover {
    background: var(--color-accent-soft);
    color: var(--color-accent);
}

.conv-menu-item.is-danger {
    color: var(--color-danger);
}

.conv-menu-item.is-danger:hover {
    background: var(--color-danger-soft);
}

.conv-menu-item.is-disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.conv-menu-item.is-disabled:hover {
    background: none;
    color: var(--color-text);
}

.conv-menu-hint {
    font-size: 11px;
    color: var(--color-faint);
}

.conv-menu-sep {
    height: 1px;
    margin: 4px 6px;
    background: var(--color-border);
}

/* toast 里的撤销链接 */
.undo-exempt-link {
    text-decoration: underline;
    cursor: pointer;
}

/* ====== 写邮件弹窗 ======
   编辑器整块复用回复那一套 DOM，这里只补弹窗里的尺寸差异。
   滚动沿用 .modal 的默认行为（整块滚、限高内部滚）—— 与模板编辑弹窗一致，
   也可以避免给编辑器套一层 overflow 把「模板 ▾」的浮层裁掉。 */
.modal-compose {
    width: min(880px, calc(100vw - 48px));
    padding: 0;
}

/* 弹窗标题行：左边是标题（不再是回复框那种「模式胶囊」），右边是一个真正的关闭按钮 */
.compose-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-bottom: 1px solid var(--color-border);
}

.compose-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text);
}

.compose-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    padding: 0;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--color-faint);
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.compose-close:hover {
    background: var(--color-surface-2);
    color: var(--color-text);
}

.modal-compose .reply-composer {
    border: none;
    border-radius: 0;
    margin-bottom: 0;
    background: var(--color-surface);
}

.modal-compose .reply-body-rich {
    min-height: 220px;
    /* 弹窗自己会滚，正文再限高就成了两层滚动条 */
    max-height: none;
}

/* 弹窗里字段多，标签宽一点对齐 */
.modal-compose .reply-label {
    width: 46px;
}

/* ====== AI 写作辅助：选中浮层（AI 帮你改）+ AI 菜单里的起草行 ====== */

/* 浮层挂在 body 下、fixed 定位，位置由 ai.js 算，这里只管外观与层级。
   层级阶梯：toast 9999 < 蒙层 10000 < 模板弹窗 10100 < AI 浮层 10200 < 确认框 11000。
   浮层要能压过写邮件弹窗（它就在弹窗里用），但不能盖住确认框。 */
.ai-rw-layer {
    position: fixed;
    inset: 0;
    pointer-events: none;          /* 自己不吃事件，只有里面的按钮和面板可点 */
    z-index: 10200;
}

.ai-rw-btn {
    position: fixed;
    pointer-events: auto;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 10px;
    border: 1px solid var(--color-border);
    border-radius: 14px;
    background: var(--color-surface);
    color: var(--color-text);
    font-size: 12.5px;
    line-height: 1.4;
    font-family: inherit;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(var(--shadow-rgb), 0.16);
    transition: background 0.15s, border-color 0.15s;
}

.ai-rw-btn:hover,
.ai-rw-btn.open {
    background: var(--color-surface-2);
    border-color: var(--color-accent);
}

.ai-rw-spark {
    color: var(--color-accent);
    font-size: 11px;
    line-height: 1;
}

.ai-rw-panel {
    position: fixed;
    pointer-events: auto;
    width: 258px;
    padding: 8px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 10px;
    box-shadow: 0 6px 22px rgba(var(--shadow-rgb), 0.18);
}

.ai-rw-input {
    width: 100%;
    box-sizing: border-box;
    padding: 7px 10px;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    background: var(--color-surface);
    color: var(--color-text);
    font-size: 12.5px;
    font-family: inherit;
}

.ai-rw-input:focus {
    outline: none;
    border-color: var(--color-accent);
}

.ai-rw-input::placeholder {
    color: var(--color-faint);
}

.ai-rw-menu {
    margin-top: 6px;
}

.ai-rw-menu.busy {
    opacity: 0.55;
    pointer-events: none;
}

.ai-rw-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 7px 9px;
    border-radius: 6px;
    font-size: 12.5px;
    color: var(--color-text);
    cursor: pointer;
}

.ai-rw-item:hover {
    background: var(--color-surface-2);
}

.ai-rw-arrow {
    color: var(--color-faint);
    font-size: 13px;
    line-height: 1;
}

/* 「其他」的二级菜单：fixed 定位，空间不够时由 ai.js 翻到左边 */
.ai-rw-sub {
    position: fixed;
    width: 132px;
    padding: 4px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(var(--shadow-rgb), 0.16);
    z-index: 10210;
}

.ai-rw-sep {
    height: 1px;
    margin: 5px 4px;
    background: var(--color-border);
}

.ai-rw-off {
    justify-content: flex-start;
    color: var(--color-muted);
}

.ai-rw-status {
    margin-top: 6px;
    padding: 6px 9px;
    border-radius: 6px;
    background: var(--color-surface-2);
    color: var(--color-muted);
    font-size: 12px;
    line-height: 1.5;
}

/* —— 「AI 生成 ▾」菜单里的「一句话起草」行 —— */
#rtb-ai-menu {
    /* 输入框 + 「起草」按钮并排。占位文案「告诉我你想写什么，我来帮你起草」有 15 个字，
       268px 时会被截成「…我来帮你起」，所以这里要留够（实测 330px 刚好放全）。 */
    min-width: 330px;
}

.rtb-ai-free {
    padding: 4px 6px 2px;
}

.rtb-ai-free-title {
    margin-bottom: 5px;
    font-size: 11.5px;
    color: var(--color-muted);
}

.rtb-ai-free-row {
    display: flex;
    gap: 6px;
}

.rtb-ai-free-input {
    flex: 1;
    min-width: 0;
    padding: 6px 9px;
    border: 1px solid var(--color-border);
    border-radius: 7px;
    background: var(--color-surface);
    color: var(--color-text);
    font-size: 12.5px;
    font-family: inherit;
}

.rtb-ai-free-input:focus {
    outline: none;
    border-color: var(--color-accent);
}

.rtb-ai-free-input::placeholder {
    color: var(--color-faint);
}

.rtb-ai-free-btn {
    flex: none;
    padding: 0 12px;
    border: none;
    border-radius: 7px;
    background: var(--color-accent);
    color: var(--color-on-accent);
    font-size: 12.5px;
    font-family: inherit;
    cursor: pointer;
}

.rtb-ai-free-btn:hover {
    background: var(--color-accent-hover);
}

.rtb-ai-tip {
    padding: 2px 8px 4px;
    font-size: 11.5px;
    color: var(--color-faint);
}

/* ==========================================================================
   售后登记：平台 + 订单号 / 物流单号
   （会话标记弹窗的下半区、「品牌与产品」页的平台页签、详情页的单号 chip）
   ========================================================================== */

/* ====== 「品牌与产品」页：品牌 / 平台 页签 ====== */
.page-tabs {
    display: flex;
    gap: 2px;
    margin-bottom: 18px;
    border-bottom: 1px solid var(--color-border);
}

.page-tab {
    border: 0;
    border-bottom: 2px solid transparent;
    /* 底下 1px 的分隔线要和页签的下边框严丝合缝对齐，靠这 -1px 让页签压在线上面 */
    margin-bottom: -1px;
    background: transparent;
    font: inherit;
    font-size: 14px;
    color: var(--color-muted);
    padding: 9px 14px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    transition: color 0.15s var(--ease-out), border-color 0.15s var(--ease-out);
}

.page-tab:hover {
    color: var(--color-text);
}

.page-tab.active {
    color: var(--color-accent);
    font-weight: 600;
    border-bottom-color: var(--color-accent);
}

/* 平台面板：与品牌面板同一张白卡的语言，但单栏 —— 平台没有下挂实体 */
.pf-panel {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 18px 20px;
}

/* 「已登记」列：判断这个平台能不能删的依据，所以数字要看得见 */
.pf-used {
    font-size: 12.5px;
    color: var(--color-muted);
}

.pf-used b {
    font-weight: 600;
    color: var(--color-text);
}

.pf-used-none {
    color: var(--color-faint);
}

/* ====== 标记产品弹窗：售后登记分区的分隔线 ====== */
.reg-divider {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 2px 0 12px;
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: 0.4px;
    color: var(--color-faint);
}

.reg-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--color-border);
}

.reg-field {
    margin-bottom: 12px;
}

.reg-field > label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--color-muted);
    margin-bottom: 7px;
}

.reg-sub {
    font-weight: 400;
    color: var(--color-faint);
}

/* 订单号 + 物流单号并排。两格而不是一格：合成一格必然出现「A 填订单号、
   B 填物流号」的混填，之后按单号对账就废了 */
.reg-two {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

/* ⚠️ 这里**故意不写输入框外观** —— 交给 `.modal input[type="text"]:not(.modal-compose *)`
   （实测特异性 0,3,1）统一管，两个单号框才会和上面的搜索框长得一模一样。
   硬要改外观必须带 id 提权（`#product-modal .reg-two input`）；
   写成 `.reg-two input`（0,1,1）永远输给它 —— 这条踩过。 */
#product-modal .reg-two input {
    margin-bottom: 0;
}

/* ====== 平台胶囊：一格一选，末尾挂「+ 新增平台」 ====== */
.pf-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}

.pf-chip {
    border: 1px solid var(--color-border-strong);
    background: var(--color-surface);
    color: var(--color-text);
    font: inherit;
    font-size: 13px;
    padding: 7px 13px;
    border-radius: 20px;
    cursor: pointer;
    transition: background 0.14s var(--ease-out),
                border-color 0.14s var(--ease-out),
                color 0.14s var(--ease-out);
}

.pf-chip:hover {
    border-color: var(--color-accent-line);
    background: var(--color-accent-tint);
}

/* 加态必须排在基础类之后：同为单类选择器，后定义者胜 */
.pf-chip.on {
    background: var(--color-accent-soft);
    border-color: var(--color-accent);
    color: var(--color-accent);
    font-weight: 600;
}

.pf-chip.off {
    color: var(--color-faint);
    border-style: dashed;
}

.pf-chip.add {
    border-style: dashed;
    border-color: var(--color-accent-line);
    color: var(--color-accent);
    background: transparent;
}

.pf-chip.add:hover {
    background: var(--color-accent-soft);
}

/* 就地新增平台的输入行（点「+ 新增平台」后原地展开，不套第二层弹窗） */
.pf-chip-add {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

/* 这个框要和旁边的胶囊同一副长相（20px 圆角、矮一点），所以必须带 id 提权 ——
   带 id 的本规则（1,2,1）压得住通用弹窗输入框规则（0,3,1）。 */
#product-modal .pf-chip-add input {
    width: 150px;
    padding: 6px 11px;
    border: 1px solid var(--color-accent);
    border-radius: 20px;
    background: var(--color-surface);
    color: var(--color-text);
    font-size: 13px;
    font-family: inherit;
}

#product-modal .pf-chip-add input:focus {
    outline: none;
    box-shadow: 0 0 0 3px var(--color-accent-soft);
}

/* ====== 详情页头部：订单号 / 物流单号（点一下复制） ====== */
/* 字号必须与 .detail-meta 主体一致（13px）：meta 行是 flex 行，
   子项被 align-items:center 居中，但**文字在行盒里的位置由 line-height 决定** ——
   字号跟兄弟不同就自己飘 1~3px，肉眼能看出来。
   要淡化就用颜色和字重，别靠缩小字号。 */
.reg-no {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-muted);
    font: inherit;
    font-size: 13px;
    padding: 1px 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.14s var(--ease-out),
                border-color 0.14s var(--ease-out),
                color 0.14s var(--ease-out);
}

.reg-no b {
    font-family: var(--font-mono);
    font-weight: 500;
    color: var(--color-text);
}

.reg-no:hover {
    border-color: var(--color-accent-line);
    background: var(--color-accent-tint);
    color: var(--color-accent);
}

.reg-no:hover b {
    color: var(--color-accent);
}

/* 禁用态（如没有任何登记时的「清除标记」）：全站没有统一的 .btn:disabled，
   这里补一条，避免出现「看着能点、点了没反应」 */
.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn:disabled:hover {
    border-color: var(--color-border-strong);
    color: var(--color-text);
    background: var(--color-surface);
}

/* ======================================================================
   售后登记弹窗（四段：登记 / 发货 / 解决 / 回访）—— 2026-10-13
   ⚠️ 通用弹窗输入框规则 `.modal input[type="text"]:not(.modal-compose *)`
      特异性是 (0,3,1)，本区块凡要改输入框外观的都必须带 #product-modal 提权，
      否则永远输给它（写成 .reg-grid input 是 (0,2,1)，不够）。
   ====================================================================== */

/* 登记切换条：一条登记一个 tab + 「+ 新增登记」。
 * 放在步骤条**上方** —— 它切的是「编辑哪一条」，步骤条切的是「这条的哪一段」，
 * 层级更高，顺序反了会让人以为 tab 也是步骤的一部分。
 * ⚠️ 带 #product-modal 提权：弹窗里另有通用 button 外观规则，裸类名压不住。 */
#product-modal .reg-tabs {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin: 0 0 10px;
    padding: 0 0 10px;
    border-bottom: 1px solid var(--color-border);
}

#product-modal .reg-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-text);
    font: inherit;
    font-size: 12.5px;
    padding: 5px 10px;
    border-radius: 999px;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.14s var(--ease-out), color 0.14s var(--ease-out),
                border-color 0.14s var(--ease-out);
}

#product-modal .reg-tab:hover {
    background: var(--color-accent-tint);
    border-color: var(--color-accent);
    color: var(--color-accent);
}

#product-modal .reg-tab.active {
    background: var(--color-accent);
    border-color: var(--color-accent);
    color: var(--color-on-accent);
    font-weight: 600;
}

/* 已闭环的那条淡化：一眼看出还剩哪几条在手上 */
#product-modal .reg-tab.closed {
    background: var(--color-surface-2);
    color: var(--color-muted);
}

#product-modal .reg-tab.closed.active {
    background: var(--color-success-soft);
    border-color: var(--color-success);
    color: var(--color-success);
}

/* 「+ 新增登记」用虚线跟已有登记区分开 —— 它不是一条登记，是一个动作 */
#product-modal .reg-tab.add {
    border-style: dashed;
    background: transparent;
    color: var(--color-muted);
}

#product-modal .reg-tab.add.active,
#product-modal .reg-tab.add:hover {
    border-style: solid;
    background: var(--color-accent-tint);
    border-color: var(--color-accent);
    color: var(--color-accent);
}

#product-modal .reg-tab .reg-tab-st {
    font-size: 11.5px;
    font-weight: 400;
    opacity: 0.78;
}

/* 计数推到最右：它解释的是整条的信息，不该跟某个 tab 贴在一起 */
#product-modal .reg-tabs-count {
    margin-left: auto;
    font-size: 12px;
    color: var(--color-faint);
}

.reg-steps {
    display: flex;
    gap: 6px;
    margin: 0 0 10px;
}

.reg-step {
    flex: 1;
    border: 1px solid transparent;
    background: var(--color-surface-2);
    color: var(--color-muted);
    font: inherit;
    font-size: 12px;
    padding: 7px 4px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.14s var(--ease-out), color 0.14s var(--ease-out);
}

.reg-step:hover {
    background: var(--color-accent-tint);
    color: var(--color-accent);
}

.reg-step.on {
    background: var(--color-accent);
    border-color: var(--color-accent);
    color: var(--color-on-accent);
    font-weight: 600;
}

.reg-step.flow-done {
    background: var(--color-success-soft);
    color: var(--color-success);
}

.reg-auto {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 14px;
    background: var(--color-surface-2);
    border: 1px dashed var(--color-accent-line);
    border-radius: 8px;
    padding: 9px 12px;
    margin-bottom: 14px;
    font-size: 12px;
}

.reg-auto-title {
    font-weight: 600;
    color: var(--color-faint);
    letter-spacing: 0.4px;
}

.reg-auto-item i {
    font-style: normal;
    color: var(--color-faint);
    margin-right: 4px;
}

.reg-auto-item b {
    font-weight: 500;
    color: var(--color-text);
}

.reg-seg {
    margin-bottom: 4px;
}

.reg-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 14px;
}

/* 地址这类长内容占满整行，别塞在半列里 */
.reg-grid .reg-field-wide {
    grid-column: 1 / -1;
}

.reg-req {
    color: var(--color-danger);
    font-weight: 400;
}

/* 多行文本 / 下拉：通用规则只盖了 input[type=text]，这两个得自己来 */
#product-modal textarea,
#product-modal select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    background: var(--color-surface);
    color: var(--color-text);
    font-family: inherit;
    font-size: 14px;
}

#product-modal textarea {
    resize: vertical;
    line-height: 1.5;
}

#product-modal textarea:focus,
#product-modal select:focus {
    outline: none;
    border-color: var(--color-accent);
}

/* 网格里的输入框去掉落差：通用规则给了 margin-bottom:12px，会把两列行高撑歪 */
#product-modal .reg-grid input[type="text"],
#product-modal .reg-grid input[type="date"],
#product-modal .reg-grid select {
    margin-bottom: 0;
}

#product-modal .reg-grid input[type="date"] {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    background: var(--color-surface);
    color: var(--color-text);
    font-family: inherit;
    font-size: 14px;
}

#product-modal .reg-grid .reg-field {
    margin-bottom: 12px;
}

/* ====== 多选胶囊（问题类型 / 满意度）====== */
.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}

.chip {
    border: 1px solid var(--color-border-strong);
    background: var(--color-surface);
    color: var(--color-text);
    font: inherit;
    font-size: 13px;
    padding: 6px 13px;
    border-radius: 20px;
    cursor: pointer;
    transition: background 0.14s var(--ease-out),
                border-color 0.14s var(--ease-out),
                color 0.14s var(--ease-out);
}

.chip:hover {
    border-color: var(--color-accent-line);
    background: var(--color-accent-tint);
}

.chip.on {
    background: var(--color-accent);
    border-color: var(--color-accent);
    color: var(--color-on-accent);
    font-weight: 500;
}

.chip.off {
    color: var(--color-faint);
    border-style: dashed;
}

.chip-add {
    border-style: dashed;
    color: var(--color-accent);
    background: var(--color-surface-2);
}

.chip-add-box {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

/* 带 id 提权：要和旁边的胶囊同一副长相（20px 圆角 / 同样的 padding） */
#product-modal .chip-add-box input {
    width: 150px;
    padding: 6px 11px;
    border: 1px solid var(--color-accent);
    border-radius: 20px;
    background: var(--color-surface);
    color: var(--color-text);
    font-size: 13px;
    font-family: inherit;
    margin-bottom: 0;
}

#product-modal .chip-add-box input:focus {
    outline: none;
    box-shadow: 0 0 0 3px var(--color-accent-soft);
}

/* ====== 问题照片：勾选会话里的图片附件（不做本地上传）====== */
/* 卡片 = 缩略图 + 文件名 + 来源标签，竖排宽 84px。缩略图位按状态叠三层
   （真图 / 占位图标），做法与详情页附件卡同源，但**不复用 .att-* 类名** ——
   那些规则全是 `.attachment-images .att-inline-card[...]` 限定的，借用反而要新建一堆。 */
.reg-photos {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 8px;
}

.reg-photo {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    width: 84px;
    padding: 5px 5px 6px;
    border: 1px solid var(--color-border-strong);
    background: var(--color-surface);
    color: var(--color-text);
    font: inherit;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.14s var(--ease-out),
                border-color 0.14s var(--ease-out),
                box-shadow 0.14s var(--ease-out);
}

.reg-photo:hover {
    border-color: var(--color-accent-line);
    background: var(--color-accent-tint);
}

/* 选中：边框 + 外描边。**不能只靠底色** —— 缩略图把卡片占满，底色几乎看不见。 */
.reg-photo.on {
    border-color: var(--color-accent);
    background: var(--color-accent-tint);
    box-shadow: 0 0 0 2px var(--color-accent-soft);
}

.reg-photo-box {
    position: relative;
    width: 100%;
    height: 46px;
    border: 1px solid var(--color-border);
    border-radius: 5px;
    background: var(--color-surface-3);
    color: var(--color-faint);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.reg-photo-ico { display: block; }
/* 出图后藏掉占位图标：透明 PNG 盖不住它，会从图里透出来。 */
.reg-photo-box[data-st="ready"] .reg-photo-ico { display: none; }
.reg-photo-box[data-st="loading"] .reg-photo-ico { opacity: .35; }
.reg-photo-box[data-st="fail"] .reg-photo-ico { color: var(--color-danger); }

.reg-photo-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    object-fit: cover;
    border: 0;
    border-radius: 0;
    opacity: 0;
    transition: opacity .22s ease-out;
}

.reg-photo-img.on { opacity: 1; }

/* 内嵌图折叠开关：**必须独占一行**（flex-basis 100%），否则会跟缩略图挤在同一行。
   做成看起来像链接的文字按钮，别用边框 —— 它旁边全是卡片，再加个框会分不清哪个能选。 */
.reg-photo-more {
    flex: 0 0 100%;
    text-align: left;
    border: none;
    background: none;
    padding: 1px 0;
    color: var(--color-accent);
    font: inherit;
    font-size: 12px;
    cursor: pointer;
    text-decoration: underline dotted;
    text-underline-offset: 3px;
}

.reg-photo-more:hover { text-decoration-style: solid; }

.reg-photo-name {
    font-family: var(--font-mono);
    font-size: 10px;
    line-height: 1.25;
    width: 100%;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.reg-photo-side {
    color: var(--color-faint);
    font-size: 10px;
    line-height: 1.25;
    width: 100%;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ====== 弹窗底部：左边一行提示，右边按钮 ====== */
/* 基准 0 而不是 auto：按内容占位会把按钮挤到折行（「保存并推进」孤行，用户截图报过）。
 * 收不下时提示截断，按钮永远保持一行。 */
.reg-foot-hint {
    flex: 1 1 0;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-right: auto;
    align-self: center;
    font-size: 12px;
    color: var(--color-faint);
}

/* 弹窗宽一点：四段表单两列排版，默认宽度会把选择框挤成一条 */
.modal.product-modal {
    width: 720px;
    max-width: calc(100vw - 32px);
}

.modal.product-modal h3 {
    margin-bottom: 12px;
}

/* ======================================================================
   统计页 · 售后登记区块 —— 2026-10-13
   与上面的「产品/品牌分布」同源同表，只是口径不同，所以视觉上用一条
   .as-head 分隔出「这一节是售后」的边界，别让人误读成同一个统计。
   ====================================================================== */

.as-section {
    margin-top: 32px;
}

.as-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 6px 16px;
    margin-bottom: 16px;
}

.as-head h2 {
    font-size: 20px;
    color: var(--color-text);
}

.as-note {
    font-size: 12px;
    color: var(--color-muted);
    line-height: 1.6;
}

.as-note b {
    color: var(--color-text);
    font-weight: 600;
}

.as-kpi {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.as-kpi-card {
    background: var(--color-surface);
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(var(--shadow-rgb), 0.06);
    padding: 16px 20px;
}

.as-kpi-card .v {
    font-size: 24px;
    font-weight: 600;
    color: var(--color-accent);
    line-height: 1.3;
}

.as-kpi-card .l {
    font-size: 13px;
    color: var(--color-text);
    margin-top: 2px;
}

.as-kpi-card .d {
    font-size: 12px;
    color: var(--color-faint);
    margin-top: 6px;
    line-height: 1.5;
}

.as-empty {
    padding: 22px;
    text-align: center;
    font-size: 13px;
    color: var(--color-faint);
    background: var(--color-surface);
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(var(--shadow-rgb), 0.06);
}

/* 明细卡：不能沿用 .chart-card 的 300px 图表高度假设，放表格要自己撑开 */
.as-recent-card {
    margin-top: 20px;
}

/* ====== 统计页邮件预览弹窗（明细行点开看邮件，不跳页） ====== */
/* 会话明细的主题列：长主题截断，不把表格撑爆 */
.an-subject {
    max-width: 260px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cvp-modal {
    width: 760px;
    max-width: calc(100vw - 32px);
    padding: 0;
    display: flex;
    flex-direction: column;
}

.cvp-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--color-border);
}

/* 弹窗里的 h3 会被 .modal 上下文放大，这里压回标题尺寸 */
.cvp-head h3 {
    margin: 0;
    font-size: 15px;
}

.cvp-head .btn {
    flex: 0 0 auto;
}

.cvp-body {
    overflow-y: auto;
    padding: 16px 20px;
}

.cvp-email {
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 12px 14px;
    margin-bottom: 12px;
}

.cvp-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 12px;
    color: var(--color-faint);
}

.cvp-dir {
    flex: none;
    padding: 1px 8px;
    border-radius: 999px;
    font-size: 11px;
}

.cvp-dir.in {
    background: var(--color-accent-tint);
    color: var(--color-accent);
}

.cvp-dir.out {
    background: var(--color-surface-strong, rgba(0, 0, 0, 0.05));
    color: var(--color-faint);
}

.cvp-sender {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cvp-date {
    margin-left: auto;
    flex: none;
}

.cvp-subject {
    font-weight: 600;
    margin: 8px 0 6px;
}

/* 正文是纯文本邮件，white-space:pre-wrap 保住换行；长度上限接口侧已截 */
.cvp-text {
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 13px;
    line-height: 1.65;
    color: var(--color-text);
    max-height: 320px;
    overflow-y: auto;
}

/* 标题里的筛选状态：跟在 h3 文字后面，要有存在感但别盖过标题 */
.as-filter-hint {
    margin-left: 10px;
    font-size: 13px;
    font-weight: 400;
    color: var(--color-accent);
}

.as-filter-hint a {
    color: var(--color-accent);
    text-decoration: underline;
}

.as-recent-table {
    box-shadow: none;
    font-size: 13px;
}

.as-recent-table th,
.as-recent-table td {
    padding: 9px 12px;
    white-space: nowrap;
}

.as-recent-table td.mono {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--color-muted);
}

/* 状态胶囊：与弹窗里的状态口径一致，已闭环绿、进行中蓝 */
.as-pill {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 11px;
    font-size: 12px;
    white-space: nowrap;
}

.as-pill.done {
    background: var(--color-success-soft);
    color: var(--color-success);
}

.as-pill.wait {
    background: var(--color-accent-soft);
    color: var(--color-accent);
}

/* 明细分页条（2026-10-14：一行 = 一条登记，行数会涨） */
.as-pager {
    display: flex;
    align-items: center;
    justify-content: flex-end;   /* 页脚靠右，别顶着表格左缘 */
    gap: 10px;
    padding: 10px 4px 2px;
    font-size: 13px;
    color: var(--color-muted);
}

/* 每页条数选择器：跟 .form-group select 同一套语言
   （去原生外观、描边圆角、自定义箭头），只把尺寸收小 */
.as-pager .as-page-size {
    appearance: none;
    -webkit-appearance: none;
    padding: 4px 26px 4px 10px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    background-color: var(--color-surface);
    color: var(--color-text);
    background-image: var(--select-arrow);
    background-repeat: no-repeat;
    background-position: right 8px center;
    cursor: pointer;
    transition: border-color .15s, box-shadow .15s;
}

.as-pager .as-page-size:hover {
    border-color: var(--color-border-strong);
}

.as-pager .as-page-size:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(var(--accent-rgb), .12);
}

/* 登记详情弹窗（stats 明细行点开）：label 固定宽左列，值自适应换行 */
#reg-preview-modal .regd-row {
    display: flex;
    gap: 12px;
    padding: 7px 0;
    border-bottom: 1px dashed var(--color-border, #e5e7eb);
    font-size: 13px;
    line-height: 1.55;
}

#reg-preview-modal .regd-row:last-of-type {
    border-bottom: none;
}

#reg-preview-modal .regd-label {
    flex: 0 0 72px;
    color: var(--color-muted);
    white-space: nowrap;
}

#reg-preview-modal .regd-val {
    flex: 1;
    min-width: 0;
    word-break: break-word;
}

#reg-preview-modal .regd-sub {
    color: var(--color-muted);
    font-size: 12px;
}

#reg-preview-modal .regd-actions {
    padding-top: 14px;
}

/* ======================================================================
   会话详情 · 售后登记卡片 —— 2026-10-13
   与弹窗共用 .reg-grid 这个类名，但弹窗里是「表单两列」、这里是「读数两列」，
   行距需求不同，所以详情卡片一律用 .reg-card 前缀提权覆盖。
   注意：通用弹窗输入框规则的特异性很高，本区块若用到输入框同样要带 #product-modal，
   这里纯展示，不带输入框。
   ====================================================================== */

.reg-card-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
}

.reg-card-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--color-text);
}

.reg-card-spacer {
    flex: 1;
}

.reg-card-hint {
    font-size: 13px;
    color: var(--color-faint);
    line-height: 1.6;
}

.reg-card-hint.warn {
    margin-top: 12px;
    padding: 9px 12px;
    border-radius: 6px;
    background: var(--color-warning-soft);
    color: var(--color-warning);
}

.reg-pill {
    display: inline-block;
    padding: 3px 11px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
}

.reg-pill.done {
    background: var(--color-success-soft);
    color: var(--color-success);
}

.reg-pill.wait {
    background: var(--color-accent-soft);
    color: var(--color-accent);
}

.reg-card .reg-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 24px;
    margin: 0;
}

.reg-kv {
    display: flex;
    align-items: baseline;
    gap: 10px;
    min-width: 0;
    font-size: 13px;
    line-height: 1.6;
}

.reg-kv .k {
    flex: none;
    width: 60px;
    color: var(--color-faint);
}

.reg-kv .v {
    color: var(--color-text);
    min-width: 0;
    word-break: break-word;
}

.reg-kv .v code {
    font-family: var(--font-mono);
    font-size: 12px;
    background: var(--color-surface-2);
    padding: 1px 6px;
    border-radius: 4px;
}

.reg-chip {
    display: inline-block;
    margin: 0 5px 4px 0;
    padding: 1px 9px;
    border-radius: 11px;
    background: var(--color-accent-soft);
    color: var(--color-accent);
    font-size: 12px;
}

.reg-tag {
    display: inline-block;
    margin-left: 4px;
    padding: 0 7px;
    border-radius: 9px;
    background: var(--color-warning-soft);
    color: var(--color-warning);
    font-size: 11px;
}

.reg-tag.quiet {
    background: var(--color-surface-3);
    color: var(--color-muted);
}

.reg-warn {
    color: var(--color-danger);
}

/* 问题详情：长文本独占整行，塞进两列键值格里会把布局撑歪 */
.reg-detail {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--color-border);
}

.reg-detail-label {
    font-size: 12px;
    color: var(--color-faint);
    margin-bottom: 6px;
}

.reg-detail-body {
    font-size: 13px;
    line-height: 1.7;
    color: var(--color-text);
    white-space: pre-wrap;
}

.reg-photo-count {
    margin-top: 10px;
    font-size: 12px;
    color: var(--color-muted);
}
