:root {
  --bg: #1f1a17;
  --ink: #f6f1ec;
  --muted: #b9aea5;
  --line: #3b332e;
  --card: #2a2420;
  --accent: #d8896b;
  --accent-ink: #1f1a17;
  font-family: -apple-system, "Apple SD Gothic Neo", "Pretendard", "Noto Sans KR", system-ui, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); }
body {
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  height: 100dvh;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
button, .btn { font: inherit; }

.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(8px + env(safe-area-inset-top)) 12px 8px;
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; font-size: 16px; }
.tag { font-size: 11px; font-weight: 600; color: var(--accent-ink); background: var(--accent); padding: 2px 6px; border-radius: 6px; margin-left: 4px; vertical-align: 2px; }
.top-actions { display: flex; gap: 8px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 38px; padding: 0 14px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  cursor: pointer; user-select: none;
}
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 700; }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: .4; }
.btn.big { width: 100%; min-height: 52px; font-size: 17px; margin-top: 10px; }

#stage { position: relative; min-height: 0; overflow: hidden; background: #0f0c0a; }
#view { width: 100%; height: 100%; display: block; touch-action: none; }

.empty { position: absolute; inset: 0; display: grid; place-items: center; padding: 20px; }
.empty-card { width: min(420px, 100%); background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 22px; }
.empty-card h1 { font-size: 21px; line-height: 1.4; margin: 0 0 8px; }
.empty-card p { color: var(--muted); margin: 0 0 6px; line-height: 1.5; font-size: 14px; }
.empty-card .fine { margin-top: 14px; font-size: 12px; }

.status {
  position: absolute; left: 50%; top: 10px; transform: translateX(-50%);
  background: rgba(20, 16, 14, .85); border: 1px solid var(--line);
  padding: 7px 12px; border-radius: 999px; font-size: 13px; white-space: nowrap; max-width: 94%;
  overflow: hidden; text-overflow: ellipsis;
}
.float { position: absolute; right: 10px; bottom: 10px; display: flex; gap: 6px; }

.chip {
  min-height: 34px; padding: 0 12px; border-radius: 999px;
  border: 1px solid var(--line); background: rgba(42, 36, 32, .92); color: var(--ink); cursor: pointer;
  white-space: nowrap;
}
.chip:disabled { opacity: .4; }
.chip.on, .chips button.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 700; }

.tabs { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--line); }
.tabs button { background: transparent; border: 0; color: var(--muted); padding: 11px 0; font-weight: 600; cursor: pointer; border-bottom: 3px solid transparent; }
.tabs button.on { color: var(--ink); border-bottom-color: var(--accent); }

.panel {
  max-height: 34dvh; overflow-y: auto; padding: 10px 12px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line); background: var(--card);
}
.row { display: flex; align-items: center; gap: 10px; margin: 6px 0; }
.lbl { flex: 0 0 auto; width: 52px; color: var(--muted); font-size: 13px; }
.more .lbl { width: 96px; }
.more { margin-top: 4px; border-top: 1px dashed var(--line); padding-top: 4px; }
.more summary { cursor: pointer; color: var(--muted); font-size: 13px; padding: 8px 0; list-style: none; }
.more summary::-webkit-details-marker { display: none; }
.more summary::before { content: '▸ '; }
.more[open] summary::before { content: '▾ '; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chips button { min-height: 34px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); cursor: pointer; white-space: nowrap; }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatches button { width: 32px; height: 32px; border-radius: 50%; border: 2px solid var(--line); cursor: pointer; }
.swatches button.on { border-color: var(--ink); box-shadow: 0 0 0 2px var(--accent); }
.slider input { flex: 1; accent-color: var(--accent); }
.toggles { flex-wrap: wrap; gap: 12px; font-size: 14px; }
.toggles label { display: inline-flex; align-items: center; gap: 6px; }
.hint { color: var(--muted); font-size: 12.5px; line-height: 1.5; margin: 8px 0 0; }

dialog {
  width: min(720px, 96vw); max-height: 90dvh; border: 1px solid var(--line); border-radius: 16px;
  background: var(--card); color: var(--ink); padding: 14px;
}
dialog::backdrop { background: rgba(0, 0, 0, .6); }
.dlg-head { display: flex; justify-content: space-between; align-items: center; }
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 8px; }
.grid button { padding: 0; border: 2px solid var(--line); border-radius: 12px; overflow: hidden; background: #000; cursor: pointer; color: var(--ink); text-align: left; }
.grid button.on { border-color: var(--accent); }
.grid canvas { width: 100%; display: block; }
.grid span { display: block; padding: 6px 8px; font-size: 13px; font-weight: 600; background: var(--card); }

@media (min-width: 900px) {
  body { grid-template-columns: 1fr 360px; grid-template-rows: auto 1fr auto; }
  .top { grid-column: 1 / -1; }
  #stage { grid-row: 2 / 4; }
  .tabs { grid-column: 2; grid-row: 2; align-self: start; border-top: 0; border-left: 1px solid var(--line); }
  .panel { grid-column: 2; grid-row: 2; margin-top: 46px; max-height: none; border-left: 1px solid var(--line); }
  .grid { grid-template-columns: repeat(3, 1fr); }
}
