/* 通讯品牌作为角标保留，聊天窗口优先使用浏览器正文高度。 */
body.has-web-shell {
  --page-tabs-height:44px;
  --chat-web-header-height:24px;
  padding-top:var(--page-tabs-height);
  padding-bottom:0;
}
body.has-web-shell #app { min-height:calc(100svh - var(--page-tabs-height)); }
body.has-web-shell[data-surface="chat"] { padding-top:calc(var(--page-tabs-height) + var(--chat-web-header-height)); }
body.has-web-shell[data-surface="chat"] #app { min-height:calc(100svh - var(--page-tabs-height) - var(--chat-web-header-height)); }

body.has-web-shell #game-taskbar {
  top:0;
  bottom:auto;
  height:var(--page-tabs-height);
  padding:0 20px;
  border-top:0;
  border-bottom:1px solid #cbd0d5;
  background:#e7eaedef;
  color:#5d6369;
}
body.has-web-shell #game-taskbar .taskbar-apps {
  flex:1;
  min-width:0;
  gap:0;
  overflow-x:auto;
  scrollbar-width:none;
}
body.has-web-shell #game-taskbar .taskbar-apps::-webkit-scrollbar { display:none; }
body.has-web-shell #game-taskbar .taskbar-app {
  flex:0 0 auto;
  min-width:0;
  padding:0 19px;
  gap:9px;
  white-space:nowrap;
  color:#6d7379;
}
body.has-web-shell #game-taskbar .taskbar-app.active { background:#f7f8f9;color:#252b30;border-bottom-color:#7a929f; }
body.has-web-shell #game-taskbar .taskbar-app[data-action="chat"].active { border-bottom-color:#08ad59; }
body.has-web-shell #game-taskbar .taskbar-app:hover { background:#f0f2f4; }
body.has-web-shell #game-taskbar .taskbar-app>.icon { width:18px;height:18px;color:#81938b; }
body.has-web-shell #game-taskbar .taskbar-app[data-action="chat"]>.icon { color:#08ad59; }
body.has-web-shell #game-taskbar .taskbar-app>img { width:19px;height:19px; }
body.has-web-shell #game-taskbar .taskbar-system { flex-shrink:0;margin-left:14px;gap:7px; }
body.has-web-shell #game-taskbar .desktop-clock { padding:0 10px;color:#676d73; }
body.has-web-shell #game-taskbar .desktop-clock small { color:#949ba1; }
body.has-web-shell #game-taskbar .taskbar-system .icon-button { border-color:#cbd0d5;color:#7b858c; }

