/* BadPet — 仿 codex-pets 视觉系统（中文） */
:root {
  --bg: #f8f6f0;
  --surface: #ffffff;
  --surface-warm: #f4f2eb;
  --surface-soft: #efede5;
  --nav-bg: rgba(248, 246, 240, 0.88);
  --nav-action-bg: rgba(255, 255, 255, 0.78);
  --ink: #0f0f0e;
  --foreground: #1c1c1a;
  --muted: #6f6f69;
  --subtle: #a3a39b;
  --border: #e4e1d9;
  --border-soft: #efede5;
  --border-strong: #d2cec3;
  --accent: #65a30d;
  --accent-deep: #4d7c0f;
  --accent-soft: #ecfccb;
  --accent-glow: rgba(101, 163, 13, 0.16);
  --primary-bg: var(--ink);
  --primary-bg-hover: #1f1f1c;
  --primary-fg: var(--surface);
  --tile-grid: rgba(180, 174, 158, 0.4);
  --preview-surface: #ffffff;
  --preview-halo: rgba(228, 225, 217, 0.74);
  --preview-soft-top: #fffdf5;
  --preview-ground: rgba(16, 16, 15, 0.06);
  --font-sans: "Cabinet Grotesk", "Noto Sans SC", -apple-system, BlinkMacSystemFont,
    "Helvetica Neue", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --shadow-sm: 0 1px 2px rgba(15, 15, 14, 0.04);
  --shadow-md: 0 6px 16px -8px rgba(15, 15, 14, 0.1);
  --shadow-lg: 0 24px 56px -24px rgba(15, 15, 14, 0.18);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --nav-h: 56px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--foreground);
  background: var(--bg);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

img {
  max-width: 100%;
  display: block;
}

/* —— Nav —— */
.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--nav-h);
  background: var(--nav-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.nav-inner {
  max-width: 1120px;
  margin: 0 auto;
  height: 100%;
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 20px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.02em;
}

.brand-logo {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  object-fit: cover;
  box-shadow: var(--shadow-sm);
}

.brand-text {
  background: linear-gradient(135deg, var(--ink) 40%, var(--accent-deep));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.nav-links {
  display: flex;
  gap: 4px;
  margin-left: 8px;
}

.nav-link {
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  transition: background 0.15s, color 0.15s;
}

.nav-link:hover,
.nav-link.active {
  color: var(--ink);
  background: var(--surface-soft);
}

.nav-actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
}

/* —— Buttons —— */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 13.5px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.15s, box-shadow 0.15s;
  white-space: nowrap;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--primary-bg);
  color: var(--primary-fg);
}

.btn-primary:hover {
  background: var(--primary-bg-hover);
}

.btn-accent {
  background: var(--accent);
  color: #fff;
}

.btn-accent:hover {
  background: var(--accent-deep);
}

.btn-ghost {
  background: var(--nav-action-bg);
  border-color: var(--border);
  color: var(--foreground);
}

.btn-ghost:hover {
  background: #fff;
  border-color: var(--border-strong);
}

.btn-lg {
  padding: 12px 20px;
  font-size: 14.5px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* —— Layout —— */
.main {
  min-height: calc(100vh - var(--nav-h) - 80px);
}

.container {
  max-width: 1120px;
  margin: 0 auto;
  padding: 28px 20px 64px;
}

/* —— Hero (home) —— */
.hero {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 28px;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: fit-content;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-deep);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.hero h1 {
  margin: 0;
  font-size: clamp(28px, 4vw, 40px);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.15;
  color: var(--ink);
}

.hero p {
  margin: 0;
  max-width: 520px;
  color: var(--muted);
  font-size: 15.5px;
}

/* —— Toolbar —— */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 22px;
}

.search-box {
  flex: 1 1 220px;
  min-width: 180px;
  position: relative;
}

.search-box input {
  width: 100%;
  padding: 10px 14px 10px 38px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.search-box input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.search-box::before {
  content: "⌕";
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--subtle);
  font-size: 16px;
  pointer-events: none;
}

.sort-tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--surface-soft);
  border-radius: 999px;
  border: 1px solid var(--border-soft);
}

.sort-tab {
  padding: 7px 14px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.sort-tab.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

.meta-line {
  color: var(--subtle);
  font-size: 13px;
  margin-left: auto;
}

/* —— Pet grid —— */
.pet-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 14px;
}

.pet-card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  overflow: hidden;
  transition: transform 0.2s var(--ease-out), box-shadow 0.2s var(--ease-out),
    border-color 0.15s;
  cursor: pointer;
}

.pet-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
}

.pet-card-preview {
  aspect-ratio: 1;
  background:
    linear-gradient(180deg, var(--preview-soft-top), var(--preview-surface)),
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 11px,
      var(--tile-grid) 11px,
      var(--tile-grid) 12px
    ),
    repeating-linear-gradient(
      90deg,
      transparent,
      transparent 11px,
      var(--tile-grid) 11px,
      var(--tile-grid) 12px
    );
  background-size: auto, 12px 12px, 12px 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  position: relative;
}

