:root {
  --bg-deep: #0a1628;
  --text-offwhite: #e8edf2;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --graphite: #1e2d3d;
  --graphite-light: #2a3a4f;
  --success: #22c55e;
  --error: #ef4444;
  --warning: #f59e0b;
  --radius: 8px;
  --gap: 12px;
  --font-mono: 'SF Mono', 'Cascadia Code', monospace;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-deep);
  color: var(--text-offwhite);
  line-height: 1.5;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  padding: 16px;
  min-height: 100dvh;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

.state-view { display: none; }
.state-view.active { display: block; }

/* header */
.header { padding: 8px 0 16px; border-bottom: 1px solid var(--graphite-light); }
.header h1 { font-size: 1.1rem; font-weight: 600; }
.header .job-id { font-family: var(--font-mono); font-size: 0.75rem; color: var(--graphite-light); margin-top: 2px; }

/* badges */
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 0.65rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; }
.badge-preview { background: var(--accent); color: #fff; }
.badge-demo { background: var(--warning); color: var(--bg-deep); }
.badge-approved { background: var(--success); color: #fff; }
.badge-error { background: var(--error); color: #fff; }
.badge-final { background: var(--success); color: #fff; }
.badge-rework { background: var(--warning); color: var(--bg-deep); }

/* status bar */
.status-bar { display: flex; gap: 8px; align-items: center; margin: 12px 0; flex-wrap: wrap; }
.status-bar .status-text { font-size: 0.85rem; font-weight: 500; }
.status-bar .format { font-size: 0.75rem; color: var(--graphite-light); font-family: var(--font-mono); }

/* video */
.video-wrap { position: relative; width: 100%; background: #000; border-radius: var(--radius); overflow: hidden; margin: 12px 0; }
.video-wrap video { display: block; width: 100%; height: auto; max-height: 75vh; }
.video-wrap .badge-overlay { position: absolute; top: 8px; left: 8px; z-index: 1; }

/* actions */
.actions { display: flex; gap: var(--gap); margin: 16px 0; flex-wrap: wrap; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 12px 24px; border: none; border-radius: var(--radius);
  font-size: 0.9rem; font-weight: 600; cursor: pointer;
  transition: opacity 0.15s, transform 0.1s; min-height: 44px; min-width: 100px;
}
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
.btn:active:not(:disabled) { transform: scale(0.97); }

.btn-approve { background: var(--success); color: var(--bg-deep); }
.btn-rework { background: var(--warning); color: var(--bg-deep); }

.btn-spinner { display: none; width: 16px; height: 16px; border: 2px solid transparent; border-top-color: currentColor; border-radius: 50%; animation: spin 0.6s linear infinite; }
.btn.loading .btn-spinner { display: inline-block; }
.btn.loading .btn-label { opacity: 0.6; }
@keyframes spin { to { transform: rotate(360deg); } }

/* feedback */
.feedback-area { margin: 12px 0; }
.feedback-area textarea {
  width: 100%; min-height: 80px; padding: 10px; border: 1px solid var(--graphite-light);
  border-radius: var(--radius); background: var(--graphite); color: var(--text-offwhite);
  font-family: inherit; font-size: 0.85rem; resize: vertical;
}
.feedback-area textarea:focus { outline: none; border-color: var(--accent); }
.feedback-area .char-count { text-align: right; font-size: 0.7rem; color: var(--graphite-light); margin-top: 4px; }
.feedback-area .error-msg { color: var(--error); font-size: 0.75rem; margin-top: 4px; }

/* history */
.history { margin: 20px 0; }
.history h3 { font-size: 0.85rem; font-weight: 600; margin-bottom: 8px; color: var(--text-offwhite); }
.version-item {
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap;
  padding: 10px 12px; border: 1px solid var(--graphite-light); border-radius: var(--radius);
  margin-bottom: 6px; font-size: 0.8rem; gap: 6px;
}
.version-item.current { border-color: var(--accent); }
.version-item.approved { border-color: var(--success); }
.version-item .vid { font-family: var(--font-mono); font-weight: 600; }
.version-item .feedback-text { width: 100%; color: var(--warning); font-size: 0.75rem; margin-top: 4px; font-style: italic; }

/* final section */
.final-section { margin: 20px 0; padding: 12px; border: 1px solid var(--graphite-light); border-radius: var(--radius); }
.final-section h3 { font-size: 0.85rem; margin-bottom: 8px; }
.final-section .final-link { color: var(--accent); text-decoration: none; font-family: var(--font-mono); font-size: 0.8rem; word-break: break-all; }

/* error states */
.error-view { text-align: center; padding: 40px 16px; }
.error-view h2 { font-size: 1.1rem; margin-bottom: 8px; color: var(--error); }
.error-view p { font-size: 0.85rem; color: var(--graphite-light); }

/* loading */
.loading-view { text-align: center; padding: 80px 16px; }
.loading-spinner { width: 32px; height: 32px; border: 3px solid var(--graphite-light); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; margin: 0 auto 12px; }

/* progress */
.progress-text { font-size: 0.8rem; color: var(--graphite-light); text-align: center; margin: 8px 0; }
