:root {
  --bg: #050608;
  --bg-elevated: #101218;
  --accent: #00c2a8;
  --accent-soft: rgba(0, 194, 168, 0.14);
  --accent-strong: #00f0c0;
  --text: #f7f7ff;
  --text-soft: #a3a7c3;
  --border-subtle: rgba(255, 255, 255, 0.12);
  --hat-front: #202533;
  --hat-bill: #181c2b;
  --patch-fill: #8b4c2e;
}

/* RESET-ish */
*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text", sans-serif;
  background: radial-gradient(circle at top, #191c2b, #050608 46%);
  color: var(--text);
  min-height: 100vh;
}

/* Header */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px clamp(16px, 4vw, 32px);
  border-bottom: 1px solid var(--border-subtle);
  backdrop-filter: blur(16px);
  background: linear-gradient(90deg, rgba(5, 6, 8, 0.96), rgba(5, 6, 8, 0.85));
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: radial-gradient(circle at 30% 20%, var(--accent-strong), var(--accent));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  letter-spacing: 1px;
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.6);
}

.brand-text h1 {
  font-size: clamp(18px, 2.1vw, 22px);
  margin: 0;
}

.brand-text p {
  margin: 0;
  font-size: 13px;
  color: var(--text-soft);
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.catalog-link {
  font-size: 12px;
  color: var(--accent-strong);
  text-decoration: none;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--accent-soft);
  background: rgba(0, 0, 0, 0.4);
}

.catalog-link:hover {
  border-color: var(--accent);
}

.pill-btn {
  border-radius: 999px;
  border: none;
  padding: 9px 18px;
  font-size: 13px;
  font-weight: 500;
  color: #020304;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  cursor: pointer;
}

.pill-btn--secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

/* Layout */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 330px) minmax(0, 1.7fr);
  gap: 22px;
  padding: 20px clamp(16px, 4vw, 32px) 40px;
}

.config-panel {
  background: linear-gradient(145deg, #101218, #050609);
  border-radius: 24px;
  padding: 18px 18px 22px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.config-group {
  padding: 12px 12px 14px;
  border-radius: 18px;
  background: radial-gradient(circle at top left, rgba(255, 255, 255, 0.02), rgba(0, 0, 0, 0.9));
  border: 1px solid var(--border-subtle);
}

.config-group > label {
  font-size: 13px;
  font-weight: 600;
  display: block;
  margin-bottom: 6px;
}

.config-header-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}

.helper-text {
  margin: 8px 0 0;
  font-size: 11px;
  color: var(--text-soft);
}

select,
input[type="search"],
input[type="number"],
textarea {
  width: 100%;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  padding: 8px 12px;
  background: rgba(3, 4, 7, 0.9);
  color: var(--text);
  font-size: 13px;
  outline: none;
}

textarea {
  border-radius: 16px;
  resize: vertical;
}

select:focus,
input[type="search"]:focus,
input[type="number"]:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(0, 194, 168, 0.7);
}

/* Color grid */
.color-grid {
  margin-top: 8px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
  gap: 8px;
  max-height: 210px;
  overflow: auto;
}

.color-chip {
  display: flex;
  flex-direction: column;
  gap: 4px;
  border-radius: 14px;
  border: 1px solid var(--border-subtle);
  background: #050609;
  padding: 5px 6px;
  cursor: pointer;
}

.color-chip__swatch {
  height: 22px;
  border-radius: 10px;
  border: 1px solid rgba(0, 0, 0, 0.6);
}

.color-chip__name {
  font-size: 11px;
  color: var(--text-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.color-chip--active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(0, 194, 168, 0.7);
  background: var(--accent-soft);
}

/* Chips */
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  border-radius: 16px;
  border: 1px solid var(--border-subtle);
  background: #050609;
  font-size: 11px;
  padding: 4px 9px;
  color: var(--text-soft);
  cursor: pointer;
}

.chip--active {
  border-color: var(--accent);
  color: var(--accent-strong);
  background: var(--accent-soft);
}

.field-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-soft);
  margin-bottom: 4px;
}

.patch-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

/* Qty/pricing */
.qty-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.price-each {
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.7);
  border: 1px solid var(--border-subtle);
  font-size: 13px;
}

/* Summary */
.summary-card h2 {
  font-size: 14px;
  margin: 0 0 6px;
}

#summaryList {
  list-style: none;
  margin: 0 0 6px;
  padding: 0;
  font-size: 12px;
  color: var(--text-soft);
}

#summaryList li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 4px 0;
}

.summary-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  font-weight: 600;
  border-top: 1px solid var(--border-subtle);
  padding-top: 6px;
}

/* Share card */
.share-card h2 {
  font-size: 14px;
  margin: 0 0 6px;
}

