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

body {
  font-family: 'Helvetica Neue', Arial, 'Hiragino Kaku Gothic ProN', 'Hiragino Sans', Meiryo, sans-serif;
  background: #f0f4f8;
  color: #1a202c;
  line-height: 1.6;
}

.sticky-top { position: sticky; top: 0; z-index: 100; }

.logo-bar {
  background: white;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid #e2e8f0;
}
.header-logo {
  height: 44px; width: auto;
  object-fit: contain;
}
.header {
  background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 100%);
  color: white;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}
.header-text { text-align: center; }
.header-text h1 { font-size: 1.3rem; font-weight: 700; letter-spacing: 0.05em; }
.header-text p  { font-size: 0.78rem; opacity: 0.8; margin-top: 3px; }

/* 言語切替バー */
.lang-bar {
  background: #1e3a5f;
  padding: 5px 12px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
}
.lang-btn {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.35);
  color: rgba(255,255,255,0.65);
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 0.7rem;
  line-height: 1.4;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}
.lang-btn:hover  { background: rgba(255,255,255,0.15); color: white; }
.lang-btn.active { background: white; color: #1e3a5f; border-color: white; font-weight: 700; }

.progress-container {
  background: #e2e8f0;
  padding: 9px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.progress-bar { flex: 1; height: 8px; background: #cbd5e0; border-radius: 4px; overflow: hidden; }
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #2563eb, #38bdf8);
  border-radius: 4px;
  transition: width 0.3s ease;
  width: 0%;
}
.progress-text { font-size: 0.8rem; color: #4a5568; white-space: nowrap; }

.container { max-width: 680px; margin: 0 auto; padding: 20px; }

.info-banner {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 20px;
  font-size: 0.85rem;
  color: #1e40af;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.info-banner-icon { font-size: 1.1rem; flex-shrink: 0; }

.section-card {
  background: white;
  border-radius: 16px;
  padding: 24px;
  margin-bottom: 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.section-title {
  font-size: 1rem;
  font-weight: 700;
  color: #2563eb;
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 2px solid #e2e8f0;
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-icon {
  width: 28px; height: 28px;
  background: #dbeafe;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

.question { margin-bottom: 24px; }
.question:last-child { margin-bottom: 0; }
/* キーボード表示時の自動スクロールが sticky な進捗バーの裏に隠れないよう余白を確保 */
.question, .sub-question, .num-input, .btn-submit { scroll-margin-top: var(--sticky-h, 150px); }

.question-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: #2d3748;
  margin-bottom: 10px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  flex-wrap: wrap;
}
.question-num {
  background: #2563eb;
  color: white;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  white-space: nowrap;
  margin-top: 2px;
  flex-shrink: 0;
}
.required-badge {
  background: #fee2e2;
  color: #dc2626;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  margin-top: 2px;
  flex-shrink: 0;
}

.radio-group { display: flex; flex-direction: column; gap: 8px; }
.radio-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: #f8fafc;
  border: 2px solid #e2e8f0;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0.9rem;
  user-select: none;
}
.radio-option:hover    { border-color: #93c5fd; background: #eff6ff; }
.radio-option.selected { border-color: #2563eb; background: #dbeafe; }
.radio-option input[type="radio"] {
  width: 18px; height: 18px;
  cursor: pointer;
  accent-color: #2563eb;
  flex-shrink: 0;
}
.option-num { display: none; }

.question.unanswered .radio-group {
  border: 2px solid #dc2626;
  border-radius: 10px;
  padding: 8px;
}
#q08-smoking.sub-unanswered {
  border: 2px solid #dc2626;
  border-radius: 8px;
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%  { transform: translateX(-6px); }
  60%  { transform: translateX(6px); }
  80%  { transform: translateX(-3px); }
}

.question-note {
  font-size: 0.78rem;
  color: #718096;
  margin-top: -4px;
  margin-bottom: 10px;
  line-height: 1.6;
}

.sub-question {
  background: #f0f4f8;
  border-radius: 8px;
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  padding: 0 14px;
  margin-top: 0;
  transition: max-height 0.35s ease, opacity 0.3s ease,
              padding-top 0.3s ease, padding-bottom 0.3s ease,
              margin-top 0.3s ease;
}
.sub-question.sub-question-open {
  max-height: 300px;
  opacity: 1;
  padding: 14px;
  margin-top: 10px;
}
.sub-question-label { font-size: 0.82rem; color: #4a5568; margin-bottom: 10px; font-weight: 600; }
.sub-question-row { display: flex; gap: 12px; flex-wrap: wrap; }
.sub-question-row .input-col { flex: 1; min-width: 120px; }
.input-row { display: flex; gap: 8px; align-items: center; }
.input-row input { flex: 1; }
.input-unit { font-size: 0.85rem; color: #718096; white-space: nowrap; }
.input-error { display: none; color: #dc2626; font-size: 0.75rem; margin-top: 5px; }
.input-error.show { display: block; }
.num-input.input-invalid { border-color: #dc2626 !important; background: #fff5f5 !important; }

.num-input {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid #e2e8f0;
  border-radius: 10px;
  font-size: 1rem;
  font-family: inherit;
  color: #2d3748;
  background: #f8fafc;
  transition: border-color 0.2s;
  -webkit-appearance: none;
  appearance: none;
}
.num-input:focus { outline: none; border-color: #2563eb; background: white; }

.btn-container { display: flex; gap: 12px; margin-top: 24px; }
.btn-submit {
  flex: 2;
  padding: 16px;
  background: linear-gradient(135deg, #2563eb, #1e40af);
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}
.btn-submit:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(37,99,235,0.4); }
.btn-clear {
  flex: 1;
  padding: 16px;
  background: white;
  color: #dc2626;
  border: 2px solid #fecaca;
  border-radius: 12px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}
.btn-clear:hover { background: #fee2e2; }

.modal-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.65);
  z-index: 300;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.show { display: flex; }
.modal-card {
  background: white;
  border-radius: 20px;
  padding: 32px 24px 24px;
  max-width: 360px;
  width: 100%;
  text-align: center;
  position: relative;
  max-height: 90vh;
  overflow-y: auto;
  animation: modalIn 0.25s ease;
}
@keyframes modalIn {
  from { transform: scale(0.9); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}
.modal-close {
  position: absolute;
  top: 12px; right: 12px;
  background: #64748b;
  border: none;
  border-radius: 50%;
  width: 36px; height: 36px;
  font-size: 1.2rem;
  color: white;
  cursor: pointer;
  line-height: 1;
}
.modal-close:hover { background: #475569; }
.qr-success-icon { font-size: 3rem; margin-bottom: 12px; }
.qr-title { font-size: 1.3rem; font-weight: 700; color: #1a202c; margin-bottom: 8px; }
.qr-subtitle { font-size: 0.85rem; color: #718096; margin-bottom: 8px; }
#qrcode { display: flex; justify-content: center; margin: 16px 0; }
#qrcode svg {
  display: block;
  width: 240px; height: 240px;
  border: 4px solid #f0f4f8;
  border-radius: 12px;
  padding: 8px;
  background: white;
}
.qr-longpress-hint {
  font-size: 13px;
  color: #555;
  text-align: center;
  margin: 12px 0 4px;
  line-height: 1.5;
}
.qr-instruction {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 10px;
  padding: 14px;
  font-size: 0.82rem;
  color: #166534;
  margin-top: 12px;
  line-height: 1.8;
}
.btn-download {
  display: block;
  width: 100%;
  margin-top: 14px;
  padding: 13px;
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}
.btn-download:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(37,99,235,0.4); }
.btn-download:active { transform: translateY(0); box-shadow: none; }

@media (max-width: 480px) {
  .container { padding: 12px; }
  .section-card { padding: 16px; }
  .header h1 { font-size: 1.1rem; }
  .header-logo { height: 36px; }
}

/* 回答再開の確認モーダル */
.resume-message {
  font-size: 0.95rem;
  line-height: 1.7;
  color: #334155;
  margin: 16px 0 24px;
}

/* 利用規約モーダル */
.tos-card {
  max-width: 560px;
  width: 92%;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  padding: 28px 24px 24px;
  text-align: left;
}
.tos-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: #1e3a5f;
  margin-bottom: 16px;
  text-align: center;
}
.tos-text {
  flex: 1;
  overflow-y: auto;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 16px;
  font-size: 0.88rem;
  line-height: 1.7;
  color: #334155;
  background: #f8fafc;
  margin-bottom: 20px;
  max-height: 50vh;
}
.tos-buttons {
  display: flex;
  gap: 12px;
  flex-direction: column;
}
.tos-btn-agree {
  padding: 14px;
  border-radius: 10px;
  border: none;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  background: linear-gradient(135deg, #2563eb, #1e40af);
  color: #fff;
  font-family: inherit;
  transition: all 0.2s;
}
.tos-btn-agree:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(37,99,235,0.4); }
.tos-btn-agree:active { transform: translateY(0); box-shadow: none; }
.tos-btn-decline {
  padding: 12px;
  border-radius: 10px;
  border: 1px solid #fecaca;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  background: #fff;
  color: #dc2626;
  font-family: inherit;
}
.tos-declined-msg {
  font-size: 1.05rem;
  color: #334155;
  text-align: center;
  padding: 40px 0 32px;
  line-height: 1.9;
}
.tos-page {
  min-height: 100vh;
  background: #f0f4f8;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 16px 40px;
}
.decline-card {
  background: white;
  border-radius: 20px;
  padding: 40px 28px 32px;
  max-width: 560px;
  width: 100%;
  text-align: center;
  animation: modalIn 0.25s ease;
}
.tos-btn-back {
  margin-top: 28px;
  padding: 13px 32px;
  border-radius: 10px;
  border: 1px solid #cbd5e1;
  background: white;
  color: #1e3a5f;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
