:root {
  color-scheme: dark;
  --bg: #070a12;
  --panel: rgba(16, 21, 36, 0.92);
  --panel-2: rgba(25, 31, 50, 0.94);
  --border: rgba(255, 255, 255, 0.09);
  --text: #f7f8fb;
  --muted: #9aa4b7;
  --accent: #8b5cf6;
  --accent-2: #22d3ee;
  --success: #34d399;
  --warning: #fbbf24;
  --danger: #fb7185;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.38);
  --radius: 20px;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
  min-height: 100vh;
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 10% 10%, rgba(139, 92, 246, 0.15), transparent 28%),
    radial-gradient(circle at 88% 8%, rgba(34, 211, 238, 0.1), transparent 24%),
    linear-gradient(180deg, #0a0d18, #070910 48%, #05070c);
}
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.app-shell { min-height: 100vh; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--border);
  background: rgba(7, 10, 18, 0.78);
  backdrop-filter: blur(22px);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 13px;
  display: grid; place-items: center;
  font-weight: 900; letter-spacing: -1px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 10px 30px rgba(139, 92, 246, 0.35);
}
.brand strong { display: block; font-size: 16px; }
.brand span { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.top-actions { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; justify-content: flex-end; }

.workspace {
  width: min(1900px, 100%);
  margin: 0 auto;
  padding: 20px;
  display: grid;
  grid-template-columns: minmax(255px, 0.75fr) minmax(430px, 1.45fr) minmax(330px, 1fr);
  gap: 18px;
  align-items: start;
}
.creator-column, .preview-column { display: grid; gap: 18px; }
.card {
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(21, 27, 45, 0.96), rgba(13, 17, 30, 0.96));
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.sidebar { padding: 19px; position: sticky; top: 90px; }
.composer, .timeline-card, .preview-card, .status-card { padding: 20px; }

.section-title { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 18px; }
.section-title > span {
  flex: 0 0 auto;
  width: 30px; height: 30px; border-radius: 10px;
  display: grid; place-items: center; font-weight: 800;
  background: rgba(139, 92, 246, 0.18); color: #c4b5fd;
  border: 1px solid rgba(139, 92, 246, 0.25);
}
h1, h2, h3, p { margin-top: 0; }
h2 { font-size: 17px; margin-bottom: 3px; }
h3 { font-size: 15px; margin-bottom: 0; }
.section-title p, .section-heading-row p { color: var(--muted); font-size: 12px; margin-bottom: 0; }
.section-heading-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 15px; }

