/* 微信风格模板 */
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: -apple-system, 'PingFang SC', 'Microsoft YaHei', sans-serif;
    background: #ededed;
    color: #333;
    height: 100vh; height: 100dvh;
    overflow: hidden;
}

/* 登录页 */
.wx-login {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: #ededed; display: flex; align-items: center; justify-content: center;
}
.wx-login-box {
    background: #fff; padding: 2.5rem 2rem; border-radius: 8px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08); text-align: center;
    max-width: 360px; width: 90%;
}
.wx-logo { font-size: 3rem; margin-bottom: 1rem; }
.wx-login-box h2 { font-size: 1.3rem; color: #333; margin-bottom: 0.3rem; }
.wx-sub { font-size: 0.85rem; color: #999; margin-bottom: 1.5rem; }
.wx-input-group { margin-bottom: 0.8rem; }
.wx-input-group input {
    width: 100%; padding: 0.7rem 0.8rem; border: 1px solid #e0e0e0;
    border-radius: 6px; font-size: 0.95rem; outline: none;
}
.wx-input-group input:focus { border-color: #07c160; }
.wx-btn-primary {
    width: 100%; padding: 0.7rem; background: #07c160; color: #fff;
    border: none; border-radius: 6px; font-size: 1rem; cursor: pointer;
    margin-top: 0.5rem;
}
.wx-btn-primary:hover { background: #06ad56; }
.wx-btn-link {
    display: block; margin: 1rem auto 0; background: none; border: none;
    color: #576b95; font-size: 0.9rem; cursor: pointer;
}

/* 聊天页 */
.wx-chat { height: 100vh; height: 100dvh; display: flex; flex-direction: column; }
.wx-header {
    background: #ededed; border-bottom: 1px solid #d8d8d8;
    padding: 0.6rem 1rem; display: flex; align-items: center; gap: 0.8rem;
    min-height: 3rem;
}
.wx-back {
    background: none; border: none; font-size: 1.8rem; color: #333;
    cursor: pointer; line-height: 1; padding: 0 0.3rem;
}
.wx-title { flex: 1; display: flex; flex-direction: column; }
.wx-title span { font-size: 1rem; font-weight: 600; color: #333; }
.wx-title small { font-size: 0.75rem; color: #999; }
.wx-actions { display: flex; gap: 0.5rem; }
.wx-icon-btn {
    background: none; border: none; font-size: 1.1rem; cursor: pointer;
    padding: 0.3rem;
}

/* 消息区 */
.wx-messages {
    flex: 1; overflow-y: auto; padding: 1rem; background: #ededed;
}
.wx-msg {
    display: flex; gap: 0.5rem; margin-bottom: 1rem; align-items: flex-start;
}
.wx-msg.system { justify-content: center; }
.wx-msg.system .wx-bubble {
    display: inline-block;
    max-width: 100%;
    width: fit-content;
    background: rgba(0,0,0,0.1); color: #666; font-size: 0.8rem;
    border-radius: 4px; padding: 0.2rem 0.6rem;
}
.wx-avatar {
    width: 36px; height: 36px; border-radius: 4px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.9rem; color: #fff; font-weight: 600;
    background: linear-gradient(135deg, #667eea, #764ba2);
}
.wx-msg-body { display: flex; flex-direction: column; max-width: 70%; }
.wx-username { font-size: 0.75rem; color: #999; margin-bottom: 0.2rem; }
.wx-bubble {
    display: inline-block;
    max-width: 100%;
    width: fit-content;
    background: #fff; padding: 0.6rem 0.8rem; border-radius: 4px;
    font-size: 0.95rem; line-height: 1.5; word-break: break-word;
    position: relative;
}
.wx-bubble::before {
    content: ''; position: absolute; left: -5px; top: 10px;
    border: 5px solid transparent; border-right-color: #fff;
}
.wx-bubble img { max-width: 100%; border-radius: 4px; cursor: pointer; }
.wx-bubble video { max-width: 100%; border-radius: 4px; }
.wx-time { font-size: 0.7rem; color: #b2b2b2; margin-top: 0.2rem; }
.wx-loc { font-size: 0.7rem; color: #b2b2b2; margin-top: 0.1rem; }

/* 输入栏 */
.wx-input-bar {
    background: #f7f7f7; border-top: 1px solid #d8d8d8;
    padding: 0.5rem 0.8rem; display: flex; align-items: center; gap: 0.5rem;
}
.wx-input-icon {
    background: none; border: none; font-size: 1.3rem; cursor: pointer;
    padding: 0.2rem;
}
.wx-input-bar textarea {
    flex: 1; border: 1px solid #e0e0e0; border-radius: 6px;
    padding: 0.5rem 0.7rem; font-size: 0.95rem; resize: none;
    max-height: 100px; outline: none; font-family: inherit;
}
.wx-input-bar textarea:focus { border-color: #07c160; }
.wx-send {
    background: #07c160; color: #fff; border: none; border-radius: 6px;
    padding: 0.5rem 1rem; font-size: 0.9rem; cursor: pointer;
}
.wx-send:hover { background: #06ad56; }

/* 自己的消息：右对齐 */
.wx-msg.self {
    flex-direction: row-reverse;
}
.wx-msg.self .wx-msg-body {
    text-align: right;
}
.wx-msg.self .wx-bubble {
    display: inline-block;
    max-width: 100%;
    width: fit-content;
    background: #95ec69;
    color: #000;
}
.wx-msg.self .wx-bubble::before {
    left: auto;
    right: -5px;
    border-right-color: transparent;
    border-left-color: #95ec69;
}
.wx-msg.self .wx-username {
    text-align: right;
}

/* 修复气泡宽度自适应 */
.wx-msg-body {
    display: flex;
    flex-direction: column;
    max-width: 70%;
}
.wx-bubble {
    display: inline-block;
    max-width: 100%;
    width: fit-content;
}
.wx-msg.self .wx-msg-body {
    align-items: flex-end;
}
.wx-msg.self .wx-bubble::before {
    left: auto;
    right: -5px;
    border-right-color: transparent;
    border-left-color: #95ec69;
}

/* 美观滚动条 */
.wx-messages::-webkit-scrollbar { width: 6px; }
.wx-messages::-webkit-scrollbar-track { background: transparent; }
.wx-messages::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.15); border-radius: 3px; }
.wx-messages::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.25); }

/* ===== v20260904：修复自己消息换行左对齐 + 撤回/已读样式 ===== */
.wx-bubble { text-align: left; }
.wx-msg.self .wx-bubble { text-align: left; }
.wx-recall { color: #999; background: rgba(0,0,0,0.06); text-align: center; font-style: italic; }
.wx-read { font-size: 0.7rem; color: #b2b2b2; margin-top: 0.1rem; text-align: left; cursor: pointer; }
.wx-read:hover { color: #667eea; }


/* ===== v20260904h：手机端输入栏优化（图标/按钮缩小，给输入框让出宽度） ===== */
@media (max-width: 480px) {
    .wx-input-bar { padding: 0.4rem 0.45rem; gap: 0.25rem; }
    .wx-input-icon { font-size: 1.05rem; padding: 0.12rem; }
    .wx-input-bar textarea { padding: 0.42rem 0.6rem; font-size: 1rem; min-height: 2.1rem; }
    .wx-send { padding: 0.42rem 0.7rem; font-size: 0.85rem; }
}


/* ===== v20260904j：两行式输入栏（上：输入框+发送，下：功能图标） + 按住说话 + 登录页备案号流式 ===== */
.wx-login { flex-direction: column; justify-content: center; overflow-y: auto; }
.wx-icp { margin-top: 1.2rem; font-size: 12px; color: #aaa; text-align: center; padding: 0 12px; }
.wx-icp a { color: #aaa; text-decoration: none; }
.wx-input-bar { display: block; padding: 0.45rem 0.6rem 0.25rem; }
.wx-input-row { display: flex; align-items: center; gap: 0.5rem; }
.wx-input-row textarea {
    flex: 1; border: 1px solid #e0e0e0; border-radius: 8px; padding: 0.55rem 0.7rem;
    font-size: 0.95rem; resize: none; max-height: 100px; outline: none;
    font-family: inherit; background: #fff; min-width: 0;
}
.wx-send { flex-shrink: 0; border-radius: 8px; padding: 0.55rem 1.1rem; font-size: 0.95rem; }
.wx-toolbar { display: flex; justify-content: space-around; padding: 0.3rem 0.5rem 0.15rem; }
.wx-input-icon {
    background: none; border: none; font-size: 1.45rem; cursor: pointer;
    padding: 0.25rem 0.7rem; color: #333;
    -webkit-user-select: none; user-select: none; touch-action: none;
}
.wx-input-icon.recording { color: #e74c3c; transform: scale(1.15); }

@media (max-width: 480px) {
    .wx-input-bar { padding: 0.4rem 0.45rem 0.2rem; }
    .wx-input-row textarea { font-size: 1rem; padding: 0.5rem 0.6rem; }
    .wx-send { padding: 0.5rem 0.85rem; }
    .wx-input-icon { font-size: 1.35rem; padding: 0.2rem 0.6rem; }
    .wx-toolbar { padding: 0.25rem 0.2rem 0.1rem; }
}

/* ===== v20260904k：微信风格语音条 + 紧凑输入栏 + 禁止横向滚动 ===== */
.voice-msg {
    display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
    padding: 5px 10px; border-radius: 6px;
    -webkit-user-select: none; user-select: none; max-width: 210px;
    vertical-align: middle;
}
.voice-play { font-size: 11px; color: #333; width: 14px; text-align: center; flex-shrink: 0; }
.voice-wave { display: inline-flex; align-items: center; gap: 2px; height: 22px; }
.voice-wave i { width: 3px; border-radius: 2px; background: #07c160; }
.wx-msg.self .voice-wave i { background: #0a8f4e; }
.voice-wave.playing i { animation: voicewave 0.8s ease-in-out infinite; }
@keyframes voicewave { 0%,100%{transform:scaleY(0.5);} 50%{transform:scaleY(1.2);} }
.voice-dur { font-size: 11px; color: #888; flex-shrink: 0; min-width: 28px; text-align: right; }

/* 图标行更紧凑 */
.wx-toolbar { justify-content: space-evenly; padding: 0.2rem 0.2rem 0.1rem; }
.wx-input-icon { padding: 0.15rem 0.5rem; }

/* 禁止横向滚动 + 气泡更紧凑 */
html, body, .wx-chat, .wx-messages, .wx-input-bar { max-width: 100%; overflow-x: hidden; }
.wx-bubble { max-width: 100%; word-break: break-word; padding: 0.45rem 0.6rem; font-size: 0.9rem; }

@media (max-width: 480px) {
    .wx-toolbar { padding: 0.15rem 0 0.05rem; }
    .wx-input-icon { font-size: 1.25rem; padding: 0.1rem 0.45rem; }
    .voice-msg { padding: 4px 8px; }
}

/* ===== v20260904l：气泡进一步缩小 ===== */
.wx-bubble { padding: 0.35rem 0.5rem; font-size: 0.85rem; line-height: 1.45; }
.wx-avatar { width: 32px; height: 32px; font-size: 0.8rem; }
.wx-msg { gap: 0.4rem; margin-bottom: 0.7rem; }
.wx-msg-body { max-width: 75%; }
.wx-time { font-size: 0.65rem; }
@media (max-width: 480px) {
    .wx-bubble { padding: 0.32rem 0.45rem; font-size: 0.88rem; }
}
