@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;700;800&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Graduate&display=swap');

/* Mismas tipografías que se queman en los subtítulos del Editor de Video
   (assets/fonts, servidas también en public/fonts) — así el selector de
   estilo las puede mostrar en su letra real, no solo el nombre. */
@font-face { font-family: 'Poppins'; src: url('/fonts/Poppins-Bold.ttf') format('truetype'); font-weight: 700; }
@font-face { font-family: 'Bebas Neue'; src: url('/fonts/BebasNeue-Regular.ttf') format('truetype'); }
@font-face { font-family: 'Montserrat'; src: url('/fonts/Montserrat-Bold.ttf') format('truetype'); font-weight: 700; }
@font-face { font-family: 'Anton'; src: url('/fonts/Anton-Regular.ttf') format('truetype'); }
@font-face { font-family: 'Raleway'; src: url('/fonts/Raleway-Bold.ttf') format('truetype'); font-weight: 700; }
@font-face { font-family: 'Archivo'; src: url('/fonts/Archivo-Bold.ttf') format('truetype'); font-weight: 700; }
@font-face { font-family: 'Caveat'; src: url('/fonts/Caveat-Bold.ttf') format('truetype'); font-weight: 700; }
@font-face { font-family: 'Dancing Script'; src: url('/fonts/DancingScript-Bold.ttf') format('truetype'); font-weight: 700; }
@font-face { font-family: 'Playfair Display'; src: url('/fonts/PlayfairDisplay-BoldItalic.ttf') format('truetype'); font-style: italic; font-weight: 700; }
@font-face { font-family: 'Pinyon Script'; src: url('/fonts/PinyonScript-Regular.ttf') format('truetype'); }

:root,
:root[data-theme="dark"] {
  --bg: #0B0F19;
  --card: #12172a;
  --border: #232a42;
  --text: #f5f5f7;
  --muted: #8b8fa3;
  --indigo: #4F46E5;
  --purple: #A855F7;
  --input-bg: #0d1220;
  --hover-overlay: rgba(255, 255, 255, 0.04);
  --status-error: #f87171;
  --status-success: #86efac;
  --status-warning: #fbbf24;
  --badge-app-bg: rgba(79, 70, 229, 0.2);
  --badge-app-text: #a5b4fc;
  --badge-ig-bg: rgba(168, 85, 247, 0.2);
  --badge-ig-text: #d8b4fe;
  --badge-manual-bg: rgba(255, 255, 255, 0.08);
}

/* Modo claro — minimalista y blanco, no solo un degradado de marca sobre fondo
   oscuro. Especificidad [data-theme="light"] > :root plano, así siempre gana
   incluso sobre el <style> con --bg de marca que el servidor inyecta por cliente. */
:root[data-theme="light"] {
  --bg: #ffffff;
  --card: #f7f7f9;
  --border: #e4e4e8;
  --text: #14161f;
  --muted: #6b7280;
  --input-bg: #ffffff;
  --hover-overlay: rgba(0, 0, 0, 0.04);
  --status-error: #dc2626;
  --status-success: #16a34a;
  --status-warning: #d97706;
  --badge-app-bg: rgba(79, 70, 229, 0.12);
  --badge-app-text: #4338ca;
  --badge-ig-bg: rgba(168, 85, 247, 0.12);
  --badge-ig-text: #7e22ce;
  --badge-manual-bg: rgba(0, 0, 0, 0.05);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Plus Jakarta Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.layout {
  min-height: 100vh;
  padding-left: 220px; /* espacio reservado para el sidebar, que ahora es fixed */
}

/* Fijo al viewport (no a la altura del contenido) — si no, cuando una vista es
   muy larga, flexbox estira el sidebar a esa misma altura y el hueco antes del
   footer (créditos/tema/usuario) se alarga muchísimo. Con position:fixed el
   sidebar siempre mide exactamente 100vh sin importar cuánto contenido tenga
   la vista activa. */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: 220px;
  height: 100vh;
  overflow-y: auto;
  background: var(--card);
  border-right: 1px solid var(--border);
  padding: 28px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sidebar-header {
  padding: 0 4px 20px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.sidebar-greeting {
  margin: 6px 0 0;
  font-size: 15px;
  font-weight: 500;
  color: var(--muted);
}

.nav-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 0;
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 12px 14px;
  text-align: left;
  text-decoration: none;
  font-size: 12.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  cursor: pointer;
}

.nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.nav-item:hover { background: var(--hover-overlay); color: var(--text); }

.nav-item.active {
  background: var(--badge-app-bg);
  border-color: rgba(79, 70, 229, 0.35);
  color: var(--indigo);
}

.sidebar-footer {
  margin-top: auto;
  padding: 14px 4px 0;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.logout-link {
  width: 100%;
  margin: 0;
  padding: 10px 14px;
  background: rgba(248, 113, 113, 0.15);
  border: 1px solid rgba(248, 113, 113, 0.35);
  border-radius: 999px;
  color: var(--status-error);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
}

.logout-link:hover { background: rgba(248, 113, 113, 0.25); }

.footer-fine-link {
  font-size: 11px;
  color: var(--muted);
  text-decoration: none;
  text-align: center;
  padding-bottom: 10px;
}
.footer-fine-link:hover { color: var(--text); text-decoration: underline; }

.theme-toggle {
  width: 100%;
  margin: 0;
  padding: 10px 14px;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
}

.theme-toggle:hover { border-color: var(--indigo); }

.credits-indicator {
  font-size: 13px;
  font-weight: 600;
  text-align: center;
}

.credits-indicator.low { color: var(--status-error); }

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.content {
  max-width: 960px;
  margin: 0 auto;
  padding: 48px 24px 80px;
  width: 100%;
}
/* Estadísticas necesita más ancho que el resto de vistas para que el scatter
   y el heatmap quepan lado a lado sin quedar apretados. */
.content:has(#statsView:not(.hidden)) { max-width: 1180px; }

.view.hidden { display: none; }

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 19px;
  font-weight: 800;
  text-transform: uppercase;
  line-height: 1.25;
  margin: 0;
  padding: 0 4px;
}

.grad {
  background: linear-gradient(135deg, var(--indigo) 0%, var(--purple) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Logo real del cliente (si subió uno) junto al nombre en texto — ver
   {{SIDEBAR_LOGO_HTML}} en renderBrandedHtml, server/index.js. */
.sidebar-logo-img {
  display: block;
  max-height: 28px;
  max-width: 100px;
  width: auto;
  object-fit: contain;
  flex-shrink: 0;
}

.tag {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--muted);
  font-weight: 600;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 28px;
  margin-bottom: 24px;
}

label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
}

.muted { color: var(--muted); font-weight: 400; }

textarea, input[type="text"], input[type="password"] {
  width: 100%;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  padding: 14px;
  resize: vertical;
  margin-bottom: 16px;
}

.section-title {
  margin: 0 0 16px;
  font-size: 15px;
}

select {
  width: 100%;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  padding: 14px;
  margin-bottom: 16px;
}

/* ---------- Selector de estilo con vista previa real de la tipografía ---------- */
.font-picker { position: relative; margin-bottom: 16px; }
.font-picker-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  padding: 14px;
  margin: 0;
  cursor: pointer;
}
.font-picker-chevron { color: var(--muted); font-size: 18px; }
.font-picker-menu {
  position: absolute;
  z-index: 10;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 16px 32px rgba(0,0,0,0.25);
  max-height: 320px;
  overflow-y: auto;
  padding: 6px;
}
.font-picker-option {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 19px;
  color: var(--text);
}
.font-picker-option:hover { background: var(--hover-overlay); }
.font-picker-option .muted { font-size: 16px; flex-shrink: 0; }

/* ---------- Timeline de recorte manual (Editor de Video) ----------
   Solo --indigo/--purple quedan FIJOS acá (no los de marca del cliente) —
   esta tarjeta es una herramienta de edición: pintar "conservado" del color
   de marca de un cliente (ej. rojo) se lee como "cortar/peligro", justo lo
   contrario. El fondo/tema SÍ sigue el claro/oscuro normal de la app (no se
   fuerza oscuro) — solo el acento índigo/morado queda fijo. */
#videoTimelineCard {
  --indigo: #6366f1;
  --purple: #a855f7;
}

.video-timeline-layout {
  display: grid; grid-template-columns: 280px 1fr; gap: 24px; align-items: start;
  margin-bottom: 20px;
}
@media (max-width: 760px) { .video-timeline-layout { grid-template-columns: 1fr; } }

