/* 仿微信会话页 */
:root {
    --keyboard-inset: 0px;
    --wx-bg: #ededed;
    --wx-bar: #f7f7f7;
    --wx-border: #d9d9d9;
    --wx-green: #95ec69;
    --wx-bubble-other: #fff;
    --wx-text: #111;
    --wx-sub: #888;
    --wx-link: #576b95;
    --wx-inputbar-stack: 56px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", sans-serif;
    background: var(--wx-bg);
    color: var(--wx-text);
    -webkit-tap-highlight-color: transparent;
}

.wx-page {
    max-width: 480px;
    margin: 0 auto;
    min-height: 100%;
    display: flex;
    flex-direction: column;
    padding-bottom: calc(var(--wx-inputbar-stack) + env(safe-area-inset-bottom, 0px) + var(--keyboard-inset, 0px));
}

.wx-header {
    flex-shrink: 0;
    height: 44px;
    padding-top: env(safe-area-inset-top, 0);
    background: var(--wx-bar);
    border-bottom: 1px solid var(--wx-border);
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.04);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    padding-left: 8px;
    padding-right: 8px;
}

.wx-back {
    position: absolute;
    left: 4px;
    top: 50%;
    transform: translateY(-50%);
    padding: 8px;
    color: var(--wx-link);
    text-decoration: none;
    display: flex;
    align-items: center;
}

.wx-back svg { display: block; }

.wx-title-wrap {
    text-align: center;
    max-width: 70%;
}

