/* Commander Finder: mobile-first, system fonts only (no third-party requests). */
:root {
  --bg: #fbf8f4;
  --surface: #ffffff;
  --text: #1f1d1b;
  --muted: #5e5a55;
  --line: #e4ded6;
  --brand: #8a3a63;
  --brand-ink: #ffffff;
  --accent: #2f6b3a;
  --amber-bg: #fff3d6;
  --amber-ink: #6b4a00;
  --red-bg: #fde4e1;
  --red-ink: #7a1d12;
  --focus: #1a5fd0;
  --radius: 10px;
  --ebay-bg: #eef3fb;
  --ebay-line: #9db4d8;
  --ebay-ink: #23406e;
  --mark: #ffe08a;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171514; --surface: #221f1d; --text: #f1ece6; --muted: #b5ada4; --line: #3a3531;
    --brand: #d27aa6; --brand-ink: #1b1214; --accent: #8fd09b;
    --amber-bg: #3d3010; --amber-ink: #ffd98a; --red-bg: #45201b; --red-ink: #ffb4a8; --focus: #7fb0ff;
    --ebay-bg: #1c2635; --ebay-line: #3f5a82; --ebay-ink: #b9cff0; --mark: #6b5310;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  padding-bottom: 72px;
}
a { color: var(--brand); }
img { max-width: 100%; height: auto; display: block; }
h1 { font-size: 1.5rem; line-height: 1.2; margin: 0.4rem 0; }
h2 { font-size: 1.2rem; margin: 1.4rem 0 0.6rem; }
h3 { font-size: 0.95rem; margin: 0 0 0.25rem; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.vh, .skip:not(:focus) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip:focus { position: fixed; top: 8px; left: 8px; background: var(--surface); padding: 8px; z-index: 50; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }

.site-header {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--text); min-height: 44px; }
.brand-mark { font-size: 1.6rem; color: var(--brand); }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text small { color: var(--muted); }
.bundle-link { min-height: 44px; display: inline-flex; align-items: center; gap: 6px; text-decoration: none; font-weight: 600; }
.badge { background: var(--brand); color: var(--brand-ink); border-radius: 999px; padding: 0 8px; font-size: 0.8rem; }

main { max-width: 1100px; margin: 0 auto; padding: 12px 16px 24px; }
.lead { color: var(--muted); margin-top: 0; }
.label { display: block; font-weight: 600; margin: 12px 0 4px; }
.hint { margin: 4px 0 0; color: var(--muted); font-size: 0.85rem; }
input[type="text"], select {
  width: 100%; min-height: 48px; font-size: 1rem; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--text);
}
.search { position: relative; }
.suggest {
  list-style: none; margin: 4px 0 0; padding: 4px; position: absolute; left: 0; right: 0; z-index: 20;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0,0,0,.15); max-height: 60vh; overflow-y: auto;
}
.suggest-item { display: flex; align-items: center; gap: 10px; padding: 6px; border-radius: 8px; cursor: pointer; min-height: 44px; }
.suggest-item[aria-selected="true"], .suggest-item:hover { background: var(--bg); }
.thumb { width: 40px; height: auto; border-radius: 3px; }
.suggest-text { display: flex; flex-direction: column; }
.suggest-name { font-weight: 600; }
.suggest-sub { font-size: 0.85rem; color: var(--muted); display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }

