﻿/* ==========================================================================
   新版对话页面样式（左侧会话列表 + 右侧主区）
   仅被 Views/Chat/Index.cshtml 引用，不影响原有 style.css 与老页面
   ========================================================================== */

:root {
    --brand: #1a73e8;
    --brand-hover: #1557b0;
    --brand-soft: #eef4fe;
    --bg: #ffffff;
    --sb-bg: #fbfbfc;
    --line: #eef0f3;
    --line-strong: #e4e7ec;
    --t1: #1a1b1e;
    --t2: #6b7180;
    --t3: #9aa0ad;
    --hover: #eef1f5;
    --sb-w: 264px;

    /* 正文字号，可在系统设置里切换 */
    --chat-font: 15px;
}

/* 字号档位 */
[data-font="s"] {
    --chat-font: 14px;
}

[data-font="m"] {
    --chat-font: 15px;
}

[data-font="l"] {
    --chat-font: 17px;
}

[data-font="xl"] {
    --chat-font: 19px;
}

/* ================= 深色主题 ================= */
[data-theme="dark"] {
    --brand: #4c8df6;
    --brand-hover: #6ba1f8;
    --brand-soft: #1c2f4d;
    --bg: #191a1d;
    --sb-bg: #141517;
    --line: #26282d;
    --line-strong: #33363c;
    --t1: #e5e7eb;
    --t2: #a1a7b3;
    --t3: #717884;
    --hover: #25272c;
    color-scheme: dark;
}

    [data-theme="dark"] body {
        background: var(--bg);
        color: var(--t1);
    }

.chat-app-reset,
.chat-app-reset * {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-box-sizing: border-box;
}

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
    color: #1a1b1e;
    background: #ffffff;
    font-size: 14px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

body svg {
    display: block;
}

body button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
    color: inherit;
    outline: none;
}

body textarea {
    font-family: inherit;
}

/* ================= 整体骨架 ================= */
.app {
    display: flex;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

/* ================= 左侧边栏 ================= */
.sidebar {
    width: var(--sb-w);
    flex: 0 0 var(--sb-w);
    background: var(--sb-bg);
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    transition: width .26s cubic-bezier(.22, .61, .36, 1), flex-basis .26s cubic-bezier(.22, .61, .36, 1);
    overflow: hidden;
}

    /* 初始化时禁止动画，避免页面打开瞬间侧边栏滑入 */
    .sidebar.no-anim,
    .mask.no-anim {
        transition: none !important;
    }

    .sidebar.collapsed {
        width: 0;
        min-width: 0;
        flex-basis: 0;
        border-right-color: transparent;
    }

/* 内容层固定宽度：收起时整体被裁切，避免按钮/文字被压扁换行 */
.sb-inner {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    width: var(--sb-w);
    min-width: var(--sb-w);
    min-height: 0;
}

/* 品牌区 */
.sb-brand {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 12px 10px 14px;
    gap: 8px;
    flex: 0 0 auto;
}

.brand-left {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

    .brand-left img {
        width: 24px;
        height: 24px;
        border-radius: 6px;
        object-fit: contain;
        flex: 0 0 auto;
    }

.brand-name {
    font-size: 16px;
    font-weight: 600;
    letter-spacing: .2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sb-actions {
    display: flex;
    align-items: center;
    gap: 2px;
    flex: 0 0 auto;
}

.icon-btn {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--t2);
    transition: background .15s, color .15s;
}

    .icon-btn:hover {
        background: var(--hover);
        color: var(--t1);
    }

/* 搜索框 */
.sb-search {
    display: none;
    padding: 0 12px 8px;
    flex: 0 0 auto;
}

    .sb-search.show {
        display: block;
    }

    .sb-search input {
        width: 100%;
        height: 34px;
        box-sizing: border-box;
        -webkit-box-sizing: border-box;
        border: 1px solid var(--line-strong);
        border-radius: 9px;
        padding: 0 10px;
        font-size: 13px;
        color: var(--t1);
        background: #fff;
        outline: none;
    }

        .sb-search input:focus {
            border-color: #c3d4ec;
        }

/* 开启新对话 */
.new-chat {
    margin: 6px 12px 10px;
    height: 42px;
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: #fff;
    border: 1px solid var(--line-strong);
    border-radius: 21px;
    font-size: 14px;
    color: var(--t1);
    transition: background .15s, border-color .15s, box-shadow .15s;
}

    .new-chat:hover {
        background: #fbfcfe;
        border-color: #d7dce3;
        box-shadow: 0 1px 3px rgba(16, 24, 40, .06);
    }

    .new-chat svg {
        color: var(--t2);
    }

/* 会话列表 */
.sb-scroll {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 2px 8px 12px;
}

.sb-group {
    margin-bottom: 6px;
}

.sb-group-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 8px 4px 8px;
    font-size: 12px;
    color: var(--t3);
    font-weight: 500;
    user-select: none;
}

.sb-item {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 34px;
    padding: 0 10px;
    border-radius: 9px;
    font-size: 13px;
    color: #3c4149;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: background .13s;
    position: relative;
}

    .sb-item .txt {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        flex: 1;
    }

    .sb-item:hover {
        background: var(--hover);
    }

    .sb-item.active {
        background: #e8eef9;
        color: #17427f;
        font-weight: 500;
    }

    .sb-item .item-del {
        width: 20px;
        height: 20px;
        border-radius: 5px;
        display: none;
        align-items: center;
        justify-content: center;
        color: var(--t3);
        flex: 0 0 20px;
    }

    .sb-item:hover .item-del {
        display: flex;
    }

    .sb-item .item-del:hover {
        background: #dfe4ea;
        color: #d9534f;
    }

.sb-empty {
    padding: 20px 10px;
    text-align: center;
    font-size: 12px;
    color: var(--t3);
}

/* 备案信息（法律合规，保持极小字号） */
.sb-foot {
    flex: 0 0 auto;
    padding: 0 12px 6px;
    font-size: 10px;
    line-height: 1.6;
    color: #b9bfc9;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

    .sb-foot a {
        color: #b9bfc9;
        text-decoration: none;
    }

        .sb-foot a:hover {
            color: var(--brand);
        }

    .sb-foot span {
        margin-left: 6px;
    }

/* 底部用户区 */
.sb-user {
    position: relative;
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 10px 12px;
    border-top: 1px solid var(--line);
    cursor: pointer;
    transition: background .15s;
}

    .sb-user:hover {
        background: var(--hover);
    }

    .sb-user img {
        width: 28px;
        height: 28px;
        border-radius: 50%;
        object-fit: cover;
        flex: 0 0 auto;
        background: #dfe4ea;
    }

    .sb-user .u-name {
        flex: 1;
        font-size: 13px;
        color: var(--t1);
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .sb-user .u-more {
        color: var(--t3);
        width: 24px;
        height: 24px;
        border-radius: 6px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

        .sb-user .u-more:hover {
            background: #e4e8ee;
        }

.login-tip {
    color: var(--brand);
    cursor: pointer;
    font-size: 13px;
}

/* ================= 右侧主区 ================= */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    position: relative;
    background: var(--bg);
}

/* 侧边栏收起后的展开按钮 */
/* 侧边栏收起后的悬浮按钮组 */
.reopen-bar {
    position: absolute;
    left: 14px;
    top: 14px;
    z-index: 20;
    display: none;
    align-items: center;
    gap: 2px;
    padding: 4px;
    border-radius: 22px;
    background: #f1f3f6;
}

body.sb-collapsed .reopen-bar {
    display: flex;
}

.rb-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--t2);
    transition: background .15s, color .15s;
}

    .rb-btn:hover {
        background: rgba(16, 24, 40, .07);
        color: var(--t1);
    }

/* 消息区 */
.chat-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 24px 0 8px;
    display: none;
    background: #fff;
}

