:root {
  --paper: #f3efe6;
  --card: #fffdf8;
  --ink: #1d1914;
  --muted: #6f675e;
  --line: #e3dcd0;
  --mark: #8c2f2a;
  --chip: #efe8dc;
  --sans: "Segoe UI", "Helvetica Neue", sans-serif;
  --serif: Georgia, "Iowan Old Style", "Palatino Linotype", serif;
  color: var(--ink);
  background: var(--paper);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.45;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
}

.top {
  padding: 1.4rem 1.5rem 0.8rem;
  max-width: 72rem;
}

.brand {
  margin: 0;
  color: var(--mark);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.brand a { color: inherit; text-decoration: none; }
.brand a:hover { text-decoration: underline; }

h1 {
  margin: 0.15rem 0 0.25rem;
  font-family: var(--serif);
  font-size: 2rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.lede, .muted { color: var(--muted); }

.lede { margin: 0; max-width: 38rem; }

main {
  display: grid;
  grid-template-columns: 17rem 20rem minmax(0, 1fr);
  gap: 0.9rem;
  padding: 0.9rem 1.1rem 1.4rem;
  align-items: start;
}

aside, #results, #reader {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  min-height: 12rem;
}

aside, #results {
  max-height: calc(100vh - 8.5rem);
  overflow: auto;
  position: sticky;
  top: 0.6rem;
}

.group { padding: 0.85rem 0.95rem 0.4rem; }

.group h2, .panel-head h2, #reader h2 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 650;
}

.group-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.group button.link, button.link {
  border: 0;
  background: transparent;
  color: var(--mark);
  font: inherit;
  font-size: 0.82rem;
  padding: 0;
  cursor: pointer;
}

label.chapter {
  display: flex;
  gap: 0.45rem;
  align-items: flex-start;
  padding: 0.22rem 0;
  font-size: 0.92rem;
  cursor: pointer;
}

input { accent-color: var(--mark); margin-top: 0.2rem; }

.actions {
  position: sticky;
  bottom: 0;
  padding: 0.7rem 0.95rem 0.9rem;
  background: linear-gradient(transparent, var(--card) 30%);
}

.actions button, .hit {
  font: inherit;
  cursor: pointer;
}

.actions button {
  width: 100%;
  border: 0;
  border-radius: 999px;
  background: var(--ink);
  color: #fffdf8;
  padding: 0.65rem 0.9rem;
}

.actions button:disabled {
  background: #c8c0b4;
  cursor: default;
}

.panel-head {
  padding: 0.9rem 0.95rem 0.4rem;
  position: sticky;
  top: 0;
  background: var(--card);
}

.panel-head p { margin: 0.2rem 0 0; font-size: 0.85rem; }

.result-list { padding: 0.2rem 0.55rem 0.8rem; }

.hit {
  display: block;
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 10px;
  padding: 0.55rem 0.5rem;
  margin: 0.1rem 0;
}

.hit:hover, .hit[aria-current="true"] {
  background: var(--chip);
  border-color: var(--line);
}

.hit .where { display: block; font-size: 0.92rem; }
.hit .what, .hit .tags { display: block; color: var(--muted); font-size: 0.8rem; }

#reader { padding: 1.1rem 1.3rem 1.6rem; }

.kicker {
  margin: 0;
  color: var(--mark);
  font-size: 0.82rem;
}

#reader h2 {
  font-family: var(--serif);
  font-size: 1.7rem;
  margin: 0.15rem 0 0.6rem;
}

.tags-line { margin: 0 0 1rem; color: var(--muted); font-size: 0.88rem; }

.sheet {
  font-family: var(--serif);
  font-size: 1.05rem;
  line-height: 1.55;
  max-width: 40rem;
}

.sheet h2, .sheet h3 {
  font-family: var(--serif);
  font-size: 1.15rem;
  margin: 1.1rem 0 0.35rem;
}

.sheet ol, .sheet ul { padding-left: 1.3rem; }
.sheet li { margin: 0.28rem 0; }
.sheet ol { list-style: decimal; }
.sheet ol ol { list-style: lower-alpha; }
.sheet ol ol ol { list-style: lower-roman; }
.sheet .gap { height: 0.7rem; }
.sheet .center { text-align: center; }
.sheet .box {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.55rem 0.75rem;
  margin: 0.6rem 0;
  background: #fffaf3;
}
.sheet .figure-note, .sheet .missing {
  font-family: var(--sans);
  font-size: 0.92rem;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 0.7rem 0.8rem;
  background: var(--chip);
}
.sheet .caps { font-variant: small-caps; letter-spacing: 0.03em; }
.sheet pre.code {
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.86rem;
  background: var(--chip);
  padding: 0.7rem 0.8rem;
  overflow-x: auto;
  border-radius: 8px;
}
.sheet .math { overflow-x: auto; max-width: 100%; }

.source { margin-top: 1.4rem; font-size: 0.88rem; }
.source a { color: var(--mark); }

.empty-reader { margin: 0.4rem; }

button:focus-visible, input:focus-visible, a:focus-visible {
  outline: 2px solid var(--mark);
  outline-offset: 2px;
}

.noscript {
  margin: 1rem 1.5rem;
}

main.subjects {
  grid-template-columns: repeat(auto-fit, minmax(16rem, 22rem));
  align-items: stretch;
}

a.subject {
  display: block;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1.15rem 1.25rem 1.3rem;
  color: inherit;
  text-decoration: none;
}

a.subject h2 {
  font-family: var(--serif);
  font-size: 1.55rem;
  font-weight: 600;
  margin: 0.25rem 0 0.4rem;
}

a.subject p:last-child { margin: 0; color: var(--muted); }
a.subject:hover { border-color: var(--mark); }
.subject-soon .kicker { color: var(--muted); }

main.solo {
  display: block;
  max-width: 40rem;
}

.notice {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1.2rem 1.3rem 1.35rem;
}

.notice p { margin: 0.7rem 0 0; }
.notice p:first-of-type { margin-top: 0.8rem; }
.notice a { color: var(--mark); }

.colophon {
  max-width: 72rem;
  padding: 0.2rem 1.5rem 1.6rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.colophon p { margin: 0; }

@media (max-width: 980px) {
  main { grid-template-columns: 1fr; }
  aside, #results {
    position: static;
    max-height: none;
  }
  aside { max-height: 22rem; overflow: auto; }
}
