:root {
  color-scheme: dark;
  --bg: #08111f;
  --surface: #101b2d;
  --surface-2: #152238;
  --surface-3: #1d2c45;
  --text: #f5f7fb;
  --muted: #91a0b8;
  --line: rgba(255,255,255,.08);
  --accent: #5b8cff;
  --accent-2: #7aa2ff;
  --danger: #ef5b68;
  --success: #52c98f;
  --shadow: 0 18px 55px rgba(0,0,0,.35);
  --radius: 18px;
}
* { box-sizing: border-box; }
html, body, #app { width:100%; height:100%; min-height:100%; margin:0; }
body { font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; background:var(--bg); color:var(--text); overflow:hidden; }
button, input, textarea { font:inherit; }
button { cursor:pointer; }
.hidden { display:none !important; }
.muted { color:var(--muted); }
.muted-inline { color:var(--muted); font-weight:400; font-size:.85em; }
.auth-view { min-height:100dvh; display:grid; place-items:center; padding:24px; background:radial-gradient(circle at 20% 20%, rgba(91,140,255,.15), transparent 36%), radial-gradient(circle at 90% 80%, rgba(82,201,143,.08), transparent 34%), var(--bg); }
.auth-card { width:min(440px, 100%); background:rgba(16,27,45,.9); border:1px solid var(--line); border-radius:26px; padding:30px; box-shadow:var(--shadow); backdrop-filter:blur(18px); }
.auth-card h1 { margin:14px 0 4px; font-size:28px; }
.auth-card > p { margin:0 0 22px; }
.brand-lock, .placeholder-badge { width:54px; height:54px; border-radius:18px; display:grid; place-items:center; background:linear-gradient(145deg, var(--accent), #7968ff); font-weight:800; letter-spacing:.02em; box-shadow:0 10px 30px rgba(91,140,255,.32); }
.tabs { display:flex; background:rgba(255,255,255,.04); padding:4px; border-radius:14px; margin:18px 0; }
.tab { flex:1; border:0; border-radius:11px; padding:10px; color:var(--muted); background:transparent; }
.tab.active { color:var(--text); background:var(--surface-3); }
.stack { display:grid; gap:14px; }
label { display:grid; gap:7px; color:#cbd5e1; font-size:14px; font-weight:600; }
input, textarea { width:100%; border:1px solid var(--line); border-radius:12px; background:#0b1526; color:var(--text); padding:12px 13px; outline:none; transition:border-color .15s, box-shadow .15s; }
input:focus, textarea:focus { border-color:rgba(91,140,255,.8); box-shadow:0 0 0 3px rgba(91,140,255,.12); }
.primary, .secondary, .danger { border:0; border-radius:12px; padding:11px 15px; font-weight:700; color:white; }
.primary { background:linear-gradient(135deg, var(--accent), #716dff); }
.secondary { background:var(--surface-3); }
.danger { background:rgba(239,91,104,.14); color:#ff9aa3; border:1px solid rgba(239,91,104,.24); }
.wide { width:100%; }
.server-details { color:var(--muted); font-size:13px; }
.server-details summary { cursor:pointer; margin-bottom:10px; }
.alert { padding:11px 13px; border-radius:12px; margin-top:14px; font-size:14px; }
.alert.error { background:rgba(239,91,104,.12); color:#ff9aa3; border:1px solid rgba(239,91,104,.22); }
.messenger { width:100%; height:100dvh; min-height:0; overflow:hidden; display:grid; grid-template-columns:360px minmax(0,1fr); background:var(--bg); }
.sidebar { min-width:0; min-height:0; overflow:hidden; border-right:1px solid var(--line); background:var(--surface); display:flex; flex-direction:column; }
.sidebar-header, .chat-header { height:70px; min-height:70px; display:flex; align-items:center; gap:12px; padding:0 16px; border-bottom:1px solid var(--line); }
.avatar-button, .chat-avatar, .large-avatar { display:grid; place-items:center; border-radius:50%; background:linear-gradient(145deg, #385ea9, #4f46e5); color:white; font-weight:800; border:0; }
.avatar-button { width:42px; height:42px; }
.chat-avatar { width:42px; height:42px; flex:0 0 auto; }
.large-avatar { width:66px; height:66px; font-size:22px; }
.brand-copy, .chat-title-wrap { min-width:0; display:grid; gap:2px; flex:1; }
.brand-copy strong, .chat-title-wrap strong { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.connection { font-size:12px; color:var(--muted); }
.connection.online { color:var(--success); }
.icon-button { width:38px; height:38px; border:0; border-radius:11px; background:transparent; color:var(--muted); font-size:22px; display:grid; place-items:center; }
.icon-button:hover { background:rgba(255,255,255,.06); color:var(--text); }
.search-wrap { position:relative; padding:12px; border-bottom:1px solid var(--line); }
.search-wrap input { background:#0b1526; }
.search-results { position:absolute; z-index:20; left:12px; right:12px; top:62px; max-height:320px; overflow:auto; border:1px solid var(--line); border-radius:14px; background:var(--surface-2); box-shadow:var(--shadow); }
.search-user, .picker-user { width:100%; border:0; color:var(--text); background:transparent; display:flex; align-items:center; gap:10px; padding:11px 12px; text-align:left; }
.search-user:hover, .picker-user:hover { background:rgba(255,255,255,.05); }
.mini-avatar { width:36px; height:36px; border-radius:50%; background:#29446f; display:grid; place-items:center; font-weight:700; flex:0 0 auto; }
.user-copy { min-width:0; display:grid; }
.user-copy span { font-size:12px; color:var(--muted); }
.chat-list { overflow:auto; min-height:0; flex:1; }
.chat-item { width:100%; border:0; border-bottom:1px solid rgba(255,255,255,.045); background:transparent; color:var(--text); display:grid; grid-template-columns:48px 1fr auto; gap:11px; padding:12px 14px; text-align:left; cursor:pointer; outline:none; }
.chat-item:hover, .chat-item.active { background:rgba(91,140,255,.10); }
.chat-item .chat-avatar { width:48px; height:48px; }
.chat-item-main { min-width:0; display:grid; gap:5px; align-content:center; }
.chat-item-top { display:flex; gap:8px; justify-content:space-between; align-items:center; }
.chat-item-title { font-weight:700; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.chat-remove-button { width:26px; height:26px; flex:0 0 auto; display:grid; place-items:center; border:0; border-radius:8px; background:transparent; color:var(--muted); font-size:13px; opacity:0; transition:opacity .12s, background .12s, color .12s; }
.chat-item:hover .chat-remove-button, .chat-item:focus-within .chat-remove-button, .chat-remove-button:focus-visible { opacity:1; }
.chat-remove-button:hover { background:rgba(239,91,104,.14); color:#ff9aa3; }
.chat-preview { color:var(--muted); font-size:13px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.chat-time { color:var(--muted); font-size:11px; white-space:nowrap; }
.chat-side { display:grid; justify-items:end; align-content:center; gap:7px; min-width:28px; }
.unread-badge { min-width:20px; height:20px; padding:0 6px; border-radius:999px; display:grid; place-items:center; background:var(--accent); color:white; font-size:11px; font-weight:800; }
.empty-state { padding:34px 24px; color:var(--muted); text-align:center; display:grid; gap:6px; }
.empty-state strong { color:#cbd5e1; }
.chat-panel { min-width:0; min-height:0; height:100%; overflow:hidden; background:radial-gradient(circle at 50% 35%, rgba(91,140,255,.06), transparent 35%), #0a1424; position:relative; }
.chat-panel.empty-chat { display:grid; place-items:center; }
.chat-placeholder { text-align:center; color:var(--muted); }
.chat-placeholder .placeholder-badge { margin:0 auto 18px; }
.chat-placeholder h2 { color:var(--text); margin:0 0 6px; }
.chat-placeholder p { margin:0; }
.active-chat { position:absolute; inset:0; min-width:0; min-height:0; overflow:hidden; display:grid; grid-template-rows:70px minmax(0,1fr) auto; }
.message-list { min-width:0; min-height:0; overflow-x:hidden; overflow-y:auto; overscroll-behavior:contain; scrollbar-gutter:stable; padding:20px clamp(14px,3vw,42px); display:flex; flex-direction:column; gap:7px; scroll-behavior:smooth; }
.message-list::-webkit-scrollbar { width:10px; }
.message-list::-webkit-scrollbar-thumb { background:rgba(145,160,184,.32); border:3px solid transparent; border-radius:999px; background-clip:padding-box; }
.message-list::-webkit-scrollbar-track { background:transparent; }
.message-row { display:flex; }
.message-row.mine { justify-content:flex-end; }
.bubble { position:relative; max-width:min(680px,78%); border:1px solid var(--line); background:var(--surface-2); border-radius:17px 17px 17px 5px; padding:9px 12px 7px; box-shadow:0 6px 18px rgba(0,0,0,.09); }
.message-row.mine .bubble { background:#284d92; border-color:rgba(122,162,255,.22); border-radius:17px 17px 5px 17px; }
.sender-name { font-size:12px; font-weight:700; color:var(--accent-2); margin-bottom:3px; }
.message-body { white-space:pre-wrap; overflow-wrap:anywhere; line-height:1.38; }
.message-meta { display:flex; justify-content:flex-end; align-items:center; gap:6px; margin-top:4px; color:rgba(255,255,255,.56); font-size:10px; }
.receipt { letter-spacing:-1px; color:#9cc5ff; font-weight:800; }
.message-actions { position:absolute; top:-13px; right:6px; display:flex; gap:3px; opacity:0; transform:translateY(3px); transition:.12s ease; pointer-events:none; }
.message-row.mine .message-actions { right:auto; left:6px; }
.bubble:hover .message-actions, .bubble:focus-within .message-actions { opacity:1; transform:none; pointer-events:auto; }
.message-actions button { width:27px; height:27px; padding:0; border:1px solid var(--line); border-radius:9px; background:#0f1c2f; color:var(--muted); display:grid; place-items:center; font-size:13px; }
.message-actions button:hover { color:var(--text); background:var(--surface-3); }
.reply-quote { width:100%; display:grid; gap:2px; margin:0 0 6px; padding:5px 8px; text-align:left; border:0; border-left:3px solid var(--accent-2); border-radius:4px 8px 8px 4px; background:rgba(5,12,24,.22); color:var(--text); }
.reply-quote strong { font-size:11px; color:#a9c3ff; }
.reply-quote span { max-width:420px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; color:rgba(255,255,255,.68); font-size:11px; }
.message-row.flash .bubble { animation:message-flash 1s ease; }
@keyframes message-flash { 0%,100% { box-shadow:0 6px 18px rgba(0,0,0,.09); } 35% { box-shadow:0 0 0 3px rgba(91,140,255,.45), 0 6px 22px rgba(0,0,0,.2); } }
.attachment-card { display:grid; grid-template-columns:38px minmax(0,1fr) auto; align-items:center; gap:9px; min-width:min(360px,65vw); padding:7px; border:1px solid rgba(255,255,255,.08); border-radius:12px; background:rgba(3,10,20,.18); }
.attachment-icon { width:38px; height:38px; display:grid; place-items:center; border-radius:10px; background:rgba(255,255,255,.07); font-size:18px; }
.attachment-copy { min-width:0; display:grid; gap:2px; }
.attachment-copy strong { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-size:13px; }
.attachment-copy span { color:rgba(255,255,255,.58); font-size:10px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.attachment-open { border:0; border-radius:9px; padding:7px 9px; background:rgba(91,140,255,.18); color:#cfe0ff; font-size:11px; }
.attachment-open:disabled { opacity:.6; cursor:wait; }
.attachment-caption { margin-top:7px; }
.media-bubble { max-width:min(520px,74vw); padding:5px 5px 6px; overflow:visible; }
.media-bubble .message-actions { z-index:6; }
.media-bubble .reply-quote { margin:4px 4px 6px; width:calc(100% - 8px); }
.image-attachment, .video-attachment, .audio-attachment { min-width:min(260px,48vw); max-width:100%; overflow:hidden; border-radius:13px; background:rgba(3,10,20,.22); }
.audio-attachment { min-width:min(360px,66vw); padding-top:2px; }
.media-decrypting { min-height:150px; display:grid; place-items:center; align-content:center; gap:8px; padding:18px; color:var(--muted); font-size:12px; }
.audio-loading { min-height:74px; }
.media-lock { font-size:24px; }
.chat-image-button { width:100%; max-width:100%; padding:0; border:0; border-radius:12px; background:#07101d; overflow:hidden; display:block; cursor:zoom-in; }
.chat-image { display:block; width:100%; height:auto; max-height:min(420px,46dvh); object-fit:contain; background:#07101d; }
.chat-video { display:block; width:100%; max-width:100%; max-height:min(420px,46dvh); border-radius:12px; background:#020712; }
.chat-audio { display:block; width:min(360px,66vw); max-width:100%; height:46px; margin:8px 6px 4px; }
.media-error { padding:14px; color:#ff9aa3; font-size:12px; line-height:1.4; }
.media-footer { min-width:0; display:flex; align-items:center; justify-content:space-between; gap:10px; padding:7px 8px 3px; color:rgba(255,255,255,.62); font-size:10px; }
.media-footer > span { min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.media-download { flex:0 0 auto; color:#cfe0ff; text-decoration:none; font-weight:700; }
.media-download:hover { text-decoration:underline; }

.composer { flex:0 0 auto; position:relative; z-index:4; display:grid; grid-template-columns:auto minmax(0,1fr) auto; gap:10px; align-items:end; padding:12px 16px calc(12px + env(safe-area-inset-bottom)); border-top:1px solid var(--line); background:rgba(16,27,45,.88); backdrop-filter:blur(12px); }
.attachment-drafts { grid-column:1/-1; display:flex; gap:8px; overflow-x:auto; overflow-y:hidden; padding:1px 0 4px; scrollbar-width:thin; }
.attachment-draft { position:relative; flex:0 0 190px; height:58px; min-width:0; display:grid; grid-template-columns:48px minmax(0,1fr) auto; gap:8px; align-items:center; padding:5px 5px 5px 6px; border:1px solid var(--line); border-radius:12px; background:rgba(8,17,31,.78); overflow:hidden; }
.attachment-draft img, .attachment-draft video { width:48px; height:48px; border-radius:9px; object-fit:cover; background:#07101d; }
.draft-icon { width:48px; height:48px; border-radius:9px; display:grid; place-items:center; background:rgba(255,255,255,.06); font-size:22px; }
.draft-copy { min-width:0; display:grid; gap:3px; }
.draft-copy strong { font-size:11px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.draft-copy span { color:var(--muted); font-size:10px; }
.draft-remove { width:24px; height:24px; padding:0; border:0; border-radius:8px; background:rgba(255,255,255,.06); color:var(--muted); font-size:18px; line-height:1; }
.draft-remove:hover { background:rgba(239,91,104,.16); color:#ff9aa3; }
.draft-play { position:absolute; left:22px; top:21px; width:18px; height:18px; display:grid; place-items:center; border-radius:50%; background:rgba(0,0,0,.6); color:white; font-size:8px; pointer-events:none; }
.drop-overlay { position:absolute; inset:70px 0 0; z-index:9; display:grid; place-items:center; padding:24px; background:rgba(8,17,31,.82); backdrop-filter:blur(7px); pointer-events:none; }
.drop-overlay > div { width:min(460px,90%); min-height:190px; display:grid; place-items:center; align-content:center; gap:8px; padding:28px; border:2px dashed rgba(122,162,255,.55); border-radius:24px; background:rgba(91,140,255,.08); text-align:center; }
.drop-overlay span { width:52px; height:52px; display:grid; place-items:center; border-radius:50%; background:var(--accent); font-size:30px; }
.drop-overlay strong { font-size:18px; }
.drop-overlay small { color:var(--muted); line-height:1.4; }
.reply-preview { grid-column:1/-1; min-width:0; display:flex; align-items:center; gap:10px; padding:8px 10px; border-left:3px solid var(--accent); border-radius:8px; background:rgba(91,140,255,.08); }
.reply-preview > div { min-width:0; flex:1; display:grid; gap:2px; }
.reply-preview strong { font-size:12px; color:#b7ccff; }
.reply-preview span { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; color:var(--muted); font-size:11px; }
.reply-preview button { width:28px; height:28px; border:0; border-radius:8px; background:transparent; color:var(--muted); font-size:20px; }
.composer textarea { resize:none; max-height:150px; min-height:44px; padding:11px 13px; }
.attach-button, .send-button { width:44px; height:44px; flex:0 0 auto; border:0; border-radius:14px; color:white; font-size:18px; }
.attach-button { background:var(--surface-3); color:#b7c3d9; }
.attach-button:hover { color:white; background:#273a58; }
.send-button { background:var(--accent); }
.attach-button:disabled, .send-button:disabled { opacity:.5; cursor:not-allowed; }
.load-more { position:absolute; left:50%; transform:translateX(-50%); top:78px; z-index:3; border:1px solid var(--line); background:var(--surface-2); color:var(--text); border-radius:999px; padding:7px 12px; font-size:12px; }
.modal-backdrop { position:fixed; inset:0; z-index:40; background:rgba(0,0,0,.54); backdrop-filter:blur(4px); }
.modal { position:fixed; z-index:50; width:min(620px, calc(100% - 28px)); max-height:min(820px, calc(100dvh - 28px)); left:50%; top:50%; transform:translate(-50%,-50%); border:1px solid var(--line); border-radius:22px; background:var(--surface); box-shadow:var(--shadow); overflow:hidden; }
.modal.compact { width:min(520px, calc(100% - 28px)); }
.modal > header { height:62px; padding:0 18px; display:flex; align-items:center; justify-content:space-between; border-bottom:1px solid var(--line); }
.modal h2, .modal h3 { margin:0; }
.modal-body { max-height:calc(100dvh - 110px); overflow:auto; padding:18px; }
.profile-card { display:flex; align-items:center; gap:14px; padding:14px; border:1px solid var(--line); border-radius:16px; background:rgba(255,255,255,.025); }
.profile-card > div:last-child { display:grid; gap:3px; }
.pill { width:max-content; border-radius:999px; padding:3px 8px; font-size:11px; color:#b8c7ff; background:rgba(91,140,255,.13); }
.security-note { margin:16px 0 22px; padding:14px; border-radius:14px; background:rgba(255,180,64,.08); border:1px solid rgba(255,180,64,.18); }
.security-note p { margin:5px 0 0; color:#c5b99f; font-size:13px; line-height:1.45; }
.settings-list { display:grid; gap:8px; margin:10px 0 22px; }
.setting-row { display:flex; gap:10px; align-items:center; padding:11px 12px; border:1px solid var(--line); border-radius:13px; background:rgba(255,255,255,.02); }
.setting-row .grow { min-width:0; flex:1; display:grid; gap:2px; }
.setting-row .sub { font-size:12px; color:var(--muted); }
.section-heading { display:flex; justify-content:space-between; align-items:center; }
.invite-code { margin:10px 0; padding:12px; border:1px dashed rgba(91,140,255,.45); background:rgba(91,140,255,.08); border-radius:13px; word-break:break-all; }
.picker-results { max-height:190px; overflow:auto; border:1px solid var(--line); border-radius:12px; }
.picker-results:empty { display:none; }
.chips { display:flex; gap:7px; flex-wrap:wrap; }
.chip { border:1px solid var(--line); background:var(--surface-3); border-radius:999px; padding:7px 10px; display:flex; gap:7px; align-items:center; font-size:13px; }
.chip button { border:0; background:transparent; color:var(--muted); padding:0; }
.toast-stack { position:fixed; z-index:100; right:16px; bottom:16px; display:grid; gap:8px; width:min(360px, calc(100% - 32px)); }
.toast { border:1px solid var(--line); background:var(--surface-2); color:var(--text); border-radius:13px; padding:11px 13px; box-shadow:var(--shadow); animation:toast-in .2s ease-out; }
.toast.error { border-color:rgba(239,91,104,.24); }
@keyframes toast-in { from { transform:translateY(8px); opacity:0; } }
.mobile-only { display:none; }

.image-viewer { position:fixed; inset:0; z-index:90; display:grid; place-items:center; padding:28px; background:rgba(2,7,15,.92); backdrop-filter:blur(12px); }
.image-viewer img { display:block; max-width:min(96vw,1400px); max-height:calc(100dvh - 100px); object-fit:contain; border-radius:12px; box-shadow:0 24px 80px rgba(0,0,0,.55); }
.image-viewer-close { position:fixed; top:18px; right:18px; width:42px; height:42px; border:1px solid rgba(255,255,255,.12); border-radius:50%; background:rgba(16,27,45,.88); color:white; font-size:26px; line-height:1; }
.image-viewer-download { position:fixed; left:50%; bottom:18px; transform:translateX(-50%); padding:9px 14px; border-radius:999px; background:rgba(16,27,45,.92); border:1px solid rgba(255,255,255,.12); color:#dbe8ff; text-decoration:none; font-size:13px; font-weight:700; }

@media (max-width: 760px) {
  body { overflow:hidden; }
  .messenger { grid-template-columns:1fr; }
  .sidebar { position:absolute; inset:0; z-index:4; border-right:0; }
  .chat-panel { position:absolute; inset:0; z-index:5; transform:translateX(100%); transition:transform .18s ease-out; }
  .messenger.chat-open .chat-panel { transform:translateX(0); }
  .messenger.chat-open .sidebar { visibility:hidden; }
  .mobile-only { display:grid; }
  .bubble { max-width:88%; }
  .message-actions { opacity:.75; transform:none; pointer-events:auto; }
  .attachment-card { min-width:min(320px,78vw); }
  .media-bubble { max-width:88vw; }
  .image-attachment, .video-attachment { min-width:min(230px,70vw); }
  .audio-attachment { min-width:min(290px,82vw); }
  .chat-image, .chat-video { max-height:38dvh; }
  .chat-audio { width:min(320px,78vw); }
  .attachment-draft { flex-basis:170px; }
  .image-viewer { padding:12px; }
  .image-viewer img { max-width:96vw; max-height:calc(100dvh - 82px); }
  .composer { padding-left:10px; padding-right:10px; gap:7px; }
  .auth-view { padding:14px; }
  .auth-card { padding:22px; }
  .modal { width:100%; max-height:92dvh; left:0; right:0; bottom:0; top:auto; transform:none; border-radius:22px 22px 0 0; }
  .modal-body { max-height:calc(92dvh - 62px); padding-bottom:calc(18px + env(safe-area-inset-bottom)); }
}

.chat-security {
  display: inline-flex;
  width: fit-content;
  margin-top: 2px;
  font-size: 11px;
  color: #67e8f9;
  opacity: .9;
}

.mls-status {
  margin: 6px 0 0;
  font-weight: 600;
}
.mls-status.ready { color: #34d399; }
.mls-status.error { color: #fb7185; }
.mls-status.loading { color: #fbbf24; }

.security-recover {
  border: 1px solid rgba(245, 158, 11, .55);
  background: rgba(245, 158, 11, .12);
  color: #fbbf24;
  border-radius: 10px;
  padding: 8px 10px;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.security-recover:hover { background: rgba(245, 158, 11, .2); }
.security-recover:disabled { opacity: .55; cursor: wait; }
@media (max-width: 720px) {
  .security-recover span { display: none; }
  .security-recover { width: 38px; height: 38px; padding: 0; }
}

/* v0.5.3 profile/avatar controls */
.avatar-button { padding:0; overflow:hidden; }
.avatar-surface { width:100%; height:100%; display:grid; place-items:center; border-radius:inherit; background:inherit; }
.chat-avatar.has-avatar, .mini-avatar.has-avatar, .large-avatar.has-avatar, .avatar-surface.has-avatar {
  background-position:center;
  background-repeat:no-repeat;
  background-size:cover;
  color:transparent;
}
.profile-avatar-editor { flex:0 0 auto; }
.avatar-edit-button { position:relative; width:72px; height:72px; padding:3px; border:0; border-radius:50%; background:transparent; color:inherit; }
.avatar-edit-button .large-avatar { width:66px; height:66px; }
.avatar-camera { position:absolute; right:0; bottom:1px; width:26px; height:26px; display:grid; place-items:center; border-radius:50%; background:#274a88; border:2px solid var(--surface); font-size:12px; box-shadow:0 4px 12px rgba(0,0,0,.3); }
.avatar-edit-button:hover .avatar-camera { background:var(--accent); }
.profile-copy { min-width:0; flex:1; display:grid; gap:3px; }
.profile-link { width:max-content; margin-top:4px; padding:0; border:0; background:transparent; color:#9fbaf5; font-size:12px; }
.profile-link:hover { color:white; text-decoration:underline; }
.settings-modal-body { max-height:min(680px, calc(100dvh - 188px)); }
.settings-footer { flex:0 0 auto; padding:14px 18px calc(14px + env(safe-area-inset-bottom)); border-top:1px solid var(--line); background:var(--surface); }
.invite-code.used-note { border-color:rgba(82,201,143,.4); background:rgba(82,201,143,.08); color:#bcebd2; }

@media (max-width: 760px) { .settings-modal-body { max-height:calc(92dvh - 132px); } }

@media (hover: none) { .chat-remove-button { opacity:.72; } }

/* v0.5.4 — Gaigram brand + welcome/auth experience */
.auth-view {
  height:100dvh;
  min-height:100dvh;
  overflow:auto;
  place-items:stretch;
  padding:clamp(18px,3vw,42px);
  background:
    radial-gradient(circle at 16% 14%, rgba(91,140,255,.18), transparent 32%),
    radial-gradient(circle at 86% 82%, rgba(124,92,246,.13), transparent 30%),
    linear-gradient(145deg, #07101e 0%, #0a1424 52%, #08121f 100%);
}
.auth-shell {
  position:relative;
  isolation:isolate;
  width:min(1180px,100%);
  min-height:min(760px, calc(100dvh - clamp(36px,6vw,84px)));
  margin:auto;
  display:grid;
  grid-template-columns:minmax(0,1.12fr) minmax(390px,.78fr);
  border:1px solid rgba(255,255,255,.07);
  border-radius:32px;
  overflow:hidden;
  background:rgba(8,17,31,.72);
  box-shadow:0 32px 100px rgba(0,0,0,.42);
}
.auth-hero {
  position:relative;
  min-width:0;
  overflow:hidden;
  display:flex;
  flex-direction:column;
  justify-content:space-between;
  padding:clamp(34px,5vw,68px);
  background:
    linear-gradient(160deg, rgba(48,73,132,.26), rgba(8,17,31,.08) 52%),
    radial-gradient(circle at 80% 18%, rgba(112,91,255,.21), transparent 32%);
  border-right:1px solid rgba(255,255,255,.06);
}
.auth-hero::before {
  content:"";
  position:absolute;
  inset:0;
  pointer-events:none;
  opacity:.18;
  background-image:
    linear-gradient(rgba(255,255,255,.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.045) 1px, transparent 1px);
  background-size:48px 48px;
  mask-image:linear-gradient(to bottom right, #000, transparent 72%);
}
.auth-hero-glow { position:absolute; border-radius:50%; filter:blur(2px); pointer-events:none; }
.auth-hero-glow.glow-one { width:330px; height:330px; right:-155px; top:-120px; background:rgba(90,122,255,.13); box-shadow:0 0 100px rgba(90,122,255,.18); }
.auth-hero-glow.glow-two { width:260px; height:260px; left:-120px; bottom:-140px; background:rgba(116,91,255,.11); box-shadow:0 0 80px rgba(116,91,255,.14); }
.auth-brand, .auth-mobile-brand {
  position:relative;
  z-index:1;
  display:flex;
  align-items:center;
  gap:13px;
  font-size:21px;
  font-weight:800;
  letter-spacing:-.025em;
}
.brand-mark { width:48px; height:48px; display:block; filter:drop-shadow(0 12px 22px rgba(73,93,237,.23)); }
.brand-mark.small { width:40px; height:40px; }
.auth-hero-copy { position:relative; z-index:1; max-width:650px; margin:64px 0 38px; }
.auth-eyebrow, .auth-kicker {
  display:inline-flex;
  align-items:center;
  gap:8px;
  color:#91b6ff;
  font-size:11px;
  font-weight:800;
  letter-spacing:.15em;
  text-transform:uppercase;
}
.auth-eyebrow::before { content:""; width:24px; height:1px; background:#7aa2ff; box-shadow:0 0 12px #7aa2ff; }
.auth-hero-copy h1 { margin:16px 0 20px; max-width:680px; font-size:clamp(40px,5vw,66px); line-height:1.01; letter-spacing:-.055em; }
.auth-hero-copy p { margin:0; max-width:580px; color:#aab7cc; font-size:clamp(16px,1.6vw,19px); line-height:1.58; }
.auth-trust-grid { position:relative; z-index:1; display:grid; gap:10px; width:min(590px,100%); }
.trust-card { display:flex; align-items:center; gap:13px; min-width:0; padding:12px 14px; border:1px solid rgba(255,255,255,.07); border-radius:16px; background:rgba(255,255,255,.025); backdrop-filter:blur(10px); }
.trust-icon { width:36px; height:36px; flex:0 0 auto; display:grid; place-items:center; border-radius:11px; background:rgba(91,140,255,.13); border:1px solid rgba(122,162,255,.16); color:#b5caff; font-size:18px; }
.trust-card div { min-width:0; display:grid; gap:2px; }
.trust-card strong { font-size:13px; }
.trust-card small { color:#8494ac; font-size:11px; line-height:1.35; }
.auth-platforms { position:relative; z-index:1; display:flex; align-items:center; gap:10px; margin-top:28px; color:#6f8099; font-size:11px; font-weight:700; letter-spacing:.08em; text-transform:uppercase; }
.auth-platforms i { width:3px; height:3px; border-radius:50%; background:#46628c; }
.auth-card-wrap { min-width:0; display:flex; align-items:center; justify-content:center; padding:clamp(24px,4vw,52px); background:linear-gradient(180deg, rgba(13,25,43,.94), rgba(9,18,32,.97)); }
.auth-mobile-brand { display:none; }
.auth-card {
  width:min(420px,100%);
  padding:0;
  border:0;
  border-radius:0;
  background:transparent;
  box-shadow:none;
  backdrop-filter:none;
}
.auth-card-heading { margin-bottom:20px; }
.auth-card-heading h2 { margin:8px 0 8px; font-size:30px; line-height:1.15; letter-spacing:-.035em; }
.auth-card-heading p { margin:0; font-size:13px; line-height:1.5; }
.tabs { margin:18px 0 16px; padding:4px; border:1px solid rgba(255,255,255,.05); border-radius:13px; background:rgba(255,255,255,.035); }
.tab { min-height:39px; border-radius:10px; font-size:13px; font-weight:700; transition:background .15s,color .15s,box-shadow .15s; }
.tab.active { background:#1c2d49; box-shadow:0 4px 14px rgba(0,0,0,.17); }
.auth-form { gap:12px; }
.auth-form label { gap:6px; color:#b8c5d8; font-size:12px; }
.auth-form input, .server-details input { min-height:45px; border-color:rgba(255,255,255,.075); border-radius:12px; background:rgba(5,13,25,.68); }
.auth-form input::placeholder, .server-details input::placeholder { color:#62728a; }
.auth-submit { min-height:46px; margin-top:3px; border-radius:12px; background:linear-gradient(135deg, #5b91ff 0%, #6578ff 52%, #7a5ef4 100%); box-shadow:0 10px 24px rgba(77,92,230,.2); transition:transform .12s ease, filter .12s ease, box-shadow .12s ease; }
.auth-submit:hover { filter:brightness(1.06); box-shadow:0 13px 30px rgba(77,92,230,.28); }
.auth-submit:active { transform:translateY(1px); }
.field-hint { margin-top:-1px; color:#687a94; font-size:10px; font-weight:500; line-height:1.35; }
.server-details { margin:0 0 14px; padding:10px 12px; border:1px solid rgba(255,255,255,.055); border-radius:12px; background:rgba(255,255,255,.02); }
.server-details summary { display:flex; align-items:center; justify-content:space-between; gap:12px; margin:0; color:#8fa1bb; font-weight:700; list-style:none; }
.server-details summary::-webkit-details-marker { display:none; }
.server-details summary::before { content:"›"; color:#647896; font-size:18px; transform:rotate(0deg); transition:transform .15s; }
.server-details[open] summary::before { transform:rotate(90deg); }
.server-details summary span { margin-right:auto; }
.server-details summary small { color:#596a82; font-size:10px; font-weight:600; }
.server-details[open] summary { margin-bottom:10px; }
.server-details > p { margin:8px 1px 0; color:#61728b; font-size:10px; line-height:1.45; }
.auth-footnote { display:flex; align-items:center; gap:7px; margin-top:16px; color:#667891; font-size:10px; line-height:1.4; }
.shield-dot { color:#52c98f; font-size:10px; text-shadow:0 0 10px rgba(82,201,143,.45); }
.placeholder-badge { width:64px; height:64px; padding:0; border-radius:20px; background:none; box-shadow:none; }
.placeholder-badge img { width:64px; height:64px; display:block; filter:drop-shadow(0 12px 26px rgba(73,93,237,.2)); }

@media (max-width: 940px) {
  .auth-view { padding:18px; }
  .auth-shell { grid-template-columns:1fr; min-height:auto; width:min(560px,100%); overflow:visible; background:transparent; border:0; box-shadow:none; }
  .auth-hero { display:none; }
  .auth-card-wrap { display:block; padding:0; background:transparent; }
  .auth-mobile-brand { display:flex; margin:0 0 22px 4px; }
  .auth-card { padding:25px; border:1px solid rgba(255,255,255,.075); border-radius:24px; background:rgba(15,27,46,.9); box-shadow:0 26px 70px rgba(0,0,0,.34); backdrop-filter:blur(16px); }
}
@media (max-width: 520px) {
  .auth-view { padding:14px; align-items:start; }
  .auth-shell { margin:0 auto; }
  .auth-mobile-brand { margin:6px 0 16px 5px; }
  .auth-card { padding:20px; border-radius:21px; }
  .auth-card-heading h2 { font-size:26px; }
  .auth-card-heading p { font-size:12px; }
}

/* v0.5.4 hotfix 1 — light Gaigram welcome page using the AdminIT palette.
   The messenger workspace itself will move to the same light visual system in v0.5.5. */
.auth-view {
  color-scheme: light;
  color:#07111F;
  background:
    radial-gradient(circle at 15% 12%, rgba(86,168,255,.19), transparent 34%),
    radial-gradient(circle at 86% 84%, rgba(110,231,249,.20), transparent 31%),
    #F7FBFF;
}
.auth-shell {
  border-color:rgba(159,176,197,.42);
  background:rgba(247,251,255,.96);
  box-shadow:0 28px 80px rgba(7,17,31,.13);
}
.auth-hero {
  border-right-color:rgba(159,176,197,.32);
  background:
    radial-gradient(circle at 82% 14%, rgba(86,168,255,.24), transparent 33%),
    radial-gradient(circle at 8% 88%, rgba(110,231,249,.18), transparent 28%),
    linear-gradient(145deg, rgba(47,128,237,.09), rgba(247,251,255,.96) 58%);
}
.auth-hero::before {
  opacity:.44;
  background-image:
    linear-gradient(rgba(47,128,237,.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(47,128,237,.06) 1px, transparent 1px);
}
.auth-hero-glow.glow-one { background:rgba(86,168,255,.10); box-shadow:0 0 100px rgba(86,168,255,.16); }
.auth-hero-glow.glow-two { background:rgba(110,231,249,.13); box-shadow:0 0 80px rgba(110,231,249,.15); }
.auth-brand, .auth-mobile-brand { color:#07111F; }
.auth-eyebrow, .auth-kicker {
  color:#2F80ED;
  font-size:13px;
  letter-spacing:.13em;
}
.auth-eyebrow::before {
  width:15px;
  background:#56A8FF;
  box-shadow:0 0 10px rgba(86,168,255,.34);
}
.auth-hero-copy h1 { color:#07111F; }
.auth-hero-copy p { color:rgba(7,17,31,.70); }
.trust-card {
  border-color:rgba(159,176,197,.38);
  background:rgba(247,251,255,.72);
  box-shadow:0 8px 28px rgba(7,17,31,.045);
}
.trust-icon {
  background:rgba(86,168,255,.13);
  border-color:rgba(47,128,237,.18);
  color:#2F80ED;
}
.trust-card strong { color:#07111F; }
.trust-card small { color:rgba(7,17,31,.60); }
.auth-platforms { color:rgba(7,17,31,.52); }
.auth-platforms i { background:#56A8FF; }
.auth-card-wrap {
  background:rgba(247,251,255,.94);
}
.auth-card-heading h2 { color:#07111F; }
.auth-card-heading p, .auth-view .muted { color:rgba(7,17,31,.58); }
.tabs {
  border-color:rgba(159,176,197,.34);
  background:rgba(159,176,197,.12);
}
.tab { color:rgba(7,17,31,.55); }
.tab.active {
  color:#07111F;
  background:#F7FBFF;
  box-shadow:0 3px 12px rgba(7,17,31,.08);
}
.auth-form label { color:#07111F; }
.auth-form input {
  border-color:rgba(159,176,197,.48);
  background:rgba(247,251,255,.96);
  color:#07111F;
  box-shadow:0 1px 0 rgba(7,17,31,.02);
}
.auth-form input::placeholder { color:#9FB0C5; }
.auth-form input:focus {
  border-color:#2F80ED;
  box-shadow:0 0 0 3px rgba(47,128,237,.12);
}
.auth-submit {
  color:#F7FBFF;
  background:linear-gradient(135deg,#2F80ED 0%,#56A8FF 100%);
  box-shadow:0 10px 24px rgba(47,128,237,.20);
}
.auth-submit:hover { box-shadow:0 13px 30px rgba(47,128,237,.26); }
.field-hint { color:rgba(7,17,31,.52); }
.auth-footnote { color:rgba(7,17,31,.52); }
.shield-dot { color:#49DCB1; text-shadow:0 0 10px rgba(73,220,177,.30); }
.auth-view .alert.error {
  background:rgba(47,128,237,.07);
  color:#07111F;
  border-color:rgba(47,128,237,.25);
}
@media (max-width: 940px) {
  .auth-card {
    border-color:rgba(159,176,197,.38);
    background:rgba(247,251,255,.95);
    box-shadow:0 24px 64px rgba(7,17,31,.13);
  }
}

/* v0.5.5 — Gaigram light workspace / unified browser visual system */
:root {
  color-scheme: light;
  --bg:#F7FBFF;
  --surface:#FFFFFF;
  --surface-2:#F3F8FE;
  --surface-3:#E9F3FE;
  --text:#07111F;
  --muted:#71849B;
  --line:rgba(159,176,197,.34);
  --accent:#2F80ED;
  --accent-2:#56A8FF;
  --cyan:#6EE7F9;
  --danger:#E25563;
  --success:#49DCB1;
  --shadow:0 18px 52px rgba(7,17,31,.11);
  --radius:18px;
}
body { background:var(--bg); color:var(--text); }
button { -webkit-tap-highlight-color:transparent; }
button:focus-visible, input:focus-visible, textarea:focus-visible { outline:none; }
.ui-icon, .icon-button svg, .attach-button svg, .send-button svg, .image-viewer-close svg, .avatar-camera svg {
  width:20px; height:20px; display:block; fill:none; stroke:currentColor; stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round;
}

/* Brand mark */
.brand-mark { object-fit:contain; filter:drop-shadow(0 9px 18px rgba(47,128,237,.18)); }
.placeholder-badge { width:76px; height:76px; }
.placeholder-badge img { width:76px; height:76px; object-fit:contain; filter:drop-shadow(0 12px 24px rgba(47,128,237,.16)); }

/* Main shell */
.messenger {
  grid-template-columns:344px minmax(0,1fr);
  background:#EEF6FD;
}
.sidebar {
  border-right:1px solid rgba(159,176,197,.34);
  background:rgba(255,255,255,.94);
  box-shadow:8px 0 28px rgba(7,17,31,.025);
}
.sidebar-header, .chat-header {
  height:76px; min-height:76px;
  padding:0 18px;
  border-bottom:1px solid rgba(159,176,197,.28);
  background:rgba(255,255,255,.88);
  backdrop-filter:blur(18px) saturate(145%);
}
.avatar-button, .chat-avatar, .large-avatar, .mini-avatar {
  background:linear-gradient(145deg,#2F80ED 0%,#56A8FF 58%,#6EE7F9 120%);
  color:#F7FBFF;
  box-shadow:0 7px 18px rgba(47,128,237,.16);
}
.avatar-button { width:44px; height:44px; box-shadow:0 6px 16px rgba(47,128,237,.15); }
.chat-avatar { width:44px; height:44px; }
.brand-copy { gap:3px; }
.brand-copy strong { color:#07111F; font-size:15px; font-weight:760; letter-spacing:-.015em; }
.chat-title-wrap strong { color:#07111F; font-size:15px; font-weight:760; letter-spacing:-.012em; }
.connection { color:#8A9DB3; }
.connection.online { color:#20B98A; font-weight:650; }
.icon-button {
  width:40px; height:40px;
  border:1px solid transparent;
  border-radius:12px;
  color:#6E829A;
  background:transparent;
  transition:background .14s ease,color .14s ease,border-color .14s ease,transform .14s ease;
}
.icon-button:hover { color:#2F80ED; background:#EDF6FF; border-color:rgba(86,168,255,.18); }
.icon-button:active { transform:scale(.97); }

/* Search */
.search-wrap { padding:14px 14px 12px; border-bottom:1px solid rgba(159,176,197,.22); background:#fff; }
.search-wrap input {
  min-height:44px;
  padding:11px 14px;
  border:1px solid rgba(159,176,197,.37);
  border-radius:14px;
  background:#F7FBFF;
  color:#07111F;
  box-shadow:inset 0 1px 0 rgba(7,17,31,.02);
}
.search-wrap input::placeholder { color:#8EA0B5; }
.search-wrap input:focus { border-color:#56A8FF; background:#fff; box-shadow:0 0 0 3px rgba(47,128,237,.09); }
.search-results {
  top:66px;
  border-color:rgba(159,176,197,.40);
  background:#fff;
  box-shadow:0 18px 48px rgba(7,17,31,.14);
}
.search-user, .picker-user { color:#07111F; }
.search-user:hover, .picker-user:hover { background:#F0F7FF; }
.user-copy span { color:#7B8FA7; }
.mini-avatar { background:linear-gradient(145deg,#2F80ED,#56A8FF); }

/* Chat list */
.chat-list { padding:7px 8px 14px; background:#fff; scrollbar-color:rgba(159,176,197,.55) transparent; }
.chat-item {
  width:100%;
  margin:2px 0;
  grid-template-columns:48px minmax(0,1fr) auto;
  padding:11px 10px;
  border:1px solid transparent;
  border-radius:15px;
  background:transparent;
  color:#07111F;
  transition:background .13s ease,border-color .13s ease,box-shadow .13s ease,transform .13s ease;
}
.chat-item:hover { background:#F4F9FF; border-color:rgba(86,168,255,.13); }
.chat-item.active {
  background:linear-gradient(110deg,rgba(47,128,237,.11),rgba(86,168,255,.075));
  border-color:rgba(47,128,237,.16);
  box-shadow:0 7px 20px rgba(47,128,237,.055);
}
.chat-item .chat-avatar { width:48px; height:48px; }
.chat-item-title { color:#07111F; font-size:14px; }
.chat-preview { color:#778BA3; font-size:12.5px; }
.chat-time { color:#8FA1B6; }
.chat-remove-button {
  color:#91A3B6;
  background:transparent;
}
.chat-remove-button .ui-icon { width:15px; height:15px; }
.chat-remove-button:hover { background:rgba(226,85,99,.09); color:#D54858; }
.unread-badge {
  min-width:21px; height:21px;
  background:linear-gradient(135deg,#2F80ED,#56A8FF);
  box-shadow:0 4px 12px rgba(47,128,237,.20);
}
.empty-state { color:#8295AA; }
.empty-state strong { color:#203147; }

/* Conversation canvas */
.chat-panel {
  background:
    radial-gradient(circle at 18% 16%, rgba(110,231,249,.11), transparent 26%),
    radial-gradient(circle at 84% 78%, rgba(86,168,255,.10), transparent 30%),
    linear-gradient(145deg,#F7FBFF 0%,#F3F9FF 48%,#F7FBFF 100%);
}
.chat-panel::after {
  content:"";
  position:absolute; inset:0;
  pointer-events:none;
  opacity:.35;
  background-image:radial-gradient(rgba(47,128,237,.09) .7px, transparent .7px);
  background-size:24px 24px;
  mask-image:linear-gradient(to bottom,rgba(0,0,0,.45),transparent 80%);
}
.chat-placeholder { position:relative; z-index:1; color:#7D90A7; }
.chat-placeholder h2 { color:#07111F; font-size:21px; letter-spacing:-.025em; }
.active-chat { z-index:1; }
.chat-header { position:relative; z-index:7; }
.chat-security { color:#2488A4; font-weight:650; opacity:1; }
.message-list {
  position:relative; z-index:1;
  padding:24px clamp(18px,4.5vw,72px) 18px;
  gap:8px;
  scrollbar-color:rgba(159,176,197,.60) transparent;
}
.message-list::-webkit-scrollbar-thumb { background:rgba(159,176,197,.55); border:3px solid transparent; background-clip:padding-box; }

/* Message bubbles */
.bubble {
  max-width:min(680px,76%);
  border:1px solid rgba(159,176,197,.30);
  background:rgba(255,255,255,.96);
  color:#07111F;
  border-radius:18px 18px 18px 6px;
  padding:10px 13px 8px;
  box-shadow:0 5px 18px rgba(7,17,31,.055);
}
.message-row.mine .bubble {
  color:#F7FBFF;
  background:linear-gradient(135deg,#2F80ED 0%,#3F91F3 55%,#56A8FF 100%);
  border-color:rgba(47,128,237,.20);
  border-radius:18px 18px 6px 18px;
  box-shadow:0 7px 20px rgba(47,128,237,.15);
}
.message-body { line-height:1.43; }
.sender-name { color:#2F80ED; }
.message-meta { color:#8A9BB0; }
.message-row.mine .message-meta { color:rgba(247,251,255,.73); }
.receipt { color:#CDE9FF; }
.reply-quote {
  border-left-color:#56A8FF;
  background:#EFF7FF;
  color:#07111F;
}
.reply-quote strong { color:#2F80ED; }
.reply-quote span { color:#6F8299; }
.message-row.mine .reply-quote { background:rgba(247,251,255,.14); border-left-color:#BEEFFF; color:#fff; }
.message-row.mine .reply-quote strong { color:#DDF5FF; }
.message-row.mine .reply-quote span { color:rgba(255,255,255,.76); }
.message-actions { top:-14px; }
.message-actions button {
  width:29px; height:29px;
  border:1px solid rgba(159,176,197,.36);
  background:#fff;
  color:#6F8299;
  box-shadow:0 5px 14px rgba(7,17,31,.10);
}
.message-actions button .ui-icon { width:15px; height:15px; }
.message-actions button:hover { color:#2F80ED; background:#F0F7FF; border-color:rgba(47,128,237,.24); }

/* Media/file bubbles */
.attachment-card {
  border-color:rgba(159,176,197,.34);
  background:rgba(247,251,255,.83);
}
.message-row.mine .attachment-card { background:rgba(255,255,255,.12); border-color:rgba(255,255,255,.18); }
.attachment-copy strong { color:inherit; }
.attachment-copy span { color:#788CA3; }
.message-row.mine .attachment-copy span { color:rgba(255,255,255,.70); }
.attachment-icon { background:rgba(86,168,255,.13); }
.message-row.mine .attachment-icon { background:rgba(255,255,255,.14); }
.attachment-open { background:#E8F3FF; color:#2F80ED; font-weight:720; }
.message-row.mine .attachment-open { background:rgba(255,255,255,.16); color:#fff; }
.image-attachment, .video-attachment, .audio-attachment { background:#EEF5FC; }
.message-row.mine .image-attachment, .message-row.mine .video-attachment, .message-row.mine .audio-attachment { background:rgba(10,51,109,.16); }
.chat-image-button { background:#EDF5FC; }
.chat-image { background:#EDF5FC; }
.media-decrypting { color:#7B8FA6; }
.media-footer { color:#778AA1; }
.message-row.mine .media-footer { color:rgba(255,255,255,.72); }
.media-download { color:#2F80ED; }
.message-row.mine .media-download { color:#E7F5FF; }
.media-error { color:#D94F5E; }

/* Composer */
.composer {
  z-index:8;
  gap:10px;
  padding:12px 18px calc(12px + env(safe-area-inset-bottom));
  border-top:1px solid rgba(159,176,197,.28);
  background:rgba(255,255,255,.91);
  backdrop-filter:blur(18px) saturate(145%);
  box-shadow:0 -8px 28px rgba(7,17,31,.035);
}
.composer textarea {
  min-height:46px;
  max-height:160px;
  border:1px solid rgba(159,176,197,.40);
  border-radius:15px;
  background:#F7FBFF;
  color:#07111F;
  padding:12px 14px;
  box-shadow:inset 0 1px 0 rgba(7,17,31,.02);
}
.composer textarea::placeholder { color:#91A2B6; }
.composer textarea:focus { background:#fff; border-color:#56A8FF; box-shadow:0 0 0 3px rgba(47,128,237,.08); }
.attach-button, .send-button { width:46px; height:46px; border-radius:14px; display:grid; place-items:center; }
.attach-button { border:1px solid rgba(86,168,255,.18); background:#EDF6FF; color:#2F80ED; }
.attach-button:hover { background:#E1F0FF; color:#1D70D7; }
.send-button {
  background:linear-gradient(135deg,#2F80ED,#56A8FF);
  color:#fff;
  box-shadow:0 8px 18px rgba(47,128,237,.22);
  transition:transform .13s ease,box-shadow .13s ease,filter .13s ease;
}
.send-button:hover { filter:brightness(1.03); box-shadow:0 10px 22px rgba(47,128,237,.28); }
.send-button:active { transform:translateY(1px) scale(.98); }
.attachment-drafts { scrollbar-color:rgba(159,176,197,.55) transparent; }
.attachment-draft {
  border-color:rgba(159,176,197,.38);
  background:#fff;
  box-shadow:0 5px 16px rgba(7,17,31,.05);
}
.attachment-draft img, .attachment-draft video { background:#EDF5FC; }
.draft-icon { background:#EDF6FF; color:#2F80ED; }
.draft-copy span { color:#8193A8; }
.draft-remove { background:#F1F5F9; color:#7B8DA2; }
.draft-remove .ui-icon { width:14px; height:14px; }
.draft-remove:hover { background:rgba(226,85,99,.10); color:#D54858; }
.reply-preview { border-left-color:#2F80ED; background:#EDF6FF; }
.reply-preview strong { color:#2F80ED; }
.reply-preview span { color:#73869D; }
.reply-preview button { color:#7E90A5; display:grid; place-items:center; }
.reply-preview button .ui-icon { width:16px; height:16px; }
.drop-overlay { background:rgba(247,251,255,.88); }
.drop-overlay > div { border-color:rgba(47,128,237,.42); background:rgba(86,168,255,.09); color:#07111F; box-shadow:0 18px 52px rgba(7,17,31,.10); }
.drop-overlay span { background:linear-gradient(135deg,#2F80ED,#56A8FF); color:#fff; }
.load-more { border-color:rgba(159,176,197,.38); background:#fff; color:#2F80ED; box-shadow:0 6px 18px rgba(7,17,31,.08); }

/* Modal/settings system */
.modal-backdrop { background:rgba(7,17,31,.31); backdrop-filter:blur(7px); }
.modal {
  border-color:rgba(159,176,197,.38);
  background:#fff;
  color:#07111F;
  box-shadow:0 28px 80px rgba(7,17,31,.18);
}
.modal > header { border-bottom-color:rgba(159,176,197,.28); background:#FBFDFF; }
.modal h2, .modal h3 { color:#07111F; }
.modal-body { scrollbar-color:rgba(159,176,197,.55) transparent; }
.profile-card {
  border-color:rgba(159,176,197,.34);
  background:linear-gradient(120deg,#F7FBFF,#F1F8FF);
}
.avatar-camera { background:#2F80ED; border-color:#fff; color:#fff; box-shadow:0 4px 12px rgba(47,128,237,.20); }
.avatar-camera svg { width:13px; height:13px; stroke-width:1.9; }
.avatar-edit-button:hover .avatar-camera { background:#56A8FF; }
.profile-link { color:#2F80ED; }
.profile-link:hover { color:#176BCB; }
.pill { color:#176BCB; background:rgba(47,128,237,.10); }
.security-note {
  background:linear-gradient(135deg,rgba(110,231,249,.12),rgba(73,220,177,.08));
  border-color:rgba(73,220,177,.26);
}
.security-note p { color:#5E7289; }
.mls-status.ready { color:#14A97A; }
.mls-status.error { color:#D94F5E; }
.mls-status.loading { color:#A87818; }
.setting-row {
  border-color:rgba(159,176,197,.32);
  background:#FAFCFF;
}
.setting-row .sub { color:#7C8FA5; }
.settings-footer { border-top-color:rgba(159,176,197,.28); background:#FBFDFF; }
.secondary { background:#EAF4FF; color:#246FCB; border:1px solid rgba(47,128,237,.10); }
.secondary:hover { background:#DDEEFF; }
.danger { background:rgba(226,85,99,.08); color:#CB4051; border-color:rgba(226,85,99,.18); }
.danger:hover { background:rgba(226,85,99,.13); }
.invite-code { border-color:rgba(47,128,237,.32); background:rgba(86,168,255,.08); }
.invite-code.used-note { border-color:rgba(73,220,177,.36); background:rgba(73,220,177,.09); color:#147D61; }
.picker-results { border-color:rgba(159,176,197,.36); }
.chip { border-color:rgba(159,176,197,.34); background:#F0F7FF; color:#07111F; }
.chip button { color:#73869B; }
.modal input, .modal textarea {
  border-color:rgba(159,176,197,.42);
  background:#F7FBFF;
  color:#07111F;
}
.modal input:focus, .modal textarea:focus { background:#fff; border-color:#56A8FF; box-shadow:0 0 0 3px rgba(47,128,237,.08); }
.modal label { color:#26374B; }

/* Feedback */
.toast { border-color:rgba(159,176,197,.38); background:#fff; color:#07111F; box-shadow:0 15px 42px rgba(7,17,31,.14); }
.toast.error { border-color:rgba(226,85,99,.26); background:#FFF8F9; }
.security-recover { border-color:rgba(221,160,47,.40); background:#FFF8E8; color:#9C6912; }
.security-recover:hover { background:#FFF1CE; }

/* Fullscreen image viewer stays dark so photos remain visually neutral. */
.image-viewer { background:rgba(4,10,18,.90); }
.image-viewer-close { display:grid; place-items:center; background:rgba(255,255,255,.12); border-color:rgba(255,255,255,.18); color:#fff; }
.image-viewer-close svg { width:20px; height:20px; }
.image-viewer-download { background:rgba(255,255,255,.13); border-color:rgba(255,255,255,.18); color:#fff; }

@media (max-width: 900px) {
  .messenger { grid-template-columns:320px minmax(0,1fr); }
}
@media (max-width: 760px) {
  .messenger { grid-template-columns:1fr; background:#F7FBFF; }
  .sidebar { box-shadow:none; }
  .sidebar-header, .chat-header { height:68px; min-height:68px; padding-left:12px; padding-right:12px; }
  .message-list { padding:17px 11px 12px; }
  .bubble { max-width:88%; }
  .composer { padding-left:10px; padding-right:10px; }
  .chat-panel::after { opacity:.24; }
  .message-actions { opacity:.86; }
}

/* v0.5.6 — group management + emoji */
.composer { grid-template-columns:auto auto minmax(0,1fr) auto; }
.emoji-button {
  width:46px; height:46px; border-radius:14px; display:grid; place-items:center;
  border:1px solid rgba(86,168,255,.18); background:#EDF6FF; color:#2F80ED;
  transition:background .14s ease, color .14s ease, box-shadow .14s ease;
}
.emoji-button:hover, .emoji-button.active { background:#E1F0FF; color:#1D70D7; box-shadow:0 0 0 3px rgba(47,128,237,.06); }
.emoji-button svg { width:22px; height:22px; fill:none; stroke:currentColor; stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round; }
.emoji-picker {
  position:absolute; z-index:18; left:72px; bottom:72px; width:min(360px,calc(100vw - 34px));
  border:1px solid rgba(159,176,197,.34); border-radius:18px; background:#fff;
  box-shadow:0 20px 58px rgba(7,17,31,.17); overflow:hidden;
}
.emoji-tabs { display:flex; gap:2px; padding:8px; border-bottom:1px solid rgba(159,176,197,.24); background:#F7FBFF; overflow-x:auto; }
.emoji-tab { flex:0 0 38px; width:38px; height:36px; border:0; border-radius:10px; background:transparent; font-size:19px; cursor:pointer; }
.emoji-tab:hover { background:#EAF5FF; }
.emoji-tab.active { background:#DCEEFF; box-shadow:inset 0 0 0 1px rgba(47,128,237,.16); }
.emoji-grid { display:grid; grid-template-columns:repeat(8,1fr); gap:2px; max-height:250px; overflow:auto; padding:9px; scrollbar-color:rgba(159,176,197,.55) transparent; }
.emoji-item { width:38px; height:38px; border:0; border-radius:9px; background:transparent; font-size:23px; line-height:1; cursor:pointer; }
.emoji-item:hover { background:#EDF6FF; transform:scale(1.08); }

#group-info-button { margin-left:auto; color:#2F80ED; background:#EDF6FF; border:1px solid rgba(86,168,255,.18); }
#group-info-button:hover { background:#E1F0FF; }
#group-info-button svg { fill:none; stroke:currentColor; stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round; }

.group-manage-body { display:grid; gap:18px; }
.group-profile-card {
  display:grid; grid-template-columns:auto minmax(0,1fr); gap:16px; align-items:start;
  padding:16px; border:1px solid rgba(159,176,197,.30); border-radius:18px; background:#FBFDFF;
}
.group-profile-fields { display:grid; gap:11px; min-width:0; }
.group-profile-fields label { display:grid; gap:6px; }
.group-profile-fields textarea { resize:vertical; min-height:76px; line-height:1.45; }
.group-profile-actions { display:flex; align-items:center; gap:12px; flex-wrap:wrap; }
.group-profile-actions .primary { min-width:132px; }
.group-members-heading { margin-top:2px; align-items:end; }
.group-members-heading > div { display:grid; gap:3px; }
.group-add-member { display:grid; gap:8px; padding:13px; border:1px solid rgba(86,168,255,.20); border-radius:15px; background:#F3F9FF; }
.group-add-member label { display:grid; gap:6px; }
.group-member-list { display:grid; gap:8px; }
.group-member-row {
  display:grid; grid-template-columns:44px minmax(0,1fr) auto auto; gap:10px; align-items:center;
  padding:10px 11px; border:1px solid rgba(159,176,197,.28); border-radius:14px; background:#fff;
}
.group-member-avatar { width:44px; height:44px; }
.group-member-copy { min-width:0; display:grid; gap:2px; }
.group-member-name { display:flex; align-items:center; gap:7px; min-width:0; }
.group-member-name strong { white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.online-dot { width:7px; height:7px; border-radius:50%; background:#49DCB1; box-shadow:0 0 0 3px rgba(73,220,177,.13); }
.group-role-badge { padding:5px 8px; border-radius:999px; font-size:11px; font-weight:750; white-space:nowrap; background:#F0F4F8; color:#718399; }
.group-role-badge.role-owner { background:#E6F2FF; color:#1E70CF; }
.group-role-badge.role-admin { background:#EAFBF6; color:#208B70; }
.group-member-actions { display:flex; align-items:center; justify-content:flex-end; gap:6px; flex-wrap:wrap; }
.group-member-action { border:0; border-radius:9px; padding:7px 9px; background:#EDF6FF; color:#2F80ED; font-size:11px; font-weight:720; cursor:pointer; }
.group-member-action:hover { background:#DDEFFF; }
.group-member-action.danger-text { background:#FFF1F3; color:#D54858; }
.group-member-action.danger-text:hover { background:#FFE5E9; }
.group-manage-hint { margin:0; font-size:12px; line-height:1.45; }
#group-avatar-edit-button:disabled { cursor:default; }
#group-avatar-edit-button:disabled .avatar-camera { display:none; }
#group-avatar-edit-button:disabled:hover { transform:none; }

@media (max-width:760px) {
  .composer { grid-template-columns:auto auto minmax(0,1fr) auto; gap:6px; }
  .attach-button, .emoji-button, .send-button { width:42px; height:42px; border-radius:13px; }
  .emoji-picker { left:10px; right:10px; bottom:66px; width:auto; }
  .emoji-grid { grid-template-columns:repeat(7,1fr); }
  .emoji-item { width:36px; height:36px; font-size:22px; }
  .group-profile-card { grid-template-columns:1fr; }
  .group-profile-card .profile-avatar-editor { justify-self:center; }
  .group-member-row { grid-template-columns:42px minmax(0,1fr) auto; }
  .group-member-actions { grid-column:2/-1; justify-content:flex-start; }
  .group-role-badge { justify-self:end; }
}

/* v0.5.7 — chat wallpaper, Telegram-style composer polish and group chat hiding */
.brand-copy strong,
.chat-title-wrap strong {
  font-size:17px;
  font-weight:650;
  letter-spacing:-.01em;
}

.chat-panel {
  background-color:#F7FBFF;
  background-image:url('./assets/chat-wallpaper.png');
  background-repeat:repeat-x;
  background-position:center center;
  background-size:auto 100%;
}
.chat-panel::after { display:none; }

.composer {
  grid-template-columns:minmax(0,1fr) auto !important;
  gap:10px;
  align-items:end;
}
.composer-input-shell {
  min-width:0;
  display:grid;
  grid-template-columns:auto minmax(0,1fr) auto;
  align-items:end;
  gap:2px;
  padding:2px 5px;
  border:1px solid rgba(159,176,197,.40);
  border-radius:17px;
  background:#F7FBFF;
  box-shadow:inset 0 1px 0 rgba(7,17,31,.02);
  transition:border-color .14s ease,box-shadow .14s ease,background .14s ease;
}
.composer-input-shell:focus-within {
  background:#fff;
  border-color:#56A8FF;
  box-shadow:0 0 0 3px rgba(47,128,237,.08);
}
.composer-input-shell .attach-button,
.composer-input-shell .emoji-button {
  width:40px;
  height:40px;
  margin:1px 0;
  border:0;
  border-radius:11px;
  background:transparent;
  color:#7890A9;
  box-shadow:none;
}
.composer-input-shell .attach-button:hover,
.composer-input-shell .emoji-button:hover,
.composer-input-shell .emoji-button.active {
  background:#EAF5FF;
  color:#2F80ED;
  box-shadow:none;
}
.composer-input-shell .attach-button:disabled { background:transparent; }
.composer textarea,
.composer-input-shell textarea {
  min-height:42px;
  max-height:160px;
  height:42px;
  padding:10px 4px 9px;
  border:0;
  border-radius:0;
  background:transparent;
  box-shadow:none;
  line-height:1.45;
  overflow-y:hidden;
  scrollbar-width:none;
}
.composer textarea::-webkit-scrollbar,
.composer-input-shell textarea::-webkit-scrollbar { width:0; height:0; display:none; }
.composer textarea:focus,
.composer-input-shell textarea:focus {
  border:0;
  background:transparent;
  box-shadow:none;
}

.emoji-picker {
  left:18px;
  bottom:76px;
  width:min(392px,calc(100vw - 36px));
  border-radius:19px;
}
.emoji-tabs {
  gap:1px;
  padding:7px 8px;
  scrollbar-width:none;
}
.emoji-tabs::-webkit-scrollbar { display:none; }
.emoji-tab,
.emoji-item {
  font-family:"Segoe UI Emoji","Apple Color Emoji","Noto Color Emoji",sans-serif;
  font-variant-emoji:emoji;
}
.emoji-tab {
  flex:0 0 40px;
  width:40px;
  height:38px;
  font-size:20px;
}
.emoji-grid {
  grid-template-columns:repeat(8,1fr);
  gap:3px;
  max-height:286px;
  padding:10px;
}
.emoji-item {
  width:41px;
  height:41px;
  border-radius:10px;
  font-size:26px;
  transition:background .10s ease,transform .10s ease;
}
.emoji-item:hover { transform:scale(1.10); }

@media (max-width:760px) {
  .brand-copy strong,
  .chat-title-wrap strong { font-size:16px; font-weight:650; }
  .composer { grid-template-columns:minmax(0,1fr) auto !important; gap:7px; }
  .composer-input-shell .attach-button,
  .composer-input-shell .emoji-button { width:38px; height:38px; border-radius:10px; }
  .composer textarea,
  .composer-input-shell textarea { min-height:40px; height:40px; padding-top:9px; padding-bottom:8px; }
  .emoji-picker { left:10px; right:10px; bottom:66px; width:auto; }
  .emoji-grid { grid-template-columns:repeat(7,1fr); }
  .emoji-item { width:38px; height:38px; font-size:24px; }
}

/* v0.5.8 — delivery states, pinning, lighter outgoing messages, responsive files, Twemoji-style artwork */
.active-chat { grid-template-rows:70px auto minmax(0,1fr) auto; }

/* Chat list pinning and last-message receipt state */
.chat-item-actions { display:flex; align-items:center; gap:2px; flex:0 0 auto; }
.chat-pin-button,
.chat-remove-button {
  width:26px; height:26px; flex:0 0 auto; display:grid; place-items:center;
  border:0; border-radius:8px; background:transparent; color:#8A9BB0;
  opacity:0; transition:opacity .12s, background .12s, color .12s;
}
.chat-item:hover .chat-pin-button,
.chat-item:focus-within .chat-pin-button,
.chat-pin-button:focus-visible,
.chat-pin-button.active { opacity:1; }
.chat-pin-button:hover,
.chat-pin-button.active { background:#EAF4FF; color:#2F80ED; }
.chat-pin-button .ui-icon,
.chat-remove-button .ui-icon { width:14px; height:14px; }
.chat-pin-indicator { display:inline-grid; place-items:center; margin-right:5px; color:#2F80ED; vertical-align:-2px; }
.chat-pin-indicator .ui-icon { width:13px; height:13px; }
.chat-preview { display:flex; align-items:center; gap:5px; min-width:0; }
.chat-preview-text { min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.chat-receipt { flex:0 0 auto; font-size:12px; line-height:1; font-weight:800; letter-spacing:-1px; color:#8A9BB0; }
.chat-receipt.delivered { color:#7590AA; }
.chat-receipt.read { color:#20A983; }

/* Pinned message strip */
.pinned-bar {
  position:relative; z-index:6; min-width:0;
  border-bottom:1px solid rgba(159,176,197,.27);
  background:rgba(255,255,255,.94);
  backdrop-filter:blur(14px) saturate(140%);
  display:flex; align-items:stretch;
}
.pinned-bar-main {
  flex:1 1 auto; width:auto; min-width:0; min-height:48px; border:0; background:transparent;
  display:grid; grid-template-columns:32px minmax(0,1fr) auto; align-items:center; gap:9px;
  padding:7px 18px; text-align:left; color:#07111F; cursor:pointer;
}
.pinned-bar-main:hover { background:#F5FAFF; }
.pinned-bar-icon { width:30px; height:30px; border-radius:10px; display:grid; place-items:center; color:#2F80ED; background:#EAF4FF; }
.pinned-bar-icon svg { width:17px; height:17px; fill:none; stroke:currentColor; stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round; }
.pinned-bar-copy { min-width:0; display:grid; gap:1px; }
.pinned-bar-copy strong { color:#2F80ED; font-size:11px; font-weight:760; }
.pinned-bar-copy > span { min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; color:#667C94; font-size:12px; }
.pinned-bar-count { min-width:22px; height:22px; padding:0 6px; border-radius:999px; display:grid; place-items:center; background:#EAF4FF; color:#2F80ED; font-size:10px; font-weight:800; }
.pinned-bar-unpin {
  flex:0 0 48px; width:48px; min-height:48px; border:0; border-left:1px solid rgba(159,176,197,.22);
  background:transparent; color:#667C94; display:grid; place-items:center; cursor:pointer;
}
.pinned-bar-unpin:hover { color:#2F80ED; background:#F5FAFF; }
.pinned-bar-unpin svg { width:18px; height:18px; fill:none; stroke:currentColor; stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round; }

/* Softer outgoing bubble from the approved Gaigram palette. */
.message-row.mine .bubble {
  color:#07111F;
  background:linear-gradient(135deg,#DDEEFF 0%,#D4ECFF 58%,#CBE8FF 100%);
  border-color:rgba(86,168,255,.32);
  box-shadow:0 6px 18px rgba(47,128,237,.10);
}
.message-row.mine .message-meta { color:#678099; }
.message-meta { font-size:12px; gap:6px; }
.receipt { font-size:12.5px; color:#7690A8; letter-spacing:-1.2px; }
.receipt.sent { color:#8298AE; }
.receipt.delivered { color:#6F89A2; }
.receipt.read { color:#18A47D; }
.message-row.mine .reply-quote { background:rgba(255,255,255,.52); border-left-color:#56A8FF; color:#07111F; }
.message-row.mine .reply-quote strong { color:#2478D8; }
.message-row.mine .reply-quote span { color:#60758D; }
.message-row.mine .attachment-card { background:rgba(255,255,255,.58); border-color:rgba(86,168,255,.25); }
.message-row.mine .attachment-copy span { color:#6F839A; }
.message-row.mine .attachment-icon { background:#EAF5FF; color:#2374D1; }
.message-row.mine .attachment-open { background:#EDF6FF; color:#2374D1; }
.message-row.mine .image-attachment,
.message-row.mine .video-attachment,
.message-row.mine .audio-attachment { background:rgba(238,247,255,.78); }
.message-row.mine .media-footer { color:#647B93; }
.message-row.mine .media-download { color:#2374D1; }
.message-actions button.active { color:#2F80ED; background:#EAF4FF; border-color:rgba(47,128,237,.25); }

/* File extension badge and narrow-window attachment layout. */
.attachment-card {
  min-width:0;
  width:clamp(250px,34vw,420px);
  max-width:100%;
  grid-template-columns:42px minmax(0,1fr) auto;
  overflow:visible;
}
.attachment-icon,
.draft-icon { font-size:inherit; }
.file-extension-badge {
  width:34px; height:30px; padding:0 4px; border-radius:7px;
  display:grid; place-items:center;
  background:linear-gradient(145deg,#2F80ED,#56A8FF);
  color:#fff; font-size:9px; font-weight:850; letter-spacing:.025em;
  overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
  box-shadow:0 3px 8px rgba(47,128,237,.15);
}
.attachment-open { white-space:nowrap; }

/* Locally bundled Twemoji-style SVG artwork (CC BY 4.0 attribution in vendor/twemoji/ATTRIBUTION.txt). */
.emoji-art,
.emoji-inline { display:inline-block; object-fit:contain; vertical-align:-.16em; user-select:none; pointer-events:none; }
.emoji-inline { width:1.18em; height:1.18em; margin:0 .035em; }
.emoji-picker-art { width:30px; height:30px; }
.emoji-tab-art { width:23px; height:23px; }
.emoji-item { display:grid; place-items:center; font-size:0; }
.emoji-tab { display:grid; place-items:center; font-size:0; }

@media (max-width:1100px) {
  .attachment-card { width:min(360px,100%); }
  .message-row.mine .message-actions { left:4px; }
  .message-actions { right:4px; }
}

@media (max-width:900px) and (min-width:761px) {
  .attachment-card {
    width:min(330px,100%);
    grid-template-columns:40px minmax(0,1fr);
  }
  .attachment-open { grid-column:2; justify-self:end; margin-top:2px; }
}

@media (max-width:760px) {
  .pinned-bar-main { padding-left:11px; padding-right:11px; }
  .attachment-card { width:100%; min-width:0; grid-template-columns:38px minmax(0,1fr) auto; }
  .bubble { max-width:90%; }
  .message-meta { font-size:11.5px; }
  .receipt { font-size:12px; }
}


/* v0.5.8-hotfix3 — stable chat wallpaper + isolated emoji artwork */
/* Keep the wallpaper on a dedicated layer inside the active conversation.
   This prevents the canvas from ending at the height of rendered messages. */
.chat-panel {
  background:#F7FBFF;
  background-image:none;
}
.active-chat {
  isolation:isolate;
  background:#F7FBFF;
}
.active-chat::before {
  content:"";
  position:absolute;
  z-index:0;
  top:70px;
  right:0;
  bottom:0;
  left:0;
  pointer-events:none;
  background-color:#F7FBFF;
  background-image:url('./assets/chat-wallpaper.png');
  background-repeat:repeat-x;
  background-position:center center;
  background-size:auto 100%;
}
.chat-header { grid-row:1; }
.pinned-bar { grid-row:2; }
.message-list {
  grid-row:3;
  height:100%;
  align-self:stretch;
  box-sizing:border-box;
  background:transparent;
}
.composer { grid-row:4; }

/* Emoji SVG artwork is intentionally confined to the picker.
   Messages themselves use native Unicode emoji so graphical replacement can
   never alter bubble dimensions or conversation layout. */
.emoji-picker {
  overflow:hidden;
}
.emoji-grid {
  grid-auto-rows:38px;
  align-content:start;
  /* Six complete desktop rows: 6×38 + 5×4 gap + 10/12px padding = 270px.
     Keeping the viewport on an exact row boundary prevents the last row from
     being sliced by the scroll container. */
  height:270px;
  max-height:none;
  gap:4px;
  padding:10px 10px 12px;
  scroll-padding-block:10px 12px;
  overflow-x:hidden;
  overflow-y:auto;
  overscroll-behavior:contain;
  scrollbar-gutter:stable;
}
.emoji-item {
  width:38px;
  height:38px;
  min-width:38px;
  min-height:38px;
  padding:3px;
  overflow:visible;
  line-height:1;
}
.emoji-picker-art {
  display:block;
  width:28px;
  height:28px;
  max-width:28px;
  max-height:28px;
  object-fit:contain;
  object-position:center;
  vertical-align:middle;
}
.emoji-tab {
  overflow:visible;
}
.emoji-tab-art {
  display:block;
  width:22px;
  height:22px;
  max-width:22px;
  max-height:22px;
  object-fit:contain;
  object-position:center;
  vertical-align:middle;
}

@media (max-width:760px) {
  .active-chat::before { top:68px; }
  .emoji-grid {
    grid-auto-rows:36px;
    /* Six complete compact rows: 6×36 + 5×4 gap + 9/11px padding = 256px. */
    height:256px;
    gap:4px;
    padding:9px 8px 11px;
    scroll-padding-block:9px 11px;
  }
  .emoji-item {
    width:36px;
    height:36px;
    min-width:36px;
    min-height:36px;
  }
  .emoji-picker-art { width:27px; height:27px; max-width:27px; max-height:27px; }
}

/* v0.5.8-hotfix4 — emoji row-boundary fix */
.emoji-grid {
  border-bottom-left-radius:17px;
  border-bottom-right-radius:17px;
}
.emoji-grid::after {
  content:"";
  display:block;
  height:0;
  grid-column:1 / -1;
}

/* v0.5.8-hotfix6 — usable category strip + hide unsupported emoji */
.emoji-tabs {
  overflow-x:auto;
  overflow-y:hidden;
  overscroll-behavior-inline:contain;
  scroll-behavior:smooth;
  touch-action:pan-x;
  -webkit-overflow-scrolling:touch;
}
.emoji-tab { scroll-margin-inline:12px; }

/* v0.5.9 — Gaigram Emoji Core */
.gaigram-emoji-inline {
  display:inline-block;
  width:1.22em;
  height:1.22em;
  margin:0 .035em;
  vertical-align:-.18em;
  object-fit:contain;
  user-select:none;
  pointer-events:none;
}
.emoji-art[data-emoji-source="gaigram"] {
  filter:drop-shadow(0 1px 1px rgba(7,17,31,.06));
}
.emoji-picker-art[data-emoji-source="gaigram"] {
  width:31px;
  height:31px;
  max-width:31px;
  max-height:31px;
}
.emoji-tab-art[data-emoji-source="gaigram"] {
  width:24px;
  height:24px;
  max-width:24px;
  max-height:24px;
}
.message-body .gaigram-emoji-inline,
.chat-preview-text .gaigram-emoji-inline,
.reply-quote .gaigram-emoji-inline,
#pinned-bar-text .gaigram-emoji-inline,
#reply-preview .gaigram-emoji-inline {
  vertical-align:-.2em;
}

/* v0.5.9-hotfix1 — glossy Gaigram Emoji + right-anchored picker + large emoji-only messages */
.emoji-picker {
  left:auto !important;
  right:58px !important;
  transform-origin:bottom right;
}

/* Picker remains compact; sent emoji get their own chat scale. */
.message-body.emoji-only {
  display:flex;
  align-items:center;
  gap:7px;
  width:max-content;
  max-width:100%;
  min-height:0;
  padding:1px 0 2px;
  line-height:1;
  letter-spacing:0;
}
.message-body.emoji-only-one {
  font-size:58px;
  line-height:1.04;
}
.message-body.emoji-only-few {
  font-size:44px;
  line-height:1.06;
}
.message-body.emoji-only-one .gaigram-emoji-inline {
  width:58px;
  height:58px;
  margin:0;
  vertical-align:middle;
  filter:drop-shadow(0 4px 5px rgba(103,72,22,.12));
}
.message-body.emoji-only-few .gaigram-emoji-inline {
  width:44px;
  height:44px;
  margin:0 1px;
  vertical-align:middle;
  filter:drop-shadow(0 3px 4px rgba(103,72,22,.10));
}
.message-body:not(.emoji-only) .gaigram-emoji-inline {
  width:1.22em;
  height:1.22em;
}

@media (max-width:760px) {
  .emoji-picker {
    left:auto !important;
    right:10px !important;
    width:min(392px,calc(100vw - 20px));
  }
  .message-body.emoji-only-one { font-size:54px; }
  .message-body.emoji-only-one .gaigram-emoji-inline { width:54px; height:54px; }
  .message-body.emoji-only-few { font-size:41px; }
  .message-body.emoji-only-few .gaigram-emoji-inline { width:41px; height:41px; }
}

/* v0.5.9-hotfix3 — startup, links, receipts and download polish */
.message-link {
  color:#176FD1;
  text-decoration:underline;
  text-decoration-thickness:1px;
  text-underline-offset:2px;
  overflow-wrap:anywhere;
  word-break:break-word;
}
.message-link:hover { color:#0E5DB9; }
.message-row.mine .message-link { color:#0D67C7; }
.chat-side { align-content:start; gap:4px; padding-top:2px; }
.chat-side .chat-receipt { justify-self:end; margin-top:1px; font-size:12.5px; }
.media-download {
  display:inline-flex; align-items:center; justify-content:center;
  min-height:28px; padding:4px 9px; border-radius:8px;
  font-size:12.5px; line-height:1; font-weight:760;
  background:#EAF4FF; text-decoration:none;
}
.media-download:hover { background:#DDEEFF; text-decoration:none; }
.message-row.mine .media-download { background:rgba(255,255,255,.62); color:#176FD1; }
.attachment-open { min-height:30px; padding:7px 11px; font-size:12px; }

.build-version{display:block;text-align:center;color:var(--muted,#9fb0c5);font-size:12px;line-height:1.4;margin:0 0 10px}

/* v0.6.0-rc3: presence indicator in direct-chat list */
.chat-item-title { display:flex; align-items:center; gap:6px; min-width:0; }
.chat-item-title-text { min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.chat-online-dot { flex:0 0 auto; width:7px; height:7px; margin-left:1px; }

/* v0.6.0-rc3 — per-user wallpaper for an individual chat */
.active-chat::before {
  background-image:var(--chat-wallpaper-image, url('./assets/chat-wallpaper.png'));
}
.active-chat.has-custom-wallpaper::before {
  background-repeat:no-repeat;
  background-position:center center;
  background-size:cover;
}

#chat-wallpaper-button {
  color:#2F80ED;
  background:#EDF6FF;
  border:1px solid rgba(86,168,255,.18);
  flex:0 0 auto;
}
#chat-wallpaper-button:hover { background:#E1F0FF; }
#chat-wallpaper-button svg {
  width:20px;
  height:20px;
  fill:none;
  stroke:currentColor;
  stroke-width:1.8;
  stroke-linecap:round;
  stroke-linejoin:round;
}

.chat-wallpaper-body { display:grid; gap:15px; }
.chat-wallpaper-preview {
  position:relative;
  width:100%;
  aspect-ratio:16/9;
  min-height:180px;
  overflow:hidden;
  border:1px solid rgba(159,176,197,.34);
  border-radius:18px;
  background-color:#F7FBFF;
  background-image:url('./assets/chat-wallpaper.png');
  background-repeat:repeat-x;
  background-position:center center;
  background-size:auto 100%;
  box-shadow:inset 0 1px 0 rgba(255,255,255,.75);
}
.chat-wallpaper-preview.custom {
  background-image:var(--preview-wallpaper-image);
  background-repeat:no-repeat;
  background-position:center center;
  background-size:cover;
}
.chat-wallpaper-preview::after {
  content:"";
  position:absolute;
  left:10%;
  right:10%;
  bottom:12%;
  height:28%;
  border-radius:16px;
  background:linear-gradient(135deg,rgba(255,255,255,.82),rgba(255,255,255,.62));
  border:1px solid rgba(159,176,197,.22);
  box-shadow:0 8px 24px rgba(7,17,31,.08);
  opacity:.68;
}
.chat-wallpaper-copy { display:grid; gap:4px; }
.chat-wallpaper-copy strong { color:#07111F; font-size:15px; }
.chat-wallpaper-copy span,
.chat-wallpaper-hint { color:#71849A; font-size:12.5px; line-height:1.45; }
.chat-wallpaper-actions { display:flex; gap:10px; flex-wrap:wrap; }
.chat-wallpaper-actions .primary,
.chat-wallpaper-actions .secondary { flex:1 1 180px; min-height:43px; }
.chat-wallpaper-actions button:disabled { opacity:.48; cursor:not-allowed; }
.chat-wallpaper-hint { margin:0; }

@media (max-width:760px) {
  #chat-wallpaper-button { width:36px; height:36px; }
  .chat-wallpaper-preview { min-height:150px; }
  .chat-wallpaper-actions { display:grid; grid-template-columns:1fr; }
}
