/* 다크 모드 전용 — OLED true black 바탕, 포인트 색 하나(앰버) */
:root {
  --bg: #000;
  --surface: #0b0b0d;
  --surface-2: #141417;
  --surface-3: #1c1c20;
  --line: #26262c;
  --line-strong: #3a3a42;
  --text: #e8e6e1;        /* 순백 대신 따뜻한 오프화이트: 저조도에서 눈부심 완화 */
  --muted: #a09fa6;
  --faint: #6f6e76;
  --accent: #ffb224;
  --accent-soft: rgba(255, 178, 36, 0.14);
  --accent-ink: #1b1300;
  /* 검정 위에서는 어두운 그림자가 안 보이므로, 윗면 하이라이트 + 옅은 후광으로 깊이를 준다 */
  --lift: inset 0 1px 0 rgba(255, 255, 255, 0.045), 0 0 0 1px var(--line), 0 10px 40px rgba(255, 255, 255, 0.022);
  --radius: 12px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 "Pretendard", "Segoe UI", "Malgun Gothic", "Apple SD Gothic Neo", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.top {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
}
.top h1 {
  margin: 0;
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 9px;
  white-space: nowrap;
}
.dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 12px rgba(255, 178, 36, 0.7);
}
.top-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

main {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 16px 16px;
}

/* ── 3D 뷰포트 ── */
.stage {
  flex: 1 1 auto;
  min-height: max(320px, 44vh);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.frame {
  position: relative;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 0 0 1px var(--line-strong), 0 0 60px rgba(255, 255, 255, 0.035);
  background: #000;
}
.frame canvas { display: block; width: 100%; height: 100%; touch-action: none; outline: none; }
/* 구도 요약: 화면을 가리지 않도록 뷰포트 바로 아래에 둔다 */
.readout {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: center;
  gap: 2px 18px;
}
#summary { font-weight: 650; font-size: 16px; color: var(--accent); letter-spacing: -0.01em; }
#stats { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
#stats b { color: var(--text); font-weight: 600; }

.hints {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 16px;
  font-size: 12px;
  color: var(--muted);
}
kbd {
  font: inherit;
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 5px;
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--line), inset 0 -1px 0 var(--line-strong);
  color: var(--text);
}
kbd.k-accent { color: var(--accent); }

/* ── 프롬프트 ── */
.promptbar {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--lift);
  padding: 10px 12px 12px 14px;
}
.prompt-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.label { font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: 0.04em; }
.prompt {
  margin: 0;
  font: 13.5px/1.6 ui-monospace, "Cascadia Code", Consolas, "Malgun Gothic", monospace;
  color: var(--text);
  user-select: text;
  overflow-wrap: anywhere;
  min-height: 3.2em;
}

/* ── 컨트롤 패널 ── */
.controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 10px;
}
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--lift);
  padding: 12px 12px 13px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}
