/* AI对话全屏页面样式 - DeepSeek Chat风格 */

/* AI对话容器 */
.ai-chat-fullscreen {
    display: flex;
    flex-direction: column;
    min-height: 600px;
    width: 100%;
    background: #f7f7f7;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    margin: 0rem 2rem 0rem 0rem;
    overflow: hidden;
}

/* 头部导航栏 */
.ai-chat-header {
    background: #ffffff;
    border-bottom: 1px solid #e5e5e5;
    padding: 0.75rem 1.5rem;
    flex-shrink: 0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.ai-chat-header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 1200px;
    margin: 0 auto;
}

.ai-chat-header-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    position: relative;
    z-index: 2;
}

.ai-chat-header-center {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-size: 1.25rem;
    padding: 0 1rem;
}

.ai-chat-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
    color: #191919;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-chat-description {
    font-size: 1rem;
    color: #000000;
    margin-top: 0.25rem;
    line-height: 1.4;
}

.ai-chat-header-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.ai-chat-header-icon {
    color: #666;
    font-size: 1.1rem;
    padding: 0.5rem;
    border-radius: 4px;
    transition: all 0.2s;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
}

.ai-chat-header-icon:hover {
    background: #f0f0f0;
    color: #191919;
}

#aiChatExportMdBtn:disabled,
#aiChatExportMdBtn.is-loading {
    opacity: 0.55;
    cursor: wait;
    pointer-events: none;
}

.ai-chat-claim-trial-btn {
    color: var(--bs-primary) !important;
    text-decoration: none;
    position: relative;
    z-index: 3;
    pointer-events: auto;
}

.ai-chat-claim-trial-btn:hover:not(:disabled) {
    background: rgba(var(--bs-primary-rgb), 0.1) !important;
    color: var(--sc-btn-active) !important;
}

.ai-chat-claim-trial-btn:disabled {
    opacity: 0.5;
}

/* 主内容区 - 两栏布局 */
.ai-chat-main {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: row;
    background: #f7f7f7;
    min-height: 400px;
    max-height: 70vh;
    height: calc(70vh - 60px);
    align-items: stretch;
}

/* 左侧历史对话边栏 */
.ai-chat-sidebar {
    width: 240px;
    flex-shrink: 0;
    min-height: 0;
    background: #ffffff;
    border-right: 1px solid #e5e5e5;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    align-self: stretch;
}

.ai-chat-sidebar-header {
    padding: 0.75rem;
    border-bottom: 1px solid #e5e5e5;
    flex-shrink: 0;
}

.ai-chat-sidebar-mobile-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: #333;
}

.ai-chat-sidebar-close {
    width: 32px;
    height: 32px;
    color: #666;
    line-height: 1;
}

.ai-chat-sidebar-close:hover {
    color: #333;
}

.ai-chat-sidebar-backdrop {
    display: none;
}

.ai-chat-new-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 0.75rem;
    background: var(--bs-primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.ai-chat-new-btn:hover {
    background: var(--sc-btn-active);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(var(--bs-primary-rgb), 0.2);
}

.ai-chat-new-btn:active {
    transform: translateY(0);
}

/* 历史对话列表 — 直接作为 sidebar 子元素滚动 */
.ai-chat-fullscreen .ai-chat-sidebar > .ai-chat-history-list {
    flex: 1 1 0;
    height: 0;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0.5rem;
    -webkit-overflow-scrolling: touch;
}

.ai-chat-history-list {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    width: 100%;
}

.ai-chat-history-pagination {
    flex-shrink: 0;
    display: none;
    align-items: center;
    justify-content: space-between;
    gap: 0.25rem;
    padding: 0.5rem 0.75rem;
    border-top: 1px solid #e5e5e5;
    background: #fafafa;
}

.ai-chat-history-page-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: #fff;
    color: #555;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.15s;
}

.ai-chat-history-page-btn:hover:not(:disabled) {
    border-color: var(--bs-primary);
    color: var(--bs-primary);
}

.ai-chat-history-page-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.ai-chat-history-page-info {
    flex: 1;
    text-align: center;
    font-size: 0.75rem;
    color: #666;
    white-space: nowrap;
}

.ai-chat-history-item {
    padding: 0.625rem;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.375rem;
    position: relative;
    border-left: 3px solid transparent;
}

.ai-chat-history-item:hover {
    background: #f7f7f7;
}

.ai-chat-history-item.active {
    background: #e8f5e9;
    border-left-color: var(--bs-primary);
}

.ai-chat-history-item-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.ai-chat-history-item-title {
    font-size: 0.8125rem;
    font-weight: 500;
    color: #191919;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    text-overflow: ellipsis;
    line-height: 1.4;
    max-height: 2.268rem; /* 2行的高度，0.8125rem * 1.4 * 2 ≈ 2.268rem */
    word-break: break-word;
}

.ai-chat-history-item-title-input {
    width: 100%;
    font-size: 0.875rem;
    font-weight: 500;
    color: #191919;
    border: 1px solid var(--bs-primary);
    border-radius: 4px;
    padding: 0.25rem 0.5rem;
    background: white;
    outline: none;
}

.ai-chat-history-item-title-input:focus {
    border-color: var(--bs-primary);
    box-shadow: 0 0 0 2px rgba(var(--bs-primary-rgb), 0.1);
}

.ai-chat-history-item-time-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 0.25rem;
}

.ai-chat-history-item-time {
    font-size: 0.75rem;
    color: #999;
    flex: 1;
}

.ai-chat-history-item-actions {
    display: flex;
    gap: 0.25rem;
    opacity: 0;
    transition: opacity 0.2s;
    margin-left: 0.5rem;
}

.ai-chat-history-item:hover .ai-chat-history-item-actions {
    opacity: 1;
}

.ai-chat-history-item-action {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    background: transparent;
    border: none;
    color: #666;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.75rem;
}

