:root {
  color-scheme: light;
  --ink: #17212b;
  --muted: #5a6673;
  --panel: #ffffff;
  --line: #d9e1e8;
  --bg: #eef3f5;
  --bg-2: #e6edf0;
  --green: #2c8b6b;
  --teal: #19758f;
  --blue: #2d66b3;
  --amber: #b77220;
  --red: #b64c48;
  --violet: #7357a4;
  --dead: #c8b27e;
  --living: #db6f74;
  --nerve: #e0b936;
  --vascular: #c9424b;
  --shadow: 0 18px 46px rgba(36, 53, 66, 0.14);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  margin: 0;
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  line-height: 1.5;
}

button,
input {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  padding: 28px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.82), rgba(238, 243, 245, 0.88)),
    repeating-linear-gradient(
      90deg,
      rgba(25, 117, 143, 0.08) 0,
      rgba(25, 117, 143, 0.08) 1px,
      transparent 1px,
      transparent 68px
    );
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 24px;
  align-items: stretch;
  max-width: 1240px;
  margin: 0 auto 22px;
}

.hero-copy {
  min-width: 0;
  padding: 28px 0 14px;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--teal);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

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

h1 {
  max-width: 780px;
  margin-bottom: 12px;
  font-size: clamp(2rem, 5vw, 4.7rem);
  line-height: 0.98;
  letter-spacing: 0;
}

.hero-copy p:last-child {
  max-width: 840px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 1.05rem;
}

.hero-meter,
.controls-panel,
.mechanism-view,
.score-card {
  border: 1px solid rgba(110, 130, 145, 0.28);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow);
}

.hero-meter {
  display: grid;
  align-content: center;
  justify-items: center;
  min-height: 190px;
  padding: 20px;
}

.meter-label,
.active-score span,
.score-meta,
.control-row small,
.switch-row small {
  color: var(--muted);
  font-size: 0.82rem;
}

.hero-meter strong {
  margin: 4px 0 14px;
  text-align: center;
  font-size: 1.1rem;
}

.score-ring {
  --score: 72;
  display: grid;
  place-items: center;
  width: 104px;
  height: 104px;
  border-radius: 50%;
  background:
    radial-gradient(circle at center, #fff 58%, transparent 60%),
    conic-gradient(var(--teal) calc(var(--score) * 1%), #dbe3e8 0);
}

.score-ring span {
  font-size: 1.8rem;
  font-weight: 900;
}

.lab-layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
  max-width: 1240px;
  margin: 0 auto;
}

.controls-panel {
  position: sticky;
  top: 18px;
  padding: 18px;
}

.panel-title {
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.panel-title h2,
.section-heading h2 {
  margin-bottom: 4px;
  font-size: 1.1rem;
}

.panel-title span,
.section-heading p {
  color: var(--muted);
  font-size: 0.9rem;
}

.control-row,
.switch-row {
  display: grid;
  gap: 10px;
  margin: 0 0 19px;
}

.control-row span,
.switch-row span {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
}

.control-row strong,
.switch-row strong {
  font-size: 0.92rem;
}

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

.switch-row {
  grid-template-columns: 1fr auto;
  align-items: center;
  margin-bottom: 0;
  padding-top: 4px;
}

.switch-row span {
  display: grid;
  justify-content: start;
  gap: 2px;
}

input[type="checkbox"] {
  width: 42px;
  height: 24px;
  margin: 0;
  accent-color: var(--teal);
}

.sim-stage {
  min-width: 0;
}

.selector {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.selector-card {
  min-width: 0;
  min-height: 112px;
  padding: 12px;
  border: 1px solid rgba(110, 130, 145, 0.3);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.7);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    background 160ms ease,
    box-shadow 160ms ease;
}

.selector-card:hover,
.selector-card:focus-visible {
  transform: translateY(-2px);
  border-color: rgba(25, 117, 143, 0.65);
  outline: none;
}

.selector-card[aria-selected="true"] {
  border-color: var(--teal);
  background: #fff;
  box-shadow: 0 12px 28px rgba(25, 117, 143, 0.14);
}

.selector-card strong {
  display: block;
  margin-bottom: 7px;
  font-size: 0.92rem;
  line-height: 1.15;
}

.selector-card small {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.35;
}

.selector-score {
  display: flex;
  gap: 7px;
  align-items: center;
  margin-top: 10px;
}

.mini-bar {
  flex: 1;
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: #dbe3e8;
}

.mini-bar span,
.bar span,
.score-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--score-color, var(--teal));
}

