:root {
  color-scheme: dark;
  --ink: #0d0f0c;
  --ink-2: #141813;
  --panel: rgba(21, 25, 20, 0.88);
  --panel-2: rgba(238, 242, 226, 0.06);
  --line: rgba(236, 244, 219, 0.16);
  --paper: #f0f5df;
  --paper-2: #c9d4be;
  --muted: #8e9b8c;
  --lime: #c8ff62;
  --cyan: #52d8c9;
  --coral: #ff745f;
  --amber: #ffc15d;
  --violet-free-blue: #204f49;
  --shadow: rgba(0, 0, 0, 0.42);
  --font-display: "IBM Plex Sans", "Avenir Next", "Helvetica Neue", sans-serif;
  --font-mono: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(120deg, rgba(82, 216, 201, 0.08), transparent 38%),
    linear-gradient(0deg, rgba(200, 255, 98, 0.08), transparent 34%),
    var(--ink);
  color: var(--paper);
  font-family: var(--font-display);
}

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

button,
select,
textarea,
input {
  font: inherit;
}

.data-lab-shell {
  min-height: 100vh;
  padding: 18px clamp(12px, 2.6vw, 34px) 42px;
}

.lab-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 0 0 16px;
  border-bottom: 1px solid var(--line);
}

.brand-link {
  color: var(--paper);
  font-size: 1.02rem;
  font-weight: 950;
}

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

.lab-topbar[data-site-header] .site-secondary-links[data-open-data-section-nav] {
  display: flex !important;
}

.lab-topbar[data-site-header] .site-secondary-links[data-open-data-section-nav] a {
  min-height: 44px !important;
}

.lab-topbar a:not(.brand-link),
.source-grid a {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  color: var(--paper-2);
  font-size: 0.78rem;
  font-weight: 850;
}

.lab-workbench {
  display: grid;
  grid-template-columns: minmax(250px, 0.58fr) minmax(560px, 1.38fr) minmax(280px, 0.72fr);
  gap: 14px;
  align-items: start;
  padding-top: 14px;
}

.catalog-rail,
.analysis-stage,
.mcp-panel {
  min-width: 0;
}

.catalog-rail,
.mcp-panel {
  display: grid;
  gap: 12px;
}

.catalog-rail {
  position: sticky;
  top: 14px;
}

.mcp-panel {
  grid-column: auto;
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
}

.implementation-receipt {
  grid-column: auto;
}

.mcp-panel > * {
  min-width: 0;
  width: 100%;
  max-width: 100%;
}

.rail-head,
.chart-panel,
.profile-panel,
.sql-panel,
.three-panel,
.chatkit-panel,
.contract-panel,
.implementation-receipt-head,
.source-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(140deg, rgba(238, 242, 226, 0.055), rgba(82, 216, 201, 0.035)),
    var(--panel);
  box-shadow: 0 24px 90px var(--shadow);
}

.rail-head {
  padding: 16px;
}

.rail-kicker,
.stage-label,
.panel-head span,
.filter-control span,
.runtime-strip span,
.dataset-card span,
.profile-facts dt,
.webmcp-receipt span {
  color: var(--lime);
  font-size: 0.72rem;
  font-weight: 950;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 12px;
  font-size: clamp(2.4rem, 5vw, 5.2rem);
  line-height: 0.92;
}

h2 {
  margin-bottom: 8px;
  font-size: clamp(1.45rem, 2.7vw, 2.65rem);
  line-height: 0.96;
}

.rail-head p:not(.rail-kicker),
.stage-toolbar p,
.source-section p {
  margin-bottom: 0;
  color: var(--paper-2);
  line-height: 1.55;
}

.filter-control {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: rgba(12, 15, 12, 0.72);
}

.filter-control strong {
  color: var(--paper);
  font-size: 0.9rem;
}

select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(9, 12, 9, 0.82);
  color: var(--paper);
}

select {
  min-height: 38px;
  padding: 0 10px;
}

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

.dataset-list {
  display: grid;
  gap: 8px;
  max-height: calc(100vh - 340px);
  overflow: auto;
  padding-right: 2px;
}

.dataset-card {
  display: grid;
  gap: 7px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: rgba(16, 19, 16, 0.78);
  color: var(--paper);
  text-align: left;
  cursor: pointer;
}

.dataset-card.is-active,
.dataset-card:hover,
.dataset-card:focus-visible {
  border-color: rgba(200, 255, 98, 0.72);
  outline: 2px solid rgba(82, 216, 201, 0.24);
}

.dataset-card strong {
  font-size: 0.98rem;
}

.dataset-card p {
  margin-bottom: 0;
  color: var(--paper-2);
  font-size: 0.84rem;
  line-height: 1.45;
}

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

.dataset-meta i {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 7px;
  color: var(--muted);
  font-style: normal;
  font-size: 0.7rem;
  font-weight: 850;
}

.analysis-stage {
  display: grid;
  gap: 12px;
}

