/* ========== 变量与基础 ========== */
:root {
    --bg-page: #f0f2f5;
    --bg-header: #fff;
    --bg-bubble-user: #00c9a7;
    --bg-bubble-kf: #fff;
    --border-bubble-kf: #e8e8e8;
    --text-primary: #1a1a2e;
    --text-secondary: #666;
    --accent: #4361ee;
    --accent-hover: #3a56d4;
    --radius-sm: 12px;
    --radius-md: 16px;
    --radius-lg: 20px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --header-h: 48px;
    --bottom-h: 56px;
    --safe-top: env(safe-area-inset-top, 0);
    --safe-bottom: env(safe-area-inset-bottom, 0);
    --safe-left: env(safe-area-inset-left, 0);
    --safe-right: env(safe-area-inset-right, 0);
}

* { outline: none; -webkit-tap-highlight-color: rgba(0,0,0,0); box-sizing: border-box; }
input:focus, textarea:focus { outline: none; outline-offset: 0; }

body {
    margin: 0;
    padding: 0;
    font-size: 15px;
    background-color: var(--bg-page);
    font-family: "Microsoft YaHei", "PingFang SC", "Helvetica Neue", "宋体", Arial, sans-serif;
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
}

/* ========== 滚动条 ========== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb {
    background-color: rgba(0,0,0,0.18);
    border-radius: 10px;
}
::-webkit-scrollbar-track { background: transparent; }
::-ms-scrollbar { width: 6px; }
::-ms-scrollbar-thumb { background-color: rgba(0,0,0,0.2); border-radius: 10px; }

/* ========== 主布局 ========== */
.content {
    width: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    overflow: hidden;
    padding-top: var(--safe-top);
    padding-bottom: var(--safe-bottom);
    padding-left: var(--safe-left);
    padding-right: var(--safe-right);
}

