* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    width: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif;
    background: #f5f7fa;
    overflow: hidden;
    color: #303133;
    font-size: 14px;
    line-height: 1.6;
}

.chat-app {
    width: 100%;
    height: 100vh;
    max-width: 860px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    background: #ffffff;
    border-left: 1px solid #ebeef5;
    border-right: 1px solid #ebeef5;
}

@media (min-width: 768px) {
    body {
        padding: 24px 0;
        background:
            radial-gradient(circle at 20% 10%, #eef2ff 0%, transparent 50%),
            radial-gradient(circle at 80% 90%, #ecfeff 0%, transparent 50%),
            #f5f7fa;
    }
    .chat-app {
        height: calc(100vh - 48px);
        border-radius: 12px;
        border: 1px solid #ebeef5;
        overflow: hidden;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
    }
}

/* ===== Header ===== */
.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 20px;
    background: #ffffff;
    color: #303133;
    border-bottom: 1px solid #ebeef5;
    flex-shrink: 0;
}

.chat-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
    border: 1px solid #ebeef5;
}

.chat-avatar-bot {
    background: #ecf5ff;
    color: #409eff;
}

.chat-title {
    display: flex;
    flex-direction: column;
    line-height: 1.3;
}

.chat-name {
    font-size: 15px;
    font-weight: 600;
    color: #303133;
}

.chat-status {
    font-size: 12px;
    color: #909399;
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 2px;
}

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #67c23a;
    box-shadow: 0 0 0 2px rgba(103, 194, 58, 0.18);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.55; }
}

.chat-actions {
    display: flex;
    gap: 4px;
}

.chat-action-btn {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: #f5f7fa;
    border: 1px solid transparent;
    color: #606266;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.18s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.chat-action-btn:hover {
    background: #ecf5ff;
    color: #409eff;
    border-color: #d9ecff;
}

/* ===== Body ===== */
.chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px 20px 16px;
    scroll-behavior: smooth;
    background: #fafbfc;
}

.chat-body::-webkit-scrollbar {
    width: 5px;
}
.chat-body::-webkit-scrollbar-thumb {
    background: #dcdfe6;
    border-radius: 3px;
}
.chat-body::-webkit-scrollbar-track {
    background: transparent;
}

.chat-date {
    text-align: center;
    margin: 6px 0 16px;
    font-size: 12px;
    color: #909399;
    position: relative;
}
.chat-date::before,
.chat-date::after {
    content: '';
    display: inline-block;
    width: 32px;
    height: 1px;
    background: #ebeef5;
    vertical-align: middle;
    margin: 0 10px;
}

.msg {
    display: flex;
    margin-bottom: 16px;
    animation: msgIn 0.28s ease;
}
@keyframes msgIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.msg-bot { justify-content: flex-start; }
.msg-user { justify-content: flex-end; }

.msg-avatar {
    width: 34px;
    height: 34px;
    font-size: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.msg-avatar-bot {
    background: #ecf5ff;
    color: #409eff;
    margin-right: 10px;
    border: 1px solid #d9ecff;
}
.msg-avatar-user {
    background: #fef0f0;
    color: #f56c6c;
    margin-left: 10px;
    order: 2;
    border: 1px solid #fde2e2;
}

.msg-bubble {
    max-width: calc(100% - 62px);
    position: relative;
}

.msg-content {
    padding: 10px 14px;
    border-radius: 10px;
    word-break: break-word;
    overflow-wrap: break-word;
    line-height: 1.65;
    font-size: 14px;
}

.msg-bot .msg-content {
    background: #ffffff;
    color: #303133;
    border-top-left-radius: 3px;
    border: 1px solid #ebeef5;
}

.msg-user .msg-content {
    background: #e6f1ff;
    color: #1d4ed8;
    border-top-right-radius: 3px;
}

.msg-content p { margin: 0 0 8px; }
.msg-content p:last-child { margin-bottom: 0; }

.msg-content img {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
    margin: 6px 0;
    display: block;
    border: 1px solid #ebeef5;
    background: #fff;
}

.msg-content a {
    color: #409eff;
    text-decoration: none;
    border-bottom: 1px dashed #c6e2ff;
    padding-bottom: 1px;
}
.msg-user .msg-content a {
    color: #1d4ed8;
    border-bottom-color: rgba(29, 78, 216, 0.35);
}
.msg-content a:hover { opacity: 0.82; }

.msg-content strong, .msg-content b { font-weight: 600; color: inherit; }

.msg-time {
    font-size: 11px;
    color: #c0c4cc;
    margin-top: 4px;
}
.msg-bot .msg-time { padding-left: 4px; }
.msg-user .msg-time { text-align: right; padding-right: 4px; }

.quick-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.quick-chip {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    background: #f4f4f5;
    color: #606266;
    border-radius: 6px;
    font-size: 11px;
    line-height: 1.5;
    cursor: pointer;
    border: 1px solid #e9e9eb;
    transition: all 0.18s;
    user-select: none;
}
.quick-chip:hover {
    background: #ecf5ff;
    color: #409eff;
    border-color: #d9ecff;
    transform: translateY(-1px);
}

/* 打字指示器 */
.typing-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 2px;
}
.typing-indicator span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #c0c4cc;
    animation: typing 1.4s infinite;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.45; }
    30% { transform: translateY(-5px); opacity: 1; }
}

/* ===== 热门提问（输入框上方） ===== */
.hot-questions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
}
.hot-questions .hot-label {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: #909399;
    white-space: nowrap;
}
.hot-questions .hot-label .mdi { font-size: 14px; color: #e6a23c; }
.hot-questions .quick-chip { margin: 0; }

/* ===== Footer ===== */
.chat-footer {
    padding: 12px 16px 16px;
    background: #ffffff;
    border-top: 1px solid #ebeef5;
    flex-shrink: 0;
}

.input-wrap {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    background: #ffffff;
    border: 1px solid #dcdfe6;
    border-radius: 10px;
    padding: 6px 6px 6px 14px;
    transition: all 0.18s;
}

.input-wrap.focused {
    border-color: #409eff;
    box-shadow: 0 0 0 3px rgba(64, 158, 255, 0.1);
}

.input-box {
    flex: 1;
    min-height: 24px;
    max-height: 130px;
    overflow-y: auto;
    padding: 6px 0;
    outline: none;
    font-size: 14px;
    line-height: 1.6;
    color: #303133;
}

.input-box:empty::before {
    content: attr(placeholder);
    color: #c0c4cc;
    pointer-events: none;
}

.input-tools { align-self: center; }

.tool-tip {
    font-size: 11px;
    color: #909399;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.tool-tip .mdi { font-size: 13px; color: #e6a23c; }

.send-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: none;
    background: #409eff;
    color: #ffffff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.18s;
    font-size: 16px;
    line-height: 1;
}
.send-btn:hover:not(:disabled) {
    background: #337ecc;
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(64, 158, 255, 0.22);
}
.send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #a0cfff;
}
.send-btn .mdi { margin-left: 1px; }

/* 嵌入模式（iframe） */
body.chat-embed-mode {
    background: transparent;
    padding: 0;
}
body.chat-embed-mode .chat-app {
    height: 100%;
    max-width: 100%;
    box-shadow: none;
    border-radius: 0;
    border: none;
}
body.chat-embed-mode .chat-header {
    display: none !important;
}
body.chat-embed-mode {
    background: #fafbfc !important;
}
