:root {
  /* OneTake brand — light theme. Screen/Slate/Signal Red/Graphite/Cutline. */
  --bg: #F6F5F1;
  --bg-elev: #FFFFFF;
  --bg-card: #FFFFFF;
  --bg-input: #FDFCFA;
  --border: #DDDBD3;
  --border-soft: #E8E6DF;
  --text: #16141D;
  --text-dim: #6E6B7A;
  --text-faint: #8B8896;
  --accent: #E8392C;
  --accent-2: #C92F24;
  --accent-grad: linear-gradient(135deg, #E8392C 0%, #D0342A 100%);
  --green: #1E9E6A;
  --amber: #B97A0F;
  --red: #E8392C;
  --blue: #2563EB;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 10px 30px rgba(22, 20, 29, 0.10);
}

* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  height: 100%;
}
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Archivo', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a {
  color: var(--accent-2);
}

.app {
  display: grid;
  grid-template-columns: 270px 1fr;
  height: 100vh;
  overflow: hidden;
}

/* ---------------- Sidebar ---------------- */
/* The project list is the only part that scrolls; the brand, New video and the
   Costs/Settings buttons stay pinned and can never be overlapped by it. */
.sidebar {
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(12px);
  border-right: 1px solid var(--border-soft);
  padding: 20px 16px calc(16px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow: hidden;
  min-height: 0;
}
.sidebar > * {
  flex-shrink: 0;
}
.sidebar > .project-list {
  flex-shrink: 1;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 4px 8px;
}
.brand-logo {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--accent-grad);
  display: grid;
  place-items: center;
  font-size: 22px;
  box-shadow: 0 6px 18px rgba(108, 92, 231, 0.5);
}
.brand-name {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.2px;
}
.brand-sub {
  font-size: 12px;
  color: var(--text-faint);
}
.projects-head {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-faint);
  padding: 4px;
  margin-top: 4px;
}
.project-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1 1 auto;
  min-height: 60px;
  overflow-y: auto;
  overscroll-behavior: contain;
  margin-right: -6px;
  padding-right: 6px; /* keep scrollbar off the cards */
}
.project-list::-webkit-scrollbar {
  width: 8px;
}
.project-list::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 8px;
}
.project-item {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: 0.15s;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.project-item:hover {
  background: var(--bg-card);
  border-color: var(--border);
}
.project-item.active {
  background: var(--bg-card);
  border-color: var(--accent);
}
.project-item .pi-title {
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.project-item .pi-meta {
  font-size: 11.5px;
  color: var(--text-faint);
  display: flex;
  align-items: center;
  gap: 6px;
}
.empty-hint {
  color: var(--text-faint);
  font-size: 12.5px;
  padding: 8px 4px;
}
.sidebar-settings {
  margin-top: auto;
}

/* ---------------- Main ---------------- */
.main {
  overflow-y: auto;
  padding: 34px 40px 80px;
}
.view {
  max-width: 1080px;
  margin: 0 auto;
}
.hidden {
  display: none !important;
}
.view-head {
  margin-bottom: 22px;
}
.view-head h1 {
  font-size: 26px;
  margin: 0 0 6px;
  letter-spacing: -0.3px;
}
.view-head.with-back {
  display: flex;
  align-items: flex-start;
  gap: 16px;
}
.view-head.with-back .grow {
  flex: 1;
}
.btn-back {
  margin-top: 4px;
}
.muted {
  color: var(--text-dim);
  margin: 0;
}
.small {
  font-size: 12.5px;
}

/* ---------------- Cards & fields ---------------- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}
.compose-card {
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.field-label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 7px;
  letter-spacing: 0.2px;
}
.prompt-input,
textarea,
input,
select {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-family: inherit;
  font-size: 14.5px;
  outline: none;
  transition: 0.15s;
}
textarea {
  resize: vertical;
  line-height: 1.55;
}
input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.18);
}
select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239aa2b4' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 34px;
  cursor: pointer;
}
.compose-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}
.input-suffix {
  position: relative;
  display: flex;
  align-items: center;
}
.input-suffix input {
  padding-right: 44px;
}
.input-suffix span {
  position: absolute;
  right: 12px;
  color: var(--text-faint);
  font-size: 13px;
  pointer-events: none;
}
.scene-estimate {
  font-size: 13px;
  color: var(--text-dim);
  background: rgba(108, 92, 231, 0.08);
  border: 1px solid rgba(108, 92, 231, 0.25);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
}
.scene-estimate b {
  color: var(--accent-2);
}

/* Toggle */
.toggle-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.toggle-title {
  font-weight: 600;
  font-size: 14px;
}
.switch {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 26px;
  flex-shrink: 0;
}
.switch input {
  display: none;
}
.slider {
  position: absolute;
  inset: 0;
  background: #2a2f3d;
  border-radius: 26px;
  transition: 0.2s;
  cursor: pointer;
}
.slider::before {
  content: "";
  position: absolute;
  height: 20px;
  width: 20px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: 0.2s;
}
.switch input:checked + .slider {
  background: var(--accent);
}
.switch input:checked + .slider::before {
  transform: translateX(20px);
}

.compose-actions,
.review-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}
.review-actions {
  margin-top: 22px;
}
.spacer {
  flex: 1;
}
.gen-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.gen-note {
  font-size: 12.5px;
  color: var(--text-faint);
  max-width: 220px;
  text-align: right;
}
.conc-field {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-dim);
}
.conc-field input {
  width: 60px;
  padding: 8px 10px;
  text-align: center;
}