.stage-toolbar,
.command-bar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background:
    linear-gradient(125deg, rgba(32, 79, 73, 0.38), rgba(16, 19, 16, 0.82)),
    var(--ink-2);
}

.runtime-strip {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 7px;
}

.runtime-strip span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 9px;
  color: var(--paper);
  background: rgba(9, 12, 9, 0.55);
}

.command-bar {
  align-items: center;
  padding: 10px;
}

.command-bar button {
  min-height: 44px;
  border: 1px solid rgba(200, 255, 98, 0.76);
  border-radius: 6px;
  padding: 0 13px;
  background: var(--lime);
  color: #14210a;
  font-weight: 950;
  cursor: pointer;
}

.command-bar button + button {
  border-color: var(--line);
  background: rgba(238, 242, 226, 0.08);
  color: var(--paper);
}

.command-bar label {
  display: grid;
  grid-template-columns: auto minmax(140px, 1fr);
  gap: 8px;
  align-items: center;
  margin-left: auto;
  color: var(--paper-2);
  font-size: 0.8rem;
  font-weight: 850;
  text-transform: uppercase;
}

.viz-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(260px, 0.72fr);
  gap: 12px;
}

.chart-panel,
.profile-panel,
.sql-panel,
.three-panel,
.chatkit-panel,
.contract-panel,
.implementation-receipt-head,
.source-section {
  padding: 13px;
}

.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.panel-head strong {
  color: var(--paper);
  font-size: 0.9rem;
}

.implementation-receipt-head {
  display: grid;
  gap: 10px;
}

.implementation-receipt-head h2 {
  margin-bottom: 0;
  font-size: clamp(1.6rem, 2.6vw, 2.55rem);
}

.implementation-receipt-head p:not(.stage-label) {
  margin-bottom: 0;
  color: var(--paper-2);
  line-height: 1.52;
}

#chart-svg {
  display: block;
  width: 100%;
  min-height: 320px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #090c09;
}

#chart-svg text {
  fill: var(--paper-2);
  font-family: var(--font-mono);
  font-size: 15px;
}

#chart-svg .axis {
  stroke: rgba(240, 245, 223, 0.24);
}

#chart-svg .bar {
  fill: var(--lime);
}

#chart-svg .line {
  fill: none;
  stroke: var(--cyan);
  stroke-width: 5;
}

#chart-svg .point {
  fill: var(--coral);
}

.profile-facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  margin: 0 0 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--line);
}

.profile-facts div {
  min-width: 0;
  padding: 10px;
  background: rgba(10, 13, 10, 0.84);
}

.profile-facts dd {
  margin: 5px 0 0;
  overflow-wrap: anywhere;
  color: var(--paper);
  font-weight: 850;
}

.question-list,
#mcp-contract-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 18px;
  color: var(--paper-2);
  line-height: 1.5;
}

.webmcp-receipt {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  border: 1px solid rgba(82, 216, 201, 0.22);
  border-radius: 7px;
  padding: 12px;
  background: rgba(82, 216, 201, 0.055);
}

.webmcp-receipt strong {
  color: var(--paper);
  line-height: 1.25;
}

.webmcp-receipt strong[data-webmcp-state="registered"] {
  color: var(--lime);
}

.webmcp-receipt p {
  margin: 0;
  color: var(--paper-2);
  font-size: 0.82rem;
  line-height: 1.46;
}

.webmcp-receipt code {
  color: var(--paper);
  overflow-wrap: anywhere;
}

.sql-panel {
  display: grid;
  gap: 10px;
}

#sql-editor {
  min-height: 132px;
  resize: vertical;
  padding: 12px;
  color: var(--paper);
  font-family: var(--font-mono);
  font-size: 0.86rem;
  line-height: 1.6;
}

.result-table-wrap {
  min-width: 0;
  max-width: 100%;
  max-height: 270px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #090c09;
}

.result-table {
  width: 100%;
  min-width: 680px;
  border-collapse: collapse;
}

.result-table th,
.result-table td {
  border-bottom: 1px solid var(--line);
  padding: 10px;
  text-align: left;
  vertical-align: top;
  font-size: 0.84rem;
}

.result-table th {
  color: var(--lime);
  font-size: 0.7rem;
  font-weight: 950;
  text-transform: uppercase;
}

#dataset-atlas {
  display: block;
  width: 100%;
  aspect-ratio: 620 / 420;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #070a07;
  cursor: crosshair;
  touch-action: manipulation;
}

#dataset-atlas:focus-visible,
#dataset-atlas.is-inspecting {
  outline: 2px solid var(--lime);
  outline-offset: 3px;
  border-color: rgba(200, 255, 98, 0.76);
}

.atlas-inspector {
  display: grid;
  gap: 5px;
  margin-top: 10px;
  border: 1px solid rgba(82, 216, 201, 0.3);
  border-radius: 7px;
  padding: 10px 11px;
  background:
    linear-gradient(120deg, rgba(82, 216, 201, 0.12), rgba(200, 255, 98, 0.06)),
    rgba(9, 12, 9, 0.74);
}

