/* ============================================================
   CSS: Reset, Variables, Theme, Layout Shell, Bottom Nav
   设计系统: 韩系法式花艺 × 微信级简约 × 情侣甜蜜感
   遵循 DESIGN-SYSTEM.md — 暖米色系 · 多层光影 · 衬线花字装饰
   ============================================================ */
/* 字体已本地化 → fonts/fonts.css（永久离线，不需 VPN/Google CDN） */

/* ===== Reset ===== */
* { margin:0; padding:0; box-sizing:border-box; -webkit-tap-highlight-color:transparent; }

/* 手机端彻底屏蔽系统复制菜单 + 桌面端禁止选择（自定义气泡菜单独立运作） */
html, body, #app, #chat-container, .bubble, .msg, .bubble-wrap, .bubble *,
.time-divider, #header, #input-area, .msg-quote, .file-preview, .file-name,
.img-carousel, .emoji-tag, button, label, .nav-tab, .tab-panel, .settings-group {
    -webkit-user-select:none; user-select:none; -webkit-touch-callout:none;
}
input, textarea, select, [contenteditable] { -webkit-user-select:text; user-select:text; }
/* 不可选元素 */
.msg-avatar, .delete-btn, .msg-checkbox,
.img-carousel-dot, .carousel-toggle-btn, .carousel-counter-text,
.time-divider, button, #scroll-to-bottom { user-select:none; -webkit-user-select:none; }
/* 纯图片/文件气泡 */
.msg.no-text .bubble, .msg.no-text .bubble-wrap { cursor:default; }
/* 气泡内图片/文件 */
.bubble .file-preview, .bubble .file-name, .bubble .img-carousel, .bubble .emoji-tag { user-select:none; -webkit-user-select:none; }
/* 引用条 */
.msg-quote { user-select:none; -webkit-user-select:none; }

/* 底部导航图标 / 头像缩略图 / 背景缩略图：屏蔽手机长按弹出「复制图片」菜单 */
.nav-icon img, .avatar-hist-thumb, .more-avatar-img img, .more-avatar-ring img, .my-avatar img {
    -webkit-touch-callout:none; -webkit-user-select:none; user-select:none;
}

/* ★ 2027 甲方实锤：全站任何图片（表情预览图/分组缩略图/小窝图标/＋号面板缩略图/聊天气泡图/大图查看器）
   长按都不许弹系统「复制/下载/分享」菜单 —— iOS 靠 touch-callout，安卓由 core.js 的 contextmenu 拦截兜底。
   只作用于 <img>，不影响输入框/文本选择/软件自己的长按菜单。 */
img { -webkit-touch-callout:none; -webkit-user-select:none; user-select:none; }

/* ================================================================
   CSS 变量 — 暖米色系 · 干燥玫瑰 · 法式奶油雾面
   所有变量遵循 DESIGN-SYSTEM.md §1-6
   ================================================================ */
