:root {
  color-scheme: light dark;
  font-family: system-ui, -apple-system, sans-serif;
  --accent: #6d4aff;
  --accent-contrast: #ffffff;
  /* 70% CanvasText clears WCAG AA 4.5:1 on both Canvas and the slightly
     tinted --surface; 55% measured 4.34:1 and failed the axe gate. */
  --muted: color-mix(in srgb, CanvasText 70%, Canvas);
  --border: color-mix(in srgb, CanvasText 18%, Canvas);
  --surface: color-mix(in srgb, CanvasText 4%, Canvas);
  --danger: #c0392b;
}

body {
  margin: 0;
  padding: 2rem;
  line-height: 1.5;
}

main {
  max-width: 40rem;
  margin: 0 auto;
}

.site-header {
  max-width: 40rem;
  margin: 0 auto 2rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  /* Wraps rather than overflowing: the signed-in email is unbounded in
     length, and a nav that pushes the page wider than the viewport gives
     every page a horizontal scrollbar on a phone. */
  flex-wrap: wrap;
}

.site-header .brand {
  font-weight: 700;
  text-decoration: none;
  color: inherit;
  margin-right: auto;
}

.site-header nav {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  min-width: 0;
}

/* A long address must shrink rather than widen the page. */
.site-header .muted {
  min-width: 0;
  overflow-wrap: anywhere;
}

.muted {
  color: var(--muted);
}

.card {
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  background: var(--surface);
  padding: 1.25rem;
  margin: 1rem 0;
}

.field {
  display: block;
  margin: 0.75rem 0;
}

.field span {
  display: block;
  font-size: 0.9rem;
  margin-bottom: 0.25rem;
}

input[type="email"],
input[type="text"] {
  width: 100%;
  box-sizing: border-box;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  background: Canvas;
  color: CanvasText;
  font: inherit;
}

.button,
button {
  display: inline-block;
  padding: 0.5rem 1rem;
  border: 1px solid var(--accent);
  border-radius: 0.375rem;
  background: var(--accent);
  color: var(--accent-contrast);
  font: inherit;
  cursor: pointer;
  text-decoration: none;
}

.button.secondary,
button.secondary {
  background: transparent;
  color: inherit;
  border-color: var(--border);
}

.button.danger,
button.danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

.button-link {
  background: none;
  border: none;
  padding: 0;
  color: inherit;
  font: inherit;
  cursor: pointer;
  text-decoration: underline;
}

.notice {
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: 0.375rem;
  padding: 0.6rem 0.8rem;
  margin: 1rem 0;
}

.error-text {
  color: var(--danger);
}

.divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--muted);
  margin: 1.25rem 0;
}

.divider::before,
.divider::after {
  content: "";
  flex: 1;
  border-top: 1px solid var(--border);
}

/* --- survey building (M3) ------------------------------------------- */

.title-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.title-row h1,
.title-row h2 {
  margin-right: auto;
}