.ai-chat-history-item-action:hover {
    background: #e5e5e5;
    color: #191919;
}

.ai-chat-history-item-action.is-loading,
.ai-chat-history-item-action:disabled {
    opacity: 0.55;
    cursor: wait;
    pointer-events: none;
}

.ai-chat-history-empty {
    text-align: center;
    padding: 3rem 1rem;
    color: #999;
}

.ai-chat-history-empty i {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    opacity: 0.5;
}

.ai-chat-history-empty p {
    font-size: 0.875rem;
    margin: 0;
}

/* 右侧对话内容区域 */
.ai-chat-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
    min-height: 0; /* ✅ 允许flex子元素正确缩小 */
}

.ai-chat-messages {
    flex: 1;
    /* 必须为 0：固定像素（如 521）会锁死高度，短屏撑破布局，长屏又对不齐视口 */
    min-height: 0;
    overflow-y: auto;
    padding: 2rem 1rem;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
    scroll-behavior: smooth;
}

/* /ai 桌面：按视口占满剩余高度，空态与有内容同高 */
body.ai-chat-page .ai-chat-fullscreen {
    height: calc(100dvh - 220px);
    min-height: 480px;
    max-height: none;
}

body.ai-chat-page .ai-chat-main {
    flex: 1 1 auto;
    min-height: 0;
    height: auto;
    max-height: none;
}

body.ai-chat-page .ai-chat-content,
body.ai-chat-page .ai-chat-messages {
    min-height: 0;
}

/* 欢迎界面 */
.ai-chat-welcome {
    text-align: center;
    padding: 4rem 2rem;
    max-width: 600px;
    margin: 0 auto;
}

.ai-chat-welcome-icon {
    font-size: 4rem;
    color: var(--bs-primary);
    margin-bottom: 1.5rem;
    opacity: 0.8;
}

.ai-chat-welcome-title {
    font-size: 1.75rem;
    font-weight: 600;
    color: #191919;
    margin-bottom: 0.75rem;
}

.ai-chat-welcome-desc {
    font-size: 1rem;
    color: #666;
    margin-bottom: 2rem;
    line-height: 1.6;
    white-space: pre-line;
}

/* 搜索提示样式 */
.ai-chat-welcome-suggestions {
    margin-top: 2rem;
    text-align: left;
}

.ai-chat-welcome-suggestions-title {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 1rem;
    text-align: center;
}

.ai-chat-welcome-suggestions-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-width: 500px;
    margin: 0 auto;
}

.ai-chat-welcome-suggestion-item {
    padding: 0.5rem 1rem;
    border: 1px solid var(--bs-primary);
    background: rgba(var(--bs-primary-rgb), 0.1);
    color: var(--bs-primary);
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.875rem;
    transition: all 0.2s;
    text-align: center;
    width: 100%;
}

.ai-chat-welcome-suggestion-item:hover {
    background: var(--bs-primary);
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(var(--bs-primary-rgb), 0.2);
}

.ai-chat-welcome-suggestion-item:active {
    transform: translateY(0);
}

.ai-chat-welcome-login {
    margin-top: 2rem;
}

.ai-chat-guest-bar .ai-chat-input:disabled,
.ai-chat-guest-bar .ai-chat-send-btn:disabled {
    cursor: not-allowed;
    opacity: 0.65;
}

.ai-chat-guest-bar .ai-chat-send-btn:disabled {
    pointer-events: none;
}

.ai-chat-sidebar-guest-hint {
    text-align: center;
    line-height: 1.5;
}

/* 消息气泡样式 */
.ai-chat-message {
    margin-bottom: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    animation: fadeInUp 0.3s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ai-chat-message.user {
    align-items: flex-end;
}

.ai-chat-message.ai {
    align-items: flex-start;
}

.ai-chat-message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    background: var(--bs-primary);
    color: white;
    margin-bottom: 0.25rem;
}

.ai-chat-message.user .ai-chat-message-avatar {
    background: var(--sc-badge-primary);
    color: var(--sc-deep-primary);
}

.ai-chat-message-content {
    width: 100%;
    max-width: 100%;
}

