/* Mesa Digital · Onboarding de clientes. Mobile first, sobrio, claro. Sin fuentes ni recursos externos (CSP estricta). */
:root {
  --bg: #f6f5f2; --panel: #ffffff; --ink: #1d2a2a; --ink-2: #4a5656; --muted: #7b8686; --line: #e4e2dc; --accent: #1d2a2a; --accent-ink: #f6f5f2;
  --soft: #efede7; --ok: #2f6b4f; --warn: #9a6a1c; --bad: #a3392b;
  --radius: 14px; --gutter: 16px;
  --font: ui-sans-serif, -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--ink); font-family: var(--font); -webkit-text-size-adjust: 100%; }
body { min-height: 100vh; min-height: 100dvh; }
.app { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.noscript { padding: 24px; }
.boot { flex: 1; display: grid; place-items: center; }
.boot-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--ink); opacity: .25; animation: pulse 1s infinite ease-in-out; }
@keyframes pulse { 50% { opacity: .8; } }

/* Marca discreta */
.brand { display: flex; align-items: center; gap: 8px; font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.brand b { color: var(--ink); font-weight: 700; }
.brand i { font-style: normal; color: var(--muted); }

/* Pantallas de entrada / salida */
.screen { flex: 1; display: flex; flex-direction: column; justify-content: center; padding: calc(24px + env(safe-area-inset-top)) var(--gutter) calc(24px + env(safe-area-inset-bottom)); max-width: 560px; width: 100%; margin: 0 auto; gap: 22px; }
.screen h1 { font-size: 30px; line-height: 1.15; letter-spacing: -.02em; margin: 0; font-weight: 650; }
.screen p { margin: 0; font-size: 17px; line-height: 1.55; color: var(--ink-2); }
.screen .note { font-size: 14px; color: var(--muted); }
.btn { appearance: none; border: 0; border-radius: 12px; background: var(--accent); color: var(--accent-ink); font: inherit; font-size: 16px; font-weight: 600; padding: 15px 22px; cursor: pointer; letter-spacing: .02em; min-height: 52px; }
.btn:disabled { opacity: .45; cursor: default; }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn.small { font-size: 14px; padding: 10px 14px; min-height: 40px; }
.btn:focus-visible, .linkbtn:focus-visible, textarea:focus-visible, .iconbtn:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.linkbtn { background: none; border: 0; padding: 6px 0; font: inherit; font-size: 14px; color: var(--ink-2); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; text-align: left; }
.err-box { border: 1px solid var(--line); background: var(--panel); border-radius: var(--radius); padding: 18px; font-size: 16px; line-height: 1.5; }

/* Chat */
.chat { position: fixed; top: 0; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; min-height: 0; height: 100%; max-width: 720px; width: 100%; background: var(--bg); }
.chat-head { padding: calc(12px + env(safe-area-inset-top)) var(--gutter) 10px; border-bottom: 1px solid var(--line); background: var(--bg); flex: none; z-index: 3; }
.chat-head .row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.progress-line { margin-top: 10px; display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--ink-2); }
.progress-line .label { white-space: nowrap; }
.bar { flex: 1; height: 6px; background: var(--soft); border-radius: 99px; overflow: hidden; }
.bar > span { display: block; height: 100%; width: 0; background: var(--ink); border-radius: 99px; transition: width .5s ease; }
.pct { font-variant-numeric: tabular-nums; min-width: 38px; text-align: right; color: var(--ink); font-weight: 600; }
.cats { display: none; margin-top: 10px; grid-template-columns: repeat(2, 1fr); gap: 8px 14px; }
.cats.open { display: grid; }
.cat { font-size: 12px; color: var(--ink-2); }
.cat .bar { height: 4px; margin-top: 4px; }
.iconbtn { appearance: none; border: 1px solid var(--line); background: var(--panel); border-radius: 10px; width: 44px; height: 44px; display: grid; place-items: center; cursor: pointer; color: var(--ink); flex: none; }
.iconbtn svg { width: 20px; height: 20px; }

.stream { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; padding: 18px var(--gutter) 12px; display: flex; flex-direction: column; gap: 12px; scroll-behavior: smooth; }
.msg { max-width: 88%; font-size: 16.5px; line-height: 1.5; border-radius: 16px; padding: 12px 14px; overflow-wrap: anywhere; }
.msg p { margin: 0 0 9px; } .msg p:last-child { margin-bottom: 0; }
.msg.assistant { align-self: flex-start; background: var(--panel); border: 1px solid var(--line); border-top-left-radius: 6px; }
.msg.client { align-self: flex-end; background: var(--accent); color: var(--accent-ink); border-top-right-radius: 6px; white-space: pre-wrap; }
.msg.system { align-self: center; background: var(--soft); color: var(--ink-2); font-size: 13.5px; padding: 8px 12px; border-radius: 99px; text-align: center; max-width: 94%; }
.msg.pending { opacity: .6; }
.msg .retry { display: block; margin-top: 6px; font-size: 13px; color: var(--accent-ink); text-decoration: underline; background: none; border: 0; padding: 0; cursor: pointer; font: inherit; }
.typing { align-self: flex-start; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; border-top-left-radius: 6px; padding: 14px 16px; display: flex; gap: 5px; }
.typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite ease-in-out; }
.typing span:nth-child(2) { animation-delay: .15s; } .typing span:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

.composer-wrap { border-top: 1px solid var(--line); background: var(--bg); padding: 10px var(--gutter) calc(10px + env(safe-area-inset-bottom)); flex: none; }
.finish-row { display: flex; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 10px; flex-wrap: wrap; }
.composer { display: flex; align-items: flex-end; gap: 8px; }
textarea { flex: 1; resize: none; font: inherit; font-size: 16px; /* 16px: iOS no hace zoom */ line-height: 1.4; border: 1px solid var(--line); background: var(--panel); border-radius: 14px; padding: 12px 14px; max-height: 160px; min-height: 48px; color: var(--ink); }
.send { width: 48px; height: 48px; border-radius: 14px; background: var(--accent); color: var(--accent-ink); border: 0; display: grid; place-items: center; cursor: pointer; flex: none; }
.send:disabled { opacity: .35; cursor: default; }
.send svg { width: 20px; height: 20px; }
.hint { font-size: 12.5px; color: var(--muted); margin-top: 8px; }
.hint.err { color: var(--bad); }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(96px + env(safe-area-inset-bottom)); background: var(--ink); color: var(--accent-ink); padding: 10px 16px; border-radius: 99px; font-size: 14px; z-index: 10; max-width: 92vw; text-align: center; }
.files { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.file-chip { font-size: 12.5px; background: var(--soft); border-radius: 99px; padding: 4px 10px; color: var(--ink-2); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (min-width: 720px) { .screen h1 { font-size: 36px; } .chat { border-left: 1px solid var(--line); border-right: 1px solid var(--line); } .msg { max-width: 80%; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }
