@font-face {
    font-family: 'HuWenMingChao';
    src: url('https://mx.bdfz.net/data/fonts/HuWenMingChaoTi.woff2') format('woff2');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

:root {
    --monet-bg: #f4efe2;
    --monet-bg-soft: #fbf7ec;
    --monet-text: #3d4d56;
    --monet-text-light: #7a8a92;
    --monet-water: #7ba398;
    --monet-water-deep: #547f74;
    --monet-water-light: #b6cfc6;
    --monet-lily: #d8b4c4;
    --monet-petal: #efc9c0;
    --monet-sun: #ecca82;
    --monet-sky: #b9cee0;
    --monet-mauve: #b3a4c4;
    --monet-leaf: #c1d4ad;
    --monet-border: rgba(122, 138, 146, 0.26);
    --monet-border-soft: rgba(122, 138, 146, 0.16);
    --monet-panel: rgba(255, 253, 247, 0.72);
    --monet-panel-strong: rgba(255, 253, 247, 0.88);
    --monet-shadow: 0 22px 60px rgba(60, 88, 96, 0.16);
    --monet-shadow-soft: 0 10px 28px rgba(60, 88, 96, 0.10);
    --monet-glow: 0 0 0 4px rgba(123, 163, 152, 0.18);
    --font-main: 'HuWenMingChao', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--monet-text);
    font-family: var(--font-main);
    line-height: 1.65;
    background:
        radial-gradient(1200px 800px at 12% 14%, rgba(216, 180, 196, 0.34), transparent 62%),
        radial-gradient(1100px 720px at 86% 22%, rgba(185, 206, 224, 0.40), transparent 60%),
        radial-gradient(900px 700px at 28% 88%, rgba(193, 212, 173, 0.38), transparent 60%),
        radial-gradient(820px 620px at 78% 92%, rgba(236, 202, 130, 0.30), transparent 62%),
        linear-gradient(rgba(244, 239, 226, 0.78), rgba(244, 239, 226, 0.86)),
        url('background.jpg');
    background-size: auto, auto, auto, auto, auto, cover;
    background-position: center;
    background-attachment: fixed;
    background-blend-mode: screen, screen, screen, screen, normal, normal;
}

body.image-zoomed {
    overflow: hidden;
}

button,
input,
select {
    font: inherit;
}

button {
    border: 1px solid var(--monet-border);
    color: var(--monet-text);
    background: linear-gradient(180deg, rgba(255, 253, 247, 0.94), rgba(247, 240, 228, 0.86));
    border-radius: 10px;
    cursor: pointer;
    transition: transform 180ms ease, border-color 180ms ease, background 220ms ease, box-shadow 180ms ease;
}

button:hover {
    transform: translateY(-1px);
    border-color: rgba(84, 127, 116, 0.55);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(214, 230, 222, 0.78));
    box-shadow: var(--monet-shadow-soft);
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

input,
select {
    width: 100%;
    border: 1px solid var(--monet-border);
    border-radius: 10px;
    color: var(--monet-text);
    background: rgba(255, 253, 247, 0.85);
    outline: none;
    transition: border-color 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

input:focus,
select:focus {
    border-color: var(--monet-water);
    background: rgba(255, 255, 255, 0.96);
    box-shadow: var(--monet-glow);
}

.shell {
    display: grid;
    grid-template-columns: minmax(310px, 380px) 1fr;
    min-height: 100vh;
    transition: grid-template-columns 180ms ease;
}

.shell.sidebar-collapsed {
    grid-template-columns: 0 1fr;
}

.sidebar {
    height: 100vh;
    position: sticky;
    top: 0;
    display: grid;
    grid-template-rows: auto auto 1fr;
    gap: 18px;
    padding: 24px;
    border-right: 1px solid var(--monet-border);
    background:
        linear-gradient(180deg, rgba(255, 253, 247, 0.78), rgba(244, 239, 226, 0.66)),
        radial-gradient(420px 320px at 50% -10%, rgba(216, 180, 196, 0.28), transparent 70%);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    overflow: hidden;
    transition: opacity 180ms ease, padding 180ms ease, transform 180ms ease;
}

.shell.sidebar-collapsed .sidebar {
    padding-right: 0;
    padding-left: 0;
    transform: translateX(-100%);
    opacity: 0;
    pointer-events: none;
    border-right: 0;
}

.brand {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.brand-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.sidebar-toggle,
.sidebar-restore {
    min-height: 34px;
    padding: 6px 12px;
    white-space: nowrap;
    font-size: 0.92rem;
}

.sidebar-restore {
    position: fixed;
    top: 14px;
    left: 14px;
    z-index: 30;
    display: none;
    box-shadow: var(--monet-shadow);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(214, 230, 222, 0.86));
}

.shell.sidebar-collapsed .sidebar-restore {
    display: inline-flex;
    align-items: center;
}

.home-link {
    color: var(--monet-water-deep);
    font-size: 2rem;
    line-height: 1;
    text-decoration: none;
    letter-spacing: 0.04em;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.6);
}