/* ---------------- Buttons ---------------- */
.btn {
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: inherit;
}
.btn:hover {
  border-color: var(--accent);
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn-primary {
  background: var(--accent-grad);
  border: none;
  color: #fff;
  box-shadow: 0 6px 20px rgba(108, 92, 231, 0.35);
}
.btn-primary:hover {
  filter: brightness(1.08);
}
.btn-lg {
  padding: 13px 22px;
  font-size: 15px;
}
.btn-block {
  width: 100%;
  justify-content: center;
}
.btn-ghost {
  background: transparent;
}
.btn-danger {
  color: var(--red);
  border-color: transparent;
  background: transparent;
}
.btn-danger:hover {
  border-color: var(--red);
}
.icon-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
}
.icon-btn:hover {
  color: var(--text);
  background: var(--bg-input);
}

/* ---------------- Scene editor ---------------- */
.scene-editor {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.scene-edit {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex;
  gap: 14px;
}
.scene-index {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--accent-grad);
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.scene-edit .se-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.se-title {
  font-weight: 600;
  font-size: 14px;
  background: transparent;
  border: none;
  padding: 2px 0;
  color: var(--text);
}
.se-title:focus {
  box-shadow: none;
  border-bottom: 1px solid var(--accent);
}
.se-prompt {
  font-size: 13.5px;
  color: var(--text);
  min-height: 62px;
}
.se-vo-label {
  font-size: 11.5px;
  color: var(--accent-2);
  font-weight: 600;
  margin-top: 2px;
}
.se-vo {
  font-size: 13px;
  min-height: 34px;
  border-color: rgba(108, 92, 231, 0.35);
  background: rgba(108, 92, 231, 0.06);
}

/* Recurring subjects (auto reference images) */
.subjects-box {
  background: rgba(108, 92, 231, 0.07);
  border: 1px solid rgba(108, 92, 231, 0.3);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 14px;
}
.subjects-title {
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 4px;
}
.subject-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}
.subject-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 5px 6px 5px 12px;
  font-size: 13px;
}
.subject-chip button {
  background: transparent;
  border: none;
  color: var(--text-faint);
  cursor: pointer;
  font-size: 12px;
  padding: 2px 6px;
  border-radius: 50%;
}
.subject-chip button:hover {
  color: var(--red);
}

