:root {
  color-scheme: dark;
  --lab-bg: #090d12;
  --lab-surface: #111821;
  --lab-surface-strong: #162231;
  --lab-surface-soft: #0d131b;
  --lab-border: rgba(184, 197, 214, 0.18);
  --lab-text: #eef4f8;
  --lab-muted: #9ba9b8;
  --lab-cyan: #5dd4d8;
  --lab-amber: #f3c96b;
  --lab-green: #8ed9a2;
  --lab-rose: #e8a0a8;
  --lab-shadow: 0 24px 70px rgba(0, 0, 0, 0.38);
  --lab-radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--lab-bg);
}

body.intention-body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(93, 212, 216, 0.08), transparent 320px),
    linear-gradient(135deg, #090d12 0%, #0d131b 52%, #101016 100%);
  color: var(--lab-text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.55;
}

body.intention-body a {
  color: inherit;
}

body.intention-body a:hover {
  color: var(--lab-cyan);
}

.skip-link {
  position: absolute;
  left: 12px;
  top: 12px;
  z-index: 10;
  transform: translateY(-140%);
  padding: 10px 14px;
  border-radius: var(--lab-radius);
  background: var(--lab-cyan);
  color: #051014;
  font-weight: 700;
}

.skip-link:focus {
  transform: translateY(0);
}

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

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--lab-cyan);
  outline-offset: 2px;
}

.lab-header {
  position: sticky;
  top: 0;
  z-index: 5;
  border-bottom: 1px solid var(--lab-border);
  background: rgba(9, 13, 18, 0.88);
  backdrop-filter: blur(14px);
}

.lab-nav,
.lab-shell,
.lab-footer {
  width: min(100% - 28px, 1180px);
  margin: 0 auto;
}

.lab-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 72px;
}

