:root {
  --bg-0: #08111b;
  --bg-1: #102033;
  --bg-2: #1f3a56;
  --line: rgba(255, 255, 255, 0.14);
  --card: rgba(255, 255, 255, 0.08);
  --text: #eef4ff;
  --muted: #a3b9d1;
  --accent: #ffcc6a;
  --accent-2: #8ff0b0;
  --male-border: #65b5ff;
  --male-bg: linear-gradient(160deg, rgba(30, 74, 130, 0.62), rgba(16, 38, 76, 0.55));
  --female-border: #ff8fb2;
  --female-bg: linear-gradient(160deg, rgba(122, 37, 77, 0.6), rgba(63, 24, 49, 0.52));
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Microsoft YaHei", "Segoe UI", "LXGW WenKai", sans-serif;
  color: var(--text);
  background: linear-gradient(140deg, var(--bg-0), var(--bg-1), var(--bg-2));
}

.page-shell {
  width: min(1100px, calc(100% - 28px));
  margin: 0 auto;
  padding: 22px 0 34px;
  display: grid;
  gap: 14px;
}

.card {
  border-radius: 20px;
  border: 1px solid var(--line);
  background: var(--card);
  backdrop-filter: blur(8px);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
  padding: 18px;
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
}

.eyebrow {
  margin: 0;
  color: #c2d8ee;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.hero h1 {
  margin: 8px 0 6px;
  font-size: clamp(30px, 5vw, 46px);
  line-height: 1.1;
}

.subline {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
}

.home-link {
  text-decoration: none;
  color: #dce9f9;
  border: 1px solid var(--line);
  padding: 8px 12px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  white-space: nowrap;
}

.controls {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) auto;
  gap: 12px;
  align-items: end;
}

.control-field {
  display: grid;
  gap: 8px;
}

.control-field label,
.control-field .label {
  font-size: 13px;
  font-weight: 700;
  color: #d3e3f4;
}

select {
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  border-radius: 16px;
  border: 1px solid rgba(155, 218, 255, 0.22);
  background:
    linear-gradient(155deg, rgba(11, 24, 40, 0.92), rgba(8, 18, 30, 0.82));
  background-image:
    linear-gradient(155deg, rgba(11, 24, 40, 0.92), rgba(8, 18, 30, 0.82)),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%23c9ecff' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.8' d='m3.5 5.75 4.5 4.5 4.5-4.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat, no-repeat;
  background-position: 0 0, calc(100% - 16px) 50%;
  background-size: auto, 16px 16px;
  color: #f5fbff;
  padding: 12px 44px 12px 14px;
  font: inherit;
  font-weight: 700;
  line-height: 1.45;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 10px 24px rgba(1, 8, 18, 0.18);
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    transform 160ms ease,
    background 160ms ease;
}

select:hover {
  border-color: rgba(176, 230, 255, 0.42);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    0 14px 28px rgba(2, 12, 24, 0.24);
}

select:focus {
  outline: none;
  border-color: rgba(255, 206, 118, 0.76);
  box-shadow:
    0 0 0 3px rgba(255, 206, 118, 0.16),
    0 16px 30px rgba(2, 12, 24, 0.28);
  transform: translateY(-1px);
}

select:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  box-shadow: none;
}

select option {
  background: #132338;
  color: #f5fbff;
}

select option:checked {
  background: #305f95;
  color: #ffffff;
}

select option:disabled {
  color: #87a0bc;
}

.segmented {
  width: fit-content;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(5, 15, 28, 0.45);
  padding: 3px;
  display: inline-flex;
  gap: 4px;
}

.seg {
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 6px 14px;
  background: transparent;
  color: #c7d9ec;
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease;
}

.seg:disabled,
.seg.is-disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: grayscale(25%);
}

.seg.active {
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.2) inset;
}

.seg[data-sex="M"] {
  background: linear-gradient(145deg, rgba(72, 149, 226, 0.2), rgba(35, 82, 136, 0.16));
  border-color: rgba(118, 187, 255, 0.35);
  color: #cde8ff;
}

.seg[data-sex="F"] {
  background: linear-gradient(145deg, rgba(235, 127, 174, 0.2), rgba(145, 66, 107, 0.15));
  border-color: rgba(255, 177, 213, 0.36);
  color: #ffe0ef;
}

.seg[data-sex="M"]:hover {
  background: linear-gradient(145deg, rgba(89, 166, 241, 0.3), rgba(42, 94, 152, 0.24));
}

.seg[data-sex="F"]:hover {
  background: linear-gradient(145deg, rgba(245, 144, 188, 0.3), rgba(159, 76, 118, 0.24));
}

.seg[data-sex="M"].active {
  background: linear-gradient(145deg, rgba(118, 196, 255, 0.9), rgba(81, 151, 222, 0.84));
  border-color: rgba(188, 230, 255, 0.95);
  color: #09253f;
}