.ai-chat-message-bubble {
    padding: 1rem 1.125rem;
    border-radius: 12px;
    line-height: 1.75;
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.ai-chat-message.user .ai-chat-message-bubble {
    background: var(--sc-badge-primary);
    color: var(--sc-deep-primary);
    border-top-right-radius: 4px;
}

.ai-chat-message.ai .ai-chat-message-bubble {
    background: #ffffff;
    color: #191919;
    border-top-left-radius: 4px;
    line-height: 1.75;
}

.ai-chat-message-text {
    margin: 0;
    word-break: break-word;
}

/* 用户消息保留换行；AI 回答已是 HTML，勿用 pre-wrap（标签间换行会显示成空行） */
.ai-chat-message.user .ai-chat-message-text {
    white-space: pre-wrap;
    line-height: 1.65;
}

.ai-chat-message.ai .ai-chat-message-text {
    white-space: normal;
    line-height: 1.75;
    font-size: 0.95rem;
}

/* AI 回答排版：保留适度段间距，避免过紧或过空 */
.ai-chat-message.ai .ai-chat-message-text p,
.ai-chat-message.ai .ai-chat-message-text .markdown-p {
    margin: 0;
    padding: 0;
    line-height: 1.75;
}

.ai-chat-message.ai .ai-chat-message-text p + p,
.ai-chat-message.ai .ai-chat-message-text .markdown-p + .markdown-p,
.ai-chat-message.ai .ai-chat-message-text p + ul,
.ai-chat-message.ai .ai-chat-message-text p + ol,
.ai-chat-message.ai .ai-chat-message-text ul + p,
.ai-chat-message.ai .ai-chat-message-text ol + p,
.ai-chat-message.ai .ai-chat-message-text blockquote + p,
.ai-chat-message.ai .ai-chat-message-text p + blockquote,
.ai-chat-message.ai .ai-chat-message-text pre + p,
.ai-chat-message.ai .ai-chat-message-text p + pre {
    margin-top: 0.85em;
}

.ai-chat-message.ai .ai-chat-message-text ul,
.ai-chat-message.ai .ai-chat-message-text ol,
.ai-chat-message.ai .ai-chat-message-text .markdown-ul,
.ai-chat-message.ai .ai-chat-message-text .markdown-ol {
    margin: 0.65em 0 0.75em;
    padding-left: 1.35em;
    line-height: 1.7;
}

.ai-chat-message.ai .ai-chat-message-text li,
.ai-chat-message.ai .ai-chat-message-text .markdown-li-ordered,
.ai-chat-message.ai .ai-chat-message-text .markdown-li-unordered {
    margin: 0.4em 0;
    line-height: 1.7;
}

.ai-chat-message.ai .ai-chat-message-text li > p {
    margin: 0;
    line-height: 1.7;
}

.ai-chat-message.ai .ai-chat-message-text h1,
.ai-chat-message.ai .ai-chat-message-text h2,
.ai-chat-message.ai .ai-chat-message-text h3,
.ai-chat-message.ai .ai-chat-message-text h4,
.ai-chat-message.ai .ai-chat-message-text h5,
.ai-chat-message.ai .ai-chat-message-text h6 {
    margin: 1em 0 0.55em;
    padding: 0;
    line-height: 1.45;
}

.ai-chat-message.ai .ai-chat-message-text h1:first-child,
.ai-chat-message.ai .ai-chat-message-text h2:first-child,
.ai-chat-message.ai .ai-chat-message-text h3:first-child,
.ai-chat-message.ai .ai-chat-message-text h4:first-child,
.ai-chat-message.ai .ai-chat-message-text h5:first-child,
.ai-chat-message.ai .ai-chat-message-text h6:first-child {
    margin-top: 0;
}

.ai-chat-message.ai .ai-chat-message-text blockquote {
    margin: 0.75em 0;
    padding: 0.5em 0.85em;
    line-height: 1.7;
}

.ai-chat-message.ai .ai-chat-message-text pre {
    margin: 0.75em 0;
    padding: 0.75em 1em;
    line-height: 1.55;
}

/* 打字机光标效果 */
.ai-chat-typing-cursor {
    display: inline-block;
    width: 1px;
    height: 1.2em;
    margin-left: 4px;
    vertical-align: text-bottom;
    animation: ai-chat-cursor-blink 1s infinite;
}

.ai-chat-streaming-text {
    white-space: normal;
    word-break: break-word;
    line-height: 1.75;
}

.ai-chat-stream-pending {
    margin-top: 0.2em;
    white-space: normal;
    word-break: break-word;
    opacity: 1;
}

.ai-chat-stream-sealed > :last-child {
    margin-bottom: 0.6em;
}

.ai-chat-stream-pending-tail {
    opacity: 1;
}

.ai-chat-stream-status {
    color: #6c757d;
    font-size: 0.92em;
}

.ai-chat-message.ai .ai-inline-cite {
    display: inline;
    margin: 0 0.1em;
    padding: 0 0.15em;
    font-size: 0.85em;
    font-weight: 600;
    line-height: 1;
    vertical-align: super;
    color: var(--bs-primary);
    text-decoration: none;
    white-space: nowrap;
}

.ai-chat-message.ai a.ai-inline-cite:hover {
    color: var(--bs-link-hover-color);
    text-decoration: underline;
}

.ai-chat-message.ai span.ai-inline-cite {
    color: #868e96;
    cursor: default;
}

/* 参考来源：上下分隔线内左对齐；窄屏长标题换行不溢出 */
.ai-chat-message.ai .ai-chat-sources-block {
    text-align: left;
    font-size: 0.75rem;
    margin-top: 0.75rem;
    padding: 0.55rem 0;
    border-top: 1px solid #e9ecef;
    border-bottom: none;
    max-width: 100%;
    min-width: 0;
    overflow-wrap: anywhere;
    box-sizing: border-box;
}

.ai-chat-message.ai .ai-chat-sources-label {
    display: block;
    margin: 0 0 0.35rem;
    padding: 0;
    color: #495057;
    font-size: 0.75rem;
    line-height: 1.5;
}

.ai-chat-message.ai .ai-chat-sources-list {
    margin: 0;
    padding: 0;
    list-style: none;
    counter-reset: source-item;
    font-size: 0.75rem;
    max-width: 100%;
    min-width: 0;
}

.ai-chat-message.ai .ai-chat-sources-item {
    display: flex;
    align-items: flex-start;
    gap: 0.35rem;
    margin: 0.28em 0;
    max-width: 100%;
    min-width: 0;
    line-height: 1.5;
    counter-increment: source-item;
}

.ai-chat-message.ai .ai-chat-sources-item::before {
    content: counter(source-item) ".";
    flex: 0 0 auto;
    min-width: 1.25em;
    text-align: right;
    color: #495057;
    font-size: 0.75rem;
    line-height: 1.5;
}

.ai-chat-message.ai .ai-chat-sources-item a,
.ai-chat-message.ai .ai-chat-sources-item > span {
    display: block;
    flex: 1 1 auto;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
    font-size: 0.75rem;
    font-weight: 400;
    background-color: #44474b;
    color: #fff;
    padding: 0.15em 0.45em;
    border-radius: 0.25rem;
    text-decoration: none;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
    line-height: 1.5;
}

.ai-chat-message.ai .ai-chat-sources-item a:hover {
    opacity: 0.9;
    color: #fff;
    text-decoration: none;
}

@keyframes ai-chat-cursor-blink {
    0%, 50% {
        opacity: 1;
    }
    51%, 100% {
        opacity: 0;
    }
}

/* Markdown 样式由 github-markdown.min.css 和 highlight-github.min.css 提供 */

/* 列表不受 white-space: pre-wrap 影响（与 ai-chat.css 保持一致） */
.ai-chat-message-text .markdown-ol,
.ai-chat-message-text .markdown-ul {
    white-space: normal !important;
    display: block !important;
}

.ai-chat-message-time {
    font-size: 0.75rem;
    color: #999;
    margin-top: 0.5rem;
    padding: 0 0.5rem;
}

/* 加载动画 */
.ai-chat-loading {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem;
    color: #666;
}

.ai-chat-loading-dots {
    display: flex;
    gap: 0.25rem;
}

.ai-chat-loading-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--bs-primary);
    animation: loadingDot 1.4s infinite ease-in-out;
}

