/* ── Variables de marca Colla-Gen ─────────────────────────────────────────── */
:root {
  --bg:          #FAF7F5;
  --dark:        #3D2B1F;
  --salmon:      #C49A8A;
  /* Alto compartido por la barra superior y la cabecera del sidebar, para que
     sus bordes inferiores queden en la misma línea. */
  --topbar-h: 62px;
  --pink-light:  #EDD5CC;
  --muted:       #7A5C50;
  --white:       #FFFFFF;
  --danger:      #CE2D4F;
  --radius-lg:   18px;
  --radius-md:   12px;
  --radius-sm:   8px;
  --shadow-sm:   0 1px 6px rgba(61, 43, 31, 0.08);
  --shadow-md:   0 4px 20px rgba(61, 43, 31, 0.12);
  --transition:  all 0.18s ease;
}

/* ── Modo oscuro ───────────────────────────────────────────────────────────
   Paleta NEUTRA (casi negro), no marrón: el espresso de marca funciona como
   texto en claro, pero como fondo oscuro se ve sucio. El salmón se mantiene
   como acento. Tres estados: data-theme="dark" fuerza oscuro, "light" fuerza
   claro, y sin atributo manda el sistema.

   --invert-bg / --invert-fg son los elementos "invertidos" (burbuja del
   usuario, cabecera de tarjeta, botón primario): en claro son oscuros sobre
   fondo claro; en oscuro NO se vuelven blancos —eso deslumbra— sino que pasan
   al acento de marca. */
:root {
  --invert-bg: var(--dark);
  --invert-fg: var(--white);
  --on-accent: #3D2B1F;   /* texto sobre salmón: 7.33:1 (blanco daría 2.52:1) */
}

:root[data-theme="dark"] {
  --bg:         #0E0E10;   /* casi negro */
  --dark:       #ECECEE;   /* pasa a ser el color de TEXTO */
  --pink-light: #26262B;
  --muted:      #9E9EA7;
  --white:      #17171A;   /* pasa a ser el color de SUPERFICIE (tarjetas) */
  --danger:     #FF6B85;
  --invert-bg:  var(--salmon);
  --invert-fg:  #14140F;
  --shadow-sm:  0 1px 6px rgba(0, 0, 0, 0.5);
  --shadow-md:  0 4px 20px rgba(0, 0, 0, 0.6);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:         #0E0E10;
    --dark:       #ECECEE;
    --pink-light: #26262B;
    --muted:      #9E9EA7;
    --white:      #17171A;
    --danger:     #FF6B85;
    --invert-bg:  var(--salmon);
    --invert-fg:  #14140F;
    --shadow-sm:  0 1px 6px rgba(0, 0, 0, 0.5);
    --shadow-md:  0 4px 20px rgba(0, 0, 0, 0.6);
    color-scheme: dark;
  }
}

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

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--dark);
  height: 100dvh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}


/* ════════════════════════════════════════════════════════════════════════════
   LOGIN
════════════════════════════════════════════════════════════════════════════ */

#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100dvh;
  padding: 1.5rem;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(237, 213, 204, 0.4) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(196, 154, 138, 0.15) 0%, transparent 45%),
    var(--bg);
}

.login-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 2.5rem 2rem 2rem;
  width: 100%;
  max-width: 380px;
  text-align: center;
}

.login-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.login-logo-mark { font-size: 1.5rem; }

.login-logo-text {
  font-size: 0.875rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: var(--salmon);
}

.login-title {
  font-size: 1.375rem;
  font-weight: 700;
  color: var(--dark);
  margin-bottom: 0.375rem;
}

.login-subtitle {
  font-size: 0.8125rem;
  color: var(--muted);
  margin-bottom: 2rem;
}

.input-wrapper {
  position: relative;
  margin-bottom: 0.875rem;
}

.input-icon {
  position: absolute;
  left: 0.875rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.9375rem;
  pointer-events: none;
}

.login-input {
  width: 100%;
  padding: 0.875rem 1rem 0.875rem 2.5rem;
  border: 1.5px solid var(--pink-light);
  border-radius: var(--radius-md);
  font-size: 0.9375rem;
  font-family: inherit;
  background: var(--bg);
  color: var(--dark);
  transition: var(--transition);
  outline: none;
}

.login-input:focus { border-color: var(--salmon); }

.btn-primary {
  width: 100%;
  padding: 0.875rem;
  background: var(--invert-bg);
  color: var(--invert-fg);
  border: none;
  border-radius: var(--radius-md);
  font-size: 0.9375rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  letter-spacing: 0.02em;
}

.btn-primary:hover:not(:disabled) { background: var(--salmon); }
.btn-primary:active:not(:disabled) { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.login-error {
  color: var(--danger);
  font-size: 0.8125rem;
  margin-top: 0.875rem;
  min-height: 1.2em;
}


/* ════════════════════════════════════════════════════════════════════════════
   APP LAYOUT
════════════════════════════════════════════════════════════════════════════ */

.layout {
  display: flex;
  height: 100dvh;
}

#app {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  height: 100dvh;
}

/* ── Sidebar / menú lateral ──────────────────────────────────────────────── */

.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--white);
  border-right: 1px solid var(--pink-light);
  display: flex;
  flex-direction: column;
  /* Sin padding arriba: la cabecera aporta su propio alto, igual al de la barra
     superior. Si el sidebar empujara desde arriba, los bordes no calzarían. */
  padding: 0 0.75rem 1rem;
  gap: 0.5rem;
  transition: width 0.18s ease;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  height: var(--topbar-h);
  flex-shrink: 0;
  /* Se estira hasta los bordes del sidebar para que su línea inferior sea
     continua con la de la barra superior. */
  margin: 0 -0.75rem 0.5rem;
  padding: 0 1.25rem;
  border-bottom: 1px solid var(--pink-light);
  margin-bottom: 0.5rem;
}

.sidebar-nav {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.sidebar-foot {
  margin-top: auto;
  border-top: 1px solid var(--pink-light);
  padding-top: 0.5rem;
}

.nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.625rem 0.75rem;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: var(--transition);
  text-align: left;
}
.nav-item:hover { background: var(--bg); color: var(--dark); }
.nav-item.active { background: var(--pink-light); color: var(--dark); }
.nav-item--muted { font-weight: 500; }
.nav-ico { font-size: 1.05rem; flex-shrink: 0; }

/* Grupo plegable del sidebar (ej. "Plataformas") */
.nav-group { list-style: none; }
.nav-parent .nav-caret {
  margin-left: auto;
  font-size: 0.7rem;
  transition: transform 0.18s ease;
}
.nav-parent.expanded .nav-caret { transform: rotate(90deg); }
.nav-sub {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin: 0.25rem 0 0.25rem 0.9rem;
  padding-left: 0.35rem;
  border-left: 1px solid var(--pink-light);
}
.nav-sub.hidden { display: none; }
.nav-subitem { font-size: 0.9rem; padding: 0.5rem 0.7rem; }

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(61, 43, 31, 0.35);
  z-index: 40;
}

.btn-icon { padding: 0.4375rem; }
/* El botón de menú (hamburguesa) solo se ve en mobile */
#menu-btn { display: none; }

/* ── Sidebar plegable ─────────────────────────────────────────────────────
   Contraído deja solo los iconos. Se ocultan los textos pero NO se sacan del
   DOM: los lectores de pantalla los siguen leyendo y el estado activo se ve
   igual. El ancho lo toma de una variable para que la transición sea una sola. */
.sidebar-toggle {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 0.3rem;
  border-radius: var(--radius-sm);
  display: inline-flex;
  transition: var(--transition);
}
.sidebar-toggle:hover { background: var(--pink-light); color: var(--dark); }

.sidebar--collapsed { width: 68px; }
.sidebar--collapsed .header-logo,
.sidebar--collapsed .nav-label,
.sidebar--collapsed .nav-caret,
.sidebar--collapsed .sidebar-foot { display: none; }
.sidebar--collapsed .sidebar-brand { padding: 0 0.5rem; justify-content: center; }
.sidebar--collapsed .sidebar-toggle { margin-left: 0; transform: rotate(180deg); }
.sidebar--collapsed .header-logomark { display: none; }
.sidebar--collapsed .nav-item,
.sidebar--collapsed .nav-parent {
  justify-content: center;
  padding-left: 0.5rem;
  padding-right: 0.5rem;
}
/* Los hijos de un grupo se esconden: sin su etiqueta son iconos sin sentido. */
.sidebar--collapsed .nav-sub { display: none; }

/* ── Vistas ──────────────────────────────────────────────────────────────── */

.view { flex: 1; min-height: 0; }
.view-agente { display: flex; flex-direction: column; }
.view-dash { overflow-y: auto; padding: 1.5rem 1.25rem 2rem; }

/* En pantallas anchas el sidebar es fijo; en mobile es un drawer */
@media (max-width: 899px) {
  #menu-btn { display: inline-flex; }
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    box-shadow: var(--shadow-md);
  }
  .sidebar.open { transform: translateX(0); }
}


/* ── Header ──────────────────────────────────────────────────────────────── */

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--topbar-h);
  padding: 0 1.25rem;
  background: var(--white);
  border-bottom: 1px solid var(--pink-light);
  flex-shrink: 0;
  gap: 1rem;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  min-width: 0;
}

.header-logomark { font-size: 1.1rem; flex-shrink: 0; }

.header-text {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  overflow: hidden;
}

.header-logo {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  color: var(--salmon);
  white-space: nowrap;
  flex-shrink: 0;
}

.header-dot { color: var(--pink-light); font-size: 0.875rem; flex-shrink: 0; }

.header-title {
  font-size: 0.8125rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  flex-shrink: 0;
}

/* Agrupa las acciones de la vista + el interruptor de sonido (que es global). */
.header-right {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  flex-shrink: 0;
}

#sound-btn { font-size: 0.95rem; line-height: 1; }

.btn-ghost {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.4375rem 0.75rem;
  background: none;
  border: 1px solid var(--pink-light);
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  font-family: inherit;
  color: var(--muted);
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.btn-ghost:hover {
  border-color: var(--salmon);
  color: var(--dark);
  background: var(--bg);
}


/* ── Messages area ───────────────────────────────────────────────────────── */

#messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem 1.25rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  scroll-behavior: smooth;
}

#messages::-webkit-scrollbar { width: 4px; }
#messages::-webkit-scrollbar-track { background: transparent; }
#messages::-webkit-scrollbar-thumb { background: var(--pink-light); border-radius: 99px; }


/* ── Welcome ─────────────────────────────────────────────────────────────── */

.welcome-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  padding: 1rem 0 0.5rem;
}

.welcome-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 1.75rem 1.5rem;
  max-width: 540px;
  width: 100%;
  text-align: center;
}

.welcome-emoji { font-size: 2rem; margin-bottom: 0.75rem; }

.welcome-title {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--dark);
  margin-bottom: 0.5rem;
}

.welcome-text {
  font-size: 0.875rem;
  color: var(--muted);
  line-height: 1.65;
  margin-bottom: 1.25rem;
}

.chips-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 0.625rem;
}

/* Cuadrícula de capacidades en la pantalla de inicio del chat */
.cap-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
  margin-top: 0.5rem;
  text-align: left;
}
.cap-card {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.875rem 1rem;
  background: var(--white);
  border: 1px solid var(--pink-light);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}
.cap-card:hover { border-color: var(--salmon); transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.cap-ico { font-size: 1.5rem; }
.cap-title { font-size: 0.9375rem; font-weight: 700; color: var(--dark); }
.cap-desc { font-size: 0.8125rem; color: var(--muted); line-height: 1.4; }

/* Botón "Generar contenido" del header */
.btn-generate {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.9rem;
  background: var(--salmon);
  color: #fff;
  border: none;
  border-radius: 999px;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.15s ease;
  white-space: nowrap;
}
.btn-generate:hover { filter: brightness(0.96); }

.welcome-cta {
  padding: 0.75rem 1.75rem;
  background: var(--salmon);
  color: var(--white);
  border: none;
  border-radius: 999px;
  font-size: 0.9375rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
}

.welcome-cta:hover {
  filter: brightness(0.96);
  transform: translateY(-1px);
}

.chip-grid + .welcome-cta { margin-top: 1.25rem; }

.welcome-back {
  margin-top: 1.25rem;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.8125rem;
  font-family: inherit;
  cursor: pointer;
  transition: var(--transition);
}

.welcome-back:hover { color: var(--dark); }

.chip-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
}

.chip {
  padding: 0.5rem 0.875rem;
  background: var(--bg);
  border: 1.5px solid var(--pink-light);
  border-radius: 999px;
  font-size: 0.8125rem;
  font-family: inherit;
  color: var(--dark);
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.chip:hover {
  background: var(--pink-light);
  border-color: var(--salmon);
}


/* ── Message bubbles ─────────────────────────────────────────────────────── */

.message {
  display: flex;
  gap: 0.625rem;
  align-items: flex-end;
}

.message.user  { flex-direction: row-reverse; align-self: flex-end;   max-width: 80%; }
.message.agent { flex-direction: row;          align-self: flex-start; max-width: 80%; }

.msg-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  flex-shrink: 0;
  margin-bottom: 2px;
}

