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

:root {
  --header-h:      72px;
  --bg:            #f8f7f4;
  --surface:       #ffffff;
  --surface-2:     #f2f0ec;
  --border:        #e4e0d8;
  --border-s:      #ccc8bf;
  --text:          #1a1916;
  --text-dim:      #5c5750;
  --text-muted:    #a09990;
  --purple:        #7c3aed;
  --purple-h:      #6d28d9;
  --purple-soft:   #f5f3ff;
  --purple-border: rgba(124,58,237,0.18);
  --purple-glow:   rgba(124,58,237,0.12);
  --amber:         #d97706;
  --amber-soft:    #fffbeb;
  --amber-border:  rgba(217,119,6,0.2);
  --green:         #059669;
  --green-soft:    #ecfdf5;
  --green-border:  rgba(5,150,105,0.18);
  --shadow-sm:     0 1px 3px rgba(0,0,0,0.05), 0 1px 2px rgba(0,0,0,0.04);
  --shadow:        0 4px 16px rgba(0,0,0,0.07), 0 1px 4px rgba(0,0,0,0.04);
}

html, body {
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.app {
  min-height: 100vh;
  width: 100%;
  display: grid;
  grid-template-rows: var(--header-h) auto;
}

/* ══════════════════════════════════════
   HEADER
══════════════════════════════════════ */
.app-header {
  display: flex;
  align-items: center;
  padding: 0 28px;
  gap: 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  overflow: hidden;
}

.header-brand {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex-shrink: 0;
}

.wordmark {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 800;
  font-size: 20px;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #7c3aed 0%, #c026d3 55%, #d97706 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1;
}

.wordmark-sub {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}

.header-div {
  width: 1px;
  height: 32px;
  background: var(--border);
  flex-shrink: 0;
}

.header-about {
  flex: 1;
  min-width: 0;
}

.about-title {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 700;
  font-size: 13px;
  color: var(--text);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.about-desc {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.poc-badge {
  font-size: 11px;
  font-weight: 600;
  font-family: 'JetBrains Mono', monospace;
  padding: 4px 12px;
  border-radius: 20px;
  background: var(--amber-soft);
  border: 1px solid var(--amber-border);
  color: var(--amber);
  flex-shrink: 0;
}

/* ══════════════════════════════════════
   STUDIO — 3-column grid
══════════════════════════════════════ */
.studio {
  display: grid;
  grid-template-columns: 260px 300px 1fr;
  min-height: calc(100vh - var(--header-h));
}

/* ── Panels ─────────────────────────── */
.panel-refs {
  border-right: 1px solid var(--border);
  padding: 18px 18px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: var(--surface);
}

.panel-script {
  border-right: 1px solid var(--border);
  padding: 18px 18px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: var(--surface);
}

.panel-output {
  padding: 18px 22px 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--bg);
}

/* ── Column labels ─────────────────── */
.col-heading {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2px;
  flex-shrink: 0;
}

/* ── Field label ───────────────────── */
.flabel {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 6px;
  letter-spacing: 0.01em;
}

/* ── Image area ───────────────────── */
.image-area { flex-shrink: 0; }

.upload-zone {
  position: relative;
  border: 2px dashed var(--border);
  border-radius: 8px;
  padding: 20px 16px;
  text-align: center;
  cursor: pointer;
  background: var(--bg);
  transition: all 0.2s;
}
.upload-zone:hover,
.upload-zone.drag-over {
  border-color: var(--purple);
  background: var(--purple-soft);
}
.upload-zone:hover .up-icon { color: var(--purple); }
.upload-zone input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.up-icon { color: var(--text-muted); margin: 0 auto 7px; display: block; transition: color 0.2s; }
.up-text { font-size: 12px; color: var(--text-dim); font-weight: 500; }
.up-fmt  { font-size: 10px; color: var(--text-muted); margin-top: 3px; font-family: 'JetBrains Mono', monospace; }

.img-preview {
  width: 100%;
  height: auto;
  max-height: 200px;
  object-fit: contain;
  border-radius: 8px;
  border: 1px solid var(--border);
  display: none;
  background: var(--surface-2);
}
.img-preview.show { display: block; }

/* ── Audio ────────────────────────── */
.audio-area { flex-shrink: 0; }

.audio-zone {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  overflow: hidden;
  cursor: pointer;
  position: relative;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s;
}
.audio-zone:hover { border-color: var(--border-s); }
.audio-zone input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; z-index: 1; }

.audio-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
}

.play-btn {
  position: relative; z-index: 2;
  width: 30px; height: 30px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--text-dim);
  flex-shrink: 0;
  transition: all 0.15s;
}
.play-btn:hover { border-color: var(--purple); color: var(--purple); background: var(--purple-soft); }
.play-icon  { display: block; }
.pause-icon { display: none; }

