:root {
  --bg: #eef1f5;
  --panel: #ffffff;
  --ink: #18202b;
  --muted: #6b7686;
  --line: #d6dce5;
  --accent: #2f6fdf;
  --accent-soft: #dde8fb;
  --ok: #1f8a5b;
  --ok-soft: #daf1e6;
  --warn: #b5590a;
  --warn-soft: #fbe8d4;
  --red: #c4302b;
  --chip: #e8ecf2;
  --die0: #c9d1dc;
  --die1: #7fa7e8;
  --die2: #2f6fdf;
  --radius: 10px;
  --nav-h: 52px;
  font-size: 15px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1218;
    --panel: #171d26;
    --ink: #e4e9f0;
    --muted: #8a95a6;
    --line: #2a3340;
    --accent: #6ea2ff;
    --accent-soft: #1d2b44;
    --ok: #5fd19b;
    --ok-soft: #173327;
    --warn: #f0a050;
    --warn-soft: #3b2a17;
    --red: #ff6b5e;
    --chip: #222a35;
    --die0: #39424f;
    --die1: #3f6db5;
    --die2: #6ea2ff;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: "Noto Sans SC", "Microsoft YaHei", "PingFang SC", sans-serif;
  line-height: 1.5;
  padding-bottom: calc(var(--nav-h) + 12px + env(safe-area-inset-bottom));
}
body.has-dock { padding-bottom: calc(var(--nav-h) + 150px + env(safe-area-inset-bottom)); }
button, select, input, textarea { font: inherit; color: inherit; }
button {
  border: 1px solid var(--line); background: var(--panel); border-radius: 7px;
  padding: 5px 11px; cursor: pointer; min-height: 32px; touch-action: manipulation;
}
button:hover { border-color: var(--accent); }
button:disabled { opacity: .4; cursor: default; border-color: var(--line); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.danger { color: var(--red); }
button.ghost { background: transparent; }
button.small { padding: 2px 8px; font-size: 13px; min-height: 28px; }
select, input[type=text], input[type=number], input[type=search], textarea {
  border: 1px solid var(--line); background: var(--panel); border-radius: 7px; padding: 4px 6px;
  max-width: 100%; min-height: 32px;
}
textarea { width: 100%; resize: vertical; }
input[type=number] { width: 72px; }
input.tiny { width: 52px; }
.grow { flex: 1; min-width: 120px; }

/* 顶栏与导航 */
#top {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  padding: 8px 12px; background: var(--panel); border-bottom: 1px solid var(--line);
}
#top .brand { font-weight: 700; letter-spacing: .05em; margin-right: 4px; }
#top select { max-width: 40vw; }
.top-btns { display: flex; gap: 4px; flex-wrap: wrap; }
#nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; background: var(--panel); border-top: 1px solid var(--line);
  height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
}
#nav button { flex: 1; border: 0; border-radius: 0; background: transparent; font-size: 15px; color: var(--muted); }
#nav button.on { color: var(--accent); font-weight: 700; box-shadow: inset 0 3px 0 var(--accent); }
@media (min-width: 900px) {
  body { padding-bottom: 16px; }
  body.has-dock { padding-bottom: 170px; }
  #nav { position: sticky; top: 0; bottom: auto; height: auto; padding: 0 12px; border-top: 0; border-bottom: 1px solid var(--line); }
  #nav button { flex: 0 0 auto; padding: 10px 22px; }
  #nav button.on { box-shadow: inset 0 -3px 0 var(--accent); }
}

#main { padding: 10px; max-width: 1280px; margin: 0 auto; }
.grid2 { display: grid; gap: 10px; grid-template-columns: 1fr; align-items: start; }
@media (min-width: 900px) { .grid2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
.grid2 > div { min-width: 0; }

.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px 12px; margin-bottom: 10px;
}
.card h3 { margin: 0 0 6px; font-size: 16px; }
details.card > summary { cursor: pointer; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; list-style: none; }
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary::before { content: '▸'; color: var(--muted); }
details.card[open] > summary::before { content: '▾'; }
details > summary { cursor: pointer; }
.row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 4px 0; }
.spacer { flex: 1; }
.small { font-size: 13px; }
.muted { color: var(--muted); }
.warn-text { color: var(--warn); }
.block { display: block; margin: 4px 0; }
.block select, .block input[type=text] { width: 100%; }
.form { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0; }
.form label { display: flex; flex-direction: column; font-size: 13px; color: var(--muted); }
.form label > * { color: var(--ink); }
.two { display: grid; grid-template-columns: 1fr; gap: 0 10px; }
@media (min-width: 560px) { .two { grid-template-columns: 1fr 1fr; } }
.chk { display: inline-flex; align-items: center; gap: 3px; font-size: 13px; }
.chks { display: flex; flex-wrap: wrap; gap: 4px 12px; margin: 4px 0; }

