/* ============================================================
   成语接龙 · 分页校准层 v1.0
   配套 theme.css，必须在其之后加载。作用于除首页外的 13 个页面。

   本轮做的事：
   - 把各页内联 CSS 里的 55 处渐变、1021 处旧色字面量收敛到语义 token
   - 修复 132 处浅灰文字（#999/#888…）的对比度
   - 精修每页特有组件：profile / learn / daily / rules / hall 等
   - 提供 .site-nav / .site-footer 公共组件样式（片段见 ui-preview/components/）

   约束：不改动任何 id、class、DOM 结构。回滚见文末。
   ============================================================ */

:root {
  --gold-soft:  #F7F0DF;
  --jade-soft:  #EAF1ED;
  --slate-soft: #EAF0F3;
}

/* ---------- 1. 通用收口：字阶、焦点、触控、残留动效 ---------- */
body:not(.page-home) h1 { font-family: var(--font-serif); letter-spacing: .02em; }
body:not(.page-home) :is(.daily-score, .stat-value, .random-char-text,
  .hall-next-char, .hall-start-char, .dc-chain, .long-chain) {
  font-family: var(--font-serif);
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--red) !important;
  box-shadow: 0 0 0 3px rgba(163, 44, 38, .12) !important;
}

button, .btn, .nav-link, .tab-btn, .level-chip, .daily-option {
  min-height: 40px;
  border-radius: var(--r-sm);
}

/* 关闭用的「×」：一律用 flex 把字形压在圆/方框正中，且不被上面的 40 / 44px 触控高度撑歪 */
button.hall-modal-close,
.long-fs-close,
.em-close,
.idiom-detail-close,
.correction-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  min-height: 0;
  line-height: 1;
}
/* 「×」字形本身偏下，光学上移 1px 才看着在正中 */
button.hall-modal-close,
.long-fs-close,
.em-close {
  padding-bottom: 1px;
}

/* 去掉残留的 hover 上浮（上一轮评审：2015 年拟物风） */
:is(.card, .stat-card, .mode-card, .diff-card, .ach-item, .daily-card,
    .random-card, .dc-card, .long-fs, .notice-item, .rank-row):hover {
  transform: none !important;
}

/* 只收敛结构性图标的彩色 emoji；聊天内容、昵称里的 emoji 必须保留原样 */
.nav-link, .site-footer, .hall-head, .hall-chat-head { font-variant-emoji: text; }

/* ---------- 2. 公共导航 / 页脚组件样式 ----------
   片段：ui-preview/components/nav.html、footer.html
   接入方式：把片段粘进页面，给当前页面的 <a> 加 class="on"。 */
