/* =========================================================
   発注・見積りフォーム 専用スタイル
   ========================================================= */

.order-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: clamp(1.5rem, 4vw, 3rem);
  align-items: start;
}

/* ---------- Progress ---------- */
.steps {
  display: flex;
  list-style: none;
  padding: 0;
  margin: 0 0 2.2rem;
  counter-reset: s;
  border-bottom: 1px solid var(--line);
}
.steps li {
  flex: 1;
  counter-increment: s;
  text-align: center;
  font-size: .74rem;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: .02em;
  padding: 0 .2rem .9rem;
  margin: 0;
  position: relative;
  line-height: 1.4;
}
.steps li::before {
  content: counter(s);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px; height: 30px;
  margin: 0 auto .45rem;
  border-radius: 50%;
  background: var(--canvas-deep);
  color: var(--muted);
  font-size: .82rem;
  border: 2px solid transparent;
  transition: background .2s, color .2s, border-color .2s;
}
.steps li::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 3px;
  background: transparent;
}
.steps li.done::before {
  content: "✓";
  background: var(--brand-soft);
  color: #fff;
}
.steps li.done { color: var(--brand-soft); }
.steps li.active::before {
  background: var(--brand);
  color: #fff;
  border-color: rgba(95,47,138,.22);
}
.steps li.active { color: var(--brand); }
.steps li.active::after { background: var(--accent); }

/* ---------- Panels ---------- */
.panel { display: none; }
.panel.active { display: block; animation: panelIn .28s ease; }
@keyframes panelIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}
.panel > h2 {
  font-size: clamp(1.2rem, 3vw, 1.5rem);
  margin-bottom: .4rem;
}
.panel > .panel-lead {
  color: var(--muted);
  font-size: .9rem;
  margin-bottom: 1.8rem;
}

/* ---------- Choice cards (radio / checkbox as cards) ---------- */
.choice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: .8rem;
  margin-bottom: 1.6rem;
}
.choice {
  position: relative;
  display: block;
  cursor: pointer;
}
.choice input {
  position: absolute;
  opacity: 0;
  width: 1px; height: 1px;
}
.choice-body {
  /* .choice-body は <span> のため、display を明示しないと初期値の inline のままになり、
     複数行コンテンツ＋枠線が行ごとに分断されて「角ブラケット」状に見える不具合が起きる。
     flex にして、アイコン・タイトル・説明を縦に中央揃えする。 */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem .9rem;
  height: 100%;
  min-height: 100%;
  text-align: center;
  transition: border-color .18s, background .18s, box-shadow .18s;
  background: #fff;
}
.choice-body .ic {
  display: block;
  width: 34px; height: 34px;
  margin: 0 0 .6rem;
  color: var(--brand-soft);
  flex-shrink: 0;
}
.choice-body .t {
  display: block;
  font-weight: 700;
  font-size: .92rem;
  color: var(--ink);
  line-height: 1.45;
}
.choice-body .d {
  display: block;
  font-size: .76rem;
  color: var(--muted);
  margin-top: .3rem;
  line-height: 1.55;
}
.choice:hover .choice-body { border-color: var(--brand-soft); }
.choice input:focus-visible + .choice-body {
  box-shadow: 0 0 0 3px rgba(95,47,138,.22);
}
.choice input:checked + .choice-body {
  border-color: var(--brand);
  background: var(--brand-tint);
  box-shadow: inset 0 0 0 1px var(--brand);
}
.choice input:checked + .choice-body .ic { color: var(--brand); }

/* compact variant — 横並びの小さい選択肢 */
.choice-row { display: flex; flex-wrap: wrap; gap: .6rem; margin-bottom: 1.4rem; }
.choice-row .choice-body {
  padding: .6rem 1.1rem;
  text-align: left;
  font-size: .88rem;
}
.choice-row .choice-body .t { font-size: .88rem; }

/* ---------- Item rows (アイテム × 数量) ---------- */
.item-rows { display: grid; gap: 1rem; margin-bottom: 1rem; }

.item-row {
  border: 1px solid var(--line);
  border-left: 3px solid var(--brand-soft);
  background: #fff;
  padding: 1.1rem 1.2rem;
  position: relative;
}
.item-row-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: .9rem;
  gap: .6rem;
}
.item-row-head .idx {
  font-size: .74rem;
  font-weight: 700;
  letter-spacing: .1em;
  color: var(--brand-soft);
}
.row-remove {
  background: none;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: .75rem;
  font-family: inherit;
  padding: .25rem .7rem;
  border-radius: var(--radius);
  cursor: pointer;
  transition: color .18s, border-color .18s;
}
.row-remove:hover { color: #b03030; border-color: #b03030; }
.item-row:only-child .row-remove { display: none; }

.item-fields {
  display: grid;
  grid-template-columns: 1.5fr 1fr 1.5fr;
  gap: .8rem;
}
.item-fields label {
  display: block;
  font-size: .76rem;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: .3rem;
  letter-spacing: .02em;
}
.item-fields select,
.item-fields input {
  width: 100%;
  font-family: inherit;
  font-size: .92rem;
  padding: .6rem .7rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
}
.item-fields select:focus,
.item-fields input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(95,47,138,.14);
}

