/* ----- Base ----- */
:root {
  --color-bg: #fafaf9;
  --color-surface: #ffffff;
  --color-text: #1f2937;
  --color-text-muted: #6b7280;
  --color-border: #e5e7eb;
  --color-border-strong: #9ca3af;
  --color-accent: #0f4c81;
  --color-accent-hover: #0c3d68;
  --color-accent-disabled: #b8c5d4;
  --color-error: #b91c1c;
  --color-error-bg: #fef2f2;
  --color-warning-bg: #fef3c7;
  --color-warning-border: #f59e0b;
  --color-warning-text: #78350f;
  --radius: 6px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.04);
}

* {
  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 Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
}

.hidden {
  display: none !important;
}

.muted {
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

/* ----- Container ----- */
.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 32px 24px 64px;
}

/* ----- Test banner ----- */
.test-banner {
  background: var(--color-warning-bg);
  border-bottom: 2px solid var(--color-warning-border);
  color: var(--color-warning-text);
  padding: 12px 24px;
  text-align: center;
  font-size: 0.95rem;
}

/* ----- Header ----- */
.survey-header {
  margin-bottom: 24px;
}

h1 {
  font-size: 1.75rem;
  font-weight: 700;
  margin: 0 0 12px;
  color: var(--color-text);
}

.intro-text {
  color: var(--color-text-muted);
  font-size: 0.95rem;
  margin: 0;
  padding: 16px 20px;
  background: var(--color-surface);
  border-left: 3px solid var(--color-accent);
  border-radius: var(--radius);
}

/* ----- Progress ----- */
.progress-wrapper {
  margin: 24px 0 32px;
}

.progress-text {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-bottom: 8px;
}

.progress-bar-bg {
  height: 6px;
  background: var(--color-border);
  border-radius: 999px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--color-accent);
  transition: width 0.3s ease;
}

/* ----- Page content ----- */
.page-title {
  font-size: 1.4rem;
  font-weight: 700;
  margin: 0 0 8px;
}

.page-intro {
  color: var(--color-text);
  margin: 0 0 8px;
  font-weight: 500;
}

.page-sub-intro {
  font-style: italic;
  color: var(--color-text-muted);
  margin: 0 0 24px;
  font-size: 0.95rem;
}

/* ----- Question block ----- */
.question {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}

.question.invalid {
  border-color: var(--color-error);
  background: var(--color-error-bg);
}

.question-id {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.question-text {
  font-size: 1.05rem;
  font-weight: 500;
  margin: 0 0 8px;
}

.question-instruction {
  font-size: 0.9rem;
  color: var(--color-text-muted);
  font-style: italic;
  margin: 0 0 12px;
}

.question-guidance {
  font-size: 0.9rem;
  color: var(--color-text-muted);
  background: #f3f4f6;
  padding: 10px 14px;
  border-radius: var(--radius);
  margin: 0 0 16px;
  border-left: 3px solid var(--color-border-strong);
}

/* ----- Options (radio + checkbox) ----- */
.option-list {
  list-style: none;
  padding: 0;
  margin: 12px 0 0;
}

.option-item {
  margin-bottom: 8px;
}

.option-label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
  font-size: 0.95rem;
}

.option-label:hover {
  background: #f9fafb;
  border-color: var(--color-border-strong);
}

.option-label input[type="radio"],
.option-label input[type="checkbox"] {
  margin: 4px 0 0;
  flex-shrink: 0;
  cursor: pointer;
}

.option-label:has(input:checked) {
  background: #eff6ff;
  border-color: var(--color-accent);
}

/* ----- Free text ----- */
.free-text-input {
  width: 100%;
  min-height: 100px;
  padding: 12px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.95rem;
  line-height: 1.5;
  background: var(--color-surface);
  resize: vertical;
  margin-top: 8px;
}

.free-text-input:focus {
  outline: 2px solid var(--color-accent);
  outline-offset: 1px;
  border-color: var(--color-accent);
}

.free-text-input.invalid {
  border-color: var(--color-error);
  background: var(--color-error-bg);
}

/* ----- Error text ----- */
.error-text {
  color: var(--color-error);
  font-size: 0.85rem;
  margin: 6px 0 0;
}

.error-text.hidden {
  display: none;
}

/* ----- Navigation buttons ----- */
.nav-buttons {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 32px;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
  font-family: inherit;
}

.btn:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--color-accent);
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background: var(--color-accent-hover);
}

.btn-primary:disabled {
  background: var(--color-accent-disabled);
  cursor: not-allowed;
}

.btn-secondary {
  background: transparent;
  color: var(--color-accent);
  border: 1px solid var(--color-border);
}

.btn-secondary:hover {
  background: var(--color-surface);
  border-color: var(--color-accent);
}

#back-button:not(.hidden) + #next-button,
#back-button:not(.hidden) + #submit-button {
  margin-left: auto;
}

.footer-note {
  text-align: center;
  margin-top: 32px;
  font-size: 0.85rem;
}

/* ----- Mobile ----- */
@media (max-width: 600px) {
  .container {
    padding: 24px 16px 48px;
  }

  h1 {
    font-size: 1.5rem;
  }

  .question {
    padding: 16px 18px;
  }

  .btn {
    padding: 12px 20px;
    font-size: 0.95rem;
  }

  .nav-buttons {
    flex-direction: column-reverse;
    align-items: stretch;
  }

  .nav-buttons .btn {
    width: 100%;
  }

  #back-button:not(.hidden) + #next-button,
  #back-button:not(.hidden) + #submit-button {
    margin-left: 0;
  }
}

/* ----- Saving indicator ----- */
.saving {
  display: inline-block;
  margin-left: 12px;
  color: var(--color-text-muted);
  font-size: 0.85rem;
}
