:root {
  --bg: #0f0f13;
  --surface: #18181f;
  --text: #e8e8ec;
  --muted: #9ca3af;
  --accent: #6366f1;
  --accent-hover: #4f46e5;
  --danger: #ef4444;
  --success: #22c55e;
  --amber: #d97706;
  --firelight: #ff8c42;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

header {
  text-align: center;
  margin-bottom: 2rem;
}

header h1 {
  margin: 0;
  font-size: 2rem;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--firelight), var(--amber));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

header p {
  color: var(--muted);
  margin: 0.5rem 0 0;
}

form {
  background: var(--surface);
  padding: 1.5rem;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

label {
  font-weight: 600;
  font-size: 0.9rem;
}

.muted {
  color: var(--muted);
  font-weight: 400;
  font-size: 0.85em;
}

.hint {
  color: var(--muted);
  font-size: 0.8rem;
  margin: -0.5rem 0 0;
  padding: 0.25rem 0.5rem;
  background: #101014;
  border-radius: 6px;
  border-left: 3px solid var(--accent);
}

.mono {
  font-family: "Cascadia Code", "Fira Code", "Consolas", monospace;
  font-size: 0.8em;
  word-break: break-all;
}

input[type="text"],
input[type="file"],
textarea,
button {
  font: inherit;
}

input[type="text"],
textarea {
  padding: 0.75rem;
  border: 1px solid #2c2c35;
  border-radius: 8px;
  background: #101014;
  color: var(--text);
}

input[type="text"]:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
}

textarea {
  resize: vertical;
}

input[type="file"],
select {
  padding: 0.5rem 0;
}

select {
  background: #101014;
  color: var(--text);
  border: 1px solid #2c2c35;
  border-radius: 8px;
  padding: 0.75rem;
}

label.checkbox {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 500;
  cursor: pointer;
}

label.checkbox input[type="checkbox"] {
  width: 1.1rem;
  height: 1.1rem;
  accent-color: var(--accent);
}

button {
  padding: 0.85rem 1.25rem;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
}

button:hover:not(:disabled) {
  background: var(--accent-hover);
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.status,
.result,
#projects {
  margin-top: 1.5rem;
  background: var(--surface);
  padding: 1.5rem;
  border-radius: 12px;
}

.hidden {
  display: none !important;
}

.progress {
  width: 100%;
  height: 8px;
  background: #2c2c35;
  border-radius: 4px;
  overflow: hidden;
  margin-top: 0.75rem;
}

.progress-bar {
  width: 0%;
  height: 100%;
  background: var(--accent);
  transition: width 0.3s ease;
}

video {
  width: 100%;
  border-radius: 8px;
  margin-bottom: 1rem;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

#project-list {
  list-style: none;
  padding: 0;
  margin: 1rem 0 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

#project-list li {
  background: #101014;
  padding: 1rem;
  border-radius: 8px;
  border-left: 4px solid var(--accent);
}

#project-list li.done {
  border-left-color: var(--success);
}

#project-list li.failed {
  border-left-color: var(--danger);
}

/* Captured Footage archive (Sep 9 2026) */
#footage {
  margin-top: 1.5rem;
  background: var(--surface);
  padding: 1.5rem;
  border-radius: 12px;
}

#footage-list {
  list-style: none;
  padding: 0;
  margin: 1rem 0 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

#footage-list li.footage-item {
  background: #101014;
  padding: 1rem;
  border-radius: 8px;
  border-left: 4px solid var(--accent);
}

#footage-list li.footage-item video {
  max-height: 240px;
  object-fit: contain;
  background: #000;
}

#project-list h3 {
  margin: 0 0 0.25rem;
  font-size: 1rem;
}

#project-list p {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

#refresh-projects {
  margin-top: 0.5rem;
}

.audio-info {
  margin-top: 0.5rem;
  padding: 0.75rem;
  background: #101014;
  border-radius: 8px;
  border-left: 3px solid var(--success);
}

.audio-info p {
  margin: 0.25rem 0;
  font-size: 0.85rem;
}

/* Reference image gallery */
.ref-gallery {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 0.5rem;
}

.ref-thumb {
  position: relative;
  width: 72px;
  height: 72px;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid #2c2c35;
}

.ref-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.ref-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 20px;
  height: 20px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  font-size: 14px;
  line-height: 18px;
  text-align: center;
  cursor: pointer;
  transition: background 0.15s ease;
}

.ref-remove:hover {
  background: var(--danger);
}

/* ============================================================
   THE STUDIO — styles (S1)
   ============================================================ */

