:root {
  --bg: #09090b;
  --surface: #18181b;
  --surface-elevated: #202024;
  --border: #27272a;
  --border-strong: #3f3f46;
  --text: #f4f4f5;
  --text-muted: #a1a1aa;
  --text-dim: #71717a;
  --accent: #10b981;
  --accent-hover: #059669;
  --accent-text: #052e16;
  --amber: #f59e0b;
  --danger: #ef4444;
  --radius-md: 6px;
  --radius-lg: 8px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

.tabular {
  font-variant-numeric: tabular-nums;
}

.hidden {
  display: none !important;
}

/* Buttons & Inputs */
button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-strong);
  background: var(--surface-elevated);
  color: var(--text);
  font-weight: 500;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  text-decoration: none;
  white-space: nowrap;
}

.btn:hover:not(:disabled) {
  background: #27272c;
  border-color: #52525b;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #041e14;
  font-weight: 600;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-amber {
  background: rgba(245, 158, 11, 0.16);
  border-color: rgba(245, 158, 11, 0.45);
  color: #fcd34d;
}

.btn-danger {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.35);
  color: #fca5a5;
}

.btn-sm {
  min-height: 34px;
  padding: 5px 10px;
  font-size: 12px;
}

.input,
.select,
.textarea {
  width: 100%;
  background: #111114;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  color: var(--text);
  font-size: 14px;
  transition: border-color 0.15s;
}

.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.textarea {
  resize: vertical;
  min-height: 76px;
}

label.field-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
}

/* Cards & Panels */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
}

.card-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.muted {
  color: var(--text-muted);
  font-size: 13px;
}

/* Auth Screen */
.auth-shell {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.auth-card {
  width: 100%;
  max-width: 440px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.02em;
}

.brand-dot {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  background: var(--accent);
}

.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin: 16px 0;
  gap: 6px;
}

.tab-btn {
  flex: 1;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 10px;
  color: var(--text-muted);
  font-weight: 500;
  cursor: pointer;
}

.tab-btn.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

/* Main App Shell */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(9, 9, 11, 0.94);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: 1320px;
  margin: 0 auto;
  padding: 10px 14px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.topbar-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.project-select-wrap {
  min-width: 180px;
  max-width: 280px;
}

.stepper-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.stepper-inner {
  max-width: 1320px;
  margin: 0 auto;
  padding: 8px 14px;
  display: flex;
  gap: 8px;
  min-width: max-content;
}

.step-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  min-height: 40px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: #111114;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}

.step-pill.active {
  background: rgba(16, 185, 129, 0.14);
  border-color: var(--accent);
  color: var(--text);
}

.step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 4px;
  background: var(--border);
  color: var(--text);
  font-size: 11px;
  font-weight: 700;
}

.step-pill.active .step-num {
  background: var(--accent);
  color: #041e14;
}

.main-container {
  max-width: 1320px;
  margin: 0 auto;
  padding: 16px 14px 80px;
}

/* Status Strip */
.status-strip {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

@media (min-width: 768px) {
  .status-strip {
    grid-template-columns: 2fr 1fr 1fr 1fr;
  }
}

.metric-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px 14px;
}

.metric-box.hero-metric {
  border-color: var(--border-strong);
}

.metric-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  margin-bottom: 4px;
}

.metric-val {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

/* Forms & Grids */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

@media (min-width: 900px) {
  .grid-2 {
    grid-template-columns: 1fr 1fr;
  }
}

.grid-3 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

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

.form-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

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

/* Upload Dropzone */
.dropzone {
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  background: #111114;
  padding: 20px 16px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.dropzone:hover,
.dropzone.dragover {
  border-color: var(--accent);
  background: rgba(16, 185, 129, 0.06);
}

/* Media Priority List (Mobile-First + Desktop) */
.media-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-top: 14px;
}

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

.media-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #111114;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px;
}

.media-card.pinned {
  border-color: var(--accent);
  background: rgba(16, 185, 129, 0.05);
}

.media-card-top {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.media-thumb {
  width: 78px;
  height: 112px;
  border-radius: var(--radius-md);
  object-fit: cover;
  background: #27272a;
  flex-shrink: 0;
  border: 1px solid var(--border);
}

.media-meta {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.rank-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--surface-elevated);
  color: var(--text-muted);
}

.badge-accent {
  background: rgba(16, 185, 129, 0.15);
  border-color: rgba(16, 185, 129, 0.4);
  color: #6ee7b7;
}

.badge-amber {
  background: rgba(245, 158, 11, 0.15);
  border-color: rgba(245, 158, 11, 0.4);
  color: #fcd34d;
}

.media-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.trim-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 8px;
  background: var(--surface);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

/* Chips for Lever Examples */
.chips-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.chip-btn {
  background: #111114;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 11px;
  cursor: pointer;
}

.chip-btn:hover {
  border-color: var(--accent);
  color: var(--text);
}

.director-box {
  border: 1px solid rgba(16, 185, 129, 0.45);
  background: rgba(16, 185, 129, 0.06);
  border-radius: var(--radius-lg);
  padding: 14px;
}

/* Storyboard Editor */
.variety-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.block-card {
  background: #111114;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

@media (min-width: 900px) {
  .block-card {
    grid-template-columns: 240px 1fr;
  }
}

.block-media-col {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.block-thumb {
  width: 64px;
  height: 92px;
  border-radius: 4px;
  object-fit: cover;
  border: 1px solid var(--border);
  flex-shrink: 0;
}

/* Render & A/B Output */
.render-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

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

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

.reel-frame {
  width: 100%;
  aspect-ratio: 9 / 16;
  max-height: 520px;
  background: #000;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  object-fit: contain;
}

.progress-track {
  width: 100%;
  height: 6px;
  background: #27272a;
  border-radius: 99px;
  overflow: hidden;
  margin: 8px 0;
}

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

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  z-index: 60;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}

@media (min-width: 640px) {
  .modal-backdrop {
    align-items: center;
    padding: 20px;
  }
}

.modal-card {
  width: 100%;
  max-width: 640px;
  max-height: 90dvh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 12px 12px 0 0;
  padding: 18px;
}

@media (min-width: 640px) {
  .modal-card {
    border-radius: var(--radius-lg);
  }
}

/* Toast Notification */
.toast {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 80;
  background: #18181b;
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 10px 16px;
  border-radius: var(--radius-md);
  font-size: 13px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  max-width: 92vw;
}
