@import url('https://fonts.googleapis.com/css2?family=Comfortaa:wght@300..700&display=swap');

:root {
  --font-ui: 'Comfortaa', sans-serif;
  --dot-panel: radial-gradient(circle at 1px 1px, rgba(0, 0, 0, .22) .9px, transparent 0);
  --dot-soft: radial-gradient(circle at 1px 1px, rgba(0, 0, 0, .13) .8px, transparent 0);
  --dot-faint: radial-gradient(circle at 1px 1px, rgba(0, 0, 0, .08) .7px, transparent 0);
  --wr: 255px 15px 225px 15px / 15px 225px 15px 255px;
  --wrs: 85px 15px 75px 15px / 15px 75px 15px 85px;
  --fg: #1a1a2e;
  --bg: #fff;
  --panel: #fff;
  --body-bg: #fff;
  --glass-bg: #fff;
  --glass-border: #000;
  --cur: rgba(200, 200, 220, .45);
  --com: #6272a4;
  --cy: #8be9fd;
  --gr: #50fa7b;
  --or: #ffb86c;
  --pk: #ff79c6;
  --pu: #A855F7;
  --ye: #f1fa8c;
  --re: #ff5555;
  --bm: 1.5px dashed #000;
  --border: 1.5px dashed var(--glass-border);
  --border-thin: 1px dashed rgba(0, 0, 0, .14);
  --ps: rgba(168, 85, 247, .08);
  --ps-dark: rgba(168, 85, 247, .12);
  --shadow-1: 3px 3px 0 rgba(124, 58, 237, .16);
  --shadow-2: 4px 4px 0 rgba(124, 58, 237, .18);
  --theme-shadow: var(--shadow-2);
  /* Code syntax tokens (Day mode) */
  --code-kw: #7c3aed;
  --code-type: #0369a1;
  --code-fn: #15803d;
  --code-str: #a16207;
  --code-num: #c2410c;
  --code-com: #64748b;
  --code-builtin: #be123c;
  --code-op: #6d28d9;
  --code-punct: #475569;
}

html.night-mode {
  --fg: #ffffff;
  --bg: #2b2d31;
  --panel: #222327;
  --body-bg: #1e1f22;
  --glass-bg: #2b2d31;
  --glass-border: #ffffff;
  --com: #94a3b8;
  --cur: rgba(100, 100, 140, .45);
  --ps: rgba(168, 85, 247, .16);
  --ps-dark: rgba(168, 85, 247, .28);
  --bm: 1.5px dashed #ffffff;
  --border-thin: 1px dashed rgba(255, 255, 255, .12);
  --shadow-1: 3px 3px 0 rgba(124, 58, 237, .22);
  --shadow-2: 4px 4px 0 rgba(124, 58, 237, .26);
  --dot-panel: radial-gradient(circle at 1px 1px, rgba(255, 255, 255, .13) .9px, transparent 0);
  --dot-soft: radial-gradient(circle at 1px 1px, rgba(255, 255, 255, .08) .8px, transparent 0);
  --dot-faint: radial-gradient(circle at 1px 1px, rgba(255, 255, 255, .05) .7px, transparent 0);
  color-scheme: dark;
  /* Code syntax tokens (Night mode) */
  --code-kw: #c4b5fd;
  --code-type: #7dd3fc;
  --code-fn: #86efac;
  --code-str: #fde68a;
  --code-num: #fdba74;
  --code-com: #94a3b8;
  --code-builtin: #fda4af;
  --code-op: #c4b5fd;
  --code-punct: #cbd5e1;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: var(--font-ui);
  outline: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--body-bg);
  background-image: var(--dot-soft);
  background-size: 18px 18px;
  color: var(--fg);
  font-size: 14px;
}

body {
  display: flex;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body.mobile-ui {
  flex-direction: column;
}

/* ── Containers & Panels ── */
:is(.panel, .panel-r, .popup) {
  background: var(--glass-bg);
  border: var(--border);
  box-shadow: var(--theme-shadow);
}

.center {
  background: var(--glass-bg);
  border-block: 1.5px solid var(--glass-border);
  flex: 1;
  min-width: 0;
}

:is(.panel, .panel-r, .center) {
  display: flex;
  flex-direction: column;
  position: relative;
  flex-shrink: 0;
  border-radius: var(--wr);
}

.panel {
  width: 280px;
  min-width: 220px;
  height: 100vh;
  z-index: 10;
  border-radius: 0 15px 225px 0 / 0 225px 15px 0;
}

#panel-left {
  border-left: none;
}

.panel-r {
  width: 300px;
  min-width: 240px;
  max-width: 360px;
  height: 100vh;
  overflow: hidden;
  border-radius: 0 15px 225px 0 / 0 225px 15px 0;
}

:is(#panel-left, #panel-right, #asset-panel-container, .bot-tab-content, .head, .toolbar, .bot-header) {
  background: var(--glass-bg);
}

#asset-panel-container {
  border-top: var(--border);
}

.head {
  height: 22px;
  padding: 0 8px 0 11px;
  border-bottom: var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .8px;
  text-transform: uppercase;
  position: relative;
}

/* Barre accent colorée collée sur le bord gauche, pleine hauteur */
.head::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--gr);
}

/* Hiérarchie → violet */
#panel-left .dock-slot[data-slot="top"] .head::before {
  background: var(--pu);
}

/* Assets → cyan */
#asset-panel-container .head::before {
  background: var(--cy);
}

/* Inspector → orange */
#panel-right .head::before {
  background: var(--or);
}

.head-label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .8px;
  text-transform: uppercase;
  color: var(--fg);
  opacity: 0.85;
  flex: 1;
}

