:root {
    --primary: #4361ee;
    --primary-light: #4895ef;
    --secondary: #3f37c9;
    --dark: #1d3557;
    --light: #f8f9fa;
    --gray: #6c757d;
    --gray-light: #e9ecef;
    --success: #4cc9f0;
    --border-radius: 12px;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    --transition: all 0.3s ease;
    
    /* 浅色主题变量 */
    --bg-color: #f8f9fa;
    --card-bg: #ffffff;
    --text-color: #1d3557;
    --text-secondary: #6c757d;
    --border-color: #e9ecef;
    --header-bg: #ffffff;
    --content-bg: #ffffff;
    --content-text: #333333;
}

.dark-mode {
    /* 深色主题变量 */
    --bg-color: #121212;
    --card-bg: #1e1e1e;
    --text-color: #e9ecef;
    --text-secondary: #a0a0a0;
    --border-color: #2d2d2d;
    --header-bg: #1e1e1e;
    --content-bg: #1e1e1e;
    --content-text: #e9ecef;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    line-height: 1.6;
    color: var(--text-color);
    background: var(--bg-color);
    min-height: 100vh;
    padding: 0 20px;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
}

.container {
    max-width: 1000px;
    width: 80%;
    margin: 0 auto;
}

.eb-header {
    text-align: center;
    margin-bottom: 40px;
    padding: 40px 20px;
    background: var(--header-bg);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
    transition: var(--transition);
}

.eb-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(to right, var(--primary), var(--success));
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1000px;
    margin: 0 auto;
    padding: 0 20px;
}

.theme-toggle {
    width: 50px;
    height: 50px;
    border-radius: 50%;

    background: var(--card-bg);
    border: none;

    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-direction: column;

    transition: var(--transition);
    box-shadow: var(--shadow);
}

.theme-toggle:hover {
    transform: rotate(15deg);
}

.theme-toggle i {
    font-size: 1.3rem;
    color: var(--text-color);
    transition: var(--transition);
}

.reading-progress-container {
    width: 100%;
    height: 5px;
    background: var(--border-color);
    position: fixed;
    top: 0;
    left: 0;
    z-index: 101;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(to right, var(--primary), var(--success));
    width: 0%;
    transition: width 0.3s ease;
}

#bookHomeFloating {
    height: 100%;
    bottom: 80px;
    top: 150px;
    overflow: hidden;
}

#bookHomeIframe {
    width: 100%;
    height: 100%;
    border: none;
    display: flex;
}

.toc-floating {
    position: fixed;
    top: 208px;
    right: 30px;
    width: 280px;

    background: var(--card-bg);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    transition: var(--transition);
    max-height: 70vh;
    display: none;
    flex-direction: column;  /* 垂直方向排列 */
    z-index: 88;
}

.toc-floating.active {
    display: flex;
}

.toc-header {
    padding: 15px 20px;
    height: 60px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    flex-shrink: 0; /* 头部不收缩 */ 
    justify-content: space-between;
    align-items: center;
}

.toc-header h3 {
    color: var(--text-color);
    font-size: 1.1rem;
    transition: var(--transition);
}

.toc-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1.2rem;
    transition: var(--transition);
}

.toc-close:hover {
    color: var(--primary);
}

.toc-list {
    flex: 1; /* 内容区域占据剩余空间 */
    overflow-y: auto;
    list-style-type: none;
    padding: 10px 0;
}

.toc-item {
    padding: 8px 20px;
    transition: var(--transition);
}

.toc-item a {
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 0.9rem;
    display: block;
    transition: var(--transition);
}

.toc-item a:hover {
    color: var(--primary);
}

.toc-item.active a {
    color: var(--primary);
    font-weight: 600;
}

.toc-level-1 { margin-left: 0; }
.toc-level-2 { margin-left: 15px; font-size: 0.85em; }
.toc-level-3 { margin-left: 30px; font-size: 0.8em; }

.breadcrumb {
    display: flex;
    align-items: center;
    margin: 20px 0;
    padding: 15px 20px;
    background: var(--card-bg);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    transition: var(--transition);
}

