* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
  min-height: 100vh;
  min-height: -webkit-fill-available;
  padding: 24px 16px;
  padding-top: max(24px, env(safe-area-inset-top));
  padding-bottom: max(24px, env(safe-area-inset-bottom));
  color: #1d1d1f;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  word-break: keep-all;
  overflow-wrap: break-word;
}

html { height: -webkit-fill-available; }

.container { max-width: 560px; margin: 0 auto; }

.card {
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.6);
  padding: 28px 20px;
  margin-bottom: 16px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
}

.card-header { text-align: center; margin-bottom: 24px; }
.card-header h1 { font-size: 22px; font-weight: 700; margin-bottom: 6px; }
.card-header p { font-size: 14px; color: #6e6e73; }

.section-title { font-size: 15px; font-weight: 600; color: #1d1d1f; margin-bottom: 12px; }
.question-label { font-size: 15px; font-weight: 600; margin-bottom: 10px; line-height: 1.6; }
.question-group { margin-bottom: 20px; }

.radio-group, .checkbox-group { display: flex; flex-direction: column; gap: 10px; }

.radio-option, .checkbox-option {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 14px 16px; border-radius: 12px; border: 1.5px solid #e5e5ea;
  cursor: pointer; transition: all 0.2s ease; font-size: 15px; line-height: 1.5;
  -webkit-user-select: none; user-select: none;
}

.radio-option:active, .checkbox-option:active {
  transform: scale(0.98); background: rgba(0, 122, 255, 0.06);
}

.radio-option.selected, .checkbox-option.selected {
  border-color: #007aff; background: rgba(0, 122, 255, 0.08);
}

.checkbox-option.disabled { opacity: 0.4; pointer-events: none; }

.radio-option input, .checkbox-option input {
  margin-top: 3px; min-width: 18px; min-height: 18px; accent-color: #007aff;
}

textarea {
  width: 100%; min-height: 88px; border: 1.5px solid #e5e5ea; border-radius: 12px;
  padding: 14px 16px; font-size: 16px; font-family: inherit; resize: vertical;
  transition: border-color 0.2s; -webkit-appearance: none;
}
textarea:focus { outline: none; border-color: #007aff; }

select {
  width: 100%; padding: 14px 16px; border: 1.5px solid #e5e5ea; border-radius: 12px;
  font-size: 16px; font-family: inherit; background: #fff;
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%236e6e73'%3E%3Cpath d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 16px center; cursor: pointer;
}
select:focus { outline: none; border-color: #007aff; }

.hidden { display: none; }

/* Progress bar */
.progress-wrap { position: sticky; top: 0; z-index: 10; padding-bottom: 10px; }
.progress-bar {
  height: 6px; border-radius: 3px; background: rgba(255, 255, 255, 0.5);
  overflow: hidden; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}
.progress-fill {
  height: 100%; width: 0%; background: #007aff; border-radius: 3px;
  transition: width 0.35s ease;
}

/* Step navigation */
.step { animation: stepIn 0.25s ease; }
@keyframes stepIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

.step-nav { display: flex; gap: 10px; margin-top: 8px; }
.step-nav .prev-btn, .step-nav .next-btn, .step-nav .submit-btn { flex: 1; margin: 0; }
.prev-btn {
  padding: 16px; border: 1.5px solid #e5e5ea; border-radius: 14px;
  background: rgba(255, 255, 255, 0.6); color: #1d1d1f; font-size: 16px; font-weight: 600;
  cursor: pointer; transition: opacity 0.2s; -webkit-appearance: none;
}
.prev-btn:active { opacity: 0.6; }
.next-btn {
  padding: 16px; border: none; border-radius: 14px;
  background: #007aff; color: #fff; font-size: 16px; font-weight: 600;
  cursor: pointer; transition: opacity 0.2s; -webkit-appearance: none;
}
.next-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.next-btn:active:not(:disabled) { opacity: 0.75; }

/* Color rank two-select row */
.rank-group { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* OOS three-step row */
#oos-add-row {
  display: grid; grid-template-columns: 1fr 1fr 1fr auto; gap: 8px; margin-top: 12px;
}
#oos-add-row select { padding: 10px 12px; font-size: 14px; }

.add-btn {
  padding: 10px 16px; border: none; border-radius: 12px;
  background: #34C759; color: #fff; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: opacity 0.2s; white-space: nowrap;
}
.add-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.add-btn:active:not(:disabled) { opacity: 0.75; }

.oos-tag {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: 10px; font-size: 14px;
  background: rgba(0, 122, 255, 0.08); border: 1px solid rgba(0, 122, 255, 0.2);
  margin: 4px 4px 4px 0;
}

.oos-tag .remove-btn {
  background: none; border: none; color: #ff3b30; font-size: 16px;
  cursor: pointer; padding: 0 2px; line-height: 1;
}

.submit-btn {
  width: 100%; padding: 16px; border: none; border-radius: 14px;
  background: #007aff; color: #fff; font-size: 17px; font-weight: 600;
  cursor: pointer; transition: opacity 0.2s; -webkit-appearance: none;
}
.submit-btn:active { opacity: 0.75; transform: scale(0.98); }
.submit-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.success-msg { text-align: center; padding: 40px 20px; }
.success-msg h2 { font-size: 20px; margin-bottom: 8px; }
.success-msg p { color: #6e6e73; font-size: 14px; }

.error-toast {
  position: fixed; bottom: max(24px, env(safe-area-inset-bottom, 24px));
  left: 50%; transform: translateX(-50%);
  background: #ff3b30; color: #fff; padding: 12px 20px; border-radius: 10px;
  font-size: 14px; font-weight: 500; z-index: 9999;
  animation: fadeInUp 0.3s ease; box-shadow: 0 4px 12px rgba(255, 59, 48, 0.3);
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@supports (-webkit-touch-callout: none) {
  select, textarea, input { font-size: 16px; }
}

@media (max-width: 390px) {
  .card { padding: 24px 16px; }
  .radio-option, .checkbox-option { padding: 12px 14px; }
  #oos-add-row { grid-template-columns: 1fr 1fr; }
}