.site-nav {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  padding: 10px 0 12px; margin-bottom: var(--sp-4);
  border-bottom: 1px solid var(--line);
}
.site-nav a {
  display: inline-flex; align-items: center; gap: 5px;
  min-height: 40px; padding: 8px 13px;
  color: var(--ink-2); text-decoration: none;
  background: transparent; border: 1px solid transparent;
  border-radius: var(--r-sm); font-size: var(--fs-sm);
  transition: background .18s var(--ease), color .18s var(--ease);
}
.site-nav a svg { width: 16px; height: 16px; fill: none; stroke: currentColor;
  stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.site-nav a:hover { background: var(--paper-sunk); color: var(--red); }
.site-nav a.on { color: var(--red); background: var(--red-soft); border-color: var(--red-line); }
.site-nav .nav-brand {
  font-family: var(--font-serif); font-size: var(--fs-lg); font-weight: 700;
  color: var(--ink); margin-right: auto; letter-spacing: .08em;
}
.site-footer {
  border-top: 1px solid var(--line); margin-top: var(--sp-6);
  padding: var(--sp-5) 0; color: var(--ink-3);
  font-size: var(--fs-sm); line-height: 1.9;
}
.site-footer a { color: var(--ink-2); text-decoration: none; }
.site-footer a:hover { color: var(--red); }

/* ---------- 3. profile：墨色头部 + 去掉光斑 + 统计卡收敛 ---------- */
body.page-profile .profile-header {
  background: var(--ink) !important;
  border-radius: var(--r-lg) !important;
  box-shadow: var(--shadow-2) !important;
}
body.page-profile .profile-header::before,
body.page-profile .profile-header::after { display: none; }
body.page-profile .profile-header h1 { font-family: var(--font-serif); }
body.page-profile .profile-header .nav-link.back {
  background: rgba(255, 255, 255, .10) !important;
  color: var(--paper-card) !important;
  border: 1px solid rgba(255, 255, 255, .22) !important;
  backdrop-filter: none;
}
body.page-profile .profile-header .nav-link.back:hover {
  background: rgba(255, 255, 255, .18) !important;
  color: var(--paper-card) !important;
  transform: none;
}
body.page-profile .profile-avatar {
  background: var(--red) !important;
  box-shadow: var(--shadow-2) !important;
  font-family: var(--font-serif);
}
body.page-profile .stat-card {
  background: var(--paper-card) !important;
  border: 1px solid var(--line) !important;
  border-left: 2px solid var(--line) !important;
  border-radius: var(--r-sm) !important;
}
body.page-profile .stat-card:hover {
  background: var(--red-soft) !important;
  border-color: var(--red-line) !important;
  box-shadow: var(--shadow-1) !important;
}
body.page-profile .stat-value { font-size: var(--fs-xl); color: var(--ink); }
body.page-profile .ach-item {
  border: 1px solid var(--line) !important;
  border-radius: var(--r-sm) !important;
  background: var(--paper-card) !important;
  box-shadow: none !important;
}
body.page-profile .ach-progress-bar { background: var(--red); border-radius: 999px; }

/* ---------- 4. idiom_learn：搜索区宣纸化、四字格母题 ---------- */
body.page-idiom-learn .learn-header h1 { font-family: var(--font-serif); }
body.page-idiom-learn .learn-logo {
  background: var(--red) !important;
  border-radius: var(--r-sm) !important;
  box-shadow: var(--shadow-2) !important;
  font-family: var(--font-serif);
}
body.page-idiom-learn .search-section {
  background: var(--paper-sunk) !important;
  border: 1px solid var(--line) !important;
  border-radius: var(--r-md) !important;
}
body.page-idiom-learn .level-chip {
  border-radius: var(--r-sm) !important;
  border: 1px solid var(--line) !important;
  background: var(--paper-card) !important;
  color: var(--ink-2) !important;
}
body.page-idiom-learn .level-chip.active {
  background: var(--red) !important;
  border-color: var(--red) !important;
  color: var(--paper-card) !important;
  box-shadow: none !important;
}
body.page-idiom-learn .random-card {
  background: var(--paper-card) !important;
  border: 1px solid var(--line) !important;
  border-radius: var(--r-md) !important;
  box-shadow: var(--shadow-2) !important;
}
body.page-idiom-learn .random-char {
  border: 1px solid var(--red-line) !important;
  background: var(--red-soft) !important;
  border-radius: var(--r-sm) !important;
  box-shadow: none !important;
}
body.page-idiom-learn .random-def {
  background: var(--gold-soft) !important;
  border-left: 3px solid var(--gold) !important;
  border-radius: var(--r-sm) !important;
}
body.page-idiom-learn .random-meta { color: var(--ink-3); }

/* ---------- 5. daily / daily_chain：去掉渐变与彩色描边 ---------- */
body.page-daily .daily-explain,
body.page-daily-chain .dc-card,
body.page-chain-long .long-chain {
  background: var(--paper-card) !important;
  border: 1px solid var(--line) !important;
  border-radius: var(--r-md) !important;
}
body.page-daily .daily-explain { font-family: var(--font-serif); font-size: var(--fs-lg); }
body.page-daily .daily-option { min-height: 48px; border-radius: var(--r-sm) !important; }
body.page-daily .daily-option.selected {
  background: var(--red-soft) !important;
  border-color: var(--red) !important;
  box-shadow: none !important;
}
body.page-daily .daily-score { color: var(--red); }
body.page-daily .daily-progress i { background: var(--red) !important; }
body.page-daily :is(.daily-share-btn, .poster-save) {
  box-shadow: var(--shadow-1) !important;
  border-radius: var(--r-sm) !important;
}
body.page-daily .daily-share-ghost { border-color: var(--red-line) !important; }

/* ---------- 6. game_rules：三色难度卡 → 统一浅底 + 语义色左条 ---------- */
body.page-game-rules :is(.mode-card h3, .mode-single h3, .mode-multi h3) {
  color: var(--ink) !important;
  font-family: var(--font-serif);
}
body.page-game-rules .diff-card {
  background: var(--paper-card) !important;
  color: var(--ink) !important;
  border: 1px solid var(--line) !important;
  border-left: 3px solid var(--red) !important;
  border-radius: var(--r-sm) !important;
  box-shadow: var(--shadow-1) !important;
}
body.page-game-rules .diff-easy { border-left-color: var(--success) !important; }
body.page-game-rules .diff-mid  { border-left-color: var(--warning) !important; }
body.page-game-rules .diff-hard { border-left-color: var(--danger) !important; }
body.page-game-rules .diff-card .name { font-family: var(--font-serif); }
body.page-game-rules .diff-card .count {
  background: var(--paper-sunk) !important; color: var(--ink-2) !important;
}
body.page-game-rules :is(.example-box, .notice-box, .purpose) {
  background: var(--paper-sunk) !important;
  border: 1px solid var(--line) !important;
  border-radius: var(--r-sm) !important;
}

/* ---------- 7. hall：品牌字、主色按钮、桌面适度放宽 ---------- */
body.page-hall .hall-title { font-family: var(--font-serif); letter-spacing: .08em; font-weight: 700; }
body.page-hall .hall-next-char { color: var(--red); }
body.page-hall .hall-btn {
  background: var(--red) !important; border-radius: var(--r-sm) !important;
  box-shadow: none !important;
}
body.page-hall .hall-send {
  background: var(--red) !important; border-radius: var(--r-sm) !important;
}
body.page-hall .hall-chain, body.page-hall .hall-chat { background: var(--paper-card); }
/* 顶部三个控件统一为中性描边，避免「统计」独自泛红 */
body.page-hall .hall-back {
  background: var(--paper-sunk) !important; color: var(--ink-2) !important;
}
body.page-hall .hall-me {
  color: var(--ink-2) !important; border-color: var(--line) !important;
  border-radius: var(--r-sm) !important;
}
body.page-hall .hall-stat-btn {
  background: var(--paper-sunk) !important; color: var(--ink-2) !important;
  border: 1px solid var(--line) !important; border-radius: var(--r-sm) !important;
  min-height: 32px; font-weight: 500;
}
body.page-hall .hall-stat-btn:active { background: var(--red-soft) !important; }
@media (min-width: 1024px) {
  body.page-hall .hall-shell { max-width: 960px; }
  body.page-hall .hall-head { padding: 0 20px; }
}

/* ---------- 8. 其余页面：统一卡片 / 提示框语义 ---------- */
body:is(.page-notice, .page-feedback, .page-page, .page-big-room,
       .page-idiom-chain, .page-leaderboard, .page-chain-long) :is(.card, .box, .notice-item, .msg-card) {
  border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--paper-card); box-shadow: var(--shadow-1);
}
body:is(.page-notice, .page-feedback, .page-page) h2,
body:is(.page-notice, .page-feedback, .page-page) h3 { font-family: var(--font-serif); }

