:root {
  color-scheme: dark;
  --canvas: #06111d;
  --canvas-deep: #030a12;
  --canvas-raised: #0a1724;
  --surface: #0d1b29;
  --surface-strong: #102233;
  --rule: #223447;
  --rule-strong: #3a5065;
  --text: #f4f7f9;
  --text-secondary: #b5c0cc;
  --text-quiet: #7d8ca0;
  --teal: #41d8bd;
  --teal-strong: #22c7a8;
  --amber: #f8b924;
  --coral: #ff655f;
  --locked: #69788b;
  --gradient-action: linear-gradient(135deg, #78f0da 0%, var(--teal) 46%, #1da7b4 100%);
  --gradient-glass: linear-gradient(145deg, rgba(19, 45, 61, 0.9), rgba(7, 19, 30, 0.76));
  --gradient-workspace:
    radial-gradient(ellipse at 18% 8%, rgba(65, 216, 189, 0.18), transparent 34%),
    radial-gradient(ellipse at 88% 18%, rgba(248, 185, 36, 0.1), transparent 28%),
    radial-gradient(ellipse at 72% 72%, rgba(255, 101, 95, 0.065), transparent 34%),
    linear-gradient(145deg, #071725 0%, var(--canvas) 46%, var(--canvas-deep) 100%);
  --sans: Inter, "Avenir Next", "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "SFMono-Regular", "Cascadia Code", "Roboto Mono", ui-monospace, monospace;
  --content-max: 1480px;
  --focus: 0 0 0 3px rgba(65, 216, 189, 0.26);
}

* {
  box-sizing: border-box;
}

html {
  color: var(--text);
  background: var(--canvas-deep);
  font-family: var(--sans);
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background: var(--gradient-workspace);
  background-attachment: fixed;
}

button,
input,
textarea {
  font: inherit;
}

button {
  color: inherit;
}

button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 3px;
  box-shadow: var(--focus);
}

.skip-link {
  position: fixed;
  z-index: 50;
  top: -80px;
  left: 12px;
  padding: 10px 14px;
  color: var(--canvas-deep);
  background: var(--teal);
  transition: top 140ms ease;
}

.skip-link:focus {
  top: 12px;
}

.app-header {
  position: relative;
  z-index: 5;
  display: grid;
  grid-template-columns: minmax(270px, 1fr) auto minmax(430px, 1fr);
  align-items: center;
  min-height: 78px;
  padding: 0 max(28px, calc((100vw - var(--content-max)) / 2));
  border-bottom: 1px solid rgba(58, 80, 101, 0.58);
  background:
    linear-gradient(90deg, rgba(8, 31, 42, 0.92), rgba(4, 13, 22, 0.8) 50%, rgba(27, 22, 27, 0.78));
  backdrop-filter: blur(18px);
}

.brand-lockup,
.header-context,
.header-actions,
.recovery-heading,
.recovery-meta,
.guide-actions,
.card-heading,
.card-title-lockup,
.evidence-heading,
.receipt-heading,
.ledger-heading,
.ledger-actions {
  display: flex;
  align-items: center;
}

.brand-lockup {
  gap: 12px;
}

.brand-mark {
  display: grid;
  flex: 0 0 38px;
  place-items: center;
  width: 38px;
  height: 38px;
  color: var(--canvas-deep);
  background: var(--gradient-action);
  border-radius: 11px;
  box-shadow: 0 0 32px rgba(65, 216, 189, 0.28);
}

.brand-mark i {
  font-size: 23px;
}

.brand-name,
.brand-tagline,
.section-label,
.judge-orientation,
.guide-kicker,
.guide-copy,
.policy-copy,
.incident-brief,
.required-action-label,
.required-action p,
.gate-callout p,
.empty-copy {
  margin: 0;
}

.brand-name {
  font-size: 20px;
  line-height: 24px;
  font-weight: 680;
  letter-spacing: -0.025em;
}

.brand-tagline {
  margin-top: 1px;
  color: var(--text-quiet);
  font-size: 12px;
  line-height: 17px;
}

.header-context {
  justify-content: center;
  gap: 14px;
  color: var(--text-secondary);
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.02em;
}

.header-separator {
  width: 1px;
  height: 15px;
  background: var(--rule-strong);
}

.header-actions {
  justify-content: flex-end;
  gap: 10px;
}

.connection-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-right: 6px;
  color: var(--text-secondary);
  font-size: 12px;
  white-space: nowrap;
}

.connection-dot {
  width: 8px;
  height: 8px;
  border: 1px solid currentColor;
  border-radius: 50%;
}

.connection-status.is-connected {
  color: var(--teal);
}

.connection-status.is-connected .connection-dot {
  background: currentColor;
  box-shadow: 0 0 12px currentColor;
}

.connection-status.is-unavailable {
  color: var(--amber);
}

.quiet-button,
.primary-button,
.text-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 44px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
}

.quiet-button {
  padding: 0 15px;
  border: 1px solid var(--rule-strong);
  color: var(--text-secondary);
  background: rgba(8, 20, 32, 0.66);
}

.quiet-button:hover {
  color: var(--text);
  border-color: var(--text-quiet);
  background: var(--surface);
}

.primary-button {
  min-width: 220px;
  padding: 0 20px;
  border: 1px solid var(--teal);
  color: #02110e;
  background: var(--gradient-action);
  box-shadow: 0 14px 34px rgba(34, 199, 168, 0.24), inset 0 1px rgba(255, 255, 255, 0.3);
}

.primary-button:hover {
  filter: brightness(1.08) saturate(1.04);
  transform: translateY(-1px);
}

.quiet-button i,
.primary-button i,
.text-button i {
  font-size: 18px;
}

.app-shell {
  width: min(100%, var(--content-max));
  margin: 0 auto;
  padding: 0 26px 20px;
}

.recovery-stage {
  position: relative;
  padding: 20px 8px 6px;
}

.recovery-heading {
  align-items: flex-start;
  justify-content: space-between;
  gap: 42px;
}

.section-label {
  color: var(--text-quiet);
  font-size: 10px;
  line-height: 15px;
  font-weight: 750;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.recovery-heading h1 {
  max-width: 760px;
  margin: 0;
  font-size: clamp(38px, 4.1vw, 58px);
  line-height: 1.02;
  font-weight: 670;
  letter-spacing: -0.047em;
}

.judge-orientation {
  max-width: 1040px;
  margin-top: 10px;
  color: var(--text-secondary);
  font-size: clamp(15px, 1.15vw, 17px);
  line-height: 1.55;
}

.recovery-meta {
  flex: 0 0 auto;
  align-items: flex-end;
  flex-direction: column;
  gap: 9px;
}

.revision-label,
.status-badge,
.policy-pill,
.rail-count,
.receipt-state,
.gate-state,
.ledger-count {
  font-family: var(--mono);
  font-size: 11px;
  white-space: nowrap;
}

.revision-label,
.status-badge {
  padding: 6px 9px;
  border: 1px solid var(--rule-strong);
  border-radius: 4px;
  color: var(--text-secondary);
  background: rgba(8, 20, 32, 0.62);
}

.status-badge {
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.status-badge.is-warning {
  color: var(--amber);
  border-color: rgba(248, 185, 36, 0.52);
}

.status-badge.is-ready,
.status-badge.is-resolved {
  color: var(--teal);
  border-color: rgba(65, 216, 189, 0.5);
}

.policy-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  color: var(--amber);
  border: 1px solid rgba(248, 185, 36, 0.62);
  border-radius: 6px;
}

.policy-pill i {
  font-size: 17px;
}

.recovery-progress {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  max-width: 1160px;
  margin: 20px auto 0;
  padding: 0;
  list-style: none;
}

.state-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1160px;
  margin: 16px auto -8px;
  color: var(--text-quiet);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.state-heading span:first-child {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--teal);
}

