/* ==========================================================================
   ZENVIX
   Identidad del logo: morado #561ccb es la BASE (botones, estados activos,
   foco) y el coral #ff5e53 es solo ACENTO (gemas, avisos). Sin degradados de
   dos colores: cada uno resalta porque el otro no compite.
   Oscuro por defecto; el claro se activa con [data-theme="light"] en <html>.
   ========================================================================== */

/* --- Tokens: OSCURO (default) ------------------------------------------- */
:root {
  --bg:         #08080b;
  --surface:    #101016;
  --surface-2:  #17171f;
  --surface-3:  #20212b;
  --surface-4:  #2a2b37;
  --border:     #23242e;
  --border-2:   #32333f;

  --text:       #f3f3f7;
  --text-dim:   #a0a0b0;
  --text-mute:  #6a6a7c;

  /* El morado del logo es #561ccb = hsl(260, 76%, 45%). Sobre el fondo oscuro
     ese valor se hunde, asi que se sube la luminosidad SIN mover el tono: el
     color sigue siendo el de la marca, solo que legible aqui. */
  --brand:       #7c46e8;
  --brand-hover: #6b32e0;
  --brand-press: #5c27c9;
  --brand-ink:   #ffffff;
  --brand-soft:  rgba(124, 70, 232, .16);
  --brand-line:  rgba(124, 70, 232, .42);

  /* El coral es ACENTO: gemas, notificaciones y poco mas. No pinta botones ni
     fondos, porque compitiendo con el morado ninguno de los dos resalta. */
  --accent:      #ff5e53;
  --accent-soft: rgba(255, 94, 83, .14);
  --gem:         var(--accent);
  --gem-soft:    var(--accent-soft);

  --ok:         #37c98b;
  --warn:       #e8b13c;
  --danger:      #f4645a;
  --danger-hover:#e04b40;
  --danger-soft: rgba(244, 100, 90, .12);

  --r-sm: 10px;
  --r:    14px;
  --r-lg: 20px;
  --r-xl: 26px;

  --shadow-sm: 0 1px 2px rgba(0,0,0,.28);
  --shadow:    0 2px 8px rgba(0,0,0,.34);
  --shadow-lg: 0 18px 48px rgba(0,0,0,.5);
  --ring:      0 0 0 3px var(--brand-soft);
  /* Sombra tenida de marca para lo que va en morado. */
  --shadow-brand: 0 4px 14px rgba(86, 28, 203, .30);

  --rail:      76px;
  --sidebar:   268px;
  --topbar-h:  56px;
  /* Hueco que deja libre la barra flotante de movil para que el contenido no
     termine debajo de ella. En escritorio se pone a 0. */
  /* Alto real de la barra flotante mas su separacion del borde: 4+9+20+9+4 de
     la barra y 8 de abajo. Lo usan el compositor y las vistas con scroll para
     no quedar tapados. Si cambia el padding del rail, cambia esto. */
  --rail-gap:  calc(54px + env(safe-area-inset-bottom, 0px));

  --ease: cubic-bezier(.22,.61,.36,1);

  color-scheme: dark;
}

/* --- Tokens: CLARO ------------------------------------------------------- */
[data-theme="light"] {
  --bg:         #f6f6fa;
  --surface:    #ffffff;
  --surface-2:  #f3f3f8;
  --surface-3:  #eaeaf2;
  --surface-4:  #dedee9;
  --border:     #e4e4ed;
  --border-2:   #d3d3e0;

  --text:       #14141b;
  --text-dim:   #5a5a6b;
  --text-mute:  #8c8c9d;

  /* Aqui si cabe el morado exacto del logotipo. */
  --brand:       #561ccb;
  --brand-hover: #4715ab;
  --brand-press: #3a108f;
  --brand-ink:   #ffffff;
  --brand-soft:  rgba(86, 28, 203, .10);
  --brand-line:  rgba(86, 28, 203, .30);

  --accent:      #ec4a3f;
  --accent-soft: rgba(236, 74, 63, .10);
  --gem:         var(--accent);
  --gem-soft:    var(--accent-soft);

  --ok:         #18996a;
  --warn:       #b8811f;
  --danger:      #d6453a;
  --danger-hover:#b8352b;
  --danger-soft: rgba(214, 69, 58, .10);

  --shadow-sm: 0 1px 2px rgba(20,20,40,.06);
  --shadow:    0 1px 3px rgba(20,20,40,.08);
  --shadow-lg: 0 16px 44px rgba(20,20,50,.14);
  --shadow-brand: 0 4px 14px rgba(86, 28, 203, .22);

  color-scheme: light;
}

/* --- Base ---------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font: 400 14px/1.55 "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI",
        Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}

/* La transicion de tema se activa por JS solo durante el cambio, para que la
   carga inicial no dispare 300ms de animacion en toda la pagina. */
.theming, .theming * {
  transition: background-color .28s var(--ease), border-color .28s var(--ease),
              color .28s var(--ease) !important;
}

button, input, textarea, select { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; padding: 0; }
a { color: inherit; text-decoration: none; }

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

::selection { background: var(--brand-soft); color: var(--text); }

svg.i { width: 20px; height: 20px; flex: none; stroke-width: 1.5; }
svg.i-sm { width: 16px; height: 16px; }
svg.i-lg { width: 24px; height: 24px; }

/*
  Iconos servidos como archivo desde /assets/img/icons/.
  
  Van de MASCARA y no dentro de un <img> porque un <img> no puede heredar el
  color del texto: el icono del rail activo se pinta de morado, el del toast de
  error de rojo y todo el set cambia entre tema claro y oscuro. Como mascara el
  archivo aporta la silueta y el color lo pone `currentColor`, que es
  exactamente lo que hacia el SVG en linea. El archivo se cachea aparte, que es
  lo que se gana respecto a incrustarlo en cada pagina.
*/
.ico {
  display: inline-block;
  width: 20px; height: 20px; flex: none;
  background-color: currentColor;
  -webkit-mask: var(--ico) center / contain no-repeat;
          mask: var(--ico) center / contain no-repeat;
}
.ico.i-sm { width: 16px; height: 16px; }
.ico.i-lg { width: 24px; height: 24px; }

/*
  Pares de iconos que dependen del tema. El servidor no puede saber cual toca
  (el tema vive en el navegador), asi que manda los dos y aqui se ensena uno.
  El default es oscuro, igual que en :root.
*/
.si-claro { display: none; }
[data-theme="light"] .si-oscuro { display: none; }
[data-theme="light"] .si-claro { display: inline-block; }

/* Los de marca (Google, la gema) llevan su color dentro y van como imagen de
   verdad: ahi la mascara sobra y taparia el color. */
img.ico {
  background: none;
  -webkit-mask: none;
          mask: none;
  object-fit: contain;
}

.sr {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* Scrollbars discretos */
* { scrollbar-width: thin; scrollbar-color: var(--surface-4) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--surface-4);
  border-radius: 99px;
  border: 3px solid transparent;
  background-clip: content-box;
}
*::-webkit-scrollbar-thumb:hover { background-color: var(--border-2); background-clip: content-box; }

/* ==========================================================================
   LAYOUT
   ========================================================================== */
/* ==========================================================================
   LAYOUT

   Mobile-first: lo que se lee aqui abajo es la version de telefono, y el
   escritorio se construye encima con `min-width`. Se hizo asi y no al reves
   porque en una media query `max-width` la version chica hereda todo lo del
   escritorio y hay que ir desmontandolo propiedad por propiedad; partiendo de
   movil, cada pantalla mas grande solo anade.

   En movil:  topbar arriba, contenido, y el rail flotando abajo como la barra
              de una app. El sidebar es un cajon que entra desde la izquierda.
   Desde 900px: el topbar cruza todo el ancho por encima, y debajo quedan las
              tres columnas (rail, sidebar, main).
   ========================================================================== */
.app {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: var(--topbar-h) 1fr;
  grid-template-areas:
    "topbar"
    "main";
  height: 100dvh;
  overflow: hidden;
}

.topbar  { grid-area: topbar; }
.main    { grid-area: main; }
.sidebar { grid-area: sidebar; }
.rail    { grid-area: rail; }

/* Velo para el cajon de conversaciones en movil. */
.veil {
  position: fixed; inset: 0;
  z-index: 55;
  background: rgba(4, 4, 8, .5);
  animation: fade .16s var(--ease);
}
.veil[hidden] { display: none; }

/* --- Rail: barra flotante abajo en movil --------------------------------- */
.rail {
  position: fixed;
  left: 8px; right: 8px;
  /* safe-area: en iPhone la franja del gesto se comeria la barra. */
  bottom: calc(8px + env(safe-area-inset-bottom, 0px));
  z-index: 60;

  display: flex;
  align-items: center;
  justify-content: space-around;
  gap: 2px;
  padding: 4px;

  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
}

/* El logotipo y el espaciador son cosa del rail vertical: en la barra de
   abajo solo caben los destinos. */
.rail-logo,
.rail-spacer { display: none; }
.rail-logo .ico { width: 26px; height: 26px; }

.rail-btn {
  flex: 1;
  min-width: 0;
  padding: 9px 2px;
  border-radius: var(--r-sm);
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  color: var(--text-mute);
  transition: background .16s var(--ease), color .16s var(--ease);
}
/* En la barra de abajo el icono basta: la etiqueta obligaba a una barra mucho
   mas alta y son cuatro destinos que se reconocen de sobra. Vuelve en el rail
   vertical, donde hay sitio de sobra. */
.rail-btn span {
  display: none;
  font-size: 10px; font-weight: 500; letter-spacing: .01em;
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.rail-btn.on { color: var(--text); }
.rail-btn.on svg, .rail-btn.on .ico { color: var(--brand); }

.avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--surface-3);
  object-fit: cover;
  border: 1.5px solid var(--border-2);
  display: grid; place-items: center;
  font-size: 13px; font-weight: 600; color: var(--text-dim);
  flex: none;
  overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }

/* --- Sidebar: cajon deslizante en movil ---------------------------------- */
.sidebar {
  position: fixed;
  top: var(--topbar-h); bottom: 0; left: 0;
  z-index: 58;
  width: min(var(--sidebar), 84vw);

  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  min-width: 0;
  overflow: hidden;

  transform: translateX(-101%);
  transition: transform .24s var(--ease);
  box-shadow: var(--shadow-lg);
}
.app.sidebar-open .sidebar { transform: translateX(0); }

.sidebar-head {
  padding: 16px 16px 12px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.sidebar-head h2 { margin: 0; font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--text-mute); }

.btn-new {
  margin: 0 12px 12px;
  padding: 11px 14px;
  border-radius: var(--r);
  background: var(--brand);
  color: #fff;
  font-weight: 600; font-size: 13.5px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  box-shadow: var(--shadow-brand);
  transition: transform .14s var(--ease), box-shadow .14s var(--ease);
}
.btn-new:hover { background: var(--brand-hover); transform: translateY(-1px); box-shadow: var(--shadow-brand); }
.btn-new:active { transform: translateY(0); }

.conv-list { flex: 1; overflow-y: auto; padding: 0 8px 16px; }

.conv {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px;
  border-radius: var(--r-sm);
  margin-bottom: 2px;
  color: var(--text-dim);
  min-width: 0;
  transition: background .14s var(--ease), color .14s var(--ease);
  width: 100%;
  text-align: left;
}
.conv:hover { background: var(--surface-2); color: var(--text); }
.conv.on { background: var(--surface-3); color: var(--text); }

