:root {
  --bg: #05050a;
  --bg2: #0b0b12;
  --bg3: #12121c;
  --card: #14141f;
  --border: rgba(255,255,255,0.08);
  --border2: rgba(255,255,255,0.14);
  --text: #f4f4f8;
  --muted: #9a9aad;
  --accent: #7c5cff;
  --accent2: #a78bfa;
  --green: #30d158;
  --yellow: #ffd60a;
  --red: #ff453a;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 20px 50px rgba(0,0,0,0.45);
  --font: 'Inter', system-ui, -apple-system, sans-serif;
  --display: 'Space Grotesk', var(--font);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }
button { cursor: pointer; border: none; background: none; }
ul, ol { list-style: none; }

.noise {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
  opacity: 0.5;
}
.bg-glow {
  position: fixed; top: -20%; left: 50%; transform: translateX(-50%);
  width: 90vw; height: 50vh; pointer-events: none; z-index: 0;
  background: radial-gradient(ellipse, rgba(124,92,255,0.18) 0%, transparent 70%);
}

/* ─── HEADER ─────────────────────────────────────────────────────── */
.top {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  background: rgba(5,5,10,0.9);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}
.logo {
  font-family: var(--display); font-weight: 700; font-size: 1.15rem; letter-spacing: -0.03em;
  flex-shrink: 0;
}
.logo span { color: var(--accent2); }
.nav { display: none; gap: 18px; margin-left: 8px; }
.nav a { font-size: 0.88rem; color: var(--muted); transition: color .15s; }
.nav a:hover { color: var(--text); }
.top-actions {
  margin-left: auto;
  display: flex; align-items: center; gap: 8px;
  flex-wrap: nowrap;
}
.top-actions .btn { white-space: nowrap; }

/* ─── BUTTONS ────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: 0.88rem;
  border: none;
  transition: transform .15s, box-shadow .15s, background .15s;
  min-height: 40px;
  touch-action: manipulation;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 8px 24px rgba(124,92,255,0.4); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-sm { padding: 7px 12px; font-size: 0.8rem; min-height: 36px; }
.btn-lg { padding: 12px 22px; font-size: 0.95rem; min-height: 46px; }
.btn-full { width: 100%; }
.btn-ghost {
  background: transparent;
  border: 1px solid var(--border2);
  color: var(--text);
}
.btn-ghost:hover { background: rgba(255,255,255,0.05); box-shadow: none; }

/* ─── HERO ───────────────────────────────────────────────────────── */
.hero {
  position: relative; z-index: 1;
  text-align: center;
  padding: 48px 16px 40px;
  max-width: 900px;
  margin: 0 auto;
}
.pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(124,92,255,0.12);
  border: 1px solid rgba(124,92,255,0.25);
  font-size: 0.78rem;
  color: var(--accent2);
  margin-bottom: 20px;
}
.dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 10px var(--green);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}
.hero h1 {
  font-family: var(--display);
  font-size: clamp(1.8rem, 6vw, 3.2rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.15;
  margin-bottom: 14px;
}
.hero h1 em { font-style: normal; color: var(--accent2); }
.lead {
  color: var(--muted);
  font-size: clamp(0.95rem, 2.5vw, 1.1rem);
  max-width: 580px;
  margin: 0 auto 24px;
  line-height: 1.55;
}
.hero-cta {
  display: flex; gap: 10px; justify-content: center;
  flex-wrap: wrap; margin-bottom: 36px;
}
.hero-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px 12px;
  max-width: 360px;
  margin: 0 auto;
}
.hero-stats div { text-align: center; }
.hero-stats strong {
  display: block;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.hero-stats span { font-size: 0.75rem; color: var(--muted); }

/* ─── SECTIONS ───────────────────────────────────────────────────── */
.section {
  position: relative; z-index: 1;
  padding: 48px 16px;
  max-width: 1100px;
  margin: 0 auto;
}
.sec-head { text-align: center; margin-bottom: 28px; }
.sec-head h2 {
  font-family: var(--display);
  font-size: clamp(1.4rem, 4vw, 1.9rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
}
.sec-head p { color: var(--muted); max-width: 520px; margin: 0 auto; font-size: 0.95rem; }

.feat-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  transition: border-color .15s;
}
.card:hover { border-color: var(--border2); }
.card-icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: rgba(124,92,255,0.15);
  display: grid; place-items: center;
  font-size: 0.95rem;
  margin-bottom: 12px;
}
.card h3 { font-size: 1rem; margin-bottom: 6px; }
.card p { font-size: 0.88rem; color: var(--muted); line-height: 1.5; }

