:root {
  color-scheme: dark;
  --bg: #050505;
  --panel: #111111;
  --panel-2: #171717;
  --panel-3: #202020;
  --line: #2d2d2d;
  --text: #f4f4f0;
  --muted: #a7a7a0;
  --soft: #74746c;
  --green: #9bff68;
  --amber: #ffca5f;
  --red: #ff6c6c;
  --cyan: #69d8ff;
  --ink: #050505;
  --radius: 8px;
}

html.locked body {
  overflow: hidden;
}

html.locked .app-shell,
html.locked .toast {
  display: none;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Pretendard", "Segoe UI", "Noto Sans KR", system-ui, sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  border-radius: var(--radius);
  background: var(--green);
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
  min-height: 42px;
  padding: 0 16px;
}

button:hover {
  filter: brightness(1.08);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

button.secondary,
button.ghost {
  background: var(--panel-3);
  color: var(--text);
  border: 1px solid var(--line);
}

button.ghost {
  min-height: 34px;
  padding: 0 12px;
  color: var(--muted);
}

label {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  margin-bottom: 8px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #090909;
  color: var(--text);
  outline: none;
  padding: 12px;
}

textarea {
  resize: vertical;
  line-height: 1.55;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--green);
}

.app-shell {
  width: min(1800px, 100%);
  margin: 0 auto;
  padding: 22px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid var(--line);
  padding: 8px 0 20px;
}

.topbar h1 {
  margin: 4px 0 0;
  max-width: 980px;
  font-size: clamp(24px, 3vw, 40px);
  line-height: 1.15;
  letter-spacing: 0;
}

.hero-copy {
  color: var(--muted);
  line-height: 1.55;
  margin: 10px 0 0;
  max-width: 880px;
}

.eyebrow {
  margin: 0;
  color: var(--green);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.api-pill {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
  padding: 9px 14px;
}

.api-pill.ready {
  border-color: rgba(155, 255, 104, 0.45);
  color: var(--green);
}

.api-pill.missing {
  border-color: rgba(255, 202, 95, 0.45);
  color: var(--amber);
}

.studio-grid {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr) 300px;
  gap: 16px;
  padding-top: 18px;
}

.control-panel,
.validator-panel,
.workspace {
  min-width: 0;
}

.control-panel,
.validator-panel {
  position: sticky;
  top: 16px;
  align-self: start;
  max-height: calc(100vh - 32px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 14px;
}

.workspace {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #0b0b0b;
  overflow: hidden;
}

.panel-section + .panel-section {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.panel-section h2 {
  margin: 6px 0 12px;
  font-size: 18px;
}

.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  padding: 8px;
  overflow-x: auto;
}

.tab {
  flex: 0 0 auto;
  min-height: 38px;
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
  padding: 0 13px;
}

.tab.active {
  background: var(--panel-3);
  border-color: var(--line);
  color: var(--text);
}

.action-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  border-bottom: 1px solid var(--line);
  padding: 12px;
}

.tab-panel {
  display: none;
  padding: 16px;
}

.tab-panel.active {
  display: block;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.section-head h2 {
  margin: 4px 0 0;
  font-size: 24px;
  letter-spacing: 0;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--soft);
  padding: 28px;
  text-align: center;
}

.topic-list,
.scene-list,
.prompt-list,
.upload-grid,
.queue-list {
  display: grid;
  gap: 12px;
}

.completed-list {
  display: grid;
  gap: 8px;
}

.topic-item,
.scene-item,
.prompt-item,
.copy-block,
.queue-item,
.reason-card,
.check-item {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 14px;
}

.topic-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
}

.topic-actions {
  display: grid;
  gap: 8px;
}

.topic-title,
.scene-title,
.prompt-title,
.queue-title {
  margin: 0;
  font-size: 17px;
  line-height: 1.35;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #090909;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  padding: 0 9px;
}

.badge.good {
  border-color: rgba(155, 255, 104, 0.4);
  color: var(--green);
}

.badge.warn {
  border-color: rgba(255, 202, 95, 0.45);
  color: var(--amber);
}

.badge.bad {
  border-color: rgba(255, 108, 108, 0.45);
  color: var(--red);
}

.scene-item {
  display: grid;
  gap: 12px;
}

.dialogue {
  border-left: 3px solid var(--green);
  background: #080808;
  color: #ffffff;
  line-height: 1.7;
  margin: 0;
  padding: 12px;
  white-space: pre-wrap;
}

.prompt-body,
.copy-body {
  margin: 10px 0 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #070707;
  color: #e9e9e2;
  font-family: "Cascadia Mono", "Consolas", monospace;
  font-size: 13px;
  line-height: 1.6;
  overflow: auto;
  padding: 12px;
  white-space: pre-wrap;
}

.prompt-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 10px;
}

.reason-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.reason-card strong,
.copy-block strong {
  display: block;
  margin-bottom: 8px;
}

.check-list {
  display: grid;
  gap: 8px;
}

.check-item {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 10px;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-top: 5px;
  background: var(--soft);
}

.dot.good {
  background: var(--green);
}

.dot.warn {
  background: var(--amber);
}

.dot.bad {
  background: var(--red);
}

.check-item p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.check-item strong {
  display: block;
  color: var(--text);
  margin-bottom: 4px;
}

.mode-box {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #090909;
  padding: 12px;
}

.mode-box strong,
.mode-box span {
  display: block;
}

.mode-box span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
  margin-top: 6px;
}

.queue-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 170px;
  gap: 12px;
  align-items: center;
}

.queue-item select {
  min-height: 38px;
  padding: 8px;
}

.completed-item {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #090909;
  padding: 10px;
}

.completed-item strong,
.completed-item span {
  display: block;
}

.completed-item strong {
  font-size: 13px;
  line-height: 1.45;
}

.completed-item span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  margin-top: 5px;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 10;
  max-width: 340px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-3);
  color: var(--text);
  opacity: 0;
  padding: 12px 14px;
  transform: translateY(12px);
  transition: 180ms ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.subscriber-gate {
  align-items: center;
  background: #050505;
  display: flex;
  inset: 0;
  justify-content: center;
  min-height: 100vh;
  padding: 18px;
  position: fixed;
  z-index: 100;
}

.gate-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  max-width: 460px;
  padding: 22px;
  width: 100%;
}

.gate-card h1 {
  font-size: 30px;
  letter-spacing: 0;
  line-height: 1.15;
  margin: 8px 0 10px;
}

.gate-card p {
  color: var(--muted);
  line-height: 1.55;
  margin: 0 0 18px;
}

.gate-card form {
  display: grid;
  gap: 10px;
}

.gate-message {
  color: var(--amber);
  display: block;
  font-size: 13px;
  font-weight: 800;
  min-height: 20px;
  margin-top: 12px;
}

@media (max-width: 1180px) {
  .studio-grid {
    grid-template-columns: 280px minmax(0, 1fr);
  }

  .validator-panel {
    position: static;
    grid-column: 1 / -1;
    max-height: none;
  }
}

@media (max-width: 820px) {
  .app-shell {
    padding: 14px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .studio-grid,
  .action-strip,
  .reason-grid,
  .queue-item {
    grid-template-columns: 1fr;
  }

  .control-panel {
    position: static;
    max-height: none;
  }

  .section-head {
    align-items: flex-start;
    flex-direction: column;
  }
}