.main.chatting .chat-scroll {
    display: block;
}

.chat-inner {
    max-width: 760px;
    margin: 0 auto;
    padding: 0 24px 16px;
    background: transparent;
}

.msg {
    display: flex;
    gap: 12px;
    margin-bottom: 26px;
}

    .msg .avatar {
        width: 28px;
        height: 28px;
        border-radius: 50%;
        flex: 0 0 28px;
        object-fit: contain;
        background: #f1f3f6;
        padding: 3px;
    }

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

        .msg.user .bubble {
            background: #e9f1fe;
            border-radius: 14px;
            padding: 9px 14px;
            font-size: var(--chat-font);
            line-height: 1.7;
            color: #14263f;
            max-width: 80%;
            white-space: pre-wrap;
            word-break: break-word;
        }

    .msg.ai .content {
        flex: 1;
        min-width: 0;
        padding-top: 1px;
        font-size: var(--chat-font);
        line-height: 1.75;
        color: #1a1b1e;
        word-break: break-word;
    }

    .msg.ai .content p {
        margin-bottom: 10px;
    }

    .msg.ai .content img {
        max-width: 100%;
    }

    .msg.ai .content pre {
        background: #f6f7f9;
        border-radius: 8px;
        padding: 12px;
        overflow-x: auto;
        font-size: 13px;
        margin-bottom: 10px;
    }

    .msg.ai .content code {
        background: #f2f4f7;
        border-radius: 4px;
        padding: 1px 5px;
        font-size: 13px;
    }

    .msg.ai .content pre code {
        background: transparent;
        padding: 0;
    }

    .msg.ai .content table {
        border-collapse: collapse;
        margin-bottom: 10px;
    }

    .msg.ai .content table th,
    .msg.ai .content table td {
        border: 1px solid var(--line-strong);
        padding: 6px 10px;
    }

/* markdown 排版（自带，避免依赖 markdown.css 的暗色主题变量） */
.msg.ai .content h1,
.msg.ai .content h2,
.msg.ai .content h3,
.msg.ai .content h4,
.msg.ai .content h5,
.msg.ai .content h6 {
    margin: 18px 0 8px;
    font-weight: 600;
    line-height: 1.4;
}

.msg.ai .content h1 {
    font-size: 1.45em;
}

.msg.ai .content h2 {
    font-size: 1.3em;
}

.msg.ai .content h3 {
    font-size: 1.15em;
}

.msg.ai .content h4 {
    font-size: 1.07em;
}

