/* Project section tabs */
.subnav {
  display: flex;
  gap: 6px;
  margin: 0 0 20px;
  padding-bottom: 4px;
  overflow-x: auto;
  scrollbar-width: none;
  border-bottom: 1px solid var(--border);
}

.subnav::-webkit-scrollbar {
  display: none;
}

.subnav a {
  flex-shrink: 0;
  padding: 10px 14px;
  margin-bottom: -5px;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}

.subnav a:hover {
  color: var(--text);
}

.subnav a.is-active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

/* Shared small pieces */
.notice {
  margin: 0;
  padding: 10px 12px;
  font-size: 0.85rem;
  color: var(--muted);
  background: var(--bg);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
}

.two-up {
  display: grid;
  gap: 14px;
}

.small-heading {
  margin: 18px 0 8px;
  font-size: 0.85rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.divider-line {
  height: 1px;
  margin: 20px 0;
  background: var(--border);
}

.error-text {
  color: var(--danger);
}

.chip--busy {
  color: var(--accent);
  border-color: rgb(231 179 90 / 0.35);
  background: rgb(231 179 90 / 0.12);
  animation: pulse 1.6s ease-in-out infinite;
}

.chip--ok {
  color: var(--success);
  border-color: rgb(70 201 143 / 0.35);
  background: rgb(70 201 143 / 0.12);
}

.chip--error {
  color: var(--danger);
  border-color: rgb(239 100 97 / 0.35);
  background: var(--danger-soft);
}

@keyframes pulse {
  50% {
    opacity: 0.55;
  }
}

.positive {
  color: var(--success);
}

.negative {
  color: var(--danger);
}

/* Story Bible and characters */
.entries {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.entry {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.entry p {
  margin: 4px 0 0;
  white-space: pre-wrap;
}

.character h3 {
  margin: 0 0 6px;
}

.character p {
  margin-bottom: 10px;
}

/* Structure tree */
.tree {
  display: grid;
  gap: 16px;
}

.tree__node {
  display: grid;
  gap: 12px;
}

.tree__node--season {
  gap: 16px;
}

.tree__node--episode,
.tree__node--chapter {
  padding: 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.tree__head h2,
.tree__head h3,
.tree__head h4 {
  margin: 6px 0 0;
}

.tree__actions {
  gap: 6px;
}

.tree__empty {
  margin: 0;
}

.tree__add {
  justify-content: flex-start;
}

.scene-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.scene-row {
  display: grid;
  gap: 8px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.scene-row__title {
  color: var(--text);
  font-weight: 600;
}

.scene-row__title:hover {
  color: var(--accent);
}

.scene-row__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

@media (min-width: 700px) {
  .scene-row {
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center;
  }

  .two-up {
    grid-template-columns: 1fr 1fr;
  }
}

/* Scene detail */
.preview {
  position: relative;
  aspect-ratio: 16 / 9;
  margin-bottom: 14px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
}

.preview::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgb(8 8 12 / 0.9), transparent 60%);
}

.preview__label {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 14px;
  z-index: 1;
  display: grid;
  gap: 4px;
}

.clip-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.clip-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
}

.clip-row.is-active {
  border-color: rgb(231 179 90 / 0.4);
}

/* Assets */
.upload {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.upload input[type="file"] {
  flex: 1 1 220px;
  min-width: 0;
  color: var(--muted);
  font: inherit;
}

.upload input[type="file"]::file-selector-button {
  margin-right: 12px;
  padding: 10px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-3);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.asset {
  padding: 12px;
}

.asset__media {
  display: grid;
  place-items: center;
  aspect-ratio: 16 / 9;
  margin-bottom: 10px;
  overflow: hidden;
  background: var(--bg);
  border-radius: var(--radius-sm);
}

.asset__media img,
.asset__media video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.asset__media audio {
  width: 90%;
}

.asset__meta {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.asset__meta strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Queue and exports */
.job-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.job {
  display: grid;
  gap: 10px;
  padding: 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.job__head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.job__head strong {
  display: block;
}

.progress {
  height: 6px;
  overflow: hidden;
  background: var(--surface-3);
  border-radius: 999px;
}

.progress__bar {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--accent), var(--accent-strong));
  border-radius: inherit;
  transition: width 0.4s ease;
}

/* Editor timeline */
.timeline {
  display: grid;
  gap: 14px;
}

.scene-card {
  display: grid;
  gap: 12px;
  align-content: start;
}

.scene-card h3 {
  margin: 0;
}

.scene-card__head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.scene-card__order {
  gap: 6px;
}

.scene-card .field {
  gap: 6px;
}

.scene-card select {
  min-width: 0;
  flex: 1;
  min-height: 40px;
  font-size: 16px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
}

@media (min-width: 700px) {
  .timeline {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1100px) {
  .timeline {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* Export checklist */
.checklist {
  display: grid;
  gap: 10px;
  margin: 0 0 16px;
  padding: 0;
  list-style: none;
}

.checklist li {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
}

.checklist li.is-done {
  color: var(--text);
}

.checklist .check {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  font-size: 0.75rem;
}

.is-done .check {
  background: var(--success);
  border-color: var(--success);
  color: var(--accent-ink);
}

/* Billing */
.plan-grid {
  align-items: stretch;
}

.plan {
  display: grid;
  gap: 12px;
  align-content: start;
}

.plan h3 {
  margin: 0;
}

.plan .btn {
  margin-top: 4px;
}

.plan p {
  margin: 0;
}

.ledger {
  display: grid;
  gap: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.ledger__row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.ledger__row:last-child {
  border-bottom: 0;
}

/* Admin tables and tools */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.toolbar input {
  max-width: 320px;
}

.table-wrap {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.table th,
.table td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.table th {
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.table tr:last-child td {
  border-bottom: 0;
}

.admin-tabs {
  display: flex;
  gap: 6px;
  margin: 0 0 24px;
  padding-bottom: 4px;
  overflow-x: auto;
  border-bottom: 1px solid var(--border);
}

.admin-tabs a {
  padding: 10px 14px;
  margin-bottom: -5px;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}

.admin-tabs a.is-active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

/* The admin page has no sidebar, so its top bar stays visible on desktop too */
.topbar.is-static {
  display: flex;
}

/* Narrow phones: tighter gutters for the page header and dialog buttons */
@media (max-width: 380px) {
  .project-hero {
    padding: 18px;
  }
}

/* Generated clip and voice players on the scene page */
.preview__media {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  margin-bottom: 8px;
  background: #000;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.preview__audio {
  display: block;
  width: 100%;
  margin: 10px 0 14px;
}

/* Phones: structure action buttons fill the row evenly instead of wrapping unevenly */
@media (max-width: 599px) {
  .tree__actions .btn {
    flex: 1 1 auto;
    min-width: 44px;
    padding: 0 10px;
  }
}

/* Plan cards */
.plan__price {
  margin: 0;
  font-size: 1.4rem;
  font-weight: 800;
}

.plan__features {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 0.9rem;
  display: grid;
  gap: 4px;
}

/* Export list */
.export {
  display: grid;
  gap: 10px;
  padding: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

/* Autosave status next to form headings */
.save-state {
  margin-left: auto;
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
}

.save-state[data-state="saved"] {
  color: var(--success);
}

.save-state[data-state="error"] {
  color: var(--danger);
}
