/* design.CabinetUI - аутентичный корпус МК-61 (requirement.AuthenticAppearance) */

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse at 30% 20%, #3a3f47 0%, #23262b 55%, #17191d 100%);
  font-family: "Helvetica Neue", Arial, sans-serif;
  padding: 24px 12px;
}

.scene { display: flex; flex-direction: column; align-items: center; gap: 18px; }

/* ---------- корпус ---------- */
.mk61 {
  width: 480px;
  max-width: 96vw;
  border-radius: 14px 14px 20px 20px;
  background: linear-gradient(172deg, #33333a 0%, #232329 38%, #17171b 100%);
  box-shadow:
    0 24px 60px rgba(0, 0, 0, 0.7),
    0 4px 14px rgba(0, 0, 0, 0.5),
    inset 0 1px 1px rgba(255, 255, 255, 0.18),
    inset 0 -4px 8px rgba(0, 0, 0, 0.6);
  padding: 18px 20px 14px;
  user-select: none;
}

.top-panel { margin-bottom: 12px; }

/* ---------- индикатор ---------- */
.display-bezel {
  background: linear-gradient(180deg, rgba(22, 84, 52, 0.55), rgba(10, 42, 26, 0.7) 55%, rgba(14, 56, 34, 0.5));
  border-radius: 8px;
  padding: 14px 16px 18px;
  border: 1px solid rgba(120, 220, 160, 0.18);
  box-shadow:
    inset 0 4px 14px rgba(0, 0, 0, 0.7),
    inset 0 -1px 2px rgba(160, 255, 200, 0.1),
    0 1px 0 rgba(255, 255, 255, 0.08);
}

.display {
  background:
    radial-gradient(ellipse at 50% 0%, #10241a 0%, #081410 70%, #050c09 100%);
  border-radius: 5px;
  height: 74px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 5px;
  padding: 10px 9px;
  box-shadow: inset 0 3px 14px rgba(0, 0, 0, 0.9);
  overflow: hidden;
  position: relative;
}
/* сетка анода вакуумно-люминесцентного индикатора */
.display::after {
  content: '';
  position: absolute; inset: 0;
  pointer-events: none;
  background:
    repeating-linear-gradient(0deg, rgba(140, 255, 190, 0.035) 0 1px, transparent 1px 3px),
    repeating-linear-gradient(90deg, rgba(140, 255, 190, 0.025) 0 1px, transparent 1px 3px);
  mix-blend-mode: screen;
}
/* блик стекла баллона */
.display::before {
  content: '';
  position: absolute; left: 0; right: 0; top: 0; height: 34%;
  background: linear-gradient(180deg, rgba(190, 255, 220, 0.07), transparent);
  pointer-events: none;
}

.digit { position: relative; width: 26px; height: 48px; flex: 0 0 auto; }
/* обособленный блок порядка: зазор, как у лампы ИЛЦ2-12/8Л */
.digit.exp-start { margin-left: 15px; }
.digit .seg {
  position: absolute;
  background: rgba(110, 255, 170, 0.06); /* погашенные сегменты ВЛИ чуть видны */
  border-radius: 3px;
  transition: background 0.04s;
}
.digit .seg.on {
  background: #b9fdd6;
  box-shadow:
    0 0 3px rgba(190, 255, 215, 1),
    0 0 9px rgba(120, 255, 175, 0.9),
    0 0 22px rgba(80, 235, 140, 0.5);
  animation: vfd-breath 1.7s ease-in-out infinite;
}
.digit:nth-child(odd) .seg.on { animation-delay: -0.9s; }
@keyframes vfd-breath {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(0.92); }
}
.seg.a { top: 0;         left: 4px;  width: 18px; height: 4px; }
.seg.g { top: 22px;      left: 4px;  width: 18px; height: 4px; }
.seg.d { bottom: 0;      left: 4px;  width: 18px; height: 4px; }
.seg.f { top: 3px;       left: 0;    width: 4px;  height: 19px; }
.seg.b { top: 3px;       right: 0;   width: 4px;  height: 19px; }
.seg.e { bottom: 3px;    left: 0;    width: 4px;  height: 19px; }
.seg.c { bottom: 3px;    right: 0;   width: 4px;  height: 19px; }
.seg.p { bottom: -2px;   right: -7px; width: 5px; height: 8px; border-radius: 1px 1px 3px 3px; }

.display.running .digit .seg.on { animation: vfd-flicker 0.35s infinite; }
@keyframes vfd-flicker {
  0%, 100% { opacity: 0.35; }
  50% { opacity: 0.9; }
}

/* ---------- шильдик и переключатели ---------- */
.controls-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 12px 4px 0;
}
.brand { display: flex; flex-direction: row; align-items: baseline; gap: 12px; line-height: 1.1; }
.brand-logo {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: #e7e9ee;
  font-family: Arial, Helvetica, sans-serif;
}
.brand-model {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.3em;
  color: #e7e9ee;
}
.switches { display: flex; gap: 26px; }
.switch-block { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.switch-labels {
  font-size: 10px;
  font-weight: 700;
  color: #d3d6db;
  letter-spacing: 0.05em;
  display: flex;
  gap: 8px;
}
.switch-labels.three { width: 84px; justify-content: space-between; }
.toggle {
  width: 56px; height: 18px;
  background: linear-gradient(180deg, #0c0c0e, #2a2a2e);
  border-radius: 9px;
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.5);
  position: relative;
  cursor: pointer;
}
.toggle.three-pos { width: 84px; }
.toggle-knob {
  position: absolute;
  top: 2px; left: 2px;
  width: 22px; height: 14px;
  border-radius: 7px;
  background: linear-gradient(180deg, #f4f1e6, #cdc7b4);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.55);
  transition: left 0.12s ease;
}
.toggle.on .toggle-knob { left: 32px; background: linear-gradient(180deg, #f6d8ae, #d9a86b); }
.toggle.three-pos .toggle-knob { left: 2px; }
.toggle.three-pos.pos-1 .toggle-knob { left: 31px; }
.toggle.three-pos.pos-2 .toggle-knob { left: 60px; }

/* ---------- клавиатура ---------- */
.keyboard {
  background: linear-gradient(180deg, #1b1b1f, #121215);
  border-radius: 12px;
  padding: 14px 12px 12px;
  box-shadow:
    inset 0 3px 10px rgba(0, 0, 0, 0.8),
    0 1px 0 rgba(255, 255, 255, 0.5);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px 10px;
}

.key-cell { display: flex; flex-direction: column; align-items: stretch; }
.key-over {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  min-height: 22px;
  padding: 0 2px 4px;
  font-size: 15.5px;
  font-weight: 800;
  letter-spacing: 0.02em;
}
.f-label { color: #f5c520; }
.k-label { color: #55c8e8; margin-left: auto; }
.key-under {
  min-height: 11px;
  text-align: right;
  font-size: 10px;
  font-weight: 700;
  font-style: italic;
  color: #d6d9de;
  padding: 2px 3px 0;
  letter-spacing: 0.1em;
}

.key {
  height: 38px;
  border: none;
  border-radius: 7px;
  background: linear-gradient(180deg, #3d3d42 0%, #26262b 45%, #1a1a1e 100%);
  color: #f4f4f0;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  box-shadow:
    0 3px 0 #101012,
    0 4px 6px rgba(0, 0, 0, 0.6),
    inset 0 1px 1px rgba(255, 255, 255, 0.22);
  transition: transform 0.04s, box-shadow 0.04s, filter 0.08s;
}
.key:active, .key.pressed {
  transform: translateY(2px);
  box-shadow:
    0 1px 0 #101012,
    0 2px 3px rgba(0, 0, 0, 0.55),
    inset 0 1px 1px rgba(255, 255, 255, 0.15);
}
.key.latched { filter: brightness(1.45); }

.key.key-f {
  background: linear-gradient(180deg, #ffd83e 0%, #f0c020 50%, #cf9f0e 100%);
  box-shadow: 0 3px 0 #7a5c05, 0 4px 6px rgba(0, 0, 0, 0.6), inset 0 1px 1px rgba(255, 255, 255, 0.5);
  color: #151515;
}
.key.key-k {
  background: linear-gradient(180deg, #55d4e8 0%, #2fb4cb 50%, #1e8ba0 100%);
  box-shadow: 0 3px 0 #0d4550, 0 4px 6px rgba(0, 0, 0, 0.6), inset 0 1px 1px rgba(255, 255, 255, 0.45);
  color: #0b2530;
}

/* цифровые клавиши: светлые с тёмными цифрами (как на приборе) */
.key.key-digit {
  background: linear-gradient(180deg, #efeee6 0%, #d9d7cc 55%, #bdbbb0 100%);
  box-shadow: 0 3px 0 #6f6d64, 0 4px 6px rgba(0, 0, 0, 0.55), inset 0 1px 1px rgba(255, 255, 255, 0.85);
  color: #17171a;
}
/* Сх: красная */
.key.key-cx {
  background: linear-gradient(180deg, #ea5546 0%, #cf3628 50%, #a52619 100%);
  box-shadow: 0 3px 0 #5d130b, 0 4px 6px rgba(0, 0, 0, 0.6), inset 0 1px 1px rgba(255, 255, 255, 0.35);
  color: #fff2ef;
}

.bottom-strip {
  margin-top: 10px;
  text-align: center;
  font-size: 9px;
  letter-spacing: 0.32em;
  color: #6f7278;
  font-weight: 600;
}

.hint {
  max-width: 480px;
  text-align: center;
  color: #9aa0a8;
  font-size: 12.5px;
  line-height: 1.55;
}

.back-link {
  position: fixed;
  top: 16px; left: 18px;
  color: #9aa0a8;
  font-size: 13px;
  text-decoration: none;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: color 0.3s, background 0.3s;
  z-index: 10;
}
.back-link:hover { color: #e8e4d8; background: rgba(255, 255, 255, 0.1); }

/* режим встраивания (iframe на страницах сайта) */
body.embed { padding: 8px 4px; background: transparent; min-height: 0; }
body.embed .back-link, body.embed .hint { display: none; }
body.embed .mk61 { box-shadow: none; }

/* отдельная страница симулятора на телефоне: ссылка «назад» не наезжает на пилюлю */
@media (max-width: 700px) {
  body:not(.embed) { flex-direction: column; justify-content: flex-start; padding: 12px 8px 24px; }
  body:not(.embed) .back-link { position: static; align-self: flex-start; margin: 0 0 12px; }
}

/* просьба повернуть телефон: показ управляется скриптом (ориентация УСТРОЙСТВА,
   media в iframe меряет сам iframe и врёт) */
.rotate-note {
  display: none; align-items: center; gap: 10px;
  max-width: 94vw;
  font: 600 13px/1.45 'Segoe UI', system-ui, sans-serif;
  color: #9df5c1;
  background: rgba(124, 255, 176, 0.08);
  border: 1px solid rgba(124, 255, 176, 0.25);
  border-radius: 14px;
  padding: 10px 14px;
  margin-bottom: 4px;
}
.rotate-note.on { display: flex; }
.rotate-note .rn-icon { font-size: 20px; flex-shrink: 0; }

/* ---------- переключатель модели МК-61 / МК-52 ---------- */
.model-switch {
  display: flex; gap: 0;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  padding: 3px;
}
.model-switch button {
  font: 600 12.5px/1 'Segoe UI', system-ui, sans-serif;
  letter-spacing: 0.06em;
  color: #9aa0a8;
  background: transparent;
  border: 0; border-radius: 999px;
  padding: 7px 16px;
  cursor: pointer;
  transition: color 0.25s, background 0.25s;
}
.model-switch button.on {
  color: #0c120e;
  background: linear-gradient(180deg, #9df5c1, #5fd894);
}
body.embed .model-switch { transform: scale(0.9); margin-bottom: -6px; }

/* ---------- корпус МК-52: геометрия 1:1 с фотографии ----------
   Фото 1668x600 px -> дизайн 1400x504 (масштаб 0.839).
   Сетка клавиш: шаг колонок 84.2, шаг рядов 84.8, капа 55x38. */
.mk52 {
  position: relative;
  width: 1400px; height: 504px;
  background: linear-gradient(180deg, #2e2e34 0%, #232327 12%, #1c1c20 55%, #17171b 100%);
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.65), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}
body.embed .mk52 { box-shadow: none; }

/* рёбра батарейного отсека по верхней кромке */
.mk52-ribs {
  position: absolute; top: 0; left: 21px; right: 22px; height: 34px;
  display: flex; gap: 25px;
}
.mk52-ribs i {
  flex: 1;
  background: linear-gradient(180deg, #26262b 0%, #131316 80%);
  border-radius: 9px 9px 3px 3px;
  box-shadow: inset 0 2px 3px rgba(255, 255, 255, 0.05), inset 0 -4px 8px rgba(0, 0, 0, 0.55);
}
.mk52-body { position: static; }
.mk52-left { position: static; }

/* шильдик: x 46-571, y 80-122 */
.mk52-brand {
  position: absolute; left: 46px; top: 80px; width: 525px; height: 42px;
  display: flex; align-items: center; gap: 26px;
  background: linear-gradient(180deg, #141417, #202024);
  border-radius: 7px;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.65), 0 1px 0 rgba(255, 255, 255, 0.05);
  padding: 0 22px;
  margin: 0;
}
.mk52-brand .brand-logo { font-size: 17px; letter-spacing: 0.34em; color: #d9d5c9; }
.mk52-brand .brand-model { font-size: 17px; letter-spacing: 0.3em; color: #e8e4d8; }

/* дисплейная ниша: x 65-571, y 136-336 */
.mk52-bezel {
  position: absolute; left: 65px; top: 136px; width: 506px; height: 200px;
  background: linear-gradient(180deg, #101013, #1a1a1e);
  border-radius: 10px;
  box-shadow: inset 0 4px 14px rgba(0, 0, 0, 0.85), 0 1px 0 rgba(255, 255, 255, 0.06);
  padding: 14px;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.mk52-bezel .display {
  display: flex; align-items: center; justify-content: center;
  padding: 10px 14px;
  transform: scale(1.16);
  transform-origin: center;
}

/* ползунки: прорези y 403, подписи снизу */
.mk52-switches { position: static; margin: 0; }
.mk52-switches .switch-block { position: absolute; top: 400px; flex-direction: column-reverse; gap: 6px; }
.mk52-switches .switch-block:nth-child(1) { left: 119px; }
.mk52-switches .switch-block:nth-child(2) { left: 231px; }
.mk52-switches .switch-block:nth-child(3) { left: 340px; }
.mk52-switches .switch-block:nth-child(4) { left: 478px; }
.mk52 .toggle-knob {
  background: linear-gradient(180deg, #2c2c31, #0c0c0f);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.8), inset 0 1px 0 rgba(255, 255, 255, 0.14);
}
.mk52 .toggle.on .toggle-knob, .mk52 .toggle.two-pos.on .toggle-knob {
  background: linear-gradient(180deg, #2c2c31, #0c0c0f);
}
.switch-labels.two { width: 56px; justify-content: space-between; }
.toggle.two-pos .toggle-knob { left: 2px; }
.toggle.two-pos.on .toggle-knob { left: 32px; }

/* панель клавиатуры: x 617-1386, y 116-491 */
.keyboard52 {
  position: absolute; left: 617px; top: 116px; width: 769px; height: 375px;
  display: grid;
  grid-template-columns: repeat(8, 55px);
  grid-auto-rows: 76px;
  column-gap: 29px;
  row-gap: 9px;
  padding: 20px 0 0 73px;
  background: linear-gradient(180deg, #101013, #17171a);
  border-radius: 12px;
  box-shadow: inset 0 3px 10px rgba(0, 0, 0, 0.8), 0 1px 0 rgba(255, 255, 255, 0.07);
}
.keyboard52 .key-cell { display: flex; flex-direction: column; }
.keyboard52 .key-over {
  height: 20px;
  white-space: nowrap;
  overflow: visible;
  font-size: 13px;
  display: flex; gap: 8px; justify-content: center; align-items: flex-end;
  padding-bottom: 3px;
}
.keyboard52 .key-over .f-label, .keyboard52 .key-over .k-label { font-size: 13px; }
.keyboard52 .key {
  height: 38px; min-width: 0;
  font-size: 15.5px;
  border-radius: 8px;
  padding: 0;
}
.keyboard52 .key-under { height: 12px; font-size: 10px; text-align: right; padding-right: 2px; }

/* строка-сообщение ППЗУ - под дисплеем */
.mk52-toast {
  position: absolute; left: 65px; top: 348px; width: 506px;
  min-height: 18px;
  font: 600 11.5px/1.4 'Segoe UI', system-ui, sans-serif;
  letter-spacing: 0.08em;
  color: #7cffb0;
  opacity: 0;
  transition: opacity 0.3s;
  text-transform: uppercase;
  text-align: center;
}
.mk52-toast.show { opacity: 1; }
