:root {
  color: #20211f;
  background: #f4f2ed;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  font-synthesis: none;
  line-height: 1.4;
  text-rendering: optimizeLegibility;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  overflow: hidden;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

/* Неактивные кнопки выделяются бледно-оранжевым, чтобы сразу отличаться от активных. */
button:disabled {
  background: #fbe4c9;
  border-color: #f0cda4;
  color: #a5713d;
  cursor: not-allowed;
}

button:disabled:hover,
button:disabled:active {
  background: #fbe4c9;
  border-color: #f0cda4;
  color: #a5713d;
  transform: none;
}

/* Кнопки истории действий («Отменить»/«Повторить») без оранжевой подсветки —
   нейтральный приглушённый вид, оранжевый оставлен переключателям функций. */
#undoButton:disabled,
#redoButton:disabled,
#editorUndoButton:disabled,
#editorRedoButton:disabled {
  background: #ece7db;
  border-color: #d5cdc0;
  color: #a8a49c;
  cursor: default;
}

#undoButton:disabled:hover,
#redoButton:disabled:hover,
#editorUndoButton:disabled:hover,
#editorRedoButton:disabled:hover {
  background: #ece7db;
  border-color: #d5cdc0;
  color: #a8a49c;
  transform: none;
}

input {
  min-width: 0;
}

.planner {
  display: grid;
  grid-template-columns: var(--left-panel-width, 320px) 4px minmax(0, 1fr) 4px var(--right-panel-width, 320px);
  grid-template-rows: 64px var(--tab-bar-height, 38px) minmax(0, 1fr);
  width: 100vw;
  height: 100vh;
  background: #f4f2ed;
}

.resizer {
  grid-row: 3;
  width: 4px;
  cursor: col-resize;
  background: transparent;
  transition: background 0.2s, box-shadow 0.2s;
  z-index: 10;
}

.resizer:hover,
.resizer.active {
  background: #d96f32;
  box-shadow: 0 0 8px rgba(217, 111, 50, 0.4);
}

.resizer-left {
  grid-column: 2;
}

.resizer-right {
  grid-column: 4;
}

.topbar {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 20px;
  padding: 10px 16px;
  border-bottom: 1px solid #d9d3c8;
  background: #fbfaf7;
}

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

#appNameTitle {
  outline: none;
  border-bottom: 1px dashed transparent;
  transition: border-color 0.2s;
}

#appNameTitle:hover {
  border-color: #d96f32;
}

#appNameTitle:focus {
  border-color: #1f8062;
  border-bottom-style: solid;
}

.brandMark {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background:
    linear-gradient(135deg, #277b61 0 48%, transparent 49%),
    linear-gradient(45deg, #d96f32 0 48%, #2f6b95 49%);
  box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.08);
}

.brand strong {
  display: block;
  font-size: 15px;
}

.brand span:last-child {
  color: #68655e;
  display: block;
  font-size: 12px;
}

[hidden] {
  display: none !important;
}

/* Полоса вкладок вариантов*/

.variantTabBar {
  grid-column: 1 / -1;
  grid-row: 2;
  display: flex;
  align-items: flex-end;
  gap: 2px;
  background: #e9e5dc;
  border-bottom: 1px solid #d9d3c8;
  padding: 4px 8px 0;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  min-height: var(--tab-bar-height, 38px);
}

.variantTab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 96px;
  max-width: 200px;
  padding: 6px 8px 7px;
  border: 1px solid #d4cdbf;
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  background: #eee9df;
  color: #6b6560;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  position: relative;
  user-select: none;
}

.variantTab:hover {
  background: #f4efe6;
  color: #4d4942;
}

.variantTab.active {
  background: #fbfaf7;
  color: #1f8062;
  font-weight: 600;
  border-color: #d9d3c8;
  box-shadow: 0 -1px 3px rgb(0 0 0 / 0.04);
}

.variantTabName {
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.variantTabName[contenteditable="true"] {
  outline: 1px solid #1f8062;
  border-radius: 3px;
  background: #fff;
  padding: 0 2px;
}

.variantTabClose {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  padding: 0;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: #a8a49c;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
}

.variantTabClose:hover {
  background: #e2d3c8;
  color: #9f3b2c;
}

.variantTabAdd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 1px solid #d4cdbf;
  border-radius: 6px;
  background: #eee9df;
  color: #6b6560;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
  margin-bottom: 5px;
}

.variantTabAdd:hover {
  background: #e1ede6;
  color: #1f8062;
  border-color: #b5d1bd;
}

.detailSettings {
  display: none;
}

.dropdownInputRow {
  padding: 0 12px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid #f0ede8;
  font-size: 13px;
  color: #20211f;
}

.dropdownInputRow:last-child {
  border-bottom: 0;
}

