.design-library {
  grid-column: 1 / -1;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid rgba(255,255,255,.09);
}

.design-library-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 12px;
}

.design-library h4 {
  margin: 0 0 5px;
  color: #fff;
  font: 700 13px Orbitron,sans-serif;
  letter-spacing: -.02em;
}

.design-library p {
  margin: 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.45;
}

.library-toggle,
.clear-library-design {
  flex: 0 0 auto;
  min-height: 29px;
  padding: 0 9px;
  border: 1px solid rgba(212,175,55,.28);
  border-radius: 8px;
  color: var(--gold-soft);
  background: rgba(212,175,55,.045);
  font: 700 8px Orbitron,sans-serif;
  letter-spacing: .04em;
}

.library-toggle:hover,
.clear-library-design:not(:disabled):hover { border-color: var(--gold); color: #fff; }
.clear-library-design:disabled { cursor: not-allowed; opacity: .38; }
.design-library-body.hide { display: none; }

.design-search { display: block; margin-bottom: 9px; }
.design-search span { display: block; margin-bottom: 5px; color: var(--muted); font-size: 8px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.design-search .input { min-height: 38px; padding: 8px 10px; font-size: 10px; }

.design-category {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
  padding-bottom: 2px;
  overflow-x: auto;
  scrollbar-width: thin;
}

.design-category button {
  flex: 0 0 auto;
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid rgba(212,175,55,.22);
  border-radius: 999px;
  color: var(--muted);
  background: transparent;
  font-size: 9px;
  white-space: nowrap;
}

.design-category button:hover { color: #fff; border-color: rgba(212,175,55,.55); }
.design-category button.active { border-color: var(--gold); color: #0d0d0d; background: var(--gold); box-shadow: 0 0 18px rgba(212,175,55,.16); }

.design-grid {
  display: grid;
  grid-template-columns: repeat(2,minmax(0,1fr));
  gap: 8px;
  max-height: 222px;
  padding: 1px 5px 3px 1px;
  overflow-y: auto;
  scrollbar-color: rgba(212,175,55,.42) rgba(255,255,255,.035);
  scrollbar-width: thin;
}

.design-template {
  position: relative;
  display: grid;
  grid-template-rows: 60px auto;
  min-width: 0;
  min-height: 100px;
  padding: 7px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.11);
  border-radius: 12px;
  color: #f5f5f5;
  background: linear-gradient(145deg,rgba(23,25,34,.98),rgba(8,9,14,.98));
  transition: transform .22s ease,border-color .22s ease,box-shadow .22s ease;
}

.design-template:hover { transform: translateY(-2px); border-color: rgba(212,175,55,.55); }
.design-template.active { border-color: #fff; box-shadow: 0 0 0 2px rgba(109,44,255,.42),0 12px 28px rgba(0,0,0,.32); }
.design-template.active::after { content: "SELECTED"; position: absolute; right: 5px; bottom: 5px; padding: 2px 5px; border-radius: 999px; color: #0d0d0d; background: var(--gold); font: 800 6px Orbitron,sans-serif; letter-spacing: .05em; }

.design-template-preview {
  display: grid;
  place-items: center;
  min-width: 0;
  height: 60px;
  overflow: hidden;
  border-radius: 8px;
  background: radial-gradient(circle,rgba(109,44,255,.1),transparent 68%),#08090d;
}

.design-template-preview svg,
.design-template-preview img {
  display: block;
  width: 100%;
  height: 52px;
  object-fit: contain;
}

.design-template-preview img { filter: grayscale(1) contrast(1.2); }
.design-template-label { min-width: 0; margin-top: 6px; overflow: hidden; color: #c8cad2; font-size: 8px; line-height: 1.3; text-align: center; text-overflow: ellipsis; white-space: nowrap; }
.template-badge { position: absolute; z-index: 2; top: 5px; right: 5px; padding: 3px 5px; border-radius: 5px; color: #fff; background: #6d2cff; font: 800 6px Orbitron,sans-serif; letter-spacing: .04em; }

.design-empty { padding: 18px 8px; text-align: center; }
.design-empty.hide { display: none; }
.design-library-footer { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 9px; padding: 8px 9px; border: 1px solid rgba(255,255,255,.07); border-radius: 9px; background: rgba(255,255,255,.02); }
.library-selection { min-width: 0; overflow: hidden; color: var(--muted); font-size: 8px; text-overflow: ellipsis; white-space: nowrap; }

.drag-selected { outline: 1px solid var(--gold); outline-offset: 5px; }
.drag-selected::after { content: "DRAG"; position: absolute; right: -6px; top: -18px; padding: 2px 5px; border-radius: 4px; color: #0d0d0d; background: var(--gold); font: 700 7px Orbitron,sans-serif; }
.studio-artwork.photo-template { mix-blend-mode: screen; filter: grayscale(1) contrast(1.55) brightness(1.1); }

.payment-details { padding: 14px; margin: 10px 0 18px; border: 1px solid var(--line); border-radius: 10px; color: var(--muted); background: rgba(109,44,255,.045); font-size: 12px; }
.payment-details b { color: var(--gold); }

html[data-theme="light"] .design-library { border-top-color: rgba(80,64,36,.1); }
html[data-theme="light"] .design-library h4 { color: #171821; }
html[data-theme="light"] .design-template { border-color: rgba(80,64,36,.12); color: #171821; background: linear-gradient(145deg,#fff,#e2e5ed); }
html[data-theme="light"] .design-template-label { color: #474c58; }
html[data-theme="light"] .design-library-footer { border-color: rgba(80,64,36,.1); background: rgba(255,255,255,.48); }

@media(max-width:1100px) {
  .design-grid { grid-template-columns: repeat(3,minmax(0,1fr)); max-height: 232px; }
}

@media(max-width:620px) {
  .design-grid { grid-template-columns: repeat(2,minmax(0,1fr)); max-height: 306px; }
}

@media(prefers-reduced-motion:reduce) {
  .design-template { transition: none; }
}
