/* =========================================================
   Live run — interactive hybrid-workflow panel (proof section)
   ========================================================= */
.run {
  --r: 4px;
  --glow: 0 0 0 1px var(--amber), 0 14px 44px -16px rgba(200, 135, 62, .55);
  position: relative; overflow: hidden;
  background: var(--carbon); border: 1px solid var(--rule-strong); border-radius: var(--r);
}
.run::before { /* faint blueprint grid */
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .45;
  background-image: linear-gradient(var(--rule) 1px, transparent 1px), linear-gradient(90deg, var(--rule) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: radial-gradient(ellipse at 50% 30%, #000 15%, transparent 72%);
  -webkit-mask-image: radial-gradient(ellipse at 50% 30%, #000 15%, transparent 72%);
}
.run > * { position: relative; }
.run button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
.run button:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }

/* ---- top bar: workflow tabs + system toggle ---- */
.run__bar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; padding: 12px 20px; border-bottom: 1px solid var(--rule); }
.run__dots { display: flex; gap: 6px; }
.run__dots i { width: 9px; height: 9px; border-radius: 50%; border: 1px solid var(--rule-strong); }
.run__tabs { display: flex; gap: 4px; font-size: 0.78rem; }
.run__tabs button { padding: 8px 12px; border-radius: 3px; color: var(--text-dim); transition: color .2s, background .2s; }
.run__tabs button:hover { color: var(--bone); background: rgba(240, 237, 232, .05); }
.run__tabs button[aria-selected="true"] { color: var(--bone); background: rgba(240, 237, 232, .08); box-shadow: inset 0 -2px 0 var(--amber); }
.run__mode { margin-left: auto; display: inline-flex; padding: 3px; border: 1px solid var(--rule-strong); border-radius: 999px; font-size: 0.74rem; }
.run__mode button { padding: 6px 14px; border-radius: 999px; color: var(--text-dim); transition: background .25s var(--ease), color .25s; }
.run__mode button:hover { color: var(--bone); }
.run__mode button[aria-pressed="true"] { background: var(--amber); color: var(--ink); }
.run__mode button[data-mode="without"][aria-pressed="true"] { background: var(--bone); color: var(--ink); }

/* ---- status row: file + clock ---- */
.run__status { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; padding: 18px 20px 6px; }
.run__file { font-size: 0.78rem; color: var(--text-dim); }
.run__clockwrap { display: grid; justify-items: end; gap: 2px; }
.run__clock-label { font-size: 0.68rem; color: var(--text-dim); }
.run__clock { color: var(--amber); font-size: clamp(1.3rem, 1rem + 1vw, 2rem); line-height: 1; letter-spacing: 0.02em; font-variant-numeric: tabular-nums; transition: color .3s; }
.run[data-mode="without"] .run__clock { color: var(--bone); }

/* ---- the five stages ---- */
.run__stages { list-style: none; margin: 0; padding: 16px 20px 22px; display: grid; gap: 14px; grid-template-columns: repeat(5, minmax(0, 1fr)); }
.run__stage { position: relative; }
.run__stage + .run__stage::before { /* connector from the previous card */
  content: ""; position: absolute; top: 58px; right: 100%; width: 14px; height: 1px;
  background: var(--rule-strong);
}
.run__stage + .run__stage::after {
  content: ""; position: absolute; top: 58px; right: 100%; width: 14px; height: 1px;
  background: var(--amber); transform: scaleX(0); transform-origin: left; transition: transform .45s var(--ease);
}
.run__stage.is-active::after, .run__stage.is-done::after { transform: scaleX(1); }
.run[data-mode="without"] .run__stage::after { background: var(--bone); }

.stage {
  width: 100%; height: 100%; text-align: left;
  display: grid; grid-template-rows: auto auto 1fr auto auto; gap: 12px;
  padding: 14px 14px 12px; border-radius: var(--r);
  background: rgba(14, 14, 14, .62); border: 1px solid var(--rule);
  opacity: .5;
  transition: opacity .35s var(--ease), border-color .3s, box-shadow .35s var(--ease), transform .3s var(--ease), background .3s;
}
.stage:hover { opacity: 1; border-color: var(--rule-strong); transform: translateY(-2px); }
.is-done .stage { opacity: .92; }
.is-active .stage { opacity: 1; border-color: var(--amber); box-shadow: var(--glow); background: rgba(200, 135, 62, .07); }
.run[data-mode="without"] .is-active .stage { border-color: var(--bone); box-shadow: 0 0 0 1px var(--bone), 0 14px 44px -18px rgba(240, 237, 232, .35); background: rgba(240, 237, 232, .05); }
.is-selected .stage { opacity: 1; border-color: var(--bone); border-style: dashed; }

.stage__top { display: flex; justify-content: space-between; gap: 8px; font-size: 0.68rem; color: var(--text-dim); }
.stage__at { font-variant-numeric: tabular-nums; }
.is-done .stage__at, .is-active .stage__at { color: var(--bone); }
.stage__title { font-family: var(--f-body); font-weight: 700; font-size: var(--step-0); line-height: 1.25; color: var(--bone); }
.stage__owner { justify-self: start; font-size: 0.68rem; padding: 3px 8px; border-radius: 999px; border: 1px solid var(--rule-strong); color: var(--text-dim); }
[data-kind="agent"] .stage__owner { border-color: rgba(200, 135, 62, .55); color: var(--amber-hi); }
[data-kind="human"] .stage__owner { border-color: rgba(240, 237, 232, .45); color: var(--bone); }

/* icons: system = hollow ring, agent = amber square, human = bone circle, result = check / cross */
.stage__icon { position: relative; width: 26px; height: 26px; display: grid; place-items: center; }
.stage__icon::before { content: ""; width: 20px; height: 20px; border-radius: 50%; border: 1.5px solid var(--text-dim); transition: background .3s, border-color .3s; }
[data-kind="agent"] .stage__icon::before { border-radius: 3px; border-color: var(--amber); background: rgba(200, 135, 62, .14); }
[data-kind="human"] .stage__icon::before { border-color: var(--bone); }
.is-done[data-kind="human"] .stage__icon::before, .is-active[data-kind="human"] .stage__icon::before { background: var(--bone); }
.is-done[data-kind="agent"] .stage__icon::before, .is-active[data-kind="agent"] .stage__icon::before { background: rgba(200, 135, 62, .45); }
[data-kind="out"] .stage__icon::before { border-color: var(--amber); }
[data-kind="out"] .stage__icon::after {
  content: ""; position: absolute; width: 9px; height: 5px; margin-top: -3px;
  border-left: 2px solid var(--amber); border-bottom: 2px solid var(--amber); transform: rotate(-45deg);
  opacity: 0; transition: opacity .3s;
}
.is-done[data-kind="out"] .stage__icon::before { background: rgba(200, 135, 62, .18); }
.is-done[data-kind="out"] .stage__icon::after { opacity: 1; }
[data-kind="fail"] .stage__icon::before { border-color: var(--text-dim); }
[data-kind="fail"] .stage__icon::after {
  content: "×"; position: absolute; font-family: var(--f-mono); font-size: 18px; line-height: 1; color: var(--bone); opacity: 0; transition: opacity .3s;
}
.is-done[data-kind="fail"] .stage__icon::after { opacity: 1; }
.is-active .stage__icon { animation: stagePing 1.6s var(--ease) infinite; border-radius: 50%; }
@keyframes stagePing { 0% { box-shadow: 0 0 0 0 rgba(200, 135, 62, .55); } 80%, 100% { box-shadow: 0 0 0 12px rgba(200, 135, 62, 0); } }

.stage__bar { height: 2px; background: var(--rule); border-radius: 2px; overflow: hidden; }
.stage__bar i { display: block; height: 100%; width: 100%; background: var(--amber); transform: scaleX(0); transform-origin: left; }
.is-done .stage__bar i { transform: scaleX(1); }
.is-active .stage__bar i { animation: stageFill var(--dwell, 1.4s) linear forwards; }
.run[data-mode="without"] .stage__bar i { background: var(--bone); }
@keyframes stageFill { to { transform: scaleX(1); } }

/* ---- inspector + log ---- */
.run__panes { display: grid; border-top: 1px solid var(--rule); }
@media (min-width: 900px) { .run__panes { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); } }
.run__inspect { padding: 20px; display: grid; align-content: start; gap: 10px; min-height: 196px; }
.run__pane-label { font-size: 0.72rem; color: var(--text-dim); }
.run__i-title { font-family: var(--f-display); font-weight: 400; font-size: var(--step-2); line-height: 1; color: var(--bone); }
.run__i-text { color: var(--text-dim); max-width: 52ch; }
.run__i-why { color: var(--bone); max-width: 52ch; padding-left: 12px; border-left: 2px solid var(--amber); }
.run__i-why:empty { display: none; }
.run[data-mode="without"] .run__i-why { border-left-color: var(--bone); }

