/* 批TGW-DEV302：桌面聊天隐藏非聊天工具，并让输入与发送保持同排。 */

@media (min-width: 761px) {
  #view-chat {
    --qq-chat-canvas: #f3f5f8;
    --qq-chat-surface: #ffffff;
    --qq-chat-sidebar: #eef1f5;
    --qq-chat-line: #d8dee7;
    --qq-chat-ink: #27313d;
    --qq-chat-muted: #768292;
    --qq-chat-brand: #16846c;
    --qq-chat-brand-soft: #e5f4ef;
    --qq-chat-mine: #d9f1e8;
    --qq-chat-incoming: #ffffff;
    --qq-chat-input: #fbfcfd;
    --qq-chat-frame: var(--qq-chat-surface);
    --qq-chat-button: #f8fafc;
    display: grid;
    grid-template-columns: var(--chat-directory-width, 196px) 6px minmax(0, 1fr) !important;
    gap: 0;
    min-height: 0;
    padding: 0;
    overflow: hidden;
    border: 1px solid var(--qq-chat-line);
    border-radius: 8px;
    background: var(--qq-chat-canvas) !important;
    color: var(--qq-chat-ink) !important;
    color-scheme: light;
  }

  #view-chat > .pane,
  #view-chat > .chat-directory,
  #view-chat > .chat-main {
    min-width: 0;
    min-height: 0;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
  }

  #view-chat > .chat-directory {
    grid-column: 1;
    grid-row: 1;
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr) !important;
    overflow: hidden;
    border-right: 1px solid var(--qq-chat-line) !important;
    background: var(--qq-chat-sidebar) !important;
  }

  #view-chat > .chat-directory-resizer {
    display: block;
    grid-column: 2;
    grid-row: 1;
  }

  #view-chat > .chat-main {
    grid-column: 3;
    grid-row: 1;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) !important;
    background: var(--qq-chat-canvas) !important;
    height: 100%;
    overflow: hidden;
  }

  #view-chat > .chat-info-pane {
    display: none;
    position: absolute;
    z-index: 20;
    inset: 0 0 0 auto;
    width: min(360px, calc(100% - 300px));
    border-left: 1px solid var(--qq-chat-line) !important;
    background: var(--qq-chat-surface) !important;
    box-shadow: -10px 0 26px rgba(39, 49, 61, 0.12) !important;
  }

  #view-chat > .chat-info-pane.is-open {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
  }

  #view-chat .pane__header,
  #view-chat .chat-head {
    min-height: 58px;
    border-bottom: 1px solid var(--qq-chat-line) !important;
    background: var(--qq-chat-surface) !important;
    color: var(--qq-chat-ink) !important;
  }

  #view-chat .chat-directory .pane__header {
    padding: 9px 12px;
  }

  #view-chat .chat-directory__heading {
    gap: 9px;
  }

  #view-chat .chat-directory__heading strong,
  #view-chat .pane__header h2,
  #view-chat .pane__header h3,
  #view-chat .chat-head__identity h2 {
    color: var(--qq-chat-ink) !important;
  }

  #view-chat .chat-directory__heading small,
  #view-chat .chat-head__identity .muted {
    color: var(--qq-chat-muted) !important;
  }

  #view-chat .chat-directory__mark,
  #view-chat .list-item::before,
  #view-chat .message__avatar {
    border-color: #a8d5c8 !important;
    background: var(--qq-chat-brand-soft) !important;
    color: var(--qq-chat-brand) !important;
  }

  #view-chat .message__avatar--action {
    cursor: pointer;
  }

  #view-chat .message__avatar--action:hover,
  #view-chat .message__avatar--action:focus-visible {
    outline: 2px solid #07c160;
    outline-offset: 2px;
  }

  #view-chat .chat-directory .icon-button,
  #view-chat .chat-head .icon-button,
  #view-chat #chatInfoClose {
    min-width: 36px;
    min-height: 36px;
    border-color: var(--qq-chat-line) !important;
    border-radius: 6px;
    background: var(--qq-chat-surface) !important;
    color: var(--qq-chat-ink) !important;
  }

  #view-chat #chatInfoClose {
    display: inline-grid;
  }

  #view-chat .chat-directory .icon-button:hover,
  #view-chat .chat-directory .icon-button:focus-visible,
  #view-chat .chat-head .icon-button:hover,
  #view-chat .chat-head .icon-button:focus-visible,
  #view-chat #chatInfoClose:hover,
  #view-chat #chatInfoClose:focus-visible {
    border-color: #8fc9b9 !important;
    background: var(--qq-chat-brand-soft) !important;
    color: var(--qq-chat-brand) !important;
  }

  #view-chat .chat-head__identity {
    max-width: 220px;
    flex: 0 1 220px;
  }

  #view-chat .chat-context-actions {
    max-width: none;
    flex: 1 1 auto;
  }

  #view-chat .chat-context-actions > button {
    min-height: 30px;
    border-color: var(--qq-chat-line) !important;
    background: #f8fafc !important;
    color: var(--qq-chat-ink) !important;
  }

  #view-chat .chat-context-actions > button:hover,
  #view-chat .chat-context-actions > button:focus-visible,
  #view-chat .chat-context-actions > button.is-active {
    border-color: #8fc9b9 !important;
    background: var(--qq-chat-brand-soft) !important;
    color: var(--qq-chat-brand) !important;
  }

  #view-chat .chat-context-actions > .chat-danger-button {
    border-color: #efb6b9 !important;
    background: #fff3f3 !important;
    color: #b52d35 !important;
  }

  #view-chat .chat-tabs {
    border-bottom: 1px solid var(--qq-chat-line) !important;
    background: var(--qq-chat-surface) !important;
  }

  #view-chat .chat-tabs button {
    min-height: 30px;
    padding: 5px 2px;
    font-size: 13px;
    border-color: var(--qq-chat-line) !important;
    color: var(--qq-chat-muted) !important;
  }

  #view-chat .chat-tabs button[aria-selected="true"] {
    background: var(--qq-chat-brand-soft) !important;
    color: var(--qq-chat-brand) !important;
    box-shadow: inset 0 -2px var(--qq-chat-brand) !important;
  }

  #view-chat .chat-search,
  #view-chat .chat-directory > .pane__body {
    border-color: var(--qq-chat-line) !important;
    background: var(--qq-chat-sidebar) !important;
  }

  #view-chat .chat-search {
    grid-template-columns: minmax(0, 1fr) 30px;
    gap: 5px;
    padding: 6px;
  }

  #view-chat .chat-search input {
    min-height: 30px;
    border: 1px solid var(--qq-chat-line) !important;
    border-radius: 6px;
    background: var(--qq-chat-surface) !important;
    color: var(--qq-chat-ink) !important;
  }

  #view-chat .chat-search__add {
    border-color: #acb6bf !important;
    background: transparent !important;
    color: #3e4a54 !important;
  }

  #view-chat .chat-search__add:hover,
  #view-chat .chat-search__add:focus-visible,
  #view-chat .chat-search__add[aria-expanded="true"] {
    border-color: var(--qq-chat-brand) !important;
    background: var(--qq-chat-brand-soft) !important;
    color: var(--qq-chat-brand) !important;
  }

  #view-chat .chat-quick-menu {
    border-color: #c8d1da !important;
    background: #ffffff !important;
    box-shadow: 0 12px 28px rgba(39, 49, 61, 0.22) !important;
  }

  #view-chat .chat-quick-menu button {
    border-color: #e4e8ed !important;
    color: #27313d !important;
  }

  #view-chat .chat-quick-menu button:hover,
  #view-chat .chat-quick-menu button:focus-visible {
    background: #edf1f4 !important;
  }

  #view-chat .chat-directory > .pane__body {
    padding: 7px;
    overflow: auto;
  }

  #view-chat .list {
    gap: 3px;
  }

  #view-chat .list-item {
    min-height: 66px;
    padding: 8px 9px 8px 7px;
    border: 1px solid transparent !important;
    border-radius: 6px;
    background: transparent !important;
    color: var(--qq-chat-ink) !important;
  }

  #view-chat .list-item:hover,
  #view-chat .list-item:focus-visible {
    border-color: #c5ded6 !important;
    background: #e5f3ef !important;
  }

  #view-chat .list-item[aria-pressed="true"] {
    border-color: #a8d5c8 !important;
    background: var(--qq-chat-brand-soft) !important;
    box-shadow: inset 3px 0 var(--qq-chat-brand);
  }

  #view-chat .list-item__title {
    color: var(--qq-chat-ink) !important;
  }

  #view-chat .list-item__meta,
  #view-chat .request-section-title {
    color: var(--qq-chat-muted) !important;
  }

  #view-chat .chat-connection-status {
    min-height: 23px;
    padding: 3px 7px;
    border: 1px solid #a8d5c8 !important;
    border-radius: 999px;
    background: var(--qq-chat-brand-soft) !important;
    color: var(--qq-chat-brand) !important;
    font-size: 10px;
  }

  #view-chat .chat-connection-status[hidden] {
    display: none !important;
  }

  #view-chat .chat-toolbox {
    display: none !important;
  }

  #view-chat .chat-lottery-strip,
  #view-chat .chat-feature-strip {
    display: flex;
    align-items: center;
    min-width: 0;
    gap: 6px;
    overflow-x: auto;
    scrollbar-width: thin;
  }

  #view-chat .chat-lottery-strip {
    padding-bottom: 7px;
  }

  #view-chat .chat-toolbox__label {
    flex: 0 0 auto;
    color: var(--qq-chat-muted);
    font-size: 11px;
    font-weight: 700;
  }

  #view-chat .chat-lottery-buttons {
    display: flex;
    flex: 0 0 auto;
    gap: 4px;
  }

  #view-chat .chat-lottery-buttons button {
    position: relative;
    min-height: 29px;
    padding: 3px 8px 3px 16px;
    border: 1px solid var(--qq-chat-line) !important;
    border-radius: 5px;
    background: var(--qq-chat-surface) !important;
    color: var(--qq-chat-muted) !important;
    font-size: 11px;
    white-space: nowrap;
  }

  #view-chat .chat-lottery-buttons button::before {
    position: absolute;
    top: 50%;
    left: 6px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #8793a0;
    content: "";
    transform: translateY(-50%);
  }

  #view-chat .chat-lottery-buttons button[data-chat-game="fc3d"]::before { background: #d5505d; }
  #view-chat .chat-lottery-buttons button[data-chat-game="pl3"]::before { background: #4e7bd6; }
  #view-chat .chat-lottery-buttons button[data-chat-game="pl5"]::before { background: #8760bf; }
  #view-chat .chat-lottery-buttons button[data-chat-game="kl8"]::before { background: #2e9a70; }
  #view-chat .chat-lottery-buttons button[data-chat-game="ssq"]::before { background: #d64a45; }
  #view-chat .chat-lottery-buttons button[data-chat-game="dlt"]::before { background: #3976c5; }
  #view-chat .chat-lottery-buttons button[data-chat-game="custom"]::before { background: #b77a2c; }

  #view-chat .chat-lottery-buttons button:hover,
  #view-chat .chat-lottery-buttons button:focus-visible,
  #view-chat .chat-lottery-buttons button[aria-pressed="true"] {
    border-color: #8fc9b9 !important;
    background: var(--qq-chat-brand-soft) !important;
    color: var(--qq-chat-brand) !important;
  }

  #view-chat .chat-game-select-proxy {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
  }

  #view-chat .chat-feature-strip {
    padding-top: 7px;
    border-top: 1px solid #e2e7ed;
  }

  #view-chat .chat-feature-strip a {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 5px;
    min-height: 31px;
    padding: 4px 9px 4px 6px;
    border: 1px solid var(--qq-chat-line) !important;
    border-radius: 5px;
    background: var(--qq-chat-surface) !important;
    color: var(--qq-chat-ink) !important;
    font-size: 11px;
    text-decoration: none;
    white-space: nowrap;
  }

  #view-chat .chat-feature-strip a span {
    display: grid;
    width: 20px;
    height: 20px;
    place-items: center;
    border-radius: 4px;
    background: #e5f4ef;
    color: var(--qq-chat-brand);
    font-size: 10px;
    font-weight: 800;
  }

  #view-chat .chat-feature-strip a:hover,
  #view-chat .chat-feature-strip a:focus-visible {
    border-color: #8fc9b9 !important;
    background: var(--qq-chat-brand-soft) !important;
    color: var(--qq-chat-brand) !important;
  }

  #view-chat .messages {
    min-height: 0;
    min-width: 0;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 20px clamp(18px, 3vw, 42px);
    background: var(--qq-chat-canvas) !important;
    scrollbar-color: #b5c2ce transparent;
  }

  #view-chat .message {
    min-width: 0;
    max-width: min(82%, 760px);
  }

  #view-chat .message__meta {
    color: var(--qq-chat-muted) !important;
  }

  #view-chat .message__more {
    color: var(--qq-chat-muted);
  }

  #view-chat .message__more:hover,
  #view-chat .message__more:focus-visible,
  #view-chat .message__more[aria-expanded="true"] {
    border-color: #b7c5d2;
    background: #edf2f6;
    color: var(--qq-chat-ink);
  }

  #view-chat .message__menu {
    grid-template-columns: repeat(4, minmax(76px, 1fr));
    width: min(420px, calc(100vw - 56px));
    max-height: min(60vh, 360px);
    overflow-y: auto;
    border-color: var(--qq-chat-line);
    background: var(--qq-chat-surface);
    box-shadow: 0 8px 20px rgba(39, 49, 61, 0.14);
  }

  #view-chat .message__menu--up {
    top: auto;
    bottom: calc(100% + 5px);
  }

  #view-chat .message__menu-item {
    color: var(--qq-chat-ink);
    white-space: nowrap;
  }

  #view-chat .message__menu-item:hover,
  #view-chat .message__menu-item:focus-visible {
    background: var(--qq-chat-brand-soft);
    color: var(--qq-chat-brand);
  }

  #view-chat .message__bubble {
    border-color: #dce2e9 !important;
    border-radius: 4px 12px 12px 12px;
    background: var(--qq-chat-incoming) !important;
    color: var(--qq-chat-ink) !important;
    box-shadow: 0 2px 8px rgba(39, 49, 61, 0.06);
  }

  #view-chat .message--mine .message__bubble {
    border-color: #b9dfd2 !important;
    border-radius: 12px 4px 12px 12px;
    background: var(--qq-chat-mine) !important;
  }

  /* The surrounding QQ-style chat is light; do not inherit the older dark theme's quote fill. */
  #view-chat .message__reply-ref {
    border-left-color: #77b39c;
    border-radius: 4px;
    background: #f0f6f2;
    color: #456255;
  }

  #view-chat .message--mine .message__reply-ref { background: #eaf5ee; }

  #view-chat .message--system .message__bubble,
  #view-chat .message--recalled .message__bubble {
    border-color: #d4dce4 !important;
    background: #e7ebf0 !important;
    color: var(--qq-chat-muted) !important;
    box-shadow: none;
  }

  #view-chat .composer {
    position: relative;
    grid-template-columns: minmax(0, 1fr) 92px !important;
    grid-template-rows: minmax(58px, auto) auto;
    gap: 8px 10px;
    padding: 10px 14px 12px;
    border-top: 1px solid var(--qq-chat-line) !important;
    background: var(--qq-chat-surface) !important;
    z-index: 4;
  }

  #view-chat .composer__tools-toggle {
    display: none !important;
  }

  #view-chat #messageInput {
    grid-column: 1 !important;
    grid-row: 1 !important;
    min-height: 58px;
    border: 1px solid var(--qq-chat-line) !important;
    border-radius: 6px;
    background: var(--qq-chat-input) !important;
    color: var(--qq-chat-ink) !important;
    resize: vertical;
  }

  #view-chat #messageInput::placeholder {
    color: #8b96a3 !important;
  }

  #view-chat .composer__tools {
    grid-column: 1 / -1 !important;
    grid-row: 2 !important;
    display: flex !important;
    align-items: center;
    min-height: 38px;
    gap: 5px;
  }

  #view-chat .composer__tools button {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 50px;
    min-width: 50px;
    height: 40px;
    padding: 2px 3px;
    border: 1px solid var(--qq-chat-line) !important;
    border-radius: 5px;
    background: #f8fafc !important;
    color: var(--qq-chat-ink) !important;
    font-size: 15px;
    line-height: 1.05;
  }

  #view-chat .composer__tools button::after {
    margin-top: 2px;
    color: var(--qq-chat-muted);
    content: attr(data-label);
    font-size: 9px;
  }

  #view-chat .composer__tools button:hover,
  #view-chat .composer__tools button:focus-visible,
  #view-chat .composer__tools button[aria-pressed="true"] {
    border-color: #8fc9b9 !important;
    background: var(--qq-chat-brand-soft) !important;
    color: var(--qq-chat-brand) !important;
  }

  #view-chat #messageSendButton {
    grid-column: 2 !important;
    grid-row: 1 !important;
    width: 92px;
    min-width: 92px;
    min-height: 58px;
    border-color: var(--qq-chat-brand) !important;
    border-radius: 5px;
    background: var(--qq-chat-brand) !important;
    color: #ffffff !important;
  }

  #view-chat #messageSendButton:disabled {
    border-color: #cbd4de !important;
    background: #d9dfe6 !important;
    color: #7c8794 !important;
  }

  #view-chat .composer__emoji-panel,
  #view-chat .composer__attachment {
    border-color: var(--qq-chat-line) !important;
    background: #f8fafc !important;
    color: var(--qq-chat-ink) !important;
  }

  #view-chat .chat-info-pane .pane__body {
    padding: 14px;
    background: var(--qq-chat-surface) !important;
  }

  #view-chat .chat-info-card,
  #view-chat .member-row {
    border-color: var(--qq-chat-line) !important;
  }

  #view-chat .chat-info-card h4,
  #view-chat .chat-info-card p,
  #view-chat .chat-info-card .muted {
    color: var(--qq-chat-ink) !important;
  }

  /* 批TGW-DEV305：桌面聊天统一采用微信式平铺控件，清除历史主题的立体阴影。 */
  html body #view-chat :is(button, [role="button"], .button-link, .list-item, .chat-feature-strip a, .message__menu) {
    box-shadow: none !important;
    filter: none !important;
  }

  html body #view-chat :is(button, [role="button"], .button-link, .chat-feature-strip a) {
    border-radius: 4px !important;
  }

  html body #view-chat .chat-tabs button {
    border-radius: 0 !important;
  }

  html body #view-chat .list-item {
    border-radius: 4px !important;
  }

  html body #view-chat .list-item[aria-pressed="true"] {
    box-shadow: none !important;
    border-left: 3px solid var(--qq-chat-brand) !important;
  }

  html body #view-chat :is(button, [role="button"], .button-link, .list-item, .chat-feature-strip a, .message__menu):hover,
  html body #view-chat :is(button, [role="button"], .button-link, .list-item, .chat-feature-strip a, .message__menu):active,
  html body #view-chat :is(button, [role="button"], .button-link, .list-item, .chat-feature-strip a, .message__menu):focus-visible,
  html body #view-chat :is(button, [role="button"], .button-link, .list-item, .chat-feature-strip a, .message__menu)[aria-expanded="true"],
  html body #view-chat :is(button, [role="button"], .button-link, .list-item, .chat-feature-strip a, .message__menu)[aria-pressed="true"],
  html body #view-chat :is(button, [role="button"], .button-link, .list-item, .chat-feature-strip a, .message__menu):disabled,
  html body #view-chat :is(button, [role="button"], .button-link, .list-item, .chat-feature-strip a, .message__menu)[aria-disabled="true"] {
    box-shadow: none !important;
    filter: none !important;
  }

  html body #view-chat .chat-directory__quick button,
  html body #view-chat .composer__tools button {
    background: var(--qq-chat-surface) !important;
  }

  html body #view-chat .chat-directory__quick button:hover,
  html body #view-chat .chat-directory__quick button:focus-visible,
  html body #view-chat .composer__tools button:hover,
  html body #view-chat .composer__tools button:focus-visible,
  html body #view-chat .composer__tools button[aria-pressed="true"] {
    background: var(--qq-chat-brand-soft) !important;
  }

  html body #view-chat .message__menu {
    border-radius: 6px !important;
  }

  html body #view-chat .message__menu-item {
    box-shadow: none !important;
    filter: none !important;
  }

  /* 批TGW-DEV306：工具栏按需展开，收起时只保留轻量开关，不挤压输入框。 */
  html body #view-chat .composer__tools-toggle {
    display: inline-flex !important;
    grid-column: 1 !important;
    grid-row: 2 !important;
    align-items: center;
    justify-content: center;
    align-self: center;
    width: 64px;
    min-width: 64px;
    min-height: 40px;
    padding: 2px 6px;
    border: 1px solid var(--qq-chat-line) !important;
    border-radius: 4px !important;
    background: var(--qq-chat-surface) !important;
    color: var(--qq-chat-muted) !important;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.1;
    position: relative;
    z-index: 2;
  }

  html body #view-chat .composer__tools-toggle:hover,
  html body #view-chat .composer__tools-toggle:focus-visible,
  html body #view-chat .composer__tools-toggle[aria-expanded="true"] {
    border-color: #8fc9b9 !important;
    background: var(--qq-chat-brand-soft) !important;
    color: var(--qq-chat-brand) !important;
  }

  html body #view-chat .composer__tools {
    grid-column: 1 / -1 !important;
    grid-row: 2 !important;
    display: flex !important;
    align-items: center;
    min-height: 40px;
    gap: 5px;
    box-sizing: border-box;
    padding-left: 74px;
  }

  html body #view-chat .composer__tools[hidden] {
    display: none !important;
  }

  html body #view-chat .composer__tools:not([hidden]) {
    display: grid !important;
  }

  #view-chat .friend-swipe-row {
    position: relative;
    min-width: 0;
    overflow: hidden;
    border-radius: 6px;
  }

  #view-chat .friend-swipe-row > .list-item {
    position: relative;
    z-index: 1;
    width: 100%;
    margin: 0;
    background: var(--qq-chat-sidebar) !important;
    touch-action: pan-y;
    transition: transform 180ms ease;
  }

  #view-chat .friend-swipe-row.is-swipe-open > .list-item {
    transform: translateX(-176px);
  }

  #view-chat .friend-swipe-actions {
    position: absolute;
    z-index: 0;
    inset: 0 0 0 auto;
    display: grid;
    grid-template-columns: 88px 88px;
    width: 176px;
  }

  #view-chat .friend-swipe-actions button {
    min-width: 0;
    min-height: 100%;
    padding: 4px;
    border: 0;
    border-radius: 0;
    background: #e9a23b;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
  }

  #view-chat .friend-swipe-actions .chat-danger-button {
    background: #d94a48 !important;
    color: #fff !important;
  }

  /* 批TGW-DEV410：微信式输入栏固定为话筒、输入框、表情、更多/发送同一行。 */
  html body #view-chat .composer {
    grid-template-columns: 48px minmax(0, 1fr) 48px 92px !important;
    grid-template-rows: minmax(58px, auto) auto !important;
  }

  html body #view-chat #messageVoiceButton {
    grid-column: 1 !important;
    grid-row: 1 !important;
    align-self: stretch;
  }

  html body #view-chat #messageInput {
    grid-column: 2 !important;
    grid-row: 1 !important;
  }

  html body #view-chat #messageEmojiButton {
    grid-column: 3 !important;
    grid-row: 1 !important;
    align-self: stretch;
  }

  html body #view-chat #messageSendButton {
    grid-column: 4 !important;
    grid-row: 1 !important;
  }

  html body #view-chat .composer__tools {
    grid-column: 1 / -1 !important;
    grid-row: 2 !important;
    display: grid !important;
    padding-left: 0;
  }

  html body #view-chat .composer__tools-row {
    display: grid;
    grid-template-columns: repeat(5, minmax(78px, 1fr)) !important;
    gap: 6px;
    overflow-x: auto;
  }

  html body #view-chat .composer__tools-row button {
    width: 100% !important;
    min-width: 78px !important;
    height: 40px !important;
  }
}

