html,
body {
  height: 100%;
}
body {
  margin: 0;
  overflow: hidden;
  background: #e67e22;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, "Hiragino Kaku Gothic ProN",
    "Noto Sans JP", sans-serif;
}
canvas {
  display: block;
}



/* =========================
   GLOBAL DROP OVERLAY
========================= */


#global-drop-overlay[hidden] {
  display: none;
}

#global-drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  font-size: 24px;
  pointer-events: none;
}


/* =========================
   UI LAYER
========================= */
#ui {
  position: fixed;
  inset: 0;
  pointer-events: none; /* 3D操作を邪魔しない */
}

#ui * {
  box-sizing: border-box;
}

/* 左上 HUD */
.hud {
  position: absolute;
  top: 14px;
  left: 14px;
  display: grid;
  gap: 6px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(10px);
  pointer-events: auto;
  user-select: none;
}

.hud__row {
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}

.hud__tag {
  font-size: 11px;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.75);
  background: rgba(255, 255, 255, 0.10);
  padding: 3px 6px;
  border-radius: 8px;
}

.hud__text {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.92);
}

/* ---- 右上ツールバー  ---- */
.toolbar {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(12px);
  pointer-events: auto;

  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: transform;
}

/* 折りたたみ状態 */
.toolbar.is-collapsed {
  /* 右端のボタン1つ分とマージンを残して右へスライド */
  /* 計算式: 全体(100%) - 残したい幅(約44px) - 右の余白(12px) */
  transform: translateX(calc(100% - 36px));
}

/* 開閉ボタンのアイコンを反転させる */
.toolbar__toggle .tool__icon {
  transition: transform 0.4s ease;
  display: inline-block;
}

.toolbar.is-collapsed .toolbar__toggle .tool__icon {
  transform: rotate(180deg); /* 矢印を反対に向ける */
}

/* 折りたたみ中は他のボタンのホバーやクリックを無効化（誤操作防止） */
.toolbar.is-collapsed .tool:not(.toolbar__toggle) {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.tool {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  padding: 0 10px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.10);
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.92);
  cursor: pointer;
  outline: none;
}

.tool:hover {
  background: rgba(255, 255, 255, 0.10);
}

.tool.is-active {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.22);
}

.tool__icon {
  font-size: 14px;
  line-height: 1;
}
.tool__label {
  font-size: 12px;
}

.toolbar__sep {
  width: 1px;
  height: 22px;
  background: rgba(255, 255, 255, 0.18);
  margin: 0 2px;
}

/* Inspector toggle（見た目だけ） */
.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: rgba(255, 255, 255, 0.9);
  user-select: none;
  cursor: pointer;
}

.toggle input {
  display: none;
}

.toggle__ui {
  width: 42px;
  height: 22px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.18);
  position: relative;
}

.toggle__dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  position: absolute;
  top: 50%;
  left: 2px;
  transform: translateY(-50%);
  transition: transform 160ms ease;
}

.toggle input:checked + .toggle__ui .toggle__dot {
  transform: translate(20px, -50%);
}

.toggle__label {
  font-size: 12px;
  opacity: 0.95;
}

/* 右パネル */
.panel {
  position: absolute;
  top: 56px;
  right: 12px;
  width: min(360px, calc(100vw - 24px));
  height: calc(100vh - 68px);
  border-radius: 16px;
  background: rgba(0, 0, 0, 0.30);
  /* VR 空間では透過度を下げた固形の色にする（クラッシュ防止） */
  /*background: rgba(0, 0, 0, 0.9) !important;*/
  /*backdrop-filter: none !important;*/
  backdrop-filter: blur(14px);
  /*box-shadow: none !important;*/
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);

  border: 1px solid rgba(255, 255, 255, 0.12);


  display: grid;
  grid-template-rows: auto 1fr auto;
  overflow: hidden;

  transform: translateX(16px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

/* パネルが非表示（opacity: 0）だと 3D 空間でも透明になってしまうため、
   VR モード中は強制的に表示されるようにする（テスト用） */
/*
.panel.vr-visible {
  opacity: 1 !important;
  pointer-events: auto !important;
  transform: none !important;
}
*/
.panel.is-open {
  transform: translateX(0);
  opacity: 1;
  pointer-events: auto;
}

.panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 12px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.10);
}

