/* 组件库：按钮、卡片、胶囊、进度、分段控件、列表、徽标、空态、数字计数器、稀有度、键盘 */

/* ---------------------------------------------------------------- 按钮 */
.btn {
  --b-bg: var(--surface-solid); --b-ink: var(--ink); --b-edge: var(--surface-3);
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 48px; padding: 0 20px; border-radius: 16px; white-space: nowrap; user-select: none;
  font: 650 1rem/1 var(--font-ui); letter-spacing: -.005em; color: var(--b-ink); background: var(--b-bg);
  box-shadow: 0 3px 0 var(--b-edge), 0 6px 14px rgba(0,0,0,.10), inset 0 1px 0 rgba(255,255,255,.35);
  transition: transform var(--t-fast) var(--ease-out), box-shadow var(--t-fast) var(--ease-out), filter var(--t-fast), opacity var(--t-fast);
}
.btn:active:not([disabled]) { transform: translateY(2px); box-shadow: 0 1px 0 var(--b-edge), 0 3px 8px rgba(0,0,0,.10), inset 0 1px 0 rgba(255,255,255,.3); }
.btn[disabled] { opacity: .45; cursor: not-allowed; filter: saturate(.6); }
.btn .btn-icon { width: 22px; height: 22px; flex: none; }
.btn .btn-sub { font: 600 0.75rem/1 var(--font-ui); opacity: .72; margin-left: 2px; }
.btn-block { display: flex; width: 100%; }
.btn-sm { height: 36px; padding: 0 14px; border-radius: 12px; font-size: 0.875rem; }
.btn-sm .btn-icon { width: 18px; height: 18px; }
.btn-lg { height: 56px; padding: 0 24px; border-radius: 18px; font-size: 1.0625rem; }
.btn-xs { height: 28px; padding: 0 10px; border-radius: 10px; font-size: 0.7812rem; box-shadow: 0 2px 0 var(--b-edge); }
.btn-xs .btn-icon { width: 15px; height: 15px; }
.btn-xs::after, .btn-sm::after { content: ""; position: absolute; inset: -8px -4px; }
.btn-primary { --b-bg: linear-gradient(180deg, #57C064 0%, #3EA44E 100%); --b-ink: #fff; --b-edge: #2A7E3B; text-shadow: 0 1px 0 rgba(0,0,0,.12); }
.btn-banana { --b-bg: linear-gradient(180deg, #FFE27A 0%, #F7C52A 100%); --b-ink: #3A2A00; --b-edge: #C99207; }
.btn-energy { --b-bg: linear-gradient(180deg, #45EBDD 0%, #14C4B8 100%); --b-ink: #052B28; --b-edge: #0B8E86; }
.btn-monkey { --b-bg: linear-gradient(180deg, #34312A 0%, #1D1B16 100%); --b-ink: #FFE9A6; --b-edge: #000; }
.btn-danger { --b-bg: linear-gradient(180deg, #F07385 0%, #E5566B 100%); --b-ink: #fff; --b-edge: #B23A4E; }
.btn-ghost { --b-bg: transparent; --b-edge: transparent; box-shadow: none; }
.btn-ghost:active:not([disabled]) { box-shadow: none; background: var(--surface-2); }
.btn-soft { --b-bg: var(--surface-2); --b-edge: var(--surface-3); box-shadow: 0 2px 0 var(--b-edge); }
.device[data-theme="night"] .btn { box-shadow: 0 3px 0 var(--b-edge), 0 6px 14px rgba(0,0,0,.35), inset 0 1px 0 rgba(255,255,255,.12); }
.device[data-theme="night"] .btn-soft { --b-bg: var(--surface-2); --b-edge: #12101B; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 14px; display: inline-flex; align-items: center; justify-content: center;
  background: var(--glass-strong); border: 1px solid var(--line); color: var(--ink); box-shadow: var(--shadow-1), var(--highlight);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); transition: transform var(--t-fast) var(--ease-out);
  position: relative;
}
.icon-btn:active { transform: scale(.94); }
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn .dot { position: absolute; top: 6px; right: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--rose-500); box-shadow: 0 0 0 2px var(--surface-solid); }

/* ---------------------------------------------------------------- 卡片 */
.card {
  position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow-1), var(--highlight); padding: 16px;
}
.card-tight { padding: 12px; border-radius: var(--r-md); }
.card-flat { box-shadow: none; background: var(--surface-2); border-color: transparent; }
.card-glass { background: var(--glass); backdrop-filter: blur(20px) saturate(1.3); -webkit-backdrop-filter: blur(20px) saturate(1.3); }
.card-press { transition: transform var(--t-fast) var(--ease-out); cursor: pointer; }
.card-press:active { transform: scale(.985); }
.card-hero { overflow: hidden; padding: 0; }
.card-title { font: 650 1rem/1.3125rem var(--font-ui); letter-spacing: -.01em; }
.card-sub { color: var(--muted); font-size: 0.8125rem; line-height: 1.125rem; margin-top: 2px; }
.divider { height: 1px; background: var(--line); margin: 12px 0; }

/* ---------------------------------------------------------------- 胶囊 / 标签 / 徽标 */
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px 0 8px; border-radius: var(--r-pill);
  background: var(--glass-strong); border: 1px solid var(--line); box-shadow: var(--shadow-1), var(--highlight);
  font: 650 0.8125rem/1 var(--font-ui); color: var(--ink); white-space: nowrap;
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
}
.chip svg { width: 18px; height: 18px; flex: none; }
.chip-press { cursor: pointer; transition: transform var(--t-fast); }
.chip-press:active { transform: scale(.95); }
.tag {
  display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 7px; border-radius: 7px;
  font: 650 0.75rem/1 var(--font-ui); letter-spacing: .01em; background: var(--surface-2); color: var(--ink-2); white-space: nowrap;
}
.tag svg { width: 12px; height: 12px; }
.tag-leaf { background: rgba(62,164,78,.14); color: var(--leaf-600); }
.tag-banana { background: rgba(245,190,30,.18); color: #8A6200; }
.tag-energy { background: rgba(20,196,184,.14); color: var(--cyan-600); }
.tag-rose { background: rgba(229,86,107,.14); color: #B23A4E; }
.tag-violet { background: rgba(139,107,255,.15); color: #6346D9; }
.tag-dark { background: var(--monkey-ink); color: #FFE9A6; }
/* 「居民·NPC」/「NPC」/「节庆主持·NPC」文字标签（kit.NpcLabel；S3 §2.1 处处标）：形状（圆角描边）+ 颜色双编码，不只靠颜色 */
.tag-resident { background: rgba(139,107,255,.12); color: #5B3FCC; box-shadow: inset 0 0 0 1px rgba(139,107,255,.35); }
.tag-npc { background: rgba(46,42,64,.10); color: #2E2A40; box-shadow: inset 0 0 0 1px rgba(46,42,64,.28); }
.npc-label { flex: none; white-space: nowrap; font-weight: 700; letter-spacing: .02em; }
.device[data-theme="night"] .tag-resident { color: #C9BAFF; background: rgba(139,107,255,.18); }
.device[data-theme="night"] .tag-npc { color: #E2DDF5; background: rgba(226,221,245,.10); box-shadow: inset 0 0 0 1px rgba(226,221,245,.25); }
.device[data-theme="night"] .tag-leaf { color: var(--leaf-300); }
.device[data-theme="night"] .tag-banana { color: var(--banana-300); }
.device[data-theme="night"] .tag-energy { color: var(--cyan-300); }
.device[data-theme="night"] .tag-rose { color: #FF9AA9; }
.device[data-theme="night"] .tag-violet { color: #BBA8FF; }
.badge-count {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--rose-500); color: #fff;
  font: 700 0.75rem/1.125rem var(--font-ui); text-align: center; box-shadow: 0 0 0 2px var(--surface-solid);
}

/* 资源计数（蕉币 / 露水 / MONKEY） */
.stat-pill {
  display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px 0 5px; border-radius: var(--r-pill);
  background: var(--glass-strong); border: 1px solid var(--line); box-shadow: var(--shadow-1), var(--highlight);
  backdrop-filter: blur(18px) saturate(1.4); -webkit-backdrop-filter: blur(18px) saturate(1.4);
  font: 700 0.9375rem/1 var(--font-ui); font-variant-numeric: tabular-nums; color: var(--ink);
}
.stat-pill .stat-icon { width: 26px; height: 26px; flex: none; }
.stat-pill.bump { animation: bump var(--t-slow) var(--ease-spring); }
@keyframes bump { 30% { transform: scale(1.12); } 100% { transform: scale(1); } }

/* ---------------------------------------------------------------- 进度条 */
.progress { position: relative; height: 8px; border-radius: 6px; background: var(--surface-3); overflow: hidden; }
.progress > i {
  position: absolute; left: 0; top: 0; bottom: 0; border-radius: inherit;
  background: var(--xp-fill); transition: width var(--t-slow) var(--ease-out);
}
/* 夜间语义色统一（跨屏幕的最小绕行）：HUD 经验条、我的页经验条、年鉴图例"已领取"都走同一组令牌 */
.device .farm-xpbar i { background: var(--xp-fill); }
.device .alm-legend .lg.claimed { background: var(--done-fill); border-color: var(--done-fill); }
.progress.energy > i { background: linear-gradient(90deg, var(--cyan-300), var(--cyan-500)); }
.progress.banana > i { background: linear-gradient(90deg, var(--banana-300), var(--banana-500)); }
.progress.shine > i::after {
  content: ""; position: absolute; inset: 0; background: linear-gradient(100deg, transparent 20%, rgba(255,255,255,.55) 45%, transparent 70%);
  animation: shine 2.4s infinite;
}
@keyframes shine { from { transform: translateX(-100%); } to { transform: translateX(200%); } }
.progress-lg { height: 12px; border-radius: 8px; }

/* ---------------------------------------------------------------- 分段控件 */
.seg { display: flex; padding: 3px; gap: 3px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line); }
.seg button {
  position: relative; flex: 1; min-width: 44px; height: 38px; border-radius: 11px; font: 650 0.875rem/1 var(--font-ui); color: var(--muted);
  transition: background var(--t-fast), color var(--t-fast);
}
/* 触控热区 ≥44px：按钮上下各延伸 6px 到分段框外沿（视觉高度不变；屏幕把按钮压到 32px 时也有 44px） */
.seg button::after { content: ""; position: absolute; inset: -6px 0; }
.seg button.on { background: var(--surface-solid); color: var(--ink); box-shadow: var(--shadow-1); }
.device[data-theme="night"] .seg button.on { background: var(--surface-3); }
/* 大 / 特大字号：按钮不再窄过自己最长的一个词；一行放不下时整组折成两行（行距 6px：上下两行各自外延 6px 的热区在行缝里重叠，没有点不到的缝，每个按钮热区仍 ≥44px），
   不让英文页签压到隔壁（W4 复核 V4-1：「Residents」「Members」在 125% 下连在一起） */
html:is([data-font='large'], [data-font='xlarge']) .seg { flex-wrap: wrap; row-gap: 6px; }
html:is([data-font='large'], [data-font='xlarge']) .seg button { min-width: auto; }

/* ---------------------------------------------------------------- 列表 */
.list { display: flex; flex-direction: column; border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line); overflow: hidden; box-shadow: var(--shadow-1); }
.list-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; min-height: 56px; }
.list-row + .list-row { border-top: 1px solid var(--line); }
.list-row.press { cursor: pointer; }
.list-row.press:active { background: var(--surface-2); }
.list-row .lr-main { flex: 1; min-width: 0; }
.list-row .lr-title { font: 600 0.9375rem/1.25rem var(--font-ui); }
.list-row .lr-sub { font-size: 0.7812rem; line-height: 1.0625rem; color: var(--muted); }
.list-row .chev { width: 18px; height: 18px; color: var(--faint); }

/* 头像 */
.avatar { position: relative; width: 44px; height: 44px; border-radius: 15px; overflow: hidden; flex: none; background: var(--surface-3); box-shadow: inset 0 0 0 1px var(--line); }
.avatar img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 18%; transform: scale(1.5); transform-origin: 50% 20%; }
.avatar svg { width: 100%; height: 100%; }
.avatar-sm { width: 32px; height: 32px; border-radius: 11px; }
.avatar-lg { width: 64px; height: 64px; border-radius: 22px; }
.avatar-ring { box-shadow: 0 0 0 2px var(--surface-solid), 0 0 0 4px var(--leaf-400); }
/* NPC 角标（kit.js Avatar）：HTML 文字，最小 10px，跟随大字号；贴在头像底边居中 */
/* 角标字号 ≥12px（S3 §9.5：原来的 10–11px 改为 12px） */
.avatar .avatar-npc { position: absolute; left: 50%; bottom: 1px; transform: translateX(-50%); padding: 0 3px; border-radius: 5px;
  font: 800 0.75rem/0.875rem var(--font-ui); font-style: normal; letter-spacing: .02em; color: #FFE27A; background: #2E2A40;
  box-shadow: 0 0 0 1px #fff; white-space: nowrap; pointer-events: none; }
.avatar-lg .avatar-npc { bottom: 2px; font-size: 0.75rem; line-height: 0.9375rem; padding: 0 5px; }
/* 居民头像：紫色描边环 + 角标同色（与真人、小铜区分；形状 + 颜色双编码） */
.avatar-is-resident { box-shadow: inset 0 0 0 1px var(--line), 0 0 0 2px rgba(139,107,255,.55); }
.avatar-is-resident .avatar-npc { background: #5B3FCC; color: #fff; }

/* ---------------------------------------------------------------- 空态 / 骨架 */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: 32px 20px; color: var(--muted); }
.empty > .empty-art > svg { width: 72px; height: 72px; opacity: .9; }
.skeleton { background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: skel 1.3s infinite; border-radius: 12px; }
@keyframes skel { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ---------------------------------------------------------------- 稀有度 & 变异 */
.rar-common { --rar: var(--rar-common); } .rar-fine { --rar: var(--rar-fine); } .rar-rare { --rar: var(--rar-rare); }
.rar-epic { --rar: var(--rar-epic); } .rar-legendary { --rar: var(--rar-legendary); }
.rar-frame { box-shadow: inset 0 0 0 2px var(--rar), 0 0 18px -6px var(--rar); }
.mut-text-wet { color: var(--mut-wet); } .mut-text-ice { color: #3FB6D9; } .mut-text-thunder { color: var(--mut-thunder); }
.mut-text-gold { color: #C99207; } .mut-text-rainbow { background: var(--mut-rainbow); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* ---------------------------------------------------------------- MONKEY 价格标 */
.price { display: inline-flex; align-items: center; gap: 5px; font: 750 0.9375rem/1 var(--font-ui); font-variant-numeric: tabular-nums; }
.price svg { width: 18px; height: 18px; }
.price-coin { color: #8A6200; }
.price .price-test { margin-left: 2px; padding: 0 5px; height: 16px; border-radius: 5px; display: inline-flex; align-items: center;
  font: 650 0.75rem/1 var(--font-ui); letter-spacing: .02em; color: var(--ink-2); background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); }
.device[data-theme="night"] .price-coin { color: var(--banana-300); }

/* ---------------------------------------------------------------- 数字键盘（模拟 Mixin PIN） */
.pin-dots { display: flex; justify-content: center; gap: 14px; margin: 16px 0 20px; }
.pin-dots i { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--line-strong); transition: background var(--t-fast), transform var(--t-fast) var(--ease-spring); }
.pin-dots i.on { background: var(--ink); border-color: var(--ink); transform: scale(1.1); }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.keypad button { height: 54px; border-radius: 16px; background: var(--surface-solid); box-shadow: 0 2px 0 var(--surface-3); font: 600 1.375rem/1 var(--font-ui); }
.keypad button:active { transform: translateY(1px); box-shadow: none; background: var(--surface-2); }
.keypad button.ghost { background: transparent; box-shadow: none; font-size: 0.9375rem; color: var(--muted); }

/* ---------------------------------------------------------------- 表单 */
.input { width: 100%; height: 46px; border-radius: 14px; border: 1px solid var(--line-strong); background: var(--surface-solid); padding: 0 14px; outline: none; }
.input:focus { border-color: var(--leaf-400); box-shadow: 0 0 0 4px rgba(92,193,100,.18); }
.switch { position: relative; width: 50px; height: 30px; border-radius: 15px; background: var(--surface-3); transition: background var(--t-med); flex: none; }
/* 触控热区 54×44（视觉 50×30 不变；::after 是滑块，热区用 ::before） */
.switch::before { content: ""; position: absolute; inset: -7px -2px; border-radius: 22px; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 2px 4px rgba(0,0,0,.2); transition: transform var(--t-med) var(--ease-spring); }
.switch.on { background: var(--leaf-500); }
.switch.on::after { transform: translateX(20px); }

/* ---------------------------------------------------------------- 杂项 */
.kbd-hint { font: 600 0.75rem/1 var(--font-mono); padding: 3px 5px; border-radius: 5px; background: var(--surface-2); color: var(--muted); }
.notice { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 16px; background: var(--surface-2); color: var(--ink-2); font-size: 0.8125rem; line-height: 1.1875rem; }
.notice svg { width: 20px; height: 20px; flex: none; margin-top: 1px; }
.notice-energy { background: rgba(20,196,184,.10); }
.notice-banana { background: rgba(245,190,30,.14); }
.notice-rose { background: rgba(229,86,107,.10); }
.pulse { animation: pulse 1.8s var(--ease-in-out) infinite; }
@keyframes pulse { 50% { transform: scale(1.04); } }
.float { animation: float 3s var(--ease-in-out) infinite; }
@keyframes float { 50% { transform: translateY(-4px); } }
.pop-in { animation: popin var(--t-slow) var(--ease-spring) both; }
@keyframes popin { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.slide-up { animation: slideup var(--t-slow) var(--ease-out) both; }
@keyframes slideup { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }
.stagger > * { animation: slideup var(--t-slow) var(--ease-out) both; }
.stagger > *:nth-child(2) { animation-delay: 30ms; } .stagger > *:nth-child(3) { animation-delay: 60ms; }
.stagger > *:nth-child(4) { animation-delay: 90ms; } .stagger > *:nth-child(5) { animation-delay: 120ms; }
.stagger > *:nth-child(6) { animation-delay: 150ms; } .stagger > *:nth-child(n+7) { animation-delay: 180ms; }

/* ---------------------------------------------------------------- 二次确认弹窗（kit.confirmDialog） */
.confirm-modal { left: 26px; right: 26px; }
.cfm { padding: 24px 20px 18px; text-align: center; }
.cfm-icon { width: 60px; height: 60px; margin: 0 auto 12px; border-radius: 20px; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(180deg, var(--banana-200), var(--banana-400)); color: #6B4A00; box-shadow: 0 8px 20px rgba(217,154,6,.25), inset 0 1px 0 rgba(255,255,255,.6); }
.cfm-icon.tone-rose { background: linear-gradient(180deg, #FFD3DA, #F07385); color: #7A1E2E; }
.cfm-title { font: 750 1.1875rem/1.5625rem var(--font-ui); letter-spacing: -.01em; }
.cfm-body { margin: 6px 4px 0; color: var(--ink-2); font-size: 0.8438rem; line-height: 1.25rem; }
.cfm-rows { margin: 14px 0 0; padding: 4px 14px; border-radius: 16px; background: var(--surface-2); text-align: left; }
.cfm-row { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; font-size: 0.8438rem; line-height: 1.125rem; }
.cfm-row + .cfm-row { border-top: 1px solid var(--line); }
.cfm-row > span { color: var(--muted); flex: none; }
.cfm-row > b { font: 650 0.8438rem/1.125rem var(--font-ui); text-align: right; font-variant-numeric: tabular-nums; }
.cfm .notice { margin-top: 12px; text-align: left; }
.cfm-actions { display: flex; gap: 10px; margin-top: 18px; }
.cfm-actions .btn { height: 50px; }