.conv-thumb {
  width: 32px; height: 32px; border-radius: 9px;
  background: var(--surface-3);
  object-fit: cover; flex: none;
  display: grid; place-items: center;
  color: var(--text-mute);
  overflow: hidden;
}
.conv-thumb img { width: 100%; height: 100%; object-fit: cover; }

.conv-body { min-width: 0; flex: 1; display: block; overflow: hidden; }
.conv-title {
  display: block;
  font-size: 13px; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.conv-meta { display: block; font-size: 11px; color: var(--text-mute); margin-top: 1px; }

.conv-del {
  opacity: 0; color: var(--text-mute); padding: 4px; border-radius: 6px;
  transition: opacity .14s, color .14s, background .14s;
  flex: none;
}
.conv:hover .conv-del { opacity: 1; }
.conv-del:hover { color: var(--danger); background: var(--danger-soft); }

.sidebar-empty {
  padding: 28px 20px; text-align: center;
  color: var(--text-mute); font-size: 12.5px; line-height: 1.6;
}

/* --- Columna principal ---------------------------------------------------- */
.main {
  display: flex; flex-direction: column;
  min-width: 0; overflow: hidden;
  background: var(--bg);
}

/* --- Topbar --------------------------------------------------------------- */
.topbar {
  height: var(--topbar-h); flex: none;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
  padding: 0 12px;
  background: var(--surface);
  z-index: 59;
}

/*
  El logotipo completo (palabra + chispa). Va aqui y no en el rail porque es
  horizontal: en una columna de 76px habia que recortarlo a la chispa suelta,
  que es marca a medias. La palabra hereda el color del texto, blanca en
  oscuro y morada en claro, porque el #561ccb sobre el fondo oscuro no se lee.
*/
.topbar-logo {
  display: flex; align-items: center;
  flex: none;
  color: var(--text);
  padding: 4px;
  border-radius: var(--r-sm);
}
[data-theme="light"] .topbar-logo { color: #561ccb; }
.topbar-logo svg, .topbar-logo .ico { width: 92px; height: auto; display: block; }

/* El topbar no lleva titulo; esto es lo que empuja las acciones a la derecha. */
.topbar-gap { flex: 1; min-width: 0; }

/* Separa el titulo de las acciones de la derecha (gemas, tema, cuenta). */
.topbar-actions {
  display: flex; align-items: center; gap: 6px;
  flex: none;
  margin-left: auto;
}

.icon-btn {
  width: 36px; height: 36px;
  border-radius: var(--r-sm);
  display: grid; place-items: center;
  color: var(--text-dim);
  transition: background .14s var(--ease), color .14s var(--ease);
  flex: none;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

.gem-pill {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 13px 7px 10px;
  border-radius: 99px;
  background: var(--gem-soft);
  border: 1px solid transparent;
  font-size: 13px; font-weight: 650;
  color: var(--gem);
  transition: border-color .14s var(--ease), transform .14s var(--ease);
  flex: none;
}
.gem-pill:hover { border-color: var(--gem); transform: translateY(-1px); }
.gem-pill svg, .gem-pill .ico { width: 16px; height: 16px; }

/* ==========================================================================
   HILO DE CHAT
   ========================================================================== */
.thread {
  flex: 1;
  overflow-y: auto;
  /* Nada del hilo debe poder empujar la pagina a lo ancho: el carrusel de
     sugerencias sale del padding a proposito y sin esto arrastraba la vista. */
  overflow-x: hidden;
  overscroll-behavior: contain;
  padding: 16px 12px 4px;
  scroll-behavior: smooth;
}
.thread-inner { max-width: 860px; margin: 0 auto; min-width: 0; }

.msg { margin-bottom: 26px; }

.msg-user {
  display: flex; justify-content: flex-end;
}
.msg-user .bubble {
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: var(--r-lg) var(--r-lg) 6px var(--r-lg);
  padding: 12px 16px;
  max-width: 76%;
  font-size: 14px;
  white-space: pre-wrap;
  word-break: break-word;
}
.msg-user .refs { display: flex; gap: 6px; margin-top: 9px; }
.msg-user .refs img { width: 42px; height: 42px; border-radius: 8px; object-fit: cover; }

.msg-bot { display: flex; gap: 12px; }
.bot-avatar {
  width: 30px; height: 30px; border-radius: 9px;
  background: var(--brand);
  display: grid; place-items: center; flex: none;
  margin-top: 2px;
}
.bot-avatar svg, .bot-avatar .ico { width: 16px; height: 16px; color: #fff; }
.msg-bot .body { flex: 1; min-width: 0; }

.gen-meta {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  margin-bottom: 10px;
}
.tag {
  font-size: 11px; font-weight: 550;
  padding: 3.5px 9px;
  border-radius: 99px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  display: inline-flex; align-items: center; gap: 5px;
}
.tag svg, .tag .ico { width: 12px; height: 12px; }
.tag-gem { color: var(--gem); background: var(--gem-soft); border-color: transparent; }
.tag-dot { width: 7px; height: 7px; border-radius: 50%; }

/* Rejilla de resultados: 1 o 2 imagenes */
.grid-out {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
  gap: 12px;
  max-width: 620px;
}
.grid-out.two { grid-template-columns: 1fr; }

.shot {
  position: relative;
  border-radius: var(--r-lg);
  overflow: hidden;
  background: var(--surface-2);
  border: 1px solid var(--border);
  aspect-ratio: var(--ar, 1);
}
.shot img { width: 100%; height: 100%; object-fit: cover; display: block; }

.shot-bar {
  position: absolute; inset: auto 0 0 0;
  padding: 26px 10px 10px;
  display: flex; gap: 6px; justify-content: flex-end;
  background: linear-gradient(to top, rgba(0,0,0,.62), transparent);
  opacity: 0;
  transition: opacity .18s var(--ease);
}
.shot:hover .shot-bar, .shot:focus-within .shot-bar { opacity: 1; }

.shot-act {
  width: 32px; height: 32px;
  border-radius: 9px;
  background: rgba(18,18,24,.72);
  backdrop-filter: blur(8px);
  color: #fff;
  display: grid; place-items: center;
  transition: background .14s var(--ease), transform .14s var(--ease);
}
.shot-act:hover { background: rgba(18,18,24,.94); transform: translateY(-2px); }
.shot-act.fav { color: var(--gem); }
.shot-act:disabled { opacity: .72; cursor: default; transform: none; }
.shot-boost {
  width: auto; padding: 0 10px;
  display: inline-flex; gap: 5px;
  font-size: 10.5px; font-weight: 650;
}
.shot-hd-badge {
  position: absolute; top: 10px; right: 10px;
  padding: 4px 8px; border-radius: 99px;
  background: var(--gem); color: #fff;
  box-shadow: 0 4px 14px rgba(242,109,83,.3);
  font-size: 10px; font-weight: 750; letter-spacing: .08em;
}

/* Estado de generacion en curso */
.gen-loading {
  display: flex; align-items: center; gap: 12px;
  padding: 18px 20px;
  border-radius: var(--r-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  max-width: 420px;
}
.spinner {
  width: 20px; height: 20px; flex: none;
  border: 2px solid var(--border-2);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.gen-loading-text { font-size: 13px; color: var(--text-dim); }
.gen-loading-text b { display: block; color: var(--text); font-weight: 600; margin-bottom: 1px; }

/* ==========================================================================
   ESPERAS

   Dos cosas distintas, y conviene no confundirlas:

   1. CAMBIAR DE PAGINA. Ahora es una navegacion de verdad, asi que durante la
      espera lo que sigue en pantalla es la pagina ANTERIOR. Ahi no cabe un
      esqueleto: el documento nuevo todavia no existe. Lo que si se puede es
      decir claramente "voy", y de ahi el velo.

   2. IMAGENES. El HTML llega entero, pero las imagenes tardan. Ese si es el
      sitio del esqueleto, porque el hueco ya esta reservado y solo falta
      rellenarlo.
   ========================================================================== */

/* --- 1. Velo de navegacion ------------------------------------------------ */
.nav-espera {
  position: fixed; inset: 0;
  z-index: 500;
  display: grid; place-items: center;
  background: rgba(8, 8, 11, .74);
  backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s var(--ease);
}
[data-theme="light"] .nav-espera { background: rgba(246, 246, 250, .82); }

/* Solo se enciende si la espera se nota; ver ui.js. Un velo que parpadea en
   cada clic rapido estorba mas que la propia espera. */
.nav-espera.va { opacity: 1; pointer-events: auto; }

.nav-espera-caja { display: grid; justify-items: center; gap: 16px; }

/*
  Espera larga.

  Si pasado medio segundo la pagina sigue sin llegar, la marca latiendo deja de
  informar: ya sabemos que esta cargando, lo que no sabemos es si falta mucho.
  Entonces el velo pasa a ensenar la SILUETA de una pagina, que ademas prepara
  la vista para lo que va a aparecer.
*/
.nav-espera .nav-esqueleto { display: none; }
.nav-espera.largo .nav-espera-caja { display: none; }
.nav-espera.largo .nav-esqueleto { display: block; }

.nav-esqueleto {
  width: min(720px, calc(100vw - 40px));
  padding: 0 4px;
}
.nav-esqueleto span {
  display: block;
  border-radius: 10px;
  background-image: linear-gradient(100deg, var(--surface-2) 20%, var(--surface-3) 40%, var(--surface-2) 60%);
  background-size: 260% 100%;
  animation: shimmer 1.4s linear infinite;
}
.nav-esq-titulo { height: 26px; width: 45%; margin-bottom: 10px; }
.nav-esq-sub    { height: 13px; width: 28%; margin-bottom: 26px; }
.nav-esq-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
}
.nav-esq-grid span { height: 86px; border-radius: var(--r); }

@media (min-width: 900px) {
  .nav-esq-grid { grid-template-columns: repeat(3, 1fr); }
}

.nav-marca {
  width: 62px; height: 62px;
  border-radius: 20px;
  background: var(--brand);
  display: grid; place-items: center;
  box-shadow: var(--shadow-brand);
  animation: latido 1.2s ease-in-out infinite;
}
.nav-marca .ico { width: 30px; height: 30px; }

@keyframes latido {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(.87); }
}

.nav-espera b {
  font-size: 13px; font-weight: 550; color: var(--text-dim); letter-spacing: .01em;
}

/* --- 2. Esqueleto de imagen ----------------------------------------------- */
/*
  El brillo va en el CONTENEDOR y la imagen encima: al cargar aparece por
  transparencia y tapa el brillo. Asi no hay un segundo elemento que quitar ni
  salto de maquetacion, porque el hueco ya lo reserva el contenedor con su
  proporcion.
*/
.js .shot,
.js .conv-thumb,
.js .adm-av {
  background-image: linear-gradient(100deg, var(--surface-2) 20%, var(--surface-3) 40%, var(--surface-2) 60%);
  background-size: 260% 100%;
  animation: shimmer 1.4s linear infinite;
}
@keyframes shimmer { to { background-position: -160% 0; } }

/* Ya cargada: se apaga el brillo, que si no sigue gastando pintado para nada. */
.shot.lista,
.conv-thumb.lista,
.adm-av.lista { background-image: none; animation: none; }

.js .shot img,
.js .conv-thumb img,
.js .adm-av img {
  opacity: 0;
  transition: opacity .3s var(--ease);
}
.shot img.lista,
.conv-thumb img.lista,
.adm-av img.lista { opacity: 1; }

/* Las miniaturas sin imagen (llevan un icono o una inicial dentro) no deben
   brillar eternamente: ahi no va a llegar nada. */
.conv-thumb:not(:has(img)),
.adm-av:not(:has(img)) { background-image: none; animation: none; }

@media (prefers-reduced-motion: reduce) {
  .shot, .conv-thumb, .adm-av, .nav-marca, .nav-esqueleto span { animation: none; }
  .shot img, .conv-thumb img, .adm-av img { transition: none; }
}

/* --- Modal de resultado ----------------------------------------------------
   Reaprovecha el marco de .gate; solo cambia la cabecera. */
.aviso-head { display: flex; align-items: flex-start; gap: 13px; }
.aviso-head .ico { margin-top: 1px; }
.aviso-head.ok .ico { color: var(--ok); }
.aviso-head.error .ico { color: var(--danger); }
.aviso-head b { display: block; font-size: 16px; font-weight: 650; letter-spacing: -.01em; }
.aviso-head span {
  display: block; font-size: 13px; color: var(--text-dim);
  margin-top: 4px; line-height: 1.5;
}

/* --- Respuesta cuando el mensaje no pide una imagen ------------------------
   Tono de conversacion, no de error: el usuario no hizo nada mal, solo
   escribio en un sitio donde unicamente se generan imagenes. */
.solo-img {
  padding: 16px 18px;
  border-radius: var(--r-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  max-width: 520px;
}
.solo-img > b { display: block; font-size: 14px; font-weight: 650; }
.solo-img p { margin: 6px 0 0; font-size: 13px; color: var(--text-dim); line-height: 1.55; }
.solo-img p b { color: var(--text); font-weight: 600; }
.solo-img p i { color: var(--text); font-style: italic; }

.solo-img-ej { margin-top: 14px; display: flex; flex-direction: column; gap: 6px; }
.solo-img-ej > span { font-size: 11.5px; color: var(--text-mute); }
.solo-img-ej .btn-ghost { align-self: flex-start; text-align: left; }

.solo-img .ref-picker-acts { margin-top: 16px; }

.msg-error {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 14px 16px;
  border-radius: var(--r);
  background: var(--danger-soft);
  border: 1px solid rgba(244,100,90,.25);
  color: var(--text);
  font-size: 13px;
  max-width: 560px;
}
.msg-error svg, .msg-error .ico { color: var(--danger); margin-top: 1px; }
.msg-error b { display: block; margin-bottom: 2px; }

/* --- Selector de imagen de referencia ------------------------------------
   Aparece dentro del hilo cuando el mensaje parece un ajuste sobre una imagen
   anterior. Todo con variables para que herede el tema claro sin reglas extra. */
.ref-picker {
  border: 1px solid var(--brand-line);
  background: var(--brand-soft);
  border-radius: var(--r-lg);
  padding: 15px;
  max-width: 560px;
}
.ref-picker-head { display: flex; gap: 10px; margin-bottom: 13px; }
.ref-picker-head svg, .ref-picker-head .ico { color: var(--brand); margin-top: 2px; flex: none; }
.ref-picker-head b { display: block; font-size: 13.5px; margin-bottom: 3px; }
.ref-picker-head span { font-size: 12px; color: var(--text-dim); line-height: 1.45; }

.ref-picker-grid { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }

.ref-opt {
  position: relative;
  width: 84px; height: 84px; padding: 0;
  border: 2px solid var(--border-2);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  overflow: hidden; cursor: pointer;
  transition: border-color .14s var(--ease), transform .14s var(--ease);
}
.ref-opt:hover { transform: translateY(-2px); }
.ref-opt img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ref-opt.on { border-color: var(--brand); }

.ref-opt-tag {
  position: absolute; left: 4px; bottom: 4px;
  padding: 2px 6px; border-radius: 999px;
  font-size: 9.5px; font-weight: 700; letter-spacing: .03em;
  background: rgba(8,8,11,.82); color: #f3f3f7;
}
.ref-opt-check {
  position: absolute; top: 4px; right: 4px;
  width: 20px; height: 20px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--brand); color: #fff;
  opacity: 0; transform: scale(.6);
  transition: opacity .14s var(--ease), transform .14s var(--ease);
}
.ref-opt.on .ref-opt-check { opacity: 1; transform: scale(1); }
.ref-opt-check svg, .ref-opt-check .ico { width: 12px; height: 12px; }

.ref-picker-acts { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.ref-picker-acts .btn-go { height: 38px; font-size: 13px; }

.btn-ghost {
  height: 38px; padding: 0 14px;
  border: 1px solid var(--border-2);
  border-radius: 99px;
  background: transparent;
  color: var(--text-dim);
  font-size: 12.5px; font-weight: 600;
  transition: background .14s var(--ease), color .14s var(--ease);
}
.btn-ghost:hover { background: var(--surface-3); color: var(--text); }
.btn.btn-ghost { background: transparent; box-shadow: none; }
.btn.btn-ghost:hover { background: var(--surface-3); }

/* La imagen del hilo sobre la que se aplicara el cambio. */
.shot.is-ref-target {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

/* --- Pantalla de bienvenida --------------------------------------------- */
.welcome {
  max-width: 640px; margin: 0 auto;
  padding: 5vh 0 20px;
  text-align: center;
}
.welcome-mark {
  width: 52px; height: 52px; margin: 0 auto 16px;
  border-radius: 16px;
  background: var(--brand);
  display: grid; place-items: center;
  box-shadow: var(--shadow-brand);
}
.welcome-mark svg, .welcome-mark .ico { width: 26px; height: 26px; color: #fff; }
.welcome h2 { margin: 0 0 6px; font-size: 21px; font-weight: 680; letter-spacing: -.02em; }
.welcome p { margin: 0 0 18px; color: var(--text-dim); font-size: 13px; }

/*
  En telefono las ideas son un carrusel: apiladas ocupaban toda la pantalla de
  inicio y empujaban el compositor fuera de la vista. Los margenes negativos
  cancelan el padding del hilo para que el carrusel llegue a los bordes y se
  vea que hay mas a la derecha.
*/
.suggest {
  display: flex; gap: 8px;
  text-align: left;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  margin: 0 -12px;
  padding: 2px 12px 6px;
}
.suggest::-webkit-scrollbar { display: none; }

.suggest-card {
  flex: 0 0 68%;
  scroll-snap-align: start;
  padding: 10px 12px;
  border-radius: var(--r);
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 11.5px; color: var(--text-dim);
  line-height: 1.45;
  transition: border-color .16s var(--ease), transform .16s var(--ease), color .16s;
}
.suggest-card:hover { border-color: var(--brand-line); color: var(--text); transform: translateY(-2px); }
.suggest-card b { display: block; color: var(--text); font-weight: 600; margin-bottom: 3px; font-size: 12.5px; }

/* ==========================================================================
   COMPOSER
   ========================================================================== */
.composer-wrap {
  flex: none;
  /* El padding de abajo deja sitio a la barra flotante de movil; en escritorio
     --rail-gap vale 0 y vuelve a ser un margen normal. */
  padding: 0 6px calc(10px + var(--rail-gap));
  background: linear-gradient(to top, var(--bg) 70%, transparent);
}
/*
  Fila de fuera del recuadro, pegada a su borde derecho. En telefono lleva los
  controles de creacion y el costo; desde tableta los controles bajan a la
  barra del compositor y aqui solo queda el costo.
*/
.composer-head {
  max-width: 860px; margin: 0 auto 6px;
  display: flex; align-items: center; justify-content: flex-end;
  padding: 0 4px;
}
.composer-head-end {
  display: flex; align-items: center; justify-content: flex-end;
  gap: 6px; flex-wrap: wrap;
  min-width: 0;
}

.composer {
  max-width: 860px; margin: 0 auto;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow);
  transition: border-color .18s var(--ease), box-shadow .18s var(--ease);
}
.composer:focus-within {
  border-color: var(--brand-line);
  box-shadow: var(--shadow), var(--ring);
}

/* Tira de imagenes de referencia */
.refs-strip {
  display: flex; gap: 8px; flex-wrap: wrap;
  padding: 14px 16px 0;
}
.refs-strip:empty { display: none; }

.ref-chip {
  position: relative;
  width: 58px; height: 58px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border-2);
  background: var(--surface-2);
}
.ref-chip img { width: 100%; height: 100%; object-fit: cover; }
.ref-chip.up { display: grid; place-items: center; }

.ref-x {
  position: absolute; top: 3px; right: 3px;
  width: 19px; height: 19px;
  border-radius: 50%;
  background: rgba(10,10,14,.82);
  color: #fff;
  display: grid; place-items: center;
}
.ref-x svg, .ref-x .ico { width: 11px; height: 11px; }

.ref-add {
  width: 58px; height: 58px;
  border-radius: 12px;
  border: 1.5px dashed var(--border-2);
  color: var(--text-mute);
  display: grid; place-items: center;
  transition: border-color .16s var(--ease), color .16s var(--ease);
}
.ref-add:hover { border-color: var(--brand-line); color: var(--brand); }
.ref-add:disabled { opacity: .4; cursor: not-allowed; }

.prompt {
  width: 100%;
  border: 0; background: none; resize: none;
  padding: 12px 14px 6px;
  font-size: 14.5px; line-height: 1.5;
  min-height: 46px; max-height: 200px;
  display: block;
}
.prompt:focus { outline: none; }
.prompt::placeholder { color: var(--text-mute); }

.composer-bar {
  display: flex; align-items: center; gap: 6px;
  padding: 0 8px 8px;
  flex-wrap: wrap;
}

/* En movil los controles de creacion se quedan en icono: no hay ancho para
   la etiqueta y el estado se lee igual por el resalte de .set. */
.opt .opt-val, .opt .chev { display: none; }

.opt {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 7px 9px;
  border-radius: 99px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 12.5px; font-weight: 500;
  transition: border-color .14s var(--ease), color .14s var(--ease), background .14s;
  max-width: 170px;
}

/* La referencia es el mismo control que los demas para que case de tamano; el
   trazo discontinuo es lo que dice "aqui se anade algo". */
.opt-ref { border-style: dashed; }
.opt-ref:hover { border-color: var(--brand-line); color: var(--brand); }
.opt-ref.set { border-style: solid; }
.opt-n { font-size: 11px; font-weight: 650; }
.opt:hover { border-color: var(--border-2); color: var(--text); }
.opt.set { color: var(--text); border-color: var(--brand-line); background: var(--brand-soft); }
.opt span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.opt svg, .opt .ico { width: 16px; height: 16px; }
.opt .chev { width: 13px; height: 13px; opacity: .55; }
.opt:disabled { opacity: .45; cursor: not-allowed; }

.composer-spacer { flex: 1; min-width: 8px; }

.cost {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12.5px; font-weight: 650; color: var(--gem);
  flex: none;
}
.cost svg, .cost .ico { width: 15px; height: 15px; }

.btn-go {
  height: 36px; padding: 0 14px;
  border-radius: 99px;
  background: var(--brand);
  color: #fff; font-weight: 650; font-size: 13.5px;
  display: inline-flex; align-items: center; gap: 8px;
  box-shadow: var(--shadow-brand);
  transition: transform .14s var(--ease), box-shadow .14s var(--ease), filter .14s;
}
.btn-go:hover:not(:disabled) { background: var(--brand-hover); transform: translateY(-1px); }
.btn-go:active:not(:disabled) { transform: translateY(0); }
.btn-go:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
.btn-go svg, .btn-go .ico { width: 17px; height: 17px; }
.btn-go .btn-go-txt { white-space: nowrap; }

.composer-hint { display: none; }
.composer-hint {
  max-width: 860px; margin: 8px auto 0;
  font-size: 11.5px; color: var(--text-mute); text-align: center;
}

/* ==========================================================================
   POPOVERS DE OPCIONES
   ========================================================================== */
.pop-veil {
  position: fixed; inset: 0;
  background: rgba(4,4,8,.5);
  backdrop-filter: blur(3px);
  z-index: 60;
  animation: fade .16s var(--ease);
}
@keyframes fade { from { opacity: 0; } }

/*
  En telefono el popover es una hoja que sube desde abajo a todo el ancho: es
  lo que se espera de una app y evita tener que calcular posiciones contra un
  ancla que casi siempre queda pegada al borde. Desde tableta vuelve a ser un
  flotante anclado al boton (ahi si hay sitio) y JS le pone left/top.
*/
.pop {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 61;
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-bottom: 0;
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  box-shadow: var(--shadow-lg);
  padding: 16px 14px calc(18px + env(safe-area-inset-bottom, 0px));
  max-height: 80dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  animation: rise .24s var(--ease);
}
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.98); } }

.pop-title {
  font-size: 11px; font-weight: 650; letter-spacing: .08em; text-transform: uppercase;
  color: var(--text-mute);
  margin: 0 0 11px;
}

/* Estilos: rejilla de tarjetas */
.style-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }

.style-card {
  border-radius: var(--r);
  border: 1.5px solid var(--border);
  background: var(--surface-2);
  padding: 0 0 8px;
  overflow: hidden;
  transition: border-color .16s var(--ease), transform .16s var(--ease);
  text-align: center;
}
.style-card:hover { transform: translateY(-2px); border-color: var(--border-2); }
.style-card.on { border-color: var(--brand); background: var(--brand-soft); }

.style-swatch {
  height: 54px;
  display: grid; place-items: center;
  background: var(--sw, var(--surface-3));
  position: relative;
}
.style-swatch::after {
  content: ""; position: absolute; inset: 0;
  background: rgba(255,255,255,.14);
}
.style-swatch svg, .style-swatch .ico { width: 20px; height: 20px; color: #fff; opacity: .9; position: relative; }
.style-card b { display: block; font-size: 11.5px; font-weight: 600; margin-top: 7px; }
.style-card i { display: block; font-size: 10px; font-style: normal; color: var(--text-mute); padding: 0 6px; line-height: 1.35; margin-top: 2px; }

/* Aspect ratios */
.ar-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.ar-card {
  padding: 14px 8px 10px;
  border-radius: var(--r);
  border: 1.5px solid var(--border);
  background: var(--surface-2);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  transition: border-color .16s var(--ease);
}
.ar-card:hover { border-color: var(--border-2); }
.ar-card.on { border-color: var(--brand); background: var(--brand-soft); }
.ar-box {
  border: 1.7px solid var(--text-mute);
  border-radius: 4px;
  width: var(--w); height: var(--h);
}
.ar-card.on .ar-box { border-color: var(--brand); }
.ar-card b { font-size: 11.5px; font-weight: 600; }
.ar-card i { font-size: 10px; font-style: normal; color: var(--text-mute); }

/* Calidad y cantidad: filas */
.row-opt {
  display: flex; align-items: center; gap: 12px;
  width: 100%;
  padding: 12px 13px;
  border-radius: var(--r);
  border: 1.5px solid var(--border);
  background: var(--surface-2);
  margin-bottom: 7px;
  text-align: left;
  transition: border-color .16s var(--ease);
}
.row-opt:hover:not(:disabled) { border-color: var(--border-2); }
.row-opt.on { border-color: var(--brand); background: var(--brand-soft); }
.row-opt:disabled { opacity: .55; cursor: not-allowed; }
.row-opt-body { flex: 1; min-width: 0; }
.row-opt b { display: block; font-size: 13px; font-weight: 600; }
.row-opt i { display: block; font-size: 11.5px; font-style: normal; color: var(--text-mute); margin-top: 1px; line-height: 1.4; }
.row-opt .price {
  font-size: 12px; font-weight: 650; color: var(--gem);
  display: inline-flex; align-items: center; gap: 4px; flex: none;
}
.row-opt .price svg, .row-opt .price .ico { width: 13px; height: 13px; }

.lock {
  font-size: 10px; font-weight: 650; text-transform: uppercase; letter-spacing: .05em;
  color: var(--brand);
  background: var(--brand-soft);
  padding: 3px 7px; border-radius: 6px;
  flex: none;
}

/* ==========================================================================
   VISTAS: GALERIA / GEMAS
   ========================================================================== */
.view { flex: 1; overflow-y: auto; padding: 20px 14px calc(30px + var(--rail-gap)); }
.view-inner { max-width: 1000px; margin: 0 auto; }

.view h2 { margin: 0 0 20px; font-size: 22px; font-weight: 680; letter-spacing: -.02em; }
/* Cuando hay subtitulo, el aire lo pone el subtitulo y no el titulo. */
.view h2:has(+ .sub) { margin-bottom: 4px; }
.view .sub { margin: 0 0 26px; color: var(--text-dim); font-size: 13.5px; }

.masonry {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
}
.masonry .shot { aspect-ratio: 1; }

.empty {
  text-align: center; padding: 64px 20px;
  color: var(--text-mute);
}
.empty svg, .empty .ico { width: 40px; height: 40px; margin-bottom: 14px; opacity: .5; }
.empty p { margin: 0; font-size: 13.5px; }

/* --- Gemas ---------------------------------------------------------------- */
.balance {
  border-radius: var(--r-xl);
  background: var(--brand-soft);
  border: 1px solid var(--brand-line);
  padding: 26px 28px;
  display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
  margin-bottom: 32px;
}
.balance-num { display: flex; align-items: center; gap: 12px; }
.balance-num svg, .balance-num .ico { width: 38px; height: 38px; color: var(--gem); }
.balance-num b { font-size: 38px; font-weight: 700; letter-spacing: -.03em; line-height: 1; }
.balance-num span { display: block; font-size: 12px; color: var(--text-dim); margin-top: 3px; }
.balance-spacer { flex: 1; min-width: 20px; }
.balance-stat { text-align: right; }
.balance-stat b { display: block; font-size: 18px; font-weight: 650; }
.balance-stat span { font-size: 11.5px; color: var(--text-dim); }

.section-h {
  font-size: 12px; font-weight: 650; letter-spacing: .07em; text-transform: uppercase;
  color: var(--text-mute);
  margin: 0 0 14px;
}

.pkg-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px; margin-bottom: 38px;
}
.pkg {
  position: relative;
  border-radius: var(--r-lg);
  border: 1.5px solid var(--border);
  background: var(--surface);
  padding: 22px 18px 18px;
  text-align: center;
  transition: border-color .16s var(--ease), transform .16s var(--ease);
}
.pkg:hover { border-color: var(--gem); transform: translateY(-3px); }
.pkg-badge {
  position: absolute; top: -9px; left: 50%; transform: translateX(-50%);
  background: var(--brand);
  color: #fff; font-size: 10px; font-weight: 700;
  padding: 4px 11px; border-radius: 99px;
  text-transform: uppercase; letter-spacing: .05em;
  white-space: nowrap;
}
.pkg-gems { display: flex; align-items: center; justify-content: center; gap: 8px; margin-bottom: 4px; }
.pkg-gems svg, .pkg-gems .ico { width: 24px; height: 24px; color: var(--gem); }
.pkg-gems b { font-size: 27px; font-weight: 700; letter-spacing: -.02em; }
.pkg-bonus { font-size: 11.5px; color: var(--ok); font-weight: 600; margin-bottom: 12px; min-height: 17px; }
.pkg-name { font-size: 12.5px; color: var(--text-dim); margin-bottom: 14px; }
.pkg-price { font-size: 20px; font-weight: 680; margin-bottom: 14px; letter-spacing: -.02em; }
.pkg-rate { font-size: 11px; color: var(--text-mute); margin-top: -10px; margin-bottom: 14px; }

/* --- Botones -------------------------------------------------------------
   Un solo sistema con altura fija. Antes `.btn` no la traia y cada sitio se
   inventaba la suya con padding, asi que en un mismo dialogo convivian botones
   de tres alturas distintas.

   Tamano:   .btn (40px) · .btn-sm (34px) · .btn-lg (46px)
   Intencion: .btn-primary · .btn-danger · .btn-ghost (sin fondo)
   Ancho:    por defecto se ajusta al contenido; .btn-block ocupa la linea.
   -------------------------------------------------------------------------- */
.btn {
  --btn-h: 40px;
  height: var(--btn-h);
  padding: 0 18px;
  border-radius: var(--r-sm);
  background: var(--surface-3);
  color: var(--text);
  font-size: 13px; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  white-space: nowrap;
  transition: background .14s var(--ease), transform .14s var(--ease);
}
.btn:hover { background: var(--surface-4); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn svg, .btn .ico { flex: none; }

.btn-sm { --btn-h: 34px; padding: 0 13px; font-size: 12.5px; }
.btn-lg { --btn-h: 46px; padding: 0 22px; font-size: 14px; }
.btn-block { width: 100%; }

/* Contenedores donde el boton ocupa la linea por diseno de la tarjeta. */
.plan .btn,
.pkg .btn,
.login .btn,
.btn-google { width: 100%; }

.btn-primary { background: var(--brand); color: var(--brand-ink); box-shadow: var(--shadow-brand); }
.btn-primary:hover { background: var(--brand-hover); transform: translateY(-1px); }
.btn-primary:active { background: var(--brand-press); transform: none; }

.plan-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(215px, 1fr));
  gap: 12px; margin-bottom: 38px;
}
.plan {
  border-radius: var(--r-lg);
  border: 1.5px solid var(--border);
  background: var(--surface);
  padding: 22px 20px;
  display: flex; flex-direction: column;
  transition: border-color .16s var(--ease);
}
.plan:hover { border-color: var(--border-2); }
.plan.current { border-color: var(--brand); background: var(--brand-soft); }
.plan h3 { margin: 0 0 3px; font-size: 16px; font-weight: 650; }
.plan .tagline { font-size: 11.5px; color: var(--text-mute); margin-bottom: 14px; min-height: 16px; }
.plan .price { font-size: 25px; font-weight: 700; letter-spacing: -.02em; }
.plan .price small { font-size: 12px; font-weight: 500; color: var(--text-mute); }
.plan .gems-mo {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12.5px; color: var(--gem); font-weight: 600;
  margin: 10px 0 14px;
}
.plan .gems-mo svg, .plan .gems-mo .ico { width: 15px; height: 15px; }
.plan ul { list-style: none; margin: 0 0 18px; padding: 0; flex: 1; }
.plan li {
  display: flex; align-items: flex-start; gap: 8px;
  font-size: 12.5px; color: var(--text-dim);
  padding: 4px 0;
}
.plan li svg, .plan li .ico { width: 14px; height: 14px; color: var(--ok); flex: none; margin-top: 2px; }
.plan li.off { color: var(--text-mute); }
.plan li.off svg, .plan li.off .ico { color: var(--text-mute); opacity: .5; }

