:root {
  --bg: #ffffff;
  --bg-soft: #f5f7fa;
  --card: #ffffff;
  --card-2: #eef2f6;
  --line: #e3e9f0;
  --line-2: #cbd6e2;
  --text: #17212e;
  --muted: #5b6b7c;
  --dim: #8b9aab;
  --accent: #0e9f6e;
  --accent-dim: #a7e8cd;
  --enemy: #d64545;
  --ally: #0e9f6e;
  --gold: #b7791f;
  --radius: 12px;
  --shadow: 0 10px 34px rgb(15 23 42 / 10%);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

body { min-height: 100vh; display: flex; flex-direction: column; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

button, input, select { font: inherit; color: inherit; }

.muted { color: var(--muted); font-size: 12px; }

.glow {
  position: fixed;
  inset: -20% -10% auto;
  height: 420px;
  background: radial-gradient(60% 60% at 50% 0%, rgb(14 159 110 / 7%), transparent 70%);
  pointer-events: none;
  z-index: 0;
}

/* ---------- 顶栏 ---------- */

.top {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 20px;
  background: rgb(255 255 255 / 90%);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: baseline; gap: 6px; }
.brand-mark { font-weight: 800; letter-spacing: .02em; color: var(--accent); font-size: 20px; }
.brand-name { font-weight: 700; font-size: 17px; }

.tabs { display: flex; gap: 4px; padding: 3px; background: var(--bg-soft); border: 1px solid var(--line); border-radius: 10px; }
.tab {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 6px 14px;
  border-radius: 7px;
  cursor: pointer;
  font-weight: 600;
}
.tab:hover { color: var(--text); }
.tab.is-on { background: var(--card); color: var(--text); box-shadow: 0 1px 3px rgb(15 23 42 / 8%), inset 0 0 0 1px var(--line); }

.controls { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.ctl { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
.ctl select {
  background: var(--card);
  border: 1px solid var(--line-2);
  border-radius: 8px;
  padding: 6px 8px;
  color: var(--text);
  outline: none;
}
.ctl select:focus { border-color: var(--accent); }

.ghost {
  background: var(--card);
  border: 1px solid var(--line-2);
  border-radius: 8px;
  padding: 6px 12px;
  color: var(--muted);
  cursor: pointer;
}
.ghost:hover { color: var(--text); border-color: var(--dim); }

.primary {
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 9px;
  padding: 9px 22px;
  font-weight: 700;
  cursor: pointer;
}
.primary:hover { filter: brightness(1.06); }
.primary:active { transform: translateY(1px); }

/* ---------- 主体 ---------- */

main { flex: 1; width: 100%; max-width: 1180px; margin: 0 auto; padding: 18px 20px 8px; position: relative; z-index: 1; }

.view { display: none; }
.view.is-on { display: block; }

/* ---------- 输入区 ---------- */

.bp-input {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 14px;
  box-shadow: 0 1px 2px rgb(15 23 42 / 4%);
}

.input-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 10px; }
.input-head h2 { margin: 0; font-size: 15px; }

.enemy-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  max-width: 500px;
}

.slot {
  position: relative;
  aspect-ratio: 1;
  border: 1px dashed var(--line-2);
  border-radius: 10px;
  background: var(--bg-soft);
  cursor: pointer;
  padding: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--dim);
  transition: border-color .15s, background .15s;
}
.slot:hover { border-color: var(--accent); background: var(--card-2); }
.enemy-row .slot::after {
  content: attr(data-pos);
  position: absolute;
  top: 3px;
  left: 5px;
  font-size: 10px;
  line-height: 16px;
  padding: 0 4px;
  color: #334155;
  background: rgb(255 255 255 / 82%);
  border-radius: 4px;
  pointer-events: none;
}
.slot .plus { font-size: 20px; font-weight: 300; }
.slot img { width: 100%; height: 100%; object-fit: cover; display: block; }
.slot .slot-name {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 10px 4px 3px;
  font-size: 11px;
  text-align: center;
  color: #fff;
  background: linear-gradient(transparent, rgb(0 0 0 / 72%));
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.query-row { display: flex; align-items: center; gap: 18px; margin-top: 14px; flex-wrap: wrap; }
.pos-pick { display: flex; align-items: center; gap: 8px; }
.pos-btns { display: flex; gap: 4px; }
.pos-btns button {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--line-2);
  background: var(--card);
  color: var(--muted);
  cursor: pointer;
  font-variant-numeric: tabular-nums;
}
.pos-btns button:hover { color: var(--text); border-color: var(--dim); }
.pos-btns button.is-on { border-color: var(--accent); color: var(--accent); background: rgb(14 159 110 / 8%); font-weight: 700; }

#query-btn { margin-left: auto; }
#query-hint { font-size: 12px; }

/* ---------- 推荐 ---------- */

.rec-panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px 14px;
  min-height: 320px;
  box-shadow: 0 1px 2px rgb(15 23 42 / 4%);
}
.rec-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.rec-head h2 { margin: 0; font-size: 15px; }
.rec-note { color: var(--dim); font-size: 12px; margin-right: auto; }