.atlas-inspector span {
  color: var(--cyan);
  font-size: 0.68rem;
  font-weight: 950;
  text-transform: uppercase;
}

.atlas-inspector strong {
  color: var(--paper);
  font-size: 0.92rem;
  line-height: 1.12;
}

.atlas-inspector p {
  margin: 0;
  color: var(--paper-2);
  font-size: 0.78rem;
  font-weight: 820;
  line-height: 1.4;
}

.atlas-inspector-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin: 2px 0 0;
}

.atlas-inspector-grid div {
  min-width: 0;
  border: 1px solid rgba(240, 245, 223, 0.1);
  border-radius: 6px;
  padding: 7px;
  background: rgba(7, 10, 7, 0.42);
}

.atlas-inspector-grid dt {
  color: var(--cyan);
  font-size: 0.64rem;
  font-weight: 950;
  text-transform: uppercase;
}

.atlas-inspector-grid dd {
  margin: 4px 0 0;
  color: var(--paper);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 800;
  line-height: 1.28;
  overflow-wrap: anywhere;
}

.atlas-status {
  margin: 10px 0 0;
  border: 1px solid rgba(82, 216, 201, 0.22);
  border-radius: 7px;
  padding: 10px 11px;
  background: rgba(82, 216, 201, 0.07);
  color: var(--paper-2);
  font-size: 0.76rem;
  font-weight: 850;
  line-height: 1.45;
}

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

.atlas-receipt div,
.atlas-receipt p {
  min-width: 0;
  margin: 0;
  border: 1px solid rgba(240, 245, 223, 0.12);
  border-radius: 7px;
  padding: 9px;
  background: rgba(9, 12, 9, 0.62);
}

.atlas-receipt span {
  display: block;
  color: var(--cyan);
  font-size: 0.68rem;
  font-weight: 950;
  text-transform: uppercase;
}

.atlas-receipt strong {
  display: block;
  margin-top: 5px;
  color: var(--paper);
  font-size: 0.78rem;
  line-height: 1.25;
}

.atlas-receipt p {
  grid-column: 1 / -1;
  color: var(--paper-2);
  font-size: 0.78rem;
  font-weight: 780;
  line-height: 1.45;
}

#chatkit-context,
#chatkit-handoff {
  min-height: 300px;
  max-height: 380px;
  overflow: auto;
  overflow-wrap: anywhere;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 12px;
  background: #090c09;
  color: var(--paper-2);
  font-family: var(--font-mono);
  font-size: 0.76rem;
  line-height: 1.6;
  white-space: pre-wrap;
}

#chatkit-handoff {
  min-height: 190px;
  max-height: 270px;
  margin-top: 10px;
  border-color: rgba(82, 216, 201, 0.26);
  background:
    linear-gradient(135deg, rgba(82, 216, 201, 0.08), transparent 44%),
    #090c09;
}

.chatkit-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
}

.chatkit-actions button {
  min-height: 38px;
  border: 1px solid rgba(82, 216, 201, 0.68);
  border-radius: 6px;
  padding: 0 11px;
  background: rgba(82, 216, 201, 0.14);
  color: var(--paper);
  font-size: 0.78rem;
  font-weight: 950;
  cursor: pointer;
}

.chatkit-actions span {
  color: var(--paper-2);
  font-size: 0.74rem;
  font-weight: 850;
}

.source-section {
  display: grid;
  grid-template-columns: minmax(220px, 0.42fr) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
  margin-top: 14px;
}

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

.source-grid a {
  display: grid;
  align-items: center;
  min-width: 0;
  min-height: 48px;
  overflow-wrap: anywhere;
  background: rgba(10, 13, 10, 0.74);
}

@media (max-width: 1280px) {
  .lab-workbench {
    grid-template-columns: minmax(240px, 0.76fr) minmax(0, 1.35fr);
  }

  .mcp-panel {
    grid-column: 1 / -1;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 820px) {
  .lab-topbar,
  .stage-toolbar,
  .command-bar,
  .source-section {
    display: grid;
  }

  .lab-topbar nav {
    justify-content: start;
  }

  .lab-workbench,
  .viz-grid,
  .mcp-panel,
  .atlas-receipt,
  .source-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .source-section,
  .source-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .atlas-receipt p {
    grid-column: auto;
  }

  .catalog-rail {
    position: static;
    order: 2;
  }

  .analysis-stage {
    order: 1;
  }

  .mcp-panel {
    order: 3;
  }

  .dataset-list {
    max-height: none;
  }

  .command-bar label {
    grid-template-columns: 1fr;
    margin-left: 0;
  }

  .result-table {
    min-width: 680px;
    table-layout: auto;
  }

  .result-table th,
  .result-table td {
    overflow-wrap: anywhere;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