/* Project reference-image thumbnails */
.project-assets {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
.project-asset {
  position: relative;
  width: 52px;
  height: 52px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.project-asset img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.project-asset i {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  font-style: normal;
  font-size: 9px;
  text-align: center;
  background: rgba(0, 0, 0, 0.65);
  color: #cfc6ff;
  padding: 1px 0;
}

/* Costs dashboard */
.cost-total-card {
  margin-bottom: 18px;
}
.cost-total-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-faint);
}
.cost-total {
  font-size: 34px;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: var(--accent-grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  margin: 2px 0 6px;
}
.costs-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.cost-card {
  padding: 18px 20px;
}
/* Spend that isn't a video: unused prompt splits, voice previews. */
.cost-card-aside {
  opacity: 0.78;
  border-style: dashed;
}
.cost-card-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.cost-card-title {
  font-weight: 700;
  font-size: 15px;
}
.cost-card-total {
  font-size: 20px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.cost-rows {
  display: flex;
  flex-direction: column;
}
.cost-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 7px 0;
  border-top: 1px solid var(--border-soft);
  font-size: 13.5px;
}
.cost-row-label {
  min-width: 150px;
  font-weight: 600;
}
.cost-row-usage {
  flex: 1;
}
.cost-row-amt {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
@media (max-width: 520px) {
  .cost-row {
    flex-wrap: wrap;
  }
  .cost-row-usage {
    order: 3;
    width: 100%;
  }
}

/* Narrator voice picker */
.voice-row {
  display: flex;
  gap: 10px;
  align-items: center;
}
.voice-row select {
  flex: 1;
}
.voice-row .btn {
  flex-shrink: 0;
  white-space: nowrap;
}
.se-remove {
  color: var(--text-faint);
  align-self: flex-start;
}
.se-remove:hover {
  color: var(--red);
  border-color: transparent;
}

/* ---------------- Progress ---------------- */
.progress-wrap {
  margin: 6px 0 22px;
}
.progress-labels {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 13px;
  color: var(--text-dim);
}
.progress-bar {
  height: 8px;
  background: var(--bg-input);
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border-soft);
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent-grad);
  transition: width 0.4s ease;
}

/* ---------------- Clip grid ---------------- */
.clip-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.clip {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.clip-media {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #0a0c11;
  display: grid;
  place-items: center;
  overflow: hidden;
}
.clip-media.ar-9-16 {
  aspect-ratio: 9 / 16;
  max-height: 320px;
  margin: 0 auto;
}
.clip-media.ar-1-1 {
  aspect-ratio: 1 / 1;
}
.clip-media video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.clip-body {
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.clip-head {
  display: flex;
  align-items: center;
  gap: 8px;
}
.clip-num {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-faint);
}
.clip-title {
  font-weight: 600;
  font-size: 13.5px;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.clip-prompt {
  font-size: 12.5px;
  color: var(--text-dim);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.clip-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
}
.clip-foot .btn {
  padding: 6px 12px;
  font-size: 12.5px;
}

/* status placeholder */
.clip-status {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  color: var(--text-faint);
  font-size: 12.5px;
  padding: 10px;
  text-align: center;
}
.policy-hint {
  color: var(--text);
  font-size: 12px;
  background: rgba(255, 170, 60, 0.1);
  border: 1px solid rgba(255, 170, 60, 0.35);
  border-radius: 8px;
  padding: 7px 10px;
}

.ltx-diag {
  max-height: 300px;
  overflow: auto;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 11.5px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0 0 14px;
}

.run-note {
  margin-top: 10px;
  font-size: 13px;
  color: var(--text);
  background: rgba(245, 166, 35, 0.1);
  border: 1px solid rgba(245, 166, 35, 0.4);
  border-radius: var(--radius-sm);
  padding: 10px 13px;
}

.gen-mode {
  display: flex;
  align-items: center;
  gap: 6px;
}
.gen-mode select {
  width: auto;
  padding: 8px 30px 8px 10px;
  font-size: 13px;
}
.gen-mode input {
  width: 58px;
  padding: 8px;
  text-align: center;
  font-size: 13px;
}

.dl-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

/* ---------------- Mix panel & captions ---------------- */
.final-wrap {
  position: relative;
}
.cap-overlay {
  position: absolute;
  left: 8%;
  right: 8%;
  bottom: 7%;
  text-align: center;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: clamp(13px, 2.2vw, 18px);
  line-height: 1.35;
  pointer-events: none;
}
.mix-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed var(--border);
}
.mix-panel h4 {
  margin: 0;
  font-size: 14px;
}
.mix-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.mix-row label {
  min-width: 130px;
  font-size: 13px;
}
.mix-row input[type='range'] {
  flex: 1;
}
.mix-val {
  min-width: 44px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-size: 13px;
}
.mix-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.cap-saved {
  color: var(--text-faint);
  font-weight: 400;
  font-size: 12px;
  margin-left: 8px;
}
.cap-list {
  max-height: 320px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-right: 4px;
}
.cap-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.cap-time {
  min-width: 44px;
  text-align: right;
  color: var(--text-faint);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.cap-text {
  flex: 1;
  font-size: 13px;
  padding: 7px 10px;
}
.narr-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 6px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
}
.align-list {
  margin: 4px 0 0;
  padding-left: 20px;
  max-height: 260px;
  overflow-y: auto;
  font-size: 13px;
  line-height: 1.6;
}
.narr-block textarea {
  width: 100%;
  resize: vertical;
  font-size: 13px;
  line-height: 1.5;
}

/* Stitch panel: original clip audio choice */
.stitch-audio-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 10px 0 4px;
  max-width: 480px;
}