.sort-tabs { display: flex; gap: 4px; }
.mini {
  border: 1px solid var(--line-2);
  background: var(--card);
  color: var(--muted);
  border-radius: 7px;
  padding: 3px 9px;
  font-size: 12px;
  cursor: pointer;
}
.mini:hover { color: var(--text); }
.mini.is-on { color: var(--accent); border-color: var(--accent); background: rgb(14 159 110 / 7%); font-weight: 600; }

.rec-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }

.rec {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  gap: 9px;
  align-items: center;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
}
.rec:hover { border-color: var(--accent); box-shadow: 0 2px 10px rgb(14 159 110 / 10%); }
.rec img { width: 36px; height: 36px; border-radius: 7px; object-fit: cover; display: block; }
.rec-main { min-width: 0; }
.rec-title { display: flex; align-items: baseline; gap: 8px; }
.rec-title h3 { margin: 0; font-size: 14px; }
.rec-pos { color: var(--dim); font-size: 11px; }
.rec-reasons { margin: 2px 0 0; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 4px; }
.rec-reasons li {
  font-size: 11px;
  color: var(--muted);
  background: var(--bg-soft);
  border-radius: 5px;
  padding: 1px 6px;
  white-space: nowrap;
}
.rec-reasons li.good { color: var(--accent); background: rgb(14 159 110 / 8%); }
.rec-score { text-align: right; }
.rec-score b { font-size: 18px; font-variant-numeric: tabular-nums; }
.rec-score span { display: block; font-size: 10px; color: var(--dim); }

.rec-empty { color: var(--dim); text-align: center; padding: 48px 10px; }

/* ---------- 查英雄 ---------- */

#view-hero.is-on { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 16px; align-items: start; }

.hero-side { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; }
.hero-search input {
  width: 100%;
  background: var(--bg-soft);
  border: 1px solid var(--line-2);
  border-radius: 8px;
  padding: 8px 10px;
  outline: none;
}
.hero-search input:focus { border-color: var(--accent); }

