:root {
  color-scheme: dark;
  --bg: #071114;
  --bg-soft: #0b181c;
  --panel: #0d1d21;
  --panel-strong: #11272b;
  --ink: #f2f4ef;
  --ink-soft: #c5ceca;
  --muted: #81918f;
  --line: rgba(184, 206, 201, 0.16);
  --line-strong: rgba(184, 206, 201, 0.34);
  --cyan: #37e1da;
  --cyan-soft: #8cf5eb;
  --coral: #ff6b58;
  --gold: #e9c46a;
  --blue: #4d7fae;
  --navy: #203f61;
  --max-width: 1480px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, "Noto Sans SC", "Microsoft YaHei", Arial, sans-serif;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  color: inherit;
}

.skip-link {
  position: fixed;
  top: 0.5rem;
  left: 0.5rem;
  z-index: 100;
  transform: translateY(-160%);
  background: var(--ink);
  color: var(--bg);
  padding: 0.65rem 0.9rem;
}

.skip-link:focus {
  transform: translateY(0);
}

.theory-header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  min-height: 68px;
  border-bottom: 1px solid var(--line);
  background: rgba(7, 17, 20, 0.95);
  padding: 0.55rem clamp(1rem, 3vw, 3.2rem);
  backdrop-filter: blur(18px);
}

.theory-brand {
  display: flex;
  align-items: center;
  gap: 0.72rem;
}

.theory-brand img {
  width: 42px;
  height: 42px;
}

.theory-brand span {
  display: flex;
  flex-direction: column;
  font-family: "Songti SC", STSong, Georgia, serif;
}

.theory-brand strong {
  font-size: 1rem;
}

.theory-brand small {
  color: var(--muted);
  font-size: 0.68rem;
}

.theory-nav {
  display: flex;
  justify-content: center;
  gap: clamp(1rem, 2.7vw, 2.4rem);
}

.theory-nav a,
.home-link,
.sibling-link {
  color: var(--ink-soft);
  font-size: 0.75rem;
  font-weight: 700;
}

.theory-nav a:hover,
.home-link:hover,
.sibling-link:hover {
  color: var(--cyan);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.sibling-link {
  border-right: 1px solid var(--line-strong);
  padding-right: 1rem;
}

.language-toggle {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 3px;
  background: transparent;
  color: var(--cyan);
  cursor: pointer;
  font-size: 0.7rem;
  font-weight: 800;
}

.language-toggle:hover {
  border-color: var(--cyan);
  background: rgba(55, 225, 218, 0.08);
}

main {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.theory-intro {
  order: 0;
}

.calculation-section {
  order: 1;
}

.response-section {
  order: 2;
}

.pca-section {
  order: 3;
}

.theory-intro {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(380px, 0.9fr);
  gap: clamp(2rem, 6vw, 7rem);
  align-items: end;
  min-height: min(660px, calc(100vh - 68px));
  max-width: var(--max-width);
  margin: 0 auto;
  padding: clamp(4.2rem, 9vh, 7.5rem) clamp(1.2rem, 4vw, 4rem) clamp(3rem, 7vh, 5.5rem);
}

.theory-intro::before {
  position: absolute;
  inset: 0 50% 0 auto;
  width: 50vw;
  border-left: 1px solid rgba(55, 225, 218, 0.12);
  background-image: linear-gradient(rgba(55, 225, 218, 0.04) 1px, transparent 1px), linear-gradient(90deg, rgba(55, 225, 218, 0.04) 1px, transparent 1px);
  background-size: 32px 32px;
  content: "";
  pointer-events: none;
  opacity: 0.65;
}

.intro-copy,
.intro-facts {
  position: relative;
  z-index: 1;
}

.eyebrow,
.section-label p,
.basis-heading p,
.rail-heading p,
.parameter-head p {
  margin: 0;
  color: var(--cyan);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 0.67rem;
  font-weight: 800;
  letter-spacing: 0;
}

.intro-copy h1 {
  display: flex;
  max-width: 900px;
  margin: 1rem 0 1.4rem;
  flex-direction: column;
  font-family: "Songti SC", STSong, Georgia, serif;
  font-size: clamp(3.1rem, 6.3vw, 6.7rem);
  font-weight: 500;
  line-height: 0.98;
  letter-spacing: 0;
}

.intro-copy h1 span:last-child {
  color: var(--cyan-soft);
}

.intro-lead {
  max-width: 760px;
  margin: 0;
  color: var(--ink-soft);
  font-family: "Songti SC", STSong, Georgia, serif;
  font-size: clamp(1.05rem, 1.5vw, 1.35rem);
  line-height: 1.9;
}

.intro-facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 0;
  border-top: 1px solid var(--line-strong);
  border-left: 1px solid var(--line-strong);
}

.intro-facts div {
  min-height: 118px;
  border-right: 1px solid var(--line-strong);
  border-bottom: 1px solid var(--line-strong);
  padding: 1.2rem;
}

.intro-facts dt {
  color: var(--coral);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2rem, 4vw, 3.7rem);
  line-height: 1;
}

.intro-facts dd {
  margin: 0.6rem 0 0;
  color: var(--muted);
  font-size: 0.75rem;
}

.pipeline-band,
.pca-section,
.response-section {
  border-top: 1px solid var(--line);
  padding: clamp(3rem, 7vw, 6.5rem) clamp(1.2rem, 4vw, 4rem);
}

.pipeline-band {
  background: #091519;
}

.pipeline-band > *,
.pca-section > *,
.response-section > * {
  width: min(100%, var(--max-width));
  margin-right: auto;
  margin-left: auto;
}

.section-label {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
}

.section-label > span {
  min-width: 36px;
  color: var(--coral);
  font-family: Georgia, serif;
  font-size: 0.78rem;
  font-style: italic;
  padding-top: 0.22rem;
}

.section-label h2 {
  margin: 0.35rem 0 0;
  font-family: "Songti SC", STSong, Georgia, serif;
  font-size: clamp(1.7rem, 3vw, 2.8rem);
  font-weight: 500;
  line-height: 1.2;
}

.pipeline-steps {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: 2.8rem;
  border-top: 1px solid var(--line-strong);
  border-left: 1px solid var(--line-strong);
}

.pipeline-step {
  position: relative;
  display: grid;
  min-height: 150px;
  border: 0;
  border-right: 1px solid var(--line-strong);
  border-bottom: 1px solid var(--line-strong);
  background: transparent;
  text-align: left;
  padding: 1.3rem;
  cursor: pointer;
}

.pipeline-step::after {
  position: absolute;
  right: -10px;
  top: 50%;
  z-index: 2;
  width: 19px;
  height: 1px;
  background: var(--line-strong);
  content: "";
}

.pipeline-step:last-child::after {
  display: none;
}

.pipeline-step > span {
  color: var(--muted);
  font-family: Consolas, monospace;
  font-size: 0.68rem;
}

.pipeline-step strong {
  align-self: end;
  font-family: "Songti SC", STSong, Georgia, serif;
  font-size: 1.16rem;
  font-weight: 600;
}

