:root {
  --green: #22c670;
  --green-dark: #119655;
  --night: #061914;
  --night-soft: #0b2b22;
  --ink: #122033;
  --cream: #f4fbf7;
  --mint: #e3f7ec;
  --line: #d4e9dd;
  --muted: #587065;
  --lime: #a3e635;
  --coral: #dc4c55;
  --gold: #f5c542;
  --blue: #62b9ff;
  --white: #ffffff;
  --shadow: 0 22px 60px rgba(5, 50, 27, .13);
  --shadow-soft: 0 10px 28px rgba(34, 198, 112, .16);
  --radius: 18px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { color-scheme: light; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100svh;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
  background:
    radial-gradient(900px 430px at 11% -8%, rgba(34, 198, 112, .18), transparent 64%),
    radial-gradient(720px 380px at 93% 2%, rgba(245, 197, 66, .11), transparent 68%),
    var(--cream);
}

button,
input,
select { font: inherit; }

button,
select,
input[type="range"],
input[type="checkbox"] { cursor: pointer; }

button:focus-visible,
select:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(34, 198, 112, .35);
  outline-offset: 3px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: 1600px;
  margin: 0 auto;
  padding: 14px clamp(14px, 2.5vw, 34px) 8px;
}

.brand {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 6px 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, .94);
  box-shadow: 0 5px 18px rgba(5, 50, 27, .07);
}

.brand img {
  display: block;
  width: auto;
  height: 30px;
  object-fit: contain;
}

.topbar-label {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 5px 12px;
  border: 1px solid #bde7ce;
  border-radius: 999px;
  color: #0b6540;
  background: rgba(227, 247, 236, .86);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  white-space: nowrap;
}

.shell {
  width: min(1600px, 100%);
  margin: 0 auto;
  padding: 6px clamp(12px, 2.4vw, 34px) 42px;
}

.hero {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin: 4px 0 18px;
}

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

.kicker,
.instrument-id,
.result-kicker {
  margin: 0 0 6px;
  color: var(--green-dark);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: .13em;
  text-transform: uppercase;
}

.hero h1 {
  margin: 0 0 7px;
  font-size: clamp(2rem, 5vw, 3.35rem);
  line-height: 1.02;
  letter-spacing: -.035em;
}

.hero-copy > p:last-child {
  max-width: 70ch;
  margin: 0;
  color: var(--muted);
  font-size: clamp(.95rem, 1.5vw, 1.08rem);
}

.spec-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 7px;
  max-width: 460px;
}

.spec-chips span {
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 255, 255, .8);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .03em;
}

.instrument-nav {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 9px;
  margin-bottom: 15px;
}

.instrument-tab {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-width: 0;
  min-height: 68px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--ink);
  text-align: left;
  background: rgba(255, 255, 255, .9);
  box-shadow: 0 8px 22px rgba(5, 50, 27, .06);
  transition: transform .18s ease, border-color .18s ease, background .18s ease;
}

.instrument-tab:hover {
  transform: translateY(-2px);
  border-color: #a6dfbd;
}

.instrument-tab.is-active {
  border-color: #22c670;
  color: #062812;
  background: linear-gradient(135deg, #e8f9ef, #f9fffb);
  box-shadow: var(--shadow-soft);
}

.tab-number {
  display: inline-grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 10px;
  color: #d9f8e7;
  background: var(--night);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .05em;
}

.instrument-tab.is-active .tab-number {
  color: #062812;
  background: var(--green);
}

.instrument-tab strong,
.instrument-tab small { display: block; }

.instrument-tab strong {
  overflow: hidden;
  margin-bottom: 2px;
  font-size: 13px;
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.instrument-tab small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.25;
}

.instrument-view {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255, 255, 255, .92);
  box-shadow: var(--shadow);
}

.instrument-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(100deg, rgba(227, 247, 236, .78), rgba(255, 255, 255, .65)),
    #fff;
}

.instrument-heading h2 {
  margin: 0 0 3px;
  font-size: clamp(1.35rem, 2.2vw, 1.75rem);
  line-height: 1.15;
}

.instrument-heading p:last-child {
  max-width: 78ch;
  margin: 0;
  color: var(--muted);
  font-size: .9rem;
}

.reset-button,
.primary-action,
.preset-row button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--ink);
  background: #fff;
  font-size: 12px;
  font-weight: 820;
}

.reset-button {
  flex: 0 0 auto;
  padding: 9px 13px;
}