.hero-grid {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 5px;
  max-height: calc(100vh - 220px);
  overflow-y: auto;
  padding-right: 2px;
}
.hero-cell {
  border: 1px solid transparent;
  background: transparent;
  border-radius: 7px;
  padding: 2px;
  cursor: pointer;
  text-align: center;
}
.hero-cell img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 6px; display: block; }
.hero-cell span { display: block; font-size: 9px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hero-cell:hover { background: var(--card-2); }
.hero-cell.is-on { background: var(--card-2); border-color: var(--accent); }

.hero-detail { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; min-height: 420px; }
.hero-detail .placeholder { color: var(--dim); text-align: center; padding: 80px 10px; }

.hd-head { display: flex; gap: 14px; align-items: center; margin-bottom: 16px; }
.hd-head img { width: 60px; height: 60px; border-radius: 9px; object-fit: cover; }
.hd-head h2 { margin: 0; font-size: 21px; }
.hd-meta { color: var(--muted); font-size: 12px; margin-top: 2px; }

.hd-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 16px; }
.hd-stat { background: var(--bg-soft); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.hd-stat b { display: block; font-size: 17px; font-variant-numeric: tabular-nums; }
.hd-stat span { font-size: 11px; color: var(--dim); }

.hd-pos { margin-bottom: 16px; }
.hd-pos-row { display: flex; align-items: center; gap: 8px; margin-top: 5px; font-size: 12px; color: var(--muted); }
.hd-pos-row .track { flex: 1; height: 6px; background: var(--bg-soft); border-radius: 3px; overflow: hidden; }
.hd-pos-row .track i { display: block; height: 100%; background: var(--accent); }
.hd-pos-row b { width: 70px; text-align: right; font-variant-numeric: tabular-nums; color: var(--text); font-weight: 500; }

.hd-cols { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.hd-col h3 { margin: 0 0 6px; font-size: 13px; color: var(--muted); }
.hd-col.enemy h3 { color: var(--enemy); }
.hd-col.ally h3 { color: var(--accent); }
.hd-row { display: grid; grid-template-columns: 24px minmax(0, 1fr) auto; gap: 6px; align-items: center; padding: 3px 0; font-size: 12px; }
.hd-row img { width: 24px; height: 24px; border-radius: 5px; object-fit: cover; }
.hd-row .nm { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hd-row .val { font-variant-numeric: tabular-nums; color: var(--muted); }
.hd-row .val.good { color: var(--accent); }
.hd-row .val.bad { color: var(--enemy); }

/* ---------- 选择器 ---------- */

.picker {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgb(15 23 42 / 42%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.picker[hidden] { display: none; }
.picker-box {
  width: min(760px, 100%);
  max-height: 82vh;
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--line-2);
  border-radius: 14px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.picker-head { display: flex; gap: 10px; padding: 12px; border-bottom: 1px solid var(--line); }
.picker-head input {
  flex: 1;
  background: var(--bg-soft);
  border: 1px solid var(--line-2);
  border-radius: 8px;
  padding: 8px 10px;
  outline: none;
}
.picker-head input:focus { border-color: var(--accent); }
.picker-grid {
  padding: 12px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  gap: 6px;
  overflow-y: auto;
}
.picker-cell {
  border: 1px solid transparent;
  background: transparent;
  border-radius: 8px;
  padding: 2px;
  cursor: pointer;
}
.picker-cell img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 6px; display: block; }
.picker-cell span { display: block; font-size: 10px; color: var(--muted); text-align: center; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.picker-cell:hover { background: var(--card-2); }
.picker-cell:disabled { opacity: .3; cursor: not-allowed; }

/* ---------- 页脚 / 加载 ---------- */

.foot {
  max-width: 1180px;
  margin: 0 auto;
  padding: 14px 20px 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  justify-content: space-between;
  color: var(--dim);
  font-size: 12px;
}
.foot b { color: var(--muted); font-weight: 600; }

.loading {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
}
.loading[hidden] { display: none; }
.loading-inner { text-align: center; color: var(--muted); }
.spinner {
  display: inline-block;
  width: 26px;
  height: 26px;
  border: 2px solid var(--line-2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 响应式 ---------- */

@media (max-width: 820px) {
  .rec-list { grid-template-columns: 1fr; }
  #view-hero.is-on { grid-template-columns: 1fr; }
  .hero-grid { max-height: 300px; grid-template-columns: repeat(6, 1fr); }
  .hd-cols { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  .top { flex-wrap: wrap; gap: 8px; padding: 8px 12px; }
  .controls { margin-left: 0; width: 100%; }
  main { padding: 12px; }
  .enemy-row { max-width: none; }
  #query-btn { margin-left: 0; width: 100%; }
  .hd-stats { grid-template-columns: repeat(2, 1fr); }
}
