:root {
  --bg: #0a0a0f;
  --surface: #1a1a2e;
  --accent: #ff4500;
  --accent-2: #ffaa00;
  --ok: #22c55e;
  --text: #e0e0e0;
  --chromatic-glow: 0 0 15px var(--accent);
  --mono: ui-monospace, 'SF Mono', SFMono-Regular, Menlo, Consolas, monospace;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'SF Pro Display', system-ui, sans-serif;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: 100vh;
  padding: 20px 0;
  padding-bottom: calc(20px + env(safe-area-inset-bottom));
  overflow-x: hidden;
  position: relative;
}
/* Subtle animated scanning grid backdrop */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 69, 0, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 69, 0, 0.05) 1px, transparent 1px);
  background-size: 40px 40px;
  animation: gridScroll 18s linear infinite;
  opacity: 0.5;
}
@keyframes gridScroll {
  from { background-position: 0 0, 0 0; }
  to   { background-position: 0 40px, 40px 0; }
}
#app {
  width: 100%;
  max-width: 420px;
  padding: 20px;
  position: relative;
  z-index: 1;
}
header h1 {
  font-size: 2rem;
  text-shadow: var(--chromatic-glow);
}
.tagline {
  font-size: 0.9rem;
  opacity: 0.8;
  margin-bottom: 1rem;
}

/* ===== Splash ===== */
#splash {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: opacity 0.8s ease;
  will-change: opacity;
}
.splash-logo {
  font-size: 3.5rem;
  animation: pulse 1.4s ease-in-out infinite;
  filter: drop-shadow(0 0 18px var(--accent));
}
.splash-text {
  margin-top: 1rem;
  opacity: 0.7;
  font-family: var(--mono);
  font-size: 0.85rem;
  letter-spacing: 0.05em;
}

/* ===== Step indicator ===== */
#steps {
  display: flex;
  justify-content: space-between;
  margin-bottom: 1rem;
  font-size: 1.3rem;
}
.step {
  opacity: 0.28;
  transform: scale(0.9);
  transition: opacity 0.4s ease, transform 0.4s ease, filter 0.4s ease;
  will-change: opacity, transform;
}
.step.active {
  opacity: 1;
  transform: scale(1.1);
  filter: drop-shadow(0 0 8px var(--accent));
}

/* ===== Button ===== */
button.chromatic {
  background: var(--accent);
  border: none;
  padding: 14px 24px;
  font-size: 1.2rem;
  border-radius: 8px;
  cursor: pointer;
  width: 100%;
  box-shadow: var(--chromatic-glow);
  color: #fff;
  font-weight: 600;
  letter-spacing: 0.05em;
  transition: filter 0.15s, transform 0.1s, box-shadow 0.15s, opacity 0.2s;
  will-change: transform;
}
button.chromatic:hover:not(:disabled) {
  filter: brightness(1.15);
  transform: translateY(-1px);
  box-shadow: 0 0 22px var(--accent);
}
button.chromatic:active:not(:disabled) {
  transform: scale(0.97);
  filter: brightness(0.95);
}
button.chromatic:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
button.chromatic:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ===== Proof certificate ===== */
@keyframes scaleIn {
  from { transform: scale(0.9); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}
.proof-card {
  position: relative;
  margin-top: 1rem;
  padding: 1rem;
  background: #11141c;
  border: 1px solid var(--ok);
  border-radius: 12px;
  text-align: center;
  display: none;
  box-shadow: 0 0 18px rgba(34, 197, 94, 0.25);
}
.proof-card.show {
  display: block;
  animation: scaleIn 0.32s ease both;
}
.proof-seal { font-size: 1.8rem; }
.proof-title { font-weight: 600; margin-top: 0.2rem; }
.proof-details {
  font-family: var(--mono);
  font-size: 0.78rem;
  opacity: 0.85;
  margin-top: 0.3rem;
  word-break: break-word;
}
.proof-stamp {
  position: absolute;
  top: 10px;
  right: 10px;
  font-family: var(--mono);
  font-size: 0.65rem;
  letter-spacing: 0.15em;
  color: var(--ok);
  border: 1px solid var(--ok);
  border-radius: 4px;
  padding: 1px 5px;
  transform: rotate(8deg);
  opacity: 0.85;
}

/* ===== Beam stage ===== */
#beam-stage {
  width: 100%;
  height: 200px;
  margin-top: 1rem;
  border-radius: 8px;
  overflow: hidden;
  background: radial-gradient(circle at 30% 30%, #1a1a3a, #0a0a15);
}
#beam-stage canvas { display: block; }
#scugs-canvas {
  display: block;
  width: 100%;
  height: 200px;
  border-radius: 8px;
}