.dropdownInputRow span {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.dropdownInputRow input {
  width: 50px;
  height: 28px;
  border: 1px solid #d5cdc0;
  border-radius: 4px;
  padding: 0 4px;
  text-align: center;
  background: #fbfaf7;
  flex-shrink: 0;
}

.dropdownInputRow input[type="text"] {
  width: 200px;
  text-align: left;
}

.dropdownInputRow .segmented {
  width: 200px;
  flex-shrink: 0;
}

.dropdownInputRow .segmented button {
  min-height: 30px;
  font-size: 12px;
}

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

.toolbar.center {
  justify-self: center;
}

.toolbar.right {
  justify-self: end;
}

.divider {
  width: 1px;
  height: 26px;
  background: #d9d3c8;
  margin: 0 4px;
}

.toolButton,
.iconButton,
.wideButton {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  background: #ece7db;
  color: #20211f;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid #d5cdc0;
  vertical-align: middle;
  line-height: 1;
  transition: all 0.2s ease;
}

.toolButton:hover:not(:disabled),
.iconButton:hover:not(:disabled),
.wideButton:hover:not(:disabled) {
  background: #e1ede6;
  border-color: #b5d1bd;
  color: #1f8062;
}

.toolButton:active:not(:disabled),
.iconButton:active:not(:disabled),
.wideButton:active:not(:disabled) {
  transform: scale(0.97);
  background: #d9e6de;
}

.toolButton.active,
.segmented button.active {
  background: #1f8062;
  color: white;
}

.toolButton.primary,
.wideButton.primary {
  background: #ece7db;
  border-color: #d5cdc0;
  color: #20211f;
}

.toolButton.primary:hover:not(:disabled),
.wideButton.primary:hover:not(:disabled) {
  background: #e1ede6;
  border-color: #b5d1bd;
  color: #1f8062;
}

/* Кнопка «Зафиксировать точку» — акцентная зелёная (действие доступно).
   В состоянии «Открепить точку» используется обычный серый .wideButton. */
.wideButton.fixPoint {
  background: #ddefdd;
  border-color: #b5d1bd;
  color: #1f8062;
}
.wideButton.fixPoint:hover:not(:disabled) {
  background: #cfe8d2;
  border-color: #a3c7ae;
  color: #1f8062;
}

/* Кнопка «Открепить точку» — обычная серая, как остальные кнопки. */
.wideButton.unfixAction {
  background: #ece7db;
  border-color: #d5cdc0;
  color: #20211f;
}
.wideButton.unfixAction:hover:not(:disabled) {
  background: #e1ede6;
  border-color: #b5d1bd;
  color: #1f8062;
}

.iconButton {
  width: 36px;
  padding: 0;
  font-size: 18px;
}

/* Кнопка «+ Новый раздел» в самом верху панели библиотеки. Светло-зелёная,
   видна только в режиме редактирования (applyEditModeToUI переключает hidden). */
.addCategoryBtn {
  background: #e1ede6;
  border-color: #b5d1bd;
  color: #1f8062;
  font-weight: 600;
}

.addCategoryBtn:hover:not(:disabled) {
  background: #d5e7de;
  border-color: #9fc4b2;
  color: #17664e;
}

.addCategoryBtn:active:not(:disabled) {
  transform: scale(0.99);
  background: #c9dfd4;
}

.leftPanel,
.rightPanel {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px;
  overflow: auto;
  /* Место под скроллбар резервируется всегда: без этого появление/исчезание
     полосы прокрутки (например, при включении режима редактирования список
     библиотеки становится выше) сдвигает ширину всего содержимого панели. */
  scrollbar-gutter: stable;
  background: #fbfaf7;
}

.leftPanel {
  border-right: 1px solid #d9d3c8;
}

.rightPanel {
  border-left: 1px solid #d9d3c8;
}

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

.panelSection.grow {
  min-height: 0;
  flex: 1;
}

h2 {
  margin: 0;
  font-size: 13px;
  color: #4d4942;
  text-transform: uppercase;
  letter-spacing: 0;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
  padding: 2px;
  border: 1px solid #d5cdc0;
  border-radius: 7px;
  background: #eee9df;
}

.segmented button {
  min-height: 26px;
  padding: 0 10px;
  border: none;
  border-radius: 5px;
  background: transparent;
  color: #3b3934;
  font-size: 11px;
  font-weight: 600;
  transition: all 0.2s ease;
}

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

.controlRow > .wideButton {
  flex: 1 1 100%;
  min-width: 0;
  white-space: normal;
  line-height: 1.15;
  padding: 6px 10px;
  word-break: break-word;
  hyphens: auto;
  text-align: center;
}

.wideButton {
  width: 100%;
  white-space: nowrap;
  min-width: 0;
}

/* Ширина левой панели ограничена снизу так, чтобы эти надписи помещались целиком
   (minLeftPanelWidth() в main.ts). overflow здесь — страховка для динамических
   подписей (имена площадок, чертежей): текст обрежется многоточием внутри кнопки,
   а не вылезет за её границы. Кнопки внутри .controlRow сюда не попадают —
   они переносят текст по словам и меряются отдельно. */
.leftPanel .panelGroupBody > .wideButton {
  /* display: block вместо inline-flex — на флекс-контейнере text-overflow не действует.
     line-height заменяет центрирование флексом: 32px = min-height 34px минус рамки. */
  display: block;
  line-height: 32px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dangerGhost {
  color: #9f3b2c;
  background: #f2e7e1;
  border-color: #e3cabe;
}

.toggleRow {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #4d4942;
}

.toggleRow input[type="checkbox"] {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  margin: 0;
  cursor: pointer;
}

.hint {
  margin: 0;
  color: #6f6a60;
  font-size: 12px;
}

.tableHeader,
.vertexRow {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 28px;
  gap: 6px;
  align-items: center;
}

.tableHeader {
  color: #706b63;
  font-size: 11px;
  padding: 0 6px;
}

.selectedEdgeLine {
  border: 1px solid #e2c4a7;
  border-radius: 7px;
  background: #fff6ed;
  color: #7b461f;
  font-size: 12px;
  padding: 7px 9px;
}

.vertexRows {
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow: auto;
  padding-right: 2px;
}

.vertexRow {
  padding: 6px;
  border: 1px solid #e2dbcf;
  border-radius: 7px;
  background: #fffdf8;
}

.vertexRow.selected {
  border-color: #d96f32;
  box-shadow: 0 0 0 1px #d96f32 inset;
}

.vertexRow.edgeSelected {
  background: #fff6ed;
  border-color: #d96f32;
}

.vertexRow input,
.selectionPanel input {
  width: 100%;
  height: 30px;
  border: 1px solid #d5cdc0;
  border-radius: 5px;
  padding: 0 7px;
  background: white;
  color: #20211f;
}

.vertexRow button {
  width: 28px;
  height: 28px;
  border-radius: 5px;
  background: #f2e7e1;
  color: #9f3b2c;
  font-size: 18px;
  line-height: 1;
}

/* Заголовка «Библиотека» в панели больше нет — строка со статусом базы убрана,
   а вместе с ней и весь panelHeader на сайте. Здесь осталась только кнопка
   настроек, поэтому выравнивание по правому краю: при space-between единственный
   ребёнок прижался бы влево и ⚙️ уехал бы из-под панели на середину. */
.panelHeader {
  display: flex;
  justify-content: flex-end;
  align-items: center;
}

.headerActions {
  display: flex;
  gap: 4px;
}

.settingsWrapper {
  position: relative;
}

.dropdownMenu {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 4px;
  background: #fff;
  border: 1px solid #d9d3c8;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  display: flex;
  flex-direction: column;
  min-width: 300px;
  z-index: 100;
  overflow: hidden;
}

/* Меню настроек шире боковой панели (min-width 300px), а панель сужаемая и с
   overflow: auto — при узкой панели absolute-меню срезалось её краем. position: fixed
   выводит его из-под клиппинга; координаты считает positionFloatingMenu() при открытии. */
.dropdownMenu.floatingMenu {
  position: fixed;
  top: auto;
  right: auto;
  margin-top: 0;
  max-height: calc(100vh - 24px);
  overflow-y: auto;
}

.dropdownMenu[hidden] {
  display: none;
}

.dropdownMenu button {
  padding: 0 12px;
  min-height: 44px;
  text-align: left;
  background: transparent;
  font-size: 13px;
  border: 0;
  border-bottom: 1px solid #f0ede8;
  transition: background 0.2s;
  display: flex;
  align-items: center;
  width: 100%;
}

.dropdownMenu button:last-child {
  border-bottom: 0;
}

.dropdownMenu button:hover:not(:disabled) {
  background: #f4f2ed;
}

.dropdownMenu button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  color: #8b8578;
}

/* Меню «Файл»: уже, чем меню настроек базы, и с колонкой горячих клавиш справа. */
.dropdownMenu.menuList {
  min-width: 240px;
}

.dropdownMenu.menuList button {
  justify-content: space-between;
  gap: 24px;
  min-height: 38px;
}

.menuShortcut {
  color: #8d8981;
  font-size: 12px;
}

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

.category {
  border: 1px solid #d9d3c8;
  border-radius: 8px;
  background: #fbfaf7;
  overflow: hidden;
}

.categoryHeader {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 12px;
  background: #1f8062;
  border-bottom: 1px solid #18664e;
}

.categoryMain {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.toggleCollapseBtn {
  background: transparent;
  padding: 0;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: #cfe7dd;
  border-radius: 4px;
  transition: background 0.2s;
}

.toggleCollapseBtn:hover {
  background: rgba(255, 255, 255, 0.18);
}

.categoryTitle {
  font-weight: 600;
  color: #fffdf8;
  outline: none;
  cursor: text;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.categoryActions {
  display: flex;
  gap: 4px;
}

/* Фиксированная высота 20px — как у toggleCollapseBtn: без неё кнопки действий
   (эмодзи 🗑️ со своими вертикальными метриками) распирают шапку раздела, и её
   высота прыгает при включении/выключении режима редактирования. */
.categoryActions button {
  background: transparent;
  height: 20px;
  padding: 0 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  font-size: 14px;
  border-radius: 4px;
  transition: background 0.2s, transform 0.1s;
}

.categoryActions button:active:not(:disabled) {
  transform: scale(0.9);
}

/* Плюс на зелёной шапке раздела: текстовый символ вместо эмодзи ➕ (он рендерится
   фиолетовым и теряется на зелёном). Цвет — как у заголовка раздела. */
.categoryActions .addAssetBtn {
  color: #fffdf8;
  font-weight: 700;
  font-size: 15px;
}

.categoryActions .addAssetBtn:hover {
  background: rgba(255, 255, 255, 0.22);
}

.categoryActions .deleteCategoryBtn:hover {
  background: #9f3b2c;
}

.categoryItems {
  padding: 8px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px;
}

.categoryItems[hidden] {
  display: none;
}

/* ---------- Разделы левой панели (та же оболочка .category, что и в библиотеке) ---------- */

/* Без этого флекс-колонка сжимает разделы вместо прокрутки панели, а .category { overflow: hidden }
   срезает нижние кнопки, и до них не добраться. */
.leftPanel > .panelGroup {
  flex: 0 0 auto;
}

.panelGroupHeader .categoryTitle {
  cursor: default;
}

.panelGroupHeader:not(.static) {
  cursor: pointer;
  user-select: none;
}

.panelGroupHeader:not(.static):hover {
  background: #249170;
}

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

.panelGroup.collapsed .panelGroupBody {
  display: none;
}

.panelGroupBody > [hidden] {
  display: none;
}

.subGroup {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px;
  border: 1px solid #e2dbcf;
  border-radius: 6px;
  background: #fffdf8;
}

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

.subGroupStack[hidden] {
  display: none;
}

.subGroupHead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.subGroupTitle {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: #68655e;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.subGroupValue {
  font-size: 12px;
  font-weight: 600;
  color: #1f8062;
  white-space: nowrap;
}

.subGroup input[type="range"] {
  width: 100%;
  margin: 0;
  cursor: pointer;
}

.inlineField {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0;
  font-size: 12px;
  color: #4d4942;
}

.inlineField select {
  flex: 1;
  min-width: 0;
  max-width: 140px;
  height: 28px;
  padding: 0 6px;
  font-size: 12px;
  border: 1px solid #d5cdc0;
  border-radius: 5px;
  background: white;
  color: #20211f;
}

.colorPickRow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.colorPickRow label {
  margin: 0;
  font-size: 12px;
  color: #4d4942;
}

.colorPickRow input[type="color"] {
  width: 56px;
  height: 28px;
  flex-shrink: 0;
  padding: 0;
  border: 1px solid #d5cdc0;
  border-radius: 4px;
  cursor: pointer;
}

.subGroup.dimmed {
  opacity: 0.45;
}

.subGroup .colorGrid {
  margin-top: 0;
}

/* Кнопки во всех вкладках левой панели — бледно-зелёные.
   Исключения: опасные действия (.dangerGhost — красные), выключенные
   переключатели (.toggledOff — красноватые) и неактивные кнопки (глобальный
   button:disabled — бледно-оранжевый, поэтому в селекторе :not(:disabled)). */
.leftPanel button.wideButton:not(:disabled):not(.dangerGhost):not(.fixPoint):not(.unfixAction):not(.toggledOff) {
  background: #ddefdd;
  border-color: #b5d1bd;
  color: #1f8062;
}

.leftPanel button.wideButton:hover:not(:disabled):not(.dangerGhost):not(.fixPoint):not(.unfixAction):not(.toggledOff) {
  background: #cfe8d2;
  border-color: #a3c7ae;
}

/* Переключатели левой панели: включено — бледно-зелёная, выключено — красноватая
   (как у .dangerGhost), чтобы состояние кнопки было хорошо видно. */
.leftPanel button.wideButton.toggledOn {
  background: #ddefdd;
  border-color: #b5d1bd;
  color: #1f8062;
}

.leftPanel button.wideButton.toggledOn:hover:not(:disabled) {
  background: #cfe8d2;
  border-color: #a3c7ae;
}

.leftPanel button.wideButton.toggledOff:not(:disabled) {
  color: #9f3b2c;
  background: #f2e7e1;
  border-color: #e3cabe;
}

.leftPanel button.wideButton.toggledOff:hover:not(:disabled) {
  background: #ebd9d0;
  border-color: #d9b3a3;
}

/* Рамку даёт сам раздел — вложенная рамка панели выбора была бы двойной. */
.panelGroupBody > .selectionPanel {
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 0;
  gap: 8px;
}

.panelGroupBody > .selectionPanel.empty {
  border: 1px dashed #cfc6b7;
  border-radius: 6px;
  min-height: 56px;
  padding: 12px;
}

.viewpointList {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.viewpointItem {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  background: #fffdf8;
  border: 1px solid #e2dbcf;
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.2s;
}

.viewpointItem:hover {
  background: #fff6ed;
  border-color: #d96f32;
}

.viewpointName {
  font-weight: 500;
  color: #3b3934;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.variantList {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.variantItem {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  background: #fffdf8;
  border: 1px solid #e2dbcf;
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.2s;
}

.variantItem:hover {
  background: #fff6ed;
  border-color: #d96f32;
}

.variantItem.active {
  background: #f0f7f4;
  border-color: #1f8062;
  box-shadow: 0 0 0 1px #1f8062 inset;
}

.variantItem.variantOriginal {
  border-style: dashed;
}

.variantItem.variantOriginal .variantName {
  font-style: italic;
  color: #6b655c;
}

.variantItem.variantOriginal.active .variantName {
  color: #1f8062;
}

.variantName {
  font-weight: 500;
  color: #3b3934;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.deleteVariantBtn,
.renameVariantBtn,
.deleteViewpointBtn {
  background: transparent;
  color: #9f3b2c;
  font-size: 16px;
  padding: 4px;
  opacity: 0.6;
  transition: opacity 0.2s, transform 0.1s;
}

.renameVariantBtn {
  color: #1f8062;
  margin-right: 4px;
}

.deleteVariantBtn:hover,
.renameVariantBtn:hover,
.deleteViewpointBtn:hover {
  opacity: 1;
  transform: scale(1.1);
}

.assetItem {
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid #e9e4db;
  border-radius: 8px;
  cursor: grab;
  overflow: hidden;
  transition: transform 0.1s, box-shadow 0.2s;
}

.assetItem:hover {
  box-shadow: 0 4px 10px rgba(0,0,0,0.08);
}

.assetItem:active {
  cursor: grabbing;
}

/* Плавающая панель «Сохранить»/«Отмена» в режиме переименования оборудования. */
.renameActionBar {
  position: fixed;
  z-index: 120;
  display: flex;
  gap: 6px;
  padding: 6px;
  background: #fff;
  border: 1px solid #d9d3c8;
  border-radius: 8px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.16);
}

.renameActionBar button {
  border: 0;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.renameActionBar .renameSaveBtn {
  background: #1f8062;
  color: #fff;
}

.renameActionBar .renameSaveBtn:hover {
  background: #18664e;
}

.renameActionBar .renameCancelBtn {
  background: #f3f0ea;
  color: #4b4a45;
}

.renameActionBar .renameCancelBtn:hover {
  background: #e7e2d8;
}

.assetPreview {
  width: 100%;
  aspect-ratio: 1;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border-bottom: 1px solid #f0ede8;
  padding: 0;
  overflow: hidden;
}

.assetPreview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transform: scale(1.15);
  transition: transform 0.2s;
}

.assetItem:hover .assetPreview img {
  transform: scale(1.25);
}

.assetInfo {
  padding: 10px 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  text-align: center;
  min-width: 0;
}

/* Название по умолчанию — одна строка; переносы задаёт автор через Enter при
   переименовании (white-space: pre). Строка шире карточки обрезается многоточием. */
.assetInfo strong {
  font-size: 13px;
  font-weight: 700;
  color: #20211f;
  line-height: 1.2;
  min-height: 1.2em;
  white-space: pre;
  overflow: hidden;
  text-overflow: ellipsis;
}

.assetInfo small {
  font-size: 11px;
  color: #6f6a60;
  letter-spacing: 0.02em;
}

/* Asset Editor Overlay */
.editorCard {
  background: #fbfaf7;
  border-radius: 14px;
  border: 1px solid #d9d3c8;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.2);
  width: 95vw;
  height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalIn 0.2s ease-out;
}

.editorHeader {
  padding: 12px 20px;
  background: #fbfaf7;
  border-bottom: 1px solid #d9d3c8;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.editorHeader h3 {
  margin: 0;
  font-size: 16px;
  color: #20211f;
}

.editorActions {
  display: flex;
  gap: 10px;
}

.editorContent {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 300px;
  min-height: 0;
}

.editorViewport {
  position: relative;
  background: #f4f2ed;
  min-width: 0;
}

#editorCanvas {
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
}

/* Сайдбар редактора повторяет левую панель сцены: те же .category/.panelGroup*,
   поэтому здесь только оболочка — раскладку разделов задают общие правила выше. */
.editorSidebar {
  background: #f4f2ed;
  border-left: 1px solid #d9d3c8;
  padding: 12px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.editorSidebar > .panelGroup {
  flex: 0 0 auto;
}

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

.detailRow .hint {
  margin-left: auto;
  white-space: nowrap;
}

/* .selectionPanel strong задаёт 16px и display:block — в сайдбаре имя детали
   живёт в одной строке с кнопкой удаления, поэтому размер задаём в .partName. */
.editorSidebar .selectionPanel strong.partName {
  display: block;
  font-size: 13px;
}

/* Заголовок выбранной детали/текстуры: имя слева, действие справа. */
.editorSidebar .partHead {
  display: flex;
  align-items: center;
  gap: 8px;
}

.editorSidebar .partName {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  font-weight: 600;
  color: #20211f;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.editorSidebar .partHead .iconButton {
  flex-shrink: 0;
  width: 30px;
  min-height: 30px;
  font-size: 15px;
}

.iconButton.danger {
  color: #9f3b2c;
  background: #f2e7e1;
  border-color: #e3cabe;
}

.iconButton.danger:hover {
  background: #ecd9d1;
  border-color: #d8b4a6;
  color: #8a3225;
}

/* Кнопки текстуры — в один ряд; общий .controlRow укладывает их колонкой. */
.editorSidebar .controlRow {
  flex-direction: row;
}

.editorSidebar .controlRow > .wideButton {
  flex: 1 1 0;
}

.detailRow input {
  width: 58px;
  height: 30px;
  border: 1px solid #d5cdc0;
  border-radius: 8px;
  padding: 0 8px;
  text-align: center;
  background: white;
  color: #20211f;
  font-weight: 600;
}

.detailRow input:focus {
  outline: none;
  border-color: #1f8062;
  box-shadow: 0 0 0 2px rgb(31 128 98 / 0.15);
}

.detailRow input:disabled {
  background: #f0ece3;
  color: #9a958b;
}

.editorTooltip {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.6);
  color: white;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 13px;
  pointer-events: none;
}

#partColorInput {
  width: 100%;
  height: 40px;
  padding: 2px;
  border: 1px solid #d5cdc0;
  border-radius: 6px;
  cursor: pointer;
  margin-top: 8px;
}

.viewportShell {
  position: relative;
  min-width: 0;
  min-height: 0;
}

#sceneCanvas {
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
  cursor: default;
}

#sceneCanvas.drawMode {
  cursor: crosshair;
}

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