.pet-card-preview img {
  width: 72%;
  max-width: 120px;
  height: auto;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  filter: drop-shadow(0 8px 12px var(--preview-ground));
  transition: transform 0.25s var(--ease-out);
}

.pet-card:hover .pet-card-preview img {
  transform: scale(1.06) translateY(-2px);
}

.pet-card-body {
  padding: 12px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  border-top: 1px solid var(--border-soft);
}

.pet-card-name {
  font-weight: 700;
  font-size: 14px;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pet-card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.pet-card-meta span {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 2px;
}

.tag {
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
}

/* —— Detail page —— */
.detail {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 36px;
  align-items: start;
}

@media (max-width: 840px) {
  .detail {
    grid-template-columns: 1fr;
    gap: 24px;
  }
}

.detail-preview-wrap {
  position: sticky;
  top: calc(var(--nav-h) + 20px);
}

.detail-preview {
  background:
    radial-gradient(ellipse 70% 50% at 50% 70%, var(--preview-halo), transparent),
    linear-gradient(180deg, var(--preview-soft-top) 0%, var(--preview-surface) 100%);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 40px 24px 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 380px;
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
}

.detail-preview::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 15px,
      var(--tile-grid) 15px,
      var(--tile-grid) 16px
    ),
    repeating-linear-gradient(
      90deg,
      transparent,
      transparent 15px,
      var(--tile-grid) 15px,
      var(--tile-grid) 16px
    );
  opacity: 0.55;
  pointer-events: none;
}

.detail-preview img {
  position: relative;
  z-index: 1;
  /* poster 约 192x208，放大到清晰可读 */
  width: auto;
  height: auto;
  max-width: min(320px, 72%);
  max-height: min(360px, 55vh);
  object-fit: contain;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  filter: drop-shadow(0 16px 24px rgba(15, 15, 14, 0.12));
  animation: float 3.2s ease-in-out infinite;
}

@keyframes float {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-8px);
  }
}

.detail-info {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
}

.breadcrumb a {
  color: var(--muted);
}

.breadcrumb a:hover {
  color: var(--accent-deep);
}

.detail-title {
  margin: 0;
  font-size: clamp(28px, 4vw, 36px);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.detail-desc {
  margin: 0;
  color: var(--muted);
  font-size: 15.5px;
  line-height: 1.65;
}

.stat-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.stat-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
}

.stat-chip .label {
  color: var(--subtle);
  font-weight: 500;
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 4px;
}

.owner-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.owner-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-deep);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
}

.owner-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.owner-meta .name {
  font-weight: 700;
  font-size: 14px;
}

.owner-meta .handle {
  color: var(--muted);
  font-size: 12.5px;
  font-family: var(--font-mono);
}

.section-title {
  margin: 8px 0 0;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--subtle);
}

.tech-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.tech-item {
  padding: 10px 12px;
  background: var(--surface-warm);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-soft);
}

.tech-item .k {
  font-size: 11px;
  color: var(--subtle);
  font-weight: 600;
  margin-bottom: 2px;
}

.tech-item .v {
  font-size: 13px;
  font-family: var(--font-mono);
  font-weight: 500;
}

/* —— States —— */
.loading,
.empty,
.error {
  text-align: center;
  padding: 64px 20px;
  color: var(--muted);
}

.spinner {
  width: 28px;
  height: 28px;
  border: 2.5px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  margin: 0 auto 14px;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.pager {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  margin-top: 32px;
}

.pager-info {
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

/* —— 首页 Landing：介绍 + 下载 并排 —— */
.landing {
  display: grid;
  grid-template-columns: 1.2fr 0.9fr;
  gap: 28px 40px;
  align-items: center;
  margin-bottom: 48px;
  padding: 12px 0 8px;
}

@media (max-width: 840px) {
  .landing {
    grid-template-columns: 1fr;
    gap: 24px;
  }
}

.landing-intro h1 {
  margin: 10px 0 14px;
  font-size: clamp(28px, 4.2vw, 40px);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.15;
  color: var(--ink);
}

.landing-lead {
  margin: 0 0 16px;
  max-width: 36em;
  color: var(--muted);
  font-size: 15.5px;
  line-height: 1.7;
}

.landing-points {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 16px;
}

@media (max-width: 480px) {
  .landing-points {
    grid-template-columns: 1fr;
  }
}

.landing-points li {
  position: relative;
  padding-left: 18px;
  color: var(--foreground);
  font-size: 13.5px;
  font-weight: 500;
}

.landing-points li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.45em;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}

.dl-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 24px;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 14px;
}

.dl-card .dl-logo {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  object-fit: cover;
  box-shadow: var(--shadow-sm);
}