.ledger { border-radius: var(--r-lg); border: 1px solid var(--border); background: var(--surface); overflow: hidden; }
.ledger-row {
  display: flex; align-items: center; gap: 14px;
  padding: 13px 18px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.ledger-row:last-child { border-bottom: 0; }
.ledger-row .desc { flex: 1; min-width: 0; }
.ledger-row .desc b { display: block; font-weight: 550; }
.ledger-row .desc span { font-size: 11.5px; color: var(--text-mute); }
.ledger-row .delta { font-weight: 680; font-size: 13.5px; flex: none; }
.delta.plus { color: var(--ok); }
.delta.minus { color: var(--text-dim); }

/* ==========================================================================
   LOGIN
   ========================================================================== */
.login {
  position: fixed; inset: 0;
  display: grid; place-items: center;
  background: var(--bg);
  padding: 24px;
  z-index: 90;
}
.login::before {
  content: ""; position: absolute; inset: 0;
  background:
    radial-gradient(72% 58% at 18% 8%, rgba(86,28,203,.26), transparent 64%),
    radial-gradient(46% 38% at 88% 92%, rgba(86,28,203,.14), transparent 66%);
  pointer-events: none;
}
.login-card {
  position: relative;
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 42px 34px 32px;
  text-align: center;
  box-shadow: var(--shadow-lg);
}
/* El logotipo oficial: la palabra hereda el color (blanca en oscuro, morada de
   marca en claro) y la chispa conserva su coral. */
.login-logo {
  margin: 0 auto 26px;
  color: var(--text);
}
[data-theme="light"] .login-logo { color: #561ccb; }
.login-logo svg, .login-logo .ico { width: 132px; height: auto; display: block; margin: 0 auto; }

.login-card h1 { margin: 0 0 6px; font-size: 21px; font-weight: 650; letter-spacing: -.02em; }
.login-card p { margin: 0 0 26px; color: var(--text-dim); font-size: 13.5px; line-height: 1.55; }

.btn-google {
  width: 100%;
  display: flex; align-items: center; justify-content: center; gap: 11px;
  padding: 13px 18px;
  border-radius: var(--r);
  background: var(--text);
  color: var(--bg);
  font-weight: 620; font-size: 14px;
  transition: transform .14s var(--ease), opacity .14s;
}
.btn-google:hover { transform: translateY(-1px); opacity: .92; }
.btn-google svg, .btn-google .ico { width: 19px; height: 19px; }
.btn-google.disabled {
  opacity: .38;
  cursor: not-allowed;
  pointer-events: none;
  transform: none;
}

.login-consent {
  display: flex; align-items: flex-start; gap: 9px;
  margin: 0 0 15px;
  text-align: left;
  font-size: 12.5px; line-height: 1.45; color: var(--text-dim);
  cursor: pointer;
}
.login-consent input { width: 16px; height: 16px; margin: 1px 0 0; accent-color: var(--brand); flex: none; }
.login-consent a { color: var(--brand); text-decoration: underline; text-underline-offset: 2px; }
.login-card .login-account-note { margin: 13px 4px 0; font-size: 11.5px; color: var(--text-mute); }
.login-copy {
  position: absolute; left: 20px; right: 20px; bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 1; text-align: center; font-size: 11px; color: var(--text-mute);
}

.public-legal-page {
  height: 100%; overflow-y: auto;
  background: var(--bg); color: var(--text);
  padding: 24px clamp(16px, 4vw, 48px) 30px;
}
.public-legal-head {
  width: min(920px, 100%); margin: 0 auto 22px;
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
}
.public-legal-head .login-logo { margin: 0; }
.public-legal-head .login-logo svg, .public-legal-head .login-logo .ico { width: 112px; }
.public-legal-login { width: auto; padding: 9px 16px; }
.public-legal-card {
  width: min(920px, 100%); margin: 0 auto;
  padding: clamp(24px, 5vw, 52px);
  border: 1px solid var(--border); border-radius: var(--r-xl);
  background: var(--surface); box-shadow: var(--shadow-lg);
}
.public-legal-card h1 { margin: 0 0 6px; font-size: clamp(24px, 4vw, 34px); }
.public-legal-card .legal { max-width: none; }
.public-legal-copy {
  margin: 24px auto 0;
  text-align: center;
  font-size: 11px;
  color: var(--text-mute);
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
/* Enlaces cruzados entre terminos y aviso: quien llega a uno desde el login
   tiene que poder ver el otro sin volver atras. */
.public-legal-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 18px; }
.public-legal-links a { color: var(--text-dim); }
.public-legal-links a:hover { color: var(--text); text-decoration: underline; }


/* ==========================================================================
   TOASTS Y MODALES
   ========================================================================== */
.toasts {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  z-index: 200;
  display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none;
  width: min(420px, calc(100vw - 32px));
}
.toast {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 16px;
  border-radius: var(--r);
  background: var(--surface-3);
  border: 1px solid var(--border-2);
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  animation: rise .22s var(--ease);
  pointer-events: auto;
  max-width: 100%;
}
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }
.toast svg, .toast .ico { flex: none; margin-top: 1px; }
.toast.err { border-color: rgba(244,100,90,.4); }
.toast.err svg, .toast.err .ico { color: var(--danger); }
.toast.ok svg, .toast.ok .ico { color: var(--ok); }

.lightbox {
  position: fixed; inset: 0; z-index: 150;
  background: rgba(4,4,8,.9);
  display: grid; place-items: center;
  padding: 40px;
  animation: fade .18s var(--ease);
}
.lightbox img {
  max-width: 100%; max-height: 100%;
  border-radius: var(--r);
  box-shadow: var(--shadow-lg);
}
.lightbox-close {
  position: absolute; top: 20px; right: 20px;
  width: 40px; height: 40px; border-radius: 50%;
  background: rgba(255,255,255,.1);
  color: #fff;
  display: grid; place-items: center;
}
.lightbox-close:hover { background: rgba(255,255,255,.2); }

/* ==========================================================================
   PANEL DE ADMINISTRACION

   Reusa los tokens de siempre, asi que el tema claro sale solo. Lo unico
   propio es la densidad: aqui se leen tablas, no se contempla una imagen.
   ========================================================================== */

/* Las tablas del panel necesitan mas aire que las 1000px del resto. */
.view-inner.wide { max-width: 1320px; }

.mono { font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace; font-size: .92em; }

/* --- Pestanas ------------------------------------------------------------ */
.adm-tabs {
  display: flex; gap: 4px;
  margin: 0 0 24px;
  padding: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  width: fit-content;
  max-width: 100%;
}
.adm-tab {
  flex: 1; justify-content: center;
  display: flex; align-items: center; gap: 7px;
  padding: 8px 6px;
  border-radius: var(--r-sm);
  font-size: 13px; font-weight: 550;
  color: var(--text-dim);
  transition: background .14s var(--ease), color .14s var(--ease);
}
.adm-tab:hover { color: var(--text); }
.adm-tab.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
/* A partir de 600px vuelve la etiqueta; en movil solo el icono. */
.adm-tab span { display: none; }
.adm-tabs { width: 100%; }
.adm-tab.on svg, .adm-tab.on .ico { color: var(--brand); }

.adm-loading {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  padding: 60px 20px;
  color: var(--text-dim); font-size: 13.5px;
}

.adm-empty {
  padding: 32px 20px;
  text-align: center;
  color: var(--text-mute); font-size: 13px;
  background: var(--surface);
  border: 1px dashed var(--border-2);
  border-radius: var(--r-lg);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.adm-empty svg, .adm-empty .ico { width: 30px; height: 30px; opacity: .55; margin-bottom: 2px; }
.adm-empty b { font-size: 13.5px; font-weight: 600; color: var(--text-dim); }

.adm-count { font-size: 12px; color: var(--text-mute); margin-bottom: 10px; }
.adm-stamp { font-size: 11.5px; color: var(--text-mute); margin: 32px 0 0; text-align: right; }

/* --- Avisos y estado ----------------------------------------------------- */
.adm-alerts { display: grid; gap: 8px; margin-bottom: 16px; }
.adm-alert {
  display: flex; gap: 11px; align-items: flex-start;
  padding: 13px 16px;
  border-radius: var(--r);
  border: 1px solid var(--border-2);
  background: var(--surface);
  font-size: 12.5px; color: var(--text-dim); line-height: 1.5;
}
.adm-alert b { display: block; color: var(--text); font-weight: 620; margin-bottom: 2px; font-size: 13px; }
.adm-alert svg, .adm-alert .ico { flex: none; margin-top: 1px; }
.adm-alert.err { border-color: rgba(244,100,90,.42); background: var(--danger-soft); }
.adm-alert.err svg, .adm-alert.err .ico { color: var(--danger); }
.adm-alert.warn { border-color: rgba(232,177,60,.42); }
.adm-alert.warn svg, .adm-alert.warn .ico { color: var(--warn); }

.adm-chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 26px; }
.adm-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 11px;
  border-radius: 99px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 11.5px; color: var(--text-dim);
}
.adm-chip b { color: var(--text); font-weight: 600; }
.adm-chip i { font-style: normal; color: var(--text-mute); }
.adm-chip svg, .adm-chip .ico { width: 13px; height: 13px; color: var(--text-mute); }