/* ---------- 9. 手机端：触控目标、宋体标题收敛 ---------- */
@media (max-width: 600px) {
  button, .btn, .nav-link, .tab-btn, .level-chip, .daily-option { min-height: 44px; }
  /* 卡片底部「收藏 / 纠错 / 朗读」：与宝典难度按钮同规格，不再被 44px 撑高 */
  .card-actions { gap: 6px; }
  .card-action-btn, .tts-btn.tts-mini {
    display: inline-flex; align-items: center; justify-content: center;
    height: 28px; min-height: 0; padding: 0 10px; font-size: 12px; line-height: 1;
  }
  /* 顶部导航：44px 会把整行撑高、挤压换行，统一压到 30px */
  .nav-link {
    display: inline-flex; align-items: center; gap: 4px;
    height: 30px; min-height: 0; padding: 0 10px; font-size: 12px; line-height: 1;
  }
  .nav-link .nav-i { width: 13px; height: 13px; }
  /* 个人中心「搜索用户 / 黑名单 / 清空」这类小工具按钮 */
  .chat-clear-btn, .btn-change-email, #avatarUploadBtn { height: 26px; min-height: 0; padding: 0 8px; font-size: 12px; line-height: 1; }
  /* 其它页面的小号次级按钮：按自身内边距高度，不再被 44px 撑高 */
  .br-ghost, .c-btn, .rm-btn { min-height: 0; }
  /* 首页「难度：简单 / 中等 / 困难 + 重新开局」：与宝典难度按钮同规格 */
  body.page-home .form-row { gap: 6px; }
  body.page-home .form-row > span { font-size: 12px; white-space: nowrap; }
  body.page-home .level-btns { flex: 1 1 auto; min-width: 0; flex-wrap: nowrap; gap: 4px; }
  body.page-home .level-btn {
    flex: 1 1 0; min-width: 0; height: 28px; min-height: 0;
    padding: 0 4px; font-size: 12px; line-height: 26px; border-radius: 6px;
  }
  body.page-home #singleReset { flex: none; height: 28px; min-height: 0; padding: 0 10px; font-size: 12px; }
  body:not(.page-home) h1 { font-size: var(--fs-lg); }
  .site-nav { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .site-nav::-webkit-scrollbar { display: none; }
  .site-nav a { flex: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---------- 10. 个人中心：未登录空态 ---------- */
body.auth-pending .wrap, body.auth-guest .wrap { display: none; }
.auth-gate { display: none; }
body.auth-pending .auth-gate, body.auth-guest .auth-gate {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 32px 20px; background: var(--paper);
}
.auth-gate-card {
  width: 100%; max-width: 400px; text-align: center;
  background: var(--paper-card); border: 1px solid var(--line);
  border-radius: 16px; padding: 36px 28px 26px;
  box-shadow: 0 12px 40px rgba(38,34,30,.07);
}
.auth-gate-seal {
  width: 56px; height: 56px; margin: 0 auto 20px;
  display: flex; align-items: center; justify-content: center;
  background: var(--red); color: var(--paper-card); border-radius: 10px;
  font-family: "Noto Serif SC", "Songti SC", serif; font-size: 30px; font-weight: 700;
}
.auth-gate-card h2 { margin: 0 0 10px; font-size: 22px; color: var(--ink); }
.auth-gate-card p { margin: 0 0 24px; font-size: 14px; line-height: 1.7; color: var(--ink-3); }
.auth-gate-actions { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.auth-gate-actions[hidden] { display: none; }
.auth-gate-actions .btn-red {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: 0 28px; border-radius: 10px;
  text-decoration: none; font-size: 15px; font-weight: 600;
}
.auth-gate-back { color: var(--ink-3); font-size: 13px; text-decoration: none; }
.auth-gate-back:hover { color: var(--red); }
.auth-gate-links {
  margin-top: 26px; padding-top: 18px; border-top: 1px solid var(--line-soft);
  font-size: 12px; color: var(--ink-3);
}
.auth-gate-links a { color: var(--ink-3); text-decoration: none; }
.auth-gate-links a:hover { color: var(--red); }
body.auth-guest .support-fab-root, body.auth-pending .support-fab-root { display: none !important; }

/* ---------- 11. 接龙大厅：主视觉、信息密度、桌面双栏 ---------- */
body.page-hall .hall-top { padding: 10px 16px 12px; }
body.page-hall .hall-round { gap: 12px; }
body.page-hall .hall-round-mid {
  flex-wrap: wrap; align-items: center; gap: 2px 8px;
  border-left: 1px dashed var(--red-line); padding-left: 14px;
}
body.page-hall .hall-round-label { font-size: 12px; color: var(--ink-2); }
body.page-hall .hall-next-char { font-size: 26px; color: var(--red); letter-spacing: 0; }
body.page-hall .hall-next-tip { margin-left: 2px; }
body.page-hall .hall-next-py { font-size: 13px; color: var(--ink-2); }
body.page-hall .hall-count { font-size: 14px; color: var(--ink-2); }
body.page-hall .hall-idle { font-size: 12px; }
body.page-hall .hall-round-right { line-height: 1.5; }
body.page-hall .hall-chat { flex-basis: 26vh; min-height: 140px; }
body.page-hall .hall-chat-head { font-size: 12px; color: var(--ink-2); padding: 8px 14px; }
body.page-hall .hall-chat-head > span:first-child::before {
  content: ''; display: inline-block; width: 3px; height: 12px;
  background: var(--red); border-radius: 2px; margin-right: 8px; vertical-align: -2px;
}
body.page-hall .hall-chat-list { padding: 10px 14px; }
body.page-hall .chat-empty, body.page-hall .hall-empty { color: var(--ink-3); }
body.page-hall .hall-tip { font-size: 12px; color: var(--ink-3); }

@media (max-width: 600px) {
  /* 手机把「现在要接」独立成第二行，给主角足够字号 */
  body.page-hall .hall-round { flex-wrap: wrap; gap: 6px 12px; }
  body.page-hall .hall-round-start { flex: 1 1 auto; }
  body.page-hall .hall-round-right { order: 2; }
  body.page-hall .hall-round-mid {
    order: 3; flex: 1 0 100%; border-left: none; padding-left: 0;
    border-top: 1px dashed var(--red-line); padding-top: 8px;
  }
  body.page-hall .hall-next-char, body.page-hall .hall-round.solo .hall-next-char { font-size: 24px; }
}

/* 聊天区按内容自适应：过滤掉刷屏播报后，把省下的高度还给链条。
   .kb-chat 状态排除，避免破坏软键盘弹起时的折叠逻辑。 */
@media (max-width: 1023px) {
  body.page-hall:not(.kb-chat) .hall-chat {
    flex: 0 0 auto; height: auto; min-height: 0; max-height: 32vh;
  }
  body.page-hall:not(.kb-chat) .hall-chat-list {
    flex: 0 1 auto; min-height: 0; max-height: 20vh;
  }
}

@media (min-width: 1024px) {
  body.page-hall .hall-shell {
    max-width: 1180px; margin: 20px auto; height: calc(100dvh - 40px);
    border: 1px solid var(--line); border-radius: 16px;
    display: grid; grid-template-columns: minmax(0, 1fr) 330px;
    grid-template-rows: 48px auto minmax(0, 1fr) auto;
    grid-template-areas:
      "head    head"
      "top     chat"
      "chain   chat"
      "compose chat";
    box-shadow: 0 16px 48px rgba(38,34,30,.08);
  }
  body.page-hall .hall-head { grid-area: head; }
  body.page-hall .hall-top { grid-area: top; }
  body.page-hall .hall-chain { grid-area: chain; min-height: 0; }
  body.page-hall .hall-compose { grid-area: compose; }
  body.page-hall .hall-closed { grid-area: chain; }
  body.page-hall .hall-chat {
    grid-area: chat; flex-basis: auto; min-height: 0; height: 100%;
    border-top: none; border-left: 1px solid var(--line);
    background: var(--paper);
  }
  body.page-hall .hall-chat-list { padding: 14px 16px; }
  body.page-hall .chain-line { font-size: 21px; }
  body.page-hall .hall-jump { right: 350px; bottom: 96px; }
  body.page-hall .hall-round-mid { border-left: 1px dashed var(--red-line); }
  body.page-hall .hall-round-mid::after { flex: 0 0 auto; }
}

/* ---------- 12. 统一页脚（footer.js 新版结构） ---------- */
.site-footer { text-align: center; border-top: 0; padding: 0; }
.site-footer-inner {
  max-width: 880px; margin: 0 auto; padding: 22px 16px 26px;
  border-top: 1px solid var(--line);
}
.site-footer-brand {
  display: flex; align-items: center; justify-content: center; gap: 9px;
  color: var(--ink); font-size: 14px; font-weight: 600; margin-bottom: 10px;
}
.site-footer-seal {
  width: 24px; height: 24px; border-radius: 6px; background: var(--red);
  color: var(--paper-card); display: inline-flex; align-items: center; justify-content: center;
  font-family: "Noto Serif SC", "Songti SC", serif; font-size: 14px; font-weight: 700;
}
.site-footer p { margin: 4px 0; }
.site-footer-links {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 14px;
  margin-top: 12px !important;
}
.site-footer-links a { font-size: 12px; }
.site-footer-beian { margin-top: 10px !important; font-size: 12px; color: var(--ink-3); }
.site-footer-beian a { color: var(--ink-3); }
.site-footer-line { display: none; }

/* ---------- 回滚 ----------
   1) 删除各页 <link ... theme-pages.css>；
   2) 用 ui-preview/backup/round2/*.before 覆盖对应 HTML；
   3) 删除 theme-pages.css。
   只想看旧版视觉时，仅执行第 1 步即可（内联色值已是 token，需配合 theme.css）。
   ============================================================ */
