/* 问道修仙 · 样式
 *
 * 布局策略：一份 DOM，两种排布。
 *   桌面端（>768px）—— 四个功能页（修炼 / 历练 / 纳戒 / 坊市）用
 *     grid-template-areas 拼成三列，全部可见；
 *   移动端（≤768px）—— 只显示当前页，由底部导航切换。
 * 主题变量集中在 :root，改配色只需改这一处。
 */

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

:root {
  --bg: #f5f1e8;
  --panel: #ffffff;
  --panel2: #f0ebdd;
  --border: #e3dac4;
  --gold: #a8842c;
  --jade: #2f9e6e;
  --text: #3d3830;
  --dim: #8d8674;
  --red: #c9574c;
  --orange: #c9803a;      /* 属性「攻击」专用，与红/蓝区分开 */
  --blue: #3d7ac7;
  --tabbar-h: 60px;
  --logdock-h: 42px;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "微软雅黑", "PingFang SC", sans-serif;
  min-height: 100vh;
  padding: 16px;
}

/* 顶部留白：原先由 header 承担，移除后由容器补上，避免内容贴边 */
.container { max-width: 1080px; margin: 0 auto; padding-top: 12px; }

/* ================= 工作区：功能分页 ================= */

.workspace {
  display: grid;
  grid-template-columns: 300px 1fr 320px;
  grid-template-areas:
    "adventure  cultivate  bag"
    "log        cultivate  market";
  gap: 14px;
  align-items: start;
}

.page {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}
#page-cultivate { grid-area: cultivate; }
#page-adventure { grid-area: adventure; }
#page-market    { grid-area: market; }
#page-bag       { grid-area: bag; }
.log-dock    { grid-area: log;  min-width: 0; }

/* ================= 面板 ================= */

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  box-shadow: 0 1px 4px rgba(96,80,45,.07);
}
.panel h2 {
  font-size: 1.05em;
  color: var(--gold);
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
  margin-bottom: 10px;
  letter-spacing: 4px;
}

/* ================= 修真纪事：全局事件广播组件 ================= */

/*
  桌面端：工作区内的一个普通面板，位置与原「纪事」页一致。
  移动端：脱离文档流，固定在底部导航栏上方；收起时只露最新一条，
  展开时向上铺开显示历史。同一份 DOM，两种呈现。
*/
.log-dock {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  box-shadow: 0 1px 4px rgba(96,80,45,.07);
}
.log-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--gold);
  font-size: 1.02em;
  letter-spacing: 4px;
  padding-bottom: 8px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
/* 桌面端始终展开，不需要切换控件 */
.log-toggle, .log-tag { display: none; }

.log-body {
  height: 210px;
  overflow-y: auto;
  font-size: .82em;
  line-height: 1.7;
  color: var(--dim);
  padding-right: 6px;
}
.log-body .t { color: #b0a88f; margin-right: 6px; font-size: .92em; }
.log-body .good { color: var(--jade); }
.log-body .bad  { color: var(--red); }
.log-body .gold { color: var(--gold); }
.log-body::-webkit-scrollbar { width: 5px; }
.log-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ================= 顶部导航栏 ================= */

/*
  身份与资源的常驻展示区，与修炼面板解耦。
  右端 #res-bar 是资源槽容器：后续新增资源只需追加 .res 片段，
  布局与配色无需再动。
*/
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 4px 12px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--border);
}
.who {
  display: flex; align-items: center;
  width: auto;
  margin: 0;
  padding: 4px 10px;
  border: 1px solid transparent;
  background: none;
  border-radius: 8px;
  letter-spacing: 1px;
  min-height: 0;
  transition: background .15s, border-color .15s;
}
.who:hover { border-color: var(--border); background: var(--panel2); }
.who-name {
  color: var(--text);
  font-size: 1.05em;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 9em;
}

/* 改名输入框：替换 .who-name 的位置，样式保持一致 */
.rename-input {
  width: 9em;
  padding: 3px 6px;
  border: 1px solid var(--gold);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  font-family: inherit;
  font-size: 1em;
  font-weight: 600;
  letter-spacing: 1px;
  outline: none;
}

.realm-chip {
  flex: 1;
  text-align: center;
  color: var(--jade);
  font-size: 1em;
  font-weight: 600;
  letter-spacing: 2px;
  white-space: nowrap;
}

.res-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}
.res { display: inline-flex; align-items: baseline; gap: 4px; white-space: nowrap; }
.res-val { color: var(--gold); font-size: 1.1em; font-weight: 600; }
.res-unit { color: var(--dim); font-size: .78em; letter-spacing: 1px; }

/* ---- 修炼页 · 三张卡 ----
 *
 * 卡一「修为主卡」：左圆环 / 右信息。圆环是全局最关键的进度，
 * 所以给它最大的视觉权重；右侧信息（层次 / 速度 / 突破）纵向排列，
 * 与圆环形成「左图右文」的稳定构图。
 *
 * 卡二「属性卡」：血用血条（当前/上限），攻与防用纯数值行 ——
 * 它们没有「当前 vs 上限」的概念，强行套血条只会浪费一行高度。
 * 两种形态共用一套行结构，所以新增属性时 JS 不用分叉。
 *
 * 卡三「身世」：保持原有版式，玩法大改时再一起换。
 */