.adm-note {
  display: flex; gap: 11px; align-items: flex-start;
  padding: 13px 16px;
  margin-bottom: 18px;
  border-radius: var(--r);
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 12.5px; color: var(--text-dim); line-height: 1.5;
}
.adm-note svg, .adm-note .ico { flex: none; margin-top: 1px; color: var(--brand); }
.adm-note code {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  background: var(--surface-3); padding: 1px 5px; border-radius: 5px; font-size: .92em;
}

/* --- Tarjetas de metrica -------------------------------------------------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 32px;
}
.kpi {
  position: relative;
  padding: 18px 18px 16px;
  border-radius: var(--r-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  transition: border-color .16s var(--ease);
}
.kpi:hover { border-color: var(--border-2); }
.kpi-ico {
  position: absolute; top: 15px; right: 15px;
  color: var(--text-mute); opacity: .55;
}
.kpi-label { display: block; font-size: 11.5px; color: var(--text-dim); padding-right: 24px; }
.kpi-value {
  display: block; margin: 9px 0 3px;
  font-size: 27px; font-weight: 700; letter-spacing: -.025em; line-height: 1.05;
}
.kpi-foot { display: block; font-size: 11px; color: var(--text-mute); }
.kpi-gem .kpi-value { color: var(--gem); }
.kpi-gem .kpi-ico { color: var(--gem); opacity: .8; }

/* --- Grafica de barras ---------------------------------------------------- */
.adm-chart {
  padding: 20px 20px 14px;
  border-radius: var(--r-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  margin-bottom: 32px;
}
.adm-chart-head {
  display: flex; gap: 20px; flex-wrap: wrap; align-items: baseline;
  font-size: 11.5px; color: var(--text-dim);
  margin-bottom: 20px;
}
.adm-chart-head b { color: var(--text); font-size: 15px; font-weight: 650; margin-right: 3px; }
.adm-chart-key { margin-left: auto; display: none; align-items: center; gap: 6px; color: var(--text-mute); }
.adm-chart-key i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }
.adm-chart-key i.k-ok { background: var(--brand); }
.adm-chart-key i.k-err { background: var(--danger); margin-left: 8px; }

