:root {
  color-scheme: dark;
  --ink: #10110e;
  --ink-2: #161a1a;
  --panel: #1c211e;
  --panel-soft: rgba(246, 242, 232, 0.06);
  --paper: #f6f2e8;
  --paper-2: #efe6d3;
  --muted: #aeb6a8;
  --line: rgba(246, 242, 232, 0.15);
  --line-strong: rgba(246, 242, 232, 0.28);
  --acid: #b7ff52;
  --cyan: #4fd7c5;
  --coral: #ff6f59;
  --amber: #ffbd54;
  --violet: #b7a6ff;
  --radius: 8px;
  --shadow: 0 26px 88px rgba(0, 0, 0, 0.32);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  margin: 0;
  background:
    linear-gradient(rgba(246, 242, 232, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(246, 242, 232, 0.035) 1px, transparent 1px),
    linear-gradient(135deg, #0e100d 0%, #121817 46%, #1c1612 100%);
  background-size:
    32px 32px,
    32px 32px,
    auto;
  color: var(--paper);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
textarea,
input {
  font: inherit;
}

button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(246, 242, 232, 0.07);
  color: var(--paper);
  font-size: 0.82rem;
  font-weight: 900;
  cursor: pointer;
}

button:hover,
button:focus-visible,
a:hover,
a:focus-visible,
textarea:focus-visible,
input:focus-visible {
  outline: 2px solid rgba(79, 215, 197, 0.48);
  outline-offset: 2px;
}

.lab-shell {
  width: min(1680px, 100%);
  margin: 0 auto;
  padding: 18px clamp(14px, 2.6vw, 42px) 56px;
}

.lab-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 16px;
}

.brand-link {
  font-weight: 950;
  letter-spacing: 0;
}

.lab-topbar nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.lab-topbar nav a {
  min-width: 76px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 9px 11px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
  text-align: center;
  background: rgba(16, 17, 14, 0.48);
}

.app-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 480px);
  gap: 24px;
  align-items: end;
  padding: 18px 0 14px;
  border-top: 1px solid var(--line);
}

.lab-kicker,
.section-label {
  display: block;
  margin: 0 0 8px;
  color: var(--acid);
  font-size: 0.74rem;
  font-weight: 950;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

h1 {
  max-width: 980px;
  margin-bottom: 8px;
  font-size: clamp(2.15rem, 4vw, 3.45rem);
  line-height: 0.94;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: clamp(1.28rem, 1.8vw, 2.08rem);
  line-height: 1.05;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 7px;
  font-size: 1rem;
  line-height: 1.18;
}

.hero-copy p:not(.lab-kicker),
.surface-thesis,
.trace-section p,
.receipts-section p,
.component-card p {
  color: var(--muted);
  line-height: 1.55;
}

.hero-copy p:not(.lab-kicker) {
  max-width: 860px;
  margin-bottom: 0;
  font-size: 0.95rem;
}

.hero-meter,
.command-strip,
.surface-stage,
.control-panel,
.trace-section,
.receipts-section {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(28, 33, 30, 0.91);
  box-shadow: var(--shadow);
}

.hero-meter {
  display: grid;
  grid-template-columns: 1.4fr repeat(2, 0.8fr);
  gap: 1px;
  overflow: hidden;
  background: var(--line);
}

.hero-meter div {
  min-width: 0;
  padding: 12px;
  background:
    linear-gradient(135deg, rgba(79, 215, 197, 0.13), rgba(255, 189, 84, 0.07)),
    rgba(28, 33, 30, 0.94);
}

.hero-meter span,
.receipt-grid span {
  display: block;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 900;
  text-transform: uppercase;
}

.hero-meter strong {
  display: block;
  min-width: 0;
  margin-top: 6px;
  overflow-wrap: anywhere;
  color: var(--paper);
  font-size: 1.12rem;
  line-height: 1.12;
}

.command-strip {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: stretch;
  margin-bottom: 14px;
  padding: 12px;
}

.prompt-block {
  display: grid;
  gap: 8px;
}

.prompt-block span,
.mini-heading strong {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 900;
  text-transform: uppercase;
}

textarea {
  width: 100%;
  min-height: 92px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 11px 12px;
  background: rgba(16, 17, 14, 0.7);
  color: var(--paper);
  line-height: 1.5;
}

.command-actions {
  display: grid;
  grid-template-columns: minmax(112px, 1fr);
  gap: 10px;
  align-content: end;
  min-width: 140px;
}

.primary-action {
  border-color: rgba(183, 255, 82, 0.64);
  background: var(--acid);
  color: #172007;
}

.studio-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(306px, 370px);
  gap: 14px;
  align-items: start;
}