.state-heading i {
  font-size: 14px;
}

.progress-step {
  position: relative;
  min-width: 0;
  padding: 0 18px;
  text-align: center;
}

.progress-step:not(:last-child)::after {
  content: "";
  position: absolute;
  z-index: 0;
  top: 21px;
  left: calc(50% + 22px);
  width: calc(100% - 44px);
  height: 2px;
  background: var(--rule-strong);
}

.progress-step.is-complete:not(:last-child)::after {
  background: var(--teal);
}

.progress-step.is-blocked:not(:last-child)::after {
  background: var(--coral);
}

.step-number {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin: 0 auto;
  border: 2px solid var(--rule-strong);
  border-radius: 50%;
  color: var(--text-secondary);
  background: var(--canvas);
  font-family: var(--mono);
  font-size: 17px;
  box-shadow: 0 0 0 5px var(--canvas);
}

.progress-step.is-complete .step-number {
  color: var(--teal);
  border-color: var(--teal);
}

.progress-step.is-active .step-number {
  color: var(--canvas-deep);
  border-color: var(--teal);
  background: var(--teal);
  box-shadow: 0 0 0 5px var(--canvas), 0 0 26px rgba(65, 216, 189, 0.22);
}

.progress-step.is-blocked .step-number {
  color: white;
  border-color: var(--coral);
  background: var(--coral);
  box-shadow: 0 0 0 5px var(--canvas), 0 0 26px rgba(255, 101, 95, 0.24);
}

.step-label {
  margin: 10px 0 0;
  color: var(--text);
  font-size: 14px;
  line-height: 20px;
  font-weight: 680;
}

.step-detail {
  margin: 4px 0 0;
  color: var(--text-quiet);
  font-size: 12px;
  line-height: 18px;
}

.progress-step.is-complete .step-detail {
  color: var(--teal);
}

.progress-step.is-blocked .step-detail {
  color: var(--coral);
}

.webmcp-help {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 14px;
  max-width: 1180px;
  margin: 14px auto 0;
  padding: 15px 17px;
  border: 1px solid rgba(248, 185, 36, 0.52);
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(50, 38, 12, 0.72), rgba(13, 27, 41, 0.86));
}

.webmcp-help[hidden] {
  display: none;
}

.webmcp-help-icon {
  color: var(--amber);
  font-size: 22px;
  line-height: 1;
}

.webmcp-help-body h2 {
  margin: 0 0 6px;
  color: var(--amber);
  font-size: 15px;
}

.webmcp-help-body p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 13px;
}

.webmcp-help-options {
  margin: 9px 0 0;
  padding-left: 18px;
  color: var(--text-secondary);
  font-size: 13px;
}

.webmcp-help-options li + li {
  margin-top: 5px;
}

.webmcp-help-options strong {
  color: var(--text);
}

.webmcp-help-options code {
  display: inline-block;
  max-width: 100%;
  overflow-x: auto;
  padding: 2px 6px;
  color: var(--amber);
  border: 1px solid rgba(248, 185, 36, 0.34);
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.28);
  font-family: var(--mono);
  font-size: 12px;
  vertical-align: baseline;
}

.webmcp-help-body .webmcp-help-note {
  margin-top: 9px;
  color: var(--text-quiet);
  font-size: 12px;
}

.recovery-guide {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) auto;
  gap: 12px 24px;
  max-width: 1180px;
  margin: 14px auto 0;
  padding: 15px 17px;
  overflow: hidden;
  border: 1px solid rgba(65, 216, 189, 0.34);
  border-radius: 16px;
  background:
    radial-gradient(circle at 8% 0%, rgba(65, 216, 189, 0.19), transparent 34%),
    radial-gradient(circle at 92% 100%, rgba(248, 185, 36, 0.09), transparent 34%),
    linear-gradient(135deg, rgba(15, 43, 57, 0.92), rgba(7, 18, 30, 0.88) 52%, rgba(21, 24, 34, 0.86));
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.28), inset 0 1px rgba(255, 255, 255, 0.055);
  backdrop-filter: blur(18px);
  text-align: left;
}

.activation-main {
  min-width: 0;
}

.activation-heading {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.activation-icon {
  display: grid;
  flex: 0 0 38px;
  place-items: center;
  width: 38px;
  height: 38px;
  color: var(--canvas-deep);
  border-radius: 11px;
  background: var(--gradient-action);
  box-shadow: 0 10px 28px rgba(65, 216, 189, 0.2);
}

.activation-icon i {
  font-size: 21px;
}

.activation-heading h2 {
  margin: 0;
  color: var(--text);
  font-size: 17px;
  line-height: 22px;
  font-weight: 680;
  letter-spacing: -0.02em;
}

.activation-heading p {
  max-width: 720px;
  margin: 3px 0 0;
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 18px;
}

.activation-steps {
  display: flex;
  flex-wrap: wrap;
  gap: 7px 14px;
  margin: 10px 0 0 50px;
  padding: 0;
  color: var(--text-secondary);
  list-style: none;
  font-size: 11px;
  line-height: 18px;
}

.activation-steps li {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.activation-steps span {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  color: var(--teal);
  border: 1px solid rgba(65, 216, 189, 0.48);
  border-radius: 50%;
  font-family: var(--mono);
  font-size: 9px;
}

.agent-next-action {
  margin: 8px 0 0 50px;
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 18px;
}

.agent-next-action strong {
  color: var(--text);
}

.activation-controls {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  flex-direction: column;
  gap: 8px;
}

.agent-activity {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-height: 22px;
  color: var(--text-quiet);
  font-family: var(--mono);
  font-size: 10px;
  line-height: 15px;
  text-align: right;
}

.agent-activity-dot {
  flex: 0 0 7px;
  width: 7px;
  height: 7px;
  border: 1px solid currentColor;
  border-radius: 50%;
}

.agent-activity.is-ready,
.agent-activity.is-active {
  color: var(--teal);
}

.agent-activity.is-ready .agent-activity-dot,
.agent-activity.is-active .agent-activity-dot {
  background: currentColor;
  box-shadow: 0 0 12px currentColor;
}

.agent-activity.is-active .agent-activity-dot {
  animation: agent-pulse 1.25s ease-in-out 2;
}

.agent-activity.is-unavailable {
  color: var(--amber);
}

.guide-actions {
  justify-content: flex-end;
  gap: 12px;
  margin: 0;
}

.prompt-toggle[aria-expanded="true"] i {
  transform: rotate(90deg);
}

.prompt-preview {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 18px;
  align-items: start;
  max-width: none;
  margin: 0;
  padding: 10px 14px;
  overflow: hidden;
  border: 1px solid var(--rule);
  border-radius: 9px;
  background: linear-gradient(90deg, rgba(5, 18, 28, 0.86), rgba(10, 29, 41, 0.72));
  text-align: left;
}

.prompt-label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--teal);
  font-size: 12px;
  white-space: nowrap;
}