.breadcrumb a {
    text-decoration: none;
    color: var(--text-secondary);
    transition: var(--transition);
    display: flex;
    align-items: center;
}

.breadcrumb a:hover {
    color: var(--primary);
}

.breadcrumb-separator {
    margin: 0 10px;
    color: var(--text-secondary);
}

.breadcrumb-current {
    color: var(--text-color);
    font-weight: 600;
}

.chapter-header {
    text-align: center;
    margin-bottom: 30px;
    padding: 20px;
    background: var(--card-bg);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    transition: var(--transition);
}

.chapter-title {
    font-size: 1.8rem;
    margin-bottom: 10px;
    color: var(--text-color);
    font-weight: 700;
    transition: var(--transition);
}

.book-title {
    font-size: 1.1rem;
    color: var(--text-secondary);
    transition: var(--transition);
}

.eb-content-container {
    background: var(--content-bg);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: var(--transition);
}

#eb-content {
    padding: 40px;
    color: var(--content-text);
    transition: var(--transition);
    text-indent: 0px;
    width: 100%;
}

/* #eb-content h2, #eb-content h3, #eb-content h4 {
    margin-top: 2rem;
    margin-bottom: 1rem;
    color: var(--text-color);
    transition: var(--transition);
}

#eb-content h2 {
    font-size: 1.5rem;
    border-bottom: 2px solid var(--primary);
    padding-bottom: 0.5rem;
}

#eb-content h3 {
    font-size: 1.3rem;
    border-left: 4px solid var(--primary);
    padding-left: 1rem;
}

#eb-content h4 {
    font-size: 1.1rem;
    border-left: 2px solid var(--primary);
    padding-left: 1rem;
}

#eb-content p {
    margin-bottom: 0.8rem;
    line-height: 1.7;
} */

/* #eb-content .img-wrapper{
    max-height: 70vh;
    display: inline;
} */

/* medium-zoom 样式 */
.medium-zoom-container {
    z-index: 9999;
}

.medium-zoom-overlay {
    background: #000;
    opacity: 0.9;
}

.medium-zoom-scaler {
    transform-origin: center center;
}

.medium-zoom-scaler img {
    max-width: 90vw;
    max-height: 90vh;
    object-fit: contain;
}

#eb-content .table-wrapper {
    width: 100%;
    overflow-x: auto;
}

#eb-content table {
    margin: 0 auto;
    border-color: var(--text-color);
}

#eb-content table tr, #eb-content table td, #eb-content table th {
    border-color: var(--text-color);
}

#eb-content table tr {
    margin: 0px;
    color: inherit;
    background-color: inherit;
}

#eb-content table th {
    background-color: inherit;
    font-weight: 600;
    color: inherit;
}

#eb-content table td {
    color: inherit;
}

#eb-content table tr:hover {
    background-color: var(--bg-color);
}

#eb-content pre code {
    padding: 10px 10px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    height: auto;
    width: 100%;
}

#eb-content pre {
    background: var(--border-color);
    border-radius: 8px;
    overflow-x: auto;
    margin: 0px;
    padding: 10px;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    display: flex;
    white-space: pre;
}

/* #eb-content blockquote {
    color: inherit;
    position: relative;
    overflow: hidden;
}

#eb-content ul, #eb-content ol {
    padding: 0;
}

#eb-content ul li, #eb-content ol li {
    border-radius: inherit;
    box-shadow: none;
    transition: all 0.3s ease;
}

#eb-content ul li:before {
    margin-right: 0.5rem;
}

#eb-content ol li:before {
    margin-right: 0.5rem;
} */

.navigation {
    display: flex;
    justify-content: space-between;
    margin: 30px 0;
    padding: 20px;
    background: var(--card-bg);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    transition: var(--transition);
}

.navigation a {
    text-decoration: none;
    line-height: 1;
}

.navigation .control-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 20px;
    background: var(--card-bg);
    color: var(--text-color);
    border-radius: 10px;
    text-decoration: none;
    font-weight: 600;
    transition: var(--transition);
    border: none;
    cursor: pointer;
    flex-direction: column;
}

