:root {
  --bg-0: #060912;
  --bg-1: #0a1221;
  --bg-2: #0e1830;
  --panel: rgba(9, 15, 28, 0.78);
  --panel-soft: rgba(9, 15, 28, 0.62);
  --line: rgba(181, 220, 255, 0.14);
  --line-strong: rgba(181, 220, 255, 0.24);
  --ink: #f4f8ff;
  --ink-soft: rgba(223, 235, 255, 0.72);
  --ink-faint: rgba(223, 235, 255, 0.46);
  --cyan: #7be7ff;
  --blue: #6695ff;
  --mint: #77efc5;
  --warning: #ffc566;
  --danger: #ff879e;
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --shadow-xl: 0 20px 60px rgba(0, 0, 0, 0.34);
  --shadow-lg: 0 12px 34px rgba(0, 0, 0, 0.24);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  background: var(--bg-0);
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 16% 18%, rgba(123, 231, 255, 0.1), transparent 20%),
    radial-gradient(circle at 82% 22%, rgba(102, 149, 255, 0.12), transparent 22%),
    linear-gradient(180deg, var(--bg-0), var(--bg-1) 42%, var(--bg-2));
  color: var(--ink);
  color-scheme: dark;
  font-family: "Segoe UI Variable Text", "Aptos", "Microsoft YaHei UI", sans-serif;
}

body::before,
body::after {
  content: "";
  position: fixed;
  z-index: 0;
  width: 26vw;
  height: 26vw;
  border-radius: 999px;
  filter: blur(56px);
  opacity: 0.7;
  pointer-events: none;
  animation: ambient-drift 18s ease-in-out infinite alternate;
}

body::before {
  top: -10vw;
  right: -8vw;
  background: radial-gradient(circle, rgba(102, 149, 255, 0.2), rgba(123, 231, 255, 0.04) 56%, transparent 72%);
}

body::after {
  left: -10vw;
  bottom: -10vw;
  animation-duration: 22s;
  background: radial-gradient(circle, rgba(123, 231, 255, 0.12), rgba(119, 239, 197, 0.04) 56%, transparent 72%);
}

button,
input,
select,
textarea {
  font: inherit;
  touch-action: manipulation;
}

button {
  cursor: pointer;
}

img,
video {
  display: block;
}

::selection {
  background: rgba(123, 231, 255, 0.2);
}

.hidden {
  display: none !important;
}

.skip-link {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 60;
  padding: 10px 14px;
  border-radius: 999px;
  color: var(--ink);
  text-decoration: none;
  border: 1px solid var(--line-strong);
  background: rgba(8, 14, 27, 0.92);
  transform: translateY(-150%);
  transition: transform 0.16s ease;
}

.skip-link:focus-visible {
  transform: translateY(0);
}

.app-shell {
  position: relative;
  z-index: 1;
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 20px 0 24px;
}

.reveal {
  opacity: 0;
  transform: translateY(16px);
  animation: rise-in 0.55s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

.glass-panel {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-xl);
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02)),
    linear-gradient(135deg, rgba(12, 21, 39, 0.9), rgba(7, 12, 23, 0.78));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    var(--shadow-xl);
  backdrop-filter: blur(24px) saturate(150%);
  -webkit-backdrop-filter: blur(24px) saturate(150%);
}

.glass-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(120deg, rgba(255, 255, 255, 0.08), transparent 24%, transparent 76%, rgba(123, 231, 255, 0.05)),
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.06), transparent 24%);
  pointer-events: none;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 20px;
}

.toolbar::after {
  content: "";
  position: absolute;
  right: -40px;
  top: -50px;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 40% 38%, rgba(255, 255, 255, 0.08), transparent 22%),
    radial-gradient(circle at 62% 42%, rgba(123, 231, 255, 0.18), transparent 20%),
    radial-gradient(circle at 44% 62%, rgba(102, 149, 255, 0.16), transparent 22%);
  border: 1px solid rgba(181, 220, 255, 0.08);
  opacity: 0.9;
  animation: liquid-drift 16s linear infinite;
  pointer-events: none;
}

.toolbar-copy,
.toolbar-actions,
.panel-head,
.stage-head,
.inline-fields {
  position: relative;
  z-index: 1;
}

.toolbar-copy {
  max-width: 520px;
}

.eyebrow,
.panel-kicker,
.upload-kicker,
.status-strip span,
.micro-meta span,
.video-empty span {
  margin: 0;
  color: var(--ink-faint);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.toolbar h1,
.stage-head h2,
.upload-placeholder strong,
.video-empty strong {
  margin: 0;
  font-family: "Segoe UI Variable Display", "Microsoft YaHei UI", sans-serif;
}

.toolbar h1 {
  margin-top: 8px;
  font-size: clamp(28px, 4.1vw, 42px);
  line-height: 0.98;
  letter-spacing: -0.05em;
}

.lead {
  margin: 10px 0 0;
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.65;
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.model-pill,
.status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(9, 16, 29, 0.56);
  color: var(--ink);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.primary-button,
.ghost-button,
.text-button,
.link-button {
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--ink);
  text-decoration: none;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.primary-button::before,
.ghost-button::before,
.text-button::before,
.link-button::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, rgba(255, 255, 255, 0.14), transparent 34%, transparent 72%, rgba(123, 231, 255, 0.16));
  transform: translateX(-36%);
  transition: transform 0.28s ease;
  pointer-events: none;
}