.pipeline-step small {
  overflow: hidden;
  color: var(--muted);
  font-family: Georgia, serif;
  font-size: 0.73rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pipeline-step.active {
  background: rgba(55, 225, 218, 0.07);
  box-shadow: inset 0 3px 0 var(--cyan);
}

.pipeline-step.active > span,
.pipeline-step:hover strong {
  color: var(--cyan);
}

.pipeline-readout {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(320px, 0.7fr);
  gap: 2rem;
  align-items: center;
  margin-top: 1.4rem;
}

.pipeline-readout p {
  margin: 0;
  color: var(--ink-soft);
  font-family: "Songti SC", STSong, Georgia, serif;
  font-size: 0.98rem;
  line-height: 1.8;
}

.pipeline-readout code {
  overflow: hidden;
  border-left: 2px solid var(--coral);
  color: var(--gold);
  font-family: Georgia, serif;
  font-size: 0.9rem;
  padding-left: 1rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.section-heading {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 0.72fr);
  gap: 3rem;
  align-items: end;
}

.section-heading > p {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.85;
}

.class-selector {
  display: grid;
  grid-template-columns: repeat(10, minmax(62px, 1fr));
  margin-top: 2.5rem;
  border-top: 1px solid var(--line-strong);
  border-left: 1px solid var(--line-strong);
}

.class-selector button {
  display: flex;
  min-height: 64px;
  border: 0;
  border-right: 1px solid var(--line-strong);
  border-bottom: 1px solid var(--line-strong);
  background: transparent;
  flex-direction: column;
  justify-content: center;
  cursor: pointer;
}

.class-selector b {
  font-family: Georgia, serif;
  font-size: 1rem;
  font-weight: 500;
}

.class-selector span {
  margin-top: 0.15rem;
  color: var(--muted);
  font-family: Consolas, monospace;
  font-size: 0.58rem;
}

.class-selector button:hover,
.class-selector button.active {
  background: rgba(255, 107, 88, 0.08);
  color: var(--coral);
}

.class-selector button.active {
  box-shadow: inset 0 3px 0 var(--coral);
}

.pca-workbench {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(310px, 0.7fr);
  min-height: 660px;
  margin-top: 1rem;
  border: 1px solid var(--line-strong);
}

.field-panel {
  min-width: 0;
  border-right: 1px solid var(--line-strong);
  padding: clamp(1rem, 2.2vw, 2rem);
}

.panel-topline,
.curve-topline {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  min-height: 46px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 0.75rem;
}

.panel-topline > div:first-child,
.curve-topline > div:first-child {
  display: flex;
  flex-direction: column;
}

.panel-topline span,
.curve-topline span {
  color: var(--cyan);
  font-family: Consolas, monospace;
  font-size: 0.62rem;
  font-weight: 700;
}

.panel-topline strong,
.curve-topline strong {
  margin-top: 0.2rem;
  font-family: "Songti SC", STSong, Georgia, serif;
  font-size: 1.05rem;
}

.field-modes {
  display: flex;
  border: 1px solid var(--line-strong);
}

.field-modes button {
  min-height: 32px;
  border: 0;
  border-right: 1px solid var(--line-strong);
  background: transparent;
  padding: 0 0.75rem;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.66rem;
  font-weight: 700;
}

.field-modes button:last-child {
  border-right: 0;
}

.field-modes button.active {
  background: var(--cyan);
  color: #041012;
}

.field-stage {
  position: relative;
  display: grid;
  width: min(100%, 660px);
  aspect-ratio: 1;
  margin: 1.4rem auto 0;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  background: #071014;
  cursor: crosshair;
}

.field-stage::after {
  position: absolute;
  inset: 0;
  border: 8px solid rgba(7, 17, 20, 0.35);
  content: "";
  pointer-events: none;
}

#fieldCanvas {
  display: block;
  width: 100%;
  height: 100%;
}

.field-crosshair {
  position: absolute;
  z-index: 3;
  width: 3.125%;
  height: 3.125%;
  border: 1px solid #fff;
  box-shadow: 0 0 12px rgba(55, 225, 218, 0.9);
  pointer-events: none;
}

.field-tooltip,
.curve-tooltip {
  position: absolute;
  z-index: 4;
  border: 1px solid var(--cyan);
  background: rgba(4, 13, 15, 0.94);
  color: var(--ink);
  font-family: Consolas, monospace;
  font-size: 0.65rem;
  line-height: 1.5;
  padding: 0.5rem 0.6rem;
  pointer-events: none;
}

.field-corner {
  position: absolute;
  right: 0.9rem;
  bottom: 0.8rem;
  z-index: 2;
  display: flex;
  border-left: 2px solid var(--coral);
  background: rgba(7, 17, 20, 0.82);
  flex-direction: column;
  padding: 0.45rem 0.65rem;
  pointer-events: none;
}

.field-corner span {
  font-family: Consolas, monospace;
  font-size: 0.65rem;
  font-weight: 700;
}

.field-corner em {
  margin-top: 0.15rem;
  color: var(--muted);
  font-size: 0.59rem;
  font-style: normal;
}

.field-scale {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 0.7rem;
  align-items: center;
  width: min(100%, 660px);
  margin: 0.7rem auto 0;
  color: var(--muted);
  font-size: 0.65rem;
}

.field-scale i {
  height: 5px;
  background: linear-gradient(90deg, #183b61 0%, #89c8c8 46%, #ecddae 54%, #d45448 100%);
}

.theory-rail {
  min-width: 0;
  background: #09171a;
  padding: clamp(1.2rem, 2.2vw, 2rem);
}

.rail-heading {
  border-bottom: 1px solid var(--line);
  padding-bottom: 1rem;
}

.rail-heading h3 {
  margin: 0.35rem 0 0.65rem;
  font-family: "Songti SC", STSong, Georgia, serif;
  font-size: 1.5rem;
  font-weight: 500;
}

.rail-heading code {
  display: block;
  overflow-wrap: anywhere;
  color: var(--gold);
  font-family: Georgia, serif;
  font-size: 0.78rem;
  line-height: 1.55;
}

.descriptor-list {
  display: grid;
  gap: 0.85rem;
  margin-top: 1.3rem;
}

.descriptor-row {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr) 54px;
  gap: 0.7rem;
  align-items: center;
}

.descriptor-row label,
.descriptor-row output {
  color: var(--muted);
  font-family: Georgia, serif;
  font-size: 0.68rem;
}

.descriptor-row output {
  color: var(--ink-soft);
  text-align: right;
}

.descriptor-track {
  position: relative;
  height: 4px;
  background: rgba(255, 255, 255, 0.08);
}

.descriptor-track i {
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--value);
  background: var(--cyan);
}

.descriptor-track b {
  position: absolute;
  top: -4px;
  bottom: -4px;
  left: var(--threshold);
  width: 1px;
  background: var(--coral);
}

.condition-trace {
  margin-top: 1.6rem;
  border-top: 1px solid var(--line);
}

.condition-row {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto;
  gap: 0.6rem;
  align-items: center;
  min-height: 42px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-family: Consolas, monospace;
  font-size: 0.65rem;
}

.condition-row > span:first-child {
  color: var(--cyan);
}

.condition-row b {
  color: var(--ink-soft);
  font-weight: 500;
}

.condition-row em {
  color: var(--cyan);
  font-size: 0.58rem;
  font-style: normal;
}

.sample-facts {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin: 1.6rem 0 0;
  border-top: 1px solid var(--line-strong);
  border-left: 1px solid var(--line-strong);
}

.sample-facts div {
  min-width: 0;
  border-right: 1px solid var(--line-strong);
  border-bottom: 1px solid var(--line-strong);
  padding: 0.75rem 0.5rem;
}

.sample-facts dt {
  color: var(--muted);
  font-size: 0.55rem;
  white-space: nowrap;
}

.sample-facts dd {
  overflow: hidden;
  margin: 0.32rem 0 0;
  color: var(--coral);
  font-family: Georgia, serif;
  font-size: 0.85rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.skeleton-readout {
  margin-top: 1.5rem;
  border-top: 1px solid var(--line);
  padding-top: 1rem;
}

.skeleton-readout > p {
  margin: 0 0 0.65rem;
  color: var(--muted);
  font-family: Consolas, monospace;
  font-size: 0.61rem;
  font-weight: 700;
}

.skeleton-point {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) 118px;
  gap: 0.65rem;
  align-items: center;
  min-height: 38px;
  border-bottom: 1px solid var(--line);
}

.skeleton-point > span {
  color: var(--gold);
  font-family: Georgia, serif;
  font-size: 0.72rem;
}

.skeleton-point i {
  position: relative;
  display: block;
  height: 3px;
  background: rgba(255, 255, 255, 0.08);
}

.skeleton-point i::before,
.skeleton-point i::after {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: var(--d);
  background: var(--cyan);
  content: "";
}

.skeleton-point i::after {
  top: 7px;
  width: var(--f);
  background: var(--coral);
}

.skeleton-point b {
  color: var(--ink-soft);
  font-family: Consolas, monospace;
  font-size: 0.59rem;
  font-weight: 500;
  text-align: right;
  white-space: nowrap;
}

.basis-console {
  margin-top: 1rem;
  border: 1px solid var(--line-strong);
  padding: clamp(1rem, 2.2vw, 2rem);
}

.basis-heading {
  display: flex;
  justify-content: space-between;
  gap: 2rem;
  align-items: end;
}