.navigation .control-btn:hover {
    transform: translateY(-4px);
}

.eb-footer {
    text-align: center;
    padding: 10px 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
    background: var(--header-bg);
    transition: var(--transition);
}

.eb-footer p {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
    background: var(--header-bg);
    transition: var(--transition);
}

.top-controls {
    position: fixed;
    top: 30px;
    right: 30px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 22;
}

.reading-controls {
    position: fixed;
    bottom: 30px;
    right: 30px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 20;
}

.reading-controls a {
    text-decoration: none;
}

.reading-controls .control-btn,.top-controls .control-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow);
    border: none;
    flex-direction: column;
}

.reading-controls .control-btn:hover, .top-controls .control-btn:hover {
    background: var(--secondary);
    transform: scale(1.1);
}

.font-controls {
    position: fixed;
    bottom: 150px;
    right: 20px;
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 15px;
    box-shadow: var(--shadow);
    display: none;
    flex-direction: column;
    gap: 10px;
    width: 200px;
    z-index: 88;
}

.font-controls.show {
    display: flex;
}

.font-size-control {
    display: flex;
    align-items: center;
    justify-content: space-around;
}

.font-size-btn {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    background: var(--border-color);
    color: var(--text-color);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    border: none;
}

.font-size-btn.active {
    background: var(--primary);
    color: white;
}

/* 移动端底部控件 */
.mobile-controls {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--card-bg);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    display: none;
    justify-content: space-around;
    padding: 10px 0;
    z-index: 99;
}

.mobile-controls .control-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    border-radius: 8px;
}

.mobile-controls .control-btn:hover,
.mobile-controls .control-btn.active {
    color: var(--primary);
}

.mobile-controls .control-btn i {
    font-size: 1.2rem;
    margin-bottom: 4px;
}

.mobile-controls .control-btn span {
    font-size: 0.7rem;
}

.mobile-controls a {
    text-decoration: none;
}


.custom-css-panel {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    margin-bottom: 30px;
    margin-top: 20px;
    overflow: hidden;
    transition: var(--transition);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: var(--primary);
    color: white;
    cursor: pointer;
}

.panel-header h3 {
    margin: 0;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 10px;
    color: white;
}

.panel-toggle {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    transition: var(--transition);
    padding: 5px;
}

.panel-toggle:hover {
    transform: scale(1.1);
}

.panel-content {
    padding: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.panel-content.expanded {
    max-height: 500px;
    padding: 20px;
}

.css-editor {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

#customCssInput {
    width: 100%;
    height: 200px;
    padding: 15px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    resize: vertical;
    background: var(--bg-color);
    color: var(--text-color);
    transition: var(--transition);
}

#customCssInput:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(67, 97, 238, 0.2);
}

.css-controls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
}

.css-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 15px;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    border: none;
    font-size: 0.9rem;
    text-align: center;
    white-space: nowrap;
}

.css-btn.primary {
    background: var(--primary);
    color: white;
}

.css-btn.primary:hover {
    background: var(--secondary);
    transform: translateY(-2px);
}

.css-btn.secondary {
    background: var(--card-bg);
    color: var(--text-color);
    border: 1px solid var(--border-color);
}

.css-btn.secondary:hover {
    background: var(--border-color);
    transform: translateY(-2px);
}

/* 通知样式 */
.custom-css-notification {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);        
    padding: 12px 20px;
    border-radius: 6px;
    color: white;
    font-weight: 600;
    z-index: 10003;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
}

.custom-css-notification.success {
    background: #4CAF50;
}

.custom-css-notification.info {
    background: var(--primary);
}

.custom-css-notification.warning {
    background: #f8961e;
}

.custom-css-notification.fade-out {
    opacity: 0;
    transform: translateY(-10px);
}

