*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: #1a1a2e;
  color: #e0e0e0;
  min-height: 100vh;
}

/* --- Toolbar --- */
.toolbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: #16213e;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  border-bottom: 1px solid #0f3460;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.toolbar-left {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.toolbar h1 {
  font-size: 1.2rem;
  font-weight: 600;
  color: #e0e0e0;
  white-space: nowrap;
}

.card-count {
  font-size: 0.85rem;
  color: #8888aa;
  white-space: nowrap;
}

.toolbar-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.toolbar-controls input,
.toolbar-controls select {
  background: #1a1a2e;
  color: #e0e0e0;
  border: 1px solid #0f3460;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 0.85rem;
  outline: none;
  transition: border-color 0.2s;
}

.toolbar-controls input:focus,
.toolbar-controls select:focus {
  border-color: #e94560;
}

.toolbar-controls input {
  width: 200px;
}

.toolbar-controls select {
  max-width: 200px;
  cursor: pointer;
}

.toolbar-controls select#set-filter {
  max-width: 360px;
}

/* --- Slider --- */
.slider-group {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  font-size: 0.85rem;
  color: #e0e0e0;
}

.slider-group label {
  cursor: default;
}

.slider-group input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 140px;
  height: 20px;
  background: transparent;
  outline: none;
  border: none;
  padding: 0;
  cursor: pointer;
}

.slider-group input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  background: #0f3460;
  border-radius: 3px;
}

.slider-group input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #e94560;
  cursor: pointer;
  margin-top: -5px;
}

.slider-group input[type="range"]::-moz-range-track {
  height: 6px;
  background: #0f3460;
  border-radius: 3px;
  border: none;
}

.slider-group input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #e94560;
  border: none;
  cursor: pointer;
}

/* --- Card Grid --- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(var(--cols, 5), 1fr);
  gap: 12px;
  padding: 20px;
}


/* --- Card Tile --- */
.card-tile {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  aspect-ratio: 488 / 680;
  background: #16213e;
  cursor: pointer;
  border: 3px solid transparent;
  transition: border-color 0.15s;
}

.card-tile.in-list {
  border-color: #ff2d95;
  box-shadow: 0 0 12px rgba(255, 45, 149, 0.45);
}

.card-tile img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.2s;
}

.card-tile:hover img {
  transform: scale(1.03);
}

/* Quantity badge — always visible */
.qty-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  background: #e94560;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
  z-index: 3;
  pointer-events: none;
}

/* Info overlay — visible by default */
.card-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.85) 0%, rgba(0,0,0,0.4) 40%, transparent 60%);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 12px;
  opacity: 1;
  transition: opacity 0.2s;
  pointer-events: none;
  z-index: 2;
}

/* When info is hidden, only show on hover */
.card-grid.hide-info .card-overlay {
  opacity: 0;
}

.card-grid.hide-info .card-tile:hover .card-overlay {
  opacity: 1;
}

.card-overlay .card-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: #fff;
  line-height: 1.2;
  margin-bottom: 4px;
}

.card-overlay .card-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  color: #bbb;
}

.card-overlay .foil-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.foil-badge.foil {
  background: linear-gradient(135deg, #c0a44d, #e6d78e, #c0a44d);
  color: #1a1a2e;
}

.foil-badge.etched {
  background: linear-gradient(135deg, #7b8ab8, #c4cfe6, #7b8ab8);
  color: #1a1a2e;
}

/* --- List toggle & Export button --- */
.list-toggle {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.85rem;
  color: #e0e0e0;
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
}

.list-toggle input[type="checkbox"] {
  accent-color: #ff2d95;
  width: 15px;
  height: 15px;
  cursor: pointer;
}

.export-btn {
  background: #ff2d95;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 6px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s;
}

.export-btn:hover {
  background: #e0247f;
}

/* --- Modal --- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal.hidden {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
}

.modal-content {
  position: relative;
  background: #16213e;
  border: 1px solid #0f3460;
  border-radius: 12px;
  padding: 24px;
  width: 90%;
  max-width: 400px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.modal-content h2 {
  font-size: 1.1rem;
  color: #e0e0e0;
  margin-bottom: 6px;
}

.modal-content p {
  font-size: 0.85rem;
  color: #8888aa;
  margin-bottom: 16px;
}

.modal-content label {
  font-size: 0.8rem;
  color: #aaa;
  display: block;
  margin-bottom: 4px;
}

.modal-content input[type="text"] {
  width: 100%;
  background: #1a1a2e;
  color: #e0e0e0;
  border: 1px solid #0f3460;
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 0.9rem;
  outline: none;
  margin-bottom: 18px;
}

.modal-content input[type="text"]:focus {
  border-color: #e94560;
}

.modal-buttons {
  display: flex;
  gap: 8px;
}

.modal-btn {
  flex: 1;
  padding: 8px 12px;
  border: none;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.modal-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.download-btn {
  background: #0f3460;
  color: #e0e0e0;
}

.download-btn:hover:not(:disabled) {
  background: #1a4a7a;
}

.send-btn {
  background: #ff2d95;
  color: #fff;
}

.send-btn:hover:not(:disabled) {
  background: #e0247f;
}

.cancel-btn {
  background: transparent;
  color: #8888aa;
  border: 1px solid #0f3460;
}

.cancel-btn:hover {
  background: #1a1a2e;
}

/* --- Loading --- */
.loading {
  text-align: center;
  padding: 60px 20px;
  color: #8888aa;
  font-size: 1rem;
}

.loading.hidden {
  display: none;
}

/* --- Empty state --- */
.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
  color: #8888aa;
  font-size: 1rem;
}

/* --- Responsive --- */
@media (max-width: 600px) {
  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar-left {
    justify-content: space-between;
  }

  .toolbar-controls {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .toolbar-controls > input,
  .toolbar-controls > select {
    width: 100%;
    max-width: none !important;
  }

  .toolbar-controls > .slider-group {
    width: 100%;
  }

  .toolbar-controls > .list-toggle,
  .toolbar-controls > .export-btn {
    width: auto;
  }

  .card-grid {
    grid-template-columns: repeat(var(--cols, 2), 1fr);
    gap: 8px;
    padding: 12px;
  }

}
