:root {
  --bg: #0e1116;
  --surface: #161b22;
  --surface-2: #1c232c;
  --border: #2a323d;
  --text: #e6edf3;
  --muted: #9aa7b4;
  --accent: #f5a623;
  --accent-2: #4cc2ff;
  --green: #3fb950;
  --red: #f85149;
  --radius: 12px;
  --maxw: 920px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

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

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand { font-weight: 800; font-size: 20px; letter-spacing: .5px; }
.brand .dot { color: var(--accent); }
.nav { margin-left: auto; display: flex; gap: 14px; flex-wrap: wrap; }
.nav a { color: var(--muted); font-size: 14px; }
.nav a:hover, .nav a.active { color: var(--text); }

.container { max-width: var(--maxw); margin: 0 auto; padding: 28px 20px 64px; }

.hero {
  text-align: center;
  padding: 40px 16px 28px;
}
.hero h1 { font-size: 30px; margin: 0 0 8px; }
.hero p { color: var(--muted); margin: 0 0 24px; }

.search {
  display: flex;
  gap: 8px;
  max-width: 560px;
  margin: 0 auto;
}
.search input {
  flex: 1;
  padding: 14px 16px;
  font-size: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  outline: none;
}
.search input:focus { border-color: var(--accent); }

.quick { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 18px; }
.quick button {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 9px 16px;
  font-size: 14px;
  cursor: pointer;
}
.quick button:hover { border-color: var(--accent); }

.section-title { font-size: 22px; margin: 36px 0 14px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }

.card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}
.card:hover { border-color: var(--accent); text-decoration: none; }
.card h3 { margin: 0 0 6px; font-size: 16px; color: var(--text); }
.card p { margin: 0; color: var(--muted); font-size: 13px; }

/* search results */
#results { margin-top: 22px; }
#results:empty { display: none; }
.result-item {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
}
.result-item:hover { border-color: var(--accent); }
.result-item h3 { margin: 0 0 4px; }
.result-item .path { color: var(--muted); font-size: 12px; }

/* tables */
table { width: 100%; border-collapse: collapse; margin: 16px 0; font-size: 14px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; }
tr:hover td { background: var(--surface); }

.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge.ok { background: rgba(63,185,80,.15); color: var(--green); }
.badge.expired { background: rgba(248,81,73,.15); color: var(--red); }
.badge.fake { background: rgba(154,167,180,.15); color: var(--muted); }

/* forms / calculator */
.field { margin: 16px 0; }
label { display: block; font-size: 14px; color: var(--muted); margin-bottom: 6px; }
select, input[type="text"] {
  width: 100%;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 15px;
}
select:focus { border-color: var(--accent); }

.output {
  margin-top: 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: none;
}
.output.show { display: block; }
.output h3 { margin-top: 0; }
.output .row { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.output .row:last-child { border-bottom: none; }
.output .k { width: 160px; color: var(--muted); flex-shrink: 0; }
.output .v { color: var(--text); }

/* placeholder / TODO */
.placeholder {
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin: 16px 0;
  background: var(--surface);
}
.placeholder .tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .5px;
  color: var(--bg);
  background: var(--accent);
  padding: 2px 8px;
  border-radius: 6px;
  margin-bottom: 8px;
}
.placeholder p { margin: 0; color: var(--muted); font-size: 14px; }

.faq-item { border-bottom: 1px solid var(--border); padding: 14px 0; }
.faq-item h3 { margin: 0 0 6px; font-size: 16px; }
.faq-item p { margin: 0; color: var(--muted); }

footer { border-top: 1px solid var(--border); padding: 20px; color: var(--muted); font-size: 13px; text-align: center; }

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

/* ---------- 兑换码页（旗舰） ---------- */
.code-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 8px 0 14px; flex-wrap: wrap; }
.code-status { color: var(--muted); font-size: 13px; }
.toggle-btn {
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border);
  border-radius: 999px; padding: 7px 14px; font-size: 13px; cursor: pointer;
}
.toggle-btn:hover, .toggle-btn.active { border-color: var(--accent); }