@media (min-width: 761px) and (max-width: 1080px) {
  #view-chat {
    grid-template-columns: var(--chat-directory-width, 260px) 6px minmax(0, 1fr) !important;
  }

  #view-chat > .chat-info-pane {
    width: min(330px, calc(100% - 270px));
  }
}

@media (max-width: 760px) {
  /* 手机版继续使用原来的单列聊天壳，顶部桌面工具不挤压消息和输入区。 */
  #view-chat .chat-toolbox {
    display: none !important;
  }

  /* 批TGW-DEV426：会话管理按钮进入标题第二行，不能用最小内容宽度撑破手机聊天列。 */
  #view-chat > .chat-main {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    grid-template-columns: minmax(0, 1fr) !important;
  }

  #view-chat .chat-head,
  #view-chat .chat-shell,
  #view-chat #messageForm {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    box-sizing: border-box;
  }

  #view-chat .chat-head {
    flex-wrap: wrap;
    overflow: hidden;
  }

  #view-chat .chat-context-actions {
    order: 2;
    width: 100%;
    max-width: 100%;
    flex: 1 0 100%;
  }

  #view-chat .message__menu {
    grid-template-columns: repeat(3, minmax(70px, 1fr));
    width: min(330px, calc(100vw - 36px));
  }
}

