/* Enlace · mezcla de dos apps que Nilo usa a diario: se conversa como en la de mensajería (burbujas, lista de
   chats, botones dentro del mensaje) y se ve y se escribe como en la de Claude (tonos cálidos, caja de escribir
   con «+», barra lateral que se ensancha y se esconde). Oscuro por defecto; claro si el teléfono está en claro. */
:root {
  --fondo: #1f1e1d;          /* barra lateral y barras */
  --fondo-chat: #262624;
  --barra-chat: #262624;
  --texto: #f5f4ee;
  --suave: #a6a39a;
  --linea: #3a3936;
  --campo: #30302e;
  --caja: #30302e;
  --mio: #4a3226;            /* mis burbujas: terracota oscura */
  --mio-texto: #f8efe9;
  --suyo: #333331;
  --acento: #d97757;         /* naranja de Claude: enviar, sin leer, activo */
  --acento-texto: #ffffff;
  --acento-suave: rgba(217, 119, 87, .16);
  --bien: #6cc58f;
  --enlace: #8fb8ff;
  --amarillo: #ffd60a;
  --mal: #f2777f;
  --aviso: #f0b45a;
  --visto: #8fb8ff;
  --trama-op: .035;
  --sombra: 0 1px 1.5px rgba(0, 0, 0, .25);
  --radio: 14px;
  --ancho-lista: 380px;
  --serif: "Iowan Old Style", Charter, Georgia, "Times New Roman", serif;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --fondo: #f0eee6; --fondo-chat: #faf9f5; --barra-chat: #faf9f5; --texto: #1f1e1d; --suave: #6b6a63; --linea: #e3e0d5;
  --campo: #e8e5da; --caja: #ffffff; --mio: #f4ddd0; --mio-texto: #2b1a12; --suyo: #ffffff; --acento: #c96442;
  --acento-suave: rgba(201, 100, 66, .12); --bien: #2e8b57; --enlace: #2563c9; --visto: #2563c9; --trama-op: .05;
  --sombra: 0 1px 2px rgba(31, 30, 29, .1); color-scheme: light;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --fondo: #f0eee6; --fondo-chat: #faf9f5; --barra-chat: #faf9f5; --texto: #1f1e1d; --suave: #6b6a63; --linea: #e3e0d5;
    --campo: #e8e5da; --caja: #ffffff; --mio: #f4ddd0; --mio-texto: #2b1a12; --suyo: #ffffff; --acento: #c96442;
    --acento-suave: rgba(201, 100, 66, .12); --bien: #2e8b57; --enlace: #2563c9; --visto: #2563c9; --trama-op: .05;
    --sombra: 0 1px 2px rgba(31, 30, 29, .1); color-scheme: light;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  background: var(--fondo); color: var(--texto); -webkit-tap-highlight-color: transparent; overscroll-behavior: none;
}
button, input, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
svg { width: 24px; height: 24px; fill: currentColor; }
.app { height: 100dvh; display: flex; overflow: hidden; }
.app.arrastrando, .app.arrastrando * { cursor: col-resize !important; user-select: none !important; }

/* --- entrada --- */
.entrada { flex: 1; display: grid; place-items: center; padding: 24px 16px; background: var(--fondo); }
.entrada__caja { width: min(100%, 360px); background: var(--caja); border-radius: 20px; padding: 28px 22px 24px; display: grid; gap: 14px; border: 1px solid var(--linea); }
.entrada__logo { justify-self: center; }
.entrada h1 { margin: 0; text-align: center; font: 500 30px var(--serif); }
.entrada__lema { margin: -8px 0 6px; text-align: center; color: var(--suave); }
.entrada label { display: grid; gap: 6px; font-size: 14px; color: var(--suave); }
.entrada input { font-size: 17px; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--linea); background: var(--fondo); color: var(--texto); }
.entrada input:focus { outline: 2px solid var(--acento); outline-offset: 1px; }
.entrada__error { margin: 0; color: var(--mal); font-size: 14px; }
.boton { border: 0; border-radius: 12px; background: var(--acento); color: var(--acento-texto); padding: 10px 16px; font-weight: 600; cursor: pointer; }
.boton--grande { padding: 13px; font-size: 17px; }
.boton--claro { background: var(--campo); color: var(--texto); }