.edgeLabel {
  position: absolute;
  left: 0;
  top: 0;
  translate: -50% -50%;
  border: 1px solid #cfc6b7;
  border-radius: 999px;
  background: rgb(255 253 248 / 0.92);
  color: #3e3a34;
  font-size: 12px;
  padding: 2px 7px;
  box-shadow: 0 4px 14px rgb(43 38 31 / 0.08);
  white-space: nowrap;
  cursor: pointer;
  pointer-events: auto;
  user-select: none;
}

.edgeLabel.selected {
  border-color: #d96f32;
  background: #d96f32;
  color: white;
}

/* Поле правки длины/диаметра, открывающееся двойным кликом по метке. */
.edgeLabelEditor {
  position: absolute;
  left: 0;
  top: 0;
  translate: -50% -50%;
  width: 68px;
  border: 1px solid #d96f32;
  border-radius: 999px;
  background: rgb(255 253 248 / 0.97);
  color: #3e3a34;
  font-family: inherit;
  font-size: 12px;
  padding: 1px 7px;
  box-shadow: 0 4px 14px rgb(43 38 31 / 0.12);
  text-align: center;
  pointer-events: auto;
  outline: none;
}

.edgeLabelEditor::-webkit-outer-spin-button,
.edgeLabelEditor::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.edgeLabelEditor::-moz-range-spin {
  display: none;
}

