/* 核心变量 */
:root {
    --bg-color: #f2e9d2; --text-color: #3e2e1e; --accent-color: #8b572a;
    --card-bg: rgba(255, 255, 255, 0.9); --border-color: rgba(62, 46, 30, 0.1);
}
body.theme-white { --bg-color: #f5f5f5; --text-color: #444; --accent-color: #555; --card-bg: #fff; --border-color: #ddd; }
body.theme-green { --bg-color: #d8e6d8; --text-color: #2c3e2c; --accent-color: #4a7c4a; --card-bg: rgba(255, 255, 255, 0.8); --border-color: rgba(0, 0, 0, 0.05); }
body.theme-night { --bg-color: #1e2327; --text-color: #a0aab5; --accent-color: #d4a76a; --card-bg: #2a3137; --border-color: #38424a; }

*{
    box-sizing: border-box;
}

body, html { margin: 0; padding: 0; height: 100%; width: 100%; overflow: hidden; background-color: var(--bg-color); color: var(--text-color); font-family: "PingFang SC", serif; transition: background 0.3s; }

#reader-viewport { width: 100%; height: 100%; position: relative; overflow: hidden; }

#content-layer {
    height: calc(100% - 60px);
    margin: 20px 0;
    padding: 0 20px;
    box-sizing: border-box;
    column-width: calc(100vw - 40px);
    column-gap: 40px;
    column-fill: auto;

    /*transition: transform 0.3s cubic-bezier(0.25, 0.1, 0.25, 1);*/
    transition: none;

    text-align: justify;
}
#content-layer h1 { font-size: 24px; margin: 0 0 20px 0; column-span: all; color: var(--accent-color); }
#content-layer p { margin: 0 0 1.2em 0; text-indent: 2em; line-height: 1.8; font-size: 19px; }

#touch-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; display: flex; z-index: 10; }
.touch-zone { position: absolute; height: 100%; top: 0; z-index: 10; }
.prev-zone { left: 0; width: 30%; }
.menu-zone { left: 30%; width: 40%; }
.next-zone { left: 70%; width: 30%; }

.ui-panel { position: fixed; background: var(--card-bg); backdrop-filter: blur(15px); transition: all 0.3s ease; z-index: 100; border: 1px solid var(--border-color); }

/* 激活状态 */
.ui-panel.active {
    transform: translateY(0);
}

/* 专门针对目录列表的滚动容器 */
.toc-list {
    height: 80vh; /* 给一个固定高度 */
    overflow-y: auto;
    position: relative;
    -webkit-overflow-scrolling: touch;
}

.toc-item.active {
    color: var(--accent-color, #d32f2f); /* 使用你的主题色 */
    background-color: rgba(0,0,0,0.05);  /* 淡淡的背景色 */
    font-weight: bold;
}

#top-nav { top: -60px;  width: 100%; height: 50px; display: flex; align-items: center; padding: 0 15px; box-sizing: border-box; border-radius: 0; }
#top-nav.active { top: 0; }
.back-btn { text-decoration: none; color: var(--accent-color); font-size: 14px; font-weight: bold; }

#settings-menu { bottom: -450px;  width: 100%; padding: 25px 20px 40px; box-sizing: border-box; border-radius: 24px 24px 0 0; }
#settings-menu.active { bottom: 0; }

.menu-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 22px; }
.row-label { font-size: 15px; opacity: 0.8; min-width: 70px; }

.theme-dots { display: flex; flex-direction: row; gap: 12px; }
.dot { width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--border-color); cursor: pointer; box-sizing: border-box; }

.btn-group { display: flex; gap: 8px; flex: 1; margin-left: 10px; justify-content: flex-end; }
.action-btn {
    padding: 10px 0; border-radius: 8px; border: 1px solid var(--border-color);
    background: rgba(255,255,255,0.5); color: var(--text-color);
    cursor: pointer; font-size: 13px; white-space: nowrap; flex: 1; text-align: center;
}
.action-btn.active { background: var(--accent-color); color: #fff; border-color: var(--accent-color); }
body.theme-night .action-btn { background: #252a2f; color: #a0aab5; }

/* 自动翻页滑块 */
.auto-config { display: flex; align-items: center; gap: 10px; flex: 1; margin-left: 10px; }
input[type=range] { flex: 1; accent-color: var(--accent-color); cursor: pointer; }

#toc-panel { top: 0; right: -100%; width: 85%; height: 100%; padding: 20px; box-sizing: border-box; overflow-y: auto; border-radius: 0; }
#toc-panel.active { right: 0; }
.toc-header { font-size: 18px; font-weight: bold; margin-bottom: 20px; color: var(--accent-color); display: flex; justify-content: space-between; }
.toc-item { padding: 15px 0; border-bottom: 1px solid var(--border-color); font-size: 15px; color: var(--text-color); cursor: pointer; display: block; text-decoration: none; }

#page-info { position: absolute; bottom: 10px; width: 100%; text-align: center; font-size: 11px; opacity: 0.4; z-index: 5; pointer-events: none; }

@media screen and (min-width: 800px) {
    #reader-viewport, #settings-menu, #top-nav { max-width: 800px; left: 50%; transform: translateX(-50%); }
    #content-layer { column-width: 760px; }
    #toc-panel { width: 350px; left: auto; transform: none; }
}

/* 固定标题样式 */
/* 固定标题样式 - 溢出处理 */
#fixed-book-title {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 40px;
    line-height: 40px;  /* 改为40px与高度一致 */
    text-align: center;
    font-size: 12px;
    opacity: 0.5;
    z-index: 5;
    pointer-events: none;
    letter-spacing: 1px;
    /* 新增溢出处理 */
    white-space: nowrap;      /* 强制单行显示 */
    overflow: hidden;         /* 隐藏溢出内容 */
    text-overflow: ellipsis;  /* 显示省略号 */
    padding: 0 20px;          /* 左右留白，避免贴边 */
    box-sizing: border-box;
}

/* 修改内容层边距，给顶部标题留出空间 */
#content-layer {
    height: calc(100% - 80px); /* 稍微调高底部，留出更多呼吸感 */
    margin: 40px 0 20px 0; /* 增加顶部 margin (40px) 避开固定标题 */
    /* 其他保持不变 */
    padding: 0 20px;
    box-sizing: border-box;
    column-width: calc(100vw - 40px);
    column-gap: 40px;
    column-fill: auto;
    transition: transform 0.3s cubic-bezier(0.25, 0.1, 0.25, 1);
    text-align: justify;
}






/* 针对没有章节时的长标题链接样式 */
.btn-group-vertical {
    display: flex;
    flex-direction: column; /* 强制上下排列 */
    gap: 12px;
    width: 100%;
}

.page-a {
    display: block; /* 块级化 */
    width: 100%;
    height: auto;   /* 高度自适应，允许长标题折行或单行 */
    min-height: 40px;
    line-height: 1.5; /* 调整行高，适合多行标题 */
    padding: 10px 15px; /* 增加内边距 */
    text-align: left;  /* 标题长，靠左对齐更好看 */
    background: var(--card-bg); /* 使用已有的变量 */
    color: var(--text-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    text-decoration: none;
    box-sizing: border-box;
    transition: opacity 0.2s;
}

.page-a:active {
    opacity: 0.7;
    background: var(--accent-color);
    color: #fff;
}

/* 高亮遮罩层 */
#read-highlight-sync {
    position: absolute;
    background-color: var(--accent-color); /* 使用你主题的强调色 */
    opacity: 0.15; /* 极低透明度，只是一层淡淡的背景 */
    pointer-events: none; /* 确保不影响点击翻页 */
    z-index: 1;
    border-radius: 4px;
    transition: all 0.2s ease; /* 让高亮切换时有个小动画 */

    mix-blend-mode: multiply; /* 推荐：这样可以让高亮颜色与文字背景融合，不遮挡文字 */
}

/* 如果你想让不同主题的高亮颜色不同，可以在你的主题样式里定义变量 */
.theme-night #read-highlight-sync { background-color: #ff9800; opacity: 0.1; }
.theme-green #read-highlight-sync { background-color: #2e7d32; opacity: 0.2; }

/* 章节导航支持多行 */
.chapter-nav {
    display: flex;
    gap: 10px;
    align-items: stretch;
}

/* 左右按钮：允许换行 */
.chapter-nav .action-btn {
    flex: 1;
    min-width: 0;

    white-space: normal;        /* ✅ 允许换行 */
    word-break: break-all;      /* ✅ 中文长句强制换行 */
    line-height: 1.4;

    padding: 8px 10px;
}

/* 中间目录按钮 */
.chapter-nav .action-btn:nth-child(2) {
    flex: 0 0 70px;
    white-space: nowrap;        /* 目录保持单行 */
}

.no-transition {
    transition: none !important;
}

/* 美化速度下拉框 */
#voice-speed {
    appearance: none;       /* 移除原生样式 */
    -webkit-appearance: none;

    flex: 1;
    padding: 8px 35px 8px 15px; /* 右侧留出空间放箭头 */
    font-size: 14px;
    color: var(--text-color);
    background-color: var(--card-bg);

    border: 1px solid var(--border-color);
    border-radius: 12px;     /* 与按钮一致的圆角 */

    cursor: pointer;
    outline: none;
    transition: all 0.2s ease;

    /* 自定义下拉箭头图标 (SVG) */

    background-repeat: no-repeat;
    background-position: calc(100% - 12px) center;

    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

#voice-speed:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px rgba(139, 87, 42, 0.1);
}