:root {
  color-scheme: dark;
  --bg: #10120f;
  --panel: #181b17;
  --panel-2: #20251e;
  --ink: #f5f0e7;
  --muted: #aaa79d;
  --line: rgba(245, 240, 231, 0.14);
  --green: #8fcf91;
  --teal: #62c3be;
  --amber: #e2b66f;
  --rose: #d8878f;
  --blue: #8eaee8;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background:
    linear-gradient(120deg, rgba(143, 207, 145, 0.08), transparent 32%),
    linear-gradient(240deg, rgba(216, 135, 143, 0.08), transparent 34%),
    var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  font-optical-sizing: auto;
}

button,
input {
  font: inherit;
}

button {
  border-radius: 0;
}

button,
.evidence-links a {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

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

[hidden] {
  display: none !important;
}

.app {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  grid-template-rows: auto auto;
  align-content: start;
  align-items: start;
  column-gap: 22px;
  row-gap: 12px;
  min-height: 100vh;
  min-height: 100svh;
  padding: 22px;
}

.stage,
.panel {
  border: 1px solid var(--line);
  background: rgba(24, 27, 23, 0.82);
  box-shadow: var(--shadow);
}

.stage {
  grid-column: 1;
  grid-row: 1;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  height: min(760px, calc(100vh - 44px));
  height: min(760px, calc(100svh - 44px));
  min-height: 540px;
  overflow: hidden;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 24px;
  padding: 26px;
  border-bottom: 1px solid var(--line);
}

.brand-block {
  min-width: 0;
}

.title-row {
  display: flex;
  align-items: flex-end;
  gap: 18px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--teal);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.055em;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 5vw, 5.25rem);
  line-height: 0.94;
  letter-spacing: -0.025em;
}

.tagline {
  max-width: 32rem;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: clamp(1rem, 1.35vw, 1.25rem);
}

h2 {
  margin-bottom: 14px;
  font-size: 1rem;
  letter-spacing: 0;
}

.status {
  min-width: 82px;
  justify-self: end;
  padding: 8px 10px;
  border: 1px solid var(--line);
  background: rgba(16, 18, 15, 0.64);
  color: var(--muted);
  text-align: center;
  font-size: 0.86rem;
}

.status.is-live {
  border-color: rgba(143, 207, 145, 0.52);
  color: var(--green);
}

.hero {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 12px;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
}

.readout {
  margin: 0 20px 20px;
  justify-self: end;
  display: grid;
  grid-template-columns: repeat(2, minmax(120px, auto));
  gap: 10px;
}

.readout > div {
  padding: 12px 14px;
  border: 1px solid var(--line);
  background: rgba(16, 18, 15, 0.72);
  backdrop-filter: blur(14px);
}

.readout-label {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.045em;
}

.readout strong {
  font-size: 1.02rem;
}

.panel {
  grid-column: 2;
  grid-row: 1;
  display: flex;
  flex-direction: column;
  gap: 18px;
  align-self: stretch;
  min-height: 0;
  overflow: visible;
  padding: 18px;
}

.transport {
  display: grid;
  grid-template-columns: 116px minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
  align-items: stretch;
}

.generator {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 92px;
  gap: 10px;
  align-items: stretch;
}

.play-button {
  min-height: 74px;
  border: 0;
  background: var(--green);
  color: #10120f;
  font-weight: 800;
  cursor: pointer;
}

.play-button:hover {
  filter: brightness(1.05);
}

.generate-button,
.share-button {
  min-height: 60px;
  border: 1px solid color-mix(in srgb, var(--green), white 18%);
  background: color-mix(in srgb, var(--green), transparent 74%);
  color: var(--ink);
  font-weight: 800;
  cursor: pointer;
}

.play-button,
.generate-button,
.share-button,
.texture-option,
.category-button,
.evidence-links a {
  transform-origin: center;
  transition:
    transform 100ms ease-out,
    filter 120ms ease-out,
    color 120ms ease-out,
    background 140ms ease-out,
    border-color 140ms ease-out;
}

.play-button:active,
.generate-button:active,
.share-button:active,
.texture-option:active,
.evidence-links a:active {
  transform: scale(0.97);
}

.category-button:active {
  transform: scale(0.985);
}

.share-button {
  min-height: 48px;
  background: rgba(16, 18, 15, 0.5);
}

