/* ===== 主题系统（H5 版，从 app.wxss 迁移）=====
   所有颜色走 CSS 变量；页面根节点 class="app-root theme-X" 切换。
   原小程序 rpx 改为 px（约 rpx/2）。 */

:root, .app-root {
  /* 默认主题 0 落日橙 */
  --bg: #1f2233;
  --bg-1: #262a40;
  --bg-2: #2a2e45;
  --border: #3a3f5c;
  --border-2: #5a6080;
  --text: #f2f2f7;
  --text-2: #c7cbe0;
  --text-3: #9aa0b5;
  --text-3-rgb: 154,160,181;
  --accent: #ff8c42;
  --accent-2: #ff6b1a;
  --accent-soft: #ffd9b0;
  --accent-ink: #1f2233;
  --accent-rgb: 255,140,66;
  --accent-soft-rgb: 255,217,176;
  --ghost-bg: rgba(255,255,255,0.08);
  --danger: #d63b3b;
  --danger-2: #ff6b6b;
  --danger-2-rgb: 255,107,107;
  --success: #4caf50;
  --success-rgb: 76,175,80;
  --info: #4a90e2;
  --info-2: #9fc2ff;
  --info-rgb: 74,144,226;
  --tile-bg: #f7f3e8;
  --tile-text: #1f2233;
  --tile-shadow: #c9c2ad;
  --ink-on-light: #23201a;
  --card-bg: #fdfaf3;
  --card-edge: #efe9dc;
  --card-hi: #ffffff;

  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "PingFang SC", "Helvetica Neue", sans-serif;
}

/* 1 莫兰迪粉（浅色） */
.theme-1 {
  --bg: #fdeacc; --bg-1: #fef2dc; --bg-2: #fffdf6;
  --border: #ead3a4; --border-2: #d9bc85;
  --text: #8e6050; --text-2: #a97b6b; --text-3: #be9798; --text-3-rgb: 190,151,152;
  --accent: #ec6698; --accent-2: #d94f84; --accent-soft: #d94f84;
  --accent-ink: #fffdf6; --accent-rgb: 236,102,152; --accent-soft-rgb: 217,79,132;
  --ghost-bg: rgba(142,96,80,0.08);
  --danger: #e04f3f; --danger-2: #ff7b6e; --danger-2-rgb: 255,123,110;
  --success: #6b9e4f; --success-rgb: 107,158,79;
  --info: #7e6b8f; --info-2: #b9a6c9; --info-rgb: 126,107,143;
  --tile-bg: #fffdf6; --tile-text: #6e4a3d; --tile-shadow: #ead3a4;
  --ink-on-light: #6e4a3d;
  --card-bg: #fffdf6; --card-edge: #fbf0d8; --card-hi: #ffffff;
}

/* 2 雾霾蓝（浅色） */
.theme-2 {
  --bg: #deeaea; --bg-1: #e7f0f0; --bg-2: #f7fafa;
  --border: #c6d4d6; --border-2: #a9bcc0;
  --text: #606d80; --text-2: #7a8aa0; --text-3: #9ba8b7; --text-3-rgb: 155,168,183;
  --accent: #edb5a5; --accent-2: #e09a85; --accent-soft: #b96b4c;
  --accent-ink: #5c4038; --accent-rgb: 237,181,165; --accent-soft-rgb: 185,107,76;
  --ghost-bg: rgba(96,109,128,0.08);
  --danger: #d96a6a; --danger-2: #e98b8b; --danger-2-rgb: 233,139,139;
  --success: #6fa08c; --success-rgb: 111,160,140;
  --info: #606d80; --info-2: #9ba8b7; --info-rgb: 96,109,128;
  --tile-bg: #f7fafa; --tile-text: #4e5a6e; --tile-shadow: #c6d4d6;
  --ink-on-light: #4e5a6e;
  --card-bg: #f7fafa; --card-edge: #e3edee; --card-hi: #ffffff;
}

