/* 冒险岛物价监控 — 「枫叶」主题：暖调中性 + 枫橙交互 + 涨红跌绿 + 金价金，浅色「枫晨」/ 暗色「枫夜」双主题 */

/* ---------- 令牌 ---------- */
:root {
  color-scheme: light;

  /* 中性（暖调微染，禁纯黑纯白） */
  --bg: oklch(97% 0.006 75);            /* 暖纸白 */
  --card: oklch(99.2% 0.004 84);        /* 卡面 */
  --card-2: oklch(96.2% 0.008 75);      /* 二级面（统计块/表头/分段控件轨道） */
  --line: oklch(89% 0.01 76);           /* 发丝线 */
  --line-strong: oklch(81% 0.013 76);
  --text: oklch(25% 0.012 55);          /* 暖炭 */
  --muted: oklch(51% 0.016 62);

  /* 交互与语义 */
  --accent: oklch(55% 0.17 45);         /* 深枫橙（白字对比达标） */
  --accent-strong: oklch(48% 0.16 44);
  --accent-soft: color-mix(in srgb, var(--accent) 10%, var(--card));
  --on-accent: oklch(99% 0.004 84);
  --up: oklch(49.5% 0.21 27);          /* 涨·红（墨重行情：加饱和） */
  --up-soft: color-mix(in srgb, var(--up) 8%, var(--card));
  --down: oklch(48% 0.16 152);         /* 跌·绿 */
  --down-soft: color-mix(in srgb, var(--down) 9%, var(--card));
  --gold: oklch(52% 0.115 85);          /* 金价·历史低 */
  --gold-soft: color-mix(in srgb, var(--gold) 10%, var(--card));

  /* 形状与层次 */
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --shadow-1: 0 1px 2px oklch(50% 0.04 60 / .05), 0 1px 3px oklch(50% 0.04 60 / .04);
  --shadow-2: 0 4px 16px oklch(45% 0.05 60 / .09);
  --shadow-3: 0 24px 64px -16px oklch(35% 0.05 60 / .28);
  --ring: 0 0 0 3px color-mix(in srgb, var(--accent) 28%, transparent);

  --ease: cubic-bezier(.16, 1, .3, 1);  /* ease-out-quart */
}
html.dark {
  color-scheme: dark;

  --bg: oklch(17.5% 0.005 55);          /* 暖炭 */
  --card: oklch(22.5% 0.007 58);
  --card-2: oklch(26% 0.008 60);
  --line: oklch(33.5% 0.009 62);
  --line-strong: oklch(43% 0.012 62);
  --text: oklch(92% 0.005 84);
  --muted: oklch(73% 0.012 72);

  --accent: oklch(74% 0.155 55);        /* 亮枫橙 */
  --accent-strong: oklch(79% 0.15 58);
  --accent-soft: color-mix(in srgb, var(--accent) 16%, var(--card));
  --on-accent: oklch(20% 0.02 50);      /* 亮底配深字 */
  --up: oklch(70% 0.185 27);
  --up-soft: color-mix(in srgb, var(--up) 14%, var(--card));
  --down: oklch(72% 0.16 150);
  --down-soft: color-mix(in srgb, var(--down) 14%, var(--card));
  --gold: oklch(76% 0.13 85);
  --gold-soft: color-mix(in srgb, var(--gold) 14%, var(--card));

  --shadow-1: none;
  --shadow-2: 0 4px 16px oklch(0% 0 0 / .25);
  --shadow-3: 0 24px 64px -16px oklch(0% 0 0 / .5);
}

* { box-sizing: border-box; }
.hidden { display: none !important; }
html, body { margin: 0; padding: 0; }
html { background: var(--bg); }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI",
    "PingFang SC", "HarmonyOS Sans SC", "MiSans", "Microsoft YaHei", system-ui, sans-serif;
  background: var(--bg); color: var(--text); min-height: 100vh;
  display: flex; flex-direction: column;
  transition: background .25s var(--ease), color .25s var(--ease);
}
::selection { background: color-mix(in srgb, var(--accent) 22%, transparent); }
input, select, button { font: inherit; color: inherit; }
button:focus-visible, .svc-chip:focus-visible, .tag-chip:focus-visible,
input:focus-visible, select:focus-visible, a:focus-visible {
  outline: none; box-shadow: var(--ring);
}
.muted { color: var(--muted); }
/* 数字一律等宽：价格刷新不抖动，表格列自然对齐 */
.price, .pct, .stat .v, .page-info, .gold-chip, td, th, .s-pct {
  font-variant-numeric: tabular-nums;
}

