:root {
  --bg: #0a0a0f;
  --bg-2: #11111a;
  --foreground: #e8e8f0;
  --muted: #8a8aa0;
  --primary-500: #6366f1;
  --primary-600: #4f46e5;
  --glass-bg: rgba(255, 255, 255, 0.03);
  --glass-hover: rgba(255, 255, 255, 0.06);
  --glass-border: rgba(255, 255, 255, 0.08);
  --red: #ef4444;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: radial-gradient(1200px 600px at 50% -10%, #1a1a2e 0%, var(--bg) 60%);
  color: var(--foreground);
  min-height: 100vh;
}

a { color: inherit; }

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--glass-border);
  position: sticky;
  top: 0;
  backdrop-filter: blur(12px);
  background: rgba(10, 10, 15, 0.6);
  z-index: 50;
}
.nav .brand { font-weight: 700; letter-spacing: -0.02em; display: flex; gap: 8px; align-items: center; }
.nav .brand .dot { width: 10px; height: 10px; border-radius: 3px; background: var(--primary-500); }
.nav .links { display: flex; gap: 18px; font-size: 13px; }
.nav .links a { color: var(--muted); text-decoration: none; }
.nav .links a:hover, .nav .links a.active { color: var(--foreground); }

.wrap { max-width: 1100px; margin: 0 auto; padding: 32px 20px 64px; }

.hero { text-align: center; margin-bottom: 36px; }
.hero h1 { font-size: clamp(28px, 5vw, 44px); margin: 0 0 10px; letter-spacing: -0.03em; }
.hero p { color: var(--muted); max-width: 620px; margin: 0 auto; font-size: 14px; line-height: 1.6; }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; align-items: start; }
@media (max-width: 900px) { .grid { grid-template-columns: 1fr; } }

.card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  padding: 24px;
}

.card-head { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; }
.card-head .icon {
  width: 40px; height: 40px; border-radius: 10px;
  background: rgba(99, 102, 241, 0.12); color: var(--primary-500);
  display: flex; align-items: center; justify-content: center; font-size: 18px;
}
.card-head h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.08em; margin: 0; }
.card-head .sub { font-size: 11px; color: var(--muted); }

.modes {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 4px; padding: 4px; margin-bottom: 20px;
  background: var(--glass-hover); border: 1px solid var(--glass-border); border-radius: 10px;
}
.modes button {
  border: 0; background: transparent; color: var(--muted);
  padding: 9px 6px; border-radius: 8px; font-size: 13px; font-weight: 500;
  cursor: pointer; transition: all 0.15s;
}
.modes button.active { background: var(--primary-500); color: #fff; }

.field { margin-bottom: 16px; }
.field > label {
  display: block; font-size: 10px; text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--muted); margin-bottom: 6px; font-weight: 600;
}

textarea,
input[type="text"],
input[type="password"],
input[type="email"],
select {
  width: 100%; background: var(--glass-bg); border: 1px solid var(--glass-border);
  color: var(--foreground); border-radius: 8px; padding: 10px 12px; font-size: 13px;
  outline: none; transition: border-color 0.15s; font-family: inherit;
}
textarea { height: 120px; resize: vertical; }
textarea:focus, input:focus, select:focus { border-color: rgba(99, 102, 241, 0.5); }

/* Dark-themed dropdowns: render the native popup + options dark so the text is
   readable against the site palette (instead of light-on-white). */
select { color-scheme: dark; cursor: pointer; }
select option {
  background-color: var(--bg-2);
  color: var(--foreground);
}

.row { display: flex; gap: 8px; }
.row input[type="text"] { flex: 1; }