:root {
    /* ---- 键盘高度（系统级CSS环境变量，JS轮询读取）---- */
    --kbd-env: env(keyboard-inset-height, 0px);
    /* ---- 底色（暖米色系，像未漂白的纸）---- */
    --bg-primary:        #F8F4EF;
    --bg-chat:           #FCFAF6;
    --surface:           rgba(255,252,249,0.82);
    --surface-solid:     #FFFFFF;

    /* ---- 文字（暖黑/暖灰褐，永远不用纯黑）---- */
    --text-primary:      #1E1C1A;
    --text-secondary:    #8A8278;
    --text-muted:        #BFB8AE;

    /* ---- 强调色 — 干燥玫瑰 + 雾紫 + 鼠尾草 ---- */
    --accent:            #C9B0A8;
    --accent-hover:      #B8A090;
    --accent-light:      rgba(201,176,168,0.15);
    --accent-glow:       rgba(200,175,160,0.28);
    --accent-rose:       #C9A8A8;
    --accent-rose-light: rgba(201,168,168,0.12);
    --accent-lavender:   #B8A8C4;
    --accent-lavender-light: rgba(184,168,196,0.10);
    --accent-sage:       #A8B8A0;

    /* ---- 别名（兼容各模块 CSS 引用）---- */
    --rose:              #C9A8A8;                     /* = --accent-rose */
    --rose-hover:        #BA9696;                     /* 比 accent-rose 深 8% */
    --rose-light:        rgba(201,168,168,0.12);      /* = --accent-rose-light */
    --rose-glow:         0 0 24px rgba(200,160,160,0.25);
    --sage:              #A8B8A0;                     /* = --accent-sage */
    --sage-light:        rgba(168,184,160,0.10);
    --lavender:          #B8A8C4;                     /* = --accent-lavender */
    --lavender-light:    rgba(184,168,196,0.10);
    --font-body:         'Noto Serif SC', 'PingFang SC', 'STSong', 'Georgia', serif;
    --font-display:      'Playfair Display', 'Georgia', 'Times New Roman', serif;
    --font-script:       'Great Vibes', 'Cormorant Garamond Italic', cursive;

    /* ---- 金色装饰（法式线条用，不参与交互）---- */
    --gold:              #C4A86A;
    --gold-dark:         #A89050;
    --gold-light:        rgba(196,168,106,0.18);

    /* ---- 边框 / 分割 ---- */
    --border:            rgba(180,170,155,0.22);
    --border-faint:      rgba(180,170,155,0.10);
    --divider:           rgba(0,0,0,0.04);

    /* ---- 玫瑰色扩展（hover背景 + 深色调）---- */
    --bg-rose-warm:      rgba(201,168,168,0.10);
    --rose-dark:         #A88080;

    /* ---- 层叠层级（顶层令牌，body 级浮层统一在此排序 低→高）---- */
    --z-viewer:          99990;   /* 全屏图片查看器 */
    --z-sheet:           99992;   /* 浮于查看器之上的上下文菜单 / action sheet */
    --z-confirm:         99994;   /* 确认弹窗 customConfirm */
    --z-toast:           99996;   /* 轻提示 customToast */
    --z-menu:            99999;   /* 顶层菜单（moments 菜单等） */

    /* ---- 渐变（按钮类已按 DESIGN-SYSTEM「禁止渐变按钮」改为纯色深玫瑰；名称保留以兼容各模块 var() 引用） ---- */
    --accent-gradient:   var(--rose-dark, #A88080);
    --gradient:          var(--rose-dark, #A88080);
    --gradient-rose:     var(--rose-dark, #A88080);
    --gradient-warm:     radial-gradient(120% 80% at 50% 0%, rgba(210,190,180,0.12), transparent 60%);
    --gradient-light-pool: radial-gradient(120% 80% at 50% 0%, rgba(210,190,180,0.10), transparent 70%);

    /* ---- 阴影（多层法：内高光 + 紧贴投影 + 远投阴影）---- */
    --shadow-xs:         0 1px 3px rgba(160,145,130,0.06);
    --shadow-sm:         0 2px 8px rgba(160,145,130,0.07);
    --shadow-md:         0 8px 28px rgba(160,145,130,0.10);
    --shadow-lg:         0 4px 18px rgba(160,145,130,0.11);
    --shadow-glow:       0 0 24px rgba(200,175,160,0.25);

    /* ---- 语义色 ---- */
    --danger:            #D8A898;
    --success:           #A8C0A0;
    --online:            #8BC9A0;
    /* ★ 2028-09 甲方曾定：全站「未读 / 待办」性质的小红点、数字角标统一用这一个**固定色**。
       ★ 2026-10 甲方改口径：小红点一律改用主题色 --rose（见下面 .nav-badge 的说明），
       本令牌已无引用，保留定义只为兼容，勿在新样式里使用。 */
    --unread:            #C56A72;

    /* ---- 输入/卡片/引用背景 ---- */
    --input-bg:          rgba(255,255,255,0.50);
    --card-bg:           rgba(255,255,255,0.55);
    --quote-bg:          rgba(201,176,168,0.15);

    /* ---- 气泡色 ---- */
    --bubble-user:       #A7C4A0;
    --bubble-user-glow:  rgba(140,175,130,0.28);
    --bubble-assistant:  rgba(255,255,255,0.92);

    /* ---- 字体（严格分工）---- */
    --font-decorative:   'Playfair Display', 'Georgia', 'Times New Roman', serif;
    --font-reading:      'Cormorant Garamond', 'Georgia', 'Noto Serif SC', 'STSong', serif;
    --font-sans:         'Inter', 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    --font-handwriting:  'Great Vibes', 'Long Cang', 'Segoe Script', 'KaiTi', 'STKaiti', cursive;

    /* ---- 间距量表（8px 基准）---- */
    --space-xs:  4px;
    --space-sm:  8px;
    --space-md:  12px;
    --space-lg:  16px;
    --space-xl:  20px;
    --space-2xl: 24px;
    --space-3xl: 32px;

    /* ---- 圆角量表 ---- */
    --radius-xs:   4px;
    --radius-sm:   8px;
    --radius-md:   12px;
    --radius-lg:   18px;
    --radius-xl:   24px;
    --radius-full: 999px;

    /* ---- 布局 ---- */
    --header-height: 56px;
    --nav-height:    56px;
    /* iOS 安全区（刘海里/状态栏/Home 条）：viewport-fit=cover 下内容会铺到屏幕最边缘，
       必须用 env() 留出安全区，否则独立运行(PWA)时头部顶进状态栏、聊天被刘海挡住。
       安卓浏览器不启用 viewport-fit=cover 时这些 env() 返回 0，不影响安卓。 */
    --safe-top:      env(safe-area-inset-top, 0px);
    --safe-bottom:   env(safe-area-inset-bottom, 0px);
}

/* ================================================================
   暗色主题变量覆盖
   ================================================================ */
[data-theme-mode="dark"] {
    --bg-primary:        #1A1614;
    --bg-chat:           #221D1A;
    --surface:           rgba(34,29,26,0.88);
    --surface-solid:     #2A2420;
    --text-primary:      #E8E0D8;
    --text-secondary:    #A09890;
    --text-muted:        #6A625A;
    --border:            rgba(180,160,140,0.12);
    --border-faint:      rgba(180,160,140,0.06);
    --divider:           rgba(255,255,255,0.04);
    --bg-rose-warm:      rgba(212,184,184,0.08);
    --rose-dark:         #C09898;
    --shadow-xs:         0 1px 3px rgba(0,0,0,0.15);
    --shadow-sm:         0 2px 8px rgba(0,0,0,0.20);
    --shadow-md:         0 8px 28px rgba(0,0,0,0.30);
    --shadow-lg:         0 4px 18px rgba(0,0,0,0.35);
    --shadow-glow:       0 0 24px rgba(200,175,160,0.15);
    --input-bg:          rgba(255,255,255,0.05);
    --card-bg:           rgba(255,255,255,0.04);
    --quote-bg:          rgba(255,255,255,0.08);
    --bubble-user:       #3A4A38;
    --bubble-user-glow:  rgba(50,70,48,0.30);
    --bubble-assistant:  rgba(44,40,36,0.92);
    --accent-gradient:   var(--rose-dark, #C09898);
    --gradient:          var(--rose-dark, #C09898);
    --accent-rose:       #D4B8B8;
    --accent-rose-light: rgba(212,184,184,0.12);
    --accent-lavender:   #C8B5D8;
    --accent-lavender-light: rgba(196,180,212,0.14);
    --rose:              #D4B8B8;
    --rose-light:        rgba(212,184,184,0.12);
    --lavender:          #C8B5D8;
    --lavender-light:    rgba(196,180,212,0.14);
}

/* ================================================================
   基础布局
   ================================================================ */
html, body {
    height: 100vh;         /* 统一用 100vh 而非 100%：iOS 独立运行(加到主屏幕)时 height:100% 只撑到
                              WebKit 的「可视区」，底部 Home 条(widget 区域)下方会露出一条白边——
                              100vh 能撑到屏幕真正的最底部。安卓 100vh == 视口，无任何影响。 */
    position: fixed;       /* 阻止浏览器在键盘出现时滚动 body */
    width: 100%;           /* 配合 position:fixed 保持全宽 */
    /* 英文→Cormorant Garamond 衬线 / 中文→思源宋体 / 回退系统 */
    font-family: "Cormorant Garamond", "Georgia",
                 "Noto Serif SC", "Songti SC", "STSong",
                 "PingFang SC", "Microsoft YaHei", serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 15px;
    line-height: 1.7;
    letter-spacing: 0.3px;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}
/* 暗色模式：光池极度微弱，仅靠 CSS 变量切换底色 */

/* ---- App 外壳（手机框）---- */
#app {
    display: flex;
    flex-direction: column;
    /* 高度撑满视口：用 position:fixed + top/bottom inset（iOS Safari 的 100dvh/100vh 会算错高度，
       把底部导航/输入栏「吞掉、挤到屏幕外」）。top:0;bottom:0 与 .chat-view 手机端同款，最可靠。
       不用 transform 居中（transform 会困住 fixed 子层 .chat-view，让它无法准确定位到视口）。 */
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    margin: 0 auto;      /* left/right:0 + max-width + auto = 水平居中 */
    width: 100%;
    max-width: 480px;
    background: var(--bg-chat);
    box-shadow:
        0 1px 0 rgba(255,255,255,0.45) inset,
        var(--shadow-lg);
    /* ★ 2026-10-30 删掉 #app 的 backdrop-filter: blur(20px)：它的底色 --bg-chat 是实色
       （浅 #FCFAF6 / 深 #221D1A），全不透明 → 这层模糊在屏幕上**根本看不见**，却让整台手机
       每帧都为它多算一次整屏采样（性能模式 1253/1269 行早就在关它）。宝宝报「聊天页往下翻特别卡」，这是白烧的一半。
       绝不许加回来：真需要磨砂就给具体的小面板加，别给整屏的 #app 加。 */
    /* iOS 安全区：让头部/内容避开顶部状态栏与刘海。全局已 box-sizing:border-box，
       内容自动下移到安全区之下。底部安全区由 #bottom-nav/.input-row 各自处理，不重复加，避免安卓多留空白。 */
    padding-top: var(--safe-top);
}
@media (min-width: 768px) {
    #app {
        border-radius: var(--radius-xl);
        /* 桌面/平板：用 20px 上下 inset 撑满（不再用 margin-top + max-height:calc(100vh-40px)，
           iOS 上 100vh 会算成「收起地址栏后的大高度」，导致底部被吞掉）。 */
        top: 20px;
        bottom: 20px;
    }
}
/* ★ (已回退 2026-09-04) iOS standalone 视口 bug：早期尝试用 #app bottom:auto+height:100vh 修「底部空白」，
   但甲方便确认「底部主题色空白带=Home 条上方安全区空隙（web 已铺到底，非外壳没填满）」，真问题是
   ①不开键盘输入框底部被安全区盖住 ②键盘收起后输入栏塌到安全区条下不可见（键盘开合回落 bug）。
   且已明确：iOS 上 100vh/100dvh 会算成「大视口」比可视区高，把底部导航/输入栏吞掉。
   因此外壳保持 position:fixed; top:0; bottom:0 + env() 安全区（开发者可靠基线），不采用 100vh 方案。
   底部安全区空隙由各元素自己的 --safe-bottom/var(--safe-bottom) 处理，安卓这些变量恒 0，零影响。 */

/* ================================================================
   Header — 微信式 3 列网格 + 多层阴影 + 毛玻璃
   ================================================================ */
#header {
    display: grid;
    grid-template-columns: 44px 1fr 44px;
    align-items: center;
    height: var(--header-height);
    padding: 0 6px;
    background: var(--surface);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    border-bottom: 1px solid var(--border);
    z-index: 100;
    flex-shrink: 0;
    position: relative;
    box-shadow:
        0 1px 0 rgba(255,255,255,0.4) inset,
        0 2px 12px rgba(160,145,130,0.06);
}
[data-theme-mode="dark"] #header {
    box-shadow:
        0 1px 0 rgba(255,255,255,0.05) inset,
        0 2px 12px rgba(0,0,0,0.20);
}

#header .h-left { display: flex; align-items: center; justify-content: flex-start; }
#header .h-center { display: flex; flex-direction: column; align-items: center; justify-content: center; cursor: pointer; min-width: 0; }
#header .h-right { display: flex; align-items: center; justify-content: flex-end; }

#header .name {
    font-family: 'Playfair Display', var(--font-decorative);
    font-style: italic;
    font-weight: 500;
    font-size: 18px;
    letter-spacing: 1.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    color: var(--text-primary);
}
#header .status {
    font-size: 11px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 4px;
    font-family: 'Inter', 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    letter-spacing: 0.5px;
}
#header .status::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--online);
    animation: breathe 2s ease-in-out infinite;
    box-shadow: 0 0 8px rgba(139,201,160,0.4);
    flex-shrink: 0;
}
@keyframes breathe {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%      { opacity: 0.5; transform: scale(0.85); }
}

