* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: system-ui, -apple-system, "Hiragino Sans", "Yu Gothic UI", sans-serif;
  background: #f4f6fa;
  color: #1f2937;
  -webkit-user-select: none;
}
button, input, select { touch-action: manipulation; font-family: inherit; }

/* 普通のWebページ式：コンテンツに合わせて伸びる、ブラウザが自然にスクロール */
#app {
  min-height: 100svh;
  max-width: 900px;
  margin: 0 auto;
  padding: 16px 20px calc(16px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
}
@supports not (min-height: 100svh) {
  #app { min-height: 100vh; }
}

.screen { display: flex; flex-direction: column; gap: 14px; }
.hidden { display: none !important; }

.progress { display: flex; gap: 8px; justify-content: center; padding: 2px 0; flex-shrink: 0; }
.progress .dot { width: 10px; height: 10px; border-radius: 50%; background: #d1d5db; }
.progress .dot.active { background: #0068c4; }
.progress .dot.done { background: #10b981; }

.step-label { text-align: center; font-size: clamp(15px, 4vw, 22px); font-weight: 700; color: #374151; flex-shrink: 0; }
.picker-label { font-size: clamp(13px, 3.2vw, 18px); font-weight: 600; color: #6b7280; flex-shrink: 0; }

.hint-friendly {
  text-align: center;
  font-size: clamp(12px, 3vw, 16px);
  color: #0068c4;
  background: #eff6ff;
  border-radius: 999px;
  padding: 5px 12px;
  align-self: center;
  flex-shrink: 0;
}
.hint-error {
  text-align: center;
  font-size: clamp(13px, 3.2vw, 16px);
  color: #b91c1c;
  background: #fee2e2;
  border-radius: 8px;
  padding: 8px 12px;
  flex-shrink: 0;
}

/* 全画面共通ヘッダー（ロゴ + 病院名） */
.site-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0 10px;
  border-bottom: 1px solid #e5e7eb;
  margin-bottom: 8px;
  flex-shrink: 0;
}
.site-header__logo {
  height: clamp(28px, 7vw, 40px);
  width: auto;
  display: block;
}
.site-header__name {
  font-size: clamp(16px, 4.4vw, 22px);
  font-weight: 700;
  color: #0068c4;
  letter-spacing: 0.04em;
}

/* Start画面廃止に伴い未使用化（2026-05-04）。.brand-logo は他画面で参照されていないため温存のみ */
.brand-logo { display: block; width: clamp(72px, 18vw, 120px); height: auto; margin: 0 auto; flex-shrink: 0; }
/* 完了/エラー画面は縦中央寄せで「アプリ感」を保つ（startは廃止） */
[data-screen="done"], [data-screen="error"] {
  justify-content: center;
  min-height: 70svh;
}

/* 「わからない」→電話相談画面 */
.phone-help-msg {
  text-align: center;
  font-size: clamp(15px, 4vw, 20px);
  color: #374151;
  line-height: 1.6;
  padding: 16px;
}
.phone-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: #5BA640;
  color: #fff;
  padding: clamp(24px, 6vw, 40px) clamp(20px, 5vw, 40px);
  border-radius: 20px;
  text-decoration: none;
  box-shadow: 0 6px 16px rgba(91, 166, 64, .3);
  margin: 8px auto;
  width: 100%;
  max-width: 480px;
  font-family: inherit;
}
.phone-link:active { transform: scale(.97); }
.phone-link.melmo-link { background: #0068c4; box-shadow: 0 6px 16px rgba(0, 104, 196, .3); }
.phone-link .phone-icon { font-size: clamp(36px, 9vw, 52px); }
.phone-link .phone-num { font-size: clamp(28px, 7vw, 42px); font-weight: 700; letter-spacing: 1px; font-family: ui-monospace, monospace; }
.phone-link .phone-sub { font-size: clamp(12px, 3vw, 14px); opacity: .9; }

/* スクロール促進ヒント（下に隠れたコンテンツがある時だけ表示） */
.scroll-hint {
  position: fixed;
  bottom: calc(20px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 104, 196, 0.92);
  color: #fff;
  padding: 8px 18px;
  border-radius: 999px;
  font-size: clamp(12px, 3vw, 14px);
  font-weight: 600;
  box-shadow: 0 4px 14px rgba(0, 104, 196, .3);
  pointer-events: none;
  z-index: 100;
  animation: scroll-hint-bounce 1.4s ease-in-out infinite;
}
@keyframes scroll-hint-bounce {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50%      { transform: translateX(-50%) translateY(-6px); }
}
.title { text-align: center; font-size: clamp(28px, 7.5vw, 48px); font-weight: 800; margin: 0; color: #0068c4; letter-spacing: 0.04em; }
.hospital-name { text-align: center; font-size: clamp(28px, 7vw, 44px); font-weight: 800; color: #0068c4; margin: 8px 0 0; letter-spacing: 0.04em; }
.hospital-area { text-align: center; font-size: clamp(13px, 3.2vw, 16px); color: #6b7280; margin: 2px 0 0; }
.subtitle { text-align: center; font-size: clamp(15px, 3.8vw, 20px); color: #6b7280; margin: 4px 0 0; line-height: 1.5; font-weight: 500; }

/* 全画面共通フッター（所在地・powered byロゴ） */
.site-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
  padding: 12px 20px calc(12px + env(safe-area-inset-bottom));
  font-size: clamp(11px, 2.8vw, 13px);
  color: #9ca3af;
  border-top: 1px solid #e5e7eb;
  background: #f4f6fa;
}
.site-footer__location { letter-spacing: 0.04em; }
.site-footer__powered {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  opacity: 0.75;
  font-size: clamp(10px, 2.4vw, 12px);
}
.site-footer__logo {
  height: clamp(16px, 4vw, 22px);
  width: auto;
  display: block;
}
.btn-start {
  margin: 12px auto 0;
  padding: clamp(16px, 4vw, 32px) clamp(40px, 12vw, 80px);
  font-size: clamp(20px, 5vw, 32px);
  font-weight: 700;
  background: #0068c4;
  color: #fff;
  border: none;
  border-radius: 18px;
  box-shadow: 0 6px 16px rgba(0,104,196,.3);
}
.btn-start:active { transform: scale(.97); }

/* Form fields */
.form { display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field .label {
  font-size: clamp(12px, 3vw, 14px);
  font-weight: 600;
  color: #6b7280;
}
.field .label .required {
  background: #dc2626; color: #fff;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 999px;
  margin-left: 6px;
}
.field input {
  font-size: clamp(16px, 4vw, 20px);
  padding: 12px 14px;
  border: 2px solid #d1d5db;
  border-radius: 10px;
  background: #fff;
  color: #111827;
  width: 100%;
}
.field input:focus { outline: none; border-color: #0068c4; }
.field textarea {
  font-family: inherit;
  font-size: clamp(15px, 4vw, 18px);
  padding: 12px 14px;
  border: 2px solid #d1d5db;
  border-radius: 10px;
  background: #fff;
  color: #111827;
  width: 100%;
  resize: vertical;
  min-height: 80px;
  line-height: 1.5;
  box-sizing: border-box;
}
.field textarea:focus { outline: none; border-color: #0068c4; }
.comment-counter {
  text-align: right;
  font-size: 12px;
  color: #9ca3af;
  margin-top: 2px;
}

/* 生年月日 — 年(4桁)・月(2桁)・日(2桁) のグループ表示 */
.dob-display {
  margin: 6px auto 4px;
  width: 100%;
  max-width: 480px;
  display: grid;
  grid-template-columns: 4fr 2fr 2fr;
  gap: 4px 10px;
  background: #fff;
  border: 2px solid #e5e7eb;
  border-radius: 12px;
  padding: 8px;
  box-sizing: border-box;
  align-self: center;
}
.dob-label {
  text-align: center;
  font-size: clamp(10px, 2.5vw, 12px);
  color: #6b7280;
  font-weight: 600;
  line-height: 1;
}
.dob-cells {
  display: grid;
  gap: 4px;
}
.dob-cells.cells-4 { grid-template-columns: repeat(4, 1fr); }
.dob-cells.cells-2 { grid-template-columns: repeat(2, 1fr); }
.dob-cell {
  aspect-ratio: 3 / 4;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: ui-monospace, "Menlo", monospace;
  font-size: clamp(20px, 5.5vw, 32px);
  font-weight: 700;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 7px;
  color: #d1d5db;
  min-height: 40px;
}
.dob-cell.filled { color: #111827; background: #fff; border-color: #0068c4; }
.dob-cell.error { border-color: #dc2626; background: #fef2f2; color: #dc2626; }

/* テンキー（生年月日入力用、3列4行） */
.numpad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  max-width: 380px;
  margin: 6px auto 0;
  width: 100%;
}
.numpad button {
  font-family: inherit;
  font-size: clamp(22px, 6vw, 32px);
  font-weight: 600;
  padding: clamp(10px, 3vw, 18px) 0;
  border: none;
  border-radius: 12px;
  background: #fff;
  color: #111827;
  box-shadow: 0 2px 6px rgba(0,0,0,.06);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-appearance: none;
  appearance: none;
  min-height: 44px;
}
.numpad button:active { background: #e0e7ff; transform: scale(.96); }
.numpad .key-clear { background: #fee2e2; color: #b91c1c; font-size: clamp(13px, 3.4vw, 18px); }
.numpad .key-back { background: #fef3c7; color: #92400e; font-size: clamp(18px, 5vw, 26px); }
.dob-hint {
  text-align: center;
  font-size: clamp(11px, 2.8vw, 13px);
  color: #6b7280;
  margin-top: 4px;
}
.dob-hint b { color: #0068c4; font-family: ui-monospace, monospace; }
.dob-preview {
  text-align: center;
  font-size: clamp(14px, 3.5vw, 18px);
  font-weight: 600;
  color: #0068c4;
  min-height: 1.4em;
  margin-top: 2px;
}
.dob-preview.error { color: #dc2626; }

/* 診療科ボタングリッド */
.dept-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}
.dept-btn {
  padding: 10px 6px;
  font-size: clamp(13px, 3.4vw, 16px);
  font-weight: 600;
  font-family: inherit;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  background: #fff;
  color: #111827;
  cursor: pointer;
  touch-action: manipulation;
  line-height: 1.2;
  min-height: 40px;
}
.dept-btn:active { transform: scale(.97); }
.dept-btn.selected { background: #0068c4; color: #fff; border-color: #0068c4; }
.dept-btn.dept-other { background: #f3f4f6; font-size: clamp(11px, 2.8vw, 13px); }
.dept-btn.dept-other.selected { background: #0068c4; color: #fff; }

/* 診療科カテゴリ別カラー */
/* 内科系：薄いブルー */
.dept-btn.dept-naika { background: #eff6ff; border-color: #bfdbfe; }
.dept-btn.dept-naika.selected { background: #0068c4; color: #fff; border-color: #0068c4; }

/* 外科系：薄いパープル */
.dept-btn.dept-geka { background: #f5f3ff; border-color: #ddd6fe; }
.dept-btn.dept-geka.selected { background: #0068c4; color: #fff; border-color: #0068c4; }

/* マイナー科：薄いレッド */
.dept-btn.dept-minor { background: #fef2f2; border-color: #fecaca; }
.dept-btn.dept-minor.selected { background: #0068c4; color: #fff; border-color: #0068c4; }

/* 自費診療科：薄いグリーン */
.dept-btn.dept-jihi { background: #f0fdf4; border-color: #bbf7d0; }
.dept-btn.dept-jihi.selected { background: #0068c4; color: #fff; border-color: #0068c4; }
.dept-btn.dept-jihi.selected .dept-tag { background: rgba(255,255,255,.25); color: #fff; }
.dept-tag {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 4px;
  background: #5BA640;
  color: #fff;
  margin-top: 2px;
  letter-spacing: .04em;
}

/* ===== Step1 ハブ画面 ===== */
/* メイン5ボタン：1=予約変更(全幅) / 2=再診・初診 / 3=オンライン・健診 */
.hub-main {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 8px 0;
}
.hub-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(16px, 5vw, 28px) 8px;
  border: none;
  border-radius: 18px;
  cursor: pointer;
  touch-action: manipulation;
  font-family: inherit;
  box-shadow: 0 4px 12px rgba(0,0,0,.12);
}
.hub-btn:active { transform: scale(.97); }
.hub-label { font-size: clamp(18px, 5vw, 26px); font-weight: 700; }

/* シンプル配色：master=濃青／4ボタン=白地に青枠 */
.hub-master {
  grid-column: 1 / -1;
  background: #0068c4;
  color: #ffffff;
  font-size: clamp(22px, 6vw, 30px);
}
.hub-master .hub-label { font-size: inherit; }
.hub-saishin,
.hub-shoshin,
.hub-online,
.hub-kenshin {
  background: #ffffff;
  color: #0068c4;
  border: 2px solid #0068c4;
}

/* サブ4ボタン（補助連絡手段・横一列） */
.hub-sub-label {
  text-align: center;
  font-size: clamp(12px, 3vw, 14px);
  color: #6b7280;
  margin-top: 8px;
  border-top: 1px solid #e5e7eb;
  padding-top: 12px;
}
.hub-sub-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.hub-sub-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 12px 4px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background: #f9fafb;
  color: #374151;
  text-decoration: none;
  font-family: inherit;
  cursor: pointer;
  touch-action: manipulation;
  text-align: center;
}
.hub-sub-btn:active { transform: scale(.97); }
.hub-sub-emoji { font-size: clamp(20px, 5.5vw, 28px); }
.hub-sub-text { font-size: clamp(11px, 2.8vw, 13px); font-weight: 700; line-height: 1.2; }

/* サブ4ボタン：単色統一（グレー） */
.hub-sub-btn--line,
.hub-sub-btn--ai,
.hub-sub-btn--tel,
.hub-sub-btn--kenshin {
  background: #f3f4f6;
  color: #374151;
  border-color: #d1d5db;
}
.hub-sub-btn--line .hub-sub-text,
.hub-sub-btn--ai .hub-sub-text,
.hub-sub-btn--tel .hub-sub-text,
.hub-sub-btn--kenshin .hub-sub-text { color: #374151; }
.hub-sub-btn--line:active,
.hub-sub-btn--ai:active,
.hub-sub-btn--tel:active,
.hub-sub-btn--kenshin:active { background: #e5e7eb; }

/* Big choice (初診/再診/オンラインなど) */
.big-choice {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  padding: 8px 0;
}
/* 縦並び（3択以上に向いている） */
.big-choice-vert {
  grid-template-columns: 1fr;
}
.choice {
  font-size: clamp(28px, 7vw, 52px);
  font-weight: 700;
  padding: clamp(28px, 8vw, 60px) 0;
  border: none;
  border-radius: 20px;
  color: #fff;
  box-shadow: 0 6px 16px rgba(0,0,0,.15);
  cursor: pointer;
  touch-action: manipulation;
  font-family: inherit;
}
.choice.yes { background: #0068c4; }       /* 再診（青：プライマリ） */
.choice.no { background: #6b7280; }        /* 初診（グレー） */
.choice.online { background: #5BA640; }    /* オンライン（公式アクセント緑） */
.choice:active { transform: scale(.97); }

/* Calendar */
.calendar {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 8px;
  cursor: pointer; /* iOS Safari の click 委譲には親 cursor も必要 */
}
.cal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 4px 4px 8px;
}
.cal-header .month-label { font-size: clamp(15px, 4vw, 18px); font-weight: 700; }
.cal-nav {
  width: 36px; height: 36px;
  border: none; background: #f3f4f6;
  border-radius: 8px;
  font-size: 18px; font-weight: 700;
  color: #0068c4;
}
.cal-nav:disabled { color: #d1d5db; background: #f9fafb; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal-dow {
  text-align: center;
  font-size: clamp(10px, 2.6vw, 13px);
  font-weight: 600;
  color: #6b7280;
  padding: 4px 0;
}
.cal-dow.sun { color: #dc2626; }
.cal-dow.sat { color: #2563eb; }
.cal-cell {
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(12px, 3.2vw, 16px);
  font-weight: 600;
  border: 1px solid transparent;
  border-radius: 6px;
  background: #fff;
  color: #111827;
  min-height: 28px;
  font-family: inherit;
  padding: 0;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-appearance: none;
  appearance: none;
}
.cal-cell:disabled { cursor: default; }
.cal-cell.empty { visibility: hidden; }
.cal-cell.disabled { color: #d1d5db; background: #f9fafb; cursor: default; }
.cal-cell.sun { color: #dc2626; }
.cal-cell.sat { color: #2563eb; }
.cal-cell.selectable:active { background: #dbeafe; }
.cal-cell.selected { background: #0068c4; color: #fff; border-color: #0068c4; }

/* Time grid */
.time-section { display: flex; flex-direction: column; gap: 8px; }
.time-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.time-grid button {
  font-size: clamp(15px, 4vw, 20px);
  font-weight: 600;
  padding: 12px 0;
  border: 2px solid #e5e7eb;
  border-radius: 10px;
  background: #fff;
  color: #111827;
}
.time-grid button.selected { background: #0068c4; color: #fff; border-color: #0068c4; }
.time-grid button:active { transform: scale(.97); }

/* Summary */
.summary { background: #fff; border-radius: 12px; padding: 14px 16px; }
.summary .row {
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 8px 0;
  border-bottom: 1px solid #e5e7eb;
  font-size: clamp(13px, 3.4vw, 17px);
  gap: 12px;
}
.summary .row:last-child { border-bottom: none; }
.summary .key { color: #6b7280; flex-shrink: 0; min-width: 70px; }
.summary .val { font-weight: 700; text-align: right; }

/* Footer buttons — テンキー等の上に明確な区切りを */
.footer {
  display: flex;
  gap: 10px;
  padding-top: 16px;
  margin-top: 16px;
  border-top: 1px solid #e5e7eb;
  flex-shrink: 0;
}
.btn-primary, .btn-secondary {
  flex: 1;
  padding: 14px 8px;
  font-size: clamp(16px, 4vw, 22px);
  font-weight: 700;
  border: none;
  border-radius: 12px;
  min-height: 50px;
}
.btn-primary { background: #0068c4; color: #fff; }
.btn-primary.big { padding: 18px; font-size: clamp(18px, 4.5vw, 26px); }
.btn-primary:disabled { background: #cbd5e1; }
.btn-primary:active:not(:disabled) { transform: scale(.97); }
.btn-secondary { background: #e5e7eb; color: #374151; }
.btn-secondary:active { transform: scale(.97); }

/* Done */
.done-mark { font-size: clamp(80px, 20vw, 140px); color: #10b981; text-align: center; line-height: 1; }
.done-msg { text-align: center; font-size: clamp(22px, 6vw, 36px); font-weight: 700; }
.done-detail { text-align: center; color: #374151; font-size: clamp(14px, 3.6vw, 18px); line-height: 1.6; padding: 0 12px; }
.done-warn {
  text-align: center;
  background: #fef3c7;
  color: #92400e;
  font-size: clamp(12px, 3vw, 14px);
  padding: 10px 14px;
  border-radius: 10px;
  margin: 4px 12px;
  line-height: 1.5;
}
.error-mark { font-size: clamp(80px, 20vw, 140px); color: #ef4444; text-align: center; line-height: 1; font-weight: 700; }
.error-detail { text-align: center; color: #6b7280; font-size: clamp(13px, 3vw, 16px); padding: 0 16px; }

/* 個人情報の取り扱い注記（Step8確認画面） */
.privacy-notice {
  font-size: clamp(11px, 2.8vw, 13px);
  color: #6b7280;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 10px 14px;
  line-height: 1.6;
  margin: 4px 0;
}

/* キャンセルボタン（ハブ画面） — 注意喚起の意味を込めた控えめな赤系 */
.hub-btn.hub-cancel {
  background: #fff;
  color: #b91c1c;
  border: 2px solid #fecaca;
}
.hub-btn.hub-cancel:active { transform: scale(.97); }

/* visit-type-select の 2ボタンレイアウト */
.hub-main.hub-main--two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 8px 0;
}
.hub-main--two .hub-btn {
  min-height: clamp(80px, 18vw, 120px);
  display: flex;
  align-items: center;
  justify-content: center;
}
.hub-sub-tip {
  display: block;
  font-size: clamp(10px, 2.4vw, 12px);
  font-weight: 500;
  opacity: 0.8;
  margin-top: 2px;
}
