/* 简阅 · 阅读系统样式
 * 设计语言：克制的出版感 / 大方呼吸 / 豆瓣绿主色
 * 单色系（主色），多层级（明度），克制装饰（细边、低对比背景）
 * 统一网格：基础 8px，内容区 1280px，阅读区 720px
 */

:root {
    color-scheme: light;
    --bg:        #f5f4f0;        /* 暖灰背景，比纯灰更温润 */
    --bg-card:   #ffffff;
    --bg-soft:   #faf9f6;
    --bg-2:      #eeece6;

    --text:      #1a1a1a;
    --text-2:    #555555;
    --text-3:    #8a8a82;

    --border:    #e6e3dc;
    --border-2:  #efece5;

    --primary:   #2f7d3a;        /* 深豆瓣绿，书籍感更强 */
    --primary-2: #266430;
    --primary-bg:#eaf2ec;
    --primary-fg:#ffffff;

    --link:      #225599;        /* 豆瓣蓝 */
    --danger:    #c1453f;
    --warning:   #d99a3e;

    /* 兼容旧变量名 */
    --color-error: var(--danger);
    --color-text-soft: var(--text-2);
    --color-text-faint: var(--text-3);
    --color-border-soft: var(--border-2);
    --color-paper-card: #ffffff;
    --color-paper-2: var(--bg-soft);
    --color-paper-3: var(--bg-2);
    --color-ink-900: #1a1a1a;
    --color-accent: var(--primary);
    --border-soft: var(--border-2);

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
    --shadow:    0 1px 3px rgba(0,0,0,0.05);
    --shadow-lg: 0 6px 24px rgba(0,0,0,0.08);

    --radius:    6px;
    --radius-sm: 4px;

    --fs-xs: 12px;
    --fs-sm: 13px;
    --fs-md: 14px;
    --fs-lg: 16px;
    --fs-xl: 18px;
    --fs-2xl: 22px;
    --fs-3xl: 30px;

    --font-sans: -apple-system, BlinkMacSystemFont, "PingFang SC",
                 "Hiragino Sans GB", "Microsoft YaHei", "微软雅黑",
                 "Source Han Sans SC", "Noto Sans SC", "WenQuanYi Micro Hei",
                 "Helvetica Neue", Helvetica, Arial, sans-serif;
    --font-serif: "Source Han Serif SC", "Noto Serif SC", "Songti SC",
                  "STSong", "SimSun", "宋体", "Songti TC",
                  Georgia, "Times New Roman", "STSongti-SC-Regular", serif;
    --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
                 "Source Code Pro", monospace;
    --font-reading: var(--font-sans); /* 阅读正文用无衬线体（微软雅黑等） */

    --header-h: 56px;
    --container: 1400px;     /* 列表/首页：更宽，容纳 7+ 本/排 */
    --container-narrow: 960px;  /* 详情页/章节导航 */
    --container-reader: 720px;  /* 章节正文 */
    --gutter: 24px;              /* 容器水平内边距（与 .container 一致） */
}

/* ========== Reset ========== */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: var(--font-sans);
    font-size: var(--fs-md);
    line-height: 1.65;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    font-feature-settings: "tnum" 1, "palt" 0;  /* tabular-nums for numbers */
    -webkit-text-size-adjust: 100%;
}
a { color: var(--text); text-decoration: none; transition: color 0.15s; }
a:hover { color: var(--primary); text-decoration: none; }
img { max-width: 100%; display: block; }
button { font: inherit; cursor: pointer; }
input, textarea, select { font: inherit; }
h1, h2, h3, h4, h5, h6 {
    margin: 0; font-weight: 600; line-height: 1.35; color: var(--text);
    letter-spacing: -0.005em;
}
h1 { font-size: var(--fs-3xl); font-weight: 700; }
h2 { font-size: var(--fs-2xl); }
h3 { font-size: var(--fs-xl); }
p { margin: 0 0 12px; }
ul, ol { margin: 0; padding: 0; list-style: none; }
.serif { font-family: var(--font-serif); }

