:root {
  --bg: #ffffff;
  --bg-panel: #f7f7f9;
  --bg-input: #f1f1f4;
  --bg-own-1: #d62976;
  --bg-own-2: #962fbf;
  --bg-own-3: #4f5bd5;
  --bg-other: #f0f0f3;
  --text: #0d0d0d;
  --text-dim: #5a5a63;
  --text-meta: #8b8b95;
  --accent: #d62976;
  --accent-2: #962fbf;
  --accent-strong: #d62976;
  --accent-soft: rgba(214, 41, 118, 0.13);
  --border: rgba(0, 0, 0, 0.08);
  --border-strong: rgba(0, 0, 0, 0.14);
  --danger: #e0245e;
  --err: #d93025;
  --ok: #16a34a;
  --radius: 16px;
  --radius-sm: 12px;
  --shadow: 0 10px 34px rgba(17, 12, 46, 0.12);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.hidden { display: none !important; }

/* App: ligera atmósfera de la paleta Instagram */
body {
  background:
    radial-gradient(1200px 620px at 82% -12%, rgba(214, 41, 118, 0.06), transparent 60%),
    radial-gradient(900px 520px at -8% 112%, rgba(250, 126, 30, 0.05), transparent 60%),
    var(--bg);
}

/* ============ Login ============ */
.login-screen {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(1100px 700px at 12% -10%, rgba(250, 126, 30, 0.18), transparent 55%),
    radial-gradient(1100px 700px at 92% 112%, rgba(214, 41, 118, 0.2), transparent 55%),
    radial-gradient(900px 600px at 50% 120%, rgba(77, 91, 213, 0.12), transparent 60%),
    #fff;
  position: relative;
  overflow: hidden;
}
/* Orbes decorativos */
.login-screen::before,
.login-screen::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.5;
  z-index: 0;
}
.login-screen::before {
  width: 430px; height: 430px;
  background: radial-gradient(circle, rgba(254, 218, 117, 0.7), transparent 70%);
  top: -130px; left: -90px;
}
.login-screen::after {
  width: 470px; height: 470px;
  background: radial-gradient(circle, rgba(150, 47, 191, 0.4), transparent 70%);
  bottom: -150px; right: -110px;
}
.login-card {
  position: relative;
  z-index: 1;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid var(--border-strong);
  padding: 42px 40px;
  border-radius: 24px;
  text-align: center;
  max-width: 384px;
  width: 100%;
  box-shadow: 0 32px 74px rgba(17, 12, 46, 0.14), inset 0 1px 0 rgba(255, 255, 255, 0.6);
}
.login-logo {
  width: 86px; height: 86px;
  margin: 0 auto 18px;
  border-radius: 26px;
  display: flex; align-items: center; justify-content: center;
  font-size: 40px;
  background: linear-gradient(135deg, var(--bg-own-1), var(--bg-own-2), var(--bg-own-3));
  color: #fff;
  box-shadow: 0 16px 34px rgba(214, 41, 118, 0.34);
}
.login-card h1 {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(90deg, #26262b, #0d0d0d);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 8px;
}
.login-card p { color: var(--text-dim); font-size: 15px; margin-bottom: 28px; }
.btn-primary {
  background: linear-gradient(135deg, var(--bg-own-1), var(--bg-own-2), var(--bg-own-3));
  color: #fff;
  border: none;
  padding: 14px 32px;
  border-radius: 15px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.2s ease, filter 0.15s ease;
  box-shadow: 0 12px 28px rgba(214, 41, 118, 0.34);
  letter-spacing: 0.01em;
}
.btn-primary:hover { filter: brightness(1.08); box-shadow: 0 15px 34px rgba(214, 41, 118, 0.44); }
.btn-primary:active { transform: scale(0.97); }
.login-msg { margin-top: 16px; color: var(--err); font-size: 14px; }
.login-feats {
  display: flex;
  justify-content: center;
  gap: 18px;
  margin-top: 26px;
  font-size: 12px;
  color: var(--text-dim);
}
.login-feats span { display: inline-flex; align-items: center; gap: 6px; }

/* ============ Layout ============ */
.app { display: flex; height: 100%; }

/* El avatar del asistente en el encabezado del chat. */
.conversation-avatar {
  width: 46px; height: 46px; border-radius: 50%;
  background: linear-gradient(135deg, var(--bg-own-1), var(--bg-own-2), var(--bg-own-3));
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; flex-shrink: 0;
  box-shadow: 0 6px 16px rgba(214, 41, 118, 0.28);
}
.user-chip { display: flex; align-items: center; gap: 10px; }
.avatar-img { width: 40px; height: 40px; border-radius: 50%; background: var(--bg-input); object-fit: cover; border: 1px solid var(--border); }
.btn-ghost {
  background: transparent; border: none; color: var(--text-dim);
  font-size: 20px; cursor: pointer; padding: 8px; border-radius: 10px;
  transition: color 0.15s, background 0.15s;
}
.btn-ghost:hover { color: var(--danger); background: rgba(224, 36, 94, 0.1); }


/* Chat */
.chat { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.chat-header {
  padding: 12px 18px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border);
}
.chat-header-title { display: flex; align-items: center; gap: 12px; }
#assistant-name { font-weight: 700; font-size: 16px; }
.chat-header-status { font-size: 12.5px; color: var(--text-dim); }
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); margin-right: 5px; box-shadow: 0 0 0 0 rgba(22, 163, 74, 0.5); }
.status-dot.is-connecting { background: #f59e0b; }
.status-dot.is-offline { background: var(--danger); }
/* Acciones del encabezado: nueva campaña + cuenta + salir. */
.header-actions { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.header-actions .user-chip { font-size: 14px; color: var(--text-dim); }
.header-actions .avatar-img { width: 32px; height: 32px; }
@media (max-width: 620px) {
  /* En pantallas chicas dejamos solo el ícono y el botón de salir. */
  .header-actions .nc-label { display: none; }
  .header-actions .user-chip span { display: none; }
}

/* Messages */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background:
    radial-gradient(1100px 600px at 90% -20%, rgba(214, 41, 118, 0.05), transparent 60%),
    radial-gradient(1000px 500px at -10% 110%, rgba(150, 47, 191, 0.05), transparent 60%),
    url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="120" height="120"><circle cx="40" cy="40" r="1.4" fill="rgba(0,0,0,0.03)"/><circle cx="100" cy="90" r="1.4" fill="rgba(0,0,0,0.03)"/><circle cx="80" cy="20" r="1" fill="rgba(0,0,0,0.02)"/><circle cx="20" cy="100" r="1" fill="rgba(0,0,0,0.02)"/></svg>'),
    #fff;
}
.messages::-webkit-scrollbar { width: 8px; }
.messages::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.14); border-radius: 10px; }
.messages::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.24); }

