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

html, body {
  height: 100%;
  overflow: hidden;
  background: #0d0f14;
  color: #e2e8f0;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 12px;
}

:root {
  --bg:        #0d0f14;
  --surface:   rgba(15,18,26,0.92);
  --border:    rgba(255,255,255,0.08);
  --border2:   rgba(255,255,255,0.12);
  --text:      #e2e8f0;
  --muted:     #64748b;
  --brand:     #3b82f6;
  --brand-dim: rgba(59,130,246,0.15);
  --accent:    #10b981;
  --danger:    #ef4444;
  --amber:     #f59e0b;
  --violet:    #8b5cf6;
  --sky:       #06b6d4;
  --radius:    6px;
  --panel-w:   260px;
  --shadow:    0 8px 32px rgba(0,0,0,0.5), 0 1px 0 rgba(255,255,255,0.04) inset;
  --panel-gap: 12px;
}

[v-cloak] { display: none !important; }

#app { display: flex; width: 100vw; height: 100vh; position: relative; }

.canvas-wrap { position: absolute; inset: 0; }
canvas { display: block; width: 100% !important; height: 100% !important; }

.drag-overlay {
  position: absolute; inset: 0;
  background: rgba(59,130,246,0.06);
  border: 2px dashed var(--brand);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; pointer-events: none;
  opacity: 0; transition: opacity .15s;
}
.drag-overlay.active { opacity: 1; }
.drag-label {
  font-size: 13px; letter-spacing: .15em; color: var(--brand); font-weight: 700;
  background: rgba(59,130,246,0.1); padding: 10px 24px;
  border-radius: 6px; border: 1px solid rgba(59,130,246,0.3);
}

.load-box {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  z-index: 50; display: flex; flex-direction: column; align-items: center;
  gap: 14px; padding: 28px 36px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; box-shadow: var(--shadow);
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
}
.load-box-title { font-size: 13px; font-weight: 700; letter-spacing: .1em; color: var(--text); }
.load-box-btns { display: flex; gap: 10px; }
.load-btn {
  display: flex; align-items: center; gap: 7px; padding: 9px 18px;
  background: rgba(59,130,246,0.1); border: 1px solid rgba(59,130,246,0.3);
  border-radius: var(--radius); color: var(--brand); font: inherit; font-size: 12px;
  cursor: pointer; transition: background .12s, border-color .12s;
}
.load-btn:hover { background: rgba(59,130,246,0.2); border-color: rgba(59,130,246,0.5); }

