/* QQ extends the shared simulation surface; explicitly authored local styles
   keep their higher priority. The existing buttons and panels remain functional. */
:is(#qq-chat-toolbar, #qq-chat-voice-panel, #qq-chat-redo-btn, #qq-chat-photos-btn)[hidden] { display: none !important; }
#chat-page:not([data-wechat-real-preset-kind="qq"]) :is(#qq-chat-toolbar, #qq-chat-voice-panel, #qq-chat-redo-btn, #qq-chat-photos-btn) { display: none !important; }

#chat-page[data-wechat-real-preset-kind="qq"]:not(#lovemi-fg):not(#lovemi-fg) > .chat-header {
    min-height: 58px;
    padding: 3px 10px !important;
    border-bottom: 0 !important;
}
#chat-page[data-wechat-real-preset-kind="qq"][data-is-group="1"]:not(#lovemi-fg):not(#lovemi-fg) > .chat-header { min-height: 50px; }
#chat-page[data-wechat-real-preset-kind="qq"]:not(#lovemi-fg):not(#lovemi-fg) .chat-header-title-cluster {
    display: grid;
    grid-template-columns: minmax(0, max-content) 30px max-content;
    grid-template-areas: 'name heartbeat count' 'presence presence presence';
    justify-content: start;
    align-items: center;
    column-gap: 5px;
    row-gap: 0;
    min-width: 0;
}
#chat-page[data-wechat-real-preset-kind="qq"]:not(#lovemi-fg):not(#lovemi-fg) #chat-contact-name {
    grid-area: name;
    text-align: left;
    font-size: calc(17px * var(--theme-user-font-scale, 1) * var(--wechat-user-font-scale, 1));
    line-height: 1.5;
    font-weight: 500;
    text-shadow: none;
}
#chat-page[data-wechat-real-preset-kind="qq"]:not(#lovemi-fg):not(#lovemi-fg) #chat-heartbeat-monitor { grid-area: heartbeat; }
#chat-page[data-wechat-real-preset-kind="qq"]:not(#lovemi-fg):not(#lovemi-fg) #wechat-real-group-count {
    grid-area: count;
    font-size: calc(17px * var(--theme-user-font-scale, 1) * var(--wechat-user-font-scale, 1));
}
#chat-page[data-wechat-real-preset-kind="qq"]:not(#lovemi-fg):not(#lovemi-fg) #chat-char-presence {
    grid-area: presence;
    justify-self: start;
    margin: 0;
    font-size: 11px;
    line-height: 16px;
    white-space: nowrap;
    color: var(--wechat-real-muted, #7c8b99);
}
#chat-page[data-wechat-real-preset-kind="qq"]:not(#lovemi-fg):not(#lovemi-fg) .chat-header .back-btn {
    width: 32px;
    margin-right: 8px;
    padding: 4px;
}
#chat-page[data-wechat-real-preset-kind="qq"]:not(#lovemi-fg):not(#lovemi-fg) .chat-header-buttons { margin-left: 8px; }
#chat-page[data-wechat-real-preset-kind="qq"]:not(#lovemi-fg):not(#lovemi-fg) .chat-header-btn::after {
    width: 23px;
    height: 18px;
    background: linear-gradient(currentColor, currentColor) top / 23px 1.7px no-repeat,
        linear-gradient(currentColor, currentColor) center / 23px 1.7px no-repeat,
        linear-gradient(currentColor, currentColor) bottom / 23px 1.7px no-repeat;
}
#chat-page[data-wechat-real-preset-kind="qq"]:not(#lovemi-fg):not(#lovemi-fg) .chat-content { padding: 14px 12px 24px; gap: 16px; }
#chat-page[data-wechat-real-preset-kind="qq"]:not(#lovemi-fg):not(#lovemi-fg) .chat-message-bubble--voice :is(.chat-voice-row, .chat-voice-icon, .chat-voice-wave, .chat-voice-duration, .chat-voice-hint, .chat-voice-transcript) { color: inherit !important; }
#chat-page[data-wechat-real-preset-kind="qq"]:not(#lovemi-fg):not(#lovemi-fg) .chat-message-bubble--voice .chat-voice-icon { background: transparent; }
#chat-page[data-wechat-real-preset-kind="qq"]:not(#lovemi-fg):not(#lovemi-fg) .chat-message-bubble--voice .chat-voice-wave span { background: currentColor !important; }

