/* ── Recoil Pre-Production Console ── */
/* Unified design: cyan accent for UI chrome, green reserved for semantic success states */
:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-tertiary: #1a1a24;
  --bg-card: #12121a;
  --bg-hover: #1e1e2e;
  --bg-active: #252535;

  --border-dim: #1e1e2e;
  --border-default: #2a2a3a;
  --border-bright: #3a3a4a;

  --text-primary: #e0e0e0;
  --text-secondary: #aaa;
  --text-dim: #666;
  --text-label: #888;

  /* Cyan = UI chrome accent. Green = semantic success/complete only. */
  --accent-green: #22c55e;
  --accent-green-dim: #1a3a2e;
  --accent-cyan: #00f0ff;
  --accent-cyan-dim: #003a40;
  --accent-amber: #f59e0b;
  --accent-amber-dim: #5a3d00;
  --accent-red: #ef4444;
  --accent-red-dim: #5a1a1a;
  --accent-blue: #2196f3;
  --accent-blue-dim: #1a3a5a;
  --accent-magenta: #ff00aa;
  --accent-purple: #9c27b0;

  --font-display: 'Orbitron', monospace;
  --font-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-script: 'Courier Prime', 'Courier New', monospace;

  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;

  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;
}

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

html, body {
  height: 100%;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  overflow: hidden;
}
body {
  display: flex;
  flex-direction: column;
}

/* ── Typography Rules (shared with Starsend) ── */
h1, h2, h3, h4, h5, h6,
.ui-chrome, button, .tab-btn, .sidebar-header, .card-header, .section-title, th, .stat-label {
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* ── Console Bar (unified top bar + tabs) ── */
.console-bar {
  display: flex;
  align-items: center;
  height: 44px;
  padding: 0 16px;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-dim);
  flex-shrink: 0;
  gap: 0;
}

.console-bar-identity {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 4px;
  text-transform: uppercase;
  color: var(--text-dim);
  white-space: nowrap;
  margin-right: 16px;
  flex-shrink: 0;
}

.console-bar-identity span {
  color: var(--accent-cyan);
}

.console-bar-spacer { flex: 1; }

.console-bar-tabs {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.project-selector {
  background: var(--bg-tertiary);
  color: var(--accent-amber);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  padding: 4px 24px 4px 10px;
  margin-left: 16px;
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 2px;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23f59e0b'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  outline: none;
}
.project-selector:hover { border-color: var(--border-bright); }

/* ── Dropdown ── */
.dropdown { position: relative; }
.dropdown-trigger {
  background: transparent;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  padding: 4px 12px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-dim);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.dropdown-trigger:hover { color: var(--text-secondary); border-color: var(--border-bright); }
.dropdown.open .dropdown-trigger { color: var(--accent-cyan); border-color: var(--accent-cyan); }

.dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 200px;
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 4px 0;
  z-index: 100;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.dropdown.open .dropdown-menu { display: block; }
.dropdown-section {
  padding: 8px 14px 4px;
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-dim);
}
.dropdown-item {
  display: block;
  padding: 6px 14px;
  font-size: 12px;
  color: var(--text-secondary);
  text-decoration: none;
  transition: all var(--transition-fast);
}
.dropdown-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.dropdown-item.disabled { color: var(--text-dim); pointer-events: none; opacity: 0.5; }
.dropdown-divider { height: 1px; background: var(--border-dim); margin: 4px 0; }

/* ── Tab Buttons (inside console-bar) — matches labs crossnav links ── */
.tab-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 12px;
  height: 44px;
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 2px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.2s;
  white-space: nowrap;
  text-transform: uppercase;
}

.tab-btn:hover { color: var(--accent-cyan); }
.tab-btn.active {
  color: var(--accent-cyan);
  border-bottom-color: var(--accent-cyan);
}

.tab-num {
  font-family: var(--font-display);
  font-size: 9px;
  font-weight: 700;
  opacity: 0.5;
}
.tab-btn.active .tab-num {
  opacity: 1;
}

.tab-badge {
  font-size: 9px;
  padding: 1px 5px;
  border-radius: 8px;
  background: var(--bg-tertiary);
  color: var(--text-dim);
}
.tab-btn.active .tab-badge {
  background: var(--accent-cyan-dim);
  color: var(--accent-cyan);
}