.lab-brand,
.lab-nav__links,
.hero-panel__actions,
.button-row,
.segmented,
.rng-controls,
.lab-footer {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.lab-brand {
  text-decoration: none;
}

.lab-brand__mark,
.app-badge {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(93, 212, 216, 0.42);
  border-radius: var(--lab-radius);
  background: rgba(93, 212, 216, 0.1);
  color: var(--lab-cyan);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.lab-brand strong,
.lab-brand small {
  display: block;
}

.lab-brand small {
  color: var(--lab-muted);
  font-size: 0.78rem;
}

.lab-nav__links a,
.lab-footer a {
  padding: 8px 10px;
  border: 1px solid var(--lab-border);
  border-radius: var(--lab-radius);
  color: var(--lab-muted);
  text-decoration: none;
  background: rgba(255, 255, 255, 0.03);
}

.lab-nav__links a:hover,
.lab-footer a:hover {
  border-color: rgba(93, 212, 216, 0.38);
  color: var(--lab-text);
}

.lab-shell {
  padding: 24px 0 36px;
  display: grid;
  gap: 18px;
}

.hero-panel,
.panel,
.model-strip article {
  border: 1px solid var(--lab-border);
  border-radius: var(--lab-radius);
  background: rgba(17, 24, 33, 0.86);
  box-shadow: var(--lab-shadow);
}

.hero-panel {
  display: grid;
  gap: 18px;
  padding: 22px;
}

.hero-panel__copy {
  display: grid;
  gap: 12px;
}

.kicker {
  margin: 0;
  color: var(--lab-cyan);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: 2.4rem;
  line-height: 1;
  letter-spacing: -0.03em;
}

h2 {
  margin-bottom: 0;
  font-size: 1.35rem;
  line-height: 1.15;
}

.hero-panel__lead {
  max-width: 760px;
  margin: 0;
  color: #dce8ed;
  font-size: 1.1rem;
}

.scope-note,
.muted,
.section-heading p,
.result-note {
  color: var(--lab-muted);
}

.scope-note,
.muted,
.result-note {
  margin-bottom: 0;
}

.button {
  min-height: 42px;
  padding: 9px 13px;
  border: 1px solid var(--lab-border);
  border-radius: var(--lab-radius);
  background: rgba(255, 255, 255, 0.04);
  color: var(--lab-text);
  text-decoration: none;
  cursor: pointer;
}

.button:hover:not(:disabled) {
  border-color: rgba(93, 212, 216, 0.46);
  background: rgba(93, 212, 216, 0.12);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.button--primary {
  border-color: rgba(93, 212, 216, 0.72);
  background: #5dd4d8;
  color: #061014;
  font-weight: 800;
}

.button--primary:hover:not(:disabled) {
  background: #7de3e5;
  color: #061014;
}

.model-strip {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr;
}

.model-strip article {
  min-height: 112px;
  padding: 14px;
  box-shadow: none;
}

.model-strip strong,
.model-strip span {
  display: block;
}

.model-strip strong {
  margin-bottom: 6px;
}

.model-strip span {
  color: var(--lab-muted);
}

.lab-grid {
  display: grid;
  gap: 18px;
  grid-template-columns: 1fr;
}

.panel {
  padding: 18px;
}

.panel--wide {
  grid-column: 1 / -1;
}

.section-heading {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.state-layout,
.field-grid,
.rng-layout {
  display: grid;
  gap: 14px;
}

.state-card {
  display: grid;
  gap: 14px;
  margin: 0;
  padding: 14px;
  border: 1px solid var(--lab-border);
  border-radius: var(--lab-radius);
  background: var(--lab-surface-soft);
}

.state-card legend {
  padding: 0 6px;
  color: var(--lab-amber);
  font-weight: 800;
}

.range-field,
.text-field,
.check-field {
  display: grid;
  gap: 8px;
}

.range-field span,
.text-field span {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: #dce8ed;
  font-weight: 700;
}

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

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--lab-border);
  border-radius: var(--lab-radius);
  background: #0b1118;
  color: var(--lab-text);
  padding: 10px 11px;
}

textarea {
  resize: vertical;
}

.text-field--full {
  grid-column: 1 / -1;
}

.delta-pill,
.status-line {
  margin: 14px 0 0;
  padding: 10px 12px;
  border: 1px solid var(--lab-border);
  border-radius: var(--lab-radius);
  background: rgba(255, 255, 255, 0.04);
  color: #dce8ed;
}

.status-line[data-tone="ok"] {
  border-color: rgba(142, 217, 162, 0.42);
  color: #dff8e6;
}

.status-line[data-tone="warn"] {
  border-color: rgba(243, 201, 107, 0.48);
  color: #ffe4a7;
}

.timer-card {
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--lab-border);
  border-radius: var(--lab-radius);
  background: var(--lab-surface-soft);
}

.timer-ring {
  --timer-progress: 0;
  --timer-angle: 0deg;
  width: 168px;
  height: 168px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background:
    conic-gradient(var(--lab-cyan) var(--timer-angle), rgba(255, 255, 255, 0.08) 0),
    #0b1118;
  position: relative;
}

.timer-ring::before {
  content: '';
  position: absolute;
  inset: 10px;
  border-radius: inherit;
  background: var(--lab-surface);
}

.timer-ring span {
  position: relative;
  font-size: 2rem;
  font-weight: 850;
  letter-spacing: 0.02em;
}

.timer-cue {
  margin: 0;
  color: #dce8ed;
  font-weight: 700;
  text-align: center;
}

.segmented {
  margin-top: 14px;
}

.segmented button {
  min-height: 38px;
  padding: 8px 11px;
  border: 1px solid var(--lab-border);
  border-radius: var(--lab-radius);
  background: rgba(255, 255, 255, 0.03);
  color: var(--lab-muted);
  cursor: pointer;
}

.segmented button.is-active {
  border-color: rgba(93, 212, 216, 0.62);
  color: var(--lab-text);
  background: rgba(93, 212, 216, 0.12);
}

.button-row {
  margin-top: 14px;
}

.rng-controls {
  align-items: end;
}

.rng-controls .text-field {
  min-width: min(100%, 220px);
}

.bit-grid {
  min-height: 164px;
  display: grid;
  grid-template-columns: repeat(16, minmax(0, 1fr));
  gap: 4px;
  padding: 10px;
  border: 1px solid var(--lab-border);
  border-radius: var(--lab-radius);
  background: #070b10;
}

.bit-cell {
  min-height: 24px;
  display: grid;
  place-items: center;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 800;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.bit-cell--1 {
  background: rgba(93, 212, 216, 0.16);
  color: #bdf6f7;
}

.bit-cell--0 {
  background: rgba(243, 201, 107, 0.12);
  color: #ffe3a3;
}

.result-card {
  padding: 14px;
  border: 1px solid var(--lab-border);
  border-radius: var(--lab-radius);
  background: var(--lab-surface-soft);
}

.stats-grid,
.recent-run dl {
  display: grid;
  gap: 8px;
  margin: 0;
}

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

.stats-grid div,
.recent-run dl div {
  padding: 10px;
  border: 1px solid var(--lab-border);
  border-radius: var(--lab-radius);
  background: rgba(255, 255, 255, 0.04);
}

.stats-grid dt,
.recent-run dt {
  color: var(--lab-muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.stats-grid dd,
.recent-run dd {
  margin: 3px 0 0;
  color: var(--lab-text);
  font-weight: 800;
}

.result-note {
  margin-top: 12px;
}

.check-field {
  grid-template-columns: auto 1fr;
  align-items: start;
  padding: 12px;
  border: 1px solid rgba(243, 201, 107, 0.36);
  border-radius: var(--lab-radius);
  background: rgba(243, 201, 107, 0.08);
}

.check-field input {
  width: auto;
  margin-top: 4px;
}

.recent-list {
  display: grid;
  gap: 10px;
}

.recent-run {
  display: grid;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--lab-border);
  border-radius: var(--lab-radius);
  background: var(--lab-surface-soft);
}

.recent-run strong,
.recent-run span {
  display: block;
}

.recent-run span {
  color: var(--lab-muted);
}

.recent-run dl {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.lab-footer {
  justify-content: center;
  padding: 0 0 40px;
}

@media (min-width: 720px) {
  .hero-panel {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
  }

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

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

  .state-layout,
  .field-grid,
  .rng-layout {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .recent-run {
    grid-template-columns: minmax(0, 1fr) minmax(260px, 0.65fr);
    align-items: center;
  }
}

@media (min-width: 1040px) {
  h1 {
    font-size: 3rem;
  }

  .lab-shell {
    padding-top: 32px;
  }
}

@media (max-width: 680px) {
  .lab-nav {
    align-items: flex-start;
    flex-direction: column;
    padding: 12px 0;
  }

  .lab-nav__links a,
  .lab-footer a,
  .button {
    flex: 1 1 auto;
  }

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

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