[hidden] {
  display: none !important;
}

.icon {
  flex: none;
  width: 20px;
  height: 20px;
}

/* ── Каркас ─────────────────────────────────────────────────────────────── */

.editor {
  --topbar-height: 48px;
  --gap: 12px;
  --rail-width: 76px;
  --panel-width: 320px;

  position: relative;
  height: 100%;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

.stage {
  position: absolute;
  inset: var(--topbar-height) 0 0;
  overflow: hidden;
}

.stage canvas {
  display: block;
  touch-action: none;
  cursor: crosshair;
}

/* Сообщение на случай, если редактор не запустился. */
.fatal {
  display: grid;
  gap: 12px;
  align-content: center;
  justify-items: start;
  height: 100%;
  max-width: 520px;
  margin: 0 auto;
  padding: 24px;
}

.fatal h1 {
  margin: 0;
  font-size: var(--text-lg);
}

.fatal p {
  margin: 0 0 12px;
  color: var(--bone-dim);
}

/* ── Кнопки ─────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--bone);
  white-space: nowrap;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}

.btn:hover {
  background: var(--slate-700);
}

.btn:disabled {
  color: var(--bone-faint);
  background: transparent;
  cursor: default;
}

.btn.is-on {
  background: var(--patina-wash);
  color: var(--patina);
}

.btn.is-on:disabled {
  background: transparent;
  color: var(--bone-faint);
}

.btn--soft {
  flex: 1;
  background: var(--slate-700);
}

.btn--soft:hover {
  background: var(--slate-600);
}

.btn--ghost {
  min-height: 30px;
  padding: 0 6px;
  color: var(--bone-dim);
}

.btn--ghost:hover {
  color: var(--bone);
}

/* Редкое действие: только текст, без плашки. */
.btn--quiet {
  justify-self: start;
  min-height: 28px;
  padding: 0 4px;
  color: var(--bone-faint);
}

.btn--quiet:hover {
  background: transparent;
  color: var(--danger);
}

.btn--primary {
  background: var(--patina);
  color: #0d2622;
  font-weight: 600;
}

.btn--primary:hover {
  background: #73d3be;
}

.btn--danger {
  background: var(--danger);
  color: #2c0d09;
  font-weight: 600;
}

.btn--danger:hover {
  background: #ec8b80;
}

.btn--round {
  width: 44px;
  height: 44px;
  padding: 0;
  border-color: var(--slate-600);
  border-radius: 50%;
  background: var(--slate-800);
  box-shadow: var(--panel-shadow);
}

.btn--round.is-on {
  border-color: var(--patina);
  background: #24403c;
}

/* ── Верхняя панель ─────────────────────────────────────────────────────── */

.topbar {
  position: absolute;
  inset: 0 0 auto;
  z-index: 3;
  /* Боковые части равной ширины держат режимы по центру; когда места мало, они сжимаются до содержимого. */
  display: grid;
  grid-template-columns: minmax(max-content, 1fr) auto minmax(max-content, 1fr);
  gap: 12px;
  align-items: center;
  height: var(--topbar-height);
  padding: 0 10px;
  border-bottom: 1px solid var(--slate-950);
  background: var(--slate-900);
}

.topbar__side {
  display: flex;
  gap: 6px;
  align-items: center;
}

.topbar__side--end {
  justify-content: flex-end;
}

.topbar__project {
  position: relative;
  display: flex;
  align-items: center;
}

.topbar__name {
  width: clamp(110px, 12vw, 180px);
  height: 32px;
  padding: 0 22px 0 10px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  text-overflow: ellipsis;
  user-select: text;
  -webkit-user-select: text;
}

.topbar__name:hover {
  border-color: var(--slate-600);
}

.topbar__name:focus {
  border-color: var(--patina);
  background: var(--slate-950);
}

.topbar__unsaved {
  position: absolute;
  right: 9px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--bronze);
  pointer-events: none;
}

.topbar__group {
  display: flex;
  gap: 2px;
  align-items: center;
}

/* Соседние группы разделяет черта. */
.topbar__group + .topbar__group,
.topbar__stats + .topbar__group {
  padding-left: 8px;
  border-left: 1px solid var(--slate-700);
}

.topbar__stats {
  margin-right: 8px;
  color: var(--bone-dim);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Переключатель режимов - главный ориентир в интерфейсе. */
.topbar__modes .segmented__option {
  min-height: 32px;
  padding: 0 12px;
  font-weight: 550;
}

.topbar__modes .segmented__option.is-on {
  background: var(--patina);
  color: #0d2622;
}

/* ── Меню ───────────────────────────────────────────────────────────────── */

.menu-anchor {
  position: relative;
}

.menu,
.select {
  display: grid;
  width: max-content;
  padding: 6px;
  border: 1px solid var(--slate-600);
  border-radius: var(--radius-md);
  background: var(--slate-800);
  box-shadow: var(--panel-shadow);
}

.menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 10;
  min-width: 220px;
  max-width: 340px;
}

.menu--end {
  right: 0;
  left: auto;
}

.menu__item,
.select__option {
  display: flex;
  gap: 16px;
  align-items: baseline;
  justify-content: space-between;
  padding: 8px 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  text-align: left;
}

.menu__item:hover,
.select__option.is-active {
  background: var(--slate-700);
}

.menu__item--danger {
  margin-top: 6px;
  color: var(--danger);
}

.menu__hint {
  color: var(--bone-faint);
}

.menu__info,
.select__group {
  margin: 0;
  padding: 5px 10px;
  color: var(--bone-dim);
}

/* Список выпадающего поля (.field__select): лежит в верхнем слое, место ему назначает dropdown.js. */
.select {
  position: fixed;
  inset: auto;
  z-index: 100;
  max-width: min(340px, 100vw - 16px);
  max-height: min(320px, var(--room, 320px));
  margin: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  color: var(--bone);
  scrollbar-width: thin;
  scrollbar-color: var(--slate-600) transparent;
  transform-origin: top;
  animation: select-open 0.12s ease-out;
}

