/* ===========================================================================
   GuionAI — tema día (por defecto) y noche.
   Todo el color vive en variables; [data-theme="dark"] las sobreescribe.
   =========================================================================== */
:root,
:root[data-theme="light"] {
  --bg: #f6f6fa;
  --bg-grad-1: rgba(71, 0, 224, 0.07);
  --bg-grad-2: rgba(107, 43, 255, 0.05);
  --surface: #ffffff;
  --surface-2: #f2f2f7;
  --line: #e3e3ed;
  --line-strong: #cfcfe0;
  --text: #16161d;
  --muted: #6a6a80;
  --accent: #4700e0;
  --accent-soft: #6b2bff;
  --accent-wash: rgba(71, 0, 224, 0.07);
  --cta-bg: #4700e0;
  --cta-text: #ffffff;
  --cta-shadow: rgba(71, 0, 224, 0.28);
  --mark: #4700e0;
  --danger: #d1003c;
  --ok: #0a7d4a;
  --shadow: 0 1px 2px rgba(16, 16, 30, 0.04), 0 8px 24px rgba(16, 16, 30, 0.06);
}

:root[data-theme="dark"] {
  --bg: #0a0a0f;
  --bg-grad-1: rgba(71, 0, 224, 0.28);
  --bg-grad-2: rgba(107, 43, 255, 0.14);
  --surface: #14141f;
  --surface-2: #101018;
  --line: #262636;
  --line-strong: #3a3a50;
  --text: #ececf2;
  --muted: #8f8fa6;
  --accent: #6b2bff;
  --accent-soft: #8a5cff;
  --accent-wash: rgba(107, 43, 255, 0.16);
  --cta-bg: #ffff00;
  --cta-text: #0a0a0f;
  --cta-shadow: rgba(255, 255, 0, 0.2);
  --mark: #ffff00;
  --danger: #ff5470;
  --ok: #7dffb0;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  padding: 0;
}
body {
  background:
    radial-gradient(900px 460px at 12% -8%, var(--bg-grad-1), transparent 70%),
    radial-gradient(700px 380px at 96% 0%, var(--bg-grad-2), transparent 70%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-family: "Montserrat", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
}
/* Ojo: NO poner `transition` sobre background-color/color en <body>.
   Cuando esos valores vienen de una custom property que cambia en :root
   (el switch de tema), Chrome se queda con el valor inicial y el fondo
   nunca llega a actualizarse. El cambio de tema va instantáneo a propósito. */

.wrap {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ---------------------------- header ---------------------------- */
.top {
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 20;
}
.top-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-top: 14px;
  padding-bottom: 14px;
}
.brand {
  text-decoration: none;
  color: inherit;
}
.logo {
  font-weight: 900;
  font-size: 21px;
  letter-spacing: -0.02em;
}
.logo-ai {
  color: var(--accent);
}
:root[data-theme="dark"] .logo-ai {
  color: var(--mark);
}
.top-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.badge {
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  color: var(--muted);
  white-space: nowrap;
}
.badge--demo {
  color: #a06b00;
  border-color: rgba(200, 140, 0, 0.4);
  background: rgba(255, 190, 0, 0.1);
}
:root[data-theme="dark"] .badge--demo {
  color: #ffd84d;
}
.badge--live {
  color: var(--ok);
  border-color: color-mix(in srgb, var(--ok) 40%, transparent);
  background: color-mix(in srgb, var(--ok) 10%, transparent);
}

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: 0.15s;
}
.icon-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.icon-moon {
  display: none;
}
:root[data-theme="dark"] .icon-sun {
  display: none;
}
:root[data-theme="dark"] .icon-moon {
  display: inline;
}

/* ---------------------------- asistente ---------------------------- */
.asistente {
  padding: 32px 0 8px;
}

.stepper {
  display: flex;
  gap: 6px;
  list-style: none;
  margin: 0 0 30px;
  padding: 0;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}