/* ---------- 顶栏（毛玻璃） ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  padding: 12px 24px;
  background: color-mix(in srgb, var(--card) 78%, transparent);
  -webkit-backdrop-filter: blur(20px) saturate(1.8);
  backdrop-filter: blur(20px) saturate(1.8);
  border-bottom: 1px solid var(--line);
  width: 100%;
}
/* 桌面端顶栏禁止整块换行；内容装不下时让 svc-group 内部换行 */
html.is-desktop .topbar { flex-wrap: nowrap; }
.brand { display: flex; align-items: center; gap: 10px; flex: 0 1 auto; min-width: 0; }
.brand h1 {
  font-size: 18px; margin: 0; letter-spacing: .3px; white-space: nowrap;
  font-weight: 700;
}
.svc-group { display: flex; gap: 4px; flex-wrap: wrap; max-width: 540px; }
.svc-chip {
  border: 1px solid transparent; background: transparent; color: var(--muted);
  font-size: 12px; padding: 3px 10px; border-radius: 999px; cursor: pointer;
  transition: all .15s var(--ease);
}
.svc-chip:hover { background: var(--card-2); color: var(--text); }
.svc-chip.on {
  background: var(--accent); border-color: var(--accent);
  color: var(--on-accent); font-weight: 600;
}
.status {
  flex: 1 1 auto; min-width: 0; font-size: 13px; color: var(--muted);
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--down); display: inline-block; }
.dot.warn { background: var(--accent); animation: dot-pulse 1.6s var(--ease) infinite; }
.dot.bad { background: var(--up); }
@keyframes dot-pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 45%, transparent); }
  100% { box-shadow: 0 0 0 7px transparent; }
}
.gold-chip {
  position: relative;
  color: var(--gold); background: var(--gold-soft);
  border: 1px solid color-mix(in srgb, var(--gold) 26%, var(--card));
  padding: 2px 10px; border-radius: 999px; font-weight: 600; font-size: 12px;
  cursor: default; white-space: nowrap;
}
.gold-chip .gold-tip {
  display: none; position: absolute; top: calc(100% + 6px); left: 0; z-index: 40;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-sm);
  box-shadow: var(--shadow-2); padding: 10px 14px;
  font-size: 12px; line-height: 1.9; color: var(--text); font-weight: 500; white-space: nowrap;
}
.gold-chip:hover .gold-tip { display: block; }
.gold-chip .gold-tip b { color: var(--gold); }
.gold-chip .gold-tip .muted { font-size: 11px; }
.gold-chip.muted { color: var(--muted); background: var(--card-2); border-color: transparent; }
.btn.profile {
  border-color: var(--line); background: var(--card); color: var(--muted); font-weight: 600;
}
.btn.profile:hover { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 30%, var(--card)); color: var(--accent); }

