:root {
  --bg: #0a0a0b;
  --panel: #141416;
  --panel-2: #1b1b1f;
  --line: #26262a;
  --text: #e8e6e0;
  --dim: #7a7a82;
  --accent: #ff3ea5;
  --radius: 7px;
}

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

/* display를 지정한 author 규칙이 hidden 속성을 덮어쓰는 것을 막는다 */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---------- header ---------- */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}

h1 {
  font-size: 14px;
  letter-spacing: 0.18em;
  font-weight: 700;
  white-space: nowrap;
}
h1 span { color: var(--accent); }

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

.field { display: flex; align-items: center; gap: 7px; }
.field label {
  font-size: 9px;
  letter-spacing: 0.15em;
  color: var(--dim);
}

input[type="text"] {
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--text);
  font-family: "SF Mono", Menlo, monospace;
  font-size: 11px;
  padding: 6px 8px;
  border-radius: var(--radius);
  outline: none;
}
#seedInput { width: 96px; }
#codeInput { width: 168px; }
input[type="text"]:focus { border-color: var(--accent); }
input[type="text"]::placeholder { color: #4c4c54; }

/* ---------- buttons ---------- */
button, select {
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--text);
  font-family: inherit;
  font-size: 11px;
  padding: 6px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.14s, background 0.14s, color 0.14s, opacity 0.14s;
}
button:hover:not(:disabled), select:hover { border-color: var(--accent); }
button:disabled { opacity: 0.35; cursor: not-allowed; }
button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #000;
  font-weight: 700;
  min-width: 38px;
}

/* ---------- main ---------- */
main {
  flex: 1 1 auto;
  display: flex;
  min-height: 0;
}

.stage {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  padding: 16px;
}

canvas {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  background: #000;
  box-shadow: 0 0 60px rgba(255, 62, 165, 0.07), 0 0 0 1px var(--line);
}

/* ---------- panel ---------- */
.panel {
  flex: 0 0 250px;
  border-left: 1px solid var(--line);
  overflow-y: auto;
  padding: 4px 0 24px;
  background: #0c0c0e;
}

.panel section {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.panel h2 {
  font-size: 9px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--dim);
  font-weight: 600;
  margin-bottom: 10px;
}

.row {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 9px;
}
.row .mini {
  font-size: 9px;
  letter-spacing: 0.12em;
  color: var(--dim);
}

.hint {
  font-size: 10px;
  line-height: 1.5;
  color: var(--dim);
  margin-top: 9px;
}

/* pills */
.pills { display: flex; flex-wrap: wrap; gap: 5px; }
.pills button {
  padding: 5px 10px;
  font-size: 10px;
  letter-spacing: 0.04em;
}
.pills button.on {
  background: var(--accent);
  border-color: var(--accent);
  color: #000;
  font-weight: 700;
}

/* swatches */
.swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 11px;
}
.swatch {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid var(--line);
  cursor: pointer;
  padding: 0;
  position: relative;
  overflow: hidden;
}
.swatch:hover { border-color: var(--accent); }
.swatch.off { opacity: 0.3; }
.swatch.off::after {
  content: '';
  position: absolute;
  left: -2px; right: -2px;
  top: 50%;
  height: 1px;
  background: var(--text);
  transform: rotate(-45deg);
}

input[type="color"] {
  width: 30px;
  height: 24px;
  padding: 0;
  background: none;
  border: 1px solid var(--line);
  border-radius: 5px;
  cursor: pointer;
}
.offscreen {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 0; height: 0;
}

/* primitive toggles */
.prims {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
}
.prims button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 7px 2px 5px;
  font-size: 14px;
  line-height: 1;
}
.prims button em {
  font-style: normal;
  font-size: 7px;
  letter-spacing: 0.04em;
  color: var(--dim);
}
.prims button.on { background: var(--panel-2); border-color: var(--accent); }
.prims button.on em { color: var(--text); }
.prims button:not(.on) { opacity: 0.4; }

/* ---------- footer ---------- */
footer {
  flex: 0 0 auto;
  border-top: 1px solid var(--line);
  padding: 11px 18px;
}

.transport {
  display: flex;
  align-items: center;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
}

