/*
 * 患者向け画面のスタイル。スマホからの流入が大半である前提で、
 * モバイルファースト・大きめのタップ領域・高いコントラストを基本にする。
 */

:root {
  --bg: #f5f7f9;
  --surface: #ffffff;
  --text: #1c2a33;
  --text-muted: #5b6b77;
  --line: #dfe5ea;
  --accent: #0f7b8a;
  --accent-dark: #0b5f6b;
  --accent-soft: #e6f3f5;
  --error: #b3261e;
  --error-soft: #fdecea;
  --radius: 12px;
  --tap: 48px; /* 最小タップ領域 */
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Hiragino Sans', 'Noto Sans JP', 'Yu Gothic', Meiryo, sans-serif;
  font-size: 16px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

/* ---------- ヘッダ ---------- */
.header {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 16px 20px 12px;
  text-align: center;
}

.header__clinic {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}

.header__title {
  margin: 2px 0 0;
  font-size: 20px;
  font-weight: 700;
}

/* ---------- 進捗 ---------- */
.steps {
  display: flex;
  gap: 4px;
  margin: 0;
  padding: 14px 12px;
  list-style: none;
  max-width: 640px;
  margin-inline: auto;
}

.steps__item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.3;
}

.steps__num {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1.5px solid var(--line);
  background: var(--surface);
  font-size: 13px;
  font-weight: 700;
}

.steps__item[data-state='current'] {
  color: var(--accent-dark);
  font-weight: 700;
}

.steps__item[data-state='current'] .steps__num {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.steps__item[data-state='done'] .steps__num {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-dark);
}

/* ---------- レイアウト ---------- */
.main {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 12px 40px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 16px 24px;
}

.panel__title {
  margin: 0 0 16px;
  font-size: 18px;
  font-weight: 700;
}

.loading,
.empty {
  color: var(--text-muted);
  text-align: center;
  padding: 24px 8px;
  margin: 0;
}

/* ---------- 主訴・空き枠の選択 ---------- */
.category {
  margin-bottom: 22px;
}

.category__name {
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 700;
  color: var(--accent-dark);
  padding-left: 10px;
  border-left: 3px solid var(--accent);
}

.option-list {
  display: grid;
  gap: 8px;
}

.option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  min-height: var(--tap);
  padding: 12px 14px;
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: 10px;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.option:hover,
.option:focus-visible {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.option__name {
  font-weight: 600;
}

.option__meta {
  flex-shrink: 0;
  font-size: 12px;
  color: var(--text-muted);
}

.date-group {
  margin-bottom: 20px;
}

.date-group__date {
  margin: 0 0 8px;
  font-size: 15px;
  font-weight: 700;
}

.time-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 8px;
}

.time {
  min-height: var(--tap);
  padding: 10px 6px;
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: 10px;
  font: inherit;
  font-weight: 600;
  color: inherit;
  cursor: pointer;
}

.time:hover,
.time:focus-visible {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.selected-item,
.summary-line {
  margin: 0 0 16px;
  padding: 10px 12px;
  background: var(--accent-soft);
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--accent-dark);
}

/* ---------- フォーム ---------- */
.field {
  margin-bottom: 18px;
}

.field label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 14px;
  font-weight: 700;
}

.required,
.optional {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  line-height: 1.4;
}

.required {
  background: var(--error-soft);
  color: var(--error);
}

.optional {
  background: #eef1f4;
  color: var(--text-muted);
}

input[type='text'],
input[type='tel'],
input[type='email'],
input[type='date'],
textarea {
  width: 100%;
  min-height: var(--tap);
  padding: 11px 12px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: inherit;
  font: inherit;
  /* iOS の自動ズームを防ぐため 16px を下回らせない */
  font-size: 16px;
}

textarea {
  min-height: 96px;
  resize: vertical;
  line-height: 1.6;
}

input:focus,
textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}

input[aria-invalid='true'],
textarea[aria-invalid='true'] {
  border-color: var(--error);
  background: var(--error-soft);
}

.field__hint {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--text-muted);
}

.field__error {
  margin: 6px 0 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--error);
}

/* ---------- 確認 ---------- */
.confirm {
  margin: 0 0 18px;
  border-top: 1px solid var(--line);
}

.confirm > div {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 12px;
  padding: 12px 2px;
  border-bottom: 1px solid var(--line);
}

.confirm dt {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
}

.confirm dd {
  margin: 0;
  word-break: break-word;
  white-space: pre-wrap;
}

.confirm dd.is-empty {
  color: var(--text-muted);
}

/* ---------- 通知 ---------- */
.notice {
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 14px;
  margin-bottom: 18px;
}

.notice p {
  margin: 0;
}

/* 段落を続けたときだけ間を空ける。1段落の通知（既存）は見た目が変わらない。 */
.notice p + p {
  margin-top: 10px;
}

