:root {
  --purple: #6b3fa0;
  --purple-dark: #55317f;
  --purple-light: #f3eefa;
  --ink: #1f2024;
  --muted: #5d6068;
  --line: #dcdde1;
  --bg: #ffffff;
  --bg-soft: #f7f7f9;
  --maxw: 1180px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
h1, h2, h3, h4 { font-family: Georgia, "Times New Roman", serif; line-height: 1.25; color: var(--ink); }
h1 { font-size: 1.9rem; margin: 0 0 .5rem; }
h2 { font-size: 1.4rem; margin: 2rem 0 .75rem; }
h3 { font-size: 1.12rem; margin: 1.5rem 0 .5rem; }
a { color: var(--purple); }
a:hover { color: var(--purple-dark); }
p { margin: 0 0 1rem; }

/* header */
.site-header {
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  position: sticky; top: 0; z-index: 20;
}
.header-inner {
  max-width: var(--maxw); margin: 0 auto; padding: .7rem 1rem;
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
}
.brand { display: flex; flex-direction: column; text-decoration: none; margin-right: auto; }
.brand strong { font-family: Georgia, serif; font-size: 1.08rem; color: var(--ink); }
.brand span { font-size: .8rem; color: var(--muted); }
.search-wrap { position: relative; flex: 1 1 260px; max-width: 420px; }
#search {
  width: 100%; padding: .5rem .7rem .5rem 2rem; font-size: .95rem;
  border: 1px solid var(--line); border-radius: 6px; background: var(--bg-soft);
}
#search:focus { outline: 2px solid var(--purple); outline-offset: 1px; background: #fff; }
.search-wrap::before {
  content: "⌕"; position: absolute; left: .6rem; top: 50%; transform: translateY(-50%);
  color: var(--muted); font-size: 1.1rem;
}
.menu-toggle {
  display: none; border: 1px solid var(--line); background: var(--bg-soft);
  border-radius: 6px; padding: .45rem .7rem; font-size: .9rem; cursor: pointer;
}

/* layout */
.layout { max-width: var(--maxw); margin: 0 auto; display: flex; gap: 2rem; padding: 0 1rem; }
.sidebar {
  width: 260px; flex: 0 0 260px; padding: 1.5rem 0 3rem;
  border-right: 1px solid var(--line); align-self: flex-start;
  position: sticky; top: 62px; max-height: calc(100vh - 62px); overflow-y: auto;
}
.sidebar h2 { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-family: inherit; margin: 1.2rem 0 .4rem; }
.sidebar a { display: block; padding: .2rem 0; font-size: .92rem; text-decoration: none; color: var(--ink); }
.sidebar a:hover, .sidebar a.active { color: var(--purple); }
.sidebar a.active { font-weight: 600; }
.sidebar .sub { padding-left: .8rem; font-size: .88rem; }
main { flex: 1 1 auto; min-width: 0; padding: 1.5rem 0 4rem; }

/* pieces */
.lede { font-size: 1.05rem; color: var(--muted); margin-bottom: 1.5rem; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: .75rem; margin: 1rem 0 2rem; }
.card {
  border: 1px solid var(--line); border-radius: 8px; padding: .8rem .9rem;
  text-decoration: none; color: var(--ink); background: var(--bg); display: block;
}
.card:hover { border-color: var(--purple); background: var(--purple-light); }
.card strong { display: block; font-family: Georgia, serif; margin-bottom: .15rem; }
.card span { font-size: .85rem; color: var(--muted); }