.basis-heading h3 {
  margin: 0.3rem 0 0;
  font-family: "Songti SC", STSong, Georgia, serif;
  font-size: 1.35rem;
  font-weight: 500;
}

.basis-heading > p {
  max-width: 430px;
  color: var(--muted);
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 400;
  line-height: 1.65;
  text-align: right;
}

.basis-strip {
  display: grid;
  grid-template-columns: repeat(8, minmax(90px, 1fr));
  gap: 0.7rem;
  margin-top: 1.35rem;
}

.basis-tile {
  position: relative;
  min-width: 0;
  border: 1px solid var(--line);
  background: #09171a;
  padding: 0.45rem;
  cursor: pointer;
}

.basis-tile canvas {
  display: block;
  width: 100%;
  aspect-ratio: 1;
}

.basis-tile span {
  display: flex;
  justify-content: space-between;
  margin-top: 0.4rem;
  color: var(--muted);
  font-family: Consolas, monospace;
  font-size: 0.58rem;
}

.basis-tile.active,
.basis-tile:hover {
  border-color: var(--cyan);
  box-shadow: 0 0 18px rgba(55, 225, 218, 0.13);
}

.basis-tile.active span {
  color: var(--cyan);
}

.basis-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: clamp(1rem, 3vw, 3rem);
  align-items: end;
  margin-top: 1.6rem;
  border-top: 1px solid var(--line);
  padding-top: 1.2rem;
}

.range-control {
  display: grid;
  gap: 0.72rem;
}

.range-control > span {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  color: var(--ink-soft);
  font-size: 0.7rem;
}

.range-control output {
  color: var(--cyan);
  font-family: Consolas, monospace;
}

input[type="range"] {
  width: 100%;
  height: 4px;
  appearance: none;
  border-radius: 0;
  background: rgba(255, 255, 255, 0.14);
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  width: 16px;
  height: 16px;
  appearance: none;
  border: 2px solid #071114;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 0 1px var(--cyan), 0 0 12px rgba(55, 225, 218, 0.55);
}

input[type="range"]::-moz-range-thumb {
  width: 13px;
  height: 13px;
  border: 2px solid #071114;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 0 1px var(--cyan), 0 0 12px rgba(55, 225, 218, 0.55);
}

.reset-button {
  min-height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 3px;
  background: transparent;
  padding: 0 1rem;
  color: var(--ink-soft);
  cursor: pointer;
  font-size: 0.68rem;
  font-weight: 700;
}

.reset-button:hover {
  border-color: var(--coral);
  color: var(--coral);
}

.variance-chart-wrap {
  height: 150px;
  margin-top: 1.2rem;
}

#varianceChart,
#hysteresisChart {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.response-section {
  background: #081316;
}

.response-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(330px, 0.65fr);
  min-height: 650px;
  margin-top: 2.5rem;
  border: 1px solid var(--line-strong);
}

.curve-panel {
  min-width: 0;
  border-right: 1px solid var(--line-strong);
  padding: clamp(1rem, 2.2vw, 2rem);
}

.curve-legend {
  display: flex;
  gap: 1.4rem;
}

.curve-legend span {
  position: relative;
  color: var(--muted);
  padding-left: 1.6rem;
}

.curve-legend span::before {
  position: absolute;
  top: 50%;
  left: 0;
  width: 1.15rem;
  height: 2px;
  background: var(--blue);
  content: "";
}

.curve-legend .formula-key::before {
  background: var(--coral);
}

.curve-stage {
  position: relative;
  height: 550px;
  margin-top: 1rem;
}

.parameter-rail {
  background: #0a181b;
  padding: clamp(1.2rem, 2.2vw, 2rem);
}

.parameter-head {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.parameter-head button {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border: 1px solid var(--cyan);
  border-radius: 50%;
  background: transparent;
  color: var(--cyan);
  cursor: pointer;
}

.parameter-head button:hover,
.parameter-head button.playing {
  background: var(--cyan);
  color: var(--bg);
  box-shadow: 0 0 22px rgba(55, 225, 218, 0.25);
}

.parameter-head strong {
  display: block;
  margin-top: 0.3rem;
  color: var(--ink-soft);
  font-family: Consolas, monospace;
  font-size: 0.78rem;
}

#responseRange {
  margin-top: 1.4rem;
}

.response-values {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  margin: 1.5rem 0 0;
  border-top: 1px solid var(--line-strong);
  border-left: 1px solid var(--line-strong);
}

.response-values div {
  border-right: 1px solid var(--line-strong);
  border-bottom: 1px solid var(--line-strong);
  padding: 0.9rem;
}

.response-values dt {
  color: var(--muted);
  font-family: Georgia, serif;
  font-size: 0.65rem;
}

.response-values dd {
  margin: 0.4rem 0 0;
  color: var(--ink);
  font-family: Consolas, monospace;
  font-size: 0.86rem;
}

.shape-parameters {
  margin-top: 1.5rem;
  border-top: 1px solid var(--line);
}

.shape-row {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) auto;
  gap: 0.8rem;
  align-items: center;
  min-height: 48px;
  border-bottom: 1px solid var(--line);
}

.shape-row code {
  color: var(--gold);
  font-family: Georgia, serif;
}

.shape-row span {
  color: var(--muted);
  font-size: 0.67rem;
}

.shape-row strong {
  color: var(--cyan);
  font-family: Consolas, monospace;
  font-size: 0.73rem;
  font-weight: 500;
}

.parameter-vector {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 0.8rem;
  align-items: center;
  margin-top: 1.6rem;
  color: var(--ink-soft);
  font-family: Georgia, serif;
}

.parameter-vector span {
  color: var(--coral);
  font-size: 1.25rem;
}

.parameter-vector i {
  height: 1px;
  background: var(--line-strong);
}

.parameter-vector strong {
  color: var(--muted);
  font-size: 0.65rem;
}

footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 100px;
  border-top: 1px solid var(--line);
  background: #050d0f;
  color: var(--muted);
  padding: 1.5rem clamp(1.2rem, 4vw, 4rem);
  font-family: Consolas, monospace;
  font-size: 0.64rem;
}

footer a {
  color: var(--cyan);
}

/* Interactive explicit-performance calculator */
.theory-intro {
  grid-template-columns: minmax(0, 1.5fr) minmax(470px, 0.9fr);
  gap: 4rem;
  min-height: 470px;
  padding-top: 5rem;
  padding-bottom: 3.8rem;
}

.theory-intro::before {
  inset: 0 0 0 auto;
  width: 42%;
}

.intro-copy h1 {
  margin: 0.72rem 0 1.2rem;
  font-size: clamp(2.4rem, 4.4vw, 4.7rem);
  font-weight: 600;
  line-height: 1.14;
}

.intro-lead {
  font-size: 1.1rem;
}

.calculation-section {
  border-top: 1px solid var(--line);
  background: #091519;
  padding: clamp(3rem, 7vw, 6.5rem) clamp(1.2rem, 4vw, 4rem);
}

.calculation-section > * {
  width: min(100%, var(--max-width));
  margin-right: auto;
  margin-left: auto;
}

.calculation-classes button {
  min-height: 74px;
}

.class-selector small {
  margin-top: 0.08rem;
  color: rgba(126, 150, 154, 0.72);
  font-family: Consolas, monospace;
  font-size: 0.52rem;
}

.calculation-workbench {
  position: relative;
  display: grid;
  grid-template-columns: minmax(300px, 0.78fr) minmax(520px, 1.42fr) minmax(290px, 0.72fr);
  min-height: 700px;
  margin-top: 1rem;
  border: 1px solid var(--line-strong);
  background: #071216;
}

.result-particle {
  position: absolute;
  z-index: 20;
  display: grid;
  min-width: 48px;
  min-height: 24px;
  place-items: center;
  border: 1px solid var(--coral);
  background: rgba(7, 17, 20, 0.95);
  box-shadow: 0 0 22px rgba(255, 107, 88, 0.46);
  color: var(--ink);
  font-family: Consolas, monospace;
  font-size: 0.53rem;
  padding: 0.25rem 0.4rem;
  pointer-events: none;
}

.micro-input,
.matrix-engine,
.performance-output {
  position: relative;
  min-width: 0;
  padding: clamp(1rem, 1.8vw, 1.65rem);
  transition: border-color 240ms ease, box-shadow 240ms ease, opacity 240ms ease;
}