.contentTop {
    width: 100%;
    height: var(--header-h);
    min-height: 44px;
    line-height: var(--header-h);
    text-align: center;
    font-size: 17px;
    font-weight: 600;
    background: var(--bg-header);
    color: var(--text-primary);
    border: none;
    border-bottom: 1px solid rgba(0,0,0,0.06);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.contentMiddle {
    width: 100%;
    height: calc(100vh - var(--header-h) - var(--bottom-h) - 30px);
    height: calc(100dvh - var(--header-h) - var(--bottom-h) - 30px);
    min-height: 120px;
    padding: 12px 10px 24px;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* ========== 附加链接区 ========== */
.contentMiddle2 {
    position: fixed;
    z-index: 2;
    bottom: calc(var(--bottom-h) + var(--safe-bottom) + 4px);
    left: var(--safe-left);
    width: auto;
    max-width: calc(100% - 20px - var(--safe-left) - var(--safe-right));
    height: 38px;
    overflow: hidden;
    padding: 0 0 0 12px;
    border: 1px solid rgba(0,0,0,0.08);
    border-right: none;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    background: var(--bg-header);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    box-shadow: var(--shadow-sm);
}
.contentMiddle2_bt {
    float: left;
    margin: 6px 10px 0 0;
    padding: 6px 12px;
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: var(--radius-sm);
    line-height: 22px;
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.2s, color 0.2s, box-shadow 0.2s;
}
.contentMiddle2_bt:hover {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
    box-shadow: 0 2px 8px rgba(67,97,238,0.35);
}

/* ========== 底部输入区 ========== */
.contentBottom {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 3;
    width: 100%;
    height: var(--bottom-h);
    min-height: 50px;
    padding-bottom: var(--safe-bottom);
    padding-left: calc(10px + var(--safe-left));
    padding-right: calc(10px + var(--safe-right));
    overflow: hidden;
    background: var(--bg-header);
    font-size: 15px;
    color: var(--text-secondary);
    border-top: 1px solid rgba(0,0,0,0.06);
    box-shadow: 0 -2px 10px rgba(0,0,0,0.04);
}

.textContent {
    width: calc(100% - 130px);
    height: 40px;
    min-height: 40px;
    max-height: 120px;
    margin: 5px 0 5px 0;
    padding: 10px 14px;
    resize: none;
    font-size: 14px;
    line-height: 1.4;
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: var(--radius-md);
    background: var(--bg-page);
    color: var(--text-primary);
    transition: border-color 0.2s, box-shadow 0.2s;
}
.textContent::placeholder { color: #999; }
.textContent:hover { border-color: rgba(67,97,238,0.3); }
.textContent:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(67,97,238,0.12);
}

.sendTextButton {
    position: absolute;
    z-index: 2;
    top: 5px;
    right: calc(10px + var(--safe-right));
    width: 54px;
    height: 40px;
    line-height: 40px;
    text-align: center;
    border-radius: var(--radius-md);
    background: var(--accent);
    color: #fff;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: background 0.2s, transform 0.1s;
    border: none;
}
.sendTextButton:hover { background: var(--accent-hover); }
.sendTextButton:active { transform: scale(0.98); }

.sendPictureButton {
    position: absolute;
    z-index: 1;
    top: 5px;
    right: calc(74px + var(--safe-right));
    width: 44px;
    height: 40px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    cursor: pointer;
    object-fit: cover;
}
.sendPicture {
    position: absolute;
    z-index: 2;
    top: 5px;
    right: calc(74px + var(--safe-right));
    width: 44px;
    height: 40px;
    border: none;
    border-radius: var(--radius-sm);
    opacity: 0;
    cursor: pointer;
}

/* ========== 消息气泡 ========== */
.messageStyle {
    margin: 10px 0;
    height: auto;
    overflow: hidden;
    opacity: 0;
    animation: fadeIn 0.35s ease-out forwards;
    clear: both;
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.messageStyleLeft1 { float: left; width: 40px; flex-shrink: 0; }
.messageStyleLeft1P {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    object-fit: cover;
    display: block;
}
.messageStyleLeft2 {
    position: relative;
    float: left;
    margin: 0 0 0 12px;
    min-width: 20px;
    max-width: calc(100% - 70px);
}
.messageStyleLeft2T {
    padding: 10px 14px;
    background: var(--bg-bubble-kf);
    border: 1px solid var(--border-bubble-kf);
    border-radius: 4px var(--radius-md) var(--radius-md) var(--radius-md);
    text-overflow: ellipsis;
    white-space: pre-wrap;
    word-break: break-word;
    overflow-wrap: break-word;
    min-height: 20px;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}
.messageStyleLeft2T img { max-width: 100%; height: auto; vertical-align: middle; }

.messageStyleRight1 { float: right; width: 40px; flex-shrink: 0; }
.messageStyleRight1P {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    object-fit: cover;
    display: block;
}
.messageStyleRight2 {
    position: relative;
    float: right;
    margin: 0 12px 0 0;
    min-width: 20px;
    max-width: calc(100% - 70px);
    text-align: left;
}
.messageStyleRight2T {
    padding: 10px 14px;
    background: var(--bg-bubble-user);
    border-radius: var(--radius-md) 4px var(--radius-md) var(--radius-md);
    text-overflow: ellipsis;
    white-space: pre-wrap;
    word-break: break-word;
    overflow-wrap: break-word;
    min-height: 20px;
    font-size: 14px;
    line-height: 1.5;
    color: #fff;
    box-shadow: var(--shadow-sm);
}
.messageStyleRight2T img { max-width: 100%; height: auto; vertical-align: middle; }

.rightArrow {
    width: 0;
    height: 0;
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
    border-left: 10px solid var(--bg-bubble-user);
    position: absolute;
    top: 12px;
    right: -8px;
}
.leftArrow {
    width: 0;
    height: 0;
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
    border-right: 10px solid var(--bg-bubble-kf);
    position: absolute;
    top: 12px;
    left: -8px;
}

/* 咨询链接（与 JS 内联样式兼容，可覆盖） */
#msgzone span[id^="xz"] {
    color: #20c0c0;
    cursor: pointer;
    text-decoration: none;
    transition: color 0.2s;
}
#msgzone span[id^="xz"]:hover { color: var(--accent); }

/* ========== 响应式：小屏手机 (≤480px) ========== */
@media (max-width: 480px) {
    :root {
        --header-h: 46px;
        --bottom-h: 52px;
    }
    .contentTop {
        font-size: 16px;
        border-radius: 0 0 16px 16px;
    }
    .contentMiddle {
        padding: 10px 8px 20px;
        height: calc(100vh - var(--header-h) - var(--bottom-h) - 26px);
        height: calc(100dvh - var(--header-h) - var(--bottom-h) - 26px);
    }
    .contentMiddle2 {
        bottom: calc(var(--bottom-h) + var(--safe-bottom) + 2px);
        max-width: calc(100% - 16px - var(--safe-left) - var(--safe-right));
        height: 36px;
        padding: 0 0 0 10px;
    }
    .contentMiddle2_bt {
        padding: 5px 10px;
        font-size: 12px;
        margin: 5px 8px 0 0;
    }
    .contentBottom {
        padding-left: calc(8px + var(--safe-left));
        padding-right: calc(8px + var(--safe-right));
        min-height: 48px;
    }
    .textContent {
        width: calc(100% - 108px);
        padding: 8px 12px;
        font-size: 16px; /* 防 iOS 缩放 */
    }
    .sendPictureButton,
    .sendPicture {
        width: 40px;
        height: 40px;
        right: calc(58px + var(--safe-right));
    }
    .sendTextButton {
        width: 48px;
        right: calc(8px + var(--safe-right));
        height: 40px;
        line-height: 40px;
        font-size: 14px;
    }
    .messageStyleLeft1,
    .messageStyleRight1 { width: 36px; }
    .messageStyleLeft1P,
    .messageStyleRight1P { width: 36px; height: 36px; border-radius: 10px; }
    .messageStyleLeft2 { margin-left: 10px; max-width: calc(100% - 58px); }
    .messageStyleRight2 { margin-right: 10px; max-width: calc(100% - 58px); }
    .messageStyleLeft2T,
    .messageStyleRight2T { padding: 8px 12px; font-size: 14px; }
    .rightArrow { right: -6px; top: 10px; border-left-width: 8px; }
    .leftArrow { left: -6px; top: 10px; border-right-width: 8px; }
}

/* ========== 响应式：中等手机 (481px-767px) ========== */
@media (min-width: 481px) and (max-width: 767px) {
    .contentMiddle {
        padding: 12px 10px 24px;
    }
    .contentMiddle2 {
        padding: 0 0 0 12px;
    }
    .messageStyleLeft2 { max-width: calc(100% - 70px); }
    .messageStyleRight2 { max-width: calc(100% - 70px); }
}

/* ========== 响应式：平板 (768px-1023px) ========== */
@media (min-width: 768px) and (max-width: 1023px) {
    :root {
        --header-h: 50px;
        --bottom-h: 60px;
    }
    .contentTop {
        font-size: 18px;
        height: var(--header-h);
        line-height: var(--header-h);
    }
    .contentMiddle {
        padding: 16px 20px 30px;
        height: calc(100vh - var(--header-h) - var(--bottom-h) - 30px);
        height: calc(100dvh - var(--header-h) - var(--bottom-h) - 30px);
    }
    .contentMiddle2 {
        padding: 0 0 0 16px;
        height: 40px;
    }
    .contentMiddle2_bt {
        padding: 7px 14px;
        font-size: 14px;
        margin: 6px 12px 0 0;
    }
    .contentBottom {
        padding-left: calc(16px + var(--safe-left));
        padding-right: calc(16px + var(--safe-right));
        height: var(--bottom-h);
        min-height: 60px;
    }
    .textContent {
        width: calc(100% - 150px);
        height: 44px;
        padding: 12px 16px;
        font-size: 15px;
    }
    .sendPictureButton,
    .sendPicture {
        width: 48px;
        height: 44px;
        right: calc(84px + var(--safe-right));
        top: 8px;
    }
    .sendTextButton {
        width: 60px;
        height: 44px;
        line-height: 44px;
        right: calc(16px + var(--safe-right));
        top: 8px;
        font-size: 15px;
    }
    .messageStyleLeft1,
    .messageStyleRight1 { width: 44px; }
    .messageStyleLeft1P,
    .messageStyleRight1P { width: 44px; height: 44px; border-radius: 14px; }
    .messageStyleLeft2 { margin-left: 14px; max-width: 70%; }
    .messageStyleRight2 { margin-right: 14px; max-width: 70%; }
    .messageStyleLeft2T,
    .messageStyleRight2T { padding: 12px 16px; font-size: 15px; }
}

/* ========== 响应式：桌面电脑 (≥1024px) ========== */
@media (min-width: 1024px) {
    :root {
        --header-h: 56px;
        --bottom-h: 70px;
    }
    .contentTop {
        font-size: 20px;
        height: var(--header-h);
        line-height: var(--header-h);
        border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    }
    .contentMiddle {
        padding: 20px 24px 40px;
        height: calc(100vh - var(--header-h) - var(--bottom-h) - 30px);
        height: calc(100dvh - var(--header-h) - var(--bottom-h) - 30px);
    }
    .contentMiddle2 {
        padding: 0 0 0 20px;
        height: 44px;
    }
    .contentMiddle2_bt {
        padding: 8px 16px;
        font-size: 15px;
        margin: 7px 14px 0 0;
    }
    .contentBottom {
        padding-left: calc(24px + var(--safe-left));
        padding-right: calc(24px + var(--safe-right));
        height: var(--bottom-h);
        min-height: 70px;
    }
    .textContent {
        width: calc(100% - 180px);
        height: 50px;
        padding: 14px 18px;
        font-size: 15px;
    }
    .sendPictureButton,
    .sendPicture {
        width: 52px;
        height: 50px;
        right: calc(98px + var(--safe-right));
        top: 10px;
    }
    .sendTextButton {
        width: 70px;
        height: 50px;
        line-height: 50px;
        right: calc(24px + var(--safe-right));
        top: 10px;
        font-size: 16px;
    }
    .messageStyleLeft1,
    .messageStyleRight1 { width: 48px; }
    .messageStyleLeft1P,
    .messageStyleRight1P { width: 48px; height: 48px; border-radius: 16px; }
    .messageStyleLeft2 { margin-left: 16px; max-width: 75%; }
    .messageStyleRight2 { margin-right: 16px; max-width: 75%; }
    .messageStyleLeft2T,
    .messageStyleRight2T {
        padding: 14px 18px;
        font-size: 15px;
        line-height: 1.6;
    }
    .rightArrow {
        border-top-width: 10px;
        border-bottom-width: 10px;
        border-left-width: 12px;
        top: 14px;
        right: -10px;
    }
    .leftArrow {
        border-top-width: 10px;
        border-bottom-width: 10px;
        border-right-width: 12px;
        top: 14px;
        left: -10px;
    }
}

/* ========== 响应式：超大屏 (≥1440px) ========== */
@media (min-width: 1440px) {
    .contentMiddle {
        padding: 24px 32px 48px;
    }
    .contentMiddle2 {
        padding: 0 0 0 24px;
    }
    .contentBottom {
        padding-left: calc(32px + var(--safe-left));
        padding-right: calc(32px + var(--safe-right));
    }
    .textContent {
        width: calc(100% - 200px);
    }
    .sendPictureButton,
    .sendPicture {
        right: calc(108px + var(--safe-right));
    }
    .sendTextButton {
        right: calc(32px + var(--safe-right));
    }
    .messageStyleLeft2 { max-width: 70%; }
    .messageStyleRight2 { max-width: 70%; }
}