.tab-shortcut {
  font-size: 9px;
  color: var(--text-dim);
  margin-left: 4px;
}

/* ── Main Layout ── */
.main-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ── Episode Sidebar ── */
.sidebar {
  width: 200px;
  min-width: 200px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-dim);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width var(--transition-normal);
}

.sidebar.collapsed {
  width: 40px;
  min-width: 40px;
}

.sidebar-header {
  padding: 8px 12px;
  font-family: var(--font-display);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 3px;
  color: var(--text-dim);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-dim);
  display: flex;
  justify-content: space-between;
  align-items: center;
  white-space: nowrap;
}

.episode-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
}

.episode-item {
  display: flex;
  align-items: center;
  padding: 8px 16px;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-secondary);
  transition: background var(--transition-fast);
  gap: 8px;
  white-space: nowrap;
  border-bottom: 1px solid rgba(30, 30, 46, 0.4);
}

.episode-item:hover { background: rgba(0,240,255,0.05); color: var(--text-primary); }
.episode-item.active {
  background: rgba(0,240,255,0.1);
  color: var(--accent-cyan);
  border-left: 2px solid var(--accent-cyan);
}

.episode-item .ep-num { flex-shrink: 0; width: 44px; }
.episode-item .ep-status { font-size: 10px; flex-shrink: 0; }
.episode-item.episode-full .ep-num { font-weight: 700; letter-spacing: 0.5px; }

.revision-badge {
  margin-left: auto;
  background: var(--accent-amber-dim);
  color: var(--accent-amber);
  font-size: 9px;
  font-weight: bold;
  min-width: 16px;
  height: 16px;
  line-height: 16px;
  text-align: center;
  border-radius: 8px;
  padding: 0 4px;
  flex-shrink: 0;
}

.status-icon { font-size: 10px; }
.status-complete { color: var(--accent-green); }
.status-progress { color: var(--accent-amber); }
.status-pending { color: var(--text-dim); }

.sidebar-toggle {
  padding: 8px;
  background: var(--bg-tertiary);
  border: none;
  border-top: 1px solid var(--border-dim);
  color: var(--text-dim);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 10px;
  text-align: right;
  padding-right: 12px;
  transition: color var(--transition-fast);
}
.sidebar-toggle:hover { color: var(--text-primary); }

.sidebar-toggle-top {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 10px;
  padding: 2px 4px;
  line-height: 1;
}
.sidebar-toggle-top:hover { color: var(--text-primary); }
/* Collapsed sidebar: show expand arrow in header, hide text */
.sidebar.collapsed .sidebar-toggle-top {
  display: block;
  width: 100%;
  text-align: center;
  padding: 4px 0;
}
.sidebar.collapsed .sidebar-header {
  justify-content: center;
  padding: 6px 4px;
}
.sidebar.collapsed .sidebar-header span { display: none; }
.sidebar.collapsed .episode-item {
  padding: 8px 0;
  justify-content: center;
}
.sidebar.collapsed .ep-num {
  width: auto;
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 700;
}
.sidebar.collapsed .episode-item.active .ep-num {
  color: var(--accent-amber);
}
.sidebar.collapsed .ep-prefix { display: none; }
.sidebar.collapsed .ep-status { display: none; }
.sidebar.collapsed .revision-badge { display: none; }
.sidebar.collapsed .sidebar-toggle {
  text-align: center;
  padding-right: 8px;
}

/* ── Workspace ── */
.workspace {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-primary);
  min-height: 0;
}

.tab-panel {
  display: none;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 28px 32px;
}
#panel-revision { padding: 0; }

.tab-panel.active { display: flex; }

/* ── Status Bar ── */
.status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 28px;
  padding: 0 16px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-dim);
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-dim);
  flex-shrink: 0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.status-bar-left, .status-bar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.progress-bar-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.progress-bar {
  width: 120px;
  height: 6px;
  background: var(--bg-tertiary);
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--accent-cyan);
  border-radius: 3px;
  transition: width var(--transition-normal);
}

/* ── Sub-tab bar (within panels) ── */
.subtab-bar {
  display: flex;
  gap: 4px;
  margin-bottom: 8px;
  flex-shrink: 0;
}

