:root {
  --cat-bg: #0a0a0a;
  --cat-surface: rgba(255, 255, 255, 0.035);
  --cat-surface-2: rgba(255, 255, 255, 0.06);
  --cat-border: rgba(186, 102, 234, 0.14);
  --cat-border-strong: rgba(186, 102, 234, 0.38);
  --cat-text: #f2f2f4;
  --cat-muted: #a0a0a8;
  --cat-faint: #6f6f78;
  --cat-accent: #c77dff;
  --cat-gradient: linear-gradient(135deg, #cd62ff 0%, #5b0097 100%);
  --cat-radius: 14px;
}

body {
  background: var(--cat-bg);
  color: var(--cat-text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
}

.catalog-main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 128px 16px 64px;
  min-height: 80vh;
}

.catalog-hero { margin-bottom: 1.5rem; }
.catalog-eyebrow {
  color: var(--cat-accent);
  font-size: .8rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  margin-bottom: .35rem;
}
.catalog-hero h1 {
  font-size: clamp(1.9rem, 4.5vw, 3rem);
  font-weight: 700;
  line-height: 1.15;
  margin-bottom: .5rem;
  background: linear-gradient(135deg, #fff 0%, #b9b9c3 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.catalog-lead { color: var(--cat-muted); font-size: 1.05rem; margin-bottom: .5rem; max-width: 760px; }
.catalog-meta { color: var(--cat-muted); font-size: .88rem; margin-bottom: .35rem; }
.catalog-meta strong { color: var(--cat-text); font-weight: 600; }
.catalog-note { color: var(--cat-faint); font-size: .82rem; margin: 0; }

.catalog-categories {
  display: flex;
  gap: .5rem;
  overflow-x: auto;
  padding: .25rem 0 .75rem;
  margin-bottom: .75rem;
  scrollbar-width: thin;
}
.cat-chip {
  flex: 0 0 auto;
  border: 1px solid var(--cat-border);
  background: var(--cat-surface);
  color: var(--cat-muted);
  border-radius: 999px;
  padding: .4rem .85rem;
  font-size: .88rem;
  white-space: nowrap;
  transition: border-color .2s ease, color .2s ease, background .2s ease;
}
.cat-chip:hover { color: var(--cat-text); border-color: var(--cat-border-strong); }
.cat-chip[aria-pressed="true"] {
  color: #fff;
  background: rgba(162, 0, 255, .18);
  border-color: rgba(162, 0, 255, .55);
}
.cat-chip .count { color: var(--cat-faint); margin-left: .35rem; font-variant-numeric: tabular-nums; }
.cat-chip[aria-pressed="true"] .count { color: #e5c7ff; }

.catalog-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: .6rem;
  align-items: center;
  margin-bottom: .75rem;
}
.catalog-search {
  position: relative;
  flex: 1 1 260px;
  min-width: 0;
}
.catalog-search i {
  position: absolute;
  left: .85rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--cat-faint);
}
.catalog-search input,
.catalog-filters select {
  width: 100%;
  background: #111114;
  color: var(--cat-text);
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 10px;
  padding: .55rem .8rem;
  font-size: .92rem;
}
.catalog-search input { padding-left: 2.3rem; }
.catalog-search input:focus,
.catalog-filters select:focus {
  outline: none;
  border-color: #7c3aed;
  box-shadow: 0 0 0 .2rem rgba(124, 58, 237, .25);
}
.catalog-filters {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  flex: 2 1 420px;
}
.catalog-filters label { display: flex; flex-direction: column; gap: .2rem; flex: 1 1 130px; min-width: 0; }
.catalog-filters label span { font-size: .72rem; color: var(--cat-faint); text-transform: uppercase; letter-spacing: .05em; }

.catalog-count { color: var(--cat-muted); font-size: .88rem; margin-bottom: .75rem; min-height: 1.3em; }

.catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: .85rem;
}
@media (max-width: 420px) {
  .catalog-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; }
}