.panel__title {
  font-size: 13px;
  letter-spacing: 0.04em;
  color: rgba(255, 255, 255, 0.92);
}

.panel__close {
  width: 30px;
  height: 30px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.92);
  cursor: pointer;
}

.panel__close:hover {
  background: rgba(255, 255, 255, 0.10);
}

.panel__body {
  padding: 12px;
  overflow: auto;
}

.panel__section {
  padding: 10px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.10);
  margin-bottom: 10px;
}

.section__title {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.85);
  margin: 2px 0 10px;
}

.input {
  width: 100%;
  height: 34px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.22);
  color: rgba(255, 255, 255, 0.92);
  padding: 0 10px;
  outline: none;
  margin-bottom: 10px;
}

.input::placeholder {
  color: rgba(255, 255, 255, 0.55);
}

.list {
  display: grid;
  gap: 6px;
}

.list__item {
  height: 34px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.10);
  background: rgba(0, 0, 0, 0.18);
  color: rgba(255, 255, 255, 0.9);
  text-align: left;
  padding: 0 10px;
  cursor: pointer;
}

.list__item:hover {
  background: rgba(255, 255, 255, 0.08);
}

.list__item.is-selected {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.20);
}
.list__item:focus-visible {
  outline: 2px solid rgba(255,255,255,.35);
  outline-offset: 2px;
}

.grid {.model-ro
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.check {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.9);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.check input {
  accent-color: #ffffff;
}

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.stat {
  padding: 10px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.10);
}

.stat__k {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.7);
  margin-bottom: 4px;
}

.stat__v {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.92);
  font-weight: 700;
}

.panel__footer {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.10);
}

.btn {
  height: 34px;
  padding: 0 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.92);
  cursor: pointer;
  flex: 1;
}

.btn:hover {
  background: rgba(255, 255, 255, 0.16);
}

.btn--ghost {
  background: rgba(0, 0, 0, 0.18);
}

/* 中央の吹き出し（モック） */
/*
.bubble {
  position: absolute;
  left: 50%;
  top: 52%;
  transform: translate(-50%, -50%);
  min-width: 280px;
  max-width: min(520px, calc(100vw - 24px));
  padding: 14px 16px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  text-align: center;
  pointer-events: auto;
}
*/


/* lil-gui theme: match your frosted UI */
.lilgui--theme-clock.lil-gui {
  border-radius: 14px;
  overflow: hidden;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 20px 60px rgba(0,0,0,.35);

  /* base */
  --background-color: rgba(0, 0, 0, 0.28);
  --text-color: rgba(255, 255, 255, 0.92);
  --border-color: rgba(255, 255, 255, 0.12);

  /* title (両対応) */
  --title-background-color: rgba(255, 255, 255, 0.08);
  --title-bg-color: rgba(255, 255, 255, 0.08);
  --title-text-color: rgba(255, 255, 255, 0.92);

  /* widget (両対応) */
  --widget-color: rgba(255, 255, 255, 0.06);
  --widget-bg-color: rgba(255, 255, 255, 0.06);
  --widget-text-color: rgba(255, 255, 255, 0.90);

  /* states */
  --hover-color: rgba(255, 255, 255, 0.10);
  --focus-color: rgba(255, 255, 255, 0.18);

  /* values */
  --number-color: rgba(255, 255, 255, 0.92);
  --string-color: rgba(255, 255, 255, 0.92);

  /* sliders (両対応) */
  --slider-color: rgba(255, 255, 255, 0.18);
  --slider-knob-color: rgba(255, 255, 255, 0.55);
  --slider-bg-color: rgba(255, 255, 255, 0.18);
  --slider-fg-color: rgba(255, 255, 255, 0.55);

  /* sizing */
  --font-size: 12px;
  --spacing: 6px;
  --title-height: 22px;
}
.lilgui--theme-clock .controller {
  border-bottom: 1px solid rgba(255,255,255,0.10) !important;
}

