:root {
  color-scheme: dark;
  --bg: #071019;
  --bg-soft: #0c1722;
  --ink: #f2f6f7;
  --muted: #91a1ac;
  --cyan: #63e6be;
  --cyan-soft: rgba(99, 230, 190, 0.12);
  --orange: #ff9f43;
  --red: #f05c63;
  --device: #d9d9d1;
  --device-deep: #aaa9a2;
  --key: #24262a;
  --key-edge: #0b0d10;
  --screen: #afbaa0;
  --screen-ink: #142018;
  --sans: "DM Sans", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", "Courier New", monospace;
  --ease-spring: cubic-bezier(0.34, 1.35, 0.64, 1);
  --ease-ios: cubic-bezier(0.22, 1, 0.36, 1);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  margin: 0;
  overflow-x: hidden;
  background:
    linear-gradient(rgba(255, 255, 255, 0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.018) 1px, transparent 1px),
    var(--bg);
  background-size: 48px 48px;
  color: var(--ink);
  font-family: var(--sans);
  overscroll-behavior-x: none;
}

button,
input,
select {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.page-glow {
  position: fixed;
  z-index: -1;
  width: 520px;
  height: 520px;
  border-radius: 50%;
  filter: blur(120px);
  pointer-events: none;
}

.page-glow--one {
  top: -260px;
  right: -120px;
  background: rgba(34, 126, 151, 0.23);
}

.page-glow--two {
  bottom: -360px;
  left: -150px;
  background: rgba(69, 202, 156, 0.13);
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(1180px, calc(100% - 40px));
  min-height: 84px;
  margin: 0 auto;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand {
  display: inline-flex;
  gap: 11px;
  align-items: center;
  color: var(--ink);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.03em;
  text-decoration: none;
}

.brand__mark {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border: 1px solid rgba(99, 230, 190, 0.42);
  border-radius: 10px;
  background: var(--cyan-soft);
  color: var(--cyan);
  font-family: Georgia, serif;
}

.brand__accent {
  color: var(--cyan);
}

.header-meta {
  display: flex;
  gap: 9px;
  align-items: center;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 12px var(--cyan);
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 0.88fr) minmax(430px, 1.12fr);
  gap: clamp(42px, 7vw, 110px);
  align-items: center;
  width: min(1180px, calc(100% - 40px));
  min-height: calc(100vh - 84px);
  margin: 0 auto;
  padding: 70px 0 90px;
}

.hero-copy {
  max-width: 570px;
}

.eyebrow {
  margin: 0 0 18px;
  color: var(--cyan);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  text-wrap: pretty;
}

h1 {
  margin: 0;
  font-size: clamp(43px, 5.4vw, 76px);
  font-weight: 600;
  line-height: 0.98;
  letter-spacing: -0.065em;
}

h1 span {
  color: #8da0aa;
}

.hero-copy__intro {
  max-width: 550px;
  margin: 30px 0 0;
  color: #a7b4bd;
  font-size: clamp(16px, 1.5vw, 19px);
  line-height: 1.7;
}

.feature-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: 28px;
}

.feature-pills span {
  padding: 9px 12px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.025);
  color: #c4ced4;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.exam-note {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: start;
  max-width: 540px;
  margin-top: 34px;
  padding-top: 22px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.exam-note__icon {
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 50%;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
}

.exam-note p {
  margin: 0;
  color: #7f909b;
  font-size: 12px;
  line-height: 1.65;
}

.exam-note strong {
  color: #c8d1d6;
  font-weight: 600;
}

.calculator-stage {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  padding: 26px 22px 0;
}

.calculator-stage::before {
  position: absolute;
  z-index: -1;
  inset: 12% 0 9%;
  border: 1px solid rgba(255, 255, 255, 0.055);
  border-radius: 36px;
  background: rgba(255, 255, 255, 0.018);
  content: "";
  transform: rotate(-2deg);
}

.stage-label {
  display: flex;
  justify-content: space-between;
  width: min(100%, 480px);
  margin: 0 0 10px;
  color: #52636f;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.12em;
}

.calculator {
  position: relative;
  width: min(100%, 480px);
  padding: 27px 25px 22px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 32px 32px 42px 42px;
  background:
    linear-gradient(100deg, transparent 0 25%, rgba(255, 255, 255, 0.24) 35%, transparent 50%),
    linear-gradient(145deg, #f0f0eb, var(--device) 52%, #bdbdb6);
  box-shadow:
    0 2px 0 #fff inset,
    0 -5px 0 #8d8d87 inset,
    0 6px 0 #3d4145,
    0 28px 70px rgba(0, 0, 0, 0.46);
  color: #1d2226;
}

.calculator::after {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.06'/%3E%3C/svg%3E");
  content: "";
  mix-blend-mode: multiply;
  opacity: 0.32;
}

.calculator > * {
  position: relative;
  z-index: 1;
}

.calculator__topline {
  display: grid;
  grid-template-columns: 1fr 108px 1.15fr;
  gap: 13px;
  align-items: center;
  min-height: 48px;
}

.maker,
.model {
  display: flex;
  flex-direction: column;
}

.maker__name {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.06em;
}

.maker__series,
.model small {
  margin-top: 3px;
  color: #60676a;
  font-family: var(--mono);
  font-size: 7px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.model {
  align-items: end;
  text-align: right;
}

.model strong {
  font-family: Georgia, serif;
  font-size: 19px;
  font-style: italic;
  font-weight: 600;
}

.model strong span {
  color: #374957;
}

.device-battery {
  display: flex;
  gap: 7px;
  align-items: center;
  justify-content: center;
  min-width: 0;
  height: 31px;
  color: #34424a;
  font-family: var(--mono);
}

.device-battery__icon {
  position: relative;
  display: block;
  width: 50px;
  height: 24px;
  padding: 3px;
  border: 3px solid #777970;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.18);
  box-shadow: 0 1px 2px rgba(255, 255, 255, 0.8) inset, 0 1px 2px rgba(0, 0, 0, 0.25);
}

.device-battery__icon::after {
  position: absolute;
  top: 6px;
  right: -7px;
  width: 4px;
  height: 8px;
  border-radius: 0 2px 2px 0;
  background: #777970;
  content: "";
}

.device-battery__track {
  display: block;
  width: 100%;
  height: 100%;
  overflow: hidden;
  border-radius: 2px;
  background: rgba(63, 72, 68, 0.16);
}

.device-battery__fill {
  display: block;
  width: 0;
  height: 100%;
  border-radius: 2px;
  background: #45b995;
  transition: width 320ms ease, background 180ms ease;
}

.device-battery__bolt {
  position: absolute;
  top: 50%;
  left: 50%;
  display: none;
  color: #fff;
  font-size: 12px;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.55));
  transform: translate(-50%, -50%);
}

.device-battery__text {
  min-width: 29px;
  overflow: hidden;
  font-size: 9px;
  font-weight: 700;
  text-align: right;
  text-overflow: clip;
  white-space: nowrap;
}

.device-battery.is-low .device-battery__fill { background: #e65b61; }
.device-battery.is-charging .device-battery__fill { background: #45b995; }
.device-battery.is-charging .device-battery__bolt { display: block; }
.device-battery.is-unavailable { opacity: 0.6; }
.device-battery.is-unavailable .device-battery__track { background: repeating-linear-gradient(135deg, rgba(70, 78, 75, 0.2) 0 3px, transparent 3px 6px); }

.display {
  height: 126px;
  margin-top: 11px;
  padding: 10px 14px 14px;
  overflow: hidden;
  border: 8px solid #aaa99f;
  border-radius: 9px;
  background:
    repeating-linear-gradient(0deg, rgba(18, 29, 21, 0.018) 0 1px, transparent 1px 3px),
    var(--screen);
  box-shadow:
    0 3px 8px rgba(0, 0, 0, 0.52) inset,
    0 -1px 1px rgba(255, 255, 255, 0.7) inset,
    0 2px 1px #fff;
  color: var(--screen-ink);
  font-family: var(--mono);
}

.display__indicators {
  display: flex;
  gap: 12px;
  height: 16px;
  font-size: 8px;
  font-weight: 700;
  opacity: 0.95;
}

.display__indicators span:not(.is-on) {
  opacity: 0.14;
}

#format-indicator,
#mode-indicator {
  margin-left: auto;
  opacity: 0.72;
}

#format-indicator + #mode-indicator {
  margin-left: 0;
}

.display__expression,
.display__result {
  display: block;
  width: 100%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: clip;
  letter-spacing: -0.045em;
}

.display__expression {
  height: 33px;
  padding-top: 5px;
  font-size: 18px;
  font-weight: 500;
}

.display__result {
  height: 45px;
  border: 0;
  background: transparent;
  color: inherit;
  font-size: 30px;
  font-weight: 600;
  line-height: 1.25;
  text-align: right;
}

.cursor {
  display: inline-block;
  width: 2px;
  height: 1.05em;
  margin: 0 -1px;
  background: currentColor;
  vertical-align: -0.15em;
  animation: blink 1s steps(1) infinite;
}

@keyframes blink {
  50% { opacity: 0; }
}

.utility-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1.65fr 1fr 1fr;
  gap: 10px;
  align-items: center;
  margin: 18px 5px 16px;
}