/* ── Shared Components ── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-dim);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 12px;
  transition: border-color var(--transition-fast);
}
.card:hover { border-color: var(--accent-cyan); }

.card-header {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-dim);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-dim);
}

.section-title {
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 20px 0 12px 0;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-dim);
}
.section-title:first-child { margin-top: 0; }

.btn {
  padding: 4px 12px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-default);
  cursor: pointer;
  transition: all var(--transition-fast);
  color: var(--text-primary);
  background: var(--bg-tertiary);
}
.btn:hover { background: var(--bg-hover); border-color: var(--accent-cyan); }
.btn-primary { background: var(--accent-cyan-dim); border-color: var(--accent-cyan); color: #fff; }
.btn-primary:hover { background: var(--accent-cyan); }
.btn-success { background: var(--accent-green-dim); border-color: var(--accent-green); color: #fff; }
.btn-success:hover { background: var(--accent-green); }
.btn-danger { background: var(--accent-red-dim); border-color: var(--accent-red); color: #fff; }
.btn-danger:hover { background: var(--accent-red); }

.pill {
  display: inline-block;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-dim);
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ── Stat Grid ── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin: 12px 0;
}
.stat-box {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-dim);
  border-radius: var(--radius-md);
  padding: 12px;
  text-align: center;
}
.stat-value {
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
}
.stat-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-top: 4px;
}

/* ── Bar Chart ── */
.bar-chart { margin: 8px 0; }
.bar-row { display: flex; align-items: center; margin-bottom: 6px; gap: 8px; }
.bar-label { width: 50px; font-family: var(--font-mono); font-size: 11px; color: var(--text-secondary); text-align: right; flex-shrink: 0; }
.bar-track { flex: 1; height: 16px; background: var(--bg-tertiary); border-radius: var(--radius-sm); overflow: hidden; position: relative; }
.bar-fill { height: 100%; border-radius: var(--radius-sm); transition: width var(--transition-normal); min-width: 2px; }
.bar-fill.target { opacity: 0.3; border-right: 2px dashed rgba(255,255,255,0.3); }
.bar-fill.actual { position: absolute; top: 0; left: 0; }
.bar-value { width: 45px; font-family: var(--font-mono); font-size: 10px; color: var(--text-dim); flex-shrink: 0; }

/* ── Timeline ── */
.timeline-container { position: relative; height: 80px; margin: 16px 0; background: var(--bg-tertiary); border-radius: var(--radius-md); overflow: hidden; }
.timeline-track { position: absolute; top: 0; left: 0; right: 0; bottom: 0; }
.timeline-zone { position: absolute; top: 0; bottom: 0; opacity: 0.2; border-radius: var(--radius-sm); }
.timeline-zone.spike { background: var(--accent-amber); }
.timeline-zone.button { background: var(--accent-red); }
.timeline-marker { position: absolute; top: 0; bottom: 0; width: 2px; }
.timeline-label { position: absolute; bottom: 4px; font-family: var(--font-mono); font-size: 9px; color: var(--text-secondary); white-space: nowrap; }
.timeline-axis { position: absolute; bottom: 0; left: 0; right: 0; height: 20px; display: flex; justify-content: space-between; padding: 0 4px; font-family: var(--font-mono); font-size: 9px; color: var(--text-dim); align-items: flex-end; }

/* ── Rule List ── */
.rule-list { list-style: none; padding: 0; }
.rule-list li { padding: 6px 0; font-size: 13px; color: var(--text-secondary); border-bottom: 1px solid var(--border-dim); display: flex; gap: 8px; }
.rule-list li:last-child { border-bottom: none; }
.rule-num { font-family: var(--font-mono); font-size: 11px; color: var(--text-dim); flex-shrink: 0; width: 24px; }

/* ── Deviation Warnings ── */
.deviation-list { margin-top: 12px; }
.deviation-item { display: flex; align-items: flex-start; gap: 8px; padding: 8px 10px; margin-bottom: 4px; border-radius: var(--radius-sm); font-size: 12px; background: var(--bg-tertiary); }
.deviation-item.warn { border-left: 3px solid var(--accent-amber); color: var(--accent-amber); }
.deviation-item.ok { border-left: 3px solid var(--accent-green); color: var(--accent-green); }
.deviation-item.error { border-left: 3px solid var(--accent-red); color: var(--accent-red); }

/* ── Empty/Loading States ── */
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 300px; color: var(--text-dim); text-align: center; }
.empty-state-icon { font-size: 48px; margin-bottom: 16px; opacity: 0.3; }
.empty-state-title { font-family: var(--font-mono); font-size: 14px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; margin-bottom: 8px; color: var(--text-secondary); }
.empty-state-desc { font-size: 13px; max-width: 400px; line-height: 1.6; }