.select[data-side='top'] {
  transform-origin: bottom;
}

@keyframes select-open {
  from {
    opacity: 0;
    transform: scaleY(0.96);
  }
}

.select__option {
  gap: 10px;
  align-items: center;
  min-width: 0;
  cursor: pointer;
}

.select__option[aria-disabled] {
  color: var(--bone-faint);
  cursor: default;
}

.select__option .icon {
  width: 16px;
  height: 16px;
}

.select__text {
  display: grid;
  flex: 1;
  min-width: 0;
}

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

.select__hint {
  color: var(--bone-faint);
  font-size: var(--text-xs);
}

/* Галочка есть у каждого пункта и видна только у выбранного: так названия стоят на одной линии. */
.select__option > .icon:last-child {
  color: var(--patina);
  visibility: hidden;
}

.select__option[aria-selected='true'] > .icon:last-child {
  visibility: visible;
}

.select__group {
  font-size: var(--text-xs);
}

.select__group:not(:first-child) {
  margin-top: 4px;
  padding-top: 9px;
  border-top: 1px solid var(--slate-700);
}

/* ── Лента инструментов ─────────────────────────────────────────────────── */

.rail {
  position: absolute;
  top: calc(var(--topbar-height) + var(--gap));
  left: var(--gap);
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: var(--rail-width);
  max-height: calc(100% - var(--topbar-height) - var(--gap) * 2);
  padding: 6px;
  overflow-y: auto;
  scrollbar-width: none;
  border: 1px solid var(--slate-700);
  border-radius: var(--radius-lg);
  background: rgba(27, 31, 35, 0.94);
  box-shadow: var(--panel-shadow);
}

.tool {
  display: grid;
  flex: none;
  gap: 2px;
  justify-items: center;
  padding: 7px 0 5px;
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--bone-dim);
  transition: background 0.12s, color 0.12s;
}

.tool .icon {
  width: 22px;
  height: 22px;
}

.tool__name {
  max-width: 100%;
  overflow: hidden;
  font-size: 0.625rem;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tool:hover {
  background: var(--slate-700);
  color: var(--bone);
}

.tool.is-on {
  background: var(--patina-wash);
  color: var(--patina);
}

/* ── Плавающие регуляторы кисти ─────────────────────────────────────────── */

.dock {
  position: absolute;
  top: calc(var(--topbar-height) + var(--gap));
  left: calc(var(--gap) * 2 + var(--rail-width));
  z-index: 2;
}

.dock__group {
  display: grid;
  gap: 14px;
  justify-items: center;
}

/* ── Ползунки ───────────────────────────────────────────────────────────── */

.slider {
  --ratio: 0;
  display: grid;
  gap: 8px;
  border-radius: var(--radius-sm);
}

.slider__head {
  display: flex;
  justify-content: space-between;
}

.slider__label {
  color: var(--bone-dim);
}

.slider__value {
  font-variant-numeric: tabular-nums;
}

.slider__value--input {
  width: 9ch;
  margin: -3px 0;
  padding: 2px 6px;
  border: 1px solid var(--slate-600);
  border-radius: var(--radius-sm);
  background: var(--slate-950);
  text-align: right;
  user-select: text;
  -webkit-user-select: text;
  transition: border-color 0.12s;
}

/* Значение обычного ползунка: выглядит надписью, пока на него не навели или не начали в нём печатать. */
.slider__value--quiet {
  width: auto;
  max-width: 14ch;
  border-color: transparent;
  background: transparent;
  cursor: text;
}

.slider__value--quiet:focus {
  background: var(--slate-950);
}

.slider--vertical .slider__value--quiet {
  max-width: 44px;
  margin: 0;
  padding: 1px 2px;
  text-align: center;
}

.slider__value--input:hover {
  border-color: var(--slate-500);
}

.slider__value--input:focus {
  border-color: var(--patina);
  box-shadow: none;
}

.slider__track {
  position: relative;
  height: 20px;
  cursor: ew-resize;
  touch-action: none;
}

.slider__track::before,
.slider__fill {
  position: absolute;
  top: 7px;
  left: 0;
  height: 6px;
  border-radius: 3px;
}

.slider__track::before {
  content: '';
  right: 0;
  background: var(--slate-600);
}

.slider__fill {
  width: calc(var(--ratio) * 100%);
  background: var(--patina);
}

.slider__thumb {
  position: absolute;
  top: 3px;
  left: calc(var(--ratio) * 100%);
  width: 14px;
  height: 14px;
  margin-left: -7px;
  border-radius: 50%;
  background: var(--bone);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

.slider--vertical {
  display: flex;
  flex-direction: column;
  gap: 5px;
  align-items: center;
  width: 44px;
}

.slider--vertical .slider__head {
  display: contents;
}

.slider--vertical .slider__value {
  order: 0;
  font-size: var(--text-xs);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
}

.slider--vertical .slider__label {
  order: 2;
  color: var(--bone);
  font-size: 0.625rem;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
}

.slider--vertical .slider__track {
  order: 1;
  width: 44px;
  height: clamp(96px, 19vh, 168px);
  overflow: hidden;
  border: 1px solid var(--slate-600);
  border-radius: 22px;
  background: rgba(27, 31, 35, 0.94);
  box-shadow: var(--panel-shadow);
  cursor: ns-resize;
}

.slider--vertical .slider__track::before {
  content: none;
}

.slider--vertical .slider__fill {
  top: auto;
  bottom: 0;
  width: 100%;
  height: calc(var(--ratio) * 100%);
  border-radius: 0;
  background: var(--patina-wash);
}

.slider--vertical .slider__thumb {
  top: auto;
  bottom: calc(var(--ratio) * 100%);
  left: 50%;
  width: 22px;
  height: 3px;
  margin: 0 0 -1.5px -11px;
  border-radius: 2px;
  background: var(--patina);
  box-shadow: none;
}

/* ── Правая панель ──────────────────────────────────────────────────────── */

.panel {
  position: absolute;
  top: calc(var(--topbar-height) + var(--gap));
  right: var(--gap);
  bottom: var(--gap);
  z-index: 2;
  display: flex;
  flex-direction: column;
  width: var(--panel-width);
  border: 1px solid var(--slate-700);
  border-radius: var(--radius-lg);
  background: rgba(27, 31, 35, 0.94);
  box-shadow: var(--panel-shadow);
}

.is-panel-hidden .panel {
  display: none;
}

/* Вкладки - переключатель во всю ширину панели. */
.tabs {
  display: flex;
  flex: none;
  gap: 2px;
  margin: 10px 10px 0;
  padding: 3px;
  border-radius: var(--radius-md);
  background: var(--slate-950);
}

.tabs__tab {
  flex: 1;
  min-height: 32px;
  padding: 0 6px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--bone-dim);
  font-weight: 550;
  transition: background 0.12s, color 0.12s;
}

.tabs__tab:hover {
  color: var(--bone);
}

.tabs__tab.is-on {
  background: var(--slate-700);
  color: var(--bone);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

.panel__content {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 22px;
  align-content: start;
  padding: 18px 16px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--slate-600) transparent;
}

.section {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
}

.section__title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 0;
  font-size: var(--text-sm);
  font-weight: 600;
}