/* ── Toolbar & Buttons ── */
.toolbar {
  position: relative;
  height: 22px;
  padding: 0 6px;
  border-bottom: var(--border);
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  min-width: 0;
}

.toolbar :is(.btn-tool, .toolbar-scene-tab) {
  height: 20px;
}

:is(.btn-tool, .bot-mode-tab, .toolbar-scene-tab, .main-add-btn) {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 28px;
  height: 30px;
  padding: 4px 10px;
  border: none;
  background: transparent;
  color: var(--com);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  cursor: pointer;
}

:is(.btn-tool, .bot-mode-tab, .toolbar-scene-tab) {
  border-radius: 12px 12px 0 0;
}

#tools-popup {
  position: sticky;
  top: 10px;
  left: 10px;
  float: left;
  margin-bottom: -300px;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6px 4px;
  gap: 4px;
  border-radius: 12px;
  background: var(--glass-bg);
  border: var(--border);
  box-shadow: var(--theme-shadow);
}

#tools-popup .btn-tool {
  width: 32px;
  height: 32px;
  min-width: 32px;
  padding: 0;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#tools-popup .toolbar-sep {
  width: 20px;
  height: 1px;
  margin: 2px 0;
  background: rgba(0, 0, 0, .14);
}

:is(.btn-tool, .bot-mode-tab, .toolbar-scene-tab)::after {
  content: '';
  position: absolute;
  left: 10%;
  bottom: 0;
  width: 80%;
  height: 2.5px;
  background: var(--pu);
  border-radius: 2px 2px 0 0;
  transform: scaleX(0);
  transition: transform .2s;
}

:is(.btn-tool, .bot-mode-tab, .toolbar-scene-tab):hover {
  color: var(--fg);
  background: rgba(168, 85, 247, .08);
}

:is(.btn-tool, .bot-mode-tab, .toolbar-scene-tab).active {
  color: var(--pu);
  background: rgba(168, 85, 247, .12);
}

:is(.btn-tool, .bot-mode-tab, .toolbar-scene-tab).active::after {
  transform: scaleX(1);
}

:is(.btn-tool, .zoom-btn, .ctx-item, .asset, .card-item):active {
  transform: scale(.97);
}

.toolbar-scene-tabs {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 2px;
  min-width: 0;
  overflow: hidden;
}

.toolbar-scene-tab {
  min-width: 0;
  padding-inline: 10px 6px;
  white-space: nowrap;
}

.tab-lbl {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tab-del {
  display: none;
  font-size: 13px;
  line-height: 1;
  padding: 0 2px;
  border-radius: 4px;
}

.toolbar-scene-tab.active .tab-del {
  display: inline-block;
}

.tab-del:hover {
  color: var(--pk);
  background: rgba(255, 121, 198, .1);
}

.tab-rename-input {
  width: 60px;
  height: 24px;
  padding: 0 6px;
  border: var(--border-thin);
  border-radius: 8px;
  background: var(--glass-bg);
  color: var(--fg);
  font-size: 11px;
  font-weight: 700;
}

.toolbar-spacer {
  flex: 1;
}

.toolbar-sep {
  width: 1px;
  height: 20px;
  background: var(--cur);
  flex-shrink: 0;
}

.main-add-btn {
  width: 24px;
  min-width: 24px;
  padding: 0;
  color: var(--fg);
  margin-left: auto;
}

.main-add-btn .material-symbols-rounded {
  font-size: 20px;
}

/* ── Viewport & Scene Frame ── */
.workspace-viewport-container {
  position: relative;
  flex: 1;
  min-height: 0;
  width: 100%;
  display: flex;
  overflow: hidden;
}

#viewport {
  flex: 1;
  min-height: 0;
  width: 100%;
  height: 100%;
  overflow: scroll;
  display: block;
  background-color: #111113;
  background-image: radial-gradient(circle at 1px 1px, rgba(255, 255, 255, .07) 1px, transparent 0);
  background-size: 24px 24px;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

#viewport::-webkit-scrollbar {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
}

/* ── Workspace Custom Scrollbar ── */
.wsb {
  position: absolute;
  z-index: 90;
  cursor: default;
  opacity: .5;
}

.wsb-v {
  top: 8px;
  right: 4px;
  bottom: 20px;
  width: 6px;
}

.wsb-h {
  left: 8px;
  bottom: 4px;
  right: 20px;
  height: 6px;
}

.wsb-thumb {
  position: absolute;
  border-radius: 999px;
  background: rgba(180, 180, 180, .45);
  cursor: default;
}

.wsb-v .wsb-thumb {
  width: 100%;
  min-height: 20px;
}

.wsb-h .wsb-thumb {
  height: 100%;
  min-width: 20px;
}

.wsb-thumb.active {
  cursor: default;
  background: rgba(180, 180, 180, .65);
}

#scene-container {
  width: 8000px;
  height: 5000px;
  position: relative;
  display: grid;
  place-items: center;
  transform-origin: center center;
  z-index: 1;
}

#scene-frame {
  width: 800px;
  height: 600px;
  position: relative;
  border: 1.5px solid var(--glass-border);
  background: #ffffff;
  box-shadow: none;
  outline: none;
  flex-shrink: 0;
  overflow: visible;
}

.zoom-ctrl {
  position: sticky;
  top: calc(100% - 35px);
  left: calc(100% - 60px);
  float: right;
  margin-bottom: -35px;
  z-index: 50;
  display: flex;
  gap: 4px;
  opacity: 0.65;
  transition: opacity .2s;
}

.zoom-ctrl:hover {
  opacity: 1;
}

.zoom-btn {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border: 1px dashed rgba(0, 0, 0, .18);
  border-radius: 6px;
  background: var(--glass-bg);
  color: var(--fg);
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .08);
}