.css-info {
    padding: 10px 15px;
    background: var(--border-color);
    border-radius: 6px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.css-info p {
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.css-info i {
    color: var(--primary);
}

.control-name {
    font-size: 0.5rem;
}

/* 翻页控制面板 */
.page-indicator {
    font-weight: 600;
    color: var(--text-color);
    min-width: 60px;
    text-align: center;
    display: flex;
    justify-items: center;
    line-height: 2rem;
    margin: 0 2px;
}

.page-nav {
    display: flex;
    gap: 10px;
}

.page-nav-btn {
    height: 40px;
    border-radius: 10%;
    padding: 5px 10px;
    background: var(--border-color);
    color: var(--text-color);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    flex-direction: column;
}

.page-nav-btn:hover {
    background: var(--primary);
    color: white;
    transform: scale(1.1);
}

.page-nav-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.page-nav-btn:disabled:hover {
    background: var(--border-color);
    color: var(--text-color);
}

/* 页面跳转输入框 */
.page-jump {
    display: flex;
    align-items: center;
    gap: 5px;
    margin: 0 5px;
}

#pageJumpInput, #pageHeightInput {
    width: 50px;
    height: 36px;
    text-align: center;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-color);
    color: var(--text-color);
    font-weight: 600;
}

#pageJumpInput:focus, #pageHeightInput:focus {
    outline: none;
    border-color: var(--primary);
}

/* 翻页模式样式 */
.pagination-mode .container {
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.pagination-mode .eb-content-container {
    box-shadow: unset !important;
    margin-bottom: 0;
    overflow: hidden;
    position: relative;
    /* 宽度由 JavaScript 统一设置 */
}

.pagination-mode .navigation {
    min-height: 50px;
    margin-top: 0;
    margin-left: 0;
    margin-right: 0;
    /* 宽度和 padding 由 JavaScript 统一设置 */
}

/* CSS Column 分页样式 - 使用 CSS Column 实现分页 */
.pagination-mode #eb-content {
    margin-top: 20px !important;
    height: 100%;
    padding: 0px !important;
    margin: 0;
    /* 列宽和容器宽度由 JavaScript 统一设置 */
    column-count: auto;
    column-gap: 0px;
    /* 允许水平滚动 */
    overflow-x: auto;
    overflow-y: hidden;
    /* 使用 snap 实现整页滚动 */
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    /* 隐藏滚动条 */
    scrollbar-width: none;
    -ms-overflow-style: none;
    /* 确保内容能够正确分割 */
    break-inside: auto;
    page-break-inside: auto;
    -webkit-column-break-inside: auto;
}

/* 隐藏滚动条 */
.pagination-mode #eb-content::-webkit-scrollbar {
    display: none;
}

.pagination-mode {
    -ms-overflow-style: none;
    scrollbar-width: none;
    padding: 0;
    background: var(--bg-color);
}

/* 确保内容能够正确分割到不同列中 */
.pagination-mode #eb-content > * {
    break-inside: auto;
    page-break-inside: auto;
    -webkit-column-break-inside: auto;
    orphans: 1;
    widows: 1;
}

/* 调整图片在分页模式下的显示 */
.pagination-mode #eb-content img {
    break-inside: auto;
    page-break-inside: auto;
    -webkit-column-break-inside: auto;
}

/* 调整表格在分页模式下的显示 */
.pagination-mode #eb-content table {
    break-inside: auto;
    page-break-inside: auto;
    -webkit-column-break-inside: auto;
    width: 100%;
}

.kindle-mode .eb-header, .kindle-mode .toc-container, 
.kindle-mode .eb-content-container, .kindle-mode .navigation,
.kindle-mode .theme-toggle, .kindle-mode .control-btn, .kindle-mode .pagination-controls {
    box-shadow: none;
    border-radius: inherit;
}

.kindle-mode .pagination-controls {
    border: 1px solid;
}

.kindle-mode .eb-footer {
    display: none;
}

.kindle-mode .breadcrumb,.kindle-mode .navigation {
    margin: 0;
}

.kindle-mode .pagination-page {
    transition: none;
}

.kindle-mode .toc-container {
    margin: 0;
}

.kindle-mode .theme-toggle {
    border: 1px solid;
}

.kindle-mode .eb-content-container {
    margin-bottom: 0;
}

