:root {
  --bg: #0c0e12;
  --bg-2: #12151c;
  --panel: #161a22;
  --line: #2a3140;
  --text: #e7ecf3;
  --muted: #8b95a8;
  --accent: #b7c0cc;
  --metal: #6e747d;
  --ok: #9dbaa8;
  --font: "Avenir Next", "PingFang SC", "Hiragino Sans GB", sans-serif;
  --mono: "SF Mono", "Menlo", ui-monospace, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  overflow: hidden;
}

.topbar {
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px 0 18px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #1a1e27, #12151c);
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
}

.mark {
  width: 20px;
  height: 20px;
  border-radius: 3px;
  background: linear-gradient(145deg, #8d9198, #3e4248);
  box-shadow: inset 0 1px 0 #c5c8ce, 0 0 0 1px #2c3036;
}

.brand strong {
  display: block;
  font-size: 14px;
  letter-spacing: 0.04em;
}

.brand span {
  display: block;
  color: #fff;
  font-size: 14px;
  position: relative;
  text-align: center;
  font-weight: bold;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.field {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}

.field select,
button,
.file-btn {
  height: 32px;
  border: 1px solid #3a4150;
  background: #0f1218;
  color: var(--text);
  border-radius: 6px;
  font: 12px/1 var(--font);
  padding: 0 10px;
}

button,
.file-btn {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  background: #2a303c;
}

button.ghost {
  background: transparent;
}

button:hover,
.file-btn:hover {
  border-color: #5b6578;
}

.file-btn input {
  display: none;
}

.workspace {
  display: grid;
  grid-template-columns: 272px 1fr;
  height: calc(100% - 56px - 32px);
  min-height: 0;
  overflow: hidden;
}

.inspector {
  border-right: 1px solid var(--line);
  background: var(--panel);
  padding: 14px 14px 20px;
  overflow: auto;
}

.inspector h2,
.fold-head {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.fold + .fold,
.inspector section + section {
  margin-top: 8px;
}

.fold-head {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  padding: 8px 2px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  cursor: pointer;
}

.fold-head:hover,
.fold.is-open .fold-head {
  color: var(--text);
  background: #121722;
}

.fold-head::after {
  content: "▸";
  font-size: 10px;
}

.fold.is-open .fold-head::after {
  content: "▾";
}

.fold-body {
  display: none;
  padding: 4px 0 8px;
}

.fold.is-open .fold-body {
  display: block;
}

.toggles,
.check,
.slider {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13px;
}

.check,
.toggles label {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

.slider + .slider {
  margin-top: 8px;
}

.slider span {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}

.slider em {
  font-style: normal;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

input[type="range"] {
  width: 100%;
  accent-color: var(--metal);
}

.seg {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.seg button {
  justify-content: center;
  background: #0f1218;
}

.angle-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
}

.angle-row button {
  justify-content: center;
  padding: 6px 0;
  background: #0f1218;
  font-variant-numeric: tabular-nums;
}

.angle-row button.on {
  background: #243044;
  color: #e7ecf3;
  box-shadow: inset 0 0 0 1px #6e7b8c;
}

.seg.stack {
  grid-template-columns: 1fr;
}

.is-hidden {
  display: none !important;
}

.dims {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  line-height: 1.7;
}

.export-hint {
  margin: -4px 0 10px;
  font-size: 11px;
  color: var(--muted);
}

.export-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.export-row select {
  flex: 1;
  min-width: 0;
  height: 32px;
  border: 1px solid #3a4150;
  background: #0f1218;
  color: var(--text);
  border-radius: 6px;
  font: 12px/1 var(--font);
  padding: 0 8px;
}

.export-row button {
  flex: 0 0 auto;
}

#focus-mode label span {
  flex: 1;
  min-width: 0;
  line-height: 1.35;
}

.stage {
  display: flex;
  height: 100%;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background:
    radial-gradient(1200px 500px at 30% 20%, #1b2029 0%, transparent 55%),
    var(--bg-2);
}

.pane {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

#pane-3d {
  flex: 1 1 58%;
}

#pane-2d {
  flex: 1 1 42%;
  background: #0a0c10;
}

.pane-label {
  position: absolute;
  z-index: 2;
  top: 10px;
  left: 12px;
  font-size: 10px;
  letter-spacing: 0.16em;
  color: #9aa3b2;
  pointer-events: none;
}

#view-3d {
  display: block;
  width: 100%;
  height: 100%;
}

#view-2d {
  display: block;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.view2d-toolbar {
  position: absolute;
  z-index: 3;
  top: 8px;
  right: 10px;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 4px;
  max-width: calc(100% - 56px);
}

.view2d-toolbar button {
  height: 26px;
  padding: 0 8px;
  background: rgba(15, 18, 24, 0.92);
}

.view2d-toolbar button.on {
  background: #2a303c;
  border-color: #8b95a8;
}

.splitter {
  width: 6px;
  cursor: col-resize;
  background: #1f2430;
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
}

.splitter:hover {
  background: #3d4554;
}

.status {
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
  background: #10131a;
}

#material-hint {
  color: var(--ok);
}

.toggle {
  position: relative;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  cursor: pointer;
  margin-bottom: 8px;
}

.toggle input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-ui {
  width: 36px;
  height: 20px;
  border-radius: 999px;
  background: #2a3140;
  border: 1px solid #3a4150;
  position: relative;
  flex: 0 0 auto;
}

.toggle-ui::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #8b95a8;
  transition: transform 0.15s ease;
}

.toggle input:checked + .toggle-ui {
  background: #3a4a40;
  border-color: #7d9a84;
}

.toggle input:checked + .toggle-ui::after {
  transform: translateX(16px);
  background: #d5e4d8;
}

.toggle input:focus-visible + .toggle-ui {
  outline: 1px solid #8b95a8;
  outline-offset: 2px;
}

.tree-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin-bottom: 8px;
}