.msg.ai .content h5,
.msg.ai .content h6 {
    font-size: 1em;
}

    .msg.ai .content h1:first-child,
    .msg.ai .content h2:first-child,
    .msg.ai .content h3:first-child,
    .msg.ai .content p:first-child {
        margin-top: 0;
    }

.msg.ai .content ul,
.msg.ai .content ol {
    padding-left: 22px;
    margin-bottom: 10px;
}

.msg.ai .content ul li {
    list-style: disc;
}

.msg.ai .content ol li {
    list-style: decimal;
}

.msg.ai .content li {
    margin-bottom: 4px;
}

    .msg.ai .content li > p {
        margin-bottom: 4px;
    }

.msg.ai .content blockquote {
    border-left: 3px solid var(--line-strong);
    padding: 2px 0 2px 12px;
    color: #5b6472;
    margin: 0 0 10px;
}

.msg.ai .content a {
    color: var(--brand);
    text-decoration: none;
    /* 长链接强制换行，避免撑破气泡 */
    overflow-wrap: anywhere;
    word-break: break-word;
    transition: color .15s;
}

    .msg.ai .content a:hover {
        text-decoration: underline;
        color: var(--brand-hover);
    }

.msg.ai .content hr {
    border: none;
    border-top: 1px solid var(--line-strong);
    margin: 14px 0;
}

.msg.ai .content strong {
    font-weight: 600;
}

/* 思考过程 */
.reason {
    border-left: 2px solid var(--line-strong);
    margin: 2px 0 12px;
    padding-left: 10px;
    color: var(--t2);
    font-size: 13px;
}

    .reason summary {
        display: flex;
        align-items: center;
        gap: 6px;
        cursor: pointer;
        color: var(--t2);
        list-style: none;
        outline: none;
        user-select: none;
    }

        .reason summary::-webkit-details-marker {
            display: none;
        }

        /* 折叠指示箭头 */
        .reason summary::before {
            content: '';
            width: 0;
            height: 0;
            border-left: 5px solid currentColor;
            border-top: 4px solid transparent;
            border-bottom: 4px solid transparent;
            opacity: .45;
            transition: transform .18s ease;
        }

    .reason[open] > summary::before {
        transform: rotate(90deg);
    }

    .reason .reason-body {
        padding-top: 6px;
        color: #7a8090;
        white-space: pre-wrap;
    }

    /* 展开时限制高度，避免把正文挤到屏幕外 */
    .reason[open] .reason-body {
        max-height: 260px;
        overflow-y: auto;
        padding-right: 4px;
    }

        .reason[open] .reason-body::-webkit-scrollbar {
            width: 4px;
        }

        .reason[open] .reason-body::-webkit-scrollbar-thumb {
            background: #dfe3e9;
            border-radius: 2px;
        }

/* 生成中提示（三点跳动，替代原先的 dotting 竖线动画） */
.ai-loading {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 24px;
    font-size: 13px;
    color: var(--t3);
}

