* {
  box-sizing: border-box;
}
body {
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", sans-serif;
  background: #f5f5f3;
  margin: 0;
}
.page {
  max-width: 640px;
  margin: 0 auto;
  padding: 20px 16px 100px;
}
h1 {
  font-size: 18px;
  margin-bottom: 20px;
}

.step label {
  display: block;
  font-size: 13px;
  color: #555;
  margin: 12px 0 4px;
}
.step input[type="text"],
.step input[type="number"],
.step select,
.step textarea {
  width: 100%;
  padding: 12px;
  border: 1px solid #ccc;
  border-radius: 8px;
  font-size: 16px;
}
.q-row {
  display: flex;
  gap: 16px;
}
.q-row > div {
  flex: 1;
}

button {
  padding: 14px 20px;
  border: none;
  border-radius: 8px;
  background: #1d6f57;
  color: #fff;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
}
#id-step button {
  width: 100%;
  margin-top: 20px;
}
button.btn-secondary {
  background: #999;
}
button.btn-add-row {
  background: #888;
  font-size: 13px;
  padding: 8px 14px;
  margin-top: 8px;
  width: auto;
}
.error {
  color: #a32d2d;
  font-size: 13px;
  margin-top: 8px;
}

/* 進捗バー */
.progress-track {
  height: 6px;
  background: #e2e2de;
  border-radius: 3px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: #1d6f57;
  transition: width 0.2s;
}
.progress-label {
  text-align: right;
  font-size: 12px;
  color: #777;
  margin: 6px 0 16px;
}

/* 質問カード */
.q-block {
  background: #fff;
  border: 1px solid #e5e5e2;
  border-radius: 12px;
  padding: 18px 16px;
}
.q-label {
  font-weight: bold;
  font-size: 16px;
  line-height: 1.5;
  margin: 0 0 6px;
}
.q-note {
  font-size: 12px;
  color: #888;
  margin: 0 0 14px;
  line-height: 1.5;
}
.q-category {
  font-weight: bold;
  color: #1d6f57;
  font-size: 14px;
  margin: 18px 0 8px;
}

/* 選択肢: タップしやすい大きめカード */
.choices {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
}
.choice {
  flex: 1 1 45%;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  border: 2px solid #ddd;
  border-radius: 10px;
  padding: 12px 10px;
  font-size: 15px;
  background: #fff;
  line-height: 1.4;
  transition:
    border-color 0.15s,
    background 0.15s;
}
/* ストレスチェックの同意: 左「同意しない」は通常の半分の大きさ、右「同意する」は1.5倍の大きさ */
.consent-choices {
  flex-wrap: nowrap;
  align-items: stretch;
} /* 2つのボタンの高さを揃える */
/* 文字を上下左右の中央に(iPhoneのSafariで、flexのままだと上に寄るため、gridで中央寄せにする) */
.consent-choices .choice {
  display: grid;
  place-items: center;
  height: 72px;
  min-height: 0;
  box-sizing: border-box;
  padding-top: 0;
  padding-bottom: 0;
  line-height: 1.2;
}
.consent-choices .choice > span {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  text-align: center;
} /* 念のため、文字の入れ物自体も、ボタンいっぱいに広げて中央寄せにする */
.consent-choices .choice[data-value="no"] {
  flex: 0 0 27%;
  padding: 0 2px;
  font-size: 11px;
  white-space: nowrap;
  border-width: 1px;
}
.consent-choices .choice[data-value="yes"] {
  flex: 1 1 0;
  font-size: 22px;
  font-weight: bold;
}
.choice-wide {
  flex-basis: 100%;
  justify-content: flex-start;
  text-align: left;
}
.choice input[type="radio"],
.choice input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.choice:has(input:checked) {
  border-color: #1d6f57;
  background: #e8f3ef;
  font-weight: bold;
}
.choice-none {
  background: #f6f6f4;
}
.choice-other input[type="text"],
.choice-other-input {
  width: 100%;
  margin-top: 10px;
  padding: 10px;
  border: 1px solid #ccc;
  border-radius: 8px;
  font-size: 15px;
}

.follow-up {
  margin-top: 16px;
  padding: 14px;
  background: #f7faf9;
  border-radius: 10px;
  border-left: 4px solid #1d6f57;
}

.table-scroll {
  overflow-x: auto;
  margin-top: 8px;
}
.q-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  min-width: 480px;
}
.q-table th,
.q-table td {
  border: 1px solid #ddd;
  padding: 6px;
  font-size: 13px;
}
.q-table input,
.q-table select {
  width: 100%;
  border: none;
  padding: 6px;
  font-size: 15px;
  background: transparent;
}

/* カード形式の表(治療歴など。1件ごとに枠で囲む) */
.card-list {
  margin-top: 8px;
}
.entry-card {
  border: 2px solid #cfe0da;
  border-radius: 12px;
  background: #fff;
  margin-bottom: 10px;
  overflow: hidden;
}
.entry-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #e8f1ee;
  color: #1d6f57;
  font-weight: bold;
  font-size: 14px;
  padding: 5px 12px;
}
button.btn-remove-entry {
  background: transparent;
  color: #a32d2d;
  font-size: 12px;
  font-weight: normal;
  padding: 2px 8px;
  width: auto;
  text-decoration: underline;
}
.card-line {
  display: flex;
  gap: 8px;
  padding: 6px 12px 0;
}
.card-line:last-child {
  padding-bottom: 8px;
}
.card-field {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.card-field-label {
  font-size: 12px;
  color: #666;
  margin-bottom: 2px;
  line-height: 1.3;
}
.card-field input,
.card-field select {
  width: 100%;
  box-sizing: border-box;
  padding: 7px 8px;
  border: 1px solid #ccc;
  border-radius: 8px;
  font-size: 15px;
  background: #fff;
  min-width: 0;
}
.card-field input + input,
.card-field select + input {
  margin-top: 6px;
}
button.btn-add-entry {
  display: block;
  width: 100%;
  padding: 12px;
  font-size: 15px;
  background: #1d6f57;
  margin-top: 0;
}

.confirm-text {
  font-size: 16px;
  margin-bottom: 20px;
}
#confirm-step button,
#done-step p {
  width: 100%;
}

.section-break {
  text-align: center;
  padding: 60px 20px;
  font-size: 16px;
  font-weight: bold;
  color: #1d6f57;
}

/* ストレスチェック等、同じスケールを共有する項目をまとめて表示するマトリクス */
.matrix-row {
  padding: 12px 0;
  border-bottom: 1px solid #eee;
}
.matrix-row:last-child {
  border-bottom: none;
}
.matrix-item-text {
  font-size: 14px;
  margin: 0 0 8px;
  line-height: 1.4;
}
.matrix-choices {
  display: flex;
  gap: 6px;
}
.matrix-choice {
  flex: 1;
  text-align: center;
  font-size: 11px;
  line-height: 1.3;
  border: 2px solid #ddd;
  border-radius: 8px;
  padding: 8px 4px;
  background: #fff;
}
.matrix-choice input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.matrix-choice:has(input:checked) {
  border-color: #1d6f57;
  background: #e8f3ef;
  font-weight: bold;
}

/* 下部固定ナビ */
.nav-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  gap: 10px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: #fff;
  border-top: 1px solid #ddd;
}
.nav-bar[hidden] {
  display: none;
}
.nav-bar button {
  flex: 1;
  margin: 0;
}