#header .h-back-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-primary);
    padding: 8px 6px;
    min-width: 40px;
    min-height: 40px;
    border-radius: var(--radius-sm);
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: flex-start;
}
#header .h-back-btn:hover { background: var(--accent-light); color: var(--accent); }
#header .h-back-btn:active { transform: scale(0.92); }

#header .h-more-btn {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--text-primary);
    padding: 4px 8px;
    font-family: inherit;
    letter-spacing: 2px;
    font-weight: 600;
    border-radius: var(--radius-sm);
    transition: all 0.15s ease;
}
#header .h-more-btn:hover { color: var(--accent); }
#header .h-more-btn:active { transform: scale(0.94); }


/* ================================================================
   Tab Panel 系统
   ================================================================ */
#tab-contents { flex: 1; display: flex; flex-direction: column; overflow: hidden; position: relative; }
.tab-panel { display: none; flex: 1; overflow-y: auto; flex-direction: column; }
.tab-panel.active { display: flex; }
#tab-chat {
    position: relative;    /* 为 .chat-view 绝对定位提供锚点 */
    flex-direction: column;
    overflow-y: hidden;
    /* 键盘偏移变量 — JS 实时更新供 #scroll-to-bottom 使用 */
    --kbd-h: 0px;
    /* 底部空间由 #bottom-panel 统一管理，不再用 padding-bottom 填充 */
}

/* ================================================================
   Bottom Navigation — 毛玻璃 + 多层阴影 + 弹性图标
   ================================================================ */
#bottom-nav {
    display: flex;
    height: calc(var(--nav-height) + var(--safe-bottom));
    padding-bottom: var(--safe-bottom);
    background: var(--surface);
    /* ★ 2026 iOS 底部安全区：导航栏背景铺满整盒（含 Home 安全区那段），下方不再露出「一截空白」——
       iOS 上导航下方原本透明露出 #app 底色，看起来就是「图标下面还有一截空白、离最底很远」（甲方实锤）。
       安卓 --safe-bottom=0 → content box=整盒，铺满与之前视觉一致，零影响。
       content(≈56px) 内容仍由 padding-bottom: var(--safe-bottom) 让 Home 横条落在内容下方，不遮挡。
       注意：导航背景用半透明 --surface，透出 APP 底色视觉上是连续的，不会像早期引擎色块那样突兀。 */
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
    z-index: 100;
    box-shadow:
        0 -1px 0 rgba(255,255,255,0.35) inset,
        0 -4px 20px rgba(160,145,130,0.05);
}
[data-theme-mode="dark"] #bottom-nav {
    box-shadow:
        0 -1px 0 rgba(255,255,255,0.03) inset,
        0 -4px 20px rgba(0,0,0,0.30);
}

