:root {
  --bg: #fbfaf7;
  --fg: #1f1d1a;
  --muted: #5d5850;
  --accent: #2f5d50;
  --border: #d9d4ca;
  --notice-bg: #f3efe4;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171614;
    --fg: #ece8e1;
    --muted: #aaa398;
    --accent: #8cc2b1;
    --border: #3a3732;
    --notice-bg: #24221e;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0 auto;
  max-width: 44rem;
  padding: 1.5rem 1rem 3rem;
  background: var(--bg);
  color: var(--fg);
  font: 1.0625rem/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}
h1 { margin: 0 0 .25rem; font-size: 2rem; }
.tagline { margin: 0 0 1.5rem; color: var(--muted); }
a { color: var(--accent); }
form { display: grid; gap: .5rem; }
label { font-weight: 600; }
textarea {
  width: 100%;
  padding: .75rem;
  border: 1px solid var(--border);
  border-radius: .5rem;
  background: transparent;
  color: inherit;
  font: inherit;
  resize: vertical;
}
button {
  justify-self: start;
  padding: .6rem 1.4rem;
  border: 0;
  border-radius: .5rem;
  background: var(--accent);
  color: var(--bg);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
#status { min-height: 1.5em; color: var(--muted); }
.notice {
  margin-top: 1.5rem;
  padding: 1rem;
  border-left: 4px solid var(--accent);
  border-radius: .25rem;
  background: var(--notice-bg);
  font-size: .95rem;
}
:root { --urgent: #9b1c1c; --urgent-bg: #fdecec; }
@media (prefers-color-scheme: dark) {
  :root { --urgent: #ff9b9b; --urgent-bg: #3a1d1d; }
}
#results { margin-top: 1.5rem; }
#urgent {
  margin-bottom: 1rem;
  padding: 1rem;
  border: 2px solid var(--urgent);
  border-radius: .5rem;
  background: var(--urgent-bg);
}
#urgent h2 { margin: 0 0 .5rem; color: var(--urgent); font-size: 1.25rem; }
#urgent .emergency { margin: 0 0 .75rem; font-weight: 600; }
#urgent .flag + .flag { margin-top: .75rem; }
#urgent h3 { margin: 0; font-size: 1rem; }
#urgent .flag p { margin: .25rem 0 0; }
#results .notice { margin-top: 1rem; }
footer {
  margin-top: 2.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: .875rem;
}
#rubrics h2 { margin: 1rem 0 .25rem; font-size: 1.15rem; }
#rubrics .hint { margin: 0 0 .75rem; color: var(--muted); font-size: .95rem; }
.phrase { margin-bottom: 1rem; }
.phrase h3 { margin: 0 0 .4rem; font-size: .95rem; font-weight: 600; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin: 0; padding: 0; list-style: none; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  max-width: 100%;
  padding: .3rem .3rem .3rem .7rem;
  border: 1px solid var(--border);
  border-radius: 1rem;
  background: var(--notice-bg);
  font-size: .9rem;
}
.chip .path { overflow-wrap: anywhere; }
.chip .cite { color: var(--muted); font-size: .8rem; white-space: nowrap; }
.chip .remove {
  flex: none;
  width: 1.6rem;
  height: 1.6rem;
  padding: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1;
}
.chip .remove:hover, .chip .remove:focus-visible { background: var(--border); color: var(--fg); }
.chip { padding: 0; }
.chip .pick {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: .35rem;
  padding: .3rem 0 .3rem .7rem;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 400;
  text-align: left;
  cursor: pointer;
}
.chip.chosen { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.chip.chosen .path::before { content: "✓ "; color: var(--accent); font-weight: 700; }
#remedies h2 { margin: 1.5rem 0 .25rem; font-size: 1.15rem; }
#remedies .hint { margin: 0 0 .75rem; color: var(--muted); font-size: .95rem; }
.legend { margin: 0 0 .75rem; padding-left: 0; list-style: none; font-size: .9rem; }
.legend li { margin: .15rem 0; }
.legend .col { font-weight: 700; }
.legend .cite { color: var(--muted); font-size: .8rem; }
.grid-wrap { overflow-x: auto; margin-bottom: .75rem; }
.grid { border-collapse: collapse; font-size: .95rem; }
.grid th, .grid td { padding: .3rem .55rem; border-bottom: 1px solid var(--border); text-align: center; }
.grid tbody th { text-align: left; font-weight: 600; white-space: nowrap; }
.grid thead th { color: var(--muted); font-weight: 600; }
.grid .g3 { font-weight: 800; }
.grid .g2 { font-style: italic; }
.grid .none { color: var(--muted); }
.grid .total { font-weight: 700; color: var(--accent); }
.srp { margin: 1rem 0; padding: .25rem .75rem .5rem; border: 1px solid var(--border); border-left: 4px solid var(--accent); border-radius: .5rem; }
.srp h2 { margin-top: .75rem !important; }
.srp h3 { margin: .75rem 0 .2rem; font-size: 1rem; }
.srp h3 .cite, .srp li .cite { color: var(--muted); font-size: .8rem; font-weight: 400; }
.srp ul { margin: 0; padding-left: 1.1rem; }
.srp li { margin: .25rem 0; line-height: 1.45; overflow-wrap: anywhere; }
.passages .mm { border-top: 1px solid var(--border); padding: .5rem 0; }
.passages .mm > summary { cursor: pointer; }
.passages .mm-name { font-weight: 600; }
.passages .cite { color: var(--muted); font-size: .8rem; }
.passages .mm-section h3 { margin: .75rem 0 .2rem; font-size: 1rem; }
.passages .mm-section p { margin: 0 0 .4rem; line-height: 1.5; overflow-wrap: anywhere; }
.passages .mm-more { margin: .5rem 0 0 .5rem; }
.passages .mm-more > summary { cursor: pointer; color: var(--accent); font-size: .95rem; }
.switch { display: block; font-weight: 400; font-size: .95rem; }
.switch input { margin-right: .4rem; }
.switch .hint { color: var(--muted); font-size: .85rem; }
.similar-label { margin: .5rem 0 .3rem; color: var(--muted); font-size: .85rem; }
.chips.similar .chip { border-style: dashed; }
/* Remedies at home (kit-ui.js) */
#kits { border: 1px solid var(--border); border-radius: .5rem; padding: .5rem .75rem; }
#kits > summary { cursor: pointer; font-weight: 600; }
#kits .hint, .kit-match .hint { color: var(--muted); font-size: .9rem; font-weight: 400; }
.kit-list { display: grid; gap: .5rem; margin: .5rem 0 .75rem; padding: 0; list-style: none; }
.kit { padding: .5rem; border: 1px solid var(--border); border-radius: .5rem; }
.kit label { display: flex; gap: .6rem; align-items: center; font-weight: 400; cursor: pointer; }
.kit input { flex: none; width: 1.2rem; height: 1.2rem; accent-color: var(--accent); }
.kit img { flex: none; width: 3.5rem; height: 3.5rem; object-fit: contain; border-radius: .25rem; background: #fff; }
.kit-text { display: grid; }
.kit-meta { color: var(--muted); font-size: .9rem; }
.kit-contents { margin: .25rem 0 0 1.8rem; font-size: .9rem; }
.kit-contents summary { cursor: pointer; color: var(--accent); }
.kit-contents p { margin: .25rem 0; }
.typed-result { margin-top: .4rem; }
.typed-result .chip .pick { cursor: default; }
.typed-result .chip.unknown { border-style: dashed; color: var(--muted); }
.grid tr.owned th { color: var(--accent); }
.grid .have { font-weight: 400; font-size: .8rem; }
.kit-match { margin: 1rem 0; padding: .75rem 1rem; border: 1px solid var(--accent); border-radius: .5rem; }
.kit-match h2 { margin: 0 0 .5rem; font-size: 1.15rem; }
.kit-match p { margin: .25rem 0; }
.kit-heading { margin-top: .5rem; color: var(--muted); font-size: .85rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
/* Visit history (history-ui.js) */
#history { margin-top: 2rem; border: 1px solid var(--border); border-radius: .5rem; padding: .5rem .75rem; }
#history > summary { cursor: pointer; font-weight: 600; }
#history .hint { color: var(--muted); font-size: .9rem; }
.visits { display: grid; gap: .5rem; margin: .75rem 0; padding: 0; list-style: none; }
.visit { border: 1px solid var(--border); border-radius: .5rem; padding: .5rem .75rem; }
.visit > details > summary { cursor: pointer; }
.visit time { color: var(--muted); font-size: .85rem; }
.visit-title { display: block; overflow-wrap: anywhere; }
.visit .now { color: var(--accent); font-size: .85rem; }
.visit label { display: block; margin-top: .75rem; }
.step { margin: .75rem 0; padding-top: .5rem; border-top: 1px dashed var(--border); font-size: .95rem; }
.step p { margin: .25rem 0; }
.step .label { color: var(--muted); font-size: .85rem; }
.step blockquote { margin: .25rem 0 .5rem; padding-left: .75rem; border-left: 3px solid var(--border); overflow-wrap: anywhere; }
.step .flags { color: var(--urgent); }
.step .q { font-weight: 600; }
.step-rubrics { margin: .25rem 0; padding-left: 1.25rem; }
button.secondary {
  margin-top: .5rem;
  padding: .4rem 1rem;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--fg);
  font-weight: 400;
}
button.secondary.danger { border-color: var(--urgent); color: var(--urgent); font-weight: 600; }
.footer-links { margin-top: .5rem; }
/* Terms and Privacy pages */
.legal h1 { font-size: 1.75rem; }
.legal h2 { margin-top: 1.75rem; font-size: 1.15rem; }
.legal .updated { color: var(--muted); }
.legal .back { margin-bottom: 1rem; }
/* Terms gate (agreement.js) */
html.gated { overflow: hidden; }
.agreement {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(4px);
}
.agreement-panel {
  display: grid;
  gap: .6rem;
  width: 100%;
  max-width: 40rem;
  max-height: calc(100dvh - 2rem);
  grid-template-rows: auto auto auto minmax(6rem, 1fr) auto auto auto auto;
  padding: 1rem 1.25rem;
  border: 1px solid var(--border);
  border-radius: .75rem;
  background: var(--bg);
  box-shadow: 0 .5rem 2rem rgb(0 0 0 / .2);
  overflow: auto;
}
.agreement-panel h2 { margin: 0; font-size: 1.35rem; }
@media (max-width: 30rem) { .agreement-panel { gap: .45rem; padding: .85rem 1rem; font-size: .95rem; } .agreement { padding: .5rem; } }
.agreement-panel p { margin: 0; }
.agreement-urgent { color: var(--urgent); font-weight: 600; }
.agreement-terms {
  min-height: 0;
  max-height: 60vh;
  overflow-y: auto;
  padding: .25rem 1rem;
  border: 1px solid var(--border);
  border-radius: .5rem;
  background: var(--notice-bg);
  font-size: .9rem;
}
.agreement-terms h1 { font-size: 1.25rem; }
.agreement-terms h2 { margin-top: 1rem; font-size: 1rem; }
.agreement-terms p { margin: .5rem 0; }
.agreement-panel .hint { color: var(--muted); font-size: .85rem; }
.agreement-check { display: flex; gap: .5rem; align-items: flex-start; font-weight: 600; }
.agreement-check input { flex: none; width: 1.2rem; height: 1.2rem; margin-top: .15rem; accent-color: var(--accent); }
.agreement-panel button:disabled { opacity: .45; cursor: not-allowed; }
.removal { margin: .5rem 0 1rem; padding: .75rem 1rem; border: 1px solid var(--border); border-radius: .5rem; }
.removal p { margin: .4rem 0; }
.removal .hint { color: var(--muted); font-size: .9rem; overflow-wrap: anywhere; }
/* Guided questions (#55) */
.questions { margin: 1rem 0 1.5rem; padding: 1rem; border: 1px solid var(--border); border-radius: .5rem; }
.questions h2 { margin: .25rem 0 .5rem; font-size: 1.15rem; }
.questions .hint { margin: 0 0 .5rem; color: var(--muted); font-size: .95rem; }
.questions label.hint { display: block; }
.questions textarea { width: 100%; box-sizing: border-box; }
.q-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.q-head button.small { margin: 0; padding: .3rem .7rem; font-size: .85rem; }
.q-count { color: var(--muted); font-size: .85rem; }
.q-actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-top: .6rem; }
.q-actions button.secondary { margin-top: 0; }
button.link { padding: .4rem .2rem; background: transparent; color: var(--accent); font-weight: 400; text-decoration: underline; }
.q-options { display: grid; gap: .5rem; margin-top: .5rem; }
button.option { justify-self: stretch; text-align: left; padding: .6rem .9rem; border: 1px solid var(--accent); background: transparent; color: var(--fg); font-weight: 400; }
button.option.muted { border-color: var(--border); color: var(--muted); }
.q-said { color: var(--muted); overflow-wrap: anywhere; }
.q-readback { font-weight: 600; }
.q-reveal { padding-left: .75rem; border-left: 3px solid var(--accent); }
.phrase.from-answer h3 { color: var(--accent); }
.q-follow { font-weight: 600; }
/* The book browser (scripts/books.mjs, books.js) */
.crumbs { margin-bottom: 1rem; color: var(--muted); font-size: .9rem; overflow-wrap: anywhere; }
.books h1 { margin: 0 0 .25rem; font-size: 1.75rem; line-height: 1.2; }
.books h2 { margin: 1.5rem 0 .4rem; font-size: 1.15rem; }
.books .lede, .books .by, .books .common { margin: 0 0 1rem; color: var(--muted); }
.books .cite { margin: 0 0 1rem; color: var(--muted); font-size: .85rem; }
.books .hint { color: var(--muted); font-size: .85rem; }
.books .about { margin: 0 0 1rem; font-size: .9rem; }
.books .about summary { cursor: pointer; color: var(--accent); }
.books-list, .entries, .remedy-list { padding: 0; list-style: none; }
.books-list li { margin-bottom: .75rem; }
.books-list .by { display: block; margin: 0; }
.entries li, .remedy-list li { padding: .2rem 0; }
.entries .common, .remedy-list .abbr { color: var(--muted); font-size: .9rem; }
.remedy-list .in { display: block; font-size: .9rem; }
.remedy-list li:target { background: var(--notice-bg); }
.chapters li { padding: .15rem 0; }
.az { display: flex; flex-wrap: wrap; gap: .2rem .6rem; margin: 0 0 1rem; font-size: .9rem; }
.az a { padding: .1rem 0; }
.entry section p { margin: 0 0 .6rem; line-height: 1.55; }
.entry h2 small, .pg { font-size: .8rem; font-weight: 400; color: var(--muted); }
.prevnext { display: flex; justify-content: space-between; gap: 1rem; margin-top: 2rem; }
.rubrics ul { margin: 0; padding-left: 1.1rem; list-style: none; }
.rubrics > ul { padding-left: 0; }
.rubrics li { padding: .1rem 0; line-height: 1.45; overflow-wrap: anywhere; }
.rubrics > ul > li { padding-top: .5rem; }
.rubrics .rb { font-weight: 600; }
.rubrics ul ul .rb { font-weight: 400; color: var(--accent); }
.rubrics .rem { font-size: .92rem; cursor: pointer; }
.rubrics .rem b { font-weight: 800; }
.rubrics li:target > .rb { background: var(--notice-bg); }
#remedy-panel {
  position: fixed; left: 50%; bottom: 1rem; transform: translateX(-50%);
  width: min(28rem, calc(100% - 2rem)); padding: .75rem 1rem;
  border: 1px solid var(--border); border-radius: .5rem; background: var(--bg);
  box-shadow: 0 4px 18px rgb(0 0 0 / .18); font-size: .95rem;
}
#remedy-panel p { margin: 0 0 .5rem; }
#remedy-panel .close { padding: .3rem .9rem; }
.books .jump { margin: 0 0 1rem; } .books .jump summary { cursor: pointer; color: var(--accent); margin-bottom: .5rem; }

/* Prose texts in the book browser (#84): numbered paragraphs, footnotes under each. */
.books .prose .para { margin-bottom: 1.25rem; }
.books .prose h2 { font-size: 1.05rem; margin: 1.5rem 0 0.5rem; }
.books .prose h2 small, .books .pgmark { font-size: 0.8rem; font-weight: normal; color: var(--muted, #666); }
.books .prose .notes { border-left: 3px solid var(--line, #ddd); padding-left: 0.75rem; margin-top: 0.5rem; font-size: 0.9rem; }
.books .prose .note { margin: 0.4rem 0; }
.books sup.fn a { text-decoration: none; }
