@import url("https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;700&display=swap");

:root {
  color-scheme: dark;
  --bg: #050507;
  --panel: #101116;
  --panel-2: #171923;
  --line: rgba(255, 255, 255, 0.1);
  --text: #f8fafc;
  --muted: #9ca3af;
  --primary: #e11d48;
  --primary-2: #fb7185;
  --green: #22c55e;
  --amber: #f59e0b;
  --danger: #ef4444;
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 20% -10%, rgba(225, 29, 72, 0.16), transparent 30%),
    linear-gradient(135deg, #050507 0%, #0f1118 52%, #07070a 100%);
  color: var(--text);
  font-family: "DM Sans", system-ui, sans-serif;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

a {
  color: inherit;
}

.login-shell {
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-main {
  width: min(100%, 440px);
}

.login-card,
.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(16, 17, 22, 0.88);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.38);
}

.login-card {
  padding: 32px;
}

.login-brand,
.brand {
  display: flex;
  gap: 12px;
  align-items: center;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--primary), #7c3aed 58%, #22d3ee);
  box-shadow: 0 0 26px rgba(225, 29, 72, 0.35);
}

.brand-mark.large {
  width: 42px;
  height: 42px;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 8px;
  font-size: clamp(30px, 4vw, 48px);
  line-height: 1.05;
}

h2 {
  font-size: 18px;
}

p {
  color: var(--muted);
  line-height: 1.6;
}

.stack {
  display: grid;
  gap: 12px;
}

label,
legend {
  color: #d6d9e0;
  font-size: 14px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #090a0e;
  color: var(--text);
  padding: 12px 14px;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--primary-2);
  outline-offset: 3px;
}

.primary-button,
.ghost-button,
.danger-button,
.mini-button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 700;
  text-decoration: none;
  transition: transform 180ms ease, background 180ms ease, border-color 180ms ease;
}

.primary-button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  padding: 0 18px;
  background: linear-gradient(135deg, var(--primary), #be123c);
  color: white;
}

.primary-button:hover,
.ghost-button:hover,
.danger-button:hover,
.mini-button:hover {
  transform: translateY(-1px);
}

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

.ghost-button,
.mini-button {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}

.danger-button {
  padding: 0 12px;
  background: rgba(239, 68, 68, 0.14);
  color: #fecaca;
}

.wide,
.full {
  width: 100%;
}

.alert {
  margin: 16px 0;
  border: 1px solid rgba(239, 68, 68, 0.34);
  border-radius: 8px;
  background: rgba(239, 68, 68, 0.1);
  padding: 12px;
  color: #fecaca;
}

.app-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  border-right: 1px solid var(--line);
  background: rgba(5, 5, 7, 0.82);
  padding: 22px;
}

.brand {
  margin-bottom: 32px;
}

.brand span,
.user-pill small,
.muted {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

nav {
  display: grid;
  gap: 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  border-radius: 8px;
  padding: 0 12px;
  color: #cbd5e1;
  text-decoration: none;
}

.nav-item.active,
.nav-item:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

.nav-icon {
  display: grid;
  place-items: center;
  width: 24px;
  color: var(--primary-2);
}

.nav-icon svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-icon svg path:first-child:last-child {
  fill: currentColor;
  stroke: none;
}

.sidebar-footer {
  display: grid;
  gap: 12px;
  margin-top: auto;
}

.user-pill {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.04);
}

.main {
  width: min(100%, 1280px);
  padding: 32px;
}

.page-head,
.section-title,
.preview-top,
.history-meta,
.row-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.eyebrow {
  margin-bottom: 6px;
  color: var(--primary-2);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

.status-chip,
.badge {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  padding: 7px 10px;
  color: #cbd5e1;
  font-size: 13px;
}

.generator-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(360px, 0.8fr);
  gap: 18px;
}

.panel {
  padding: 20px;
}

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

.prompt-composer {
  display: grid;
  gap: 10px;
}

.reference-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 58px;
  border: 1px solid rgba(251, 113, 133, 0.35);
  border-radius: 8px;
  background: rgba(225, 29, 72, 0.11);
  padding: 8px;
}