.tag {
  display: inline-block; font-size: 12px; padding: 0 6px; border-radius: 10px;
  background: var(--chip); color: var(--muted); margin-right: 3px; white-space: nowrap;
}
.tag.act { background: var(--accent-soft); color: var(--accent); }
.tag.cost { background: var(--warn-soft); color: var(--warn); }
.tag.ok, .tag.on { background: var(--ok-soft); color: var(--ok); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.sub { background: var(--accent-soft); color: var(--accent); }

.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 6px; margin: 6px 0; }
.stats > div { background: var(--chip); border-radius: 8px; padding: 4px 8px; display: flex; flex-direction: column; }
.stats span { font-size: 12px; color: var(--muted); }
.stats b { font-size: 18px; }
.stats .bad b { color: var(--red); }
.issues { margin: 6px 0 0; padding-left: 18px; color: var(--warn); font-size: 13px; }
.lic, .mats { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; align-items: flex-end; }
.mini { display: flex; flex-direction: column; font-size: 12px; color: var(--muted); }
.mini input { width: 70px; }
table.ledger { width: 100%; border-collapse: collapse; font-size: 13px; }
table.ledger td { border-bottom: 1px solid var(--line); padding: 3px 4px; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }

/* 训练 */
.class .cname { font-weight: 700; }
.pips { display: flex; gap: 3px; margin: 6px 0; flex-wrap: wrap; }
.pips button { width: 30px; min-height: 30px; padding: 0; font-size: 13px; }
.pips button.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.levels { display: flex; flex-direction: column; gap: 2px; }
.lvrow { padding: 3px 6px; border-radius: 6px; font-size: 13px; color: var(--muted); }
.lvrow.owned { background: var(--accent-soft); color: var(--ink); }
.lvrow > summary { list-style: none; }
.lvrow > summary::-webkit-details-marker { display: none; }
.lvno { display: inline-block; width: 20px; color: var(--muted); font-variant-numeric: tabular-nums; }
.lvrow .desc { padding: 2px 0 2px 20px; }
select.pick { max-width: 230px; font-size: 13px; min-height: 28px; }
.subtree { border-top: 1px dashed var(--line); margin-top: 8px; padding-top: 6px; }
.desc { font-size: 13px; color: var(--ink); opacity: .88; }
.desc.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; cursor: pointer; }
.skill { margin: 4px 0; font-size: 13px; }
.artcat { margin: 6px 0; }
.art { margin: 3px 0 3px 10px; }
.art select { max-width: 260px; }

