:root {
    --ink: #17211c;
    --muted: #68736d;
    --line: #dfe5e1;
    --surface: #ffffff;
    --canvas: #f3f6f4;
    --brand: #176b4a;
    --brand-strong: #0f5138;
    --accent: #b86a18;
    --danger: #b43a32;
    --reader: #f7f1e5;
    --shadow: 0 12px 32px rgba(23, 33, 28, 0.08);
}

* { box-sizing: border-box; }
html { background: var(--canvas); }
body {
    min-height: 100vh;
    margin: 0;
    color: var(--ink);
    background: var(--canvas);
    font-family: "Noto Sans SC", "Microsoft YaHei", sans-serif;
    letter-spacing: 0;
}
body, button, input { font-size: 15px; }
a { color: inherit; }
img { display: block; max-width: 100%; }
button, input { font-family: inherit; }

.shell { width: min(1180px, 100%); margin: 0 auto; padding: 0 20px; }
.page-main { padding-top: 24px; padding-bottom: 40px; }
.app-bar {
    position: sticky;
    top: 0;
    z-index: 40;
    min-height: 64px;
    border-bottom: 1px solid rgba(223, 229, 225, 0.9);
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(14px);
}
.app-bar__inner { min-height: 64px; display: flex; align-items: center; gap: 14px; }
.app-bar__brand { min-width: 0; margin-right: auto; font-family: "Noto Serif SC", "STSong", serif; font-size: 21px; font-weight: 700; }
.app-bar__title { min-width: 0; flex: 1; overflow: hidden; text-align: center; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.icon-button { width: 42px; height: 42px; display: inline-grid; flex: 0 0 42px; place-items: center; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--ink); cursor: pointer; }
.icon-button .layui-icon { font-size: 20px; }
.search-bar { display: flex; width: min(520px, 100%); gap: 8px; }
.search-bar input { width: auto; min-width: 0; flex: 1; height: 42px; border: 1px solid var(--line); border-radius: 6px; padding: 0 14px; background: #f8faf9; outline: none; }
.search-bar input:focus { border-color: var(--brand); background: #fff; box-shadow: 0 0 0 3px rgba(23, 107, 74, 0.12); }
.primary-button, .secondary-button { min-height: 42px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; border-radius: 6px; padding: 0 18px; font-weight: 700; white-space: nowrap; cursor: pointer; }
.primary-button { border: 1px solid var(--brand); background: var(--brand); color: #fff; }
.primary-button:hover { background: var(--brand-strong); }
.secondary-button { border: 1px solid var(--line); background: #fff; color: var(--ink); }

.section { margin-top: 34px; }
.section:first-child { margin-top: 0; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.section-heading h2 { margin: 0; font-family: "Noto Serif SC", "STSong", serif; font-size: 23px; line-height: 1.25; }
.section-heading a { color: var(--brand); font-weight: 700; }
.section-kicker { display: block; margin-bottom: 5px; color: var(--accent); font-size: 12px; font-weight: 700; }
.feature-strip { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(150px, 190px); gap: 14px; overflow-x: auto; padding: 2px 2px 12px; scroll-snap-type: x mandatory; scrollbar-width: thin; }
.feature-book { scroll-snap-align: start; }
.feature-book__cover { aspect-ratio: 3 / 4; overflow: hidden; border-radius: 6px; background: #dce3df; box-shadow: var(--shadow); }
.feature-book__cover img { width: 100%; height: 100%; object-fit: cover; }
.feature-book__title { margin-top: 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }

.book-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.book-card { display: grid; grid-template-columns: 104px minmax(0, 1fr); gap: 14px; min-height: 150px; padding: 14px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
.book-card:hover { border-color: #b7c7bf; box-shadow: var(--shadow); }
.book-card__cover { width: 104px; aspect-ratio: 3 / 4; overflow: hidden; border-radius: 5px; background: #dce3df; }
.book-card__cover img { width: 100%; height: 100%; object-fit: cover; }
.book-card__body { min-width: 0; }
.book-card__title { margin: 2px 0 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: "Noto Serif SC", "STSong", serif; font-size: 18px; font-weight: 700; }
.book-card__meta { color: var(--muted); font-size: 13px; }
.book-card__desc { margin-top: 10px; overflow: hidden; color: var(--muted); line-height: 1.65; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; }
.update-list { overflow: hidden; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
.update-row { display: grid; grid-template-columns: minmax(0, 1fr) 120px; gap: 14px; align-items: center; min-height: 64px; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.update-row:last-child { border-bottom: 0; }
.update-row__title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.update-row__meta { color: var(--muted); font-size: 13px; }
.update-row__time { color: var(--muted); text-align: right; font-size: 13px; }

.library-page { min-height: calc(100vh - 136px); }
.library-heading { align-items: center; margin-bottom: 18px; }
.library-heading h1 { margin: 0; font-family: "Noto Serif SC", "STSong", serif; font-size: 28px; line-height: 1.25; }
.result-count { flex: 0 0 auto; border: 1px solid var(--line); border-radius: 4px; padding: 6px 10px; background: var(--surface); color: var(--muted); font-size: 13px; }
.library-search { width: min(640px, 100%); margin-bottom: 24px; }
.library-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.library-card { display: grid; grid-template-columns: 126px minmax(0, 1fr); gap: 18px; min-height: 196px; padding: 14px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
.library-card:hover { border-color: #b7c7bf; box-shadow: var(--shadow); }
.library-card__cover { width: 126px; aspect-ratio: 3 / 4; overflow: hidden; border-radius: 5px; background: #dce3df; }
.library-card__cover img { width: 100%; height: 100%; object-fit: cover; }
.library-card__body { min-width: 0; display: flex; flex-direction: column; }
.library-card__badges { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.library-card__badges span { border-radius: 4px; padding: 3px 7px; background: #edf3ef; color: var(--brand); font-size: 12px; }
.library-card h2 { margin: 0 0 5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: "Noto Serif SC", "STSong", serif; font-size: 20px; line-height: 1.35; }
.library-card__author { color: var(--muted); font-size: 13px; }
.library-card p { margin: 12px 0; overflow: hidden; color: #4d5953; line-height: 1.7; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.library-card__footer { display: flex; justify-content: space-between; gap: 12px; margin-top: auto; padding-top: 10px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.library-card__latest { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); }
.library-card__updated { margin-top: 5px; color: var(--muted); font-size: 12px; }
.library-state { grid-column: 1 / -1; min-height: 190px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 7px; border: 1px dashed #cbd5d0; border-radius: 6px; color: var(--muted); text-align: center; }
.library-state strong { color: var(--ink); font-size: 16px; }
.library-pagination { min-height: 32px; margin-top: 22px; text-align: center; }

.detail-layout { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 32px; padding: 26px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
.detail-cover { width: 100%; aspect-ratio: 3 / 4; overflow: hidden; border-radius: 6px; background: #dce3df; box-shadow: var(--shadow); }
.detail-cover img { width: 100%; height: 100%; object-fit: cover; }
.detail-title { margin: 2px 0 12px; font-family: "Noto Serif SC", "STSong", serif; font-size: clamp(28px, 4vw, 42px); line-height: 1.2; }
.meta-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 20px; }
.meta-chip { border: 1px solid var(--line); border-radius: 4px; padding: 5px 9px; color: var(--muted); background: #f8faf9; font-size: 13px; }
.detail-desc { max-width: 780px; color: #4d5953; line-height: 1.9; }
.action-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 24px; }
.chapter-panel { margin-top: 22px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
.chapter-panel__head { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.chapter-panel__head h2 { margin: 0; font-family: "Noto Serif SC", "STSong", serif; font-size: 20px; }
.chapter-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.chapter-link { min-height: 54px; display: flex; align-items: center; gap: 8px; padding: 10px 18px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); overflow: hidden; }
.chapter-link:nth-child(3n) { border-right: 0; }
.chapter-link__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chapter-link__vip { margin-left: auto; color: var(--accent); font-size: 12px; }

.reader-page { background: var(--reader); }
.reader-page[data-reader-theme="green"] { --reader: #eaf2e8; }
.reader-page[data-reader-theme="night"] { --reader: #1c211f; --ink: #d9dedb; --muted: #9ba59f; --line: #39413d; --surface: #252b28; --canvas: #1c211f; }
.reader-toolbar { position: sticky; top: 64px; z-index: 30; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--reader) 94%, transparent); backdrop-filter: blur(12px); }
.reader-toolbar__inner { min-height: 54px; display: flex; align-items: center; justify-content: center; gap: 8px; }
.tool-button { min-width: 42px; height: 36px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface); color: var(--ink); cursor: pointer; }
.reader-article { width: min(820px, calc(100% - 32px)); margin: 0 auto; padding: 46px 0 80px; }
.reader-article h1 { margin: 0 0 12px; font-family: "Noto Serif SC", "STSong", serif; font-size: clamp(26px, 5vw, 38px); line-height: 1.3; }
.reader-meta { margin-bottom: 34px; color: var(--muted); font-size: 13px; }
.reader-content { color: var(--ink); font-family: "Noto Serif SC", "STSong", serif; font-size: 20px; line-height: 2; }
.reader-content p { margin: 0 0 1em; text-indent: 2em; }
.paywall { padding: 32px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); text-align: center; }
.paywall h2 { margin: 0 0 12px; font-family: "Noto Serif SC", "STSong", serif; }
.paywall__price { margin: 18px 0; color: var(--danger); font-size: 18px; font-weight: 700; }
.reader-nav { width: min(820px, calc(100% - 32px)); display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; margin: 0 auto 40px; }
.reader-nav a { min-height: 46px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); font-weight: 700; }

.site-footer-spacer { height: 28px; }
.site-footer { min-height: 72px; display: flex; justify-content: center; gap: 36px; align-items: center; border-top: 1px solid var(--line); background: #fff; }
.site-footer__item { min-width: 64px; display: flex; align-items: center; justify-content: center; gap: 7px; color: var(--muted); }
.site-footer__item .layui-icon { font-size: 19px; }

@media (max-width: 900px) {
    .book-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .library-grid { grid-template-columns: 1fr; }
    .chapter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .chapter-link:nth-child(3n) { border-right: 1px solid var(--line); }
    .chapter-link:nth-child(2n) { border-right: 0; }
}

@media (max-width: 640px) {
    .shell { padding: 0 14px; }
    .page-main { padding-top: 16px; }
    .app-bar, .app-bar__inner { min-height: 56px; }
    .app-bar__brand { font-size: 18px; }
    .app-bar .search-bar { display: none; }
    .section { margin-top: 26px; }
    .section-heading h2 { font-size: 20px; }
    .feature-strip { grid-auto-columns: 128px; }
    .book-grid { grid-template-columns: 1fr; }
    .book-card { grid-template-columns: 88px minmax(0, 1fr); min-height: 132px; padding: 12px; }
    .book-card__cover { width: 88px; }
    .book-card__desc { -webkit-line-clamp: 2; }
    .update-row { grid-template-columns: minmax(0, 1fr) 76px; padding: 10px 12px; }
    .library-heading { align-items: end; }
    .library-heading h1 { font-size: 23px; }
    .library-search { margin-bottom: 18px; }
    .library-card { grid-template-columns: 92px minmax(0, 1fr); gap: 13px; min-height: 150px; padding: 12px; }
    .library-card__cover { width: 92px; }
    .library-card h2 { font-size: 18px; }
    .library-card p { margin: 8px 0; -webkit-line-clamp: 2; line-height: 1.6; }
    .library-card__footer { padding-top: 8px; }
    .library-card__updated { display: none; }
    .detail-layout { grid-template-columns: 108px minmax(0, 1fr); gap: 16px; padding: 16px; }
    .detail-title { margin-top: 0; font-size: 25px; }
    .detail-desc, .action-row { grid-column: 1 / -1; }
    .action-row { margin-top: 2px; }
    .action-row > * { flex: 1; }
    .chapter-grid { grid-template-columns: 1fr; }
    .chapter-link, .chapter-link:nth-child(2n), .chapter-link:nth-child(3n) { border-right: 0; }
    .reader-toolbar { top: 56px; }
    .reader-toolbar__inner { justify-content: flex-start; overflow-x: auto; }
    .reader-article { width: min(100% - 28px, 820px); padding-top: 30px; }
    .reader-content { font-size: 18px; line-height: 1.9; }
    .site-footer-spacer { height: 78px; }
    .site-footer { position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; min-height: 62px; justify-content: space-around; gap: 0; box-shadow: 0 -8px 24px rgba(23, 33, 28, 0.08); }
    .site-footer__item { flex-direction: column; gap: 1px; font-size: 11px; }
}

/* Taxonomy-first library layout. */
body {
    background:
        radial-gradient(circle at 100% 0, rgba(184, 106, 24, 0.09), transparent 28rem),
        linear-gradient(180deg, #f7faf8 0, var(--canvas) 42rem);
}
.app-bar {
    box-shadow: 0 8px 28px rgba(23, 33, 28, 0.05);
}
.icon-button,
.primary-button,
.secondary-button,
.result-count,
.taxonomy-panel,
.library-card,
.detail-layout,
.chapter-panel {
    border-radius: 12px;
}
.primary-button { box-shadow: 0 7px 16px rgba(23, 107, 74, 0.18); }
.home-taxonomy { margin-top: 24px; }
.home-taxonomy__list { display: flex; flex-wrap: wrap; gap: 9px; }
.home-taxonomy__list a {
    display: inline-flex;
    min-height: 38px;
    align-items: center;
    border: 1px solid #d8e5dc;
    border-radius: 999px;
    padding: 0 15px;
    background: rgba(255, 255, 255, 0.82);
    color: var(--brand);
    font-weight: 700;
}
.home-taxonomy__list a:hover { border-color: var(--brand); background: #eaf3ed; }
.library-hero {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 18px;
    padding: 24px;
    border: 1px solid #dbe7df;
    border-radius: 18px;
    background:
        linear-gradient(135deg, rgba(23, 107, 74, 0.97), rgba(15, 81, 56, 0.93)),
        #176b4a;
    color: #fff;
    box-shadow: 0 18px 40px rgba(23, 107, 74, 0.16);
}
.library-hero .section-kicker { color: #f5c27f; }
.library-hero h1 {
    max-width: 620px;
    margin: 0;
    font-family: "Noto Serif SC", "STSong", serif;
    font-size: clamp(25px, 6vw, 38px);
    line-height: 1.25;
}
.library-hero p { margin: 10px 0 0; color: rgba(255, 255, 255, 0.74); }
.library-hero .result-count { border-color: rgba(255, 255, 255, 0.2); background: rgba(255, 255, 255, 0.12); color: #fff; }
.library-search {
    position: relative;
    width: 100%;
    margin: 18px 0;
}
.search-bar__icon {
    position: absolute;
    z-index: 1;
    top: 13px;
    left: 14px;
    color: var(--muted);
}
.library-search input { padding-left: 42px; border-radius: 12px; background: #fff; }
.library-search .primary-button { min-width: 88px; }
.taxonomy-panel {
    margin-bottom: 18px;
    padding: 7px 16px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 8px 24px rgba(23, 33, 28, 0.05);
}
.taxonomy-row {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 13px 0;
    border-bottom: 1px solid #edf1ee;
}
.taxonomy-row:last-child { border-bottom: 0; }
.taxonomy-row strong { width: 42px; flex: 0 0 42px; padding-top: 7px; color: var(--ink); }
.filter-chips { display: flex; flex-wrap: wrap; gap: 7px; }
.filter-chip {
    min-height: 32px;
    border: 1px solid transparent;
    border-radius: 999px;
    padding: 0 12px;
    background: #f1f5f2;
    color: var(--muted);
    cursor: pointer;
}
.filter-chip:hover { color: var(--brand); background: #e8f1eb; }
.filter-chip.is-active { border-color: var(--brand); background: var(--brand); color: #fff; }
.taxonomy-row--compact { align-items: center; }
.taxonomy-row--compact strong { padding-top: 0; }
.clear-filters {
    min-height: 32px;
    margin-left: auto;
    border: 0;
    background: transparent;
    color: var(--danger);
    cursor: pointer;
}
.active-filters { display: flex; flex-wrap: wrap; gap: 7px; min-height: 0; margin: -4px 0 14px; }
.active-filters:empty { display: none; }
.active-filters span {
    border-radius: 999px;
    padding: 5px 10px;
    background: #fff2e2;
    color: #955313;
    font-size: 12px;
}
.detail-taxonomy { display: flex; align-items: center; gap: 8px; }
.detail-taxonomy .section-kicker { margin-bottom: 0; }
.detail-taxonomy__category {
    border-radius: 999px;
    padding: 4px 9px;
    background: #fff1df;
    color: #985d1a;
    font-size: 12px;
}
.detail-tags { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 6px; }
.detail-tags a {
    border-radius: 999px;
    padding: 4px 9px;
    background: #edf3ef;
    color: var(--brand);
    font-size: 12px;
}
.library-card {
    border-color: #dbe5de;
    box-shadow: 0 8px 22px rgba(23, 33, 28, 0.04);
    transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}
.library-card:hover { transform: translateY(-2px); }
.library-card__cover { border-radius: 9px; }
.library-card__badges { min-height: 25px; }
.book-label {
    border-radius: 999px;
    padding: 4px 8px;
    background: #edf3ef;
    color: var(--brand);
    font-size: 11px;
}
.book-label--module { background: #e6f0ea; color: #0f5138; font-weight: 700; }
.book-label--tag { background: #fff1df; color: #985d1a; }

@media (max-width: 640px) {
    .library-hero { align-items: flex-start; padding: 20px 16px; }
    .library-hero .result-count { margin-top: 2px; }
    .taxonomy-panel { margin-right: -2px; margin-left: -2px; padding: 5px 13px; }
    .taxonomy-row { gap: 10px; }
    .taxonomy-row strong { width: 34px; flex-basis: 34px; }
    .filter-chips { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
    .filter-chips::-webkit-scrollbar { display: none; }
    .filter-chip { flex: 0 0 auto; }
    .clear-filters { padding: 0; }
}
