/* ==========================================================================
 *  asIGstant — sistema visual
 *
 *  La paleta sale del isologo: el teal del anillo del obturador, el azul
 *  hielo de su fondo y el amarillo de la bombilla. El gradiente de Instagram
 *  queda RESERVADO para las dos acciones que tocan Instagram —generar la
 *  pieza y compartirla— y para el "IG" del nombre. Si aparece en cualquier
 *  otro lado deja de significar algo.
 * ========================================================================== */

:root {
  /* Tomados del isologo */
  --ink:       #0F2A33;   /* contorno del obturador: texto y superficie oscura */
  --ink-soft:  #1B4451;
  --lens:      #157A8C;   /* anillo del obturador: estructura y estado activo */
  --lens-deep: #0E5F6E;
  --lens-tint: #E3F0F3;
  --haze:      #DCE8EE;   /* fondo original del asset */
  --bulb:      #F5B301;   /* bombilla */
  --leaf:      #4E9E56;   /* hoja verde del diafragma: paso cumplido */

  /* Instagram — solo generar, compartir y el "IG" del nombre */
  --ig-1: #FA7E1E;
  --ig-2: #D62976;
  --ig-3: #962FBF;
  --ig-4: #4F5BD5;
  --ig: linear-gradient(118deg, var(--ig-1), var(--ig-2) 42%, var(--ig-3) 72%, var(--ig-4));
  /* Variante legible: mismo arco de color, sin el naranja que no aguanta
     texto blanco encima. */
  --ig-btn: linear-gradient(118deg, #C1265F, #A02A96 38%, #7B3FB8 70%, #4A54C9);

  --surface:   #ffffff;
  --paper:     #F4F8F9;
  --text:      #0F2A33;
  --text-dim:  #47646E;
  --text-mute: #5C7580;
  --line:      #D8E4E9;
  --line-firm: #79929C;
  --err:       #C22E3A;

  --r-card: 20px;
  --r-ctl: 11px;
  --shadow-card: 0 1px 2px rgba(15, 42, 51, .05), 0 14px 32px -14px rgba(15, 42, 51, .22);
  --shadow-pop: 0 24px 60px -18px rgba(15, 42, 51, .45);

  --font-display: 'Bricolage Grotesque', 'Instrument Sans', system-ui, sans-serif;
  --font-ui: 'Instrument Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

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

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

.hidden { display: none !important; }

:focus-visible {
  outline: 2px solid var(--lens);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ============ Marca ============ */
.wordmark {
  font-family: var(--font-display);
  font-weight: 800;
  letter-spacing: -.035em;
  color: var(--text);
  line-height: 1;
}
/* El "IG" del nombre es el de Instagram: se pinta con su gradiente. */
.wordmark em {
  font-style: normal;
  color: var(--ig-2);
  background: var(--ig);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* ============ Login ============ */
.login-screen {
  height: 100%;
  overflow-y: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(24px + env(safe-area-inset-top, 0px)) 24px calc(24px + env(safe-area-inset-bottom, 0px));
  background:
    radial-gradient(760px 420px at 50% -8%, #ffffff, transparent 70%),
    var(--haze);
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 40px 38px 34px;
  border-radius: 26px;
  text-align: center;
  max-width: 400px;
  width: 100%;
  box-shadow: var(--shadow-card);
}
.login-mark {
  width: 132px;
  height: auto;
  display: block;
  margin: 0 auto 20px;
}
.login-card .wordmark { font-size: 34px; margin-bottom: 10px; }
.login-lede {
  color: var(--text-dim);
  font-size: 15px;
  line-height: 1.5;
  margin-bottom: 26px;
  text-wrap: balance;
}
.login-msg { margin-top: 14px; color: var(--err); font-size: 13.5px; min-height: 1em; }

/* Los tres pasos del flujo: acá el número sí ordena, es una secuencia real. */
.login-flow {
  list-style: none;
  margin-top: 28px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 11px;
  text-align: left;
}
.login-flow li {
  display: flex;
  align-items: center;
  gap: 11px;
  font-size: 13.5px;
  color: var(--text-dim);
}
.login-flow i {
  flex-shrink: 0;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--lens-tint);
  color: var(--lens-deep);
  font-style: normal;
  font-size: 11.5px;
  font-weight: 700;
  display: grid;
  place-items: center;
}

/* ============ Estructura de la app ============ */
.app { display: flex; height: 100%; }

/* Columna de navegación: en escritorio es una barra lateral oscura, en
   teléfono se pliega en un encabezado con los pasos debajo. */
.rail {
  width: 258px;
  flex-shrink: 0;
  background: var(--ink);
  color: #fff;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: calc(20px + env(safe-area-inset-top, 0px)) 16px calc(18px + env(safe-area-inset-bottom, 0px));
}
.rail-brand {
  order: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 18px;
}
.rail-mark { width: 58px; height: auto; }
.rail .wordmark { font-size: 21px; color: #fff; }

.rail-steps {
  order: 2;
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1 1 auto;
  min-height: 0;
}
.wz-step {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 10px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 500;
  color: rgba(255, 255, 255, .52);
  white-space: nowrap;
  transition: color .15s, background .15s;
}
.wz-step i {
  flex-shrink: 0;
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, .22);
  font-style: normal;
  font-size: 11px;
  font-weight: 700;
  display: grid;
  place-items: center;
  transition: background .15s, border-color .15s, color .15s;
}
.wz-step i svg { width: 12px; height: 12px; }
.wz-step.active { background: rgba(255, 255, 255, .09); color: #fff; font-weight: 600; }
.wz-step.active i { background: var(--lens); border-color: var(--lens); color: #fff; }
.wz-step.done { color: rgba(255, 255, 255, .74); }
.wz-step.done i { background: var(--leaf); border-color: var(--leaf); color: #fff; }

.user-chip {
  order: 3;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 10px;
  border-top: 1px solid rgba(255, 255, 255, .1);
  font-size: 13px;
  color: rgba(255, 255, 255, .7);
  min-width: 0;
}
.user-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar-img {
  width: 30px; height: 30px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--ink-soft);
  border: 1px solid rgba(255, 255, 255, .16);
}

.rail-actions { order: 4; display: flex; gap: 6px; padding-top: 4px; }
.btn-ghost {
  background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(255, 255, 255, .12);
  color: rgba(255, 255, 255, .78);
  cursor: pointer;
  padding: 9px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, color .15s, border-color .15s;
}
.btn-ghost:hover { background: rgba(255, 255, 255, .13); color: #fff; border-color: rgba(255, 255, 255, .26); }

/* Área de trabajo */
.stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--haze);
}
.wizard-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 24px 44px;
}
.wizard-body::-webkit-scrollbar { width: 10px; }
.wizard-body::-webkit-scrollbar-thumb { background: var(--line-firm); border-radius: 10px; border: 3px solid var(--haze); }

/* ============ Tarjeta de paso ============ */
.wz-card {
  width: 100%;
  max-width: 560px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-card);
  padding: 30px 32px 28px;
  animation: card-in .2s ease;
}
@keyframes card-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.wz-card h2 {
  font-family: var(--font-display);
  font-size: 27px;
  font-weight: 700;
  letter-spacing: -.03em;
  line-height: 1.15;
  margin-bottom: 7px;
}
.wz-hint { font-size: 14px; line-height: 1.5; color: var(--text-dim); margin-bottom: 22px; }
.wz-sub { font-size: 14.5px; line-height: 1.55; margin-bottom: 18px; }
.wz-muted { color: var(--text-mute); font-size: 13px; }

/* ============ Controles ============ */
.wz-label,
.wz-field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 6px;
}
.wz-field { margin-bottom: 14px; }

.wz-input {
  width: 100%;
  background: var(--paper);
  color: var(--text);
  border: 1px solid var(--line-firm);
  border-radius: var(--r-ctl);
  padding: 12px 14px;
  font-size: 15px;
  font-family: inherit;
  outline: none;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
textarea.wz-input { resize: vertical; line-height: 1.5; }
.wz-input:focus {
  background: var(--surface);
  border-color: var(--lens);
  box-shadow: 0 0 0 3px rgba(21, 122, 140, .16);
}
.wz-input::placeholder { color: var(--text-mute); }

.wz-group { margin-bottom: 18px; }
.wz-group-title {
  display: block;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-mute);
  margin-bottom: 9px;
  text-transform: uppercase;
  letter-spacing: .07em;
}
.wz-choices { display: flex; flex-wrap: wrap; gap: 8px; }
.wz-choice {
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: left;
  background: var(--surface);
  color: var(--text-dim);
  border: 1px solid var(--line-firm);
  padding: 9px 15px;
  border-radius: var(--r-ctl);
  font-family: inherit;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.wz-choice span { font-size: 14px; font-weight: 600; }
.wz-choice small { font-size: 11.5px; color: var(--text-mute); line-height: 1.3; }
.wz-choice.active small { color: var(--lens-deep); }
.wz-choice:hover { border-color: var(--lens); color: var(--lens-deep); }
.wz-choice.active {
  background: var(--lens-tint);
  color: var(--lens-deep);
  border-color: var(--lens);
  box-shadow: inset 0 0 0 1px var(--lens);
}

/* ============ Botones ============ */
.wz-btn, .act-btn, .btn-primary, .pay-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: filter .15s, transform .06s, background .15s, border-color .15s, color .15s;
}
.wz-btn svg, .act-btn svg, .btn-primary svg, .pay-btn svg { flex-shrink: 0; }
.wz-btn:active, .act-btn:active, .btn-primary:active, .pay-btn:active { transform: scale(.985); }
.wz-btn:disabled, .act-btn:disabled, .btn-primary:disabled { opacity: .55; cursor: not-allowed; transform: none; }

.wz-btn {
  padding: 12px 20px;
  border-radius: var(--r-ctl);
  font-size: 14.5px;
}
/* Navegar entre pasos: sobrio, es el camino y no el destino. */
.wz-btn.primary { background: var(--ink); color: #fff; }
.wz-btn.primary:hover { background: var(--ink-soft); }
.wz-btn.ghost {
  background: var(--surface);
  color: var(--text-dim);
  border: 1px solid var(--line-firm);
}
.wz-btn.ghost:hover { border-color: var(--lens); color: var(--lens-deep); }

/* Instagram: generar y compartir. Único lugar donde vive el gradiente. */
.wz-btn.ig, .act-btn.share {
  background: var(--ig-btn);
  color: #fff;
  box-shadow: 0 8px 20px -8px rgba(214, 41, 118, .6);
}
.wz-btn.ig:hover, .act-btn.share:hover { filter: brightness(1.07); }

/* Entrar y pagar no son acciones de Instagram: van en el teal de la marca. */
.btn-primary, .pay-btn {
  background: var(--lens-deep);
  color: #fff;
  box-shadow: 0 8px 20px -10px rgba(15, 42, 51, .55);
}
.btn-primary:hover, .pay-btn:hover { background: var(--lens); }

.btn-primary {
  padding: 14px 30px;
  border-radius: 13px;
  font-size: 15.5px;
  font-weight: 700;
  width: 100%;
}

.wz-nav { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 24px; }
.wz-err { margin-top: 12px; color: var(--err); font-size: 13.5px; font-weight: 600; }

/* ============ Paso 1: foto o URL ============ */
.wz-imgbox { display: flex; flex-direction: column; gap: 12px; }
.wz-img {
  position: relative;
  width: 100%;
  border-radius: 16px;
  overflow: hidden;
  border: 1px dashed var(--line-firm);
  background: var(--paper);
}
.wz-img img { width: 100%; height: auto; display: block; object-fit: contain; max-height: 340px; }
.wz-img.empty { height: 148px; display: flex; align-items: center; justify-content: center; }
.wz-img-ph {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--text-mute);
  font-size: 14.5px;
}
.wz-img-ph svg { width: 20px; height: 20px; }
.wz-img-remove {
  position: absolute; top: 10px; right: 10px;
  background: rgba(15, 42, 51, .72);
  color: #fff;
  border: none;
  border-radius: 9px;
  padding: 6px 9px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
}
.wz-img-remove svg { width: 13px; height: 13px; }
.wz-img-actions { display: flex; gap: 9px; }
.wz-img-actions .wz-btn { flex: 1; }

/* Varias fotos = collage. Una sola ocupa todo el ancho; de dos en adelante
   van en grilla para que se vean como lo que serán en la pieza. */
.wz-fotos {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
.wz-fotos.una { grid-template-columns: 1fr; }
.wz-foto {
  position: relative;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--paper);
  aspect-ratio: 4 / 5;
}
.wz-fotos.una .wz-foto { aspect-ratio: auto; max-height: 340px; }
.wz-foto img { width: 100%; height: 100%; display: block; object-fit: cover; }
.wz-fotos.una .wz-foto img { object-fit: contain; max-height: 340px; }
.wz-foto .wz-img-remove { top: 7px; right: 7px; padding: 5px 7px; border-radius: 8px; }
.wz-foto-n {
  position: absolute;
  left: 7px; bottom: 7px;
  min-width: 20px;
  padding: 1px 6px;
  border-radius: 20px;
  background: rgba(15, 42, 51, .72);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  text-align: center;
}
.wz-fotos-nota { margin: 0; font-size: 12.5px; color: var(--text-mute); }

.wz-or {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0 14px;
}
.wz-or::before, .wz-or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.wz-or span {
  padding: 4px 12px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
  color: var(--text-mute);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
}

/* ============ Paso 2: notas de voz ============ */
.wz-voz {
  margin-top: 16px;
  padding: 14px 15px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--paper);
}
.wz-voz-head { margin-bottom: 10px; }
.wz-voz-head .wz-group-title { display: flex; align-items: center; gap: 7px; margin-bottom: 3px; }
.wz-voz-head .wz-group-title svg { width: 14px; height: 14px; }
.wz-voz-head small { display: block; font-size: 12.5px; line-height: 1.45; color: var(--text-mute); }
.wz-audios { display: flex; flex-direction: column; gap: 8px; }
.wz-audios:not(:empty) { margin-bottom: 11px; }
.wz-audio {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}
.wz-audio audio { flex: 1; min-width: 0; height: 34px; }
.wz-audio-n {
  flex-shrink: 0;
  width: 21px; height: 21px;
  border-radius: 50%;
  background: var(--lens-tint);
  color: var(--lens-deep);
  font-size: 11.5px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.wz-audio-dur { flex-shrink: 0; font-size: 12px; color: var(--text-mute); font-variant-numeric: tabular-nums; }
.wz-audio-del {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--text-mute);
  cursor: pointer;
  padding: 5px;
  display: inline-flex;
  border-radius: 8px;
}
.wz-audio-del:hover { color: var(--err); background: rgba(194, 46, 58, .08); }
.wz-audio-del svg { width: 16px; height: 16px; }
.wz-voz-actions { display: flex; gap: 9px; }
.wz-voz-actions .wz-btn { flex: 1; }
/* Grabando: el botón se pone rojo y late, para que se note de un vistazo. */
.wz-btn.ghost.rec {
  border-color: var(--err);
  color: var(--err);
  animation: recPulse 1.4s ease-in-out infinite;
}
@keyframes recPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(194, 46, 58, .28); }
  50% { box-shadow: 0 0 0 6px rgba(194, 46, 58, 0); }
}
@media (prefers-reduced-motion: reduce) { .wz-btn.ghost.rec { animation: none; } }
.wz-voz .wz-muted, .wz-voz .wz-err { margin: 9px 0 0; min-height: 1em; }