.zoom-btn:hover {
  color: var(--pu);
  border-color: var(--pu);
}

.zoom-btn.active {
  color: #fff;
  border-color: var(--pu);
  background: var(--pu);
}

/* ── Content & Hierarchy ── */
:is(#hierarchy, #inspector-content, #assets) {
  flex: 1;
  min-height: 0;
  margin: 6px;
  background: transparent;
}

:is(#hierarchy, #inspector-content) {
  overflow: hidden auto;
}

#inspector-content {
  padding: 10px 8px 10px 12px;
}

:is(.item, .asset, .card-item) {
  border: var(--border);
  background: transparent;
  transition: border-color .15s, background .15s, transform .15s;
}

.item {
  margin: 3px 8px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-radius: var(--wrs);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  border-left-style: solid;
  color: var(--fg);
}

.item:hover {
  background: var(--ps);
}

.item.active {
  background: var(--ps-dark);
  border-left: 3px solid var(--pu);
  color: var(--fg);
}

.hier-row-actions {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.hier-rigidbody {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  color: #EF4444;
  background: transparent;
  cursor: pointer;
  margin-left: 0;
  flex-shrink: 0;
}

.hier-rigidbody .material-symbols-rounded {
  font-size: 17px;
  overflow: visible;
}

.hier-rigidbody.disabled { opacity: .45; }

.hier-rust {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: #F97316;
  cursor: pointer;
  flex-shrink: 0;
}

.hier-rust .material-symbols-rounded { font-size: 15px; }
.hier-rust:hover { background: #F9731622; }

.item span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hier-icon {
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  line-height: 1;
}

.hier-icon > img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.hier-icon.material-symbols-rounded {
  font-size: 20px;
}

.hier-icon > .material-symbols-rounded {
  min-width: 20px;
  overflow: visible;
}

/* ── Assets Grid ── */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  align-content: flex-start;
  gap: 8px;
  padding: 10px;
  overflow: auto;
}

.asset {
  width: 100%;
  min-height: 66px;
  padding: 6px 4px;
  border-radius: var(--wrs);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  cursor: grab;
}

:is(.asset, .card-item):hover {
  border-color: var(--pu);
}

.asset-sel {
  border-color: #7c3aed !important;
  background: rgba(124, 58, 237, .18) !important;
  outline: none;
}

.asset img {
  display: block;
  width: 100%;
  height: 40px;
  max-width: 100%;
  object-fit: contain;
  pointer-events: none;
}

.btn-imp {
  padding: 5px 14px;
  border: var(--border);
  border-radius: 999px;
  background: var(--fg);
  color: var(--glass-bg);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .5px;
  text-transform: uppercase;
  cursor: pointer;
}

:is(.btn-imp:hover, .btn-imp.active) {
  background: var(--pu);
  border-color: var(--pu);
  color: #fff;
}

/* ── Form Controls & Steppers ── */
.insp-grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px 10px;
}

.insp-grid-2 > .g-row {
  grid-column: auto;
}

.g-content {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px 10px;
  align-items: start;
}

.g-content> :is(.insp-grid-2, .p-content, .g-row, .grp-title, .field-row-full, .inspector-section, textarea, .ui-textarea) {
  grid-column: 1 / -1;
  width: 100%;
}

.g-content> :is(blender-input, .field-group) {
  width: 100%;
  min-width: 0;
}

.field-group {
  min-width: 0;
  display: flex;
  flex-direction: column;
  width: 100%;
}

:is(.field-group label, .field-label) {
  display: block;
  font-size: 10px;
  font-weight: 700;
  margin-bottom: 2px;
  opacity: 0.85;
  letter-spacing: 0.4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.input-stepper-merged {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  position: relative;
  background: var(--glass-bg);
  border: var(--bm);
  border-radius: var(--wrs);
  padding: 1px 4px 5px 4px;
  height: 26px;
  width: 100%;
}

.input-stepper-merged.no-slider {
  height: 22px;
  padding: 0 4px;
  justify-content: center;
}

.stepper-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2px;
  height: 16px;
  width: 100%;
  flex-shrink: 0;
  margin-top: 1px;
}

.input-stepper-merged.no-slider .stepper-row {
  height: 100%;
  margin-top: 0;
}

.stepper-btn {
  border: none;
  background: transparent;
  font-size: 9px;
  cursor: pointer;
  color: var(--com);
  padding: 0 3px;
  font-weight: bold;
  line-height: 1;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 16px;
  z-index: 3;
}

.input-stepper-merged.no-slider .stepper-btn {
  height: 100%;
}

.stepper-btn:hover {
  color: var(--pu);
}

.stepper-val {
  flex: 1;
  min-width: 20px;
  width: 100%;
  border: none !important;
  text-align: center;
  font-weight: 700;
  font-size: 11px;
  outline: none;
  background: transparent !important;
  height: 16px !important;
  padding: 0 !important;
  color: var(--fg);
  line-height: 16px;
  box-shadow: none !important;
  border-radius: 0 !important;
  z-index: 1;
}

.input-stepper-merged.no-slider .stepper-val {
  height: 100% !important;
  line-height: 20px;
}

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type="number"] {
  -moz-appearance: textfield;
  text-align: center;
}

.mini-slider {
  position: absolute;
  bottom: 1px;
  left: 6px;
  width: calc(100% - 12px);
  height: 8px;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  z-index: 2;
  user-select: none;
  touch-action: none;
  display: flex;
  align-items: center;
}

.mini-slider-bar {
  width: 100%;
  height: 2px;
  background: var(--cur);
  border-radius: 2px;
  position: relative;
  pointer-events: none;
}

