/* === RESET & BASE === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --color-bg: #f5f7fa;
  --color-surface: #ffffff;
  --color-primary: #2563eb;
  --color-primary-hover: #1d4ed8;
  --color-primary-light: #dbeafe;
  --color-text: #1e293b;
  --color-text-secondary: #64748b;
  --color-border: #e2e8f0;
  --color-error: #dc2626;
  --color-error-bg: #fef2f2;
  --color-success: #16a34a;
  --color-success-bg: #f0fdf4;
  --color-warning: #d97706;
  --color-warning-bg: #fffbeb;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-lg: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --max-width: 640px;
}

html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  min-height: 100dvh;
}

/* === LAYOUT === */
#app {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 1rem;
  padding-bottom: 2rem;
}

/* === PROGRESS BAR === */
.progress-container {
  background: var(--color-border);
  border-radius: 999px;
  height: 8px;
  margin-bottom: 0.75rem;
  position: relative;
  overflow: hidden;
}
.progress-bar {
  background: var(--color-primary);
  height: 100%;
  border-radius: 999px;
  transition: width 0.3s ease;
  width: 0%;
}
.progress-label {
  display: block;
  font-size: 0.8rem;
  color: var(--color-text-secondary);
  margin-top: 0.35rem;
  text-align: center;
}

/* === NOTICE BANNER === */
.notice-banner {
  background: var(--color-warning-bg);
  border: 1px solid var(--color-warning);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin-bottom: 1.25rem;
  font-size: 0.85rem;
  color: #92400e;
  line-height: 1.5;
}
.notice-banner strong { display: block; margin-bottom: 0.15rem; }

/* === SCREEN === */
.screen {
  animation: fadeIn 0.25s ease;
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  margin-bottom: 1rem;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.screen-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
  color: var(--color-text);
}
.screen-subtitle {
  font-size: 0.875rem;
  color: var(--color-text-secondary);
  margin-bottom: 1.25rem;
}

/* === FORM FIELDS === */
.form-group {
  margin-bottom: 1rem;
}
.form-group:last-child { margin-bottom: 0; }

label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
  color: var(--color-text);
}
label .required {
  color: var(--color-error);
  margin-left: 2px;
}
label .optional {
  font-weight: 400;
  color: var(--color-text-secondary);
  font-size: 0.8rem;
  margin-left: 0.3rem;
}

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="url"],
select,
textarea {
  width: 100%;
  padding: 0.65rem 0.85rem;
  font-size: 1rem;
  font-family: var(--font);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  color: var(--color-text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  -webkit-appearance: none;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-light);
}
input.error, select.error, textarea.error {
  border-color: var(--color-error);
  box-shadow: 0 0 0 3px var(--color-error-bg);
}
textarea {
  min-height: 100px;
  resize: vertical;
}
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.85rem center;
  padding-right: 2.25rem;
}

/* Checkbox / radio groups */
.checkbox-group, .radio-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.checkbox-label, .radio-label {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  font-weight: 400;
  cursor: pointer;
  padding: 0.5rem 0.75rem;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius);
  transition: border-color 0.15s ease, background 0.15s ease;
}
.checkbox-label:has(input:checked), .radio-label:has(input:checked) {
  border-color: var(--color-primary);
  background: var(--color-primary-light);
}
.checkbox-label input, .radio-label input {
  margin-top: 0.2rem;
  accent-color: var(--color-primary);
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
}
.checkbox-label .label-text, .radio-label .label-text {
  font-size: 0.9rem;
  line-height: 1.4;
}

/* Other field */
.other-field {
  margin-top: 0.5rem;
  display: none;
}
.other-field.visible { display: block; }

/* Field error */
.field-error {
  font-size: 0.8rem;
  color: var(--color-error);
  margin-top: 0.25rem;
  display: none;
}
.field-error.visible { display: block; }

/* === NAVIGATION === */
.nav-buttons {
  display: flex;
  gap: 0.75rem;
  justify-content: space-between;
  padding: 0 0.125rem;
}

.btn {
  padding: 0.7rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  font-family: var(--font);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s ease, opacity 0.15s ease;
  min-width: 110px;
  text-align: center;
}
.btn:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn-primary {
  background: var(--color-primary);
  color: #fff;
}
.btn-primary:hover:not(:disabled) { background: var(--color-primary-hover); }
.btn-secondary {
  background: var(--color-surface);
  color: var(--color-text);
  border: 1.5px solid var(--color-border);
}
.btn-secondary:hover:not(:disabled) { background: var(--color-bg); }

/* === ERROR SUMMARY === */
.error-summary {
  background: var(--color-error-bg);
  border: 1px solid var(--color-error);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  color: var(--color-error);
  font-size: 0.9rem;
}
.error-summary ul { margin: 0.25rem 0 0 1.25rem; }

/* === SUCCESS === */
.success-message {
  background: var(--color-success-bg);
  border: 1px solid var(--color-success);
  border-radius: var(--radius-lg);
  padding: 2rem;
  text-align: center;
  box-shadow: var(--shadow);
}
.success-message h2 { color: var(--color-success); margin-bottom: 0.5rem; }

/* === SPINNER === */
.spinner {
  display: inline-block;
  width: 1rem;
  height: 1rem;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
  margin-right: 0.35rem;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* === MOBILE === */
@media (max-width: 480px) {
  #app { padding: 0.75rem; padding-bottom: 1.5rem; }
  .screen { padding: 1.25rem; }
  .screen-title { font-size: 1.15rem; }
  .btn { padding: 0.65rem 1rem; min-width: 90px; font-size: 0.95rem; }
  .notice-banner { font-size: 0.8rem; padding: 0.6rem 0.75rem; }
}

/* === REDUCED MOTION === */
@media (prefers-reduced-motion: reduce) {
  .screen { animation: none; }
  .progress-bar { transition: none; }
  .spinner { animation: none; }
}