:root {
  color-scheme: light;
  font-family: "Segoe UI", Arial, sans-serif;
  background:
    linear-gradient(180deg, #d7d2c8 0%, #c5bfb2 100%);
  color: #121212;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.75), transparent 22%),
    linear-gradient(180deg, #ddd8cf 0%, #c9c3b8 100%);
}

button {
  font: inherit;
}

button:focus {
  outline: none;
}

.page {
  min-height: 100vh;
  display: grid;
  justify-content: center;
  gap: 28px;
  padding: 28px 18px 40px;
}

.iskra {
  width: min(1080px, 100%);
  background: linear-gradient(180deg, #2f3438 0%, #202428 100%);
  border-radius: 18px 18px 34px 34px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow:
    0 24px 60px rgba(0, 0, 0, 0.32),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  position: relative;
  overflow: hidden;
}

.iskra::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 44px;
  background: linear-gradient(180deg, #d7d1c4 0%, #f2efe7 100%);
}

.topDeck {
  display: grid;
  grid-template-columns: 72px 1fr auto;
  align-items: start;
  gap: 18px;
  padding: 22px 28px 10px;
}

.powerToggle {
  width: 32px;
  height: 18px;
  border-radius: 4px;
  background: linear-gradient(180deg, #1b1f22 0%, #353b40 100%);
  box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.12);
}

.speakerField {
  justify-self: stretch;
  min-height: 80px;
  background-image:
    radial-gradient(circle, rgba(188, 196, 202, 0.32) 1.6px, transparent 1.7px);
  background-size: 18px 14px;
  opacity: 0.9;
}

.brandPlate {
  margin-top: 10px;
  padding: 6px 10px;
  background: #f4f4f4;
  color: #2b2b2b;
  border-radius: 4px;
  font-weight: 700;
  letter-spacing: 0;
}

.displayWindow {
  margin: 0 28px;
  background:
    linear-gradient(180deg, rgba(12, 17, 20, 0.98) 0%, rgba(26, 32, 36, 0.95) 100%);
  border-radius: 16px;
  padding: 18px 20px 24px;
  display: grid;
  grid-template-columns: 64px 1fr;
  align-items: center;
  gap: 18px;
  box-shadow:
    inset 0 4px 10px rgba(0, 0, 0, 0.55),
    inset 0 -1px 0 rgba(255, 255, 255, 0.03);
}

.displayLegend {
  display: grid;
  gap: 14px;
}

.indicatorLamp {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid rgba(119, 240, 238, 0.22);
  color: rgba(119, 240, 238, 0.25);
  background: rgba(70, 132, 133, 0.08);
  font-size: 1.1rem;
}

.lampActive {
  color: #9efeff;
  box-shadow:
    0 0 12px rgba(81, 232, 235, 0.7),
    inset 0 0 12px rgba(81, 232, 235, 0.24);
}

.tubeDisplay {
  display: grid;
  grid-template-columns: repeat(16, minmax(0, 1fr));
  gap: 6px;
  align-items: stretch;
  transform: translateZ(0);
  backface-visibility: hidden;
}

.tubeCell {
  min-height: 96px;
  display: grid;
  place-items: center;
  font-family: "Courier New", monospace;
  font-size: clamp(1.9rem, 4vw, 3.3rem);
  color: #a5ffff;
  text-shadow:
    0 0 12px rgba(99, 248, 252, 0.9),
    0 0 28px rgba(99, 248, 252, 0.4);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(94, 118, 124, 0.06) 0%, rgba(17, 20, 24, 0.02) 100%);
  position: relative;
  contain: content;
  transform: translateZ(0);
  backface-visibility: hidden;
}

.tubeCellDot::after {
  content: "";
  position: absolute;
  right: 2px;
  top: 62px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #a5ffff;
  box-shadow: 0 0 8px rgba(99, 248, 252, 0.85);
}

.controlDeck {
  display: grid;
  grid-template-columns: 78px 160px 210px 230px;
  gap: 18px;
  align-items: start;
  padding: 24px 28px 76px;
}

.precisionUnit {
  display: grid;
  justify-items: center;
  gap: 10px;
}

.precisionLabel {
  color: #efe6cd;
  font-weight: 700;
}

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

.precisionStep {
  width: 54px;
  min-height: 30px;
  border: none;
  border-radius: 4px;
  background: linear-gradient(180deg, #f2efe7 0%, #c7bda3 100%);
  color: #2e2c26;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.18);
  cursor: pointer;
}

.precisionActive {
  background: linear-gradient(180deg, #e95b47 0%, #a91f18 100%);
  color: #fff4ef;
}

.memoryBoard,
.digitBoard,
.operationBoard {
  display: grid;
  gap: 8px;
}

.memoryBoard {
  grid-template-columns: repeat(2, 70px);
}

.digitBoard {
  grid-template-columns: repeat(3, 62px);
}

.operationBoard {
  grid-template-columns: repeat(3, 62px);
}

.key {
  min-height: 52px;
  border: none;
  border-radius: 7px;
  cursor: pointer;
  color: #2b2723;
  background: linear-gradient(180deg, #f5f2e8 0%, #d8cfba 100%);
  box-shadow:
    0 2px 0 rgba(0, 0, 0, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.55);
  font-weight: 600;
}

.key:active {
  transform: translateY(1px);
}

.key:focus-visible,
.precisionStep:focus-visible {
  box-shadow:
    0 0 0 2px rgba(165, 255, 255, 0.42),
    0 2px 0 rgba(0, 0, 0, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.55);
}

.keyMemory {
  background: linear-gradient(180deg, #ddd3b8 0%, #b8ad90 100%);
}

.keyDigit {
  background: linear-gradient(180deg, #f7f4ea 0%, #eadfc0 100%);
  font-size: 1.2rem;
}

.keyOperation {
  background: linear-gradient(180deg, #d6cec0 0%, #aea594 100%);
}

.keyAccent {
  background: linear-gradient(180deg, #ea5c48 0%, #ad2018 100%);
  color: #fff6f0;
}

.keyZero {
  grid-column: span 2;
}

.servicePanel {
  width: min(1080px, 100%);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  overflow: hidden;
}

.serviceBlock {
  background: rgba(255, 255, 255, 0.82);
  border-radius: 14px;
  padding: 16px 18px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  min-height: 132px;
  min-width: 0;
  overflow: hidden;
  display: grid;
  align-content: start;
}

.serviceBlock h2,
.serviceBlock p,
.memoryState {
  margin: 0;
}

.serviceBlock h2 {
  margin-bottom: 10px;
  font-size: 1rem;
}

.memoryState {
  padding-left: 18px;
  display: grid;
  gap: 6px;
}

.expressionText {
  display: grid;
  align-content: start;
  gap: 4px;
  margin-top: 6px;
  max-width: 100%;
  max-height: 74px;
  overflow-y: auto;
  overflow-x: hidden;
  padding-bottom: 2px;
}

.expressionPrefix {
  display: block;
}

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

.expressionLine {
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  max-width: 100%;
}

.memoryActive {
  font-weight: 700;
}

@media (max-width: 980px) {
  .displayWindow {
    grid-template-columns: 1fr;
  }

  .displayLegend {
    grid-auto-flow: column;
    justify-content: start;
  }

  .controlDeck {
    grid-template-columns: 1fr;
  }

  .servicePanel {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .topDeck {
    grid-template-columns: 40px 1fr;
  }

  .brandPlate {
    grid-column: span 2;
    justify-self: start;
  }

  .displayWindow {
    margin: 0 16px;
    padding: 16px;
  }

  .controlDeck {
    padding: 20px 16px 70px;
  }

  .memoryBoard,
  .digitBoard,
  .operationBoard {
    justify-content: start;
  }
}

/* Equal side columns keep the calculator itself at the viewport center. */
.page {
  grid-template-columns: minmax(0, 1fr) 790px minmax(0, 1fr);
  grid-template-areas: ". calculator help" ". service help";
  grid-template-rows: auto 1fr;
  align-items: start;
  align-content: start;
  gap: 24px;
  padding: 24px 24px 32px;
}
.iskra { grid-area: calculator; width: 100%; }
.servicePanel { grid-area: service; width: 100%; }
.buttonHelp {
  grid-area: help;
  width: 100%;
  max-width: 650px;
  min-width: 0;
  padding: 20px;
  border: 1px solid rgba(255,255,255,.7);
  border-radius: 18px;
  background: #f8f6f0;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  line-height: 1.4;
}
.buttonHelp h2 { margin: 0 0 6px; font-size: 1.3rem; font-weight: 650; letter-spacing: -.02em; }
.helpIntro { margin: 0; color: #69655c; font-size: .85rem; }
.helpList { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 16px 0 14px; }
.helpItem { padding: 10px; border: 1px solid #e6e0d4; border-radius: 10px; background: #fffdf8; }
.helpItem dt { display: flex; align-items: center; gap: 8px; font-size: .9rem; font-weight: 650; }
.helpKey { flex-shrink: 0; min-width: 38px; padding: 3px 6px; border-radius: 5px; background: #e9e2d3; color: #39352d; text-align: center; white-space: nowrap; font-size: .85rem; }
.helpItem dd { margin: 5px 0 0; color: #514d44; font-size: .85rem; }
.helpExample { display: block; margin-top: 5px; color: #285b55; font-size: .8rem; font-variant-numeric: tabular-nums; }
@media (max-width: 1760px) {
  .page { grid-template-columns: minmax(0, 790px); grid-template-areas: "calculator" "service" "help"; grid-template-rows: auto auto auto; }
  .buttonHelp { max-width: none; }
}
@media (max-width: 560px) {
  .page { padding: 16px 12px 24px; }
  .buttonHelp { padding: 18px; }
  .helpList { grid-template-columns: 1fr; }
}
