/* Late refinements: sticky panel headers, scrollbars, compact workspace spacing. */
/* 0.70.7: keep panel headers visible; only the content scrolls. */
#editor-library-rail {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
#editor-library-rail > .library-rail-heading {
  flex: 0 0 auto;
}
#editor-library-rail > #node-palette {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  margin-bottom: 0;
  overflow: hidden;
}
#editor-library-rail .node-palette-head {
  flex: 0 0 auto;
}
#node-palette-categories {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
}
main > #props-panel {
  display: flex !important;
  flex-direction: column;
  overflow: hidden;
}
#props-panel > .dock-handle {
  flex: 0 0 auto;
}
#props-panel > #node-properties {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: thin;
}
main > #preview-panel {
  overflow: hidden !important;
}
#preview-panel > .preview-panel-header {
  flex: 0 0 auto;
}
#preview-panel > .preview-scroll-body {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
}
#preview-panel .preview-scroll-body > #terrain-view {
  position: static;
  flex: 1 0 auto;
  min-height: 0;
  margin: 0;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #111b25;
}
#preview-panel .preview-scroll-body > #terrain-view > #three {
  min-height: 220px;
}
#preview-panel.terrain-expanded .preview-scroll-body > #terrain-view {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 200px;
  overflow: auto;
}
#preview-panel.terrain-expanded .preview-scroll-body > #terrain-view > #three {
  flex: 1 1 auto;
  height: auto;
  min-height: 160px;
}
.tf-library-dialog > header,
.tf-library-tabs,
.tf-library-tools {
  flex: 0 0 auto;
}
.tf-library-results {
  flex: 1 1 auto;
  min-height: 0;
}
/* 0.70.8: reserve clearance for classic and overlay scrollbars. */
#node-palette-categories,
#props-panel > #node-properties,
#preview-panel > .preview-scroll-body {
  scrollbar-gutter: stable;
  padding-right: 16px;
  margin-right: -9px;
  min-width: 0;
  overflow-x: hidden;
}
.tf-library-results {
  scrollbar-gutter: stable;
  padding-right: 24px;
}
#preview-panel.terrain-expanded .preview-scroll-body > #terrain-view {
  scrollbar-gutter: stable;
}
/* 0.70.9: keep the palette scrollbar inside its clipped parent. */
#editor-library-rail #node-palette-categories {
  margin-right: 0;
  padding-right: 6px;
  overflow-y: scroll;
  scrollbar-color: #526b7e #192631;
  scrollbar-width: thin;
}
/* 0.71.0 compact workspace */
body > header {
  padding: 7px 16px;
  gap: 10px;
}
body > header strong {
  font-size: 15px;
}
body > header span {
  font-size: 11px;
}
.editor-canvas-column > .performance-details {
  margin: 3px 0 0;
  padding: 6px 9px;
  flex: 0 1 auto;
  min-height: 0;
  overflow: auto;
  max-height: 35%;
}
.editor-canvas-column > #graph-status {
  padding: 4px 2px;
  flex: 0 0 auto;
}
.editor-canvas-column > #graph-stage {
  min-height: 120px;
  flex: 1 1 0;
}
.editor-frame.selected-frame {
  outline: 2px solid var(--frame-color);
  outline-offset: 2px;
}
/* 0.75.2: consistent scrollbar colors and precise inspector / palette alignment. */
:root {
  scrollbar-color: #526b7e #192631;
}
/* Align full-width inspector controls to a common inset; compact row buttons stay compact. */
#props-panel
  #node-properties
  :is(.property, .property label)
  > :is(input:not([type="checkbox"]), textarea, select, button, .property-field-row),