/* 4 羊皮纸（浅色） */
.theme-4 {
  --bg: #f3ede1; --bg-1: #ece4d4; --bg-2: #e3d9c6;
  --border: #cdbfa6; --border-2: #a8967a;
  --text: #2b2620; --text-2: #5c5240; --text-3: #8a7d66; --text-3-rgb: 138,125,102;
  --accent: #c8741f; --accent-2: #a85e15; --accent-soft: #a85e15;
  --accent-ink: #fff7ec; --accent-rgb: 200,116,31; --accent-soft-rgb: 168,94,21;
  --ghost-bg: rgba(0,0,0,0.05);
  --danger: #c0392b; --danger-2: #e05a4a; --danger-2-rgb: 224,90,74;
  --success: #2e8b3a; --success-rgb: 46,139,58;
  --info: #2f6fd0; --info-2: #5a8fd0; --info-rgb: 47,111,208;
  --tile-bg: #fffdf7; --tile-text: #3a2f20; --tile-shadow: #cdbfa6;
  --ink-on-light: #3a2f20;
  --card-bg: #fffdf7; --card-edge: #efe6d4; --card-hi: #ffffff;
}

.app-root { min-height: 100vh; background: var(--bg); color: var(--text); }

/* 基础组件 */
.btn {
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: 8px;
  text-align: center;
  padding: 12px 0;
  font-weight: 600;
  border: none;
  cursor: pointer;
}
.btn-ghost {
  background: var(--ghost-bg);
  color: var(--text);
  border: 1px solid var(--border-2);
  border-radius: 8px;
  text-align: center;
  padding: 12px 0;
  cursor: pointer;
}
.tile {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin: 4px;
  background: linear-gradient(180deg, var(--card-hi) 0%, var(--card-bg) 62%, var(--card-edge) 100%);
  color: var(--ink-on-light);
  border-radius: 5px 5px 7px 7px;
  font-size: 22px;
  font-weight: 600;
  border: 1px solid var(--card-edge);
  box-shadow: 0 3px 0 var(--tile-shadow), 0 6px 10px rgba(0,0,0,.35), inset 0 1px 0 var(--card-hi);
  cursor: pointer;
  position: relative;
  transition: transform .14s ease, box-shadow .14s ease;
  user-select: none;
}
.tile.sel {
  transform: translateY(-8px);
  box-shadow: 0 10px 0 var(--tile-shadow), 0 14px 18px rgba(0,0,0,.45), inset 0 1px 0 var(--card-hi);
}
/* 点按高光（替代小程序 hover-class）：按下/悬停给即时反馈 */
.tile:active { filter: brightness(1.14); }
.tile:not(.sel):active { transform: translateY(-3px); }
@media (hover: hover) {
  .tile:hover { filter: brightness(1.07); }
  .tile.sel:hover { filter: brightness(1.07); }
}
/* 通用按钮点按反馈（手机按下微暗，替代原生点击态） */
.btn:active, .top-pill:active, .btn-draw:active:not(.disabled),
.modal-btn:active, .btn-result:active, .theme-fab:active,
.compose-actions > div:active, .compose-actions > button:active { filter: brightness(0.93); }
.muted { color: var(--text-3); }
.center { text-align: center; }

/* ===== 全局组件（跨页面统一）===== */
/* 主按钮：此前缺少基础样式，导致首页/说明页等按钮没有底色 */
.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: var(--accent-ink); border-radius: 10px; text-align: center; padding: 13px 0; font-weight: 700; font-size: 15px; cursor: pointer; }
.btn-primary.sm { padding: 10px 0; border-radius: 8px; font-size: 14px; }
.btn-primary.disabled { background: var(--border); color: var(--text-3); pointer-events: none; box-shadow: none; }
/* 请求在途：按钮进入 busy 态（视觉变淡 + 拦截重复点击），全站统一 */
.btn-primary.busy, .btn-ghost.busy, .btn.busy { opacity: .6; pointer-events: none; cursor: default; }

/* ===== 主题悬浮球 + 底部选色抽屉（对齐小程序 theme-fab）=====
   层叠顺序约定（全站统一，改这里前先看这一行）：
     内容 < 顶栏 50 < 悬浮球 90 < 通用弹窗 100 < 结算浮层 150 < 主题抽屉 350 < toast 400
   悬浮球必须低于弹窗(100)：否则它会飘在所有弹窗/抽屉上面，压住弹窗按钮。 */
