/* Dedicated styles for run-detail.html and originman-reference-run.html.
   Split from experiment.css so the Studio MCP App bundle (plugins/.../ui/experiment.html)
   never ships unused live-stage, telemetry-curve, or log-terminal CSS. */

#quality-status[data-verdict],
.run-verdict-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: var(--fs-meta);
  font-weight: 600;
}
#quality-status[data-verdict="passed"] {
  color: var(--green-text);
  background: var(--green-soft);
  border: 1px solid var(--green-border);
}
#quality-status[data-verdict="warning-silent-failure"],
#quality-status[data-verdict="quick-check"] {
  color: var(--amber-text);
  background: var(--amber-soft);
  border: 1px solid var(--amber-border);
}
#quality-status[data-verdict="failed"] {
  color: var(--red-text);
  background: var(--red-soft);
  border: 1px solid var(--red-border);
}
#quality-summary[data-verdict="passed"] {
  background: var(--green-soft);
  color: var(--green-text);
  border: 1px solid var(--green-border);
  text-align: left;
  place-items: start;
}
#quality-summary[data-verdict="warning-silent-failure"],
#quality-summary[data-verdict="quick-check"] {
  background: var(--amber-soft);
  color: var(--amber-text);
  border: 1px solid var(--amber-border);
  text-align: left;
  place-items: start;
}
#quality-summary[data-verdict="failed"] {
  background: var(--red-soft);
  color: var(--red-text);
  border: 1px solid var(--red-border);
  text-align: left;
  place-items: start;
}

.run-login-prompt {
  margin: 0 0 20px;
  padding: 12px 16px;
  border: 1px solid var(--orange-200);
  border-radius: 8px;
  background: var(--orange-50);
  font-weight: 600;
}

.run-artifact-summary {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  color: var(--muted-strong);
  font-size: var(--fs-meta);
}

.telemetry-charts-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin-top: 16px;
}
.telemetry-chart-card {
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}
.telemetry-chart-card figcaption {
  margin-bottom: 8px;
  color: var(--muted-strong);
  font-size: var(--fs-meta);
  font-weight: 600;
}
.telemetry-chart-card svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}
.telemetry-line-rmse { stroke: var(--blue); stroke-width: 2; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.telemetry-line-tilt { stroke: var(--amber); stroke-width: 2; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.telemetry-bar-rmse { fill: var(--blue); opacity: 0.85; }
.telemetry-bar-tilt { fill: var(--amber); opacity: 0.85; }
.telemetry-baseline-line { stroke: var(--green); stroke-width: 1.5; stroke-dasharray: 5 4; }
.telemetry-limit-line { stroke: var(--red); stroke-width: 1.5; stroke-dasharray: 5 4; }
.telemetry-point-failed { fill: var(--panel); stroke: var(--red); stroke-width: 2; }
.checkpoint-rmse-wrap { margin-bottom: 16px; }

.experiment-content-stack[data-run-phase="active"] .run-section-summary { order: 1; }
.experiment-content-stack[data-run-phase="active"] .run-section-queue { order: 2; }
.experiment-content-stack[data-run-phase="active"] .run-section-live { order: 3; }
.experiment-content-stack[data-run-phase="active"] .run-section-curve { order: 4; }
.experiment-content-stack[data-run-phase="active"] .run-section-overview { order: 5; }
.experiment-content-stack[data-run-phase="active"] .run-section-dance { order: 6; }
.experiment-content-stack[data-run-phase="active"] .run-section-config { order: 7; }
.experiment-content-stack[data-run-phase="active"] .run-section-completion { order: 8; }
.experiment-content-stack[data-run-phase="active"] .run-section-replay { order: 9; }
.experiment-content-stack[data-run-phase="active"] .run-section-quality { order: 10; }
.experiment-content-stack[data-run-phase="active"] .run-section-independent { order: 11; }
.experiment-content-stack[data-run-phase="active"] .run-section-resimulated { order: 12; }
.experiment-content-stack[data-run-phase="active"] .run-section-meta { order: 13; }

.experiment-content-stack[data-run-phase="active"] .run-section-replay,
.experiment-content-stack[data-run-phase="active"] .run-section-quality {
  border-style: dashed;
  background: var(--panel-soft);
  box-shadow: none;
}
.experiment-content-stack[data-run-phase="active"] .run-section-replay .empty-state,
.experiment-content-stack[data-run-phase="active"] .run-section-quality .empty-state {
  min-height: 48px;
  padding: 12px 16px;
}

.experiment-content-stack[data-run-phase="failed"] .run-section-summary { order: 1; }
.experiment-content-stack[data-run-phase="failed"] .run-section-overview { order: 2; }
.experiment-content-stack[data-run-phase="failed"] .run-section-quality { order: 3; }
.experiment-content-stack[data-run-phase="failed"] .run-section-optimize { order: 4; }
.experiment-content-stack[data-run-phase="failed"] .run-section-curve { order: 5; }
.experiment-content-stack[data-run-phase="failed"] .run-section-config { order: 5; }
.experiment-content-stack[data-run-phase="failed"] .run-section-dance { order: 6; }
.experiment-content-stack[data-run-phase="failed"] .run-section-completion { order: 7; }
.experiment-content-stack[data-run-phase="failed"] .run-section-replay { order: 8; }
.experiment-content-stack[data-run-phase="failed"] .run-section-meta { order: 9; }

.run-live-stage {
  border-color: var(--orange-200);
  background: linear-gradient(180deg, var(--orange-50) 0%, var(--panel) 88px);
}
.run-live-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}
.run-live-title-wrap {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.run-live-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
  animation: run-pulse 1.6s ease-in-out infinite;
  flex: none;
}
.run-live-stage[data-status="queued"] .run-live-dot,
.run-live-stage[data-status="ready"] .run-live-dot {
  background: var(--amber);
  box-shadow: 0 0 0 4px var(--amber-soft);
}
.run-live-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: var(--fs-meta);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  background: var(--accent-soft);
  color: var(--accent-text);
  border: 1px solid var(--orange-200);
}
.run-live-stage[data-status="queued"] .run-live-badge,
.run-live-stage[data-status="ready"] .run-live-badge {
  background: var(--amber-soft);
  color: var(--amber-text);
  border-color: var(--amber-border);
}

