:root {
  color-scheme: dark;
  --case-light: #3d3d39;
  --case: #242522;
  --case-dark: #111210;
  --panel: #171816;
  --panel-dark: #090a09;
  --metal: #a6a392;
  --ink: #dad7c7;
  --phosphor: #efffff;
  --phosphor-dim: #54e9db;
  --amber: #f8ce00;
  --orange: #e66b00;
  --red: #a83b24;
  --cell: #efffff;
  --grid: rgba(42, 76, 68, 0.23);
  font-family: "Courier New", Courier, monospace;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: #202225;
}

body {
  display: grid;
  place-items: center;
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 50% 12%, rgba(130, 136, 141, 0.19), transparent 34rem),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.015) 0 1px, transparent 1px 5px),
    linear-gradient(#292b2e, #17191b);
}

button,
input {
  font: inherit;
}

button:focus-visible,
input:focus-visible {
  outline: 3px solid var(--amber);
  outline-offset: 4px;
}

.page-shell {
  width: min(900px, calc(100% - 44px));
  padding: 22px 0 30px;
}

main {
  width: 100%;
}

.site-signature {
  display: flex;
  gap: 0.7em;
  align-items: center;
  justify-content: center;
  margin-top: 43px;
  color: #8f928b;
  font-family: Arial, sans-serif;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.site-signature::before,
.site-signature::after {
  width: min(70px, 12vw);
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(166, 163, 146, 0.45));
  content: "";
}

.site-signature::after {
  background: linear-gradient(90deg, rgba(166, 163, 146, 0.45), transparent);
}

.site-signature a {
  color: #c0bdad;
  text-decoration: none;
  transition: color 120ms ease, text-shadow 120ms ease;
}

.site-signature a:hover,
.site-signature a:focus-visible {
  color: var(--phosphor-dim);
  text-shadow: 0 0 8px rgba(84, 233, 219, 0.38);
}

.lab {
  position: relative;
  padding: 22px;
  border: 3px solid #090a09;
  border-radius: 5px;
  background:
    radial-gradient(circle at 13% 7%, rgba(255, 255, 255, 0.08) 0 1px, transparent 2px),
    radial-gradient(circle at 78% 18%, rgba(255, 255, 255, 0.045) 0 1px, transparent 2px),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.018) 0 1px, transparent 1px 4px),
    linear-gradient(145deg, var(--case-light), var(--case) 45%, #171815);
  box-shadow:
    0 35px 80px rgba(0, 0, 0, 0.55),
    inset 0 1px 1px rgba(255, 255, 255, 0.18),
    inset 0 -3px 4px rgba(0, 0, 0, 0.7);
}

