body {
    background-color: #f8f9fc;
    font-family: 'Helvetica Neue', Arial, sans-serif;
    font-size: 0.85rem;
    min-height: 100vh;
    margin: 0;
    padding: 0;
    overflow: hidden;
    color: #495057;
}

html {
    height: 100%;
    overflow: hidden;
}

.container-fluid {
    height: 100vh;
    overflow: hidden;
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
}

.row {
    height: 100%;
    margin: 0;
    flex-grow: 1;
}

.sidebar {
    background-color: #fff;
    height: 100vh;
    border-right: 1px solid #e3e6f0;
    padding: 10px;
    overflow-y: auto;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.05);
}

.main-content {
    padding: 10px;
    height: 100vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    padding-bottom: 0;
}

h2 {
    font-size: 1.5rem;
    margin: 0.5rem 0;
    color: #3a3f51;
    font-weight: 600;
}

h5 {
    font-size: 1rem;
    margin: 0.3rem 0;
    color: #3a3f51;
    font-weight: 600;
}

.card {
    margin-bottom: 0.75rem;
    border: none;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    border-radius: 0.5rem;
}

.card-header {
    padding: 0.75rem 1rem;
    background-color: #f8f9fa;
    border-bottom: 1px solid #eaecf0;
    border-top-left-radius: 0.5rem !important;
    border-top-right-radius: 0.5rem !important;
}

.card-body {
    padding: 1rem;
    min-height: 50px;
}

.mb-3 {
    margin-bottom: 1rem !important;
}

.mb-4 {
    margin-bottom: 1.5rem !important;
}

.form-control, .form-select {
    padding: 0.375rem 0.75rem;
    font-size: 0.85rem;
    border-radius: 0.375rem;
    border: 1px solid #ced4da;
    transition: border-color 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}

.form-control:focus, .form-select:focus {
    border-color: #80bdff;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

.btn {
    padding: 0.375rem 0.75rem;
    font-size: 0.85rem;
    border-radius: 0.375rem;
    transition: all 0.2s ease-in-out;
}

/* 确保 btn-sm 尺寸一致（避免被上面的 .btn 重置覆盖） */
.btn-sm {
    padding: 0.25rem 0.5rem !important;
    font-size: 0.875rem !important;
    border-radius: 0.2rem !important;
    line-height: 1.2 !important;
    height: 32px !important;
    display: inline-flex;
    align-items: center;
}

.btn-primary {
    background-color: #4e73df;
    border-color: #4e73df;
}

.btn-primary:hover {
    background-color: #3a5cca;
    border-color: #3a5cca;
}

.btn-success {
    background-color: #1cc88a;
    border-color: #1cc88a;
}

.btn-success:hover {
    background-color: #17a673;
    border-color: #17a673;
}

.chat-container {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    min-height: 300px;
}

.chat-messages {
    flex-grow: 1;
    overflow-y: auto;
    border: 1px solid #e3e6f0;
    border-radius: 0.25rem;
    padding: 15px;
    background-color: #f8f9fa;
    transition: height 0.3s ease;
    margin-bottom: 0.5rem;
    height: auto;
}

/* 当设置面板折叠时扩大聊天区域 */
.settings-collapsed .chat-messages {
    height: calc(100vh - 180px);
}

#userMessage {
    min-height: 36px;
    height: 36px;
    max-height: 120px;
    resize: none;
    overflow-y: auto;
    border-radius: 0.375rem 0 0 0.375rem;
}

.input-group .btn {
    border-radius: 0 0.375rem 0.375rem 0;
}