.lilgui--theme-clock .name {
  color: rgba(255,255,255,0.85) !important;
}

.lilgui--theme-clock .widget input,
.lilgui--theme-clock .widget select {
  border-radius: 10px !important;
}


/* ===== Info panel layout fixes ===== */
.panel[data-panel="info"] .stats {
  /* もともと2列前提なら、Infoは1列 or 自動にする */
  display: grid;
  grid-template-columns: 1fr; /* 安全に1列 */
  gap: 10px;
}

.panel[data-panel="info"] .stat {
  /* key/value が縦に崩れないように */
  display: grid;
  grid-template-columns: 56px 1fr;
  align-items: center;
  gap: 10px;
}

.panel[data-panel="info"] .stat__k {
  opacity: 0.8;
  white-space: nowrap;
}

.panel[data-panel="info"] .stat__v {
  /* 長いパスやマテリアル名対策 */
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Materials list の横幅はみ出し対策 */
.panel[data-panel="info"] [data-bind="matList"] .list__item {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* talk toggle */
.model-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.model-row__main {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.model-thumb {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 8px;
  flex: 0 0 auto;
}

.model-thumb--empty {
  display: grid;
  place-items: center;
  background: rgba(255,255,255,.08);
  font-size: 10px;
}

.model-row__actions {
  flex: 0 0 auto;
}

.model-row .list__item {
  width: 100%;
}
.model-row .list__item {
  width: 100%;
}
.toggle--mini .toggle__ui {
  width: 34px;
  height: 20px;
}

.toggle--mini .toggle__dot {
  width: 14px;
  height: 14px;
}

.toggle--mini .toggle__label {
  font-size: 12px;
  opacity: 0.85;
}


/**/
.rig-selection {
  min-height: 36px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  border-radius: 12px;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.08);
  color: rgba(255,255,255,.92);
  margin-bottom: 10px;
}

.rig-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.rig-actions input[type="number"] {
  width: 64px;
}

.rig-actions button:disabled {
  opacity: .45;
  cursor: default;
}

.rig-actions input[type="number"] {
  width: 64px;
  height: 32px;
  padding: 0 8px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.06);
  color: #fff;
}

.rig-actions button {
  height: 32px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.08);
  color: #fff;
  cursor: pointer;
}

.rig-actions button:hover {
  background: rgba(255,255,255,.14);
}

.rig-actions button:active {
  transform: translateY(1px);
}


/* Wallpaper */

.panel select.input,
.panel input[type="color"].input {
  width: 100%;
  box-sizing: border-box;
}

.panel input[type="color"].input {
  height: 42px;
  padding: 6px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 12px;
}

.color-swatches {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  margin-bottom: 10px;
}

.swatch {
  width: 100%;
  aspect-ratio: 1 / 1;
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 10px;
  background: var(--sw);
  cursor: pointer;
}

.swatch:hover {
  transform: scale(1.03);
}

.swatch.is-active {
  outline: 2px solid rgba(255,255,255,0.9);
  outline-offset: 2px;
}
.wallpaper-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.wallpaper-tile {
  position: relative;
  display: block;
  border: 0;
  background: rgba(255,255,255,.06);
  border-radius: 12px;
  overflow: hidden;
  padding: 0;
  text-align: left;
}

.wallpaper-tile__thumb {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  display: block;
}

.wallpaper-tile__thumb--none {
  display: grid;
  place-items: center;
  background: rgba(255,255,255,.08);
  color: rgba(255,255,255,.8);
}

.wallpaper-tile__label {
  padding: 8px 10px;
  font-size: 12px;
}

.wallpaper-tile__delete {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: rgba(0,0,0,.45);
}


/* ===== Settings panel ===== */

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.settings-field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.settings-field--wide {
  grid-column: 1 / -1;
}

.settings-field__label {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.72);
  letter-spacing: 0.04em;
}