/* First row: receive / flexible text editor / send. The toolbar is row two. */
#chat-page[data-wechat-real-preset-kind="qq"]:not(#lovemi-fg):not(#lovemi-fg) .chat-input-area {
    display: grid !important;
    grid-template-columns: 36px minmax(0, 1fr) 60px;
    grid-template-rows: auto 44px;
    column-gap: 8px !important;
    row-gap: 4px !important;
    align-items: end;
    padding: 8px 12px 3px !important;
    border-top: 0 !important;
    order: 0;
}
#chat-page[data-wechat-real-preset-kind="qq"]:not(#lovemi-fg):not(#lovemi-fg) #wechat-receive-btn {
    grid-row: 1;
    grid-column: 1;
    width: 36px;
    height: 44px;
}
#chat-page[data-wechat-real-preset-kind="qq"]:not(#lovemi-fg):not(#lovemi-fg) #chat-input {
    display: block !important;
    grid-row: 1;
    grid-column: 2;
    width: 100%;
    min-width: 0;
    min-height: 44px;
    max-height: 120px;
    padding: 10px 14px;
    border-radius: 20px !important;
    background: var(--wechat-real-input-bg, #e7edf5) !important;
    line-height: 1.5;
}
#chat-page[data-wechat-real-preset-kind="qq"]:not(#lovemi-fg):not(#lovemi-fg) .send-btn {
    grid-row: 1;
    grid-column: 3;
    width: 60px;
    height: 38px;
    margin: 0 0 3px;
    color: var(--wechat-real-bubble-out-text, #fff) !important;
    background: var(--wechat-real-bubble-out, #0078d4) !important;
    border-radius: 18px !important;
}
#chat-page[data-wechat-real-preset-kind="qq"] .send-btn > svg { display: none !important; }
#chat-page[data-wechat-real-preset-kind="qq"] .send-btn::after { content: '发送'; font-size: 14px; line-height: 1; white-space: nowrap; }
#chat-page[data-wechat-real-preset-kind="qq"]:not(#lovemi-fg):not(#lovemi-fg) #qq-chat-toolbar {
    grid-row: 2;
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    align-items: center;
    justify-items: center;
    width: 100%;
    min-width: 0;
}
#chat-page[data-wechat-real-preset-kind="qq"]:not(#lovemi-fg):not(#lovemi-fg) #qq-chat-toolbar .chat-function-btn {
    width: 44px;
    height: 44px;
    border-radius: 8px !important;
    color: var(--wechat-real-text, #334452) !important;
    --chat-tool-icon: 26px;
}
#chat-page[data-wechat-real-preset-kind="qq"]:not(#lovemi-fg):not(#lovemi-fg) #qq-chat-toolbar .more-btn::after { width: 26px; height: 26px; }
#chat-page[data-wechat-real-preset-kind="qq"][data-qq-chat-panel="more"]:not(#lovemi-fg):not(#lovemi-fg) #qq-chat-toolbar .more-btn::after { transform: rotate(45deg); }
#chat-page[data-wechat-real-preset-kind="qq"][data-qq-chat-panel="voice"]:not(#lovemi-fg):not(#lovemi-fg) #wechat-real-voice-toggle,
#chat-page[data-wechat-real-preset-kind="qq"][data-qq-chat-panel="emoji"]:not(#lovemi-fg):not(#lovemi-fg) #qq-chat-toolbar .emoji-btn,
#chat-page[data-wechat-real-preset-kind="qq"][data-qq-chat-panel="more"]:not(#lovemi-fg):not(#lovemi-fg) #qq-chat-toolbar .more-btn {
    color: var(--wechat-real-accent, #0078d4) !important;
    background: var(--wechat-real-input-bg, #e7edf5) !important;
}

/* The real emoji/more panels are docked below the toolbar, inside composer. */
#chat-page[data-wechat-real-preset-kind="qq"][data-qq-chat-panel]:not(#lovemi-fg):not(#lovemi-fg) .chat-bottom-composer {
    max-height: 100% !important;
    /* Exclusive layouts can position the real menu above this composer.
       Its panels own their height limits and scrolling; clipping the shared
       parent hides an otherwise-open popup and prevents every menu hit. */
    overflow: visible;
}
#chat-page[data-wechat-real-preset-kind="qq"]:not(#lovemi-fg):not(#lovemi-fg) :is(#emoji-panel, #chat-more-panel, #qq-chat-voice-panel) {
    position: relative !important;
    top: auto !important;
    right: auto !important;
    bottom: auto !important;
    left: auto !important;
    transform: none;
    order: 1 !important;
    margin: 0 !important;
    width: 100%;
    box-sizing: border-box;
    border: 0 !important;
    border-top: 1px solid var(--wechat-real-line, #e2e7ed) !important;
    border-radius: 0 !important;
    background: var(--wechat-real-composer-bg, #f7f8fa) !important;
    color: var(--wechat-real-text, #334452);
    box-shadow: none !important;
    max-height: min(40vh, 310px);
    min-height: 0;
    flex-shrink: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
}
#chat-page[data-wechat-real-preset-kind="qq"]:not(#lovemi-fg):not(#lovemi-fg) :is(#emoji-panel.show, #chat-more-panel.show, #qq-chat-voice-panel:not([hidden])) { animation: qq-chat-dock-in 180ms ease-out; }
#chat-page[data-wechat-real-preset-kind="qq"]:not(#lovemi-fg):not(#lovemi-fg) #chat-more-panel { padding: 16px 12px !important; }
#chat-page[data-wechat-real-preset-kind="qq"]:not(#lovemi-fg):not(#lovemi-fg) .chat-more-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px 10px; }
#chat-page[data-wechat-real-preset-kind="qq"]:not(#lovemi-fg):not(#lovemi-fg) .chat-more-item {
    padding: 0;
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
    gap: 7px;
}
#chat-page[data-wechat-real-preset-kind="qq"]:not(#lovemi-fg):not(#lovemi-fg) .chat-more-icon {
    width: 48px;
    height: 48px;
    background: var(--wechat-real-input-bg, #e7edf5) !important;
    color: var(--wechat-real-accent, #0078d4) !important;
    border: 0;
    border-radius: 14px;
    box-shadow: none;
}
#chat-page[data-wechat-real-preset-kind="qq"]:not(#lovemi-fg):not(#lovemi-fg) .chat-more-icon svg { width: 26px; height: 26px; }
#chat-page[data-wechat-real-preset-kind="qq"]:not(#lovemi-fg):not(#lovemi-fg) .chat-more-label { color: var(--wechat-real-muted, #7c8b99) !important; }
#chat-page[data-wechat-real-preset-kind="qq"]:not(#lovemi-fg):not(#lovemi-fg) #qq-chat-voice-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    height: clamp(180px, 34vh, 280px);
    padding: 18px 12px 12px;
    gap: 10px;
}
#chat-page[data-wechat-real-preset-kind="qq"]:not(#lovemi-fg):not(#lovemi-fg) #qq-chat-voice-title { font-size: 15px; line-height: 1.5; }
#chat-page[data-wechat-real-preset-kind="qq"]:not(#lovemi-fg):not(#lovemi-fg) #wechat-real-voice-hold {
    flex: 0 0 104px;
    width: 104px;
    height: 104px;
    min-height: 104px;
    padding: 0;
    border: 3px solid var(--wechat-real-input-bg, #cce8fa);
    border-radius: 50%;
    background: var(--wechat-real-bubble-out, #0078d4);
    color: transparent;
    font-size: 0;
    position: relative;
    box-shadow: none;
}
#chat-page[data-wechat-real-preset-kind="qq"]:not(#lovemi-fg):not(#lovemi-fg) #wechat-real-voice-hold::before {
    content: '';
    position: absolute;
    width: 26px;
    height: 42px;
    left: calc(50% - 13px);
    top: 19px;
    border: 2px solid #fff;
    border-radius: 14px;
    box-sizing: border-box;
}
#chat-page[data-wechat-real-preset-kind="qq"]:not(#lovemi-fg):not(#lovemi-fg) #wechat-real-voice-hold::after {
    content: '';
    position: absolute;
    width: 44px;
    height: 45px;
    left: calc(50% - 22px);
    top: 32px;
    border: 2px solid #fff;
    border-top: 0;
    border-radius: 0 0 23px 23px;
    background: linear-gradient(#fff, #fff) center bottom / 2px 11px no-repeat;
    box-sizing: border-box;
}
#chat-page[data-wechat-real-preset-kind="qq"]:not(#lovemi-fg):not(#lovemi-fg) #wechat-real-voice-hold.is-recording { background: #005ca8; }
#chat-page[data-wechat-real-preset-kind="qq"]:not(#lovemi-fg):not(#lovemi-fg) #wechat-real-voice-hold.is-canceling { background: #ad424b; }
#chat-page[data-wechat-real-preset-kind="qq"]:not(#lovemi-fg):not(#lovemi-fg) #wechat-real-voice-status { padding: 0; font-size: 12px; color: var(--wechat-real-muted, #7c8b99); }
#chat-page[data-wechat-real-preset-kind="qq"]:not(#lovemi-fg):not(#lovemi-fg) #wechat-real-voice-status.is-error { color: #b44141; }
#chat-page[data-wechat-real-preset-kind="qq"]:not(#lovemi-fg):not(#lovemi-fg) #wechat-real-voice-settings { padding: 0 10px; }
#chat-page[data-wechat-real-preset-kind="qq"].voice-call-mode #qq-chat-toolbar { display: none !important; }
@keyframes qq-chat-dock-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@media (max-height: 520px) {
    #chat-page[data-wechat-real-preset-kind="qq"]:not(#lovemi-fg):not(#lovemi-fg) #qq-chat-voice-panel { height: 170px; padding: 8px; gap: 5px; }
    #chat-page[data-wechat-real-preset-kind="qq"]:not(#lovemi-fg):not(#lovemi-fg) :is(#emoji-panel, #chat-more-panel) { max-height: 35vh; }
}
@media (prefers-reduced-motion: reduce) {
    #chat-page[data-wechat-real-preset-kind="qq"]:not(#lovemi-fg):not(#lovemi-fg) :is(#emoji-panel.show, #chat-more-panel.show, #qq-chat-voice-panel:not([hidden])) { animation: none; }
}