.theme-fab {
  position: fixed; right: 16px; bottom: 88px; z-index: 90;
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--bg-2); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; box-shadow: 0 4px 12px rgba(0,0,0,.35); cursor: pointer;
  touch-action: none;              /* 拖动时不要触发页面滚动 */
  user-select: none; -webkit-user-select: none;
}
.theme-fab:active { transform: scale(.92); }
.theme-fab.dragging { transform: scale(1.06); box-shadow: 0 8px 22px rgba(0,0,0,.45); }
.theme-fab.snapping { transition: left .2s ease-out, top .2s ease-out; }  /* 松手吸附到左/右边缘的过渡 */

.tf-mask {
  position: fixed; inset: 0; z-index: 350;
  background: rgba(0,0,0,.55);
  display: flex; align-items: flex-end;
}
.tf-sheet {
  width: 100%; box-sizing: border-box;
  background: var(--bg-2); border-radius: 16px 16px 0 0;
  padding: 18px 16px 26px;
  max-height: 84vh; overflow-y: auto;
  transform: translateY(100%);
}
.tf-mask.tf-in .tf-sheet { animation: tfUp .22s ease-out forwards; }
@keyframes tfUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.tf-title { font-size: 16px; font-weight: 700; color: var(--text); }
.tf-sub { font-size: 12px; color: var(--text-3); line-height: 1.6; margin: 6px 0 14px; }
.tf-list { display: flex; flex-direction: column; gap: 8px; }
.tf-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px; border-radius: 12px;
  background: var(--bg-1); border: 1px solid var(--border);
  cursor: pointer;
}
.tf-item.on { border-color: var(--accent); background: var(--bg-2); }
.tf-item:active { transform: scale(.985); }
.tf-swatch { display: flex; flex: 0 0 auto; }
.tf-dot { width: 20px; height: 20px; border-radius: 50%; margin-right: -6px; border: 2px solid var(--bg-2); }
.tf-name { flex: 1; font-size: 15px; font-weight: 600; color: var(--text); }
.tf-check { font-size: 17px; font-weight: 700; color: var(--accent); min-width: 20px; text-align: right; }
.tf-cancel { text-align: center; color: var(--text-3); font-size: 14px; padding: 14px 0 2px; cursor: pointer; }

/* 通用弹窗 */
.modal-mask { position: fixed; inset: 0; background: rgba(0,0,0,.65); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 16px; box-sizing: border-box; }
.modal-card { width: 90%; max-width: 320px; background: linear-gradient(160deg, var(--bg-2) 0%, var(--bg) 100%); border-radius: 14px; padding: 18px; box-sizing: border-box; box-shadow: 0 10px 30px rgba(0,0,0,.55); border: 1px solid var(--border); }
.modal-title { font-size: 18px; font-weight: 700; color: var(--accent-soft); text-align: center; margin-bottom: 8px; }
.modal-text { font-size: 13px; color: var(--text-2); line-height: 1.7; margin-bottom: 10px; text-align: center; }
.modal-btn { flex: 1; padding: 11px 0; border-radius: 8px; text-align: center; font-weight: 600; font-size: 14px; cursor: pointer; }
.modal-btn.ghost { background: var(--bg-2); color: var(--text-2); border: 1px solid var(--border); }
.modal-btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: var(--accent-ink); }
.modal-btn.danger { background: linear-gradient(135deg, var(--danger-2), var(--danger)); color: var(--accent-ink); }
.modal-id-row { background: var(--bg-2); border-radius: 8px; padding: 10px; margin-bottom: 10px; }
.modal-id-label { display: block; color: var(--text-3); font-size: 12px; margin-bottom: 4px; }
.modal-id { text-align: center; font-size: 16px; font-weight: 700; color: var(--accent); word-break: break-all; letter-spacing: 1px; line-height: 1.4; }
.modal-id-tip { display: block; color: var(--border-2); font-size: 12px; text-align: center; margin-top: 4px; }
.modal-btns { display: flex; gap: 8px; }
/* 表单类弹窗：字段名 / 输入框 / 说明 / 按钮之间留出层次，别挤在一起 */
.modal-label { display: block; font-size: 13px; color: var(--text-3); margin: 4px 0 6px; }
.modal-field { width: 100%; box-sizing: border-box; height: 46px; background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 0 12px; font-size: 15px; color: var(--text); outline: none; }
.modal-field:focus { border-color: var(--accent); }
.modal-note { font-size: 12px; color: var(--text-3); line-height: 1.6; margin: 8px 0 0; }
.modal-btns.gap { margin-top: 18px; }
.modal-close { text-align: center; color: var(--text-3); font-size: 13px; margin-top: 12px; cursor: pointer; }