/* ========== Topbar ========== */
.topbar {
    background: rgba(255,255,255,0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    height: var(--header-h);
    position: sticky; top: 0; z-index: 100;
}
.topbar-inner {
    max-width: var(--container); margin: 0 auto;
    height: 100%;
    padding: 0 var(--gutter);
    display: flex; align-items: center; gap: 32px;
}
.topbar.scrolled { box-shadow: 0 1px 0 var(--border), 0 4px 12px rgba(0,0,0,0.03); }

.brand {
    display: flex; align-items: center; gap: 10px;
    font-size: 19px; font-weight: 700;
    color: var(--text);
    letter-spacing: -0.01em;
}
.brand:hover { text-decoration: none; color: var(--text); }
.brand .logo {
    width: 30px; height: 30px;
    background: var(--primary);
    color: #fff;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 4px;
    font-size: 16px; font-weight: 700;
    font-family: var(--font-serif);
}
.brand-center { justify-content: center; margin-bottom: 24px; }

.nav { display: flex; align-items: center; gap: 4px; flex: 1; }
.nav a {
    padding: 7px 14px; border-radius: var(--radius-sm);
    color: var(--text-2); font-size: var(--fs-md);
    transition: color 0.15s, background 0.15s;
    font-weight: 500;
}
.nav a:hover { background: var(--bg-soft); color: var(--text); text-decoration: none; }
.nav a.active { color: var(--primary); background: var(--primary-bg); }
.nav .right { margin-left: auto; }

/* ========== Container ========== */
.container {
    max-width: var(--container);
    margin: 0 auto;
    padding: 20px 24px 16px;
}
.container-narrow {
    max-width: var(--container-narrow);
    margin: 0 auto;
    padding: 28px 24px 16px;
}
.container-reader {
    max-width: var(--container-reader);
    margin: 0 auto;
    padding: 24px;
}

/* ========== Card ========== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
}
.card + .card { margin-top: 16px; }
.card-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 16px; padding-bottom: 16px;
    border-bottom: 1px solid var(--border-2);
}
.card-title { font-size: var(--fs-lg); font-weight: 600; }

/* ========== Buttons ========== */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    height: 38px; padding: 0 18px;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text);
    border-radius: var(--radius-sm);
    font-size: var(--fs-md);
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
    text-decoration: none;
    white-space: nowrap;
    line-height: 1;
    font-weight: 500;
}
.btn:hover { border-color: #b8b8b0; text-decoration: none; color: var(--text); }
.btn-primary {
    background: var(--primary); color: var(--primary-fg); border-color: var(--primary);
}
.btn-primary:hover { background: var(--primary-2); border-color: var(--primary-2); color: #fff; }
.btn-link {
    background: transparent; border-color: transparent;
    color: var(--link); padding: 0 4px;
    height: auto;
}
.btn-link:hover { background: transparent; text-decoration: underline; }
.btn-text {
    background: transparent; border-color: transparent;
    color: var(--text-2);
    padding: 7px 14px;
    height: auto;
    font-weight: 500;
}
.btn-text:hover { background: var(--bg-soft); color: var(--text); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--bg-soft); color: var(--text); }
.btn-sm { height: 30px; padding: 0 12px; font-size: var(--fs-sm); }
.btn-lg { height: 48px; padding: 0 28px; font-size: var(--fs-lg); }
.btn-block { width: 100%; }
.btn-danger { color: var(--danger); border-color: var(--danger); background: #fff; }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-mini.btn-danger, .btn-sm.btn-danger { padding: 0 8px; }
[data-theme="dark"] .btn-danger { background: #2a2a2a; }

/* ========== Form ========== */
.form-row { margin-bottom: 18px; }
.form-row label {
    display: block; margin-bottom: 8px;
    font-size: var(--fs-sm); color: var(--text-2);
    font-weight: 500;
}
.form-row input, .form-row textarea, .form-row select {
    width: 100%; height: 40px; padding: 0 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: #fff;
    font-size: var(--fs-md);
    color: var(--text);
    transition: border-color 0.15s, box-shadow 0.15s;
}
.form-row input:focus, .form-row textarea:focus, .form-row select:focus {
    outline: none; border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(47,125,58,0.10);
}
.form-row textarea { height: auto; min-height: 100px; padding: 10px 14px; resize: vertical; }
.mono-textarea { min-height: 420px; font-family: var(--font-mono); line-height: 1.7; }
.form-row .hint { font-size: var(--fs-xs); color: var(--text-3); margin-top: 6px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 720px) { .form-grid { grid-template-columns: 1fr; } }

/* ========== Alert ========== */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: var(--fs-md);
    border: 1px solid var(--border);
    background: var(--bg-soft);
    margin-bottom: 18px;
}
.alert-error   { background: #fbecec; border-color: #f0c4c1; color: #9a2e2a; }
.alert-success { background: #e6f0e8; border-color: #b4d4ba; color: #2c5e36; }
.alert-info    { background: #e6eef7; border-color: #b4cae3; color: #2c4a8b; }

/* ========== Section & Hero ========== */
.section {
    background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
    padding: 28px; margin-bottom: 20px;
}
.section-head {
    display: flex; align-items: baseline; justify-content: space-between;
    margin-bottom: 20px; gap: 12px; flex-wrap: wrap;
}
.section-head h2 { font-size: var(--fs-xl); }
.section-head .sub, .section-head .lead { color: var(--text-3); font-size: var(--fs-sm); margin-top: 4px; }
.section-head .more { color: var(--text-3); font-size: var(--fs-sm); }

/* 首屏：标题 + 副标题 + 内联统计 + 工具栏 一行搞定
 * 微信读书的范式：标题左，分类+搜索在右，整页很紧凑
 */
.page-hero {
    display: flex; align-items: center; justify-content: space-between;
    gap: 20px; flex-wrap: wrap;
    padding: 4px 0 12px;
    margin-bottom: 12px;
    border-bottom: 1px solid var(--border-2);
}
.page-hero h1 {
    font-family: var(--font-serif);
    font-size: 24px; font-weight: 700;
    letter-spacing: -0.01em;
    margin: 0 0 2px;
    line-height: 1.2;
}
.page-hero .lead {
    color: var(--text-3);
    font-size: 12.5px;
    line-height: 1.4;
}
.page-hero .stats {
    display: flex; gap: 4px;
    align-items: center;
    color: var(--text-2);
    font-size: 12px;
}
.page-hero .stats .sep { color: var(--text-3); margin: 0 8px; }
.page-hero .stats strong {
    color: var(--text);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    font-family: var(--font-serif);
}

/* ========== Book grid ==========
 * 高密度网格：150px 起步，一排尽可能多。
 * 卡片是经典的"封面+书名+作者+统计"四行竖排。
 * 微信读书是横卡（封面左、字右），豆瓣是竖卡。简阅用竖卡，
 * 但缩到 150px、缩窄 gap、缩窄 padding，达到 7+ 一排。
 */
.book-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 18px 14px;
}
@media (max-width: 600px) { .book-grid { grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 16px 10px; } }
.book-card {
    display: flex;
    flex-direction: column;
    color: inherit;
    /* 关键：让 .book-card 在 grid item 里彻底块级流，不被邻居拉伸 */
    width: 100%;
    align-self: start;
}
.book-card a { color: inherit; text-decoration: none; }
a.book-cover-link {
    display: block;
    text-decoration: none;
    color: inherit;
    border-radius: 3px;
}
.book-cover {
    position: relative;
    width: 100%;
    height: 0;
    padding-bottom: 150%;   /* 2/3 比例，固定 150% 高度 */
    background: #f0ede6;
    border-radius: 3px;
    overflow: hidden;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    margin-bottom: 8px;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.book-cover img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
a.book-cover-link:hover .book-cover {
    transform: translateY(-2px);
    box-shadow: 0 2px 6px rgba(0,0,0,0.08), 0 6px 16px rgba(0,0,0,0.08);
}
.book-cover .cover-corner {
    position: absolute; top: 6px; right: 6px;
}
.book-title {
    font-size: 13px; font-weight: 500;
    color: var(--text);
    line-height: 1.35;
    display: block;          /* 强制单行 */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin: 0;
    transition: color 0.15s;
    text-align: left;
    text-decoration: none;
}
a.book-cover-link:hover ~ .book-title,
.book-card:hover .book-title { color: var(--primary); }
.book-author {
    display: block;
    text-align: left;
    font-size: 12px;
    color: var(--text-2);
    margin: 3px 0 0;
    line-height: 1.35;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.book-stats {
    text-align: left;
    font-size: 11px;
    color: var(--text-3);
    line-height: 1.4;
    margin-top: 2px;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;     /* 章·字 同行不换行 */
    overflow: hidden;
    text-overflow: ellipsis;
}
.book-stats .sep { color: var(--text-3); margin: 0 3px; }

/* ========== Footer / 转载声明 ========== */
.site-footer {
    border-top: 1px solid var(--border);
    margin-top: 64px;
    padding: 36px 32px 48px;
    color: var(--text-3);
    font-size: 12px;
    line-height: 1.9;
    text-align: center;
}
.site-footer .disclaimer {
    max-width: 720px;
    margin: 0 auto;
}
.site-footer .disclaimer p { margin: 4px 0; }
.site-footer .disclaimer .lead {
    font-weight: 500;
    color: var(--text-2);
    font-size: 13px;
}
.site-footer .disclaimer .contact {
    margin-top: 8px;
    color: var(--text-2);
}
.site-footer .disclaimer a {
    color: var(--text-2);
    text-decoration: none;
    border-bottom: 1px dashed var(--text-3);
    padding-bottom: 1px;
}
.site-footer .disclaimer a:hover { color: var(--primary); border-bottom-color: var(--primary); }
.site-footer .copy {
    margin-top: 16px;
    color: var(--text-3);
    font-size: 11px;
    letter-spacing: 0.05em;
}
.book-meta { font-size: var(--fs-xs); color: var(--text-3); }
.book-meta .author { color: var(--text-2); }

/* ========== 分页 ========== */
.pager {
    margin-top: 32px;
    display: flex;
    justify-content: center;
}
.pager-inner {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 2px;
    align-items: center;
    padding: 4px;
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.pager a, .pager .pg-cur, .pager .pg-disabled, .pager .pg-ellipsis {
    display: inline-block;
    min-width: 36px;
    padding: 7px 12px;
    border-radius: 4px;
    font-size: 13px;
    text-align: center;
    text-decoration: none;
    line-height: 1.2;
    color: var(--text-2);
    transition: background 0.15s, color 0.15s;
    font-variant-numeric: tabular-nums;
}
.pager a:hover { background: var(--bg-card); color: var(--primary); }
.pager .pg-cur { background: var(--primary); color: #fff; font-weight: 600; cursor: default; }
.pager .pg-disabled { color: var(--text-3); cursor: not-allowed; opacity: 0.5; }
.pager .pg-ellipsis { color: var(--text-3); padding: 7px 4px; min-width: 0; }

/* ========== 历史勾选 / 批量删除 ========== */
.hist-row {
    display: flex;
    align-items: center;
    gap: 14px;
}
.hist-row .hist-check {
    flex: 0 0 auto;
    width: 18px; height: 18px;
    accent-color: var(--primary);
    cursor: pointer;
}
.hist-row .hist-link {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: inherit;
}
.hist-row .hist-link:hover { color: var(--primary); }
.hist-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-soft);
    border-radius: var(--radius) var(--radius) 0 0;
}
.hist-toolbar .left, .hist-toolbar .right { display: flex; align-items: center; gap: 8px; }
.hist-toolbar .count { color: var(--text-3); font-size: 12px; }
.hist-toolbar .btn-del {
    background: #fff;
    border: 1px solid var(--danger);
    color: var(--danger);
    border-radius: 4px;
    padding: 4px 10px;
    font-size: 13px;
    cursor: pointer;
}
.hist-toolbar .btn-del:hover:not(:disabled) { background: var(--danger); color: #fff; }
.hist-toolbar .btn-del:disabled { opacity: 0.4; cursor: not-allowed; }

/* ========== Pills ========== */
.pill {
    display: inline-block;
    padding: 1px 7px;
    border-radius: 3px;
    font-size: 11px; font-weight: 500;
    background: var(--bg-soft);
    color: var(--text-2);
    margin-right: 4px;
    line-height: 1.6;
}
.pill-public  { background: #e6eef7; color: #2c4a8b; }
.pill-private { background: #fbf0dc; color: #a8742c; }
.pill-on      { background: #e6f0e8; color: #2c5e36; }
.pill-off     { background: #fbecec; color: #9a2e2a; }
.pill-vip     { background: #fbf0dc; color: #a8742c; }

/* ========== Book detail ========== */
.book-detail {
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: 56px;
    padding: 16px 0 32px;
}
@media (max-width: 720px) { .book-detail { grid-template-columns: 1fr; gap: 24px; } .book-detail .cover-large { max-width: 180px; margin: 0 auto; } }
.book-detail .cover-large {
    aspect-ratio: 2/3;
    border-radius: var(--radius);
    overflow: hidden;
    background: #f0ede6;
    box-shadow: 0 6px 24px rgba(0,0,0,0.10), 0 2px 6px rgba(0,0,0,0.05);
}
.book-detail .cover-large img { width: 100%; height: 100%; object-fit: cover; }
.book-detail h1 {
    font-family: var(--font-serif);
    font-size: 32px;
    margin-bottom: 10px;
    letter-spacing: -0.01em;
    line-height: 1.3;
}
.book-detail .byline {
    color: var(--text-2);
    margin-bottom: 20px;
    font-size: var(--fs-md);
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.book-detail .byline .author { color: var(--text); font-weight: 500; }
.book-detail .byline .sep { color: var(--text-3); }
.book-detail .desc {
    color: var(--text-2);
    line-height: 1.8;
    margin-bottom: 24px;
    font-size: 14.5px;
    border-left: 2px solid var(--border);
    padding-left: 14px;
}

.meta-strip {
    display: flex; gap: 0;
    color: var(--text-2); font-size: var(--fs-sm);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #fff;
    overflow: hidden;
    margin-bottom: 24px;
}
.meta-strip .item {
    flex: 1; padding: 14px 18px;
    text-align: center;
    border-right: 1px solid var(--border-2);
}
.meta-strip .item:last-child { border-right: none; }
.meta-strip .item .label {
    display: block; font-size: 11px; color: var(--text-3);
    margin-bottom: 6px;
    letter-spacing: 0.04em;
}
.meta-strip .item .v {
    color: var(--text); font-weight: 600; font-size: var(--fs-xl);
    font-family: var(--font-serif);
    font-variant-numeric: tabular-nums;
}

.book-detail .actions {
    display: flex; gap: 10px; flex-wrap: wrap;
    margin-top: 8px;
}

.progress-box {
    background: #fff; border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 18px;
    margin-bottom: 24px;
}
.progress-box .lbl {
    display: flex; justify-content: space-between;
    font-size: var(--fs-sm); color: var(--text-2);
    margin-bottom: 10px;
    font-variant-numeric: tabular-nums;
}
.progress-box .bar {
    height: 4px; background: var(--border); border-radius: 2px; overflow: hidden;
}
.progress-box .bar > div, .progress-box .bar > .bar-fill {
    height: 100%; background: var(--primary);
    transition: width 0.4s;
}

/* ========== Chapter list ========== */
.chapter-list { list-style: none; padding: 0; margin: 0; }
.chapter-list li { border-bottom: 1px solid var(--border-2); }
.chapter-list li:last-child { border-bottom: none; }
.chapter-list a {
    display: flex; align-items: center; gap: 14px;
    padding: 14px 12px;
    color: var(--text);
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
}
.chapter-list a:hover { background: var(--bg-soft); }
.chapter-list .num {
    color: var(--text-3); font-size: var(--fs-sm);
    min-width: 56px;
    font-variant-numeric: tabular-nums;
    font-family: var(--font-mono);
}
.chapter-list .name {
    flex: 1; font-size: var(--fs-md);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chapter-list .name:hover { color: var(--primary); }
.chapter-list .word {
    color: var(--text-3); font-size: var(--fs-xs);
    font-variant-numeric: tabular-nums;
    min-width: 60px; text-align: right;
}
.chapter-list a.chapter-locked { color: var(--text-3); position: relative; }
.chapter-list a.chapter-locked:hover { background: var(--bg-soft); }
.chapter-list a.chapter-locked .name { color: var(--text-2); }
.chapter-list a.chapter-locked::after {
    content: "登录后阅读";
    font-size: 11px;
    color: var(--text-3);
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 1px 6px;
    margin-left: 4px;
}

.volume-group { margin-top: 24px; }
.volume-title {
    font-family: var(--font-serif);
    font-size: var(--fs-lg); font-weight: 600;
    margin: 0 0 12px;
    padding: 10px 0;
    color: var(--text);
    border-bottom: 1px solid var(--primary);
    display: flex; align-items: baseline; gap: 8px;
}
.volume-title .count { font-size: var(--fs-xs); color: var(--text-3); font-weight: normal; font-family: var(--font-sans); }

/* ========== Empty state ========== */
.empty {
    text-align: center;
    padding: 80px 20px;
    color: var(--text-3);
}
.empty .icon { font-size: 44px; opacity: 0.4; margin-bottom: 14px; }
.empty h3 { font-weight: normal; color: var(--text-2); margin-bottom: 8px; font-family: var(--font-serif); }
.empty p { font-size: var(--fs-sm); margin: 0; }

/* ========== Auth pages ========== */
.auth-page { min-height: 100vh; background: var(--bg); display: flex; flex-direction: column; }
.auth-wrap { flex: 1; display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.auth-card {
    width: 100%; max-width: 400px;
    background: #fff; border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 36px 32px;
    box-shadow: var(--shadow);
}
.auth-card h1 { font-size: var(--fs-2xl); margin-bottom: 8px; text-align: center; font-family: var(--font-serif); }
.auth-card .lead { color: var(--text-2); text-align: center; margin-bottom: 28px; font-size: var(--fs-md); }
.auth-card .foot {
    margin-top: 20px; padding-top: 18px;
    border-top: 1px solid var(--border-2);
    text-align: center; color: var(--text-2); font-size: var(--fs-sm);
}
.auth-card .foot a { color: var(--link); }

/* ========== Reader ========== */
.reader-page { background: #fff; min-height: 100vh; }
/* 阅读主题：纸张 / 羊皮 / 暗色（与后台 reading_theme 同步） */
.reader-page.theme-sepia { background: #f4ecd8; color: #5b4636; }
.reader-page.theme-sepia .reader { color: #5b4636; }
.reader-page.theme-sepia .reader-body { color: #5b4636; }
.reader-page.theme-sepia .reader-header h1 { color: #5b4636; }
.reader-page.theme-sepia .reader-bar { background: rgba(244,236,216,0.95); border-bottom-color: #d8c9a8; }
.reader-page.theme-sepia .reader-nav a, .reader-page.theme-sepia .reader-nav span { background: #fbf5e6; border-color: #d8c9a8; color: #5b4636; }
.reader-page.theme-sepia .reader-controls { background: #fbf5e6; border-color: #d8c9a8; }
.reader-page.theme-sepia .reader-bar .ctrls button { background: #fbf5e6; border-color: #d8c9a8; color: #5b4636; }

.reader-page.theme-dark { background: #181818; color: #d0d0d0; }
.reader-page.theme-dark .reader { color: #d0d0d0; }
.reader-page.theme-dark .reader-body { color: #d0d0d0; }
.reader-page.theme-dark .reader-header h1 { color: #e8e8e8; }
.reader-page.theme-dark .reader-bar { background: rgba(31,31,31,0.95); border-bottom-color: #2a2a2a; }
.reader-page.theme-dark .reader-nav a, .reader-page.theme-dark .reader-nav span { background: #232323; border-color: #2a2a2a; color: #d0d0d0; }
.reader-page.theme-dark .reader-controls { background: #232323; border-color: #2a2a2a; }
.reader-page.theme-dark .reader-bar .ctrls button { background: #232323; border-color: #2a2a2a; color: #d0d0d0; }

.reader-bar {
    position: sticky; top: 0; z-index: 50;
    background: rgba(255,255,255,0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    height: 52px;
    display: flex; align-items: center;
    padding: 0 32px; gap: 20px;
    font-size: var(--fs-sm);
    max-width: 100%;
}
.reader-bar a, .reader-bar .crumb { color: var(--text-2); text-decoration: none; }
.reader-bar a:hover { color: var(--text); }
.breadcrumb { display: flex; align-items: center; gap: 6px; font-size: var(--fs-sm); white-space: nowrap; overflow: hidden; }
.breadcrumb span { color: var(--text-3); }
.breadcrumb a { color: var(--text-2); text-decoration: none; }
.breadcrumb a:hover { color: var(--text); }
.reader-bar .title {
    flex: 1; text-align: center;
    font-weight: 500; color: var(--text);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.reader-bar .ctrls { display: flex; gap: 4px; }
.reader-bar .ctrls button {
    width: 32px; height: 32px;
    border: 1px solid var(--border);
    background: #fff; color: var(--text-2);
    border-radius: var(--radius-sm);
    font-size: 12px; line-height: 1;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.reader-bar .ctrls button:hover { color: var(--primary); border-color: var(--primary); }

.reader {
    max-width: var(--container-reader);
    margin: 0 auto;
    padding: 56px 24px 96px;
    color: #222;
}
.reader-header {
    text-align: center;
    margin-bottom: 40px;
    padding-bottom: 28px;
    border-bottom: 1px solid var(--border-2);
}
.reader-header h1 {
    font-family: var(--font-serif);
    font-size: 26px; font-weight: 600;
    margin: 14px 0 10px;
    letter-spacing: -0.005em;
    line-height: 1.4;
}
.reader-header .info { color: var(--text-3); font-size: var(--fs-sm); }
.reader-header .info .sep { margin: 0 6px; color: var(--border); }
.reader-header .volume {
    display: inline-block;
    font-family: var(--font-sans);
    font-size: var(--fs-xs); color: var(--text-3);
    padding: 3px 10px;
    border: 1px solid var(--border);
    border-radius: 3px;
    letter-spacing: 0.05em;
}
.reader-body {
    white-space: pre-wrap; word-break: break-word;
    text-align: justify;
    font-size: 22px; line-height: 1.9;
    color: #222;
    font-family: var(--font-reading);
}
.reader-body p {
    margin: 0 0 1.2em;
    text-indent: 2em;
}
.reader-nav {
    display: flex;
    gap: 12px;
    margin-top: 56px;
    padding-top: 32px;
    border-top: 1px solid var(--border-2);
}
.reader-nav a, .reader-nav span {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 16px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #fff;
    color: var(--text);
    text-decoration: none;
    font-size: 15px;
    font-weight: 500;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
    min-height: 64px;
}
.reader-nav a.prev { align-items: flex-start; }
.reader-nav a.next { align-items: flex-end; }
.reader-nav a:hover { border-color: var(--primary); color: var(--primary); }
.reader-nav .center {
    flex: 0 0 auto;
    background: var(--primary); color: #fff; border-color: var(--primary);
    padding-left: 32px; padding-right: 32px;
}
.reader-nav .center:hover { background: var(--primary-2); color: #fff; }
.reader-nav .empty { border: none; background: transparent; }
.reader-nav .nav-title {
    display: block; font-size: 12px; font-weight: 400; color: var(--text-3);
    margin-bottom: 4px;
    letter-spacing: 0.04em;
}
.reader-nav a:hover .nav-title { color: var(--primary); }

.reader-controls {
    position: fixed; right: 20px; bottom: 20px; z-index: 60;
    background: #fff; border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 4px; display: flex; flex-direction: column; gap: 2px;
    box-shadow: var(--shadow);
}
.reader-controls button {
    width: 34px; height: 34px;
    border: none; background: transparent;
    color: var(--text-2); font-size: 14px;
    border-radius: 3px; line-height: 1;
    transition: background 0.15s, color 0.15s;
}
.reader-controls button:hover { background: var(--bg-soft); color: var(--text); }

/* ========== 浮动工具按钮（TOP + 主题） ========== */
.float-actions {
    position: fixed; right: 20px; bottom: 20px; z-index: 60;
    display: flex; flex-direction: column; gap: 8px;
    opacity: 0; transform: translateY(8px);
    pointer-events: none;
    transition: opacity 0.2s, transform 0.2s;
}
.float-actions.is-visible { opacity: 1; transform: translateY(0); pointer-events: auto; }
.fab {
    width: 42px; height: 42px;
    background: #fff; border: 1px solid var(--border);
    color: var(--text-2); font-size: 18px;
    border-radius: 50%;
    line-height: 1; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
    box-shadow: var(--shadow);
    transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.15s;
}
.fab:hover { background: var(--primary); border-color: var(--primary); color: #fff; transform: translateY(-2px); }
.fab:active { transform: translateY(0); }
.fab.is-on { background: var(--primary); color: #fff; border-color: var(--primary); }
[data-theme="dark"] .fab, [data-theme="dark"] .reader-controls { background: #2a2a2a; border-color: var(--border); }
@media (prefers-reduced-motion: reduce) {
    .fab, .float-actions { transition: none; }
}
@media (max-width: 600px) {
    .float-actions { right: 10px; bottom: 10px; }
    .fab { width: 36px; height: 36px; font-size: 16px; }
    .reader-controls {
        right: auto; left: 50%; bottom: 12px;
        transform: translateX(-50%);
        flex-direction: row;
        border-radius: 20px;
        padding: 2px 4px;
    }
    .reader-controls button { width: 32px; height: 32px; font-size: 13px; }
}

.reader-end {
    text-align: center;
    padding: 40px 0 80px;
    color: var(--text-3);
    font-size: 14px;
    letter-spacing: 0.15em;
    font-family: var(--font-serif);
}

/* ========== Admin ========== */
.admin-shell {
    display: grid;
    grid-template-columns: 220px 1fr;
    min-height: 100vh;
}
@media (max-width: 900px) { .admin-shell { grid-template-columns: 1fr; } .admin-side { display: none; } }
.admin-side {
    background: #232323;
    color: #b0b0b0;
    padding: 18px 0;
    display: flex; flex-direction: column;
}
.admin-side .brand {
    padding: 0 20px 18px; color: #fff;
    border-bottom: 1px solid #333;
    margin-bottom: 14px;
    font-size: 17px;
    display: flex; flex-direction: column; gap: 0;
}
.admin-side .brand small {
    font-size: 10px; color: #888; font-weight: normal;
    margin-top: 4px;
    letter-spacing: 0.04em;
}
.admin-side nav { flex: 1; }
.admin-side nav a {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 20px;
    color: #b0b0b0;
    font-size: var(--fs-md);
    border-left: 3px solid transparent;
    text-decoration: none;
}
.admin-side nav a:hover { background: #2e2e2e; color: #fff; }
.admin-side nav a.active { background: #2e2e2e; color: #fff; border-left-color: var(--primary); }
.admin-side nav .icon { width: 16px; font-size: 14px; opacity: 0.7; }
.admin-side .foot {
    padding: 14px 20px;
    border-top: 1px solid #333;
    font-size: var(--fs-xs); color: #888;
}
.admin-side .foot a { color: #b0b0b0; }
.admin-side .foot a:hover { color: #fff; }

.admin-main { padding: 32px 40px; background: var(--bg); min-height: 100vh; min-width: 0; }
.admin-main .page-head {
    display: flex; align-items: baseline; justify-content: space-between;
    margin-bottom: 24px; padding-bottom: 18px;
    border-bottom: 1px solid var(--border);
    gap: 16px; flex-wrap: wrap;
}
.admin-main h1 { font-size: var(--fs-2xl); }
.admin-main .subtitle { color: var(--text-3); font-size: var(--fs-sm); margin-top: 4px; }
.admin-main .actions { display: flex; gap: 8px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 24px; }
.stat, .stat-card {
    background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
    padding: 20px;
}
.stat .label, .stat-card .label { font-size: var(--fs-xs); color: var(--text-3); margin-bottom: 6px; letter-spacing: 0.04em; }
.stat .num, .stat-card .num { font-size: var(--fs-2xl); font-weight: 600; color: var(--text); font-family: var(--font-serif); font-variant-numeric: tabular-nums; }

.admin-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; align-items: center; }
.toolbar { display: flex; gap: 8px; margin-bottom: 18px; }
.toolbar input[type="text"] {
    flex: 1; min-width: 0; max-width: 360px; height: 38px; padding: 0 14px;
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: #fff; font-size: var(--fs-md);
    transition: border-color 0.15s, box-shadow 0.15s;
}
.toolbar input[type="text"]:focus {
    outline: none; border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(47,125,58,0.10);
}
.empty-tip { padding: 48px 16px; text-align: center; color: var(--text-3); font-size: var(--fs-sm); }
.btn-mini { height: 28px; padding: 0 10px; font-size: 12px; border-radius: 3px; }
.tab-bar { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; flex-wrap: wrap; }
.tab-bar a,
.tab-bar button {
    padding: 10px 18px; color: var(--text-2); text-decoration: none;
    border-bottom: 2px solid transparent; margin-bottom: -1px;
    font-size: var(--fs-md);
    background: transparent; border-left: none; border-right: none; border-top: none;
    cursor: pointer; font-family: inherit;
    font-weight: 500;
}
.tab-bar a:hover, .tab-bar button:hover { color: var(--text); text-decoration: none; }
.tab-bar a.active, .tab-bar button.active { color: var(--primary); border-bottom-color: var(--primary); }
.row-flex { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row-flex .grow { flex: 1; min-width: 160px; }
.row-flex select,
.row-flex input { height: 38px; padding: 0 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: #fff; font-size: var(--fs-md); }
.select-mini { padding: 2px 6px; font-size: 12px; height: 28px; border: 1px solid var(--border); border-radius: 3px; background: #fff; }
[data-theme="dark"] .select-mini { background: #2a2a2a; border-color: var(--border); color: var(--text); }

/* Tables */
.table-wrap { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.table, .table-wrap table { width: 100%; border-collapse: collapse; }
.table th, .table td, .table-wrap th, .table-wrap td {
    padding: 12px 18px; text-align: left;
    border-bottom: 1px solid var(--border-2);
    font-size: var(--fs-md);
    vertical-align: middle;
}
.table th, .table-wrap th {
    background: var(--bg-soft);
    font-size: var(--fs-sm); color: var(--text-2);
    font-weight: 600;
}
.table tr:last-child td, .table-wrap tr:last-child td { border-bottom: none; }
.table tbody tr:hover td, .table-wrap tbody tr:hover td { background: var(--bg-soft); }

.pagination { padding: 14px 18px; display: flex; gap: 4px; justify-content: flex-end; flex-wrap: wrap; }
.pagination a, .pagination span {
    padding: 5px 12px; border: 1px solid var(--border); border-radius: 3px;
    font-size: var(--fs-sm); text-decoration: none; color: var(--text);
    background: #fff;
}
.pagination a:hover { border-color: var(--primary); color: var(--primary); }
.pagination .active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination .disabled { color: var(--text-3); background: var(--bg-soft); }
.pagination .page-info { padding: 6px 14px; color: var(--text-2); font-size: 14px; line-height: 1.6; border: none; }

.copy-btn {
    border: 1px solid var(--border);
    background: #fff;
    font-family: var(--font-sans);
    color: var(--text-2);
    padding: 3px 8px; border-radius: 3px;
    cursor: pointer; font-size: 11px;
}
.copy-btn:hover { color: var(--primary); border-color: var(--primary); }
.copy-btn.copied { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ========== Utilities ========== */
.muted { color: var(--text-2); } .faint { color: var(--text-3); }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row-spread { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; } .mb-3 { margin-bottom: 24px; }
.text-sm { font-size: var(--fs-sm); } .text-xs { font-size: var(--fs-xs); }
.text-center { text-align: center; }
.hide-mobile { display: initial; }
@media (max-width: 600px) { .hide-mobile { display: none; } }
@media (max-width: 600px) { .show-mobile { display: initial; } .hide-on-mobile { display: none; } }

.code { font-family: var(--font-mono); font-size: 0.95em; background: var(--bg-soft); padding: 1px 6px; border-radius: 3px; border: 1px solid var(--border-2); }

/* ========== Dark theme ========== */
[data-theme="dark"] {
    color-scheme: dark;
    --bg:        #181816;
    --bg-card:   #222220;
    --bg-soft:   #2a2a27;
    --bg-2:      #30302c;

    --text:      #e8e6e0;
    --text-2:    #a8a6a0;
    --text-3:    #78766f;

    --border:    #34342f;
    --border-2:  #2a2a26;

    --primary:   #6fcf7e;
    --primary-2: #5cba6b;
    --primary-bg:#1f2e22;
    --primary-fg:#0a1f10;

    --link:      #7a9bd9;
    --danger:    #e07870;
}
[data-theme="dark"] body { color: var(--text); background: var(--bg); }
[data-theme="dark"] .topbar { background: rgba(31,31,29,0.92); border-bottom-color: var(--border); }
[data-theme="dark"] .brand { color: var(--text); }
[data-theme="dark"] .nav a { color: var(--text-2); }
[data-theme="dark"] .nav a:hover { background: var(--bg-soft); color: var(--text); }
[data-theme="dark"] .nav a.active { color: var(--primary); background: var(--primary-bg); }
[data-theme="dark"] .btn { background: #2a2a27; border-color: var(--border); color: var(--text); }
[data-theme="dark"] .btn:hover { border-color: #555; color: var(--text); }
[data-theme="dark"] .btn-primary { background: var(--primary); color: var(--primary-fg); border-color: var(--primary); }
[data-theme="dark"] .btn-primary:hover { background: var(--primary-2); color: var(--primary-fg); }
[data-theme="dark"] .btn-text { color: var(--text-2); }
[data-theme="dark"] .btn-text:hover { background: var(--bg-soft); color: var(--text); }
[data-theme="dark"] .form-row input,
[data-theme="dark"] .form-row textarea,
[data-theme="dark"] .form-row select { background: #2a2a27; border-color: var(--border); color: var(--text); }
[data-theme="dark"] .form-row input:focus,
[data-theme="dark"] .form-row textarea:focus,
[data-theme="dark"] .form-row select:focus { border-color: var(--primary); }
[data-theme="dark"] .card, [data-theme="dark"] .section,
[data-theme="dark"] .table-wrap, [data-theme="dark"] .meta-strip,
[data-theme="dark"] .stat, [data-theme="dark"] .stat-card,
[data-theme="dark"] .progress-box { background: var(--bg-card); border-color: var(--border); }
[data-theme="dark"] .book-cover { background: #2a2a27; }
[data-theme="dark"] .alert { background: var(--bg-soft); border-color: var(--border); }
[data-theme="dark"] .alert-error { background: #3a1f1d; border-color: #5a2c2a; color: #f0a89e; }
[data-theme="dark"] .alert-success { background: #1f2e22; border-color: #2c4a32; color: #9fcf9f; }
[data-theme="dark"] .alert-info { background: #1f2638; border-color: #2c3a5a; color: #a8c0e0; }
[data-theme="dark"] .pill-public { background: #1f2638; color: #a8c0e0; }
[data-theme="dark"] .pill-private { background: #3a2c1f; color: #d4b58a; }
[data-theme="dark"] .pill-on { background: #1f2e22; color: #9fcf9f; }
[data-theme="dark"] .pill-off { background: #3a1f1d; color: #f0a89e; }
[data-theme="dark"] .table th, [data-theme="dark"] .table-wrap th { background: var(--bg-soft); color: var(--text-2); }
[data-theme="dark"] .table td, [data-theme="dark"] .table-wrap td { border-bottom-color: var(--border-2); }
[data-theme="dark"] .table tbody tr:hover td,
[data-theme="dark"] .table-wrap tbody tr:hover td { background: var(--bg-soft); }
[data-theme="dark"] .chapter-list li { border-bottom-color: var(--border-2); }
[data-theme="dark"] .chapter-list a:hover { background: var(--bg-soft); }
[data-theme="dark"] .book-detail .desc, [data-theme="dark"] .book-detail .byline { color: var(--text-2); }
[data-theme="dark"] .meta-strip .item { border-right-color: var(--border-2); }
[data-theme="dark"] .meta-strip .item .label { color: var(--text-3); }
[data-theme="dark"] .meta-strip .item .v { color: var(--text); }
[data-theme="dark"] .reader-page { background: var(--bg-card); }
[data-theme="dark"] .reader { color: #d0d0d0; }
[data-theme="dark"] .reader-body { color: #d0d0d0; }
[data-theme="dark"] .reader-bar { background: rgba(31,31,29,0.95); border-bottom-color: var(--border); }
[data-theme="dark"] .reader-bar .ctrls button { background: #2a2a27; border-color: var(--border); color: var(--text-2); }
[data-theme="dark"] .reader-nav a, [data-theme="dark"] .reader-nav span { background: var(--bg-card); border-color: var(--border); color: var(--text); }
[data-theme="dark"] .reader-controls { background: var(--bg-card); border-color: var(--border); }
[data-theme="dark"] .auth-card { background: var(--bg-card); border-color: var(--border); }
[data-theme="dark"] .admin-main { background: var(--bg); }
[data-theme="dark"] .admin-side { background: #161614; }
[data-theme="dark"] .toolbar input[type="text"] { background: #2a2a27; border-color: var(--border); color: var(--text); }
[data-theme="dark"] .empty, [data-theme="dark"] .empty-tip { color: var(--text-3); }
[data-theme="dark"] .progress-box .bar { background: var(--border); }
[data-theme="dark"] .topbar.scrolled { box-shadow: 0 1px 4px rgba(0,0,0,0.4); }
[data-theme="dark"] .pager-inner { background: var(--bg-soft); }

/* ========== Focus / a11y / motion ========== */
:focus { outline: none; }
:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}
.btn:focus-visible,
.form-row input:focus-visible,
.form-row select:focus-visible,
.form-row textarea:focus-visible,
.nav a:focus-visible,
.tab-bar a:focus-visible,
.admin-side nav a:focus-visible {
    outline-offset: 2px;
}
::selection { background: rgba(47,125,58,0.20); color: inherit; }
[data-theme="dark"] ::selection { background: rgba(111,207,126,0.30); }
[data-theme="dark"] ::-webkit-scrollbar { width: 10px; height: 10px; }
[data-theme="dark"] ::-webkit-scrollbar-track { background: #1a1a18; }
[data-theme="dark"] ::-webkit-scrollbar-thumb { background: #3a3a36; border-radius: 4px; }
[data-theme="dark"] ::-webkit-scrollbar-thumb:hover { background: #4a4a45; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d0cec5; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #b0aea5; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ========== Skip link / form filter tools ========== */
.skip-link {
    position: absolute; top: -40px; left: 8px; z-index: 9999;
    background: var(--primary); color: #fff;
    padding: 6px 12px; border-radius: var(--radius-sm);
    text-decoration: none; font-size: var(--fs-sm);
    transition: top 0.2s;
}
.skip-link:focus { top: 8px; color: #fff; }

.filter-input, .filter-select {
    height: 32px; padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: #fff;
    font-size: 13px;
    color: var(--text);
    margin: 0;
    min-width: 0;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.filter-input { width: 200px; }
.filter-select { width: 130px; padding-right: 24px; }
.filter-input:focus, .filter-select:focus {
    outline: none; border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(47,125,58,0.10);
}
[data-theme="dark"] .filter-input,
[data-theme="dark"] .filter-select { background: #2a2a27; border-color: var(--border); color: var(--text); }

/* 工具栏：分类 + 搜索 + 排序 一行 */
.tools-bar {
    display: flex; align-items: center; gap: 12px;
    flex-wrap: wrap;
    padding: 8px 0 12px;
    margin-bottom: 4px;
}
.tools-bar .cat-tabs { margin-bottom: 0; flex: 1 1 auto; min-width: 0; }
.tools-bar .filter-input,
.tools-bar .filter-select { flex: 0 0 auto; }
@media (max-width: 720px) {
    .tools-bar { gap: 8px; }
    .tools-bar .filter-input { width: 100%; flex: 1 1 100%; order: 99; }
}

/* 分类 Tab 栏 */
.cat-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 0;
}
.cat-tab {
    display: inline-block;
    padding: 4px 11px;
    font-size: 12.5px;
    color: var(--text-2);
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 14px;
    text-decoration: none;
    white-space: nowrap;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
    line-height: 1.5;
}
.cat-tab:hover {
    color: var(--primary);
    border-color: var(--primary);
    background: var(--primary-bg);
}
.cat-tab.active {
    color: var(--primary-fg);
    background: var(--primary);
    border-color: var(--primary);
    font-weight: 500;
}
[data-theme="dark"] .cat-tab { background: transparent; border-color: var(--border); }
[data-theme="dark"] .cat-tab:hover { background: var(--primary-bg); }
[data-theme="dark"] .cat-tab.active { background: var(--primary); border-color: var(--primary); color: var(--primary-fg); }

/* 作者筛选提示条 */
.author-filter-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 0 0 12px;
    padding: 6px 12px;
    background: var(--primary-bg);
    border-radius: 4px;
    border: 1px solid rgba(47,125,58,0.18);
    color: var(--text);
    font-size: 12.5px;
}
.author-filter-bar a { color: var(--primary); }

/* 作者名链接（卡片 + 详情页） */
a.book-author,
.byline a.author {
    color: var(--text-2);
    text-decoration: none;
    transition: color 0.15s;
}
a.book-author:hover,
.byline a.author:hover {
    color: var(--primary);
    text-decoration: underline;
}

/* 书籍卡片上的分类标签（贴在封面左下角） */
.cover-cat {
    position: absolute; left: 0; bottom: 0;
    display: inline-block;
    font-size: 11px;
    padding: 1px 7px;
    color: #fff;
    background: rgba(0,0,0,0.55);
    border-top-right-radius: 4px;
    font-weight: 500;
    letter-spacing: 0.02em;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}
[data-theme="dark"] .cover-cat { background: rgba(0,0,0,0.6); }
.cover-corner { position: absolute; top: 6px; right: 6px; }

/* chapter-list 嵌在 card 内时的内边距 */
.card > .chapter-list { padding: 4px 0; }
.card > .volume-group { padding: 0 0; }
.card > .volume-group:first-child { padding-top: 8px; }
.card > .volume-group:last-child { padding-bottom: 8px; }

/* history 行内主信息 */
.hist-main { flex: 1; min-width: 0; }
.hist-title {
    font-size: var(--fs-md); font-weight: 500; color: var(--text);
    margin-bottom: 4px; line-height: 1.4;
    display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical;
    overflow: hidden; text-overflow: ellipsis;
}
.hist-sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hist-time { white-space: nowrap; margin-left: 12px; }

/* 强制 admin 侧栏激活项更明显 */
.admin-side nav a.active { background: #2e2e2e; color: #fff; }

/* reader 正文：长段落两端对齐、首行缩进中文 */
.reader-body p { margin-bottom: 1em; }

/* 表格内行链接色 */
.table a, .table-wrap a { color: var(--link); }
.table a:hover, .table-wrap a:hover { color: var(--primary); }

/* nav 在小屏下允许横向滚动 */
@media (max-width: 600px) {
    .topbar-inner { gap: 16px; padding: 0 16px; }
    .nav { gap: 0; flex-wrap: wrap; }
    .nav a { padding: 6px 10px; font-size: var(--fs-sm); }
    .brand { font-size: 17px; }
    .reader-bar { padding: 0 16px; }
    .reader { padding: 32px 16px 60px; }
    .container { padding: 24px 16px 16px; }
    .container-narrow { padding: 24px 16px 16px; }
    .form-grid { grid-template-columns: 1fr; }
    .admin-main { padding: 20px 16px; }
    .book-detail { gap: 32px; }
    .book-detail h1 { font-size: 26px; }
    .page-hero { gap: 16px; }
    .page-hero h1 { font-size: 26px; }
    .page-hero .stats { gap: 18px; width: 100%; justify-content: flex-start; }
    .page-hero .stat { text-align: left; }
    .section { padding: 20px; }
}

/* 移动端 reader bar 的标题隐藏，避免挤 */
@media (max-width: 600px) {
    .reader-bar .title { display: none; }
    .reader-nav { flex-direction: column; gap: 8px; }
    .reader-nav a, .reader-nav span { flex-direction: row; gap: 8px; align-items: center; justify-content: center; min-height: 48px; font-size: 14px; }
    .reader-nav a.prev, .reader-nav a.next { align-items: center; }
    .reader-nav .nav-title { margin-bottom: 0; }
}
