:root {
  --bg-deep: #060e0b;
  --bg-dark: #08130f;
  --panel-bg: #0d1e17;
  --panel-alt: #11261e;
  --border-subtle: #1a382c;
  --border-glow: #245240;
  
  --emerald: #10b981;
  --emerald-glow: rgba(16, 185, 129, 0.25);
  --cyan: #06b6d4;
  --cyan-glow: rgba(6, 182, 212, 0.25);
  --gold: #f59e0b;
  --gold-glow: rgba(245, 158, 11, 0.25);
  --crimson: #ef4444;
  --magenta: #ec4899;

  --text-main: #f3f4f6;
  --text-dim: #9ca3af;
  --text-muted: #6b7280;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

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

body {
  background-color: var(--bg-deep);
  color: var(--text-main);
  font-family: var(--font-sans);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* TOP NAVIGATION HEADER */
.music-header {
  background: rgba(13, 30, 23, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  padding: 12px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-icon {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, var(--emerald), var(--cyan));
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #060e0b;
  font-size: 18px;
  box-shadow: 0 0 15px var(--emerald-glow);
}

.brand-title {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-title .badge-sub {
  font-size: 11px;
  font-weight: 600;
  background: var(--panel-alt);
  color: var(--cyan);
  padding: 2px 8px;
  border-radius: 12px;
  border: 1px solid var(--border-glow);
  font-family: var(--font-mono);
}

.brand-desc {
  font-size: 11px;
  color: var(--text-dim);
}

.header-links {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-links a {
  color: var(--text-dim);
  text-decoration: none;
  font-size: 12px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid transparent;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
}

.header-links a:hover {
  color: var(--emerald);
  background: var(--panel-alt);
  border-color: var(--border-subtle);
}

.header-links a.active {
  color: var(--emerald);
  background: rgba(16, 185, 129, 0.12);
  border-color: var(--border-glow);
}

/* MAIN CONTAINER LAYOUT */
.main-wrapper {
  max-width: 1700px;
  margin: 0 auto;
  padding: 24px;
  flex: 1;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* SECTION CARDS */
.studio-card {
  background: var(--panel-bg);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  transition: border-color 0.2s;
}

.studio-card:hover {
  border-color: var(--border-glow);
}

.card-header {
  padding: 16px 20px;
  background: var(--panel-alt);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.card-header-left i {
  color: var(--emerald);
  font-size: 16px;
}

.card-title {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.01em;
}

.card-subtitle {
  font-size: 12px;
  color: var(--text-dim);
}

.card-header-badge {
  font-size: 11px;
  font-family: var(--font-mono);
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(16, 185, 129, 0.15);
  color: var(--emerald);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.card-body {
  padding: 20px;
}

/* WORKFLOW STAGE 1: AUDIO & STYLE LOCK SHEET */
.ingest-grid {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 20px;
}

@media (max-width: 1100px) {
  .ingest-grid {
    grid-template-columns: 1fr;
  }
}

.drop-zone {
  border: 2px dashed var(--border-glow);
  border-radius: 10px;
  padding: 30px 20px;
  text-align: center;
  background: rgba(8, 19, 15, 0.6);
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.drop-zone:hover, .drop-zone.dragover {
  border-color: var(--emerald);
  background: rgba(16, 185, 129, 0.05);
}

.drop-zone i {
  font-size: 36px;
  color: var(--emerald);
}

.drop-zone .drop-title {
  font-size: 15px;
  font-weight: 600;
  color: #fff;
}

.drop-zone .drop-hint {
  font-size: 12px;
  color: var(--text-dim);
}

/* AUDIO WAVEFORM & CONTROLS */
.audio-player-box {
  display: none;
  margin-top: 16px;
  background: var(--bg-deep);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 16px;
}

.audio-track-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.track-filename {
  font-size: 13px;
  font-weight: 600;
  color: var(--cyan);
  display: flex;
  align-items: center;
  gap: 6px;
}

.track-duration {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--gold);
  background: rgba(245, 158, 11, 0.1);
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid rgba(245, 158, 11, 0.25);
}

.waveform-canvas-wrap {
  width: 100%;
  height: 60px;
  position: relative;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 12px;
}

#waveformCanvas {
  width: 100%;
  height: 100%;
  display: block;
}

.playback-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn-icon-play {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--emerald);
  color: #060e0b;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: transform 0.15s, box-shadow 0.15s;
}

.btn-icon-play:hover {
  transform: scale(1.06);
  box-shadow: 0 0 12px var(--emerald-glow);
}

.player-timer {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-dim);
}

/* FORM FIELDS & STYLE LOCK */
.field-group {
  margin-bottom: 14px;
}

.field-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.field-label span.badge-lock {
  color: var(--emerald);
  font-size: 10px;
  background: rgba(16, 185, 129, 0.15);
  padding: 1px 6px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.input-text, .select-input, .textarea-input {
  width: 100%;
  background: var(--bg-deep);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  color: #fff;
  padding: 9px 12px;
  font-size: 13px;
  font-family: var(--font-sans);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input-text:focus, .select-input:focus, .textarea-input:focus {
  border-color: var(--emerald);
  box-shadow: 0 0 0 2px var(--emerald-glow);
}

.textarea-input {
  resize: vertical;
  min-height: 64px;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.btn-primary {
  width: 100%;
  padding: 12px 18px;
  background: linear-gradient(135deg, var(--emerald), #059669);
  color: #060e0b;
  font-size: 14px;
  font-weight: 700;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s;
  box-shadow: 0 4px 14px var(--emerald-glow);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #34d399, var(--emerald));
  box-shadow: 0 6px 18px rgba(16, 185, 129, 0.4);
  transform: translateY(-1px);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}

/* CHARACTER PRESET PILLS & CONCEPT CARD */
.character-preset-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.preset-pill {
  background: var(--bg-deep);
  border: 1px solid var(--border-subtle);
  color: var(--text-dim);
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: var(--font-sans);
}

.preset-pill:hover {
  border-color: var(--emerald);
  color: #fff;
  background: rgba(16, 185, 129, 0.1);
}

.preset-pill.active {
  border-color: var(--emerald);
  background: rgba(16, 185, 129, 0.2);
  color: var(--emerald);
  font-weight: 600;
}

.badge-warning {
  background: rgba(245, 158, 11, 0.15);
  color: var(--gold);
  border: 1px solid rgba(245, 158, 11, 0.35);
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 10px;
  font-family: var(--font-mono);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.badge-success {
  background: rgba(16, 185, 129, 0.18);
  color: var(--emerald);
  border: 1px solid rgba(16, 185, 129, 0.45);
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 10px;
  font-family: var(--font-mono);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.badge-danger {
  background: rgba(239, 68, 68, 0.18);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.4);
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 10px;
  font-family: var(--font-mono);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* AI DISCOVERED CHARACTER CARDS */
.discovered-char-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
  margin-top: 8px;
}

.discovered-char-card {
  background: var(--bg-deep);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.discovered-char-card:hover {
  border-color: var(--emerald);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.15);
}

.discovered-char-card.selected {
  border-color: var(--emerald);
  background: rgba(16, 185, 129, 0.12);
  box-shadow: 0 0 0 1px var(--emerald);
}

.discovered-char-name {
  font-weight: 700;
  font-size: 13px;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.discovered-char-role {
  font-size: 10px;
  background: rgba(6, 182, 212, 0.15);
  color: var(--cyan);
  padding: 1px 6px;
  border-radius: 4px;
  font-family: var(--font-mono);
}

.discovered-char-desc {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 6px;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.discovered-char-prop {
  font-size: 10px;
  color: var(--gold);
  margin-top: 6px;
  font-family: var(--font-mono);
}

/* STAGE 2: STORYBOARD TIMELINE GRID */
.timeline-meta-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--panel-alt);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.timeline-stats {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 12px;
  color: var(--text-dim);
}

.stat-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  background: rgba(0, 0, 0, 0.3);
  padding: 3px 10px;
  border-radius: 6px;
  border: 1px solid var(--border-subtle);
}

.stat-pill i {
  color: var(--cyan);
}

.storyboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
  max-height: 680px;
  overflow-y: auto;
  padding-right: 6px;
}

/* Custom Scrollbar */
.storyboard-grid::-webkit-scrollbar {
  width: 6px;
}
.storyboard-grid::-webkit-scrollbar-thumb {
  background: var(--border-glow);
  border-radius: 3px;
}

.scene-card {
  background: var(--bg-deep);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: all 0.2s;
}

.scene-card:hover {
  border-color: var(--emerald);
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
}

.scene-thumb-wrap {
  width: 100%;
  aspect-ratio: 9 / 16;
  max-height: 420px;
  position: relative;
  background: #000;
  overflow: hidden;
}

.scene-thumb-wrap.ratio-16-9 {
  aspect-ratio: 16 / 9;
  max-height: none;
}

.scene-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s;
}

.scene-card:hover .scene-thumb {
  transform: scale(1.03);
}

.scene-time-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  background: rgba(13, 30, 23, 0.9);
  color: var(--cyan);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border-glow);
}

.scene-motion-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(0, 0, 0, 0.85);
  color: var(--gold);
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid rgba(245, 158, 11, 0.3);
  text-transform: uppercase;
}

.scene-content {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.scene-num-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.scene-index-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--emerald);
  font-family: var(--font-mono);
}

.scene-title-input {
  background: transparent;
  border: 1px solid transparent;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  width: 100%;
  border-radius: 4px;
  padding: 2px 4px;
}

.scene-title-input:focus {
  background: var(--panel-alt);
  border-color: var(--border-glow);
}

.scene-action-input {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  color: var(--text-dim);
  font-size: 11px;
  padding: 6px;
  resize: none;
  min-height: 48px;
  font-family: var(--font-sans);
}

.scene-action-input:focus {
  border-color: var(--emerald);
  color: #fff;
}

.scene-footer-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: auto;
  padding-top: 8px;
  border-top: 1px solid rgba(26, 56, 44, 0.5);
}

.btn-scene-action {
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-dim);
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 11px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s;
}

.btn-scene-action:hover {
  color: var(--cyan);
  border-color: var(--cyan);
  background: rgba(6, 182, 212, 0.1);
}

/* STAGE 3: MASTER COMPILATION & VIDEO PLAYER */
.production-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 20px;
}

@media (max-width: 1100px) {
  .production-grid {
    grid-template-columns: 1fr;
  }
}

.video-container {
  background: #000;
  border-radius: 10px;
  border: 1px solid var(--border-subtle);
  overflow: hidden;
  position: relative;
  aspect-ratio: 9 / 16;
  max-height: 580px;
  max-width: 330px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

.video-container.ratio-16-9 {
  aspect-ratio: 16 / 9;
  max-height: none;
  max-width: 100%;
  margin: 0;
}

#masterVideoPlayer {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.video-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-muted);
}

.video-placeholder i {
  font-size: 42px;
  color: var(--border-glow);
}

.render-console-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.progress-box {
  background: var(--bg-deep);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 16px;
}

.progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  margin-bottom: 8px;
}