/* Сворачиваемый блок панели: строка с названием, по щелчку - содержимое. */
.fold {
  padding-top: 16px;
  border-top: 1px solid var(--slate-700);
}

.fold__title {
  display: flex;
  gap: 8px;
  align-items: baseline;
  font-size: var(--text-sm);
  font-weight: 600;
  list-style: none;
  cursor: pointer;
}

.fold__title::-webkit-details-marker {
  display: none;
}

.fold__title::before {
  content: '';
  flex: none;
  align-self: center;
  width: 6px;
  height: 6px;
  border-right: 1.5px solid var(--bone-dim);
  border-bottom: 1.5px solid var(--bone-dim);
  transform: rotate(-45deg);
  transition: transform 0.12s;
}

.fold[open] > .fold__title::before {
  transform: rotate(45deg);
}

.fold[open] > .fold__title {
  margin-bottom: 12px;
}

.section__count {
  color: var(--bone-faint);
  font-size: var(--text-xs);
  font-weight: 400;
  font-variant-numeric: tabular-nums;
}

.section__note {
  margin: 0;
  color: var(--bone-faint);
  font-size: var(--text-xs);
  line-height: 1.5;
}

.row {
  display: flex;
  gap: 8px;
}

.stack {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 6px;
}

.stack > .slider {
  margin-top: 8px;
}

.stack .btn {
  justify-content: flex-start;
}

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

.grid-2__wide {
  display: grid;
  grid-column: 1 / -1;
}

/* ── Положение, поворот и размер числами ────────────────────────────────── */

.transform {
  display: grid;
  grid-template-columns: auto repeat(3, minmax(0, 1fr)) auto;
  gap: 6px;
  align-items: center;
}

.transform__label {
  color: var(--bone-dim);
  white-space: nowrap;
}

.transform__field {
  display: flex;
  align-items: center;
  min-width: 0;
  height: 30px;
  padding: 0 6px;
  border: 1px solid var(--slate-600);
  border-radius: var(--radius-sm);
  background: var(--slate-950);
  transition: border-color 0.12s;
}

.transform__field:hover {
  border-color: var(--slate-500);
}

.transform__field:focus-within {
  border-color: var(--patina);
}

.transform__axis {
  color: var(--bone-faint);
  font-size: var(--text-xs);
  font-weight: 600;
}

.transform__input {
  flex: 1;
  width: 100%;
  min-width: 0;
  padding: 0 0 0 4px;
  border: 0;
  background: transparent;
  font-variant-numeric: tabular-nums;
  text-align: right;
  user-select: text;
  -webkit-user-select: text;
}

.transform__input:focus {
  outline: none;
  box-shadow: none;
}

.transform__link {
  width: 30px;
  height: 30px;
  padding: 0;
}

/* ── Список объектов ────────────────────────────────────────────────────── */

