:root {
    --wx-bg: #ededed;
    --wx-green: #95ec69;
    --wx-white: #ffffff;
    --wx-text: #191919;
    --wx-muted: #9a9a9a;
    --wx-line: #dcdcdc;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    background: #d7d7d7;
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
    color: var(--wx-text);
    -webkit-font-smoothing: antialiased;
}

.chat-shell {
    max-width: 480px;
    margin: 0 auto;
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    background: var(--wx-bg);
    box-shadow: 0 0 40px rgba(0, 0, 0, .12);
    overflow: hidden;
}

.chat-header {
    flex: 0 0 auto;
    height: 56px;
    padding: 0 14px 0 18px;
    background: #f7f7f7;
    border-bottom: 1px solid var(--wx-line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: env(safe-area-inset-top);
}

.chat-title {
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #07c160;
    box-shadow: 0 0 0 3px rgba(7, 193, 96, .12);
}

.chat-header-actions { display: flex; align-items: center; gap: 10px; }

.mode-badge {
    font-size: 11px;
    color: #07c160;
    background: rgba(7, 193, 96, .1);
    border-radius: 10px;
    padding: 3px 8px;
}
.mode-badge.mock { color: #b07a00; background: rgba(255, 180, 0, .14); }

#clearBtn {
    border: none;
    background: transparent;
    color: #576b95;
    font-size: 14px;
    cursor: pointer;
    padding: 6px 4px;
}
#clearBtn:hover { opacity: .7; }

.chat-body {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 16px 14px 8px;
    -webkit-overflow-scrolling: touch;
}

.time-divider {
    text-align: center;
    color: #a5a5a5;
    font-size: 12px;
    margin: 4px 0 18px;
}

.msg { display: flex; align-items: flex-start; gap: 9px; margin-bottom: 18px; }
.msg.user { flex-direction: row-reverse; }

.avatar {
    flex: 0 0 36px;
    width: 36px;
    height: 36px;
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    color: #fff;
}
.avatar.assistant { background: #07c160; }
.avatar.user { background: #576b95; }

.msg-column { max-width: 76%; min-width: 0; }

.bubble {
    position: relative;
    background: var(--wx-white);
    border-radius: 6px;
    padding: 10px 13px;
    font-size: 15px;
    line-height: 1.62;
    word-break: break-word;
    box-shadow: 0 1px 1px rgba(0, 0, 0, .03);
}
.msg.user .bubble { background: var(--wx-green); }

.bubble::before {
    content: "";
    position: absolute;
    top: 13px;
    width: 0;
    height: 0;
    border: 6px solid transparent;
}
.msg.assistant .bubble::before { left: -11px; border-right-color: var(--wx-white); }
.msg.user .bubble::before { right: -11px; border-left-color: var(--wx-green); }

.bubble p { margin: 0 0 6px; }
.bubble p:last-child { margin-bottom: 0; }
.bubble a { color: #576b95; }
.bubble ul, .bubble ol { margin: 4px 0; padding-left: 20px; }

.typing { display: inline-flex; align-items: center; gap: 4px; height: 18px; }
.typing i {
    width: 6px; height: 6px; border-radius: 50%; background: #b9b9b9;
    animation: blink 1.2s infinite ease-in-out;
}
.typing i:nth-child(2) { animation-delay: .2s; }
.typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 60%, 100% { opacity: .3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

/* 等待 LLM 首字（推理模型 reasoning 阶段）时的状态提示 */
.thinking-text { color: #9a9a9a; font-size: 13px; margin-left: 8px; }

.error-text { color: #e64340; }

.sources { margin-top: 6px; }
.source-details {
    font-size: 12px;
    color: #576b95;
    background: rgba(255, 255, 255, .7);
    border-radius: 5px;
    padding: 6px 9px;
}
.source-details summary { cursor: pointer; outline: none; }
.source-list { margin-top: 6px; border-top: 1px solid #e5e5e5; padding-top: 5px; }
.source-item { display: flex; align-items: center; gap: 6px; padding: 3px 0; color: #666; }
.source-idx {
    flex: 0 0 17px; width: 17px; height: 17px; line-height: 17px; text-align: center;
    border-radius: 50%; background: #e3e3e3; color: #777; font-size: 10px;
}
.source-text { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.source-score { color: #999; font-variant-numeric: tabular-nums; }
.source-note { font-size: 12px; color: #999; padding: 2px 4px; }

.quick-bar {
    flex: 0 0 auto;
    padding: 6px 14px 10px;
    background: var(--wx-bg);
}
.quick-bar.hidden { display: none; }
.quick-title { font-size: 12px; color: var(--wx-muted); margin-bottom: 8px; }
.quick-list { display: flex; flex-wrap: wrap; gap: 8px; }
.quick-item {
    border: 1px solid #dcdcdc;
    background: #fff;
    color: #4a4a4a;
    font-size: 13px;
    border-radius: 16px;
    padding: 7px 13px;
    cursor: pointer;
    transition: all .15s ease;
}
.quick-item:hover { border-color: #07c160; color: #07c160; }

.chat-input {
    flex: 0 0 auto;
    display: flex;
    align-items: flex-end;
    gap: 9px;
    padding: 9px 12px calc(9px + env(safe-area-inset-bottom));
    background: #f7f7f7;
    border-top: 1px solid var(--wx-line);
}
.chat-input textarea {
    flex: 1;
    resize: none;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    background: #fff;
    padding: 9px 10px;
    font-size: 15px;
    line-height: 1.4;
    max-height: 120px;
    outline: none;
    font-family: inherit;
}
.chat-input textarea:focus { border-color: #b6e59a; }
.chat-input button {
    flex: 0 0 auto;
    border: none;
    border-radius: 5px;
    background: #07c160;
    color: #fff;
    font-size: 14px;
    padding: 10px 18px;
    cursor: pointer;
}
.chat-input button:disabled { background: #b9dfc5; cursor: default; }

@media (min-width: 700px) {
    body { padding: 24px 0; }
    .chat-shell { height: calc(100vh - 48px); height: calc(100dvh - 48px); border-radius: 12px; }
}