.micro-input,
.matrix-engine {
  border-right: 1px solid var(--line-strong);
}

.calc-panel-head,
.matrix-head {
  display: flex;
  min-height: 56px;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  border-bottom: 1px solid var(--line);
  padding-bottom: 0.8rem;
}

.calc-panel-head p,
.matrix-head p,
.performance-head p {
  margin: 0;
  color: var(--cyan);
  font-family: Consolas, monospace;
  font-size: 0.61rem;
  font-weight: 800;
}

.calc-panel-head h3,
.matrix-head h3,
.performance-head h3 {
  margin: 0.25rem 0 0;
  font-family: "Songti SC", STSong, Georgia, serif;
  font-size: 1.18rem;
  font-weight: 500;
}

.micro-modes,
.matrix-family {
  display: flex;
  flex: 0 0 auto;
  border: 1px solid var(--line-strong);
}

.micro-modes button,
.matrix-family button {
  min-height: 31px;
  border: 0;
  border-right: 1px solid var(--line-strong);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 0 0.62rem;
  font-size: 0.61rem;
  font-weight: 750;
}

.matrix-family button {
  width: 34px;
  padding: 0;
  font-family: Georgia, serif;
}

.micro-modes button:last-child,
.matrix-family button:last-child {
  border-right: 0;
}

.micro-modes button.active,
.matrix-family button.active {
  background: var(--cyan);
  color: #041012;
}

.micro-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 720 / 520;
  margin-top: 1rem;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #061014;
  cursor: crosshair;
}

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

.feature-overlay {
  position: absolute;
  z-index: 3;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  color: var(--cyan);
  pointer-events: none;
}

.feature-zoom {
  --feature-color: var(--cyan);
  position: absolute;
  z-index: 5;
  top: 0;
  left: 0;
  width: min(42%, 240px);
  border: 1px solid color-mix(in srgb, var(--feature-color) 72%, #20383d);
  background: rgba(4, 13, 17, 0.94);
  box-shadow: 0 0 0 1px rgba(2, 8, 10, 0.9), 0 0 24px color-mix(in srgb, var(--feature-color) 18%, transparent);
  color: var(--feature-color);
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px) scale(0.82);
  transform-origin: center;
  visibility: hidden;
  transition: border-color 180ms ease, box-shadow 180ms ease, opacity 170ms ease, transform 220ms cubic-bezier(.2,.8,.2,1), visibility 0s linear 220ms;
}

.feature-zoom.is-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  visibility: visible;
  transition-delay: 0s;
}

.feature-zoom::before,
.feature-zoom::after {
  position: absolute;
  z-index: 4;
  width: 18px;
  height: 18px;
  border-color: var(--feature-color);
  content: "";
  pointer-events: none;
}

.feature-zoom::before {
  top: -4px;
  left: -4px;
  border-top: 2px solid;
  border-left: 2px solid;
}

.feature-zoom::after {
  right: -4px;
  bottom: -4px;
  border-right: 2px solid;
  border-bottom: 2px solid;
}

.feature-zoom-head,
.feature-zoom-readout {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.42rem 0.5rem;
}

.feature-zoom-head {
  border-bottom: 1px solid color-mix(in srgb, var(--feature-color) 28%, transparent);
}

.feature-zoom-head span,
.feature-zoom-readout span {
  overflow: hidden;
  color: var(--ink-soft);
  font-size: 0.46rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.feature-zoom-head span {
  font-family: Consolas, monospace;
  letter-spacing: 0;
}

.feature-zoom-head b {
  color: var(--feature-color);
  font-family: Georgia, serif;
  font-size: 0.72rem;
  text-shadow: 0 0 10px currentColor;
}

.feature-zoom-field {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  overflow: hidden;
  background: #050f13;
}

#featureZoomCanvas,
#featureZoomOverlay {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

#featureZoomCanvas {
  opacity: 0.88;
  filter: contrast(1.08) brightness(0.9);
}

#featureZoomOverlay {
  z-index: 2;
  overflow: visible;
  color: var(--feature-color);
  filter: drop-shadow(0 0 5px currentColor);
}

.feature-zoom-readout {
  border-top: 1px solid color-mix(in srgb, var(--feature-color) 28%, transparent);
  background: color-mix(in srgb, var(--feature-color) 5%, #061014);
}

.feature-zoom-readout strong {
  color: var(--feature-color);
  font-family: Consolas, monospace;
  font-size: 0.58rem;
  font-weight: 650;
  text-shadow: 0 0 10px currentColor;
}

.feature-zoom-scan {
  position: absolute;
  z-index: 3;
  top: 0;
  right: 0;
  left: 0;
  height: 1px;
  background: var(--feature-color);
  box-shadow: 0 0 9px 2px color-mix(in srgb, var(--feature-color) 55%, transparent);
  opacity: 0.72;
  pointer-events: none;
}

.calculation-playing .feature-zoom {
  box-shadow: 0 0 0 1px rgba(2, 8, 10, 0.9), 0 0 34px color-mix(in srgb, var(--feature-color) 30%, transparent);
}

.calculation-playing .feature-zoom-scan,
.stage-active .feature-zoom-scan {
  animation: feature-zoom-scan 1.15s ease-in-out infinite;
}

.zoom-corners,
.zoom-window,
.zoom-dimension,
.zoom-grid,
.zoom-brackets,
.zoom-correlation,
.zoom-offset,
.zoom-interface,
.probe-selection,
.probe-connector,
.probe-interface {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}

.zoom-corners {
  stroke-width: 2.5;
}

.zoom-window,
.probe-selection {
  fill: color-mix(in srgb, currentColor 5%, transparent);
  stroke-dasharray: 9 6;
}

.zoom-local,
.zoom-volume {
  fill: color-mix(in srgb, currentColor 12%, transparent);
}

.zoom-grid,
.zoom-offset {
  opacity: 0.55;
  stroke-width: 1;
  stroke-dasharray: 3 4;
}

.zoom-dimension,
.zoom-correlation,
.zoom-interface,
.probe-interface {
  stroke-dasharray: 9 6;
}

.zoom-interface.secondary {
  opacity: 0.58;
  stroke-dasharray: 4 8;
}

.zoom-node,
.zoom-samples circle,
.probe-origin {
  fill: currentColor;
  stroke: #f3f5ef;
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

.zoom-samples circle:nth-child(even) {
  opacity: 0.48;
}

.zoom-symbol {
  fill: currentColor;
  font-family: Georgia, serif;
  font-size: 18px;
  font-weight: 700;
  text-anchor: middle;
}

.probe-connector {
  opacity: 0.68;
  stroke-dasharray: 5 8;
}

.probe-selection {
  stroke-width: 2.5;
}

.probe-volume-window {
  fill: color-mix(in srgb, currentColor 10%, transparent);
}

.feature-probe {
  filter: drop-shadow(0 0 5px currentColor);
}

.probe-window,
.probe-dimension,
.probe-trace,
.probe-correlation,
.probe-sweep {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}

.probe-window {
  fill: color-mix(in srgb, currentColor 5%, transparent);
  stroke-dasharray: 10 7;
}

.probe-block {
  fill: color-mix(in srgb, currentColor 13%, transparent);
}

.probe-dimension {
  stroke-dasharray: 3 5;
}

.probe-trace,
.probe-correlation {
  stroke-dasharray: 8 6;
}

.probe-sweep {
  stroke-width: 3;
}

.probe-node {
  fill: currentColor;
  stroke: #f2f4ef;
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

.probe-label {
  fill: currentColor;
  font-family: Georgia, serif;
  font-size: 18px;
  font-weight: 700;
  text-anchor: middle;
}

.feature-anchor {
  fill: currentColor;
  opacity: 0.01;
}

.calculation-playing .feature-probe .probe-window,
.calculation-playing .feature-probe .probe-trace,
.calculation-playing .feature-probe .probe-correlation,
.calculation-playing .feature-probe .probe-dimension,
.calculation-playing .feature-probe .probe-interface,
.calculation-playing .feature-probe .probe-connector,
.calculation-playing .zoom-probe path {
  animation: feature-trace 1.15s linear infinite;
}

.calculation-playing .feature-probe .probe-node,
.calculation-playing .zoom-node,
.calculation-playing .zoom-samples circle {
  animation: feature-node 720ms ease-in-out infinite alternate;
}

.micro-tooltip {
  position: absolute;
  z-index: 4;
  border: 1px solid var(--cyan);
  background: rgba(4, 13, 15, 0.95);
  color: var(--ink-soft);
  font-family: Consolas, monospace;
  font-size: 0.59rem;
  line-height: 1.55;
  padding: 0.45rem 0.55rem;
  pointer-events: none;
}

.micro-tooltip b {
  color: var(--cyan);
  font-weight: 700;
}

.scan-line {
  position: absolute;
  z-index: 2;
  top: -12%;
  right: 0;
  left: 0;
  height: 1px;
  background: var(--cyan);
  box-shadow: 0 0 12px 2px rgba(55, 225, 218, 0.48);
  opacity: 0;
  pointer-events: none;
}

.stage-active .scan-line,
.calculation-playing .scan-line {
  animation: micro-scan 2.2s ease-in-out infinite;
  opacity: 0.75;
}

@keyframes micro-scan {
  0% { top: 4%; opacity: 0; }
  15%, 85% { opacity: 0.78; }
  100% { top: 96%; opacity: 0; }
}

@keyframes feature-trace {
  to { stroke-dashoffset: -32; }
}

@keyframes feature-node {
  from { opacity: 0.55; }
  to { opacity: 1; }
}

@keyframes feature-zoom-scan {
  0% { top: 2%; opacity: 0; }
  16%, 84% { opacity: 0.82; }
  100% { top: 98%; opacity: 0; }
}

.micro-equation {
  min-height: 50px;
  margin-top: 0.8rem;
  border-left: 2px solid var(--coral);
  color: var(--gold);
  font-family: Georgia, serif;
  font-size: 0.78rem;
  padding: 0.7rem 0 0.7rem 0.8rem;
}

.micro-facts {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin: 0;
  border-top: 1px solid var(--line-strong);
  border-left: 1px solid var(--line-strong);
}

.micro-facts div {
  border-right: 1px solid var(--line-strong);
  border-bottom: 1px solid var(--line-strong);
  padding: 0.65rem;
}

.micro-facts dt {
  color: var(--muted);
  font-family: Georgia, serif;
  font-size: 0.63rem;
}

.micro-facts dd {
  margin: 0.2rem 0 0;
  color: var(--ink);
  font-family: Consolas, monospace;
  font-size: 0.69rem;
}

.feature-extraction {
  --feature-color: var(--cyan);
  margin-top: 0.9rem;
  border-top: 1px solid var(--line-strong);
  padding-top: 0.85rem;
}

.feature-extraction-head {
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
  align-items: flex-start;
}

.feature-extraction-head p {
  margin: 0;
  color: var(--feature-color);
  font-family: Consolas, monospace;
  font-size: 0.52rem;
  font-weight: 800;
}

.feature-extraction-head strong {
  display: block;
  margin-top: 0.2rem;
  font-family: "Songti SC", STSong, Georgia, serif;
  font-size: 0.9rem;
  font-weight: 500;
}

.feature-extraction-head > span {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--muted);
  font-family: Consolas, monospace;
  font-size: 0.5rem;
  white-space: nowrap;
}

.feature-extraction-head > span i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--feature-color);
  box-shadow: 0 0 8px var(--feature-color);
}