.ai-chat-loading-dot:nth-child(1) {
    animation-delay: -0.32s;
}

.ai-chat-loading-dot:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes loadingDot {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* 底部输入区：边线 + 轻阴影，与全站卡片一致 */
.ai-chat-content .ai-chat-footer {
    background: #ffffff;
    border-top: 1px solid #e5e5e5;
    padding: 0.75rem 1rem;
    flex-shrink: 0;
    box-shadow: 0 -1px 3px rgba(0, 0, 0, 0.05);
    margin-top: auto;
}

/* 模式条 + 输入框：同一卡片区域 */
.ai-chat-composer {
    max-width: 1200px;
    margin: 0 auto;
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.ai-chat-composer:focus-within {
    border-color: var(--bs-primary);
    box-shadow: 0 0 0 3px rgba(var(--bs-primary-rgb), 0.1);
}

.ai-chat-composer-meta {
    max-width: 1200px;
    margin: 0.45rem auto 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0 0.15rem;
}

.ai-chat-input-container {
    max-width: none;
    margin: 0;
}

.ai-chat-input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 0.75rem;
    background: #f7f7f7;
    border-radius: 0;
    padding: 0.5rem 0.85rem 0.55rem;
    border: none;
    box-shadow: none;
    transition: none;
    margin: 0;
}

.ai-chat-input-wrapper:focus-within {
    border-color: #e5e5e5;
    box-shadow: none;
}

/* 未登录：同样卡片边线 */
.ai-chat-guest-bar {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0.55rem 0.85rem;
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.ai-chat-guest-bar .ai-chat-input-wrapper {
    background: transparent;
    border: none;
    border-radius: 0;
    padding: 0;
    box-shadow: none;
}

.ai-chat-guest-bar .ai-chat-input-wrapper:focus-within {
    border-color: transparent;
    box-shadow: none;
}

/* 全局有板块 chips、指定文档没有：固定同高；文字与左侧图标垂直居中 */
body.ai-chat-page .ai-chat-input-wrapper {
    min-height: 96px;
    box-sizing: border-box;
    align-items: center;
}

body.ai-chat-page .ai-chat-input-wrapper .ai-chat-input {
    align-self: center;
    min-height: 48px;
    height: auto;
    max-height: 160px;
    box-sizing: border-box;
    padding-top: 0.55rem;
    padding-bottom: 0.55rem;
}

body.ai-chat-page .ai-chat-input-wrapper .ai-chat-send-btn {
    align-self: center;
    height: 40px;
    min-height: 40px;
    width: 40px;
}

.ai-chat-scope-chips {
    display: none;
    flex-direction: column;
    gap: 4px;
    flex-shrink: 0;
    align-self: center;
    justify-content: center;
}

.ai-chat-scope-chips.is-visible {
    display: flex;
}

.ai-chat-scope-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    border: 1px solid #d0d0d0;
    background: #fff;
    color: #666;
    border-radius: 8px;
    padding: 4px 8px;
    font-size: 12px;
    font-family: inherit;
    line-height: 1.2;
    cursor: pointer;
    white-space: nowrap;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    transition: border-color 0.15s, background 0.15s, color 0.15s, box-shadow 0.15s;
}

.ai-chat-scope-chip i {
    font-size: 13px;
}

.ai-chat-scope-chip-label {
    display: inline;
}

.ai-chat-scope-chip.is-on {
    background: #e8f8ef;
    border-color: var(--bs-primary);
    color: var(--bs-primary);
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(var(--bs-primary-rgb), 0.15);
}

.ai-chat-scope-chip:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(var(--bs-primary-rgb), 0.2);
}

.ai-chat-input {
    flex: 1;
    border: none;
    background: transparent;
    resize: none;
    font-size: 0.9375rem;
    line-height: 1.5;
    padding: 0.5rem;
    min-height: 24px;
    max-height: 200px;
    overflow-y: auto;
    font-family: inherit;
    color: #191919;
}

.ai-chat-input:focus {
    outline: none;
}

.ai-chat-input::placeholder {
    color: #999;
}

.ai-chat-send-btn {
    width: 36px;
    height: 52px;
    border-radius: 8px;
    border: none;
    background: var(--bs-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s, box-shadow 0.2s, opacity 0.15s;
    flex-shrink: 0;
    font-size: 1rem;
    box-shadow: 0 2px 4px rgba(var(--bs-primary-rgb), 0.2);
}

.ai-chat-send-btn i {
    display: block;
    line-height: 1;
}

.ai-chat-send-btn:hover:not(:disabled) {
    background: var(--sc-btn-active);
    transform: none;
    box-shadow: 0 2px 8px rgba(var(--bs-primary-rgb), 0.3);
}

.ai-chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.ai-chat-quota-row {
    display: flex;
    align-items: center;
    padding: 0;
}

.ai-chat-footer-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 0.75rem;
    padding: 0 0.75rem;
}