.objects {
  display: grid;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.objects__row {
  display: flex;
  align-items: center;
  border-radius: var(--radius-sm);
  min-width: 0; /* длинное имя сокращается, а не раздвигает список */
}

.objects__row:hover {
  background: var(--slate-700);
}

.objects__row.is-active {
  background: var(--patina-wash);
}

.objects__row.is-selected {
  background: rgba(92, 196, 174, 0.07);
}

.objects__select {
  display: flex;
  flex: 1;
  gap: 8px;
  align-items: baseline;
  justify-content: space-between;
  min-width: 0;
  padding: 8px 6px 8px 10px;
  border: 0;
  background: transparent;
  text-align: left;
}

.objects__row--nested {
  margin-left: 14px;
  border-left: 1px solid var(--slate-600);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.objects__fold {
  display: grid;
  flex: none;
  place-items: center;
  width: 26px;
  height: 30px;
  margin-right: -8px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--bone-dim);
}

.objects__fold .icon {
  width: 16px;
  height: 16px;
  transition: rotate 0.12s;
}

.objects__fold.is-collapsed .icon {
  rotate: -90deg;
}

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

.is-active .objects__name {
  color: var(--patina);
}

.objects__meta {
  display: flex;
  flex: none;
  gap: 6px;
  align-items: center;
  color: var(--bone-faint);
  font-size: var(--text-xs);
  font-variant-numeric: tabular-nums;
}

.objects__badge {
  color: var(--patina);
}

.objects__badge .icon {
  width: 14px;
  height: 14px;
  vertical-align: -2px;
}

/* ── Дерево костей ──────────────────────────────────────────────────────── */

.bones {
  --step: 12px; /* отступ на один уровень дерева */
  display: grid;
  max-height: 46vh;
  margin: 0;
  padding: 4px;
  overflow-y: auto;
  border: 1px solid var(--slate-700);
  border-radius: var(--radius-md);
  background: var(--slate-950);
  list-style: none;
  scrollbar-width: thin;
  scrollbar-color: var(--slate-600) transparent;
}

.bones__row {
  display: flex;
  align-items: stretch;
  min-width: 0;
  border-radius: var(--radius-sm);
}

.bones__row:hover {
  background: var(--slate-800);
}

.bones__row.is-active {
  background: var(--patina-wash);
}

/* Направляющие: по вертикальной черте на каждый уровень вложенности. */
.bones__indent {
  flex: none;
  width: calc(var(--depth) * var(--step));
  margin-left: 10px;
  background: repeating-linear-gradient(90deg, var(--slate-700) 0 1px, transparent 1px var(--step));
}

.bones__select {
  display: flex;
  flex: 1;
  gap: 8px;
  align-items: center;
  min-width: 0;
  height: 28px;
  padding: 0 8px 0 0;
  border: 0;
  background: transparent;
  color: var(--bone-dim);
  text-align: left;
}

.bones__row:hover .bones__select {
  color: var(--bone);
}

.bones__joint {
  flex: none;
  width: 7px;
  height: 7px;
  margin-left: -3px;
  border: 1.5px solid var(--slate-500);
  border-radius: 50%;
  background: var(--slate-950);
}

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

.is-active .bones__select {
  color: var(--patina);
}

.is-active .bones__joint {
  border-color: var(--patina);
  background: var(--patina);
}

.bones .rename {
  margin: 2px 4px 2px 0;
}

.rename {
  flex: 1;
  min-width: 0;
  margin: 4px 6px;
  padding: 3px 6px;
  border: 1px solid var(--patina);
  border-radius: 4px;
  background: var(--slate-950);
  user-select: text;
  -webkit-user-select: text;
}

.row > .menu-anchor {
  display: flex;
  flex: 1;
}

/* Кнопка с меню во всю ширину раздела. */
.section > .menu-anchor {
  display: grid;
}

.row > .btn[aria-label] {
  flex: none;
  width: 34px;
  padding: 0;
}

.row > .field {
  flex: 1;
}

/* Перетаскивание строк: полоска показывает место вставки, рамка - «внутрь группы». */
.is-sorting,
.is-sorting button {
  cursor: grabbing;
}

.is-dragging {
  opacity: 0.45;
}

.is-drop-before {
  box-shadow: 0 -2px 0 var(--patina);
}

.is-drop-after {
  box-shadow: 0 2px 0 var(--patina);
}

.is-drop-inside {
  box-shadow: inset 0 0 0 1.5px var(--patina);
}

/* ── Поля, переключатели, счётчики ──────────────────────────────────────── */

.segmented {
  display: grid;
  grid-auto-columns: 1fr;
  grid-auto-flow: column;
  gap: 2px;
  padding: 2px;
  border-radius: var(--radius-sm);
  background: var(--slate-950);
}

.segmented__option {
  min-height: 30px;
  padding: 0 4px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--bone-dim);
  white-space: nowrap;
}

.segmented__option:hover {
  color: var(--bone);
}

.segmented__option.is-on {
  background: var(--slate-600);
  color: var(--bone);
}

.field {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  min-width: 0;
}

.field__label {
  color: var(--bone-dim);
  white-space: nowrap;
}

/* Поле с выбором: выпадающий список (dropdown.js) и шрифт (fontPicker.js). */
.field__select {
  display: flex;
  flex: 0 1 170px;
  gap: 6px;
  align-items: center;
  justify-content: space-between;
  min-width: 88px;
  height: 32px;
  padding: 0 6px 0 10px;
  border: 1px solid var(--slate-600);
  border-radius: var(--radius-sm);
  background: var(--slate-700);
  color: var(--bone);
  font: inherit;
  cursor: pointer;
  transition: border-color 0.12s, background-color 0.12s;
}

.field__select:hover {
  border-color: var(--slate-500);
}

.field__select[aria-expanded='true'] {
  border-color: var(--patina);
  background: var(--slate-800);
}

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

.field__select .icon {
  width: 16px;
  height: 16px;
  color: var(--bone-dim);
}

.field__value .icon {
  margin-right: 6px;
  vertical-align: -3px;
}

.field__select > .icon {
  transition: transform 0.12s;
}

.field__select[aria-expanded='true'] > .icon {
  transform: rotate(180deg);
}

/* Выбор цвета: круглый образец, подпись и код цвета. */
.swatch {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0 10px;
  align-items: center;
  padding: 7px 10px 7px 8px;
  border: 1px solid var(--slate-700);
  border-radius: var(--radius-md);
  background: var(--slate-800);
  cursor: pointer;
  transition: border-color 0.12s;
}

.swatch:hover {
  border-color: var(--slate-500);
}

.swatch::before {
  content: '';
  grid-row: span 2;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--color);
  box-shadow: inset 0 0 0 1px rgba(235, 230, 220, 0.22), 0 1px 3px rgba(0, 0, 0, 0.4);
}

/* Системное поле цвета лежит поверх всей плашки невидимым: щелчок в любом её месте открывает палитру. */
.swatch__input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  opacity: 0;
  cursor: pointer;
}

.swatch__label {
  color: var(--bone-dim);
  font-size: var(--text-xs);
  line-height: 1.3;
}

.swatch__code {
  font-size: var(--text-xs);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
  line-height: 1.3;
}

.stepper {
  display: flex;
  flex: none;
  align-items: stretch;
  height: 34px;
  border-radius: var(--radius-sm);
  background: var(--slate-950);
}

.stepper__button {
  width: 28px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--bone-dim);
  font-size: var(--text-md);
}

.stepper__button:hover {
  color: var(--patina);
}

.stepper__input {
  width: 46px;
  padding: 0;
  border: 0;
  background: transparent;
  font-variant-numeric: tabular-nums;
  text-align: center;
  appearance: textfield;
  -moz-appearance: textfield;
  user-select: text;
  -webkit-user-select: text;
}

