:root {
  color-scheme: light;
  --bg: #f6f7f3;
  --panel: #ffffff;
  --ink: #20252b;
  --muted: #66707a;
  --line: #dfe5dd;
  --accent: #1f8f7a;
  --accent-2: #d45b48;
  --chip: #eef4f1;
  --shadow: 0 18px 42px rgba(33, 40, 48, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 16px clamp(16px, 3vw, 34px);
  background: rgba(246, 247, 243, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

h1 {
  margin: 0;
  font-size: clamp(24px, 3vw, 34px);
  line-height: 1;
  letter-spacing: 0;
}

#countText {
  color: var(--muted);
  font-size: 14px;
  white-space: nowrap;
}

.site-nav {
  display: flex;
  gap: 6px;
  margin-left: 6px;
}

.site-nav a {
  min-height: 32px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
  font-size: 14px;
  text-decoration: none;
}

.site-nav a.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.search {
  width: min(420px, 48vw);
}

.search input {
  width: 100%;
  height: 42px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  outline: none;
}

.search input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 143, 122, 0.14);
}

main {
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 18px clamp(12px, 2.6vw, 30px) 36px;
}

.calculator-page {
  width: min(1240px, 100%);
}

.calc-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 18px;
  align-items: start;
}

.calc-panel,
.calc-result {
  display: grid;
  gap: 14px;
}

.calc-section,
.result-card,
.formula-note {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 16px;
}

.calc-section h2 {
  margin: 0 0 12px;
  font-size: 18px;
}

.calc-section label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.calc-section input,
.calc-section select {
  width: 100%;
  height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcf8;
  color: var(--ink);
  outline: none;
}

.calc-section input:focus,
.calc-section select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 143, 122, 0.14);
}

.calc-section > label + label {
  margin-top: 10px;
}

.calc-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.calc-result {
  position: sticky;
  top: 92px;
}

.result-card {
  display: grid;
  gap: 6px;
}

.result-card span {
  color: var(--muted);
  font-size: 14px;
}

.result-card strong {
  color: var(--accent-2);
  font-size: 44px;
  line-height: 1;
}

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

.formula-note p {
  margin: 0 0 8px;
}

.duel-layout {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(320px, 0.92fr) minmax(280px, 1fr);
  gap: 14px;
  align-items: start;
}

.combatant-card,
.battle-core,
.preset-manager {
  display: grid;
  gap: 12px;
}

.combatant-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 16px;
}

.combatant-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.combatant-title h2 {
  margin: 0;
  font-size: 22px;
}

.combatant-title span,
.combatant-profile span {
  color: var(--muted);
  font-size: 13px;
}

.combatant-card label,
.preset-editor label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.combatant-card input,
.combatant-card select,
.preset-editor input,
.preset-editor select {
  width: 100%;
  height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcf8;
  color: var(--ink);
  outline: none;
}

.pet-picker-trigger {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 8px;
  align-items: center;
  width: 100%;
  min-height: 46px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcf8;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

.pet-picker-trigger:hover,
.pet-picker-trigger:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 143, 122, 0.14);
  outline: none;
}

.pet-picker-trigger img {
  width: 34px;
  height: 34px;
  object-fit: contain;
}

.pet-picker-trigger span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.combatant-profile {
  display: grid;
  grid-template-columns: 86px 1fr;
  gap: 12px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcf8;
}

.combatant-profile img {
  width: 86px;
  height: 86px;
  object-fit: contain;
}

.combatant-profile div {
  display: grid;
  gap: 4px;
}

.combatant-profile strong {
  font-size: 20px;
}

.stat-table {
  display: grid;
  gap: 6px;
}

.stat-row {
  display: grid;
  grid-template-columns: 48px 56px minmax(68px, 1fr) 62px;
  gap: 8px;
  align-items: center;
  min-height: 38px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcf8;
}

.stat-row span {
  color: var(--muted);
  font-size: 13px;
}

.stat-row strong {
  color: var(--ink);
  font-size: 15px;
}

.stat-row input {
  height: 30px;
  padding: 0 8px;
}

.stat-row em {
  color: var(--accent-2);
  font-style: normal;
  font-weight: 700;
  text-align: right;
}

.battle-core .calc-section {
  padding: 14px;
}

.skill-summary {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 10px;
  align-items: center;
  margin-top: 10px;
}

.skill-summary img {
  width: 64px;
  height: 64px;
  object-fit: contain;
}

.skill-summary div {
  display: grid;
  gap: 3px;
}

.skill-summary span,
.skill-summary p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.main-result strong {
  font-size: 56px;
}

