/* no IE11, no safari 9 or less, yes chrome 50+, yes firefox 50+, yes opera 40+, yes android 4.4+ */

* {
    box-sizing: border-box;
}

.app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
}

.app button {
    display: inline-block;
    font-size: inherit;
    color: inherit;
    cursor: pointer;
    background: transparent;
    border: none;
    border-radius: 5px;
    outline: 0;
    text-align: inherit;
    margin: 0;
    padding: 0;
    line-height: 1;
    font-weight: inherit;
    text-decoration: none;
    vertical-align: middle;
}

.app button::-moz-focus-inner {
    border: 0;
    padding: 0;
}

.app button:hover {
    background: rgba(0, 0, 0, 0.05);
}

.app button:active {
    background: rgba(0, 0, 0, 0.1);
}

.app .bar {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    height: 44px;
    line-height: 44px;
    padding: 0 10px;
}

.app .bar>div {
    flex: 0 0 auto;
}

.app .bar .title {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0px;
    flex: 1;
    text-align: center;
}

.app .book {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    justify-content: stretch;
    height: calc(100vh - 96px);
}

.app .book>div {
    flex: 1;
    height: 100%;
    width: 100%;
}

.app .book .empty-wrapper {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    justify-content: center;
}

.app .book .empty-wrapper .empty {
    display: block;
    flex: 0 0 auto;
    text-align: center;
    padding-top: 60px;
}

.app .book .empty-wrapper .empty .app-name {
    display: block;
    font-size: 40px;
    font-weight: 300;
    margin-bottom: 20px;
}

.app .book .empty-wrapper .empty .big-button,
.app .book .empty-wrapper .empty .big-button:link,
.app .book .empty-wrapper .empty .big-button:visited {
    display: inline-block;
    width: 150px;
    max-width: 100%;
    font-size: 20px;
    border-radius: 10px;
    padding: 10px;
    text-align: center;
    margin: auto;
    color: inherit;
    text-decoration: none;
    margin: 20px;
    background: rgba(0, 0, 0, 0.03);
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.app .book .empty-wrapper .empty .big-button:hover,
.app .book .empty-wrapper .empty .big-button:active {
    background: rgba(0, 0, 0, 0.1);
}

.app .book .empty-wrapper .empty .big-button:active {
    border: 1px solid rgba(0, 0, 0, 0.2);
}


.app .book .empty-wrapper .empty .message {
    display: block;
    max-width: 400px;
    margin: 0 auto;
}

.app .dictionary-wrapper {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    justify-content: center;
    position: fixed;
    bottom: 16px;
    left: 16px;
    right: 16px;
    height: 200px;
    max-height: 50%;
    min-height: 150px;
    z-index: 500;
}

.app .dictionary-wrapper .dictionary {
    flex: 0 0 auto;
}

.app .dictionary {
    background: #fff;
    color: #000;
    box-shadow: 0px 0px 4px 0px rgba(0, 0, 0, .15);
    border: 1px solid #ddd;
    border-radius: 4px;
    width: 100%;
    max-width: 450px;
    overflow-y: auto;
    overflow-x: hidden;
}

.app .dictionary .definition {
    display: block;
    padding: 8px;
    margin-bottom: 8px;
    border-bottom: 1px solid #ddd;
}

.app .dictionary .definition:last-child {
    border-bottom: none;
}

.app .dictionary .definition .word {
    font-weight: bold;
    font-size: 16px;
    margin-bottom: 4px;
}

.app .dictionary .definition .info {
    display: block;
    margin-bottom: 8px;
    font-style: italic;
}

.app .dictionary .definition .meanings {
    display: block;
}

.app .dictionary .definition .meaning {
    display: block;
    margin-bottom: 8px;
    text-indent: 10px;
}

.app .dictionary .definition .meaning:first-line {
    margin-left: -10px;
}

.app .dictionary .definition .meaning .text {
    display: block;
    margin-bottom: 2px;
}

.app .dictionary .definition .meaning .example {
    display: block;
    font-style: italic;
}

.app .dictionary .definition .note {
    display: block;
    font-style: italic;
}

.app .dictionary .definition .credit {
    display: block;
    margin-top: 4px;
    font-style: italic;
    font-size: 12px;
}

.app .sidebar {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 90%;
    max-width: 300px;
    background: #fff;
    color: #000;
    z-index: 1001;
    box-shadow: 0px 0px 8px 0px rgba(0, 0, 0, .2);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.app .sidebar-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.54);
    z-index: 1000;
    cursor: pointer;
    -webkit-tap-highlight-color: rgba(255, 255, 255, 0);
    will-change: background-color;
    transition: all 0.4s cubic-bezier(0.23, 1, 0.32, 1);
}

