/* Theocracy — reading-first styling.
   Excerpts are set in a serif face because they are the thing being read;
   chrome stays in the system sans stack so it recedes. */

:root {
  --bg: #fbfaf7;
  --surface: #ffffff;
  --ink: #1c1b19;
  --ink-muted: #6b6862;
  --line: #e4e0d8;
  --accent: #5b6f52;
  --accent-soft: #eef1ea;
  --mark: #fdf3d0;
  --danger: #a03c2e;
  --radius: 10px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16150f;
    --surface: #1e1d17;
    --ink: #eceae3;
    --ink-muted: #9b978c;
    --line: #322f26;
    --accent: #9cb58c;
    --accent-soft: #24291f;
    --mark: #453b1c;
    --danger: #e08a78;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

main { max-width: 820px; margin: 0 auto; padding: 28px 20px 96px; }

/* ---- top bar ---- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  padding: 12px 20px;
  padding-top: calc(12px + env(safe-area-inset-top, 0px));
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 600; letter-spacing: -0.01em; text-decoration: none; color: var(--ink); }
.topbar nav { display: flex; align-items: center; gap: 18px; }
.topbar nav a { color: var(--ink-muted); text-decoration: none; font-size: 14px; }
.topbar nav a:hover { color: var(--ink); }
.inline { display: inline; margin: 0; }
.linkish {
  background: none; border: 0; padding: 0; cursor: pointer;
  color: var(--ink-muted); font: inherit; font-size: 14px;
}
.linkish:hover { color: var(--ink); }

/* ---- ask box ---- */
.ask { margin-bottom: 28px; }
textarea {
  width: 100%; padding: 14px 16px;
  font-family: var(--serif); font-size: 17px; line-height: 1.5;
  color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius);
  resize: vertical;
}
textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.controls { display: flex; gap: 10px; align-items: center; margin-top: 10px; flex-wrap: wrap; }
select {
  padding: 8px 10px; font: inherit; font-size: 14px;
  color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 8px;
}
button {
  padding: 9px 18px; font: inherit; font-size: 14px; font-weight: 500;
  border-radius: 8px; border: 1px solid transparent; cursor: pointer;
}
button.primary { background: var(--accent); color: #fff; }
button.primary:hover { filter: brightness(1.08); }
button.secondary { background: transparent; color: var(--ink-muted); border-color: var(--line); }
button.secondary:hover { color: var(--ink); border-color: var(--ink-muted); }

.stats { margin-top: 12px; font-size: 13px; }

/* ---- answer ---- */
.answer {
  font-family: var(--serif); font-size: 17.5px; line-height: 1.72;
  background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px 24px;
}
.answer p { margin: 0 0 1em; }
.answer p:last-child { margin-bottom: 0; }

/* Answers are structured prose, not a wall of text: the model uses headings
   to separate distinct provisions and lists to enumerate them. Without these
   rules the browser defaults (oversized headings, 40px bullet indents) fight
   the serif reading column. */
.answer .answer-heading {
  font-family: var(--sans);
  font-size: 0.78em;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin: 1.7em 0 0.7em;
  padding-bottom: 0.4em;
  border-bottom: 1px solid var(--line);
}
.answer .answer-heading:first-child { margin-top: 0; }

.answer ul,
.answer ol {
  margin: 0 0 1em;
  padding-left: 1.15em;
}
.answer li { margin: 0 0 0.6em; padding-left: 0.2em; }
.answer li:last-child { margin-bottom: 0; }
.answer ul { list-style: none; }
/* A restrained marker: a full disc competes with the citation chips. */
.answer ul > li { position: relative; }
.answer ul > li::before {
  content: "";
  position: absolute;
  left: -0.85em;
  top: 0.68em;
  width: 4px; height: 4px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.55;
}

.answer strong { font-weight: 650; }
.answer em { font-style: italic; }

/* Long verbatim quotations from the sources read better set off than run
   inline, since distinguishing quoted policy from summary matters here. */
.answer blockquote {
  margin: 0 0 1em;
  padding: 0.1em 0 0.1em 1em;
  border-left: 2px solid var(--accent-soft);
  color: var(--ink);
}

mark.cite {
  background: var(--mark); color: inherit;
  font-family: var(--sans); font-size: 0.78em; font-weight: 600;
  padding: 1px 4px; border-radius: 4px; vertical-align: 1px;
}

.answer-meta {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  margin: 12px 2px 0; font-size: 12.5px; color: var(--ink-muted);
}
.answer-meta .model { font-weight: 600; color: var(--ink); }
.answer-meta .cost { font-variant-numeric: tabular-nums; }
.answer-meta .dot { opacity: 0.5; }

.thinking { display: flex; align-items: center; gap: 10px; color: var(--ink-muted); padding: 18px 2px; }
.spinner {
  width: 13px; height: 13px; border-radius: 50%;
  border: 2px solid var(--line); border-top-color: var(--accent);
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- excerpts ---- */
.section-title {
  font-size: 12px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.07em; color: var(--ink-muted);
  margin: 30px 0 12px;
}
.excerpts { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.excerpt {
  display: flex; gap: 14px;
  background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px;
}
.excerpt-num {
  flex: 0 0 auto; width: 24px; height: 24px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center;
  font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums;
}
.excerpt-body { min-width: 0; flex: 1; }
.excerpt .text {
  font-family: var(--serif); font-size: 16px; line-height: 1.62;
  margin: 0 0 10px; white-space: pre-wrap;
}
.cites { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  display: inline-block; padding: 3px 9px;
  font-size: 12px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent);
  text-decoration: none; border: 1px solid transparent;
}
a.chip:hover { border-color: var(--accent); }
.chip.subtle { background: transparent; color: var(--ink-muted); border-color: var(--line); }

/* ---- library ---- */
h1 { font-size: 24px; letter-spacing: -0.015em; margin: 0 0 6px; }
.crumbs { font-size: 13px; color: var(--ink-muted); margin-bottom: 10px; }
.crumbs a { color: var(--ink-muted); }
.meta-line { font-size: 13.5px; margin: 0 0 4px; }
.path { font-size: 12px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; word-break: break-all; }

.table-wrap { overflow-x: auto; }
table.docs { width: 100%; border-collapse: collapse; font-size: 14px; margin-top: 16px; }
table.docs th, table.docs td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); }
table.docs th { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-muted); font-weight: 600; }
table.docs td a { color: var(--ink); text-decoration: none; font-weight: 500; }
table.docs td a:hover { text-decoration: underline; }
table.docs .num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---- login ---- */
.login { max-width: 340px; margin: 12vh auto 0; }
.login h1 { margin-bottom: 2px; }
.login form { display: grid; gap: 6px; margin-top: 22px; }
.login label { font-size: 13px; color: var(--ink-muted); margin-top: 8px; }
.login input {
  padding: 10px 12px; font: inherit;
  color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 8px;
}
.login input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.login button { margin-top: 18px; background: var(--accent); color: #fff; }

.muted { color: var(--ink-muted); }
.error { color: var(--danger); font-size: 14px; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.9em; }

@media (max-width: 560px) {
  main { padding: 20px 16px 72px; }
  .excerpt { padding: 14px; gap: 10px; }
  .answer { padding: 18px 16px; font-size: 16.5px; }
}

/* Greeting — the first thing on the page after signing in. Set in the serif
   face so it reads as a welcome rather than as UI chrome, and sized to sit
   comfortably above the ask box without dominating it. */
.greeting {
  margin: 8px 0 22px;
}

.greeting h1 {
  font-family: var(--serif);
  font-size: clamp(26px, 4.5vw, 34px);
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin: 0 0 6px;
  color: var(--ink);
}

.greeting-sub {
  margin: 0;
  font-size: 15px;
  color: var(--ink-muted);
}

@media (max-width: 480px) {
  .greeting { margin: 4px 0 18px; }
  .greeting-sub { font-size: 14px; }
}
