:root {
  --bg: #0f1115;
  --panel: #171a21;
  --card: #1e222b;
  --line: #2b303b;
  --text: #e8eaf0;
  --muted: #9aa3b2;
  --accent: #ff3d6e;
  --accent2: #7c5cff;
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Noto Sans KR", system-ui, sans-serif;
  font-size: 14px;
}
button, select, input, textarea { font: inherit; color: inherit; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 18px; border-bottom: 1px solid var(--line); background: var(--panel);
  position: sticky; top: 0; z-index: 10;
}
.logo { font-weight: 900; font-size: 18px; }
.logo .sub { font-weight: 400; font-size: 12px; color: var(--muted); margin-left: 6px; }
.top-actions { display: flex; gap: 8px; }

.layout {
  display: grid; grid-template-columns: minmax(360px, 1fr) minmax(320px, 480px);
  gap: 18px; padding: 18px; max-width: 1400px; margin: 0 auto;
}
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .preview { order: -1; position: static !important; }
}

.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 12px; }
.tab {
  flex: 1; padding: 10px 6px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--panel); cursor: pointer; color: var(--muted); white-space: nowrap;
}
.tab.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }
.panel { display: none; }
.panel.active { display: block; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; margin-bottom: 12px;
}
.card h3 { margin: 0 0 10px; font-size: 15px; }
label { display: block; margin: 8px 0; color: var(--muted); font-size: 13px; }
label > input:not([type=checkbox]):not([type=color]), label > select, label > textarea {
  display: block; width: 100%; margin-top: 4px;
}
input[type=text], input[type=password], input[type=number], select, textarea {
  background: #11141a; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; color: var(--text);
}
textarea { resize: vertical; }
input[type=range] { width: 100%; accent-color: var(--accent); }
input[type=color] { width: 44px; height: 30px; border: none; background: none; vertical-align: middle; padding: 0; cursor: pointer; }
label.check { display: flex; align-items: center; gap: 6px; color: var(--text); cursor: pointer; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.row > label { flex: 1; min-width: 110px; }
.row.end { justify-content: flex-end; }
.val { color: var(--text); font-weight: 700; margin-left: 4px; }
.hint { color: var(--muted); font-size: 12px; margin: 6px 0 0; line-height: 1.5; }

button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 14px; border-radius: 10px; border: 1px solid var(--line);
  background: #262b36; cursor: pointer; color: var(--text); font-size: 13px; margin: 0;
}
button:hover, .btn:hover { filter: brightness(1.15); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.primary { background: linear-gradient(135deg, var(--accent), var(--accent2)); border: none; color: #fff; font-weight: 700; }
button.ghost { background: transparent; }
button.wide { width: 100%; margin-top: 8px; padding: 12px; }
button.small { padding: 5px 9px; font-size: 12px; }
button.danger { color: #ff7b7b; }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; }

/* 장면 카드 */
.scene {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px; margin: 10px 0; display: grid; grid-template-columns: 96px 1fr; gap: 12px;
}
.scene.current { border-color: var(--accent); }
.scene .thumb {
  width: 96px; height: 170px; border-radius: 8px; background: #000 center/cover no-repeat;
  position: relative; overflow: hidden; display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 11px; text-align: center;
}
.scene .thumb video { width: 100%; height: 100%; object-fit: cover; }
.scene .num { position: absolute; top: 4px; left: 4px; background: rgba(0,0,0,.6); color: #fff; border-radius: 6px; padding: 1px 6px; font-weight: 700; }
.scene textarea { width: 100%; }
.scene .meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 6px; }
.scene .meta input[type=number] { width: 70px; padding: 5px 6px; }
.scene .meta select { padding: 5px 6px; }
.scene details { margin-top: 6px; }
.scene summary { cursor: pointer; color: var(--muted); font-size: 12px; }
.badge { font-size: 11px; padding: 2px 7px; border-radius: 20px; background: #2c3240; color: var(--muted); }
.badge.ok { background: #173d2a; color: #6ee7a8; }
.badge.warn { background: #45331a; color: #ffc46b; }
.busy { opacity: .6; pointer-events: none; }

/* 미리보기 */
.preview { position: sticky; top: 70px; align-self: start; }
.canvas-wrap {
  background: #000; border-radius: 16px; overflow: hidden; display: flex; justify-content: center;
  border: 1px solid var(--line);
}
#stage { width: 100%; height: auto; max-height: 68vh; object-fit: contain; display: block; }
.controls { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.controls #seek { flex: 1; }
#timeLabel { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 12px; min-width: 80px; text-align: right; }
button.round { width: 42px; height: 42px; border-radius: 50%; padding: 0; font-size: 16px; }
.export { margin-top: 8px; }
.download {
  display: block; text-align: center; margin-top: 8px; padding: 12px; border-radius: 10px;
  background: #173d2a; color: #6ee7a8; text-decoration: none; font-weight: 700;
}
.hidden { display: none !important; }

/* 설정 */
dialog { border: 1px solid var(--line); border-radius: 16px; background: var(--panel); color: var(--text); padding: 0; width: min(520px, 94vw); }
dialog::backdrop { background: rgba(0,0,0,.6); }
.dlg { padding: 20px; }
.dlg h2 { margin: 0 0 6px; font-size: 18px; }
.dlg details { margin: 10px 0; }
.dlg summary { cursor: pointer; color: var(--muted); }

#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px);
  background: #262b36; border: 1px solid var(--line); color: var(--text); padding: 10px 16px;
  border-radius: 10px; opacity: 0; transition: .25s; pointer-events: none; z-index: 100; max-width: 90vw;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.error { border-color: #ff7b7b; color: #ffb3b3; }

input[type=file] { display: none !important; }