#props-panel #node-properties > button,
#props-panel #node-properties .group-material-shortcuts > button {
  box-sizing: border-box;
  margin-left: 3px;
  margin-right: 0;
  width: calc(100% - 3px);
  max-width: calc(100% - 3px);
  min-width: 0;
}
#props-panel #node-properties .property-field-row > textarea {
  flex: 1 1 0;
  min-width: 0;
  margin: 0;
}
#props-panel #node-properties .property input[type="range"] {
  padding-inline: 0;
}
.material-studio-layer-actions {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding-top: 8px;
  border-top: 1px solid #40505e;
}
.material-studio-layer-actions button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
#editor-library-rail .node-category-items {
  grid-template-columns: minmax(0, 1fr);
}
.node-palette-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 24px;
  min-width: 0;
  gap: 4px;
}
.node-palette-item > button:first-child {
  width: 100%;
  min-width: 0;
  white-space: normal;
  overflow-wrap: anywhere;
}
.node-palette-item > .node-favorite-toggle {
  width: 24px;
  min-width: 24px;
  margin: 0;
}
/* 0.75.2: final panel spacing and preview selector corners. */
/* Shared scroll gutter: search and categories use the same content box. */
#editor-library-rail, #editor-library-rail.collapsed { padding-top: 4px; }
#editor-library-rail > .library-rail-heading { height: var(--tf-control-height); }
#collapse-library-rail {
  height: var(--tf-control-height); width: var(--tf-control-height);
  min-height: var(--tf-control-height); padding: 0;
  border-radius: var(--tf-control-radius); line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
}
#editor-library-rail > #node-palette {
  display: block; overflow-y: auto; overflow-x: hidden;
  scrollbar-gutter: stable; scrollbar-width: thin;
  padding: 0 3px;
}
#editor-library-rail .node-palette-head {
  position: sticky; top: 0; z-index: 1;
  background: #15202b; padding: 3px 0 5px; margin: 0;
  overflow: visible;
}
#editor-library-rail #node-palette-categories {
  overflow: visible; scrollbar-gutter: auto; margin: 0; padding: 0;
}
#editor-library-rail #node-palette-search {
  display: block; box-sizing: border-box; margin: 0;
  width: 100%; max-width: none; min-width: 0;
}
#editor-library-rail #node-palette-search:focus {
  outline: 2px solid #a8bacb; outline-offset: -2px;
}

.editor-sticky-note {
  background: color-mix(in srgb, var(--frame-color) 18%, #151d25);
  pointer-events: auto;
  overflow: hidden;
}
.editor-sticky-note .editor-frame-description {
  max-height: none;
  height: calc(100% - 34px);
  overflow: auto;
  overflow-wrap: anywhere;
  padding: 9px 12px 20px;
  color: #e1e6eb;
}
#graph-minimap {
  position: absolute;
  right: 10px;
  bottom: 10px;
  width: 180px;
  height: 112px;
  max-width: 45%;
  max-height: 45%;
  z-index: 110;
  background: #101820;
  border: 1px solid #52677c;
  border-radius: 6px;
  cursor: crosshair;
  touch-action: none;
}
#graph-minimap[hidden] {
  display: none !important;
}

#preview-panel > .preview-panel-header {
  flex-wrap: wrap;
  gap: 6px;
}
#preview-panel .preview-panel-header > .preview-dock-heading {
  min-width: 95px;
}

/* v30.78: shared panel header and graph/library alignment. */
:root { --tf-heading-height: calc(var(--tf-control-height) + 11px); }
.graph-panel-header,
#props-panel > .dock-handle,
#preview-panel > .preview-panel-header {
  box-sizing: border-box;
  flex: 0 0 var(--tf-heading-height);
  height: var(--tf-heading-height);
  min-height: var(--tf-heading-height);
  margin: 0 0 12px;
  padding: 0 0 10px;
  border-bottom: 1px solid var(--line);
  flex-wrap: nowrap;
}
#preview-panel .preview-panel-header > .preview-dock-heading { min-width: 0; }
/* Rail: 1px border + 4px inset + 30px header + 8px gap + 3px search inset.
   Navigation: 1px border + 4px inset on each side + 30px controls.
   The remaining 6px aligns the graph border with the search field. */
#group-navigation { flex: 0 0 auto; margin-bottom: 6px; }