.stepper li {
  display: flex;
  align-items: center;
  gap: 7px;
  flex: 1;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--line);
  transition: 0.2s;
}
.stepper .dot {
  display: grid;
  place-items: center;
  width: 21px;
  height: 21px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  font-size: 11px;
  flex-shrink: 0;
}
.stepper li[data-estado="activo"] {
  color: var(--text);
  border-bottom-color: var(--accent);
}
.stepper li[data-estado="activo"] .dot {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.stepper li[data-estado="hecho"] {
  color: var(--accent);
  cursor: pointer;
  border-bottom-color: var(--accent);
}
.stepper li[data-estado="hecho"] .dot {
  background: var(--accent-wash);
  border-color: var(--accent);
  color: var(--accent);
}
.stepper li[data-estado="hecho"] .dot::after {
  content: "✓";
}
.stepper li[data-estado="hecho"] .dot {
  font-size: 0;
}
.stepper li[data-estado="hecho"] .dot::after {
  font-size: 11px;
}

h1 {
  font-size: 27px;
  font-weight: 900;
  letter-spacing: -0.025em;
  margin: 0 0 6px;
  line-height: 1.2;
}
.sub {
  color: var(--muted);
  font-size: 14px;
  margin: 0 0 22px;
}
.tip {
  font-size: 13px;
  margin-bottom: 16px;
}
h2 {
  font-size: 14px;
  font-weight: 800;
  margin: 0 0 10px;
}
em {
  font-style: normal;
  color: var(--muted);
  font-weight: 400;
}

.paso {
  animation: entra 0.25s ease;
}
@keyframes entra {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

.bloque {
  margin-bottom: 22px;
}

/* ---------------------------- inputs ---------------------------- */
textarea,
input[type="text"],
select {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  color: var(--text);
  border-radius: 11px;
  padding: 12px 14px;
  font-family: inherit;
  font-size: 15px;
  resize: vertical;
  transition: 0.15s;
}
textarea::placeholder,
input::placeholder {
  color: var(--muted);
  opacity: 0.75;
}
textarea:focus,
input:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-wash);
}
.field {
  display: block;
  margin-top: 14px;
}
.field > span {
  display: block;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 6px;
}
.field small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 5px;
}
.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  align-items: start;
}
@media (max-width: 600px) {
  .row {
    grid-template-columns: 1fr;
  }
}
.otros {
  margin-top: 10px;
}

.mas {
  margin-top: 16px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}
.mas summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  list-style: none;
}
.mas summary::-webkit-details-marker {
  display: none;
}
.mas summary::before {
  content: "+ ";
  color: var(--accent);
}
.mas[open] summary::before {
  content: "− ";
}

.segmented {
  display: inline-flex;
  gap: 4px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 4px;
  margin-bottom: 14px;
}
.segmented input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.segmented span {
  display: block;
  padding: 7px 15px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
  transition: 0.15s;
}
.segmented input:checked + span {
  background: var(--surface);
  color: var(--accent);
  box-shadow: var(--shadow);
}

/* ---------------------------- chips ---------------------------- */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chip input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.chip span {
  display: block;
  padding: 8px 14px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
  user-select: none;
  transition: 0.12s;
}
.chip span:hover {
  border-color: var(--accent);
}
.chip input:checked + span {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 700;
}
.chip input:focus-visible + span {
  box-shadow: 0 0 0 3px var(--accent-wash);
}

/* ---------------------------- estilos ---------------------------- */
.estilos {
  display: grid;
  gap: 12px;
}
.estilo input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.estilo .box {
  display: block;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 13px;
  padding: 18px;
  cursor: pointer;
  transition: 0.15s;
}
.estilo .box:hover {
  border-color: var(--accent);
}
.estilo input:checked + .box {
  border-color: var(--accent);
  background: var(--accent-wash);
  box-shadow: 0 0 0 1px var(--accent);
}
.estilo b {
  font-size: 16px;
  font-weight: 800;
}
.estilo p {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--muted);
}
.tag {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  padding: 2px 6px;
  margin-left: 8px;
  vertical-align: middle;
}

/* ---------------------------- nav / botones ---------------------------- */
.nav {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 30px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}
.nav .errores {
  flex: 1;
}
#atras + .errores {
  text-align: center;
}
.nav #siguiente,
.nav #generar {
  margin-left: auto;
}