/* ---------------- Per-clip editor ---------------- */
.clip-editor {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
}
.clip-editor .ce-prompt {
  width: 100%;
  resize: vertical;
  font-size: 13px;
  line-height: 1.5;
}
.clip-editor .ce-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.clip-editor .ce-actions .btn {
  padding: 7px 12px;
  font-size: 12.5px;
}
.se-head {
  display: flex;
  gap: 8px;
  align-items: center;
}
.se-head .se-title {
  flex: 1;
}
.se-secs-wrap {
  display: flex;
  align-items: center;
  gap: 5px;
}
.se-secs {
  width: 62px;
  text-align: right;
}
.badge.secs {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-faint);
}
.badge.model {
  background: rgba(120, 140, 255, 0.14);
  color: var(--accent-2);
  border: 1px solid rgba(120, 140, 255, 0.35);
}
.spinner {
  width: 26px;
  height: 26px;
  border: 3px solid rgba(255, 255, 255, 0.12);
  border-top-color: var(--accent-2);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
.status-icon {
  font-size: 26px;
}

/* ---------------- Badges ---------------- */
.badge {
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  border: 1px solid var(--border);
  color: var(--text-dim);
  text-transform: capitalize;
}
.badge.pending {
  color: var(--text-faint);
}
.badge.generating {
  color: var(--blue);
  border-color: rgba(79, 172, 254, 0.4);
  background: rgba(79, 172, 254, 0.1);
}
.badge.done {
  color: var(--green);
  border-color: rgba(46, 204, 143, 0.4);
  background: rgba(46, 204, 143, 0.1);
}
.badge.error {
  color: var(--red);
  border-color: rgba(255, 93, 108, 0.4);
  background: rgba(255, 93, 108, 0.1);
}
.badge.partial,
.badge.paused {
  color: var(--amber);
  border-color: rgba(245, 166, 35, 0.4);
  background: rgba(245, 166, 35, 0.1);
}

/* ---------------- Stitch panel ---------------- */
.stitch-panel {
  margin-bottom: 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.stitch-row {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.stitch-row h3 {
  margin: 0;
  font-size: 16px;
}
.final-video {
  width: 100%;
  max-width: 720px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: #000;
}
.final-video.ar-9-16 {
  max-width: 320px;
}

/* project head actions */
.project-head-actions {
  display: flex;
  gap: 8px;
}

/* ---------------- Modal ---------------- */
.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 50;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(3px);
}
.modal-card {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  width: 460px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}
.modal-head h2 {
  margin: 0;
  font-size: 19px;
}
.modal input,
.modal select {
  margin-bottom: 4px;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 8px;
}
code {
  background: var(--bg-input);
  padding: 1px 6px;
  border-radius: 5px;
  font-size: 12px;
}

/* ---------------- Toast ---------------- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 20px;
  border-radius: 10px;
  box-shadow: var(--shadow);
  z-index: 100;
  font-size: 14px;
  max-width: 90vw;
}
.toast.err {
  border-color: var(--red);
  color: #ffd9dd;
}
.toast.ok {
  border-color: var(--green);
}

/* ---------------- Reference image assets ---------------- */
.assets-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.assets-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 4px;
}
.asset-add {
  width: 84px;
  height: 84px;
  border: 1.5px dashed var(--border);
  background: var(--bg-input);
  color: var(--text-dim);
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 12px;
  cursor: pointer;
  transition: 0.15s;
  font-family: inherit;
}
.asset-add:hover {
  border-color: var(--accent);
  color: var(--text);
}
.asset-add-plus {
  font-size: 20px;
}
.asset-thumb {
  position: relative;
  width: 84px;
  height: 84px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  background: #000;
}
.asset-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.asset-thumb .asset-remove {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
}
.asset-thumb .asset-remove:hover {
  background: var(--red);
}

/* ---------------- Mobile top bar + drawer ---------------- */
.mobile-bar {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.95);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 40;
}
.mobile-title {
  font-weight: 700;
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.mobile-bar .icon-btn {
  font-size: 22px;
}
.drawer-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 44;
}
.drawer-backdrop.open {
  display: block;
}

