:root {
  --paper: #ffffff;
  --ink: #1b2333;        /* blue-black ink */
  --ink-2: #4a5366;
  --ink-3: #687184;
  --rule: #dde2ea;
  --field: #f3f5f9;
  --link: #2346a8;       /* hyperref-style link blue */
  --mark: #fdeba0;       /* highlighter for a cited reference */
  --button: #1b2333;
  --button-ink: #ffffff;

  --serif: "STIX Two Text", "STIX Two", Georgia, serif;
  --sans: "Instrument Sans", system-ui, sans-serif;

  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #161a22;
    --ink: #e5e8ee;
    --ink-2: #b6bcc8;
    --ink-3: #8e96a6;
    --rule: #2d3443;
    --field: #212837;
    --link: #93b1ff;
    --mark: #514616;
    --button: #e5e8ee;
    --button-ink: #161a22;
  }
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 1.0625rem/1.55 var(--serif);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--link); text-underline-offset: 0.15em; text-decoration-thickness: 1px; }
a:not(:hover) { text-decoration: none; }

:focus-visible { outline: 2px solid var(--link); outline-offset: 3px; border-radius: 2px; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}

/* ---------- masthead ---------- */

.masthead {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1.5rem;
  padding: 0.75rem clamp(1rem, 4vw, 2rem);
  border-bottom: 1px solid var(--rule);
  font: 400 0.875rem/1.4 var(--sans);
  color: var(--ink-2);
}

.wordmark { font: 700 1.05rem/1 var(--serif); color: var(--ink); letter-spacing: 0.01em; }

.model { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.75rem; }

progress {
  width: 9rem;
  height: 4px;
  appearance: none;
  border: 0;
  border-radius: 2px;
  background: var(--rule);
  color: var(--link);
}
progress::-webkit-progress-bar { background: var(--rule); border-radius: 2px; }
progress::-webkit-progress-value { background: var(--link); border-radius: 2px; }
progress::-moz-progress-bar { background: var(--link); border-radius: 2px; }

/* ---------- buttons ---------- */

.button {
  font: 600 0.9375rem/1 var(--sans);
  color: var(--button-ink);
  background: var(--button);
  border: 0;
  border-radius: 3px;
  padding: 0.7rem 1.25rem;
  cursor: pointer;
}
.button:disabled { opacity: 0.45; cursor: progress; }

.button-quiet {
  font: 500 0.875rem/1.2 var(--sans);
  color: var(--link);
  background: none;
  border: 1px solid currentColor;
  border-radius: 3px;
  padding: 0.3rem 0.6rem;
  cursor: pointer;
}

/* ---------- the page ---------- */

.sheet {
  max-width: 43rem;
  margin: 0 auto;
  padding: clamp(2.5rem, 8vh, 5rem) 1rem 5rem;
}

.ask textarea {
  display: block;
  width: 100%;
  field-sizing: content;
  resize: none;
  margin: 0;
  padding: 0.8rem 1rem;
  border: 1px solid var(--ink-3);
  border-radius: 3px;
  background: var(--field);
  color: var(--ink);
  font: 500 clamp(1.2rem, 1.05rem + 0.7vw, 1.5rem)/1.3 var(--serif);
}
.ask textarea::placeholder { color: var(--ink-3); opacity: 1; }
.ask textarea:hover { border-color: var(--ink-2); }
.ask textarea:focus { outline: none; border-color: var(--link); box-shadow: 0 0 0 1px var(--link); }

.local-note {
  width: fit-content;
  max-width: 100%;
  margin: 1.1rem auto 0;
  color: var(--ink);
  font: 400 0.9375rem/1.45 var(--sans);
  text-align: center;
  text-wrap: balance;
}
.local-note strong { display: block; font-weight: 600; }
.local-note.is-warning { padding: 0.45rem 0.8rem; border-radius: 3px; background: var(--mark); font-weight: 500; }

.byline {
  margin: 0.9rem 0 0;
  text-align: center;
  font: 400 0.875rem/1.45 var(--sans);
  color: var(--ink-3);
}

.ask-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 2rem;
}

.settings { font: 400 0.9rem/1.4 var(--sans); color: var(--ink-2); }
.settings summary { cursor: pointer; padding: 0.55rem 0; width: max-content; }
.settings-body {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  gap: 1rem 1.5rem;
  padding: 0.75rem 0 0.25rem;
}
.settings[open] { flex: 1; }
.field { display: grid; gap: 0.35rem; }
.field select, .field input[type="range"] { font: inherit; color: var(--ink); width: 100%; }
.field select {
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--rule);
  border-radius: 3px;
  background: var(--paper);
}
.field input[type="range"] { accent-color: var(--link); margin: 0.4rem 0 0; }

/* ---------- answer: set like an abstract ---------- */

.answer {
  margin: 3rem 0 0;
  padding: 0 clamp(0rem, 5vw, 2.5rem);
}
.answer-body {
  margin: 0;
  font-size: 1rem;
  line-height: 1.6;
  text-align: justify;
  hyphens: auto;
}
.runin { font-weight: 700; }
.answer.is-notice #answer-text { color: var(--ink-2); }
.cite { white-space: nowrap; }

.answer-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  margin-top: 0.75rem;
  min-height: 1.75rem;
  font: 400 0.8125rem/1.4 var(--sans);
  color: var(--ink-3);
}

/* ---------- references ---------- */

.references { margin-top: 3.25rem; }
.references h2 { margin: 0 0 1.1rem; font: 700 1.25rem/1.3 var(--serif); }

.refs-status { margin: 0; font: 400 0.9375rem/1.5 var(--sans); color: var(--ink-2); }

.ref-group { list-style: none; margin: 0; padding: 0; }

.ref {
  display: grid;
  grid-template-columns: 2.6rem 1fr;
  column-gap: 0.4rem;
  padding: 0.6rem 0.5rem 0.75rem 0;
  margin-left: -0.5rem;
  padding-left: 0.5rem;
  border-radius: 3px;
  scroll-margin-top: 1.5rem;
}
.ref > :not(.ref-num) { grid-column: 2; }
.ref-num { grid-row: 1; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.ref-cite { margin: 0; }
.ref-authors { color: var(--ink-2); }
.ref-title { color: var(--ink); font-style: italic; }
.ref-meta { white-space: normal; }

.ref-abstract {
  margin: 0.35rem 0 0;
  font-size: 0.9375rem;
  line-height: 1.55;
  color: var(--ink-2);
}
.ref-abstract.is-clamped {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  overflow: hidden;
}

.ref-toggle {
  justify-self: start;
  margin-top: 0.2rem;
  padding: 0.15rem 0;
  border: 0;
  background: none;
  font: 500 0.8125rem/1.3 var(--sans);
  color: var(--link);
  cursor: pointer;
}

/* Clicking a citation in the answer marks the reference like a highlighter. */
.ref:target { animation: mark 2.6s ease-out; }
@keyframes mark { from { background: var(--mark); } to { background: transparent; } }

.cutoff {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1.25rem 0 0.75rem;
  font: 400 0.8125rem/1.4 var(--sans);
  color: var(--ink-3);
}
.cutoff::after { content: ""; flex: 1; border-top: 1px solid var(--rule); }

@media (max-width: 34rem) {
  .answer-body { text-align: left; }
  .ref { grid-template-columns: 2.2rem 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .ref:target { animation: none; background: var(--mark); }
}
