:root {
  --paper: #F4F7F6;
  --surface: #FFFFFF;
  --ink: #16324A;
  --ink-soft: #4A5E70;
  --line: #C9D4DB;
  --action: #0B6E69;
  --action-dark: #07524E;
  --highlight: #FFE14D;
  --danger: #A12A2A;
  --radius-lg: 14px;
  --radius-sm: 8px;
  font-size: 112.5%; /* 18px base: easier to read */
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Atkinson Hyperlegible", "Verdana", "Segoe UI", sans-serif;
  line-height: 1.55;
}

::selection { background: var(--highlight); color: var(--ink); }

a { color: var(--action-dark); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 3px; }

/* The signature: a highlighter-pen focus state everywhere */
:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 2px;
  box-shadow: 0 0 0 7px var(--highlight);
}
a:focus-visible { background: var(--highlight); color: var(--ink); box-shadow: none; outline: none; text-decoration-thickness: 3px; }

.wrap { width: min(40rem, 100% - 2.5rem); margin-inline: auto; }

.skip { position: absolute; left: -999px; top: 0.5rem; background: var(--highlight); color: var(--ink); padding: 0.5rem 0.75rem; z-index: 10; }
.skip:focus { left: 0.5rem; }

/* Masthead */
.masthead { background: var(--ink); color: var(--paper); }
.masthead-inner { display: flex; align-items: center; justify-content: space-between; min-height: 4rem; }
.wordmark { display: inline-flex; align-items: center; gap: 0.6rem; color: inherit; text-decoration: none; font-size: 1.15rem; letter-spacing: -0.01em; }
.wordmark b { font-weight: 700; }
.mark { width: 2rem; height: 2rem; color: #3A6788; }
.install { font: inherit; font-size: 0.85rem; background: transparent; color: var(--paper); border: 1.5px solid currentColor; border-radius: 999px; padding: 0.3rem 0.9rem; cursor: pointer; }

/* Intro */
.intro { padding-block: 2.75rem 1.5rem; }
h1 {
  font-size: clamp(1.9rem, 5.5vw, 2.6rem);
  line-height: 1.12;
  letter-spacing: -0.02em;
  margin: 0 0 1rem;
  max-width: 20ch;
}
.lede { font-size: 1.1rem; color: var(--ink-soft); margin: 0; max-width: 34em; }

/* Question form */
.ask {
  background: var(--surface);
  border: 2px solid var(--ink);
  border-radius: var(--radius-lg);
  padding: 1rem 1rem 0.85rem;
}
.ask-label { display: block; font-weight: 700; margin-bottom: 0.4rem; }
textarea {
  width: 100%;
  font: inherit;
  font-size: 1.15rem;
  color: var(--ink);
  border: 0;
  resize: vertical;
  min-height: 5.5rem;
  padding: 0.25rem 0;
  background: transparent;
}
textarea::placeholder { color: #7A8B99; }
textarea:focus-visible { outline: none; box-shadow: none; }
.ask:focus-within { box-shadow: 0 0 0 5px var(--highlight); }
.ask-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; border-top: 1px solid var(--line); padding-top: 0.75rem; margin-top: 0.25rem; }
.count { font-size: 0.85rem; color: var(--ink-soft); }
.field-error { color: var(--danger); font-weight: 700; margin: 0.6rem 0 0; }

button { font: inherit; cursor: pointer; }
.primary {
  background: var(--action);
  color: #fff;
  border: 0;
  border-radius: var(--radius-sm);
  padding: 0.7rem 1.4rem;
  font-weight: 700;
  font-size: 1.05rem;
  box-shadow: 0 3px 0 var(--action-dark);
}
.primary:hover { background: var(--action-dark); }
.primary:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--action-dark); }
.primary[disabled] { opacity: 0.6; cursor: progress; }
.secondary {
  background: transparent;
  color: var(--ink);
  border: 1.5px solid var(--ink);
  border-radius: var(--radius-sm);
  padding: 0.5rem 1rem;
}
.secondary:hover { background: #E3EAEE; }

/* Examples */
.examples { margin-top: 1.75rem; }
.examples h2 { font-size: 1rem; margin: 0 0 0.6rem; color: var(--ink-soft); font-weight: 400; }
.chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.5rem; }
.chips button {
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: 1.2rem;
  padding: 0.45rem 0.95rem;
  font-size: 0.95rem;
  text-align: left;
}
.chips button:hover { border-color: var(--ink); }