/* Transcripción real de lo que se dijo (mismo transcript que ya usa el
   quemado de subtítulos, solo que acá se muestra legible) — las palabras
   que Gemini marcó como "emphasis" (las mismas que salen resaltadas en el
   video final) se pintan del color de acento, para que se entienda de un
   vistazo qué se va a destacar. Clic en una línea salta el preview a ese
   momento. */
.video-timeline-transcript-label {
  margin: 0 0 8px; font-size: 12.5px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.04em;
}
.video-timeline-transcript {
  max-height: 360px; overflow-y: auto;
  background: var(--input-bg); border: 1px solid var(--border); border-radius: 12px;
  padding: 6px;
}
.transcript-line {
  padding: 7px 10px; border-radius: 8px; cursor: pointer;
  font-size: 13.5px; line-height: 1.55; color: var(--text);
}
.transcript-line:hover { background: var(--hover-overlay); }
.transcript-line.is-playing { background: rgba(79, 70, 229, 0.12); }
.transcript-time { display: block; font-size: 10.5px; color: var(--muted); margin-bottom: 1px; }
.transcript-emphasis { color: var(--purple); font-weight: 700; }
.transcript-emphasis--principal { font-size: 1.15em; }
.transcript-emphasis--complemento { font-style: italic; }
.video-timeline-transcript-empty { padding: 10px; font-size: 13px; color: var(--muted); }

.video-timeline-preview-wrap { position: relative; max-width: 320px; margin: 0 auto 10px; }
.video-timeline-preview-wrap video {
  width: 100%; border-radius: 14px; border: 1px solid var(--border); display: block; background: #000;
}
.video-timeline-play-btn {
  position: absolute; bottom: 10px; left: 10px;
  width: 34px; height: 34px; border-radius: 50%; border: none; cursor: pointer;
  background: rgba(0, 0, 0, 0.6); color: #fff;
  display: flex; align-items: center; justify-content: center;
}
.video-timeline-play-btn svg { width: 15px; height: 15px; }

.video-timeline-duration-label { margin: 0 0 8px; font-size: 13px; }

/* Pistas apiladas (video + subtítulos + regla) que comparten la MISMA escala
   de tiempo — la columna de etiqueta (86px) se repite idéntica en las 3 filas
   a propósito, así los carriles de la derecha arrancan todos en el mismo
   punto horizontal y el tiempo queda alineado verticalmente entre pistas
   (ver timeline de referencia tipo DaVinci/CapCut que pidió el cliente). */
.timeline-tracks { display: flex; flex-direction: column; gap: 6px; }
.timeline-track-row {
  display: grid; grid-template-columns: 86px 1fr; align-items: center; gap: 10px;
}
.timeline-track-label {
  font-size: 11px; font-weight: 700; color: var(--muted);
  display: flex; align-items: center; gap: 5px; white-space: nowrap;
  text-transform: uppercase; letter-spacing: 0.03em;
}
.timeline-track-label .inline-icon { width: 13px; height: 13px; flex-shrink: 0; }

.video-timeline {
  position: relative; height: 56px; border-radius: 10px;
  background: var(--input-bg); border: 1px solid var(--border);
  overflow: hidden;
  /* Tira de miniaturas real (ver extractClipFilmstrip en videoEdit.js) — se
     fija por JS como background-image cuando está lista; 100% 100% la
     estira para llenar el track exacto en vez de recortarla/repetirla. */
  background-size: 100% 100%;
  background-repeat: no-repeat;
}

/* Pista de subtítulos: solo lectura, un bloque por fragmento de transcripción
   (mismas coordenadas de tiempo que el video, así quedan alineados) — no se
   edita acá, es para que se vea de un vistazo cuándo hay texto en pantalla. */
