:root {
  --ink: #25324a;
  --muted: #68738a;
  --line: #dbe4ef;
  --paper: #fffdf8;
  --sky: #dff3ff;
  --mint: #dff8ed;
  --gold: #ffd36d;
  --coral: #ff8d7a;
  --blue: #4f8dff;
  --teal: #2bb8a8;
  --violet: #8b78ff;
  --shadow: 0 18px 48px rgba(38, 55, 91, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--ink);
  font-family:
    "Microsoft YaHei",
    "PingFang SC",
    system-ui,
    sans-serif;
  background:
    linear-gradient(120deg, rgba(223, 243, 255, 0.9), rgba(255, 253, 248, 0.96) 44%, rgba(223, 248, 237, 0.9)),
    var(--paper);
}

button,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 22px;
}

main,
.tab-panel,
.dashboard,
.atlas-layout,
.history-layout,
.dashboard > *,
.atlas-layout > *,
.history-layout > * {
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 86px;
}

.eyebrow,
.section-kicker {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1;
}

h2 {
  margin-bottom: 0;
  font-size: 21px;
  line-height: 1.2;
}

.top-actions,
.tabs,
.section-title,
.pet-heading,
.progress-copy {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.primary-button,
.ghost-button,
.tab-button,
.task-button,
.pet-choice,
.branch-card {
  border: 1px solid var(--line);
  border-radius: 8px;
}

.primary-button,
.ghost-button {
  min-height: 42px;
  padding: 0 15px;
  font-weight: 800;
}

.primary-button {
  border-color: #e7b948;
  background: var(--gold);
  color: #3e2a00;
}

.ghost-button {
  background: rgba(255, 255, 255, 0.76);
  color: var(--ink);
}

.tabs {
  justify-content: flex-start;
  margin: 10px 0 18px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.7);
  width: fit-content;
}

.tab-button {
  min-width: 88px;
  min-height: 38px;
  background: transparent;
  color: var(--muted);
  font-weight: 900;
}

.tab-button.active {
  border-color: rgba(79, 141, 255, 0.35);
  background: #ffffff;
  color: var(--blue);
  box-shadow: 0 8px 18px rgba(79, 141, 255, 0.13);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.dashboard {
  display: grid;
  grid-template-columns: minmax(320px, 1.05fr) minmax(360px, 1.25fr) minmax(300px, 0.95fr);
  gap: 18px;
}

.pet-stage,
.quick-score,
.route-panel,
.weekly-card,
.log-panel,
.atlas-layout > section {
  border: 1px solid rgba(219, 228, 239, 0.95);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: var(--shadow);
}

.pet-stage,
.quick-score,
.route-panel,
.weekly-card,
.log-panel,
.atlas-layout > section {
  padding: 18px;
}

.stage-pill {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 10px;
  border-radius: 999px;
  background: #eef5ff;
  color: #315fa8;
  font-size: 13px;
  font-weight: 900;
  white-space: nowrap;
}

.pet-art-wrap {
  position: relative;
  display: grid;
  place-items: center;
  height: clamp(340px, 38vw, 440px);
  margin: 18px 0 22px;
  overflow: visible;
  border: 1px solid #edf1f6;
  border-radius: 8px;
  background: linear-gradient(180deg, #fff7e8, #f7fbff);
}

.pet-status-badges {
  position: absolute;
  top: 14px;
  right: 14px;
  left: 14px;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  pointer-events: none;
}

.pet-stat-badge {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 11px;
  border: 1px solid rgba(219, 228, 239, 0.94);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.88);
  color: var(--ink);
  font-size: 13px;
  font-weight: 950;
  white-space: nowrap;
  box-shadow: 0 8px 18px rgba(38, 55, 91, 0.1);
  backdrop-filter: blur(10px);
}

.pet-level-badge {
  border-color: rgba(79, 141, 255, 0.22);
  background: #e8f2ff;
  color: #235fbd;
}

.pet-growth-badge {
  border-color: rgba(255, 211, 109, 0.4);
  background: #fff4c9;
  color: #8a5b00;
}

.pet-bond-badge {
  border-color: rgba(43, 184, 168, 0.28);
  background: #e7faf4;
  color: #087466;
}

.pet-art-wrap img {
  width: auto;
  max-width: var(--pet-max-width, 72%);
  height: auto;
  max-height: var(--pet-max-height, 72%);
  object-fit: contain;
  cursor: pointer;
  transform-origin: center bottom;
  animation: petIdle 3.8s ease-in-out infinite;
}

.pet-art-wrap img.pet-stage-0 {
  --pet-max-width: 44%;
  --pet-max-height: 48%;
}

.pet-art-wrap img.pet-stage-1 {
  --pet-max-width: 58%;
  --pet-max-height: 64%;
}

.pet-art-wrap img.pet-stage-2 {
  --pet-max-width: 70%;
  --pet-max-height: 78%;
}

.pet-art-wrap img.pet-stage-3 {
  --pet-max-width: 76%;
  --pet-max-height: 86%;
}

.pet-art-wrap img.pet-stage-4 {
  --pet-max-width: 84%;
  --pet-max-height: 92%;
}

.pet-art-wrap img.pet-pat {
  animation: petPat 700ms ease;
}

.pet-art-wrap img.pet-greet {
  animation: petGreet 800ms ease;
}

.pet-art-wrap img.pet-spin {
  animation: petSpin 850ms ease;
}

.pet-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: -2px 0 14px;
}

