/* 4.2: theme-independent geometry and bounded, interruptible motion. */
.theme-picker{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:12px}
.theme-option{position:relative;display:flex;flex-direction:column;align-items:stretch;gap:12px;padding:12px;min-width:0;text-align:left;border:1px solid var(--control-line);background:var(--surface);color:var(--ink);border-radius:16px;transition:border-color 160ms,box-shadow 160ms,transform 160ms var(--spring)}
.theme-option[aria-pressed=true]{border-color:var(--accent);box-shadow:0 0 0 2px color-mix(in srgb,var(--accent) 35%,transparent)}
.theme-option>svg{position:absolute;right:14px;bottom:16px;width:18px;height:18px;color:var(--accent)}
.theme-option-name{padding-right:24px;font-size:14px;font-weight:600;line-height:1.5}
.theme-sample{display:flex!important;position:relative;overflow:hidden;height:108px;padding:8px;gap:7px;border-radius:10px;background:var(--sample-bg);border:1px solid color-mix(in srgb,var(--sample-accent) 20%,transparent)}
.theme-sample:before,.theme-sample:after{display:none!important}
.sample-sidebar{display:flex;flex-direction:column;gap:6px;width:28%;padding:7px 4px;background:var(--sample-surface);border-radius:6px}
.sample-sidebar i{position:static!important;width:100%!important;height:8px!important;margin:0!important;border-radius:3px!important;background:color-mix(in srgb,var(--sample-accent) 22%,var(--sample-surface))!important}
.sample-sidebar i:first-child{background:var(--sample-accent)!important}
.sample-conversation{flex:1;display:flex;flex-direction:column;gap:8px;padding-top:10px}
.sample-conversation i{position:static!important;width:72%!important;height:16px!important;margin:0!important;border-radius:5px!important;background:var(--sample-surface)!important}
.sample-conversation i:nth-child(2){align-self:flex-end;background:var(--sample-out)!important;width:80%!important;height:22px!important}
.sample-conversation i:nth-child(3){margin-top:auto!important;background:var(--sample-surface)!important;width:100%!important}
.theme-changing body,.theme-changing .main,.theme-changing .nav-strip,.theme-changing .content,.theme-changing .chat-area,.theme-changing .chat-heading,.theme-changing .inbox-list,.theme-changing .message,.theme-changing .message-composer,.theme-changing .modal,.theme-changing .modal-body,.theme-changing .modal-head,.theme-changing .modal-actions,.theme-changing .section-card,.theme-changing .settings-disclosure{transition:background-color 180ms ease,color 180ms ease,border-color 180ms ease}
.chat-quick-actions .button{font-size:13px;line-height:1.4;gap:8px}
.topbar-right>.icon-button,.topbar-right>.button{min-height:44px}
.icon-button svg{width:20px;height:20px}.button.small svg{width:18px;height:18px}
.button:hover:not(:disabled){transform:none}.button:active:not(:disabled){transform:scale(.975)}
.button.primary:hover:not(:disabled),.composer-send:hover:not(:disabled){background:color-mix(in srgb,var(--accent) 88%,var(--on-action));color:var(--on-action)}
.icon-button:focus-visible,.theme-option:focus-visible,.conversation-item:focus-visible{outline:2px solid var(--accent);outline-offset:3px}
.conversation-enter{animation-duration:180ms}.view-enter{animation-duration:180ms}.message-arrive{animation-duration:200ms}.modal{animation-duration:200ms}.drawer{animation-duration:220ms}
.message-media-loading{background:var(--surface-soft)}
.conversation-entry{content-visibility:auto;contain-intrinsic-size:auto 102px}
.conversation-entry>.thread-actions{top:44px;bottom:auto}
.message-stack{overflow-anchor:none}
.history-more{align-self:center;margin:4px auto 16px;padding:10px 16px;min-height:44px;background:var(--surface);color:var(--muted);font-size:13px}
.chat-presence{transition:color 150ms ease}.chat-presence.is-typing{color:var(--accent)}
@media(max-width:1050px){.theme-picker{grid-template-columns:repeat(2,minmax(0,1fr))}}
@media(max-width:760px){.theme-sample{height:94px}.theme-option{padding:10px}.theme-option-name{font-size:13px}.chat-quick-actions .button{font-size:12px}.modal-head h2{font-size:18px}}
@media(prefers-reduced-motion:reduce){.theme-changing *{transition:none!important}.conversation-enter,.view-enter,.message-arrive{animation:none}}
.message-photo{display:block;width:min(320px,100%);overflow:hidden;background:var(--surface-soft);position:relative}
.message-photo>img{width:100%;height:100%;position:absolute;inset:0;object-fit:cover}
.message-photo.message-media-loading{background:var(--elevated,var(--surface-soft))}
.message-photo>img{transition:opacity .18s ease}
.message-photo.message-media-loading>img{opacity:0}
.connection-recovery{min-height:100dvh;display:grid;place-items:center;padding:24px;background:var(--bg);color:var(--ink)}
.connection-recovery>.section-card{max-width:460px;width:100%;padding:32px;display:flex;flex-direction:column;align-items:flex-start;gap:20px}
.connection-recovery h1{font-size:24px;line-height:1.25;margin:0}.connection-recovery p{margin:0;line-height:1.6;color:var(--muted)}

