:root {
  --red: oklch(0.6 0.22 30);
  --red-ink: oklch(0.48 0.19 30);
  --red-tint: oklch(0.95 0.03 30);
  --ink: oklch(0.24 0.015 30);
  --ink-2: oklch(0.45 0.015 30);
  --ink-3: oklch(0.62 0.012 30);
  --line: oklch(0.9 0.008 30);
  --bg: oklch(0.985 0.004 80);
  --surface: oklch(1 0.002 80);
  --gold: oklch(0.83 0.15 85);

  --t-grass: oklch(0.62 0.15 140);
  --t-water: oklch(0.6 0.13 240);
  --t-fire: oklch(0.63 0.19 40);
  --t-lightning: oklch(0.8 0.15 90);
  --t-psychic: oklch(0.58 0.17 320);
  --t-fighting: oklch(0.55 0.11 55);
  --t-colorless: oklch(0.7 0.01 80);
  --t-trainer: oklch(0.45 0.03 260);

  --s-xs: 4px; --s-sm: 8px; --s-md: 12px; --s-lg: 16px; --s-xl: 24px; --s-2xl: 32px; --s-3xl: 48px;
  --radius: 10px;
  --display: "Bricolage Grotesque", system-ui, sans-serif;
  --body: "Atkinson Hyperlegible", system-ui, sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--body); }
button, input, select { font: inherit; color: inherit; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
[hidden] { display: none !important; }
h1, h2, h3 { font-family: var(--display); margin: 0; }

/* ---------- header ---------- */
.top { padding: var(--s-xl) clamp(16px, 4vw, 48px) var(--s-lg); display: grid; grid-template-columns: auto 1fr; gap: var(--s-xs) var(--s-xl); align-items: end; border-bottom: 1px solid var(--line); background: var(--surface); }
.brand { display: flex; align-items: center; gap: var(--s-md); text-decoration: none; color: var(--ink); font: 800 30px/1 var(--display); letter-spacing: -0.02em; }
.ball { width: 30px; height: 30px; border-radius: 50%; border: 3px solid var(--ink); background: linear-gradient(var(--red) 0 calc(50% - 1.5px), var(--ink) 0 calc(50% + 1.5px), var(--surface) 0); position: relative; flex: none; }
.ball::after { content: ""; position: absolute; inset: 50% auto auto 50%; width: 9px; height: 9px; translate: -50% -50%; border-radius: 50%; background: var(--surface); border: 3px solid var(--ink); }
.brand-sub { font-weight: 600; color: var(--ink-2); }
.owner { grid-column: 1; margin: var(--s-xs) 0 0; display: flex; align-items: center; gap: var(--s-sm); font: 800 18px/1 var(--display); letter-spacing: -0.01em; }
.crown { width: 26px; height: 22px; flex: none; transform: rotate(-8deg) translateY(-2px); }
.tag { grid-column: 1; margin: 0; color: var(--ink-2); }
.worth { grid-column: 2; grid-row: 1 / span 3; justify-self: end; display: grid; gap: var(--s-xs); }
.worth-label { font-size: 12px; color: var(--ink-3); text-align: right; }
.worth-row { display: flex; gap: var(--s-xs); }
.worth-btn { border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius); padding: var(--s-sm) var(--s-md); text-align: left; cursor: pointer; min-width: 112px; transition: border-color .2s var(--ease), background .2s var(--ease); }
.worth-btn b { display: block; font: 800 20px/1.1 var(--display); font-variant-numeric: tabular-nums; }
.worth-btn span { font-size: 12px; color: var(--ink-2); }
.worth-btn:hover { border-color: var(--ink-3); }
.worth-btn[aria-checked="true"] { border-color: var(--red); background: var(--red-tint); box-shadow: inset 0 0 0 1px var(--red); }
.worth-btn[aria-checked="true"] span { color: var(--red-ink); }