.compact {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.preset-manager {
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  margin-top: 16px;
}

.preset-editor-grid,
.preset-iv-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.preset-iv-grid {
  margin: 12px 0;
}

.primary-action {
  min-height: 38px;
  padding: 8px 14px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
}

.secondary-action {
  min-height: 38px;
  margin-left: 8px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
  cursor: pointer;
  font-weight: 700;
}

.secondary-action:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.preset-list {
  display: grid;
  gap: 8px;
}

.preset-row {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcf8;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

.preset-row:hover,
.preset-row.editing {
  border-color: var(--accent);
  box-shadow: 0 8px 18px rgba(33, 40, 48, 0.1);
}

.preset-row.editing {
  background: #eef4f1;
}

.preset-row img {
  width: 48px;
  height: 48px;
  object-fit: contain;
}

.preset-row div {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.preset-row span {
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preset-row button {
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
  cursor: pointer;
}

.preset-row button:hover {
  border-color: var(--accent-2);
  color: var(--accent-2);
}

.pet-picker-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(20, 26, 32, 0.58);
}

.pet-picker-modal.open {
  display: flex;
}

.pet-picker-panel {
  position: relative;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 12px;
  width: min(920px, 100%);
  height: min(760px, calc(100vh - 40px));
  padding: 18px;
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.pet-picker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.pet-picker-head h2 {
  margin: 0;
  font-size: 22px;
}

.pet-picker-panel .close-button {
  position: static;
}

.pet-picker-search {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcf8;
  color: var(--ink);
  outline: none;
}

.pet-picker-search:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 143, 122, 0.14);
}

.pet-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(178px, 1fr));
  gap: 8px;
  overflow: auto;
  padding-right: 4px;
}

.skill-picker-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  overflow: auto;
  padding-right: 4px;
}