/* 暗黑模式全局修复 */
.dark-mode #eb-content * {
    color: var(--content-text) !important;
}

/* 图片保持原样 */
.dark-mode #eb-content img {
    filter: none !important;
}

/* 链接颜色 */
.dark-mode #eb-content a {
    color: var(--primary) !important;
}

/* 代码块 */
.dark-mode #eb-content pre code {
    background: var(--bg-color) !important;
    color: var(--content-text) !important;
}

.dark-mode #eb-content pre {
    background: var(--border-color) !important;
}

/* 代码高亮主题覆盖 */
.dark-mode .hljs {
    background: var(--bg-color) !important;
    color: var(--content-text) !important;
}

.dark-mode .hljs-comment,
.dark-mode .hljs-quote {
    color: var(--text-secondary) !important;
}

.dark-mode .hljs-keyword,
.dark-mode .hljs-selector-tag,
.dark-mode .hljs-literal,
.dark-mode .hljs-section,
.dark-mode .hljs-link {
    color: var(--primary) !important;
}

.dark-mode .hljs-string,
.dark-mode .hljs-title,
.dark-mode .hljs-name,
.dark-mode .hljs-type,
.dark-mode .hljs-attribute,
.dark-mode .hljs-symbol,
.dark-mode .hljs-bullet,
.dark-mode .hljs-built_in,
.dark-mode .hljs-addition,
.dark-mode .hljs-variable,
.dark-mode .hljs-template-tag,
.dark-mode .hljs-template-variable {
    color: var(--content-text) !important;
}

.dark-mode .hljs-number,
.dark-mode .hljs-regexp,
.dark-mode .hljs-literal {
    color: var(--success) !important;
}

.dark-mode .hljs-deletion,
.dark-mode .hljs-meta {
    color: #ff6b6b !important;
}

/* 日间模式代码高亮覆盖 */
:not(.dark-mode) .hljs {
    background: var(--bg-color) !important;
    color: var(--content-text) !important;
}

:not(.dark-mode) .hljs-comment,
:not(.dark-mode) .hljs-quote {
    color: var(--text-secondary) !important;
}

:not(.dark-mode) .hljs-keyword,
:not(.dark-mode) .hljs-selector-tag,
:not(.dark-mode) .hljs-literal,
:not(.dark-mode) .hljs-section,
:not(.dark-mode) .hljs-link {
    color: var(--primary) !important;
}

:not(.dark-mode) .hljs-string,
:not(.dark-mode) .hljs-title,
:not(.dark-mode) .hljs-name,
:not(.dark-mode) .hljs-type,
:not(.dark-mode) .hljs-attribute,
:not(.dark-mode) .hljs-symbol,
:not(.dark-mode) .hljs-bullet,
:not(.dark-mode) .hljs-built_in,
:not(.dark-mode) .hljs-addition,
:not(.dark-mode) .hljs-variable,
:not(.dark-mode) .hljs-template-tag,
:not(.dark-mode) .hljs-template-variable {
    color: var(--content-text) !important;
}

:not(.dark-mode) .hljs-number,
:not(.dark-mode) .hljs-regexp,
:not(.dark-mode) .hljs-literal {
    color: var(--success) !important;
}

:not(.dark-mode) .hljs-deletion,
:not(.dark-mode) .hljs-meta {
    color: #ff6b6b !important;
}

/* 表格 */
.dark-mode #eb-content table tr:hover {
    background-color: var(--bg-color) !important;
}

/* 引用 */
/* .dark-mode #eb-content blockquote {
    border-left: 4px solid var(--primary) !important;
} */

/* 列表项 */
/* .dark-mode #eb-content ul li:before,
.dark-mode #eb-content ol li:before {
    color: var(--primary) !important;
} */

/* medium-zoom 覆盖层 */
.dark-mode .medium-zoom-overlay {
    background: rgba(0, 0, 0, 0.9) !important;
}
.font-family-selector select {
    width: 100%;
    padding: 10px 15px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-color);
    color: var(--text-color);
    font-size: 0.9rem;
    transition: var(--transition);
}

.font-family-selector select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(67, 97, 238, 0.2);
}

