/* =========================================================
   EDITOR 3D
   ========================================================= */
.editor { display: flex; flex-direction: column; height: 100dvh; background: var(--stage-bg); }

.editor-top {
  flex: none; height: calc(var(--topbar-h) + var(--safe-t)); padding: var(--safe-t) var(--s2) 0;
  display: flex; align-items: center; gap: 2px;
  background: var(--card); border-bottom: 1px solid var(--border); z-index: 5;
}
.editor-title { flex: 1; min-width: 0; padding: 0 var(--s1); }
.editor-title b { display: block; font-size: 15px; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.save-status { font-size: 11px; color: var(--text-2); display: flex; align-items: center; gap: 4px; min-height: 16px; }
.save-status.error { color: var(--error); }
.save-status.saved { color: var(--success); }
.editor-top .icon-btn { width: 40px; height: 40px; }
.save-btn { position: relative; min-height: 38px; padding: 0 var(--s3); font-size: 14px; }
.save-btn .dirty-dot { position: absolute; top: -3px; right: -3px; width: 10px; height: 10px; border-radius: 50%; background: var(--warning); box-shadow: 0 0 0 2px var(--card); display: none; }
.save-btn.dirty .dirty-dot { display: block; }
.save-btn .lbl { display: none; }

.editor-main { position: relative; flex: 1; min-height: 0; display: flex; }
.editor-stage { position: relative; flex: 1; min-width: 0; overflow: hidden; touch-action: none; }
.editor-stage canvas { width: 100% !important; height: 100% !important; touch-action: none; }
.stage-loading {
  position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: var(--s3);
  color: var(--text-2); font-size: 14px; background: var(--stage-bg); z-index: 2; transition: opacity var(--med);
}
.stage-loading.done { opacity: 0; pointer-events: none; }
.stage-hint {
  position: absolute; left: 50%; top: var(--s3); transform: translateX(-50%);
  padding: 6px 12px; border-radius: 99px; font-size: 12px; font-weight: 500;
  background: color-mix(in srgb, var(--card) 88%, transparent); color: var(--text-2);
  box-shadow: var(--shadow-sm); pointer-events: none; white-space: nowrap; max-width: 92%; overflow: hidden; text-overflow: ellipsis;
  transition: opacity var(--med);
}
.stage-drop { outline: 3px dashed var(--primary); outline-offset: -6px; }

/* Barra inferior com as 4 ferramentas (celular) */
.editor-tabs {
  flex: none; display: grid; grid-template-columns: repeat(4, 1fr);
  height: calc(62px + var(--safe-b)); padding-bottom: var(--safe-b);
  background: var(--card); border-top: 1px solid var(--border); z-index: 6;
}
.editor-tabs button {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--text-2); font-size: 11px; font-weight: 500;
}
.editor-tabs button svg.icon { width: 22px; height: 22px; }
.editor-tabs button[aria-pressed="true"] { color: var(--primary); font-weight: 600; }

/* Celular/tablet: a área 3D fica em cima e o painel aberto abaixo dela (sem cobrir a sala) */
.editor-main { flex-direction: column; }
.editor-stage { order: 0; min-height: 0; }
.editor-panel[data-panel="objetos"] { order: 1; }
.editor-side { order: 2; }

.editor-panel {
  position: relative; z-index: 4; flex: none;
  max-height: min(42dvh, 380px);
  display: none; flex-direction: column;
  background: var(--card); border-top: 1px solid var(--border);
  border-radius: 18px 18px 0 0; box-shadow: 0 -8px 24px rgba(32, 34, 53, 0.08);
  animation: sheet-up var(--med) var(--ease);
}
.editor[data-open="true"][data-tab="objetos"] .editor-panel[data-panel="objetos"],
.editor[data-open="true"][data-tab="selecionar"] .editor-panel[data-panel="selecionar"],
.editor[data-open="true"][data-tab="propriedades"] .editor-panel[data-panel="propriedades"],
.editor[data-open="true"][data-tab="sala"] .editor-panel[data-panel="sala"] { display: flex; }
.panel-head { display: flex; align-items: center; gap: var(--s2); padding: var(--s2) var(--s2) var(--s2) var(--s4); flex: none; }
.panel-head h2 { flex: 1; font-size: 15px; font-weight: 650; }
.panel-head .icon-btn { width: 38px; height: 38px; }
.panel-body { overflow-y: auto; overscroll-behavior: contain; padding: 0 var(--s4) var(--s4); flex: 1; min-height: 0; }
.side-tabs { display: none; }

