* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent !important;
}


:root {
    --base-font-size: 20px;
    --line-height: 2.2;
    --primary-color: #000;
    --primary-dark: #333;
    --highlight-bg: #eee;
    --highlight-border: #999;
    --progress-width: 0%;
}



html,
body {
    height: 100vh;
    overflow: hidden;
    scroll-behavior: auto !important;
}

body {
    font-family: "Hiragino Mincho ProN", "Yu Mincho", "MS Mincho", serif;
    background: #fff;
    color: #000;
    -webkit-font-smoothing: antialiased;
    font-size: var(--base-font-size);
    line-height: var(--line-height);
    display: flex;
    flex-direction: column;
}

/* Re-enable scroll ONLY when reader is active */
html.reader-active,
body.reader-active {
    overflow-y: auto !important;
    height: auto !important;
}

.novel-text.font-mincho {
    font-family: "Hiragino Mincho ProN", "Yu Mincho", "MS Mincho", serif;
}

.novel-text.font-gothic {
    font-family: "Hiragino Sans", "Yu Gothic", "Meiryo", sans-serif;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: #fff;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.loading-overlay.hidden {
    display: none;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #eee;
    border-top: 3px solid #000;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

    100% {
        transform: rotate(360deg);
    }
}


.loading-text {
    font-weight: bold;
    font-size: 16px;
}

/* ===== 书籍列表视图 ===== */
.book-list-view,
.store-view {
    flex: 1;
    display: flex;
    flex-direction: column;
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
    overflow: hidden;
    padding: 0;
}

.main-header-container {
    background: #fff;
    z-index: 100;
    max-width: 800px;
    margin: 0 auto;
    /* padding-top: 40px; */
    width: 100%;
    flex-shrink: 0;
}

body.reader-active .main-header-container {
    display: none;
}

.home-adaptive-grid {
    flex: 1;
    overflow: hidden !important;

    grid-template-rows: repeat(var(--grid-rows, 2), 1fr);
    gap: 20px;
    padding: 10px 0;
}


body.reader-active .main-header-container {
    display: none;
}

.book-list-header {
    /* padding-bottom: 10px; */
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.icon-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    /* padding: 8px; */
    display: flex;
    align-items: center;
    justify-content: center;
    color: #000;

}



.icon-btn svg {
    width: 24px;
    height: 24px;
}

.icon-btn.hidden {
    display: none;
}

.book-list-header h1 {
    font-size: calc(var(--base-font-size) * 1.5);
    font-weight: bold;
}

.library-footer {
    padding-bottom: 10px;
}

.library-footer p {
    font-size: 12px;
    color: #888;
    font-family: "Hiragino Sans", sans-serif;
}

.github-footer-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: #000;
    text-decoration: none;
    font-family: "Hiragino Sans", "Yu Gothic", sans-serif;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.4;
    margin-left: 20px;
}

.github-footer-link svg {
    width: 18px;
    height: 18px;
    flex: 0 0 18px;
    fill: currentColor;
}

.github-footer-link span {
    overflow-wrap: anywhere;
}

.header-actions button {
    /* padding: 10px 20px; */
    /* background: var(--primary-color); */
    color: #000000;
    /* border: 2px solid var(--primary-color); */
    font-weight: bold;
    cursor: pointer;
    font-size: 14px;
}

/* Library Sections */

.library-section-title {
    font-size: 20px;
    font-weight: bold;
    margin: 40px 0 20px 0;
    padding: 4px 12px;
    background: #000;
    color: #fff;
    display: inline-block;
    letter-spacing: 2px;
}

.book-grid,
.library-section-grid {
    display: grid;
    grid-template-columns: repeat(2, 380px);
    justify-content: center;
    gap: 24px;
}

