:root {
  color-scheme: light;
  --ink: #1f1a1c;
  --muted: #5a4b52;
  --peach: #f7c6a6;
  --mint: #b6e7d8;
  --sun: #ffd68f;
  --rose: #f3a6b4;
  --card: rgba(255, 255, 255, 0.86);
  --stroke: rgba(31, 26, 28, 0.08);
  --shadow: 0 20px 60px rgba(31, 26, 28, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Space Grotesk", system-ui, sans-serif;
  color: var(--ink);
  background: #fdf6ef;
  min-height: 100vh;
  overflow-x: hidden;
}

.background {
  position: fixed;
  inset: 0;
  z-index: -1;
  background: radial-gradient(circle at top, #fff7ef 0%, #fef2e9 45%, #fef9f3 100%);
}

.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(0px);
  opacity: 0.7;
  animation: float 14s ease-in-out infinite;
}

.blob-peach {
  width: 340px;
  height: 340px;
  background: radial-gradient(circle, var(--peach), transparent 70%);
  top: -80px;
  left: -60px;
}

.blob-mint {
  width: 420px;
  height: 420px;
  background: radial-gradient(circle, var(--mint), transparent 70%);
  right: -120px;
  top: 120px;
  animation-delay: -4s;
}

.blob-sun {
  width: 280px;
  height: 280px;
  background: radial-gradient(circle, var(--sun), transparent 70%);
  bottom: -90px;
  left: 20%;
  animation-delay: -8s;
}

.page {
  max-width: 1080px;
  margin: 0 auto;
  padding: 48px 24px 64px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.hero {
  text-align: left;
  animation: fadeInUp 0.8s ease-out;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-size: 0.7rem;
  color: var(--muted);
  margin: 0 0 10px;
}

h1 {
  font-family: "Fraunces", serif;
  font-size: clamp(2.4rem, 4vw, 3.6rem);
  margin: 0 0 8px;
}

.subhead {
  margin: 0;
  color: var(--muted);
  max-width: 560px;
  line-height: 1.5;
}

.card {
  background: var(--card);
  border: 1px solid var(--stroke);
  border-radius: 22px;
  padding: 22px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
  animation: fadeInUp 0.8s ease-out;
}

.mode-switch {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.mode-tab {
  border: 1px solid rgba(31, 26, 28, 0.15);
  border-radius: 999px;
  padding: 8px 18px;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.7);
  color: var(--muted);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.mode-tab:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(31, 26, 28, 0.12);
}

.mode-tab.is-active {
  background: linear-gradient(135deg, rgba(255, 159, 142, 0.9), rgba(255, 209, 162, 0.9));
  color: #2f1f1f;
  border-color: transparent;
  box-shadow: 0 14px 28px rgba(255, 159, 142, 0.3);
}

.mode-panel {
  display: none;
  flex-direction: column;
  gap: 28px;
}

.mode-panel.is-active {
  display: flex;
}

.inputs-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.inputs-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.inputs-load {
  width: 100%;
  height: 42px;
}

.inputs-root {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.inputs-group {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.inputs-group-title {
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--ink);
  margin: 0 2px;
}

.inputs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.input-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
}

.input-meta {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.input-filename {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--ink);
  word-break: break-all;
}

.input-status {
  font-size: 0.82rem;
  color: var(--muted);
}

.input-timer {
  font-size: 0.78rem;
}

.input-timer .timer-label {
  font-size: 0.62rem;
}

.input-timer .timer-value {
  padding: 4px 10px;
}

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

.input-media {
  display: grid;
  gap: 10px;
}

.input-media img,
.input-media video {
  width: 100%;
  border-radius: 16px;
  border: 1px solid rgba(31, 26, 28, 0.1);
  background: rgba(255, 255, 255, 0.5);
}

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

.field-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.source-image-field {
  padding: 14px;
  border: 1px dashed rgba(31, 26, 28, 0.22);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.48);
}

.source-image-field .face-preview-container {
  max-width: 320px;
  max-height: 240px;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 0.95rem;
  color: var(--muted);
  font-weight: 600;
}

.toggle input {
  width: 18px;
  height: 18px;
  accent-color: #ff9f8e;
}

.note {
  margin-top: 0.25rem;
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.4;
}

.field-inline {
  display: flex;
  gap: 10px;
  align-items: center;
}

.field-inline input[type='text'] {
  flex: 1;
}

.secondary.small {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 0.9rem;
}

input[type='number'],
input[type='file'] {
  border-radius: 16px;
  border: 1px solid rgba(31, 26, 28, 0.15);
  padding: 10px 14px;
  font-family: "Space Grotesk", system-ui, sans-serif;
  font-size: 1rem;
  background: rgba(255, 255, 255, 0.8);
  color: var(--ink);
  outline: none;
  transition: border 0.2s ease, box-shadow 0.2s ease;
  width: 100%;
  cursor: pointer;
}

input[type='number']:focus,
input[type='file']:focus {
  border-color: var(--rose);
  box-shadow: 0 0 0 3px rgba(243, 166, 180, 0.2);
}

input[type='file']::file-selector-button {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(31, 26, 28, 0.15);
  border-radius: 12px;
  padding: 6px 12px;
  margin-right: 12px;
  font-family: "Space Grotesk", system-ui, sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}

input[type='file']::file-selector-button:hover {
  background: rgba(255, 255, 255, 1);
  border-color: var(--rose);
}

.face-preview-container {
  position: relative;
  margin-top: 12px;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, 0.8);
  max-width: 200px;
  max-height: 200px;
}

