:root {
  color-scheme: light;
  --paper: #faf8f3;
  --surface: #fffdf8;
  --ink: #252720;
  --muted: #625c50;
  --line: #dfd8ca;
  --accent: #783b2c;
  --tint: #f0e6da;
  --serif: "Palatino Linotype", Palatino, "Noto Serif", Georgia, serif;
  --sans: system-ui, "PingFang SC", "Microsoft YaHei", sans-serif;
  --masthead-height: 4.5rem;
  font-family: var(--sans);
  background: var(--paper);
  color: var(--ink);
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; }
a { color: var(--accent); text-underline-offset: .22em; }
button, input { font: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
html { scroll-padding-top: calc(var(--masthead-height) + 3.5rem); }

.visually-hidden, .skip:not(:focus) {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.skip:focus { position: fixed; z-index: 4; top: .5rem; left: .5rem; padding: .6rem; background: var(--surface); }

.masthead {
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.masthead-inner, .layout { max-width: 96rem; margin-inline: auto; }
.masthead-inner {
  min-height: calc(var(--masthead-height) - 1px);
  padding: .55rem clamp(1rem, 3.2vw, 3rem);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.brand { display: flex; align-items: center; gap: .9rem; color: var(--ink); text-decoration: none; white-space: nowrap; }
.wordmark { font: 700 2rem/1 var(--serif); color: var(--accent); letter-spacing: -.045em; }
.brand-title { font-weight: 650; }
#search { display: flex; width: min(100%, 25rem); }
#query {
  flex: 1;
  min-width: 0;
  padding: .6rem .75rem;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: .3rem 0 0 .3rem;
}
#search button, .toc-toggle, .more {
  padding: .58rem .9rem;
  color: var(--accent);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: .3rem;
  white-space: nowrap;
}
#search button { background: var(--accent); color: white; border-color: var(--accent); border-radius: 0 .3rem .3rem 0; }
#search button:hover { background: #602f23; }
.toc-toggle { display: none; }

.layout { display: grid; grid-template-columns: clamp(14rem, 21vw, 19rem) minmax(0, 1fr); }
.sidebar {
  position: sticky;
  top: var(--masthead-height);
  align-self: start;
  height: calc(100dvh - var(--masthead-height));
  overflow-y: auto;
  scrollbar-gutter: stable;
  border-right: 1px solid var(--line);
  padding: 2.15rem .95rem 2rem clamp(1rem, 3vw, 2.8rem);
}
.sidebar h2 { margin: 0 0 1.15rem; font-size: .94rem; color: var(--muted); }
.toc-group { border-top: 1px solid var(--line); }
.toc-group summary, .toc-link { padding: .58rem .5rem; font-size: .9rem; line-height: 1.45; }
.toc-group summary { cursor: pointer; font-weight: 650; }
.toc-group summary::marker { color: var(--accent); }
.toc-group summary:hover, .toc-link:hover, .toc-toggle:hover, .more:hover { background: var(--tint); }
.toc-group ul { list-style: none; padding: 0 0 .45rem .6rem; margin: 0; }
.toc-link { display: flex; gap: .48rem; color: var(--ink); text-decoration: none; border-radius: .25rem; }
.toc-link.subsection { padding-inline-start: 1.15rem; }
.toc-link[aria-current="location"] { background: var(--tint); color: var(--accent); font-weight: 650; }
.toc-number { color: var(--accent); font-variant-numeric: tabular-nums; flex-shrink: 0; }
.toc-standalone { font-weight: 650; }

.reading { min-width: 0; padding: 2.55rem clamp(1.3rem, 4.5vw, 4.6rem) 2rem; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 1rem; margin-bottom: 1.65rem; }
.chapter-name { color: var(--accent); font-size: .9rem; font-weight: 650; margin: 0 0 .65rem; }
h1 { font-size: clamp(1.7rem, 3vw, 2.7rem); line-height: 1.25; margin: 0; overflow-wrap: anywhere; }
.german-title { font-size: 1.06rem; line-height: 1.45; color: var(--muted); margin: .5rem 0 0; }
.section-meta { color: var(--muted); font-size: .84rem; white-space: nowrap; margin: 0 0 .2rem; }
.comparison { width: 100%; table-layout: fixed; border-spacing: 0; border-top: 2px solid var(--accent); }
.comparison th {
  position: sticky;
  top: var(--masthead-height);
  z-index: 1;
  text-align: start;
  font-size: .84rem;
  font-weight: 700;
  background: var(--tint);
  color: var(--accent);
  border-bottom: 1px solid var(--line);
}
.comparison :is(th, td) { padding: .85rem clamp(.7rem, 1.6vw, 1.25rem); overflow-wrap: anywhere; }
.comparison td { border-bottom: 1px solid var(--line); vertical-align: top; line-height: 1.55; }
.comparison td + td { border-inline-start: 1px solid var(--line); }
.comparison th:first-child { width: 39%; }
.comparison th:nth-child(2) { width: 30%; }
.entry { background: var(--surface); }
.entry.alt { background: #f6f2ea; }
.entry.is-target, .entry:focus { background: #f3e6d3; }
.phrase { margin: 0; }
.phrase mark { background: #f4d98e; color: var(--ink); border-radius: .12em; }
.latin .phrase { font: 1.22rem/1.45 var(--serif); }
.marked[lang="la"], .marked[lang="el"] { font-family: var(--serif); }
[lang="de"] { font-family: var(--sans); }
.marked[lang="de"] { font-size: .93em; }
.row-actions { display: flex; flex-wrap: wrap; align-items: baseline; gap: .25rem .75rem; margin-top: .28rem; font-size: .78rem; }
.permalink, .note-toggle { color: var(--accent); }
.permalink { text-decoration: none; }
.permalink:hover, .note-toggle:hover { text-decoration: underline; text-underline-offset: .2em; }
.note-toggle { background: none; border: 0; padding: 0; }
.note-toggle::after { content: " ▸"; }
.note-toggle[aria-expanded="true"]::after { content: " ▾"; }
.missing { color: var(--muted); font-size: .86rem; }
.note-row { background: var(--tint); }
.note-content { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem 1.75rem; margin: .1rem 0; }
.note-content dt { color: var(--accent); font-size: .8rem; font-weight: 650; margin-bottom: .3rem; }
.note-content dd { margin: 0; font-size: .93rem; white-space: pre-wrap; }

.section-nav { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; margin-top: 1.7rem; }
.section-nav a { border: 1px solid var(--line); padding: .65rem .85rem; border-radius: .3rem; text-decoration: none; background: var(--surface); }
.section-nav a:hover { background: var(--tint); }
.section-nav a[rel="next"] { grid-column: 2; text-align: end; }
.section-nav span { display: block; font-size: .78rem; color: var(--muted); margin-bottom: .2rem; }
.subsections { list-style: none; padding: 0; margin: 0; border-top: 2px solid var(--accent); }
.subsections li { border-bottom: 1px solid var(--line); }
.subsections .toc-link { padding: .8rem 1rem; }
.message { color: var(--muted); }
.search-empty { background: var(--surface); border-top: 2px solid var(--accent); padding: 1rem; }
.search-empty p { margin: 0; }
.search-empty p + p { margin-top: .45rem; }
.search-actions { display: flex; align-items: center; flex-wrap: wrap; gap: .55rem .9rem; }
.search-actions .section-meta { margin: 0; }
.search-exit { padding: .4rem .65rem; border: 1px solid var(--line); border-radius: .3rem; background: var(--surface); white-space: nowrap; font-size: .86rem; }
.search-exit:hover { background: var(--tint); }
.introduction { border-top: 1px solid var(--line); margin-top: 2.75rem; padding-top: 1.25rem; }
.introduction h2 { font-size: 1.24rem; margin: 0 0 .7rem; }
.introduction p { max-width: 68ch; line-height: 1.75; margin: .55rem 0; }
.more { display: block; margin: 1.25rem auto 0; }
.colophon { border-top: 1px solid var(--line); padding-top: .8rem; margin-top: 2.75rem; color: var(--muted); font-size: .8rem; }
.colophon p { margin: .3rem 0; line-height: 1.6; }

@media (max-width: 760px) {
  :root { --masthead-height: 6.4rem; }
  html { scroll-padding-top: calc(var(--masthead-height) + .5rem); }
  .masthead-inner { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .35rem .7rem; }
  .brand { gap: .65rem; }
  .wordmark { font-size: 1.7rem; }
  .toc-toggle { display: block; grid-column: 2; grid-row: 1; padding: .38rem .65rem; }
  #search { grid-column: 1 / -1; width: 100%; }
  #query, #search button { padding-block: .42rem; }
  .layout { display: block; }
  .sidebar { display: none; position: fixed; z-index: 2; inset-inline: 0; height: auto; max-height: calc(100dvh - var(--masthead-height)); background: var(--surface); border-bottom: 1px solid var(--line); padding: 1rem; }
  .sidebar.is-open { display: block; }
  .reading { padding: 1.65rem 1rem 1.5rem; }
  .section-heading { display: block; margin-bottom: 1rem; }
  .section-meta { margin-top: .55rem; }
  .search-actions { margin-top: .65rem; }
  .comparison, .comparison tbody, .entry { display: block; }
  .comparison thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .entry { border-bottom: 1px solid var(--line); padding: .65rem .75rem; }
  .comparison .entry td { display: grid; grid-template-columns: 2.7rem minmax(0, 1fr); gap: .45rem; padding: .34rem 0; border: 0; }
  .cell-label { color: var(--accent); font-size: .75rem; font-weight: 650; padding-top: .2rem; }
  .note-row:not([hidden]), .note-row td { display: block; }
  .note-content { grid-template-columns: 1fr; gap: .7rem; }
}

@media (min-width: 761px) { .cell-label { display: none; } }