/* ---------- 按钮：实底 / 着色 / 描边三档 ---------- */
.btn {
  border: 1px solid var(--line); background: var(--card); color: var(--text);
  padding: 7px 14px; border-radius: var(--r-sm); font-size: 13px; cursor: pointer;
  transition: background .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease);
  text-decoration: none; display: inline-flex; align-items: center; gap: 4px;
}
.btn:hover { border-color: var(--line-strong); background: var(--card-2); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary {
  background: var(--accent); border-color: var(--accent); color: var(--on-accent);
  font-weight: 600;
}
.btn.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
/* 着色文字钮：次级动作（采集/备份/源站） */
.btn.tint {
  background: var(--accent-soft); border-color: transparent; color: var(--accent); font-weight: 600;
}
.btn.tint:hover {
  background: color-mix(in srgb, var(--accent) 16%, var(--card)); color: var(--accent-strong);
}
.btn.danger-text { color: var(--up); }
.btn.small { padding: 4px 10px; font-size: 12px; border-radius: 8px; }
.btn.small.icon {
  padding: 3px 8px; font-size: 13px; line-height: 1.4;
  border-color: transparent; background: transparent; color: var(--muted);
}
.btn.small.icon:hover { background: var(--card-2); border-color: transparent; color: var(--text); }
.btn.small.icon.danger-text:hover { background: var(--up-soft); color: var(--up); }

.actions { display: flex; gap: 8px; flex-wrap: wrap; flex: 0 0 auto; align-items: center; }
.actions .p-name { margin-left: 2px; }

/* ---------- 提示横幅 ---------- */
.banner {
  margin: 12px 24px 0; padding: 10px 14px; border-radius: var(--r-sm);
  background: var(--gold-soft); color: color-mix(in srgb, var(--gold) 70%, var(--text));
  border: 1px solid color-mix(in srgb, var(--gold) 24%, var(--card)); font-size: 13px;
}
.banner.error {
  background: var(--up-soft); color: var(--up);
  border-color: color-mix(in srgb, var(--up) 22%, var(--card));
}

/* ---------- 工具栏（去箱化：直接浮在背景上） ---------- */
main { flex: 1; padding: 20px 24px 32px; }
.tag-bar {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  margin-bottom: 10px;
}
.tag-bar-label { font-size: 12px; color: var(--muted); font-weight: 600; }
.tag-hint { font-size: 11.5px; margin-left: auto; }
.tag-chip {
  --tc: var(--muted);
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; font-weight: 600; line-height: 1;
  padding: 5px 10px; border-radius: 999px; cursor: pointer;
  color: var(--tc); background: color-mix(in srgb, var(--tc) 10%, var(--card));
  border: 1px solid color-mix(in srgb, var(--tc) 28%, var(--card));
  transition: all .15s var(--ease);
}
html.dark .tag-chip {
  color: color-mix(in oklab, var(--tc) 55%, var(--text));
  background: color-mix(in srgb, var(--tc) 20%, var(--card));
  border-color: color-mix(in srgb, var(--tc) 34%, var(--card));
}
.tag-chip:hover { filter: brightness(.97); transform: none; }
.tag-chip.on { color: var(--on-accent); background: var(--tc); border-color: var(--tc); }
html.dark .tag-chip.on { color: oklch(20% 0.02 55); }
.tag-chip .tag-count { font-size: 10px; opacity: .75; font-weight: 700; }
.tag-chip.mini { font-size: 11px; padding: 3px 8px; cursor: default; }
.tag-check-list { display: flex; flex-direction: column; gap: 8px; max-height: 260px; overflow-y: auto; }
.tag-check {
  display: flex; align-items: center; gap: 8px; font-size: 13px;
  border: 1px solid var(--line); border-radius: var(--r-sm); padding: 8px 10px; cursor: pointer;
}
.tag-check input { accent-color: var(--accent); }
.tag-check .muted { margin-left: auto; font-size: 11.5px; }

.sort-bar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-bottom: 16px; font-size: 13px;
}
.sort-bar select {
  border: 1px solid var(--line); border-radius: var(--r-sm); padding: 5px 8px; font-size: 13px;
  background: var(--card); transition: border-color .15s var(--ease);
}
.sort-bar select:hover { border-color: var(--line-strong); }
.sort-bar input[type=number] {
  border: 1px solid var(--line); border-radius: var(--r-sm); padding: 5px 8px; font-size: 13px;
  width: 110px; background: var(--card);
}
.sort-bar input[type=number]:hover { border-color: var(--line-strong); }
.sort-bar .btn.small { font-weight: 600; }
.sort-bar .btn.small:not(.tint) {
  border-color: transparent; background: var(--card-2); color: var(--muted);
}
.sort-bar .btn.small:not(.tint):hover { color: var(--text); background: var(--line); }

/* ---------- 卡片网格 ---------- */
/* 列数显式声明：超宽 6 列；1440 左右降到 4 列保证道具名单行完整（6 列窄卡名字必截断）；
   手机 2 列。与 app.js cardColsByViewport 断点表保持一致 */
