:root {
  color-scheme: light;
  --bg: #f7fafc;
  --paper: #ffffff;
  --ink: #17212f;
  --muted: #5f6f82;
  --line: #dce5ee;
  --blue: #1f8ed6;
  --blue-deep: #0d5f78;
  --teal: #18a999;
  --red: #c3413d;
  --orange: #f0783c;
  --green: #3d9b63;
  --shadow: 0 18px 50px rgba(23, 33, 47, 0.12);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, #eef7fb 0, #f7fafc 420px),
    var(--bg);
  color: var(--ink);
}

button,
input {
  font: inherit;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 14px clamp(18px, 4vw, 56px);
  background: rgba(247, 250, 252, 0.88);
  border-bottom: 1px solid rgba(220, 229, 238, 0.85);
  backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background:
    radial-gradient(circle at 35% 35%, #f0783c 0 18%, transparent 19%),
    radial-gradient(circle at 70% 70%, #1f8ed6 0 20%, transparent 21%),
    linear-gradient(135deg, #18a999, #0d5f78);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.5);
}

nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

nav a {
  color: var(--muted);
  font-size: 0.94rem;
  font-weight: 700;
  text-decoration: none;
  padding: 8px 10px;
  border-radius: 8px;
}

nav a:hover,
nav a:focus-visible {
  background: #e8f3f8;
  color: var(--blue-deep);
}

.lab {
  display: grid;
  grid-template-columns: minmax(280px, 0.8fr) minmax(360px, 1.15fr) minmax(280px, 0.72fr);
  gap: clamp(18px, 3vw, 34px);
  align-items: stretch;
  max-width: 1480px;
  min-height: calc(100vh - 58px);
  margin: 0 auto;
  padding: clamp(24px, 4vw, 56px);
}

.lab-copy,
.controls {
  align-self: center;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--blue-deep);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  max-width: 13ch;
  margin-bottom: 18px;
  font-size: clamp(2.35rem, 5vw, 5.8rem);
  line-height: 0.96;
}

h2 {
  margin-bottom: 14px;
  font-size: clamp(2rem, 3.4vw, 4rem);
  line-height: 1;
}

h3 {
  margin-bottom: 10px;
  font-size: 1.2rem;
}

.lead,
.section-heading p {
  color: var(--muted);
  font-size: clamp(1.02rem, 1.4vw, 1.18rem);
  line-height: 1.65;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 28px;
}

.metrics article,
.scale-results article {
  min-width: 0;
  padding: 14px;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metrics span,
.scale-results span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.metrics strong,
.scale-results strong {
  font-size: clamp(1.05rem, 1.5vw, 1.35rem);
}

.lab-stage {
  position: relative;
  min-height: min(70vh, 760px);
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.88), rgba(236, 246, 250, 0.9)),
    #eef7fb;
  border: 1px solid rgba(185, 207, 220, 0.9);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

#sample-canvas {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 520px;
}

.canvas-legend {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  pointer-events: none;
}

.canvas-legend span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 9px;
  color: #26384d;
  font-size: 0.82rem;
  font-weight: 800;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(220, 229, 238, 0.85);
  border-radius: 8px;
}

.canvas-legend i {
  width: 11px;
  height: 11px;
  border-radius: 50%;
}

.legend-hot {
  background: var(--orange);
}

.legend-flow {
  background: var(--blue);
}

.legend-stress {
  background: var(--red);
}

.controls {
  display: grid;
  gap: 18px;
  padding: 20px;
  background: rgba(255, 255, 255, 0.84);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 12px 35px rgba(23, 33, 47, 0.08);
}

.control-group label,
.scale-controls label {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 8px;
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 800;
}

output {
  color: var(--blue-deep);
  font-weight: 900;
  white-space: nowrap;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--blue);
}

.control-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  padding-top: 4px;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 12px;
  color: var(--muted);
  font-weight: 800;
  background: #f5f9fb;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.toggle input {
  width: 18px;
  height: 18px;
  accent-color: var(--teal);
}