.video-timeline-subtitles {
  position: relative; height: 26px; border-radius: 8px;
  background: var(--input-bg); border: 1px solid var(--border);
  overflow: hidden;
}
.timeline-caption-block {
  position: absolute; top: 3px; bottom: 3px;
  background: rgba(168, 85, 247, 0.16);
  border: 1px solid rgba(168, 85, 247, 0.4);
  border-radius: 4px;
  display: flex; align-items: center; padding: 0 5px;
  overflow: hidden;
}
.timeline-caption-block span {
  font-size: 9px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* 3 acentos rotando por fragmento (ver CAPTION_PALETTE en videoTimeline.js) —
   puramente visual, el color no indica nada funcional distinto entre bloques. */
.timeline-caption-block--purple { background: rgba(168, 85, 247, 0.16); border-color: rgba(168, 85, 247, 0.4); }
.timeline-caption-block--purple span { color: var(--purple); }
.timeline-caption-block--amber { background: rgba(245, 158, 11, 0.16); border-color: rgba(245, 158, 11, 0.4); }
.timeline-caption-block--amber span { color: #d97706; }
.timeline-caption-block--teal { background: rgba(14, 165, 165, 0.16); border-color: rgba(14, 165, 165, 0.4); }
.timeline-caption-block--teal span { color: #0d9488; }

/* Insignia de color por tipo de pista (video/audio/subtítulos) en la
   etiqueta — mismo lenguaje visual que los 3 acentos de arriba, para que de
   un vistazo se identifique qué pista es cuál (como los cuadros de color de
   la referencia que mandó el cliente). */
.timeline-track-icon-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border-radius: 5px; flex-shrink: 0;
}
.timeline-track-icon-badge svg { width: 11px; height: 11px; }
.timeline-track-icon-badge--video { background: rgba(99, 102, 241, 0.15); color: var(--indigo); }
.timeline-track-icon-badge--audio { background: rgba(14, 165, 165, 0.15); color: #0d9488; }
.timeline-track-icon-badge--captions { background: rgba(168, 85, 247, 0.15); color: var(--purple); }

/* Pistas de solo lectura del resumen de "Voz en off" (#voiceoverTimelineSummary)
   — a diferencia de .video-timeline (recortable), acá siempre es un único
   bloque de borde a borde: no hay nada que arrastrar porque el video ya se
   generó completo, ajustado a la duración exacta de la narración. */
.video-timeline-readonly {
  position: relative; height: 56px; border-radius: 10px;
  background: var(--input-bg); border: 1px solid var(--border);
  overflow: hidden;
}
/* --track-image: lo fija JS con url(/api/preview/<archivo>) cuando ffmpeg
   generó la tira de miniaturas/forma de onda real (ver
   showVoiceoverTimelineSummary en videoEdit.js) — con eso ausente (ffmpeg
   falló, extremo raro) cae de vuelta al degradado de marca de siempre, nunca
   se queda vacío. */
.video-timeline-readonly::after {
  content: ''; position: absolute; inset: 4px; border-radius: 6px;
  background: var(--track-image, linear-gradient(135deg, var(--indigo), var(--purple)));
  background-size: cover; background-position: center;
}
.video-timeline-readonly--audio {
  height: 32px;
}
.video-timeline-readonly--audio::after {
  background: var(--track-image, linear-gradient(135deg, #0ea5a5, #22c55e));
  background-color: #0b1220;
  background-size: 100% 100%; background-position: center;
}

/* Estado vacío (#videoTimelinePreview, antes de subir/analizar nada) — franja
   discontinua y neutra en vez del degradado de marca, para que se lea como
   "todavía no hay nada" y no como un resultado real ya listo. */
.video-timeline-readonly--placeholder::after {
  background: none; border: 1.5px dashed var(--border);
  inset: 6px;
}

/* Estado de carga — mismo lugar en pantalla que el vacío y el resultado
   real, solo cambia el contenido interno (ver setTimelinePreviewState en
   videoEdit.js), así el "look" de editor no desaparece ni un segundo
   mientras se procesa. */
@keyframes timelineShimmer { 0% { background-position: -200% 0; } 100% { background-position: 200% 0; } }
.video-timeline-readonly--loading::after {
  background: linear-gradient(90deg, var(--input-bg) 25%, var(--hover-overlay) 50%, var(--input-bg) 75%);
  background-size: 200% 100%;
  animation: timelineShimmer 1.4s ease-in-out infinite;
  border: none;
}
.timeline-block {
  position: absolute; top: 4px; bottom: 4px;
  border-radius: 6px;
}
.timeline-block--kept {
  /* Translúcido a propósito: deja ver la tira de miniaturas del clip por
     debajo (ver .video-timeline) — antes era un degradado sólido y no se
     distinguía nada del video real. */
  background: rgba(99, 102, 241, 0.3);
  border: 2px solid var(--indigo);
  cursor: default;
}
.timeline-block--gap {
  top: 14px; bottom: 14px;
  /* Más opaco que antes a propósito: con la tira de miniaturas real de fondo
     (ver .video-timeline), un hueco casi transparente ya no se distinguía
     del tramo conservado (que ahora también deja ver el video) — este oscurece
     la miniatura debajo para que quede claro que esa parte se está quitando. */
  background: rgba(0, 0, 0, 0.55);
  border: 1px dashed var(--border);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  transition: background 0.15s ease;
}
.timeline-block--gap:hover { background: rgba(79, 70, 229, 0.5); color: #fff; }
.timeline-gap-icon { width: 14px; height: 14px; }
.timeline-handle {
  position: absolute; top: 0; bottom: 0; width: 10px;
  cursor: ew-resize; touch-action: none;
}
.timeline-handle--left { left: 0; }
.timeline-handle--right { right: 0; }
.timeline-handle::after {
  content: ''; position: absolute; top: 50%; left: 50%;
  width: 3px; height: 16px; border-radius: 2px;
  background: rgba(255, 255, 255, 0.7);
  transform: translate(-50%, -50%);
}
.timeline-block-delete-btn {
  position: absolute; top: 3px; right: 3px;
  width: 18px; height: 18px; border-radius: 50%; border: none; cursor: pointer;
  background: rgba(0, 0, 0, 0.35); color: #fff;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity 0.15s ease;
}
.timeline-block-delete-btn svg { width: 10px; height: 10px; }
.timeline-block--kept:hover .timeline-block-delete-btn { opacity: 1; }

.video-timeline-ruler { position: relative; height: 16px; margin-bottom: 18px; }

/* Estado "ya se generó" de #videoTimelineCard — se queda visible como vista
   "después" (en vez de desaparecer) pero deja de ser editable: sin manijas,
   sin botón de borrar, sin huecos clicables, sin selector de formato/
   subtítulos ni botón de generar (ya no aplican). Reusa el mismo DOM que ya
   estaba correctamente pintado justo antes de generar, en vez de construir
   una vista de solo lectura aparte. */
.timeline-finalized .timeline-handle,
.timeline-finalized .timeline-block-delete-btn,
.timeline-finalized .video-options-row,
.timeline-finalized #renderVideoBtn,
.timeline-finalized #renderVideoStatus {
  display: none;
}
.timeline-finalized .timeline-block--gap { pointer-events: none; cursor: default; }
.video-timeline-ruler-tick {
  position: absolute; top: 0; transform: translateX(-50%);
  font-size: 10.5px; color: var(--muted); white-space: nowrap;
}

/* ---------- Selector de música: video a la izquierda (sticky), controles a
   la derecha — antes el video (320px) quedaba solo en una tarjeta de ~900px
   de ancho, dejando ~550px vacíos a su lado, y cada fila de canción se
   estiraba de extremo a extremo con todo el contenido pegado a los bordes. ---------- */
.music-picker-layout {
  display: grid; grid-template-columns: 320px 1fr; gap: 28px; align-items: start;
}
.music-picker-preview { position: sticky; top: 20px; }
.music-picker-preview video {
  width: 100%; border-radius: 14px; border: 1px solid var(--border); display: block;
}
.music-picker-controls label:first-child { margin-top: 0; }
@media (max-width: 760px) {
  .music-picker-layout { grid-template-columns: 1fr; }
  .music-picker-preview { position: static; max-width: 320px; }
}

/* Filas de canción más compactas dentro del selector de música: el texto y
   los botones quedan juntos a la izquierda en vez de separados a los
   extremos de la fila — ya no hace falta estirarlos porque la columna de
   controles es mucho más angosta que la tarjeta completa. No se toca
   .list-row en general porque también la usan history.js/generate.js/
   referrals.js con su propio espaciado de siempre. */
#musicPickerCard .list-row { justify-content: flex-start; }
#musicPickerCard .list-row > span:first-child { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#musicPickerCard .list-row > button { margin-left: 0; flex-shrink: 0; }

/* ---------- Búsqueda de música: barra + resultados como un solo bloque ---------- */
.music-search-box {
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 16px;
}
.music-search-bar {
  display: flex;
  gap: 8px;
  padding: 10px;
  border-bottom: 1px solid var(--border);
}
.music-search-bar input[type="text"] {
  flex: 1;
  margin: 0;
  border: none;
  background: transparent;
  padding: 8px 10px;
}
.music-search-bar input[type="text"]:focus { outline: none; }
.music-search-bar button { margin: 0; flex-shrink: 0; }
#musicSearchResults { max-height: 280px; overflow-y: auto; }
#musicSearchResults:empty { display: none; }
.music-search-box:has(#musicSearchResults:empty) .music-search-bar { border-bottom: none; }
#musicSearchResults .list-row { padding: 10px 14px; margin: 0; border-radius: 0; }
#musicSearchResults .list-row:last-child { border-bottom: none; }

.list-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.list-row:last-child { border-bottom: none; }
.list-row .meta { color: var(--muted); font-size: 12px; }

.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 8px;
  border-radius: 999px;
  margin-right: 6px;
}

.badge.app { background: var(--badge-app-bg); color: var(--badge-app-text); }
.badge.manual { background: var(--badge-manual-bg); color: var(--muted); }
.badge.instagram { background: var(--badge-ig-bg); color: var(--badge-ig-text); }
.badge.facebook { background: var(--badge-app-bg); color: var(--badge-app-text); }

.agg-row {
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.agg-row:last-child { border-bottom: none; }

.agg-label {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  margin-bottom: 6px;
}

.agg-bar-track {
  background: var(--input-bg);
  border-radius: 8px;
  height: 8px;
  overflow: hidden;
}

.agg-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--indigo), var(--purple));
  border-radius: 8px;
}

/* Fila de "adjuntos" del generador de post: un botón + que abre un menú con
   opciones (hoy solo la foto de producto; con el tiempo se le irán sumando
   más ahí mismo, sin necesitar más espacio permanente en el formulario). */
.attach-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 2px 0 16px;
  position: relative;
}
.attach-trigger-wrap { position: relative; }
.attach-trigger {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: border-color 0.15s, color 0.15s, transform 0.15s;
}
.attach-trigger:hover {
  border-color: var(--indigo);
  color: var(--indigo);
}
.attach-trigger.open { transform: rotate(45deg); }

.attach-menu {
  position: absolute;
  top: 42px;
  left: 0;
  z-index: 20;
  min-width: 260px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
  padding: 6px;
}
.attach-menu-item {
  width: 100%;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px;
  border: none;
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
}
.attach-menu-item:hover { background: var(--hover-bg, rgba(127, 127, 127, 0.1)); }
.attach-menu-icon { font-size: 18px; line-height: 1.3; }
.attach-menu-title {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.attach-menu-desc {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
  line-height: 1.4;
}

.attach-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 4px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}
.attach-chip img {
  width: 26px;
  height: 26px;
  object-fit: cover;
  border-radius: 50%;
}
.attach-chip-remove {
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  padding: 0 2px;
  line-height: 1;
}
.attach-chip-remove:hover { color: var(--status-error); }

.carousel-toggle-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 4px 0 16px;
  flex-wrap: wrap;
}
.carousel-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  margin: 0;
}
.carousel-toggle input { accent-color: var(--indigo); }
#carouselSlideCount { width: auto; margin: 0; padding: 8px 12px; font-size: 13px; }

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-label { font-size: 13px; }

.date-range-custom {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  font-size: 13px;
}
.date-range-custom input[type="date"] {
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--input-bg);
  color: var(--text);
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}
.kpi-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--input-bg);
}
.kpi-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-weight: 700;
}
.kpi-value { font-size: 28px; font-weight: 800; }
.kpi-variation {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  min-height: 16px;
}
.kpi-variation .inline-icon { width: 14px; height: 14px; }
.kpi-variation.positive { color: var(--status-success); }
.kpi-variation.negative { color: var(--status-error); }

.heatmap-wrap { overflow-x: auto; }
.heatmap-grid {
  display: grid;
  grid-template-columns: 56px repeat(var(--heatmap-cols, 7), minmax(44px, 1fr));
  gap: 4px;
  min-width: 480px;
}
.heatmap-header {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  text-align: center;
  padding-bottom: 4px;
}
.heatmap-time-label {
  font-size: 11px;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 6px;
}
.heatmap-cell {
  aspect-ratio: 1;
  border-radius: 6px;
  border: 1px solid var(--border);
  cursor: default;
}
.heatmap-cell.empty {
  background: transparent;
  border-style: dashed;
  opacity: 0.4;
}

