/* Pipeline player: conveyor of stages, the current stage's artifact, rules and run log. */
.player { margin-top: 48px; background: var(--panel); border-radius: 14px; box-shadow: 0 40px 80px -50px rgba(16, 35, 47, 0.6); overflow: hidden; }

.p-bar { background: var(--deep); color: var(--deep-ink); padding: 16px 24px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.p-title { flex: 1 1 280px; min-width: 0; }
.p-title strong { display: block; color: #fff; font-size: 16px; }
.p-title span { font-size: 13.5px; color: var(--deep-muted); }
.p-sim { font-size: 12.5px; font-weight: 700; color: var(--deep); background: var(--deep-ink); border-radius: 999px; padding: 3px 10px; }
.p-controls { display: flex; gap: 8px; }
.p-controls button {
  font: 600 15px var(--sans); color: #fff; background: var(--deep-on); border: 1px solid #2f4d61;
  border-radius: 8px; min-height: 44px; padding: 0 14px; cursor: pointer; display: inline-flex; align-items: center; gap: 8px;
}
.p-controls button:hover { background: #28475b; }
.p-controls button:disabled { opacity: 0.45; cursor: default; }
.p-controls .primary { background: var(--teal); border-color: var(--teal); }
.p-controls svg { width: 16px; height: 16px; }
.p-progress { height: 4px; background: var(--deep-on); }
.p-progress div { height: 100%; width: 0; background: var(--flag); transition: width 400ms ease; }

/* Conveyor */
.conveyor { position: relative; padding: 26px 24px 18px; border-bottom: 1px solid var(--line); background: var(--side); }
.conveyor ol { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); position: relative; }
.conveyor .track { position: absolute; left: 0; right: 0; top: 51px; height: 3px; background: var(--line); }
.conveyor .track-fill { position: absolute; left: 0; top: 51px; height: 3px; background: var(--teal); width: 0; transition: width 700ms cubic-bezier(.5, 0, .2, 1); }
.conveyor .packet {
  position: absolute; top: 44px; width: 17px; height: 17px; margin-left: -8.5px; border-radius: 50%;
  background: var(--flag); box-shadow: 0 0 0 5px rgba(242, 140, 56, 0.25); left: 0; opacity: 0;
  transition: left 700ms cubic-bezier(.5, 0, .2, 1), opacity 300ms;
}
.conveyor li { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; position: relative; z-index: 1; }
.node {
  width: 52px; height: 52px; border-radius: 50%; background: var(--panel); border: 2px solid var(--line);
  display: flex; align-items: center; justify-content: center; color: var(--muted); transition: border-color 300ms, background 300ms, color 300ms, transform 300ms;
}
.node svg { width: 24px; height: 24px; }
.conveyor li span { font-size: 14px; font-weight: 600; color: var(--muted); }
.conveyor li[data-s="run"] .node { border-color: var(--flag); color: var(--ink); transform: scale(1.08); }
.conveyor li[data-s="run"] span { color: var(--ink); }
.conveyor li[data-s="done"] .node { border-color: var(--teal); background: var(--teal); color: #fff; }
.conveyor li[data-s="done"] span { color: var(--ink); }
.conveyor li[data-s="halt"] .node { border-color: var(--bad); background: var(--bad); color: #fff; }

/* Body: artifact + side */
.p-body { display: grid; grid-template-columns: minmax(0, 1fr) 340px; min-height: 560px; }
.stage { padding: 26px 32px 32px; min-width: 0; }
.stage-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.stage-head h3 { margin: 0; font-size: 22px; letter-spacing: -0.01em; }
.stage-head p { margin: 0; font-size: 14px; color: var(--muted); }
.side { background: var(--side); border-left: 1px solid var(--line); padding: 24px 22px; display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.side h4 { margin: 0 0 10px; font-size: 14px; }

.rules { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.rules li { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; display: grid; grid-template-columns: 22px 1fr; gap: 2px 10px; transition: border-color 300ms, background 300ms; }
.rules .dot { grid-row: 1 / span 2; width: 18px; height: 18px; margin-top: 2px; border-radius: 50%; border: 2px solid var(--line); display: flex; align-items: center; justify-content: center; }
.rules .dot svg { width: 12px; height: 12px; }
.rules b { font-size: 14.5px; font-weight: 600; line-height: 1.3; }
.rules small { font-size: 13px; color: var(--muted); line-height: 1.35; }
.rules li[data-s="run"] { border-color: var(--flag); }
.rules li[data-s="run"] .dot { border-color: var(--flag); border-top-color: transparent; animation: spin 900ms linear infinite; }
.rules li[data-s="pass"] .dot { background: var(--ok); border-color: var(--ok); color: #fff; }
.rules li[data-s="fail"] { border-color: var(--bad); background: var(--bad-bg); }
.rules li[data-s="fail"] .dot { background: var(--bad); border-color: var(--bad); color: #fff; }
.rules li[data-s="flag"] { border-color: var(--flag); background: var(--flag-bg); }
.rules li[data-s="flag"] .dot { background: var(--flag); border-color: var(--flag); color: #10232f; }
.rules li[data-s="wait"] .dot { border-color: var(--teal); border-style: dashed; }
@keyframes spin { to { transform: rotate(360deg); } }

.log { font-family: var(--mono); font-size: 12.5px; line-height: 1.55; background: var(--deep); color: var(--deep-ink); border-radius: 10px; padding: 12px 14px; height: 196px; overflow-y: auto; margin: 0; list-style: none; }
.log li { white-space: pre-wrap; word-break: break-word; }
.log .t { color: var(--deep-muted); }
.log .warn { color: #ffb37a; }
.log .bad { color: #ff9a90; }
.log .good { color: #7fd6b0; }

/* Artifacts */
.enter { animation: enter 420ms cubic-bezier(.2, .7, .2, 1) both; }
@keyframes enter { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.rows { display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 0; list-style: none; }
.row { border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; display: grid; grid-template-columns: 84px minmax(0, 1fr) auto; gap: 4px 12px; align-items: baseline; background: var(--panel); }
.row .k { font-size: 13px; font-weight: 700; color: var(--teal); }
.row .t { font-size: 15.5px; }
.row .n { grid-column: 2 / -1; font-size: 13.5px; color: var(--muted); }
.row .n b { font-weight: 600; }
.chip { font-size: 12px; font-weight: 700; border-radius: 6px; padding: 2px 8px; white-space: nowrap; border: 1px solid currentColor; }
.c-done { color: var(--ok); } .c-prog { color: var(--teal); } .c-wait { color: #b05a12; } .c-scope { color: #8a4bb8; } .c-int { color: var(--muted); } .c-bad { color: var(--bad); }
.stamp { display: inline-block; font-size: 12px; font-weight: 800; color: #fff; background: var(--bad); border-radius: 4px; padding: 2px 8px; transform: rotate(-2deg); }
.vault { margin-top: 14px; border: 2px dashed var(--line); border-radius: 10px; padding: 12px 14px; }
.vault h5 { margin: 0 0 8px; font-size: 13.5px; display: flex; gap: 8px; align-items: center; }
.vault h5 svg { width: 16px; height: 16px; }
.vault li { font-family: var(--mono); font-size: 12.5px; color: var(--muted); }
.vault ul { margin: 0; padding-left: 18px; }

.draft { font-family: var(--serif); font-size: 17px; line-height: 1.65; display: flex; flex-direction: column; gap: 10px; }
.draft p { margin: 0; position: relative; }
.draft h6 { font-family: var(--sans); font-size: 12.5px; font-weight: 700; color: var(--muted); margin: 6px 0 0; }
.src { font-family: var(--sans); font-size: 11.5px; font-weight: 700; color: var(--teal); background: var(--teal-soft); border-radius: 4px; padding: 1px 6px; margin-left: 6px; white-space: nowrap; }
.caught { background: var(--bad-bg); outline: 2px solid var(--bad); border-radius: 6px; padding: 4px 8px; margin: 0 -8px; }
.caught del { text-decoration-color: var(--bad); }
.fixed { background: var(--teal-soft); border-radius: 6px; padding: 4px 8px; margin: 0 -8px; }
.flagged { background: var(--flag-bg); outline: 2px solid var(--flag); border-radius: 6px; padding: 4px 8px; margin: 0 -8px; }
.caret::after { content: ""; display: inline-block; width: 2px; height: 1em; background: var(--ink); margin-left: 2px; vertical-align: -2px; animation: blink 800ms steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

.poster { display: flex; flex-direction: column; justify-content: center; align-items: flex-start; gap: 14px; height: 100%; min-height: 420px; }
.poster p { font-family: var(--serif); font-size: 19px; line-height: 1.55; margin: 0; max-width: 32em; color: var(--body); }
.poster .big { font-family: var(--sans); font-size: 26px; font-weight: 800; letter-spacing: -0.02em; color: var(--ink); }

.review { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.approve { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; border-top: 1px solid var(--line); padding-top: 14px; margin-top: 4px; }
.approve .who { width: 40px; height: 40px; border-radius: 50%; background: var(--teal); color: #fff; font-weight: 800; display: flex; align-items: center; justify-content: center; }
.approve p { margin: 0; font-size: 15px; flex: 1 1 220px; }
.approve .btn { font: 700 15px var(--sans); border-radius: 10px; min-height: 44px; padding: 0 16px; display: inline-flex; align-items: center; border: 2px dashed var(--muted); color: var(--muted); }
.approve .btn.on { border: 2px solid var(--teal); background: var(--teal); color: #fff; }
.checkline { display: flex; gap: 10px; align-items: flex-start; font-size: 14.5px; }
.checkline .box { width: 18px; height: 18px; flex-shrink: 0; border: 2px solid var(--muted); border-radius: 4px; margin-top: 2px; display: flex; align-items: center; justify-content: center; }
.checkline .box.on { background: var(--teal); border-color: var(--teal); color: #fff; }
.checkline .box svg { width: 12px; height: 12px; }

/* Explainer below the player */
.steps { list-style: none; counter-reset: s; margin: 72px 0 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 36px 48px; }
.steps li { counter-increment: s; }
.steps li::before { content: counter(s); display: inline-flex; width: 30px; height: 30px; border-radius: 50%; background: var(--ink); color: var(--ground); font-weight: 800; font-size: 14px; align-items: center; justify-content: center; margin-bottom: 10px; }
.steps h3 { margin: 0; font-size: 21px; letter-spacing: -0.01em; }
.steps p { margin: 6px 0 0; font-family: var(--serif); font-size: 17px; line-height: 1.55; color: var(--body); }

@media (max-width: 980px) {
  .p-body { grid-template-columns: minmax(0, 1fr); }
  .side { border-left: 0; border-top: 1px solid var(--line); }
  .steps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 620px) {
  .stage { padding: 20px 16px 24px; }
  .conveyor { padding: 20px 8px 14px; }
  .node { width: 40px; height: 40px; }
  .node svg { width: 19px; height: 19px; }
  .conveyor .track, .conveyor .track-fill { top: 39px; }
  .conveyor .packet { top: 32px; }
  .conveyor li span { font-size: 11px; }
  .row { grid-template-columns: minmax(0, 1fr) auto; }
  .row .k { grid-column: 1 / -1; }
  .row .n { grid-column: 1 / -1; }
  .steps { grid-template-columns: minmax(0, 1fr); }
  .p-controls { width: 100%; }
  .p-controls button { flex: 1; justify-content: center; }
}
/* Phones: the whole player fits one screen. The stage scrolls itself to the
   newest item; rules become pills and the log shows the latest line. */
@media (max-width: 620px) {
  .player { height: calc(100svh - 16px); max-height: 900px; min-height: 560px; display: flex; flex-direction: column; margin-top: 32px; scroll-margin-top: 8px; }
  .p-bar { padding: 10px 12px; gap: 8px; }
  .p-title { flex: 1 1 100%; }
  .p-title strong { font-size: 15px; }
  .p-title span { display: none; }
  .p-sim { font-size: 11px; padding: 2px 8px; }
  .p-controls { width: auto; flex: 1; }
  .p-controls button { min-height: 40px; padding: 0 10px; font-size: 14px; }
  .conveyor { padding: 12px 6px 10px; flex: none; }
  .node { width: 34px; height: 34px; }
  .node svg { width: 16px; height: 16px; }
  .conveyor .track, .conveyor .track-fill { top: 29px; }
  .conveyor .packet { top: 22px; width: 13px; height: 13px; margin-left: -6.5px; }
  .conveyor li { gap: 5px; }
  .conveyor li span { font-size: 10px; white-space: nowrap; letter-spacing: -0.01em; }
  .conveyor li[data-s="run"] span, .conveyor li[data-s="halt"] span { font-weight: 800; }
  .p-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
  .stage { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 14px 14px 18px; scroll-behavior: smooth; }
  .stage-head { margin-bottom: 10px; }
  .stage-head h3 { font-size: 19px; }
  .stage-head p { font-size: 12.5px; }
  .side { flex: none; border-left: 0; border-top: 1px solid var(--line); padding: 10px 12px 12px; gap: 8px; }
  .side h4 { display: none; }
  .rules { flex-direction: row; flex-wrap: wrap; gap: 6px; }
  .rules li { display: flex; align-items: center; gap: 6px; padding: 4px 9px 4px 5px; border-radius: 999px; }
  .rules small { display: none; }
  .rules b { font-size: 11.5px; line-height: 1.2; }
  .rules .dot { width: 14px; height: 14px; margin: 0; }
  .rules .dot svg { width: 9px; height: 9px; }
  .log { height: auto; max-height: none; padding: 7px 10px; font-size: 11.5px; line-height: 1.4; overflow: hidden; }
  .log li { display: none; }
  .log li:last-child { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
}

/* Recording mode: a fixed 1920x1080 frame for rendering the video cut */
body.record { background: var(--ground); }
body.record .top, body.record .hero, body.record .after { display: none; }
body.record .wrap { max-width: none; padding: 40px 60px; }
body.record .player { margin: 0; }
body.record .p-body { min-height: 760px; }