/* ---------------- Responsive ---------------- */
@media (max-width: 820px) {
  .mobile-bar {
    display: flex;
  }
  .app {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 0;
  }
  /* Sidebar becomes an off-canvas drawer */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    max-width: 85vw;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 45;
    border-right: 1px solid var(--border);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main {
    padding: 20px 16px 70px;
    height: auto;
    overflow: visible;
  }
  .view-head h1 {
    font-size: 22px;
  }
  .compose-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .compose-card {
    padding: 16px;
  }
  .gen-controls {
    width: 100%;
    justify-content: stretch;
  }
  .gen-controls .btn-lg {
    flex: 1;
    justify-content: center;
  }
  .gen-note {
    max-width: none;
    text-align: left;
    width: 100%;
  }
  .review-actions {
    flex-wrap: wrap;
  }
  .view-head.with-back {
    flex-wrap: wrap;
  }
  .project-head-actions {
    flex-wrap: wrap;
  }
  .modal {
    padding: 10px;
  }
  .modal-card {
    width: calc(100vw - 20px);
    max-height: calc(100dvh - 20px);
    padding: 18px;
  }
  /* 16px stops iOS zooming the page when an input is focused */
  .modal input,
  .modal select,
  .modal textarea {
    font-size: 16px;
  }
  .dl-row .btn,
  .mix-actions .btn {
    flex: 1 1 auto;
    justify-content: center;
    text-align: center;
  }
}

@media (max-width: 520px) {
  .compose-grid {
    grid-template-columns: 1fr;
  }
  .clip-grid {
    grid-template-columns: 1fr;
  }
  .btn {
    padding: 11px 16px;
  }
}

/* ---------------- Auth gate ---------------- */
.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--bg);
}
.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 26px;
}
.auth-brand {
  font-size: 24px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
}
.auth-sub {
  color: var(--text-dim);
  margin: 4px 0 18px;
}
.auth-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
  background: var(--bg-input);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 4px;
}
.auth-tab {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--text-dim);
  padding: 8px 10px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 14px;
}
.auth-tab.active {
  background: var(--bg-elev);
  color: var(--text);
  border: 1px solid var(--border);
}
.auth-card input {
  width: 100%;
  margin-bottom: 12px;
}
.auth-error {
  color: var(--amber);
  font-size: 13px;
  margin: 2px 0 10px;
}
.auth-link {
  border: 0;
  background: none;
  color: var(--text-faint);
  cursor: pointer;
  margin-top: 12px;
  font-size: 13px;
  text-decoration: underline;
}
.auth-link:hover {
  color: var(--text-dim);
}

