@import url("https://fonts.googleapis.com/css2?family=Orbitron:wght@400;500;600;700&family=Exo+2:wght@300;400;500;600&display=swap");

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  background:
    radial-gradient(circle at 15% 8%, rgba(95, 243, 255, 0.08), transparent 30%),
    linear-gradient(135deg, #061821 0%, #02070d 62%, #010409 100%);
  color: rgba(210, 248, 255, 0.92);
  font-family: "Exo 2", "Segoe UI", Arial, sans-serif;
}

#hmi-root {
  width: 100vw;
  height: 100svh;
  padding: clamp(0.12rem, 0.28vw, 0.34rem);
  overflow: hidden;
}

.hmi-screen {
  --hmi-gap: clamp(0.18rem, 0.42vw, 0.48rem);
  --hmi-header: clamp(0.78rem, 1.8vh, 1.05rem);
  --hmi-fkey-height: clamp(2rem, 5vh, 3rem);

  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;

  display: grid;
  grid-template-rows: minmax(0, 1fr) var(--hmi-fkey-height);
  gap: var(--hmi-gap);

  border: 1px solid rgba(95, 243, 255, 0.22);
  background:
    linear-gradient(rgba(95, 243, 255, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(95, 243, 255, 0.04) 1px, transparent 1px),
    rgba(2, 14, 20, 0.34);
  background-size: 1.8rem 1.8rem;
  overflow: hidden;
}

.hmi-main {
  min-width: 0;
  min-height: 0;

  display: grid;
  grid-template-columns: repeat(var(--hmi-columns), minmax(0, 1fr));
  grid-template-rows: minmax(0, 1.35fr) minmax(0, 1fr);
  gap: var(--hmi-gap);

  padding: var(--hmi-gap);
  overflow: hidden;
}

.hmi-panel {
  min-width: 0;
  min-height: 0;

  display: grid;
  grid-template-rows: var(--hmi-header) minmax(0, 1fr);

  border: 1px solid rgba(95, 243, 255, 0.25);
  background:
    radial-gradient(circle at 8% 0%, rgba(95, 243, 255, 0.05), transparent 36%),
    rgba(3, 20, 28, 0.26);

  overflow: hidden;
}

.hmi-panel-title {
  display: flex;
  align-items: center;
  min-width: 0;
  padding: 0 clamp(0.22rem, 0.5vw, 0.55rem);

  border-bottom: 1px solid rgba(95, 243, 255, 0.12);
  background: linear-gradient(90deg, rgba(70, 124, 255, 0.34), rgba(70, 124, 255, 0.1), transparent);

  color: rgba(150, 188, 255, 0.95);
  font-size: clamp(0.42rem, 0.34rem + 0.24vw, 0.68rem);
  font-weight: 600;
  line-height: 1;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hmi-panel-body {
  min-width: 0;
  min-height: 0;
  padding: clamp(0.18rem, 0.38vw, 0.42rem);
  overflow: hidden;
}

.hmi-cell-grid {
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;

  display: grid;
  grid-template-rows: repeat(var(--panel-rows), minmax(0, 1fr));
  gap: clamp(0.16rem, 0.36vw, 0.42rem);

  overflow: hidden;
}

.hmi-cell-grid.cols-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(var(--panel-rows), minmax(0, 1fr));
}

.hmi-cell {
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.hmi-empty {
  width: 100%;
  height: 100%;
  border: 1px solid rgba(95, 243, 255, 0.045);
  background: rgba(0, 0, 0, 0.07);
}

.hmi-button,
.hmi-value,
.hmi-input,
.hmi-label {
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;

  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  font: inherit;
}

.hmi-button-inner,
.hmi-value-inner,
.hmi-input-inner,
.hmi-label {
  position: relative;
  width: 100%;
  height: 100%;

  display: grid;
  place-items: center;

  border: 1px solid rgba(95, 243, 255, 0.26);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.03), transparent 24%),
    radial-gradient(circle at 18% 0%, rgba(95, 243, 255, 0.09), transparent 46%),
    rgba(4, 26, 36, 0.22);

  box-shadow:
    inset 0 0 0 1px rgba(255,255,255,0.018),
    inset 0 0 0.9rem rgba(95, 243, 255, 0.035);

  overflow: hidden;
}

.hmi-button-inner::before,
.hmi-value-inner::before,
.hmi-input-inner::before,
.hmi-label::before {
  content: "";
  position: absolute;
  inset: clamp(0.04rem, 0.1vw, 0.09rem);
  border: 1px solid rgba(150, 245, 255, 0.07);
  pointer-events: none;
}

.hmi-label-text {
  position: relative;
  z-index: 2;
  min-width: 0;
  color: var(--hmi-item-button-color, var(--hmi-panel-button-color, rgba(135, 232, 255, 0.86)));
  font-family: var(--hmi-item-button-font-family, var(--hmi-panel-button-font-family, "Orbitron", "Cascadia Mono", monospace));
  font-size: var(--hmi-item-button-font, var(--hmi-panel-button-font));
  font-weight: var(--hmi-item-button-font-weight, var(--hmi-panel-button-font-weight, 500));
  line-height: 1.05;
  text-align: center;
  text-transform: uppercase;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hmi-button {
  cursor: pointer;
}

.hmi-button:hover .hmi-button-inner {
  border-color: rgba(150, 245, 255, 0.36);
  box-shadow:
    inset 0 0 1rem rgba(95, 243, 255, 0.07),
    0 0 0.6rem rgba(95, 243, 255, 0.08);
}

.hmi-button:active .hmi-button-inner {
  transform: translateY(1px) scale(0.992);
}

.hmi-button-label {
  position: relative;
  z-index: 2;
  color: rgba(135, 232, 255, 0.86);
  font-family: "Orbitron", "Cascadia Mono", monospace;
  font-size: var(--cell-font, clamp(0.54rem, 0.38rem + 0.42vw, 0.9rem));
  font-weight: 500;
  line-height: 1.05;
  letter-spacing: 0.08em;
  text-align: center;
  text-transform: uppercase;
  text-shadow:
    0 0 0.22rem rgba(95, 243, 255, 0.24),
    0 0 0.8rem rgba(95, 243, 255, 0.12);
}

.hmi-button.axis {
  --cell-font: clamp(0.95rem, 0.68rem + 0.82vw, 1.65rem);
}

.hmi-button.danger .hmi-button-inner {
  border-color: rgba(255, 49, 94, 0.34);
  background:
    radial-gradient(circle at 18% 0%, rgba(255, 49, 94, 0.09), transparent 46%),
    rgba(42, 8, 18, 0.24);
}

.hmi-button.danger .hmi-button-label {
  color: rgba(255, 145, 175, 0.88);
  text-shadow: 0 0 0.75rem rgba(255, 49, 94, 0.18);
}

.hmi-button.success .hmi-button-inner {
  border-color: rgba(53, 255, 139, 0.28);
}

.hmi-button.success .hmi-button-label {
  color: rgba(130, 255, 190, 0.86);
}

.hmi-button.active .hmi-button-inner {
  border-color: rgba(175, 252, 255, 0.92);
  background:
    linear-gradient(180deg, rgba(230, 255, 255, 0.82), rgba(110, 232, 238, 0.62)),
    rgba(66, 222, 230, 0.44);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.38),
    0 0 1.2rem rgba(93, 243, 255, 0.34);
}

.hmi-button.active .hmi-button-label {
  color: rgba(1, 22, 28, 0.98);
  text-shadow: none;
}

.hmi-value-inner {
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: clamp(0.1rem, 0.25vw, 0.28rem);
  padding: clamp(0.06rem, 0.16vw, 0.18rem) clamp(0.14rem, 0.32vw, 0.34rem);
}

.hmi-value-axis {
  min-width: clamp(0.95rem, 1.6vw, 1.5rem);
  color: rgba(145, 238, 255, 0.8);
  font-family: "Orbitron", monospace;
  font-size: clamp(0.44rem, 0.32rem + 0.32vw, 0.72rem);
  font-weight: 500;
}

.hmi-value-text {
  min-width: 0;
  color: rgba(125, 230, 255, 0.86);
  font-family: "Orbitron", monospace;
  font-size: clamp(0.82rem, 0.58rem + 0.82vw, 1.55rem);
  font-weight: 400;
  letter-spacing: 0.02em;
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-variant-numeric: tabular-nums;
  text-shadow:
    0 0 0.25rem rgba(95, 243, 255, 0.22),
    0 0 0.9rem rgba(95, 243, 255, 0.12);
}

.hmi-value-unit {
  color: rgba(185, 225, 235, 0.48);
  font-size: clamp(0.28rem, 0.22rem + 0.16vw, 0.48rem);
  white-space: nowrap;
}

.hmi-input-inner {
  grid-template-rows: auto minmax(0, 1fr);
  padding: clamp(0.05rem, 0.14vw, 0.16rem);
}

.hmi-input-title {
  color: rgba(170, 230, 240, 0.58);
  font-size: clamp(0.32rem, 0.25rem + 0.18vw, 0.5rem);
  line-height: 1;
  text-align: center;
}

.hmi-input-value {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: none;
  background: transparent;
  color: rgba(125, 230, 255, 0.88);
  font-family: "Orbitron", monospace;
  font-size: clamp(0.62rem, 0.44rem + 0.54vw, 1.05rem);
  text-align: center;
}

.hmi-bottom-panel {
  grid-column: span var(--span, 1);
}

.hmi-main > .hmi-panel:not(.hmi-bottom-panel) {
  grid-column: span var(--span, 1);
}

.hmi-fkeys {
  min-width: 0;
  min-height: 0;

  display: grid;
  grid-template-columns: repeat(14, minmax(0, 1fr));
  gap: var(--hmi-gap);

  padding: 0 var(--hmi-gap) var(--hmi-gap);
  overflow: hidden;
}

.hmi-fkey-title {
  grid-column: span 2;
  display: grid;
  place-items: center;

  border: 1px solid rgba(95, 243, 255, 0.25);
  background: rgba(3, 20, 28, 0.26);

  color: rgba(210, 248, 255, 0.85);
  font-size: clamp(0.42rem, 0.32rem + 0.22vw, 0.62rem);
  line-height: 1;
  text-transform: uppercase;
  text-align: center;
}

.hmi-fkeys .hmi-button {
  --cell-font: clamp(0.36rem, 0.28rem + 0.2vw, 0.56rem);
}