.studio-toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 12px 0;
}
.studio-toolbar input {
  flex: 1;
  min-width: 140px;
}
.studio-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  margin-top: 12px;
}
.studio-card {
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 10px;
  overflow: hidden;
  background: rgba(255,255,255,0.03);
}
.studio-headshot {
  width: 100%;
  height: 220px;
  object-fit: cover;
  display: block;
  background: rgba(0,0,0,0.3);
}
.studio-nohead {
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255,255,255,0.4);
  font-size: 13px;
}
.studio-card-body {
  padding: 10px 12px 12px;
}
.studio-card-body h3 {
  margin: 0 0 4px;
  font-size: 15px;
}
.studio-meta {
  margin: 2px 0;
  font-size: 12px;
  opacity: 0.75;
}
.studio-badge {
  display: inline-block;
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.25);
  margin-left: 4px;
  vertical-align: middle;
}
.studio-locked {
  border-color: #d4a017;
  color: #d4a017;
}
.studio-untested {
  opacity: 0.6;
}
.studio-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.studio-actions button,
.studio-upload-label {
  font-size: 12px;
  padding: 4px 10px;
  cursor: pointer;
}
.studio-upload-label {
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 6px;
  display: inline-block;
}
.studio-birth {
  border-color: #c2743a;
}
.studio-train-form {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.studio-train-form.hidden {
  display: none;
}
/* Multi-page hub navigation and controls ??? added Sep 15 2026 */

/* Top navigation bar */
.top-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-brand {
  font-size: 1.4rem;
  font-weight: 700;
  color: #e94560;
  text-decoration: none;
  letter-spacing: 0.5px;
}

.nav-links {
  display: flex;
  gap: 24px;
}

.nav-link {
  color: rgba(255, 255, 255, 0.7);
  text-decoration: none;
  font-size: 0.95rem;
  padding: 6px 12px;
  border-radius: 6px;
  transition: all 0.2s ease;
}

.nav-link:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

.nav-link.active {
  color: #e94560;
  background: rgba(233, 69, 96, 0.15);
}

/* Studio page controls */
.studio-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 20px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.studio-search {
  flex: 1;
  min-width: 200px;
}

.studio-search input {
  width: 100%;
  padding: 10px 14px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  color: #fff;
  font-size: 0.95rem;
}

.studio-search input:focus {
  outline: none;
  border-color: #e94560;
}

.studio-filters {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.studio-filters select {
  padding: 10px 14px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  color: #fff;
  font-size: 0.95rem;
  cursor: pointer;
}

.studio-filters select:focus {
  outline: none;
  border-color: #e94560;
}

/* Pagination */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-top: 24px;
  padding: 16px;
}

.pagination button {
  padding: 8px 16px;
  background: rgba(233, 69, 96, 0.2);
  border: 1px solid rgba(233, 69, 96, 0.4);
  border-radius: 6px;
  color: #e94560;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.pagination button:hover:not(:disabled) {
  background: rgba(233, 69, 96, 0.4);
}

.pagination button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.pagination span {
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.9rem;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .top-nav {
    flex-direction: column;
    gap: 12px;
    padding: 12px 16px;
  }

  .nav-links {
    gap: 12px;
  }

  .studio-controls {
    flex-direction: column;
  }

  .studio-filters {
    flex-direction: column;
    width: 100%;
  }

  .studio-filters select {
    width: 100%;
  }
}

/* ==============================================================
   CASTING & SOUND PREVIEW (Sep 16 2026)
   ============================================================== */
.preview-btn {
  margin-top: 8px;
  background: linear-gradient(135deg, #b48a3a 0%, #8a6a2a 100%);
  color: #fff;
  border: 1px solid #d4b06a;
  padding: 10px 18px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  letter-spacing: 0.3px;
}
.preview-btn:hover {
  filter: brightness(1.1);
}
.preview-panel {
  margin: 12px 0;
  padding: 14px;
  border: 1px solid rgba(180, 138, 58, 0.4);
  border-radius: 8px;
  background: rgba(180, 138, 58, 0.06);
}
.preview-panel h3 {
  margin: 10px 0 6px 0;
  color: #d4b06a;
}
.preview-panel ul {
  margin: 6px 0;
  padding-left: 20px;
}
.preview-panel li {
  margin: 4px 0;
  font-size: 14px;
}

/* ── MANUSCRIPT PREVIEW PANEL (Sep 25 2026) ── */
.manuscript-panel {
  margin: 12px 0;
  padding: 14px;
  border: 1px solid rgba(110, 160, 90, 0.5);
  border-radius: 8px;
  background: rgba(110, 160, 90, 0.07);
}
.manuscript-panel h3 {
  margin: 4px 0 8px 0;
  color: #9ec98a;
  font-size: 15px;
}
.manuscript-panel .manuscript-stats {
  margin: 0 0 10px 0;
  font-size: 13px;
  color: #b8d8a8;
}
.manuscript-panel .manuscript-opening {
  margin: 0;
  padding: 10px;
  max-height: 160px;
  overflow-y: auto;
  white-space: pre-wrap;
  font-family: Georgia, serif;
  font-size: 13px;
  line-height: 1.5;
  color: #d8d4c8;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 6px;
}
.manuscript-panel.manuscript-missing {
  border-color: rgba(200, 80, 70, 0.6);
  background: rgba(200, 80, 70, 0.08);
}
.manuscript-panel.manuscript-missing h3 {
  color: #e89080;
}
.manuscript-panel.manuscript-missing p {
  color: #d8a8a0;
  font-size: 13px;
}
.preview-panel .warn {
  color: #d4a04a;
  font-style: italic;
}
.preview-panel .muted {
  opacity: 0.6;
}

/* ==============================================================
   CAST FROM THE LOT (Sep 16 2026)
   ============================================================== */
.cast-lot-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 12px;
  margin-top: 10px;
}
.cast-lot-card {
  cursor: pointer;
  border: 1px solid rgba(180, 138, 58, 0.3);
  border-radius: 8px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.3);
  text-align: center;
  transition: transform 0.15s, border-color 0.15s;
}
.cast-lot-card:hover {
  transform: translateY(-2px);
  border-color: #d4b06a;
}
.cast-lot-card img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
}
.cast-lot-nohead {
  width: 100%;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #666;
  font-size: 12px;
  background: rgba(255, 255, 255, 0.03);
}
.cast-lot-name {
  font-size: 12px;
  font-weight: 600;
  padding: 6px 4px 2px;
  color: #eee;
}
.cast-lot-vault {
  font-size: 10px;
  color: #888;
  padding: 0 4px 6px;
}
.cast-lot-cast {
  border-color: #6a6;
  box-shadow: 0 0 0 2px rgba(102, 170, 102, 0.4);
}
.cast-lot-cast::after {
  content: "✓ cast";
  display: block;
  font-size: 10px;
  color: #8c8;
  padding-bottom: 4px;
}