.nav-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 10px;
    font-family: inherit;
    /* ★ Motion 3.0：明确属性，不用 transition: all（原有手感不变：颜色 0.2s / 图标位移见下） */
    transition: color 0.2s ease, transform 0.32s cubic-bezier(0.16, 1, 0.3, 1);
    padding: 4px 2px;
    position: relative;
    -webkit-tap-highlight-color: transparent;
}
.nav-tab.active { color: var(--accent); }
.nav-tab .nav-icon {
    font-size: 22px;
    line-height: 1;
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.nav-tab .nav-icon .nav-icon-text {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}
.nav-tab .nav-icon svg {
    width: 22px;
    height: 22px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.6;
    stroke-linecap: round;
    stroke-linejoin: round;
    /* ★ Motion 3.0：只变化描边粗细（激活态由 .active 那条改），明确属性 */
    transition: stroke-width 0.25s ease;
}
.nav-tab .nav-icon img { position: absolute; inset: 0; left: 2px; }
.nav-tab.active .nav-icon { transform: scale(1.12); }
.nav-tab.active .nav-icon svg { stroke-width: 1.8; }

/* 激活指示器 — 顶部小圆点 */
.nav-tab::before {
    content: '';
    position: absolute;
    top: 4px;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--accent);
    opacity: 0;
    transition: opacity 0.25s ease;
}
.nav-tab.active::before { opacity: 1; }

.nav-tab .nav-badge {
    position: absolute;
    top: 2px;
    right: calc(50% - 20px);
    /* ★ 2026-10 甲方定：小红点一律跟主题色走（--rose），不再用固定未读红。
       数字用暖褐 #3A322B——与 css/chat/chat-pins.css 的 #pins-badge 同一套口径
       （浅色主题的 --rose #C9A8A8 配白字只有 2.2:1，数字读不清）。 */
    background: var(--rose, #C9A8A8);
    color: #3A322B;
    font-size: 10px;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    display: none;
    align-items: center;
    justify-content: center;
    /* ★ 2028-09 甲方实锤「红点里的数字偏靠上、不居中」：根因是数字继承了 .nav-tab 按钮的
       line-height:1 + padding 4px 2px，字形盒被顶到红底上沿。
       口径（全站新增未读角标一律照这个写）：**行高与高度相等**把字形盒摆正，
       再由**上下 padding 归零**去掉多余留白；flex 居中只作兜底、不依赖它单独生效。 */
    padding: 0 4px;
    line-height: 16px;
    font-family: var(--font-serif-en);
    text-align: center;
    box-shadow: 0 1px 4px rgba(201,168,168,0.4);
}
.nav-tab .nav-badge.show { display: flex; }

/* 键盘出现时隐藏底部导航栏 */
#bottom-nav.nav-hidden { display: none; }

/* ================================================================
   Sub-tabs（「我的」标签页 / 小窝内子标签）
   ================================================================ */
.sub-tab-bar {
    display: flex;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    padding: 0 4px;
    background: var(--surface);
}
/* 问题5：窄屏适配 — 横向可滚动，不换行 */
.nest-sub-bar {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
}
.nest-sub-bar::-webkit-scrollbar { display: none; }
.sub-tab-btn {
    flex: 1;
    padding: 12px 8px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    font-size: 13px;
    font-family: inherit;
    color: var(--text-secondary);
    /* ★ Motion 3.0 硬规则：明确指定实际变化的属性，不用 transition: all */
    transition: color 0.22s ease, opacity 0.22s ease;
    position: relative;
    letter-spacing: 0.3px;
    white-space: nowrap;       /* 问题5：防止3字项折行 */
    overflow: hidden;
    text-overflow: ellipsis;
}
/* 窄屏手机（≤375px）子标签按钮缩小 */
@media (max-width: 375px) {
    .sub-tab-btn {
        padding: 12px 5px;
        font-size: 11px;
    }
}
.sub-tab-btn::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 2px;
    background: var(--accent-gradient);
    border-radius: 1px;
    transition: width 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.sub-tab-btn.active { color: var(--accent); font-weight: 600; }
.sub-tab-btn.active::after { width: 60%; }

/* 子面板切换：display切换，无需全屏叠化，仅内容区轻微淡入 */
.sub-tab-panel {
    display: none;
    flex: 1;
    overflow-y: auto;
    padding: 16px 16px calc(var(--nav-height) + var(--safe-bottom) + 32px + var(--kbd-h,0px)) 16px;
    flex-direction: column;
}
.sub-tab-panel.active {
    display: flex;
    /* ★ 禁止常驻入场动画：display:none↔flex 切换会让动画整体重播（离开再回来=整面板闪一下）。
       需要淡入的子视图用 JS 一次性 class（如设置子页 .ssp-show）。 */
}
/* 不需要默认 padding 的面板自行覆盖 */
#nest-sub-rules, #nest-sub-treasury, #sub-settings { padding: 0; }
/* settings子页面的absolute叠层需要relative定位锚点 */
#sub-settings { position: relative; }
/* 我的标签页需要relative定位支撑settings-sub-views的absolute覆盖 */
#tab-my { position: relative; }

/* ================================================================
   Smooth Scrolling（所有可滚面板统一平滑）
   ================================================================ */
#chat-container, .tab-panel, .sub-tab-panel, .nest-sub-panel,
.br-text-panel, .note-popover-thread,
.ep-content-area, .category-editor-scroll, .admin-body,
.rules-editor-textarea, .split-preview,
.bookshelf-grid-outer {
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;  /* 问题10：防止橡皮筋效果导致页面级滚动 */
    /* ★ 常驻预留滚动条那道槽（2028-09 外文返工 · 甲方原文第 4 条）。
       为什么必须在这一条上写：外文点开单词详情时是一个 position:fixed 的弹层，
       底层这个滚动容器一旦因为内容变化出现/消失系统滚动条，视口可用宽度就变 4px
       （core.css 里那条 webkit-scrollbar 的 width 是 4px）—— 甲方实锤「点开详情右边
       冒出一条滑动栏，页面被压缩一下」。scrollbar-gutter 的 stable 档让那道位置一直留着，
       有没有滚动条都不改宽度，打开/关闭前后宽度必然一致。
       这是全站既有惯例（panels-calendar / panels-memory-lib / panels-mailbox 同款），
       放在共享选择器上是为了所有子面板都免疫这一类「滚动条一冒出来整页跳一下」。
       注意：这条注释里绝不能出现「星号紧跟斜杠」的写法，否则注释当场闭合、
       下一条规则整条被浏览器吃掉（长期规则 #86 实锤）。 */
    scrollbar-gutter: stable;
}
/* ★ 一级页面的滚动条不画出来（2028-10-01 甲方真机实锤）
   现象：安卓上小窝 / 我的 / 记忆库 右侧有一条贯穿整屏的浅灰竖带（甲方原话
   「右侧没铺满、漏边、整体靠左」）。真机截图逐行量过：那条带宽 4 CSS 像素，
   与上面那条 `::-webkit-scrollbar { width: 4px }` 完全一致 —— 它是**滚动条自身
   被画了出来**，不是内容没铺满（同图里卡片左右边缘 41 / 992 是对称的）。
   为什么只有这三处看得见：朋友圈整片面板的滚动条早就藏了（panels-moments.css），
   小窝 / 我的 / 记忆库 这三处是**自己滚自己**的容器、滚动条一直露着。
   修法＝与朋友圈同款同源：只把「画不画滚动条」关掉，**不动布局**——
   `scrollbar-gutter: stable` 那条常驻槽宽度一个字没改，所以「有没有滚动条都不改宽度」
   这条既有保证仍然成立，也不会出现「打开详情整页跳一下」的老毛病。
   注意：这条注释里绝不能出现「星号紧跟斜杠」的写法（长期规则 #86）。 */
.nest-sub-panel, .myh-scroll, .ml-body-scroll { scrollbar-width: none; -ms-overflow-style: none; }
.nest-sub-panel::-webkit-scrollbar, .myh-scroll::-webkit-scrollbar,
.ml-body-scroll::-webkit-scrollbar,
.tab-panel::-webkit-scrollbar { width: 0; height: 0; display: none; }
.tab-panel { scrollbar-width: none; -ms-overflow-style: none; }
/* ★ 滚动条既然不画了，那道「常驻槽」也必须撤掉（2028-10-01 甲方真机第二轮实锤）
   上面那条 `scrollbar-gutter: stable` 原本是为「滚动条一出现/消失，可用宽度变 4px、整页跳一下」
   而常驻预留的。但这三处现在**根本不画滚动条了**，槽就永远填不满 —— 甲方真机看到的就是
   「右侧没铺满 / 整体靠左 / 漏边」，量出来正好 4 像素。
   本机 A/B 定死（同一份 App，只改这一个属性）：`stable` → 面板内容宽 385px；`auto` → 389px。
   撤掉之后宽度恒定（滚动条永远不画 = 永远不会忽宽忽窄），原来防的那个「跳一下」不再存在。 */
.nest-sub-panel, .myh-scroll, .ml-body-scroll { scrollbar-gutter: auto; }
/* ★ 上层容器也要一起撤（2028-10-01 真机第三轮量到）：同一页里「槽是叠起来的」——
   「我的」页实测：#tab-my 393 →（留槽）389 →（#sub-home 又留一道）385 → .myh-scroll 385。
   可是这两层根本不画滚动条：#tab-my 是 overflow:hidden，真正的滚动发生在内层 .myh-scroll 上。
   它们留槽＝纯白留。所以凡是「自己不显示滚动条、滚动交给内层容器」的层级一律撤掉；
   真正自己滚自己的容器（外文详情、便签、日历等）保持原样不动。 */
.sub-tab-panel, #tab-my { scrollbar-gutter: auto; }
/* 聊天容器禁用浏览器原生滚动锚定：位置保持全靠手动锚点补偿，
   否则定位消息/加载历史时浏览器会自动调 scrollTop 造成「滑一页」偏移 */
#chat-container {
    overflow-anchor: none;
}

