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

body {
  background: #1a1a1a;
  background-image:
    radial-gradient(ellipse at 50% 30%, #2a2a2a 0%, #111 100%);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  font-family: monospace;
  padding: 14px 20px;
}

/* ---- Раскладка: панели мануала + калькулятор ---- */
.layout {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) 430px minmax(280px, 1fr);
  grid-template-rows: auto auto;
  column-gap: 20px;
  row-gap: 20px;
  align-items: start;
  width: 100%;
  max-width: none;
}
.manual-left   { grid-column: 1; grid-row: 1; }
.calculator    { grid-column: 2; grid-row: 1; }
.manual-right  { grid-column: 3; grid-row: 1; }
.manual-bottom { grid-column: 1 / -1; grid-row: 2; }

/* На узком экране всё в один столбик */
@media (max-width: 1000px) {
  .layout {
    grid-template-columns: 1fr;
  }
  .manual-left,
  .calculator,
  .manual-right,
  .manual-bottom {
    grid-column: 1;
    grid-row: auto;
    justify-self: center;
    width: 100%;
    max-width: 560px;
  }
  .calculator { max-width: 430px; }
}

/* ---- Стили "бумажных" страниц мануала ---- */
.manual {
  background: #ece6d0;
  background-image:
    repeating-linear-gradient(
      0deg,
      rgba(0,0,0,0.012) 0px,
      rgba(0,0,0,0.012) 1px,
      transparent 1px,
      transparent 3px
    );
  color: #2a2520;
  border-radius: 3px;
  padding: 18px 20px 22px;
  font-family: "Courier New", Courier, monospace;
  font-size: 12.5px;
  line-height: 1.5;
  box-shadow:
    0 0 0 1px #b8b09a,
    0 6px 18px rgba(0,0,0,0.5),
    inset 0 1px 0 rgba(255,255,255,0.6);
  position: relative;
}
.manual::before {
  /* "Уголок" страницы */
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 18px; height: 18px;
  background: linear-gradient(225deg, #1a1a1a 0 50%, #ece6d0 50% 100%);
  border-radius: 0 3px 0 0;
}

.manual h2 {
  font-size: 14px;
  text-align: center;
  letter-spacing: 3px;
  padding: 4px 0 6px;
  margin: 0 0 14px;
  border-bottom: 2px solid #2a2520;
  border-top: 2px solid #2a2520;
  background: #d9d2bd;
}
.manual h3 {
  font-size: 12.5px;
  margin: 14px 0 6px;
  padding: 2px 6px;
  background: #2a2520;
  color: #ece6d0;
  letter-spacing: 1px;
  display: inline-block;
}
.manual h4 {
  font-size: 12.5px;
  margin: 0 0 6px;
  padding: 0;
  color: #1a1510;
  font-weight: bold;
}
.manual p {
  margin: 0 0 8px;
}
.manual p.hint {
  font-style: italic;
  font-size: 11.5px;
  color: #5a5040;
  margin-bottom: 14px;
  padding: 6px 10px;
  border-left: 3px solid #8a7c5e;
  background: rgba(0,0,0,0.04);
}
.manual p.setup {
  font-size: 11.5px;
  color: #5a5040;
  margin-bottom: 6px;
}
.manual p.note {
  font-size: 11.5px;
  color: #5a5040;
  margin-top: 6px;
  font-style: italic;
}

/* Описания клавиш в формате dl */
.manual dl {
  margin: 0 0 8px;
}
.manual dt {
  font-weight: bold;
  margin-top: 6px;
  color: #1a1510;
}
.manual dd {
  margin: 0 0 4px 14px;
  font-size: 12px;
  color: #3a3025;
}

/* "Клавиша" inline */
.manual kbd {
  display: inline-block;
  font-family: "Courier New", Courier, monospace;
  font-size: 11px;
  font-weight: bold;
  background: linear-gradient(180deg, #fff 0%, #d4cdb4 100%);
  color: #1a1510;
  border: 1px solid #6a5e44;
  border-radius: 3px;
  padding: 1px 5px;
  margin: 0 1px;
  min-width: 14px;
  text-align: center;
  box-shadow:
    0 1px 0 #6a5e44,
    inset 0 1px 0 rgba(255,255,255,0.6);
  line-height: 1.2;
  vertical-align: baseline;
}
.manual code {
  font-family: "Courier New", Courier, monospace;
  background: rgba(0,0,0,0.06);
  padding: 1px 4px;
  border-radius: 2px;
}

/* Примеры */
.examples {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 18px;
  margin-top: 12px;
}
.example {
  background: #f3eed8;
  border: 1px solid #b8b09a;
  border-radius: 3px;
  padding: 12px 14px;
}
.example .steps {
  display: grid;
  grid-template-columns: auto auto 1fr;
  column-gap: 12px;
  margin-top: 4px;
  font-size: 12px;
}
.example .steps > .keys,
.example .steps > .result,
.example .steps > .note {
  padding: 3px 0;
  border-bottom: 1px dotted #b8b09a;
  align-self: center;
}
.example .steps > .keys {
  white-space: nowrap;
}
.example .steps > .result {
  font-weight: bold;
  color: #cc4400;
  white-space: nowrap;
  text-align: right;
  font-family: "Courier New", Courier, monospace;
}
.example .steps > .note {
  font-size: 11px;
  color: #5a5040;
  font-style: italic;
}
/* Убрать рамку у последней строки (последние 3 ячейки) */
.example .steps > *:nth-last-child(-n+3) {
  border-bottom: none;
}

.calculator {
  width: 430px;
  background: linear-gradient(180deg, #5a5a5a 0%, #484848 100%);
  border-radius: 6px 6px 10px 10px;
  box-shadow:
    0 0 0 1px #444,
    0 8px 40px rgba(0,0,0,0.7),
    inset 0 1px 0 rgba(255,255,255,0.1);
  position: relative;
  padding-bottom: 16px;
}

/* -- Верхняя "крышка" -- */
.top-lid {
  height: 80px;
  background:
    linear-gradient(#888, #888) 30px 8px  / calc(100% - 60px) 2px no-repeat,
    linear-gradient(#888, #888) 30px 16px / calc(100% - 60px) 2px no-repeat,
    linear-gradient(#888, #888) 30px 24px / calc(100% - 60px) 2px no-repeat,
    linear-gradient(#888, #888) 30px 32px / calc(100% - 60px) 2px no-repeat,
    linear-gradient(180deg, #e2dfd6 0%, #ccc9c0 100%);
  border-radius: 6px 6px 0 0;
  border-bottom: 2px solid #aaa;
  position: relative;
}

.top-lid::before, .top-lid::after { content: none; }

/* -- Вентиляция -- */
.vents {
  position: absolute;
  bottom: 10px;
  left: ё0px; right: 30px;
  display: flex;
  gap: 4px;
  justify-content: center;
}
.vent {
  width: 3px;
  height: 20px;
  background: rgba(0,0,0,0.2);
  border-radius: 1px;
}

/* -- Дисплей -- */
.display-section {
  background: #2a2a28;
  margin: 0 28px;
  border-radius: 4px 4px 0 0;
  padding: 10px 8px 6px;
  position: relative;
  box-shadow: inset 0 2px 8px rgba(0,0,0,0.8);
  border: 1px solid #1a1a18;
  border-bottom: none;
}

/* Nixie-tube display */
.nixie-display {
  background: #0a0a08;
  border-radius: 3px;
  padding: 8px 8px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 1px;
  border: 1px solid #333;
  box-shadow:
    inset 0 2px 10px rgba(0,0,0,0.9),
    0 0 20px rgba(255, 80, 0, 0.08);
  position: relative;
}

.nixie-display::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg,
    rgba(255,100,0,0.03) 0%,
    transparent 50%,
    rgba(0,0,0,0.2) 100%);
  pointer-events: none;
}

/* Разряды nixie */
.nixie-digit {
  font-family: "Courier New", Courier, monospace;
  font-size: 28px;
  width: 24px;
  text-align: center;
  color: transparent;
  position: relative;
  line-height: 1;
  flex-shrink: 0;
  font-variant-numeric: lining-nums;
  font-feature-settings: "zero" 0, "ss01" 0;
}

.nixie-digit .glow-char {
  position: relative;
  display: inline-block;
  color: #ff6600;
  text-shadow:
    0 0 4px #ff6600,
    0 0 10px rgba(255, 100, 0, 0.8),
    0 0 20px rgba(255, 60, 0, 0.4);
  filter: blur(0.3px);
  transition: opacity 0.05s;
}

.nixie-digit.dim .glow-char {
  color: #4a1500;
  text-shadow: none;
  filter: none;
}

/* Запятая -- отдельная лампа (одна из 11 между разрядами) */
.nixie-dot {
  font-family: monospace;
  font-size: 28px;
  width: 3px;
  text-align: center;
  flex-shrink: 0;
  position: relative;
  line-height: 1;
}
.nixie-dot .glow-char {
  position: absolute;
  bottom: -2px;
  left: -3px;
  color: transparent;
}
.nixie-dot.visible .glow-char {
  color: #ff6600;
  text-shadow: 0 0 4px #ff6600, 0 0 10px rgba(255,100,0,0.8);
}

/* Мерцание при ошибке */
@keyframes nixie-flicker {
  0%,100% { opacity: 1; }
  25% { opacity: 0.3; }
  50% { opacity: 0.9; }
  75% { opacity: 0.2; }
}
.nixie-display.error-flash .nixie-digit .glow-char,
.nixie-display.error-flash .nixie-dot .glow-char {
  animation: nixie-flicker 0.15s infinite;
}

/* клавиатура*/
.keyboard-section {
  background: transparent;
  margin: 0;
  padding: 14px 56px 12px 56px;
  border-radius: 0 0 4px 4px;
  border: none;
  position: relative;
}

/* Три полосы в верхней части клавиатуры */
.keyboard-section::before {
  content: '';
  position: absolute;
  top: 8px; left: 30px; right: 30px;
  height: 2px;
  background: #2a2a2a;
  box-shadow:
    0 8px 0 0 #2a2a2a,
    0 16px 0 0 #2a2a2a;
}

/* Шильдик */
.badge {
  position: absolute;
  top: 44px;
  right: 56px;
  width: 84px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #c8c4b8, #a8a49a);
  border: 1px solid #888;
  border-radius: 3px;
  padding: 0 6px;
  font-size: 14px;
  font-weight: bold;
  color: #333;
  letter-spacing: 2px;
  font-family: monospace;
  box-shadow: 0 1px 3px rgba(0,0,0,0.4);
}

/* тумблеры*/
.side-switch {
  position: absolute;
  background: linear-gradient(180deg, #2a2a2a, #1a1a1a);
  border: 1px solid #111;
  border-radius: 3px;
  cursor: pointer;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  box-shadow:
    inset 0 1px 2px rgba(0,0,0,0.6),
    0 1px 2px rgba(0,0,0,0.4);
  outline: none;
}
.side-switch:hover { filter: brightness(1.4); }
.side-switch:focus { outline: none; }

/* Рычажок внутри тумблера */
.switch-knob {
  display: block;
  width: 100%;
  height: 7px;
  background: linear-gradient(180deg, #f0ecd8 0%, #c8c4b0 50%, #908c78 100%);
  border-radius: 2px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.6);
  position: absolute;
  left: 0;
  transition: top 0.12s ease-out;
}

/* Левый тумблер ВКЛ ВЫКЛ */
.side-switch-left {
  left: 32px;
  top: 50%;
  transform: translateY(-50%);
  width: 10px;
  height: 22px;
}
.side-switch-left[data-pos="0"] .switch-knob { top: 16px; }
.side-switch-left[data-pos="1"] .switch-knob { top: 2px; }

/* Правый тумблер: 3 положения
   T (top)    — все операции 3 знака
   M (middle) — × и ÷ полная точность, + и − 3 знака
   B (bottom) — все операции 4 знака без округления */
.side-switch-right {
  right: 32px;
  top: 135px;
  width: 12px;
  height: 40px;
}
.side-switch-right[data-pos="T"] .switch-knob { top: 2px; }
.side-switch-right[data-pos="M"] .switch-knob { top: 18px; }
.side-switch-right[data-pos="B"] .switch-knob { top: 35px; }

/* символ над правым тумблером*/
.prec-label {
  position: absolute;
  right: 32px;
  top: 120px;
  width: 12px;
  text-align: center;
  font-family: monospace;
  font-size: 11px;
  font-weight: bold;
  color: #e0e0e0;
  text-shadow: 0 1px 1px rgba(0,0,0,0.5);
  pointer-events: none;
  line-height: 1;
}

/* Кнопочная сетка */
.key-grid {
  display: grid;
  grid-template-columns:
    3fr 3fr
    0.5fr
    1fr 1fr 1fr 1fr 1fr 1fr
    0.5fr
    3fr 3fr;
  grid-template-rows: repeat(4, auto);
  gap: 5px;
  margin-top: 30px;
}

/* Базовая кнопка */
.btn {
  height: 36px;
  border-radius: 5px;
  border: none;
  cursor: pointer;
  font-family: monospace;
  font-size: 13px;
  font-weight: bold;
  position: relative;
  transition: transform 0.06s, box-shadow 0.06s, filter 0.06s;
  user-select: none;
  -webkit-user-select: none;
  outline: none;
  letter-spacing: 0.5px;
}

/* Светлая кнопка */
.btn-cream {
  background: linear-gradient(180deg, #e8e4da 0%, #d4d0c6 100%);
  color: #222;
  box-shadow:
    0 3px 0 #8a8880,
    0 4px 6px rgba(0,0,0,0.5),
    inset 0 1px 0 rgba(255,255,255,0.6);
  border: 1px solid #aaa;
}
.btn-cream:hover { filter: brightness(1.05); }
.btn-cream:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #8a8880, 0 2px 3px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.3);
}

/* Красная кнопка */
.btn-red {
  background: linear-gradient(180deg, #cc2200 0%, #991900 100%);
  color: #fff;
  box-shadow:
    0 3px 0 #5a0d00,
    0 4px 6px rgba(0,0,0,0.5),
    inset 0 1px 0 rgba(255,100,80,0.4);
  border: 1px solid #881500;
}
.btn-red:hover { filter: brightness(1.1); }
.btn-red:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #5a0d00, 0 2px 3px rgba(0,0,0,0.4);
}

/* Тёмная кнопка */
.btn-dark {
  background: linear-gradient(180deg, #3a3a3a 0%, #282828 100%);
  color: #ddd;
  box-shadow:
    0 3px 0 #111,
    0 4px 6px rgba(0,0,0,0.5),
    inset 0 1px 0 rgba(255,255,255,0.1);
  border: 1px solid #222;
}
.btn-dark:hover { filter: brightness(1.15); }
.btn-dark:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #111, 0 2px 3px rgba(0,0,0,0.4);
}

/* Ряд 1 */
.btn-C    { grid-column: 1;           grid-row: 1; }
.btn-CK   { grid-column: 2;           grid-row: 1; }
.btn-7    { grid-column: 4 / span 2;  grid-row: 1; }
.btn-8    { grid-column: 6 / span 2;  grid-row: 1; }
.btn-9    { grid-column: 8 / span 2;  grid-row: 1; }

/* Ряд 2 */
.btn-M    { grid-column: 1;           grid-row: 2; }
.btn-DIV  { grid-column: 2;           grid-row: 2; }
.btn-4    { grid-column: 4 / span 2;  grid-row: 2; }
.btn-5    { grid-column: 6 / span 2;  grid-row: 2; }
.btn-6    { grid-column: 8 / span 2;  grid-row: 2; }

/* Ряд 3 */
.btn-SUB   { grid-column: 1;           grid-row: 3; }
.btn-MUL   { grid-column: 2;           grid-row: 3; }
.btn-1     { grid-column: 4 / span 2;  grid-row: 3; }
.btn-2     { grid-column: 6 / span 2;  grid-row: 3; }
.btn-3     { grid-column: 8 / span 2;  grid-row: 3; }
.btn-MINUS { grid-column: 11;          grid-row: 3; }
.btn-CA    { grid-column: 12;          grid-row: 3; }

/* Ряд 4 */
.btn-ADD  { grid-column: 1;           grid-row: 4; }
.btn-EQ   { grid-column: 2;           grid-row: 4; }
.btn-0    { grid-column: 4 / span 3;  grid-row: 4; }
.btn-DOT  { grid-column: 7 / span 3;  grid-row: 4; }
.btn-PLUS { grid-column: 11;          grid-row: 4; }
.btn-MR   { grid-column: 12;          grid-row: 4; }

/* Иконки на кнопках */
.sym-circle { font-size: 20px; line-height: 1; }

/* Ромб на кнопке MR сжат */
.sym-diamond {
  display: inline-block;
  font-size: 20px;
  line-height: 1;
  transform: scaleX(0.65) scaleY(1.1);
  transform-origin: center;
}

/* Подпись снизу */
.footer-label {
  text-align: center;
  color: #555;
  font-size: 10px;
  letter-spacing: 3px;
  margin-top: 18px;
  text-transform: uppercase;
}
