/* ── Reset ──────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 13px;
  line-height: 1.5;
  color: #111827;
  background: #f0f2f5;
  min-height: 100vh;
}

/* ── Header ─────────────────────────────────────────────────────────────────── */

header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: #fff;
  border-bottom: 1px solid #dde1ea;
  height: 52px;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.header-left  { display: flex; align-items: center; gap: 16px; min-width: 0; }
.header-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

.logo {
  font-size: 15px;
  font-weight: 700;
  color: #4f46e5;
  letter-spacing: -0.3px;
  white-space: nowrap;
}

#exp-select {
  border: 1px solid #d1d5db;
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 13px;
  min-width: 260px;
  max-width: 420px;
  color: #374151;
  background: #fafafa;
  cursor: pointer;
}
#exp-select:focus { outline: 2px solid #a5b4fc; border-color: #6366f1; }

.user-chip {
  font-size: 11px;
  color: #6b7280;
  background: #f3f4f6;
  border-radius: 10px;
  padding: 3px 9px;
  white-space: nowrap;
}

/* ── Status dot ─────────────────────────────────────────────────────────────── */

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #d1d5db;
  flex-shrink: 0;
}
.status-dot.loading { background: #f59e0b; animation: pulse 1.2s ease-in-out infinite; }
.status-dot.live    { background: #22c55e; }
.status-dot.idle    { background: #9ca3af; }
.status-dot.error   { background: #ef4444; }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

/* ── Main layout ────────────────────────────────────────────────────────────── */

main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 20px;
}

/* ── Picker empty state ─────────────────────────────────────────────────────── */

#picker-view { padding: 80px 0; text-align: center; color: #9ca3af; font-size: 15px; }

/* ── Run selector ───────────────────────────────────────────────────────────── */

.run-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.run-bar-label {
  font-size: 10px;
  font-weight: 700;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  white-space: nowrap;
}

#run-chips { display: flex; flex-wrap: wrap; gap: 6px; }

.run-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px 3px 6px;
  border-radius: 12px;
  border: 1.5px solid var(--c, #6b7280);
  color: var(--c, #6b7280);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  background: transparent;
  transition: background 0.1s;
}
.run-chip:hover { background: color-mix(in srgb, var(--c) 10%, transparent); }
.run-chip input[type="checkbox"] { accent-color: var(--c); cursor: pointer; }
.chip-label { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Tabs ───────────────────────────────────────────────────────────────────── */

.tab-bar {
  display: flex;
  border-bottom: 2px solid #e5e7eb;
  margin-bottom: 16px;
}

.tab-btn {
  padding: 9px 22px;
  border: none;
  background: none;
  font-size: 13px;
  font-weight: 500;
  color: #6b7280;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color 0.12s;
}
.tab-btn:hover  { color: #374151; }
.tab-btn.active { color: #4f46e5; border-bottom-color: #4f46e5; }

/* ── Tab panes ──────────────────────────────────────────────────────────────── */

.tab-pane {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 14px;
  align-items: start;
}

.empty-pane {
  grid-column: 1 / -1;
  padding: 56px;
  text-align: center;
  color: #9ca3af;
  font-size: 14px;
}

/* ── Metric card (shared shell) ─────────────────────────────────────────────── */

.metric-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 12px 14px 10px;
  overflow: hidden;
  min-width: 0;
}

.card-title {
  font-size: 11px;
  font-weight: 600;
  color: #374151;
  margin-bottom: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Scalars: Plotly chart container ────────────────────────────────────────── */

.chart-host { width: 100%; }

/* ── Images ─────────────────────────────────────────────────────────────────── */

.img-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 6px;
}

.img-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.img-cell img {
  display: block;
  max-width: 220px;
  max-height: 180px;
  border-radius: 4px;
  border: 1px solid #e5e7eb;
  background: #f9fafb;
  object-fit: contain;
}

.img-cell figcaption {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
}

/* ── Text tab: full-width cards ─────────────────────────────────────────────── */

.text-metric-card {
  grid-column: 1 / -1;
}

.text-block { margin-top: 10px; }

.text-run-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 5px;
}

.code-block {
  background: #f8f9fa;
  border: 1px solid #e5e7eb;
  border-radius: 5px;
  padding: 10px 14px;
  font-family: "JetBrains Mono", "Fira Code", "Cascadia Code", ui-monospace, monospace;
  font-size: 11.5px;
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-x: auto;
  max-height: 450px;
  overflow-y: auto;
  color: #1a1a2e;
}

/* ── Shared label helpers ───────────────────────────────────────────────────── */

.run-label {
  font-size: 10px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 220px;
}

.step-label {
  font-size: 10px;
  color: #9ca3af;
}
