:root {
  color-scheme: dark;
  --bg: #030505;
  --ink: #f7fffb;
  --muted: rgba(247, 255, 251, 0.64);
  --soft: rgba(247, 255, 251, 0.38);
  --hair: rgba(247, 255, 251, 0.12);
  --hair-strong: rgba(247, 255, 251, 0.26);
  --glass: rgba(5, 8, 8, 0.66);
  --glass-strong: rgba(5, 8, 8, 0.88);
  --accent-a: #35f2b7;
  --accent-b: #58c4ff;
  --accent-c: #ff4d6d;
  --base-a: #35f2b7;
  --base-c: #58c4ff;
  --base-g: #f7d046;
  --base-t: #ff5c8a;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    radial-gradient(circle at 50% 48%, transparent 0 36%, rgba(3, 5, 5, 0.16) 55%, rgba(3, 5, 5, 0.72) 100%),
    linear-gradient(180deg, rgba(3, 5, 5, 0.5), transparent 28%, transparent 70%, rgba(3, 5, 5, 0.68));
}

button,
input {
  font: inherit;
}

button {
  min-height: 42px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition:
    color 150ms ease,
    background 150ms ease,
    border-color 150ms ease;
}

button:hover,
button:focus-visible {
  color: var(--ink);
  outline: 0;
}

button:focus-visible,
input:focus-visible {
  outline: 1px solid color-mix(in srgb, var(--accent-a), white 12%);
  outline-offset: 3px;
}

#terrarium {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
  background: #030505;
  touch-action: none;
}

.topbar,
.readout,
.inspector,
.dna-legend,
.life-toggle,
.controls,
.credit {
  position: fixed;
  z-index: 2;
}

.topbar {
  top: 18px;
  left: 18px;
  right: 18px;
  display: grid;
  grid-template-columns: auto minmax(300px, 560px) minmax(160px, 1fr) auto;
  align-items: center;
  min-height: 58px;
  border: 1px solid var(--hair);
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(8, 12, 12, 0.78), rgba(8, 12, 12, 0.5));
  box-shadow: 0 22px 90px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(24px) saturate(130%);
}

.brand {
  padding: 0 18px 0 20px;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 680;
  text-decoration: none;
  white-space: nowrap;
}

.repo-form {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  min-height: 58px;
  padding: 0 16px;
  border-left: 1px solid var(--hair);
  border-right: 1px solid var(--hair);
}

.repo-form label {
  color: var(--soft);
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.repo-form input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 0.98rem;
}

.repo-form input::placeholder {
  color: var(--soft);
}

.repo-form button,
.inspect-toggle {
  padding: 0 16px;
  border-left: 1px solid transparent;
  color: var(--accent-a);
  font-weight: 560;
}

.inspect-toggle {
  min-width: 102px;
  border-left-color: var(--hair);
  border-radius: 0 999px 999px 0;
}

.inspect-toggle[aria-expanded="true"] {
  background: rgba(53, 242, 183, 0.1);
}

.signal {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 14px;
  min-width: 0;
  padding: 0 16px;
  color: var(--muted);
  font-size: 0.82rem;
  white-space: nowrap;
}

#status-text[data-tone="good"] {
  color: var(--accent-a);
}

#status-text[data-tone="warn"] {
  color: #f7d046;
}

#status-text[data-tone="bad"] {
  color: #ff6b6b;
}

.signal code {
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.74rem;
}

.readout {
  left: 28px;
  bottom: 96px;
  width: min(520px, calc(100vw - 56px));
}

