/* メーカー共通: スマホの操作性(ステージの形・拡大・下のバーの「もどる/保存/決める」)。
   どのメーカーのページでも最後に読む(各メーカーの CSS より後)。部品は maker/shell の StageZoomControls・StepBar・BarSaveMenu */

/* ---- ステージの形: --stage-ar(幅÷高さ)を渡したメーカーは、その形にする。省くと 5:3 ---- */
/* 完成の画面(.stage-done)にも当てる。water-maker.css の「.lm.water-maker .stage.stage-done { aspect-ratio:5/3 }」に負けると、幅は縦長の計算・形は横長になって小さく縮む(2026-12-05) */
.lm .stage[style*="--stage-ar"] { aspect-ratio:var(--stage-ar); width:min(calc(100% - 16px), calc(var(--sh) * var(--stage-ar))); }
.lm.water-maker .stage.stage-done[style*="--stage-ar"] { aspect-ratio:var(--stage-ar); }
@media (min-width:900px) and (min-height:520px) {
  .lm-side .stage[style*="--stage-ar"], .lm-side .stage.stage-done[style*="--stage-ar"] { width:min(100%, calc((100vh - 214px) * var(--stage-ar))); }
}
/* 縦長・正方形のステージは、スマホでは少し高さを使う(横幅いっぱいにならない分) */
@media (max-width:899px) {
  .lm .stage[style*="--stage-ar"] { --sh:calc(min(56vh, 560px) - var(--head-extra, 70px)); }
}

