:root {
  --bg: #0d0d14;
  --panel: #16161f;
  --card: #1c1c28;
  --line: #2a2a3a;
  --text: #e8e8f0;
  --muted: #9a9ab0;
  --accent: #e94560;
  --accent-2: #00d2a8;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}

/* ---------- header: slim bar + sticky stats strip (Blur-style) ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.topbar-row {
  display: flex; align-items: center; gap: 1rem;
  padding: .6rem 1.25rem; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: .6rem; }
.brand h1 { margin: 0; font-size: 1.25rem; letter-spacing: .5px; }
.brand .logo { height: 34px; width: 34px; border-radius: 8px; }
.live {
  display: inline-flex; align-items: center; gap: .35rem;
  font-size: .72rem; color: var(--muted); white-space: nowrap;
}
.live .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #555; display: inline-block;
}
.live.on { color: var(--accent-2); }
.live.on .dot { background: var(--accent-2); animation: pulse 2s infinite; }
@keyframes pulse {
  0%, 100% { opacity: 1; } 50% { opacity: .35; }
}
.meta { display: flex; gap: .5rem; margin-left: auto; }
.pill {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 999px; padding: .35rem .8rem; font-size: .8rem;
  white-space: nowrap;
}
.tabs { display: flex; gap: .4rem; }
.tab {
  background: var(--card); border: 1px solid var(--line); color: var(--muted);
  border-radius: 999px; padding: .45rem 1.1rem; font-size: .85rem;
  cursor: pointer; font-weight: 600;
}
.tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.statstrip {
  display: flex; gap: 1.75rem; align-items: stretch;
  padding: .45rem 1.25rem; border-top: 1px solid var(--line);
  overflow-x: auto; scrollbar-width: none;
}
.statstrip::-webkit-scrollbar { display: none; }
.sstat { display: flex; flex-direction: column; gap: .1rem; flex-shrink: 0; }
.sstat .sl {
  font-size: .66rem; color: var(--muted); text-transform: uppercase;
  letter-spacing: .5px; white-space: nowrap;
}
.sstat .sv { font-size: .95rem; font-weight: 700; white-space: nowrap; }
.sstat .sv small { color: var(--muted); font-weight: 400; font-size: .75rem; }

/* ---------- listings layout ---------- */
.layout {
  display: flex; gap: 1.25rem; padding: 1.25rem;
  max-width: 1400px; margin: 0 auto; align-items: flex-start;
}
.filters {
  width: 250px; flex-shrink: 0; background: var(--panel);
  border: 1px solid var(--line); border-radius: 12px;
  padding: 1rem; position: sticky; top: 118px;
  max-height: calc(100vh - 140px); overflow-y: auto;
}
.filter-head { display: flex; justify-content: space-between; align-items: center; }
.filter-head h2 { margin: 0; font-size: 1rem; }
.filter-head button {
  background: none; border: none; color: var(--accent);
  cursor: pointer; font-size: .85rem;
}
.field { display: block; margin: .8rem 0; }
.field span { display: block; font-size: .78rem; color: var(--muted); margin-bottom: .3rem; }
.field input, .field select {
  width: 100%; padding: .5rem .6rem; border-radius: 8px;
  border: 1px solid var(--line); background: var(--card); color: var(--text);
}
.field-row { display: flex; gap: .6rem; }
.field-row .field { flex: 1; }

/* trait groups: collapsible checkbox lists with counts (OpenSea-style) */
.tgroup { border-top: 1px solid var(--line); margin-top: .6rem; }
.tgroup summary {
  cursor: pointer; list-style: none; display: flex;
  justify-content: space-between; align-items: center;
  padding: .6rem 0; font-size: .85rem; font-weight: 600;
}
.tgroup summary::-webkit-details-marker { display: none; }
.tgroup summary::after { content: "▾"; color: var(--muted); font-size: .75rem; }
.tgroup:not([open]) summary::after { content: "▸"; }
.tgroup summary .tcount {
  font-size: .72rem; color: var(--muted); font-weight: 400;
  background: var(--card); border-radius: 999px; padding: .1rem .5rem;
}
.topt {
  display: flex; align-items: center; gap: .5rem;
  padding: .32rem 0; font-size: .82rem; cursor: pointer; color: var(--text);
}
.topt:hover { color: var(--accent-2); }
.topt input { accent-color: var(--accent-2); margin: 0; }
.topt .cnt {
  margin-left: auto; font-size: .72rem; color: var(--muted);
  background: var(--card); border-radius: 999px; padding: .08rem .45rem;
}
.topt .fl { font-size: .7rem; color: var(--muted); }

.note { font-size: .75rem; color: var(--muted); line-height: 1.4; }

/* ---------- toolbar + grid ---------- */
.results { flex: 1; min-width: 0; }
.toolbar {
  display: flex; gap: .6rem; align-items: center;
  margin-bottom: .9rem; flex-wrap: wrap;
}
#filter-toggle { display: none; padding: .5rem 1rem;
  border-radius: 8px; border: 1px solid var(--line);
  background: var(--panel); color: var(--text); cursor: pointer; }