/* ─── STUDIO ─────────────────────────────────────────────────────── */
.studio-wrap { max-width: 1200px; }
.studio {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}
.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.panel-title {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.url-row { display: flex; gap: 8px; flex-wrap: wrap; }
.url-row input {
  flex: 1;
  min-width: 0;
  padding: 11px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg3);
  min-height: 44px;
}
.url-row input:focus { outline: none; border-color: var(--accent); }
.meta-box {
  display: flex; gap: 12px; align-items: center;
  padding: 10px;
  background: var(--bg3);
  border-radius: 12px;
  border: 1px solid var(--border);
}
.meta-box img {
  width: 72px; height: 40px;
  object-fit: cover;
  border-radius: 6px;
  flex-shrink: 0;
}
.meta-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.meta-text strong {
  font-size: 0.88rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.meta-text span { font-size: 0.75rem; color: var(--muted); }

.controls { display: flex; flex-direction: column; gap: 12px; }
.ctrl label {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 5px;
}
.ctrl select, .ctrl input[type="text"] {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg3);
  min-height: 42px;
}
.ratio-seg {
  display: flex;
  background: var(--bg3);
  border-radius: 10px;
  padding: 3px;
  border: 1px solid var(--border);
}
.ratio-seg button {
  flex: 1;
  padding: 9px 4px;
  border: none;
  background: transparent;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--muted);
  min-height: 38px;
  transition: background .15s, color .15s;
}
.ratio-seg button.on {
  background: var(--accent);
  color: #fff;
}

.results-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.results-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.progress {
  margin-bottom: 16px;
}
.progress-bar {
  height: 6px;
  background: var(--bg3);
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 8px;
}
.progress-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  border-radius: 99px;
  transition: width .3s ease;
}
.progress-text { font-size: 0.85rem; color: var(--muted); }