.card h2 {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.04em;
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.card h2 small { font-weight: 500; color: var(--faint); letter-spacing: 0; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
/* 인물 방향: 위 = 카메라를 봄, 아래 = 등을 보임, 좌우 = 화면에서 향하는 쪽 */
.chips.dir {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-areas: "fl front fr" "l . r" "bl back br";
}
.chips.dir .chip { padding: 5px 4px; }
.chips.dir [data-id=fl] { grid-area: fl; }
.chips.dir [data-id=front] { grid-area: front; }
.chips.dir [data-id=fr] { grid-area: fr; }
.chips.dir [data-id=l] { grid-area: l; }
.chips.dir [data-id=r] { grid-area: r; }
.chips.dir [data-id=bl] { grid-area: bl; }
.chips.dir [data-id=back] { grid-area: back; }
.chips.dir [data-id=br] { grid-area: br; }

.chip, .btn, .seg button {
  font: inherit;
  color: var(--text);
  background: var(--surface-2);
  border: 0;
  border-radius: 8px;
  box-shadow: inset 0 0 0 1px var(--line), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  cursor: pointer;
  transition: background 0.12s, box-shadow 0.12s, color 0.12s;
}
.chip { padding: 5px 10px; font-size: 13px; white-space: nowrap; }
.btn { padding: 6px 12px; font-size: 13px; font-weight: 550; white-space: nowrap; }
.btn.small { padding: 5px 10px; font-size: 12.5px; }
.chip:hover, .btn:hover, .seg button:hover { background: var(--surface-3); box-shadow: inset 0 0 0 1px var(--line-strong); }
.chip:focus-visible, .btn:focus-visible, .seg button:focus-visible, .text:focus-visible, input[type=range]:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
.chip.on, .seg button.on {
  background: var(--accent-soft);
  color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}
.btn.primary {
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
  box-shadow: 0 0 22px rgba(255, 178, 36, 0.22);
}
.btn.primary:hover { background: #ffc24d; box-shadow: 0 0 28px rgba(255, 178, 36, 0.34); }
.btn:disabled { opacity: 0.38; cursor: not-allowed; }

.seg { display: flex; gap: 4px; padding: 3px; border-radius: 10px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); }
.seg button { padding: 4px 12px; font-size: 13px; background: transparent; box-shadow: none; font-variant-numeric: tabular-nums; }

.row { display: grid; grid-template-columns: auto 1fr 52px; align-items: center; gap: 10px; font-size: 12.5px; color: var(--muted); }
.row output { text-align: right; color: var(--text); font-variant-numeric: tabular-nums; font-weight: 600; }
input[type=range] { width: 100%; accent-color: var(--accent); height: 18px; margin: 0; }
.check { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); cursor: pointer; }
.check input { accent-color: var(--accent); width: 15px; height: 15px; margin: 0; }
.row-btns { display: flex; gap: 6px; flex-wrap: wrap; }
.text {
  font: inherit; font-size: 13px;
  color: var(--text);
  background: var(--bg);
  border: 0; border-radius: 8px;
  box-shadow: inset 0 0 0 1px var(--line);
  padding: 7px 10px;
  width: 100%;
}
.text::placeholder { color: var(--faint); }

.toast {
  position: fixed;
  left: 50%; bottom: 28px;
  transform: translate(-50%, 12px);
  padding: 9px 16px;
  border-radius: 10px;
  background: var(--surface-3);
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--line-strong), 0 0 40px rgba(255, 255, 255, 0.06);
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s, transform 0.18s;
  max-width: min(92vw, 560px);
  text-align: center;
  z-index: 10;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 760px) {
  .top { flex-wrap: wrap; }
  .top-actions { margin-left: 0; width: 100%; justify-content: flex-start; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* 체형 선택: 눈에 덜 띄는 작은 토글 */
.shape { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--faint); }
.shape span { margin-right: 4px; }
.shape button {
  font: inherit; font-size: 11.5px; color: var(--muted); background: transparent; border: 0; border-radius: 6px;
  padding: 1px 8px; cursor: pointer; box-shadow: inset 0 0 0 1px var(--line);
}
.shape button:hover { color: var(--text); box-shadow: inset 0 0 0 1px var(--line-strong); }
.shape button.on { color: var(--text); background: var(--surface-3); box-shadow: inset 0 0 0 1px var(--line-strong); }
.shape button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.credit { padding: 0 16px 12px; font-size: 11.5px; color: var(--faint); text-align: center; }
.credit a { color: var(--muted); text-decoration: underline; text-underline-offset: 2px; }
.credit a:hover { color: var(--text); }

/* 조리개 · 조명 카드 */
.card.wide { grid-column: span 2; }
@media (max-width: 560px) { .card.wide { grid-column: auto; } }
.sub { display: flex; align-items: center; gap: 10px; font-size: 12.5px; color: var(--muted); flex-wrap: wrap; }
.note { margin: 0; font-size: 11.5px; color: var(--faint); }
.seg.inline { align-self: flex-start; }
.seg.inline button { padding: 3px 12px; font-size: 12.5px; }
#sunBox { display: flex; flex-direction: column; gap: 10px; }
#sunBox[hidden] { display: none; }
#rigs[hidden] { display: none; }

/* 클릭 초점 표시 (DOM 오버레이라 저장 이미지에는 찍히지 않는다) */
.focus-mark {
  position: absolute; width: 34px; height: 34px; margin: -17px 0 0 -17px; pointer-events: none;
  background:
    linear-gradient(var(--accent), var(--accent)) 0 0 / 10px 2px, linear-gradient(var(--accent), var(--accent)) 0 0 / 2px 10px,
    linear-gradient(var(--accent), var(--accent)) 100% 0 / 10px 2px, linear-gradient(var(--accent), var(--accent)) 100% 0 / 2px 10px,
    linear-gradient(var(--accent), var(--accent)) 0 100% / 10px 2px, linear-gradient(var(--accent), var(--accent)) 0 100% / 2px 10px,
    linear-gradient(var(--accent), var(--accent)) 100% 100% / 10px 2px, linear-gradient(var(--accent), var(--accent)) 100% 100% / 2px 10px;
  background-repeat: no-repeat;
  filter: drop-shadow(0 0 2px rgba(0, 0, 0, 0.7));
  animation: focus-mark 0.9s ease-out forwards;
}
@keyframes focus-mark {
  0% { transform: scale(1.5); opacity: 0; }
  18% { transform: scale(1); opacity: 1; }
  40% { opacity: 0.35; }
  60% { opacity: 1; }
  100% { opacity: 0; }
}

/* 조명 설명 팝업 */
.tip {
  position: fixed; z-index: 20; width: 356px; max-width: calc(100vw - 16px);
  display: grid; grid-template-columns: 132px 1fr; gap: 12px; padding: 10px;
  background: var(--surface-2); border-radius: 12px; pointer-events: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 0 0 1px var(--line-strong), 0 0 46px rgba(255, 255, 255, 0.07);
}
.tip[hidden] { display: none; }
.tip img { width: 132px; height: 165px; border-radius: 8px; display: block; object-fit: cover; background: #000; }
.tip h3 { margin: 2px 0 6px; font-size: 14px; font-weight: 650; color: var(--accent); }
.tip dl { margin: 0; display: grid; gap: 6px; font-size: 12.5px; line-height: 1.45; }
.tip dt { font-size: 11px; color: var(--faint); letter-spacing: 0.03em; }
.tip dd { margin: 0; color: var(--text); }

/* 슬라이더 이름: 클릭하면 기본값으로 초기화 */
.row .resettable {
  cursor: pointer; border-radius: 5px; padding: 1px 5px; margin: -1px -5px;
  text-decoration: underline dotted var(--line-strong); text-underline-offset: 3px;
  transition: color 0.12s, background 0.12s;
}
.row .resettable:hover { color: var(--accent); background: var(--accent-soft); }