.screw {
  position: absolute;
  z-index: 5;
  width: 13px;
  height: 13px;
  border: 1px solid #4f493f;
  border-radius: 50%;
  background:
    linear-gradient(45deg, transparent 43%, #514b41 44% 56%, transparent 57%),
    radial-gradient(circle at 35% 30%, #eee8d6, #8d8776 68%);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.screw-top-left { top: 7px; left: 7px; }
.screw-top-right { top: 7px; right: 7px; }
.screw-bottom-left { bottom: 7px; left: 7px; }
.screw-bottom-right { right: 7px; bottom: 7px; }

.foot {
  position: absolute;
  z-index: 6;
  bottom: -27px;
  width: 90px;
  height: 31px;
  border: 3px solid #050505;
  border-radius: 2px 2px 16px 16px;
  background:
    repeating-linear-gradient(90deg, transparent 0 8px, rgba(255, 255, 255, 0.04) 8px 9px),
    linear-gradient(#3a3c38, #111210 68%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.12),
    0 9px 10px rgba(0, 0, 0, 0.65);
}

.foot-left { left: 58px; }
.foot-right { right: 58px; }

.lab-toolbar {
  display: flex;
  gap: 28px;
  align-items: center;
  justify-content: space-between;
  min-height: 88px;
  padding: 12px 16px 17px;
  border: 2px solid #050605;
  border-bottom: 0;
  border-radius: 6px 6px 0 0;
  color: #eee9d8;
  background:
    linear-gradient(102deg, transparent 0 35%, rgba(255, 255, 255, 0.025) 36%, transparent 37%),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.012) 0 1px, transparent 1px 4px),
    #10110f;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    inset 0 -3px 8px rgba(0, 0, 0, 0.75);
}

.instrument-id {
  min-width: 230px;
}

.nameplate {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 16px;
  min-width: 270px;
  padding: 9px 21px 8px;
  border: 2px solid #8c8b80;
  color: #191a18;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.32), transparent 22% 78%, rgba(0, 0, 0, 0.12)),
    #aaa99d;
  box-shadow:
    inset 0 0 0 1px #484941,
    0 2px 3px rgba(0, 0, 0, 0.68);
  font-family: Arial, sans-serif;
  text-transform: uppercase;
}

.nameplate::before,
.nameplate::after {
  position: absolute;
  top: 50%;
  width: 7px;
  height: 7px;
  border: 1px solid #484941;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #deddd2, #67685f 70%);
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.5);
  content: "";
  transform: translateY(-50%);
}

.nameplate::before { left: 7px; }
.nameplate::after { right: 7px; }

.nameplate-type {
  grid-column: 1 / -1;
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.12em;
}

.nameplate strong {
  font-family: "Courier New", monospace;
  font-size: 21px;
  line-height: 1;
  letter-spacing: 0.04em;
}

.serial-number {
  align-self: end;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.maker-plate,
.plate-label {
  display: block;
  width: max-content;
  max-width: 100%;
  padding: 3px 7px 2px;
  border: 1px solid rgba(32, 29, 25, 0.75);
  color: #dad7c7;
  background: linear-gradient(#32332f, #1b1c1a);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.18),
    0 1px 2px rgba(0, 0, 0, 0.4);
  font-family: Arial, sans-serif;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.13em;
  line-height: 1.2;
  text-transform: uppercase;
}

.model-line {
  display: flex;
  gap: 12px;
  align-items: baseline;
  margin-top: 9px;
}

.model-line strong {
  color: #e3e0d1;
  font-size: clamp(21px, 3vw, 30px);
  letter-spacing: 0.06em;
  line-height: 1;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.45);
}

.model-line > span {
  color: #99978c;
  font-family: Arial, sans-serif;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.readouts,
.stats {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.status-unit,
.meter {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.simulation-status {
  display: flex;
  gap: 7px;
  align-items: flex-start;
  min-height: 46px;
  padding: 5px 6px 4px;
  border: 2px solid #050504;
  background: #0c0d0b;
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.84);
}

.mode-indicator {
  display: flex;
  flex-direction: column;
  gap: 5px;
  align-items: center;
  min-width: 39px;
  color: #7d7d73;
}

.mode-indicator b {
  font-family: Arial, sans-serif;
  font-size: 7px;
  letter-spacing: 0.06em;
  line-height: 1;
  text-transform: uppercase;
}

.status-dot {
  display: block;
  width: 13px;
  height: 13px;
  border: 2px solid #332e28;
  border-radius: 50%;
  background: #33332e;
  box-shadow:
    inset 0 1px 2px rgba(255, 255, 255, 0.2),
    0 0 0 2px #171410;
}

.mode-indicator[data-mode="ready"].is-active .status-dot {
  background: #82a94f;
  box-shadow:
    inset 0 1px 2px rgba(255, 255, 255, 0.55),
    0 0 0 2px #171410,
    0 0 11px rgba(130, 169, 79, 0.88);
}

.mode-indicator[data-mode="work"].is-active .status-dot {
  background: var(--orange);
  box-shadow:
    inset 0 1px 2px rgba(255, 255, 255, 0.55),
    0 0 0 2px #171410,
    0 0 11px rgba(230, 107, 0, 0.9);
}

.mode-indicator[data-mode="fault"] .status-dot {
  background: #43251f;
}

.mode-indicator.is-active {
  color: #d9d6c7;
}

.meter strong {
  display: flex;
  gap: 3px;
  min-width: 0;
  padding: 4px 5px;
  border: 2px solid #050504;
  background: #0c0b09;
  box-shadow:
    inset 0 2px 8px rgba(0, 0, 0, 0.96),
    0 1px 0 rgba(255, 255, 255, 0.08);
}

.nixie-digit {
  position: relative;
  display: grid;
  width: 25px;
  height: 36px;
  place-items: center;
  overflow: hidden;
  border: 1px solid rgba(158, 75, 37, 0.68);
  border-radius: 48% 48% 40% 40% / 35% 35% 54% 54%;
  color: #ff7a23;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.09), transparent 22% 76%, rgba(255, 255, 255, 0.04)),
    radial-gradient(circle at 50% 55%, rgba(119, 24, 4, 0.38), #160a06 72%);
  font-family: "Arial Narrow", "Courier New", sans-serif;
  font-size: 25px;
  font-stretch: condensed;
  font-weight: 400;
  line-height: 1;
  text-shadow:
    0 0 2px #fff1bd,
    0 0 5px #ff671f,
    0 0 11px rgba(255, 70, 10, 0.92);
  box-shadow:
    inset 0 0 6px rgba(255, 102, 35, 0.18),
    0 0 7px rgba(255, 72, 15, 0.12);
}

.nixie-digit::before,
.nixie-digit::after {
  position: absolute;
  inset: 0;
  content: "";
  pointer-events: none;
}

.nixie-digit::before {
  opacity: 0.32;
  background:
    repeating-linear-gradient(0deg, transparent 0 5px, #27140e 5px 6px),
    repeating-linear-gradient(90deg, transparent 0 7px, #27140e 7px 8px);
}

.nixie-digit::after {
  background: linear-gradient(105deg, transparent 12%, rgba(255, 255, 255, 0.17) 18%, transparent 31%);
}

.screen-bezel {
  position: relative;
  padding: 29px 24px 24px;
  border: 2px solid #050605;
  background:
    radial-gradient(circle at 14% 20%, rgba(255, 255, 255, 0.04) 0 1px, transparent 2px),
    linear-gradient(145deg, #181916, #080908 55%, #20211e);
  box-shadow:
    inset 0 3px 8px rgba(0, 0, 0, 0.8),
    0 2px 0 rgba(255, 255, 255, 0.12);
}

.canvas-wrap {
  position: relative;
  width: min(100%, 700px);
  height: auto;
  aspect-ratio: 1;
  margin: 0 auto;
  overflow: hidden;
  border: 5px solid #070807;
  border-radius: 50%;
  background:
    radial-gradient(circle at 48% 44%, #d2ddd3 0%, #b8cabd 58%, #88a096 100%);
  cursor: crosshair;
  touch-action: none;
  box-shadow:
    inset 0 0 42px rgba(21, 44, 38, 0.7),
    inset 0 0 11px rgba(239, 255, 255, 0.28),
    0 0 0 6px #262721,
    0 0 0 8px #050605,
    0 7px 15px rgba(0, 0, 0, 0.9);
}

.canvas-wrap::before,
.canvas-wrap::after {
  position: absolute;
  z-index: 2;
  inset: 0;
  content: "";
  pointer-events: none;
}

.canvas-wrap::before {
  background:
    radial-gradient(circle at 50% 45%, transparent 48%, rgba(31, 58, 50, 0.34) 100%),
    linear-gradient(115deg, rgba(255, 255, 255, 0.16), transparent 30%);
}

.canvas-wrap::after {
  opacity: 0.16;
  background: repeating-linear-gradient(
    0deg,
    transparent 0 3px,
    rgba(0, 0, 0, 0.23) 3px 4px
  );
}

canvas {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
}

.controls {
  display: flex;
  gap: 32px;
  align-items: flex-end;
  justify-content: space-between;
  min-height: 142px;
  padding: 20px 22px 17px;
  border: 2px solid #050605;
  border-top: 0;
  border-radius: 0 0 6px 6px;
  background:
    radial-gradient(circle at 23% 28%, rgba(255, 255, 255, 0.045) 0 1px, transparent 2px),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.012) 0 1px, transparent 1px 5px),
    linear-gradient(#1e1f1c, #0e0f0d);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    inset 0 -4px 8px rgba(0, 0, 0, 0.55);
}

.button-group {
  display: flex;
  gap: 22px;
  align-items: flex-start;
}

.control-unit {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}

.control-unit > .plate-label {
  display: flex;
  width: 82px;
  min-height: 18px;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.button {
  width: 62px;
  min-width: 62px;
  height: 58px;
  min-height: 58px;
  padding: 0;
  border: 4px solid #050504;
  border-radius: 50%;
  color: transparent;
  background: radial-gradient(circle, #34342f 0 48%, #171815 66%, #080908 100%);
  cursor: pointer;
  box-shadow:
    0 4px 0 #050504,
    0 7px 7px rgba(0, 0, 0, 0.72),
    inset 0 1px 2px rgba(255, 255, 255, 0.22);
  transition: filter 100ms ease, transform 100ms ease, box-shadow 100ms ease;
}

.button:hover {
  filter: brightness(1.08);
}

.button:active {
  transform: translateY(3px);
  box-shadow:
    0 1px 0 #050504,
    0 2px 2px rgba(0, 0, 0, 0.4),
    inset 0 2px 3px rgba(0, 0, 0, 0.2);
}

.button-primary {
  background: radial-gradient(circle, #b94b17 0 48%, #68250d 66%, #270d06 100%);
}

.button-primary.is-running {
  background: radial-gradient(circle, #873421 0 48%, #4b190f 66%, #1e0805 100%);
}

.button-reset {
  background: radial-gradient(circle, #52352c 0 48%, #291713 66%, #0e0706 100%);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.speed-control {
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: center;
  min-width: 235px;
}

.speed-track {
  display: flex;
  gap: 9px;
  align-items: center;
  color: #28231e;
  font-size: 9px;
  font-weight: 800;
}

input[type="range"] {
  width: 170px;
  height: 7px;
  margin: 0;
  border: 1px solid #2e2923;
  border-radius: 0;
  appearance: none;
  background: linear-gradient(#2e2923, #544b3d);
  box-shadow:
    inset 0 2px 3px rgba(0, 0, 0, 0.65),
    0 1px 0 rgba(255, 255, 255, 0.24);
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  width: 30px;
  height: 30px;
  border: 3px solid #201c18;
  border-radius: 50%;
  appearance: none;
  background:
    linear-gradient(90deg, transparent 47%, #d6caa4 48% 52%, transparent 53%) top center / 100% 42% no-repeat,
    repeating-conic-gradient(#3b352e 0deg 8deg, #181512 8deg 16deg);
  box-shadow: 0 3px 4px rgba(0, 0, 0, 0.6);
}

input[type="range"]::-moz-range-thumb {
  width: 26px;
  height: 26px;
  border: 3px solid #201c18;
  border-radius: 50%;
  background: #2a251f;
  box-shadow: 0 3px 4px rgba(0, 0, 0, 0.6);
}

@media (max-width: 860px) {
  .page-shell {
    width: min(calc(100% - 20px), 1180px);
    padding: 10px 0;
  }

  .lab {
    padding: 13px;
  }

  .lab-toolbar {
    align-items: flex-start;
    padding: 13px 12px 15px;
  }

  .model-line {
    flex-direction: column;
    gap: 5px;
  }

  .readouts {
    align-items: flex-end;
  }

  .screen-bezel {
    padding: 24px 12px 13px;
  }

  .canvas-wrap {
    width: min(100%, 560px);
    height: auto;
    aspect-ratio: 1;
    border-radius: 50%;
  }

  .controls {
    flex-direction: column;
    gap: 23px;
    align-items: stretch;
    padding: 16px 12px 18px;
  }

  .button-group {
    display: flex;
    gap: 4px;
    justify-content: space-between;
  }

  .button {
    width: 62px;
  }

  .control-unit {
    min-width: 0;
  }

  .control-unit > .plate-label {
    width: auto;
    min-width: 62px;
    padding-inline: 3px;
    font-size: 7px;
  }

  .speed-control {
    min-width: 0;
  }

  .speed-track {
    width: 100%;
  }

  input[type="range"] {
    flex: 1;
    width: auto;
  }
}

@media (max-width: 650px) {
  .lab-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .model-line {
    flex-direction: row;
    align-items: baseline;
  }

  .readouts,
  .stats {
    width: 100%;
  }

  .readouts {
    gap: 6px;
    flex-wrap: nowrap;
  }

  .stats {
    flex: 1 1 auto;
    gap: 6px;
    width: auto;
    justify-content: space-between;
  }

  .simulation-status {
    gap: 3px;
    padding-inline: 4px;
  }

  .mode-indicator {
    min-width: 31px;
  }

  .nixie-digit {
    width: 19px;
    height: 31px;
    font-size: 21px;
  }
}

@media (max-width: 480px) {
  .lab-toolbar {
    gap: 12px;
  }

  .instrument-id {
    min-width: 0;
  }

  .nameplate {
    min-width: 0;
  }

  .nameplate strong {
    font-size: 18px;
  }

  .serial-number {
    white-space: normal;
  }

  .stats {
    gap: 7px;
  }

  .nixie-digit {
    width: 18px;
    height: 30px;
    font-size: 20px;
  }

  .plate-label {
    font-size: 8px;
  }

  .foot {
    width: 64px;
  }

  .foot-left { left: 32px; }
  .foot-right { right: 32px; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