/* ============ Paso 5: avanzado ============ */
.wz-avanzado { margin: 18px 0 4px; }
.wz-avanzado .wz-btn.ghost { width: 100%; }
.wz-prompt {
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--paper);
  padding: 13px 15px;
}
.wz-prompt-title {
  display: block;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-mute);
  text-transform: uppercase;
  letter-spacing: .07em;
  margin-bottom: 8px;
}
.wz-prompt pre {
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text-dim);
}

/* ==========================================================================
 *  Generando: el diafragma del obturador abriéndose. Es el momento largo de
 *  la app —la espera— y el único lugar donde el logo se mueve.
 * ========================================================================== */
.wz-loading { text-align: center; padding: 44px 20px; }
.gen-figure {
  position: relative;
  width: 208px;
  height: 208px;
  margin: 0 auto 28px;
}
.gen-iris {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform-origin: 50% 50%;
  animation: iris 3.4s cubic-bezier(.45, 0, .25, 1) infinite;
  filter: drop-shadow(0 14px 26px rgba(15, 42, 51, .22));
  opacity: .92;
}
@keyframes iris {
  0%, 100% { transform: rotate(0deg) scale(.9); }
  50%      { transform: rotate(21deg) scale(1); }
}
.gen-bot {
  position: absolute;
  bottom: -14px;
  left: 50%;
  width: 152px;
  transform: translateX(-50%);
  animation: bot-bob 3.4s ease-in-out infinite;
  filter: drop-shadow(0 8px 14px rgba(15, 42, 51, .3));
}
@keyframes bot-bob {
  0%, 100% { transform: translate(-50%, 0); }
  50%      { transform: translate(-50%, -7px); }
}
.wz-loading h2 {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -.025em;
  margin-bottom: 8px;
}
.wz-loading p { color: var(--text-dim); font-size: 14px; }