.face-preview-container img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.face-preview-remove {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid var(--stroke);
  border-radius: 50%;
  width: 28px;
  height: 28px;
  font-size: 18px;
  font-weight: bold;
  color: var(--ink);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease, transform 0.2s ease;
  line-height: 1;
  padding: 0;
}

.face-preview-remove:hover {
  background: rgba(255, 255, 255, 1);
  transform: scale(1.1);
}

.seconds {
  padding: 10px 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.65);
  border: 1px dashed rgba(31, 26, 28, 0.2);
  font-weight: 600;
  color: var(--muted);
}

.label {
  font-weight: 600;
  color: var(--muted);
}

textarea {
  resize: vertical;
  min-height: 120px;
  border-radius: 16px;
  border: 1px solid rgba(31, 26, 28, 0.15);
  padding: 14px 16px;
  font-family: "Space Grotesk", system-ui, sans-serif;
  font-size: 1rem;
  background: rgba(255, 255, 255, 0.8);
  color: var(--ink);
  outline: none;
  transition: border 0.2s ease, box-shadow 0.2s ease;
}

textarea:focus {
  border-color: var(--rose);
  box-shadow: 0 0 0 3px rgba(243, 166, 180, 0.2);
}

.actions {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.timer-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
  color: var(--muted);
}

.timer-label {
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.7rem;
}

.timer-value {
  font-variant-numeric: tabular-nums;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--stroke);
}

.progress {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.progress-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.65);
  border: 1px solid var(--stroke);
}

.progress-label {
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 600;
}

.progress-value {
  font-size: 0.85rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(31, 26, 28, 0.08);
  color: var(--muted);
  transition: background 0.2s ease, color 0.2s ease;
}

.progress-value[data-state='queued'] {
  background: rgba(255, 193, 143, 0.3);
  color: #9a5b1b;
}

.progress-value[data-state='running'] {
  background: rgba(246, 156, 177, 0.28);
  color: #a13b55;
}

.progress-value[data-state='done'] {
  background: rgba(182, 231, 216, 0.4);
  color: #1f6c56;
}

.progress-value[data-state='error'] {
  background: rgba(255, 120, 120, 0.25);
  color: #9e1f1f;
}

.primary {
  background: linear-gradient(135deg, #ff9f8e, #ffc18f);
  border: none;
  color: #2f1f1f;
  padding: 12px 22px;
  border-radius: 999px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 10px 20px rgba(255, 159, 142, 0.3);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.secondary {
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(31, 26, 28, 0.15);
  color: var(--muted);
  padding: 12px 20px;
  border-radius: 999px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.secondary:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 24px rgba(31, 26, 28, 0.12);
}

.secondary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.primary:hover {
  transform: translateY(-2px) scale(1.01);
  box-shadow: 0 14px 30px rgba(255, 159, 142, 0.35);
}

.primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.status {
  font-size: 0.95rem;
  color: var(--muted);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 22px;
}

.storyboard-grid {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.output {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.storyboard-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.story-meta {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.story-summary {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.5;
}

.story-details {
  border: 1px solid var(--stroke);
  border-radius: 14px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.6);
}

.story-details summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--muted);
}

.story-details p {
  margin: 10px 0 0;
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--ink);
}

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

.log-box {
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid var(--stroke);
  border-radius: 16px;
  padding: 14px 16px;
  font-size: 0.9rem;
  color: var(--muted);
  max-height: 220px;
  overflow-y: auto;
  white-space: pre-line;
}

.card-title {
  font-weight: 600;
  color: var(--muted);
}

.media-box {
  position: relative;
  border-radius: 16px;
  background: rgba(250, 245, 240, 0.8);
  min-height: 220px;
  overflow: hidden;
  display: grid;
  place-items: center;
}

.media-box img,
.media-box video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
}

.placeholder {
  padding: 20px;
  text-align: center;
  color: rgba(31, 26, 28, 0.5);
  font-size: 0.95rem;
}

.footer {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.pill {
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--stroke);
  font-size: 0.85rem;
  color: var(--muted);
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0px);
  }
}

@keyframes float {
  0%,
  100% {
    transform: translateY(0px);
  }
  50% {
    transform: translateY(18px);
  }
}

@media (max-width: 720px) {
  .page {
    padding: 32px 18px 48px;
  }

  .actions {
    align-items: flex-start;
  }
}

/* Lightbox Styles */
.lightbox {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox.active {
  opacity: 1;
  visibility: visible;
}

.lightbox-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(4px);
}

.lightbox-content {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: white;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.lightbox-content img,
.lightbox-content video {
  max-width: 100%;
  max-height: 90vh;
  object-fit: contain;
  display: block;
}

.lightbox-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: rgba(255, 255, 255, 0.9);
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  font-size: 24px;
  font-weight: bold;
  color: var(--ink);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: background 0.2s ease;
}

.lightbox-close:hover {
  background: rgba(255, 255, 255, 1);
  transform: scale(1.1);
}

@media (max-width: 768px) {
  .lightbox-content {
    max-width: 95vw;
    max-height: 95vh;
    border-radius: 8px;
  }

  .lightbox-content img,
  .lightbox-content video {
    max-height: 80vh;
  }

  .lightbox-close {
    width: 36px;
    height: 36px;
    font-size: 20px;
  }
}
