:root{
  --bg:#f5f7fb;--surface:#fff;--surface-2:#f7f8fb;--line:#e8ebf1;--line-strong:#dfe3eb;
  --text:#171b24;--muted:#81899a;--muted-2:#a4abba;--primary:#5b6cf9;--primary-2:#7180ff;
  --primary-soft:#eef0ff;--success:#22b573;--danger:#ef5d66;--shadow:0 18px 55px rgba(31,37,52,.12);
  --rail:72px;--sidebar:322px;--details:310px;--radius:18px
}
*{box-sizing:border-box}html,body{width:100%;height:100%;margin:0}body{font-family:Inter,"SF Pro Display","Segoe UI","Microsoft YaHei",system-ui,sans-serif;background:var(--bg);color:var(--text);overflow:hidden;-webkit-font-smoothing:antialiased}
button,input,textarea{font:inherit}button{color:inherit}.hidden{display:none!important}
svg{width:20px;height:20px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
.auth-view{min-height:100vh;display:grid;place-items:center;background:linear-gradient(145deg,#f8f9ff 0%,#f2f5ff 48%,#f8f8fc 100%);position:relative;overflow:hidden;padding:24px}
.auth-glow{position:absolute;border-radius:50%;filter:blur(1px);opacity:.85}.auth-glow-a{width:480px;height:480px;background:radial-gradient(circle,#dce0ff 0%,rgba(220,224,255,0) 70%);top:-170px;left:-140px}.auth-glow-b{width:520px;height:520px;background:radial-gradient(circle,#e8dbff 0%,rgba(232,219,255,0) 70%);bottom:-230px;right:-140px}
.auth-card{width:min(420px,100%);padding:42px 42px 34px;background:rgba(255,255,255,.9);backdrop-filter:blur(26px);border:1px solid rgba(255,255,255,.86);border-radius:28px;box-shadow:0 30px 80px rgba(72,78,120,.16);position:relative;z-index:1}
.brand-mark{border:0;display:grid;place-items:center;background:linear-gradient(145deg,#6878ff,#4d5de9);color:#fff;box-shadow:0 8px 20px rgba(91,108,249,.28);font-weight:800;letter-spacing:-.06em}.brand-mark.large{width:52px;height:52px;border-radius:16px;font-size:23px;margin:0 auto}.auth-heading{text-align:center;margin:18px 0 26px}.auth-heading h1{font-size:28px;letter-spacing:-.04em;margin:0 0 8px}.auth-heading p{margin:0;color:var(--muted);font-size:14px}.auth-tabs{display:grid;grid-template-columns:1fr 1fr;background:#f2f3f7;padding:4px;border-radius:12px;margin-bottom:23px}.auth-tab{border:0;background:transparent;padding:10px;border-radius:9px;color:var(--muted);cursor:pointer;font-weight:650}.auth-tab.active{background:#fff;color:var(--text);box-shadow:0 3px 10px rgba(30,35,50,.08)}
.field-label{display:block;font-size:12px;font-weight:700;color:#666f80;margin:14px 0 7px}.input{width:100%;border:1px solid var(--line-strong);background:#fff;border-radius:12px;padding:12px 14px;outline:none;transition:.18s;color:var(--text)}.input:focus{border-color:#aeb6ff;box-shadow:0 0 0 4px rgba(91,108,249,.09)}textarea.input{resize:vertical}.primary-button,.secondary-button,.danger-button{border:0;border-radius:11px;padding:11px 16px;font-weight:700;cursor:pointer;transition:.18s}.primary-button{background:var(--primary);color:#fff;box-shadow:0 7px 18px rgba(91,108,249,.22)}.primary-button:hover{background:#4f60ee;transform:translateY(-1px)}.secondary-button{background:#f0f2f6;color:#535c6d}.secondary-button:hover{background:#e9ebf1}.danger-button{background:#fff0f1;color:#db4a55}.full-button{width:100%;margin-top:10px}.auth-submit{width:100%;margin-top:22px;padding:13px}.server-settings{margin-top:18px;color:var(--muted);font-size:12px}.server-settings summary{cursor:pointer;text-align:center;user-select:none}.server-settings .field-label{margin-top:12px}.auth-error{min-height:20px;margin-top:14px;text-align:center;color:var(--danger);font-size:13px}
.app-shell{height:100vh;display:grid;grid-template-columns:var(--rail) var(--sidebar) minmax(0,1fr);background:var(--surface)}.nav-rail{background:#f8f9fc;border-right:1px solid var(--line);display:flex;flex-direction:column;align-items:center;padding:14px 0 16px;z-index:20}.nav-brand{width:42px;height:42px;border-radius:13px;font-size:19px;cursor:pointer}.rail-nav{display:flex;flex-direction:column;gap:7px;margin-top:30px}.rail-item{width:44px;height:44px;border:0;border-radius:13px;background:transparent;color:#9299a8;display:grid;place-items:center;cursor:pointer;position:relative;transition:.18s}.rail-item:hover{background:#f0f1f6;color:#687181}.rail-item.active{background:var(--primary-soft);color:var(--primary)}.rail-item svg{width:21px;height:21px}.rail-badge{position:absolute;right:-2px;top:-3px;min-width:17px;height:17px;padding:0 5px;border-radius:9px;background:var(--danger);color:#fff;font-size:10px;font-weight:800;display:flex;align-items:center;justify-content:center;border:2px solid #f8f9fc}.rail-bottom{margin-top:auto}.me-avatar-button{border:0;background:none;padding:0;position:relative;cursor:pointer}.connection-dot{position:absolute;width:11px;height:11px;border-radius:50%;right:0;bottom:0;border:2px solid #f8f9fc}.connection-dot.online{background:var(--success)}.connection-dot.offline{background:#b7bdc8}
.avatar{border-radius:50%;display:grid;place-items:center;background:linear-gradient(145deg,#dde2ff,#bfc8ff);color:#5361c7;font-weight:800;background-position:center;background-size:cover;flex:0 0 auto;overflow:hidden}.avatar-sm{width:38px;height:38px;font-size:13px}.avatar-md{width:44px;height:44px;font-size:15px}.avatar-lg{width:58px;height:58px;font-size:20px}.avatar-xl{width:86px;height:86px;font-size:25px}.avatar.online-ring{box-shadow:0 0 0 3px #fff,0 0 0 5px rgba(34,181,115,.65)}
.sidebar{min-width:0;border-right:1px solid var(--line);background:#fbfcfe;display:flex;flex-direction:column;position:relative;z-index:15}.sidebar-header{height:88px;padding:22px 20px 14px;display:flex;align-items:center;justify-content:space-between}.eyebrow{font-size:10px;letter-spacing:.12em;text-transform:uppercase;color:#a0a6b3;font-weight:800;margin-bottom:3px}.sidebar-header h2{margin:0;font-size:21px;letter-spacing:-.03em}.icon-button{width:38px;height:38px;border:1px solid var(--line);border-radius:11px;background:#fff;display:grid;place-items:center;cursor:pointer;color:#717988;transition:.18s}.icon-button:hover{background:#f4f5f8;color:#424a58;border-color:#dfe3ea}.icon-button.subtle{border-color:transparent;background:transparent}.search-wrap{margin:0 16px 14px;height:42px;border-radius:12px;background:#f0f2f6;display:flex;align-items:center;padding:0 12px;color:#a0a7b4}.search-wrap svg{width:17px;height:17px}.search-wrap input{border:0;background:transparent;outline:0;width:100%;padding:0 9px;color:var(--text);font-size:13px}.sidebar-content{overflow:auto;flex:1;padding:0 10px 12px;scrollbar-width:thin;scrollbar-color:#d9dde5 transparent}.section-label{font-size:11px;color:#a4aab6;font-weight:750;padding:12px 10px 8px;text-transform:uppercase;letter-spacing:.05em}.list-item{display:flex;gap:11px;align-items:center;padding:10px 10px;border-radius:13px;cursor:pointer;position:relative;transition:.15s;min-height:65px}.list-item:hover{background:#f2f4f8}.list-item.active{background:#edf0ff}.list-item-main{min-width:0;flex:1}.list-item-top,.list-item-bottom{display:flex;align-items:center;gap:8px}.list-item-top strong{font-size:14px;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.list-time{margin-left:auto;font-size:10px;color:#adb3bf;white-space:nowrap}.list-item-bottom{margin-top:5px}.list-preview{font-size:12px;color:#9097a5;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;flex:1}.unread-pill{min-width:19px;height:19px;padding:0 6px;border-radius:10px;background:var(--primary);color:#fff;font-size:10px;font-weight:800;display:flex;align-items:center;justify-content:center}.presence-mini{width:10px;height:10px;background:var(--success);border-radius:50%;border:2px solid #fff;position:absolute;left:43px;top:42px}.channel-icon{width:44px;height:44px;border-radius:14px;display:grid;place-items:center;font-size:17px;font-weight:800;flex:0 0 auto}.channel-icon.world{background:linear-gradient(145deg,#eff1ff,#dee3ff);color:#5e6ceb}.channel-icon.team{background:linear-gradient(145deg,#fff1e8,#ffe2d0);color:#d97943}.sidebar-footer{height:66px;border-top:1px solid var(--line);display:flex;align-items:center;padding:0 16px;gap:10px;background:#fafbfc}.sidebar-me-text{min-width:0;flex:1;display:flex;flex-direction:column}.sidebar-me-text strong{font-size:13px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.sidebar-me-text span{font-size:10px;color:var(--muted);margin-top:2px}
.chat-main{min-width:0;background:#fff;position:relative;display:flex;overflow:hidden}.empty-chat{margin:auto;text-align:center;padding:30px;color:var(--muted)}.empty-chat h2{color:#343a47;font-size:20px;margin:22px 0 8px}.empty-chat p{margin:0;font-size:14px}.empty-illustration{width:150px;height:110px;margin:0 auto;position:relative;display:grid;place-items:center}.empty-illustration .brand-mark{position:relative;z-index:2}.bubble{position:absolute;border-radius:24px;background:#eef0ff}.bubble-a{width:90px;height:62px;left:2px;top:10px;transform:rotate(-10deg)}.bubble-b{width:85px;height:58px;right:0;bottom:5px;background:#f4efff;transform:rotate(12deg)}.chat-panel{width:100%;height:100%;display:flex;flex-direction:column;min-width:0}.chat-header{height:73px;border-bottom:1px solid var(--line);display:flex;align-items:center;padding:0 20px;gap:12px;flex:0 0 auto}.channel-avatar{border-radius:14px}.chat-heading{min-width:0;flex:1}.chat-title-row{display:flex;align-items:center;gap:8px}.chat-heading h2{font-size:16px;margin:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.chat-heading p{font-size:11px;color:var(--muted);margin:4px 0 0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.secure-badge{font-size:9px;font-weight:800;color:#3c8b68;background:#e8f8f0;border-radius:8px;padding:3px 6px}.chat-header-actions{display:flex;gap:7px}.messages-scroller{position:relative;flex:1;overflow:auto;background:linear-gradient(180deg,#fff 0%,#fcfcfe 100%);padding:14px 4.5% 24px;scrollbar-width:thin;scrollbar-color:#d7dbe4 transparent}.messages{display:flex;flex-direction:column;gap:3px;min-height:100%}.load-older{display:block;margin:2px auto 18px;border:0;background:#f2f3f7;color:#747c8c;padding:7px 14px;border-radius:16px;font-size:11px;cursor:pointer}.date-divider{display:flex;align-items:center;justify-content:center;margin:16px 0 12px;color:#a2a8b4;font-size:10px}.message-row{display:flex;align-items:flex-end;gap:8px;margin:2px 0}.message-row.own{justify-content:flex-end}.message-row.grouped{margin-top:-1px}.message-avatar{align-self:flex-start;margin-top:19px}.message-row.grouped .message-avatar{visibility:hidden}.message-stack{max-width:min(70%,680px);display:flex;flex-direction:column;align-items:flex-start;min-width:0}.message-row.own .message-stack{align-items:flex-end}.message-sender{font-size:10px;color:#8e96a5;margin:0 0 4px 5px}.message-bubble{position:relative;background:#f0f2f6;color:#303642;border-radius:7px 17px 17px 17px;padding:9px 12px;font-size:14px;line-height:1.55;word-break:break-word;white-space:pre-wrap;box-shadow:0 1px 1px rgba(20,24,35,.02)}.message-row.own .message-bubble{background:var(--primary);color:#fff;border-radius:17px 7px 17px 17px}.message-bubble.recalled{background:transparent!important;color:#a2a8b4!important;border:1px dashed #d9dde5;font-size:12px;font-style:italic;box-shadow:none}.message-meta{display:flex;align-items:center;gap:5px;color:#a0a7b4;font-size:9px;margin:4px 5px 0}.read-state{color:#7f8dff;font-weight:700}.message-actions{opacity:0;transition:.15s;align-self:center}.message-row:hover .message-actions{opacity:1}.message-action-button{border:0;background:transparent;color:#9ba2af;font-size:11px;cursor:pointer;padding:4px 5px}.message-action-button:hover{color:var(--danger)}.message-image-wrap{overflow:hidden;border-radius:13px;max-width:min(360px,55vw);background:#f0f2f6;cursor:zoom-in}.message-image{display:block;max-width:100%;max-height:390px;object-fit:cover}.message-image-caption{padding:8px 10px;background:#fff;color:#4e5665;font-size:12px;border:1px solid var(--line);border-top:0}.message-row.own .message-image-caption{background:#f7f8ff}.file-card{display:flex;align-items:center;gap:11px;width:min(330px,62vw);padding:11px;border-radius:14px;background:#f3f4f8;color:#333b49;text-decoration:none;border:1px solid #eceef3}.message-row.own .file-card{background:#f0f2ff;border-color:#dfe3ff}.file-icon{width:42px;height:42px;border-radius:11px;background:#fff;display:grid;place-items:center;font-weight:800;color:var(--primary);box-shadow:0 2px 8px rgba(20,25,40,.05)}.file-info{min-width:0;flex:1}.file-info strong{display:block;font-size:12px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.file-info span{font-size:10px;color:#9299a7}.download-mark{font-size:18px;color:#8790a1}.encrypted-placeholder{font-size:12px;opacity:.82}.new-message-hint{position:sticky;bottom:8px;margin:-34px auto 0;width:max-content;background:#3e4758;color:#fff;font-size:11px;padding:8px 13px;border-radius:18px;cursor:pointer;box-shadow:0 6px 20px rgba(30,35,48,.18)}
.composer{min-height:82px;border-top:1px solid var(--line);padding:13px 18px;display:flex;align-items:flex-end;gap:9px;background:#fff;position:relative}.composer-tools{display:flex;align-items:center;gap:5px;height:42px}.composer-tool{border:0;background:transparent}.composer-input-wrap{flex:1;min-width:0;position:relative;background:#f4f5f8;border:1px solid transparent;border-radius:14px;transition:.18s}.composer-input-wrap:focus-within{background:#fff;border-color:#cfd5ff;box-shadow:0 0 0 3px rgba(91,108,249,.08)}#messageInput{display:block;width:100%;max-height:130px;resize:none;border:0;background:transparent;outline:0;padding:11px 14px;color:var(--text);font-size:13px;line-height:20px}.message-length{position:absolute;right:9px;bottom:4px;font-size:9px;color:#a5abb7}.send-button{width:43px;height:43px;border:0;border-radius:13px;background:var(--primary);color:#fff;display:grid;place-items:center;cursor:pointer;transition:.18s;box-shadow:0 7px 16px rgba(91,108,249,.22)}.send-button:hover{background:#4d5eea;transform:translateY(-1px)}.send-button svg{width:18px}.e2ee-control{height:32px;display:flex;align-items:center;gap:5px;padding:0 8px;border-radius:9px;background:#f1f7f4;color:#488064;font-size:10px;font-weight:700;cursor:pointer}.e2ee-control input{display:none}.e2ee-control:has(input:checked){background:#e1f6eb;color:#258b5e}.lock-icon{font-size:15px}.drop-hint{position:absolute;inset:-1px;background:rgba(91,108,249,.94);border-radius:14px;color:#fff;z-index:5;display:grid;place-items:center;font-weight:800;letter-spacing:.03em}.upload-strip{display:flex;align-items:center;gap:11px;border-top:1px solid var(--line);padding:10px 18px;background:#fbfbfe}.upload-file-icon{width:37px;height:37px;border-radius:11px;background:var(--primary-soft);color:var(--primary);display:grid;place-items:center;font-weight:800}.upload-strip-main{flex:1}.upload-strip-top{display:flex;justify-content:space-between;font-size:11px;margin-bottom:6px}.upload-progress{height:5px;background:#e7e9ef;border-radius:5px;overflow:hidden}.upload-progress span{display:block;width:0;height:100%;background:var(--primary);transition:width .1s}.upload-strip small{font-size:9px;color:var(--muted)}
.details-drawer{position:absolute;right:0;top:0;bottom:0;width:var(--details);background:#fff;border-left:1px solid var(--line);z-index:30;transform:translateX(100%);transition:.25s ease;box-shadow:-14px 0 35px rgba(35,40,55,.07)}.details-drawer.open{transform:translateX(0)}.details-header{height:73px;border-bottom:1px solid var(--line);display:flex;align-items:center;justify-content:space-between;padding:0 18px}.details-header h3{font-size:14px;margin:0}.details-content{height:calc(100% - 73px);overflow:auto;padding:22px}.details-profile{text-align:center}.details-profile .avatar{margin:0 auto 11px}.details-profile h3{font-size:16px;margin:0}.details-profile .handle{font-size:11px;color:var(--muted);margin-top:4px}.online-label{display:inline-flex;align-items:center;gap:5px;margin-top:9px;padding:5px 8px;border-radius:9px;background:#eff9f4;color:#3a946c;font-size:10px;font-weight:700}.online-label.offline{background:#f2f3f5;color:#8e95a2}.info-block{margin-top:22px;padding-top:17px;border-top:1px solid var(--line)}.info-block h4{font-size:10px;color:#9aa1ae;text-transform:uppercase;letter-spacing:.08em;margin:0 0 10px}.info-block p{font-size:12px;color:#596171;line-height:1.65;margin:0}.member-list{display:flex;flex-direction:column;gap:9px}.member-item{display:flex;align-items:center;gap:9px}.member-info{min-width:0;flex:1}.member-info strong{display:block;font-size:12px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.member-info span{font-size:9px;color:var(--muted)}.role-badge{font-size:8px;color:#b06d3e;background:#fff1e6;padding:3px 5px;border-radius:6px}
.modal-backdrop{position:fixed;inset:0;background:rgba(21,25,35,.35);backdrop-filter:blur(5px);z-index:100;display:grid;place-items:center;padding:20px}.modal-card{width:min(560px,100%);max-height:min(760px,92vh);overflow:auto;background:#fff;border-radius:22px;box-shadow:var(--shadow);border:1px solid rgba(255,255,255,.7)}.compact-modal{width:min(620px,100%)}.modal-header{display:flex;align-items:center;justify-content:space-between;padding:20px 22px 15px}.modal-header h3{margin:0;font-size:20px;letter-spacing:-.03em}.modal-body{padding:4px 22px 22px}.modal-footer{display:flex;align-items:center;gap:8px;padding:16px 22px;border-top:1px solid var(--line)}.spacer{flex:1}.profile-cover{height:92px;margin:0 14px;border-radius:16px;background:linear-gradient(120deg,#7482ff,#af91ff 55%,#f5a7ca)}.profile-avatar-row{display:flex;align-items:flex-end;gap:14px;padding:0 28px;margin-top:-35px}.avatar-edit{border:5px solid #fff;position:relative;cursor:pointer}.avatar-edit span{position:absolute;inset:0;background:rgba(27,31,43,.55);color:#fff;display:grid;place-items:center;font-size:10px;opacity:0;transition:.18s}.avatar-edit:hover span{opacity:1}.profile-avatar-row strong{font-size:14px}.profile-avatar-row p{font-size:10px;color:var(--muted);margin:4px 0 8px}.form-grid{display:grid;grid-template-columns:1fr;gap:15px;padding:24px 28px 28px}.form-grid label span{display:block;font-size:11px;color:#747d8d;font-weight:700;margin-bottom:7px}.form-grid .full{grid-column:1/-1}.modal-search{margin:0 0 14px}.search-results{max-height:380px;overflow:auto}.search-user{display:flex;align-items:center;gap:11px;padding:10px;border-radius:12px}.search-user:hover{background:#f6f7fa}.search-user-main{flex:1;min-width:0}.search-user strong{font-size:13px}.search-user p{font-size:10px;color:var(--muted);margin:3px 0 0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.small-button{border:0;background:var(--primary-soft);color:var(--primary);font-weight:750;border-radius:9px;padding:7px 10px;font-size:10px;cursor:pointer}.placeholder-block{text-align:center;color:#a0a7b4;font-size:12px;padding:42px 15px}.split-actions{display:grid;grid-template-columns:1fr 44px 1fr;gap:4px;align-items:stretch}.action-box{padding:18px;background:#f8f9fb;border-radius:15px}.action-box h4{font-size:14px;margin:0 0 5px}.action-box p{font-size:10px;color:var(--muted);margin:0 0 14px}.action-divider{display:grid;place-items:center;color:#aaa;font-size:10px}.image-preview{position:fixed;inset:0;background:rgba(10,12,17,.86);z-index:120;display:flex;flex-direction:column;align-items:center;justify-content:center;padding:50px}.image-preview img{max-width:90vw;max-height:78vh;border-radius:10px;box-shadow:0 18px 70px rgba(0,0,0,.35)}.image-preview-close{position:absolute;right:24px;top:20px;border:0;background:rgba(255,255,255,.12);color:#fff;width:40px;height:40px;border-radius:50%;font-size:24px;cursor:pointer}.image-preview-caption{color:#d9dbe1;margin-top:12px;font-size:12px}.toast-container{position:fixed;right:20px;bottom:20px;z-index:200;display:flex;flex-direction:column;gap:9px}.toast{min-width:250px;max-width:360px;padding:12px 14px;border-radius:13px;background:#202633;color:#fff;box-shadow:0 12px 35px rgba(20,25,35,.22);font-size:12px;animation:toastIn .22s ease}.toast.success{background:#27785a}.toast.error{background:#b94a55}@keyframes toastIn{from{transform:translateY(8px);opacity:0}to{transform:none;opacity:1}}
.request-item{display:flex;align-items:center;gap:10px;padding:10px;border-radius:12px;background:#fff;border:1px solid var(--line);margin:6px 0}.request-main{min-width:0;flex:1}.request-main strong{font-size:12px}.request-main span{display:block;color:var(--muted);font-size:10px;margin-top:2px}.request-actions{display:flex;gap:5px}.empty-list{text-align:center;padding:45px 18px;color:#a2a9b6}.empty-list strong{display:block;color:#7c8493;font-size:13px;margin-bottom:5px}.empty-list span{font-size:11px}.mobile-only{display:none}
@media(max-width:1050px){:root{--sidebar:292px}.message-stack{max-width:78%}.details-drawer{width:290px}}
@media(max-width:760px){body{overflow:hidden}.app-shell{grid-template-columns:60px minmax(0,1fr)}.nav-rail{grid-column:1}.sidebar{position:fixed;left:60px;top:0;bottom:0;width:min(330px,calc(100vw - 60px));transform:translateX(-110%);box-shadow:15px 0 35px rgba(30,35,48,.12);transition:.25s}.sidebar.mobile-open{transform:none}.chat-main{grid-column:2}.mobile-only{display:grid}.chat-header{padding:0 12px}.messages-scroller{padding-left:12px;padding-right:12px}.message-stack{max-width:84%}.composer{padding:10px}.composer-tools .e2ee-control span:last-child{display:none}.details-drawer{width:min(310px,calc(100vw - 30px))}.auth-card{padding:34px 24px}.split-actions{grid-template-columns:1fr}.action-divider{height:30px}.toast-container{left:12px;right:12px;bottom:12px}.toast{max-width:none;min-width:0}}

/* ==================== V4 会话增强 ==================== */
body.theme-dark{
  --bg:#11151d;--surface:#171c25;--surface-2:#1c222d;--line:#2a313d;--line-strong:#39414f;
  --text:#eef2f8;--muted:#98a2b3;--muted-2:#747f90;--primary-soft:color-mix(in srgb,var(--primary) 18%,transparent);
  --shadow:0 18px 55px rgba(0,0,0,.35)
}
body.theme-dark .app-shell,body.theme-dark .chat-main,body.theme-dark .chat-panel,body.theme-dark .chat-header,
body.theme-dark .composer,body.theme-dark .details-drawer,body.theme-dark .modal-card,body.theme-dark .sidebar-footer,
body.theme-dark .sidebar,body.theme-dark .nav-rail{background:var(--surface);color:var(--text)}
body.theme-dark .sidebar{background:#151a22}body.theme-dark .nav-rail{background:#121720}
body.theme-dark .messages-scroller{background:linear-gradient(180deg,#171c25,#151a22)}
body.theme-dark .input,body.theme-dark .icon-button,body.theme-dark .auth-tab.active{background:#202733;color:var(--text)}
body.theme-dark .search-wrap,body.theme-dark .composer-input-wrap,body.theme-dark .action-box{background:#202631}
body.theme-dark .list-item:hover{background:#202631}body.theme-dark .list-item.active{background:color-mix(in srgb,var(--primary) 17%,#171c25)}
body.theme-dark .message-bubble{background:#242b36;color:#edf2f8}body.theme-dark .message-row.own .message-bubble{background:var(--primary);color:#fff}
body.theme-dark .file-card{background:#222936;color:var(--text);border-color:#303846}
body.theme-dark .modal-backdrop{background:rgba(4,7,11,.65)}
body.theme-dark .secondary-button{background:#272e3a;color:#dce2eb}
body.theme-dark .details-drawer,body.theme-dark .chat-header,body.theme-dark .composer,body.theme-dark .sidebar,body.theme-dark .nav-rail,body.theme-dark .sidebar-footer{border-color:var(--line)}

.list-item.pinned{background:color-mix(in srgb,var(--primary) 6%,transparent)}
.list-item-flags{display:flex;gap:4px;align-items:center;margin-left:auto}.mini-flag{font-size:9px;color:var(--muted);line-height:1}.mini-flag.pin{color:var(--primary)}
.list-item.muted .unread-pill{background:#a4a9b3}.list-item.hidden-conversation{opacity:.58}
.channel-icon.region{background:linear-gradient(145deg,#e8f8ef,#d8f1e4);color:#34845e}.channel-icon.game{background:linear-gradient(145deg,#f5ecff,#eadbff);color:#8653c6}.channel-icon.system{background:linear-gradient(145deg,#eef1f5,#e1e6ed);color:#596475}

.composer-picker{position:absolute;left:18px;right:18px;bottom:78px;z-index:25;background:var(--surface);border:1px solid var(--line);border-radius:16px;box-shadow:var(--shadow);overflow:hidden;max-height:320px}.picker-tabs{display:flex;gap:4px;padding:8px;border-bottom:1px solid var(--line);background:var(--surface-2)}.picker-tab{border:0;background:transparent;color:var(--muted);padding:7px 10px;border-radius:8px;cursor:pointer;font-size:11px;font-weight:700}.picker-tab.active{background:var(--primary-soft);color:var(--primary)}.picker-content{padding:12px;overflow:auto;max-height:260px}.emoji-grid,.sticker-grid,.mention-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(42px,1fr));gap:6px}.emoji-cell,.sticker-cell{border:0;background:var(--surface-2);border-radius:9px;min-height:40px;cursor:pointer;font-size:21px}.sticker-cell{font-size:28px;min-height:58px}.emoji-cell:hover,.sticker-cell:hover{background:var(--primary-soft)}.mention-grid{grid-template-columns:1fr}.mention-cell{display:flex;align-items:center;gap:9px;border:0;background:transparent;padding:7px 8px;border-radius:9px;text-align:left;cursor:pointer;color:var(--text)}.mention-cell:hover{background:var(--surface-2)}.mention-cell .avatar{width:32px;height:32px}.mention-cell strong{display:block;font-size:12px}.mention-cell span{display:block;font-size:9px;color:var(--muted)}.gif-box{display:flex;gap:8px}.gif-box .input{flex:1}.picker-help{font-size:10px;color:var(--muted);margin-top:9px;line-height:1.55}

.message-mention{color:var(--primary);font-weight:800}.message-meta .sending{color:#a0a7b4}.message-meta .sent{color:#6f7888}.message-meta .failed{color:var(--danger);font-weight:700}.message-row.pending{opacity:.78}.message-row.failed{opacity:1}.retry-message{border:0;background:none;color:var(--danger);padding:0;font-size:10px;cursor:pointer}.favorite-active{color:#e2a933!important}.message-actions{gap:5px;flex-wrap:wrap}.message-action-button{white-space:nowrap}

.typing-indicator{color:var(--primary)!important}.details-actions{display:grid;gap:8px;margin-top:18px}.detail-action{width:100%;border:1px solid var(--line);background:var(--surface-2);color:var(--text);padding:10px 12px;border-radius:10px;text-align:left;cursor:pointer;font-size:11px}.detail-action:hover{border-color:var(--primary);color:var(--primary)}.detail-action.danger{color:var(--danger)}.detail-switch{display:flex;align-items:center;justify-content:space-between;gap:12px}.detail-switch input{accent-color:var(--primary)}.detail-input{margin-top:7px}.detail-note{font-size:9px;color:var(--muted);line-height:1.5;margin-top:6px}.conversation-backgrounds{display:grid;grid-template-columns:repeat(4,1fr);gap:7px;margin-top:8px}.bg-choice{height:46px;border:2px solid transparent;border-radius:10px;cursor:pointer}.bg-choice.active{border-color:var(--primary)}.bg-default{background:var(--surface)}.bg-dots{background-color:#f7f8fc;background-image:radial-gradient(#ccd2df 1px,transparent 1px);background-size:12px 12px}.bg-grid{background-color:#f8fafc;background-image:linear-gradient(#e5e9f0 1px,transparent 1px),linear-gradient(90deg,#e5e9f0 1px,transparent 1px);background-size:18px 18px}.bg-warm{background:linear-gradient(145deg,#fff8f0,#f7f2ff)}
.messages-scroller.chat-bg-dots{background-color:#f7f8fc;background-image:radial-gradient(#d9ddea 1px,transparent 1px);background-size:15px 15px}.messages-scroller.chat-bg-grid{background-color:#fafbfe;background-image:linear-gradient(#edf0f5 1px,transparent 1px),linear-gradient(90deg,#edf0f5 1px,transparent 1px);background-size:22px 22px}.messages-scroller.chat-bg-warm{background:linear-gradient(145deg,#fffaf4,#faf6ff)}
body.theme-dark .messages-scroller.chat-bg-dots{background-color:#171c25;background-image:radial-gradient(#343b48 1px,transparent 1px)}body.theme-dark .messages-scroller.chat-bg-grid{background-color:#171c25;background-image:linear-gradient(#282f3b 1px,transparent 1px),linear-gradient(90deg,#282f3b 1px,transparent 1px)}body.theme-dark .messages-scroller.chat-bg-warm{background:linear-gradient(145deg,#211d1b,#1e1a25)}

.settings-grid{display:grid;gap:14px}.setting-row,.setting-block{border:1px solid var(--line);border-radius:13px;padding:12px 14px;background:var(--surface-2)}.setting-row{display:flex;align-items:center;justify-content:space-between;gap:16px}.setting-block{display:grid;gap:10px}.setting-row span,.setting-block span{display:block}.setting-row strong,.setting-block strong{display:block;font-size:12px}.setting-row small,.setting-block small{display:block;color:var(--muted);font-size:9px;margin-top:3px}.setting-row input[type=checkbox]{width:18px;height:18px;accent-color:var(--primary)}.setting-block input[type=color]{width:100%;height:42px;border:1px solid var(--line);border-radius:9px;background:transparent;padding:3px}
.favorites-list{display:flex;flex-direction:column;gap:9px}.favorite-item{border:1px solid var(--line);border-radius:12px;padding:11px 12px;background:var(--surface-2)}.favorite-item-top{display:flex;justify-content:space-between;gap:8px;font-size:9px;color:var(--muted);margin-bottom:7px}.favorite-item-content{font-size:12px;line-height:1.6;word-break:break-word}.favorite-item-actions{display:flex;justify-content:flex-end;margin-top:8px}.world-filter-badge{display:inline-flex;padding:3px 7px;border-radius:8px;background:var(--primary-soft);color:var(--primary);font-size:9px;font-weight:800;margin-left:5px}
.system-message .message-bubble{background:#f1f3f7;color:#596171;border:1px solid var(--line)}body.theme-dark .system-message .message-bubble{background:#202631;color:#cdd5e0}

@media(max-width:760px){.composer-picker{left:8px;right:8px;bottom:72px}.composer-tools{gap:1px}.composer-tool{width:34px}.settings-grid{gap:10px}}

/* ==================== V5 响应式与性能优化 ==================== */
.nav-rail{min-height:0;overflow:hidden}
.nav-brand,.rail-bottom{flex:0 0 auto}
.rail-nav{flex:1;min-height:0;width:100%;overflow-y:auto;overflow-x:hidden;align-items:center;padding:2px 0 10px;scrollbar-width:none;overscroll-behavior:contain}
.rail-nav::-webkit-scrollbar{display:none}
.sidebar,.sidebar-content{min-height:0}
.sidebar-content{overscroll-behavior:contain;-webkit-overflow-scrolling:touch}
.messages-scroller{overscroll-behavior:contain;-webkit-overflow-scrolling:touch;contain:layout paint}
.messages{contain:layout style}
.message-row{content-visibility:auto;contain-intrinsic-size:72px}
.list-item{contain:layout paint}
.history-loading{margin:auto;padding:34px 18px;color:var(--muted);font-size:12px;text-align:center}
.undo-toast{min-width:310px;max-width:430px;padding:11px 12px 11px 14px;border-radius:14px;background:#202633;color:#fff;box-shadow:0 12px 35px rgba(20,25,35,.24);font-size:12px;display:flex;align-items:center;gap:14px;animation:toastIn .2s ease}
.undo-toast span{flex:1;min-width:0}
.undo-toast button{border:0;border-radius:9px;padding:7px 11px;background:#fff;color:#293042;font-size:11px;font-weight:800;cursor:pointer;white-space:nowrap}
body.theme-dark .undo-toast{background:#f0f3f8;color:#1c2330}
body.theme-dark .undo-toast button{background:#1f2632;color:#fff}

@media(max-height:560px){
  .nav-rail{padding-top:8px;padding-bottom:8px}
  .nav-brand{width:38px;height:38px}
  .rail-nav{margin-top:10px;gap:3px}
  .rail-item{width:40px;height:40px;border-radius:11px}
  .rail-bottom .avatar-md{width:38px;height:38px}
}

@media(max-width:760px){
  .sidebar{z-index:35;will-change:transform}
  .nav-rail{z-index:40}
  .undo-toast{min-width:0;max-width:none;width:100%}
}

.auth-remember-hint{margin-top:10px;text-align:center;font-size:12px;color:var(--muted,#8b93a7);}

/* ==================== V7 交互与缓存修复 ==================== */
.list-item{
  width:100%;
  border:0;
  background:transparent;
  text-align:left;
  color:inherit;
  font:inherit;
  appearance:none;
  -webkit-appearance:none;
  touch-action:manipulation;
  user-select:none;
}
.list-item:focus-visible,.rail-item:focus-visible,.icon-button:focus-visible{
  outline:2px solid var(--primary);
  outline-offset:2px;
}
.rail-item,.icon-button,.send-button,.small-button,.primary-button,.secondary-button,.danger-button{
  touch-action:manipulation;
}
.mobile-sidebar-backdrop{
  display:none;
  position:fixed;
  inset:0 0 0 60px;
  z-index:34;
  border:0;
  padding:0;
  background:rgba(20,25,35,.20);
  backdrop-filter:blur(1px);
  cursor:default;
}
@media(max-width:760px){
  .mobile-sidebar-backdrop.show{display:block}
  .sidebar{pointer-events:none}
  .sidebar.mobile-open{pointer-events:auto}
  .sidebar-content{touch-action:pan-y}
}
@media(min-width:761px){
  .mobile-sidebar-backdrop{display:none!important}
  .sidebar{pointer-events:auto!important}
}


/* ==================== V8 频道折叠与最新消息排序 ==================== */
.section-toggle{
  width:100%;border:0;background:transparent;display:flex;align-items:center;gap:7px;
  text-align:left;cursor:pointer;appearance:none;-webkit-appearance:none;touch-action:manipulation;
}
.section-toggle:hover{color:var(--text);background:color-mix(in srgb,var(--primary) 5%,transparent);border-radius:9px}
.section-toggle .section-count{margin-left:auto;min-width:20px;height:18px;padding:0 6px;border-radius:9px;display:inline-flex;align-items:center;justify-content:center;background:var(--surface-2);color:var(--muted);font-size:9px;font-weight:800}
.section-toggle .section-arrow{font-size:14px;line-height:1;transform:rotate(0deg);transition:transform .18s ease;color:var(--muted)}
.section-toggle[aria-expanded="false"] .section-arrow{transform:rotate(-90deg)}
.collapsible-section-body{display:block;overflow:visible}
.collapsible-section-body.collapsed{display:none}
body.theme-dark .section-toggle:hover{background:rgba(255,255,255,.035)}
@media(max-width:760px){.section-toggle{min-height:38px;padding-top:9px;padding-bottom:7px}}

/* ==================== V9 WebRTC 语音 / 视频 ==================== */
.call-header-button.hidden{display:none!important}
.call-modal-backdrop{z-index:1200;backdrop-filter:blur(14px)}
.incoming-call-card{position:relative;width:min(360px,calc(100vw - 32px));padding:34px 28px 28px;border-radius:28px;background:var(--surface,#fff);box-shadow:0 24px 80px rgba(15,23,42,.2);text-align:center;overflow:hidden}
.incoming-call-card .call-avatar{position:relative;z-index:2;margin:0 auto 18px;width:88px;height:88px;font-size:28px}
.incoming-call-pulse{position:absolute;top:28px;left:50%;width:100px;height:100px;margin-left:-50px;border:2px solid var(--primary);border-radius:50%;opacity:.28;animation:novaCallPulse 1.7s ease-out infinite}
.incoming-call-card h3{margin:0 0 8px;font-size:24px}
.incoming-call-card p{margin:0;color:var(--muted,#7b8497)}
.incoming-call-actions{display:flex;justify-content:center;gap:54px;margin-top:30px}
.round-call-button{width:62px;height:62px;border:0;border-radius:50%;font-size:25px;cursor:pointer;color:#fff;transition:transform .16s ease,filter .16s ease}
.round-call-button:hover{transform:translateY(-2px);filter:brightness(1.04)}
.round-call-button.reject{background:#ef4444}.round-call-button.accept{background:#22c55e}
@keyframes novaCallPulse{0%{transform:scale(.82);opacity:.38}100%{transform:scale(1.55);opacity:0}}

.call-overlay{position:fixed;inset:0;z-index:1300;background:#080b14;color:#fff}
.call-overlay.hidden{display:none!important}
.call-stage{position:relative;width:100%;height:100%;overflow:hidden;background:radial-gradient(circle at 50% 35%,#26304d 0,#121725 45%,#080b14 100%)}
.remote-video{position:absolute;inset:0;width:100%;height:100%;object-fit:cover;background:#080b14}
.remote-video.audio-only{opacity:0;pointer-events:none}
.audio-call-backdrop{position:absolute;inset:0;display:flex;flex-direction:column;align-items:center;justify-content:center;padding-bottom:100px;text-align:center;background:radial-gradient(circle at 50% 40%,rgba(91,108,249,.28),rgba(8,11,20,.96) 58%)}
.audio-call-backdrop.video-active{background:linear-gradient(to top,rgba(0,0,0,.52),transparent 38%);justify-content:flex-end;align-items:flex-start;padding:0 0 150px 32px;text-align:left;pointer-events:none}
.call-peer-avatar{width:120px;height:120px;font-size:34px;margin-bottom:22px;box-shadow:0 0 0 10px rgba(255,255,255,.05)}
.audio-call-backdrop.video-active .call-peer-avatar{display:none}
.audio-call-backdrop h2{font-size:28px;margin:0 0 8px}.audio-call-backdrop p{margin:0 0 8px;color:rgba(255,255,255,.72)}
.call-timer{font-variant-numeric:tabular-nums;letter-spacing:.08em}
.local-video{position:absolute;right:24px;top:76px;width:min(24vw,260px);aspect-ratio:3/4;object-fit:cover;border-radius:20px;background:#141927;box-shadow:0 16px 50px rgba(0,0,0,.35);border:1px solid rgba(255,255,255,.12)}
.local-video.hidden{display:none!important}
.call-topbar{position:absolute;top:max(18px,env(safe-area-inset-top));left:20px;right:20px;display:flex;justify-content:space-between;align-items:center;pointer-events:none}
.call-mode-badge,.call-network-state{padding:8px 12px;border-radius:999px;background:rgba(0,0,0,.36);backdrop-filter:blur(12px);font-size:13px}
.call-controls{position:absolute;left:50%;bottom:max(28px,env(safe-area-inset-bottom));transform:translateX(-50%);display:flex;gap:16px;padding:12px 16px;border-radius:28px;background:rgba(14,18,29,.72);backdrop-filter:blur(20px);border:1px solid rgba(255,255,255,.09)}
.call-control{width:72px;height:66px;border:0;border-radius:20px;background:rgba(255,255,255,.12);color:#fff;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:3px;cursor:pointer}
.call-control span{font-size:22px}.call-control small{font-size:11px}.call-control.active{background:#fff;color:#111827}.call-control.danger{background:#ef4444}

.team-voice-panel{position:fixed;z-index:1100;right:22px;bottom:22px;width:min(380px,calc(100vw - 28px));max-height:min(70vh,620px);display:flex;flex-direction:column;background:var(--surface,#fff);border:1px solid var(--border,#e8eaf0);border-radius:24px;box-shadow:0 24px 70px rgba(15,23,42,.22);overflow:hidden}
.team-voice-panel.hidden{display:none!important}
.team-voice-header{display:flex;align-items:center;justify-content:space-between;padding:20px 20px 14px;border-bottom:1px solid var(--border,#e8eaf0)}
.team-voice-header h3{margin:2px 0 0}
.team-voice-participants{padding:12px;overflow:auto;display:flex;flex-direction:column;gap:6px}
.voice-participant{display:flex;align-items:center;gap:11px;padding:10px 11px;border-radius:16px;background:var(--soft,#f5f7fb);transition:background .18s ease,box-shadow .18s ease}
.voice-participant.speaking{background:color-mix(in srgb,var(--primary) 13%,var(--soft,#f5f7fb));box-shadow:inset 3px 0 0 var(--primary)}
.voice-participant .avatar{flex:0 0 auto}.voice-participant-main{min-width:0;flex:1}.voice-participant-main strong,.voice-participant-main span{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.voice-participant-main span{font-size:12px;color:var(--muted,#7b8497);margin-top:2px}
.voice-state-dot{width:9px;height:9px;border-radius:50%;background:#94a3b8}.voice-participant.speaking .voice-state-dot{background:#22c55e;box-shadow:0 0 0 5px rgba(34,197,94,.12)}
.team-voice-footer{display:flex;gap:10px;padding:14px 16px 16px;border-top:1px solid var(--border,#e8eaf0)}
.team-voice-footer>button{flex:1}

.call-history{display:flex;flex-direction:column;gap:8px;margin-top:10px}.call-history-row{display:flex;align-items:center;gap:10px;padding:10px 0;border-bottom:1px solid var(--border,#eceef4)}.call-history-row:last-child{border-bottom:0}.call-history-icon{width:34px;height:34px;border-radius:11px;display:grid;place-items:center;background:var(--soft,#f5f7fb)}.call-history-main{flex:1;min-width:0}.call-history-main strong,.call-history-main span{display:block}.call-history-main span{font-size:12px;color:var(--muted,#7b8497);margin-top:2px}.call-history-status{font-size:12px;color:var(--muted,#7b8497)}.call-history-status.missed{color:#ef4444}

@media(max-width:760px){
  .chat-header-actions{gap:2px}.chat-header-actions .icon-button{width:38px;height:38px}
  .local-video{right:12px;top:66px;width:34vw;border-radius:16px}
  .call-controls{gap:8px;width:calc(100% - 24px);justify-content:center;padding:10px}.call-control{flex:1;max-width:86px}
  .team-voice-panel{right:8px;left:8px;bottom:8px;width:auto;max-height:64vh}
  .audio-call-backdrop.video-active{padding-left:18px}
}
.call-header-button.active{background:color-mix(in srgb,var(--primary) 14%,transparent);color:var(--primary)}

/* V10 voice message */
.voice-record-strip{display:flex;align-items:center;gap:12px;border-top:1px solid var(--line);padding:10px 18px;background:var(--surface)}
.voice-record-pulse{width:12px;height:12px;border-radius:50%;background:#ef5350;box-shadow:0 0 0 0 rgba(239,83,80,.35);animation:voicePulse 1.2s infinite}
@keyframes voicePulse{70%{box-shadow:0 0 0 9px rgba(239,83,80,0)}100%{box-shadow:0 0 0 0 rgba(239,83,80,0)}}
.voice-record-main{min-width:0;flex:1;display:grid;grid-template-columns:auto 1fr;gap:2px 10px;align-items:center}
.voice-record-main strong{font-size:12px}.voice-record-main span{font-size:12px;color:#ef5350;font-variant-numeric:tabular-nums}.voice-record-main small{grid-column:1/-1;font-size:9px;color:var(--muted)}
.voice-message{width:min(300px,68vw);display:flex;align-items:center;gap:10px;padding:10px 12px;border-radius:7px 17px 17px 17px;background:#f0f2f6;color:#303642}
.message-row.own .voice-message{background:var(--primary);color:#fff;border-radius:17px 7px 17px 17px}
.voice-play{width:34px;height:34px;border:0;border-radius:50%;display:grid;place-items:center;background:rgba(255,255,255,.86);color:var(--primary);cursor:pointer;flex:0 0 auto}
.voice-track{height:5px;flex:1;background:rgba(120,130,150,.2);border-radius:10px;overflow:hidden}.voice-track span{display:block;height:100%;width:0;background:currentColor;opacity:.7;transition:width .08s linear}
.voice-duration{font-size:10px;min-width:34px;text-align:right;font-variant-numeric:tabular-nums;opacity:.72}
body.theme-dark .voice-record-strip{background:var(--surface);border-color:var(--line)}body.theme-dark .voice-message{background:#242b36;color:#edf2f8}.message-row.own .voice-message{background:var(--primary);color:#fff}
@media(max-width:760px){.voice-record-strip{padding:9px 10px;gap:8px}.voice-record-main small{display:none}.voice-message{width:min(280px,72vw)}}

/* ==================== V11 手机浏览器完整适配 ==================== */
.rail-label{display:none}

@media(max-width:760px){
  :root{--mobile-nav-h:calc(64px + env(safe-area-inset-bottom,0px))}
  html,body{height:100%;overscroll-behavior:none}
  body{-webkit-text-size-adjust:100%;touch-action:manipulation}
  .app-shell{
    height:var(--app-height,100dvh);
    min-height:0;
    grid-template-columns:minmax(0,1fr);
    grid-template-rows:minmax(0,1fr);
    padding-bottom:var(--mobile-nav-h);
    overflow:hidden;
  }
  .nav-rail{
    position:fixed;
    left:0;right:0;bottom:0;
    width:100%;height:var(--mobile-nav-h);
    padding:4px 8px max(4px,env(safe-area-inset-bottom,0px));
    border-right:0;border-top:1px solid var(--line);
    display:flex;flex-direction:row;align-items:flex-start;
    background:color-mix(in srgb,var(--surface) 94%,transparent);
    backdrop-filter:blur(18px);
    -webkit-backdrop-filter:blur(18px);
    z-index:100;
  }
  .nav-brand{display:none}
  .rail-nav{
    margin:0;padding:0;
    width:auto;min-width:0;flex:1;
    height:56px;
    display:flex;flex-direction:row;align-items:center;justify-content:space-around;
    gap:1px;overflow:visible;
  }
  .rail-item{
    width:auto;min-width:54px;max-width:76px;height:54px;
    padding:5px 8px 4px;border-radius:13px;
    display:flex;flex-direction:column;align-items:center;justify-content:center;gap:2px;
  }
  .rail-item svg{width:20px;height:20px;flex:0 0 auto}
  .rail-label{display:block;font-size:10px;line-height:1.1;font-weight:700;white-space:nowrap}
  .rail-badge{right:8px;top:1px;border-color:var(--surface)}
  .rail-bottom{margin:0 0 0 1px;height:56px;display:flex;align-items:center}
  .me-avatar-button{width:54px;height:54px;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:2px}
  .me-avatar-button .avatar-md{width:25px;height:25px;font-size:10px}
  .connection-dot{width:8px;height:8px;right:10px;bottom:22px;border-width:1.5px;border-color:var(--surface)}
  .profile-label{color:#9299a8}

  .chat-main{grid-column:1;grid-row:1;min-height:0;width:100%;height:100%}
  .chat-panel{height:100%;min-height:0}
  .empty-chat{padding:24px 22px 80px}

  .sidebar{
    position:fixed;
    left:0;right:0;top:0;bottom:var(--mobile-nav-h);
    width:100%;max-width:none;
    transform:translateX(-102%);
    box-shadow:none;
    border-right:0;
    transition:transform .22s cubic-bezier(.2,.75,.25,1);
    z-index:90;
  }
  .sidebar.mobile-open{transform:translateX(0)}
  .sidebar-header{height:72px;padding:16px 16px 10px;padding-top:max(16px,env(safe-area-inset-top,0px))}
  .sidebar-header h2{font-size:22px}
  .search-wrap{margin:0 12px 10px;height:44px}
  .sidebar-content{padding:0 8px 10px}
  .sidebar-footer{height:58px;padding:0 12px}
  .list-item{min-height:64px;padding:9px 10px}
  .section-label{padding-left:10px;padding-right:10px}
  .mobile-sidebar-backdrop{inset:0 0 var(--mobile-nav-h) 0;z-index:89;background:rgba(15,20,30,.16)}

  .chat-header{height:62px;padding:0 8px;gap:8px;padding-top:env(safe-area-inset-top,0px)}
  .chat-heading h2{font-size:15px}
  .chat-heading p{font-size:10px;margin-top:2px}
  .chat-header-actions{gap:2px;flex:0 0 auto}
  .chat-header-actions .icon-button,.chat-header>.icon-button{width:36px;height:36px;border-radius:10px}
  #refreshChatButton{display:none}
  .secure-badge{display:none!important}
  .mobile-only{display:grid}

  .messages-scroller{
    padding:10px 10px 16px;
    min-height:0;
    scroll-padding-bottom:18px;
  }
  .messages{min-height:100%}
  .message-stack{max-width:86%}
  .message-bubble{font-size:14px;padding:9px 11px;line-height:1.5}
  .message-avatar{width:34px;height:34px;font-size:11px}
  .message-row{gap:6px}
  .message-actions{opacity:.72}
  .message-action-button{min-height:30px;padding:5px 6px}
  .message-image-wrap{max-width:min(78vw,360px)}
  .file-card{width:min(78vw,330px)}
  .voice-message{width:min(78vw,300px)}

  .composer{
    min-height:auto;
    padding:7px 8px max(7px,env(safe-area-inset-bottom,0px));
    display:grid;
    grid-template-columns:minmax(0,1fr) 44px;
    grid-template-areas:"tools tools" "input send";
    align-items:end;
    gap:6px 7px;
  }
  .composer-tools{
    grid-area:tools;height:36px;min-width:0;
    display:flex;align-items:center;gap:2px;
    overflow-x:auto;overflow-y:hidden;scrollbar-width:none;
    -webkit-overflow-scrolling:touch;
  }
  .composer-tools::-webkit-scrollbar{display:none}
  .composer-tool{width:36px!important;height:36px!important;min-width:36px;border-radius:10px}
  .e2ee-control{min-width:38px;height:32px;flex:0 0 auto;padding:0 7px}
  .e2ee-control span:last-child{display:none}
  .composer-input-wrap{grid-area:input}
  #messageInput{font-size:16px;line-height:21px;padding:10px 12px;max-height:104px}
  .send-button{grid-area:send;width:44px;height:44px;border-radius:12px}
  .composer-picker{left:6px;right:6px;bottom:96px;max-height:min(52dvh,360px)}
  .picker-tabs{overflow-x:auto;scrollbar-width:none;padding:6px}
  .picker-tabs::-webkit-scrollbar{display:none}
  .picker-tab{white-space:nowrap;min-height:38px;padding:7px 12px}
  .picker-content{max-height:calc(min(52dvh,360px) - 52px)}
  .emoji-grid,.sticker-grid{grid-template-columns:repeat(6,minmax(0,1fr))}

  .upload-strip,.voice-record-strip{padding-left:10px;padding-right:10px}
  .voice-record-strip{flex-wrap:wrap}
  .voice-record-main{min-width:150px}
  .voice-record-strip .small-button{min-height:38px}

  .details-drawer{
    position:fixed;
    left:0;right:0;top:0;bottom:var(--mobile-nav-h);
    width:100%;max-width:none;
    z-index:95;
    border-left:0;
    transform:translateX(102%);
    box-shadow:none;
  }
  .details-header{height:64px;padding:0 14px;padding-top:env(safe-area-inset-top,0px)}
  .details-content{height:calc(100% - 64px);padding:18px 16px 28px}

  .modal-backdrop{padding:0;place-items:end center}
  .modal-card,.compact-modal,.profile-modal{
    width:100%;max-width:none;
    max-height:min(88dvh,760px);
    border-radius:22px 22px 0 0;
    border-left:0;border-right:0;border-bottom:0;
    overscroll-behavior:contain;
  }
  .modal-header{padding:16px 16px 12px}
  .modal-body{padding:4px 16px 18px}
  .modal-footer{padding:12px 16px max(12px,env(safe-area-inset-bottom,0px));flex-wrap:wrap}
  .modal-footer .spacer{display:none}
  .modal-footer>button{flex:1;min-width:92px}
  .profile-cover{margin:0 10px;height:78px}
  .profile-avatar-row{padding:0 18px}
  .form-grid{padding:20px 18px 22px}
  .input,.search-wrap input{font-size:16px}

  .toast-container{left:8px;right:8px;bottom:calc(var(--mobile-nav-h) + 8px)}
  .image-preview{padding:18px 10px calc(18px + env(safe-area-inset-bottom,0px))}
  .image-preview img{max-width:96vw;max-height:82dvh}

  .team-voice-panel{left:6px;right:6px;bottom:calc(var(--mobile-nav-h) + 6px);width:auto;max-height:62dvh;border-radius:20px}
  .call-controls{bottom:max(14px,env(safe-area-inset-bottom,0px));width:calc(100% - 16px);gap:6px;padding:8px}
  .call-control{height:62px;min-width:0;border-radius:18px}
  .local-video{right:10px;top:max(60px,calc(env(safe-area-inset-top,0px) + 52px));width:min(36vw,150px)}
  .call-topbar{top:max(10px,env(safe-area-inset-top,0px));left:10px;right:10px}
}

@media(max-width:420px){
  .chat-header{gap:5px}
  #chatHeaderAvatar{display:none}
  .chat-header-actions .icon-button,.chat-header>.icon-button{width:34px;height:34px}
  .message-stack{max-width:90%}
  .message-avatar{display:none}
  .emoji-grid,.sticker-grid{grid-template-columns:repeat(5,minmax(0,1fr))}
}

@media(max-width:350px){
  .rail-item{min-width:48px;padding-left:4px;padding-right:4px}
  .rail-label{font-size:9px}
  .chat-heading p{display:none}
  .composer-tool{width:34px!important;min-width:34px}
}

body.mobile-keyboard-open .app-shell{padding-bottom:0}
body.mobile-keyboard-open .nav-rail{display:none}
body.mobile-keyboard-open .sidebar{bottom:0}
body.mobile-keyboard-open .details-drawer{bottom:0}
body.mobile-keyboard-open .mobile-sidebar-backdrop{inset:0}
body.mobile-keyboard-open .toast-container{bottom:8px}
body.mobile-keyboard-open .team-voice-panel{bottom:6px}
body.mobile-keyboard-open .composer{padding-bottom:6px}
@media(max-width:760px){
  .auth-view{min-height:100dvh;padding:16px 14px max(16px,env(safe-area-inset-bottom,0px))}
  .auth-card{padding:28px 20px 24px;border-radius:22px}
  .auth-heading{margin:14px 0 20px}
  .auth-heading h1{font-size:25px}
}


/* ==================== V12 输入工具收纳 + 手机 WebRTC 细节 ==================== */
.composer{position:relative}
.composer-more-button{width:43px;height:43px;flex:0 0 43px;border-radius:13px;font-size:25px;line-height:1;color:var(--muted);transition:.18s}
.composer-more-button.active{background:var(--primary-soft);color:var(--primary);transform:rotate(45deg)}
.composer-more-menu{position:absolute;left:18px;bottom:70px;z-index:18;width:246px;padding:10px;display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:7px;background:var(--surface,#fff);border:1px solid var(--line);border-radius:18px;box-shadow:0 18px 48px rgba(25,32,50,.18)}
.composer-more-menu.hidden{display:none!important}
.composer-more-action{min-width:0;height:64px;border:0;border-radius:14px;background:var(--soft,#f5f6f9);color:var(--text);display:flex;flex-direction:column;align-items:center;justify-content:center;gap:5px;cursor:pointer;transition:.16s;padding:6px}
.composer-more-action:hover,.composer-more-action:active{background:var(--primary-soft);color:var(--primary)}
.composer-more-action>span{font-size:21px;line-height:1}.composer-more-action>small{font-size:10px;font-weight:700;white-space:nowrap}
.composer-more-menu .e2ee-control{height:64px;padding:6px;display:flex}.composer-more-menu .e2ee-control input{display:none}.composer-more-menu .e2ee-control:has(input:checked){background:var(--primary-soft);color:var(--primary)}
body.theme-dark .composer-more-menu{background:var(--surface);border-color:var(--line)}
body.theme-dark .composer-more-action{background:#202631}
.call-network-state{max-width:min(58vw,360px);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}

@media(max-width:760px){
  .composer{grid-template-columns:42px minmax(0,1fr) 44px;grid-template-areas:"more input send";gap:6px;padding:7px 8px max(7px,env(safe-area-inset-bottom,0px))}
  .composer-more-button{grid-area:more;width:42px;height:44px;border-radius:12px;align-self:end}
  .composer-input-wrap{grid-area:input}
  .send-button{grid-area:send}
  .composer-more-menu{left:8px;right:8px;bottom:60px;width:auto;grid-template-columns:repeat(4,minmax(0,1fr));padding:8px;border-radius:17px}
  .composer-more-action{height:62px}
  .composer-picker{bottom:60px}
}
@media(max-width:390px){.composer-more-menu{grid-template-columns:repeat(4,minmax(0,1fr));gap:5px}.composer-more-action{height:58px}.composer-more-action>span{font-size:19px}.composer-more-action>small{font-size:9px}}

/* ==================== V13 手机输入法稳定 + 快捷语音 ==================== */
.voice-quick-button{
  width:43px;height:43px;flex:0 0 43px;border-radius:13px;
  color:var(--muted);font-size:19px;align-self:flex-end;
  background:var(--surface-2,#f5f6f9);border:1px solid var(--line);
}
.voice-quick-button:hover,.voice-quick-button:active{background:var(--primary-soft);color:var(--primary)}
.voice-quick-button.recording{background:#fff0f0;color:#ef5350;border-color:#ffd1d1;animation:voicePulse 1.25s infinite}
body.theme-dark .voice-quick-button{background:#202631;border-color:var(--line)}

@media(max-width:760px){
  /* 固定到真实可视区域，避免 iOS/Android 键盘弹出后浏览器把整个聊天页向上滚走。 */
  .app-shell{
    position:fixed;
    left:0;right:0;
    top:var(--visual-viewport-top,0px);
    height:var(--app-height,100dvh);
    max-height:var(--app-height,100dvh);
    width:100%;
  }
  .chat-main,.chat-panel{min-height:0;overflow:hidden}
  .messages-scroller{min-height:80px}

  .composer{
    grid-template-columns:42px minmax(0,1fr) 42px 44px;
    grid-template-areas:"more input voice send";
    gap:6px;
  }
  .voice-quick-button{
    grid-area:voice;
    width:42px;height:44px;min-width:42px;
    border-radius:12px;
  }
  .composer-more-menu{grid-template-columns:repeat(4,minmax(0,1fr))}

  body.mobile-keyboard-open .app-shell{
    padding-bottom:0;
  }
  body.mobile-keyboard-open .chat-header{
    flex:0 0 56px;
    height:56px;
  }
  body.mobile-keyboard-open .messages-scroller{
    min-height:90px;
    padding-bottom:10px;
  }
  body.mobile-keyboard-open .composer{
    flex:0 0 auto;
    padding-top:6px;
    padding-bottom:max(6px,env(safe-area-inset-bottom,0px));
  }
}

@media(max-width:370px){
  .composer{grid-template-columns:38px minmax(0,1fr) 38px 42px;gap:4px}
  .composer-more-button,.voice-quick-button{width:38px;min-width:38px;height:42px}
  .send-button{width:42px;height:42px}
}
.voice-quick-button.active{background:#fff0f0;color:#ef5350;border-color:#ffd1d1;animation:voicePulse 1.25s infinite}
body.theme-dark .voice-quick-button.active{background:#3a2225;color:#ff8d8d;border-color:#66373d}


/* ==================== V15 手机“我的”页面重构 ==================== */
.mobile-profile-actions{display:none}
.mobile-profile-action{border:0;background:transparent;color:inherit}

@media(max-width:760px){
  /* “我的”在手机端是独立页面，不再使用桌面底部弹窗。 */
  #profileModal{
    position:fixed;
    left:0;right:0;top:0;bottom:var(--mobile-nav-h);
    inset:0 0 var(--mobile-nav-h) 0;
    padding:0;
    place-items:stretch;
    background:var(--surface);
    backdrop-filter:none;
    -webkit-backdrop-filter:none;
    z-index:98;
    overflow:hidden;
  }
  #profileModal .profile-modal{
    width:100%;height:100%;max-width:none;max-height:none;
    border:0;border-radius:0;box-shadow:none;
    background:var(--surface);
    overflow-y:auto;overflow-x:hidden;
    overscroll-behavior:contain;
    padding-bottom:max(12px,env(safe-area-inset-bottom,0px));
  }
  #profileModal .modal-header{
    position:sticky;top:0;z-index:4;
    min-height:64px;
    padding:calc(12px + env(safe-area-inset-top,0px)) 16px 12px;
    background:color-mix(in srgb,var(--surface) 94%,transparent);
    backdrop-filter:blur(18px);
    -webkit-backdrop-filter:blur(18px);
    border-bottom:1px solid color-mix(in srgb,var(--line) 70%,transparent);
  }
  #profileModal .modal-header .eyebrow{display:none}
  #profileModal .modal-header h3{font-size:22px}
  #profileModal .profile-cover{
    height:126px;margin:14px 14px 0;border-radius:22px;
  }
  #profileModal .profile-avatar-row{
    margin-top:-48px;padding:0 24px;
    align-items:flex-end;gap:14px;
  }
  #profileModal .profile-avatar-row .avatar-xl{width:84px;height:84px;font-size:23px}
  #profileModal .profile-avatar-row strong{font-size:17px}
  #profileModal .profile-avatar-row p{font-size:11px;margin-bottom:9px}
  #profileModal .avatar-edit{border-width:5px;box-shadow:0 6px 18px rgba(30,36,55,.12)}
  #profileModal .avatar-edit span{opacity:1;background:linear-gradient(transparent 48%,rgba(25,30,42,.62));align-items:end;padding-bottom:8px}

  .mobile-profile-actions{
    display:grid!important;
    gap:8px;
    padding:18px 16px 4px;
  }
  .mobile-profile-action{
    width:100%;min-height:68px;
    display:grid;grid-template-columns:42px minmax(0,1fr) 24px;
    align-items:center;gap:11px;
    padding:10px 12px;
    border:1px solid var(--line);
    border-radius:17px;
    background:var(--surface-2,#f7f8fb);
    text-align:left;cursor:pointer;
  }
  .mobile-profile-action:active{background:var(--primary-soft)}
  .mobile-profile-action-icon{
    width:42px;height:42px;border-radius:13px;
    display:grid;place-items:center;
    background:var(--primary-soft);color:var(--primary);
    font-size:19px;
  }
  .mobile-profile-action-copy{min-width:0;display:block}
  .mobile-profile-action-copy strong{display:block;font-size:14px}
  .mobile-profile-action-copy small{display:block;margin-top:4px;font-size:10px;color:var(--muted);white-space:normal}
  .mobile-profile-action-arrow{font-size:25px;color:var(--muted);text-align:center}

  #profileModal .form-grid{
    margin:12px 16px 0;
    padding:16px;
    border:1px solid var(--line);
    border-radius:18px;
    background:var(--surface-2,#f8f9fb);
    gap:14px;
  }
  #profileModal .form-grid label span{font-size:12px}
  #profileModal .form-grid .input{background:var(--surface)}
  #profileModal .modal-footer{
    position:sticky;bottom:0;z-index:5;
    display:grid;grid-template-columns:1fr 1.35fr;gap:9px;
    margin-top:14px;
    padding:12px 16px max(14px,env(safe-area-inset-bottom,0px));
    background:color-mix(in srgb,var(--surface) 96%,transparent);
    backdrop-filter:blur(16px);
    -webkit-backdrop-filter:blur(16px);
    border-top:1px solid var(--line);
  }
  #profileModal .modal-footer .spacer,
  #profileModal .modal-footer .secondary-button{display:none}
  #profileModal .modal-footer>button{width:100%;min-width:0;min-height:44px}
  #profileModal #logoutButton{grid-column:1}
  #profileModal #saveProfileButton{grid-column:2}

  .me-avatar-button.active .profile-label{color:var(--primary)}
  .me-avatar-button.active .avatar-md{box-shadow:0 0 0 3px var(--primary-soft);color:var(--primary)}
  body.theme-dark .mobile-profile-action,
  body.theme-dark #profileModal .form-grid{background:#1d232d}

  /* 设置依旧用弹层，但必须盖在个人页之上。 */
  #settingsModal,#favoritesModal{z-index:112}
}

@media(max-width:380px){
  #profileModal .profile-cover{height:110px;margin-left:10px;margin-right:10px}
  #profileModal .profile-avatar-row{padding:0 18px;margin-top:-43px}
  #profileModal .profile-avatar-row .avatar-xl{width:76px;height:76px}
  .mobile-profile-actions{padding-left:10px;padding-right:10px}
  #profileModal .form-grid{margin-left:10px;margin-right:10px}
  #profileModal .modal-footer{padding-left:10px;padding-right:10px}
}

/* ==================== V16 手机个人页头像定位修复 ==================== */
@media(max-width:760px){
  #profileModal .profile-cover{
    height:132px;
    margin:14px 14px 0;
    border-radius:22px;
  }
  #profileModal .profile-avatar-row{
    position:relative;
    z-index:2;
    margin:-46px 18px 0;
    padding:0;
    min-height:128px;
    display:flex;
    flex-direction:column;
    align-items:center;
    justify-content:flex-start;
    gap:8px;
    text-align:center;
  }
  #profileModal .profile-avatar-row .avatar-xl{
    width:92px;
    height:92px;
    font-size:24px;
    flex:0 0 92px;
  }
  #profileModal .profile-avatar-row>div{
    width:100%;
    min-width:0;
    padding:0 12px;
  }
  #profileModal .profile-avatar-row strong{
    display:block;
    font-size:18px;
    line-height:1.25;
    overflow:hidden;
    text-overflow:ellipsis;
    white-space:nowrap;
  }
  #profileModal .profile-avatar-row p{
    margin:5px 0 0;
    font-size:11px;
    line-height:1.45;
  }
  #profileModal .avatar-edit{
    border:5px solid var(--surface);
    box-shadow:0 8px 24px rgba(30,36,55,.16);
  }
  #profileModal .mobile-profile-actions{
    padding-top:8px;
  }
}

@media(max-width:380px){
  #profileModal .profile-cover{
    height:116px;
    margin-left:10px;
    margin-right:10px;
  }
  #profileModal .profile-avatar-row{
    margin-top:-42px;
    min-height:120px;
  }
  #profileModal .profile-avatar-row .avatar-xl{
    width:84px;
    height:84px;
    flex-basis:84px;
  }
}

/* V17: 管理员个人页快捷入口 */
.profile-admin-entry{margin:0 24px 6px;width:calc(100% - 48px)}
@media(max-width:760px){.profile-admin-entry{display:none!important}}