.scatter-legend {
  display: flex;
  gap: 18px;
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
}
.scatter-legend-item { display: flex; align-items: center; gap: 6px; }
.scatter-legend-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.scatter-legend-line {
  width: 16px;
  height: 0;
  border-top: 2px dashed var(--purple);
  flex-shrink: 0;
}

.scatter-chart-inner { position: relative; }
.scatter-tooltip {
  position: absolute;
  z-index: 10;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  max-width: 260px;
  padding: 10px;
  border-radius: 10px;
  background: var(--card);
  border: 1px solid var(--border);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  font-size: 12px;
}
.scatter-tooltip-thumb {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
}
.scatter-tooltip-date { color: var(--muted); margin-bottom: 3px; }
.scatter-tooltip-caption {
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.scatter-tooltip-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
  color: var(--indigo);
  font-weight: 700;
  text-decoration: none;
}
.scatter-tooltip-link .inline-icon { width: 12px; height: 12px; }

.stats-columns {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 24px;
  align-items: start;
}
/* Cada columna es su propio contenedor de cards apiladas — el margin-bottom
   que ya trae .card se encarga del espacio vertical entre ellas, así que acá
   no hace falta gap. */
.stats-column { min-width: 0; }

@media (max-width: 900px) {
  .stats-columns { grid-template-columns: 1fr; }
}