.prompt-label i {
  font-size: 17px;
}

.prompt-preview code {
  overflow: hidden;
  color: var(--text-secondary);
  font-family: var(--mono);
  font-size: 11px;
  line-height: 18px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.prompt-preview.is-expanded code {
  overflow: visible;
  white-space: normal;
}

.choreography-stage {
  --machine-accent: var(--teal);
  max-width: 1320px;
  margin: 20px auto 4px;
  overflow: hidden;
  border: 1px solid rgba(65, 216, 189, 0.34);
  border-radius: 16px;
  background:
    radial-gradient(circle at 14% 4%, rgba(65, 216, 189, 0.14), transparent 30%),
    radial-gradient(circle at 88% 100%, rgba(248, 185, 36, 0.09), transparent 32%),
    linear-gradient(145deg, rgba(12, 35, 49, 0.96), rgba(5, 16, 27, 0.94));
  box-shadow: 0 30px 86px rgba(0, 0, 0, 0.3), inset 0 1px rgba(255, 255, 255, 0.055);
}

.choreography-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 28px;
  padding: 18px 20px 16px;
  border-bottom: 1px solid var(--rule);
}

.choreography-heading h2 {
  margin: 3px 0 0;
  font-size: clamp(22px, 2.4vw, 32px);
  line-height: 1.12;
  letter-spacing: -0.035em;
}

.choreography-intro {
  max-width: 790px;
  margin: 7px 0 0;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 20px;
}