.custom-font-input {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.custom-font-input input {
    padding: 10px 15px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-color);
    color: var(--text-color);
    font-size: 0.9rem;
    transition: var(--transition);
}

.custom-font-input input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(67, 97, 238, 0.2);
}

.custom-font-input small {
    color: var(--text-secondary);
    font-size: 0.8rem;
    text-align: left;
}

/* 响应式设计 */
@media (max-width: 1079px) {
    .container {
        max-width: 100%;
        min-width: 70%;
    }
}

@media (max-width: 768px) {
    .desktop-only {
        display: none !important;
    }
    
    body:not(.pagination-mode) .container {
        width: 100%;
    }

    .chapter-title {
        font-size: 1.5rem;
    }
    
    .navigation {
        padding: 10px 5px;
        gap: 2px;
        flex-wrap: nowrap;
        justify-content: center;
        overflow-x: auto;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }
    
    .navigation::-webkit-scrollbar {
        display: none;
    }

    .pagination-mode .navigation{
        padding: 10px 5px;
        gap: 2px;
        flex-wrap: nowrap;
        justify-content: space-between;
    }

    .pagination-mode .navigation .prev-chapter, .pagination-mode .navigation .next-chapter{
        display: none;
    }

    .pagination-mode .navigation #paginationInfo{
        width: auto;
        justify-content: center;
        flex-wrap: nowrap;
        gap: 2px;
    }

    .navigation .control-btn {
        padding: 0 8px;
        font-size: 0.75rem;
        min-width: 0;
        flex-shrink: 0;
    }
    
    .navigation .control-btn i {
        font-size: 0.9rem;
    }
    
    .navigation .control-name {
        font-size: 0.65rem;
        white-space: nowrap;
    }
    
    .navigation .page-indicator {
        font-size: 0.85rem;
        padding: 0 5px;
        white-space: nowrap;
    }
    
    .navigation #pageJumpInput {
        width: 40px;
        font-size: 0.85rem;
        padding: 2px;
    }
    
    .nav-btn {
        justify-content: center;
    }

    .top-controls {
        top: 20px;
        right: 20px;
        display: none;
    }
    
    .reading-controls {
        bottom: 20px;
        right: 20px;
        display: none;
    }
    
    .toc-floating {
        width: 90%;
        right: 5%;
        left: 5%;
        top: 20px;
        bottom: 90px;
        max-height: 100vh;
    }

    #bookHomeFloating {
        right: 5%;
        left: 5%;
        top: 20px;
        bottom: 90px;
        width: auto;
        height: auto;
    }

    .mobile-controls {
        display: flex;
    }

    .font-controls {
        bottom: 80px;
    }

    .css-controls {
        grid-template-columns: 1fr 1fr;
    }
    
    .css-btn {
        justify-content: center;
    }

    .pagination-controls {
        bottom: 70px; /* 避免与移动端底部控件重叠 */
        max-width: 80%;
    }
    
    .pagination-info {
        justify-content: space-between;
    }

    .page-nav-btn {
        width: 65px;
    }

    .pagination-page {
        transition: none;
    }
}

@media (max-width: 480px) {
    .container {
        max-width: 100%;
        min-width: 80%;
    }

    .breadcrumb {
        flex-wrap: wrap;
    }
    
    .breadcrumb-separator {
        margin: 0 5px;
    }
    
    #eb-content {
        padding: 20px;
    }

    .css-controls {
        grid-template-columns: 1fr;
    }
}

/* 加载动画样式 */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 1);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 5px solid #f3f3f3;
    border-top: 5px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.dark-mode .loading-overlay {
    background-color: rgba(0, 0, 0, 1);
}

.dark-mode .loading-spinner {
    border: 5px solid #333;
    border-top: 5px solid var(--primary);
}

.kindle-mode .loading-spinner {
    width: auto;
    height: auto;
    border: none;
    border-radius: 0;
    animation: none;
    font-size: 18px;
    color: var(--text);
    font-family: var(--font-family);
}

.kindle-mode .loading-spinner::after {
    content: "Loading...";
}