/* Preview side */
.preview-panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.preview-card {
  background: radial-gradient(circle at top left, #1a1c27, #050608 52%);
  border-radius: 26px;
  padding: 18px 18px 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

/* Adjust the preview stage to a single column so that if the 3D hat mockup is hidden,
   the photo area takes up the full width. */
.preview-stage {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  align-items: center;
}

/* 3D hat */
.hat-3d-shell {
  /* Hide the 3D hat mockup entirely. The site will rely on real product photos
     (or the fallback message) instead of the stylised CSS hat shape, which looked
     unrealistic. */
  display: none;
}

.hat-3d-top,
.hat-3d-front,
.hat-3d-bill,
.hat-3d-mesh {
  position: absolute;
  border-radius: 999px;
  background: var(--hat-front);
}

.hat-3d-top {
  top: 6%;
  left: 19%;
  width: 52%;
  height: 30%;
  background: radial-gradient(circle at 30% 10%, #ffffff16, var(--hat-front));
}

.hat-3d-front {
  top: 24%;
  left: 14%;
  width: 60%;
  height: 38%;
  border-radius: 62% 40% 60% 48%;
  background: linear-gradient(135deg, var(--hat-front), #050608);
}

.hat-3d-bill {
  bottom: 6%;
  left: 6%;
  width: 82%;
  height: 28%;
  border-radius: 80% 80% 140% 140%;
  background: radial-gradient(circle at 20% 0, #ffffff14, var(--hat-bill));
}

.hat-3d-mesh {
  inset: 16% 2% 11% 54%;
  border-radius: 70% 92% 95% 40%;
  background-image: radial-gradient(circle at 1px 1px, rgba(255, 255, 255, 0.15) 1px, transparent 0);
  background-size: 6px 6px;
  opacity: 0.7;
}

/* Patch shape */
.patch-preview {
  position: absolute;
  top: 34%;
  left: 32%;
  transform: translate(-50%, -50%);
  width: 34%;
  height: 32%;
  background: var(--patch-fill);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.patch-preview--circle {
  border-radius: 999px;
}

.patch-preview--hex {
  clip-path: polygon(25% 2%, 75% 2%, 100% 50%, 75% 98%, 25% 98%, 0 50%);
}

.patch-preview--la {
  clip-path: polygon(14% 12%, 80% 12%, 84% 40%, 72% 40%, 72% 52%, 90% 52%, 90% 88%, 12% 88%, 12% 52%, 24% 52%, 24% 40%, 14% 40%);
}

/* Photo */
.hat-photo-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: 22px;
  background: radial-gradient(circle at top, #24283a, #050608);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

#hatPhoto {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.photo-fallback {
  position: absolute;
  inset: auto 10px 10px;
  font-size: 11px;
  color: var(--text-soft);
  background: rgba(0, 0, 0, 0.8);
  padding: 5px 7px;
  border-radius: 999px;
}

/* Meta */
.preview-meta {
  margin-top: 14px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

#previewTitle {
  font-size: 16px;
  margin: 0 0 4px;
}

#previewSubtitle {
  margin: 0;
  font-size: 12px;
  color: var(--text-soft);
}

.preview-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.preview-tag {
  border-radius: 99px;
  border: 1px solid var(--border-subtle);
  padding: 2px 8px;
  font-size: 10px;
  color: var(--text-soft);
  background: rgba(0, 0, 0, 0.7);
}

/* Style grid */
.grid-section {
  background: linear-gradient(145deg, #11131c, #050608);
  border-radius: 26px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  padding: 16px 16px 18px;
  margin-top: 12px;
}

.grid-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.grid-header h2 {
  font-size: 15px;
  margin: 0;
}

.grid-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.filter-chip {
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  background: #050609;
  font-size: 11px;
  padding: 4px 10px;
  color: var(--text-soft);
  cursor: pointer;
}

.filter-chip--active {
  border-color: var(--accent);
  color: var(--accent-strong);
  background: var(--accent-soft);
}

.style-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}

.style-card {
  border-radius: 16px;
  padding: 10px;
  background: radial-gradient(circle at top left, rgba(255, 255, 255, 0.04), rgba(0, 0, 0, 0.9));
  border: 1px solid rgba(255, 255, 255, 0.08);
  cursor: pointer;
}

.style-card__tag-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  margin-bottom: 6px;
}

.style-card__style {
  font-size: 12px;
  font-weight: 600;
}

.style-card__category {
  font-size: 10px;
  color: var(--text-soft);
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.7);
}

.style-card__name {
  font-size: 11px;
  color: var(--text-soft);
  margin-bottom: 5px;
}

.style-card__swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.style-card__swatch {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  border: 1px solid rgba(0, 0, 0, 0.8);
}

/* Footer */
.site-footer {
  padding: 0 24px 18px;
  text-align: center;
  font-size: 11px;
  color: var(--text-soft);
}

/* Responsive */
@media (max-width: 920px) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
  }
  .config-panel {
    order: 2;
  }
  .preview-panel {
    order: 1;
  }
  .preview-stage {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 640px) {
  .site-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  .preview-meta {
    flex-direction: column;
    gap: 6px;
  }
  .grid-header {
    flex-direction: column;
    align-items: flex-start;
  }
}