/* ===== Council ===== */
#council-section { margin-top: 1rem; }
#council-bar {
  height: 5px;
  background: #e63939;
  border-radius: 3px;
  margin: 0.4rem 0;
  box-shadow: 0 0 10px rgba(255, 120, 60, 0.4);
}
.council-rationale {
  font-family: var(--mono);
  font-size: 0.78rem;
  opacity: 0.85;
  min-height: 1.2rem;
  line-height: 1.5;
}

/* ===== Status panel ===== */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.status-panel {
  margin-top: 1rem;
  padding: 1rem;
  background: var(--surface);
  border-radius: 8px;
  font-family: var(--mono);
  font-size: 0.85rem;
  line-height: 1.6;
  min-height: 2rem;
  word-break: break-all;
  overflow-wrap: anywhere;
}
.status-line {
  animation: fadeIn 0.25s ease both;
  padding: 1px 0;
}
.status-line.error { color: #ff6b6b; }
.tag {
  font-size: 0.7rem;
  background: rgba(255, 69, 0, 0.18);
  border: 1px solid var(--accent);
  border-radius: 4px;
  padding: 0 5px;
  margin-left: 4px;
}
.swatch {
  display: inline-block;
  width: 12px; height: 12px;
  border-radius: 50%;
  vertical-align: middle;
  margin-left: 4px;
}

/* ===== Esther ===== */
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.12); }
}
.esther-stack {
  position: fixed;
  bottom: calc(20px + env(safe-area-inset-bottom));
  right: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 5;
}
.esther {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: var(--chromatic-glow);
  transition: background 0.3s, box-shadow 0.3s;
}
.esther.listening { box-shadow: 0 0 25px var(--accent); }
.esther.speaking {
  background: var(--accent-2);
  box-shadow: 0 0 25px var(--accent-2);
  animation: pulse 1s ease-in-out infinite;
}
/* Voice waveform */
.esther-wave {
  display: none;
  align-items: flex-end;
  gap: 2px;
  height: 22px;
}
.esther-wave.active { display: flex; }
.esther-wave span {
  width: 3px;
  height: 4px;
  background: var(--accent-2);
  border-radius: 1px;
  animation: wave 0.6s ease-in-out infinite alternate;
}
.esther-wave span:nth-child(2) { animation-delay: 0.1s; }
.esther-wave span:nth-child(3) { animation-delay: 0.2s; }
.esther-wave span:nth-child(4) { animation-delay: 0.3s; }
.esther-wave span:nth-child(5) { animation-delay: 0.4s; }
@keyframes wave {
  from { height: 4px; }
  to   { height: 18px; }
}

.hidden { display: none; }

/* ===== Sponsor bar ===== */
.sponsor-bar {
  display: flex;
  gap: 8px;
  margin: 0.6rem 0 0.4rem;
  flex-wrap: wrap;
}
.sponsor-badge {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  padding: 3px 10px;
  border-radius: 20px;
  border: 1px solid;
  opacity: 0.85;
  backdrop-filter: blur(6px);
  transition: opacity 0.2s, transform 0.15s;
  cursor: default;
}
.sponsor-badge:hover { opacity: 1; transform: translateY(-1px); }
.sponsor-badge.nvidia {
  color: #76b900;
  border-color: #76b900;
  background: rgba(118, 185, 0, 0.08);
}
.sponsor-badge.stripe {
  color: #635bff;
  border-color: #635bff;
  background: rgba(99, 91, 255, 0.08);
}
.sponsor-badge.nous {
  color: #00aaff;
  border-color: #00aaff;
  background: rgba(0, 170, 255, 0.08);
}