/* ===== 问题10：全局操作手感优化 ===== */
/* 交互元素即时反馈：轻触缩放 */
button:active, .nav-tab:active, .sub-tab-btn:active,
.ep-item:active, .plus-item:active, .ep-group-icon:active,
.fav-filter-tab:active, .card:active {
    transform: scale(0.97);
    transition: transform 0.08s ease;
}
/* 所有可滚动区域触摸优化 */
.tab-panel, .sub-tab-panel, .nest-sub-panel, .ep-content-area,
#chat-container,
.br-text-panel, .note-popover-thread, .category-editor-scroll,
.rules-editor-textarea, .admin-body, .split-preview, .bookshelf-grid-outer {
    touch-action: pan-y;  /* 允许垂直滚动，阻止浏览器手势拦截 */
}
/* ★ 滑动条防误触（2026-09）：浏览器默认 range 是 touch-action:none——
   手指碰到轨道会锁住滚动并把圆球跳到手指位置。改 pan-y：垂直滚动照常，
   轨道触摸不跳值由 core.js 的 pointerdown 近圆球守卫负责（只有按住圆球拖才调值）。 */
input[type="range"] {
    touch-action: pan-y;
}
/* 横向滚动区域 */
.ep-group-bar, .ep-swipe-track, .plus-page-content, .nest-sub-bar,
.img-carousel-track {
    touch-action: pan-x;
}
/* 面板动画GPU加速提示 */
.bottom-panel, #task-bar {
    will-change: height, opacity;
}

/* ================================================================
   Scrollbars — 细线条风格
   ================================================================ */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: rgba(180,170,160,0.22);
    border-radius: 2px;
    transition: background 0.2s ease;
}
::-webkit-scrollbar-thumb:hover { background: rgba(160,150,140,0.40); }
[data-theme-mode="dark"] ::-webkit-scrollbar-thumb { background: rgba(120,110,100,0.25); }
[data-theme-mode="dark"] ::-webkit-scrollbar-thumb:hover { background: rgba(150,140,130,0.40); }

/* ================================================================
   全局装饰类 — 英文花字 / 手写签名 / 分隔线
   遵循 DESIGN-SYSTEM.md §7
   ================================================================ */

/* 英文装饰小字：Cormorant Garamond，全大写，极小，用于面板副标题 */
.en-label {
    font-family: var(--font-reading);
    font-size: 9px;
    letter-spacing: 4px;
    text-transform: uppercase;
    color: var(--text-muted);
    line-height: 1;
}

/* 标题花字：Playfair Display，用于面板标题/品牌名 */
.title-decorative {
    font-family: var(--font-decorative);
    font-size: 20px;
    font-weight: 500;
    letter-spacing: 3px;
    font-style: italic;
}

/* 手写甜蜜小字：Great Vibes，仅用于签名/批注/浪漫小提示 */
.sweet-note {
    font-family: 'Great Vibes', var(--font-handwriting);
    font-size: 18px;
    color: var(--accent-rose);
    transform: rotate(-2deg);
    opacity: 0.75;
    line-height: 1;
}
/* 暗色模式下手写字颜色微调 */
[data-theme-mode="dark"] .sweet-note { color: #C8A0A8; }

/* 渐变消失的分隔线（替代无聊的实线） */
.divider-elegant {
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--border), transparent);
    margin: var(--space-lg) 0;
}

