: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; }
.profile-identity-button { cursor:pointer; border-radius:10px; outline:none; }
.profile-identity-button:focus-visible { box-shadow:0 0 0 3px rgba(47,128,237,.16); }
.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; }
.media-load-button { border:0; border-radius:10px; padding:9px 13px; background:#EDF6FF; color:#2F80ED; font-weight:720; cursor:pointer; }
.media-load-button:hover { background:#DDEFFF; }
.media-load-button:disabled { opacity:.65; cursor:default; }
.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; }
.profile-modal-body, .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) { .profile-modal-body, .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, .auth-form textarea {
  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, .auth-form textarea::placeholder { color:#9FB0C5; }
.auth-form input:focus, .auth-form textarea: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 minmax(88px,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:nowrap; min-width:0; }
.group-member-primary { white-space:nowrap; }
.group-member-overflow { position:relative; }
.group-member-action-menu { min-width:220px; }
.group-member-action-menu button:disabled { opacity:.55; cursor:default; }
.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-action-menu { right:0; left:auto; max-width:min(260px,calc(100vw - 48px)); }
  .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:linear-gradient(135deg, var(--surface-2, #10212A), var(--bg, #0A1018));
  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:linear-gradient(135deg, var(--surface-2, #10212A), var(--bg, #0A1018));
  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, linear-gradient(135deg, var(--surface-2, #10212A), var(--bg, #0A1018)));
}
.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:linear-gradient(135deg, var(--surface-2, #10212A), var(--bg, #0A1018));
  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; }
}


/* v0.6.0-rc3 staging fixes: session restore splash + compact mobile message actions. */
.boot-view { position:fixed; inset:0; z-index:120; display:grid; place-items:center; background:#F7FBFF; }
.boot-card { display:grid; justify-items:center; gap:10px; color:#0B1728; font-size:14px; }
.boot-card img { width:64px; height:64px; object-fit:contain; }
.boot-card strong { font-size:23px; }
.boot-card span { color:#728198; }

@media (max-width:760px) {
  .message-actions { opacity:0 !important; transform:translateY(3px) !important; pointer-events:none !important; }
  .message-row.actions-open .message-actions { opacity:1 !important; transform:none !important; pointer-events:auto !important; }
}


/* v0.6.0-rc3 staging fix 3: keep Settings footer fully inside short viewports. */
#profile-modal, #settings-modal { display:flex; flex-direction:column; }
#profile-modal .profile-modal-body, #settings-modal .settings-modal-body { flex:1 1 auto; min-height:0; max-height:none; overflow:auto; }
#profile-modal .settings-footer { flex:0 0 auto; position:relative; z-index:1; }

/* v0.6.0-rc3 staging-fix7: sidebar sections, contacts and per-chat drafts */
.sidebar-tabs { display:grid; grid-template-columns:1fr 1fr; gap:6px; padding:10px 12px 0; background:#fff; }
.sidebar-tab { min-height:36px; border:1px solid rgba(159,176,197,.34); border-radius:11px; background:#F7FBFF; color:#70849B; font-weight:750; cursor:pointer; }
.sidebar-tab:hover { background:#EEF6FF; color:#2F80ED; }
.sidebar-tab.active { background:linear-gradient(135deg,#2F80ED,#56A8FF); color:#fff; border-color:transparent; box-shadow:0 5px 14px rgba(47,128,237,.18); }
.contact-list { overflow:auto; min-height:0; flex:1; padding:7px 8px 14px; background:#fff; }
.contact-item { width:100%; display:grid; grid-template-columns:42px minmax(0,1fr) auto; align-items:center; gap:10px; padding:10px; margin:2px 0; border:1px solid transparent; border-radius:14px; background:transparent; color:#07111F; text-align:left; cursor:pointer; }
.contact-item:hover { background:#F4F9FF; border-color:rgba(86,168,255,.14); }
.contact-avatar { width:42px; height:42px; }
.contact-copy { min-width:0; display:grid; gap:2px; }
.contact-copy strong { overflow:hidden; white-space:nowrap; text-overflow:ellipsis; font-size:14px; }
.contact-copy span { overflow:hidden; white-space:nowrap; text-overflow:ellipsis; color:#7B8FA7; font-size:12px; }
.contact-online-dot { width:8px; height:8px; }
.draft-label { color:#E07A2D; font-weight:750; margin-right:5px; }
.draft-preview-text { color:#778BA3; }

/* v0.6.0-rc3 staging-fix8: fixed bottom sidebar navigation. */
.sidebar-tabs {
  flex:0 0 auto;
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:8px;
  padding:8px 12px max(8px, env(safe-area-inset-bottom));
  margin:0;
  border-top:1px solid rgba(159,176,197,.32);
  background:rgba(255,255,255,.98);
  box-shadow:0 -8px 22px rgba(7,17,31,.035);
  z-index:4;
}
.sidebar-tab {
  min-height:44px;
  display:flex;
  align-items:center;
  justify-content:center;
  gap:7px;
  border:1px solid transparent;
  border-radius:12px;
  background:transparent;
  color:#70849B;
  font-weight:750;
  cursor:pointer;
}
.sidebar-tab svg { width:20px; height:20px; fill:none; stroke:currentColor; stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round; }
.sidebar-tab:hover { background:#EEF6FF; color:#2F80ED; }
.sidebar-tab.active { background:rgba(47,128,237,.10); color:#2F80ED; border-color:rgba(47,128,237,.14); box-shadow:none; }


/* v0.6.0-rc3 staging fix9 — stable tail positioning / unread boundary / mobile media */
.message-list.initial-positioning { scroll-behavior:auto !important; }
.new-messages-divider {
  display:flex;
  align-items:center;
  gap:10px;
  margin:9px 0 7px;
  color:#4D82B7;
  font-size:12px;
  font-weight:800;
  letter-spacing:.01em;
}
.new-messages-divider::before,
.new-messages-divider::after {
  content:"";
  height:1px;
  flex:1 1 auto;
  background:rgba(86,168,255,.35);
}
.new-messages-divider span {
  flex:0 0 auto;
  padding:4px 10px;
  border-radius:999px;
  background:rgba(238,247,255,.94);
  border:1px solid rgba(86,168,255,.26);
  box-shadow:0 4px 14px rgba(45,113,179,.08);
}
.new-messages-button {
  position:absolute;
  z-index:8;
  right:22px;
  bottom:82px;
  width:46px;
  height:46px;
  border-radius:999px;
  border:1px solid rgba(86,168,255,.34);
  background:rgba(255,255,255,.96);
  color:#2E82E6;
  box-shadow:0 8px 24px rgba(39,96,159,.18);
  display:grid;
  place-items:center;
  cursor:pointer;
}
.new-messages-button.hidden { display:none; }
.new-messages-button svg { width:22px; height:22px; fill:none; stroke:currentColor; stroke-width:2; stroke-linecap:round; stroke-linejoin:round; }
.new-messages-count {
  position:absolute;
  top:-5px;
  right:-5px;
  min-width:20px;
  height:20px;
  padding:0 5px;
  border-radius:999px;
  display:grid;
  place-items:center;
  background:#2F80ED;
  color:#fff;
  font-size:10px;
  font-weight:800;
  border:2px solid #fff;
}
.new-messages-count:empty { display:none; }
@media (max-width:760px) {
  .new-messages-button { right:12px; bottom:72px; width:42px; height:42px; }
  .new-messages-divider { margin-left:2px; margin-right:2px; }
  .media-decrypting { min-height:118px; }
}


/* v0.6.0-rc4: private contacts, contact requests and exact username lookup. */
.sidebar-tab { position:relative; }
.sidebar-badge { min-width:18px; height:18px; padding:0 5px; border-radius:999px; display:inline-flex; align-items:center; justify-content:center; background:#E5484D; color:#fff; font-size:10px; line-height:1; font-weight:800; box-shadow:0 0 0 2px #fff; }
.sidebar-badge.hidden { display:none; }
.contact-list { display:block; }
.contact-list.hidden { display:none; }
.contact-section-title { display:flex; align-items:center; justify-content:space-between; gap:8px; padding:10px 9px 5px; color:#788CA4; font-size:11px; font-weight:800; text-transform:uppercase; letter-spacing:.06em; }
.contact-section-count { min-width:20px; height:20px; display:inline-flex; align-items:center; justify-content:center; padding:0 6px; border-radius:999px; background:#EEF6FF; color:#2F80ED; font-size:10px; letter-spacing:0; }
.contact-item.contact-item-row { display:grid; grid-template-columns:minmax(0,1fr) auto; gap:4px; padding:2px 4px; margin:2px 0; border:0; background:transparent; }
.contact-main { min-width:0; width:100%; display:grid; grid-template-columns:42px minmax(0,1fr) auto; align-items:center; gap:10px; padding:8px 6px; border:1px solid transparent; border-radius:12px; background:transparent; color:#07111F; text-align:left; cursor:pointer; }
.contact-main:hover { background:#F4F9FF; border-color:rgba(86,168,255,.14); }
.contact-remove { align-self:center; width:34px; height:34px; display:grid; place-items:center; border:0; border-radius:10px; background:transparent; color:#9AA9BA; cursor:pointer; }
.contact-remove:hover { background:#FFF0F0; color:#D64545; }
.contact-remove .ui-icon { width:17px; height:17px; }
.contact-request, .contact-lookup-card { display:grid; grid-template-columns:42px minmax(0,1fr); align-items:start; gap:8px 10px; margin:4px 4px 7px; padding:10px; border:1px solid rgba(159,176,197,.24); border-radius:14px; background:#FAFCFF; }
.contact-request.incoming { border-color:rgba(47,128,237,.22); background:#F7FBFF; }
.contact-request-avatar { width:42px; height:42px; }
.contact-request-actions { grid-column:2; display:flex; flex-wrap:wrap; justify-content:flex-start; gap:5px; margin-top:-2px; }
.contact-request-accept, .contact-lookup-action { min-height:28px; padding:0 9px; border:0; border-radius:8px; background:#2F80ED; color:#fff; font-size:12px; font-weight:750; cursor:pointer; }
.contact-request-decline { min-height:28px; padding:0 8px; border:1px solid rgba(159,176,197,.36); border-radius:8px; background:#fff; color:#6D8198; font-size:12px; font-weight:700; cursor:pointer; }
.contact-request-accept:hover, .contact-lookup-action:not(:disabled):hover { background:#246FCE; }
.contact-request-decline:hover { background:#F4F7FA; }
.contact-request-pending { color:#7C8FA7; font-size:12px; white-space:nowrap; }
.contact-lookup-action { grid-column:2; justify-self:start; }
.contact-lookup-action:disabled { background:#EDF2F7; color:#8799AC; cursor:default; }
.contact-lookup-empty { margin:8px 4px; padding:12px; border:1px dashed rgba(159,176,197,.38); border-radius:12px; color:#7C8FA7; font-size:12px; text-align:center; }

@media (max-width:760px) {
  .contact-request, .contact-lookup-card { grid-template-columns:42px minmax(0,1fr); }
  .contact-lookup-action { grid-column:2; justify-self:start; min-width:110px; }
}


/* v0.6.0-rc4 owner server management. */
.owner-management-entry { margin-top:6px; }
.settings-nav-card { width:100%; display:grid; grid-template-columns:42px minmax(0,1fr) auto; align-items:center; gap:11px; padding:12px; border:1px solid rgba(159,176,197,.32); border-radius:14px; background:#FAFCFF; color:#07111F; text-align:left; cursor:pointer; }
.settings-nav-card:hover { background:#F3F8FE; border-color:rgba(47,128,237,.22); }
.settings-nav-icon { width:42px; height:42px; display:grid; place-items:center; border-radius:12px; background:#EAF4FF; color:#2F80ED; }
.settings-nav-icon svg { width:23px; height:23px; fill:none; stroke:currentColor; stroke-width:1.7; stroke-linecap:round; stroke-linejoin:round; }
.settings-nav-copy { min-width:0; display:grid; gap:3px; }
.settings-nav-copy strong { font-size:14px; }
.settings-nav-copy > span { color:#7C8FA5; font-size:12px; line-height:1.35; }
.settings-nav-chevron { color:#91A3B8; font-size:26px; line-height:1; }
.modal-title-row { min-width:0; display:flex; align-items:center; gap:8px; }
.modal-back-button svg { width:20px; height:20px; fill:none; stroke:currentColor; stroke-width:2; stroke-linecap:round; stroke-linejoin:round; }
.server-management-body { display:grid; gap:16px; align-content:start; grid-template-rows:auto auto; }
.server-management-tabs { display:grid; grid-template-columns:1fr 1fr; gap:4px; padding:4px; border:1px solid rgba(159,176,197,.28); border-radius:12px; background:#F1F5F9; }
.server-management-tab { min-height:36px; border:0; border-radius:9px; background:transparent; color:#6D8198; font-weight:750; cursor:pointer; }
.server-management-tab.active { background:#fff; color:#176BCB; box-shadow:0 2px 7px rgba(7,17,31,.08); }
.server-management-panel.hidden { display:none; }
.server-section-heading { align-items:flex-end; gap:12px; }
.server-section-heading > div { min-width:0; display:grid; gap:3px; }
.section-subtitle { color:#7C8FA5; font-size:12px; }
.server-user-list { margin-bottom:4px; }
.server-user-row { align-items:center; }
.server-user-avatar { width:42px; height:42px; flex:0 0 42px; }
.server-role-badge { display:inline-flex; align-items:center; min-height:18px; margin-left:5px; padding:0 6px; border-radius:999px; background:#EDF2F7; color:#72859A; font-size:9px; font-weight:800; text-transform:uppercase; vertical-align:1px; }
.server-role-badge.owner { background:#FFF3D6; color:#A96B00; }
.server-role-badge.admin { background:#EAF4FF; color:#176BCB; }
.invite-row strong { overflow-wrap:anywhere; }
@media (max-width:760px) {
  .server-section-heading { align-items:flex-start; flex-direction:column; }
  .server-section-heading .secondary { align-self:flex-start; }
  .server-user-row { padding:10px; }
}


/* v0.6.0-rc5: private local chat search and encrypted chat content browser. */
.chat-search-bar {
  flex:0 0 auto;
  min-height:52px;
  display:flex;
  align-items:center;
  gap:8px;
  padding:7px 14px;
  border-bottom:1px solid rgba(159,176,197,.26);
  background:rgba(255,255,255,.96);
  position:relative;
  z-index:6;
}
.chat-search-bar.hidden { display:none; }
.chat-search-input-wrap { min-width:0; flex:1 1 auto; height:38px; display:flex; align-items:center; gap:8px; padding:0 11px; border:1px solid rgba(159,176,197,.38); border-radius:12px; background:#F7FBFF; }
.chat-search-input-wrap:focus-within { background:#fff; border-color:#56A8FF; box-shadow:0 0 0 3px rgba(47,128,237,.08); }
.chat-search-input-wrap svg { width:18px; height:18px; flex:0 0 auto; fill:none; stroke:#7D91A8; stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round; }
.chat-search-input-wrap input { min-width:0; width:100%; border:0; outline:0; background:transparent; color:#10243A; font:inherit; }
.chat-search-status { flex:0 0 auto; max-width:150px; color:#70849B; font-size:12px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.chat-search-nav, .chat-search-close { width:34px; height:34px; min-width:34px; }
.chat-search-nav:disabled { opacity:.35; cursor:default; }
.chat-search-button.active { background:#EAF5FF; color:#2374D1; }

.chat-content-modal { width:min(760px, calc(100% - 28px)); height:min(760px, calc(100dvh - 28px)); display:flex; flex-direction:column; }
.chat-content-modal.hidden { display:none; }
.chat-content-tabs { flex:0 0 auto; display:grid; grid-template-columns:repeat(3,1fr); gap:6px; padding:10px 14px; border-bottom:1px solid rgba(159,176,197,.26); background:#FBFDFF; }
.chat-content-tab { min-height:38px; border:1px solid transparent; border-radius:11px; background:transparent; color:#70849B; font-weight:750; cursor:pointer; }
.chat-content-tab:hover { background:#F0F7FF; color:#2F80ED; }
.chat-content-tab.active { background:#EAF5FF; border-color:rgba(47,128,237,.14); color:#2374D1; }
.chat-content-tab span { font-size:11px; font-weight:700; opacity:.72; }
.chat-content-body { flex:1 1 auto; min-height:0; max-height:none; overflow:auto; padding:14px; }
.chat-content-progress { padding:18px; color:#70849B; text-align:center; }
.chat-content-progress.hidden { display:none; }
.chat-content-list.media { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:7px; }
.chat-media-tile { position:relative; min-width:0; aspect-ratio:1/1; padding:0; border:0; border-radius:12px; overflow:hidden; background:#EAF2FA; cursor:pointer; }
.chat-media-tile img { width:100%; height:100%; object-fit:cover; display:block; }
.chat-media-tile img.hidden { display:none; }
.chat-media-placeholder { position:absolute; inset:0; display:grid; place-items:center; color:#4E789F; font-size:30px; background:linear-gradient(135deg,#EEF7FF,#DCECF8); }
.chat-media-kind { position:absolute; right:7px; bottom:7px; padding:3px 7px; border-radius:999px; background:rgba(7,17,31,.62); color:#fff; font-size:10px; font-weight:800; }
.chat-media-kind:empty { display:none; }
.chat-content-list.files, .chat-content-list.links { display:flex; flex-direction:column; gap:8px; }
.chat-file-row, .chat-link-row { display:flex; align-items:center; gap:11px; min-width:0; padding:11px; border:1px solid rgba(159,176,197,.28); border-radius:13px; background:#fff; }
.chat-file-icon, .chat-link-icon { width:42px; height:42px; flex:0 0 42px; display:grid; place-items:center; border-radius:11px; background:#EAF5FF; color:#2374D1; font-weight:850; }
.chat-file-copy, .chat-link-copy { min-width:0; flex:1 1 auto; display:flex; flex-direction:column; gap:3px; }
.chat-file-copy strong, .chat-link-copy a { min-width:0; color:#142A41; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; text-decoration:none; }
.chat-file-copy span, .chat-link-copy span, .chat-link-copy small { color:#74889E; font-size:12px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.chat-link-copy a:hover { color:#2374D1; text-decoration:underline; }
.chat-content-actions { flex:0 0 auto; display:flex; gap:6px; }
.chat-content-actions button, .chat-link-row > button { min-height:32px; padding:0 10px; border:1px solid rgba(47,128,237,.16); border-radius:9px; background:#F0F7FF; color:#2374D1; font-size:11px; font-weight:750; cursor:pointer; }
.chat-content-empty { grid-column:1/-1; min-height:220px; display:grid; place-items:center; color:#70849B; }

@media (max-width:760px) {
  .chat-search-bar { padding:6px 8px; gap:5px; }
  .chat-search-status { max-width:72px; font-size:10px; }
  .chat-search-nav, .chat-search-close { width:32px; height:32px; min-width:32px; }
  .chat-content-modal { height:92dvh; }
  .chat-content-list.media { grid-template-columns:repeat(3,minmax(0,1fr)); gap:4px; }
  .chat-file-row, .chat-link-row { align-items:flex-start; flex-wrap:wrap; }
  .chat-content-actions { width:100%; padding-left:53px; }
  .chat-content-actions button { flex:1 1 auto; }
  .chat-link-row > button { margin-left:53px; }
}

/* rc5 grid placement for optional search + pinned bars. */
.active-chat { grid-template-rows:70px auto auto minmax(0,1fr) auto; }
.chat-header { grid-row:1; }
.chat-search-bar { grid-row:2; }
.pinned-bar { grid-row:3; }
.message-list { grid-row:4; }
.composer { grid-row:5; }
@media (max-width:760px) {
  .chat-header { gap:4px; padding-left:7px; padding-right:7px; background:#fff; backdrop-filter:none; -webkit-backdrop-filter:none; }
  .chat-header .icon-button { width:34px; height:34px; min-width:34px; border-radius:10px; }
  .chat-header .chat-avatar { width:36px; height:36px; min-width:36px; font-size:13px; }
  .chat-title-wrap { gap:1px; }
  .chat-title-wrap strong { font-size:14px; }
  .chat-security, .chat-subtitle { font-size:10px; }
}

.chat-search-match { background:#FFE38A; color:inherit; border-radius:3px; padding:0 1px; box-shadow:0 0 0 1px rgba(197,146,0,.10); }

/* v0.6.0-rc6.1: owner announcements and read-only system channel. */
.server-management-tabs { grid-template-columns:repeat(3,1fr); }
.announcement-admin-form { display:grid; gap:11px; padding:14px; border:1px solid rgba(159,176,197,.28); border-radius:14px; background:#FAFCFF; }
.announcement-admin-form label { min-width:0; display:grid; gap:6px; color:#566C84; font-size:12px; font-weight:700; }
.announcement-admin-form input,
.announcement-admin-form select,
.announcement-admin-form textarea { width:100%; min-width:0; border:1px solid rgba(159,176,197,.38); border-radius:10px; background:#fff; color:#10243A; font:inherit; padding:9px 10px; outline:0; }
.announcement-admin-form textarea { resize:vertical; min-height:104px; line-height:1.45; }
.announcement-admin-form input:focus,
.announcement-admin-form select:focus,
.announcement-admin-form textarea:focus { border-color:#56A8FF; box-shadow:0 0 0 3px rgba(47,128,237,.08); }
.announcement-form-grid { display:grid; grid-template-columns:minmax(0,1fr) minmax(190px,.55fr); gap:10px; }
.announcement-admin-actions { display:flex; justify-content:flex-end; }
.announcement-history-heading { margin-top:2px; }
.admin-announcement-list { display:grid; gap:8px; }
.admin-announcement-row { display:grid; gap:7px; padding:12px; border:1px solid rgba(159,176,197,.26); border-radius:13px; background:#fff; }
.admin-announcement-top { display:flex; align-items:flex-start; justify-content:space-between; gap:10px; }
.admin-announcement-copy { min-width:0; display:grid; gap:3px; }
.admin-announcement-copy strong { font-size:13px; overflow-wrap:anywhere; }
.admin-announcement-copy span { color:#71869D; font-size:11px; line-height:1.4; }
.admin-announcement-body { color:#40566E; font-size:12px; line-height:1.45; white-space:pre-wrap; overflow-wrap:anywhere; }
.announcement-status { flex:0 0 auto; display:inline-flex; align-items:center; min-height:22px; padding:0 8px; border-radius:999px; background:#EEF4FA; color:#6C8198; font-size:9px; font-weight:850; text-transform:uppercase; }
.announcement-status.published { background:#EAF8F0; color:#2F8A5E; }
.announcement-status.scheduled { background:#EAF4FF; color:#2F80ED; }
.announcement-status.expired { background:#F2F4F7; color:#8998A8; }
.announcement-admin-meta { display:flex; flex-wrap:wrap; gap:6px 12px; color:#7B8FA5; font-size:10px; }
.announcement-cancel { justify-self:start; min-height:30px; padding:0 9px; border:1px solid rgba(214,69,69,.22); border-radius:8px; background:#FFF7F7; color:#C93D3D; font-size:11px; font-weight:750; cursor:pointer; }
.announcement-cancel:hover { background:#FFECEC; }

.announcement-banner { position:absolute; z-index:18; top:78px; left:50%; transform:translateX(-50%); width:min(760px,calc(100% - 36px)); min-height:52px; display:grid; grid-template-columns:34px minmax(0,1fr) 22px; align-items:center; gap:10px; padding:9px 12px; border:1px solid rgba(47,128,237,.20); border-radius:14px; background:rgba(255,255,255,.97); color:#10243A; text-align:left; box-shadow:0 12px 34px rgba(23,75,129,.14); cursor:pointer; backdrop-filter:blur(12px); }
.announcement-banner.hidden { display:none; }
.announcement-banner.important { border-color:rgba(225,143,31,.34); background:rgba(255,250,239,.98); }
.announcement-banner.maintenance { border-color:rgba(126,92,230,.28); background:rgba(249,246,255,.98); }
.announcement-banner-icon { width:32px; height:32px; display:grid; place-items:center; border-radius:10px; background:#EAF5FF; color:#2374D1; font-weight:900; }
.announcement-banner.important .announcement-banner-icon { background:#FFF0D8; color:#B56A0A; }
.announcement-banner.maintenance .announcement-banner-icon { background:#EFE9FF; color:#6E4BD5; }
.announcement-banner-copy { min-width:0; display:grid; gap:2px; }
.announcement-banner-copy strong,
.announcement-banner-copy span { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.announcement-banner-copy strong { font-size:12px; }
.announcement-banner-copy span { color:#6F849B; font-size:11px; }
.announcement-banner-open { color:#8BA0B7; font-size:24px; line-height:1; }

.system-chat-item .chat-avatar { background:linear-gradient(135deg,#2F80ED,#6A62E8); color:#fff; }
.system-chat-badge { display:none; }
.announcement-chat { position:absolute; inset:0; z-index:3; min-width:0; min-height:0; overflow:hidden; display:grid; grid-template-rows:70px minmax(0,1fr) auto; background:#F5F9FD; }
.announcement-chat.hidden { display:none; }
.announcement-chat-avatar { background:linear-gradient(135deg,#2F80ED,#6A62E8); color:#fff; }
.announcement-message-list { min-height:0; overflow:auto; padding:24px clamp(12px,4vw,42px); display:flex; flex-direction:column; gap:12px; }
.announcement-message-card { width:min(760px,100%); margin:0 auto; padding:15px 16px; border:1px solid rgba(159,176,197,.28); border-radius:16px; background:#fff; box-shadow:0 7px 22px rgba(31,77,124,.06); }
.announcement-message-card.important { border-left:4px solid #E39724; }
.announcement-message-card.maintenance { border-left:4px solid #7656D8; }
.announcement-message-head { display:flex; align-items:flex-start; justify-content:space-between; gap:10px; }
.announcement-message-sender { min-width:0; display:flex; align-items:center; gap:7px; flex-wrap:wrap; }
.announcement-message-sender strong { font-size:13px; }
.announcement-official { display:none; }
.announcement-message-time { flex:0 0 auto; color:#8799AC; font-size:10px; }
.announcement-message-card h3 { margin:9px 0 6px; color:#132B43; font-size:15px; }
.announcement-message-body { margin:0; color:#40566E; font-size:13px; line-height:1.55; white-space:pre-wrap; overflow-wrap:anywhere; }
.announcement-readonly { min-height:52px; display:flex; align-items:center; justify-content:center; gap:7px; padding:10px 14px max(10px,env(safe-area-inset-bottom)); border-top:1px solid rgba(159,176,197,.25); background:#fff; color:#7A8EA5; font-size:11px; font-weight:650; text-align:center; }
.announcement-empty { min-height:240px; display:grid; place-items:center; color:#7A8EA5; text-align:center; }

@media (max-width:760px) {
  .server-management-tabs { grid-template-columns:repeat(3,minmax(0,1fr)); gap:3px; }
  .server-management-tab { min-height:34px; padding:0 5px; font-size:11px; }
  .announcement-form-grid { grid-template-columns:1fr; }
  .announcement-admin-actions .primary { width:100%; }
  .announcement-banner { top:76px; width:calc(100% - 18px); grid-template-columns:30px minmax(0,1fr) 18px; padding:8px 9px; border-radius:12px; }
  .announcement-banner-icon { width:28px; height:28px; border-radius:9px; }
  .announcement-chat { grid-template-rows:68px minmax(0,1fr) auto; }
  .announcement-message-list { padding:18px 10px; }
  .announcement-message-card { padding:13px; border-radius:14px; }
}


/* v0.6.0-rc6.2: system-channel branding, stable server tabs and scrollable announcement history. */
.system-announcement-avatar {
  overflow:hidden;
  padding:5px;
  background:#fff;
  border:1px solid rgba(47,128,237,.16);
  box-shadow:0 4px 14px rgba(47,128,237,.10);
}
.system-announcement-avatar img {
  display:block;
  width:100%;
  height:100%;
  object-fit:contain;
}
.system-announcement-title {
  min-width:0;
  display:inline-flex;
  align-items:center;
  gap:4px;
}
.system-verified-badge {
  flex:0 0 auto;
  width:16px;
  height:16px;
  margin-left:4px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  color:#2F80ED;
  vertical-align:-3px;
  cursor:help;
}
.system-verified-badge svg {
  width:16px;
  height:16px;
  display:block;
  overflow:visible;
}
.system-verified-badge circle {
  fill:currentColor;
  stroke:none;
}
.system-verified-badge path {
  fill:none;
  stroke:#fff;
  stroke-width:1.9;
  stroke-linecap:round;
  stroke-linejoin:round;
}
.announcement-message-sender {
  flex-wrap:nowrap;
}
.announcement-message-sender strong {
  min-width:0;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}
.admin-announcement-list {
  max-height:min(320px, 36dvh);
  min-height:92px;
  overflow-y:auto;
  overflow-x:hidden;
  padding-right:5px;
  margin-bottom:0;
  overscroll-behavior:contain;
  scrollbar-gutter:stable;
  scrollbar-width:thin;
  scrollbar-color:rgba(159,176,197,.58) transparent;
}
.admin-announcement-list::-webkit-scrollbar { width:8px; }
.admin-announcement-list::-webkit-scrollbar-thumb {
  background:rgba(159,176,197,.50);
  border-radius:999px;
}
.admin-announcement-list::-webkit-scrollbar-track { background:transparent; }
#server-management-modal {
  display:flex;
  flex-direction:column;
  height:min(820px, calc(100dvh - 28px));
}
#server-management-modal > .server-management-body {
  flex:1 1 auto;
  min-height:0;
  max-height:none;
  overflow-y:auto;
}
@media (max-width:760px) {
  .system-verified-badge,
  .system-verified-badge svg { width:15px; height:15px; }
  .admin-announcement-list { max-height:34dvh; }
  #server-management-modal { height:92dvh; }
}

/* v0.6.0-rc6.3: lock server-management chrome in place; only the active panel scrolls. */
#server-management-modal {
  display:grid;
  grid-template-rows:62px minmax(0,1fr);
  height:min(820px, calc(100dvh - 28px));
}
#server-management-modal > header {
  position:relative;
  z-index:2;
  width:100%;
  height:62px;
  min-height:62px;
  flex:0 0 62px;
  background:#FBFDFF;
}
#server-management-modal > .server-management-body {
  display:grid;
  grid-template-rows:auto minmax(0,1fr);
  align-content:stretch;
  gap:16px;
  min-height:0;
  max-height:none;
  overflow:hidden;
  padding:18px;
}
#server-management-modal .server-management-tabs {
  min-height:46px;
  height:46px;
  align-self:start;
  flex:0 0 auto;
}
#server-management-modal .server-management-panel {
  min-width:0;
  min-height:0;
  height:100%;
  overflow-y:auto;
  overflow-x:hidden;
  padding-right:4px;
  overscroll-behavior:contain;
  scrollbar-gutter:stable;
  scrollbar-width:thin;
  scrollbar-color:rgba(159,176,197,.55) transparent;
}
#server-management-modal .server-management-panel::-webkit-scrollbar { width:8px; }
#server-management-modal .server-management-panel::-webkit-scrollbar-thumb {
  background:rgba(159,176,197,.48);
  border-radius:999px;
}
#server-management-modal .server-management-panel::-webkit-scrollbar-track { background:transparent; }
@media (max-width:760px) {
  #server-management-modal {
    height:92dvh;
    grid-template-rows:62px minmax(0,1fr);
  }
  #server-management-modal > .server-management-body { padding:14px; gap:12px; }
  #server-management-modal .server-management-tabs { min-height:42px; height:42px; }
}


/* v0.6.0-rc6.5: restored original incoming-message chime at higher gain. */


/* v0.6.0-rc6.7 — safer chat actions + resilient notification audio */
/* Pin/delete are intentionally removed from sidebar hover state. The sidebar is
   now one large, unambiguous click target; chat management lives in the open
   conversation header menu. */
.chat-item-actions, .chat-pin-button, .chat-remove-button { display:none !important; }
.chat-actions-wrap { position:relative; flex:0 0 auto; display:grid; place-items:center; }
.chat-actions-menu {
  position:absolute; z-index:80; top:calc(100% + 8px); right:0; width:210px; padding:6px;
  border:1px solid #D6E1EE; border-radius:12px; background:#fff;
  box-shadow:0 14px 34px rgba(40,63,88,.18);
}
.chat-actions-menu button {
  width:100%; min-height:38px; padding:8px 10px; border:0; border-radius:9px;
  background:transparent; color:#25384D; display:flex; align-items:center; gap:9px;
  font:inherit; font-size:13px; font-weight:700; text-align:left; cursor:pointer;
}
.chat-actions-menu button:hover, .chat-actions-menu button:focus-visible { background:#F1F7FD; outline:none; }
.chat-actions-menu button.active { color:#2F80ED; }
.chat-actions-menu button.danger { color:#D84A4A; }
.chat-actions-menu button.danger:hover, .chat-actions-menu button.danger:focus-visible { background:#FFF2F2; }
.chat-actions-menu svg { width:17px; height:17px; flex:0 0 auto; fill:none; stroke:currentColor; stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round; }
@media (max-width:760px) {
  .chat-actions-menu { right:-2px; width:min(210px,calc(100vw - 28px)); }
}


/* v0.6.0-rc6.8 — compact chat header: content and wallpaper moved into the ⋯ menu. */
.chat-actions-separator { height:1px; margin:5px 6px; background:#E6EDF5; }

/* v0.6.1-rc2 — Owner server system dashboard. */
.server-management-tabs { grid-template-columns:repeat(4,minmax(0,1fr)); }
.system-heading { margin-bottom:2px; }
.system-heading .secondary:disabled { opacity:.58; cursor:default; }
.system-stat-grid { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:10px; }
.system-stat-card {
  min-width:0; display:grid; gap:5px; padding:14px;
  border:1px solid rgba(159,176,197,.28); border-radius:14px; background:#FAFCFF;
}
.system-stat-card > span { color:#6F849B; font-size:11px; font-weight:750; }
.system-stat-card > strong { color:#10243A; font-size:22px; line-height:1.12; overflow-wrap:anywhere; }
.system-stat-card > small { color:#8A9BAE; font-size:10px; line-height:1.35; }
.system-block { display:grid; gap:9px; margin-top:14px; }
.system-block-title { display:flex; align-items:baseline; justify-content:space-between; gap:10px; padding:0 2px; }
.system-block-title strong { color:#263C53; font-size:12px; }
.system-block-title span { color:#8A9CAF; font-size:10px; }
.system-resource-grid { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:10px; }
.system-resource-card { min-width:0; display:grid; gap:10px; padding:13px 14px; border:1px solid rgba(159,176,197,.28); border-radius:14px; background:#fff; }
.system-resource-head { min-width:0; display:flex; align-items:center; justify-content:space-between; gap:10px; }
.system-resource-head span { color:#627890; font-size:11px; font-weight:800; }
.system-resource-head strong { min-width:0; color:#142C44; font-size:12px; text-align:right; overflow-wrap:anywhere; }
.system-meter { height:7px; overflow:hidden; border-radius:999px; background:#E8EEF5; }
.system-meter > i { display:block; width:0; height:100%; border-radius:inherit; background:linear-gradient(90deg,#70B8FF,#2F80ED); transition:width .28s ease; }
.system-service-list { overflow:hidden; border:1px solid rgba(159,176,197,.28); border-radius:14px; background:#fff; }
.system-service-row { min-height:45px; display:flex; align-items:center; justify-content:space-between; gap:12px; padding:9px 13px; border-bottom:1px solid rgba(159,176,197,.20); }
.system-service-row:last-child { border-bottom:0; }
.system-service-row > span { color:#40566E; font-size:12px; font-weight:700; }
.system-service-status { display:inline-flex; align-items:center; gap:6px; color:#7A8EA5; font-size:11px; font-weight:800; }
.system-service-status::before { content:""; width:8px; height:8px; border-radius:50%; background:#AAB7C5; box-shadow:0 0 0 3px rgba(170,183,197,.13); }
.system-service-status.running { color:#27815A; }
.system-service-status.running::before { background:#39B477; box-shadow:0 0 0 3px rgba(57,180,119,.13); }
.system-service-status.stopped { color:#C44848; }
.system-service-status.stopped::before { background:#D95858; box-shadow:0 0 0 3px rgba(217,88,88,.13); }
.system-storage-grid { grid-template-columns:repeat(4,minmax(0,1fr)); margin-top:14px; }
.system-storage-grid .system-stat-card > strong { font-size:17px; }
.system-build-info { margin:12px 2px 2px; color:#8A9CAF; font-size:10px; text-align:right; }

@media (max-width:760px) {
  .server-management-tabs { grid-template-columns:repeat(4,minmax(0,1fr)); }
  .server-management-tab { padding:0 2px; font-size:10px; }
  .system-stat-grid, .system-resource-grid { grid-template-columns:1fr; }
  .system-storage-grid { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .system-stat-card { padding:12px; }
  .system-stat-card > strong { font-size:20px; }
  .system-block-title { align-items:flex-start; flex-direction:column; gap:2px; }
}

/* v0.7.0-dev10-fix1 account recovery */
.auth-text-button { border:0; background:transparent; color:var(--accent, #2f80ed); padding:4px 0; cursor:pointer; font:inherit; }
.auth-text-button:hover { text-decoration:underline; }
#recovery-key-input { resize:vertical; min-height:76px; }
.recovery-setting-row { align-items:center; gap:10px; }
.recovery-key-value { padding:16px; border:1px dashed rgba(47,128,237,.35); border-radius:14px; background:rgba(47,128,237,.06); font-family:ui-monospace,SFMono-Regular,Consolas,monospace; font-size:15px; line-height:1.7; letter-spacing:.04em; word-break:break-all; user-select:all; }
.recovery-key-actions { display:flex; flex-wrap:wrap; gap:10px; margin-top:14px; }
@media (max-width:720px) { .recovery-setting-row { flex-wrap:wrap; } .recovery-setting-row .grow { min-width:calc(100% - 54px); } }
/* v0.7.0-dev10-fix1 recovery UI polish */
.secure-password-dialog { width:min(390px,calc(100vw - 32px)); border:1px solid rgba(159,176,197,.38); border-radius:16px; padding:0; background:#fff; color:#07111F; box-shadow:0 22px 70px rgba(7,17,31,.24); }
.secure-password-dialog::backdrop { background:rgba(7,17,31,.48); backdrop-filter:blur(1px); }
.secure-password-form { display:grid; gap:14px; padding:20px; }
.secure-password-form h3 { margin:0; font-size:18px; }
.secure-password-form p { margin:0; color:#60758C; font-size:13px; line-height:1.45; }
.secure-password-form label { display:grid; gap:6px; color:#26374B; font-size:12px; font-weight:700; }
.secure-password-form input { width:100%; min-height:44px; border:1px solid rgba(159,176,197,.48); border-radius:12px; background:#F7FBFF; color:#07111F; padding:11px 12px; outline:none; }
.secure-password-form input:focus { background:#fff; border-color:#2F80ED; box-shadow:0 0 0 3px rgba(47,128,237,.12); }
.secure-password-actions { display:flex; justify-content:flex-end; gap:10px; margin-top:2px; }

/* v0.7.0-dev20 — final UI polish: scrollable group details, message overflow menu,
   read-receipt people list and avatar viewer. */
#group-manage-modal { display:flex; flex-direction:column; }
#group-manage-modal > header { flex:0 0 62px; }
#group-manage-modal .group-manage-body {
  flex:1 1 auto;
  min-height:0;
  max-height:none;
  overflow-y:auto;
  overscroll-behavior:contain;
  scrollbar-gutter:stable;
}

/* Wallpaper is an ordinary chat action, not a highlighted/selected item. */
#chat-wallpaper-button {
  width:100%;
  min-height:38px;
  padding:8px 10px;
  border:0;
  border-radius:9px;
  background:transparent;
  color:#25384D;
  flex:initial;
}
#chat-wallpaper-button:hover,
#chat-wallpaper-button:focus-visible { background:#F1F7FD; color:#25384D; outline:none; }
#chat-wallpaper-button svg { width:17px; height:17px; }

/* One compact overflow trigger replaces the permanently visible message buttons. */
.message-row .bubble { /* menu trigger overlays the bubble; keep natural bubble padding */ }
.message-actions,
.message-row.mine .message-actions {
  top:5px !important;
  right:5px !important;
  left:auto !important;
  z-index:14;
  display:block;
  opacity:0;
  transform:none !important;
  pointer-events:none;
}
.bubble:hover .message-actions,
.bubble:focus-within .message-actions,
.message-row.menu-open .message-actions {
  opacity:1 !important;
  pointer-events:auto !important;
}
.message-actions .message-menu-trigger {
  width:27px;
  height:27px;
  padding:0;
  border:1px solid rgba(159,176,197,.34);
  border-radius:9px;
  background:rgba(255,255,255,.94);
  color:#71849A;
  display:grid;
  place-items:center;
  box-shadow:0 4px 12px rgba(7,17,31,.08);
  cursor:pointer;
}
.message-actions .message-menu-trigger:hover,
.message-row.menu-open .message-menu-trigger { color:#2F80ED; background:#F3F8FE; }
.message-actions .message-menu-trigger .ui-icon { width:16px; height:16px; }
.message-action-menu {
  position:absolute;
  z-index:30;
  top:32px;
  right:0;
  width:190px;
  padding:6px;
  border:1px solid #D6E1EE;
  border-radius:12px;
  background:#fff;
  box-shadow:0 14px 34px rgba(40,63,88,.20);
}
.message-action-menu button {
  width:100% !important;
  height:auto !important;
  min-height:36px;
  padding:7px 9px !important;
  border:0 !important;
  border-radius:9px !important;
  background:transparent !important;
  color:#25384D !important;
  display:flex !important;
  align-items:center;
  justify-content:flex-start;
  gap:9px;
  box-shadow:none !important;
  font:inherit;
  font-size:12.5px;
  font-weight:700;
  text-align:left;
  cursor:pointer;
}
.message-action-menu button:hover,
.message-action-menu button:focus-visible { background:#F1F7FD !important; outline:none; color:#176BCB !important; }
.message-action-menu button.active { color:#2F80ED !important; }
.message-action-menu button.danger { color:#D84A4A !important; }
.message-action-menu button.danger:hover { background:#FFF2F2 !important; color:#C93D3D !important; }
.message-action-menu .ui-icon { width:16px; height:16px; flex:0 0 auto; }
.message-action-separator { height:1px; margin:4px 6px; background:#E7EEF6; }

.message-info-summary { display:block; margin-top:2px; color:#7A8EA5; font-size:11px; font-weight:600; }
.message-info-body { min-height:160px; }
.message-info-list { display:grid; gap:16px; }
.message-info-loading { padding:24px 8px; color:#71849A; text-align:center; }
.message-info-loading.error { color:#C94343; }
.message-receipt-section { display:grid; gap:8px; }
.message-receipt-heading { display:flex; align-items:center; justify-content:space-between; gap:10px; }
.message-receipt-heading strong { font-size:13px; }
.message-receipt-heading span { min-width:24px; height:22px; padding:0 7px; border-radius:999px; display:grid; place-items:center; background:#EEF4FA; color:#667C94; font-size:10px; font-weight:800; }
.message-receipt-section.status-read .message-receipt-heading span { background:#E8F8F2; color:#168766; }
.message-receipt-list { display:grid; gap:7px; }
.message-receipt-row { display:grid; grid-template-columns:42px minmax(0,1fr) auto; align-items:center; gap:10px; padding:9px 10px; border:1px solid rgba(159,176,197,.26); border-radius:13px; background:#fff; }
.message-receipt-avatar { width:42px; height:42px; border:0; padding:0; font:inherit; }
.message-receipt-copy { min-width:0; display:grid; gap:2px; }
.message-receipt-copy strong { overflow:hidden; white-space:nowrap; text-overflow:ellipsis; font-size:13px; }
.message-receipt-copy span { overflow:hidden; white-space:nowrap; text-overflow:ellipsis; color:#7B8FA7; font-size:11px; }
.message-receipt-state { padding:4px 7px; border-radius:999px; background:#F0F4F8; color:#73879D; font-size:10px; font-weight:750; white-space:nowrap; }
.message-receipt-state.read { background:#E8F8F2; color:#168766; }
.message-receipt-state.delivered { background:#EAF4FF; color:#2374D1; }

.avatar-viewable { cursor:zoom-in !important; }
button.avatar-viewable { appearance:none; -webkit-appearance:none; }
button.group-member-avatar { border:0; padding:0; font:inherit; }

@media (max-width:760px) {
  #group-manage-modal .group-manage-body { padding-bottom:calc(18px + env(safe-area-inset-bottom)); }
  .message-actions,
  .message-row.mine .message-actions { opacity:0 !important; pointer-events:none !important; }
  .message-row.mobile-actions-visible .message-actions,
  .message-row.menu-open .message-actions { opacity:1 !important; pointer-events:auto !important; transform:none !important; }
  .message-action-menu { width:min(190px,calc(100vw - 44px)); }
  .message-receipt-row { grid-template-columns:40px minmax(0,1fr); }
  .message-receipt-avatar { width:40px; height:40px; }
  .message-receipt-state { grid-column:2; justify-self:start; }
}

/* v0.7.0-dev21 — message reactions and group @mentions */
.message-action-menu { width:min(252px,calc(100vw - 36px)); }
.message-quick-reactions { display:grid; grid-template-columns:repeat(7,1fr); gap:4px; padding:4px 5px 2px; }
.message-action-menu .message-quick-reactions button.quick-reaction {
  min-width:0; width:30px; height:30px; padding:0; border:0; border-radius:9px; background:transparent; color:#52677D;
  display:grid; place-items:center; cursor:pointer;
}
.message-action-menu .message-quick-reactions button.quick-reaction:hover,
.message-action-menu .message-quick-reactions button.quick-reaction.active { background:#EAF4FF !important; color:#176BCB !important; }
.quick-reaction-art { width:21px; height:21px; object-fit:contain; }
.message-action-menu .message-quick-reactions button.reaction-more { font-size:21px; line-height:1; font-weight:500; }
.message-reactions { display:flex; flex-wrap:wrap; gap:4px; margin:4px 0 -3px; }
.message-reaction-chip {
  height:25px; min-width:38px; padding:2px 7px; border:1px solid #DCE7F2; border-radius:999px; background:#F7FAFD; color:#5C7187;
  display:inline-flex; align-items:center; justify-content:center; gap:4px; font-size:11px; font-weight:700; cursor:pointer;
}
.message-reaction-chip:hover { background:#EFF6FD; border-color:#C9DCF0; }
.message-reaction-chip.mine { background:#EAF4FF; color:#176BCB; border-color:#BFDDF8; }
.reaction-emoji-art { width:17px; height:17px; object-fit:contain; }
.reaction-detail-emoji { margin-left:auto; min-width:34px; display:flex; justify-content:flex-end; align-items:center; }
.reaction-detail-emoji .reaction-emoji-art { width:24px; height:24px; }
.reaction-emoji-picker {
  position:fixed; z-index:4000; max-height:306px; overflow:hidden; border:1px solid rgba(159,176,197,.45); border-radius:16px;
  background:#fff; box-shadow:0 18px 48px rgba(26,54,86,.22); display:flex; flex-direction:column;
}
.reaction-emoji-tabs { flex:0 0 auto; display:flex; gap:2px; overflow-x:auto; padding:7px 8px; border-bottom:1px solid #E8EEF5; scrollbar-width:none; }
.reaction-emoji-tabs::-webkit-scrollbar { display:none; }
.reaction-emoji-tab { width:31px; height:31px; flex:0 0 31px; padding:0; border:0; border-radius:9px; background:transparent; display:grid; place-items:center; cursor:pointer; }
.reaction-emoji-tab:hover,.reaction-emoji-tab.active { background:#EAF4FF; }
.reaction-emoji-grid { display:grid; grid-template-columns:repeat(8,1fr); gap:2px; overflow:auto; padding:8px; }
.reaction-emoji-grid button { width:34px; height:34px; padding:2px; border:0; border-radius:9px; background:transparent; display:grid; place-items:center; cursor:pointer; }
.reaction-emoji-grid button:hover { background:#F0F6FC; }
.reaction-emoji-grid .emoji-picker-art { width:27px; height:27px; }

.message-mention { display:inline; padding:0; margin:0; border-radius:0; background:transparent; color:#176BCB; font-weight:inherit; }
.message-mention.mention-me { background:transparent; color:#0D67C7; font-weight:inherit; }
.message-mention.mention-link { display:inline; padding:0; border:0; background:transparent; color:#176BCB; font:inherit; font-weight:inherit; text-decoration:underline; text-underline-offset:2px; cursor:pointer; vertical-align:baseline; }
.message-mention.mention-link:hover,.message-mention.mention-link:focus-visible { color:#0754A1; text-decoration-thickness:2px; }
.message-mention.mention-link.mention-me { color:#0D67C7; }
.mention-suggestions {
  position:absolute; z-index:24; left:56px; bottom:calc(100% - 4px); width:min(360px,calc(100% - 116px)); max-height:290px; overflow:auto;
  padding:6px; border:1px solid rgba(159,176,197,.42); border-radius:14px; background:#fff; box-shadow:0 16px 42px rgba(30,57,88,.18);
}
.mention-suggestion {
  width:100%; min-height:48px; padding:6px 8px; border:0; border-radius:10px; background:transparent; color:#10243A; display:flex; align-items:center; gap:9px; text-align:left; cursor:pointer;
}
.mention-suggestion:hover,.mention-suggestion.active { background:#EEF6FF; }
.mention-avatar { flex:0 0 auto; width:34px; height:34px; font-size:12px; }
.mention-copy { min-width:0; display:flex; flex-direction:column; gap:1px; }
.mention-copy strong { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-size:13px; }
.mention-copy small { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; color:#8193A7; font-size:11px; }

@media (max-width:720px) {
  .message-action-menu { width:min(244px,calc(100vw - 28px)); }
  .message-quick-reactions { gap:2px; padding-left:3px; padding-right:3px; }
  .message-action-menu .message-quick-reactions button.quick-reaction { width:29px; height:29px; }
  .mention-suggestions { left:10px; right:10px; width:auto; bottom:calc(100% - 2px); }
  .reaction-emoji-grid { grid-template-columns:repeat(7,1fr); }
}


/* v0.7.0-dev21-fix1 — compact overlay menu + date separators */
.message-actions,
.message-row.mine .message-actions {
  top:5px !important;
  right:5px !important;
  left:auto !important;
}
.message-actions .message-menu-trigger {
  background:rgba(255,255,255,.88);
  backdrop-filter:blur(4px);
  -webkit-backdrop-filter:blur(4px);
}
.message-row.mine .message-actions .message-menu-trigger { background:rgba(255,255,255,.76); }
.message-day-separator {
  width:100%;
  display:flex;
  align-items:center;
  justify-content:center;
  margin:9px 0 5px;
  pointer-events:none;
}
.message-day-separator span {
  display:inline-flex;
  align-items:center;
  min-height:28px;
  padding:5px 11px;
  border:1px solid rgba(159,176,197,.32);
  border-radius:999px;
  background:rgba(255,255,255,.88);
  box-shadow:0 4px 14px rgba(40,63,88,.07);
  color:#6F8398;
  font-size:14px;
  font-weight:700;
  line-height:1;
  backdrop-filter:blur(5px);
  -webkit-backdrop-filter:blur(5px);
}
@media (max-width:720px) {
  .message-day-separator { margin:7px 0 3px; }
  .message-day-separator span { min-height:28px; padding:5px 11px; font-size:13px; }
}

/* v0.7.0-dev21-fix2 — keep the message action popup inside the chat viewport.
   The trigger lives in the top-right corner of every bubble. For incoming
   messages the popup must grow to the right; for outgoing messages it grows
   to the left. This prevents short incoming bubbles from pushing the popup
   beyond the left edge of the conversation. */
.message-row:not(.mine) .message-action-menu {
  left:0;
  right:auto;
}
.message-row.mine .message-action-menu {
  left:auto;
  right:0;
}


/* v0.7.0-dev21-fix3 — flip the message popup above the trigger when the
   message is too close to the composer. This avoids creating artificial
   scroll space just to reveal the lower part of the menu. */
.message-row.menu-up .message-action-menu {
  top:auto !important;
  bottom:32px !important;
}

/* dev22: Web Push settings */
.notification-setting-row { align-items:center; }
.notification-setting-icon { font-size:17px; background:linear-gradient(145deg,#2F80ED,#56A8FF); }
.notification-setting-row #push-toggle-button { flex:0 0 auto; }
.notification-setting-row #push-toggle-button[data-active="1"] { color:#d84854; background:#fff5f6; border-color:#ffd9dd; }
@media (max-width:720px) {
  .notification-setting-row { flex-wrap:wrap; }
  .notification-setting-row .grow { min-width:calc(100% - 54px); }
  .notification-setting-row #push-toggle-button { margin-left:46px; }
}


/* v0.7.0-dev22-fix1 — mobile action reveal, crisp iOS header and push onboarding. */
.push-onboarding {
  position:fixed; z-index:35; left:50%; bottom:max(18px,env(safe-area-inset-bottom)); transform:translateX(-50%);
  width:min(520px,calc(100vw - 28px)); display:grid; grid-template-columns:auto minmax(0,1fr) auto; align-items:center; gap:12px;
  padding:12px 13px; border:1px solid rgba(159,176,197,.38); border-radius:16px; background:#fff; color:#10243A;
  box-shadow:0 16px 44px rgba(24,52,82,.18);
}
.push-onboarding.hidden { display:none; }
.push-onboarding-icon { width:38px; height:38px; display:grid; place-items:center; border-radius:12px; background:#EAF4FF; font-size:19px; }
.push-onboarding-copy { min-width:0; display:grid; gap:2px; }
.push-onboarding-copy strong { font-size:13px; }
.push-onboarding-copy span { color:#6F8398; font-size:11px; line-height:1.35; }
.push-onboarding-actions { display:flex; align-items:center; gap:7px; }
.push-onboarding-actions button { min-height:36px; padding:8px 11px; border-radius:10px; font-size:12px; }
@media (max-width:720px) {
  .push-onboarding { grid-template-columns:auto minmax(0,1fr); bottom:calc(12px + env(safe-area-inset-bottom)); }
  .push-onboarding-actions { grid-column:1 / -1; justify-content:flex-end; }
}

/* v0.7.0-dev22-fix2 — iOS/PWA crisp chat header.
   The mobile chat panel used to remain on transform:translateX(0) after the
   slide-in transition. iOS WebKit can keep descendants rasterized on that
   composited layer, which makes the avatar/title/status look soft. Once the
   chat is open, remove the transform entirely so WebKit paints the header at
   native device resolution. */
@media (max-width:760px) {
  .messenger.chat-open .chat-panel {
    transform:none !important;
    -webkit-transform:none !important;
    will-change:auto;
  }
  .messenger.chat-open .chat-header {
    transform:none !important;
    -webkit-transform:none !important;
    filter:none !important;
    backdrop-filter:none !important;
    -webkit-backdrop-filter:none !important;
  }
}

/* v0.7.0-dev23-fix1 — encrypted group polls + stable direct composer layout */
.composer-input-shell.poll-enabled { grid-template-columns:auto auto minmax(0,1fr) auto; }
.composer-input-shell .poll-button {
  width:40px; height:40px; margin:1px 0; border:0; border-radius:11px;
  display:grid; place-items:center; background:transparent; color:#7890A9; box-shadow:none;
}
.composer-input-shell .poll-button:hover { background:#EAF5FF; color:#2F80ED; }
.composer-input-shell .poll-button svg { width:22px; height:22px; fill:none; stroke:currentColor; stroke-width:1.9; stroke-linecap:round; stroke-linejoin:round; }
.poll-form { display:grid; gap:16px; }
.poll-form > label:first-child { display:grid; gap:7px; font-weight:650; }
.poll-options-editor { display:grid; gap:9px; }
.poll-editor-heading { display:flex; justify-content:space-between; align-items:center; gap:12px; color:#26374B; }
.poll-editor-heading span { color:#8396AA; font-size:12px; font-weight:500; }
.poll-option-inputs { display:grid; gap:8px; }
.poll-option-editor-row { display:grid; grid-template-columns:minmax(0,1fr) 36px; gap:7px; align-items:center; }
.poll-option-editor-row input { min-width:0; }
.poll-option-remove { width:36px; height:36px; border:0; border-radius:10px; background:#FFF2F3; color:#D84D59; font-size:20px; line-height:1; }
.poll-option-remove:hover { background:#FFE6E8; }
.poll-add-option { justify-self:start; }
.poll-setting-check { display:grid !important; grid-template-columns:auto minmax(0,1fr); align-items:start; gap:10px; cursor:pointer; }
.poll-setting-check input { width:18px !important; height:18px; margin:2px 0 0; accent-color:#2F80ED; }
.poll-setting-check span { display:grid; gap:2px; }
.poll-setting-check strong { font-size:13px; }
.poll-setting-check small { color:#7A8EA4; font-size:11px; font-weight:500; line-height:1.35; }
.poll-form-actions { display:flex; justify-content:flex-end; gap:9px; padding-top:3px; }

.poll-card { min-width:min(320px,72vw); max-width:420px; display:grid; gap:11px; }
.poll-question { font-size:15px; line-height:1.35; font-weight:750; color:#10243A; overflow-wrap:anywhere; }
.poll-options { display:grid; gap:7px; }
.poll-option {
  position:relative; isolation:isolate; width:100%; min-height:42px; display:grid;
  grid-template-columns:22px minmax(0,1fr) auto; align-items:center; gap:8px;
  padding:9px 10px; border:1px solid rgba(86,168,255,.25); border-radius:12px;
  overflow:hidden; background:rgba(255,255,255,.64); color:#18314B; text-align:left;
}
.poll-option:hover:not(:disabled) { border-color:rgba(47,128,237,.45); background:#F8FCFF; }
.poll-option:disabled { cursor:default; }
.poll-option-progress { position:absolute; z-index:-1; inset:0 auto 0 0; width:0; background:rgba(86,168,255,.13); transition:width .2s ease; }
.poll-option.selected { border-color:rgba(47,128,237,.55); }
.poll-option.selected .poll-option-progress { background:rgba(47,128,237,.16); }
.poll-option-check { width:20px; height:20px; display:grid; place-items:center; border:1.5px solid #9EB4CA; border-radius:50%; color:white; font-size:12px; font-weight:800; background:#fff; }
.poll-option.selected .poll-option-check { border-color:#2F80ED; background:#2F80ED; }
.poll-option-text { min-width:0; font-size:13px; line-height:1.32; overflow-wrap:anywhere; }
.poll-option-count { min-width:22px; text-align:right; color:#607890; font-size:12px; font-weight:700; }
.poll-submit-vote {
  justify-self:start; min-height:34px; padding:7px 13px; border:0; border-radius:10px;
  background:#2F80ED; color:#fff; font-size:12px; font-weight:750; cursor:pointer;
}
.poll-submit-vote:hover:not(:disabled) { filter:brightness(.97); }
.poll-submit-vote:disabled { opacity:.48; cursor:default; }
.poll-footer { display:flex; justify-content:space-between; align-items:flex-end; gap:14px; color:#7A8EA4; font-size:10.5px; line-height:1.35; }
.poll-footer strong { flex:0 0 auto; color:#55708B; font-size:11px; }
.poll-error { color:#B34752; }
.message-row.mine .poll-question { color:#10243A; }
.message-row.mine .poll-option { background:rgba(255,255,255,.52); }
.message-row.mine .poll-footer { color:#6F8398; }

@media (max-width:760px) {
  .composer-input-shell .poll-button { width:38px; height:38px; border-radius:10px; }
  .poll-card { min-width:min(280px,76vw); max-width:76vw; }
  .poll-question { font-size:14px; }
  .poll-option { min-height:40px; padding:8px 9px; }
  .poll-option-text { font-size:12.5px; }
}


/* v0.7.0-dev24-fix1 — forwarding and reaction '+' alignment */
.message-action-menu .message-quick-reactions button.reaction-more { font-size:0; line-height:1; }
.message-action-menu .message-quick-reactions button.reaction-more .ui-icon { width:18px; height:18px; display:block; margin:0; stroke-width:2; }
.forwarded-label { display:flex; align-items:baseline; gap:5px; margin:0 0 5px; color:#5E86B2; font-size:11px; line-height:1.25; }
.forwarded-label span { color:#7C91A8; }
.forwarded-label strong { color:#3C78BA; font-weight:700; }
.forward-modal-body { display:grid; gap:12px; }
.forward-search-label { display:block; }
.forward-search-label input { width:100%; height:42px; border:1px solid #D8E4F0; border-radius:13px; background:#F8FBFE; color:var(--text); padding:0 13px; font:inherit; outline:none; }
.forward-search-label input:focus { border-color:#9BC8F4; box-shadow:0 0 0 3px rgba(74,151,232,.10); }
.forward-target-list { display:grid; gap:6px; max-height:min(480px, calc(100dvh - 190px)); overflow:auto; padding-right:2px; }
.forward-target-row { width:100%; min-height:58px; display:grid; grid-template-columns:44px minmax(0,1fr) 18px; align-items:center; gap:10px; padding:7px 10px; border:1px solid transparent; border-radius:14px; background:transparent; color:var(--text); text-align:left; cursor:pointer; }
.forward-target-row:hover { background:#F4F8FC; border-color:#E2ECF5; }
.forward-target-row:disabled { opacity:.62; cursor:default; }
.forward-target-row.busy { background:#F4F8FC; border-color:#D8E7F5; }
.forward-target-avatar { width:44px; height:44px; border-radius:50%; display:grid; place-items:center; overflow:hidden; background:linear-gradient(145deg,#3E84F6,#49C9E9); color:#fff; font-weight:800; background-size:cover; background-position:center; }
.forward-target-copy { min-width:0; display:grid; gap:3px; }
.forward-target-copy strong, .forward-target-copy span { overflow:hidden; white-space:nowrap; text-overflow:ellipsis; }
.forward-target-copy strong { font-size:13px; }
.forward-target-copy span { color:#7D91A7; font-size:11px; }
.forward-target-chevron { color:#9AABBC; font-size:22px; line-height:1; justify-self:end; }
.forward-empty { padding:28px 12px; text-align:center; color:#8295AA; font-size:13px; }
@media (max-width:760px) { .forward-target-list { max-height:calc(92dvh - 180px); } }


/* v0.7.0-dev24-fix2 — keep quick-reaction hover cells perfectly aligned */
.message-action-menu .message-quick-reactions {
  grid-template-columns:repeat(7,30px);
  justify-content:space-between;
  align-items:center;
  gap:0;
}
.message-action-menu .message-quick-reactions > button.quick-reaction {
  width:30px !important;
  min-width:30px !important;
  max-width:30px !important;
  height:30px !important;
  min-height:30px !important;
  max-height:30px !important;
  padding:0 !important;
  margin:0 !important;
  border:0 !important;
  border-radius:9px !important;
  display:grid !important;
  place-items:center !important;
  align-items:center !important;
  justify-content:center !important;
  gap:0 !important;
  line-height:1 !important;
  box-sizing:border-box !important;
}
.message-action-menu .message-quick-reactions > button.quick-reaction .quick-reaction-art {
  width:21px;
  height:21px;
  display:block;
  margin:0;
}
.message-action-menu .message-quick-reactions > button.reaction-more .ui-icon {
  width:18px;
  height:18px;
  display:block;
  margin:0;
}
@media (max-width:720px) {
  .message-action-menu .message-quick-reactions {
    grid-template-columns:repeat(7,29px);
    justify-content:space-between;
    gap:0;
  }
  .message-action-menu .message-quick-reactions > button.quick-reaction {
    width:29px !important;
    min-width:29px !important;
    max-width:29px !important;
    height:29px !important;
    min-height:29px !important;
    max-height:29px !important;
  }
}

/* v0.7.0-dev25 — Owner account lifecycle and technical user card. */
.server-user-open { width:100%; appearance:none; -webkit-appearance:none; font:inherit; color:inherit; text-align:left; cursor:pointer; }
.server-user-open:hover { background:#F7FBFF; }
.server-account-badge { display:inline-flex; align-items:center; min-height:18px; margin-left:5px; padding:0 6px; border-radius:999px; font-size:9px; font-weight:800; text-transform:uppercase; vertical-align:1px; }
.server-account-badge.active { background:#EAF9F2; color:#12845D; }
.server-account-badge.blocked { background:#FFF3D6; color:#A96B00; }
.server-account-badge.deleted { background:#FFECEF; color:#C73B52; }
.server-user-detail { display:grid; gap:14px; margin-bottom:14px; padding:14px; border:1px solid rgba(107,132,161,.25); border-radius:16px; background:#FAFCFF; box-shadow:0 8px 26px rgba(28,52,77,.06); }
.server-user-detail-head { display:flex; align-items:flex-start; gap:12px; }
.server-user-detail-identity { min-width:0; flex:1 1 auto; display:flex; align-items:center; gap:11px; }
.server-user-detail-avatar { width:52px; height:52px; flex:0 0 52px; }
.server-user-detail-status { padding:10px 12px; border-radius:11px; background:#F1F6FB; color:#536A82; font-size:12px; line-height:1.45; }
.server-user-detail-stats { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:8px; }
.server-user-stat { min-width:0; display:grid; gap:4px; padding:10px; border:1px solid rgba(159,176,197,.24); border-radius:11px; background:#fff; }
.server-user-stat span { color:#7A8EA5; font-size:10px; }
.server-user-stat strong { color:#10243A; font-size:12px; overflow-wrap:anywhere; }
.server-user-detail-section { display:grid; gap:8px; }
.server-user-detail-section h4 { margin:0; font-size:12px; color:#10243A; }
.server-user-detail-list { display:grid; gap:7px; }
.server-user-detail-row { display:grid; gap:3px; padding:9px 10px; border:1px solid rgba(159,176,197,.22); border-radius:10px; background:#fff; }
.server-user-detail-row strong { font-size:12px; color:#10243A; }
.server-user-detail-row span { font-size:10px; line-height:1.4; color:#7A8EA5; overflow-wrap:anywhere; }
.server-user-detail-actions { display:flex; flex-wrap:wrap; align-items:center; gap:8px; padding-top:2px; }
.server-user-detail-actions button { min-height:38px; border-radius:10px; padding:0 13px; font-weight:750; cursor:pointer; }
.server-user-detail-actions .warning { border:1px solid #F3D18A; background:#FFF8E8; color:#9A6500; }
.server-user-detail-actions .warning:hover { background:#FFF1CF; }
.server-user-detail-actions .danger-button { border:1px solid #F4BCC6; background:#FFF1F3; color:#C5344D; }
.server-user-detail-actions .danger-button:hover { background:#FFE5EA; }
.server-user-action-note { color:#7A8EA5; font-size:11px; line-height:1.4; }
.empty-state.compact { padding:8px 0; min-height:0; }
@media (max-width:760px) {
  .server-user-detail { padding:12px; }
  .server-user-detail-stats { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .server-user-detail-actions { display:grid; grid-template-columns:1fr; }
  .server-user-detail-actions button { width:100%; }
}

/* v0.7.0-dev25-fix1 — reports/moderation and current encryption wording. */
.security-note-secondary { margin-top:6px !important; color:#6F8398 !important; font-size:11px !important; }
.chat-actions-menu button.report { color:#A66A00; }
.chat-actions-menu button.report:hover { background:#FFF8E8; color:#915C00; }
.group-member-action.report-text { color:#A66A00; }

.report-form { display:grid; gap:14px; }
.report-form > label { display:grid; gap:6px; font-weight:750; color:#18314B; }
.report-form select,
.report-form textarea,
.report-form input[type="file"] { width:100%; box-sizing:border-box; }
.report-target-card { display:flex; align-items:center; gap:11px; padding:11px 12px; border:1px solid rgba(159,176,197,.28); border-radius:13px; background:#F8FBFF; }
.report-target-card .mini-avatar { width:42px; height:42px; flex:0 0 42px; }
.report-target-card > div { min-width:0; display:grid; gap:3px; }
.report-screenshot-field input[type="file"] { padding:9px; border:1px dashed rgba(93,128,167,.35); border-radius:10px; background:#FBFDFF; font-weight:500; }
.report-privacy-note { margin:0; padding:10px 11px; border-radius:10px; background:#FFF8E8; color:#7C5A16; font-size:11px; line-height:1.45; }

.server-management-tabs { grid-template-columns:repeat(5,minmax(0,1fr)); }
.server-reports-note { margin:0 0 10px; color:#6F8398; font-size:11px; line-height:1.45; }
.server-report-list { display:grid; gap:12px; padding-bottom:4px; }
.server-report-target-card { display:grid; gap:10px; padding:12px; border:1px solid rgba(107,132,161,.24); border-radius:14px; background:#FAFCFF; }
.server-report-target-head { display:flex; align-items:center; gap:10px; }
.server-report-target-head .grow { min-width:0; display:grid; gap:2px; }
.server-report-target-head .grow > strong { color:#10243A; font-size:13px; }
.server-report-target-head .sub { color:#7A8EA5; font-size:11px; }
.server-report-summary { color:#60758C; font-size:10px; line-height:1.4; }
.server-report-open-user { flex:0 0 auto; min-height:34px; }

.server-report-block-user { flex:0 0 auto; min-height:34px; border:1px solid #F3D18A; border-radius:9px; padding:0 10px; background:#FFF8E8; color:#9A6500; font-weight:750; cursor:pointer; }
.server-report-block-user:hover { background:#FFF1CF; }
.server-report-items { display:grid; gap:8px; }
.server-report-item { display:grid; gap:6px; padding:10px 11px; border:1px solid rgba(159,176,197,.22); border-left:3px solid #D8E4EF; border-radius:10px; background:#fff; }
.server-report-item.status-new { border-left-color:#F0A53A; }
.server-report-item.status-reviewing { border-left-color:#4A8EF0; }
.server-report-item.status-actioned { border-left-color:#31A77A; }
.server-report-item.status-dismissed { border-left-color:#9AA9B8; }
.server-report-item-head { display:flex; align-items:center; justify-content:space-between; gap:8px; }
.server-report-item-head strong { color:#10243A; font-size:12px; }
.server-report-status { flex:0 0 auto; padding:3px 7px; border-radius:999px; font-size:9px; font-weight:800; }
.server-report-status.new { background:#FFF3D9; color:#A86A00; }
.server-report-status.reviewing { background:#EAF3FF; color:#236DC9; }
.server-report-status.actioned { background:#E8F8F1; color:#147A57; }
.server-report-status.dismissed { background:#EEF2F6; color:#687B8E; }
.server-report-meta,
.server-report-review { color:#7A8EA5; font-size:10px; line-height:1.4; overflow-wrap:anywhere; }
.server-report-comment { margin:0; color:#243B53; font-size:12px; line-height:1.48; white-space:pre-wrap; overflow-wrap:anywhere; }
.server-report-actions { display:flex; flex-wrap:wrap; gap:7px; padding-top:2px; }
.server-report-actions button { min-height:32px; padding:0 10px; font-size:10px; }

@media (max-width:760px) {
  .server-management-tabs { grid-template-columns:repeat(5,minmax(78px,1fr)); overflow-x:auto; scrollbar-width:none; }
  .server-management-tabs::-webkit-scrollbar { display:none; }
  .server-report-target-head { align-items:flex-start; flex-wrap:wrap; }
  .server-report-open-user,
  .server-report-block-user { width:100%; }
  .server-report-actions { display:grid; grid-template-columns:1fr; }
  .server-report-actions button { width:100%; }
}


/* v0.7.0-dev25-fix2 — moderation form polish + stable OWNER layout. */
.report-form select {
  width:100%;
  min-height:44px;
  box-sizing:border-box;
  border:1px solid rgba(159,176,197,.42);
  border-radius:12px;
  background-color:#F8FBFF;
  background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23697f96' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat:no-repeat;
  background-position:right 13px center;
  background-size:14px 14px;
  color:#10243A;
  padding:10px 38px 10px 12px;
  font:inherit;
  font-weight:600;
  outline:none;
  appearance:none;
  -webkit-appearance:none;
  transition:border-color .15s, box-shadow .15s, background-color .15s;
}
.report-form select:hover { border-color:rgba(47,128,237,.40); background-color:#fff; }
.report-form select:focus { border-color:#56A8FF; box-shadow:0 0 0 3px rgba(86,168,255,.13); background-color:#fff; }
.report-screenshot-field { min-width:0; }
.report-file-picker {
  min-width:0;
  display:grid;
  grid-template-columns:auto minmax(0,1fr);
  align-items:center;
  gap:10px;
  min-height:46px;
  padding:5px;
  border:1px solid rgba(159,176,197,.38);
  border-radius:12px;
  background:#F8FBFF;
}
.report-file-button {
  min-height:34px;
  margin:0;
  padding:0 12px;
  border-radius:9px;
  white-space:nowrap;
}
.report-file-selected {
  min-width:0;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
  color:#61778E;
  font-size:12px;
  font-weight:550;
}
.report-file-input { display:none !important; }
.report-screenshot-field > .field-hint { margin:0 2px; }

#server-management-modal .server-management-tabs {
  display:flex;
  grid-template-columns:none;
  align-items:center;
  gap:4px;
  min-height:46px;
  height:auto;
  padding:4px;
  overflow-x:auto;
  overflow-y:hidden;
  scrollbar-width:none;
}
#server-management-modal .server-management-tabs::-webkit-scrollbar { display:none; }
#server-management-modal .server-management-tab {
  flex:1 0 auto;
  min-width:max-content;
  min-height:36px;
  height:36px;
  padding:0 11px;
  border-radius:9px;
  white-space:nowrap;
  font-size:11.5px;
  line-height:1;
  box-sizing:border-box;
}
#server-management-modal .server-management-tab.active {
  background:#fff;
  color:#176BCB;
  box-shadow:0 2px 7px rgba(7,17,31,.08);
}

.server-report-target-card { gap:11px; padding:12px 13px; }
.server-report-target-head {
  display:grid;
  grid-template-columns:42px minmax(0,1fr);
  align-items:center;
  gap:10px;
  min-width:0;
}
.server-report-target-identity {
  min-width:0;
  display:grid;
  gap:3px;
}
.server-report-target-name {
  min-width:0;
  display:flex;
  align-items:center;
  flex-wrap:wrap;
  gap:6px;
}
.server-report-target-name > strong {
  min-width:0;
  color:#10243A;
  font-size:13px;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}
.server-report-target-identity .sub { color:#7A8EA5; font-size:11px; }
.server-report-target-actions {
  display:flex;
  align-items:center;
  flex-wrap:wrap;
  gap:8px;
  padding-left:52px;
}
.server-report-open-user,
.server-report-block-user {
  width:auto;
  min-height:34px;
  flex:0 0 auto;
}
.server-report-items { margin-top:1px; }

@media (max-width:760px) {
  .report-file-picker { grid-template-columns:1fr; gap:6px; }
  .report-file-button { width:100%; }
  .report-file-selected { padding:0 6px 3px; text-align:center; }
  #server-management-modal .server-management-tab {
    flex:0 0 auto;
    min-width:max-content;
    padding:0 10px;
    font-size:11px;
  }
  .server-report-target-head { grid-template-columns:42px minmax(0,1fr); align-items:center; }
  .server-report-target-actions { padding-left:0; display:grid; grid-template-columns:1fr; }
  .server-report-open-user,
  .server-report-block-user { width:100%; }
}

/* v0.7.1-rc1 — Light / Dark / System theme. Light remains the established
   production palette. Dark mode is selected explicitly or follows the OS when
   the user chooses "System". */
.theme-select {
  min-width:132px;
  min-height:38px;
  border:1px solid rgba(159,176,197,.38);
  border-radius:10px;
  background:#F7FBFF;
  color:#10243A;
  padding:0 34px 0 11px;
  font:inherit;
  font-weight:650;
  outline:none;
}
.theme-select:focus { border-color:#56A8FF; box-shadow:0 0 0 3px rgba(47,128,237,.08); }
.theme-setting-icon { background:#EAF4FF; color:#2F80ED; }
.message-edited-label { white-space:nowrap; }
.reply-preview.editing-preview { border-left-color:#8B5CF6; background:#F2EEFF; }
.reply-preview.editing-preview strong { color:#7143D6; }

html[data-theme="dark"] {
  color-scheme:dark;
  --bg:#08111F;
  --surface:#101B2D;
  --surface-2:#152238;
  --surface-3:#1D2C45;
  --text:#F5F7FB;
  --muted:#91A0B8;
  --line:rgba(255,255,255,.09);
  --accent:#5B8CFF;
  --accent-2:#7AA2FF;
  --danger:#EF5B68;
  --success:#52C98F;
  --shadow:0 18px 55px rgba(0,0,0,.38);
}
html[data-theme="dark"] body,
html[data-theme="dark"] .app-root,
html[data-theme="dark"] .messenger { background:#08111F; color:#F5F7FB; }
html[data-theme="dark"] .auth-view {
  background:radial-gradient(circle at 20% 20%,rgba(91,140,255,.16),transparent 36%),radial-gradient(circle at 90% 80%,rgba(82,201,143,.08),transparent 34%),#08111F;
}
html[data-theme="dark"] .auth-shell,
html[data-theme="dark"] .auth-card-wrap { color:#F5F7FB; }
html[data-theme="dark"] .auth-hero { background:linear-gradient(145deg,#0D1A2D,#102541); color:#F5F7FB; }
html[data-theme="dark"] .auth-hero-copy p,
html[data-theme="dark"] .auth-trust-grid small,
html[data-theme="dark"] .auth-platforms { color:#9FB0C6; }
html[data-theme="dark"] .trust-card { background:rgba(255,255,255,.045); border-color:rgba(255,255,255,.09); }
html[data-theme="dark"] .auth-card,
html[data-theme="dark"] .auth-card-wrap .auth-card { background:#101B2D; border-color:rgba(255,255,255,.09); color:#F5F7FB; box-shadow:0 24px 70px rgba(0,0,0,.34); }
html[data-theme="dark"] .auth-card h1,
html[data-theme="dark"] .auth-card h2,
html[data-theme="dark"] .auth-card-heading h2 { color:#F5F7FB; }
html[data-theme="dark"] .auth-card-heading p,
html[data-theme="dark"] .auth-footnote,
html[data-theme="dark"] .field-hint { color:#91A0B8; }
html[data-theme="dark"] label,
html[data-theme="dark"] .modal label { color:#CBD5E1; }
html[data-theme="dark"] input,
html[data-theme="dark"] textarea,
html[data-theme="dark"] select,
html[data-theme="dark"] .modal input,
html[data-theme="dark"] .modal textarea,
html[data-theme="dark"] .report-form select,
html[data-theme="dark"] .theme-select {
  background:#0B1526;
  color:#F5F7FB;
  border-color:rgba(255,255,255,.11);
}
html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder { color:#6F829A; }
html[data-theme="dark"] input:focus,
html[data-theme="dark"] textarea:focus,
html[data-theme="dark"] select:focus,
html[data-theme="dark"] .modal input:focus,
html[data-theme="dark"] .modal textarea:focus,
html[data-theme="dark"] .report-form select:focus,
html[data-theme="dark"] .theme-select:focus { background:#0E1B2F; border-color:#6B9CFF; box-shadow:0 0 0 3px rgba(91,140,255,.14); }
html[data-theme="dark"] .tabs { background:rgba(255,255,255,.045); }
html[data-theme="dark"] .tab { color:#91A0B8; }
html[data-theme="dark"] .tab.active { color:#F5F7FB; background:#1D2C45; }
html[data-theme="dark"] .auth-text-button { color:#8DB5FF; }
html[data-theme="dark"] .alert.error { background:rgba(239,91,104,.12); color:#FF9AA3; border-color:rgba(239,91,104,.25); }

html[data-theme="dark"] .sidebar { background:#101B2D; border-right-color:rgba(255,255,255,.08); }
html[data-theme="dark"] .sidebar-header,
html[data-theme="dark"] .chat-header { background:#101B2D; border-bottom-color:rgba(255,255,255,.08); }
html[data-theme="dark"] .brand-copy strong,
html[data-theme="dark"] .chat-title-wrap strong,
html[data-theme="dark"] .chat-item-title,
html[data-theme="dark"] .empty-state strong { color:#F5F7FB; }
html[data-theme="dark"] .connection,
html[data-theme="dark"] .chat-preview,
html[data-theme="dark"] .chat-time,
html[data-theme="dark"] .muted,
html[data-theme="dark"] .sub { color:#91A0B8; }
html[data-theme="dark"] .search-wrap { border-bottom-color:rgba(255,255,255,.08); }
html[data-theme="dark"] .search-wrap input { background:#0B1526; color:#F5F7FB; border-color:rgba(255,255,255,.09); }
html[data-theme="dark"] .search-results,
html[data-theme="dark"] .picker-results,
html[data-theme="dark"] .mention-suggestions { background:#152238; border-color:rgba(255,255,255,.10); box-shadow:0 18px 48px rgba(0,0,0,.34); }
html[data-theme="dark"] .search-user,
html[data-theme="dark"] .picker-user { color:#F5F7FB; }
html[data-theme="dark"] .search-user:hover,
html[data-theme="dark"] .picker-user:hover { background:rgba(255,255,255,.055); }
html[data-theme="dark"] .chat-item { color:#F5F7FB; border-bottom-color:rgba(255,255,255,.045); }
html[data-theme="dark"] .chat-item:hover,
html[data-theme="dark"] .chat-item.active { background:rgba(91,140,255,.12); }
html[data-theme="dark"] .chat-remove-button { color:#91A0B8; }
html[data-theme="dark"] .sidebar-tabs,
html[data-theme="dark"] .sidebar-footer { border-color:rgba(255,255,255,.08); background:#101B2D; }
html[data-theme="dark"] .sidebar-tab { color:#91A0B8; }
html[data-theme="dark"] .sidebar-tab.active { color:#8DB5FF; background:rgba(91,140,255,.12); }

html[data-theme="dark"] .chat-panel,
html[data-theme="dark"] .messenger .chat-panel {
  background:radial-gradient(circle at 50% 28%,rgba(91,140,255,.09),transparent 38%),linear-gradient(155deg,#091421 0%,#0A1727 52%,#08111F 100%);
}
html[data-theme="dark"] .chat-panel::after { opacity:.20; background-image:radial-gradient(rgba(122,162,255,.18) .7px,transparent .7px); }
html[data-theme="dark"] .chat-placeholder { color:#91A0B8; }
html[data-theme="dark"] .chat-placeholder h2 { color:#F5F7FB; }
html[data-theme="dark"] .message-list { scrollbar-color:rgba(145,160,184,.34) transparent; }
html[data-theme="dark"] .bubble { background:#152238; border-color:rgba(255,255,255,.09); color:#F5F7FB; box-shadow:0 7px 20px rgba(0,0,0,.15); }
html[data-theme="dark"] .message-row.mine .bubble { background:linear-gradient(135deg,#234A8B,#2E67B9 58%,#337BCC); border-color:rgba(122,162,255,.20); color:#F7FBFF; }
html[data-theme="dark"] .sender-name { color:#8DB5FF; }
html[data-theme="dark"] .message-meta { color:#8394AA; }
html[data-theme="dark"] .message-row.mine .message-meta { color:rgba(247,251,255,.70); }
html[data-theme="dark"] .reply-quote { background:#10213A; color:#F5F7FB; border-left-color:#6B9CFF; }
html[data-theme="dark"] .reply-quote strong { color:#8DB5FF; }
html[data-theme="dark"] .reply-quote span { color:#9AAAC0; }
html[data-theme="dark"] .message-row.mine .reply-quote { background:rgba(3,17,38,.22); }
html[data-theme="dark"] .message-actions button,
html[data-theme="dark"] .message-menu-trigger { background:#101B2D; color:#A3B2C6; border-color:rgba(255,255,255,.11); box-shadow:0 6px 16px rgba(0,0,0,.26); }
html[data-theme="dark"] .message-actions button:hover { color:#8DB5FF; background:#1D2C45; border-color:rgba(122,162,255,.28); }
html[data-theme="dark"] .message-action-menu,
html[data-theme="dark"] .reaction-emoji-picker,
html[data-theme="dark"] .emoji-picker { background:#101B2D; color:#F5F7FB; border-color:rgba(255,255,255,.10); box-shadow:0 18px 48px rgba(0,0,0,.36); }
html[data-theme="dark"] .message-action-menu > button { color:#D8E1ED; }
html[data-theme="dark"] .message-action-menu > button:hover,
html[data-theme="dark"] .quick-reaction:hover { background:#1D2C45; }
html[data-theme="dark"] .message-action-separator { background:rgba(255,255,255,.08); }
html[data-theme="dark"] .reaction-summary button,
html[data-theme="dark"] .reaction-chip { background:#182943; border-color:rgba(255,255,255,.09); color:#DCE6F3; }
html[data-theme="dark"] .reaction-summary button.mine,
html[data-theme="dark"] .reaction-chip.mine { background:rgba(91,140,255,.18); border-color:rgba(91,140,255,.28); }
html[data-theme="dark"] .date-separator span { background:#142238; color:#A6B5C8; border-color:rgba(255,255,255,.07); }
html[data-theme="dark"] .unread-divider span { background:#142B4A; color:#A9C8FF; }

html[data-theme="dark"] .composer { background:rgba(16,27,45,.94); border-top-color:rgba(255,255,255,.08); box-shadow:0 -10px 30px rgba(0,0,0,.14); }
html[data-theme="dark"] .composer textarea { background:#0B1526; color:#F5F7FB; border-color:rgba(255,255,255,.11); }
html[data-theme="dark"] .composer textarea:focus { background:#0E1B2F; border-color:#6B9CFF; box-shadow:0 0 0 3px rgba(91,140,255,.13); }
html[data-theme="dark"] .attach-button,
html[data-theme="dark"] .emoji-button { background:#152A46; color:#8DB5FF; border-color:rgba(91,140,255,.20); }
html[data-theme="dark"] .attach-button:hover,
html[data-theme="dark"] .emoji-button:hover { background:#1B3557; color:#A7C6FF; }
html[data-theme="dark"] .reply-preview { background:#10213A; color:#F5F7FB; border-left-color:#6B9CFF; }
html[data-theme="dark"] .reply-preview strong { color:#8DB5FF; }
html[data-theme="dark"] .reply-preview span { color:#9AAAC0; }
html[data-theme="dark"] .reply-preview.editing-preview { background:#211A3B; border-left-color:#A78BFA; }
html[data-theme="dark"] .reply-preview.editing-preview strong { color:#C4B5FD; }
html[data-theme="dark"] .attachment-draft { background:#152238; border-color:rgba(255,255,255,.09); color:#F5F7FB; }
html[data-theme="dark"] .draft-icon { background:#152A46; color:#8DB5FF; }
html[data-theme="dark"] .draft-copy span { color:#91A0B8; }
html[data-theme="dark"] .draft-remove { background:#1D2C45; color:#A3B2C6; }
html[data-theme="dark"] .drop-overlay { background:rgba(8,17,31,.88); }
html[data-theme="dark"] .drop-overlay > div { background:rgba(21,34,56,.96); border-color:rgba(91,140,255,.42); color:#F5F7FB; }

html[data-theme="dark"] .attachment-card,
html[data-theme="dark"] .image-attachment,
html[data-theme="dark"] .video-attachment,
html[data-theme="dark"] .audio-attachment { background:#101D31; border-color:rgba(255,255,255,.09); }
html[data-theme="dark"] .attachment-copy span,
html[data-theme="dark"] .media-decrypting,
html[data-theme="dark"] .media-footer { color:#91A0B8; }
html[data-theme="dark"] .attachment-icon { background:#152A46; }
html[data-theme="dark"] .attachment-open { background:#183052; color:#8DB5FF; }
html[data-theme="dark"] .chat-image-button,
html[data-theme="dark"] .chat-image { background:#0F1A2C; }

html[data-theme="dark"] .modal-backdrop { background:rgba(0,5,12,.58); }
html[data-theme="dark"] .modal,
html[data-theme="dark"] .secure-password-dialog { background:#101B2D; color:#F5F7FB; border-color:rgba(255,255,255,.10); box-shadow:0 28px 80px rgba(0,0,0,.46); }
html[data-theme="dark"] .modal > header,
html[data-theme="dark"] .settings-footer { background:#0E192A; border-color:rgba(255,255,255,.08); }
html[data-theme="dark"] .modal h2,
html[data-theme="dark"] .modal h3,
html[data-theme="dark"] .secure-password-dialog h3 { color:#F5F7FB; }
html[data-theme="dark"] .profile-card { background:linear-gradient(120deg,#142238,#11233A); border-color:rgba(255,255,255,.09); }
html[data-theme="dark"] .profile-link { color:#8DB5FF; }
html[data-theme="dark"] .pill { color:#A9C8FF; background:rgba(91,140,255,.15); }
html[data-theme="dark"] .security-note { background:linear-gradient(135deg,rgba(56,189,248,.09),rgba(52,211,153,.07)); border-color:rgba(52,211,153,.18); }
html[data-theme="dark"] .security-note p,
html[data-theme="dark"] .security-note-secondary { color:#9AACBF; }
html[data-theme="dark"] .setting-row,
html[data-theme="dark"] .settings-nav-card,
html[data-theme="dark"] .device-row,
html[data-theme="dark"] .invite-row,
html[data-theme="dark"] .admin-announcement-item,
html[data-theme="dark"] .server-user-item,
html[data-theme="dark"] .server-user-detail-card,
html[data-theme="dark"] .server-system-card,
html[data-theme="dark"] .server-report-target-card,
html[data-theme="dark"] .server-report-item { background:#121F33; border-color:rgba(255,255,255,.09); color:#F5F7FB; }
html[data-theme="dark"] .setting-row .sub,
html[data-theme="dark"] .settings-nav-copy > span,
html[data-theme="dark"] .server-report-summary,
html[data-theme="dark"] .server-report-meta,
html[data-theme="dark"] .server-report-review,
html[data-theme="dark"] .server-report-target-identity .sub { color:#91A0B8; }
html[data-theme="dark"] .settings-nav-card:hover { background:#17263D; border-color:rgba(91,140,255,.24); }
html[data-theme="dark"] .settings-nav-icon,
html[data-theme="dark"] .theme-setting-icon { background:#152A46; color:#8DB5FF; }
html[data-theme="dark"] .theme-select { background:#0B1526; color:#F5F7FB; border-color:rgba(255,255,255,.11); }
html[data-theme="dark"] .secondary { background:#172B48; color:#9CC0FF; border-color:rgba(91,140,255,.16); }
html[data-theme="dark"] .secondary:hover { background:#1C3557; }
html[data-theme="dark"] .danger { background:rgba(239,91,104,.12); color:#FF9AA3; border-color:rgba(239,91,104,.22); }
html[data-theme="dark"] .toast { background:#142238; color:#F5F7FB; border-color:rgba(255,255,255,.10); box-shadow:0 15px 42px rgba(0,0,0,.35); }
html[data-theme="dark"] .toast.error { background:#2A1822; border-color:rgba(239,91,104,.27); }

html[data-theme="dark"] .chip,
html[data-theme="dark"] .member-row,
html[data-theme="dark"] .contact-row,
html[data-theme="dark"] .request-row,
html[data-theme="dark"] .chat-content-item,
html[data-theme="dark"] .wallpaper-option,
html[data-theme="dark"] .poll-card,
html[data-theme="dark"] .poll-option,
html[data-theme="dark"] .poll-setting-check,
html[data-theme="dark"] .reaction-detail-row { background:#121F33; color:#F5F7FB; border-color:rgba(255,255,255,.09); }
html[data-theme="dark"] .chip button,
html[data-theme="dark"] .poll-option-count,
html[data-theme="dark"] .poll-meta,
html[data-theme="dark"] .contact-row .sub,
html[data-theme="dark"] .member-row .sub { color:#91A0B8; }
html[data-theme="dark"] .poll-option:hover { background:#172A45; }
html[data-theme="dark"] .poll-option.selected { background:rgba(91,140,255,.16); border-color:rgba(91,140,255,.32); }
html[data-theme="dark"] .poll-option-progress { background:#477FD0; }

html[data-theme="dark"] .server-management-tabs { background:#0B1526; border-color:rgba(255,255,255,.08); }
html[data-theme="dark"] #server-management-modal .server-management-tab { color:#9AACBF; }
html[data-theme="dark"] #server-management-modal .server-management-tab.active { background:#1B2C46; color:#9CC0FF; box-shadow:0 2px 7px rgba(0,0,0,.22); }
html[data-theme="dark"] .server-report-target-name > strong,
html[data-theme="dark"] .server-report-target-head .grow > strong,
html[data-theme="dark"] .server-report-item-head strong { color:#EAF0F7; }
html[data-theme="dark"] .server-report-comment { color:#C8D4E3; }
html[data-theme="dark"] .server-report-block-user { background:#312914; color:#F0C56A; border-color:#6B5523; }
html[data-theme="dark"] .server-report-block-user:hover { background:#3A3017; }
html[data-theme="dark"] .report-file-picker { background:#0B1526; border-color:rgba(255,255,255,.10); }
html[data-theme="dark"] .report-file-selected { color:#91A0B8; }

html[data-theme="dark"] .announcement-chat,
html[data-theme="dark"] .announcement-message-card { background:#101B2D; color:#F5F7FB; border-color:rgba(255,255,255,.09); }
html[data-theme="dark"] .announcement-message-body { color:#DCE5F0; }
html[data-theme="dark"] .announcement-banner { background:#162943; color:#DCE9FF; border-color:rgba(91,140,255,.18); }

@media (max-width:760px) {
  html[data-theme="dark"] .messenger { background:#08111F; }
}

/* Gaigram 0.7.1-rc1 fix1: coherent dark surfaces and default-chat wallpaper.
   All overrides are scoped to resolved dark mode. The established light
   palette, user-uploaded custom chat wallpapers and layout are unchanged. */
html[data-theme="dark"] {
  --theme-dark-card:#142238;
  --theme-dark-inset:#0B1526;
  --theme-dark-border:rgba(151,174,209,.18);
  --theme-dark-ink:#F1F6FF;
  --theme-dark-secondary:#B2C1D5;
}
/* The existing Gaigram wallpaper is rendered as a dark, blue-toned layer.
   Do not recolor a user's custom wallpaper or change its cover behavior. */
html[data-theme="dark"] .chat-panel,
html[data-theme="dark"] .active-chat { background-color:#0B1526; }
html[data-theme="dark"] .active-chat:not(.has-custom-wallpaper)::before {
  background-color:#F7FBFF;
  filter:invert(1) hue-rotate(180deg) brightness(.78) contrast(.82);
}
html[data-theme="dark"] .chat-wallpaper-preview:not(.custom) {
  background-color:#F7FBFF;
  filter:invert(1) hue-rotate(180deg) brightness(.78) contrast(.82);
}
/* The wallpaper preview's mock message is a light-mode decoration. */
html[data-theme="dark"] .chat-wallpaper-preview:not(.custom)::after {
  background:linear-gradient(135deg,rgba(42,73,113,.78),rgba(28,52,83,.83));
  border-color:rgba(151,174,209,.22);
}
html[data-theme="dark"] .chat-wallpaper-copy strong { color:var(--theme-dark-ink); }

/* Composer is one dark input surface, not two differently styled buttons. */
html[data-theme="dark"] .composer-input-shell {
  background:var(--theme-dark-inset);
  border-color:var(--theme-dark-border);
  box-shadow:none;
}
html[data-theme="dark"] .composer-input-shell:focus-within {
  background:#0F1D31;
  border-color:rgba(116,163,237,.55);
  box-shadow:0 0 0 2px rgba(91,140,255,.11);
}
html[data-theme="dark"] .composer-input-shell textarea,
html[data-theme="dark"] .composer-input-shell textarea:focus {
  background:transparent;
  color:var(--theme-dark-ink);
  border:0;
  box-shadow:none;
}
html[data-theme="dark"] .composer-input-shell .attach-button,
html[data-theme="dark"] .composer-input-shell .emoji-button,
html[data-theme="dark"] .composer-input-shell .poll-button {
  background:transparent;
  color:#AFC1D8;
  border:0;
  box-shadow:none;
}
html[data-theme="dark"] .composer-input-shell .attach-button:hover:not(:disabled),
html[data-theme="dark"] .composer-input-shell .emoji-button:hover:not(:disabled),
html[data-theme="dark"] .composer-input-shell .poll-button:hover:not(:disabled),
html[data-theme="dark"] .composer-input-shell .emoji-button.active {
  background:#203956;
  color:#BED8FF;
  box-shadow:none;
}
html[data-theme="dark"] .composer-input-shell :is(.attach-button,.emoji-button,.poll-button):focus-visible {
  outline:2px solid #86B5FF;
  outline-offset:1px;
}

/* Owner modal chrome: its ID-specific light header previously overrode the
   ordinary dark .modal header and left white text on a white title bar. */
html[data-theme="dark"] #server-management-modal > header {
  background:#0E192A;
  color:var(--theme-dark-ink);
  border-bottom-color:var(--theme-dark-border);
}
html[data-theme="dark"] #server-management-modal > header :is(h2,.modal-title-row) { color:var(--theme-dark-ink); }
html[data-theme="dark"] #server-management-modal > header :is(.icon-button,.modal-back-button) { color:#AFC1D8; }
html[data-theme="dark"] #server-management-modal > header :is(.icon-button,.modal-back-button):hover {
  color:var(--theme-dark-ink);
  background:#1E314C;
}
html[data-theme="dark"] #server-management-modal .server-management-panel,
html[data-theme="dark"] .admin-announcement-list {
  scrollbar-color:rgba(160,185,219,.40) transparent;
}
html[data-theme="dark"] #server-management-modal .server-management-panel::-webkit-scrollbar-thumb,
html[data-theme="dark"] .admin-announcement-list::-webkit-scrollbar-thumb { background:rgba(160,185,219,.40); }

/* Announcements: form, history, inputs, date-time controls, badges. */
html[data-theme="dark"] #server-announcements-panel .announcement-admin-form,
html[data-theme="dark"] #server-announcements-panel .admin-announcement-row {
  background:var(--theme-dark-card);
  color:var(--theme-dark-ink);
  border-color:var(--theme-dark-border);
}
html[data-theme="dark"] #server-announcements-panel .announcement-admin-form label { color:var(--theme-dark-secondary); }
html[data-theme="dark"] #server-announcements-panel .announcement-admin-form :is(input,select,textarea) {
  background:var(--theme-dark-inset);
  color:var(--theme-dark-ink);
  border-color:var(--theme-dark-border);
  color-scheme:dark;
}
html[data-theme="dark"] #server-announcements-panel .announcement-admin-form :is(input,select,textarea)::placeholder { color:#93A8C3; }
html[data-theme="dark"] #server-announcements-panel .announcement-admin-form :is(input,select,textarea):focus {
  background:#11223A;
  border-color:#81ACF2;
  box-shadow:0 0 0 2px rgba(91,140,255,.15);
}
html[data-theme="dark"] #server-announcements-panel :is(.admin-announcement-copy span,.announcement-admin-meta,.field-hint) { color:var(--theme-dark-secondary); }
html[data-theme="dark"] #server-announcements-panel .admin-announcement-body { color:#D7E2F1; }
html[data-theme="dark"] #server-announcements-panel .announcement-status { background:#25364E; color:#CBD8E9; }
html[data-theme="dark"] #server-announcements-panel .announcement-status.published { background:#173A30; color:#8BE0B3; }
html[data-theme="dark"] #server-announcements-panel .announcement-status.scheduled { background:#1A3553; color:#A8D1FF; }
html[data-theme="dark"] #server-announcements-panel .announcement-status.expired { background:#253042; color:#B5C2D3; }
html[data-theme="dark"] #server-announcements-panel .announcement-cancel {
  background:#351D2A; color:#FFA8B1; border-color:rgba(249,124,141,.30);
}
html[data-theme="dark"] #server-announcements-panel .announcement-cancel:hover { background:#462332; }

/* System dashboard: actual classes are system-* (not server-system-*). */
html[data-theme="dark"] #server-system-panel :is(.system-stat-card,.system-resource-card,.system-service-list) {
  background:var(--theme-dark-card);
  color:var(--theme-dark-ink);
  border-color:var(--theme-dark-border);
}
html[data-theme="dark"] #server-system-panel :is(.system-stat-card > strong,.system-resource-head strong,.system-block-title strong) { color:var(--theme-dark-ink); }
html[data-theme="dark"] #server-system-panel :is(.system-stat-card > span,.system-stat-card > small,.system-resource-head span,.system-block-title span,.system-build-info) { color:var(--theme-dark-secondary); }
html[data-theme="dark"] #server-system-panel .system-service-row { border-bottom-color:var(--theme-dark-border); }
html[data-theme="dark"] #server-system-panel .system-service-row > span { color:#DFE8F6; }
html[data-theme="dark"] #server-system-panel .system-service-status { color:#B9C8DB; }
html[data-theme="dark"] #server-system-panel .system-service-status.running { color:#89E2B5; }
html[data-theme="dark"] #server-system-panel .system-service-status.stopped { color:#FFABB4; }
html[data-theme="dark"] #server-system-panel .system-meter { background:#263951; }

/* Owner user-detail cards, report surfaces and invitation affordances. */
html[data-theme="dark"] #server-management-modal :is(.server-user-detail,.server-user-detail-status,.server-user-stat,.server-user-detail-row) {
  background:var(--theme-dark-card);
  color:var(--theme-dark-ink);
  border-color:var(--theme-dark-border);
}
html[data-theme="dark"] #server-management-modal :is(.server-user-detail-section h4,.server-user-stat strong,.server-user-detail-row strong) { color:var(--theme-dark-ink); }
html[data-theme="dark"] #server-management-modal :is(.server-user-stat span,.server-user-detail-row span,.server-user-action-note) { color:var(--theme-dark-secondary); }
html[data-theme="dark"] #server-management-modal .server-user-open:hover { background:#1B304A; }
html[data-theme="dark"] #server-management-modal .server-user-detail-actions .warning { background:#40321E; color:#F3CF88; border-color:#756039; }
html[data-theme="dark"] #server-management-modal .server-user-detail-actions .warning:hover { background:#504025; }
html[data-theme="dark"] #server-management-modal .server-user-detail-actions .danger-button { background:#391E2C; color:#FFB2BE; border-color:#754150; }
html[data-theme="dark"] #server-management-modal .server-user-detail-actions .danger-button:hover { background:#482535; }
html[data-theme="dark"] #server-management-modal .invite-code { background:#142E4A; color:#C7E1FF; border-color:#345778; }
html[data-theme="dark"] #server-management-modal .section-subtitle,
html[data-theme="dark"] #server-management-modal .server-reports-note { color:var(--theme-dark-secondary); }

/* Polls: the original light rules were applied to the sender's bubble and
   overridden only for the outer card in rc1. Keep answer tiles dark as well. */
html[data-theme="dark"] .poll-question,
html[data-theme="dark"] .message-row.mine .poll-question { color:var(--theme-dark-ink); }
html[data-theme="dark"] .poll-option,
html[data-theme="dark"] .message-row.mine .poll-option {
  background:#1B2F4A;
  color:#ECF4FF;
  border-color:rgba(140,181,240,.25);
}
html[data-theme="dark"] .poll-option:hover:not(:disabled),
html[data-theme="dark"] .message-row.mine .poll-option:hover:not(:disabled) {
  background:#254060;
  border-color:rgba(153,193,255,.55);
}
html[data-theme="dark"] .poll-option.selected,
html[data-theme="dark"] .message-row.mine .poll-option.selected {
  background:#294C79;
  border-color:#82B6FC;
}
html[data-theme="dark"] .poll-option:disabled:not(.selected) { opacity:.87; }
html[data-theme="dark"] .poll-option-check { background:#102137; color:#DDEBFE; border-color:#94ABC7; }
html[data-theme="dark"] .poll-option.selected .poll-option-check { background:#397BD0; border-color:#8FBDF7; color:#fff; }
html[data-theme="dark"] .poll-option-count,
html[data-theme="dark"] .poll-footer,
html[data-theme="dark"] .message-row.mine .poll-footer,
html[data-theme="dark"] .poll-footer strong { color:#B4C8DF; }
html[data-theme="dark"] .poll-option-progress { background:rgba(107,162,244,.24); }
html[data-theme="dark"] .poll-setting-check small,
html[data-theme="dark"] .poll-editor-heading,
html[data-theme="dark"] .poll-editor-heading span { color:var(--theme-dark-secondary); }
html[data-theme="dark"] .poll-option-remove { background:#352332; color:#FFA9B4; }
html[data-theme="dark"] .poll-option-remove:hover { background:#462938; }
html[data-theme="dark"] .poll-form .poll-setting-check { background:transparent; }

/* Secondary modal/list surfaces found in source audit. */
html[data-theme="dark"] .chat-content-tabs,
html[data-theme="dark"] .chat-search-bar { background:#101B2D; border-color:var(--theme-dark-border); }
html[data-theme="dark"] .chat-content-tab { color:#B4C5DA; }
html[data-theme="dark"] .chat-content-tab:hover,
html[data-theme="dark"] .chat-content-tab.active { background:#223A59; color:#B9D7FF; border-color:rgba(142,185,246,.24); }
html[data-theme="dark"] .chat-search-input-wrap { background:var(--theme-dark-inset); border-color:var(--theme-dark-border); }
html[data-theme="dark"] .chat-search-input-wrap:focus-within { background:#11223A; border-color:#81ACF2; box-shadow:0 0 0 2px rgba(91,140,255,.14); }
html[data-theme="dark"] .chat-search-input-wrap input { background:transparent; color:var(--theme-dark-ink); }
html[data-theme="dark"] .chat-search-status,
html[data-theme="dark"] .chat-content-progress { color:var(--theme-dark-secondary); }
html[data-theme="dark"] .forward-target-row:hover,
html[data-theme="dark"] .forward-target-row.busy { background:#1B304A; border-color:var(--theme-dark-border); }
html[data-theme="dark"] .forward-target-copy span { color:var(--theme-dark-secondary); }
html[data-theme="dark"] .report-target-card,
html[data-theme="dark"] .report-privacy-note { background:var(--theme-dark-card); color:#D5E3F4; border-color:var(--theme-dark-border); }
html[data-theme="dark"] .report-form select:hover,
html[data-theme="dark"] .report-form select:focus { background-color:#11223A; color:var(--theme-dark-ink); }
html[data-theme="dark"] .announcement-banner.important { background:#392A19; color:#FFE3B7; border-color:#705530; }
html[data-theme="dark"] .announcement-banner.maintenance { background:#2B2545; color:#DACCFF; border-color:#5A4A8A; }
html[data-theme="dark"] .announcement-banner-copy span { color:#B2C1D5; }


/* Gaigram 0.7.1-rc1 theme fix2: dark-mode parity regression after fix1.
   Intentional scope: resolved dark mode only. Do not tint user-uploaded chat
   wallpapers, alter message content, or change any cryptographic behavior. */
html[data-theme="dark"] {
  --theme-fix2-panel:#101B2D;
  --theme-fix2-card:#17273D;
  --theme-fix2-inset:#0B1526;
  --theme-fix2-hover:#233A57;
  --theme-fix2-border:rgba(160,184,220,.19);
  --theme-fix2-text:#EEF4FC;
  --theme-fix2-secondary:#B6C5D9;
  --theme-fix2-accent:#A6CAFF;
}

/* 1/2: Buttons, modal close/back actions, Chats/Contacts navigation. Hover
   must never switch a dark surface into the old white/light-blue palette. */
html[data-theme="dark"] :is(.modal .icon-button,.chat-header .icon-button,.sidebar-header .icon-button,.settings-footer .icon-button):hover:not(:disabled),
html[data-theme="dark"] :is(.modal .icon-button,.chat-header .icon-button,.sidebar-header .icon-button):focus-visible {
  background:var(--theme-fix2-hover);
  color:var(--theme-fix2-text);
  border-color:var(--theme-fix2-border);
}
html[data-theme="dark"] #group-info-button,
html[data-theme="dark"] #chat-actions-button {
  background:#1A2D46;
  color:var(--theme-fix2-accent);
  border:1px solid var(--theme-fix2-border);
}
html[data-theme="dark"] #group-info-button:hover,
html[data-theme="dark"] #chat-actions-button:hover,
html[data-theme="dark"] #group-info-button:focus-visible,
html[data-theme="dark"] #chat-actions-button:focus-visible {
  background:#274669;
  color:#E4F0FF;
  border-color:#5F91D5;
}
html[data-theme="dark"] .sidebar-tab:hover:not(.active),
html[data-theme="dark"] .sidebar-tab:focus-visible:not(.active) {
  background:#203750;
  color:#D7E8FF;
  border-color:var(--theme-fix2-border);
}
html[data-theme="dark"] .sidebar-tab.active,
html[data-theme="dark"] .sidebar-tab.active:hover,
html[data-theme="dark"] .sidebar-tab.active:focus-visible {
  background:#253F61;
  color:#E2F0FF;
  border-color:rgba(126,170,231,.38);
  box-shadow:none;
}
html[data-theme="dark"] .sidebar-badge { box-shadow:0 0 0 2px var(--theme-fix2-panel); }

/* 8: Actual scrollable Chats/Contacts surfaces remained white after fix1.
   Their descendant title colors were already white, making them unreadable. */
html[data-theme="dark"] .sidebar :is(.chat-list,.contact-list,.sidebar-tabs),
html[data-theme="dark"] .sidebar .contact-item.contact-item-row {
  background:var(--theme-fix2-panel);
  color:var(--theme-fix2-text);
  border-color:var(--theme-fix2-border);
  scrollbar-color:rgba(150,177,212,.40) transparent;
}
html[data-theme="dark"] .sidebar :is(.chat-item,.contact-item,.contact-main) {
  background:transparent;
  color:var(--theme-fix2-text);
  border-color:transparent;
}
html[data-theme="dark"] .sidebar .chat-item:hover,
html[data-theme="dark"] .sidebar :is(.contact-item,.contact-main):hover,
html[data-theme="dark"] .sidebar :is(.contact-item,.contact-main):focus-visible {
  background:#1C304B;
  border-color:var(--theme-fix2-border);
}
html[data-theme="dark"] .sidebar .chat-item.active,
html[data-theme="dark"] .sidebar .chat-item.active:hover {
  background:#223C5E;
  border-color:rgba(126,170,231,.32);
  box-shadow:none;
}
html[data-theme="dark"] .sidebar :is(.chat-item-title,.contact-copy strong,.contact-main strong) { color:var(--theme-fix2-text); }
html[data-theme="dark"] .sidebar :is(.chat-preview,.chat-time,.contact-copy span,.draft-preview-text,.contact-section-title) { color:var(--theme-fix2-secondary); }
html[data-theme="dark"] .contact-section-count { background:#233C5A; color:#C2DCFF; }
html[data-theme="dark"] :is(.contact-request,.contact-request.incoming,.contact-lookup-card) {
  background:var(--theme-fix2-card);
  color:var(--theme-fix2-text);
  border-color:var(--theme-fix2-border);
}
html[data-theme="dark"] .contact-lookup-empty { color:var(--theme-fix2-secondary); border-color:var(--theme-fix2-border); }
html[data-theme="dark"] .contact-request-decline { background:#23364F; color:#D6E4F6; border-color:var(--theme-fix2-border); }
html[data-theme="dark"] .contact-request-decline:hover { background:var(--theme-fix2-hover); }
html[data-theme="dark"] .contact-remove:hover { background:#3B2532; color:#FFB1BA; }

/* 3/11: File tiles and download controls have their own higher-specificity
   outgoing-message light rules. Images stay unfiltered; only the chrome tints. */
html[data-theme="dark"] .message-row .attachment-card,
html[data-theme="dark"] .message-row.mine .attachment-card {
  background:#1C324E;
  color:#F4F8FF;
  border-color:rgba(161,190,229,.28);
}
html[data-theme="dark"] .message-row .attachment-copy strong,
html[data-theme="dark"] .message-row.mine .attachment-copy strong { color:#F4F8FF; }
html[data-theme="dark"] .message-row .attachment-copy span,
html[data-theme="dark"] .message-row.mine .attachment-copy span { color:#C2D2E6; }
html[data-theme="dark"] .message-row .attachment-icon,
html[data-theme="dark"] .message-row.mine .attachment-icon {
  background:#244A74;
  color:#B9D7FF;
  border-color:rgba(158,194,239,.22);
}
html[data-theme="dark"] .message-row :is(.image-attachment,.video-attachment,.audio-attachment),
html[data-theme="dark"] .message-row.mine :is(.image-attachment,.video-attachment,.audio-attachment) { background:#13243A; }
html[data-theme="dark"] .message-row :is(.attachment-open,.media-download),
html[data-theme="dark"] .message-row.mine :is(.attachment-open,.media-download) {
  background:#24486D;
  color:#D9EBFF;
  border:1px solid rgba(160,194,233,.32);
  text-decoration:none;
}
html[data-theme="dark"] .message-row :is(.attachment-open,.media-download):hover:not(:disabled),
html[data-theme="dark"] .message-row.mine :is(.attachment-open,.media-download):hover:not(:disabled) {
  background:#315982;
  color:#FFFFFF;
  border-color:#7FADE7;
}
html[data-theme="dark"] .message-row :is(.media-footer,.media-decrypting),
html[data-theme="dark"] .message-row.mine .media-footer { color:#C0D0E4; }

/* 4/12: Read-only system channel bar and announcements title were still
   using light CSS; the latter was dark text on a dark message card. */
html[data-theme="dark"] .announcement-chat .announcement-readonly {
  background:#101B2D;
  color:#B8C9DD;
  border-top:1px solid var(--theme-fix2-border);
}
html[data-theme="dark"] .announcement-chat .announcement-message-card h3 { color:#E4EEFC; }
html[data-theme="dark"] .announcement-chat .announcement-message-sender strong { color:#F4F8FF; }
html[data-theme="dark"] .announcement-chat .announcement-message-time { color:#A9BBD2; }
html[data-theme="dark"] .announcement-chat .announcement-message-body { color:#D8E6F5; }

/* 5: These are .message-day-separator, NOT the old .date-separator name. */
html[data-theme="dark"] .active-chat .load-more,
html[data-theme="dark"] .message-day-separator span,
html[data-theme="dark"] .new-messages-divider span {
  background:#20334C;
  color:#E0ECFC;
  border-color:rgba(148,182,226,.34);
  box-shadow:0 4px 14px rgba(0,0,0,.24);
}
html[data-theme="dark"] .active-chat .load-more:hover:not(:disabled),
html[data-theme="dark"] .active-chat .load-more:focus-visible { background:#2C496D; color:#FFFFFF; border-color:#80A9DE; }
html[data-theme="dark"] .new-messages-divider { color:#B8D5FF; }
html[data-theme="dark"] .new-messages-button { background:#233A58; color:#B8D5FF; border-color:var(--theme-fix2-border); }
html[data-theme="dark"] .new-messages-count { border-color:#233A58; }

/* 6: Chat-header overflow menu and group information icon. Specific ID
   rules and legacy white hover rules must not leak into resolved dark mode. */
html[data-theme="dark"] #chat-actions-menu {
  background:#14243A;
  color:var(--theme-fix2-text);
  border-color:var(--theme-fix2-border);
  box-shadow:0 18px 42px rgba(0,0,0,.46);
}
html[data-theme="dark"] #chat-actions-menu button,
html[data-theme="dark"] #chat-wallpaper-button { background:transparent; color:#E1EBF8; }
html[data-theme="dark"] #chat-actions-menu button:hover,
html[data-theme="dark"] #chat-actions-menu button:focus-visible,
html[data-theme="dark"] #chat-wallpaper-button:hover,
html[data-theme="dark"] #chat-wallpaper-button:focus-visible {
  background:#28415E;
  color:#FFFFFF;
}
html[data-theme="dark"] #chat-actions-menu .chat-actions-separator { background:var(--theme-fix2-border); }
html[data-theme="dark"] #chat-actions-menu button.danger { background:transparent; color:#FFACBA; }
html[data-theme="dark"] #chat-actions-menu button.danger:hover { background:#3C2836; color:#FFD5DC; }
html[data-theme="dark"] #chat-actions-menu button.report { color:#F2CD91; }
html[data-theme="dark"] #chat-actions-menu button.report:hover { background:#3A3223; color:#FFE0A6; }

/* 7: Group details uses separate profile/member components, none of which
   inherit the generic modal and member-row dark styles. */
html[data-theme="dark"] #group-manage-modal :is(.group-profile-card,.group-add-member,.group-member-row) {
  background:var(--theme-fix2-card);
  color:var(--theme-fix2-text);
  border-color:var(--theme-fix2-border);
}
html[data-theme="dark"] #group-manage-modal :is(.group-profile-fields label,.group-add-member label,.group-member-name strong) { color:var(--theme-fix2-text); }
html[data-theme="dark"] #group-manage-modal :is(.group-member-copy span,.group-manage-hint,.group-members-heading span) { color:var(--theme-fix2-secondary); }
html[data-theme="dark"] #group-manage-modal :is(.group-profile-card,.group-add-member) :is(input,textarea) {
  background:var(--theme-fix2-inset);
  color:var(--theme-fix2-text);
  border-color:var(--theme-fix2-border);
}
html[data-theme="dark"] #group-manage-modal :is(.group-profile-card,.group-add-member) :is(input,textarea)::placeholder { color:#A4B7CE; }
html[data-theme="dark"] #group-manage-modal .group-role-badge { background:#26364E; color:#D8E6F7; }
html[data-theme="dark"] #group-manage-modal .group-role-badge.role-owner { background:#22446B; color:#B6D8FF; }
html[data-theme="dark"] #group-manage-modal .group-role-badge.role-admin { background:#1C493B; color:#ABEACB; }
html[data-theme="dark"] #group-manage-modal .group-member-action { background:#264260; color:#D4E8FF; }
html[data-theme="dark"] #group-manage-modal .group-member-action:hover { background:#315478; }
html[data-theme="dark"] #group-manage-modal .group-member-action.danger-text { background:#392735; color:#FFB4C0; }
html[data-theme="dark"] #group-manage-modal .group-member-action.danger-text:hover { background:#4C3040; }
html[data-theme="dark"] #group-manage-modal .group-member-action.report-text { color:#F1CB90; }
html[data-theme="dark"] #group-manage-modal .picker-results { background:#14243A; color:var(--theme-fix2-text); border-color:var(--theme-fix2-border); }
html[data-theme="dark"] #group-manage-modal .picker-user:hover { background:#243E5B; }

/* 9: Emoji category strips (regular and reaction picker) were never themed.
   Preserve the actual Unicode/Twemoji images without color filters. */
html[data-theme="dark"] :is(.emoji-tabs,.reaction-emoji-tabs) {
  background:#14243A;
  border-bottom-color:var(--theme-fix2-border);
}
html[data-theme="dark"] :is(.emoji-tab,.reaction-emoji-tab,.emoji-item,.reaction-emoji-grid button) { background:transparent; color:#C7D8EB; }
html[data-theme="dark"] :is(.emoji-tab,.reaction-emoji-tab,.emoji-item,.reaction-emoji-grid button):hover { background:#263F5D; }
html[data-theme="dark"] :is(.emoji-tab,.reaction-emoji-tab).active { background:#31557E; color:#F2F7FF; box-shadow:inset 0 0 0 1px rgba(158,194,239,.30); }
html[data-theme="dark"] :is(.emoji-grid,.reaction-emoji-grid) { background:#101B2D; scrollbar-color:rgba(150,177,212,.40) transparent; }

/* 10: Legacy action-menu rules use !important on dark text and white hover.
   Override those EXACT rules, while keeping genuine disabled actions dimmed. */
html[data-theme="dark"] .message-actions .message-menu-trigger,
html[data-theme="dark"] .message-row.mine .message-actions .message-menu-trigger {
  background:#1F344F;
  color:#D1E2F7;
  border-color:var(--theme-fix2-border);
}
html[data-theme="dark"] .message-actions .message-menu-trigger:hover,
html[data-theme="dark"] .message-row.menu-open .message-actions .message-menu-trigger { background:#2C4A70; color:#FFFFFF; }
html[data-theme="dark"] .message-action-menu button:not(:disabled) { color:#E6F0FD !important; }
html[data-theme="dark"] .message-action-menu button:not(:disabled):hover,
html[data-theme="dark"] .message-action-menu button:not(:disabled):focus-visible {
  background:#284362 !important;
  color:#FFFFFF !important;
  outline:2px solid transparent;
}
html[data-theme="dark"] .message-action-menu button.active:not(:disabled) { color:#B6D6FF !important; }
html[data-theme="dark"] .message-action-menu button:disabled { color:#8394AC !important; background:transparent !important; opacity:.66; cursor:not-allowed; }
html[data-theme="dark"] .message-action-menu button.danger:not(:disabled) { color:#FFADB9 !important; }
html[data-theme="dark"] .message-action-menu button.danger:not(:disabled):hover { background:#432936 !important; color:#FFD7DE !important; }
html[data-theme="dark"] .message-action-menu .message-quick-reactions > button.quick-reaction:hover:not(:disabled),
html[data-theme="dark"] .message-action-menu .message-quick-reactions > button.quick-reaction.active:not(:disabled) {
  background:#284362 !important;
  color:#D8E8FD !important;
}
html[data-theme="dark"] .message-action-menu .message-action-separator { background:var(--theme-fix2-border); }
html[data-theme="dark"] .message-info-list :is(.message-receipt-row,.message-receipt-heading span) {
  background:var(--theme-fix2-card);
  color:var(--theme-fix2-text);
  border-color:var(--theme-fix2-border);
}
html[data-theme="dark"] .message-info-list :is(.message-receipt-copy span,.message-info-loading) { color:var(--theme-fix2-secondary); }

/* Gaigram 0.7.1-rc1 theme fix3: targeted dark-mode parity after staging visual review.
   Scope: forwarded labels, sidebar searches, Media/Files/Links content rows. */
html[data-theme="dark"] .forwarded-label {
  color:#B8C9DD;
}
html[data-theme="dark"] .forwarded-label span {
  color:#AFC1D7;
}
html[data-theme="dark"] .forwarded-label strong {
  color:#9CC8FF;
  font-weight:750;
}
html[data-theme="dark"] .message-row.mine .forwarded-label span {
  color:rgba(255,255,255,.72);
}
html[data-theme="dark"] .message-row.mine .forwarded-label strong {
  color:#F2F8FF;
}

/* Sidebar search chrome: both Chats and Contacts reuse .search-wrap. */
html[data-theme="dark"] .search-wrap {
  background:#101B2D;
  border-bottom-color:rgba(151,174,209,.18);
}
html[data-theme="dark"] .search-wrap input {
  background:#0B1526;
  color:#F1F6FF;
  border-color:rgba(151,174,209,.22);
  box-shadow:none;
}
html[data-theme="dark"] .search-wrap input::placeholder {
  color:#8FA4BE;
}
html[data-theme="dark"] .search-wrap input:focus {
  background:#101F33;
  color:#FFFFFF;
  border-color:#5C94D5;
  box-shadow:0 0 0 3px rgba(86,168,255,.12);
}
html[data-theme="dark"] .search-results {
  background:#142238;
  color:#F1F6FF;
  border-color:rgba(151,174,209,.22);
  box-shadow:0 18px 48px rgba(0,0,0,.38);
}
html[data-theme="dark"] .search-user,
html[data-theme="dark"] .picker-user {
  color:#F1F6FF;
}
html[data-theme="dark"] .search-user:hover,
html[data-theme="dark"] .picker-user:hover {
  background:#223A59;
}
html[data-theme="dark"] .search-results .user-copy span {
  color:#A8B9CF;
}

/* Media & files / links modal: rows and controls previously kept light-mode cards. */
html[data-theme="dark"] .chat-content-modal {
  background:#101B2D;
  color:#F1F6FF;
  border-color:rgba(151,174,209,.18);
}
html[data-theme="dark"] .chat-content-body {
  background:#101B2D;
}
html[data-theme="dark"] .chat-file-row,
html[data-theme="dark"] .chat-link-row {
  background:#142238;
  color:#F1F6FF;
  border-color:rgba(151,174,209,.20);
  box-shadow:none;
}
html[data-theme="dark"] .chat-file-icon,
html[data-theme="dark"] .chat-link-icon {
  background:#1E3A5A;
  color:#A9D0FF;
  border:1px solid rgba(151,190,238,.18);
}
html[data-theme="dark"] .chat-file-copy strong,
html[data-theme="dark"] .chat-link-copy a {
  color:#F1F6FF;
}
html[data-theme="dark"] .chat-file-copy span,
html[data-theme="dark"] .chat-link-copy span,
html[data-theme="dark"] .chat-link-copy small {
  color:#A9BBD1;
}
html[data-theme="dark"] .chat-link-copy a:hover {
  color:#9CC8FF;
}
html[data-theme="dark"] .chat-content-actions button,
html[data-theme="dark"] .chat-link-row > button {
  background:#203A59;
  color:#D8E9FF;
  border-color:rgba(151,190,238,.25);
}
html[data-theme="dark"] .chat-content-actions button:hover,
html[data-theme="dark"] .chat-content-actions button:focus-visible,
html[data-theme="dark"] .chat-link-row > button:hover,
html[data-theme="dark"] .chat-link-row > button:focus-visible {
  background:#2B4C70;
  color:#FFFFFF;
  border-color:#6F9FD8;
}
html[data-theme="dark"] .chat-content-empty,
html[data-theme="dark"] .chat-content-progress {
  color:#A9BBD1;
}

/* Gaigram 0.7.1-rc1 theme fix4: dark poll parity after staging visual review.
   Keep the light-theme hierarchy, but make poll controls read naturally inside
   both incoming dark bubbles and outgoing blue bubbles. */
html[data-theme="dark"] .poll-card {
  background:transparent;
  color:#F2F7FF;
  border-color:transparent;
}
html[data-theme="dark"] .poll-question {
  color:#F3F8FF;
  text-shadow:none;
}
html[data-theme="dark"] .poll-option {
  background:#1A2D46;
  color:#EAF3FF;
  border-color:rgba(151,190,238,.28);
  box-shadow:none;
}
html[data-theme="dark"] .poll-option:hover:not(:disabled) {
  background:#223B59;
  border-color:rgba(157,199,251,.56);
}
html[data-theme="dark"] .poll-option.selected {
  background:#2A4E78;
  color:#FFFFFF;
  border-color:#82B6FC;
}
html[data-theme="dark"] .poll-option:disabled:not(.selected) {
  opacity:.94;
}
html[data-theme="dark"] .poll-option-progress {
  background:rgba(89,145,221,.16);
}
html[data-theme="dark"] .poll-option.selected .poll-option-progress {
  background:rgba(112,172,250,.22);
}
html[data-theme="dark"] .poll-option-check {
  background:#102137;
  color:#E9F3FF;
  border-color:#91A9C5;
}
html[data-theme="dark"] .poll-option.selected .poll-option-check {
  background:#3F87DE;
  border-color:#A7D0FF;
  color:#FFFFFF;
}
html[data-theme="dark"] .poll-option-text {
  color:inherit;
}
html[data-theme="dark"] .poll-option-count {
  color:#C4D5E9;
}
html[data-theme="dark"] .poll-footer,
html[data-theme="dark"] .poll-footer strong {
  color:#B7C8DC;
}
html[data-theme="dark"] .poll-submit-vote {
  background:#3478C9;
  color:#FFFFFF;
  border:1px solid rgba(160,202,255,.22);
  box-shadow:none;
}
html[data-theme="dark"] .poll-submit-vote:hover:not(:disabled) {
  background:#4088DA;
  filter:none;
}
html[data-theme="dark"] .poll-submit-vote:disabled {
  background:#203A59;
  color:#A9BDD5;
  border-color:rgba(151,190,238,.14);
  opacity:.82;
}

/* Outgoing poll: avoid a dark rectangle sitting inside the blue outgoing
   bubble. Use translucent navy controls so the poll feels like one message. */
html[data-theme="dark"] .message-row.mine .poll-card {
  background:transparent;
  color:#FFFFFF;
}
html[data-theme="dark"] .message-row.mine .poll-question {
  color:#FFFFFF;
}
html[data-theme="dark"] .message-row.mine .poll-option {
  background:rgba(8,27,52,.46);
  color:#F7FBFF;
  border-color:rgba(208,230,255,.30);
}
html[data-theme="dark"] .message-row.mine .poll-option:hover:not(:disabled) {
  background:rgba(10,39,73,.58);
  border-color:rgba(218,237,255,.62);
}
html[data-theme="dark"] .message-row.mine .poll-option.selected {
  background:rgba(9,45,88,.68);
  color:#FFFFFF;
  border-color:#A7D0FF;
}
html[data-theme="dark"] .message-row.mine .poll-option-progress {
  background:rgba(137,190,255,.15);
}
html[data-theme="dark"] .message-row.mine .poll-option.selected .poll-option-progress {
  background:rgba(157,205,255,.20);
}
html[data-theme="dark"] .message-row.mine .poll-option-check {
  background:rgba(6,24,47,.60);
  border-color:rgba(218,237,255,.66);
  color:#FFFFFF;
}
html[data-theme="dark"] .message-row.mine .poll-option.selected .poll-option-check {
  background:#4B93E7;
  border-color:#C5E1FF;
}
html[data-theme="dark"] .message-row.mine .poll-option-count {
  color:#DCEBFC;
}
html[data-theme="dark"] .message-row.mine .poll-footer,
html[data-theme="dark"] .message-row.mine .poll-footer strong {
  color:rgba(245,250,255,.82);
}
html[data-theme="dark"] .message-row.mine .poll-submit-vote {
  background:rgba(7,37,75,.62);
  color:#FFFFFF;
  border-color:rgba(215,236,255,.28);
}
html[data-theme="dark"] .message-row.mine .poll-submit-vote:hover:not(:disabled) {
  background:rgba(8,49,96,.78);
}
html[data-theme="dark"] .message-row.mine .poll-submit-vote:disabled {
  background:rgba(8,31,58,.44);
  color:rgba(238,247,255,.68);
  border-color:rgba(215,236,255,.16);
  opacity:1;
}


/* v0.7.1-rc1-theme-fix5 — reaction chips in dark theme */
html[data-theme="dark"] .message-reaction-chip {
  background:rgba(16,27,45,.88);
  border-color:rgba(145,175,216,.22);
  color:#DCE6F4;
  box-shadow:none;
}
html[data-theme="dark"] .message-reaction-chip:hover {
  background:#223553;
  border-color:rgba(145,175,216,.36);
  color:#F3F7FD;
}
html[data-theme="dark"] .message-reaction-chip.mine {
  background:rgba(91,140,255,.22);
  border-color:rgba(126,171,255,.42);
  color:#EAF2FF;
}
html[data-theme="dark"] .message-row.mine .message-reaction-chip {
  background:rgba(7,16,31,.42);
  border-color:rgba(255,255,255,.14);
  color:#F5F8FF;
}
html[data-theme="dark"] .message-row.mine .message-reaction-chip:hover {
  background:rgba(7,16,31,.56);
  border-color:rgba(255,255,255,.22);
}
html[data-theme="dark"] .message-row.mine .message-reaction-chip.mine {
  background:rgba(255,255,255,.18);
  border-color:rgba(188,216,255,.40);
  color:#FFFFFF;
}

/* 0.7.1 fix2: safer contact actions */
.contact-actions{position:relative;align-self:center;flex:0 0 auto}.contact-menu-trigger{width:34px;height:34px;display:grid;place-items:center;border:0;border-radius:10px;background:transparent;color:#66788d;cursor:pointer}.contact-menu-trigger:hover{background:#eef5fc;color:#176bcb}.contact-menu-trigger .ui-icon{width:18px;height:18px}.contact-action-menu{position:absolute;z-index:80;right:0;top:38px;min-width:190px;padding:6px;background:#fff;border:1px solid #dce6f0;border-radius:12px;box-shadow:0 10px 28px rgba(32,55,80,.16)}.contact-action-menu.hidden{display:none}.contact-action-menu button{width:100%;display:flex;align-items:center;gap:9px;padding:9px 10px;border:0;border-radius:8px;background:transparent;text-align:left;cursor:pointer}.contact-action-menu button.danger{color:#d84a4a}.contact-action-menu button.danger:hover{background:#fff2f2}.contact-action-menu .ui-icon{width:16px;height:16px}html[data-theme="dark"] .contact-menu-trigger{color:#aebed1}html[data-theme="dark"] .contact-menu-trigger:hover{background:#243447;color:#d9eaff}html[data-theme="dark"] .contact-action-menu{background:#172331;border-color:#30445a;box-shadow:0 12px 30px rgba(0,0,0,.35)}html[data-theme="dark"] .contact-action-menu button.danger{color:#ffadb9}html[data-theme="dark"] .contact-action-menu button.danger:hover{background:#3b2532}

/* Cross-platform MediaAliasesGroupInfo3 — mobile visual viewport, docked emoji picker and message-info layout. */
.messenger {
  height:var(--gaigram-visual-viewport-height, 100dvh);
}

#message-info-modal {
  display:flex;
  flex-direction:column;
}
#message-info-modal.hidden { display:none; }
#message-info-modal > header {
  flex:0 0 auto;
  height:auto;
  min-height:70px;
  padding:10px 18px;
  gap:12px;
}
#message-info-modal > header > div:first-child {
  min-width:0;
  flex:1 1 auto;
}
#message-info-title {
  font-size:20px;
  line-height:1.18;
  letter-spacing:-.02em;
  overflow-wrap:anywhere;
}
#message-info-modal .message-info-body {
  flex:1 1 auto;
  min-height:0;
  max-height:none;
  overflow:auto;
}

@media (max-width:760px) {
  .messenger {
    height:var(--gaigram-visual-viewport-height, 100dvh);
  }

  .composer.emoji-open .emoji-picker {
    position:relative !important;
    z-index:5;
    left:auto !important;
    right:auto !important;
    bottom:auto !important;
    width:100% !important;
    max-width:none;
    grid-column:1 / -1;
    margin:2px 0 0;
    transform:none;
    transform-origin:center top;
    box-shadow:0 10px 28px rgba(7,17,31,.12);
  }
  .composer.emoji-open .emoji-grid {
    max-height:256px;
  }

  #message-info-modal {
    width:calc(100% - 20px);
    max-height:calc(var(--gaigram-visual-viewport-height, 100dvh) - 20px);
    top:var(--gaigram-visual-viewport-center-y, 50%);
  }
  #message-info-modal > header {
    min-height:76px;
    padding:10px 14px;
    align-items:center;
  }
  #message-info-modal > header .icon-button {
    flex:0 0 auto;
    align-self:center;
  }
  #message-info-title {
    font-size:19px;
    line-height:1.18;
  }
  #message-info-modal .message-info-summary {
    margin-top:3px;
    line-height:1.3;
  }
  #message-info-modal .message-info-body {
    padding:14px;
    padding-bottom:calc(14px + env(safe-area-inset-bottom));
  }
  #message-info-modal .message-info-list {
    gap:13px;
  }
  #message-info-modal .message-receipt-row {
    padding:9px;
    gap:9px;
  }
}


/* Contact alias dialog — Gaigram-native replacement for browser prompt. */
.contact-alias-modal { width:min(460px,calc(100% - 28px)); }
.contact-alias-form { display:grid; gap:18px; padding:18px; }
.contact-alias-fields { display:grid; gap:7px; }
.contact-alias-fields > label { font-size:13px; font-weight:700; }
.contact-alias-fields .field-hint { margin:0; font-size:12px; line-height:1.45; }
.contact-alias-actions { display:flex; justify-content:flex-end; gap:10px; }
.contact-alias-actions .primary,
.contact-alias-actions .secondary { min-width:112px; }
.contact-alias-modal .icon-button svg { width:18px; height:18px; }

@media (max-width: 700px) {
  .contact-alias-modal { width:100%; }
  .contact-alias-form { padding:16px 16px calc(16px + env(safe-area-inset-bottom)); }
  .contact-alias-actions { display:grid; grid-template-columns:1fr 1fr; }
  .contact-alias-actions .primary,
  .contact-alias-actions .secondary { width:100%; min-width:0; }
}

html[data-theme="dark"] .contact-alias-modal .field-hint { color:#91A0B8; }


/* Cross-platform MediaAliasesGroupInfo5 — iPhone modal centering + zoom/viewport hardening. */
@media (max-width:760px) {
  .contact-alias-modal {
    display:flex;
    flex-direction:column;
    width:min(460px,calc(100% - 28px));
    max-height:min(640px,calc(var(--gaigram-visual-viewport-height, 100dvh) - 20px));
    left:50%;
    right:auto;
    top:var(--gaigram-visual-viewport-center-y, 50%);
    bottom:auto;
    transform:translate(-50%,-50%);
    border-radius:22px;
  }
  .contact-alias-modal > header { flex:0 0 auto; }
  .contact-alias-modal .contact-alias-form {
    min-height:0;
    overflow:auto;
    -webkit-overflow-scrolling:touch;
  }
}

/* Cross-platform MediaAliasesGroupInfo6 — remove duplicate iPhone safe-area gap while keyboard is visible. */
@media (max-width:760px) {
  html[data-gaigram-keyboard-open="1"] .composer {
    padding-bottom:8px;
  }
}


/* Cross-platform MediaAliasesGroupInfo10-fix3 — split Profile and Settings surfaces. */
.owner-management-entry > h3 { margin-top:2px; }

/* Cross-platform MediaAliasesGroupInfo10 — compact sidebar menu, storage controls, mobile Group Info polish. */
/* Cross-platform MediaAliasesGroupInfo10-fix2 — keep the header-owned overflow menu above the following search stacking layer. */
.sidebar-header { position:relative; z-index:40; overflow:visible; }

.sidebar-actions-wrap { position:relative; flex:0 0 auto; }
.sidebar-actions-menu {
  position:absolute; z-index:90; right:0; top:44px; min-width:214px; padding:7px;
  border:1px solid rgba(159,176,197,.38); border-radius:14px; background:#fff;
  box-shadow:0 14px 38px rgba(32,55,80,.18);
}
.sidebar-actions-menu.hidden { display:none; }
.sidebar-actions-menu button {
  width:100%; border:0; border-radius:9px; padding:10px 11px; background:transparent;
  color:#20364D; text-align:left; font:inherit; font-size:13px; font-weight:650; cursor:pointer;
}
.sidebar-actions-menu button:hover,
.sidebar-actions-menu button:focus-visible { background:#EEF6FF; color:#176BCB; outline:none; }
.sidebar-actions-menu button.danger { color:#D54858; }
.sidebar-actions-menu button.danger:hover { background:#FFF1F3; color:#C63A4B; }
.sidebar-actions-separator { height:1px; margin:5px 4px; background:#E5EDF5; }

#data-storage-modal { display:flex; flex-direction:column; }
#data-storage-modal.hidden { display:none; }
#data-storage-modal .data-storage-body { display:grid; gap:14px; overflow:auto; }
.storage-settings-card { padding:15px; border:1px solid rgba(159,176,197,.30); border-radius:16px; background:#FAFCFF; }
.storage-card-heading { display:flex; justify-content:space-between; align-items:flex-start; gap:12px; }
.storage-card-heading > div { display:grid; gap:4px; min-width:0; }
.storage-card-heading h3 { margin:0; font-size:15px; }
.storage-card-heading .muted { font-size:12px; line-height:1.35; }
.storage-limit-pill { flex:0 0 auto; padding:5px 8px; border-radius:999px; background:#EAF4FF; color:#246FCB; font-size:11px; font-weight:750; }
.storage-meter { height:8px; margin:13px 0 10px; overflow:hidden; border-radius:999px; background:#E6EDF5; }
.storage-meter > i { display:block; width:0; height:100%; border-radius:inherit; background:linear-gradient(90deg,#2F80ED,#56A8FF); transition:width .18s ease; }
.storage-note { margin:0 0 13px; color:#70849B; font-size:12px; line-height:1.45; }
.storage-clear-button { width:100%; }
.storage-choice-list { display:grid; gap:8px; margin-top:12px; }
.storage-choice { display:grid; grid-template-columns:auto minmax(0,1fr); gap:10px; align-items:flex-start; padding:11px; border:1px solid rgba(159,176,197,.28); border-radius:13px; background:#fff; cursor:pointer; }
.storage-choice:has(input:checked) { border-color:rgba(47,128,237,.42); background:#F1F7FF; box-shadow:0 0 0 2px rgba(47,128,237,.07); }
.storage-choice input { margin-top:3px; accent-color:#2F80ED; }
.storage-choice > span { display:grid; gap:3px; }
.storage-choice strong { color:#18314B; font-size:13px; }
.storage-choice small { color:#74889E; font-size:11px; line-height:1.4; }

.group-member-row { grid-template-columns:44px minmax(0,1fr) auto; }
.group-member-side { display:flex; align-items:center; justify-content:flex-end; gap:7px; min-width:0; }
.group-member-actions:empty { display:none; }

@media (max-width:760px) {
  .sidebar-actions-menu { right:-2px; top:42px; min-width:205px; max-width:calc(100vw - 28px); }
  #data-storage-modal { width:calc(100% - 20px); max-height:calc(var(--gaigram-visual-viewport-height,100dvh) - 20px); left:50%; right:auto; top:var(--gaigram-visual-viewport-center-y,50%); bottom:auto; transform:translate(-50%,-50%); border-radius:22px; }
  #data-storage-modal .data-storage-body { padding:14px; padding-bottom:calc(14px + env(safe-area-inset-bottom)); }
  .storage-card-heading { align-items:center; }
  .group-member-row { grid-template-columns:42px minmax(0,1fr) minmax(108px,auto); gap:9px; align-items:center; }
  .group-member-side { display:grid; justify-items:end; align-content:center; gap:5px; }
  .group-member-actions { grid-column:auto; justify-content:flex-end; gap:4px; }
  .group-member-action { padding:6px 8px; font-size:10.5px; }
  .contact-menu-trigger.group-member-menu-trigger { width:30px; height:30px; border-radius:9px; }
  .group-role-badge { justify-self:end; font-size:10px; padding:4px 7px; }
}

html[data-theme="dark"] .sidebar-actions-menu { background:#172331; border-color:#30445A; box-shadow:0 14px 38px rgba(0,0,0,.38); }
html[data-theme="dark"] .sidebar-actions-menu button { color:#D8E6F7; }
html[data-theme="dark"] .sidebar-actions-menu button:hover,
html[data-theme="dark"] .sidebar-actions-menu button:focus-visible { background:#243E5B; color:#B9D8FF; }
html[data-theme="dark"] .sidebar-actions-menu button.danger { color:#FFADB9; }
html[data-theme="dark"] .sidebar-actions-menu button.danger:hover { background:#3B2532; }
html[data-theme="dark"] .sidebar-actions-separator { background:#30445A; }
html[data-theme="dark"] .storage-settings-card { background:#121F33; border-color:rgba(255,255,255,.09); }
html[data-theme="dark"] .storage-limit-pill { background:#152A46; color:#9CC0FF; }
html[data-theme="dark"] .storage-meter { background:#223249; }
html[data-theme="dark"] .storage-note,
html[data-theme="dark"] .storage-card-heading .muted { color:#91A0B8; }
html[data-theme="dark"] .storage-choice { background:#101B2D; border-color:rgba(255,255,255,.09); }
html[data-theme="dark"] .storage-choice:has(input:checked) { background:#142A46; border-color:rgba(91,140,255,.35); box-shadow:0 0 0 2px rgba(91,140,255,.08); }
html[data-theme="dark"] .storage-choice strong { color:#F5F7FB; }
html[data-theme="dark"] .storage-choice small { color:#91A0B8; }

/* Cross-platform MediaAliasesGroupInfo10-fix4 — iPhone sheet alignment + contact action polish. */
@media (max-width:760px) {
  /* Desktop width rules (.modal.compact / .chat-content-modal) have higher/later
     specificity than the generic mobile bottom-sheet width. Reassert the intended
     full-width mobile sheet for the three affected surfaces so no one-sided gutter remains. */
  #chat-content-modal,
  #chat-wallpaper-modal,
  #group-modal {
    width:100%;
    max-width:none;
    left:0;
    right:0;
  }

  /* Keep long chat names on one clean header line instead of making the media
     sheet title wrap while the close action remains on the first row. */
  #chat-content-modal > header { gap:10px; }
  #chat-content-title {
    flex:1 1 auto;
    min-width:0;
    font-size:20px;
    line-height:1.2;
    white-space:nowrap;
    overflow:hidden;
    text-overflow:ellipsis;
  }
  #chat-content-modal > header .icon-button { flex:0 0 auto; }

  /* Destructive contact action stays red but no longer inherits the global
     bold .danger button typography; preserve the full touch target. */
  .contact-action-menu button.danger {
    font-size:14px;
    font-weight:500;
    white-space:nowrap;
  }
}

/* Cross-platform MediaAliasesGroupInfo10-fix6 — iPhone reaction/image overlay alignment. */
@media (max-width:760px) {
  /* message-info-modal is also reused for reaction details. The generic mobile
     bottom-sheet rule leaves left/right/bottom/transform behind; restore the
     intended centered visual-viewport dialog geometry explicitly. */
  #message-info-modal {
    left:50%;
    right:auto;
    bottom:auto;
    transform:translate(-50%,-50%);
    border-radius:22px;
  }

  /* Keep the image inside the viewer's padded grid cell instead of sizing it
     against 96vw, which can be wider than that cell on narrow iPhone screens
     and produces a one-sided horizontal overflow. */
  .image-viewer {
    grid-template-columns:minmax(0,1fr);
    grid-template-rows:minmax(0,1fr);
  }
  .image-viewer img {
    width:auto;
    height:auto;
    max-width:100%;
    justify-self:center;
    align-self:center;
    margin-inline:auto;
  }
}

/* Unified archive and viewer UI: encrypted media is decrypted only on-device. */
.group-archive-notice { padding:12px 16px calc(12px + env(safe-area-inset-bottom)); text-align:center; color:var(--muted); background:var(--surface-2); border-top:1px solid var(--line); font-size:13px; }
.archived-readonly .message-actions, .archived-readonly .message-quick-reactions, .archived-readonly #poll-button { display:none !important; }
.video-expand { display:block; width:max-content; max-width:100%; margin:6px 8px 8px auto; padding:6px 12px; border:1px solid var(--line); border-radius:999px; background:var(--surface-2); color:var(--text); font-size:12px; cursor:pointer; }
.video-expand:hover, .video-expand:focus-visible { border-color:var(--accent); }
.image-viewer video { display:block; max-width:min(96vw,1400px); max-height:calc(100dvh - 105px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); object-fit:contain; border-radius:12px; background:#020712; }
.image-viewer video.hidden { display:none; }
.image-viewer img.hidden { display:none; }
.image-viewer-close { top:max(18px,env(safe-area-inset-top)); }
.image-viewer-download { bottom:max(18px,env(safe-area-inset-bottom)); }

/* Unified fix4 visual states */
.message-mention.mention-link { text-decoration:none; }
.message-mention.mention-link:hover,.message-mention.mention-link:focus-visible { text-decoration:none; box-shadow:0 2px 0 currentColor; }
.receipt.unknown { color:var(--muted); }
.chat-video-preview { position:relative; display:block; width:100%; overflow:hidden; border-radius:12px; background:#07111f; }
.chat-video-preview video { display:block; width:100%; max-height:min(420px,46dvh); pointer-events:none; }
.video-play-overlay { position:absolute; inset:0; display:grid; place-items:center; width:100%; height:100%; border:0; background:transparent; color:#fff; font-size:32px; cursor:pointer; text-shadow:0 2px 8px #07111f; }
.video-play-overlay::first-letter { background:rgba(8,17,31,.66); }
.group-member-action-menu.group-member-portal { position:fixed; z-index:2147480000; max-height:calc(100dvh - 24px); overflow-y:auto; overscroll-behavior:contain; }
#gaigram-action-dialog { width:min(430px,calc(100vw - 30px)); max-width:100%; border:1px solid var(--line); border-radius:18px; background:var(--surface); color:var(--text); padding:22px; box-shadow:var(--shadow); }
#gaigram-action-dialog::backdrop { background:rgba(7,17,31,.6); }
#gaigram-action-dialog h2 { font-size:18px; margin:0 0 12px; }
#gaigram-action-dialog p { margin:0; white-space:pre-wrap; line-height:1.5; }
#gaigram-action-dialog input { margin-top:16px; width:100%; padding:10px 12px; color:var(--text); background:var(--surface-2); border:1px solid var(--line); border-radius:10px; }
#gaigram-action-dialog footer { display:flex; gap:10px; justify-content:flex-end; margin-top:22px; }
#gaigram-action-dialog footer button { min-height:40px; padding:9px 14px; border-radius:10px; border:1px solid var(--line); color:var(--text); background:var(--surface-2); cursor:pointer; }
#gaigram-action-dialog footer [data-dialog-accept] { color:#fff; background:var(--accent); border-color:var(--accent); }
#gaigram-action-dialog footer [data-dialog-accept].danger { background:var(--danger); border-color:var(--danger); }


/* Unified fix4 Web fix1: archived PWA safe-bottom, honest receipt/forward labels. */
.chat-receipt.unknown { color:var(--muted); letter-spacing:0; }
.forwarded-label { flex-wrap:wrap; align-items:baseline; overflow-wrap:anywhere; }
.forwarded-label .forwarded-attribution-note { opacity:.7; font-size:11px; cursor:help; }
/* An archived chat has no composer: leave a comfortable safe-area inset and
   keep the final bubble clear of rounded corners/home-indicator in iOS PWA. */
.archived-readonly .message-list {
  padding-bottom:max(44px, calc(24px + env(safe-area-inset-bottom, 0px)));
  scroll-padding-bottom:max(44px, calc(24px + env(safe-area-inset-bottom, 0px)));
}
.archived-readonly .group-archive-notice {
  flex-shrink:0;
  padding-bottom:max(16px, calc(10px + env(safe-area-inset-bottom, 0px)));
}
@media (max-width:760px) {
  .archived-readonly .message-list {
    padding-bottom:max(62px, calc(30px + env(safe-area-inset-bottom, 0px)));
    scroll-padding-bottom:max(62px, calc(30px + env(safe-area-inset-bottom, 0px)));
  }
}

/* NUMERUS TEAM G14 / STAGE 1 — scoped dark design tokens.
   Light and System selection behavior is unchanged. No storage, crypto or PWA identity edits. */
html[data-theme="dark"] {
  --nt-bg:#0A1018;
  --nt-surface:#0F151D;
  --nt-surface-alt:#10212A;
  --nt-text:#F5F8FB;
  --nt-muted:#9FB4C5;
  --nt-accent:#2CCEE8;
  --nt-accent-bright:#41E2EF;
  --nt-border:#28343E;
  --bg:var(--nt-bg); --surface:var(--nt-surface); --surface-2:var(--nt-surface-alt);
  --text:var(--nt-text); --muted:var(--nt-muted); --accent:var(--nt-accent);
  --accent-2:var(--nt-accent-bright); --line:var(--nt-border);
}
html[data-theme="dark"] body,
html[data-theme="dark"] .app-root,
html[data-theme="dark"] .messenger { background:var(--nt-bg); color:var(--nt-text); }
html[data-theme="dark"] .sidebar,
html[data-theme="dark"] .sidebar-header,
html[data-theme="dark"] .chat-header { background:var(--nt-surface); border-color:var(--nt-border); }
html[data-theme="dark"] .auth-hero { background:linear-gradient(145deg,#0A1018,#10212A); }
html[data-theme="dark"] .auth-card,
html[data-theme="dark"] .auth-card-wrap .auth-card { background:var(--nt-surface); border-color:var(--nt-border); }
html[data-theme="dark"] .chat-item.active,
html[data-theme="dark"] .chat-item:hover { background:rgba(44,206,232,.12); }
html[data-theme="dark"] .sidebar-tab.active { color:var(--nt-accent-bright); background:rgba(44,206,232,.1); }
html[data-theme="dark"] .chat-panel,
html[data-theme="dark"] .messenger .chat-panel { background:var(--nt-bg); }
html[data-theme="dark"] .primary { background:linear-gradient(135deg,var(--nt-accent),#159BC4); color:#071521; }
html[data-theme="dark"] :is(input,textarea,select):focus { border-color:var(--nt-accent); }
