.lab-root { max-width: 980px; margin: 0 auto; font-family: system-ui, -apple-system, sans-serif; }
.lab-preview { background:#f6f6f6; border-radius:16px; padding:16px; }
.lab-stage {
  width: 360px; height: 360px; margin: 0 auto;
  position: relative; background:#fff; border-radius:16px; overflow:hidden;
  border: 1px solid #eee;
}
.lab-layer {
  position:absolute; inset:0;
  width:100%; height:100%;
  object-fit: contain;
  user-select:none; -webkit-user-drag:none;
}

.lab-layerbar {
  display:flex; gap:8px; flex-wrap:wrap;
  margin: 14px 0;
}
.lab-layerbtn {
  padding:10px 12px;
  border-radius:999px;
  border:1px solid #ddd;
  background:#fff;
  cursor:pointer;
}
.lab-layerbtn.is-active { border-color:#111; }

.lab-grid {
  display:grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap:10px;
  background:#fff;
  border:1px solid #eee;
  border-radius:16px;
  padding:12px;
}
.lab-tile {
  border:1px solid #eee;
  border-radius:12px;
  background:#fff;
  padding:10px;
  cursor:pointer;
  min-height: 110px;
  display:flex;
  align-items:center;
  justify-content:center;
}
.lab-tile img { width:100%; height:90px; object-fit:contain; display:block; }
.lab-tile.is-active { outline:2px solid #111; }
.lab-none { color:#111; opacity:.7; font-size:14px; }

.lab-actions { display:flex; gap:10px; align-items:center; margin-top:14px; flex-wrap:wrap; }
.lab-btn {
  padding:12px 16px; border-radius:12px; border:1px solid #111;
  background:#111; color:#fff; cursor:pointer;
}
.lab-btn-secondary { background:#fff; color:#111; }
.lab-link { margin-left: 8px; color:#111; text-decoration: underline; }
/* ============================
   プレビューをスクロール追従（固定表示）にする
   - PC: 左にプレビュー / 右にパーツ（2カラム）
   - スクロールしてもプレビューは上に張り付く
   - スマホ: 上にプレビュー（sticky）→下にパーツ
   ============================ */

/* 全体を2カラムに */
.lab-root {
  display: grid;
  grid-template-columns: 420px 1fr;
  gap: 16px;
  align-items: start;
}

/* プレビューはstickyにする */
.lab-preview {
  position: sticky;
  top: 16px;              /* 固定される位置（ヘッダーがあるなら増やす） */
  z-index: 10;
}

/* プレビュー内部のステージサイズ調整（好みで） */
.lab-stage {
  width: 380px;
  height: 380px;
}

/* 右側（パーツ選択）をまとめるための余白調整 */
.lab-layerbar,
.lab-grid,
.lab-actions {
  grid-column: 2;
}

/* プレビューは左カラム */
.lab-preview {
  grid-column: 1;
}

/* 画面幅が狭い時（スマホ）は1カラムに戻し、プレビューだけsticky */
@media (max-width: 900px) {
  .lab-root {
    grid-template-columns: 1fr;
  }

  .lab-preview {
    grid-column: 1;
    top: 8px;
  }

  .lab-layerbar,
  .lab-grid,
  .lab-actions {
    grid-column: 1;
  }

  .lab-stage {
    width: 100%;
    height: 320px;
  }
}