.kicker {
  margin: 0 0 10px;
  color: var(--accent-a);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1 {
  max-width: 18ch;
  margin: 0;
  color: var(--ink);
  font-size: clamp(2rem, 4.6vw, 4.4rem);
  font-weight: 760;
  line-height: 0.92;
  letter-spacing: 0;
}

#repo-subtitle {
  max-width: 56ch;
  margin: 14px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.stats {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 1px;
  width: min(620px, calc(100vw - 56px));
  margin-top: 18px;
  border: 1px solid var(--hair);
  background: rgba(5, 8, 8, 0.42);
  backdrop-filter: blur(18px);
}

.stats span {
  display: grid;
  gap: 3px;
  min-width: 0;
  padding: 11px 12px;
  border-right: 1px solid var(--hair);
  color: var(--soft);
  font-size: 0.64rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.stats span:last-child {
  border-right: 0;
}

.stats b {
  overflow: hidden;
  color: var(--ink);
  font-size: 1.02rem;
  font-weight: 680;
  letter-spacing: 0;
  text-overflow: ellipsis;
  text-transform: none;
  white-space: nowrap;
}

.dna-legend {
  right: 32px;
  bottom: 96px;
  display: grid;
  grid-template-columns: repeat(4, 28px);
  gap: 8px;
  color: var(--soft);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.75rem;
}

.dna-legend span {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--hair);
  background: rgba(5, 8, 8, 0.34);
  backdrop-filter: blur(12px);
}

.dna-legend span:nth-child(1) {
  color: var(--base-a);
}

.dna-legend span:nth-child(2) {
  color: var(--base-c);
}

.dna-legend span:nth-child(3) {
  color: var(--base-g);
}

.dna-legend span:nth-child(4) {
  color: var(--base-t);
}

.life-toggle {
  right: 32px;
  bottom: 140px;
  display: grid;
  grid-template-columns: repeat(2, 8px);
  grid-template-rows: repeat(2, 8px);
  gap: 5px;
  width: 42px;
  min-height: 42px;
  place-content: center;
  border: 1px solid var(--hair);
  border-radius: 12px;
  background: rgba(5, 8, 8, 0.46);
  backdrop-filter: blur(14px);
}

.life-toggle span {
  display: block;
  width: 8px;
  height: 8px;
  border-radius: 3px;
  background: var(--soft);
}

.life-toggle span:nth-child(1) {
  background: var(--base-a);
}

.life-toggle span:nth-child(2) {
  background: var(--base-c);
}

.life-toggle span:nth-child(3) {
  background: var(--base-g);
}

.life-toggle span:nth-child(4) {
  background: var(--base-t);
}

.life-toggle:hover,
.life-toggle:focus-visible,
.life-toggle[aria-expanded="true"] {
  border-color: var(--hair-strong);
  background: rgba(247, 255, 251, 0.08);
}

.life-lab {
  position: fixed;
  inset: 18px;
  z-index: 4;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  border: 1px solid var(--hair-strong);
  border-radius: 24px;
  background:
    radial-gradient(circle at 50% 50%, rgba(53, 242, 183, 0.08), transparent 44%),
    rgba(3, 5, 5, 0.94);
  box-shadow: 0 40px 160px rgba(0, 0, 0, 0.62);
  backdrop-filter: blur(30px) saturate(140%);
  opacity: 0;
  pointer-events: none;
  transform: scale(0.985);
  transition:
    opacity 180ms ease,
    transform 180ms ease;
  overflow: hidden;
}

.life-lab.is-open {
  opacity: 1;
  pointer-events: auto;
  transform: scale(1);
}

.life-lab-head {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  padding: 18px 22px;
  border-bottom: 1px solid var(--hair);
}

.life-lab-head p,
.life-lab-note {
  margin: 0;
  color: var(--soft);
  font-size: 0.68rem;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.life-lab-head h2 {
  margin: 3px 0 0;
  color: var(--ink);
  font-size: clamp(1.35rem, 3vw, 2.5rem);
  line-height: 1;
}

.life-lab-actions {
  display: flex;
  gap: 10px;
}

.life-lab-actions button {
  min-width: 74px;
  min-height: 38px;
  border: 1px solid var(--hair);
  border-radius: 999px;
}

#life-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.life-lab-note {
  padding: 14px 22px 18px;
  border-top: 1px solid var(--hair);
  text-transform: none;
  letter-spacing: 0;
}

.controls {
  left: 50%;
  bottom: 22px;
  display: flex;
  gap: 2px;
  padding: 4px;
  border: 1px solid var(--hair);
  border-radius: 999px;
  background: rgba(5, 8, 8, 0.68);
  box-shadow: 0 18px 70px rgba(0, 0, 0, 0.34);
  backdrop-filter: blur(22px) saturate(130%);
  transform: translateX(-50%);
}

.controls button {
  min-width: 78px;
  min-height: 38px;
  border-radius: 999px;
  color: var(--muted);
}

.controls button:hover,
.controls button:focus-visible {
  background: rgba(247, 255, 251, 0.08);
}

.credit {
  right: 32px;
  bottom: 28px;
  color: var(--soft);
  font-size: 0.76rem;
}

.inspector {
  top: 90px;
  right: 18px;
  width: min(430px, calc(100vw - 36px));
  max-height: calc(100vh - 132px);
  border: 1px solid var(--hair);
  background: var(--glass-strong);
  box-shadow: 0 30px 120px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(28px) saturate(140%);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-8px) scale(0.985);
  transition:
    opacity 180ms ease,
    transform 180ms ease;
  overflow: hidden;
}

.inspector.is-open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.inspector-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  padding: 16px 18px;
  border-bottom: 1px solid var(--hair);
}

.inspector-head div {
  display: grid;
  gap: 3px;
}