.breadcrumb {
  font-size: 0.9rem;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

.chip {
  display: inline-block;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  border: 1px solid var(--border);
}

.chip-open {
  background: color-mix(in srgb, #1a7f37 20%, Canvas);
  border-color: #1a7f37;
}

.chip-closed {
  background: color-mix(in srgb, var(--danger) 18%, Canvas);
  border-color: var(--danger);
}

.chip-draft {
  background: var(--surface);
}

.chip-small {
  font-size: 0.7rem;
  padding: 0.05rem 0.45rem;
}

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

.survey-title {
  font-size: 1.15rem;
  font-weight: 600;
  text-decoration: none;
  color: inherit;
}

.survey-title:hover {
  text-decoration: underline;
}

.questions {
  padding-left: 1.25rem;
  margin: 0;
}

.question {
  margin: 0.5rem 0;
}

.question summary {
  cursor: pointer;
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.qtype {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  white-space: nowrap;
}

.qtext {
  font-weight: 500;
}

.question details[open] > form,
.question details[open] > .question-actions {
  margin: 0.75rem 0 1rem 0;
  padding-left: 0.5rem;
  border-left: 2px solid var(--border);
}

.question-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.question-actions button {
  font-size: 0.85rem;
  padding: 0.3rem 0.7rem;
}

.field-row {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.field-row .field {
  flex: 1 1 10rem;
}

textarea,
select,
input[type="date"],
input[type="number"] {
  width: 100%;
  box-sizing: border-box;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  background: Canvas;
  color: CanvasText;
  font: inherit;
}

input[type="number"] {
  max-width: 8rem;
}

fieldset {
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  padding: 0.75rem 1rem;
}

.choice {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
  margin: 0.6rem 0;
}

.choice small,
.field small {
  display: block;
  color: var(--muted);
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.75rem 0;
}

.warn {
  font-size: 0.9rem;
  border-left: 3px solid var(--accent);
  padding-left: 0.6rem;
  margin: 0.75rem 0 0;
}

.versions,
.audit {
  padding-left: 1.25rem;
}

.versions {
  list-style: none;
  padding: 0;
}

.versions li {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--border);
}

.audit li {
  padding: 0.3rem 0;
}

.participants {
  list-style: none;
  padding: 0;
  margin: 0 0 1rem;
  max-height: 16rem;
  overflow-y: auto;
}

.participants li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.3rem 0;
  border-bottom: 1px solid var(--border);
}

.danger-zone {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.share-link {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  word-break: break-all;
}

/* --- respondent pages (M4) ------------------------------------------ */

.respond main {
  max-width: 34rem;
}

.preview-banner {
  border: 1px solid var(--accent);
  border-radius: 0.375rem;
  background: color-mix(in srgb, var(--accent) 12%, Canvas);
  padding: 0.6rem 0.9rem;
  margin-bottom: 1.5rem;
}

.disclosure {
  border-left: 3px solid var(--border);
  padding-left: 0.9rem;
  margin: 1rem 0 2rem;
  color: var(--muted);
  font-size: 0.95rem;
}

.error-summary {
  border: 2px solid var(--danger);
  border-radius: 0.375rem;
  padding: 0.9rem 1.1rem;
  margin-bottom: 1.5rem;
}

.error-summary h2 {
  margin-top: 0;
  font-size: 1.05rem;
}

.error-summary ul {
  margin-bottom: 0;
}

.respond-questions {
  list-style: none;
  padding: 0;
  margin: 0;
}

.respond-question fieldset {
  border: none;
  padding: 0;
  margin: 0 0 2.5rem 0;
}

.respond-form.paged .respond-question fieldset {
  margin-bottom: 1.5rem;
}

.respond-question legend {
  padding: 0;
  margin-bottom: 0.9rem;
}

.q-position {
  display: block;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 0.3rem;
}

.q-text {
  display: block;
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.35;
}

.q-required,
.q-optional {
  display: inline-block;
  margin-top: 0.25rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.options {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.option {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  cursor: pointer;
}

.option:hover {
  border-color: var(--accent);
}

.option:focus-within {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.scale {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.scale-point {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  min-width: 2.75rem;
  padding: 0.5rem 0.35rem;
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  cursor: pointer;
}

.scale-point:focus-within {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.scale-hint {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 0.4rem;
}

.respond-progress {
  font-size: 0.9rem;
  color: var(--muted);
  margin-bottom: 1rem;
}

.respond-nav {
  display: flex;
  gap: 0.75rem;
  margin: 1.5rem 0;
}

.respond-actions {
  margin-top: 1.5rem;
}

.respond-submit {
  font-size: 1.05rem;
  padding: 0.65rem 1.5rem;
}

/* The honeypot must be unreachable for people (including screen reader
   and keyboard users) while staying a normal, fillable field for a bot
   that parses the HTML. display:none would be skipped by naive bots too;
   moving it off-screen catches more of them. */
.hp {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

@media (max-width: 30rem) {
  body {
    padding: 1rem;
  }
}
