.pipeline-main {
  max-width: 72rem;
}

.pipeline-header {
  margin-bottom: 2rem;
  padding-top: 1rem;
}

.pipeline-header .site-tagline {
  max-width: 38rem;
  margin-inline: auto;
}

.stage-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.8rem;
  margin-bottom: 1rem;
}

.stage-card,
.control-panel,
.timeline-panel,
.status-panel,
.notes-panel {
  border: 1px solid var(--wa-gray-light);
  border-radius: 8px;
  background: var(--wa-white);
}

.stage-card {
  display: grid;
  gap: 0.45rem;
  min-height: 11rem;
  padding: 1rem;
}

.stage-card-head,
.panel-title-row,
.toggle-row,
.toggle-label {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.stage-card-head {
  justify-content: space-between;
}

.stage-token,
.inline-token,
.stage-cell {
  display: inline-grid;
  place-items: center;
  border-radius: 6px;
  font-weight: 700;
  letter-spacing: 0;
}

.stage-token {
  width: 2.25rem;
  height: 2.25rem;
  color: var(--wa-white);
}

.inline-token {
  min-width: 1.55rem;
  min-height: 1.55rem;
  padding: 0 0.35rem;
  background: var(--wa-orange-pale);
  color: var(--wa-orange-dark);
}

.stage-card h2 {
  margin: 0;
  font-size: 1rem;
  letter-spacing: 0;
}

.stage-card p,
.notes-panel p {
  margin: 0;
  color: var(--wa-ink-light);
  font-size: 0.9rem;
}

.stage-fetch,
.cell-fetch {
  background: #2b7a9e;
}

.stage-decode,
.cell-decode {
  background: #4a7c59;
}

.stage-execute,
.cell-execute {
  background: #cc7a00;
}

.stage-write,
.cell-write {
  background: #6b7280;
}

.control-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 0.85rem;
  align-items: center;
  margin-bottom: 1rem;
  padding: 1rem;
}

.mode-group,
.step-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.mode-group {
  justify-content: flex-start;
  justify-self: start;
}

.step-controls {
  justify-content: flex-end;
  justify-self: end;
}

.mode-button {
  min-height: 2.4rem;
  padding: 0.45rem 0.9rem;
  border: 1px solid var(--wa-gray-light);
  border-radius: 6px;
  background: var(--wa-white);
  color: var(--wa-ink);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
}

.mode-button.is-active {
  border-color: var(--wa-orange);
  background: var(--wa-orange-pale);
  color: var(--wa-orange-dark);
}

.toggle-row {
  min-height: 2.4rem;
  justify-content: center;
  justify-self: end;
  min-width: 13rem;
  visibility: visible;
  color: var(--wa-ink-light);
  font-size: 0.9rem;
  font-weight: 700;
}

.toggle-row.hidden {
  display: flex !important;
  visibility: hidden;
  pointer-events: none;
}

.toggle-label input {
  width: 1rem;
  height: 1rem;
  accent-color: var(--wa-orange);
}

.pipeline-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 18rem;
  gap: 1rem;
  align-items: start;
  margin-bottom: 1rem;
}

.timeline-panel,
.status-panel,
.notes-panel {
  padding: 1rem;
}

.panel-title-row {
  justify-content: space-between;
  margin-bottom: 0.9rem;
}

.timeline-wrap {
  overflow-x: auto;
  padding-bottom: 0.2rem;
}

.timeline-grid {
  display: grid;
  min-width: 48rem;
  border: 1px solid var(--wa-gray-light);
  border-radius: 8px;
  overflow: hidden;
  background: var(--wa-bg);
}

.timeline-cell {
  min-height: 3rem;
  padding: 0.45rem;
  border-right: 1px solid var(--wa-gray-light);
  border-bottom: 1px solid var(--wa-gray-light);
  background: var(--wa-white);
  font-size: 0.82rem;
}

.timeline-head {
  display: grid;
  place-items: center;
  min-height: 2.4rem;
  background: var(--wa-orange-pale);
  color: var(--wa-orange-dark);
  font-weight: 700;
}

.instruction-cell {
  display: grid;
  align-content: center;
  gap: 0.1rem;
  min-width: 10rem;
  background: #fffdf8;
}

