
:root {
  --bg: #faf8f3;
  --text: #2c2416;
  --accent: #8b1a1a;
  --accent-light: #c4a35a;
  --border: #d4c9a8;
  --latin-bg: #f5f0e6;
  --sidebar-bg: #2c2416;
  --sidebar-text: #e8e0d0;
  --sidebar-width: 280px;
}

* { 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.7;
}

/* Sidebar */
#sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  overflow-y: auto;
  padding: 1em;
  z-index: 100;
  transition: transform 0.3s;
  font-size: 0.85em;
}
.sidebar-header { margin-bottom: 0.8em; }
.sidebar-header a { color: var(--accent-light); text-decoration: none; font-weight: bold; font-size: 1.1em; display: block; margin-bottom: 0.5em; }
.back-to-missal { font-size: 0.85em !important; font-weight: normal !important; opacity: 0.7; margin-bottom: 0.3em !important; }
.back-to-missal:hover { opacity: 1; }
.sidebar-header select { width: 100%; padding: 0.3em; background: #3d3426; color: var(--sidebar-text); border: 1px solid #555; border-radius: 3px; font-family: inherit; font-size: 0.95em; }
.sidebar-nav { margin-bottom: 0.8em; display: flex; justify-content: space-between; }
.sidebar-nav a { color: var(--accent-light); text-decoration: none; font-size: 0.9em; }
.sidebar-nav a:hover { text-decoration: underline; }
.sidebar-sections { border-top: 1px solid #555; padding-top: 0.5em; }
#sidebar-toc { list-style: none; padding: 0; }
#sidebar-toc li { padding: 0.2em 0; }
#sidebar-toc a { color: var(--sidebar-text); text-decoration: none; display: block; padding: 0.15em 0.4em; border-radius: 3px; line-height: 1.3; }
#sidebar-toc a:hover { background: rgba(255,255,255,0.1); }
#sidebar-toc a.active { background: var(--accent); color: white; font-weight: bold; }

#sidebar-toggle {
  position: fixed;
  top: 0.8em; left: 0.8em;
  z-index: 200;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  border: none;
  padding: 0.5em 0.7em;
  font-size: 1.3em;
  cursor: pointer;
  border-radius: 4px;
  display: none;
}

main {
  margin-left: var(--sidebar-width);
  max-width: 52em;
  padding: 0 2em;
}

/* Back to top */
#back-to-top {
  display: none;
  position: fixed;
  bottom: 2em; right: 2em;
  background: var(--accent);
  color: white;
  border: none;
  width: 2.5em; height: 2.5em;
  border-radius: 50%;
  font-size: 1.2em;
  text-align: center;
  line-height: 2.5em;
  text-decoration: none;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  z-index: 50;
}
#back-to-top:hover { background: #a52020; }

@media (max-width: 900px) {
  #sidebar { transform: translateX(-100%); }
  #sidebar.open { transform: translateX(0); box-shadow: 4px 0 20px rgba(0,0,0,0.5); }
  #sidebar-toggle { display: block; }
  main { margin-left: 0; padding: 0 1em; padding-top: 3em; }
}

/* Index page */
.index-sections { list-style: none; padding: 0.3em 0 0.3em 1em; }
.index-sections li { padding: 0.1em 0; font-size: 0.9em; }
.index-sections a { color: var(--text); text-decoration: none; border-bottom: 1px dotted var(--border); }
.index-sections a:hover { color: var(--accent); }
.section-count { color: #999; font-size: 0.85em; }
.hint { font-size: 0.9em; color: #888; margin-bottom: 1em; font-style: italic; }

/* Bottom Navigation */
.bottom-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.8em 0;
  border-top: 1px solid var(--border);
  margin-top: 2em;
  font-size: 0.9em;
}
.nav-left, .nav-center, .nav-right { flex: 1; }
.nav-center { text-align: center; }
.nav-right { text-align: right; }
nav a, .bottom-nav a { color: var(--accent); text-decoration: none; }
nav a:hover, .bottom-nav a:hover { text-decoration: underline; }

/* Header */
header { text-align: center; margin: 2em 0; }
.index-header { margin: 4em 0 2em; }
h1 { font-size: 2em; color: var(--accent); margin-bottom: 0.3em; font-weight: normal; letter-spacing: 0.05em; }
.author { font-size: 1.1em; font-style: italic; margin: 0.2em 0; }
.translator, .edition { font-size: 0.95em; color: #666; margin: 0.2em 0; }

/* Volume list */
.volume-list { margin: 2em 0; }
.volume-list h2 { color: var(--accent); font-size: 1.3em; margin-bottom: 0.8em; }
.volume-list ol { padding-left: 1.5em; }
.volume-list li { padding: 0.4em 0; font-size: 1.05em; }
.volume-list a { color: var(--text); text-decoration: none; border-bottom: 1px solid var(--border); }
.volume-list a:hover { color: var(--accent); border-color: var(--accent); }

/* Article content */
article { margin: 2em 0; }
article p { margin: 0.8em 0; text-align: justify; text-indent: 1.5em; }
article p:first-child { text-indent: 0; }

h2 {
  font-size: 1.4em;
  color: var(--accent);
  margin: 2.5em 0 0.8em;
  padding-top: 1em;
  border-top: 2px solid var(--accent-light);
  font-weight: normal;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
h3.liturgical {
  font-size: 1.2em;
  color: var(--accent);
  text-align: center;
  margin: 1.5em 0 0.5em;
  font-weight: bold;
  letter-spacing: 0.1em;
}
h4.mass-part {
  font-size: 1em;
  text-align: center;
  margin: 1.2em 0 0.4em;
  font-weight: bold;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--accent);
}
h4.sub-element {
  font-size: 1em;
  margin: 1.2em 0 0.4em;
  font-style: italic;
  color: #555;
}

/* Latin text */
.latin {
  display: block;
  font-style: italic;
  background: var(--latin-bg);
  padding: 0.1em 0.8em;
  margin: 0.2em 0;
  border-left: 3px solid var(--accent-light);
}

/* Liturgical responses */
.response, .verse-marker {
  font-weight: bold;
  display: block;
  margin: 0.2em 0 0.2em 2em;
}
.footnote {
  display: block;
  font-size: 0.85em;
  color: #666;
  margin: 0.5em 0 0.5em 2em;
  font-style: italic;
}

/* Footer */
footer {
  text-align: center;
  padding: 2em 0;
  margin-top: 3em;
  border-top: 1px solid var(--border);
  font-size: 0.85em;
  color: #888;
}
footer a { color: var(--accent); }

/* Print */
@media print {
  #sidebar, #sidebar-toggle, #back-to-top, .bottom-nav, footer { display: none !important; }
  main { margin-left: 0 !important; max-width: 100%; }
  h2 { page-break-before: always; }
}
