/* ==========================================================================
   原神圣遗物副本推荐器 — 元素色谱决策看板
   THESIS: 把「刷哪个副本」做成一张可读的数据看板；七元素色是唯一的语义
           身份编码（角色 + 筛选 + 契合度状态），拒绝 SaaS 灰与游戏插画。
   OWN-WORLD: 暖白中性底 + 炭色品牌锚（主按钮/排名/选中）+ 七元素色语义点。
           数字用 tabular-nums，卡片 12–14px 圆角，单一边界阴影作为唯一深度。

   对比度口径（2026-09-01 修订，全部实算至 WCAG AA）：
     --text-2 = 7.8:1 / --text-3 = 4.8:1 on --bg（旧 text-3 #949087 仅 2.89:1）
     元素色分两档：--elem 只用于圆点·描边·图底，承载白字时一律用 --elem-ink（≥4.5:1）
   ========================================================================== */

:root {
  /* 中性底 —— Operate 工具，PC 白天室内使用 → 浅色 */
  --bg: #f5f4f0;
  --surface: #ffffff;
  --surface-2: #f0efea;
  --border: #e2dfd7;
  --border-strong: #cfcabd;

  --text: #1c1b18;
  --text-2: #4f4c45;   /* 7.8:1 */
  --text-3: #6f6b62;   /* 4.8:1 —— 次级说明的最小可读档，再浅就不可用了 */

  /* 品牌锚：炭色（近黑），用于主 action / 排名 / 选中 */
  --ink: #1c1b18;
  --ink-soft: #35332e;

  /* 七元素色 —— 语义身份编码，不用于装饰 */
  --fire: #df6237;
  --water: #3a7fd4;
  --wind: #3fae93;
  --electro: #8a7ad3;
  --cryo: #6aa1d6;
  --dendro: #79aa35;
  --geo: #bd892c;
  --neutral: #8b877d;

  /* 契合度状态色（文字 / 浅底配对，均已验 ≥4.5:1） */
  --good: #0f6b49;     --good-soft: #e2f2eb;   /* 4.9:1 */
  --info: #2f57bd;     --info-soft: #e7ecf8;   /* 5.5:1 */
  --warn: #8a5a0c;     --warn-soft: #f6ecd9;   /* 5.1:1 */
  --bad:  #a53a25;     --bad-soft:  #f7e5e0;   /* 5.1:1 */

  /* 焦点 / 选择 */
  --focus: #2f57bd;

  /* 圆角体系 */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 14px;

  /* 唯一深度：偏移 + 柔和模糊的单一边界阴影 */
  --shadow: 0 1px 2px rgba(28, 27, 24, 0.04), 0 3px 10px rgba(28, 27, 24, 0.05);

  /* 内容壳宽：超宽屏不无限拉伸，保证正文 measure */
  --shell: 1440px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  caret-color: var(--ink);
}

/* 数字：所有可量化信息统一等宽数字，对齐 */
.num, .combo-score, .metric b, .gain, .ease-row .val {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

h1, h2, h3 { font-weight: 600; margin: 0; }
p { margin: 0; }

/* ---------- 主题化浏览器默认（build 而非 assemble 的信号） ---------- */
::selection { background: rgba(47, 87, 189, 0.2); color: var(--text); }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: 4px;
}