@media (max-height: 760px) {
  .hmi-screen {
    --hmi-fkey-height: clamp(1.75rem, 4.4vh, 2.45rem);
    --hmi-header: clamp(0.64rem, 1.55vh, 0.86rem);
  }

  .hmi-panel-body {
    padding: clamp(0.12rem, 0.28vw, 0.3rem);
  }

  .hmi-cell-grid {
    gap: clamp(0.12rem, 0.28vw, 0.3rem);
  }

  .hmi-button.axis {
    --cell-font: clamp(0.72rem, 0.52rem + 0.58vw, 1.15rem);
  }

  .hmi-value-text {
    font-size: clamp(0.68rem, 0.5rem + 0.62vw, 1.18rem);
  }
}


/* STEP_02_BOTTOM_GRID_FIX */

.bottom-grid {
  grid-column: 1 / -1;

  min-width: 0;
  min-height: 0;

  display: grid;
  grid-template-columns: repeat(var(--hmi-columns), minmax(0, 1fr));
  grid-template-rows: minmax(0, 1fr);
  gap: var(--hmi-gap);

  overflow: hidden;
}

.bottom-grid .hmi-panel {
  min-width: 0;
  min-height: 0;
}

.hmi-bottom-panel {
  grid-column: span var(--span, 1);
}

/*
  Нижний рабочий блок:
  1 колонка скорость,
  1 колонка шаг,
  2 колонки движение,
  1 колонка референция,
  2 колонки инструмент.
*/
.bottom-grid .hmi-panel-body {
  padding: clamp(0.16rem, 0.34vw, 0.38rem);
}

.bottom-grid .hmi-cell-grid {
  gap: clamp(0.14rem, 0.32vw, 0.36rem);
}

.bottom-grid .hmi-button-label {
  font-size: clamp(0.46rem, 0.34rem + 0.32vw, 0.76rem);
}

.bottom-grid .hmi-value-text,
.bottom-grid .hmi-input-value {
  font-size: clamp(0.58rem, 0.42rem + 0.46vw, 0.98rem);
}

.bottom-grid .hmi-input-title {
  font-size: clamp(0.3rem, 0.24rem + 0.16vw, 0.48rem);
}

/*
  В двухколоночных панелях нижнего ряда элементы должны сидеть
  в одинаковой клеточной сетке, а не расползаться.
*/
.bottom-grid .cols-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (max-height: 760px) {
  .bottom-grid .hmi-panel-body {
    padding: clamp(0.1rem, 0.25vw, 0.28rem);
  }

  .bottom-grid .hmi-cell-grid {
    gap: clamp(0.1rem, 0.24vw, 0.28rem);
  }

  .bottom-grid .hmi-button-label {
    font-size: clamp(0.38rem, 0.28rem + 0.26vw, 0.62rem);
  }

  .bottom-grid .hmi-value-text,
  .bottom-grid .hmi-input-value {
    font-size: clamp(0.48rem, 0.36rem + 0.38vw, 0.82rem);
  }
}


/* STEP_05_STYLE_CONFIG_VARS */

.hmi-main {
  grid-template-rows:
    minmax(0, var(--hmi-top-share, 1.35fr))
    minmax(0, var(--hmi-bottom-share, 1fr));
}

.hmi-panel {
  grid-template-rows:
    var(--hmi-header, clamp(0.78rem, 1.8vh, 1.05rem))
    minmax(0, 1fr);
}

/* Верхние панели */
.hmi-main > .hmi-panel:not(.hmi-bottom-panel) .hmi-panel-body {
  padding: var(--hmi-top-panel-padding, clamp(0.18rem, 0.38vw, 0.42rem));
}

.hmi-main > .hmi-panel:not(.hmi-bottom-panel) .hmi-cell-grid {
  gap: var(--hmi-top-cell-gap, clamp(0.16rem, 0.36vw, 0.42rem));
}

.hmi-main > .hmi-panel:not(.hmi-bottom-panel) .hmi-button-label {
  font-size: var(--hmi-top-button-font, clamp(0.54rem, 0.38rem + 0.42vw, 0.9rem));
}

.hmi-main > .hmi-panel:not(.hmi-bottom-panel) .hmi-button.axis {
  --cell-font: var(--hmi-axis-font, clamp(0.95rem, 0.68rem + 0.82vw, 1.65rem));
}

.hmi-main > .hmi-panel:not(.hmi-bottom-panel) .hmi-value-text {
  font-size: var(--hmi-top-value-font, clamp(0.82rem, 0.58rem + 0.82vw, 1.55rem));
}

.hmi-main > .hmi-panel:not(.hmi-bottom-panel) .hmi-value-axis {
  font-size: var(--hmi-top-value-axis-font, clamp(0.44rem, 0.32rem + 0.32vw, 0.72rem));
}

/* Средняя рабочая зона */
.bottom-grid .hmi-panel-body {
  padding: var(--hmi-bottom-panel-padding, clamp(0.16rem, 0.34vw, 0.38rem));
}

.bottom-grid .hmi-cell-grid {
  gap: var(--hmi-bottom-cell-gap, clamp(0.14rem, 0.32vw, 0.36rem));
}

.bottom-grid .hmi-button-label {
  font-size: var(--hmi-bottom-button-font, clamp(0.46rem, 0.34rem + 0.32vw, 0.76rem));
}

.bottom-grid .hmi-input-value,
.bottom-grid .hmi-value-text {
  font-size: var(--hmi-bottom-input-font, clamp(0.58rem, 0.42rem + 0.46vw, 0.98rem));
}

.bottom-grid .hmi-input-title {
  font-size: var(--hmi-bottom-input-title-font, clamp(0.3rem, 0.24rem + 0.16vw, 0.48rem));
}

/* F-клавиши */
.hmi-fkeys .hmi-button {
  --cell-font: var(--hmi-fkey-font, clamp(0.36rem, 0.28rem + 0.2vw, 0.56rem));
}

.hmi-fkey-title {
  font-size: var(--hmi-fkey-title-font, clamp(0.42rem, 0.32rem + 0.22vw, 0.62rem));
}


/* STEP_06_INPUT_BUTTON */

.hmi-input-inner {
  grid-template-rows: auto minmax(0, 1fr);
  gap: clamp(0.04rem, 0.1vw, 0.08rem);
  padding: clamp(0.04rem, 0.12vw, 0.12rem);
}

.hmi-input-title {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  color: rgba(180, 225, 235, 0.7);
  text-align: center;
  line-height: 1;
}

.hmi-input-plate {
  width: 100%;
  height: 100%;
  min-height: 0;
  display: grid;
  place-items: center;

  border: 1px solid rgba(165, 245, 255, 0.18);
  background:
    linear-gradient(180deg, rgba(180, 235, 255, 0.22), rgba(120, 200, 230, 0.16)),
    rgba(130, 185, 205, 0.16);

  box-shadow:
    inset 0 0 0 1px rgba(255,255,255,0.03),
    inset 0 0 0.8rem rgba(180, 230, 255, 0.06);
}

.hmi-input-value {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: none;
  background: transparent;
  color: rgba(215, 245, 255, 0.96);
  font-family: "Orbitron", monospace;
  text-align: center;
  font-variant-numeric: tabular-nums;
  text-shadow:
    0 0 0.22rem rgba(210, 245, 255, 0.18),
    0 0 0.7rem rgba(120, 200, 230, 0.1);
}

.bottom-grid .hmi-input-plate {
  min-height: clamp(1.2rem, 2.6vh, 1.9rem);
}


/* STEP_07_TOP_INPUT_BUTTONS */

.hmi-main > .hmi-panel:not(.hmi-bottom-panel) .hmi-input-title {
  font-size: clamp(0.34rem, 0.26rem + 0.2vw, 0.54rem);
  color: rgba(220, 245, 255, 0.72);
}

.hmi-main > .hmi-panel:not(.hmi-bottom-panel) .hmi-input-value {
  font-size: clamp(0.76rem, 0.54rem + 0.64vw, 1.28rem);
}

.hmi-main > .hmi-panel:not(.hmi-bottom-panel) .hmi-input-plate {
  min-height: clamp(1.1rem, 2.4vh, 1.75rem);
}


/* STEP_08_GENERIC_PANEL_COLS_AND_MOTION */

.hmi-cell-grid.has-cols {
  grid-template-columns: repeat(var(--panel-cols, 2), minmax(0, 1fr)) !important;
  grid-template-rows: repeat(var(--panel-rows), minmax(0, 1fr)) !important;
}

/*
  Теперь нижняя схема:
  Скорость 1 + Шаг 1 + Движение 3 + Инструмент 2 = 7 колонок.
*/
.bottom-grid .hmi-bottom-panel {
  grid-column: span var(--span, 1);
}

/*
  В 3-колоночной панели "Движение" текст чуть уплотняем,
  чтобы влезали подписи вроде >>> С учетом %.
*/
.bottom-grid .hmi-cell-grid.has-cols .hmi-input-title {
  font-size: clamp(0.28rem, 0.22rem + 0.16vw, 0.46rem);
}

.bottom-grid .hmi-cell-grid.has-cols .hmi-button-label {
  font-size: clamp(0.54rem, 0.4rem + 0.38vw, 0.86rem);
}

.bottom-grid .hmi-cell-grid.has-cols .hmi-input-value {
  font-size: clamp(0.58rem, 0.42rem + 0.44vw, 0.95rem);
}


/* STEP_09_BUILDER_MODE */

.hmi-builder-mode .hmi-cell {
  cursor: crosshair;
}

.hmi-builder-mode .hmi-cell:hover {
  outline: 2px solid rgba(255, 220, 120, 0.9);
  outline-offset: -2px;
}

.hmi-builder-modal[hidden] {
  display: none;
}

.hmi-builder-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  background: rgba(0, 8, 14, 0.72);
  backdrop-filter: blur(0.4rem);
}

.hmi-builder-window {
  width: min(54rem, 94vw);
  max-height: 92vh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  border: 1px solid rgba(140, 235, 255, 0.28);
  background:
    linear-gradient(180deg, rgba(20, 42, 54, 0.96), rgba(6, 16, 24, 0.98));
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.04) inset,
    0 1rem 4rem rgba(0,0,0,0.5),
    0 0 2rem rgba(80, 200, 255, 0.12);
  color: rgba(230, 250, 255, 0.94);
  font-family: system-ui, sans-serif;
}

