:root {
    --bg: #faf7f2;
    --bg-card: #ffffff;
    --bg-sidebar: #f0ece4;
    --bg-header: #1c130a;
    --text: #1c1c1c;
    --text-muted: #706a60;
    --accent: #7a4f1d;
    --accent-hover: #9b6325;
    --accent-light: #f0e8d8;
    --border: #ddd8cf;
    --sidebar-width: 260px;
    --reading-width: 680px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: Georgia, 'Times New Roman', serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.8;
}

/* ---- SITE HEADER / BREADCRUMB ---- */
.site-header {
    background: var(--bg-header);
    padding: 13px 24px;
    display: flex;
    align-items: center;
}
.breadcrumb {
    font-size: 0.85em;
    color: #9a8878;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
}
.breadcrumb a { color: #c8a96e; text-decoration: none; }
.breadcrumb a:hover { color: #e8cc96; text-decoration: underline; }
.breadcrumb .sep { color: #5a4a3a; }
.breadcrumb .current { color: #b09878; }

/* ---- LIBRARY PAGE ---- */
.library-wrap {
    max-width: 1200px;
    margin: 0 auto;
}
.library-hero {
    padding: 48px 40px 28px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 20px;
}
.library-hero h1 {
    font-size: 2em;
    font-weight: normal;
    color: var(--text);
    letter-spacing: -0.01em;
}
.search-box {
    padding: 9px 16px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-family: inherit;
    font-size: 0.95em;
    background: white;
    color: var(--text);
    width: 280px;
}
.search-box:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-light); }
.book-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
    padding: 28px 40px 48px;
}
.book-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 20px 18px;
    text-decoration: none;
    display: block;
    transition: box-shadow 0.15s, border-color 0.15s, transform 0.1s;
}
.book-card:hover {
    box-shadow: 0 4px 14px rgba(0,0,0,0.09);
    border-color: var(--accent);
    transform: translateY(-1px);
}
.book-card .card-title {
    display: block;
    font-size: 0.95em;
    color: var(--accent);
    font-weight: bold;
    line-height: 1.4;
    margin-bottom: 8px;
}
.book-card .card-author {
    display: block;
    font-size: 0.82em;
    color: var(--text-muted);
    font-style: italic;
}
.book-card.hidden { display: none; }
.library-footer {
    padding: 0 40px 40px;
    color: var(--text-muted);
    font-size: 0.88em;
}

/* ---- BOOK INDEX PAGE ---- */
.book-index-wrap {
    max-width: 720px;
    margin: 0 auto;
    padding: 44px 40px 64px;
}
.book-index-wrap h1 {
    font-size: 2em;
    font-weight: normal;
    line-height: 1.3;
    margin-bottom: 6px;
}
.book-index-author {
    color: var(--text-muted);
    font-style: italic;
    font-size: 1.05em;
    margin-bottom: 36px;
}
.toc-heading {
    font-size: 0.75em;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-muted);
    font-weight: normal;
    margin-bottom: 12px;
    font-family: Arial, Helvetica, sans-serif;
}
.toc-list {
    list-style: none;
    border-top: 1px solid var(--border);
    margin-bottom: 36px;
}
.toc-list li { border-bottom: 1px solid var(--border); }
.toc-list a {
    display: block;
    padding: 11px 4px;
    color: var(--text);
    text-decoration: none;
    font-size: 0.95em;
    transition: color 0.12s, padding-left 0.12s;
}
.toc-list a:hover { color: var(--accent); padding-left: 6px; }
.toc-list li.depth-0 > a { font-weight: bold; }
.toc-list li.depth-1 > a { padding-left: 20px; color: var(--text-muted); }
.toc-list li.depth-2 > a { padding-left: 40px; color: var(--text-muted); }
.toc-list li.depth-1 > a:hover,
.toc-list li.depth-2 > a:hover { color: var(--accent); }

.btn-start {
    display: inline-block;
    padding: 11px 28px;
    background: var(--accent);
    color: white;
    text-decoration: none;
    border-radius: 4px;
    font-size: 0.95em;
    transition: background 0.15s;
}
.btn-start:hover { background: var(--accent-hover); }

/* ---- CHAPTER PAGE ---- */
.sidebar-toggle {
    display: none;
    width: 100%;
    background: var(--bg-header);
    color: #c8a96e;
    border: none;
    padding: 11px 20px;
    text-align: left;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.9em;
}
.chapter-layout {
    display: flex;
    min-height: calc(100vh - 48px);
}
.sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    padding: 20px 0 40px;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}
.sidebar-book-title {
    padding: 4px 18px 16px;
    font-size: 0.88em;
    font-weight: bold;
    line-height: 1.4;
    color: var(--text);
    border-bottom: 1px solid var(--border);
    margin-bottom: 8px;
}
.sidebar-book-title a { color: var(--accent); text-decoration: none; }
.sidebar-book-title a:hover { text-decoration: underline; }
.sidebar-toc { list-style: none; }
.sidebar-toc li a {
    display: block;
    padding: 6px 18px;
    font-size: 0.83em;
    color: var(--text-muted);
    text-decoration: none;
    line-height: 1.45;
    transition: background 0.1s, color 0.1s;
}
.sidebar-toc li a:hover { background: rgba(0,0,0,0.06); color: var(--text); }
.sidebar-toc li.current > a {
    background: var(--accent);
    color: white;
}
.sidebar-toc li.depth-1 > a { padding-left: 30px; }
.sidebar-toc li.depth-2 > a { padding-left: 42px; }

