:root {
  --bg0: #07080c;
  --bg1: #10131a;
  --ink: #f4f6fb;
  --muted: #9aa3b5;
  --line: rgba(255, 255, 255, 0.1);
  --cyan: #25f4ee;
  --hot: #fe2c55;
  --ok: #7dffb3;
  --warn: #ffd166;
  --radius: 18px;
  --font-display: "Bebas Neue", Impact, sans-serif;
  --font-body: "DM Sans", sans-serif;
  --pad-x: clamp(1rem, 4vw, 3rem);
  --mobile-bar-h: 74px;
}

* { box-sizing: border-box; }
html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font-body);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(37, 244, 238, 0.18), transparent 55%),
    radial-gradient(900px 500px at 100% 0%, rgba(254, 44, 85, 0.22), transparent 50%),
    linear-gradient(160deg, var(--bg0), var(--bg1) 45%, #0a0d14);
  overflow-x: hidden;
  padding-bottom: env(safe-area-inset-bottom);
}

.noise {
  pointer-events: none;
  position: fixed;
  inset: 0;
  opacity: 0.04;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  z-index: 0;
}

.top, .hero, .panel, .foot, .mobile-bar { position: relative; z-index: 1; }

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem var(--pad-x);
  padding-top: max(1rem, env(safe-area-inset-top));
}

.brand { display: flex; gap: 0.75rem; align-items: center; min-width: 0; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 12px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--cyan), #0ea5a0 40%, var(--hot));
  box-shadow: 0 0 0 1px rgba(255,255,255,0.15), 0 12px 40px rgba(254,44,85,0.25);
  animation: pulse 3.2s ease-in-out infinite;
}
.brand-name {
  margin: 0;
  font-family: var(--font-display);
  letter-spacing: 0.04em;
  font-size: clamp(1.15rem, 4.2vw, 2rem);
  line-height: 1;
}
.brand-sub { margin: 0.2rem 0 0; color: var(--muted); font-size: 0.8rem; }

.hero {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: clamp(1.25rem, 4vw, 3rem);
  align-items: start;
  padding: 0.35rem var(--pad-x) 2rem;
  min-height: calc(100vh - 110px);
}

.composer h1 {
  margin: 0 0 0.65rem;
  font-family: var(--font-display);
  font-size: clamp(2rem, 6vw, 4.4rem);
  line-height: 0.95;
  letter-spacing: 0.02em;
  max-width: 12ch;
}
.lede {
  margin: 0 0 1.35rem;
  color: var(--muted);
  font-size: 1.02rem;
  max-width: 36rem;
  line-height: 1.45;
}

.label {
  display: block;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--cyan);
  margin-bottom: 0.45rem;
}

.idea-box {
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.03);
  border-radius: var(--radius);
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
  overflow: hidden;
}
.idea-box:focus-within,
.idea-box.dragover {
  border-color: rgba(37, 244, 238, 0.55);
  box-shadow: 0 0 0 4px rgba(37, 244, 238, 0.12);
}
.idea-box.dragover { background: rgba(37, 244, 238, 0.06); }

.attach-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  padding: 0.75rem 0.85rem 0;
}

.attach-chip {
  position: relative;
  width: 64px;
  height: 64px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #0b0d12;
  flex-shrink: 0;
}
.attach-chip img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.attach-chip button {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 999px;
  background: rgba(0,0,0,0.72);
  color: #fff;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
}

textarea {
  width: 100%;
  resize: vertical;
  min-height: 120px;
  border: 0;
  background: transparent;
  color: var(--ink);
  border-radius: 0;
  padding: 1rem 1.1rem 0.35rem;
  /* 16px evita zoom automático en iOS */
  font: 500 16px/1.45 var(--font-body);
  outline: none;
}

.idea-toolbar {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
  padding: 0.35rem 0.65rem 0.65rem;
}

.clip-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.04);
  color: var(--ink);
  border-radius: 999px;
  padding: 0.65rem 0.95rem;
  min-height: 44px;
  font: 600 0.85rem/1 var(--font-body);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.clip-btn:hover {
  border-color: rgba(37, 244, 238, 0.45);
  color: var(--cyan);
  background: rgba(37, 244, 238, 0.08);
}
.clip-btn svg { flex-shrink: 0; }
.clip-hint { color: var(--muted); font-size: 0.78rem; }

.duration-box {
  margin-top: 1rem;
  padding: 0.9rem 0.95rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255,255,255,0.03);
}
.duration-box .clip-hint { display: block; margin-top: 0.7rem; }
.duration-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}
.duration-head .label { margin: 0; }
.duration-head strong {
  font-family: var(--font-display);
  letter-spacing: 0.04em;
  font-size: 1.25rem;
  color: var(--cyan);
}
#duration {
  width: 100%;
  accent-color: var(--hot);
  cursor: pointer;
  height: 28px;
}
.duration-marks {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.7rem;
  margin-top: 0.15rem;
}
.duration-presets {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.7rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-bottom: 2px;
}
.duration-presets::-webkit-scrollbar { display: none; }
.preset {
  appearance: none;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.04);
  color: var(--muted);
  border-radius: 999px;
  padding: 0.55rem 0.8rem;
  min-height: 40px;
  font: 600 0.78rem/1 var(--font-body);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}