.hmi-builder-head,
.hmi-builder-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.8rem 1rem;
  border-bottom: 1px solid rgba(140, 235, 255, 0.14);
}

.hmi-builder-foot {
  border-top: 1px solid rgba(140, 235, 255, 0.14);
  border-bottom: 0;
  justify-content: flex-end;
}

.hmi-builder-title {
  font-size: 1rem;
  font-weight: 700;
}

.hmi-builder-subtitle {
  margin-top: 0.18rem;
  font-size: 0.72rem;
  opacity: 0.68;
}

.hmi-builder-close,
.hmi-builder-apply,
.hmi-builder-copy {
  border: 1px solid rgba(140, 235, 255, 0.24);
  background: rgba(80, 160, 190, 0.18);
  color: rgba(235, 250, 255, 0.96);
  padding: 0.45rem 0.8rem;
  cursor: pointer;
}

.hmi-builder-close {
  width: 2.2rem;
  height: 2.2rem;
  padding: 0;
  font-size: 1.4rem;
}

.hmi-builder-body {
  min-height: 0;
  overflow: auto;
  padding: 1rem;
  display: grid;
  gap: 1rem;
}

.hmi-builder-section {
  border: 1px solid rgba(140, 235, 255, 0.13);
  background: rgba(0, 20, 30, 0.28);
  padding: 0.75rem;
}

.hmi-builder-section-title {
  margin-bottom: 0.65rem;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(170, 235, 255, 0.78);
}

.hmi-builder-field {
  display: grid;
  grid-template-columns: 12rem minmax(0, 1fr);
  gap: 0.7rem;
  align-items: center;
  margin-bottom: 0.5rem;
  font-size: 0.82rem;
}

.hmi-builder-field input,
.hmi-builder-json {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid rgba(140, 235, 255, 0.18);
  background: rgba(0, 10, 16, 0.7);
  color: rgba(235, 250, 255, 0.96);
  padding: 0.45rem 0.55rem;
  outline: none;
}

.hmi-builder-json {
  min-height: 10rem;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.78rem;
  line-height: 1.4;
}


/* STEP_10_BUILDER_SAVE_STATUS */

.hmi-builder-save-status {
  margin-right: auto;
  min-width: 12rem;
  font-size: 0.78rem;
  color: rgba(210, 235, 245, 0.72);
}

.hmi-builder-save-status[data-status-mode="ok"] {
  color: rgba(130, 255, 190, 0.95);
}

.hmi-builder-save-status[data-status-mode="error"] {
  color: rgba(255, 120, 120, 0.95);
}

.hmi-builder-save-status[data-status-mode="pending"] {
  color: rgba(255, 220, 130, 0.95);
}


/* STEP_11_FULL_BUILDER */

.hmi-builder-toolbar {
  position: fixed;
  left: 0.7rem;
  top: 0.7rem;
  z-index: 9998;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem;
  border: 1px solid rgba(140, 235, 255, 0.24);
  background: rgba(0, 12, 20, 0.86);
  backdrop-filter: blur(0.35rem);
  box-shadow: 0 0 1.2rem rgba(0,0,0,0.35);
}

.hmi-builder-toolbar button,
.hmi-builder-foot button {
  border: 1px solid rgba(140, 235, 255, 0.24);
  background: rgba(80, 160, 190, 0.18);
  color: rgba(235, 250, 255, 0.96);
  padding: 0.42rem 0.65rem;
  cursor: pointer;
  font-size: 0.78rem;
}

.hmi-builder-toolbar button:hover,
.hmi-builder-foot button:hover {
  background: rgba(120, 210, 240, 0.26);
}

.hmi-builder-toolbar-status {
  min-width: 13rem;
  font-size: 0.76rem;
  color: rgba(210, 235, 245, 0.72);
}

.hmi-builder-toolbar-status[data-status-mode="ok"],
.hmi-builder-save-status[data-status-mode="ok"] {
  color: rgba(130, 255, 190, 0.95);
}

.hmi-builder-toolbar-status[data-status-mode="error"],
.hmi-builder-save-status[data-status-mode="error"] {
  color: rgba(255, 120, 120, 0.95);
}

.hmi-builder-toolbar-status[data-status-mode="pending"],
.hmi-builder-save-status[data-status-mode="pending"] {
  color: rgba(255, 220, 130, 0.95);
}

.hmi-builder-mode .hmi-panel-title {
  cursor: pointer;
}

.hmi-builder-mode .hmi-panel-title:hover {
  outline: 2px solid rgba(255, 220, 120, 0.9);
  outline-offset: -2px;
}

.hmi-cell {
  --hmi-item-button-font-local: var(--hmi-item-button-font);
  --hmi-item-input-font-local: var(--hmi-item-input-font);
  --hmi-item-value-font-local: var(--hmi-item-value-font);
  --hmi-item-input-title-font-local: var(--hmi-item-input-title-font);
}

.hmi-cell .hmi-button-label {
  font-size: var(--hmi-item-button-font-local, inherit);
}

.hmi-cell .hmi-input-value {
  font-size: var(--hmi-item-input-font-local, inherit);
}

.hmi-cell .hmi-value-text {
  font-size: var(--hmi-item-value-font-local, inherit);
}

.hmi-cell .hmi-input-title {
  font-size: var(--hmi-item-input-title-font-local, inherit);
}

.hmi-panel {
  --hmi-panel-title-font-local: var(--hmi-panel-title-font);
  --hmi-panel-button-font-local: var(--hmi-panel-button-font);
  --hmi-panel-input-font-local: var(--hmi-panel-input-font);
  --hmi-panel-value-font-local: var(--hmi-panel-value-font);
  --hmi-panel-input-title-font-local: var(--hmi-panel-input-title-font);
}

.hmi-panel .hmi-panel-title {
  font-size: var(--hmi-panel-title-font-local, inherit);
}

.hmi-panel .hmi-button-label {
  font-size: var(--hmi-item-button-font-local, var(--hmi-panel-button-font-local, inherit));
}

.hmi-panel .hmi-input-value {
  font-size: var(--hmi-item-input-font-local, var(--hmi-panel-input-font-local, inherit));
}

.hmi-panel .hmi-value-text {
  font-size: var(--hmi-item-value-font-local, var(--hmi-panel-value-font-local, inherit));
}

.hmi-panel .hmi-input-title {
  font-size: var(--hmi-item-input-title-font-local, var(--hmi-panel-input-title-font-local, inherit));
}


/* STEP_12_STYLE_DEFAULTS_FIX */

/*
  Верхние панели получают базовые panel-level переменные из общего style-config.
  Если в конструкторе не задан индивидуальный стиль, всё наследуется отсюда.
*/
.hmi-main > .hmi-panel:not(.hmi-bottom-panel) {
  --hmi-panel-button-font: var(--hmi-top-button-font);
  --hmi-panel-value-font: var(--hmi-top-value-font);
  --hmi-panel-input-font: var(--hmi-top-value-font);
  --hmi-panel-input-title-font: var(--hmi-top-value-axis-font);
}

/*
  Нижние панели получают базовые panel-level переменные из общего style-config.
*/
.bottom-grid .hmi-panel {
  --hmi-panel-button-font: var(--hmi-bottom-button-font);
  --hmi-panel-value-font: var(--hmi-bottom-input-font);
  --hmi-panel-input-font: var(--hmi-bottom-input-font);
  --hmi-panel-input-title-font: var(--hmi-bottom-input-title-font);
}

/*
  Важное исправление:
  не используем промежуточные переменные вида var(--missing),
  потому что они могут ломать computed font-size.
*/
.hmi-panel .hmi-cell .hmi-button-label {
  font-size: var(--hmi-item-button-font, var(--hmi-panel-button-font));
}

.hmi-panel .hmi-cell .hmi-input-value {
  font-size: var(--hmi-item-input-font, var(--hmi-panel-input-font));
}

.hmi-panel .hmi-cell .hmi-value-text {
  font-size: var(--hmi-item-value-font, var(--hmi-panel-value-font));
}

.hmi-panel .hmi-cell .hmi-input-title {
  font-size: var(--hmi-item-input-title-font, var(--hmi-panel-input-title-font));
}

/* Оси станка должны оставаться крупными, если не задан отдельный стиль ячейки. */
.hmi-main > .hmi-panel:not(.hmi-bottom-panel) .hmi-button.axis .hmi-button-label {
  font-size: var(--hmi-item-button-font, var(--hmi-axis-font));
}


/* STEP_13_DRAGGABLE_BUILDER_TOOLBAR */

.hmi-builder-toolbar {
  user-select: none;
}

.hmi-builder-toolbar-handle {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 2.35rem;
  padding: 0 0.85rem;
  border: 1px solid rgba(140, 235, 255, 0.22);
  background:
    linear-gradient(180deg, rgba(80, 160, 190, 0.22), rgba(20, 60, 80, 0.18));
  color: rgba(225, 245, 255, 0.94);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: grab;
  white-space: nowrap;
}

.hmi-builder-toolbar-handle:active,
.hmi-builder-toolbar[data-dragging="1"] .hmi-builder-toolbar-handle {
  cursor: grabbing;
  color: rgba(255, 235, 150, 0.98);
  border-color: rgba(255, 220, 120, 0.58);
  box-shadow:
    inset 0 0 0.8rem rgba(255, 220, 120, 0.08),
    0 0 1rem rgba(255, 220, 120, 0.12);
}

.hmi-builder-toolbar[data-dragging="1"] {
  opacity: 0.92;
}


/* STEP_14_CONFIGURATOR_TOOL_PANEL */

.hmi-configurator-toolbox {
  position: fixed;
  left: 0.75rem;
  top: 0.75rem;
  z-index: 9998;

  width: min(21rem, 92vw);
  max-height: calc(100vh - 1.5rem);

  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 0.55rem;

  padding: 0.65rem;

  border: 1px solid rgba(140, 235, 255, 0.24);
  background:
    linear-gradient(180deg, rgba(8, 30, 42, 0.96), rgba(2, 12, 20, 0.96));
  color: rgba(230, 250, 255, 0.94);

  box-shadow:
    0 0 0 1px rgba(255,255,255,0.035) inset,
    0 1rem 4rem rgba(0,0,0,0.45),
    0 0 2rem rgba(80, 200, 255, 0.12);

  backdrop-filter: blur(0.45rem);
  overflow: auto;
  user-select: none;
  font-family: system-ui, sans-serif;
}