.loading-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--border-default);
  border-top-color: var(--accent-cyan);
  border-radius: 50%;
  animation: spin 800ms linear infinite;
  margin-right: 8px;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Modals & Overlays ── */
.modal-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.8);
  z-index: 100; align-items: center; justify-content: center;
}
.modal-overlay.active { display: flex; }
.modal {
  background: var(--bg-secondary); border: 1px solid var(--border-default);
  border-radius: var(--radius-lg); padding: 24px; max-width: 600px; width: 90%;
  max-height: 80vh; overflow-y: auto; box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}
.modal h3 { font-family: var(--font-mono); font-size: 14px; margin-bottom: 16px; color: var(--text-primary); text-transform: uppercase; letter-spacing: 1px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }

/* ── Casting Tab ── */
.casting-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

.casting-card {
  background: var(--bg-card);
  border: 1px solid var(--border-dim);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: border-color var(--transition-fast);
}
.casting-card:hover { border-color: var(--accent-cyan); }

.casting-card-img {
  width: 100%;
  aspect-ratio: 3/4;
  object-fit: cover;
  display: block;
  background: var(--bg-tertiary);
}

.casting-card-body {
  padding: 12px;
}

.casting-card-name {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--text-primary);
  text-transform: uppercase;
  margin-bottom: 4px;
}

.casting-card-role {
  font-family: var(--font-sans);
  font-size: 11px;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.casting-card-status {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.casting-grid-9 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 16px 0;
}

.casting-grid-panel {
  aspect-ratio: 3/4;
  border: 2px solid var(--border-dim);
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: pointer;
  transition: border-color var(--transition-fast);
  background: var(--bg-tertiary);
  position: relative;
}
.casting-grid-panel:hover { border-color: var(--accent-cyan); }
.casting-grid-panel.selected { border-color: var(--accent-cyan); box-shadow: 0 0 12px rgba(0, 240, 255, 0.3); }
.casting-grid-panel img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* URSS RefSelector */
.ref-candidate { position: relative; transition: opacity 0.2s; }
.ref-candidate.ref-rejected { opacity: 0.3; }
.ref-candidate.ref-kept { outline: 2px solid var(--accent-amber); border-radius: var(--radius-sm); }
.ref-candidate.ref-locked { outline: 2px solid var(--accent-green); border-radius: var(--radius-sm); }
.ref-candidate .ref-actions { opacity: 0; transition: opacity 0.15s; }
.ref-candidate:hover .ref-actions { opacity: 1; }

/* ── Location Moodboard Cards ── */
.loc-ref-card {
  position: relative;
  border: 2px solid var(--border-dim);
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: pointer;
  transition: border-color 150ms ease, opacity 150ms ease;
}
.loc-ref-card img {
  width: 100%; aspect-ratio: 9/16; object-fit: cover; display: block;
  opacity: 0.7; transition: opacity 150ms ease;
}
.loc-ref-card[data-picked="true"] {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 0 1px var(--accent-cyan), 0 0 12px rgba(0, 240, 255, 0.15);
}
.loc-ref-card[data-picked="true"] img { opacity: 1; }
.loc-ref-card[data-picked="true"]::after {
  content: "MOODBOARD";
  position: absolute; top: 6px; left: 6px;
  padding: 2px 6px; font-size: 10px; font-weight: 700;
  font-family: var(--font-mono); letter-spacing: 0.05em;
  background: var(--accent-cyan); color: var(--bg-primary);
  border-radius: 3px; z-index: 2;
}
.loc-ref-card .loc-ref-delete {
  position: absolute; top: 6px; right: 6px;
  width: 22px; height: 22px; border-radius: 50%;
  background: rgba(0,0,0,0.6); color: var(--text-secondary);
  border: none; font-size: 13px; line-height: 22px; text-align: center;
  cursor: pointer; opacity: 0.4;
  transition: opacity 150ms ease, background 150ms ease; z-index: 2;
}
.loc-ref-card:hover .loc-ref-delete,
.loc-ref-card .loc-ref-delete:focus-visible { opacity: 1; }
.loc-ref-card .loc-ref-delete:hover { background: var(--accent-red); color: #fff; }
.loc-ref-card .loc-ref-zoom {
  position: absolute; bottom: 24px; right: 6px;
  width: 22px; height: 22px; border-radius: 50%;
  background: rgba(0,0,0,0.6); color: var(--text-secondary);
  border: none; font-size: 12px; line-height: 22px; text-align: center;
  cursor: pointer; opacity: 0; transition: opacity 150ms ease; z-index: 2;
}
.loc-ref-card:hover .loc-ref-zoom { opacity: 0.7; }
.loc-ref-card .loc-ref-zoom:hover { opacity: 1; background: rgba(0,0,0,0.9); }
.loc-ref-card .loc-ref-fname {
  font-family: var(--font-mono); font-size: 9px; color: var(--text-dim);
  padding: 4px 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* Drop zone active */
.loc-ref-grid.drop-active {
  outline: 2px dashed var(--accent-cyan); outline-offset: -2px;
  background: rgba(0, 240, 255, 0.03);
}
.loc-ref-grid.drop-active .loc-ref-card { opacity: 0.4; pointer-events: none; }
/* Lightbox */
.loc-lightbox {
  display: none; position: fixed; inset: 0; z-index: 9999;
  background: rgba(0,0,0,0.92); align-items: center; justify-content: center; cursor: pointer;
}
.loc-lightbox.active { display: flex; }
.loc-lightbox img { max-width: 90vw; max-height: 90vh; object-fit: contain; cursor: default; }

.turnaround-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin: 16px 0;
}

.turnaround-panel {
  border: 3px solid var(--border-dim);
  border-radius: var(--radius-md);
  overflow: hidden;
  text-align: center;
  transition: border-color var(--transition-fast);
}
.turnaround-panel.approved { border-color: var(--accent-green); }
.turnaround-panel.rejected { border-color: var(--accent-red); opacity: 0.6; }
.turnaround-panel img { width: 100%; display: block; background: var(--bg-tertiary); }
.turnaround-panel .angle-label {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-dim);
  text-transform: uppercase;
  padding: 6px;
}

.expression-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px;
  margin: 12px 0;
}

