/* 全体レイアウト */
:root {
  --ab-bg: #0b1020;
  --ab-panel-bg: #141a2b;
  --ab-accent: #4cc3ff;
  --ab-border: #2a3248;
  --ab-text: #f0f4ff;
  --ab-muted: #9aa3c5;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--ab-bg);
  color: var(--ab-text);
}

.ab-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--ab-border);
  background: rgba(5, 10, 25, 0.9);
  backdrop-filter: blur(10px);
}

.ab-header__title {
  font-size: 20px;
  font-weight: 600;
}

.ab-header__beta {
  font-size: 12px;
  margin-left: 6px;
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--ab-accent);
  color: #03101e;
}

.ab-header__controls {
  display: flex;
  gap: 8px;
}

.ab-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--ab-border);
  background: rgba(10, 14, 30, 0.7);
  font-size: 12px;
  color: var(--ab-muted);
}

.ab-toggle input[type="checkbox"] {
  margin: 0;
  accent-color: var(--ab-accent);
}

.ab-btn {
  border: 1px solid var(--ab-accent);
  background: transparent;
  color: var(--ab-accent);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 14px;
  cursor: pointer;
}
.ab-btn:hover {
  background: rgba(76, 195, 255, 0.12);
}
.ab-btn--sub {
  border-color: var(--ab-border);
  color: var(--ab-muted);
}

/* メインエリア */
.ab-main {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 48px);
}

.ab-workspace {
  flex: 1;
  display: flex;
  padding: 12px;
  gap: 12px;
  min-height: 0;
}

/* ビルドエリア */
.ab-build-area {
  flex: 3;
  position: relative;
  background: radial-gradient(circle at top, #243150, #050916 60%);
  border-radius: 16px;
  border: 1px solid var(--ab-border);
  overflow: hidden;
}

#buildCanvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* 手カーソル（デバッグ用） */
.ab-hand-cursor {
  position: absolute;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  border: 2px solid var(--ab-accent);
  pointer-events: none;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 12px rgba(76, 195, 255, 0.6);
  opacity: 0; /* JSでONにする */
}

/* サイドバー */
.ab-sidebar {
  flex: 0 0 260px;  /* 固定幅めにして細く */
  max-width: 280px;
  display: flex;
  flex-direction: column;
  gap: 8px; 
}

.ab-panel {
  background: var(--ab-panel-bg);
  border-radius: 12px;
  border: 1px solid var(--ab-border);
  padding: 8px 10px; 
}

.ab-panel--palette {
  flex: 0 0 auto;
}

.ab-panel__title {
  font-size: 14px;
  margin: 0 0 8px;
  color: var(--ab-muted);
}

.ab-panel__text {
  font-size: 13px;
  line-height: 1.4;
  margin: 0;
}

/* パーツパレット */
.ab-palette {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.ab-part {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--ab-border);
  background: #1d2540;
  color: var(--ab-text);
  font-size: 16px;
  cursor: pointer;
}
.ab-part--square {
  background: linear-gradient(135deg, #23345e, #1b2138);
}
.ab-part--triangle {
  background: linear-gradient(135deg, #463265, #24213b);
}

/* 下部：カメラ & ステータス */
.ab-bottom {
  display: flex;
  gap: 12px;
  padding: 0 12px 12px;
}

.ab-camera,
.ab-status {
  background: var(--ab-panel-bg);
  border-radius: 12px;
  border: 1px solid var(--ab-border);
  padding: 10px 12px;
}
.ab-camera {
  flex: 2; /* カメラを大きく */
}

.ab-status {
  flex: 0 0 220px;  /* 固定幅で小さめ */
  max-width: 260px;
}

.ab-camera__title,
.ab-status__title {
  font-size: 11px;
  margin: 0 0 4px;
  color: var(--ab-muted);
}

#statusText {
  font-size: 12px;
  line-height: 1.4;
  margin: 0;
}

#cameraPreview {
  width: 100%;
  /* max-height: 300px; */
  object-fit: cover;
  border-radius: 8px;
  background: #000;
  transform: scaleX(-1);
}

/* ビルドエリア上に重ねるカメラプレビュー */
#cameraPreview.ab-build-camera {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 16px;         /* .ab-build-area と合わせる */
  background: #000;
  opacity: 0;                  /* デフォルトは非表示＝パーツだけ表示 */
  pointer-events: none;
  transition: opacity 0.2s ease;
}

/* 重ね表示ON のときだけ薄く表示 */
body.is-overlay-camera #cameraPreview.ab-build-camera {
  opacity: 0.35;               /* 好みで 0.2〜0.5 くらいで調整 */
}


/* ハンドモード */
.ab-hand-modes {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.ab-chip {
  border-radius: 999px;
  border: 1px solid var(--ab-border);
  background: #181f34;
  color: var(--ab-muted);
  font-size: 11px;
  padding: 4px 8px;
  cursor: pointer;
}

.ab-chip.is-active {
  border-color: var(--ab-accent);
  color: var(--ab-accent);
  background: rgba(76, 195, 255, 0.12);
}

.ab-panel__hint {
  margin-top: 6px;
  font-size: 11px;
  color: var(--ab-muted);
}

/* レスポンシブ（スマホ） */
@media (max-width: 768px) {
  .ab-workspace {
    flex-direction: column;
  }
  .ab-sidebar {
    flex-direction: row;
  }
  .ab-panel--palette {
    flex: 2;
  }
}


#handCursor {
  position: absolute;
  width: 40px;
  height: 40px;
  border: 2px solid #4cc3ff;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  opacity: 0;
}

#handCursor.is-grabbing {
  border-color: #ffde59;   /* 明るい黄色 */
  box-shadow: 0 0 12px rgba(255, 222, 89, 0.8);
  background: rgba(255, 222, 89, 0.15);
}
