.deck-builder-app {
  padding: 0.85rem 1rem 1.5rem;
  max-width: 1800px;
  margin: 0 auto;
}

.builder-toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 0.85rem;
}

.builder-toolbar h1 {
  margin: 0 0 0.25rem;
  font-size: 1.35rem;
}

.builder-toolbar p {
  margin: 0;
  color: #64748b;
  font-size: 0.88rem;
}

.toolbar-right {
  display: flex;
  gap: 0.5rem;
}

.builder-split {
  display: grid;
  grid-template-columns: 1fr minmax(340px, 420px);
  gap: 1rem;
  align-items: start;
}

/* ——— Library panel ——— */
.library-panel {
  min-height: calc(100vh - 8rem);
  display: flex;
  flex-direction: column;
}

.filter-bar {
  display: grid;
  grid-template-columns: 1.5fr repeat(2, 1fr);
  gap: 0.65rem;
  margin-bottom: 0.75rem;
}

.filter-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #64748b;
}

.filter-field input,
.filter-field select {
  padding: 0.55rem 0.65rem;
  border-radius: 0.45rem;
  border: 1px solid rgba(100, 120, 180, 0.2);
  background: rgba(8, 12, 24, 0.8);
  color: #e2e8f0;
  font-size: 0.88rem;
}

.library-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.65rem;
  font-size: 0.82rem;
  color: #94a3b8;
}

.page-size-label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.78rem;
  color: #64748b;
}

.page-size-label select {
  padding: 0.25rem 0.4rem;
  border-radius: 0.35rem;
  border: 1px solid rgba(100, 120, 180, 0.2);
  background: rgba(8, 12, 24, 0.8);
  color: #e2e8f0;
}

.catalog-grid {
  display: grid;
  gap: 0.65rem;
  flex: 1;
  overflow-y: auto;
  padding-bottom: 0.5rem;
}

.catalog-item {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.catalog-card-hit {
  cursor: pointer;
  border-radius: 0.45rem;
  overflow: hidden;
  border: 2px solid transparent;
  transition: border-color 0.15s;
}

.catalog-card-hit:hover,
.catalog-card-hit .vh-card.is-selected {
  border-color: rgba(99, 102, 241, 0.6);
}

.catalog-item .vh-card {
  aspect-ratio: 2.5 / 3.5;
  width: 100%;
}

.catalog-add-btn {
  padding: 0.35rem 0.5rem;
  border-radius: 0.35rem;
  border: 1px solid rgba(100, 120, 180, 0.2);
  background: rgba(30, 41, 59, 0.8);
  color: #cbd5e1;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
}

.catalog-add-btn:hover:not(:disabled) {
  border-color: rgba(99, 102, 241, 0.5);
  color: #fff;
}

.catalog-add-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.catalog-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 2rem;
}

.catalog-pagination {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  justify-content: center;
  margin-top: 0.75rem;
  padding-top: 0.65rem;
  border-top: 1px solid rgba(100, 120, 180, 0.12);
}

.page-btn {
  min-width: 2rem;
  height: 2rem;
  padding: 0 0.5rem;
  border-radius: 0.35rem;
  border: 1px solid rgba(100, 120, 180, 0.2);
  background: rgba(20, 28, 48, 0.9);
  color: #cbd5e1;
  font-size: 0.82rem;
  cursor: pointer;
}

.page-btn.active {
  background: linear-gradient(135deg, #ec4899, #a855f7);
  border-color: transparent;
  color: #fff;
}

.page-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.page-ellipsis {
  color: #64748b;
  align-self: center;
}

/* ——— Deck compose panel ——— */
.deck-compose-panel {
  position: sticky;
  top: 4rem;
  max-height: calc(100vh - 5rem);
  overflow-y: auto;
}

.deck-validation-bar {
  padding: 0.55rem 0.75rem;
  border-radius: 0.45rem;
  margin-bottom: 0.75rem;
  font-size: 0.85rem;
  font-weight: 600;
}

.deck-validation-bar.valid {
  background: rgba(34, 197, 94, 0.12);
  border: 1px solid rgba(34, 197, 94, 0.35);
  color: #86efac;
}

.deck-validation-bar.invalid {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #fca5a5;
}

.deck-validation-bar.partial {
  background: rgba(251, 191, 36, 0.1);
  border: 1px solid rgba(251, 191, 36, 0.35);
  color: #fcd34d;
}

.compose-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.65rem;
}