.spinner {
  width: 18px; height: 18px;
  border: 2px solid rgba(21, 122, 140, .22);
  border-top-color: var(--lens);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============ Resultado ============ */
.wz-card.result, .wz-card.edit { max-width: 470px; }
.wz-result-imgwrap {
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--line-firm);
  background: var(--paper);
}
.wz-result-img {
  width: 100%;
  display: block;
  padding: 0;
  border: none;
  background: none;
  cursor: zoom-in;
  font: inherit;
}
.wz-result-img img { width: 100%; height: auto; display: block; object-fit: contain; }
.creative-null {
  width: 100%;
  height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-mute);
  background: var(--paper);
}
.wz-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.act-btn {
  padding: 11px 16px;
  border-radius: var(--r-ctl);
  font-size: 14px;
  color: #fff;
}
.act-btn.share { flex: 1 1 100%; }
.act-btn.submit { background: var(--ink); }
.act-btn.submit:hover { background: var(--ink-soft); }
.act-btn.ghost {
  background: var(--surface);
  color: var(--text-dim);
  border: 1px solid var(--line-firm);
  flex: 1;
}
.act-btn.ghost:hover { border-color: var(--lens); color: var(--lens-deep); }

/* ============ Barra "Generar ya" ============ */
.generate-now {
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, .86);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 13px 24px calc(13px + env(safe-area-inset-bottom, 0px));
}
.generate-now-btn { width: 100%; max-width: 560px; margin: 0 auto; display: flex; }
.generate-now-err { color: var(--err); font-size: 12.5px; text-align: center; margin-top: 8px; }