.generate-button:hover,
.share-button:hover {
  background: color-mix(in srgb, var(--green), transparent 62%);
}

.volume {
  display: grid;
  align-content: center;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  background: rgba(16, 18, 15, 0.5);
  color: var(--muted);
  font-size: 0.84rem;
}

.mix-control {
  gap: 9px;
}

.range-ends {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: rgba(245, 240, 231, 0.48);
  font-size: 0.66rem;
  line-height: 1.15;
}

.range-ends span:last-child {
  text-align: right;
}

.texture-control {
  grid-column: 1 / -1;
  gap: 10px;
}

.texture-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
}

.texture-option {
  min-height: 38px;
  border: 1px solid rgba(245, 240, 231, 0.13);
  background: rgba(245, 240, 231, 0.04);
  color: var(--muted);
  padding: 0 6px;
  font-size: 0.72rem;
  font-weight: 800;
  cursor: pointer;
}

.texture-option:hover {
  border-color: color-mix(in srgb, var(--green), white 18%);
  background: color-mix(in srgb, var(--green), transparent 72%);
  color: var(--ink);
}

.texture-option.is-active {
  border-color: color-mix(in srgb, var(--green), white 28%);
  background: color-mix(in srgb, var(--green), transparent 64%);
  color: var(--ink);
  box-shadow: inset 0 -2px 0 var(--green);
}

.seed-card {
  display: grid;
  align-content: center;
  gap: 7px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  background: rgba(16, 18, 15, 0.5);
}

.generator .seed-card {
  grid-column: 2;
  grid-row: 1;
}