/* 滚动条：角色网格与左栏各有一条，必须与暖白底同色系 */
.scroll { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
.scroll::-webkit-scrollbar { width: 11px; height: 11px; }
.scroll::-webkit-scrollbar-track { background: transparent; }
.scroll::-webkit-scrollbar-thumb {
  background: var(--border-strong); border-radius: 99px;
  border: 3px solid var(--surface); background-clip: content-box;
}
.scroll::-webkit-scrollbar-thumb:hover { background: var(--text-3); background-clip: content-box; }

/* 表格数字列右对齐 + 等宽 */
table.rt td.num { font-variant-numeric: tabular-nums; }

/* 仅供屏幕阅读器 */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 18px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  max-width: var(--shell); margin: 0 auto;
}
.topbar h1 { font-size: 20px; letter-spacing: -0.015em; }
.topbar .sub { font-size: 13px; color: var(--text-2); margin-top: 3px; }
.topbar-stat {
  font-size: 13px; color: var(--text-2); text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ---------- 布局 ---------- */
.layout {
  display: grid;
  grid-template-columns: minmax(340px, 440px) minmax(0, 1fr);
  gap: 20px;
  padding: 20px 28px 44px;
  align-items: start;
  max-width: var(--shell); margin: 0 auto;
}

/* 桌面：左栏吸顶。调权重 ↔ 看结果 是核心循环，输入不该被滚走。 */
@media (min-width: 1041px) {
  .panel-left {
    position: sticky; top: 16px;
    max-height: calc(100vh - 32px);
    overflow-y: auto; overscroll-behavior: contain;
    padding-right: 2px;
  }
}

@media (max-width: 1040px) {
  .layout { grid-template-columns: 1fr; padding: 16px 16px 36px; }
  .topbar { padding: 14px 16px; }
}

/* 窄屏：顶栏标题 + 状态并排会挤爆，改为竖排；结论行改为堆叠 */
@media (max-width: 620px) {
  .topbar { flex-direction: column; align-items: flex-start; gap: 5px; }
  .topbar-stat { text-align: left; }
  .layout { padding: 14px 12px 30px; }
  .foot { padding: 0 12px 28px; }
  .panel-block { padding: 15px 14px 17px; }
  .combo { padding: 14px 14px; }
  .conc-list li { flex-wrap: wrap; gap: 6px 12px; }
  .conc-dom { width: auto; flex: 1 0 100%; }
  .conc-sum { margin-left: auto; }
  .char-grid { max-height: 300px; }
}

.panel { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

.panel-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px 20px 20px;
  box-shadow: var(--shadow);
}

.block-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px; margin-bottom: 16px;
}
.block-head h2 { font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }
.hint { font-size: 12.5px; color: var(--text-3); }

/* ---------- 元素筛选 ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 14px; }
.chip {
  border: 1px solid var(--border); background: transparent; color: var(--text-2);
  border-radius: 999px; padding: 6px 15px; font-size: 14px; cursor: pointer;
  font-family: inherit; transition: border-color .12s, color .12s, background .12s;
}
.chip:hover { border-color: var(--border-strong); color: var(--text); }
.chip:active { background: var(--surface-2); }
.chip.on {
  background: var(--ink); color: #fff; border-color: var(--ink);
}
/* 元素 chip 上的元素色小圆点，作为身份提示 */
.chip .dot {
  display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  margin-right: 7px; vertical-align: 1px;
}
.chip.on .dot { opacity: .95; }
.chip:not(.on) .dot { opacity: .75; }

/* ---------- 角色网格 ---------- */
.char-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 8px;
  max-height: clamp(220px, 36vh, 420px);
  overflow-y: auto; padding-right: 2px;
}
.char-card {
  border: 1px solid var(--border); border-radius: var(--r-md);
  background: var(--surface); padding: 9px 7px 7px;
  transition: border-color .12s, background .12s;
}
.char-card.on {
  border-color: var(--elem, var(--ink));
  background: var(--elem-soft, var(--surface-2));
  box-shadow: inset 0 0 0 1px var(--elem, var(--ink));
}
/* 真正可点的按钮：承载键盘焦点与 aria-pressed */
.char-pick {
  display: block; width: 100%; border: 0; background: none; padding: 0;
  font: inherit; color: inherit; text-align: center; cursor: pointer;
  border-radius: 6px;
}
.char-pick:hover .cname { color: var(--ink); }
.char-pick:active .thumb { transform: scale(.93); }
.char-card .cname { display: block; font-size: 15px; line-height: 1.3; font-weight: 500; }
.char-card .cmeta { display: block; font-size: 12.5px; color: var(--text-3); margin-top: 2px; }
.char-card .thumb {
  width: 40px; height: 40px; border-radius: 50%; margin: 0 auto 7px;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; color: #fff; font-weight: 600;
  line-height: 1;         /* 消除继承的 1.55 行高，让单字真正落在圆心 */
  padding-top: 1px;       /* 中文方块字的视觉重心略偏上，微调补偿 */
  background: var(--elem-ink, var(--ink-soft));  /* 白字 → 用加深版元素色 */
  transition: transform .09s ease-out;
}