/* notices on the home page */
.notice {
  border: 1px solid var(--line); border-left: 4px solid var(--purple);
  background: var(--bg-soft); border-radius: 6px; padding: .9rem 1.1rem; margin: 0 0 1.25rem;
}
.notice p { margin: 0 0 .6rem; }
.notice p:last-child { margin-bottom: 0; }
.notice h2 { font-size: 1rem; margin: .2rem 0 .3rem; font-family: inherit; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.notice.read-first h2:first-child { margin-top: 0; }
.notice .updated { font-size: .88rem; color: var(--muted); }

/* topic table of contents */
.toc-cols { columns: 2; column-gap: 2.5rem; margin: 1rem 0 2rem; }
.toc-sec { break-inside: avoid; page-break-inside: avoid; margin: 0 0 1.1rem; }
.toc-sec h3 { margin: 0 0 .25rem; font-size: 1.02rem; }
.toc-sec h3 a { text-decoration: none; }
.toc-sec ul { list-style: none; margin: 0; padding: 0 0 0 .1rem; }
.toc-sec li { font-size: .92rem; padding: .08rem 0; }
.toc-sec li a { text-decoration: none; color: var(--ink); }
.toc-sec li a:hover { color: var(--purple); text-decoration: underline; }
.toc-sec .count { font-size: .78rem; color: var(--muted); }
@media (max-width: 720px) { .toc-cols { columns: 1; } }

.sidebar a.sec { font-weight: 600; margin-top: .45rem; }

table { width: 100%; border-collapse: collapse; margin: .5rem 0 2rem; font-size: .93rem; }
th, td { text-align: left; padding: .55rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); border-bottom: 2px solid var(--line); }
tr.history td:first-child { padding-left: 1.6rem; color: var(--muted); }
td .cite { color: var(--muted); font-size: .88rem; display: block; }
.links a { white-space: nowrap; }
.links a + a::before { content: " · "; color: var(--muted); }
.note { color: var(--muted); font-style: italic; font-size: .85rem; }

.chip {
  display: inline-block; padding: .12rem .55rem; border-radius: 999px;
  background: var(--purple-light); color: var(--purple-dark); font-size: .82rem;
  text-decoration: none; margin: 0 .3rem .3rem 0; border: 1px solid #e3d9f3;
}
.chip:hover { background: #e9defa; }
.meta { background: var(--bg-soft); border: 1px solid var(--line); border-radius: 8px; padding: .8rem 1rem; margin: 0 0 1.5rem; font-size: .93rem; }
.meta div + div { margin-top: .4rem; }
.meta strong { color: var(--muted); font-weight: 600; font-size: .82rem; text-transform: uppercase; letter-spacing: .04em; }
.summary-body p { margin-bottom: 1rem; }
.summary-body em { font-style: italic; }
.notes { border-top: 1px solid var(--line); margin-top: 2rem; padding-top: 1rem; font-size: .9rem; color: var(--muted); }
.credit { font-style: italic; color: var(--muted); font-size: .9rem; margin-top: 1.5rem; }
.backlink { display: inline-block; margin-bottom: 1rem; font-size: .9rem; text-decoration: none; }
.count { color: var(--muted); font-size: .9rem; }
.empty { color: var(--muted); }
mark { background: #f6e9b8; }

.result { border-bottom: 1px solid var(--line); padding: .8rem 0; }
.result a { font-family: Georgia, serif; font-size: 1.02rem; text-decoration: none; }
.result p { margin: .25rem 0 0; font-size: .9rem; color: var(--muted); }

.alpha-nav { margin: 1rem 0; }
.alpha-nav a { text-decoration: none; padding: .1rem .35rem; }

footer.site-footer {
  border-top: 1px solid var(--line); margin-top: 2rem;
  padding: 1.5rem 1rem 3rem; font-size: .85rem; color: var(--muted);
}
footer.site-footer div { max-width: var(--maxw); margin: 0 auto; }

@media (max-width: 860px) {
  .menu-toggle { display: block; order: 3; }
  .layout { display: block; padding: 0 1rem; }
  .sidebar {
    display: none; width: auto; position: static; max-height: none;
    border-right: 0; border-bottom: 1px solid var(--line);
  }
  .sidebar.open { display: block; }
  table, thead, tbody, tr, td, th { display: block; }
  thead { display: none; }
  tr { border-bottom: 1px solid var(--line); padding: .6rem 0; }
  td { border: 0; padding: .15rem 0; }
  td:empty { display: none; }
  td[data-label]::before { content: attr(data-label) ": "; color: var(--muted); font-size: .8rem; }
  td:first-child::before { content: none; }
  tr.history td:first-child { padding-left: .8rem; }
}
@media print {
  .site-header, .sidebar, .backlink, .menu-toggle { display: none; }
  a { color: #000; text-decoration: none; }
  .layout { display: block; }
}