@media (max-width: 600px) {

    .book-grid,
    .library-section-grid {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .home-adaptive-grid {
        grid-template-columns: 1fr;
    }
}

@media (min-width: 601px) and (max-width: 860px) {
    .home-adaptive-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.book-card {
    border: 1.5px solid var(--primary-color);
    padding: 16px 20px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    background: #fff;
    position: relative;
    height: 100%;
    min-height: 160px;
    line-height: 1;
}

.book-info {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.book-title-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.book-title {
    font-size: 19px;
    font-weight: 800;
}

.book-title-sep {
    color: #888;
    font-weight: bold;
    flex-shrink: 0;
}

.badge-e {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    font-size: 11px;
    color: #ff0000;
    border: 1px solid #ff0000;
    border-radius: 50%;
    font-weight: bold;
    margin-left: 5px;
    background: #fff;
    flex-shrink: 0;
}

.book-author {
    font-size: 12px;
    color: #444;
}

.book-desc {
    font-size: 13px;
    line-height: 1.5;
    color: #666;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    padding-top: 10px;
}

.book-progress-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 0 0 0;
}

.book-progress-label {
    font-size: 11px;
    color: #444;
    font-weight: 800;
    font-family: "Hiragino Sans", "Yu Gothic", sans-serif;
    flex-shrink: 0;
}

.book-progress-row .progress-bar-container {
    flex: 1;
    height: 4px;
    background: #eee;
}

.book-progress-row .book-progress {
    font-size: 11px;
    color: #000;
    font-weight: bold;
    font-family: "Hiragino Sans", "Yu Gothic", sans-serif;
    flex-shrink: 0;
}

.book-card-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.book-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    min-width: 0;
    flex-shrink: 1;
}

.book-tag {
    display: inline-block;
    border: 1px solid #000;
    padding: 5px;
    font-family: "Hiragino Sans", "Yu Gothic", sans-serif;
    font-size: 11px;
    font-weight: 700;
    line-height: 1.4;
    white-space: nowrap;
}

.book-card-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    white-space: nowrap;
}

.book-meta {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    margin-top: 12px;
    gap: 20px;
}

.download-btn {
    background: #000;
    color: #fff;
    border: 2.5px solid #000;
    padding: 6px 16px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    font-family: inherit;
}

.download-btn:active {
    transform: translate(2px, 2px);
}

.delete-btn {
    background: #fff;
    color: #000;
    border: 2px solid #000;
    padding: 4px 10px;
    font-size: 13px;
    font-weight: bold;
    cursor: pointer;
    font-family: inherit;
}

.delete-btn:active {
    background: #000;
    color: #fff;
}

.download-btn.downloaded {
    background: #fff;
    color: #000;
    border: 2.5px solid #000;
}

.download-btn.downloaded::before {
    content: "\2713  ";
}

/* 优化后的注释和外字旁注样式 */
.annotation-wrapper,
.gaiji-badge {
    display: inline-flex;
    align-items: center;
    font-size: 0.65em;
    color: #ff820d;
    /* 用户喜欢的橙色 */
    /* background: #fff; */
    /* border: 1px solid #ff820d; */
    /* padding: 0 6px; */
    /* border-radius: 10px; */
    /* margin: 0 4px; */
    /* vertical-align: middle; */
    position: relative;
    /* 修复：不再使用 absolute，避免遮挡假名 */
    top: 0;
}


.annotation-content {
    font-weight: normal;
}

.gaiji-badge::before {
    content: "※";
    margin-right: 3px;
    color: #000;
}

.file-id {
    font-family: monospace;
    font-size: 11px;
    color: #999;
    background: #f5f5f5;
    padding: 2px 6px;
    border: 1px solid #ddd;
}

.delete-btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    color: #999;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.delete-btn-icon:active {
    color: #000;
}

.progress-bar-fill {
    height: 100%;
    background: var(--primary-color);
    width: var(--progress-width, 0%);
}

/* ===== 阅读器视图 ===== */
.reader-view {
    display: none;
    max-width: 800px;
    margin: 0 auto;
    padding: 20px 0 100px;
}

.reader-view.active {
    display: block;
}

.book-list-view.hidden {
    display: none;
}

/* 阅读器头部 */
.reader-header {
    margin-bottom: 24px;
    padding-bottom: 14px;
    padding-top: 50px;
}

.reader-header h1 {
    /* font-size: 24px; */
    font-weight: bold;
    margin-bottom: 4px;
    cursor: pointer;
    display: inline-block;
}

.reader-header h1:active {
    opacity: 0.6;
}

.reader-header .author {
    font-size: 14px;
    color: #666;
}

.book-frontmatter {
    /* margin-bottom: 36px; */
    padding-bottom: 24px;
}

.frontmatter-desc {
    margin: 0 0 18px;
    font-size: calc(var(--base-font-size) * 0.9);
    line-height: 1.8;
    color: #222;
}