/* 权重条：选中后出现的主练/次练/随缘 */
.wbar { display: flex; gap: 3px; margin-top: 7px; }
.wbtn {
  flex: 1; border: 1px solid var(--border); background: var(--surface);
  border-radius: 6px; font-size: 12px; padding: 3px 0; cursor: pointer;
  color: var(--text-2); font-family: inherit; line-height: 1.5;
  transition: background .1s, color .1s, border-color .1s;
}
.wbtn:hover { background: var(--surface-2); color: var(--text); }
.wbtn:active { transform: translateY(1px); }
.wbtn.on {
  background: var(--elem-ink, var(--ink)); color: #fff;
  border-color: var(--elem-ink, var(--ink));
}

.row-actions { display: flex; gap: 8px; margin-top: 14px; }
.btn {
  border: 1px solid var(--border-strong); background: transparent; color: var(--text);
  border-radius: var(--r-sm); padding: 7px 15px; font-size: 13.5px; cursor: pointer;
  font-family: inherit; transition: background .12s, border-color .12s, transform .06s;
}
.btn:hover { background: var(--surface-2); border-color: var(--ink-soft); }
.btn:active { transform: translateY(1px); background: var(--border); }
.btn.sm { padding: 6px 13px; font-size: 13.5px; }

/* ---------- 表单 ---------- */
.field { display: block; margin-bottom: 18px; }
.field > label { display: block; font-size: 14px; margin-bottom: 7px; cursor: pointer; }
.field > label b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.note {
  font-size: 12.5px; color: var(--text-3); margin: 7px 0 0; line-height: 1.6;
}

.field input[type=range] {
  width: 100%; height: 20px; cursor: pointer;
  appearance: none; -webkit-appearance: none;
  background: transparent; outline: none; margin: 0;
}
/* 轨道用伪元素画，thumb 才有可定制的圆环焦点态 */
.field input[type=range]::-webkit-slider-runnable-track {
  height: 4px; background: var(--border); border-radius: 2px;
}
.field input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 17px; height: 17px; border-radius: 50%; margin-top: -6.5px;
  background: var(--ink); border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(28,27,24,.25); cursor: pointer;
  transition: transform .1s ease-out;
}
.field input[type=range]:active::-webkit-slider-thumb { transform: scale(1.15); }
.field input[type=range]::-moz-range-track { height: 4px; background: var(--border); border-radius: 2px; }
.field input[type=range]::-moz-range-thumb {
  width: 15px; height: 15px; border-radius: 50%;
  background: var(--ink); border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(28,27,24,.25); cursor: pointer;
}

.field select {
  width: 100%; font: inherit; font-size: 14.5px; color: var(--text);
  appearance: none; -webkit-appearance: none;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5' fill='none' stroke='%234f4c45' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 11px center / 12px 8px;
  border: 1px solid var(--border-strong); border-radius: var(--r-sm);
  padding: 8px 34px 8px 11px; cursor: pointer;
  transition: border-color .12s;
}
.field select:hover { border-color: var(--ink-soft); }

/* 复选框：input + 文案 + 说明，说明通过 aria-describedby 关联而非塞进 label */
.check {
  display: grid; grid-template-columns: auto 1fr; gap: 3px 10px;
  margin-bottom: 16px;
}
.check > input {
  grid-column: 1; grid-row: 1; margin-top: 4px;
  accent-color: var(--ink); width: 16px; height: 16px; cursor: pointer;
}
.check > label { grid-column: 2; grid-row: 1; font-size: 14px; cursor: pointer; }
.check > .note { grid-column: 2; grid-row: 2; margin-top: 1px; }

