:root {
  --bg: #FBF8F1;
  --surface: #FFFFFF;
  --surface-2: #F4ECDA;
  --ink: #241C12;
  --ink-muted: #6B6154;
  --accent: #A9762F;
  --accent-bright: #E3A825;
  --accent-tint: #F3E6CE;
  --line: #E4DCC8;
  --sidebar-width: 280px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17140F;
    --surface: #1F1B14;
    --surface-2: #2A2419;
    --ink: #F1ECE0;
    --ink-muted: #B3A890;
    --accent: #E3B268;
    --accent-bright: #F0C24B;
    --accent-tint: #362C1B;
    --line: #3A3225;
  }
}
:root[data-theme="dark"] {
  --bg: #17140F;
  --surface: #1F1B14;
  --surface-2: #2A2419;
  --ink: #F1ECE0;
  --ink-muted: #B3A890;
  --accent: #E3B268;
  --accent-bright: #F0C24B;
  --accent-tint: #362C1B;
  --line: #3A3225;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Public Sans", "Segoe UI", Arial, sans-serif;
  line-height: 1.6;
}

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

h1, h2, h3 {
  font-family: "Fraunces", Georgia, "Times New Roman", serif;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0.2em 0 0.4em;
  color: var(--ink);
}

/* ---------- Layout ---------- */
.layout {
  display: flex;
  align-items: flex-start;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 24px 20px 40px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.content-col {
  flex: 1;
  min-width: 0;
}

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 3.2rem 2rem 5rem;
}

/* ---------- Sidebar brand + tree ---------- */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-family: "Fraunces", Georgia, serif;
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--ink);
  margin-bottom: 1.6rem;
}
.sidebar-brand:hover { text-decoration: none; }
.logo-mark { width: 26px; height: 26px; flex-shrink: 0; }

ul.tree, ul.tree ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
ul.tree ul {
  margin-left: 0.9rem;
  padding-left: 0.7rem;
  border-left: 1px solid var(--line);
}
ul.tree li { margin: 0.1rem 0; }

ul.tree a {
  display: block;
  padding: 0.35rem 0.5rem;
  border-radius: 6px;
  color: var(--ink-muted);
  font-size: 0.92rem;
  text-decoration: none;
}
ul.tree a:hover { background: var(--surface-2); color: var(--ink); }
ul.tree a.active {
  background: var(--accent-tint);
  color: var(--ink);
  font-weight: 600;
}

ul.tree details > summary {
  list-style: none;
  cursor: pointer;
}
ul.tree details > summary::-webkit-details-marker { display: none; }
ul.tree details > summary::before {
  content: "›";
  display: inline-block;
  width: 1em;
  color: var(--ink-muted);
  transition: transform 0.15s ease;
}
ul.tree details[open] > summary::before { transform: rotate(90deg); }
ul.tree details > summary { display: flex; align-items: center; }
ul.tree details > summary a { flex: 1; }

/* ---------- Breadcrumbs ---------- */
nav.breadcrumbs {
  max-width: 720px;
  margin: 0 auto;
  padding: 2rem 2rem 0;
  font-size: 0.85rem;
  color: var(--ink-muted);
}
nav.breadcrumbs a { color: var(--ink-muted); }
nav.breadcrumbs a:hover { color: var(--accent); }

/* ---------- Headings / hero ---------- */
main > h1 {
  font-size: clamp(1.9rem, 3.6vw, 2.6rem);
  border-bottom: 1px solid var(--line);
  padding-bottom: 1.1rem;
  margin-bottom: 1.4rem;
}

/* ---------- Homepage hero + search ---------- */
.hero-search {
  text-align: center;
  padding-bottom: 2.6rem;
  border-bottom: 1px solid var(--line);
  margin-bottom: 2.6rem;
}
.hero-search h1 {
  font-size: clamp(2.1rem, 4.4vw, 3rem);
  border-bottom: none;
  margin-bottom: 0.5rem;
}
.hero-search > p {
  color: var(--ink-muted);
  max-width: 46ch;
  margin: 0 auto 1.8rem;
  font-size: 1.02rem;
}

.search-box {
  position: relative;
  max-width: 480px;
  margin: 0 auto;
  text-align: left;
}
.search-box input[type="search"] {
  width: 100%;
  font: inherit;
  font-size: 1rem;
  padding: 0.8rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
}
.search-box input[type="search"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
}

.search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 10;
  margin: 0;
  padding: 0.4rem;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 12px 28px -14px rgba(36, 28, 18, 0.4);
  max-height: 340px;
  overflow-y: auto;
}
.search-results li a {
  display: block;
  padding: 0.55rem 0.7rem;
  border-radius: 7px;
  text-decoration: none;
}
.search-results li a:hover { background: var(--surface-2); }
.result-title {
  display: block;
  color: var(--ink);
  font-weight: 600;
  font-size: 0.95rem;
}
.result-breadcrumb {
  display: block;
  color: var(--ink-muted);
  font-size: 0.78rem;
  margin-top: 0.1rem;
}

/* ---------- Homepage sections ---------- */
section.block { margin-bottom: 2.8rem; }
section.block h2 { font-size: 1.4rem; margin-bottom: 1rem; }
.card-summary {
  margin: 0.4rem 0 0;
  font-size: 0.88rem;
  color: var(--ink-muted);
}

/* ---------- Card grid (section listings) ---------- */
.card-grid {
  list-style: none;
  margin: 2rem 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1.1rem;
}

.card-grid li {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  padding: 1.3rem 1.4rem;
  transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.card-grid li:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 6px 18px -12px rgba(36, 28, 18, 0.35);
}

.card-grid a {
  color: var(--ink);
  font-family: "Fraunces", Georgia, serif;
  font-weight: 600;
  font-size: 1.05rem;
  text-decoration: none;
}

/* ---------- Footer ---------- */
footer.site-footer {
  max-width: 720px;
  margin: 0 auto;
  border-top: 1px solid var(--line);
  text-align: left;
  padding: 1.8rem 2rem 3rem;
  color: var(--ink-muted);
  font-size: 0.85rem;
}

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .layout { flex-direction: column; }
  .sidebar {
    width: 100%;
    height: auto;
    position: static;
    border-right: none;
    border-bottom: 1px solid var(--line);
  }
  main { padding: 2.2rem 1.3rem 3rem; }
  nav.breadcrumbs { padding: 1.4rem 1.3rem 0; }
  footer.site-footer { padding: 1.4rem 1.3rem 2.4rem; }
}