.chapter-main {
    flex: 1;
    min-width: 0;
    padding: 44px 52px 64px;
}
.chapter-content { max-width: var(--reading-width); }
.chapter-content h1 {
    font-size: 1.75em;
    font-weight: normal;
    line-height: 1.3;
    margin-bottom: 32px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}
.body p {
    margin-bottom: 1.35em;
    text-align: justify;
}
.body br { display: none; }

/* essay / section title beneath the chapter heading */
.body .section-title {
    font-size: 1.3em;
    font-weight: normal;
    font-style: italic;
    color: var(--accent);
    text-align: center;
    margin: 0 0 1.6em;
}
/* author byline & signature */
.body .byline {
    text-align: center;
    font-style: italic;
    color: var(--text-muted);
}
.body .signature {
    text-align: right;
    font-style: italic;
    color: var(--text-muted);
    margin-top: 1.6em;
}
.body .the-end {
    text-align: center;
    letter-spacing: 0.2em;
    color: var(--text-muted);
    margin-top: 2.4em;
}
/* section subheading within a chapter (small all-caps cross-head) */
.body .subhead {
    font-size: 0.95em;
    font-weight: bold;
    letter-spacing: 0.08em;
    text-align: center;
    color: var(--accent);
    margin: 2.2em 0 1.2em;
}
.body .subhead:first-child { margin-top: 0; }
/* verse / poetry blocks — preserve line breaks */
.body .verse {
    margin: 1.8em 0 1.8em 1.6em;
    padding-left: 1.2em;
    border-left: 3px solid var(--border);
    font-style: italic;
    color: var(--text-muted);
    white-space: pre-line;
    text-align: left;
}
/* prose quotation (e.g. a dictionary definition) */
.body blockquote {
    margin: 1.6em 0 1.6em 1.6em;
    padding-left: 1.2em;
    border-left: 3px solid var(--border);
    color: var(--text-muted);
    font-style: italic;
}
.body blockquote p { margin-bottom: 0; }
/* attribution / citation line beneath a quote or verse */
.body .citation {
    text-align: right;
    font-style: italic;
    color: var(--text-muted);
    margin-top: -0.6em;
    margin-bottom: 1.6em;
}
/* diary-style dateline at the head of a chapter */
.body .dateline {
    font-style: italic;
    color: var(--text-muted);
    margin-bottom: 1.6em;
}
/* an inscription / sign quoted in the text (e.g. words painted on a rock) */
.body .inscription {
    text-align: center;
    letter-spacing: 0.12em;
    font-weight: bold;
    color: var(--accent);
    margin: 1.6em 0;
}
/* asterism / scene break between sections */
.body .scene-break {
    border: none;
    text-align: center;
    margin: 2em 0;
    color: var(--text-muted);
}
.body .scene-break::before {
    content: "* * *";
    letter-spacing: 0.5em;
}
/* lists within the reading body */
.body ul, .body ol {
    margin: 1.2em 0 1.4em 2em;
}
.body li {
    margin-bottom: 0.5em;
    text-align: left;
}

.chapter-nav {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-top: 52px;
    padding-top: 28px;
    border-top: 1px solid var(--border);
}
.chapter-nav a {
    padding: 10px 18px;
    border: 1px solid var(--border);
    border-radius: 4px;
    text-decoration: none;
    color: var(--text);
    font-size: 0.88em;
    line-height: 1.4;
    max-width: 46%;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.chapter-nav a:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-light); }
.chapter-nav .nav-prev { text-align: left; }
.chapter-nav .nav-next { text-align: right; margin-left: auto; }

/* ---- RESPONSIVE ---- */
@media (max-width: 900px) {
    .chapter-main { padding: 32px 28px 48px; }
}
@media (max-width: 768px) {
    .sidebar-toggle { display: block; }
    .chapter-layout { flex-direction: column; }
    .sidebar {
        width: 100%;
        height: auto;
        position: static;
        display: none;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }
    .sidebar.open { display: block; }
    .chapter-main { padding: 24px 20px 48px; }
    .book-grid { grid-template-columns: repeat(2, 1fr); padding: 20px; gap: 12px; }
    .library-hero { padding: 28px 20px 20px; }
    .library-footer { padding: 0 20px 32px; }
    .book-index-wrap { padding: 28px 20px 48px; }
    .search-box { width: 100%; }
    .library-hero { flex-direction: column; align-items: flex-start; }
}
@media (max-width: 480px) {
    .book-grid { grid-template-columns: 1fr; }
}