.message {
    margin-bottom: 15px;
    padding: 12px 15px;
    border-radius: 1rem;
    max-width: 80%;
    word-wrap: break-word;
    position: relative;
    line-height: 1.5;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.message-actions {
    display: none;
    position: absolute;
    top: 8px;
    right: 12px;
}

.message:hover .message-actions {
    display: flex;
}

.message-action-btn {
    background: none;
    border: none;
    font-size: 0.8rem;
    color: #6c757d;
    margin-left: 5px;
    cursor: pointer;
    transition: color 0.2s;
}

.message-action-btn:hover {
    color: #495057;
}

.edit-btn, .delete-btn, .edit-message {
    background: none;
    border: none;
    font-size: 0.8rem;
    padding: 0;
    cursor: pointer;
    transition: color 0.2s;
}

/* 编辑和删除按钮的图标样式 */
.edit-btn i, .delete-btn i, .edit-message i {
    font-size: 0.9rem;
}

.user-message {
    background-color: #4e73df;
    color: white;
    margin-left: auto;
    border-bottom-right-radius: 0.25rem;
}

.user-message .message-action-btn {
    color: rgba(255, 255, 255, 0.8);
}

.user-message .message-action-btn:hover {
    color: white;
}

.assistant-message {
    background-color: #e9ecef;
    color: #212529;
    border-bottom-left-radius: 0.25rem;
}

.editing-message {
    border: 2px dashed #ffc107;
}

.message-edit-form {
    margin-top: 5px;
}

.message-edit-form textarea {
    width: 100%;
    min-height: 60px;
    margin-bottom: 5px;
    border-radius: 0.375rem;
    padding: 0.5rem;
}

.message-edit-actions {
    display: flex;
    justify-content: flex-end;
    gap: 5px;
}

/* 提示词列表样式 */
.prompt-name {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 10px 12px;
    cursor: pointer;
    background-color: #f8f9fa;
    border-radius: 0.375rem;
    transition: all 0.2s ease;
    margin-bottom: 5px;
    border-left: 3px solid transparent;
}

.prompt-name:hover {
    background-color: #e9ecef;
    border-left: 3px solid #4e73df;
    transform: translateX(2px);
}

.prompt-name:active {
    background-color: #dde1e6;
    transform: translateX(4px);
}

.prompt-name-text {
    font-weight: 600;
    cursor: pointer;
    flex-grow: 1;
}

.prompt-name-text:hover {
    color: #4e73df;
}

.prompt-name .small.text-muted {
    font-size: 0.8em;
    opacity: 0.8;
    display: block;
    margin-top: 4px;
}

.prompt-actions {
    display: flex;
    gap: 5px;
    align-self: flex-start;
}

/* 提示词列表按钮样式 */
.expand-versions-btn, .delete-prompt-btn, .favorite-btn {
    background: none;
    border: none;
    padding: 3px 8px;
    margin-left: 5px;
    cursor: pointer;
    color: #6c757d;
    transition: all 0.2s ease;
    border-radius: 0.25rem;
}

.expand-versions-btn:hover, .delete-prompt-btn:hover, .favorite-btn:hover {
    background-color: rgba(0, 0, 0, 0.05);
    color: #495057;
}

/* 收藏按钮样式 */
.favorite-btn {
    color: #6c757d;
    font-size: 1rem;
}

.favorite-btn:hover {
    color: #ffc107;
}

.favorite-btn.active {
    color: #ffc107;
    text-shadow: 0 0 3px rgba(255, 193, 7, 0.5);
}

/* 收藏项的样式 */
.prompt-item.favorite {
    background-color: rgba(255, 243, 205, 0.5);
    border-left: 3px solid #ffc107;
}

/* 版本列表容器样式 */
.prompt-versions {
    padding: 0.5rem;
    border-top: 1px solid #eaecf0;
    background-color: #f8f9fc;
    overflow: hidden;
    max-height: 0;
    transition: max-height 0.3s ease;
}

/* 展开的版本列表样式 */
.prompt-versions.show {
    max-height: 1000px; /* 设置足够大的高度以容纳所有版本 */
    overflow-y: auto;
}

.prompt-item {
    padding: 10px 12px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border-bottom: 1px solid #f0f0f0;
    transition: background-color 0.2s;
    border-radius: 0.25rem;
    margin-bottom: 5px;
}

.prompt-item span {
    flex: 1;
}

.prompt-item .small.text-muted {
    font-size: 0.8em;
    display: block;
    margin-top: 2px;
    color: #6c757d;
}

.prompt-item:hover {
    background-color: #f8f9fa;
}

.prompt-item.active {
    background-color: #e7f0ff;
    border-left: 3px solid #4e73df;
    font-weight: 600;
}

.delete-version-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #dc3545;
    font-size: 0.8rem;
    padding: 0 5px;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.delete-version-btn:hover {
    opacity: 1;
}

#saveConversation, #resetConversation, #retryLastTurn, #copyConversation {
    margin-top: 10px;
}

/* 打字动画指示器 */
.typing-indicator {
    display: flex;
    align-items: center;
    padding: 6px 0;
}

.typing-indicator span {
    display: inline-block;
    width: 8px;
    height: 8px;
    background-color: #bbb;
    border-radius: 50%;
    margin: 0 2px;
    animation: typing 1.4s infinite both;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

/* 首字耗时显示 */
.first-token-time {
    font-size: 0.8rem;
    color: #6c757d;
    margin-top: 5px;
    text-align: right;
    font-style: italic;
}

.first-token-time span {
    font-weight: bold;
}

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

/* 全屏编辑模式优化 - 铺满整个屏幕 */
.fullscreen-editor {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.95);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
}

/* 区块背景增强，避免误点 */
#dialogSettingsCard {
  background: #f9fbff;
}
#initialSettingsCard {
  background: #fff9f3;
}
#initialSettingsCard .card-header {
  position: sticky;
  top: 0; /* 贴在右侧主内容区域顶部 */
  z-index: 120; /* 高于面板内容 */
  box-shadow: 0 2px 6px rgba(0,0,0,0.06);
}
.compact-card .compact-header {
  cursor: pointer;
  user-select: none;
  transition: background-color 0.15s ease, color 0.15s ease;
}

