:root {
  --bg: #090b10;
  --panel: #11141d;
  --panel-2: #171b27;
  --text: #f5f7fb;
  --muted: #9da7ba;
  --line: #2b3140;
  --green: #7ae582;
  --red: #ff5d5d;
  --amber: #ffc857;
  --dead: #111111;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(122,229,130,.12), transparent 30%),
    radial-gradient(circle at top right, rgba(255,93,93,.1), transparent 28%),
    linear-gradient(180deg, #0d1119, var(--bg));
  color: var(--text);
  font: 16px/1.4 "Avenir Next", "Segoe UI", sans-serif;
}
.app { max-width: 1040px; margin: 0 auto; padding: 32px 20px 48px; }
.topbar, .hero, .science-grid { display: grid; gap: 18px; }
.topbar { grid-template-columns: 1fr auto; align-items: start; }
.eyebrow, .label, .explanation { color: var(--muted); }
.eyebrow { margin: 0 0 6px; text-transform: uppercase; letter-spacing: .12em; font-size: .72rem; }
h1, h2, h3, p { margin: 0; }
h1 { font: 600 clamp(2.4rem, 5vw, 4.3rem)/.95 Georgia, serif; }
h3 { margin-bottom: 12px; font-size: 1rem; }
.register-tag {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .16em;
  font-size: .78rem;
  justify-self: end;
  text-align: right;
}
.hero { grid-template-columns: repeat(2, minmax(0, 1fr)); margin: 28px 0 18px; }
.hero-card, .panel {
  background: linear-gradient(180deg, rgba(255,255,255,.02), rgba(255,255,255,.01)), var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 22px;
  box-shadow: 0 24px 60px rgba(0,0,0,.28);
}
.hero-card { min-width: 0; }
.state {
  font-size: clamp(2rem, 6vw, 5rem);
  line-height: .95;
  letter-spacing: .02em;
  overflow-wrap: anywhere;
  text-wrap: balance;
}
.state.RESPIRING { color: var(--green); }
.state.FERMENTING { color: var(--red); }
.state.STARVING { color: var(--amber); }
.state.CALCULATING { color: #d7e3f6; }
.state.DEAD { color: #fff; background: var(--dead); display: inline-block; padding: .06em .22em; border-radius: .2em; }
.growth-card { display: flex; flex-direction: column; justify-content: space-between; }
.growth { display: flex; gap: 14px; align-items: baseline; flex-wrap: wrap; min-width: 0; }
.growth span { color: var(--muted); text-transform: uppercase; letter-spacing: .16em; }
.growth strong { font-size: clamp(2.4rem, 6vw, 5.4rem); line-height: .9; overflow-wrap: anywhere; }
.controls { background: var(--panel-2); }
.modes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 18px; }
.modes button, input[type="range"] { width: 100%; }
.modes button {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 14px;
  background: #0c1018;
  color: var(--muted);
  cursor: pointer;
  min-width: 0;
  font-size: clamp(.88rem, 1.9vw, 1rem);
}
.modes button.active { color: var(--text); border-color: var(--green); background: rgba(122,229,130,.08); }
.controls-meta { display: grid; gap: 10px; margin-bottom: 18px; }
.mode-hint { color: var(--muted); max-width: 72ch; min-height: 3.2em; }
.unit-note {
  color: var(--muted);
  font-size: .82rem;
  margin-top: -2px;
}
.calc-status {
  opacity: 0;
  transition: opacity .16s ease, transform .16s ease;
  min-height: 58px;
  pointer-events: none;
  transform: translateY(-2px);
  padding: 12px 14px 10px;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,.05);
  background: linear-gradient(180deg, rgba(255,255,255,.035), rgba(255,255,255,.015));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.04);
}
.calc-status.active { opacity: 1; }
.calc-status.active { transform: translateY(0); }
.calc-status::before {
  content: "";
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 10px;
  border-radius: 999px;
  vertical-align: middle;
  background: var(--green);
  box-shadow: 0 0 0 0 rgba(122,229,130,.5);
  animation: calc-pulse 1.2s ease-out infinite;
}
.calc-status[data-mode="glucose"]::before { background: #9ef01a; }
.calc-status[data-mode="glycerol"]::before { background: #4cc9f0; }
.calc-status[data-mode="methanol"]::before { background: #f4a261; }
.calc-text {
  color: var(--text);
  margin-bottom: 10px;
  font-size: .76rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  display: inline-block;
  vertical-align: middle;
}
.calc-bar {
  height: 9px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.04);
}
.calc-bar span {
  display: block;
  width: 34%;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(122,229,130,0), rgba(122,229,130,.72), rgba(246,255,248,1), rgba(122,229,130,0));
  animation: calc-slide 1.15s ease-in-out infinite;
}
.slider-grid { display: grid; gap: 12px; }
.slider-row {
  display: grid;
  grid-template-columns: 160px 1fr 56px;
  gap: 14px;
  align-items: center;
  min-height: 42px;
}
.slider-row span, th, td { overflow-wrap: anywhere; }
.slider-row.collapsed { display: none; }
input[type="range"] { accent-color: var(--green); }
output, th { color: var(--muted); }
.science-grid { grid-template-columns: minmax(260px, 320px) 1fr; align-items: start; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px 0; border-bottom: 1px solid var(--line); text-align: left; font-weight: 500; }
td { color: var(--text); }
.table-note {
  color: var(--muted);
  margin: -4px 0 10px;
  font-size: .82rem;
}
.chart-axis {
  color: var(--muted);
  margin-top: 8px;
  font-size: .82rem;
}
#chart { width: 100%; height: auto; display: block; background: #0b0f16; border: 1px solid var(--line); border-radius: 14px; }
.explanation { margin-top: 14px; min-height: 48px; }
@keyframes calc-slide {
  from { transform: translateX(-120%); }
  to { transform: translateX(260%); }
}
@keyframes calc-pulse {
  0% { box-shadow: 0 0 0 0 rgba(122,229,130,.45); }
  70% { box-shadow: 0 0 0 10px rgba(122,229,130,0); }
  100% { box-shadow: 0 0 0 0 rgba(122,229,130,0); }
}
@media (max-width: 760px) {
  .topbar, .hero, .science-grid { grid-template-columns: 1fr; }
  .modes { grid-template-columns: repeat(2, 1fr); }
  .slider-row { grid-template-columns: 1fr; }
  .mode-hint { min-height: 0; }
  .register-tag { justify-self: start; text-align: left; }
}
@media (max-width: 520px) {
  .state { font-size: clamp(1.7rem, 11vw, 2.7rem); }
  .growth strong { font-size: clamp(2rem, 12vw, 3.4rem); }
}