.adm-bars { display: flex; align-items: flex-end; gap: 4px; height: 104px; }
.adm-bar { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; min-width: 0; }
.adm-bar-stack {
  width: 100%;
  /* Una barra de cero seria invisible y parecería un hueco en la serie: se le
     deja 3px para que se lea "ese dia hubo cero", no "ese dia falta". */
  height: max(3px, var(--h));
  margin-top: auto;
  display: flex; flex-direction: column;
  border-radius: 5px;
  overflow: hidden;
  background: var(--surface-3);
  transition: opacity .14s;
}
.adm-bar:hover .adm-bar-stack { opacity: .78; }
.adm-bar-stack span { display: block; width: 100%; height: var(--p); }
.adm-bar-stack .b-err { background: var(--danger); }
.adm-bar-stack .b-ok { background: var(--brand); }
.adm-bar-label { font-size: 9.5px; color: var(--text-mute); margin-top: 7px; }

.adm-cols { display: grid; grid-template-columns: 1fr; gap: 22px; margin-bottom: 8px; }
.adm-cols .section-h { margin-top: 0; }

.adm-clickable { cursor: pointer; transition: background .12s; }
.adm-clickable:hover { background: var(--surface-2); }

/* --- Barra de filtros ------------------------------------------------------ */
.adm-toolbar { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
/* Los hijos DIRECTOS ocupan el ancho (cabecera, rejilla, acciones). No se usa
   `> *` a secas porque eso alcanzaba tambien a los controles de dentro de la
   rejilla y los apilaba en una columna aunque hubiera sitio de sobra. */
.adm-toolbar > .adm-filter-head,
.adm-toolbar > .adm-search-row,
.adm-toolbar > .adm-filter-grid { width: 100%; }

.adm-filter-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; margin-bottom: 6px;
}
.adm-filter-head h3 { margin: 0; font-size: 14px; }
.adm-filter-head p { margin: 3px 0 0; color: var(--text-mute); font-size: 11.5px; }
.adm-view-toggle {
  display: inline-flex; width: auto !important; flex: none;
  padding: 3px; border: 1px solid var(--border); border-radius: var(--r-sm);
  background: var(--surface-2);
}
.adm-view-toggle button {
  height: 31px; padding: 0 11px; border-radius: 7px;
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--text-mute); font-size: 11.5px; font-weight: 600;
}
.adm-view-toggle button.on { background: var(--surface); color: var(--brand); box-shadow: var(--shadow-sm); }
/* Fila de busqueda: el campo y sus acciones juntos.
   Estaban separados, con los botones sueltos al final del formulario y lejos
   de aquello sobre lo que actuan. */