.feature-extraction-head > span b {
  font-weight: 650;
}

.calculation-playing .feature-extraction-head > span i {
  animation: feature-status 720ms ease-in-out infinite alternate;
}

.feature-chips {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  margin-top: 0.65rem;
  background: var(--line-strong);
  border: 1px solid var(--line-strong);
}

.feature-chip {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-rows: auto auto;
  min-width: 0;
  min-height: 58px;
  gap: 0.1rem 0.5rem;
  align-content: center;
  background: #081519;
  padding: 0.48rem 0.55rem;
  transition: background 180ms ease, box-shadow 180ms ease, opacity 180ms ease;
}

.feature-chip::before {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 2px;
  background: var(--feature-color);
  content: "";
  opacity: 0.22;
}

.feature-chip > span {
  grid-row: 1 / 3;
  align-self: center;
  color: var(--feature-color);
  font-family: Georgia, serif;
  font-size: 0.76rem;
  font-weight: 700;
}

.feature-chip b {
  overflow: hidden;
  color: var(--ink);
  font-family: Consolas, monospace;
  font-size: 0.65rem;
  font-weight: 650;
  text-overflow: ellipsis;
}

.feature-chip small {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.49rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.feature-chip.is-seen::before {
  opacity: 0.7;
}

.feature-chip.is-active {
  background: color-mix(in srgb, var(--feature-color) 16%, #081519);
  box-shadow: inset 0 0 24px color-mix(in srgb, var(--feature-color) 20%, transparent), 0 0 12px color-mix(in srgb, var(--feature-color) 18%, transparent);
}

.feature-chip.is-active > span,
.feature-chip.is-active b {
  color: var(--feature-color);
  text-shadow: 0 0 10px currentColor;
}

.feature-chip.is-active::before,
.feature-chip.is-receiving::before {
  width: 3px;
  opacity: 1;
}

.feature-chip.is-receiving {
  box-shadow: inset 0 0 22px color-mix(in srgb, var(--feature-color) 24%, transparent), 0 0 14px color-mix(in srgb, var(--feature-color) 20%, transparent);
}

.feature-progress {
  position: relative;
  display: flex;
  height: 18px;
  align-items: center;
  justify-content: flex-end;
  margin-top: 0.45rem;
  background: rgba(184, 206, 201, 0.07);
  overflow: hidden;
}

.feature-progress i {
  position: absolute;
  inset: 0 auto 0 0;
  width: 25%;
  background: color-mix(in srgb, var(--feature-color) 32%, transparent);
  box-shadow: 0 0 13px color-mix(in srgb, var(--feature-color) 42%, transparent);
  transition: width 220ms ease, background 180ms ease;
}

.feature-progress span {
  position: relative;
  z-index: 1;
  color: var(--ink-soft);
  font-family: Consolas, monospace;
  font-size: 0.48rem;
  padding-right: 0.45rem;
}

.feature-particle {
  position: absolute;
  z-index: 20;
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 1px solid var(--feature-color);
  background: rgba(6, 16, 20, 0.96);
  box-shadow: 0 0 18px color-mix(in srgb, var(--feature-color) 58%, transparent);
  color: var(--feature-color);
  font-family: Georgia, serif;
  font-size: 0.58rem;
  font-weight: 700;
  pointer-events: none;
}

@keyframes feature-status {
  from { opacity: 0.4; transform: scale(0.75); }
  to { opacity: 1; transform: scale(1.25); }
}

.matrix-equation {
  min-height: 52px;
  margin-top: 1rem;
  border-top: 1px solid rgba(227, 199, 95, 0.28);
  border-bottom: 1px solid rgba(227, 199, 95, 0.28);
  color: var(--gold);
  font-family: Georgia, serif;
  font-size: 0.76rem;
  line-height: 1.65;
  padding: 0.7rem 0;
  text-align: center;
}

.matrix-expression {
  position: relative;
  min-height: 560px;
  margin-top: 0.8rem;
  padding: 0.2rem 0.1rem;
}

.matrix-flow-layer {
  position: absolute;
  z-index: 1;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.matrix-flow-layer path {
  fill: none;
  stroke-linecap: round;
  stroke-width: 1.5;
  opacity: 0;
  filter: drop-shadow(0 0 5px currentColor);
}

#basisFlowPath {
  color: var(--gold);
  stroke: currentColor;
}

#coefficientFlowPath {
  color: var(--cyan);
  stroke: currentColor;
}

#outputFlowPath {
  color: var(--coral);
  stroke: currentColor;
}

.matrix-flow-layer path.is-flowing {
  stroke-dasharray: 7 8;
  animation: matrix-flow 720ms linear infinite;
  opacity: 0.9;
}

@keyframes matrix-flow {
  to { stroke-dashoffset: -30; }
}

.vector-frame,
.coefficient-frame,
.output-frame {
  position: relative;
  z-index: 2;
  opacity: 0.72;
  transition: opacity 220ms ease, filter 220ms ease;
}

.matrix-caption {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  margin-bottom: 0.45rem;
  color: var(--muted);
  font-family: Consolas, monospace;
  font-size: 0.55rem;
  text-transform: uppercase;
}

