/* ====== Base ====== */
* {
  box-sizing: border-box;
}
html,
body {
  height: 100%;
}
body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Noto Sans JP, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  color: #222;
  line-height: 1.6;
}

.container {
  max-width: 720px;
  margin: 40px auto;
  padding: 24px;
  background: #fff;
}

h1 {
  margin-top: 0;
  font-size: 1.75rem;
  letter-spacing: 0.02em;
}

.req {
  display: inline-block;
  margin-left: 0.4em;
  font-size: 0.8em;
  color: #c81e1e;
}

/* ====== Fields ====== */
.field {
  margin: 18px 0 20px;
  padding: 12px 14px;
  border-radius: 12px;
  background: #fafafa;
  outline: 2px solid #d1d5db;
  transition: outline-color 0.2s ease, background-color 0.2s ease;
}

.field label,
.field legend {
  display: block;
  font-weight: 600;
  margin-bottom: 8px;
}

fieldset.field[data-field="gender"] {
  border: none;
}

fieldset.field[data-field="gender"] input[type="radio"] {
  appearance: none; /* 各ブラウザ標準の丸ボタンを消す */
  -webkit-appearance: none; /* Safari対応 */
  -moz-appearance: none; /* Firefox対応 */
  margin: 0;
  width: 0;
  height: 0;
  position: absolute; /* 配置を崩さず非表示 */
  opacity: 0; /* 完全に見えなくする */
}

fieldset.field[data-field="gender"] label {
  background: #aaa;
  padding: 0.35em 2em 0.35em;
  border-radius: 1.5em;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

fieldset.field[data-field="gender"] input[type="radio"]:checked + label {
  background: #28a22a;
  color: #fff;
}

/* 「性別」文字（legend）の位置を微調整 */
fieldset.field[data-field="gender"] legend {
  font-weight: 600;
  font-size: 1rem;
  padding-top: 12px;
  margin-bottom: -3px;
}

/* ====== 入力要素の基本スタイル ====== */
input[type="text"],
textarea {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid #e5e7eb;
  border-radius: 10px;
  font-size: 16px;
  background: #fff;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

textarea {
  resize: vertical;
}

/* ====== 状態別カラー適用 ====== */

/* 通常時（まだvalid/invalidでない状態） */
input[type="text"]:focus,
textarea:focus {
  border-color: #2563eb; /* 青 */
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

/* valid: 常時 緑枠 */
.field.valid input[type="text"],
.field.valid textarea {
  border-color: #16a34a; /* 緑 */
  box-shadow: 0 0 0 2px rgba(22, 163, 74, 0.15);
}

/* invalid: 常時 赤枠 */
.field.invalid input[type="text"],
.field.invalid textarea {
  border-color: #dc2626; /* 赤 */
  box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.15);
}

/* フォーカス中でも valid/invalid 色を維持 */
.field.valid input[type="text"]:focus,
.field.valid textarea:focus {
  border-color: #16a34a;
  box-shadow: 0 0 0 4px rgba(22, 163, 74, 0.25);
}

.field.invalid input[type="text"]:focus,
.field.invalid textarea:focus {
  border-color: #dc2626;
  box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.25);
}

/* radio/checkbox inline labels */
fieldset.field label {
  display: inline-flex;
  align-items: center;
  /* gap: 8px; */
  margin-right: 16px;
  font-weight: 500;
}

/* ====== Error Box (red background with white text) ====== */
.error-box {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #ef4444;
  color: #fff;
  font-size: 0.95rem;
  display: none;
  white-space: pre-line;
}
.field.invalid .error-box {
  display: block;
}

/* ====== Buttons ====== */
.btn {
  display: inline-block;
  width: 100%;
  padding: 14px 18px;
  border: 0;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.06s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.btn.disabled {
  background: #e5e7eb;
  color: #9ca3af;
  cursor: not-allowed;
}

.btn:not(.disabled) {
  background: #2563eb;
  color: #fff;
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.25);
}
.btn:not(.disabled):hover {
  transform: translateY(-1px);
}

.placeholder-weak::placeholder {
  color: #9ca3af;
}

/* ▼ 追記・調整ここから */
.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center; /* 常にセンター揃え */
  overflow: hidden;
  padding: 10px 24px;
  font-size: 16px;
  border: none;
  border-radius: 6px;
  background: #007bff;
  color: #fff;
  cursor: pointer;
}

.btn-inner {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px; /* ✔と文字の間隔 */
}

/* ローディングバー */
.btn.loading::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 0%;
  background: #16a34a;
  animation: btn-loading 2s linear forwards;
}
@keyframes btn-loading {
  0% {
    width: 0%;
  }
  100% {
    width: 100%;
  }
}

/* SVGチェック */
.check-svg {
  width: 20px;
  height: 20px;
  display: none;
}
.btn.done .check-svg {
  display: inline-block;
}

/* 円のスタイル */
.check-circle {
  fill: none;
  stroke: rgba(255, 255, 255, 0.3);
  stroke-width: 2.5;
}

/* チェックマーク */
.check-path {
  fill: none;
  stroke: #fff;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 60;
  stroke-dashoffset: 60;
  transition: stroke-dashoffset 0.4s ease-out;
}

/* 完了後（緑化＋センター維持） */
.btn.success {
  background: #16a34a !important;
  color: #fff !important;
  box-shadow: 0 8px 18px rgba(22, 163, 74, 0.25) !important;
}

/* アニメを抑制（OS設定対応） */
@media (prefers-reduced-motion: reduce) {
  .check-path {
    transition: none;
  }
}
/* ▲ 追記ここまで */
