/* Simulation supplies window defaults. Explicit local styles override only
   their own selectors/properties; offline modes keep a separate surface. */
#chat-page[data-wechat-real-preset="1"]:not(#lovemi-fg):not(#lovemi-fg) {
    color: var(--wechat-real-text, #191919);
    --chat-text: var(--wechat-real-text, #191919);
    --chat-text-soft: var(--wechat-real-text, #191919);
    --chat-line: var(--wechat-real-line, #dedede);
    --chat-glass-bg: var(--wechat-real-composer-bg, #f7f7f7);
    --chat-shadow: none;
    --chat-radius-lg: 0px;
    --wechat-real-bubble-paint: var(--wechat-real-bubble-in, #fff);
    --wechat-real-bubble-ink: var(--wechat-real-bubble-text, #191919);
    --wechat-real-tail-left: -4px;
    --wechat-real-tail-right: auto;
}

#chat-page[data-wechat-real-preset="1"]:not([data-wechat-exclusive-has-bg="1"]):not(#lovemi-fg):not(#lovemi-fg) {
    background-color: var(--wechat-real-chat-bg, #ededed) !important;
}

/* A card-only JSON keeps the global wallpaper. An explicitly authored local
   background rule has higher priority; a private uploaded background stays inline. */
html.wechat-global-bg-on #chat-page[data-wechat-real-preset="1"]:not([data-wechat-exclusive-has-bg="1"]):not(#lovemi-fg):not(#lovemi-fg) {
    background-image: var(--wechat-global-bg-image) !important;
    background-size: cover !important;
    background-position: center !important;
    background-repeat: no-repeat !important;
}

#chat-page[data-wechat-real-preset="1"]:not(#lovemi-fg):not(#lovemi-fg) > .status-bar,
#chat-page[data-wechat-real-preset="1"]:not(#lovemi-fg):not(#lovemi-fg) > .chat-header {
    background: var(--wechat-real-header-bg, #ededed) !important;
    color: var(--wechat-real-text, #191919) !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}

#chat-page[data-wechat-real-preset="1"]:not(#lovemi-fg):not(#lovemi-fg) > .chat-header {
    margin: 0 !important;
    padding: 3px 8px !important;
    min-height: 48px;
    box-sizing: border-box;
    border-bottom: 1px solid var(--wechat-real-line, #dedede) !important;
}

#chat-page[data-wechat-real-preset="1"]:not(#lovemi-fg):not(#lovemi-fg) > .status-bar :is(.status-left, .status-icon, .status-icon-svg) {
    color: var(--wechat-real-muted, #888) !important;
}

#chat-page[data-wechat-real-preset="1"]:not(#lovemi-fg):not(#lovemi-fg) .chat-header-title-cluster { gap: 5px; }
#chat-page[data-wechat-real-preset="1"]:not(#lovemi-fg):not(#lovemi-fg) #chat-contact-name {
    color: var(--wechat-real-text, #191919) !important;
    font-weight: 600;
}
#chat-page[data-wechat-real-preset="1"]:not(#lovemi-fg):not(#lovemi-fg) .chat-header :is(.back-btn, .chat-header-btn) {
    width: 40px;
    height: 44px;
    flex-shrink: 0;
    padding: 7px;
    background: transparent !important;
    color: var(--wechat-real-text, #191919) !important;
    border: 0 !important;
    border-radius: 4px !important;
    box-shadow: none !important;
    transition: background-color 120ms ease-out;
}
#chat-page[data-wechat-real-preset="1"]:not(#lovemi-fg):not(#lovemi-fg) .chat-header .back-btn { margin-right: 2px; }
#chat-page[data-wechat-real-preset="1"]:not(#lovemi-fg):not(#lovemi-fg) .chat-header-buttons { margin-left: 2px; }
#chat-page[data-wechat-real-preset="1"]:not(#lovemi-fg):not(#lovemi-fg) .chat-header-settings-icon { display: none; }
#chat-page[data-wechat-real-preset="1"]:not(#lovemi-fg):not(#lovemi-fg) .chat-header-btn::after {
    content: '';
    width: 25px;
    height: 5px;
    background: radial-gradient(circle, currentColor 2px, transparent 2.5px) 0 0 / 9px 5px repeat-x;
}
.wechat-real-group-count[hidden] { display: none !important; }
#chat-page[data-wechat-real-preset="1"]:not(#lovemi-fg):not(#lovemi-fg) .wechat-real-group-count {
    color: var(--wechat-real-text, #191919);
    font-size: calc(18px * var(--theme-user-font-scale, 1) * var(--wechat-user-font-scale, 1));
    line-height: 1.5;
    flex: 0 0 auto;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}
#chat-page[data-wechat-real-preset="1"][data-is-group="1"] .chat-char-presence { display: none !important; }

#chat-page[data-wechat-real-preset="1"]:not(#lovemi-fg):not(#lovemi-fg) :is(.chat-main-stack, .chat-content) { background: transparent !important; }
/* Reserve space inside the scroll area for both the last bubble and its receipt. */
#chat-page[data-wechat-real-preset="1"]:not(#lovemi-fg):not(#lovemi-fg) .chat-content { padding: 14px 12px 24px; gap: 16px; }
#chat-page[data-wechat-real-preset="1"]:not(#lovemi-fg):not(#lovemi-fg) .chat-message { gap: 10px; }
#chat-page[data-wechat-real-preset="1"]:not(#lovemi-fg):not(#lovemi-fg) .chat-message-avatar {
    box-shadow: none !important;
}
/* Respect each side's saved size; a custom shape retains the avatar module's
   complete geometry (notably the rectangle's width/height ratio and clipping). */
#chat-page[data-wechat-real-preset="1"]:not(#lovemi-fg):not(#lovemi-fg) .other-message:not(.chat-message--offline-flow) > .chat-message-avatar {
    width: var(--chat-char-avatar-size, 40px) !important;
    height: var(--chat-char-avatar-size, 40px) !important;
}
#chat-page[data-wechat-real-preset="1"]:not(#lovemi-fg):not(#lovemi-fg) .my-message:not(.chat-message--offline-flow) > .chat-message-avatar {
    width: var(--chat-user-avatar-size, 40px) !important;
    height: var(--chat-user-avatar-size, 40px) !important;
}
#chat-page[data-wechat-real-preset="1"]:not([data-char-avatar-shape]):not(#lovemi-fg):not(#lovemi-fg) .other-message:not(.chat-message--offline-flow) > .chat-message-avatar,
#chat-page[data-wechat-real-preset="1"]:not([data-user-avatar-shape]):not(#lovemi-fg):not(#lovemi-fg) .my-message:not(.chat-message--offline-flow) > .chat-message-avatar { border-radius: var(--wechat-real-avatar-radius, 5px) !important; }
#chat-page[data-wechat-real-preset="1"]:not([data-char-avatar-shape]):not(#lovemi-fg):not(#lovemi-fg) .other-message:not(.chat-message--offline-flow) > .chat-message-avatar .chat-avatar-img,
#chat-page[data-wechat-real-preset="1"]:not([data-user-avatar-shape]):not(#lovemi-fg):not(#lovemi-fg) .my-message:not(.chat-message--offline-flow) > .chat-message-avatar .chat-avatar-img { border-radius: inherit !important; }
#chat-page[data-wechat-real-preset="1"]:not(#lovemi-fg):not(#lovemi-fg) .chat-message-content { gap: 4px; }
#chat-page[data-wechat-real-preset="1"]:not(#lovemi-fg):not(#lovemi-fg) :is(.chat-message-name, .chat-message-timestamp, .chat-time-divider, .chat-read-receipt-time) {
    color: var(--wechat-real-muted, #888) !important;
    text-shadow: none !important;
}

/* Limit bubble painting to ordinary text/voice; photo, transfer, red packet and
   other independently rendered cards keep their own layout and semantics. */
#chat-page[data-wechat-real-preset="1"]:not(#lovemi-fg):not(#lovemi-fg) .chat-message-bubble:is(:not([class*="chat-message-bubble--"]), .chat-message-bubble--motion-dialogue):not(:has(img, video, [class*="-card"], .chat-transfer-bubble, .chat-location-bubble, .chat-photo-flip-root, .wechat-polaroid-wrap, .art-vibe)),
#chat-page[data-wechat-real-preset="1"]:not(#lovemi-fg):not(#lovemi-fg) .chat-message-bubble--voice {
    color: var(--wechat-real-bubble-ink) !important;
    background: var(--wechat-real-bubble-paint) !important;
    border: 0 !important;
    border-radius: var(--wechat-real-bubble-radius, 5px) !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    padding: 10px 12px;
    min-height: 40px;
    max-width: 100%;
    overflow: visible;
    line-height: 1.5;
}
#chat-page[data-wechat-real-preset="1"]:not(#lovemi-fg):not(#lovemi-fg) .my-message {
    --wechat-real-bubble-paint: var(--wechat-real-bubble-out, #95ec69);
    --wechat-real-bubble-ink: var(--wechat-real-bubble-out-text, #13251a);
    --wechat-real-tail-left: auto;
    --wechat-real-tail-right: -4px;
}
#chat-page[data-wechat-real-preset="1"]:not(#lovemi-fg):not(#lovemi-fg) .chat-message-bubble:is(:not([class*="chat-message-bubble--"]), .chat-message-bubble--motion-dialogue):not(:has(img, video, [class*="-card"], .chat-transfer-bubble, .chat-location-bubble, .chat-photo-flip-root, .wechat-polaroid-wrap, .art-vibe))::before {
    content: '';
    position: absolute;
    display: block !important;
    top: 14px;
    left: var(--wechat-real-tail-left);
    right: var(--wechat-real-tail-right);
    width: 8px;
    height: 8px;
    border: 0;
    border-radius: 1px;
    background: inherit;
    transform: rotate(45deg);
    box-shadow: none;
    pointer-events: none;
    z-index: -1;
}

#chat-page[data-wechat-real-preset="1"]:not(#lovemi-fg):not(#lovemi-fg) .chat-bottom-composer {
    margin: 0 !important;
    background: var(--wechat-real-composer-bg, #f7f7f7) !important;
    border-radius: 0 !important;
}
#chat-page[data-wechat-real-preset="1"]:not([data-chat-keyboard-open="1"]):not(#lovemi-fg):not(#lovemi-fg) .chat-bottom-composer {
    padding-bottom: var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px));
}
#chat-page[data-wechat-real-preset="1"]:not(#lovemi-fg):not(#lovemi-fg) .chat-input-area {
    --chat-tool-btn: 32px;
    --chat-tool-icon: 25px;
    margin: 0 !important;
    padding: 6px 7px !important;
    gap: 3px !important;
    align-items: flex-end;
    background: var(--wechat-real-composer-bg, #f7f7f7) !important;
    color: var(--wechat-real-text, #191919) !important;
    border: 0 !important;
    border-top: 1px solid var(--wechat-real-line, #dedede) !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}
#chat-page[data-wechat-real-preset="1"]:not(#lovemi-fg):not(#lovemi-fg) .chat-function-btn {
    width: 32px;
    height: 44px;
    border: 0 !important;
    border-radius: 4px !important;
    background: transparent !important;
    color: var(--wechat-real-text, #191919) !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    transition: background-color 120ms ease-out;
}
#chat-page[data-wechat-real-preset="1"]:not(#lovemi-fg):not(#lovemi-fg) .chat-input {
    flex: 1 1 0;
    min-width: 0;
    min-height: 44px;
    box-sizing: border-box;
    padding: 10px 8px;
    border: 0 !important;
    border-radius: 5px !important;
    background: var(--wechat-real-input-bg, #fff) !important;
    color: var(--wechat-real-text, #191919) !important;
    caret-color: #07a650;
    box-shadow: none !important;
    line-height: 1.5;
}
#chat-page[data-wechat-real-preset="1"] .chat-input::placeholder { color: var(--wechat-real-muted, #888) !important; }
#chat-page[data-wechat-real-preset="1"]:not(#lovemi-fg):not(#lovemi-fg) .send-btn {
    width: 38px;
    height: 40px;
    margin-bottom: 2px;
    background: #07a650 !important;
    color: #fff !important;
    border-radius: 5px !important;
}
#chat-page[data-wechat-real-preset="1"]:not(#lovemi-fg):not(#lovemi-fg) .more-btn > svg { display: none; }
#chat-page[data-wechat-real-preset="1"]:not(#lovemi-fg):not(#lovemi-fg) .more-btn::after {
    content: '';
    width: 25px;
    height: 25px;
    box-sizing: border-box;
    border: 1.7px solid currentColor;
    border-radius: 50%;
    background: linear-gradient(currentColor, currentColor) center / 13px 1.7px no-repeat, linear-gradient(currentColor, currentColor) center / 1.7px 13px no-repeat;
}
#chat-page[data-wechat-real-preset="1"]:not(#lovemi-fg):not(#lovemi-fg) :is(.chat-more-panel, .emoji-panel) {
    background: var(--wechat-real-composer-bg, #f7f7f7) !important;
    color: var(--wechat-real-text, #191919) !important;
    box-shadow: none !important;
    border-radius: 0 !important;
}

/* Voice controls default to hidden even before JS initializes. */
:is(#wechat-real-voice-toggle, #wechat-real-voice-hold, #wechat-real-voice-status, #wechat-real-voice-settings)[hidden] { display: none !important; }
#chat-page:not([data-wechat-real-preset="1"]) :is(#wechat-real-voice-toggle, #wechat-real-voice-hold, #wechat-real-voice-status, #wechat-real-voice-settings) { display: none !important; }
#chat-page[data-wechat-real-preset="1"][data-wechat-real-voice="1"] #chat-input { display: none !important; }
#chat-page[data-wechat-real-preset="1"] #wechat-real-voice-hold {
    flex: 1 1 0;
    min-width: 0;
    height: 44px;
    border: 0;
    border-radius: 5px;
    padding: 5px;
    background: var(--wechat-real-input-bg, #fff);
    color: var(--wechat-real-text, #191919);
    font: inherit;
    font-weight: 600;
    white-space: nowrap;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    cursor: pointer;
}
#chat-page[data-wechat-real-preset="1"] #wechat-real-voice-hold.is-recording { background: var(--wechat-real-line, #dedede); }
#chat-page[data-wechat-real-preset="1"] #wechat-real-voice-hold.is-canceling { color: #c63535; }
#chat-page[data-wechat-real-preset="1"] #wechat-real-voice-status {
    padding: 7px 12px 2px;
    color: var(--wechat-real-muted, #666);
    font-size: 12px;
    line-height: 1.5;
    text-align: center;
}
#chat-page[data-wechat-real-preset="1"] #wechat-real-voice-settings {
    display: block;
    margin: 0 auto;
    padding: 5px 12px;
    border: 0;
    background: transparent;
    color: var(--wechat-real-text, #191919);
    font: inherit;
    font-size: 12px;
    text-decoration: underline;
    cursor: pointer;
}
#chat-page[data-wechat-real-preset="1"] :is(.chat-function-btn, #wechat-real-voice-hold):disabled { opacity: .45; cursor: default; }
#chat-page[data-wechat-real-preset="1"] :is(.chat-function-btn, .chat-header-btn, .back-btn, #wechat-real-voice-hold):focus-visible {
    outline: 2px solid #07a650 !important;
    outline-offset: -2px;
}
#chat-page[data-wechat-real-preset="1"] :is(.chat-function-btn, .chat-header-btn, .back-btn, #wechat-real-voice-hold):not(:disabled):active { opacity: .65; }
@media (prefers-reduced-motion: reduce) {
    #chat-page[data-wechat-real-preset="1"] :is(.chat-function-btn, .chat-header-btn, .back-btn) { transition: none !important; }
}