.statusToast {
  position: fixed;
  left: 50%;
  top: 24px;
  translate: -50% 0;
  border-radius: 7px;
  background: #20211f;
  color: white;
  padding: 9px 14px;
  box-shadow: 0 14px 34px rgb(33 29 24 / 0.2);
  z-index: 10000;
}

.emptyList,
.selectionPanel.empty {
  min-height: 72px;
  border: 1px dashed #cfc6b7;
  border-radius: 7px;
  display: grid;
  place-items: center;
  color: #6f6a60;
  text-align: center;
  padding: 14px;
}

.selectionPanel {
  display: flex;
  flex-direction: column;
  gap: 8px;
  border: 1px solid #ddd5c8;
  border-radius: 7px;
  background: #fffdf8;
  padding: 12px;
}

.selectionPanel strong {
  display: block;
  font-size: 16px;
  color: #20211f;
  word-break: break-word;
  overflow-wrap: break-word;
  line-height: 1.3;
}

.selectionPanel label:not(.toggleRow) {
  display: grid;
  gap: 4px;
  color: #4d4942;
  font-size: 12px;
}

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

.fieldGroup label {
  font-size: 11px;
  font-weight: 600;
  color: #68655e;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.selectionPanel textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #d9d3c8;
  border-radius: 6px;
  background: #fff;
  font-size: 13px;
  color: #20211f;
  resize: vertical;
  min-height: 60px;
  outline: none;
  transition: border-color 0.2s;
}

