:root {
  --paper: #d7ded1;
  --paper-2: #cfd7c9;
  --ink: #161b19;
  --faint: #6e776e;
  --line: #252b27;
  --red: #f52517;
  --accent: #f52517;
  --wash: rgba(255, 255, 255, 0.22);
  --object-glow: rgba(245, 37, 23, 0.18);
  --blueprint: rgba(28, 33, 31, 0.14);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: #111;
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  letter-spacing: 0;
}

.sim-shell {
  height: 100vh;
  padding: 8px;
  background:
    radial-gradient(circle at 52% 48%, var(--wash), transparent 32%),
    linear-gradient(rgba(22, 27, 25, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(22, 27, 25, 0.025) 1px, transparent 1px),
    var(--paper);
  background-size: auto, 100% 4px, 4px 100%, auto;
  border: 3px solid var(--line);
  overflow: hidden;
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  transition: background-color 260ms ease, filter 260ms ease;
}

.sim-shell::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(var(--ink) 0.75px, transparent 0.75px),
    linear-gradient(90deg, transparent 49.8%, rgba(20, 25, 22, 0.08) 50%, transparent 50.2%);
  background-size: 21px 21px, 100% 100%;
  mix-blend-mode: multiply;
  opacity: 0.34;
}

.panel {
  border: 2px solid var(--line);
  background: rgba(215, 222, 209, 0.82);
  position: relative;
  z-index: 1;
}

.top-grid {
  display: grid;
  grid-template-columns: 185px minmax(0, 1fr) 108px 104px 104px;
  gap: 0;
}

.top-grid .panel {
  min-height: 66px;
  border-right: 0;
}

.top-grid .panel:last-child {
  border-right: 2px solid var(--line);
}

.stamp {
  padding: 9px 14px 6px;
  text-transform: uppercase;
}

.stamp span,
.status span,
.runtime span,
.seed span {
  display: block;
  color: var(--faint);
  font-family: "Courier New", monospace;
  font-size: 10px;
  font-weight: 700;
}

.stamp strong {
  display: block;
  font-size: 27px;
  line-height: 0.94;
  margin: 3px 0 5px;
}

