body.chat-active footer{display:none}
body.chat-active #app{height:100dvh;display:flex;flex-direction:column;overflow:hidden}
body.chat-active #app>.environment,body.chat-active #app>header{flex-shrink:0}
body.chat-active #main{flex:1;min-height:0}
.chat-page{padding-top:26px;padding-bottom:20px}.chat-title{display:flex;align-items:center;justify-content:space-between;gap:20px;margin-bottom:20px}.chat-title h1{font-size:32px;margin:0}
.chat-shell{display:grid;grid-template-columns:310px minmax(0,1fr);height:calc(100dvh - 220px);min-height:470px;max-height:950px;border:1px solid var(--line);border-radius:20px;background:white;overflow:hidden}
.chat-sidebar{display:flex;flex-direction:column;min-height:0;border-right:1px solid var(--line);background:#fffdfa}
.chat-search{display:flex;align-items:center;gap:10px;margin:18px;padding:4px 12px;background:#f5f0ec;border-radius:12px;color:var(--muted)}.chat-search input{background:none;border:0;padding:9px 0;min-width:0}
.chat-inbox{overflow:auto;flex:1;min-height:0}.chat-contact{display:flex;gap:12px;align-items:center;border:0;border-bottom:1px solid var(--line);background:none;padding:17px 16px;width:100%;text-align:left;color:var(--ink);min-height:100px}.chat-contact:hover{background:#fff1ec}.chat-contact.selected{background:#f0eafb;box-shadow:inset 3px 0 var(--purple)}
.chat-avatar{display:block;width:48px;height:48px;border-radius:50%;overflow:hidden;flex-shrink:0}.chat-avatar .portrait{height:56px;width:48px;object-fit:cover}.chat-avatar .avatar-label{display:none}
.chat-contact-text{flex:1;min-width:0;line-height:1.5}.chat-contact-text strong{display:block;font-size:1rem;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.chat-contact-text>span{display:-webkit-box;-webkit-line-clamp:1;-webkit-box-orient:vertical;overflow:hidden;color:var(--muted);font-size:.875rem;margin-top:3px}.chat-contact-text small{font-size:.875rem;display:block;color:var(--purple);margin-top:5px}
.chat-unread{border-radius:20px;min-width:24px;height:24px;display:grid;place-items:center;background:var(--coral);color:#fff;font-size:.875rem}.chat-inbox-pages{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:5px 16px;border-top:1px solid var(--line);font-size:.875rem}.chat-empty-inbox{padding:30px 22px;color:var(--muted);font-size:1rem}.chat-receipt-choice{margin:15px 18px 0}.chat-receipt-hint{margin:10px 18px 18px}
.chat-panel{display:flex;flex-direction:column;min-width:0;min-height:0;background:#fff9f6}.chat-peer-header{display:flex;align-items:center;gap:13px;min-height:82px;padding:15px 23px;background:white;border:0;border-bottom:1px solid var(--line)}.chat-peer-header>div{min-width:0;flex:1}.chat-peer-header strong{display:block;font-size:1rem}.chat-peer-header small{display:block;color:var(--muted);font-size:.875rem;margin-top:4px}.chat-peer-header .text-button{margin-left:auto}.chat-back{display:none;font-size:24px;min-width:32px}
.chat-peer-header>.chat-peer-actions{flex:0 0 auto;display:flex;flex-direction:column;align-items:flex-end;gap:0}.chat-peer-actions .text-button{padding:3px 0;min-height:30px;font-size:.875rem}
.chat-empty{margin:auto;text-align:center;padding:40px;max-width:520px}.chat-empty>svg{color:var(--purple);margin-bottom:25px}.chat-empty h2{font-size:28px}.chat-empty p{font-size:1rem;color:var(--muted);margin-bottom:25px}
.chat-introduction{max-width:650px;padding:35px;overflow:auto}.chat-introduction>p{font-size:1rem;color:var(--muted)}.chat-introduction h2{font-size:25px}.chat-introduction .small-link{display:inline-block;margin-top:20px}
.chat-log{overflow:auto;flex:1;min-height:0;padding:24px 28px;overscroll-behavior:contain;scrollbar-gutter:stable}.chat-log>#older-messages{display:block;margin:0 auto 25px;font-size:.875rem}.chat-log>#older-messages[hidden]{display:none}.message-row{display:flex;margin:0 0 13px}.message-row.mine{justify-content:flex-end}.message-bubble{max-width:78%;padding:13px 17px;border:1px solid #e9e1dd;background:white;border-radius:16px 16px 16px 4px;overflow-wrap:anywhere;min-width:100px}.mine .message-bubble{background:#efe6fb;border-color:#e4d8f3;border-radius:16px 16px 4px 16px}.message-bubble p{font-size:1rem;line-height:1.6;margin:0;white-space:pre-wrap}.message-meta{display:flex;justify-content:flex-end;align-items:center;gap:8px;font-size:.875rem;color:var(--muted);margin-top:7px;min-height:20px}.message-ticks{color:#716e79;font-size:16px;font-weight:650;white-space:nowrap;letter-spacing:-3px;padding-right:3px}.message-ticks.read{color:#1769bd}.message-meta button{background:none;border:0;font-size:20px;color:var(--muted);min-width:32px;min-height:28px;padding:0}.message-photo{max-width:280px;max-height:300px;width:100%;height:auto;object-fit:contain;border-radius:10px;display:block;margin-bottom:5px}.chat-no-messages{text-align:center;color:var(--muted);font-size:1rem;margin:50px 10px}
.chat-compose{background:white;padding:14px 20px 10px;border-top:1px solid var(--line)}.chat-compose-row{display:flex;gap:12px;align-items:flex-end}.chat-compose-text{flex:1;min-width:0}.chat-compose textarea{display:block;resize:none;min-height:54px;max-height:150px;background:#f8f5f1;border-color:#ebe4dd;font-size:1rem;border-radius:14px;padding:14px;line-height:1.5}.chat-compose button.primary{width:48px;height:48px;min-width:48px;padding:0;border-radius:50%}.chat-attach{display:grid;place-items:center;color:var(--purple);width:34px;height:48px;position:relative;overflow:hidden;cursor:pointer;flex-shrink:0}.chat-attach input{position:absolute;inset:0;opacity:0;cursor:pointer;width:100%;height:100%}.chat-selected-photo{display:flex;align-items:center;justify-content:space-between;gap:10px;font-size:.875rem;overflow-wrap:anywhere}.chat-compose-help{margin:9px 0 0;font-size:.875rem}.chat-connection{font-size:.875rem;color:#8c343e;margin:10px 0;line-height:1.5}
@media(max-width:1000px){.chat-shell{grid-template-columns:275px minmax(0,1fr)}.chat-peer-header{padding:15px}.chat-peer-header .text-button{font-size:.875rem}.chat-log{padding:20px}.message-bubble{max-width:88%}.chat-title .eyebrow{display:none}}
@media(max-width:760px){
 .chat-page{padding:12px 12px 90px}.chat-title{margin:0 8px 12px}.chat-title h1{font-size:25px}
 .chat-shell{display:flex;flex-direction:column;height:calc(100dvh - 240px);min-height:300px;border-radius:15px;max-height:none}.chat-sidebar,.chat-panel{height:100%;width:100%}.chat-sidebar{border:0}.chat-shell.thread-open .chat-sidebar{display:none}.chat-shell:not(.thread-open) .chat-panel{display:none}
 .chat-back{display:block}.chat-peer-header{gap:8px;padding:12px;min-height:72px}.chat-peer-header .chat-avatar{width:36px;height:36px}.chat-peer-header .chat-avatar .portrait{width:36px;height:42px}.chat-peer-header .text-button{max-width:90px;text-align:right;line-height:1.5}.chat-peer-header small{font-size:.875rem}
 .chat-log{padding:18px 12px}.message-bubble{max-width:88%;padding:11px 13px}.message-photo{max-width:220px}.chat-compose{padding:10px}.chat-compose-row{gap:8px}.chat-compose textarea{padding:12px;min-height:50px}.chat-compose-help{display:none}.chat-introduction{padding:25px 20px}.chat-empty{padding:30px 22px}.chat-receipt-hint{max-height:75px;overflow:auto}.chat-empty h2{font-size:24px}
}
/* Let the actual header/navigation height determine the available chat area. */
.chat-page{height:100%;display:flex;flex-direction:column}.chat-title{flex-shrink:0}
.chat-shell{height:auto;max-height:none;min-height:0;flex:1}.chat-connection{flex-shrink:0}.chat-connection:empty{display:none}
@media(max-width:760px){body.chat-active .mobile-nav{position:static;flex-shrink:0}.chat-page{padding-bottom:12px}}
.chat-compose-tools{display:flex;align-items:center;margin:0 0 7px;flex-shrink:0}
.chat-compose-tools .text-button{display:inline-flex;gap:7px;align-items:center;font-size:.9375rem;min-height:40px;padding:5px 8px;text-align:left}
.message-contact-link{color:#493093;text-decoration:underline;text-underline-offset:3px;overflow-wrap:anywhere}
.share-contact-options{border:0;margin:20px 0;padding:0;display:grid;gap:12px}
.share-contact-option{display:flex;align-items:flex-start;gap:12px;border:1px solid var(--line);border-radius:12px;padding:16px;cursor:pointer}
.share-contact-option input{width:20px;height:20px;min-height:20px;flex-shrink:0;margin:4px 0 0;accent-color:var(--purple)}
.share-contact-option>span{display:flex;flex-direction:column;gap:5px;min-width:0}
.share-contact-option>span>span{font-size:.9375rem;line-height:1.6;overflow-wrap:anywhere;color:var(--muted)}
.share-contact-option:has(input:checked){border-color:var(--purple);background:#f6f0ff}
.share-contact-option:has(input:disabled){background:#f8f5f4;cursor:default}
.contact-share-preview{white-space:pre-wrap;overflow-wrap:anywhere;font-family:inherit;font-size:1rem;line-height:1.65;border:1px solid var(--line);border-radius:12px;background:#faf7fb;padding:16px}
#chat-share-form .form-actions{flex-wrap:wrap}
#chat-share-form .form-actions button{max-width:100%;white-space:normal}
#modal:has(#chat-share-form){width:min(620px,calc(100vw - 32px));max-height:calc(100dvh - 32px);padding:24px;overflow:auto}
#chat-share-form .share-contact-options{margin:14px 0;gap:8px}
#chat-share-form .share-contact-option{padding:12px}
#chat-share-form h3{margin-top:18px}
