:root {
  --color-bg: #f6f7f9;
  --color-surface: #ffffff;
  --color-border: #e2e5ea;
  --color-text: #1c2129;
  --color-text-muted: #5b6270;
  --color-primary: #2f5fd9;
  --color-primary-dark: #2549ab;
  --color-primary-contrast: #ffffff;
  --color-danger: #c23b3b;
  --color-success: #1f8a52;
  --radius: 10px;
  --max-width: 720px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #14161b;
    --color-surface: #1c1f26;
    --color-border: #2b2f38;
    --color-text: #eceef1;
    --color-text-muted: #a2a8b4;
    --color-primary: #6a8ef2;
    --color-primary-dark: #8aa5f5;
    --color-primary-contrast: #10131a;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
}

.page-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: 14px 20px 12px;
}

.brand {
  font-weight: 700;
  font-size: 15px;
  margin-bottom: 10px;
  max-width: var(--max-width);
  margin-left: auto;
  margin-right: auto;
}

.progress-track {
  max-width: var(--max-width);
  margin: 0 auto;
  height: 6px;
  background: var(--color-border);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--color-primary);
  transition: width 0.25s ease;
}

.progress-label {
  max-width: var(--max-width);
  margin: 6px auto 0;
  font-size: 12px;
  color: var(--color-text-muted);
}

.app-main {
  flex: 1;
  padding: 28px 20px 40px;
}

.screen {
  max-width: var(--max-width);
  margin: 0 auto;
}

.screen h1 {
  font-size: 22px;
  margin: 0 0 6px;
}

.screen h2 {
  font-size: 17px;
  margin: 28px 0 4px;
}

.lede {
  color: var(--color-text-muted);
  margin: 0 0 20px;
}

.lede-list {
  color: var(--color-text-muted);
  margin: 0 0 20px;
  padding-left: 22px;
}

.lede-list li {
  margin-bottom: 6px;
}

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}

.field {
  margin-bottom: 18px;
}

.field label.field-label {
  display: block;
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 6px;
}

.field input[type="text"],
.field input[type="email"],
.field input[type="number"],
.field select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--color-border);
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 15px;
}

.field input:focus,
.field select:focus {
  outline: 2px solid var(--color-primary);
  outline-offset: 1px;
}

.no-spinner::-webkit-outer-spin-button,
.no-spinner::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.no-spinner {
  -moz-appearance: textfield;
  appearance: textfield;
}

.field-error {
  color: var(--color-danger);
  font-size: 12px;
  margin-top: 6px;
  display: none;
}

.field.has-error input,
.field.has-error select {
  border-color: var(--color-danger);
}

.field.has-error .field-error {
  display: block;
}

.question-block {
  margin-bottom: 22px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--color-border);
}

.question-block:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.question-text {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 12px;
}

.question-number {
  color: var(--color-text-muted);
  font-weight: 500;
  margin-right: 6px;
}

.likert-options {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

@media (max-width: 560px) {
  .likert-options {
    grid-template-columns: 1fr;
  }
}

.likert-option {
  position: relative;
}

.likert-option input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.likert-option label {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 56px;
  padding: 8px 6px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font-size: 12px;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.likert-option input:checked + label {
  border-color: var(--color-primary);
  background: var(--color-primary);
  color: var(--color-primary-contrast);
  font-weight: 600;
}

.likert-option input:focus-visible + label {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

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

.question-block.has-error .likert-option label {
  border-color: var(--color-danger);
}

.app-footer {
  position: sticky;
  bottom: 0;
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  padding: 14px 20px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  max-width: 100%;
}

.app-footer .btn {
  max-width: var(--max-width);
}

.btn {
  padding: 12px 22px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.btn-primary {
  background: var(--color-primary);
  color: var(--color-primary-contrast);
  margin-left: auto;
}

.btn-primary:hover { background: var(--color-primary-dark); }

.btn-primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-secondary {
  background: transparent;
  border-color: var(--color-border);
  color: var(--color-text);
}

.btn-secondary:disabled {
  visibility: hidden;
}

.consent-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 14px;
  color: var(--color-text-muted);
}

.consent-row input { margin-top: 3px; }

.privacy-notice {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin: 0 0 18px;
  background: var(--color-bg);
  font-size: 13px;
  color: var(--color-text-muted);
}

.privacy-notice summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--color-text);
  font-size: 14px;
}

.privacy-notice[open] summary {
  margin-bottom: 12px;
}

.privacy-notice p {
  margin: 0 0 10px;
}

.privacy-notice p:last-child {
  margin-bottom: 0;
}

.privacy-notice strong {
  color: var(--color-text);
}

.consent-block {
  margin-bottom: 14px;
}

.consent-block:last-of-type {
  margin-bottom: 4px;
}

.consent-block.has-error .consent-row {
  color: var(--color-danger);
}

.consent-block.has-error .consent-row input {
  outline: 2px solid var(--color-danger);
  outline-offset: 2px;
}

.consent-block .field-error {
  margin-top: 4px;
  margin-left: 26px;
}

.thankyou h1 { margin-bottom: 12px; }

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  display: inline-block;
  margin-right: 8px;
  animation: spin 0.7s linear infinite;
  vertical-align: -2px;
}

@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed;
  left: 50%;
  bottom: 90px;
  transform: translate(-50%, 20px);
  background: var(--color-text);
  color: var(--color-bg);
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  max-width: 90vw;
  text-align: center;
}

.toast.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}