/* ============ Modal de configuración ============ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 42, 51, .58);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 40;
}
.modal-card {
  background: var(--surface);
  width: 100%;
  max-width: 430px;
  border-radius: 22px;
  box-shadow: var(--shadow-pop);
  overflow: hidden;
  border: 1px solid var(--line);
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}
.modal-head h2 {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -.02em;
}
.modal-close {
  background: var(--paper);
  border: 1px solid var(--line);
  color: var(--text-dim);
  width: 32px; height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, color .15s, border-color .15s;
}
.modal-close:hover { background: var(--lens-tint); color: var(--lens-deep); border-color: var(--lens); }
.modal-body { padding: 20px; max-height: 64vh; overflow-y: auto; }
.modal-loading, .modal-error { color: var(--text-dim); font-size: 14px; }
.modal-error { color: var(--err); }

.settings-plan {
  border-radius: 15px;
  padding: 15px 17px;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  background: var(--paper);
}
.settings-plan.paid { background: rgba(78, 158, 86, .09); border-color: rgba(78, 158, 86, .32); }
.settings-plan.unpaid { background: rgba(194, 46, 58, .06); border-color: rgba(194, 46, 58, .26); }
.settings-plan.test { background: var(--lens-tint); border-color: rgba(21, 122, 140, .32); }
.settings-plan.trial { background: rgba(245, 179, 1, .12); border-color: rgba(245, 179, 1, .45); }
.plan-title {
  display: flex;
  align-items: center;
  gap: 7px;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -.015em;
  margin-bottom: 5px;
}
.plan-title svg { width: 16px; height: 16px; }
.plan-sub { font-size: 13px; line-height: 1.5; color: var(--text-dim); margin-bottom: 12px; }
.usage-row {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
}
.usage-row b { display: inline-flex; align-items: center; gap: 5px; }
.usage-row b svg { width: 15px; height: 15px; }
.bar {
  height: 8px;
  border-radius: 5px;
  background: rgba(15, 42, 51, .1);
  overflow: hidden;
  margin-bottom: 7px;
}
.bar-fill {
  height: 100%;
  background: var(--lens);
  border-radius: 5px;
  transition: width .3s ease;
}
.bar-label { font-size: 12.5px; color: var(--text-dim); }
.pay-block { text-align: center; }
.pay-btn {
  width: 100%;
  padding: 13px 20px;
  border-radius: 13px;
  font-size: 14.5px;
  font-weight: 700;
}
.pay-note { margin-top: 10px; font-size: 12.5px; color: var(--text-dim); }

/* Selector de modelo de imagen (Gemini / OpenAI) en Configuración */
.settings-prov { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 14px; }
.settings-prov .wz-choices { align-items: stretch; }
.settings-prov .wz-choice { flex: 1; justify-content: center; text-align: center; }
.settings-prov .wz-choice.disabled { opacity: .45; cursor: not-allowed; }
.prov-note { margin-top: 8px; font-size: 11.5px; color: var(--text-dim); }

