/* ==========================================================================
   心情美 · 全站背景与深色适配（theme-bg.css  v2）
   —— 用于“完成系统背景（Bg）问题”，四件事：
      1) 统一文档底色：html 与 body 同底色，消除底部/滚动区不铺满的浅色带；
      2) 移动端铺满：body 最小高度按动态视口（100dvh），顶栏/底栏不被地址栏裁切；
      3) 声明 color-scheme，避免浏览器自动反色把页面背景改坏；
      4) 系统深色（prefers-color-scheme: dark）时全站统一切换深色面板与文字色。
   —— 面板清单与文字清单均来自线上逐页「明暗两态对比度实测」，
      只收录实测确有低对比（<3.0）的元素，不做通用猜测；发现遗漏可在本表追加。
   —— 全部规则都在 dark 媒体查询内，浅色（light）呈现完全不受影响。
   —— 回退方式：删除本文件，并从模板 <head> 移除 theme-bg.css 的 <link> 即可完全复原。
   —— 引入位置：每个页面 <head> 末尾（页面自身 <style> 之后），版本号用于击穿 7 天强缓存。
   ========================================================================== */

:root { color-scheme: light; }

html {
  background: var(--bg, var(--ds-bg, #f6f7fb));
  min-height: 100%;
}
body {
  min-height: 100vh;
  min-height: 100dvh;
}

/* ---------------- 深色模式 ---------------- */
@media (prefers-color-scheme: dark) {

  /* 用 html:root 提升优先级，压过各页面自身 <style> 里的 :root 变量；
     同时覆盖 design-system 的 --ds-* 令牌，让 .ds-* 组件一起适配 */
  html:root {
    color-scheme: dark;
    --bg: #10131f;
    --panel: #1a1e2e;
    --card: #1a1e2e;
    --panel2: #222739;
    --line: #2a2f45;
    --border: #2a2f45;
    --text: #eef0f8;
    --text2: #c3c8dc;
    --muted: #8b90a3;
    --shadow: 0 4px 18px rgba(0, 0, 0, .35);
    --ds-bg: #10131f;
    --ds-panel: #1a1e2e;
    --ds-panel-2: #222739;
    --ds-line: #2a2f45;
    --ds-line-strong: #363c56;
    --ds-text: #eef0f8;
    --ds-text-2: #c3c8dc;
    --ds-muted: #8b90a3;
    --ds-muted-2: #6b7188;
    --ds-brand-50: #232840;
    --ds-brand-100: #2b2f4d;
    --ds-success-bg: #15291d;
    --ds-warn-bg: #2a2113;
    --ds-danger-bg: #2c1a1a;
    --ds-info-bg: #16233a;
    --ds-sh-2: 0 4px 18px rgba(0, 0, 0, .35);
    --ds-sh-3: 0 10px 32px rgba(0, 0, 0, .5);
  }

  html { background: #080b13 !important; }
  body {
    background-color: var(--bg) !important;
    color: var(--text) !important;
  }

  /* --- 浅色面板/容器 → 深色面板 -------------------------------------------
     只覆盖 background-color（不覆盖 background），品牌渐变、商品图、封面图不受影响 */
  .card, .stat, .wx-panel, .modal-box, .form-card, .rule-item, .rule-card,
  .quick-item, .quick-nav, .mall-zone, .video-zone, .profit-body, .bottom-nav,
  .group-card, .dist-card, .record-card, .friend-card, .score-card, .appeal-card,
  .status-card, .action-card, .agreement-box, .moment-card, .publish-panel,
  .header, .modal-sheet, .action-sheet, .actions, .gc-list, .gc-bar, .tb-navbar,
  .staff-bar, .subject-tabs, .chat-input, .chat-input-bar, .notice-card, .msg.bot,
  .input-bar, .m-card, .addr-item, .om-card, .oa-status, .oa-card, .pkg, .sheet,
  .buybar, .tabbar, .toolbar, .search-bar, .search-box, .upload-preview,
  .more-panel, .mall-card, .mall-img, .mall-img-wrap, .bubble, .message .bubble,
  .list-item, .order-card, .product-card, .goods-card, .cart-item, .wallet-card,
  .task-card, .service-card, .panel, .sheet-box, .empty, .loading, .dialog,
  .drawer, .mask-box, .input-wrap, .eligible-box, .form-card, .agree-box,
  .tab-bar, .stats-bar, .topbar, .rec-card, .v-thumb, .big-icon,
  .btn-secondary, .btn-cancel, .gc-ok, .b-logo, .action-sheet-item {
    background-color: var(--panel) !important;
    color: var(--text);
  }

  /* 深色下隐藏层的遮罩保持深色 */
  .mask, .overlay, .backdrop { background-color: rgba(8, 11, 19, .62) !important; }

  /* --- 页面内硬编码的深色文字 → 深色下的正文色 ---------------------------
     html:root 前缀让规则稳过页面内两段类选择器（如 .form-card .section-title），
     故无需 !important；正文类用 --text，次要说明类用 --text2（对比度均 > 8） */
  html:root p, html:root li, html:root strong, html:root b, html:root em,
  html:root h1, html:root h2, html:root h3, html:root h4, html:root h5, html:root h6,
  html:root label, html:root dt, html:root dd, html:root figcaption,
  html:root blockquote, html:root td, html:root th,
  html:root .section-title, html:root .title, html:root .header-title,
  html:root .content-text, html:root .option-value, html:root .mall-name,
  html:root .a-detail, html:root .cnt, html:root .rules, html:root .om-section-title,
  html:root .nm, html:root .mall-tab, html:root .logo, html:root .status-text,
  html:root .ma-text, html:root .t-title, html:root .li-title, html:root .post-text,
  html:root .goods-name, html:root .task-title, html:root .friend-name,
  html:root .card-title, html:root .item-title, html:root .list-title,
  html:root .modal-text, html:root .dialog-text, html:root .empty-text {
    color: var(--text);
  }

  html:root .option-label, html:root .confirm-text, html:root .note,
  html:root .status-desc, html:root .desc, html:root .sub, html:root .muted,
  html:root .who, html:root .tip, html:root .hint, html:root .placeholder {
    color: var(--text2);
  }

  /* 点赞/评论/删除操作按钮：深色下未激活态用次要文字色，
     已赞（红）与删除（红）保持语义色，按下态用深色反馈 */
  html:root .action-btn:not(.liked):not(.delete-btn) { color: var(--text2); }
  html:root .action-btn:not(.liked):not(.delete-btn) svg { fill: var(--text2); }
  html:root .action-btn:active { background-color: #2b2f4d; }

  /* 警示/免责说明（浅底深红字）在深色下改用浅警示色，保留语义 */
  html:root .dist-desc { color: #ef9a8e; }

  /* 浅底彩色小徽标（已取消）→ 深底浅字，保留色相语义 */
  html:root .badge-cancelled { background-color: #3a2229 !important; color: #ff9aa8; }

  /* 输入类控件 */
  input, textarea, select {
    background-color: #131722 !important;
    color: var(--text) !important;
    border-color: var(--line) !important;
  }
  input::placeholder, textarea::placeholder { color: #6b7188 !important; }

  hr, .divider { border-color: var(--line); }

  img { opacity: .97; }
}