/* Design tokens. Components never use a literal colour, only these tokens.
   Light is the base; dark applies for an explicit data-theme="dark", or for the
   system dark preference unless the visitor explicitly chose light (Auto follows the system). */
:root {
  color-scheme: light dark;
  --bg: #f7f8fa;
  --surface: #ffffff;
  --text: #1b1f27;
  --text-muted: #566070;
  --border: #d3d9e2;
  --accent: #2b55c9;
  --accent-text: #ffffff;
  --note-bg: #eaf0ff;
  --danger: #b3261e;
  --danger-bg: #fdecea;
  --focus: #1b3fa0;
}

:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #11151c;
    --surface: #1a2029;
    --text: #e8ecf2;
    --text-muted: #9ba7b6;
    --border: #2e3846;
    --accent: #7ea5ff;
    --accent-text: #0b1220;
    --note-bg: #1b2740;
    --danger: #ff8f85;
    --danger-bg: #3a1e1c;
    --focus: #a9c3ff;
  }
}

:root[data-theme="dark"] {
  --bg: #11151c;
  --surface: #1a2029;
  --text: #e8ecf2;
  --text-muted: #9ba7b6;
  --border: #2e3846;
  --accent: #7ea5ff;
  --accent-text: #0b1220;
  --note-bg: #1b2740;
  --danger: #ff8f85;
  --danger-bg: #3a1e1c;
  --focus: #a9c3ff;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.55;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--accent); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.brand { font-weight: 700; color: var(--text); text-decoration: none; }

.theme-switch { display: inline-flex; border: 1px solid var(--border); border-radius: 0.5rem; overflow: hidden; }
.theme-switch[hidden] { display: none; }
.theme-switch button {
  background: transparent;
  color: var(--text);
  border: 0;
  padding: 0.35rem 0.7rem;
  font: inherit;
  cursor: pointer;
}
.theme-switch button + button { border-left: 1px solid var(--border); }
.theme-switch button[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); }

.page { flex: 1; width: 100%; max-width: 44rem; margin: 0 auto; padding: 1.5rem 1rem 2rem; }
h1 { font-size: 1.75rem; line-height: 1.25; margin: 0 0 0.75rem; }
.lead { font-size: 1.1rem; }
.eyebrow { margin: 0 0 0.25rem; color: var(--text-muted); font-size: 0.9rem; text-transform: uppercase; letter-spacing: 0.04em; }

.site-footer { border-top: 1px solid var(--border); padding: 1rem 0; color: var(--text-muted); font-size: 0.9rem; }
.site-footer p { max-width: 44rem; margin: 0 auto 0.4rem; padding: 0 1rem; }

