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

:root {
    --gold: #f3d488;
    --gold-deep: #d8a94c;
    --gold-light: #fff3cf;
    --red-deep: #7d0d12;
    --red-main: #a3151a;
}

html, body {
    height: 100%;
    font-family: -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif;
}

body {
    height: 100vh;
    overflow: hidden;
    background: url("/img/bj.png") no-repeat;
    background-size: 100% auto;
    background-color: #7d0d12;
    color: #f4ead6;
}

/* ============ 面板外框 ============ */
.chat-stage {
    height: 100vh;
    display: flex;
    align-items: stretch;
    justify-content: center;
    padding: 30px 28px;
}

.chat-panel {
    width: 100%;
    min-width: 0;
    max-width: 1380px;
    display: flex;
    border-radius: 22px;
    overflow: hidden;
    border: 1px solid rgba(243, 212, 136, .55);
    box-shadow: 0 18px 60px rgba(60, 0, 0, .45), inset 0 0 0 1px rgba(255, 240, 200, .12);
    background: var(--red-deep);
}

.chat-side,
.chat-main { height: 100%; }

/* ============ 左侧历史栏 ============ */
.chat-side {
    width: 27%;
    min-width: 250px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    background: linear-gradient(180deg, #9c1318 0%, #8a1014 55%, #7d0d12 100%);
    border-right: 1px solid rgba(243, 212, 136, .35);
}

.side-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 26px 24px 20px;
}

.side-title { display: flex; align-items: center; gap: 12px; }

.side-title .logo {
    width: 34px; height: 34px;
    color: var(--gold);
    filter: drop-shadow(0 2px 4px rgba(0,0,0,.35));
}

