:root { color-scheme: light; font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: #20382f; background: #f2f5f1; }
* { box-sizing: border-box; }
body { margin: 0; padding: 24px; }
button, textarea { font: inherit; }
button { cursor: pointer; border: 1px solid #cbd6ce; border-radius: 12px; background: #fff; color: #254939; padding: 12px 16px; font-weight: 600; }
button:hover { background: #edf3ee; }
button:disabled { opacity: .55; cursor: wait; }
:focus-visible { outline: 3px solid #619a77; outline-offset: 3px; }
.chat { max-width: 900px; height: calc(100dvh - 48px); min-height: 360px; margin: auto; display: flex; flex-direction: column; background: #fff; border: 1px solid #dce4dc; border-radius: 22px; overflow: hidden; box-shadow: 0 12px 40px #294a3610; }
.header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 22px 28px; border-bottom: 1px solid #e7ece6; }
h1 { font-size: 25px; letter-spacing: -.8px; margin: 0; }
h1 span { font-size: 14px; font-weight: 400; letter-spacing: 0; margin-left: 12px; color: #6d7f73; }
#status { font-size: 13px; margin: 8px 0 0; display: flex; align-items: center; gap: 7px; }
#status::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: #9aab9f; }
#status[data-state="connected"]::before { background: #36835b; }
#status[data-state="processing"]::before { background: #ba8a24; }
#status[data-state="error"]::before { background: #b24637; }
#messages { flex: 1; overflow-y: auto; min-height: 0; padding: 28px; }
#welcome { padding: 12vh 0 30px; text-align: center; color: #6a7d6f; }
#welcome h2 { color: #294a38; font-size: clamp(24px, 5vw, 34px); font-weight: 500; letter-spacing: -.8px; }
.eyebrow { font-size: 11px; letter-spacing: 2px; }
.message { max-width: 86%; margin: 0 0 20px; padding: 15px 18px; border-radius: 16px; background: #f1f5f0; overflow-wrap: anywhere; }
.message.user { margin-left: auto; background: #e3eee5; }
.message h3 { margin: 0 0 7px; font-size: 12px; color: #54715b; }
.message p { margin: 0; line-height: 1.65; white-space: pre-wrap; }
.message.failed { border: 1px solid #c68d7c; }
#composer { padding: 18px 28px; border-top: 1px solid #e7ece6; }
label { display: block; font-size: 13px; margin-bottom: 9px; font-weight: 600; }
.input-row { display: flex; align-items: flex-end; gap: 12px; }
textarea { width: 100%; min-width: 0; resize: vertical; max-height: 180px; border: 1px solid #cbd6ce; border-radius: 12px; padding: 12px; line-height: 1.5; background: #fcfdfb; color: inherit; }
#send { background: #294f3a; color: white; border-color: #294f3a; min-height: 48px; white-space: nowrap; }
#send:hover { background: #36694b; }
#send span { margin-left: 8px; }
.hint { color: #6a7d6f; font-size: 11px; margin: 10px 0 0; }
#error { margin: 0; padding: 12px 28px; background: #fff0eb; color: #873b2d; font-size: 14px; }
[hidden] { display: none !important; }
@media (max-width: 600px) {
    body { padding: 0; }
    .chat { height: 100dvh; border: 0; border-radius: 0; }
    .header { padding: 18px 16px; }
    .header button { padding: 10px; font-size: 12px; }
    #messages { padding: 20px 16px; }
    .message { max-width: 94%; }
    #composer { padding: 14px 16px max(14px, env(safe-area-inset-bottom)); }
    textarea { font-size: 16px; }
    .input-row { gap: 8px; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }
/* Acceso personal y cierre de sesión. */
.header-actions { display: flex; align-items: center; gap: 8px; }
.header-actions form { margin: 0; }
.login-page { min-height: 100dvh; display: grid; place-items: center; padding: 20px; }
.login-card { width: 100%; max-width: 400px; padding: 32px; border: 1px solid #dce4dc; background: white; border-radius: 20px; }
.login-card form { margin-top: 26px; }
.login-card input { width: 100%; padding: 12px; border: 1px solid #cbd6ce; border-radius: 10px; margin-bottom: 20px; font: inherit; }
.login-card button { width: 100%; background: #294f3a; color: white; }
.login-error { color: #873b2d; background: #fff0eb; padding: 12px; border-radius: 8px; }
@media (max-width: 420px) { .header { flex-wrap: wrap; } .header-actions { margin-left: auto; } }
/* Voz opcional: el formulario escrito conserva su propio flujo. */
.voice-controls { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 12px; }
.voice-controls button { padding: 9px 12px; font-size: 13px; }
.spoken-toggle { display: flex; align-items: center; gap: 7px; margin: 0; font-size: 13px; }
.spoken-toggle input { width: 18px; height: 18px; accent-color: #294f3a; }
#microphone[aria-pressed="true"] { background: #e3eee5; border-color: #36835b; }
#voice-status[data-state="listening"], #voice-status[data-state="speaking"] { color: #236b43; font-weight: 600; }
#voice-status[data-state="error"] { color: #873b2d; }
#voice-transcript { font-size: 14px; color: #54715b; overflow-wrap: anywhere; margin: 8px 0; }
@media (max-height: 650px) { #voice-help { display: none; } #composer { padding-top: 10px; padding-bottom: 10px; } }