.tree-actions button {
  height: 26px;
  justify-content: center;
  padding: 0 4px;
  font-size: 11px;
  background: #0f1218;
}

.tree {
  margin: 0 -8px;
  max-height: 400px;
  overflow: auto;
  border: 1px solid #222833;
  border-radius: 6px;
  background: #10141b;
  padding: 4px 0;
}

.tree-row {
  display: flex;
  align-items: center;
  gap: 5px;
  min-height: 24px;
  padding: 2px 8px 2px calc(6px + var(--d, 0) * 12px);
  cursor: pointer;
  user-select: none;
}

.tree-row:hover {
  background: #1c232e;
}

.tree-row.is-active {
  background: #2a3344;
}

.tree-row.is-off {
  opacity: 0.42;
}

.tree-twist {
  width: 14px;
  height: 18px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #7d8796;
  font-size: 10px;
  line-height: 18px;
  justify-content: center;
  flex: 0 0 14px;
}

.tree-twist.is-leaf {
  display: inline-block;
  pointer-events: none;
}

.tree-row input[type="checkbox"] {
  margin: 0;
  flex: 0 0 auto;
  accent-color: #c9b27a;
}

.tree-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}

.tree-name.is-cut {
  color: #8aa0b5;
  font-style: italic;
}

.tree-meta {
  margin-left: auto;
  padding-left: 8px;
  color: #667084;
  font-family: var(--mono);
  font-size: 10px;
  white-space: nowrap;
}

.tree-row.is-active .tree-name {
  color: #f2d889;
}

@media (max-width: 960px) {
  .topbar {
    height: auto;
    min-height: 56px;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 12px;
  }

  .workspace {
    grid-template-columns: 1fr;
    height: calc(100% - 88px - 32px);
  }

  .inspector {
    max-height: 168px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .stage {
    flex-direction: column;
  }

  .splitter {
    width: auto;
    height: 6px;
    cursor: row-resize;
  }

  #pane-3d,
  #pane-2d {
    flex-basis: 50% !important;
    min-height: 160px;
  }
}
