/* --- GENERAL STYLES --- */
/* --- 自定义字体定义 --- */
@font-face {
  font-family: 'MyCustomFont'; /* 1. 给你的字体起一个名字，后面会用到 */
  src: url('腾祥沁圆简.ttf') format('truetype'); /* 2. 指定字体文件的路径和格式 */
  /* 你还可以指定字重和样式，如果你的字体有多个文件的话 */
  /* font-weight: normal; */
  /* font-style: normal; */
  font-display: swap; /* 3. 优化加载行为，推荐使用 swap */
}
body {
    overflow: hidden;
    /* background-color and color will be handled by Bootstrap's data-bs-theme */
    font-family: 'MyCustomFont', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    /* transition: background-color 0.3s ease, color 0.3s ease; */ /* Bootstrap handles its own transitions */
}

.app-layout {
    overflow: hidden;
}
.app-layout.vh-100 {
    height: 100dvh !important;
}

/* --- SCROLLBAR STYLES (These are fine, keep them if you like custom scrollbars) --- */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: var(--bs-tertiary-bg); /* Use Bootstrap's tertiary background for track */
    border-radius: 4px;
}
::-webkit-scrollbar-thumb {
    background: var(--bs-secondary-color); /* Use Bootstrap's secondary text color for thumb */
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--bs-gray-600); /* Darker gray on hover */
}
[data-bs-theme="dark"] ::-webkit-scrollbar-thumb {
    background: var(--bs-gray-700);
}
[data-bs-theme="dark"] ::-webkit-scrollbar-thumb:hover {
    background: var(--bs-gray-600);
}


/* --- FULL PAGE AUTH VIEW --- */
#fullPageAuthView {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background-color: var(--bs-secondary-bg); /* Bootstrap variable */
    padding: 1rem;
}
.auth-form-container {
    min-width: 320px;
    max-width: 480px;
    width: 100%;
}
/* Card and form elements within fullPageAuthView will use Bootstrap's default theme-aware styles */
/* If specific overrides are still needed, target them minimally: */
/*
#fullPageAuthView .card {
    background-color: var(--bs-body-bg);
    border-color: var(--bs-border-color);
}
*/

.app-layout.initially-hidden {
     display: none !important;
}

/* --- SIDEBAR --- */
#conversationSidebar {
    width: 280px;
    min-width: 280px;
    flex-shrink: 0;
    /* background-color, color, border-right will be handled by Bootstrap's .offcanvas or your direct assignments */
    background-color: var(--bs-light-bg-subtle); /* Or a more specific sidebar bg if Bootstrap doesn't provide one */
    border-right: 1px solid var(--bs-border-color);
}
[data-bs-theme="dark"] #conversationSidebar {
    background-color: var(--bs-dark-bg-subtle); /* Example dark sidebar bg */
}

@media (max-width: 991.98px) {
    #conversationSidebar.offcanvas {
        /* Offcanvas specific background might be needed if default isn't right */
        /* background-color: var(--bs-body-bg) !important; */
    }
    /* Dark theme close button for offcanvas, Bootstrap should handle this, but if not: */
    [data-bs-theme="dark"] #conversationSidebar.offcanvas .offcanvas-header .btn-close {
       filter: invert(1) grayscale(100%) brightness(200%);
    }
}

#conversationSidebar .btn-new-conversation {
    /* Use Bootstrap button variables for consistency */
    background-color: var(--bs-primary);
    color: var(--bs-light); /* Or var(--bs-white) */
    border-color: var(--bs-primary);
}
#conversationSidebar .btn-new-conversation:hover {
    opacity: 0.9;
}

#conversationSidebar .conversation-list-container {
    max-height: calc(100vh - 120px); /* This is layout, keep */
}

#conversationSidebar .list-group-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 0.85rem;
    border-radius: 0.375rem;
    margin-bottom: 0.3rem;
    font-size: 0.9em;
    /* background-color, border, color will be handled by Bootstrap .list-group-item and .active */
    /* If you want a very custom look different from Bootstrap's list-group: */
    background-color: var(--bs-tertiary-bg);
    border: 1px solid transparent;
    color: var(--bs-body-color);
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}
#conversationSidebar .list-group-item:hover {
    background-color: var(--bs-secondary-bg);
}
#conversationSidebar .list-group-item.active {
    background-color: var(--bs-primary);
    border-color: var(--bs-primary);
    color: var(--bs-light); /* Or var(--bs-white) */
    font-weight: 500;
}