.filter-chip {
  margin: 0;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.filter-chip.active {
  background: linear-gradient(135deg, var(--indigo) 0%, var(--purple) 100%);
  color: white;
  border-color: transparent;
}

.boost-link {
  margin: 0 0 0 10px;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.boost-link:hover { border-color: var(--purple); }

/* ---------- Tabla de "Todos los posts" (Estadísticas) ---------- */
.posts-table-wrap {
  overflow-x: auto;
  /* Wide enough (miniatura + varias columnas) para desbordar en pantallas
     angostas — se envuelve en su propio scroller para que la página nunca
     tenga que hacer scroll horizontal completo. */
}
.posts-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.posts-table th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-weight: 700;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.posts-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.posts-table tbody tr:hover { background: var(--hover-overlay); }
.posts-table tbody tr:last-child td { border-bottom: none; }

.posts-table-thumb {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  overflow: hidden;
  background: var(--input-bg);
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.posts-table-thumb img,
.posts-table-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.posts-table-thumb-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
}
.posts-table-thumb-placeholder .inline-icon { width: 18px; height: 18px; }

.posts-table-content {
  max-width: 320px;
  min-width: 180px;
}
.posts-table-caption {
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.posts-table-caption a { color: inherit; }
.posts-table-topic {
  font-size: 11px;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#postsEmptyState { margin-top: 12px; }

textarea:focus, button:focus {
  outline: 2px solid var(--indigo);
  outline-offset: 1px;
}

button {
  margin-top: 16px;
  border: none;
  border-radius: 12px;
  padding: 14px 22px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  background: linear-gradient(135deg, var(--indigo) 0%, var(--purple) 100%);
  color: white;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Spinner universal para cualquier botón en curso (ver withLoading en
   utils.js) — funciona igual para un botón de solo texto que para uno con
   ícono SVG (stroke="currentColor"), porque ambos quedan invisibles con
   color:transparent y el spinner usa un color fijo, no currentColor. */
.btn-loading {
  position: relative;
  color: transparent !important;
}
.btn-loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 15px;
  height: 15px;
  margin: -8px 0 0 -8px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: btn-loading-spin 0.6s linear infinite;
}
/* Blanco funciona sobre el degradado indigo/púrpura de un botón normal, pero
   un botón "secondary"/ícono es transparente — se ve sobre el fondo de la
   página (blanco en modo claro), donde un spinner blanco desaparecería. */
button.secondary.btn-loading::after,
.icon-btn.btn-loading::after,
.cancel-link.btn-loading::after {
  border-color: rgba(79, 70, 229, 0.25);
  border-top-color: var(--indigo);
}
@keyframes btn-loading-spin {
  to { transform: rotate(360deg); }
}

button.secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

.status {
  margin-top: 12px;
  font-size: 14px;
  color: var(--muted);
  white-space: pre-wrap;
}

.status.error { color: var(--status-error); }
.status.success { color: var(--status-success); }
.status.warning { color: var(--status-warning); }

/* Icono inline junto al texto de estado/botones — mismo estilo de trazo que
   la barra de navegación (ver public/js/icons.js), en vez de emojis. */
.inline-icon {
  width: 1em;
  height: 1em;
  vertical-align: -0.15em;
  flex-shrink: 0;
}
.status-icon {
  display: inline-block;
  width: 14px;
  height: 14px;
  vertical-align: -2px;
  margin-right: 6px;
}
.status-icon svg { width: 100%; height: 100%; }

.hidden { display: none !important; }

.preview-grid {
  display: grid;
  grid-template-columns: minmax(0, 320px) 1fr;
  gap: 28px;
}

#previewVideo {
  width: 100%;
  border-radius: 14px;
  border: 1px solid var(--border);
  aspect-ratio: 1080 / 1350;
  object-fit: cover;
}

/* ---------- Mockup de vista previa (Instagram / Facebook) ----------
   Siempre con la estética real de cada red (tarjeta blanca, tipografía y
   colores propios) independiente del tema claro/oscuro del panel — igual
   criterio que el login, para que se vea creíble como si fuera la app real. */
.post-mockup { display: flex; flex-direction: column; gap: 10px; }

.mockup-tabs { display: flex; gap: 8px; }
.mockup-tab {
  flex: 1;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--input-bg);
  color: var(--muted);
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.mockup-tab.active {
  background: linear-gradient(135deg, var(--indigo) 0%, var(--purple) 100%);
  color: white;
  border-color: transparent;
}

.mockup-frame {
  background: #ffffff;
  color: #14161f;
  border: 1px solid #dbdbdb;
  border-radius: 12px;
  overflow: hidden;
  font-family: -apple-system, 'Segoe UI', Roboto, sans-serif;
}

.mockup-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--indigo) 0%, var(--purple) 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 800;
  flex-shrink: 0;
}

/* Contenedor de la imagen — cuando es un carrusel, guarda varias <img> apiladas
   (una visible a la vez vía .active) más flechas y puntos de navegación; en un
   post normal solo tiene la única imagen ya existente, sin flechas/puntos. */
.mockup-slider {
  position: relative;
  width: 100%;
  aspect-ratio: 1080 / 1350;
  overflow: hidden;
}
.mockup-slider img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  margin: 0;
  border: none;
  border-radius: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.mockup-slider img.active { opacity: 1; pointer-events: auto; cursor: zoom-in; }

/* Fondo blanco sólido + sombra en vez de negro translúcido — sobre diseños
   oscuros (el caso más común) un círculo negro semi-transparente casi no se
   distinguía del fondo de la imagen. */
.slider-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 3;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.92);
  color: #14161f;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
  font-size: 20px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.slider-arrow:hover { background: #ffffff; transform: translateY(-50%) scale(1.08); }
.slider-arrow.slider-prev { left: 10px; }
.slider-arrow.slider-next { right: 10px; }

.slider-dots {
  position: absolute;
  bottom: 10px;
  left: 0;
  right: 0;
  z-index: 3;
  display: flex;
  justify-content: center;
  gap: 6px;
}
.slider-dots .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.55);
  border: none;
  padding: 0;
  cursor: pointer;
}
.slider-dots .dot.active { background: #ffffff; }

/* Vista ampliada al hacer clic en la imagen del mockup — un overlay simple,
   sin nombre "modal" a secas para no repetir el choque de CSS que ya tuvimos
   con .avatar-modal vs .modal en otra parte del panel. */
.image-lightbox {
  position: fixed;
  inset: 0;
  z-index: 999;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  cursor: zoom-out;
}
.image-lightbox img,
.image-lightbox video {
  max-width: 90vw;
  max-height: 90vh;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

/* Verde de WhatsApp a propósito (no es decorativo): ayuda a reconocer de un
   vistazo que este botón lleva específicamente ahí, distinto de "Publicar". */
.lightbox-share-btn {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border: none;
  border-radius: 999px;
  background: #25d366;
  color: #ffffff;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}
.lightbox-share-btn:hover { background: #1fb959; }
.lightbox-share-btn .inline-icon { width: 18px; height: 18px; }

/* Envuelve el botón de WhatsApp + el de Historias (cuando el cliente lo tiene
   habilitado) — reemplaza el posicionamiento individual de .lightbox-share-btn
   (pensado para un solo botón centrado) por uno compartido en fila. */
.lightbox-actions {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 3;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  max-width: calc(100% - 32px);
}
.lightbox-actions .lightbox-share-btn {
  position: static;
  transform: none;
}
.lightbox-story-btn {
  background: linear-gradient(135deg, var(--indigo) 0%, var(--purple) 100%);
}
.lightbox-story-btn:hover { filter: brightness(1.1); }

/* Neutro a propósito (no verde ni gradiente) — es un paso intermedio
   ("prepáralo para tu celular"), no la acción final de compartir. */
.lightbox-qr-btn {
  background: rgba(18, 23, 42, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.18);
}
.lightbox-qr-btn:hover { background: rgba(18, 23, 42, 1); }

.qr-share-modal-card {
  max-width: 380px;
  text-align: center;
}
.qr-share-modal-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 4px 0 8px;
}
#qrShareModalImg {
  width: 240px;
  height: 240px;
  border-radius: 16px;
  background: #fff;
  padding: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}
.qr-share-modal-link {
  font-size: 12.5px;
  color: var(--muted);
  word-break: break-all;
  text-decoration: none;
}
.qr-share-modal-link:hover { color: var(--indigo); }
.lightbox-status-wrap {
  position: absolute;
  bottom: 76px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 3;
  max-width: 80vw;
  text-align: center;
}
.lightbox-status-wrap .status { margin: 0; }

/* Pantalla completa gris mientras se genera — un esqueleto animado con la
   forma de un post (avatar + imagen + líneas de texto) en vez de un spinner
   genérico, para que no se "pierda la idea" de qué se está armando. */
.generate-overlay {
  position: fixed;
  inset: 0;
  z-index: 998;
  background: rgba(11, 15, 25, 0.82);
  backdrop-filter: blur(3px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  padding: 24px;
}
.generate-overlay-card {
  width: 100%;
  max-width: 280px;
  background: #ffffff;
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.skeleton-header { display: flex; align-items: center; gap: 10px; }
.skeleton {
  background: linear-gradient(90deg, #e4e4e8 25%, #f2f2f5 37%, #e4e4e8 63%);
  background-size: 400% 100%;
  animation: skeleton-shimmer 1.4s ease infinite;
  border-radius: 8px;
}
.skeleton-avatar { width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0; }
.skeleton-line { height: 12px; border-radius: 6px; }
.skeleton-image { width: 100%; aspect-ratio: 1080 / 1350; border-radius: 10px; }
.skeleton-video { width: 100%; aspect-ratio: 9 / 16; border-radius: 10px; }

/* Caja del loader de Generar: debajo del shimmer de siempre (que se ve
   mientras no hay nada más que mostrar), se revela primero el boceto elegido
   y luego la imagen real que va generando la app — con un "parpadeo" (fundido
   a blanco y de vuelta) en cada transición, ver blinkOverlayTo() en
   generate.js. El shimmer y la imagen nunca conviven: uno de los dos siempre
   está en 0 de opacidad. */
.generate-overlay-image-slot { position: relative; width: 100%; aspect-ratio: 1080 / 1350; border-radius: 10px; overflow: hidden; background: #ffffff; }
.generate-overlay-image-slot .skeleton-image { position: absolute; inset: 0; }
.generate-overlay-template-frame,
.generate-overlay-preview-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.25s ease;
}
.generate-overlay-template-frame.visible,
.generate-overlay-preview-img.visible { opacity: 1; }
/* El boceto es HTML real a tamaño de canvas completo (1080x1350) — se
   renderiza a su tamaño nativo y se reduce con transform:scale (mismo truco
   que .layout-picker-preview), ajustado al ancho fijo de esta tarjeta
   (280px de max-width, menos 32px de padding = 248px). */
.generate-overlay-template-frame iframe { width: 1080px; height: 1350px; border: none; pointer-events: none; transform: scale(0.2296); transform-origin: top left; }
.avatar-generate-overlay-card { max-width: 220px; }
@keyframes skeleton-shimmer {
  0% { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}
.generate-overlay-text {
  color: #ffffff;
  font-size: 15px;
  font-weight: 600;
  text-align: center;
  max-width: 320px;
  margin: 0;
}

/* -- Instagram -- */
.ig-header { display: flex; align-items: center; gap: 10px; padding: 10px 12px; }
.ig-header-text { flex: 1; min-width: 0; }
.ig-username { font-size: 13px; font-weight: 700; color: #14161f; }
.ig-more { color: #262626; font-weight: 700; padding: 0 4px; }
.ig-icons { display: flex; align-items: center; gap: 14px; padding: 10px 12px 4px; font-size: 20px; }
.ig-icons .ig-bookmark { margin-left: auto; font-size: 17px; }
.ig-likes { padding: 4px 12px 4px; font-size: 13px; font-weight: 700; }
.ig-caption {
  padding: 0 12px 4px;
  font-size: 13px;
  line-height: 1.4;
  word-break: break-word;
}
.ig-caption b { margin-right: 4px; }
.ig-comments { padding: 2px 12px 12px; font-size: 12.5px; color: #8e8e8e; }

/* -- Facebook -- */
.fb-header { display: flex; align-items: center; gap: 10px; padding: 12px; }
.fb-header-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.fb-username { font-size: 14px; font-weight: 700; color: #050505; }
.fb-timestamp { font-size: 12px; color: #65676b; }
.fb-more { color: #65676b; font-weight: 700; padding: 0 4px; }
.fb-caption {
  padding: 0 12px 10px;
  font-size: 14px;
  line-height: 1.4;
  color: #050505;
  word-break: break-word;
}

/* Recorte "Ver más" — puramente visual (no despliega nada al hacer clic),
   solo para que el mockup no muestre el caption completo sin cortar. */
.caption-see-more { color: #65676b; font-weight: 700; }
.fb-reactions {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  font-size: 12px;
  color: #65676b;
  border-bottom: 1px solid #ced0d4;
  white-space: nowrap;
}
.fb-reaction-icons { font-size: 13px; flex-shrink: 0; }
.fb-reaction-count { flex-shrink: 0; }
.fb-comments-count { margin-left: auto; overflow: hidden; text-overflow: ellipsis; }
.fb-action-row { display: flex; }
.fb-action-row span {
  flex: 1;
  text-align: center;
  padding: 8px 0;
  font-size: 13px;
  font-weight: 600;
  color: #65676b;
}

.preview-side {
  display: flex;
  flex-direction: column;
}

.preview-side textarea {
  flex: 1;
}

.actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

@media (max-width: 720px) {
  .preview-grid {
    grid-template-columns: 1fr;
  }
}

/* Video con presentador IA (HeyGen) — vertical 9:16, distinto del post 4:5 */
#previewAvatarVideo {
  width: 100%;
  border-radius: 14px;
  border: 1px solid var(--border);
  aspect-ratio: 9 / 16;
  object-fit: cover;
  background: #000;
}

/* Selector de avatar en Configuración */
.avatar-picker-current {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
}

.avatar-picker-current img {
  width: 56px;
  height: 56px;
  border-radius: 10px;
  object-fit: cover;
  border: 1px solid var(--border);
}

/* Prefijo avatar- para no chocar con .modal/.modal-content ya usados por el
   modal del calendario (ese usa .modal-backdrop como overlay) — esa colisión
   de nombres hacía que este modal se viera siempre, sin importar .hidden,
   porque esta regla .modal quedaba después en la cascada y ganaba el empate. */
.avatar-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.avatar-modal.hidden { display: none; }

.avatar-modal-content {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  width: min(900px, 92vw);
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.avatar-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.avatar-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 12px;
  overflow-y: auto;
  padding-right: 4px;
}

.avatar-card {
  cursor: pointer;
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 8px;
  text-align: center;
  background: rgba(255, 255, 255, 0.02);
  transition: border-color 0.15s ease;
}

.avatar-card:hover {
  border-color: #4F46E5;
}

.avatar-card img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 8px;
  margin-bottom: 6px;
  background: #fff;
}

.avatar-card span {
  font-size: 12px;
  color: var(--muted);
}

.avatar-card-appearance {
  display: block;
  font-size: 10.5px;
  line-height: 1.3;
  margin-top: 2px;
  opacity: 0.75;
}

/* Calendario */
.calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.calendar-header h2 {
  margin: 0;
  font-size: 18px;
  text-transform: capitalize;
}

button.small {
  margin-top: 0;
  padding: 8px 14px;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}

.calendar-weekday {
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  padding-bottom: 6px;
}

.calendar-day {
  min-height: 84px;
  min-width: 0; /* los tracks de grid con 1fr no se encogen bajo el ancho de su contenido si no se fija esto explícito — sin esto, un tema largo estiraba toda la columna */
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px;
  cursor: pointer;
  background: var(--input-bg);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.calendar-day:hover { border-color: var(--indigo); }
.calendar-day.other-month { opacity: 0.35; }
.calendar-day.today { border-color: var(--purple); }
.calendar-day.past { opacity: 0.4; cursor: not-allowed; }
.calendar-day.past:hover { border-color: var(--border); }

.calendar-day-number {
  font-size: 13px;
  font-weight: 700;
}

.calendar-event {
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  border-radius: 6px;
  padding: 2px 6px;
  color: white;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0; /* mismo motivo que .calendar-day — es flex item de su columna */
}
.calendar-event-icon { width: 10px; height: 10px; flex-shrink: 0; }
.calendar-event-icon svg { width: 100%; height: 100%; }

.calendar-event.pending { background: #6366f1; }
.calendar-event.running { background: #a855f7; }
.calendar-event.done { background: #16a34a; }
.calendar-event.failed { background: #dc2626; }

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 10;
}

.modal-backdrop.hidden { display: none; }

.modal {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  width: 100%;
  max-width: 440px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal h3 { margin-top: 0; }

input[type="time"] {
  width: 100%;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  padding: 12px 14px;
  margin-bottom: 16px;
}

.day-events {
  margin-top: 20px;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

.day-events h4 { margin: 0 0 10px; font-size: 13px; color: var(--muted); }

.day-event-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.day-event-row:last-child { border-bottom: none; }

.cancel-link {
  color: var(--status-error);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  background: none;
  border: none;
  margin: 0;
  padding: 0;
}

/* ---------- Feed tipo Instagram de "lo que ha creado tu negocio" ---------- */
.created-feed-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.created-feed-item {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--input-bg);
  cursor: zoom-in;
  padding: 0;
  margin: 0;
}
.created-feed-item:hover { border-color: var(--indigo); }
.created-feed-item img,
.created-feed-item video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}
.created-feed-carousel-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  font-size: 14px;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.6));
}
.created-feed-delete-btn {
  position: absolute;
  top: 6px;
  left: 6px;
  width: 22px;
  height: 22px;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s;
}
.created-feed-item:hover .created-feed-delete-btn { opacity: 1; }
.created-feed-delete-btn:hover { background: var(--status-error); }
.created-feed-pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 16px;
  font-size: 13px;
}
.created-feed-pager button:disabled { opacity: 0.35; cursor: default; }

@media (max-width: 560px) {
  .created-feed-grid { grid-template-columns: repeat(2, 1fr); }
}

.product-photos-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 12px;
  max-width: 340px;
}
.product-photo-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
  /* Fondo blanco fijo (no var(--input-bg), que es oscuro en tema oscuro) —
     las fotos de producto suelen tener el fondo recortado (PNG con
     transparencia), y sin esto se ve "transparente"/roto en vez de una
     ficha de producto limpia. */
  background: #ffffff;
}
.product-photo-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.product-photo-delete-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: none;
  background: rgba(11, 15, 25, 0.7);
  color: white;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
}
.product-photo-delete-btn .inline-icon { width: 14px; height: 14px; }
.product-photo-item:hover .product-photo-delete-btn { opacity: 1; }

.logo-preview-item {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 120px;
  padding: 20px;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--input-bg);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  margin-bottom: 12px;
}
.logo-preview-item img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
.logo-preview-item .product-photo-delete-btn { opacity: 1; background: rgba(11, 15, 25, 0.7); }

/* ---------- Catálogo de productos (foto + nombre + descripción) ---------- */
.products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}
.product-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: var(--input-bg);
  display: flex;
  flex-direction: column;
}
.product-card img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; background: #ffffff; }
.product-card-fields { padding: 10px; display: flex; flex-direction: column; gap: 6px; }
.product-card-fields input { margin: 0; font-size: 12.5px; }
.product-card-actions { display: flex; gap: 6px; margin-top: 2px; }
.product-card-actions button { margin: 0; padding: 6px 8px; font-size: 12px; }
.product-card-actions .product-save-btn { flex: 1; }
.product-card-actions .product-delete-btn { flex: 0 0 auto; display: flex; align-items: center; justify-content: center; }
.product-card-actions .product-delete-btn .inline-icon { width: 14px; height: 14px; }

/* Galería de fotos por producto, dentro de la tarjeta — reusa
   .product-photos-grid/.product-photo-item/.product-photo-delete-btn de
   arriba (pensadas originalmente para una grilla suelta de hasta 340px), acá
   en variante compacta porque viven dentro de una .product-card angosta. */
.product-photos-grid--compact { grid-template-columns: repeat(4, 1fr); gap: 6px; max-width: none; margin-bottom: 0; }
.product-photo-add-tile {
  aspect-ratio: 1;
  border-radius: 12px;
  border: 1.5px dashed var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.product-photo-add-tile:hover { border-color: var(--indigo); color: var(--indigo); }
.product-photo-add-tile .inline-icon { width: 16px; height: 16px; }

/* ---------- Vista "Marca" del panel del cliente (antes solo en /admin) ----------
   .products-grid/.product-card/.logo-preview-item de arriba ya se reusan tal
   cual ahí — esto es solo lo que no tenía un equivalente compartido: la
   grilla de campos de identidad y los colores de marca. */
.brand-field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px 16px;
  margin-bottom: 4px;
}
.brand-field { min-width: 0; }
.brand-field label { display: block; font-size: 12.5px; font-weight: 600; color: var(--muted); margin-bottom: 5px; }
.brand-field input, .brand-field select, .brand-field textarea { margin: 0; width: 100%; }
.brand-field input[type="color"] { height: 42px; padding: 4px; cursor: pointer; }
.brand-field-full { grid-column: 1 / -1; }
.brand-field-hint { font-size: 11.5px; margin: 6px 0 0; line-height: 1.4; }

/* Rediseño "Colores de marca" / "Logo del panel" (2026-10-24, a pedido del
   usuario con una referencia de onboarding tipo Holo/competidor): swatches
   grandes y limpios (sin el hex quemado adentro), tarjeta de logo más
   generosa — en vez del grid chiquito/denso de antes. */
.brand-colors-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}
.brand-color-card { position: relative; text-align: center; }
.brand-color-swatch {
  height: 76px;
  border-radius: 16px;
  border: 1px solid var(--border);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}
.brand-color-swatch span { display: none; }
.brand-color-label { display: block; font-size: 12.5px; font-weight: 600; margin-top: 9px; color: var(--muted); }
.brand-color-remove {
  position: absolute; top: 6px; right: 6px;
  width: 24px; height: 24px; border-radius: 50%; border: none;
  background: rgba(11, 15, 25, 0.55); color: #fff;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; opacity: 0; transition: opacity 0.15s;
}
.brand-color-remove .inline-icon { width: 12px; height: 12px; }
.brand-color-card:hover .brand-color-remove { opacity: 1; }

.brand-cards-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}
.brand-cards-row .card { margin-bottom: 0; }
@media (max-width: 760px) { .brand-cards-row { grid-template-columns: 1fr; } }

.brand-add-color-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.brand-add-color-row input[type="color"] { width: 42px; height: 42px; padding: 2px; margin: 0; cursor: pointer; flex-shrink: 0; }
.brand-add-color-row input[type="text"] { flex: 1; min-width: 160px; margin: 0; }

.brand-add-product-form {
  display: none;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
  padding: 12px;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.brand-add-product-form.open { display: flex; }
.brand-add-product-form input { margin: 0; flex: 1; min-width: 160px; }
.brand-add-product-form button { margin: 0; flex-shrink: 0; }

/* Checkbox "Quitar fondo automáticamente" + vista previa — opcional a
   propósito (ver removeBgService.js), el cliente ve cómo quedaría ANTES de
   decidir si lo usa, nunca corre sin que lo pida. */
.remove-bg-check {
  flex-basis: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--muted);
  cursor: pointer;
}
.remove-bg-check input { margin: 0; width: auto; flex: 0 0 auto; }

/* Popup "Así quedaría" (ver removeBgModal en brand.js/admin.js) — al marcar
   "Quitar fondo", en vez de una vista previa metida adentro de la tarjeta
   (se veía apretada y el checkbox se desmarcaba solo sin avisar si la
   petición fallaba), se abre este popup centrado con el resultado real
   antes de decidir. Reusa .modal-overlay/.modal-card del resto de la app. */
.removebg-modal-card { max-width: 420px; text-align: center; }
.removebg-modal-body {
  min-height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 16px 0 20px;
}
.removebg-modal-loading { color: var(--muted); font-size: 13.5px; }
.removebg-modal-img {
  max-width: 100%;
  max-height: 320px;
  border-radius: 12px;
  background: repeating-conic-gradient(#8884 0% 25%, transparent 0% 50%) 0 0 / 16px 16px;
}
.removebg-modal-actions { display: flex; gap: 8px; }
.removebg-modal-actions button { margin: 0; flex: 1; }

/* Panel de confirmación al agregar una foto extra a un producto existente —
   aparece debajo de la grilla de miniaturas al elegir un archivo, en vez de
   subir directo, para poder elegir "Quitar fondo" y ver la vista previa
   antes de guardar de verdad. */
.photo-add-stage {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--input-bg);
}
/* display:flex de arriba empata en especificidad con el [hidden]{display:none}
   del navegador y gana por venir después — sin esto, el panel quedaba visible
   siempre, incluso antes de elegir un archivo. */
.photo-add-stage[hidden] { display: none; }
.photo-add-stage-preview {
  max-width: 110px;
  max-height: 110px;
  border-radius: 8px;
  object-fit: cover;
  align-self: flex-start;
}
.photo-add-stage-actions { display: flex; gap: 6px; }
.photo-add-stage-actions button { margin: 0; padding: 6px 10px; font-size: 12px; }

/* ---------- Rediseño del popup de programar (selector de tipo + lista del día) ---------- */
.schedule-type-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  margin: 4px 0 20px;
}
.schedule-type-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 6px;
  border: 2px solid var(--border);
  border-radius: 14px;
  background: var(--input-bg);
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  text-align: center;
}
.schedule-type-card:hover { border-color: var(--indigo); }
.schedule-type-card.active {
  border-color: var(--indigo);
  color: var(--text);
  background: var(--badge-app-bg);
  box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.25);
}
.schedule-type-icon { font-size: 22px; }
.schedule-type-label { line-height: 1.2; }