.mini-slider-thumb {
  position: absolute;
  top: 50%;
  left: 0%;
  width: 7.5px;
  height: 7.5px;
  border-radius: 50%;
  background: var(--pu);
  border: 1px solid var(--glass-bg);
  transform: translate(-50%, -50%);
  pointer-events: none;
  transition: none;
}

.mini-slider::-webkit-slider-runnable-track {
  height: 2px;
  background: var(--cur);
  border-radius: 2px;
  border: none;
}

.mini-slider::-moz-range-track {
  height: 2px;
  background: var(--cur);
  border-radius: 2px;
  border: none;
}

.mini-slider::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 7.5px;
  height: 7.5px;
  border-radius: 50%;
  background: var(--pu);
  border: 1px solid var(--glass-bg);
  cursor: pointer;
}

.mini-slider::-moz-range-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 7.5px;
  height: 7.5px;
  border-radius: 50%;
  background: var(--pu);
  border: 1px solid var(--glass-bg);
  cursor: pointer;
  transition: none;
}

.mini-slider::-webkit-slider-thumb {
  margin-top: -2.75px;
}

:is(input:not(.stepper-val, .mini-slider, [type="checkbox"], [type="range"]), textarea, select, .insp-toggle-btn, .ui-select-trigger) {
  max-width: 100%;
  min-width: 0;
  color: var(--fg);
  background: var(--glass-bg);
  background-image: var(--dot-faint);
  background-size: 14px 14px;
  border: var(--border);
  border-radius: var(--wrs);
  user-select: text;
}

:is(input:not(.stepper-val, .mini-slider, [type="checkbox"], [type="range"]), select, .insp-toggle-btn, .ui-select-trigger) {
  height: 26px;
  padding: 2px 8px;
  font-size: 11px;
}

.ui-select-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  cursor: pointer;
  width: 100%;
  text-align: left;
  user-select: none;
}

.ui-select-trigger>span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

textarea,
.ui-textarea {
  padding: 10px 12px;
  width: 100%;
  min-height: 72px;
  resize: vertical;
  line-height: 1.45;
}

:is(input, textarea, select):focus,

:is(.g-row, .popup-row, .insp-toggle-group) {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.g-row {
  grid-column: 1 / -1;
  margin: 4px 0;
  flex-wrap: wrap;
}

input[type='checkbox'] {
  width: 17px;
  height: 17px;
  min-width: 17px;
  margin: 0;
  border-radius: 4px;
  cursor: pointer;
  accent-color: var(--pu);
}

.inspector-color-flower {
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  border: 2px solid rgba(255, 255, 255, .92);
  border-radius: 999px;
  background: currentColor;
  cursor: pointer;
}

.insp-flex-col {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.p-content {
  min-width: 0;
  padding: 6px;
}

.field-help {
  min-width: 0;
  color: var(--com);
  font-size: 10px;
  line-height: 1.4;
}

.custom-scrollbar {
  flex: 1;
  min-height: 0;
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--com) transparent;
}

.custom-scrollbar::-webkit-scrollbar { width: 6px; height: 6px; }
.custom-scrollbar::-webkit-scrollbar-thumb { background: var(--cur); border-radius: 999px; }

.grp-title {
  margin: 10px 0 6px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .6px;
  text-transform: uppercase;
  color: var(--com);
  display: flex;
  align-items: center;
  gap: 5px;
}

.grp-title::before {
  content: '';
  display: inline-block;
  width: 3px;
  height: 11px;
  border-radius: 2px;
  background: var(--cy);
  flex-shrink: 0;
}

#inspector-content .grp-title::before,
#inspector-content .section-title::before {
  display: none;
}

.inspector-section {
  padding-bottom: 8px;
  margin-bottom: 8px;
  border-bottom: none;
}

.inspector-section>summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  list-style: none;
  padding: 2px 0 6px;
}

.inspector-section>summary::-webkit-details-marker {
  display: none;
}

.inspector-section>summary::after {
  content: '›';
  font-size: 16px;
  font-weight: 700;
  color: var(--com);
  line-height: 1;
  transition: transform .2s;
  margin-left: auto;
  padding-left: 8px;
}

.inspector-section[open]>summary::after {
  transform: rotate(90deg);
}

.section-title {
  font-weight: 900;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

.section-title::before {
  content: '';
  display: inline-block;
  width: 3px;
  height: 12px;
  border-radius: 2px;
  background: var(--or);
  flex-shrink: 0;
}

/* ── Scene Objects — ghost divs (Canvas 2D render) ── */
.obj {
  position: absolute;
  pointer-events: none;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  outline: none !important;
  overflow: visible;
}

.obj>canvas {
  pointer-events: auto;
}

.audio-pivot {
  display: none !important;
}

/* ── Bottom Panel & Timeline ── */
#bot-panel {
  height: 260px;
  min-height: 80px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-top: var(--border);
  margin: 0;
  transition: height .18s ease;
}

#bot-panel.collapsed {
  height: 30px !important;
  min-height: 30px;
}



textarea,
input:not([type="button"]):not([type="submit"]):not([type="reset"]):not([type="checkbox"]):not([type="radio"]) {
  user-select: text !important;
  -webkit-user-select: text !important;
}



.bot-header {
  height: 30px;
  padding: 0 6px;
  display: flex;
  align-items: flex-end;
  flex-shrink: 0;
  border-bottom: var(--border);
  gap: 2px;
  overflow-x: auto;
  overflow-y: hidden;
  min-width: 0;
}