.reference-chip[hidden] {
  display: none;
}

.reference-chip img {
  width: 42px;
  height: 42px;
  border-radius: 6px;
  object-fit: cover;
  background: #090a0e;
}

.reference-chip span {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.reference-chip strong {
  color: #ffe4e6;
  font-size: 14px;
}

.reference-chip small,
.prompt-tools span,
.image-dropzone small {
  color: var(--muted);
  font-size: 13px;
}

.reference-chip button {
  width: 34px;
  height: 34px;
  min-height: 34px;
  margin-left: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  cursor: pointer;
  font-size: 20px;
}

.prompt-tools {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.compact {
  width: auto;
  min-height: 36px;
  padding: 0 12px;
}

.reference-field {
  gap: 10px;
}

.image-dropzone {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 76px;
  border: 1px dashed rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
  padding: 14px;
  cursor: pointer;
  transition: border-color 180ms ease, background 180ms ease;
}

.image-dropzone:hover {
  border-color: rgba(251, 113, 133, 0.65);
  background: rgba(225, 29, 72, 0.08);
}

.image-dropzone-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--primary-2);
  font-size: 24px;
  font-weight: 700;
}

.image-dropzone span:not(.image-dropzone-icon) {
  display: grid;
  gap: 2px;
}

.visually-hidden-file {
  position: absolute;
  width: 1px;
  min-height: 1px;
  opacity: 0;
  pointer-events: none;
}

.generate-panel {
  display: grid;
  gap: 18px;
}

.controls-row {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 16px;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 0;
  border: 0;
  padding: 0;
}

.segmented legend {
  grid-column: 1 / -1;
}

.segmented input {
  position: absolute;
  width: 1px;
  min-height: 1px;
  opacity: 0;
}

.segmented label {
  position: relative;
}

.segmented span {
  display: grid;
  place-items: center;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  background: #090a0e;
}

.segmented input:checked + span {
  border-color: rgba(251, 113, 133, 0.72);
  background: rgba(225, 29, 72, 0.18);
}

.preview-panel {
  min-height: 520px;
}

.progress-area,
.empty-state,
.loader-card {
  display: grid;
  place-items: center;
  min-height: 430px;
}

.progress-area video {
  width: 100%;
  max-height: 430px;
  border-radius: 8px;
  background: black;
}

.empty-state {
  border: 1px dashed rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  padding: 24px;
  text-align: center;
}

.empty-state span {
  width: 74px;
  height: 74px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(251, 113, 133, 0.5), rgba(34, 211, 238, 0.08));
}

.failed p,
.error-text {
  color: #fecaca;
}

.spinner {
  width: 56px;
  height: 56px;
  border: 3px solid rgba(255, 255, 255, 0.12);
  border-top-color: var(--primary-2);
  border-radius: 50%;
  animation: spin 900ms linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

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

.download-link {
  margin-top: 14px;
}

.history-strip {
  margin-top: 18px;
}

.history-list {
  display: grid;
  gap: 10px;
}

.history-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
  padding: 14px;
}

.history-row p {
  margin: 8px 0 0;
  color: #e5e7eb;
}

.history-meta {
  justify-content: flex-start;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 13px;
}

.badge.completed {
  color: #bbf7d0;
}

.badge.failed {
  color: #fecaca;
}

.badge.queued {
  color: #fde68a;
}

.row-actions {
  flex-direction: column;
  align-items: flex-end;
  color: var(--muted);
  font-size: 13px;
}

.mini-button {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 12px;
}

.admin-grid {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 18px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 13px 10px;
  text-align: left;
}

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

#toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 50;
  max-width: 360px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #151720;
  padding: 12px 14px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: 180ms ease;
}

#toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 980px) {
  .app-shell,
  .generator-grid,
  .admin-grid {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .controls-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .main,
  .login-card {
    padding: 20px;
  }

  .page-head,
  .history-row,
  .row-actions {
    align-items: stretch;
    grid-template-columns: 1fr;
    flex-direction: column;
  }
}