/* 批TGW-DEV427：输入栏紧凑同高；群成员头像提供单人管理快捷入口。 */
html body #view-chat .composer {
  grid-template-columns: 48px minmax(0, 1fr) 48px 48px !important;
  grid-template-rows: minmax(48px, auto) auto !important;
  gap: 4px !important;
  padding: 6px 8px 8px !important;
}

html body #view-chat #messageInput {
  min-height: 48px !important;
  height: 48px;
  max-height: 120px;
  padding: 10px 12px !important;
  line-height: 26px !important;
  box-sizing: border-box;
}

html body #view-chat :is(#messageVoiceButton, #messageEmojiButton, #messageSendButton) {
  width: 48px !important;
  min-width: 48px !important;
  height: 48px !important;
  min-height: 48px !important;
  align-self: start !important;
  padding: 0 !important;
  line-height: 1 !important;
}

html body #view-chat #messageSendButton.is-send {
  font-size: 13px !important;
}

/* 批TGW-DEV434：新增语音转文字和手写；文件工具仍固定一行五列。 */
html body #view-chat .composer__tools {
  gap: 6px !important;
}

html body #view-chat .composer__tools-row {
  display: grid !important;
  grid-template-columns: repeat(5, minmax(64px, 1fr)) !important;
  gap: 6px !important;
  width: 100%;
  min-width: 0;
  overflow-x: auto;
}

