/* Estudio Paikan en el teléfono: como una app del iPhone, con lugar para el pulgar. */
:root {
  --fondo: #f2f2f7; --tarjeta: #ffffff; --texto: #1c1c1e; --suave: #6e6e73; --linea: #d1d1d6;
  --acento: #0a66d8; --peligro: #d70015; --bien: #248a3d;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --fondo: #000000; --tarjeta: #1c1c1e; --texto: #f2f2f7; --suave: #98989f; --linea: #38383a; --acento: #3b8cff; --peligro: #ff453a; --bien: #30d158; }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--fondo); color: var(--texto); }
body { font: 17px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; -webkit-text-size-adjust: 100%; }
main { min-height: 100dvh; padding: env(safe-area-inset-top) 0 calc(76px + env(safe-area-inset-bottom)); }

.barra { position: sticky; top: 0; z-index: 2; padding: 12px 16px 8px; background: color-mix(in srgb, var(--fondo) 88%, transparent); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); }
.barra h1 { margin: 0; font-size: 32px; font-weight: 700; letter-spacing: -0.5px; }
.volver { border: 0; background: none; color: var(--acento); font: inherit; font-size: 17px; padding: 8px 0; min-height: 44px; }

.lista { padding: 4px 16px 16px; display: grid; gap: 10px; }
.tarjeta { display: block; width: 100%; text-align: left; border: 0; border-radius: 14px; background: var(--tarjeta); color: inherit; font: inherit; padding: 14px; }
.tarjeta:active { opacity: 0.7; }
.cabeza { display: flex; gap: 10px; align-items: center; }
.cabeza strong { display: block; font-size: 17px; }
.cabeza small { display: block; color: var(--suave); font-size: 14px; }
.foto { width: 40px; height: 40px; border-radius: 50%; flex: none; object-fit: cover; }
.foto.inicial { display: grid; place-items: center; background: var(--linea); color: var(--suave); font-size: 15px; font-weight: 600; }
.tema { margin: 10px 0 2px; font-weight: 600; }
.pedido { margin: 0; color: var(--suave); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-line; }
.vacio { text-align: center; color: var(--suave); margin-top: 30vh; }

.detalle { padding: 4px 16px 32px; }
.detalle h2 { font-size: 22px; margin: 16px 0 6px; }
.detalle h3 { font-size: 15px; text-transform: uppercase; letter-spacing: 0.3px; color: var(--suave); margin: 26px 0 8px; font-weight: 600; }
.texto { white-space: pre-line; background: var(--tarjeta); border-radius: 12px; padding: 12px 14px; margin: 8px 0; }
details { margin: 10px 0; } summary { color: var(--acento); padding: 6px 0; }
.nota { color: var(--suave); font-size: 15px; margin: 4px 0 10px; }