.run-live-pipeline {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 0 0 16px;
  padding: 0;
}
.run-live-pipeline li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--muted);
  font-size: var(--fs-meta);
}
.run-live-pipeline li span {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 999px;
  font-size: var(--fs-meta);
  font-weight: 700;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  color: var(--muted-strong);
  flex: none;
}
.run-live-pipeline li strong {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.run-live-pipeline li[data-state="done"] {
  background: var(--green-soft);
  border-color: var(--green-border);
  color: var(--green-text);
}
.run-live-pipeline li[data-state="done"] span {
  background: var(--green);
  border-color: var(--green);
  color: var(--white);
}
.run-live-pipeline li[data-state="active"] {
  background: var(--accent-soft);
  border-color: var(--orange-300);
  color: var(--accent-text);
}
.run-live-pipeline li[data-state="active"] span {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--white);
}

.run-live-progress-wrap {
  margin-bottom: 12px;
}
.run-live-track {
  position: relative;
  height: 10px;
  border-radius: 999px;
  background: var(--bg-deep);
  overflow: hidden;
  border: 1px solid var(--line);
}
.run-live-fill {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent-strong), var(--orange-400));
  transition: width 0.35s ease;
}
.run-live-track.is-indeterminate .run-live-fill {
  width: 36%;
  animation: run-live-slide 1.7s ease-in-out infinite;
}

.run-live-message {
  margin: 0 0 16px;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  color: var(--text);
}
.run-live-stage[data-status="queued"] .run-live-message,
.run-live-stage[data-status="ready"] .run-live-message {
  border-left-color: var(--amber);
}

.run-live-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}
.run-live-metrics > div {
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
}
.run-live-metrics span {
  display: block;
  font-size: var(--fs-meta);
  color: var(--muted);
}
.run-live-metrics strong {
  display: block;
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.run-live-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}
.run-live-btn-primary {
  border-color: var(--accent-strong);
  background: var(--accent-strong);
  color: var(--white);
  font-weight: 600;
}
.run-live-btn-primary:hover:not(:disabled) {
  background: var(--accent);
  border-color: var(--accent);
}
.run-live-btn-danger {
  border-color: var(--red-border);
  background: var(--red-soft);
  color: var(--red-text);
  font-weight: 600;
}
.run-live-btn-danger:hover:not(:disabled),
.run-live-btn-danger[data-confirming="true"] {
  border-color: var(--red);
  background: var(--red);
  color: var(--white);
}
.run-live-link {
  margin-left: auto;
  font-size: var(--fs-meta);
  font-weight: 600;
}

