:root {
  --bg: #f4f7f6;
  --card: #ffffff;
  --text: #1d2a28;
  --muted: #5b6b68;
  --line: #d5dfdc;
  --brand: #0f7a6c;
  --brand-dark: #0a5d52;
  --brand-soft: #e3f3f0;
  --error: #c62828;
  --error-soft: #fdecec;
  --line-green: #06c755;
  --radius: 14px;
  color-scheme: light;
}

* { 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", "Hiragino Kaku Gothic ProN", "Noto Sans JP", sans-serif;
  font-size: 18px;
  line-height: 1.6;
  padding-bottom: env(safe-area-inset-bottom);
}

/* ---------- ヘッダー ---------- */
.top {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--brand);
  color: #fff;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
}
.brand { font-size: 13px; opacity: .85; letter-spacing: .05em; }
.top h1 { margin: 0; font-size: 20px; line-height: 1.4; }
.progress { margin-top: 8px; }
.progress[hidden] { display: none; }
.progress-track { height: 6px; background: rgba(255, 255, 255, .3); border-radius: 3px; overflow: hidden; }
.progress-bar { height: 100%; width: 0; background: #fff; transition: width .3s; }
.progress-label { margin: 4px 0 0; font-size: 13px; opacity: .9; }

/* ---------- ステップ ---------- */
main { max-width: 640px; margin: 0 auto; padding: 16px 16px 32px; }
.step h2 { font-size: 22px; margin: 4px 0 8px; }
.intro { color: var(--muted); margin: 0 0 16px; font-size: 16px; }

.field {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}
.field[hidden] { display: none; }
.field.sub {
  margin-top: -6px;
  margin-left: 12px;
  border-left: 4px solid var(--brand);
  background: #fbfdfc;
}
.field.has-error { border-color: var(--error); background: var(--error-soft); }

.label { font-weight: 700; margin-bottom: 10px; }
.req {
  display: inline-block;
  margin-left: 8px;
  padding: 0 6px;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  background: var(--error);
  border-radius: 4px;
  vertical-align: 2px;
}
.note { font-size: 14px; color: var(--muted); margin: -4px 0 10px; }
.hint { font-size: 14px; color: var(--muted); margin: 8px 0 0; }
.err { color: var(--error); font-size: 15px; font-weight: 700; margin: 8px 0 0; }
.err:empty { display: none; }

/* ---------- 入力欄（iOS のズームを防ぐため 16px 以上） ---------- */
input[type="text"], input[type="tel"], textarea, select {
  width: 100%;
  font: inherit;
  font-size: 18px;
  color: var(--text);
  background: #fff;
  border: 2px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  -webkit-appearance: none;
  appearance: none;
}
textarea { resize: vertical; min-height: 3em; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--brand); }
::placeholder { color: #a3b0ad; }

.with-unit { display: flex; align-items: center; gap: 8px; }
.with-unit input { max-width: 10em; }
.unit { font-weight: 700; }

/* 生年月日 */
.dob { display: grid; grid-template-columns: 1.1fr 1fr 1fr 1fr; gap: 6px; }
.dob select {
  padding: 12px 6px;
  text-align: center;
  background-image: none;
}
.dob-age { margin: 8px 0 0; font-size: 15px; color: var(--brand-dark); font-weight: 700; }
.dob-age:empty { display: none; }

/* ---------- 選択肢ボタン ---------- */
.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; }
.choices.vertical { grid-template-columns: 1fr; }
.choice { position: relative; display: block; cursor: pointer; }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice span {
  display: flex;
  align-items: center;
  min-height: 52px;
  padding: 10px 14px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: #fff;
  font-weight: 600;
  justify-content: center;
  text-align: center;
  -webkit-tap-highlight-color: transparent;
  transition: background .15s, border-color .15s;
}
.choices.vertical .choice span { justify-content: flex-start; text-align: left; }
.choice input:checked + span {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: var(--brand-dark);
}
.choice input:focus-visible + span { outline: 3px solid rgba(15, 122, 108, .35); outline-offset: 2px; }

/* チェックボックスは左に☐/☑を表示 */
.checks .choice span::before {
  content: "";
  flex: none;
  width: 22px;
  height: 22px;
  margin-right: 12px;
  border: 2px solid #9fb0ac;
  border-radius: 6px;
  background: #fff;
}
.checks .choice input:checked + span::before {
  border-color: var(--brand);
  background: var(--brand) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/18px no-repeat;
}
.checks .choice.none { margin-top: 4px; }
.checks .choice.none span { border-style: dashed; }