.message.user  .msg-avatar { background: var(--invert-bg); }
.message.agent .msg-avatar { background: var(--pink-light); }

.msg-bubble {
  padding: 0.75rem 1rem;
  font-size: 0.9375rem;
  line-height: 1.6;
  border-radius: var(--radius-lg);
}

.message.user  .msg-bubble {
  background: var(--invert-bg);
  color: var(--invert-fg);
  border-bottom-right-radius: 4px;
}

/* Rehacer un mensaje propio. Discretos por defecto: aparecen al pasar el cursor
   sobre la burbuja, para no competir con el contenido. En pantallas táctiles,
   donde no hay hover, se ven siempre. */
.msg-actions {
  display: flex;
  gap: 0.25rem;
  justify-content: flex-end;
  margin-top: 0.4rem;
  opacity: 0;
  transition: opacity 0.15s;
}
.message.user:hover .msg-actions,
.message.user:focus-within .msg-actions { opacity: 1; }
@media (hover: none) { .msg-actions { opacity: 0.75; } }

.msg-act {
  border: none;
  background: rgba(255, 255, 255, 0.16);
  color: inherit;
  font-size: 0.8rem;
  line-height: 1;
  padding: 0.25rem 0.4rem;
  border-radius: 6px;
  cursor: pointer;
}
.msg-act:hover { background: rgba(255, 255, 255, 0.3); }

/* Aviso de edición, sobre el cuadro de escritura. */
.edit-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  font-size: 0.82rem;
  background: rgba(196, 154, 138, 0.14);
  border: 1px solid rgba(196, 154, 138, 0.35);
}
.edit-banner button {
  border: none;
  background: none;
  color: inherit;
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
  opacity: 0.8;
  flex-shrink: 0;
}

.message.agent .msg-bubble {
  background: var(--white);
  color: var(--dark);
  border-bottom-left-radius: 4px;
  box-shadow: var(--shadow-sm);
}

/* Imágenes adjuntas dentro del bubble de usuario */
.msg-imgs {
  display: flex;
  gap: 0.375rem;
  flex-wrap: wrap;
  margin-bottom: 0.375rem;
}

.msg-img-thumb {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  display: block;
  cursor: zoom-in;
  border: 1.5px solid rgba(255,255,255,0.2);
}

/* Markdown dentro del bubble */
.msg-bubble strong { font-weight: 700; }
.msg-bubble em { font-style: italic; }
.msg-bubble code {
  font-family: 'Courier New', monospace;
  font-size: 0.85em;
  background: rgba(0,0,0,0.07);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}
.message.user .msg-bubble code { background: rgba(255,255,255,0.18); }
.msg-bubble ul, .msg-bubble ol {
  padding-left: 1.25rem;
  margin: 0.25rem 0;
}
.msg-bubble li { margin-bottom: 0.2rem; }


/* ── Typing indicator ────────────────────────────────────────────────────── */

.typing-label {
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 0.3rem;
}

.typing-dots {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0.25rem 0;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--salmon);
  animation: bounce 1.3s infinite ease-in-out;
}

.dot:nth-child(2) { animation-delay: 0.18s; }
.dot:nth-child(3) { animation-delay: 0.36s; }

@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.8; }
  30%            { transform: translateY(-7px); opacity: 1; }
}


/* ── Generating badge ────────────────────────────────────────────────────── */

.gen-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.625rem 1rem;
  background: var(--bg);
  border: 1.5px solid var(--pink-light);
  border-radius: 14px;
  font-size: 0.875rem;
  color: var(--muted);
}

.gen-text {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  line-height: 1.35;
}