/* 三点装饰分隔 */
.divider-dots {
    text-align: center;
    letter-spacing: 8px;
    color: var(--text-muted);
    font-family: var(--font-decorative);
    font-size: 12px;
    margin: var(--space-md) 0;
}

/* 带英文花字副标题的标题组合 */
.title-with-deco {
    text-align: center;
}
.title-with-deco .cn {
    font-family: var(--font-decorative);
    font-size: 20px;
    font-weight: 500;
    font-style: italic;
    letter-spacing: 3px;
    color: var(--text-primary);
}
.title-with-deco .en {
    font-family: var(--font-reading);
    font-size: 9px;
    letter-spacing: 5px;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-top: 2px;
}

/* 卡片签名（右下角手写体） */
.card-signature {
    font-family: 'Great Vibes', var(--font-handwriting);
    font-size: 22px;
    color: var(--accent-rose);
    text-align: right;
    transform: rotate(-3deg);
    margin-top: var(--space-md);
    opacity: 0.7;
}

/* ================================================================
   全局卡片基类 — 多层阴影 + 内高光
   遵循 DESIGN-SYSTEM.md §3.1
   ================================================================ */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--space-lg);
    box-shadow:
        0 1px 0 rgba(255,255,255,0.5) inset,
        var(--shadow-sm);
    transition: all 0.2s ease;
}
.card:hover {
    transform: translateY(-2px);
    box-shadow:
        0 1px 0 rgba(255,255,255,0.5) inset,
        var(--shadow-md);
}
.card:active {
    transform: scale(0.97);
    transition: all 0.06s ease;
}
[data-theme-mode="dark"] .card {
    box-shadow:
        0 1px 0 rgba(255,255,255,0.04) inset,
        var(--shadow-sm);
}
[data-theme-mode="dark"] .card:hover {
    box-shadow:
        0 1px 0 rgba(255,255,255,0.04) inset,
        var(--shadow-md);
}

/* ================================================================
   全局按钮基类 — 三态反馈
   遵循 DESIGN-SYSTEM.md §4.1
   ================================================================ */
.btn {
    transition: all 0.15s ease;
    cursor: pointer;
}
.btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}
.btn:active {
    transform: scale(0.96);
    transition: all 0.06s ease;
}
.btn:disabled {
    opacity: 0.45;
    filter: grayscale(0.3);
    cursor: not-allowed;
    transform: none;
}

/* ================================================================
   全局动效 — 漂浮 / 呼吸 / 骨架屏
   遵循 DESIGN-SYSTEM.md §4.3-4.6
   ================================================================ */

/* 漂浮动画（装饰花字/花瓣/轻元素） */
@keyframes float {
    0%, 100% { transform: translateY(0px); }
    50%      { transform: translateY(-6px); }
}
.float-deco {
    animation: float 5s ease-in-out infinite;
}
.float-deco:nth-child(2) { animation-delay: 1.2s; }
.float-deco:nth-child(3) { animation-delay: 2.8s; }

/* 呼吸光晕（在线状态/等待指示器/未读红点） */
@keyframes pulse-glow {
    0%, 100% { box-shadow: 0 0 4px var(--accent-rose); }
    50%      { box-shadow: 0 0 14px var(--accent-rose); }
}

/* 骨架屏加载闪烁 */
@keyframes shimmer {
    0%   { background-position: -200px 0; }
    100% { background-position: 200px 0; }
}
.skeleton {
    background: linear-gradient(90deg,
        var(--surface) 25%,
        rgba(210,195,180,0.2) 50%,
        var(--surface) 75%
    );
    background-size: 400px 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    border-radius: var(--radius-sm);
}