.home-link:hover {
    color: var(--monet-water);
}

#sync-status,
#book-count,
#result-count {
    color: var(--monet-text-light);
    font-size: 0.9rem;
    white-space: nowrap;
}

.search-panel,
.book-section,
.results-panel,
.reader-panel {
    border: 1px solid var(--monet-border);
    border-radius: 14px;
    background: var(--monet-panel);
    box-shadow: var(--monet-shadow);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.search-panel {
    padding: 16px;
    background:
        linear-gradient(180deg, rgba(255, 253, 247, 0.82), rgba(247, 240, 228, 0.66)),
        radial-gradient(220px 160px at 100% 0%, rgba(185, 206, 224, 0.32), transparent 75%);
}

.field-label,
.eyebrow {
    display: block;
    color: var(--monet-water-deep);
    font-size: 0.84rem;
    letter-spacing: 0.02em;
}

.search-box {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    margin-top: 8px;
}

.search-box input {
    min-width: 0;
    padding: 10px 12px;
}

.search-box button,
.reader-actions button {
    padding: 10px 14px;
}

.search-box button {
    background: linear-gradient(180deg, rgba(123, 163, 152, 0.88), rgba(84, 127, 116, 0.92));
    color: #fbf7ec;
    border-color: rgba(84, 127, 116, 0.55);
}

.search-box button:hover {
    background: linear-gradient(180deg, rgba(140, 178, 167, 0.95), rgba(98, 142, 130, 0.98));
    color: #ffffff;
}

.filter-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 10px;
}

.filter-grid select {
    padding: 9px 10px;
}

.book-section {
    min-height: 0;
    display: grid;
    grid-template-rows: auto 1fr;
    overflow: hidden;
    background:
        linear-gradient(180deg, rgba(255, 253, 247, 0.78), rgba(247, 240, 228, 0.6)),
        radial-gradient(280px 200px at 0% 100%, rgba(193, 212, 173, 0.32), transparent 75%);
}

.section-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--monet-border-soft);
}

.section-head h2 {
    margin: 0;
    color: var(--monet-water-deep);
    font-size: 1.22rem;
    font-weight: normal;
    letter-spacing: 0.02em;
}

.book-list {
    min-height: 0;
    overflow: auto;
    padding: 10px;
    scrollbar-color: rgba(123, 163, 152, 0.5) transparent;
    scrollbar-width: thin;
}

.book-list::-webkit-scrollbar,
.results::-webkit-scrollbar,
.page-nav::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.book-list::-webkit-scrollbar-thumb,
.results::-webkit-scrollbar-thumb,
.page-nav::-webkit-scrollbar-thumb {
    background: rgba(123, 163, 152, 0.45);
    border-radius: 8px;
}

.book-item {
    width: 100%;
    display: grid;
    grid-template-columns: 52px 1fr;
    gap: 10px;
    margin-bottom: 8px;
    padding: 8px;
    text-align: left;
    border-radius: 10px;
    background: linear-gradient(180deg, rgba(255, 253, 247, 0.78), rgba(247, 240, 228, 0.5));
}

.book-item:hover {
    background: linear-gradient(180deg, rgba(255, 253, 247, 0.95), rgba(220, 234, 226, 0.78));
}