.day-event-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.day-event-row:last-child { border-bottom: none; }
.day-event-info { display: flex; align-items: center; gap: 8px; min-width: 0; }
.day-event-info-editable { cursor: pointer; border-radius: 6px; }
.day-event-info-editable:hover { background: var(--hover-overlay); }
.day-event-icon { width: 15px; height: 15px; flex-shrink: 0; }
.day-event-icon svg { width: 100%; height: 100%; }
.day-event-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.day-event-status {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 999px;
  color: white;
  flex-shrink: 0;
}
.day-event-status.pending { background: #6366f1; }
.day-event-status.running { background: #a855f7; }
.day-event-status.done { background: #16a34a; }
.day-event-status.failed { background: #dc2626; }
.icon-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 5px;
  margin: 0;
  flex-shrink: 0;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.icon-btn .inline-icon { width: 15px; height: 15px; }
.icon-btn:hover { color: var(--text); background: var(--hover-overlay); }

@media (max-width: 480px) {
  .schedule-type-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- Panel de "Generar" rediseñado (prompt + tarjetas de acción) ---------- */
.prompt-card { padding-bottom: 24px; }

.quota-line {
  font-size: 13px;
  color: var(--muted);
  padding-bottom: 14px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.avatar-hero-img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 20px;
  margin-bottom: 16px;
}

.avatar-video-desc { margin-bottom: 4px; }

.script-mode-toggle {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.script-mode-btn {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--input-bg);
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.script-mode-btn.active {
  border-color: var(--indigo);
  color: var(--indigo);
  background: var(--badge-app-bg);
}
.script-mode-hint { margin: -8px 0 16px; font-size: 12px; }

.avatar-duration-row {
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 14px;
  margin-bottom: 14px;
}
.avatar-duration-row label { font-size: 12.5px; display: block; margin-bottom: 8px; }
.avatar-duration-row input[type="range"] {
  width: 100%;
  margin: 0;
  display: block;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: var(--border);
  border-radius: 999px;
  cursor: pointer;
}
.avatar-duration-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--indigo);
  cursor: pointer;
}
.avatar-duration-row input[type="range"]::-moz-range-track {
  height: 4px;
  background: var(--border);
  border-radius: 999px;
}
.avatar-duration-row input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--indigo);
  border: none;
  cursor: pointer;
}
.avatar-duration-cost { margin: 6px 0 0; font-size: 12px; }
.avatar-result-cost { margin: 4px 0 8px; font-size: 12.5px; }

.voice-source-toggle { margin-bottom: 12px; }
.elevenlabs-voice-chosen {
  font-size: 13px;
  padding: 10px 12px;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 10px;
}

.modal-card.layout-picker-modal-card.avatar-voice-picker-card { max-width: 1040px; }

.avatar-voice-picker-columns {
  display: grid;
  grid-template-columns: 1fr 1fr 220px;
  gap: 24px;
}

.avatar-voice-picker-column label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
}

.avatar-voice-picker-column .avatar-grid,
.avatar-voice-picker-column .voice-list {
  max-height: 360px;
}

@media (max-width: 860px) {
  .avatar-voice-picker-columns { grid-template-columns: 1fr; }
}

.avatar-bg-preview {
  position: relative;
  width: 100%;
  aspect-ratio: 9 / 16;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--input-bg);
  margin-bottom: 8px;
}
.avatar-bg-preview-color,
.avatar-bg-preview-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.avatar-bg-preview-color { background: var(--indigo); }
.avatar-bg-preview-avatar {
  position: absolute;
  bottom: 0;
  left: 5%;
  width: 90%;
  height: auto;
  max-height: 92%;
  object-fit: contain;
  object-position: bottom;
}
.avatar-bg-hint { font-size: 11px; margin: 0 0 10px; }
.link-btn {
  background: none;
  border: none;
  color: var(--indigo);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 6px 0 0;
  text-align: left;
}