.bot-mode-tab {
  min-width: 0;
  max-width: 160px;
  flex: 0 1 auto;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.bot-mode-tab::before {
  content: '';
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 1px;
  background: var(--com);
  flex-shrink: 0;
  opacity: 0.5;
  transition: opacity .15s, background .15s;
}

.bot-mode-tab.active::before {
  background: var(--pk);
  opacity: 1;
}

.tab-close-console:hover {
  color: var(--re);
  opacity: 1 !important;
}

.bot-tab-content {
  display: none;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}


.bot-tab-content.active {
  display: flex;
  flex-direction: column;
}

/* ── Animation Panel Layout & Timeline ── */
:is(#m-anim, .ar) {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.at {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  padding: 3px 8px;
  flex-shrink: 0;
  border-bottom: var(--border-thin);
}

.atw {
  flex: 1;
  min-height: 0;
  overflow: auto;
  position: relative;
}

#anim-timeline {
  position: relative;
  min-width: 100%;
  min-height: 100%;
  padding-bottom: 12px;
}

.atr {
  position: relative;
  min-width: max-content;
  width: 100%;
  display: flex;
  flex-direction: column;
}

.anim-ruler {
  position: relative;
  height: 18px;
  margin-left: 58px;
  border-bottom: var(--border-thin);
  background: var(--ps);
}

.anim-ruler-mark {
  position: absolute;
  top: 2px;
  font-size: 9px;
  font-weight: 800;
  color: var(--com);
  border-left: 1px solid var(--cur);
  padding-left: 2px;
}

.anim-track-row {
  display: flex;
  align-items: center;
  position: relative;
  height: 28px;
  padding: 0 6px 0 4px;
  border-bottom: var(--border-thin);
}

:is(.anim-track-row:hover, .anim-track-row.active-track) {
  background: rgba(255, 255, 255, .03);
}

.anim-track-row.active-track {
  border-left: 3px solid rgba(255, 255, 255, .2);
}

.track-label {
  width: 50px;
  min-width: 50px;
  font-size: 10px;
  font-weight: 700;
  color: var(--com);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-right: 4px;
}

.anim-track-line {
  position: relative;
  flex: 1;
  height: 20px;
  background: var(--dot-faint);
  border: var(--border-thin);
  border-radius: 4px;
}

.anim-track-span {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  height: 5px;
  background: rgba(255, 255, 255, .2);
  border-radius: 3px;
  opacity: 0.75;
}

.anim-frame {
  position: absolute;
  top: 50%;
  width: 10px;
  height: 10px;
  transform: translate(-50%, -50%) rotate(45deg);
  background: var(--panel);
  border: 2px solid rgba(255, 255, 255, .55);
  border-radius: 2px;
  cursor: grab;
  z-index: 3;
}

:is(.anim-frame:hover, .anim-frame.active) {
  background: rgba(255, 255, 255, .9);
  border-color: rgba(255, 255, 255, .95);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .25);
}

html:not(.night-mode) .anim-frame {
  background: #000;
  border-color: #000;
}

html:not(.night-mode) :is(.anim-frame:hover, .anim-frame.active) {
  background: #000;
  border-color: #000;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, .35);
}

.aunit {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
  color: var(--com);
}

.anim-num-inp {
  width: 44px;
  height: 20px;
  padding: 0 4px;
  font-weight: 800;
  font-size: 11px;
  text-align: center;
}

.anim-name-bar {
  border-top: var(--border-thin);
  border-bottom: none;
  justify-content: center;
  height: 28px;
}

.atarget {
  font-weight: 800;
  font-size: 12px;
  color: var(--fg);
  padding: 2px 8px;
  border-radius: 6px;
  cursor: pointer;
}

.atarget:hover {
  background: var(--ps);
  color: var(--pu);
}

.anim-track-row .tab-del {
  display: inline-block;
  margin-left: 6px;
  opacity: 0.6;
  transition: opacity .15s;
}

.anim-track-row:hover .tab-del {
  display: inline-block;
  opacity: 1;
}

#anim-playhead {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--re);
  z-index: 10;
  pointer-events: none;
  box-shadow: 0 0 4px var(--re);
}

#anim-playhead::before {
  content: '';
  position: absolute;
  top: 0;
  left: -4px;
  width: 10px;
  height: 7px;
  background: var(--re);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
}

.anim-ghost {
  border: 1.5px dashed var(--pu);
  box-shadow: 0 0 5px rgba(124, 58, 237, 0.15);
}

/* ── Popups & Context Menus ── */
.popup {
  position: fixed;
  display: none;
  min-width: 200px;
  padding: 10px;
  border-radius: var(--wr);
  background-image: var(--dot-panel);
  background-size: 18px 18px;
  z-index: 200;
}