.book-item.active {
    border-color: var(--monet-water);
    background: linear-gradient(180deg, rgba(218, 234, 226, 0.95), rgba(193, 212, 173, 0.55));
    box-shadow: inset 0 0 0 1px rgba(84, 127, 116, 0.25);
}

.book-cover {
    width: 52px;
    aspect-ratio: 3 / 4;
    border-radius: 6px;
    object-fit: cover;
    background: var(--monet-water-light);
    box-shadow: 0 4px 12px rgba(60, 88, 96, 0.15);
}

.book-name {
    display: block;
    color: var(--monet-text);
    line-height: 1.4;
}

.book-detail {
    display: block;
    margin-top: 4px;
    color: var(--monet-text-light);
    font-size: 0.84rem;
}

.reader {
    min-width: 0;
    padding: 28px;
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.hidden {
    display: none !important;
}

.reader-panel {
    overflow: hidden;
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    background:
        linear-gradient(180deg, rgba(255, 253, 247, 0.78), rgba(247, 240, 228, 0.62)),
        radial-gradient(520px 320px at 100% 0%, rgba(216, 180, 196, 0.20), transparent 70%),
        radial-gradient(420px 320px at 0% 100%, rgba(185, 206, 224, 0.22), transparent 75%);
}

.reader-top {
    flex: 0 0 auto;
}

.results-panel {
    border: 0;
    border-bottom: 1px solid var(--monet-border-soft);
    border-radius: 0;
    box-shadow: none;
    background: linear-gradient(180deg, rgba(247, 240, 228, 0.5), transparent);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

.results {
    display: grid;
    gap: 8px;
    max-height: 30vh;
    overflow: auto;
    padding: 10px 14px 14px;
}

.result-item {
    display: grid;
    grid-template-columns: 56px 1fr;
    gap: 10px;
    width: 100%;
    padding: 8px;
    text-align: left;
    border-radius: 10px;
    background: linear-gradient(180deg, rgba(255, 253, 247, 0.82), rgba(247, 240, 228, 0.55));
}

.result-item:hover {
    background: linear-gradient(180deg, rgba(255, 253, 247, 0.96), rgba(220, 234, 226, 0.78));
}

.result-thumb {
    width: 56px;
    aspect-ratio: 3 / 4;
    border-radius: 6px;
    object-fit: cover;
    background: var(--monet-water-light);
    box-shadow: 0 3px 10px rgba(60, 88, 96, 0.14);
}

.result-title {
    color: var(--monet-water-deep);
}

.result-meta,
.result-snippet {
    color: var(--monet-text-light);
    font-size: 0.9rem;
}

mark {
    color: #6e4a1f;
    background: linear-gradient(180deg, rgba(236, 202, 130, 0.85), rgba(239, 201, 192, 0.78));
    border-radius: 4px;
    padding: 0 3px;
}

.reader-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 22px;
    border-bottom: 1px solid var(--monet-border-soft);
    background: linear-gradient(180deg, rgba(255, 253, 247, 0.6), transparent);
}

.reader-top h2 {
    margin: 4px 0 0;
    color: var(--monet-water-deep);
    font-size: 1.5rem;
    font-weight: normal;
    letter-spacing: 0.02em;
}

.reader-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

#page-indicator {
    min-width: 124px;
    text-align: center;
    color: var(--monet-text-light);
    font-variant-numeric: tabular-nums;
}

.jump-form {
    display: grid;
    grid-template-columns: minmax(116px, 140px) auto;
    gap: 8px;
}

.jump-form input {
    min-width: 0;
    padding: 9px 10px;
}

.jump-form button {
    padding: 9px 12px;
}

.reader-layout {
    display: grid;
    grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
    flex: 1 1 auto;
    min-height: 0;
}

.page-nav {
    border-right: 1px solid var(--monet-border-soft);
    background: linear-gradient(180deg, rgba(255, 253, 247, 0.45), rgba(218, 230, 222, 0.30));
    overflow: auto;
    min-height: 0;
    scrollbar-color: rgba(123, 163, 152, 0.5) transparent;
    scrollbar-width: thin;
}

.toc-list {
    display: grid;
    gap: 6px;
    padding: 12px;
    border-bottom: 1px solid var(--monet-border-soft);
}