/* Atajo al historial desde Configuración */
.settings-gal { margin-top: 20px; border-top: 1px solid var(--line); padding-top: 16px; }
.settings-gal .wz-btn { width: 100%; }
.gal-thumb {
  position: relative;
  display: block;
  border-radius: 11px;
  overflow: hidden;
  border: 1px solid var(--line);
  aspect-ratio: 4 / 5;
  background: var(--paper);
  transition: border-color .15s;
}
.gal-thumb:hover { border-color: var(--lens); }
.gal-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gal-empty { font-size: 13px; color: var(--text-dim); grid-column: 1 / -1; }

/* ==========================================================================
 *  Teléfono: la barra lateral se pliega en encabezado y los pasos pasan
 *  a una fila desplazable debajo.
 * ========================================================================== */
@media (max-width: 900px) {
  .app { flex-direction: column; }
  .rail {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    padding: calc(10px + env(safe-area-inset-top, 0px)) 14px 8px;
  }
  .rail-brand { order: 1; flex: 1; padding: 0; gap: 9px; }
  .rail-mark { width: 32px; }
  .rail .wordmark { font-size: 17px; }
  .rail-actions { order: 2; padding: 0; }
  .user-chip {
    order: 3;
    border-top: none;
    padding: 0 4px 0 0;
    gap: 0;
  }
  .user-chip span { display: none; }
  .rail-steps {
    order: 4;
    flex-direction: row;
    width: 100%;
    flex: 0 0 auto;
    gap: 4px;
    overflow-x: auto;
    scrollbar-width: none;
    padding-bottom: 2px;
  }
  .rail-steps::-webkit-scrollbar { display: none; }
  .wz-step { padding: 6px 9px; font-size: 12px; gap: 7px; }
  .wz-step i { width: 19px; height: 19px; font-size: 10px; }

  .wizard-body { padding: 18px 14px 30px; }
  .wz-card { padding: 22px 20px; border-radius: 17px; }
  .wz-card h2 { font-size: 23px; }
  .generate-now { padding: 11px 14px calc(11px + env(safe-area-inset-bottom, 0px)); }
  .login-card { padding: 32px 24px 28px; }
  .gen-figure { width: 176px; height: 176px; }
  .gen-bot { width: 128px; }
}

