.collection-tools {
  position: sticky;
  top: -16px;
  z-index: 4;
  display: grid;
  grid-template-columns: minmax(150px, 2fr) repeat(3, minmax(105px, 1fr));
  gap: 7px;
  padding: 10px 0;
  background: linear-gradient(180deg, var(--bg) 82%, transparent);
}

.collection-tools input,
.collection-tools select {
  min-width: 0;
  min-height: 40px;
  padding: 7px 9px;
  color: var(--ink);
  background: #201b30;
  border: 2px solid var(--border);
  border-radius: 7px;
  font: inherit;
}

.collection-tools .compare-toggle.active {
  color: #17111f;
  background: #ffd54f;
  border-color: #fff1a6;
}

.collection-summary {
  grid-column: 1 / -1;
  color: var(--ink-dim);
  font-size: 12px;
}

.dex-cell.collection-hidden { display: none; }
.dex-cell.collection-selected { outline: 3px solid #ffd54f; outline-offset: -3px; }
.dex-cell.collection-favorite { background: linear-gradient(145deg, rgba(255,213,79,.17), rgba(255,255,255,.025)); }

.favorite-toggle {
  position: absolute;
  top: 3px;
  right: 3px;
  z-index: 2;
  width: 27px;
  height: 27px;
  padding: 0;
  border: 0;
  color: #756d82;
  background: rgba(16, 13, 24, .82);
  border-radius: 50%;
  font-size: 17px;
  line-height: 27px;
}

.favorite-toggle.on { color: #ffd54f; }
.dex-cell { position: relative; }

.collection-compare {
  margin: 4px 0 12px;
  padding: 10px;
  border: 2px solid #76679c;
  border-radius: 9px;
  background: rgba(30, 24, 46, .94);
}

.collection-compare.hidden { display: none; }
.compare-hint { color: var(--ink-dim); text-align: center; }
.compare-head,
.compare-row {
  display: grid;
  grid-template-columns: minmax(78px, .8fr) repeat(2, minmax(105px, 1fr));
  gap: 7px;
  align-items: center;
  padding: 5px 0;
  border-bottom: 1px solid rgba(255,255,255,.09);
}

.compare-head { text-align: center; font-size: 15px; }
.compare-row > span:first-child { color: var(--ink-dim); }
.compare-win { color: #82e9a8; font-weight: bold; }
.compare-reset { width: 100%; margin-top: 8px; }

.box-cell .favorite-toggle { top: 2px; right: 2px; }
.box-cell .box-tags { display: block; color: var(--ink-dim); font-size: 10px; line-height: 1.3; }

@media (max-width: 650px) {
  .collection-tools {
    top: -10px;
    grid-template-columns: 1fr 1fr;
    padding: 7px 0;
  }
  .collection-tools input { grid-column: 1 / -1; }
  .collection-tools input,
  .collection-tools select,
  .collection-tools button { min-height: 42px; font-size: 13px; }
  .compare-head,
  .compare-row { grid-template-columns: 70px repeat(2, minmax(82px, 1fr)); font-size: 12px; }
}