html body #view-chat .composer__tools-row button {
  width: 100% !important;
  min-width: 64px !important;
  height: 40px !important;
  white-space: nowrap;
}

html body #view-chat .composer__tools-row--voice {
  grid-template-columns: repeat(3, minmax(88px, 1fr)) !important;
}

.chat-handwriting-editor {
  display: grid;
  gap: 10px;
  width: min(920px, calc(100vw - 72px));
  max-width: 100%;
}

.chat-handwriting-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.chat-handwriting-toolbar label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
}

.chat-handwriting-toolbar input[type="color"] {
  width: 44px;
  height: 36px;
  padding: 2px;
}

.chat-handwriting-toolbar input[type="range"] {
  width: min(220px, 38vw);
}

.chat-handwriting-toolbar button {
  width: 40px;
  height: 36px;
  padding: 0;
  font-size: 22px;
}

#chatHandwritingCanvas {
  display: block;
  width: 100%;
  aspect-ratio: 2 / 1;
  max-height: min(52vh, 480px);
  border: 1px solid #aeb9c5;
  border-radius: 4px;
  background: #ffffff;
  cursor: crosshair;
  touch-action: none;
}

#view-chat .chat-member-avatar {
  display: inline-flex;
  flex: 0 0 38px;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  min-width: 38px;
  padding: 0;
  border: 1px solid #99b9b2;
  border-radius: 50%;
  background: #e5f4ef;
  color: #126f5e;
  font-size: 15px;
  font-weight: 800;
  line-height: 1;
  box-sizing: border-box;
  overflow: hidden;
}