/* Biblioteca de objetos */
.lib-tools { display: flex; flex-direction: column; gap: var(--s2); padding: 0 var(--s4) var(--s2); flex: none; }
.lib-cats .chip { min-height: 32px; padding: 0 var(--s3); font-size: 13px; }
/* Celular/tablet: uma fileira horizontal de objetos (painel baixo) */
.editor-panel[data-panel="objetos"] .panel-body { overflow: visible; padding-bottom: var(--s3); }
.lib-grid {
  display: grid; grid-auto-flow: column; grid-auto-columns: 88px; gap: var(--s2);
  overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain; scrollbar-width: none;
  margin: 0 calc(-1 * var(--s4)); padding: 2px var(--s4);
}
.lib-grid::-webkit-scrollbar { display: none; }
.lib-card {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 6px 8px; border-radius: 14px; border: 1px solid var(--border); background: var(--card);
  font-size: 12px; font-weight: 500; text-align: center; min-width: 0;
  transition: border-color var(--fast), transform var(--fast);
}
.lib-card:hover { border-color: var(--primary); }
.lib-card:active { transform: scale(0.97); }
.lib-card .thumb { width: 100%; aspect-ratio: 1; border-radius: 10px; background: var(--muted-soft); display: grid; place-items: center; overflow: hidden; }
.lib-card .thumb img { width: 100%; height: 100%; object-fit: contain; }
.lib-card .name { width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lib-card .add { position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; border-radius: 8px; background: var(--primary); color: #fff; display: grid; place-items: center; }
.lib-card .add svg.icon { width: 14px; height: 14px; stroke-width: 2.6; }
.lib-card.import .thumb { color: var(--primary); background: var(--primary-soft); }

/* Propriedades */
.prop-head { display: flex; align-items: center; gap: var(--s3); margin-bottom: var(--s3); }
.prop-head .thumb { width: 48px; height: 48px; border-radius: 12px; background: var(--muted-soft); flex: none; overflow: hidden; }
.prop-head .thumb img { width: 100%; height: 100%; object-fit: contain; }
.prop-group { padding: var(--s3) 0; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: var(--s2); }
.prop-group:first-of-type { border-top: 0; }
.prop-group > .label { font-size: 13px; font-weight: 600; color: var(--text); display: flex; align-items: center; justify-content: space-between; }
.xyz { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.xyz label { position: relative; }
.xyz label span { position: absolute; left: 9px; top: 50%; transform: translateY(-50%); font-size: 11px; font-weight: 600; color: var(--text-2); pointer-events: none; }
.xyz input { padding-left: 24px; padding-right: 4px; font-variant-numeric: tabular-nums; }
.concept-chip {
  display: flex; align-items: center; gap: var(--s3); padding: var(--s3);
  border-radius: var(--radius-btn); background: var(--primary-soft);
}
.concept-chip .ico { width: 34px; height: 34px; border-radius: 10px; background: var(--primary); color: #fff; display: grid; place-items: center; flex: none; }
.concept-chip .ico svg.icon { width: 18px; height: 18px; }
.prop-actions { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s2); }
.quick-rot { display: flex; gap: 6px; }
.quick-rot .btn { flex: 1; min-height: 36px; padding: 0 6px; font-size: 13px; }
details.precise summary { cursor: pointer; font-size: 13px; font-weight: 600; list-style: none; display: flex; align-items: center; justify-content: space-between; min-height: 36px; }
details.precise summary::-webkit-details-marker { display: none; }
details.precise summary svg.icon { width: 18px; height: 18px; transition: transform var(--fast); color: var(--text-2); }
details.precise[open] summary svg.icon { transform: rotate(180deg); }
details.precise .inner { display: flex; flex-direction: column; gap: var(--s3); padding-top: var(--s2); }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); font-size: 14px; }

/* Lista de objetos da sala */
.obj-row { display: flex; align-items: center; gap: var(--s3); padding: 8px; border-radius: 12px; width: 100%; text-align: left; }
.obj-row:hover { background: var(--muted-soft); }
.obj-row[aria-pressed="true"] { background: var(--primary-soft); }
.obj-row .thumb { width: 40px; height: 40px; border-radius: 10px; background: var(--muted-soft); overflow: hidden; flex: none; }
.obj-row .thumb img { width: 100%; height: 100%; object-fit: contain; }
.obj-row .t { font-weight: 600; font-size: 14px; }
.obj-row .s { font-size: 12px; color: var(--text-2); }
.obj-row .has-concept { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); flex: none; }

