:root {
  color-scheme: dark;
  --bg: #100e0c;
  --panel: #221c16;
  --panel-2: #2a231b;
  --line: rgba(214, 176, 106, 0.32);
  --gold: #f0d7a2;
  --gold-2: #c6a46a;
  --ink: #f6efe2;
  --muted: #b4a690;
  --faint: #7d7264;
  --seal: #e15d4c;
  --wei: #7eafd6;
  --shu: #86b56d;
  --wu: #d87a6a;
  --qun: #e0c36a;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
  --nav-h: calc(64px + env(safe-area-inset-bottom));
  font-family: "PingFang TC", "Noto Sans TC", "Heiti TC", "Microsoft JhengHei", "WenQuanYi Micro Hei", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background:
    radial-gradient(900px 380px at 0% -10%, rgba(150, 48, 34, 0.28), transparent 60%),
    radial-gradient(700px 320px at 100% 0%, rgba(150, 110, 40, 0.16), transparent 55%),
    var(--bg);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.45;
}
body.lock { overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--gold); text-decoration: none; }
h1, h2, h3, p { margin: 0; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

.shell { min-height: 100vh; }
.top {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: rgba(16, 14, 12, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}
.brand { display: flex; gap: 10px; align-items: center; }
.brand h1 { font-size: 20px; letter-spacing: 0.08em; font-weight: 650; }
.eyebrow { color: var(--gold-2); font-size: 12px; letter-spacing: 0.14em; }
.mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 1px solid var(--gold-2);
  border-radius: 12px;
  color: var(--gold);
  background: #2a2118;
  font-weight: 700;
}
.account-switch { display: flex; flex-direction: column; gap: 2px; font-size: 12px; color: var(--muted); }
.account-switch select, .search, .field, .sort-select, textarea {
  background: #16130f;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  min-height: 44px;
}
.account-switch select { min-width: 128px; }

.banner {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin: 12px 16px 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #2a2118;
  color: var(--gold);
  font-size: 14px;
}
main { padding: 16px 16px var(--nav-h); max-width: 1180px; margin: 0 auto; }
.page-head, .row-between { display: flex; justify-content: space-between; gap: 12px; align-items: flex-end; }
.page-head { margin-bottom: 14px; }
.page-head h2, .dialog h3, .sheet h3 { font-size: 26px; letter-spacing: 0.06em; }
.sub, .muted, .help { color: var(--muted); }
.faint { color: var(--faint); font-size: 13px; }

.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 25;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  background: rgba(18, 15, 12, 0.96);
  border-top: 1px solid var(--line);
}
.tabbar a {
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 12px;
  min-height: 48px;
  justify-content: center;
  border-radius: 10px;
}
.tabbar a[aria-current="page"] { color: var(--gold); background: rgba(198, 164, 106, 0.1); }
.tabbar svg { display: block; }