.app .sidebar-wrapper .sidebar {
    cursor: default;
}

.app .sidebar-wrapper,
.app .sidebar-wrapper .sidebar {
    will-change: transform, box-shadow;
    transition: all 0.4s cubic-bezier(0.23, 1, 0.32, 1);
}

.app .sidebar-wrapper.out {
    background: rgba(0, 0, 0, 0);
    pointer-events: none;
}

.app .sidebar-wrapper.out .sidebar {
    -webkit-transform: translateX(100%);
    transform: translateX(100%);
    box-shadow: none;
}

.app .sidebar .tab-list {
    display: flex;
    flex-direction: row;
    justify-content: flex-start;
    align-items: flex-end;
    border-bottom: 1px solid #ddd;
    background: #fff;
    box-shadow: 0px 0px 4px 0px rgba(0, 0, 0, .15);
    z-index: 1000;
}

.app .sidebar .tab-list .item,
.app .sidebar .tab-list .item:link,
.app .sidebar .tab-list .item:visited {
    flex: 1;
    display: block;
    color: inherit;
    text-align: center;
    text-decoration: none;
    outline: 0;
    line-height: 50px;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    -webkit-tap-highlight-color: rgba(255, 255, 255, 0);
    transition: background .1s cubic-bezier(0.23, 1, 0.32, 1), color .15s cubic-bezier(0.23, 1, 0.32, 1), border .15s cubic-bezier(0.23, 1, 0.32, 1);
}

.app .sidebar .tab-list .item:hover {
    background: rgba(0, 0, 0, 0.05);
}

.app .sidebar .tab-list .item:active {
    background: rgba(0, 0, 0, 0.1);
}

.app .sidebar .tab-list .item.active {
    color: #1565C0;
    border-bottom: 2px solid #1565C0;
}

.app .sidebar .tab-list .item .icon {
    display: inline-block;
    vertical-align: middle;
}

.app .sidebar .tab-container {
    display: block;
    overflow-x: hidden;
    overflow-y: auto;
    background: #f5f5f4;
}

.app .sidebar .toc-list {
    display: block;
}