#conversationSidebar .conversation-title-text {
    flex-grow: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-right: 0.5rem;
}

#conversationSidebar .conversation-options-dropdown .btn {
    color: var(--bs-secondary-color);
    padding: 0.1rem 0.4rem;
    border: none;
}
#conversationSidebar .list-group-item.active .conversation-options-dropdown .btn {
    color: var(--bs-light); /* Match active item text */
}
/* Hover/focus for dropdown button can rely on Bootstrap or minimal override */
#conversationSidebar .conversation-options-dropdown .btn:hover,
#conversationSidebar .conversation-options-dropdown .btn:focus {
    background-color: var(--bs-tertiary-bg); /* Subtle hover */
}


#conversationSidebar .dropdown-menu {
    /* Bootstrap .dropdown-menu will be theme-aware */
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}
#conversationSidebar .dropdown-menu .dropdown-item {
    font-size: 0.9em;
    /* color, hover background handled by Bootstrap */
}
#conversationSidebar .dropdown-menu .dropdown-item.text-danger {
    /* color: var(--bs-danger) !important; Keep if Bootstrap's default text-danger isn't strong enough */
}
#conversationSidebar .dropdown-menu .dropdown-item.text-danger:hover {
    /* background-color: var(--bs-danger-bg-subtle); */
    /* color: var(--bs-danger-text-emphasis) !important; */
}
#conversationSidebar .sidebar-footer-text {
    color: var(--bs-secondary-color); /* Bootstrap's muted text color */
}


/* --- CHAT CONTAINER --- */
.chat-container {
    overflow: hidden;
    /* background-color: var(--bs-body-bg); Will use Bootstrap's body background */
}

.chat-header {
    /* background-color: var(--bs-tertiary-bg); Use a subtle background */
    /* border-bottom: 1px solid var(--bs-border-color) !important; */
}
/* Buttons and select in header will use Bootstrap defaults */


/* --- CONVERSATION FILE CONTEXT --- */
#conversationFileContextWrapper .btn {
    text-align: left;
    /* color: var(--bs-secondary-color); */
    /* background-color: transparent; */
    /* border-color: var(--bs-border-color); */
}
/*
#conversationFileContextWrapper .btn:hover {
    background-color: var(--bs-tertiary-bg);
}
*/
#conversationFileContextWrapper .btn .collapse-icon {
    transition: transform 0.2s ease-in-out;
}
#conversationFileContextWrapper .btn[aria-expanded="true"] .collapse-icon {
    transform: rotate(180deg);
}
#conversationFileContextDisplay {
    /* background-color: var(--bs-tertiary-bg); */
    /* border: 1px solid var(--bs-border-color) !important; */
    /* color: var(--bs-secondary-color); */
}