.gen-elapsed {
  color: var(--salmon);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.gen-hint {
  font-size: 0.75rem;
  opacity: 0.7;
}

.gen-badge--warn {
  /* Tinte de aviso translúcido: funciona sobre fondo claro y oscuro. */
  border-color: rgba(224, 180, 160, 0.55);
  background: rgba(224, 180, 160, 0.16);
}

.gen-spinner {
  width: 13px;
  height: 13px;
  border: 2px solid var(--pink-light);
  border-top-color: var(--salmon);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
  flex-shrink: 0;
}

.gen-logs-link {
  margin-left: 0.25rem;
  color: var(--salmon);
  font-size: 0.8rem;
  text-decoration: none;
  white-space: nowrap;
  opacity: 0.85;
}
.gen-logs-link:hover { opacity: 1; text-decoration: underline; }

/* ── Identidad, compartir y avisos ────────────────────────────────────────── */
.cg-whoami {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.4rem 0.75rem 0.6rem;
  font-size: 0.74rem;
  color: var(--muted);
  min-width: 0;
}
.whoami-dot { width: 7px; height: 7px; border-radius: 50%; flex: 0 0 auto; }
.whoami-dot.ok   { background: #2e9e5b; }
.whoami-dot.warn { background: #E0A100; }
.whoami-mail { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.whoami-login {
  margin-left: auto;
  flex: 0 0 auto;
  font-family: inherit;
  font-size: 0.7rem;
  padding: 0.2rem 0.5rem;
  color: var(--on-accent);
  background: var(--salmon);
  border: none;
  border-radius: 999px;
  cursor: pointer;
}
.whoami-login:hover { opacity: 0.9; }

.history-share-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0.15rem 0.3rem;
  border-radius: var(--radius-sm);
  opacity: 0.65;
  transition: var(--transition);
}
.history-share-btn:hover { opacity: 1; background: var(--pink-light); }

.shared-banner {
  margin: 0 0 1rem;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-md);
  background: rgba(196, 154, 138, 0.12);
  border: 1px solid rgba(196, 154, 138, 0.4);
}
.shared-banner-title { font-weight: 600; font-size: 0.9rem; }
.shared-banner-sub   { font-size: 0.8rem; color: var(--muted); margin: 0.2rem 0 0.6rem; }

/* Turno del chat compartido: aviso de que otra persona lo tiene. */
.lock-banner {
  margin: 0.6rem 0;
  padding: 0.7rem 0.9rem;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  background: rgba(224, 161, 0, 0.12);
  border: 1px solid rgba(224, 161, 0, 0.45);
}

/* Autoría dentro de un chat compartido: se escribe entre varios. */
.msg-author {
  font-size: 0.7rem;
  font-weight: 600;
  opacity: 0.75;
  margin-bottom: 0.2rem;
  text-transform: lowercase;
}
.history-shared-tag {
  font-size: 0.68rem;
  color: var(--salmon);
  white-space: nowrap;
  padding: 0.1rem 0.35rem;
  border: 1px solid rgba(196, 154, 138, 0.4);
  border-radius: 999px;
}

.cg-toast {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  transform: translateX(-50%);
  z-index: 9999;
  max-width: min(90vw, 460px);
  padding: 0.7rem 1rem;
  border-radius: var(--radius-md);
  background: var(--invert-bg);
  color: var(--invert-fg);
  font-size: 0.85rem;
  box-shadow: var(--shadow-md);
  opacity: 1;
  transition: opacity 0.3s ease;
}
.cg-toast.is-out { opacity: 0; }

/* ── Vista: Configuración ─────────────────────────────────────────────────── */
.cfg-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.cfg-card {
  background: var(--white);
  border: 1px solid rgba(196, 154, 138, 0.25);
  border-radius: var(--radius-lg);
  padding: 1.1rem 1.2rem;
  box-shadow: var(--shadow-sm);
}
.cfg-title { font-size: 1rem; margin-bottom: 0.5rem; }
.cfg-hint  { font-size: 0.8rem; color: var(--muted); line-height: 1.5; margin-bottom: 0.7rem; }
.cfg-block { margin-bottom: 1.1rem; }
.cfg-block:last-child { margin-bottom: 0; }
.cfg-block-title { font-weight: 600; font-size: 0.88rem; margin-bottom: 0.45rem; }

/* Selector segmentado (tema / idioma) */
.cfg-seg { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.cfg-seg-btn {
  flex: 1 1 auto;
  padding: 0.5rem 0.7rem;
  font-size: 0.85rem;
  font-family: inherit;
  color: var(--dark);
  background: var(--bg);
  border: 1px solid rgba(196, 154, 138, 0.35);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
}
.cfg-seg-btn:hover  { border-color: var(--salmon); }
.cfg-seg-btn.active { background: var(--salmon); color: var(--on-accent); border-color: var(--salmon); }

/* Tarjetas de modelo */
.cfg-model {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
  padding: 0.65rem 0.75rem;
  margin-bottom: 0.45rem;
  border: 1px solid rgba(196, 154, 138, 0.3);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition);
}
.cfg-model:hover { border-color: var(--salmon); }
.cfg-model.is-selected { border-color: var(--salmon); background: rgba(196, 154, 138, 0.10); }
.cfg-model.is-locked   { opacity: 0.55; cursor: not-allowed; }
.cfg-model input { margin-top: 0.2rem; accent-color: var(--salmon); }
.cfg-model-body { flex: 1; min-width: 0; }
.cfg-model-top  { display: flex; justify-content: space-between; gap: 0.6rem; align-items: baseline; }
.cfg-model-name { font-weight: 600; font-size: 0.88rem; }
.cfg-model-cost { font-size: 0.78rem; color: var(--salmon); font-variant-numeric: tabular-nums; white-space: nowrap; }
.cfg-model-note { font-size: 0.78rem; color: var(--muted); line-height: 1.45; margin-top: 0.15rem; }
.cfg-model-lock { font-size: 0.76rem; color: var(--danger); margin-top: 0.3rem; }

/* Etiquetas del estado de un modelo. Van junto al nombre y no en la nota de
   abajo: el riesgo tiene que verse AL ELEGIR, no al leer la letra chica. */
.cfg-badge {
  display: inline-block; margin-left: 0.4rem; padding: 0.08rem 0.4rem;
  border-radius: 999px; font-size: 0.66rem; font-weight: 600;
  letter-spacing: 0.02em; text-transform: uppercase; vertical-align: middle;
  border: 1px solid currentColor;
}
.cfg-badge--preview { color: #B4690E; }
.cfg-badge--legado  { color: #8A6D3B; }
:root:not([data-theme="light"]) .cfg-badge--preview { color: #E0A052; }
:root:not([data-theme="light"]) .cfg-badge--legado  { color: #C4A582; }
:root[data-theme="dark"] .cfg-badge--preview { color: #E0A052; }
:root[data-theme="dark"] .cfg-badge--legado  { color: #C4A582; }

/* Credenciales */
.cfg-cred { padding: 0.7rem 0; border-top: 1px solid rgba(196, 154, 138, 0.2); }
.cfg-cred:first-of-type { border-top: none; }
.cfg-cred-head { display: flex; justify-content: space-between; gap: 0.6rem; align-items: baseline; margin-bottom: 0.4rem; }
.cfg-cred-label { font-weight: 600; font-size: 0.86rem; }
.cfg-cred-state { font-size: 0.78rem; font-variant-numeric: tabular-nums; }
.cfg-cred-state.ok      { color: var(--salmon); }
.cfg-cred-state.missing { color: var(--muted); }
.cfg-cred-row { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.cfg-input {
  flex: 1 1 180px;
  min-width: 0;
  padding: 0.45rem 0.6rem;
  font-family: inherit;
  font-size: 0.82rem;
  color: var(--dark);
  background: var(--bg);
  border: 1px solid rgba(196, 154, 138, 0.35);
  border-radius: var(--radius-sm);
}
.cfg-input:focus { outline: none; border-color: var(--salmon); }
.cfg-cred-row .btn-primary, .cfg-cred-row .btn-ghost { padding: 0.45rem 0.8rem; font-size: 0.82rem; }

/* Aviso de saldo bajo en la pantalla de Inicio */
.alert-banner {
  margin-bottom: 1rem;
  padding: 0.85rem 1rem;
  border-radius: 10px;
  font-size: 0.88rem;
}
.alert-banner--danger {
  background: rgba(206, 45, 79, 0.08);
  border: 1px solid rgba(206, 45, 79, 0.35);
}
.alert-banner--warn {
  background: rgba(196, 154, 138, 0.10);
  border: 1px solid rgba(196, 154, 138, 0.35);
}
.alert-title { font-weight: 600; margin-bottom: 0.4rem; }
.alert-list  { margin: 0.3rem 0 0.5rem 1.1rem; padding: 0; }
.alert-list li { margin: 0.2rem 0; }
.alert-hint  { font-size: 0.82rem; opacity: 0.8; line-height: 1.5; }
.alert-cta {
  color: var(--salmon, #C49A8A);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
.alert-cta:hover { text-decoration: underline; }

/* Confirmación de costo antes de generar (pedidos de 5+ imágenes) */
.cost-confirm .card-title,
.cost-blocked .card-title { font-weight: 600; }
.cost-lead { margin: 0 0 0.6rem; font-size: 0.9rem; }
.cost-list { margin: 0 0 0.8rem 1.1rem; padding: 0; font-size: 0.85rem; opacity: 0.9; }
.cost-list li { margin: 0.15rem 0; }
.cost-grid {
  display: grid;
  gap: 0.35rem;
  margin-bottom: 0.8rem;
  padding: 0.7rem 0.8rem;
  border-radius: 10px;
  background: rgba(196, 154, 138, 0.08);
  border: 1px solid rgba(196, 154, 138, 0.25);
}
.cost-grid > div { display: flex; justify-content: space-between; gap: 1rem; font-size: 0.85rem; }
.cost-grid b { font-variant-numeric: tabular-nums; }
.cost-total {
  margin-top: 0.25rem;
  padding-top: 0.4rem;
  border-top: 1px solid rgba(196, 154, 138, 0.3);
  font-size: 0.95rem !important;
}
.cost-total b { color: var(--salmon, #C49A8A); font-size: 1.05rem; }
.cost-checks { margin: 0 0 0.7rem; padding: 0; list-style: none; font-size: 0.8rem; }
.cost-checks li { margin: 0.15rem 0; }
.chk-ok  { opacity: 0.7; }
.chk-bad { color: #CE2D4F; font-weight: 600; }
.cost-note { margin: 0 0 0.8rem; font-size: 0.78rem; opacity: 0.65; }
.cost-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.cost-closed { font-size: 0.85rem; opacity: 0.8; }

/* Caja de entrega única: todas las piezas de una misma petición (imágenes,
   videos, reels) caen aquí dentro en vez de crear un cuadro por pieza. */
.delivery-box .card-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.delivery-box .card-title .gen-spinner {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
}
.delivery-hint {
  font-size: 0.8rem;
  opacity: 0.75;
}
.delivery-counter {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.delivery-warn {
  margin: 0.5rem 0;
  padding: 0.5rem 0.7rem;
  border-radius: 8px;
  font-size: 0.85rem;
  background: rgba(206, 45, 79, 0.07);
  border: 1px solid rgba(206, 45, 79, 0.25);
}
/* Fallo accionable (ej: sin créditos): motivo real + botón para resolverlo. */
.delivery-warn--action { padding: 0.8rem 0.9rem; }

/* Video en camino. En ámbar, NO en rojo: no falló nada — la generación sigue
   corriendo del lado del proveedor. Pintarlo de rojo diría lo contrario. */
.delivery-warn--pending {
  padding: 0.8rem 0.9rem;
  background: rgba(196, 154, 138, 0.10);
  border-color: rgba(196, 154, 138, 0.35);
}
.delivery-warn--pending code {
  font-size: 0.72rem;
  padding: 0.05rem 0.3rem;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.06);
}
.warn-title { font-weight: 600; margin-bottom: 0.3rem; }
.warn-text  { opacity: 0.85; margin-bottom: 0.6rem; line-height: 1.45; }
.warn-cta {
  display: inline-block;
  text-decoration: none;
  font-size: 0.85rem;
  padding: 0.45rem 0.9rem;
}
.warn-hint { margin-top: 0.5rem; font-size: 0.78rem; opacity: 0.65; }

/* En la confirmación, lo facturable se distingue de lo que se entrega. */
.cost-calls { opacity: 0.7; }

/* Entrega incremental: miniaturas de las piezas que ya se generaron, mientras
   el resto sigue en proceso. */
.gen-progress {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.6rem;
}
.gen-thumb {
  width: 64px;
  height: 64px;
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg);
  border: 1px solid rgba(196, 154, 138, 0.35);
  flex: 0 0 auto;
}
.gen-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gen-thumb-ph {
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, rgba(196,154,138,0.10) 25%, rgba(196,154,138,0.22) 50%, rgba(196,154,138,0.10) 75%);
  background-size: 200% 100%;
  animation: genThumbShimmer 1.2s ease-in-out infinite;
}
@keyframes genThumbShimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}


/* ════════════════════════════════════════════════════════════════════════════
   CONTENT CARDS
════════════════════════════════════════════════════════════════════════════ */

.content-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  max-width: 680px;
  width: 100%;
  align-self: center;
  border: 1px solid var(--pink-light);
  flex-shrink: 0; /* en el flex column de #messages, overflow:hidden la encogía a una línea */
}

.card-header {
  padding: 1rem 1.25rem;
  background: var(--invert-bg);
  color: var(--invert-fg);
  cursor: pointer;
  user-select: none;
}

.card-header:hover { opacity: 0.95; }

.card-header-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.25rem;
}

.card-header-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.card-chevron {
  display: flex;
  align-items: center;
  opacity: 0.6;
  transition: transform 0.25s ease;
}

.card-body {
  overflow: hidden;
  max-height: 5000px;
  transition: max-height 0.35s ease;
}

.content-card.collapsed .card-body {
  max-height: 0;
}

.card-title {
  font-size: 0.9375rem;
  font-weight: 700;
}

.card-date {
  font-size: 0.8125rem;
  opacity: 0.6;
  white-space: nowrap;
}

.card-theme {
  font-size: 0.8125rem;
  opacity: 0.75;
}

/* Content item inside card */
.content-item {
  padding: 1.25rem;
  border-bottom: 1px solid var(--pink-light);
}

.content-item:last-child { border-bottom: none; }

.item-header {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  cursor: pointer;
  user-select: none;
  padding: 0.125rem 0;
}

.item-header:hover .item-subtype { color: var(--salmon); }

.item-num {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--salmon);
  color: var(--white);
  font-size: 0.75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.item-subtype {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--dark);
}

.item-format {
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.2rem 0.625rem;
  border-radius: 999px;
  background: var(--pink-light);
  color: var(--muted);
  white-space: nowrap;
}

/* Image grid (3 variations) */
.img-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.img-thumb {
  aspect-ratio: 9/16;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--bg);
  cursor: pointer;
  position: relative;
  border: 1px solid var(--pink-light);
}

.img-btn-overlay {
  position: absolute;
  bottom: 0.5rem;
  right: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  z-index: 2;
}

.img-dl-btn,
.img-quote-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.88);
  border: none;
  font-size: 0.875rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, transform 0.12s;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  box-shadow: 0 1px 4px rgba(0,0,0,0.18);
}

.img-dl-btn:hover:not(:disabled)    { background: var(--white); transform: scale(1.1); }
.img-quote-btn:hover:not(:disabled) { background: var(--white); transform: scale(1.1); }
.img-dl-btn:disabled,
.img-quote-btn:disabled             { opacity: 0; cursor: default; }

.img-overlay {
  position: absolute;
  inset: 0;
  background: rgba(61, 43, 31, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: var(--transition);
  color: white;
  font-size: 1.4rem;
}

.img-thumb:hover .img-overlay { opacity: 1; }

.img-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.2s;
}

.img-thumb:hover img { transform: scale(1.03); }

/* Video corto (Reel/Story) dentro de la tarjeta */
.video-thumb { cursor: pointer; }

/* Capa para ampliar el video. Deja libres los 44px de abajo: ahí viven los
   controles nativos del <video>, y taparlos rompería play/pausa y volumen. */
.video-zoom {
  position: absolute;
  inset: 0 0 44px 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(61, 43, 31, 0.35);
  color: white;
  font-size: 1.4rem;
  opacity: 0;
  transition: var(--transition);
}

.video-thumb:hover .video-zoom { opacity: 1; }
.video-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  background: #000;
}

.img-loading {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 0.75rem;
  flex-direction: column;
  gap: 0.5rem;
}

.img-loading-spin {
  width: 18px;
  height: 18px;
  border: 2px solid var(--pink-light);
  border-top-color: var(--salmon);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

/* Caption & hashtags */
.item-caption {
  font-size: 0.875rem;
  color: var(--dark);
  line-height: 1.65;
  margin-bottom: 0.625rem;
  white-space: pre-wrap;
}

.item-hashtags {
  font-size: 0.8125rem;
  color: var(--salmon);
  line-height: 1.55;
  margin-bottom: 1rem;
  word-break: break-word;
}

/* Botón de copiar caption mostrado inline en la tarjeta (no solo en el modal) */
.item-copy-inline {
  margin-top: 0.25rem;
}

/* Action buttons */
.item-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.btn-action {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.4375rem 0.875rem;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: var(--transition);
  border: 1.5px solid var(--pink-light);
  background: none;
  color: var(--muted);
}

.btn-action:hover {
  border-color: var(--salmon);
  color: var(--dark);
  background: var(--bg);
}

.btn-action.copied {
  border-color: var(--salmon);
  color: var(--salmon);
}

/* Item open icon */
.item-open-icon {
  margin-left: auto;
  display: flex;
  align-items: center;
  opacity: 0.4;
  transition: opacity 0.15s, color 0.15s;
  flex-shrink: 0;
}
.item-header:hover .item-open-icon { opacity: 1; color: var(--salmon); }

/* ── Quantity picker ─────────────────────────────────────────────────────── */
.qty-modal {
  position: fixed;
  inset: 0;
  z-index: 950;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.qty-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(61, 43, 31, 0.45);
  backdrop-filter: blur(3px);
}

.qty-box {
  position: relative;
  z-index: 1;
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: 0 16px 48px rgba(61, 43, 31, 0.2);
  padding: 1.75rem 2rem;
  width: 100%;
  max-width: 340px;
  text-align: center;
}

.qty-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--dark);
  margin-bottom: 0.5rem;
}

.qty-sub {
  font-size: 0.875rem;
  color: var(--muted);
  margin-bottom: 1.5rem;
}

.qty-btns {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
}

.qty-btn {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-md);
  border: 2px solid var(--pink-light);
  background: var(--bg);
  font-size: 1.375rem;
  font-weight: 700;
  color: var(--dark);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
  font-family: inherit;
}

.qty-btn:hover {
  border-color: var(--salmon);
  background: var(--salmon);
  color: var(--white);
}

/* ── Content menu (popup "Generar Contenido para Hoy") ───────────────────── */
.cmenu-modal {
  position: fixed;
  inset: 0;
  z-index: 950;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.cmenu-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(61, 43, 31, 0.45);
  backdrop-filter: blur(3px);
}

.cmenu-box {
  position: relative;
  z-index: 1;
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: 0 16px 48px rgba(61, 43, 31, 0.2);
  padding: 1.25rem 1.25rem 1.5rem;
  width: 100%;
  max-width: 360px;
}

.cmenu-box--loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.875rem;
  padding: 2rem 1.5rem;
}

.cmenu-loading-text {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--dark);
  text-align: center;
}

.cmenu-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.cmenu-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--dark);
}

.cmenu-close {
  background: none;
  border: none;
  font-size: 1rem;
  color: var(--muted);
  cursor: pointer;
  padding: 0.25rem;
  line-height: 1;
  border-radius: var(--radius-sm);
  transition: color 0.15s;
}
.cmenu-close:hover { color: var(--dark); }

.cmenu-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.cmenu-sub {
  margin: 0 0 0.25rem;
  font-size: 0.8125rem;
  color: var(--muted);
  line-height: 1.4;
}

.cmenu-opt {
  width: 100%;
  text-align: left;
  padding: 0.75rem 1rem;
  background: var(--bg);
  border: 1.5px solid var(--pink-light);
  border-radius: var(--radius-md);
  font-size: 0.9375rem;
  font-family: inherit;
  color: var(--dark);
  cursor: pointer;
  transition: var(--transition);
}

.cmenu-opt:hover {
  background: var(--pink-light);
  border-color: var(--salmon);
}

/* Opción destacada del evento de hoy */
.cmenu-opt--event {
  background: var(--salmon);
  border-color: var(--salmon);
  color: var(--white);
  font-weight: 600;
}

/* Etiqueta del deporte destacado (torneo activo / temporada) */
.cmenu-badge {
  display: inline-block;
  margin-left: 0.4rem;
  padding: 0.05rem 0.4rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.25);
  font-size: 0.6875rem;
  font-weight: 600;
  vertical-align: middle;
  white-space: nowrap;
}
.cmenu-opt--event:hover {
  filter: brightness(0.96);
  background: var(--salmon);
}

/* ── Item modal ──────────────────────────────────────────────────────────── */
.item-modal {
  position: fixed;
  inset: 0;
  z-index: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.item-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(61, 43, 31, 0.55);
  backdrop-filter: blur(4px);
}

.item-modal-content {
  position: relative;
  z-index: 1;
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 60px rgba(61, 43, 31, 0.25);
  max-width: 720px;
  width: 100%;
  max-height: 90dvh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.item-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--pink-light);
  position: sticky;
  top: 0;
  background: var(--white);
  z-index: 1;
}

.item-modal-title {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  font-size: 0.9375rem;
}

.item-modal-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  display: flex;
  align-items: center;
  padding: 0.25rem;
  border-radius: var(--radius-sm);
  transition: color 0.15s;
  flex-shrink: 0;
}
.item-modal-close:hover { color: var(--dark); }

.item-modal-actions-hdr {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-shrink: 0;
}