.stepper__input::-webkit-inner-spin-button {
  appearance: none;
}

.modifier {
  display: grid;
  gap: 6px;
}

.modifier__settings {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
  align-items: center;
  padding-left: 10px;
  border-left: 1px solid var(--slate-600);
}

/* ── Фон и свет ─────────────────────────────────────────────────────────── */

.backdrop {
  display: grid;
  gap: 8px;
}

.backdrop__preview {
  height: 64px;
  border: 1px solid var(--slate-700);
  border-radius: var(--radius-md);
}

.backdrop__presets {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
}

.backdrop__preset {
  aspect-ratio: 1;
  padding: 0;
  border: 1px solid rgba(235, 230, 220, 0.18);
  border-radius: 50%;
  transition: scale 0.12s;
}

.backdrop__preset:hover {
  scale: 1.08;
}

.light {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 16px;
  align-items: center;
}

.light__settings {
  display: grid;
  gap: 12px;
}

.light__side {
  display: flex;
  justify-content: space-between;
  margin: 0;
  color: var(--bone-dim);
}

.light__value {
  color: var(--bone);
  font-variant-numeric: tabular-nums;
}

/* Круговой регулятор: вид сверху, источник ходит по кругу вокруг модели. */
.dial {
  --angle: 0deg;
  --size: 92px;
  position: relative;
  width: var(--size);
  height: var(--size);
  border: 1px solid var(--slate-600);
  border-radius: 50%;
  background: radial-gradient(circle, var(--slate-800) 0 58%, var(--slate-950) 59%);
  cursor: grab;
  touch-action: none;
}

/* Модель в центре: «нос» смотрит вниз - там перед. */
.dial__model {
  position: absolute;
  inset: 36%;
  border-radius: 50% 50% 50% 50% / 42% 42% 58% 58%;
  background: var(--clay);
  box-shadow: inset 0 -5px 6px rgba(0, 0, 0, 0.28);
}

.dial__model::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: calc(50% - 3px);
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--clay);
}

/* Источник: при угле 0 стоит внизу круга и идёт против часовой стрелки - вправо от модели. */
.dial__source {
  position: absolute;
  top: calc(50% - 7px);
  left: calc(50% - 7px);
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--bronze);
  box-shadow: 0 0 0 3px rgba(207, 154, 98, 0.22), 0 0 12px rgba(207, 154, 98, 0.7);
  transform: rotate(calc(var(--angle) * -1)) translateY(calc(var(--size) * 0.39));
}

/* ── Готовые материалы ──────────────────────────────────────────────────── */

.presets {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px 4px;
}

.presets__item {
  display: grid;
  gap: 4px;
  justify-items: center;
  padding: 6px 0 4px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--bone-dim);
}

.presets__item:hover {
  background: var(--slate-700);
  color: var(--bone);
}

/* Шарик: блик тем резче, чем глаже материал; у металла тёмный низ, как в отражении. */
.presets__ball {
  width: 34px;
  aspect-ratio: 1;
  border-radius: 50%;
  background:
    radial-gradient(
      circle at 34% 30%,
      rgba(255, 255, 255, calc(0.25 + var(--gloss) * 0.007)) 0%,
      transparent calc(46% - var(--gloss) * 0.3%)
    ),
    radial-gradient(circle at 40% 36%, transparent 40%, rgba(0, 0, 0, calc(0.38 + var(--metal) * 0.3)) 100%),
    var(--color);
}