/* ===== Live Metrics Bar ===== */
.metrics-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin: 0.5rem 0 1rem;
}
.metric-cell {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 6px 8px;
  text-align: center;
  backdrop-filter: blur(4px);
}
.metric-label {
  font-family: var(--mono);
  font-size: 0.6rem;
  letter-spacing: 0.08em;
  opacity: 0.5;
  text-transform: uppercase;
  margin-bottom: 2px;
}
.metric-value {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--text);
  word-break: break-all;
  transition: color 0.3s;
}
@keyframes metricPop {
  0%   { color: var(--ok); }
  100% { color: var(--text); }
}
.metric-live { animation: metricPop 1.2s ease forwards; }

/* ===== Technical Deep Dive Panel ===== */
.debug-panel {
  margin-top: 1rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  overflow: hidden;
  backdrop-filter: blur(6px);
  background: rgba(255, 255, 255, 0.02);
}
.debug-panel summary {
  padding: 0.6rem 1rem;
  cursor: pointer;
  font-family: var(--mono);
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  opacity: 0.7;
  list-style: none;
  border-bottom: 1px solid transparent;
  transition: opacity 0.2s, background 0.2s;
}
.debug-panel[open] summary {
  border-bottom-color: rgba(255, 255, 255, 0.08);
  opacity: 1;
  background: rgba(255, 255, 255, 0.03);
}
.debug-panel summary::-webkit-details-marker { display: none; }
.debug-panel summary::before {
  content: '▶ ';
  font-size: 0.6rem;
  opacity: 0.6;
}
.debug-panel[open] summary::before { content: '▼ '; }
.debug-content {
  padding: 0.5rem 0.75rem 0.75rem;
}
.debug-section {
  margin-bottom: 0.8rem;
  padding-bottom: 0.8rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.debug-section:last-child { border-bottom: none; margin-bottom: 0; }
.debug-title {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  color: var(--accent);
  margin-bottom: 0.4rem;
}
.debug-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--mono);
  font-size: 0.7rem;
  padding: 2px 0;
  opacity: 0.85;
  gap: 8px;
}
.debug-row span:first-child { opacity: 0.55; }
.debug-row span:last-child { text-align: right; word-break: break-all; }
.debug-code {
  font-family: var(--mono);
  font-size: 0.65rem;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 4px;
  padding: 4px 8px;
  margin-top: 4px;
  word-break: break-all;
  color: var(--ok);
  opacity: 0.9;
}
.debug-label {
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  opacity: 0.45;
  margin-top: 0.4rem;
}
.debug-quote {
  font-family: var(--mono);
  font-size: 0.68rem;
  opacity: 0.8;
  border-left: 2px solid rgba(255, 255, 255, 0.15);
  padding-left: 8px;
  margin: 3px 0 6px;
  line-height: 1.5;
}

/* ===== Scenario Picker ===== */
.scenario-picker {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 1rem;
}
.scenario-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 8px 4px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  transition: border-color 0.2s, background 0.2s, transform 0.15s;
  color: var(--text);
  font: inherit;
}
.scenario-card:hover { background: rgba(255,255,255,0.07); transform: translateY(-1px); }
.scenario-card.active {
  border-color: var(--accent);
  background: rgba(255, 69, 0, 0.1);
  box-shadow: 0 0 12px rgba(255, 69, 0, 0.22);
}
.sc-icon { font-size: 1.2rem; }
.sc-name {
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.04em;
  text-align: center;
  line-height: 1.3;
}
.sc-badge {
  font-family: var(--mono);
  font-size: 0.55rem;
  letter-spacing: 0.05em;
  padding: 1px 5px;
  border-radius: 3px;
  border: 1px solid;
}
.sc-badge.pass { color: var(--ok); border-color: var(--ok); background: rgba(34,197,94,0.1); }
.sc-badge.fail { color: #ff6b6b; border-color: #ff6b6b; background: rgba(255,107,107,0.1); }

/* ===== Run row (voice + run button) ===== */
.run-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
  margin-bottom: 1rem;
}
.run-row #run-demo { flex: 1; margin: 0; }
.voice-btn {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 8px;
  padding: 0 14px;
  font-size: 1.1rem;
  cursor: pointer;
  color: var(--text);
  transition: background 0.2s, border-color 0.2s, box-shadow 0.2s;
  flex-shrink: 0;
}
.voice-btn:hover { background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.3); }
.voice-btn.listening {
  border-color: var(--accent);
  box-shadow: 0 0 14px rgba(255, 69, 0, 0.5);
  animation: pulse 0.8s ease-in-out infinite;
}