.toc-link {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    align-items: baseline;
    padding: 8px 10px;
    text-align: left;
    color: var(--monet-text);
    background: linear-gradient(180deg, rgba(255, 253, 247, 0.7), rgba(247, 240, 228, 0.45));
    border-radius: 8px;
}

.toc-link:hover {
    background: linear-gradient(180deg, rgba(255, 253, 247, 0.95), rgba(220, 234, 226, 0.78));
}

.toc-link.level-1 {
    color: var(--monet-water-deep);
    background: linear-gradient(180deg, rgba(218, 234, 226, 0.85), rgba(193, 212, 173, 0.45));
    font-size: 1.02rem;
}

.toc-link.level-2 {
    padding-left: 22px;
}

.toc-link.current {
    border-color: var(--monet-water);
    background: linear-gradient(180deg, rgba(216, 180, 196, 0.45), rgba(185, 206, 224, 0.45));
    box-shadow: inset 0 0 0 1px rgba(84, 127, 116, 0.25);
}

.toc-title {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.toc-page {
    color: var(--monet-text-light);
    font-size: 0.78rem;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.page-grid-details {
    padding: 10px 12px 14px;
}

.page-grid-details summary {
    cursor: pointer;
    color: var(--monet-water-deep);
    font-size: 0.95rem;
    padding: 6px 4px;
    list-style: none;
    user-select: none;
}

.page-grid-details summary::-webkit-details-marker {
    display: none;
}

.page-grid-details summary::before {
    content: '▸';
    display: inline-block;
    margin-right: 6px;
    transition: transform 180ms ease;
    color: var(--monet-water);
}

.page-grid-details[open] summary::before {
    transform: rotate(90deg);
}

.page-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(46px, 1fr));
    gap: 6px;
    padding-top: 10px;
}

.page-button {
    min-height: 38px;
    padding: 6px 4px;
    color: var(--monet-text-light);
    font-variant-numeric: tabular-nums;
    font-size: 0.88rem;
}

.page-button.current {
    color: #fbf7ec;
    border-color: var(--monet-water-deep);
    background: linear-gradient(180deg, var(--monet-water), var(--monet-water-deep));
    box-shadow: 0 4px 12px rgba(84, 127, 116, 0.35);
}

.page-frame {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin: 0;
    padding: 18px;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
}

#page-image {
    max-width: 100%;
    max-height: 100%;
    min-height: 0;
    object-fit: contain;
    border-radius: 10px;
    background: white;
    box-shadow: 0 22px 70px rgba(60, 88, 96, 0.22), 0 0 0 1px rgba(122, 138, 146, 0.12);
    cursor: zoom-in;
    transition: transform 220ms ease, box-shadow 220ms ease;
}

#page-image:hover {
    transform: translateY(-2px);
    box-shadow: 0 28px 84px rgba(60, 88, 96, 0.28), 0 0 0 1px rgba(122, 138, 146, 0.16);
}

#page-caption {
    color: var(--monet-text-light);
    font-size: 0.92rem;
    letter-spacing: 0.02em;
}

.image-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: grid;
    place-items: center;
    padding: 24px;
    cursor: zoom-out;
    background:
        radial-gradient(900px 700px at 18% 22%, rgba(216, 180, 196, 0.40), transparent 60%),
        radial-gradient(900px 700px at 82% 78%, rgba(123, 163, 152, 0.42), transparent 62%),
        radial-gradient(700px 540px at 50% 50%, rgba(185, 206, 224, 0.30), transparent 70%),
        rgba(40, 56, 60, 0.62);
    backdrop-filter: blur(18px) saturate(120%);
    -webkit-backdrop-filter: blur(18px) saturate(120%);
    animation: monet-fade-in 220ms ease both;
}

.image-overlay img {
    max-width: 96vw;
    max-height: 92vh;
    object-fit: contain;
    border-radius: 12px;
    background: white;
    box-shadow: 0 36px 110px rgba(40, 56, 60, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.18);
    cursor: zoom-out;
    animation: monet-zoom-in 280ms cubic-bezier(0.22, 0.9, 0.32, 1) both;
}

