/* ============================================================================
 * Cuentista — Web App Design System
 * Fuente de verdad de los tokens de marca (colores HSL, tipografía, sombras,
 * radios, motion). Autocontenido: fuentes autoalojadas en web/shared/fonts/.
 * ============================================================================ */

/* ── Fuentes de marca, autoalojadas (variables: Inter 400-600, Nunito 700-800) ── */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url('/web/shared/fonts/inter.woff2') format('woff2');
}
@font-face {
  font-family: 'Nunito';
  font-style: normal;
  font-weight: 700 800;
  font-display: swap;
  src: url('/web/shared/fonts/nunito.woff2') format('woff2');
}

:root {
  --primary:          197 31% 37%;
  --primary-glow:     197 40% 50%;
  --secondary:        35 40% 92%;
  --mango:            26 82% 60%;
  --mango-soft:       26 78% 91%;
  --coral:             7 72% 64%;
  --coral-soft:        7 72% 92%;
  --leaf:             150 30% 50%;
  --leaf-soft:        150 28% 90%;
  --background:         0 0% 99%;
  --foreground:         0 0% 20%;
  --card:               0 0% 97%;
  --popover:            0 0% 100%;
  --muted:              0 0% 94%;
  --muted-foreground:   0 0% 50%;
  --border:             0 0% 92%;
  --destructive:        0 70% 70%;
  --primary-foreground: 0 0% 100%;
  --ring:               197 31% 37%;

  /* Ámbar de marca (portado de colors_and_type.css) para el estado "Revisión" */
  --sun:               43 86% 63%;
  --sun-soft:          43 90% 90%;
  /* Azul cielo de marca (portado de colors_and_type.css --blue-light); -soft derivado
     con la convención estándar (~90% L) para el estado "Listo" y avatares */
  --blue-light:       197 50% 65%;
  --blue-soft:        197 55% 90%;
  /* Gris azulado neutro (lo usa dashboard.css; faltaba definirlo aquí) */
  --accent:           200 20% 65%;

  /* Estados semánticos: capa fina sobre los tokens de marca. TODOS en pastel soft,
     misma intensidad; el color solo distingue estado, no jerarquiza. Texto en
     --foreground sobre el -soft. */
  --status-draft:      0 0% 50%;      /* = muted-foreground (Borrador) */
  --status-draft-soft: 0 0% 94%;      /* = muted */
  --status-progress:      26 82% 60%; /* = mango (En proceso) */
  --status-progress-soft: 26 78% 91%; /* = mango-soft */
  --status-review:      43 86% 63%;   /* = sun ámbar (Revisión) */
  --status-review-soft: 43 90% 90%;   /* = sun-soft */
  --status-done:      197 50% 65%;    /* = blue-light azul (Listo) */
  --status-done-soft: 197 55% 90%;    /* = blue-soft */
  --status-sent:      150 30% 50%;    /* = leaf verde (Enviado) */
  --status-sent-soft: 150 28% 90%;    /* = leaf-soft */

  /* Estados de FLUJO del cuento: el matiz codifica «de quién depende» (para escanear
     el dashboard de un vistazo); TODOS en pastel soft a la misma intensidad, el color
     nunca jerarquiza. Reusan los hues de marca; error/cancelado son nuevos.
       ia      gris    · depende de la IA (proceso automático)
       equipo  ámbar   · depende del equipo (hay que trabajar)
       accion  naranja · depende del equipo, fase de acción (listo para mandar)
       cliente azul    · depende del cliente (esperando fuera)
       cerrado verde   · cerrado, no depende de nadie
       error   rojo    · falló la generación (marca)
       cancel. mostaza · apartado del flujo (marca) */
  --st-ia:            0 0% 50%;        --st-ia-soft:       0 0% 94%;
  --st-equipo:        43 86% 63%;      --st-equipo-soft:   43 90% 90%;
  --st-accion:        26 82% 60%;      --st-accion-soft:   26 78% 91%;
  --st-cliente:       197 50% 65%;     --st-cliente-soft:  197 55% 90%;
  --st-cerrado:       150 30% 50%;     --st-cerrado-soft:  150 28% 90%;
  --st-error:         0 70% 66%;       --st-error-soft:    0 75% 93%;
  --st-cancelado:     45 58% 52%;      --st-cancelado-soft: 46 60% 89%;

  --shadow-card: 0 2px 12px -2px hsl(0 0% 0% / 0.08);
  --shadow-warm: 0 4px 20px -4px hsl(var(--primary) / 0.15);
  --shadow-glow: 0 0 20px        hsl(var(--primary-glow) / 0.2);

  --radius-card: 0.75rem;
  --radius-lg:   1rem;
  --radius-xl:   1.5rem;
  --radius-pill: 9999px;

  --font-display: "Nunito", "Inter", system-ui, sans-serif;
  --font-sans:    "Inter", system-ui, sans-serif;

  --ease-magical: cubic-bezier(0.4, 0, 0.2, 1);
  --transition-magical: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Base ── */
body {
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.6;
  background: hsl(35 22% 97%);   /* surface cálida M3: cream muy sutil */
  color: hsl(var(--foreground));
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* h2 used everywhere as section label — M3 left-indicator style */
h2 {
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: hsl(var(--primary));
  margin-bottom: 1.1rem;
  border-left: 3px solid hsl(var(--primary));
  padding-left: 0.6rem;
  line-height: 1.4;
}

/* ── Header ── */
header {
  background: hsl(var(--popover));
  padding: 0.85rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
  gap: 1rem;
  flex-wrap: wrap;
  border-bottom: 1px solid hsl(var(--border));
  border-top: 3px solid hsl(var(--primary));   /* barra de acento M3 */
  box-shadow: 0 2px 8px hsl(0 0% 0% / 0.06);
}
header .cab-left { display: flex; align-items: center; gap: 0.75rem; min-width: 0; }
/* Botón Inicio (casita): cuadrado al estilo del resto de la barra (nav-btn / btn.sec) */
.cab-home {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2.2rem; height: 2.2rem; flex: none;
  border: 1.5px solid hsl(var(--primary));
  border-radius: 8px;
  background: hsl(var(--primary));
  color: #fff;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.cab-home:hover { background: hsl(var(--primary-glow)); border-color: hsl(var(--primary-glow)); }
.cab-home svg { width: 1.15rem; height: 1.15rem; display: block; }
header .id { font-family: var(--font-display); font-weight: 700; white-space: nowrap; }
header .id .cod { color: hsl(var(--primary)); }
header a { color: hsl(var(--primary)); text-decoration: none; font-size: 0.85rem; white-space: nowrap; transition: color 0.2s; }
header a:hover { color: hsl(var(--primary-glow)); }

/* ── Stepper (barra propia, fuera de la cabecera) ── */
.stepper {
  display: flex;
  justify-content: center;
  padding: 0.9rem 1.5rem;
}
.steps { display: flex; align-items: flex-start; gap: 0; }
.step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  min-width: 88px;
  padding: 0 4px;
  position: relative;
  background: transparent;
  color: hsl(var(--muted-foreground));
  white-space: nowrap;
  border-radius: 0;
  font-weight: 400;
  transition: color 0.2s;
}
/* Bola con número */
.step > span:first-child {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: hsl(var(--background));
  border: 2px solid hsl(var(--border));
  color: hsl(var(--muted-foreground));
  font-size: 0.78rem;
  font-weight: 700;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}
/* Etiqueta */
.step > span:last-child {
  font-size: 0.67rem;
  font-weight: 500;
  color: hsl(var(--muted-foreground));
  transition: color 0.2s;
  line-height: 1;
}
/* Línea conectora centrada entre bolas */
.step + .step::before {
  content: '';
  position: absolute;
  top: 12px;
  right: 50%;
  width: 100%;
  height: 2px;
  background: hsl(var(--border));
  z-index: 0;
}
/* Done */
.step.done > span:first-child { background: hsl(var(--primary)); border-color: hsl(var(--primary)); color: #fff; }
.step.done > span:last-child { color: hsl(var(--primary)); }
.step.done + .step::before { background: hsl(var(--primary)); }
/* Activo */
.step.act > span:first-child { background: hsl(var(--primary)); border-color: hsl(var(--primary)); color: #fff; }
.step.act > span:last-child { color: hsl(var(--primary)); font-weight: 700; }
/* Pasos navegables (clic para saltar de un paso a otro) */
a.step { text-decoration: none; color: inherit; cursor: pointer; }
a.step:hover > span:last-child { color: hsl(var(--primary)); text-decoration: underline; }
a.step:hover > span:first-child { border-color: hsl(var(--primary)); }
a.step:hover > span:first-child { background: hsl(var(--primary) / 0.55); }

/* ── Layout ── */
.wrap { max-width: 1080px; margin: 0 auto; padding: 1.4rem 1.5rem; }
.wrap--sm { max-width: 860px; }

/* ── Cards / sections ── */
section {
  background: hsl(var(--popover));
  border-radius: var(--radius-lg);
  padding: 1.3rem 1.4rem;
  margin-bottom: 1.1rem;
  box-shadow: var(--shadow-card);
  transition: box-shadow 0.3s var(--ease-magical);
}
section:hover { box-shadow: var(--shadow-warm); }

/* ── Buttons ── */
.btn {
  background: hsl(var(--primary));
  color: #fff;
  border: 1.5px solid transparent;
  border-radius: 8px;
  padding: 0.55rem 1.1rem;
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  line-height: 1.4;
  letter-spacing: 0.01em;
  transition: background 0.15s, box-shadow 0.15s;
  white-space: nowrap;
}
.btn:hover {
  background: hsl(var(--primary-glow));
  box-shadow: 0 2px 8px hsl(var(--primary) / 0.25);
}
.btn:active { box-shadow: none; }
.btn.sec {
  background: transparent;
  color: hsl(var(--primary));
  border-color: hsl(var(--primary) / 0.3);
}
.btn.sec:hover {
  background: hsl(var(--primary) / 0.06);
  border-color: hsl(var(--primary) / 0.5);
  box-shadow: none;
}
.btn.print {
  background: hsl(var(--mango));
  color: #fff;
  border-color: transparent;
}
.btn.print:hover {
  background: hsl(26 72% 50%);
  box-shadow: 0 2px 8px hsl(var(--mango) / 0.3);
}
.btn.dl {
  background: hsl(var(--primary));
  color: #fff;
  border-color: transparent;
}
.btn.dl:hover {
  background: hsl(var(--primary-glow));
  box-shadow: 0 2px 8px hsl(var(--primary) / 0.25);
}
/* Coral: reservado en TODO el sistema a una sola acción, «Enviar a GE» (imprenta,
   irreversible y con coste). Nunca para otras primarias. */
.btn.coral { background: hsl(var(--coral)); color: #fff; border-color: transparent; }
.btn.coral:hover { background: hsl(7 78% 70%); box-shadow: 0 2px 10px hsl(var(--coral) / 0.35); }
/* Peligro (outline rojo): acciones destructivas secundarias (Eliminar sobre una marca). */
.btn.sec.danger { color: hsl(var(--destructive)); border-color: hsl(var(--destructive) / 0.45); background: transparent; }
.btn.sec.danger:hover { background: hsl(var(--destructive) / 0.08); border-color: hsl(var(--destructive) / 0.7); box-shadow: none; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: none !important; }

/* Botón "volver" (secundario, pill) — reutilizable entre pantallas. */
.btn-volver {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  text-decoration: none;
  padding: 0.5rem 1rem;
  border-radius: 9px;
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.85rem;
  color: hsl(var(--primary));
  background: transparent;
  border: 1.5px solid hsl(var(--primary) / 0.3);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.btn-volver:hover { background: hsl(var(--primary) / 0.06); border-color: hsl(var(--primary) / 0.5); }

.nav-btn {
  background: transparent;
  color: hsl(var(--primary));
  border: 1.5px solid hsl(var(--primary) / 0.25);
  border-radius: 8px;
  padding: 0.55rem 1.1rem;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font-sans);
  transition: background 0.15s, border-color 0.15s;
}
.nav-btn:hover { background: hsl(var(--primary) / 0.06); border-color: hsl(var(--primary) / 0.45); }
.nav-btn:disabled { opacity: 0.3; cursor: default; }

/* ── Misc ── */
.saved { font-size: 0.75rem; color: hsl(var(--leaf)); opacity: 0; transition: opacity 0.2s; }
.saved.on { opacity: 1; }

/* ── Barra de acción fija (pie de página siempre visible) ── */
.action-bar { position: fixed; bottom: 0; left: 0; right: 0; z-index: 100; background: hsl(var(--popover)); border-top: 1px solid hsl(var(--border)); box-shadow: 0 -4px 20px hsl(0 0% 0% / 0.06); padding: 0.65rem 1.5rem; }
.action-bar-inner { max-width: 860px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.action-bar-right { display: flex; align-items: center; gap: 0.55rem; flex-wrap: wrap; }
.action-bar-right form { margin: 0; }
/* Reserva espacio para que el contenido no quede bajo la barra fija */
body:has(.action-bar) .wrap { padding-bottom: 5rem; }

label.field-label { display: block; font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.09em; color: hsl(var(--primary)); margin-bottom: 0.45rem; }
.codigo-wrap { margin-bottom: 1.4rem; }

/* ── Inputs ── */
.codigo-input {
  width: 100%;
  padding: 0.8rem 1.1rem;
  border: 1.5px solid hsl(var(--border));
  border-radius: var(--radius-card);
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: hsl(var(--foreground));
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  background: hsl(var(--popover));
  font-family: var(--font-sans);
}
.codigo-input:focus { border-color: hsl(var(--primary)); box-shadow: 0 0 0 3px hsl(var(--ring) / 0.12); }
.codigo-input::placeholder { color: hsl(var(--muted-foreground)); font-weight: 400; font-size: 1.1rem; }

/* ── Textarea ── */
textarea {
  width: 100%;
  border: 1.5px solid hsl(var(--border));
  border-radius: var(--radius-card);
  padding: 0.65rem 0.85rem;
  font-size: 0.9rem;
  font-family: var(--font-sans);
  line-height: 1.6;
  resize: vertical;
  min-height: 190px;
  outline: none;
  color: hsl(var(--foreground));
  background: hsl(var(--popover));
  transition: border-color 0.15s, box-shadow 0.15s;
}
textarea:focus { border-color: hsl(var(--primary)); box-shadow: 0 0 0 2px hsl(var(--ring) / 0.1); }

/* ── File zone ── */
.pdf-wrap { margin-bottom: 1.6rem; }
.file-zone {
  position: relative;
  border: 2px dashed hsl(var(--border));
  border-radius: var(--radius-lg);
  padding: 2rem 1.2rem;
  text-align: center;
  cursor: pointer;
  transition: var(--transition-magical);
  background: hsl(var(--card));
}
.file-zone:hover, .file-zone.has-file { border-color: hsl(var(--primary) / 0.7); background: hsl(var(--secondary)); }
.file-zone input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.zone-icon { font-size: 2rem; margin-bottom: 0.5rem; line-height: 1; }
.zone-hint { font-size: 0.85rem; color: hsl(var(--muted-foreground)); }
.zone-hint b { color: hsl(var(--primary)); }
.zone-fname { display: none; margin-top: 0.5rem; font-size: 0.88rem; color: hsl(var(--primary)); font-weight: 600; word-break: break-all; }

/* ── Index: submit button + proc msg ── */
.btn-procesar {
  width: 100%;
  padding: 0.7rem 1rem;
  background: hsl(var(--primary));
  color: #fff;
  font-size: 0.95rem;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  letter-spacing: 0.01em;
  transition: background 0.15s, box-shadow 0.15s;
  font-family: var(--font-sans);
}
.btn-procesar:hover { background: hsl(var(--primary-glow)); box-shadow: 0 2px 8px hsl(var(--primary) / 0.25); }
.btn-procesar:active { box-shadow: none; }
.btn-procesar:disabled { opacity: 0.5; cursor: not-allowed; box-shadow: none; }

/* Tarjeta de "algo está cargando" (generando, subiendo PDF, eliminando…).
   Tinte fresco teal→azul en vez del gris/pardo plano; un carril luminoso recorre el
   borde superior para transmitir progreso. Reutilizada en todas las pantallas. */
.proc-msg {
  display: none;
  position: relative;
  overflow: hidden;
  margin-top: 1rem;
  padding: 0.8rem 1rem;
  background:
    linear-gradient(135deg, hsl(var(--primary) / 0.09), hsl(var(--blue-light) / 0.10));
  border-radius: var(--radius-card);
  font-size: 0.84rem;
  font-weight: 600;
  color: hsl(var(--primary));
  text-align: center;
  border: 1px solid hsl(var(--primary) / 0.18);
  box-shadow: 0 4px 14px hsl(var(--primary) / 0.08);
}
.proc-msg::before {
  content: "";
  position: absolute;
  top: 0; left: 0;
  height: 3px; width: 40%;
  background: linear-gradient(90deg, transparent, hsl(var(--primary)), hsl(var(--blue-light)), transparent);
  animation: proc-sweep 1.6s ease-in-out infinite;
}
@keyframes proc-sweep {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(350%); }
}
@media (prefers-reduced-motion: reduce) {
  .proc-msg::before { animation: none; opacity: 0.6; }
}

/* ── Index: centered page layout ── */
body.page-index { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 2.5rem 1.5rem; gap: 1.6rem; }
.logo-wrap { text-align: center; }
.logo-wrap img { width: 200px; margin-bottom: 0.4rem; }
.tagline { font-size: 0.82rem; color: hsl(var(--primary) / 0.65); letter-spacing: 0.03em; }

.card {
  background: hsl(var(--popover));
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-card);
  padding: 2.4rem 2.2rem;
  width: 100%;
  max-width: 440px;
  transition: box-shadow 0.3s var(--ease-magical);
  border-top: 3px solid hsl(var(--primary));
}
.card:hover { box-shadow: var(--shadow-warm); }

.anteriores { width: 100%; max-width: 440px; }
.anteriores summary { list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 0.5rem; font-size: 0.8rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; color: hsl(var(--primary) / 0.7); padding: 0.5rem 0; user-select: none; }
.anteriores summary::-webkit-details-marker { display: none; }
.anteriores summary::after { content: '▾'; font-size: 0.7rem; transition: transform 0.2s; }
.anteriores[open] summary::after { transform: rotate(-180deg); }
.buscar-bar {
  display: flex; align-items: center; width: 100%; max-width: 440px;
  background: hsl(var(--popover));
  border: 1.5px solid hsl(var(--primary) / 0.5); border-radius: 999px;
  box-shadow: 0 2px 12px -2px hsl(var(--primary) / 0.2);
  transition: var(--transition-magical);
}
.buscar-bar:hover { border-color: hsl(var(--primary) / 0.7); }
.buscar-bar:focus-within {
  border-color: hsl(var(--primary));
  box-shadow: 0 0 0 3px hsl(var(--ring) / 0.12);
}
.buscar-icono {
  width: 1rem; height: 1rem; flex-shrink: 0; margin-left: 0.9rem;
  color: hsl(var(--primary)); transition: color 0.2s;
}
.buscar-cuentos {
  flex: 1; min-width: 0; border: none; background: transparent; outline: none;
  padding: 0.55rem 0.5rem 0.55rem 0.6rem; font-size: 0.9rem; font-family: var(--font-body);
  color: hsl(var(--foreground));
}
.buscar-cuentos::placeholder { color: hsl(var(--muted-foreground)); }
.buscar-cuentos::-webkit-search-cancel-button { cursor: pointer; }
.proy-vacio { margin: 0.7rem 0 0; text-align: center; font-size: 0.85rem; color: hsl(var(--muted-foreground)); }
.proy-lista { margin-top: 0.6rem; display: flex; flex-direction: column; gap: 0.4rem; }
.proy {
  display: flex; justify-content: space-between; align-items: center;
  background: hsl(var(--popover));
  border-radius: var(--radius-card);
  padding: 0.75rem 1rem;
  text-decoration: none;
  color: hsl(var(--foreground));
  box-shadow: var(--shadow-card);
  transition: var(--transition-magical);
  border-left: 3px solid transparent;
}
.proy:hover {
  box-shadow: var(--shadow-warm);
  border-left-color: hsl(var(--primary));
  transform: translateX(2px);
}
.proy .proy-info { display: flex; flex-direction: column; gap: 0.15rem; min-width: 0; }
.proy .cod { font-weight: 700; color: hsl(var(--primary)); margin-right: 0.4rem; }
.proy .titulo-proy { color: hsl(var(--muted-foreground)); font-size: 0.92rem; }
.proy .autor { font-size: 0.72rem; color: hsl(var(--muted-foreground) / 0.8); }
.proy .fase { font-size: 0.72rem; color: hsl(var(--muted-foreground)); white-space: nowrap; margin-left: 0.5rem; }

/* ── Edición: título ── */
.titulo-edit { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1.1rem; }
.titulo-inp { flex: 1; min-width: 0; font-size: 1.7rem; font-weight: 800; font-family: var(--font-display); color: hsl(var(--foreground)); line-height: 1.25; padding: 0.3rem 0.75rem; border: 2px solid hsl(var(--primary) / 0.25); border-radius: var(--radius-card); background: transparent; outline: none; transition: var(--transition-magical); }
.titulo-inp::placeholder { color: hsl(var(--muted-foreground)); font-weight: 400; font-size: 1.3rem; }
.titulo-inp:hover { border-color: hsl(var(--primary) / 0.45); }
.titulo-inp:focus { border-color: hsl(var(--primary)); box-shadow: 0 0 0 3px hsl(var(--ring) / 0.1); }

/* ── Portada thumbs ── */
.portada-thumbs { display: flex; gap: 0.45rem; flex-shrink: 0; align-items: center; order: -1; }
.portada-thumb-img { width: 52px; height: 70px; object-fit: cover; border-radius: 7px; display: block; transition: opacity 0.15s; }
.thumb-wrap:hover .portada-thumb-img { opacity: 0.72; }
.portada-ph { width: 52px; height: 70px; background: hsl(var(--muted)); border-radius: 7px; border: 1.5px dashed hsl(var(--border)); display: flex; align-items: center; justify-content: center; font-size: 0.62rem; color: hsl(var(--muted-foreground)); text-align: center; line-height: 1.3; transition: border-color 0.15s; }
.thumb-wrap:hover .portada-ph { border-color: hsl(var(--primary) / 0.4); }
.pop-down { left: 0; top: calc(100% + 8px); }

/* ── Two-column layout ── */
.content-layout { display: flex; gap: 1.3rem; align-items: flex-start; }
.main-col { flex: 1; min-width: 0; }
.ilus-col { width: 200px; flex-shrink: 0; position: sticky; top: 4.4rem; }

/* ── Page rows ── */
.row { display: flex; gap: 0.9rem; padding: 0.9rem 0; border-bottom: 1px solid hsl(var(--border)); align-items: flex-start; }
.row:last-child { border-bottom: none; }
.row-num { font-size: 2.5rem; font-weight: 900; font-family: var(--font-display); color: hsl(var(--primary) / 0.2); width: 2.5rem; text-align: right; flex-shrink: 0; line-height: 1; padding-top: 0.15rem; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.row-imgs { display: flex; flex-direction: column; gap: 0.45rem; width: 90px; flex-shrink: 0; }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0.3rem; }

/* Floater de página (insertar / eliminar): aparece a la izquierda al pasar el ratón. */
.page-handle { display: flex; flex-direction: column; gap: 0.25rem; width: 1.5rem; flex-shrink: 0; padding-top: 0.2rem; opacity: 0; transition: opacity 0.12s; }
.row:hover .page-handle, .page-handle:focus-within { opacity: 1; }
.ph-btn { width: 1.5rem; height: 1.5rem; padding: 0; border-radius: 6px; border: 1px solid hsl(var(--border)); background: hsl(var(--popover)); color: hsl(var(--muted-foreground)); font-family: var(--font-sans); font-size: 1.05rem; font-weight: 700; line-height: 1; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: background 0.12s, color 0.12s, border-color 0.12s; }
.ph-btn:hover { background: hsl(var(--primary)); color: #fff; border-color: hsl(var(--primary)); }
.ph-del:hover { background: hsl(var(--destructive)); border-color: hsl(var(--destructive)); }
.ph-drag { cursor: grab; font-size: 0.9rem; }
.ph-drag:active { cursor: grabbing; }
/* Fila que se está arrastrando: atenuada para ver dónde caerá. */
.row.dragging { opacity: 0.45; background: hsl(var(--primary) / 0.04); border-radius: 8px; }

/* ── Thumbnails ── */
.thumb-wrap { position: relative; cursor: pointer; border-radius: 9px; }
.thumb-img { width: 90px; height: 90px; object-fit: cover; border-radius: 9px; display: block; transition: opacity 0.15s; }
.thumb-wrap:hover .thumb-img { opacity: 0.72; }
.thumb-ph { width: 90px; height: 90px; background: hsl(var(--muted)); border-radius: 9px; border: 1.5px dashed hsl(var(--border)); display: flex; align-items: center; justify-content: center; font-size: 0.68rem; color: hsl(var(--muted-foreground)); text-align: center; line-height: 1.4; transition: border-color 0.15s, color 0.15s; }
.thumb-wrap:hover .thumb-ph { border-color: hsl(var(--primary) / 0.4); color: hsl(var(--primary) / 0.55); }

/* ── Popup ── */
.thumb-popup { display: none; position: absolute; left: calc(100% + 8px); top: 0; z-index: 30; background: hsl(var(--popover)); border-radius: 11px; box-shadow: 0 6px 28px hsl(0 0% 0% / 0.16); padding: 0.35rem; min-width: 150px; flex-direction: column; gap: 0.15rem; }
.thumb-popup.open { display: flex; }
.pop-btn { display: flex; align-items: center; gap: 0.45rem; padding: 0.48rem 0.65rem; border-radius: 7px; font-size: 0.82rem; font-weight: 600; cursor: pointer; color: hsl(var(--foreground)); text-decoration: none; white-space: nowrap; transition: background 0.12s; border: none; background: none; font-family: var(--font-sans); width: 100%; }
.pop-btn:hover { background: hsl(var(--muted)); }
.pop-divider { height: 1px; background: hsl(var(--border)); margin: 0.1rem 0; }
.pop-replace { position: relative; }
.pop-replace input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }

/* ── Illustration sidebar ── */
.ilus-card { background: hsl(var(--popover)); border-radius: var(--radius-lg); padding: 1.1rem 1.1rem 1.2rem; box-shadow: var(--shadow-card); }
.ilus-card h2 { margin-bottom: 0.9rem; }
.ilus-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.45rem; margin-bottom: 0.9rem; }
.ilus-item { position: relative; border-radius: 8px; overflow: hidden; cursor: pointer; aspect-ratio: 1; background: hsl(var(--muted)); }
.ilus-item img { width: 100%; height: 100%; object-fit: cover; display: block; transition: opacity 0.15s; }
.ilus-item:hover img { opacity: 0.75; }
.ilus-overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; opacity: 0; transition: opacity 0.15s; background: hsl(0 0% 0% / 0.25); color: #fff; font-size: 1.1rem; }
.ilus-item:hover .ilus-overlay { opacity: 1; }
.btn-zip { width: 100%; text-align: center; font-size: 0.82rem; padding: 0.45rem 0.6rem; }

/* ── Lightbox ── */
#lightbox { display: none; position: fixed; inset: 0; background: hsl(0 0% 0% / 0.9); z-index: 200; align-items: center; justify-content: center; }
#lightbox.open { display: flex; }
.lb-backdrop { position: absolute; inset: 0; z-index: 0; }
.lb-box { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; gap: 0.9rem; max-width: 88vw; }
#lb-img { max-width: 80vw; max-height: 76vh; border-radius: var(--radius-card); display: block; object-fit: contain; }
.lb-actions { display: flex; gap: 0.8rem; align-items: center; }
.lb-dl { background: hsl(var(--primary)); color: #fff; padding: 0.5rem 1.2rem; border-radius: 8px; text-decoration: none; font-size: 0.85rem; font-weight: 700; display: inline-flex; align-items: center; gap: 0.35rem; transition: background 0.2s; }
.lb-dl:hover { background: hsl(var(--primary-glow)); }
.lb-close { background: hsl(0 0% 100% / 0.15); border: none; color: #fff; width: 2.2rem; height: 2.2rem; border-radius: 50%; cursor: pointer; font-size: 1rem; display: flex; align-items: center; justify-content: center; }
.lb-close:hover { background: hsl(0 0% 100% / 0.28); }
.lb-arrow { position: fixed; top: 50%; transform: translateY(-50%); z-index: 2; background: hsl(0 0% 100% / 0.12); border: none; color: #fff; width: 3rem; height: 3rem; border-radius: 50%; cursor: pointer; font-size: 1.4rem; display: flex; align-items: center; justify-content: center; transition: background 0.15s; }
.lb-arrow:hover { background: hsl(0 0% 100% / 0.28); }
.lb-arrow:disabled { opacity: 0.2; cursor: default; }
#lb-prev { left: 1.2rem; }
#lb-next { right: 1.2rem; }

/* ── Preview: cards, badges, viewer ── */
.preview-card { background: hsl(var(--popover)); border-radius: var(--radius-lg); padding: 1.3rem 1.4rem; margin-bottom: 1.2rem; box-shadow: var(--shadow-card); }
.badge { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; padding: 0.25rem 0.75rem; border-radius: var(--radius-pill); }
.badge.digital { background: hsl(var(--primary) / 0.12); color: hsl(var(--primary)); }
.badge.print { background: hsl(var(--mango-soft)); color: hsl(var(--mango)); }
.pg-counter { font-size: 0.82rem; color: hsl(var(--muted-foreground)); font-weight: 600; font-variant-numeric: tabular-nums; }
.viewer-nav { display: flex; align-items: center; justify-content: space-between; }

/* ── Tipo de maquetado (segmented control / radio pills) ── */
.tipo-wrap { margin-bottom: 1.4rem; }
.tipo-group {
  display: flex;
  gap: 0.5rem;
}
.tipo-opt {
  flex: 1;
  position: relative;
}
.tipo-opt input[type=radio] {
  position: absolute;
  width: 1px; height: 1px;
  opacity: 0;
  pointer-events: none;
}
.tipo-opt span {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 0.6rem 0.5rem;
  border-radius: var(--radius-pill);
  border: 1.5px solid hsl(var(--border));
  background: hsl(var(--card));
  font-size: 0.84rem;
  font-weight: 600;
  color: hsl(var(--muted-foreground));
  cursor: pointer;
  transition: var(--transition-magical);
  text-align: center;
  user-select: none;
  line-height: 1.2;
}
.tipo-opt:hover span {
  border-color: hsl(var(--primary) / 0.35);
  color: hsl(var(--primary));
  background: hsl(var(--secondary));
}
.tipo-opt input[type=radio]:checked + span {
  background: hsl(var(--primary));
  color: #fff;
  border-color: transparent;
  box-shadow: 0 2px 6px hsl(var(--primary) / 0.25);
}
.tipo-opt input[type=radio]:focus-visible + span {
  outline: 2px solid hsl(var(--primary));
  outline-offset: 2px;
}

/* ── Section heading with badge ── */
.section-head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 1.1rem;
}
.section-head h2 { margin-bottom: 0; }

@media (max-width: 760px) {
  .content-layout { flex-direction: column; }
  .ilus-col { width: 100%; position: static; }
}

/* ── Pastilla de estado de flujo (componente global) ─────────────────────────
   La pastilla que identifica el estado del cuento. Vive bajo el título en la ficha
   del editor y comparte lenguaje con los badges del dashboard. El matiz codifica
   «de quién depende» (tokens --st-*); misma intensidad pastel para todas. */
.pastilla {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.2rem 0.6rem 0.2rem 0.5rem;
  border-radius: var(--radius-pill);
  font-size: 0.75rem; font-weight: 600; white-space: nowrap;
  color: hsl(var(--foreground));
  background: hsl(var(--st-ia-soft));
}
.pastilla-dot { width: 7px; height: 7px; border-radius: 50%; flex: none; background: hsl(var(--st-ia)); }
.pastilla--ia        { background: hsl(var(--st-ia-soft)); }
.pastilla--ia        .pastilla-dot { background: hsl(var(--st-ia)); }
.pastilla--equipo    { background: hsl(var(--st-equipo-soft)); }
.pastilla--equipo    .pastilla-dot { background: hsl(var(--st-equipo)); }
.pastilla--accion    { background: hsl(var(--st-accion-soft)); }
.pastilla--accion    .pastilla-dot { background: hsl(var(--st-accion)); }
.pastilla--cliente   { background: hsl(var(--st-cliente-soft)); }
.pastilla--cliente   .pastilla-dot { background: hsl(var(--st-cliente)); }
.pastilla--cerrado   { background: hsl(var(--st-cerrado-soft)); }
.pastilla--cerrado   .pastilla-dot { background: hsl(var(--st-cerrado)); }
.pastilla--error     { background: hsl(var(--st-error-soft)); }
.pastilla--error     .pastilla-dot { background: hsl(var(--st-error)); }
.pastilla--cancelado { background: hsl(var(--st-cancelado-soft)); }
.pastilla--cancelado .pastilla-dot { background: hsl(var(--st-cancelado)); }