.code-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.code-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.code-card.hidden-code { display: none; }
.code-list.show-inactive .code-card.hidden-code { display: block; }
.code-main { display: flex; align-items: center; gap: 10px; justify-content: space-between; }
.code-value {
  background: var(--surface-2); border: 1px dashed var(--accent); color: var(--accent);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 15px; font-weight: 700;
  padding: 8px 12px; border-radius: 8px; cursor: pointer; letter-spacing: .5px; max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.code-value:hover { background: rgba(245,166,35,.12); }
.code-reward { margin-top: 10px; color: var(--text); font-size: 14px; }
.code-meta { margin-top: 6px; color: var(--muted); font-size: 12px; }

/* toast 复制反馈 */
.toast {
  position: fixed; left: 50%; bottom: 32px; transform: translateX(-50%) translateY(20px);
  background: var(--accent); color: #1a1206; font-weight: 700; font-size: 14px;
  padding: 10px 18px; border-radius: 999px; opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s; z-index: 50;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- 首页今日速览（留存钩子） ---------- */
.today { margin: 4px 0 8px; }
.today-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.today-card {
  display: block; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; text-decoration: none;
}
.today-card:hover { border-color: var(--accent); text-decoration: none; }
.today-card.hot { border-color: var(--accent); background: linear-gradient(135deg, rgba(245,166,35,.10), var(--surface)); }
.today-num { font-size: 26px; font-weight: 800; color: var(--text); }
.today-card.hot .today-num { color: var(--accent); }
.today-label { margin-top: 6px; color: var(--muted); font-size: 13px; line-height: 1.5; }

/* ---------- 配装计算器分享按钮 ---------- */
.share-btn {
  margin-top: 16px;
  background: var(--accent); color: #1a1206; border: none;
  border-radius: var(--radius); padding: 11px 18px; font-size: 14px; font-weight: 700;
  cursor: pointer;
}
.share-btn:hover { filter: brightness(1.08); }

/* ---------- 我的配装（本地存档） ---------- */
.output-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.save-btn {
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 11px 18px; font-size: 14px; font-weight: 700; cursor: pointer;
}
.save-btn:hover { border-color: var(--accent); }

.my-builds-section { margin-top: 36px; }
.my-builds { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.build-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px;
}
.build-name { font-size: 14px; color: var(--text); }
.build-actions { display: flex; gap: 8px; flex-shrink: 0; }
.build-actions button {
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border);
  border-radius: 999px; padding: 6px 12px; font-size: 13px; cursor: pointer;
}
.build-load:hover { border-color: var(--accent); color: var(--accent); }
.build-del:hover { border-color: var(--red); color: var(--red); }

/* ---------- 今日作战台（streak + 倒计时） ---------- */
.battle-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.battle-head .section-title { margin: 4px 0 0; }
.streak { text-align: right; }
.streak-dots { display: flex; gap: 6px; justify-content: flex-end; }
.dot-day { width: 11px; height: 11px; border-radius: 50%; border: 1px solid var(--border); background: transparent; }
.dot-day.on { background: var(--accent); border-color: var(--accent); }
.streak-label { margin-top: 6px; color: var(--muted); font-size: 12px; }

.today-countdown { margin-top: 8px; color: var(--accent); font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; }
.today-countdown.expired { color: var(--red); }
.today-sub { margin-top: 2px; color: var(--muted); font-size: 12px; }

/* ---------- 声骸声纳 ---------- */
.sonar-wrap { max-width: 440px; margin: 8px auto 0; }
.sonar { position: relative; width: 100%; max-width: 360px; aspect-ratio: 1 / 1; margin: 8px auto 0; }
.sonar-ring {
  position: absolute; left: 50%; top: 50%; width: 70%; height: 70%;
  transform: translate(-50%, -50%); border: 1px solid var(--border); border-radius: 50%;
  animation: sonar-pulse 3s ease-out infinite;
}
.sonar-ring.ring2 { width: 92%; height: 92%; animation-delay: 1.5s; }
@keyframes sonar-pulse {
  0%   { transform: translate(-50%, -50%) scale(.6); opacity: .55; }
  100% { transform: translate(-50%, -50%) scale(1);  opacity: 0; }
}
.sonar-core {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 92px; height: 92px; border-radius: 50%; line-height: 1.3;
  background: var(--surface); border: 1px solid var(--accent); color: var(--accent);
  font-size: 13px; font-weight: 700; cursor: pointer; z-index: 3; text-align: center;
}
.sonar-core:hover { background: rgba(245,166,35,.12); }
.sonar-nodes { position: absolute; inset: 0; }
.sonar-node {
  position: absolute; transform: translate(-50%, -50%);
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  border-radius: 999px; padding: 6px 10px; font-size: 12px; cursor: pointer;
  transition: opacity .2s, border-color .2s, background .2s, color .2s; white-space: nowrap;
}
.sonar-node.dim { opacity: .25; filter: grayscale(1); }
.sonar-node.match { border-color: var(--accent); }
.sonar-node.selected { background: var(--accent); color: #1a1206; border-color: var(--accent); }

.sonar-controls { margin-top: 18px; }
.sonar-filter { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.sonar-filter button {
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border);
  border-radius: 999px; padding: 7px 14px; font-size: 13px; cursor: pointer;
}
.sonar-filter button:hover { border-color: var(--accent); }
.sonar-filter button.active { background: var(--accent); color: #1a1206; border-color: var(--accent); }

.sonar-detail {
  margin-top: 16px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; display: none;
}
.sonar-detail.show { display: block; }
.sonar-detail .detail-head { font-size: 16px; font-weight: 700; color: var(--text); margin-bottom: 8px; }
.sonar-detail .row { display: flex; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.sonar-detail .row:last-child { border-bottom: none; }
.sonar-detail .k { width: 96px; color: var(--muted); flex-shrink: 0; }
.sonar-detail .v { color: var(--text); }

.sonar-table-toggle { margin-top: 22px; }
.sonar-table-toggle summary { cursor: pointer; color: var(--accent-2); font-size: 14px; }

/* 兑换码红点（导航） */
.nav a { position: relative; }
.reddot {
  position: absolute; top: -7px; right: -11px; min-width: 16px; height: 16px; padding: 0 4px;
  background: var(--red); color: #fff; font-size: 10px; font-weight: 700;
  border-radius: 999px; display: flex; align-items: center; justify-content: center;
  line-height: 1; pointer-events: none;
}

/* 兑换码「标记已兑换」 */
.code-used {
  margin-top: 10px; background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 999px; padding: 5px 12px; font-size: 12px; cursor: pointer;
}
.code-used:hover { border-color: var(--accent); }
.code-used.on { background: rgba(63,185,80,.15); color: var(--green); border-color: var(--green); }

/* 今日作战台 · 账号 / 云端 */
.streak-account { margin-top: 8px; display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.acct-btn {
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--border);
  border-radius: 999px; padding: 4px 10px; font-size: 12px; cursor: pointer;
}
.acct-btn:hover { border-color: var(--accent); color: var(--accent); }

/* 声骸声纳 · 稀有度配色 + 掉率光晕 */
.sonar-node.rarity-legend { border-color: #f5a623; }
.sonar-node.rarity-rare { border-color: #b37feb; }
.sonar-node.selected {
  background: var(--accent); color: #1a1206; border-color: var(--accent);
  box-shadow: 0 0 16px rgba(245,166,35,.5) !important;
}
.sonar-legend {
  display: flex; gap: 14px; flex-wrap: wrap; align-items: center;
  margin-top: 14px; font-size: 12px; color: var(--muted);
}
.sonar-legend .lg-item { display: inline-flex; align-items: center; gap: 6px; }
.sonar-legend .lg { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.sonar-legend .lg-legend { background: #f5a623; }
.sonar-legend .lg-rare { background: #b37feb; }
.sonar-legend .lg-note { color: var(--muted); }

/* ---------- 移动端适配 ---------- */
@media (max-width: 640px) {
  .topbar {
    padding: 10px 12px;
    gap: 8px;
  }
  .brand { font-size: 18px; }
  .nav {
    margin-left: auto;
    gap: 10px;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    max-width: calc(100% - 94px);
  }
  .nav::-webkit-scrollbar { display: none; }
  .nav a { white-space: nowrap; font-size: 13px; }

  .container { padding: 20px 14px 40px; }
  .hero { padding: 28px 10px 22px; }
  .hero h1 { font-size: 24px; }
  .section-title { font-size: 18px; margin: 28px 0 12px; }

  .output .row { flex-direction: column; gap: 2px; padding: 10px 0; }
  .output .k { width: auto; }

  .output-actions { flex-direction: column; }
  .output-actions .share-btn, .output-actions .save-btn { width: 100%; }

  .sonar { max-width: 300px; }
  .sonar-core { width: 78px; height: 78px; font-size: 12px; }
  .sonar-node { font-size: 11px; padding: 5px 8px; }
}