/* Botón expandir (▲) — solo visible en estado minimizado */
.item-modal-restore {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  align-items: center;
  padding: 0.25rem;
  border-radius: var(--radius-sm);
  transition: color 0.15s;
  flex-shrink: 0;
}
.item-modal-restore:hover { color: var(--dark); }
.item-modal.minimized .item-modal-restore { display: flex; }

.item-modal-body {
  padding: 1.25rem;
}

/* Estado minimizado: al abrir el lightbox, el modal se reduce a la esquina inferior derecha */
.item-modal.minimized {
  inset: auto 1.25rem 1.25rem auto;
  width: auto;
  height: auto;
  padding: 0;
  z-index: 210; /* por encima del lightbox (200) */
  pointer-events: none;
}

.item-modal.minimized .item-modal-backdrop {
  display: none;
}

.item-modal.minimized .item-modal-content {
  width: 280px;
  pointer-events: auto;
  box-shadow: 0 12px 40px rgba(61, 43, 31, 0.5);
}

/* Solo el header (barra de título) queda visible al minimizar */
.item-modal.minimized .item-modal-body {
  display: none;
}

.item-modal.minimized .item-modal-header {
  border-bottom: none;
}

/* ════════════════════════════════════════════════════════════════════════════
   INPUT AREA
════════════════════════════════════════════════════════════════════════════ */

.input-area {
  padding: 0.875rem 1.25rem 1rem;
  border-top: 1px solid var(--pink-light);
  background: var(--white);
  flex-shrink: 0;
}

.input-box {
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border: 1.5px solid var(--pink-light);
  border-radius: var(--radius-md);
  transition: border-color 0.18s;
  overflow: hidden;
}

.input-box:focus-within { border-color: var(--salmon); }

/* Strip de previsualización de imágenes adjuntas */
#img-preview-strip {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding: 0.5rem 0.5rem 0.375rem;
  border-bottom: 1px solid var(--pink-light);
}

.preview-item {
  position: relative;
  width: 56px;
  height: 56px;
  flex-shrink: 0;
}

.preview-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--pink-light);
  display: block;
}

.preview-remove {
  position: absolute;
  top: -5px;
  right: -5px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: none;
  background: var(--invert-bg);
  color: var(--invert-fg);
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.preview-remove:hover { background: var(--danger); }

/* Fila de controles: botón adjuntar + textarea + enviar */
.input-row {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  padding: 0.5rem;
}

.attach-btn {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  cursor: pointer;
  color: var(--muted);
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.attach-btn:hover { background: var(--pink-light); color: var(--dark); }

.message-input {
  flex: 1;
  padding: 0.25rem 0;
  border: none;
  background: none;
  font-size: 0.9375rem;
  font-family: inherit;
  color: var(--dark);
  resize: none;
  outline: none;
  max-height: 160px;
  min-height: 28px;
  line-height: 1.55;
}

.message-input::placeholder { color: var(--muted); opacity: 0.7; }

.send-btn {
  width: 36px;
  height: 36px;
  background: var(--invert-bg);
  color: var(--invert-fg);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  flex-shrink: 0;
}

.send-btn:hover:not(:disabled) { background: var(--salmon); }
.send-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.input-hint {
  font-size: 0.725rem;
  color: var(--muted);
  opacity: 0.65;
  margin-top: 0.375rem;
  text-align: right;
}


/* ════════════════════════════════════════════════════════════════════════════
   LIGHTBOX
════════════════════════════════════════════════════════════════════════════ */

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(20, 10, 5, 0.9);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 1.5rem;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.lightbox.hidden { display: none; }

.lightbox-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 40px;
  height: 40px;
  background: rgba(255,255,255,0.12);
  border: none;
  border-radius: 50%;
  color: var(--white);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.lightbox-close:hover { background: rgba(255,255,255,0.22); }

#lightbox-img {
  max-width: min(100%, 400px);
  max-height: 80dvh;
  border-radius: var(--radius-md);
  object-fit: contain;
  box-shadow: 0 8px 40px rgba(0,0,0,0.5);
}

#lightbox-video {
  max-width: min(100%, 400px);
  max-height: 80dvh;
  border-radius: var(--radius-md);
  background: #000;
  box-shadow: 0 8px 40px rgba(0,0,0,0.5);
}

.lightbox-caption {
  margin-top: 0.875rem;
  font-size: 0.8125rem;
  color: rgba(255,255,255,0.65);
  text-align: center;
}


/* ════════════════════════════════════════════════════════════════════════════
   HISTORY DRAWER
════════════════════════════════════════════════════════════════════════════ */

.history-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(61, 43, 31, 0.35);
  z-index: 99;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

.history-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 360px;
  max-width: 100vw;
  background: var(--white);
  z-index: 100;
  display: flex;
  flex-direction: column;
  box-shadow: -4px 0 24px rgba(61, 43, 31, 0.14);
}

.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--pink-light);
  flex-shrink: 0;
}

.history-title {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--dark);
}

.history-close {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  cursor: pointer;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.history-close:hover { background: var(--pink-light); color: var(--dark); }

.history-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem 0;
}

.history-list::-webkit-scrollbar { width: 4px; }
.history-list::-webkit-scrollbar-track { background: transparent; }
.history-list::-webkit-scrollbar-thumb { background: var(--pink-light); border-radius: 99px; }

.history-loading,
.history-empty {
  padding: 2rem 1.25rem;
  text-align: center;
  font-size: 0.875rem;
  color: var(--muted);
  line-height: 1.6;
}

/* History item */
.history-item {
  border-bottom: 1px solid var(--pink-light);
}

.history-item:last-child { border-bottom: none; }

.history-item-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.875rem 1.25rem 0;
  cursor: pointer;
  transition: background 0.15s;
}

.history-item-header:hover { background: var(--bg); }

.history-item-meta {
  flex: 1;
  min-width: 0;
}

.history-item-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--dark);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-item-date {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.125rem;
}

.history-item-actions {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  flex-shrink: 0;
}

