:root { color-scheme:light; --page:#f4f4f6; --panel:#fff; --soft:#ececf0; --hover:#f0f0f3; --active:#315ff4; --text:#202124; --muted:#73757b; --line:#e3e3e7; --incoming:#e9e9ec; --outgoing:#315ff4; --danger:#d44b4b; --shadow:none; }
[data-theme="dark"] { color-scheme:dark; --page:#1b1c1f; --panel:#25272e; --soft:#333438; --hover:#303137; --active:#315ff4; --text:#f4f4f6; --muted:#a8a9af; --line:#34363d; --incoming:#303033; --outgoing:#315ff4; --danger:#ff6b6b; --shadow:none; }
* { box-sizing:border-box; }
html,body { height:100%; }
body { margin:0; overflow:hidden; background:var(--page); color:var(--text); font:15px/1.4 -apple-system,BlinkMacSystemFont,"Segoe UI",Inter,sans-serif; touch-action:manipulation; }
button,input,textarea { font:inherit; } button { color:inherit; }
.hidden { display:none !important; }
.sr-only { position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; border:0; }
.gate { min-height:100%; display:grid; place-items:center; padding:20px; background:var(--page); }
.gate-card { width:min(100%,360px); display:flex; flex-direction:column; gap:14px; padding:32px; border-radius:14px; background:var(--panel); box-shadow:0 12px 40px rgb(0 0 0 / 14%); }
.gate-card .brand-mark { width:54px; height:54px; margin:0 auto 4px; font-size:1.25rem; }
.gate-card h1 { margin:0; text-align:center; font-size:1.55rem; }.gate-card>p { margin:-6px 0 8px; color:var(--muted); text-align:center; }
.gate-card label { display:flex; flex-direction:column; gap:6px; color:var(--muted); font-size:.82rem; }.gate-card input { width:100%; padding:12px; border:1px solid var(--line); border-radius:9px; outline:0; background:var(--panel); color:var(--text); }
.gate-card input:focus { border-color:#3390ec; box-shadow:0 0 0 2px rgb(51 144 236 / 16%); }.gate-card .remember { flex-direction:row; align-items:center; }.gate-card .remember input { width:17px; height:17px; }
.primary-button { min-height:44px; border:0; border-radius:9px; background:#3390ec; color:#fff; font-weight:650; cursor:pointer; }.primary-button:disabled { opacity:.55; }.form-error { min-height:20px; margin:0!important; color:var(--danger)!important; font-size:.82rem; text-align:center; }
.app-shell { display:grid; grid-template-columns:330px minmax(0,1fr); width:min(100%,1500px); height:100dvh; margin:0 auto; background:var(--panel); }
.sidebar { min-width:0; display:grid; grid-template-rows:56px 50px 1fr 58px; border-right:1px solid var(--line); background:var(--panel); }
.brand-row,.chat-header,.profile-chip { display:flex; align-items:center; gap:11px; padding:8px 12px; }.brand-row { justify-content:space-between; }.brand { display:flex; align-items:center; gap:9px; font-size:1.05rem; font-weight:700; }
.brand-mark { display:grid; place-items:center; width:36px; height:36px; border-radius:50%; background:#315ff4; color:#fff; font-weight:750; }
.icon-button { display:grid; place-items:center; min-width:38px; height:38px; padding:0 9px; border:0; border-radius:50%; background:transparent; color:var(--muted); cursor:pointer; }.icon-button:hover { background:var(--hover); color:var(--text); }.icon-button svg,.search svg,.composer-tool svg,.send-button svg { width:20px; height:20px; fill:none; stroke:currentColor; stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round; }
.text-button { padding:7px 9px; border:0; border-radius:8px; background:transparent; color:var(--muted); cursor:pointer; }
.search { display:flex; align-items:center; height:38px; margin:4px 10px 8px; border-radius:20px; background:var(--soft); }.search:focus-within { box-shadow:inset 0 0 0 2px #3390ec; background:var(--panel); }
.search input { min-width:0; flex:1; padding:8px 4px 8px 15px; border:0; outline:0; background:transparent; color:var(--text); }.search button { display:grid; width:42px; height:38px; place-items:center; border:0; background:transparent; color:var(--muted); cursor:pointer; }.search svg { width:17px; height:17px; }
.conversation-list { overflow-y:auto; padding:2px 7px 8px; scrollbar-width:thin; }.conversation { width:100%; display:grid; grid-template-columns:48px minmax(0,1fr) auto; align-items:center; gap:10px; padding:8px; border:0; border-radius:10px; background:transparent; text-align:left; cursor:pointer; }
.conversation:hover { background:var(--hover); }.conversation.active { background:var(--active); color:#fff; }
.avatar { display:grid; place-items:center; width:44px; height:44px; flex:0 0 auto; border-radius:50%; background:#607d9b; color:#fff; font-weight:700; }.conversation:nth-child(3n+2) .avatar { background:#a66c97; }.conversation:nth-child(3n+3) .avatar { background:#5b9279; }.avatar.small { width:38px; height:38px; }
.conversation-copy,.conversation-meta,.profile-chip>span:not(.avatar),.chat-person { display:flex; min-width:0; flex-direction:column; }.conversation-copy strong { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-weight:650; }.conversation-copy small { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; color:var(--muted); }.conversation.active .conversation-copy small,.conversation.active .conversation-meta { color:rgb(255 255 255 / 75%); }
.conversation-meta { align-self:start; padding-top:2px; color:var(--muted); font-size:.72rem; }.profile-chip { border-top:1px solid var(--line); }.profile-chip>span:not(.avatar) { flex:1; }.profile-chip strong { font-size:.9rem; }.profile-chip small { color:var(--muted); font-size:.75rem; }
.chat { min-width:0; display:grid; grid-template-rows:68px minmax(0,1fr) auto; background:var(--page); }.chat-header { z-index:1; padding:10px 18px; border-bottom:1px solid var(--line); background:var(--panel); }.chat-person { flex:1; }.chat-person strong { font-size:1.05rem; font-weight:500; }.chat-person small { color:var(--muted); font-size:.8rem; }
.messages { display:flex; flex-direction:column; gap:14px; overflow-y:auto; padding:24px max(18px,calc((100% - 780px)/2)); scrollbar-width:thin; }.message { position:relative; width:fit-content; max-width:min(78%,590px); padding:10px 13px 7px; border-radius:18px 18px 18px 5px; background:var(--incoming); }.message.outgoing { align-self:flex-end; border-radius:18px 18px 5px 18px; background:var(--outgoing); color:#fff; }.message p { margin:0; overflow-wrap:anywhere; white-space:pre-wrap; font-size:1.05rem; line-height:1.3; }.message time { display:block; margin:4px 0 0 18px; color:var(--muted); font-size:.72rem; text-align:right; }.message.outgoing time,.message.outgoing .reply-label { color:rgb(255 255 255 / 70%); }.reply-label { display:block; margin-bottom:4px; padding-left:7px; border-left:2px solid #819cff; color:var(--muted); font-size:.75rem; }.message.deleted p { color:var(--muted); font-style:italic; }.message-actions { position:absolute; top:-29px; right:0; display:none; gap:2px; padding:3px; border-radius:12px; background:var(--panel); box-shadow:0 4px 18px rgb(0 0 0 / 28%); }.message:hover .message-actions,.message:focus-within .message-actions { display:flex; }.message-actions button { min-width:29px; height:24px; padding:0 6px; border:0; border-radius:8px; background:transparent; color:var(--muted); font-size:.72rem; cursor:pointer; }.message-actions button:hover { background:var(--soft); color:var(--text); }
.composer { display:flex; align-items:center; gap:4px; width:min(calc(100% - 28px),760px); min-height:52px; margin:0 auto max(14px,env(safe-area-inset-bottom)); padding:6px 7px 6px 14px; border-radius:28px; background:var(--incoming); }.composer textarea { min-width:0; max-height:128px; flex:1; resize:none; border:0; outline:0; padding:8px 2px; background:transparent; color:var(--text); font-size:1rem; line-height:1.35; }.send-button,.attach-button { display:grid; place-items:center; width:42px; height:42px; flex:0 0 auto; border:0; border-radius:50%; background:#315ff4; color:#fff; cursor:pointer; }.send-button:disabled { display:none; }.composer:has(.send-button:not(:disabled)) .attach-button { display:none; }.expiry-select { width:34px; height:32px; padding:0; border:0; outline:0; background:transparent; color:var(--muted); font-size:.72rem; text-align:center; }.reply-cancel,.composer-tool { display:grid; place-items:center; width:34px; height:34px; flex:0 0 auto; border:0; border-radius:50%; background:transparent; color:var(--muted); cursor:pointer; }.reply-cancel { border-radius:0; border-right:2px solid #315ff4; }.composer-tool:hover { background:var(--soft); color:var(--text); }.composer-tool.recording { background:#e05252; color:#fff; animation:pulse 1s infinite; }
.message-image { display:block; width:min(320px,65vw); max-height:360px; object-fit:cover; border-radius:8px; }.file-card { display:flex; align-items:center; gap:9px; min-width:190px; color:inherit; text-decoration:none; }.file-icon { display:grid; place-items:center; width:38px; height:38px; border-radius:50%; background:#3390ec; color:#fff; font-size:.72rem; }.file-copy { display:flex; min-width:0; flex-direction:column; }.file-copy strong { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }.file-copy small { color:var(--muted); }.voice-player { width:min(290px,65vw); height:36px; }.uploading { opacity:.55; pointer-events:none; }
@keyframes pulse { 50% { transform:scale(.88); } }
.empty-copy { margin:28px 14px; color:var(--muted); font-size:.86rem; text-align:center; }.centered { margin:auto; padding:8px 12px; border-radius:14px; background:rgb(0 0 0 / 18%); color:#fff; }.mobile-only { display:none; }
dialog { width:min(430px,calc(100% - 24px)); padding:0; border:0; border-radius:14px; background:var(--panel); color:var(--text); box-shadow:0 18px 60px rgb(0 0 0 / 28%); } dialog::backdrop { background:rgb(0 0 0 / 48%); backdrop-filter:blur(2px); }.dialog-card { padding:18px; }.dialog-title { display:flex; align-items:center; justify-content:space-between; }.dialog-title h2 { margin:0; font-size:1.15rem; }.dialog-card section { margin-top:20px; }.dialog-card h3 { margin:0 0 6px; color:var(--muted); font-size:.72rem; letter-spacing:.05em; text-transform:uppercase; }
.setting-row { display:flex; width:100%; align-items:center; justify-content:space-between; gap:14px; padding:11px 2px; }.setting-row span { display:flex; flex-direction:column; text-align:left; }.setting-row small { color:var(--muted); font-size:.75rem; }.button-row { border:0; background:none; cursor:pointer; }.invite-result { display:flex; gap:7px; }.invite-result input { min-width:0; flex:1; padding:9px; border:1px solid var(--line); border-radius:8px; background:var(--soft); color:var(--text); }.invite-result button,.danger-button { padding:9px 12px; border:0; border-radius:8px; background:var(--soft); color:var(--text); cursor:pointer; }.danger-button { width:100%; margin-top:18px; color:var(--danger); }
.toast { position:fixed; z-index:10; left:50%; bottom:24px; translate:-50% 12px; padding:9px 14px; border-radius:18px; background:rgb(0 0 0 / 78%); color:#fff; opacity:0; pointer-events:none; transition:.18s ease; }.toast.show { translate:-50% 0; opacity:1; }
@media (max-width:720px) { body { background:var(--panel); }.app-shell { grid-template-columns:1fr; width:100%; }.sidebar { display:grid; height:100dvh; border:0; }.chat { display:none; height:100dvh; }.app-shell.chat-open .sidebar { display:none; }.app-shell.chat-open .chat { display:grid; }.mobile-only { display:grid; }.messages { padding:14px 9px 18px; }.message { max-width:84%; }.composer { width:calc(100% - 12px); margin-bottom:max(6px,env(safe-area-inset-bottom)); }.gate-card input,.search input,.composer textarea { font-size:16px; } }
@media (prefers-reduced-motion:reduce) { *,*::before,*::after { scroll-behavior:auto!important; transition:none!important; } }

/* Compact, touch-stable layout */
body { font-size:14px; line-height:1.38; overscroll-behavior:none; }
.app-shell { grid-template-columns:300px minmax(0,1fr); max-width:1440px; }
.sidebar { grid-template-rows:50px 44px 1fr 52px; }
.avatar { width:39px; height:39px; }.avatar.small { width:34px; height:34px; }
.chat { grid-template-rows:58px minmax(0,1fr) auto; }.chat-header { padding:8px 14px; }.chat-person strong { font-size:1rem; }.chat-person small { font-size:.76rem; }
.messages { gap:10px; padding:18px max(14px,calc((100% - 720px)/2)); }.message { max-width:min(76%,540px); padding:8px 11px 6px; border-radius:16px 16px 16px 5px; }.message.outgoing { border-radius:16px 16px 5px 16px; }.message p { font-size:.96rem; line-height:1.28; }
.composer { gap:3px; width:min(calc(100% - 20px),700px); min-height:46px; margin-bottom:max(10px,env(safe-area-inset-bottom)); padding:4px 5px 4px 11px; border-radius:24px; }.composer textarea { font-size:.95rem; }.send-button,#attachButton { width:38px; height:38px; background:#315ff4; color:#fff; }.composer-tool { width:31px; height:31px; }.composer-tool svg { width:19px; height:19px; }
@media (max-width:720px) { .app-shell { grid-template-columns:1fr; }.messages { padding:12px 8px 16px; }.message { max-width:86%; }.composer { width:calc(100% - 10px); margin-bottom:max(5px,env(safe-area-inset-bottom)); } }
.message-reactions { position:absolute; right:8px; bottom:-14px; padding:2px 7px; border-radius:10px; background:var(--panel); color:var(--text); font-size:.68rem; box-shadow:0 1px 4px rgb(0 0 0 / 20%); }
.timer-button { position:relative; }.timer-button small { position:absolute; right:-1px; bottom:-1px; min-width:15px; padding:0 3px; border-radius:7px; background:var(--panel); color:var(--text); font-size:.55rem; line-height:12px; }