/* --- MESSAGE DISPLAY AREA --- */
.chat-messages {
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

/* 1. 设定基础消息块的通用样式 */
.message {
    padding: 1rem;                      /* 给予足够的内部空间 */
    margin-bottom: 1rem;                /* 关键：用外边距在垂直方向上清晰地分隔消息 */
    border-radius: 0.75rem;             /* 现代感的圆角 (Bootstrap .rounded-3) */
    max-width: 100%;                     /* 限制最大宽度，避免过长 */
    line-height: 1.6;                   /* 增加行高，提升可读性 */
    box-shadow: var(--bs-box-shadow-sm);/* 添加一个非常细微的阴影，增加层次感 (可选) */
}

/* 2. 为用户消息设置独特的背景和对齐方式 */
.user-message {
    align-self: flex-end; /* 消息靠右对齐 */
    background-color: var(--bs-primary-bg-subtle) !important; /* 关键：使用主题中的淡主色作为背景 */
    color: var(--bs-primary-text-emphasis) !important;      /* Bootstrap 提供的配套文字颜色，确保对比度 */
    border-bottom-right-radius: 0.25rem; /* 小技巧：靠边的角更尖锐，有“锚定”感 */
}

/* 3. 为模型消息设置背景和对齐方式 */
.model-message {
    align-self: flex-start; /* 消息靠左对齐 */
    background-color: var(--bs-secondary-bg) !important; /* 关键：使用次要背景色，与页面背景有轻微区分 */
    color: var(--bs-body-color) !important;              /* 使用标准的正文颜色 */
    border-bottom-left-radius: 0.25rem; /* 同上，锚定在左侧 */
}
.model-message.thinking {
    font-style: italic;
    color: var(--bs-secondary-color);
}
.model-message .message-content-wrapper img,
.model-message .message-content-wrapper video,
.model-message .message-content-wrapper audio {
    max-width: 100%;
    height: auto;
    border-radius: 0.375rem;
    margin-top: 0.5rem;
}

.message .role {
    font-weight: 600;       /* 加粗 */
    font-size: 0.85em;      /* 尺寸稍小 */
    margin-bottom: 0.3rem;  /* 和下方的消息内容保持一点距离 */
    display: block;         /* 独占一行 */
    opacity: 0.8;           /* 略微降低不透明度，使消息内容更突出 */
}
.message .file-attachment-info {
    font-size: 0.8em;
    padding: 5px 8px;
    background-color: var(--bs-tertiary-bg); /* Using tertiary for a subtle bg */
    border-radius: 4px;
    margin-top: 5px;
    display: inline-block;
}
.message .file-attachment-info i {
    margin-right: 5px;
}

.system-message {
    font-size: 0.9rem;
    color: var(--bs-secondary-color);
}


/* --- INPUT AREA --- */
.chat-input-area {
    /* background-color: var(--bs-tertiary-bg); */
    /* border-top: 1px solid var(--bs-border-color) !important; */
}
.chat-input-area textarea {
    resize: none;
    max-height: 150px; /* Keep layout style */
    overflow-y: auto; /* Keep layout style */
    /* background-color, color, border, focus styles from Bootstrap .form-control */
}
/* Placeholder color will be handled by Bootstrap */
/* Focus styles will be handled by Bootstrap */

.chat-input-area .btn-outline-secondary,
.chat-input-area .btn-outline-info {
    white-space: nowrap; /* Keep layout style */
    /* Colors and borders from Bootstrap .btn-outline-* */
}
/* Hover for .btn-outline-info will be Bootstrap default */


/* --- FILE UPLOAD & PREVIEW --- */
.upload-progress-overall-container {
    width: 100%;
    background-color: var(--bs-tertiary-bg);
    border-radius: 4px;
    margin-bottom: 10px;
    height: 10px;
    overflow: hidden;
}
.upload-progress-overall-bar {
    width: 0%;
    height: 100%;
    background-color: var(--bs-primary);
    text-align: center;
    line-height: 10px;
    color: white; /* Bootstrap .progress-bar text is white */
    font-size: 0.7em;
    border-radius: 4px;
    transition: width 0.2s ease-out;
}
.upload-progress-overall-bar.error, /* Assuming you add 'error' class via JS */
.upload-progress-overall-bar.bg-danger { /* Or use Bootstrap's bg-danger */
    background-color: var(--bs-danger) !important;
}


#pendingFilesPreview {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 1rem;
}
.file-preview-item-container {
    width: 150px;
    padding: 8px;
    border: 1px solid var(--bs-border-color);
    border-radius: 6px;
    background-color: var(--bs-tertiary-bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05); /* Keep subtle shadow if desired */
}
[data-bs-theme="dark"] .file-preview-item-container {
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.file-preview-item-container .preview-media {
    max-width: 100%;
    max-height: 100px;
    margin-bottom: 8px;
    border-radius: 4px;
    object-fit: contain;
}
.file-preview-item-container video.preview-media,
.file-preview-item-container audio.preview-media {
    width: 100%;
}
.file-preview-item-container .file-meta-info .file-name {
    font-weight: bold;
    display: block;
    margin-bottom: 3px;
    width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    /* color: var(--bs-secondary-color); */
}
.file-preview-item-container .file-meta-info {
    font-size: 0.8rem;
    color: var(--bs-secondary-color); /* Muted text */
    width: 100%;
    text-align: center;
}
.file-preview-item-container .remove-file-preview {
    margin-top: auto;
    color: var(--bs-danger);
    cursor: pointer;
    font-size: 1.2em;
}
.file-preview-item-container .remove-file-preview:hover {
    opacity: 0.7;
}


/* --- TOOL OPTIONS --- */
.tool-options {
    /* border-top: 1px solid var(--bs-border-color) !important; */
}
/* Form check/switch styles will be handled by Bootstrap */


/* --- SEND BUTTON SPINNER (Keep as is) --- */
#sendButton .spinner-border-sm {
    display: none;
}
#sendButton.sending .bi-send-fill {
    display: none;
}
#sendButton.sending .spinner-border-sm {
    display: inline-block;
}