.adm-search-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: stretch; }
.adm-search-row .adm-search { flex: 1 1 260px; }
.adm-search-row .btn { flex: none; }

/* Cada filtro con su rotulo encima.
   Antes el unico campo de texto entre desplegables no se entendia: su
   marcador de posicion desaparecia al escribir y no quedaba nada que dijera
   que era. Los desplegables se explicaban solos por su primera opcion, pero
   eso obligaba a redactarlos como frases ("Cualquier estado") en vez de como
   valores. */
.adm-field-sm { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.adm-field-sm > span {
  font-size: 11px; font-weight: 600;
  color: var(--text-mute);
  letter-spacing: .02em;
}
.adm-field-sm .adm-select,
.adm-field-sm .adm-input { width: 100%; }

.adm-filter-grid { display: grid; grid-template-columns: 1fr; gap: 12px 8px; }

.adm-search {
  display: flex; align-items: center; gap: 8px;
  flex: none; min-width: 0;
  padding: 0 13px;
  height: 38px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text-mute);
}
.adm-search:focus-within { border-color: var(--brand-line); box-shadow: var(--ring); }
.adm-search input {
  flex: 1; min-width: 0;
  background: none; border: 0; outline: none;
  font-size: 13px; color: var(--text);
}
.adm-search input::-webkit-search-cancel-button { filter: grayscale(1) opacity(.5); }

.adm-select, .adm-input {
  height: 40px;
  padding: 0 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-size: 13px; color: var(--text);
  outline: none;
}
.adm-select { cursor: pointer; padding-right: 28px; }
.adm-select:focus, .adm-input:focus { border-color: var(--brand-line); box-shadow: var(--ring); }
.adm-select:disabled, .adm-input:disabled { opacity: .5; cursor: not-allowed; }
.adm-input.grow, .adm-field.grow { flex: 1; min-width: 0; }

/* --- Tabla ------------------------------------------------------------------ */
.adm-table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  overflow-x: auto;
}
.adm-table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 720px; }
.adm-table th {
  text-align: left;
  padding: 11px 16px;
  font-size: 10.5px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase;
  color: var(--text-mute);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.adm-table td { padding: 11px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.adm-table tbody tr:last-child td { border-bottom: 0; }
.adm-table tbody tr { cursor: pointer; transition: background .12s; }
.adm-table tbody tr:hover { background: var(--surface-2); }
.adm-table tbody tr:focus-visible { background: var(--surface-2); outline: 2px solid var(--brand); outline-offset: -2px; }
.adm-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.adm-table .dim { color: var(--text-mute); font-size: 12px; white-space: nowrap; }

/* La fila entera lleva a la ficha: el enlace va dentro de la celda de la
   cuenta y se estira sobre toda la fila con ::after, para que se pueda abrir
   en pestana nueva y el navegador ensene a donde va. */
.adm-row-link { position: relative; }
.adm-row-link:hover { background: var(--surface-2); }
.adm-person::after { content: ""; position: absolute; inset: 0; }

.adm-person { display: flex; align-items: center; gap: 10px; min-width: 0; color: inherit; }
.adm-av { width: 32px; height: 32px; font-size: 12px; flex: none; }
.adm-av.lg { width: 48px; height: 48px; font-size: 18px; }
.adm-person-txt { min-width: 0; }
.adm-person-txt b {
  display: block; font-weight: 600; font-size: 13px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.adm-person-txt span {
  display: block; font-size: 11.5px; color: var(--text-mute);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.adm-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px;
  border-radius: 99px;
  background: var(--surface-3);
  font-size: 11px; font-weight: 550;
  color: var(--text-dim);
  white-space: nowrap;
}
.adm-badge svg, .adm-badge .ico { width: 11px; height: 11px; }
.adm-badge.ok   { background: rgba(55,201,139,.14); color: var(--ok); }
.adm-badge.err  { background: var(--danger-soft);   color: var(--danger); }
.adm-badge.warn { background: rgba(232,177,60,.16); color: var(--warn); }
.adm-badge.dim  { background: var(--surface-2);     color: var(--text-mute); }
.adm-badge.brand{ background: var(--brand-soft);    color: var(--brand); }
.adm-badge.model{ background: rgba(86,28,203,.1);   color: var(--brand); }

.gem-num {
  color: var(--gem); font-weight: 650;
  display: inline-flex; align-items: center; gap: 4px;
}
.gem-num svg, .gem-num .ico { width: 13px; height: 13px; }

.adm-pager {
  display: flex; align-items: center; justify-content: center; gap: 14px;
  margin-top: 18px;
  font-size: 12.5px; color: var(--text-dim);
}
.adm-pager { --btn-h: 34px; }

/* --- Lista de generaciones --------------------------------------------------- */
.gen-list { display: grid; gap: 10px; }
.gen-card {
  padding: 14px 16px;
  border-radius: var(--r);
  background: var(--surface);
  border: 1px solid var(--border);
}
.gen-card-top { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 9px; }
.gen-card-spacer { flex: 1; min-width: 8px; }
.gen-refund { font-style: normal; font-size: 10.5px; color: var(--text-mute); font-weight: 500; }

.gen-card-prompt {
  margin: 0 0 8px;
  font-size: 13px; line-height: 1.5; color: var(--text);
  /* El prompt puede ser larguisimo; tres lineas bastan para reconocerlo. */
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}

.gen-card-err {
  display: flex; gap: 8px; align-items: flex-start;
  margin: 0 0 8px;
  padding: 8px 11px;
  border-radius: var(--r-sm);
  background: var(--danger-soft);
  font-size: 11.5px; color: var(--text-dim); line-height: 1.45;
}
.gen-card-err svg, .gen-card-err .ico { flex: none; color: var(--danger); margin-top: 1px; }
.gen-card-err b { color: var(--danger); font-weight: 600; }

.gen-card-foot {
  display: flex; gap: 14px; flex-wrap: wrap; align-items: center;
  font-size: 11px; color: var(--text-mute);
}
.gen-card-user {
  display: inline-flex; align-items: center; gap: 5px;
  color: var(--text-dim); font-size: 11px;
  padding: 3px 9px; border-radius: 99px;
  background: var(--surface-2);
}
.gen-card-user:hover { background: var(--surface-3); color: var(--text); }
.gen-card-user svg, .gen-card-user .ico { width: 12px; height: 12px; }

.adm-image-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 12px;
}
.adm-image-card {
  min-width: 0; overflow: hidden;
  border: 1px solid var(--border); border-radius: var(--r);
  background: var(--surface);
}
.adm-image-preview {
  position: relative; display: block;
  aspect-ratio: 1; overflow: hidden; background: var(--surface-2);
}
.adm-image-preview img {
  width: 100%; height: 100%; display: block; object-fit: cover;
  transition: transform .25s var(--ease);
}
.adm-image-preview:hover img { transform: scale(1.025); }
.adm-image-hd {
  position: absolute; top: 9px; right: 9px;
  padding: 3px 7px; border-radius: 99px;
  background: var(--gem); color: #fff;
  font-size: 9.5px; font-weight: 750; letter-spacing: .06em;
}
.adm-image-info { padding: 10px 11px 12px; }
.adm-image-info p {
  margin: 0 0 8px; min-height: 36px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; font-size: 12px; line-height: 1.45;
}
.adm-image-info > div { display: flex; align-items: center; gap: 5px; min-width: 0; }
.adm-image-info > div span { color: var(--brand); font-size: 10.5px; font-weight: 650; }
.adm-image-info > div b {
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--text-mute); font-size: 10px; font-weight: 500;
}
.adm-image-info small { display: block; margin: 6px 0; color: var(--text-mute); font-size: 9.5px; }

/* --- Ajustes ------------------------------------------------------------------ */
.set-grid { display: grid; gap: 8px; margin-bottom: 8px; }
.set-row {
  display: flex; flex-direction: column; align-items: stretch; gap: 12px;
  padding: 14px 18px;
  border-radius: var(--r);
  background: var(--surface);
  border: 1px solid var(--border);
  /* Iban pegados uno a otro y las tarjetas se leian como una sola lista
     continua, sin saber donde acaba un ajuste y empieza el siguiente. */
  margin-bottom: 10px;
}
.set-row:last-of-type { margin-bottom: 0; }
.set-row.danger { border-color: rgba(232,177,60,.34); }
.set-txt { flex: 1; min-width: 0; }
.set-txt b { display: block; font-size: 13px; font-weight: 600; }
.set-txt i {
  display: block; font-style: normal; font-size: 11.5px;
  color: var(--text-mute); line-height: 1.45; margin-top: 2px;
}
.set-txt code {
  display: inline-block; margin-top: 5px;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 10.5px; color: var(--text-mute);
  background: var(--surface-2); padding: 2px 7px; border-radius: 5px;
}
.set-txt .set-new { color: var(--warn); }
.set-ctl { flex: none; }
.set-ctl .adm-input, .set-ctl .adm-select { width: 100%; }

.switch {
  width: 44px; height: 25px;
  border-radius: 99px;
  background: var(--surface-4);
  position: relative;
  transition: background .18s var(--ease);
}
.switch.on { background: var(--brand); }
.switch-knob {
  position: absolute; top: 3px; left: 3px;
  width: 19px; height: 19px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.3);
  transition: transform .18s var(--ease);
}
.switch.on .switch-knob { transform: translateX(19px); }

/*
  Version de formulario: el interruptor es una casilla de verdad dentro de una
  etiqueta. Asi se envia con el formulario, se puede marcar con el teclado y no
  hace falta JavaScript para que funcione.
*/
.switch-input { display: inline-flex; cursor: pointer; }
.switch-input input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-input > span {
  width: 44px; height: 25px;
  border-radius: 99px;
  background: var(--surface-4);
  position: relative;
  transition: background .18s var(--ease);
}
.switch-input > span::after {
  content: "";
  position: absolute; top: 3px; left: 3px;
  width: 19px; height: 19px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.3);
  transition: transform .18s var(--ease);
}
.switch-input input:checked + span { background: var(--brand); }
.switch-input input:checked + span::after { transform: translateX(19px); }
.switch-input input:focus-visible + span { box-shadow: var(--ring); }