/* 折叠条着色：对话设置 */
#dialogSettingsCard .compact-header {
  background: #e9f2ff; /* 关闭状态 */
  color: #0b5ed7;
  border-bottom: 1px solid #d6e4ff;
}
#dialogSettingsCard .compact-header.is-open {
  background: #d6e4ff; /* 打开状态 */
  color: #084298;
}

/* 折叠条着色：初始对话设置 */
#initialSettingsCard .compact-header {
  background: #fff1e6; /* 关闭状态 */
  color: #b04a00;
  border-bottom: 1px solid #ffdfcc;
}
#initialSettingsCard .compact-header.is-open {
  background: #ffdfcc; /* 打开状态 */
  color: #7a2f00;
}

/* 优化折叠动画：缩短过渡，减少重排 */
/* 取消折叠动画，提升性能 */
.collapse {
  transition: none !important;
}
.collapsing {
  height: auto !important;
  overflow: hidden !important;
  transition: none !important;
}

.fullscreen-content {
    width: 100%;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    height: 100vh;
    padding: 10px;
}

.fullscreen-textarea {
    width: 100%;
    height: calc(100% - 50px);
    background-color: #fff;
    padding: 1rem;
    border: none;
    border-radius: 0;
    resize: none;
    font-family: monospace;
    font-size: 1rem;
    line-height: 1.5;
    box-shadow: none;
    margin-bottom: 10px;
}

.fullscreen-actions {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    padding: 0 10px;
}

.fullscreen-actions button {
    padding: 0.5rem 1.5rem;
    font-size: 1rem;
}

.fullscreen-toggle {
    border: none;
    background: none;
    color: #6c757d;
}

.fullscreen-toggle:hover {
    color: #4e73df;
}

#promptVersionSelect:disabled {
    background-color: #f8f9fa;
    cursor: not-allowed;
}

/* 搜索框样式优化 */
.input-group {
    position: relative;
    display: flex;
    align-items: center;
    margin-top: auto;
}

#promptSearchInput {
    border-radius: 0.375rem;
    padding-left: 2.5rem;
    padding-right: 2.5rem; /* 为清除按钮留出空间 */
}

.input-group-text {
    background-color: transparent;
    border-right: none;
    position: absolute;
    z-index: 5;
    left: 0;
}

/* 清除搜索按钮样式 */
.clear-search-btn {
    position: absolute;
    right: 0;
    top: 0;
    height: 100%;
    border: none;
    background: transparent;
    color: #6c757d;
    font-size: 0.8rem;
    width: 35px;
    z-index: 5;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.clear-search-btn:hover {
    color: #495057;
    background-color: rgba(0, 0, 0, 0.03);
}

/* 响应式布局优化 */
@media (max-width: 768px) {
    .sidebar, .main-content {
        height: auto;
        max-height: 100vh;
    }
    
    .chat-messages {
        height: 50vh;
    }
    
    .settings-collapsed .chat-messages {
        height: 60vh;
    }
}

/* 提高用户交互反馈 */
.btn:active, .form-control:focus, .form-select:focus {
    transition: transform 0.1s;
    transform: scale(0.98);
}

/* 滚动条美化 */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* 确保折叠面板中的元素可以正常交互 */
.collapse, .collapsing {
    position: relative;
    z-index: 10;
}

/* 确保折叠面板内的表单控件正常显示和交互 */
#initialSettings.collapse.show, #dialogSettings.collapse.show {
    display: block !important;
    height: auto !important;
    overflow: visible !important;
    opacity: 1 !important;
}

/* 确保下拉菜单可见并可交互 */
#modelSelect, #temperatureInput {
    position: relative;
    z-index: 15;
    pointer-events: auto;
    opacity: 1;
}

/* 修复表单控件在折叠面板中的可用性 */
.collapse.show .form-select, 
.collapse.show .form-control {
    pointer-events: auto;
    user-select: auto;
    opacity: 1;
}

/* 避免bootstrap样式冲突 */
.card-body.collapse.show {
    display: block !important;
}

/* 确保温度输入框正确显示 */
#temperatureInput {
    padding-right: 0.5rem;
    text-align: left;
    width: 100%;
}

/* 修复可能影响下拉菜单的样式 */
.form-select {
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 16px 12px;
    padding-right: 2rem !important;
}

/* 确保初始对话设置面板中的下拉菜单和输入框可见并可交互 */
#initialSettings .card-body {
    overflow: visible !important;
    padding: 1.5rem !important;
    min-height: 280px !important;
    position: relative;
    border-bottom-left-radius: 0.5rem;
    border-bottom-right-radius: 0.5rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