.utility-key {
  position: relative;
  height: 35px;
  border: 0;
  border-radius: 12px 12px 16px 16px;
  background: linear-gradient(#aaa9a2, #888781);
  box-shadow: 0 3px 0 #585a59, 0 1px 0 #e9e9e5 inset;
  color: #20252a;
  cursor: pointer;
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 700;
}

.utility-key--orange { color: #a35d0b; }
.utility-key--red { color: #bb2635; }

.utility-key__alt {
  position: absolute;
  top: -12px;
  left: 50%;
  color: #a56d28;
  font-size: 6px;
  transform: translateX(-50%);
}

.replay-pad {
  display: grid;
  grid-template-columns: 21px 1fr 21px;
  grid-template-rows: 18px 23px 18px;
  min-height: 68px;
  padding: 2px;
  border: 2px solid #898983;
  border-radius: 50%;
  background: linear-gradient(145deg, #bab9b2, #8f8e87);
  box-shadow: 0 2px 0 #f4f4ef inset, 0 3px 1px #666761;
}

.replay-pad button {
  border: 0;
  background: transparent;
  color: #646762;
  cursor: pointer;
  font-size: 9px;
}

.replay-pad button:first-child { grid-column: 2; grid-row: 1; }
.replay-pad button:nth-child(2) { grid-column: 1; grid-row: 2; }
.replay-pad__center {
  grid-column: 2;
  grid-row: 2;
  align-self: center;
  color: #686b68;
  font-family: var(--mono);
  font-size: 7px;
  font-weight: 700;
  text-align: center;
}
.replay-pad button:nth-child(4) { grid-column: 3; grid-row: 2; }
.replay-pad button:last-child { grid-column: 2; grid-row: 3; }

.keypad {
  display: grid;
  grid-template-columns: repeat(30, 1fr);
  gap: 12px 8px;
}

.keypad > span {
  grid-column: span 5;
}

.calc-key {
  position: relative;
  grid-column: span 5;
  min-width: 0;
  height: 39px;
  padding: 0 2px;
  border: 1px solid #57595c;
  border-radius: 10px 10px 14px 14px;
  background: linear-gradient(145deg, #3a3b3e, #181a1d 72%);
  box-shadow:
    0 4px 0 var(--key-edge),
    0 1px 0 rgba(255, 255, 255, 0.46) inset,
    0 5px 8px rgba(0, 0, 0, 0.17);
  color: #f5f4ee;
  cursor: pointer;
  font-family: var(--sans);
  font-size: 16px;
  font-weight: 600;
  transition: transform 80ms ease, box-shadow 80ms ease, filter 100ms ease;
}

.calc-key[data-size="number"] {
  grid-column: span 6;
  height: 45px;
  font-size: 23px;
}

.calc-key__shift,
.calc-key__alpha,
.calc-key__context {
  position: absolute;
  top: -11px;
  max-width: 100%;
  overflow: hidden;
  font-family: var(--mono);
  font-size: 6px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
}

.calc-key__shift {
  left: 2px;
  color: #a66c1e;
}

.calc-key__alpha {
  right: 2px;
  color: #bf3b49;
}

.calc-key__context {
  left: 50%;
  color: #287b61;
  transform: translateX(-50%);
}

.calc-key__context--stat {
  color: #376a8b;
}

.calc-key__context--complex {
  color: #76517f;
}

.calc-key--orange {
  background: linear-gradient(145deg, #ff9a31, #e96e14 72%);
  border-color: #ec8b2c;
  box-shadow: 0 4px 0 #83320c, 0 1px 0 #ffd0a4 inset;
}

.calc-key--danger {
  color: #ff6471;
}

.calc-key--execute {
  font-size: 16px !important;
  letter-spacing: -0.05em;
}

@media (hover: hover) {
  .calc-key:hover,
  .utility-key:hover,
  .replay-pad button:hover {
    filter: brightness(1.12);
  }
}

.calc-key:active,
.calc-key.is-pressed {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--key-edge), 0 1px 0 rgba(255, 255, 255, 0.2) inset;
}

.utility-key:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #585a59;
}

button:focus-visible,
a:focus-visible {
  outline: 3px solid var(--cyan);
  outline-offset: 3px;
}

.calculator__footer {
  display: flex;
  justify-content: space-between;
  margin-top: 19px;
  color: #666b6b;
  font-family: var(--mono);
  font-size: 6px;
  font-weight: 600;
  letter-spacing: 0.08em;
}

.keyboard-hint {
  margin: 22px 0 0;
  color: #61717c;
  font-family: var(--mono);
  font-size: 9px;
}

.mode-workbench {
  width: min(100%, 700px);
  margin-top: 24px;
  padding: 24px;
  border: 1px solid rgba(99, 230, 190, 0.18);
  border-radius: 20px;
  background: linear-gradient(145deg, rgba(17, 31, 42, 0.98), rgba(9, 20, 29, 0.98));
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.28);
  color: #dce5e8;
}

.mode-workbench[hidden] { display: none; }

.workbench__header {
  display: flex;
  gap: 20px;
  align-items: start;
  justify-content: space-between;
  margin-bottom: 20px;
}

.workbench__header .eyebrow { margin-bottom: 5px; font-size: 9px; }
.workbench__header h2 { margin: 0; font-size: 22px; letter-spacing: -0.035em; }
.workbench__header p:last-child { margin: 6px 0 0; color: #758995; font-size: 11px; line-height: 1.5; }

.workbench__close {
  flex: 0 0 auto;
  width: 31px;
  height: 31px;
  border: 1px solid #2d424d;
  border-radius: 50%;
  background: transparent;
  color: #7f929d;
  cursor: pointer;
  font-size: 20px;
}

.workbench__group { margin-top: 16px; }
.workbench__group > span,
.select-label,
.program-editor {
  display: block;
  margin-bottom: 8px;
  color: #8fa1ab;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.workbench__toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.workbench__toolbar button,
.slot-tabs button {
  padding: 8px 11px;
  border: 1px solid #2b414c;
  border-radius: 8px;
  background: #12232e;
  color: #9dafb8;
  cursor: pointer;
  font-family: var(--mono);
  font-size: 10px;
}

.workbench__toolbar button:hover,
.workbench__toolbar button.is-selected,
.slot-tabs button.is-selected {
  border-color: rgba(99, 230, 190, 0.5);
  background: rgba(99, 230, 190, 0.1);
  color: var(--cyan);
}

.workbench__tip {
  margin: 16px 0 0;
  color: #758792;
  font-size: 11px;
  line-height: 1.6;
}

.workbench__tip code { color: #acc0ca; font-family: var(--mono); }

.text-action {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--cyan);
  cursor: pointer;
  font-size: inherit;
}

.entry-form,
.coordinate-form {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 9px;
  align-items: end;
  margin-bottom: 16px;
}

.entry-form--reg { grid-template-columns: 1fr 1fr 0.8fr auto; }
.entry-form label,
.coordinate-form label,
.predict-form label,
.program-runner label,
.formula-form label {
  display: grid;
  gap: 6px;
  color: #80939e;
  font-size: 10px;
}

.entry-form input,
.coordinate-form input,
.predict-form input,
.program-runner input,
.formula-form input,
.catalogue-search,
.select-label select,
.program-editor textarea {
  width: 100%;
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid #2a3e49;
  border-radius: 8px;
  outline: none;
  background: #091720;
  color: #dce6e9;
  font-family: var(--mono);
  font-size: 11px;
}

.entry-form input:focus,
.coordinate-form input:focus,
.predict-form input:focus,
.program-runner input:focus,
.formula-form input:focus,
.catalogue-search:focus,
.select-label select:focus,
.program-editor textarea:focus { border-color: rgba(99, 230, 190, 0.7); }

.entry-form > button,
.coordinate-form > button,
.predict-form > button,
.program-runner > button,
.formula-form > button {
  min-height: 35px;
  padding: 9px 13px;
  border: 0;
  border-radius: 8px;
  background: var(--cyan);
  color: #071710;
  cursor: pointer;
  font-size: 10px;
  font-weight: 700;
}

.entry-form > button:disabled,
.program-runner > button:disabled { cursor: not-allowed; opacity: 0.45; }

.data-table-wrap {
  max-height: 220px;
  overflow: auto;
  border: 1px solid #243842;
  border-radius: 10px;
}

.data-table { width: 100%; border-collapse: collapse; font-family: var(--mono); font-size: 10px; }
.data-table th { position: sticky; top: 0; background: #11222c; color: #718590; text-align: left; }
.data-table th,
.data-table td { padding: 8px 10px; border-bottom: 1px solid #20333d; }
.data-table td { color: #aebcc3; }
.data-table td[colspan] { padding: 18px; color: #607681; text-align: center; }
.row-delete { border: 0; background: transparent; color: #b47378; cursor: pointer; }

.workbench__section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 18px 0 10px;
}

.workbench__section-heading h3 { margin: 0; font-size: 13px; }
.empty-state { margin: 0; padding: 18px; border-radius: 10px; background: #0a1821; color: #667b86; font-size: 11px; text-align: center; }

.result-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
}

.result-grid div { min-width: 0; padding: 10px; border: 1px solid #243a45; border-radius: 9px; background: #0a1821; }
.result-grid span { display: block; margin-bottom: 4px; color: #6e828d; font-size: 9px; }
.result-grid strong { display: block; overflow: hidden; color: #c9d6db; font-family: var(--mono); font-size: 10px; text-overflow: ellipsis; }

.select-label select { margin-top: 7px; text-transform: none; }
.predict-form { display: grid; grid-template-columns: 1fr auto minmax(80px, 1fr); gap: 9px; align-items: end; margin-top: 12px; }
.predict-form output { align-self: center; color: var(--cyan); font-family: var(--mono); font-size: 11px; }

.slot-tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 14px; }
.program-editor textarea { min-height: 110px; margin-top: 7px; resize: vertical; line-height: 1.6; text-transform: none; }
.workbench__toolbar--commands { margin-top: 10px; }
.program-meta { display: flex; justify-content: space-between; margin: 10px 0; color: #687e89; font-family: var(--mono); font-size: 9px; }
.program-meta .is-over { color: var(--red); }
.program-runner { display: grid; grid-template-columns: 1fr auto; gap: 9px; align-items: end; }

.workbench__output {
  display: block;
  min-height: 35px;
  margin-top: 12px;
  padding: 10px 12px;
  border-left: 2px solid var(--cyan);
  border-radius: 0 7px 7px 0;
  background: rgba(99, 230, 190, 0.06);
  color: var(--cyan);
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.5;
}

.catalogue-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(220px, 0.95fr); gap: 16px; }
.catalogue-search { margin-bottom: 9px; }
.catalogue-list { display: grid; gap: 5px; max-height: 390px; overflow: auto; padding-right: 4px; }
.catalogue-item {
  display: grid;
  grid-template-columns: 25px 1fr;
  gap: 2px 8px;
  padding: 9px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: #0b1922;
  color: #9cafb8;
  cursor: pointer;
  text-align: left;
}

.catalogue-item:hover,
.catalogue-item.is-selected { border-color: #2b4b51; background: rgba(99, 230, 190, 0.07); }
.catalogue-item > span { grid-row: 1 / 3; color: #536b76; font-family: var(--mono); font-size: 8px; }
.catalogue-item strong { font-size: 10px; }
.catalogue-item small { overflow: hidden; color: #657b86; font-family: var(--mono); font-size: 8px; text-overflow: ellipsis; white-space: nowrap; }
.catalogue-detail { padding: 15px; border: 1px solid #263b46; border-radius: 12px; background: #0b1922; }
.catalogue-detail__number { color: var(--orange); font-family: var(--mono); font-size: 9px; }
.catalogue-detail h3 { margin: 6px 0; font-size: 16px; }
.formula-display { min-height: 36px; margin: 0 0 13px; color: var(--cyan); font-family: var(--mono); font-size: 12px; line-height: 1.5; }
.formula-form { display: grid; gap: 8px; }

.constant-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; max-height: 420px; overflow: auto; padding-right: 4px; }
.constant-item {
  display: grid;
  grid-template-columns: 38px 1fr;
  gap: 2px 8px;
  padding: 10px;
  border: 1px solid #223640;
  border-radius: 9px;
  background: #0a1821;
  color: #9aadb6;
  cursor: pointer;
  text-align: left;
}

.constant-item:hover { border-color: rgba(99, 230, 190, 0.45); }
.constant-item > span { grid-row: 1 / 3; color: var(--cyan); font-family: Georgia, serif; font-size: 15px; text-align: center; }
.constant-item strong { font-size: 10px; }
.constant-item small { overflow: hidden; color: #627983; font-family: var(--mono); font-size: 8px; text-overflow: ellipsis; white-space: nowrap; }

kbd {
  padding: 2px 5px;
  border: 1px solid #344450;
  border-radius: 4px;
  background: #111d27;
  color: #aebbc3;
  font-family: inherit;
  font-size: 8px;
}

.scope {
  display: grid;
  grid-template-columns: 0.65fr 1.35fr;
  gap: 70px;
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 95px 0 110px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.scope h2 {
  max-width: 380px;
  margin: 0;
  font-size: clamp(34px, 4vw, 52px);
  font-weight: 600;
  line-height: 1.04;
  letter-spacing: -0.055em;
}

.scope-grid {
  display: grid;
  gap: 14px;
}

.scope-card {
  display: grid;
  grid-template-columns: 60px 1fr;
  gap: 22px;
  padding: 27px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.022);
}

.scope-card--active {
  border-color: rgba(99, 230, 190, 0.24);
  background: linear-gradient(110deg, rgba(99, 230, 190, 0.08), transparent 62%);
}

.scope-card__number {
  color: #52636e;
  font-family: var(--mono);
  font-size: 12px;
}

.scope-card__status {
  margin: 0 0 8px;
  color: var(--cyan);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.scope-card h3 {
  margin: 0;
  font-size: 22px;
  letter-spacing: -0.03em;
}

.scope-card p:last-child {
  max-width: 600px;
  margin: 10px 0 0;
  color: #84949e;
  font-size: 14px;
  line-height: 1.6;
}

footer {
  display: flex;
  justify-content: space-between;
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 25px 0 35px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  color: #53636d;
  font-family: var(--mono);
  font-size: 9px;
}

.panel-dialog {
  width: min(520px, calc(100% - 30px));
  max-height: min(760px, calc(100dvh - 30px));
  padding: 0;
  overflow-y: auto;
  border: 1px solid #253641;
  border-radius: 22px;
  background: #0e1a24;
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.58);
  color: var(--ink);
}

.panel-dialog::backdrop {
  background: rgba(2, 8, 13, 0.76);
  backdrop-filter: blur(8px);
}

.panel-dialog form {
  padding: 26px;
}

.panel-dialog__header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  margin-bottom: 24px;
}

.panel-dialog h2 {
  margin: 0;
  font-size: 28px;
  letter-spacing: -0.045em;
}

.dialog-close {
  width: 34px;
  height: 34px;
  border: 1px solid #2e3d47;
  border-radius: 50%;
  background: transparent;
  color: #8fa0aa;
  cursor: pointer;
  font-size: 22px;
}

.mode-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.mode-option {
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: 3px 8px;
  padding: 14px;
  border: 1px solid #273743;
  border-radius: 12px;
  background: #111f2a;
  color: #a2b0b9;
  cursor: pointer;
  text-align: left;
}

.mode-option span {
  grid-row: 1 / 3;
  color: #536570;
  font-family: var(--mono);
  font-size: 9px;
}

.mode-option strong { font-size: 14px; }
.mode-option small { color: #5c6e79; font-size: 10px; }
.mode-option--active { border-color: rgba(99, 230, 190, 0.5); color: var(--cyan); }
.mode-option:disabled { opacity: 0.55; }

.panel-dialog fieldset {
  margin: 0 0 22px;
  padding: 0;
  border: 0;
}

.panel-dialog legend {
  margin-bottom: 10px;
  color: #8fa0aa;
  font-size: 12px;
}

.segmented-control {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 4px;
  border-radius: 12px;
  background: #09131b;
}

.segmented-control button {
  padding: 10px 5px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: #6f818d;
  cursor: pointer;
  font-size: 11px;
}

.segmented-control button.is-selected {
  background: #1b2b36;
  color: var(--cyan);
}

.done-button {
  width: 100%;
  padding: 12px;
  border: 0;
  border-radius: 10px;
  background: var(--cyan);
  color: #071710;
  cursor: pointer;
  font-weight: 700;
}

.toast {
  position: fixed;
  z-index: 20;
  right: 24px;
  bottom: 24px;
  max-width: min(360px, calc(100% - 48px));
  padding: 12px 16px;
  border: 1px solid #2b414b;
  border-radius: 10px;
  background: rgba(16, 33, 42, 0.86);
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.35);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  color: #c4d0d5;
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: opacity 260ms ease, transform 420ms var(--ease-spring);
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 930px) {
  .hero {
    grid-template-columns: minmax(0, 1fr);
    padding-top: 65px;
  }

  .hero-copy {
    min-width: 0;
    max-width: 700px;
    text-align: center;
  }

  .hero-copy__intro,
  .exam-note {
    margin-right: auto;
    margin-left: auto;
  }

  .feature-pills { justify-content: center; }
  .exam-note { text-align: left; }
  .calculator-stage { min-width: 0; margin-top: 15px; }
  .scope { grid-template-columns: 1fr; gap: 40px; }
}

@media (max-width: 560px) {
  .site-header,
  .hero,
  .scope,
  footer {
    width: min(calc(100% - 24px), 480px);
  }

  .site-header { min-height: 70px; }
  .header-meta { display: none; }
  .hero { min-height: 0; padding: 50px 0 75px; }
  h1 { font-size: clamp(40px, 13vw, 58px); }
  h1 { overflow-wrap: anywhere; }
  .hero-copy__intro { font-size: 16px; }
  .calculator-stage { padding: 12px 0 0; }

  .calculator {
    padding: 23px 16px 20px;
    border-radius: 25px 25px 34px 34px;
  }

  .calculator__topline { grid-template-columns: 1fr 82px 1.1fr; gap: 8px; }
  .maker__name { font-size: 12px; }
  .model strong { font-size: 16px; }
  .display { height: 114px; border-width: 7px; }
  .display__expression { font-size: 16px; }
  .display__result { font-size: 27px; }
  .utility-row { gap: 6px; margin-right: 0; margin-left: 0; }
  .utility-key { font-size: 7px; }
  .keypad { gap: 11px 5px; }
  .calc-key { height: 36px; font-size: 14px; }
  .calc-key[data-size="number"] { height: 42px; font-size: 21px; }
  .keyboard-hint { text-align: center; }
  .mode-workbench { padding: 18px 14px; border-radius: 15px; }
  .workbench__header h2 { font-size: 19px; }
  .entry-form,
  .entry-form--reg,
  .coordinate-form { grid-template-columns: 1fr 1fr; }
  .entry-form > button,
  .coordinate-form > button { grid-column: 1 / -1; }
  .result-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .catalogue-layout { grid-template-columns: 1fr; }
  .catalogue-list { max-height: 210px; }
  .constant-grid { grid-template-columns: 1fr; }
  .predict-form { grid-template-columns: 1fr auto; }
  .predict-form output { grid-column: 1 / -1; }
  .program-runner { grid-template-columns: 1fr; }
  .scope { padding: 70px 0 80px; }
  .scope-card { grid-template-columns: 38px 1fr; gap: 10px; padding: 22px 17px; }
  footer { flex-direction: column; gap: 8px; }
}

@media (max-width: 360px) {
  .calculator {
    padding: 21px 10px 18px;
  }

  .calculator__topline {
    grid-template-columns: minmax(0, 1fr) 72px minmax(0, 1.15fr);
    gap: 6px;
  }

  .maker__name { font-size: 10px; }
  .maker__series,
  .model small { font-size: 5px; }
  .model strong { font-size: 14px; }
  .device-battery { gap: 4px; height: 27px; }
  .device-battery__icon { width: 43px; height: 21px; border-width: 2px; }
  .device-battery__icon::after { top: 5px; right: -6px; height: 7px; }
  .device-battery__text { min-width: 24px; font-size: 8px; }
  .display { margin-top: 9px; }
  .utility-row { gap: 4px; margin-top: 16px; }
  .keypad { column-gap: 4px; }
  .calc-key { height: 39px; }
  .calc-key[data-size="number"] { height: 44px; }
}

@media (hover: none) and (pointer: coarse) {
  .calc-key,
  .utility-key,
  .replay-pad button {
    user-select: none;
  }

  .keyboard-hint {
    display: none;
  }
}

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

/* Full-screen application shell ------------------------------------------------ */

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body.is-calculator-view {
  touch-action: none;
}

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

.app-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: 100%;
  height: 100dvh;
  min-height: 0;
}

.app-bar {
  position: relative;
  z-index: 30;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  min-height: calc(62px + env(safe-area-inset-top));
  padding: calc(8px + env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) 8px max(14px, env(safe-area-inset-left));
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(7, 16, 25, 0.86);
  backdrop-filter: blur(16px);
}

.app-bar .brand {
  justify-self: center;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.brand__identity {
  display: flex;
  flex-direction: column;
  line-height: 1;
}

.brand__identity small {
  margin-top: 4px;
  color: #7f929d;
  font-family: var(--mono);
  font-size: 7px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.calculator .model strong {
  font-size: 22px;
  text-decoration: underline;
  text-decoration-color: rgba(55, 73, 87, 0.25);
  text-underline-offset: 4px;
}

.app-nav-button,
.zoom-controls,
.calculator-dock button,
.primary-action {
  border: 1px solid rgba(255, 255, 255, 0.11);
  background: rgba(255, 255, 255, 0.045);
  color: #c7d2d8;
}

.app-nav-button {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  justify-self: start;
  width: fit-content;
  min-height: 38px;
  padding: 7px 12px 7px 7px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 12px;
}

.app-nav-button__icon {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border-radius: 50%;
  background: var(--cyan-soft);
  color: var(--cyan);
  font-family: var(--mono);
}

.zoom-controls {
  display: grid;
  grid-template-columns: 32px 44px 32px auto;
  gap: 3px;
  align-items: center;
  justify-self: end;
  padding: 3px;
  border-radius: 12px;
}

.zoom-controls button {
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #b9c6cc;
  cursor: pointer;
  font-weight: 700;
}

.zoom-controls button:hover,
.zoom-controls button:focus-visible {
  background: rgba(99, 230, 190, 0.1);
  color: var(--cyan);
}

.zoom-controls output {
  color: #748792;
  font-family: var(--mono);
  font-size: 9px;
  text-align: center;
}

.zoom-controls .zoom-controls__fit {
  padding: 0 9px;
  color: var(--cyan);
  font-size: 9px;
  text-transform: uppercase;
}

.app-main {
  position: relative;
  min-height: 0;
  overflow: hidden;
}

.app-view {
  position: absolute;
  inset: 0;
}

.app-view[hidden] {
  display: none !important;
}

.app-view--calculator {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  min-height: 0;
  overflow: hidden;
}

.calculator-viewport {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 0;
  padding: 8px 12px;
  overflow: hidden;
  overscroll-behavior: none;
  scrollbar-color: #34515b transparent;
  scrollbar-width: thin;
  touch-action: none;
}

.calculator-viewport.is-overflowing {
  align-items: flex-start;
  justify-content: flex-start;
  overflow: auto;
  overscroll-behavior: contain;
  scroll-padding-block: 8px;
  touch-action: pan-x pan-y;
  -webkit-overflow-scrolling: touch;
}

.calculator-viewport.is-phone-portrait .calculator {
  overflow: clip;
}

.calculator-viewport.is-phone-portrait .display {
  position: sticky;
  z-index: 8;
  top: 16px;
  box-shadow:
    0 3px 8px rgba(0, 0, 0, 0.52) inset,
    0 -1px 1px rgba(255, 255, 255, 0.7) inset,
    0 2px 1px #fff,
    0 8px 22px rgba(24, 29, 29, 0.2);
}

@supports not (overflow: clip) {
  .calculator-viewport.is-phone-portrait .calculator {
    overflow: visible;
  }
}

.calculator-space {
  position: relative;
  flex: 0 0 auto;
}

.calculator-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 500px;
  transform-origin: top left;
  will-change: transform;
}

.calculator-stage {
  width: 100%;
  margin: 0;
  padding: 6px 10px 12px;
}

.calculator-stage::before {
  inset: 9% 0 5%;
}

.keyboard-hint {
  margin-top: 14px;
  margin-bottom: 0;
}

.calculator-dock {
  position: relative;
  z-index: 25;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: calc(58px + env(safe-area-inset-bottom));
  padding: 8px max(14px, env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(7, 16, 25, 0.9);
  backdrop-filter: blur(16px);
}

.calculator-dock__status {
  display: inline-flex;
  gap: 9px;
  align-items: center;
  margin-left: 180px;
  color: #70838e;
  font-family: var(--mono);
  font-size: 9px;
  text-transform: uppercase;
}

.calculator-dock button,
.primary-action {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 8px 14px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
}

.calculator-dock button span:first-child {
  display: grid;
  width: 20px;
  height: 20px;
  place-items: center;
  border-radius: 50%;
  background: var(--cyan-soft);
  color: var(--cyan);
  font-family: var(--mono);
}

.language-picker {
  position: fixed;
  z-index: 90;
  bottom: calc(12px + env(safe-area-inset-bottom));
  left: max(12px, env(safe-area-inset-left));
}

.language-picker select {
  width: 158px;
  height: 36px;
  padding: 0 30px 0 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 9px;
  outline: none;
  background: #0d1d27;
  color: #b9c7cd;
  cursor: pointer;
  font-size: 11px;
}

.language-picker select:focus {
  border-color: rgba(99, 230, 190, 0.65);
}

.is-about-view .zoom-controls,
.is-manual-view .zoom-controls {
  visibility: hidden;
}

.app-view--scrollable {
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
  touch-action: pan-y;
}

.content-page {
  width: min(1040px, calc(100% - 40px));
  min-height: 100%;
  margin: 0 auto;
  padding: clamp(54px, 8vw, 100px) 0 96px;
}

.content-page__header {
  max-width: 780px;
}

.content-page h1 {
  max-width: 850px;
}

.content-page__lead {
  max-width: 690px;
  margin: 27px 0 0;
  color: #a6b4bc;
  font-size: clamp(16px, 2vw, 20px);
  line-height: 1.7;
}

.primary-action {
  margin-top: 26px;
  border-color: rgba(99, 230, 190, 0.35);
  background: var(--cyan-soft);
  color: var(--cyan);
}

.content-page > .feature-pills {
  margin-top: 38px;
}

.content-page > .exam-note {
  max-width: 760px;
}

.reference-model-banner {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 18px;
  align-items: center;
  margin-top: 34px;
  padding: 18px 20px;
  border: 1px solid rgba(99, 230, 190, 0.22);
  border-radius: 14px;
  background: linear-gradient(100deg, rgba(99, 230, 190, 0.09), rgba(255, 255, 255, 0.02));
}

.reference-model-banner span,
.reference-model-banner small {
  color: #728791;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.reference-model-banner strong {
  color: var(--cyan);
  font-family: Georgia, serif;
  font-size: clamp(20px, 3vw, 30px);
  font-style: italic;
}

.reference-model-banner small {
  max-width: 250px;
  line-height: 1.5;
  text-align: right;
}

.content-page .scope {
  grid-template-columns: minmax(220px, 0.65fr) minmax(0, 1.35fr);
  width: 100%;
  margin-top: 80px;
  padding: 76px 0;
}

.content-footer {
  display: flex;
  gap: 20px;
  align-items: center;
  justify-content: space-between;
  padding: 25px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  color: #61737d;
  font-family: var(--mono);
  font-size: 9px;
}

.manual-hero {
  display: flex;
  gap: 32px;
  align-items: end;
  justify-content: space-between;
  padding-bottom: 42px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.manual-hero .primary-action {
  flex: 0 0 auto;
}

.manual-model-banner {
  display: grid;
  grid-template-columns: minmax(150px, auto) auto minmax(260px, 1fr);
  gap: 22px;
  align-items: center;
  margin-top: 24px;
  padding: 20px 22px;
  border: 1px solid rgba(99, 230, 190, 0.32);
  border-radius: 16px;
  background: linear-gradient(110deg, rgba(99, 230, 190, 0.12), rgba(11, 27, 36, 0.92));
}

.manual-model-banner > span {
  color: #88a09f;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.07em;
  line-height: 1.5;
  text-transform: uppercase;
}

.manual-model-banner strong {
  color: var(--cyan);
  font-family: Georgia, serif;
  font-size: clamp(25px, 4vw, 38px);
  font-style: italic;
  white-space: nowrap;
}

.manual-model-banner p {
  margin: 0;
  color: #93a6af;
  font-size: 12px;
  line-height: 1.6;
}

.manual-index {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 24px 0 36px;
}

.manual-index a {
  padding: 7px 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  color: #82949e;
  font-family: var(--mono);
  font-size: 9px;
  text-decoration: none;
}

.manual-index a:hover {
  border-color: rgba(99, 230, 190, 0.4);
  color: var(--cyan);
}

.manual-content {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding-bottom: 70px;
}

.manual-section {
  scroll-margin-top: 20px;
  padding: 24px;
  border: 1px solid rgba(255, 255, 255, 0.085);
  border-radius: 17px;
  background: rgba(255, 255, 255, 0.025);
}

.manual-section--wide {
  grid-column: 1 / -1;
}

.manual-section__number {
  color: var(--cyan);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.12em;
}

.manual-section h2 {
  margin: 8px 0 13px;
  font-size: 22px;
}

.manual-section p,
.manual-section li {
  color: #93a4ad;
  font-size: 13px;
  line-height: 1.7;
}

.manual-section p {
  margin: 0;
}

.manual-section ul,
.manual-section ol {
  margin: 0;
  padding-left: 20px;
}

.manual-section li + li {
  margin-top: 7px;
}

.manual-section code {
  padding: 2px 5px;
  border-radius: 4px;
  background: rgba(99, 230, 190, 0.08);
  color: #b8e8d8;
  font-family: var(--mono);
  font-size: 0.9em;
}

/* Specialist mode panels sit above the locked calculator viewport. */
.mode-workbench {
  position: fixed;
  z-index: 80;
  inset: calc(74px + env(safe-area-inset-top)) 12px calc(72px + env(safe-area-inset-bottom));
  width: min(700px, calc(100% - 24px));
  max-height: none;
  margin: 0 auto;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  box-shadow: 0 0 0 100vmax rgba(2, 8, 13, 0.72), 0 24px 70px rgba(0, 0, 0, 0.55);
  touch-action: pan-y;
}

.toast {
  z-index: 110;
  bottom: calc(72px + env(safe-area-inset-bottom));
}

@media (max-width: 760px) {
  .content-page .scope {
    grid-template-columns: 1fr;
    gap: 34px;
  }

  .manual-content {
    grid-template-columns: 1fr;
  }

  .manual-section--wide {
    grid-column: auto;
  }
}

@media (max-width: 560px) {
  .app-bar {
    grid-template-columns: auto 1fr auto;
    gap: 7px;
    min-height: calc(58px + env(safe-area-inset-top));
    padding-right: max(8px, env(safe-area-inset-right));
    padding-left: max(8px, env(safe-area-inset-left));
  }

  .app-nav-button {
    padding-right: 9px;
    font-size: 10px;
  }

  .app-bar .brand {
    justify-self: center;
    font-size: 14px;
  }

  .calculator .model strong {
    font-size: 19px;
  }

  .brand__mark {
    width: 28px;
    height: 28px;
  }

  .zoom-controls {
    grid-template-columns: 28px 36px 28px 35px;
  }

  .zoom-controls button {
    height: 30px;
  }

  .zoom-controls .zoom-controls__fit {
    padding: 0 4px;
    font-size: 8px;
  }

  .calculator-canvas {
    width: 500px;
  }

  .calculator-stage {
    padding: 6px 10px 12px;
  }

  .calculator {
    width: min(100%, 480px);
  }

  .calculator-dock__status {
    display: none;
  }

  .calculator-dock {
    justify-content: flex-end;
  }

  .calculator-dock button {
    max-width: calc(100% - 168px);
    min-height: 36px;
    padding: 7px 10px;
    font-size: 10px;
  }

  .language-picker select {
    width: 150px;
    height: 34px;
    font-size: 10px;
  }

  .content-page {
    width: min(100% - 28px, 480px);
    padding-top: 46px;
  }

  .content-page h1 {
    font-size: clamp(38px, 12vw, 55px);
  }

  .manual-hero {
    display: block;
  }

  .manual-hero .primary-action {
    margin-top: 22px;
  }

  .manual-model-banner {
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 18px;
  }

  .manual-section {
    padding: 20px 17px;
  }

  .reference-model-banner {
    grid-template-columns: 1fr;
    gap: 7px;
  }

  .reference-model-banner small {
    max-width: none;
    text-align: left;
  }

  .mode-workbench {
    inset: calc(66px + env(safe-area-inset-top)) 8px calc(66px + env(safe-area-inset-bottom));
    width: calc(100% - 16px);
  }
}

@media (max-width: 380px) {
  .app-nav-button > span:last-child,
  .zoom-controls output {
    display: none;
  }

  .brand__name {
    display: none;
  }

  .brand__identity small {
    margin-top: 0;
    color: var(--cyan);
    font-size: 8px;
  }

  .zoom-controls {
    grid-template-columns: 28px 28px 34px;
  }

  .zoom-controls button[data-zoom="out"] { grid-column: 1; }
  .zoom-controls button[data-zoom="in"] { grid-column: 2; }
  .zoom-controls__fit { grid-column: 3; }
}

/* Integrated key legends and stronger top controls -------------------------- */

.utility-row {
  gap: 9px;
  margin-top: 17px;
  margin-bottom: 14px;
}

.utility-key {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 41px;
  padding: 4px 2px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.015em;
}

.utility-key__alt {
  position: static;
  display: block;
  margin-bottom: 2px;
  color: #8b5616;
  font-size: 8px;
  font-weight: 800;
  line-height: 1;
  transform: none;
}

.replay-pad {
  grid-template-columns: 23px 1fr 23px;
  grid-template-rows: 20px 25px 20px;
  min-height: 74px;
  padding: 3px;
}

.replay-pad button {
  font-size: 12px;
  font-weight: 800;
}

.replay-pad__center {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.keypad {
  gap: 8px;
}

.calc-key {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: 15px minmax(0, 1fr);
  height: 43px;
  padding: 4px 6px 5px;
}

.calc-key[data-size="number"] {
  height: 49px;
}

.calc-key__main {
  grid-column: 1 / -1;
  grid-row: 1 / 3;
  align-self: center;
  justify-self: center;
  line-height: 1;
}

.calc-key--layered .calc-key__main {
  grid-row: 2;
}

.calc-key__shift,
.calc-key__alpha,
.calc-key__context {
  position: static;
  top: auto;
  max-width: none;
  align-self: center;
  overflow: visible;
  font-size: 8px;
  font-weight: 800;
  line-height: 1;
}

.calc-key__shift {
  grid-column: 1;
  grid-row: 1;
  justify-self: start;
}

.calc-key__alpha {
  grid-column: 3;
  grid-row: 1;
  justify-self: end;
}

.calc-key__context {
  grid-column: 3;
  grid-row: 1;
  justify-self: end;
  left: auto;
  transform: none;
}

.calc-key__context--stat {
  grid-column: 2;
  justify-self: center;
  font-size: 9.5px;
  line-height: 0.72;
  text-align: center;
  white-space: pre-line;
}

.calc-key__alpha--base {
  padding-bottom: 1px;
  border-bottom: 1px solid #287b61;
  text-shadow: 0 0 5px rgba(40, 123, 97, 0.35);
}

.calc-key[data-key-label="x⁻¹"] .calc-key__context--base {
  font-size: 9.5px;
  letter-spacing: -0.04em;
}

.calc-key--orange .calc-key__main {
  font-size: 17px;
  font-weight: 800;
}

.calc-key--danger .calc-key__main {
  font-weight: 800;
}

@media (max-width: 560px) {
  .utility-row {
    gap: 6px;
  }

  .utility-key {
    height: 40px;
    font-size: 12px;
  }

  .replay-pad {
    min-height: 70px;
  }

  .keypad {
    gap: 8px 5px;
  }

  .calc-key {
    height: 42px;
    font-size: 15px;
  }

  .calc-key[data-size="number"] {
    height: 48px;
    font-size: 21px;
  }
}

/* Smart Calculator platform, mobile ergonomics and deterministic press states */

.app-bar__actions {
  display: flex;
  gap: 7px;
  align-items: center;
  justify-self: end;
  min-width: 0;
}

.is-about-view .interface-mode-toggle,
.is-manual-view .interface-mode-toggle,
.is-linear-algebra-view .interface-mode-toggle,
.is-linear-algebra-view .zoom-controls,
.is-computer-calculator-view .interface-mode-toggle,
.is-computer-calculator-view .zoom-controls,
.is-economics-calculator-view .interface-mode-toggle,
.is-economics-calculator-view .zoom-controls {
  visibility: hidden;
}

body:not(.is-calculator-view) .mode-workbench {
  display: none;
}

.interface-mode-toggle {
  display: inline-flex;
  gap: 7px;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 7px 11px;
  border: 1px solid rgba(99, 230, 190, 0.28);
  border-radius: 12px;
  background: rgba(99, 230, 190, 0.075);
  color: #a7d8c9;
  cursor: pointer;
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 700;
  white-space: nowrap;
  transition: transform 90ms ease, background 160ms ease, border-color 160ms ease, box-shadow 90ms ease;
}

.interface-mode-toggle__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 10px rgba(99, 230, 190, 0.7);
}

.interface-mode-toggle[aria-pressed="true"] {
  border-color: rgba(255, 159, 67, 0.45);
  background: rgba(255, 159, 67, 0.1);
  color: #ffc38a;
}

.interface-mode-toggle[aria-pressed="true"] .interface-mode-toggle__dot {
  background: var(--orange);
  box-shadow: 0 0 10px rgba(255, 159, 67, 0.7);
}

button.is-pressed,
.utility-key.is-pressed,
.replay-pad button.is-pressed,
.app-nav-button.is-pressed,
.zoom-controls button.is-pressed,
.calculator-dock button.is-pressed,
.primary-action.is-pressed,
.text-action.is-pressed,
.interface-mode-toggle.is-pressed {
  filter: brightness(1.2);
  transform: translateY(2px) scale(0.975);
}

.calc-key.is-pressed {
  filter: brightness(1.18);
  transform: translateY(4px) scale(0.975);
  box-shadow: 0 0 0 var(--key-edge), 0 1px 0 rgba(255, 255, 255, 0.16) inset;
}

.utility-key.is-pressed {
  box-shadow: 0 1px 0 #585a59, 0 1px 0 rgba(255, 255, 255, 0.18) inset;
}

.app-view.is-entering {
  animation: view-enter 220ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.app-view--scrollable.is-entering {
  animation: view-enter-soft 320ms var(--ease-ios) both;
}

@keyframes view-enter {
  from { opacity: 0; transform: translateY(7px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes view-enter-soft {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.platform-tools {
  grid-template-columns: 1fr;
}

.tool-card {
  align-items: start;
}

.tool-card__action {
  display: inline-flex;
  margin-top: 14px;
  padding: 0;
  border: 0;
  background: transparent;
}

.tool-card--future {
  border-style: dashed;
}

.content-page--home {
  width: min(960px, calc(100% - 40px));
  padding-top: clamp(42px, 6vw, 72px);
}

.home-hero {
  max-width: 680px;
}

.content-page--home .home-hero h1 {
  max-width: 620px;
  font-size: clamp(44px, 6vw, 68px);
  line-height: 1.02;
}

.content-page--home .content-page__lead {
  max-width: 540px;
  margin-top: 18px;
  line-height: 1.5;
}

.home-tools {
  margin-top: clamp(30px, 5vw, 52px);
}

.home-tool-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.home-tool-card {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 14px;
  min-width: 0;
  min-height: 160px;
  padding: 22px;
  border: 1px solid rgba(99, 230, 190, 0.25);
  border-radius: 18px;
  background: linear-gradient(145deg, rgba(22, 48, 51, 0.68), rgba(10, 25, 34, 0.9));
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.2);
}

.home-tool-card__number {
  color: var(--cyan);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.home-tool-card h3 {
  margin: 0;
  color: #ecf5f4;
  font-size: clamp(19px, 2.2vw, 25px);
  line-height: 1.18;
}

.home-tool-card .primary-action {
  min-height: 44px;
  margin-top: 22px;
}

.content-page--home .content-footer {
  margin-top: clamp(34px, 6vw, 64px);
}

.content-page--linear {
  width: min(1120px, calc(100% - 40px));
  padding-top: clamp(34px, 5vw, 64px);
}

.linear-hero {
  max-width: 760px;
  padding-bottom: 28px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.linear-hero h1 {
  margin-top: 12px;
  font-size: clamp(38px, 5.2vw, 60px);
  line-height: 1.04;
}

.linear-hero .content-page__lead {
  margin-top: 16px;
}

.matrix-workspace {
  margin-top: 24px;
  padding: clamp(16px, 2.5vw, 28px);
  border: 1px solid rgba(99, 230, 190, 0.19);
  border-radius: 22px;
  background: linear-gradient(145deg, rgba(17, 31, 42, 0.98), rgba(8, 20, 29, 0.98));
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.24);
}

.matrix-workspace__header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 20px;
  align-items: end;
}

.matrix-workspace__header .eyebrow {
  margin: 0 0 7px;
}

.matrix-workspace__header h2 {
  max-width: 560px;
  margin: 0;
  color: #edf5f5;
  font-size: clamp(20px, 2.6vw, 28px);
  line-height: 1.2;
}

.matrix-example-bar {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.matrix-example-bar > span,
.matrix-controls label > span {
  color: #7f949e;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.matrix-example-list {
  display: flex;
  gap: 7px;
}

.matrix-example-list button,
.matrix-template-row button,
.matrix-swap {
  min-height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.035);
  color: #b7c6cc;
  cursor: pointer;
  font-size: 11px;
  font-weight: 650;
  transition: border-color 150ms ease, background 150ms ease, color 150ms ease, transform 90ms ease;
}

.matrix-example-list button {
  padding: 8px 11px;
  white-space: nowrap;
}

.matrix-example-list button:hover,
.matrix-template-row button:hover,
.matrix-swap:hover {
  border-color: rgba(99, 230, 190, 0.35);
  color: var(--cyan);
}

.matrix-operation-palette {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 9px;
  margin-top: 22px;
}

.matrix-operation-palette button {
  display: grid;
  gap: 5px;
  min-width: 0;
  min-height: 72px;
  padding: 11px 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 13px;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.018));
  color: #d3dddf;
  cursor: pointer;
  text-align: start;
  transition: border-color 150ms ease, background 150ms ease, color 150ms ease, transform 90ms ease, box-shadow 150ms ease;
}

.matrix-operation-palette button strong {
  overflow: hidden;
  color: #eef6f5;
  font-family: var(--mono);
  font-size: 18px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
  direction: ltr;
}

.matrix-operation-palette button span {
  overflow: hidden;
  color: #8499a3;
  font-size: 10px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.matrix-operation-palette button:hover {
  border-color: rgba(99, 230, 190, 0.32);
}

.matrix-operation-palette button.is-selected {
  border-color: rgba(99, 230, 190, 0.58);
  background: linear-gradient(145deg, rgba(99, 230, 190, 0.14), rgba(99, 230, 190, 0.055));
  box-shadow: 0 0 0 1px rgba(99, 230, 190, 0.08) inset, 0 10px 24px rgba(0, 0, 0, 0.14);
}

.matrix-operation-palette button.is-selected strong,
.matrix-operation-palette button.is-selected span {
  color: var(--cyan);
}

.matrix-expression-preview {
  display: flex;
  gap: 12px;
  align-items: center;
  margin: 14px 0 0;
  padding: 9px 12px;
  border-radius: 10px;
  background: rgba(99, 230, 190, 0.05);
  color: #738994;
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
}

.matrix-expression-preview strong {
  color: var(--cyan);
  font-size: 13px;
  font-weight: 600;
  text-transform: none;
  direction: ltr;
}

.matrix-inputs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.matrix-workspace.is-unary-operation .matrix-inputs {
  grid-template-columns: minmax(0, 1fr);
}

.matrix-card {
  display: grid;
  gap: 11px;
  min-width: 0;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 15px;
  background: rgba(3, 12, 18, 0.34);
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.matrix-card[hidden] {
  display: none;
}

.matrix-card > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.matrix-card label {
  color: #dce7e7;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.matrix-card output {
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  color: #7f949e;
  font-family: var(--mono);
  font-size: 10px;
}

.matrix-card.has-valid-input output {
  background: rgba(99, 230, 190, 0.08);
  color: var(--cyan);
}

.matrix-card.has-invalid-input {
  border-color: rgba(240, 92, 99, 0.5);
  box-shadow: 0 0 0 3px rgba(240, 92, 99, 0.06);
}

.matrix-entry-shell {
  position: relative;
  min-width: 0;
}

.matrix-entry-shell::before,
.matrix-entry-shell::after {
  position: absolute;
  z-index: 1;
  top: 10px;
  bottom: 10px;
  width: 8px;
  border-top: 2px solid rgba(99, 230, 190, 0.4);
  border-bottom: 2px solid rgba(99, 230, 190, 0.4);
  content: "";
  pointer-events: none;
}

.matrix-entry-shell::before {
  left: 9px;
  border-left: 2px solid rgba(99, 230, 190, 0.4);
  border-radius: 5px 0 0 5px;
}

.matrix-entry-shell::after {
  right: 9px;
  border-right: 2px solid rgba(99, 230, 190, 0.4);
  border-radius: 0 5px 5px 0;
}

.matrix-card textarea,
.matrix-controls select {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 12px;
  outline: 0;
  background: #08151e;
  color: #e2ebeb;
  font-family: var(--mono);
  font-size: 16px;
}

.matrix-card textarea {
  display: block;
  min-height: 142px;
  padding: 16px 24px;
  resize: vertical;
  line-height: 1.65;
  direction: ltr;
}

.matrix-card textarea:focus,
.matrix-controls select:focus {
  border-color: rgba(99, 230, 190, 0.62);
  box-shadow: 0 0 0 3px rgba(99, 230, 190, 0.08);
}

.matrix-template-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.matrix-template-row button {
  overflow: hidden;
  padding: 6px 7px;
  font-family: var(--mono);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.matrix-input-hint {
  margin: 9px 2px 0;
  color: #6e838d;
  font-size: 10px;
}

.matrix-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 10px;
  align-items: end;
  margin-top: 16px;
}

.matrix-controls label {
  display: grid;
  gap: 8px;
}

.matrix-controls select {
  min-height: 48px;
  padding: 0 42px 0 13px;
}

.matrix-swap {
  min-width: 142px;
  padding: 8px 14px;
}

.matrix-swap > span:first-child {
  margin-inline-end: 7px;
  color: var(--cyan);
  font-size: 16px;
}

.matrix-calculate {
  min-height: 48px;
  margin: 0;
  padding-inline: 24px;
}

.matrix-calculate.has-success {
  box-shadow: 0 0 0 3px rgba(99, 230, 190, 0.09);
}

.matrix-calculate.has-error {
  border-color: rgba(240, 92, 99, 0.5);
  color: #ff9ca1;
}

.matrix-result {
  min-height: 174px;
  margin-top: 18px;
  padding: 18px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 16px;
  background: rgba(0, 0, 0, 0.15);
  transition: border-color 180ms ease, background 180ms ease;
}

.matrix-result[data-state="matrix"],
.matrix-result[data-state="scalar"],
.matrix-result[data-state="eigen"] {
  border-color: rgba(99, 230, 190, 0.25);
  background: rgba(99, 230, 190, 0.025);
}

.matrix-result[data-state="error"] {
  border-color: rgba(240, 92, 99, 0.35);
}

.matrix-result__header {
  display: flex;
  gap: 18px;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 13px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.matrix-result__header .eyebrow {
  margin: 0 0 4px;
}

.matrix-result__header strong {
  color: #e3eded;
  font-family: var(--mono);
  font-size: 14px;
  direction: ltr;
}

.matrix-result__header output {
  flex: 0 0 auto;
  color: var(--cyan);
  font-family: var(--mono);
  font-size: 11px;
}

#matrix-result {
  min-width: 0;
  padding: 17px 0 10px;
  overflow-x: auto;
}

.matrix-result__summary {
  margin: 8px 0 0;
  color: #6f838d;
  font-family: var(--mono);
  font-size: 9px;
  line-height: 1.5;
  direction: ltr;
}

.matrix-output-table {
  border-spacing: 0;
  border-collapse: separate;
  margin: 0 auto;
  border-right: 2px solid rgba(99, 230, 190, 0.45);
  border-left: 2px solid rgba(99, 230, 190, 0.45);
  border-radius: 8px;
  color: #e7f0f0;
  font-family: var(--mono);
  direction: ltr;
}

.matrix-output-table td {
  min-width: 70px;
  padding: 10px 13px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.055);
  text-align: center;
}

.matrix-output-table tr:last-child td {
  border-bottom: 0;
}

.matrix-scalar-result {
  display: grid;
  min-height: 80px;
  place-items: center;
  color: var(--cyan);
  font-family: var(--mono);
  font-size: clamp(30px, 6vw, 52px);
}

.matrix-error {
  margin: 0;
  color: #ff969c;
  line-height: 1.6;
}

.eigen-results {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.eigen-card {
  display: grid;
  gap: 10px;
  padding: 15px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.025);
}

.eigen-card strong {
  color: var(--cyan);
  font-family: var(--mono);
}

.eigen-card > span {
  color: #718691;
  font-family: var(--mono);
  font-size: 9px;
}

.eigen-card .matrix-output-table td {
  min-width: 110px;
  padding: 7px 10px;
}

.matrix-note {
  margin: 12px 2px 0;
  color: #71848e;
  font-size: 10px;
  line-height: 1.55;
}

.calculator,
.calculator button,
.display {
  direction: ltr;
}

html[dir="rtl"] .app-bar__actions,
html[dir="rtl"] .app-nav-button {
  direction: rtl;
}

@media (max-width: 760px) {
  .app-bar__actions {
    gap: 4px;
  }

  .zoom-controls {
    grid-template-columns: 30px 30px;
  }

  .zoom-controls output,
  .zoom-controls__fit {
    display: none;
  }

  .matrix-workspace__header {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .matrix-example-list {
    max-width: 100%;
    padding-bottom: 2px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: thin;
  }
}

@media (max-width: 560px) {
  .app-bar {
    min-height: calc(54px + env(safe-area-inset-top));
    padding: calc(6px + env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) 6px max(8px, env(safe-area-inset-left));
  }

  .content-page--home {
    width: min(100% - 28px, 480px);
    padding-top: 28px;
    padding-bottom: 70px;
  }

  .content-page--home .home-hero h1 {
    font-size: clamp(38px, 11vw, 46px);
    line-height: 1;
  }

  .content-page--home .content-page__lead {
    margin-top: 14px;
    font-size: 15px;
    line-height: 1.45;
  }

  .home-tools {
    margin-top: 24px;
  }

  .home-tool-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .home-tool-card {
    grid-template-columns: 1fr;
    gap: 7px;
    min-height: 0;
    padding: 12px;
    border-radius: 15px;
  }

  .home-tool-card__number {
    font-size: 9px;
  }

  .home-tool-card > div {
    display: flex;
    flex-direction: column;
    min-height: 108px;
  }

  .home-tool-card h3 {
    font-size: 15px;
    line-height: 1.15;
  }

  .home-tool-card .primary-action {
    width: 100%;
    min-height: 44px;
    margin-top: auto;
    padding: 8px;
    font-size: 9px;
    line-height: 1.2;
  }

  .content-page--home .content-footer {
    margin-top: 28px;
  }

  .app-shell {
    height: 100dvh;
  }

  .calculator-viewport {
    padding: 2px 4px;
  }

  .calculator-canvas {
    width: 430px;
  }

  .calculator-stage {
    padding: 3px 8px 8px;
  }

  .calculator {
    width: min(100%, 414px);
    padding: 18px 16px 16px;
    border-radius: 27px 27px 36px 36px;
  }

  .calculator-viewport.is-phone-portrait.is-fit-locked {
    overflow: hidden;
    overscroll-behavior: none;
    touch-action: none;
  }

  .calculator-viewport.is-phone-portrait .stage-label,
  .calculator-viewport.is-phone-portrait .calculator__topline,
  .calculator-viewport.is-phone-portrait .calculator__footer,
  .calculator-viewport.is-phone-portrait .keyboard-hint {
    display: none;
  }

  .calculator-viewport.is-phone-portrait .calculator-stage {
    padding: 2px 8px;
  }

  .calculator-viewport.is-phone-portrait .calculator-stage::before {
    display: none;
  }

  .calculator-viewport.is-phone-portrait .calculator {
    padding: 10px clamp(13px, 3.5vw, 16px);
  }

  .calculator-viewport.is-phone-portrait .display {
    position: relative;
    top: auto;
    margin-top: 0;
  }

  .calculator-viewport.is-phone-portrait .utility-row {
    margin-top: 10px;
    margin-bottom: 8px;
  }

  .calculator-viewport.is-phone-portrait.is-compact-height .calculator {
    padding-top: 7px;
    padding-bottom: 7px;
  }

  .calculator-viewport.is-phone-portrait.is-compact-height .display {
    height: 94px;
    padding-top: 6px;
    padding-bottom: 8px;
  }

  .calculator-viewport.is-phone-portrait.is-compact-height .display__expression {
    height: 28px;
    padding-top: 2px;
  }

  .calculator-viewport.is-phone-portrait.is-compact-height .display__result {
    height: 39px;
  }

  .calculator-viewport.is-phone-portrait.is-compact-height .utility-row {
    margin-top: 7px;
    margin-bottom: 6px;
  }

  .calculator-viewport.is-phone-portrait.is-compact-height .replay-pad {
    min-height: 68px;
  }

  .calculator-viewport.is-phone-portrait.is-compact-height .keypad {
    gap-block: 4px;
  }

  .calculator-viewport.is-phone-portrait.is-compact-height .calc-key {
    min-height: 52px;
    height: 52px;
  }

  .calculator-viewport.is-phone-portrait.is-compact-height .calc-key[data-size="number"] {
    min-height: 58px;
    height: 58px;
  }

  .stage-label {
    width: min(100%, 414px);
    margin-bottom: 6px;
    font-size: 9px;
  }

  .calculator__topline {
    min-height: 44px;
  }

  .display {
    height: 108px;
    padding: 8px 12px 12px;
  }

  .display__expression {
    font-size: 17px;
  }

  .display__result {
    font-size: 28px;
  }

  .utility-row {
    margin-top: 12px;
    margin-bottom: 10px;
  }

  .utility-key {
    min-height: 48px;
    height: 48px;
    font-size: 13px;
  }

  .utility-key__alt {
    font-size: 9px;
  }

  .replay-pad {
    min-height: 78px;
  }

  .keypad {
    gap: 6px 5px;
  }

  .calc-key {
    min-height: 54px;
    height: 54px;
    padding: 5px 6px 6px;
    font-size: 16px;
  }

  .calc-key[data-size="number"] {
    min-height: 60px;
    height: 60px;
    font-size: 23px;
  }

  .calc-key__shift,
  .calc-key__alpha,
  .calc-key__context {
    font-size: 10.5px;
  }

  .calc-key--layered .calc-key__main {
    font-size: 15px;
  }

  .calc-key--orange .calc-key__main {
    font-size: 18px;
  }

  .calculator__footer {
    margin-top: 14px;
    font-size: 6.5px;
  }

  .calculator-dock {
    min-height: calc(52px + env(safe-area-inset-bottom));
    padding-top: 6px;
    padding-bottom: calc(6px + env(safe-area-inset-bottom));
  }

  .language-picker {
    bottom: calc(9px + env(safe-area-inset-bottom));
  }

  .is-linear-algebra-view .language-picker {
    top: calc(8px + env(safe-area-inset-top));
    right: max(8px, env(safe-area-inset-right));
    bottom: auto;
    left: auto;
  }

  .is-linear-algebra-view .language-picker select {
    width: 108px;
    height: 38px;
  }

  html[dir="rtl"] .is-linear-algebra-view .language-picker {
    right: auto;
    left: max(8px, env(safe-area-inset-left));
  }

  .interface-mode-toggle {
    min-height: 38px;
    padding: 6px 8px;
    font-size: 8px;
  }

  .content-page--linear {
    width: min(100% - 20px, 520px);
    padding-top: 18px;
    padding-bottom: calc(82px + env(safe-area-inset-bottom));
  }

  .linear-hero {
    padding-bottom: 17px;
  }

  .linear-hero .eyebrow {
    margin-bottom: 8px;
    font-size: 9px;
  }

  .linear-hero h1 {
    margin-top: 0;
    font-size: clamp(30px, 9vw, 38px);
    line-height: 1.04;
  }

  .linear-hero .content-page__lead {
    margin-top: 11px;
    font-size: 13px;
    line-height: 1.45;
  }

  .matrix-workspace {
    margin-top: 12px;
    padding: 12px;
    border-radius: 17px;
  }

  .matrix-workspace__header {
    gap: 11px;
  }

  .matrix-workspace__header h2 {
    font-size: 19px;
  }

  .matrix-example-bar {
    gap: 5px;
  }

  .matrix-example-list button {
    min-height: 44px;
    padding-inline: 10px;
  }

  .matrix-operation-palette {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
    margin-top: 14px;
  }

  .matrix-operation-palette button {
    grid-template-columns: auto minmax(0, 1fr);
    gap: 9px;
    align-items: center;
    min-height: 54px;
    padding: 9px 10px;
  }

  .matrix-operation-palette button strong {
    font-size: 15px;
  }

  .matrix-operation-palette button span {
    text-align: end;
  }

  .matrix-expression-preview {
    margin-top: 9px;
  }

  .matrix-inputs,
  .matrix-controls {
    grid-template-columns: 1fr;
  }

  .matrix-inputs {
    gap: 9px;
    margin-top: 9px;
  }

  .matrix-card {
    gap: 9px;
    padding: 11px;
    border-radius: 13px;
  }

  .matrix-card textarea {
    min-height: 126px;
    padding: 13px 21px;
    font-size: 16px;
    line-height: 1.55;
  }

  .matrix-template-row {
    gap: 5px;
  }

  .matrix-template-row button {
    min-height: 44px;
    padding-inline: 4px;
  }

  .matrix-input-hint {
    line-height: 1.4;
  }

  .matrix-controls {
    gap: 8px;
    margin-top: 12px;
  }

  .matrix-swap,
  .matrix-calculate {
    width: 100%;
    min-height: 48px;
  }

  .matrix-calculate {
    width: 100%;
  }

  .matrix-result {
    min-height: 154px;
    margin-top: 12px;
    padding: 14px 10px;
  }

  .matrix-result__header {
    padding-inline: 3px;
  }

  #matrix-result {
    padding-top: 14px;
  }

  .matrix-output-table td {
    min-width: 58px;
    padding: 9px 8px;
  }

  .matrix-note {
    font-size: 9px;
  }

}

@media (max-width: 390px) {
  .app-nav-button {
    min-width: 38px;
  }

  .app-nav-button > span:last-child {
    display: none;
  }

  .interface-mode-toggle > span:last-child {
    max-width: 58px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .calculator-canvas {
    width: 410px;
  }

  .calculator {
    width: min(100%, 396px);
    padding-inline: 13px;
  }

  .stage-label {
    width: min(100%, 396px);
  }
}

@media (orientation: landscape) and (max-height: 600px) {
  .app-bar {
    min-height: calc(48px + env(safe-area-inset-top));
    padding-top: calc(4px + env(safe-area-inset-top));
    padding-bottom: 4px;
  }

  .app-nav-button,
  .interface-mode-toggle {
    min-height: 34px;
  }

  .calculator-dock {
    min-height: calc(46px + env(safe-area-inset-bottom));
    padding-top: 4px;
  }

  .calculator-canvas {
    width: 430px;
  }

  .calc-key {
    min-height: 50px;
    height: 50px;
    padding: 5px 6px 6px;
    font-size: 16px;
  }

  .calc-key[data-size="number"] {
    min-height: 56px;
    height: 56px;
    font-size: 23px;
  }

  .calc-key__shift,
  .calc-key__alpha,
  .calc-key__context {
    font-size: 9.5px;
  }

  .mode-workbench {
    inset: calc(54px + env(safe-area-inset-top)) 8px calc(54px + env(safe-area-inset-bottom));
  }
}

/* iOS-inspired motion system --------------------------------------------------- */

/* Shared entrance keyframes */
@keyframes rise-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes panel-enter {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Staggered hero and card entrances; restarts with the view's is-entering class.
   `backwards` (not `both`) so the fill releases transform after completion and
   hover lifts keep working. */
.app-view--scrollable.is-entering :where(.home-hero, .linear-hero, .computer-hero, .manual-hero) > * {
  animation: rise-in 420ms var(--ease-ios) backwards;
}

.app-view--scrollable.is-entering :where(.home-hero, .linear-hero, .computer-hero, .manual-hero) > *:nth-child(2) {
  animation-delay: 60ms;
}

.app-view--scrollable.is-entering :where(.home-hero, .linear-hero, .computer-hero, .manual-hero) > *:nth-child(3) {
  animation-delay: 120ms;
}

.app-view--scrollable.is-entering .home-tool-card:nth-child(1) { animation: rise-in 460ms var(--ease-ios) backwards; }
.app-view--scrollable.is-entering .home-tool-card:nth-child(2) { animation: rise-in 460ms var(--ease-ios) 60ms backwards; }
.app-view--scrollable.is-entering .home-tool-card:nth-child(3) { animation: rise-in 460ms var(--ease-ios) 120ms backwards; }
.app-view--scrollable.is-entering .home-tool-card:nth-child(4) { animation: rise-in 460ms var(--ease-ios) 180ms backwards; }

.app-view--scrollable.is-entering .matrix-workspace {
  animation: rise-in 460ms var(--ease-ios) 80ms backwards;
}

/* One-shot entrances when [hidden] is lifted (animations restart on display flip) */
.mode-workbench:not([hidden]),
[data-computer-panel]:not([hidden]),
[data-economics-panel]:not([hidden]),
.matrix-card:not([hidden]) {
  animation: panel-enter 280ms var(--ease-ios) backwards;
}

/* Press spring: fast press-in, springy release (transition follows the destination state) */
button {
  transition: transform 300ms var(--ease-spring), filter 180ms ease;
}

.calc-key {
  transition: transform 300ms var(--ease-spring), box-shadow 80ms ease, filter 100ms ease;
}

.interface-mode-toggle {
  transition: transform 300ms var(--ease-spring), background 160ms ease, border-color 160ms ease, box-shadow 90ms ease;
}

.matrix-example-list button,
.matrix-template-row button,
.matrix-swap {
  transition: border-color 150ms ease, background 150ms ease, color 150ms ease, transform 300ms var(--ease-spring);
}

.matrix-operation-palette button {
  transition: border-color 150ms ease, background 150ms ease, color 150ms ease, transform 300ms var(--ease-spring), box-shadow 150ms ease;
}

button.is-pressed {
  transition: transform 70ms ease, filter 70ms ease, box-shadow 70ms ease;
}

/* Hover lift (pointer devices only) */
.home-tool-card {
  transition: transform 300ms var(--ease-spring), border-color 200ms ease, box-shadow 260ms ease;
}

.computer-tool-card {
  transition: transform 300ms var(--ease-spring), border-color 200ms ease, box-shadow 260ms ease;
}

.matrix-card {
  transition: transform 300ms var(--ease-spring), border-color 160ms ease, box-shadow 160ms ease;
}

@media (hover: hover) and (pointer: fine) {
  .home-tool-card:hover {
    transform: translateY(-3px);
    border-color: rgba(99, 230, 190, 0.45);
    box-shadow: 0 24px 55px rgba(0, 0, 0, 0.3);
  }

  .computer-tool-card:hover {
    transform: translateY(-3px);
    border-color: rgba(255, 255, 255, 0.18);
    box-shadow: 0 26px 60px rgba(0, 0, 0, 0.26);
  }

  .matrix-card:hover {
    transform: translateY(-3px);
    border-color: rgba(99, 230, 190, 0.3);
    box-shadow: 0 14px 38px rgba(0, 0, 0, 0.22);
  }

  .primary-action:not(.is-pressed):hover,
  .app-nav-button:not(.is-pressed):hover,
  .zoom-controls button:not(.is-pressed):hover,
  .calculator-dock button:not(.is-pressed):hover,
  .interface-mode-toggle:not(.is-pressed):hover,
  .text-action:not(.is-pressed):hover,
  .matrix-operation-palette button:not(.is-pressed):hover,
  .matrix-template-row button:not(.is-pressed):hover,
  .matrix-example-list button:not(.is-pressed):hover,
  .matrix-swap:not(.is-pressed):hover {
    transform: translateY(-1px);
    filter: brightness(1.08);
  }
}

/* Ambient glow drift (decorative, transform only) */
.page-glow--one { animation: glow-drift-a 28s ease-in-out infinite alternate; }
.page-glow--two { animation: glow-drift-b 34s ease-in-out infinite alternate; }

@keyframes glow-drift-a {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to { transform: translate3d(-36px, 24px, 0) scale(1.06); }
}

@keyframes glow-drift-b {
  from { transform: translate3d(0, 0, 0) scale(1.06); }
  to { transform: translate3d(30px, -22px, 0) scale(1); }
}

/* Result refresh tick (re-triggered from app.js when the result text changes) */
.display__result.is-ticking {
  animation: result-tick 160ms ease-out;
}

@keyframes result-tick {
  from { opacity: 0.35; }
  to { opacity: 1; }
}

/* Scientific calculator entrance: the whole panel rises (relative geometry stays
   intact, so the fit-lock layout assertions keep passing), the stage fades in a
   beat later, and the dock slides up from below. */
.app-view--calculator.is-entering {
  animation: calc-view-enter 380ms var(--ease-ios) both;
}

@keyframes calc-view-enter {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

.app-view--calculator.is-entering .calculator-stage {
  animation: calc-stage-fade 320ms var(--ease-ios) 70ms backwards;
}

@keyframes calc-stage-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

.app-view--calculator.is-entering .calculator-dock {
  animation: rise-in 380ms var(--ease-ios) 60ms backwards;
}
