:root {
  color-scheme: light;
  --bg: #f4f5f7;
  --panel: #ffffff;
  --ink: #111827;
  --muted: #64748b;
  --line: rgba(15, 23, 42, 0.16);
  --accent: #111827;
  --shadow: 0 22px 42px rgba(15, 23, 42, 0.10);
  font-family: "Malgun Gothic", "맑은 고딕", "Apple SD Gothic Neo", "Noto Sans KR", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}

html,
body,
button,
textarea,
input,
select {
  font-synthesis-weight: none;
  -webkit-font-smoothing: auto;
  -moz-osx-font-smoothing: auto;
  text-rendering: optimizeLegibility;
}

body :where(h1, h2, h3, p, label, span, strong, em, button, input, textarea, select) {
  letter-spacing: 0;
  text-shadow: none;
  filter: none;
}

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

.lock-screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #0d0f14;
}

.lock-box {
  width: min(360px, 100%);
  display: grid;
  gap: 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(24, 27, 34, 0.96);
  box-shadow: var(--shadow);
  padding: 24px;
}

.lock-box label {
  color: #d8dee9;
}

.lock-box input {
  width: 100%;
  min-height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: #10131a;
  color: #ffffff;
  padding: 0 12px;
  font-weight: 850;
}

.lock-box button {
  border-color: rgba(225, 29, 46, 0.45);
  background: #e11d2e;
  color: #ffffff;
}

.lock-message {
  min-height: 20px;
  margin: 0;
  color: #f8d34d;
  font-size: 0.86rem;
  font-weight: 800;
}

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(520px, 1fr) 430px 260px;
  align-items: start;
  gap: 18px;
  padding: 20px 22px;
}

.panel {
  display: grid;
  align-content: start;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 16px;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

textarea,
input[type="text"],
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 11px 12px;
}

input[type="text"] {
  min-height: 42px;
}

textarea {
  min-height: 92px;
  resize: vertical;
  line-height: 1.45;
}

.storyboard-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 168px;
  gap: 12px;
  align-items: end;
}

.image-generate {
  min-height: 92px;
  border-color: rgba(17, 24, 39, 0.36);
  background: #111827;
  color: #fff;
}

.image-generate:hover {
  border-color: #111827;
  background: #1f2937;
}

.ban-story-field {
  gap: 8px;
}

.history-panel {
  display: grid;
  gap: 10px;
  border: 1px solid rgba(15, 23, 42, 0.14);
  border-radius: 8px;
  background: #fbfcfd;
  padding: 12px;
}

.ban-story-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 86px;
  gap: 8px;
}

.ban-story-row button {
  min-height: 42px;
}

.history-card {
  min-width: 0;
  display: grid;
  gap: 8px;
  border: 1px solid rgba(15, 23, 42, 0.14);
  border-radius: 8px;
  background: #fbfcfd;
  padding: 10px;
}

.history-unified {
  background: #fff;
}

.history-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 82px;
  align-items: center;
  gap: 8px;
}

.history-head strong {
  min-width: 0;
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 900;
}

.history-head button {
  min-height: 34px;
  padding: 0 10px;
  font-size: 0.78rem;
}

.history-head-single {
  grid-template-columns: minmax(0, 1fr) 96px;
}

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

.history-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  border-radius: 8px;
  padding: 0 10px;
  font-size: 0.8rem;
  font-weight: 900;
}

.history-chip-generated {
  border: 1px solid rgba(17, 24, 39, 0.25);
  background: #111827;
  color: #fff;
}

.history-chip-ban {
  border: 1px solid rgba(225, 29, 46, 0.25);
  background: #e11d2e;
  color: #fff;
}

.history-preview {
  min-height: 38px;
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.45;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.compact-text {
  min-height: 224px;
}

.input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 168px;
  gap: 12px;
  align-items: stretch;
}

.file-picker {
  position: relative;
  align-self: end;
  height: 224px;
  min-height: 224px;
  border: 1px dashed rgba(15, 23, 42, 0.34);
  border-radius: 8px;
  background: #fbfcfd;
  padding: 0;
  overflow: hidden;
  grid-template-rows: minmax(0, 1fr);
  transition: border-color 0.15s ease, background-color 0.15s ease;
  cursor: pointer;
}

.file-picker.dragging {
  border-color: #111827;
  background: #fff;
}

.file-picker[draggable="true"] {
  cursor: grab;
}

.file-picker[draggable="true"]:active {
  cursor: grabbing;
}

.file-picker.has-image::after {
  content: "드래그로 위치 교환";
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 8px;
  min-height: 28px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: rgba(17, 24, 39, 0.76);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.15s ease, transform 0.15s ease;
  pointer-events: none;
}

.file-picker.has-image:hover::after,
.file-picker.has-image.dragging::after,
.file-picker.has-image.swap-source::after {
  opacity: 1;
  transform: translateY(0);
}

.file-picker.swap-source {
  border-color: #111827;
  box-shadow: inset 0 0 0 2px rgba(17, 24, 39, 0.16);
}

.drop-text {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  background: #fff;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.45;
  text-align: center;
}

.file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.image-preview {
  display: none;
  width: 100%;
  height: 100%;
  background: #fff;
  object-fit: cover;
}

.file-picker.has-image .drop-text {
  display: none;
}