.run-summary-box {
  margin: 0 0 12px;
  padding: 12px 16px;
  border-radius: 8px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-left: 3px solid var(--line-strong);
  color: var(--text);
}
.run-summary-box[data-status="running"] { border-left-color: var(--accent); }
.run-summary-box[data-status="queued"],
.run-summary-box[data-status="ready"],
.run-summary-box[data-status="cancelling"] { border-left-color: var(--amber); }
.run-summary-box[data-status="completed"] { border-left-color: var(--green); }
.run-summary-box[data-status="failed"],
.run-summary-box[data-status="blocked"] { border-left-color: var(--red); background: var(--red-soft); color: var(--red-text); }
.run-summary-box[data-verdict="warning-silent-failure"],
.run-summary-box[data-verdict="quick-check"] { border-color: var(--amber-border); border-left-color: var(--amber); background: var(--amber-soft); color: var(--amber-text); }
.run-summary-box[data-verdict="failed"] { border-color: var(--red-border); border-left-color: var(--red); background: var(--red-soft); color: var(--red-text); }
.run-summary-box[data-verdict="passed"] { border-color: var(--green-border); border-left-color: var(--green); background: var(--green-soft); color: var(--green-text); }

.run-logs-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 12px;
}
.run-logs-status {
  color: var(--muted);
  font-size: var(--fs-meta);
}
.run-logs-terminal {
  display: block;
  text-align: left;
  min-height: 80px;
  max-height: 360px;
  overflow: auto;
  margin: 12px 0 0;
  padding: 12px 16px;
  border-radius: 8px;
  background: var(--bg-deep);
  border: 1px solid var(--line);
  color: var(--text);
  font: var(--fs-meta)/1.6 var(--font-label);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.empty-state.is-live-waiting {
  border: 1px dashed var(--orange-200);
  background: var(--orange-50);
  color: var(--muted-strong);
}

@media (max-width: 720px) {
  .run-live-pipeline,
  .run-live-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@keyframes run-live-slide {
  0% { transform: translateX(-110%); }
  100% { transform: translateX(300%); }
}
@media (prefers-reduced-motion: reduce) {
  .run-live-dot,
  .run-live-track.is-indeterminate .run-live-fill {
    animation: none;
  }
}

/* RL Live Training 3D Motion Stream Viewer */
.run-live-3d-panel {
  margin-bottom: 16px;
  min-width: 0;
}
.run-live-3d-panel[hidden] {
  display: none;
}
.run-live-3d-shell {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--ui-radius-lg);
  background: var(--panel-soft);
  min-width: 0;
}
.run-live-3d-shell > * {
  min-width: 0;
}
.run-live-3d-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.run-live-3d-meta {
  font-size: var(--fs-meta);
  color: var(--muted);
}
.run-live-3d-viewport {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: var(--ui-radius-md);
  background: var(--frame-navy);
}
.run-live-3d-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
}
.run-live-3d-canvas:active {
  cursor: grabbing;
}
.run-live-3d-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  text-align: center;
  background: var(--navy-deep);
  color: var(--mist);
  font-size: var(--fs-body);
}
.run-live-3d-overlay[hidden] {
  display: none;
}
.run-live-3d-hud,
.run-live-3d-fresh {
  position: absolute;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: var(--fs-meta);
  font-weight: 600;
  pointer-events: none;
}
.run-live-3d-hud {
  top: 10px;
  left: 10px;
  background: var(--navy-deep);
  border: 1px solid var(--line-strong);
  color: var(--frost);
}
.run-live-3d-fresh {
  top: 10px;
  right: 10px;
  background: var(--green);
  color: var(--white);
}
.run-live-3d-fresh[hidden] {
  display: none;
}
.run-live-3d-scrubber {
  width: 100%;
  accent-color: var(--accent);
}
.run-live-3d-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.run-live-3d-btn {
  padding: 6px 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--ui-radius-md);
  background: var(--panel);
  color: var(--text);
  font-size: var(--fs-meta);
  font-weight: 600;
  cursor: pointer;
}
.run-live-3d-btn[aria-pressed='true'] {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-text);
}
.run-live-3d-evolution {
  display: grid;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--ui-radius-md);
  background: var(--panel);
  min-width: 0;
}
.run-live-3d-evolution[hidden] {
  display: none;
}
.run-live-3d-delta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: var(--fs-meta);
  font-weight: 600;
  color: var(--green-text);
  font-variant-numeric: tabular-nums;
}
.run-live-3d-rounds {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.run-live-3d-round-btn {
  padding: 4px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--panel-soft);
  color: var(--muted-strong);
  font-size: var(--fs-meta);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}