/* ===== Council Sequential Deliberation ===== */
.council-deliberation {
  margin-bottom: 0.7rem;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.agent-row {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}
.agent-label {
  font-family: var(--mono);
  font-size: 0.6rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 4px;
  flex-shrink: 0;
  margin-top: 3px;
  border: 1px solid;
}
.ember-row .agent-label { color: var(--accent); border-color: var(--accent); background: rgba(255,69,0,0.12); }
.umber-row .agent-label { color: #c8a876; border-color: #c8a876; background: rgba(200,168,118,0.1); }
.agent-text {
  font-family: var(--mono);
  font-size: 0.72rem;
  line-height: 1.55;
  opacity: 0.88;
  min-height: 1rem;
}
@keyframes agentFadeIn {
  from { opacity: 0; transform: translateX(-6px); }
  to   { opacity: 0.88; transform: translateX(0); }
}
.agent-row { animation: agentFadeIn 0.3s ease both; }

/* ===== SSE Streaming Preview ===== */
.stream-preview {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  background: rgba(118, 185, 0, 0.04);
}
.stream-header {
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.07em;
  color: #76b900;
  margin-bottom: 5px;
  opacity: 0.85;
  text-transform: uppercase;
}
.stream-header::before { content: '▶ '; font-size: 0.55rem; }
.stream-text {
  font-family: var(--mono);
  font-size: 0.7rem;
  line-height: 1.6;
  color: var(--text);
  opacity: 0.82;
  min-height: 2.5rem;
  max-height: 180px;
  overflow-y: auto;
  word-break: break-word;
}
@keyframes cursorBlink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}
.stream-text::after {
  content: '▌';
  font-size: 0.7rem;
  color: #76b900;
  animation: cursorBlink 1s step-end infinite;
  margin-left: 1px;
}

/* ===== FAIL state overrides ===== */
.proof-card.fail {
  border-color: var(--accent);
  box-shadow: 0 0 18px rgba(255, 69, 0, 0.35);
}

/* ===== System status bar ===== */
.system-status {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 0.6rem;
}
.sys-chip {
  display: flex;
  align-items: center;
  gap: 5px;
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.05em;
  padding: 3px 8px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.03);
  opacity: 0.65;
  transition: opacity 0.4s, border-color 0.4s;
}
.sys-chip.online { opacity: 1; border-color: rgba(34, 197, 94, 0.3); }
.sys-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #444;
  flex-shrink: 0;
  transition: background 0.4s;
}

/* ===== IBC Compliance panel ===== */
.compliance-panel {
  margin-top: 0.7rem;
  padding: 0.75rem;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  animation: fadeIn 0.3s ease both;
}
.compliance-title {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  color: var(--accent);
  margin-bottom: 0.5rem;
}
.ibc-rule {
  display: grid;
  grid-template-columns: 1.2rem 1fr auto auto;
  gap: 4px 8px;
  align-items: center;
  padding: 4px 0;
  font-family: var(--mono);
  font-size: 0.65rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}
