:root {
  --bg: #ffffff;
  --fg: #111111;
  --muted: #5a5a5a;
  --border: #e4e4e4;
  --accent: #111111;
  --accent-fg: #ffffff;
  --card-bg: #fafafa;
  --error-bg: #fdecec;
  --error-fg: #9c1c1c;
  --success-bg: #eaf7ee;
  --success-fg: #1c7a34;
  --max-width: 1040px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e0e0e;
    --fg: #f2f2f2;
    --muted: #a3a3a3;
    --border: #2a2a2a;
    --accent: #f2f2f2;
    --accent-fg: #111111;
    --card-bg: #171717;
    --error-bg: #341414;
    --error-fg: #ff8080;
    --success-bg: #123018;
    --success-fg: #7be79a;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--fg);
  line-height: 1.5;
}

a { color: inherit; }

.wrap {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
}

header.site {
  border-bottom: 1px solid var(--border);
  padding: 18px 0;
}

header.site .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

header.site .brand {
  font-weight: 700;
  font-size: 18px;
  text-decoration: none;
}

header.site nav a {
  margin-left: 24px;
  text-decoration: none;
  color: var(--muted);
  font-size: 14px;
}

header.site nav a:hover { color: var(--fg); }

.btn {
  display: inline-block;
  padding: 10px 20px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid var(--accent);
  cursor: pointer;
}

.btn.primary {
  background: var(--accent);
  color: var(--accent-fg);
}

.btn.secondary {
  background: transparent;
  color: var(--fg);
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

section.hero {
  padding: 72px 0 48px;
  text-align: center;
}

section.hero h1 {
  font-size: 42px;
  margin: 0 0 16px;
}

section.hero p.sub {
  color: var(--muted);
  font-size: 18px;
  max-width: 640px;
  margin: 0 auto 28px;
}

.pricing-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 18px;
  font-size: 14px;
  margin-bottom: 28px;
}

.pricing-badge strong { font-size: 16px; }

.cta-row { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

section { padding: 48px 0; }
section h2 { font-size: 26px; margin-bottom: 24px; }

.grid-3 {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 20px;
}

.grid-3 .card {
  flex: 1 1 260px;
  max-width: 320px;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
}

.card h3 { margin: 0 0 8px; font-size: 16px; }
.card p { margin: 0; color: var(--muted); font-size: 14px; }

.example {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 24px;
}

.example h3 { margin-top: 0; }

.example .pair {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  align-items: start;
}

.example .video-col {
  max-width: 720px;
  margin: 0 auto;
  width: 100%;
}

@media (max-width: 640px) {
  section.hero h1 { font-size: 30px; }
}

.example .thumbs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  max-width: 720px;
  margin: 0 auto;
}

.example .label {
  max-width: 720px;
  margin-left: auto;
  margin-right: auto;
}

.example .thumbs img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 4px;
}

.example video {
  width: 100%;
  border-radius: 8px;
  background: #000;
}

.example .label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 8px;
}

footer.site {
  border-top: 1px solid var(--border);
  padding: 40px 0 24px;
  color: var(--muted);
  font-size: 13px;
}

footer.site .footer-cols {
  display: grid;
  grid-template-columns: repeat(3, minmax(140px, 1fr));
  gap: 24px;
  margin-bottom: 28px;
}

footer.site .footer-col-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--fg);
  margin-bottom: 10px;
}

footer.site .footer-col ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

footer.site .footer-col li { margin-bottom: 8px; }

footer.site a {
  text-decoration: none;
  color: var(--muted);
}

footer.site a:hover { color: var(--fg); }

footer.site .footer-copyright {
  border-top: 1px solid var(--border);
  padding-top: 20px;
  text-align: center;
}

@media (max-width: 640px) {
  footer.site .footer-cols { grid-template-columns: 1fr 1fr; }
}

/* Auth / dashboard */

.auth-card, .panel {
  max-width: 420px;
  margin: 64px auto;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 32px;
}

.auth-card h1 { font-size: 22px; margin-top: 0; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; margin-bottom: 6px; color: var(--muted); }
.field input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--fg);
  font-size: 14px;
}

.dashboard-wrap { max-width: var(--max-width); margin: 0 auto; padding: 40px 24px; }

.stat-row { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 32px; }

.stat {
  flex: 1;
  min-width: 200px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
}

.stat .label { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.stat .value { font-size: 26px; font-weight: 700; }

.key-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 14px;
  overflow-x: auto;
}

table.generations {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

table.generations th, table.generations td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
}

.banner {
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 14px;
  margin-bottom: 20px;
}

.banner.error { background: var(--error-bg); color: var(--error-fg); }
.banner.success { background: var(--success-bg); color: var(--success-fg); }

.hidden { display: none !important; }

/* Loading skeleton (credits, API key, music picker while fetching) */

.skeleton {
  position: relative;
  color: transparent !important;
  background: linear-gradient(
    90deg,
    var(--border) 25%,
    var(--card-bg) 50%,
    var(--border) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.2s ease-in-out infinite;
  border-radius: 4px;
  pointer-events: none;
}

.stat .value.skeleton {
  display: inline-block;
  min-width: 70px;
  height: 1em;
}

.skeleton-text {
  display: inline-block;
  min-width: 220px;
}

select.skeleton {
  color: var(--muted) !important;
}

@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Crop modal (assets/crop.js) */

.crop-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.crop-modal {
  background: var(--bg);
  border-radius: 10px;
  padding: 20px;
  max-width: 560px;
  width: 100%;
}

.crop-modal-title {
  font-size: 14px;
  margin: 0 0 14px;
}

.crop-modal-image-wrap {
  max-height: 60vh;
  overflow: hidden;
  border-radius: 6px;
}

.crop-modal-image {
  display: block;
  max-width: 100%;
}

.crop-modal-actions {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 16px;
}

.crop-modal .cropper-view-box,
.crop-modal .cropper-face {
  outline: 2px solid rgba(79, 70, 229, 0.85);
}
