:root {
  --fondo: #f7f5f0;
  --panel: #ffffff;
  --lateral: #efece5;
  --borde: #dedad0;
  --texto: #1d1c1a;
  --tenue: #6d6960;
  --acento: #1d5c7a;
  --acento-suave: #e3eef3;
  --sobre-acento: #ffffff;
  --ambar: #e0a243;
  --burbuja: #e9e5dc;
  --error: #a3261e;
  --aviso: #7a5b00;
  --sombra: 0 1px 2px rgb(0 0 0 / 0.05), 0 8px 24px rgb(0 0 0 / 0.06);
  --ancho-texto: 760px;
  --barra: color-mix(in srgb, var(--texto) 18%, transparent);
  --barra-activa: color-mix(in srgb, var(--texto) 32%, transparent);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --fondo: #1c1b19;
    --panel: #272623;
    --lateral: #161514;
    --borde: #3b3935;
    --texto: #eceae4;
    --tenue: #a29e95;
    --acento: #7fbcd8;
    --acento-suave: #23323a;
    --sobre-acento: #0f2530;
    --ambar: #e8b565;
    --burbuja: #33312d;
    --error: #f0958d;
    --aviso: #e0bd5c;
    --sombra: 0 1px 2px rgb(0 0 0 / 0.3), 0 8px 24px rgb(0 0 0 / 0.35);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body { background: var(--fondo); color: var(--texto); font: 15px/1.55 system-ui, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
h1, h2, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { width: 20px; height: 20px; flex: none; }
:focus-visible { outline: 2px solid var(--acento); outline-offset: 2px; }

/* Barras de desplazamiento finas y del color del tema */
* { scrollbar-width: thin; scrollbar-color: var(--barra) transparent; }
@supports not (scrollbar-color: auto) {
  ::-webkit-scrollbar { width: 10px; height: 10px; }
  ::-webkit-scrollbar-track { background: transparent; }
  ::-webkit-scrollbar-thumb { background: var(--barra); border-radius: 10px; border: 3px solid transparent; background-clip: content-box; }
  ::-webkit-scrollbar-thumb:hover { background-color: var(--barra-activa); }
  ::-webkit-scrollbar-corner { background: transparent; }
}
.tenue { color: var(--tenue); font-size: 0.82rem; }
.error { color: var(--error); min-height: 1.3em; }
.enlace { border: 0; background: none; padding: 0; color: var(--tenue); text-decoration: underline; font-size: 0.82rem; }
.enlace:hover { color: var(--texto); }
.boton { border: 1px solid var(--borde); background: var(--panel); border-radius: 10px; padding: 0.6rem 1rem; }
.boton.principal { background: var(--acento); color: var(--sobre-acento); border-color: var(--acento); font-weight: 600; }
.icono { display: grid; place-items: center; width: 36px; height: 36px; border: 0; background: none; border-radius: 10px; color: var(--tenue); cursor: pointer; }
.icono:hover { background: var(--burbuja); color: var(--texto); }

/* ---------- Acceso ---------- */
.acceso { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.tarjeta-acceso { display: grid; gap: 0.9rem; width: min(360px, 100%); background: var(--panel); border: 1px solid var(--borde); border-radius: 18px; padding: 2rem 1.6rem; box-shadow: var(--sombra); text-align: center; }
.tarjeta-acceso h1 { font: 600 1.9rem/1.1 ui-serif, Georgia, serif; }
.tarjeta-acceso label { display: grid; gap: 0.3rem; text-align: left; font-size: 0.88rem; }
.tarjeta-acceso input { width: 100%; border: 1px solid var(--borde); background: var(--fondo); border-radius: 10px; padding: 0.6rem 0.7rem; }
.marca-grande { width: 56px; height: 56px; margin: 0 auto; animation: mecer 4s ease-in-out infinite; transform-origin: 50% 85%; }

/* ---------- Estructura ---------- */
.app { height: 100%; display: grid; grid-template-columns: 272px 1fr; }
.lateral { display: flex; flex-direction: column; gap: 4px; background: var(--lateral); border-right: 1px solid var(--borde); padding: 12px 10px; min-height: 0; }
.lateral-cabecera { display: flex; align-items: center; gap: 8px; padding: 4px 8px 12px; font: 600 1.25rem ui-serif, Georgia, serif; }
.marca { width: 26px; height: 26px; }
.fila-accion { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: none; border-radius: 10px; padding: 0.55rem 0.6rem; text-align: left; }
.fila-accion:hover { background: var(--burbuja); }
.buscador { display: flex; align-items: center; gap: 8px; border: 1px solid var(--borde); background: var(--panel); border-radius: 10px; padding: 0 0.6rem; color: var(--tenue); margin: 4px 0 8px; }
.buscador input { border: 0; background: none; outline: 0; padding: 0.5rem 0; width: 100%; }
.rotulo { color: var(--tenue); font-size: 0.78rem; padding: 6px 10px 2px; }
.lista-chats { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 1px; min-height: 0; scrollbar-color: transparent transparent; }
.lista-chats:hover, .lista-chats:focus-within { scrollbar-color: var(--barra) transparent; }
@supports not (scrollbar-color: auto) {
  .lista-chats::-webkit-scrollbar-thumb { background-color: transparent; }
  .lista-chats:hover::-webkit-scrollbar-thumb, .lista-chats:focus-within::-webkit-scrollbar-thumb { background-color: var(--barra); }
  .lista-chats::-webkit-scrollbar-thumb:hover { background-color: var(--barra-activa); }
}
.fila-chat { display: flex; align-items: center; border-radius: 9px; flex: none; }
.fila-chat:hover, .fila-chat:focus-within, .fila-chat.con-menu { background: var(--burbuja); }
.fila-chat[aria-current="true"] { background: var(--panel); box-shadow: inset 0 0 0 1px var(--borde); }
.fila-chat .titulo { flex: 1; min-width: 0; border: 0; background: none; padding: 0.45rem 0.2rem 0.45rem 0.6rem; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fila-chat .puntos { display: grid; place-items: center; width: 30px; height: 30px; margin-right: 3px; border: 0; background: none; border-radius: 8px; color: var(--tenue); opacity: 0; flex: none; }
.fila-chat:hover .puntos, .fila-chat:focus-within .puntos, .fila-chat.con-menu .puntos { opacity: 1; }
.fila-chat .puntos:hover { background: color-mix(in srgb, var(--texto) 10%, transparent); color: var(--texto); }
.fila-chat input { flex: 1; min-width: 0; margin: 3px; border: 1px solid var(--acento); background: var(--panel); border-radius: 7px; padding: 0.3rem 0.45rem; outline: 0; }
.fila-chat.saliendo { animation: irse 0.22s ease-in forwards; }
@keyframes irse { to { opacity: 0; transform: translateX(-14px); } }

.menu { position: fixed; z-index: 30; min-width: 190px; background: var(--panel); border: 1px solid var(--borde); border-radius: 12px; box-shadow: var(--sombra); padding: 5px; display: grid; gap: 1px; animation: aparecer 0.12s ease-out both; }
.menu button { display: flex; align-items: center; gap: 10px; border: 0; background: none; border-radius: 8px; padding: 0.5rem 0.6rem; text-align: left; }
.menu button:hover, .menu button:focus-visible { background: var(--burbuja); outline: 0; }
.menu svg { width: 17px; height: 17px; color: var(--tenue); }
.peligro, .menu .peligro svg { color: var(--error); }
.boton.peligro { background: var(--error); border-color: var(--error); color: var(--fondo); font-weight: 600; }

.dialogo { border: 1px solid var(--borde); border-radius: 16px; background: var(--panel); color: var(--texto); padding: 1.3rem 1.4rem; width: min(420px, calc(100vw - 32px)); box-shadow: var(--sombra); }
.dialogo::backdrop { background: rgb(0 0 0 / 0.4); }
.dialogo h3 { margin: 0 0 0.5rem; font-size: 1.05rem; }
.dialogo p { color: var(--tenue); overflow-wrap: anywhere; }
.dialogo p.error { color: var(--error); }
.dialogo strong { color: var(--texto); }
.acciones { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; margin-top: 1.1rem; }
.casilla { display: flex; align-items: center; gap: 8px; font-size: 0.88rem; color: var(--tenue); margin-top: 0.4rem; }
.lista-chats .nada { color: var(--tenue); font-size: 0.85rem; padding: 0.4rem 0.6rem; }
.lateral-pie { display: flex; align-items: center; gap: 10px; border-top: 1px solid var(--borde); padding: 10px 6px 2px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--acento); color: var(--sobre-acento); display: grid; place-items: center; font-weight: 600; flex: none; }
.cuenta { min-width: 0; flex: 1; }
.cuenta-correo { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 0.88rem; }

.principal { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.cabecera { display: flex; align-items: center; gap: 8px; min-height: 52px; padding: 8px 16px; }
.cabecera h2 { font-size: 0.98rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.solo-movil { display: none; }

.lienzo { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.bienvenida { display: none; }
.lienzo.vacio { justify-content: center; padding-bottom: 12vh; }
.lienzo.vacio .bienvenida { display: block; text-align: center; padding: 0 16px 28px; }
.lienzo.vacio .mensajes { display: none; }
.bienvenida h1 { display: inline-flex; align-items: center; gap: 14px; font: 400 clamp(1.7rem, 4vw, 2.5rem)/1.15 ui-serif, Georgia, serif; text-wrap: balance; }
.bienvenida .marca { width: 40px; height: 40px; animation: mecer 4s ease-in-out infinite; transform-origin: 50% 85%; }

/* ---------- Conversación ---------- */
.mensajes { flex: 1; overflow-y: auto; padding: 12px 16px 24px; display: flex; flex-direction: column; gap: 14px; scroll-behavior: smooth; }
.msg { width: 100%; max-width: var(--ancho-texto); margin: 0 auto; overflow-wrap: anywhere; animation: aparecer 0.25s ease-out both; }
.msg.usuario { display: flex; justify-content: flex-end; }
.sugerencias-google { display: block; width: 100%; height: 52px; border: 0; border-radius: 10px; }
.msg.usuario > div { max-width: 85%; background: var(--burbuja); border-radius: 18px 18px 4px 18px; padding: 0.6rem 0.95rem; white-space: pre-wrap; }
.msg.texto > :first-child { margin-top: 0; }
.msg.texto > :last-child { margin-bottom: 0; }
.msg.texto h1, .msg.texto h2, .msg.texto h3 { font-size: 1.05rem; margin: 1.1em 0 0.4em; }
.msg.texto pre { overflow-x: auto; background: var(--panel); border: 1px solid var(--borde); border-radius: 10px; padding: 0.8rem; font-size: 0.85rem; }
.msg.texto code { font-family: ui-monospace, Consolas, monospace; font-size: 0.9em; background: var(--burbuja); border-radius: 5px; padding: 0.05em 0.3em; }
.msg.texto pre code { background: none; padding: 0; }
.msg.texto table { border-collapse: collapse; display: block; overflow-x: auto; font-size: 0.9rem; margin: 0.7em 0; }
.msg.texto p { margin: 0.6em 0; }
.msg.texto th, .msg.texto td { border: 1px solid var(--borde); padding: 0.35rem 0.7rem; text-align: left; }
.msg.texto th { background: var(--burbuja); }
.msg.texto a { color: var(--acento); }
.msg.aviso { color: var(--aviso); font-size: 0.84rem; text-align: center; }
/* Sin el min-height de .error, que deja encoger la caja dentro de la columna flex. */
.msg.error { min-height: auto; color: var(--error); background: color-mix(in srgb, var(--error) 9%, transparent); border-radius: 10px; padding: 0.5rem 0.8rem; }
.msg.fin { color: var(--tenue); font-size: 0.74rem; }
/* Segunda opinión: la revisión de otro modelo se distingue de la respuesta del chat. */
.msg.texto.revision { border-left: 3px solid var(--ambar); padding-left: 0.9rem; }
.cabecera-revision { color: var(--tenue); font-size: 0.78rem; font-weight: 600; margin-bottom: 0.4rem; }
.acciones-revision { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.desglose summary { cursor: pointer; width: fit-content; list-style: none; }
.desglose summary::-webkit-details-marker { display: none; }
.desglose summary:hover { color: var(--texto); text-decoration: underline; }
.desglose table { border-collapse: collapse; margin: 0.4rem 0; font-variant-numeric: tabular-nums; }
.desglose th, .desglose td { border-bottom: 1px solid var(--borde); padding: 0.2rem 0.7rem 0.2rem 0; text-align: right; font-weight: 400; }
.desglose th:first-child, .desglose td:first-child { text-align: left; }
.desglose th { color: var(--tenue); }
.desglose p { margin: 0.2rem 0 0; }

/* Actividad del agente: pasos agrupados y plegados */
.actividad { border: 1px solid var(--borde); border-radius: 12px; background: var(--panel); font-size: 0.86rem; }
.actividad summary { display: flex; align-items: center; gap: 10px; padding: 0.5rem 0.75rem; cursor: pointer; list-style: none; color: var(--tenue); }
.actividad summary::-webkit-details-marker { display: none; }
.actividad .ultimo { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--texto); }
.actividad .cuantos { flex: none; font-size: 0.78rem; }
.actividad .giro { width: 16px; height: 16px; transition: transform 0.15s; }
.actividad[open] .giro { transform: rotate(90deg); }
.actividad .punto { width: 9px; height: 9px; border-radius: 50%; background: var(--borde); flex: none; }
.actividad.viva .punto { background: var(--ambar); animation: latir 1.1s ease-in-out infinite; }
.actividad.viva .ultimo { background: linear-gradient(90deg, var(--texto) 30%, var(--tenue) 50%, var(--texto) 70%) 0 0 / 200% 100%; -webkit-background-clip: text; background-clip: text; color: transparent; animation: brillo 1.8s linear infinite; }
.actividad ol { margin: 0; padding: 0.2rem 0.75rem 0.6rem 2.2rem; color: var(--tenue); font-family: ui-monospace, Consolas, monospace; font-size: 0.8rem; display: grid; gap: 2px; }
.actividad li.sub { margin-left: 1rem; opacity: 0.8; }

/* Entregable generado */
.entregable { display: flex; align-items: center; gap: 12px; width: fit-content; max-width: 100%; border: 1px solid var(--borde); background: var(--panel); border-radius: 12px; padding: 0.6rem 0.8rem; text-align: left; transition: transform 0.12s, box-shadow 0.12s; }
.entregable:hover { transform: translateY(-1px); box-shadow: var(--sombra); }
.entregable .tipo { width: 36px; height: 36px; border-radius: 9px; background: var(--acento-suave); color: var(--acento); display: grid; place-items: center; }
.entregable .nombre { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entregable .bajar { color: var(--acento); }

/* ---------- Espera: el barquito ---------- */
.pensando { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; color: var(--tenue); }
.pensando .silencio { flex-basis: 100%; padding-left: 72px; font-size: 0.85em; }
.mar { position: relative; width: 58px; height: 40px; overflow: hidden; border-radius: 10px; flex: none; }
.barquito { position: absolute; left: 13px; top: 2px; width: 32px; height: 32px; transform-origin: 50% 85%; animation: navegar 2.4s ease-in-out infinite; }
.olas { position: absolute; left: 0; bottom: 0; width: 200%; height: 12px; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 12'%3E%3Cpath d='M0 6q5-6 10 0t10 0 10 0 10 0v6H0z' fill='%235f9fbd'/%3E%3C/svg%3E") repeat-x 0 0 / 40px 12px; animation: oleaje 1.6s linear infinite; }
.olas.lejos { bottom: 3px; opacity: 0.4; animation-duration: 2.6s; animation-direction: reverse; }
.frase { font-style: italic; animation: aparecer 0.4s ease-out both; }
.frase::after { content: ""; display: inline-block; width: 1.2em; text-align: left; animation: puntos 1.4s steps(4, end) infinite; }

@keyframes navegar { 0%, 100% { transform: translateY(1px) rotate(-7deg); } 50% { transform: translateY(-3px) rotate(7deg); } }
@keyframes mecer { 0%, 100% { transform: rotate(-4deg); } 50% { transform: rotate(4deg); } }
@keyframes oleaje { to { transform: translateX(-40px); } }
@keyframes puntos { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75%, 100% { content: "..."; } }
@keyframes latir { 0%, 100% { transform: scale(0.8); opacity: 0.6; } 50% { transform: scale(1.25); opacity: 1; } }
@keyframes brillo { to { background-position: -200% 0; } }
@keyframes aparecer { from { opacity: 0; transform: translateY(6px); } }
@keyframes subiendo { to { background-position: -200% 0; } }

/* ---------- Redactor ---------- */
.zona-redactor { width: 100%; max-width: calc(var(--ancho-texto) + 32px); margin: 0 auto; padding: 0 16px 10px; }
.redactor { background: var(--panel); border: 1px solid var(--borde); border-radius: 22px; box-shadow: var(--sombra); padding: 10px 10px 8px 14px; transition: border-color 0.15s; }
.redactor:focus-within { border-color: color-mix(in srgb, var(--acento) 55%, var(--borde)); }
.redactor textarea { display: block; width: 100%; border: 0; outline: 0; background: none; resize: none; max-height: 40vh; padding: 6px 2px 8px; line-height: 1.5; }
.redactor-barra { display: flex; align-items: center; gap: 6px; margin-left: -6px; }
.hueco { flex: 1; }
.pastilla { display: inline-flex; align-items: center; gap: 6px; height: 34px; border: 1px solid var(--borde); background: none; border-radius: 99px; padding: 0 0.75rem; font-size: 0.86rem; color: var(--tenue); }
.pastilla svg { width: 17px; height: 17px; }
.pastilla:hover:not(:disabled) { background: var(--burbuja); color: var(--texto); }
.pastilla[aria-pressed="true"] { background: var(--acento-suave); border-color: var(--acento); color: var(--acento); }
.selector { appearance: none; padding-right: 1.7rem; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M7 10l5 5 5-5' fill='none' stroke='%238a857b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 0.5rem center / 16px; cursor: pointer; }
.selector:disabled { border-color: transparent; background-image: none; padding-right: 0.75rem; cursor: default; opacity: 1; }
.selector option { background: var(--panel); color: var(--texto); }
.redondo { display: grid; place-items: center; width: 36px; height: 36px; border: 0; border-radius: 50%; background: var(--acento); color: var(--sobre-acento); transition: transform 0.1s, opacity 0.15s; }
.redondo:hover:not(:disabled) { transform: scale(1.06); }
.redondo:disabled { opacity: 0.35; cursor: default; }
.redondo.parar { background: var(--texto); color: var(--fondo); animation: latir-suave 1.4s ease-in-out infinite; }
@keyframes latir-suave { 50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--texto) 14%, transparent); } }

.ficheros { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 4px 8px; }
.ficha { display: inline-flex; align-items: center; gap: 6px; max-width: 240px; border: 1px solid var(--borde); background: var(--panel); border-radius: 10px; padding: 0.25rem 0.6rem; font-size: 0.82rem; }
.ficha span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ficha svg { width: 15px; height: 15px; color: var(--tenue); }
.ficha.agente { border-color: color-mix(in srgb, var(--acento) 50%, var(--borde)); }
.ficha.agente svg { color: var(--acento); }
.ficha.subiendo { background: linear-gradient(90deg, var(--panel) 30%, var(--acento-suave) 50%, var(--panel) 70%) 0 0 / 200% 100%; animation: subiendo 1.1s linear infinite; cursor: progress; }

.sugerencias { display: none; flex-wrap: wrap; justify-content: center; gap: 8px; padding-top: 16px; }
.lienzo.vacio .sugerencias { display: flex; }
.sugerencias button { border: 1px solid var(--borde); background: none; border-radius: 99px; padding: 0.4rem 0.9rem; font-size: 0.86rem; color: var(--tenue); transition: transform 0.12s, background 0.12s; }
.sugerencias button:hover { background: var(--panel); color: var(--texto); transform: translateY(-1px); }
.nota-pie { text-align: center; color: var(--tenue); font-size: 0.74rem; padding-top: 8px; }
.lienzo.vacio .nota-pie { display: none; }

/* ---------- Dictado ---------- */
.micro span:empty { display: none; }
.micro[data-estado="grabando"] { background: color-mix(in srgb, var(--error) 12%, transparent); border-color: var(--error); color: var(--error); font-variant-numeric: tabular-nums; animation: latir-rojo 1.2s ease-in-out infinite; }
.micro[data-estado="grabando"] span { display: inline; }
.micro[data-estado="transcribiendo"] { background: linear-gradient(90deg, transparent 30%, var(--acento-suave) 50%, transparent 70%) 0 0 / 200% 100%; animation: subiendo 1.1s linear infinite; opacity: 1; cursor: progress; }
@keyframes latir-rojo { 50% { box-shadow: 0 0 0 5px color-mix(in srgb, var(--error) 16%, transparent); } }

/* ---------- Visor de artefactos y documentos ---------- */
.app.con-visor { grid-template-columns: 272px minmax(0, 1fr) minmax(380px, 46%); }
.visor { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--panel); border-left: 1px solid var(--borde); animation: entrar-visor 0.22s ease-out both; }
@keyframes entrar-visor { from { opacity: 0; transform: translateX(24px); } }
.visor-cabecera { display: flex; align-items: center; gap: 6px; min-height: 52px; padding: 8px 10px 8px 16px; border-bottom: 1px solid var(--borde); }
.visor-cabecera strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pastilla.llena { background: var(--acento); border-color: var(--acento); color: var(--sobre-acento); font-weight: 600; }
.pastilla.llena:hover:not(:disabled) { background: var(--acento); color: var(--sobre-acento); filter: brightness(1.08); }
.visor-cuerpo { flex: 1; min-height: 0; overflow: auto; display: flex; flex-direction: column; }
.visor-marco { flex: 1; width: 100%; border: 0; background: #fff; }
.visor-imagen { max-width: 100%; margin: auto; padding: 16px; }
.visor-hoja { padding: 20px 24px 40px; max-width: none; margin: 0; }
.visor-pre { margin: 0; padding: 16px 20px; font: 0.85rem/1.55 ui-monospace, Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.visor-codigo { flex: 1; width: 100%; border: 0; outline: 0; resize: none; background: var(--fondo); padding: 16px 20px; font: 0.85rem/1.55 ui-monospace, Consolas, monospace; tab-size: 2; }
.visor-aviso { margin: 0; padding: 0.45rem 16px; font-size: 0.82rem; color: var(--aviso); background: color-mix(in srgb, var(--ambar) 12%, transparent); border-bottom: 1px solid var(--borde); }
.visor-espera { margin: auto; display: grid; justify-items: center; gap: 10px; }
.visor-desliza { padding: 16px; overflow: auto; display: grid; gap: 12px; justify-items: start; }
.visor-tabla { border-collapse: collapse; font-size: 0.86rem; }
.visor-tabla th, .visor-tabla td { border: 1px solid var(--borde); padding: 0.3rem 0.6rem; text-align: left; min-width: 4.5rem; white-space: pre-wrap; vertical-align: top; }
.visor-tabla th { background: var(--burbuja); position: sticky; top: 0; }
.visor-tabla [contenteditable]:focus { outline: 2px solid var(--acento); outline-offset: -2px; background: var(--acento-suave); }
.ficha.visible, .entregable.visible { cursor: zoom-in; }

/* ---------- Navegación: proyectos y habilidades ---------- */
.fila-accion[aria-current="true"] { background: var(--panel); box-shadow: inset 0 0 0 1px var(--borde); }
.fila-accion svg { color: var(--tenue); }
.miga { border: 0; background: none; padding: 0.2rem 0.3rem; border-radius: 7px; color: var(--tenue); font-size: 0.98rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40%; flex: none; }
.miga:hover { background: var(--burbuja); color: var(--texto); }
.miga-sep { color: var(--borde); }
.con-icono, .boton.principal.con-icono { display: inline-flex; flex-direction: row; align-items: center; gap: 6px; }
.con-icono svg { width: 18px; height: 18px; }
label.boton { cursor: pointer; }

/* Vistas de lista */
.vista { flex: 1; min-height: 0; overflow-y: auto; padding: 8px 16px 48px; }
.vista-ancho { max-width: 880px; margin: 0 auto; }
.vista-cabecera { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; padding: 18px 0 14px; }
.vista-cabecera h1 { font: 400 clamp(1.6rem, 3.5vw, 2.1rem)/1.15 ui-serif, Georgia, serif; }
.acciones-vista { display: flex; flex-wrap: wrap; gap: 8px; }
.vista .buscador { margin: 0 0 16px; }
.explicacion { color: var(--tenue); max-width: 68ch; margin-bottom: 18px; }
.nada { color: var(--tenue); font-size: 0.88rem; }
.vacio-vista { grid-column: 1 / -1; display: grid; justify-items: center; gap: 8px; text-align: center; padding: 48px 16px; border: 1px dashed var(--borde); border-radius: 16px; color: var(--tenue); }
.vacio-vista svg { width: 32px; height: 32px; color: var(--acento); }
.vacio-vista strong { color: var(--texto); font-size: 1.05rem; }
.vacio-vista p { max-width: 46ch; }
.vacio-vista .boton { margin-top: 8px; }
.aviso-vista { margin: 0 0 12px; padding: 0.55rem 0.85rem; border-radius: 10px; background: var(--acento-suave); color: var(--acento); font-size: 0.9rem; animation: aparecer 0.2s ease-out both; }
.aviso-vista.error { background: color-mix(in srgb, var(--error) 10%, transparent); color: var(--error); }

.rejilla-proyectos { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.tarjeta-proyecto { display: flex; flex-direction: column; gap: 6px; min-height: 132px; text-align: left; border: 1px solid var(--borde); background: var(--panel); border-radius: 14px; padding: 14px 16px; transition: transform 0.12s, box-shadow 0.12s, border-color 0.12s; }
.tarjeta-proyecto:hover { transform: translateY(-1px); box-shadow: var(--sombra); border-color: color-mix(in srgb, var(--acento) 35%, var(--borde)); }
.tarjeta-proyecto strong { font-size: 1rem; overflow-wrap: anywhere; }
.tarjeta-proyecto .descripcion { flex: 1; color: var(--tenue); font-size: 0.88rem; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.tarjeta-proyecto .pie { color: var(--tenue); font-size: 0.78rem; }

/* Página de un proyecto: cabecera, redactor y chats a la izquierda; panel a la derecha */
.lienzo.en-proyecto { display: grid; grid-template-columns: minmax(0, 1fr) 300px; grid-template-areas: "cab cab" "red panel" "chats panel"; grid-template-rows: auto auto 1fr; align-content: start; column-gap: 28px; width: 100%; max-width: 1120px; margin: 0 auto; padding: 12px 24px 48px; overflow-y: auto; }
.lienzo.en-proyecto .bienvenida, .lienzo.en-proyecto .mensajes, .lienzo.en-proyecto .sugerencias, .lienzo.en-proyecto .nota-pie { display: none; }
.lienzo.en-proyecto .zona-redactor { grid-area: red; max-width: none; padding: 0 0 18px; }
.proyecto-cabecera { grid-area: cab; padding: 6px 0 18px; }
.volver { display: inline-flex; align-items: center; gap: 4px; border: 0; background: none; padding: 0.2rem 0.4rem 0.2rem 0.1rem; margin-left: -0.2rem; border-radius: 8px; color: var(--tenue); font-size: 0.86rem; }
.volver svg { width: 16px; height: 16px; }
.volver:hover { color: var(--texto); background: var(--burbuja); }
.proyecto-titulo { display: flex; align-items: center; gap: 6px; margin-top: 8px; }
.proyecto-titulo h1 { font: 400 clamp(1.6rem, 3.5vw, 2.2rem)/1.15 ui-serif, Georgia, serif; overflow-wrap: anywhere; }
.proyecto-descripcion { color: var(--tenue); margin-top: 6px; max-width: 70ch; white-space: pre-wrap; }
.proyecto-chats { grid-area: chats; min-width: 0; }
.proyecto-chats h3, .tarjeta h3 { margin: 0; font-size: 0.9rem; font-weight: 600; }
.proyecto-chats h3 { padding: 0 4px 8px; }
#proyecto-lista-chats { display: grid; border-top: 1px solid var(--borde); }
#proyecto-lista-chats .nada { padding: 14px 4px; }
.fila-proyecto-chat { display: flex; align-items: baseline; gap: 12px; width: 100%; border: 0; border-bottom: 1px solid var(--borde); background: none; padding: 0.75rem 0.5rem; text-align: left; }
.fila-proyecto-chat:hover { background: var(--burbuja); }
.fila-proyecto-chat .titulo { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fila-proyecto-chat .tenue { flex: none; }
.proyecto-panel { grid-area: panel; align-self: start; display: grid; gap: 12px; position: sticky; top: 0; }
.tarjeta { border: 1px solid var(--borde); background: var(--panel); border-radius: 14px; padding: 12px 14px 14px; display: grid; gap: 8px; }
.tarjeta header { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tarjeta .pastilla { height: 30px; font-size: 0.82rem; cursor: pointer; }
.instrucciones-resumen { font-size: 0.86rem; white-space: pre-wrap; display: -webkit-box; -webkit-line-clamp: 6; -webkit-box-orient: vertical; overflow: hidden; }
.instrucciones-resumen.vacio { color: var(--tenue); }
.proyecto-ficheros { display: grid; gap: 2px; max-height: 320px; overflow-y: auto; }
.proyecto-ficheros .nada { font-size: 0.84rem; padding: 4px 0; }
.fichero-proyecto { display: flex; align-items: center; gap: 6px; border-radius: 8px; padding-right: 2px; font-size: 0.85rem; }
.fichero-proyecto:hover { background: var(--burbuja); }
.fichero-proyecto .nombre { display: flex; align-items: center; gap: 6px; flex: 1; min-width: 0; border: 0; background: none; padding: 0.35rem 0.3rem; text-align: left; }
.fichero-proyecto .nombre span, .nombre-provisional { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fichero-proyecto svg { width: 16px; height: 16px; color: var(--tenue); }
.fichero-proyecto .peso { color: var(--tenue); font-size: 0.76rem; flex: none; }
.fichero-proyecto.subiendo { padding: 0.35rem 0.3rem; background: linear-gradient(90deg, transparent 30%, var(--acento-suave) 50%, transparent 70%) 0 0 / 200% 100%; animation: subiendo 1.1s linear infinite; cursor: progress; }
.icono.pequeno { width: 28px; height: 28px; border-radius: 7px; flex: none; opacity: 0; }
.icono.pequeno svg { width: 15px; height: 15px; }
.fichero-proyecto:hover .icono.pequeno, .icono.pequeno:focus-visible { opacity: 1; }
@media (hover: none) { .icono.pequeno { opacity: 1; } }
.uso { display: grid; gap: 4px; margin-top: 2px; }
.uso-barra { height: 5px; border-radius: 3px; background: var(--burbuja); overflow: hidden; }
.uso-barra span { display: block; height: 100%; width: 0; background: var(--acento); border-radius: 3px; transition: width 0.3s; }

/* Habilidades */
.lista-habilidades { display: grid; gap: 8px; }
.habilidad { display: flex; align-items: center; gap: 12px; border: 1px solid var(--borde); background: var(--panel); border-radius: 14px; padding: 10px 14px; transition: opacity 0.15s; }
.habilidad-icono { width: 36px; height: 36px; border-radius: 10px; background: var(--acento-suave); color: var(--acento); display: grid; place-items: center; flex: none; }
.habilidad.apagada .habilidad-icono { background: var(--burbuja); color: var(--tenue); }
.habilidad.apagada .habilidad-texto { opacity: 0.65; }
.habilidad-texto { flex: 1; min-width: 0; display: grid; gap: 2px; border: 0; background: none; padding: 2px 0; text-align: left; border-radius: 8px; }
.habilidad-texto:hover .habilidad-nombre { text-decoration: underline; }
.habilidad-nombre { font-family: ui-monospace, Consolas, monospace; font-size: 0.9rem; font-weight: 600; }
.habilidad-descripcion { color: var(--tenue); font-size: 0.86rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.interruptor { position: relative; display: inline-block; width: 40px; height: 24px; flex: none; cursor: pointer; }
.interruptor input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.interruptor .pista { position: absolute; inset: 0; border-radius: 99px; background: var(--borde); transition: background 0.15s; pointer-events: none; }
.interruptor .pista::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--panel); box-shadow: 0 1px 2px rgb(0 0 0 / 0.25); transition: transform 0.15s; }
.interruptor input:checked + .pista { background: var(--acento); }
.interruptor input:checked + .pista::after { transform: translateX(16px); }
.interruptor input:focus-visible + .pista { outline: 2px solid var(--acento); outline-offset: 2px; }

/* Formularios de los diálogos */
.dialogo.ancho { width: min(720px, calc(100vw - 32px)); }
.formulario { display: grid; gap: 12px; }
.formulario > h3 { margin-bottom: 0; }
.campo { display: grid; gap: 5px; font-size: 0.88rem; font-weight: 600; }
.campo .tenue { font-weight: 400; }
.campo[hidden] { display: none; }
.formulario input:not([type="radio"]):not([type="checkbox"]), .formulario textarea { width: 100%; border: 1px solid var(--borde); background: var(--fondo); border-radius: 10px; padding: 0.55rem 0.7rem; font-weight: 400; resize: vertical; }
.formulario input:not([type="radio"]):not([type="checkbox"]):focus, .formulario textarea:focus { outline: 0; border-color: var(--acento); box-shadow: 0 0 0 3px var(--acento-suave); }
.formulario textarea[readonly] { background: var(--panel); }
.campo-largo { min-height: 240px; max-height: 60vh; line-height: 1.5; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 0.85rem; }
.contador { text-align: right; margin-top: -6px; }
.formulario .error { min-height: 0; }
.formulario .error:empty { display: none; }
.formulario .acciones { margin-top: 4px; align-items: center; }
.boton.peligro-suave { color: var(--error); border-color: color-mix(in srgb, var(--error) 40%, var(--borde)); }
.boton.peligro-suave:hover { background: color-mix(in srgb, var(--error) 8%, transparent); }
.boton:disabled { opacity: 0.6; cursor: progress; }

/* Compartir, memoria y mover chats */
.menu button[hidden] { display: none; }
.etiqueta { display: inline-flex; align-items: center; gap: 4px; padding: 0.05rem 0.5rem; border-radius: 99px; background: var(--burbuja); color: var(--tenue); font: 500 0.72rem/1.6 system-ui, sans-serif; white-space: nowrap; vertical-align: middle; }
.etiqueta svg { width: 13px; height: 13px; }
.tarjeta h3 .etiqueta { margin-left: 4px; }
.tarjeta-titulo { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.tarjeta-titulo .etiqueta { flex: none; max-width: 55%; overflow: hidden; text-overflow: ellipsis; }
.proyecto-titulo .hueco { flex: 1; }
.proyecto-titulo .pastilla svg { width: 17px; height: 17px; }
.proyecto-acceso { display: inline-flex; color: var(--tenue); font-size: 0.86rem; margin-top: 4px; }
.fila-interruptor { display: flex; align-items: center; gap: 10px; font-size: 0.9rem; cursor: pointer; }
.fila-compartir { display: flex; gap: 8px; flex-wrap: wrap; }
.fila-compartir input { flex: 1 1 220px; }
.formulario select, .miembro select { border: 1px solid var(--borde); background: var(--fondo); color: var(--texto); border-radius: 10px; padding: 0.5rem 0.6rem; font: inherit; }
.lista-miembros { display: grid; border-top: 1px solid var(--borde); }
.miembro { display: flex; align-items: center; gap: 8px; padding: 0.5rem 0; border-bottom: 1px solid var(--borde); min-height: 52px; }
.miembro .correo { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.miembro select { padding: 0.35rem 0.5rem; font-size: 0.86rem; }
.icono.pequeno.visible { opacity: 1; }
.lista-mover { display: grid; gap: 4px; max-height: 50vh; overflow-y: auto; }
.opcion-mover { display: flex; align-items: center; gap: 10px; padding: 0.55rem 0.7rem; border: 1px solid var(--borde); border-radius: 10px; cursor: pointer; }
.opcion-mover:has(input:checked) { border-color: var(--acento); background: var(--acento-suave); }
.opcion-mover input { accent-color: var(--acento); margin: 0; }
.opcion-mover .textos { display: grid; min-width: 0; }
.opcion-mover .textos span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Habilidades: propias y de la organización */
.seccion-habilidades { margin-bottom: 28px; }
.seccion-cabecera { display: flex; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-bottom: 12px; }
.seccion-cabecera h2 { font-size: 1.1rem; font-weight: 600; margin-bottom: 2px; }
.vacio-vista.pequeno { padding: 20px 16px; }
.habilidad-nombre .etiqueta { margin-left: 8px; font-family: system-ui, sans-serif; }

@media (max-width: 900px) {
  .lienzo.en-proyecto { grid-template-columns: minmax(0, 1fr); grid-template-areas: "cab" "red" "panel" "chats"; padding: 8px 16px 40px; }
  .proyecto-panel { position: static; margin-bottom: 20px; }
}

/* ---------- Móvil ---------- */
.velo { position: fixed; inset: 0; background: rgb(0 0 0 / 0.35); z-index: 9; }
@media (hover: none) { .fila-chat .puntos { opacity: 1; } }
@media (max-width: 1100px) {
  .app.con-visor { grid-template-columns: 272px minmax(0, 1fr); }
  .visor { position: fixed; inset: 0 0 0 auto; width: min(720px, 100%); z-index: 20; box-shadow: var(--sombra); }
}
@media (max-width: 800px) {
  .app, .app.con-visor { grid-template-columns: 1fr; }
  .solo-movil { display: grid; }
  .lateral { position: fixed; inset: 0 auto 0 0; width: min(290px, 86vw); z-index: 10; transform: translateX(-102%); transition: transform 0.22s ease; box-shadow: var(--sombra); }
  .lateral.abierto { transform: none; }
  .pastilla span { display: none; }
  .pastilla { padding: 0 0.55rem; }
}
@media (min-width: 801px) { .velo { display: none !important; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001s !important; animation-iteration-count: 1 !important; transition: none !important; scroll-behavior: auto !important; }
  .frase::after { content: "…"; }
}

/* Acceso, cuenta y usuarios */
.codigo { text-align: center; font-size: 1.2rem; letter-spacing: 0.35em; font-variant-numeric: tabular-nums; }
.tarjeta-acceso .pequeno { font-size: 0.82rem; }
.tarjeta-acceso .enlace { justify-self: center; min-height: 28px; }
.abrir-cuenta { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; border: 0; background: none; border-radius: 10px; padding: 4px; text-align: left; }
.abrir-cuenta:hover { background: var(--burbuja); }
.abrir-cuenta .cuenta > span { display: block; }
.cuenta-secciones { display: grid; }
.cuenta-secciones section { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 0.8rem 0; border-top: 1px solid var(--borde); }
.cuenta-secciones section > div { min-width: 0; overflow-wrap: anywhere; }
.cuenta-secciones p { font-size: 0.88rem; margin-top: 3px; }
.cuenta-secciones .pastilla { flex: none; }
.cuenta-secciones .pastilla:disabled, .usuario .pastilla:disabled { opacity: 0.5; cursor: not-allowed; }
.etiqueta.activa { background: var(--acento-suave); color: var(--acento); }
.qr { width: 210px; height: 210px; justify-self: center; border-radius: 10px; background: #fff; image-rendering: pixelated; }
.clave-manual { display: block; margin-top: 4px; font: 0.92rem/1.5 ui-monospace, Consolas, monospace; color: var(--texto); user-select: all; overflow-wrap: anywhere; }
.form-invitar { margin-bottom: 18px; }
.lista-usuarios { display: grid; border-top: 1px solid var(--borde); }
.usuario { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 16px; padding: 0.7rem 0; border-bottom: 1px solid var(--borde); }
.usuario-datos { min-width: 0; flex: 1 1 280px; font-size: 0.86rem; }
.usuario-correo { font-size: 0.95rem; overflow-wrap: anywhere; }
.usuario-correo .etiqueta { margin-left: 6px; }
.usuario.inactivo .usuario-datos { opacity: 0.6; }
.usuario .pastilla { height: 32px; font-size: 0.82rem; }
.formulario .campo-credito { display: flex; align-items: center; gap: 6px; font-size: 0.88rem; }
.formulario .campo-credito #credito-invitar { width: 96px; flex: none; text-align: right; }
.usuario-saldo { font-variant-numeric: tabular-nums; }
.usuario-saldo.agotado { color: var(--error); }
#resumen-credito { margin-bottom: 8px; font-size: 0.88rem; }
.cifras { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 0; }
.cifras div { border: 1px solid var(--borde); border-radius: 10px; padding: 0.5rem 0.7rem; }
.cifras dt { color: var(--tenue); font-size: 0.78rem; }
.cifras dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.movimientos { display: grid; max-height: 180px; overflow-y: auto; font-size: 0.84rem; }
.movimiento { display: flex; gap: 10px; padding: 0.3rem 0; border-top: 1px solid var(--borde); }
.movimiento .importe { flex: 0 0 84px; text-align: right; font-variant-numeric: tabular-nums; }
.movimiento .tenue { min-width: 0; overflow-wrap: anywhere; }
