/* ELEMENT 予約フォーム — スマホ優先（PCでも崩れない）
 * 配色は elementgym-fit.com のLPから抽出したブランド色
 *   #ae987b ベージュ（アクセント） / #f5f3ef オフホワイト（地） / #1a1a1a 墨 / #666 本文グレー
 * 見出しは Shippori Mincho（LPと同じ）、本文は端末標準のゴシック
 */
:root {
  --brand: #ae987b;
  --brand-dark: #97815f;
  --bg: #f5f3ef;
  --surface: #fff;
  --ink: #1a1a1a;
  --muted: #666;
  --line: #e2ddd4;
  --ok: #2f7d5c;
  --danger: #c0392b;
  --choice-bg: #fffdfa;
  --choice-hover: #faf7f2;
  --choice-selected: var(--ink);
  --choice-selected-note: #d8cbb5;
  --choice-unavailable: #fafafa;
  --button-disabled: #cfcac1;
  --info-bg: #f4f1ea;
  --skeleton-start: #f0ece5;
  --skeleton-mid: #f7f4ef;
  --heading-weight: 700;
  --heading-marker: none;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(26, 26, 26, .06), 0 8px 24px rgba(26, 26, 26, .05);
  --sans: "Helvetica Neue", Arial, "Hiragino Kaku Gothic ProN", "Hiragino Sans", "BIZ UDPGothic", Meiryo, sans-serif;
  --serif: "Shippori Mincho", serif;
}

