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

:root {
  --bg: #101014;
  --panel: #17171c;
  --panel-2: #1f1f26;
  --line: #2a2a33;
  --text: #e8e8ec;
  --muted: #9a9aa6;
  --accent: #e8b64c;
}

html, body { height: 100%; }

body {
  display: flex;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 13px;
}

#viewport {
  position: relative;
  flex: 1;
  min-width: 0;
  background: radial-gradient(1200px 800px at 50% 30%, #23232c 0%, #101014 70%);
}

#scene { display: block; width: 100%; height: 100%; }

#drop-hint {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  color: var(--muted);
  font-size: 12px;
  pointer-events: none;
  opacity: 0.7;
}

#viewport.dragging::after {
  content: "Drop image to apply";
  position: absolute;
  inset: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px dashed var(--accent);
  border-radius: 12px;
  background: rgba(232, 182, 76, 0.08);
  color: var(--accent);
  font-size: 16px;
  pointer-events: none;
}

#panel {
  width: 300px;
  flex-shrink: 0;
  overflow-y: auto;
  background: var(--panel);
  border-left: 1px solid var(--line);
  padding: 18px 16px 32px;
}

#panel h1 { font-size: 18px; letter-spacing: 0.02em; }
#panel .subtitle { color: var(--muted); margin: 2px 0 14px; }

#panel section {
  border-top: 1px solid var(--line);
  padding: 12px 0;
}

#panel h2 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 10px;
}

.seg { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button {
  flex: 1;
  padding: 7px 0;
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
}
.seg button.active { background: var(--panel-2); color: var(--text); }
.seg.wrap { flex-wrap: wrap; }
.seg.wrap button { flex: 1 0 33%; padding: 7px 2px; font-size: 12px; }

.swatches { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.swatch {
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 2px solid var(--line);
  cursor: pointer;
}
.swatch.active { border-color: var(--accent); }
#custom-color, #makeup-color {
  width: 26px; height: 26px;
  border: 2px solid var(--line);
  border-radius: 50%;
  background: none;
  cursor: pointer;
  padding: 0;
}
#custom-color::-webkit-color-swatch-wrapper, #makeup-color::-webkit-color-swatch-wrapper { padding: 2px; }
#custom-color::-webkit-color-swatch, #makeup-color::-webkit-color-swatch { border: none; border-radius: 50%; }

.thumbs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.thumb {
  width: 40px; height: 40px;
  border-radius: 8px;
  border: 2px solid var(--line);
  cursor: pointer;
  background-size: cover;
  background-position: center;
  background-color: var(--panel-2);
  padding: 0;
}
.thumb:hover { border-color: var(--muted); }

.hint { color: var(--muted); font-size: 11px; margin: -4px 0 8px; }

#layer-list { display: flex; flex-direction: column; gap: 4px; margin: 10px 0; }
#layer-list .empty { color: var(--muted); font-size: 11px; text-align: center; padding: 4px; }
.layer-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  background: transparent;
}
.layer-row.selected { border-color: var(--accent); background: var(--panel-2); }
.layer-row img {
  width: 26px; height: 26px;
  border-radius: 5px;
  object-fit: cover;
  background: var(--panel-2);
}
.layer-row .name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.layer-row .mini {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  padding: 2px 4px;
}
.layer-row .mini:hover { color: var(--text); }

.row { display: flex; gap: 8px; margin: 8px 0; align-items: center; }

.btn {
  flex: 1;
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
  font: inherit;
}
.btn:hover { border-color: var(--muted); }
.btn.active { border-color: var(--accent); color: var(--accent); }
.btn.ghost { background: transparent; color: var(--muted); flex: 0 0 auto; }

#text-input {
  flex: 1;
  min-width: 0;
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
}
#text-btn { flex: 0 0 auto; }

.slider-row {
  display: grid;
  grid-template-columns: 58px 1fr 44px;
  align-items: center;
  gap: 8px;
  margin: 8px 0;
  color: var(--muted);
}
.slider-row output { text-align: right; color: var(--text); font-variant-numeric: tabular-nums; }

input[type="range"] {
  -webkit-appearance: none;
  height: 4px;
  border-radius: 2px;
  background: var(--line);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}

.check { display: flex; align-items: center; gap: 8px; color: var(--muted); cursor: pointer; }
.check input { accent-color: var(--accent); }