html.is-desktop .cards {
  display: grid; gap: 16px;
  grid-template-columns: repeat(6, 1fr);
}
@media (max-width: 1599px) { html.is-desktop .cards { grid-template-columns: repeat(4, 1fr); } }
@media (max-width: 1023px) { html.is-desktop .cards { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 767px)  { html.is-desktop .cards { grid-template-columns: repeat(2, 1fr); } }
html.is-touch .cards {
  display: grid; gap: 10px;
  grid-template-columns: repeat(2, 1fr);
}
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-md);
  box-shadow: var(--shadow-1); padding: 16px 18px; cursor: pointer;
  transition: border-color .15s var(--ease), box-shadow .2s var(--ease), opacity .15s var(--ease);
  position: relative;
  display: flex; flex-direction: column; gap: 10px;
  min-width: 0; /* 允许 grid 窄列下内部收缩，避免内容把卡片撑破 */
  container-type: inline-size;
}
.card:hover { border-color: var(--line-strong); box-shadow: var(--shadow-2); }
.card { cursor: grab; }
.card:active { cursor: grabbing; }
.card.dragging { opacity: .45; transform: scale(.98); box-shadow: none; }
.card.disabled-item { opacity: .55; }
.item-name {
  flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  /* 道具名=主视觉之一：雅黑真实粗体（700，更高字重是伪粗会发糊）+ 加大字号 + 抗锯齿 */
  font-family: "Microsoft YaHei", "PingFang SC", -apple-system, sans-serif;
  font-size: 16px; font-weight: 700; line-height: 1.3;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
.price-row { display: flex; align-items: baseline; gap: 8px; min-width: 0; flex-wrap: wrap; row-gap: 2px; }
.price-row .pct { margin-left: auto; flex-shrink: 0; }
.price {
  /* 墨重行情：Segoe UI Black(900) 真实字重 + 紧字距 */
  font-family: "Segoe UI", system-ui, sans-serif;
  font-size: 30px; font-weight: 900; letter-spacing: -.8px;
  min-width: 0; overflow-wrap: anywhere;
}
.price.na { font-size: 17px; color: var(--muted); font-weight: 600; }
.pct {
  font-family: "Segoe UI", system-ui, sans-serif;
  font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 6px;
}
.pct.up { color: var(--up); background: var(--up-soft); }
.pct.down { color: var(--down); background: var(--down-soft); }
.pct.flat { color: var(--muted); background: var(--card-2); }
/* 迷你走势：颜色由趋势方向决定（涨红/跌绿/平灰），降高度降透明退为背景参考 */
.spark { height: 24px; opacity: .8; color: var(--muted); }
.spark.up { color: var(--up); }
.spark.down { color: var(--down); }
.spark.flat { color: var(--muted); }
.spark svg { display: block; width: 100%; height: 100%; }
.badge-stale {
  font-size: 10.5px;
  color: var(--muted); background: var(--card-2); border: 1px solid transparent;
  padding: 2px 8px; border-radius: 999px;
  flex-shrink: 0;
}
.badge-stale.err { color: var(--up); background: var(--up-soft); border-color: color-mix(in srgb, var(--up) 20%, var(--card)); }
.star-btn {
  position: absolute; top: 10px; right: 10px; z-index: 2;
  background: none; border: none; cursor: pointer; user-select: none;
  font-size: 17px; line-height: 1; padding: 3px 4px;
  filter: grayscale(1) opacity(.35);
  transition: filter .15s var(--ease), transform .15s var(--ease);
}
.star-btn:hover { filter: grayscale(.2) opacity(.95); transform: scale(1.15); }
.star-btn.on { filter: none; }
.star-btn.pop { animation: star-pop .35s var(--ease); }
@keyframes star-pop {
  0% { transform: scale(.55) rotate(-12deg); }
  55% { transform: scale(1.28) rotate(6deg); }
  100% { transform: scale(1) rotate(0); }
}
/* 卡片/列表共用的操作工具集：桌面悬停/键盘聚焦浮现；触屏常显弱化 */
.c-tools { display: flex; align-items: center; gap: 4px; opacity: 0; transition: opacity .18s var(--ease); }
.card:hover .c-tools, .card:focus-within .c-tools { opacity: 1; }
html.is-touch .c-tools { opacity: .75; }
/* ---------- 双区卡（卡片视图）：主区白空间只住名字+价格，脚注带收辅助信息 ---------- */
.card.vcard { padding: 16px 18px 13px; }
/* emoji 做独立图标列：顶部与名字行平齐（margin 抵消名字行高差）；名字与价格文字起点严格对齐 */
.vcard .c-hero { display: flex; align-items: flex-start; gap: 10px; padding: 2px 2px 13px; }
.vcard .c-emoji { flex: 0 0 auto; font-size: 21px; line-height: 1; margin-top: 3px; }
.vcard .c-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 9px; }
.vcard .item-name { display: block; flex: none; }
.vcard .c-foot {
  border-top: 1px solid var(--line); padding-top: 9px; margin-top: auto;
  display: flex; align-items: center; gap: 7px; flex-wrap: wrap;
  font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums;
}
.vcard .c-foot .c-low b { font-weight: 600; }
.vcard .c-foot .tag-chip { font-size: 10px; padding: 2px 7px; opacity: .85; }
.vcard .c-rmb { color: var(--muted); font-size: 11px; font-weight: 500; white-space: nowrap; }
.vcard .c-tools { margin-left: auto; }
/* [试验] 名字与价格同大：21px / 21px（退回=删除下面两条 + 容器查询里两条） */
.vcard .item-name { font-size: 21px; }
.vcard .price { font-size: 21px; letter-spacing: -.4px; }