/* 购买次数按钮样式 */
.ai-chat-purchase-btn {
    display: inline-flex;
    align-items: center;
    font-size: 0.75rem;
    padding: 0.375rem 0.875rem;
    border-radius: 20px;
    border: 1px solid var(--bs-primary);
    background: rgba(var(--bs-primary-rgb), 0.1);
    color: var(--bs-primary);
    transition: all 0.2s;
    text-decoration: none;
    cursor: pointer;
    font-weight: normal;
    line-height: 1.5;
    user-select: none;
    white-space: nowrap;
}

/* 导出当前对话 */
.ai-chat-export-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.75rem;
    padding: 0.375rem 0.875rem;
    border-radius: 20px;
    border: 1px solid #d0d5dd;
    background: #fff;
    color: #344054;
    transition: all 0.2s;
    text-decoration: none;
    cursor: pointer;
    font-weight: normal;
    line-height: 1.5;
    user-select: none;
    white-space: nowrap;
}

.ai-export-m {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.15rem;
    height: 1.15rem;
    border-radius: 4px;
    background: var(--bs-primary);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 800;
    font-family: Georgia, "Times New Roman", serif;
    line-height: 1;
    letter-spacing: 0;
    flex-shrink: 0;
}

.ai-chat-history-item-action .ai-export-m {
    width: 1rem;
    height: 1rem;
    font-size: 0.65rem;
    border-radius: 3px;
}

.ai-chat-export-btn:hover {
    background: #f2f4f7;
    border-color: #98a2b3;
    color: #1d2939;
    text-decoration: none;
}

.ai-chat-export-btn:disabled,
.ai-chat-export-btn.is-loading {
    opacity: 0.55;
    cursor: wait;
    pointer-events: none;
}

.ai-chat-purchase-btn:hover {
    background: var(--bs-primary);
    color: white;
    border-color: var(--bs-primary);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(var(--bs-primary-rgb), 0.2);
    text-decoration: none;
}

.ai-chat-purchase-btn:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(var(--bs-primary-rgb), 0.25);
}

/* 滚动条样式 */
.ai-chat-messages::-webkit-scrollbar,
.ai-chat-history-list::-webkit-scrollbar {
    width: 6px;
}

.ai-chat-messages::-webkit-scrollbar-track,
.ai-chat-history-list::-webkit-scrollbar-track {
    background: transparent;
}

.ai-chat-messages::-webkit-scrollbar-thumb,
.ai-chat-history-list::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.ai-chat-messages::-webkit-scrollbar-thumb:hover,
.ai-chat-history-list::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* 移动端侧边栏抽屉（< lg） */
@media (max-width: 991.98px) {
    .ai-chat-sidebar-backdrop {
        position: fixed;
        inset: 0;
        z-index: 1040;
        background: rgba(0, 0, 0, 0.45);
    }

    .ai-chat-sidebar-backdrop.is-visible {
        display: block;
    }

    .ai-chat-main {
        flex-direction: column;
    }

    .ai-chat-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: min(280px, 86vw);
        max-width: 320px;
        z-index: 1050;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        box-shadow: 2px 0 16px rgba(0, 0, 0, 0.12);
        height: 100dvh;
        max-height: 100dvh;
    }

    .ai-chat-fullscreen.ai-chat-sidebar-open .ai-chat-sidebar {
        transform: translateX(0);
    }

    .ai-chat-fullscreen .ai-chat-sidebar > .ai-chat-history-list {
        flex: 1 1 auto;
        height: auto;
        min-height: 0;
    }

    .ai-chat-content {
        width: 100%;
    }
}