.frontmatter-section {
    font-family: "Hiragino Sans", "Yu Gothic", sans-serif;
    /* line-height: 1.5; */
}

.frontmatter-section h2 {
    display: inline-block;
    margin: 0 0 12px;
    padding: 3px 10px;
    background: #000;
    color: #fff;
    font-size: 13px;
    font-weight: 800;
}

.frontmatter-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 10px;
}

.frontmatter-row {
    border-top: 1px solid #ddd;
    padding-top: 7px;
}

.frontmatter-label {
    margin-bottom: 2px;
    color: #666;
    font-size: 12px;
    font-weight: 800;
}

.frontmatter-value {
    color: #000;
    font-size: 13px;
    word-break: break-word;
}

.frontmatter-link {
    display: inline-block;
    margin-top: 16px;
    color: #000;
    font-size: 13px;
    font-weight: 800;
}

.frontmatter-start {
    margin-top: 24px;
    font-family: "Hiragino Sans", "Yu Gothic", sans-serif;
    font-size: 12px;
    font-weight: 800;
    color: #555;
    letter-spacing: 0;
}

/* 章节标题 */
.chapter-title {
    font-size: 22px;
    font-weight: bold;
    margin: 40px 0 20px;
    border-left: 8px solid #000;
    padding-left: 15px;
}

/* 小说正文 */
.novel-text {
    padding: 0;
}

.novel-text p {
    font-size: var(--base-font-size);
    line-height: var(--line-height);
    margin-bottom: 1em;
    text-indent: 0;
    position: relative;
    /* Standard Japanese indentation is 1 character */
}

/* Ruby (振假名) */
ruby {
    ruby-position: over;
    -webkit-ruby-position: over;
    /* 显式针对 WebKit 内核 */
    ruby-align: center;
    white-space: nowrap;
    /* 防止假名折行 */
}

rp {
    display: none;
    /* 彻底隐藏 Ruby 的回退括号 */
}

rt {
    font-size: 0.55em;
    line-height: 1.1;
    color: #000;
    user-select: none;
    font-weight: bold;
    /* 默认隐藏假名，但保持其为 ruby-text 布局以防止安卓渲染到右边 */
    opacity: 0;
    font-size: 0.01px;
}

.novel-text.font-mincho rt {
    font-family: "Hiragino Sans", "Yu Gothic", "Meiryo", sans-serif;
}

.novel-text.font-gothic rt {
    font-family: "Hiragino Mincho ProN", "Yu Mincho", "MS Mincho", serif;
}

body.show-furigana rt {
    opacity: 1;
    font-size: 0.55em;
}

/* 外字注释 */
.gaiji {
    cursor: help;
    text-decoration: underline dotted;
    text-underline-offset: 3px;
    font-size: 0.85em;
    color: #666;
}

/* 傍点（强调标记） */
.bōten {
    font-style: normal;
    text-emphasis: dot;
    -webkit-text-emphasis: dot;
    text-emphasis-position: over;
    -webkit-text-emphasis-position: over;
}

/* 通用注释标记 */
.annotation {
    cursor: help;
    font-size: 0.75em;
    color: #999;
    vertical-align: super;
}

/* 翻译图标 */
.trans-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    font-size: 12px;
    color: #ff0000;
    cursor: pointer;
    border: 1.5px solid #ff0000;
    border-radius: 50%;
    vertical-align: middle;
    font-weight: bold;
    background: #fff;
    flex-shrink: 0;
    position: relative;
    top: -10px;
    margin-left: 6px;
    /* 防止图标单独换行：通过负边距使其不占用排版宽度，从而永远紧跟在前一个字符后面 */
    margin-right: -25px;
    left: -5px;
}

.trans-icon.disabled {
    color: #ccc;
    border-color: #eee;
    cursor: default;
    background: transparent;
}

.trans-icon:not(.disabled):active {
    background: #000;
    color: #fff;
}

/* 翻译行 */
.translation-line {
    font-size: 0.88em;
    color: #333;
    line-height: 1.7;
    /* margin: 16px 0 24px 1.5em; */
    padding: 0 20px;
    border-left: 3px solid #000;
    margin-bottom: 1em;
    ;
    /* background: #fafafa; */
    font-family: "Hiragino Sans", "Yu Gothic", "Microsoft YaHei", sans-serif;
}

.translation-line.hidden {
    display: none;
}