.card {
  border-radius: 14px;
  background:
    radial-gradient(140% 100% at 50% -30%, rgba(255,255,255,.95) 0%, rgba(255,255,255,0) 62%),
    linear-gradient(165deg, #f8f6ee 0%, #eef3ea 55%, #e9f0e9 100%);
  box-shadow:
    0 1px 2px rgba(96, 80, 45, .04),
    0 8px 24px -12px rgba(96, 80, 45, .18);
  padding: 18px 16px 16px;
}
.card-self { background: var(--panel); }
/* 身世卡的标题与其它页的 .panel h2 保持同一套排版 */
.card-self h2 {
  font-size: 1.05em;
  color: var(--gold);
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
  margin-bottom: 10px;
  letter-spacing: 4px;
}

/* ---- 卡一：圆环 ---- */
.card-main {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  display: grid;
  /* minmax(0, 1fr) 而不是 1fr：grid 轨道的 min-width 默认是 auto，
     不肯收缩到内容最小宽度以下。配合卡片的 overflow:hidden，
     超出部分会被直接裁掉——手机上表现为「修炼速度显示不全」。 */
  grid-template-columns: 132px minmax(0, 1fr);
  gap: 16px;
  align-items: center;
}

/* 太极水印：置于内容之下，极低不透明度，只在右下的留白处隐约可见 */
.card-mark {
  position: absolute;
  z-index: -1;
  right: -8%;
  bottom: -34%;
  font-size: 12em;
  line-height: 1;
  color: var(--jade);
  opacity: .05;
  user-select: none;
  pointer-events: none;
  animation: mark-breathe 9s ease-in-out infinite;
}
@keyframes mark-breathe {
  0%, 100% { transform: none; opacity: .05; }
  50%      { transform: translateY(-1.5%) scale(1.05); opacity: .075; }
}

.exp-ring-box { position: relative; width: 132px; height: 132px; }
.exp-ring { width: 100%; height: 100%; display: block; transform: rotate(-90deg); }
.ring-track {
  fill: none;
  stroke: rgba(47, 158, 110, .14);
  stroke-width: 9;
}
.ring-fill {
  fill: none;
  stroke: var(--jade);
  stroke-width: 9;
  stroke-linecap: round;
  /* dasharray / dashoffset 由 JS 按 expPct 写入 */
  transition: stroke-dashoffset .4s cubic-bezier(.4, 0, .2, 1), stroke .3s;
  filter: drop-shadow(0 1px 3px rgba(47, 158, 110, .35));
}
/* 修为溢出：圆环已封顶，转金色说明「其实还能连破好几级」 */
.ring-fill.is-overflow { stroke: var(--gold); filter: drop-shadow(0 1px 3px rgba(168, 132, 44, .4)); }

.ring-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  pointer-events: none;
}
.ring-pct {
  font-size: 1.6em;
  font-weight: 700;
  color: var(--jade);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.ring-pct span { font-size: .5em; margin-left: 1px; font-weight: 600; }
.exp-ring-box.is-overflow .ring-pct { color: var(--gold); }
.ring-cap { font-size: .7em; color: var(--dim); letter-spacing: 3px; }
.ring-num {
  font-size: .68em;
  color: var(--dim);
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
}

.main-side { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.main-realm { display: flex; align-items: baseline; gap: 8px; }
.main-realm-name { font-size: 1.5em; font-weight: 700; color: var(--text); letter-spacing: 2px; }
.main-realm-stage { font-size: .95em; color: var(--gold); letter-spacing: 2px; }

/* 修炼速度：做成可点的「胶囊」，点开弹出来源 */
.src-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255, 255, 255, .62);
  text-align: left;
  transition: background .18s, border-color .18s;
}
.src-chip:hover { background: #fff; border-color: var(--jade); }
.src-chip-k { font-size: .8em; color: var(--dim); flex-shrink: 0; }
.src-chip-v {
  flex: 1;
  color: var(--jade);
  font-weight: 700;
  font-size: 1.02em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.src-chip-arrow {
  width: 15px; height: 15px; flex-shrink: 0;
  color: var(--dim);
  transition: transform .22s;
}
.src-chip:active { background: #fff; border-color: var(--jade); }

/* ---- 数值来源弹窗：一行一个环节，不用长公式 ---- */
/* .modal 自带 text-align:center（老结算窗要居中排版），
   列表类内容继承过去会把分组标题也居中，这里改回左对齐。 */
.src-modal { max-width: 420px; text-align: left; }
.src-modal h3 { text-align: center; }
.src-modal-body {
  display: flex;
  flex-direction: column;
  margin-bottom: 16px;
  max-height: 56vh;
  overflow-y: auto;
}
.src-group {
  font-size: .74em;
  color: var(--dim);
  letter-spacing: 2px;
  margin: 10px 0 4px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
}
.src-group:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.src-item {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 2px;
  font-size: .92em;
  border-bottom: 1px dashed #ece5d2;
}
.src-item:last-child { border-bottom: 0; }
.src-item-k { color: var(--dim); flex-shrink: 0; }
.src-item-v {
  color: var(--text);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: right;
}
/* 合计行是这个弹窗的落点：加分隔 + 金色，一眼看到最终值 */
.src-item.is-strong {
  margin-top: 6px;
  padding-top: 10px;
  border-top: 1px solid var(--gold);
  border-bottom: 0;
}
.src-item.is-strong .src-item-k { color: var(--text); font-weight: 700; }
.src-item.is-strong .src-item-v { color: var(--gold); font-size: 1.1em; }

/* ---- 卡二：属性列表 ---- */
.card-attr { display: flex; flex-direction: column; gap: 2px; }
.attr-rows { display: flex; flex-direction: column; }

.attr-row {
  display: grid;
  /* 名字列要放得下「血量」两个字（显示名从单字改成了全称）。
     两字 CJK + 1px 字距 ≈ 32px，留到 40px 才稳。 */
  grid-template-columns: 40px minmax(0, 1fr) auto 12px;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 11px 4px;
  border: 0;
  border-bottom: 1px dashed #e6dfcc;
  background: none;
  text-align: left;
  transition: background .18s;
}
.attr-row:last-child { border-bottom: 0; }
.attr-row:hover { background: rgba(255, 255, 255, .6); }
/* 有弹窗了，行上不再需要「已展开」的高亮态 */
.attr-row:active { background: #fff; }

.attr-row-name {
  font-size: .95em;
  font-weight: 700;
  color: var(--attr-color, var(--jade));
  letter-spacing: 1px;
  white-space: nowrap;      /* 「血量」是两个字，绝不能折行 */
}
.attr-row-body { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
/* 血这一行：血条与「当前 / 上限」并排，省下一整行高度 */
.attr-row-body.is-inline { flex-direction: row; align-items: center; gap: 9px; }
.attr-row-body.is-inline .attr-hpbar { flex: 1; min-width: 0; }
.attr-row-body.is-inline .attr-row-val { flex-shrink: 0; }

/* 血条：只在这一行出现，其余属性没有「当前/上限」概念 */
.attr-hpbar {
  display: block;
  height: 9px;
  border-radius: 5px;
  background: rgba(0, 0, 0, .07);
  overflow: hidden;
}
.attr-hpbar.is-hidden { display: none; }
.attr-hpfill {
  display: block;
  height: 100%;
  width: 100%;
  border-radius: 5px;
  background: linear-gradient(90deg, #d9534f 0%, #c9574c 55%, #b0473d 100%);
  transition: width .32s cubic-bezier(.4, 0, .2, 1), background .3s;
}
.attr-hpbar.mid .attr-hpfill       { background: linear-gradient(90deg, #d9a03f, #c98a2c); }
.attr-hpbar.low .attr-hpfill       { background: linear-gradient(90deg, #a83a30, #8c2c22); }
.attr-hpbar.critical .attr-hpfill  { animation: hp-crit 1.1s ease-in-out infinite; }
@keyframes hp-crit {
  0%, 100% { filter: brightness(1); }
  50%      { filter: brightness(1.35); }
}

.attr-row-val {
  color: var(--text);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  font-size: .95em;
}
.attr-row-gain {
  font-size: .72em;
  color: var(--attr-color, var(--jade));
  font-variant-numeric: tabular-nums;
  opacity: .85;
  min-width: 34px;
  text-align: right;
}
.attr-row-arrow { color: var(--dim); font-size: 1.1em; line-height: 1; }
/* ---- 修炼页 · 进度与突破 ---- */
/* 修炼速度的数值由 .src-chip-v 负责排版。
   这里曾有一条 #rate-display 规则带着 text-align:center / margin-top，
   而 id 选择器优先级高于 class，会把胶囊里的数值强行居中并顶出间距 ——
   元素挪进胶囊后那条规则就该一起删掉，不要"留着万一用得上"。 */
#buff-line {
  color: var(--blue); font-size: .8em;
  text-align: center; min-height: 1.2em; margin-top: 2px;
}
/* 历练中：修炼暂停的提示条。金色虚线框与「已暂停」语义一致。 */
#idle-line {
  margin-top: 8px;
  padding: 6px 9px;
  border: 1px dashed var(--gold);
  border-radius: 6px;
  background: rgba(168, 132, 44, .07);
  color: var(--gold);
  font-size: .8em;
  text-align: center;
  line-height: 1.5;
}
#idle-line[hidden] { display: none; }

/* 突破按钮：修炼页唯一的主动作，做成大号、有呼吸感的金色主按钮 */
.breakthrough-btn {
  width: 100%;
  margin-top: 12px;
  min-height: 48px;
  font-size: 1.02em;
  letter-spacing: 1px;
  border-radius: 10px;
}
.breakthrough-btn:not(:disabled) {
  animation: ready-pulse 2.4s ease-in-out infinite;
}
@keyframes ready-pulse {
  0%, 100% { box-shadow: 0 2px 8px rgba(168, 132, 44, .28); }
  50%      { box-shadow: 0 3px 16px rgba(168, 132, 44, .48); }
}

/* 危险操作收进一个弱化的区块，避免和主按钮抢注意力 */
.danger-zone {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
  display: flex;
  gap: 8px;
}
.danger-zone button { flex: 1; min-height: 40px; font-size: .84em; }

/* ---- 年龄 / 寿元 ----
   接近寿元时转琥珀色、最后十年转红：让「会老死」有压迫感，
   而不是某天打开页面发现存档没了。 */
.age-row .v { font-variant-numeric: tabular-nums; }
.stat-row.is-warn .v { color: #c98a2c; }
.stat-row.is-danger .v { color: var(--red); }
.stat-row.is-danger { animation: age-pulse 1.8s ease-in-out infinite; }
@keyframes age-pulse {
  0%, 100% { background: transparent; }
  50%      { background: rgba(201, 87, 76, .07); }
}

/* ================= 通用元件 ================= */

.stat-row {
  display: flex; justify-content: space-between;
  padding: 7px 0;
  font-size: .92em;
  border-bottom: 1px dashed #e8e1cd;
}
.stat-row .k { color: var(--dim); }
.stat-row .v { color: var(--text); }

/* ---- 渡劫演出 ---- */
/*
 * 9 道天雷逐道落下。电光用一条竖直渐变 + 关键帧缩放模拟，
 * 刻意不用 canvas/图片 —— 这是纯 DOM 的轻量做法，手机上也不掉帧。
 */
.trib-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(18, 20, 26, .93);
  animation: fade-in .25s ease-out;
}
.trib-overlay[hidden] { display: none; }
.trib-sky {
  position: relative;
  width: min(420px, 88vw);
  padding: 26px 20px 22px;
  border-radius: 14px;
  background: linear-gradient(180deg, #1b1f2a, #12151c);
  box-shadow: 0 0 60px rgba(120, 160, 255, .18);
  overflow: hidden;
}
.trib-bolts { position: absolute; inset: 0; pointer-events: none; }
.trib-bolt {
  position: absolute;
  top: -8%;
  width: 3px;
  height: 116%;
  background: linear-gradient(180deg,
    rgba(255,255,255,0) 0%, #cfe4ff 18%, #ffffff 50%,
    #cfe4ff 82%, rgba(255,255,255,0) 100%);
  box-shadow: 0 0 14px rgba(190, 220, 255, .95);
  opacity: 0;
  transform: scaleY(.2);
}
.trib-bolt.strike {
  animation: bolt-strike .42s ease-out;
}
@keyframes bolt-strike {
  0%   { opacity: 0;   transform: scaleY(.2) scaleX(3); }
  18%  { opacity: 1;   transform: scaleY(1) scaleX(1.6); }
  40%  { opacity: .9;  transform: scaleY(1) scaleX(.8); }
  60%  { opacity: 1;   transform: scaleY(1) scaleX(1.3); }
  100% { opacity: 0;   transform: scaleY(1) scaleX(2.4); }
}
.trib-title {
  position: relative;
  text-align: center;
  font-size: 1.15em;
  font-weight: 700;
  letter-spacing: 5px;
  color: #dbe6ff;
  text-indent: 5px;
  margin-bottom: 14px;
}
.trib-hp {
  position: relative;
  height: 20px;
  border-radius: 10px;
  background: rgba(255, 255, 255, .1);
  overflow: hidden;
  margin-bottom: 12px;
}
.trib-hp-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #b8433a, #d4584c);
  transition: width .3s ease-out;
}
.trib-hp-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .7em;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .5);
  font-variant-numeric: tabular-nums;
}
/* 逐条追加的伤害流水 */
.trib-log {
  position: relative;
  max-height: 148px;
  overflow-y: auto;
  font-size: .76em;
  line-height: 1.75;
  color: #aebbd6;
  font-variant-numeric: tabular-nums;
}
.trib-log .row { display: flex; justify-content: space-between; gap: 8px; }
.trib-log .row.blocked { opacity: .55; }
.trib-log .dmg  { color: #ef7a6e; font-weight: 600; }
.trib-log .dmg.zero { color: #7f8ca6; }
.trib-log .remain { color: #cfd9ee; }

button {
  font-family: inherit;
  cursor: pointer;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel2);
  color: var(--text);
  padding: 10px 14px;
  font-size: .95em;
  width: 100%;
  margin-top: 8px;
  transition: all .15s;
  letter-spacing: 2px;
  -webkit-tap-highlight-color: transparent;
}
button:hover:not(:disabled) { border-color: var(--gold); color: var(--gold); }
button:disabled { opacity: .4; cursor: not-allowed; }
button.primary {
  background: linear-gradient(180deg, #c9a44a, #b08c33);
  border-color: var(--gold);
  color: #fff;
  font-size: 1.05em;
  padding: 13px;
  text-shadow: 0 1px 1px rgba(90,70,20,.35);
}
button.primary:hover:not(:disabled) { color: #fff; filter: brightness(1.08); }
button.danger:hover:not(:disabled) { border-color: var(--red); color: var(--red); }

.shop-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 9px 0;
  border-bottom: 1px dashed #e8e1cd;
  font-size: .88em;
  gap: 8px;
}
.shop-item:last-child { border-bottom: none; }
.shop-item .info .name { color: var(--text); }
.shop-item .info .desc { color: var(--dim); font-size: .82em; margin-top: 2px; }
.shop-item button { width: auto; margin: 0; padding: 7px 12px; font-size: .85em; flex-shrink: 0; }

/* ---- 纳戒：方形格子背包 ---- */
.bag {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}

/* ---- 历练：按境界解锁的挂机地点卡 ---- */
/*
  列表纵向排列，锁定地点沉底且不可点。地点卡是「挂机点」的入口，
  每张卡同时承担：地点说明 + 收益区间 + 掉落池提示 + 出发按钮。
*/
.sites { display: flex; flex-direction: column; gap: 8px; }
/* 同上：display:flex 会盖过 [hidden] */
.sites[hidden] { display: none; }
.site {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel2);
  transition: border-color .15s, background .15s;
}
.site-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.site-name { font-weight: 600; font-size: .98em; }
.site-stone {
  font-size: .78em;
  color: var(--gold);
  font-weight: 600;
  white-space: nowrap;
}
.site-desc { font-size: .78em; color: var(--text); opacity: .75; line-height: 1.45; }
.site-drop { font-size: .72em; color: var(--jade); opacity: .85; }
.site-go {
  margin-top: 4px;
  width: 100%;
  min-height: 34px;
  font-size: .85em;
}
.site.locked {
  background: transparent;
  border-style: dashed;
  border-color: #e6dfcb;
  opacity: .6;
}
.site.locked .site-stone { color: var(--text); opacity: .5; }

/* ---- 挂机中：历练进行时的面板 ---- */
/*
  与地点列表互斥显示。事件流是核心——它让「挂机」这件事可见：
  没有事件流，玩家只能盯一个跳动的秒表，感觉不到在推进。
*/
.idle-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 11px 12px;
  border: 1px solid var(--gold);
  border-radius: 8px;
  background: linear-gradient(180deg, #fbf6e6, var(--panel2));
}
/* display:flex 会盖过 [hidden] 的默认 display:none，必须显式声明 */
.idle-panel[hidden] { display: none; }
.idle-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.idle-where {
  display: flex;
  align-items: center;
  gap: 7px;
  font-weight: 600;
  font-size: 1.02em;
  color: var(--gold);
}
/* 呼吸的圆点：表示「正在进行」 */
.idle-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--jade);
  animation: idle-pulse 1.8s ease-in-out infinite;
  flex-shrink: 0;
}
@keyframes idle-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: .35; transform: scale(.78); }
}
.idle-clock {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 1.05em;
  color: var(--text);
}
.idle-sub {
  font-size: .74em;
  color: var(--text);
  opacity: .7;
}

/* 事件流：倒序（最新在上），固定高度可滚动 */
.idle-feed {
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-height: 210px;
  overflow-y: auto;
  padding: 8px 9px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: rgba(255, 255, 255, .72);
}
.idle-ev {
  display: flex;
  gap: 7px;
  font-size: .79em;
  line-height: 1.5;
  animation: idle-in .25s ease-out;
}
@keyframes idle-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: none; }
}
.idle-ev-time {
  flex-shrink: 0;
  color: var(--dim);
  font-size: .88em;
  font-variant-numeric: tabular-nums;
  opacity: .75;
}
.idle-ev-text { flex: 1; min-width: 0; }

/* 三级事件用颜色与左侧竖条区分：
   彩蛋 = 中性（纯内容）/ 小事件 = 玉绿（少量资源）/ 大事件 = 金（天材地宝）*/
.idle-ev.flavor { color: var(--text); opacity: .72; }
.idle-ev.flavor .idle-ev-text { font-style: italic; }
.idle-ev.minor  { color: var(--jade); }
.idle-ev.major  { color: var(--gold); font-weight: 600; }
.idle-ev.major .idle-ev-text { text-shadow: 0 0 8px rgba(168, 132, 44, .28); }

.idle-back {
  width: 100%;
  min-height: 40px;
  font-size: .9em;
}
.idle-empty {
  font-size: .78em;
  color: var(--dim);
  text-align: center;
  padding: 10px 0;
}
.slot {
  position: relative;
  aspect-ratio: 1;               /* 保持正方形格子 */
  width: auto;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel2);
  color: var(--text);
  display: grid;
  grid-template-rows: 1fr auto; /* 上面图片区，下面名称条 */
  cursor: pointer;
  transition: border-color .15s, background .15s;
  overflow: hidden;
}
.slot:hover:not(:disabled) { border-color: var(--gold); background: #f7f0dd; }
.slot.empty {
  background: transparent;
  border-style: dashed;
  border-color: #e6dfcb;
  cursor: default;
}
.slot-icon { font-size: 1.15em; font-weight: 600; color: var(--jade); }
/* 图片区：相对定位容器，承载美术资源 + 数量/售价角标 */
.slot-img-area {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
/* 美术资源：128×128 源图，object-fit 缩放到格子尺寸，不放大像素。
   必须绝对定位——图片区高度由 grid row 决定而非显式高度，
   flex 子元素写 height:100% 会解析失败导致图片塌陷成 0 高度。 */
.slot-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  pointer-events: none;      /* 点击交给格子本身 */
}
.slot-count {
  position: absolute; right: 3px; bottom: 1px;
  font-size: .68em; font-weight: 600;
  color: var(--gold);
  letter-spacing: 0;
  pointer-events: none;
}
/* 名称条：底部一行，名称必显示；坊市额外在右侧带售价 */
.slot-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  padding: 2px 5px;
  font-size: .72em;
  font-weight: 600;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  background: rgba(255, 255, 255, 0.55);
  white-space: nowrap;
  overflow: hidden;
  pointer-events: none;
}
.slot-label-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}
.slot-label-price {
  flex-shrink: 0;
  color: var(--gold);
  font-size: .95em;
}
.slot-label-price::before { content: "◆"; margin-right: 2px; font-size: .9em; }
/* 坊市格子买不起：整格灰暗，名称条价格变红 */
.slot.locked { opacity: .55; }
.slot.locked .slot-label-price { color: var(--red); }
.bag-meta {
  margin-top: 10px;
  text-align: right;
  font-size: .78em;
  color: var(--dim);
  letter-spacing: 1px;
}

/* ---- 道具详情浮窗 ---- */
.sheet-mask {
  display: none;
  position: fixed; inset: 0;
  background: rgba(60,50,30,.45);
  align-items: center; justify-content: center;
  z-index: 40;
  padding: 16px;
}
.sheet-mask.show { display: flex; }
.sheet {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--gold);
  border-radius: 12px;
  padding: 26px 24px 18px;
  width: 100%;
  max-width: 320px;
  text-align: center;
  box-shadow: 0 8px 40px rgba(120,95,40,.25);
}
.sheet-close {
  position: absolute; top: 6px; right: 6px;
  width: 34px; height: 34px;
  min-height: 0;
  margin: 0; padding: 0;
  border: none; background: none;
  color: var(--dim);
  display: flex; align-items: center; justify-content: center;
}
.sheet-close svg { width: 18px; height: 18px; }
.sheet-close:hover { color: var(--red); }
.sheet-icon {
  width: 62px; height: 62px;
  margin: 2px auto 10px;
  border-radius: 12px;
  background: var(--panel2);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.6em; font-weight: 600;
  color: var(--jade);
  overflow: hidden;
}
/* 浮窗图标复用美术资源。图片背景色 = 品阶底色（与 .sheet-icon 同底），
   所以不会有接缝；不套 object-fit 圆角，图片自带方角正好贴合圆角裁切。 */