.clip-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}
.clip-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  transition: border-color .15s, transform .15s;
}
.clip-card:hover { border-color: var(--border2); transform: translateY(-2px); }
.clip-card.selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.clip-thumb {
  aspect-ratio: 9/16;
  background: #1a1a28;
  position: relative;
  overflow: hidden;
}
.clip-thumb img {
  width: 100%; height: 100%;
  object-fit: cover;
  opacity: 0.7;
}
.clip-score {
  position: absolute; top: 8px; left: 8px;
  font-size: 0.72rem; font-weight: 700;
  padding: 3px 7px;
  border-radius: 6px;
  background: rgba(0,0,0,0.65);
}
.clip-score.high { color: var(--green); }
.clip-score.mid { color: var(--yellow); }
.clip-score.low { color: var(--muted); }
.clip-check {
  position: absolute; top: 8px; right: 8px;
  width: 22px; height: 22px;
  border-radius: 6px;
  border: 1.5px solid rgba(255,255,255,0.4);
  display: grid; place-items: center;
  font-size: 0.7rem;
  color: transparent;
  background: rgba(0,0,0,0.3);
}
.clip-card.selected .clip-check {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.clip-real {
  position: absolute;
  bottom: 6px; left: 6px;
  font-size: 0.62rem;
  background: rgba(34,197,94,0.9);
  color: #fff;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
}
.clip-body { padding: 10px; }
.clip-body h4 {
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.clip-body .time { font-size: 0.72rem; color: var(--muted); }
.clip-body .reason {
  font-size: 0.7rem;
  color: var(--muted);
  margin-top: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.clip-dl {
  display: inline-block;
  margin-top: 6px;
  font-size: 0.75rem;
  color: #60a5fa;
  font-weight: 500;
}
.clip-dl:hover { text-decoration: underline; }

.empty-state {
  text-align: center;
  padding: 40px 16px;
  color: var(--muted);
  font-size: 0.95rem;
}

/* ─── STYLES GRID ────────────────────────────────────────────────── */
.style-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}
.style-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-align: center;
  min-height: 90px;
  cursor: default;
}
.style-preview {
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.style-name { font-size: 0.72rem; color: var(--muted); }

/* Caption style demos */
.style-wordpop .style-preview { color: #fff; text-shadow: 0 2px 0 #7c5cff; }
.style-hormozi .style-preview { background: #fff; color: #000; padding: 2px 6px; border-radius: 4px; font-weight: 900; }
.style-beast .style-preview { color: #ffd60a; font-weight: 900; text-transform: uppercase; }
.style-karaoke .style-preview span { background: #7c5cff; color: #fff; padding: 0 3px; border-radius: 3px; }
.style-neon .style-preview { color: #a78bfa; text-shadow: 0 0 8px #7c5cff, 0 0 16px #7c5cff; }
.style-boxed .style-preview { border: 2px solid #fff; padding: 2px 6px; }
.style-minimal .style-preview { color: #fff; font-weight: 400; letter-spacing: 0.05em; }
.style-bounce .style-preview { color: #30d158; }
.style-typewriter .style-preview { font-family: monospace; color: #ccc; }
.style-emoji .style-preview::after { content: ' 🔥'; }

/* ─── FAQ ────────────────────────────────────────────────────────── */
.faq-list {
  max-width: 700px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.faq-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
}
.faq-item summary {
  font-weight: 600;
  font-size: 0.92rem;
  cursor: pointer;
  list-style: none;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item p {
  margin-top: 8px;
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.5;
}

/* ─── EDITOR MODAL ───────────────────────────────────────────────── */
.editor-modal {
  position: fixed; inset: 0; z-index: 900;
  display: flex; align-items: center; justify-content: center;
  padding: 12px;
}
.editor-modal.hidden { display: none; }
.editor-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(8px);
}
.editor-card {
  position: relative;
  width: min(920px, 100%);
  max-height: 92vh;
  overflow: auto;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
}
.editor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0;
  background: var(--bg2);
  z-index: 2;
}
.editor-head h3 { font-size: 1rem; }
.editor-body {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  padding: 16px;
}
.ed-preview {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.phone {
  width: min(220px, 70vw);
  aspect-ratio: 9/16;
  background: #0a0a12;
  border-radius: 20px;
  position: relative;
  overflow: hidden;
  border: 2px solid var(--border2);
  box-shadow: 0 12px 40px rgba(0,0,0,0.5);
}
.phone-safe {
  position: absolute;
  left: 8%; right: 8%;
  top: 12%; bottom: 18%;
  border: 1px dashed rgba(255,255,255,0.15);
  border-radius: 4px;
  pointer-events: none;
}
.phone-cap {
  position: absolute;
  left: 8%; right: 8%;
  bottom: 22%;
  text-align: center;
  font-weight: 700;
  font-size: 0.95rem;
  line-height: 1.25;
  text-shadow: 0 1px 4px rgba(0,0,0,0.8);
}
.ed-controls { display: flex; flex-direction: column; gap: 12px; }
.color-row { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
}
.swatch.on { border-color: #fff; }
.ctrl.row { display: flex; gap: 16px; flex-wrap: wrap; }
.chk {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.88rem; cursor: pointer;
}
.editor-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  position: sticky; bottom: 0;
  background: var(--bg2);
}

/* ─── BACKEND MODAL ──────────────────────────────────────────────── */
.modal {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.modal.hidden { display: none; }
.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(6px);
}
.modal-card {
  position: relative;
  background: #12121a;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 16px;
  width: min(460px, 100%);
  padding: 20px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.5);
  max-height: 90vh;
  overflow-y: auto;
}
.modal-wide { width: min(480px, 100%); }
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}
.modal-head h3 { margin: 0; font-size: 1.1rem; }
.modal-body .lbl {
  display: block;
  margin: 12px 0 5px;
  font-size: 0.78rem;
  opacity: 0.7;
}
.modal-body .input, .modal-body select {
  width: 100%;
  padding: 11px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.12);
  background: #0c0c12;
  color: #fff;
  font-size: 0.9rem;
  min-height: 44px;
}
.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: wrap;
  margin-top: 18px;
}
.os-status {
  margin-top: 12px;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 0.84rem;
  background: rgba(255,255,255,0.04);
}
.os-status.connected { background: rgba(34,197,94,0.15); color: #4ade80; }
.os-status.error { background: rgba(239,68,68,0.12); color: #f87171; }
.hint { font-size: 0.85rem; color: var(--muted); margin-bottom: 8px; }
.hint.small { font-size: 0.75rem; opacity: 0.55; margin-top: 10px; }
.icon-btn {
  background: none; border: none;
  color: #aaa; font-size: 1.5rem;
  cursor: pointer; line-height: 1;
  padding: 4px 8px;
  min-width: 36px; min-height: 36px;
}
.backend-tips {
  margin-top: 14px;
  padding: 12px;
  background: rgba(255,255,255,0.03);
  border-radius: 10px;
  font-size: 0.76rem;
  line-height: 1.55;
  opacity: 0.8;
}
.backend-tips code {
  background: rgba(255,255,255,0.08);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.72rem;
}

.hidden { display: none !important; }

/* ─── RESPONSIVE ─────────────────────────────────────────────────── */
@media (min-width: 640px) {
  .top { padding: 14px 24px; gap: 16px; }
  .nav { display: flex; }
  .hero { padding: 64px 24px 56px; }
  .hero-stats {
    display: flex;
    justify-content: center;
    gap: 32px;
    max-width: none;
  }
  .feat-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .section { padding: 56px 24px; }
  .clip-grid {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  }
}

@media (min-width: 900px) {
  .studio {
    grid-template-columns: 360px 1fr;
  }
  .editor-body {
    grid-template-columns: 260px 1fr;
  }
  .feat-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  .top-actions { gap: 10px; }
}

@media (min-width: 1100px) {
  .feat-grid {
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  }
}

/* Prevent horizontal scroll on tiny screens */
@media (max-width: 380px) {
  .top-actions .btn-sm { padding: 6px 10px; font-size: 0.75rem; }
  .logo { font-size: 1.05rem; }
}