.trans-item {
    margin-bottom: 16px;
}

.trans-item:last-child {
    margin-bottom: 0;
}

.trans-meta {
    margin-bottom: 4px;
    display: flex;
    align-items: center;
}

.trans-model {
    font-size: 0.65em;
    color: #fff;
    background: #000;
    padding: 1px 6px;
    font-family: "Hiragino Sans", sans-serif;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.trans-text {
    display: block;
    word-break: break-all;
}

.novel-text.font-mincho .trans-text,
.novel-text.font-mincho .trans-grammar-text {
    font-family: "Hiragino Sans", "Yu Gothic", "Meiryo", sans-serif;
}

.novel-text.font-gothic .trans-text,
.novel-text.font-gothic .trans-grammar-text {
    font-family: "Hiragino Mincho ProN", "Yu Mincho", "MS Mincho", serif;
}

.trans-grammar {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px dashed #ddd;
}

.trans-grammar-label {
    font-size: 0.7em;
    color: #999;
    font-family: "Hiragino Sans", sans-serif;
    font-weight: bold;
    display: block;
    margin-bottom: 4px;
}

.trans-grammar-text {
    font-size: 0.8em;
    color: #555;
    line-height: 1.7;
}

/* 可点击的单词 */
.word-token {
    cursor: pointer;
    border-bottom: 1px dashed transparent;
}

.word-token.has-furigana {
    /* Reserved for future specific styling of words with furigana */
    border-bottom-style: solid;
}

/* ===== 设置面板 ===== */
.settings-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    width: 440px;
    max-width: 90vw;
    max-height: 90vh;
    background: #fff;
    border: 3px solid #000;
    z-index: 2000;
    padding: 20px;
    overflow-y: auto;
    /* Isolate settings from global typography changes */
    line-height: 1.4 !important;
    font-size: 16px !important;
    opacity: 0;
    visibility: hidden;

}

/* Modal Overlay (Generic) */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 3000;
    display: none;
    align-items: center;
    justify-content: center;
}

.modal-overlay.active {
    display: flex;
}

.modal-card {
    background: #fff;
    border: 3px solid #000;
    padding: 30px;
    width: 320px;
    max-width: 85vw;
    box-shadow: 15px 15px 0px rgba(0, 0, 0, 0.05);
}

.modal-card h2 {
    margin-bottom: 15px;
    font-size: 18px;
    /* border-bottom: 2px solid #000; */
    padding-bottom: 8px;
    text-align: center;
}

.modal-card p {
    font-size: 14px;
    margin-bottom: 24px;
    line-height: 1.6;
    text-align: center;
}

.modal-footer {
    display: flex;
    gap: 12px;
}

.modal-btn {
    flex: 1;
    padding: 10px;
    border: 2px solid #000;
    background: #fff;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
}

.modal-btn.primary {
    background: #000;
    color: #fff;
}

/* Download Progress specific */
.download-progress-container {
    width: 100%;
    height: 12px;
    background: #eee;
    border: 1.5px solid #000;
    margin: 20px 0;
    overflow: hidden;
    position: relative;
}

.download-progress-fill {
    height: 100%;
    background: #000;
    width: 0%;
}

.download-status-text {
    font-size: 13px;
    font-weight: bold;
    margin-bottom: 10px;
    display: block;
}

.settings-panel.open {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
    display: block !important;
}

/* Overlay for modal */
.settings-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 1999;
    display: none;
}

.settings-overlay.active {
    display: block;
}

.settings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    /* border-bottom: 3px solid #000; */
    /* padding-bottom: 10px; */
}

.settings-header h2 {
    font-size: 30px;
    font-weight: bold;
    margin-bottom: 0;
    border-bottom: none;
    padding-bottom: 0;
}

.settings-header .menu-btn {
    background: none;
    border: none;
    padding: 5px;
    cursor: pointer;
    color: #666;
    display: flex;
    align-items: center;
    justify-content: center;
}

.settings-header .close-btn {
    background: none;
    border: none;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
    padding: 0 5px;
}

.settings-group {
    padding: 15px 0;
    margin-bottom: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid #eee;
}

.settings-group:last-of-type {
    border-bottom: none;
}

.status-settings-btn {
    width: 32px;
    height: 32px;
    padding: 0;
    border: 0;
    background: transparent;
    color: #000;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    line-height: 1;
}