/* Status */
.waking { margin-top: 1.5rem; padding: 0.75rem 1rem; border-left: 5px solid var(--highlight); background: var(--surface); }

/* Result */
.result { margin-top: 2.5rem; }
.asked { font-size: 1.25rem; font-weight: 700; margin: 0 0 1rem; padding-left: 0.9rem; border-left: 5px solid var(--ink); }
.loading { display: flex; align-items: center; gap: 0.8rem; color: var(--ink-soft); }
.bar { width: 3rem; height: 0.55rem; border-radius: 99px; background: linear-gradient(90deg, var(--highlight) 0 40%, #E3EAEE 40%); background-size: 250% 100%; animation: sweep 1.2s ease-in-out infinite; }
@keyframes sweep { from { background-position: 100% 0; } to { background-position: 0 0; } }

.answer {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.35rem;
  font-size: 1.1rem;
  border: 1px solid var(--line);
}
.answer p { margin: 0 0 0.9rem; }
.answer p:last-child, .answer ul:last-child { margin-bottom: 0; }
.answer ul { padding-left: 1.2rem; margin: 0 0 0.9rem; }
.answer li { margin-bottom: 0.35rem; }
.answer.ungrounded { border-left: 5px solid var(--ink-soft); }
.cite {
  display: inline; /* inline, not inline-block, so the badge never wraps away from its word */
  white-space: nowrap;
  font-size: 0.75em;
  font-weight: 700;
  line-height: 1;
  padding: 0.18em 0.42em;
  margin-left: 0.12em;
  border-radius: 4px;
  background: #E3EAEE;
  color: var(--ink);
  text-decoration: none;
  vertical-align: 0.2em;
}
.cite:hover { background: var(--highlight); }

.sources { margin-top: 1.5rem; }
.sources h2 { font-size: 1.1rem; margin: 0 0 0.6rem; }
.sources ol { margin: 0; padding: 0; list-style: none; counter-reset: none; }
.sources li { display: grid; grid-template-columns: 2rem 1fr; gap: 0.5rem; padding: 0.7rem 0; border-top: 1px solid var(--line); scroll-margin-top: 1rem; }
.sources li:target { background: #FFF6C2; }
.sources .num { font-weight: 700; }
.sources .src-title { display: block; font-weight: 700; }
.sources .src-section { color: var(--ink-soft); font-size: 0.95rem; }

.result-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 1.25rem; }
.error { color: var(--danger); font-weight: 700; background: var(--surface); border-left: 5px solid var(--danger); padding: 0.75rem 1rem; }

/* Notice */
.notice { margin-block: 3.5rem 2rem; padding-top: 1.5rem; border-top: 2px solid var(--ink); }
.notice h2 { font-size: 1.2rem; margin: 0 0 0.6rem; }
.notice h3 { font-size: 1rem; margin: 1.25rem 0 0.4rem; }
.notice p { margin: 0 0 0.75rem; color: var(--ink-soft); }
.help { margin: 0; padding-left: 1.2rem; }
.help li { margin-bottom: 0.4rem; }

.foot { background: #E3EAEE; font-size: 0.85rem; color: var(--ink-soft); padding-block: 1.25rem; }
.foot p { margin: 0; }

[hidden] { display: none !important; }

@media (max-width: 30rem) {
  .ask-row { flex-direction: column-reverse; align-items: stretch; }
  .primary { width: 100%; }
  .count { text-align: right; }
}

@media (prefers-reduced-motion: reduce) {
  .bar { animation: none; background: var(--highlight); }
  .primary:active { transform: none; }
}