#view-chat .chat-member-avatar img,
.chat-settings-member-avatar img {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  object-fit: cover;
}

#view-chat button.chat-member-avatar--action {
  cursor: pointer;
}

#view-chat button.chat-member-avatar--action:hover,
#view-chat button.chat-member-avatar--action:focus-visible {
  border-color: #16846c;
  background: #cfece3;
  outline: 2px solid rgba(22, 132, 108, 0.2);
}

#view-chat .member-row {
  align-items: center !important;
}

/* 批TGW-DEV437：群成员管理使用独立弹窗，姓名、角色与管理动作在弹窗内直接可见。 */
.chat-member-management-list {
  display: grid;
  gap: 8px;
  max-height: min(58vh, 520px);
  overflow-y: auto;
}

.chat-member-management-row {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 58px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.035);
}

.chat-member-management-row .member-row__name {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.chat-member-management-row .member-row__name :is(strong, small) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-member-management-row .member-row__name small {
  color: var(--muted);
}

.chat-member-management-row .member-row__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.chat-member-management-row .member-row__actions button {
  min-height: 34px;
  padding: 5px 10px;
}

@media (max-width: 640px) {
  .chat-member-management-row {
    grid-template-columns: 38px minmax(0, 1fr);
  }

  .chat-member-management-row .member-row__actions {
    grid-column: 1 / -1;
    justify-content: stretch;
  }

  .chat-member-management-row .member-row__actions button {
    flex: 1 1 92px;
  }
}

.chat-member-action-summary {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
}

.chat-member-action-summary > span:last-child {
  display: grid;
  gap: 3px;
}

.chat-member-action-summary small {
  color: #6b7480;
}

/* 批TGW-DEV427：外框、功能按键和消息区域按会话独立配色。 */
html[data-business-view="chat"] .topbar,
html[data-business-view="chat"] .sidebar,
#view-chat :is(.pane__header, .chat-head, .chat-tabs, .chat-directory, .chat-info-pane, .composer, .chat-info-pane .pane__body) {
  background: var(--active-chat-frame, var(--qq-chat-frame, #ffffff)) !important;
}

html[data-business-view="chat"] .sidebar :is(.nav-button, .sidebar-tool-link, .sidebar-action-button),
#view-chat :is(.chat-search__add, .chat-quick-menu button, .chat-call-actions .icon-button, #messageSoundButton, #chatInfoButton, .composer__tools button) {
  background: var(--active-chat-button, var(--qq-chat-button, #f8fafc)) !important;
}

/* 微信式输入栏：话筒、表情和更多仅显示符号，不绘制独立按钮框。 */
html body #view-chat :is(#messageVoiceButton, #messageEmojiButton, #messageSendButton:not(.is-send)) {
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  color: var(--qq-chat-ink) !important;
  font-size: 25px !important;
}

html body #view-chat :is(#messageVoiceButton, #messageEmojiButton, #messageSendButton:not(.is-send)):hover,
html body #view-chat :is(#messageVoiceButton, #messageEmojiButton, #messageSendButton:not(.is-send)):focus-visible {
  background: transparent !important;
  color: var(--qq-chat-brand) !important;
  outline: 0 !important;
}

.chat-large-reading {
  display: grid;
  gap: 16px;
  min-height: min(56vh, 520px);
  padding: 18px;
  border: 1px solid #d8dee7;
  background: #ffffff;
  color: #202934;
}

.chat-large-reading header {
  color: #6b7480;
  font-size: 13px;
}

.chat-large-reading > div {
  font-size: clamp(20px, 3vw, 34px);
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.chat-translation-result,
.chat-reminder-preview {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.chat-translation-source,
.chat-translation-text,
.chat-reminder-preview {
  padding: 12px;
  border: 1px solid #d8dee7;
  background: #f7f9fb;
  line-height: 1.6;
}

.chat-translation-text {
  margin-top: 10px;
  background: #edf8f4;
}

.chat-group-qr {
  display: grid;
  justify-items: center;
  gap: 12px;
  text-align: center;
}

.chat-group-qr__code {
  width: min(320px, 78vw);
  aspect-ratio: 1;
  padding: 10px;
  background: #ffffff;
}

.chat-group-qr__code svg {
  display: block;
  width: 100%;
  height: 100%;
}

/* 批TGW-DEV443：微信式消息头像/气泡操作，以及无滚动的紧凑会话设置。 */
html body #view-chat .message:not(.message--system) {
  display: grid !important;
  grid-template-areas: "avatar stack";
  grid-template-columns: 34px minmax(0, 1fr) !important;
  align-items: start;
  gap: 6px !important;
  max-width: min(78%, 720px) !important;
  margin: 0 0 9px !important;
}

html body #view-chat .message--mine:not(.message--system) {
  grid-template-areas: "stack avatar";
  grid-template-columns: minmax(0, 1fr) 34px !important;
  margin-right: 0 !important;
  margin-left: auto !important;
}

html body #view-chat .message--system {
  display: flex !important;
  justify-content: center;
  max-width: 100% !important;
}

