:root {
  --bg: #f7f5f0;
  --bg-panel: #ffffff;
  --text: #2a241c;
  --text-dim: #6b6255;
  --accent: #7a2323;
  --accent-bg: #f1e4c8;
  --border: #ddd4bf;
  --link: #7a2323;
  --header-bg: #1f1a14;
  --header-text: #f1e4c8;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
}

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }

.site-header {
  background: var(--header-bg);
  color: var(--header-text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  position: sticky;
  top: 0;
  z-index: 10;
  gap: 1rem;
  flex-wrap: wrap;
}

.site-title {
  color: var(--header-text);
  font-weight: bold;
  font-size: 1.15rem;
  letter-spacing: 0.02em;
}
.site-title:hover { text-decoration: none; opacity: 0.85; }

.search-box { position: relative; width: min(320px, 60vw); }
.search-box input {
  width: 100%;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 3px;
  font-family: inherit;
  font-size: 0.95rem;
}
#search-results {
  position: absolute;
  top: 110%;
  left: 0;
  right: 0;
  background: var(--bg-panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  max-height: 60vh;
  overflow-y: auto;
  display: none;
  box-shadow: 0 6px 16px rgba(0,0,0,0.2);
}
#search-results.open { display: block; }
#search-results a {
  display: block;
  padding: 0.5rem 0.7rem;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
#search-results a:hover { background: var(--accent-bg); text-decoration: none; }
#search-results .r-section { color: var(--text-dim); font-size: 0.8rem; }
#search-results .r-empty { padding: 0.6rem; color: var(--text-dim); font-size: 0.9rem; }

.layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  max-width: 1100px;
  margin: 0 auto;
  align-items: start;
}

.sidebar {
  padding: 1.25rem 1rem;
  position: sticky;
  top: 3.2rem;
  max-height: calc(100vh - 3.2rem);
  overflow-y: auto;
  border-right: 1px solid var(--border);
}

.chapter-nav, .chapter-nav ul { list-style: none; margin: 0; padding: 0; }
.chapter-nav > li { margin-bottom: 0.15rem; }
.chapter-nav > li > a {
  display: block;
  padding: 0.25rem 0.4rem;
  border-radius: 3px;
  font-size: 0.95rem;
}
.chapter-nav > li.current > a { background: var(--accent-bg); font-weight: bold; }
.subnav { margin: 0.15rem 0 0.5rem 0.75rem; border-left: 2px solid var(--border); padding-left: 0.6rem; }
.subnav li a { display: block; padding: 0.15rem 0; font-size: 0.85rem; color: var(--text-dim); }
.subnav li a:hover { color: var(--link); }

.content { padding: 1.5rem 2rem 4rem; max-width: 760px; }

.breadcrumb { font-size: 0.85rem; color: var(--text-dim); margin-bottom: 0.5rem; }

h1 { font-size: 1.9rem; margin: 0 0 0.3rem; }
h2 { font-size: 1.3rem; margin-top: 1.8rem; border-bottom: 1px solid var(--border); padding-bottom: 0.2rem; }
h3 { font-size: 1.1rem; }

.source { color: var(--text-dim); font-size: 0.85rem; font-style: italic; margin: 0.2rem 0; }
.summary { color: var(--text-dim); font-size: 0.95rem; margin: 0.4rem 0 1rem; }

article table {
  border-collapse: collapse;
  width: 100%;
  margin: 1rem 0;
  font-size: 0.92rem;
}
article th, article td {
  border: 1px solid var(--border);
  padding: 0.35rem 0.55rem;
  text-align: left;
}
article th { background: var(--accent-bg); }

article blockquote {
  border-left: 3px solid var(--accent);
  margin: 1rem 0;
  padding: 0.4rem 0.9rem;
  background: var(--bg-panel);
  color: var(--text-dim);
  font-size: 0.92rem;
}

.entry-list, .chapter-list { list-style: none; padding: 0; margin: 1.2rem 0; }
.entry-list li, .chapter-list li {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}
.entry-list a, .chapter-list a { font-size: 1.05rem; }
.chapter-list .count { color: var(--text-dim); font-size: 0.85rem; }

.related { margin-top: 2rem; padding-top: 0.5rem; border-top: 1px solid var(--border); }
.related ul { padding-left: 1.2rem; }
.related-section { color: var(--text-dim); font-size: 0.85rem; }

.prevnext {
  display: flex;
  justify-content: space-between;
  margin-top: 2.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.95rem;
  gap: 1rem;
}
.prevnext .next { margin-left: auto; text-align: right; }

.site-footer {
  text-align: center;
  padding: 1.5rem;
  color: var(--text-dim);
  font-size: 0.85rem;
  border-top: 1px solid var(--border);
}

@media (max-width: 800px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; max-height: none; border-right: none; border-bottom: 1px solid var(--border); }
  .content { padding: 1.25rem; }
}