.ctx-item {
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1.5px dashed transparent;
  border-radius: var(--wrs);
  color: var(--fg);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.ctx-item:hover {
  color: var(--pu);
  background: var(--ps);
  border-color: rgba(168, 85, 247, .2);
}

.btn-imp-sm {
  padding: 2px 8px;
  font-size: 10px;
  border-radius: 999px;
}

.head-tools {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.head-tools .btn-tool {
  height: 18px;
  min-width: 20px;
  min-height: 0;
  padding: 0 4px;
  border-radius: 4px;
}

.head-tools .main-add-btn {
  margin-left: 0;
}

.head-tools .btn-tool .material-symbols-rounded {
  font-size: 15px !important;
}

.scene-merge-card.active {
  background: var(--bg);
}

.head-tools .inspector-icon {
  font-size: 16px !important;
  color: var(--com);
  opacity: 0.85;
  margin-left: 2px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.tool-inline .material-symbols-rounded,
.mobile-ui .toolbar .btn-tool .material-symbols-rounded {
  font-size: 18px;
}

:is(.grp-title, .ctx-item, .btn-tool) .material-symbols-rounded {
  font-size: 16px;
}

:is(.section-title, .btn-imp, .zoom-btn) .material-symbols-rounded {
  font-size: 14px;
}

.material-symbols-rounded {
  font-family: 'Material Symbols Rounded';
  font-size: 18px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-feature-settings: 'liga';
}

/* Mobile keeps the scene and the bottom dock independent. */
@supports (height: 100dvh) { html, body { height: 100dvh; } }
body.mobile-ui #viewport { flex: 1; min-height: 0; height: 100%; touch-action: none; overscroll-behavior: contain; }
body.mobile-ui .workspace-viewport-container { flex: 1 1 auto; min-height: 130px; overflow: hidden; }
body.mobile-ui #workspace-area { position: relative; z-index: 10; flex: 0 1 36vh; min-height: 120px; margin-top: -12px; overflow: hidden; padding-bottom: env(safe-area-inset-bottom); }
body.mobile-ui #bot-panel { display: flex; flex: 1; width: 100%; height: 100%; min-height: 0; flex-direction: column-reverse; overflow: hidden; border: var(--border); border-radius: 12px 12px 0 0; background: var(--glass-bg); box-shadow: var(--theme-shadow); }
body.mobile-ui #bot-panel .bot-tab-content { width: 100%; height: 100%; min-height: 0; flex: 1; overflow: hidden; }
body.mobile-ui #bot-panel .bot-tab-content > .panel { width: 100%; height: 100%; min-width: 0; min-height: 0; flex: 1; margin: 0; border: 0; border-radius: 12px 12px 0 0; box-shadow: none; }
body.mobile-ui #bot-panel .bot-header { height: 38px; align-items: center; border-top: var(--border); border-bottom: 0; }
body.mobile-ui #bot-panel .bot-header .btn-tool { flex: 0 0 32px; width: 32px; min-width: 32px; height: 32px; padding: 0; }
body.mobile-ui #bot-panel .bot-mode-tab { flex-shrink: 0; gap: 0; padding: 4px 8px; font-size: 0; }
body.mobile-ui #bot-panel .bot-mode-tab::before { display: none; }
body.mobile-ui #bot-panel .bot-mode-tab .material-symbols-rounded { font-size: 20px; }
body.mobile-ui #bot-panel.collapsed { height: 30px !important; min-height: 30px; }
body.mobile-ui #bot-panel.collapsed .bot-header { height: 30px; }
body.mobile-ui #bot-panel.collapsed .bot-header > :not(#btn-collapse-bot) { display: none; }
body.mobile-ui #bot-panel.collapsed #btn-collapse-bot { height: 24px; flex-basis: 24px; }
body.mobile-ui #bot-panel.collapsed .bot-tab-content { display: none; }
body.mobile-ui .toolbar { height: 52px; padding: 0 10px; gap: 6px; overflow-x: auto; overflow-y: hidden; touch-action: pan-x; background-image: var(--dot-panel); background-size: 18px 18px; }
body.mobile-ui .toolbar > :not(.toolbar-scene-tabs, .toolbar-spacer) { flex-shrink: 0; }
body.mobile-ui .toolbar-scene-tabs { flex: 0 0 auto; min-width: max-content; overflow: visible; }
body.mobile-ui .toolbar-spacer { display: none; }
body.mobile-ui .toolbar :is(.btn-tool, .main-add-btn) { flex: 0 0 32px; width: 32px; min-width: 32px; height: 32px; padding: 0; }
body.mobile-ui #tools-popup { margin-right: -44px; }
body.mobile-ui #tools-popup.collapsed > :not(#btn-gizmo-fold) { display: none; }
body.mobile-ui #resizer { position: relative; z-index: 20; height: 24px; margin: -12px 0; flex-shrink: 0; touch-action: none; cursor: row-resize; }
body.mobile-ui #script-editor { user-select: text; -webkit-user-select: text; touch-action: pan-x pan-y; }
body.mobile-ui .wsb { display: none; }
@media (max-height: 560px) { body.mobile-ui .workspace-viewport-container { min-height: 95px; } body.mobile-ui #workspace-area { min-height: 95px; } }

.panel-side-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  padding: 8px 10px;
  border-bottom: var(--border-thin);
}

.panel-side-tools .btn-tool {
  border-radius: 8px;
  height: 30px;
  min-width: 30px;
  padding: 0;
}

.panel-side-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  flex-shrink: 0;
}


/* ── Home (Main Menu) ── */
.menu-overlay {
  position: fixed;
  inset: 0;
  z-index: 5000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 64px 16px 16px;
}

.menu-nav { position: absolute; top: 18px; z-index: 201; display: flex; gap: 8px; }
.menu-doc-page { position: absolute; inset: 72px 12px 24px 8vw; padding-right: calc(8vw - 12px); overflow: auto; color: var(--fg); line-height: 1.6; }
.menu-doc-page h1 { margin-bottom: 8px; color: var(--fg); font-size: clamp(24px, 4vw, 38px); }
.menu-engine-icon { color: #38BDF8; font-size: 64px; line-height: 1; }
.menu-doc-page h1 { display: flex; align-items: center; gap: 10px; }
.menu-doc-page h1 .menu-engine-icon { font-size: clamp(34px, 4vw, 46px); }
.menu-doc-page h2 { margin: 24px 0 6px; color: var(--pu); font-size: 15px; letter-spacing: .8px; text-transform: uppercase; }
.menu-doc-page ul { padding-left: 22px; }
.menu-examples-page { padding-bottom: 18px; }
.examples-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(min(100%,360px),1fr)); gap:12px; padding:8px 4px 20px 0; }
.example-card { display:flex; min-width:0; flex-direction:column; gap:8px; padding:12px; border:var(--border); border-radius:var(--wrs); background:var(--glass-bg); box-shadow:2px 2px 0 var(--cur); }
.example-card-heading { display:flex; align-items:center; justify-content:space-between; gap:8px; }
.example-card-heading h2 { margin:0; color:var(--fg); font-size:13px; letter-spacing:0; text-transform:none; }
.example-category { flex:none; border:1px dashed var(--pu); border-radius:999px; padding:2px 7px; color:var(--pu); font-size:9px; font-weight:800; text-transform:uppercase; }
.example-card p { margin:0; color:var(--com); font-size:11px; }
.example-code { box-sizing:border-box; max-height:210px; min-height:128px; overflow:auto; margin:0; padding:9px; border:var(--border-thin); border-radius:6px; background:var(--body-bg); color:var(--fg); font:10px/1.5 'Cascadia Code',Consolas,'Courier New',monospace; white-space:pre; }
.example-copy { align-self:flex-start; }
.example-copy .material-symbols-rounded { font-size:14px; }
.examples-loading,.examples-error { padding:16px; color:var(--com); font-size:12px; }
@media (max-width:700px) {
  .menu-nav { max-width:calc(100vw - 20px); flex-wrap:wrap; justify-content:center; top:8px; gap:4px; }
  .menu-nav .btn-imp { padding:4px 7px; font-size:10px; }
  .menu-doc-page { inset:82px 10px 16px; padding-right:0; }
  .examples-grid { grid-template-columns:minmax(0,1fr); }
}

/* ── Dock Section Drag & Drop ── */
.dock-slot {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.dock-slot.slot-empty {
  flex: 0 0 0 !important;
  min-height: 0 !important;
  overflow: hidden;
}

.dock-section {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

body.is-dragging-dock .dock-slot.slot-empty {
  flex: 1 !important;
  min-height: 50px !important;
  overflow: visible;
  pointer-events: auto;
  outline: 2px dashed rgba(124, 58, 237, 0.4);
  outline-offset: -3px;
}

.dock-tab-bar {
  display: flex;
  gap: 4px;
  padding: 4px 6px;
  background: var(--glass-bg);
  border-bottom: var(--border);
  flex-shrink: 0;
}

.dock-tab {
  padding: 4px 10px;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  border: none;
  background: transparent;
  color: var(--com);
  cursor: pointer;
  border-radius: 6px 6px 0 0;
}

.dock-tab:hover {
  color: var(--fg);
  background: var(--ps);
}

.dock-tab.active {
  color: var(--pu);
  background: var(--ps-dark);
  box-shadow: inset 0 -2px 0 var(--pu);
}

/* ── Helper Utility Classes ── */
.row-flex {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.row-flex-sm {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
  border-bottom: var(--border-thin);
}

.col-flex {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.grid-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 6px;
  padding: 8px 8px 8px 12px;
  border-left: 1.5px dashed var(--cur);
  margin: 2px 0 0 6px;
}

.inp-sm {
  flex: 1;
  min-width: 0;
  background: var(--ps);
  border: var(--border-thin);
  border-radius: 4px;
  color: var(--fg);
  padding: 2px 6px;
  font-size: 11px;
}

.card-item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 4px;
  border-radius: var(--wrs);
  background: var(--bg);
  border: var(--border);
  cursor: pointer;
  transition: border-color .15s, background .15s, transform .15s;
}

.card-item.active {
  border-color: var(--pu);
  background: var(--ps-dark);
}

/* ── UI2D Widgets ── */
.ui-node-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
}

.ui-native-btn {
  width: 100%;
  height: 100%;
  border: none;
  appearance: none;
  cursor: pointer;
  background: var(--pu);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .5px;
  transition: background .15s, transform .1s;
}

.ui-native-btn:hover {
  background: #6d28d9;
}

.ui-native-btn:active {
  transform: none;
}

.ui-native-toggle {
  width: 100%;
  height: 100%;
  border: none;
  appearance: none;
  cursor: pointer;
  background: var(--cur);
  padding: 3px;
  transition: background .2s;
  display: flex;
  align-items: center;
  justify-content: flex-start;
}

.ui-native-toggle.is-on {
  background: var(--pu);
}

.ui-thumb {
  width: 40%;
  height: 100%;
  background: #fff;
  display: block;
  transition: transform .2s;
}

.ui-checkbox-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  height: 100%;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
}

.ui-custom-box {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  background: var(--glass-bg);
  border: 2px solid var(--com);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, border-color .15s;
}

.ui-custom-box.is-checked {
  background: var(--pu);
  border-color: var(--pu);
}

.ui-check-mark {
  font-size: 13px;
  color: #fff;
  opacity: 0;
  transition: opacity .15s;
}

.ui-check-mark.is-checked {
  opacity: 1;
}

.ui-slider-wrapper {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
}

.ui-slider-track {
  position: relative;
  width: 100%;
  height: 8px;
  background: var(--cur);
  cursor: pointer;
}

.ui-slider-fill {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  background: var(--pu);
  pointer-events: none;
}

.ui-slider-thumb {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 18px;
  height: 18px;
  background: #fff;
  border: 2.5px solid var(--pu);
  cursor: grab;
  transition: transform .1s;
}

.ui-slider-thumb:hover {
  transform: translate(-50%, -50%) scale(1.2);
}

/* ── Recurring dotted background ── */
:is(#panel-left, #panel-right, #asset-panel-container, .bot-tab-content, #tools-popup, .input-stepper-merged, .popup, #tm-controls, #vx-controls, #paint-controls) {
  background-image: var(--dot-panel);
  background-size: 18px 18px;
}

:is(.head, .toolbar, .bot-header, .at) {
  background-image: var(--dot-soft);
  background-size: 18px 18px;
}

/* ── Engine Console ── */
#bot-console-content.active {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#cl-body {
  flex: 1;
  overflow-y: auto;
  padding: 2px 0;
  font-size: 12px;
  font-family: monospace;
}