.primary-button:hover::before,
.ghost-button:hover::before,
.text-button:hover::before,
.link-button:hover::before {
  transform: translateX(0);
}

.primary-button,
.link-button {
  background:
    linear-gradient(135deg, rgba(123, 231, 255, 0.22), rgba(102, 149, 255, 0.18)),
    rgba(9, 16, 29, 0.8);
}

.ghost-button,
.text-button {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.02)),
    rgba(9, 16, 29, 0.68);
}

.text-button {
  color: var(--ink-soft);
}

.primary-button:hover,
.ghost-button:hover,
.text-button:hover,
.link-button:hover {
  transform: translateY(-1px);
  border-color: var(--line-strong);
}

.primary-button:disabled {
  cursor: wait;
  opacity: 0.72;
}

.disabled-link {
  pointer-events: none;
  opacity: 0.46;
}

.studio {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
  margin-top: 16px;
}

.control-panel,
.stage-panel {
  display: grid;
  gap: 16px;
  padding: 16px;
}

.panel-head,
.stage-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.panel-note {
  color: var(--ink-faint);
  font-size: 12px;
}

.control-form {
  display: grid;
  gap: 14px;
}

.upload-panel {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 170px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid rgba(181, 220, 255, 0.12);
  background:
    radial-gradient(circle at 22% 18%, rgba(123, 231, 255, 0.1), transparent 22%),
    linear-gradient(160deg, rgba(9, 16, 30, 0.92), rgba(8, 13, 25, 0.78));
  transition: border-color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

.upload-panel::before {
  content: "";
  position: absolute;
  inset: -20%;
  background:
    radial-gradient(circle at 30% 35%, rgba(123, 231, 255, 0.14), transparent 18%),
    radial-gradient(circle at 72% 56%, rgba(102, 149, 255, 0.14), transparent 20%);
  animation: liquid-drift 14s linear infinite;
  pointer-events: none;
}

.upload-panel input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.upload-panel:hover,
.upload-panel.dragging {
  transform: translateY(-1px);
  border-color: rgba(123, 231, 255, 0.22);
  box-shadow: var(--shadow-lg);
}

.upload-panel.error {
  border-color: rgba(255, 135, 158, 0.42);
  box-shadow:
    0 0 0 4px rgba(255, 135, 158, 0.08),
    var(--shadow-lg);
}

.source-preview,
.hero-preview,
.result-video {
  width: 100%;
  height: 100%;
}

.source-preview,
.hero-preview {
  object-fit: cover;
}

.result-video {
  object-fit: contain;
  background: #03060d;
}

.upload-placeholder,
.video-empty {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  padding: 18px;
  text-align: center;
}

.upload-placeholder strong,
.video-empty strong {
  max-width: 420px;
  font-size: clamp(18px, 2.4vw, 26px);
  line-height: 1.08;
  letter-spacing: -0.04em;
}

.upload-placeholder p,
.video-empty p,
.status-message {
  margin: 0;
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.65;
}

.field {
  display: grid;
  gap: 8px;
}

.field span {
  color: var(--ink-faint);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.field textarea,
.field select {
  width: 100%;
  color: var(--ink);
  border: 1px solid rgba(181, 220, 255, 0.12);
  border-radius: var(--radius-md);
  outline: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.02)),
    rgba(9, 15, 28, 0.84);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.field textarea {
  min-height: 132px;
  padding: 14px;
  resize: vertical;
  line-height: 1.65;
}

.field textarea::placeholder {
  color: rgba(223, 235, 255, 0.4);
}

.field select {
  min-height: 42px;
  padding: 0 12px;
  appearance: none;
}

.field textarea:focus,
.field select:focus {
  transform: translateY(-1px);
  border-color: rgba(123, 231, 255, 0.24);
  box-shadow: 0 0 0 4px rgba(123, 231, 255, 0.07);
}

.inline-fields {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 10px;
  align-items: end;
}

.micro-meta,
.status-strip {
  display: grid;
  gap: 10px;
}

.micro-meta {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.micro-meta article,
.status-strip article {
  display: grid;
  gap: 6px;
  padding: 12px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(181, 220, 255, 0.1);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.02)),
    rgba(8, 13, 25, 0.62);
}

.micro-meta strong,
.status-strip strong {
  line-height: 1.4;
  word-break: break-word;
}

.stage-head h2 {
  margin-top: 6px;
  font-size: clamp(22px, 3vw, 32px);
  line-height: 1;
  letter-spacing: -0.04em;
}

.status-badge.idle,
.status-badge.queued {
  color: #d9e6ff;
}

.status-badge.processing {
  color: var(--warning);
}

.status-badge.completed {
  color: var(--mint);
}

.status-badge.failed {
  color: var(--danger);
}