.seg[data-sex="F"].active {
  background: linear-gradient(145deg, rgba(255, 183, 216, 0.92), rgba(237, 143, 187, 0.85));
  border-color: rgba(255, 224, 239, 0.96);
  color: #4b1731;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.stat .kicker {
  margin: 0;
  color: #bdd3ea;
  font-size: 12px;
  font-weight: 700;
}

.stat .value {
  margin: 8px 0 0;
  font-size: clamp(30px, 4vw, 44px);
  font-weight: 900;
  color: #fff5d6;
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  margin-bottom: 10px;
}

.section-head h2 {
  margin: 0;
  font-size: 18px;
}

.muted {
  color: var(--muted);
  font-size: 12px;
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chain-controls {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.chain-controls label {
  font-size: 13px;
  font-weight: 700;
  color: #d3e3f4;
}

.chip-list .pet-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(148px, 1fr));
  width: 100%;
  gap: 10px;
  flex-basis: 100%;
}

.pet-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(148px, 1fr));
  gap: 10px;
}

.pet-card {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: auto auto;
  gap: 8px;
  align-items: center;
  justify-items: center;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(8, 20, 35, 0.52);
  padding: 10px 8px;
  min-height: 118px;
}

.pet-card-button {
  cursor: pointer;
  font: inherit;
  color: inherit;
  text-align: inherit;
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
}

.pet-card-button:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 231, 170, 0.7);
}

.pet-card-button.is-active {
  border-color: rgba(255, 210, 113, 0.92);
  background: linear-gradient(145deg, rgba(69, 53, 12, 0.6), rgba(35, 28, 9, 0.5));
}

.pet-avatar {
  width: 68px;
  height: 68px;
  object-fit: contain;
  border-radius: 12px;
  background: rgba(7, 18, 31, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.pet-name {
  display: block;
  max-width: 100%;
  text-align: center;
  font-size: 13px;
  line-height: 1.3;
  color: #d8e8f8;
  word-break: break-all;
}

.chip {
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(8, 20, 35, 0.48);
  color: #d8e8f8;
  font-size: 13px;
}

.chip-empty {
  color: #9ab2cc;
  border-style: dashed;
}

.chain-view {
  display: grid;
  gap: 10px;
}

.chain-empty {
  margin: 0;
  border-radius: 12px;
  border: 1px dashed rgba(255, 255, 255, 0.2);
  padding: 14px;
  color: #9eb5cf;
  background: rgba(6, 16, 28, 0.38);
}

.chain-stack {
  display: grid;
  gap: 10px;
}

.chain-step-card {
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: linear-gradient(155deg, rgba(16, 29, 47, 0.88), rgba(9, 18, 31, 0.82));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
  padding: 10px;
}

.chain-step-done {
  display: grid;
  justify-items: center;
  gap: 10px;
}

.chain-done-text {
  margin: 0;
  color: #d7e7f7;
  font-weight: 700;
}

.chain-step-head {
  margin-bottom: 10px;
}

.chain-step-index {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.08);
  color: #d8e6f7;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
}

.chain-breed-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
}

.chain-op {
  color: #ffd78f;
  font-size: 19px;
  font-weight: 800;
  text-align: center;
}

.chain-node {
  min-width: 0;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(10, 24, 40, 0.72);
  padding: 8px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 8px;
  align-items: center;
}

.chain-node.is-shiny {
  border-color: rgba(255, 212, 116, 0.85);
  background: linear-gradient(152deg, rgba(42, 60, 95, 0.78), rgba(28, 39, 69, 0.74));
}

.chain-node.is-normal {
  border-color: rgba(151, 172, 201, 0.52);
  background: linear-gradient(150deg, rgba(38, 44, 56, 0.75), rgba(30, 35, 46, 0.7));
}

.chain-node.sex-m {
  box-shadow: inset 0 0 0 1px rgba(102, 187, 255, 0.38);
}

.chain-node.sex-f {
  box-shadow: inset 0 0 0 1px rgba(255, 158, 194, 0.4);
}

.chain-node.is-shiny.sex-m {
  background: linear-gradient(152deg, rgba(39, 74, 128, 0.92), rgba(24, 53, 99, 0.88));
  border-color: rgba(124, 195, 255, 0.86);
}

.chain-node.is-shiny.sex-f {
  background: linear-gradient(152deg, rgba(118, 53, 95, 0.92), rgba(78, 34, 66, 0.88));
  border-color: rgba(255, 174, 212, 0.88);
}

.chain-node.is-normal.sex-m {
  background: linear-gradient(150deg, rgba(41, 60, 88, 0.9), rgba(28, 44, 70, 0.86));
  border-color: rgba(113, 178, 235, 0.72);
}

.chain-node.is-normal.sex-f {
  background: linear-gradient(150deg, rgba(86, 51, 76, 0.9), rgba(61, 38, 57, 0.86));
  border-color: rgba(225, 152, 194, 0.72);
}

.chain-avatar-wrap {
  position: relative;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px;
}

.chain-node.sex-m .chain-avatar-wrap {
  background: linear-gradient(150deg, rgba(76, 154, 230, 0.2), rgba(45, 87, 141, 0.14));
  border: 1px solid rgba(122, 194, 255, 0.46);
}