.button {
  display: inline-block;
  background: var(--accent);
  color: var(--accent-text);
  border: 1px solid var(--accent);
  border-radius: 0.5rem;
  padding: 0.6rem 1.1rem;
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.button.secondary { background: transparent; color: var(--accent); }
.button[hidden] { display: none; }

.question {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.6rem;
  margin: 0 0 1rem;
  padding: 0.9rem 1rem 1rem;
}
.question.has-error { border-color: var(--danger); }
.question legend { font-weight: 600; padding: 0 0.3rem; }
.help { margin: 0.2rem 0 0.6rem; color: var(--text-muted); font-size: 0.95rem; }
.field-error { margin: 0.2rem 0 0.6rem; color: var(--danger); font-weight: 600; }

select {
  width: 100%;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 0.4rem;
  padding: 0.55rem 0.6rem;
  font: inherit;
}

.choices { display: grid; gap: 0.35rem; }
.choice { display: flex; gap: 0.55rem; align-items: baseline; padding: 0.3rem 0; cursor: pointer; }

.scale { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.scale-end { color: var(--text-muted); font-size: 0.9rem; min-width: 5.5rem; }
.scale-points { display: flex; gap: 0.5rem; }
.scale-point { display: flex; flex-direction: column; align-items: center; gap: 0.15rem; cursor: pointer; min-width: 2.2rem; }

.actions { display: flex; gap: 0.75rem; flex-wrap: wrap; margin-top: 1.25rem; }

.error-summary {
  background: var(--danger-bg);
  border: 1px solid var(--danger);
  border-radius: 0.6rem;
  padding: 0.5rem 1rem;
  margin: 1rem 0;
}
.error-summary ul { margin: 0 0 0.5rem; padding-left: 1.2rem; }

.note {
  background: var(--note-bg);
  border-left: 4px solid var(--accent);
  border-radius: 0.4rem;
  padding: 0.1rem 1rem;
  margin: 1rem 0;
}

/* Account: header tools, the invitation on the result page, the guides. Tokens only. */
.site-header { flex-wrap: wrap; }
.header-tools { display: flex; align-items: center; flex-wrap: wrap; gap: 0.75rem; }
.account { display: flex; align-items: center; flex-wrap: wrap; gap: 0.6rem; }
.account-email { color: var(--text-muted); font-size: 0.9rem; overflow-wrap: anywhere; }
.logout-form { margin: 0; }
.button.small { padding: 0.3rem 0.7rem; font-size: 0.9rem; }

.cta {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.6rem;
  margin: 1.25rem 0;
  padding: 0.25rem 1rem 0.5rem;
}
.cta h2 { font-size: 1.2rem; margin: 0.6rem 0 0.4rem; }
.cta .actions { margin-top: 0.5rem; }
.legal-note { margin: 0.6rem 0 0.4rem; color: var(--text-muted); font-size: 0.95rem; }

/* Footer links and the legal pages (privacy notice, terms). Tokens only; wide tables scroll inside their own box. */
.site-footer .footer-links a { color: var(--accent); }
.legal-page { overflow-wrap: anywhere; }
.legal-page h2 { font-size: 1.25rem; margin: 1.5rem 0 0.4rem; }
.legal-page table { display: block; max-width: 100%; overflow-x: auto; border-collapse: collapse; margin: 0.75rem 0; }
.legal-page th, .legal-page td { border: 1px solid var(--border); padding: 0.4rem 0.6rem; text-align: left; vertical-align: top; }
.legal-page tbody tr:hover { background: var(--note-bg); }
.legal-page code { font-size: 0.9em; }

.collection { background: var(--surface); border: 1px solid var(--border); border-radius: 0.6rem; margin: 1rem 0; padding: 0.25rem 1rem 0.75rem; }
.collection h2 { font-size: 1.3rem; margin: 0.6rem 0 0.3rem; }
.collection h3 { font-size: 1.05rem; margin: 1rem 0 0.3rem; }
.toc { margin: 0 0 0.5rem; padding-left: 1.2rem; }
.toc li { margin: 0.25rem 0; }
.answers { margin: 0.25rem 0 0.5rem; }
.answer-row { padding: 0.45rem 0; border-top: 1px solid var(--border); }
.answer-row:first-child { border-top: 0; }
.answer-row dt { color: var(--text-muted); font-size: 0.9rem; }
.answer-row dd { margin: 0.1rem 0 0; overflow-wrap: anywhere; }
.earlier-entry { margin: 0.4rem 0; }
.earlier-entry summary { cursor: pointer; padding: 0.3rem 0; }
.summary, .meta { color: var(--text-muted); font-size: 0.95rem; }
.meta span + span::before { content: " - "; }
.note-error { color: var(--danger); font-weight: 600; }
.crumbs { margin: 0 0 0.75rem; }

.doc-body { overflow-wrap: anywhere; }
.doc-body img { max-width: 100%; height: auto; }
.doc-body pre { background: var(--surface); border: 1px solid var(--border); border-radius: 0.4rem; padding: 0.75rem; overflow-x: auto; }
.doc-body code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.92em; }
.doc-body blockquote { border-left: 4px solid var(--border); margin: 1rem 0; padding: 0 1rem; color: var(--text-muted); }
.doc-body table { border-collapse: collapse; display: block; max-width: 100%; overflow-x: auto; }
.doc-body th, .doc-body td { border: 1px solid var(--border); padding: 0.35rem 0.6rem; text-align: left; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