:root[data-theme="lp-pilates"] {
  --bg: #ffffff;
  --surface: #ffffff;
  --ink: #404040;
  --brand: #bfb192;
  --choice-bg: #f4f4f4;
  --choice-hover: #f4f4f4;
  --choice-selected: #404040;
  --choice-selected-note: #ffffff;
  --sans: "游ゴシック体", YuGothic, "Yu Gothic", "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
  --serif: var(--sans);
  --heading-weight: 700;
  --heading-marker: linear-gradient(transparent 70%, #fff200 70%);
}

:root[data-theme="lp-personal"] {
  --bg: #ffffff;
  --surface: #ffffff;
  --ink: #404040;
  --brand: #e0a800;
  --choice-bg: #fff8e0;
  --choice-hover: #fff8e0;
  --choice-selected: #404040;
  --choice-selected-note: #ffffff;
  --sans: "LINE Seed JP", "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, sans-serif;
  --serif: var(--sans);
  --heading-weight: 700;
  --heading-marker: linear-gradient(transparent 70%, #ffe66d 70%);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;              /* iOS で入力時に拡大されない最小値 */
  line-height: 1.7;
  -webkit-text-size-adjust: 100%;
}

.wrap { max-width: 480px; margin: 0 auto; padding: 0 16px 120px; }

/* ── ヘッダー ───────────────────────────── */
.hd {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.hd-in { max-width: 480px; margin: 0 auto; padding: 12px 16px; }
.hd-title { font-family: var(--serif); font-size: 17px; font-weight: var(--heading-weight); margin: 0; letter-spacing: .04em; }
.hd-title, .card h2 { background-image: var(--heading-marker); }
:root[data-theme] .hd-title, :root[data-theme] .card h2 {
  width: fit-content; max-width: 100%;
  -webkit-box-decoration-break: clone; box-decoration-break: clone;
}
.hd-sub { font-size: 12px; color: var(--muted); margin: 2px 0 0; }

/* ステップ表示: 現在地が一目で分かる（3つだけなので点で足りる） */
.steps { display: flex; gap: 6px; margin-top: 10px; }
.steps li { flex: 1; list-style: none; font-size: 11px; color: var(--muted); text-align: center; }
.steps li::before {
  content: ""; display: block; height: 3px; border-radius: 2px;
  background: var(--line); margin-bottom: 5px;
}
.steps li[aria-current="step"] { color: var(--ink); font-weight: 700; }
.steps li[aria-current="step"]::before,
.steps li.done::before { background: var(--brand); }

/* ── カード ───────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; margin-top: 16px;
}
.card h2 { font-family: var(--serif); font-size: 16px; font-weight: var(--heading-weight); margin: 0 0 4px; }
.card .note { font-size: 13px; color: var(--muted); margin: 0 0 14px; }

/* ── カレンダー ───────────────────────────
 * 🔑 このフォームの肝。押す前に「その日に空きがあるか」が分かる。
 *    参考にした BOOKOM も現行の外注版も、押してから「空きがありません」と返す作りだった。 */
.cal-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.cal-month { font-family: var(--serif); font-size: 15px; }
.cal-btn {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  width: 40px; height: 36px; border-radius: 8px; font-size: 15px; cursor: pointer;
}
.cal-btn:disabled { opacity: .3; cursor: default; }

.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal-dow { font-size: 11px; color: var(--muted); text-align: center; padding-bottom: 4px; }
.cal-dow.sun { color: #c0705f; }
.cal-dow.sat { color: #5f7fa0; }

.day {
  aspect-ratio: 1 / 1; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); color: var(--ink);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1px; padding: 0; cursor: pointer; font-family: inherit;
  min-width: 0;
  min-height: 44px;             /* タップ領域を潰さない */
}
.day .d { font-size: 15px; line-height: 1; }
.day .n { font-size: 10px; color: var(--brand-dark); line-height: 1; }
.day.empty { border: none; background: none; cursor: default; }
.day.none, .day[aria-disabled="true"] { color: #bbb; background: var(--choice-unavailable); cursor: default; }
.day.none .n { color: #bbb; }
.day.has { border-color: var(--brand); background: var(--choice-bg); }
.day.has:hover { background: var(--choice-hover); }
/* 🔴 選択状態は hover より必ず強くする。
   `.day.has:hover`(0,3,0) が `.day[aria-pressed]`(0,2,0) に勝ってしまい、
   選択中のセルにカーソルが乗ると「白文字 × 明るい背景」で読めなくなっていた（実画面で発見）。 */
.day[aria-pressed="true"],
.day[aria-pressed="true"]:hover { background: var(--choice-selected); border-color: var(--choice-selected); color: #fff; }
.day[aria-pressed="true"] .n { color: var(--choice-selected-note); }
.day.loading { color: #ccc; }

/* 空きの記号（2026-10-26 森さま選択「B」）: ◎ 空きあり／残N 残りわずか（色付き）／× 空きなし */
.day.has .n { font-size: 11px; }
.day.few .n { color: var(--danger); font-weight: bold; }
.day[aria-pressed="true"].few .n { color: var(--choice-selected-note); }

.cal-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 11px; color: var(--muted); margin-top: 10px; }
.cal-legend b { margin-right: 4px; font-weight: bold; }
.cal-legend .m-has { color: var(--brand-dark); }
.cal-legend .m-few { color: var(--danger); }
.cal-legend .m-none { color: #bbb; }

/* 選んだ日時: 開いた時は最短の空きを選んだ状態。お客様が選び直すとここが変わる */
.picked {
  display: flex; flex-direction: column; gap: 2px;
  margin: 0 0 12px; padding: 10px 12px; border: 2px solid var(--brand); border-radius: 12px;
  background: var(--choice-bg); color: var(--ink);
}
.picked small { font-size: 11px; color: var(--muted); }
.picked strong { font-size: 15px; }
.picked-note { font-size: 11px; color: var(--brand-dark); }
.picked-note:empty { display: none; }
/* 埋め込み時の「選んだ日時」直下の進むボタン。固定しない（親LPの固定要素と重ねない）＝body.embedded .actions と同じ方針 */
.picked .picked-next { margin-top: 8px; width: 100%; flex: none; }

/* ── 時間 ───────────────────────────── */
.times { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
@media (max-width: 360px) { .times { grid-template-columns: repeat(2, 1fr); } }
.time {
  min-height: 46px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); color: var(--ink); font-size: 15px;
  font-family: inherit; cursor: pointer;
}
.time:hover { border-color: var(--brand); background: var(--choice-hover); }
.time-retry { grid-column: 1 / -1; }
.time[aria-pressed="true"],
.time[aria-pressed="true"]:hover { background: var(--choice-selected); border-color: var(--choice-selected); color: #fff; }

/* ── フォーム ───────────────────────────── */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 700; margin-bottom: 6px; }
.field .req { color: var(--danger); font-size: 11px; font-weight: 400; margin-left: 6px; }
.field input, .field select {
  width: 100%; min-height: 48px; padding: 10px 12px; font-size: 16px; font-family: inherit;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink);
}
.field input:focus, .field select:focus { outline: 2px solid var(--brand); outline-offset: 1px; border-color: var(--brand); }
.field .err { color: var(--danger); font-size: 12px; margin-top: 4px; display: none; }
.field.invalid input { border-color: var(--danger); }
.field.invalid .err { display: block; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ── 確認・サマリー ───────────────────────────── */
.summary { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.summary div { display: flex; padding: 10px 12px; font-size: 14px; border-bottom: 1px solid var(--line); }
.summary div:last-child { border-bottom: none; }
.summary dt { width: 84px; color: var(--muted); flex: none; margin: 0; font-size: 13px; }
.summary dd { margin: 0; font-weight: 700; }

@media (max-width: 380px) {
  .wrap { padding-right: 10px; padding-left: 10px; }
  .hd-in { padding-right: 10px; padding-left: 10px; }
  .card { padding: 12px; }
  .cal-grid { gap: 3px; }
  .day { aspect-ratio: auto; }
  .day .d { font-size: 14px; }
  .row2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .summary dd { min-width: 0; overflow-wrap: anywhere; }
}

/* ── ボタン ───────────────────────────── */
.actions {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: rgba(255,255,255,.94); backdrop-filter: blur(6px);
  border-top: 1px solid var(--line);
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
}
.actions-in { max-width: 480px; margin: 0 auto; display: flex; gap: 10px; }

/* 🔴 埋め込み（iframe）では CTA を固定しない。
   iframe の高さ＝コンテンツ高（embed.js が postMessage で合わせる）なので、fixed にすると
   CTA が iframe の下端に貼り付き、**親LPの固定要素と重なって押せなくなる**。
   2026-09-18 実測: 柏LPのバナー（z-index:10000）が予約ボタンを完全に覆い、
   elementFromPoint が IMG.st-pc を返した（フォーム側は z-index:30）。
   ⚠️ 単独ページ（/）は従来どおり fixed のまま。狭い画面でも常に押せる形が要るため。 */
body.embedded .actions {
  position: static; z-index: auto;
  background: transparent; backdrop-filter: none; border-top: 0;
  padding: 4px 16px calc(16px + env(safe-area-inset-bottom));
}
body.embedded .wrap { padding-bottom: 8px; }   /* fixed CTA 用に空けていた 120px は不要 */

/* 受付を止めている店が指定された時は、案内と電話番号だけ残す。
   予約に進む導線を残すと、お客様が入力してから断られることになる。 */
body.store-unavailable .card:not(#unavailableCard),
body.store-unavailable .actions,
body.store-unavailable .steps { display: none; }
.btn {
  flex: 1; min-height: 52px; border-radius: 10px; font-size: 16px; font-weight: 700;
  font-family: inherit; cursor: pointer; border: 1px solid transparent;
}
.btn-primary { background: var(--ink); color: #fff; }
.btn-primary:disabled { background: var(--button-disabled); cursor: default; }
.btn-ghost { flex: 0 0 96px; background: var(--surface); border-color: var(--line); color: var(--ink); }

/* ── 状態表示 ───────────────────────────── */
.msg { font-size: 14px; padding: 12px; border-radius: 10px; margin-top: 12px; }
.msg-info { background: var(--info-bg); color: var(--muted); }
.msg-error { background: #fdf0ee; color: var(--danger); border-left: 4px solid var(--danger); padding: 16px; }
.msg-heading { font-weight: 700; font-size: 16px; margin: 0 0 4px; }
.msg-heading::before { content: "⚠️ "; }
.msg-body { font-size: 14px; margin: 0; }
.msg-phone {
  display: inline-block; background: var(--danger); color: var(--surface); padding: 10px 16px;
  border-radius: 8px; font-weight: 700; font-size: 15px; text-decoration: none; margin-top: 12px;
  white-space: nowrap;
}
.phone-help { font-size: 13px; color: var(--muted); margin: 10px 0 0; }
/* 🔴 電話番号を途中で折り返さない（「03-6694-」「0094」に割れると読み間違えられる） */
.phone-help a { color: inherit; white-space: nowrap; }
.skeleton { background: linear-gradient(90deg,var(--skeleton-start),var(--skeleton-mid),var(--skeleton-start)); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: 8px; }
@keyframes sk { 0% { background-position: 200% 0 } 100% { background-position: -200% 0 } }
.hidden { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ── 完了 ───────────────────────────── */
.done-mark { text-align: center; padding: 24px 0 8px; }
.done-mark span { display: inline-flex; width: 56px; height: 56px; border-radius: 50%; background: var(--ok); color: #fff; align-items: center; justify-content: center; font-size: 28px; }

/* 固定ボタン（高さ76px＋端末のセーフエリア）より下余白を大きく取り、連絡先を隠さない */
.contact-footer { max-width: 480px; margin: 0 auto; padding: 0 16px calc(100px + env(safe-area-inset-bottom)); font-size: 12px; color: var(--muted); }
.contact-footer a { color: inherit; white-space: nowrap; }

/* 実機テストの判定表示（?debug=1 の時だけ出る）。textContent の改行をそのまま見せる */
#doneDebug { white-space: pre-line; }

/* ボット対策ウィジェット（公開鍵がある時だけ出る） */
.turnstile { max-width: 100%; margin-top: 16px; display: flex; justify-content: center; }