.settings-subtitle {
  margin: 10px 0 8px;
  font-size: 12px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.9);
}

.panel__footer--compact {
  padding: 8px 0 10px;
  border-top: 0;
}

.settings-item {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  gap: 8px;
  align-items: center;
  min-height: 40px;
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.10);
  background: rgba(0, 0, 0, 0.18);
  color: rgba(255, 255, 255, 0.92);
}

.settings-item__main {
  min-width: 0;
}

.settings-item__name {
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.settings-item__path {
  font-size: 11px;
  opacity: 0.72;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.settings-item__radio {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: rgba(255,255,255,0.8);
}

.settings-item__del {
  height: 30px;
  padding: 0 10px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.08);
  color: #fff;
  cursor: pointer;
}

.settings-item__del:hover {
  background: rgba(255,255,255,0.14);
}



.wallpaper-item.video-item {
  position: relative;
}

.wallpaper-thumb-btn {
  width: 100%;
  min-height: 72px;
  border: none;
  border-radius: 12px;
  background: rgba(255,255,255,0.08);
  color: #fff;
  cursor: pointer;
}

.wallpaper-item-label {
  margin-top: 6px;
  font-size: 12px;
  line-height: 1.3;
  word-break: break-all;
}

.wallpaper-delete-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 999px;
  cursor: pointer;
}


/* Voice Toggle */

.voice-toggle {
  position: absolute;
  right: 14px;
  bottom: 14px;
  z-index: 20;

  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 12px;
  border-radius: 999px;

  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.28);
  color: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);

  pointer-events: auto;
  cursor: pointer;
  user-select: none;
}

.voice-toggle:hover {
  background: rgba(255, 255, 255, 0.10);
}

.voice-toggle.is-on {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.22);
}

.voice-toggle:disabled {
  opacity: 0.6;
  cursor: wait;
}

.voice-toggle__icon {
  font-size: 16px;
  line-height: 1;
}

.voice-toggle__label {
  font-size: 12px;
}



/* --- ensureChatUI --- */

.chat-toggle {
  position: absolute;
  right: 102px;
  bottom: 14px;
  z-index: 20;

  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 40px;
  min-width: 64px;
  padding: 0 12px;
  border-radius: 999px;

  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.28);
  color: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);

  pointer-events: auto;
  cursor: pointer;
  user-select: none;
}

.chat-toggle:hover {
  background: rgba(255, 255, 255, 0.10);
}

.chat-toggle.is-on {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.22);
}

.chat-panel {
  position: absolute;
  right: 14px;
  bottom: 62px;
  z-index: 25;

  width: 320px;
  border-radius: 16px;
  overflow: hidden;

  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.42);
  color: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(14px);

  pointer-events: auto;
}

.chat-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.chat-panel__title {
  font-size: 13px;
  font-weight: 700;
}

.chat-panel__close {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: inherit;
  cursor: pointer;
}

.chat-panel__body {
  padding: 12px;
}

.chat-panel__input {
  width: 100%;
  min-height: 100px;
  resize: vertical;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.10);
  background: rgba(255, 255, 255, 0.06);
  color: inherit;
  box-sizing: border-box;
}

.chat-panel__actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 10px;
}

.chat-panel__send {
  height: 36px;
  padding: 0 14px;
  border: 0;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.14);
  color: inherit;
  cursor: pointer;
}

/* --- CHAT 対話ログ --- */
.chat-panel__messages {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 140px;
  overflow-y: auto;
  margin-bottom: 10px;
  padding: 6px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
}

.chat-msg {
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-msg--user {
  align-self: flex-end;
  background: rgba(255, 255, 255, 0.12);
}

.chat-msg--assistant {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.08);
}


/* --- FILE OPNE--- */
.file-toggle {
  position: absolute;
  right: 180px; /* Chat(102px) + ボタン幅約80px + 余白 */
  bottom: 14px;
  z-index: 20;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.28);
  color: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  pointer-events: auto;
  cursor: pointer;
  user-select: none;
}

.file-toggle:hover {
  background: rgba(255, 255, 255, 0.10);
}