/* 弹性入场（弹窗/面板用） */
@keyframes slideUp {
    from { transform: translateY(60px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}
@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}
@keyframes popIn {
    from { opacity: 0; transform: scale(0.92) translateY(8px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* 列表交错入场 */
@keyframes slideInUp {
    from { transform: translateY(20px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}
.list-item {
    animation: slideInUp 0.4s ease both;
}
.list-item:nth-child(1) { animation-delay: 0.00s; }
.list-item:nth-child(2) { animation-delay: 0.06s; }
.list-item:nth-child(3) { animation-delay: 0.12s; }
.list-item:nth-child(4) { animation-delay: 0.18s; }
.list-item:nth-child(5) { animation-delay: 0.24s; }

/* 触摸波纹（替代系统默认灰色高亮） */
.touch-ripple {
    position: relative;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
}
.touch-ripple::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at center,
        rgba(200,180,165,0.18), transparent 60%);
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}
.touch-ripple:active::after {
    opacity: 1;
    transition: opacity 0s;
}

/* 毛玻璃遮罩 */
.glass-overlay {
    background: rgba(10, 8, 12, 0.55);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}
.glass-overlay-light {
    background: rgba(255, 252, 249, 0.65);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

/* ===== Header 列表模式坍塌（0高度，避免布局跳动） ===== */
#header.list-collapsed {
    height: 0 !important;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    padding-top: 0;
    padding-bottom: 0;
    border: none;
    transition: height 0.2s ease, opacity 0.15s ease;
}

/* ===== 聊天视图 — 完整全屏面板（WeChat风格：覆盖 header+内容区+底部栏） ===== */
.chat-view {
    position: fixed;
    top: 0; bottom: 0;
    left: 50%;
    width: 100%;
    max-width: 480px;
    z-index: 110;               /* 高于 #header(100) 和 #bottom-nav(100) */
    display: none;              /* 默认隐藏，进入聊天时 flex */
    flex-direction: column;
    background: var(--bg-chat);
    transform: translateX(calc(-50% + 100%)) translateZ(0);  /* 初始在屏幕右侧外 */
    transition: transform 0.3s cubic-bezier(0.25, 0.1, 0.25, 1);
    will-change: transform;
    -webkit-overflow-scrolling: touch;
    /* iOS 安全区：聊天界面是 position:fixed 全屏层（不随 #app 的 padding 下移），
       必须自己加顶部安全区，否则聊天头部/内容/输入栏被刘海和状态栏挡住。
       底部安全区由 #bottom-dock/.input-row 处理，这里只加顶部，避免重复留白。 */
    padding-top: var(--safe-top);
    /* ★ 2026 iOS：兜底裁剪任何超出容器顶部的面板/输入栏溢出（双重复合会让面板盖过 .chat-header） */
    overflow: hidden;
}
.chat-view.active {
    display: flex;
    transform: translateX(-50%);  /* 滑到屏幕正中 */
}
.chat-view.sliding {
    display: flex;                /* 滑出过程中保持可见 */
}
/* 桌面端：和 #app 一样加圆角和间距，高度约束和 #app 完全一致 */
@media (min-width: 768px) {
    .chat-view {
        top: 20px;
        bottom: 20px;
        border-radius: var(--radius-xl);
    }
}
/* 减少动效偏好：
   ① 跟着系统设置走（prefers-reduced-motion）；
   ② ★ 2028-09 第 9 窗口：她也能在「外文 → 单词 → 学习设置 → 少一点动效」里自己打开 ——
      那时 #app 上带 .ec-reduce-motion（唯一写者是 js/panels/ec/ec-vocab.js 的 ecApplyReduceMotion）。
      两条路做的事一样：把动效与过渡压到几乎为 0，绝不留位移。 */
@media (prefers-reduced-motion: reduce) {
    .chat-view { transition: none; }
}
.ec-reduce-motion *, .ec-reduce-motion *::before, .ec-reduce-motion *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
}

/* ===== 聊天界面内置顶部栏（chat-view 子元素，和界面一起滑入） ===== */
.chat-header {
    display: grid;
    grid-template-columns: 44px 1fr 44px;
    align-items: center;
    height: var(--header-height);
    padding: 0 6px;
    background: var(--surface);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    box-shadow:
        0 1px 0 rgba(255,255,255,0.4) inset,
        0 2px 12px rgba(160,145,130,0.06);
}
[data-theme-mode="dark"] .chat-header {
    box-shadow:
        0 1px 0 rgba(255,255,255,0.05) inset,
        0 2px 12px rgba(0,0,0,0.20);
}
.chat-header .ch-left  { display: flex; align-items: center; justify-content: flex-start; }
.chat-header .ch-center { display: flex; flex-direction: column; align-items: center; justify-content: center; cursor: pointer; min-width: 0; }
.chat-header .ch-right  { display: flex; align-items: center; justify-content: flex-end; }
.chat-header .ch-name {
    font-family: 'Playfair Display', var(--font-decorative);
    font-style: italic; font-weight: 500;
    font-size: 18px; letter-spacing: 1.5px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    max-width: 100%; color: var(--text-primary);
}
.chat-header .ch-status {
    font-size: 11px; color: var(--text-secondary);
    display: flex; align-items: center; gap: 4px;
    font-family: 'Inter', 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    letter-spacing: 0.5px;
}
.chat-header .ch-status::before {
    content: ''; width: 6px; height: 6px; border-radius: 50%;
    background: var(--online);
    animation: breathe 2s ease-in-out infinite;
    box-shadow: 0 0 8px rgba(139,201,160,0.4);
    flex-shrink: 0;
}
.chat-header .ch-back-btn {
    background: none; border: none; cursor: pointer;
    color: var(--text-primary);
    padding: 8px 6px; min-width: 40px; min-height: 40px;
    border-radius: var(--radius-sm);
    transition: all 0.15s ease;
    display: flex; align-items: center; justify-content: flex-start;
    -webkit-tap-highlight-color: transparent;
}
@media (hover: hover) {
    .chat-header .ch-back-btn:hover { background: var(--accent-light); color: var(--accent); }
}
.chat-header .ch-back-btn:active { transform: scale(0.92); }
.chat-header .ch-more-btn {
    background: none; border: none; font-size: 20px;
    cursor: pointer; color: var(--text-primary);
    padding: 4px 8px; font-family: inherit;
    letter-spacing: 2px; font-weight: 600;
    border-radius: var(--radius-sm);
    transition: all 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}
@media (hover: hover) {
    .chat-header .ch-more-btn:hover { color: var(--accent); }
}
.chat-header .ch-more-btn:active { transform: scale(0.94); }

/* 返回确认 Toast */
#exit-toast {
    position: fixed;
    bottom: calc(100px + env(safe-area-inset-bottom, 0px));
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: rgba(30, 28, 26, 0.88);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: #F8F4EF;
    font-family: var(--font-body);
    font-size: 13px;
    letter-spacing: 1px;
    padding: 11px 26px;
    border-radius: var(--radius-full);
    z-index: 20000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
    white-space: nowrap;
    box-shadow: 0 8px 32px rgba(0,0,0,0.22);
}
#exit-toast.show {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(-50%) translateY(0);
}
[data-theme-mode="dark"] #exit-toast {
    background: rgba(248, 244, 239, 0.92);
    color: #1A1614;
}

/* ===== Splash 加载动画 ===== */
#splash {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: #F8F4EF;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 28px;
    transition: opacity 0.4s ease;
}
#splash.fade-out { opacity: 0; pointer-events: none; }

/* 星星容器 */
.sp-stars { position: absolute; inset: 0; pointer-events: none; }