.pet-picker-item {
  display: grid;
  grid-template-columns: 54px 1fr;
  gap: 10px;
  align-items: center;
  min-height: 76px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcf8;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

.skill-picker-item {
  display: grid;
  grid-template-columns: 54px 1fr;
  gap: 10px;
  align-items: center;
  min-height: 78px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcf8;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

.pet-picker-item:hover,
.pet-picker-item:focus-visible,
.skill-picker-item:hover,
.skill-picker-item:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 8px 18px rgba(33, 40, 48, 0.12);
  outline: none;
}

.pet-picker-item img {
  width: 54px;
  height: 54px;
  object-fit: contain;
}

.skill-picker-item img {
  width: 54px;
  height: 54px;
  object-fit: contain;
}

.pet-picker-item > span {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.skill-picker-item > span {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.pet-picker-item strong,
.pet-picker-item span span,
.skill-picker-item strong,
.skill-picker-item span span,
.skill-picker-item em {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pet-picker-item span span {
  color: var(--muted);
  font-size: 12px;
}

.skill-picker-item span span,
.skill-picker-item em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.filters {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filter-chip {
  min-height: 34px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--chip);
  color: var(--ink);
  cursor: pointer;
}

.filter-chip.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.skill-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
  gap: 12px;
}

.skill-card {
  display: grid;
  grid-template-rows: 72px auto auto;
  justify-items: center;
  gap: 6px;
  min-height: 148px;
  padding: 12px 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  box-shadow: 0 1px 0 rgba(33, 40, 48, 0.04);
}

.skill-card:hover,
.skill-card:focus-visible {
  border-color: rgba(31, 143, 122, 0.55);
  box-shadow: 0 10px 24px rgba(33, 40, 48, 0.12);
  outline: none;
  transform: translateY(-1px);
}

.skill-card img {
  width: 72px;
  height: 72px;
  object-fit: contain;
}

.pet-grid {
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
}

.pet-card {
  grid-template-rows: 104px 18px auto auto;
  min-height: 198px;
}

.pet-card img.pet-card-image {
  width: 104px;
  height: 104px;
}

.card-number,
.pet-number {
  color: var(--muted);
  font-size: 12px;
}

.skill-name {
  width: 100%;
  min-height: 40px;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.skill-meta {
  display: flex;
  justify-content: center;
  gap: 5px;
  width: 100%;
  color: var(--muted);
  font-size: 12px;
}

.detail-shell {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 22px 82px;
  background: rgba(20, 26, 32, 0.58);
}

.detail-shell.open {
  display: flex;
}

.detail-panel {
  position: relative;
  width: min(660px, 100%);
  max-height: min(760px, calc(100vh - 44px));
  overflow: auto;
  padding: 26px;
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.close-button,
.nav-button {
  display: grid;
  place-items: center;
  border: 0;
  cursor: pointer;
}

.close-button {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: #f1f3ef;
  color: var(--ink);
}

.close-button svg,
.nav-button svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-button {
  position: absolute;
  top: 50%;
  width: 54px;
  height: 76px;
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  transform: translateY(-50%);
  box-shadow: var(--shadow);
}

.nav-button:hover,
.close-button:hover {
  background: var(--accent);
  color: #fff;
}

.previous {
  left: 18px;
}

.next {
  right: 18px;
}

.detail-head {
  display: grid;
  grid-template-columns: 112px 1fr;
  gap: 18px;
  align-items: center;
  padding-right: 34px;
}

.pet-head {
  grid-template-columns: 176px 1fr;
}

.detail-icon {
  width: 112px;
  height: 112px;
  object-fit: contain;
}

.pet-portrait {
  width: 176px;
  height: 176px;
  object-fit: contain;
}

.detail-title h2 {
  margin: 0 0 12px;
  font-size: clamp(26px, 5vw, 42px);
  line-height: 1.08;
  letter-spacing: 0;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.badges span {
  min-height: 30px;
  padding: 5px 10px;
  border-radius: 8px;
  background: #eef4f1;
  color: #24534b;
  font-size: 14px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 22px 0 16px;
}

.stats > div {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 8px;
  min-height: 72px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcf8;
}

.pet-stats {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.trait-box {
  display: grid;
  grid-template-columns: 70px 1fr;
  gap: 14px;
  align-items: center;
  margin: 18px 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcf8;
}

.trait-icon {
  width: 70px;
  height: 70px;
  object-fit: contain;
}

.trait-box h3 {
  margin: 0 0 6px;
  font-size: 18px;
}

.trait-box p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.pet-extra {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}

.pet-extra span:not(:empty) {
  padding: 6px 10px;
  border-radius: 8px;
  background: #eef4f1;
}

.stat-value {
  font-size: 32px;
  font-weight: 700;
  color: var(--accent-2);
}

.stat-label {
  color: var(--muted);
}

.effect,
.description {
  margin: 0 0 12px;
  color: var(--ink);
  font-size: 16px;
  line-height: 1.75;
}

.description:empty {
  display: none;
}

.learners {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.learners h3 {
  margin: 0 0 10px;
  font-size: 16px;
}

.learner-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.learner {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 128px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcf8;
  color: var(--muted);
  font-size: 13px;
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.learner:hover,
.pet-skill:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.learner-thumb {
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
  object-fit: contain;
}

.pet-skills {
  margin-top: 20px;
}

.pet-skill-list {
  display: grid;
  gap: 8px;
}

.pet-skill {
  display: grid;
  grid-template-columns: 46px 1fr;
  gap: 10px;
  align-items: center;
  min-height: 68px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcf8;
  color: var(--ink);
  text-decoration: none;
}

.pet-skill img {
  width: 46px;
  height: 46px;
  object-fit: contain;
}

.pet-skill-body {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.pet-skill-body strong {
  font-size: 14px;
}

.pet-skill-meta,
.pet-skill-effect {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.pet-skill-effect {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.source-link {
  display: inline-flex;
  margin-top: 18px;
  color: var(--accent);
  text-decoration: none;
  font-weight: 700;
}

@media (max-width: 720px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .search {
    width: 100%;
  }

  .calc-layout {
    grid-template-columns: 1fr;
  }

  .duel-layout,
  .preset-manager {
    grid-template-columns: 1fr;
  }

  .calc-grid {
    grid-template-columns: 1fr;
  }

  .compact,
  .preset-editor-grid,
  .preset-iv-grid {
    grid-template-columns: 1fr;
  }

  .calc-result {
    position: static;
  }

  .stat-row {
    grid-template-columns: 48px 46px minmax(64px, 1fr) 54px;
  }

  .skill-grid {
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
    gap: 9px;
  }

  .brand {
    flex-wrap: wrap;
  }

  .pet-grid {
    grid-template-columns: repeat(auto-fill, minmax(108px, 1fr));
  }

  .skill-card {
    grid-template-rows: 62px auto auto;
    min-height: 134px;
  }

  .pet-card {
    grid-template-rows: 82px 18px auto auto;
    min-height: 176px;
  }

  .skill-card img {
    width: 62px;
    height: 62px;
  }

  .pet-card img.pet-card-image {
    width: 82px;
    height: 82px;
  }

  .detail-shell {
    align-items: stretch;
    padding: 12px;
  }

  .detail-panel {
    max-height: calc(100vh - 24px);
    padding: 20px;
  }

  .detail-head {
    grid-template-columns: 82px 1fr;
    gap: 12px;
  }

  .pet-head {
    grid-template-columns: 108px 1fr;
  }

  .detail-icon {
    width: 82px;
    height: 82px;
  }

  .pet-portrait {
    width: 108px;
    height: 108px;
  }

  .pet-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .nav-button {
    top: auto;
    bottom: 22px;
    width: 48px;
    height: 54px;
    transform: none;
  }

  .previous {
    left: 22px;
  }

  .next {
    right: 22px;
  }
}