.reset-button:hover,
.preset-row button:hover { border-color: #7ed6a3; background: #f3fcf7; }

.primary-action {
  width: 100%;
  padding: 9px 12px;
  border-color: #17985a;
  color: #062812;
  background: linear-gradient(180deg, #37d984, #22c670);
}

.primary-action[aria-pressed="true"] {
  border-color: #f2bf32;
  background: linear-gradient(180deg, #ffe58a, #f5c542);
}

.instrument-grid {
  display: grid;
  grid-template-columns: minmax(250px, 310px) minmax(460px, 1fr) minmax(250px, 300px);
  gap: 14px;
  padding: 14px;
  align-items: start;
}

.control-card,
.result-card,
.stage-card {
  min-width: 0;
  border-radius: 16px;
}

.control-card,
.result-card {
  padding: 15px;
  border: 1px solid var(--line);
  background: #fff;
}

.control-card h3 {
  margin: 0 0 14px;
  color: var(--green-dark);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.control-section-title {
  margin-top: 22px !important;
  padding-top: 17px;
  border-top: 1px solid var(--line);
}

.stage-card {
  overflow: hidden;
  border: 1px solid #143d32;
  background: var(--night);
  box-shadow: inset 0 0 60px rgba(34, 198, 112, .05);
}

.stage-card canvas {
  display: block;
  width: 100%;
  height: clamp(470px, 58vh, 640px);
}

.stage-card-tall canvas { height: clamp(560px, 68vh, 720px); }

.control { margin-bottom: 16px; }

.control label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 720;
}

.control output {
  color: var(--ink);
  font-weight: 850;
  text-align: right;
  white-space: nowrap;
}

.control small {
  display: block;
  margin-top: 4px;
  color: #70877b;
  font-size: 10px;
  line-height: 1.35;
}

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

.select-control { margin-bottom: 16px; }

.select-control label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 720;
}

.select-control select {
  width: 100%;
  min-height: 42px;
  padding: 8px 34px 8px 10px;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--ink);
  background: #fbfefc;
}

.check-row {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin: 13px 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
}

.check-row input {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--green);
}

.preset-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin-top: 14px;
}

.preset-row button {
  min-width: 0;
  min-height: 44px;
  padding: 6px;
  line-height: 1.15;
}

.readout-list {
  display: grid;
  gap: 8px;
  margin: 0 0 13px;
}

.readout-list div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #f9fdfb;
}

.readout-list dt {
  color: var(--muted);
  font-size: 11px;
  font-weight: 720;
}

.readout-list dd {
  margin: 0;
  color: var(--ink);
  font-size: 13px;
  font-weight: 900;
  text-align: right;
}

.verdict-positive { color: #08733e !important; }
.verdict-negative { color: #b8323c !important; }

.equation-block {
  display: grid;
  gap: 3px;
  padding: 12px;
  border-radius: 12px;
  color: #dff8e9;
  background: var(--night);
}

.equation-block span {
  margin-top: 7px;
  color: #93c7ad;
  font-size: 10px;
  font-weight: 750;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.equation-block span:first-child { margin-top: 0; }

.equation-block strong {
  font-family: "Segoe UI", system-ui, sans-serif;
  font-size: 12px;
  font-weight: 760;
}

.notice {
  margin-top: 12px;
  padding: 12px;
  border-left: 4px solid var(--green);
  border-radius: 0 11px 11px 0;
  background: var(--mint);
}

.notice strong {
  color: #0c6f43;
  font-size: 11px;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.notice p,
.challenge,
.scale-warning {
  margin: 5px 0 0;
  color: #315348;
  font-size: 11px;
  line-height: 1.48;
}

.challenge {
  margin-top: 13px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.scale-warning {
  padding: 10px;
  border: 1px solid #ead793;
  border-radius: 10px;
  color: #69551a;
  background: #fff9df;
}

.observatory-footer {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 4px 0;
  color: var(--muted);
  font-size: 11px;
}

.observatory-footer p { margin: 0; }

.noscript-message {
  max-width: 900px;
  margin: 20px auto;
  padding: 16px;
  border: 1px solid #ead793;
  border-radius: 12px;
  color: #69551a;
  background: #fff9df;
}

@media (max-width: 1150px) {
  .instrument-grid {
    grid-template-columns: minmax(240px, 300px) minmax(420px, 1fr);
    grid-template-areas:
      "controls stage"
      "results stage";
  }
  .control-card { grid-area: controls; }
  .stage-card { grid-area: stage; }
  .result-card { grid-area: results; }
}

@media (max-width: 980px) {
  .hero { align-items: flex-start; flex-direction: column; gap: 12px; }
  .spec-chips { justify-content: flex-start; max-width: none; }
  .instrument-nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .instrument-grid {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "stage"
      "controls"
      "results";
  }
  .stage-card canvas { height: clamp(480px, 64vh, 650px); }
  .stage-card-tall canvas { height: clamp(620px, 78vh, 760px); }
}

@media (max-width: 620px) {
  .topbar { padding-top: 10px; }
  .brand { min-height: 39px; padding: 4px 9px; }
  .brand img { height: 25px; }
  .topbar-label { min-height: 28px; padding: 4px 8px; font-size: 9px; }
  .shell { padding-inline: 9px; }
  .hero { margin-top: 10px; }
  .hero h1 { font-size: 2rem; }
  .instrument-nav { grid-template-columns: minmax(0, 1fr); gap: 6px; }
  .instrument-tab { min-height: 56px; }
  .instrument-tab small { display: none; }
  .instrument-heading { align-items: flex-start; flex-direction: column; padding: 15px; }
  .reset-button { width: 100%; }
  .instrument-grid { gap: 9px; padding: 9px; }
  .stage-card canvas { height: 510px; }
  .stage-card-tall canvas { height: 780px; }
  .preset-row { grid-template-columns: minmax(0, 1fr); }
  .observatory-footer { flex-direction: column; }
}

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