/* 星星 — 十字光点 */
.sp-star {
    position: absolute;
    width: 6px; height: 6px;
    background: var(--gold, #C4A86A);
    border-radius: 50%;
    animation: spTwinkle 2s ease-in-out infinite;
    animation-delay: var(--d, 0s);
    box-shadow:
        0 0 4px rgba(196, 168, 106, 0.6),
        0 0 12px rgba(196, 168, 106, 0.2);
}
/* 十字光芒 */
.sp-star::before, .sp-star::after {
    content: '';
    position: absolute;
    background: var(--gold, #C4A86A);
    border-radius: 1px;
}
.sp-star::before {
    width: 14px; height: 1px;
    top: 2.5px; left: -4px;
    opacity: 0.5;
}
.sp-star::after {
    width: 1px; height: 14px;
    top: -4px; left: 2.5px;
    opacity: 0.5;
}

/* 品牌区 */
.sp-brand { text-align: center; display: flex; flex-direction: column; gap: 10px; }
.sp-title {
    font-family: 'Playfair Display', Georgia, serif;
    font-style: italic;
    font-size: 46px;
    letter-spacing: 5px;
    color: var(--rose, #C9A8A8);
    text-shadow: 0 0 32px rgba(200, 160, 160, 0.25);
}
.sp-sub {
    font-family: 'Noto Serif SC', 'STSong', serif;
    font-size: 12px;
    letter-spacing: 2px;
    color: var(--text-muted, #BFB8AE);
}

/* 进度条轨道 */
.sp-bar-track {
    width: 140px;
    height: 2px;
    background: rgba(180, 170, 155, 0.2);
    border-radius: 1px;
    overflow: hidden;
}
.sp-bar-fill {
    width: 0%;
    height: 100%;
    border-radius: 1px;
    background: linear-gradient(90deg, var(--gold, #C4A86A), var(--rose, #C9A8A8), var(--gold, #C4A86A));
    background-size: 200% 100%;
    animation: spShimmer 2s linear infinite;
    transition: width 0.4s ease;
}

/* 动画 */
@keyframes spTwinkle {
    0%, 100% { opacity: 0.15; transform: scale(0.8); }
    50%      { opacity: 1;    transform: scale(1.4); }
}
@keyframes spShimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ===== 聊天加载遮罩 ===== */
#chat-loading-overlay {
    position: absolute; inset: 0; z-index: 50;
    display: flex; align-items: center; justify-content: center;
    background: rgba(248,244,239,0.88);
    backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
    transition: opacity 0.3s ease;
}
.chat-loading-inner { text-align: center; }
.chat-loading-ring {
    width: 44px; height: 44px; margin: 0 auto 16px;
    border: 2px solid var(--border);
    border-top-color: var(--rose);
    border-radius: 50%;
    animation: clSpin 0.8s linear infinite;
}
.chat-loading-dot { display: none; }
.chat-loading-text {
    font-size: 13px; color: var(--text-muted);
    font-family: var(--font-body); letter-spacing: 0.5px;
}
@keyframes clSpin { to { transform: rotate(360deg); } }

/* ============================================================
   卡顿自愈：提示条 + 轻快化（js/perf-guard.js）
   ============================================================ */
.perf-hint {
  position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%) translateY(8px);
  width: calc(100% - 28px); max-width: 452px; z-index: 4000;
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px;
  background: var(--surface-solid, #fffdf8);
  border: 1px solid var(--gold-light, rgba(201,168,138,0.4));
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(60,40,25,0.18);
  opacity: 0; transition: opacity 0.22s ease, transform 0.22s ease;
}
.perf-hint.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.perf-hint-txt { flex: 1; font-size: 12.5px; color: var(--text-secondary, #8a7a70); line-height: 1.5; }
.perf-hint-btn {
  flex: 0 0 auto; border: none; border-radius: 20px; padding: 8px 14px;
  background: linear-gradient(135deg, var(--rose,#c98d90), var(--rose-dark,#b26f74));
  color: #fff; font-size: 13px; cursor: pointer;
  transition: transform 0.18s ease;
}
.perf-hint-btn:active { transform: scale(0.96); }
.perf-hint-close {
  flex: 0 0 auto; width: 26px; height: 26px; border: none; background: transparent;
  color: var(--text-muted, #a89a90); font-size: 18px; line-height: 1; cursor: pointer;
}
@media (max-width: 370px) {
  .perf-hint { width: calc(100% - 20px); padding: 10px 12px; }
  .perf-hint-txt { font-size: 12px; }
}
/* 轻快化（点「一键轻快化」后生效）：临时压掉重型滤镜/长动效/合成层，不伤布局 */
#app.perf-hard, #app.perf-hard * { backdrop-filter: none !important; -webkit-backdrop-filter: none !important; }
#app.perf-hard * { animation-duration: 0.001s !important; animation-delay: 0s !important; transition-duration: 0.001s !important; will-change: auto !important; }

/* ============================================================
   「省电轻快模式」——手机上长期省着用（点一次一直有效，再点关掉）
   ------------------------------------------------------------
   为什么要有它：甲方手机上的卡是「点得动、但画面重绘慢」，而且点一次轻快化只顶 4 秒。
   这一档是**可以一直开着的**，但只收「每次重绘都要重算一大片」的东西，不动字体排版与卡片：
     · 整屏铺满的毛玻璃（每次重绘都要对整屏重算一遍）
     · 背景迷雾/极光/可可雾这类**大块 + 高斯模糊**的飘动元素（手机上最贵的合成）
     · 主题图片粒子
   小图标、小卡片、返回条上的毛玻璃**全部保留**（那是设计质感，摘了会变廉价）。
   ============================================================ */
body.perf-lite #app,
body.perf-lite #app .chat-view {
  /* #app 本来就是不透明底，整屏毛玻璃在它身上**没有任何视觉效果**，纯浪费手机显卡 */
  backdrop-filter: none !important; -webkit-backdrop-filter: none !important;
}
body.perf-lite .amb-mist, body.perf-lite .amb-fog, body.perf-lite .amb-glow,
body.perf-lite .amb-aurora, body.perf-lite .amb-cocoa, body.perf-lite .amb-sunset,
body.perf-lite .amb-warm, body.perf-lite .amb-rainbow, body.perf-lite .amb-cocoa-drift {
  display: none !important;
}
body.perf-lite #ambient-layer img { display: none !important; }

/* ===== 运行时体检报告（点「体检」出来的那张纸卡）===== */
.perf-report {
  position: fixed; left: 50%; bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  width: calc(100% - 24px); max-width: 456px; z-index: 4100;
  display: flex; align-items: flex-end; justify-content: center;
  transform: translateX(-50%) translateY(10px); opacity: 0;
  transition: opacity .22s ease, transform .22s ease;
}
.perf-report.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.perf-report-card {
  width: 100%; padding: 16px 16px 12px;
  background: var(--surface-solid, #fffdf8);
  border: 1px solid var(--gold-light, rgba(201,168,138,.4));
  border-radius: 18px; box-shadow: 0 14px 36px rgba(60,40,25,.20);
}
.perf-report-title {
  font-family: var(--font-decorative, 'Playfair Display', Georgia, serif);
  font-style: italic; font-size: 15px; color: var(--accent, #C9A8A8); margin-bottom: 8px;
}
.perf-report-body {
  font-size: 12.5px; line-height: 1.7; color: var(--text-secondary, #8a7a70);
  white-space: pre-line; max-height: 40vh; overflow-y: auto;
}
.perf-report-actions { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.perf-report-btn {
  flex: 1; border: none; border-radius: 18px; padding: 9px 12px;
  background: linear-gradient(135deg, var(--rose,#c98d90), var(--rose-dark,#b26f74));
  color: #fff; font-size: 13px; font-family: var(--font-body); cursor: pointer;
  transition: transform .18s ease;
}
.perf-report-btn-quiet { background: var(--surface, #fff); color: var(--text-secondary,#8a7a70); border: 1px solid var(--border, rgba(0,0,0,.08)); }
.perf-report-btn:active { transform: scale(.96); }
.perf-report-close {
  flex: 0 0 auto; border: none; background: transparent; color: var(--text-muted, #a89a90);
  font-size: 13px; font-family: var(--font-body); padding: 8px 6px; cursor: pointer;
}
@media (max-width: 370px) {
  .perf-report { width: calc(100% - 16px); }
  .perf-report-body { font-size: 12px; }
}