.btn {
  font-family: inherit;
  font-weight: 800;
  font-size: 14px;
  border-radius: 11px;
  padding: 12px 22px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: 0.15s;
  white-space: nowrap;
}
.btn--primary {
  background: var(--cta-bg);
  color: var(--cta-text);
}
.btn--primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px var(--cta-shadow);
}
.btn--ghost {
  background: var(--surface);
  border-color: var(--line-strong);
  color: var(--text);
  padding: 10px 16px;
  font-size: 13px;
}
.btn--ghost:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}
.errores {
  color: var(--danger);
  font-size: 13px;
  font-weight: 700;
}
.link {
  background: none;
  border: 0;
  color: var(--muted);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  padding: 0;
}
.link:hover {
  color: var(--accent);
}
.back {
  display: inline-block;
  margin: 26px 0 18px;
  font-weight: 700;
}

/* ---------------------------- historial ---------------------------- */
.historial {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 26px 0 0;
  border-top: 1px solid var(--line);
  margin-top: 26px;
}
.historial-label {
  font-size: 11px;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}
.historial-items {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  flex: 1;
}
.historial-items button {
  font-family: inherit;
  font-size: 12px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 5px 13px;
  cursor: pointer;
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.historial-items button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ---------------------------- resumen ---------------------------- */
.resumen {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 6px 18px;
  margin-bottom: 26px;
  box-shadow: var(--shadow);
}
.resumen-fila {
  display: flex;
  gap: 14px;
  align-items: baseline;
  padding: 11px 0;
  font-size: 13px;
  border-bottom: 1px solid var(--line);
}
.resumen-fila:last-child {
  border-bottom: 0;
}
.resumen-fila > b {
  flex: 0 0 92px;
  color: var(--muted);
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.resumen-fila > span {
  flex: 1;
  min-width: 0;
}
.resumen-fila .link {
  flex: 0 0 auto;
  font-size: 12px;
}

/* ---------------------------- resultado ---------------------------- */
.resultado {
  padding-bottom: 50px;
}
.resultado-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.resultado-head h1 {
  font-size: 25px;
}
.resultado-acciones {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.aviso {
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 11px;
  padding: 12px 15px;
  font-size: 13px;
  margin: 0 0 18px;
}

.tomas {
  display: grid;
  gap: 14px;
}
.toma {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 13px;
  padding: 18px 20px;
  box-shadow: var(--shadow);
}
.toma-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.toma-num {
  font-weight: 900;
  font-size: 15px;
}
.toma-bloque {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: var(--accent);
  color: #fff;
  border-radius: 5px;
  padding: 3px 8px;
}
.toma-dur {
  margin-left: auto;
  font-size: 12px;
  color: var(--muted);
}
.meta-line {
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 5px;
}
.meta-line b {
  color: var(--text);
  font-weight: 700;
}
.dialogo {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 14px 16px;
  margin: 13px 0 11px;
  font-size: 15.5px;
  line-height: 1.6;
}
.dialogo::before {
  content: "DI ESTA FRASE";
  display: block;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.11em;
  color: var(--accent);
  margin-bottom: 6px;
}
:root[data-theme="dark"] .dialogo::before {
  color: var(--mark);
}
.dialogo[contenteditable="true"]:hover {
  border-color: var(--line-strong);
}
.dialogo[contenteditable="true"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-wash);
}
.storyboard {
  border-top: 1px dashed var(--line-strong);
  padding-top: 11px;
  font-size: 13px;
  color: var(--muted);
}
.storyboard b {
  color: var(--text);
  font-weight: 700;
}
.storyboard img {
  display: block;
  width: 100%;
  max-width: 210px;
  border-radius: 10px;
  margin-top: 10px;
}

.notas {
  margin-top: 22px;
}
.notas-inner {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 18px 20px;
  box-shadow: var(--shadow);
}
.notas h2 {
  margin-bottom: 8px;
}
.notas ul {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 13px;
}
.notas li + li {
  margin-top: 6px;
}

/* ---------------------------- foot ---------------------------- */
.foot {
  border-top: 1px solid var(--line);
  padding-top: 18px;
  padding-bottom: 34px;
  color: var(--muted);
  font-size: 12px;
}
.foot p {
  margin: 0;
}

.spinner {
  display: inline-block;
  width: 13px;
  height: 13px;
  border: 2px solid color-mix(in srgb, var(--cta-text) 30%, transparent);
  border-top-color: var(--cta-text);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin-right: 8px;
  vertical-align: -2px;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}