.wx-title {
    font-size: 17px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.wx-subtitle {
    font-size: 11px;
    color: var(--wx-sub);
    margin-top: 1px;
}

.wx-menu {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    padding: 8px;
    background: none;
    border: none;
    cursor: pointer;
    color: #333;
}

.wx-msgs {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 12px 10px 16px;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
}

.wx-scroll-sentinel {
    width: 100%;
    height: 1px;
    margin: 0;
    padding: 0;
    flex-shrink: 0;
    pointer-events: none;
    opacity: 0;
}

.wx-load-more {
    text-align: center;
    font-size: 12px;
    color: #999;
    padding: 6px 4px 10px;
}

.wx-load-more-inner {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    vertical-align: middle;
}

.wx-load-spinner {
    flex-shrink: 0;
    color: #999;
    animation: wx-spin 0.65s linear infinite;
}

@keyframes wx-spin {
    to { transform: rotate(360deg); }
}

.wx-load-end {
    text-align: center;
    font-size: 12px;
    color: #bbb;
    padding: 4px 4px 8px;
}

.wx-hidden {
    display: none !important;
}

.wx-time-divider {
    text-align: center;
    font-size: 12px;
    color: #fff;
    margin: 16px auto;
    padding: 2px 10px;
    line-height: 1.5;
    display: table;
    max-width: 92%;
    background: rgba(0, 0, 0, 0.18);
    border-radius: 4px;
}

.wx-row {
    display: flex;
    margin-bottom: 12px;
    align-items: flex-start;
}

.wx-row.me { flex-direction: row-reverse; }

.wx-ava {
    width: 40px;
    height: 40px;
    border-radius: 4px;
    object-fit: cover;
    flex-shrink: 0;
}

.wx-row.me .wx-ava { margin-left: 8px; }
.wx-row.other .wx-ava { margin-right: 8px; }

.wx-bubble-wrap {
    max-width: 75%;
}

.wx-name {
    font-size: 12px;
    margin-bottom: 4px;
    padding-left: 2px;
    font-weight: 500;
}

.wx-name-tone-0 { color: #576b95; }
.wx-name-tone-1 { color: #c08727; }
.wx-name-tone-2 { color: #9070b0; }
.wx-name-tone-3 { color: #2f8f6d; }

.wx-row.me .wx-name { display: none; }

.wx-bubble {
    padding: 9px 12px;
    border-radius: 6px;
    font-size: 16px;
    line-height: 1.45;
    word-break: break-word;
    position: relative;
    overflow: visible;
}

.wx-row.other .wx-bubble::before {
    content: '';
    position: absolute;
    left: -4px;
    top: 14px;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 4px 5px 4px 0;
    border-color: transparent #fff transparent transparent;
}

.wx-row.me .wx-bubble::before {
    content: '';
    position: absolute;
    right: -4px;
    top: 14px;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 4px 0 4px 5px;
    border-color: transparent transparent transparent #95ec69;
}

.wx-bubble:has(.chat-img)::before {
    display: none;
}

.wx-row.other .wx-bubble {
    background: var(--wx-bubble-other);
    border: 1px solid #ebebeb;
    border-radius: 4px 6px 6px 6px;
}

.wx-row.me .wx-bubble {
    background: var(--wx-green);
    border: 1px solid #7acc50;
    border-radius: 6px 4px 6px 6px;
}

.wx-bubble img.chat-img {
    display: block;
    max-width: 200px;
    border-radius: 4px;
    vertical-align: middle;
    cursor: pointer;
}

.wx-inputbar {
    position: fixed;
    left: 0;
    right: 0;
    margin: 0 auto;
    bottom: calc(env(safe-area-inset-bottom, 0px) + var(--keyboard-inset, 0px));
    width: 100%;
    max-width: 480px;
    z-index: 100;
    flex-shrink: 0;
    background: var(--wx-bar);
    border-top: 1px solid var(--wx-border);
    box-shadow: 0 -1px 0 rgba(0, 0, 0, 0.04);
    padding: 8px 8px calc(8px + env(safe-area-inset-bottom, 0px));
    display: flex;
    align-items: flex-end;
    gap: 6px;
    box-sizing: border-box;
}

.wx-icon-btn {
    width: 36px;
    height: 36px;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #444;
}

.wx-icon-btn svg { display: block; }

.wx-input-wrap {
    flex: 1;
    background: #fff;
    border: 1px solid var(--wx-border);
    border-radius: 6px;
    min-height: 36px;
    max-height: 120px;
    overflow-y: auto;
}

#msgInput {
    width: 100%;
    border: none;
    outline: none;
    resize: none;
    font-size: 16px;
    line-height: 22px;
    padding: 7px 10px;
    font-family: inherit;
    background: transparent;
}

.wx-send-hint {
    font-size: 11px;
    color: var(--wx-sub);
    padding: 0 4px 4px;
    text-align: center;
    margin-bottom: calc(var(--wx-inputbar-stack) - 4px);
}

.wx-lightbox {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 2600;
    background: rgba(0, 0, 0, 0.92);
    align-items: center;
    justify-content: center;
    flex-direction: column;
    padding: env(safe-area-inset-top, 0px) 12px env(safe-area-inset-bottom, 0px);
}

.wx-lightbox.show {
    display: flex;
}

.wx-lightbox-inner {
    max-width: 100%;
    max-height: 88vh;
}

.wx-lightbox-inner img {
    display: block;
    max-width: 100%;
    max-height: 85vh;
    object-fit: contain;
    margin: 0 auto;
}

.wx-lightbox-close {
    position: absolute;
    top: calc(8px + env(safe-area-inset-top, 0px));
    right: 12px;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
}

/* 弹层 */
.wx-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.55);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.wx-overlay.show { display: flex; }

.wx-sheet {
    background: #fff;
    border-radius: 12px;
    max-width: 320px;
    width: 100%;
    padding: 20px 18px 16px;
    text-align: center;
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
}

.wx-sheet h2 {
    margin: 0 0 10px;
    font-size: 18px;
    font-weight: 600;
}

.wx-sheet p.desc {
    margin: 0 0 14px;
    font-size: 14px;
    color: #555;
    line-height: 1.5;
    text-align: left;
}

.wx-qr-box {
    margin: 12px auto;
    padding: 10px;
    background: #fafafa;
    border-radius: 8px;
    display: inline-block;
}

.wx-qr-box img {
    display: block;
    max-width: 220px;
    height: auto;
    margin: 0 auto;
}

.wx-share-link {
    font-size: 12px;
    word-break: break-all;
    color: var(--wx-link);
    text-align: left;
    margin: 10px 0;
    padding: 8px;
    background: #f0f0f0;
    border-radius: 6px;
}

.wx-sheet-actions {
    margin-top: 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.wx-btn {
    padding: 10px 16px;
    border-radius: 8px;
    border: none;
    font-size: 15px;
    cursor: pointer;
}

.wx-btn-primary {
    background: #07c160;
    color: #fff;
}

.wx-btn-ghost {
    background: #f2f2f2;
    color: #333;
}

.wx-btn-text {
    background: none;
    color: var(--wx-link);
    font-size: 13px;
}

.wx-close-sheet {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 32px;
    height: 32px;
    border: none;
    background: #eee;
    border-radius: 50%;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wx-toast {
    position: fixed;
    left: 50%;
    bottom: calc(100px + env(safe-area-inset-bottom, 0px) + var(--keyboard-inset, 0px));
    transform: translateX(-50%);
    background: rgba(0,0,0,.78);
    color: #fff;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 14px;
    z-index: 3000;
    display: none;
    max-width: 90%;
    text-align: center;
}

.wx-overlay--mandatory {
    background: rgba(0, 0, 0, 0.62);
}

.wx-sheet--poster {
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
}

.wx-poster-lock-hint {
    margin: 0 0 10px;
    padding: 8px 10px;
    font-size: 12px;
    color: #b85a00;
    background: #fff7e6;
    border-radius: 8px;
    text-align: center;
    line-height: 1.45;
}

.wx-privacy-foot {
    text-align: center;
    font-size: 11px;
    color: #888;
    padding: 6px 12px calc(14px + env(safe-area-inset-bottom, 0px));
    margin: 0;
}

.wx-privacy-foot a {
    color: var(--wx-link);
    text-decoration: none;
}

.wx-toast.show { display: block; }
