:root {
  --ink: #10231f;
  --muted: #5d716b;
  --brand: #0f4c45;
  --brand-2: #16695f;
  --mint: #dff3ea;
  --paper: #f1ede6;
  --bubble-me: #d8f0e2;
  --line: rgba(16, 35, 31, .09);
  --red: #c8372d;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); color: var(--ink); background: #e7e2d9; -webkit-font-smoothing: antialiased; }
body.standalone { display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 30% 20%, #f4efe7, #dcd5c9); }
body.standalone .phone { width: 400px; height: min(840px, calc(100vh - 48px)); border-radius: 34px; box-shadow: 0 30px 80px rgba(16, 35, 31, .25), 0 0 0 10px #111, 0 0 0 11px #333; }
@media (max-width: 520px) { body.standalone { padding: 0; } body.standalone .phone { width: 100%; height: 100%; border-radius: 0; box-shadow: none; } }

.phone { position: relative; display: flex; flex-direction: column; width: 100%; height: 100%; overflow: hidden; background: var(--paper); }

/* Cabecera */
.top { display: flex; align-items: center; gap: 12px; padding: 14px 16px; padding-top: max(14px, env(safe-area-inset-top)); background: var(--brand); color: #fff; z-index: 2; }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: #fff; display: grid; place-items: center; flex: none; }
.avatar svg { width: 22px; height: 22px; fill: var(--brand); }
.who { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.who strong { font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who span { font-size: 12.5px; opacity: .8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.timer { display: flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 99px; background: rgba(255, 255, 255, .14); font-size: 12.5px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.timer .dot { width: 7px; height: 7px; border-radius: 50%; background: #ffd166; animation: pulse 1.2s infinite; }
.timer.done { background: #fff; color: var(--brand); font-weight: 600; }
.timer.done .dot { background: #2fae74; animation: none; }
@keyframes pulse { 50% { opacity: .3; } }

/* Conversación */
.thread { flex: 1; overflow-y: auto; padding: 14px 12px 18px; display: flex; flex-direction: column; gap: 6px; scroll-behavior: smooth;
  background-color: var(--paper);
  background-image: radial-gradient(rgba(16, 35, 31, .045) 1px, transparent 1px); background-size: 18px 18px; }
.day { align-self: center; font-size: 12px; color: var(--muted); background: rgba(255, 255, 255, .75); padding: 4px 10px; border-radius: 8px; margin-bottom: 4px; }
.note { align-self: center; max-width: 88%; text-align: center; font-size: 12px; line-height: 1.45; color: #6b5d2f; background: #fbf3d5; padding: 8px 12px; border-radius: 10px; margin-bottom: 8px; }

.msg { max-width: 84%; padding: 8px 10px 6px; border-radius: 12px; font-size: 15px; line-height: 1.42; position: relative; box-shadow: 0 1px .5px rgba(0, 0, 0, .08); animation: pop .22s ease-out; word-wrap: break-word; }
.msg.bot { align-self: flex-start; background: #fff; border-top-left-radius: 4px; }
.msg.me { align-self: flex-end; background: var(--bubble-me); border-top-right-radius: 4px; }
.msg .time { display: block; text-align: right; font-size: 11px; color: var(--muted); margin-top: 2px; }
.msg.me .time::after { content: " ✓✓"; color: #34b7f1; letter-spacing: -2px; }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.98); } }

.typing { display: inline-flex; gap: 4px; padding: 4px 2px; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: #9aa9a4; animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; } .typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 60%, 100% { opacity: .3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

/* Nota de voz */
.voice { display: flex; align-items: center; gap: 10px; min-width: 230px; padding-top: 2px; }
.voice .play { width: 34px; height: 34px; border-radius: 50%; border: 0; background: var(--brand-2); display: grid; place-items: center; cursor: pointer; flex: none; }
.voice .play svg { width: 16px; height: 16px; fill: #fff; }
.voice .bars { flex: 1; display: flex; align-items: center; gap: 2px; height: 28px; }
.voice .bars i { flex: 1; background: #9cc5b5; border-radius: 2px; min-height: 3px; transition: background .1s; }
.voice .bars i.on { background: var(--brand-2); }
.voice .dur { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.transcript { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--line); font-size: 13.5px; color: #33473f; }
.transcript b { display: block; font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); margin-bottom: 2px; }
.transcript.wait { color: var(--muted); font-style: italic; }
.transcript .fix { display: flex; gap: 6px; margin-top: 6px; }
.transcript .fix input { flex: 1; min-width: 0; border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; font: inherit; font-size: 14px; }
.transcript .fix button { border: 0; border-radius: 8px; background: var(--brand); color: #fff; padding: 0 12px; font: inherit; font-size: 13px; cursor: pointer; }

/* Respuestas rápidas y huecos */
.quick { align-self: flex-start; display: flex; flex-wrap: wrap; gap: 6px; max-width: 92%; margin: 2px 0 6px; animation: pop .25s ease-out; }
.quick button { border: 1px solid rgba(15, 76, 69, .25); background: #fff; color: var(--brand); border-radius: 99px; padding: 8px 13px; font: inherit; font-size: 14px; cursor: pointer; transition: background .15s, transform .1s; }
.quick button:hover { background: var(--mint); }
.quick button:active { transform: scale(.97); }
.quick.used button { opacity: .45; pointer-events: none; }
.quick.used button.chosen { opacity: 1; background: var(--mint); }

.slots { align-self: flex-start; width: 84%; display: flex; flex-direction: column; gap: 6px; margin: 2px 0 6px; animation: pop .25s ease-out; }
.slot { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; border: 0; background: #fff; border-radius: 12px; padding: 11px 13px; font: inherit; cursor: pointer; box-shadow: 0 1px .5px rgba(0, 0, 0, .08); transition: transform .1s, box-shadow .15s; }
.slot:hover { box-shadow: 0 0 0 2px var(--brand-2); }
.slot:active { transform: scale(.98); }
.slot .cal { width: 38px; height: 38px; border-radius: 10px; background: var(--mint); color: var(--brand); display: grid; place-items: center; flex: none; }
.slot .cal svg { width: 20px; height: 20px; fill: currentColor; }
.slot strong { display: block; font-size: 15px; }
.slot span { font-size: 12.5px; color: var(--muted); }
.slot .go { margin-left: auto; color: var(--brand-2); font-size: 13px; font-weight: 600; }
.slots.used .slot { opacity: .45; pointer-events: none; }
.slots.used .slot.chosen { opacity: 1; box-shadow: 0 0 0 2px var(--brand-2); }
.slots .other { align-self: flex-start; border: 0; background: none; color: var(--brand-2); font: inherit; font-size: 13.5px; padding: 4px 2px; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.slots.used .other { display: none; }

.done-card { align-self: stretch; margin: 8px 4px; background: #fff; border-radius: 16px; padding: 16px; text-align: center; box-shadow: 0 6px 24px rgba(16, 35, 31, .1); animation: pop .3s ease-out; }
.done-card .ok { width: 44px; height: 44px; border-radius: 50%; background: #2fae74; margin: 0 auto 8px; display: grid; place-items: center; }
.done-card .ok svg { width: 24px; height: 24px; fill: #fff; }
.done-card.alert .ok { background: var(--red); }
.done-card h3 { margin: 0 0 4px; font-size: 16px; }
.done-card p { margin: 0; font-size: 13.5px; color: var(--muted); }
.done-card .again { margin-top: 12px; border: 0; background: none; color: var(--brand-2); font: inherit; font-size: 13.5px; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

/* Ejemplos de demo */
.demo { padding: 10px 12px 4px; background: linear-gradient(transparent, rgba(241, 237, 230, .95) 30%); }
.demo p { margin: 0 0 6px; font-size: 12px; color: var(--muted); }
.demo-chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; scrollbar-width: none; }
.demo-chips button { flex: none; display: flex; align-items: center; gap: 6px; border: 0; border-radius: 99px; background: var(--brand); color: #fff; padding: 8px 12px; font: inherit; font-size: 13px; cursor: pointer; }
.demo-chips button svg { width: 14px; height: 14px; fill: currentColor; }
.demo-chips button.alarm { background: #8f2a22; }

/* Barra de escribir / grabar */
.composer, .recorder { display: flex; align-items: center; gap: 8px; padding: 8px 10px; padding-bottom: max(8px, env(safe-area-inset-bottom)); background: #ebe6dd; }
.field { flex: 1; background: #fff; border-radius: 22px; padding: 0 14px; }
.field input { width: 100%; border: 0; outline: 0; background: none; font: inherit; font-size: 15.5px; padding: 11px 0; color: var(--ink); }
.round { width: 46px; height: 46px; border-radius: 50%; border: 0; background: var(--brand); display: grid; place-items: center; cursor: pointer; flex: none; transition: transform .1s; }
.round:active { transform: scale(.94); }
.round svg { width: 22px; height: 22px; fill: #fff; }
.round .i-send { display: none; }
.round.typing-mode .i-mic { display: none; }
.round.typing-mode .i-send { display: block; }
.round:disabled { opacity: .5; cursor: default; }
.recorder .ghost { width: 42px; height: 42px; border: 0; background: none; cursor: pointer; display: grid; place-items: center; }
.recorder .ghost svg { width: 22px; height: 22px; fill: var(--muted); }
.rec-info { flex: 1; display: flex; align-items: center; gap: 8px; min-width: 0; background: #fff; border-radius: 22px; padding: 11px 14px; font-size: 15px; font-variant-numeric: tabular-nums; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--red); animation: pulse 1s infinite; flex: none; }
.rec-live { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.toast { position: absolute; left: 50%; bottom: 80px; transform: translateX(-50%); background: rgba(16, 35, 31, .92); color: #fff; font-size: 13px; padding: 8px 14px; border-radius: 10px; z-index: 5; max-width: 88%; text-align: center; }