.instruction-name {
  color: var(--wa-ink);
  font-weight: 700;
}

.instruction-code {
  color: var(--wa-ink-light);
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.78rem;
  line-height: 1.35;
}

.stage-cell {
  position: relative;
  width: 2.1rem;
  height: 2.1rem;
  margin: 0 auto;
  color: var(--wa-white);
}

.stage-cell.is-current {
  outline: 3px solid var(--wa-orange-light);
  outline-offset: 2px;
}

.stage-cell.is-future {
  opacity: 0.25;
}

.stage-cell.is-forwarded::after {
  content: "→";
  position: absolute;
  transform: translate(1.45rem, -0.95rem);
  color: var(--wa-orange-dark);
  font-size: 0.9rem;
}

.cell-stall,
.cell-flush {
  color: var(--wa-ink);
}

.cell-stall {
  background: #fff3e0;
  border: 1px dashed var(--wa-orange);
}

.cell-flush {
  background: #e5e7eb;
  border: 1px dashed var(--wa-gray);
  color: var(--wa-gray);
}

.clock-readout {
  display: grid;
  gap: 0.1rem;
  margin-bottom: 1rem;
}

.clock-readout span {
  color: var(--wa-gray);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.clock-readout strong {
  color: var(--wa-orange-dark);
  font-size: 2.6rem;
  line-height: 1;
}

.status-text {
  min-height: 7.2rem;
  margin: 0 0 1rem;
  color: var(--wa-ink-light);
  font-size: 0.92rem;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.5rem;
}

.metrics div {
  padding: 0.65rem 0.5rem;
  border: 1px solid var(--wa-gray-light);
  border-radius: 6px;
  background: var(--wa-bg);
  text-align: center;
}

.metrics dt {
  color: var(--wa-gray);
  font-size: 0.72rem;
  font-weight: 700;
}

.metrics dd {
  margin: 0;
  color: var(--wa-ink);
  font-size: 1.2rem;
  font-weight: 700;
}

.notes-panel {
  display: grid;
  gap: 0.7rem;
}

.info-modal {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.info-modal.hidden {
  display: none;
}

.info-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(26, 26, 26, 0.42);
}

.info-modal-panel {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(100%, 46rem);
  max-height: min(88vh, 42rem);
  overflow: hidden;
  border: 1px solid var(--wa-gray-light);
  border-radius: 8px;
  background: var(--wa-white);
  box-shadow: 0 20px 44px rgba(26, 26, 26, 0.18);
}

.info-modal-header {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 1.35rem 3.8rem 1rem 1.35rem;
  border-bottom: 1px solid var(--wa-gray-light);
  background: var(--wa-white);
}

.info-modal-kicker {
  margin: 0 0 0.35rem;
  color: var(--wa-orange-dark);
  font-size: 0.78rem;
  font-weight: 700;
}

.info-modal-panel h2 {
  margin: 0;
  font-size: 1.2rem;
}

.info-modal-body {
  display: grid;
  gap: 0.85rem;
  min-height: 0;
  overflow: auto;
  padding: 1.2rem 1.35rem 1.35rem;
  color: var(--wa-ink-light);
  font-size: 0.92rem;
}

.info-modal-body p,
.info-modal-body ul {
  margin: 0;
}

.info-modal-body ul {
  padding-left: 1.2rem;
}

.info-modal-body code {
  padding: 0.08rem 0.25rem;
  border-radius: 4px;
  background: var(--wa-bg);
  color: var(--wa-ink);
  font-family: Consolas, "Courier New", monospace;
}

@media (max-width: 980px) {
  .stage-strip,
  .pipeline-layout,
  .control-panel {
    grid-template-columns: 1fr;
  }

  .control-panel {
    align-items: stretch;
  }

  .toggle-row {
    justify-content: flex-start;
  }

  .toggle-row.hidden {
    display: none !important;
  }

  .step-controls {
    justify-content: flex-start;
  }

  .status-text {
    min-height: auto;
  }
}

@media (max-width: 560px) {
  .pipeline-main {
    padding-inline: 0.9rem;
  }

  .stage-strip {
    gap: 0.65rem;
  }

  .stage-card,
  .control-panel,
  .timeline-panel,
  .status-panel,
  .notes-panel {
    padding: 0.85rem;
  }
}