.section {
  max-width: 1280px;
  margin: 0 auto;
  padding: clamp(54px, 8vw, 104px) clamp(18px, 4vw, 56px);
}

.section-heading {
  max-width: 760px;
  margin-bottom: 30px;
}

.principle-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.principle-card {
  min-width: 0;
  padding: 20px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(23, 33, 47, 0.07);
}

.principle-card p {
  color: var(--muted);
  line-height: 1.6;
}

.diagram {
  display: grid;
  place-items: center;
  height: 150px;
  margin-bottom: 18px;
  background: #f3f8fb;
  border-radius: 8px;
}

.diagram svg {
  width: min(100%, 260px);
  height: 100%;
}

code,
.equation,
.coupling-formula {
  display: block;
  overflow-wrap: anywhere;
  color: #16354a;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.9rem;
  line-height: 1.45;
  background: #edf6f8;
  border: 1px solid #cce3ea;
  border-radius: 8px;
  padding: 12px;
}

.equation-workbench,
.coupling-layout,
.scale-board {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 12px 34px rgba(23, 33, 47, 0.08);
}

.equation-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.tab,
.matrix-cell {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f6fafc;
  color: var(--muted);
  cursor: pointer;
  font-weight: 900;
}

.tab {
  padding: 10px 13px;
}

.tab.active,
.matrix-cell.active {
  color: #fff;
  background: var(--blue-deep);
  border-color: var(--blue-deep);
}

.equation-panel {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(260px, 0.75fr);
  gap: 22px;
  padding: 22px;
  align-items: start;
}

.equation-label {
  margin: 0 0 9px;
  color: var(--blue-deep);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

#equation-explain,
.coupling-detail p,
.scale-results p {
  color: var(--muted);
  line-height: 1.65;
}

.coupling-layout {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(280px, 1fr);
  gap: 0;
  overflow: hidden;
}

.coupling-matrix {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 18px;
  background: #f6fafc;
  border-right: 1px solid var(--line);
}

.matrix-cell {
  min-height: 104px;
  padding: 16px;
  text-align: left;
  line-height: 1.35;
}

.matrix-cell span {
  display: block;
  margin-bottom: 8px;
  font-size: 1.25rem;
  color: inherit;
}

.coupling-detail {
  padding: clamp(22px, 4vw, 36px);
}

.coupling-detail h3 {
  font-size: clamp(1.6rem, 3vw, 2.55rem);
  line-height: 1.05;
}

.coupling-formula {
  margin-top: 18px;
}

.scale-board {
  display: grid;
  grid-template-columns: minmax(280px, 0.8fr) minmax(280px, 1fr);
  gap: 20px;
  padding: 20px;
}

.scale-controls {
  display: grid;
  gap: 12px;
  align-content: center;
}

.scale-results {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.scale-results article {
  background: #f8fbfd;
}

.site-footer {
  max-width: 1280px;
  margin: 0 auto;
  padding: 32px clamp(18px, 4vw, 56px) 54px;
  color: var(--muted);
  border-top: 1px solid var(--line);
}

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

  .controls {
    grid-column: 1 / -1;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .control-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-column: 1 / -1;
  }

  h1 {
    max-width: 12ch;
  }
}

@media (max-width: 860px) {
  .site-header {
    position: static;
    align-items: flex-start;
    flex-direction: column;
  }

  nav {
    justify-content: flex-start;
  }

  .lab,
  .principle-grid,
  .equation-panel,
  .coupling-layout,
  .scale-board,
  .scale-results {
    grid-template-columns: 1fr;
  }

  .lab {
    min-height: 0;
  }

  .lab-stage {
    min-height: 440px;
  }

  #sample-canvas {
    min-height: 440px;
  }

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

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

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

  .coupling-matrix {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
}

@media (max-width: 560px) {
  h1 {
    max-width: 11ch;
    font-size: 2.3rem;
  }

  .site-header,
  .lab,
  .section {
    padding-left: 16px;
    padding-right: 16px;
  }

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

  .canvas-legend {
    justify-content: flex-start;
  }
}