.selector-score b {
  min-width: 2.2em;
  font-size: 0.8rem;
}

.mechanism-view {
  overflow: hidden;
}

.diagram-wrap {
  min-height: 430px;
  padding: 14px;
  background:
    linear-gradient(180deg, rgba(244, 248, 250, 0.95), rgba(235, 242, 245, 0.95)),
    linear-gradient(90deg, transparent 96%, rgba(23, 33, 43, 0.04) 96%);
}

#diagram {
  display: block;
  width: 100%;
  min-height: 380px;
}

.explain-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 190px;
  gap: 22px;
  align-items: center;
  padding: 20px;
  border-top: 1px solid var(--line);
  background: #fff;
}

.explain-panel h2 {
  margin-bottom: 6px;
  font-size: 1.35rem;
}

.explain-panel p {
  margin-bottom: 0;
  color: var(--muted);
}

.active-score {
  display: grid;
  gap: 8px;
}

.active-score strong {
  font-size: 2.5rem;
  line-height: 1;
}

.bar,
.score-bar {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #dbe3e8;
}

.tradeoff-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  border-top: 1px solid var(--line);
  background: var(--line);
}

.tradeoff {
  min-width: 0;
  padding: 14px;
  background: #fff;
}

.tradeoff span {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
  text-transform: uppercase;
}

.tradeoff strong {
  color: var(--ink);
  font-size: 0.85rem;
  text-transform: none;
}

.tradeoff p {
  min-height: 3rem;
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.viz-strip {
  position: relative;
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: #dbe3e8;
}

.viz-strip::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: calc(var(--value) * 1%);
  border-radius: inherit;
  background: var(--metric-color, var(--teal));
}

.comparison {
  max-width: 1240px;
  margin: 22px auto 0;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  gap: 28px;
  align-items: end;
  margin-bottom: 12px;
}

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

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

.score-card {
  min-width: 0;
  padding: 15px;
  box-shadow: none;
}

.score-card h3 {
  margin: 0 0 8px;
  font-size: 0.96rem;
  line-height: 1.2;
}

.score-card .score-line {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: baseline;
  margin-bottom: 10px;
}

.score-card b {
  font-size: 1.55rem;
}

.score-card p {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.svg-label {
  paint-order: stroke;
  stroke: rgba(255, 255, 255, 0.92);
  stroke-width: 5px;
  stroke-linejoin: round;
  fill: var(--ink);
  font-size: 17px;
  font-weight: 800;
}

.svg-small {
  paint-order: stroke;
  stroke: rgba(255, 255, 255, 0.92);
  stroke-width: 4px;
  fill: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.wheel-spin {
  transform-box: fill-box;
  transform-origin: center;
  animation: spin var(--spin-speed, 2.4s) linear infinite;
}

.reverse-spin {
  animation-direction: reverse;
}

.pulse {
  animation: pulse 1.5s ease-in-out infinite;
}

.flow {
  stroke-dasharray: 10 10;
  animation: dash 1.2s linear infinite;
}

.cord {
  fill: none;
  stroke-linecap: round;
  stroke-width: 5;
}

.terrain-line {
  fill: none;
  stroke: #6d7c83;
  stroke-width: 5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.terrain-fill {
  fill: rgba(109, 124, 131, 0.12);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.55;
    transform: scale(1);
  }
  50% {
    opacity: 1;
    transform: scale(1.05);
  }
}

@keyframes dash {
  to {
    stroke-dashoffset: -40;
  }
}

@media (max-width: 1040px) {
  .app-shell {
    padding: 18px;
  }

  .hero,
  .lab-layout {
    grid-template-columns: 1fr;
  }

  .controls-panel {
    position: static;
  }

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

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

@media (max-width: 640px) {
  .app-shell {
    padding: 12px;
  }

  .hero-copy {
    padding-top: 14px;
  }

  h1 {
    font-size: 2.35rem;
  }

  .selector,
  .scoreboard,
  .tradeoff-grid,
  .explain-panel {
    grid-template-columns: 1fr;
  }

  .diagram-wrap {
    min-height: 330px;
    padding: 8px;
  }

  #diagram {
    min-height: 310px;
  }

  .control-row span {
    align-items: start;
    flex-direction: column;
    gap: 2px;
  }

  .section-heading {
    display: block;
  }
}