.dl-name {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.dl-meta {
  margin-top: 2px;
  font-size: 13px;
  color: var(--muted);
}

.dl-btn {
  width: 100%;
  justify-content: center;
  margin-top: 4px;
}

.dl-hint {
  margin: 0;
  text-align: center;
  font-size: 12.5px;
  color: var(--subtle);
}

.dl-hint a {
  color: var(--accent-deep);
  font-weight: 600;
}

.dl-hint a:hover {
  text-decoration: underline;
}

/* 画廊区 */
.home-section {
  margin-bottom: 40px;
  scroll-margin-top: calc(var(--nav-h) + 16px);
}

.home-section-title {
  margin: 0;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.gallery-head {
  margin-bottom: 16px;
}

.gallery-sub {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
}

/* —— Docs —— */
.doc-page {
  max-width: 720px;
}

.doc-hero {
  margin-bottom: 24px;
}

.doc-hero h1 {
  margin: 0 0 8px;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.doc-hero p {
  margin: 0;
  color: var(--muted);
}

.doc-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 22px 24px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
}

.doc-block h3 {
  margin: 0 0 12px;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.doc-block p,
.doc-block li {
  color: var(--muted);
  line-height: 1.75;
  margin: 0 0 8px;
}

.doc-block ul,
.doc-block ol {
  margin: 0 0 8px;
  padding-left: 1.3em;
}

.doc-block code,
.doc-code {
  font-family: var(--font-mono);
  font-size: 12.5px;
}

.doc-block code {
  background: var(--surface-soft);
  padding: 1px 6px;
  border-radius: 4px;
  color: var(--ink);
}

.doc-code {
  display: block;
  margin: 0;
  padding: 14px 16px;
  background: var(--terminal-bg, #11110f);
  color: var(--terminal-fg, #e8e6e0);
  border-radius: var(--radius-md);
  overflow-x: auto;
  line-height: 1.6;
  white-space: pre;
}

.doc-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}

@media (max-width: 700px) {
  .doc-grid {
    grid-template-columns: 1fr;
  }
}

.download-solo {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - var(--nav-h) - 120px);
  padding: 24px 0 48px;
}

.download-card {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 24px;
  margin-bottom: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
}

.download-card-solo {
  width: min(520px, 100%);
  margin: 0;
  flex-direction: column;
  align-items: stretch;
  padding: 36px 32px;
  gap: 28px;
}

.download-card-solo .download-card-main {
  flex-direction: column;
  text-align: center;
  gap: 14px;
}

.download-card-solo .download-card-actions {
  justify-content: center;
}

.download-card-solo .download-logo {
  width: 72px;
  height: 72px;
  border-radius: 18px;
}

.download-card-solo .btn-lg {
  min-width: 200px;
  padding: 14px 28px;
  font-size: 15px;
}

.download-card-main {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.download-logo {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  object-fit: cover;
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}

.download-title {
  margin: 0 0 4px;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.download-meta {
  margin: 0;
  font-size: 13.5px;
  color: var(--muted);
}

.download-meta.subtle {
  color: var(--subtle);
  font-size: 12.5px;
  margin-top: 2px;
}

.download-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.table-wrap {
  overflow-x: auto;
}

.doc-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.doc-table th,
.doc-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-soft);
}

.doc-table th {
  color: var(--subtle);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.doc-table td {
  color: var(--foreground);
}

.doc-table kbd {
  display: inline-block;
  padding: 1px 6px;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  background: var(--surface-soft);
  font-family: var(--font-mono);
  font-size: 12px;
}

.doc-footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
  margin-bottom: 24px;
}

.about-card {
  max-width: 640px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 32px;
  box-shadow: var(--shadow-sm);
}

.about-card h1 {
  margin: 0 0 12px;
  font-size: 28px;
  letter-spacing: -0.02em;
}

.about-card p {
  color: var(--muted);
  margin: 0 0 12px;
  line-height: 1.7;
}

.about-card ul {
  margin: 0;
  padding-left: 1.2em;
  color: var(--muted);
  line-height: 1.8;
}

/* —— Footer —— */
.footer {
  border-top: 1px solid var(--border);
  padding: 22px 20px;
  color: var(--muted);
  font-size: 13px;
}

.footer-inner {
  max-width: 1120px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  justify-content: space-between;
}

.footer-muted {
  color: var(--subtle);
}

/* skeleton */
.skeleton-grid .pet-card {
  pointer-events: none;
}

.skel {
  background: linear-gradient(90deg, var(--surface-soft), #f8f6f0, var(--surface-soft));
  background-size: 200% 100%;
  animation: shimmer 1.2s ease infinite;
  border-radius: 8px;
}

@keyframes shimmer {
  0% {
    background-position: 100% 0;
  }
  100% {
    background-position: -100% 0;
  }
}

.skel-img {
  width: 80px;
  height: 80px;
  border-radius: 12px;
}

.skel-line {
  height: 12px;
  width: 70%;
  margin-top: 4px;
}