.seed-card span {
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.seed-card strong {
  font-size: 0.95rem;
}

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

.modes {
  display: grid;
  gap: 10px;
}

.modes h2 {
  margin: 0;
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.055em;
  text-transform: uppercase;
}

.category-list {
  display: grid;
  gap: 8px;
}

.category-button {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  width: 100%;
  min-height: 68px;
  padding: 12px 13px;
  border: 1px solid var(--line);
  background: rgba(16, 18, 15, 0.44);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.category-button:hover {
  border-color: color-mix(in srgb, var(--accent), white 18%);
  background: color-mix(in srgb, var(--accent), transparent 84%);
}

.category-button.is-active {
  border-color: color-mix(in srgb, var(--accent), white 28%);
  background: color-mix(in srgb, var(--accent), transparent 78%);
  box-shadow: inset 3px 0 0 var(--accent);
}

.category-button strong {
  display: block;
  margin-bottom: 5px;
  font-size: 0.96rem;
}

.category-button span {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
}

.category-button .meter {
  width: 42px;
  height: 42px;
  border: 1px solid color-mix(in srgb, var(--accent), white 10%);
  background:
    linear-gradient(to top, color-mix(in srgb, var(--accent), black 8%) var(--fill), transparent 0),
    rgba(255, 255, 255, 0.04);
}

.protocol,
.evidence {
  padding: 16px;
  border: 1px solid var(--line);
  background: var(--panel-2);
}

dl {
  display: grid;
  gap: 10px;
  margin: 0;
}

dl > div {
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr);
  gap: 10px;
  align-items: baseline;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

dl > div:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

dt {
  color: var(--muted);
  font-size: 0.76rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

dd {
  margin: 0;
  font-size: 0.92rem;
}

.note,
.safety {
  color: var(--muted);
  line-height: 1.55;
}

.note {
  margin: 16px 0 0;
  font-size: 0.9rem;
}

.evidence {
  grid-column: 1;
  grid-row: 2;
  background: rgba(16, 18, 15, 0.52);
}

.evidence p,
.evidence li {
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.5;
}

.evidence p {
  margin: 0 0 12px;
}

.evidence ul {
  display: grid;
  gap: 9px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.evidence li {
  padding-left: 12px;
  border-left: 2px solid rgba(143, 207, 145, 0.38);
}

.evidence strong {
  color: var(--ink);
}

.evidence-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.evidence-links a {
  display: grid;
  min-height: 44px;
  align-items: center;
  border: 1px solid rgba(245, 240, 231, 0.14);
  background: rgba(245, 240, 231, 0.04);
  color: var(--green);
  padding: 7px 10px;
  font-size: 0.72rem;
  font-weight: 850;
  line-height: 1.12;
  text-decoration: none;
}

.evidence-links small {
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 700;
}

.evidence-links a:hover {
  border-color: color-mix(in srgb, var(--green), white 14%);
  color: var(--ink);
}

.safety {
  margin: auto 0 0;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: 0.84rem;
}

.site-footer {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 20px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.78rem;
}

.site-footer p {
  margin: 0;
}

.site-footer a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: inherit;
  text-underline-offset: 3px;
  touch-action: manipulation;
}

.site-footer a:hover {
  color: var(--ink);
}

.site-footer .social-share {
  padding: 0 12px;
  border: 1px solid var(--line);
  text-decoration: none;
}

@media (min-width: 961px) {
  .panel {
    align-self: start;
    height: min(760px, calc(100vh - 44px));
    height: min(760px, calc(100svh - 44px));
    max-height: calc(100vh - 44px);
    max-height: calc(100svh - 44px);
    contain: size layout;
    overflow-y: auto;
    overscroll-behavior: contain;
  }
}

@media (max-width: 1320px) {
  .topbar {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .brand-block {
    grid-column: 1;
    grid-row: 1;
  }

  .status {
    grid-column: 2;
    grid-row: 1;
  }
}

@media (max-width: 960px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
    height: auto;
    min-height: 100svh;
    padding: 12px;
  }

  .evidence {
    grid-column: auto;
    grid-row: auto;
  }

  .stage,
  .panel {
    grid-column: auto;
    grid-row: auto;
    height: auto;
    min-height: auto;
  }

  .panel {
    overflow: visible;
    max-height: none;
    contain: none;
    overscroll-behavior: auto;
  }

  .stage {
    overflow: visible;
  }

  .topbar {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    gap: 14px;
    padding: 16px;
  }

  .status {
    grid-column: 2;
    grid-row: 1;
    min-width: 54px;
    min-height: 36px;
    align-self: start;
    justify-self: end;
    padding: 7px 10px;
  }

  .title-row {
    align-items: flex-start;
  }

  .hero {
    height: clamp(260px, 42svh, 340px);
    min-height: 0;
  }

  canvas {
    min-height: 0;
  }
}

@media (max-width: 560px) {
  .app {
    padding: 8px;
  }

  .topbar,
  .title-row,
  .generator {
    grid-template-columns: 1fr;
  }

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

  .play-button {
    grid-column: 1 / -1;
  }

  .topbar,
  .title-row {
    display: grid;
  }

  .topbar {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    padding: 15px;
  }

  .brand-block {
    grid-column: 1;
    grid-row: 1;
    align-self: start;
  }

  .eyebrow {
    max-width: 15rem;
    margin-bottom: 6px;
    font-size: 0.68rem;
  }

  h1 {
    font-size: clamp(2rem, 12vw, 2.55rem);
  }

  .tagline {
    max-width: 13rem;
    margin-top: 8px;
    font-size: 1rem;
    line-height: 1.2;
  }

  .hero {
    height: clamp(250px, 42svh, 320px);
  }

  .texture-control,
  .generator .seed-card {
    grid-column: auto;
    grid-row: auto;
  }

  .status {
    width: fit-content;
    min-width: 50px;
    min-height: 34px;
    font-size: 0.78rem;
  }

  .readout {
    margin: 0 12px 12px;
    justify-self: stretch;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .readout > div {
    min-width: 0;
    padding: 10px 11px;
  }

  .readout-label {
    font-size: 0.62rem;
  }

  .readout strong {
    font-size: 0.92rem;
  }
}

@media (pointer: coarse) {
  .texture-option,
  .evidence-links a {
    min-height: 44px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .play-button,
  .generate-button,
  .share-button,
  .texture-option,
  .category-button,
  .evidence-links a {
    transition: none;
  }

  .play-button:active,
  .generate-button:active,
  .share-button:active,
  .texture-option:active,
  .category-button:active,
  .evidence-links a:active {
    transform: none;
  }
}

@media (prefers-reduced-transparency: reduce) {
  .stage,
  .panel,
  .readout > div {
    background: var(--panel);
    backdrop-filter: none;
  }
}

@media (prefers-contrast: more) {
  :root {
    --muted: #d3d0c7;
    --line: rgba(245, 240, 231, 0.38);
  }

  .stage,
  .panel,
  .volume,
  .seed-card,
  .category-button,
  .protocol,
  .evidence {
    background-color: #10120f;
  }
}