.chat-web-header {
  display:none;
  position:fixed;
  top:var(--page-tabs-height);
  left:16px;
  right:auto;
  width:max-content;
  max-width:calc(100% - 32px);
  height:var(--chat-web-header-height);
  z-index:44;
  align-items:center;
  gap:12px;
  padding:0;
  background:transparent;
  color:#6e777d;
  font-family:"Microsoft YaHei UI","Microsoft YaHei",sans-serif;
}
body.has-web-shell[data-surface="chat"] .chat-web-header { display:flex; }
.chat-web-brand { display:flex;align-items:center;gap:6px;white-space:nowrap; }
.chat-web-brand svg { width:18px;height:18px; }
.chat-web-brand strong { font-size:12px;font-weight:400;letter-spacing:0; }
.chat-web-brand>span { margin-left:2px;padding-left:8px;border-left:1px solid #bcc4ca;color:#899198;font-size:10px;line-height:13px; }
.chat-web-connection { display:flex;align-items:center;gap:4px;color:#899198;font-size:10px;white-space:nowrap; }
.chat-web-connection i { width:4px;height:4px;border-radius:50%;background:#32ad6a; }

/* 角标之外的空间交给会话；收藏、朋友圈及登录页保留各自布局。 */
body.has-web-shell[data-surface="chat"] .chat-window {
  height:min(790px,calc(100svh - var(--page-tabs-height) - var(--chat-web-header-height) - 48px));
  min-height:min(520px,max(360px,calc(100svh - var(--page-tabs-height) - var(--chat-web-header-height) - 48px)));
}
body.has-web-shell[data-surface="chat"] .moments-window { height:min(730px,calc(100svh - var(--page-tabs-height) - var(--chat-web-header-height) - 88px)); }
body.has-web-shell[data-surface="chat"] .comm-auth-desktop { min-height:calc(100svh - var(--page-tabs-height) - var(--chat-web-header-height) - 48px); }
body.has-web-shell .guide-print-toolbar { top:var(--page-tabs-height); }
body.has-web-shell .guide-print-desktop>.browser-navigation { top:var(--page-tabs-height); }
body.has-web-shell .guide-print-desktop:has(>.browser-navigation) .guide-print-toolbar { top:calc(var(--page-tabs-height) + 47px); }
body.has-web-shell.has-return-school-errors .browser-toolbar { top:var(--page-tabs-height); }
body.has-web-shell.has-finale { padding:0; }
body.has-web-shell.has-finale .chat-web-header { display:none; }

@media(max-width:680px) {
  body.has-web-shell .guide-print-desktop:has(>.browser-navigation) .guide-print-toolbar { top:calc(var(--page-tabs-height) + 43px); }
}
@media(max-width:650px) {
  body.has-web-shell { --chat-web-header-height:24px; }
  body.has-web-shell #game-taskbar { padding:0 7px; }
  body.has-web-shell #game-taskbar .taskbar-app { padding:0 10px;gap:6px; }
  body.has-web-shell #game-taskbar .taskbar-app>span { max-width:130px;overflow:hidden;text-overflow:ellipsis; }
  body.has-web-shell #game-taskbar .taskbar-app>.icon,body.has-web-shell #game-taskbar .taskbar-app>img { width:17px;height:17px; }
  body.has-web-shell #game-taskbar .taskbar-system { margin-left:5px;gap:3px; }
  body.has-web-shell #game-taskbar .desktop-clock { padding:0 4px; }
  body.has-web-shell #game-taskbar .desktop-clock small { font-size:8px; }
  .chat-web-header { left:10px;max-width:calc(100% - 20px); }
  body.has-web-shell[data-surface="chat"] .chat-window { height:calc(100svh - var(--page-tabs-height) - var(--chat-web-header-height));min-height:360px; }
  body.has-web-shell[data-surface="chat"] .moments-window { height:calc(100svh - var(--page-tabs-height) - var(--chat-web-header-height) - 35px); }
  body.has-web-shell[data-surface="chat"] .comm-auth-desktop { min-height:calc(100svh - var(--page-tabs-height) - var(--chat-web-header-height)); }
}
/* 按逻辑视口高度分配会话空间；沿用显示模块的视口换算，不改变字号和倍率。 */
body.has-web-shell[data-surface="chat"] {
  --page-tabs-height:clamp(34px,8svh,44px);
  --chat-web-header-height:24px;
  --chat-frame-gap:clamp(4px,calc(4svh - 12px),8px);
  --chat-title-height:clamp(0px,calc(20svh - 58px),30px);
  --chat-conversation-header:clamp(44px,calc(6svh + 8px),65px);
  --chat-compose-height:clamp(100px,calc(50svh - 180px),190px);
  --chat-radio-compose-height:clamp(80px,calc(25svh - 30px),136px);
  --chat-compose-padding:clamp(5px,calc(2svh - 2px),11px);
}
body.has-web-shell[data-surface="chat"] .chat-desktop:has(>.chat-window:not(.comm-favorites-window)) {
  margin-block:var(--chat-frame-gap);
}
body.has-web-shell[data-surface="chat"] .chat-window:not(.comm-favorites-window) {
  height:max(0px,calc(100svh - var(--page-tabs-height) - var(--chat-web-header-height) - var(--chat-frame-gap) - var(--chat-frame-gap)));
  min-height:0;
  grid-template-rows:var(--chat-title-height) minmax(0,1fr);
}
body.has-web-shell[data-surface="chat"] .chat-window:not(.comm-favorites-window)>.chat-titlebar {
  height:var(--chat-title-height);
  overflow:hidden;
}
body.has-web-shell[data-surface="chat"] .chat-window:not(.comm-favorites-window) .conversation-header,
body.has-web-shell[data-surface="chat"] .chat-window:not(.comm-favorites-window) .contacts-search {
  height:var(--chat-conversation-header);
}
body.has-web-shell[data-surface="chat"] .chat-window:not(.comm-favorites-window) .chat-composer {
  height:var(--chat-compose-height);
  padding:var(--chat-compose-padding) clamp(15px,3svh,23px);
  display:flex;
  flex-direction:column;
}
body.has-web-shell[data-surface="chat"] .chat-window:not(.comm-favorites-window) .composer-tools {flex:0 0 24px;}
body.has-web-shell[data-surface="chat"] .chat-window:not(.comm-favorites-window) .chat-editor {
  flex:1 1 auto;
  height:auto;
  min-height:24px;
  max-height:95px;
  padding:2px 0;
}
body.has-web-shell[data-surface="chat"] .chat-window:not(.comm-favorites-window) .composer-bottom {flex:0 0 30px;min-height:30px;margin-top:0;}
body.has-web-shell[data-surface="chat"] .chat-window:not(.comm-favorites-window) .group-announcement {padding-block:clamp(4px,1svh,8px);}
body.has-web-shell[data-surface="chat"] .chat-window:not(.comm-favorites-window) .messages {padding-bottom:clamp(12px,2.6svh,26px);}
body.has-web-shell[data-surface="chat"] .chat-window:not(.comm-favorites-window) .chat-ime {min-width:min(220px,calc(100% - 20px));}
body.has-web-shell[data-surface="chat"] .chat-window:not(.comm-favorites-window) .chat-rail {gap:clamp(5px,calc(3svh - 3px),17px);padding-top:clamp(6px,2svh,17px);}
body.has-web-shell[data-surface="chat"] .chat-window:not(.comm-favorites-window) .rail-bottom {margin-bottom:clamp(4px,2svh,18px);}
body.has-web-shell[data-surface="chat"] .comm-secondary-window .conversation {
  grid-template-rows:var(--chat-conversation-header) minmax(0,1fr) var(--chat-radio-compose-height);
}
body.has-web-shell[data-surface="chat"] .comm-secondary-window .radio-composer {display:flex;flex-direction:column;min-height:0;padding:6px 12px;}
body.has-web-shell[data-surface="chat"] .comm-secondary-window .radio-composer textarea {flex:1 1 auto;height:auto;min-height:24px;}
body.has-web-shell[data-surface="chat"] .comm-secondary-window .radio-composer>div {flex-shrink:0;}
@media(max-width:650px) {
  body.has-web-shell[data-surface="chat"] {--chat-web-header-height:24px;}
  body.has-web-shell[data-surface="chat"] .chat-window:not(.comm-favorites-window):not(.comm-secondary-window) {display:grid;grid-template-columns:48px minmax(0,1fr);padding-top:0;}
  body.has-web-shell[data-surface="chat"] .chat-window:not(.comm-favorites-window):not(.comm-secondary-window)>.chat-titlebar {position:static;grid-row:1;}
  body.has-web-shell[data-surface="chat"] .chat-window:not(.comm-favorites-window):not(.comm-secondary-window)>.conversation {grid-column:2;grid-row:2;height:100%;}
  body.has-web-shell[data-surface="chat"] .chat-window.show-contacts:not(.comm-favorites-window):not(.comm-secondary-window)>.contacts-panel {inset:var(--chat-title-height) 0 0 48px;}
  body.has-web-shell[data-surface="chat"] .true-ending-scene .chat-window:not(.comm-favorites-window):not(.comm-secondary-window) {grid-template-columns:44% minmax(0,1fr);}
  body.has-web-shell[data-surface="chat"] .true-ending-scene .chat-window:not(.comm-favorites-window):not(.comm-secondary-window)>.comm-rail {display:none;}
}
@media(max-height:450px) {
  body.has-web-shell[data-surface="chat"] {--chat-web-header-height:0px;}
  body.has-web-shell[data-surface="chat"] .chat-web-header {display:none;}
}
@media print {
  body.has-web-shell,body.has-web-shell[data-surface="chat"] { padding:0; }
  body.has-web-shell #game-taskbar,body.has-web-shell .chat-web-header { display:none!important; }
  body.has-web-shell #app { min-height:0; }
  body.has-web-shell .guide-print-toolbar,body.has-web-shell .guide-print-desktop>.browser-navigation { top:0; }
}
