:root {
  --bg: #0c0e16;
  --surface: #141826;
  --surface-2: #1b2033;
  --border: #28304a;
  --text: #eef2ff;
  --muted: #98a4c7;
  --accent: #6c8cff;
  --accent-2: #a855f7;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --radius: 14px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: radial-gradient(circle at top right, #181d34 0%, var(--bg) 55%);
  color: var(--text);
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--border);
  background: rgba(12, 14, 22, 0.88);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid; place-items: center; font-weight: 800; letter-spacing: 0.5px;
}
.brand h1 { margin: 0; font-size: 1.05rem; }
.subtitle { font-size: 0.78rem; color: var(--muted); }

.topbar-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.search-box input {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 8px 12px;
  width: 260px;
  font-size: 0.88rem;
}

.studio-grid {
  display: grid;
  grid-template-columns: 310px minmax(420px, 1fr) 340px;
  gap: 16px;
  padding: 16px;
  max-width: 1640px;
  margin: 0 auto;
  min-height: calc(100vh - 70px);
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.panel-header h2 { margin: 0; font-size: 0.98rem; }
.caption { font-size: 0.75rem; color: var(--muted); }
.panel-body { padding: 14px 16px; overflow-y: auto; flex: 1; }

.panel-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-bottom: 1px solid var(--border);
}
.tab-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 12px 8px;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
}
.tab-btn.active { color: var(--text); border-bottom-color: var(--accent); background: rgba(108, 140, 255, 0.08); }

.btn {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 8px 13px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s ease, border-color 0.15s ease;
}
.btn:hover { border-color: var(--accent); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-accent { background: linear-gradient(135deg, var(--accent), var(--accent-2)); border: none; color: #fff; }
.btn-danger { border-color: rgba(239, 68, 68, 0.5); color: #fca5a5; }
.btn-sm { padding: 5px 9px; font-size: 0.78rem; }

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px; font-size: 0.74rem; font-weight: 600;
}
.pill-muted { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.pill-queued { background: rgba(245, 158, 11, 0.16); color: #fcd34d; }
.pill-in_progress { background: rgba(108, 140, 255, 0.2); color: #93c5fd; }
.pill-completed { background: rgba(34, 197, 94, 0.18); color: #86efac; }
.pill-failed { background: rgba(239, 68, 68, 0.18); color: #fca5a5; }
.pill-cancelled { background: rgba(148, 163, 184, 0.18); color: #cbd5e1; }

.card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 10px;
}
.card.selectable { cursor: pointer; }
.card.selectable:hover, .card.active { border-color: var(--accent); }

.episode-row { display: flex; gap: 10px; align-items: center; }
.thumb {
  width: 52px; height: 52px; border-radius: 9px; object-fit: cover;
  background: linear-gradient(135deg, #222947, #362554);
  flex-shrink: 0; display: grid; place-items: center; font-weight: 700; color: var(--muted);
}

.visual-stage {
  position: relative;
  border-radius: 14px;
  overflow: hidden;
  background: linear-gradient(135deg, #1b2240, #251a3d);
  border: 1px solid var(--border);
  min-height: 250px;
  display: grid;
  place-items: center;
  margin-bottom: 14px;
}
.visual-stage img, .visual-stage video {
  width: 100%;
  max-height: 340px;
  object-fit: cover;
  display: block;
}
.visual-toggle-bar {
  position: absolute;
  top: 10px; right: 10px;
  display: flex; gap: 6px;
}

.player-controls {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; flex-wrap: wrap; margin: 10px 0 14px;
}
audio { width: 100%; margin: 8px 0; }

.chapter-list { display: flex; flex-direction: column; gap: 8px; }
.chapter-item {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 10px;
  background: var(--surface-2); border: 1px solid var(--border); cursor: pointer;
}
.chapter-item.active { border-color: var(--accent); background: rgba(108, 140, 255, 0.12); }

.field { margin-bottom: 11px; }
.field label { display: block; font-size: 0.78rem; color: var(--muted); margin-bottom: 4px; }
.field input, .field textarea, .field select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 9px;
  padding: 8px 10px;
  font-size: 0.86rem;
  font-family: inherit;
}
.field textarea { min-height: 110px; resize: vertical; }

.row-between { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.muted { color: var(--muted); font-size: 0.82rem; }
.summary-box {
  background: rgba(108, 140, 255, 0.08);
  border-left: 3px solid var(--accent);
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 0.88rem;
  line-height: 1.5;
  margin-bottom: 12px;
}

.modal {
  position: fixed; inset: 0; background: rgba(5, 7, 13, 0.75);
  display: grid; place-items: center; z-index: 50; padding: 16px;
}
.modal.hidden { display: none; }
.modal-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  max-width: 680px; width: 100%; max-height: 85vh; overflow-y: auto; padding: 20px;
}
.pack-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; margin: 12px 0; }

.toast-container { position: fixed; bottom: 18px; right: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast {
  background: var(--surface-2); border: 1px solid var(--accent); color: var(--text);
  padding: 10px 14px; border-radius: 10px; font-size: 0.84rem; box-shadow: 0 10px 30px rgba(0,0,0,0.4);
}
.toast.error { border-color: var(--danger); }

@media (max-width: 1180px) {
  .studio-grid { grid-template-columns: 280px 1fr; }
  .panel-media { grid-column: 1 / -1; }
}
@media (max-width: 780px) {
  .studio-grid { grid-template-columns: 1fr; }
  .search-box input { width: 100%; }
}