/* ---------- 列表视图：行情行（名字左 · 小走势中 · 涨跌/价格右） ---------- */
#cards.list-mode {
  display: flex; flex-direction: column; gap: 0;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-md);
  box-shadow: var(--shadow-1); padding: 4px 0; overflow: hidden;
}
#cards.list-mode .card {
  border: none; border-radius: 0; box-shadow: none; background: transparent;
  padding: 10px 16px; transition: background .12s var(--ease), opacity .15s var(--ease);
}
#cards.list-mode .card + .card { border-top: 1px solid var(--line); }
#cards.list-mode .card:hover { background: var(--card-2); }
.lrow { display: flex; flex-direction: row; align-items: center; gap: 14px; }
/* 表格式列对齐：名字固定列宽（14em），各行价格/涨跌/走势纵向对齐；窄屏递减 */
.lrow .item-name { flex: 0 0 14em; min-width: 0; font-size: 15.5px; }
.lrow .spark { flex: 0 0 84px; width: 84px; height: 26px; }
@media (max-width: 1100px) { .lrow .item-name { flex-basis: 11em; } }
@media (max-width: 900px) { .lrow .item-name { flex-basis: 9em; } }
@media (max-width: 640px) {
  /* 窄屏列表：走势/涨跌/工具组隐藏，过期徽标缩成圆点（金=过期 红=异常），名字弹性占满剩余宽度不截断 */
  .lrow { gap: 10px; }
  .lrow .item-name { flex: 1 1 auto; }
  .lrow .spark, .lrow .l-pct, .lrow .c-tools { display: none; }
  .lrow .l-price { flex-basis: 5em; }
  .lrow .badge-stale {
    font-size: 0; padding: 0; width: 9px; height: 9px; border-radius: 50%;
    background: var(--gold); border: none;
  }
  .lrow .badge-stale.err { background: var(--up); }
}
.lrow .badge-stale { font-size: 10px; padding: 1px 7px; }
.l-pct {
  flex: 0 0 4.5em; text-align: left;
  font-family: "Segoe UI", system-ui, sans-serif; font-size: 12.5px; font-weight: 700;
}
.l-pct.up { color: var(--up); }
.l-pct.down { color: var(--down); }
.l-pct.flat { color: var(--muted); }
.l-price {
  flex: 0 0 6.5em; text-align: left;
  font-family: "Segoe UI", system-ui, sans-serif;
  font-size: 23px; font-weight: 900; letter-spacing: -.5px;
  font-variant-numeric: tabular-nums; line-height: 1.15;
}
.l-price small { display: block; font-size: 11px; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.l-price .na-txt { font-size: 13px; font-weight: 600; color: var(--muted); }
.lrow .star-btn { position: static; font-size: 15px; padding: 2px 3px; }
/* 视图切换分段控件靠右 */
.view-seg { margin-left: auto; }
/* 窄卡片（列宽 ≤ 240px，超宽屏 6 列时）紧凑排版 */
@container (max-width: 240px) {
  .card.vcard { padding: 12px 12px 10px; gap: 8px; }
  .vcard .c-hero { padding: 0 0 10px; gap: 7px; }
  .price { font-size: 22px; }
  .item-name { font-size: 15px; }
  .vcard .c-foot { font-size: 10.5px; padding-top: 8px; }
  .c-tools .btn.small { font-size: 11px; padding: 3px 7px; }
  /* [试验] 窄卡同步：名字与价格同大 */
  .vcard .item-name { font-size: 16px; }
  .vcard .price { font-size: 16px; }
}

/* ---------- 空状态 ---------- */
.empty {
  text-align: center; color: var(--muted); padding: 80px 20px; font-size: 14px; line-height: 2;
}
.empty .big { font-size: 40px; }

/* ---------- 弹窗（iOS 化） ---------- */
.modal {
  position: fixed; inset: 0; z-index: 50;
  background: color-mix(in srgb, oklch(16% 0.01 55) 42%, transparent);
  -webkit-backdrop-filter: blur(8px) saturate(1.2);
  backdrop-filter: blur(8px) saturate(1.2);
  display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px;
  overflow-y: auto;
  animation: modal-fade .2s var(--ease);
}
.modal.hidden { display: none; }
@keyframes modal-fade { from { opacity: 0; } }
.dialog {
  background: var(--card); border-radius: var(--r-lg); width: 100%; max-width: 680px;
  border: 1px solid color-mix(in srgb, var(--line) 55%, transparent);
  box-shadow: var(--shadow-3); padding: 22px 24px;
  animation: sheet-in .24s var(--ease);
}
@keyframes sheet-in { from { opacity: 0; transform: translateY(10px) scale(.98); } }
.dialog.wide { max-width: 960px; }
.dialog-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.dialog-head h2 { font-size: 17px; font-weight: 600; margin: 0; flex: 1; letter-spacing: .2px; }
.close {
  border: none; background: var(--card-2); font-size: 15px; color: var(--muted);
  width: 28px; height: 28px; border-radius: 50%; cursor: pointer; line-height: 1;
  transition: background .15s var(--ease), color .15s var(--ease);
}
.close:hover { background: var(--accent-soft); color: var(--accent); }

.search-row { display: flex; gap: 8px; }
.search-row input {
  flex: 1; border: 1px solid var(--line); border-radius: var(--r-sm); padding: 10px 12px; font-size: 14px;
  background: var(--card); transition: border-color .15s var(--ease);
}
.search-row input:hover { border-color: var(--line-strong); }
.search-row input:focus { outline: none; box-shadow: var(--ring); border-color: var(--accent); }
.hint { font-size: 12px; color: var(--muted); margin: 8px 0 12px; }
.candidates { display: flex; flex-direction: column; gap: 8px; max-height: 420px; overflow-y: auto; }
.cand {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  transition: border-color .15s var(--ease), background .15s var(--ease);
}
.cand:hover { border-color: var(--line-strong); background: var(--card-2); }
.cand .n { font-weight: 700; font-size: 14px; }
.cand .m { font-size: 12px; color: var(--muted); flex: 1; }
.cand .p { font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; }
.loading { text-align: center; color: var(--muted); padding: 24px; font-size: 13px; }
.err-text { color: var(--up); font-size: 13px; padding: 8px 0; }

/* ---------- 详情 ---------- */
.summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 14px; }
.stat { background: var(--card-2); border-radius: var(--r-sm); padding: 10px 12px; border: 1px solid transparent; }
.stat .k { font-size: 12px; color: var(--muted); font-weight: 500; }
.stat .v { font-size: 17px; font-weight: 800; margin-top: 2px; }
.stat .v small { font-size: 11px; color: var(--muted); font-weight: 500; }
.stat .v .v-main { display: block; }
.stat .v .v-time { display: block; font-size: 11px; color: var(--muted); font-weight: 500; margin-top: 4px; }
.stat .v small.up { color: var(--up); }
.stat .v small.down { color: var(--down); }
.stat.hl { background: var(--down-soft); }
.stat.hl .v { color: var(--down); }
.stat.amberhl { background: var(--gold-soft); }
.stat.amberhl .v { color: var(--gold); }
.amber { color: var(--gold); }
.newlow { color: var(--down); font-weight: 700; }
.icon-btn {
  border: 1px solid transparent; background: transparent; border-radius: 6px;
  font-size: 11px; padding: 2px 6px; cursor: pointer; line-height: 1.4; color: var(--muted);
  transition: background .15s var(--ease), color .15s var(--ease);
}
.icon-btn:hover { background: var(--card-2); color: var(--text); }
.stat { position: relative; }
.stat .icon-btn.abs { position: absolute; right: 8px; top: 8px; }
.rmb-strong { color: var(--muted); font-weight: 600; font-size: 12px; }
td.rmb-col { color: var(--muted); }
.sec-title { font-size: 14px; font-weight: 700; margin: 18px 0 8px; }
.sec-title .muted { font-weight: 400; }
table.cmp tr.mine { background: var(--accent-soft); }
.badge-mine {
  font-size: 10px; color: var(--accent); background: var(--accent-soft);
  padding: 1px 6px; border-radius: 999px; font-weight: 600;
}
td .up { color: var(--up); }
td .down { color: var(--down); }
td .flat { color: var(--muted); }
.pager {
  display: flex; align-items: center; justify-content: flex-end; gap: 8px;
  padding: 10px 2px 2px; font-size: 12.5px;
}
.pager .page-info { font-weight: 600; }