/* --- MODALS --- */
/* Bootstrap .modal-content, .modal-header, .modal-body, .modal-footer will be theme-aware */
/* Input elements within modals will also be theme-aware */
[data-bs-theme="dark"] .modal-header .btn-close {
   filter: invert(1) grayscale(100%) brightness(200%); /* Ensure close button is visible in dark modal */
}
/* Danger Modal Header */
.modal-header-danger { /* You can still use this class for specific danger modals */
    background-color: var(--bs-danger-bg-subtle); /* Bootstrap variable */
    color: var(--bs-danger-text-emphasis);   /* Bootstrap variable */
    border-bottom-color: var(--bs-danger-border-subtle);
}
.modal-header-danger .modal-title {
    color: var(--bs-danger-text-emphasis);
}
.modal-header-danger .btn-close {
   filter: invert(1) grayscale(100%) brightness(200%) !important; /* Keep for high contrast */
}

/* Bilibili specific styles for text elements if needed */
/* #bilibiliVideoDesc { color: var(--bs-secondary-color); } */


/* --- DEBUG OUTPUT (Keep as is, or adapt to Bootstrap variables if preferred) --- */
#debugOutputContainer {
    position: fixed;
    bottom: 0;
    right: 0;
    max-width: 400px;
    max-height: 300px;
    overflow: auto;
    z-index: 10000;
    border-top-left-radius: 0.5rem;
    background-color: var(--bs-dark); /* Using Bootstrap dark for debug bg */
    color: var(--bs-light);           /* Using Bootstrap light for debug text */
    border: 1px solid var(--bs-gray-700);
    box-shadow: -2px -2px 10px rgba(0,0,0,0.1);
}
[data-bs-theme="light"] #debugOutputContainer {
    background-color: var(--bs-light);
    color: var(--bs-dark);
    border: 1px solid var(--bs-gray-300);
}
#debugOutputContainer h6 {
    color: inherit; /* Inherit from parent */
}
#debugOutput {
    font-size: 0.8em;
    white-space: pre-wrap;
    word-break: break-all;
    color: inherit;
}


/* --- TABLE STYLING (from model messages) --- */
/* Bootstrap .table, .table-striped, .table-bordered should be theme-aware */
/* If you use these classes on your tables generated from markdown, they will adapt. */
/* The following custom table styles can be simplified or removed if you use BS classes. */
.model-message .message-content-wrapper table {
    /* These styles are very custom. If you add .table class to your generated tables, */
    /* Bootstrap will handle theming. If not, you'll need to provide dark theme versions or use BS vars. */
    /* For example: */
    /* color: var(--bs-body-color); */
    /* border: 1px solid var(--bs-border-color); */
    font-size: 0.9em;
}
.model-message .message-content-wrapper th,
.model-message .message-content-wrapper td {
    padding: 0.65rem;
    vertical-align: top;
    /* border: 1px solid var(--bs-border-color); */
}
.model-message .message-content-wrapper thead th {
    vertical-align: bottom;
    /* border-bottom: 2px solid var(--bs-border-color); */
    /* background-color: var(--bs-tertiary-bg); */
    font-weight: 600;
}
/*
.model-message .message-content-wrapper tbody tr:nth-of-type(odd) {
    background-color: var(--bs-tertiary-bg); // If using Bootstrap's table-striped, this is not needed
}
.model-message .message-content-wrapper tbody tr:hover {
    background-color: var(--bs-secondary-bg); // If using Bootstrap's table-hover, this is not needed
}
*/