.barcode {
  height: 11px;
  background:
    repeating-linear-gradient(90deg, #111 0 2px, transparent 2px 4px, #111 4px 5px, transparent 5px 8px),
    linear-gradient(#111, #111);
  background-size: 100% 100%, 100% 1px;
}

.title {
  padding: 11px 14px 8px;
  text-transform: uppercase;
  min-width: 0;
}

.title h1 {
  margin: 0;
  font-size: clamp(19px, 1.5vw, 22px);
  line-height: 0.95;
  font-weight: 900;
  white-space: nowrap;
  overflow: hidden;
  transform: scaleX(0.92);
  transform-origin: left center;
}

.meta {
  display: flex;
  gap: 32px;
  margin-top: 8px;
  font-family: "Courier New", monospace;
  font-size: 10px;
  font-weight: 700;
}

.status,
.runtime,
.seed {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 5px;
  text-transform: uppercase;
  text-align: center;
}

.mini-select {
  width: 86px;
  height: 22px;
  border: 1px solid rgba(22, 27, 25, 0.55);
  background: rgba(215, 222, 209, 0.74);
  color: var(--ink);
  font-family: "Courier New", monospace;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.status strong,
.audio-toggle,
.runtime strong,
.seed strong {
  font-size: 13px;
}

.status strong,
.audio-toggle {
  color: var(--accent);
}

.status i,
.audio-toggle i,
.ticker i {
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--accent);
  vertical-align: 1px;
}

.audio-toggle {
  padding: 0;
  border: 0;
  background: transparent;
  font: inherit;
  font-weight: 800;
  text-transform: uppercase;
  cursor: pointer;
}

.audio-toggle:focus-visible {
  outline: 1px solid var(--line);
  outline-offset: 3px;
}

.audio-toggle.is-on i {
  animation: pulseCore 1.2s steps(2, end) infinite;
}

@keyframes pulseCore {
  50% {
    opacity: 0.35;
  }
}

.body-grid {
  display: grid;
  grid-template-columns: 230px minmax(430px, 1fr) 260px;
  gap: 0;
  min-height: 0;
  overflow: hidden;
}

.body-grid > .panel {
  border-top: 0;
  border-right: 0;
  min-height: 0;
}

.body-grid > .panel:last-child {
  border-right: 2px solid var(--line);
}

.left-rail {
  padding: 9px 8px;
  overflow-y: auto;
  scrollbar-width: thin;
}

.lab-button,
.commit-button,
.creator-head button {
  border: 1px solid var(--line);
  background: rgba(215, 222, 209, 0.82);
  color: var(--ink);
  font-family: "Courier New", monospace;
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
  cursor: pointer;
}

.lab-button {
  width: 100%;
  height: 28px;
  margin-bottom: 8px;
}

.lab-button:hover,
.commit-button:hover,
.creator-head button:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.star {
  min-height: 86px;
  padding: 7px 4px 8px;
  border-bottom: 1px dashed rgba(22, 27, 25, 0.45);
  overflow: hidden;
  cursor: pointer;
  transition: background 160ms ease, color 160ms ease;
}

.star.is-custom strong::after {
  content: " *";
  color: var(--accent);
}

.star:focus-visible {
  outline: 2px dashed var(--accent);
  outline-offset: -2px;
}

.star-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.star strong {
  font-size: 12px;
}

.star-head span,
.star-head span::before,
.star-head span::after {
  display: block;
  width: 5px;
  height: 6px;
  background: var(--ink);
}

.star-head span {
  position: relative;
  margin-right: 10px;
}

.star-head span::before,
.star-head span::after {
  content: "";
  position: absolute;
  top: 0;
}

.star-head span::before {
  left: 7px;
}

.star-head span::after {
  left: 14px;
}

.star p {
  margin: 5px 0 7px 9px;
  color: #394239;
  font-family: "Courier New", monospace;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

.star.active p,
.star.active .meter i {
  color: var(--accent);
  background: var(--accent);
}

.star.active {
  background: color-mix(in srgb, var(--accent) 14%, transparent);
}

.star code {
  display: block;
  height: 20px;
  color: #687268;
  font-family: "Courier New", monospace;
  font-size: 6px;
  line-height: 1.35;
  overflow: hidden;
  overflow-wrap: anywhere;
}

.meter {
  height: 4px;
  margin-top: 6px;
  background: rgba(22, 27, 25, 0.18);
}

.meter i {
  display: block;
  height: 100%;
  background: #111;
}

.star small {
  display: flex;
  justify-content: space-between;
  margin-top: 5px;
  color: #555e56;
  font-family: "Courier New", monospace;
  font-size: 8px;
}

.viewport {
  min-width: 0;
  overflow: hidden;
  height: 100%;
}

.scene-head {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 12px 14px 0;
  position: absolute;
  inset: 0 0 auto;
  z-index: 2;
  pointer-events: none;
}

.scene-head h2,
.engine h3 {
  margin: 0;
  color: var(--accent);
  font-size: clamp(27px, 3vw, 38px);
  line-height: 0.9;
  text-transform: uppercase;
  font-weight: 900;
  max-width: 640px;
  white-space: nowrap;
}

.scene-head strong,
.engine strong {
  display: block;
  margin-top: 5px;
  font-size: 20px;
  line-height: 1;
}

.scene-head span,
.engine p {
  color: var(--accent);
  font-family: "Courier New", monospace;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

.scene-head dl {
  margin: 3px 0 0;
  width: 240px;
  font-family: "Courier New", monospace;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

.scene-head dl div {
  display: grid;
  grid-template-columns: 1fr 52px;
  gap: 8px;
  margin-bottom: 6px;
}

.scene-head dt,
.scene-head dd {
  margin: 0;
}

.scene-head dt {
  text-align: right;
  color: #69736a;
}

#spaceCanvas {
  width: 100%;
  height: 100%;
  min-height: 0;
  display: block;
  cursor: grab;
  touch-action: none;
}

#spaceCanvas:active {
  cursor: grabbing;
}

.engine {
  position: absolute;
  left: 14px;
  bottom: 23px;
  z-index: 2;
  text-transform: uppercase;
  pointer-events: none;
}

.engine p {
  margin: 7px 0 0;
  color: #666f66;
}

.engine p span {
  display: inline-block;
  width: 0;
  height: 0;
  margin: 0 8px;
  border-left: 6px solid var(--accent);
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
}

.right-rail {
  padding: 8px 11px 10px;
  overflow: hidden;
}

.chart-card {
  padding: 0 5px 14px;
  border-bottom: 2px solid rgba(22, 27, 25, 0.16);
  margin-bottom: 17px;
}

.chart-card h3 {
  margin: 0 0 10px;
  font-size: 14px;
  line-height: 1.1;
  text-transform: uppercase;
}

.chart-card svg,
.instrument-canvas {
  width: 100%;
  border: 1px solid rgba(22, 27, 25, 0.25);
  display: block;
}

.legend {
  width: 96px;
  margin-left: auto;
  margin-top: -127px;
  padding-bottom: 89px;
  font-family: "Courier New", monospace;
  font-size: 5.5px;
  font-weight: 700;
  text-transform: uppercase;
}

.legend span {
  display: block;
  border-top: 1px solid #111;
  padding-left: 18px;
}

.shear-canvas {
  height: 150px;
}

.dial-canvas {
  width: min(200px, 90%);
  height: auto;
  margin: 8px auto 0;
  border: 0;
}

.temp-canvas {
  height: 112px;
}

.dial {
  width: min(190px, 86%);
  aspect-ratio: 1;
  margin: 8px auto 0;
  border-radius: 50%;
  position: relative;
  background:
    repeating-conic-gradient(from 0deg, #171c19 0 1deg, transparent 1deg 5deg),
    radial-gradient(circle, transparent 0 20%, rgba(22, 27, 25, 0.12) 20.5% 21%, transparent 21.5% 32%, rgba(22, 27, 25, 0.18) 32.5% 33%, transparent 33.5% 100%);
  border: 1px dashed rgba(22, 27, 25, 0.55);
}

.dial::before,
.dial::after {
  content: "";
  position: absolute;
  inset: 17%;
  border-radius: 50%;
  border: 10px solid transparent;
  border-right-color: var(--ink);
  border-bottom-color: var(--ink);
  transform: rotate(18deg);
}

.dial::after {
  inset: 34%;
  border-width: 6px;
  border-right-color: transparent;
  border-left-color: var(--ink);
  transform: rotate(-48deg);
}

.dial strong {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 31px;
}

.ring {
  position: absolute;
  border-radius: 50%;
  border: 1px dashed rgba(22, 27, 25, 0.45);
}

.r1 { inset: 8%; }
.r2 { inset: 22%; }
.r3 { inset: 42%; }

.dial i {
  position: absolute;
  left: 50%;
  top: -10px;
  width: 1px;
  height: calc(100% + 20px);
  background: rgba(22, 27, 25, 0.35);
}

.temp {
  border-bottom: 0;
}

.heatmap {
  height: 102px;
  border: 8px solid transparent;
  background:
    linear-gradient(30deg, transparent 32%, #1b211f 33% 66%, transparent 67%) 0 0 / 26px 30px,
    linear-gradient(-30deg, transparent 32%, #4c574e 33% 66%, transparent 67%) 0 0 / 26px 30px,
    linear-gradient(30deg, transparent 32%, #909a8d 33% 66%, transparent 67%) 13px 15px / 26px 30px,
    linear-gradient(-30deg, transparent 32%, #b5bcae 33% 66%, transparent 67%) 13px 15px / 26px 30px,
    var(--paper-2);
  clip-path: polygon(5% 0, 95% 0, 100% 18%, 100% 82%, 95% 100%, 5% 100%, 0 82%, 0 18%);
}

.scale {
  float: right;
  width: 25px;
  height: 103px;
  margin-top: -103px;
  background: linear-gradient(#1b211f, #576157, #c5cbbd);
  border: 1px solid rgba(22, 27, 25, 0.45);
}

.ticker {
  display: grid;
  grid-template-columns: 54px 78px 220px 80px 1fr 190px 220px 172px 60px;
  align-items: center;
  min-height: 25px;
  border-top: 0;
  font-family: "Courier New", monospace;
  font-size: 10px;
  text-transform: uppercase;
}

.ticker span,
.ticker strong,
.ticker b {
  height: 100%;
  display: flex;
  align-items: center;
  padding: 0 7px;
  border-right: 1px solid rgba(22, 27, 25, 0.42);
  white-space: nowrap;
}

.ticker strong {
  color: var(--accent);
}

.engine em {
  font-style: normal;
}

.creator-panel {
  position: absolute;
  z-index: 6;
  left: 250px;
  top: 92px;
  width: min(520px, calc(100% - 290px));
  padding: 12px;
  background: color-mix(in srgb, var(--paper) 88%, white 12%);
  box-shadow: 12px 12px 0 rgba(22, 27, 25, 0.12);
}

.creator-panel[hidden] {
  display: none;
}

.creator-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  border-bottom: 1px dashed rgba(22, 27, 25, 0.45);
  padding-bottom: 8px;
}

.creator-head h2 {
  margin: 0;
  color: var(--accent);
  font-size: 22px;
  line-height: 1;
  text-transform: uppercase;
}

.creator-head button {
  width: 28px;
  height: 24px;
  font-size: 16px;
  line-height: 1;
}

.creator-panel label {
  display: grid;
  gap: 4px;
  color: var(--faint);
  font-family: "Courier New", monospace;
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
}

.creator-panel input,
.creator-panel select {
  min-width: 0;
  height: 28px;
  border: 1px solid rgba(22, 27, 25, 0.62);
  background: rgba(215, 222, 209, 0.82);
  color: var(--ink);
  font: inherit;
}

.creator-panel input[type="color"] {
  padding: 2px;
}

.creator-panel input[type="range"] {
  accent-color: var(--accent);
}

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

.commit-button {
  width: 100%;
  height: 30px;
  color: var(--accent);
}

.sim-shell[data-preset^="custom-"] {
  --paper: #d8ddd4;
  --paper-2: #c9d2cc;
  --wash: color-mix(in srgb, var(--accent) 18%, transparent);
  --object-glow: color-mix(in srgb, var(--accent) 25%, transparent);
}

.sim-shell[data-preset="sirius"] {
  --paper: #d6ddd9;
  --paper-2: #c7d1d1;
  --accent: #1f6f8e;
  --wash: rgba(128, 213, 239, 0.22);
  --object-glow: rgba(31, 111, 142, 0.24);
  filter: saturate(0.95) contrast(1.04);
}

.sim-shell[data-preset="crab"] {
  --paper: #d4d9cd;
  --paper-2: #c5cbbd;
  --accent: #8d34ff;
  --wash: rgba(141, 52, 255, 0.16);
  --object-glow: rgba(141, 52, 255, 0.25);
  filter: contrast(1.08);
}

.sim-shell[data-preset="cygnus"] {
  --paper: #cfd4c9;
  --paper-2: #bbc4b8;
  --accent: #111;
  --wash: rgba(0, 0, 0, 0.12);
  --object-glow: rgba(0, 0, 0, 0.3);
  filter: contrast(1.12) brightness(0.95);
}

.sim-shell[data-preset="procyon"] {
  --paper: #d9ddd4;
  --paper-2: #ccd3cb;
  --accent: #d14f00;
  --wash: rgba(255, 132, 39, 0.18);
  --object-glow: rgba(209, 79, 0, 0.24);
}

.sim-shell[data-preset="betelgeuse"] {
  --paper: #ded8cf;
  --paper-2: #d3c5b9;
  --accent: #c72414;
  --wash: rgba(242, 94, 41, 0.22);
  --object-glow: rgba(199, 36, 20, 0.28);
  filter: saturate(1.08);
}

@media (max-width: 1060px) {
  .top-grid {
    grid-template-columns: 165px 1fr 96px;
  }

  .runtime,
  .seed {
    display: none;
  }

  .body-grid {
    grid-template-columns: 190px minmax(360px, 1fr);
  }

  .right-rail {
    display: none;
  }

  .body-grid > .viewport {
    border-right: 2px solid var(--line);
  }
}

@media (max-width: 760px) {
  .sim-shell {
    min-width: 360px;
    overflow-x: auto;
  }

  .top-grid,
  .body-grid,
  .ticker {
    width: 900px;
  }

  .top-grid {
    grid-template-columns: 160px 1fr 100px;
  }

  .body-grid {
    grid-template-columns: 190px 710px;
  }
}