/* 长说明折叠：默认只留一行摘要，避免 11px 文字墙 */
.more-note { margin-top: 7px; }
.more-note > summary {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12.5px; color: var(--text-2); cursor: pointer;
  list-style: none; padding: 2px 0; width: fit-content;
}
.more-note > summary::-webkit-details-marker { display: none; }
.more-note > summary::before {
  content: ''; width: 0; height: 0; flex: none;
  border-left: 5px solid var(--text-3);
  border-top: 4px solid transparent; border-bottom: 4px solid transparent;
  transition: transform .15s ease-out;
}
.more-note[open] > summary::before { transform: rotate(90deg); }
.more-note > summary:hover { color: var(--text); }
.more-note > summary:hover::before { border-left-color: var(--text); }
.more-note > p { font-size: 12.5px; color: var(--text-3); line-height: 1.65; margin-top: 7px; }

/* ---------- 空态 ---------- */
.empty { text-align: center; padding: 56px 16px; color: var(--text-2); }
.empty-mark { width: 52px; height: 52px; margin: 0 auto 18px; display: block; color: var(--border-strong); }
.empty p { font-size: 15px; }
.empty .empty-sub { font-size: 13px; color: var(--text-3); margin-top: 8px; }

/* ---------- 组合卡片 ---------- */
.combo {
  border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 16px 18px; margin-bottom: 14px; background: var(--surface);
}
.combo.top { border-color: var(--ink); box-shadow: var(--shadow); }
.combo-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.rank {
  width: 26px; height: 26px; border-radius: 50%; flex: none;
  background: var(--ink); color: #fff; font-size: 13px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
}
.combo-title { font-size: 17px; font-weight: 600; letter-spacing: -0.015em; }
.combo-region { font-size: 12px; color: var(--text-3); }
.combo-score { margin-left: auto; font-size: 19px; font-weight: 600; color: var(--ink); }

.metrics { display: flex; gap: 8px; flex-wrap: wrap; margin: 14px 0 15px; }
.metric {
  background: var(--surface-2); border-radius: var(--r-sm); padding: 8px 13px;
  font-size: 13px; color: var(--text-2);
}
.metric b { display: block; font-size: 18px; font-weight: 600; color: var(--text); margin-top: 1px; }

/* 明细表 7 列，窄屏放不下：交给横向滚动而不是压成一团 *
 * min-width 保证列不被挤扁，滚动条走 .scroll 的主题化样式 */