/* 机库 */
.active-mech { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.mechsec { margin: 6px 0; }
.mechsec.locked { opacity: .5; }
.inv { margin: 4px 0; font-size: 13px; }
.chip { display: inline-flex; align-items: center; gap: 2px; background: var(--chip); border-radius: 12px; padding: 0 2px 0 8px; margin: 2px; }
.chip .x { border: 0; background: transparent; min-height: 22px; padding: 0 5px; color: var(--muted); }

/* 战斗 */
.last { background: var(--accent-soft); color: var(--accent); border-radius: 8px; padding: 4px 10px; margin-bottom: 8px; }
.meters { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.meter { display: flex; align-items: center; gap: 4px; }
.meter > span { font-size: 13px; color: var(--muted); min-width: 28px; }
.meter b { min-width: 46px; text-align: center; font-size: 18px; font-variant-numeric: tabular-nums; }
.meter b small, .counter small, .pts small { font-size: 12px; color: var(--muted); font-weight: 400; }
.shieldmode { margin-top: 4px; }
.result { background: var(--chip); border-radius: 8px; padding: 6px 8px; margin: 6px 0; font-size: 13px; }
.counter { display: inline-flex; align-items: center; gap: 3px; font-size: 13px; }
.counter b { min-width: 26px; text-align: center; }
.weapon { border-top: 1px solid var(--line); padding: 6px 0; }
.weapon:first-of-type { border-top: 0; }
/* 技能分类图标（game-icons.net） */
:root {
  --ic-melee: #d2552c; --ic-ranged: #2f74d0; --ic-magic: #7457d2; --ic-hack: #138a64; --ic-music: #c8467a;
  --ic-mech: #a8690f; --ic-shield: #2a86bd; --ic-gray: #5d6877; --ic-buff: #4a8519;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ic-melee: #e8794f; --ic-ranged: #5b9cf0; --ic-magic: #9b85f0; --ic-hack: #2fbf8f; --ic-music: #e46c98;
    --ic-mech: #d1922e; --ic-shield: #4fb0e0; --ic-gray: #7d8999; --ic-buff: #74ad3a;
  }
}
.ic-melee { --ic: var(--ic-melee); } .ic-ranged { --ic: var(--ic-ranged); }
.ic-spell, .ic-crystal, .ic-psi, .ic-pure { --ic: var(--ic-magic); }
.ic-hack { --ic: var(--ic-hack); } .ic-music { --ic: var(--ic-music); } .ic-mech { --ic: var(--ic-mech); }
.ic-shield { --ic: var(--ic-shield); } .ic-buff { --ic: var(--ic-buff); }
.ic-drone, .ic-gear, .ic-parry { --ic: var(--ic-gray); }
.gi { width: 1em; height: 1em; fill: currentColor; display: block; flex: none; }
.gib { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 26px; height: 26px; border-radius: 7px; background: var(--ic); color: #fff; }
.gib .gi { width: 20px; height: 20px; }
.gih { display: inline-flex; vertical-align: -0.18em; margin-right: 5px; color: var(--ic); }
.gih .gi { width: 1.2em; height: 1.2em; }
.tag .gih { margin-right: 3px; vertical-align: -0.2em; }
.tag .gih .gi { width: 1.1em; height: 1.1em; }
.ability.unavail .gib, .ability.passive .gib { opacity: .55; }
.credits { text-align: center; margin: 14px 0 4px; }
.credits a { color: inherit; }
body.in-net .gib { box-shadow: 0 0 8px color-mix(in srgb, var(--ic) 55%, transparent); }

.ability { border-top: 1px solid var(--line); padding: 6px 0; }
.ability:first-of-type { border-top: 0; }
.ability.blocked > .row b { color: var(--muted); }
.ability.passive { opacity: .85; }
.ability.unavail { opacity: .55; }
.tags { margin: 2px 0; }
.segs { display: flex; gap: 4px; margin: 6px 0; }
.seg { flex: 1; text-align: center; border-radius: 6px; background: var(--chip); font-size: 13px; padding: 2px; }
.seg.cur { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.seg.done { background: var(--ok-soft); color: var(--ok); }
.param { display: block; border-top: 1px solid var(--line); padding: 6px 0; font-size: 13px; }
.param.blocked { opacity: .55; }
.rules { padding-left: 18px; margin: 6px 0; }

/* 底部骰子栏 */
#dock:empty { display: none; }
.dock {
  position: fixed; left: 0; right: 0; z-index: 25;
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
  background: var(--panel); border-top: 2px solid var(--accent);
  padding: 6px 10px; box-shadow: 0 -4px 14px rgba(0, 0, 0, .12);
}
@media (min-width: 900px) { .dock { bottom: 0; } }
.dock .row { margin: 2px 0; max-width: 1280px; margin-left: auto; margin-right: auto; }
.dock.min { display: flex; align-items: center; gap: 10px; }
.pts { display: inline-flex; align-items: center; gap: 3px; font-size: 13px; }
.pts b { font-size: 20px; min-width: 28px; text-align: center; }
.acts { font-size: 13px; display: inline-flex; align-items: center; gap: 2px; }
.dot { width: 18px; height: 18px; min-height: 18px; padding: 0; border-radius: 50%; }
.dot.on { background: var(--accent); border-color: var(--accent); }
.dice { gap: 4px; }
.die { width: 32px; min-height: 32px; padding: 0; font-weight: 700; border-radius: 7px; }
.die.d0 { background: var(--die0); }
.die.d1 { background: var(--die1); color: #fff; }
.die.d2 { background: var(--die2); color: #fff; }

/* 资料 */
.libitem { margin-bottom: 6px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 10px; }
.libitem[open] { padding-bottom: 10px; }
.libitem > summary { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
#flash {
  position: fixed; left: 50%; top: 12px; transform: translateX(-50%) translateY(-80px);
  background: var(--ink); color: var(--bg); padding: 6px 14px; border-radius: 18px; z-index: 50;
  transition: transform .2s; font-size: 14px; pointer-events: none;
}
#flash.show { transform: translateX(-50%) translateY(0); }

/* 网络世界：沉浸式黑客面板 */
.netphase { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.body-title { margin: 4px 2px 6px; font-size: 13px; color: var(--muted); font-weight: 400; letter-spacing: .1em; }
body.in-net {
  --bg: #04110f;
  --panel: rgba(6, 28, 25, .92);
  --ink: #c9fff1;
  --muted: #5fa597;
  --line: #11473f;
  --accent: #19e6b5;
  --accent-soft: #0b3a33;
  --chip: #0b2723;
  --die0: #0f3b35;
  --die1: #128a73;
  --die2: #19e6b5;
  background-color: var(--bg);
  background-image:
    linear-gradient(rgba(25, 230, 181, .06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(25, 230, 181, .06) 1px, transparent 1px);
  background-size: 28px 28px;
}
body.in-net .card { box-shadow: 0 0 0 1px rgba(25, 230, 181, .08), 0 0 18px rgba(25, 230, 181, .06); }
body.in-net button.primary { color: #02201a; }
body.in-net #top, body.in-net #nav { background: #061a17; }
body.in-net h3 { text-shadow: 0 0 8px rgba(25, 230, 181, .45); }

#main.warp-in { animation: warp-in .55s cubic-bezier(.2, .8, .2, 1); transform-origin: 50% 30%; }
#main.warp-out { animation: warp-out .55s cubic-bezier(.2, .8, .2, 1); transform-origin: 50% 30%; }
@keyframes warp-in {
  0% { transform: scale(.55); opacity: 0; filter: blur(6px) hue-rotate(60deg); }
  60% { opacity: 1; filter: blur(0); }
  100% { transform: scale(1); }
}
@keyframes warp-out {
  0% { transform: scale(1.5); opacity: 0; filter: blur(6px); }
  60% { opacity: 1; filter: blur(0); }
  100% { transform: scale(1); }
}
#warp {
  position: fixed; inset: 0; z-index: 60; pointer-events: none; opacity: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; letter-spacing: .5em; font-weight: 700; color: #19e6b5;
  text-shadow: 0 0 12px #19e6b5;
  background: radial-gradient(circle at 50% 40%, rgba(25, 230, 181, .35), rgba(2, 16, 14, .92) 70%);
}
#warp.warp-in { animation: warp-flash-in .7s ease-out; }
#warp.warp-out { animation: warp-flash-out .6s ease-out; }
@keyframes warp-flash-in {
  0% { opacity: 0; transform: scale(1.6); }
  25% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(.4); }
}
@keyframes warp-flash-out {
  0% { opacity: 0; transform: scale(.4); }
  25% { opacity: .9; }
  100% { opacity: 0; transform: scale(1.8); }
}
@media (prefers-reduced-motion: reduce) {
  #main.warp-in, #main.warp-out, #warp.warp-in, #warp.warp-out { animation-duration: .01s; }
}

/* 已完成的乐曲：保留显示效果 */
.songdone { border: 1px dashed var(--ok); border-radius: 8px; padding: 4px 8px; margin: 4px 0 8px; }
/* 手机上 6 个页面按钮 */
@media (max-width: 899px) { #nav button { font-size: 13px; padding: 0 2px; } }

/* 武器选用与射击次数 */
.weapon.selected { box-shadow: inset 3px 0 0 var(--accent); padding-left: 8px; }
.wchips { gap: 4px; }
.wchip { min-height: 28px; padding: 2px 8px; font-size: 13px; }
.wchip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.wchip small { opacity: .8; }
.shotline { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; font-size: 13px; background: var(--chip); border-radius: 6px; padding: 2px 6px; margin: 3px 0; }

/* 增益后的数值 */
.fxline { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-size: 13px; margin: 3px 0; }
.fxline s { color: var(--muted); }
.fxline b { color: var(--accent); }
.togs { flex-basis: 100%; }
.togs .tog { display: flex; margin: 2px 0 2px 8px; }
.tog { font-size: 12px; color: var(--muted); }

/* 攻击方向与招架 */
.dirbtn { min-width: 34px; min-height: 28px; padding: 0 6px; font-size: 16px; }
.dirbtn.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.guard { display: inline-flex; align-items: center; gap: 2px; background: var(--ok-soft); color: var(--ok); border-radius: 12px; padding: 1px 4px 1px 8px; font-size: 13px; font-weight: 700; }
.guard small { font-weight: 400; }
.guard .x { border: 0; background: transparent; min-height: 20px; padding: 0 4px; color: var(--ok); }