.image-overlay-caption {
    position: fixed;
    bottom: 22px;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255, 253, 247, 0.92);
    font-size: 0.92rem;
    letter-spacing: 0.04em;
    text-shadow: 0 1px 6px rgba(0, 0, 0, 0.4);
    pointer-events: none;
}

.image-overlay-close {
    position: fixed;
    top: 18px;
    right: 18px;
    width: 40px;
    height: 40px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.35);
    color: rgba(255, 253, 247, 0.94);
    background: rgba(40, 56, 60, 0.45);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    display: grid;
    place-items: center;
    transition: background 180ms ease, transform 180ms ease;
}

.image-overlay-close:hover {
    background: rgba(40, 56, 60, 0.7);
    transform: scale(1.05);
    color: #ffffff;
}

.image-overlay-nav {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    width: 56px;
    height: 56px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.32);
    color: rgba(255, 253, 247, 0.94);
    background: rgba(40, 56, 60, 0.45);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    font-size: 2rem;
    line-height: 1;
    cursor: pointer;
    display: grid;
    place-items: center;
    transition: background 180ms ease, transform 180ms ease, opacity 180ms ease;
    z-index: 210;
}

.image-overlay-prev {
    left: 24px;
}

.image-overlay-next {
    right: 24px;
}

.image-overlay-nav:hover:not(:disabled) {
    background: rgba(40, 56, 60, 0.72);
    transform: translateY(-50%) scale(1.06);
    color: #ffffff;
}

.image-overlay-nav:disabled {
    opacity: 0.32;
    cursor: not-allowed;
}

@keyframes monet-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes monet-zoom-in {
    from {
        opacity: 0;
        transform: scale(0.92);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@media (max-width: 900px) {
    body {
        background-attachment: scroll;
    }

    .shell {
        display: block;
    }

    .shell.sidebar-collapsed .sidebar {
        display: none;
    }

    .sidebar {
        position: static;
        height: auto;
        max-height: none;
        border-right: none;
        border-bottom: 1px solid var(--monet-border);
        overflow: visible;
    }

    .brand {
        align-items: flex-start;
    }

    .brand-actions {
        flex-wrap: wrap;
        justify-content: flex-end;
    }

    .book-list {
        max-height: 44vh;
    }

    .reader {
        padding: 10px;
        height: auto;
        overflow: visible;
        display: block;
    }

    .reader-panel {
        display: block;
        flex: none;
    }

    .page-frame {
        display: grid;
        place-items: center;
        overflow: visible;
        min-height: 0;
    }

    #page-image {
        width: 100%;
        max-width: 100%;
        max-height: none;
    }

    .reader-top {
        display: block;
        padding: 14px 16px;
    }

    .reader-actions {
        margin-top: 12px;
        justify-content: stretch;
    }

    .reader-actions > button {
        min-width: 44px;
    }

    #page-indicator {
        flex: 1 1 112px;
        min-width: 112px;
    }

    .jump-form {
        flex: 1 1 100%;
        grid-template-columns: minmax(0, 1fr) auto;
    }

    .reader-layout {
        grid-template-columns: 1fr;
        min-height: 0;
    }

    .page-nav {
        border-right: none;
        border-bottom: 1px solid var(--monet-border-soft);
        max-height: 38vh;
    }
}

@media (max-width: 520px) {
    .sidebar {
        padding: 16px 12px;
    }

    .home-link {
        font-size: 1.65rem;
    }

    .filter-grid {
        grid-template-columns: 1fr;
    }

    .book-item {
        grid-template-columns: 44px 1fr;
    }

    .book-cover {
        width: 44px;
    }

    .reader-top h2 {
        font-size: 1.18rem;
        line-height: 1.35;
    }

    .toc-link {
        grid-template-columns: 1fr;
        gap: 2px;
    }

    .toc-title {
        white-space: normal;
    }

    .result-item {
        grid-template-columns: 1fr;
    }

    .result-thumb {
        display: none;
    }

    .page-frame {
        padding: 10px 0;
    }

    .image-overlay-close {
        top: 12px;
        right: 12px;
    }

    .image-overlay-nav {
        width: 44px;
        height: 44px;
        font-size: 1.6rem;
    }

    .image-overlay-prev {
        left: 10px;
    }

    .image-overlay-next {
        right: 10px;
    }
}