.msg {
  max-width: 76%;
  padding: 10px 14px 8px;
  border-radius: var(--radius);
  position: relative;
  line-height: 1.5;
  font-size: 15px;
  word-wrap: break-word;
  white-space: pre-wrap;
  animation: msg-in 0.18s ease;
}
@keyframes msg-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.msg.own {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--bg-own-1), var(--bg-own-2), var(--bg-own-3));
  border-top-right-radius: 5px;
  border-bottom-right-radius: 5px;
  color: #fff;
  box-shadow: 0 8px 24px rgba(214, 41, 118, 0.24);
}
.msg.other {
  align-self: flex-start;
  background: var(--bg-other);
  border-top-left-radius: 5px;
  border-bottom-left-radius: 5px;
  box-shadow: 0 2px 8px rgba(17, 12, 46, 0.08);
  border: 1px solid var(--border);
}
.msg.from {
  align-self: center;
  background: rgba(0, 0, 0, 0.05);
  padding: 2px 12px;
  border-radius: 14px;
  font-size: 12px;
  color: var(--text-dim);
  box-shadow: none;
}
.msg img { max-width: 260px; border-radius: 10px; display: block; margin-bottom: 6px; }
.msg .meta { font-size: 11px; color: rgba(255,255,255,0.78); text-align: right; margin-top: 3px; }
.msg.other .meta { color: var(--text-meta); }
.msg.error { background: rgba(224, 36, 94, 0.08); border: 1px solid rgba(224,36,94,0.3); color: var(--err); }
.msg.pending { opacity: 0.8; }
.msg.pending .meta { color: rgba(255,255,255,0.9); font-style: italic; }
.msg .avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, var(--bg-own-1), var(--bg-own-2), var(--bg-own-3));
  color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  margin-right: 8px; vertical-align: middle; font-size: 16px; flex-shrink: 0;
  box-shadow: 0 3px 8px rgba(214, 41, 118, 0.24);
}
.msg .msg-text a { color: var(--accent-strong); text-decoration: underline; }
.msg .msg-text code {
  background: rgba(0,0,0,0.06);
  padding: 1px 6px; border-radius: 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9em;
}

