:root {
  --bg: #f2f5f9;
  --bg-alt: #e6edf5;
  --surface: #ffffff;
  --surface-hover: #f4f8fc;
  --border: rgba(24, 34, 48, 0.10);
  --border-strong: rgba(24, 34, 48, 0.16);
  --text: #182232;
  --text-muted: #6c7788;
  --accent: #7c91b4;
  --accent-soft: rgba(124, 145, 180, 0.14);
  --radius-card: 10px;
  --radius-chip: 6px;
  --space: 8px;
  --ease: cubic-bezier(0.2, 0, 0, 1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background:
    radial-gradient(circle at 18% 12%, rgba(132, 158, 196, 0.16), transparent 22%),
    radial-gradient(circle at 84% 8%, rgba(255, 255, 255, 0.62), transparent 24%),
    linear-gradient(180deg, #f7f9fc 0%, var(--bg) 38%, var(--bg-alt) 100%);
  color: var(--text);
  font-family: "Zen Kaku Gothic New", "Hiragino Sans", "Noto Sans SC", sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------- Topbar ---------- */
.topbar {
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: rgba(255, 255, 255, 0.76);
  backdrop-filter: blur(16px) saturate(120%);
  z-index: 10;
}

.topbar-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 20px 32px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.02em;
  display: flex;
  align-items: baseline;
  gap: 10px;
  color: inherit;
  text-decoration: none;
}

.brand-sub {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.14em;
  color: var(--text-muted);
}

.stats {
  font-size: 13px;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.stats strong {
  color: var(--accent);
  font-weight: 700;
}

/* ---------- Layout ---------- */
.layout {
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
  padding: 32px;
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 40px;
  flex: 1;
  align-items: start;
}

@media (max-width: 860px) {
  .layout {
    grid-template-columns: 1fr;
    padding: 20px;
    gap: 24px;
  }
}

/* ---------- Filters ---------- */
.filters {
  position: sticky;
  top: 96px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

@media (max-width: 860px) {
  .filters {
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 20px 32px;
  }
}

.filter-title {
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--text);
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.filter-title-en {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.1em;
  color: var(--text-muted);
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 12.5px;
  padding: 5px 11px;
  border-radius: var(--radius-chip);
  cursor: pointer;
  transition: border-color 160ms var(--ease), color 160ms var(--ease), background 160ms var(--ease);
  white-space: nowrap;
}

.chip:hover {
  border-color: var(--border-strong);
  color: var(--text);
}

.chip.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.clear-btn {
  appearance: none;
  border: none;
  background: none;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 12px;
  text-align: left;
  padding: 0;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: transparent;
  transition: text-decoration-color 160ms var(--ease), color 160ms var(--ease);
  width: fit-content;
}

.clear-btn:hover {
  color: var(--text);
  text-decoration-color: var(--border-strong);
}

/* ---------- Active filters ---------- */
.active-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 20px;
  min-height: 0;
}

.active-filters:empty {
  margin-bottom: 0;
}

.active-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  color: var(--accent);
  font-size: 12px;
  padding: 4px 8px 4px 11px;
  border-radius: var(--radius-chip);
}

.active-chip button {
  appearance: none;
  border: none;
  background: none;
  color: inherit;
  font-family: inherit;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0;
  opacity: 0.75;
}

.active-chip button:hover { opacity: 1; }

@keyframes page-enter {
  from {
    opacity: 0;
    transform: translateY(12px);
    filter: blur(3px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
    filter: blur(0);
  }
}

@keyframes card-enter {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.98);
    filter: blur(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0);
  }
}

body.list-entering .topbar {
  animation: page-enter 760ms var(--ease) both;
}

body.list-entering .layout {
  animation: page-enter 860ms var(--ease) both;
  animation-delay: 90ms;
}

body.list-entering .filters {
  animation: page-enter 820ms var(--ease) both;
  animation-delay: 140ms;
}

body.list-entering .active-filters {
  animation: page-enter 760ms var(--ease) both;
  animation-delay: 150ms;
}

body.list-entering .grid {
  animation: page-enter 800ms var(--ease) both;
  animation-delay: 180ms;
}

/* ---------- Grid ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 20px;
}

.card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 160ms var(--ease), border-color 160ms var(--ease), box-shadow 160ms var(--ease);
}

body.list-entering .card {
  opacity: 0;
  transform: translateY(20px) scale(0.98);
  animation: card-enter 720ms var(--ease) both;
  animation-delay: calc(var(--enter-row, 0) * 130ms + var(--enter-col, 0) * 28ms);
}

.card:hover {
  transform: translateY(-3px);
  border-color: var(--border-strong);
  box-shadow: 0 16px 36px -22px rgba(94, 113, 138, 0.35);
}

.card:target {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), 0 16px 36px -22px rgba(94, 113, 138, 0.35);
}

.card-cover {
  aspect-ratio: 1 / 1;
  background:
    radial-gradient(circle at 35% 28%, rgba(124, 145, 180, 0.08), transparent 45%),
    linear-gradient(180deg, #f7f9fc 0%, #eaf0f6 100%);
  overflow: hidden;
  position: relative;
}

.favorite-btn {
  position: absolute;
  right: 8px;
  bottom: 8px;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(10px) saturate(120%);
  color: #8d98aa;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  z-index: 2;
  box-shadow: 0 10px 22px rgba(94, 113, 138, 0.14);
  transition: transform 160ms var(--ease), color 160ms var(--ease), border-color 160ms var(--ease), background 160ms var(--ease), box-shadow 160ms var(--ease);
}

.favorite-btn:hover {
  transform: translateY(-1px) scale(1.04);
  color: #6f7c91;
  border-color: rgba(124, 145, 180, 0.22);
}

.favorite-btn.is-favorite {
  color: #e05c6a;
  border-color: rgba(224, 92, 106, 0.18);
  background: rgba(255, 246, 247, 0.82);
  box-shadow: 0 12px 24px rgba(224, 92, 106, 0.18);
}

.favorite-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent) 20%, transparent), 0 12px 24px rgba(94, 113, 138, 0.14);
}

.card-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.card-cover .fallback {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-align: center;
  padding: 12px;
}

.mode-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(255, 255, 255, 0.68);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 10px;
  letter-spacing: 0.06em;
  padding: 3px 7px;
  border-radius: var(--radius-chip);
}

.card-body {
  padding: 12px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.card-name-zh {
  font-size: 14.5px;
  font-weight: 700;
  line-height: 1.35;
  text-wrap: pretty;
}

.card-name-sub {
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.4;
  text-wrap: pretty;
}

.card-tags {
  margin-top: auto;
  padding-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.tag {
  font-size: 10.5px;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-chip);
  padding: 2px 7px;
  letter-spacing: 0.02em;
}

.tag.platform {
  color: var(--text);
  border-color: var(--border-strong);
}

.example-flag {
  position: absolute;
  top: 8px;
  left: 8px;
  background: rgba(124, 145, 180, 0.16);
  color: #304055;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 3px 6px;
  border-radius: var(--radius-chip);
}

.empty-state {
  color: var(--text-muted);
  font-size: 14px;
  padding: 60px 0;
  text-align: center;
}

/* ---------- Footer ---------- */
.foot {
  border-top: 1px solid var(--border);
  padding: 18px 32px;
  text-align: center;
}

.foot p {
  margin: 0;
  font-size: 11.5px;
  color: var(--text-muted);
}

.foot code {
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 11px;
}
