:root { color-scheme: light; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: #172e2c; background: #f2f4f1; font-synthesis: none; }
* { box-sizing: border-box; }
body { margin: 0; min-width: 280px; }
.language-choice { position: absolute; inset: 14px 24px auto auto; display: flex; gap: 18px; z-index: 1; }
.language-choice a { color: #075e54; font-size: 14px; }
main { min-height: 100svh; display: grid; place-items: center; padding: 60px 24px; }
.login-card { width: min(100%, 460px); padding: 48px; background: #fff; border: 1px solid #e0e7e1; border-radius: 20px; box-shadow: 0 14px 50px #103d2b0c; }
.wordmark { display: flex; align-items: center; gap: 5px; color: #075e54; font-size: 42px; font-weight: 750; letter-spacing: -3px; margin-bottom: 36px; }
h1 { font-size: 28px; line-height: 1.25; letter-spacing: -.8px; font-weight: 600; margin: 0 0 32px; }
label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 9px; }
input { width: 100%; padding: 14px 15px; border: 1px solid #a8b9b0; border-radius: 9px; font: inherit; font-size: 17px; background: #fff; color: #172e2c; }
input:focus-visible, button:focus-visible, a:focus-visible { outline: 3px solid #77c9ae; outline-offset: 3px; }
button { display: flex; justify-content: space-between; align-items: center; gap: 12px; width: 100%; border: 0; border-radius: 9px; background: #087e62; color: #fff; padding: 15px 18px; font: inherit; font-weight: 600; cursor: pointer; }
button:hover { background: #07644e; }
button:disabled { opacity: .65; cursor: wait; }
button.secondary { background: #edf3ef; color: #075e54; margin-top: 12px; }
.form-error { min-height: 20px; margin: 8px 0 12px; color: #9b2f2f; font-size: 14px; line-height: 1.4; }
.helper { font-size: 14px; line-height: 1.7; color: #60716b; margin: 22px 0 18px; }
a { color: #087e62; text-underline-offset: 3px; }
.privacy-link { font-size: 13px; }
.honeypot { position: absolute; width: 1px; height: 1px; overflow: hidden; left: -10000px; }
.inbox-icon { margin-bottom: 20px; color: #087e62; font-size: 30px; }
.address { overflow-wrap: anywhere; font-weight: 600; }
.login-code { display: block; text-align: center; font-size: 48px; line-height: 1.4; font-weight: 700; font-variant-numeric: tabular-nums; color: #075e54; margin: 22px 0; }
/* HTML §4.10: native radio choices preserve keyboard and screen-reader behavior. */
.replacement-card { width: min(100%, 580px); }
.replacement-card .wordmark { margin-bottom: 24px; }
.replacement-card h1 { margin-bottom: 16px; }
#replacement-devices { border: 0; padding: 0; margin: 24px 0; min-width: 0; display: grid; gap: 10px; }
#replacement-devices legend { font-size: 14px; font-weight: 600; margin-bottom: 12px; }
.replacement-device { display: flex; gap: 12px; align-items: start; padding: 14px; border: 1px solid #a8b9b0; border-radius: 9px; cursor: pointer; margin: 0; }
.replacement-device:has(input:checked) { border-color: #087e62; background: #edf5f1; }
.replacement-device input { width: 18px; height: 18px; flex: 0 0 18px; margin: 2px 0; padding: 0; accent-color: #087e62; }
.replacement-details { display: grid; gap: 6px; min-width: 0; font-weight: 400; font-size: 12px; line-height: 1.5; }
.replacement-details strong { font-size: 15px; }
.replacement-details code { overflow-wrap: anywhere; font-size: 11px; }
#replacement-cancel { margin-top: 22px; }
#replacement-back[hidden] { display: none; }
.quiet-link { border: none; background: none; width: auto; padding: 0; font-size: 14px; color: #087e62; display: inline-block; text-decoration: underline; }
.quiet-link:hover { background: none; color: #064e3d; }
.chat-empty { width: min(100%, 1100px); min-height: 70svh; display: grid; grid-template-columns: 300px 1fr; border: 1px solid #dce4dd; background: #fff; border-radius: 14px; overflow: hidden; }
.chat-sidebar { padding: 24px; border-right: 1px solid #e3e9e4; display: flex; flex-direction: column; gap: 18px; }
.chat-sidebar .wordmark { margin: 0; font-size: 30px; }
.chat-sidebar button { margin-top: auto; }
.empty-copy { display: grid; align-content: center; justify-items: center; padding: 48px; text-align: center; background: #f6f8f5; }
.empty-copy p { color: #60716b; line-height: 1.7; }
.empty-copy h1 { margin-bottom: 8px; }
.chat-empty { height: max(650px, calc(100svh - 120px)); }
.chat-sidebar { min-width: 0; overflow: auto; }
.chat-sidebar #new-chat, .contact-list button { margin-top: 0; }
.contact-list { display: grid; gap: 6px; }
.contact-item { display: grid; justify-content: stretch; gap: 5px; padding: 14px 12px; color: #172e2c; background: transparent; text-align: start; overflow-wrap: anywhere; }
.contact-item:hover, .contact-item[aria-current=true] { background: #edf3ef; }
.contact-item span { font-size: 12px; font-weight: 400; }
.key-notice-label { color: #97571f; }
.contact-pane { padding: 32px; min-width: 0; overflow: auto; }
.contact-pane h1 { font-size: 24px; overflow-wrap: anywhere; margin-bottom: 8px; }
.contact-address { overflow-wrap: anywhere; color: #60716b; }
.contact-pane h2 { font-size: 18px; margin-top: 28px; }
.contact-pane form { max-width: 430px; margin-top: 32px; }
.contact-pane form button { margin-top: 20px; }
.contact-pane button.secondary { width: auto; display: inline-flex; padding: 10px 14px; font-size: 14px; }
.key-warning, .key-notice { margin: 20px 0; padding: 16px; border-radius: 10px; background: #fff2df; border: 1px solid #d9b57c; }
.key-notice { background: #edf5f1; border-color: #bdd6c8; }
.key-warning h2 { margin: 0 0 10px; }
.device-list { display: grid; gap: 14px; }
.device-card { border: 1px solid #dce4dd; border-radius: 10px; padding: 18px; }
.device-card h3 { font-size: 16px; margin: 0 0 8px; }
.device-card p { font-size: 13px; margin: 12px 0 5px; }
.device-card .device-status { color: #60716b; }
.contact-pane code { display: block; font-size: 12px; line-height: 1.6; overflow-wrap: anywhere; white-space: pre-wrap; }
@media (max-width: 600px) { main { padding: 32px 18px; } .login-card { padding: 32px 25px; } .chat-empty { grid-template-columns: 1fr; } .chat-sidebar { border-right: 0; border-bottom: 1px solid #e3e9e4; } .empty-copy { padding: 40px 24px; } }
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }
/* Device-local conversation: ordered WebRTC messages, no server content. */
.conversation-pane { min-width: 0; min-height: 0; display: flex; flex-direction: column; overflow: hidden; background: #eef1eb; }
.conversation-header { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 18px 24px; border-bottom: 1px solid #dce4dd; background: #fff; }
.conversation-header h1 { font-size: 20px; margin: 0; overflow-wrap: anywhere; }
.conversation-address { color: #60716b; font-size: 12px; margin: 5px 0; overflow-wrap: anywhere; }
.conversation-header button.secondary { width: auto; margin: 0; padding: 9px 12px; font-size: 13px; }
.conversation-header > div:first-child { min-width: 0; }
.conversation-controls { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; max-width: 50%; }
.sound-controls { display: grid; gap: 10px; }
.sound-controls #app-sound { margin-top: 0; justify-content: center; padding: 10px; font-size: 13px; }
.sound-controls #test-sound { margin: 0; justify-self: start; }
[role=switch][aria-checked=false] { color: #60716b; background: #edf0ee; }
.muted-label { color: #60716b; }
.peer-status { font-size: 12px; color: #60716b; }
.message-list { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 20px 24px; }
.chat-description { color: #60716b; font-size: 12px; line-height: 1.6; align-self: center; text-align: center; max-width: 440px; }
.message-bubble { align-self: flex-start; background: #fff; max-width: 85%; min-width: 100px; border-radius: 10px; padding: 10px 13px; box-shadow: 0 1px 2px #163e2820; }
.message-bubble.outgoing { background: #d9f3df; align-self: flex-end; }
.message-text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 15px; line-height: 1.5; margin: 0; }
.message-meta { display: flex; justify-content: flex-end; align-items: center; gap: 7px; font-size: 11px; color: #60716b; margin-top: 5px; }
.message-ticks { font-size: 16px; letter-spacing: -3px; padding-right: 3px; }
.message-ticks.read { color: #0879b2; }
.message-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 7px; }
.message-actions button { font-size: 11px; }
.tombstone { font-style: italic; color: #60716b; }
.message-composer { background: #fff; border-top: 1px solid #dce4dd; display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 14px 20px; }
.message-composer textarea { flex: 1; min-width: 0; resize: none; font: inherit; font-size: 15px; line-height: 1.4; padding: 10px 12px; border: 1px solid #a8b9b0; border-radius: 9px; }
.message-composer textarea:focus-visible { outline: 2px solid #77c9ae; }
.message-composer button[type=submit] { width: auto; padding: 12px 16px; }
.message-composer .form-error { flex-basis: 100%; min-height: 0; margin: 0; }
.message-composer .form-error:empty { display: none; }
.editing-label { flex-basis: 70%; font-size: 12px; }
.message-request { padding: 12px 24px; background: #fff7e6; font-size: 13px; }
.message-request button.secondary { width: auto; display: inline-flex; margin: 0 8px 0 0; padding: 8px 14px; }
.chat-key-warning { margin: 0; border-radius: 0; padding: 10px 20px; font-size: 12px; }
.chat-key-warning button { margin-left: 12px; font-size: 12px; }
.load-earlier { align-self: center; font-size: 12px; width: auto; padding: 8px; }
.contact-preview { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.unread-badge { background: #087e62; color: #fff; padding: 2px 7px; border-radius: 10px; justify-self: end; }
@media (max-width: 600px) {
  main:has(.chat-empty) { padding: 54px 0 0; }
  .chat-empty { height: calc(100svh - 54px); min-height: 0; border-radius: 0; grid-template-rows: auto minmax(0, 1fr); }
  .chat-sidebar { max-height: 190px; padding: 10px 16px; gap: 8px; }
  .chat-sidebar .wordmark { font-size: 24px; }
  .chat-sidebar #new-chat, .chat-sidebar #logout { width: auto; padding: 7px 12px; font-size: 12px; }
  .chat-sidebar .helper { margin: 0; }
  .contact-list { display: flex; overflow-x: auto; flex-shrink: 0; }
  .contact-item { min-width: 150px; max-width: 240px; padding: 9px; }
  .conversation-header { padding: 10px 14px; gap: 8px; }
  .conversation-header h1 { font-size: 16px; }
  .message-list { padding: 12px; }
  .message-composer { padding: 10px; }
}
.file-card { display: flex; flex-direction: column; gap: 8px; min-width: 200px; padding: 6px 0; overflow-wrap: anywhere; }
.file-card strong { font-size: 14px; }
.file-size, .file-state, .file-progress-text { font-size: 12px; color: #526a60; }
.file-card progress { width: 100%; height: 6px; accent-color: #087e62; }
.file-actions { display: flex; gap: 14px; flex-wrap: wrap; }
.file-actions button { font-size: 12px; }
.file-picker { display: none; }
.message-composer #attach-file { width: auto; padding: 8px 10px; margin: 0; font-size: 12px; }
.file-hashing { font-size: 12px; flex-basis: 100%; }
.file-viewer { width: min(90vw, 950px); max-height: 90svh; border: 1px solid #bdd0c3; border-radius: 14px; padding: 20px; color: #172e2c; }
.file-viewer::backdrop { background: #122c27aa; }
.file-viewer header { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.file-viewer h2 { font-size: 18px; overflow-wrap: anywhere; }
.file-viewer-content { overflow: auto; max-height: 65svh; margin: 15px 0; }
.file-viewer-content img, .file-viewer-content video { max-width: 100%; max-height: 60svh; display: block; margin: auto; }
.file-viewer-content audio { max-width: 100%; }
.file-viewer-content pre { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13px; }
.file-download { display: inline-block; padding: 10px 0; }
@media (max-width: 600px) { .file-card { min-width: 160px; } .message-composer #attach-file { flex-basis: 100%; } }
.file-recipient-summary { font-size: 12px; font-weight: 600; }
.file-device-progress { margin: 0; padding: 0; display: grid; gap: 7px; list-style: none; }
.file-device-progress li { display: grid; grid-template-columns: 1fr; gap: 3px; padding-top: 7px; border-top: 1px solid #bfd3c4; font-size: 11px; }
.file-device-name { font-weight: 600; }
.file-device-state { color: #526a60; }
.file-error-reason { font-size: 11px; line-height: 1.5; margin: 0; color: #8b3c1b; }
.pasted-files { flex-basis: 100%; display: flex; flex-wrap: wrap; align-items: center; gap: 10px; max-height: 190px; overflow: auto; }
.pasted-file { display: flex; flex-direction: column; gap: 4px; max-width: 130px; }
.pasted-file img { width: 110px; height: 90px; object-fit: contain; border-radius: 7px; background: #edf2ee; }
.pasted-file-hint { font-size: 12px; color: #4b665a; }
.pasted-file-chip { display: grid; gap: 4px; padding: 10px; border: 1px solid #c1d1c7; border-radius: 7px; background: #f2f6f3; font-size: 12px; overflow-wrap: anywhere; }
.file-drag-over { outline: 3px dashed #087e62; outline-offset: -4px; background: #e5f4eb; }
/* WM5: persistent media panel lives outside chat's re-rendered root. */
.call-panel { position: fixed; z-index: 5; inset: max(16px, 8vh) max(16px, calc((100vw - 850px) / 2)); background: #173a34; color: #fff; border-radius: 18px; padding: 24px; box-shadow: 0 15px 90px #081f2866; display: flex; flex-direction: column; gap: 12px; max-height: 85svh; overflow: auto; }
.call-panel[hidden], .call-panel [hidden] { display: none; }
.call-panel h2 { margin: 0; font-size: 21px; overflow-wrap: anywhere; }
.call-panel p { margin: 0; }
.call-panel #call-status { color: #c6ded5; }
.call-media { position: relative; min-height: 150px; flex: 1; display: grid; place-items: center; background: #102d29; border-radius: 10px; overflow: hidden; }
.call-media #call-remote { width: 100%; max-height: 45svh; object-fit: contain; }
.call-media #call-remote.audio-only { position: absolute; width: 1px; height: 1px; opacity: 0; }
.call-placeholder { padding: 54px 16px; color: #b6d7c8; }
.call-media #call-local { position: absolute; right: 10px; bottom: 10px; width: min(25%, 150px); max-height: 120px; border-radius: 8px; background: #071e18; }
.call-controls { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.call-controls button { width: auto; min-width: 70px; max-width: 96px; padding: 4px; font-size: 12px; background: transparent; color: #fff; flex-direction: column; align-items: center; gap: 6px; }
.call-controls .button-icon { width: 24px; height: 24px; padding: 12px; box-sizing: content-box; border-radius: 50%; background: #2b6859; }
.call-controls .button-label { min-height: 2.2em; line-height: 1.2; text-align: center; }
.call-controls #call-hangup .button-icon, .call-controls #call-decline .button-icon { background: #ad353c; }
.call-controls [data-active=true] .button-icon { background: #d8eae2; color: #173a34; }
.call-panel .call-error { color: #ffcfb5; font-size: 14px; }
.call-quality { color: #c6ded5; font-size: 12px; }
.call-history { padding: 12px 20px; background: #f6f8f5; max-height: 180px; overflow: auto; flex-shrink: 0; }
.call-history h2 { font-size: 15px; margin: 0 0 10px; }
.call-history ul { list-style: none; margin: 0; padding: 0; }
.call-history li { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12px; padding: 6px 0; }
@media (max-width: 600px) { .call-panel { inset: 10px; padding: 18px; max-height: calc(100svh - 20px); } .conversation-controls { max-width: 60%; } .conversation-controls button.secondary { padding: 6px 8px; font-size: 11px; } }
.call-panel[data-phase=idle] { inset: auto 16px 16px auto; width: min(400px, calc(100vw - 32px)); max-height: 40svh; padding: 18px; }
.call-panel[data-phase=idle] h2 { font-size: 15px; }

/* Lucide ISC/MIT SVG symbols; semantic buttons retain EN/ES accessible names. */
.button-icon { width: 22px; height: 22px; flex: 0 0 auto; pointer-events: none; }
.has-icon { display: inline-flex; align-items: center; justify-content: center; gap: 9px; }
.icon-control { min-width: 44px; min-height: 44px; border-radius: 50%; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.conversation-header .conversation-controls button.icon-control { width: 44px; height: 44px; padding: 10px; }
.message-composer button.icon-control, .message-composer #attach-file.icon-control { width: 44px; height: 44px; padding: 10px; }
.message-actions button.icon-control { padding: 10px; }
.pasted-file button.icon-control { width: 44px; height: 44px; padding: 10px; }
.call-panel .call-controls button[hidden] { display: none; }
/* Conversation uses available viewport; menus are overlays with no message reflow. */
main:has(.chat-empty) { padding: 36px 8px 8px; height: 100dvh; min-height: 0; display: block; }
.chat-empty { width: 100%; height: calc(100dvh - 44px); min-height: 0; grid-template-columns: clamp(250px, 22vw, 300px) minmax(0, 1fr); border-radius: 8px; }
main:has(.chat-empty) ~ .language-choice { top: 8px; }
.conversation-header { padding: 10px 14px; }
.conversation-title { min-width: 0; flex: 1; }
.conversation-header h1 { font-size: 18px; }
.message-composer { padding: 9px 14px; }
.message-text { font-size: 16px; }
.message-bubble { position: relative; flex-shrink: 0; padding-right: 38px; max-width: min(85%, 840px); }
.message-actions { position: absolute; top: 1px; right: 2px; margin: 0; display: block; }
.message-actions .message-menu-toggle { width: 32px; min-width: 32px; height: 32px; min-height: 32px; padding: 6px; color: #60716b; background: transparent; opacity: 0; }
.message-bubble:hover .message-menu-toggle, .message-bubble:focus-within .message-menu-toggle, .message-menu-toggle[aria-expanded=true] { opacity: 1; }
.message-options { position: absolute; top: 32px; left: 0; width: 190px; padding: 5px; background: #fff; color: #172e2c; border: 1px solid #d6e1da; border-radius: 9px; box-shadow: 0 5px 24px #163e2830; z-index: 3; max-height: 55dvh; overflow: auto; }
.outgoing .message-options, .message-actions.menu-right .message-options { left: auto; right: 0; }
.message-actions.menu-left .message-options { left: 0; right: auto; }
.message-actions.menu-up .message-options { top: auto; bottom: 100%; }
.message-options[hidden], .message-options [hidden] { display: none; }
.message-options button { width: 100%; min-height: 40px; display: flex; padding: 9px 12px; margin: 0; border-radius: 5px; background: transparent; color: #172e2c; text-align: left; font-size: 14px; font-weight: 400; text-decoration: none; }
.message-options button:hover, .message-options button:focus-visible { background: #edf3ef; }
.message-options button.has-icon { justify-content: flex-start; }
.message-options .button-icon { width: 18px; height: 18px; flex: 0 0 18px; }
.message-options .reaction-picker { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 3px; }
.message-options .reaction-picker[hidden] { display: none; }
.reaction-picker button { justify-content: center; font-size: 23px; padding: 8px; }
.reaction-picker [aria-checked=true] { background: #d9f3df; }
.reaction-picker button.reaction-back { grid-column: 1 / -1; font-size: 13px; }
.message-reactions { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.reaction-group { position: relative; }
.reaction-chip { width: auto; min-height: 30px; padding: 4px 8px; border-radius: 15px; border: 1px solid #dce4dd; background: #fff; color: #172e2c; font-size: 14px; font-weight: 400; }
.reaction-chip[data-own=true] { border-color: #087e62; background: #edf8ef; }
.reaction-names { position: absolute; bottom: 100%; left: 0; padding: 8px 10px; min-width: 120px; max-width: 220px; font-size: 12px; border-radius: 6px; background: #173a34; color: #fff; z-index: 2; overflow-wrap: anywhere; }
.message-quote { position: relative; display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 4px; width: 100%; min-height: 46px; padding: 8px 10px; margin: 0 0 8px; border-left: 3px solid #087e62; border-radius: 5px; background: #163e2809; color: #526a60; text-align: left; font-weight: 400; }
.message-quote strong { color: #075e54; font-size: 12px; }
.quote-text { font-size: 13px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
.message-quote:has(img) { padding-right: 60px; }
.message-quote img { position: absolute; right: 5px; top: 5px; width: 42px; height: 42px; object-fit: cover; border-radius: 4px; }
.reply-draft { flex-basis: 100%; display: flex; align-items: center; gap: 6px; }
.reply-draft .message-quote { margin: 0; }
.reply-draft button.icon-control { flex: 0 0 44px; }
.message-highlight { outline: 2px solid #43ae88; outline-offset: 2px; }
#show-chats { display: none; }
@media (hover: none) { .message-actions .message-menu-toggle { opacity: 1; } }
@media (max-width: 600px) {
  main:has(.chat-empty) { padding: 36px 0 0; }
  .chat-empty { height: calc(100dvh - 36px); grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); border-radius: 0; }
  .chat-empty[data-sidebar-collapsed=true] { grid-template-rows: minmax(0, 1fr); }
  .chat-empty[data-sidebar-collapsed=true] .chat-sidebar { display: none; }
  .chat-sidebar { max-height: min(240px, 35dvh); }
  .conversation-header { gap: 5px; padding: 7px 9px; }
  .conversation-header h1 { font-size: 16px; }
  .conversation-controls { gap: 2px; }
  .conversation-header .conversation-controls button.icon-control { width: 36px; height: 36px; min-width: 36px; min-height: 36px; padding: 7px; }
  #show-chats { display: inline-flex; width: 36px; min-width: 36px; padding: 6px; }
  #show-chats .button-icon { transform: rotate(90deg); }
  .message-list { padding: 10px; }
  .message-composer { padding: 8px; }
}
.message-quote:disabled { opacity: 1; cursor: default; }
.message-quote:hover { background: #163e2812; }
.message-composer #attach-file.icon-control { flex: 0 0 44px; }
/* CSS Positioned Layout 3 §§2.1,3.5: reserve the status column and menu hitbox. */
.message-bubble.outgoing { padding-right: 104px; min-height: 46px; }
.outgoing > .message-actions { right: 66px; }
.message-meta .message-ticks { position: absolute; top: 8px; right: 6px; font-size: 12px; line-height: 1; }
.outgoing > .message-meta > time { position: absolute; top: 22px; right: 6px; line-height: 14px; white-space: nowrap; }
/* WCAG 2.2 §1.4.3; Media Queries 5 prefers-color-scheme. Opaque readable bubbles. */
.chat-background { --wallpaper: #f2eee6; --wallpaper-dot: #dad8cf; --bubble-in: #fff; --bubble-out: #d9f3df; --bubble-text: #172e2c; --bubble-muted: #435b53; --bubble-link: #086246; --bubble-read: #006b9e; --quote-bg: #e5ece7; --bubble-error: #874600; }
.background-sand { --wallpaper: #f2eee6; --wallpaper-dot: #dad8cf; }
.background-sage { --wallpaper: #e9f0e9; --wallpaper-dot: #cddbcf; }
.background-sky { --wallpaper: #eaf0f6; --wallpaper-dot: #cfdae5; }
.background-rose { --wallpaper: #f6ecee; --wallpaper-dot: #e2cfd4; }
.background-plain { --wallpaper: #f4f6f5; --wallpaper-dot: transparent; }
.chat-background .message-list, .background-preview, .wallpaper-swatch { background-color: var(--wallpaper); background-image: radial-gradient(circle, var(--wallpaper-dot) .7px, transparent .8px); background-size: 24px 24px; }
.chat-background .message-bubble { background: var(--bubble-in); color: var(--bubble-text); }
.chat-background .message-bubble.outgoing { background: var(--bubble-out); }
.chat-background .message-meta, .chat-background .tombstone, .chat-background .chat-description, .chat-background .message-actions .message-menu-toggle { color: var(--bubble-muted); }
.chat-background .message-ticks.read { color: var(--bubble-read); }
.chat-background .message-quote, .chat-background .message-quote:hover { background: var(--quote-bg); color: var(--bubble-muted); }
.chat-background .message-quote strong { color: var(--bubble-text); }
.chat-background .file-card p, .chat-background .file-device-progress { color: var(--bubble-muted); }
.chat-background .file-size, .chat-background .file-state, .chat-background .file-progress-text, .chat-background .file-device-state { color: var(--bubble-muted); }
.chat-background .file-card button, .chat-background .file-card a { color: var(--bubble-link); }
.chat-background .file-card .file-error-reason { color: var(--bubble-error); }
.background-dialog { width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 32px); overflow-y: auto; padding: 24px; border: 1px solid #c7d7cc; border-radius: 16px; color: #172e2c; background: #fff; }
.background-dialog::backdrop { background: #122c2777; }
.background-dialog header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.background-dialog h2 { margin: 0; font-size: 22px; }
.background-dialog #close-background { width: 44px; padding: 10px; margin: 0; background: #edf3ef; color: #172e2c; }
.background-dialog fieldset { border: 0; padding: 0; margin: 20px 0 0; min-width: 0; }
.background-dialog legend { font-size: 14px; font-weight: 600; padding: 0 0 10px; }
.background-choices { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.background-choice { position: relative; display: grid; gap: 5px; text-align: center; font-size: 12px; cursor: pointer; }
.background-choice input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.wallpaper-swatch { display: grid; place-items: center; height: 48px; border: 2px solid #dbe4de; border-radius: 9px; color: #435b53; font-size: 22px; }
.background-choice:has(input:checked) .wallpaper-swatch { border-color: #087e62; box-shadow: inset 0 0 0 2px #fff; }
.background-choice:has(input:focus-visible) .wallpaper-swatch { outline: 2px solid #075e54; outline-offset: 3px; }
.background-preview { display: flex; flex-direction: column; gap: 8px; padding: 18px; border-radius: 10px; }
.background-preview .message-bubble { margin: 0; min-width: 0; max-width: 90%; padding: 9px 12px; font-size: 14px; }
.background-status { min-height: 1.5em; font-size: 12px; margin: 12px 0 0; color: #435b53; }
#background-settings { margin-top: 0; padding: 10px; font-size: 13px; }
@media (prefers-color-scheme: dark) {
  .chat-background { --bubble-in: #2d3935; --bubble-out: #174b3b; --bubble-text: #f1f5f2; --bubble-muted: #c2d0c8; --bubble-link: #9fe6c8; --bubble-read: #70c8ff; --quote-bg: #253e34; --bubble-error: #ffd79b; }
  .background-sand { --wallpaper: #252521; --wallpaper-dot: #3a3932; }
  .background-sage { --wallpaper: #1e2b28; --wallpaper-dot: #34433b; }
  .background-sky { --wallpaper: #202a35; --wallpaper-dot: #354554; }
  .background-rose { --wallpaper: #30252c; --wallpaper-dot: #493740; }
  .background-plain { --wallpaper: #23292c; --wallpaper-dot: transparent; }
  .wallpaper-swatch { color: #e4eee8; }
}
