:root {
  color-scheme: light;
  --ink: #24313c;
  --muted: #65717c;
  --rule: #e1e6eb;
  --wei: #3b607e;
  --shu: #507448;
  --wu: #a04e3d;
  --qun: #79637c;
  --category-bar-height: 74px;
  --faction-bar-height: 62px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  background: #fff;
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  font-size: 15px;
  line-height: 1.8;
  -webkit-text-size-adjust: 100%;
}

a {
  color: inherit;
  text-underline-offset: 4px;
}

a:focus-visible {
  outline: 2px solid var(--wei);
  outline-offset: 5px;
}

.wrap {
  width: min(100% - 64px, 960px);
  margin-inline: auto;
}

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 20;
  padding: 8px 14px;
  background: #fff;
  transform: translateY(-150%);
}

.skip-link:focus {
  transform: translateY(0);
}

.page-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  padding-block: 32px 24px;
}

.page-heading h1 {
  margin: 0;
  font-size: 30px;
  font-weight: 700;
  line-height: 1.5;
}

.intro,
.totals {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.totals {
  flex-shrink: 0;
  padding-bottom: 2px;
}

.totals span {
  padding-inline: 6px;
  color: #b4bcc4;
}

.faction-nav {
  position: sticky;
  top: var(--category-bar-height);
  z-index: 10;
  border-block: 1px solid var(--rule);
  background: #fff;
}

.category-switcher {
  position: sticky;
  top: 0;
  z-index: 11;
  height: var(--category-bar-height);
  border-block: 1px solid var(--rule);
  background: #fff;
}

.category-tabs {
  display: flex;
  height: calc(var(--category-bar-height) - 2px);
  gap: 24px;
}

.category-tabs button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-width: 200px;
  padding: 6px;
  border: 0;
  border-bottom: 3px solid transparent;
  color: var(--muted);
  background: transparent;
  font-family: inherit;
  cursor: pointer;
}

.category-tabs button[aria-selected="true"] {
  border-bottom-color: var(--ink);
  color: var(--ink);
}

.category-tabs button:focus-visible {
  outline: 2px solid var(--wei);
  outline-offset: -4px;
}

.category-name {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.5;
}

.category-size {
  font-size: 12px;
  line-height: 1.5;
}

.category-panel {
  scroll-margin-top: var(--category-bar-height);
}

.nav-inner {
  display: flex;
  gap: 24px;
}

.nav-inner a {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-width: 100px;
  min-height: 60px;
  border-bottom: 3px solid transparent;
  text-decoration: none;
}

.nav-inner a:hover {
  border-bottom-color: currentColor;
}

.faction-name {
  font-size: 21px;
  font-weight: 700;
}

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

.nav-wei { color: var(--wei); }
.nav-shu { color: var(--shu); }
.nav-wu { color: var(--wu); }
.nav-qun { color: var(--qun); }

.faction-wei { --faction: var(--wei); }
.faction-shu { --faction: var(--shu); }
.faction-wu { --faction: var(--wu); }
.faction-qun { --faction: var(--qun); }

.faction {
  margin-top: 36px;
  scroll-margin-top: calc(var(--category-bar-height) + var(--faction-bar-height) + 18px);
}

.faction-heading {
  display: flex;
  align-items: baseline;
  gap: 14px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--faction);
}

.faction-heading h2 {
  margin: 0;
  color: var(--faction);
  font-size: 27px;
  line-height: 1.5;
}

.faction-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.general {
  display: grid;
  grid-template-columns: 138px minmax(0, 1fr);
  gap: 28px;
  padding-block: 26px;
  border-bottom: 1px solid var(--rule);
  scroll-margin-top: calc(var(--category-bar-height) + var(--faction-bar-height) + 18px);
}

.portrait {
  margin: 0;
  text-align: center;
}

.portrait img {
  display: block;
  width: 110px;
  max-width: 100%;
  height: auto;
  margin-inline: auto;
  border-radius: 5px;
  background: #f2f4f6;
}

.portrait h3 {
  margin: 10px 0 0;
  font-size: 19px;
  line-height: 1.5;
}

.portrait p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.portrait .pack-name {
  margin-top: 8px;
  color: var(--faction);
  font-size: 12px;
}

.portrait .alias {
  font-size: 12px;
}

.skill + .skill {
  margin-top: 22px;
}

.skill h4 {
  margin: 0 0 5px;
  color: var(--faction);
  font-size: 17px;
  line-height: 1.6;
}

.original,
.plain {
  margin: 0;
  overflow-wrap: anywhere;
}

.label {
  margin-right: 10px;
  font-size: 13px;
  font-weight: 600;
}

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

.plain {
  margin-top: 9px;
  padding: 8px 12px;
  border-left: 2px solid var(--faction);
  background: #f7f9fa;
}

.plain .label {
  color: var(--faction);
}

.granted-skill {
  margin-top: 10px;
  padding-top: 4px;
  color: var(--muted);
  font-size: 14px;
}

.granted-skill summary {
  min-height: 40px;
  padding-block: 7px;
  cursor: pointer;
}

.granted-skill summary:focus-visible {
  outline: 2px solid var(--faction);
  outline-offset: 3px;
}

.granted-skill[open] {
  padding-bottom: 6px;
}

.granted-skill .plain {
  font-size: 14px;
}

.glossary {
  margin-top: 44px;
}

.glossary h2 {
  margin: 0 0 14px;
  font-size: 20px;
}

.glossary dl {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px 32px;
  margin: 0;
}

.glossary dt {
  font-weight: 600;
}

.glossary dd {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.page-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-top: 36px;
  padding-block: 22px 30px;
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-size: 12px;
}

.page-footer p {
  margin: 0;
}

.back-top {
  flex-shrink: 0;
}

@media (max-width: 640px) {
  :root {
    --faction-bar-height: 56px;
  }

  .wrap {
    width: calc(100% - 28px);
  }

  .page-heading {
    display: block;
    padding-block: 22px 18px;
  }

  .page-heading h1 {
    font-size: 26px;
  }

  .totals {
    margin-top: 10px;
    font-size: 12px;
  }

  .nav-inner {
    justify-content: space-between;
    gap: 0;
  }

  .category-tabs {
    gap: 0;
  }

  .category-tabs button {
    flex: 1;
    min-width: 0;
  }

  .category-name {
    font-size: 14px;
  }

  .nav-inner a {
    flex: 1;
    gap: 7px;
    min-width: 0;
    min-height: 54px;
  }

  .faction-name {
    font-size: 20px;
  }

  .faction-count {
    font-size: 11px;
  }

  .faction {
    margin-top: 26px;
    scroll-margin-top: calc(var(--category-bar-height) + var(--faction-bar-height) + 18px);
  }

  .general {
    grid-template-columns: 84px minmax(0, 1fr);
    gap: 14px;
    padding-block: 20px;
    scroll-margin-top: calc(var(--category-bar-height) + var(--faction-bar-height) + 18px);
  }

  .portrait img {
    width: 82px;
  }

  .portrait h3 {
    font-size: 17px;
  }

  .portrait p {
    font-size: 11px;
  }

  .skill h4 {
    font-size: 16px;
  }

  .skill + .skill {
    margin-top: 18px;
  }

  .original {
    font-size: 13px;
  }

  .plain {
    padding: 6px 8px;
    font-size: 14px;
  }

  .label {
    margin-right: 7px;
    font-size: 12px;
  }

  .glossary dl {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .page-footer {
    align-items: start;
    margin-top: 26px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}
