:root { --bg:#14141c; --panel:#1e1e2a; --ink:#ececf4; --mute:#9a9ab0; --accent:#7c9cff; --me:#2d3a66; color-scheme: dark; }
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--ink); font: 16px/1.45 system-ui, sans-serif; padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom); }
main { display: grid; grid-template-columns: minmax(260px, 38%) 1fr; height: 100%; }
#stage { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; padding: 16px; position: relative; }
#avatar { width: 100%; max-width: 420px; aspect-ratio: 4/5; }
#avatar svg, #avatar canvas { width: 100%; height: 100%; display: block; }
#status { color: var(--mute); font-size: .85rem; margin-top: 8px; }
#chat { display: flex; flex-direction: column; min-height: 0; padding: 16px; gap: 8px; }
#log { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.msg { max-width: 85%; padding: 8px 12px; border-radius: 14px; background: var(--panel); white-space: pre-wrap; word-break: break-word; }
.msg.me { align-self: flex-end; background: var(--me); }
.msg.sys { align-self: center; color: var(--mute); background: none; font-size: .85rem; }
.msg.reminder { border: 1px solid var(--accent); }
form { display: flex; gap: 8px; }
input[type=text], #text, #url, #token { flex: 1; padding: 10px 12px; border-radius: 12px; border: 1px solid #33334a; background: var(--panel); color: var(--ink); font: inherit; min-width: 0; }
button { padding: 10px 14px; border-radius: 12px; border: 0; background: var(--accent); color: #0b0b14; font: inherit; cursor: pointer; min-width: 44px; min-height: 44px; }
button#mic.on { background: #ff7c8a; }
button:focus-visible, input:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.opt { color: var(--mute); font-size: .85rem; }
dialog { background: var(--panel); color: var(--ink); border: 1px solid #33334a; border-radius: 16px; padding: 20px; max-width: min(92vw, 420px); }
dialog::backdrop { background: #000a; }
dialog div, dialog form { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
dialog form { flex-direction: column; align-items: stretch; }
#no { background: #3a3a4c; color: var(--ink); }
@media (max-width: 720px) {
  main { grid-template-columns: 1fr; grid-template-rows: 34% 1fr; }
  #stage { min-height: 0; overflow: hidden; padding: 8px; }
  #avatar { height: calc(100% - 28px); width: auto; max-width: 100%; }  /* entra entero en el 34 % de alto */
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto; } }

/* Modo compañero (app de escritorio): fondo transparente, solo avatar + globo + cuadro de texto */
body.companion { background: transparent; overflow: hidden; }
body.companion main { display: flex; flex-direction: column; height: 100%; }
body.companion #stage { flex: 1; padding: 0; justify-content: flex-end; -webkit-app-region: drag; }
body.companion #avatar { max-width: 300px; }
body.companion #status, body.companion .opt { display: none; }
body.companion #chat { padding: 0 8px 8px; flex: none; -webkit-app-region: no-drag; }
body.companion #log { max-height: 150px; flex: none; }
body.companion .msg:not(:nth-last-child(-n+2)) { display: none; }
body.companion form { background: #14141ccc; padding: 6px; border-radius: 14px; }