.hmi-tool-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  gap: 0.6rem;
  align-items: center;

  padding: 0.55rem;
  border: 1px solid rgba(140, 235, 255, 0.18);
  background: rgba(80, 160, 190, 0.12);
  cursor: grab;
}

.hmi-configurator-toolbox[data-dragging="1"] .hmi-tool-head {
  cursor: grabbing;
  border-color: rgba(255, 220, 120, 0.55);
}

.hmi-tool-drag {
  width: 2rem;
  height: 2rem;
  display: grid;
  place-items: center;
  border: 1px solid rgba(140, 235, 255, 0.22);
  background: rgba(0, 20, 32, 0.55);
  color: rgba(255, 220, 120, 0.95);
  font-size: 1.1rem;
}

.hmi-tool-title {
  font-weight: 800;
  font-size: 0.95rem;
  line-height: 1.1;
}

.hmi-tool-subtitle {
  margin-top: 0.16rem;
  font-size: 0.72rem;
  color: rgba(190, 225, 235, 0.68);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hmi-tool-status-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.35rem;
  align-items: center;
  min-height: 1.25rem;
}

.hmi-tool-actions {
  display: grid;
  grid-template-columns: repeat(2, 2.15rem);
  gap: 0.28rem;
}

.hmi-tool-actions button {
  width: 2.15rem;
  height: 2.15rem;
  padding: 0 !important;
  font-size: 1.08rem !important;
  line-height: 1;
}

.hmi-tool-actions button:disabled {
  cursor: default;
  opacity: 0.34;
}

.hmi-tool-status {
  min-width: 0;
  min-height: 1.1rem;
  font-size: 0.76rem;
  color: rgba(120, 255, 190, 0.92);
  overflow: hidden;
  text-overflow: ellipsis;
}

.hmi-tool-status[data-status-kind="error"] {
  color: rgba(255, 120, 120, 0.96);
}

.hmi-tool-status-copy {
  width: 1.8rem;
  height: 1.8rem;
  padding: 0 !important;
  display: grid;
  place-items: center;
  font-size: 0.86rem !important;
}

.hmi-tool-section,
.hmi-configurator-toolbox details.hmi-tool-section {
  display: grid;
  gap: 0.48rem;
  padding: 0.58rem;
  border: 1px solid rgba(140, 235, 255, 0.13);
  background: rgba(0, 18, 28, 0.42);
}

.hmi-tool-section + .hmi-tool-section,
.hmi-configurator-toolbox details.hmi-tool-section + details.hmi-tool-section {
  margin-top: 0.55rem;
}

.hmi-tool-section-title,
.hmi-configurator-toolbox summary {
  color: rgba(170, 235, 255, 0.82);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.hmi-configurator-toolbox summary {
  cursor: pointer;
}

.hmi-tool-field {
  display: grid;
  gap: 0.18rem;
  font-size: 0.72rem;
  color: rgba(205, 235, 245, 0.78);
}

.hmi-tool-field input,
.hmi-tool-field select {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;

  border: 1px solid rgba(140, 235, 255, 0.18);
  background: rgba(0, 10, 16, 0.72);
  color: rgba(235, 250, 255, 0.96);

  padding: 0.42rem 0.5rem;
  outline: none;
  font-size: 0.78rem;
}

.hmi-tool-field input:focus,
.hmi-tool-field select:focus {
  border-color: rgba(255, 220, 120, 0.55);
  box-shadow: 0 0 0.6rem rgba(255, 220, 120, 0.08);
}

.hmi-tool-button-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.38rem;
}

.hmi-screen-nav-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.32rem;
}

.hmi-screen-nav-grid-axes {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.hmi-screen-nav-button {
  min-height: 4.2rem;
  display: grid;
  grid-template-rows: auto auto auto;
  align-content: center;
  gap: 0.15rem;
  padding: 0.42rem 0.32rem !important;
  text-align: center;
}

.hmi-screen-nav-button strong {
  color: rgba(235, 250, 255, 0.98);
  font-size: 0.82rem;
  line-height: 1;
}

.hmi-screen-nav-button em,
.hmi-screen-nav-button small {
  min-width: 0;
  overflow: hidden;
  color: rgba(205, 235, 245, 0.68);
  font-size: 0.5rem;
  font-style: normal;
  line-height: 1.08;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hmi-screen-nav-button small {
  color: rgba(135, 232, 255, 0.62);
}

.hmi-screen-nav-button span {
  color: rgba(255, 220, 120, 0.82);
  font-size: 0.48rem;
  line-height: 1;
  text-transform: uppercase;
}

.hmi-screen-nav-button[aria-pressed="true"] {
  border-color: rgba(175, 252, 255, 0.86) !important;
  background:
    linear-gradient(180deg, rgba(230, 255, 255, 0.22), rgba(80, 212, 232, 0.2)),
    rgba(80, 190, 210, 0.22) !important;
  color: rgba(245, 255, 255, 0.98) !important;
  box-shadow: 0 0 0.75rem rgba(93, 243, 255, 0.16);
}

.hmi-screen-nav-button.is-drop-target {
  border-color: rgba(130, 255, 190, 0.9) !important;
  background:
    linear-gradient(180deg, rgba(60, 255, 150, 0.24), rgba(20, 120, 78, 0.22)),
    rgba(20, 70, 58, 0.32) !important;
  box-shadow: 0 0 1rem rgba(53, 255, 139, 0.22);
}

.hmi-tool-subsection-title {
  margin-top: 0.55rem;
  margin-bottom: 0.34rem;
  font-size: 0.66rem;
  opacity: 0.82;
}

.hmi-transfer-mode {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.32rem;
}

.hmi-transfer-mode button[aria-pressed="true"] {
  border-color: rgba(255, 220, 120, 0.6) !important;
  background: rgba(255, 220, 120, 0.14) !important;
  color: rgba(255, 235, 170, 0.98) !important;
}

.hmi-inventory-panel {
  display: grid;
  gap: 0.28rem;
}

.hmi-inventory-panel + .hmi-inventory-panel {
  margin-top: 0.58rem;
}

.hmi-inventory-panel-title {
  color: rgba(150, 188, 255, 0.92);
  font-size: 0.66rem;
  font-weight: 800;
  text-transform: uppercase;
}

.hmi-inventory-list {
  display: grid;
  gap: 0.24rem;
}

.hmi-inventory-item {
  min-width: 0;
  display: grid;
  grid-template-columns: 4.8rem minmax(0, 1fr);
  align-items: center;
  gap: 0.34rem;
  padding: 0.32rem 0.42rem !important;
  text-align: left;
}

.hmi-inventory-item[draggable="true"] {
  cursor: grab;
}

.hmi-inventory-item[aria-pressed="true"] {
  border-color: rgba(255, 220, 120, 0.7) !important;
  background: rgba(255, 220, 120, 0.13) !important;
}

.hmi-inventory-type {
  overflow: hidden;
  color: rgba(135, 232, 255, 0.72);
  font-family: "Orbitron", "Cascadia Mono", monospace;
  font-size: 0.48rem;
  text-overflow: ellipsis;
  text-transform: uppercase;
}

.hmi-inventory-item strong {
  min-width: 0;
  overflow: hidden;
  color: rgba(235, 250, 255, 0.94);
  font-size: 0.68rem;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hmi-configurator-toolbox button {
  border: 1px solid rgba(140, 235, 255, 0.24);
  background: rgba(80, 160, 190, 0.18);
  color: rgba(235, 250, 255, 0.96);
  padding: 0.45rem 0.55rem;
  cursor: pointer;
  font-size: 0.76rem;
  font-weight: 700;
}

.hmi-tool-collapse {
  width: 2.15rem;
  height: 2.15rem;
  padding: 0 !important;
  font-size: 1.15rem !important;
  line-height: 1;
}

.hmi-configurator-toolbox.is-collapsed {
  width: auto;
  max-height: none;
  display: block;
  padding: 0.35rem;
  overflow: visible !important;
}

.hmi-tool-collapsed-button {
  min-width: 5.2rem;
  min-height: 2.45rem;
  display: inline-grid;
  grid-template-columns: auto auto;
  gap: 0.42rem;
  align-items: center;
  justify-content: center;
  padding: 0.45rem 0.7rem !important;
  white-space: nowrap;
}

.hmi-tool-collapsed-button span {
  color: rgba(255, 220, 120, 0.95);
  font-size: 1.05rem;
}

.hmi-configurator-toolbox button:hover {
  background: rgba(120, 210, 240, 0.26);
  border-color: rgba(170, 245, 255, 0.42);
}

.hmi-tool-font-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 2.15rem 2.15rem 2.15rem;
  gap: 0.3rem;
  align-items: end;
}

.hmi-tool-font-row button {
  height: 2.15rem;
  padding: 0;
  font-size: 1.05rem;
}

.hmi-tool-apply-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 2.15rem;
  gap: 0.3rem;
  align-items: end;
}

.hmi-tool-apply-current {
  height: 2.15rem;
  padding: 0 !important;
  border-color: rgba(53, 255, 139, 0.34) !important;
  background:
    linear-gradient(180deg, rgba(53, 255, 139, 0.2), rgba(10, 80, 46, 0.2)) !important;
  color: rgba(135, 255, 185, 0.96) !important;
  font-size: 1.05rem !important;
  line-height: 1;
}

.hmi-tool-apply-current:hover {
  border-color: rgba(115, 255, 185, 0.68) !important;
  background:
    linear-gradient(180deg, rgba(90, 255, 170, 0.28), rgba(10, 95, 55, 0.24)) !important;
}

.hmi-tool-apply-row.is-dirty,
.hmi-tool-font-row.is-dirty,
.hmi-tool-bulk-row.is-dirty {
  filter: drop-shadow(0 0 0.35rem rgba(255, 220, 120, 0.12));
}

.hmi-tool-apply-row.is-dirty .hmi-tool-field input,
.hmi-tool-apply-row.is-dirty .hmi-tool-field select,
.hmi-tool-font-row.is-dirty .hmi-tool-field input,
.hmi-tool-bulk-row.is-dirty .hmi-tool-field input,
.hmi-tool-bulk-row.is-dirty .hmi-tool-field select {
  border-color: rgba(255, 220, 120, 0.62);
  box-shadow: 0 0 0.6rem rgba(255, 220, 120, 0.1);
}

.hmi-tool-apply-row.is-dirty .hmi-tool-apply-current,
.hmi-tool-font-row.is-dirty .hmi-tool-apply-current {
  border-color: rgba(130, 255, 190, 0.82) !important;
  box-shadow: 0 0 0.75rem rgba(53, 255, 139, 0.18);
}

.hmi-tool-empty {
  font-size: 0.78rem;
  line-height: 1.35;
  color: rgba(205, 235, 245, 0.7);
}

.hmi-workspace-current {
  display: grid;
  gap: 0.14rem;
  padding: 0.55rem 0.62rem;
  border: 1px solid rgba(95, 243, 255, 0.18);
  background:
    radial-gradient(circle at 12% 0%, rgba(95, 243, 255, 0.1), transparent 52%),
    rgba(4, 26, 36, 0.26);
}

.hmi-workspace-current strong {
  overflow: hidden;
  color: rgba(245, 255, 255, 0.98);
  font-size: 0.88rem;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hmi-workspace-current span {
  color: rgba(135, 232, 255, 0.66);
  font-family: "Orbitron", "Cascadia Mono", monospace;
  font-size: 0.58rem;
}

.hmi-empty-screen {
  grid-column: 1 / -1;
  min-height: 100%;
  display: grid;
  place-content: center;
  gap: 0.55rem;
  padding: 2rem;
  color: rgba(205, 235, 245, 0.72);
  text-align: center;
  border: 1px dashed rgba(95, 243, 255, 0.22);
  background:
    radial-gradient(circle at 50% 30%, rgba(95, 243, 255, 0.08), transparent 48%),
    rgba(4, 26, 36, 0.18);
}

.hmi-empty-screen strong {
  color: rgba(235, 250, 255, 0.96);
  font-family: "Orbitron", "Cascadia Mono", monospace;
  font-size: clamp(1.4rem, 2vw, 2.4rem);
  letter-spacing: 0.08em;
}

.hmi-empty-screen span {
  max-width: 34rem;
  font-size: clamp(0.82rem, 1vw, 1rem);
  line-height: 1.45;
}

.hmi-builder-mode .hmi-cell {
  cursor: crosshair;
}

.hmi-builder-mode .hmi-cell[draggable="true"] {
  cursor: grab;
}

.hmi-builder-mode .hmi-cell:hover {
  outline: 2px solid rgba(255, 220, 120, 0.9);
  outline-offset: -2px;
}

.hmi-builder-mode .hmi-panel-title {
  cursor: pointer;
}

.hmi-builder-mode .hmi-panel-title:hover {
  outline: 2px solid rgba(255, 220, 120, 0.9);
  outline-offset: -2px;
}

.hmi-builder-selected {
  outline: 2px solid rgba(255, 220, 120, 0.95) !important;
  outline-offset: -2px;
  box-shadow:
    inset 0 0 0 1px rgba(255, 220, 120, 0.22),
    0 0 1.2rem rgba(255, 220, 120, 0.18);
}


/* STEP_15_TOOLBOX_FIX_INFO_FKEYS_SCROLLBAR */

/*
  Исправление: конфигуратор теперь состоит из фиксированной шапки,
  статуса, секции "Экран" и отдельной прокручиваемой рабочей области.
  Поэтому поля "Заголовок" больше не налезают на верхние кнопки.
*/
.hmi-configurator-toolbox {
  overflow: hidden !important;
  grid-template-rows: auto auto auto minmax(0, 1fr) !important;
}

.hmi-tool-screen-section {
  flex: 0 0 auto;
}

.hmi-tool-scroll {
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 0.28rem;
  display: block;
}

/* Скроллбар в стиле HMI */
.hmi-tool-scroll {
  scrollbar-width: thin;
  scrollbar-color: rgba(120, 230, 255, 0.55) rgba(0, 20, 30, 0.65);
}

.hmi-tool-scroll::-webkit-scrollbar {
  width: 0.6rem;
}

.hmi-tool-scroll::-webkit-scrollbar-track {
  background:
    linear-gradient(180deg, rgba(0, 20, 30, 0.75), rgba(0, 8, 14, 0.85));
  border-left: 1px solid rgba(120, 230, 255, 0.12);
}

.hmi-tool-scroll::-webkit-scrollbar-thumb {
  background:
    linear-gradient(180deg, rgba(120, 230, 255, 0.65), rgba(40, 130, 160, 0.5));
  border: 1px solid rgba(180, 250, 255, 0.22);
  box-shadow:
    inset 0 0 0.5rem rgba(255,255,255,0.05),
    0 0 0.6rem rgba(120, 230, 255, 0.18);
}

.hmi-tool-scroll::-webkit-scrollbar-thumb:hover {
  background:
    linear-gradient(180deg, rgba(170, 250, 255, 0.8), rgba(70, 170, 200, 0.65));
}

/* Маленькая информационная кнопка i */
.hmi-tool-info {
  display: inline-grid;
  place-items: center;
  width: 0.9rem;
  height: 0.9rem;
  margin-left: 0.22rem;

  border: 1px solid rgba(140, 235, 255, 0.34);
  border-radius: 999px;
  color: rgba(180, 240, 255, 0.92);
  background: rgba(40, 120, 150, 0.22);

  font-size: 0.62rem;
  font-weight: 900;
  line-height: 1;
  cursor: help;
}

.hmi-tool-field > span {
  display: flex;
  align-items: center;
  gap: 0.18rem;
}

/* F-клавиши теперь редактируемые элементы */
.hmi-fkey-cell {
  min-width: 0;
  min-height: 0;
  display: grid;
}

.hmi-fkey-cell > .hmi-button,
.hmi-fkey-cell > .hmi-fkey-title {
  width: 100%;
  height: 100%;
}

.hmi-builder-mode .hmi-fkey-cell {
  cursor: crosshair;
}

.hmi-builder-mode .hmi-fkey-cell:hover {
  outline: 2px solid rgba(255, 220, 120, 0.9);
  outline-offset: -2px;
}


/* STEP_16_EXTENDED_STYLE_VARS_AND_BULK_TOOLS */

.hmi-panel {
  border-color: var(--hmi-panel-border-color, rgba(95, 243, 255, 0.25));
  background: var(
    --hmi-panel-background,
    radial-gradient(circle at 8% 0%, rgba(95, 243, 255, 0.05), transparent 36%),
    rgba(3, 20, 28, 0.26)
  );
}

.hmi-panel .hmi-panel-title {
  color: var(--hmi-panel-title-color, rgba(150, 188, 255, 0.95));
  font-family: var(--hmi-panel-title-font-family, "Exo 2", "Segoe UI", Arial, sans-serif);
  font-weight: var(--hmi-panel-title-font-weight, 600);
}

.hmi-panel .hmi-button-label {
  color: var(--hmi-item-button-color, var(--hmi-panel-button-color, rgba(135, 232, 255, 0.86)));
  font-family: var(--hmi-item-button-font-family, var(--hmi-panel-button-font-family, "Orbitron", "Cascadia Mono", monospace));
  font-weight: var(--hmi-item-button-font-weight, var(--hmi-panel-button-font-weight, 500));
}

.hmi-panel .hmi-value-text {
  color: var(--hmi-item-value-color, var(--hmi-panel-value-color, rgba(125, 230, 255, 0.86)));
  font-family: var(--hmi-item-value-font-family, var(--hmi-panel-value-font-family, "Orbitron", monospace));
  font-weight: var(--hmi-item-value-font-weight, var(--hmi-panel-value-font-weight, 400));
}

.hmi-panel .hmi-input-value {
  color: var(--hmi-item-input-color, var(--hmi-panel-input-color, rgba(215, 245, 255, 0.96)));
  font-family: var(--hmi-item-input-font-family, var(--hmi-panel-input-font-family, "Orbitron", monospace));
  font-weight: var(--hmi-item-input-font-weight, var(--hmi-panel-input-font-weight, 400));
}

.hmi-panel .hmi-input-title {
  color: var(--hmi-item-input-title-color, var(--hmi-panel-input-title-color, rgba(180, 225, 235, 0.7)));
  font-family: var(--hmi-item-input-title-font-family, var(--hmi-panel-input-title-font-family, "Exo 2", "Segoe UI", Arial, sans-serif));
  font-weight: var(--hmi-item-input-title-font-weight, var(--hmi-panel-input-title-font-weight, 400));
}

.hmi-fkey-cell .hmi-button-label,
.hmi-fkey-cell .hmi-fkey-title {
  color: var(--hmi-item-button-color, rgba(135, 232, 255, 0.86));
  font-family: var(--hmi-item-button-font-family, "Orbitron", "Cascadia Mono", monospace);
  font-size: var(--hmi-item-button-font, var(--hmi-fkey-font));
  font-weight: var(--hmi-item-button-font-weight, 500);
}


/* STEP_24_EDITOR_SHELL */

body {
  --hmi-editor-topbar-height: clamp(3rem, 6vh, 3.8rem);
  --hmi-editor-sidebar-width: min(27rem, 30vw);
}

#hmi-root {
  transition:
    width 180ms ease,
    height 180ms ease,
    margin 180ms ease,
    padding 180ms ease;
}

.hmi-editor-topbar,
.hmi-configurator-toolbox {
  display: none;
}

body.hmi-editor-active #hmi-root {
  width: calc(100vw - var(--hmi-editor-sidebar-width));
  height: calc(100svh - var(--hmi-editor-topbar-height));
  margin-top: var(--hmi-editor-topbar-height);
}

body.hmi-editor-active .hmi-editor-topbar {
  position: fixed;
  inset: 0 var(--hmi-editor-sidebar-width) auto 0;
  z-index: 9997;
  height: var(--hmi-editor-topbar-height);
  display: grid;
  grid-template-columns: minmax(12rem, 18rem) minmax(0, 1fr) auto;
  gap: 0.75rem;
  align-items: center;
  padding: 0.45rem 0.72rem;
  border-bottom: 1px solid rgba(140, 235, 255, 0.22);
  background:
    linear-gradient(180deg, rgba(6, 24, 34, 0.97), rgba(2, 10, 17, 0.97));
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.025) inset,
    0 0.9rem 2rem rgba(0,0,0,0.32);
  color: rgba(230, 250, 255, 0.94);
  font-family: "Exo 2", "Segoe UI", Arial, sans-serif;
}

