:root {
  color-scheme: dark;
  font-family: "Noto Sans SC", system-ui, sans-serif;
  background: #08090b;
  color: #e8e7e3;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  margin: 0;
  background: radial-gradient(circle at top left, #242529 0, #08090b 42%);
}

button,
a {
  font: inherit;
}

button {
  min-height: 2.5rem;
  padding: 0.5rem 0.85rem;
  border: 1px solid #56585b;
  border-radius: 0.25rem;
  background: #1b1c1f;
  color: inherit;
  cursor: pointer;
}

button:hover:not(:disabled),
button:focus-visible,
a:focus-visible {
  border-color: #f0efea;
  outline: 2px solid #f0efea;
  outline-offset: 2px;
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

a {
  color: #e8e7e3;
}

.site-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 2rem;
  max-width: 1520px;
  padding: 2rem 2rem 1.25rem;
  margin: 0 auto;
}

.site-header h1 {
  margin: 0.2rem 0;
  font-size: clamp(1.6rem, 3vw, 2.7rem);
  letter-spacing: 0.08em;
}

.site-header p:last-child {
  margin: 0.3rem 0 0;
  color: #a6a7a8;
  font-size: 0.9rem;
}

.site-header a {
  flex: 0 0 auto;
  padding: 0.5rem;
  text-decoration: none;
}

.eyebrow {
  margin: 0;
  color: #a6a7a8;
  font-size: 0.7rem;
  letter-spacing: 0.14em;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(300px, 0.85fr);
  align-items: start;
  gap: 1rem;
  max-width: 1520px;
  padding: 0 2rem 2rem;
  margin: 0 auto;
}

.workspace,
.test-sidebar > section {
  border: 1px solid #3b3c3e;
  background: rgba(17, 18, 20, 0.95);
}

.workspace {
  padding: 1rem;
}

.test-sidebar {
  display: grid;
  gap: 1rem;
}

.test-sidebar > section {
  padding: 1rem;
}

.test-sidebar > section[hidden] {
  display: none;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}

.section-heading h2,
.measurements h3,
.neural-panel h2 {
  margin: 0.15rem 0 0;
  font-size: 1.05rem;
}

.state-pill {
  max-width: 58%;
  padding: 0.4rem 0.6rem;
  border: 1px solid #5d5f61;
  border-radius: 999px;
  color: #d3d3d0;
  font-size: 0.72rem;
  text-align: right;
}

.state-pill[data-state="active"] {
  border-color: #e3e2dc;
  color: white;
}

.state-pill[data-state="error"] {
  border-color: #aaa;
  background: #3b1d1d;
}

.preview-frame {
  position: relative;
  display: grid;
  aspect-ratio: 4 / 3;
  place-items: center;
  overflow: hidden;
  background: #050506;
}

.preview-frame video,
.preview-frame canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  transform: scaleX(-1);
}

.preview-frame video {
  filter: grayscale(1);
  object-fit: contain;
}

.preview-frame canvas {
  pointer-events: none;
}

.preview-frame p {
  z-index: 1;
  max-width: 24rem;
  padding: 0.8rem;
  margin: 0;
  color: #a6a7a8;
  text-align: center;
}

.preview-frame p[hidden] {
  display: none;
}

.toolbar,
.neural-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.8rem;
}

.primary-button {
  background: #e8e7e3;
  color: #090a0b;
  font-weight: 700;
}

.diagnostic {
  min-height: 2.5em;
  margin: 0.8rem 0;
  color: #d1d1cc;
  font-size: 0.85rem;
  line-height: 1.5;
}

.measurements {
  padding-top: 0.9rem;
  border-top: 1px solid #3b3c3e;
}

.measurements dl {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.5rem;
  margin: 0.75rem 0;
}

.measurements dl > div {
  min-width: 0;
  padding: 0.65rem;
  background: #202124;
}

.measurements dt {
  color: #a6a7a8;
  font-size: 0.72rem;
}

.measurements dd {
  overflow: hidden;
  margin: 0.3rem 0 0;
  font-size: 0.9rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.measurements p,
.category-help,
.neural-panel p {
  color: #a6a7a8;
  font-size: 0.78rem;
  line-height: 1.55;
}

.sensor-nav {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.45rem;
}

.sensor-nav button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  text-align: left;
  font-size: 0.76rem;
}

.sensor-nav button span {
  color: #a6a7a8;
}

.sensor-nav button[aria-pressed="true"] {
  border-color: #e8e7e3;
  background: #3a3b3e;
}

.action-list {
  display: grid;
  gap: 0.5rem;
  padding: 0;
  margin: 0;
  list-style: none;
}

.action-list li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid #303134;
  font-size: 0.82rem;
}

.action-list output {
  flex: 0 0 auto;
  color: #aaa;
  font-size: 0.7rem;
}

.action-list li[data-passed="true"] output {
  color: #f0efea;
}

.neural-actions button {
  flex: 1 1 44%;
  font-size: 0.75rem;
}

.neural-panel output {
  display: block;
  margin-top: 0.6rem;
  color: #d1d1cc;
  font-size: 0.8rem;
}

.event-panel ol {
  display: grid;
  gap: 0.5rem;
  max-height: 12rem;
  overflow: auto;
  padding-left: 1.3rem;
  margin: 0;
  color: #c7c7c4;
  font-size: 0.75rem;
}

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

@media (max-width: 600px) {
  .site-header {
    padding: 1rem;
  }

  .layout {
    padding: 0 1rem 1rem;
  }

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

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