/* ── CHARACTER BUILDER CORE ── */
.builder-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.92);
  display: none; align-items: center; justify-content: center;
  z-index: 10002;
  backdrop-filter: blur(4px);
}
.builder-overlay.is-open { display: flex; }

.builder-modal {
  background: var(--void);
  border: 1px solid var(--line2);
  width: 1200px; max-width: 96vw;
  height: 800px; max-height: 92vh;
  display: flex; flex-direction: column;
  position: relative;
  box-shadow: 0 0 100px rgba(0,0,0,1);
  overflow: hidden;
}

.builder-header {
  display: flex; align-items: center;
  padding: 16px 48px 14px 24px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
  background: rgba(0,0,0,0.2);
}

.builder-title {
  font-family: 'IM Fell English', serif;
  font-size: 1.3rem;
  letter-spacing: 0.12em;
  color: #e8c97a;
  text-transform: uppercase;
  text-shadow: 0 0 10px rgba(232, 201, 122, 0.2);
}

.btn-builder-close {
  position: absolute; top: 0; right: 0; width: 42px; height: 42px;
  border: none; border-left: 1px solid var(--line); border-bottom: 1px solid var(--line);
  background: transparent; color: var(--muted); font-size: 1.5rem; cursor: pointer;
  z-index: 100; transition: all 0.2s;
}
.btn-builder-close:hover { background: rgba(139,0,0,0.15); color: var(--text); }

.builder-body {
  display: grid;
  grid-template-columns: 420px 1fr; /* Navigation/Controls on left, Preview on right */
  flex: 1;
  min-height: 0;
}

/* ── SIDEBAR & NAVIGATION ── */
.builder-sidebar {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: rgba(255,255,255,0.01);
  overflow-y: auto;
}

.sidebar-header {
  padding: 24px 24px 12px;
  font-size: 0.75rem;
  letter-spacing: 0.3em;
  color: var(--dim);
  text-transform: uppercase;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 12px 24px;
}

.sidebar-tab {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  font-family: 'Courier Prime', monospace;
  font-size: 1rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
}

.sidebar-tab:hover {
  color: var(--text);
  background: rgba(255,255,255,0.03);
}

.sidebar-tab.active {
  color: #e8c97a;
  background: rgba(232, 201, 122, 0.06);
  border-color: rgba(232, 201, 122, 0.15);
  box-shadow: inset 3px 0 0 #e8c97a;
}

.tab-icon {
  font-size: 0.8rem;
  opacity: 0.5;
}
.sidebar-tab.active .tab-icon {
  opacity: 1;
  text-shadow: 0 0 8px #e8c97a;
}

/* ── CONTROLS AREA ── */
.sidebar-controls {
  padding: 12px 24px 40px;
  border-top: 1px solid var(--line);
}

.builder-group {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 32px;
}

.builder-section {
  display: none;
  flex-direction: column;
  animation: fadeIn 0.3s ease;
}
.builder-section.active { display: flex; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.builder-section-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.builder-section-title {
  font-size: 0.85rem;
  color: var(--muted);
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.builder-section-meta {
  font-size: 0.75rem;
  color: var(--dim);
  letter-spacing: 0.1em;
}

/* ── FACE GRID ── */
.face-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.face-item {
  aspect-ratio: 1;
  background: var(--surface);
  border: 1px solid var(--line);
  cursor: pointer;
  overflow: hidden;
  transition: all 0.2s;
}
.face-item:hover { border-color: var(--line2); transform: scale(1.02); }
.face-item.active { border-color: #e8c97a; box-shadow: 0 0 10px rgba(232, 201, 122, 0.2); }

.face-thumb-wrap { width: 100%; height: 100%; pointer-events: none; position: relative; overflow: hidden; }
.face-thumb { 
  width: 100% !important;
  height: 480% !important; /* Significant zoom */
  object-fit: cover !important;
  object-position: center 25% !important; /* Raise image up to center head */
  filter: brightness(1.1); 
}

/* ── CHIPS & BUTTONS ── */
.body-chips {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
  gap: 6px;
}
.body-chip {
  padding: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}
.body-chip:hover { border-color: var(--line2); color: var(--text); }
.body-chip.active {
  border-color: #e8c97a;
  color: #e8c97a;
  background: rgba(232, 201, 122, 0.08);
}

/* ── COLOR SWATCHES ── */
.color-swatch-container {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}
.color-swatch {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  border: 1px solid rgba(255,255,255,0.2);
  transition: all 0.2s;
}
.color-swatch:hover { transform: scale(1.2); }
.color-swatch.is-active, .custom-color-input-wrapper.is-active {
  border-color: #fff;
  transform: scale(1.1);
  box-shadow: 0 0 12px rgba(255,255,255,0.4);
}

.custom-color-input-wrapper {
  position: relative;
  width: 32px;
  height: 32px;
  overflow: hidden;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.4);
  background: conic-gradient(red, yellow, lime, aqua, blue, magenta, red);
}
input[type="color"].hidden-picker {
  position: absolute;
  top: -10px; left: -10px;
  width: 50px; height: 50px;
  cursor: pointer;
  opacity: 0;
}

/* ── POSE LIST ── */
.pose-list { display: flex; flex-direction: column; gap: 8px; }
.pose-item {
  display: flex; align-items: center; gap: 16px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  cursor: pointer;
  transition: all 0.2s;
}
.pose-item:hover { background: rgba(255,255,255,0.02); }
.pose-item.active { border-color: #e8c97a; background: rgba(232, 201, 122, 0.05); }
.pose-icon { width: 24px; height: 24px; opacity: 0.5; }
.pose-item.active .pose-icon { opacity: 1; filter: drop-shadow(0 0 5px #e8c97a); }
.pose-name { font-size: 0.9rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.pose-item.active .pose-name { color: var(--text); }
.pose-accent { margin-left: auto; color: var(--dim); font-size: 0.8rem; }
.pose-item.active .pose-accent { color: #e8c97a; }

/* ── PREVIEW AREA ── */
.builder-preview {
  position: relative;
  background: radial-gradient(circle at center, #1a1a1a 0%, #050505 100%);
  overflow: hidden;
  display: flex; justify-content: center; align-items: flex-end;
}
.builder-preview::after {
  content: '';
  position: absolute; inset: 0;
  background-image: linear-gradient(var(--line) 1px, transparent 1px), linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 50px 50px;
  pointer-events: none;
  opacity: 0.2;
}

.builder-layers {
  position: relative;
  width: 100%; height: 100%;
  display: flex; justify-content: center; align-items: flex-end;
  z-index: 1;
}
.layer-body, .layer-hair, .layer-top, .layer-bottom, .layer-bra, .layer-pants, .layer-socks, .layer-shoes, .layer-jacket {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  height: 95%;
  width: auto;
  pointer-events: none;
}
.layer-body { z-index: 10; }
.layer-socks { z-index: 11; }
.layer-bottom { z-index: 12; }
.layer-pants { z-index: 13; }
.layer-bra { z-index: 14; }
.layer-top  { z-index: 15; }
.layer-shoes { z-index: 17; }
.layer-jacket { z-index: 18; }
.layer-hair { z-index: 20; }