.cl-line {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 3px 12px;
  border-bottom: var(--border-thin);
  color: var(--fg);
}

.cl-line:hover {
  background: var(--cur);
}

.cl-ts {
  min-width: 54px;
  font-size: 10px;
  opacity: .4;
  flex-shrink: 0;
}

.cl-icon {
  min-width: 10px;
  flex-shrink: 0;
  font-weight: 800;
  color: var(--pu);
}

.cl-msg {
  word-break: break-all;
  opacity: .9;
}

.cl-ok .cl-icon {
  color: var(--pk);
}

.cl-ok .cl-msg {
  color: var(--pk);
}

.cl-warn .cl-icon {
  color: var(--ye);
}

.cl-warn .cl-msg {
  color: var(--ye);
  opacity: 1;
}

.cl-err .cl-icon {
  color: var(--re);
}

.cl-err .cl-msg {
  color: var(--re);
  opacity: 1;
}


/* ── Frames Inspector Design System ── */
.sketch-box {
  background: var(--glass-bg);
  border: var(--border);
  border-radius: var(--wrs);
}

.btn-sketch-black {
  padding: 3px 10px;
  border: var(--border);
  border-radius: 999px;
  background: var(--fg);
  color: var(--glass-bg);
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

:is(.btn-sketch-black:hover, .btn-sketch-black.active) {
  background: var(--pu);
  border-color: var(--pu);
  color: #fff;
}

/* ── Script & Shader Editor ── */
#bot-script-content {
  background-color: var(--body-bg);
  background-image: var(--dot-soft);
  background-size: 18px 18px;
}
#script-editor-host {
  --script-line-height: 21px;
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