.row-sub {
  margin-top: .85rem;
  padding-top: .7rem;
  border-top: 1px dashed var(--line);
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: .8rem;
  color: var(--muted);
  gap: .6rem;
  flex-wrap: wrap;
}
.row-sub .amt {
  font-size: 1.08rem;
  font-weight: 700;
  color: var(--brand);
  font-variant-numeric: tabular-nums;
}

.row-add {
  width: 100%;
  background: #fff;
  border: 2px dashed var(--line);
  color: var(--brand);
  font-family: inherit;
  font-weight: 700;
  font-size: .9rem;
  padding: .9rem;
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color .18s, background .18s;
}
.row-add:hover { border-color: var(--brand); background: var(--brand-tint); }

/* ---------- Summary sidebar ---------- */
.summary {
  position: sticky;
  top: 88px;
  border: 1px solid var(--line);
  background: #fff;
}
.summary-head {
  background: var(--brand);
  color: #fff;
  padding: .95rem 1.2rem;
  font-size: .88rem;
  font-weight: 700;
  letter-spacing: .06em;
}
.summary-body { padding: 1.2rem; }
.summary-lines {
  list-style: none;
  padding: 0;
  margin: 0 0 1rem;
  font-size: .84rem;
}
.summary-lines li {
  display: flex;
  justify-content: space-between;
  gap: .7rem;
  padding: .5rem 0;
  border-bottom: 1px dotted var(--line);
  margin: 0;
}
.summary-lines li span:last-child {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
}
.summary-lines .empty {
  display: block;
  color: var(--muted);
  border: none;
  padding: .3rem 0 .8rem;
  font-size: .82rem;
}
.summary-total {
  border-top: 2px solid var(--brand);
  padding-top: .9rem;
  text-align: right;
}
.summary-total .lbl { display: block; font-size: .76rem; color: var(--muted); }
.summary-total .amt {
  font-size: 1.85rem;
  font-weight: 700;
  color: var(--accent-deep);
  line-height: 1.25;
  font-variant-numeric: tabular-nums;
}
.summary-total .tax { font-size: .74rem; color: var(--muted); }

.summary-note {
  background: var(--canvas);
  font-size: .76rem;
  color: var(--body);
  padding: .8rem 1rem;
  margin-top: 1rem;
  line-height: 1.7;
}
.summary-warn {
  background: #f2f3f3;
  border-left: 3px solid var(--accent);
  font-size: .78rem;
  padding: .75rem .9rem;
  margin-top: 1rem;
  line-height: 1.7;
  color: #4a4d50;
}

/* ---------- Nav buttons ---------- */
.panel-nav {
  display: flex;
  gap: .8rem;
  margin-top: 2.2rem;
  padding-top: 1.6rem;
  border-top: 1px solid var(--line);
}
.panel-nav .btn { flex: 1; }
.panel-nav .btn-back { flex: 0 0 auto; min-width: 110px; }