.sheet-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  border-radius: 11px;
}
.sheet-name { color: var(--gold); font-size: 1.15em; letter-spacing: 3px; }
.sheet-type { color: var(--dim); font-size: .72em; letter-spacing: 1px; margin-top: 4px; }
.sheet-desc { color: var(--dim); font-size: .85em; line-height: 1.7; margin-top: 12px; }
.sheet-effect {
  color: var(--jade); font-size: .85em; line-height: 1.6;
  font-weight: 600; margin-top: 6px;
}
.sheet-own {
  display: flex; justify-content: space-between;
  padding: 9px 0; margin-top: 12px;
  border-top: 1px dashed #e8e1cd;
  font-size: .85em;
}
.sheet-own .k { color: var(--dim); }
.sheet-own .v { color: var(--gold); font-weight: 600; }
.sheet-actions { display: flex; gap: 8px; margin-top: 10px; }
.sheet-actions button { margin-top: 0; }
.sheet-actions .hidden-slot { display: none; }

.note { font-size: .78em; color: var(--dim); margin-top: 10px; line-height: 1.7; }

/* ================= 底部导航（桌面端隐藏） ================= */

.tabbar { display: none; }
.tab { width: auto; margin-top: 0; }

/* ================= 身世词缀：称号墙 =================
 *
 * 四档稀有度各有自己的气泡框 / 字体 / 特效，靠 data-rarity 切换，
 * 徽章 DOM 结构完全一致 —— 加一档稀有度只要在这里加一段。
 *
 *   凡 common   素框 + 细字，无特效（越普通越不抢眼）
 *   灵 uncommon 双线框 + 玉绿内发光
 *   玄 rare     描金斜切角 + 紫青流光横扫，字体加粗描边
 *   天 legend   鎏金双描边 + 呼吸光晕 + 金色渐变字
 */