.expression-item {
  text-align: center;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-dim);
  border-radius: var(--radius-sm);
  padding: 4px;
}
.expression-item img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 2px; }
.expression-item .label { font-family: var(--font-mono); font-size: 9px; color: var(--text-dim); text-transform: uppercase; margin-top: 4px; }

/* ── Workflow Bar (ADR-CUI-01) ── */
.workflow-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border-dim);
}

.workflow-back {
  font-size: 10px;
  padding: 4px 8px;
  flex-shrink: 0;
}

.workflow-char-name {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 1px;
  margin-right: 16px;
  flex-shrink: 0;
}

.workflow-steps {
  display: flex;
  align-items: center;
  gap: 2px;
}

.workflow-arrow {
  color: var(--text-dim);
  font-size: 10px;
  margin: 0 2px;
  opacity: 0.4;
}

.workflow-step {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  padding: 8px 18px;
  background: linear-gradient(180deg, rgba(255,255,255,0.03) 0%, transparent 100%);
  border: 1px solid var(--border-dim);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  letter-spacing: 0.5px;
}
.workflow-step:hover {
  background: linear-gradient(180deg, rgba(255,255,255,0.06) 0%, rgba(255,255,255,0.02) 100%);
  border-color: var(--border-bright);
  color: var(--text-secondary);
}
.workflow-step.active {
  background: linear-gradient(180deg, rgba(255,255,255,0.08) 0%, rgba(255,255,255,0.03) 100%);
  border-color: var(--border-bright);
  color: var(--text-primary);
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

/* LED status dot */
.workflow-led {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--text-dim);
  opacity: 0.4;
  box-shadow: none;
  transition: all var(--transition-fast);
}
.workflow-led.led-green {
  background: var(--accent-green);
  opacity: 1;
  box-shadow: 0 0 6px rgba(34, 197, 94, 0.5);
}
.workflow-led.led-amber {
  background: var(--accent-amber);
  opacity: 1;
  box-shadow: 0 0 6px rgba(245, 158, 11, 0.5);
}
.workflow-led.led-red {
  background: var(--accent-red);
  opacity: 1;
  box-shadow: 0 0 6px rgba(239, 68, 68, 0.4);
}