.app .sidebar .toc-list .item,
.app .sidebar .toc-list .item:link,
.app .sidebar .toc-list .item:visited {
    display: block;
    text-decoration: none;
    color: inherit;
    outline: 0;
    line-height: 32px;
    padding: 0 8px;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

.app .sidebar .toc-list .item:hover {
    background: rgba(0, 0, 0, 0.05);
}

.app .sidebar .toc-list .item.active {
    color: #1565C0;
    background: rgba(0, 0, 0, 0.05);
}

.app .sidebar .search-bar {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    justify-content: flex-start;
    background: #fff;
    margin: 8px;
    border-radius: 4px;
    box-shadow: 0px 0px 8px 0px rgba(0, 0, 0, .15);
    border: 1px solid #ddd;
}

.app .sidebar .search-bar .search-box {
    flex: 1;
    padding: 0;
    margin: 0;
    color: inherit;
    background: transparent;
    border: 0;
    box-shadow: none;
    font-size: inherit;
    min-width: 50px;
    padding: 4px;
    border-top-left-radius: inherit;
    border-bottom-left-radius: inherit;
    outline: 0;
}

.app .sidebar .search-bar .search-button {
    flex: 0 0 auto;
    padding: 0;
    margin: 0;
    border: 0;
    box-shadow: none;
    font-size: inherit;
    padding: 4px;
    border-top-right-radius: inherit;
    border-bottom-right-radius: inherit;
    outline: 0;
    border-left: 1px solid #ddd;
    width: 32px;
    text-align: center;
    cursor: pointer;
    -webkit-tap-highlight-color: rgba(255, 255, 255, 0);
}

.app .sidebar .search-bar .search-button:hover {
    background: #eee;
}

.app .sidebar .search-bar .search-button .icon {
    vertical-align: middle;
}

.app .sidebar .search-results {
    display: block;
}

.app .sidebar .search-results .item,
.app .sidebar .search-results .item:link,
.app .sidebar .search-results .item:visited {
    display: block;
    text-decoration: none;
    color: inherit;
    outline: 0;
    line-height: 1.2;
    background: #fff;
    margin: 8px;
    border-radius: 4px;
    font-size: 12px;
    box-shadow: 0px 0px 8px 0px rgba(0, 0, 0, .15);
}

.app .sidebar .search-results .item:hover {
    background: rgba(0, 0, 0, 0.05);
}

.app .sidebar .search-results .item .text {
    display: block;
    padding: 4px;
}

.app .sidebar .search-results .item .pbar {
    background: #ddd;
}

.app .sidebar .search-results .item .pbar .pbar-inner {
    height: 1px;
    background: rgba(0, 0, 0, 0.5);
    box-shadow: 0 0 3px rgba(0, 0, 0, 0.3);
}

.app .sidebar .info {
    display: block;
}

.app .sidebar .info .cover-wrapper {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    margin: 24px auto;
    width: 80%;
    border-radius: 4px;
    box-shadow: 0px 0px 8px 0px rgba(0, 0, 0, .15);
}

.app .sidebar .info .cover-wrapper .cover {
    flex: 0 0 auto;
    display: block;
    width: 100%;
    border-radius: inherit;
}

.app .sidebar .info .title {
    display: block;
    text-align: center;
    font-size: 18px;
    margin-top: 8px;
    font-weight: bold;
}

.app .sidebar .info .series-info {
    display: block;
    text-align: center;
    font-size: 16px;
    margin-top: 4px;
}

.app .sidebar .info .author {
    display: block;
    text-align: center;
    font-size: 14px;
    margin-top: 4px;
}

.app .sidebar .info .description {
    display: block;
    text-align: justify;
    margin: 12px auto;
    padding-top: 12px;
    border-top: 1px solid #ccc;
    max-width: 80%;
    width: 100%;
    line-height: 1.6;
}

.app .sidebar .setting {
    display: block;
    padding: 8px 12px;
    border-bottom: 1px solid #ccc;
}

.app .sidebar .setting .setting-label {
    display: block;
    font-weight: 700;
    margin-bottom: 8px;
}

.app .sidebar .settings .setting-content {
    display: block;
}

.app .sidebar .settings .chips {
    display: block;
}

.app .sidebar .settings .chips .chip {
    display: inline-block;
    vertical-align: middle;
    border-radius: 32px;
    border: 1px solid rgba(0, 0, 0, 0.15);
    text-align: center;
    margin: 4px;
    padding: 4px 8px;
}

.app .sidebar .settings .chips .chip:hover,
.app .sidebar .settings .chips .chip.active {
    border: 1px solid rgba(0, 0, 0, 0.35);
    background: rgba(0, 0, 0, 0.05);
    box-shadow: 0 0 4px 0 rgba(0, 0, 0, 0.15);
}

.app .sidebar,
.app .sidebar-wrapper,
.app .top-bar,
.app .bottom-bar {
    -ms-user-select: none;
    -webkit-user-select: none;
    -webkit-user-drag: none;
    -moz-user-select: none;
    user-select: none;
}

.app .error {
    display: block;
    background: #fff;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2000;
    padding: 28px 32px;
}

.app .error .error-title {
    display: block;
    margin-bottom: 16px;
    color: red;
    font-weight: 300;
    font-size: 32px;
    line-height: 1;
}

.app .error .error-description,
.app .error .error-info {
    display: block;
    margin-bottom: 8px;
    font-weight: 300;
    font-size: 16px;
    line-height: 1.4;
}

.app .error .error-dump {
    display: block;
    background: rgba(0, 0, 0, 0.1);
    margin-top: 16px;
    padding: 8px;
    border-radius: 5px;
    font-family: monospace;
    word-wrap: break-word;
    word-break: break-all;
    font-size: 12px;
}

@media only screen and (max-width: 950px) {
    .app .bar {
        height: 36px;
        line-height: 36px;
        padding: 0 4px;
    }
}

@media only screen and (max-width: 450px) {
    .app .bar .title {
        display: none !important;
    }
}

.app .hidden {
    display: none !important;
}

.main-container {
    display: flex;
    width: 100%;
    height: 100%;
    position: relative;
}

.reader-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    width: 50%;
    /* 默认宽度50% */
    min-width: 300px;
    /* 最小宽度 */
}

