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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f5f5f5;
  color: #333;
  line-height: 1.5;
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.container { max-width: 1200px; margin: 0 auto; padding: 20px; overflow-y: auto; flex: 1; }

header {
  background: #1a1a2e;
  color: white;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
}

header h1 { font-size: 20px; font-weight: 600; }
header .back-btn {
  background: rgba(255,255,255,0.15);
  border: none;
  color: white;
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
}
header .back-btn:hover { background: rgba(255,255,255,0.25); }

/* Project List */
.project-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 20px;
  justify-content: flex-start;
}
.project-card, .add-card {
  width: 280px;
  flex-shrink: 0;
}

.project-card {
  background: white;
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  cursor: pointer;
  transition: box-shadow 0.2s;
}
.project-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.15); }
.project-card h3 { font-size: 18px; margin-bottom: 8px; }
.project-card .stats { color: #666; font-size: 14px; }
.project-card .status { font-size: 12px; margin-top: 8px; }
.project-card .status.ready { color: #27ae60; }
.project-card .status.analyzing { color: #f39c12; }
.project-card .status.error { color: #e74c3c; }
.project-card .status.created { color: #3498db; }

.add-card {
  border: 2px dashed #ccc;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 120px;
  cursor: pointer;
  background: transparent;
  box-shadow: none;
}
.add-card:hover { border-color: #999; }
.add-card span { font-size: 36px; color: #999; }

/* Modal */
.modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}
.modal {
  background: white;
  border-radius: 8px;
  padding: 24px;
  min-width: 400px;
  max-width: 500px;
}
.modal h2 { margin-bottom: 16px; font-size: 18px; }
.modal label { display: block; margin-bottom: 4px; font-weight: 500; font-size: 14px; }
.modal input[type="text"] {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
  margin-bottom: 12px;
}
.modal .btn-row { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }

/* Buttons */
.btn {
  padding: 8px 16px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
}
.btn-primary { background: #3498db; color: white; }
.btn-primary:hover { background: #2980b9; }
.btn-danger { background: #e74c3c; color: white; }
.btn-danger:hover { background: #c0392b; }
.btn-secondary { background: #95a5a6; color: white; }
.btn-secondary:hover { background: #7f8c8d; }
.btn-success { background: #27ae60; color: white; }
.btn-success:hover { background: #219a52; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Project workspace: two-panel layout */
.project-workspace {
  display: flex;
  flex: 1;
  overflow: hidden;
  background: #111827;
}

.left-panel {
  width: 300px;
  min-width: 260px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: #0f172a;
  border-right: 1px solid #1f2937;
  overflow: hidden;
}

.left-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 700;
  color: #94a3b8;
  letter-spacing: .07em;
  text-transform: uppercase;
  border-bottom: 1px solid #1f2937;
  flex-shrink: 0;
  background: #0f172a;
}

.right-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* Role list in left panel */
.role-list {
  overflow-y: auto;
  flex: 1;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Progress */
.progress-container { margin: 20px 0; }
.progress-bar-wrapper {
  background: #eee;
  border-radius: 4px;
  height: 8px;
  overflow: hidden;
  margin-top: 8px;
}
.progress-bar-fill {
  height: 100%;
  background: #3498db;
  transition: width 0.3s;
  border-radius: 4px;
}
.progress-label { font-size: 14px; color: #666; }

/* Role Gallery */
.role-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.role-card {
  background: #1e293b;
  border-radius: 6px;
  padding: 10px;
  border: 1px solid #334155;
}
.role-card.skipped { opacity: 0.45; }

.role-portraits {
  display: flex;
  gap: 4px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.role-portraits img {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 3px;
  border: 1px solid #334155;
  cursor: pointer;
}

.role-name-input {
  width: 100%;
  padding: 4px 8px;
  border: 1px solid #374151;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  background: #0f172a;
  color: #e2e8f0;
}
.role-name-input:focus { border-color: #3b82f6; outline: none; }

.role-stats { font-size: 11px; color: #64748b; margin-bottom: 8px; }

.role-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

.role-replacement {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid #1f2937;
}
.role-replacement img {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 3px;
  border: 2px solid #22c55e;
}
.role-replacement .label { font-size: 11px; color: #22c55e; font-weight: 500; }

.skip-toggle { display: flex; align-items: center; gap: 6px; font-size: 12px; color: #9ca3af; }
.skip-toggle input { cursor: pointer; }

/* File upload hidden input */
.file-input-hidden { display: none; }

/* Jobs */
.job-list { margin-top: 16px; }
.job-item {
  background: white;
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  display: flex;
  align-items: center;
  gap: 16px;
}
.job-item .job-name { font-weight: 500; flex: 1; }
.job-item .job-status { font-size: 13px; }
.job-item .job-status.completed { color: #27ae60; }
.job-item .job-status.running { color: #f39c12; }
.job-item .job-status.failed { color: #e74c3c; }
.job-item .job-status.pending { color: #999; }

.empty-state {
  text-align: center;
  padding: 40px;
  color: #999;
  font-size: 15px;
}

/* Analyze section — compact bar in left panel */
.analyze-section {
  background: #1e293b;
  padding: 8px 12px;
  border-bottom: 1px solid #334155;
}
.analyze-section p { margin-bottom: 8px; color: #94a3b8; font-size: 12px; }

/* Lightbox */
.img-lightbox {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}
.img-lightbox img {
  max-width: 90vw;
  max-height: 90vh;
  border-radius: 4px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.5);
}
.img-lightbox-close {
  position: fixed;
  top: 20px;
  right: 28px;
  font-size: 36px;
  color: #fff;
  cursor: pointer;
  line-height: 1;
  user-select: none;
}

/* Timeline (legacy — kept for fallback) */
#timelineWrap {
  background: #111827;
  border-radius: 8px;
  padding: 12px 16px 10px;
  margin-bottom: 4px;
}
#sceneDetail {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 16px 20px;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}

/* NLE Layout */
.nle-topbar { display:flex;align-items:center;gap:8px;padding:8px 12px 8px;flex-shrink:0;background:#0f172a;border-bottom:1px solid #1f2937 }
.nle-topbar select { flex:1;min-width:0;padding:6px 10px;border:1px solid #374151;border-radius:4px;font-size:14px;background:#1e293b;color:#e2e8f0 }
.nle-upper { display:flex;gap:0;flex:1;min-height:0;border-radius:0;overflow:hidden;border:none }
.nle-media-panel { width:180px;flex-shrink:0;background:#111827;display:flex;flex-direction:column;border-right:1px solid #1f2937 }
.nle-preview-panel { flex:1;background:#000;display:flex;align-items:center;justify-content:center;min-width:0 }
.nle-media-item { display:flex;gap:8px;align-items:center;padding:6px 10px;cursor:pointer;border-bottom:1px solid #1f2937;transition:background .1s }
.nle-media-item:hover { background:#1f2937 }
.nle-media-item-active { background:#1e3a5f !important }
.nle-media-thumb { width:48px;height:32px;flex-shrink:0;border-radius:3px;overflow:hidden }
.nle-media-label { min-width:0;flex:1 }
.nle-timeline-panel { flex-shrink:0;background:#111827;border-radius:0 0 6px 6px;border:1px solid #1f2937;border-top:2px solid #374151 }
.nle-timeline-toolbar { display:flex;align-items:center;padding:6px 8px;border-bottom:1px solid #1f2937 }
.nle-track-label { width:70px;flex-shrink:0;display:flex;align-items:center;padding:0 8px;font-size:11px;color:#6b7280;background:#0f172a;border-right:1px solid #1f2937 }
#timelineTrack { background:#1f2937;cursor:pointer }
#timelineRuler { background:#111827;font-size:10px;color:#6b7280 }
.nle-legend-dot { display:inline-block;width:8px;height:8px;border-radius:2px;margin-right:4px;vertical-align:middle }