.typing {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

    .typing i {
        width: 6px;
        height: 6px;
        border-radius: 50%;
        background: #b9bfc9;
        animation: chatTyping 1.1s infinite ease-in-out;
    }

        .typing i:nth-child(2) {
            animation-delay: .16s;
        }

        .typing i:nth-child(3) {
            animation-delay: .32s;
        }

@keyframes chatTyping {
    0%, 70%, 100% {
        opacity: .35;
        transform: translateY(0);
    }

    35% {
        opacity: 1;
        transform: translateY(-3px);
    }
}

/* 反馈按钮 */
/* 参考来源：站内检索命中（结束帧带回），位于回答与操作条之间 */
.sources {
    margin-top: 12px;
    border: 1px solid var(--line, #e6ebf2);
    border-radius: 12px;
    background: #fbfcfe;
    overflow: hidden;
}

    .sources-head {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 9px 12px;
        background: #f6f9fc;
        border-bottom: 1px solid #edf1f6;
    }

    .sources-title {
        font-size: 12.5px;
        font-weight: 600;
        color: #334155;
    }

    .sources-count {
        min-width: 18px;
        height: 18px;
        padding: 0 6px;
        border-radius: 9px;
        background: #e8f0fb;
        color: #1a5fb4;
        font-size: 11px;
        line-height: 18px;
        text-align: center;
        font-family: Consolas, Monaco, monospace;
    }

    .sources-hint {
        margin-left: auto;
        font-size: 11px;
        color: #9aa8b6;
        white-space: nowrap;
    }

    .sources-list {
        max-height: 286px;
        overflow-y: auto;
    }

    .source-item {
        display: flex;
        align-items: center;
        gap: 9px;
        padding: 8px 12px;
        border-top: 1px solid #f1f4f8;
        text-decoration: none;
    }

        .source-item:first-child {
            border-top: 0;
        }

        .source-item:hover {
            background: #f3f8fd;
        }

    .source-favicon {
        position: relative;
        width: 18px;
        height: 18px;
        flex: 0 0 18px;
        border-radius: 5px;
        background: #e8eef6;
        overflow: hidden;
        display: flex;
        align-items: center;
        justify-content: center;
    }

        .source-favicon img {
            position: absolute;
            inset: 0;
            width: 18px;
            height: 18px;
            object-fit: cover;
            background: #fff;
        }

    .source-letter {
        font-size: 10px;
        font-weight: 700;
        color: #5b7390;
    }

    .source-main {
        flex: 1;
        min-width: 0;
        display: flex;
        flex-direction: column;
        gap: 1px;
    }

    .source-title {
        font-size: 12.5px;
        color: #20364a;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .source-meta {
        display: flex;
        align-items: center;
        gap: 6px;
        min-width: 0;
        font-size: 11px;
        color: #8a9aab;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .source-host {
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .source-tag {
        flex: 0 0 auto;
        padding: 0 5px;
        border-radius: 4px;
        font-size: 10px;
        line-height: 15px;
    }

        .source-tag.site {
            color: #1a5fb4;
            background: #eaf2ff;
        }

        .source-tag.web {
            color: #9a6700;
            background: #fff4e5;
        }

    .source-arrow {
        flex: 0 0 auto;
        color: #b4c0cc;
        font-size: 15px;
        line-height: 1;
    }

.feedback {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    margin-top: 6px;
    opacity: .55;
    transition: opacity .15s;
}

    .feedback:hover {
        opacity: 1;
    }

    .feedback .fb-btn {
        width: 26px;
        height: 26px;
        border-radius: 6px;
        display: flex;
        align-items: center;
        justify-content: center;
        color: var(--t2);
    }

        .feedback .fb-btn:hover {
            background: var(--hover);
        }

        .feedback .fb-btn.on {
            color: var(--brand);
        }

    /* 重新生成只对最后一条回答开放 */
    .feedback .regen-btn {
        display: none;
    }

    .feedback.last .regen-btn {
        display: flex;
    }

/* 主动停止生成的提示 */
.stop-note {
    margin-top: 6px;
    font-size: 12px;
    color: var(--t3, #98a1ad);
}

/* 流式增量渲染的尾部占位：内容为空时不占位，避免气泡底部多出空白 */
.msg.ai .content .md-tail:empty {
    display: none;
}

/* 本轮输出速度：生成过程中实时显示，结束后定格到操作条右侧 */
.speed-live {
    margin-top: 8px;
    font-size: 12px;
    color: var(--t3);
    user-select: none;
}

.feedback .speed-tag {
    margin-left: 2px;
    padding-left: 8px;
    border-left: 1px solid var(--line);
    font-size: 12px;
    line-height: 1;
    color: var(--t3);
    white-space: nowrap;
}

/* 轻提示：layer 未加载时的兜底，保证任何操作都有可见反馈 */
.g-toast {
    position: fixed;
    left: 50%;
    bottom: 104px;
    transform: translate(-50%, 8px);
    padding: 8px 14px;
    max-width: 70vw;
    background: rgba(22, 24, 28, .88);
    color: #fff;
    font-size: 13px;
    line-height: 1.4;
    border-radius: 8px;
    opacity: 0;
    pointer-events: none;
    transition: opacity .18s, transform .18s;
    z-index: 9999;
}

    .g-toast.show {
        opacity: 1;
        transform: translate(-50%, 0);
    }

/* ================= 应用内确认弹窗（替代原生 confirm） ================= */
.dlg-mask {
    position: fixed;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 9998;
    background: rgba(15, 18, 24, .45);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity .18s;
}

    .dlg-mask.show {
        opacity: 1;
    }

.dlg {
    width: 360px;
    max-width: calc(100vw - 48px);
    background: var(--bg);
    border-radius: 14px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, .22);
    padding: 20px 22px 18px;
    transform: translateY(10px) scale(.97);
    transition: transform .18s;
}

    .dlg-mask.show .dlg {
        transform: none;
    }

.dlg-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--t1);
    margin-bottom: 8px;
}

.dlg-text {
    font-size: 13.5px;
    line-height: 1.6;
    color: var(--t2);
    word-break: break-all;
}

.dlg-btns {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 18px;
}

.dlg-btn {
    height: 32px;
    padding: 0 18px;
    border-radius: 16px;
    font-size: 13px;
    color: var(--t2);
    background: var(--hover);
    border: none;
    cursor: pointer;
    transition: background .18s, color .18s;
}

    .dlg-btn:hover {
        color: var(--t1);
    }

    .dlg-btn.danger {
        background: #e5484d;
        color: #fff;
    }

        .dlg-btn.danger:hover {
            background: #d13d42;
            color: #fff;
        }


/* ================= 输入区 ================= */
.composer-wrap {
    flex: 0 0 auto;
    padding: 0 24px 18px;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0) 0%, #fff 40%);
}

.main.empty .composer-wrap {
    flex: 1;
    justify-content: center;
    padding-bottom: 0;
    background: #fff;
}

.main.empty .welcome {
    display: flex;
}

.welcome {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 26px;
    font-size: 24px;
    font-weight: 600;
    letter-spacing: .3px;
}

    .welcome img {
        width: 30px;
        height: 30px;
        border-radius: 8px;
        object-fit: contain;
    }

/* ================= 文章引用条（输入框内部，带 id/type 进入时） ================= */
.news-ref {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 6px 8px 6px 10px;
    margin-bottom: 9px;
    background: #f2f6fd;
    border: 1px solid #dce8fa;
    border-radius: 12px;
    font-size: 13px;
    max-width: 100%;
}

    .news-ref.show {
        display: flex;
    }