.history-del-btn {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.history-del-btn:hover { background: var(--danger); color: white; }

.history-chevron {
  font-size: 0.75rem;
  color: var(--muted);
  user-select: none;
}

.history-item-preview {
  padding: 0.25rem 1.25rem 0.875rem;
  font-size: 0.8125rem;
  color: var(--muted);
  line-height: 1.5;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Expanded messages inside history item */
.history-item-body {
  padding: 0 1rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.history-msg {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
}

.history-msg-avatar {
  font-size: 0.875rem;
  flex-shrink: 0;
  margin-top: 0.2rem;
}

.history-msg-content {
  font-size: 0.8125rem;
  line-height: 1.55;
  color: var(--dark);
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  flex: 1;
  min-width: 0;
  word-break: break-word;
}

.history-msg-assistant .history-msg-content {
  background: var(--pink-light);
}

/* Footer */
.history-footer {
  padding: 0.875rem 1.25rem;
  border-top: 1px solid var(--pink-light);
  flex-shrink: 0;
}

.btn-danger-ghost {
  width: 100%;
  padding: 0.5rem;
  background: none;
  border: 1.5px solid var(--pink-light);
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  font-family: inherit;
  color: var(--muted);
  cursor: pointer;
  transition: var(--transition);
}

.btn-danger-ghost:hover {
  border-color: var(--danger);
  color: var(--danger);
  background: rgba(206, 45, 79, 0.05);
}

/* ════════════════════════════════════════════════════════════════════════════
   DASHBOARDS
════════════════════════════════════════════════════════════════════════════ */

.dash { max-width: 920px; margin: 0 auto; }

.dash-head { margin-bottom: 1.25rem; }
.dash-title { font-size: 1.25rem; font-weight: 700; color: var(--dark); }
.dash-sub { font-size: 0.9375rem; color: var(--muted); margin-top: 0.25rem; }

.dash-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.875rem;
  margin-bottom: 1.25rem;
}

.stat-card {
  background: var(--white);
  border: 1px solid var(--pink-light);
  border-radius: var(--radius-md);
  padding: 1rem 1.125rem;
  box-shadow: var(--shadow-sm);
}
.stat-label { font-size: 0.8125rem; color: var(--muted); margin-bottom: 0.375rem; }
.stat-value { font-size: 1.5rem; font-weight: 700; color: var(--dark); }
.stat-foot  { font-size: 0.75rem; color: var(--muted); margin-top: 0.375rem; }

/* Barra de % de uso */
.usage-bar-wrap {
  height: 12px;
  background: var(--pink-light);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 0.4rem;
}
.usage-bar {
  height: 100%;
  background: var(--salmon);
  border-radius: 999px;
  transition: width 0.4s ease;
}
.usage-bar--warn { background: #E0A100; }
.usage-bar--over { background: var(--danger); }
.usage-bar-cap { font-size: 0.8125rem; color: var(--muted); margin-bottom: 1rem; }

/* Control de presupuesto */
.budget-ctl {
  background: var(--white);
  border: 1px solid var(--pink-light);
  border-radius: var(--radius-md);
  padding: 1rem 1.125rem;
  margin-bottom: 1.25rem;
}
.budget-label { display: block; font-size: 0.8125rem; color: var(--muted); margin-bottom: 0.5rem; }
.budget-row { display: flex; gap: 0.5rem; }
.budget-input {
  flex: 1;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--pink-light);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.9375rem;
  color: var(--dark);
}
.budget-input:focus { outline: none; border-color: var(--salmon); }

.usage-h3 { font-size: 0.95rem; font-weight: 700; color: var(--dark); margin: 0.5rem 0 0.625rem; }

/* Funnel GA4 */
.funnel-row { margin-bottom: 0.875rem; }
.funnel-head {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 0.35rem; gap: 0.5rem;
}
.funnel-name { font-size: 0.9375rem; font-weight: 600; color: var(--dark); }
.funnel-val  { font-size: 0.9375rem; font-weight: 700; color: var(--dark); white-space: nowrap; }
.funnel-step { font-size: 0.75rem; font-weight: 500; color: var(--muted); margin-left: 0.35rem; }

/* Filtros del dashboard (rango de tiempo + granularidad día/hora) */
.dash-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  margin-bottom: 1.25rem;
}
.filter-group { display: flex; align-items: center; gap: 0.5rem; }
.filter-label { font-size: 0.8125rem; color: var(--muted); font-weight: 600; }
.seg {
  display: inline-flex;
  background: var(--pink-light);
  border-radius: 999px;
  padding: 3px;
}
.seg button {
  border: none;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.seg button.active { background: var(--white); color: var(--dark); box-shadow: var(--shadow-sm); }
.seg button:hover:not(.active) { color: var(--dark); }

/* Botón de periodo (abre el selector tipo Datadog) */
.picker-btn {
  border: 1px solid var(--pink-light);
  background: var(--white);
  color: var(--dark);
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s ease;
}
.picker-btn:hover { border-color: var(--salmon); }

/* Selector de periodo (modal) */
.picker-box { max-width: 420px; }
.picker-hdr { font-size: 1rem; font-weight: 700; color: var(--dark); margin-bottom: 0.875rem; }
.picker-presets { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.5rem; margin-bottom: 1rem; }
.picker-preset {
  border: 1px solid var(--pink-light);
  background: var(--white);
  color: var(--dark);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.picker-preset:hover { background: var(--pink-light); }
.picker-preset.active { background: var(--salmon); color: #fff; border-color: var(--salmon); }
.picker-sec { border-top: 1px solid var(--pink-light); padding-top: 0.875rem; margin-top: 0.5rem; }
.picker-sec-t { font-size: 0.8125rem; font-weight: 600; color: var(--muted); margin-bottom: 0.5rem; }
.picker-dates, .picker-hours { display: flex; gap: 0.75rem; flex-wrap: wrap; }
.picker-dates label, .picker-hours label { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.8125rem; color: var(--muted); }
.picker-dates input, .picker-hours select {
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--pink-light);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.875rem;
  color: var(--dark);
  background: var(--white);
}
.picker-dates input:focus, .picker-hours select:focus { outline: none; border-color: var(--salmon); }
.picker-hours-toggle { display: flex; align-items: center; gap: 0.5rem; font-size: 0.875rem; color: var(--dark); cursor: pointer; margin-bottom: 0.625rem; }
.picker-actions { display: flex; justify-content: flex-end; gap: 0.625rem; margin-top: 1.25rem; }

/* Visualización (día/hora/hora exacta/tiempo real) dentro del selector */
.picker-gran { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.picker-gbtn {
  border: 1px solid var(--pink-light);
  background: var(--white);
  color: var(--dark);
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  padding: 0.45rem 0.8rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.picker-gbtn:hover { border-color: var(--salmon); }
.picker-gbtn.active { background: var(--salmon); color: #fff; border-color: var(--salmon); }
.picker-gbtn--rt.active { background: #2e9e5b; border-color: #2e9e5b; }

/* Cuadrícula de gráficos (dashboard) */
.chart-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-top: 1.25rem;
}
@media (max-width: 760px) { .chart-grid { grid-template-columns: 1fr; } }
.chart-card {
  background: var(--white);
  border: 1px solid var(--pink-light);
  border-radius: var(--radius-md);
  padding: 1rem 1.125rem 1.125rem;
  display: flex;
  flex-direction: column;
}
.chart-title { font-size: 0.95rem; font-weight: 700; color: var(--dark); margin: 0 0 0.875rem; }
.chart-body { flex: 1; }
.chart-svg { width: 100%; height: auto; display: block; }
.chart-foot { font-size: 0.8125rem; color: var(--muted); margin: 0.75rem 0 0; }
.chart-axis { font-size: 9px; fill: var(--muted); }

/* Selección de rango (brush) sobre gráficos de línea */
.chart-interactive { position: relative; }
.brush-ovl { cursor: crosshair; }
.brush-readout { font-size: 0.8125rem; color: var(--dark); margin-top: 0.5rem; min-height: 1.4em; display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.brush-hint { color: var(--muted); font-style: italic; }
.brush-info strong { color: var(--dark); }
.brush-clear {
  border: none;
  background: var(--pink-light);
  color: var(--muted);
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  cursor: pointer;
}
.brush-clear:hover { color: var(--dark); }
.chart-empty {
  display: flex; align-items: center; justify-content: center; text-align: center;
  min-height: 120px; padding: 0.5rem; color: var(--muted); font-size: 0.875rem;
}
.chart-note {
  font-size: 0.75rem; color: var(--muted);
  background: var(--pink-light);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.6rem;
  margin-bottom: 0.625rem;
}

/* Dona */
.donut-wrap { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.donut-svg { width: 120px; height: 120px; flex: 0 0 auto; }
.donut-center { font-size: 22px; font-weight: 700; fill: var(--dark); }
.donut-legend { flex: 1; min-width: 140px; display: flex; flex-direction: column; gap: 0.4rem; }
.legend-item { display: flex; align-items: center; gap: 0.4rem; font-size: 0.875rem; color: var(--dark); }
.legend-dot { width: 10px; height: 10px; border-radius: 3px; flex: 0 0 auto; }
.legend-txt { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend-pct { color: var(--muted); }

/* Recomendaciones (Insights) */
.insight-headline {
  background: var(--pink-light);
  border-radius: var(--radius-md);
  padding: 0.875rem 1.125rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--dark);
  margin-bottom: 1.25rem;
}
.insight-item { padding: 0.625rem 0; border-bottom: 1px solid var(--pink-light); }
.insight-item:last-child { border-bottom: none; }
.insight-item__t { font-size: 0.9375rem; font-weight: 700; color: var(--dark); margin-bottom: 0.2rem; }
.insight-item__d { font-size: 0.875rem; color: var(--muted); line-height: 1.5; }
.btn-idea-gen {
  margin-top: 0.5rem;
  background: var(--salmon);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 0.4rem 0.875rem;
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s ease;
}
.btn-idea-gen:hover { opacity: 0.88; }

/* Cajón del analista: panel lateral derecho, de alto completo y ensanchable.
   Lo usan Recomendaciones y Fichas de producto (el chat dejó de vivir dentro
   de la vista). */
.analista-drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 60;
  width: min(440px, 100vw);
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--white);
  border-left: 1px solid var(--pink-light);
  box-shadow: -8px 0 28px rgb(0 0 0 / 0.14);
  transition: width 0.18s ease;
}
.analista-drawer.wide { width: min(920px, 100vw); }
/* OBLIGATORIO: el `display:flex` de arriba es de autor y le gana al
   `[hidden] { display:none }` del navegador — sin esta regla el cajón queda
   visible siempre, incluso cerrado. */
.analista-drawer[hidden] { display: none; }
.ad-ctx[hidden] { display: none; }
.ad-hdr {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.85rem 0.75rem 0.85rem 1.125rem;
  border-bottom: 1px solid var(--pink-light);
}
.ad-title { flex: 1; font-size: 0.95rem; font-weight: 700; color: var(--dark); }
.ad-btn {
  border: 1px solid var(--pink-light);
  background: transparent;
  color: var(--dark);
  border-radius: var(--radius-sm);
  width: 2rem;
  height: 2rem;
  font-size: 0.9rem;
  cursor: pointer;
  line-height: 1;
}
.ad-btn:hover { background: var(--pink-light); }
/* De qué recomendación se está hablando: sin esto, el mensaje con el contexto
   aparecería de la nada y no se sabría a qué tarjeta corresponde. */
.ad-ctx {
  margin: 0.75rem 1.125rem 0;
  padding: 0.6rem 0.75rem;
  background: var(--pink-light);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--salmon);
}
.ad-ctx-hdr {
  display: flex;
  align-items: center;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-weight: 700;
}
.ad-ctx-hdr span { flex: 1; }
.ad-ctx-x { border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 0.8rem; padding: 0 0.15rem; }
.ad-ctx-t { font-size: 0.875rem; font-weight: 600; color: var(--dark); margin-top: 0.2rem; }
.ad-ctx-d { font-size: 0.8125rem; color: var(--muted); margin-top: 0.15rem; }
.analista-drawer .ins-chat-msgs { flex: 1; min-height: 0; max-height: none; padding: 1rem 1.125rem 0; margin-bottom: 0; }
.analista-drawer .ins-chat-input { padding: 0.75rem 1.125rem; border-top: 1px solid var(--pink-light); }
/* La caja crece con lo que escribes (JS ajusta la altura hasta 220px). El
   min-height evita que el texto de ayuda salga cortado en una sola línea. */
.analista-drawer .ins-chat-input textarea { min-height: 3.1rem; max-height: 220px; line-height: 1.45; }
/* Adjuntar imagen. Es un <label> con el input dentro: clic = abre el selector,
   sin JS. */
.ad-attach {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  flex-shrink: 0;
  border: 1px solid var(--pink-light);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 1rem;
  user-select: none;
}
.ad-attach:hover { border-color: var(--salmon); background: var(--pink-light); }
.ins-preview {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding: 0.5rem 1.125rem;
  border-top: 1px solid var(--pink-light);
}
.ins-preview[hidden] { display: none; }
.ins-msg-img {
  display: block;
  max-width: 100%;
  border-radius: var(--radius-sm);
  margin-bottom: 0.4rem;
}
/* El contexto de la recomendación se pliega: son varias líneas que si no
   taparían la pregunta. */
.ins-ctx-det { margin-bottom: 0.35rem; }
.ins-ctx-det > summary { cursor: pointer; font-size: 0.75rem; opacity: 0.75; }
.ins-ctx-det[open] > summary { margin-bottom: 0.3rem; }
.ins-ctx-det { font-size: 0.8125rem; white-space: pre-wrap; }
@media (max-width: 720px) {
  .analista-drawer, .analista-drawer.wide { width: 100vw; }
  /* A pantalla completa el cajón TAPA la vista: que el fondo siga
     desplazándose bajo el dedo se siente como que se movió el chat. */
  body.con-analista { overflow: hidden; }
}

/* Preguntar por UNA recomendación: abre el cajón con ese contexto cargado. */
.btn-preguntar {
  margin-top: 0.6rem;
  border: 1px solid var(--pink-light);
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 0.3rem 0.7rem;
  font-size: 0.78rem;
  font-family: inherit;
  cursor: pointer;
}
.btn-preguntar:hover { border-color: var(--salmon); color: var(--dark); }
/* Fila de acciones de una tarjeta: "generar" / "ver la ficha" y "preguntar"
   alineados, en vez de uno colgando del otro. */
.item-acciones { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; margin-top: 0.6rem; }
.item-acciones .btn-preguntar { margin-top: 0; }

/* Memoria de sugerencias: ✅ ya lo hice / 🚫 no aplica. Lo que se marca aquí
   dura (R2) y vuelve al prompt del agente. */
.sug-acc { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }
.sug-btn {
  border: 1px solid var(--pink-light);
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 0.3rem 0.7rem;
  font-size: 0.78rem;
  font-family: inherit;
  cursor: pointer;
}
.sug-btn:hover { border-color: var(--salmon); color: var(--dark); }
.sug-badge { font-size: 0.78rem; font-weight: 600; color: var(--dark); }
.sug-acc--ok .sug-badge { color: #2E7D5B; }
.sug-acc--no .sug-badge { color: var(--muted); }
.sug-nota { font-size: 0.78rem; color: var(--muted); font-style: italic; }
.sug-undo {
  border: 0; background: transparent; color: var(--muted);
  font-size: 0.72rem; font-family: inherit; cursor: pointer; text-decoration: underline;
}
.sug-motivo { display: flex; gap: 0.4rem; align-items: center; flex-basis: 100%; margin-top: 0.4rem; }
.sug-motivo input {
  flex: 1;
  min-width: 0;
  padding: 0.35rem 0.6rem;
  border: 1px solid var(--pink-light);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.8rem;
  color: var(--dark);
  background: transparent;
}
.sug-motivo input:focus { outline: none; border-color: var(--salmon); }
/* Lo resuelto se atenúa: sigue a la vista (para poder deshacerlo) pero deja de
   competir por la atención con lo que falta por hacer. */
.ficha-cambio:has(.sug-acc--ok) > :not(.item-acciones),
.ficha-cambio:has(.sug-acc--no) > :not(.item-acciones) { opacity: 0.55; }

.ins-chat-msgs { overflow-y: auto; display: flex; flex-direction: column; gap: 0.6rem; }
.ins-chat-empty { color: var(--muted); font-size: 0.875rem; text-align: center; padding: 1rem 0; }
.ins-msg { max-width: 85%; padding: 0.55rem 0.8rem; border-radius: 14px; font-size: 0.9rem; line-height: 1.5; }
.ins-msg--user { align-self: flex-end; background: var(--invert-bg); color: var(--invert-fg); border-bottom-right-radius: 4px; }
.ins-msg--assistant { align-self: flex-start; background: var(--pink-light); color: var(--dark); border-bottom-left-radius: 4px; }
.ins-msg--assistant p { margin: 0 0 0.5rem; }
.ins-msg--assistant p:last-child { margin-bottom: 0; }
.ins-chat-input { display: flex; gap: 0.5rem; align-items: flex-end; }
.ins-chat-input textarea {
  flex: 1;
  resize: none;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--pink-light);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--dark);
  max-height: 120px;
}
.ins-chat-input textarea:focus { outline: none; border-color: var(--salmon); }

.insights-toolbar { display: flex; justify-content: flex-end; margin-bottom: 1rem; }

.idea-gen {
  position: relative;
  display: inline-flex;
  align-items: stretch;
  /* El margen vive en el CONTENEDOR, no en el botón: .btn-idea-gen trae un
     margin-top propio que dentro del flex empujaba solo al botón y dejaba la
     flecha desalineada hacia arriba. */
  margin-top: 0.5rem;
}
.idea-gen .btn-idea-gen {
  margin-top: 0;
  border-radius: 999px 0 0 999px;
}
.btn-idea-model {
  border: none;
  border-left: 1px solid rgba(255, 255, 255, 0.35);
  /* Mismo fondo y color que el botón: son una sola pieza partida en dos. */
  background: var(--salmon);
  color: #fff;
  border-radius: 0 999px 999px 0;
  padding: 0 0.7rem;
  cursor: pointer;
  font-size: 0.7rem;
  line-height: 1;
  transition: opacity 0.15s ease;
}
.btn-idea-model:hover { opacity: 0.88; }

.idea-model-menu {
  position: absolute;
  top: calc(100% + 0.3rem);
  right: 0;
  z-index: 20;
  min-width: 19rem;
  max-width: 90vw;
  background: var(--white);
  border: 1px solid var(--pink-light);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 28px rgba(0,0,0,0.18);
  padding: 0.3rem;
}
.idea-model-opt {
  display: grid;
  grid-template-columns: 1rem 1fr auto;
  gap: 0.5rem;
  align-items: center;
  width: 100%;
  text-align: left;
  border: none;
  background: none;
  font-family: inherit;
  font-size: 0.78rem;
  padding: 0.45rem 0.5rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: inherit;
}
.idea-model-opt:hover:not(:disabled) { background: var(--pink-light); }
.idea-model-opt:disabled { opacity: 0.45; cursor: not-allowed; }
.imo-cost { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.72rem; color: var(--muted); }
.imo-name em { font-style: normal; color: var(--muted); font-size: 0.72rem; }
.imo-note { margin: 0.3rem 0.5rem 0.2rem; font-size: 0.68rem; color: var(--muted); line-height: 1.4; }

.model-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.5rem 0 0.25rem;
}

.model-pick {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: var(--pink-light);
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0.15rem 0.5rem 0.15rem 0.6rem;
  font-size: 0.72rem;
  max-width: 100%;
}
/* Un modelo cambiado respecto de ⚙️ Configuración se marca: si no, es
   imposible saber que esta conversación está usando otro. */
.model-pick--changed {
  border-color: var(--accent, #C49A8A);
  background: color-mix(in srgb, var(--accent, #C49A8A) 18%, transparent);
}
.model-pick select {
  border: none;
  background: none;
  font-family: inherit;
  font-size: 0.72rem;
  color: inherit;
  max-width: 22rem;
  cursor: pointer;
  padding: 0.1rem 0;
}
.model-pick select:focus-visible { outline: 2px solid var(--accent, #C49A8A); border-radius: 4px; }

.item-review-warn {
  margin-left: auto;
  font-size: 0.6875rem;
  padding: 0.1rem 0.4rem;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--accent, #C49A8A) 22%, transparent);
  white-space: nowrap;
  cursor: help;
}

.item-review {
  background: color-mix(in srgb, var(--accent, #C49A8A) 12%, transparent);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.8rem;
  margin-top: 0.5rem;
  font-size: 0.78125rem;
  line-height: 1.45;
}
.item-review ul { margin: 0.35rem 0; padding-left: 1.1rem; }
.item-review span { color: var(--muted); }

.cost-warn {
  background: color-mix(in srgb, var(--accent, #C49A8A) 16%, transparent);
  border-left: 3px solid var(--accent, #C49A8A);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.8rem;
  margin-bottom: 0.75rem;
  font-size: 0.8125rem;
  line-height: 1.45;
}

.item-jobid {
  margin-left: auto;
  max-width: 42%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: none;
  border: none;
  padding: 0.1rem 0.35rem;
  border-radius: var(--radius-sm);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.6875rem;
  color: var(--muted);
  cursor: pointer;
  opacity: 0.65;
  transition: var(--transition);
}
.item-jobid:hover { opacity: 1; background: var(--pink-light); }

.insights-fallback {
  display: flex; flex-direction: column; gap: 0.25rem;
  background: var(--pink-light);
  border-left: 3px solid var(--accent, #C49A8A);
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.9rem;
  margin-bottom: 1rem;
  font-size: 0.8125rem;
  line-height: 1.45;
}
.insights-fallback span { color: var(--muted); }
.btn-gen-now {
  background: var(--invert-bg);
  color: var(--invert-fg);
  border: none;
  border-radius: 999px;
  padding: 0.55rem 1.1rem;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s ease;
}
.btn-gen-now:hover { opacity: 0.88; }
.btn-gen-now:disabled { opacity: 0.5; cursor: default; }
a.btn-gen-now { display: inline-block; text-decoration: none; }

/* Inicio: botón "ver más" y filas de conversaciones recientes */
.home-link { margin-top: 0.875rem; align-self: flex-start; }
.home-conv {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--white);
  border: 1px solid var(--pink-light);
  border-radius: var(--radius-md);
  padding: 0.625rem 0.75rem;
  margin-bottom: 0.5rem;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.home-conv:hover { background: var(--pink-light); border-color: var(--salmon); }
.home-conv__t { display: block; font-size: 0.9375rem; font-weight: 700; color: var(--dark); }
.home-conv__d { display: block; font-size: 0.8125rem; color: var(--muted); margin-top: 0.15rem; }
.home-conv__when { display: block; font-size: 0.75rem; color: var(--salmon); margin-top: 0.25rem; }

.ml-connect {
  background: var(--white);
  border: 1px solid var(--pink-light);
  border-radius: var(--radius-md);
  padding: 2rem 1.5rem;
  text-align: center;
  max-width: 460px;
  margin: 1.5rem auto;
}
.ml-connect__ico { font-size: 2.5rem; margin-bottom: 0.5rem; }
.ml-connect p { color: var(--dark); margin: 0.5rem 0 1rem; }

.usage-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
  background: var(--white);
  border: 1px solid var(--pink-light);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.usage-table th, .usage-table td {
  padding: 0.5rem 0.75rem;
  text-align: right;
  border-bottom: 1px solid var(--pink-light);
}
.usage-table th:first-child, .usage-table td:first-child { text-align: left; }
.usage-table thead th { color: var(--muted); font-weight: 600; background: var(--bg); }
.usage-table tbody tr:last-child td { border-bottom: none; }

.dash-placeholder {
  background: var(--white);
  border: 1.5px dashed var(--pink-light);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  text-align: center;
  font-size: 0.9375rem;
  color: var(--muted);
  line-height: 1.6;
}
.dash-placeholder strong { color: var(--dark); }

/* Tarjeta "Próximamente" para vistas aún no conectadas (Instagram / TikTok) */
.soon-card {
  background: var(--white);
  border: 1.5px dashed var(--pink-light);
  border-radius: var(--radius-md);
  padding: 2.5rem 1.5rem;
  text-align: center;
  max-width: 520px;
  margin: 1.5rem auto;
}
.soon-card .soon-emoji { font-size: 2.75rem; line-height: 1; margin-bottom: 0.5rem; }
.soon-card h3 { margin: 0.25rem 0 0.5rem; color: var(--dark); font-size: 1.15rem; }
.soon-card p { margin: 0; color: var(--muted); font-size: 0.9375rem; line-height: 1.6; }

/* ── Drive (gestor de archivos) ───────────────────────────────────────────── */
.drive-toolbar { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 0.75rem; }
.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.85rem; border-radius: var(--radius-sm); cursor: pointer; }
.drive-breadcrumb {
  display: flex; align-items: center; flex-wrap: wrap; gap: 0.15rem;
  margin-bottom: 0.9rem; font-size: 0.9rem;
}
.drive-crumb {
  background: none; border: none; color: var(--pink); font-weight: 600;
  cursor: pointer; padding: 0.2rem 0.35rem; border-radius: var(--radius-sm);
}
.drive-crumb:hover { background: var(--pink-light); color: var(--dark); }
.drive-crumb-sep { color: var(--muted); }
.drive-grid {
  display: grid; gap: 0.85rem;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
}
.drive-card {
  position: relative; background: var(--white); border: 1px solid var(--pink-light);
  border-radius: var(--radius-md); padding: 0.6rem; display: flex; flex-direction: column;
  gap: 0.35rem; transition: var(--transition);
}
.drive-card:hover { box-shadow: 0 3px 12px rgba(61,43,31,0.08); }
.drive-thumb {
  aspect-ratio: 1 / 1; border-radius: var(--radius-sm); overflow: hidden;
  background: var(--bg); display: flex; align-items: center; justify-content: center;
  font-size: 2.4rem; cursor: pointer; position: relative;
}
.drive-thumb--folder { font-size: 3rem; }
.drive-thumb--file { font-size: 2.6rem; }
.drive-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.drive-badge {
  position: absolute; bottom: 6px; right: 6px; background: rgba(61,43,31,0.75);
  color: #fff; border-radius: 50%; width: 26px; height: 26px; display: flex;
  align-items: center; justify-content: center; font-size: 0.8rem;
}
.drive-name {
  font-size: 0.85rem; font-weight: 600; color: var(--dark); cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.drive-meta { font-size: 0.72rem; color: var(--muted); }
.drive-menu-btn {
  position: absolute; top: 0.5rem; right: 0.5rem; width: 26px; height: 26px;
  border: none; border-radius: 50%; background: rgba(255,255,255,0.85);
  color: var(--dark); font-size: 1.1rem; line-height: 1; cursor: pointer;
}
.drive-menu-btn:hover { background: var(--pink-light); }
.drive-popmenu {
  position: absolute; z-index: 100; background: var(--white);
  border: 1px solid var(--pink-light); border-radius: var(--radius-sm);
  box-shadow: 0 6px 22px rgba(61,43,31,0.16); padding: 0.3rem; min-width: 170px;
}
.drive-popitem {
  display: block; width: 100%; text-align: left; background: none; border: none;
  padding: 0.5rem 0.6rem; font-size: 0.88rem; color: var(--dark);
  border-radius: var(--radius-sm); cursor: pointer;
}
.drive-popitem:hover { background: var(--bg); }

/* ── Editor de video ──────────────────────────────────────────────────────── */
.editor-wrap { display: grid; grid-template-columns: minmax(240px, 340px) 1fr; gap: 1.25rem; align-items: start; }
@media (max-width: 820px) { .editor-wrap { grid-template-columns: 1fr; } }
.editor-stage {
  position: relative; background: #000; border-radius: var(--radius-md); overflow: hidden;
  aspect-ratio: 9 / 16; max-height: 70vh; margin: 0 auto; width: 100%;
}
.editor-video { width: 100%; height: 100%; object-fit: contain; display: block; background: #000; transform-origin: center center; will-change: transform, opacity; }
.editor-overlay { position: absolute; inset: 0; }
.editor-play {
  position: absolute; bottom: 10px; left: 10px; z-index: 5; width: 40px; height: 40px;
  border: none; border-radius: 50%; background: rgba(255,255,255,0.85); font-size: 1rem; cursor: pointer;
}
.editor-sticker {
  position: absolute; transform: translate(-50%, -50%); cursor: grab; user-select: none;
  line-height: 1; touch-action: none; white-space: nowrap;
}
.editor-sticker--text { font-weight: 800; text-shadow: 0 1px 4px rgba(0,0,0,0.6); }
.editor-sticker.selected { outline: 2px dashed rgba(255,255,255,0.9); outline-offset: 4px; }
.editor-sticker-del {
  position: absolute; top: -12px; right: -12px; width: 22px; height: 22px; border: none;
  border-radius: 50%; background: rgba(61,43,31,0.92); color: #fff; font-size: 0.7rem;
  line-height: 1; cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.editor-sticker-del:hover { background: #ce2d4f; }
.editor-sticker-handle {
  position: absolute; bottom: -12px; right: -12px; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; border: 2px solid var(--pink); cursor: nwse-resize; touch-action: none;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}
.editor-credit { color: #b06a4f; font-weight: 600; }
.editor-panel { display: flex; flex-direction: column; gap: 1rem; }
.editor-group { background: var(--white); border: 1px solid var(--pink-light); border-radius: var(--radius-md); padding: 0.85rem; }
.editor-group h4 { margin: 0 0 0.6rem; color: var(--dark); font-size: 0.95rem; }
.editor-row { display: flex; align-items: center; gap: 0.5rem; margin: 0.35rem 0; }
.editor-row input[type=range] { flex: 1; accent-color: var(--pink); }
.editor-lbl { font-size: 0.8rem; color: var(--muted); min-width: 52px; }
.editor-val { font-size: 0.8rem; color: var(--dark); min-width: 42px; text-align: right; }
.editor-palette { display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); gap: 4px; margin-bottom: 0.5rem; }
.editor-emoji { border: 1px solid var(--pink-light); background: var(--bg); border-radius: var(--radius-sm); font-size: 1.2rem; padding: 4px; cursor: pointer; }
.editor-emoji:hover { background: var(--pink-light); }
.editor-select { width: 100%; padding: 0.45rem; border: 1px solid var(--pink-light); border-radius: var(--radius-sm); font-family: inherit; margin-bottom: 0.4rem; }
.editor-hint { font-size: 0.75rem; color: var(--muted); margin: 0.35rem 0 0; line-height: 1.4; }
.editor-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.editor-picker-info { color: var(--muted); font-size: 0.9rem; margin-bottom: 0.9rem; }
.editor-result { margin-top: 1.25rem; }
.editor-rendering { display: flex; align-items: center; gap: 0.6rem; color: var(--muted); font-size: 0.9rem; }
.editor-result-title { color: var(--dark); margin: 0 0 0.6rem; }
.editor-result-video { width: 100%; max-width: 320px; border-radius: var(--radius-md); display: block; }

/* ════════════════════════════════════════════════════════════════════════════
   UTILITIES
════════════════════════════════════════════════════════════════════════════ */

.hidden { display: none !important; }

@keyframes spin { to { transform: rotate(360deg); } }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.fade-in { animation: fadeIn 0.22s ease forwards; }


/* ════════════════════════════════════════════════════════════════════════════
   RESPONSIVE
════════════════════════════════════════════════════════════════════════════ */

@media (max-width: 600px) {
  .header-title { display: none; }
  .header-dot   { display: none; }
  .btn-ghost span:not(svg) { display: none; }
  /* En mobile el botón "Generar contenido" muestra solo el emoji para no amontonar */
  .btn-generate { font-size: 0; gap: 0; padding: 0.45rem 0.6rem; }
  .btn-generate::before { content: '🗓️'; font-size: 1rem; }

  .history-drawer { width: 100vw; }

  .message.user,
  .message.agent { max-width: 92%; }

  .content-card { border-radius: var(--radius-md); }
  .content-item { padding: 1rem; }
  .img-grid     { gap: 0.375rem; }

  .input-hint { display: none; }
}

/* ════════════════════════════════════════════════════════════════════════════
   PANTALLA DE LOGIN
   Se muestra cuando no hay sesión propia. Cloudflare Access ya no protege el
   panel, así que esta es la puerta visible; la real es el portero del Worker.
════════════════════════════════════════════════════════════════════════════ */

.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 1.5rem;
}

.login-card {
  background: var(--white);
  border: 1px solid var(--pink-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 2.5rem 2rem;
  max-width: 380px;
  width: 100%;
  text-align: center;
}

.login-logo {
  font-size: 0.75rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--salmon);
  font-weight: 600;
  margin-bottom: 0.75rem;
}

.login-card h1 {
  font-size: 1.35rem;
  color: var(--dark);
  margin: 0 0 0.5rem;
}

.login-sub {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
  margin: 0 0 1.5rem;
}

.login-btn {
  display: block;
  width: 100%;
  padding: 0.8rem 1rem;
  margin-top: 0.6rem;
  border: none;
  border-radius: var(--radius-md);
  background: var(--salmon);
  color: var(--on-accent);   /* 7.33:1 — blanco sobre salmón daría 2.52:1 */
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.login-btn:hover { filter: brightness(1.06); }

.login-warn {
  color: var(--danger);
  font-size: 0.85rem;
  line-height: 1.55;
  margin: 0;
}

/* Versiones mejoradas de un pedido con poco contexto: botones que copian el
   texto al cuadro de escritura. */
.prompt-ejemplos {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-top: 0.65rem;
}
.prompt-ejemplo {
  text-align: left;
  font: inherit;
  font-size: 0.85rem;
  line-height: 1.45;
  color: inherit;
  background: rgba(196, 154, 138, 0.10);
  border: 1px solid rgba(196, 154, 138, 0.35);
  border-radius: 8px;
  padding: 0.5rem 0.7rem;
  cursor: pointer;
}
.prompt-ejemplo:hover { background: rgba(196, 154, 138, 0.22); }

/* Editor: pestañas Video / Quitar fondo. */
.editor-tabs { display: flex; gap: 0.4rem; margin-bottom: 1rem; }
.editor-tab {
  font: inherit; font-size: 0.875rem; color: var(--muted);
  background: none; border: 1px solid var(--pink-light);
  border-radius: 999px; padding: 0.4rem 0.9rem; cursor: pointer;
}
.editor-tab.is-active { background: var(--invert-bg); color: var(--invert-fg); border-color: transparent; }

/* Quitar fondo */
.bgr-upload { display: inline-flex; align-items: center; gap: 0.4rem; margin: 0.75rem 0 1rem; cursor: pointer; }
.bgr-sub { margin: 1.25rem 0 0.6rem; font-size: 0.9rem; }
/* Cuadriculado para que la transparencia se VEA: sobre un fondo liso no se
   distingue un recorte limpio de uno que dejó el fondo blanco. */
.bgr-checker {
  display: inline-block; max-width: 100%; border-radius: 10px; padding: 12px;
  background-color: #fff;
  background-image:
    linear-gradient(45deg, #e5e5e5 25%, transparent 25%),
    linear-gradient(-45deg, #e5e5e5 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e5e5e5 75%),
    linear-gradient(-45deg, transparent 75%, #e5e5e5 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
}
.bgr-checker img { display: block; max-width: 100%; max-height: 420px; }

/* ── Recomendaciones: dónde se publica cada idea y con qué texto ─────────── */
.idea-destino { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem; margin: 0.3rem 0 0.35rem; }
.dest-chip {
  display: inline-flex; align-items: center;
  font-size: 0.75rem; font-weight: 600;
  padding: 0.15rem 0.55rem; border-radius: 999px;
  background: var(--pink-light); color: var(--dark);
}
.dest-when { font-size: 0.75rem; color: var(--muted); }
.idea-captions { margin-top: 0.5rem; }
.idea-captions > summary {
  cursor: pointer; list-style: none; user-select: none;
  font-size: 0.8125rem; font-weight: 600; color: var(--dark);
}
.idea-captions > summary::-webkit-details-marker { display: none; }
.idea-captions > summary::before { content: '▸ '; color: var(--muted); }
.idea-captions[open] > summary::before { content: '▾ '; }
.cap-block {
  margin-top: 0.5rem; padding: 0.6rem 0.75rem;
  border: 1px solid var(--pink-light); border-radius: var(--radius-sm);
  background: var(--white);
}
.cap-hdr { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; font-size: 0.8125rem; color: var(--dark); }
.cap-copy {
  flex-shrink: 0; cursor: pointer;
  font-family: inherit; font-size: 0.75rem; font-weight: 600;
  padding: 0.2rem 0.6rem; border-radius: 999px;
  border: 1px solid var(--pink-light); background: transparent; color: var(--dark);
}
.cap-copy:hover { background: var(--pink-light); }
.cap-copy.copied { border-color: var(--salmon); }
.cap-text { margin: 0.4rem 0 0; font-size: 0.875rem; line-height: 1.5; color: var(--dark); white-space: pre-line; overflow-wrap: anywhere; }
.cap-tags { margin: 0.35rem 0 0; font-size: 0.8125rem; color: var(--muted); overflow-wrap: anywhere; }
.cap-hook { margin: 0.5rem 0 0; font-size: 0.8125rem; color: var(--muted); }
.cap-hook b { color: var(--dark); }
.item-publish { margin-top: 0.5rem; }
.cap-same { margin: 0.4rem 0 0; font-size: 0.8125rem; color: var(--muted); }

/* ── Fichas de producto ──────────────────────────────────────────────────── */
.fichas-toolbar { gap: 0.5rem; flex-wrap: wrap; }
.btn-gen-now.btn-gen-now--ghost { background: transparent; color: var(--dark); box-shadow: inset 0 0 0 1px var(--pink-light); }
.btn-gen-now.btn-gen-now--ghost:hover { background: var(--pink-light); opacity: 1; }
.insights-fallback .btn-gen-now { align-self: flex-start; margin-top: 0.35rem; }
.fichas-trafico { margin: 0.6rem 0 0; font-size: 0.875rem; color: var(--muted); }
.fichas-trafico b { color: var(--dark); }
.quick-list { margin: 0; padding-left: 1.1rem; display: flex; flex-direction: column; gap: 0.45rem; font-size: 0.875rem; line-height: 1.45; color: var(--dark); }
.fichas-scroll { overflow-x: auto; }
.fichas-table { width: 100%; border-collapse: collapse; font-size: 0.8125rem; }
.fichas-table th { text-align: left; font-weight: 600; color: var(--muted); padding: 0.35rem 0.5rem; border-bottom: 1px solid var(--pink-light); white-space: nowrap; }
.fichas-table td { padding: 0.45rem 0.5rem; border-bottom: 1px solid var(--pink-light); color: var(--dark); }
.fichas-table td:not(:first-child) { white-space: nowrap; }
.fichas-table a { color: var(--dark); }
.fichas-list { display: flex; flex-direction: column; gap: 0.875rem; margin-top: 1.25rem; }
.fichas-grupo { margin: 0.75rem 0 0; font-size: 1rem; color: var(--dark); }
.ficha-card {
  background: var(--white); border-radius: var(--radius-md); box-shadow: var(--shadow-sm);
  padding: 1rem 1.125rem; border-left: 4px solid var(--pink-light);
}
.ficha-card.prio-alta { border-left-color: var(--danger); }
.ficha-card.prio-media { border-left-color: var(--salmon); }
.ficha-hdr { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.ficha-nombre { flex: 1 1 auto; min-width: 0; font-size: 1rem; font-weight: 700; color: var(--dark); }
.canal-badge { font-size: 0.75rem; font-weight: 600; padding: 0.15rem 0.55rem; border-radius: 999px; background: var(--pink-light); color: var(--dark); }
.prio-chip { font-size: 0.72rem; font-weight: 700; padding: 0.15rem 0.55rem; border-radius: 999px; border: 1px solid currentColor; }
.prio-chip.prio-alta { color: var(--danger); }
.prio-chip.prio-media, .prio-chip.prio-baja { color: var(--muted); }
/* Competencia: en qué se diferencian y qué copiar. */
.comp-dif { padding: 0.7rem 0.8rem; border-radius: var(--radius-sm); background: var(--bg); margin-bottom: 0.6rem; }
.comp-dif:last-child { margin-bottom: 0; }
.comp-lado { margin-top: 0.3rem; font-size: 0.875rem; line-height: 1.5; color: var(--dark); }
.comp-de { font-size: 0.8125rem; color: var(--muted); font-weight: 400; }
.comp-sitio { margin-bottom: 0.9rem; }
.comp-sitio-t { font-size: 0.8125rem; font-weight: 700; color: var(--dark); margin-bottom: 0.35rem; word-break: break-all; }
.comp-nuestro { background: var(--pink-light); }
.comp-nuestro td { font-weight: 600; }

/* Costos y margen en ⚙️ Configuración. */
.costos-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0.75rem; margin: 0.75rem 0; }
.costo-campo { display: flex; flex-direction: column; gap: 0.2rem; }
.costo-lbl { font-size: 0.8125rem; font-weight: 600; color: var(--dark); }
.costo-campo input {
  padding: 0.45rem 0.6rem; border: 1px solid var(--pink-light); border-radius: var(--radius-sm);
  font-family: inherit; font-size: 0.9rem; color: var(--dark); background: transparent;
}
.costo-campo input:focus { outline: none; border-color: var(--salmon); }
.costo-campo textarea {
  padding: 0.45rem 0.6rem; border: 1px solid var(--pink-light); border-radius: var(--radius-sm);
  font-family: inherit; font-size: 0.85rem; line-height: 1.5; color: var(--dark);
  background: transparent; resize: vertical;
}
.costo-campo textarea:focus { outline: none; border-color: var(--salmon); }

/* Avisos de la tienda (webhooks) en ⚙️ Configuración. */
.hooks-lista { display: flex; flex-direction: column; gap: 0.6rem; margin-top: 0.6rem; }
.hook-fila { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; flex-wrap: wrap; }
.hook-ok { font-size: 0.8125rem; font-weight: 600; color: #2E7D5B; }

/* Elegir una foto ya generada para subirla a un producto. */
.foto-picker { max-width: 640px; width: min(640px, 94vw); }
.foto-aviso { margin: 0 0 0.75rem; font-size: 0.8125rem; line-height: 1.45; color: var(--muted); }
.foto-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 0.6rem; max-height: 60vh; overflow-y: auto; }
.foto-op {
  border: 1px solid var(--pink-light);
  background: transparent;
  border-radius: var(--radius-sm);
  padding: 0.3rem;
  cursor: pointer;
  font-family: inherit;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.foto-op:hover { border-color: var(--salmon); }
.foto-op img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: var(--radius-sm); display: block; }
.foto-op span { font-size: 0.68rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.foto-op.subiendo { opacity: 0.5; }

/* Traspaso al Chat con Agente cuando la pregunta no es del analista. */
.ins-derivar {
  margin-top: 0.55rem; padding: 0.55rem 0.7rem;
  border-radius: var(--radius-sm); background: var(--bg);
  border-left: 3px solid var(--salmon);
}
.ins-derivar-t { font-size: 0.8125rem; font-weight: 700; color: var(--dark); }
.ins-derivar-m { font-size: 0.8125rem; line-height: 1.45; color: var(--muted); margin-top: 0.2rem; }
.ins-derivar-b { margin-top: 0.5rem; }

/* Calendario: qué se vende y cuándo publicar. */
.cal-tira { display: flex; flex-direction: column; gap: 0.4rem; max-height: 60vh; overflow-y: auto; }
.cal-tira--compacta { max-height: none; }
.cal-dia {
  padding: 0.45rem 0.6rem; border-radius: var(--radius-sm);
  background: var(--bg); border-left: 3px solid transparent;
}
.cal-dia--hoy { border-left-color: var(--salmon); background: var(--pink-light); }
.cal-dia--venta { border-left-color: var(--danger, #CE2D4F); }
.cal-dia-h { display: flex; align-items: center; gap: 0.45rem; flex-wrap: wrap; }
.cal-dia-n { font-size: 0.8125rem; font-weight: 700; color: var(--dark); text-transform: capitalize; }
.cal-hoy { font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--salmon); }
.cal-mejor { font-size: 0.7rem; font-weight: 600; color: #2E7D5B; }
.cal-evs { display: flex; gap: 0.3rem; flex-wrap: wrap; margin-top: 0.25rem; }
.cal-ev { font-size: 0.72rem; padding: 0.1rem 0.45rem; border-radius: 999px; background: var(--white); color: var(--dark); }
.cal-ev--venta { background: var(--danger, #CE2D4F); color: #fff; font-weight: 600; }
.cal-ev--marca { background: var(--salmon); color: var(--on-accent, #3D2B1F); font-weight: 600; }
.cal-plan { margin-top: 0.2rem; font-size: 0.75rem; color: var(--muted); }
.cal-prox { display: flex; flex-direction: column; gap: 0.5rem; }
.cal-prox-i { padding: 0.55rem 0.7rem; border-radius: var(--radius-sm); background: var(--bg); border-left: 3px solid var(--pink-light); }
.cal-prox-i--ya { border-left-color: var(--danger, #CE2D4F); }
.cal-prox-t { font-size: 0.875rem; font-weight: 700; color: var(--dark); }
.cal-prox-f { font-size: 0.8125rem; color: var(--muted); margin-top: 0.1rem; }
.cal-prox-q { font-size: 0.8125rem; line-height: 1.45; color: var(--muted); margin-top: 0.25rem; }
.cal-est { font-size: 0.68rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }

/* Contexto de mercado de MercadoLibre: reputación, tendencias, preguntas. */
.merc-box {
  background: var(--white);
  border: 1px solid var(--pink-light);
  border-radius: var(--radius-md);
  padding: 0.85rem 1.125rem;
  margin-bottom: 1rem;
}
.merc-chips { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.merc-chip { font-size: 0.8125rem; font-weight: 600; color: var(--dark); background: var(--pink-light); border-radius: 999px; padding: 0.2rem 0.65rem; }
.merc-chip--ojo { color: var(--danger, #CE2D4F); background: transparent; border: 1px solid currentColor; }
.merc-tend { margin-top: 0.6rem; display: flex; gap: 0.4rem; flex-wrap: wrap; align-items: center; }
.merc-tend-lbl { font-size: 0.8125rem; font-weight: 600; color: var(--dark); }
.merc-term { font-size: 0.78rem; color: var(--dark); background: var(--bg); border-radius: 999px; padding: 0.18rem 0.6rem; }
.merc-nota { flex-basis: 100%; font-size: 0.78rem; color: var(--muted); line-height: 1.45; }
.merc-term-grupo { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-bottom: 0.5rem; }
.merc-kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 0.6rem; }
.merc-kv > div { display: flex; flex-direction: column; gap: 0.1rem; }
.merc-kv span { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); font-weight: 700; }
.merc-kv b { font-size: 0.95rem; color: var(--dark); }
.merc-preg { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.merc-preg li { font-size: 0.8125rem; line-height: 1.45; color: var(--dark); padding: 0.45rem 0.6rem; background: var(--bg); border-radius: var(--radius-sm); }
.merc-preg--sin { border-left: 3px solid var(--danger, #CE2D4F); }
.merc-preg-f { display: block; margin-top: 0.15rem; font-size: 0.72rem; color: var(--muted); }
.merc-res-grupo { margin-bottom: 0.75rem; }
.merc-res-t { font-size: 0.8125rem; font-weight: 700; color: var(--dark); margin-bottom: 0.3rem; }
.merc-res { font-size: 0.8125rem; line-height: 1.45; color: var(--muted); padding: 0.35rem 0; border-top: 1px solid var(--pink-light); }

/* Campañas de MercadoLibre en Inicio. Va arriba y no en la grilla porque una
   invitación caduca sola: enterarse tarde equivale a no enterarse. */
.camp-box {
  background: var(--white);
  border: 1px solid var(--pink-light);
  border-radius: var(--radius-md);
  padding: 1rem 1.125rem;
  margin-bottom: 1rem;
}
.camp-box--hay { border-left: 4px solid var(--salmon); }
.camp-hdr { font-size: 0.95rem; font-weight: 700; color: var(--dark); }
.camp-sub { margin-top: 0.3rem; font-size: 0.8125rem; line-height: 1.5; color: var(--muted); }
.camp-vacio { margin-top: 0.3rem; font-size: 0.875rem; color: var(--muted); }
.camp-lista { list-style: none; margin: 0.75rem 0; padding: 0; display: flex; flex-direction: column; gap: 0.6rem; }
.camp-item { padding: 0.6rem 0.75rem; border-radius: var(--radius-sm); background: var(--bg); }
.camp-top { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; font-size: 0.875rem; color: var(--dark); }
.camp-desc { font-weight: 700; color: var(--danger, #CE2D4F); }
.camp-precio { color: var(--muted); font-size: 0.8125rem; }
.camp-precio s { opacity: 0.7; }
.camp-vence { margin-left: auto; font-size: 0.75rem; color: var(--muted); }
.camp-nombre { margin-top: 0.15rem; font-size: 0.8125rem; font-weight: 600; color: var(--dark); }
.camp-que { margin-top: 0.25rem; font-size: 0.8125rem; line-height: 1.45; color: var(--muted); }
.camp-pauta { margin-top: 0.6rem; font-size: 0.8125rem; line-height: 1.45; color: var(--muted); }
.carrito-top { list-style: none; margin: 0.6rem 0 0; padding: 0; display: flex; flex-direction: column; gap: 0.35rem; }
.carrito-top li { font-size: 0.8125rem; color: var(--dark); padding: 0.4rem 0.6rem; background: var(--bg); border-radius: var(--radius-sm); }

/* Minimizar una recomendación. Deja a la vista la cabecera y un resumen de
   cuántos cambios quedan, para poder recorrer la lista sin perder el hilo. */
.ficha-min {
  flex-shrink: 0;
  width: 1.75rem;
  height: 1.75rem;
  border: 1px solid var(--pink-light);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 0.8rem;
  line-height: 1;
  cursor: pointer;
}
.ficha-min:hover { border-color: var(--salmon); color: var(--dark); }
.ficha-min-resumen { display: none; margin-top: 0.3rem; font-size: 0.8125rem; color: var(--muted); }
.ficha-card.min .ficha-min-resumen { display: block; }
.ficha-card.min .ficha-metricas,
.ficha-card.min .ficha-diag,
.ficha-card.min .ficha-cambios,
.ficha-card.min .ficha-listos,
.ficha-card.min .ficha-todo-listo,
.ficha-card.min > .item-acciones { display: none; }
/* Lo ya resuelto, plegado: seguía a la vista a tamaño completo, así que
   aplicar cambios no despejaba nada. */
.ficha-listos { margin-top: 0.75rem; }
.ficha-listos > summary { cursor: pointer; font-size: 0.8125rem; font-weight: 600; color: var(--muted); }
.ficha-listos[open] > summary { margin-bottom: 0.5rem; }
.ficha-listos .ficha-cambios { margin-top: 0; }
.ficha-todo-listo { margin: 0.75rem 0 0; font-size: 0.875rem; color: var(--muted); }
/* Marcado como aplicado, pero los datos siguen mostrando el problema. Este NO
   se pliega: es el que hay que mirar. */
.ficha-cambio--revisar { border: 1px solid var(--danger, #CE2D4F); }
.cambio-revisar { margin-top: 0.35rem; font-size: 0.8125rem; line-height: 1.45; color: var(--danger, #CE2D4F); }
.ficha-metricas { margin-top: 0.3rem; font-size: 0.8125rem; color: var(--muted); }
/* Margen del producto. En rojo cuando queda poco espacio: ahí la palanca no
   es bajar el precio sino subir el valor percibido. */
.ficha-margen { display: inline-block; margin-left: 0.5rem; padding: 0.1rem 0.5rem; border-radius: 999px;
  background: var(--pink-light); color: var(--dark); font-weight: 600; font-size: 0.78rem; }
.ficha-margen--ajustado { color: var(--danger, #CE2D4F); background: transparent; border: 1px solid currentColor; }
.ficha-diag { margin: 0.5rem 0 0; font-size: 0.875rem; line-height: 1.5; color: var(--dark); }
.ficha-cambios { margin: 0.75rem 0 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 0.6rem; }
.ficha-cambio { padding: 0.7rem 0.8rem; border-radius: var(--radius-sm); background: var(--bg); }
.cambio-campo { display: inline-block; font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); }
.cambio-actual { margin-top: 0.3rem; font-size: 0.8125rem; line-height: 1.45; color: var(--muted); }
.cambio-actual span { font-weight: 600; }
.cambio-prop { margin-top: 0.45rem; padding: 0.55rem 0.7rem; border-radius: var(--radius-sm); background: var(--white); border: 1px solid var(--pink-light); }
.cambio-prop-hdr { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; font-size: 0.75rem; font-weight: 700; color: var(--dark); }
/* Antes y después de un reemplazo: lo que dice hoy en rojo, lo propuesto en
   verde. Los colores se definen aquí como tokens propios porque tienen que
   funcionar en claro y en oscuro: un verde pálido sobre fondo oscuro no se
   lee, y un rojo saturado encima tampoco. */
.ficha-cambio {
  --antes-borde: #CE2D4F;
  --antes-fondo: #CE2D4F14;
  --despues-borde: #2E7D5B;
  --despues-fondo: #2E7D5B14;
}
:root[data-theme="dark"] .ficha-cambio,
:root:not([data-theme="light"]) .ficha-cambio {
  --antes-fondo: #CE2D4F26;
  --despues-fondo: #2E7D5B2E;
}
.cambio-lado {
  margin-top: 0.45rem;
  padding: 0.5rem 0.65rem;
  border-radius: var(--radius-sm);
  border-left: 4px solid;
}
.cambio-lado--hoy { border-color: var(--antes-borde); background: var(--antes-fondo); }
.cambio-lado--prop { border-color: var(--despues-borde); background: var(--despues-fondo); }
.cambio-lado-hdr {
  display: flex; align-items: center; gap: 0.5rem;
  font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em;
}
.cambio-lado--hoy .cambio-lado-hdr { color: var(--antes-borde); }
.cambio-lado--prop .cambio-lado-hdr { color: var(--despues-borde); }
.cambio-lado-hdr .cambio-largo { margin-left: auto; }
.cambio-lado p {
  margin: 0.3rem 0 0; font-size: 0.875rem; line-height: 1.5;
  color: var(--dark); white-space: pre-line; overflow-wrap: anywhere;
}
.cambio-lado--hoy p { opacity: 0.85; }

/* Contador de caracteres en los campos con largo máximo (título de ML, título
   y meta para Google): si alguna vez se vuelve a colar uno largo, se ve. */
.cambio-largo { margin-left: auto; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }
.cambio-largo--mal { color: var(--danger, #CE2D4F); }
.cambio-prop p { margin: 0.3rem 0 0; font-size: 0.875rem; line-height: 1.5; color: var(--dark); white-space: pre-line; overflow-wrap: anywhere; }
.cambio-porque { margin-top: 0.4rem; font-size: 0.8125rem; line-height: 1.45; color: var(--muted); }
.cambio-link, .ficha-ver { display: inline-block; margin-top: 0.45rem; font-size: 0.8125rem; font-weight: 600; color: var(--dark); }
.ficha-ver { margin-top: 0.75rem; }

/* ── Pieza descartada ──────────────────────────────────────────────────────
   Se generó, se pagó y NO se entrega. Se muestra igual, con la evidencia y el
   motivo: el validador puede equivocarse, y sin ver la imagen nadie podría
   darse cuenta ni escribir un comentario útil para pedirla de nuevo.
   Tono de advertencia, NO de error: el pipeline funcionó, el control dijo que no. */
.delivery-discard {
  border: 1px solid var(--pink-light);
  border-left: 3px solid #C49A8A;
  border-radius: 10px;
  padding: 0.75rem 0.9rem;
  margin: 0.6rem 0;
  background: rgba(196, 154, 138, 0.06);
}
.discard-head { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.55rem; flex-wrap: wrap; }
.discard-tag { font-weight: 600; font-size: 0.86rem; }
.discard-sub { font-size: 0.78rem; opacity: 0.7; }
.discard-body { display: flex; gap: 0.85rem; align-items: flex-start; }
.discard-thumb {
  flex: 0 0 116px; width: 116px; min-height: 116px;
  border-radius: 8px; overflow: hidden; background: var(--bg);
  border: 1px solid var(--pink-light);
}
.discard-thumb img { width: 100%; height: auto; display: block; cursor: zoom-in; }
.discard-info { flex: 1 1 auto; min-width: 0; font-size: 0.84rem; }
.discard-info ul { margin: 0.3rem 0 0.7rem; padding-left: 1.1rem; }
.discard-info li { margin-bottom: 0.2rem; }
.discard-label { display: block; font-size: 0.79rem; opacity: 0.8; margin-bottom: 0.25rem; }
.discard-fb {
  width: 100%; box-sizing: border-box; resize: vertical;
  border: 1px solid var(--pink-light); border-radius: 7px;
  padding: 0.45rem 0.55rem; font: inherit; font-size: 0.83rem;
  background: var(--white); color: var(--dark);
}
.discard-actions { display: flex; align-items: center; gap: 0.6rem; margin-top: 0.5rem; flex-wrap: wrap; }
.discard-nota { font-size: 0.76rem; opacity: 0.65; }
.discard-error { font-size: 0.8rem; color: #CE2D4F; margin-top: 0.4rem; }

/* En pantalla angosta la miniatura pasa arriba en vez de estrujar el texto. */
@media (max-width: 560px) {
  .discard-body { flex-direction: column; }
  .discard-thumb { flex: none; width: 100%; max-width: 180px; }
}

/* Nota del tope de reintento, bajo el presupuesto. */
.budget-nota { font-size: 0.78rem; opacity: 0.72; margin: 0.45rem 0 0; line-height: 1.45; }
/* Cuando el defecto es del BACKEND y no del prompt: reintentar daría lo mismo. */
.discard-hint {
  font-size: 0.8rem; line-height: 1.45;
  background: rgba(224, 161, 0, 0.10);
  border: 1px solid rgba(224, 161, 0, 0.35);
  border-radius: 7px; padding: 0.45rem 0.6rem; margin: 0 0 0.6rem;
}