.run-live-3d-round-btn[aria-pressed='true'] {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-text);
}
.run-live-3d-round-btn.is-follow[aria-pressed='true'] {
  border-color: var(--green-border);
  background: var(--green-soft);
  color: var(--green-text);
}
.run-live-3d-diag {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--ui-radius-md);
  background: var(--panel);
  font-size: var(--fs-meta);
  color: var(--muted-strong);
  font-variant-numeric: tabular-nums;
  min-width: 0;
}
.run-live-3d-diag[hidden] {
  display: none;
}
.run-live-3d-note {
  margin: 0;
  font-size: var(--fs-meta);
  color: var(--muted);
}

.x5-env-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 10px 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--ui-radius-md);
  background: var(--panel-soft);
}
.x5-env-bar[hidden] {
  display: none;
}
.x5-env-pills {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.x5-env-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted-strong);
  font-size: var(--fs-meta);
  font-weight: 600;
}
.x5-env-pill[data-tone='ok'] {
  border-color: var(--green-border);
  background: var(--green-soft);
  color: var(--green-text);
}
.x5-env-pill[data-tone='warn'] {
  border-color: var(--amber-border);
  background: var(--amber-soft);
  color: var(--amber-text);
}
.x5-env-pill[data-tone='info'] {
  border-color: var(--accent-ring);
  background: var(--accent-soft);
  color: var(--accent-text);
}
.x5-env-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

/* Continuous Optimization & Multi-Round Evolution */
.run-section-optimize {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  min-width: 0;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--accent-ring);
  border-radius: var(--ui-radius-lg);
  background: var(--panel);
}
.run-optimize-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border: 1px solid var(--accent-ring);
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-text);
  font-size: var(--fs-meta);
  font-weight: 600;
}
.run-optimize-lead,
.run-optimize-status {
  margin: 0;
  font-size: var(--fs-body);
  color: var(--muted);
}
.run-optimize-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 8px;
}
.run-optimize-field {
  display: grid;
  gap: 4px;
  font-size: var(--fs-meta);
  color: var(--muted);
}
.run-rounds-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  min-width: 0;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}
.run-rounds-wrap .comparison-scroll {
  min-width: 0;
  max-width: 100%;
  overflow-x: auto;
}
.run-rounds-wrap table {
  min-width: 520px;
}
.run-rounds-wrap th,
.run-rounds-wrap td {
  white-space: nowrap;
}
.run-rounds-wrap h3 {
  margin: 0;
  font-size: var(--fs-body);
  color: var(--text);
}
.run-rounds-wrap tr.is-current-round {
  background: var(--accent-soft);
  font-weight: 600;
}

/* RDK X5 Managed 4-Step Real-Robot Execution Cockpit */
.x5-managed-cockpit {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  min-width: 0;
  gap: 12px;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--ui-radius-lg);
  background: var(--panel-soft);
}
.x5-cockpit-step {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  min-width: 0;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--ui-radius-md);
  background: var(--panel);
}
.x5-managed-cockpit select,
.x5-managed-cockpit input:not([type='checkbox']) {
  max-width: 100%;
  min-width: 0;
}
.x5-cockpit-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.x5-cockpit-status {
  margin: 0;
  font-size: var(--fs-meta);
  color: var(--muted);
}
.x5-token-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--amber-border);
  background: var(--amber-soft);
  color: var(--amber-text);
  font-size: var(--fs-meta);
  font-weight: 600;
}
.x5-token-pill[data-tone='ok'] {
  border-color: var(--green-border);
  background: var(--green-soft);
  color: var(--green-text);
}
.x5-spotter-label {
  display: inline-flex;
  align-items: flex-start;
  gap: 8px;
  font-size: var(--fs-body);
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
}
.x5-spotter-label input {
  margin-top: 2px;
  flex: none;
}
.x5-estop-btn {
  border: 1px solid var(--red-border);
  background: var(--red-soft);
  color: var(--red-text);
  font-weight: 700;
}
.x5-estop-btn:not(:disabled):hover {
  border-color: var(--red);
  background: var(--red);
  color: var(--panel);
}
.x5-feedback-card {
  display: grid;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--amber-border);
  border-radius: var(--ui-radius-md);
  background: var(--amber-soft);
}
.x5-feedback-card[data-tone='ok'] {
  border-color: var(--green-border);
  background: var(--green-soft);
}
.x5-feedback-card[hidden] {
  display: none;
}
.x5-feedback-card p {
  margin: 0;
  font-size: var(--fs-body);
  color: var(--text);
}
html.theme-dark .run-live-btn-primary {
  color: var(--warm-ink);
}