/* Search Entry Point (Grounding) */
.search-entry-point {
    margin-top: 1rem;
    border-top: 1px dashed var(--bs-border-color);
    padding-top: 0.5rem;
    font-size: 0.9em;
    /* color: var(--bs-secondary-color); */
}
.search-entry-point a {
    /* color: var(--bs-link-color); */
    text-decoration: none;
}
/* .search-entry-point a:hover { text-decoration: underline; } */

/* Theme selector in Modal: Buttons will use Bootstrap's .btn-outline-primary theming */

/* --- GROUNDING / VERIFICATION STYLES --- */
.grounding-container {
    /* background-color: var(--bs-tertiary-bg); */
    /* border: 1px solid var(--bs-border-color) !important; */
    /* color: var(--bs-body-color); */
}
.grounding-label {
    font-size: 0.9em;
    /* color: var(--bs-secondary-color); */
    margin-right: 8px;
    font-weight: bold;
}
.grounding-placeholder-text {
    font-size: 0.9em;
    /* color: var(--bs-secondary-color); */ /* Bootstrap .text-muted should work */
    margin: 0;
}
.grounding-chip {
    display: inline-block;
    padding: 3px 10px;
    /* border: 1px solid var(--bs-border-color); */
    border-radius: 16px;
    /* background-color: var(--bs-body-bg); */
    /* color: var(--bs-link-color); */
    text-decoration: none;
    font-size: 0.8em;
    margin-right: 6px;
    margin-bottom: 4px;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}
/*
.grounding-chip:hover {
    background-color: var(--bs-tertiary-bg);
    border-color: var(--bs-link-color);
}
*/
.grounding-sources-collapsed .grounding-source-list-collapsed {
    list-style: none;
    padding-left: 0;
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 6px 10px;
}
.grounding-source-item-collapsed { margin: 0; }
.grounding-source-link-collapsed {
    display: inline-block;
    padding: 3px 10px;
    /* border: 1px solid var(--bs-border-color); */
    border-radius: 4px;
    /* background-color: var(--bs-body-bg); */
    /* color: var(--bs-link-color); */
    text-decoration: none;
    font-size: 0.8em;
    transition: background-color 0.2s ease;
}
/*
.grounding-source-link-collapsed:hover {
    background-color: var(--bs-tertiary-bg);
}
*/
.grounding-content--expandable {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out, margin-top 0.3s ease-out, padding-top 0.3s ease-out, border-top-width 0.3s ease-out;
    margin-top: 0;
    padding-top: 0;
    border-top: 0px solid transparent;
}
.grounding-container.expanded .grounding-content--expandable {
    max-height: 1500px; /* Keep large max-height */
    transition: max-height 0.3s ease-in, margin-top 0.3s ease-in, padding-top 0.3s ease-in, border-top-width 0.3s ease-in;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid var(--bs-border-color);
}
.grounding-source-group { margin-bottom: 12px; }
.grounding-source-title {
    font-size: 1em;
    /* color: var(--bs-body-color); */
}
.grounding-source-link-expanded {
    /* color: var(--bs-link-color); */
    text-decoration: none;
    font-weight: 500;
}
/* .grounding-source-link-expanded:hover { text-decoration: underline; } */
.grounding-segment-list {
    margin-top: 4px;
    list-style-type: disc;
}
.grounding-segment-item {
    line-height: 1.5;
    font-size: 0.95em;
    /* color: var(--bs-secondary-color); */
    margin-bottom: 5px;
}
.grounding-toggle-container { padding-bottom: 5px; }
.grounding-toggle-button {
    /* Will use Bootstrap .btn and .btn-outline-* theming if class is applied */
    /* If not, define explicitly or use BS vars */
    /* color: var(--bs-secondary-color); */
    /* background-color: transparent; */
    /* border: 1px solid var(--bs-border-color); */
    padding: 0.25rem 0.75rem;
}
.grounding-toggle-icon {
    margin-left: 5px;
    vertical-align: middle;
    transition: transform 0.2s ease-in-out;
}
.grounding-error {
    /* background-color: var(--bs-danger-bg-subtle); */
    /* color: var(--bs-danger-text-emphasis); */
    /* border: 1px solid var(--bs-danger-border-subtle) !important; */
}