.voice-list {
  max-height: 180px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-top: 8px;
}

#voiceoverVoicePickerList { max-height: 360px; }
.voice-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  font-size: 13px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.voice-row:last-child { border-bottom: none; }
.voice-row:hover { background: var(--hover-overlay); }
.voice-row.selected { background: var(--badge-app-bg); color: var(--indigo); font-weight: 700; }

.voice-preview-btn {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--input-bg);
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.voice-preview-btn:hover { border-color: var(--indigo); color: var(--indigo); }

.avatar-card.selected { border-color: var(--indigo); box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.25); }
.avatar-card.avatar-card-default {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100px;
}
.avatar-card-default-icon { font-size: 28px; margin-bottom: 6px; }

.eyebrow {
  color: var(--indigo);
  font-weight: 700;
  font-size: 22px;
  margin-bottom: 4px;
}

.hero-heading {
  font-family: 'Graduate', serif;
  font-size: 30px;
  font-weight: 400;
  margin: 0 0 20px;
  color: var(--text);
}

.prompt-box {
  position: relative;
  border: 1px solid var(--indigo);
  border-radius: 20px;
  padding: 18px 60px 18px 20px;
  margin-bottom: 16px;
}
.prompt-box textarea {
  width: 100%;
  border: none;
  background: transparent;
  resize: none;
  font: inherit;
  color: var(--text);
  padding: 0;
}
.prompt-box textarea:focus { outline: none; }
.prompt-submit {
  position: absolute;
  right: 16px;
  bottom: 16px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--text);
  background: transparent;
  color: var(--text);
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.prompt-submit:hover { border-color: var(--indigo); color: var(--indigo); }

/* ---------- Editor de Video: mockup con adjuntos + miniaturas + formato ---------- */
.video-upload-row {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.video-upload-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 18px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--input-bg);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.video-upload-trigger:hover { border-color: var(--indigo); color: var(--indigo); }
.video-upload-trigger svg { width: 18px; height: 18px; flex-shrink: 0; }

.video-clip-thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  flex: 1;
  min-width: 160px;
}