.pet-actions button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  font-weight: 900;
}

.pet-actions button:hover {
  border-color: rgba(79, 141, 255, 0.45);
  background: #f5fbff;
}

.progress-block {
  display: grid;
  gap: 8px;
}

.progress-copy {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.progress-track,
.mini-track {
  height: 13px;
  overflow: hidden;
  border-radius: 999px;
  background: #edf1f6;
}

.progress-track span,
.mini-track span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--blue), var(--teal), var(--gold));
  transition: width 220ms ease;
}

.pet-mood {
  display: flex;
  gap: 10px;
  align-items: center;
  min-height: 46px;
  margin-top: 14px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #f5fbff;
}

.pet-mood p {
  margin-bottom: 0;
  color: var(--muted);
  font-weight: 700;
}

#moodDot {
  width: 12px;
  height: 12px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--gold);
  box-shadow: 0 0 0 5px rgba(255, 211, 109, 0.25);
}

select {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  font-weight: 800;
}

.task-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.task-button {
  position: relative;
  display: grid;
  grid-template-rows: 1fr auto;
  min-height: 98px;
  padding: 12px;
  text-align: left;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(247, 251, 255, 0.96)),
    #ffffff;
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease;
}

.task-button::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--blue), var(--teal), var(--gold));
}

.task-button:hover {
  transform: translateY(-2px);
  border-color: rgba(79, 141, 255, 0.5);
  box-shadow: 0 10px 24px rgba(79, 141, 255, 0.12);
}

.task-name {
  display: block;
  padding-right: 46px;
  font-weight: 900;
  line-height: 1.35;
}

.task-reward {
  position: absolute;
  top: 12px;
  right: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 38px;
  min-height: 28px;
  padding: 0 9px;
  border: 1px solid rgba(255, 211, 109, 0.42);
  border-radius: 999px;
  background: #fff3bf;
  color: #8a5b00;
  font-size: 13px;
  font-weight: 950;
}

.task-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

@keyframes petIdle {
  0%,
  100% {
    transform: translateY(0) scale(1);
  }
  50% {
    transform: translateY(-5px) scale(1.01);
  }
}

@keyframes petPat {
  0%,
  100% {
    transform: translateY(0) scale(1);
  }
  35% {
    transform: translateY(8px) scale(0.98);
  }
  65% {
    transform: translateY(-8px) scale(1.03);
  }
}

@keyframes petGreet {
  0%,
  100% {
    transform: rotate(0deg);
  }
  25% {
    transform: rotate(-5deg) translateY(-4px);
  }
  55% {
    transform: rotate(5deg) translateY(-4px);
  }
  75% {
    transform: rotate(-3deg);
  }
}

@keyframes petSpin {
  0% {
    transform: rotate(0deg) scale(1);
  }
  45% {
    transform: rotate(8deg) scale(1.04);
  }
  100% {
    transform: rotate(0deg) scale(1);
  }
}