.matrix-caption span {
  color: var(--ink-soft);
  font-weight: 700;
}

.matrix-caption small {
  color: var(--cyan);
  font-size: inherit;
}

.matrix-row-shell,
.matrix-grid-shell {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) 10px;
  align-items: stretch;
}

.matrix-product-stage {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: minmax(235px, 1.15fr) minmax(190px, 0.85fr);
  gap: clamp(0.8rem, 1.6vw, 1.4rem);
  align-items: center;
  margin-top: 1rem;
}

.output-frame {
  margin-top: 1rem;
}

.matrix-bracket {
  display: flex;
  align-items: center;
  color: rgba(197, 220, 216, 0.42);
  font-family: Georgia, serif;
  font-size: clamp(2rem, 3vw, 3.6rem);
  font-weight: 400;
  transform: scaleY(1.35);
}

.basis-vector,
.output-vector {
  display: grid;
  gap: 3px;
}

.basis-vector {
  grid-template-columns: repeat(var(--matrix-rows), minmax(0, 1fr));
}

.output-vector {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.basis-vector span,
.output-vector span {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 48px;
  align-items: center;
  border: 1px solid var(--line);
  background: rgba(18, 33, 40, 0.82);
  padding: 0.24rem 0.3rem;
  text-align: center;
  transition: border-color 180ms ease, background 180ms ease, box-shadow 180ms ease, transform 180ms ease, opacity 180ms ease;
}

.basis-vector b,
.output-vector b {
  overflow: hidden;
  color: var(--muted);
  font-family: Georgia, serif;
  font-size: 0.5rem;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.basis-vector em,
.output-vector em {
  overflow: hidden;
  color: var(--ink-soft);
  font-family: Consolas, monospace;
  font-size: 0.51rem;
  font-style: normal;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.output-vector span {
  min-height: 58px;
  border-color: rgba(255, 107, 88, 0.3);
}

.output-vector b {
  color: var(--coral);
}

.basis-vector span.is-active-term {
  z-index: 3;
  border-color: var(--gold);
  background: rgba(233, 196, 106, 0.16);
  box-shadow: 0 0 22px rgba(233, 196, 106, 0.32), inset 0 0 14px rgba(233, 196, 106, 0.08);
  transform: translateY(-3px);
}

.output-vector span.is-active-output,
.output-vector span.is-committed {
  border-color: var(--coral);
  background: rgba(255, 107, 88, 0.14);
  box-shadow: 0 0 24px rgba(255, 107, 88, 0.28), inset 0 0 18px rgba(255, 107, 88, 0.08);
}

.output-vector span.is-committed:not(.is-active-output) {
  box-shadow: inset 0 0 14px rgba(255, 107, 88, 0.06);
}

.coefficient-matrix {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-template-rows: repeat(var(--matrix-rows), 31px);
  gap: 3px;
}

.coefficient-matrix button {
  min-width: 0;
  border: 1px solid rgba(236, 244, 242, 0.09);
  border-radius: 0;
  color: var(--ink);
  cursor: crosshair;
  font-family: Consolas, monospace;
  font-size: 0.49rem;
  padding: 0.1rem;
  opacity: 0.76;
  transition: border-color 160ms ease, filter 160ms ease, transform 160ms ease, opacity 160ms ease, box-shadow 160ms ease;
}

.coefficient-matrix button:hover,
.coefficient-matrix button:focus-visible {
  z-index: 2;
  border-color: #fff;
  filter: brightness(1.28);
  transform: scale(1.12);
}

.coefficient-matrix button.is-active-column {
  border-color: rgba(55, 225, 218, 0.62);
  opacity: 1;
  box-shadow: inset 0 0 10px rgba(55, 225, 218, 0.12);
}

.coefficient-matrix button.is-active-term {
  z-index: 4;
  border-color: #fff;
  filter: brightness(1.45) saturate(1.15);
  box-shadow: 0 0 18px rgba(55, 225, 218, 0.46), inset 0 0 14px rgba(255, 255, 255, 0.16);
  transform: scale(1.14);
}

.dot-product-console {
  position: relative;
  z-index: 3;
  min-width: 0;
  border-top: 1px solid rgba(55, 225, 218, 0.38);
  border-bottom: 1px solid rgba(55, 225, 218, 0.18);
  background: linear-gradient(90deg, rgba(55, 225, 218, 0.075), transparent);
  padding: 1rem 0.15rem 1rem 0.9rem;
}

.dot-product-console::before {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 2px;
  background: var(--cyan);
  box-shadow: 0 0 14px rgba(55, 225, 218, 0.7);
  content: "";
}

.dot-product-console p {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  margin: 0;
  color: var(--muted);
  font-family: Consolas, monospace;
  font-size: 0.55rem;
  text-transform: uppercase;
}

.dot-product-console p b {
  color: var(--cyan);
  font-family: Georgia, serif;
  font-size: 0.72rem;
  font-weight: 500;
}

.term-equation {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 0.18rem;
  align-items: center;
  min-height: 72px;
  margin-top: 0.8rem;
  color: var(--ink);
  font-family: Consolas, monospace;
  font-size: 0.6rem;
  text-align: center;
}

.term-equation b,
.term-equation strong {
  overflow: hidden;
  border: 1px solid var(--line-strong);
  background: rgba(7, 17, 20, 0.8);
  padding: 0.48rem 0.12rem;
  font-weight: 500;
  text-overflow: ellipsis;
}

.term-equation b {
  color: var(--gold);
  box-shadow: 0 0 14px rgba(233, 196, 106, 0.12);
}

.term-equation strong {
  color: var(--cyan-soft);
  box-shadow: 0 0 14px rgba(55, 225, 218, 0.12);
}

.term-equation .term-product {
  color: var(--coral);
  box-shadow: 0 0 14px rgba(255, 107, 88, 0.14);
}

.term-equation em {
  color: var(--coral);
  font-family: Georgia, serif;
  font-size: 1rem;
  font-style: normal;
}

.accumulator {
  display: flex;
  justify-content: space-between;
  gap: 0.7rem;
  align-items: center;
  border-top: 1px solid var(--line);
  padding-top: 0.75rem;
  color: var(--muted);
  font-size: 0.58rem;
}

.accumulator strong {
  color: var(--coral);
  font-family: Consolas, monospace;
  font-size: 0.72rem;
  font-weight: 500;
}

.contribution-track {
  display: grid;
  grid-template-columns: repeat(var(--matrix-rows), 1fr);
  gap: 3px;
  height: 5px;
  margin-top: 0.8rem;
}

.contribution-track i {
  background: rgba(255, 255, 255, 0.08);
  transition: background 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.contribution-track i.is-complete {
  background: var(--cyan);
  box-shadow: 0 0 7px rgba(55, 225, 218, 0.6);
}

.contribution-track i.is-current {
  background: var(--coral);
  box-shadow: 0 0 9px rgba(255, 107, 88, 0.72);
  transform: scaleY(1.7);
}

.matrix-inspector {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 0.8rem;
  align-items: center;
  min-height: 48px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.62rem;
  padding: 0.55rem 0;
}

.matrix-inspector b {
  color: var(--cyan);
  font-family: Georgia, serif;
  font-weight: 500;
}

.matrix-inspector span {
  color: var(--ink-soft);
  font-family: Consolas, monospace;
}

.matrix-inspector em {
  color: var(--coral);
  font-family: Georgia, serif;
  font-style: normal;
}

.calculation-timeline {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) minmax(110px, auto);
  gap: 0.75rem;
  align-items: center;
  margin-top: 0.9rem;
}

.calculation-timeline button {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border: 1px solid var(--cyan);
  border-radius: 50%;
  background: transparent;
  color: var(--cyan);
  cursor: pointer;
  font-size: 0.64rem;
}

.calculation-timeline button.playing {
  background: var(--cyan);
  color: var(--bg);
  box-shadow: 0 0 18px rgba(55, 225, 218, 0.25);
}

.calculation-track {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
}

.calculation-track i {
  height: 3px;
  background: rgba(255, 255, 255, 0.1);
  transition: background 220ms ease, box-shadow 220ms ease;
}

.calculation-track i.active {
  background: var(--cyan);
  box-shadow: 0 0 10px rgba(55, 225, 218, 0.55);
}

.calculation-timeline strong {
  color: var(--ink-soft);
  font-family: Consolas, monospace;
  font-size: 0.57rem;
  font-weight: 500;
  text-align: right;
}

.calc-stage.stage-active {
  box-shadow: inset 0 2px 0 var(--cyan), inset 0 0 30px rgba(55, 225, 218, 0.035);
}

.calc-stage.stage-active.vector-frame,
.calc-stage.stage-active.coefficient-frame,
.calc-stage.stage-active.output-frame,
.calc-stage.stage-complete.vector-frame,
.calc-stage.stage-complete.coefficient-frame,
.calc-stage.stage-complete.output-frame {
  filter: saturate(1.2) brightness(1.07);
  opacity: 1;
}

.performance-output {
  background: #09171a;
}

.performance-head {
  border-bottom: 1px solid var(--line);
  padding-bottom: 0.9rem;
}

.performance-head code {
  display: block;
  margin-top: 0.7rem;
  color: var(--gold);
  font-family: Georgia, serif;
  font-size: 0.64rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.performance-chart {
  height: 220px;
  margin-top: 0.8rem;
}

#performanceChart {
  display: block;
  width: 100%;
  height: 100%;
}

#performanceChart .skeleton-path {
  transition: filter 180ms ease, stroke-width 180ms ease;
}

#performanceChart .skeleton-path.is-linked {
  animation: skeleton-charge 620ms cubic-bezier(.22,.8,.22,1);
}

@keyframes skeleton-charge {
  0% { filter: drop-shadow(0 0 0 rgba(55, 225, 218, 0)); stroke-width: 3; }
  45% { filter: drop-shadow(0 0 8px rgba(55, 225, 218, 0.88)); stroke-width: 4.6; }
  100% { filter: drop-shadow(0 0 0 rgba(55, 225, 218, 0)); stroke-width: 3; }
}

#performanceChart .keypoint-marker {
  transform-box: fill-box;
  transform-origin: center;
}