.preset.active {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(90deg, var(--hot), #ff5a7a);
}

.actions { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 1rem; }

.btn {
  appearance: none;
  border: 0;
  cursor: pointer;
  font: 700 0.95rem/1 var(--font-body);
  border-radius: 999px;
  padding: 0.95rem 1.35rem;
  min-height: 48px;
  text-decoration: none;
  color: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease, opacity 0.15s ease, background 0.15s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn:not(:disabled):hover { transform: translateY(-1px); }
.btn.primary {
  background: linear-gradient(90deg, var(--hot), #ff5a7a 55%, #ff8aa3);
  color: #fff;
  box-shadow: 0 10px 30px rgba(254, 44, 85, 0.35);
}
.btn.secondary {
  background: rgba(255,255,255,0.08);
  border: 1px solid var(--line);
}
.btn.ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
}

.status {
  min-height: 1.4rem;
  margin-top: 0.85rem;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.35;
}
.status.ok { color: var(--ok); }
.status.err { color: #ff7b8f; }
.status.warn { color: var(--warn); }

.progress {
  margin-top: 0.75rem;
  height: 6px;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
  overflow: hidden;
}
.bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--cyan), var(--hot));
  transition: width 0.35s ease;
}

.preview { display: grid; justify-items: center; gap: 0.85rem; }
.phone {
  width: min(100%, 320px);
  aspect-ratio: 9 / 16;
  border-radius: 28px;
  padding: 10px;
  background: linear-gradient(160deg, #1a1f2b, #0b0d12);
  border: 1px solid var(--line);
  box-shadow: 0 30px 80px rgba(0,0,0,0.55);
  position: relative;
  overflow: hidden;
  animation: floaty 5s ease-in-out infinite;
}
.phone-notch {
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%);
  width: 38%; height: 18px; border-radius: 999px; background: #050607; z-index: 2;
}
#stage {
  width: 100%; height: 100%;
  display: block;
  border-radius: 20px;
  background: #111;
  object-fit: cover;
}
.phone-caption {
  position: absolute;
  left: 18px; right: 18px; bottom: 28px;
  text-align: center;
  font-weight: 700;
  font-size: 0.95rem;
  text-shadow: 0 2px 10px #000;
  pointer-events: none;
}
.preview-actions {
  display: flex;
  gap: 0.55rem;
  flex-wrap: wrap;
  justify-content: center;
  width: 100%;
}
.preview-actions .btn { flex: 1 1 140px; max-width: 200px; }

.panel { padding: 0 var(--pad-x) 3rem; }
.panel-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
.panel article {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  background: rgba(255,255,255,0.03);
}
.panel h2 {
  margin: 0 0 0.75rem;
  font-family: var(--font-display);
  letter-spacing: 0.04em;
  font-size: 1.5rem;
}
#scriptOut {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--muted);
  font-size: 0.82rem;
  max-height: 420px;
  overflow: auto;
}
.scenes {
  display: grid;
  gap: 0.75rem;
  max-height: 420px;
  overflow: auto;
}
.scene-card {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 0.75rem;
  align-items: center;
}
.scene-card img {
  width: 72px; height: 128px; object-fit: cover; border-radius: 10px; background: #111;
}
.scene-card p { margin: 0.15rem 0; color: var(--muted); font-size: 0.85rem; }
.scene-card strong { font-size: 0.95rem; }

.foot {
  padding: 1rem var(--pad-x) 2rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.mobile-bar { display: none; }

@keyframes pulse {
  0%, 100% { transform: scale(1); filter: brightness(1); }
  50% { transform: scale(1.04); filter: brightness(1.15); }
}
@keyframes floaty {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

/* —— Móvil / tablet —— */
@media (max-width: 960px) {
  .hero {
    grid-template-columns: 1fr;
    min-height: unset;
    gap: 1.25rem;
    padding-bottom: calc(var(--mobile-bar-h) + env(safe-area-inset-bottom) + 1.25rem);
  }

  .composer h1 {
    max-width: none;
    font-size: clamp(1.85rem, 9vw, 2.6rem);
  }
  .lede { font-size: 0.95rem; margin-bottom: 1rem; }

  .desktop-actions { display: none; }

  .preview { order: -1; }
  .phone {
    width: min(58vw, 220px);
    animation: none;
    margin: 0 auto;
  }
  .phone-notch { top: 10px; height: 12px; }
  .preview-actions .btn { max-width: none; }

  .panel {
    padding-bottom: calc(var(--mobile-bar-h) + env(safe-area-inset-bottom) + 1.5rem);
  }
  .panel-grid { grid-template-columns: 1fr; }

  .foot {
    padding-bottom: calc(var(--mobile-bar-h) + env(safe-area-inset-bottom) + 1rem);
    font-size: 0.78rem;
  }

  .mobile-bar {
    display: flex;
    gap: 0.55rem;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 50;
    padding: 0.7rem 0.85rem;
    padding-bottom: max(0.7rem, env(safe-area-inset-bottom));
    background: rgba(7, 8, 12, 0.92);
    backdrop-filter: blur(14px);
    border-top: 1px solid var(--line);
    box-shadow: 0 -12px 40px rgba(0,0,0,0.45);
  }
  .mobile-bar .btn.ghost { flex: 0 0 auto; min-width: 88px; }
  .mobile-bar .btn.primary { flex: 1; }
}

@media (max-width: 420px) {
  .brand-sub { display: none; }
  .clip-hint { width: 100%; }
  .phone { width: min(64vw, 200px); }
  .attach-chip { width: 56px; height: 56px; }
}

@media (hover: none) {
  .btn:not(:disabled):hover { transform: none; }
  .preset:hover { color: var(--muted); border-color: var(--line); }
  .preset.active:hover { color: #fff; }
}