/* はい/いいえ を横並びにする短い設問 */
.field.compact { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 8px 12px; }
.field.compact .label { margin: 0; font-weight: 600; }
.field.compact .req { display: none; }
.field.compact .choices { grid-template-columns: repeat(2, 76px); }
.field.compact .choice span { min-height: 46px; padding: 8px; }
.field.compact .err { grid-column: 1 / -1; margin: 0; }
@media (max-width: 360px) {
  .field.compact { grid-template-columns: 1fr; }
}

/* ---------- ナビゲーション ---------- */
.nav {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 10px;
  margin-top: 20px;
}
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 56px;
  padding: 12px 16px;
  font: inherit;
  font-size: 18px;
  font-weight: 700;
  border-radius: 14px;
  border: 2px solid transparent;
  text-decoration: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.btn.primary { background: var(--brand); color: #fff; }
.btn.primary:active { background: var(--brand-dark); }
.btn.primary:disabled { opacity: .6; }
.btn.ghost { background: #fff; color: var(--brand-dark); border-color: var(--line); }
.btn.line { background: var(--line-green); color: #fff; margin-top: 12px; }

/* ---------- 確認画面 ---------- */
.summary {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 12px;
}
.summary-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.summary h3 { margin: 0; font-size: 17px; color: var(--brand-dark); }
.link {
  background: none;
  border: none;
  color: var(--brand);
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  text-decoration: underline;
  padding: 8px 0 8px 8px;
  cursor: pointer;
}
.summary dl { margin: 8px 0 0; }
.summary dt { font-size: 14px; color: var(--muted); margin-top: 10px; }
.summary dd { margin: 2px 0 0; font-weight: 600; white-space: pre-wrap; overflow-wrap: anywhere; }

/* ---------- 完了画面 ---------- */
.done { text-align: center; padding-top: 24px; }
.done-mark {
  width: 72px;
  height: 72px;
  margin: 0 auto 12px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  font-size: 40px;
  line-height: 72px;
}
.test-note { font-size: 14px; color: var(--error); }
.line-card {
  margin-top: 24px;
  padding: 20px 16px;
  background: var(--card);
  border: 2px solid var(--line-green);
  border-radius: var(--radius);
}
.line-card h3 { margin: 0 0 8px; font-size: 18px; }
.line-card p { margin: 0; font-size: 16px; color: var(--muted); }

/* ---------- 入口ページ ---------- */
.menu { display: grid; gap: 12px; }
.menu-item {
  display: block;
  padding: 20px;
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  text-decoration: none;
}
.menu-item:active { border-color: var(--brand); background: var(--brand-soft); }
.menu-title { display: block; font-size: 22px; font-weight: 700; color: var(--brand-dark); }
.menu-sub { display: block; font-size: 15px; color: var(--muted); margin-top: 4px; }

/* ---------- LINE処方箋受付サービスの案内 ---------- */
.line-page h2 { color: var(--brand-dark); }
.flow { list-style: none; padding: 0; margin: 0 0 20px; display: grid; gap: 10px; }
.flow li {
  position: relative;
  display: flex;
  gap: 12px;
  padding: 14px 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.flow li + li::before {
  content: "▼";
  position: absolute;
  top: -15px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  color: #f0943c;
}
.flow-no {
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--line-green);
  color: #fff;
  font-weight: 700;
  text-align: center;
  line-height: 34px;
}
.flow h3 { margin: 2px 0 4px; font-size: 17px; }
.flow p { margin: 0; font-size: 15px; color: var(--muted); }

.line-card { text-align: center; }
.line-icon { display: block; margin: 0 auto 4px; border-radius: 20px; width: 160px; height: auto; }

.notice, .shop {
  margin: 20px 0;
  padding: 14px 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.notice h3, .shop h3 { margin: 0 0 6px; font-size: 17px; }
.notice ul { margin: 0; padding-left: 1.2em; font-size: 15px; }
.notice li { margin: 6px 0; }
.notice strong { color: var(--error); }
.shop p { margin: 0 0 8px; font-size: 15px; }
.shop a { color: var(--brand); font-weight: 700; }
.hours { border-collapse: collapse; font-size: 15px; }
.hours caption { text-align: left; font-weight: 700; padding-bottom: 4px; }
.hours th { text-align: left; font-weight: 600; padding: 2px 16px 2px 0; color: var(--muted); }
.hours td { padding: 2px 0; }

/* 見出しの1文字だけの改行を防ぐ */
h1, h2, h3 { text-wrap: balance; }
.submit-err { text-align: center; margin-top: 16px; }
.done-mark.blocked { background: #c2570c; }
.loading { text-align: center; padding: 40px 0; }
