:root {
  --bg: #fff8ec;
  --canvas: #fff8ec;
  --surface: #ffffff;
  --surface-hover: #fff7e9;
  --surface-warm: #fff4e2;
  --line: #e0d8cc;
  --line-strong: #b9afa2;
  --text: #0d141a;
  --muted: #70685d;
  --accent: #3f176c;
  --accent-strong: #552195;
  --blue: #3857ff;
  --selection: #6469ff;
  --selection-soft: #f5f7ff;
  --selection-border: color-mix(in srgb, var(--selection) 36%, var(--line));
  --selection-muted: #b7b8c5;
  --error: #9f3a36;
  --radius-sm: 8px;
  --radius-md: 10px;
  --focus-outline-size: 2px;
  --focus-outline-color: var(--blue);
}

* {
  box-sizing: border-box;
}

body.quiz-app {
  margin: 0;
  min-height: 100svh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}

.page-shell {
  width: min(100%, 760px);
  margin: 0 auto;
  padding: clamp(16px, 4vi, 40px);
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: clamp(20px, 4vi, 36px);
}

.panel + .panel {
  margin-top: 16px;
}

.panel-wide {
  padding-bottom: 28px;
}

.eyebrow,
.progress-label,
.selector-meta {
  margin: 0 0 12px;
  font-size: 0.92rem;
  line-height: 1.45;
  color: var(--muted);
}

.page-title {
  margin: 0;
  max-width: 14ch;
  font-size: 2.35rem;
  line-height: 1.08;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.page-body,
.selector-subtitle {
  margin: 16px 0 0;
  max-width: 42rem;
  font-size: 1.06rem;
  line-height: 1.6;
  color: var(--muted);
}

.selector-grid,
.result-actions,
.stack-lg,
.stack-md {
  display: grid;
  gap: 12px;
}

.selector-grid {
  margin-top: 24px;
}

.result-actions {
  margin-top: 24px;
}

.selector-card {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.selector-name {
  margin: 0;
  font-size: 1.12rem;
  font-weight: 700;
}

.quiz-app .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 48px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  font: inherit;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.25;
  text-align: center;
  text-decoration: none;
  color: var(--text);
  background: var(--surface);
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
  white-space: normal;
  overflow-wrap: anywhere;
}

.quiz-app .button:focus-visible,
.back-link:focus-visible,
.af-choice:focus-within {
  outline: var(--focus-outline-size) solid var(--focus-outline-color);
  outline-offset: 2px;
}

.quiz-app .button-primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}

.quiz-app .button-primary:hover {
  background: var(--accent-strong);
}

.quiz-app .button-secondary {
  background: var(--surface);
  border-color: var(--line);
  color: var(--text);
}

.quiz-app .button-secondary:hover,
.af-choice:hover {
  background: var(--surface-hover);
  border-color: var(--line-strong);
}

.quiz-app .button-large {
  min-height: 52px;
}

.back-link {
  display: inline-block;
  margin-bottom: 16px;
  color: var(--muted);
  text-decoration: none;
}

.back-link:hover {
  color: var(--text);
}

.progress-meta {
  margin-bottom: 18px;
}

.progress-bar {
  width: 100%;
  height: 8px;
  border-radius: var(--radius-sm);
  background: var(--surface-warm);
  overflow: hidden;
}

.progress-bar-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--selection);
}

.step-panel .stack-lg {
  margin-top: clamp(20px, 2.6vi, 28px);
  gap: 16px;
}

.options-group {
  margin: 0;
  padding: 0;
  border: 0;
  display: grid;
  gap: 12px;
}

.af-choice {
  position: relative;
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  column-gap: 12px;
  align-items: start;
  min-height: 52px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease;
}

.af-choice.is-selected,
.af-choice:has(.af-choice__input:checked) {
  border-color: var(--selection-border);
  background: var(--selection-soft);
}

.af-choice.is-selected:hover,
.af-choice:has(.af-choice__input:checked):hover {
  border-color: var(--selection-border);
  background: var(--selection-soft);
}

.af-choice__input {
  appearance: none;
  position: relative;
  display: block;
  inline-size: 24px;
  block-size: 24px;
  margin: 0.06em 0 0;
  padding: 0;
  border: 2px solid var(--selection-muted);
  background: var(--surface);
  box-shadow: none;
  flex: 0 0 auto;
}

.af-choice__input[type="checkbox"] {
  border-radius: 4px;
}

.af-choice__input[type="checkbox"]:checked {
  border-color: var(--selection);
  background: var(--selection);
  box-shadow: rgba(100, 105, 255, 0.3) 0 2px 4px 0;
}

.af-choice__input[type="radio"] {
  border-radius: 50%;
}

.af-choice__input[type="radio"]:checked {
  border-color: var(--selection);
  background:
    radial-gradient(circle at center, var(--selection) 0 37%, transparent 40%),
    var(--surface);
}

.af-choice__check {
  position: absolute;
  inset-block-start: calc(10px + 0.06em + 4px);
  inset-inline-start: 16px;
  inline-size: 16px;
  block-size: 16px;
  color: #ffffff;
  opacity: 0;
  pointer-events: none;
}

.af-choice__input[type="checkbox"]:checked + .af-choice__check {
  opacity: 1;
}

.af-choice__body {
  min-width: 0;
  display: grid;
  gap: 4px;
  padding-top: 1px;
}

.af-choice__label {
  font-size: 1rem;
  font-weight: 650;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.af-choice__helper {
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

.inline-error {
  margin: 16px 0 0;
  color: var(--error);
}

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