.btn, .btn-ghost, .check, .chip, .pip, .node, .branch, .slot-btn, .icon-btn {
  border: 1px solid var(--line);
  background: #1a1612;
  color: var(--ink);
  border-radius: 10px;
  min-height: 40px;
  padding: 8px 12px;
}
.btn.primary, .chip[aria-checked="true"], .pip.on, .check.on, .branch.on, .node.on, .slot-btn.current {
  background: #3c2f1d;
  color: var(--gold);
  border-color: var(--gold-2);
}
.btn-ghost { background: transparent; color: var(--muted); }
.btn-row, .chips, .entry-row { display: flex; flex-wrap: wrap; gap: 8px; }
.toolbar { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.search, textarea, .field { width: 100%; }
textarea { min-height: 180px; resize: vertical; }
textarea.notes { min-height: 84px; }
.team-card { display: block; color: inherit; }
.team-card-top { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.team-card-main { display: block; flex: 1; min-width: 0; color: inherit; text-decoration: none; }
.team-card > .btn { margin-top: 10px; }
.backup-grid { display: grid; gap: 12px; }

.layout { display: block; }
.filter-panel { display: none; }
.generals-page.filter-open .filter-panel {
  display: flex;
  flex-direction: column;
  position: fixed;
  z-index: 40;
  inset: 0;
  background: rgba(12, 10, 8, 0.96);
  padding: calc(12px + env(safe-area-inset-top)) 16px calc(16px + env(safe-area-inset-bottom));
}
.filter-card, .panel, .gcard, .trow, .team-card, .member, .help-card, .account-card, .dock, .sheet, .dialog {
  background: linear-gradient(180deg, rgba(255, 236, 206, 0.03), transparent 30%), var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}
.filter-card { padding: 12px; overflow: auto; }
.filter-row {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 8px;
  align-items: start;
  padding: 8px 0;
  border-bottom: 1px solid rgba(214, 176, 106, 0.14);
}
.filter-row span { color: var(--gold-2); font-size: 13px; padding-top: 8px; }
.chip { min-height: 36px; padding: 6px 10px; color: var(--muted); }
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}
.roster { display: flex; flex-direction: column; gap: 6px; }
.gcard { padding: 12px 12px 12px 16px; position: relative; overflow: hidden; }
.gcard.grow { padding: 0 6px 0 10px; border-radius: 12px; }
.grow-row {
  display: grid;
  grid-template-columns: auto auto max-content minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 6px;
  row-gap: 2px;
  min-height: 48px;
}
.gcard.grow .camp { grid-column: 1; grid-row: 1; font-size: 15px; }
.gcard.grow .cost { grid-column: 2; grid-row: 1; padding: 0 6px; font-size: 12px; line-height: 1.6; }
.grow-name {
  grid-column: 3;
  grid-row: 1;
  min-width: max-content;
  display: flex;
  align-items: center;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  min-height: 36px;
  border-radius: 0;
}
button.grow-name { cursor: pointer; }
.grow-name strong {
  white-space: nowrap;
  font-size: 16px;
  font-weight: 700;
}
.gcard.grow .apt-row {
  grid-column: 4;
  grid-row: 1;
  min-width: 0;
  overflow: hidden;
  flex-wrap: nowrap;
  margin: 0;
  gap: 1px;
}
.gcard.grow .apt {
  background: transparent;
  padding: 0;
  font-size: 11px;
  white-space: nowrap;
  flex: 0 0 auto;
}
.gcard.grow .check { grid-column: 5; grid-row: 1; }
.grow-chips {
  grid-column: 3 / 5;
  grid-row: 2;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  min-width: 0;
  padding-bottom: 4px;
}
.gcard.grow.has-chips .camp,
.gcard.grow.has-chips .cost,
.gcard.grow.has-chips .check { grid-row: 1 / span 2; }
.gcard.grow .mini { padding: 0 5px; font-size: 11px; }
.gcard.grow .stamp {
  transform: none;
  letter-spacing: 0;
  font-size: 11px;
  line-height: 1.4;
  padding: 0 3px;
}
.gcard.grow .check {
  flex: 0 0 auto;
  min-height: 36px;
  padding: 4px 6px;
  white-space: nowrap;
  gap: 4px;
}
.grow-more {
  padding: 2px 4px 10px 22px;
  border-top: 1px solid rgba(214, 176, 106, 0.14);
}
.grow-more .innate { margin-top: 8px; }
.gcard::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--camp, var(--gold-2));
}
.gcard.wei { --camp: var(--wei); }
.gcard.shu { --camp: var(--shu); }
.gcard.wu { --camp: var(--wu); }
.gcard.qun { --camp: var(--qun); }
.gcard header, .trow, .member-top { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.camp { font-weight: 700; }
.camp-ink.wei { color: var(--wei); }
.camp-ink.shu { color: var(--shu); }
.camp-ink.wu { color: var(--wu); }
.camp-ink.qun { color: var(--qun); }
.team-head { align-items: center; flex-wrap: wrap; }
.team-head .team-title { flex: 1 1 160px; min-width: 0; }
.team-tools { flex: 0 0 auto; flex-wrap: wrap; justify-content: flex-end; }
.template-filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 10px 0; }
.sheet.template-sheet {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0;
  height: min(86vh, 820px);
}
.template-sheet > .row-between { padding: 16px 16px 0; flex: 0 0 auto; }
.template-body { padding: 0 16px; flex: 0 0 auto; }
.template-results { overflow: auto; flex: 1; min-height: 0; padding: 0 16px 16px; }
.template-options { display: flex; flex-wrap: wrap; gap: 0 16px; }
.template-options .season-opt { margin: 8px 0; }
.template-list { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.template-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #16130f;
}
.template-item p { margin: 2px 0 0; color: var(--muted); font-size: 14px; }
.template-item .btn { flex: 0 0 auto; }
.template-item.blocked,
.help-card.blocked { opacity: 0.45; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.tag.alt-team,
.template-item .tag { margin-left: 6px; }
.team-notes { white-space: pre-wrap; }
.team-tools .btn,
.team-tools .btn-ghost { white-space: nowrap; }
.cost {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 8px;
  color: var(--gold);
  font-size: 13px;
}
.gcard h3, .member h3 { font-size: 20px; margin: 6px 0; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.stamp {
  border: 1px solid var(--seal);
  color: var(--seal);
  border-radius: 4px;
  padding: 0 5px;
  font-size: 12px;
  letter-spacing: 0.08em;
  transform: rotate(-6deg);
}
.apt-row { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0; }
.apt {
  font-size: 12px;
  border-radius: 6px;
  padding: 2px 5px;
  background: #16130f;
  color: var(--faint);
}
.apt i { font-style: normal; margin-right: 2px; }
.apt-S { color: var(--gold); }
.apt-A { color: #e2a15a; }
.apt-B { color: #c4b49a; }
.check { display: inline-flex; align-items: center; gap: 6px; }
.box {
  width: 16px; height: 16px;
  border: 1px solid var(--gold-2);
  border-radius: 4px;
  display: inline-block;
}
.check.on .box { background: var(--gold-2); box-shadow: inset 0 0 0 2px #1a1612; }
.reds, .seg { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; align-items: center; }
.pip { min-width: 36px; min-height: 36px; padding: 4px; }
.tag, .mini {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 1px 7px;
  font-size: 12px;
  color: var(--gold-2);
}
.tag.ghost { color: var(--muted); }
.tag.grade-s { color: #1a1208; background: var(--gold); border-color: var(--gold); font-weight: 700; }
.tag.grade-a { color: #1a1208; background: #d7b4f0; border-color: #d7b4f0; font-weight: 700; }
.mini.duwei, .mini.season {
  color: #100e0c;
  background: var(--gold-2);
  border-color: var(--gold-2);
  font-weight: 700;
}
.list { display: flex; flex-direction: column; gap: 8px; }
.trow { padding: 12px; align-items: flex-start; box-shadow: none; }
.trow .body { flex: 1; min-width: 0; }
.trow h3 { font-size: 18px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.quota { text-align: right; min-width: 72px; font-variant-numeric: tabular-nums; }
.quota b { display: block; font-size: 18px; }
.quota.ready b, .quota.ready { color: var(--gold); }
.quota.used, .quota.used b { color: #8d8680; }
.quota.none, .quota.none b { color: #d37a6c; }
.entry-row { margin: 14px 0; }

.team-grid { display: grid; gap: 10px; }
.member, .team-card, .account-card, .help-card { padding: 14px; }
.member { padding: 10px 12px; }
.member .member-top { align-items: flex-start; }
.member-id {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  min-width: 0;
  flex: 1;
}
.member-move { display: inline-flex; gap: 4px; flex: 0 0 auto; }
.member-top h3 { margin: 0; font-size: 18px; }
button.member-name {
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.2;
  text-align: left;
  min-height: 0;
  display: inline-flex;
  gap: 8px;
  align-items: center;
  cursor: pointer;
}
button.member-name:hover,
button.member-name:focus-visible { color: var(--gold); }
.picker-replacing { margin: 2px 0 0; color: var(--gold); font-weight: 700; }
.member-meta { color: var(--muted); font-size: 13px; }
.member .apt-row {
  flex: 1 0 100%;
  flex-wrap: nowrap;
  margin: 0;
  gap: 6px;
}
.member .apt {
  background: transparent;
  padding: 0;
  font-size: 13px;
  white-space: nowrap;
}
.member .apt i { margin-right: 0; }
.member-marks {
  flex: 1 0 100%;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.share-preview, .share-missing { margin: 8px 0 12px; padding-left: 1.2em; }
.share-preview li + li, .share-missing li + li { margin-top: 8px; }
.share-missing-label { margin-bottom: 0; font-weight: 700; }
.share-applied { margin-bottom: 12px; }
.share-applied h3 { margin-top: 0; }
.member-learn {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
}
.member-learn .slot-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 1px;
  min-height: 44px;
  padding: 6px 8px;
  line-height: 1.25;
}
.member-learn .slot-btn strong { font-size: 14px; font-weight: 650; }
.slot-label { display: flex; flex-wrap: wrap; gap: 2px 6px; align-items: baseline; }
.slot-origin { color: var(--gold-2); font-size: 12px; }
.member-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
}
.member-actions .faint,
.member .muted { margin: 0; }
.member .muted,
.member .warn { margin-top: 6px; }
.member-book {
  flex: 1;
  min-width: 0;
  text-align: left;
  min-height: 36px;
  padding: 6px 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.member-actions .btn-ghost { flex: 0 0 auto; min-height: 36px; padding: 6px 10px; }
.chip:disabled { opacity: 0.4; cursor: not-allowed; }
.account-list, .help-grid, .stack { display: grid; gap: 12px; }
.help-grid { margin-top: 16px; }
.member .locked, .picked {
  margin: 8px 0;
  padding: 8px 10px;
  border-radius: 10px;
  background: #16130f;
  border: 1px dashed var(--line);
}
.slot-btn { width: 100%; text-align: left; }
.icon-btn { min-width: 40px; padding: 8px; }
.dock { margin-top: 14px; padding: 14px; }
.branches, .nodes { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 12px; }
.branch { min-width: 92px; }
.node { max-width: 240px; text-align: left; }
.node small, .branch small { display: block; color: var(--muted); font-size: 12px; }
.path { color: var(--gold); }

.season-opt { display: flex; align-items: center; gap: 8px; margin: 8px 0; }
.season-opt input { width: 18px; height: 18px; }
.account-card-top { display: flex; align-items: flex-start; gap: 8px; }
.account-card-main { flex: 1; min-width: 0; }
.account-side { display: flex; flex-direction: column; align-items: center; gap: 6px; flex: 0 0 auto; }
.account-side .btn { min-height: 32px; padding: 4px 10px; white-space: nowrap; }
.accounts .account-card header,
.accounts .account-card header label { display: block; }
.counts { display: flex; gap: 12px; color: var(--muted); font-size: 14px; margin: 8px 0; }
.active-pill { color: #100e0c; background: var(--gold); border-radius: 999px; padding: 2px 8px; font-size: 12px; white-space: nowrap; }

.backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0, 0, 0, 0.62);
  display: grid;
  place-items: end center;
  padding: 12px;
}
.sheet, .dialog { width: min(640px, 100%); max-height: min(86vh, 820px); overflow: auto; padding: 16px; }
.sheet.picker-sheet,
.sheet.bingshu-sheet {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0;
}
.sheet.picker-sheet { height: min(86vh, 820px); }
.picker-head, .bingshu-head { padding: 14px 16px 8px; align-items: center; flex: 0 0 auto; }
.picker-head h3, .bingshu-head h3 { margin: 0; font-size: 22px; }
.picker-filters { display: flex; flex-direction: column; gap: 8px; padding: 0 16px 8px; flex: 0 0 auto; }
.picker-filters .filter-row { padding: 2px 0; border-bottom: 0; }
.picker-filters .filter-row span { padding-top: 6px; }
.bingshu-steps, .bingshu-hint, .sheet-foot { flex: 0 0 auto; }
.picker-count { margin: 0; }
.picker-list, .bingshu-body {
  overflow: auto;
  padding: 0 16px 16px;
  flex: 1;
  min-height: 0;
}
.bingshu-steps {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 0 16px 6px;
}
.step-arrow { color: var(--faint); }
.bingshu-hint { margin: 0 16px 8px; }
.bingshu-body .branches,
.bingshu-body .nodes {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin: 0;
}
.bingshu-body .branch,
.bingshu-body .node { width: 100%; max-width: none; }
.sheet-foot {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  padding: 10px 16px 14px;
  border-top: 1px solid var(--line);
  background: #1c1814;
}
.sheet-foot .path { margin: 0; min-width: 0; }
.sheet-foot .btn-row { flex: 0 0 auto; }
.dialog { place-self: center; }
.sheet h3, .dialog h3 { margin-bottom: 8px; }
.choice { width: 100%; text-align: left; margin-top: 8px; }
.choice:disabled, .slot-btn:disabled, .icon-btn:disabled { opacity: 0.55; cursor: not-allowed; }
.warn { color: #e2a15a; font-size: 13px; }
.empty, .fatal {
  padding: 28px 16px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 16px;
}
.fatal { margin: 24px; }
.colophon { margin-top: 18px; color: var(--faint); font-size: 12px; }
.colophon a { color: var(--gold-2); }
a.help-card { color: inherit; text-decoration: none; display: block; }
.release h3 { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.release .changes { margin: 8px 0 0; padding-left: 1.2em; }
.release .changes li + li { margin-top: 4px; }
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-h) + 8px);
  transform: translateX(-50%);
  background: #3c2f1d;
  color: var(--gold);
  border: 1px solid var(--gold-2);
  border-radius: 16px;
  padding: 8px 14px;
  z-index: 60;
  max-width: min(420px, calc(100% - 24px));
  text-align: center;
  line-height: 1.45;
}
.toast:empty { display: none; }
.sr {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

@media (min-width: 980px) {
  .filter-panel { display: block; }
  .generals-page.filter-open .filter-panel {
    position: sticky;
    inset: auto;
    top: 74px;
    background: transparent;
    padding: 0;
    z-index: 1;
    max-height: calc(100vh - 96px);
  }
  .layout { display: grid; grid-template-columns: 320px 1fr; gap: 16px; align-items: start; }
  .only-mobile { display: none; }
  .team-grid { grid-template-columns: repeat(3, 1fr); }
  .help-grid { grid-template-columns: repeat(3, 1fr); }
  .backup-grid { grid-template-columns: 1.2fr 0.8fr; align-items: start; }
  .backdrop { place-items: center; }
  main { padding-top: 22px; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}