.scenes-toolbar {
  display: flex; align-items: center; gap: 4px; padding: 6px 10px;
  border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.tb-sep { width: 1px; height: 20px; background: var(--border2); margin: 0 4px; flex-shrink: 0; }

.statusbar-inline { display: flex; align-items: center; gap: 6px; min-width: 0; max-width: 220px; }
.statusbar-inline .stext { font-size: 10px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.panel {
  position: absolute;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: var(--shadow);
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  display: flex; flex-direction: column; overflow: hidden;
  z-index: 50; top: var(--panel-gap);
  max-height: calc(100vh - var(--panel-gap) * 2);
}
.panel-scenes { left: var(--panel-gap); width: var(--panel-w); }
.panel-left {
  right: calc(var(--panel-w) + var(--panel-gap) * 2); width: var(--panel-w);
  transition: opacity .18s, transform .18s;
}
.panel-left.hidden { opacity: 0; pointer-events: none; transform: translateX(8px); }
.panel-right { right: var(--panel-gap); width: var(--panel-w); }

.panel-hdr {
  display: flex; align-items: center; gap: 6px;
  padding: 9px 12px 8px; border-bottom: 1px solid var(--border);
  flex-shrink: 0; background: rgba(255,255,255,0.02);
}
.panel-hdr-title {
  flex: 1; min-width: 0; font-size: 10px; font-weight: 700;
  letter-spacing: .12em; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.panel-hdr-filename { color: var(--text); font-weight: 400; letter-spacing: .04em; }
.panel-hdr-title.editable-name {
  color: var(--text); font-size: 11px; letter-spacing: .04em;
  cursor: text; border-radius: 3px; padding: 1px 3px; margin-left: -3px; transition: background .1s;
}
.panel-hdr-title.editable-name:hover { background: rgba(255,255,255,0.07); }
.panel-hdr-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.dot-scene { background: var(--muted); }
.bug-link {
  display: flex; align-items: center; color: var(--muted); opacity: .55;
  transition: opacity .12s, color .12s; flex-shrink: 0; text-decoration: none;
}
.bug-link:hover { opacity: 1; color: var(--danger); }

.name-input, .vname-input {
  background: rgba(59,130,246,0.12); color: var(--text);
  border: 1px solid rgba(59,130,246,0.5); border-radius: 3px;
  font: inherit; font-size: 11px; padding: 1px 4px; outline: none;
  box-shadow: 0 0 0 2px rgba(59,130,246,0.15);
}
.name-input  { width: 100%; }
.vname-input { flex: 1; min-width: 0; }

.tb-btn {
  display: flex; align-items: center; gap: 5px; padding: 5px 9px;
  background: rgba(255,255,255,0.05); border: 1px solid var(--border2);
  border-radius: var(--radius); color: var(--text); font: inherit; font-size: 11px;
  cursor: pointer; white-space: nowrap; transition: background .12s, border-color .12s;
}
.tb-btn:hover { background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.2); }
.tb-btn svg { opacity: .7; }
.tb-btn.danger { background: rgba(239,68,68,0.1); border-color: rgba(239,68,68,0.25); color: var(--danger); }
.tb-btn.danger:hover { background: rgba(239,68,68,0.18); }

.scene-list-wrap { flex: 1; overflow-y: auto; overflow-x: hidden; min-height: 0; }
.scene-item {
  display: flex; align-items: center; gap: 6px; padding: 7px 10px; cursor: pointer;
  border-bottom: 1px solid var(--border); border-left: 3px solid transparent;
  transition: background .08s, border-color .08s;
}
.scene-item:last-child { border-bottom: none; }
.scene-item:hover { background: rgba(255,255,255,0.04); }
.scene-item.active { background: rgba(59,130,246,0.08); border-left-color: var(--brand); }
.scene-icon { color: var(--muted); flex-shrink: 0; }
.scene-item.active .scene-icon { color: var(--brand); }
.scene-name {
  flex: 1; min-width: 0; font-size: 11px; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  border-radius: 3px; padding: 1px 3px; margin-left: -3px; transition: background .1s;
}
.scene-item.active .scene-name { color: var(--text); font-weight: 600; }

.scene-add-row { padding: 8px 10px; border-top: 1px solid var(--border); flex-shrink: 0; }
.add-scene-btn {
  width: 100%; display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 6px 10px; font: inherit; font-size: 11px;
  background: rgba(255,255,255,0.04); border: 1px solid var(--border2);
  border-radius: var(--radius); color: var(--muted); cursor: pointer; transition: all .12s;
}
.add-scene-btn:hover { background: var(--brand-dim); border-color: rgba(59,130,246,.4); color: var(--brand); }

.add-strip { padding: 8px 10px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.add-strip-label { font-size: 9px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }

.add-strip-btns {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
}
.add-btn {
  min-width: 0;
  height: 50px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  background: rgba(255,255,255,0.03); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--muted);
  font: inherit; font-size: 8px; letter-spacing: .03em; text-transform: uppercase;
  cursor: pointer; transition: all .12s;
  overflow: hidden;
  white-space: nowrap; text-overflow: ellipsis;
  padding: 0 2px;
}
.add-btn svg { opacity: 1.; transition: opacity .12s; flex-shrink: 0; }
.add-btn:hover svg { opacity: 1; }
.add-btn.scalar:hover     { background: rgba(59,130,246,0.12); border-color: rgba(59,130,246,.4); color: var(--brand); }
.add-btn.solid:hover      { background: rgba(245,158,11,0.12); border-color: rgba(245,158,11,.4); color: var(--amber); }
.add-btn.vector:hover     { background: rgba(139,92,246,0.12); border-color: rgba(139,92,246,.4); color: var(--violet); }
.add-btn.slice:hover      { background: rgba(6,182,212,0.12);  border-color: rgba(6,182,212,.4);  color: var(--sky); }
.add-btn.annotation:hover { background: rgba(167,139,250,0.12); border-color: rgba(167,139,250,.4); color: #a78bfa; }
.add-btn.threshold:hover  { background: rgba(16,185,129,0.12); border-color: rgba(16,185,129,.4); color: var(--accent); }
.add-btn.streamline:hover { background: rgba(236,72,153,0.12); border-color: rgba(236,72,153,.4); color: #ec4899; }
.add-btn:disabled { opacity: 0.3; cursor: not-allowed; pointer-events: none; }

.visual-list-wrap { flex: 1; overflow-y: auto; overflow-x: hidden; min-height: 0; }
.vlist-empty { padding: 20px 12px; font-size: 11px; color: var(--muted); font-style: italic; text-align: center; line-height: 1.6; }
.vitem {
  display: flex; align-items: center; gap: 6px; padding: 6px 10px;
  cursor: pointer; border-bottom: 1px solid var(--border);
  border-left: 3px solid transparent;
  transition: background .08s, border-color .08s; min-width: 0;
}
.vitem:last-child { border-bottom: none; }
.vitem:hover { background: rgba(255,255,255,0.04); }
.vitem.active { background: rgba(59,130,246,0.08); }
.vitem.active.scalar { border-left-color: var(--brand); }
.vitem.active.solid  { border-left-color: var(--amber); }
.vitem.active.vector { border-left-color: var(--violet); }
.vitem.active.slice  { border-left-color: var(--sky); }
.vitem.active.threshold  { border-left-color: var(--accent); }
.vitem.active.streamline { border-left-color: #ec4899; }
.vitem.active.annotation { border-left-color: #a78bfa; }
.vdot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.dot-scalar { background: var(--brand); }
.dot-solid  { background: var(--amber); }
.dot-vector { background: var(--violet); }
.dot-slice  { background: var(--sky); }
.dot-threshold  { background: var(--accent); }
.dot-streamline { background: #ec4899; }
.dot-annotation { background: #a78bfa; }
.vname {
  flex: 1; min-width: 0; font-size: 11px; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  border-radius: 3px; padding: 1px 3px; margin-left: -3px; transition: background .1s;
}
.vitem.active .vname { color: var(--text); font-weight: 600; }
.vic-btn {
  padding: 2px 4px; background: none; border: none; cursor: pointer;
  color: var(--muted); display: flex; align-items: center;
  border-radius: 3px; flex-shrink: 0; opacity: .4; transition: color .12s, opacity .12s;
}
.vic-btn:hover { color: var(--text); opacity: 1; }
.vic-btn.del:hover { color: var(--danger); opacity: 1; }
.vic-btn.hidden-icon { opacity: .18; }

.global-section { border-top: 1px solid var(--border); flex-shrink: 0; }
.config-area { flex: 1; overflow-y: auto; overflow-x: hidden; min-height: 0; }

.acc { border-bottom: 1px solid var(--border); }
.acc:last-child { border-bottom: none; }
.acc-hdr {
  display: flex; align-items: center; padding: 7px 10px;
  cursor: pointer; user-select: none; gap: 6px; transition: background .08s;
}
.acc-hdr:hover { background: rgba(255,255,255,0.04); }
.acc-icon { color: var(--muted); flex-shrink: 0; }
.acc-hdr.open .acc-icon { color: var(--brand); }
.acc-title { flex: 1; font-size: 10px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.acc-hdr.open .acc-title { color: var(--text); }
.acc-chev { font-size: 8px; color: var(--muted); transition: transform .15s; flex-shrink: 0; }
.acc-hdr.open .acc-chev { transform: rotate(90deg); color: var(--brand); }
.acc-hdr-actions { display: flex; gap: 3px; align-items: center; }
.acc-icon-btn {
  width: 20px; height: 20px; display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.04); border: 1px solid var(--border2);
  border-radius: 4px; cursor: pointer; color: var(--muted); font: inherit; transition: all .12s;
}
.acc-icon-btn:hover { background: var(--brand-dim); border-color: rgba(59,130,246,.4); color: var(--brand); }
.acc-body { padding: 2px 0 6px; }

.frow {
  display: flex; align-items: center;
  padding: 3px 10px; gap: 8px; min-height: 26px; min-width: 0;
}

.flabel {
  font-size: 10px; color: var(--muted);
  width: 74px; min-width: 74px; max-width: 74px;
  flex-shrink: 0;
  overflow: visible;
  position: relative;
  display: flex;
  align-items: center;
  gap: 0;
}
.flabel-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.fctrl { flex: 1; min-width: 0; display: flex; align-items: center; gap: 4px; }
.fctrl-tog { flex: 1; min-width: 0; display: flex; align-items: center; justify-content: flex-end; }

select, input[type="number"] {
  width: 100%; min-width: 0;
  background: #1e2330; color: #e2e8f0;
  border: 1px solid var(--border2); border-radius: var(--radius);
  font: inherit; font-size: 11px; padding: 3px 6px; outline: none;
  transition: border-color .12s, box-shadow .12s;
  color-scheme: dark;
}
select:focus, input:focus {
  border-color: rgba(59,130,246,.5);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.12);
}
select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='5'%3E%3Cpath d='M0 0l4 5 4-5z' fill='%2364748b'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 7px center;
  padding-right: 20px; cursor: pointer;
}
select option { background: #1e2330; color: #e2e8f0; }
select option:checked { background: #2a3450; color: #e2e8f0; }
input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; }

input[type="range"] {
  width: 0; flex: 1; min-width: 0;
  height: 3px; padding: 0; border: none;
  accent-color: var(--brand); cursor: pointer; background: none; color-scheme: dark;
}
.rn { flex: 1; min-width: 0; display: flex; align-items: center; gap: 4px; }
.rn input[type="range"]  { flex: 1; width: 0; min-width: 0; }
.rn input[type="number"] { width: 46px; min-width: 46px; max-width: 46px; flex-shrink: 0; }

.tog {
  position: relative; display: inline-flex; align-items: center;
  width: 32px; height: 18px; flex-shrink: 0; cursor: pointer;
}
.tog input { position: absolute; opacity: 0; width: 0; height: 0; }
.tog-track { position: absolute; inset: 0; background: rgba(255,255,255,0.1); border-radius: 10px; transition: background .2s; }
.tog input:checked + .tog-track { background: var(--brand); }
.tog-thumb {
  position: absolute; left: 2px; width: 14px; height: 14px; background: #fff;
  border-radius: 50%; box-shadow: 0 1px 3px rgba(0,0,0,.4);
  transition: transform .2s; pointer-events: none; z-index: 1;
}
.tog input:checked ~ .tog-thumb { transform: translateX(14px); }

.swatch {
  width: 22px; height: 22px; border-radius: var(--radius);
  border: 1px solid var(--border2); cursor: pointer; overflow: hidden; flex-shrink: 0;
}
.swatch input[type="color"] {
  width: 200%; height: 200%; border: none; padding: 0; margin: -25%; cursor: pointer; background: none;
}

.block-list { padding: 2px 8px 6px; display: flex; flex-direction: column; gap: 2px; }
.block-row {
  display: flex; align-items: center; gap: 8px; padding: 3px 4px;
  border-radius: var(--radius); transition: background .08s;
}
.block-row:hover { background: rgba(255,255,255,0.04); }
.block-n { flex: 1; min-width: 0; font-size: 11px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.sdiv {
  padding: 5px 10px 2px; font-size: 10px; letter-spacing: .08em;
  color: var(--muted); text-transform: uppercase;
  border-top: 1px solid var(--border); margin-top: 2px;
}

.normal-presets { display: flex; gap: 3px; padding: 2px 10px 4px; flex-wrap: wrap; }
.np-btn {
  flex: 1; min-width: 28px; max-width: 36px;
  font: inherit; font-size: 10px; padding: 3px 0; text-align: center;
  background: rgba(255,255,255,0.04); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--muted); cursor: pointer; transition: all .12s;
}
.np-btn:hover { background: var(--brand-dim); border-color: rgba(59,130,246,.4); color: var(--brand); }

.mini-btn {
  font: inherit; font-size: 10px; padding: 4px 10px;
  background: rgba(255,255,255,0.05); border: 1px solid var(--border2);
  border-radius: var(--radius); color: var(--muted); cursor: pointer; transition: all .12s; width: 100%;
}
.mini-btn:hover { background: rgba(255,255,255,0.1); color: var(--text); }

.timebar { border-top: 1px solid var(--border); padding: 7px 10px; flex-shrink: 0; }
.timebar-lbl { font-size: 9px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.timebar-row { display: flex; align-items: center; gap: 6px; min-width: 0; }
.timebar-row input[type="range"] { flex: 1; width: 0; min-width: 0; }
.timebar-val { font-size: 11px; color: var(--brand); width: 64px; flex-shrink: 0; text-align: right; white-space: nowrap; }

.sdot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; background: var(--muted); transition: background .3s; }
.sdot.ok   { background: var(--accent); }
.sdot.busy { background: #f59e0b; animation: pulse .8s infinite; }
.sdot.err  { background: var(--danger); }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.3} }
.stext { font-size: 10px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.comp-btns { display: flex; gap: 5px; padding: 2px 0; }
.comp-btn {
  flex: 1; height: 28px; min-width: 36px;
  display: flex; align-items: center; justify-content: center;
  font: inherit; font-size: 11px; font-family: monospace; font-weight: 600; letter-spacing: 0.03em;
  background: rgba(255,255,255,0.05); border: 1px solid var(--border2);
  color: var(--muted); border-radius: var(--radius); cursor: pointer; transition: all .12s;
}
.comp-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.comp-btn:hover:not(.active) { background: rgba(255,255,255,0.1); color: var(--text); }

::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

.tooltip-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}
.tooltip-icon {
  font-size: 10px;
  opacity: 0.55;
  cursor: help;
  margin-right: 4px;
  line-height: 1;
}
.tooltip-bubble {
  display: none;
  position: absolute;
  left: 0;
  bottom: calc(100% + 6px);
  background: #1e2330;
  color: #e2e8f0;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 4px;
  padding: 5px 8px;
  width: max-content;
  max-width: 200px;
  font-size: 10px;
  line-height: 1.5;
  z-index: 9999;
  pointer-events: none;
  word-break: break-word;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  white-space: normal;
}
.tooltip-wrap:hover .tooltip-bubble { display: block; }

.string-input {
  width: 100%; box-sizing: border-box;
  background: #1e2330; border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--radius); color: #e2e8f0;
  padding: 3px 6px; font: inherit; font-size: 11px; outline: none;
  transition: border-color .12s, box-shadow .12s;
}
.string-input:focus { border-color: rgba(59,130,246,.5); box-shadow: 0 0 0 3px rgba(59,130,246,0.12); }
.string-input--unset { border-style: dashed; opacity: 0.55; }
.string-input::placeholder { color: #64748b; font-style: italic; }

.fctrl-color {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.vdot-icon { flex-shrink: 0; color: var(--muted); }
.vitem.active .vdot-icon { color: var(--brand); }


.add-btn.isosurface:hover { background: rgba(251,146,60,0.12); border-color: rgba(251,146,60,.4); color: #fb923c; }
.vitem.active.isosurface { border-left-color: #fb923c; }
.dot-isosurface { background: #fb923c; }


.add-btn:disabled,
.add-btn.disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: auto; /* keep tooltip working */
}
.add-btn:disabled:hover,
.add-btn.disabled:hover {
  background: inherit;
}