#performanceChart .keypoint-marker.is-receiving {
  animation: keypoint-charge 680ms cubic-bezier(.22,.8,.22,1);
}

@keyframes keypoint-charge {
  0% { filter: drop-shadow(0 0 0 rgba(255, 255, 255, 0)); transform: scale(1); }
  45% { filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.8)); transform: scale(1.45); }
  100% { filter: drop-shadow(0 0 0 rgba(255, 255, 255, 0)); transform: scale(1); }
}

#hysteresisChart .formula-curve.is-calculated {
  animation: response-charge 1100ms cubic-bezier(.22,.8,.22,1);
}

@keyframes response-charge {
  0% { filter: drop-shadow(0 0 0 rgba(255, 107, 88, 0)); stroke-width: 2.6; }
  45% { filter: drop-shadow(0 0 9px rgba(255, 107, 88, 0.82)); stroke-width: 4.3; }
  100% { filter: drop-shadow(0 0 0 rgba(255, 107, 88, 0)); stroke-width: 2.6; }
}

.performance-keypoints {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  border-top: 1px solid var(--line-strong);
  border-left: 1px solid var(--line-strong);
}

.performance-keypoints div {
  display: grid;
  min-width: 0;
  border-right: 1px solid var(--line-strong);
  border-bottom: 1px solid var(--line-strong);
  padding: 0.55rem;
  box-shadow: inset 2px 0 var(--point-color);
  transition: background 220ms ease, box-shadow 220ms ease;
}

.performance-keypoints div.is-receiving,
.performance-parameters div.is-receiving {
  background: rgba(55, 225, 218, 0.1);
  box-shadow: inset 0 0 22px rgba(55, 225, 218, 0.14), 0 0 18px rgba(55, 225, 218, 0.12);
}

.performance-keypoints div.is-receiving {
  box-shadow: inset 2px 0 var(--point-color), inset 0 0 22px rgba(55, 225, 218, 0.14), 0 0 18px rgba(55, 225, 218, 0.12);
}

.performance-keypoints span {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--point-color);
  font-family: Georgia, serif;
  font-size: 0.58rem;
}

.keypoint-symbol {
  display: inline-block;
  width: 8px;
  height: 8px;
  background: var(--point-color);
}

.keypoint-symbol.circle {
  border-radius: 50%;
}

.keypoint-symbol.diamond {
  transform: rotate(45deg) scale(0.82);
}

.keypoint-symbol.triangle {
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
}