/* ---------------- Sidebar account box ---------------- */
.account-box {
  border-top: 1px solid var(--border-soft);
  margin-top: 8px;
  padding-top: 10px;
}
.account-email {
  display: block;
  font-size: 12px;
  color: var(--text-faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-bottom: 6px;
}

/* ---------------- Credits & upgrade (sidebar) ---------------- */
.credits-box {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 8px;
  background: var(--bg-elev);
}
.credits-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 8px;
}
.credits-label {
  font-size: 12px;
  color: var(--text-faint);
}
.credits-balance {
  font-size: 18px;
  font-weight: 700;
}
.upgrade-card {
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 8px;
}
.upgrade-title {
  font-weight: 600;
  font-size: 13px;
}
.upgrade-list {
  font-size: 12px;
  color: var(--text-dim);
  margin: 4px 0;
}
.upgrade-note {
  font-size: 11px;
  color: var(--text-faint);
}

/* ---------------- Buy-credits modal ---------------- */
.pack-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
}
.pack-btn {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text);
  cursor: pointer;
  font-size: 15px;
}
.pack-btn:hover {
  border-color: var(--accent);
}
.pack-credits {
  font-weight: 600;
}
.pack-usd {
  color: var(--text-dim);
}

/* ---------------- Team modal ---------------- */
.team-h {
  margin: 16px 0 6px;
  font-size: 14px;
}
.team-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-soft);
}
.team-row .btn {
  padding: 4px 10px;
  font-size: 12px;
}
.team-who {
  font-size: 14px;
}
.team-who i {
  display: block;
  font-style: normal;
  font-size: 12px;
  color: var(--text-faint);
}
.team-code {
  padding: 6px 0;
  font-size: 15px;
  letter-spacing: 1px;
}
.row-flex {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}