/* /ai 移动端：隐藏站点页头页脚；中间自适应，输入区贴底 */
@media (max-width: 768px) {
    body.ai-chat-page > header.navbar-light,
    body.ai-chat-page > footer.bg-dark {
        display: none !important;
    }

    body.ai-chat-page {
        background: #f7f7f7;
        overflow: hidden;
        height: 100dvh;
    }

    body.ai-chat-page main {
        height: 100dvh;
        min-height: 0;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    body.ai-chat-page section.position-relative {
        flex: 1 1 auto;
        min-height: 0;
        padding-top: 0 !important;
        padding-bottom: 0 !important;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    body.ai-chat-page section.position-relative .container {
        flex: 1 1 auto;
        min-height: 0;
        padding-left: 0;
        padding-right: 0;
        max-width: none;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    body.ai-chat-page .first-level-section {
        display: none !important;
    }

    body.ai-chat-page .ai-chat-fullscreen {
        flex: 1 1 auto;
        min-height: 0;
        height: 100%;
        margin: 0;
        border-radius: 0;
        box-shadow: none;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    body.ai-chat-page .ai-chat-header {
        flex-shrink: 0;
    }

    /* 中间区域吃掉剩余高度，不再锁 70vh */
    body.ai-chat-page .ai-chat-main {
        flex: 1 1 auto;
        min-height: 0;
        height: auto !important;
        max-height: none !important;
        overflow: hidden;
    }

    body.ai-chat-page .ai-chat-content {
        flex: 1 1 auto;
        min-height: 0;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    body.ai-chat-page .ai-chat-messages {
        flex: 1 1 auto;
        min-height: 0;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* 输入区固定在对话区底部 */
    body.ai-chat-page .ai-chat-content .ai-chat-footer {
        flex-shrink: 0;
        margin-top: auto;
        position: relative;
        z-index: 2;
    }
}

/* 响应式设计 */
@media (max-width: 768px) {
    /* 页面容器调整 */
    section.position-relative {
        padding-top: 1.5rem !important;
        padding-bottom: 0.5rem !important;
    }

    section.position-relative .container {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }

    /* 标题区域调整 */
    .first-level-section {
        padding: 0.8rem !important;
    }

    .first-level-section h1 {
        font-size: 1.1rem !important;
    }

    /* 容器边距调整 */
    .ai-chat-fullscreen {
        margin: 0 0.5rem 1rem 0.5rem;
        border-radius: 8px;
        min-height: 500px;
    }

    /* 头部样式调整 */
    .ai-chat-header {
        padding: 0.5rem 0.75rem;
    }

    .ai-chat-header-content {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .ai-chat-header-left {
        order: 1;
        flex-shrink: 0;
    }

    .ai-chat-header-center {
        order: 3;
        flex: 1 1 100%;
        width: 100%;
        padding: 0.25rem 0;
        margin-top: 0.25rem;
    }

    .ai-chat-header-right {
        order: 2;
        flex-shrink: 0;
        margin-left: auto;
    }

    .ai-chat-title {
        font-size: 1rem;
    }

    .ai-chat-description {
        font-size: 0.75rem;
        margin-top: 0.15rem;
        line-height: 1.3;
    }

    /* 购买按钮调整 */
    .ai-chat-purchase-btn,
    .ai-chat-export-btn {
        font-size: 0.7rem;
        padding: 0.3rem 0.7rem;
    }

    .ai-chat-purchase-btn .me-1,
    .ai-chat-export-btn .me-1 {
        margin-right: 0.25rem;
    }

    .ai-chat-export-btn .ai-export-m {
        margin-right: 0;
    }

    /* 设置按钮调整 */
    .ai-chat-header-icon {
        width: 32px;
        height: 32px;
        font-size: 1rem;
        padding: 0.4rem;
    }

    /* 下拉菜单调整 */
    .ai-chat-settings-dropdown .dropdown-menu {
        min-width: 180px !important;
        font-size: 0.85rem;
    }

    /* 两栏布局：移动端侧边栏改为抽屉，不占主内容宽度 */
    .ai-chat-main {
        flex-direction: column;
    }

    .ai-chat-content {
        width: 100%;
    }

    /* 消息区域调整 */
    .ai-chat-messages {
        padding: 1rem 0.5rem;
    }

    .ai-chat-welcome {
        padding: 2rem 1rem;
    }

    .ai-chat-welcome-icon {
        font-size: 2.5rem;
    }

    .ai-chat-welcome-title {
        font-size: 1.25rem;
    }

    .ai-chat-welcome-desc {
        font-size: 0.9rem;
    }

    /* 输入区域调整 */
    .ai-chat-footer {
        padding: 0.5rem;
    }

    .ai-chat-input-container {
        padding: 0;
    }

    .ai-chat-input-wrapper {
        padding: 0.5rem;
        gap: 0.5rem;
        border-radius: 10px;
    }

    /* 移动端：输入文字与左侧小图标垂直居中 */
    body.ai-chat-page .ai-chat-input-wrapper {
        min-height: 96px;
        align-items: center;
    }

    body.ai-chat-page .ai-chat-input-wrapper .ai-chat-input {
        min-height: 44px;
        padding-top: 0.45rem;
        padding-bottom: 0.45rem;
    }

    body.ai-chat-page .ai-chat-input-wrapper .ai-chat-send-btn {
        height: 36px;
        min-height: 36px;
        width: 32px;
        font-size: 0.85rem;
        border-radius: 6px;
    }

    .ai-chat-scope-chips {
        width: 28px;
        min-width: 28px;
        gap: 2px;
    }

    .ai-chat-scope-chip {
        width: 26px;
        height: 26px;
        padding: 0;
        border-radius: 6px;
    }

    .ai-chat-scope-chip i {
        font-size: 11px;
    }

    .ai-chat-scope-chip-label {
        display: none;
    }

    .ai-chat-input {
        font-size: 0.9rem;
        padding: 0.4rem;
        min-height: 20px;
    }

    .ai-chat-send-btn {
        width: 32px;
        height: 50px;
        font-size: 0.85rem;
        border-radius: 6px;
    }

    .ai-chat-footer-info {
        flex-wrap: wrap;
        gap: 0.25rem;
        font-size: 0.7rem;
        padding: 0 0.5rem;
        margin-top: 0.5rem;
    }

    /* 消息气泡调整 */
    .ai-chat-message {
        margin-bottom: 0.75rem;
    }
    
    .ai-chat-message-content {
        max-width: 100%;
    }

    .ai-chat-message-text {
        font-size: 0.9rem;
        line-height: 1.5;
    }
}

/* 超小屏幕适配 */
@media (max-width: 480px) {
    /* 页面容器调整 */
    section.position-relative {
        padding-top: 1.5rem !important;
        padding-bottom: 0.5rem !important;
    }

    section.position-relative .container {
        padding-left: 0.25rem;
        padding-right: 0.25rem;
    }

    /* 标题区域调整 */
    .first-level-section h1 {
        font-size: 1rem !important;
    }

    .first-level-section .me-2 {
        margin-right: 0.5rem !important;
    }

    .ai-chat-fullscreen {
        margin: 0 0.25rem 0.5rem 0.25rem;
        min-height: 450px;
    }

    .ai-chat-header {
        padding: 0.5rem;
    }

    .ai-chat-header-center {
        padding: 0.15rem 0;
    }

    .ai-chat-description {
        font-size: 0.7rem;
    }

    .ai-chat-purchase-btn {
        font-size: 0.65rem;
        padding: 0.25rem 0.6rem;
    }

    /* 隐藏购买/导出按钮文字，只显示图标 */
    .ai-chat-purchase-text,
    .ai-chat-export-text {
        display: none;
    }

    .ai-chat-purchase-btn .me-1,
    .ai-chat-export-btn .me-1 {
        margin-right: 0;
    }

    .ai-chat-purchase-btn,
    .ai-chat-export-btn {
        padding: 0.3rem 0.5rem;
        min-width: 36px;
        justify-content: center;
    }

    .ai-chat-export-btn {
        gap: 0;
    }

    .ai-chat-messages {
        padding: 0.75rem 0.25rem;
    }

    .ai-chat-message {
        margin-bottom: 0.6rem;
    }
    
    .ai-chat-message-content {
        max-width: 100%;
    }

    .ai-chat-input-wrapper {
        padding: 0.4rem;
        gap: 0.4rem;
    }

    .ai-chat-input {
        font-size: 0.85rem;
        padding: 0.35rem;
        min-height: 18px;
    }

    .ai-chat-send-btn {
        width: 30px;
        height: 50px;
        font-size: 0.8rem;
    }

    .ai-chat-footer-info {
        font-size: 0.65rem;
        padding: 0 0.4rem;
    }
}

/* Markdown 样式由 github-markdown.min.css 提供，无需重复定义 */

.ai-chat-context-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem 0.75rem;
    flex-wrap: nowrap;
    height: 36px;
    min-height: 36px;
    max-height: 36px;
    padding: 0 0.85rem;
    border: none;
    border-bottom: 1px solid #e5e5e5;
    background: #fafafa;
    box-sizing: border-box;
}

.ai-chat-mode-switch {
    flex-shrink: 0;
    display: inline-flex;
    height: 36px;
    border: none;
    border-radius: 0;
    overflow: visible;
    background: transparent;
    gap: 0.15rem;
}

.ai-chat-mode-switch .ai-chat-mode-btn {
    min-width: auto;
    width: auto;
    height: 36px;
    padding: 0 0.35rem;
    font-size: 0.82rem;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    border: none !important;
    border-bottom: 2px solid transparent !important;
    border-radius: 0 !important;
    background: transparent !important;
    color: #8a8a8a;
    box-shadow: none !important;
}

.ai-chat-mode-switch .ai-chat-mode-btn + .ai-chat-mode-btn {
    border-left: none !important;
    margin-left: 0.55rem;
}

.ai-chat-mode-switch .btn.active,
.ai-chat-mode-switch .ai-chat-mode-btn.active {
    background: transparent !important;
    border-bottom-color: var(--bs-primary) !important;
    color: var(--bs-primary);
    font-weight: 600;
}

.ai-chat-material-summary {
    flex: 1 1 auto;
    min-width: 0;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.35rem;
    font-size: 0.8rem;
    color: #777;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.ai-chat-material-summary-hint-label {
    display: none;
    flex-shrink: 0;
    font-size: 0.68rem;
    line-height: 1;
    padding: 0.18rem 0.35rem;
    border: 1px solid #e0e0e0;
    border-radius: 3px;
    background: #f3f3f3;
    color: #999;
    font-weight: 500;
}

.ai-chat-material-summary-icon {
    flex-shrink: 0;
    color: #aaa;
}

.ai-chat-material-summary-caret {
    display: none;
    flex-shrink: 0;
    margin-left: 0.15rem;
    font-size: 0.65rem;
    color: #bbb;
}

/* 全局：右侧为只读提示，与可点击操作区分 */
.ai-chat-material-summary.is-hint {
    cursor: default;
    color: #9a9a9a;
    font-size: 0.75rem;
    user-select: none;
}

.ai-chat-material-summary.is-hint .ai-chat-material-summary-hint-label {
    display: inline-flex;
    align-items: center;
}

.ai-chat-material-summary.is-hint .ai-chat-material-summary-icon {
    color: #b0b0b0;
    font-size: 0.78rem;
}

/* 指定文档：无边框可点击文案，靠颜色/箭头区分操作 */
.ai-chat-material-summary.is-action {
    flex: 0 1 auto;
    cursor: pointer;
    justify-content: flex-end;
    align-self: center;
    height: 28px;
    max-width: min(100%, 20rem);
    margin: 0 0 0 auto;
    padding: 0 0.2rem;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: var(--bs-primary);
    font-size: 0.68rem;
    font-weight: 500;
    box-shadow: none;
    user-select: none;
}

.ai-chat-material-summary.is-action .ai-chat-material-summary-suffix {
    flex-shrink: 0;
    margin-left: 0.15rem;
    font-size: 0.62rem;
    font-weight: 400;
    color: #999;
}

.ai-chat-material-summary.is-action .ai-chat-material-summary-hint-label {
    display: none;
}

.ai-chat-material-summary.is-action:hover,
.ai-chat-material-summary.is-action:active {
    background: rgba(var(--bs-primary-rgb), 0.06);
    color: var(--bs-primary);
    box-shadow: none;
}

.ai-chat-material-summary.is-action .ai-chat-material-summary-caret {
    display: inline-block;
    margin-left: 0;
    color: var(--bs-primary);
}

.ai-chat-material-summary.is-action .ai-chat-material-summary-icon {
    color: var(--bs-primary);
    font-size: 0.68rem;
}

.ai-chat-material-summary.is-action.is-selected {
    font-weight: 400;
    color: #777;
}

.ai-chat-material-summary.is-action.is-selected .ai-chat-material-summary-icon {
    color: #aaa;
}

.ai-chat-material-summary.is-action.is-selected:hover .ai-chat-material-summary-icon,
.ai-chat-material-summary.is-action.is-selected:hover .ai-chat-material-summary-caret,
.ai-chat-material-summary.is-action.is-selected:hover .ai-chat-material-summary-suffix {
    color: var(--bs-primary);
}

.ai-chat-material-summary #aiMaterialSummaryText {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ai-chat-material-summary #aiMaterialSummaryText a {
    color: inherit;
    text-decoration: none;
    font-size: inherit;
    font-weight: 400;
    line-height: 1.2;
}

.ai-chat-material-summary.is-action #aiMaterialSummaryText a:hover {
    text-decoration: underline;
}

/* 选文档面板打开时：隐藏模式切换与「请选择」摘要，面板本身已足够 */
.ai-chat-composer.is-material-panel-open .ai-chat-mode-switch,
.ai-chat-composer.is-material-panel-open .ai-chat-material-summary {
    display: none !important;
}

.ai-chat-composer.is-material-panel-open .ai-chat-context-bar {
    display: none !important;
}

.ai-chat-material-panel {
    margin: 0;
    border: none;
    border-bottom: 1px solid #ebebeb;
    border-radius: 0;
    background: #fff;
    box-shadow: none;
    flex-direction: column;
    overflow: hidden;
}

.ai-chat-material-backdrop {
    display: none;
}

.ai-chat-material-panel-header,
.ai-chat-material-panel-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.65rem 0.85rem;
    border-bottom: 1px solid #f0f0f0;
    flex-shrink: 0;
}

.ai-chat-material-panel-header {
    background: #fafafa;
}

.ai-chat-material-panel-title {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    min-width: 0;
    color: #222;
    line-height: 1.2;
}

.ai-chat-material-panel-title > i {
    color: var(--bs-primary);
    font-size: 0.95rem;
    flex-shrink: 0;
}

.ai-chat-material-panel-title strong {
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: 0.01em;
}

.ai-chat-material-panel-close {
    width: 32px;
    height: 32px;
    margin: 0;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: #eee;
    color: #666;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, transform 0.15s;
}

.ai-chat-material-panel-close i {
    font-size: 0.85rem;
    line-height: 1;
}

.ai-chat-material-panel-close:hover {
    background: #e2e2e2;
    color: #222;
}

.ai-chat-material-panel-close:active {
    transform: scale(0.94);
}

.ai-chat-material-panel-close:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px rgba(var(--bs-primary-rgb), 0.25);
}

.ai-chat-material-panel-footer {
    border-bottom: none;
    border-top: 1px solid #f0f0f0;
    flex-shrink: 0;
    background: #fff;
}

.ai-chat-material-tab-content {
    max-height: 220px;
    overflow-y: auto;
    flex: 1 1 auto;
    min-height: 0;
}

.ai-chat-material-list {
    padding: 0.25rem 0.5rem;
}

.ai-chat-material-item {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.35rem 0.25rem;
    cursor: pointer;
    border-bottom: 1px dashed #f3f3f3;
}

.ai-chat-material-item-title {
    font-size: 0.85rem;
    line-height: 1.4;
}

.ai-chat-material-selected {
    padding: 0.35rem 0.75rem 0.5rem;
    min-height: 34px;
    max-height: 80px;
    overflow-y: auto;
    flex-shrink: 0;
}

.ai-material-chip {
    display: inline-flex;
    align-items: center;
    font-weight: normal;
}

.badge-multi-doc {
    background-color: var(--sc-btn-active) !important;
}

@media (max-width: 768px) {
    .ai-chat-content .ai-chat-footer {
        padding: 0.5rem;
    }

    .ai-chat-composer,
    .ai-chat-guest-bar {
        border-radius: 8px;
    }

    /* 移动端仍单行紧凑，与桌面同高，切换不跳 */
    .ai-chat-context-bar {
        height: 34px;
        min-height: 34px;
        max-height: 34px;
        padding: 0 0.65rem;
        gap: 0.45rem;
    }

    .ai-chat-mode-switch {
        height: 34px;
    }

    .ai-chat-mode-switch .ai-chat-mode-btn {
        width: auto;
        min-width: 0;
        height: 34px;
        font-size: 0.78rem;
        padding: 0 0.2rem;
    }

    .ai-chat-mode-switch .ai-chat-mode-btn + .ai-chat-mode-btn {
        margin-left: 0.4rem;
    }

    .ai-chat-material-summary {
        height: 34px;
        font-size: 0.75rem;
    }

    .ai-chat-material-summary.is-action {
        height: 28px;
        font-size: 0.66rem;
        padding: 0 0.15rem;
        max-width: min(100%, 12rem);
    }

    .ai-chat-material-summary.is-hint .ai-chat-material-summary-icon {
        display: none;
    }

    .ai-chat-composer-meta {
        padding: 0.3rem 0.65rem 0.45rem;
    }

    .ai-chat-input-wrapper {
        padding: 0.45rem 0.65rem 0.5rem;
    }

    .ai-chat-material-backdrop {
        position: fixed;
        inset: 0;
        z-index: 1040;
        background: rgba(0, 0, 0, 0.45);
    }

    .ai-chat-material-backdrop.is-visible {
        display: block;
    }

    .ai-chat-material-panel {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 1050;
        margin: 0;
        max-height: min(78vh, calc(100dvh - 48px));
        border-radius: 12px 12px 0 0;
        border-left: none;
        border-right: none;
        border-bottom: none;
        box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.15);
    }

    .ai-chat-material-panel-header {
        flex-shrink: 0;
        padding: 0.75rem 1rem 0.65rem;
        border-radius: 12px 12px 0 0;
        position: relative;
    }

    .ai-chat-material-panel-header::before {
        content: "";
        display: block;
        width: 36px;
        height: 4px;
        border-radius: 999px;
        background: #d8d8d8;
        margin: 0 auto 0.55rem;
        position: absolute;
        left: 50%;
        top: 0.4rem;
        transform: translateX(-50%);
    }

    .ai-chat-material-panel-title {
        padding-top: 0.35rem;
    }

    .ai-chat-material-panel-close {
        margin-top: 0.35rem;
        width: 30px;
        height: 30px;
    }

    .ai-chat-material-panel .nav-tabs {
        flex-shrink: 0;
    }

    .ai-chat-material-tab-content {
        max-height: none;
    }

    .ai-chat-material-panel-footer {
        padding-bottom: calc(0.5rem + env(safe-area-inset-bottom, 0px));
    }

    .ai-chat-material-panel-footer #aiMaterialConfirmBtn {
        min-width: 72px;
        padding: 0.35rem 1rem;
    }
}