html body #view-chat .message__avatar,
html body #view-chat .message--mine .message__avatar {
  position: relative;
  grid-area: avatar;
  display: grid !important;
  width: 34px !important;
  min-width: 34px !important;
  height: 34px !important;
  min-height: 34px !important;
  place-items: center;
  overflow: hidden;
  padding: 0 !important;
  border-radius: 5px !important;
}

html body #view-chat .message__avatar img {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

html body #view-chat .message__avatar span {
  line-height: 1;
}

html body #view-chat .message__stack {
  position: relative;
  grid-area: stack;
  display: grid;
  min-width: 0;
  justify-items: start;
}

html body #view-chat .message--mine .message__stack {
  justify-self: auto !important;
  justify-items: end;
}

html body #view-chat .message__meta {
  gap: 4px;
  margin-bottom: 2px !important;
  line-height: 1.25;
}

html body #view-chat .message__bubble {
  padding: 8px 10px !important;
  cursor: context-menu;
}

html body #view-chat .message__bubble:focus-visible {
  outline: 2px solid var(--active-chat-accent, #16846c);
  outline-offset: 2px;
}

html body #view-chat .message__menu {
  top: calc(100% + 4px);
}

html body #view-chat .message--mine .message__menu {
  right: 0;
  left: auto;
}