.chain-node.sex-f .chain-avatar-wrap {
  background: linear-gradient(150deg, rgba(231, 128, 174, 0.2), rgba(149, 72, 111, 0.15));
  border: 1px solid rgba(255, 173, 210, 0.5);
}

.chain-avatar {
  width: 54px;
  height: 54px;
  object-fit: contain;
  border-radius: 10px;
  background: rgba(4, 12, 20, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.24);
}

.chain-sex-badge {
  position: absolute;
  right: -3px;
  top: -3px;
  min-width: 18px;
  height: 18px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.55);
  background: rgba(7, 12, 20, 0.88);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
}

.chain-prob-badge {
  position: absolute;
  left: -4px;
  bottom: -4px;
  border-radius: 999px;
  border: 1px solid rgba(255, 230, 168, 0.85);
  background: linear-gradient(145deg, rgba(159, 116, 28, 0.95), rgba(110, 79, 18, 0.92));
  color: #fff3cd;
  font-size: 9px;
  font-weight: 800;
  line-height: 1;
  padding: 2px 6px;
  letter-spacing: 0.02em;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.32);
  z-index: 2;
}

.chain-sex-badge.sex-m {
  color: #66bbff;
}

.chain-sex-badge.sex-f {
  color: #ff9ec2;
}

.chain-node-meta {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.chain-role {
  display: inline-flex;
  width: fit-content;
  max-width: 100%;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(0, 0, 0, 0.25);
  color: #d8e8f8;
  font-size: 11px;
  line-height: 1;
  padding: 4px 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chain-species {
  font-size: 14px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.footnote {
  text-align: center;
  color: #92a9c1;
  font-size: 12px;
}

@media (max-width: 900px) {
  .controls {
    grid-template-columns: minmax(0, 1.2fr) auto;
    gap: 8px;
  }

  .summary-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  .hero {
    flex-direction: column;
    gap: 10px;
  }

  .page-shell {
    width: min(1100px, calc(100% - 20px));
    padding: 10px 0 18px;
    gap: 10px;
  }

  .card {
    border-radius: 14px;
    padding: 10px;
  }

  .hero h1 {
    margin: 6px 0 4px;
    font-size: clamp(24px, 7vw, 34px);
  }

  .subline {
    font-size: 12px;
    line-height: 1.5;
  }

  .stat .value {
    margin-top: 6px;
    font-size: clamp(22px, 6vw, 30px);
  }

  .control-field {
    gap: 6px;
  }

  .control-field label,
  .control-field .label {
    font-size: 12px;
  }

  select {
    padding: 9px 40px 9px 12px;
    background-position: 0 0, calc(100% - 14px) 50%;
  }

  .pet-grid {
    grid-template-columns: repeat(auto-fit, minmax(102px, 1fr));
    gap: 8px;
  }

  .chip-list .pet-grid {
    grid-template-columns: repeat(auto-fit, minmax(102px, 1fr));
    gap: 8px;
  }

  .pet-card {
    min-height: 116px;
    padding: 8px 6px;
    border-radius: 12px;
  }

  .pet-avatar {
    width: 56px;
    height: 56px;
  }

  .pet-name {
    font-size: 12px;
  }

  .chain-controls {
    margin-bottom: 10px;
  }

  .chain-step-card {
    border-radius: 12px;
    padding: 8px;
  }

  .chain-breed-row {
    grid-template-columns: minmax(0, 1fr) 14px minmax(0, 1fr) 14px minmax(0, 1fr);
    gap: 6px;
  }

  .chain-op {
    transform: none;
    line-height: 1;
    justify-self: stretch;
    align-self: center;
    font-size: 16px;
  }

  .chain-node {
    grid-template-columns: 42px minmax(0, 1fr);
    gap: 6px;
    padding: 6px;
  }

  .chain-avatar {
    width: 38px;
    height: 38px;
  }

  .chain-sex-badge {
    min-width: 15px;
    height: 15px;
    font-size: 10px;
  }

  .chain-prob-badge {
    left: -3px;
    bottom: -3px;
    font-size: 9px;
    padding: 2px 5px;
  }

  .chain-role {
    font-size: 10px;
    padding: 3px 6px;
  }

  .chain-species {
    font-size: 12px;
  }

}

@media (max-width: 560px) {
  .chain-breed-row {
    grid-template-columns: minmax(0, 1fr);
    gap: 6px;
  }

  .chain-op {
    transform: none;
    justify-self: center;
  }

  .chain-node {
    grid-template-columns: 48px minmax(0, 1fr);
    gap: 7px;
    padding: 7px;
  }

  .chain-avatar {
    width: 48px;
    height: 48px;
  }

  .chain-sex-badge {
    min-width: 16px;
    height: 16px;
    font-size: 11px;
  }

  .chain-prob-badge {
    font-size: 9px;
    padding: 2px 5px;
  }

  .chain-species {
    font-size: 13px;
  }
}