.performance-keypoints b,
.performance-keypoints strong {
  overflow: hidden;
  color: var(--ink-soft);
  font-family: Consolas, monospace;
  font-size: 0.58rem;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.performance-keypoints b {
  margin-top: 0.25rem;
}

.performance-parameters {
  margin-top: 0.8rem;
  border-top: 1px solid var(--line);
}

.performance-parameters div {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  gap: 0.6rem;
  align-items: center;
  min-height: 34px;
  border-bottom: 1px solid var(--line);
}

.performance-parameters code {
  color: var(--gold);
  font-family: Georgia, serif;
  font-size: 0.66rem;
}

.performance-parameters i {
  height: 1px;
  background: var(--line);
}

.performance-parameters strong {
  color: var(--cyan);
  font-family: Consolas, monospace;
  font-size: 0.6rem;
  font-weight: 500;
  transition: color 180ms ease, text-shadow 180ms ease;
}

.performance-parameters div.is-receiving strong {
  color: var(--cyan-soft);
  text-shadow: 0 0 12px rgba(55, 225, 218, 0.7);
}

.performance-keypoints div.is-receiving b,
.performance-keypoints div.is-receiving strong {
  color: var(--point-color);
  text-shadow: 0 0 12px currentColor;
}

.performance-fit {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin: 0.9rem 0 0;
  border-top: 1px solid var(--line-strong);
  border-left: 1px solid var(--line-strong);
}

.performance-fit div {
  border-right: 1px solid var(--line-strong);
  border-bottom: 1px solid var(--line-strong);
  padding: 0.55rem;
}

.performance-fit dt {
  color: var(--muted);
  font-family: Georgia, serif;
  font-size: 0.56rem;
}

.performance-fit dd {
  margin: 0.15rem 0 0;
  color: var(--coral);
  font-family: Consolas, monospace;
  font-size: 0.68rem;
}

.pca-workbench {
  grid-template-columns: minmax(360px, 0.72fr) minmax(0, 1.28fr);
  min-height: 520px;
  margin-top: 2rem;
}

.field-stage,
.field-scale {
  width: min(100%, 420px);
}

.basis-console {
  margin-top: 0;
  border: 0;
  background: #09171a;
  padding: clamp(1rem, 2vw, 1.7rem);
}

.basis-heading {
  align-items: flex-start;
}

.basis-heading > p {
  max-width: 330px;
}

.basis-strip {
  grid-template-columns: repeat(4, minmax(70px, 1fr));
  gap: 0.55rem;
  margin-top: 1rem;
}

.basis-tile {
  padding: 0.35rem;
}

.basis-controls {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 1.2rem;
  margin-top: 1rem;
  padding-top: 1rem;
}

.variance-chart-wrap {
  height: 112px;
  margin-top: 0.8rem;
}

/* Selectable theory states advertise interaction without animating content. */
.class-selector button,
.micro-modes button,
.matrix-family button,
.field-modes button,
.basis-tile {
  position: relative;
  transition: background-color 180ms ease, border-color 180ms ease, box-shadow 180ms ease, color 180ms ease, filter 180ms ease, transform 180ms ease;
}

:is(.class-selector, .micro-modes, .matrix-family, .field-modes) button:nth-child(5n + 1),
.basis-tile:nth-child(5n + 1) { --tab-signal-color: #37e1da; }
:is(.class-selector, .micro-modes, .matrix-family, .field-modes) button:nth-child(5n + 2),
.basis-tile:nth-child(5n + 2) { --tab-signal-color: #e9c46a; }
:is(.class-selector, .micro-modes, .matrix-family, .field-modes) button:nth-child(5n + 3),
.basis-tile:nth-child(5n + 3) { --tab-signal-color: #ff6b58; }
:is(.class-selector, .micro-modes, .matrix-family, .field-modes) button:nth-child(5n + 4),
.basis-tile:nth-child(5n + 4) { --tab-signal-color: #65a9d7; }
:is(.class-selector, .micro-modes, .matrix-family, .field-modes) button:nth-child(5n),
.basis-tile:nth-child(5n) { --tab-signal-color: #b58cff; }

.class-selector button:not(.active)::after,
.micro-modes button:not(.active)::after,
.matrix-family button:not(.active)::after,
.field-modes button:not(.active)::after,
.basis-tile:not(.active)::after {
  position: absolute;
  top: 7px;
  right: 8px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  color: var(--tab-signal-color, var(--cyan));
  box-shadow: 0 0 0 0 currentColor;
  content: "";
  pointer-events: none;
  animation: theory-tab-signal 2.4s ease-in-out infinite;
  will-change: opacity, transform, box-shadow;
}

.class-selector button:nth-child(3n + 2)::after,
.micro-modes button:nth-child(3n + 2)::after,
.matrix-family button:nth-child(3n + 2)::after,
.field-modes button:nth-child(3n + 2)::after,
.basis-tile:nth-child(3n + 2)::after { animation-delay: -0.8s; }

.class-selector button:nth-child(3n)::after,
.micro-modes button:nth-child(3n)::after,
.matrix-family button:nth-child(3n)::after,
.field-modes button:nth-child(3n)::after,
.basis-tile:nth-child(3n)::after { animation-delay: -1.6s; }

.class-selector button:hover,
.class-selector button:focus-visible,
.micro-modes button:hover,
.micro-modes button:focus-visible,
.matrix-family button:hover,
.matrix-family button:focus-visible,
.field-modes button:hover,
.field-modes button:focus-visible,
.basis-tile:hover,
.basis-tile:focus-visible {
  z-index: 2;
  filter: brightness(1.16);
  transform: translateY(-1px);
}

.class-selector button.active {
  box-shadow: inset 0 3px 0 var(--coral), 0 0 18px rgba(255, 107, 88, 0.16);
}

.micro-modes button.active,
.matrix-family button.active,
.field-modes button.active,
.basis-tile.active {
  box-shadow: inset 0 0 0 1px rgba(55, 225, 218, 0.36), 0 0 17px rgba(55, 225, 218, 0.16);
}

@keyframes theory-tab-signal {
  0%, 100% { opacity: 0.38; box-shadow: 0 0 0 0 currentColor; transform: scale(0.72); }
  50% { opacity: 1; box-shadow: 0 0 14px 5px currentColor; transform: scale(1.18); }
}

@media (max-width: 1100px) {
  .theory-nav {
    display: none;
  }

  .theory-header {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .theory-intro {
    grid-template-columns: minmax(0, 1.25fr) minmax(300px, 0.75fr);
  }

  .calculation-workbench {
    grid-template-columns: minmax(300px, 0.75fr) minmax(500px, 1.25fr);
  }

  .performance-output {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: minmax(260px, 0.8fr) minmax(300px, 1.2fr);
    gap: 0 1.5rem;
    border-top: 1px solid var(--line-strong);
  }

  .performance-chart {
    grid-row: 1 / span 3;
    grid-column: 2;
    height: 260px;
    margin-top: 0;
  }

  .performance-keypoints,
  .performance-parameters,
  .performance-fit {
    grid-column: 1;
  }

  .pca-workbench,
  .response-layout {
    grid-template-columns: minmax(330px, 0.8fr) minmax(460px, 1.2fr);
  }

  .basis-strip {
    grid-template-columns: repeat(4, minmax(90px, 1fr));
  }
}

@media (max-width: 820px) {
  .home-link,
  .sibling-link {
    display: none;
  }

  .theory-intro {
    display: block;
    min-height: auto;
    padding-top: 4.5rem;
  }

  .theory-intro::before {
    inset: 0 0 auto auto;
    width: 70vw;
    height: 55%;
  }

  .intro-copy h1 {
    font-size: clamp(2.8rem, 13vw, 5rem);
  }

  .intro-facts {
    margin-top: 3rem;
  }

  .section-heading {
    grid-template-columns: 1fr;
  }

  .class-selector {
    grid-template-columns: repeat(5, 1fr);
  }

  .calculation-workbench,
  .pca-workbench,
  .response-layout {
    grid-template-columns: 1fr;
  }

  .micro-input,
  .matrix-engine {
    border-right: 0;
    border-bottom: 1px solid var(--line-strong);
  }

  .performance-output {
    grid-column: auto;
    display: block;
    border-top: 0;
  }

  .performance-chart,
  .performance-keypoints,
  .performance-parameters,
  .performance-fit {
    grid-row: auto;
    grid-column: auto;
  }

  .performance-chart {
    height: 250px;
    margin-top: 0.8rem;
  }

  .field-panel,
  .curve-panel {
    border-right: 0;
    border-bottom: 1px solid var(--line-strong);
  }

  .curve-stage {
    height: 430px;
  }

  .basis-controls {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  .basis-controls .reset-button {
    grid-column: 1 / -1;
  }
}

@media (max-width: 560px) {
  .theory-header {
    min-height: 58px;
    padding: 0.45rem 0.8rem;
  }

  .theory-brand img {
    width: 36px;
    height: 36px;
  }

  .theory-brand strong {
    font-size: 0.88rem;
  }

  .theory-brand small {
    font-size: 0.58rem;
  }

  .theory-intro,
  .calculation-section,
  .pca-section,
  .response-section {
    padding-right: 0.9rem;
    padding-left: 0.9rem;
  }

  .intro-facts div {
    min-height: 94px;
    padding: 0.9rem;
  }

  .section-heading {
    gap: 1.2rem;
  }

  .class-selector button {
    min-height: 54px;
  }

  .calculation-workbench,
  .pca-workbench,
  .response-layout,
  .basis-console {
    border-right: 0;
    border-left: 0;
    margin-right: -0.9rem;
    margin-left: -0.9rem;
  }

  .panel-topline,
  .curve-topline,
  .basis-heading,
  .calc-panel-head,
  .matrix-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .micro-modes,
  .matrix-family {
    width: 100%;
  }

  .micro-modes button,
  .matrix-family button {
    flex: 1;
  }

  .feature-zoom { width: 46%; }

  .feature-zoom-head,
  .feature-zoom-readout {
    padding: 0.28rem 0.34rem;
  }

  .feature-zoom-head span {
    display: none;
  }

  .feature-chips {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .matrix-expression {
    min-height: auto;
  }

  .matrix-product-stage {
    grid-template-columns: 1fr;
  }

  .matrix-flow-layer {
    display: none;
  }

  .basis-vector span,
  .output-vector span {
    min-height: 44px;
    padding: 0.18rem 0.12rem;
  }

  .coefficient-matrix {
    gap: 2px;
  }

  .coefficient-matrix button {
    font-size: 0.43rem;
  }

  .basis-vector em,
  .output-vector em {
    font-size: 0.48rem;
  }

  .matrix-inspector {
    grid-template-columns: 1fr;
    gap: 0.25rem;
  }

  .calculation-timeline {
    grid-template-columns: 32px minmax(0, 1fr);
  }

  .calculation-timeline strong {
    grid-column: 1 / -1;
    text-align: left;
  }

  .basis-controls {
    grid-template-columns: 1fr;
  }

  .basis-controls .reset-button {
    grid-column: auto;
  }

  .field-modes {
    width: 100%;
  }

  .field-modes button {
    flex: 1;
    padding: 0 0.35rem;
  }

  .basis-heading > p {
    text-align: left;
  }

  .basis-strip {
    grid-template-columns: repeat(4, minmax(62px, 1fr));
    gap: 0.4rem;
  }

  .basis-tile {
    padding: 0.3rem;
  }

  .basis-tile span {
    font-size: 0.5rem;
  }

  .variance-chart-wrap {
    height: 120px;
  }

  .curve-stage {
    height: 330px;
  }

  .curve-legend {
    gap: 0.8rem;
  }

  .curve-legend span {
    padding-left: 1.25rem;
    font-size: 0.56rem;
  }

  footer {
    min-height: 84px;
    padding-right: 0.9rem;
    padding-left: 0.9rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .class-selector button::after,
  .micro-modes button::after,
  .matrix-family button::after,
  .field-modes button::after,
  .basis-tile::after {
    animation: none !important;
    opacity: 0.72;
  }
}