/* Input disabled state: Bootstrap should handle .form-control:disabled */

/* --- FORM CHECK INPUTS (checkbox, switch) --- */
/* Bootstrap .form-check-label, .form-check-input will be theme-aware */

/* --- CONVERSATION FILE CONTEXT DISPLAY --- */
/* List group items and Badges will use Bootstrap's theme-aware styles */
/* Example: #conversationFileContextDisplay .list-group-item should adapt */
/* #conversationFileContextDisplay .badge.bg-danger will adapt */


/* --- THOUGHTS BLOCK --- */
.thoughts-block {
    margin-bottom: 0.75rem;
    border: 1px solid var(--bs-border-color);
    border-radius: 0.375rem;
    background-color: var(--bs-tertiary-bg);
    overflow: hidden;
}
.thoughts-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    border-bottom: 1px solid var(--bs-border-color);
    font-size: 0.875em;
    color: var(--bs-secondary-color);
}
.thoughts-block:not(.expanded) .thoughts-header {
    padding-top: 0.25rem;
    padding-bottom: 0.25rem;
    border-bottom: none;
    height: auto;
}
.thoughts-status-container {
    display: flex;
    align-items: center;
    column-gap: 0.5rem;
    row-gap: 0.1em;
    flex-wrap: wrap;
    align-content: flex-start;
    overflow: hidden;
    line-height: 1.2;
}
.thoughts-status-container .spinner-border {
    /* color: var(--bs-secondary-color); /* Or Bootstrap default */
    flex-shrink: 0;
}
.thinking-status-text {
    font-weight: 500;
    /* color: var(--bs-secondary-color); */
}
.current-thought-summary {
    font-style: italic;
    color: var(--bs-text-muted); /* More muted */
    margin-left: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    display: inline-block;
    flex-basis: 100%;
}
.toggle-thoughts-btn {
    background: none;
    border: none;
    padding: 0.25rem 0.5rem;
    color: var(--bs-secondary-color);
    line-height: 1;
}
.toggle-thoughts-btn:hover {
    color: var(--bs-body-color);
}
.toggle-thoughts-btn i {
    transition: transform 0.2s ease-in-out;
}
.thoughts-block.expanded .toggle-thoughts-btn i.bi-chevron-down,
.thoughts-block:not(.expanded) .toggle-thoughts-btn i.bi-chevron-up { /* Corrected logic for up arrow when not expanded */
    transform: rotate(180deg);
}
.thoughts-content {
    padding: 0.75rem;
    font-size: 0.85em;
    line-height: 1.5;
    max-height: 150px; /* Keep if this is a desired constraint */
    overflow-y: auto;
    background-color: var(--bs-body-bg); /* Main content area background */
    color: var(--bs-body-color);
}
.thought-step {
    padding: 0.3rem 0;
    border-bottom: 1px dashed var(--bs-border-color-translucent); /* Softer dash */
    white-space: pre-wrap;
    word-break: break-word;
}
.thought-step:last-child {
    border-bottom: none;
}

.local-api-settings-section.visually-hidden {
    display: none !important;
}

/* === Code Block Enhancements === */
/* These are very specific to your custom code block. Try to use BS vars where possible. */
.code-block-wrapper {
    position: relative;
    margin-bottom: 1rem;
    border-radius: 0.25rem;
    background-color: var(--bs-tertiary-bg);
    border: 1px solid var(--bs-border-color);
    overflow: hidden;
}
.code-block-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.35rem 0.75rem;
    background-color: var(--bs-light-bg-subtle); /* Or another subtle BS background */
    border-bottom: 1px solid var(--bs-border-color);
    font-size: 0.8rem;
    color: var(--bs-secondary-color);
}
[data-bs-theme="dark"] .code-block-header {
    background-color: var(--bs-dark-bg-subtle);
}