textarea, select, input { width: 100%; font: inherit; color: inherit; background: var(--tarjeta); border: 1px solid var(--linea); border-radius: 12px; padding: 12px; }
textarea { resize: vertical; min-height: 110px; }
select { min-height: 48px; -webkit-appearance: none; appearance: none; padding-right: 36px; background: var(--tarjeta) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%238e8e93' stroke-width='2'/%3E%3C/svg%3E") no-repeat right 14px center; }
.fila { display: flex; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.fila > * { flex: 1 1 140px; }

.boton { min-height: 50px; border: 0; border-radius: 12px; background: var(--acento); color: #fff; font: inherit; font-weight: 600; padding: 0 16px; }
.boton.secundario { background: var(--tarjeta); color: var(--acento); border: 1px solid var(--linea); }
.boton.peligro { background: none; color: var(--peligro); margin-top: 18px; }
.boton.ancho { width: 100%; }
.boton.grande { width: 100%; font-size: 19px; min-height: 56px; margin-top: 28px; }
.boton:active { opacity: 0.7; }

.pestanas { position: fixed; bottom: 0; left: 0; right: 0; z-index: 3; display: flex; border-top: 1px solid var(--linea); background: color-mix(in srgb, var(--fondo) 88%, transparent); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); padding-bottom: env(safe-area-inset-bottom); }
.pestana { flex: 1; min-height: 58px; border: 0; background: none; color: var(--suave); font: inherit; font-size: 15px; font-weight: 600; display: flex; align-items: center; justify-content: center; gap: 6px; }
.pestana.activa { color: var(--acento); }
.globo { background: var(--peligro); color: #fff; border-radius: 10px; font-size: 13px; min-width: 20px; padding: 1px 6px; }

.portada { padding: 18vh 28px 0; text-align: center; }
.logo { width: 84px; height: 84px; border-radius: 20px; }
.portada h1 { margin: 16px 0 8px; }
.campo { display: block; text-align: left; color: var(--suave); font-size: 15px; margin-top: 24px; }
.campo input { margin-top: 6px; }
.error { color: var(--peligro); min-height: 1.4em; }

.ocupado, .aviso { position: fixed; left: 16px; right: 16px; bottom: calc(72px + env(safe-area-inset-bottom)); z-index: 4; border-radius: 14px; padding: 14px 16px; background: var(--texto); color: var(--fondo); display: flex; gap: 10px; align-items: center; box-shadow: 0 6px 24px rgb(0 0 0 / 0.2); }
.aviso.malo { background: var(--peligro); color: #fff; }
.rueda { width: 18px; height: 18px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: girar 0.8s linear infinite; }
@keyframes girar { to { transform: rotate(360deg); } }

/* Sesiones */
.barra.con-boton { display: flex; align-items: center; justify-content: space-between; }
.mas { width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--acento); color: #fff; font-size: 26px; line-height: 1; }
.grupo { font-size: 15px; text-transform: uppercase; letter-spacing: 0.3px; color: var(--suave); margin: 14px 4px 0; font-weight: 600; }
.pedido.urgente { color: #ff9f0a; font-weight: 600; }

/* Chat */
.chat { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
.barra.chica { display: flex; align-items: center; gap: 8px; padding: 6px 12px; border-bottom: 1px solid var(--linea); }
.barra.chica .volver { font-size: 17px; flex: none; padding: 8px 4px; }
.barra.chica .volver:first-child { font-size: 30px; line-height: 1; }
.titulo { flex: 1; min-width: 0; text-align: center; }
.titulo strong, .titulo small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.titulo small { color: var(--suave); font-size: 13px; }
.pedido-chat { margin: 10px 16px 0; }
#hilo { display: flex; flex-direction: column; gap: 8px; padding: 12px; }
.vacio.chico { margin-top: 20vh; }
.burbuja { max-width: 86%; padding: 9px 13px; border-radius: 18px; background: var(--tarjeta); overflow-wrap: anywhere; }
.burbuja small { display: block; color: var(--suave); font-size: 12px; font-weight: 600; margin-bottom: 2px; }
.burbuja.yo { align-self: flex-end; background: var(--acento); color: #fff; }
.burbuja.claude, .burbuja.cliente { align-self: flex-start; }
.burbuja.cliente { border: 1px solid #ff9f0a; }
.burbuja.enviado { align-self: flex-end; background: color-mix(in srgb, var(--bien) 18%, var(--tarjeta)); }
.md { white-space: pre-wrap; }
.md pre { white-space: pre-wrap; font-size: 13px; background: color-mix(in srgb, var(--texto) 8%, transparent); padding: 8px; border-radius: 8px; margin: 6px 0; }
.md code { font-size: 14px; background: color-mix(in srgb, var(--texto) 8%, transparent); padding: 1px 4px; border-radius: 4px; }
.pasos { font-size: 14px; color: var(--suave); margin: 2px 0 6px; }
.pasos summary { padding: 2px 0; }
.pasos ol { margin: 4px 0; padding-left: 20px; }
#vivo, #borrador { padding: 0 12px; }
.vivo { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 14px; background: var(--tarjeta); color: var(--suave); margin-bottom: 8px; }
.vivo .ahora { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.frenar { border: 0; background: var(--peligro); color: #fff; border-radius: 10px; font: inherit; font-size: 15px; font-weight: 600; padding: 8px 12px; }
.tarjeta-aviso { background: var(--tarjeta); border-radius: 14px; padding: 12px 14px; margin-bottom: 10px; border: 1px solid #ff9f0a; }
.tarjeta-aviso > p { margin: 0 0 10px; white-space: pre-line; }
.tarjeta-aviso h3:first-child { margin-top: 4px; }
.opcion { margin-top: 8px; text-align: left; }

.redactar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 3; padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); border-top: 1px solid var(--linea); background: color-mix(in srgb, var(--fondo) 92%, transparent); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); }
.fila-redactar { display: flex; align-items: flex-end; gap: 8px; }
.fila-redactar textarea { flex: 1; min-height: 40px; max-height: 160px; border-radius: 20px; padding: 9px 14px; resize: none; }
.clip, .enviar { flex: none; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-size: 20px; border: 0; }
.clip { background: var(--tarjeta); }
.enviar { background: var(--acento); color: #fff; font-size: 22px; font-weight: 700; }
#adjuntos { display: flex; gap: 8px; flex-wrap: wrap; }
#adjuntos:not(:empty) { margin-bottom: 8px; }
.miniatura { position: relative; width: 56px; height: 56px; border-radius: 10px; overflow: hidden; background: var(--tarjeta); display: grid; place-items: center; }
.miniatura img { width: 100%; height: 100%; object-fit: cover; }
.miniatura button { position: absolute; top: 2px; right: 2px; width: 22px; height: 22px; border-radius: 50%; border: 0; background: rgb(0 0 0 / 0.6); color: #fff; font-size: 14px; line-height: 1; }
.chat ~ #capas .ocupado, .chat ~ #capas .aviso { bottom: calc(70px + env(safe-area-inset-bottom)); }