@media (max-width: 420px) {
  .wz-nav { flex-wrap: wrap; }
  .wz-nav .wz-btn { flex: 1 1 auto; }
  .wz-img-actions { flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* ==========================================================================
 *  Visor de piezas
 *  Mirar una pieza no debe sacarte de la app: en el teléfono, una pestaña
 *  nueva con la imagen cruda es un callejón sin retorno.
 * ========================================================================== */
.viewer {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(9, 26, 32, .94);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 68px 16px calc(20px + env(safe-area-inset-bottom, 0px));
  animation: viewer-in .16s ease;
}
@keyframes viewer-in { from { opacity: 0; } to { opacity: 1; } }
.viewer-bar {
  position: absolute;
  top: calc(12px + env(safe-area-inset-top, 0px));
  right: 14px;
  left: 14px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.viewer-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: rgba(255, 255, 255, .12);
  border: 1px solid rgba(255, 255, 255, .2);
  color: #fff;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 9px 14px;
  border-radius: 11px;
  cursor: pointer;
  transition: background .15s;
}
.viewer-btn:hover { background: rgba(255, 255, 255, .22); }
.viewer-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 10px;
  display: block;
  animation: viewer-img-in .2s ease;
}
@keyframes viewer-img-in { from { transform: scale(.97); } to { transform: none; } }

/* La pieza terminada y las miniaturas invitan a tocarse */
.wz-result-img, .gal-thumb { cursor: zoom-in; }
.gal-thumb { border: 1px solid var(--line); padding: 0; background: var(--paper); font: inherit; }

/* ============ Aviso breve ============ */
.toast {
  position: fixed;
  left: 50%;
  top: calc(16px + env(safe-area-inset-top, 0px));
  transform: translateX(-50%);
  z-index: 70;
  max-width: min(440px, calc(100vw - 32px));
  background: var(--ink);
  color: #fff;
  font-size: 14px;
  line-height: 1.45;
  padding: 12px 17px;
  border-radius: 13px;
  box-shadow: var(--shadow-pop);
  animation: toast-in .18s ease;
}
.toast.err { background: var(--err); }
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, -10px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

/* ==========================================================================
 *  En el teléfono el modal sube desde abajo y ocupa la pantalla: se maneja
 *  con el pulgar y no queda una tarjetita flotando en el medio.
 * ========================================================================== */
@media (max-width: 620px) {
  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal-card {
    max-width: none;
    border-radius: 22px 22px 0 0;
    max-height: 92vh;
    display: flex;
    flex-direction: column;
    animation: sheet-up .22s cubic-bezier(.2, .7, .3, 1);
  }
  @keyframes sheet-up { from { transform: translateY(100%); } to { transform: none; } }
  .modal-head { padding: 16px 18px; }
  .modal-body {
    max-height: none;
    flex: 1;
    padding: 18px 18px calc(24px + env(safe-area-inset-bottom, 0px));
  }
  .viewer { padding: 62px 10px calc(14px + env(safe-area-inset-bottom, 0px)); }
}

/* ============ Instalar como app ============ */
.install-box {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  margin-bottom: 18px;
  border-radius: 15px;
  border: 1px solid rgba(21, 122, 140, .3);
  background: var(--lens-tint);
}
.install-txt { flex: 1; min-width: 0; }
.install-txt b {
  display: block;
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -.015em;
  color: var(--lens-deep);
  margin-bottom: 2px;
}
.install-txt span { font-size: 12.5px; line-height: 1.45; color: var(--text-dim); }
.install-box .wz-btn { flex-shrink: 0; padding: 10px 18px; font-size: 14px; }

/* Aviso dentro de la tarjeta de resultado cuando la generación no salió */
.wz-warn {
  margin: 0 0 14px;
  padding: 11px 13px;
  border-radius: 11px;
  background: rgba(245, 179, 1, .14);
  border: 1px solid rgba(245, 179, 1, .45);
  color: #6B4A00;
  font-size: 13px;
  line-height: 1.5;
}

/* Arranque: tapa el blanco mientras se resuelve la sesión */
.boot {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--haze);
}
.boot .spinner { width: 26px; height: 26px; border-width: 2.5px; }

