/* ── Reset & Base ─────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary:    #b71c1c;
  --primary-dk: #7f0000;
  --accent:     #ff8f00;
  --bg:         #fdf6ec;
  --bg-sidebar: #fff8ee;
  --text:       #333;
  --border:     #e0d5c1;
  --radius:     6px;
}

html { scroll-behavior: smooth; }
body {
  font-family: "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
}

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

/* ── Header ───────────────────────────────────── */
#site-header {
  background: linear-gradient(135deg, var(--primary-dk), var(--primary));
  color: #fff;
  padding: 0.8rem 1.5rem;
  position: sticky; top: 0; z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
}
.header-title, .header-nav {
  max-width: 1200px; margin: 0 auto;
}
.header-title { text-align: center; padding-bottom: 0.5rem; }
.header-title h1 { font-size: 1.1rem; font-weight: 600; line-height: 1.3; }
.header-title h1 a { color: inherit; }
.header-title h1 a:hover { color: inherit; opacity: 0.85; }

.header-nav { display: flex; align-items: center; gap: 0.2rem; }
#main-nav { display: flex; flex-wrap: wrap; gap: 0.2rem; margin-left: auto; margin-right: auto; }
#main-nav a {
  color: #fff; padding: 0.35rem 0.7rem; border-radius: var(--radius);
  font-size: 0.88rem; transition: background .2s;
}
#main-nav a:hover, #main-nav a.active {
  background: rgba(255,255,255,.2); color: #fff;
}

#search-toggle {
  background: none; border: none; color: #fff;
  cursor: pointer; padding: 0.35rem; border-radius: var(--radius);
  display: flex; align-items: center; transition: background .2s;
}
#search-toggle:hover { background: rgba(255,255,255,.2); }

#search-box {
  display: none;
  position: absolute; left: 0; right: 0; top: 100%;
  background: #fff; box-shadow: 0 4px 12px rgba(0,0,0,.15);
  z-index: 99;
}
#search-box.open { display: block; }
#search-box-inner {
  max-width: 1200px; margin: 0 auto; padding: 0.8rem 1.5rem;
}
#search-input {
  width: 100%; padding: 0.6rem 0.8rem;
  font-size: 1rem; border: 2px solid var(--border);
  border-radius: var(--radius); outline: none;
  font-family: inherit; color: var(--text);
}
#search-input:focus { border-color: var(--primary); }
#search-results { margin-top: 0.5rem; }
.search-result {
  border-bottom: 1px solid var(--border);
}
.search-result:last-child { border-bottom: none; }
.search-result a {
  display: block; padding: 0.6rem 0.4rem; border-radius: var(--radius);
  transition: background .15s;
}
.search-result a:hover { background: var(--bg); }
.search-result strong { display: block; color: var(--primary-dk); font-size: 0.95rem; }
.search-snippet { font-size: 0.85rem; color: #666; line-height: 1.4; }
.search-snippet mark { background: #fff3cd; color: var(--text); padding: 0 2px; border-radius: 2px; }
.search-min { font-size: 0.85rem; color: #999; padding: 0.3rem 0; }

#menu-toggle {
  display: none; background: none; border: none;
  color: #fff; font-size: 1.6rem; cursor: pointer;
}

/* ── 3-Column Layout ──────────────────────────── */
.page-layout {
  max-width: 1200px; margin: 1.5rem auto; padding: 0 1rem;
  display: grid;
  grid-template-columns: 220px 1fr 260px;
  gap: 1.5rem;
  align-items: start;
}

/* ── Sidebars ─────────────────────────────────── */
.sidebar {
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  font-size: 0.9rem;
}
.sidebar h2, .sidebar h3 {
  font-size: 1rem;
  color: var(--primary);
  border-bottom: 2px solid var(--accent);
  padding-bottom: .35rem;
  margin-bottom: .6rem;
}
.sidebar ul { list-style: none; }
.sidebar li { padding: 0.3rem 0; border-bottom: 1px dotted var(--border); }
.sidebar li:last-child { border-bottom: none; }
.sidebar a { font-size: 0.88rem; }

/* ── Main Content ─────────────────────────────── */
#page-content {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.8rem 2rem;
  min-height: 50vh;
}
#page-content h1 {
  color: var(--primary-dk);
  font-size: 1.5rem;
  border-bottom: 3px solid var(--accent);
  padding-bottom: .5rem;
  margin-bottom: 1rem;
}
#page-content h2 { color: var(--primary); margin: 1.2rem 0 .5rem; font-size: 1.2rem; }
#page-content h3 { color: var(--primary); margin: 1rem 0 .4rem; font-size: 1.05rem; }
#page-content p  { margin-bottom: 0.9rem; }
#page-content strong { color: var(--primary-dk); }

/* ── Footer ───────────────────────────────────── */
footer {
  text-align: center; padding: 1.2rem;
  background: var(--primary-dk); color: rgba(255,255,255,.8);
  font-size: 0.85rem; margin-top: 2rem;
}

/* ── Responsive ───────────────────────────────── */
@media (max-width: 900px) {
  .page-layout { grid-template-columns: 1fr; }
  #sidebar-left  { order: 2; }
  #page-content   { order: 1; }
  #sidebar-right  { order: 3; }
  .header-title h1 { font-size: 0.95rem; }
}
@media (max-width: 640px) {
  .header-nav { flex-wrap: wrap; }
  .header-title { order: 1; flex: 1; min-width: 0; }
  #search-toggle { order: 2; flex-shrink: 0; }
  #menu-toggle { order: 3; display: block; flex-shrink: 0; }
  #main-nav { order: 4; display: none; flex-direction: column; width: 100%; margin: 0; }
  #main-nav.open { display: flex; }
}
