/* A familiar messaging surface, deliberately distinct from the household pages. */
:root{--chat-paper:#f5f2eb;--chat-incoming:#fff;--chat-outgoing:#dcfbd2;--chat-ink:#111b21;--chat-muted:#72786f;--chat-header:#f5f2ec;--chat-green:#1bad60}
.chat-panel{position:fixed;z-index:40;left:0;right:0;max-width:700px;margin:auto;display:flex;flex-direction:column;background:var(--chat-paper);color:var(--chat-ink);box-shadow:none;border-radius:0;overflow:hidden;font:15px/1.4 -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif;isolation:isolate}
.chat-panel[hidden]{display:none}
.chat-panel *{box-sizing:border-box}
.chat-panel button{font:inherit;min-height:0;box-shadow:none;border:0;letter-spacing:normal}
.chat-controls{position:absolute;z-index:3;top:6px;right:8px;display:flex;gap:4px;padding:3px;border-radius:28px;background:var(--chat-header);box-shadow:0 1px 6px #0002}
.chat-connection{position:absolute;z-index:2;top:19px;left:11px;max-width:calc(100% - 178px);padding:3px 7px;border-radius:10px;background:var(--chat-header);font-size:11px;color:var(--chat-muted)}
.chat-panel .chat-icon{width:35px;height:35px;min-width:35px;padding:7px;border-radius:50%;background:transparent;color:var(--chat-muted)}
.chat-controls .chat-icon{width:44px;height:44px;min-width:44px;padding:9px}
.chat-controls .chat-icon svg{width:26px;height:26px}
.chat-panel .chat-icon.enabled{color:var(--chat-green);background:#00806915}
.chat-panel .chat-icon[aria-pressed=true]{color:var(--chat-green);background:color-mix(in srgb,var(--chat-green) 18%,transparent)}
.chat-panel svg{width:21px;height:21px;flex:none}
.chat-log-wrap{position:relative;min-height:0;flex:1;display:flex;flex-direction:column;background-image:url('./chat-pattern.svg');background-size:280px 260px}
.chat-messages{flex:1;overflow-y:auto;overflow-x:hidden;overscroll-behavior:contain;padding:58px 11px 12px;scroll-padding-top:58px;scrollbar-width:thin;touch-action:pan-y;min-height:0;display:flex;flex-direction:column;gap:5px}
.chat-bubble{position:relative;max-width:91%;width:fit-content;padding:6px 11px 5px;border-radius:17px;background:var(--chat-incoming);box-shadow:0 1px 1px #0b141a09;overflow-wrap:anywhere;flex:none;text-align:left;touch-action:pan-y;outline-offset:3px}
.chat-bubble+.chat-bubble{margin-top:5px}
.chat-bubble[data-speaker=paco]+.chat-bubble[data-speaker=paco],.chat-bubble[data-speaker=tania]+.chat-bubble[data-speaker=tania],.chat-bubble[data-speaker=nido]+.chat-bubble[data-speaker=nido]{margin-top:0}
.chat-bubble[data-speaker=paco]+.chat-bubble[data-speaker=paco]>.chat-sender,.chat-bubble[data-speaker=tania]+.chat-bubble[data-speaker=tania]>.chat-sender,.chat-bubble[data-speaker=nido]+.chat-bubble[data-speaker=nido]>.chat-sender{display:none}
.chat-own{align-self:flex-end;background:var(--chat-outgoing)}
.chat-other{align-self:flex-start}
.chat-sender{font-size:16px;line-height:1.35;font-weight:650;margin-bottom:2px;color:#007c6b}
.chat-sender.paco{color:#856916}.chat-sender.tania{color:#9c4591}
.chat-text{font-size:16px;line-height:1.35;white-space:normal}
.chat-text p{margin:0 0 5px;line-height:inherit}.chat-text p:last-child{margin:0}
.chat-text ul,.chat-text ol{padding-left:19px;margin:5px 0}.chat-text li{margin:2px 0}
.chat-text h1,.chat-text h2,.chat-text h3{font-weight:650;font-size:15px;line-height:1.4;margin:5px 0}
.chat-text pre{overflow-x:auto;max-width:100%;margin:8px 0;white-space:pre;overflow-wrap:normal;word-break:normal;font:13px/1.55 ui-monospace,SFMono-Regular,Menlo,Consolas,monospace}
.chat-text pre code{font:inherit;white-space:inherit;overflow-wrap:normal;word-break:normal}
.chat-text :not(pre)>code{font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:.9em}
.chat-text a{color:#027eb5;text-decoration:underline}
.chat-message-footer{display:flex;justify-content:flex-end;align-items:center;gap:4px;color:var(--chat-muted);font-size:11px;line-height:13px;margin:1px 0 0;min-height:14px;white-space:nowrap}
.chat-inline-meta .chat-message-footer{position:absolute;bottom:6px;right:10px;margin:0}
.chat-meta-space{display:inline-block;width:45px;height:1px}.chat-own .chat-meta-space{width:67px}
.chat-panel .chat-reply-button{position:absolute;top:calc(50% - 17px);right:-35px;background:var(--chat-header);color:var(--chat-muted);width:32px;height:32px;padding:8px;border-radius:50%;opacity:0;pointer-events:none;box-shadow:0 1px 4px #0002}
.chat-own .chat-reply-button{right:auto;left:-35px}.chat-selected>.chat-reply-button,.chat-bubble:focus-within>.chat-reply-button{opacity:1;pointer-events:auto}
.chat-bubble.chat-selected{outline:2px solid #65aa8566}
.chat-reply-button svg{width:16px;height:16px}.chat-receipt{display:inline-flex;align-items:center;color:var(--chat-muted)}.chat-panel .chat-receipt svg{width:17px;height:14px}.chat-receipt.read{color:#49a8f2}
.chat-date{align-self:center;padding:3px 9px;margin:5px 0;background:#fff9;border-radius:7px;font-size:10px;color:#53636e;flex:none;box-shadow:0 1px 1px #0001}
.chat-panel .chat-earlier{align-self:center;background:#ffffffbf;font-size:11px;color:var(--chat-green);border-radius:16px;padding:6px 12px;flex:none}
.chat-panel .chat-new{position:absolute;bottom:8px;right:10px;background:var(--chat-header);color:var(--chat-green);font-size:12px;padding:7px 12px;border-radius:20px;box-shadow:0 2px 5px #0002}
.chat-panel [hidden]{display:none!important}
.chat-panel .chat-composer{display:flex;align-items:flex-end;gap:5px;padding:7px 9px;background:var(--chat-header);margin:0;flex:none}
.chat-composer textarea{flex:1;min-width:0;resize:none;min-height:39px;max-height:110px;height:39px;line-height:23px;padding:8px 12px;border:0;border-radius:20px;background:var(--chat-incoming);color:var(--chat-ink);font:16px/23px -apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;margin:0;box-shadow:none;overflow-y:auto;touch-action:pan-y}
.chat-composer .chat-send,.chat-composer .chat-mic{width:39px;height:39px;min-width:39px;padding:9px;border-radius:50%;background:var(--chat-green);color:white;touch-action:none}
.chat-composer .chat-mic[aria-pressed=true]{background:#dd3030;color:#fff}
.chat-panel .chat-quote{display:flex;flex-direction:column;gap:2px;text-align:left;width:100%;background:#00000007;border-left:3px solid var(--chat-green);border-radius:4px;padding:5px 7px;font-size:12px;margin-bottom:5px;color:var(--chat-muted)}
.chat-quote strong{color:var(--chat-green);font-size:11px}.chat-quote span{display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}
.chat-reply-compose{display:flex;align-items:center;justify-content:space-between;gap:8px;background:var(--chat-header);border-left:4px solid var(--chat-green);padding:6px 9px;flex:none}
.chat-reply-compose>div{display:flex;flex-direction:column;min-width:0;font-size:12px}.chat-reply-compose span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.chat-reply-compose strong{font-size:11px;color:var(--chat-green)}
.chat-activity{display:flex;align-items:center;gap:6px;color:var(--chat-muted);font-size:12px;min-height:24px}
.chat-working-dot{width:5px;height:5px;border-radius:50%;background:var(--chat-green);animation:chat-pulse 1s ease-in-out infinite}
.chat-panel .chat-retry,.chat-panel .chat-view{padding:5px 8px;border-radius:6px;font-size:12px;color:var(--chat-green);background:#0080690c;text-align:left;margin-top:5px}
.chat-destinations{display:flex;flex-wrap:wrap;align-items:flex-end;gap:4px 8px;margin-top:5px}
.chat-panel .chat-destinations .chat-view{margin-top:0}
.chat-destinations .chat-message-footer{margin:0 0 2px auto;flex:none}
/* A message on its way looks like any sent message, with a clock where the tick will be. Notes and the Retry and
   Delete controls appear only while it waits for a connection or after the server refused it. */
.chat-outbox>.chat-unsent-footer{flex-wrap:wrap;white-space:normal;pointer-events:auto;gap:4px 12px}
/* Stated again here because the voice-bubble footer rule further down switches touches off; without it Retry and
   Delete on an unsent voice message cannot be tapped. */
.chat-voice-bubble.chat-outbox>.chat-unsent-footer{margin-top:2px;pointer-events:auto}
.chat-voice-bubble.chat-outbox>.chat-unsent-footer:not(:has(button)){margin-top:-14px;pointer-events:none}
.chat-unsent-note{color:var(--chat-muted);font-size:11px;margin-right:auto}
.chat-unsent-problem .chat-unsent-note{color:#a83434}
.chat-panel .chat-unsent-footer button{background:none;border:0;margin:0;padding:4px;min-height:36px;font-size:13px;box-shadow:none}
.chat-panel .chat-delete{color:#a83434}.chat-unsent-footer button:disabled{opacity:.5;cursor:wait}
.chat-panel .chat-sending svg{width:13px;height:13px}
@media(prefers-color-scheme:dark){.chat-panel .chat-delete,.chat-unsent-problem .chat-unsent-note{color:#ffaaa4}}
.chat-error{font-size:12px;background:#fff1d0;color:#705414;padding:5px 10px;flex:none}
.chat-voice-compose{padding:6px 10px;display:flex;align-items:center;gap:8px;background:var(--chat-header);font-size:12px;flex:none;min-width:0}
.chat-panel audio[hidden]{display:none}.chat-voice-compose .voice-player{min-width:0;flex:1}
.chat-voice-bubble{min-width:280px;padding:9px 10px 6px}
.voice-player{width:290px;max-width:100%;display:flex;align-items:center;gap:8px;min-width:0}
.chat-panel .voice-play{padding:4px;width:28px;height:38px;flex:none;color:#69736a;background:none;display:grid;place-items:center}
.chat-panel .voice-play svg{width:25px;height:25px}
.voice-track{flex:1;min-width:0;align-self:stretch;padding-top:3px}
.voice-wave{position:relative;height:28px;min-width:65px}
.chat-panel .voice-wave svg{width:100%;height:28px;display:block;stroke:#a4b09e}.voice-wave .played{stroke:#53a6eb}
.voice-wave input[type=range]{position:absolute;inset:0;margin:0;padding:0;width:100%;height:100%;min-height:0;opacity:0;cursor:pointer;touch-action:pan-y}
.voice-wave:focus-within{outline:2px solid #53a6eb;outline-offset:3px;border-radius:4px}
.voice-time{display:block;font-size:11px;line-height:15px;color:var(--chat-muted);font-variant-numeric:tabular-nums}
.voice-avatar{position:relative;display:grid;place-items:center;width:40px;height:40px;flex:none;border-radius:50%;background:#dec78e;color:#554921;font-size:17px;font-weight:600}
.voice-avatar.tania{background:#dec6e7;color:#643e7e}.voice-avatar img{width:100%;height:100%;object-fit:contain}
.chat-panel .voice-avatar>.icon{position:absolute;bottom:-2px;right:-3px;width:15px;height:19px;color:#56a8ed;filter:drop-shadow(0 0 1px var(--chat-incoming))}
.voice-incoming .voice-avatar>.icon{right:auto;left:-3px}
.chat-voice-bubble .chat-transcript{margin-left:76px;margin-top:0;font-size:10px}.chat-voice-bubble .chat-transcript summary{padding:0;line-height:15px;width:fit-content}
.chat-voice-bubble>.chat-message-footer{margin-top:-14px;pointer-events:none}.chat-voice-bubble:has(.chat-transcript[open])>.chat-message-footer{margin-top:2px}
.chat-recording-dot{width:8px;height:8px;background:#e74c3c;border-radius:50%;animation:chat-pulse 1s infinite}
.chat-recording-time{font-variant-numeric:tabular-nums}.chat-record-hint{font-size:10px;flex:1;color:var(--chat-muted)}
.chat-panel .chat-stop{background:var(--chat-incoming);padding:6px 10px;color:var(--chat-ink);border-radius:8px}
.chat-transcript{font-size:12px;color:var(--chat-muted)}.chat-transcript summary{padding:3px 0}.chat-transcript p{margin:4px 0;color:var(--chat-ink)}
.chat-toggle{position:relative}.chat-badge{position:absolute;right:-3px;top:-2px;background:#25d366;color:#103625;border-radius:12px;font:700 10px/17px sans-serif;min-width:17px;text-align:center;padding:0 4px}
.chat-highlight,.nido-chat-highlight{animation:chat-highlight 1.7s ease-out}
@keyframes chat-pulse{50%{opacity:.35}}@keyframes chat-highlight{0%,30%{box-shadow:0 0 0 3px #25d36688}100%{box-shadow:none}}
@media(prefers-color-scheme:dark){:root{--chat-paper:#090b0a;--chat-incoming:#222624;--chat-outgoing:#144d3e;--chat-ink:#e9edef;--chat-muted:#929c98;--chat-header:#111413;--chat-green:#21c66a}.chat-date{background:#222624;color:#aebac1}.chat-panel .chat-earlier{background:#222624}.chat-sender{color:#82dba6}.chat-sender.paco{color:#e8bd68}.chat-sender.tania{color:#d99bd1}.chat-text a{color:#53bdeb}.chat-error{background:#44391f;color:#edcd8b}.chat-panel .voice-play{color:#aeb6b1}.chat-panel .voice-wave svg{stroke:#788e7f}}
@media(prefers-reduced-motion:reduce){.chat-panel *,.nido-chat-highlight{animation:none!important;scroll-behavior:auto!important}}
:root:has(body.chat-open){overflow:hidden;overscroll-behavior:none}
body.chat-open{position:fixed;inset:0;overflow:hidden;}
body.chat-open .app-shell{padding-bottom:0}
body.chat-open .topbar{position:fixed;left:0;right:0;top:calc(var(--viewport-top,0px) + env(safe-area-inset-top));max-width:700px;margin:auto}
body.chat-open .bottom-nav{bottom:var(--viewport-bottom,0px)}
body.chat-open.keyboard-open .chat-composer{margin-top:44px}
body.chat-open.keyboard-open .bottom-nav{display:grid;bottom:calc(var(--viewport-bottom,0px) + var(--chat-composer-height,53px));height:44px;padding:0 2px}
/* These two end in classes on purpose. A rule under a body class that ends in a bare tag (button, span) makes the
   browser restyle every such element in every kept screen whenever Chat or the keyboard opens. */
body.chat-open.keyboard-open .bottom-nav .nav-button{height:44px;min-height:44px;padding:0;gap:0}
body.chat-open.keyboard-open .bottom-nav .nav-label{display:none}