.run__log-wrap { display: flex; flex-direction: column; border-top: 1px solid var(--rule); background: rgba(14, 14, 14, .5); }
@media (min-width: 900px) { .run__log-wrap { border-top: 0; border-left: 1px solid var(--rule); } }
.run__log-wrap .run__pane-label { padding: 16px 20px 0; }
.run__log {
  list-style: none; margin: 0; flex: 1; min-height: 170px; padding: 8px 20px 16px;
  display: flex; flex-direction: column; justify-content: flex-end; gap: 7px; overflow: hidden;
  font-size: 0.76rem; line-height: 1.45;
  mask-image: linear-gradient(180deg, transparent, #000 38%); -webkit-mask-image: linear-gradient(180deg, transparent, #000 38%);
}
.run__log li { display: grid; grid-template-columns: auto 1.1em minmax(0, 1fr); gap: 10px; color: var(--text-dim); animation: logIn .4s var(--ease) both; }
.run__log li .who { color: var(--amber); }
.run__log li.human .who, .run__log li.system .who { color: var(--bone); }
.run__log li.out { color: var(--bone); }
.run__log li.fail { color: var(--bone); }
.run__log li.fail .who { color: var(--bone); }
@keyframes logIn { from { opacity: 0; transform: translateY(8px); } }

/* ---- footer: controls + result ---- */
.run__foot { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; padding: 14px 20px; border-top: 1px solid var(--rule); }
.run__controls { display: flex; gap: 8px; }
.run .run__btn { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border: 1px solid var(--rule-strong) !important; border-radius: 999px; font-size: 0.74rem; color: var(--bone); transition: border-color .2s, background .2s; }
.run .run__btn:hover { border-color: var(--bone) !important; background: rgba(240, 237, 232, .05); }
.run__btn-icon { width: 10px; height: 10px; display: inline-block; border-left: 3px solid currentColor; border-right: 3px solid currentColor; }
.run.is-paused .run__btn-icon { border: 0; width: 0; height: 0; border-left: 9px solid currentColor; border-top: 5px solid transparent; border-bottom: 5px solid transparent; }
.run__result { margin-left: auto; font-size: 0.78rem; color: var(--amber); text-align: right; min-height: 1.4em; transition: opacity .3s; }
.run[data-mode="without"] .run__result { color: var(--bone); }
.run__result:empty { opacity: 0; }

/* ---- tablet / phone: stages become a vertical timeline ---- */
@media (max-width: 899px) {
  .run__bar { padding: 12px 16px; }
  .run__dots { display: none; }
  .run__tabs { width: 100%; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); font-size: 0.72rem; }
  .run__tabs button { padding: 9px 6px; text-align: center; line-height: 1.25; }
  .run__mode { margin-left: 0; width: 100%; display: grid; grid-template-columns: 1fr 1fr; }
  .run__mode button { padding: 8px 10px; }
  .run__status { padding: 16px 16px 4px; }
  .run__stages { grid-template-columns: minmax(0, 1fr); gap: 10px; padding: 12px 16px 18px; }
  .run__stage + .run__stage::before, .run__stage + .run__stage::after {
    top: auto; bottom: 100%; right: auto; left: 28px; width: 1px; height: 10px; transform-origin: top;
  }
  .run__stage + .run__stage::after { transform: scaleY(0); }
  .run__stage.is-active::after, .run__stage.is-done::after { transform: scaleY(1); }
  .stage {
    grid-template-columns: 26px minmax(0, 1fr) auto; grid-template-rows: auto auto;
    grid-template-areas: "icon top top" "icon title owner";
    column-gap: 12px; row-gap: 4px; padding: 12px 14px; align-items: center;
  }
  .stage:hover { transform: none; }
  .stage__icon { grid-area: icon; align-self: center; }
  .stage__top { grid-area: top; }
  .stage__title { grid-area: title; font-size: 0.98rem; }
  .stage__owner { grid-area: owner; justify-self: end; }
  .stage__bar { display: none; }
  .run__inspect { padding: 18px 16px; min-height: 0; }
  .run__log-wrap .run__pane-label { padding: 14px 16px 0; }
  .run__log { padding: 8px 16px 14px; min-height: 150px; font-size: 0.72rem; }
  .run__foot { padding: 12px 16px; }
  .run__result { margin-left: 0; width: 100%; text-align: left; }
}

@media (prefers-reduced-motion: reduce) {
  .is-active .stage__icon { animation: none; }
}

/* phones: the timeline already shows every step, so drop the duplicate log */
@media (max-width: 599px) { .run__log-wrap { display: none; } }