/* 反馈表单 */
.feedback-input { width: 100%; height: 90px; box-sizing: border-box; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 8px; font-size: 14px; color: var(--text); margin-bottom: 12px; resize: none; }
.feedback-actions { display: flex; gap: 8px; }

/* Toast */
.toast { position: fixed; left: 50%; top: 38%; transform: translateX(-50%); background: rgba(0,0,0,.82); color: #fff; padding: 10px 18px; border-radius: 10px; font-size: 14px; z-index: 400; max-width: 80%; text-align: center; }

/* ===== 顶部导航栏（全局统一）===== */
.topbar { position: sticky; top: 0; height: 48px; display: flex; align-items: center; padding: 0 10px; z-index: 50; background: var(--bg); box-shadow: 0 1px 0 var(--border); box-sizing: border-box; }
/* 返回键：全站只有一个「＜」，做成 40×40 的圆形触摸区（移动端好按又不显笨重） */
.topbar-back { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; margin-left: -4px; border-radius: 50%; background: transparent; color: inherit; cursor: pointer; transition: background .14s ease, transform .12s ease; }
.topbar-back svg { width: 22px; height: 22px; display: block; }
.topbar-back:hover { background: var(--ghost-bg); }
.topbar-back:active { transform: scale(.9); background: var(--ghost-bg); }
/* 标题绝对定位居中：不依赖左右按钮等宽（联机页无返回键时 flex 方案会明显偏左） */
.topbar-title { position: absolute; left: 56px; right: 56px; top: 0; height: 48px; line-height: 48px; text-align: center; font-weight: 700; font-size: 17px; color: inherit; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; pointer-events: none; }
.topbar-right { min-width: 36px; display: flex; align-items: center; justify-content: flex-end; }

/* 主题球首访只做轻微呼吸，不再弹文字浮条（浮条会挡内容） */
.theme-fab.fab-pulse { animation: fabPulse 1.1s ease-in-out 3; }
@keyframes fabPulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.14); } }

/* ===== 首屏 loading 遮罩（各页共用，渲染完成后由页面脚本隐藏）===== */
.boot-mask { position: fixed; inset: 0; z-index: 120; background: var(--bg); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 24px; box-sizing: border-box; text-align: center; }
.boot-spin { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--border); border-top-color: var(--accent); animation: bootSpin .8s linear infinite; }
@keyframes bootSpin { to { transform: rotate(360deg); } }
.boot-text { font-size: 14px; color: var(--text-2); line-height: 1.7; max-width: 280px; }

/* 输入超限红色错误反馈 */
.input-limit-err { display: none; color: var(--danger-2, #ff6b6b); font-size: 12px; margin-top: 4px; line-height: 1.4; }
.input-limit-err.show { display: block; }

/* 自定义滚动条（覆盖出牌记录、弹窗、规则面板等所有可滚动区域） */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--accent) var(--bg-2);
}
*::-webkit-scrollbar { width: 6px; height: 6px; }
*::-webkit-scrollbar-track { background: var(--bg-2); border-radius: 3px; }
*::-webkit-scrollbar-thumb { background: var(--accent); border-radius: 3px; }
*::-webkit-scrollbar-thumb:hover { background: var(--accent-2); }
*::-webkit-scrollbar-corner { background: transparent; }
/* 横向滚动条拇指更扁，避免挤占 quick-bar 高度 */
.quick-bar::-webkit-scrollbar { height: 4px; }
.talk-list::-webkit-scrollbar { width: 4px; }
.discard::-webkit-scrollbar { width: 5px; }