/* 从新调整模型选择和温度控件的位置和样式 */
#initialSettings .row:last-child {
    position: relative;
    margin-top: 20px;
    padding-top: 10px;
    z-index: 20;
}

#modelSelect, #temperatureInput {
    position: relative;
    z-index: 20;
    background-color: #fff;
    width: 100% !important;
    box-sizing: border-box;
    display: block;
    margin-top: 0 !important;
    margin-bottom: 0 !important;
    height: 36px;
}

/* 调整标签样式，使其与控件位置匹配 */
#initialSettings .form-label {
    margin-bottom: 0.5rem;
    font-weight: 500;
    display: block;
}

/* 增加卡片间距，为被删除的元素腾出更多空间 */
.card.mb-3 {
    margin-bottom: 3rem !important;
}

/* 确保下拉菜单可见并可交互 */
#modelSelect option {
    background-color: #fff;
    z-index: 21;
}

/* 搜索匹配项高亮样式 */
.prompt-item.search-match {
    background-color: rgba(78, 115, 223, 0.1);
    border: 1px solid #4e73df;
    box-shadow: 0 0 5px rgba(78, 115, 223, 0.3);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 0 5px rgba(78, 115, 223, 0.3); }
    50% { box-shadow: 0 0 10px rgba(78, 115, 223, 0.5); }
    100% { box-shadow: 0 0 5px rgba(78, 115, 223, 0.3); }
}

/* 防止行列间隔过小 */
.row .col-md-6 {
    margin-bottom: 5px;
}

/* 对话容器样式优化 - 确保底部对齐到浏览器底部 */
.card.chat-container {
    margin-top: 10px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    height: calc(100vh - 120px); /* 进一步优化高度 */
    margin-bottom: 0 !important;
}

.card.chat-container .card-body {
    flex-grow: 1;
    overflow: hidden;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
}

.card.chat-container .card-header {
    padding: 0.5rem 0.75rem;
    min-height: auto;
}

/* 页脚操作按钮区域 */
.card.chat-container .mt-2 {
    margin-top: 0.5rem !important;
    padding-bottom: 0;
}

/* 搜索匹配项高亮样式 - 提示词名称 */
.prompt-name.search-match {
    background-color: rgba(78, 115, 223, 0.1);
    border: 1px solid #4e73df;
    box-shadow: 0 0 5px rgba(78, 115, 223, 0.3);
    animation: pulse 2s infinite;
}

/* 初始对话设置面板样式 */
#initialSettings {
    position: relative !important;
    z-index: 50 !important;
}

#initialSettings.collapse.show {
    display: block !important;
    height: auto !important;
    overflow: visible !important;
    opacity: 1 !important;
    margin-bottom: 20px;
}

#initialSettings .card-body {
    padding: 1.5rem !important;
    background-color: #fff;
    border-radius: 0 0 0.5rem 0.5rem;
    overflow: visible !important;
}

/* 初始对话设置内的标题 */
#initialSettings h6 {
    font-weight: 600;
    color: #4e73df;
    margin-bottom: 10px;
    padding-bottom: 5px;
    border-bottom: 1px solid #e3e6f0;
}

/* 确保模型选择和温度控件正常显示 */
#modelSelect, #temperatureInput {
    position: relative;
    z-index: 60;
    width: 100% !important;
    box-sizing: border-box;
    display: block;
    background-color: #fff !important;
    height: 36px;
}

/* 确保下拉菜单选项可见 */
#modelSelect option {
    background-color: #fff;
    padding: 5px;
}

/* 调整标签样式 */
#initialSettings .form-label {
    margin-bottom: 0.3rem;
    font-weight: 500;
    display: block;
}

/* 确保模型参数区域与首句设置区域分隔 */
#initialSettings .mt-3 {
    margin-top: 1rem !important;
    padding-top: 0.5rem;
}

/* 紧凑型卡片样式 */
.compact-card {
    margin-bottom: 0.5rem !important;
}

.compact-header {
    padding: 0.4rem 0.75rem !important;
    min-height: auto;
}

.compact-card .card-header {
    border-radius: 0.375rem !important;
}

/* 折叠面板折叠状态优化 */
.compact-card .card-header.compact-header h5 {
    font-size: 0.9rem;
    margin: 0;
}

/* 确保在折叠时紧凑显示，不占用额外空间 */
.compact-card .collapse:not(.show) {
    display: none !important;
    height: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    border: none !important;
}

/* 变量替换功能样式 */
.variable-replacement-pair {
    transition: all 0.3s ease;
    padding: 5px;
    border-radius: 4px;
}

.variable-replacement-pair:hover {
    background-color: rgba(0, 0, 0, 0.03);
}

.remove-variable-btn {
    padding: 0.2rem 0.5rem;
    font-size: 0.75rem;
}

#addVariablePairBtn {
    font-size: 0.8rem;
    padding: 0.25rem 0.5rem;
}