.audio-info { flex: 1; min-width: 0; }
.audio-name {
  font-size: 11px; font-weight: 500;
  color: var(--text-dim);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.audio-hint { font-size: 10px; color: var(--text-muted); margin-top: 1px; }

.waveform {
  padding: 0 12px 10px;
  display: flex; align-items: center; gap: 2px;
  height: 28px;
}
.bar {
  flex: 1; background: var(--border); border-radius: 1px;
  transition: background 0.3s;
}
.waveform.active .bar {
  background: var(--purple);
  animation: wbar var(--dur) ease-in-out infinite alternate;
}
@keyframes wbar {
  from { transform: scaleY(0.2); opacity: 0.5; }
  to   { transform: scaleY(1); opacity: 1; }
}

/* ── Script ───────────────────────── */
.script-area {
  display: flex;
  flex-direction: column;
  flex: 1;
}

textarea {
  width: 100%;
  flex: 1;
  min-height: 200px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  line-height: 1.65;
  padding: 10px 12px;
  resize: vertical;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
textarea::placeholder { color: var(--text-muted); }
textarea:focus {
  border-color: var(--purple);
  box-shadow: 0 0 0 3px var(--purple-glow);
}

.char-count {
  text-align: right;
  font-size: 10px;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-muted);
  margin-top: 4px;
  flex-shrink: 0;
}

/* ── Generate ─────────────────────── */
.btn-generate {
  flex-shrink: 0;
  width: 100%;
  padding: 12px;
  background: var(--purple);
  border: none;
  border-radius: 8px;
  color: white;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 7px;
  transition: all 0.15s;
  box-shadow: 0 2px 8px var(--purple-glow);
  margin-top: auto;
}
.btn-generate:hover:not(:disabled) {
  background: var(--purple-h);
  transform: translateY(-1px);
  box-shadow: 0 5px 18px var(--purple-glow);
}
.btn-generate:active:not(:disabled) { transform: translateY(0); }
.btn-generate:disabled { opacity: 0.4; cursor: not-allowed; box-shadow: none; }

/* ── Output header ─────────────────── */
.out-header {
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0;
}
.out-title {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 700; font-size: 13px; color: var(--text);
}

.badge {
  font-size: 10px; font-weight: 600;
  font-family: 'JetBrains Mono', monospace;
  padding: 3px 10px; border-radius: 20px;
}
.b-idle       { background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border); }
.b-processing { background: var(--purple-soft); color: var(--purple); border: 1px solid var(--purple-border); }
.b-ready      { background: var(--green-soft);  color: var(--green);  border: 1px solid var(--green-border); }

/* ── Video container ─────────────── */
.video-wrap {
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.video-empty {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 10px;
}
.video-empty::before {
  content: '';
  position: absolute; inset: 0;
  background:
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 36px 36px;
  opacity: 0.45;
}
.ve-icon {
  width: 48px; height: 48px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  position: relative; z-index: 1;
}
.video-empty p {
  font-size: 12px; color: var(--text-muted);
  font-weight: 500; z-index: 1;
}

/* Progress */
.progress-wrap {
  position: absolute; inset: 0;
  background: var(--surface);
  display: none;
  flex-direction: column; align-items: center; justify-content: center; gap: 14px;
}
.progress-wrap.show { display: flex; }

.prog-title {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 700; font-size: 14px; color: var(--text);
}
.prog-track {
  width: 220px; height: 4px;
  background: var(--border); border-radius: 2px; overflow: hidden;
}
.prog-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--purple), #c026d3);
  border-radius: 2px; width: 0%;
  transition: width 0.08s linear;
}
.prog-num {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px; font-weight: 500; color: var(--purple);
}

.steps { display: flex; flex-direction: column; gap: 7px; margin-top: 2px; }
.step {
  font-size: 12px; color: var(--text-muted);
  display: flex; align-items: center; gap: 9px;
  opacity: 0.25; transition: opacity 0.3s, color 0.3s;
}
.step.active { opacity: 1; color: var(--text-dim); }
.step.done   { opacity: 0.6; color: var(--green); }
.step-dot {
  width: 7px; height: 7px; border-radius: 50%;
  border: 1.5px solid currentColor; flex-shrink: 0;
}
.step.done   .step-dot { background: var(--green); border-color: var(--green); }
.step.active .step-dot {
  background: var(--purple); border-color: var(--purple);
  animation: sdot 1s ease-in-out infinite alternate;
}
@keyframes sdot {
  from { box-shadow: 0 0 0 2px var(--purple-glow); }
  to   { box-shadow: 0 0 0 5px var(--purple-glow); }
}

.out-video { width: 100%; height: 100%; object-fit: contain; display: block; }

/* ── Scrollbar ─────────────────────── */
::-webkit-scrollbar { width: 3px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-s); border-radius: 2px; }

/* ── Entrance animations ────────────── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.panel-refs > * { animation: fadeUp 0.3s ease both; }
.panel-refs > *:nth-child(1) { animation-delay: 0.04s; }
.panel-refs > *:nth-child(2) { animation-delay: 0.08s; }
.panel-refs > *:nth-child(3) { animation-delay: 0.12s; }

.panel-script > * { animation: fadeUp 0.3s ease both; }
.panel-script > *:nth-child(1) { animation-delay: 0.08s; }
.panel-script > *:nth-child(2) { animation-delay: 0.12s; }
.panel-script > *:nth-child(3) { animation-delay: 0.16s; }

.panel-output > * { animation: fadeUp 0.3s ease 0.12s both; }