.rt-wrap { overflow-x: auto; overscroll-behavior-x: contain; }
table.rt { width: 100%; min-width: 540px; border-collapse: collapse; font-size: 13.5px; }
table.rt th {
  text-align: left; font-weight: 500; color: var(--text-3);
  padding: 6px 8px; border-bottom: 1px solid var(--border); font-size: 12px;
  white-space: nowrap;
}
table.rt td { padding: 7px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.rt tr:last-child td { border-bottom: none; }
table.rt td.num { text-align: right; }

/* 角色名前的元素色标识 */
.rt-elem {
  display: inline-block; width: 8px; height: 8px; border-radius: 2px;
  margin-right: 7px; vertical-align: 0; flex: none;
}

/* 多套命中标签 */
.multi-tag {
  display: inline-block; margin-left: 5px; padding: 0 6px; border-radius: 4px;
  font-size: 11px; font-weight: 600; line-height: 18px;
  background: var(--warn-soft); color: var(--warn);
}

.reforge-tag {
  display: inline-block; padding: 0 7px; border-radius: 4px;
  font-size: 12px; font-weight: 600; line-height: 19px;
  background: var(--info-soft); color: var(--info);
}

.tag {
  display: inline-block; padding: 1px 8px; border-radius: 5px;
  font-size: 12px; font-weight: 500; background: var(--surface-2); color: var(--text-2);
}
.tag.s { background: var(--good-soft); color: var(--good); }
.tag.a { background: var(--info-soft); color: var(--info); }
.tag.b { background: var(--warn-soft); color: var(--warn); }
.tag.c { background: var(--bad-soft); color: var(--bad); }

.bar { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; min-width: 46px; }
.bar > i {
  display: block; height: 100%; background: var(--ink); border-radius: 3px;
  transition: width .3s cubic-bezier(.16,.84,.44,1);
}

/* ---------- 贪心 / 易度 ---------- */
.step {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 14px;
}
.step:last-child { border-bottom: none; }
.step .n { color: var(--text-3); font-size: 13px; width: 16px; flex: none; font-variant-numeric: tabular-nums; }
.step .nm { min-width: 118px; }
.step .grow { flex: 1; }
.step .gain { font-variant-numeric: tabular-nums; font-size: 13px; color: var(--text-2); }

.ease-row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 14px;
}
.ease-row:last-child { border-bottom: none; }
.ease-row .nm { width: 92px; flex: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ease-row .grow { flex: 1; min-width: 0; }
.ease-row .val {
  font-size: 13px; color: var(--text-2); font-variant-numeric: tabular-nums;
  min-width: 150px; text-align: right; flex: none; white-space: nowrap;
}

.mc-note {
  margin-top: 12px; font-size: 13px; color: var(--text-2);
  background: var(--surface-2); border-radius: var(--r-sm); padding: 10px 13px;
}

/* 折叠的组合卡片（第 3 个起默认隐藏） */
.combo-more { display: flex; justify-content: center; padding: 2px 0 4px; }
.combo-more .btn { border-style: dashed; color: var(--text-2); }
.combo-more .btn:hover { color: var(--text); border-color: var(--ink-soft); }

/* ---------- 结论区 ---------- */
.conc-head {
  display: flex; align-items: center; gap: 12px;
  font-size: 14.5px; line-height: 1.65; color: var(--text);
}
.conc-score {
  flex: none; font-size: 21px; font-weight: 700; color: var(--ink);
  font-variant-numeric: tabular-nums; padding-right: 13px;
  border-right: 1px solid var(--border);
}
.conc-head b { font-weight: 600; color: var(--ink); }

.conc-list {
  list-style: none; margin: 15px 0 0; padding: 0;
  border-top: 1px solid var(--border);
}
.conc-list li {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid var(--border); font-size: 13.5px;
}
.conc-dom {
  flex: none; width: 118px; font-weight: 600; color: var(--text);
  padding-top: 2px;
}
/* 结论区：所有角色共享同一个网格容器，名 | 圣遗物 两栏固定对齐；
   定宽名栏（7.5em）+ 固定的副本列（118px），任意缩放下圣遗物列左缘都一致 */
.conc-roles {
  flex: 1; min-width: 0;
  display: grid;
  grid-template-columns: 7.5em 1fr;
  column-gap: 12px; row-gap: 7px;
  align-items: center; font-size: 13.5px; color: var(--text-2);
}
.conc-nm {
  display: inline-flex; align-items: center; gap: 6px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0;
  color: var(--text); font-weight: 500;
}
.conc-dot {
  width: 8px; height: 8px; border-radius: 2px; flex: none;
  background: var(--ec, var(--neutral));
}
.conc-sub { font-style: normal; color: var(--text-3); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conc-sum {
  flex: none; font-size: 13px; color: var(--text-2);
  font-variant-numeric: tabular-nums; padding-top: 2px;
}
.conc-sum b { color: var(--ink); font-weight: 600; }

.conc-gap {
  margin-top: 13px; font-size: 13.5px; color: var(--text-2);
  background: var(--surface-2); border-radius: var(--r-sm); padding: 10px 13px;
  line-height: 1.65;
}
.conc-gap b { color: var(--ink); font-weight: 600; }

.conc-miss {
  margin-top: 13px; font-size: 13.5px; color: var(--bad);
  background: var(--bad-soft); border-radius: var(--r-sm); padding: 10px 13px;
  line-height: 1.65;
}

/* ---------- 页脚 ---------- */
.foot {
  max-width: var(--shell); margin: 0 auto;
  padding: 0 28px 36px; font-size: 12.5px; color: var(--text-3);
}

/* ---------- 唯一一处编排过的动效 ----------
   只在「最优组合本身发生变化」时播放（换角色 / 调权重导致换本），
   拖滑块微调分数不会重播。 */
@keyframes riseIn {
  from { opacity: 0; transform: translateY(7px); }
  to   { opacity: 1; transform: none; }
}
.combo.reveal { animation: riseIn .34s cubic-bezier(.16,.84,.44,1) both; }

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