/* ---- 拡大の層: ステージの中身を包み、transform で拡大・移動する ---- */
/* 拡大した中身は、ステージの中でスクロールさせない(ボタンにフォーカスが移ると、隠れた所までずれて札やボタンがはみ出す) */
.stage:has(> .stage-zoom-clip) { overflow:clip; }
.stage-zoom-clip { position:absolute; inset:0; overflow:clip; border-radius:inherit; }
.stage-zoom { position:absolute; inset:0; display:grid; place-items:center; transform-origin:0 0; will-change:transform; }
.stage-zoom-controls { position:absolute; z-index:6; left:8px; bottom:8px; display:none; align-items:center; gap:2px; padding:2px; border-radius:999px; background:rgba(20,16,18,.62); color:#fff; box-shadow:0 2px 8px rgba(0,0,0,.18); }
.stage-zoom-controls[hidden] { display:none !important; }
.stage-zoom-btn { width:36px; height:36px; display:grid; place-items:center; padding:0; border:0; border-radius:50%; background:transparent; color:inherit; cursor:pointer; }
.stage-zoom-btn:disabled { opacity:.4; cursor:default; }
.stage-zoom-btn .ms { font-size:22px; }
.stage-zoom-value { min-width:40px; font-size:12px; font-weight:800; text-align:center; font-variant-numeric:tabular-nums; }
/* 拡大ボタンは、指で操作する端末か、スマホの幅で出す。拡大中は PC でも(元に戻せるように) */
@media (max-width:899px), (pointer:coarse) { .stage-zoom-controls { display:flex; } }
.stage-zoom-controls.is-zoomed { display:flex; }
/* 拡大中は、左下の札(タップで次へ など)をボタンと重ねない */
.stage.is-zoomed .tap-hint { visibility:hidden; }

/* ---- 下のバー: 手順の列(StepBar)が入ったら [もどる] [保存▾] [決める] ---- */
.step-bar-slot:empty { display:none; }
.bar-save { display:contents; }
.bar-save-toggle { display:none; }
.bar-save-pop { display:contents; }
.lm-bottom:has(.step-bar-slot > *) .lm-bottom-inner { display:flex; align-items:center; gap:8px; }
.lm-bottom:has(.step-bar-slot > *) .step-bar-slot, .lm-bottom .step-bar-slot > .is-in-bar { display:contents; }
.step-bar-slot > .is-in-bar > button { order:1; flex:none; height:48px; margin:0; }
/* もどる(と、まんなかの戻る)はアイコンだけの丸いボタン。名前は読み上げに残す */
.step-bar-slot > .is-in-bar > button:not(.btn-main) { width:48px; min-width:48px; padding:0; font-size:0; gap:0; border-radius:50%; }
.step-bar-slot > .is-in-bar > button:not(.btn-main) .ms { font-size:22px; margin:0; }
.step-bar-slot > .is-in-bar > .btn-main, .step-bar-slot > .is-in-bar > .hint-wrap { order:3; flex:1 1 auto; min-width:0; height:48px; margin:0; font-size:15px; box-shadow:0 3px 0 var(--accent-deep, rgba(0,0,0,.25)); }
.step-bar-slot > .is-in-bar > .hint-wrap > .btn-main { height:48px; margin:0; }
.lm-bottom:has(.step-bar-slot > *) .bar-save { order:2; position:relative; display:block; flex:none; }
.lm-bottom:has(.step-bar-slot > *) .bar-save-toggle { display:flex; height:48px; padding:0 10px 0 12px; gap:2px; }
.lm-bottom:has(.step-bar-slot > *) .bar-save-toggle .ms:last-child { font-size:18px; opacity:.7; }
.lm-bottom:has(.step-bar-slot > *) .bar-save-pop { position:absolute; z-index:40; left:0; bottom:calc(100% + 10px); display:none; width:min(260px, calc(100vw - 24px)); padding:8px; border:1px solid var(--line); border-radius:18px; background:var(--surface); box-shadow:0 8px 28px rgba(0,0,0,.22); }
.lm-bottom:has(.step-bar-slot > *) .bar-save.is-open .bar-save-pop { display:grid; gap:8px; }
.lm-bottom:has(.step-bar-slot > *) .bar-save-pop .footer-btn { width:100%; height:48px; }
/* 下のバーへ移した列の、操作欄の中の跡(余白)を残さない */
.panel .actions:empty, .panel .step-actions:empty { display:none; }
/* 決めるボタンだけの列(最初の手順・完成)。操作欄の中では、これまでどおり横いっぱい */
.actions.actions-solo { display:block; }
/* スマホ: キャンバスの上には何も重ねない。拡大ボタン(左)・札(タップで次へ など、まんなか)・元に戻す(右)は、
   キャンバスのすぐ下の1列に出す。ステージの札(背景・かざり など)は上の手順の列と同じなので出さない。
   拡大した中身は内側の stage-zoom-clip が切るので、ステージ自体ははみ出してよい */
@media (max-width:899px) {
  .lm .stage:has(> .stage-zoom-clip) { overflow:visible; }
  .lm:not(.is-done) .stage:has(> .stage-zoom-clip):has(> .stage-zoom-controls:not([hidden])),
  .lm .stage:has(> .stage-zoom-clip):is(:has(> .hint:not(:empty)), :has(> .tap-hint:not([hidden])), :has(> .stage-undo:not(:disabled))) { margin-bottom:46px; }
  /* キャンバスのまんなかに出る大きな案内(クリスマスツリーの「ツリーをタップして飾りを置こう」など)は、下の列の札と同じことなので出さない */
  .lm .stage:has(> .stage-zoom-clip) :is(.xt-deco-guide, .mj-draw-cue) { display:none; }
  .lm .stage:has(> .stage-zoom-clip) > .stage-label { display:none; }
  .lm .stage:has(> .stage-zoom-clip) > .stage-zoom-controls { top:calc(100% + 6px); bottom:auto; left:0; padding:0; gap:0; background:var(--surface, #fff); color:var(--text, #333); border:1px solid var(--line, rgba(0,0,0,.12)); box-shadow:none; }
  .lm .stage:has(> .stage-zoom-clip) > .stage-zoom-controls .stage-zoom-btn { width:34px; height:34px; }
  .lm .stage:has(> .stage-zoom-clip) > .stage-zoom-controls .stage-zoom-btn .ms { font-size:20px; }
  .lm .stage:has(> .stage-zoom-clip) > .stage-undo { top:calc(100% + 6px) !important; right:0 !important; width:36px; height:36px; border:1px solid var(--line, rgba(0,0,0,.12)); background:var(--surface, #fff); color:var(--text, #333); box-shadow:none; transition:none; }
  .lm .stage:has(> .stage-zoom-clip) > .stage-undo .ms { font-size:20px; }
  .lm .stage:has(> .stage-zoom-clip) > .tap-hint { top:calc(100% + 6px); bottom:auto; left:44px; right:44px; height:36px; display:flex; align-items:center; justify-content:center; gap:3px; max-width:none; margin:0; padding:0; border-radius:0; background:none; box-shadow:none; text-shadow:none; color:var(--sub, #777); font-size:11px; font-weight:700; line-height:1.3; text-align:center; white-space:normal; transform:none; }
  .lm .stage:has(> .stage-zoom-clip) > .tap-hint[hidden] { display:none; }
  .lm .stage:has(> .stage-zoom-clip) > .tap-hint .ms { font-size:15px; color:inherit; text-shadow:none; }
  /* 案内文(#hint: 文字をつつくと〜 など)も同じ列のまんなかへ。出ているあいだは「タップで次へ」より優先する */
  .lm .stage:has(> .stage-zoom-clip) > .hint { top:calc(100% + 6px); bottom:auto; left:44px; right:44px; height:36px; display:flex; align-items:center; justify-content:center; margin:0; padding:0; border-radius:0; background:none; box-shadow:none; text-shadow:none; color:var(--sub, #777); font-size:11px; font-weight:700; line-height:1.3; text-align:center; transform:none; }
  .lm .stage:has(> .stage-zoom-clip) > .hint:empty { display:none; }
  .lm .stage:has(> .stage-zoom-clip):has(> .hint:not(:empty)) > .tap-hint { display:none; }
  .lm .stage.is-zoomed > .hint { visibility:hidden; }
}

/* 完成の画面は小さな見本だけなので、拡大のボタンを出さない */
.lm.is-done .stage-zoom-controls { display:none !important; }