.room-swap { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--s2); }
.room-swap button { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; text-align: left; font-size: 12px; font-weight: 600; background: var(--card); }
.room-swap button .thumb { aspect-ratio: 16 / 10; background: var(--muted-soft); position: relative; }
.room-swap button .thumb img { width: 100%; height: 100%; object-fit: cover; }
.room-swap button span { display: block; padding: 6px 8px; }
.room-swap button[aria-pressed="true"] { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary); }
.color-row { display: flex; gap: 8px; flex-wrap: wrap; }
.color-row .swatch { width: 32px; height: 32px; }

/* =========================================================
   EXPLORAÇÃO EM PRIMEIRA PESSOA
   ========================================================= */
.explore { background: #111; touch-action: none; user-select: none; -webkit-user-select: none; }
.explore-stage { position: absolute; inset: 0; }
.explore-stage canvas { width: 100% !important; height: 100% !important; touch-action: none; }
.explore-top {
  position: absolute; left: 0; right: 0; top: 0; z-index: 5;
  padding: calc(var(--s3) + var(--safe-t)) var(--s3) var(--s3);
  display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; gap: var(--s2);
  pointer-events: none;
  background: linear-gradient(rgba(10, 10, 20, 0.35), transparent);
}
.explore-top > * { pointer-events: auto; }
.glass-btn {
  width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center;
  background: rgba(20, 22, 38, 0.45); color: #fff; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.14);
}
.explore-title { text-align: center; color: #fff; text-shadow: 0 1px 6px rgba(0, 0, 0, 0.45); min-width: 0; pointer-events: none !important; }
.explore-title b { display: block; font-size: 15px; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.explore-title span { font-size: 12px; opacity: 0.85; }

.look-area { position: absolute; top: 0; right: 0; bottom: 0; width: 55%; z-index: 2; touch-action: none; }
.joystick-zone { position: absolute; left: 0; bottom: 0; width: 45%; height: 60%; z-index: 3; touch-action: none; }
.joystick {
  position: absolute; left: calc(var(--s6) + env(safe-area-inset-left, 0px)); bottom: calc(var(--s8) + var(--safe-b));
  width: 132px; height: 132px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.10), rgba(255, 255, 255, 0.22));
  border: 1.5px solid rgba(255, 255, 255, 0.35);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  pointer-events: none; transition: opacity var(--fast);
  opacity: 0.8;
}
.joystick.active { opacity: 1; transition: none; }
.joystick::before, .joystick::after { content: ''; position: absolute; left: 50%; top: 50%; background: rgba(255, 255, 255, 0.35); transform: translate(-50%, -50%); }
.joystick::before { width: 2px; height: 70%; }
.joystick::after { width: 70%; height: 2px; }
.joystick-knob {
  position: absolute; left: 50%; top: 50%; width: 58px; height: 58px; margin: -29px 0 0 -29px; border-radius: 50%; z-index: 1;
  background: radial-gradient(circle at 40% 35%, #fff, #E4E5EE);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}

.interact-btn {
  position: absolute; z-index: 6; right: calc(var(--s5) + env(safe-area-inset-right, 0px)); bottom: calc(150px + var(--safe-b));
  display: flex; align-items: center; gap: var(--s3); max-width: min(72vw, 300px);
  padding: 10px 18px 10px 10px; border-radius: 18px;
  background: var(--primary); color: #fff; text-align: left;
  box-shadow: 0 8px 26px rgba(40, 40, 140, 0.45);
  animation: pop-in var(--med) var(--ease);
}
.interact-btn .ico { width: 40px; height: 40px; border-radius: 50%; background: rgba(255, 255, 255, 0.2); display: grid; place-items: center; flex: none; }
.interact-btn b { display: block; font-size: 16px; line-height: 1.2; }
.interact-btn span { display: block; font-size: 12px; opacity: 0.9; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.interact-btn .txt { min-width: 0; }

.crosshair { position: absolute; left: 50%; top: 50%; width: 6px; height: 6px; margin: -3px 0 0 -3px; border-radius: 50%; background: rgba(255, 255, 255, 0.9); box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.25); z-index: 4; pointer-events: none; display: none; }
.explore.locked .crosshair { display: block; }
.explore-hint {
  position: absolute; left: 50%; bottom: calc(var(--s5) + var(--safe-b)); transform: translateX(-50%); z-index: 4;
  padding: 8px 14px; border-radius: 99px; background: rgba(20, 22, 38, 0.55); color: #fff; font-size: 13px;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); white-space: nowrap; pointer-events: none;
  display: none;
}
.explore-hint .kbd { background: rgba(255, 255, 255, 0.12); border-color: rgba(255, 255, 255, 0.25); color: #fff; }
.lock-overlay {
  position: absolute; inset: 0; z-index: 3; display: none; place-content: center; justify-items: center; gap: var(--s3);
  background: rgba(10, 12, 24, 0.35); color: #fff; text-align: center; cursor: pointer;
}
.lock-overlay .card { color: var(--text); padding: var(--s5) var(--s6); max-width: 360px; display: flex; flex-direction: column; gap: var(--s2); align-items: center; }
.explore-loading { position: absolute; inset: 0; z-index: 8; display: grid; place-content: center; justify-items: center; gap: var(--s3); background: #15161f; color: #c9cbe0; font-size: 14px; transition: opacity var(--med); }
.explore-loading.done { opacity: 0; pointer-events: none; }

/* Painel do conceito durante a exploração */
.concept-panel {
  position: absolute; z-index: 20; left: 0; right: 0; bottom: 0;
  height: 64dvh; display: flex; flex-direction: column;
  background: var(--card); color: var(--text);
  border-radius: 22px 22px 0 0; box-shadow: var(--shadow-lg);
  animation: sheet-up var(--med) var(--ease);
  padding-bottom: var(--safe-b);
  touch-action: auto; user-select: text; -webkit-user-select: text;
}
.concept-panel .sheet-body { padding-top: 0; }
.concept-panel-backdrop { position: absolute; inset: 0; z-index: 19; background: rgba(10, 12, 24, 0.25); animation: fade-in var(--fast); }
.explore.panel-open .joystick, .explore.panel-open .joystick-zone, .explore.panel-open .look-area, .explore.panel-open .interact-btn { display: none; }

.settings-pop { position: absolute; z-index: 7; right: var(--s3); top: calc(64px + var(--safe-t)); width: min(300px, calc(100vw - 24px)); padding: var(--s4); display: flex; flex-direction: column; gap: var(--s3); animation: pop-in var(--fast) var(--ease); }

/* Aparência: acessórios e cor */
.acc-add { display: flex; flex-wrap: wrap; gap: 6px; }
.acc-add .chip { min-height: 32px; padding: 0 10px; font-size: 13px; }
.acc-card { border: 1px solid var(--border); border-radius: 12px; padding: 8px 10px 10px; display: flex; flex-direction: column; gap: 6px; background: var(--muted-soft); }
.acc-head { display: flex; align-items: center; gap: 8px; }
.acc-head b { font-size: 14px; flex: 1; min-width: 0; }
.acc-head .select { width: auto; min-width: 0; max-width: 150px; min-height: 34px; font-size: 13px; padding: 0 8px; }
.acc-head .icon-btn { width: 34px; height: 34px; }
.acc-card .color-row .swatch, [data-looks] .color-row .swatch { width: 26px; height: 26px; }
.acc-card .color-row .swatch svg.icon, [data-looks] .color-row .swatch svg.icon { width: 14px; height: 14px; }
[data-looks] .color-row .chip { min-height: 26px; padding: 0 10px; font-size: 12px; }
details.precise summary > span { display: inline-flex; align-items: center; gap: 6px; }
details.precise summary > span svg.icon { width: 16px; height: 16px; color: var(--primary); }
.acc-card { background: var(--card); }
.acc-card input[type="range"]::-webkit-slider-runnable-track { background: var(--border); }
.acc-card input[type="range"]::-moz-range-track { background: var(--border); }
.segmented button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.segmented button svg.icon { width: 16px; height: 16px; }