.resize-handle {
    width: 8px;
    background-color: #f0f0f0;
    cursor: col-resize;
    transition: background-color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.resize-handle:hover {
    background-color: #ddd;
}

.resize-handle::after {
    content: "⋮";
    color: #999;
    font-size: 20px;
    line-height: 1;
}

.ai-summary-container {
    width: 50%;
    /* 默认宽度50% */
    min-width: 300px;
    /* 最小宽度 */
    background: #ffffff;
    /* 改为白色背景 */
    display: flex;
    flex-direction: column;
    padding: 15px;
    overflow: hidden;
    /* 防止内容溢出 */
}

.ai-summary-header {
    margin-bottom: 15px;
}

.ai-summary-button {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 8px 15px;
    background: #4CAF50;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.3s;
}

.ai-summary-button:hover {
    background: #45a049;
}

.ai-summary-button:disabled {
    background: #cccccc;
    cursor: not-allowed;
}

.ai-summary-button .icon {
    font-size: 20px;
}

.ai-summary-content {
    flex: 1;
    overflow-y: auto;
    padding-right: 10px;
    padding-bottom: 20px;
    height: calc(100vh - 120px);
    max-height: 100%;
    position: relative;
}

.summary-placeholder {
    color: #666;
    font-style: italic;
}

.privacy-note {
    color: #888;
    font-size: 12px;
    line-height: 1.4;
    margin-top: 8px;
    padding: 8px 12px;
    background-color: #f8f9fa;
    border-left: 3px solid #28a745;
    border-radius: 4px;
    font-style: normal;
}

.summary-text {
    line-height: 1.6;
    font-size: 14px;
    white-space: pre-wrap;
    /* 保留换行和空格 */
    word-wrap: break-word;
    /* 长单词换行 */
    padding: 10px;
    color: #000000;
    /* 改为黑色文字 */
}

.summary-text h4 {
    margin: 15px 0 10px 0;
    font-size: 16px;
    color: #2196F3;
    border-bottom: 1px solid #eee;
    padding-bottom: 5px;
}

.summary-text strong {
    color: #333;
    font-weight: 600;
}

.summary-text ul {
    margin: 10px 0;
    padding-left: 20px;
}

.summary-text li {
    margin: 5px 0;
}

.summary-text .loading {
    color: #666;
    font-style: italic;
}

.summary-text .error {
    color: #f44336;
    padding: 10px;
    background: #ffebee;
    border-radius: 4px;
    margin-top: 10px;
}

/* 自定义滚动条 */
.ai-summary-content::-webkit-scrollbar {
    width: 6px;
}

.ai-summary-content::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.ai-summary-content::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 3px;
}

.ai-summary-content::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* 在拖动时禁用文本选择 */
.resizing {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.summary-text.markdown-body {
    padding: 20px;
    font-size: 14px;
    line-height: 1.6;
    color: #24292e;
    /* GitHub 风格的深灰色文字 */
    background-color: #ffffff;
    /* 确保背景是白色 */
}

.summary-text.markdown-body h2 {
    color: #24292e;
    /* 标题也使用深灰色 */
    margin-top: 24px;
    margin-bottom: 16px;
    font-size: 1.5em;
    font-weight: 600;
    line-height: 1.25;
    padding-bottom: 0.3em;
    border-bottom: 1px solid #eaecef;
}

.summary-text.markdown-body h3 {
    color: #24292e;
    /* 三级标题也使用深灰色 */
    margin-top: 24px;
    margin-bottom: 16px;
    font-size: 1.25em;
    font-weight: 600;
    line-height: 1.25;
}

.summary-text.markdown-body strong {
    font-weight: 600;
    color: #24292e;
}

.summary-text.markdown-body ul {
    margin-top: 0;
    margin-bottom: 16px;
    padding-left: 2em;
}

.summary-text.markdown-body li {
    margin: 0.25em 0;
}

.summary-text.markdown-body li+li {
    margin-top: 0.25em;
}

.summary-text.markdown-body p {
    margin-top: 0;
    margin-bottom: 16px;
}

.summary-text.markdown-body code {
    padding: 0.2em 0.4em;
    margin: 0;
    font-size: 85%;
    background-color: rgba(27, 31, 35, 0.05);
    border-radius: 3px;
}

.summary-text.markdown-body pre {
    padding: 16px;
    overflow: auto;
    font-size: 85%;
    line-height: 1.45;
    background-color: #f6f8fa;
    border-radius: 3px;
}

.ai-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
}