/* ---------- layout ---------- */
#list-view { display: grid; grid-template-columns: 272px 1fr; gap: var(--s-2xl); padding: var(--s-xl) clamp(16px, 4vw, 48px) var(--s-3xl); align-items: start; }
.filters { position: sticky; top: var(--s-lg); display: grid; gap: var(--s-xl); max-height: calc(100vh - 32px); overflow: auto; padding-right: var(--s-xs); }
.filters-head { display: flex; align-items: baseline; justify-content: space-between; }
.filters-head h2 { font-size: 20px; }
.link { background: none; border: 0; padding: 0; color: var(--red-ink); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.close-filters, .open-filters { display: none; }
.filters-head { gap: var(--s-md); }
.filters-head h2 { margin-right: auto; }
.search input { width: 100%; padding: var(--s-md) var(--s-lg); border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.search input:focus, select:focus { outline: 2px solid var(--red); outline-offset: 1px; }
.f-block { display: grid; gap: var(--s-sm); }
.f-block h3 { font-size: 14px; font-weight: 600; display: flex; justify-content: space-between; }
.f-block h3 small { font: 12px var(--body); color: var(--ink-3); }

.hist { display: flex; align-items: end; gap: 2px; height: 44px; }
.hist i { flex: 1; background: var(--line); border-radius: 2px 2px 0 0; min-height: 2px; transition: background .2s; }
.hist i.on { background: var(--red); opacity: .75; }
.range { position: relative; height: 22px; margin-top: -6px; }
.range input { position: absolute; inset: 0; width: 100%; appearance: none; background: none; pointer-events: none; margin: 0; }
.range input::-webkit-slider-runnable-track { height: 4px; background: transparent; }
.range::before { content: ""; position: absolute; left: 0; right: 0; top: 9px; height: 4px; border-radius: 2px; background: var(--line); }
.range input::-webkit-slider-thumb { appearance: none; pointer-events: auto; width: 20px; height: 20px; margin-top: -8px; border-radius: 50%; background: var(--surface); border: 2px solid var(--red); box-shadow: 0 1px 3px oklch(0 0 0 / .2); cursor: grab; }
.range input::-moz-range-thumb { pointer-events: auto; width: 16px; height: 16px; border-radius: 50%; background: var(--surface); border: 2px solid var(--red); cursor: grab; }
.range-vals { display: flex; justify-content: space-between; font-variant-numeric: tabular-nums; font-weight: 700; }

.chips { display: flex; flex-wrap: wrap; gap: var(--s-xs); }
.chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 4px 10px 4px 6px; cursor: pointer; font-size: 13px; }
.chip .dot { width: 14px; height: 14px; border-radius: 50%; background: var(--c); }
.chip .n { color: var(--ink-3); font-size: 12px; }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.chip[aria-pressed="true"] .n { color: oklch(0.8 0.01 30); }
.checks { display: grid; gap: 2px; }
.check { display: flex; align-items: center; gap: var(--s-sm); padding: 3px 0; cursor: pointer; }
.check input { accent-color: var(--red); width: 16px; height: 16px; margin: 0; }
.check .n { margin-left: auto; color: var(--ink-3); font-size: 13px; font-variant-numeric: tabular-nums; }

/* ---------- results ---------- */
.toolbar { display: flex; align-items: center; gap: var(--s-lg); flex-wrap: wrap; margin-bottom: var(--s-lg); }
.summary { margin: 0; flex: 1; color: var(--ink-2); }
.summary b { color: var(--ink); }
.tools { display: flex; gap: var(--s-md); font-size: 13px; color: var(--ink-2); }
.tools select { margin-left: 4px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.group-h { display: flex; align-items: baseline; gap: var(--s-md); margin: var(--s-2xl) 0 var(--s-md); font-size: 22px; }
.group-h:first-child { margin-top: 0; }
.group-h small { font: 14px var(--body); color: var(--ink-3); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: var(--s-xl) var(--s-lg); }

.card { display: grid; gap: var(--s-sm); text-decoration: none; color: inherit; animation: rise .4s var(--ease) both; }
.card .pic { position: relative; aspect-ratio: 3 / 4; border-radius: var(--radius); overflow: hidden; background: var(--line); }
.card img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .35s var(--ease); }
.card:hover img { transform: scale(1.04); }
.card:focus-visible { outline: 2px solid var(--red); outline-offset: 4px; border-radius: var(--radius); }
.badges { position: absolute; top: 8px; left: 8px; right: 8px; display: flex; gap: 4px; flex-wrap: wrap; }
.badge { font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 999px; background: oklch(1 0 0 / .92); color: var(--ink); }
.badge.holo { background: var(--gold); }
.badge.est { background: oklch(0.24 0.015 30 / .82); color: var(--surface); }
.card .meta { display: grid; gap: 1px; }
.card .row1 { display: flex; justify-content: space-between; gap: var(--s-sm); align-items: baseline; }
.card .nm { font-weight: 700; line-height: 1.25; }
.card .price { font: 800 17px/1 var(--display); font-variant-numeric: tabular-nums; white-space: nowrap; }
.card .sub { font-size: 13px; color: var(--ink-2); display: flex; align-items: center; gap: 6px; }
.tdot { width: 9px; height: 9px; border-radius: 50%; background: var(--c); flex: none; }
.empty { padding: var(--s-3xl) 0; text-align: center; color: var(--ink-2); }
.empty button { margin-top: var(--s-md); }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }

/* ---------- detail ---------- */
#detail-view { padding: var(--s-xl) clamp(16px, 4vw, 48px) var(--s-3xl); max-width: 1080px; }
.crumbs { display: flex; justify-content: space-between; align-items: center; margin-bottom: var(--s-xl); }
.crumbs a, .pager a { color: var(--ink-2); text-decoration: none; }
.crumbs a:hover, .pager a:hover { color: var(--red-ink); }
.pager { display: flex; gap: var(--s-lg); font-size: 14px; }
.pager .off { opacity: .35; pointer-events: none; }
.d-wrap { display: grid; grid-template-columns: minmax(240px, 380px) 1fr; gap: var(--s-3xl); align-items: start; }
.d-img { width: 100%; border-radius: 14px; display: block; box-shadow: 0 10px 30px oklch(0.24 0.015 30 / .18); }
.d-info { display: grid; gap: var(--s-xl); }
.d-title h1 { font-size: clamp(30px, 4vw, 44px); line-height: 1.05; letter-spacing: -0.02em; }
.d-title p { margin: var(--s-sm) 0 0; color: var(--ink-2); display: flex; gap: var(--s-sm); align-items: center; flex-wrap: wrap; }
.ladder { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.ladder div { padding: var(--s-md) var(--s-lg); display: grid; gap: 2px; }
.ladder div + div { border-left: 1px solid var(--line); }
.ladder span { font-size: 12px; color: var(--ink-2); }
.ladder b { font: 800 22px/1.1 var(--display); font-variant-numeric: tabular-nums; }
.ladder .sel { background: var(--red-tint); }
.ladder .sel span { color: var(--red-ink); }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: var(--s-sm) var(--s-xl); margin: 0; }
.facts dt { color: var(--ink-3); }
.facts dd { margin: 0; }
.note { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--s-md) var(--s-lg); font-size: 14px; color: var(--ink-2); }
.note b { color: var(--ink); }

.foot { padding: var(--s-xl) clamp(16px, 4vw, 48px); color: var(--ink-3); font-size: 12px; border-top: 1px solid var(--line); }

/* ---------- mobile ---------- */
@media (max-width: 820px) {
  .top { grid-template-columns: 1fr; }
  .worth { grid-column: 1; grid-row: auto; justify-self: stretch; margin-top: var(--s-md); }
  .worth-label { text-align: left; }
  .worth-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--s-sm); }
  .worth-btn { min-width: 0; padding: var(--s-sm) var(--s-md); }
  .worth-btn b { font-size: 19px; }
  .brand { font-size: 26px; }
  .top { padding-top: var(--s-lg); }
  .toolbar { position: sticky; top: 0; z-index: 5; background: var(--bg); margin: 0 -16px var(--s-md); padding: var(--s-sm) 16px; border-bottom: 1px solid var(--line); gap: var(--s-sm); }
  .tools { gap: var(--s-sm); }
  .tools select { padding: 6px 4px; }
  #list-view { padding-top: 0; }
  .filters-head { position: sticky; top: calc(-1 * var(--s-xl)); background: var(--bg); padding: var(--s-sm) 0; z-index: 1; }
  .card .row1 { flex-direction: column; gap: 2px; }
  .crumbs { flex-wrap: wrap; gap: var(--s-sm); }
  #list-view { grid-template-columns: 1fr; }
  .filters { position: fixed; inset: 0; z-index: 10; max-height: none; background: var(--bg); padding: var(--s-xl); transform: translateY(100%); transition: transform .35s var(--ease); }
  .filters.open { transform: none; }
  .close-filters { display: inline-block; border: 0; background: var(--ink); color: var(--surface); border-radius: 999px; padding: 6px 14px; }
  .open-filters { display: inline-block; border: 1px solid var(--ink); background: var(--surface); border-radius: 999px; padding: 6px 14px; font-weight: 700; }
  .summary { flex-basis: 100%; order: 3; }
  .grid { grid-template-columns: repeat(2, 1fr); gap: var(--s-lg) var(--s-md); }
  .d-wrap { grid-template-columns: 1fr; gap: var(--s-xl); }
  .d-img { max-width: 320px; margin: 0 auto; }
  .ladder { grid-template-columns: repeat(2, 1fr); }
  .ladder div:nth-child(3) { border-left: 0; }
  .ladder div:nth-child(n+3) { border-top: 1px solid var(--line); }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