/* Composer */
.composer { background: rgba(255, 255, 255, 0.92); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--border); padding: 10px 16px 18px; }
.attachment-preview { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.attachment-preview img { max-width: 110px; max-height: 90px; border-radius: 8px; border: 1px solid var(--border-strong); }
.remove-attach {
  background: rgba(0,0,0,0.5); color: #fff; border: none; cursor: pointer;
  width: 24px; height: 24px; border-radius: 50%; font-size: 13px;
  transition: background 0.15s;
}
.remove-attach:hover { background: var(--danger); }
.composer-row { display: flex; align-items: flex-end; gap: 10px; }
.attach-btn {
  font-size: 22px; cursor: pointer; padding: 10px; color: var(--text-dim);
  line-height: 1; transition: color 0.15s, transform 0.08s;
}
.attach-btn:hover { color: var(--accent); transform: scale(1.08); }
textarea#message-input {
  flex: 1;
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 17px;
  padding: 13px 16px;
  font-size: 15px;
  font-family: inherit;
  resize: none;
  max-height: 120px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
textarea#message-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea#message-input::placeholder { color: var(--text-meta); }
.send-btn {
  background: linear-gradient(135deg, var(--bg-own-1), var(--bg-own-2), var(--bg-own-3));
  color: #fff;
  border: none;
  width: 46px; height: 46px;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 20px rgba(214, 41, 118, 0.34);
  transition: transform 0.08s, filter 0.15s;
}
.send-btn:hover { filter: brightness(1.08); transform: scale(1.04); }
.send-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* Typing indicator */
.typing-indicator {
  color: var(--text-dim); font-size: 13px; margin-top: 8px; padding-left: 4px;
  display: inline-flex; align-items: center;
}
.typing-indicator span {
  display: inline-block; width: 6px; height: 6px; background: var(--text-dim);
  border-radius: 50%; margin-left: 3px; animation: blink 1.2s infinite;
}
.typing-indicator span:nth-child(2){ animation-delay: .2s; }
.typing-indicator span:nth-child(3){ animation-delay: .4s; }
@keyframes blink { 0%,80%,100%{opacity:.2;} 40%{opacity:1;} }

/* ==========================================================================
 *  WIZARD DE MARKETING (Instagram) — estilos del chat
 * ========================================================================== */

/* Botón "Nueva campaña" (encabezado del chat) */
.new-campaign-btn {
  display: flex;
  align-items: center;
  gap: 9px;
  background: linear-gradient(135deg, var(--bg-own-1), var(--bg-own-2), var(--bg-own-3));
  border: none;
  color: #fff;
  padding: 9px 15px;
  border-radius: 13px;
  cursor: pointer;
  font-size: 14px;
  white-space: nowrap;
  font-weight: 700;
  transition: filter .15s, transform .06s, box-shadow .2s;
  box-shadow: 0 6px 16px rgba(214, 41, 118, 0.3);
}
.new-campaign-btn:hover { filter: brightness(1.1); box-shadow: 0 8px 22px rgba(214, 41, 118, 0.4); }
.new-campaign-btn:active { transform: scale(.98); }
.nc-icon { font-size: 18px; }

/* Opciones clicables dentro de la burbuja del asistente */
.msg-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(0,0,0,0.07);
  width: 100%;
}
.option-btn {
  background: var(--accent-soft);
  color: #c2185b;
  border: 1px solid rgba(214, 41, 118, 0.4);
  padding: 8px 15px;
  border-radius: 20px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, color .15s, transform .05s, border-color .15s;
}
.option-btn:hover { background: rgba(214, 41, 118, 0.22); color: #fff; border-color: var(--accent); }
.option-btn:active { transform: scale(.97); }

/* Input inline (escena / nombre) dentro del chat */
.msg-inline-form {
  flex-shrink: 0;
  width: 60%;
  max-width: 420px;
  margin-top: 4px;
  align-self: flex-start;
  background: var(--bg-other);
  border-radius: 16px;
  border-top-left-radius: 5px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  box-shadow: 0 2px 10px rgba(17, 12, 46, 0.08);
  border: 1px solid var(--border);
}
.inline-row { display: flex; gap: 8px; align-items: center; }
.mt6 { margin-top: 6px; }
.inline-input {
  flex: 1;
  min-width: 0;
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.inline-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.inline-input::placeholder { color: var(--text-meta); }
.inline-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 10px 16px;
  border-radius: 11px;
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: filter .15s, transform .05s;
}
.inline-btn.primary { background: linear-gradient(135deg, var(--bg-own-1), var(--bg-own-2), var(--bg-own-3)); }
.inline-btn.danger { background: #d13b4d; }
.inline-btn.ghost { background: var(--bg-input); color: var(--text); }
.inline-btn:hover { filter: brightness(1.1); }
.inline-btn:active { transform: scale(.98); }
.format-btn {
  background: var(--bg-input);
  color: var(--text-dim);
  border: 1px solid var(--border-strong);
  padding: 8px 13px;
  border-radius: 10px;
  font-size: 13px;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.format-btn.active { background: var(--accent-soft); color: #c2185b; border-color: var(--accent); }

/* Tarjeta de la pieza generada (revisión y aprobación) */
.creative-card {
  flex-shrink: 0;
  max-width: 420px;
  align-self: flex-start;
  width: 92%;
  background: #ffffff;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow);
  margin-top: 4px;
}
.creative-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 14px;
  background: rgba(0,0,0,0.02);
  border-bottom: 1px solid var(--border);
}
.creative-badge {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: #c2185b;
  background: var(--accent-soft);
  padding: 4px 10px;
  border-radius: 7px;
}
.creative-code { font-family: ui-monospace, monospace; font-size: 12.5px; color: var(--text-meta); }
/* La imagen se muestra COMPLETA (sin recortar): ancho 100% y alto según su
   proporción. Si queda más alta que la pantalla, el contenedor del chat hace
   scroll para verla entera y el scroll de la pieza. */
.creative-img { width: 100%; height: auto; object-fit: contain; display: block; background: #f7f7f9; }
.creative-null { width: 100%; height: 200px; display: flex; align-items: center; justify-content: center; color: var(--text-dim); background: var(--bg-input); }
/* Editor: imagen actual + corrección (también completa, sin recorte) */
.edit-box { display: flex; flex-direction: column; gap: 9px; }
.edit-preview {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  background: #f7f7f9;
  overflow: hidden;
}
.edit-preview img { width: 100%; height: auto; display: block; object-fit: contain; }

/* Estado "Regenerando": reemplaza input + botones mientras se genera */
.edit-loading {
  display: flex;
  align-items: center;
  gap: 11px;
  color: var(--text-dim);
  font-size: 13.5px;
  line-height: 1.4;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--bg-input);
}
.spinner {
  width: 18px; height: 18px;
  border: 2px solid rgba(214, 41, 118, 0.25);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }
.creative-body { padding: 13px 15px; }
.creative-caption { font-size: 13.5px; line-height: 1.55; color: var(--text); white-space: normal; }
.creative-cta { display: flex; flex-direction: column; gap: 5px; margin-top: 10px; font-size: 12.5px; color: var(--text-dim); }
.creative-cta a { color: var(--accent-strong); }
.creative-reject { margin-top: 8px; font-size: 12.5px; color: var(--err); background: rgba(224,36,94,0.08); padding: 8px 11px; border-radius: 9px; }
.creative-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.act-btn {
  border: none;
  padding: 10px 14px;
  border-radius: 11px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  color: #fff;
  transition: filter .15s, transform .05s;
}
.act-btn.submit { background: linear-gradient(135deg, var(--bg-own-1), var(--bg-own-2), var(--bg-own-3)); }
.act-btn.ok { background: #149e63; }
.act-btn.danger { background: #d13b4d; }
.act-btn.share { background: linear-gradient(135deg, #d62976, #962fbf, #4f5bd5); }
.act-btn.ghost { background: var(--bg-input); color: var(--text); border: 1px solid var(--border-strong); }
.act-btn:hover { filter: brightness(1.1); }
.act-btn:active { transform: scale(.98); }
.permalink { color: var(--accent-strong); font-weight: 700; font-size: 13.5px; text-decoration: none; }
.permalink:hover { text-decoration: underline; }

/* Fijar el texto de la burbuja para que las opciones queden debajo del texto */
.msg-text { display: block; white-space: normal; }

/* Formulario de la pieza (paso 1 del wizard) — campos apilados */
.promo-form {
  width: 82%;
  max-width: 440px;
}
.promo-form .inline-row {
  margin-bottom: 6px;
}
.promo-form .inline-input {
  font-size: 13.5px;
  padding: 9px 12px;
}
.promo-form .inline-btn {
  width: 100%;
  justify-content: center;
}

/* Campo IMAGEN del formulario de la pieza (adjuntar / pegar) */
.promo-form .inline-btn.ghost {
  background: var(--bg-input);
  color: var(--text);
  border: 1px dashed var(--border-strong);
}
.promo-form .inline-btn.ghost:hover { border-color: var(--accent); color: var(--accent); }
.pf-img-hint { font-size: 11px; color: var(--text-dim); line-height: 1.2; }
.promo-form .inline-btn.ghost { flex: 1; justify-content: center; }

.pf-img-preview {
  position: relative;
  border-radius: 11px;
  overflow: hidden;
  border: 1px solid var(--border-strong);
}
.pf-img-preview img {
  display: block;
  width: 100%;
  max-height: 160px;
  object-fit: cover;
}
.pf-img-remove {
  position: absolute;
  top: 7px;
  right: 7px;
  background: rgba(0,0,0,0.6);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
}
.hidden { display: none !important; }

/* ============ Botones de adjuntar / sacar foto ============ */
.composer-row .attach-btn { color: var(--text-dim); }
.composer-row .attach-btn:hover { color: var(--accent); }
.promo-form .inline-row .pf-img-hint { min-width: 0; flex-shrink: 1; }

/* ============ Modal de configuración / uso ============ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(20, 12, 32, 0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  z-index: 40;
}
.modal-card {
  background: #fff;
  color: #0d0d0d;
  width: 100%;
  max-width: 420px;
  border-radius: 20px;
  box-shadow: 0 30px 70px rgba(17, 12, 46, 0.28);
  overflow: hidden;
  border: 1px solid var(--border);
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  background: #fff;
}
.modal-head h2 { font-size: 18px; font-weight: 800; }
.modal-close {
  background: var(--bg-input); border: none; color: var(--text-dim);
  width: 32px; height: 32px; border-radius: 50%;
  font-size: 14px; cursor: pointer;
  transition: background .15s, color .15s;
}
.modal-close:hover { background: rgba(214, 41, 118, 0.14); color: var(--accent); }
.modal-body { padding: 18px; max-height: 62vh; overflow-y: auto; }
.modal-loading, .modal-error { color: var(--text-dim); font-size: 14px; }
.modal-error { color: var(--err); }

.settings-plan {
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 16px;
  border: 1px solid var(--border);
}
.settings-plan.paid { background: rgba(35, 183, 121, 0.08); border-color: rgba(35, 183, 121, 0.3); }
.settings-plan.unpaid { background: rgba(224, 36, 94, 0.07); border-color: rgba(224, 36, 94, 0.3); }
.settings-plan.trial { background: rgba(77, 91, 213, 0.08); border-color: rgba(77, 91, 213, 0.3); }
.settings-plan.test { background: var(--accent-soft); border-color: rgba(214, 41, 118, 0.3); }
.plan-title { font-size: 16px; font-weight: 800; margin-bottom: 4px; }
.plan-sub { font-size: 13px; color: var(--text-dim); margin-bottom: 10px; }
.usage-row {
  display: flex; justify-content: space-between;
  font-size: 14px; font-weight: 600; margin-bottom: 8px;
}
.bar {
  height: 10px; border-radius: 6px;
  background: rgba(0, 0, 0, 0.08);
  overflow: hidden; margin-bottom: 6px;
}
.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #d62976, #962fbf, #4f5bd5);
  border-radius: 6px;
  transition: width .3s ease;
}
.bar-label { font-size: 12px; color: var(--text-dim); }
.pay-block { text-align: center; }
.pay-btn {
  width: 100%;
  display: block;
  margin-top: 4px;
  background: linear-gradient(135deg, #d62976, #962fbf, #4f5bd5);
  box-shadow: 0 8px 22px rgba(214, 41, 118, 0.3);
}
.pay-btn:hover { box-shadow: 0 10px 28px rgba(214, 41, 118, 0.4); }
.pay-note { margin-top: 10px; font-size: 12.5px; color: var(--text-dim); }

/* Galería de últimas imágenes (en Configuración) */
.settings-gal {
  margin-top: 18px;
  border-top: 1px solid var(--border);
  padding-top: 14px;
}
.gal-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 14px; font-weight: 800; margin-bottom: 12px;
}
.gal-title svg { width: 17px; height: 17px; }
.images-gal {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.gal-thumb {
  position: relative;
  display: block;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  aspect-ratio: 4 / 5;
  background: var(--bg-input);
}
.gal-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gal-thumb:hover img { opacity: .9; }
.gal-empty { font-size: 13px; color: var(--text-dim); grid-column: 1 / -1; }


/* ==========================================================================
 *  WIZARD (pantalla completa) — reemplaza al chat
 * ========================================================================== */
.app { height: 100%; }
.wizard {
  height: 100%;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(1100px 600px at 90% -20%, rgba(214, 41, 118, 0.05), transparent 60%),
    radial-gradient(1000px 500px at -10% 110%, rgba(150, 47, 191, 0.05), transparent 60%),
    #fff;
}
.wizard-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 18px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  min-width: 0;
}
.wizard-brand { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.wizard-subtitle { font-size: 12px; color: var(--text-dim); }
.wizard-steps {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  padding: 0 6px;
}
.wz-step {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 700; color: var(--text-meta);
  white-space: nowrap; padding: 4px 8px; border-radius: 8px;
}
.wz-step i {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--bg-input); color: var(--text-meta); font-style: normal; font-size: 11px;
}
.wz-step.active { color: #c2185b; }
.wz-step.active i { background: var(--accent-soft); color: #c2185b; }
.wz-step.done { color: var(--text-dim); }
.wz-step.done i { background: #17a05e; color: #fff; }

.wizard-body {
  flex: 1;
  overflow-y: auto;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 26px 20px 40px;
}
.wizard-body::-webkit-scrollbar { width: 8px; }
.wizard-body::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.14); border-radius: 10px; }

.wz-card {
  width: 100%;
  max-width: 560px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: 0 10px 30px rgba(17, 12, 46, 0.06);
  padding: 26px 28px;
  animation: msg-in 0.18s ease;
}
.wz-card h2 { font-size: 22px; font-weight: 800; margin-bottom: 6px; }
.wz-hint { font-size: 13.5px; color: var(--text-dim); margin-bottom: 18px; }
.wz-sub { font-size: 14px; margin-bottom: 16px; }
.wz-muted { color: var(--text-meta); font-size: 12.5px; }

.wz-imgbox { display: flex; flex-direction: column; gap: 12px; margin-bottom: 6px; }
.wz-img {
  position: relative;
  width: 100%;
  border-radius: 16px;
  overflow: hidden;
  border: 1px dashed var(--border-strong);
  background: #fafafc;
}
.wz-img img { width: 100%; height: auto; display: block; object-fit: contain; max-height: 340px; }
.wz-img.empty { height: 150px; display: flex; align-items: center; justify-content: center; }
.wz-img-ph { color: var(--text-meta); font-size: 15px; }
.wz-img-remove {
  position: absolute; top: 10px; right: 10px;
  background: rgba(0,0,0,0.6); color: #fff; border: none; border-radius: 8px;
  padding: 5px 11px; font-size: 12px; cursor: pointer;
}
.wz-img-actions { display: flex; gap: 10px; }
.wz-or { text-align: center; color: var(--text-meta); font-size: 13px; margin: 8px 0; }
.wz-or span { padding: 0 8px; }
.wz-label { display: block; font-size: 12.5px; font-weight: 700; color: var(--text-dim); margin-bottom: 6px; }
.wz-field { margin-bottom: 12px; }
.wz-field label { display: block; font-size: 12.5px; font-weight: 700; color: var(--text-dim); margin-bottom: 6px; }

.wz-input {
  width: 100%;
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 15px;
  font-family: inherit;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
textarea.wz-input { resize: vertical; }
.wz-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.wz-input::placeholder { color: var(--text-meta); }

.wz-group { margin-bottom: 16px; }
.wz-group-title {
  display: block; font-size: 12.5px; font-weight: 700; color: var(--text-dim);
  margin-bottom: 8px; text-transform: uppercase; letter-spacing: .04em;
}
.wz-choices { display: flex; flex-wrap: wrap; gap: 8px; }
.wz-choice {
  background: var(--bg-input);
  color: var(--text-dim);
  border: 1px solid var(--border-strong);
  padding: 10px 16px;
  border-radius: 12px;
  font-size: 14px; font-weight: 600;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.wz-choice:hover { border-color: var(--accent); color: var(--accent); }
.wz-choice.active { background: var(--accent-soft); color: #c2185b; border-color: var(--accent); }

.wz-nav { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 20px; }
.wz-btn {
  border: none;
  padding: 12px 22px;
  border-radius: 13px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: filter .15s, transform .06s;
}
.wz-btn.primary { background: linear-gradient(135deg, #d62976, #962fbf, #4f5bd5); color: #fff; box-shadow: 0 8px 20px rgba(214, 41, 118, 0.3); }
.wz-btn.primary:hover { filter: brightness(1.08); }
.wz-btn.ghost { background: var(--bg-input); color: var(--text); border: 1px solid var(--border-strong); }
.wz-btn.ghost:hover { border-color: var(--accent); color: var(--accent); }
.wz-btn:active { transform: scale(.98); }
.wz-btn:disabled { opacity: .6; cursor: not-allowed; transform: none; }
.wz-err { margin-top: 12px; color: var(--err); font-size: 14px; font-weight: 600; }

.wz-avanzado { margin: 16px 0 4px; }
.wz-avanzado .wz-btn.ghost { width: 100%; }
.wz-prompt {
  margin-top: 10px;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: #fafafc;
  padding: 12px 14px;
}
.wz-prompt-title {
  display: block; font-size: 12px; font-weight: 700; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: .04em; margin-bottom: 8px;
}
.wz-prompt pre {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px; line-height: 1.55; white-space: pre-wrap; word-break: break-word;
  color: var(--text-dim);
}

.wz-loading { text-align: center; padding: 60px 20px; }
.spinner.big { width: 44px; height: 44px; border-width: 3px; margin: 0 auto 18px; }

/* Resultado */
.wz-card.result { max-width: 460px; }
.wz-result-imgwrap { border-radius: 16px; overflow: hidden; border: 1px solid var(--border-strong); background: #f7f7f9; }
.wz-result-img { width: 100%; height: auto; display: block; object-fit: contain; }
.wz-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.wz-card.edit { max-width: 460px; }

/* Barra "Generar Ya!" (pasos 1-4) */
.generate-now {
  border-top: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
}
.generate-now.hidden { display: none; }
.generate-now-btn { width: 100%; }
.generate-now-err { color: var(--err); font-size: 12.5px; text-align: center; margin-top: 8px; }

/* Iconos vectoriales: alineación y tamaño dentro de botones/textos */
.wz-btn, .act-btn, .btn-primary, .btn-ghost, .pay-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.wz-btn svg, .act-btn svg, .btn-primary svg, .btn-ghost svg, .pay-btn svg { flex-shrink: 0; }
.wz-img-ph { display: inline-flex; align-items: center; gap: 8px; }
.wz-img-ph svg { font-size: 20px; }
.wz-img-remove svg { width: 13px; height: 13px; }
.wz-img-remove { display: inline-flex; align-items: center; justify-content: center; }
.usage-row b svg { width: 15px; height: 15px; vertical-align: -2px; }
.plan-title svg { width: 16px; height: 16px; vertical-align: -3px; }
.wz-result-imgwrap .creative-null { color: var(--text-dim); }

/* ============ Respuesta adaptativa ============ */
@media (max-width: 760px) {
  .messages { padding: 14px 12px; gap: 8px; }
  .msg { max-width: 84%; font-size: 14.5px; }
  .msg img { max-width: 210px; }
  .msg-inline-form, .promo-form { width: 92%; max-width: none; }
  .creative-card { max-width: none; width: 98%; }
  .composer { padding: 8px 10px 14px; }
  .login-card { padding: 32px 24px; }
  .wizard-header { flex-wrap: wrap; gap: 10px; padding: 10px 12px; }
  .wizard-brand .wizard-subtitle { display: none; }
  .header-actions .user-chip span { display: none; }
  .wizard-steps { order: 3; width: 100%; }
  .wz-step { font-size: 11px; padding: 4px 6px; gap: 4px; }
  .wz-step b { display: none; }
  .wizard-body { padding: 16px 12px 30px; }
  .wz-card { padding: 20px 18px; border-radius: 16px; }
  .wz-choices { gap: 6px; }
  .wz-choice { padding: 9px 13px; font-size: 13px; }
  .wz-nav { flex-wrap: wrap; }
  .wz-actions { gap: 7px; }
  .wz-actions .act-btn { flex: 1 1 100%; justify-content: center; }
}