label { display: grid; gap: 7px; margin-bottom: 13px; }
label > span { color: #d8deeb; font-size: 12px; font-weight: 700; }
small { color: var(--muted); font-size: 10px; line-height: 1.4; }
input, textarea, select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  background: rgba(5, 8, 16, 0.62);
  outline: none;
  padding: 11px 12px;
  transition: border-color .2s, box-shadow .2s, background .2s;
}
textarea { resize: vertical; min-height: 74px; line-height: 1.48; }
input:focus, textarea:focus, select:focus {
  border-color: rgba(139, 92, 246, 0.8);
  box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.12);
  background: rgba(8, 11, 22, 0.95);
}
.grid { display: grid; gap: 11px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.upload-zone {
  min-height: 210px;
  margin-bottom: 15px;
  border: 1px dashed rgba(139, 92, 246, 0.48);
  border-radius: 17px;
  overflow: hidden;
  position: relative;
  cursor: pointer;
  background: radial-gradient(circle at 50% 35%, rgba(139, 92, 246, 0.14), transparent 47%), rgba(6, 8, 15, 0.55);
}
.upload-zone:hover { border-color: rgba(34, 211, 238, 0.7); }
.upload-zone img { width: 100%; height: 248px; object-fit: cover; display: block; }
#uploadPlaceholder { min-height: 210px; display: grid; place-items: center; align-content: center; gap: 7px; color: var(--muted); text-align: center; }
#uploadPlaceholder strong { color: var(--text); }
.upload-icon { width: 46px; height: 46px; border-radius: 15px; display: grid; place-items: center; font-size: 25px; color: #ddd6fe; background: rgba(139, 92, 246, 0.16); }

.consent-box {
  display: flex; align-items: flex-start; gap: 9px;
  padding: 11px; margin-top: 4px;
  border-radius: 13px;
  background: rgba(34, 211, 238, 0.06);
  border: 1px solid rgba(34, 211, 238, 0.12);
}
.consent-box input { width: auto; margin-top: 2px; }
.consent-box label { margin: 0; display: block; color: var(--muted); font-size: 11px; line-height: 1.42; }

.button {
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 9px 13px;
  color: var(--text);
  background: rgba(255,255,255,0.07);
  text-decoration: none;
  cursor: pointer;
  font-weight: 800;
  font-size: 12px;
  transition: transform .16s, background .16s, border-color .16s, opacity .16s;
}
.button:hover { transform: translateY(-1px); background: rgba(255,255,255,0.11); border-color: rgba(255,255,255,0.17); }
.button.primary { background: linear-gradient(135deg, var(--accent), #6d5dfc); border-color: transparent; box-shadow: 0 10px 24px rgba(139,92,246,.25); }
.button.ghost { background: transparent; }
.button.disabled { pointer-events: none; opacity: .42; }
.composer-actions, .timeline-actions, .scene-buttons { display: flex; gap: 9px; flex-wrap: wrap; }
.composer-actions { justify-content: flex-end; margin-top: 5px; }

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 9px; border-radius: 999px;
  font-size: 10px; font-weight: 900; letter-spacing: .04em; text-transform: uppercase;
  color: #e9d5ff; background: rgba(139,92,246,.12); border: 1px solid rgba(139,92,246,.22);
}
.badge.subtle { color: #bcc5d7; background: rgba(255,255,255,.05); border-color: rgba(255,255,255,.08); }
.badge.ready { color: #a7f3d0; background: rgba(52,211,153,.09); border-color: rgba(52,211,153,.2); }
.badge.warn { color: #fde68a; background: rgba(251,191,36,.09); border-color: rgba(251,191,36,.22); }
.badge.error { color: #fecdd3; background: rgba(251,113,133,.09); border-color: rgba(251,113,133,.22); }

.timeline { display: grid; gap: 12px; }
.timeline.empty-state { min-height: 160px; place-items: center; border: 1px dashed var(--border); border-radius: 15px; color: var(--muted); }
.scene-card {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 12px;
  background: rgba(5, 8, 16, 0.46);
}
.scene-number { width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center; font-weight: 900; color: #c4b5fd; background: rgba(139,92,246,.13); }
.scene-card-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; margin-bottom: 10px; }
.scene-duration { color: var(--muted); font-size: 10px; }
.scene-content label { margin-bottom: 9px; }
.scene-content textarea { min-height: 58px; }
.scene-detail-grid { display: grid; grid-template-columns: 1fr 1.5fr; gap: 9px; }
details { margin: 6px 0 10px; }
summary { color: var(--muted); cursor: pointer; font-size: 11px; margin-bottom: 8px; }
.scene-buttons { justify-content: flex-end; }

.stage {
  width: 100%;
  aspect-ratio: 9 / 16;
  max-height: 60vh;
  min-height: 420px;
  position: relative;
  overflow: hidden;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,.1);
  background:
    radial-gradient(circle at 50% 24%, rgba(139,92,246,.18), transparent 32%),
    linear-gradient(160deg, #111629, #090c16 60%, #05070c);
}
.stage.horizontal { aspect-ratio: 16 / 9; min-height: 260px; max-height: none; }
.stage-grid { position: absolute; inset: 0; opacity: .15; background-image: linear-gradient(rgba(255,255,255,.07) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.07) 1px, transparent 1px); background-size: 36px 36px; }
.stage img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; filter: saturate(.95) contrast(1.05); transform: scale(1.02); }
.stage-placeholder { position: absolute; inset: 0; display: grid; align-content: center; justify-items: center; gap: 5px; color: var(--muted); }
.stage-placeholder strong { color: var(--text); }
.caption { position: absolute; left: 8%; right: 8%; bottom: 8%; padding: 11px 13px; border-radius: 12px; text-align: center; font-weight: 800; line-height: 1.35; background: rgba(0,0,0,.54); backdrop-filter: blur(9px); text-shadow: 0 2px 10px #000; }
.rec-indicator { position: absolute; top: 13px; left: 13px; z-index: 3; display: flex; align-items: center; gap: 5px; font-size: 9px; font-weight: 900; letter-spacing: .1em; color: rgba(255,255,255,.75); }
.rec-indicator span { width: 7px; height: 7px; border-radius: 50%; background: var(--danger); box-shadow: 0 0 12px rgba(251,113,133,.8); }

.stage.talking img { animation: cinematicMove 7s ease-in-out infinite alternate, actorPulse .34s ease-in-out infinite alternate; }
.stage.talking .caption { animation: captionIn .35s ease both; }
.stage.emotion-angry { box-shadow: inset 0 0 90px rgba(251,113,133,.18); }
.stage.emotion-sad { box-shadow: inset 0 0 90px rgba(34,211,238,.13); }
.stage.emotion-joyful { box-shadow: inset 0 0 90px rgba(251,191,36,.15); }
@keyframes cinematicMove { from { transform: scale(1.03) translate3d(-1.2%,0,0); } to { transform: scale(1.11) translate3d(1.4%,-1.1%,0); } }
@keyframes actorPulse { from { filter: saturate(.95) contrast(1.04) brightness(.99); } to { filter: saturate(1.02) contrast(1.06) brightness(1.02); } }
@keyframes captionIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.transport { display: flex; align-items: center; gap: 11px; margin-top: 13px; }
.transport > div { min-width: 0; flex: 1; }
.transport strong, .transport span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.transport span { color: var(--muted); font-size: 10px; margin-top: 2px; }
.round-button { width: 40px; height: 40px; border: 0; border-radius: 50%; color: white; background: linear-gradient(135deg, var(--accent), #6d5dfc); cursor: pointer; }

.pipeline-list { list-style: none; padding: 0; margin: 0 0 14px; display: grid; gap: 9px; }
.pipeline-list li { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 12px; }
.pipeline-list li > span { width: 10px; height: 10px; border-radius: 50%; background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.12); }
.pipeline-list li.active { color: #ddd6fe; }
.pipeline-list li.active > span { background: var(--accent); box-shadow: 0 0 14px rgba(139,92,246,.8); }
.pipeline-list li.done { color: #a7f3d0; }
.pipeline-list li.done > span { background: var(--success); box-shadow: 0 0 12px rgba(52,211,153,.55); }
.pipeline-list li.error { color: #fecdd3; }
.pipeline-list li.error > span { background: var(--danger); }
.notice { padding: 11px; border-radius: 12px; font-size: 11px; color: #cbd5e1; line-height: 1.45; background: rgba(251,191,36,.06); border: 1px solid rgba(251,191,36,.14); }
.notice code { color: #fde68a; }
.log-panel { margin: 12px 0 0; min-height: 90px; max-height: 220px; overflow: auto; padding: 12px; border-radius: 12px; color: #9ee7ff; background: #05070c; border: 1px solid rgba(255,255,255,.06); font-size: 10px; line-height: 1.45; white-space: pre-wrap; }

@media (max-width: 1280px) {
  .workspace { grid-template-columns: 280px 1fr; }
  .preview-column { grid-column: 1 / -1; grid-template-columns: minmax(360px, 1fr) minmax(290px, .7fr); }
  .sidebar { top: 82px; }
}
@media (max-width: 860px) {
  .topbar { position: static; align-items: flex-start; }
  .workspace { display: block; padding: 12px; }
  .sidebar, .creator-column, .preview-column { position: static; display: grid; grid-template-columns: 1fr; margin-bottom: 12px; }
  .card { margin-bottom: 12px; }
  .grid.two, .grid.three, .scene-detail-grid { grid-template-columns: 1fr; }
  .section-heading-row { align-items: flex-start; flex-direction: column; }
  .timeline-actions { width: 100%; }
  .timeline-actions .button { flex: 1; }
  .stage { min-height: 500px; max-height: none; }
}
@media (max-width: 560px) {
  .topbar { padding: 12px; }
  .brand span { display: none; }
  .top-actions .button { padding: 8px 10px; }
  .workspace { padding: 8px; }
  .sidebar, .composer, .timeline-card, .preview-card, .status-card { padding: 14px; }
  .scene-card { grid-template-columns: 1fr; }
  .scene-number { width: 30px; height: 30px; }
  .transport { flex-wrap: wrap; }
  .transport .button { width: 100%; text-align: center; }
}
.stage video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #000; z-index: 2; }