.ibc-rule:last-child { border-bottom: none; }
.ibc-check { text-align: center; }
.ibc-rule.pass .ibc-check { color: var(--ok); }
.ibc-rule.fail .ibc-check { color: #ff6b6b; }
.ibc-label { opacity: 0.7; }
.ibc-val { font-weight: 600; text-align: right; }
.ibc-rule.pass .ibc-val { color: var(--ok); }
.ibc-rule.fail .ibc-val { color: #ff6b6b; }
.ibc-req { opacity: 0.4; text-align: right; }

/* ===== Hermes routing card ===== */
.hermes-card {
  margin-top: 0.7rem;
  padding: 0.75rem;
  background: rgba(0, 170, 255, 0.04);
  border: 1px solid rgba(0, 170, 255, 0.2);
  border-radius: 10px;
  animation: fadeIn 0.3s ease both;
}
.hermes-header {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  color: #00aaff;
  margin-bottom: 0.5rem;
}
.hermes-pipeline {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 0.4rem;
}
.agent-chip {
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.04em;
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid;
}
.agent-chip.active {
  color: #00aaff;
  border-color: #00aaff;
  background: rgba(0, 170, 255, 0.1);
}
.agent-chip.blocked {
  color: #444;
  border-color: #333;
  background: transparent;
  text-decoration: line-through;
  opacity: 0.55;
}
.pipeline-arrow {
  font-family: var(--mono);
  font-size: 0.7rem;
  opacity: 0.35;
  margin: 0 1px;
}
.hermes-rationale {
  font-family: var(--mono);
  font-size: 0.65rem;
  line-height: 1.55;
  opacity: 0.7;
  border-left: 2px solid rgba(0, 170, 255, 0.22);
  padding-left: 8px;
  margin-top: 4px;
}

/* ===== Stripe receipt card ===== */
.stripe-receipt {
  margin-top: 0.7rem;
  padding: 0.75rem;
  background: rgba(99, 91, 255, 0.05);
  border: 1px solid rgba(99, 91, 255, 0.25);
  border-radius: 10px;
  animation: fadeIn 0.3s ease both;
}
.receipt-header {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  color: #635bff;
  margin-bottom: 0.5rem;
}
.receipt-rows { display: flex; flex-direction: column; gap: 4px; }
.receipt-row {
  display: flex;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 0.68rem;
  opacity: 0.88;
}
.receipt-row span:first-child { opacity: 0.55; }
.receipt-ok { color: var(--ok); font-weight: 600; }
.receipt-id {
  font-family: var(--mono);
  font-size: 0.6rem;
  color: #635bff;
  opacity: 0.7;
  word-break: break-all;
  margin-top: 6px;
  padding: 3px 6px;
  background: rgba(99, 91, 255, 0.08);
  border-radius: 4px;
}

/* ===== Compare scenarios ===== */
.compare-btn {
  margin-top: 0.8rem;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.18);
  padding: 10px 16px;
  font-size: 0.88rem;
  border-radius: 8px;
  cursor: pointer;
  width: 100%;
  color: var(--text);
  font-family: var(--mono);
  letter-spacing: 0.04em;
  transition: border-color 0.2s, background 0.2s;
}
.compare-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.35);
}
.compare-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.comparison-table {
  margin-top: 0.6rem;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
  animation: fadeIn 0.3s ease both;
}
.comp-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--mono);
  font-size: 0.68rem;
}
.comp-table th {
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.04);
  text-align: left;
  letter-spacing: 0.05em;
  opacity: 0.55;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.comp-table td {
  padding: 7px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.comp-row.fail-row { background: rgba(255, 69, 0, 0.06); }
.comp-loading {
  font-family: var(--mono);
  font-size: 0.75rem;
  padding: 1rem;
  opacity: 0.6;
  text-align: center;
}

/* ===== φ-Harmony confidence gauge ===== */
.harmony-gauge {
  display: flex;
  justify-content: center;
  margin: 0.5rem 0 0.6rem;
  animation: fadeIn 0.4s ease both;
}
.gauge-svg { width: 108px; height: 108px; }
.gauge-track {
  fill: none;
  stroke: rgba(255, 255, 255, 0.07);
  stroke-width: 8;
}
.gauge-arc {
  fill: none;
  stroke: var(--accent);
  stroke-width: 8;
  stroke-linecap: round;
  transform-origin: 50px 50px;
  transform: rotate(-90deg);
  transition: stroke-dashoffset 1.3s cubic-bezier(0.34, 1.56, 0.64, 1),
              stroke 0.4s ease;
}
.gauge-label {
  fill: #fff;
  font-size: 16px;
  font-weight: bold;
  text-anchor: middle;
  dominant-baseline: middle;
  font-family: var(--mono);
}
.gauge-sub {
  fill: rgba(255, 255, 255, 0.38);
  font-size: 6.5px;
  text-anchor: middle;
  dominant-baseline: middle;
  font-family: var(--mono);
  letter-spacing: 0.07em;
}

/* ===== Certificate download button ===== */
.cert-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0.6rem auto;
  padding: 0.45rem 1.2rem;
  background: rgba(255, 122, 60, 0.1);
  border: 1px solid rgba(255, 122, 60, 0.38);
  border-radius: 20px;
  color: #ffaa70;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, transform 0.15s;
  animation: fadeIn 0.4s ease both;
}
.cert-btn:hover {
  background: rgba(255, 122, 60, 0.2);
  border-color: rgba(255, 122, 60, 0.65);
  transform: translateY(-1px);
}
.cert-btn:active { transform: translateY(0); }
.cert-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.cert-btn-wrap { text-align: center; }