#script-line-numbers { grid-column: 1; width: 48px; display:flex; flex-direction:column; overflow:hidden; padding:10px 8px; border-right:1px solid var(--cur); color:var(--code-type); background:var(--body-bg); background-image:linear-gradient(rgba(168,85,247,.09),rgba(168,85,247,.09)),var(--dot-soft); background-size:100% var(--script-line-height),18px 18px; background-position:0 var(--active-row-y,10px),0 0; background-repeat:no-repeat,repeat; font:13px/var(--script-line-height) var(--font-ui); text-align:right; user-select:none; }
#script-editor {
  grid-column: 2;
  box-sizing: border-box;
  display: block;
  flex: 1;
  width: 100%;
  min-width: 0;
  height: 100%;
  min-height: 0;
  resize: none;
  overflow: auto;
  margin: 0;
  padding: 10px 12px;
  outline: none;
  color: var(--fg);
  caret-color: var(--code-type);
  background: var(--body-bg);
  background-image: linear-gradient(rgba(168, 85, 247, .09), rgba(168, 85, 247, .09)), var(--dot-soft);
  background-size: 100% var(--script-line-height), 18px 18px;
  background-position: 0 var(--active-row-y, 10px), 0 0;
  background-repeat: no-repeat, repeat;
  border: 0;
  font: 13px/var(--script-line-height) var(--font-ui);
  line-height: var(--script-line-height);
  tab-size: 4;
  white-space: pre;
  cursor: text;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
#script-editor > .script-code-line,
#script-line-numbers > .script-number-line { box-sizing:border-box; display:flex; align-items:center; flex:0 0 var(--script-line-height); height:var(--script-line-height); min-height:var(--script-line-height); line-height:var(--script-line-height); white-space:pre; }
#script-line-numbers > .script-number-line { justify-content:flex-end; }
#script-editor .script-code-content { display:inline-block; height:var(--script-line-height); line-height:var(--script-line-height); white-space:pre; }
#script-editor::selection,
#script-editor *::selection {
  color: inherit !important;
  background: rgba(168, 85, 247, .2);
  border-radius: 6px;
}
#sp-bar {
  min-height: 32px;
  height: auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  padding: 0 8px;
  gap: 6px;
  border-bottom: var(--border-thin);
  flex-shrink: 0;
  background-color: var(--body-bg);
  background-image: var(--dot-soft);
  background-size: 18px 18px;
}
#script-target-label {
  margin-left: auto;
  overflow: hidden;
  color: var(--com);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#sp-modes { display: flex; gap: 2px; align-items: center; }
.script-insp-status { font: 700 10px/1 var(--font-ui, sans-serif); color: #34d399; white-space: nowrap; }
.script-insp-status.error { color: #f87171; }

.behavior-rules { display:flex; flex-direction:column; gap:8px; margin-top:8px; }
.behavior-rule { display:flex; flex-direction:column; gap:7px; min-width:0; padding:9px; border:1px solid var(--cur); border-radius:7px; background:var(--panel); }
.behavior-rule-title { color:var(--code-type); font-size:10px; letter-spacing:.04em; }
.behavior-rule-actions { display:flex; flex-direction:column; gap:5px; min-width:0; }
.behavior-rule-row { display:grid; grid-template-columns:repeat(auto-fit,minmax(105px,1fr)); align-items:center; gap:5px; min-width:0; }
.behavior-rule-row > * { min-width:0; }
.editor-select-popup:has(.editor-select-search) { display:flex!important; flex-direction:column; overflow:hidden!important; gap:4px; }
.editor-select-search { box-sizing:border-box; flex-shrink:0; width:100%; min-height:30px; padding:5px 8px; border:1px solid var(--cur); border-radius:6px; background:var(--body-bg); color:var(--fg); }
.editor-select-options { min-height:0; overflow:auto; }