/* ---------- 分段控件（iOS 式） ---------- */
.tabs, .seg {
  display: inline-flex; padding: 2px; gap: 2px;
  background: var(--card-2); border-radius: 9px;
}
.tabs { margin-bottom: 10px; }
.tab, .seg button {
  border: none; background: transparent; color: var(--muted);
  border-radius: 7px; padding: 5px 16px; font-size: 13px; cursor: pointer;
  transition: background .2s var(--ease), color .2s var(--ease), box-shadow .2s var(--ease);
}
.tab.active, .seg button.active {
  background: var(--card); color: var(--text); font-weight: 600;
  box-shadow: var(--shadow-1);
}
.seg button.active { color: var(--accent); }
#chart { width: 100%; height: 340px; }

/* ---------- 榜单面板 ---------- */
.cmp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
  gap: 16px; margin-top: 22px; justify-content: stretch;
  width: 100%;
}
.panel {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-md);
  box-shadow: var(--shadow-1); padding: 14px 16px;
}
.panel h3 { margin: 0 0 10px; font-size: 14px; display: flex; align-items: center; }
.mini-sel {
  border: 1px solid var(--line); border-radius: 6px; font-size: 11px;
  padding: 1px 4px; margin-left: 6px; background: var(--card); color: var(--muted);
}
.gold-view { cursor: pointer; transition: all .15s var(--ease); white-space: nowrap; margin-left: auto; }
.gold-view:hover { border-color: var(--line-strong); color: var(--text); }
.gold-view.on {
  background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600;
}
.panel.down h3 { color: var(--down); }
.panel.up h3 { color: var(--up); }
.panel.gold h3 { color: var(--gold); }
table.slim {
  width: 100%;
  border-collapse: collapse; font-size: 13px;
  table-layout: fixed;
}
table.slim th {
  text-align: left; padding: 5px 8px; color: var(--muted); font-weight: 600;
  border-bottom: 1px solid var(--line); font-size: 11px; letter-spacing: .02em;
}
/* 金价榜保持表格式原样（仅末列右对齐） */
table.slim th:last-child, table.slim td:last-child { text-align: right; }
table.slim td { padding: 7px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.slim tr:last-child td { border-bottom: none; }
table.slim tbody tr { transition: background .12s var(--ease); }
table.slim tbody tr:hover { background: var(--card-2); }
table.slim td.s-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; }
table.slim td.s-pct { font-weight: 800; }