.hmi-editor-brand {
  min-width: 0;
  display: grid;
  gap: 0.12rem;
}

.hmi-editor-brand strong {
  overflow: hidden;
  color: rgba(245, 255, 255, 0.98);
  font-size: clamp(0.82rem, 0.68rem + 0.35vw, 1.05rem);
  font-weight: 800;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hmi-editor-brand span {
  overflow: hidden;
  color: rgba(135, 232, 255, 0.62);
  font-size: 0.7rem;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hmi-editor-menu,
.hmi-editor-quick {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.hmi-editor-menu {
  overflow: auto hidden;
  scrollbar-width: none;
}

.hmi-editor-menu::-webkit-scrollbar {
  display: none;
}

.hmi-editor-topbar button {
  min-height: 2.05rem;
  border: 1px solid rgba(140, 235, 255, 0.22);
  background:
    linear-gradient(180deg, rgba(120, 220, 255, 0.12), rgba(30, 90, 115, 0.12)),
    rgba(0, 20, 30, 0.44);
  color: rgba(232, 250, 255, 0.94);
  padding: 0.4rem 0.7rem;
  cursor: pointer;
  font-size: 0.76rem;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
}

.hmi-editor-topbar button:hover {
  border-color: rgba(170, 245, 255, 0.44);
  background:
    linear-gradient(180deg, rgba(120, 220, 255, 0.2), rgba(30, 100, 125, 0.18)),
    rgba(0, 26, 38, 0.62);
}

.hmi-editor-topbar button:disabled {
  cursor: default;
  opacity: 0.36;
}

.hmi-editor-quick {
  justify-content: end;
}

.hmi-editor-quick button[data-editor-action="save"] {
  border-color: rgba(53, 255, 139, 0.35);
  color: rgba(150, 255, 195, 0.96);
}

.hmi-editor-quick button[data-editor-action="hide"] {
  border-color: rgba(255, 220, 120, 0.34);
  color: rgba(255, 230, 160, 0.96);
}

body.hmi-editor-active .hmi-configurator-toolbox {
  position: fixed;
  inset: var(--hmi-editor-topbar-height) 0 0 auto !important;
  z-index: 9998;
  width: var(--hmi-editor-sidebar-width);
  max-width: none;
  max-height: none;
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr) !important;
  gap: 0.55rem;
  border-width: 0 0 0 1px;
  border-color: rgba(140, 235, 255, 0.24);
  box-shadow:
    -0.8rem 0 2.4rem rgba(0,0,0,0.38),
    0 0 0 1px rgba(255,255,255,0.025) inset;
  overflow: hidden !important;
}

body.hmi-editor-active .hmi-tool-head {
  cursor: default;
}

body.hmi-editor-active .hmi-tool-drag {
  cursor: default;
}

.hmi-button.configurator .hmi-button-inner {
  border-color: rgba(255, 220, 120, 0.42);
  background:
    radial-gradient(circle at 16% 0%, rgba(255, 220, 120, 0.13), transparent 46%),
    rgba(34, 28, 8, 0.24);
}

.hmi-button.configurator .hmi-button-label {
  color: rgba(255, 230, 150, 0.95);
}

body.hmi-editor-active .hmi-button.configurator .hmi-button-inner {
  border-color: rgba(175, 252, 255, 0.92);
  box-shadow:
    inset 0 0 1rem rgba(95, 243, 255, 0.1),
    0 0 1rem rgba(255, 220, 120, 0.16);
}

@media (max-width: 1180px) {
  body {
    --hmi-editor-sidebar-width: min(24rem, 36vw);
  }
}

@media (max-width: 860px) {
  body {
    --hmi-editor-sidebar-width: min(22rem, 42vw);
  }

  body.hmi-editor-active .hmi-editor-topbar {
    grid-template-columns: minmax(9rem, 1fr) auto;
  }

  body.hmi-editor-active .hmi-editor-menu {
    grid-column: 1 / -1;
    order: 3;
  }
}

.hmi-cell .hmi-button-inner,
.hmi-cell .hmi-value-inner,
.hmi-cell .hmi-input-inner,
.hmi-cell .hmi-label {
  border-color: var(--hmi-item-border-color, rgba(95, 243, 255, 0.26));
}

.hmi-cell .hmi-button-inner,
.hmi-cell .hmi-value-inner,
.hmi-cell .hmi-label {
  background: var(
    --hmi-item-background,
    linear-gradient(180deg, rgba(255,255,255,0.03), transparent 24%),
    radial-gradient(circle at 18% 0%, rgba(95, 243, 255, 0.09), transparent 46%),
    rgba(4, 26, 36, 0.22)
  );
}

.hmi-cell .hmi-input-inner {
  background: var(
    --hmi-item-background,
    linear-gradient(180deg, rgba(255,255,255,0.03), transparent 24%),
    radial-gradient(circle at 18% 0%, rgba(95, 243, 255, 0.09), transparent 46%),
    rgba(4, 26, 36, 0.22)
  );
}

.hmi-tool-mode-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.35rem;
}

.hmi-tool-mode-tabs button[aria-pressed="true"] {
  border-color: rgba(255, 220, 120, 0.62);
  background: rgba(255, 220, 120, 0.16);
  color: rgba(255, 242, 185, 0.98);
}

.hmi-tool-bulk-grid {
  display: grid;
  gap: 0.42rem;
}

.hmi-tool-bulk-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.4rem;
  align-items: end;
}

.hmi-tool-check {
  display: grid;
  place-items: center;
  width: 2.15rem;
  height: 2.15rem;
  border: 1px solid rgba(140, 235, 255, 0.18);
  background: rgba(0, 10, 16, 0.72);
}

.hmi-tool-check input {
  width: 1rem;
  height: 1rem;
  accent-color: rgb(120, 230, 255);
}

.hmi-history-list {
  display: grid;
  gap: 0.38rem;
}

.hmi-history-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.45rem;
  align-items: center;
  padding: 0.42rem;
  border: 1px solid rgba(140, 235, 255, 0.12);
  background: rgba(0, 10, 16, 0.38);
}

.hmi-history-meta {
  min-width: 0;
  display: grid;
  gap: 0.12rem;
}

.hmi-history-meta strong,
.hmi-history-meta span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hmi-history-meta strong {
  color: rgba(230, 250, 255, 0.92);
  font-size: 0.7rem;
}

.hmi-history-meta span {
  color: rgba(190, 225, 235, 0.66);
  font-size: 0.66rem;
}

.hmi-history-item button {
  padding-inline: 0.48rem;
}

.hmi-component-list {
  display: grid;
  gap: 0.42rem;
}

.hmi-component-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.45rem;
  align-items: center;
  padding: 0.48rem;
  border: 1px solid rgba(140, 235, 255, 0.13);
  background:
    linear-gradient(180deg, rgba(80, 160, 190, 0.08), transparent),
    rgba(0, 10, 16, 0.36);
}

.hmi-component-meta {
  min-width: 0;
  display: grid;
  gap: 0.12rem;
}

.hmi-component-meta strong,
.hmi-component-meta span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hmi-component-meta strong {
  color: rgba(230, 250, 255, 0.92);
  font-size: 0.74rem;
}

.hmi-component-meta span {
  color: rgba(190, 225, 235, 0.68);
  font-size: 0.66rem;
  line-height: 1.25;
}

.hmi-component-card button {
  padding-inline: 0.48rem;
}

/* MWOS legacy state classes are added by mwos/js/MWOS*.js after Workerman data arrives. */
.hmi-button.MWController-disconnectServer,
.hmi-input.MWController-disconnectServer,
.hmi-value.MWController-disconnectServer {
  opacity: 0.45;
  background:
    linear-gradient(180deg, rgba(87, 101, 113, 0.56), rgba(29, 41, 49, 0.72)),
    var(--hmi-control-bg);
  border-color: rgba(148, 163, 184, 0.55);
}

.hmi-button.MWController-disconnectServer .hmi-button-inner,
.hmi-input.MWController-disconnectServer .hmi-input-inner,
.hmi-value.MWController-disconnectServer .hmi-value-inner {
  border-color: rgba(148, 163, 184, 0.55);
  background:
    linear-gradient(180deg, rgba(87, 101, 113, 0.34), rgba(29, 41, 49, 0.5)),
    rgba(4, 26, 36, 0.22);
}

.hmi-button.MWController-offline,
.hmi-input.MWController-offline,
.hmi-value.MWController-offline {
  opacity: 0.72;
  background:
    linear-gradient(180deg, rgba(127, 29, 29, 0.7), rgba(69, 10, 10, 0.82)),
    var(--hmi-control-bg);
  border-color: rgba(248, 113, 113, 0.75);
  box-shadow: inset 0 0 18px rgba(248, 113, 113, 0.18);
}

.hmi-button.MWController-offline .hmi-button-inner,
.hmi-input.MWController-offline .hmi-input-inner,
.hmi-value.MWController-offline .hmi-value-inner {
  border-color: rgba(248, 113, 113, 0.75);
  background:
    linear-gradient(180deg, rgba(127, 29, 29, 0.5), rgba(69, 10, 10, 0.64)),
    rgba(4, 26, 36, 0.22);
  box-shadow: inset 0 0 1rem rgba(248, 113, 113, 0.16);
}

.hmi-button.MWController-online,
.hmi-input.MWController-online,
.hmi-value.MWController-online {
  border-color: rgba(34, 197, 94, 0.8);
}

.hmi-button.MWController-online .hmi-button-inner,
.hmi-input.MWController-online .hmi-input-inner,
.hmi-value.MWController-online .hmi-value-inner {
  border-color: rgba(34, 197, 94, 0.72);
}

.hmi-button.MWModule-status-Ok,
.hmi-input.MWModule-status-Ok,
.hmi-value.MWModule-status-Ok {
  background:
    linear-gradient(180deg, rgba(11, 61, 48, 0.82), rgba(5, 34, 32, 0.9)),
    var(--hmi-control-bg);
  border-color: rgba(34, 197, 94, 0.9);
  box-shadow:
    inset 0 0 18px rgba(34, 197, 94, 0.16),
    0 0 12px rgba(34, 197, 94, 0.12);
}