.tsearch {
  flex: 1; min-width: 140px; padding: .55rem .8rem; border-radius: 8px;
  border: 1px solid var(--line); background: var(--panel); color: var(--text);
  font-size: .88rem;
}
#f-sort {
  padding: .55rem .6rem; border-radius: 8px; border: 1px solid var(--line);
  background: var(--panel); color: var(--text); font-size: .85rem;
}
.seg { display: flex; gap: .3rem; background: var(--panel);
  border: 1px solid var(--line); border-radius: 999px; padding: .25rem; }
.seg button {
  background: none; border: none; color: var(--muted); cursor: pointer;
  border-radius: 999px; padding: .35rem .8rem; font-size: .8rem; font-weight: 600;
  white-space: nowrap;
}
.seg button.active { background: var(--card); color: var(--text); }
.seg-sm button { padding: .3rem .65rem; font-size: .75rem; }

.grid {
  display: grid; gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
}
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; overflow: hidden;
  display: flex; flex-direction: column;
  transition: transform .12s ease, border-color .12s ease;
}
.card:hover { transform: translateY(-2px); border-color: var(--accent); }
.card img { width: 100%; aspect-ratio: 1; object-fit: cover; background: #101018; }
.card-body { padding: .8rem; display: flex; flex-direction: column; gap: .45rem; flex: 1; }
.card-name { margin: 0; font-size: .95rem; }
.card-name a { color: inherit; text-decoration: none; }
.card-name a:hover { color: var(--accent-2); }
.card > a[data-item-link] { display: block; }
.badges { display: flex; gap: .35rem; flex-wrap: wrap; }
.badge {
  font-size: .7rem; padding: .15rem .5rem; border-radius: 999px;
  background: var(--panel); border: 1px solid var(--line); color: var(--muted);
}
.badge.rarity-Legendary { color: #ffb020; border-color: #6b4d10; }
.badge.rarity-Epic { color: #c77dff; border-color: #4a2a6b; }
.badge.rarity-Rare { color: #4da3ff; border-color: #1d3f6b; }
.price { font-size: 1.05rem; font-weight: 700; }
.price small { color: var(--muted); font-weight: 400; font-size: .8rem; }
.buy {
  margin-top: auto; text-align: center; text-decoration: none;
  background: var(--accent-2); color: #06231c; font-weight: 700;
  padding: .55rem; border-radius: 8px; font-size: .9rem;
  display: inline-block;
}
.buy:hover { filter: brightness(1.1); }
.buy.sm { padding: .4rem .9rem; font-size: .8rem; margin-top: 0; }
.empty { color: var(--muted); text-align: center; padding: 3rem 1rem; }

/* compact density: Magic Eden-style inventory cards */
body[data-density="compact"] .grid {
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .7rem;
}
body[data-density="compact"] .card-body { padding: .55rem; gap: .3rem; }
body[data-density="compact"] .card-name { font-size: .8rem; }
body[data-density="compact"] .badge { font-size: .62rem; padding: .08rem .4rem; }
body[data-density="compact"] .price { font-size: .9rem; }
body[data-density="compact"] .price small { font-size: .7rem; }
body[data-density="compact"] .card .ends { display: none; }
body[data-density="compact"] .buy { padding: .4rem; font-size: .78rem; }

footer {
  padding: 1.5rem; text-align: center; color: var(--muted);
  font-size: .78rem; border-top: 1px solid var(--line); margin-top: 1rem;
}
.layout[hidden] { display: none; }

/* ---------- market view ---------- */
.market {
  max-width: 1100px; margin: 0 auto; padding: 1.25rem;
  display: flex; flex-direction: column; gap: 1rem;
}
.market[hidden], .itemview[hidden] { display: none; }
.trends-controls { display: flex; gap: .8rem; flex-wrap: wrap; align-items: center; }
.trends-note { margin: 0; }
.chart-card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 1rem;
}
.chart-card h3 { margin: 0 0 .6rem; font-size: 1rem; }
.chart-card h3 select {
  background: var(--card); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: .25rem .5rem; font-size: .9rem;
}
.chart-wrap { position: relative; }
.chart-wrap canvas { width: 100%; height: 240px; display: block; touch-action: manipulation; }
.tip {
  position: absolute; pointer-events: none; z-index: 5;
  background: #0a0a12; border: 1px solid var(--line); border-radius: 8px;
  padding: .45rem .6rem; font-size: .75rem; line-height: 1.5;
  color: var(--text); white-space: nowrap; transform: translate(-50%, -110%);
}
.tip .t { color: var(--muted); }
.legend { display: flex; gap: 1rem; flex-wrap: wrap; margin-top: .6rem;
  font-size: .78rem; color: var(--muted); }
.legend .sw { display: inline-block; width: .7rem; height: .7rem;
  border-radius: 3px; margin-right: .35rem; vertical-align: baseline; }

.market-cols { display: grid; gap: 1rem; grid-template-columns: 1fr 1fr; }
.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 1rem; min-width: 0;
}
.panel h3 { margin: 0 0 .7rem; font-size: 1rem; }
.mini-row {
  display: flex; align-items: center; gap: .7rem;
  padding: .5rem 0; border-top: 1px solid var(--line);
  text-decoration: none; color: var(--text);
}
.mini-row:first-of-type { border-top: none; }
.mini-row:hover .row-name { color: var(--accent-2); }
.row-thumb {
  width: 44px; height: 44px; border-radius: 8px; object-fit: cover;
  background: #101018; flex-shrink: 0;
}
.row-thumb-empty { display: inline-block; }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.row-name { font-size: .88rem; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub { font-size: .75rem; color: var(--muted); }
.drop-badge {
  background: #3a1020; color: #ff7ab8; border: 1px solid #6b1d36;
  border-radius: 999px; padding: .2rem .6rem; font-size: .78rem; font-weight: 700;
  white-space: nowrap;
}
.new-grid {
  display: grid; gap: 0 1.5rem; grid-template-columns: 1fr 1fr;
}

/* activity feed rows */
.ev {
  display: flex; align-items: center; gap: .7rem;
  padding: .5rem 0; border-top: 1px solid var(--line);
  text-decoration: none; color: var(--text); font-size: .85rem;
}
.ev:first-of-type { border-top: none; }
.ev:hover .row-name { color: var(--accent-2); }
.ev-ic {
  width: 30px; height: 30px; border-radius: 8px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: .9rem; font-weight: 700; background: var(--card);
  border: 1px solid var(--line);
}
.ev-listed .ev-ic { color: var(--accent-2); border-color: #0d4a3e; }
.ev-sold .ev-ic { color: #ffb020; border-color: #6b4d10; }
.ev-price_drop .ev-ic { color: #ff7ab8; border-color: #6b1d36; }
.ev-price_rise .ev-ic { color: #4da3ff; border-color: #1d3f6b; }
.ev-cancelled .ev-ic, .ev-delisted .ev-ic { color: var(--muted); }

/* ---------- item detail ---------- */
.itemview { max-width: 1100px; margin: 0 auto; padding: 1.25rem;
  display: flex; flex-direction: column; gap: 1rem; }
.back-link { color: var(--muted); text-decoration: none; font-size: .88rem;
  align-self: flex-start; }
.back-link:hover { color: var(--text); }
.item-hero { display: flex; gap: 1.2rem; align-items: flex-start; }
.item-img { width: 180px; height: 180px; border-radius: 14px; object-fit: cover;
  background: #101018; border: 1px solid var(--line); flex-shrink: 0; }
.item-head { flex: 1; min-width: 0; }
.item-head h2 { margin: 0 0 .7rem; font-size: 1.4rem; }
.item-head .note { display: inline-block; margin-top: .7rem; }

/* trait cards: value + rarity % + per-trait floor (OpenSea-style) */
.trait-cards {
  display: grid; gap: .6rem;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
}
.tcard {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 10px; padding: .6rem .7rem;
  display: flex; flex-direction: column; gap: .2rem;
}
.tcard .tc-label {
  font-size: .66rem; color: var(--muted); text-transform: uppercase;
  letter-spacing: .4px;
}
.tcard .tc-val { font-size: .92rem; font-weight: 700; }
.tcard .tc-val.rarity-Legendary { color: #ffb020; }
.tcard .tc-val.rarity-Epic { color: #c77dff; }
.tcard .tc-val.rarity-Rare { color: #4da3ff; }
.tcard .tc-meta { font-size: .72rem; color: var(--muted); }

.item-panels { display: grid; gap: 1rem; grid-template-columns: 1fr 1fr; }

/* order-book style listings table (Magic Eden-style) */
table.book { width: 100%; border-collapse: collapse; font-size: .88rem; }
.book th {
  text-align: left; font-size: .7rem; color: var(--muted);
  text-transform: uppercase; letter-spacing: .4px; font-weight: 600;
  padding: .4rem .5rem; border-bottom: 1px solid var(--line);
}
.book td { padding: .55rem .5rem; border-bottom: 1px solid var(--line); }
.book tr:last-child td { border-bottom: none; }
.book .bprice { font-weight: 700; color: var(--accent-2); white-space: nowrap; }
.book .busd { color: var(--muted); white-space: nowrap; }
.book .bends { color: var(--muted); font-size: .78rem; white-space: nowrap; }
.book td.bact { text-align: right; }

.sale-list { list-style: none; margin: 0; padding: 0; }
.sale-list li { display: flex; justify-content: space-between; align-items: baseline;
  padding: .5rem 0; border-top: 1px solid var(--line); }
.sale-list li:first-child { border-top: none; }
.sale-price { font-weight: 700; }
.comp-grid { display: grid; gap: .7rem; grid-template-columns: repeat(5, 1fr); }
.comp-card { text-decoration: none; color: var(--text); background: var(--card);
  border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.comp-card:hover { border-color: var(--accent-2); }
.comp-card img { width: 100%; aspect-ratio: 1; object-fit: cover; background: #101018; }
.comp-name { font-size: .75rem; font-weight: 600; padding: .4rem .5rem 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.comp-price { font-size: .78rem; color: var(--accent-2); font-weight: 700;
  padding: .15rem .5rem .5rem; }

/* ---------- mobile ---------- */
@media (max-width: 760px) {
  .topbar-row { padding: .55rem .8rem; gap: .6rem; }
  .brand h1 { font-size: 1.1rem; }
  .statstrip { padding: .4rem .8rem; gap: 1.2rem; }
  .layout { flex-direction: column; padding: .8rem; }
  #filter-toggle { display: block; }
  .filters {
    display: none; width: 100%; position: static; max-height: none;
  }
  .filters.open { display: block; }
  .toolbar { gap: .5rem; }
  .tsearch { order: 3; flex-basis: 100%; }
  /* dense 2-col inventory grid on phones */
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; }
  .card-body { padding: .55rem; gap: .3rem; }
  .card-name { font-size: .82rem; }
  .badge { font-size: .64rem; padding: .1rem .4rem; }
  .price { font-size: .92rem; }
  .price small { font-size: .72rem; }
  .card .ends { font-size: .7rem; }
  .buy { padding: .45rem; font-size: .8rem; }
  body[data-density="compact"] .grid { gap: .45rem; }
  body[data-density="compact"] .card-body { padding: .4rem; }

  .market { padding: .8rem; }
  .chart-wrap canvas { height: 200px; }
  .market-cols, .item-panels { grid-template-columns: 1fr; }
  .new-grid { grid-template-columns: 1fr; }
  .item-hero { gap: .8rem; }
  .item-img { width: 110px; height: 110px; }
  .item-head h2 { font-size: 1.1rem; }
  .itemview { padding: .8rem; }
  .comp-grid { grid-template-columns: repeat(3, 1fr); }
  .trait-cards { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- sets landing page ---------- */
.setsview { max-width: 1200px; margin: 0 auto; padding: 1rem 1.25rem 3rem; }
.hero { text-align: center; padding: 2.5rem 1rem 1.5rem; }
.hero-logo { width: 110px; height: 110px; border-radius: 24px; }
.hero h2 { font-size: 2.1rem; margin: .9rem 0 .3rem; letter-spacing: .5px; }
.hero .tagline { color: var(--muted); margin: 0 0 .6rem; font-size: 1.02rem; }
.hero-stats { color: var(--muted); font-size: .92rem; margin: 0 0 1.3rem; }
.hero-cta { display: flex; gap: .7rem; justify-content: center; flex-wrap: wrap; }
.btn-primary, .btn-ghost {
  display: inline-block; text-decoration: none; font-weight: 700;
  padding: .7rem 1.4rem; border-radius: 10px; font-size: .95rem;
}
.btn-primary { background: var(--accent-2); color: #06231c; }
.btn-primary:hover { filter: brightness(1.1); }
.btn-ghost { border: 1px solid var(--line); color: var(--text); background: var(--panel); }
.btn-ghost:hover { border-color: var(--accent-2); }
.sets-heading { font-size: 1.2rem; margin: 2.2rem 0 1rem; }
.sets-grid {
  display: grid; gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(215px, 1fr));
}
.set-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  overflow: hidden; text-decoration: none; color: inherit;
  transition: transform .12s ease, border-color .12s ease;
  display: flex; flex-direction: column;
}
.set-card:hover { transform: translateY(-3px); border-color: var(--accent-2); }
.set-card img { width: 100%; aspect-ratio: 1; object-fit: cover; background: #101018; }
.set-noimg { width: 100%; aspect-ratio: 1; background: #101018; }
.set-card-body { padding: .8rem .9rem; }
.set-card-body h4 { margin: 0 0 .25rem; font-size: 1rem; }
.set-card-body p { margin: 0; color: var(--muted); font-size: .82rem; }
@media (max-width: 760px) {
  .sets-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; }
  .hero { padding: 1.5rem .5rem 1rem; }
  .hero-logo { width: 84px; height: 84px; border-radius: 18px; }
  .hero h2 { font-size: 1.6rem; }
}