.code-block-language {
    font-weight: bold;
    text-transform: capitalize;
    color: var(--bs-body-color); /* Contrast with header bg */
}
.code-block-copy-button {
    background-color: transparent;
    border: none;
    color: var(--bs-link-color);
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    font-size: 0.9rem;
    line-height: 1;
    border-radius: 0.2rem;
    transition: background-color 0.15s ease-in-out, color 0.15s ease-in-out;
}
.code-block-copy-button i { pointer-events: none; }
.code-block-copy-button:hover {
    color: var(--bs-link-hover-color);
    background-color: var(--bs-tertiary-bg);
}
/*
.code-block-copy-button:active {
    background-color: var(--bs-secondary-bg);
}
*/

.code-block-wrapper pre {
    margin: 0 !important;
    border-radius: 0 !important;
    border: none !important;
    padding: 0.75rem !important;
    overflow-x: auto;
    /* Prism themes handle their own background for <pre> or <code> */
}
.code-block-wrapper pre code[class*="language-"] {
    font-size: 0.875rem;
    line-height: 1.5;
}
.code-render-tabs,
.code-render-tabs .nav-tabs,
.code-render-tabs .nav-link,
.code-render-tabs .tab-content,
.code-render-tabs .tab-pane {
    white-space: normal !important; /* 或者 initial, unset */
    white-space-collapse: collapse !important; /* 如果原先是 preserve */
    text-wrap-mode: normal !important; /* 如果原先是 wrap */
    /* 你可能只需要重置 white-space 就够了 */
}

.svg-preview-container {
    width: 100%;
    min-height: 100px; /* 或者根据内容自适应，或者设置一个最大高度 */
    max-height: 500px; /* 防止过大的SVG撑破布局 */
    resize: vertical;
    overflow: auto;
    border: 1px dashed #ccc; /* 只是一个视觉提示，可以去掉 */
    padding: 5px;
    box-sizing: border-box; /* 确保 padding 和 border 不会增加总宽度 */
    display: flex; /* 可选：用于内部 SVG 的对齐 */
    justify-content: center; /* 可选：水平居中 SVG */
    align-items: center; /* 可选：垂直居中 SVG */
}

.svg-preview-container svg {
    max-width: 100%; /* 确保 SVG 在容器内响应式缩放 */
    max-height: 100%; /* (可选) 如果容器有固定高度，确保 SVG 不会溢出 */
    display: block; /* 移除 SVG 元素底部可能产生的额外空间 */
    margin: auto; /* 另一种居中方式 */
}

/* 粘贴到 style.css */
.splash-screen-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: var(--bs-body-bg); /* 使用主题背景色 */
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999; /* 最高层级 */
    opacity: 1;
    transition: opacity 0.7s ease-out; /* 平滑淡出 */
}

.splash-screen-container.hidden {
    opacity: 0;
    pointer-events: none; /* 淡出后允许与下方元素交互 */
}

.splash-content {
    text-align: center;
}

/* 将此CSS添加到您的样式表中 */

.rendered-svg-container {
    position: relative; /* 关键：为内部绝对定位的元素提供坐标系 */
    border: 1px solid #e0e0e0; /* 您要求的单线边框 */
    border-radius: 6px;
    padding: 1rem;
    background-color: #ffffff; /* 确保SVG在深色模式下也有白色背景 */
    margin: 1rem 0;
    overflow: hidden; /* 防止SVG内容溢出边框 */
}

/* 深色模式下的背景调整 */
[data-bs-theme="dark"] .rendered-svg-container {
    background-color: #2b3035; /* 一个适合深色模式的背景色 */
    border-color: #444;
}

.svg-controls {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 10;
}

.svg-download-btn {
    background-color: rgba(255, 255, 255, 0.8);
    border: 1px solid #ccc;
    border-radius: 5px;
    padding: 4px 8px;
    cursor: pointer;
    opacity: 0; /* 默认隐藏 */
    transition: opacity 0.2s ease-in-out;
    font-size: 14px;
    line-height: 1;
}

