.studio {
  margin: 0 auto;
  max-width: 900px;
  padding: 28px 20px 80px;
}

.studio-head {
  align-items: flex-end;
  display: flex;
  gap: 18px;
  justify-content: space-between;
  margin-bottom: 20px;
}

.head-actions {
  align-items: flex-end;
  display: flex;
  gap: 12px;
}

.head-actions .button {
  white-space: nowrap;
  width: auto;
}

.password-row {
  display: flex;
  gap: 8px;
}

.password-row input {
  min-width: 0;
}

.password-row .button {
  white-space: nowrap;
  width: auto;
}

.panel-head {
  align-items: center;
  display: flex;
  gap: 14px;
  margin-bottom: 18px;
}

.panel-head .button {
  width: auto;
}

.panel-head h2 {
  margin: 0;
}

/* ------------------------------------------------------------- lists */

.project-list,
.chapter-list {
  display: grid;
  gap: 10px;
  list-style: none;
  margin: 16px 0;
  padding: 0;
}

.project-open,
.chapter-open {
  align-items: center;
  background: rgba(10, 15, 22, 0.7);
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 16px;
  color: var(--ink);
  cursor: pointer;
  display: flex;
  font: inherit;
  justify-content: space-between;
  padding: 14px 16px;
  text-align: left;
  width: 100%;
}

.project-open:hover,
.chapter-open:hover {
  border-color: rgba(224, 122, 63, 0.55);
}

.project-item {
  align-items: stretch;
  display: flex;
  gap: 8px;
}

.project-item .project-open {
  flex: 1;
}

.project-delete {
  background: rgba(10, 15, 22, 0.7);
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 16px;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  padding: 0 16px;
  white-space: nowrap;
}

.project-delete:hover {
  border-color: rgba(239, 68, 68, 0.55);
  color: #fca5a5;
}

.project-delete.armed {
  background: rgba(127, 29, 29, 0.45);
  border-color: rgba(239, 68, 68, 0.8);
  color: #fecaca;
}

.project-title {
  font-weight: 600;
}

.project-meta {
  color: var(--muted);
  font-size: 0.85rem;
}

.empty {
  color: var(--muted);
  font-size: 0.9rem;
  padding: 10px 2px;
}

.new-project {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.new-project input {
  flex: 1;
  min-width: 180px;
}

.mode-select {
  flex: 0 0 auto;
}

.new-project .button {
  white-space: nowrap;
  width: auto;
}

/* -------------------------------------------------------------- cast */

.cast-block,
.chapter-block {
  border-top: 1px solid rgba(148, 163, 184, 0.14);
  margin-bottom: 18px;
  padding-top: 14px;
}

summary {
  color: var(--ink);
  cursor: pointer;
  font-weight: 600;
  margin-bottom: 8px;
}

.cast-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.cast-row {
  align-items: center;
  background: rgba(10, 15, 22, 0.55);
  border: 1px solid rgba(148, 163, 184, 0.14);
  border-radius: 14px;
  display: grid;
  gap: 12px;
  grid-template-columns: 140px 1fr;
  padding: 10px 14px;
}

.cast-row .voice-desc {
  padding: 8px 12px;
  width: 100%;
}

.narrator-engine {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  width: 100%;
}

.narrator-engine .engine-select {
  flex: 0 0 auto;
}

.narrator-engine .voice-openai {
  flex: 1;
  min-width: 120px;
}

.narrator-engine .voice-desc {
  flex: 1;
  min-width: 160px;
  width: auto;
}

.chapter-nav {
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin-top: 22px;
}

#chapterNumber {
  max-width: 160px;
}

.cast-name {
  font-weight: 600;
}

.cast-persona {
  color: var(--muted);
  font-size: 0.85rem;
}

.badge {
  border-radius: 999px;
  font-size: 0.78rem;
  padding: 3px 10px;
}

.badge-ready {
  background: rgba(34, 197, 94, 0.16);
  color: #86efac;
}

.badge-rendering,
.badge-segmenting,
.badge-pending {
  background: rgba(224, 122, 63, 0.18);
  color: #fbbf7d;
}

.badge-queued {
  background: rgba(148, 163, 184, 0.16);
  color: var(--muted);
}

.import-block {
  border-top: 1px solid rgba(148, 163, 184, 0.14);
  margin-top: 18px;
  padding-top: 14px;
}

.import-row {
  align-items: center;
  display: flex;
  gap: 10px;
  margin: 10px 0;
}

.import-row input[type="file"] {
  color: var(--muted);
  font-size: 0.85rem;
  padding: 10px 12px;
}

.import-row .button {
  white-space: nowrap;
  width: auto;
}

.badge-error {
  background: rgba(239, 68, 68, 0.18);
  color: #fca5a5;
}

/* Inline replacement for alert()/confirm(), which mobile browsers block. */
.notice {
  background: rgba(224, 122, 63, 0.12);
  border: 1px solid rgba(224, 122, 63, 0.4);
  border-radius: 14px;
  color: #fbbf7d;
  font-size: 0.9rem;
  margin: 0 0 14px;
  padding: 10px 14px;
}

.warning {
  background: rgba(224, 122, 63, 0.12);
  border: 1px solid rgba(224, 122, 63, 0.4);
  border-radius: 14px;
  color: #fbbf7d;
  font-size: 0.88rem;
  margin-bottom: 14px;
  padding: 10px 14px;
}

/* ------------------------------------------------------------ player */

/* The sticky overlay holds only the player and its skip buttons, on one line. */
.player-bar {
  align-items: center;
  background: rgba(10, 15, 22, 0.6);
  border: 1px solid rgba(148, 163, 184, 0.14);
  border-radius: 18px;
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
  padding: 14px;
  position: sticky;
  top: 10px;
  z-index: 5;
}

.player-bar #player {
  flex: 1;
  min-width: 0;
  width: auto;
}

.player-bar .button {
  white-space: nowrap;
  width: auto;
}

/* Speed, auto-scroll, chapter number and the re-render/segment actions — not sticky. */
.chapter-settings {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}

.chapter-settings .button {
  width: auto;
}

#chapterNumberEdit {
  padding: 8px 10px;
  width: 96px;
}

.inline-field {
  align-items: center;
  color: var(--muted);
  display: flex;
  font-size: 0.85rem;
  gap: 6px;
}

.inline-field select {
  padding: 8px 10px;
  width: auto;
}

.inline-field.checkbox input {
  width: auto;
}

/* -------------------------------------------------------- transcript */

.transcript {
  display: grid;
  gap: 4px;
  margin-top: 10px;
}

.line {
  border-left: 3px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  padding: 8px 12px;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.line:hover {
  background: rgba(148, 163, 184, 0.06);
}

.line.active {
  background: rgba(224, 122, 63, 0.12);
  border-left-color: var(--accent, #e07a3f);
}

.line-head {
  align-items: baseline;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 2px;
}

.speaker {
  color: #fbbf7d;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.line-narrator .speaker {
  color: var(--muted);
}

.direction {
  color: var(--muted);
  font-size: 0.8rem;
  font-style: italic;
}

.voice-tag {
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.7rem;
  margin-left: auto;
  padding: 1px 8px;
}

.line-text {
  line-height: 1.6;
  margin: 0;
}

.line-narrator .line-text {
  color: #cbd5e1;
}

@media (max-width: 720px) {
  .cast-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .studio-head {
    align-items: stretch;
    flex-direction: column;
  }

  .voice-tag {
    margin-left: 0;
  }
}