.progress-label {
  font-weight: 600;
  color: var(--cyan);
  display: flex;
  align-items: center;
  gap: 6px;
}

.progress-percentage {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--emerald);
}

.progress-bar-bg {
  width: 100%;
  height: 8px;
  background: rgba(26, 56, 44, 0.5);
  border-radius: 4px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--emerald), var(--cyan));
  transition: width 0.3s;
  box-shadow: 0 0 10px var(--cyan-glow);
}

.render-step-msg {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 8px;
  font-family: var(--font-mono);
}

/* STAGE 4: GENERATION HISTORY TRAIL */
.trail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
  max-height: 400px;
  overflow-y: auto;
}

.trail-card {
  background: var(--bg-deep);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  gap: 12px;
  padding: 12px;
  transition: all 0.2s;
  align-items: center;
}

.trail-card:hover {
  border-color: var(--emerald);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
}

.trail-thumb {
  width: 90px;
  height: 65px;
  border-radius: 6px;
  object-fit: cover;
  background: #000;
  border: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.trail-details {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.trail-title {
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.trail-meta {
  font-size: 11px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 8px;
}

.trail-meta span {
  font-family: var(--font-mono);
  color: var(--cyan);
}

.trail-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.trail-btn {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  border: 1px solid var(--border-subtle);
  background: var(--panel-alt);
  color: var(--text-dim);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  transition: all 0.15s;
}

.trail-btn:hover {
  color: var(--emerald);
  border-color: var(--emerald);
}

.trail-btn-pen:hover {
  color: var(--cyan);
  border-color: var(--cyan);
  background: rgba(6, 182, 212, 0.15);
}

.trail-btn-delete:hover {
  color: var(--crimson);
  border-color: var(--crimson);
  background: rgba(239, 68, 68, 0.15);
}

/* FOOTER */
.studio-footer {
  margin-top: auto;
  padding: 16px 24px;
  border-top: 1px solid var(--border-subtle);
  background: var(--panel-bg);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--text-muted);
}