/* 道具榜（跌幅/涨幅）：表格式。道具列自动吃满剩余宽度、放不下换行（不截断）；
   现价/昨价/环比 作为数字簇靠右对齐，现价(15.5/800) 主角，昨价/环比(12px 灰) 弱化 */
table.rank-t { width: 100%; border-collapse: collapse; table-layout: auto; }
table.rank-t th {
  text-align: left; padding: 5px 8px; border-bottom: 1px solid var(--line);
  font-size: 11px; color: var(--muted); font-weight: 600; letter-spacing: .02em;
  white-space: nowrap;
}
table.rank-t th:not(:first-child), table.rank-t td:not(:first-child) { text-align: right; }
table.rank-t td { padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: baseline; }
table.rank-t tr:last-child td { border-bottom: none; }
table.rank-t tbody tr { transition: background .12s var(--ease); }
table.rank-t tbody tr:hover { background: var(--card-2); }
table.rank-t td:not(:first-child) { white-space: nowrap; font-variant-numeric: tabular-nums; }
table.rank-t td.s-name {
  font-weight: 700; font-size: 13.5px;
  white-space: normal; word-break: break-word; /* 名字放不下换行，不截断 */
}
table.rank-t td.s-price { font-size: 15.5px; font-weight: 800; letter-spacing: -.2px; }
table.rank-t td.s-ref { color: var(--muted); font-size: 12px; font-weight: 400; }
table.rank-t td.s-pct { font-weight: 700; font-size: 12px; }
table.rank-t td.s-pct.up { color: var(--up); }
table.rank-t td.s-pct.down { color: var(--down); }
table.rank-t td.s-pct.flat { color: var(--muted); }
table.slim td.s-pct.up { color: var(--up); }
table.slim td.s-pct.down { color: var(--down); }
table.slim td.s-pct.flat { color: var(--muted); }
table.slim .empty-td { text-align: center; color: var(--muted); }
.summary-note { margin-top: 8px; font-size: 11.5px; text-align: right; color: var(--muted); }
@media (max-width: 760px) { .cmp-grid { grid-template-columns: 1fr; } }