.news-ref-icon {
    flex: 0 0 auto;
    display: flex;
    color: #1a73e8;
}

.news-ref-title {
    flex: 1;
    min-width: 0;
    color: #2b3a4d;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.news-ref-tag {
    flex: 0 0 auto;
    font-size: 11px;
    color: #1a73e8;
    background: #e2ecfd;
    border-radius: 4px;
    padding: 1px 6px;
}

.news-ref-close {
    flex: 0 0 auto;
    width: 20px;
    height: 20px;
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #8a9099;
    font-size: 16px;
    line-height: 1;
}

    .news-ref-close:hover {
        background: #e3ebf7;
        color: #5b6472;
    }

/* 帮我总结一下（有引用时才出现） */
.summary-chip {
    display: none;
    align-items: center;
    gap: 5px;
    height: 30px;
    padding: 0 12px;
    border-radius: 15px;
    font-size: 13px;
    color: #1a73e8;
    background: #e8f0fe;
    transition: background .18s;
}

    .summary-chip.show {
        display: inline-flex;
    }

    .summary-chip:hover {
        background: #dbe8fc;
    }

/* 用户气泡里的“基于某篇文章”引用条 */
.msg.user .bubble .quote {
    font-size: 12px;
    color: #4a6b9a;
    background: rgba(255, 255, 255, .62);
    border-radius: 7px;
    padding: 4px 8px;
    margin-bottom: 6px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.composer {
    width: 100%;
    max-width: 760px;
    background: #fff;
    border: 1px solid var(--line-strong);
    border-radius: 22px;
    padding: 12px 14px 10px;
    box-shadow: 0 2px 10px rgba(16, 24, 40, .04);
    transition: border-color .15s, box-shadow .15s;
}

    .composer:focus-within {
        border-color: #c3d4ec;
        box-shadow: 0 0 0 3px rgba(26, 115, 232, .07);
    }

.main.empty .composer {
    border-radius: 24px;
    padding: 16px 16px 12px;
    box-shadow: 0 4px 20px rgba(16, 24, 40, .06);
}

.composer textarea {
    width: 100%;
    border: none;
    outline: none;
    resize: none;
    font-size: var(--chat-font);
    line-height: 1.6;
    color: var(--t1);
    max-height: 180px;
    min-height: 24px;
    background: transparent;
    display: block;
}

    .composer textarea::placeholder {
        color: var(--t3);
    }

    .composer textarea:disabled {
        cursor: not-allowed;
    }

.composer-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 8px;
}

.tools {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

/* 深度思考按钮：灰度=未启用，点亮=启用 */
.think-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 30px;
    padding: 0 14px 0 12px;
    border-radius: 15px;
    font-size: 13px;
    color: #8a9099;
    background: #f1f3f6;
    border: 1px solid transparent;
    transition: background .18s, color .18s, border-color .18s, box-shadow .18s;
}

    .think-btn svg {
        flex: 0 0 auto;
        opacity: .9;
    }

    .think-btn:hover {
        background: #e9ecf1;
        color: #5b6472;
    }

    .think-btn.on {
        background: var(--brand);
        color: #fff;
        box-shadow: 0 2px 6px rgba(26, 115, 232, .28);
    }

        .think-btn.on:hover {
            background: var(--brand-hover);
            color: #fff;
        }

.actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
}

.round-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--t2);
    transition: background .15s, color .15s;
}

    .round-btn:hover {
        background: var(--hover);
        color: var(--t1);
    }

.send-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #dbe8fc;
    color: #fff;
    transition: background .15s, opacity .15s;
}

    .send-btn.ready {
        background: var(--brand);
    }

        .send-btn.ready:hover {
            background: var(--brand-hover);
        }

    .send-btn.loading {
        background: #9db8e0;
        cursor: wait;
    }

/* 生成中：同一个按钮变成「停止」，方形图标 */
.send-btn .ico-stop {
    display: none;
}

.send-btn.generating {
    background: var(--brand);
    cursor: pointer;
}

    .send-btn.generating:hover {
        background: var(--brand-hover);
    }

    .send-btn.generating .ico-send {
        display: none;
    }

    .send-btn.generating .ico-stop {
        display: block;
    }

/* ================= 上下文用量进度环 ================= */
.ctx {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    flex: 0 0 auto;
    cursor: default;
    transition: background .15s;
}

    .ctx:hover {
        background: var(--hover);
    }

    .ctx svg {
        display: block;
    }

#ctxArc {
    transition: stroke-dashoffset .35s ease, stroke .3s;
}

.ctx-tip {
    position: absolute;
    bottom: 32px;
    right: -8px;
    padding: 6px 10px;
    border-radius: 8px;
    background: #4a4e55;
    color: #fff;
    font-size: 12px;
    line-height: 1.4;
    white-space: nowrap;
    opacity: 0;
    transform: translateY(2px);
    pointer-events: none;
    transition: opacity .16s ease, transform .16s ease;
    z-index: 30;
    box-shadow: 0 4px 14px rgba(16, 24, 40, .18);
}