.status-settings-btn:active {
    opacity: 1;
    transform: rotate(30deg);
}

.settings-group label {
    font-size: 16px;
    font-weight: bold;
    color: #000;
    /* flex: 1; */
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.settings-group .control-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 0 0 auto;
    justify-content: flex-end;
}

.step-btn {
    width: 28px;
    height: 28px;
    border: 2px solid #000;
    background: #fff;
    font-size: 20px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    flex-shrink: 0;
}

.settings-group input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100px;
    /* Narrower slider */
    height: 4px;
    background: #000;
    outline: none;
}

.settings-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    background: #fff;
    border: 2px solid #000;
    cursor: pointer;
    border-radius: 0;
}

.settings-group .value-display {
    font-size: 14px;
    font-weight: bold;
    min-width: 40px;
    text-align: right;
    font-family: "Hiragino Sans", sans-serif;
    display: none;
}

/* 字体切换按钮 */
.font-btn-group {
    display: flex;
    gap: 8px;
}

.font-btn {
    padding: 3px 13px;
    border: 2.5px solid #000;
    background: #fff;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    box-shadow: 4px 4px 0px rgba(0, 0, 0, 0.1);
}

.font-btn.active {
    background: #000;
    color: #fff;
    box-shadow: none;
    transform: translate(2px, 2px);
}

.settings-select {
    padding: 6px 32px 6px 12px;
    border: 2.5px solid #000;
    background: #fff;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    text-align: left;
    min-width: 140px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3' stroke-linecap='square' stroke-linejoin='miter'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
}

.settings-select:focus {
    background: #eee;
}

/* 开关 */
.switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 25px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider-round {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background-color: #fff;
    border: 2.5px solid #000;
    width: 48px;
}

.slider-round:before {
    position: absolute;
    content: "";
    height: 13px;
    width: 13px;
    left: 3px;
    bottom: 3.5px;
    background-color: #000;
}

input:checked+.slider-round {
    background-color: #000;
}

input:checked+.slider-round:before {
    background-color: #fff;
    transform: translateX(24px);
}

/* 设置遮罩 */
.settings-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 1999;
}

.settings-overlay.hidden {
    display: none;
}

/* ===== Custom Scrollbar ===== */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #fff;
}

::-webkit-scrollbar-thumb {
    background: #000;
    border: 2px solid #fff;
}

/* ===== 响应式 ===== */
@media (max-width: 900px) {

    .book-list-view,
    .reader-view,
    .store-view,
    .main-header-container,
    .reader-status-bar {
        padding-left: 20px !important;
        padding-right: 20px !important;
    }

    .reader-back-btn {
        left: 20px;
    }

    .filter-label {
        width: 100%;
    }
}

/* ===== Store View ===== */
.store-view {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px 0;
}

.store-search {
    margin-bottom: 16px;
}

.store-search input {
    width: 100%;
    box-sizing: border-box;
    padding: 12px 16px;
    border: 2px solid #000;
    font-size: 16px;
    font-family: inherit;
    outline: none;
}

.store-search input:focus {
    background: #f8f8f8;
}

.store-filter-panel {
    margin-bottom: 24px;
    /* border-top: 2px solid #000;
    border-bottom: 2px solid #000; */
    padding: 14px 0;
}



.home-filter-main {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.home-pagination-header {
    display: flex;
    align-items: center;
    gap: 12px;
}

#home-page-info {
    font-family: "Hiragino Sans", "Yu Gothic", sans-serif;
    font-size: 13px;
    font-weight: 800;
    color: #000;
    min-width: 40px;
    text-align: center;
}

.header-pagination-btns {
    display: flex;
    gap: 4px;
}

.icon-btn-small {
    background: none;
    border: none;
    color: #000;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    /* border-radius: 4px; */

}

.icon-btn-small:disabled {
    opacity: 0.2;
    cursor: default;
}

.icon-btn-small:active:not(:disabled) {
    background: #000;
    color: #fff;
}

.filter-select {
    font-size: 13px !important;
    padding: 4px 28px 4px 10px !important;
    min-width: 120px !important;
    flex-shrink: 0;
}

.filter-group {
    display: flex;
    align-items: flex-start;
    margin-bottom: 18px;
    gap: 12px;
}

.filter-group:last-of-type {
    margin-bottom: 0;
}