/* 批TGW-DEV453：已有群标题栏直接拉好友，名单保留已入群好友并锁定勾选。 */
#view-chat .chat-invite-friends-button {
  flex: 0 0 auto;
  min-height: 36px;
  padding: 4px 8px;
  border: 1px solid var(--qq-chat-brand, #16846c);
  border-radius: 5px;
  background: var(--active-chat-button, var(--qq-chat-brand-soft, #e5f3ef));
  color: var(--qq-chat-brand, #16846c);
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
}

#view-chat .chat-invite-friends-button[hidden] { display: none !important; }

/* DEV460：按消息区自身宽度排版，不能只按宿主宽度判断浮窗标题栏。 */
#view-chat > .chat-main { container-type: inline-size; }
@container (max-width: 520px) {
  html body #view-chat .chat-head { flex-wrap: wrap; gap: 6px; padding: 8px; }
  html body #view-chat .chat-head-avatar { order: 0; flex: 0 0 36px; width: 36px; height: 36px; }
  html body #view-chat .chat-head__identity { order: 1; flex: 1 0 calc(100% - 96px); min-width: 0; max-width: none; }
  html body #view-chat .chat-head__identity h2,
  html body #view-chat .chat-head__identity .muted { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--qq-chat-ink, #27313d) !important; }
  html body #view-chat #chatInfoButton { order: 2; flex: 0 0 36px; min-width: 36px; }
  html body #view-chat .chat-invite-friends-button { order: 3; flex: 1 1 136px; min-width: 0; max-width: 100%; white-space: nowrap; padding-inline: 4px; }
  html body #view-chat .chat-call-actions { order: 4; flex: 0 0 auto; }
  html body #view-chat #messageSoundButton { order: 5; }
}

.chat-settings-group-members { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; min-height: 62px; }
.chat-settings-group-members > button { display: grid; grid-template-rows: 36px 16px; justify-items: center; gap: 3px; min-width: 0; height: auto !important; min-height: 62px; padding: 3px; border: 0; background: transparent; }
.chat-settings-member-avatar { display: grid; place-items: center; width: 36px; height: 36px; overflow: hidden; border: 1px solid #64af9a; border-radius: 6px; background: #d9f1e8; color: #126653; font-size: 20px; }
.chat-settings-group-members small { display: block; width: 100%; min-height: 16px; line-height: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.chat-settings-member-invite small { color: #54c7a3; font-weight: 700; }

.chat-invite-friend-list {
  display: grid;
  max-height: min(40dvh, 320px);
  overflow-y: auto;
  overflow-x: hidden;
  gap: 5px;
}

.chat-invite-friend-row {
  display: grid !important;
  grid-template-columns: 20px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  margin: 0 !important;
  padding: 5px 8px;
  border: 1px solid var(--line, #476171);
  border-radius: 5px;
}

.chat-invite-friend-row input { width: 18px; height: 18px; margin: 0; }
.chat-invite-friend-row > span { overflow-wrap: anywhere; }
.chat-invite-friend-row small { color: var(--muted, #91a9b8); white-space: nowrap; }

dialog.gate__panel--conversation-settings {
  width: min(780px, calc(100vw - 24px));
  height: min(560px, calc(100dvh - 24px));
  max-height: calc(100dvh - 24px);
  overflow: hidden !important;
  padding: 18px;
}

dialog.gate__panel--conversation-settings > form {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

dialog.gate__panel--conversation-settings .pane__header {
  margin: 0 0 8px !important;
  padding-block: 0 !important;
  min-height: 36px;
}

dialog.gate__panel--conversation-settings #dialogBody {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

dialog.gate__panel--conversation-settings .form-actions {
  min-height: 38px;
  margin-top: 8px !important;
}

.chat-settings-tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 5px;
  min-width: 0;
  padding-bottom: 7px;
}

.chat-settings-tabs button {
  min-width: 0;
  min-height: 34px;
  padding: 5px 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-settings-tabs button[aria-selected="true"] {
  border-color: #41b884;
  background: #16573f;
  color: #fff;
}

.chat-settings-panel {
  display: grid;
  grid-auto-rows: minmax(26px, auto);
  align-content: start;
  gap: 3px;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.chat-settings-panel[hidden] {
  display: none !important;
}

.chat-settings-row {
  display: grid !important;
  grid-template-columns: minmax(108px, 150px) minmax(120px, 40%) minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-width: 0;
  min-height: 26px;
  margin: 0 !important;
  font-size: 13px;
}

.chat-settings-row > span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-settings-row :is(input:not([type="checkbox"]), select) {
  width: 100% !important;
  min-width: 0;
  min-height: 26px !important;
  height: 26px;
  padding: 3px 7px;
  font-size: 12px;
  box-sizing: border-box;
}

.chat-settings-row input[type="file"] {
  max-width: 100%;
  padding: 2px 4px;
}

.chat-settings-row input[type="color"] {
  width: 78px !important;
  min-width: 78px;
  padding: 2px;
}

.chat-settings-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 0;
}

.chat-settings-row small {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-settings-row--action button {
  width: max-content;
  min-height: 26px;
  padding: 3px 10px;
}

.chat-settings-actions--compact {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-content: start;
  gap: 6px;
  min-width: 0;
  padding: 0;
}

.chat-settings-actions--compact button {
  min-width: 0;
  min-height: 36px;
  padding: 5px 7px;
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* DEV460：浮窗可用高度小于整页；成员姓名不能溢出到下一行申请按钮。 */
.chat-settings-panel[data-chat-settings-panel="basic"]:has(> .chat-settings-group-members) {
  grid-template-rows: 62px 26px;
}
.chat-settings-panel[data-chat-settings-panel="basic"] .chat-settings-actions--compact button {
  height: 26px !important;
  min-height: 26px;
  padding-block: 3px;
}

@media (max-width: 560px) {
  dialog.gate__panel--conversation-settings {
    width: calc(100vw - 12px);
    height: calc(100dvh - 12px);
    padding: 12px;
  }

  dialog.gate__panel--conversation-settings .pane__header {
    margin: 0 0 6px !important;
  }

  .chat-settings-tabs button {
    padding-inline: 3px;
    font-size: 11px;
  }

  .chat-settings-row {
    grid-template-columns: minmax(92px, 38%) minmax(108px, 42%) minmax(0, 1fr);
    gap: 5px;
  }

  .chat-settings-actions--compact {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
/* TGWIMDEV010: boolean settings use a switch; destructive actions retain buttons. */
.chat-settings-row input[type="checkbox"][role="switch"] { appearance:none;width:44px;height:26px;flex:none;border:0;border-radius:16px;background:#b4bdc7;padding:3px;cursor:pointer; }
.chat-settings-row input[role="switch"]::before { content:"";display:block;width:20px;height:20px;background:white;border-radius:50%;box-shadow:0 1px 3px #0003;transition:transform .15s; }
.chat-settings-row input[role="switch"]:checked { background:#16846c; }
.chat-settings-row input[role="switch"]:checked::before { transform:translateX(18px); }
.chat-settings-row input[role="switch"]:disabled { opacity:.55;cursor:default; }