.side-title span {
    font-size: 21px;
    font-weight: 800;
    letter-spacing: 2px;
    background: linear-gradient(180deg, #fff6da 0%, #f3d488 60%, #d8a94c 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: var(--gold);
}

.side-add {
    width: 32px; height: 32px;
    border-radius: 50%;
    border: 1px solid rgba(243, 212, 136, .7);
    background: rgba(255, 220, 150, .12);
    color: var(--gold);
    font-size: 20px;
    line-height: 28px;
    text-align: center;
    cursor: pointer;
    transition: .2s;
}
.side-add:hover { background: rgba(255, 220, 150, .25); }

.side-list { flex: 1; min-height: 0; overflow-y: auto; padding: 8px 16px 20px; }

.side-item {
    position: relative;
    padding: 13px 30px 13px 18px;
    margin-bottom: 10px;
    border-radius: 12px;
    background: rgba(255, 235, 190, .07);
    border: 1px solid rgba(243, 212, 136, .18);
    cursor: pointer;
    transition: .2s;
}
.side-item:hover { background: rgba(255, 235, 190, .13); }

.side-item.active {
    background: linear-gradient(180deg, rgba(190, 30, 26, .9), rgba(150, 18, 18, .9));
    border-color: var(--gold);
    box-shadow: 0 0 14px rgba(243, 200, 110, .25), inset 0 0 12px rgba(243, 200, 110, .1);
}

.side-item .name {
    font-size: 15px;
    color: #f7e9cf;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.side-item.active .name { color: #ffeec2; }

.side-item .time { font-size: 12px; color: rgba(244, 230, 200, .55); margin-top: 5px; }

.side-item.active::after {
    content: '›';
    position: absolute;
    right: 14px; top: 50%;
    transform: translateY(-50%);
    color: var(--gold);
    font-size: 20px;
    font-weight: 700;
}

.side-empty {
    text-align: center;
    color: rgba(244, 230, 200, .6);
    padding: 50px 20px;
    font-size: 13px;
}
/* ============ 右侧主区头部 ============ */
.chat-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 30px;
    background: linear-gradient(180deg, #b11e20 0%, #a3151a 100%);
    border-bottom: 1px solid rgba(243, 212, 136, .3);
}

.header-info { display: flex; align-items: center; gap: 14px; min-width: 0; }

.btn-menu {
    display: none;
    width: 38px; height: 38px;
    flex-shrink: 0;
    border-radius: 10px;
    border: 1px solid rgba(243, 212, 136, .55);
    background: rgba(255, 220, 150, .1);
    cursor: pointer;
}
.btn-menu svg { width: 20px; height: 20px; fill: var(--gold); }

.btn-home {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px; height: 38px;
    flex-shrink: 0;
    border-radius: 10px;
    border: 1px solid rgba(243, 212, 136, .55);
    background: rgba(255, 220, 150, .1);
    cursor: pointer;
}
.btn-home svg { width: 20px; height: 20px; fill: var(--gold); }
.btn-home:hover { background: rgba(255, 220, 150, .22); }

.header-text { min-width: 0; }
.chat-header h1 {
    font-size: 25px;
    font-weight: 800;
    letter-spacing: 1px;
    background: linear-gradient(180deg, #fff8e2 0%, #f3d488 65%, #dca747 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: var(--gold);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.chat-header .subtitle {
    margin-top: 3px;
    font-size: 13px;
    color: rgba(255, 238, 205, .78);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header-status { display: flex; align-items: center; gap: 14px; flex-shrink: 0; }

.header-status .user-ic {
    width: 34px; height: 34px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
}
.header-status .user-ic svg { width: 26px; height: 26px; fill: var(--gold); }

.online-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 18px;
    font-size: 14px;
    color: var(--gold-light);
    border-radius: 20px;
    border: 1px solid rgba(243, 212, 136, .65);
    background: rgba(255, 220, 150, .1);
}
.online-pill i { font-style: normal; font-size: 13px; }

/* ============ 消息区 ============ */
.chat-messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 28px 34px;
    background: linear-gradient(180deg, #fffdf8 0%, #fdf6ec 100%);
}

.chat-msg { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 24px; }
.chat-msg.user { flex-direction: row-reverse; }
.chat-msg.ai { flex-direction: row; }

.msg-avatar {
    width: 34px; height: 34px;
    flex-shrink: 0;
    border-radius: 50%;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #b01e1d, #d45026);
    border: 1px solid rgba(216, 169, 76, .8);
    box-shadow: 0 2px 8px rgba(120, 50, 0, .25);
}
.chat-msg.user .msg-avatar {
    background: linear-gradient(135deg, #f0c268, #d99f43);
}
.msg-avatar img { width: 100%; height: 100%; object-fit: cover; }
.msg-avatar svg { width: 20px; height: 20px; fill: #fff3cf; }
.chat-msg.user .msg-avatar svg { fill: #7d1012; }

.msg-body { display: flex; flex-direction: column; min-width: 0; max-width: 72%; }
.chat-msg.user .msg-body { align-items: flex-end; }
.chat-msg.ai .msg-body { align-items: flex-start; }

.bubble {
    position: relative;
    max-width: 100%;
    padding: 10px 12px;
    border-radius: 14px;
    line-height: 1.8;
    word-break: break-word;
    font-size: 13px;
    color: #fff;
    box-shadow: 0 8px 22px rgba(150, 30, 10, .25);
}

.chat-msg.user .bubble {
    background: linear-gradient(135deg, #e0522e 0%, #c8341f 100%);
}
.chat-msg.user .bubble::after {
    content: '';
    position: absolute;
    right: -7px; top: 12px;
    border: 7px solid transparent;
    border-left-color: #c8341f;
    border-right: 0;
}

.chat-msg.ai .bubble {
    background: linear-gradient(135deg, #8e1015 0%, #b5271e 55%, #e0662c 100%);
}
.chat-msg.ai .bubble::after {
    content: '';
    position: absolute;
    left: -7px; top: 12px;
    border: 7px solid transparent;
    border-right-color: #8e1015;
    border-left: 0;
}

.bubble code {
    background: rgba(40, 0, 0, .4);
    border: 1px solid rgba(255, 220, 160, .2);
    padding: 2px 7px;
    border-radius: 4px;
    font-size: 13px;
}
.bubble pre {
    background: rgba(40, 0, 0, .45);
    border: 1px solid rgba(255, 220, 160, .2);
    padding: 12px 14px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 10px 0;
}
.bubble pre code { background: none; border: none; padding: 0; }
.bubble hr { border: none; border-top: 1px solid rgba(255, 225, 180, .35); margin: 12px 0; }
.bubble ul, .bubble ol { margin: 8px 0; padding-left: 24px; }
.bubble li { margin: 4px 0; }
.bubble h1, .bubble h2, .bubble h3, .bubble h4, .bubble h5, .bubble h6 { margin: 10px 0 5px; font-size: 16px; color: #ffe9bd; }
.bubble a { color: #ffd98a; text-decoration: underline; }

.msg-source {
    display: inline-flex;
    align-items: center;
    margin-top: 8px;
    padding: 4px 14px;
    font-size: 12px;
    color: #8a1014;
    background: #fff7e2;
    border: 1px solid rgba(216, 169, 76, .8);
    border-radius: 9px;
}
.bubble a.rec-q {
    display: inline-block;
    margin: 4px 6px 4px 0;
    padding: 5px 16px;
    color: var(--gold-light);
    text-decoration: none;
    border-radius: 18px;
    border: 1px solid rgba(243, 212, 136, .7);
    background: rgba(255, 220, 150, .1);
}
.bubble a.rec-q:hover { background: rgba(255, 220, 150, .22); }
/* ============ 欢迎区 ============ */
.chat-intro { max-width: 460px; margin: 46px auto 0; }

.intro-avatar {
    width: 92px; height: 92px;
    border-radius: 24px;
    overflow: hidden;
    margin: 0 auto 18px;
    background: linear-gradient(135deg, #a3151a, #d45026);
    border: 1px solid rgba(243, 212, 136, .6);
    box-shadow: 0 10px 26px rgba(160, 30, 10, .3);
    display: flex; align-items: center; justify-content: center;
    font-size: 52px;
}
.intro-avatar img { width: 100%; height: 100%; object-fit: cover; }

.intro-title {
    text-align: center;
    font-size: 16px;
    font-weight: 700;
    color: #8a1014;
    margin-bottom: 18px;
}

.intro-opening {
    padding: 14px 18px;
    font-size: 14px;
    line-height: 1.8;
    color: #7a1014;
    background: linear-gradient(180deg, #fff7e8, #fdeed6);
    border: 1px solid rgba(200, 60, 30, .18);
    border-radius: 12px;
    margin-bottom: 16px;
}

.chat-shortcuts { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }

.shortcut-item {
    padding: 8px 20px;
    font-size: 14px;
    color: #8a1014;
    background: #fff;
    border: 1px solid rgba(216, 169, 76, .7);
    border-radius: 22px;
    cursor: pointer;
    transition: .2s;
}
.shortcut-item:hover { background: #fff4da; border-color: var(--gold-deep); }

/* ============ 思考动画 ============ */
.thinking { display: inline-flex; align-items: center; gap: 10px; color: #ffe6b8; font-size: 14px; }
.thinking .dots { display: inline-flex; gap: 5px; }
.thinking .dots span {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--gold);
    animation: thinkDot 1.2s infinite ease-in-out;
}
.thinking .dots span:nth-child(2) { animation-delay: .2s; }
.thinking .dots span:nth-child(3) { animation-delay: .4s; }
@keyframes thinkDot {
    0%, 80%, 100% { transform: scale(0.6); opacity: .4; }
    40% { transform: scale(1); opacity: 1; }
}
.thinking .think-text::after { content: '正在理解你的问题'; animation: thinkPhrase 9s infinite; }
@keyframes thinkPhrase {
    0%, 15% { content: '正在理解你的问题'; }
    16%, 30% { content: '正在检索相关知识'; }
    31%, 45% { content: '正在组织回答思路'; }
    46%, 60% { content: '正在生成回答内容'; }
    61%, 75% { content: '正在优化表达措辞'; }
    76%, 100% { content: '马上就好…'; }
}
.thinking .think-bar { position: relative; display: inline-block; width: 80px; height: 3px; background: rgba(255, 225, 180, .3); border-radius: 3px; overflow: hidden; margin-left: 4px; }
.thinking .think-bar i { position: absolute; left: -30%; top: 0; height: 100%; width: 40%; background: linear-gradient(90deg, transparent, var(--gold), transparent); border-radius: 3px; animation: thinkBar 1.5s infinite ease-in-out; }
@keyframes thinkBar {
    0% { left: -30%; }
    100% { left: 110%; }
}

/* ============ 底部输入区 ============ */
.chat-input-wrap { padding: 18px 30px 22px; background: #fdf6ec; }

.chat-input-box { position: relative; }

.input-shell {
    position: relative;
    border-radius: 20px;
    padding: 18px 26px 58px;
    background: linear-gradient(135deg, #fffdf8 0%, #fff4e4 100%);
    border: 1px solid rgba(217, 159, 67, .55);
    box-shadow: 0 8px 22px rgba(150, 90, 30, .12);
}
.input-shell::before {
    content: '';
    position: absolute;
    inset: 10px;
    border-radius: 14px;
    border: 1px solid rgba(217, 159, 67, .3);
    pointer-events: none;
}

#queryInput {
    width: 100%;
    height: 64px;
    min-height: 64px;
    max-height: 180px;
    resize: none;
    border: none;
    outline: none;
    background: transparent;
    color: #5a3418;
    font-size: 16px;
    font-family: inherit;
    line-height: 1.7;
}
#queryInput::placeholder { color: rgba(140, 90, 40, .45); }

.send-btn {
    position: absolute;
    right: 30px; bottom: 22px;
    min-width: 96px;
    height: 42px;
    padding: 0 24px;
    border: none;
    border-radius: 21px;
    background: linear-gradient(180deg, #ffe9ac 0%, #f0c268 55%, #d99f43 100%);
    color: #7d1012;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(120, 50, 0, .35), inset 0 1px 0 rgba(255, 255, 255, .7);
    transition: .2s;
}
.send-btn:hover { filter: brightness(1.05); }
.send-btn.loading {
    background: linear-gradient(180deg, #f6d98e, #dcae54);
}

.chat-tip { text-align: center; font-size: 12px; color: #b79a7d; margin-top: 10px; }
/* ============ 移动端抽屉 ============ */
.drawer-mask {
    position: fixed; inset: 0;
    background: rgba(40, 0, 0, .5);
    opacity: 0; visibility: hidden;
    transition: .25s;
    z-index: 900;
}
.drawer-mask.open { opacity: 1; visibility: visible; }

.drawer {
    position: fixed;
    top: 0; left: 0;
    width: 300px; max-width: 82vw;
    height: 100vh;
    background: linear-gradient(180deg, #9c1318, #7d0d12);
    border-right: 1px solid rgba(243, 212, 136, .4);
    box-shadow: 2px 0 18px rgba(0, 0, 0, .35);
    transform: translateX(-100%);
    transition: transform .25s ease;
    z-index: 901;
    display: flex;
    flex-direction: column;
}
.drawer.open { transform: translateX(0); }

.drawer-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 22px;
    border-bottom: 1px solid rgba(243, 212, 136, .25);
}
.drawer-head .drawer-title {
    display: flex; align-items: center; gap: 10px;
    font-size: 18px;
    font-weight: 800;
    color: var(--gold);
}
.drawer-head .logo { width: 26px; height: 26px; color: var(--gold); }
.drawer-head .close {
    cursor: pointer;
    font-size: 24px;
    color: var(--gold);
    line-height: 1;
}
.drawer-list { flex: 1; overflow-y: auto; padding: 12px; }

/* ============ 滚动条 ============ */
.side-list::-webkit-scrollbar,
.drawer-list::-webkit-scrollbar,
.chat-messages::-webkit-scrollbar { width: 6px; }
.side-list::-webkit-scrollbar-thumb,
.drawer-list::-webkit-scrollbar-thumb { background: rgba(243, 212, 136, .3); border-radius: 3px; }
.chat-messages::-webkit-scrollbar-thumb { background: rgba(180, 120, 60, .3); border-radius: 3px; }

/* ============ 响应式 ============ */
@media (max-width: 1024px) {
    .chat-stage { padding: 14px; }
    .chat-side { display: none; }
    .btn-menu { display: flex; align-items: center; justify-content: center; }
    .chat-header { padding: 16px 20px; }
    .chat-header h1 { font-size: 20px; }
    .chat-messages { padding: 20px 18px; }
    .bubble { max-width: 100%; }
    .msg-body { max-width: 85%; }
    .chat-input-wrap { padding: 14px 18px 18px; }
}

@media (max-width: 560px) {
    .chat-header { padding: 14px; }
    .header-info { gap: 10px; }
    .online-pill { padding: 6px 12px; font-size: 13px; }
    .header-status { gap: 8px; }
    .header-status .user-ic { display: none; }
    .input-shell { padding: 14px 18px 56px; }
    .send-btn { right: 20px; min-width: 80px; height: 38px; font-size: 15px; }
}

