:root {
  --ink: #18242d;
  --muted: #68757d;
  --line: #dce3e6;
  --soft: #f6f8f9;
  --orange: #de6b32;
  --orange-soft: #fff0e7;
  --green: #277457;
  --green-soft: #e4f2eb;
  --amber: #9a6b24;
  --amber-soft: #f8edcf;
  --red: #ad3e3e;
  --red-soft: #f9e3e3;
  --issue: #e8e2f7;
  --issue-ink: #5f4c99;
  --execute: #d9eee8;
  --execute-ink: #236e5c;
  --writeback: #f4e6cc;
  --writeback-ink: #8a6025;
  --blocked: #f5d5d5;
  --blocked-ink: #9a3434;
  --cell: 48px;
  --label-width: max(300px, calc(100% - 768px));
  --row-height: 48px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  background: #fff;
  color: var(--ink);
  font-family: Inter, "Noto Sans SC", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button {
  font: inherit;
}

.page-shell {
  width: min(1320px, calc(100% - 48px));
  margin: 0 auto;
  padding: 12px 0;
}

.page-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 28px;
  margin-bottom: 24px;
}

.eyebrow,
.panel-kicker,
.group-label {
  margin: 0;
  color: var(--orange);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.12em;
}

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

h1 {
  margin: 4px 0 4px;
  font-family: Georgia, "Noto Serif SC", serif;
  font-size: 42px;
  line-height: 1.08;
  letter-spacing: -0.035em;
}

h2 {
  margin: 4px 0 0;
  font-family: Georgia, "Noto Serif SC", serif;
  font-size: 20px;
  line-height: 1.2;
}

.lede {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 15px;
}

.stage-switch {
  display: inline-flex;
  flex: 0 0 auto;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--soft);
}

.stage-button,
.control-button {
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: #43515a;
  cursor: pointer;
}

.stage-button {
  padding: 8px 13px;
  font-size: 13px;
  font-weight: 650;
}

.stage-button.is-active {
  background: white;
  color: var(--ink);
  box-shadow: 0 1px 4px rgb(22 34 43 / 13%);
}

.stage-button:focus-visible,
.control-button:focus-visible {
  outline: 3px solid rgb(45 111 139 / 22%);
  outline-offset: 2px;
}

.status-board {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(270px, 0.8fr);
  gap: 14px;
  margin-bottom: 16px;
}

.hardware-overview,
.verdict-card {
  min-height: 220px;
  padding: 18px 20px;
  border: 1px solid var(--line);
  background: white;
}

.hardware-overview {
  border-top: 3px solid #2d718c;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 17px;
}

.mode-description {
  max-width: 470px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 13px;
  text-align: right;
}

.hardware-groups {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 250px;
  gap: 18px;
}

.group-label {
  margin-bottom: 8px;
  color: #7a878e;
}

.register-bank {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(54px, 1fr));
  gap: 7px;
}

.state-groups {
  display: grid;
  gap: 14px;
}

.state-group {
  min-width: 0;
}

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

.state-group-heading .group-label {
  margin-bottom: 0;
}

.state-group-heading span {
  color: var(--muted);
  font-size: 10px;
  text-align: right;
}

.state-group-content {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(64px, 1fr));
  gap: 7px;
}

.state-group-content .register-bank {
  grid-column: 1 / -1;
}

.score-register-card {
  min-width: 82px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fafbfb;
}

.score-register-name {
  display: block;
  margin-bottom: 5px;
  color: var(--ink);
  font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 12px;
  text-align: center;
}

.score-register-values {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
}

.score-cell {
  position: relative;
  display: grid;
  min-height: 31px;
  grid-template-columns: auto auto;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: 1px solid #b8d3c5;
  border-radius: 3px;
  background: var(--green-soft);
  color: #225f49;
  font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 11px;
}

.score-cell b,
.score-cell em {
  font-style: normal;
  font-weight: 750;
}

.score-cell.active {
  border-color: #ddc68b;
  background: var(--amber-soft);
  color: #7b551e;
}

.score-cell.checked {
  outline: 2px solid var(--orange);
  outline-offset: 1px;
  z-index: 1;
}

