:root {
  color-scheme: light;
  --black: #000;
  --white: #fff;
  --paper: #f2f2ee;
  --gray: #777;
  --line: #000;
}

[data-theme="dark"] {
  color-scheme: dark;
  --black: #f4f4f4;
  --white: #050505;
  --paper: #101010;
  --gray: #a7a7a7;
  --line: #f4f4f4;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--black);
  font: 14px/1.45 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button { font: inherit; }

.theme-toggle {
  position: relative;
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 2px solid var(--black);
  background: var(--white);
  color: var(--black);
  cursor: pointer;
}

.theme-toggle:hover,
.theme-toggle:focus-visible {
  outline: 0;
  background: var(--black);
  color: var(--white);
}

.connector-button {
  min-height: 34px;
  border: 2px solid var(--black);
  background: var(--black);
  color: var(--white);
  padding: 6px 11px;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
  cursor: pointer;
}

.connector-button:hover,
.connector-button:focus-visible {
  outline: 0;
  background: var(--white);
  color: var(--black);
}

.theme-toggle-icon {
  width: 20px;
  height: 20px;
  border: 2px solid currentColor;
  border-radius: 50%;
  box-shadow: inset -6px -4px 0 0 currentColor;
}

[data-theme="dark"] .theme-toggle-icon {
  border-radius: 0;
  background: currentColor;
  box-shadow: none;
  transform: rotate(45deg) scale(0.82);
}

.shell {
  width: min(1500px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 14px 0 42px;
}

.topbar {
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 10px 12px;
  background: var(--white);
  border: 2px solid var(--black);
  border-bottom: 0;
}

.brand,
.top-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.mark {
  width: 40px;
  height: 40px;
  position: relative;
  background: var(--black);
}

.mark::before,
.mark::after {
  content: "";
  position: absolute;
  top: -8px;
  width: 17px;
  height: 17px;
  background: var(--black);
  transform: rotate(45deg);
}

.mark::before { left: 2px; }
.mark::after { right: 2px; }

.mark span {
  position: absolute;
  inset: 13px 9px auto;
  height: 7px;
  border-left: 5px solid var(--white);
  border-right: 5px solid var(--white);
}

.eyebrow,
.label {
  margin: 0 0 5px;
  color: var(--gray);
  text-transform: uppercase;
  letter-spacing: 0;
  font-size: 11px;
  font-weight: 900;
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(28px, 4vw, 52px);
  line-height: 0.9;
}

h2 {
  font-size: 20px;
  line-height: 1.1;
}

.verdict,
.stamp {
  border: 2px solid var(--black);
  background: var(--white);
  color: var(--black);
  padding: 9px 11px;
  font-weight: 900;
  white-space: nowrap;
}

.verdict {
  background: var(--black);
  color: var(--white);
}

.verdict.fail {
  background: var(--white);
  color: var(--black);
  box-shadow: inset 0 0 0 4px var(--black);
}

.kernel-surface {
  min-height: calc(100vh - 86px);
  display: grid;
  grid-template-columns: minmax(580px, 1fr) minmax(320px, 420px);
  grid-template-rows: minmax(560px, 1fr) auto;
  position: relative;
  overflow: hidden;
  background: var(--white);
  border: 2px solid var(--black);
}

.kernel-grid {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(var(--paper) 1px, transparent 1px),
    linear-gradient(90deg, var(--paper) 1px, transparent 1px);
  background-size: 44px 44px;
  pointer-events: none;
}

.kernel-grid span {
  position: absolute;
  background: var(--black);
}

.kernel-grid span:nth-child(1) {
  left: 8%;
  right: 28%;
  top: 18%;
  height: 2px;
}

.kernel-grid span:nth-child(2) {
  left: 16%;
  right: 40%;
  bottom: 24%;
  height: 2px;
}

.kernel-grid span:nth-child(3) {
  left: 52%;
  top: 11%;
  bottom: 18%;
  width: 2px;
}

.kernel-grid span:nth-child(4) {
  left: 28%;
  top: 16%;
  bottom: 30%;
  width: 2px;
}

.machine-cat {
  position: relative;
  z-index: 1;
  grid-column: 1;
  grid-row: 1;
  align-self: center;
  justify-self: center;
  width: min(660px, 92%);
  height: min(660px, 72vw);
  min-height: 520px;
}

.cat-ear {
  position: absolute;
  top: 34px;
  width: 142px;
  height: 142px;
  background: var(--black);
  transform: rotate(45deg);
}

.cat-ear.ok::after,
.cat-eye.ok::after,
.cat-paw.ok::after {
  background: var(--black);
}

.cat-ear.warn::after,
.cat-eye.warn::after,
.cat-paw.warn::after {
  background: var(--white);
}

.cat-ear::after {
  content: "";
  position: absolute;
  right: 16px;
  bottom: 16px;
  width: 24px;
  height: 24px;
  border: 2px solid var(--white);
  background: var(--black);
}

.cat-ear-left { left: 118px; }
.cat-ear-right { right: 118px; }

.cat-head {
  position: absolute;
  top: 88px;
  left: 50%;
  width: min(470px, 82vw);
  height: 350px;
  transform: translateX(-50%);
  background: var(--white);
  border: 3px solid var(--black);
  border-radius: 50%;
}

.cat-eye {
  position: absolute;
  top: 118px;
  width: 58px;
  height: 58px;
  border: 3px solid var(--black);
  background: var(--black);
}

.cat-eye::after {
  content: "";
  position: absolute;
  inset: 15px;
  border: 2px solid var(--white);
  background: var(--black);
}

.cat-eye-left { left: 128px; }
.cat-eye-right { right: 128px; }

.cat-nose {
  position: absolute;
  left: 50%;
  top: 185px;
  width: 30px;
  height: 30px;
  background: var(--black);
  transform: translateX(-50%) rotate(45deg);
}

.cat-mouth {
  position: absolute;
  left: 50%;
  top: 226px;
  width: 108px;
  height: 52px;
  border: 3px solid var(--black);
  border-top: 0;
  border-radius: 0 0 72px 72px;
  transform: translateX(-50%);
}

.bus {
  position: absolute;
  height: 3px;
  width: 148px;
  background: var(--black);
}

.bus-left { left: -82px; }
.bus-right { right: -82px; }
.bus-a { top: 162px; }
.bus-b { top: 218px; }
.bus-left.bus-a { transform: rotate(8deg); }
.bus-left.bus-b { transform: rotate(-8deg); }
.bus-right.bus-a { transform: rotate(-8deg); }
.bus-right.bus-b { transform: rotate(8deg); }

.cat-body {
  position: absolute;
  left: 50%;
  bottom: 64px;
  width: min(500px, 80vw);
  height: 315px;
  transform: translateX(-50%);
  background: var(--black);
  border: 3px solid var(--black);
  border-radius: 50% 50% 22px 22px;
  display: grid;
  align-content: center;
  justify-items: center;
  padding: 72px 42px 36px;
}

.kernel-window {
  width: min(310px, 100%);
  min-height: 142px;
  display: grid;
  align-content: center;
  justify-items: center;
  border: 3px solid var(--white);
  background: var(--white);
  color: var(--black);
  text-align: center;
}

.kernel-window span,
.kernel-window em {
  color: var(--gray);
  text-transform: uppercase;
  font-size: 11px;
  font-style: normal;
  font-weight: 900;
}

.kernel-window strong {
  margin: 5px 0;
  font-size: clamp(48px, 5.8vw, 86px);
  line-height: 0.86;
}

.kernel-slots {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  width: min(360px, 100%);
  margin-top: 16px;
}

.kernel-slot {
  height: 18px;
  border: 2px solid var(--white);
  background: var(--black);
}

.kernel-slot.ok { background: var(--white); }

.cat-paw {
  position: absolute;
  bottom: 36px;
  width: 144px;
  height: 82px;
  border: 3px solid var(--black);
  background: var(--white);
  border-radius: 50%;
}

.cat-paw::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 44px;
  height: 20px;
  border: 2px solid var(--black);
  transform: translate(-50%, -50%);
}

.cat-paw-left { left: 95px; }
.cat-paw-right { right: 95px; }

.operation-dock {
  position: relative;
  z-index: 2;
  grid-column: 1;
  grid-row: 2;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  border-top: 2px solid var(--black);
  background: var(--white);
}

.op-button {
  position: relative;
  min-height: 88px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-right: 2px solid var(--black);
  background: var(--white);
  color: var(--black);
  font-weight: 950;
  text-transform: uppercase;
  cursor: pointer;
}

.op-button::before {
  content: "";
  position: absolute;
  top: 10px;
  right: 10px;
  width: 12px;
  height: 12px;
  border: 2px solid var(--black);
  background: var(--white);
}

.op-button.ready::before {
  background: var(--black);
}

.op-button:last-child { border-right: 0; }

.op-button span {
  color: var(--gray);
  font-size: 11px;
  font-weight: 900;
}

.op-button:hover,
.op-button:focus-visible,
.op-button.active {
  outline: 0;
  background: var(--black);
  color: var(--white);
}

.op-button:hover::before,
.op-button:focus-visible::before,
.op-button.active::before {
  border-color: var(--white);
}

.op-button.ready:hover::before,
.op-button.ready:focus-visible::before,
.op-button.ready.active::before {
  background: var(--white);
}

.op-button:hover span,
.op-button:focus-visible span,
.op-button.active span {
  color: var(--white);
}

.system-spine {
  position: relative;
  z-index: 2;
  grid-column: 2;
  grid-row: 1 / span 2;
  display: grid;
  grid-template-rows: 1fr auto 54px;
  border-left: 2px solid var(--black);
  background: var(--white);
}

.state-stack {
  padding: clamp(22px, 3.4vw, 44px);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.state-stack h2 {
  max-width: 360px;
  font-size: clamp(44px, 5.8vw, 86px);
  line-height: 0.86;
}

.state-stack p:not(.label) {
  max-width: 340px;
  margin: 24px 0 0;
  color: var(--gray);
  font-size: 15px;
}

.spine-ledger {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-top: 2px solid var(--black);
}

.readout-item {
  min-height: 96px;
  padding: 13px;
  border-right: 2px solid var(--black);
  border-bottom: 2px solid var(--black);
}

.readout-item:nth-child(even) { border-right: 0; }
.readout-item:nth-last-child(-n + 2) { border-bottom: 0; }

.readout-item span {
  display: block;
  color: var(--gray);
  text-transform: uppercase;
  font-size: 11px;
  font-weight: 900;
}

.readout-item strong {
  display: block;
  margin-top: 10px;
  font-size: 29px;
  line-height: 0.95;
}

.action-readout {
  display: flex;
  align-items: center;
  border-top: 2px solid var(--black);
  padding: 0 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  overflow-wrap: anywhere;
}

.trust-constellation,
.operator-plain,
.continuity-pulse,
.panel,
.status,
.pulse-item,
.gate,
.row,
.phase,
.chip,
.chain-item {
  border: 2px solid var(--black);
  background: var(--white);
}

.trust-constellation {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
  margin-top: 14px;
}

.constellation-line { display: none; }

.gate {
  min-height: 128px;
  border-right: 0;
  padding: 15px;
}

.gate:last-child { border-right: 2px solid var(--black); }

.gate span,
.pulse-item span,
.status .label,
.chain-item .k {
  display: block;
  color: var(--gray);
  text-transform: uppercase;
  font-size: 11px;
  font-weight: 900;
}

.gate strong {
  display: block;
  margin-top: 16px;
  font-size: 27px;
  line-height: 1;
}

.gate p {
  margin: 9px 0 0;
  color: var(--gray);
}

.operator-plain,
.continuity-pulse {
  display: grid;
  grid-template-columns: minmax(250px, 0.34fr) minmax(0, 0.66fr);
  gap: 18px;
  align-items: center;
  padding: 18px;
  margin-top: 14px;
}

.operator-plain h2,
.continuity-pulse h2 {
  font-size: clamp(24px, 2.5vw, 40px);
}

.operator-plain p:not(.label) {
  margin: 0;
  font-size: 16px;
}

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

.pulse-item {
  min-height: 82px;
  padding: 12px;
  position: relative;
}

.pulse-item::after {
  content: "";
  position: absolute;
  right: 12px;
  top: 12px;
  width: 16px;
  height: 16px;
  background: var(--black);
  border-radius: 50%;
}

.pulse-item.warn::after {
  background: var(--white);
  border: 2px solid var(--black);
}

.pulse-item strong {
  display: block;
  margin-top: 24px;
  font-size: 16px;
  line-height: 1.15;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 8px;
  margin-top: 14px;
}

.status {
  min-height: 82px;
  padding: 12px;
  position: relative;
}

.status::after {
  content: "";
  position: absolute;
  left: 12px;
  bottom: 12px;
  width: 28px;
  height: 12px;
  background: var(--black);
}

.status.fail::after {
  background: var(--white);
  border: 2px solid var(--black);
}

.status strong {
  display: block;
  margin-top: 8px;
  font-size: 18px;
}

.fleet-connector {
  display: grid;
  gap: 12px;
}

.connector-state {
  min-height: 58px;
  display: grid;
  grid-template-columns: 22px minmax(0, auto) 1fr;
  align-items: center;
  gap: 12px;
  border: 2px solid var(--black);
  padding: 12px;
}

.connector-light {
  width: 18px;
  height: 18px;
  border: 2px solid var(--black);
  background: var(--white);
}

.connector-state.connected .connector-light {
  background: var(--black);
}

.connector-state strong {
  font-size: 18px;
  line-height: 1;
}

.connector-state em {
  justify-self: end;
  color: var(--gray);
  font-style: normal;
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

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

.fleet-metric,
.fleet-node {
  border: 2px solid var(--black);
  background: var(--white);
}

.fleet-metric {
  min-height: 82px;
  padding: 12px;
}

.fleet-metric span,
.fleet-node span {
  display: block;
  color: var(--gray);
  text-transform: uppercase;
  font-size: 11px;
  font-weight: 900;
}

.fleet-metric strong {
  display: block;
  margin-top: 8px;
  font-size: 24px;
  line-height: 1;
}

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

.fleet-node {
  min-height: 112px;
  padding: 12px;
}

.fleet-node strong {
  display: block;
  margin: 10px 0 8px;
  font-size: 20px;
  line-height: 1;
  overflow-wrap: anywhere;
}

.fleet-node .bars {
  display: grid;
  gap: 6px;
  margin-top: 10px;
}

.fleet-node .bar {
  height: 10px;
  border: 2px solid var(--black);
  background:
    linear-gradient(90deg, var(--black) var(--value, 0%), transparent var(--value, 0%));
}

.panel {
  margin-top: 12px;
  padding: 16px;
}

.section-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border: 2px solid var(--black);
  padding: 5px 9px;
  background: var(--black);
  color: var(--white);
  font-size: 12px;
  font-weight: 850;
  white-space: nowrap;
}

.proof-grid,
.evidence-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.18fr) minmax(360px, 0.82fr);
  gap: 12px;
}