.pip-row { display: inline-flex; gap: 3px; vertical-align: middle; }
.pip { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%;
  font-size: 0.7rem; font-weight: 700; border: 1px solid rgba(0,0,0,.25); color: #1f1d1b; }
.pip-W { background: #f8f3d8; } .pip-U { background: #a9d3f0; } .pip-B { background: #b9b0ab; }
.pip-R { background: #f2a68e; } .pip-G { background: #9fd3a6; } .pip-C { background: #d8d4d0; }

.popular { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.pop-tile { display: block; text-decoration: none; color: var(--text); }
.pop-tile img { border-radius: 4.75% / 3.5%; }
.pop-name { display: block; font-size: 0.8rem; margin-top: 4px; font-weight: 600; }
.precon-pick { margin-top: 8px; }
.stock-line { color: var(--muted); font-size: 0.9rem; }
.disclosure { color: var(--muted); font-size: 0.9rem; border-top: 1px solid var(--line); padding-top: 10px; margin-top: 20px; }
.notice { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.loading { color: var(--muted); }

.banner { padding: 10px 16px; font-size: 0.95rem; }
.banner-amber { background: var(--amber-bg); color: var(--amber-ink); }
.banner-strong { background: var(--red-bg); color: var(--red-ink); font-weight: 600; }
.banner a { color: inherit; font-weight: 700; }

.cmd-head { display: flex; gap: 12px; align-items: flex-start; }
.cmd-images { display: flex; gap: 6px; flex: 0 0 auto; }
.cmd-img { width: 96px; border-radius: 4.75% / 3.5%; }
.cmd-info { min-width: 0; }
.cmd-info p { margin: 4px 0; }
.precon-note { background: var(--surface); border: 1px dashed var(--line); padding: 6px 8px; border-radius: 8px; }
#partner-area { margin-top: 6px; }
.partner-search { margin-top: 6px; }

.filters {
  position: sticky; top: 64px; z-index: 5; background: var(--bg); padding: 8px 0;
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center; border-bottom: 1px solid var(--line);
}
.chips { display: flex; gap: 6px; overflow-x: auto; max-width: 100%; }
.chip {
  min-height: 44px; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); font-size: 0.9rem; cursor: pointer; white-space: nowrap;
}
.chip-on { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); font-weight: 600; }
.sel { flex: 1 1 140px; }
.sel select { min-height: 44px; padding: 6px 10px; }

.group-title .count { color: var(--muted); font-weight: 400; }
.grid { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; display: flex; flex-direction: column; }
.tile-img { padding: 0; border: 0; background: none; cursor: pointer; display: block; width: 100%; }
.tile-img img { width: 100%; border-radius: 4.75% / 3.5%; }
.img-missing { display: grid; place-items: center; aspect-ratio: 488 / 680; background: var(--bg); border: 1px dashed var(--line); border-radius: 8px; padding: 8px; text-align: center; }
.tile-body { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; flex: 1; }
.tile-name { font-size: 0.9rem; }
.price-row { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; margin: 0; }
.price { font-size: 1.25rem; font-weight: 700; }
.offer { font-size: 0.75rem; font-weight: 700; color: var(--accent); border: 1px solid currentColor; border-radius: 4px; padding: 0 4px; }
.finish { font-size: 0.8rem; color: var(--muted); }
.reason { font-size: 0.85rem; margin: 2px 0 6px; flex: 1; }
.linkish { background: none; border: 0; color: var(--brand); text-decoration: underline; padding: 0; font: inherit; cursor: pointer; min-height: 32px; text-align: left; }
.versions-chip { font-size: 0.85rem; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 8px 12px;
  border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--text);
  font: inherit; font-size: 0.95rem; cursor: pointer; text-decoration: none; text-align: center;
}
.btn-buy { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); font-weight: 700; }
.btn-add { margin-top: 6px; }
.btn-quiet { background: transparent; }
.more { margin-top: 10px; width: 100%; }

.bundle-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 15; background: var(--brand); }
.bundle-bar a { display: block; color: var(--brand-ink); padding: 14px 16px; text-decoration: none; font-weight: 600; min-height: 48px; }
.bundle-items { list-style: none; padding: 0; }
.bundle-item { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; margin-bottom: 10px; }
.bundle-item.sold-out { opacity: 0.8; border-style: dashed; }
.bundle-name { margin: 0; font-weight: 600; }
.bundle-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; align-items: center; }
.sold { color: var(--red-ink); font-weight: 600; }
.bundle-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.progress { height: 14px; background: var(--line); border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--accent); width: 0; }

.sheet { border: 0; border-radius: 16px 16px 0 0; padding: 0; width: 100%; max-width: 640px; margin: auto auto 0; max-height: 92vh; background: var(--surface); color: var(--text); }
.sheet::backdrop { background: rgba(0,0,0,.5); }
.sheet-close-row { display: flex; justify-content: flex-end; padding: 6px 8px 0; }
.sheet-body { padding: 0 16px 16px; display: flex; flex-direction: column; gap: 12px; }
.sheet-image img { width: min(260px, 70vw); margin: 0 auto; border-radius: 4.75% / 3.5%; }
.sheet-info { display: flex; flex-direction: column; gap: 8px; }
.sheet-info h2 { margin: 0; }
.versions { border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 10px; }
.version { display: flex; align-items: center; gap: 8px; min-height: 44px; }
.version input { width: 20px; height: 20px; }

.site-footer { max-width: 1100px; margin: 0 auto; padding: 16px; font-size: 0.85rem; color: var(--muted); border-top: 1px solid var(--line); }

.prose { max-width: 720px; }
.prose pre { white-space: pre-wrap; font-size: 0.8rem; background: var(--surface); border: 1px solid var(--line); padding: 10px; border-radius: 8px; }

@media (min-width: 640px) {
  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .popular { grid-template-columns: repeat(5, 1fr); }
  .cmd-img { width: 150px; }
  .sheet { border-radius: 16px; margin: auto; }
  .sheet-body { flex-direction: row; }
  .sheet-image { flex: 0 0 260px; }
}
@media (min-width: 960px) {
  .grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}

/* eBay listing data: its own labelled panel, visually separate from Scryfall data and our text
   (eBay API Licence §8.1(b)). */
.ebay-panel {
  background: var(--ebay-bg); border: 1px solid var(--ebay-line); border-radius: 8px;
  padding: 6px 8px 8px; display: flex; flex-direction: column; gap: 4px; margin-top: 4px;
}
.ebay-label {
  margin: 0; font-size: 0.7rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ebay-ink);
}
.ebay-panel .versions { background: var(--surface); }
.ebay-panel-row { flex: 1 1 100%; }

/* text filter */
.text-filter { margin: 10px 0 4px; }
.text-row { display: flex; gap: 6px; }
.text-row input { flex: 1; min-height: 44px; font-size: 1rem; padding: 8px 12px; border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--surface); color: var(--text); }
.chips-wrap { flex-wrap: wrap; overflow: visible; margin-top: 6px; }
.chip-small { min-height: 36px; padding: 4px 12px; font-size: 0.85rem; }
mark { background: var(--mark); color: inherit; border-radius: 2px; padding: 0 1px; }
.text-snippet { font-size: 0.8rem; color: var(--muted); margin: 0; }
.rules { border-left: 3px solid var(--line); padding-left: 10px; }
.rules-label { margin: 0 0 2px; font-size: 0.8rem; font-weight: 600; }
.rules-text { margin: 0; white-space: pre-line; font-size: 0.9rem; }