/* ===== Execution Graph ===== */
.exec-graph-panel {
  margin: 16px 0;
  padding: 12px 14px;
  background: rgba(255, 69, 0, 0.04);
  border: 1px solid rgba(255, 69, 0, 0.18);
  border-radius: 10px;
}
.eg-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.eg-title {
  font-size: 0.7rem;
  font-family: var(--mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  opacity: 0.8;
}
.eg-intent-id {
  font-size: 0.6rem;
  font-family: var(--mono);
  color: rgba(255, 255, 255, 0.3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 55%;
}
.exec-graph { display: flex; flex-direction: column; }
.eg-node {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 4px 0;
  transition: opacity 0.25s ease;
}
.eg-pending { opacity: 0.55; }
.eg-connector {
  width: 2px;
  height: 8px;
  margin-left: 8px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.10);
  transition: background 0.4s ease;
}
/* Live edge: the execution wave has passed through. A travelling highlight
   reads as data flowing downstream rather than a static rule. */
.eg-connector-live {
  background: linear-gradient(rgba(34, 197, 94, 0.15), rgba(34, 197, 94, 0.5));
  background-size: 100% 200%;
  animation: egFlow 1.1s linear infinite;
}
.eg-connector-dead { background: rgba(239, 68, 68, 0.4); }
@keyframes egFlow {
  from { background-position: 0 -200%; }
  to   { background-position: 0 200%; }
}
.eg-icon {
  width: 16px;
  text-align: center;
  font-size: 0.7rem;
  line-height: 1.4;
  flex-shrink: 0;
  transition: color 0.25s ease, transform 0.25s ease;
}
.eg-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 4px;
  min-width: 0;
}
.eg-header-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}
.eg-label {
  font-size: 0.78rem;
  font-family: var(--mono);
  color: var(--text);
  white-space: nowrap;
}
.eg-meta {
  font-size: 0.62rem;
  font-family: var(--mono);
  color: rgba(255, 255, 255, 0.35);
  white-space: nowrap;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Evidence chips — the artifacts each completed stage emits */
.eg-evidence {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.eg-chip {
  font-size: 0.58rem;
  font-family: var(--mono);
  letter-spacing: 0.02em;
  padding: 1px 6px;
  border-radius: 5px;
  background: rgba(34, 197, 94, 0.08);
  border: 1px solid rgba(34, 197, 94, 0.22);
  color: rgba(190, 242, 200, 0.9);
  white-space: nowrap;
  animation: egChipIn 0.32s ease both;
}
.eg-failed .eg-chip {
  background: rgba(239, 68, 68, 0.08);
  border-color: rgba(239, 68, 68, 0.3);
  color: rgba(254, 202, 202, 0.9);
}
@keyframes egChipIn {
  from { opacity: 0; transform: translateY(-3px); }
  to   { opacity: 1; transform: translateY(0); }
}
/* State colours */
.eg-pending .eg-icon { color: rgba(255, 255, 255, 0.25); }
.eg-running .eg-icon {
  color: var(--accent-2);
  animation: egPulse 0.9s ease-in-out infinite;
}
.eg-running .eg-label { color: var(--accent-2); }
.eg-running .eg-meta { color: var(--accent-2); opacity: 0.7; }
.eg-success .eg-icon { color: var(--ok); }
.eg-success .eg-meta { color: rgba(34, 197, 94, 0.55); }
.eg-failed .eg-icon { color: #ef4444; }
.eg-failed .eg-label { color: #ef4444; }
.eg-failed .eg-meta { color: rgba(239, 68, 68, 0.7); }
@keyframes egPulse {
  0%, 100% { transform: scale(1);   opacity: 1; }
  50%      { transform: scale(1.3); opacity: 0.6; }
}

/* ===== Self-Healing runtime ===== */
.self-healing-panel {
  margin: 16px 0;
  padding: 12px 14px;
  background: rgba(34, 197, 94, 0.04);
  border: 1px solid rgba(34, 197, 94, 0.18);
  border-radius: 10px;
  transition: border-color 0.3s, background 0.3s;
}
.sh-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.sh-title {
  font-size: 0.7rem;
  font-family: var(--mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ok);
  opacity: 0.85;
}
.sh-fault-btn {
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.04em;
  padding: 4px 10px;
  border-radius: 14px;
  background: rgba(255, 69, 0, 0.12);
  border: 1px solid rgba(255, 69, 0, 0.4);
  color: #ffb08a;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}
.sh-fault-btn:hover { background: rgba(255, 69, 0, 0.22); }
.sh-fault-btn:active { transform: scale(0.96); }
.sh-fault-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.self-healing { display: flex; flex-direction: column; gap: 8px; }
.sh-statusline {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}
.sh-badge {
  font-family: var(--mono);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  transition: color 0.3s;
}
.sh-metric { font-family: var(--mono); font-size: 0.7rem; color: rgba(255, 255, 255, 0.55); }
.sh-metric strong { color: var(--text); }
.sh-min { opacity: 0.5; }

/* Yield gauge with the IBC threshold marker */
.sh-gauge {
  position: relative;
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}
.sh-gauge-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--ok);
  transition: width 0.4s ease, background 0.3s;
}
.sh-gauge-threshold {
  position: absolute;
  top: -2px; bottom: -2px;
  /* IBC min 36 ksi mapped onto the 20–45 ksi gauge range */
  left: 64%;
  width: 2px;
  background: rgba(255, 255, 255, 0.6);
}

.sh-trace { display: flex; flex-direction: column; gap: 2px; }
.sh-line {
  font-family: var(--mono);
  font-size: 0.62rem;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.5);
  animation: fadeIn 0.25s ease both;
}
.sh-line.sh-fault     { color: var(--accent-2); }
.sh-line.sh-violation { color: #ef4444; }
.sh-line.sh-rollback  { color: #a78bfa; }
.sh-line.sh-healed    { color: var(--ok); }

/* State theming of the whole panel */
.sh-state-safe   .sh-badge { color: var(--ok); }
.sh-state-fail   .sh-badge { color: #ef4444; }
.sh-state-rollback .sh-badge { color: #a78bfa; }
.sh-state-healed .sh-badge { color: var(--ok); }
.self-healing-panel:has(.sh-state-fail) { border-color: rgba(239, 68, 68, 0.5); background: rgba(239, 68, 68, 0.05); }
.self-healing-panel:has(.sh-state-rollback) { border-color: rgba(167, 139, 250, 0.5); background: rgba(167, 139, 250, 0.05); }
.self-healing-panel:has(.sh-state-fail) .sh-gauge-fill { background: #ef4444; }

/* Choreography: fault shake + rollback rewind sweep */
.sh-shake { animation: shShake 0.5s cubic-bezier(.36,.07,.19,.97) both; }
@keyframes shShake {
  10%, 90% { transform: translateX(-1px); }
  20%, 80% { transform: translateX(2px); }
  30%, 50%, 70% { transform: translateX(-4px); }
  40%, 60% { transform: translateX(4px); }
}
.sh-rewind { position: relative; overflow: hidden; }
.sh-rewind::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(167, 139, 250, 0.25), transparent);
  animation: shRewind 0.7s ease both;
  pointer-events: none;
}
@keyframes shRewind {
  from { transform: translateX(100%); }
  to   { transform: translateX(-100%); }
}

/* ===== Choreography: ambient intensification while a run is live ===== */
body.demo-live::before { animation-duration: 9s; opacity: 0.7; }
body.with-music::before { opacity: 0.85; }
.music-btn.playing, #music-btn.playing { color: var(--accent-2); }

/* ===== Small screens ===== */
@media (max-width: 360px) {
  header h1 { font-size: 1.6rem; }
  #steps { font-size: 1.1rem; }
}

/* ===== Reduced motion ===== */
@media (prefers-reduced-motion: reduce) {
  *, *::before { animation: none !important; transition: none !important; }
}