.task-tag {
  color: #0f7d6d;
}

.route-card,
.bond-card {
  margin-top: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.route-card strong {
  display: block;
  margin-bottom: 6px;
  font-size: 20px;
}

.route-card p,
.bond-card p,
.weekly-card p {
  color: var(--muted);
  line-height: 1.55;
}

.bond-card {
  display: grid;
  gap: 10px;
}

.bond-card strong {
  font-size: 24px;
}

.attributes-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.attr-card {
  min-height: 116px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 12px 28px rgba(38, 55, 91, 0.08);
}

.attr-card strong {
  display: block;
  font-size: 24px;
}

.attr-card span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.atlas-layout {
  display: grid;
  grid-template-columns: minmax(320px, 0.9fr) minmax(420px, 1.4fr);
  gap: 18px;
}

.pet-choice-grid,
.branch-grid {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.pet-choice {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 14px;
  align-items: center;
  min-height: 128px;
  padding: 10px;
  background: #ffffff;
  text-align: left;
}

.pet-choice.active {
  border-color: var(--blue);
  box-shadow: inset 0 0 0 2px rgba(79, 141, 255, 0.16);
}

.pet-choice img {
  width: 110px;
  height: 96px;
  object-fit: cover;
  border-radius: 7px;
}

.pet-choice strong,
.branch-card strong {
  display: block;
  margin-bottom: 5px;
  font-size: 18px;
}

.pet-choice p,
.branch-card p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.4;
}

.branch-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.branch-card {
  min-height: 142px;
  padding: 14px;
  background: #ffffff;
  border-top-width: 5px;
}

.branch-card[data-route="勇气"] {
  border-top-color: var(--coral);
}

.branch-card[data-route="智慧"] {
  border-top-color: var(--blue);
}

.branch-card[data-route="爱心"] {
  border-top-color: #ff9ec2;
}

.branch-card[data-route="秩序"] {
  border-top-color: #92a8c8;
}

.branch-card[data-route="坚持"] {
  border-top-color: #8e7b62;
}

.branch-card[data-route="家庭"] {
  border-top-color: var(--gold);
}

.history-layout {
  display: grid;
  grid-template-columns: minmax(280px, 0.75fr) minmax(420px, 1.25fr);
  gap: 18px;
}

.log-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.log-item {
  display: grid;
  gap: 5px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.log-item strong {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.log-item span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

@media (max-width: 1100px) {
  .dashboard,
  .atlas-layout,
  .history-layout {
    grid-template-columns: 1fr;
  }

  .attributes-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 680px) {
  body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    padding-bottom: 92px;
  }

  .app-shell {
    max-width: 100%;
    padding: 8px;
  }

  .topbar {
    display: grid;
    grid-template-columns: 1fr;
    align-items: stretch;
    max-width: 100%;
    min-width: 0;
    min-height: 0;
    gap: 6px;
  }

  .topbar .eyebrow {
    display: none;
  }

  h1 {
    font-size: 22px;
  }

  h2 {
    font-size: 18px;
  }

  .top-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    justify-content: stretch;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    gap: 8px;
  }

  .top-actions .primary-button,
  .top-actions .ghost-button {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    min-height: 34px;
    padding: 0 10px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
  }

  .section-title,
  .pet-heading {
    align-items: stretch;
    flex-direction: column;
    gap: 6px;
  }

  .tabs {
    position: fixed;
    right: 12px;
    bottom: 12px;
    left: 12px;
    z-index: 30;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    justify-content: stretch;
    width: auto;
    gap: 6px;
    margin: 0;
    padding: 7px;
    border-color: rgba(175, 194, 220, 0.9);
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 12px 28px rgba(38, 55, 91, 0.18);
    backdrop-filter: blur(16px);
  }

  .tab-button {
    min-width: 0;
    min-height: 44px;
    padding: 0 8px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .dashboard {
    max-width: 100%;
    min-width: 0;
    gap: 12px;
  }

  .pet-stage,
  .quick-score,
  .route-panel,
  .weekly-card,
  .log-panel,
  .atlas-layout > section {
    max-width: 100%;
    min-width: 0;
    padding: 12px;
    box-shadow: 0 10px 26px rgba(38, 55, 91, 0.1);
  }

  .pet-stage {
    border-color: rgba(198, 216, 238, 0.9);
    background:
      linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(247, 251, 255, 0.9)),
      #ffffff;
  }

  .stage-pill {
    width: fit-content;
    min-height: 30px;
  }

  .pet-art-wrap {
    height: clamp(264px, 69vw, 294px);
    margin: 8px 0 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    justify-content: center;
    overflow: hidden;
    border-color: rgba(232, 221, 194, 0.78);
    background:
      linear-gradient(180deg, #fff5dd 0%, #f3fbff 100%),
      #fffaf0;
  }

  .pet-status-badges {
    position: static;
    width: 100%;
    padding: 0 10px;
    gap: 6px;
    justify-content: center;
  }

  .pet-stat-badge {
    min-height: 30px;
    padding: 0 9px;
    font-size: 12px;
  }

  .pet-art-wrap img {
    width: auto;
    height: var(--pet-mobile-height, clamp(190px, 54vw, 230px));
    max-width: none;
    max-height: none;
    object-fit: contain;
  }

  .pet-art-wrap img.pet-stage-0 {
    --pet-mobile-height: clamp(116px, 30vw, 140px);
  }

  .pet-art-wrap img.pet-stage-1 {
    --pet-mobile-height: clamp(150px, 40vw, 188px);
  }

  .pet-art-wrap img.pet-stage-2 {
    --pet-mobile-height: clamp(190px, 50vw, 230px);
  }

  .pet-art-wrap img.pet-stage-3 {
    --pet-mobile-height: clamp(204px, 56vw, 234px);
  }

  .pet-art-wrap img.pet-stage-4 {
    --pet-mobile-height: clamp(214px, 58vw, 244px);
  }

  .pet-actions {
    position: relative;
    z-index: 1;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    justify-content: stretch;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    gap: 8px;
    margin: 0 0 10px;
  }

  .pet-actions button {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    min-height: 34px;
    padding: 0 6px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .progress-copy {
    align-items: center;
    flex-direction: row;
    font-size: 12px;
  }

  .progress-track,
  .mini-track {
    height: 10px;
  }

  .pet-mood {
    min-height: 0;
    margin-top: 8px;
    padding: 8px 10px;
    font-size: 13px;
  }

  .quick-score .section-title {
    flex-direction: row;
    align-items: end;
  }

  .task-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-top: 12px;
  }

  .task-button {
    min-width: 0;
    min-height: 88px;
    padding: 12px 10px 10px;
  }

  .task-name {
    padding-right: 42px;
    font-size: 14px;
    line-height: 1.28;
    overflow-wrap: anywhere;
  }

  .task-reward {
    top: 10px;
    right: 8px;
    min-width: 34px;
    min-height: 26px;
    padding: 0 8px;
    font-size: 12px;
  }

  .task-meta {
    align-items: flex-end;
    flex-direction: column;
    gap: 4px;
    font-size: 12px;
  }

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

  .route-panel {
    display: grid;
    gap: 10px;
  }

  .route-panel .section-title {
    flex-direction: row;
    align-items: end;
  }

  .route-card,
  .bond-card {
    margin-top: 0;
    padding: 12px;
  }

  .route-card strong {
    font-size: 17px;
  }

  .route-card p,
  .bond-card p {
    margin-bottom: 0;
    font-size: 13px;
    line-height: 1.45;
  }

  .bond-card {
    gap: 8px;
  }

  .bond-card strong {
    font-size: 18px;
  }

  .attributes-strip {
    grid-template-columns: repeat(5, minmax(92px, 1fr));
    gap: 8px;
    margin-top: 12px;
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .attr-card {
    min-height: 78px;
    padding: 10px;
  }

  .attr-card strong {
    font-size: 20px;
  }

  .attr-card span {
    font-size: 12px;
  }

  .pet-choice {
    grid-template-columns: 1fr;
  }

  .pet-choice img {
    width: 100%;
    height: 150px;
  }
}