.cat-card {
  display: flex;
  flex-direction: column;
  background: var(--cat-surface);
  border: 1px solid var(--cat-border);
  border-radius: var(--cat-radius);
  overflow: hidden;
  color: inherit;
  text-decoration: none;
  transition: transform .2s ease, border-color .2s ease, background .2s ease;
  min-width: 0;
}
.cat-card:hover, .cat-card:focus-visible {
  transform: translateY(-3px);
  border-color: var(--cat-border-strong);
  background: rgba(198, 76, 255, .05);
  color: inherit;
}
.cat-card-media {
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 35%, rgba(162, 0, 255, .14), rgba(255, 255, 255, .02) 70%);
  position: relative;
}
.cat-card-media img { width: 78%; height: 78%; object-fit: contain; }
.cat-noimg {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .3rem;
  color: var(--cat-faint);
  font-size: .75rem;
  text-align: center;
  padding: .5rem;
}
.cat-noimg i { font-size: 1.6rem; }
.cat-card-flags { position: absolute; top: .45rem; left: .45rem; right: .45rem; display: flex; gap: .3rem; flex-wrap: wrap; }
.cat-card-body { padding: .65rem .75rem .8rem; display: flex; flex-direction: column; gap: .3rem; min-width: 0; }
.cat-card-name {
  font-weight: 600;
  font-size: .95rem;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  word-break: break-word;
}
.cat-card-sub { color: var(--cat-faint); font-size: .75rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-card-stat { color: var(--cat-muted); font-size: .82rem; font-variant-numeric: tabular-nums; }
.cat-card-stat strong { color: var(--cat-text); }

.cat-badge {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  border-radius: 999px;
  padding: .12rem .5rem;
  font-size: .7rem;
  font-weight: 600;
  background: rgba(255, 255, 255, .08);
  color: #d9d9df;
  border: 1px solid rgba(255, 255, 255, .1);
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cat-badge.warn { background: rgba(255, 176, 32, .12); color: #ffcf73; border-color: rgba(255, 176, 32, .3); }
.cat-badge.info { background: rgba(80, 160, 255, .12); color: #9ccbff; border-color: rgba(80, 160, 255, .3); }
.rarity-Common { color: #cfcfcf; }
.rarity-Uncommon { color: #6ee7a0; border-color: rgba(110, 231, 160, .35); }
.rarity-Rare { color: #6cb6ff; border-color: rgba(108, 182, 255, .35); }
.rarity-Epic { color: #c590ff; border-color: rgba(197, 144, 255, .4); }
.rarity-Legendary { color: #ffd45e; border-color: rgba(255, 212, 94, .4); }
.rarity-Mythic { color: #ff7a7a; border-color: rgba(255, 122, 122, .4); }
.rarity-Omega { color: #ffa94d; border-color: rgba(255, 169, 77, .45); }
.rarity-Secret { color: #ff6ec7; border-color: rgba(255, 110, 199, .45); }
.rarity-Exclusive { color: #e0a3ff; border-color: rgba(224, 163, 255, .45); }
.rarity-Limited { color: #5eead4; border-color: rgba(94, 234, 212, .4); }

.cat-skeleton {
  border-radius: var(--cat-radius);
  border: 1px solid rgba(255, 255, 255, .05);
  aspect-ratio: 3 / 4;
  background: linear-gradient(100deg, rgba(255, 255, 255, .03) 30%, rgba(255, 255, 255, .07) 50%, rgba(255, 255, 255, .03) 70%);
  background-size: 300% 100%;
  animation: cat-shimmer 1.4s ease-in-out infinite;
}
@keyframes cat-shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }
@media (prefers-reduced-motion: reduce) {
  .cat-skeleton { animation: none; }
  .cat-card, .cat-card:hover { transform: none; transition: none; }
}

.cat-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 3rem 1rem;
  border: 1px dashed rgba(255, 255, 255, .12);
  border-radius: var(--cat-radius);
  color: var(--cat-muted);
}
.cat-empty i { font-size: 2rem; display: block; margin-bottom: .5rem; color: var(--cat-faint); }

.catalog-pagination { display: flex; justify-content: center; flex-wrap: wrap; gap: .35rem; margin-top: 1.5rem; }
.catalog-pagination button {
  min-width: 2.4rem;
  border: 1px solid rgba(255, 255, 255, .12);
  background: #111114;
  color: var(--cat-muted);
  border-radius: 10px;
  padding: .4rem .7rem;
  font-variant-numeric: tabular-nums;
}
.catalog-pagination button[aria-current="page"] { color: #fff; border-color: rgba(162, 0, 255, .6); background: rgba(162, 0, 255, .2); }
.catalog-pagination button:disabled { opacity: .4; }

/* ================= Entry ================= */

.catalog-back { display: inline-flex; gap: .4rem; align-items: center; color: var(--cat-muted); text-decoration: none; margin-bottom: 1rem; }
.catalog-back:hover { color: var(--cat-text); }
.entry-loading, .entry-error { color: var(--cat-muted); padding: 2rem 0; }
.entry-head {
  display: grid;
  grid-template-columns: minmax(0, 320px) minmax(0, 1fr);
  gap: 1.5rem;
  align-items: start;
  margin-bottom: 1.5rem;
}
@media (max-width: 767px) { .entry-head { grid-template-columns: minmax(0, 1fr); } }
.entry-gallery { display: flex; flex-direction: column; gap: .6rem; }
.entry-main-image {
  aspect-ratio: 1 / 1;
  border-radius: var(--cat-radius);
  border: 1px solid var(--cat-border);
  background: radial-gradient(circle at 50% 35%, rgba(162, 0, 255, .16), rgba(255, 255, 255, .02) 70%);
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 320px;
  width: 100%;
}
.entry-main-image img { width: 80%; height: 80%; object-fit: contain; }
.entry-variants { display: flex; gap: .5rem; flex-wrap: wrap; }
.entry-variant {
  width: 72px;
  border: 1px solid rgba(255, 255, 255, .12);
  background: #111114;
  border-radius: 10px;
  padding: .3rem;
  color: var(--cat-muted);
  font-size: .68rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .2rem;
}
.entry-variant[aria-pressed="true"] { border-color: rgba(162, 0, 255, .6); color: #fff; }
.entry-variant .thumb { width: 52px; height: 52px; display: flex; align-items: center; justify-content: center; }
.entry-variant img { max-width: 100%; max-height: 100%; }
.entry-title h1 { font-size: clamp(1.6rem, 4vw, 2.4rem); font-weight: 700; margin-bottom: .35rem; word-break: break-word; }
.entry-key { color: var(--cat-faint); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .82rem; word-break: break-all; }
.entry-badges { display: flex; flex-wrap: wrap; gap: .35rem; margin: .6rem 0; }
.entry-primary { font-size: 1.15rem; color: var(--cat-muted); margin-top: .5rem; }
.entry-primary strong { color: var(--cat-text); font-size: 1.4rem; }
.entry-desc { color: #d2d2d8; margin-top: .75rem; white-space: pre-line; }
.entry-banner {
  border-radius: 12px;
  padding: .75rem 1rem;
  margin-bottom: 1rem;
  font-size: .9rem;
  background: rgba(255, 176, 32, .08);
  border: 1px solid rgba(255, 176, 32, .3);
  color: #ffd896;
}

.entry-section {
  background: var(--cat-surface);
  border: 1px solid rgba(255, 255, 255, .07);
  border-radius: var(--cat-radius);
  padding: 1rem 1.1rem;
  margin-bottom: 1rem;
}
.entry-section h2 { font-size: 1.05rem; font-weight: 650; margin-bottom: .75rem; color: #fff; }
.entry-section .hint { color: var(--cat-faint); font-size: .8rem; margin: -.35rem 0 .75rem; }
.attr-table { width: 100%; border-collapse: collapse; font-size: .9rem; table-layout: fixed; }
.attr-table th, .attr-table td { padding: .45rem .5rem; border-bottom: 1px solid rgba(255, 255, 255, .06); vertical-align: top; word-break: break-word; }
.attr-table th { color: var(--cat-muted); font-weight: 500; width: 40%; }
.attr-table td { color: var(--cat-text); font-variant-numeric: tabular-nums; }
.attr-table .unit { color: var(--cat-faint); margin-left: .25rem; }
.swatch { display: inline-block; width: .9rem; height: .9rem; border-radius: 4px; vertical-align: -2px; margin-right: .35rem; border: 1px solid rgba(255, 255, 255, .25); }
.table-scroll { overflow-x: auto; }

.rel-list { display: flex; flex-direction: column; gap: .4rem; }
.rel-item {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  gap: .65rem;
  align-items: center;
  padding: .45rem .55rem;
  border-radius: 10px;
  background: rgba(255, 255, 255, .025);
  color: inherit;
  text-decoration: none;
  border: 1px solid transparent;
}
a.rel-item:hover { border-color: var(--cat-border-strong); color: inherit; }
.rel-thumb { width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; border-radius: 8px; background: rgba(255, 255, 255, .04); color: var(--cat-faint); }
.rel-thumb img { max-width: 100%; max-height: 100%; }
.rel-name { font-weight: 600; font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rel-sub { color: var(--cat-faint); font-size: .75rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rel-value { text-align: right; font-size: .82rem; color: var(--cat-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.rel-value small { display: block; color: var(--cat-faint); }
@media (max-width: 575px) {
  .rel-item { grid-template-columns: 44px minmax(0, 1fr); }
  .rel-value { grid-column: 2; text-align: left; white-space: normal; }
  .rel-value small { display: inline; margin-left: .4rem; }
}

.entry-raw summary { cursor: pointer; color: var(--cat-muted); }
.entry-raw pre {
  margin-top: .75rem;
  max-height: 480px;
  overflow: auto;
  background: #0d0d10;
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 10px;
  padding: .85rem;
  color: #d8c5ff;
  font-size: .8rem;
  white-space: pre;
}
.provenance { color: var(--cat-muted); font-size: .85rem; }
.provenance dl { display: grid; grid-template-columns: minmax(0, 180px) minmax(0, 1fr); gap: .3rem .8rem; margin: 0; }
.provenance dt { color: var(--cat-faint); font-weight: 500; }
.provenance dd { margin: 0; word-break: break-all; }
@media (max-width: 520px) { .provenance dl { grid-template-columns: minmax(0, 1fr); } .provenance dd { margin-bottom: .35rem; } }