.chain,
.list {
  display: grid;
  gap: 8px;
}

.chain-item {
  display: grid;
  grid-template-columns: 152px minmax(0, 1fr) 94px;
  align-items: center;
  gap: 12px;
  padding: 12px;
}

.chain-item .v,
dd,
.row code,
.chain-item code,
dd code {
  overflow-wrap: anywhere;
}

.chain-item .state {
  text-align: right;
  font-weight: 900;
}

.chain-item details { margin-top: 6px; }

.chain-item summary,
dd summary {
  color: var(--gray);
  cursor: pointer;
  font-size: 12px;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

dl {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 8px 14px;
  margin: 0;
}

dt {
  color: var(--gray);
  font-weight: 850;
}

dd { margin: 0; }

.row { padding: 10px; }

.row strong {
  display: block;
  overflow-wrap: anywhere;
}

.row code {
  display: block;
  margin-top: 6px;
}

.meta {
  color: var(--gray);
  font-size: 12px;
}

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

.phase {
  min-height: 98px;
  padding: 12px;
}

.phase::before {
  content: "";
  display: block;
  height: 12px;
  width: 42px;
  margin-bottom: 12px;
  background: var(--black);
}

.phase.next::before,
.phase.later::before {
  background: var(--white);
  border: 2px solid var(--black);
}

.phase strong {
  display: block;
  margin-bottom: 8px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  padding: 9px 11px;
  font-weight: 750;
}

@media (max-width: 1180px) {
  .kernel-surface {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(520px, auto) auto auto;
  }

  .machine-cat {
    grid-column: 1;
    grid-row: 1;
  }

  .operation-dock {
    grid-column: 1;
    grid-row: 2;
  }

  .system-spine {
    grid-column: 1;
    grid-row: 3;
    border-left: 0;
    border-top: 2px solid var(--black);
    grid-template-rows: auto auto 54px;
  }

  .state-stack h2,
  .state-stack p:not(.label) {
    max-width: none;
  }

  .trust-constellation,
  .pulse-stream {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .operator-plain,
  .continuity-pulse,
  .proof-grid,
  .evidence-grid {
    grid-template-columns: 1fr;
  }

  .status-grid,
  .timeline,
  .fleet-metrics,
  .fleet-nodes {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .shell {
    width: min(100vw - 18px, 720px);
    padding-top: 9px;
  }

  .topbar,
  .top-actions {
    height: auto;
    align-items: stretch;
    flex-direction: column;
  }

  .brand { align-items: center; }

  .stamp,
  .verdict {
    width: 100%;
    white-space: normal;
  }

  .machine-cat {
    width: 100%;
    height: 520px;
    min-height: 0;
  }

  .cat-ear {
    width: 104px;
    height: 104px;
  }

  .cat-ear-left { left: 72px; }
  .cat-ear-right { right: 72px; }

  .cat-head {
    top: 76px;
    width: min(390px, 82vw);
    height: 292px;
  }

  .cat-eye {
    top: 98px;
    width: 46px;
    height: 46px;
  }

  .cat-eye-left { left: 94px; }
  .cat-eye-right { right: 94px; }

  .cat-nose { top: 156px; }
  .cat-mouth { top: 194px; }
  .bus { width: 96px; }
  .bus-left { left: -54px; }
  .bus-right { right: -54px; }

  .cat-body {
    height: 250px;
    bottom: 48px;
    padding: 56px 34px 30px;
  }

  .cat-paw {
    width: 108px;
    height: 66px;
    bottom: 27px;
  }

  .cat-paw-left { left: 66px; }
  .cat-paw-right { right: 66px; }

  .operation-dock,
  .spine-ledger,
  .readout,
  .status-grid,
  .timeline,
  .trust-constellation,
  .pulse-stream,
  .fleet-metrics,
  .fleet-nodes {
    grid-template-columns: 1fr 1fr;
  }

  .connector-state {
    grid-template-columns: 22px 1fr;
  }

  .connector-state em {
    grid-column: 1 / -1;
    justify-self: start;
  }

  .chain-item {
    grid-template-columns: 1fr;
  }

  .chain-item .state { text-align: left; }
}

@media (max-width: 470px) {
  .operation-dock,
  .spine-ledger,
  .readout,
  .status-grid,
  .timeline,
  .trust-constellation,
  .pulse-stream,
  .fleet-metrics,
  .fleet-nodes {
    grid-template-columns: 1fr;
  }

  .cat-ear-left { left: 48px; }
  .cat-ear-right { right: 48px; }
  .cat-paw-left { left: 40px; }
  .cat-paw-right { right: 40px; }
}