.titles { margin-top: 14px; }
.titles-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 7px;
  margin-bottom: 9px;
  border-bottom: 1px solid var(--border);
}
.titles-title { font-size: .88em; color: var(--gold); letter-spacing: 3px; }
.titles-count {
  font-size: .78em;
  color: var(--dim);
  font-variant-numeric: tabular-nums;
}
.titles-list { display: flex; flex-wrap: wrap; gap: 8px; }
.titles-empty { font-size: .8em; color: var(--dim); opacity: .8; line-height: 1.7; }

/* 有待选词缀时的常驻入口：三选一只在「新一批」时自动弹，
   关掉之后靠这个按钮随时回来选。 */
.pending-cta {
  display: flex;
  align-items: center;
  gap: 7px;
  width: 100%;
  margin: 0 0 9px;
  padding: 9px 12px;
  border: 1px solid var(--gold);
  border-radius: 10px;
  background: linear-gradient(150deg, #fdf7e4, #f4e2ac);
  color: #8a6a1c;
  font-size: .84em;
  font-weight: 700;
  letter-spacing: 1px;
  animation: pending-breathe 2.2s ease-in-out infinite;
}
.pending-cta[hidden] { display: none; }
.pending-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--gold);
  flex-shrink: 0;
  box-shadow: 0 0 6px rgba(212, 175, 55, .9);
}
@keyframes pending-breathe {
  0%, 100% { box-shadow: 0 0 0 0 rgba(212, 175, 55, 0); }
  50%      { box-shadow: 0 0 14px -2px rgba(212, 175, 55, .7); }
}

