
:root {
  --bg: #fbfbfa; --fg: #1d1f21; --muted: #6b6f73; --line: #e3e3e0; --field: #ffffff;
  --accent: #1d4e89; --accent-soft: #e8eef6; --flash: #fff4c2;
  --serif: Charter, "Iowan Old Style", "Source Serif Pro", Georgia, Cambria, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #131416; --fg: #e6e6e3; --muted: #9a9ea3; --line: #2c2e31; --field: #1b1c1f;
    --accent: #8db6e8; --accent-soft: #1d2a3a; --flash: #3a3420; }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 16px/1.5 var(--sans); }
[hidden] { display: none !important; }

.top { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem;
  max-width: 72rem; margin: 0 auto; padding: 1.1rem 1rem .5rem; }
.wordmark { margin: 0; font-size: 1.35rem; letter-spacing: .2em; font-weight: 700; }
.sub { margin: .1rem 0 0; color: var(--muted); font-size: .85rem; }
.meta { display: flex; align-items: center; gap: .9rem; font-size: .75rem; color: var(--muted);
  white-space: nowrap; padding-top: .3rem; }
.badge { letter-spacing: .08em; }
.dot { color: #3b8a5a; font-size: .6rem; vertical-align: .1em; }

main { max-width: 72rem; margin: 0 auto; padding: 0 1rem 3rem; }
label { display: block; font-weight: 600; margin-bottom: .35rem; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; }

button { font: inherit; cursor: pointer; }
button.primary { border: 0; border-radius: .4rem; background: var(--accent); color: #fff;
  font-weight: 600; padding: .55rem 1rem; }
button.primary:disabled { opacity: .55; cursor: default; }
button.link { border: 0; background: none; color: var(--muted); padding: 0; font-size: .75rem; }
button.link:hover { color: var(--fg); text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.login { max-width: 22rem; margin-top: 2rem; }
.login input { width: 100%; font: inherit; padding: .6rem .7rem; border: 1px solid var(--line);
  border-radius: .4rem; background: var(--field); color: var(--fg); }
.login button { margin-top: .6rem; width: 100%; }

.ask { margin: .75rem 0 0; }
.askbar { display: flex; align-items: flex-end; gap: .5rem; background: var(--field);
  border: 1px solid var(--line); border-radius: .55rem; padding: .35rem .35rem .35rem .8rem; }
.askbar:focus-within { border-color: var(--accent); }
.askbar textarea { flex: 1; min-width: 0; border: 0; outline: none; resize: none;
  background: transparent; color: var(--fg); font: inherit; line-height: 1.5;
  padding: .35rem 0; max-height: 10rem; }
.askbar button { flex: none; }
.msg { color: var(--muted); min-height: 1.4em; margin: .4rem 0 0; font-size: .9rem; }

.result { margin-top: 1.25rem; }
.label { font: 600 .72rem/1 var(--sans); letter-spacing: .14em; text-transform: uppercase;
  color: var(--muted); margin: 0 0 .9rem; }

.prose { font-family: var(--serif); font-size: 1.07rem; line-height: 1.68; max-width: 44rem;
  overflow-wrap: anywhere; }
.prose p { margin: 0 0 .9em; }
.prose h3, .prose h4, .prose h5, .prose h6 { font-family: var(--sans); margin: 1.3em 0 .4em;
  font-size: 1rem; }
.prose ul, .prose ol { margin: 0 0 .9em; padding-left: 1.3rem; }
.prose li { margin: .25em 0; }
.prose code { font: .9em ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: var(--accent-soft); padding: .05em .3em; border-radius: .25em; }
.prose pre { overflow-x: auto; background: var(--accent-soft); padding: .7rem; border-radius: .4rem; }
.prose pre code { background: none; padding: 0; }
.prose math { font-size: 1.05em; }
.prose .math-block { margin: .6em 0 1em; padding: .2em 0; overflow-x: auto; overflow-y: hidden;
  max-width: 100%; }
.prose math[display="block"] { display: block; margin: 0; }

.cite { font: 600 .72em/1 var(--sans); color: var(--accent); background: var(--accent-soft);
  border: 0; border-radius: .25em; padding: .15em .3em; margin: 0 .08em; vertical-align: .15em; }
.cite:hover { text-decoration: underline; }
.cite.invalid { color: var(--muted); background: none; text-decoration: line-through; cursor: help; }

.sources { border-top: 1px solid var(--line); margin-top: 1.5rem; padding-top: 1.25rem; }
.evidence { list-style: none; margin: 0; padding: 0; }
.src { padding: 0 0 1rem; margin: 0 0 1rem; border-bottom: 1px solid var(--line); }
.src:last-child { border-bottom: 0; }
.src-nums { font: 600 .78rem var(--sans); color: var(--accent); margin-right: .35rem; }
.src-title { font-weight: 600; font-size: .92rem; }
.src-authors, .src-page { font-size: .82rem; color: var(--muted); }
.ex { margin: .6rem 0 0; padding: .35rem .5rem; border-left: 2px solid var(--line);
  border-radius: .2rem; transition: background-color .4s; }
.ex.flash { background: var(--flash); border-left-color: var(--accent); }
.ex-n { font: 600 .7rem var(--sans); color: var(--muted); }
.ex blockquote { margin: .15rem 0 0; font-family: var(--serif); font-size: .9rem;
  line-height: 1.5; overflow-wrap: anywhere; }
.ex details { margin-top: .3rem; font-size: .8rem; }
.ex summary { color: var(--accent); cursor: pointer; }
.ctx { font-family: var(--serif); font-size: .88rem; line-height: 1.55; margin: .4rem 0 0;
  overflow-wrap: anywhere; color: var(--fg); }
.fine { font-size: .75rem; color: var(--muted); }

.diag { margin-top: 1.5rem; font-size: .82rem; color: var(--muted); }
.diag summary { cursor: pointer; }
dl { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: .15rem 1rem;
  margin: .6rem 0; }
dt { font-weight: 600; } dd { margin: 0; overflow-wrap: anywhere; }

@media (min-width: 60rem) {
  .result { display: grid; grid-template-columns: minmax(0, 7fr) minmax(16rem, 3fr);
    grid-template-rows: auto 1fr; column-gap: 3rem; align-items: start; }
  .answer { grid-column: 1; grid-row: 1; }
  .sources { grid-column: 2; grid-row: 1 / span 2; border-top: 0; margin-top: 0; padding-top: 0;
    border-left: 1px solid var(--line); padding-left: 1.5rem; position: sticky; top: 1rem;
    max-height: calc(100vh - 2rem); overflow-y: auto; }
  .diag { grid-column: 1; grid-row: 2; }
}