.stage-screen {
  position: relative;
  min-height: 400px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid rgba(181, 220, 255, 0.1);
  background:
    radial-gradient(circle at 22% 20%, rgba(123, 231, 255, 0.1), transparent 22%),
    radial-gradient(circle at 78% 26%, rgba(102, 149, 255, 0.12), transparent 24%),
    linear-gradient(160deg, rgba(5, 11, 22, 0.92), rgba(8, 14, 27, 0.84));
}

.stage-screen::before {
  content: "";
  position: absolute;
  inset: 12px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  pointer-events: none;
}

.hero-preview,
.result-media {
  position: absolute;
  inset: 0;
}

.hero-preview:not(.hidden) {
  opacity: 0.84;
}

.liquid-reflection {
  position: absolute;
  inset: -14%;
  background:
    radial-gradient(circle at 24% 30%, rgba(255, 255, 255, 0.12), transparent 16%),
    radial-gradient(circle at 68% 36%, rgba(123, 231, 255, 0.14), transparent 20%),
    radial-gradient(circle at 58% 74%, rgba(102, 149, 255, 0.14), transparent 20%);
  mix-blend-mode: screen;
  opacity: 0.82;
  animation: liquid-drift 18s linear infinite;
  pointer-events: none;
}

.result-media {
  padding: 12px;
}

.result-video {
  border-radius: 18px;
  box-shadow:
    0 12px 32px rgba(0, 0, 0, 0.26),
    inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.stage-bottom {
  display: grid;
  gap: 12px;
}

.timeline {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.timeline-step {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 10px 12px;
  border-radius: 999px;
  border: 1px solid rgba(181, 220, 255, 0.1);
  background: rgba(8, 13, 25, 0.46);
  color: var(--ink-faint);
  font-size: 12px;
}

.timeline-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: rgba(223, 235, 255, 0.2);
  transition: transform 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}

.timeline-step.active {
  color: var(--ink);
}

.timeline-step.active .timeline-dot {
  transform: scale(1.15);
  background: linear-gradient(135deg, var(--cyan), var(--blue));
  box-shadow: 0 0 0 5px rgba(123, 231, 255, 0.08);
}

.timeline-step.failed .timeline-dot {
  background: var(--danger);
}

.status-strip {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.download-card .link-button {
  width: 100%;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  z-index: 50;
  padding: 11px 16px;
  border-radius: 999px;
  color: var(--ink);
  border: 1px solid var(--line);
  background:
    linear-gradient(135deg, rgba(123, 231, 255, 0.12), rgba(102, 149, 255, 0.1)),
    rgba(8, 14, 27, 0.88);
  box-shadow: var(--shadow-lg);
  transform: translate(-50%, 12px);
  opacity: 0;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.ghost-button:focus-visible,
.primary-button:focus-visible,
.text-button:focus-visible,
.link-button:focus-visible,
.field textarea:focus-visible,
.field select:focus-visible,
.upload-panel:focus-within {
  outline: 0;
  box-shadow:
    0 0 0 4px rgba(123, 231, 255, 0.1),
    0 12px 28px rgba(0, 0, 0, 0.22);
}

.upload-panel:focus-visible {
  outline: 0;
  box-shadow:
    0 0 0 4px rgba(123, 231, 255, 0.1),
    0 12px 28px rgba(0, 0, 0, 0.22);
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes ambient-drift {
  from {
    transform: translate3d(0, 0, 0) scale(1);
  }
  to {
    transform: translate3d(14px, -16px, 0) scale(1.06);
  }
}

@keyframes liquid-drift {
  0% {
    transform: rotate(0deg) scale(1);
  }
  50% {
    transform: rotate(180deg) scale(1.05);
  }
  100% {
    transform: rotate(360deg) scale(1);
  }
}

@media (max-width: 980px) {
  .toolbar {
    align-items: start;
    flex-direction: column;
  }

  .toolbar-actions {
    justify-content: flex-start;
  }

  .studio {
    grid-template-columns: 1fr;
  }

  .stage-screen {
    min-height: 340px;
  }

  .status-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100%, calc(100% - 16px));
    padding-top: 12px;
  }

  .toolbar,
  .control-panel,
  .stage-panel {
    padding: 14px;
  }

  .toolbar::after {
    width: 120px;
    height: 120px;
    right: -30px;
    top: -30px;
  }

  .toolbar h1 {
    font-size: clamp(24px, 9vw, 34px);
  }

  .toolbar-actions,
  .inline-fields {
    display: grid;
    grid-template-columns: 1fr;
    align-items: stretch;
    width: 100%;
  }

  .primary-button,
  .ghost-button,
  .text-button,
  .link-button {
    width: 100%;
  }

  .micro-meta,
  .status-strip,
  .timeline {
    grid-template-columns: 1fr;
  }

  .upload-panel,
  .stage-screen {
    min-height: 220px;
  }

  .upload-placeholder strong,
  .video-empty strong {
    font-size: clamp(18px, 7vw, 24px);
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .reveal {
    opacity: 1;
    transform: none;
  }
}
