:root {
  --bg: #0b0b12;
  --panel: #14141f;
  --panel-2: #1c1c2a;
  --line: rgba(255, 255, 255, .12);
  --text: #f2f2f7;
  --muted: #9a9ab0;
  --accent: #00e5ff;
  --accent-2: #ff2bd6;
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

button, input { font: inherit; color: inherit; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: rgba(11, 11, 18, .9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 17px; margin: 0; flex: 1; letter-spacing: .02em; }
.back { color: var(--text); text-decoration: none; font-size: 20px; padding: 2px 6px; }
.badge {
  font-size: 11px; padding: 4px 8px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--muted); white-space: nowrap;
}
.badge.ok { color: #6dffb0; border-color: rgba(109, 255, 176, .4); }
.badge.warn { color: #ffcf6d; border-color: rgba(255, 207, 109, .4); }

.layout {
  display: grid;
  gap: 16px;
  padding: 16px;
  padding-bottom: calc(24px + env(safe-area-inset-bottom));
  max-width: 1100px;
  margin: 0 auto;
}
@media (min-width: 860px) {
  .layout { grid-template-columns: auto 1fr; align-items: start; }
  .stage-wrap { position: sticky; top: 70px; }
}

/* Stage */
.stage-wrap { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.stage {
  position: relative;
  height: min(62vh, 760px);
  aspect-ratio: 9 / 16;
  max-width: 100%;
  border-radius: var(--radius);
  overflow: hidden;
  background: #000;
  box-shadow: 0 10px 40px rgba(0, 0, 0, .5);
}
.stage canvas { width: 100%; height: 100%; display: block; }

.rec-overlay {
  position: absolute; inset: auto 0 0 0;
  display: grid; gap: 8px; justify-items: center;
  padding: 14px;
  background: linear-gradient(transparent, rgba(0, 0, 0, .8));
  font-size: 13px;
}
.rec-overlay[hidden] { display: none; }
.rec-dot { width: 12px; height: 12px; border-radius: 50%; background: #ff3b3b; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .2; } }
.rec-bar { width: 100%; height: 4px; background: rgba(255, 255, 255, .2); border-radius: 4px; overflow: hidden; }
#rec-progress { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }

/* Player */
.player {
  width: 100%; max-width: 480px;
  display: flex; align-items: center; gap: 8px;
}
.round {
  flex: none; width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--panel-2); cursor: pointer; font-size: 14px;
}
.round.main {
  width: 50px; height: 50px; font-size: 18px; border: 0;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #000;
}
.round:disabled { opacity: .4; }
.seek { flex: 1; min-width: 0; }
.seek input { width: 100%; }
.time { display: flex; justify-content: space-between; gap: 8px; font-size: 11px; color: var(--muted); }
.now-title { flex: 1; text-align: center; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: var(--text); }

input[type=range] { accent-color: var(--accent); }

/* Panel */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  min-width: 0;
}
.tabs { display: grid; grid-template-columns: repeat(4, 1fr); border-bottom: 1px solid var(--line); }
.tab {
  padding: 12px 4px; background: none; border: 0; cursor: pointer;
  font-size: 13px; color: var(--muted); border-bottom: 2px solid transparent;
}
.tab.active { color: var(--text); border-bottom-color: var(--accent); }
.tabpane { display: none; padding: 16px; gap: 14px; flex-direction: column; }
.tabpane.active { display: flex; }

.drop {
  display: grid; gap: 4px; text-align: center; cursor: pointer;
  padding: 22px 12px;
  border: 1.5px dashed rgba(255, 255, 255, .25);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .03);
}
.drop span { font-size: 12px; color: var(--muted); }
.drop.dragover { border-color: var(--accent); background: rgba(0, 229, 255, .07); }

.track-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; }
.track-list li {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 10px; background: var(--panel-2); cursor: pointer;
  font-size: 14px;
}
.track-list li.on { outline: 1.5px solid var(--accent); }
.track-list .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.track-list .meta { font-size: 11px; color: var(--muted); }
.track-list .del { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 16px; }
.track-list .del:disabled { opacity: .25; cursor: default; }
.track-list .meta { white-space: nowrap; }

.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.field { display: grid; gap: 8px; font-size: 13px; color: var(--muted); }
.field.inline { display: flex; align-items: center; gap: 8px; flex: 1; }
.field.inline input { flex: 1; }
.field output { color: var(--text); float: right; }
.field input[type=text], .field input[type=number], .field select {
  width: 100%; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
}
.color { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); flex: 1; }
.color input[type=color] { width: 44px; height: 32px; border: 0; padding: 0; background: none; }
.color input[type=number] { flex: 1; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }

.seg { display: flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { flex: 1; padding: 9px 4px; background: none; border: 0; cursor: pointer; font-size: 13px; color: var(--muted); }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--panel-2); color: var(--text); }

.style-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.style-grid button {
  display: grid; gap: 4px; justify-items: center;
  padding: 10px 4px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--line); background: var(--panel-2); font-size: 11px; color: var(--muted);
}
.style-grid button .ico { font-size: 20px; color: var(--text); }
.style-grid button.on { border-color: var(--accent); color: var(--text); }

.palette { display: flex; gap: 8px; flex-wrap: wrap; }
.palette button {
  width: 34px; height: 34px; border-radius: 50%; cursor: pointer;
  border: 2px solid transparent;
}
.palette button.on { border-color: #fff; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 12px 16px; border-radius: 12px; cursor: pointer; text-decoration: none;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text); font-size: 14px;
}
.btn.primary { border: 0; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #000; font-weight: 600; }
.btn.ghost { background: transparent; }
.btn.small { padding: 7px 12px; font-size: 12px; }
.btn:disabled { opacity: .4; cursor: default; }

.muted { color: var(--muted); }
.small { font-size: 12px; line-height: 1.5; margin: 0; }
.small.warn { color: #ffcf6d; }

.result { display: grid; gap: 10px; }
.result[hidden] { display: none; }
.result video { width: 100%; max-height: 50vh; border-radius: 10px; background: #000; }

.field select { font-size: 14px; }
.field select optgroup { color: var(--muted); }
.field select option { color: var(--text); background: var(--panel-2); }