.filter-group {
    display: flex;
    align-items: flex-start;
    margin-bottom: 18px;
    gap: 12px;
}

.filter-label {
    width: 60px;
    flex-shrink: 0;
    font-family: "Hiragino Sans", "Yu Gothic", sans-serif;
    font-size: 13px;
    font-weight: 800;
    color: #444;
    padding-top: 6px;
    /* letter-spacing: 1px; */
}

.filter-chips-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    flex: 1;
}

.filter-chip {
    display: flex;
    align-items: center;
    gap: 6px;
    border: 1.5px solid #000;
    background: #fff;
    color: #000;
    padding: 5px 12px;
    font-family: "Hiragino Sans", "Yu Gothic", sans-serif;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;

    line-height: 1.2;
}

.chip-label {
    white-space: nowrap;
}

.chip-count {
    font-size: 10px;
    font-weight: 700;
    background: #eee;
    color: #666;
    padding: 1px 5px;
    min-width: 14px;
    text-align: center;
    border-radius: 2px;
}

.filter-chip.active {
    background: #000;
    color: #fff;
    border-color: #000;
}

.filter-chip.active .chip-count {
    background: #333;
    color: #aaa;
}

.filter-chip:active {
    transform: scale(0.96);
}

.filter-summary {
    margin-top: 10px;
    font-family: "Hiragino Sans", "Yu Gothic", sans-serif;
    font-size: 12px;
    font-weight: 700;
    color: #555;
}

.book-card.downloading {
    opacity: 0.7;
    pointer-events: none;
    position: relative;
}

.book-card.downloading::after {
    content: "読み込み中...";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #000;
    color: #fff;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: bold;
}

.book-card.downloaded .book-title::after {
    content: " (取得済み)";
    font-size: 12px;
    color: #666;
    font-weight: normal;
}

.header-actions {
    display: flex;
    gap: 10px;
}


.hidden {
    display: none !important;
}

/* Pagination */
.pagination-bar {
    display: flex;
    justify-content: center;
    gap: 20px;
    /* margin-top: 32px; */
    /* padding-top: 24px; */
}

.page-btn {
    background: #fff;
    color: #000;
    border: 1px solid #000;
    padding: 6px 20px;
    font-size: 14px;
    font-family: "Hiragino Mincho ProN", "Yu Mincho", serif;
    font-weight: 800;
    cursor: pointer;
}

.page-btn:active {
    background: #000;
    color: #fff;
}

.page-btn:disabled {
    border-color: #ddd;
    color: #bbb;
    background: #fff;
    cursor: not-allowed;
}

/* Reader Status Bar */
.reader-back-btn {
    position: fixed;
    top: 18px;
    left: max(18px, calc((100vw - 800px) / 2));
    width: 46px;
    height: 46px;
    border: 3px solid #000;
    border-radius: 50%;
    background: #fff;
    color: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 101;
    opacity: 0;
    pointer-events: none;
    box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.08);
}

.reader-back-btn:active {
    background: #000;
    color: #fff;
    box-shadow: none;
    transform: translate(2px, 2px);
}

.reader-status-bar {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 800px;
    background: #fff;
    /* border-top: 1px solid #eee; */
    padding: 0 0 5px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    font-family: "Hiragino Sans", sans-serif;
    color: #888;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
}

body.reader-active.reader-controls-available.reader-controls-visible .reader-status-bar,
body.reader-active.reader-controls-available.reader-controls-visible .reader-back-btn {
    opacity: 1;
    pointer-events: auto;
}

.status-left {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 70%;
    cursor: pointer;

}

.status-left:active {
    opacity: 0.6;
}

/* Book Info Card (Floating) */
.book-info-card {
    position: fixed;
    bottom: 56px;
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 40px);
    max-width: 760px;
    max-height: 75vh;
    background: #fff;
    border: 3px solid #000;
    padding: 10px 20px 20px 20px;
    z-index: 2000;
    display: none;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.1), 15px 15px 0 rgba(0, 0, 0, 0.05);
    font-family: "Hiragino Sans", "Yu Gothic", sans-serif;
    overflow-y: auto;
    /* Hide scrollbar but allow scrolling */
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.book-info-card::-webkit-scrollbar {
    display: none;
}

.book-info-card.active {
    display: block;
}