.title-badge {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  /* 全局 button 是 width:100% + margin-top，这里要的是只包住文字的小方块 */
  width: auto;
  margin-top: 0;
  /* **必须清零**：移动端 `button { min-height: 46px }` 是给主要交互按钮
     保证触摸目标用的。称号徽章是纯展示，任何一点内边距都只会被那 46px
     撑成一大块留白 —— 类选择器优先级高于元素选择器，这里能盖掉它。 */
  min-height: 0;
  padding: 1px 5px 1px 2px;
  border-radius: 4px;              /* 方框，不做胶囊 */
  font-family: inherit;
  font-size: .78em;
  line-height: 1.15;              /* 压住行高，别让方框上下留白 */
  white-space: nowrap;
  overflow: hidden;
  cursor: pointer;
  border: 1px solid var(--bc);
  background: var(--bg1);
  color: var(--bc);
  transition: transform .18s, box-shadow .18s;
}
.title-badge:hover { transform: translateY(-1px); box-shadow: 0 4px 14px var(--bs); }
.title-badge:active { transform: translateY(0); }

/* 左端的稀有度字：凡灵玄天 */
.tb-rarity {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 12px; height: 12px;      /* 高度跟文字行齐，不要再撑高一档 */
  border-radius: 2px;              /* 与外框同语汇：方 */
  font-size: .7em;
  font-weight: 700;
  line-height: 1;
  color: var(--bg1);
  background: var(--bc);
  flex-shrink: 0;
}
.tb-name { font-weight: 600; letter-spacing: .5px; }
.tb-stack {
  font-size: .78em;
  opacity: .85;
  font-variant-numeric: tabular-nums;
  padding-left: 2px;
  border-left: 1px solid var(--bc);
}

/* ---- 凡品：素框，克制 ---- */
.title-badge[data-rarity="common"] {
  --bc: #8d8674;
  --bg1: rgba(255, 255, 255, .7);
  --bs: rgba(141, 134, 116, .25);
  font-weight: 400;
}

/* ---- 灵品：双线框 + 玉绿内发光 ---- */
.title-badge[data-rarity="uncommon"] {
  --bc: #2f9e6e;
  --bg1: linear-gradient(160deg, #eefaf3, #dff2e8);
  --bs: rgba(47, 158, 110, .3);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .8), 0 0 10px -2px rgba(47, 158, 110, .35);
}

/* ---- 玄品：描金斜切角 + 紫青流光 ---- */
.title-badge[data-rarity="rare"] {
  --bc: #6a5acd;
  --bg1: linear-gradient(150deg, #f3efff, #e2ecfb);
  --bs: rgba(106, 90, 205, .4);
  border-color: #9d8ce8;
  font-weight: 700;
  text-shadow: 0 1px 0 rgba(255, 255, 255, .7);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .85);
}
/* 横扫的高光带 */
.title-badge[data-rarity="rare"]::after {
  content: '';
  position: absolute;
  top: 0; bottom: 0;
  width: 45%;
  left: -60%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, .85), transparent);
  animation: tb-sweep 3.6s ease-in-out infinite;
  pointer-events: none;
}
@keyframes tb-sweep {
  0%, 62%  { left: -60%; }
  86%, 100% { left: 130%; }
}