.ctx:hover .ctx-tip {
    opacity: 1;
    transform: translateY(0);
}

    /* tooltip 小三角 */
    .ctx-tip::after {
        content: '';
        position: absolute;
        top: 100%;
        right: 14px;
        border: 4px solid transparent;
        border-top-color: #4a4e55;
    }

.disclaimer {
    width: 100%;
    max-width: 760px;
    margin-top: 10px;
    text-align: center;
    font-size: 12px;
    color: var(--t3);
}

.main.chatting .welcome {
    display: none;
}

/* 滚动条 */
.sb-scroll::-webkit-scrollbar,
.chat-scroll::-webkit-scrollbar {
    width: 6px;
}

.sb-scroll::-webkit-scrollbar-thumb,
.chat-scroll::-webkit-scrollbar-thumb {
    background: #dde1e7;
    border-radius: 3px;
}

    .sb-scroll::-webkit-scrollbar-thumb:hover,
    .chat-scroll::-webkit-scrollbar-thumb:hover {
        background: #c8ced7;
    }

.sb-scroll::-webkit-scrollbar-track,
.chat-scroll::-webkit-scrollbar-track {
    background: transparent;
}

/* 遮罩（移动端） */
.mask {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(16, 24, 40, .35);
    z-index: 30;
}

/* ================= 响应式 ================= */
/* 移动端顶栏：桌面端隐藏，仅在下面的媒体查询里启用 */
.m-topbar {
    display: none;
}

@media (max-width: 768px) {
    :root {
        --sb-w: 280px;
    }

    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        z-index: 40;
        transform: translateX(0);
        box-shadow: 0 8px 30px rgba(16, 24, 40, .16);
        transition: transform .28s cubic-bezier(.22, .61, .36, 1), box-shadow .28s ease;
        will-change: transform;
    }

        .sidebar.collapsed {
            transform: translateX(-100%);
            width: var(--sb-w);
            min-width: var(--sb-w);
            max-width: var(--sb-w);
            flex-basis: var(--sb-w);
            box-shadow: 0 8px 30px rgba(16, 24, 40, 0);
        }

    /* 遮罩用透明度淡入淡出，和侧边栏滑动同步 */
    .mask {
        display: block;
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        transition: opacity .28s ease, visibility 0s linear .28s;
    }

        .mask.show {
            opacity: 1;
            visibility: visible;
            pointer-events: auto;
            transition: opacity .28s ease, visibility 0s;
        }

    /* ---- 移动端顶栏 ---- */
    .m-topbar {
        display: flex;
        align-items: center;
        justify-content: space-between;
        flex: 0 0 52px;
        height: 52px;
        padding: 0 6px;
        background: var(--bg);
        border-bottom: 1px solid var(--line);
        position: relative;
        z-index: 25;
    }

    .mt-btn {
        width: 40px;
        height: 40px;
        border-radius: 12px;
        display: flex;
        align-items: center;
        justify-content: center;
        color: var(--t1);
        background: transparent;
    }

        .mt-btn:active {
            background: rgba(16, 24, 40, .07);
        }

    .mt-title {
        position: absolute;
        left: 50%;
        transform: translateX(-50%);
        max-width: 56%;
        font-size: 15.5px;
        font-weight: 600;
        color: var(--t1);
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
    }

    /* 顶栏已有入口，收起态的悬浮按钮组在手机上不再需要 */
    .reopen-bar {
        display: none !important;
    }

    /* iOS 聚焦时字体小于 16px 会自动放大页面，导致侧边栏看起来变宽 */
    .sb-search input {
        font-size: 16px;
    }

    .composer-wrap {
        padding: 0 26px 12px;
        padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    }

    .chat-inner {
        padding: 0 14px 16px;
    }

    .sources-hint {
        display: none;
    }

    .sources-list {
        max-height: 250px;
    }

    /* 空态：图标与文案同一行，和输入框作为一组居中略偏上 */
    .main.empty .composer-wrap {
        justify-content: center;
        padding-bottom: 9vh;
        background: #fff;
    }

    .welcome {
        gap: 11px;
        margin-bottom: 26px;
        font-size: 22px;
        font-weight: 650;
    }

        .welcome img {
            width: 36px;
            height: 36px;
            border-radius: 10px;
        }


    .think-btn {
        height: 30px;
        padding: 0 12px 0 10px;
        gap: 5px;
        font-size: 12.5px;
        background: #fff;
        border: 1px solid #e6ebf3;
    }

        .think-btn.on {
            background: #eef3fe;
            border-color: #c9dbf7;
        }

        .think-btn svg {
            width: 13px;
            height: 13px;
        }

    .news-ref {
        font-size: 12px;
        padding: 5px 6px 5px 8px;
        margin-bottom: 7px;
        gap: 6px;
    }

    .summary-chip {
        height: 28px;
        padding: 0 10px;
        font-size: 12px;
    }

    /* 输入卡片：明显的浮起感，贴近 App 观感 */
    .composer,
    .main.empty .composer {
        max-width: 100%;
        border-radius: 26px;
        padding: 14px 12px 12px 16px;
        border-color: #e6ebf3;
        box-shadow: 0 6px 24px rgba(16, 24, 40, .08);
    }

    /* 16px 是 iOS 的临界值，小于它聚焦输入框时页面会自动放大 */
    .composer textarea {
        font-size: 16px;
    }

    /* 未输入时的发送按钮：白箭头压在浅蓝底上对比度太低，
       这里加深底色，保证在手机上能看清是个可点的按钮 */
    .send-btn {
        width: 40px;
        height: 40px;
        background: #bccbf7;
    }
}