.number-plan .field{margin:0}.number-plan-accounts{display:grid;grid-template-columns:repeat(auto-fit,minmax(220px,1fr));gap:12px}.number-plan-accounts .checkbox-label{border:1px solid var(--border);border-radius:14px;padding:12px;gap:12px;margin:0}.number-plan-accounts small{display:block;opacity:.72;margin-top:4px}.number-plan-week{display:flex;flex-wrap:wrap;gap:12px}.number-plan-week .checkbox-label{margin:0;padding:8px}.number-plan-stats{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:12px;margin:16px 0}.number-plan-stats strong{display:block;font-size:24px}.number-plan-stats small{opacity:.72}.number-plan textarea{min-height:150px;resize:vertical}@media(max-width:540px){.number-plan-stats{grid-template-columns:repeat(2,minmax(0,1fr))}.number-plan .grid-two{grid-template-columns:1fr}.number-plan-accounts{grid-template-columns:1fr}}
.delivery-route{display:grid;gap:12px;padding:20px;border:1px solid var(--control-line);background:var(--surface);border-inline-start:3px solid currentColor;border-radius:16px;min-width:0}
.delivery-route-heading{display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap}
.delivery-route-heading strong{overflow-wrap:anywhere}
.delivery-route[data-status="received"]{border-inline-start-color:#5cad89}
.delivery-route[data-status="delayed"]{border-inline-start-color:#d9a441}
.delivery-route[data-status="unconfirmed"]{border-inline-start-color:#d57676}
.delivery-route>.number-plan-stats{grid-template-columns:repeat(2,minmax(0,1fr))}
@media(max-width:540px){.delivery-route{padding:16px}.delivery-route>.number-plan-stats{grid-template-columns:1fr}}

/* Translation belongs to the incoming audio bubble; playback keeps its own DOM. */
.voice-translation {margin-top:8px;padding-top:8px;border-top:1px solid color-mix(in srgb,currentColor 14%,transparent);max-width:380px;overflow-wrap:anywhere;}
.voice-translation-label {display:block;opacity:.75;font-size:12px;margin-bottom:6px;}
.voice-translation-text,.voice-transcript {white-space:pre-wrap;line-height:1.5;font-size:15px;user-select:text;}
.voice-translation details {margin-top:8px;}
.voice-translation summary {cursor:pointer;padding:8px 0;min-height:36px;font-size:13px;}
.voice-transcript {opacity:.82;margin-top:4px;}
.voice-translate-button {min-height:40px;padding:8px 12px;border-radius:12px;font-size:13px;gap:8px;}
.voice-translate-button[aria-busy=true]::before {content:"";width:12px;height:12px;display:inline-block;margin-right:8px;border:2px solid currentColor;border-right-color:transparent;border-radius:50%;animation:voice-translate-spin .8s linear infinite;}
.voice-translation-error {display:block;font-size:12px;line-height:1.5;margin-top:6px;}
@keyframes voice-translate-spin {to{transform:rotate(360deg)}}
@media(prefers-reduced-motion:reduce){.voice-translate-button[aria-busy=true]::before{animation:none}}

/* Delivery is readable without hovering or distinguishing two similar greens. */
.message-meta .message-status{font-size:12px;line-height:1.5;font-weight:500;letter-spacing:.01em;}
.message-meta .message-status.whatsapp-read{color:#79cfff;font-weight:600;}
:root[data-theme="light"] .message-meta .message-status.whatsapp-read,
:root[data-theme="ocean-light"] .message-meta .message-status.whatsapp-read{color:#0764a3;}

/* Connection alert occupies its own row; it never covers the composer or chats. */
#account-health-banner{display:flex;flex:none;align-items:center;gap:12px;padding:12px 24px;border-bottom:1px solid #b764343f;background:#3b3022;color:#ffe0a5;font-size:13px;line-height:1.5;max-height:160px;overflow:auto;}
#account-health-banner[hidden]{display:none}
#account-health-banner>svg{width:22px;height:22px;flex:none}
#account-health-banner[data-severity=error]{background:#3e2429;color:#ffccd0;border-color:#a94b55}
.account-health-copy{flex:1;min-width:0;overflow-wrap:anywhere;display:grid;gap:2px}
#account-health-banner .button{flex:none;color:inherit;border:1px solid currentColor;background:transparent}
[data-health=disconnected],[data-health=needs_qr]{color:#ffb7c0!important}
:root[data-theme=light] #account-health-banner,:root[data-theme=ocean-light] #account-health-banner{background:#fff4df;color:#745016}
:root[data-theme=light] #account-health-banner[data-severity=error],:root[data-theme=ocean-light] #account-health-banner[data-severity=error]{background:#fff0f1;color:#952d3a;border-color:#e9b7bd}
:root[data-theme=light] [data-health=disconnected],:root[data-theme=light] [data-health=needs_qr],:root[data-theme=ocean-light] [data-health=disconnected],:root[data-theme=ocean-light] [data-health=needs_qr]{color:#952d3a!important}
[data-health-action][hidden]{display:none!important}
@media(max-width:600px){#account-health-banner{padding:10px 12px;gap:8px;font-size:12px;max-height:132px}#account-health-banner .button{padding:8px;min-height:40px}#account-health-banner>svg{display:none}}

#connection-state[data-health=disconnected] .dot{background:currentColor}

/* 4.2.8: receipts are visible information, independent of hover and unread badges. */
:root{--receipt-ink:#17669C;--receipt-wash:#E4F2FB}
:root[data-theme="dark"],:root[data-theme="ocean"]{--receipt-ink:#86CFFF;--receipt-wash:#173B50}
.thread-preview-row .thread-preview{display:flex;align-items:center;gap:5px;min-width:0}
.thread-snippet{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}
.thread-receipt{flex:none;display:inline-block;font-size:14px;line-height:20px;font-weight:700;color:var(--muted);letter-spacing:-2px;padding-right:2px}
.thread-receipt.read{color:var(--receipt-ink)}
.thread-receipt.failed{color:var(--danger)}
.thread-preview-row .thread-preview.is-typing{color:var(--accent);font-weight:600}
.message-meta .message-status{font-size:12px;line-height:18px;font-weight:500;opacity:1;color:var(--muted)}
.message-meta .message-status.whatsapp-read{color:var(--receipt-ink);background:var(--receipt-wash);border-radius:6px;padding:1px 5px;font-weight:600}