.hmi-button.MWModule-status-Ok .hmi-button-inner,
.hmi-input.MWModule-status-Ok .hmi-input-inner,
.hmi-value.MWModule-status-Ok .hmi-value-inner {
  border-color: rgba(34, 197, 94, 0.9);
  background:
    linear-gradient(180deg, rgba(11, 61, 48, 0.62), rgba(5, 34, 32, 0.74)),
    rgba(4, 26, 36, 0.22);
  box-shadow:
    inset 0 0 1.1rem rgba(34, 197, 94, 0.18),
    0 0 0.75rem rgba(34, 197, 94, 0.1);
}

.hmi-button.MWModule-status-No,
.hmi-input.MWModule-status-No,
.hmi-value.MWModule-status-No,
.hmi-button.MWModule-status-Min,
.hmi-input.MWModule-status-Min,
.hmi-value.MWModule-status-Min,
.hmi-button.MWModule-status-Max,
.hmi-input.MWModule-status-Max,
.hmi-value.MWModule-status-Max {
  background:
    linear-gradient(180deg, rgba(127, 29, 29, 0.86), rgba(69, 10, 10, 0.92)),
    var(--hmi-control-bg);
  border-color: rgba(244, 63, 94, 0.95);
  box-shadow:
    inset 0 0 20px rgba(244, 63, 94, 0.18),
    0 0 14px rgba(244, 63, 94, 0.14);
}

.hmi-button.MWModule-status-No .hmi-button-inner,
.hmi-input.MWModule-status-No .hmi-input-inner,
.hmi-value.MWModule-status-No .hmi-value-inner,
.hmi-button.MWModule-status-Min .hmi-button-inner,
.hmi-input.MWModule-status-Min .hmi-input-inner,
.hmi-value.MWModule-status-Min .hmi-value-inner,
.hmi-button.MWModule-status-Max .hmi-button-inner,
.hmi-input.MWModule-status-Max .hmi-input-inner,
.hmi-value.MWModule-status-Max .hmi-value-inner {
  border-color: rgba(244, 63, 94, 0.95);
  background:
    linear-gradient(180deg, rgba(127, 29, 29, 0.66), rgba(69, 10, 10, 0.78)),
    rgba(4, 26, 36, 0.22);
  box-shadow:
    inset 0 0 1.2rem rgba(244, 63, 94, 0.2),
    0 0 0.85rem rgba(244, 63, 94, 0.12);
}

.hmi-button.MWController-alarm,
.hmi-input.MWController-alarm,
.hmi-value.MWController-alarm {
  animation: hmi-mwos-alarm 0.9s ease-in-out infinite alternate;
}

@keyframes hmi-mwos-alarm {
  from {
    filter: saturate(1);
  }

  to {
    filter: saturate(1.65) brightness(1.18);
  }
}

.hmi-mwos-diagnostics {
  position: fixed;
  top: clamp(0.35rem, 0.7vw, 0.75rem);
  right: clamp(0.35rem, 0.7vw, 0.75rem);
  z-index: 40;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  gap: 0.35rem;
  max-width: min(42rem, calc(100vw - 1rem));
  color: rgba(218, 250, 255, 0.9);
  font-family: "Exo 2", "Segoe UI", Arial, sans-serif;
  pointer-events: none;
}

.hmi-mwos-diagnostics-toggle {
  pointer-events: auto;
  height: 2rem;
  min-width: 3.9rem;
  border: 1px solid rgba(148, 163, 184, 0.45);
  background: rgba(11, 18, 24, 0.82);
  color: rgba(210, 220, 230, 0.88);
  font: 700 0.72rem/1 "Orbitron", monospace;
  letter-spacing: 0;
  cursor: pointer;
}

.hmi-mwos-diagnostics-toggle::before {
  content: "";
  display: inline-block;
  width: 0.46rem;
  height: 0.46rem;
  margin-right: 0.35rem;
  border-radius: 999px;
  background: rgb(148, 163, 184);
  box-shadow: 0 0 0.5rem rgba(148, 163, 184, 0.35);
  vertical-align: 0.02rem;
}

.hmi-mwos-diagnostics[data-mwos-diag-mode="online"] .hmi-mwos-diagnostics-toggle {
  border-color: rgba(34, 197, 94, 0.72);
  color: rgba(160, 255, 198, 0.96);
}

.hmi-mwos-diagnostics[data-mwos-diag-mode="online"] .hmi-mwos-diagnostics-toggle::before {
  background: rgb(34, 197, 94);
  box-shadow: 0 0 0.7rem rgba(34, 197, 94, 0.55);
}

.hmi-mwos-diagnostics[data-mwos-diag-mode="pending"] .hmi-mwos-diagnostics-toggle {
  border-color: rgba(250, 204, 21, 0.72);
  color: rgba(255, 235, 140, 0.96);
}

.hmi-mwos-diagnostics[data-mwos-diag-mode="pending"] .hmi-mwos-diagnostics-toggle::before {
  background: rgb(250, 204, 21);
  box-shadow: 0 0 0.7rem rgba(250, 204, 21, 0.52);
}

.hmi-mwos-diagnostics[data-mwos-diag-mode="offline"] .hmi-mwos-diagnostics-toggle {
  border-color: rgba(244, 63, 94, 0.78);
  color: rgba(255, 170, 185, 0.96);
}

.hmi-mwos-diagnostics[data-mwos-diag-mode="offline"] .hmi-mwos-diagnostics-toggle::before {
  background: rgb(244, 63, 94);
  box-shadow: 0 0 0.7rem rgba(244, 63, 94, 0.55);
}

.hmi-mwos-diagnostics-body {
  display: none;
  min-width: min(34rem, calc(100vw - 5rem));
  padding: 0.55rem 0.65rem;
  border: 1px solid rgba(95, 243, 255, 0.2);
  background: rgba(3, 13, 20, 0.9);
  box-shadow: 0 1rem 2.4rem rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(10px);
  pointer-events: auto;
}

.hmi-mwos-diagnostics.is-open .hmi-mwos-diagnostics-body {
  display: grid;
  gap: 0.25rem;
}

.hmi-mwos-diagnostics-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  min-width: 0;
  font-size: 0.74rem;
}

.hmi-mwos-diagnostics-row span,
.hmi-mwos-diagnostics-row strong {
  padding: 0.1rem 0.35rem;
  border: 1px solid rgba(95, 243, 255, 0.12);
  background: rgba(80, 160, 190, 0.08);
  font-weight: 600;
  white-space: nowrap;
}

.hmi-mwos-diagnostics-url,
.hmi-mwos-diagnostics-last {
  min-width: 0;
  color: rgba(190, 225, 235, 0.7);
  font: 0.68rem/1.25 "Cascadia Mono", monospace;
  word-break: break-all;
}

.hmi-mwos-diagnostics-toggle {
  height: 1.45rem;
  min-width: 2.8rem;
  padding: 0 0.42rem;
  font-size: 0.52rem;
}

.hmi-mwos-diagnostics-toggle::before {
  width: 0.34rem;
  height: 0.34rem;
  margin-right: 0.24rem;
}


/* STEP_25_COMPACT_EDITOR_CHROME */

body.hmi-editor-active {
  --hmi-editor-topbar-height: clamp(1.9rem, 3.8vh, 2.35rem);
  --hmi-editor-sidebar-width: min(22rem, 24vw);
}

body.hmi-editor-active .hmi-editor-topbar {
  grid-template-columns: minmax(8.5rem, 12rem) minmax(0, 1fr) auto;
  gap: 0.32rem;
  padding: 0.18rem 0.38rem;
}

body.hmi-editor-active .hmi-editor-brand {
  gap: 0.06rem;
}

body.hmi-editor-active .hmi-editor-brand strong {
  font-size: clamp(0.58rem, 0.48rem + 0.22vw, 0.72rem);
}

body.hmi-editor-active .hmi-editor-brand span {
  font-size: 0.48rem;
}

body.hmi-editor-active .hmi-editor-menu,
body.hmi-editor-active .hmi-editor-quick {
  gap: 0.18rem;
}

body.hmi-editor-active .hmi-editor-topbar button {
  min-height: 1.35rem;
  padding: 0.18rem 0.36rem;
  font-size: 0.52rem;
  font-weight: 800;
}

body.hmi-editor-active .hmi-editor-topbar button[aria-pressed="true"] {
  border-color: rgba(255, 220, 120, 0.58);
  color: rgba(255, 235, 170, 0.96);
  background:
    linear-gradient(180deg, rgba(255, 220, 120, 0.16), rgba(90, 70, 24, 0.14)),
    rgba(0, 20, 30, 0.48);
}

body.hmi-editor-active .hmi-configurator-toolbox {
  gap: 0.28rem;
  padding: 0.36rem;
}

body.hmi-editor-active .hmi-tool-head {
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  gap: 0.32rem;
  padding: 0.28rem;
}

body.hmi-editor-active .hmi-tool-drag {
  width: 1.34rem;
  height: 1.34rem;
  font-size: 0.76rem;
}

body.hmi-editor-active .hmi-tool-title {
  font-size: 0.64rem;
}

body.hmi-editor-active .hmi-tool-subtitle {
  margin-top: 0.06rem;
  font-size: 0.5rem;
}

body.hmi-editor-active .hmi-tool-actions {
  grid-template-columns: repeat(2, 1.42rem);
  gap: 0.16rem;
}

body.hmi-editor-active .hmi-tool-actions button,
body.hmi-editor-active .hmi-tool-collapse,
body.hmi-editor-active .hmi-tool-status-copy,
body.hmi-editor-active .hmi-tool-apply-current,
body.hmi-editor-active .hmi-tool-font-row button {
  width: 1.42rem;
  height: 1.42rem;
  min-height: 1.42rem;
  font-size: 0.66rem !important;
}

body.hmi-editor-active .hmi-tool-section,
body.hmi-editor-active .hmi-configurator-toolbox details.hmi-tool-section {
  gap: 0.28rem;
  padding: 0.34rem;
}

body.hmi-editor-active .hmi-tool-section + .hmi-tool-section,
body.hmi-editor-active .hmi-configurator-toolbox details.hmi-tool-section + details.hmi-tool-section {
  margin-top: 0.34rem;
}

body.hmi-editor-active .hmi-tool-section-title,
body.hmi-editor-active .hmi-configurator-toolbox summary {
  font-size: 0.5rem;
  letter-spacing: 0.05em;
}

body.hmi-editor-active .hmi-tool-status {
  min-height: 0.86rem;
  font-size: 0.54rem;
}

body.hmi-editor-active .hmi-tool-field {
  gap: 0.1rem;
  font-size: 0.52rem;
}