.surface-stage {
  min-width: 0;
  padding: 14px;
}

.stage-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 0.72fr) minmax(260px, 0.6fr);
  gap: 18px;
  align-items: end;
  margin-bottom: 12px;
}

.surface-thesis {
  margin: 0;
  font-size: 0.88rem;
}

#generative-surface-canvas {
  display: block;
  width: 100%;
  aspect-ratio: 1200 / 680;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0b0d0c;
}

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

.component-card {
  min-height: 142px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: rgba(246, 242, 232, 0.055);
}

.component-card.is-selected {
  border-color: rgba(183, 255, 82, 0.72);
  background: rgba(183, 255, 82, 0.09);
}

.component-card button {
  display: block;
  width: 100%;
  min-height: 0;
  margin: 0 0 7px;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--paper);
  text-align: left;
  line-height: 1.18;
}

.component-card p {
  margin-bottom: 10px;
  font-size: 0.82rem;
}

.component-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.component-meta span {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 5px 7px;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 900;
  text-transform: uppercase;
}

.control-panel {
  display: grid;
  gap: 18px;
  padding: 14px;
}

@media (min-width: 1080px) {
  .control-panel {
    position: sticky;
    top: 16px;
  }
}

.scenario-buttons {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.scenario-buttons button.active {
  border-color: rgba(79, 215, 197, 0.62);
  background: rgba(79, 215, 197, 0.14);
  color: var(--paper);
}

.mini-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

input[type="range"] {
  min-height: 32px;
  width: 100%;
  accent-color: var(--acid);
}

.channel-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.channel-controls label {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 9px;
  align-items: center;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px;
  background: rgba(246, 242, 232, 0.045);
}

.channel-controls input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--cyan);
}

.channel-controls span {
  min-width: 0;
  color: var(--paper-2);
  font-size: 0.82rem;
  font-weight: 850;
}

#surface-readout {
  min-height: 188px;
  max-height: 260px;
  overflow: auto;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: rgba(16, 17, 14, 0.78);
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.78rem;
  line-height: 1.62;
  white-space: pre-wrap;
}

.trace-section,
.receipts-section {
  display: grid;
  gap: 18px;
  margin-top: 16px;
  padding: 18px;
}

.model-trace {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.model-trace li,
.receipt-grid article {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: rgba(246, 242, 232, 0.05);
}

.model-trace strong {
  display: block;
  margin-bottom: 7px;
  color: var(--paper);
  line-height: 1.18;
}

.model-trace span {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.45;
}

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

.receipt-grid code {
  display: block;
  margin: 12px 0;
  overflow-wrap: anywhere;
  color: var(--acid);
  font-size: 0.82rem;
}

.receipt-grid p {
  margin-bottom: 0;
  font-size: 0.86rem;
}

@media (max-width: 1040px) {
  .app-hero,
  .studio-layout,
  .stage-toolbar,
  .command-strip {
    grid-template-columns: 1fr;
  }

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

  .model-trace {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .command-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    min-width: 0;
  }
}

@media (max-width: 620px) {
  .lab-topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .app-hero {
    padding-top: 12px;
  }

  h1 {
    font-size: 2rem;
  }

  h2 {
    font-size: 1.3rem;
  }

  .hero-meter,
  .component-grid,
  .receipt-grid,
  .model-trace,
  .channel-controls {
    grid-template-columns: 1fr;
  }

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

  .surface-stage,
  .control-panel,
  .trace-section,
  .receipts-section {
    padding: 12px;
  }

  .component-card {
    min-height: 120px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}