.workflow-num {
  font-weight: 700;
  margin-right: 6px;
  opacity: 0.5;
  font-size: 10px;
}

/* ── Mood Reference (ADR-CUI-07) ── */
.mood-reference {
  flex-shrink: 0;
  width: 160px;
  text-align: center;
}

.mood-reference-label {
  font-family: var(--font-mono);
  font-size: 8px;
  color: var(--accent-cyan);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.mood-reference img {
  width: 100%;
  aspect-ratio: 2/3;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 2px solid var(--accent-cyan);
  cursor: zoom-in;
}

.mood-reference-hint {
  font-family: var(--font-mono);
  font-size: 7px;
  color: var(--text-dim);
  opacity: 0.5;
  margin-top: 4px;
  line-height: 1.4;
}

/* ── Hero Select (ADR-CUI-05) ── */
.hero-select {
  text-align: center;
  padding: 16px;
  margin-bottom: 16px;
  border: 2px solid var(--accent-green);
  border-radius: var(--radius-md);
  background: rgba(0, 255, 136, 0.03);
}

.hero-select-label {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  color: var(--accent-green);
  letter-spacing: 1px;
  margin-bottom: 12px;
}

.hero-select-img {
  max-width: 300px;
  max-height: 400px;
  object-fit: contain;
  border-radius: var(--radius-sm);
  cursor: zoom-in;
}

.hero-select-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 12px;
}

/* ── Hero Identity Card (ADR-CUI-06) ── */
.hero-identity-card {
  flex-shrink: 0;
  width: 120px;
  text-align: center;
  position: sticky;
  top: 16px;
}

.hero-identity-card img {
  width: 100%;
  aspect-ratio: 3/4;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 2px solid var(--accent-green);
  cursor: zoom-in;
  margin-bottom: 4px;
}

.hero-identity-name {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  color: var(--accent-green);
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

/* ── Phase Cards (ADR-CUI-03) ── */
.phase-card {
  border: 1px solid var(--border-dim);
  border-radius: var(--radius-md);
  margin-bottom: 12px;
  overflow: hidden;
}

.phase-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-dim);
}

.phase-card-label {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.phase-card-eps {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-dim);
}

.phase-card-body {
  padding: 12px;
}

.phase-card-slots {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 8px;
  max-width: 600px;
}

.phase-slot {
  border: 1px dashed var(--border-dim);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.phase-card-prompt {
  padding-top: 8px;
  border-top: 1px solid var(--border-dim);
}

/* Promoted candidate highlight */
.ref-candidate.ref-promoted {
  outline: 2px solid var(--accent-green);
  border-radius: var(--radius-sm);
  opacity: 0.6;
}

/* ── The Bin (ADR-CUI-04) ── */
.casting-bin {
  margin-top: 20px;
  border: 1px solid var(--border-dim);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.casting-bin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--bg-secondary);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  color: var(--text-dim);
  letter-spacing: 0.5px;
  cursor: pointer;
  user-select: none;
}
.casting-bin-header:hover { color: var(--text-primary); }

.casting-bin-toggle {
  font-size: 8px;
  opacity: 0.5;
}

.casting-bin-grid {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  overflow-x: auto;
  flex-wrap: wrap;
}

.casting-bin.collapsed .casting-bin-grid {
  display: none;
}

.casting-bin-image {
  flex-shrink: 0;
  width: 80px;
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: pointer;
  transition: border-color var(--transition-fast);
}
.casting-bin-image:hover { border-color: var(--accent-cyan); }
.casting-bin-image.bin-selected { border-color: var(--accent-cyan); box-shadow: 0 0 8px rgba(0, 240, 255, 0.3); }

.casting-bin-image img {
  width: 100%;
  aspect-ratio: 2/3;
  object-fit: cover;
  display: block;
}

/* ── Reference Sub-tabs (ADR-CUI-09) ── */
.reference-subtabs {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-dim);
}

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 48px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg-card);
  border: 1px solid var(--border-bright);
  padding: 8px 20px;
  border-radius: var(--radius-md);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  opacity: 0;
  pointer-events: none;
  transition: all var(--transition-normal);
  z-index: 1000;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.success { border-color: var(--accent-cyan); color: var(--accent-cyan); }
.toast.error { border-color: var(--accent-red); color: var(--accent-red); }

/* ── Screenplay Tab ── */
.screenplay-page {
  max-width: 680px;
  margin: 0 auto;
  padding: 32px 24px 80px;
}