.choreography-counter {
  display: flex;
  align-items: flex-end;
  flex-direction: column;
  gap: 5px;
  min-width: 180px;
  color: var(--text-quiet);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.choreography-counter strong {
  color: var(--machine-accent);
  font-size: 12px;
  transition: color 180ms ease;
}

.choreography-body {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(310px, 0.75fr);
  min-height: 410px;
}

.mill-panel {
  position: relative;
  min-width: 0;
  overflow: hidden;
  border-right: 1px solid var(--rule);
  background:
    linear-gradient(180deg, rgba(4, 16, 25, 0.14), rgba(3, 10, 18, 0.62)),
    radial-gradient(circle at 56% 52%, rgba(65, 216, 189, 0.075), transparent 42%);
}

.machine-readout {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 4px 16px;
  align-items: baseline;
  padding: 14px 18px 8px;
}

.machine-kicker {
  grid-row: 1 / span 2;
  max-width: 150px;
  color: var(--text-quiet);
  font-family: var(--mono);
  font-size: 9px;
  line-height: 14px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.machine-readout strong {
  color: var(--machine-accent);
  font-family: var(--mono);
  font-size: 12px;
  line-height: 18px;
  transition: color 180ms ease;
}

.machine-readout p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 11px;
  line-height: 17px;
}

.arrastra-scene {
  display: block;
  width: 100%;
  height: auto;
  min-height: 260px;
  max-height: 318px;
  overflow: visible;
}

.scene-sky { fill: url(#relay-sky); }
.scene-hill { fill: #1b3841; opacity: 0.72; }
.scene-hill.is-back { fill: #18323d; opacity: 0.7; }
.scene-hill.is-front { fill: #28464a; opacity: 0.76; }
.scene-ground { fill: url(#relay-ground); }
.scene-pines { fill: #102b31; opacity: 0.82; }
.scene-fence { fill: none; stroke: #6f6b59; stroke-width: 3; opacity: 0.44; }
.scene-label { fill: #b5c0cc; font: 700 9px var(--mono); letter-spacing: 0.09em; }

.scene-miner {
  opacity: 0.52;
  transition: opacity 180ms ease, filter 180ms ease;
}

.miner-head { fill: #af8968; stroke: #d3b08a; stroke-width: 1.5; }
.miner-hat { fill: var(--amber); stroke: #ffd679; stroke-width: 1.5; }
.miner-body { fill: #365c66; stroke: #74a1a7; stroke-width: 2; }
.miner-limb { fill: none; stroke: #8aa3a8; stroke-width: 6; stroke-linecap: round; }
.miner-bucket {
  transform-box: fill-box;
  transform-origin: 8% 55%;
}
.miner-bucket > path:first-child { fill: #273c43; stroke: #91a6aa; stroke-width: 2; }
.ore-rock { fill: url(#relay-ore); stroke: #3a3a36; stroke-width: 1; }

.arrastra-shadow { fill: rgba(0, 0, 0, 0.38); }
.arrastra-rim { fill: url(#relay-stone-wall); stroke: #aaa89b; stroke-width: 4; }
.arrastra-bed { fill: url(#relay-bed); stroke: #454640; stroke-width: 2; }
.ring-masonry ellipse { fill: url(#relay-stone); stroke: #464944; stroke-width: 1.4; }
.ore-load path {
  fill: url(#relay-ore);
  stroke: #292c2a;
  stroke-width: 1.4;
  opacity: 0;
  transform-box: fill-box;
  transform-origin: center;
  transition: opacity 260ms ease, fill 260ms ease, transform 420ms ease;
}
.arrastra-post { fill: url(#relay-wood); stroke: #b09773; stroke-width: 2; }
.post-brace { fill: none; stroke: #695441; stroke-width: 6; stroke-linecap: round; }
.arrastra-hub { fill: #07141d; stroke: var(--machine-accent); stroke-width: 3; transition: stroke 180ms ease; }
.sweep-trace { fill: none; stroke: rgba(177, 156, 119, 0.34); stroke-width: 2; stroke-dasharray: 8 8; }

.donkey-orbit {
  transform-origin: 378px 103px;
}
.timber-beam { stroke: url(#relay-wood); stroke-width: 12; stroke-linecap: round; }
.beam-highlight { stroke: rgba(221, 190, 146, 0.42); stroke-width: 2; stroke-linecap: round; }
.drag-chain { fill: none; stroke: #4d5554; stroke-width: 3; stroke-dasharray: 4 3; }
.drag-stone .stone-body { fill: url(#relay-stone); stroke: #c1bdb0; stroke-width: 2; }
.drag-stone .stone-groove { fill: none; stroke: #4f514d; stroke-width: 2.3; opacity: 0.82; }
.mill-dust { opacity: 0; transition: opacity 160ms ease; }
.dust-puff {
  fill: #b39a72;
  opacity: 0.34;
  transform-box: fill-box;
  transform-origin: center;
}
.dust-puff:nth-child(2) { animation-delay: 420ms; }
.dust-puff:nth-child(3) { animation-delay: 820ms; }
.robot-donkey {
  transform-box: fill-box;
  transform-origin: center;
}
.donkey-harness { fill: none; stroke: #9a7048; stroke-width: 4; stroke-linecap: round; }
.donkey-body { fill: url(#relay-iron); stroke: #68cdbb; stroke-width: 2; }
.donkey-panel { fill: #0a1b25; stroke: #65b9e8; stroke-width: 2; }
.donkey-neck,
.donkey-leg,
.donkey-tail { fill: none; stroke: #7592a0; stroke-width: 6; stroke-linecap: round; }
.donkey-eye { fill: var(--teal); filter: drop-shadow(0 0 5px var(--teal)); }
.donkey-ear { fill: #7592a0; }
.donkey-leg {
  transform-box: fill-box;
  transform-origin: top center;
}
.donkey-leg.leg-2,
.donkey-leg.leg-4 { animation-direction: alternate-reverse; }

.agent-hologram { opacity: 0.16; transition: opacity 180ms ease, filter 180ms ease; }
.agent-panel { fill: rgba(4, 17, 25, 0.92); stroke: var(--machine-accent); stroke-width: 2; }
.agent-core { fill: var(--machine-accent); }
.agent-eye { fill: #06111b; }
.agent-workline {
  fill: none;
  stroke: var(--machine-accent);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-dasharray: 10 8;
}
.gate-lock { opacity: 0; transform: translateY(-24px); transition: opacity 120ms ease, transform 220ms ease; }
.gate-bar { fill: var(--coral); filter: drop-shadow(0 0 8px rgba(255, 101, 95, 0.72)); }
.gate-text { fill: #fff4f2; font: 800 10px var(--mono); letter-spacing: 0.07em; }
.proof-sparks { opacity: 0; transition: opacity 180ms ease; }
.proof-sparks circle {
  fill: var(--amber);
  transform-box: fill-box;
  transform-origin: center;
}
.proof-sparks circle:nth-child(2) { animation-delay: 160ms; }
.proof-sparks circle:nth-child(3) { animation-delay: 320ms; }
.receipt-output { opacity: 0; transform: translateX(-34px); transition: opacity 220ms ease, transform 420ms ease; }
.receipt-body { fill: #e8f5f2; stroke: var(--teal); stroke-width: 2; }
.receipt-line { stroke: #4d6e74; stroke-width: 2; }
.receipt-check { fill: var(--teal); }

.choreography-stage[data-mode="blocked"] { --machine-accent: var(--coral); }
.choreography-stage[data-mode="verify"] { --machine-accent: var(--amber); }
.choreography-stage[data-mode="audit"] { --machine-accent: #aeb9c7; }
.choreography-stage[data-mode="transfer"] .scene-miner,
.choreography-stage.is-dumping .scene-miner { opacity: 1; filter: saturate(1.15); }
.choreography-stage[data-mode="intake"] .agent-hologram,
.choreography-stage[data-mode="transfer"] .agent-hologram,
.choreography-stage[data-mode="resume"] .agent-hologram,
.choreography-stage[data-mode="blocked"] .agent-hologram,
.choreography-stage[data-mode="verify"] .agent-hologram,
.choreography-stage[data-mode="commit"] .agent-hologram { opacity: 0.52; }
.choreography-stage.is-agent-working .agent-hologram { opacity: 1; filter: drop-shadow(0 0 10px rgba(65, 216, 189, 0.46)); }
.choreography-stage[data-mode="transfer"] .ore-load path,
.choreography-stage[data-mode="resume"] .ore-load path,
.choreography-stage[data-mode="blocked"] .ore-load path,
.choreography-stage[data-mode="verify"] .ore-load path { opacity: 1; }
.choreography-stage[data-mode="commit"] .ore-load path,
.choreography-stage[data-mode="audit"] .ore-load path {
  fill: var(--teal);
  opacity: 0.72;
  transform: scale(0.58);
}
.choreography-stage[data-mode="blocked"] .gate-lock { opacity: 1; transform: translateY(0); }
.choreography-stage[data-mode="verify"] .proof-sparks,
.choreography-stage.is-verifying .proof-sparks { opacity: 1; }
.choreography-stage[data-mode="commit"] .receipt-output,
.choreography-stage[data-mode="audit"] .receipt-output,
.choreography-stage.is-receiving .receipt-output { opacity: 1; transform: translateX(0); }

.choreography-stage.is-dumping .miner-bucket { animation: relay-bucket-dump 1.75s ease-in-out 1 both; }
.choreography-stage.is-dumping .ore-rock { animation: relay-rock-drop 1.25s ease-in 1 both; }
.choreography-stage.is-dumping .ore-rock.rock-2 { animation-delay: 140ms; }
.choreography-stage.is-dumping .ore-rock.rock-3 { animation-delay: 280ms; }
.choreography-stage.is-agent-working .donkey-orbit,
.choreography-stage.is-call-pending .donkey-orbit,
.choreography-stage.is-agent-working .robot-donkey,
.choreography-stage.is-call-pending .robot-donkey,
.choreography-stage.is-agent-working .donkey-leg,
.choreography-stage.is-call-pending .donkey-leg,
.choreography-stage.is-agent-working .agent-workline,
.choreography-stage.is-call-pending .agent-workline,
.choreography-stage.is-agent-working .dust-puff,
.choreography-stage.is-call-pending .dust-puff,
.choreography-stage.is-verifying .donkey-orbit,
.choreography-stage.is-verifying .robot-donkey,
.choreography-stage.is-verifying .donkey-leg,
.choreography-stage.is-verifying .agent-workline,
.choreography-stage.is-verifying .dust-puff,
.choreography-stage.is-verifying .proof-sparks circle { animation-play-state: running; }
.choreography-stage.is-agent-working .donkey-orbit,
.choreography-stage.is-call-pending .donkey-orbit,
.choreography-stage.is-verifying .donkey-orbit { animation: relay-donkey-circuit 2.8s ease-in-out infinite; }
.choreography-stage.is-agent-working .robot-donkey,
.choreography-stage.is-call-pending .robot-donkey,
.choreography-stage.is-verifying .robot-donkey { animation: relay-donkey-counter 2.8s ease-in-out infinite; }
.choreography-stage.is-agent-working .donkey-leg,
.choreography-stage.is-call-pending .donkey-leg,
.choreography-stage.is-verifying .donkey-leg { animation: relay-donkey-step 420ms ease-in-out infinite alternate; }
.choreography-stage.is-agent-working .agent-workline,
.choreography-stage.is-call-pending .agent-workline,
.choreography-stage.is-verifying .agent-workline { animation: relay-agent-scan 780ms linear infinite; }
.choreography-stage.is-agent-working .dust-puff,
.choreography-stage.is-call-pending .dust-puff,
.choreography-stage.is-verifying .dust-puff { animation: relay-dust-lift 1.4s ease-out infinite; }
.choreography-stage.is-verifying .proof-sparks circle { animation: relay-proof-rise 720ms ease-out infinite; }
.choreography-stage.is-agent-working .mill-dust,
.choreography-stage.is-call-pending .mill-dust,
.choreography-stage.is-verifying .mill-dust { opacity: 1; }
.choreography-stage.is-call-pending .agent-hologram {
  opacity: 1;
  filter: drop-shadow(0 0 10px rgba(65, 216, 189, 0.46));
}

/* The release-candidate scene uses the approved Meta AI image as its visual
   ground truth. Every overlay below is driven by the same authoritative
   choreography state as the adjacent audit trail; there is no demo timer. */
.arrastra-scene {
  position: relative;
  display: block;
  width: 100%;
  height: auto;
  min-height: 0;
  max-height: none;
  aspect-ratio: 16 / 9;
  margin: 0;
  overflow: hidden;
  isolation: isolate;
  border-top: 1px solid rgba(65, 216, 189, 0.16);
  border-bottom: 1px solid rgba(65, 216, 189, 0.18);
  background: #07121a;
}

.arrastra-scene-image,
.scene-vignette,
.scene-flow-map {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.arrastra-scene-image {
  z-index: 0;
  display: block;
  object-fit: cover;
}

.scene-vignette {
  z-index: 1;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(3, 12, 20, 0.26), transparent 26%, transparent 70%, rgba(3, 12, 20, 0.44)),
    linear-gradient(90deg, rgba(3, 12, 20, 0.25), transparent 18%, transparent 80%, rgba(3, 12, 20, 0.18));
}

.scene-flow-map {
  z-index: 2;
  pointer-events: none;
}

.scene-flow-path {
  fill: none;
  stroke: var(--machine-accent);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-dasharray: 3 14;
  opacity: 0;
  filter: drop-shadow(0 0 5px color-mix(in srgb, var(--machine-accent) 68%, transparent));
  transition: opacity 180ms ease;
}

.scene-node {
  position: absolute;
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 8px 6px 6px;
  border: 1px solid rgba(210, 231, 236, 0.28);
  border-radius: 8px;
  color: rgba(238, 246, 248, 0.72);
  background: rgba(4, 15, 23, 0.76);
  box-shadow: 0 9px 25px rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(8px);
  opacity: 0.68;
  transform: scale(0.96);
  transform-origin: center;
  transition: border-color 180ms ease, color 180ms ease, opacity 180ms ease, transform 180ms ease;
}

.scene-node-number {
  display: grid;
  place-items: center;
  width: 25px;
  height: 25px;
  border: 1px solid currentColor;
  border-radius: 50%;
  font-family: var(--mono);
  font-size: 8px;
}

.scene-node span:last-child { display: grid; gap: 1px; }
.scene-node strong {
  font-family: var(--mono);
  font-size: 9px;
  line-height: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.scene-node small {
  color: rgba(221, 234, 238, 0.65);
  font-size: 8px;
  line-height: 10px;
  white-space: nowrap;
}

.scene-node-human { top: 7%; right: 3%; }
.scene-node-agent { top: 7%; left: 42%; }
.scene-node-gate { bottom: 5%; left: 42%; }
.scene-node-output { right: 3%; bottom: 5%; }

.scene-signal {
  position: absolute;
  z-index: 3;
  pointer-events: none;
  opacity: 0;
  transition: opacity 160ms ease;
}

.scene-signal-human {
  top: 46%;
  right: 12%;
  width: 31%;
  height: 31%;
}

.scene-signal-human i {
  position: absolute;
  top: calc(12% + var(--rock-offset, 0%));
  left: 0;
  width: 9px;
  height: 9px;
  border-radius: 2px;
  background: var(--teal);
  box-shadow: 0 0 12px rgba(65, 216, 189, 0.9);
  transform: rotate(38deg);
}
.scene-signal-human i:nth-child(2) { --rock-offset: 15%; animation-delay: 130ms; }
.scene-signal-human i:nth-child(3) { --rock-offset: 29%; animation-delay: 260ms; }

.scene-signal-agent {
  top: 34%;
  left: 34%;
  width: 29%;
  aspect-ratio: 1.45;
  border: 1px solid rgba(65, 216, 189, 0.5);
  border-radius: 50%;
  box-shadow: inset 0 0 25px rgba(65, 216, 189, 0.1), 0 0 20px rgba(65, 216, 189, 0.14);
}
.scene-signal-agent span {
  position: absolute;
  inset: -7px;
  border: 2px solid transparent;
  border-top-color: var(--machine-accent);
  border-right-color: var(--machine-accent);
  border-radius: 50%;
}

.scene-signal-gate {
  bottom: 17%;
  left: 43%;
  display: grid;
  place-items: center;
  width: 76px;
  height: 76px;
  border: 2px solid var(--amber);
  border-radius: 50%;
  color: var(--amber);
  background: rgba(5, 15, 22, 0.38);
  box-shadow: 0 0 25px rgba(248, 185, 36, 0.38), inset 0 0 20px rgba(248, 185, 36, 0.13);
  font-size: 27px;
}

.scene-signal-output {
  right: 11%;
  bottom: 12%;
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border: 1px solid var(--teal);
  border-radius: 12px;
  color: var(--teal);
  background: rgba(4, 18, 25, 0.82);
  box-shadow: 0 0 24px rgba(65, 216, 189, 0.38);
  font-size: 24px;
}

.scene-alert {
  position: absolute;
  z-index: 6;
  top: 51%;
  left: 50%;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 12px;
  border: 1px solid rgba(255, 166, 161, 0.75);
  border-radius: 8px;
  color: #fff4f2;
  background: rgba(61, 14, 19, 0.9);
  box-shadow: 0 0 34px rgba(255, 101, 95, 0.36);
  opacity: 0;
  transform: translate(-50%, -42%) scale(0.94);
  transition: opacity 160ms ease, transform 180ms ease;
}
.scene-alert i { color: var(--coral); font-size: 22px; }
.scene-alert span { display: grid; gap: 2px; }
.scene-alert strong {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.scene-alert small { color: #ffb5b0; font-family: var(--mono); font-size: 8px; }

.choreography-stage[data-mode="policy"] .scene-node-human,
.choreography-stage[data-mode="transfer"] .scene-node-human,
.choreography-stage.is-dumping .scene-node-human,
.choreography-stage[data-mode="intake"] .scene-node-agent,
.choreography-stage[data-mode="transfer"] .scene-node-agent,
.choreography-stage[data-mode="resume"] .scene-node-agent,
.choreography-stage.is-agent-working .scene-node-agent,
.choreography-stage.is-call-pending .scene-node-agent,
.choreography-stage[data-mode="blocked"] .scene-node-gate,
.choreography-stage[data-mode="verify"] .scene-node-gate,
.choreography-stage.is-verifying .scene-node-gate,
.choreography-stage[data-mode="commit"] .scene-node-output,
.choreography-stage[data-mode="audit"] .scene-node-output,
.choreography-stage.is-receiving .scene-node-output {
  border-color: var(--machine-accent);
  color: var(--machine-accent);
  opacity: 1;
  transform: scale(1);
  box-shadow: 0 0 24px color-mix(in srgb, var(--machine-accent) 28%, transparent);
}

.choreography-stage[data-mode="transfer"] .flow-human-to-mill,
.choreography-stage.is-dumping .flow-human-to-mill,
.choreography-stage[data-mode="intake"] .flow-agent-to-gate,
.choreography-stage[data-mode="transfer"] .flow-agent-to-gate,
.choreography-stage[data-mode="resume"] .flow-agent-to-gate,
.choreography-stage[data-mode="blocked"] .flow-agent-to-gate,
.choreography-stage[data-mode="verify"] .flow-agent-to-gate,
.choreography-stage.is-agent-working .flow-agent-to-gate,
.choreography-stage.is-call-pending .flow-agent-to-gate,
.choreography-stage[data-mode="commit"] .flow-gate-to-output,
.choreography-stage[data-mode="audit"] .flow-gate-to-output,
.choreography-stage.is-receiving .flow-gate-to-output { opacity: 0.88; }

.choreography-stage.is-dumping .scene-signal-human,
.choreography-stage.is-agent-working .scene-signal-agent,
.choreography-stage.is-call-pending .scene-signal-agent,
.choreography-stage[data-mode="verify"] .scene-signal-gate,
.choreography-stage.is-verifying .scene-signal-gate,
.choreography-stage[data-mode="commit"] .scene-signal-output,
.choreography-stage[data-mode="audit"] .scene-signal-output,
.choreography-stage.is-receiving .scene-signal-output { opacity: 1; }

.choreography-stage[data-mode="blocked"] .scene-alert {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.choreography-stage.is-dumping .scene-signal-human i { animation: relay-raster-ore 1.3s ease-in both; }
.choreography-stage.is-agent-working .scene-signal-agent span,
.choreography-stage.is-call-pending .scene-signal-agent span { animation: relay-raster-agent 1.9s linear infinite; }
.choreography-stage.is-verifying .scene-signal-gate { animation: relay-raster-gate 1s ease-in-out infinite alternate; }
.choreography-stage.is-receiving .scene-signal-output { animation: relay-raster-receipt 700ms ease-out both; }
.choreography-stage.is-dumping .flow-human-to-mill,
.choreography-stage.is-agent-working .flow-agent-to-gate,
.choreography-stage.is-call-pending .flow-agent-to-gate,
.choreography-stage.is-verifying .flow-agent-to-gate,
.choreography-stage.is-receiving .flow-gate-to-output { animation: relay-raster-flow 780ms linear infinite; }

@keyframes relay-raster-ore {
  0% { opacity: 0; transform: translate(0, -8px) rotate(38deg) scale(0.6); }
  18% { opacity: 1; }
  100% { opacity: 0; transform: translate(-190px, 78px) rotate(-150deg) scale(1.15); }
}
@keyframes relay-raster-agent { to { transform: rotate(360deg); } }
@keyframes relay-raster-gate { to { transform: scale(1.09); filter: brightness(1.25); } }
@keyframes relay-raster-receipt {
  0% { opacity: 0; transform: translate(-38px, -22px) scale(0.72); }
  100% { opacity: 1; transform: translate(0, 0) scale(1); }
}
@keyframes relay-raster-flow { to { stroke-dashoffset: -34; } }

.mill-readouts {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  margin: 0;
  border-top: 1px solid var(--rule);
  background: var(--rule);
}
.mill-readouts div { min-width: 0; padding: 10px 12px; background: rgba(5, 17, 27, 0.93); }
.mill-readouts dt {
  color: var(--text-quiet);
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.mill-readouts dd {
  margin: 3px 0 0;
  overflow: hidden;
  color: var(--machine-accent);
  font-family: var(--mono);
  font-size: 10px;
  line-height: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.choreography-beats {
  display: grid;
  align-content: start;
  gap: 0;
  margin: 0;
  padding: 8px 16px;
  list-style: none;
  background: rgba(3, 12, 20, 0.42);
}
.choreography-beat {
  position: relative;
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 10px;
  min-width: 0;
  padding: 8px 8px;
  border-left: 1px solid var(--rule-strong);
  color: var(--text-quiet);
}
.choreography-beat::before {
  content: "";
  position: absolute;
  top: 16px;
  left: -4px;
  width: 7px;
  height: 7px;
  border: 1px solid var(--rule-strong);
  border-radius: 50%;
  background: var(--canvas-raised);
}
.choreography-beat-number {
  display: grid;
  place-items: center;
  width: 25px;
  height: 25px;
  border: 1px solid var(--rule);
  border-radius: 50%;
  font-family: var(--mono);
  font-size: 9px;
}
.choreography-beat-title {
  display: block;
  overflow: hidden;
  color: inherit;
  font-size: 11px;
  line-height: 15px;
  font-weight: 670;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.choreography-beat-tool {
  display: block;
  overflow: hidden;
  margin-top: 1px;
  font-family: var(--mono);
  font-size: 8px;
  line-height: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.choreography-beat.is-complete { color: var(--teal); border-left-color: rgba(65, 216, 189, 0.62); }
.choreography-beat.is-complete::before { border-color: var(--teal); background: var(--teal); }
.choreography-beat.is-current {
  color: var(--text);
  border-left-color: var(--machine-accent);
  border-radius: 0 7px 7px 0;
  background: linear-gradient(90deg, rgba(65, 216, 189, 0.12), transparent);
}
.choreography-beat.is-current::before {
  left: -5px;
  width: 9px;
  height: 9px;
  border-color: var(--machine-accent);
  background: var(--machine-accent);
  box-shadow: 0 0 13px var(--machine-accent);
}
.choreography-stage[data-mode="blocked"] .choreography-beat.is-current {
  background: linear-gradient(90deg, rgba(255, 101, 95, 0.14), transparent);
}

@keyframes relay-bucket-dump {
  0%, 12% { transform: rotate(0deg); }
  34%, 72% { transform: rotate(-48deg); }
  100% { transform: rotate(0deg); }
}
@keyframes relay-rock-drop {
  0%, 15% { opacity: 1; transform: translate(0, 0) scale(0.72); }
  100% { opacity: 0; transform: translate(220px, 46px) scale(1.05); }
}
@keyframes relay-donkey-circuit {
  0%, 100% { transform: rotate(-14deg); }
  50% { transform: rotate(24deg); }
}
@keyframes relay-donkey-counter {
  0%, 100% { transform: rotate(14deg); }
  50% { transform: rotate(-24deg); }
}
@keyframes relay-donkey-step { from { transform: rotate(12deg); } to { transform: rotate(-15deg); } }
@keyframes relay-dust-lift {
  0% { opacity: 0; transform: translateY(2px) scale(0.55); }
  34% { opacity: 0.38; }
  100% { opacity: 0; transform: translateY(-18px) scale(1.35); }
}
@keyframes relay-agent-scan { to { stroke-dashoffset: -36; } }
@keyframes relay-proof-rise {
  0% { opacity: 0; transform: translateY(0) scale(0.5); }
  35% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-34px) scale(1.3); }
}

.decision-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(360px, 0.85fr);
  gap: 20px;
  margin-top: 10px;
}

.decision-card {
  min-width: 0;
  padding: 16px 18px;
  border: 1px solid var(--rule);
  border-radius: 10px;
  background: var(--gradient-glass);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.2), inset 0 1px rgba(255, 255, 255, 0.035);
  backdrop-filter: blur(14px);
}

.gate-card {
  border-left: 4px solid var(--rule-strong);
}

.gate-card.is-blocked {
  border-left-color: var(--coral);
  background:
    linear-gradient(90deg, rgba(255, 101, 95, 0.055), transparent 30%),
    rgba(9, 22, 34, 0.8);
}

.gate-card.is-ready,
.gate-card.is-resolved {
  border-left-color: var(--teal);
}

.card-heading {
  justify-content: space-between;
  gap: 20px;
}

.card-title-lockup {
  align-items: flex-start;
  gap: 12px;
}

.card-icon {
  display: grid;
  flex: 0 0 40px;
  place-items: center;
  width: 40px;
  height: 40px;
  color: var(--teal);
  border: 1px solid currentColor;
  border-radius: 50%;
  background: rgba(65, 216, 189, 0.05);
}

.card-icon.is-amber {
  color: var(--amber);
  background: rgba(248, 185, 36, 0.05);
}

.card-icon i {
  font-size: 21px;
}

.card-heading h2,
.evidence-heading h3,
.ledger-heading h2 {
  margin: 4px 0 0;
  color: var(--text);
  font-size: 19px;
  line-height: 25px;
  font-weight: 660;
  letter-spacing: -0.02em;
}

.gate-state {
  padding: 5px 8px;
  color: var(--text-secondary);
  border: 1px solid var(--rule-strong);
  border-radius: 4px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.gate-card.is-blocked .gate-state {
  color: var(--coral);
  border-color: rgba(255, 101, 95, 0.58);
}

.gate-card.is-ready .gate-state,
.gate-card.is-resolved .gate-state {
  color: var(--teal);
  border-color: rgba(65, 216, 189, 0.54);
}

.gate-callout {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr);
  gap: 12px;
  margin-top: 10px;
  padding: 9px 12px;
  color: var(--text-secondary);
  border: 1px solid var(--rule-strong);
  border-radius: 6px;
  background: rgba(5, 14, 23, 0.54);
}

.gate-callout > i {
  margin-top: 1px;
  color: var(--text-quiet);
  font-size: 22px;
}

.gate-callout code {
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
  line-height: 18px;
}

.gate-callout p {
  margin-top: 4px;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 20px;
}

.gate-card.is-blocked .gate-callout {
  border-color: rgba(255, 101, 95, 0.68);
  background: rgba(255, 101, 95, 0.055);
}

.gate-card.is-blocked .gate-callout > i,
.gate-card.is-blocked .gate-callout code {
  color: var(--coral);
}

.gate-card.is-ready .gate-callout,
.gate-card.is-resolved .gate-callout {
  border-color: rgba(65, 216, 189, 0.52);
}

.gate-card.is-ready .gate-callout > i,
.gate-card.is-ready .gate-callout code,
.gate-card.is-resolved .gate-callout > i,
.gate-card.is-resolved .gate-callout code {
  color: var(--teal);
}

.required-action {
  margin-top: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--rule);
}

.required-action-label {
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
}

.required-action p:last-child {
  margin-top: 6px;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 21px;
}

.evidence-heading {
  justify-content: space-between;
  gap: 20px;
  margin-top: 10px;
}

.evidence-heading h3 {
  margin: 0;
  font-size: 13px;
}

.rail-count,
.ledger-count {
  color: var(--text-quiet);
}

.incident-brief {
  display: none;
}

.evidence-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 9px;
  margin-top: 8px;
}

.evidence-row {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 8px;
  min-width: 0;
  padding: 8px 9px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: rgba(5, 14, 23, 0.36);
}

.evidence-icon {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  color: var(--teal);
  border: 1px solid currentColor;
  border-radius: 50%;
}

.evidence-row.is-pending .evidence-icon {
  color: var(--amber);
  border-style: dashed;
}

.evidence-icon i {
  font-size: 13px;
}

.evidence-id,
.evidence-detail {
  margin: 0;
}

.evidence-id {
  overflow: hidden;
  color: var(--text-secondary);
  font-family: var(--mono);
  font-size: 10px;
  line-height: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.evidence-detail {
  margin-top: 3px;
  color: var(--text-quiet);
  font-size: 10px;
  line-height: 14px;
  overflow-wrap: anywhere;
}

.policy-copy {
  margin-top: 10px;
  color: var(--text);
  font-size: 15px;
  line-height: 21px;
}

.policy-requirements {
  margin: 10px 0 0;
}

.requirement-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  padding: 6px 0;
  border-top: 1px solid var(--rule);
}

.requirement-row:last-child {
  border-bottom: 1px solid var(--rule);
}

.requirement-row dt,
.requirement-row dd {
  margin: 0;
  font-size: 12px;
  line-height: 18px;
}

.requirement-row dt {
  color: var(--text-quiet);
}

.requirement-row dd {
  color: var(--text-secondary);
  font-family: var(--mono);
  text-align: right;
}

.requirement-row dd.is-passed {
  color: var(--teal);
}

.requirement-row dd.is-blocked {
  color: var(--coral);
}

.receipt-heading {
  justify-content: space-between;
  gap: 20px;
  margin-top: 10px;
}

.receipt-state {
  padding: 4px 7px;
  color: var(--text-quiet);
  border: 1px solid var(--rule-strong);
  border-radius: 4px;
  text-transform: uppercase;
}

.receipt-state.is-filled {
  color: var(--teal);
  border-color: var(--teal);
}

.commit-receipt {
  min-height: 60px;
  margin-top: 7px;
  padding: 10px;
  border: 1px dashed var(--rule-strong);
  border-radius: 6px;
  background: rgba(5, 14, 23, 0.48);
}

.empty-copy {
  color: var(--text-quiet);
  font-size: 12px;
  line-height: 20px;
}

.receipt-grid {
  display: grid;
  gap: 8px;
  margin: 0;
}

.receipt-grid div {
  display: grid;
  gap: 2px;
}

.receipt-grid dt,
.receipt-grid dd {
  margin: 0;
}

.receipt-grid dt {
  color: var(--text-quiet);
  font-size: 9px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.receipt-grid dd {
  overflow: hidden;
  color: var(--teal);
  font-family: var(--mono);
  font-size: 11px;
  line-height: 17px;
  text-overflow: ellipsis;
}

.activity-ledger {
  margin-top: 14px;
  padding: 14px 20px 0;
  border: 1px solid var(--rule);
  border-radius: 10px;
  background:
    radial-gradient(circle at 95% 0%, rgba(65, 216, 189, 0.07), transparent 28%),
    linear-gradient(145deg, rgba(13, 31, 45, 0.82), rgba(6, 17, 28, 0.68));
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.16), inset 0 1px rgba(255, 255, 255, 0.03);
  backdrop-filter: blur(14px);
}

.ledger-heading {
  justify-content: space-between;
  gap: 20px;
}

.ledger-heading h2 {
  margin-top: 3px;
}

.ledger-actions {
  justify-content: flex-end;
  gap: 18px;
}

.text-button {
  min-height: 44px;
  padding: 0;
  border: 0;
  color: var(--teal);
  background: transparent;
}

.text-button:hover {
  color: #79ead5;
}

.ledger-table {
  margin-top: 8px;
  overflow: hidden;
  border-top: 1px solid var(--rule);
  font-family: var(--mono);
}

.ledger-row {
  display: grid;
  grid-template-columns: 54px 150px minmax(165px, 230px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
  padding: 7px 2px;
  border-top: 1px solid var(--rule);
  color: var(--text-secondary);
  font-size: 11px;
  line-height: 18px;
}

.ledger-row:first-child {
  border-top: 0;
}

.ledger-row--head {
  color: var(--text-quiet);
  font-size: 9px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.ledger-row.is-rejection {
  color: var(--coral);
  background: rgba(255, 101, 95, 0.035);
}

.ledger-row.is-success {
  color: var(--teal);
}

.ledger-row span:last-child {
  overflow-wrap: anywhere;
}

.empty-ledger {
  margin: 0;
  padding: 18px 2px 22px;
  color: var(--text-quiet);
  font-family: var(--sans);
  font-size: 12px;
}

.toast {
  position: fixed;
  z-index: 20;
  right: 24px;
  bottom: 24px;
  max-width: min(390px, calc(100vw - 48px));
  padding: 13px 16px;
  border: 1px solid var(--rule-strong);
  border-left: 4px solid var(--teal);
  border-radius: 7px;
  color: var(--text);
  background: var(--surface-strong);
  box-shadow: 0 18px 54px rgba(0, 0, 0, 0.38);
  font-size: 13px;
  line-height: 20px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.toast.is-error {
  border-left-color: var(--coral);
}

.flash {
  animation: row-flash 850ms ease-out;
}

@keyframes row-flash {
  from { background: rgba(65, 216, 189, 0.12); }
  to { background: transparent; }
}

@keyframes agent-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.55; transform: scale(1.55); }
}

@media (max-width: 1120px) {
  .app-header {
    grid-template-columns: 1fr auto;
    padding: 0 24px;
  }

  .header-context {
    display: none;
  }

  .decision-grid {
    grid-template-columns: 1fr;
  }

  .recovery-guide {
    grid-template-columns: 1fr;
  }

  .activation-controls {
    align-items: flex-start;
  }

  .agent-activity {
    justify-content: flex-start;
    text-align: left;
  }

  .guide-actions {
    justify-content: flex-start;
  }

  .evidence-list {
    grid-template-columns: repeat(4, minmax(120px, 1fr));
  }
}

@media (max-width: 820px) {
  .app-header {
    grid-template-columns: 1fr;
    gap: 16px;
    padding-top: 18px;
    padding-bottom: 18px;
  }

  .header-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .connection-status {
    flex: 1 0 100%;
    margin: 0;
  }

  .recovery-heading {
    flex-direction: column;
    gap: 18px;
  }

  .recovery-meta {
    align-items: flex-start;
    flex-direction: row;
    flex-wrap: wrap;
  }

  .recovery-progress {
    grid-template-columns: 1fr;
    gap: 0;
    max-width: 620px;
  }

  .state-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 4px;
  }

  .progress-step {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr);
    gap: 14px;
    align-items: start;
    min-height: 82px;
    padding: 0;
    text-align: left;
  }

  .progress-step:not(:last-child)::after {
    top: 44px;
    bottom: 0;
    left: 21px;
    width: 2px;
    height: auto;
  }

  .step-number {
    margin: 0;
    grid-row: 1 / span 2;
  }

  .step-label {
    margin-top: 4px;
  }

  .step-detail {
    grid-column: 2;
    margin-top: -17px;
  }

  .guide-actions {
    align-items: stretch;
  }

  .guide-actions > * {
    flex: 1;
  }

  .prompt-preview {
    grid-template-columns: 1fr;
    gap: 7px;
  }

  .choreography-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
  }

  .choreography-counter {
    align-items: flex-start;
  }

  .choreography-body {
    grid-template-columns: 1fr;
  }

  .mill-panel {
    border-right: 0;
    border-bottom: 1px solid var(--rule);
  }

  .choreography-beats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 12px 16px 16px;
  }

  .evidence-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .ledger-row--head {
    display: none;
  }

  .ledger-row {
    grid-template-columns: 38px 1fr;
    gap: 5px 12px;
    padding: 13px 0;
  }

  .ledger-row span:nth-child(2) {
    color: var(--text-quiet);
  }

  .ledger-row span:nth-child(3),
  .ledger-row span:nth-child(4) {
    grid-column: 2;
  }
}

@media (max-width: 560px) {
  .app-header {
    padding-right: 18px;
    padding-left: 18px;
  }

  .app-shell {
    padding-right: 16px;
    padding-left: 16px;
  }

  .recovery-stage {
    padding-top: 20px;
  }

  .recovery-heading h1 {
    font-size: 36px;
  }

  .judge-orientation {
    margin-top: 8px;
    font-size: 14px;
    line-height: 22px;
  }

  .recovery-meta {
    width: 100%;
    gap: 6px;
    flex-wrap: nowrap;
  }

  .revision-label,
  .status-badge,
  .policy-pill {
    padding: 6px 7px;
    font-size: 9px;
  }

  .policy-pill {
    gap: 5px;
  }

  .policy-pill i {
    font-size: 14px;
  }

  .state-heading {
    align-items: center;
    flex-direction: row;
    gap: 10px;
    font-size: 8px;
  }

  .recovery-progress {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0;
    margin-top: 14px;
  }

  .progress-step {
    display: block;
    min-height: 0;
    padding: 0 4px;
    text-align: center;
  }

  .progress-step:not(:last-child)::after {
    top: 17px;
    bottom: auto;
    left: calc(50% + 18px);
    width: calc(100% - 36px);
    height: 2px;
  }

  .step-number {
    grid-row: auto;
    width: 36px;
    height: 36px;
    margin: 0 auto;
    font-size: 14px;
    box-shadow: 0 0 0 4px var(--canvas);
  }

  .progress-step.is-active .step-number,
  .progress-step.is-blocked .step-number {
    box-shadow: 0 0 0 4px var(--canvas), 0 0 22px rgba(65, 216, 189, 0.2);
  }

  .step-label {
    margin-top: 7px;
    font-size: 11px;
    line-height: 15px;
  }

  .step-detail {
    grid-column: auto;
    margin-top: 2px;
    font-size: 9px;
    line-height: 13px;
  }

  .header-actions .quiet-button {
    flex: 1;
  }

  .guide-actions {
    flex-direction: column;
  }

  .recovery-guide {
    padding: 15px;
    border-radius: 14px;
  }

  .activation-steps {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin-left: 0;
  }

  .activation-steps li {
    align-items: flex-start;
    min-width: 0;
    font-size: 10px;
    line-height: 15px;
  }

  .activation-steps span {
    flex: 0 0 18px;
  }

  .agent-next-action {
    margin-left: 0;
  }

  .activation-controls,
  .guide-actions,
  .guide-actions > * {
    width: 100%;
  }

  .primary-button {
    width: 100%;
  }

  .choreography-stage {
    margin-right: -2px;
    margin-left: -2px;
    border-radius: 14px;
  }

  .choreography-heading {
    padding: 16px;
  }

  .choreography-intro {
    font-size: 12px;
    line-height: 18px;
  }

  .machine-readout {
    grid-template-columns: 1fr;
    gap: 3px;
    padding: 12px 14px 5px;
  }

  .machine-kicker {
    grid-row: auto;
    max-width: none;
  }

  .arrastra-scene {
    min-height: 0;
  }

  .scene-node {
    gap: 4px;
    padding: 4px 6px 4px 4px;
    border-radius: 6px;
  }

  .scene-node-number {
    width: 20px;
    height: 20px;
    font-size: 7px;
  }

  .scene-node strong {
    font-size: 7px;
    line-height: 9px;
  }

  .scene-node small {
    display: none;
  }

  .scene-node-gate {
    left: 36%;
  }

  .scene-signal-gate {
    bottom: 14%;
    left: 42%;
    width: 52px;
    height: 52px;
    font-size: 20px;
  }

  .scene-signal-output {
    right: 9%;
    bottom: 10%;
    width: 38px;
    height: 38px;
    font-size: 18px;
  }

  .scene-alert {
    padding: 7px 9px;
  }

  .scene-alert i {
    font-size: 18px;
  }

  .mill-readouts {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .choreography-beats {
    grid-template-columns: 1fr;
  }

  .decision-card,
  .activity-ledger {
    padding: 20px 16px;
  }

  .card-heading {
    align-items: flex-start;
  }

  .card-icon {
    flex-basis: 36px;
    width: 36px;
    height: 36px;
  }

  .gate-state {
    margin-top: 4px;
  }

  .evidence-list {
    grid-template-columns: 1fr 1fr;
  }

  .ledger-heading,
  .ledger-actions {
    align-items: flex-start;
    flex-direction: column;
  }

  .ledger-actions {
    gap: 0;
  }

  .toast {
    right: 16px;
    bottom: 16px;
    max-width: calc(100vw - 32px);
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .toast,
  .agent-activity.is-active .agent-activity-dot,
  .choreography-stage *,
  .choreography-stage *::before,
  .choreography-stage *::after,
  .skip-link,
  .flash {
    animation: none;
    transition: none;
  }
}