/* ==========================================================================
 *  Mis piezas — historial del usuario
 * ========================================================================== */
.wz-card.piezas { max-width: 820px; }
.piezas-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 20px;
}
.piezas-head h2 { margin-bottom: 6px; }
.piezas-head .wz-hint { margin-bottom: 0; }
.piezas-head .wz-btn { flex-shrink: 0; }

.piezas-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
}
.pieza { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.pieza figcaption {
  font-size: 11.5px;
  color: var(--text-mute);
  text-align: center;
}
.pieza .gal-thumb { width: 100%; }

.piezas-vacio {
  grid-column: 1 / -1;
  text-align: center;
  padding: 40px 20px;
  color: var(--text-dim);
}
.piezas-vacio svg { width: 34px; height: 34px; color: var(--text-mute); margin-bottom: 12px; }
.piezas-vacio p { margin-bottom: 16px; font-size: 14.5px; }

@media (max-width: 900px) {
  .piezas-grid { grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; }
  .piezas-head { align-items: center; gap: 10px; margin-bottom: 16px; }
  .piezas-head .wz-btn { padding: 9px 13px; font-size: 13.5px; }
  .piezas-head h2 { font-size: 21px; }
}

/* ============ Compartir sobre la imagen ============ */
/* El mismo botón vive en la miniatura de la galería y en la pieza del
   resultado: circular, sobre la esquina inferior derecha de la imagen. */
.img-share {
  position: absolute;
  right: 10px;
  top: 10px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 42, 51, .78);
  color: #fff;
  font-size: 18px;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  box-shadow: 0 4px 12px rgba(15, 42, 51, .35);
  transition: background .15s, transform .08s;
}
.img-share:hover { background: var(--lens); }
.img-share:active { transform: scale(.94); }

/* Los contenedores donde flota: necesitan ser el marco de referencia. */
.pieza { position: relative; }
.wz-result-imgwrap { position: relative; }

@media (max-width: 900px) {
  .pieza .img-share { width: 40px; height: 40px; right: 8px; top: 8px; }
}
