/* はつめいロボバトルDX — workshop.css：ガレージ（つくる・ずのう）（2026-12-02 P0 で css/style.css から同じ順番のまま分割。中身は変えていない。持ち主：P5） */

/* Top-Left Compact Stats & 1P/2P Slot Switch */
.hud-top-left {
  position: absolute;
  top: 6px;
  left: 6px;
  right: 6px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 6px;
  z-index: 10;
  pointer-events: none;
  flex-wrap: wrap;
}

.stats-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  pointer-events: auto;
}

.stat-pill {
  background: rgba(255, 255, 255, 0.92);
  border: 2px solid var(--ink);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 10.5px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.stat-pill.warn {
  background: #ffe3e3;
  color: #c92a2a;
  border-color: #c92a2a;
}

.builder-slot-switch {
  display: inline-flex;
  gap: 4px;
  pointer-events: auto;
}

.slot-chip {
  font-family: inherit;
  font-size: 10.5px;
  font-weight: 900;
  padding: 3px 8px;
  border-radius: 999px;
  border: 2px solid var(--ink);
  background: #fff;
  cursor: pointer;
  box-shadow: 0 2px 0 var(--ink);
}

.slot-chip.active-1p {
  background: #dbeafe;
  color: #1d4ed8;
}

.slot-chip.active-2p {
  background: #ffe4e6;
  color: #be123c;
}

/* Wrapped, Non-Clipping Floating Workshop Toolbar（P5：#workshop-tools は .g-tools へ。旧クラスだけ残す） */
.workshop-tools {
  position: absolute;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 5px;
  z-index: 10;
  width: min(96vw, 720px);
  padding: 3px 4px;
}

.tool-btn {
  font-family: inherit;
  font-weight: 900;
  font-size: 11px;
  padding: 6px 10px;
  border-radius: 11px;
  border: 2px solid var(--ink);
  background: rgba(255, 255, 255, 0.96);
  color: var(--ink);
  cursor: pointer;
  box-shadow: 0 2.5px 0 var(--ink);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  flex-shrink: 0;
}

.tool-btn:active {
  transform: translateY(2px);
  box-shadow: none;
}

.tool-btn.active,
.tool-btn.active-select {
  background: var(--accent-yellow);
  color: var(--ink);
}

.tool-btn.active-danger,
.tool-btn.active-erase {
  background: var(--accent-pink);
  color: #fff;
}

.tool-btn.active-sim {
  background: var(--accent-green);
  color: #fff;
}

.tool-btn.active-cam {
  background: var(--accent-cyan);
  color: #fff;
}

.tool-btn.active-rev {
  background: #7c3aed;
  color: #fff;
}

.build-hint-banner {
  position: absolute;
  bottom: 5px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(25, 32, 56, 0.84);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  white-space: nowrap;
  max-width: 95%;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
  z-index: 9;
}

/* Build Dock */
.build-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 5px;
}

.cat-pills {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
  flex: 1;
}
.cat-pills::-webkit-scrollbar { display: none; }

.cat-pill {
  font-family: inherit;
  font-size: 10.5px;
  font-weight: 800;
  padding: 4px 9px;
  border-radius: 999px;
  border: 2px solid var(--ink);
  background: #f1f5f9;
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}

.cat-pill.active {
  background: var(--accent-cyan);
  color: #fff;
}