/* --- barras --- */
.barra { display: flex; align-items: center; gap: 4px; min-height: 60px; padding: 6px 6px 6px 8px; padding-top: max(6px, env(safe-area-inset-top)); background: var(--fondo); color: var(--texto); position: relative; flex: none; }
.barra__titulo { margin: 0 0 0 6px; font: 500 25px var(--serif); flex: 1; letter-spacing: -.2px; }
.barra--chat { background: var(--barra-chat); gap: 8px; border-bottom: 1px solid var(--linea); }
.barra__quien { flex: 1; min-width: 0; }
.barra__quien h2 { margin: 0; font-size: 17.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.barra__quien p { margin: 0; font-size: 13px; color: var(--suave); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.barra__quien p.escribe { color: var(--acento); }
.icono-btn { border: 0; background: none; width: 42px; height: 42px; border-radius: 10px; display: grid; place-items: center; cursor: pointer; color: inherit; flex: none; }
.icono-btn:hover { background: rgba(166, 163, 154, .12); }
.icono-btn:active { background: rgba(166, 163, 154, .22); }
.entorno { font-size: 11px; font-weight: 800; letter-spacing: .6px; padding: 3px 7px; border-radius: 6px; background: var(--amarillo); color: #0b1f3a; }
.entorno--prod { background: var(--mal); color: #fff; }
.menu { position: absolute; right: 10px; top: calc(100% - 4px); background: var(--caja); color: var(--texto); border: 1px solid var(--linea); border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.3); z-index: 30; min-width: 230px; overflow: hidden; padding: 4px; }
.menu button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 11px 14px; cursor: pointer; border-radius: 8px; }
.menu button:hover, .menu button:active { background: var(--acento-suave); }
.menu--msg { position: fixed; min-width: 170px; }

/* --- barra lateral --- */
.lista { width: 100%; display: flex; flex-direction: column; background: var(--fondo); position: relative; }
.buscar { margin: 4px 12px 10px; display: flex; align-items: center; gap: 10px; background: var(--campo); border-radius: 22px; padding: 0 16px; color: var(--suave); }
.buscar svg { width: 20px; height: 20px; flex: none; }
.buscar input { flex: 1; border: 0; background: none; padding: 11px 0; color: var(--texto); outline: none; font-size: 16px; min-width: 0; }
.filtros { display: flex; gap: 8px; padding: 0 12px 8px; overflow-x: auto; scrollbar-width: none; flex: none; }
.filtros button { flex: none; border: 1px solid var(--linea); background: none; color: var(--suave); border-radius: 16px; padding: 5px 13px; font-size: 14.5px; cursor: pointer; white-space: nowrap; }
.filtros button.es-activo { background: var(--acento-suave); border-color: transparent; color: var(--acento); font-weight: 600; }
.chats { list-style: none; margin: 0; padding: 0 8px 90px; overflow-y: auto; flex: 1; }
.grupo-fila { display: flex; align-items: center; gap: 12px; padding: 14px 8px 4px; }
.grupo-fila__avatar { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 16px; flex: none; box-shadow: inset 0 -3px 0 var(--amarillo); }
.grupo-fila__textos { flex: 1; min-width: 0; }
.grupo-fila__nombre { font-weight: 700; font-size: 15.5px; display: flex; gap: 8px; align-items: center; }
.grupo-fila__sub { font-size: 12.5px; color: var(--suave); }
.chat-fila { display: flex; gap: 12px; align-items: center; padding: 9px 10px; cursor: pointer; border: 0; width: 100%; background: none; text-align: left; border-radius: 12px; }
.chat-fila--funcion { padding-left: 20px; }
.chat-fila:hover { background: rgba(166, 163, 154, .08); }
.chat-fila:active, .chat-fila.es-actual { background: var(--campo); }
.chat-fila__cuerpo { flex: 1; min-width: 0; }
.chat-fila__fila1, .chat-fila__fila2 { display: flex; align-items: center; gap: 8px; }
.chat-fila__titulo { flex: 1; font-weight: 500; font-size: 16.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-fila__hora { font-size: 12px; color: var(--suave); }
.chat-fila.tiene-nuevos .chat-fila__hora { color: var(--acento); font-weight: 600; }
.chat-fila__previa { flex: 1; font-size: 14.5px; color: var(--suave); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-fila__previa.escribe { color: var(--acento); }
.insignia { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--acento); color: #fff; font-size: 11.5px; font-weight: 800; display: grid; place-items: center; }
.etiqueta { font-size: 10.5px; font-weight: 800; padding: 1px 6px; border-radius: 5px; background: var(--amarillo); color: #0b1f3a; }
.avatar { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 21px; flex: none; background: var(--campo); }
.barra .avatar { width: 38px; height: 38px; font-size: 18px; }
.lista__vacia { padding: 30px 20px; text-align: center; color: var(--suave); }
.nuevo { position: absolute; right: 14px; bottom: calc(80px + env(safe-area-inset-bottom)); display: flex; align-items: center; gap: 8px; border: 0; border-radius: 24px; padding: 12px 18px 12px 14px; background: var(--texto); color: var(--fondo); font-weight: 600; font-size: 15.5px; cursor: pointer; box-shadow: 0 6px 18px rgba(0,0,0,.3); }
.nuevo svg { width: 22px; height: 22px; }
.pestanas { display: flex; border-top: 1px solid var(--linea); background: var(--fondo); padding-bottom: env(safe-area-inset-bottom); flex: none; }
.pestana { flex: 1; border: 0; background: none; color: var(--texto); padding: 8px 0 9px; display: grid; justify-items: center; gap: 3px; font-size: 13px; font-weight: 600; cursor: pointer; }
.pestana__icono { width: 60px; height: 30px; border-radius: 15px; display: grid; place-items: center; position: relative; }
.pestana.es-activa .pestana__icono { background: var(--acento-suave); color: var(--acento); }
.punto { position: absolute; top: 1px; right: 13px; width: 9px; height: 9px; border-radius: 50%; background: var(--acento); }
.asa { display: none; }

/* --- conversación --- */
.conversacion { flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative; background: var(--fondo-chat); isolation: isolate; }
.conversacion::before {
  content: ""; position: absolute; inset: 0; z-index: -1; opacity: var(--trama-op); pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240' viewBox='0 0 240 240' fill='none' stroke='%23ffffff' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 30h28v20H20zM20 30l14 9 14-9'/%3E%3Ccircle cx='118' cy='38' r='12'/%3E%3Cpath d='M112 38h12M118 32v12'/%3E%3Cpath d='M186 22l10 19h-20z'/%3E%3Cpath d='M30 118a13 13 0 1 1 26 0c0 9-13 19-13 19s-13-10-13-19z'/%3E%3Cpath d='M98 108h34v24H98zM104 108v-7h22v7'/%3E%3Cpath d='M172 112l9 9 17-17'/%3E%3Crect x='18' y='184' width='32' height='24' rx='4'/%3E%3Ccircle cx='34' cy='196' r='6'/%3E%3Cpath d='M102 190c7-11 24-11 31 0M106 201h23'/%3E%3Cpath d='M176 182l20 4-4 20-20-4z'/%3E%3C/svg%3E");
  background-size: 240px 240px;
}
:root[data-theme="light"] .conversacion::before { filter: invert(1); }
@media (prefers-color-scheme: light) { :root:not([data-theme="dark"]) .conversacion::before { filter: invert(1); } }
.mensajes { flex: 1; overflow-y: auto; padding: 12px max(4%, 12px) 10px; display: flex; flex-direction: column; gap: 2px; overscroll-behavior: contain; }
.mensajes > * { flex-shrink: 0; } /* sin esto, las tarjetas (overflow: hidden) se encogían y cortaban sus botones */
.dia { align-self: center; margin: 12px 0 8px; font-size: 12.5px; padding: 4px 12px; border-radius: 10px; background: var(--campo); color: var(--suave); }
.burbuja { max-width: min(82%, 600px); padding: 7px 10px 6px 11px; border-radius: var(--radio); box-shadow: var(--sombra); background: var(--suyo); align-self: flex-start; position: relative; overflow-wrap: anywhere; margin-top: 7px; border-top-left-radius: 4px; }
.burbuja.sigue { margin-top: 2px; border-top-left-radius: var(--radio); }
.burbuja--yo { background: var(--mio); color: var(--mio-texto); align-self: flex-end; border-top-left-radius: var(--radio); border-top-right-radius: 4px; }
.burbuja--yo.sigue { border-top-right-radius: var(--radio); }
.burbuja__texto { white-space: pre-wrap; font-size: 15.5px; }
.burbuja__texto a { color: var(--enlace); }
.burbuja__pie { float: right; margin: 8px 0 -4px 12px; font-size: 11.5px; color: var(--suave); line-height: 1; display: flex; gap: 3px; align-items: center; }
.burbuja--yo .burbuja__pie { color: color-mix(in srgb, var(--mio-texto) 60%, transparent); }
.burbuja__pie svg { width: 17px; height: 17px; }
.burbuja__agente { font-size: 12.5px; font-weight: 700; color: var(--acento); margin-bottom: 1px; }
.burbuja__mas { position: absolute; top: 4px; right: 4px; width: 26px; height: 26px; border-radius: 8px; border: 0; background: var(--campo); color: var(--suave); display: none; place-items: center; cursor: pointer; }
.burbuja__mas svg { width: 16px; height: 16px; }
@media (hover: hover) { .burbuja:hover > .burbuja__mas { display: grid; } }
.burbuja.marcada { outline: 2px solid var(--acento); }
.burbuja--foto { padding: 3px; }
.burbuja--foto img { display: block; width: 100%; max-width: 320px; max-height: 380px; object-fit: cover; border-radius: 11px; cursor: zoom-in; background: var(--linea); aspect-ratio: var(--ar, 4/3); }
.burbuja--foto .burbuja__texto { padding: 5px 7px 2px; }
.burbuja--foto .burbuja__pie { margin: 0; position: absolute; right: 10px; bottom: 9px; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.6); }
.burbuja--foto:has(.burbuja__texto) .burbuja__pie { position: static; color: inherit; opacity: .7; text-shadow: none; margin: 4px 4px 2px 10px; }
.sello { position: absolute; left: 10px; top: 10px; font-size: 11.5px; font-weight: 700; padding: 3px 8px; border-radius: 8px; background: rgba(20, 20, 19, .75); color: #fff; }
.doc { display: flex; align-items: center; gap: 12px; padding: 8px 6px 6px 4px; color: inherit; text-decoration: none; min-width: 230px; }
.doc__ico { width: 40px; height: 48px; border-radius: 6px; background: #e5484d; color: #fff; display: grid; place-items: end center; padding-bottom: 6px; font-size: 10.5px; font-weight: 800; flex: none; position: relative; }
.doc__ico::before { content: ""; position: absolute; right: 0; top: 0; border-style: solid; border-width: 0 11px 11px 0; border-color: transparent var(--suyo) rgba(0,0,0,.25) transparent; }
.burbuja--yo .doc__ico::before { border-right-color: var(--mio); }
.doc__textos { min-width: 0; display: grid; }
.doc__nombre { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc__meta { font-size: 12.5px; opacity: .75; }
.burbuja--error { background: #43252a; color: #ffd6dc; }
:root[data-theme="light"] .burbuja--error { background: #fde8e7; color: #7a1a12; }
.burbuja--nota { font-style: italic; color: var(--suave); }
.cita { display: flex; gap: 8px; align-items: center; background: rgba(0, 0, 0, .16); border-left: 4px solid var(--acento); border-radius: 8px; padding: 6px 8px 6px 10px; margin: 1px 0 5px; font-size: 14px; }
:root[data-theme="light"] .cita { background: rgba(31, 30, 29, .05); }
.cita__cuerpo { min-width: 0; flex: 1; display: grid; }
.cita__cuerpo b { color: var(--acento); font-size: 13px; }
.cita__cuerpo span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: .85; }
.cita--escribir { margin: 0 0 6px; }

/* tarjetas (vista previa, dónde y cómo, promos) */
.tarjeta { padding: 0; overflow: hidden; width: min(82%, 440px); }
.tarjeta__fotos { display: grid; grid-auto-flow: column; grid-auto-columns: 100%; overflow-x: auto; scroll-snap-type: x mandatory; background: #fff; }
.tarjeta__fotos img { width: 100%; aspect-ratio: 1; object-fit: contain; background: #fff; scroll-snap-align: start; cursor: zoom-in; }
.tarjeta__cuerpo { padding: 10px 13px 4px; }
.tarjeta__titulo { margin: 0 0 2px; font: 600 19px var(--serif); }
.tarjeta__sub { margin: 0 0 6px; color: var(--acento); font-size: 13.5px; font-weight: 600; }
.tarjeta__precio { margin: 4px 0 6px; font-size: 21px; font-weight: 800; }
.tarjeta__precio small { display: block; font-size: 12.5px; font-weight: 500; color: var(--suave); }
.campos { margin: 6px 0; display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; font-size: 14.5px; }
.campos dt { color: var(--suave); }
.campos dd { margin: 0; }
.avisos-revisor { margin: 8px 0 4px; padding: 0; list-style: none; display: grid; gap: 5px; font-size: 14px; }
.avisos-revisor li { padding: 6px 9px; border-radius: 8px; background: rgba(240, 180, 90, .13); color: #f5cf92; }
.avisos-revisor li.es-bloqueo { background: rgba(242, 119, 127, .15); color: #ffaab0; }
.avisos-revisor li.es-bien { background: rgba(108, 197, 143, .15); color: #9fe0b9; }
:root[data-theme="light"] .avisos-revisor li { background: #fff4e0; color: #6b3d00; }
:root[data-theme="light"] .avisos-revisor li.es-bloqueo { background: #fde8e7; color: #7a1a12; }
:root[data-theme="light"] .avisos-revisor li.es-bien { background: #e3f5ec; color: #0c5a40; }
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .avisos-revisor li { background: #fff4e0; color: #6b3d00; }
  :root:not([data-theme="dark"]) .avisos-revisor li.es-bloqueo { background: #fde8e7; color: #7a1a12; }
  :root:not([data-theme="dark"]) .avisos-revisor li.es-bien { background: #e3f5ec; color: #0c5a40; }
  :root:not([data-theme="dark"]) .burbuja--error { background: #fde8e7; color: #7a1a12; }
  :root:not([data-theme="dark"]) .cita { background: rgba(31, 30, 29, .05); }
}
.tarjeta .burbuja__pie { margin: 0 12px 8px; }
.tarjeta__video { display: block; width: 100%; max-height: 460px; background: #000; }
.botones { display: flex; flex-direction: column; border-top: 1px solid var(--linea); clear: both; margin-top: 4px; }
.botones button { border: 0; background: none; padding: 12px 10px; color: var(--enlace); font-weight: 500; font-size: 15.5px; cursor: pointer; border-bottom: 1px solid var(--linea); }
.botones button:last-child { border-bottom: 0; }
.botones button.es-principal { color: var(--acento); font-weight: 700; }
.botones button.es-peligro { color: var(--mal); }
.botones button:disabled { color: var(--suave); cursor: default; }
.botones button:hover:not(:disabled) { background: rgba(166, 163, 154, .08); }
.usado { font-size: 13px; color: var(--suave); padding: 8px 12px; border-top: 1px solid var(--linea); clear: both; }

/* progreso de los agentes */
.progreso { min-width: min(82%, 320px); }
.pasos { list-style: none; margin: 6px 0 2px; padding: 0; display: grid; gap: 6px; font-size: 14.5px; }
.pasos li { display: flex; gap: 9px; align-items: flex-start; color: var(--suave); }
.pasos li.es-hecho { color: var(--texto); }
.burbuja--yo .pasos li.es-hecho { color: var(--mio-texto); }
.pasos li.es-error { color: var(--mal); }
.paso-marca { width: 18px; height: 18px; flex: none; border-radius: 50%; border: 2px solid var(--linea); display: grid; place-items: center; margin-top: 2px; }
.es-hecho .paso-marca { border-color: var(--bien); background: var(--bien); }
.es-hecho .paso-marca::after { content: ""; width: 5px; height: 9px; border: solid #1f1e1d; border-width: 0 2px 2px 0; transform: translateY(-1px) rotate(45deg); }
.es-ahora .paso-marca { border-color: var(--acento); border-right-color: transparent; animation: girar .8s linear infinite; }
.es-error .paso-marca { border-color: var(--mal); background: var(--mal); }
@keyframes girar { to { transform: rotate(360deg); } }

/* avisos */
.aviso { border-left: 4px solid var(--enlace); }
.aviso--alerta { border-left-color: var(--mal); }
.aviso--aviso { border-left-color: var(--aviso); }
.aviso--bien { border-left-color: var(--bien); }
.aviso__origen { font-size: 12px; font-weight: 700; color: var(--suave); text-transform: uppercase; letter-spacing: .5px; }
.aviso__titulo { margin: 2px 0 3px; font-weight: 700; }
.aviso a { color: var(--enlace); font-size: 14.5px; }
.escribiendo-burbuja { display: inline-flex; gap: 4px; padding: 13px 14px; }
.escribiendo-burbuja i { width: 7px; height: 7px; border-radius: 50%; background: var(--acento); animation: saltar 1.2s infinite; }
.escribiendo-burbuja i:nth-child(2) { animation-delay: .15s; }
.escribiendo-burbuja i:nth-child(3) { animation-delay: .3s; }
@keyframes saltar { 0%, 60%, 100% { transform: none; opacity: .45; } 30% { transform: translateY(-4px); opacity: 1; } }
.abajo { position: absolute; right: 16px; bottom: 150px; width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--linea); background: var(--caja); color: var(--suave); box-shadow: 0 2px 8px rgba(0,0,0,.25); display: grid; place-items: center; cursor: pointer; z-index: 2; }
.soltar { position: absolute; inset: 70px 12px 12px; z-index: 5; border: 2px dashed var(--acento); border-radius: 18px; background: color-mix(in srgb, var(--fondo-chat) 85%, transparent); display: grid; place-items: center; font-size: 18px; font-weight: 600; color: var(--acento); pointer-events: none; }

/* atajos y la caja de escribir (como la de Claude) */
.atajos { display: flex; gap: 8px; overflow-x: auto; padding: 6px 12px 2px; scrollbar-width: none; flex: none; }
.atajos:empty { display: none; }
.atajos button { flex: none; border: 1px solid var(--linea); background: var(--caja); color: var(--texto); border-radius: 16px; padding: 6px 12px; font-size: 14px; cursor: pointer; }
.atajos button:hover { border-color: var(--acento); }
.escribir { padding: 6px max(4%, 10px) calc(10px + env(safe-area-inset-bottom)); flex: none; position: relative; }
.caja { background: var(--caja); border: 1px solid var(--linea); border-radius: 24px; padding: 10px 10px 8px 14px; box-shadow: 0 2px 10px rgba(0,0,0,.12); max-width: 900px; margin: 0 auto; }
.caja:focus-within { border-color: color-mix(in srgb, var(--acento) 55%, var(--linea)); }
.caja textarea { display: block; width: 100%; resize: none; border: 0; background: none; padding: 4px 2px 6px; max-height: 180px; height: 34px; color: var(--texto); line-height: 1.4; font-size: 16.5px; }
.caja textarea:focus { outline: none; }
.caja textarea::placeholder { color: var(--suave); }
.caja__fila { display: flex; align-items: center; gap: 4px; }
.caja__hueco { flex: 1; }
.redondo { width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--linea); background: none; color: var(--texto); display: grid; place-items: center; cursor: pointer; flex: none; }
.redondo:hover { background: rgba(166, 163, 154, .12); }
.redondo svg { width: 20px; height: 20px; }
.chip-funcion { margin-left: 6px; border: 1px solid var(--linea); border-radius: 16px; padding: 5px 12px; font-size: 13.5px; color: var(--suave); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 48%; }
.caja .icono-btn { color: var(--suave); width: 38px; height: 38px; border-radius: 50%; }
#btn-dictar.oyendo { color: #fff; background: var(--mal); animation: latido 1.2s infinite; }
@keyframes latido { 50% { box-shadow: 0 0 0 6px rgba(242, 119, 127, .25); } }
.enviar { width: 38px; height: 38px; flex: none; border-radius: 50%; border: 0; background: var(--acento); color: #fff; display: grid; place-items: center; cursor: pointer; margin-left: 2px; }
.enviar:disabled, .enviar.vacio { opacity: .45; }
.enviar svg { width: 20px; height: 20px; }
.previa { display: flex; gap: 8px; padding: 2px 0 8px; overflow-x: auto; }
.previa figure { margin: 0; position: relative; flex: none; }
.previa img { width: 70px; height: 70px; object-fit: cover; border-radius: 12px; display: block; }
.previa .doc-chip { height: 70px; min-width: 150px; max-width: 220px; border-radius: 12px; border: 1px solid var(--linea); display: flex; align-items: center; gap: 8px; padding: 0 10px; font-size: 13px; }
.previa .doc-chip .doc__ico { width: 30px; height: 38px; font-size: 9px; padding-bottom: 4px; }
.previa .doc-chip .doc__ico::before { border-right-color: var(--caja); }
.previa .doc-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.previa .sello { left: 4px; top: auto; bottom: 4px; font-size: 10px; padding: 2px 5px; }
.previa figure.subiendo img, .previa figure.subiendo .doc-chip { opacity: .5; }
.previa figure.subiendo::after { content: ""; position: absolute; left: 50%; top: 50%; width: 22px; height: 22px; margin: -11px; border: 3px solid var(--acento); border-right-color: transparent; border-radius: 50%; animation: girar .8s linear infinite; }
.previa figure.fallo img, .previa figure.fallo .doc-chip { outline: 3px solid var(--mal); }
.previa .quitar { position: absolute; top: -6px; right: -6px; width: 22px; height: 22px; border-radius: 50%; border: 0; background: var(--texto); color: var(--fondo); font-size: 12px; line-height: 1; cursor: pointer; }
.hoja { position: absolute; left: max(4%, 10px); bottom: calc(100% - 4px); z-index: 20; background: var(--caja); border: 1px solid var(--linea); border-radius: 16px; box-shadow: 0 12px 34px rgba(0,0,0,.35); padding: 6px; width: min(330px, calc(100vw - 24px)); }
.hoja button { display: flex; gap: 12px; align-items: center; width: 100%; text-align: left; border: 0; background: none; padding: 9px 10px; border-radius: 10px; cursor: pointer; }
.hoja button:hover, .hoja button:active { background: var(--acento-suave); }
.hoja__ico { width: 36px; height: 36px; border-radius: 10px; background: var(--campo); display: grid; place-items: center; font-size: 18px; flex: none; }
.hoja b { display: block; font-weight: 600; font-size: 15px; }
.hoja small { display: block; color: var(--suave); font-size: 12.5px; }

.vacio { flex: 1; display: grid; place-content: center; justify-items: center; gap: 12px; color: var(--suave); background: var(--fondo-chat); text-align: center; padding: 20px; }
.vacio h2 { margin: 0; color: var(--texto); font: 500 30px var(--serif); }
.visor { border: 0; padding: 0; background: rgba(0,0,0,.94); color: #fff; max-width: 100vw; max-height: 100dvh; width: 100vw; height: 100dvh; }
.visor img { width: 100%; height: 100%; object-fit: contain; }
.visor__cerrar { position: absolute; top: max(10px, env(safe-area-inset-top)); right: 10px; color: #fff; font-size: 22px; }
.visor::backdrop { background: rgba(0,0,0,.9); }
.toast { position: fixed; left: 50%; bottom: calc(110px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 40; background: var(--texto); color: var(--fondo); padding: 10px 16px; border-radius: 12px; font-size: 14.5px; max-width: calc(100vw - 32px); box-shadow: 0 6px 20px rgba(0,0,0,.3); }

/* Móvil / Fold cerrado (como la app de Claude): el chat ocupa la pantalla y la barra lateral es un cajón que entra
   deslizando desde la izquierda (botón ☰, o arrastrar desde el borde) y se va al elegir un chat, tocar fuera o «atrás» */
@media (max-width: 599px) {
  .btn-panel--chat, .btn-panel--vacio, .barra--lista .btn-panel { display: none; }
  .barra--lista .barra__titulo { margin-left: 10px; }
  .app--dentro .lista, .app--dentro .lista[hidden] { display: flex !important; position: fixed; z-index: 30; top: 0; bottom: 0; left: 0;
    width: min(86vw, 400px); transform: translateX(-102%); transition: transform .26s cubic-bezier(.2,.8,.2,1);
    box-shadow: 6px 0 28px rgba(0,0,0,.45); border-radius: 0 18px 18px 0; overflow: hidden; }
  .app--cajon .lista, .app--cajon .lista[hidden] { transform: none; }
  .app.cajon-arrastre .lista { transition: none; }
  .velo { position: fixed; inset: 0; z-index: 29; background: rgba(0,0,0,.5); opacity: 0; transition: opacity .26s; }
  .velo { pointer-events: none; }
  .app--cajon .velo { opacity: 1; pointer-events: auto; }
  .nuevo { bottom: calc(80px + env(safe-area-inset-bottom)); }
}
@media (min-width: 600px) { .velo { display: none !important; } }
/* Pantalla ancha (Fold abierto, tablet, ordenador): barra lateral a la izquierda que se ensancha arrastrando
   su borde y se esconde con el botón de arriba; abajo no hacen falta las pestañas del móvil */
@media (min-width: 600px) {
  .lista { width: var(--ancho-lista); min-width: 260px; max-width: 70vw; flex: none; border-right: 1px solid var(--linea); }
  .app--dentro .lista[hidden] { display: flex !important; }
  .app--sin-lista .lista, .app--sin-lista .lista[hidden] { display: none !important; }
  .app:not(.app--sin-lista) .btn-panel--chat, .app:not(.app--sin-lista) .btn-panel--vacio { display: none; }
  .volver { display: none; }
  .pestanas { display: none; }
  .nuevo { bottom: calc(18px + env(safe-area-inset-bottom)); }
  .asa { display: block; touch-action: none; user-select: none; position: absolute; top: 0; right: -6px; bottom: 0; width: 12px; cursor: col-resize; z-index: 6; }
  .asa::after { content: ""; position: absolute; top: 0; bottom: 0; left: 5px; width: 2px; background: transparent; transition: background .15s; }
  .asa:hover::after, .asa:focus-visible::after, .app.arrastrando .asa::after { background: var(--acento); }
  .asa:focus-visible { outline: none; }
}

/* --- usabilidad (mensajería + Claude) --- */
.dia { position: sticky; top: 6px; z-index: 3; box-shadow: 0 2px 6px rgba(0,0,0,.25); }                     /* la fecha queda arriba al desplazarse */
.sin-leer { align-self: stretch; text-align: center; margin: 10px -4%; padding: 5px 0; font-size: 13px; font-weight: 600;
  color: var(--acento); background: var(--acento-suave); }
.estado { display: inline-grid; }
.estado svg { width: 16px; height: 16px; }
.estado--enviando, .estado--recibido, .estado--procesando { color: color-mix(in srgb, currentColor 75%, transparent); }
.estado--atendido { color: var(--visto); }
.estado--error { color: var(--mal); }
.burbuja--yo .estado--atendido svg { color: var(--visto); }
.sin-enviar { opacity: .92; outline: 1px dashed var(--mal); }
.burbuja { transition: transform .12s ease-out; }
.burbuja.deslizando::after { content: "↩"; position: absolute; left: -34px; top: 50%; transform: translateY(-50%); width: 26px; height: 26px;
  border-radius: 50%; background: var(--campo); color: var(--texto); display: grid; place-items: center; font-size: 14px; }
.abajo.con-nuevos::after { content: attr(data-n); position: absolute; top: -6px; right: -4px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px;
  background: var(--acento); color: #fff; font-size: 11.5px; font-weight: 800; display: grid; place-items: center; }
.otra-foto { flex: none; width: 70px; height: 70px; border-radius: 12px; border: 1.5px dashed var(--linea); background: none; color: var(--suave);
  display: grid; place-content: center; justify-items: center; gap: 0; cursor: pointer; }
.otra-foto small { font-size: 11px; }
#btn-dictar.dictar--grande { width: 38px; height: 38px; background: var(--acento); color: #fff; }
#btn-dictar.dictar--grande.oyendo { background: var(--mal); }
.visor { display: none; }
.visor[open] { display: grid; grid-template-rows: auto 1fr; }
.visor__barra { display: flex; align-items: center; gap: 6px; padding: max(8px, env(safe-area-inset-top)) 8px 8px 16px; color: #fff; }
.visor__cuenta { flex: 1; font-size: 14px; opacity: .85; }
.visor__barra .icono-btn { color: #fff; position: static; }
.visor__marco { overflow: auto; display: grid; place-items: center; min-height: 0; }
.visor__marco img { max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; touch-action: pinch-zoom; }
.visor.ampliado .visor__marco { place-items: start; }
.visor.ampliado .visor__marco img { max-width: none; max-height: none; width: 220%; }
.visor__ant, .visor__sig { position: absolute; top: 50%; transform: translateY(-50%); color: #fff; background: rgba(0, 0, 0, .35); width: 46px; height: 46px; border-radius: 50%; }
.visor__ant { left: 10px; } .visor__sig { right: 10px; }

/* --- notas de voz, búsqueda, fijar y silenciar --- */
.burbuja--audio { min-width: min(82%, 300px); }
.burbuja--audio audio { width: 100%; height: 40px; display: block; margin: 2px 0; }
.audio__meta { font-size: 12.5px; font-weight: 600; opacity: .8; }
.audio__texto { font-size: 14.5px; margin-top: 3px; }
.audio__texto--sin { font-style: italic; opacity: .6; font-size: 13px; }
.grabando { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 4px 2px 8px; font-variant-numeric: tabular-nums; }
.grabando__punto { width: 10px; height: 10px; border-radius: 50%; background: var(--mal); animation: latido 1s infinite; }
.grabando__ayuda { flex: 1; text-align: right; font-size: 12.5px; color: var(--suave); }
.grabando__texto { flex-basis: 100%; font-size: 14px; color: var(--suave); font-style: italic; min-height: 0; }
#btn-dictar.grabando-btn { background: var(--mal); color: #fff; transform: scale(1.25); }
#btn-dictar { touch-action: none; user-select: none; -webkit-user-select: none; }
.buscador { display: flex; align-items: center; gap: 4px; padding: 6px 8px 6px 14px; background: var(--barra-chat); border-bottom: 1px solid var(--linea); flex: none; }
.buscador input { flex: 1; min-width: 0; border: 1px solid var(--linea); border-radius: 18px; background: var(--caja); color: var(--texto); padding: 8px 14px; font-size: 15.5px; outline: none; }
.buscador input:focus { border-color: var(--acento); }
.buscador__cuenta { font-size: 13px; color: var(--suave); min-width: 34px; text-align: center; font-variant-numeric: tabular-nums; }
.burbuja.hallada { box-shadow: 0 0 0 2px color-mix(in srgb, var(--aviso) 60%, transparent); }
.burbuja.hallada-actual { box-shadow: 0 0 0 3px var(--aviso); }
.icono-fila { display: inline-grid; color: var(--suave); }
.icono-fila svg { width: 16px; height: 16px; }
.insignia--gris { background: var(--suave); }
#menu-fila { min-width: 230px; }

/* --- alta y doble factor --- */
.entrada { overflow-y: auto; }
.entrada__caja--ancha { width: min(100%, 440px); }
.pasos-2fa { margin: 0; padding-left: 20px; display: grid; gap: 6px; color: var(--suave); font-size: 15px; }
.doble__qr { justify-self: center; width: 220px; height: 220px; border-radius: 12px; background: #fff; padding: 6px; }
.doble__secreto { margin: 0; font-size: 13.5px; color: var(--suave); text-align: center; }
.doble__secreto code { display: block; margin-top: 4px; font-size: 15px; color: var(--texto); letter-spacing: .5px; user-select: all; }
#form-doble { display: grid; gap: 12px; }
#doble-recuperacion { display: grid; gap: 10px; }
.doble__codigos { margin: 0; padding: 12px; list-style: none; display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px;
  background: var(--fondo); border-radius: 12px; font: 600 16px ui-monospace, Consolas, monospace; text-align: center; }
a.boton { text-align: center; text-decoration: none; }
.archivo-borrado { padding: 18px 14px; font-size: 13px; font-style: italic; color: var(--suave); }