.ai-provider-select {
    padding: 8px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background-color: white;
    font-size: 14px;
    color: #333;
    cursor: pointer;
    outline: none;
    transition: border-color 0.3s, box-shadow 0.3s;
}

.ai-provider-select:hover {
    border-color: #4CAF50;
}

.ai-provider-select:focus {
    border-color: #4CAF50;
    box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.2);
}

/* AI Configuration Styles */
.ai-config-content {
    padding: 0;
}

.api-key-input,
.api-base-url,
.model-name-input,
.max-tokens-input {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.3s, box-shadow 0.3s;
}

.api-key-input {
    padding-right: 40px;
    /* Make room for visibility toggle */
}

.api-key-input:focus,
.api-base-url:focus,
.model-name-input:focus,
.max-tokens-input:focus {
    border-color: #4CAF50;
    box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.2);
}

.setting-content {
    position: relative;
}

.toggle-visibility {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    padding: 4px;
    color: #666;
    border-radius: 3px;
}

.toggle-visibility:hover {
    background: rgba(0, 0, 0, 0.1);
    color: #333;
}

.advanced-setting {
    margin: 10px 0;
}

.advanced-setting label {
    display: block;
    margin-bottom: 5px;
    font-size: 13px;
    color: #555;
}

.temperature-slider {
    width: 100%;
    margin: 5px 0;
}

.temperature-value {
    font-weight: bold;
    color: #4CAF50;
}

.test-connection-btn,
.export-settings-btn,
.import-settings-btn,
.reset-settings-btn,
.save-ai-config-btn {
    padding: 8px 15px;
    background: #2196F3;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    margin: 2px 5px 2px 0;
    transition: background 0.3s;
}

.test-connection-btn:hover,
.export-settings-btn:hover,
.import-settings-btn:hover,
.save-ai-config-btn:hover {
    background: #1976D2;
}

.reset-settings-btn {
    background: #f44336;
}

.reset-settings-btn:hover {
    background: #d32f2f;
}

.connection-status {
    margin-left: 10px;
    font-size: 12px;
    font-weight: bold;
}

.connection-status.success {
    color: #4CAF50;
}

.connection-status.error {
    color: #f44336;
}

.connection-status.testing {
    color: #FF9800;
}

.current-provider-label {
    font-size: 14px;
    color: #666;
    margin-right: 15px;
    display: flex;
    align-items: center;
}

.current-provider-name {
    margin-left: 5px;
    color: #2196F3;
}

.ai-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}

/* Responsive adjustments */
@media only screen and (max-width: 768px) {
    .ai-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .current-provider-label {
        text-align: center;
        margin-bottom: 10px;
        justify-content: center;
    }
}

/* AI配置模态
框样式 */
.ai-config-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-config-modal.hidden {
    display: none;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
}

.modal-content {
    position: relative;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    border-bottom: 1px solid #eee;
    background: #f8f9fa;
}

.modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #333;
}

.modal-close-btn {
    padding: 5px;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close-btn:hover {
    background: rgba(0, 0, 0, 0.1);
}

.modal-body {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
}

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    padding: 20px;
    border-top: 1px solid #eee;
    background: #f8f9fa;
}

.cancel-btn {
    padding: 8px 15px;
    font-size: 13px;
    background: #6c757d;
    color: white;
    border-radius: 4px;
    transition: background 0.3s;
    border: none;
}

.cancel-btn:hover {
    background: #5a6268;
}