.cta-battle-btn {
  font-family: inherit;
  font-size: 12px;
  font-weight: 900;
  padding: 6px 12px;
  border-radius: 11px;
  border: 2px solid var(--ink);
  background: linear-gradient(180deg, #ff7b3b 0%, #f04e18 100%);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 2.5px 0 var(--ink);
  white-space: nowrap;
  flex-shrink: 0;
}

.cta-battle-btn:active {
  transform: translateY(2px);
  box-shadow: none;
}

.parts-Palette {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 3px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.parts-Palette::-webkit-scrollbar { display: none; }

.part-card {
  font-family: inherit;
  min-width: 88px;
  max-width: 102px;
  flex-shrink: 0;
  background: #f8fafc;
  border: 2px solid var(--ink);
  border-radius: 12px;
  padding: 5px 5px;
  cursor: pointer;
  box-shadow: 0 2.5px 0 var(--ink);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.part-card.selected {
  background: #fff3bf;
  border-color: #d9480f;
  box-shadow: 0 2.5px 0 #d9480f;
  transform: translateY(-1px);
}

.part-svg-wrap {
  width: 28px;
  height: 28px;
  margin-bottom: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.part-name {
  font-size: 10px;
  font-weight: 900;
  color: var(--ink);
  line-height: 1.15;
}

.part-sub {
  font-size: 8.5px;
  font-weight: 700;
  color: #64748b;
  margin-top: 2px;
  line-height: 1.1;
}

/* Program Dock */
.prog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 5px;
  flex-wrap: wrap;
}

.prog-presets {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
  flex: 1 1 240px;
  min-width: 0;
  padding: 2px 1px;
  -webkit-overflow-scrolling: touch;
}
.prog-presets::-webkit-scrollbar { display: none; }

.mini-preset-btn {
  font-family: inherit;
  font-size: 10px;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1.5px solid var(--ink);
  background: #eef2ff;
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
}

.rules-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 5px;
  max-height: 138px;
  overflow-y: auto;
}

.rule-row {
  display: flex;
  align-items: center;
  gap: 4px;
  background: #f8fafc;
  border: 2px solid var(--ink);
  border-radius: 10px;
  padding: 4px 6px;
  transition: opacity 0.14s ease, background 0.14s ease;
}
.rule-row.inactive-rule {
  opacity: 0.68;
  background: #f1f5f9;
  border-style: dashed;
}

.rule-row.firing {
  background: #fff9db;
  border-color: #f59f00;
}

.rule-num {
  background: var(--accent-purple);
  color: #fff;
  font-weight: 900;
  font-size: 10px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.rule-select {
  font-family: inherit;
  font-size: 10.5px;
  font-weight: 800;
  padding: 3px 4px;
  border-radius: 7px;
  border: 1.5px solid var(--ink);
  background: #e7f5ff;
  color: var(--ink);
  flex: 1;
  min-width: 0;
  cursor: pointer;
}

.rule-select.then-select {
  background: #fff0f6;
}

.rule-arrow {
  font-weight: 900;
  font-size: 11px;
  color: var(--ink);
  flex-shrink: 0;
}

/* 3D Cascading Brain Chip Board Bottom Palette */
.prog-cascade-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  background: #0f172a;
  color: #f8fafc;
  border: 2px solid var(--ink);
  border-radius: 10px;
  padding: 4px 8px;
  margin-bottom: 5px;
  flex-wrap: wrap;
}
.prog-row-pills,
.prog-col-tabs {
  display: flex;
  align-items: center;
  gap: 3px;
  flex-wrap: nowrap;
}
.prog-row-pill {
  font-family: inherit;
  font-size: 10.5px;
  font-weight: 900;
  width: 23px;
  height: 23px;
  border-radius: 7px;
  border: 1.5px solid #475569;
  background: #1e293b;
  color: #cbd5e1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.prog-row-pill.has-chip {
  border-color: #38bdf8;
  color: #e0f2fe;
}
.prog-row-pill.active {
  background: #ffd43b;
  color: #192038;
  border-color: #ffffff;
  box-shadow: 0 0 0 2px #f59f00;
}
.prog-col-tab {
  font-family: inherit;
  font-size: 10px;
  font-weight: 900;
  padding: 3px 7px;
  border-radius: 7px;
  border: 1.5px solid #475569;
  background: #1e293b;
  color: #cbd5e1;
  cursor: pointer;
  white-space: nowrap;
}
.prog-col-tab.if-tab.active {
  background: #0ea5e9;
  color: #ffffff;
  border-color: #bae6fd;
}
.prog-col-tab.act-tab.active {
  background: #f59f00;
  color: #192038;
  border-color: #fff3bf;
}
.prog-col-tab.else-tab {
  border-color: #818cf8;
  color: #e0e7ff;
}
.prog-col-tab.else-tab.active {
  background: #6366f1;
  color: #ffffff;
  border-color: #e0e7ff;
}
.prog-base-bar {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}
.base-sw-btn {
  font-family: inherit;
  font-size: 10px;
  font-weight: 900;
  padding: 2.5px 7px;
  border-radius: 7px;
  border: 1.5px solid #475569;
  background: #1e293b;
  color: #cbd5e1;
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.base-sw-btn.on-cw {
  background: #451a03;
  border-color: #f59f00;
  color: #fde68a;
}
.base-sw-btn.on-ccw {
  background: #431407;
  border-color: #fb923c;
  color: #fed7aa;
}
.base-sw-btn.on-safe {
  background: #064e3b;
  border-color: #34d399;
  color: #d1fae5;
}
.base-sw-btn.on-burst {
  background: #3b0764;
  border-color: #c084fc;
  color: #f3e8ff;
}
.rule-lamp.lit-else {
  background: #818cf8 !important;
  color: #ffffff !important;
  border-color: #e0e7ff !important;
  box-shadow: 0 0 6px #818cf8;
}
.prog-combo-readout {
  font-size: 10.5px;
  font-weight: 900;
  color: #66f7ff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 320px;
}
.prog-clear-row-btn {
  font-family: inherit;
  font-size: 9.5px;
  font-weight: 900;
  padding: 2px 7px;
  border-radius: 6px;
  border: 1.5px solid #f87171;
  background: #450a0a;
  color: #fecaca;
  cursor: pointer;
  white-space: nowrap;
}
.chip-piece-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  gap: 5px;
  max-height: 112px;
  overflow-y: auto;
  padding-bottom: 2px;
}
.chip-piece-btn {
  font-family: inherit;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 7px;
  border-radius: 9px;
  border: 2px solid var(--ink);
  background: #ffffff;
  color: var(--ink);
  cursor: pointer;
  box-shadow: 0 2.5px 0 var(--ink);
  text-align: left;
  position: relative;
  transition: transform 0.08s ease;
}
.chip-piece-btn:active {
  transform: translateY(1px);
}
.chip-piece-btn.selected {
  background: #fff3bf !important;
  border-color: #d9480f;
  box-shadow: 0 2.5px 0 #d9480f;
}
.chip-piece-btn.cat-if { background: #e0f2fe; }
.chip-piece-btn.cat-move { background: #dcfce7; }
.chip-piece-btn.cat-orbit { background: #ede9fe; }
.chip-piece-btn.cat-wep { background: #ffe4e6; }
.chip-piece-btn.cat-pwr { background: #fef3c7; }
.chip-piece-btn.cat-off { background: #f1f5f9; border-style: dashed; }
.chip-piece-dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  border: 1.5px solid var(--ink);
  flex-shrink: 0;
}
.chip-piece-lbl {
  font-size: 10px;
  font-weight: 900;
  line-height: 1.15;
}

/* =========================================================================
   P5 ガレージ（つくる・ずのう・いろ・かお・おてほん）2026-12-02
   ・押せる所は 44px 以上、主操作は 56px 以上。文字は 12px 以上（ボタンの主な字は 15px）
   ・左だけ太い線は使わない（枠は四辺同じ）。押下に合わせて光らせない
   ========================================================================= */
#app.in-garage #topbar { display: none !important; }
#app.in-garage .dock-handle-bar { display: none !important; }
#app.in-garage #viewport-hint { display: none !important; }

.g-ic {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  pointer-events: none;
}
.g-ic svg { width: 100%; height: 100%; display: block; }

/* 上の帯 */
.garage-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 16;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: max(8px, env(safe-area-inset-top)) 10px 6px;
  pointer-events: none;
}
.garage-bar > * { pointer-events: auto; }
.g-nav-btn,
.g-done-btn,
.g-seg-btn {
  font-family: inherit;
  font-weight: 900;
  font-size: 15px;
  min-height: 48px;
  border: 2.5px solid var(--ink);
  border-radius: 14px;
  background: #fff;
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  box-shadow: 0 3px 0 var(--ink);
  -webkit-touch-callout: none;
  touch-action: manipulation;
  white-space: nowrap;
}
.g-nav-btn { padding: 0 12px 0 6px; }
@media (max-width: 420px) {
  .garage-bar { gap: 6px; padding-left: 8px; padding-right: 8px; }
  .g-nav-btn, .g-done-btn, .g-seg-btn { font-size: 14px; }
  .g-nav-btn { padding: 0 10px 0 2px; }
  .g-done-btn { padding: 0 10px 0 6px; }
  .g-seg-btn { min-width: 0; padding: 0 10px; }
  .g-seg-btn .g-ic { display: none; }
}
.g-done-btn {
  padding: 0 14px 0 10px;
  min-height: 52px;
  background: var(--accent-orange);
  color: #fff;
}
.g-seg {
  display: inline-flex;
  border: 2.5px solid var(--ink);
  border-radius: 16px;
  background: #fff;
  overflow: hidden;
  box-shadow: 0 3px 0 var(--ink);
}
.g-seg-btn {
  border: 0;
  border-radius: 0;
  box-shadow: none;
  padding: 0 12px;
  min-width: 84px;
  background: #fff;
}
.g-seg-btn + .g-seg-btn { border-left: 2.5px solid var(--ink); }
.g-seg-btn.is-on {
  background: var(--accent-yellow);
}
.g-nav-btn:active, .g-done-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
/* スマホ幅：上の max-width:420px の指定は、あとに書いた .g-seg-btn / .g-done-btn の基本の指定に負けていた。
   ここで改めて細くし、3つ（もどる・つくる／ずのう・できた！）が重ならないようにする */
@media (max-width: 420px) {
  .garage-bar .g-seg { flex: 0 1 auto; min-width: 0; }
  .garage-bar .g-seg-btn { min-width: 0; padding: 0 10px; }
  .garage-bar .g-seg-btn .g-ic { display: none; }
  .garage-bar .g-done-btn { padding: 0 10px 0 8px; flex-shrink: 0; }
  .garage-bar .g-nav-btn { flex-shrink: 0; }
}
@media (max-width: 370px) {
  .garage-bar .g-done-btn .g-ic, .garage-bar .g-nav-btn .g-ic { display: none; }
  .garage-bar .g-nav-btn { padding: 0 10px; }
}

/* ゲージ（重さ・パーツ数・バランス） */
.g-hud {
  position: absolute;
  top: calc(max(8px, env(safe-area-inset-top)) + 62px);
  left: 10px;
  right: 10px;
  bottom: 10px;
  z-index: 10;
  pointer-events: none;
}
.g-gauges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: stretch;
}
.g-gauge,
.g-balance {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.94);
  border: 2px solid var(--ink);
  border-radius: 12px;
  padding: 4px 8px;
  min-height: 38px;
}
.g-gauge-name {
  font-size: 12px;
  font-weight: 900;
  color: var(--ink);
  white-space: nowrap;
}
.g-gauge-track {
  position: relative;
  width: 64px;
  height: 12px;
  border-radius: 999px;
  background: #e2e8f0;
  border: 2px solid var(--ink);
  overflow: hidden;
}
.g-gauge-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 10%;
  background: var(--accent-green);
  border-radius: 999px;
  transition: width 0.2s ease;
}
.g-gauge.is-over .g-gauge-fill { background: #f03e3e; }
.g-gauge.is-over { background: #fff5f5; }
.g-gauge.is-free .g-gauge-fill { background: linear-gradient(90deg, #845ef7, #ff6b9d); width: 100% !important; }
.g-gauge-num {
  font-size: 13px;
  font-weight: 900;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.g-balance { color: #2f9e44; }
.g-balance.is-warn { color: #f03e3e; background: #fff5f5; }
.g-balance svg { display: block; overflow: visible; }
#g-balance-body { transition: transform 0.2s ease; }
.g-reg-over {
  display: inline-block;
  margin-top: 6px;
  padding: 5px 12px;
  border-radius: 999px;
  background: #f03e3e;
  color: #fff;
  font-size: 14px;
  font-weight: 900;
  border: 2px solid var(--ink);
}

/* 1〜3号機 */
.g-slot {
  position: absolute;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  pointer-events: auto;
  touch-action: pan-y;
}
.g-slot-arrow {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 2.5px solid var(--ink);
  background: #fff;
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 3px 0 var(--ink);
  touch-action: manipulation;
}
.g-slot-arrow:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.g-slot-name {
  min-width: 96px;
  text-align: center;
  font-size: 15px;
  font-weight: 900;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.94);
  border: 2px solid var(--ink);
  border-radius: 999px;
  padding: 6px 12px;
  white-space: nowrap;
}
.g-slot-name.is-p2 { background: #ffe4e6; color: #be123c; }

/* 常設の道具（右の縦の列） */
.g-tools {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-46%);
  z-index: 11;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.g-tool {
  font-family: inherit;
  width: 68px;
  min-height: 60px;
  padding: 5px 2px 4px;
  border: 2.5px solid var(--ink);
  border-radius: 16px;
  background: #fff;
  color: var(--ink);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 14px;
  font-weight: 900;
  line-height: 1.1;
  word-break: keep-all; /* 「いろ・かお」は index.html の wbr（・のあと）でだけ折り返す */
  cursor: pointer;
  box-shadow: 0 3px 0 var(--ink);
  -webkit-touch-callout: none;
  touch-action: manipulation;
}
.g-tool:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.g-tool.is-on { background: #d3f9d8; }
.g-tool--more { min-height: 46px; }
.g-pop {
  position: absolute;
  right: 88px;
  top: 50%;
  z-index: 18;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: #fff;
  border: 2.5px solid var(--ink);
  border-radius: 16px;
  padding: 6px;
  box-shadow: 0 5px 0 var(--ink);
}
.g-pop-item {
  font-family: inherit;
  min-height: 48px;
  padding: 0 14px 0 10px;
  border: 0;
  border-radius: 12px;
  background: #f8fafc;
  color: var(--ink);
  font-size: 15px;
  font-weight: 900;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  white-space: nowrap;
  text-align: left;
}
.g-pop-item:active { background: #e7f5ff; }

/* タッチの2段目（✓）・付けたパーツのメニュー・ドラッグの影 */
.g-place-ok {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 17;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: 3px solid var(--ink);
  background: #22d3ee;
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 0 var(--ink);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-touch-callout: none;
}
.g-place-ok .g-ic { width: 32px; height: 32px; }
.g-part-menu {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 17;
  display: flex;
  gap: 4px;
  padding: 5px;
  background: #fff;
  border: 2.5px solid var(--ink);
  border-radius: 16px;
  box-shadow: 0 5px 0 var(--ink);
}
.g-pm-btn {
  font-family: inherit;
  min-width: 58px;
  min-height: 58px;
  padding: 4px 6px;
  border: 2px solid #cbd5e1;
  border-radius: 12px;
  background: #f8fafc;
  color: var(--ink);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 14px;
  font-weight: 900;
  white-space: nowrap;
  cursor: pointer;
  touch-action: manipulation;
}
.g-pm-btn--danger { color: #c92a2a; background: #fff5f5; border-color: #ffc9c9; }
.g-pm-btn:active { transform: translateY(1px); }
.g-drag-ghost {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 19;
  width: 64px;
  height: 64px;
  padding: 8px;
  border-radius: 16px;
  border: 2.5px solid var(--ink);
  background: rgba(255, 255, 255, 0.9);
  pointer-events: none;
}
.g-drag-ghost svg { width: 100%; height: 100%; }
#app.g-testing .g-hud .g-gauges,
#app.g-testing .g-slot,
#app.g-testing #panel-build { opacity: 0.4; pointer-events: none; }

/* 下のシート（つくる） */
#app.in-garage #bottom-dock {
  height: 40%;
  height: 40svh;
  min-height: 210px;
  display: flex;
  flex-direction: column;
  padding: 8px 8px max(8px, env(safe-area-inset-bottom));
}
#app.in-garage #bottom-dock .dock-panel.active {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
}
.g-cat-tabs {
  display: grid;
  grid-auto-columns: minmax(0, 1fr);
  grid-auto-flow: column;
  gap: 5px;
  margin-bottom: 6px;
  flex-shrink: 0;
}
.g-cat-tabs[hidden] { display: none !important; }
.g-cat-tab {
  font-family: inherit;
  min-height: 46px;
  padding: 2px 2px;
  border: 2px solid var(--ink);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  font-size: 14px;
  font-weight: 900;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  line-height: 1.1;
  cursor: pointer;
  touch-action: manipulation;
  white-space: nowrap;
}
.g-cat-tab .g-ic { width: 20px; height: 20px; }
.g-cat-tab.is-on { background: var(--accent-yellow); }
.g-parts-grid {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-auto-rows: minmax(82px, auto);
  align-content: start;
  gap: 6px;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 2px 2px 6px;
}
.g-part-card {
  position: relative;
  font-family: inherit;
  min-height: 82px;
  padding: 6px 3px 5px;
  border: 2.5px solid var(--ink);
  border-radius: 14px;
  background: #fff;
  color: var(--ink);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 3px;
  cursor: pointer;
  box-shadow: 0 3px 0 var(--ink);
  touch-action: pan-y;
  -webkit-touch-callout: none;
  -webkit-user-drag: none;
}
.g-part-card:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.g-part-card.is-on { background: #fff3bf; border-color: #e8590c; box-shadow: 0 3px 0 #e8590c; }
.g-part-card.is-hint { outline: 4px solid #ff922b; outline-offset: 2px; animation: gHintPulse 1.1s ease-in-out infinite; }
.g-part-svg { width: 42px; height: 42px; display: flex; align-items: center; justify-content: center; pointer-events: none; }
.g-part-svg svg { width: 100%; height: 100%; }
.g-part-name {
  font-size: 14px;
  font-weight: 900;
  line-height: 1.15;
  text-align: center;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: keep-all;
  overflow-wrap: anywhere;
  pointer-events: none;
}
/* 名前は JS が行を分け、--n＝長い方の行の文字数。カードの幅に合わせて 12〜14px で1行に収める（途中で折らない） */
.g-part-card { container-type: inline-size; }
.g-part-card .g-part-name[style*="--n"] {
  display: block;
  white-space: nowrap;
  overflow-wrap: normal;
  letter-spacing: -0.03em;
  flex: none;            /* 低いカードで縮められて2行目が切れないように */
  line-height: 1.12;
  font-size: 13px;
  font-size: clamp(12px, calc((100cqi - 8px) / (var(--n) * 0.97)), 14px);
  max-width: 100%;
}
.g-new {
  position: absolute;
  top: -7px;
  right: -5px;
  font-size: 14px;
  font-weight: 900;
  color: #fff;
  background: #f03e3e;
  border: 2px solid var(--ink);
  border-radius: 999px;
  padding: 0 6px;
  line-height: 18px;
  pointer-events: none;
}
@keyframes gHintPulse {
  0%, 100% { outline-color: #ff922b; }
  50% { outline-color: #ffd43b; }
}

/* ずのう：文の形のカード */
.g-prog-head {
  display: flex;
  gap: 6px;
  margin-bottom: 6px;
  flex-shrink: 0;
}
.g-mini-btn {
  font-family: inherit;
  min-height: 44px;
  padding: 0 12px 0 8px;
  border: 2px solid var(--ink);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  font-size: 14px;
  font-weight: 900;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  box-shadow: 0 2px 0 var(--ink);
  touch-action: manipulation;
}
.g-mini-btn:active { transform: translateY(1px); box-shadow: none; }
.g-base-switches {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
  flex-shrink: 0;
}
.g-base-switches[hidden] { display: none !important; }
.g-base-sw {
  font-family: inherit;
  min-height: 44px;
  padding: 3px 10px 3px 6px;
  border: 2px solid var(--ink);
  border-radius: 12px;
  background: #f1f5f9;
  color: #475569;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 900;
  touch-action: manipulation;
}
.g-base-sw.is-on { background: #d3f9d8; color: var(--ink); }
.g-base-state {
  font-size: 14px;
  padding: 1px 8px;
  border-radius: 999px;
  background: #fff;
  border: 1.5px solid currentColor;
}
.g-rule-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 2px 2px 6px;
}
.g-rule {
  display: grid;
  grid-template-columns: 30px 1fr;
  align-items: start;
  gap: 4px 6px;
  padding: 6px 8px 6px 6px;
  background: #f8fafc;
  border: 2px solid #cbd5e1;
  border-radius: 14px;
}
.g-rule.is-sel { border-color: var(--ink); background: #fff; }
.g-rule-num {
  grid-row: span 2;
  width: 28px;
  height: 28px;
  margin-top: 14px;
  border-radius: 50%;
  background: var(--accent-purple);
  color: #fff;
  font-size: 15px;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
}
.g-rule-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  min-width: 0;
}
.g-rule-else { grid-column: 2; }
.g-word {
  font-size: 15px;
  font-weight: 900;
  color: var(--ink);
  white-space: nowrap;
}
.g-arrow {
  font-size: 18px;
  font-weight: 900;
  color: #64748b;
}
.g-chip {
  font-family: inherit;
  min-height: 56px;
  max-width: 100%;
  padding: 4px 12px 4px 8px;
  border: 2.5px solid var(--ink);
  border-radius: 14px;
  background: #fff;
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 15px;
  font-weight: 900;
  line-height: 1.2;
  text-align: left;
  cursor: pointer;
  box-shadow: 0 3px 0 var(--ink);
  touch-action: manipulation;
  -webkit-touch-callout: none;
}
.g-chip:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.g-chip.is-hint, .g-opt.is-hint, .g-base-sw.is-hint { outline: 4px solid #ff922b; outline-offset: 2px; animation: gHintPulse 1.1s ease-in-out infinite; }
.g-tone-cond { background: #d0ebff; }
.g-tone-move { background: #d3f9d8; }
.g-tone-orbit { background: #e5dbff; }
.g-tone-weapon { background: #ffe3e3; }
.g-tone-power { background: #fff3bf; }
.g-tone-off { background: #f1f5f9; }
.g-tone-empty { background: #fff; border-style: dashed; color: #64748b; box-shadow: none; }

/* 下から出る選択シート */
.g-sheet-backdrop {
  position: fixed;
  left: 0;
  right: 0;
  top: 0;
  bottom: var(--tb);
  z-index: 60;
  background: rgba(25, 32, 56, 0.45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.g-sheet-backdrop[hidden] { display: none !important; }
.g-sheet {
  width: 100%;
  max-width: 720px;
  max-height: 72%;
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 3px solid var(--ink);
  border-bottom: 0;
  border-radius: 22px 22px 0 0;
  padding: 10px 12px max(12px, env(safe-area-inset-bottom));
  animation: gSheetUp 0.18s ease-out;
}
@keyframes gSheetUp {
  from { transform: translateY(24px); opacity: 0.4; }
  to { transform: none; opacity: 1; }
}
.g-sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.g-sheet-title {
  margin: 0;
  font-size: 17px;
  font-weight: 900;
  color: var(--ink);
}
.g-sheet-close {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 2.5px solid var(--ink);
  background: #fff;
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}
.g-sheet-body {
  overflow-y: auto;
  overscroll-behavior: contain;
  min-height: 0;
}
.g-sheet-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 7px 7px 9px;  /* 案内の橙の枠（outline 4px＋ずらし2px）が送る箱の端で切れないゆとり */
}
.g-opt {
  font-family: inherit;
  min-height: 58px;
  padding: 6px 10px 6px 8px;
  border: 2.5px solid var(--ink);
  border-radius: 14px;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 900;
  line-height: 1.2;
  text-align: left;
  cursor: pointer;
  box-shadow: 0 3px 0 var(--ink);
  touch-action: manipulation;
}
.g-opt.is-on { border-color: #e8590c; box-shadow: 0 3px 0 #e8590c; }
.g-opt.is-on::after { content: ''; margin-left: auto; width: 12px; height: 12px; border-radius: 50%; background: #e8590c; flex-shrink: 0; }
.g-opt:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.g-opt-txt, .g-chip-txt, .g-tpl-desc, .g-head-desc { word-break: keep-all; overflow-wrap: anywhere; }
.g-opt--clear { background: #fff5f5; color: #c92a2a; border-style: dashed; box-shadow: none; }
.g-sheet-tpl {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.g-tpl {
  font-family: inherit;
  min-height: 110px;
  padding: 10px 8px;
  border: 2.5px solid var(--ink);
  border-radius: 16px;
  background: #f8f9ff;
  color: var(--ink);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  box-shadow: 0 3px 0 var(--ink);
  touch-action: manipulation;
}
.g-tpl-ic { width: 40px; height: 40px; color: var(--accent-purple); }
.g-tpl-ic svg { width: 100%; height: 100%; }
.g-tpl-title { font-size: 16px; font-weight: 900; }
.g-tpl-desc { font-size: 14px; font-weight: 700; color: #475569; text-align: center; line-height: 1.3; }
.g-info-list {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 12px;
  margin: 0;
  font-size: 15px;
}
.g-info-list dt { font-weight: 900; color: #475569; }
.g-info-list dd { margin: 0; font-weight: 800; color: var(--ink); }
.g-info-warn {
  margin: 0 0 10px;
  padding: 8px 12px;
  border-radius: 12px;
  background: #fff5f5;
  border: 2px solid #f03e3e;
  color: #c92a2a;
  font-size: 14px;
  font-weight: 900;
}

/* いろ・かお・おてほんロボ */
.g-modal .g-modal-box { max-width: 560px; display: flex; flex-direction: column; }
.g-close-btn { min-height: 44px; min-width: 64px; font-size: 15px !important; padding: 0 14px !important; justify-content: center; }
.g-modal-scroll { overflow-y: auto; min-height: 0; }
.g-modal-lbl {
  font-size: 15px;
  font-weight: 900;
  color: var(--ink);
  margin: 10px 0 6px;
}
.g-modal-lbl:first-child { margin-top: 0; }
.g-modal-lead {
  font-size: 14px;
  font-weight: 700;
  color: #475569;
  margin: 0 0 10px;
  line-height: 1.5;
}
.g-paint-tabs {
  display: grid;
  /* 6つ（かお・ステッカーを足した 2026-12-03）。上の段は顔まわり（あたま・かお・目）、下の段は体（ボディ・ほね・うで・ステッカー） */
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 5px;
  margin-bottom: 10px;
}
.g-paint-tab {
  font-family: inherit;
  min-height: 44px;
  padding: 0 4px;
  border: 2px solid var(--ink);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  font-size: 14px;
  font-weight: 900;
  cursor: pointer;
  white-space: nowrap;
  touch-action: manipulation;
}
.g-paint-tab.is-on { background: var(--accent-yellow); }
.g-paint-sec[hidden] { display: none !important; }
.g-head-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}
.g-head-card {
  font-family: inherit;
  min-height: 96px;
  padding: 6px 4px;
  border: 2.5px solid var(--ink);
  border-radius: 14px;
  background: #fff;
  color: var(--ink);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  cursor: pointer;
  box-shadow: 0 3px 0 var(--ink);
  touch-action: manipulation;
}
.g-head-card.is-on { background: #fff3bf; border-color: #e8590c; box-shadow: 0 3px 0 #e8590c; }
.g-head-svg { width: 40px; height: 40px; }
.g-head-svg svg { width: 100%; height: 100%; }
.g-head-name { font-size: 14px; font-weight: 900; }
.g-head-desc { font-size: 14px; font-weight: 700; color: #475569; text-align: center; line-height: 1.2; }
.g-swatch-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.g-swatch {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 3px solid var(--ink);
  background: var(--sw, #fff);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  touch-action: manipulation;
}
.g-swatch.is-on { box-shadow: 0 0 0 3px #fff, 0 0 0 6px #e8590c; }
.g-swatch.is-locked { opacity: 0.55; border-style: dashed; }
.g-sw-price {
  font-size: 14px;
  font-weight: 900;
  color: #fff;
  background: rgba(25, 32, 56, 0.78);
  border-radius: 999px;
  padding: 0 3px;
  line-height: 18px;
}
.g-head-card.is-locked { background: #f1f5f9; color: #64748b; box-shadow: none; border-style: dashed; }
.g-head-svg--locked { filter: grayscale(1) brightness(0.6); opacity: 0.5; }
/* かお・ステッカー（交換所の品）の札。まだ持っていない品も絵は見せて、値段の札を付ける */
/* 上の 22px は値段の札の場所。絵を札の下から始めて、値段がかおの絵に重ならないようにする（2026-12-03） */
.g-cos-card { position: relative; justify-content: flex-start; min-height: 84px; padding-top: 22px; }
.g-cos-art { display: grid; place-items: center; height: 40px; }
.g-cos-art img { width: 76px; height: 38px; display: block; }
.g-cos-art svg { width: 40px; height: 40px; display: block; }
.g-cos-none { width: 34px; height: 34px; border-radius: 50%; border: 2.5px dashed #94a3b8; }
.g-cos-card.is-shop { background: #f8fafc; box-shadow: none; border-style: dashed; }
.g-cos-price {
  position: absolute; right: 4px; top: 3px; min-width: 24px; padding: 0 6px; border-radius: 999px;
  background: rgba(25, 32, 56, 0.86); color: #fff; font-size: 12px; font-weight: 900; line-height: 17px;
}
.g-shop-item {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}
.g-shop-sw { width: 56px; height: 56px; border-radius: 50%; border: 3px solid var(--ink); background: var(--sw, #fff); flex-shrink: 0; }
/* かお・ステッカーの絵は丸に入らないので角丸の札にする。.g-shop-sw より後ろに書く（前に書くと丸と 56px が勝って、かおが丸からはみ出した。2026-12-03） */
.g-shop-sw.g-shop-sw--art { display: grid; place-items: center; width: 92px; height: 60px; border-radius: 14px; background: #f1f5f9; overflow: hidden; }
.g-shop-sw--art img { width: 80px; height: 40px; display: block; }
.g-shop-sw--art svg { width: 44px; height: 44px; display: block; }
.g-shop-name { font-size: 16px; font-weight: 900; color: var(--ink); }
.g-shop-price { margin-left: auto; font-size: 16px; font-weight: 900; color: #e8590c; white-space: nowrap; }
/* 送る箱（.g-sheet-body）の端でボタンの下の影が切れないよう、下にゆとりを置く */
.g-sheet-shop { padding: 2px 2px 6px; }
.g-shop-actions { display: flex; gap: 8px; justify-content: flex-end; }
.g-shop-actions .g-mini-btn { min-height: 52px; padding: 0 18px; font-size: 15px; }
.g-mini-btn--main { background: var(--accent-orange); color: #fff; }
.g-preset-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  overflow-y: auto;
  min-height: 0;
}
.g-preset-list .g-modal-lead { grid-column: 1 / -1; margin: 4px 0 0; }
.g-preset {
  font-family: inherit;
  min-height: 72px;
  padding: 8px 10px;
  border: 2.5px solid var(--ink);
  border-radius: 14px;
  background: #fff;
  color: var(--ink);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  text-align: left;
  box-shadow: 0 3px 0 var(--ink);
  touch-action: manipulation;
}
.g-preset-title { font-size: 15px; font-weight: 900; line-height: 1.25; }
.g-preset-badge { font-size: 14px; font-weight: 800; color: #475569; }

/* PC（ポインタ端末）：シートを少し低く、パーツは横に多く並べる */
@media (min-width: 760px) {
  #app.in-garage #bottom-dock { height: 248px; min-height: 0; }
  #app.in-garage.in-garage-prog #bottom-dock { height: 290px; }
  .g-parts-grid { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); grid-auto-rows: minmax(88px, auto); }
  .g-part-name { font-size: 14px; }
  .g-sheet-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .g-sheet-tpl { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .g-gauge-track { width: 96px; }
  .g-cat-tabs { grid-auto-columns: minmax(0, 150px); }
  .g-cat-tab { flex-direction: row; gap: 4px; font-size: 14px; }
  .g-rule-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-content: start; }
}

/* 低い画面 */
@media (max-height: 640px) {
  .g-tool { min-height: 50px; width: 66px; }
  .g-tools { gap: 5px; }
  .g-gauge, .g-balance { min-height: 32px; padding: 2px 6px; }
  #app.in-garage #bottom-dock { min-height: 180px; }
}

/* ずのう：スマホでは2D のカードが主（3D 基板は背景の飾り） */
#app.in-garage-prog #bottom-dock { height: 46%; height: 46svh; }
/* スマホ縦：2D のカードの範囲を広げ（6割）、3D の基板と見本は上の4割に小さく置く。
   いつものスイッチは2つ横に並べて縦を節約する */
@media (max-width: 759px) {
  #app.in-garage-prog #bottom-dock { height: 60%; height: 60svh; }
  #panel-prog .g-base-switches { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #panel-prog .g-base-sw { min-width: 0; line-height: 1.15; text-align: left; padding: 3px 6px 3px 5px; }
  #panel-prog .g-base-title { word-break: keep-all; } /* 切れ目は garage.js の wrapAt（wbr）だけ */
  #panel-prog .g-base-sw .g-base-state { margin-left: auto; flex-shrink: 0; padding: 1px 6px; }
  #panel-prog .g-rule { padding: 5px 6px 5px 4px; gap: 4px 5px; }
  #panel-prog .g-rule-line { gap: 4px; }
}
@media (max-width: 759px) and (max-height: 640px) {
  #app.in-garage-prog #bottom-dock { height: 62%; height: 62svh; }
}

/* =========================================================================
   ずのう：回路の盤（2026-12-02 作り直し）
   盤は DOM。上の行から順に光が流れ、当てはまった行・効くチップが点く（評価の流れの光。押した札を光らせる演出ではない）。
   3D は右（スマホは上）の「ためしに」の見本の台だけ（main.js の tickBrainDemo）。
   ========================================================================= */
#app.in-garage-prog { --bd-w: clamp(500px, 47vw, 800px); --bd-cyan: #22d3ee; --bd-ink: #0b1020; }
#app.in-garage.in-garage-prog #bottom-dock {
  color: #e2e8f0;
  border-top: 3px solid var(--ink);
  background:
    radial-gradient(circle at 13px 13px, #ffe066 0 3.5px, #8a6a00 4px 5px, transparent 5.5px),
    radial-gradient(circle at calc(100% - 13px) 13px, #ffe066 0 3.5px, #8a6a00 4px 5px, transparent 5.5px),
    radial-gradient(circle at 13px calc(100% - 13px), #ffe066 0 3.5px, #8a6a00 4px 5px, transparent 5.5px),
    radial-gradient(circle at calc(100% - 13px) calc(100% - 13px), #ffe066 0 3.5px, #8a6a00 4px 5px, transparent 5.5px),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.022) 0 2px, transparent 2px 7px),
    linear-gradient(180deg, #1f2a47 0%, #131b30 100%);
  padding: 10px 14px max(10px, env(safe-area-inset-bottom));
}
/* PC・横長：盤を左に立てる。右の空いた所が見本の台 */
@media (min-width: 760px) and (orientation: landscape) {
  #app.in-garage.in-garage-prog #bottom-dock {
    position: absolute;
    left: 12px;
    top: 70px;
    bottom: calc(12px + var(--tb, 0px));
    width: var(--bd-w);
    height: auto;
    min-height: 0;
    border: 3px solid var(--ink);
    border-radius: 22px;
    box-shadow: 0 6px 0 var(--ink), 0 22px 46px rgba(10, 16, 32, 0.36);
    padding: 14px 18px 14px;
  }
}
#panel-prog .g-prog-head { align-items: center; margin-bottom: 8px; }
#panel-prog .g-prog-head::before {
  content: 'BRAIN CIRCUIT';
  margin-right: auto;
  padding: 4px 12px 4px 30px;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.14em;
  color: #fde68a;
  border-radius: 8px;
  background:
    repeating-linear-gradient(-45deg, #ffd43b 0 5px, #192038 5px 10px) left center / 20px 100% no-repeat,
    rgba(0, 0, 0, 0.3);
  border: 2px solid var(--bd-ink);
  white-space: nowrap;
}
#panel-prog .g-mini-btn {
  background: #2a3656;
  color: #f8fafc;
  border-color: var(--bd-ink);
  box-shadow: 0 3px 0 var(--bd-ink);
}
#panel-prog .g-mini-btn:active { box-shadow: none; }

/* いつも はたらく スイッチ（行の外の回路） */
#panel-prog .g-base-switches {
  position: relative;
  align-items: center;
  gap: 8px;
  padding: 13px 8px 8px;
  margin-top: 8px;
  margin-bottom: 8px;
  background: rgba(0, 0, 0, 0.28);
  border: 2px solid var(--bd-ink);
  border-radius: 14px;
  box-shadow: inset 0 2px 0 rgba(0, 0, 0, 0.35);
}
/* 名札は枠の上辺に載せる（高さを食わない） */
#panel-prog .g-base-lbl {
  position: absolute;
  top: -11px;
  left: 12px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 9px 1px 6px;
  font-size: 13px;
  font-weight: 900;
  line-height: 17px;
  color: #fcd34d;
  white-space: nowrap;
  background: #1b2440;
  border: 2px solid var(--bd-ink);
  border-radius: 8px;
}
#panel-prog .g-base-lbl .g-ic { width: 18px; height: 18px; }
#panel-prog .g-base-sw {
  position: relative;
  min-height: 46px;
  background: #253150;
  color: #cbd5e1;
  border: 2px solid var(--bd-ink);
  box-shadow: 0 3px 0 var(--bd-ink);
  transition: box-shadow 0.2s, border-color 0.2s;
}
#panel-prog .g-base-sw.is-on { background: #23314f; color: #f8fafc; }
#panel-prog .g-lamp {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #475569;
  border: 2px solid var(--bd-ink);
  flex-shrink: 0;
}
#panel-prog .g-base-sw.is-on .g-lamp { background: #4ade80; box-shadow: 0 0 8px #4ade80; }
#panel-prog .g-base-state { background: #334155; color: #94a3b8; border: 0; font-weight: 900; }
#panel-prog .g-base-sw.is-on .g-base-state { background: #fcd34d; color: var(--ink); }
#panel-prog .g-base-sw.is-run { border-color: var(--bd-cyan); box-shadow: 0 3px 0 var(--bd-ink), 0 0 0 2px rgba(34, 211, 238, 0.55), 0 0 14px rgba(34, 211, 238, 0.45); }

/* 行の並び：左の線（回路）を上から光が流れる */
#panel-prog .g-rule-list {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 2px 6px 10px;
}
#panel-prog .g-flow-head {
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
  padding-left: 12px;
  min-height: 28px;
  color: #7dd3fc;
  font-size: 13px;
  font-weight: 900;
}
#panel-prog .g-flow-start {
  position: relative;
  z-index: 1;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #12304a;
  border: 2px solid var(--bd-cyan);
  color: var(--bd-cyan);
  display: flex;
  align-items: center;
  justify-content: center;
}
#panel-prog .g-flow-start svg { width: 16px; height: 16px; }
#panel-prog .g-flow-head::after {
  content: '';
  position: absolute;
  left: 23.5px;
  top: 26px;
  bottom: -10px;
  width: 3px;
  background: rgba(34, 211, 238, 0.35);
}
#panel-prog .g-flow-pulse {
  position: absolute;
  left: 23px;
  top: 0;
  z-index: 3;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: radial-gradient(circle, #fff 0 30%, #67e8f9 55%, rgba(34, 211, 238, 0) 72%);
  box-shadow: 0 0 14px 5px rgba(34, 211, 238, 0.6);
  pointer-events: none;
  transition: transform 0.24s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s;
}
#panel-prog .g-flow-pulse.is-done { opacity: 0; }
#panel-prog .g-rule {
  position: relative;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 6px 8px;
  padding: 8px 10px 8px 6px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02));
  border: 2px solid #2d3a5c;
  border-radius: 16px;
  transition: border-color 0.2s, background-color 0.2s;
}
#panel-prog .g-rule::before {
  content: '';
  position: absolute;
  left: 21.5px;
  top: -10px;
  bottom: -10px;
  width: 3px;
  background: rgba(34, 211, 238, 0.28);
}
#panel-prog .g-rule:last-child::before { bottom: 50%; }
#panel-prog .g-rule.is-sel { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.28); }
#panel-prog .g-rule-num {
  position: relative;
  z-index: 1;
  width: 34px;
  height: 34px;
  margin-top: 16px;
  background: #253150;
  color: #cbd5e1;
  border: 2px solid var(--bd-ink);
  font-size: 16px;
  transition: background-color 0.2s, color 0.2s, box-shadow 0.2s;
}
#panel-prog .g-rule.is-check { border-color: rgba(34, 211, 238, 0.7); }
#panel-prog .g-rule.is-check .g-rule-num { background: #67e8f9; color: var(--ink); }
#panel-prog .g-rule.is-yes { border-color: var(--bd-cyan); background-color: rgba(34, 211, 238, 0.12); }
#panel-prog .g-rule.is-yes .g-rule-num { background: var(--bd-cyan); color: var(--ink); box-shadow: 0 0 12px rgba(34, 211, 238, 0.8); }
#panel-prog .g-rule.is-else { border-color: #a5b4fc; background-color: rgba(129, 140, 248, 0.14); }
#panel-prog .g-rule.is-else .g-rule-num { background: #a5b4fc; color: var(--ink); box-shadow: 0 0 12px rgba(165, 180, 252, 0.8); }
#panel-prog .g-rule.is-miss .g-chip { opacity: 0.5; }
#panel-prog .g-rule.is-miss .g-rule-num,
#panel-prog .g-rule.is-empty .g-rule-num { background: #1b2440; color: #64748b; }
#panel-prog .g-rule-line { gap: 6px; align-items: center; }
/* まだ持っていない行（鍵） */
#panel-prog .g-rule--locked {
  align-items: center;
  min-height: 56px;
  background: repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.03) 0 10px, transparent 10px 20px);
  border: 2px dashed #2d3a5c;
}
#panel-prog .g-rule--locked::before { background: rgba(100, 116, 139, 0.25); }
#panel-prog .g-rule--locked .g-rule-num { margin-top: 0; background: #1b2440; color: #475569; }
#panel-prog .g-lock-ic { display: inline-flex; align-self: center; width: 24px; height: 24px; color: #475569; }
#panel-prog .g-rule--locked .g-rule-num { align-self: center; }
#panel-prog .g-lock-ic svg { width: 100%; height: 100%; }

/* チップ：上の帯に「もし」「どうする」、下に中身 */
#panel-prog .g-chip {
  position: relative;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  padding: 0;
  min-height: 64px;
  min-width: 0;
  overflow: hidden;
  border: 2.5px solid var(--ink);
  border-radius: 14px;
  box-shadow: 0 4px 0 var(--bd-ink);
  transition: box-shadow 0.2s, opacity 0.2s, filter 0.2s;
}
@media (hover: hover) {
  #panel-prog .g-chip:hover { transform: translateY(-1px); }
}
#panel-prog .g-chip:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--bd-ink); }
#panel-prog .g-chip-tag {
  display: block;
  padding: 3px 10px 2px;
  font-size: 14px;
  font-weight: 900;
  line-height: 1.25;
  letter-spacing: 0.04em;
  color: #fff;
  background: #0369a1;
  text-align: left;
  white-space: nowrap;
}
#panel-prog .g-chip--act .g-chip-tag { background: #1f2a44; }
#panel-prog .g-chip[data-col="4"] .g-chip-tag { background: #4f46e5; }
#panel-prog .g-chip--always { background: #e7ecf7; }
#panel-prog .g-chip--always .g-chip-tag { background: #475569; }
#panel-prog .g-chip-body {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px 7px 9px;
  font-size: 16px;
  font-weight: 900;
  line-height: 1.2;
  text-align: left;
}
#panel-prog .g-chip-body .g-ic { width: 24px; height: 24px; }
#panel-prog .g-chip.is-met .g-chip-tag { background: var(--bd-cyan); color: var(--ink); }
#panel-prog .g-chip.is-unmet { opacity: 0.55; }
#panel-prog .g-chip.is-run { box-shadow: 0 4px 0 var(--bd-ink), 0 0 0 3px rgba(34, 211, 238, 0.75), 0 0 16px rgba(34, 211, 238, 0.45); }
#panel-prog .g-chip.is-blocked { opacity: 0.62; filter: grayscale(0.85); }
#panel-prog .g-chip-flag {
  display: none;
  position: absolute;
  top: 3px;
  right: 4px;
  align-items: center;
  gap: 2px;
  padding: 0 7px 0 4px;
  font-size: 13px;
  font-weight: 900;
  line-height: 18px;
  color: var(--ink);
  background: #fcc419;
  border-radius: 999px;
}
#panel-prog .g-chip-flag svg { width: 12px; height: 12px; }
#panel-prog .g-chip.is-blocked .g-chip-flag { display: inline-flex; filter: none; }
/* 空き：押したくなる「＋ えらぶ」 */
#panel-prog .g-chip.g-tone-empty {
  border: 2.5px dashed var(--bd-cyan);
  background: repeating-linear-gradient(135deg, rgba(34, 211, 238, 0.14) 0 8px, rgba(34, 211, 238, 0.05) 8px 16px);
  color: #e0f2fe;
  box-shadow: none;
}
#panel-prog .g-chip.g-tone-empty .g-chip-tag { background: transparent; color: #67e8f9; }
#panel-prog .g-chip.g-tone-empty .g-plus {
  width: 28px;
  height: 28px;
  padding: 3px;
  border-radius: 50%;
  background: #ffd43b;
  color: var(--ink);
  border: 2px solid var(--ink);
}
@media (hover: hover) {
  #panel-prog .g-chip.g-tone-empty:hover { background-color: rgba(34, 211, 238, 0.12); }
}
/* つなぎ（なら → ／ ちがうときは） */
#panel-prog .g-link {
  display: inline-flex;
  align-items: center;
  gap: 1px;
  color: #64748b;
  flex-shrink: 0;
  transition: color 0.2s;
}
#panel-prog .g-link-word { font-size: 14px; font-weight: 900; color: #cbd5e1; }
#panel-prog .g-link-arrow { display: inline-flex; width: 20px; height: 20px; }
#panel-prog .g-link-arrow svg { width: 100%; height: 100%; }
#panel-prog .g-link--plus .g-link-arrow { width: 16px; height: 16px; }
#panel-prog .g-link--else { color: #a5b4fc; width: 26px; height: 26px; margin-left: 4px; }
#panel-prog .g-link--else svg { width: 100%; height: 100%; }
#panel-prog .g-rule.is-yes .g-link:not(.g-link--else) { color: var(--bd-cyan); }
#panel-prog .g-rule.is-else .g-link--else { color: #e0e7ff; }
#panel-prog .g-rule-else { grid-column: 2; }

/* ためしに：見本の台の下の帯（場面を切り替える・その場面のうごき） */
.g-brain-stage {
  position: absolute;
  z-index: 15;
  left: 8px;
  right: 8px;
  bottom: 8px;
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none;
}
#app.in-garage-prog .g-brain-stage:not([hidden]) { display: flex; }
#app.g-testing .g-brain-stage { display: none !important; }
.g-scene {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
  padding: 4px;
  background: rgba(17, 24, 43, 0.92);
  border: 2.5px solid var(--ink);
  border-radius: 999px;
  box-shadow: 0 4px 0 var(--ink);
}
.g-scene-nav {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border-radius: 50%;
  border: 2px solid #0b1020;
  background: #2a3656;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  cursor: pointer;
  touch-action: manipulation;
}
.g-scene-nav svg { width: 100%; height: 100%; }
.g-scene-nav:disabled { opacity: 0.3; cursor: default; }
.g-scene-txt {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
  padding: 0 8px;
  color: #fff;
  line-height: 1.2;
  text-align: center;
}
.g-scene-tag { font-size: 13px; font-weight: 900; color: #67e8f9; letter-spacing: 0.08em; }
.g-scene-name { font-size: 16px; font-weight: 900; word-break: keep-all; overflow-wrap: anywhere; }
.g-scene-result {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 5px;
}
.g-scene-res-list { display: contents; }
.g-scene-res-lbl {
  font-size: 13px;
  font-weight: 900;
  color: #fff;
  background: var(--ink);
  padding: 2px 9px;
  border-radius: 999px;
}
.g-res-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px 3px 6px;
  font-size: 14px;
  font-weight: 900;
  line-height: 1.2;
  color: var(--ink);
  border: 2px solid var(--ink);
  border-radius: 10px;
  box-shadow: 0 2px 0 var(--ink);
}
.g-res-chip .g-ic { width: 18px; height: 18px; }
@media (min-width: 760px) and (orientation: landscape) {
  .g-brain-stage { left: calc(var(--bd-w, 520px) + 24px); right: 12px; bottom: calc(14px + var(--tb, 0px)); }
}
@media (max-width: 759px), (orientation: portrait) {
  .g-scene-result { display: none; }
  .g-scene-name { font-size: 15px; }
}
/* スマホ縦：スイッチは2つ横並び。チップと行の余白を詰めて、1行が2段までに収まるようにする */
@media (max-width: 759px) {
  #panel-prog .g-base-switches { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
  #panel-prog .g-base-sw { font-size: 14px; gap: 4px; padding: 3px 6px 3px 6px; }
  #panel-prog .g-base-sw .g-ic { width: 20px; height: 20px; flex-shrink: 0; }
  #panel-prog .g-base-sw .g-base-state { font-size: 13px; padding: 1px 6px; }
}
@media (max-width: 480px) {
  #app.in-garage.in-garage-prog #bottom-dock { padding-left: 10px; padding-right: 10px; }
  #panel-prog .g-prog-head::before { content: none; }
  #panel-prog .g-prog-head { justify-content: flex-end; margin-bottom: 4px; }
  #panel-prog .g-lamp,
  #panel-prog .g-base-sw .g-ic { display: none; }
  #panel-prog .g-base-sw { padding-left: 8px; }
  #panel-prog .g-rule-list { gap: 7px; padding: 2px 4px 10px; }
  #panel-prog .g-flow-head { padding-left: 8px; min-height: 26px; }
  #panel-prog .g-flow-head::after { left: 19.5px; }
  #panel-prog .g-flow-pulse { left: 17px; }
  #panel-prog .g-rule { grid-template-columns: 28px minmax(0, 1fr); padding: 6px 6px 6px 5px; gap: 5px 6px; }
  #panel-prog .g-rule::before { left: 17.5px; }
  #panel-prog .g-rule-num { width: 28px; height: 28px; font-size: 15px; margin-top: 18px; }
  #panel-prog .g-rule-line { gap: 4px; }
  #panel-prog .g-chip { min-height: 60px; }
  #panel-prog .g-chip-tag { font-size: 13px; padding: 2px 8px 1px; }
  #panel-prog .g-chip-body { font-size: 14px; padding: 5px 9px 6px 7px; gap: 5px; }
  #panel-prog .g-chip-body .g-ic { width: 20px; height: 20px; }
  #panel-prog .g-chip.g-tone-empty .g-plus { width: 24px; height: 24px; }
  #panel-prog .g-link-word { font-size: 13px; }
  #panel-prog .g-link-arrow { width: 16px; height: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  #panel-prog .g-flow-pulse { transition: none; }
}

@media (prefers-reduced-motion: reduce) {
  .g-part-card.is-hint, .g-chip.is-hint, .g-opt.is-hint { animation: none; }
  .g-sheet { animation: none; }
}