/* ================= 用户菜单（三点） ================= */
.user-menu {
    position: absolute;
    bottom: calc(100% - 4px);
    left: 8px;
    right: 8px;
    display: none;
    padding: 6px;
    background: #fff;
    border: 1px solid var(--line-strong);
    border-radius: 12px;
    box-shadow: 0 10px 32px rgba(16, 24, 40, .14);
    z-index: 60;
}

    .user-menu.show {
        display: block;
    }

.um-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    height: 38px;
    padding: 0 10px;
    border-radius: 8px;
    font-size: 13.5px;
    color: var(--t1);
    transition: background .14s;
}

    .um-item svg {
        flex: 0 0 auto;
        color: var(--t2);
    }

    .um-item:hover {
        background: var(--hover);
    }

/* ================= 系统设置弹窗 ================= */
.modal {
    position: fixed;
    inset: 0;
    display: none;
    z-index: 100;
}

    .modal.show {
        display: block;
    }

.modal-mask {
    position: absolute;
    inset: 0;
    background: rgba(16, 20, 28, .38);
    animation: fadeIn .16s ease;
}

.modal-box {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 540px;
    max-width: calc(100vw - 32px);
    max-height: calc(100vh - 64px);
    overflow-y: auto;
    padding: 20px 22px 22px;
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 24px 70px rgba(16, 24, 40, .22);
    animation: popIn .18s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes popIn {
    from { opacity: 0; transform: translate(-50%, -48%) scale(.98); }
    to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
}

    .modal-head h3 {
        font-size: 16px;
        font-weight: 600;
        color: var(--t1);
    }

.modal-close {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    line-height: 1;
    color: var(--t3);
}

    .modal-close:hover {
        background: var(--hover);
        color: var(--t2);
    }

.set-row {
    margin-bottom: 18px;
}

    .set-row.last {
        margin-bottom: 0;
    }

.set-label {
    font-size: 13.5px;
    color: var(--t2);
    margin-bottom: 10px;
}

/* 主题三张卡片 */
.theme-options {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.theme-opt {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 7px;
    height: 72px;
    border: 1px solid var(--line-strong);
    border-radius: 10px;
    background: #fff;
    font-size: 13px;
    color: var(--t1);
    transition: border-color .15s, background .15s, color .15s;
}

    .theme-opt:hover {
        border-color: var(--brand);
    }

    .theme-opt.on {
        background: var(--brand-soft);
        border-color: var(--brand);
        color: var(--brand);
    }

/* 字号分段 */
.font-options {
    display: inline-flex;
    padding: 3px;
    background: var(--hover);
    border-radius: 9px;
}

.font-opt {
    min-width: 54px;
    padding: 7px 14px;
    border-radius: 7px;
    font-size: 13px;
    color: var(--t2);
    transition: background .15s, color .15s;
}

    .font-opt.on {
        background: #fff;
        color: var(--t1);
        box-shadow: 0 1px 3px rgba(16, 24, 40, .1);
    }

/* ================= 深色主题细节覆盖 ================= */
[data-theme="dark"] .user-menu,
[data-theme="dark"] .modal-box {
    background: #212327;
}

[data-theme="dark"] .composer {
    background: #26282d;
    border-color: #343840;
    box-shadow: none;
}

[data-theme="dark"] .msg.user .bubble {
    background: #24384f;
    color: #dbe6f5;
}

[data-theme="dark"] .msg.user .bubble .quote {
    background: rgba(255, 255, 255, .1);
    color: #a9c3e2;
}

[data-theme="dark"] .msg.ai .content {
    color: #e3e5e9;
}

[data-theme="dark"] .msg .avatar {
    background: #26282d;
}

[data-theme="dark"] .news-ref {
    background: #1e2a3a;
    border-color: #2c3d54;
}

[data-theme="dark"] .news-ref-title {
    color: #ccd8e8;
}

[data-theme="dark"] .news-ref-tag {
    background: #23374f;
    color: #7fb0f8;
}

[data-theme="dark"] .news-ref-close:hover {
    background: #2c3d54;
    color: #ccd8e8;
}

[data-theme="dark"] .summary-chip {
    background: #1c2f4d;
    color: #86b4f9;
}

[data-theme="dark"] .msg.ai .content pre {
    background: #1a1c20;
    border-color: #2c2f35;
}

[data-theme="dark"] .reason .reason-body {
    color: #98a0ac;
}

[data-theme="dark"] .theme-opt {
    background: #212327;
    border-color: #3a3d44;
    color: var(--t1);
}

[data-theme="dark"] .theme-opt.on {
    background: #1c2f4d;
    border-color: var(--brand);
    color: #86b4f9;
}

[data-theme="dark"] .font-options {
    background: #2a2c31;
}

[data-theme="dark"] .font-opt.on {
    background: #3a3d44;
    color: var(--t1);
    box-shadow: none;
}

[data-theme="dark"] .ctx svg circle:first-child {
    stroke: #33363c;
}

[data-theme="dark"] .chat-scroll {
    background: var(--bg);
}

/* 深色主题：侧边栏与控制区补充 */
[data-theme="dark"] .new-chat {
    background: #26282d;
    border-color: transparent;
    color: #e5e7eb;
}

    [data-theme="dark"] .new-chat:hover {
        background: #2e3138;
    }

[data-theme="dark"] .sb-item {
    color: #b6bcc7;
}

    [data-theme="dark"] .sb-item:hover {
        background: var(--hover);
        color: #e5e7eb;
    }

    [data-theme="dark"] .sb-item.active {
        background: #2a2f38;
        color: #e5e7eb;
    }

[data-theme="dark"] .sb-group-title,
[data-theme="dark"] .sb-foot a,
[data-theme="dark"] .sb-foot span {
    color: #8b919d;
}

[data-theme="dark"] .disclaimer {
    color: #8b919d;
}

[data-theme="dark"] .think-btn {
    background: transparent;
    border-color: #3a3d44;
    color: #9aa1ad;
}

    [data-theme="dark"] .think-btn:hover {
        background: #2a2d33;
        color: #c2c8d2;
    }

    [data-theme="dark"] .think-btn.on {
        background: rgba(76, 141, 246, .12);
        border-color: #35507a;
        color: #8fbcfb;
    }

[data-theme="dark"] .u-more:hover {
    background: var(--hover);
}

/* 深色主题：滚动条与细节收尾 */
[data-theme="dark"] .sb-scroll::-webkit-scrollbar-thumb,
[data-theme="dark"] .chat-scroll::-webkit-scrollbar-thumb {
    background: #34373d;
}

    [data-theme="dark"] .sb-scroll::-webkit-scrollbar-thumb:hover,
    [data-theme="dark"] .chat-scroll::-webkit-scrollbar-thumb:hover {
        background: #43474e;
    }

[data-theme="dark"] .send-btn {
    background: #3a3f47;
    color: #e8eaee;
}

    [data-theme="dark"] .send-btn:hover {
        background: #474d56;
    }

    [data-theme="dark"] .send-btn.loading {
        background: #2a2e35;
        color: #8b919d;
    }

    [data-theme="dark"] .send-btn.generating {
        background: var(--brand);
        color: #fff;
    }

[data-theme="dark"] .composer textarea::placeholder {
    color: #7e8593;
}

[data-theme="dark"] .welcome {
    color: #e5e7eb;
}

[data-theme="dark"] .reopen-bar {
    background: #2a2d33;
}

[data-theme="dark"] .rb-btn {
    color: #a1a7b3;
}

    [data-theme="dark"] .rb-btn:hover {
        background: rgba(255, 255, 255, .08);
        color: #e5e7eb;
    }

[data-theme="dark"] .sb-search input {
    background: #232529;
    color: #e5e7eb;
}

/* 空态：composer-wrap 原本硬编码白底，深色下会整块刷白 */
[data-theme="dark"] .main.empty .composer-wrap {
    background: var(--bg);
}

[data-theme="dark"] .main.empty .composer {
    box-shadow: 0 4px 20px rgba(0, 0, 0, .35);
}

/* 输入框上方原本是白色渐变遮罩（让消息淡出），深色下要换成背景色渐变 */
[data-theme="dark"] .composer-wrap {
    background: linear-gradient(180deg, rgba(25, 26, 29, 0) 0%, var(--bg) 40%);
}

/* ================= 用户区头像 ================= */
.u-avatar {
    width: 28px;
    height: 28px;
    flex: 0 0 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #9aa0ad;
    background-color: #eef1f5;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    overflow: hidden;
}

    /* 有真实头像时隐藏占位图标 */
    .u-avatar.has-photo svg {
        display: none;
    }

.login-tip {
    color: var(--brand);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: color .15s;
}

    .login-tip:hover {
        color: var(--brand-hover);
        text-decoration: underline;
    }

[data-theme="dark"] .u-avatar {
    background-color: #2a2d33;
    color: #858c99;
}

[data-theme="dark"] .login-tip {
    color: #8fbcfb;
}

    [data-theme="dark"] .login-tip:hover {
        color: #a9cdfd;
    }

/* 未登录时不展示文章引用条（整条隐藏，含「帮我总结一下」按钮） */
body.is-guest .news-ref.show,
body.is-guest .summary-chip.show {
    display: none;
}

/* ================= 宽屏响应式 ================= */
/* 默认 760px 适合阅读，但 1440px 以上右侧会空太多；按屏幕分档加宽，同时保持行长可控 */
@media (min-width: 1440px) {
    .chat-inner,
    .composer,
    .disclaimer {
        max-width: 900px;
    }

    .msg.user .bubble {
        max-width: 680px;
    }
}

@media (min-width: 1760px) {
    .chat-inner,
    .composer,
    .disclaimer {
        max-width: 1040px;
    }
}

@media (min-width: 2200px) {
    .chat-inner,
    .composer,
    .disclaimer {
        max-width: 1120px;
    }
}