.file-picker.has-image .image-preview {
  display: block;
}

.preview {
  width: 430px;
  max-width: 430px;
  display: grid;
  align-content: start;
  gap: 10px;
}

.canvas-stage {
  position: relative;
  width: 430px;
  max-width: 430px;
  aspect-ratio: 9 / 16;
}

canvas {
  width: 100%;
  height: 100%;
  display: block;
  border: 1px solid #c9d3df;
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.canvas-progress {
  position: absolute;
  z-index: 2;
  left: 12px;
  right: 12px;
  bottom: 12px;
  min-height: 40px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.12);
  color: var(--ink);
  padding: 8px 10px;
  font-size: 0.82rem;
  font-weight: 800;
}

.progress-track {
  position: relative;
  height: 8px;
  border-radius: 999px;
  background: #30343b;
  overflow: visible;
}

.progress-fill {
  width: 0%;
  height: 100%;
  border-radius: 999px;
  background: #f3b33d;
}

.progress-knob {
  position: absolute;
  top: 50%;
  left: 0%;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #f3b33d;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 0 2px rgba(243, 179, 61, 0.22);
}

.canvas-progress span {
  white-space: nowrap;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.actions {
  width: 260px;
  min-width: 260px;
  gap: 12px;
  background: #eef3f8;
}

.control-card {
  display: grid;
  gap: 10px;
  border: 1px solid rgba(148, 163, 184, 0.45);
  border-radius: 8px;
  background: #fff;
  padding: 13px;
  min-height: 84px;
}

.control-head {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 3px 8px;
  align-items: baseline;
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 900;
}

.control-head em {
  grid-column: 1 / -1;
  justify-self: end;
  color: var(--muted);
  font-size: 0.72rem;
  font-style: normal;
}

.timing-rule {
  margin: 0;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  line-height: 1.45;
}

input[type="range"] {
  width: 100%;
  accent-color: #e11d2e;
}

.bgm-select {
  min-height: 38px;
}

.voice-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 52px;
  color: var(--ink);
}

.voice-toggle input {
  width: 18px;
  height: 18px;
  accent-color: #e11d2e;
}

button {
  width: 100%;
  min-height: 42px;
  border: 1px solid rgba(15, 23, 42, 0.35);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-weight: 900;
}

button:hover {
  border-color: rgba(15, 23, 42, 0.7);
}

button:disabled {
  opacity: 0.56;
  cursor: wait;
}

.download {
  min-height: 58px;
  border-color: rgba(225, 29, 46, 0.35);
  background: #e11d2e;
  color: #fff;
  font-size: 1rem;
}

.download.secondary {
  border-color: rgba(15, 23, 42, 0.2);
  background: #fff;
  color: var(--ink);
}

.voice-box {
  display: grid;
  gap: 9px;
  border: 1px solid rgba(148, 163, 184, 0.45);
  border-radius: 8px;
  background: #fff;
  padding: 13px;
}

.voice-box p {
  margin: 0;
  min-height: 38px;
  border: 1px solid rgba(15, 23, 42, 0.14);
  border-radius: 8px;
  background: #fbfcfd;
  color: var(--muted);
  padding: 9px;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

@media (max-width: 1120px) {
  .app {
    grid-template-columns: minmax(0, 1fr) 430px;
  }

  .actions {
    grid-column: 1 / -1;
    width: auto;
    min-width: 0;
    grid-template-columns: minmax(220px, 280px) minmax(300px, 1fr);
  }

  .voice-box {
    border: 1px solid rgba(148, 163, 184, 0.45);
    padding: 13px;
  }
}

@media (max-width: 760px) {
  .app,
  .storyboard-row,
  .input-row,
  .actions {
    grid-template-columns: 1fr;
  }

  .app {
    padding: 12px;
  }

  .preview,
  .canvas-stage {
    width: 100%;
    max-width: 430px;
  }

  .voice-box {
    border-left: 0;
    border-top: 1px solid var(--line);
    padding-left: 0;
    padding-top: 12px;
  }
}

/* 20260528 layoutfix1: add KBO-style centered preview play/pause control. */
.canvas-play-zone {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  place-items: center;
  pointer-events: none;
}

.canvas-play-button {
  position: relative;
  width: 58px;
  height: 58px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.16);
  color: transparent;
  font-size: 0;
  opacity: 0;
  pointer-events: auto;
  transition: opacity 0.15s ease;
}

.canvas-stage:hover .canvas-play-button,
.canvas-play-button:focus-visible {
  opacity: 1;
}

.canvas-play-button::before,
.canvas-play-button::after {
  content: "";
  position: absolute;
  top: 50%;
  display: block;
}

.canvas-play-button.is-playing::before,
.canvas-play-button.is-playing::after {
  width: 8px;
  height: 26px;
  border: 0;
  border-radius: 3px;
  background: #020617;
  transform: translateY(-50%);
}

.canvas-play-button.is-playing::before {
  left: 20px;
}

.canvas-play-button.is-playing::after {
  right: 20px;
}

.canvas-play-button.is-paused::before {
  left: 23px;
  width: 0;
  height: 0;
  border-top: 13px solid transparent;
  border-bottom: 13px solid transparent;
  border-left: 21px solid #020617;
  transform: translateY(-50%);
}

.canvas-play-button.is-paused::after {
  display: none;
}