.video-clip-thumb {
  position: relative;
  width: 68px;
  border: 2px solid var(--clip-color, var(--border));
  border-radius: 10px;
  overflow: hidden;
  background: var(--input-bg);
  display: flex;
  flex-direction: column;
}
.video-clip-thumb-img-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  background: #000;
}
.video-clip-thumb-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.video-clip-thumb-number {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.video-clip-thumb-name {
  font-size: 9px;
  color: var(--muted);
  padding: 3px 4px 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.video-clip-thumb-controls {
  display: flex;
  justify-content: space-between;
  padding: 2px 3px 3px;
  gap: 2px;
}
.video-clip-thumb-controls button {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 10px;
  cursor: pointer;
  padding: 2px 0;
  border-radius: 4px;
}
.video-clip-thumb-controls button:hover:not(:disabled) { background: var(--hover-overlay); color: var(--text); }
.video-clip-thumb-controls button:disabled { opacity: 0.3; cursor: default; }

.video-format-picker {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.video-format-icons { display: flex; gap: 6px; }
.format-icon-btn {
  width: 36px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--input-bg);
  color: var(--muted);
  cursor: pointer;
  padding: 0;
}
.format-icon-btn svg { width: 20px; height: 20px; }
.format-icon-btn:hover { border-color: var(--indigo); }
.format-icon-btn.active { border-color: var(--text); color: var(--text); border-width: 2px; }
.video-format-label { font-size: 11px; }

.video-clips-hint { font-size: 12px; margin: 0 0 20px; }

/* ---------- Extracción de "mejores momentos" desde video crudo largo ---------- */
.highlights-gallery-list { display: flex; flex-direction: column; gap: 16px; }
.highlight-card { border: 1px solid var(--border); border-radius: 14px; padding: 16px; }
.highlight-card-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.highlight-card-time { font-size: 12px; font-weight: 700; color: var(--indigo); }
.highlight-card-title { font-size: 15px; font-weight: 700; margin: 4px 0; }
.highlight-card-reason { font-size: 13px; color: var(--muted); margin: 0 0 10px; }
.highlight-card-result { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 10px; }
.highlight-card-result video { max-width: 280px; border-radius: 14px; border: 1px solid var(--border); }

.video-options-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 18px;
}
.video-option-col label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 8px;
}
.field-hint-inline {
  font-size: 11.5px;
  font-weight: 400;
}

.pill-input {
  width: 100%;
  padding: 12px 18px;
  border-radius: 999px;
  border: 1px solid var(--indigo);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 13px;
}
.pill-input:focus { outline: none; }
.pill-input::placeholder { color: var(--muted); }

.pill-dropdown .font-picker-trigger { border-radius: 999px; border-color: var(--indigo); }

.voiceover-toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 600;
}

.avatar-subtitle-option { margin-bottom: 18px; max-width: 320px; }

.toggle-switch { position: relative; display: inline-block; width: 40px; height: 22px; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.15s;
}
.toggle-switch input:checked + .toggle-slider { background: var(--indigo); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(18px); }

.prompt-generate-btn {
  padding: 12px 28px;
  border-radius: 999px;
  border: none;
  background: linear-gradient(135deg, var(--indigo) 0%, var(--purple) 100%);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
}
.prompt-generate-btn:hover { opacity: 0.92; }
.prompt-generate-btn:disabled { opacity: 0.6; cursor: default; }

.video-edit-actions-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

.secondary-generate-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--input-bg);
  color: var(--text);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
}
.secondary-generate-btn:hover { border-color: var(--indigo); color: var(--indigo); }
.secondary-generate-btn:disabled { opacity: 0.6; cursor: default; }
.secondary-generate-btn svg { width: 18px; height: 18px; flex-shrink: 0; }

.pill-row .pill-chip {
  padding: 8px 18px;
  border-radius: 999px;
}

/* Modal para elegir plantilla (se abre al darle a la flecha de "Generar") */
.modal-card.layout-picker-modal-card {
  max-width: 620px;
  max-height: 85vh;
  overflow-y: auto;
}
.layout-picker-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}
.layout-picker-modal-header h3 { margin: 0 0 4px; }
.layout-picker-modal-header-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.layout-picker-slide-count-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}
.layout-picker-slide-count-row label { font-size: 13px; font-weight: 600; margin: 0; }
.layout-picker-slide-count-row select {
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}
.layout-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 16px;
}
.layout-picker-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 8px;
  border: 2px solid var(--border);
  border-radius: 12px;
  background: var(--card);
  cursor: pointer;
}
.layout-picker-card:hover { border-color: var(--indigo); }
.layout-picker-card.selected { border-color: var(--indigo); box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.25); }
.layout-picker-preview {
  width: 100%;
  aspect-ratio: 4 / 5;
  border-radius: 8px;
  overflow: hidden;
  background: #ffffff;
  position: relative;
}
.layout-picker-preview iframe {
  width: 1080px;
  height: 1350px;
  border: none;
  pointer-events: none;
  transform: scale(0.139);
  transform-origin: top left;
}
.layout-picker-random {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  background: var(--bg);
}
.layout-picker-label {
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  line-height: 1.2;
  color: var(--text);
}
.layout-picker-sublabel {
  font-size: 11px;
  color: var(--muted);
  text-align: center;
  line-height: 1.2;
}
.layout-picker-see-more {
  display: block;
  margin: 16px 0 0 auto;
  background: none;
  border: none;
  color: var(--indigo);
  font-weight: 600;
  cursor: pointer;
  padding: 4px;
}

.action-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-top: 20px;
}
.action-card-wrap { position: relative; }
.action-card {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  text-align: left;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #ffffff;
  color: #14161f;
  transition: border-color 0.15s;
}
.action-card:hover { border-color: var(--indigo); }
.action-card-img {
  width: 100%;
  height: 110px;
  object-fit: cover;
  border-radius: 10px;
  margin-bottom: 4px;
  background: #ffffff;
}
.action-card-title {
  font-weight: 700;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: #14161f;
}
.action-card-desc {
  font-family: 'Graduate', serif;
  font-size: 13px;
  color: #4b4f5c;
  line-height: 1.4;
}
.action-card-wrap .attach-menu { top: calc(100% + 8px); left: 0; right: 0; }

.action-card-img-remove {
  position: absolute;
  top: 22px;
  right: 22px;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: rgba(20, 22, 31, 0.65);
  color: #ffffff;
  cursor: pointer;
  z-index: 1;
}
.action-card-img-remove:hover { background: var(--status-error); }
.action-card-img-remove svg { width: 14px; height: 14px; }

/* Modal genérico (hoy solo lo usa el carrusel, pero sirve para cualquier otro
   flujo que necesite una decisión rápida antes de generar). */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 999;
  background: rgba(11, 15, 25, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.modal-card {
  width: 100%;
  max-width: 360px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
}
.modal-card h3 { margin: 0 0 6px; }
.modal-card select {
  width: 100%;
  margin: 14px 0 20px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ---------- Timeline: botón "Cortar aquí" (dividir un tramo en el punto
   donde está el preview) ---------- */
.video-timeline-split-btn {
  width: fit-content;
  margin: 0 auto 10px;
}

/* ---------- Recortar un clip individual (antes de subir) ---------- */
.video-clip-trim-btn.is-trimmed { color: var(--indigo); }

.clip-trim-modal-card {
  max-width: 560px;
  max-height: 85vh;
  overflow-y: auto;
}
.clip-trim-video {
  width: 100%;
  max-height: 320px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #000;
  display: block;
  margin-bottom: 12px;
}

/* ---------- Elegir desde dónde empieza la música (click en "Usar esta"
   revela este panel inline antes de aplicar de verdad) ---------- */
.music-track-row { flex-wrap: wrap; }
.music-offset-panel {
  flex: 1 0 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--input-bg);
}
.music-offset-waveform-wrap { position: relative; height: 48px; }
.music-offset-waveform-canvas { width: 100%; height: 48px; display: block; border-radius: 6px; }
.music-offset-window {
  position: absolute;
  top: 0;
  height: 100%;
  background: rgba(99, 102, 241, 0.18);
  border-left: 2px solid var(--indigo);
  border-right: 2px solid var(--indigo);
  pointer-events: none;
}
.music-offset-handle {
  position: absolute;
  top: -4px;
  width: 14px;
  height: 56px;
  margin-left: -7px;
  border-radius: 7px;
  background: var(--indigo);
  cursor: ew-resize;
  touch-action: none;
}
.music-offset-label { margin: 0; font-size: 12px; color: var(--muted); }
.music-offset-actions { display: flex; gap: 8px; }
.music-offset-number-label { font-size: 13px; color: var(--muted); }
.music-offset-number-input { width: 110px; margin: 0; }