.ai-buttons-group {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.ai-config-button {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 8px 15px;
    background: #2196F3;
    color: white;
    border-radius: 4px;
    font-size: 14px;
    transition: background 0.3s;
}

.ai-config-button:hover {
    background: #1976D2;
}

.ai-config-button .icon {
    font-size: 18px;
}

/* 响应式设计 */
@media only screen and (max-width: 768px) {
    .modal-content {
        width: 95%;
        max-height: 90vh;
    }

    .modal-header,
    .modal-body,
    .modal-footer {
        padding: 15px;
    }

    .ai-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .ai-buttons-group {
        margin-left: 0;
        margin-bottom: 10px;
    }

    .ai-config-button {
        margin-bottom: 0;
    }
}

/* Mermaid图表样式 */
.summary-text .mermaid-svg {
    margin: 15px 0;
    text-align: center;
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch; /* 提升移动端滚动体验 */
}

.summary-text .mermaid-svg svg {
    max-width: none !important;  /* 取消最大宽度限制，允许自然宽度，超出时容器横向滚动 */
    width: auto !important;       /* 改为auto，让SVG使用自然宽度 */
    height: auto !important;      /* 保持宽高比 */
    display: block !important;
    margin: 0 auto !important;
    border-radius: 4px;
    overflow: visible;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    word-break: break-word;
    /* avoid clipping of edge labels and markers */
    overflow: visible;
}

/* 增强响应式：为 wrapper 添加容器限制 */
.mermaid-svg-wrapper {
    width: 100%;
    margin: 16px auto;
    overflow: auto;
    display: block;
    text-align: center;
}

/* 备用的 Mermaid 字体控制 - 主要控制在 JavaScript 配置中 */
.summary-text .mermaid-svg svg,
.summary-text .mermaid-svg-wrapper svg,
.summary-text .mermaid-container svg {
    font-family: 'Inter', 'Noto Sans SC', 'Microsoft YaHei', sans-serif !important;
}

/* Mermaid 文本标签优化 - 确保文本完全显示 */
.summary-text .mermaid-svg svg text,
.summary-text .mermaid-svg-wrapper svg text,
.summary-text .mermaid-container svg text {
    font-family: 'Inter', 'Noto Sans SC', 'Microsoft YaHei', sans-serif !important;
    fill: #334155 !important;
}

/* 流程图节点标签确保可见性 */
.summary-text .mermaid-svg svg .nodeLabel,
.summary-text .mermaid-svg-wrapper svg .nodeLabel,
.summary-text .mermaid-container svg .nodeLabel {
    color: #334155 !important;
    font-family: 'Inter', 'Noto Sans SC', 'Microsoft YaHei', sans-serif !important;
}

.mermaid-error {
    border: 2px solid #ef4444;
    border-radius: 12px;
    padding: 20px;
    margin: 20px 0;
    background: linear-gradient(135deg, #fef2f2 0%, #fde8e8 100%);
    color: #dc2626;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.1);
}

.mermaid-error h4 {
    margin: 0 0 12px 0;
    color: #dc2626;
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.mermaid-error h4::before {
    content: '⚠️';
    font-size: 18px;
}

.mermaid-error p {
    margin: 0 0 12px 0;
    font-size: 14px;
    line-height: 1.4;
}

.mermaid-error button {
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(185, 28, 28, 0.3);
}

.mermaid-error button:hover {
    background: linear-gradient(135deg, #b91c1c 0%, #991b1b 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(185, 28, 28, 0.4);
}

.mermaid-error button:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(185, 28, 28, 0.3);
}

.mermaid-error details {
    margin-top: 12px;
}

.mermaid-error summary {
    cursor: pointer;
    color: #7c2d12;
    font-weight: 500;
    padding: 4px 0;
    user-select: none;
    transition: color 0.2s ease;
}

.mermaid-error summary:hover {
    color: #dc2626;
}

.mermaid-error pre {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 16px;
    margin: 12px 0 0 0;
    overflow-x: auto;
    font-size: 12px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    color: #374151;
    line-height: 1.5;
}

/* Dark mode support for Mermaid diagrams */
[data-theme="dark"] .mermaid-svg-wrapper {
    background: linear-gradient(135deg, #1f2937 0%, #111827 100%);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .mermaid-error {
    background: linear-gradient(135deg, #7f1d1d 0%, #6b1d1d 100%);
    border-color: #dc2626;
    color: #fca5a5;
}

[data-theme="dark"] .mermaid-error pre {
    background: #374151;
    border-color: #4b5563;
    color: #d1d5db;
}

/* Responsive adjustments */
@media only screen and (max-width: 768px) {
    .summary-text .mermaid-svg {
        margin: 10px 0;
    }

    .mermaid-svg-wrapper {
        padding: 12px;
        margin: 12px 0;
    }

    .mermaid-error {
        padding: 16px;
        margin: 16px 0;
    }

    .mermaid-error pre {
        padding: 12px;
        font-size: 11px;
    }
}