.presets__name {
  max-width: 100%;
  overflow: hidden;
  font-size: var(--text-xs);
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Цвет ───────────────────────────────────────────────────────────────── */

.color {
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  gap: 5px;
}

.color__picker,
.color__swatch {
  width: 100%;
  aspect-ratio: 1;
  padding: 0;
  border: 1px solid rgba(235, 230, 220, 0.18);
  border-radius: 50%;
}

.color__picker {
  min-width: 0;
  height: auto;
  overflow: hidden;
  border: 2px solid transparent;
  background: conic-gradient(#e2766a, #d9a441, #6f9a5b, #4f8fa8, #6b5aa6, #e2766a) border-box;
  cursor: pointer;
  appearance: none;
}

.color__picker::-webkit-color-swatch-wrapper {
  padding: 0;
}

.color__picker::-webkit-color-swatch,
.color__picker::-moz-color-swatch {
  border: 0;
  border-radius: 50%;
}

.color__swatch.is-on {
  box-shadow: 0 0 0 2px var(--slate-900), 0 0 0 3.5px var(--bone);
}

/* ── Куб видов ──────────────────────────────────────────────────────────── */

.viewcube {
  --size: 58px;
  position: absolute;
  top: calc(var(--topbar-height) + var(--gap) + 10px);
  right: calc(var(--panel-width) + var(--gap) * 2 + 14px);
  z-index: 2;
  display: grid;
  gap: 18px;
  justify-items: center;
}

.is-panel-hidden .viewcube {
  right: calc(var(--gap) + 14px);
}

.viewcube__stage {
  width: var(--size);
  height: var(--size);
  perspective: 320px;
  cursor: grab;
  touch-action: none;
}

.viewcube__stage.is-locked {
  cursor: pointer;
}

.viewcube__cube {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
}

.viewcube__face {
  position: absolute;
  inset: 0;
  padding: 0;
  border: 1px solid var(--slate-500);
  border-radius: 4px;
  background: rgba(35, 40, 45, 0.92);
  color: var(--bone);
  font-size: var(--text-xs);
  backface-visibility: hidden;
  cursor: inherit;
  transition: background 0.12s, color 0.12s;
}

.viewcube__face:hover {
  background: #24403c;
  color: var(--patina);
}

.viewcube__face--front {
  transform: translateZ(calc(var(--size) / 2));
}

.viewcube__face--back {
  transform: rotateY(180deg) translateZ(calc(var(--size) / 2));
}

.viewcube__face--right {
  transform: rotateY(90deg) translateZ(calc(var(--size) / 2));
}

.viewcube__face--left {
  transform: rotateY(-90deg) translateZ(calc(var(--size) / 2));
}

.viewcube__face--top {
  transform: rotateX(90deg) translateZ(calc(var(--size) / 2));
}

.viewcube__face--bottom {
  transform: rotateX(-90deg) translateZ(calc(var(--size) / 2));
}

.viewcube__lock {
  width: 36px;
  height: 36px;
}

.viewcube__lock .icon {
  width: 18px;
  height: 18px;
}

/* ── Текстуры кисти ─────────────────────────────────────────────────────── */

.textures {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}

.textures__item {
  aspect-ratio: 1;
  padding: 0;
  border: 1px solid var(--slate-600);
  border-radius: 50%;
  background: radial-gradient(circle, var(--bone) 0%, var(--bone) 34%, #000 72%) center / cover;
  filter: grayscale(1);
}

.textures__item.is-on {
  box-shadow: 0 0 0 2px var(--slate-900), 0 0 0 3.5px var(--patina);
}

/* Штампы - фигуры, а не круглые отпечатки кисти: плитка показывает картинку целиком. */
.textures--square .textures__item {
  border-radius: var(--radius-sm);
  background-color: #000;
}

/* Строка о последнем оттиске: пока он жив и следует за настройками, точка перед ней горит. */
.stamp-status {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-height: 3em; /* место под две строки: смена надписи не двигает ползунки */
  margin: 0;
  color: var(--bone-faint);
  font-size: var(--text-xs);
  line-height: 1.5;
}

.stamp-status::before {
  content: '';
  flex: none;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--slate-500);
}

.stamp-status.is-live {
  color: var(--bone-dim);
}

.stamp-status.is-live::before {
  background: var(--patina);
}

/* ── Шкала времени ──────────────────────────────────────────────────────── */

.timeline {
  position: absolute;
  right: calc(var(--panel-width) + var(--gap) * 2);
  bottom: var(--gap);
  left: var(--gap);
  z-index: 2;
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 8px 16px 8px 8px;
  border: 1px solid var(--slate-700);
  border-radius: var(--radius-lg);
  background: rgba(27, 31, 35, 0.94);
  box-shadow: var(--panel-shadow);
}

.is-panel-hidden .timeline {
  right: var(--gap);
}

.timeline .btn--round {
  flex: none;
  box-shadow: none;
}

.timeline__track {
  position: relative;
  flex: 1;
  height: 32px;
  border-radius: var(--radius-sm);
  background:
    repeating-linear-gradient(90deg, var(--slate-600) 0 1px, transparent 1px 12.5%) 0 100% / 100% 7px no-repeat,
    var(--slate-950);
  cursor: ew-resize;
  touch-action: none;
}

.timeline__key {
  position: absolute;
  top: 50%;
  width: 9px;
  height: 9px;
  margin: -4.5px 0 0 -4.5px;
  background: var(--bronze);
  rotate: 45deg;
}

.timeline__head {
  position: absolute;
  top: -3px;
  bottom: -3px;
  width: 2px;
  margin-left: -1px;
  border-radius: 1px;
  background: var(--patina);
  pointer-events: none;
}

.timeline__time {
  flex: none;
  min-width: 96px;
  color: var(--bone-dim);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

/* ── Рамка выделения ────────────────────────────────────────────────────── */

.marquee {
  position: absolute;
  border: 1px solid var(--patina);
  background: var(--patina-wash);
  pointer-events: none;
}

/* ── Курсор кисти и подсказка ───────────────────────────────────────────── */

.brush-cursor {
  --radius: 60px;
  position: absolute;
  top: calc(var(--radius) * -1);
  left: calc(var(--radius) * -1);
  width: calc(var(--radius) * 2);
  height: calc(var(--radius) * 2);
  border: 1.5px solid rgba(235, 230, 220, 0.85);
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(20, 24, 27, 0.45), inset 0 0 0 1px rgba(20, 24, 27, 0.45);
  pointer-events: none;
}

.brush-cursor.is-inverted {
  border-color: var(--bronze);
}

.hint {
  position: absolute;
  bottom: var(--gap);
  left: calc(var(--gap) * 3 + var(--rail-width) + 44px);
  z-index: 1;
  max-width: calc(100% - var(--panel-width) - var(--rail-width) - 140px);
  color: rgba(235, 230, 220, 0.5);
  font-size: var(--text-xs);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
  pointer-events: none;
}

.is-panel-hidden .hint {
  max-width: calc(100% - var(--rail-width) - 100px);
}

/* ── Сообщения ──────────────────────────────────────────────────────────── */

.toasts {
  position: fixed;
  bottom: 44px;
  left: 50%;
  z-index: 100;
  display: grid;
  gap: 8px;
  justify-items: center;
  translate: -50% 0;
  pointer-events: none;
}

.toast {
  max-width: min(90vw, 480px);
  padding: 10px 16px;
  border: 1px solid var(--slate-600);
  border-radius: var(--radius-md);
  background: var(--slate-800);
  box-shadow: var(--panel-shadow);
}

.toast--success {
  border-color: var(--patina-deep);
}

.toast--error {
  border-color: var(--danger);
  color: #f3b3ab;
}

/* ── Диалоги ────────────────────────────────────────────────────────────── */

.dialog {
  width: min(92vw, 420px);
  max-height: 86vh;
  padding: 0;
  border: 1px solid var(--slate-600);
  border-radius: var(--radius-lg);
  background: var(--slate-800);
  color: var(--bone);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
}

.dialog[open] {
  display: flex;
  flex-direction: column;
}

.dialog--wide {
  width: min(94vw, 860px);
}

.dialog::backdrop,
.progress::backdrop {
  background: rgba(13, 15, 17, 0.62);
  backdrop-filter: blur(3px);
}

/* Плашка ожидания: кольцо крутится, пока идёт долгая операция. */
.progress {
  padding: 0;
  border: 1px solid var(--slate-600);
  border-radius: var(--radius-lg);
  background: var(--slate-800);
  color: var(--bone);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
  cursor: progress;
}

.progress[open] {
  display: flex;
  gap: 16px;
  align-items: center;
  min-width: 280px;
  max-width: min(92vw, 420px);
  padding: 18px 24px 18px 20px;
}

.progress__spinner {
  flex: none;
  width: 30px;
  height: 30px;
  border: 3px solid var(--slate-600);
  border-top-color: var(--patina);
  border-radius: 50%;
  animation: progress-spin 0.9s linear infinite;
}

.progress__text {
  display: grid;
  gap: 2px;
  margin: 0;
  font-size: var(--text-md);
  font-weight: 550;
}

.progress__detail {
  color: var(--bone-dim);
  font-size: var(--text-sm);
  font-weight: 400;
  font-variant-numeric: tabular-nums;
}

@keyframes progress-spin {
  to {
    rotate: 360deg;
  }
}

.dialog__head {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: space-between;
  padding: 14px 12px 6px 20px;
}

.dialog__title {
  margin: 0;
  font-size: var(--text-lg);
  font-weight: 600;
  letter-spacing: -0.01em;
}

.dialog__body {
  padding: 6px 20px 20px;
  overflow-y: auto;
  /* Полоса прокрутки - как в панелях: тонкая, тёмная, без белой дорожки. */
  scrollbar-width: thin;
  scrollbar-color: var(--slate-600) transparent;
}

.dialog__text {
  margin: 0 0 20px;
  color: var(--bone-dim);
  font-size: var(--text-md);
}

.dialog__actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.dialog__actions .btn {
  min-height: 38px;
  padding: 0 16px;
}

/* Выбор из нескольких вариантов с пояснениями. */
.choices {
  display: grid;
  gap: 10px;
}

.choice {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 4px 12px;
  padding: 14px;
  border: 1px solid var(--slate-600);
  border-radius: var(--radius-md);
  background: var(--slate-700);
  color: var(--bone);
  text-align: left;
}

.choice:hover,
.choice:focus-visible {
  border-color: var(--patina);
  background: #24403c;
}

.choice__icon {
  display: grid;
  grid-row: span 2;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--slate-900);
  color: var(--patina);
}

.choice__name {
  align-self: end;
  font-size: var(--text-md);
  font-weight: 600;
}

.choice__text {
  color: var(--bone-dim);
  font-size: var(--text-sm);
  line-height: 1.45;
}

/* Окно объёмной надписи: поле текста и настройки столбиком. */
.text-form {
  display: grid;
  gap: 12px;
  margin-bottom: 20px;
}

.text-form__input {
  height: auto;
  min-height: 84px;
  padding: 8px 10px;
  font: inherit;
  font-size: var(--text-md);
  line-height: 1.4;
  resize: vertical;
}

.text-form .segmented {
  min-width: 190px;
}

/* ── Проекты ────────────────────────────────────────────────────────────── */

.projects__toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.projects__toolbar .btn {
  min-height: 38px;
  padding: 0 14px;
}

.projects__about {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
  margin-bottom: 16px;
  padding: 10px 12px;
  border: 1px solid var(--slate-600);
  border-radius: var(--radius-md);
}

.projects__note {
  flex: 1 1 280px;
  margin: 0;
  color: var(--bone-dim);
  font-size: var(--text-sm);
  line-height: 1.4;
}

.projects {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
}

.projects__empty {
  grid-column: 1 / -1;
  margin: 24px 0;
  color: var(--bone-dim);
  font-size: var(--text-md);
}

.project {
  position: relative;
  border: 1px solid var(--slate-700);
  border-radius: var(--radius-md);
  background: var(--slate-900);
  transition: border-color 0.12s;
}

.project:hover {
  border-color: var(--slate-500);
}

.project.is-current {
  border-color: var(--patina);
}

.project.is-selected {
  border-color: var(--patina);
  background: var(--patina-wash);
  box-shadow: 0 0 0 2px var(--patina);
}

.project__open {
  display: grid;
  gap: 2px;
  width: 100%;
  padding: 0 0 10px;
  border: 0;
  border-radius: inherit;
  background: transparent;
  text-align: left;
}

.project__thumb {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  margin-bottom: 8px;
  border-radius: 9px 9px 0 0;
  object-fit: cover;
  background: var(--slate-700);
}

.project__name,
.project__meta {
  padding: 0 40px 0 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project__name {
  font-weight: 600;
}

.project__meta {
  padding-right: 12px;
  color: var(--bone-faint);
  font-size: var(--text-xs);
}

.project > .btn {
  position: absolute;
  right: 6px;
  bottom: 22px;
}

.project > .btn:hover {
  color: var(--danger);
}

/* ── Помощник ───────────────────────────────────────────────────────────── */

/* Лента диалога прокручивается, поле ввода всегда внизу. */
.chat {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 0;
  min-height: 0;
  padding: 0;
  overflow: hidden;
}

.chat__log {
  flex: 1;
  min-height: 0;
  padding: 18px 16px 8px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--slate-600) transparent;
  user-select: text;
  -webkit-user-select: text;
}

.chat__intro {
  display: grid;
  gap: 10px;
}

.chat__title {
  margin: 0;
  font-size: var(--text-md);
  font-weight: 600;
}

.chat__examples {
  display: grid;
  gap: 6px;
  margin-top: 6px;
}

.chat__example {
  padding: 9px 12px;
  border: 1px solid var(--slate-700);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--bone-dim);
  line-height: 1.35;
  text-align: left;
  transition: border-color 0.12s, color 0.12s, background 0.12s;
}

.chat__example:hover {
  border-color: var(--patina-deep);
  background: var(--patina-wash);
  color: var(--bone);
}

.chat__turns {
  display: grid;
  gap: 22px;
}

.chat__turn {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
}

/* Просьба пользователя - плашка справа; ответ помощника - обычный текст слева. */
.chat__prompt {
  justify-self: end;
  max-width: 92%;
  margin: 0;
  padding: 8px 12px;
  border-radius: var(--radius-md) var(--radius-md) 3px var(--radius-md);
  background: var(--slate-700);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.chat__answer {
  display: grid;
  gap: 8px;
  overflow-wrap: anywhere;
}

.chat__answer:empty {
  display: none;
}

.chat__answer p {
  margin: 0;
  line-height: 1.5;
  white-space: pre-wrap;
}

.chat__activity {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 0;
  color: var(--bone-dim);
  font-size: var(--text-xs);
}

.chat__activity::before {
  flex: none;
  width: 12px;
  height: 12px;
  border: 2px solid var(--slate-600);
  border-top-color: var(--patina);
  border-radius: 50%;
  content: '';
  animation: progress-spin 0.9s linear infinite;
}

.chat__error {
  margin: 0;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: rgba(226, 118, 106, 0.12);
  color: var(--danger);
}

.chat__note {
  margin: 0;
  color: var(--bone-faint);
  font-size: var(--text-xs);
}

.chat__turn > .btn {
  flex: none;
  justify-self: start;
  min-height: 30px;
}

.chat__composer {
  display: grid;
  flex: none;
  gap: 4px;
  padding: 8px 12px 10px;
}

.chat__field {
  display: flex;
  gap: 6px;
  align-items: flex-end;
  padding: 6px 6px 6px 12px;
  border: 1px solid var(--slate-600);
  border-radius: var(--radius-md);
  background: var(--slate-950);
  transition: border-color 0.12s;
}

.chat__field:focus-within {
  border-color: var(--patina-deep);
}

.chat__input {
  flex: 1;
  min-width: 0;
  min-height: 32px;
  padding: 6px 0;
  border: 0;
  background: transparent;
  color: var(--bone);
  font: inherit;
  line-height: 1.45;
  resize: none;
  scrollbar-width: thin;
}

.chat__input:focus-visible {
  box-shadow: none;
}

.chat__input::placeholder {
  color: var(--bone-faint);
}

.chat__send {
  display: grid;
  flex: none;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: var(--patina);
  color: #0d2622;
  transition: background 0.12s;
}

.chat__send:hover {
  background: #73d3be;
}

.chat__send:disabled {
  background: var(--slate-700);
  color: var(--bone-faint);
  cursor: default;
}

.chat__send--stop {
  background: var(--slate-600);
  color: var(--bone);
}

.chat__send--stop:hover {
  background: var(--slate-500);
}

.chat__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 28px;
  padding: 0 4px;
}

/* Остаток лимита: полоска убывает слева направо, у самого конца краснеет. */
.chat__budget {
  display: flex;
  gap: 8px;
  align-items: center;
  color: var(--bone-faint);
  font-size: var(--text-xs);
  font-variant-numeric: tabular-nums;
}

.chat__budget-bar {
  position: relative;
  width: 64px;
  height: 4px;
  border-radius: 2px;
  background: var(--slate-700);
  overflow: hidden;
}

.chat__budget-bar::after {
  position: absolute;
  inset: 0;
  background: var(--patina-deep);
  content: '';
  transform: scaleX(var(--share, 1));
  transform-origin: left;
  transition: transform 0.3s;
}

.chat__budget.is-low {
  color: var(--danger);
}

.chat__budget.is-low .chat__budget-bar::after {
  background: var(--danger);
}

.chat__foot .btn--quiet:hover {
  color: var(--bone);
}

/* ── Узкие экраны ───────────────────────────────────────────────────────── */

@media (max-width: 1500px) {
  .topbar__stats {
    display: none;
  }
}

/* Подписи кнопок уступают место, чтобы режимы оставались по центру. */
@media (max-width: 1700px) {
  .topbar .btn:not(.btn--text) .btn__label {
    display: none;
  }
}

@media (max-width: 720px) {
  .editor {
    --topbar-height: 126px;
    --rail-width: 52px;
    --gap: 8px;
  }

  /* Три строки: проект, режимы, действия. Боковые части раскрываются в общий ряд. */
  .topbar {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 2px;
    align-content: center;
    padding: 0 8px;
  }

  .topbar__side {
    display: contents;
  }

  .topbar__project {
    flex: 1 1 0;
    min-width: 0;
  }

  .topbar__name {
    width: 100%;
  }

  .topbar__modes {
    order: 2;
    flex: 1 0 100%;
  }

  .topbar__modes .segmented__option {
    padding: 0 2px;
    font-size: var(--text-sm);
  }

  .topbar__group {
    order: 3;
    gap: 0;
  }

  .topbar__group + .topbar__group,
  .topbar__stats + .topbar__group {
    padding-left: 0;
    border-left: 0;
  }

  /* Действия с файлами прижаты влево, вид - вправо. */
  .topbar__side--end .topbar__group {
    margin-left: auto;
  }

  .topbar .btn {
    min-width: 30px;
    padding: 0 5px;
  }

  .tool__name,
  .hint {
    display: none;
  }

  .panel {
    width: min(var(--panel-width), calc(100% - var(--gap) * 2));
  }
}

/* Референсы на экране: картинки поверх вьюпорта или под ним (холст прозрачный, фон - у самой сцены). */
/* Холст сцены встаёт в общий порядок слоёв: что в разметке до него - под моделью, что после - над ней. */
.stage > canvas {
  position: relative;
}

.references {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.references .references__image {
  position: absolute;
  width: auto;
  max-width: none;
  transform: translate(-50%, -50%);
  border-radius: 4px;
}

/* Остаток лимита - одной строкой: полоска и проценты. */
.chat__budget {
  flex: none;
  white-space: nowrap;
}

/* Кнопки «Развернуть» и «Отразить» под полями положения - во всю ширину блока. */
.transform > .row {
  grid-column: 1 / -1;
}
