/* Collection page: view toggle, size presets, list view. */
.view-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.view-bar .result-count { margin: 0; }

.view-toggle { display: flex; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.view-toggle button {
  border: none; background: var(--bg-card); color: var(--text-dim);
  padding: 7px 12px; font-size: 12px; font-weight: 700;
}
.view-toggle button:not(:first-child) { border-left: 1px solid var(--border); }
.view-toggle button.active { background: var(--yellow); color: #0a0a0f; }
.view-toggle button:focus-visible { outline: 2px solid var(--cyan); outline-offset: -2px; }

/* Card sizes. min(100%, ...) keeps a grid from forcing a phone wider. */
.card-grid.size-lg { grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); }
.card-grid.size-md { grid-template-columns: repeat(auto-fill, minmax(min(100%, clamp(136px, 14vw, 190px)), 1fr)); }
.card-grid.size-sm { grid-template-columns: repeat(auto-fill, minmax(min(100%, 84px), 1fr)); gap: 8px; }
.card-grid.size-sm .need-card-info { display: none; }
.card-grid.size-sm .need-card { contain-intrinsic-size: auto 120px; border-radius: 6px; }
.card-grid.size-lg .need-card-name { font-size: 14px; }

.own-qty {
  position: absolute; left: 50%; bottom: 6px; transform: translateX(-50%);
  background: rgba(7, 7, 11, .88); color: var(--yellow);
  border: 1px solid var(--yellow); border-radius: 12px;
  padding: 1px 9px; font-size: 13px; font-weight: 800; font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.own-qty small { font-size: 10px; font-weight: 600; color: var(--text-dim); }
.size-sm .own-qty { font-size: 11px; padding: 0 6px; bottom: 3px; }
.size-sm .own-qty small { display: none; }

.need-card.own-missing .need-card-img-wrap img { opacity: .35; filter: grayscale(.8); }
.need-card.own-missing .own-qty { color: var(--text-dim); border-color: var(--border); }
.need-card.own-full .own-qty { color: var(--green); border-color: var(--green); }

/* List view: rarity sections */
.own-list { display: flex; flex-direction: column; gap: 10px; }
.rar-group { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--bg-card); }
.rar-head {
  width: 100%; display: flex; align-items: center; gap: 10px; text-align: left;
  padding: 10px 14px; border: none; background: rgba(255, 255, 255, .03);
  color: var(--text); font-size: 14px; font-weight: 800; cursor: pointer;
}
.rar-head:hover { background: rgba(255, 255, 255, .06); }
.rar-head:focus-visible { outline: 2px solid var(--cyan); outline-offset: -2px; }
.rar-head .rarity-icon { width: 22px; height: 22px; flex: none; }
.rar-title { white-space: nowrap; }
.rar-count { margin-left: auto; font-size: 11px; font-weight: 600; color: var(--text-dim); text-align: right; }
.rar-caret { width: 8px; height: 8px; flex: none; border-right: 2px solid var(--text-dim); border-bottom: 2px solid var(--text-dim); transform: rotate(45deg); margin: -3px 2px 0 4px; transition: transform .2s; }
.rar-group.shut .rar-caret { transform: rotate(-45deg); margin: 0 2px 0 4px; }

.own-row {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 220px) 70px;
  gap: 12px; align-items: center; padding: 8px 14px;
  border-top: 1px solid var(--border); color: var(--text);
}
.own-row:hover { background: rgba(245, 228, 0, .06); }
.own-name { display: flex; align-items: center; gap: 10px; min-width: 0; }
.own-name a { color: inherit; text-decoration: none; min-width: 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: 1px 7px; }
.own-name a:hover b { color: var(--yellow); }
.own-num { font-size: 12px; color: var(--cyan); font-variant-numeric: tabular-nums; }
.own-name b { font-size: 14px; }
.own-name i { font-size: 12px; color: var(--text-dim); }
.own-set-m { display: none; font-size: 11px; color: var(--text-dim); flex-basis: 100%; }
.own-pic {
  flex: none; width: 30px; height: 30px; display: grid; place-items: center;
  border: 1px solid var(--border); border-radius: 6px; background: transparent;
  color: var(--text-dim); cursor: pointer; padding: 0;
}
.own-pic:hover, .own-pic:focus-visible { color: var(--yellow); border-color: var(--yellow); outline: none; }
.own-col-set { font-size: 12px; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.own-col-qty { text-align: right; font-size: 16px; font-weight: 800; color: var(--yellow); font-variant-numeric: tabular-nums; }
.own-col-qty small { font-size: 11px; font-weight: 600; color: var(--text-dim); }
.own-row.own-missing .own-name b, .own-row.own-missing .own-col-qty { color: var(--text-dim); }
.own-row.own-full .own-col-qty { color: var(--green); }

/* Card preview (hover on desktop, tap on touch) */
#card-pop { position: fixed; z-index: 60; width: 260px; pointer-events: none; filter: drop-shadow(0 12px 30px rgba(0, 0, 0, .7)); }
#card-pop img { width: 100%; display: block; border-radius: 12px; border: 1px solid var(--yellow); background: #000; }
#card-pop.centered { left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(78vw, 300px); }
#card-pop[hidden] { display: none; }

@media (max-width: 720px) {
  .own-row { grid-template-columns: minmax(0, 1fr) 52px; padding: 8px 12px; gap: 8px; }
  .own-col-set { display: none; }
  .own-set-m { display: block; }
  .own-pic { width: 36px; height: 36px; }
  .rar-head { padding: 12px; }
  .rar-count { font-size: 10px; }
}

/* Card view popup */
body.modal-open { overflow: hidden; }
#card-modal {
  position: fixed; inset: 0; z-index: 80; background: rgba(4, 4, 8, .82);
  display: flex; align-items: center; justify-content: center; padding: 16px; overflow-y: auto;
}
#card-modal[hidden] { display: none; }
.cm-box {
  position: relative; display: grid; grid-template-columns: minmax(0, 340px) minmax(0, 1fr); gap: 24px;
  width: min(100%, 820px); max-height: calc(100dvh - 32px); overflow-y: auto; margin: auto;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; padding: 22px;
}
.cm-art { width: 100%; border-radius: 12px; border: 1px solid var(--yellow); background: #000; align-self: start; }
.cm-close {
  position: absolute; top: 8px; right: 10px; width: 36px; height: 36px; border-radius: 8px;
  background: rgba(7, 7, 11, .75); border: 1px solid var(--border); color: var(--text); font-size: 24px; line-height: 1; cursor: pointer; z-index: 1;
}
.cm-close:hover { background: rgba(255, 255, 255, .14); }
.cm-close:focus-visible { outline: 2px solid var(--cyan); outline-offset: 1px; }
.cm-info { min-width: 0; padding-right: 30px; }
.cm-info h2 { margin: 0; font-size: 22px; line-height: 1.2; }
.cm-sub { color: var(--text-dim); font-style: italic; margin-top: 2px; }
.cm-meta { font-size: 12px; color: var(--text-dim); margin-top: 6px; }
.cm-stats { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.cm-stat { display: flex; gap: 6px; align-items: baseline; padding: 4px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; font-weight: 700; }
.cm-stat small { font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--text-dim); font-weight: 600; }
.cm-owned { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px; }
.cm-owned > div { border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font-size: 13px; color: var(--text-dim); }
.cm-owned > div.on { border-color: var(--yellow); }
.cm-owned small { display: block; font-size: 10px; letter-spacing: .08em; text-transform: uppercase; }
.cm-owned b { font-size: 20px; color: var(--yellow); }
.cm-rules { margin-top: 14px; font-size: 14px; line-height: 1.5; white-space: pre-line; }
@media (max-width: 720px) {
  .cm-box { grid-template-columns: minmax(0, 1fr); padding: 16px; gap: 14px; }
  .cm-art { width: min(100%, 300px); justify-self: center; }
  .cm-info { padding-right: 0; }
}