.screenplay-toolbar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  padding: 0 0 12px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border-dim);
}

.screenplay-save-status {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--accent-green);
}

.screenplay-editor {
  outline: none;
  cursor: text;
}

.screenplay-editor:focus {
  outline: none;
}

.sp-blank {
  height: 8px;
  user-select: none;
}

.screenplay-loading {
  text-align: center;
  padding: 48px 0;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-dim);
  text-transform: uppercase;
}

.screenplay-episode-break {
  height: 48px;
  border-top: 1px solid var(--border-dim);
  margin: 40px 0;
}

.sp-title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 2px;
  text-align: center;
  margin-bottom: 8px;
  padding-bottom: 12px;
}

.sp-meta {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  text-align: center;
  margin-bottom: 4px;
}

.sp-rule {
  height: 1px;
  background: var(--border-dim);
  margin: 24px 0;
}

.sp-beat {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-cyan);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin: 32px 0 16px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-dim);
}

.sp-beat-time {
  color: var(--text-dim);
  font-weight: 400;
}

.sp-scene {
  font-family: var(--font-script);
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  text-transform: uppercase;
  margin: 24px 0 12px;
  letter-spacing: 0.5px;
}

.sp-character {
  font-family: var(--font-script);
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  text-align: center;
  margin: 20px 0 2px;
  letter-spacing: 1px;
}

.sp-paren {
  font-family: var(--font-script);
  font-size: 14px;
  color: var(--text-dim);
  text-align: center;
  margin: 0 auto 4px;
  max-width: 400px;
  font-style: italic;
  line-height: 1.6;
}

.sp-dialogue {
  font-family: var(--font-script);
  font-size: 16px;
  color: var(--text-primary);
  text-align: center;
  margin: 0 auto 8px;
  max-width: 440px;
  line-height: 1.7;
}

.sp-action {
  font-family: var(--font-script);
  font-size: 16px;
  color: var(--text-secondary);
  line-height: 1.8;
  margin: 8px 0;
}

.sp-annotation {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 16px 0 8px;
  padding: 6px 10px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--accent-cyan);
}

/* ── AI Rewrite Popover ── */
.ai-rewrite-overlay {
  position: absolute;
  z-index: 2000;
  background: var(--bg-card);
  border: 1px solid var(--accent-cyan);
  border-radius: var(--radius-md);
  box-shadow: 0 12px 40px rgba(0, 240, 255, 0.15), 0 0 0 1px rgba(0,0,0,0.5);
  width: 420px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-family: var(--font-sans);
}

.ai-rewrite-header {
  background: var(--bg-secondary);
  padding: 8px 12px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--accent-cyan);
  text-transform: uppercase;
  letter-spacing: 1px;
  border-bottom: 1px solid var(--border-dim);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.ai-rewrite-header .ai-close {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 14px;
  padding: 0 4px;
}
.ai-rewrite-header .ai-close:hover { color: var(--text-primary); }

.ai-rewrite-loading {
  padding: 24px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
}

.ai-proposal {
  padding: 12px;
  border-bottom: 1px solid var(--border-dim);
  cursor: pointer;
  transition: background var(--transition-fast);
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.ai-proposal:hover, .ai-proposal.focused {
  background: var(--bg-hover);
}
.ai-proposal-key {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--bg-primary);
  background: var(--accent-cyan);
  border-radius: 4px;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-weight: bold;
}
.ai-proposal-text {
  font-family: var(--font-script, 'Courier Prime', 'Courier New', monospace);
  font-size: 14px;
  color: var(--text-primary);
  line-height: 1.5;
  flex: 1;
}

.ai-manual-input {
  padding: 12px;
  background: var(--bg-tertiary);
}
.ai-manual-label {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}
.ai-manual-input textarea {
  width: 100%;
  background: var(--bg-primary);
  border: 1px solid var(--border-dim);
  color: var(--text-primary);
  font-family: var(--font-script, 'Courier Prime', 'Courier New', monospace);
  font-size: 14px;
  padding: 8px;
  border-radius: var(--radius-sm);
  resize: vertical;
  min-height: 50px;
  outline: none;
}
.ai-manual-input textarea:focus { border-color: var(--accent-cyan); }

.ai-rewrite-footer {
  padding: 8px 12px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-dim);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-default); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-bright); }
