:root {
  --bg: #0b1216;
  --bg2: #0f181d;
  --panel: #162129;
  --panel2: #1b2831;
  --line: #24343e;
  --line2: #2f4451;
  --text: #e6eef3;
  --dim: #8fa3af;
  --dim2: #62757f;
  --accent: #5ee0a0;
  --accent-dim: rgba(94, 224, 160, .12);
  --warn: #f0b429;
  --bad: #ff6b6b;
  --radius: 10px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: radial-gradient(1200px 600px at 50% -10%, #16242c 0%, var(--bg) 55%) fixed, var(--bg);
  color: var(--text);
  font: 14px/1.55 -apple-system, "Segoe UI", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #273941; border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: #33494f; }
::-webkit-scrollbar-track { background: transparent; }

.app { height: 100%; display: flex; flex-direction: column; }

/* ---------------- topbar ---------------- */
.topbar {
  height: 54px; flex: 0 0 54px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(22, 33, 41, .95), rgba(15, 24, 29, .85));
  backdrop-filter: blur(8px);
}
.brand { display: flex; align-items: baseline; gap: 8px; letter-spacing: .5px; }
.brand .logo {
  font-weight: 700; color: #0b1216; background: var(--accent);
  padding: 2px 8px; border-radius: 5px; font-size: 14px;
}
.brand .slash { color: var(--dim2); }
.brand strong { font-weight: 650; }
.brand .tag {
  font-size: 11px; color: var(--accent); border: 1px solid rgba(94, 224, 160, .35);
  border-radius: 4px; padding: 0 5px; margin-left: 2px;
}
.topmeta { color: var(--dim2); font-size: 12px; }
.topmeta b { color: var(--dim); font-weight: 600; }

/* ---------------- layout ---------------- */
.layout {
  flex: 1; min-height: 0;
  display: grid;
  grid-template-columns: 268px minmax(0, 1fr) 330px;
  gap: 0;
}
.side, .stats { min-height: 0; overflow-y: auto; }
.side { border-right: 1px solid var(--line); background: rgba(11, 18, 22, .5); }
.stats { border-left: 1px solid var(--line); background: rgba(11, 18, 22, .5); padding: 14px; }
.main { min-height: 0; overflow-y: auto; padding: 16px 18px 40px; }

/* ---------------- weapon list ---------------- */
.side-head { position: sticky; top: 0; z-index: 5; padding: 12px; background: linear-gradient(180deg, #0e171c 70%, rgba(14, 23, 28, 0)); }
.search {
  width: 100%; height: 34px; padding: 0 11px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  outline: none; color: var(--text);
}
.search::placeholder { color: var(--dim2); }
.search:focus { border-color: var(--line2); box-shadow: 0 0 0 3px rgba(94, 224, 160, .08); }
.cats { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.cat {
  border: 1px solid var(--line); background: transparent; color: var(--dim);
  border-radius: 999px; padding: 2px 10px; font-size: 12px;
}
.cat:hover { color: var(--text); border-color: var(--line2); }
.cat.on { color: #0b1216; background: var(--accent); border-color: var(--accent); font-weight: 600; }

.wlist { padding: 0 8px 16px; }
.witem {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 8px; border-radius: 8px; cursor: pointer;
  border: 1px solid transparent;
}
.witem:hover { background: var(--panel); }
.witem.on { background: var(--panel2); border-color: var(--line2); }
.witem img { width: 46px; height: 26px; object-fit: contain; flex: 0 0 auto; opacity: .9; }
.witem .wn { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.witem .wc { font-size: 11px; color: var(--dim2); }
.witem .dot { width: 4px; height: 4px; border-radius: 2px; background: var(--accent); flex: 0 0 auto; opacity: 0; }
.witem.on .dot { opacity: 1; }
.wempty { color: var(--dim2); padding: 18px 10px; font-size: 13px; }

/* ---------------- hero ---------------- */
.hero { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: linear-gradient(160deg, #182b34, #101a20 60%); }
.hero-empty { padding: 64px 0; text-align: center; color: var(--dim2); }
.hero-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; padding: 16px 18px 0; }
.hero-title { font-size: 22px; font-weight: 650; letter-spacing: .3px; }
.hero-meta { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 7px; }
.chip {
  font-size: 11.5px; color: var(--dim); border: 1px solid var(--line2);
  border-radius: 999px; padding: 1px 9px; background: rgba(255, 255, 255, .02);
}
.chip.warn { color: var(--warn); border-color: rgba(240, 180, 41, .35); }
.hero-img { display: block; width: 100%; max-width: 720px; height: 210px; object-fit: contain; margin: 4px auto 0; filter: drop-shadow(0 12px 28px rgba(0, 0, 0, .5)); }
.hero-img.none { height: 60px; opacity: .25; }
.hero-actions { display: flex; gap: 8px; }

/* ---------------- 3D 舞台（P3） ---------------- */
.stage-wrap {
  position: relative;
  height: 320px;
  background:
    radial-gradient(90% 90% at 50% 18%, rgba(43, 92, 122, .30), rgba(0, 0, 0, 0) 60%),
    linear-gradient(180deg, #0e1a21, #0a1218 70%, #080e13);
  overflow: hidden;
  cursor: grab;
}
.stage-wrap:active { cursor: grabbing; }
.stage-canvas { position: absolute; inset: 0; }
.stage-canvas canvas { display: block; width: 100%; height: 100%; }
.stage-labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.hs-label {
  position: absolute; left: 0; top: 0;
  pointer-events: none; cursor: pointer;
  opacity: 0;
  font-size: 12px; line-height: 1; white-space: nowrap;
  color: #bfe6ff;
  background: rgba(10, 25, 34, .78);
  border: 1px solid rgba(126, 214, 255, .35);
  border-radius: 999px;
  padding: 4px 10px;
  backdrop-filter: blur(3px);
  transition: border-color .15s, color .15s, background .15s, opacity .18s;
  will-change: transform;
}
.hs-label.show { opacity: 1; pointer-events: auto; }
.hs-label:hover { border-color: rgba(126, 214, 255, .9); color: #e6f6ff; background: rgba(20, 44, 58, .9); }
.hs-label.fill { color: #ffd79a; border-color: rgba(255, 183, 77, .55); background: rgba(38, 28, 10, .78); }
.hs-label.fill:hover { border-color: rgba(255, 183, 77, .95); }
.stage-bar {
  position: absolute; left: 12px; bottom: 10px;
  display: flex; align-items: center; gap: 7px;
  pointer-events: none;
}
.sbtn {
  pointer-events: auto;
  height: 26px; padding: 0 11px; font-size: 12px;
  color: var(--dim); background: rgba(10, 25, 34, .78);
  border: 1px solid var(--line2); border-radius: 999px;
  cursor: pointer; backdrop-filter: blur(3px);
  transition: color .15s, border-color .15s;
}
.sbtn:hover { color: var(--fg); border-color: var(--line2); }
.sbtn.on { color: #ffd79a; border-color: rgba(255, 183, 77, .55); }
.stage-tip { font-size: 11.5px; color: var(--dim2); margin-left: 4px; }
.stage-fallback { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; }
.stage-fallback[hidden] { display: none; }
.stage-fallback img { max-width: 86%; height: 230px; object-fit: contain; filter: drop-shadow(0 12px 28px rgba(0, 0, 0, .5)); }
.fallback-note { font-size: 12px; color: var(--dim2); }

/* ---------------- buttons ---------------- */
.btn {
  height: 32px; padding: 0 13px; border-radius: 7px;
  border: 1px solid var(--line2); background: var(--panel2); color: var(--text);
  font-size: 12.5px;
}
.btn:hover { border-color: #3c5765; background: #203139; }
.btn.primary { background: var(--accent); color: #08110d; border-color: var(--accent); font-weight: 650; }
.btn.primary:hover { filter: brightness(1.06); }
.ghost { height: 32px; padding: 0 12px; border-radius: 7px; border: 1px solid var(--line); background: transparent; color: var(--dim); font-size: 12.5px; }
.ghost:hover { color: var(--text); border-color: var(--line2); }
.icon-btn { width: 28px; height: 28px; border-radius: 6px; border: 1px solid var(--line); background: transparent; color: var(--dim); }
.icon-btn:hover { color: var(--text); border-color: var(--line2); }

/* ---------------- slots ---------------- */
.slots-head { display: flex; align-items: center; justify-content: space-between; margin: 18px 0 10px; }
.slots-head h2 { margin: 0; font-size: 13px; font-weight: 600; color: var(--dim); letter-spacing: 1px; }
.slots-head .hint { font-size: 12px; color: var(--dim2); }
.slot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(228px, 1fr)); gap: 10px; }
.slot {
  position: relative; border: 1px solid var(--line); border-radius: 9px;
  background: var(--panel); padding: 9px 10px; cursor: pointer; min-height: 62px;
  transition: border-color .15s, background .15s, transform .1s;
}
.slot:hover { border-color: var(--line2); background: var(--panel2); }
.slot:active { transform: translateY(1px); }
.slot.filled { border-color: #2c4a3f; background: linear-gradient(180deg, rgba(94, 224, 160, .07), rgba(15, 24, 29, .2)); }
.slot.unfit { opacity: .5; }
.slot-h { display: flex; align-items: center; justify-content: space-between; font-size: 11.5px; color: var(--dim2); letter-spacing: .6px; }
.slot-h .rm { border: 0; background: transparent; color: var(--dim2); font-size: 13px; padding: 0 2px; line-height: 1; }
.slot-h .rm:hover { color: var(--bad); }
.slot-body { display: flex; align-items: center; gap: 9px; margin-top: 4px; }
.slot-body img { width: 38px; height: 30px; object-fit: contain; flex: 0 0 auto; }
.pname { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.peff { font-size: 11px; color: var(--accent); margin-top: 1px; }
.peff .neg { color: #ff9b76; }
.slot .empty-txt { color: var(--dim2); font-size: 12.5px; margin-top: 6px; }
.slot .plus { color: var(--accent); margin-right: 4px; }

/* ---------------- stats ---------------- */
.stats-card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); overflow: hidden; }
.stats-card + .stats-card { margin-top: 12px; }
.stats-title { padding: 10px 13px; font-size: 12px; letter-spacing: 1.2px; color: var(--dim); border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; }
.stats-title span { color: var(--dim2); letter-spacing: 0; }
.srow { display: grid; grid-template-columns: 1fr 54px 66px 58px; align-items: center; gap: 4px; padding: 6px 13px; font-size: 12.5px; }
.srow + .srow { border-top: 1px solid rgba(36, 52, 62, .55); }
.srow .lab { color: var(--dim); }
.srow .base { text-align: right; color: var(--dim2); font-variant-numeric: tabular-nums; }
.srow .cur { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.srow .dlt { text-align: right; font-size: 11.5px; font-variant-numeric: tabular-nums; }
.srow .dlt.up { color: var(--accent); }
.srow .dlt.down { color: var(--bad); }
.srow .dlt.zero { color: var(--dim2); }
.srow.changed { background: rgba(94, 224, 160, .045); }
.srow.head { font-size: 11px; color: var(--dim2); padding-bottom: 2px; }
.srow.head .base, .srow.head .cur, .srow.head .dlt { font-weight: 400; }

.gauge { padding: 10px 13px; }
.gauge + .gauge { border-top: 1px solid rgba(36, 52, 62, .55); }
.gauge .gl { display: flex; justify-content: space-between; font-size: 12px; color: var(--dim); margin-bottom: 4px; }
.gauge .gs { color: var(--text); font-variant-numeric: tabular-nums; }
.bar { height: 5px; border-radius: 3px; background: #1e2c34; overflow: hidden; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, #2fa97a, var(--accent)); border-radius: 3px; transition: width .25s; }
.bar.b2 i { background: linear-gradient(90deg, #a97b2f, var(--warn)); }

.build-meta { padding: 10px 13px; font-size: 12px; color: var(--dim); }
.build-meta b { color: var(--text); font-weight: 600; }
.build-meta .note { color: var(--dim2); font-size: 11.5px; margin-top: 4px; }
.build-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 0 13px 13px; }
.build-actions .btn { width: 100%; }

/* ---------------- drawer ---------------- */
.drawer-mask {
  position: fixed; inset: 0; background: rgba(4, 8, 10, .55);
  opacity: 0; pointer-events: none; transition: opacity .18s; z-index: 20;
}
.drawer-mask.on { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(430px, 92vw);
  background: #101a20; border-left: 1px solid var(--line2);
  transform: translateX(102%); transition: transform .22s cubic-bezier(.4, 0, .2, 1);
  z-index: 21; display: flex; flex-direction: column;
  box-shadow: -20px 0 50px rgba(0, 0, 0, .45);
}
.drawer.on { transform: none; }
.drawer-head { display: flex; align-items: flex-start; justify-content: space-between; padding: 14px 16px 10px; border-bottom: 1px solid var(--line); }
.drawer-title { font-size: 15px; font-weight: 650; }
.drawer-sub { font-size: 11.5px; color: var(--dim2); margin-top: 2px; }
.drawer-tools { display: flex; gap: 8px; padding: 10px 16px; }
.drawer-tools .search { flex: 1; }
.plist { flex: 1; overflow-y: auto; padding: 0 10px 20px; }

.pcard {
  display: grid; grid-template-columns: 54px 1fr auto; gap: 10px; align-items: center;
  padding: 9px 10px; border: 1px solid transparent; border-radius: 9px; cursor: pointer;
}
.pcard:hover { background: var(--panel); border-color: var(--line); }
.pcard.on { background: rgba(94, 224, 160, .07); border-color: #2c4a3f; }
.pcard img { width: 54px; height: 38px; object-fit: contain; }
.pcard .pn { font-size: 13px; }
.pcard .pmeta { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 3px; }
.eff { font-size: 11px; padding: 0 6px; border-radius: 4px; background: rgba(94, 224, 160, .1); color: var(--accent); }
.eff.neg { background: rgba(255, 107, 107, .1); color: #ff9b76; }
.eff.cap { background: rgba(240, 180, 41, .12); color: var(--warn); }
.stars { font-size: 10.5px; color: var(--warn); letter-spacing: 1px; }
.padv { font-size: 11px; color: var(--dim2); margin-top: 3px; line-height: 1.4; }
.pick { font-size: 11.5px; color: var(--accent); border: 1px solid rgba(94, 224, 160, .3); background: transparent; border-radius: 6px; padding: 3px 9px; }
.pcard.on .pick { background: var(--accent); color: #08110d; border-color: var(--accent); }
.psect { padding: 10px 10px 4px; font-size: 11px; letter-spacing: 1px; color: var(--dim2); }

/* ---------------- toast ---------------- */
.toast {
  position: fixed; left: 50%; bottom: 34px; transform: translate(-50%, 12px);
  background: #1d2c35; border: 1px solid var(--line2); color: var(--text);
  padding: 8px 16px; border-radius: 8px; font-size: 13px;
  opacity: 0; pointer-events: none; transition: .2s; z-index: 40;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .4);
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }

/* ---------------- responsive ---------------- */
@media (max-width: 1180px) {
  .layout { grid-template-columns: 226px minmax(0, 1fr) 300px; }
  .hero-img { height: 170px; }
  .stage-wrap { height: 280px; }
}
@media (max-width: 920px) {
  .layout { grid-template-columns: 1fr; }
  .side { border-right: 0; border-bottom: 1px solid var(--line); max-height: 44vh; }
  .stats { border-left: 0; border-top: 1px solid var(--line); }
  .main { padding: 14px 12px 26px; }
  .hero-img { height: 150px; }
  .stage-wrap { height: 230px; }
  .stage-tip { display: none; }
  .srow { grid-template-columns: 1fr 46px 58px 52px; }
}