/* ---------- Validation ---------- */
.field.invalid input,
.field.invalid select,
.field.invalid textarea { border-color: #c0392b; background: #fdf6f5; }
.err {
  display: none;
  color: #c0392b;
  font-size: .78rem;
  font-weight: 700;
  margin: .35rem 0 0;
}
.field.invalid .err { display: block; }

.form-alert {
  display: none;
  background: #fdf6f5;
  border-left: 4px solid #c0392b;
  color: #96281b;
  font-size: .86rem;
  font-weight: 700;
  padding: .9rem 1.1rem;
  margin-bottom: 1.4rem;
}
.form-alert.show { display: block; }

/* ---------- Confirm view ---------- */
.confirm-dl { border-top: 1px solid var(--line); margin: 0 0 1.6rem; }
.confirm-dl > div {
  display: grid;
  grid-template-columns: 180px 1fr;
  border-bottom: 1px solid var(--line);
}
.confirm-dl dt {
  background: var(--canvas);
  padding: .8rem 1rem;
  font-size: .82rem;
  font-weight: 700;
  color: var(--ink);
}
.confirm-dl dd {
  padding: .8rem 1rem;
  margin: 0;
  font-size: .88rem;
  white-space: pre-wrap;
  word-break: break-word;
}
.confirm-dl dd:empty::before { content: "（未入力）"; color: var(--muted); }

/* ---------- Consent ---------- */
.consent {
  display: flex;
  gap: .7rem;
  align-items: flex-start;
  background: var(--canvas);
  padding: 1rem 1.2rem;
  font-size: .86rem;
  margin-bottom: 1.4rem;
}
.consent input { margin-top: .35rem; flex-shrink: 0; width: 18px; height: 18px; }

/* ---------- Draft saved toast ---------- */
.draft-bar {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: .8rem;
  flex-wrap: wrap;
  background: #eef3ff;
  border: 1px solid #c9d6f5;
  font-size: .82rem;
  padding: .7rem 1rem;
  margin-bottom: 1.6rem;
  color: var(--brand);
}
.draft-bar.show { display: flex; }
.draft-bar button {
  background: none;
  border: 1px solid var(--brand);
  color: var(--brand);
  font-family: inherit;
  font-size: .78rem;
  font-weight: 700;
  padding: .3rem .8rem;
  border-radius: var(--radius);
  cursor: pointer;
}
.draft-bar button:hover { background: var(--brand); color: #fff; }

/* ---------- Done panel ---------- */
.done-box { text-align: center; padding: 1rem 0 0; }
.done-box .check {
  width: 66px; height: 66px;
  margin: 0 auto 1.4rem;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
}

/* ---------- Mobile: 合計を常に見せる固定バー ---------- */
.mini-total {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 95;
  background: rgba(58,52,70,.98);
  color: #fff;
  padding: .7rem 1rem calc(.7rem + env(safe-area-inset-bottom));
  border-top: 2px solid var(--accent);
  align-items: center;
  justify-content: space-between;
  gap: .8rem;
  box-shadow: 0 -6px 20px rgba(0,0,0,.18);
}
.mini-total .mt-l { line-height: 1.3; }
.mini-total .mt-lbl {
  display: block;
  font-size: .68rem;
  color: rgba(255,255,255,.72);
  letter-spacing: .04em;
}
.mini-total .mt-amt {
  display: block;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--accent-light);
  font-variant-numeric: tabular-nums;
}
.mini-total .mt-btn {
  background: none;
  border: 1px solid rgba(255,255,255,.45);
  color: #fff;
  font-family: inherit;
  font-size: .78rem;
  font-weight: 700;
  padding: .5rem .9rem;
  border-radius: var(--radius);
  cursor: pointer;
  white-space: nowrap;
}
.mini-total .mt-btn:hover { background: #fff; color: var(--brand); }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .order-layout { grid-template-columns: 1fr; }
  .summary { position: static; }
  .mini-total.show { display: flex; }
  body:has(.mini-total.show) { padding-bottom: 76px; }
  .item-fields { grid-template-columns: 1fr 1fr; }
  .item-fields .f-pos { grid-column: 1 / -1; }
  .confirm-dl > div { grid-template-columns: 1fr; }
  .confirm-dl dt { border-bottom: 1px solid var(--line); }
}

@media (max-width: 560px) {
  .steps li { font-size: 0; padding-bottom: .8rem; }
  .steps li::before { margin-bottom: 0; }
  .item-fields { grid-template-columns: 1fr; }
  .panel-nav { flex-direction: column-reverse; }
  .panel-nav .btn-back { width: 100%; }
}

/* =========================================================
   Wix埋め込み時：フォーム自体を内部スクロールの「箱」にする
   埋め込み時はこのページ自身に動かせる余白がなく window.scrollTo() が
   効かない（Wix側にリスナーを置けないため親ページへスクロール依頼も
   できない）。そこでフォーム部分だけを内部スクロール可能にし、
   ステップ切り替え時は常に自分自身の力だけで先頭に戻せるようにする。
   埋め込みでない通常表示（プレビュー等）では今まで通りページ全体が
   スクロールする（このクラスは付かない）。

   2026-09-24 修正：ここを vh（画面の高さ割合）や小さいpx値で制限すると、
   ほとんどのステップで中身が箱に収まりきらず、常時ミニスクロールバー
   つきの窮屈な箱になってしまい、逆に操作しづらくなった（実際に発生）。
   そもそも vh はこのiframe自身の高さ（＝内容に合わせて外側で伸縮する）
   を基準にするため、実際の端末の画面サイズとは一致しない。
   通常の1ステップぶんの中身が収まりきる、十分に大きい絶対値だけを
   「暴走防止の保険」として設定し、普段は箱の中でスクロールが起きない
   （＝今まで通りページ全体がスクロールする）ようにする。
   ========================================================= */
.is-embedded .order-form-col {
  max-height: 2400px;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}