body.hmi-editor-active .hmi-tool-field input,
body.hmi-editor-active .hmi-tool-field select,
body.hmi-editor-active .hmi-tool-field textarea {
  padding: 0.24rem 0.32rem;
  font-size: 0.56rem;
}

body.hmi-editor-active .hmi-tool-button-grid,
body.hmi-editor-active .hmi-tool-mode-tabs,
body.hmi-editor-active .hmi-transfer-mode,
body.hmi-editor-active .hmi-screen-nav-grid {
  gap: 0.18rem;
}

body.hmi-editor-active .hmi-configurator-toolbox button {
  padding: 0.24rem 0.34rem;
  font-size: 0.54rem;
}

body.hmi-editor-active .hmi-tool-empty {
  font-size: 0.56rem;
  line-height: 1.25;
}

body.hmi-editor-active .hmi-screen-nav-button {
  min-height: 2.6rem;
  gap: 0.08rem;
  padding: 0.26rem 0.18rem !important;
}

body.hmi-editor-active .hmi-screen-nav-button strong {
  font-size: 0.58rem;
}

body.hmi-editor-active .hmi-screen-nav-button em,
body.hmi-editor-active .hmi-screen-nav-button small {
  font-size: 0.42rem;
}

body.hmi-editor-active .hmi-workspace-current {
  gap: 0.06rem;
  padding: 0.32rem 0.38rem;
}

body.hmi-editor-active .hmi-workspace-current strong {
  font-size: 0.62rem;
}

body.hmi-editor-active .hmi-workspace-current span,
body.hmi-editor-active .hmi-inventory-type,
body.hmi-editor-active .hmi-component-meta span {
  font-size: 0.44rem;
}

body.hmi-editor-active .hmi-inventory-item {
  grid-template-columns: 3.5rem minmax(0, 1fr);
  gap: 0.22rem;
  padding: 0.2rem 0.28rem !important;
}

body.hmi-editor-active .hmi-inventory-item strong,
body.hmi-editor-active .hmi-component-meta strong {
  font-size: 0.52rem;
}

body.hmi-editor-active .hmi-tool-font-row {
  grid-template-columns: minmax(0, 1fr) 1.42rem 1.42rem 1.42rem;
  gap: 0.18rem;
}

body.hmi-editor-active .hmi-tool-apply-row {
  grid-template-columns: minmax(0, 1fr) 1.42rem;
  gap: 0.18rem;
}

body.hmi-editor-active .hmi-tool-info {
  width: 0.64rem;
  height: 0.64rem;
  font-size: 0.42rem;
}

body.hmi-editor-active .hmi-tool-section.is-editor-focused,
body.hmi-editor-active details.hmi-tool-section.is-editor-focused {
  border-color: rgba(255, 220, 120, 0.58);
  box-shadow: 0 0 0.7rem rgba(255, 220, 120, 0.12);
}

body.hmi-editor-active .hmi-panel,
body.hmi-editor-active .hmi-panel-body,
body.hmi-editor-active .hmi-cell-grid,
body.hmi-editor-active .hmi-cell {
  overflow: visible;
}

body.hmi-editor-active .hmi-panel {
  position: relative;
}

body.hmi-editor-active .hmi-panel-slot {
  min-width: 0;
  min-height: 0;
  border: 1px dashed rgba(95, 243, 255, 0.18);
  background:
    linear-gradient(180deg, rgba(95, 243, 255, 0.035), rgba(95, 243, 255, 0.012)),
    rgba(3, 20, 28, 0.12);
}

body.hmi-editor-active .hmi-empty-screen {
  grid-column: 1 / -1;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 0.55rem;
  place-content: stretch;
  place-items: stretch;
}

body.hmi-editor-active .hmi-empty-screen strong {
  align-self: start;
  justify-self: start;
  padding-left: 2.2rem;
  font-size: clamp(0.75rem, 1vw, 1rem);
  opacity: 0.72;
}

body.hmi-editor-active .hmi-empty-panel-map {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(var(--hmi-columns), minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
  gap: var(--hmi-gap);
}

body.hmi-editor-active .hmi-cell {
  box-shadow: inset 0 0 0 1px rgba(95, 243, 255, 0.075);
}

body.hmi-editor-active .hmi-cell-grid.has-cols {
  background:
    linear-gradient(90deg, rgba(95, 243, 255, 0.08) 1px, transparent 1px),
    linear-gradient(rgba(95, 243, 255, 0.055) 1px, transparent 1px);
  background-size:
    calc(100% / max(var(--panel-cols, 1), 1)) 100%,
    100% calc(100% / max(var(--panel-rows, 1), 1));
}

body.hmi-editor-active .hmi-main {
  position: relative;
}

body.hmi-editor-active .hmi-tool-action-bank {
  display: none !important;
}

body.hmi-editor-active .hmi-cell,
body.hmi-editor-active .hmi-panel-title,
body.hmi-editor-active .hmi-empty-screen {
  position: relative;
}

body.hmi-editor-active .hmi-panel-title {
  overflow: visible;
}

body.hmi-editor-active .hmi-screen-inline-actions {
  position: relative;
  z-index: 45;
  min-width: 0;
  min-height: 0;
  display: grid;
  place-items: start;
  padding: 0.34rem;
  border: 1px dashed rgba(255, 220, 120, 0.34);
  background:
    linear-gradient(180deg, rgba(255, 220, 120, 0.04), rgba(95, 243, 255, 0.015)),
    rgba(3, 20, 28, 0.12);
}

body.hmi-editor-active .hmi-screen-inline-actions > .hmi-inline-create {
  position: relative;
}

body.hmi-editor-active .hmi-panel-inline-actions {
  position: absolute;
  z-index: 42;
  top: 0.2rem;
  right: 0.2rem;
  display: flex;
  align-items: center;
  gap: 0.16rem;
  opacity: 0;
  transition: opacity 120ms ease;
}

body.hmi-editor-active .hmi-panel:hover > .hmi-panel-inline-actions,
body.hmi-editor-active .hmi-panel:focus-within > .hmi-panel-inline-actions,
body.hmi-editor-active .hmi-panel.hmi-builder-selected > .hmi-panel-inline-actions {
  opacity: 1;
}

body.hmi-editor-active .hmi-empty-screen span {
  display: none;
}

.hmi-inline-create,
.hmi-inline-actions {
  position: absolute;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 0.18rem;
  font-family: "Exo 2", "Segoe UI", Arial, sans-serif;
}

.hmi-inline-create::after {
  content: "";
  position: absolute;
  left: -0.18rem;
  right: -0.18rem;
  top: 100%;
  height: 0.28rem;
}

.hmi-empty-screen > .hmi-inline-create {
  top: 0.55rem;
  left: 0.55rem;
}

.hmi-panel-title > .hmi-inline-create {
  top: 50%;
  right: 0.24rem;
  transform: translateY(-50%);
}

.hmi-cell > .hmi-inline-create {
  top: 0.24rem;
  left: 0.24rem;
  opacity: 0;
  transition: opacity 120ms ease;
}

.hmi-cell:hover > .hmi-inline-create,
.hmi-cell:focus-within > .hmi-inline-create {
  opacity: 1;
}

.hmi-inline-plus,
.hmi-inline-actions button,
.hmi-panel-inline-actions > button,
.hmi-inline-menu button {
  min-width: 1.2rem;
  min-height: 1.2rem;
  border: 1px solid rgba(140, 235, 255, 0.32);
  background:
    linear-gradient(180deg, rgba(120, 230, 255, 0.18), rgba(20, 80, 105, 0.18)),
    rgba(0, 20, 30, 0.78);
  color: rgba(235, 250, 255, 0.96);
  padding: 0.12rem 0.28rem;
  cursor: pointer;
  font-size: 0.58rem;
  font-weight: 900;
  line-height: 1;
  box-shadow: 0 0.35rem 0.9rem rgba(0, 0, 0, 0.22);
}

.hmi-inline-plus {
  color: rgba(255, 230, 150, 0.98);
  border-color: rgba(255, 220, 120, 0.48);
}

.hmi-inline-menu {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 6rem;
  display: none;
  grid-template-columns: 1fr;
  gap: 0.12rem;
  padding: 0.18rem;
  border: 1px solid rgba(140, 235, 255, 0.22);
  background: rgba(2, 14, 20, 0.96);
  box-shadow: 0 0.8rem 1.8rem rgba(0, 0, 0, 0.34);
}

.hmi-panel-title .hmi-inline-menu {
  left: auto;
  right: 0;
}

.hmi-inline-create:hover .hmi-inline-menu,
.hmi-inline-create:focus-within .hmi-inline-menu,
.hmi-inline-create.is-open .hmi-inline-menu {
  display: grid;
}

.hmi-inline-menu button {
  justify-content: start;
  width: 100%;
  text-align: left;
  white-space: nowrap;
}

.hmi-inline-actions {
  top: 0.22rem;
  right: 0.22rem;
  opacity: 0;
  transition: opacity 120ms ease;
}

.hmi-cell:hover > .hmi-inline-actions,
.hmi-cell:focus-within > .hmi-inline-actions {
  opacity: 1;
}

.hmi-inline-actions button[data-inline-delete] {
  border-color: rgba(255, 80, 120, 0.58);
  color: rgba(255, 150, 175, 0.98);
}

.hmi-panel-inline-actions button[data-panel-delete] {
  border-color: rgba(255, 80, 120, 0.58);
  color: rgba(255, 150, 175, 0.98);
}

.hmi-panel-inline-actions button[data-panel-span-dec],
.hmi-panel-inline-actions button[data-panel-span-inc] {
  color: rgba(255, 230, 150, 0.96);
  border-color: rgba(255, 220, 120, 0.42);
}

body.hmi-editor-active .hmi-cell.is-drop-target {
  outline: 2px solid rgba(120, 255, 190, 0.95);
  outline-offset: -2px;
  box-shadow:
    inset 0 0 0 1px rgba(120, 255, 190, 0.24),
    0 0 1rem rgba(120, 255, 190, 0.18);
}

@media (max-width: 1180px) {
  body.hmi-editor-active {
    --hmi-editor-sidebar-width: min(20rem, 31vw);
  }
}

@media (max-width: 860px) {
  body.hmi-editor-active {
    --hmi-editor-sidebar-width: min(18rem, 44vw);
  }
}