/* Clip currently on screen while the film plays */
.clip.now-playing {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------------- OneTake type ---------------- */
h1, h2, .brand-name, .auth-brand {
  font-family: 'Unbounded', 'Archivo', sans-serif;
  letter-spacing: -0.01em;
}
.mono, code, .team-code, .badge.secs {
  font-family: 'Space Mono', monospace;
}

/* Word being spoken (captions v2 highlight) */
.cap-overlay .cap-word-on {
  color: var(--red);
  font-weight: 700;
}

/* ---------------- OneTake mark — the exact brand SVG ---------------- */
.ot-mark {
  width: 46px;
  height: 36px;
  min-width: 46px;
  display: inline-block;
  background: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 90 70'><circle cx='34' cy='35' r='24' fill='none' stroke='%2316141D' stroke-width='7'/><circle cx='34' cy='35' r='9' fill='%23E8392C'/><path d='M 58 35 H 74' stroke='%23E8392C' stroke-width='7' stroke-linecap='round'/></svg>") no-repeat center / contain;
}
.ot-mark::after { content: none; }
.ot-mark-sm {
  width: 32px;
  height: 25px;
  min-width: 32px;
}

/* ---------------- Sidebar navigation (v2) ---------------- */
.side-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 6px;
}
.side-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-faint);
  padding: 10px 6px 4px;
}
.side-foot {
  margin-top: auto;
  display: flex;
  flex-direction: column;
}
.side-nav {
  display: flex;
  flex-direction: column;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.nav-item:hover {
  background: rgba(22, 20, 29, 0.06);
}
.nav-ico {
  width: 20px;
  text-align: center;
  opacity: 0.85;
}
.sidebar .sidebar-settings {
  margin-top: 0; /* the foot block handles the push-down now */
}
.sidebar .account-box {
  margin-top: 6px;
}

/* Auth card v2: the mark front and center */
.auth-card {
  padding: 34px 30px;
  text-align: left;
}
.auth-brand {
  justify-content: center;
  font-size: 26px;
  margin-bottom: 2px;
}
.auth-sub {
  text-align: center;
  margin-bottom: 22px;
}
.auth-card .btn-block {
  padding: 12px;
  font-size: 15px;
}

/* ================= OneTake design v3 — modern pass ================= */

/* The one continuous take: a red line running down the page (brand signature) */
.main {
  position: relative;
}
.main::before {
  content: '';
  position: fixed;
  top: 0;
  bottom: 0;
  margin-left: -1px;
  width: 4px;
  background: var(--red);
  opacity: 0.14;
  pointer-events: none;
}
/* On phones the sidebar is a drawer, so the line would sit on the screen edge
   looking like a rendering glitch — desktop only. */
@media (max-width: 820px) {
  .main::before {
    display: none;
  }
}

/* Timecode section labels */
.tc {
  font-family: 'Space Mono', monospace;
  font-size: 12px;
  letter-spacing: 0.18em;
  color: var(--red);
  text-transform: uppercase;
  display: block;
  margin-bottom: 8px;
}

/* Headlines breathe */
.view-head {
  padding: 10px 0 6px;
}
.view-head h1 {
  font-size: clamp(24px, 3.2vw, 34px);
  letter-spacing: -0.01em;
}
.view-head .muted {
  max-width: 640px;
}

/* Cards: soft, white, roomy */
.card,
.compose-card,
.modal-card {
  border-radius: 16px;
  box-shadow: 0 1px 2px rgba(22, 20, 29, 0.04);
}
.card:hover {
  box-shadow: 0 4px 18px rgba(22, 20, 29, 0.06);
}
.clip {
  border-radius: 16px;
  overflow: hidden;
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}
.clip:hover {
  box-shadow: 0 6px 22px rgba(22, 20, 29, 0.08);
  transform: translateY(-1px);
}

/* Primary buttons: the REC pill, in the brand's display face */
.btn-primary {
  border-radius: 999px;
  font-family: 'Unbounded', 'Archivo', sans-serif;
  font-weight: 700;
  font-size: 13.5px;
  letter-spacing: 0.01em;
  padding: 11px 20px;
  background: var(--red);
  border: 0;
  box-shadow: none;
}
.btn-primary:hover {
  background: var(--accent-2);
}
.btn {
  transition: background 0.12s ease, border-color 0.12s ease;
}
.btn-ghost {
  border-radius: 999px;
}
.btn-danger {
  border-radius: 999px;
}

/* Sidebar: clean white rail */
.sidebar {
  background: #fff;
  backdrop-filter: none;
}
.brand {
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border-soft);
  margin-bottom: 12px;
}
.brand-sub {
  font-family: 'Space Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-faint);
}

/* Project list: cards with a red active edge */
.project-list .project-item,
.project-item {
  border-radius: 12px;
  border: 1px solid transparent;
}
.project-item:hover {
  background: rgba(22, 20, 29, 0.04);
}
.project-item.active {
  background: #fff;
  border-color: var(--border);
  box-shadow: inset 3px 0 0 var(--red);
}

/* Inputs: calmer focus */
input, select, textarea {
  border-radius: 10px;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--red) !important;
  box-shadow: 0 0 0 3px rgba(232, 57, 44, 0.12);
}

/* Progress bar goes Signal Red */
.progress-fill, #progressFill {
  background: var(--red) !important;
}
.badge.generating {
  color: var(--red);
  border-color: var(--red);
}

/* Modals: roomy, rounded */
.modal-card {
  border-radius: 18px;
  padding: 26px;
}

/* Auth gate: put the full lockup on stage */
.auth-card {
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(22, 20, 29, 0.12);
}
.auth-brand .ot-mark {
  width: 58px;
  height: 45px;
  min-width: 58px;
}
.auth-tab {
  border-radius: 999px;
}
.auth-tabs {
  border-radius: 999px;
  padding: 5px;
}
.auth-tab.active {
  border-radius: 999px;
}

/* Mobile bar matches the rail */
.mobile-bar {
  background: #fff;
}


/* Exact brand lockup (inline SVG with the Unbounded wordmark) */
.ot-lockup {
  display: block;
}
.auth-brand {
  display: flex;
  justify-content: center;
}
.brand .brand-sub {
  margin-top: 4px;
}