/* 深色模式下的按钮样式 */
[data-bs-theme="dark"] .svg-download-btn {
    background-color: rgba(40, 40, 40, 0.8);
    border-color: #555;
    color: #eee;
}

/* 当鼠标悬停在容器上时，显示下载按钮 */
.rendered-svg-container:hover .svg-download-btn {
    opacity: 1;
}

.svg-download-menu {
    display: none; /* 默认隐藏菜单 */
    position: absolute;
    top: 100%;
    right: 0;
    background-color: white;
    border: 1px solid #ccc;
    border-radius: 5px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    list-style: none;
    padding: 5px 0;
    margin: 2px 0 0 0;
    min-width: 120px;
}

/* 深色模式下的菜单样式 */
[data-bs-theme="dark"] .svg-download-menu {
    background-color: #33383d;
    border-color: #555;
}

.svg-download-menu a {
    display: block;
    color: #333;
    text-decoration: none;
    font-size: 14px;
}
.svg-download-menu a:hover {
    background-color: #f0f0f0;
}

/* 深色模式下的菜单项样式 */
[data-bs-theme="dark"] .svg-download-menu a {
    color: #eee;
}
[data-bs-theme="dark"] .svg-download-menu a:hover {
    background-color: #4a5157;
}
/* --- 暗黑模式下通过混合模式智能调暗内联背景色 --- */

/*
 * 目标：选择所有在暗黑模式下，位于消息内容中，
 * 并且 style 属性里包含 "background-color" 的元素。
 * 使用 [style*="..."] 属性选择器可以更精确地定位目标。
 */
[data-bs-theme="dark"] .message-content-wrapper *[style*="background-color"] {
  /* 
   * 步骤 1: 将元素设为相对定位，作为其伪元素的定位容器。
   * 这不会影响元素自身的布局。
   */
  position: relative;
  
  /* 
   * 步骤 2: 确保元素自身的内容（文字）显示在伪元素的上方。
   * z-index 只在定位元素上生效，所以上面的 position:relative 是必须的。
   * isolation: isolate 确保该元素的混合效果不会影响到外部其他元素。
   */
  isolation: isolate;
  z-index: 1; 
}

/*
 * 步骤 3: 创建伪元素，作为我们的“调暗图层”。
 */
[data-bs-theme="dark"] .message-content-wrapper *[style*="background-color"]::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  
  /* 
   * 步骤 4: 设置伪元素的背景和混合模式。
   * 我们给它一个半透明的黑色。透明度 (alpha) 越高，最终背景色越暗。
   * 0.8 是一个不错的起始值，可以根据喜好在 0.7 - 0.9 之间调整。
   *
   * mix-blend-mode: multiply; 是这里的魔法。
   * 它会将这层黑色与元素自身的浅色背景混合，从而得到一个深色版本。
   * 例如：浅灰色 +（正片叠底）黑色 = 深灰色。
   *        浅黄色 +（正片叠底）黑色 = 暗黄色。
   */
  background: rgba(0, 0, 0, 0.8);
  mix-blend-mode: multiply;
  
  /* 
   * 步骤 5: 将伪元素置于其父元素内容的下方。
   */
  z-index: -1;

  /* 
   * (可选) 如果元素有圆角，我们也希望调暗图层有圆角。
   * inherit 可以继承父元素的 border-radius。
   */
  border-radius: inherit;
}

/*
 * 豁免代码块：代码块有自己的暗黑主题，我们不希望这个效果干扰它们。
 * 我们通过将伪元素设为 display: none 来彻底禁用它。
 */
[data-bs-theme="dark"] .message-content-wrapper .code-block-wrapper *[style*="background-color"]::before,
[data-bs-theme="dark"] .message-content-wrapper pre[style*="background-color"]::before,
[data-bs-theme="dark"] .message-content-wrapper code[style*="background-color"]::before {
  display: none;
}

.output-mode-container .btn-check:checked + .btn-outline-secondary {
    background-color: var(--bs-primary); /* 使用Bootstrap的主题色 */
    border-color: var(--bs-primary);
    color: white;
}