.slider-group { display: flex; align-items: center; gap: 8px; }
.slider-group label {
  font-size: 9px;
  letter-spacing: 0.15em;
  color: var(--dim);
}
.slider-group span {
  font-family: "SF Mono", Menlo, monospace;
  font-size: 11px;
  min-width: 32px;
}

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

.stat {
  font-family: "SF Mono", Menlo, monospace;
  font-size: 10px;
  color: var(--dim);
}

/* ---------- 오디오 ---------- */
.slider-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 9px;
}
.slider-row label {
  font-size: 9px;
  letter-spacing: 0.12em;
  color: var(--dim);
  min-width: 22px;
}
.slider-row input[type="range"] { width: 108px; flex: 1 1 auto; }
.slider-row span {
  font-family: "SF Mono", Menlo, monospace;
  font-size: 10px;
  min-width: 30px;
  text-align: right;
}

#audioMapPills { margin-bottom: 2px; }

.waveform-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 0 11px;
}
#waveform {
  flex: 1 1 auto;
  height: 42px;
  width: 100%;
  min-width: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  box-shadow: none;
  max-height: none;
}
#timeLabel { white-space: nowrap; }

/* ---------- 체크박스 ---------- */
.check {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 11px;
  font-size: 10px;
  line-height: 1.4;
  color: var(--dim);
  cursor: pointer;
}
.check input {
  accent-color: var(--accent);
  width: 13px;
  height: 13px;
  cursor: pointer;
  flex: 0 0 auto;
}
.check:hover { color: var(--text); }

/* 도구가 켜졌을 때 캔버스 커서 */
canvas.tooling { cursor: crosshair; }

#brushOpts .swatches { margin-top: 7px; }
#brushOpts .swatch.sel { border-color: var(--accent); border-width: 2px; }
#brushPrims { margin-top: 6px; }

/* 캔버스로 오디오 파일을 끌어올 때 */
.stage.drop-active canvas {
  outline: 2px dashed var(--accent);
  outline-offset: 6px;
}

.rec-dot {
  font-family: "SF Mono", Menlo, monospace;
  font-size: 10px;
  color: #ff4444;
  opacity: 0;
  transition: opacity 0.2s;
}
.rec-dot.on { opacity: 1; animation: blink 1s steps(2, start) infinite; }
@keyframes blink { 50% { opacity: 0.25; } }

/* ---------- 좁은 화면 ---------- */
@media (max-width: 860px) {
  main { flex-direction: column; }
  .panel {
    flex: 0 0 auto;
    max-height: 42vh;
    border-left: none;
    border-top: 1px solid var(--line);
  }
  .stage { padding: 10px; }
  header { flex-wrap: wrap; gap: 10px; }
}

/* ---------- 갤러리 ---------- */
.gallery {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.gallery:empty { display: none; }
.g-item {
  position: relative;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 5px;
  overflow: hidden;
  cursor: pointer;
  background: #000;
  line-height: 0;
}
.g-item:hover { border-color: var(--accent); }
.g-item img { width: 100%; height: auto; display: block; }
.g-del {
  position: absolute;
  top: 2px; right: 2px;
  width: 15px; height: 15px;
  padding: 0;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,0.7);
  color: #fff;
  font-size: 11px;
  line-height: 15px;
  opacity: 0;
  transition: opacity 0.12s;
}
.g-item:hover .g-del { opacity: 1; }
.g-del:hover { background: var(--accent); color: #000; }

/* ---------- 미디어월 설정 ---------- */
.mw-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 9px;
}
.mw-row label {
  font-size: 9px;
  letter-spacing: 0.12em;
  color: var(--dim);
  flex: 0 0 62px;
}
.mw-row input[type="number"] {
  width: 52px;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--text);
  font-family: "SF Mono", Menlo, monospace;
  font-size: 11px;
  padding: 5px 6px;
  border-radius: 5px;
  outline: none;
}
.mw-row input[type="number"]:focus { border-color: var(--accent); }
.mw-row .mw-x { color: var(--dim); font-size: 10px; }
#mwReadout {
  font-family: "SF Mono", Menlo, monospace;
  color: var(--text);
}