.unit-bank {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(76px, 1fr));
  gap: 8px;
}

.hardware-tile {
  display: grid;
  min-height: 48px;
  border: 1px solid #b8d3c5;
  border-radius: 4px;
  background: var(--green-soft);
  color: #225f49;
  font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 13px;
  font-weight: 750;
  place-items: center;
}

.hardware-tile.active {
  border-color: #ddc68b;
  background: var(--amber-soft);
  color: #7b551e;
}

.hardware-tile {
  position: relative;
}

.hardware-tile.checked {
  outline: 2px solid var(--orange);
  outline-offset: 2px;
}

.hardware-tile.checked::after {
  position: absolute;
  top: -7px;
  right: -7px;
  display: grid;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--orange);
  color: white;
  content: "·";
  font-family: system-ui, sans-serif;
  font-size: 15px;
  line-height: 1;
  place-items: center;
}

.state-legend {
  display: flex;
  gap: 16px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 11px;
}

.state-legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.state-dot {
  width: 9px;
  height: 9px;
  border: 1px solid;
  border-radius: 2px;
}

.state-dot.available {
  border-color: #8fbea6;
  background: var(--green-soft);
}

.state-dot.active {
  border-color: #cdaa5a;
  background: var(--amber-soft);
}

.state-ring {
  width: 10px;
  height: 10px;
  border: 2px solid;
  border-radius: 2px;
  background: transparent;
}

.state-ring.checked {
  border-color: var(--orange);
}

.verdict-card {
  position: relative;
  overflow: hidden;
  border-top: 3px solid var(--green);
}

.verdict-card.blocked {
  border-color: #df9999;
  border-top-color: var(--red);
  background: #fffafa;
}

.verdict-cycle {
  position: absolute;
  top: 12px;
  right: 16px;
  color: #bac3c8;
  font-family: Georgia, serif;
  font-size: 20px;
}

.verdict-cycle span {
  color: var(--ink);
  font-size: 32px;
}

.verdict-card h2 {
  margin-top: 18px;
  font-size: 27px;
}

.verdict-card.blocked h2 {
  color: var(--red);
}

#verdict-reason {
  min-height: 44px;
  margin: 10px 0 13px;
  color: #4c5a62;
  font-size: 14px;
}

.check-summary {
  margin: 0;
  padding: 8px 10px;
  border-left: 3px solid var(--orange);
  background: var(--orange-soft);
  color: #81502f;
  font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 12px;
}

.verdict-card.blocked .check-summary {
  border-left-color: var(--red);
  background: var(--red-soft);
  color: #8b3030;
}

.replay-figure {
  border: 1px solid var(--line);
  background: white;
}

.replay-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--line);
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 13px;
  color: var(--muted);
  font-size: 11px;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.legend-swatch {
  width: 11px;
  height: 11px;
  border: 1px solid;
}

.legend-swatch.issue,
.pipeline-cell.issue {
  border-color: #9e8ed1;
  background: var(--issue);
  color: var(--issue-ink);
}

.legend-swatch.execute,
.pipeline-cell.execute {
  border-color: #89bcae;
  background: var(--execute);
  color: var(--execute-ink);
}

.legend-swatch.writeback,
.pipeline-cell.writeback {
  border-color: #d0ad6e;
  background: var(--writeback);
  color: var(--writeback-ink);
}

.legend-swatch.blocked,
.pipeline-cell.blocked {
  border-color: #d38282;
  background: var(--blocked);
  color: var(--blocked-ink);
}

.legend-swatch.nop,
.pipeline-cell.nop {
  border-color: #bdc5c9;
  background: #edf0f2;
  color: #657179;
}

.pipeline-cell.issue,
.pipeline-cell.execute,
.pipeline-cell.writeback,
.pipeline-cell.blocked,
.pipeline-cell.nop {
  border-color: var(--line);
}

.pipeline-scroller {
  height: calc(32px + 7 * var(--row-height));
  overflow: scroll;
  scrollbar-gutter: stable;
  scrollbar-color: #9aa7ad #edf1f2;
  scrollbar-width: auto;
  overscroll-behavior: contain;
}