.notice--info {
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.notice--error {
  background: var(--error-soft);
  color: var(--error);
  font-weight: 600;
}

/* ---------- ボタン ---------- */
.actions {
  display: flex;
  gap: 10px;
  margin-top: 22px;
}

.btn {
  flex: 1;
  min-height: 52px;
  padding: 12px 16px;
  border-radius: 10px;
  border: 1.5px solid transparent;
  font: inherit;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  text-decoration: none;
}

.btn--primary {
  background: var(--accent);
  color: #fff;
}

.btn--primary:hover:not(:disabled) {
  background: var(--accent-dark);
}

.btn--primary:disabled {
  background: #a8bcc2;
  cursor: not-allowed;
}

.btn--ghost {
  background: var(--surface);
  border-color: var(--line);
  color: var(--text-muted);
  flex: 0 0 34%;
}

.btn--ghost:hover {
  border-color: var(--text-muted);
}

.btn--calendar {
  background: var(--surface);
  border-color: var(--accent);
  color: var(--accent-dark);
  width: 100%;
}

.btn--calendar:hover {
  background: var(--accent-soft);
}

/* ---------- 完了画面 ---------- */
.done {
  text-align: center;
  margin-bottom: 20px;
}

.done__mark {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  margin: 0 auto 12px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 30px;
  line-height: 1;
}

.done__lead {
  margin: 4px 0 0;
  color: var(--text-muted);
}

.calendar {
  margin: 22px 0;
  padding: 16px 14px;
  border: 1.5px dashed var(--accent);
  border-radius: var(--radius);
  background: var(--accent-soft);
}

.calendar__title {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 700;
  color: var(--accent-dark);
}

.calendar__lead {
  margin: 0 0 14px;
  font-size: 13px;
  color: var(--accent-dark);
}

.calendar__buttons {
  display: grid;
  gap: 10px;
}

.clinic-card {
  padding: 16px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 14px;
}

.clinic-card__name {
  margin: 0 0 8px;
  font-weight: 700;
  font-size: 15px;
}

.clinic-card__row {
  margin: 0 0 6px;
  color: var(--text-muted);
}

.clinic-card__note {
  margin: 12px 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 13px;
  color: var(--text-muted);
}

.tel {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent-dark);
  text-decoration: none;
  letter-spacing: 0.02em;
}

.fallback {
  text-align: center;
  margin: 0 0 18px;
}

.turnstile {
  display: flex;
  justify-content: center;
}

.turnstile:empty {
  display: none;
}

/* ---------- フッタ ---------- */
.footer {
  padding: 20px 12px 32px;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
}

.footer p {
  margin: 0;
}

/* ---------- 問診票 ---------- */

.panel__lead {
  margin: -4px 0 20px;
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-muted);
}

/* 予約時に入力済みの内容（再入力させない） */
.carried {
  margin-bottom: 24px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
}

.carried__title {
  margin: 0 0 10px;
  font-size: 14px;
  font-weight: 700;
}

.carried__note {
  margin: 10px 0 0;
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-muted);
}

/* ラジオ・チェックボックスの選択肢 */
.choice-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.choice {
  display: flex;
  align-items: center;
  gap: 10px;
  /* タップ領域を確保する。選択肢の取り違えは問診票では実害になる。 */
  min-height: var(--tap);
  padding: 4px 10px;
  border-radius: 10px;
}

.choice:hover {
  background: var(--accent-soft);
}

.choice input {
  flex: none;
  width: 22px;
  height: 22px;
  margin: 0;
  accent-color: var(--accent);
}

.choice label {
  /* .field label の flex/太字を打ち消す（選択肢のラベルは本文と同じ見た目にする） */
  display: block;
  flex: 1;
  margin: 0;
  font-size: 15px;
  font-weight: 400;
  line-height: 1.5;
  cursor: pointer;
}

.choice__other {
  margin-top: 6px;
}

.choice__other:disabled {
  background: #f1f4f6;
  color: var(--text-muted);
}

/* 生年月日から算出して表示する年齢（入力欄ではない） */
.field__derived {
  margin: 0;
  padding: 11px 12px;
  border: 1.5px dashed var(--line);
  border-radius: 10px;
  background: var(--bg);
  font-size: 16px;
  color: var(--text-muted);
}

/* 完了画面から問診票への導線 */
.questionnaire-cta {
  margin-top: 20px;
  padding: 18px 16px 20px;
  border: 1.5px solid var(--accent);
  border-radius: var(--radius);
  background: var(--accent-soft);
  text-align: center;
}

.questionnaire-cta__title {
  margin: 0 0 8px;
  font-size: 16px;
  font-weight: 700;
  color: var(--accent-dark);
}

.questionnaire-cta__lead {
  margin: 0 0 14px;
  font-size: 14px;
  line-height: 1.7;
}

.questionnaire-cta__note {
  margin: 10px 0 0;
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-muted);
}

@media (min-width: 600px) {
  .panel {
    padding: 28px 28px 32px;
  }

  .steps__item {
    font-size: 12px;
  }
}