/* ---------- 表格（记录/比价/账本） ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-wrap table { min-width: max-content; }
.table-wrap { max-height: 260px; overflow-y: auto; margin-top: 12px; border: 1px solid var(--line); border-radius: var(--r-sm); }
table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
th, td { text-align: left; padding: 7px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { position: sticky; top: 0; background: var(--card-2); color: var(--muted); font-weight: 600; font-size: 11.5px; letter-spacing: .02em; }
td.ok { color: var(--text); }
td.fail { color: var(--up); }
.empty-td { text-align: center; color: var(--muted); padding: 18px 0 !important; }

/* ---------- 交易账本 ---------- */
.trade-form {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  padding: 12px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--card-2);
  margin-bottom: 4px;
}
.trade-form input {
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 13px;
  min-width: 120px; flex: 1 1 120px; background: var(--card);
}
.trade-form input:hover { border-color: var(--line-strong); }
.trade-form input:focus { outline: none; box-shadow: var(--ring); border-color: var(--accent); }
#tfAdd { flex-shrink: 0; }
.stat.hl-profit .v { color: var(--up); }
.stat.loss .v { color: var(--down); }
.side-badge { font-size: 11px; padding: 2px 8px; border-radius: 6px; font-weight: 600; }
.side-badge.buy { color: var(--accent); background: var(--accent-soft); }
.side-badge.sell { color: var(--gold); background: var(--gold-soft); }

/* ---------- 页脚 ---------- */
footer {
  padding: 14px 24px; font-size: 12px; color: var(--muted);
  border-top: 1px solid var(--line); line-height: 1.8;
}
footer a { color: var(--accent); text-decoration: none; }
footer a:hover { text-decoration: underline; }

/* ---------- 手机端（UA 识别 is-touch）：移动布局，与视口宽度无关 ---------- */
html.is-touch .topbar { padding: 10px 14px; gap: 10px; }
html.is-touch .brand h1 { font-size: 16px; }
html.is-touch .link-src { display: none; }
html.is-touch .btn.profile .p-name { display: none; }
html.is-touch .btn.profile { padding: 8px 10px; }
html.is-touch .svc-chip { font-size: 11px; padding: 3px 8px; }
html.is-touch .status { font-size: 12px; }
html.is-touch .gold-chip { font-size: 11px; padding: 2px 8px; }
html.is-touch .modal { padding: 0; align-items: stretch; backdrop-filter: none; -webkit-backdrop-filter: none; }
html.is-touch .dialog { max-width: 100%; border-radius: 0; min-height: 100%; border: none; }
html.is-touch .summary { grid-template-columns: repeat(2, 1fr); }
html.is-touch #chart { height: 280px; }
/* 任意窄视口通用（桌面窄窗也适用，避免溢出） */
@media (max-width: 640px) {
  .sort-bar input[type=number] { width: 84px; }
  .sort-bar, .tag-bar { gap: 6px; }
  main { padding: 12px 12px 24px; }
  .cmp-grid { margin-top: 14px; }
  html.is-desktop .cards { gap: 12px; }
  .cmp-grid > .panel { min-width: 0; }
  table.slim td, table.slim th { white-space: normal; }
}
/* 超宽屏：内容限宽居中，避免 4K 无限拉伸 */
@media (min-width: 1600px) {
  main { max-width: 1920px; margin-left: auto; margin-right: auto; }
}

/* ---------- 动效可关 ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- 窄屏顶栏（置于文件末尾，确保覆盖 .btn 等基础规则） ---------- */
/* ≤900px（含手机）：两行网格——左品牌右操作、状态独占次行，不再自由换行炸开 */
@media (max-width: 900px) {
  .topbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 190px);
    column-gap: 10px;
    align-items: center;
    row-gap: 6px;
  }
  .brand { grid-column: 1; grid-row: 1; flex-wrap: wrap; min-width: 0; }
  .actions { grid-column: 2; grid-row: 1; flex-wrap: wrap; justify-content: flex-end; row-gap: 4px; }
  .status { grid-column: 1 / -1; grid-row: 2; }
  .brand h1 { font-size: 16px; }
}
/* ≤640px：低频入口收纳——备份/源站隐藏、账本只留头像 */
@media (max-width: 640px) {
  .backup-btn, .link-src, .actions .p-name { display: none; }
}

/* ---------- 账本切换 / 管理 ---------- */
.profile-actions { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.btn.profile.main-ledger { border-color: var(--gold); color: var(--gold); }
.ledger-manager-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.lm-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--card-2);
}
.lm-row.main { border-color: var(--gold); }
.lm-name { font-weight: 700; }
.lm-actions { display: inline-flex; gap: 6px; flex-wrap: wrap; }

/* 详情空状态：源网首次未返回历史 */
.detail-empty {
  padding: 60px 30px; text-align: center; color: var(--muted);
  font-size: 14px; line-height: 1.9;
  border: 1px dashed var(--line); border-radius: 10px;
  background: color-mix(in srgb, var(--card-2) 60%, transparent);
}