.selectionPanel textarea:focus {
  border-color: #28775a;
}

.colorGrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
  gap: 6px;
  margin-top: 4px;
}

.colorSwatch {
  position: relative;
  aspect-ratio: 1;
  border-radius: 4px;
  border: 1px solid #d5cdc0;
  cursor: pointer;
  transition: transform 0.1s, border-color 0.1s;
}

/* Кнопка «+» в палитре — тот же размер и рамка, что у образцов цвета. */
.colorSwatch.addSwatch {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  line-height: 1;
  background: white;
  color: #68655e;
}

.colorSwatch.addSwatch:hover {
  border-color: #1f8062;
  color: #1f8062;
}

input.colorSwatch[type="color"] {
  background: white;
  padding: 2px;
  width: 100%;
  height: auto;
  min-width: 0;
  box-sizing: border-box;
}
input.colorSwatch[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
input.colorSwatch[type="color"]::-webkit-color-swatch { border: none; border-radius: 2px; }

.deleteColorBtn {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 18px;
  height: 18px;
  background: #9f3b2c;
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: bold;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s, transform 0.1s;
  z-index: 5;
  border: 1.5px solid white;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.colorSwatch:hover .deleteColorBtn,
.colorSwatch:hover .editColorBtn {
  opacity: 1;
}

.deleteColorBtn:hover {
  background: #bf3f2c;
  transform: scale(1.15);
}

.editColorBtn {
  position: absolute;
  top: -6px;
  left: -6px;
  width: 18px;
  height: 18px;
  background: #1f8062;
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s, transform 0.1s;
  z-index: 5;
  border: 1.5px solid white;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.editColorBtn:hover {
  background: #289673;
  transform: scale(1.15);
}

.colorSwatch.editing {
  border-color: #d96f32;
  box-shadow: 0 0 0 2px #d96f32;
  transform: scale(1.1);
  z-index: 2;
}

.globalColorEditor {
  margin-top: 16px;
  padding: 14px;
  background: #fff6ed;
  border: 1px solid #f9e2d0;
  border-radius: 10px;
  animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-5px); }
  to { opacity: 1; transform: translateY(0); }
}

.globalColorEditor h4 {
  margin: 0 0 10px 0;
  font-size: 12px;
  color: #7b461f;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.colorSwatch:hover {
  transform: scale(1.1);
  border-color: #6f6a60;
  z-index: 1;
}

.colorSwatch.active {
  border-color: #d96f32;
  box-shadow: 0 0 0 2px #d96f32;
  z-index: 2;
}

.modalBackdrop {
  position: fixed;
  inset: 0;
  background: rgba(43, 38, 31, 0.45);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modalBackdrop.confirmLayer {
  z-index: 1100;
}

.modalBackdrop[hidden] {
  display: none;
}

.loadingOverlay {
  position: fixed;
  inset: 0;
  background: #f4f2ed;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: opacity 0.5s ease, visibility 0.5s;
}

.loadingOverlay[hidden] {
  opacity: 0;
  visibility: hidden;
  display: none;
}

.loadingCard {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  width: 320px;
}

.brandMark.large {
  width: 80px;
  height: 80px;
  border-radius: 18px;
  margin-bottom: 10px;
  animation: pulse 2s infinite ease-in-out;
}

@keyframes pulse {
  0% { transform: scale(1); filter: brightness(1); }
  50% { transform: scale(1.05); filter: brightness(1.1); }
  100% { transform: scale(1); filter: brightness(1); }
}

.loadingCard h2 {
  margin: 0;
  font-size: 20px;
  color: #3b3934;
}

.progressContainer {
  width: 100%;
  height: 8px;
  background: #e9e4db;
  border-radius: 10px;
  overflow: hidden;
}

.progressBar {
  height: 100%;
  background: linear-gradient(90deg, #d96f32, #1f8062);
  transition: width 0.3s ease;
}

.loadingCard small {
  color: #68655e;
  font-size: 13px;
}

.modalCard {
  background: #fbfaf7;
  padding: 28px;
  border-radius: 14px;
  border: 1px solid #d9d3c8;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.2);
  max-width: 480px;
  width: 90vw;
  animation: modalIn 0.2s ease-out;
  display: flex;
  flex-direction: column;
}

@keyframes modalIn {
  from { transform: translateY(10px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.modalCard h3 {
  margin: 0 0 12px 0;
  font-size: 18px;
  color: #20211f;
}

.modalCard p {
  margin: 0 0 24px 0;
  color: #6f6a60;
  line-height: 1.5;
  word-break: normal;
}

.modalActions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
}

.modalActions button {
  white-space: nowrap;
}

@media (max-width: 1150px) {
  .planner {
    grid-template-columns: 280px minmax(0, 1fr) 280px;
  }
}

@media (max-width: 900px) {
  body {
    overflow: auto;
  }

  .planner {
    grid-template-columns: minmax(250px, 0.9fr) minmax(360px, 1.1fr);
    grid-template-rows: auto var(--tab-bar-height, 38px) minmax(420px, 1fr) auto;
    width: 100vw;
    min-height: 100vh;
    height: auto;
  }

  .topbar {
    align-items: flex-start;
    overflow-x: auto;
  }

  .toolbar {
    flex-wrap: nowrap;
  }

  .variantTabBar {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .leftPanel {
    grid-column: 1;
    grid-row: 3;
    max-height: none;
  }

  .viewportShell {
    grid-column: 2;
    grid-row: 3;
    min-height: 420px;
  }

  .rightPanel {
    grid-column: 1 / -1;
    grid-row: 4;
    display: grid;
    grid-template-columns: 1fr 1fr;
    border-left: 0;
    border-top: 1px solid #d9d3c8;
  }
}

@media (max-width: 700px) {
  .planner {
    grid-template-columns: 1fr;
    grid-template-rows: auto var(--tab-bar-height, 38px) 340px auto auto;
  }

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

  .toolbar {
    max-width: 100%;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .variantTabBar {
    grid-column: 1;
    grid-row: 2;
  }

  .viewportShell {
    grid-column: 1;
    grid-row: 3;
    min-height: 340px;
  }

  .leftPanel {
    grid-column: 1;
    grid-row: 4;
    border-right: 0;
    border-top: 1px solid #d9d3c8;
  }

  .rightPanel {
    grid-column: 1;
    grid-row: 5;
    grid-template-columns: 1fr;
  }
}

/* ---------- RAL picker ---------- */

/* <input type="color"> с отключённой нативной палитрой: остаётся только образцом текущего
   цвета, выбор идёт через каталог RAL. Клик по образцу тоже открывает каталог. */
input[type="color"].colorDisplay {
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  padding: 2px;
}

input[type="color"].colorDisplay::-webkit-color-swatch-wrapper { padding: 0; }
input[type="color"].colorDisplay::-webkit-color-swatch {
  border: none;
  border-radius: 2px;
}

.ralOverlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 20, 18, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 24px;
}

.ralModal {
  width: min(880px, 100%);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  background: #fbfaf7;
  border: 1px solid #d5cdc0;
  border-radius: 10px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.28);
  overflow: hidden;
}

.ralHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid #ddd5c8;
  background: #fff;
}

.ralTitle {
  font-size: 14px;
  font-weight: 700;
  color: #4d4942;
}

.ralClose {
  width: 28px;
  height: 28px;
  font-size: 16px;
  line-height: 1;
  color: #68655e;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
}

.ralClose:hover {
  background: #f4f2ed;
  border-color: #d5cdc0;
  color: #d96f32;
}

.ralSearchRow {
  padding: 10px 16px 0;
}

.ralSearch {
  width: 100%;
  height: 32px;
  padding: 0 10px;
  font-size: 13px;
  color: #20211f;
  background: #fff;
  border: 1px solid #d5cdc0;
  border-radius: 6px;
  outline: none;
}

.ralSearch:focus {
  border-color: #d96f32;
  box-shadow: 0 0 0 2px rgba(217, 111, 50, 0.18);
}

.ralNearestNote {
  padding: 8px 16px 0;
  font-size: 12px;
  color: #68655e;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
}

.ralSwatchInline {
  display: inline-block;
  width: 14px;
  height: 14px;
  margin: 0 2px;
  border: 1px solid #d5cdc0;
  border-radius: 3px;
  vertical-align: -3px;
}

.ralGrid {
  padding: 12px 16px 16px;
  overflow: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 8px;
}

.ralCell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 64px;
  padding: 0;
  border: 1px solid rgba(0, 0, 0, 0.18);
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.05s, box-shadow 0.12s, outline-color 0.12s;
  outline: 2px solid transparent;
  outline-offset: -2px;
}

.ralCell:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  outline-color: #d96f32;
  z-index: 2;
}

.ralCell:active {
  transform: scale(0.97);
}

.ralCell.isNearest {
  outline-color: #1f8062;
  box-shadow: 0 0 0 2px #1f8062, 0 4px 10px rgba(31, 128, 98, 0.35);
  z-index: 1;
}

.ralCellCode {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.4px;
  text-align: center;
  pointer-events: none;
}

.ralCell.onLight .ralCellCode {
  color: #1a1a1a;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.6);
}

.ralCell.onDark .ralCellCode {
  color: #ffffff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.55);
}

.ralEmpty {
  grid-column: 1 / -1;
  padding: 24px;
  font-size: 13px;
  color: #68655e;
  text-align: center;
}