/* ---- 天品：鎏金双描边 + 呼吸光晕 + 金色渐变字 ---- */
.title-badge[data-rarity="legend"] {
  --bc: #a8842c;
  --bg1: linear-gradient(150deg, #fdf5df, #f6e6b8);
  --bs: rgba(168, 132, 44, .5);
  border-color: #d4af37;
  font-weight: 700;
  letter-spacing: 1px;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, .9),
    inset 0 0 0 2px rgba(212, 175, 55, .35),
    0 0 14px -2px rgba(212, 175, 55, .5);
  animation: tb-breathe 2.8s ease-in-out infinite;
}
.title-badge[data-rarity="legend"] .tb-name {
  background: linear-gradient(92deg, #8a6a1c 0%, #e0bd5c 45%, #a8842c 70%, #d9bb63 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.title-badge[data-rarity="legend"] .tb-rarity {
  background: linear-gradient(140deg, #e8c96f, #a8842c);
  color: #fffdf5;
  box-shadow: 0 0 6px rgba(212, 175, 55, .8);
}
@keyframes tb-breathe {
  0%, 100% { box-shadow: inset 0 0 0 1px rgba(255,255,255,.9), inset 0 0 0 2px rgba(212,175,55,.35), 0 0 12px -3px rgba(212,175,55,.4); }
  50%      { box-shadow: inset 0 0 0 1px rgba(255,255,255,.9), inset 0 0 0 2px rgba(212,175,55,.55), 0 0 20px -2px rgba(212,175,55,.75); }
}

/* ================= 三选一 ================= */

.pick-modal {
  max-width: 520px;
  /* 弹窗是 .modal-mask（flex）的子项，不给上限时三张卡会被压扁并裁掉底部。
     改成「自身限高 + 列表内部滚动」，卡多了也不会溢出屏幕。 */
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.pick-hint { margin-bottom: 14px; font-size: .82em; color: var(--dim); }
.pick-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 6px;
  overflow-y: auto;
  min-height: 0;                 /* flex 子项允许收缩，否则撑破 max-height */
  padding-right: 2px;
}

.pick-card {
  position: relative;
  display: grid;
  grid-template-columns: 30px 1fr;
  grid-template-areas: 'rim name' 'rim sum' 'rim up';
  align-items: center;
  column-gap: 10px;
  width: 100%;
  margin-top: 0;
  padding: 12px 14px;
  border: 1px solid var(--bc);
  border-radius: 12px;
  background: var(--bg1);
  color: var(--text);
  text-align: left;
  overflow: hidden;
  transition: transform .16s, box-shadow .16s;
}
.pick-card:hover { transform: translateY(-2px); box-shadow: 0 8px 22px var(--bs); }
.pick-card .tb-rarity { grid-area: rim; width: 26px; height: 26px; font-size: .82em; }
.pc-name {
  grid-area: name;
  font-size: 1.02em;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--bc);
}
.pc-sum { grid-area: sum; font-size: .86em; color: var(--text); margin-top: 2px; }
.pc-up { grid-area: up; font-size: .74em; color: var(--dim); margin-top: 4px; }

.pick-card[data-rarity="common"] {
  --bc: #8d8674; --bg1: rgba(255, 255, 255, .85); --bs: rgba(141,134,116,.22);
}
.pick-card[data-rarity="uncommon"] {
  --bc: #2f9e6e; --bg1: linear-gradient(150deg, #f2fbf6, #dcf0e5); --bs: rgba(47,158,110,.3);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.85);
}
.pick-card[data-rarity="rare"] {
  --bc: #6a5acd; --bg1: linear-gradient(150deg, #f6f2ff, #dfe9fb); --bs: rgba(106,90,205,.35);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.85);
}
.pick-card[data-rarity="legend"] {
  --bc: #a8842c; --bg1: linear-gradient(150deg, #fdf7e4, #f5e3ac); --bs: rgba(212,175,55,.5);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.9), inset 0 0 0 2px rgba(212,175,55,.3);
}
.pick-card[data-rarity="legend"] .pc-name { color: #8a6a1c; }
.pick-card[data-rarity="legend"] .tb-rarity {
  background: linear-gradient(140deg, #e8c96f, #a8842c);
  color: #fffdf5;
  box-shadow: 0 0 8px rgba(212, 175, 55, .85);
}
.pick-card[data-rarity="legend"]::after {
  content: '';
  position: absolute;
  top: 0; bottom: 0;
  width: 40%;
  left: -60%;
  background: linear-gradient(100deg, transparent, rgba(255,255,255,.8), transparent);
  animation: tb-sweep 3.2s ease-in-out infinite;
  pointer-events: none;
}

/* ================= 词缀详情弹窗 ================= */

.affix-modal { max-width: 400px; }
.affix-crest {
  width: 58px; height: 58px;
  margin: 0 auto 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 1.7em;
  font-weight: 700;
  border: 2px solid var(--bc, var(--gold));
  background: var(--bg1, #fff);
  color: var(--bc, var(--gold));
  box-shadow: 0 0 18px -4px var(--bs, rgba(168,132,44,.5));
}
.affix-crest[data-rarity="common"]   { --bc: #8d8674; --bg1: rgba(255,255,255,.9); --bs: rgba(141,134,116,.25); }
.affix-crest[data-rarity="uncommon"] { --bc: #2f9e6e; --bg1: linear-gradient(150deg,#f2fbf6,#dcf0e5); --bs: rgba(47,158,110,.4); }
.affix-crest[data-rarity="rare"]     { --bc: #6a5acd; --bg1: linear-gradient(150deg,#f6f2ff,#dfe9fb); --bs: rgba(106,90,205,.45); }
.affix-crest[data-rarity="legend"] {
  --bc: #a8842c; --bg1: linear-gradient(150deg,#fdf7e4,#f5e3ac); --bs: rgba(212,175,55,.6);
  box-shadow: 0 0 22px -3px rgba(212,175,55,.7);
}
.affix-summary {
  font-size: .92em;
  color: var(--jade);
  font-weight: 600;
  text-align: center;
  margin-bottom: 10px;
}
.affix-desc { margin-bottom: 16px; }
.affix-desc p {
  font-size: .84em;
  color: var(--dim);
  line-height: 1.8;
  margin-bottom: 4px;
  white-space: normal;
}
.affix-stack-note { color: var(--gold) !important; }

/* ================= 弹窗 ================= */

.modal-mask {
  display: none;
  position: fixed; inset: 0;
  background: rgba(60,50,30,.45);
  align-items: center; justify-content: center;
  z-index: 30;
  padding: 16px;
}
.modal-mask.show { display: flex; }
.modal {
  background: var(--panel);
  border: 1px solid var(--gold);
  border-radius: 12px;
  padding: 28px 36px;
  text-align: center;
  max-width: 420px;
  width: 100%;
  box-shadow: 0 8px 40px rgba(120,95,40,.2);
}
.modal h3 { color: var(--gold); font-size: 1.4em; letter-spacing: 6px; margin-bottom: 12px; }
.modal p { color: var(--dim); line-height: 1.8; margin-bottom: 16px; white-space: pre-line; }

/* ================= 移动端：单页 + 底部导航 ================= */

@media (max-width: 768px) {
  body {
    padding: 10px;
    /* 给底部导航 + 纪事广播条让位，env() 兼容 iPhone 底部横条 */
    padding-bottom: calc(var(--tabbar-h) + var(--logdock-h)
                         + env(safe-area-inset-bottom) + 8px);
  }

  .container { padding-top: 10px; }

  /* 单页显示：只渲染当前功能页 */
  .workspace { display: block; }
  .page { display: none; animation: fade-in .2s ease-out; }
  .page.is-active { display: flex; }

  @keyframes fade-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; } }

  .panel { padding: 13px 14px; }
  button { min-height: 46px; }
  .shop-item button { min-height: 40px; }

  /* ---- 修炼页 · 移动端英雄式竖排 ----
     主卡从「左环右文」改为竖向：境界 → 圆环 → 突破 → 速度。
     圆环是全局最关键的进度，居中放大做视觉主角；突破是页面
     唯一的主动作，给全宽通栏，长文字不再折行。
     .main-side 用 display:contents 拆开，子元素直接参与卡片
     的 flex 排序 —— DOM 与 JS 钩子完全不动。 */
  .page { gap: 10px; }
  .card { padding: 16px 12px 12px; border-radius: 12px; }

  .card-main {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    text-align: center;
  }
  .main-side { display: contents; }

  /* 1 · 境界名号：置顶居中，层次做成金色小章 */
  .main-realm { order: 1; justify-content: center; gap: 8px; }
  .main-realm-name { font-size: 1.5em; letter-spacing: 4px; }
  .main-realm-stage {
    font-size: .76em;
    letter-spacing: 2px;
    padding: 2px 9px;
    border: 1px solid rgba(168, 132, 44, .55);
    border-radius: 999px;
    background: rgba(168, 132, 44, .08);
  }

  /* 2 · 圆环：居中放大，稳坐视觉中心 */
  .exp-ring-box { order: 2; width: 168px; height: 168px; margin: 0 auto; }
  .ring-pct { font-size: 1.9em; }
  .ring-cap { font-size: .66em; letter-spacing: 3px; margin-top: 3px; }
  .ring-num { font-size: .66em; margin-top: 3px; }
  .card-mark { font-size: 10em; right: -14%; bottom: -30%; }

  /* 3 · 突破：全宽主动作，紧随圆环 */
  .breakthrough-btn { order: 3; min-height: 52px; margin-top: 2px; font-size: 1.02em; }

  /* 4 · 修炼速度：单行圆角胶囊，退为辅助信息 */
  .src-chip {
    order: 4;
    padding: 8px 14px;
    border-radius: 999px;
    background: rgba(255, 255, 255, .55);
  }
  .src-chip-k { font-size: .76em; }
  .src-chip-v { font-size: .95em; }
  #buff-line { order: 5; margin-top: 0; }
  #idle-line { order: 6; margin-top: 0; }

  /* 属性卡：压实行高。行本身是 button，会继承移动端全局的
     min-height:46px 与 margin-top:8px —— 逐项收回，
     保留 44px 触控目标即可。 */
  .card-attr { gap: 0; padding-top: 8px; padding-bottom: 8px; }
  .attr-row {
    grid-template-columns: 38px minmax(0, 1fr) auto 10px;   /* 放得下「血量」 */
    gap: 8px;
    min-height: 44px;
    margin-top: 0;
    padding: 6px 4px;
  }
  .attr-row-name { font-size: .88em; }
  .attr-row-val { font-size: .9em; }
  .attr-row-gain { font-size: .66em; min-width: 30px; }

  /* 身世卡：年龄 / 寿元并排成双格砖 */
  .vital-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .card-self .stat-row {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 9px 6px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: rgba(255, 255, 255, .65);
  }
  .card-self .stat-row .k { font-size: .72em; letter-spacing: 2px; }
  .card-self .stat-row .v { font-size: 1.02em; font-weight: 600; }
  .titles { margin-top: 10px; }

  .src-modal { max-width: none; }
  .src-modal-body { max-height: 62vh; }
  .src-item { font-size: .88em; padding: 9px 2px; }

  .danger-zone button { min-height: 44px; }

  /* 背包格子在窄屏改为 4 列，保证触摸目标不小于 44px */
  .bag { grid-template-columns: repeat(4, 1fr); gap: 6px; }
  .slot-icon { font-size: 1.05em; }
  .slot-label { font-size: .62em; padding: 1px 3px; }

  /* 历练地点卡在窄屏给足触摸高度 */
  .site-go { min-height: 44px; }

  /* 挂机面板：窄屏按钮也要 44px，事件流留更多可视高度 */
  .idle-back { min-height: 46px; }
  .idle-feed { max-height: 240px; }

  /* 顶部栏在窄屏收紧，保证「名字 + 境界 + 资源」一行放得下 */
  .topbar { gap: 8px; padding: 8px 2px 10px; }
  .who { padding: 4px 7px; }
  .who-name { font-size: .95em; max-width: 5.5em; }
  .rename-input { width: 5.5em; }
  .realm-chip { font-size: .88em; letter-spacing: 1px; }
  .res-bar { gap: 10px; }
  .res-val { font-size: 1em; }

  /* ---- 修真纪事：紧贴底部导航栏的全局广播条 ---- */
  .log-dock {
    position: fixed;
    left: 0; right: 0;
    bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
    z-index: 19;                    /* 低于导航栏(20)，两者相邻不互相遮挡 */
    border-radius: 0;
    border-left: none; border-right: none; border-bottom: none;
    box-shadow: 0 -3px 14px rgba(96,80,45,.12);
    background: rgba(255,255,255,.97);
    padding: 0;
  }

  /* 收起态：单行，露出最新一条，点击整条可展开 */
  .log-dock.is-collapsed {
    display: flex;
    align-items: center;
    gap: 8px;
    height: var(--logdock-h);
    padding: 0 12px;
    cursor: pointer;
  }
  .log-dock.is-collapsed .log-head { display: none; }
  .log-dock.is-collapsed .log-tag {
    display: inline-block;
    flex-shrink: 0;
    color: var(--gold);
    background: var(--panel2);
    border-radius: 4px;
    padding: 2px 6px;
    font-size: .7em;
    letter-spacing: 1px;
  }
  .log-dock.is-collapsed .log-body {
    flex: 1;
    min-width: 0;
    height: var(--logdock-h);
    line-height: var(--logdock-h);
    overflow: hidden;
    /* 关键：内容贴底对齐 + 裁切 → 永远只露出最新一条 */
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    font-size: .78em;
    color: var(--text);
  }

  /* 展开态：向上铺开显示历史 */
  .log-dock:not(.is-collapsed) {
    display: flex;
    flex-direction: column;
    max-height: 46vh;
    box-shadow: 0 -6px 24px rgba(96,80,45,.18);
  }
  .log-dock:not(.is-collapsed) .log-tag { display: none; }
  .log-dock:not(.is-collapsed) .log-head {
    display: flex;
    margin: 0;
    padding: 5px 12px;
    font-size: .88em;
    letter-spacing: 3px;
    cursor: pointer;
  }
  .log-dock:not(.is-collapsed) .log-body {
    flex: 1;
    min-height: 0;
    height: auto;
    overflow-y: auto;
    padding: 7px 12px 12px;
    border-top: 1px solid var(--border);
    font-size: .8em;
    line-height: 1.7;
  }
  .log-toggle {
    display: inline-flex; align-items: center; gap: 3px;
    width: auto;
    /* 必须清零：移动端全局 button { min-height: 46px } 会把
       这个只有两个字的次要按钮撑到 46px，标题栏因此凭空多出大片空白。
       整条 .log-head 都可点，这里只需保持可辨识即可。 */
    min-height: 0;
    margin: 0;
    padding: 3px 4px;
    border: none; background: none;
    color: var(--dim);
    font-size: .78em;
    letter-spacing: 1px;
    cursor: pointer;
  }
  .log-toggle svg { width: 15px; height: 15px; }
  .log-toggle:hover { color: var(--gold); }

  .modal { padding: 22px 20px; }

  /* ---- 底部导航 ---- */
  .tabbar {
    display: flex;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 20;
    background: var(--panel);
    border-top: 1px solid var(--border);
    box-shadow: 0 -2px 14px rgba(96,80,45,.09);
    padding: 5px 4px calc(5px + env(safe-area-inset-bottom));
    isolation: isolate;                 /* 指示器的 z-index 不外泄 */
  }

  /*
    选中框（滑动指示器）
    ------------------------------------------------------------------------
    做成**独立元素**而不是 .tab.is-active 的背景，原因：
      - 纯 CSS 的 background 只能「闪」不能「滑」，切页时没有连贯感；
      - 独立元素用 transform: translateX() 位移，配合 cubic-bezier
        就能得到从旧列滑到新列的动画，GPU 合成也不触发重排。
    宽度用 calc 均分（与 .tab 的 flex:1 对齐），位置由 --tab-index 决定。
  */
  .tab-indicator {
    position: absolute;
    top: 5px;
    left: 4px;                          /* 与 tabbar 的 padding 对齐 */
    /* tab 数量由 JS 以 --tab-count 传入，将来加导航项不会错位 */
    width: calc((100% - 8px) / var(--tab-count, 4));
    height: calc(100% - 10px - env(safe-area-inset-bottom));
    border-radius: 10px;
    background: linear-gradient(180deg,
      rgba(168, 132, 44, .16) 0%,
      rgba(168, 132, 44, .08) 100%);
    box-shadow: inset 0 0 0 1px rgba(168, 132, 44, .28);
    transform: translateX(calc(var(--tab-index, 0) * 100%));
    transition: transform .34s cubic-bezier(.34, 1.26, .48, 1);
    pointer-events: none;               /* 不拦截点击 */
    z-index: -1;                        /* 在文字之下 */
  }
  /* 顶部小色条：强化「选中」的指向性 */
  .tab-indicator::before {
    content: "";
    position: absolute;
    left: 50%; top: 0;
    transform: translateX(-50%);
    width: 22px; height: 2.5px;
    border-radius: 0 0 3px 3px;
    background: var(--gold);
    opacity: .85;
  }

  .tab {
    flex: 1;
    position: relative;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 3px;
    min-height: 50px;
    padding: 5px 2px;
    border: none; background: none;
    color: var(--dim);
    font-size: .7em;
    letter-spacing: 1px;
    border-radius: 8px;
    transition: color .22s ease;
  }
  .tab svg {
    width: 21px; height: 21px; display: block;
    transition: transform .28s cubic-bezier(.34, 1.56, .48, 1);
  }
  .tab.is-active { color: var(--gold); }
  .tab.is-active span { font-weight: 600; }
  .tab.is-active svg { transform: translateY(-1px) scale(1.08); }
  .tab:active { background: rgba(240, 235, 221, .6); }

  /* 首次进入不做滑入动画：从「无指示器」直接落位，避免刷新时闪一下 */
  .tabbar.no-anim .tab-indicator,
  .tabbar.no-anim .tab svg { transition: none; }
}

/* 超窄屏微调 */
@media (max-width: 360px) {
  .topbar { gap: 6px; }
  .who-name { max-width: 4.5em; }
  .realm-chip { font-size: .82em; }
  /* 修炼主卡在超窄屏仍是竖排英雄布局，只把圆环与字号收一档 */
  .exp-ring-box { width: 148px; height: 148px; }
  .ring-pct { font-size: 1.7em; }
  .ring-num { font-size: .6em; }
  .main-realm-name { font-size: 1.3em; letter-spacing: 3px; }
  .main-realm-stage { font-size: .7em; }
  .src-chip-k { font-size: .7em; }
  .src-chip-v { font-size: .86em; }
  .attr-row-val { font-size: .8em; }          /* 位数多时先缩数值，保住不换行 */
  .attr-row-gain { display: none; }            /* 极窄屏放弃增长提示 */
  .title-badge { font-size: .74em; }   /* 移动端再收一档，padding 沿用基础值 */
  .pick-modal { max-width: none; }
  .pick-card { padding: 10px 12px; }
  .tab { font-size: .65em; }
}

/* 桌面端 hover 效果仅在指针设备上启用 */
@media (hover: hover) and (min-width: 769px) {
  .page .panel { transition: box-shadow .2s; }
  .page .panel:hover { box-shadow: 0 3px 12px rgba(96,80,45,.1); }
  .card { transition: box-shadow .25s; }
  .card:hover {
    box-shadow:
      0 1px 2px rgba(96, 80, 45, .04),
      0 14px 32px -14px rgba(96, 80, 45, .26);
  }
}

/* 尊重用户的减少动效偏好 */
@media (prefers-reduced-motion: reduce) {
  .page { animation: none !important; }
  .card-mark { animation: none; }
  .breakthrough-btn:not(:disabled) { animation: none; }
  .ring-fill { transition: none; }
  .attr-hpfill, .trib-hp-fill { transition: none; }
  .attr-hpbar.critical .attr-hpfill { animation: none; }
  .trib-bolt.strike { animation-duration: .01s; }
  .trib-overlay { animation: none; }
  /* 词缀的光效：关掉动效时保留静态边框与配色，只停动画 */
  .title-badge[data-rarity="legend"] { animation: none; }
  .pending-cta { animation: none; }
  .stat-row.is-danger { animation: none; }
  .title-badge[data-rarity="rare"]::after,
  .pick-card[data-rarity="legend"]::after { display: none; }
  /* 导航指示器直接跳位，不做滑动 */
  .tab-indicator, .tab svg, .tab { transition: none; }
}