.icon-btn {
  width: 38px; height: 38px; flex: 0 0 38px; border-radius: 8px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; font-size: 15px;
  background: rgba(99, 102, 241, 0.1); border: 1px solid rgba(99, 102, 241, 0.2);
  color: var(--primary-500); transition: all 0.15s;
}
.icon-btn:hover { background: var(--primary-500); color: #fff; }
.icon-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.hint { font-size: 10px; color: var(--muted); margin: 8px 0 0; line-height: 1.5; }
.hint b { color: var(--foreground); }

.thumbs { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-top: 10px; }
.thumb {
  position: relative; aspect-ratio: 1; border-radius: 8px; overflow: hidden;
  border: 1px solid var(--glass-border); background: var(--glass-bg);
}
.thumb img, .thumb video { width: 100%; height: 100%; object-fit: cover; }
.thumb .tag {
  position: absolute; bottom: 3px; right: 3px; background: rgba(0,0,0,0.65);
  font-size: 8px; padding: 1px 4px; border-radius: 3px; color: #fff; font-weight: 700;
}
.thumb .del {
  position: absolute; top: 3px; right: 3px; background: rgba(239,68,68,0.9);
  border: 0; color: #fff; width: 18px; height: 18px; border-radius: 4px; cursor: pointer;
  font-size: 10px; line-height: 1; opacity: 0; transition: opacity 0.15s;
}
.thumb:hover .del { opacity: 1; }

.audio-list { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.audio-item {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 10px; border-radius: 8px; font-size: 11px;
  background: var(--glass-bg); border: 1px solid var(--glass-border);
}
.audio-item .del { background: none; border: 0; color: var(--muted); cursor: pointer; }
.audio-item .del:hover { color: var(--red); }

.opts { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 4px; }

.generate {
  width: 100%; margin-top: 20px; border: 0; border-radius: 8px;
  background: var(--primary-500); color: #fff; padding: 12px; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: all 0.15s;
}
.generate:hover { background: var(--primary-600); }
.generate:disabled { opacity: 0.55; cursor: not-allowed; }

.error { color: var(--red); font-size: 11px; text-align: center; margin-top: 10px; font-weight: 500; }

.preview { min-height: 480px; display: flex; flex-direction: column; gap: 14px; }
.preview > label {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); font-weight: 600;
}
.preview-stage {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--glass-hover); border: 1px solid var(--glass-border); border-radius: 10px;
  position: relative; overflow: hidden; padding: 16px; gap: 14px;
}
.preview-stage video { width: 100%; aspect-ratio: 16 / 9; object-fit: contain; background: #000; border-radius: 8px; }
.badges { display: flex; gap: 8px; }
.badge {
  font-size: 10px; text-transform: uppercase; padding: 4px 8px; border-radius: 5px; font-weight: 600;
}
.badge.primary { background: rgba(99,102,241,0.12); color: var(--primary-500); }
.badge.muted { background: var(--glass-hover); color: var(--muted); }
.placeholder { text-align: center; color: var(--muted); }
.placeholder .big { font-size: 28px; opacity: 0.35; }
.placeholder p { font-size: 10px; text-transform: uppercase; letter-spacing: 0.15em; margin-top: 10px; }

.spinner {
  width: 38px; height: 38px; border-radius: 50%;
  border: 3px solid rgba(99,102,241,0.2); border-top-color: var(--primary-500);
  animation: spin 0.8s linear infinite;
}
.spinner.sm { width: 16px; height: 16px; border-width: 2px; }
.status-text { font-size: 10px; text-transform: uppercase; letter-spacing: 0.15em; color: var(--muted); }
@keyframes spin { to { transform: rotate(360deg); } }

.download {
  position: absolute; top: 24px; right: 24px; width: 42px; height: 42px; border-radius: 50%;
  background: rgba(255,255,255,0.9); color: #000; border: 0; cursor: pointer; font-size: 16px;
  display: flex; align-items: center; justify-content: center;
}
.download:hover { background: #fff; }

.hidden { display: none !important; }

/* Login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card { width: 100%; max-width: 360px; }
.login-card form { margin-top: 4px; }
.login-card .generate { margin-top: 8px; }

/* Top-bar user + sign out */
.nav .user { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--muted); }
.nav .user b { color: var(--foreground); font-weight: 600; }
.nav .user a { color: var(--muted); text-decoration: none; }
.nav .user a:hover { color: var(--foreground); }

/* Creations gallery */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; align-items: start; }
.gallery .item { background: var(--glass-bg); border: 1px solid var(--glass-border); border-radius: 12px; overflow: hidden; }
.gallery .item > video { width: 100%; aspect-ratio: 16/9; object-fit: cover; background: #000; }
.gallery .item .media-placeholder {
  aspect-ratio: 16/9; display: flex; flex-direction: column; gap: 6px;
  align-items: center; justify-content: center; background: var(--glass-hover);
  color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: 0.12em;
}
.gallery .item .media-placeholder span { font-size: 26px; opacity: 0.5; }
.gallery .item .meta { padding: 12px; }
.gallery .item .meta .p { font-size: 12px; line-height: 1.4; max-height: 3.4em; overflow: hidden; }
.gallery .item .meta .row2 { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.empty { text-align: center; color: var(--muted); padding: 60px 0; }

/* Status badge colours */
.badge.status-processing, .badge.status-queued, .badge.status-running {
  background: rgba(234, 179, 8, 0.14); color: #eab308;
}
.badge.status-completed { background: rgba(34, 197, 94, 0.14); color: #22c55e; }
.badge.status-failed { background: rgba(239, 68, 68, 0.14); color: var(--red); }

/* Card actions (check status / expand) */
.gallery .item .actions { display: flex; gap: 8px; margin-top: 12px; }
.btn-sm {
  flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 10px; font-size: 11px; font-weight: 600; border-radius: 7px; cursor: pointer;
  background: var(--glass-hover); border: 1px solid var(--glass-border); color: var(--foreground);
  transition: all 0.15s;
}
.btn-sm:hover { border-color: rgba(99, 102, 241, 0.5); }
.btn-sm.check { color: var(--primary-500); }
.btn-sm:disabled { opacity: 0.6; cursor: progress; }
.check-error { color: var(--red); font-size: 10px; margin-top: 6px; }

/* Expandable details */
.gallery .item .details {
  margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--glass-border);
  display: flex; flex-direction: column; gap: 12px;
}
.detail-label {
  font-size: 9px; text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--muted); font-weight: 700; margin-bottom: 5px;
}
.detail-text { font-size: 12px; line-height: 1.5; color: var(--foreground); white-space: pre-wrap; word-break: break-word; }
.detail-text.error { color: var(--red); }
.tokens { display: flex; gap: 8px; flex-wrap: wrap; }