.book-info-card .card-label {
    display: inline-block;
    margin: 0 0 16px;
    padding: 3px 10px;
    background: #000;
    color: #fff;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1.5px;
}

.book-info-card .card-title {
    font-size: 20px;
    font-weight: 900;
    color: #000;
    margin-bottom: 6px;
    line-height: 1.3;
    display: block;
}

.book-info-card .card-author {
    font-size: 14px;
    color: #666;
    /* margin-bottom: 24px; */
    display: block;
    font-weight: 800;
}


.book-info-card .frontmatter-row {
    border-top: 1px solid #eee;
    padding-top: 8px;
    margin-bottom: 4px;
}

.book-info-card .frontmatter-row:first-child {
    border-top: none;
}

.book-info-card .frontmatter-label {
    font-size: 10px;
    color: #999;
}

.book-info-card .frontmatter-value {
    font-size: 12px;
    line-height: 1.5;
}

.card-footer {
    margin-top: 20px;
    border-top: 1.5px solid #eee;
    padding-top: 12px;
}

.status-right {
    font-weight: bold;
    color: #000;
    display: flex;
    align-items: center;
    gap: 12px;
}

.status-settings-btn {
    cursor: pointer;
    font-size: 16px;
}

.status-settings-btn:active {
    opacity: 1;
    transform: rotate(30deg);
}

/* Sub-panel (Book Info) */
.sub-panel {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #fff;
    z-index: 10;
    display: flex;
    flex-direction: column;
}

.sub-panel.hidden {
    display: none;
}

.sub-panel-header {
    display: flex;
    align-items: center;
    padding: 15px;
    border-bottom: 2px solid #000;
}

.sub-panel-header h3 {
    margin-left: 15px;
    font-size: 18px;
}

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

.back-btn-sm {
    background: #fff;
    border: 1px solid #000;
    padding: 5px 12px;
    font-size: 14px;
    cursor: pointer;
}

/* Info Items */
.info-section {
    margin-bottom: 24px;
}

.info-section h4 {
    font-size: 14px;
    color: #666;
    margin-bottom: 8px;
    border-bottom: 1px solid #eee;
    padding-bottom: 4px;
}

.info-row {
    margin-bottom: 12px;
}

.info-label {
    font-size: 12px;
    color: #888;
    display: block;
}

.info-value {
    font-size: 15px;
    color: #000;
    word-break: break-all;
}

.aozora-link {
    display: inline-block;
    margin-top: 10px;
    padding: 8px 16px;
    border: 1px solid #000;
    color: #000;
    text-decoration: none;
    font-weight: bold;
}

.status-info-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    font-size: 14px;
    border: 1px solid #000;
    border-radius: 50%;
    margin-left: 8px;
    cursor: pointer;
    vertical-align: middle;
}

.status-info-btn:active {
    background: #000;
    color: #fff;
}

/* Global Footer Styling */
.global-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    /* padding: 16px 0; */
    /* border-top: 1.5px solid #000; */
    flex-shrink: 0;
}

body.reader-active .global-footer {
    display: none;
}

@media (max-width: 900px) {
    .global-footer {
        width: calc(100% - 40px);
        margin: 20px 20px 0 20px;
    }
}



/* Utility Classes */
.u-cursor-pointer {
    cursor: pointer;
}

.u-margin-bottom-20 {
    margin-bottom: 20px;
}

.u-margin-top-20 {
    margin-top: 20px;
}

.u-display-flex {
    display: flex;
}

.u-display-none {
    display: none;
}

.u-gap-10 {
    gap: 10px;
}

.u-text-align-right {
    text-align: right;
}

.u-font-size-12 {
    font-size: 12px;
}

.u-font-weight-bold {
    font-weight: bold;
}

.u-color-black {
    color: #000;
}

.u-color-error {
    color: #ff0000;
}

.reader-sentinel {
    height: 100px;
    margin: 20px 0;
}

.version-tag {
    font-size: 12px;
    font-weight: bold;
    color: #000;
}

.empty-msg {
    padding: 20px;
    color: #999;
}

.dict-progress-info {
    font-size: 0.85em;
    color: #888;
}

.download-progress-container {
    width: 100%;
    height: 10px;
    background: #eee;
    margin-top: 10px;
    position: relative;
}

.download-progress-fill {
    height: 100%;
    background: #000;
    width: 0%;

}

.u-indent {
    text-indent: var(--indent, 0);
}