.set-bar {
  position: sticky; bottom: 16px;
  display: flex; align-items: center; gap: 10px;
  margin-top: 24px;
  padding: 12px 16px;
  border-radius: var(--r);
  background: var(--surface-3);
  border: 1px solid var(--border-2);
  box-shadow: var(--shadow-lg);
  font-size: 12.5px;
}
.set-bar span { flex: 1; color: var(--text-dim); }
.set-bar { --btn-h: 34px; }
/* `display:flex` gana al display:none que el navegador aplica a [hidden], asi
   que sin esta linea la barra de guardado nunca se esconderia. */
.set-bar[hidden] { display: none; }

/* --- Cajon lateral (ficha de usuario) ------------------------------------------ */
.drawer-veil {
  position: fixed; inset: 0; z-index: 120;
  background: rgba(4,4,8,.55);
  backdrop-filter: blur(2px);
  animation: fade .16s var(--ease);
}
@keyframes slide-in { from { transform: translateX(30px); opacity: 0; } }

.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 130;
  width: 100vw;
  display: flex; flex-direction: column;
  background: var(--bg);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  animation: slide-in .22s var(--ease);
}

.drawer-head {
  display: flex; align-items: center; gap: 14px;
  padding: 20px 22px;
  border-bottom: 1px solid var(--border);
  flex: none;
}
.drawer-id { flex: 1; min-width: 0; }
.drawer-id > b {
  display: block; font-size: 16px; font-weight: 650; letter-spacing: -.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.drawer-id > span {
  display: block; font-size: 12px; color: var(--text-mute);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.drawer-badges { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 7px; }

.drawer-body { flex: 1; overflow-y: auto; padding: 20px 22px 40px; }
.drawer-body .section-h { margin-top: 26px; }
.drawer-body .section-h:first-child { margin-top: 0; }

.drawer-stats {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
  margin-bottom: 4px;
}
.drawer-stats > div { background: var(--surface); padding: 13px 14px; }
.drawer-stats b { display: block; font-size: 18px; font-weight: 680; letter-spacing: -.02em; }
.drawer-stats span { font-size: 10.5px; color: var(--text-mute); }

.drawer-actions {
  display: flex; flex-wrap: wrap; gap: 14px;
  padding: 16px 18px;
  border-radius: var(--r);
  background: var(--surface);
  border: 1px solid var(--border);
}
.adm-field { display: flex; flex-direction: column; gap: 6px; }
.adm-field > span { font-size: 11px; color: var(--text-mute); font-weight: 550; }
.adm-inline { display: flex; gap: 8px; flex-wrap: wrap; }
.adm-inline .adm-input { min-width: 120px; }

.pin-form {
  display: grid; grid-template-columns: 1fr; gap: 10px;
  margin: 12px 0 32px; padding: 16px;
  border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface);
}
.pin-form .btn { align-self: end; }

.drawer-danger {
  display: flex; gap: 8px; flex-wrap: wrap;
  width: 100%;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.drawer-danger { --btn-h: 36px; }

.btn-danger { background: var(--danger); color: #fff; box-shadow: 0 4px 14px rgba(214,69,58,.28); }
.btn-danger:hover { background: var(--danger-hover); color: #fff; }
.btn-danger:active { background: var(--danger-hover); transform: none; }

/* Celda de descripcion de una generacion: titulo, autor y motivo del fallo. */
.adm-prompt { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.adm-prompt b { font-weight: 600; font-size: 12.5px; }
.adm-prompt a { font-size: 11.5px; color: var(--text-mute); }
.adm-prompt a:hover { color: var(--brand); }
.adm-prompt .dim { font-size: 11px; color: var(--danger); }

.adm-kv {
  display: grid; grid-template-columns: 1fr; gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
}
.adm-kv > div { background: var(--surface); padding: 11px 14px; min-width: 0; }
.adm-kv span { display: block; font-size: 10.5px; color: var(--text-mute); margin-bottom: 2px; }
.adm-kv b {
  display: block; font-size: 12.5px; font-weight: 550;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ==========================================================================
   PIE DE PAGINA
   ========================================================================== */
.footer {
  margin-top: 44px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px;
  font-size: 11.5px; color: var(--text-mute);
}
.footer-links { display: flex; flex-wrap: wrap; gap: 14px; }
.footer a { color: var(--text-mute); }
.footer a:hover { color: var(--text-dim); text-decoration: underline; }
.footer-copy { margin-left: auto; }

/* ==========================================================================
   MI PERFIL
   ========================================================================== */
.profile-head {
  display: flex; align-items: center; gap: 16px;
  padding: 20px;
  border-radius: var(--r-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  margin-bottom: 26px;
}
.profile-head .avatar { width: 60px; height: 60px; font-size: 22px; }
.profile-head-txt { min-width: 0; }
.profile-head-txt b {
  display: block; font-size: 17px; font-weight: 650; letter-spacing: -.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.profile-head-txt span {
  display: block; font-size: 12.5px; color: var(--text-mute);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.profile-grid { display: grid; grid-template-columns: 1fr; gap: 14px; }

.profile-progress {
  position: relative; overflow: hidden;
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px 16px;
  margin-bottom: 16px; padding: 14px 16px 18px;
  border: 1px solid var(--brand-line); border-radius: var(--r);
  background: var(--brand-soft);
}
.profile-progress div b, .profile-progress div span { display: block; }
.profile-progress div b { font-size: 13px; }
.profile-progress div span { font-size: 11.5px; color: var(--text-dim); }
.profile-progress strong { color: var(--brand); font-size: 14px; }
.profile-progress > i {
  position: absolute; left: 0; bottom: 0; height: 4px; width: var(--profile-progress);
  background: var(--brand); border-radius: 0 99px 99px 0;
}
.profile-progress.complete { display: flex; padding: 13px 16px; color: var(--ok); border-color: rgba(55,201,139,.3); background: rgba(55,201,139,.08); }
.profile-progress.complete b { color: var(--text); }
.field-missing > label::after { content: " · pendiente"; color: var(--accent); font-weight: 650; }
.field-missing input,
.field-missing select {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.field-missing input:focus,
.field-missing select:focus { border-color: var(--brand-line); }

/* --- Opciones de refinamiento del prompt ---------------------------------- */
.refine-opts { display: grid; gap: 8px; margin-bottom: 14px; }
.refine-opt {
  text-align: left;
  padding: 12px 14px;
  border-radius: var(--r);
  background: var(--surface-2);
  border: 1px solid var(--border);
  transition: border-color .14s var(--ease), background .14s var(--ease);
}
.refine-opt:hover { border-color: var(--brand-line); background: var(--brand-soft); }
.refine-opt b { display: block; font-size: 13px; font-weight: 600; color: var(--text); }
.refine-opt i {
  display: block; font-style: normal; font-size: 11.5px;
  color: var(--text-mute); margin-top: 2px;
}

/* --- Tarjeta de sin gemas -------------------------------------------------- */
.nogems {
  padding: 16px 18px;
  border-radius: var(--r-lg);
  background: var(--surface);
  border: 1px solid var(--accent);
}
.nogems-head { display: flex; gap: 13px; align-items: center; margin-bottom: 10px; }
.nogems-head svg, .nogems-head .ico { color: var(--accent); flex: none; }
.nogems-head b { display: block; font-size: 14.5px; font-weight: 650; }
.nogems-head span { font-size: 12.5px; color: var(--text-dim); }
.nogems p { margin: 0 0 14px; font-size: 12.5px; color: var(--text-dim); line-height: 1.55; }

.field-opt { color: var(--text-mute); font-weight: 400; }

/* --- Tarjeta de seguridad (contrasena de confirmacion) -------------------- */
.security-card {
  display: flex; align-items: flex-start; gap: 14px;
  padding: 16px 18px;
  margin-bottom: 22px;
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  background: var(--surface);
}
.security-card > svg, .security-card > .ico { flex: none; margin-top: 2px; }
.security-txt { flex: 1; min-width: 0; }
.security-txt b { display: block; font-size: 14px; font-weight: 650; margin-bottom: 3px; }
.security-txt span { font-size: 12.5px; color: var(--text-dim); line-height: 1.5; }
.security-card .btn { flex: none; }

/* Sin contrasena hay acciones bloqueadas, asi que se avisa en tono de pendiente. */
.security-card.todo { border-color: var(--accent); background: var(--accent-soft); }
.security-card.todo > svg, .security-card.todo > .ico { color: var(--accent); }
.security-card.done > svg, .security-card.done > .ico { color: var(--ok); }

/* En movil el boton baja a su propia linea en vez de estrujar el texto. */
.security-card { flex-wrap: wrap; }
.security-card .btn { width: 100%; }

/* --- Dialogo de baja de cuenta ------------------------------------------- */
.del-steps { margin: 0 0 18px; padding-left: 20px; }
.del-steps li { font-size: 13px; line-height: 1.6; color: var(--text-dim); margin-bottom: 9px; }
.del-steps b { color: var(--text); font-weight: 620; }

.check-row {
  display: flex; align-items: flex-start; gap: 10px;
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: var(--r);
  background: var(--surface-2);
  border: 1px solid var(--border);
  cursor: pointer;
}
.check-row input { margin-top: 2px; flex: none; width: 17px; height: 17px; accent-color: var(--danger); }
.check-row span { font-size: 12.5px; line-height: 1.5; color: var(--text-dim); }
.check-row:has(input:checked) { border-color: var(--danger); background: var(--danger-soft); }

/* ==========================================================================
   NOTIFICACIONES
   ========================================================================== */
.notification-btn { position: relative; }
.notification-btn > span {
  position: absolute; top: -5px; right: -5px; min-width: 17px; height: 17px; padding: 0 4px;
  display: grid; place-items: center; border-radius: 99px;
  background: var(--gem); color: #fff; border: 2px solid var(--surface);
  font-size: 9px; font-weight: 750;
}
.notifications-head {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  margin-bottom: 20px;
  --btn-h: 34px;
}
.notifications-head h2 { margin: 0; }
.notification-list { display: grid; gap: 9px; }
.notification-item {
  width: 100%; display: grid; grid-template-columns: 40px 1fr auto; align-items: center; gap: 12px;
  padding: 15px; text-align: left;
  border: 1px solid var(--border); border-radius: var(--r); background: var(--surface);
  transition: border-color .15s var(--ease), background .15s var(--ease), transform .15s var(--ease);
}
.notification-item:hover { border-color: var(--brand-line); transform: translateY(-1px); }
.notification-item.unread { background: var(--brand-soft); border-color: var(--brand-line); }
.notification-icon { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px; background: var(--surface-3); color: var(--brand); }
.notification-icon.success { color: var(--ok); background: rgba(55,201,139,.12); }
.notification-icon.warning { color: var(--warn); background: rgba(232,177,60,.12); }
.notification-icon.billing { color: var(--gem); background: var(--gem-soft); }
.notification-content { min-width: 0; }
.notification-content b, .notification-content span, .notification-content time { display: block; }
.notification-content b { font-size: 13.5px; margin-bottom: 2px; }
.notification-content span { font-size: 12.5px; color: var(--text-dim); line-height: 1.5; }
.notification-content time { margin-top: 5px; font-size: 10.5px; color: var(--text-mute); }
.notification-item > i { width: 8px; height: 8px; border-radius: 50%; background: var(--gem); }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-size: 12px; font-weight: 550; color: var(--text-dim); }
.field > i {
  font-style: normal; font-size: 11px; color: var(--text-mute); line-height: 1.45;
}
.field input,
.field select {
  height: 42px;
  padding: 0 13px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-size: 13.5px; color: var(--text);
  outline: none;
  width: 100%;
}
.field select { cursor: pointer; }
.field input:focus,
.field select:focus { border-color: var(--brand-line); box-shadow: var(--ring); }
.field input:disabled {
  background: var(--surface-2);
  color: var(--text-mute);
  cursor: not-allowed;
}
/* El icono del calendario lo pinta el navegador; sin color-scheme se queda
   negro sobre el fondo oscuro. */
.field input[type="date"] { color-scheme: dark; }
[data-theme="light"] .field input[type="date"] { color-scheme: light; }

/* --- Paginas de formulario (contrasena, baja de cuenta) ------------------- */
.view-inner.narrow { max-width: 620px; }

.volver {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12.5px; color: var(--text-mute);
  margin-bottom: 18px;
}
.volver:hover { color: var(--text); }
/* La flecha apunta a la derecha en el set: aqui se gira para que senale atras. */
.volver svg, .volver .ico { transform: rotate(180deg); }

.form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 22px;
  display: flex; flex-direction: column; gap: 16px;
  margin-top: 20px;
}
.form-acts {
  display: flex; flex-direction: column; gap: 8px;
  margin-top: 4px;
}
.form-acts .btn { width: 100%; }

.profile-actions {
  display: flex; gap: 10px; flex-wrap: wrap;
  margin-top: 22px;
}


/* La zona de acciones irreversibles va separada y al final, no entre los
   campos normales: nadie debe llegar a "eliminar cuenta" por inercia. */
.danger-zone {
  margin-top: 38px;
  padding: 18px 20px;
  border-radius: var(--r-lg);
  border: 1px solid rgba(244,100,90,.34);
  background: var(--danger-soft);
}
.danger-zone b { display: block; font-size: 13.5px; margin-bottom: 3px; }
.danger-zone p { margin: 0 0 14px; font-size: 12.5px; color: var(--text-dim); line-height: 1.5; }
.danger-zone { --btn-h: 36px; }

/* ==========================================================================
   TERMINOS Y CONDICIONES
   ========================================================================== */
.legal { max-width: 760px; }
.legal h3 {
  margin: 30px 0 8px;
  font-size: 15px; font-weight: 650; letter-spacing: -.01em;
}
.legal h3:first-of-type { margin-top: 10px; }
.legal p,
.legal li { font-size: 13.5px; line-height: 1.65; color: var(--text-dim); }
.legal p { margin: 0 0 10px; }
.legal ul { margin: 0 0 14px; padding-left: 20px; }
.legal li { margin-bottom: 5px; }
.legal strong { color: var(--text); font-weight: 600; }

.legal-meta {
  padding: 13px 16px;
  border-radius: var(--r);
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 12px; color: var(--text-mute);
  margin-bottom: 24px;
}

/* --- Sesiones abiertas ---------------------------------------------------- */
.sessions-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-top: 34px;
  --btn-h: 32px;
}
.sessions-head .section-h { margin: 0; }

.session-list { display: flex; flex-direction: column; gap: 8px; }

.session {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 14px;
  border-radius: var(--r);
  border: 1px solid var(--border);
  background: var(--surface);
  --btn-h: 30px;
}
.session.is-current { border-color: var(--brand-line); background: var(--brand-soft); }

.session-ico {
  width: 36px; height: 36px; flex: none;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface-2);
  color: var(--text-dim);
}
.session.is-current .session-ico { background: var(--surface); color: var(--brand); }
.session-ico svg, .session-ico .ico { width: 18px; height: 18px; }

.session-txt { flex: 1; min-width: 0; }
.session-txt b { display: block; font-size: 13px; font-weight: 600; }
.session-txt span,
.session-txt time {
  display: block;
  font-size: 11.5px; color: var(--text-mute);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.session-txt span { margin-top: 2px; }

.pill-current {
  flex: none;
  font-size: 10.5px; font-weight: 650; letter-spacing: .04em; text-transform: uppercase;
  padding: 5px 10px;
  border-radius: 99px;
  color: var(--ok);
  background: rgba(55,201,139,.13);
  border: 1px solid rgba(55,201,139,.32);
}

.empty-line {
  margin: 0; padding: 18px 4px;
  font-size: 13px; color: var(--text-mute); text-align: center;
}

/*
  Puerta de aceptacion. Es un modal sin boton de cerrar a proposito: mientras
  no se acepte no se puede generar, y un aspa daria a entender que se puede
  seguir sin decidir. La salida es aceptar o cerrar sesion.
*/
.gate {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(4,4,8,.72);
  display: grid; place-items: end center;
  padding: 0;
  animation: fade .2s var(--ease);
}
.gate-card {
  width: 100%;
  max-height: 92dvh;
  display: flex; flex-direction: column;
  background: var(--surface);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  box-shadow: var(--shadow-lg);
  animation: rise .26s var(--ease);
}
.gate-head {
  padding: 22px 22px 14px;
  border-bottom: 1px solid var(--border);
  flex: none;
}
.gate-head b { display: block; font-size: 17px; font-weight: 650; letter-spacing: -.01em; }
.gate-head span { display: block; font-size: 12.5px; color: var(--text-dim); margin-top: 4px; line-height: 1.5; }
.gate-body {
  flex: 1; overflow-y: auto;
  padding: 18px 22px;
  -webkit-overflow-scrolling: touch;
}
.gate-foot {
  padding: 16px 22px calc(18px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 8px;
  flex: none;
}
.gate-foot .btn { width: 100%; }

/* ==========================================================================
   RESPONSIVE · de movil hacia arriba

   Todo lo de arriba es la version de telefono. Estos bloques solo ANADEN a
   medida que hay sitio; ninguno desmonta nada.
   ========================================================================== */

/* --- Tableta: caben dos columnas en las rejillas -------------------------- */
@media (min-width: 600px) {
  .topbar { padding: 0 16px; }
.topbar-logo svg, .topbar-logo .ico { width: 104px; }

  .thread { padding: 24px 20px 8px; }
  .composer-wrap { padding: 0 16px calc(14px + var(--rail-gap)); }
  .composer-bar { gap: 8px; padding: 0 12px 12px 14px; }
  .prompt { padding: 16px 18px 10px; min-height: 58px; line-height: 1.55; }
  .btn-go { height: 40px; padding: 0 20px; }

  .grid-out.two { grid-template-columns: 1fr 1fr; }

  /* Hay sitio para verlas todas: el carrusel vuelve a ser rejilla. */
  .suggest {
    display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
    overflow: visible; margin: 0; padding: 0;
  }
  .suggest-card { flex: initial; padding: 14px 16px; font-size: 13px; }
  .suggest-card b { font-size: 13px; }

  .welcome { padding: 8vh 0 40px; }
  .welcome-mark { width: 64px; height: 64px; margin: 0 auto 22px; border-radius: 20px; }
.welcome-mark svg, .welcome-mark .ico { width: 30px; height: 30px; }
  .welcome h2 { margin: 0 0 8px; font-size: 25px; }
  .welcome p { margin: 0 0 28px; font-size: 14.5px; }

  .opt .opt-val, .opt .chev { display: inline; }
  .opt { max-width: none; padding: 7px 11px; gap: 7px; }
  .opt-ref .opt-n { margin-left: 2px; }

  .pop {
    left: auto; right: auto; bottom: auto;
    width: min(400px, calc(100vw - 32px));
    border: 1px solid var(--border-2);
    border-radius: var(--r-lg);
    padding: 14px;
    max-height: min(62vh, 520px);
    animation: pop .18s var(--ease);
  }

  .view { padding: 26px 20px calc(40px + var(--rail-gap)); }
  .masonry { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }

  .kpi-grid { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
  .adm-tab span { display: inline; }
  .set-row { flex-direction: row; align-items: center; }
  .set-ctl .adm-input { width: 130px; text-align: right; }
  .set-ctl .adm-select { max-width: 200px; }
  .drawer-stats { grid-template-columns: repeat(3, 1fr); }
  .adm-kv { grid-template-columns: 1fr 1fr; }
  .adm-filter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .profile-grid { grid-template-columns: 1fr 1fr; }
  .form-acts { flex-direction: row; justify-content: flex-end; }
  .form-acts .btn { width: auto; padding: 0 22px; }
  .security-card { flex-wrap: nowrap; }
  .security-card .btn { width: auto; }
  .pin-form { grid-template-columns: repeat(3, minmax(0, 1fr)) auto; }
}

/* --- Escritorio: el rail sube a columna y el sidebar deja de flotar ------- */
@media (min-width: 900px) {
  :root { --topbar-h: 60px; --rail-gap: 0px; }

  .adm-filter-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }

  .app {
    grid-template-columns: var(--rail) var(--sidebar) 1fr;
    grid-template-areas:
      "topbar topbar topbar"
      "rail   sidebar main";
  }
  /* Vistas sin conversaciones (galeria, plan, perfil, admin): la columna del
     sidebar se cierra a 0 en vez de esconderlo, para que `main` ocupe el hueco. */
  .app.sidebar-off { grid-template-columns: var(--rail) 0 1fr; }

  .rail {
    position: static;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    gap: 6px;
    padding: 14px 0 16px;

    border: 0;
    border-right: 1px solid var(--border);
    border-radius: 0;
    box-shadow: none;
  }
  .rail-spacer { display: block; flex: 1; }

  .rail-btn {
    flex: none;
    width: 56px;
    padding: 9px 4px 7px;
    border-radius: var(--r);
    gap: 5px;
  }
  .rail-btn span { display: block; font-size: 10.5px; }
  .rail-btn:hover { background: var(--surface-2); color: var(--text-dim); }
  .rail-btn.on { background: var(--surface-3); }

  .sidebar {
    position: static;
    width: auto;
    transform: none;
    box-shadow: none;
    z-index: auto;
  }
  .app.sidebar-off .sidebar { border-right: 0; }

  /* El velo solo tiene sentido con el cajon flotante. */
  .veil { display: none; }

  .topbar { padding: 0 20px; gap: 14px; }
  .topbar-logo { width: calc(var(--rail) + var(--sidebar) - 40px); }
.topbar-logo svg, .topbar-logo .ico { width: 112px; }

  .thread { padding: 28px 20px 8px; }
  .composer-wrap { padding: 0 20px 18px; }
  .composer-hint { display: block; }
  .suggest { grid-template-columns: 1fr 1fr; }

  .view { padding: 30px 24px 60px; }
  .masonry { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
  .style-grid { grid-template-columns: repeat(3, 1fr); }
  .balance { padding: 26px 28px; }
  .drawer { width: min(620px, 100vw); }

  /* La puerta de terminos deja de ser una hoja que sube desde abajo y se
     centra como un modal normal. */
  .gate { place-items: center; padding: 24px; }
  .gate-card { width: min(680px, 100%); max-height: 86dvh; border-radius: var(--r-xl); }
  .gate-foot { flex-direction: row; justify-content: flex-end; padding-bottom: 16px; }
  .gate-foot .btn { width: auto; padding: 0 22px; }
}

/* --- Pantallas anchas: el panel de admin respira ------------------------- */
@media (min-width: 1100px) {
  .adm-cols { grid-template-columns: 1fr 1fr; }
  .profile-grid { grid-template-columns: 1fr 1fr; }
  .adm-chart-key { display: flex; }
}

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