.compose-header h2 {
  margin: 0;
  font-size: 1rem;
  display: inline;
}

.deck-total-pill {
  margin-left: 0.5rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: rgba(99, 102, 241, 0.2);
  font-size: 0.78rem;
  color: #a5b4fc;
}

#deckName {
  flex: 1;
  min-width: 140px;
  padding: 0.45rem 0.65rem;
  border-radius: 0.45rem;
  border: 1px solid rgba(100, 120, 180, 0.2);
  background: rgba(8, 12, 24, 0.8);
  color: #e2e8f0;
}

.compose-preview {
  display: flex;
  justify-content: center;
  margin-bottom: 0.75rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid rgba(100, 120, 180, 0.1);
}

.compose-preview .preview-card-inner {
  width: min(100%, 140px);
}

.compose-preview .vh-card {
  width: 100%;
}

.deck-sections {
  display: grid;
  gap: 0.5rem;
}

.deck-section {
  border: 1px solid rgba(100, 120, 180, 0.12);
  border-radius: 0.5rem;
  overflow: hidden;
}

.deck-section summary {
  display: flex;
  justify-content: space-between;
  padding: 0.55rem 0.75rem;
  background: rgba(20, 28, 48, 0.6);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  list-style: none;
}

.deck-section summary::-webkit-details-marker {
  display: none;
}

.section-count {
  font-weight: 400;
  color: #64748b;
  font-size: 0.78rem;
}

.deck-slot-grid {
  display: grid;
  gap: 0.4rem;
  padding: 0.55rem;
}

.deck-slot {
  aspect-ratio: 2.5 / 3.5;
  border-radius: 0.35rem;
  position: relative;
  overflow: hidden;
}

.deck-slot.empty {
  border: 1px dashed rgba(100, 140, 200, 0.25);
  background: rgba(8, 12, 24, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #475569;
  font-size: 1.1rem;
}

.deck-slot.filled {
  cursor: pointer;
  border: 1px solid rgba(99, 102, 241, 0.3);
}

.deck-slot.filled .vh-card {
  width: 100%;
  height: 100%;
}

.slot-count {
  position: absolute;
  bottom: 0.15rem;
  left: 0.15rem;
  padding: 0.1rem 0.3rem;
  border-radius: 0.25rem;
  background: rgba(0, 0, 0, 0.75);
  font-size: 0.65rem;
  font-weight: 700;
  color: #fff;
}

.slot-remove {
  position: absolute;
  top: 0.1rem;
  right: 0.1rem;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 50%;
  border: none;
  background: rgba(239, 68, 68, 0.85);
  color: #fff;
  font-size: 0.85rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
}

.deck-slot.filled:hover .slot-remove {
  opacity: 1;
}

.deck-errors {
  color: #fca5a5;
  min-height: 1.25rem;
  font-size: 0.82rem;
  margin: 0.5rem 0 0;
}

.compose-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.75rem;
}

.compose-actions .btn {
  flex: 1;
  min-width: 100px;
}

.saved-decks {
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid rgba(100, 120, 180, 0.12);
}

.saved-decks h3 {
  margin: 0 0 0.5rem;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748b;
}

.saved-decks ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.35rem;
}

.saved-decks li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.55rem;
  border-radius: 0.4rem;
  background: rgba(8, 12, 24, 0.6);
  font-size: 0.82rem;
}

.help-text {
  color: #64748b;
  font-size: 0.85rem;
}

@media (max-width: 1100px) {
  .builder-split {
    grid-template-columns: 1fr;
  }

  .deck-compose-panel {
    position: static;
    max-height: none;
  }
}

@media (max-width: 640px) {
  .filter-bar {
    grid-template-columns: 1fr;
  }
}