.pipeline-scroller::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

.pipeline-scroller::-webkit-scrollbar-track {
  background: #edf1f2;
}

.pipeline-scroller::-webkit-scrollbar-thumb {
  border: 2px solid #edf1f2;
  border-radius: 6px;
  background: #9aa7ad;
}

.pipeline-scroller::-webkit-scrollbar-corner {
  background: #edf1f2;
}

.pipeline {
  display: grid;
  grid-template-columns: minmax(var(--label-width), 1.55fr) repeat(7, minmax(var(--cell), 1fr));
  grid-template-rows: 32px;
  grid-auto-rows: var(--row-height);
  width: 100%;
  min-width: calc(var(--label-width) + 8 * var(--cell));
  font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 13px;
}

.pipeline-header,
.instruction-label,
.pipeline-cell {
  min-height: var(--row-height);
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.pipeline-header {
  position: sticky;
  top: 0;
  z-index: 2;
  display: grid;
  min-height: 32px;
  background: #fafbfb;
  color: #7a878e;
  font-size: 11px;
  place-items: center;
}

.pipeline-header.label-header {
  left: 0;
  z-index: 4;
  justify-items: start;
  padding-left: 14px;
}

.pipeline-header.current-cycle {
  color: var(--ink);
  box-shadow: inset 0 -3px 0 var(--orange);
  font-weight: 750;
}

.instruction-label {
  position: sticky;
  left: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 4px 10px;
  background: white;
  color: #33414a;
}

.instruction-label.row-alt {
  background: #fafbfb;
}

.instruction-label strong {
  overflow: hidden;
  font-size: 12px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.instruction-label.current-candidate {
  box-shadow: inset 4px 0 0 var(--orange);
}

.instruction-label.blocked-candidate {
  background: #fff4f4;
  color: #7d2e2e;
  box-shadow: inset 4px 0 0 var(--red);
}

.instruction-label.inspectable {
  cursor: crosshair;
}

.instruction-label.inspectable:hover {
  background: var(--orange-soft);
  box-shadow: inset 4px 0 0 var(--orange);
}

.instruction-label.inspectable.blocked-candidate:hover {
  background: #fff0f0;
  box-shadow: inset 4px 0 0 var(--red);
}

.pipeline-cell {
  position: relative;
  display: grid;
  border-color: var(--line);
  background: white;
  color: #44515a;
  font-size: 12px;
  font-weight: 750;
  place-items: center;
}

.pipeline-cell.row-alt {
  background: #fafbfb;
}

.pipeline-cell.current-cycle {
  box-shadow: none;
}

.pipeline-cell.blocked {
  animation: cell-flash 380ms ease-out;
}

@keyframes cell-flash {
  from { background: #efbcbc; }
  to { background: var(--blocked); }
}

.pipeline-cell.future {
  color: transparent;
  background: white;
  opacity: 1;
}

.pipeline-cell.future.row-alt {
  background: #fafbfb;
}

.replay-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px 7px;
  border-top: 1px solid var(--line);
  background: white;
}

.control-button {
  padding: 7px 11px;
  border: 1px solid #cfd8dc;
  color: #46545d;
}

.control-button:hover:not(:disabled) {
  border-color: #92a8b2;
  background: var(--soft);
}

.control-button.primary {
  border-color: #4d7f94;
  background: #356b82;
  color: white;
}

.control-button.primary:hover:not(:disabled) {
  border-color: #3d7187;
  background: #2d6076;
}

.control-button:disabled {
  opacity: 0.38;
  cursor: default;
}

.slider-row {
  display: grid;
  grid-template-columns: 20px minmax(200px, 440px) 20px;
  align-items: center;
  gap: 8px;
  padding: 0 16px 15px;
  color: #89959c;
  font-size: 10px;
}

d-slider {
  width: 100%;
}

@media (max-width: 900px) {
  .status-board {
    grid-template-columns: 1fr;
  }

  .hardware-groups {
    grid-template-columns: 1fr;
  }

  .mode-description {
    max-width: 52%;
  }
}