.inspector-head span {
  color: var(--soft);
  font-size: 0.68rem;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.inspector-head strong {
  color: var(--ink);
  font-size: 1rem;
}

#inspector-close {
  min-height: 34px;
  color: var(--soft);
}

.inspector-body {
  display: grid;
  gap: 20px;
  max-height: calc(100vh - 206px);
  padding: 18px;
  overflow: auto;
}

.presets {
  display: flex;
  gap: 10px;
}

.presets button {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--hair);
  color: var(--muted);
}

.presets button:hover,
.presets button:focus-visible {
  border-color: var(--hair-strong);
  background: rgba(247, 255, 251, 0.06);
}

.inspector-section {
  display: grid;
  gap: 12px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: baseline;
  color: var(--soft);
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.section-head small {
  color: var(--soft);
  font-size: 0.65rem;
  letter-spacing: 0;
  text-transform: none;
}

.dna-sequence {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 7px;
  padding: 12px;
  border: 1px solid var(--hair);
  background: rgba(247, 255, 251, 0.03);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.72rem;
  line-height: 1.45;
}

.codon {
  display: inline-grid;
  grid-template-columns: repeat(3, auto);
  gap: 1px;
}

.codon i {
  min-width: 0.62rem;
  color: var(--base-color);
  font-style: normal;
  text-align: center;
}

.genes,
.languages {
  display: grid;
  gap: 8px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.genes li,
.languages li {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 38px;
  gap: 12px;
  align-items: center;
  color: var(--muted);
  font-size: 0.82rem;
  overflow: hidden;
}

.genes li::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: var(--gene-percent);
  height: 1px;
  background: var(--gene-color);
}

.languages li {
  grid-template-columns: 8px minmax(0, 1fr) 38px;
}

.languages li::before {
  content: "";
  width: 7px;
  height: 7px;
  background: var(--swatch);
}

.genes span,
.languages span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.genes b,
.languages strong {
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 560;
  text-align: right;
}

@media (max-width: 980px) {
  .topbar {
    top: 12px;
    left: 12px;
    right: 12px;
    grid-template-columns: minmax(0, 1fr) auto;
    border-radius: 22px;
  }

  .brand {
    display: none;
  }

  .repo-form {
    grid-column: 1 / -1;
    grid-template-columns: minmax(0, 1fr) auto;
    min-height: 52px;
    border: 0;
    border-bottom: 1px solid var(--hair);
    padding: 0 14px;
  }

  .repo-form label {
    display: none;
  }

  .signal {
    justify-content: flex-start;
    min-height: 44px;
    padding: 0 14px;
  }

  .inspect-toggle {
    min-width: 92px;
    min-height: 44px;
  }

  .readout {
    left: 14px;
    right: 14px;
    bottom: 110px;
    width: auto;
    padding: 14px 0 0;
    background: linear-gradient(180deg, rgba(3, 5, 5, 0), rgba(3, 5, 5, 0.62) 18%, rgba(3, 5, 5, 0.74));
  }

  h1 {
    max-width: 14ch;
    font-size: clamp(1.65rem, 9vw, 3.2rem);
  }

  #repo-subtitle {
    max-width: 38ch;
    font-size: 0.92rem;
  }

  .stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: min(100%, 420px);
  }

  .dna-legend,
  .credit {
    display: none;
  }

  .life-toggle {
    right: 14px;
    bottom: 70px;
    width: 40px;
    min-height: 40px;
    border-radius: 11px;
  }

  .controls {
    left: 12px;
    right: 12px;
    bottom: 12px;
    justify-content: space-between;
    transform: none;
  }

  .controls button {
    min-width: 0;
    flex: 1 1 0;
    font-size: 0.86rem;
  }

  .inspector {
    top: auto;
    right: 12px;
    bottom: 68px;
    left: 12px;
    width: auto;
    max-height: min(68vh, 620px);
    transform: translateY(12px);
  }

  .inspector.is-open {
    transform: translateY(0);
  }

  .inspector-body {
    max-height: calc(min(68vh, 620px) - 68px);
  }

  .life-lab {
    inset: 10px;
    border-radius: 18px;
  }

  .life-lab-head {
    padding: 14px;
  }

  .life-lab-actions button {
    min-width: 64px;
  }
}

@media (max-width: 520px) {
  .status-text {
    max-width: 40vw;
  }

  .signal {
    overflow: hidden;
  }

  #status-text {
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .stats span {
    padding: 9px 10px;
  }

  .controls {
    gap: 1px;
    padding: 3px;
  }

  .controls button {
    min-height: 36px;
    font-size: 0.8rem;
  }
}
