*, *::before, *::after { box-sizing: border-box; }
:root {
  --serif: Georgia, 'Times New Roman', serif;
  --sans: 'Helvetica Neue', Arial, sans-serif;
  --text: #1a1a1a;
  --muted: #666;
  --border: #dde;
  --bg: #fff;
  --bg2: #f8f9fa;
  --link: #1a5276;
  --accent: #c0392b;
}
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: var(--serif);
  color: var(--text);
  line-height: 1.7;
  max-width: 900px;
  margin: 0 auto;
  padding: 1.5rem 1.5rem 4rem;
  background: var(--bg);
}
h1,h2,h3,h4,h5,h6 {
  font-family: var(--sans); font-weight: 700;
  line-height: 1.25; margin: 1.3em 0 .4em;
}
p { margin: .65em 0; }
a { color: var(--link); }
img { max-width: 100%; height: auto; border-radius: 3px;
      display: block; margin: .8em auto; }
figure { margin: 1em 0; text-align: center; }
figcaption { font-size: .82em; color: var(--muted); margin-top: .3em; }
table { border-collapse: collapse; width: 100%; margin: 1em 0; font-size: .87em; }
th,td { border: 1px solid var(--border); padding: 6px 10px;
        text-align: left; vertical-align: top; }
th { background: #eef2f7; font-weight: 700; font-family: var(--sans); }
tr:nth-child(even) { background: #fafafa; }
ul,ol { padding-left: 1.4em; }
li { margin: .2em 0; }
hr { border: none; border-top: 1px solid var(--border); margin: 1.8em 0; }
blockquote {
  border-left: 4px solid var(--accent);
  margin: 1em 0; padding: .5em 1em;
  background: #fdf6f6; font-style: italic;
}
code { font-family: monospace; font-size: .9em;
       background: #f4f4f4; padding: .1em .35em; border-radius: 3px; }

/* ── Top navigation bar ── */
.topnav {
  display: flex; align-items: center; gap: .8rem;
  background: #1a3a5c; color: #fff;
  padding: .6rem 1rem; border-radius: 6px;
  margin-bottom: 1.8rem; font-family: var(--sans);
  font-size: .85rem; flex-wrap: wrap;
}
.topnav a { color: #9ec5e8; text-decoration: none; }
.topnav a:hover { color: #fff; text-decoration: underline; }
.topnav .sep { opacity: .4; }
.topnav .title { color: #fff; font-weight: 700; margin-left: auto; }

/* ── Article header ── */
.article-header {
  border-left: 5px solid var(--accent);
  padding: .6rem 0 .6rem 1rem;
  margin-bottom: 1.4rem;
}
.article-header h1 { margin: 0 0 .2em; font-size: 1.6rem; }
.source-link { font-size: .72rem; color: #aaa; text-decoration: none; }

/* ── Floating back-to-top button ── */
#back-to-top {
  position: fixed; bottom: 1.8rem; right: 1.8rem;
  width: 2.6rem; height: 2.6rem;
  background: #1a3a5c; color: #fff;
  border: none; border-radius: 50%;
  font-size: 1.2rem; line-height: 2.6rem;
  text-align: center; cursor: pointer;
  opacity: 0; transform: translateY(10px);
  transition: opacity .25s, transform .25s;
  box-shadow: 0 2px 8px rgba(0,0,0,.3);
  z-index: 999; text-decoration: none;
}
#back-to-top.visible { opacity: .85; transform: translateY(0); }
#back-to-top:hover { opacity: 1; background: var(--accent); }

/* ── Index page specific ── */
.index-cover {
  text-align: center; padding: 2.5rem 1rem;
  background: linear-gradient(135deg,#f0f4f8,#dce8f0);
  border-radius: 8px; margin-bottom: 2rem;
}
.index-cover h1 { font-size: 2.2rem; color: #1a3a5c; margin: 0 0 .3em; }
.index-cover p { color: #555; margin: .3em 0; }
.stats { display: flex; justify-content: center;
         gap: 1.2rem; flex-wrap: wrap; margin: 1.2rem 0; }
.stat { background: #fff; border: 1px solid #bcd; border-radius: 6px;
        padding: .4rem 1rem; font-family: var(--sans); text-align: center; }
.stat-n { font-size: 1.6rem; font-weight: 900; color: #1a3a5c; line-height: 1; }
.stat-l { font-size: .68rem; color: #888; text-transform: uppercase; letter-spacing: .06em; }
.search-bar {
  display: flex; gap: .5rem; max-width: 480px;
  margin: 1.2rem auto 0;
}
.search-bar input {
  flex: 1; padding: .5rem .8rem; border: 1px solid #bcd;
  border-radius: 4px; font-size: .95rem; font-family: var(--sans);
}
.search-bar input:focus { outline: 2px solid #1a3a5c; border-color: transparent; }
.toc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: .9rem; margin-top: 1rem;
}
.toc-section { background: #fff; border: 1px solid var(--border);
               border-radius: 4px; overflow: hidden; }
.toc-section-title {
  color: #fff; font-family: var(--sans); font-weight: 700;
  font-size: .72rem; letter-spacing: .05em; text-transform: uppercase;
  padding: 7px 11px 3px;
}
.toc-section-sub {
  font-size: .7rem; color: #777; padding: 0 11px 6px;
  font-style: italic; border-bottom: 1px solid var(--border);
}
.toc-section ul { list-style: none; padding: 5px 11px; margin: 0; }
.toc-section li { margin: 2px 0; }
.toc-section a { font-size: .8rem; text-decoration: none; color: var(--link); }
.toc-section a:hover { text-decoration: underline; }
.search-hidden { display: none; }

@media print {
  body { max-width: 100%; padding: .8cm; font-size: 9pt; }
  .topnav, #back-to-top { display: none; }
  img { max-width: 65%; page-break-inside: avoid; }
}
