/* Inbox Firewall: the story is set by /story.css. This sheet adds the
   pipeline drawing and the lab that app.js runs. The lab keeps the night's
   palette: moon for what passed, amber for what a defense stopped, red for
   what got through. */

/* ---------- the pipeline ---------- */

.pipe { margin: 0; }
.prose > .pipe { margin-block: 1.6em 1.2em; }

.pipe svg { width: 100%; height: auto; overflow: visible; }
.pipe text { font-family: var(--font); }
.pipe-tall { display: none; max-width: 360px; }

@media (max-width: 559px) {
  .pipe-wide { display: none; }
  .pipe-tall { display: block; }
}

/* ---------- the lab ---------- */

.lab-body {
  grid-column: 1 / -1;
  margin-top: clamp(48px, 8vh, 88px);
}

.controls {
  display: grid;
  grid-template-columns: auto 1fr minmax(220px, .6fr);
  gap: 24px 40px;
  align-items: end;
}

.control-label {
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
  font-size: .875rem;
  color: var(--moon-soft);
}

.control-label strong {
  color: var(--moon);
  font-weight: 500;
}

.segmented {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.segmented button,
.stream-controls button {
  padding: 6px 15px;
  border: 1px solid color-mix(in oklab, var(--moon) 30%, transparent);
  border-radius: 999px;
  background: none;
  color: var(--moon);
  font: inherit;
  font-size: .875rem;
  cursor: pointer;
  transition: background-color .2s, color .2s, border-color .2s;
}

.segmented button:hover,
.stream-controls button:hover { border-color: var(--moon); }

.segmented button.active {
  background: var(--moon);
  border-color: var(--moon);
  color: var(--night);
}

input[type="range"] {
  width: 100%;
  margin: 8px 0;
  accent-color: var(--amber);
}

.metrics {
  margin: clamp(48px, 8vh, 80px) 0;
  padding-top: 28px;
  border-top: 1px solid var(--hair);
}

.metrics .danger .figure { color: var(--red-text); }

.lab-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--col-gap);
  margin-bottom: var(--col-gap);
}

.lab-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: clamp(20px, 2.5vw, 32px);
  border-radius: 20px;
  background: var(--surface);
}

.panel-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px 20px;
  margin-bottom: 24px;
}

.panel-head h3 {
  margin: 0;
  font-size: clamp(1.5rem, 1.1rem + 1vw, 2rem);
  font-stretch: 75%;
  font-weight: 500;
  line-height: 1;
  letter-spacing: -.02em;
}

.stream-controls { display: flex; gap: 6px; }

/* ---------- the message ---------- */

.message-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 2px 2px 14px;
  scrollbar-width: none;
}

.message-tab {
  position: relative;
  flex: 0 0 34px;
  height: 34px;
  border: 1px solid var(--hair);
  border-radius: 50%;
  background: none;
  color: var(--moon-soft);
  font: inherit;
  font-size: .75rem;
  cursor: pointer;
  transition: background-color .2s, color .2s, border-color .2s;
}

.message-tab:hover { border-color: var(--moon); color: var(--moon); }

.message-tab.active {
  background: var(--moon);
  border-color: var(--moon);
  color: var(--night);
}

/* The adversarial ones carry a red dot. */
.message-tab[data-slice="adversarial"]::after {
  content: "";
  position: absolute;
  top: 1px;
  right: 1px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 0 2px var(--surface);
}

.message-card {
  flex: 1;
  padding: clamp(18px, 2vw, 26px);
  border: 1px solid var(--hair);
  border-radius: 14px;
}

.message-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 22px;
  font-size: .8125rem;
  color: var(--moon-soft);
}

.slice-badge {
  padding: 3px 11px;
  border: 1px solid var(--hair);
  border-radius: 999px;
}

.slice-badge.adversarial {
  color: var(--red-text);
  border-color: color-mix(in oklab, var(--red) 60%, transparent);
}

.message-card h4 {
  margin: 0 0 6px;
  font-size: 1.25rem;
  font-weight: 560;
  line-height: 1.25;
}

.sender {
  margin: 0 0 18px;
  font-size: .875rem;
  color: var(--moon-soft);
}

.message-body {
  font-size: .9375rem;
  line-height: 1.6;
  color: var(--moon-body);
  overflow-wrap: anywhere;
}

.truth-row,
.proposal-box {
  display: grid;
  gap: 6px;
  margin-top: 18px;
  font-size: .8125rem;
  color: var(--moon-soft);
}

.lab code { overflow-wrap: anywhere; }

/* ---------- the trace ---------- */

.outcome-pill {
  padding: 4px 13px;
  border: 1px solid currentColor;
  border-radius: 999px;
  font-size: .8125rem;
  white-space: nowrap;
}

.outcome-pill.blocked { color: var(--amber-text); }
.outcome-pill.unsafe { color: var(--red-text); }

.trace-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.trace-step {
  display: grid;
  grid-template-columns: 2em 1fr auto;
  gap: 12px;
  align-items: baseline;
  padding: 13px 0;
  border-top: 1px solid var(--hair);
}

.trace-index {
  font-size: .8125rem;
  color: var(--moon-soft);
}

.trace-step strong {
  display: block;
  font-size: .9375rem;
  font-weight: 560;
}

.trace-step p {
  margin: 3px 0 0;
  font-size: .8125rem;
  line-height: 1.45;
  color: var(--moon-soft);
}

.trace-state {
  font-size: .8125rem;
  color: var(--moon);
  white-space: nowrap;
}

.trace-step.blocked .trace-state,
.trace-step.blocked .trace-index { color: var(--amber-text); }

.trace-step.danger .trace-state,
.trace-step.danger .trace-index { color: var(--red-text); }

.proposal-box {
  margin-top: auto;
  padding-top: 18px;
  border-top: 1px solid var(--hair);
}

/* ---------- the evidence ---------- */

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  font-size: .8125rem;
  color: var(--moon-soft);
}

.chart-legend span { display: inline-flex; align-items: center; gap: 8px; }

.legend-line {
  width: 18px;
  height: 2px;
  background: var(--moon);
}

.legend-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--amber);
}

.chart-wrap { aspect-ratio: 720 / 320; }

#risk-chart {
  width: 100%;
  height: 100%;
  overflow: visible;
}

#risk-chart text { font-family: var(--font); }

.chart-note {
  margin: 20px 0 0;
  font-size: .875rem;
  line-height: 1.5;
  color: var(--moon-soft);
}

.ablation-bars {
  display: grid;
  gap: 18px;
  margin-bottom: 28px;
}

.ablation-row {
  display: grid;
  grid-template-columns: minmax(0, 9em) 1fr 4.5em;
  gap: 14px;
  align-items: center;
  font-size: .875rem;
}

.ablation-track {
  height: 12px;
  background: var(--track);
  border-radius: 0 4px 4px 0;
}

.ablation-fill {
  height: 100%;
  background: var(--s2);
  border-radius: 0 4px 4px 0;
  transition: width .5s var(--ease);
}

.ablation-row:last-child .ablation-fill { background: var(--amber); }

.ablation-value {
  text-align: right;
}

.calibration-note {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 20px;
  align-items: center;
  margin-top: auto;
  padding-top: 24px;
  border-top: 1px solid var(--hair);
}

.calibration-note .figure { font-size: clamp(2rem, 1.4rem + 1.6vw, 3rem); }

.calibration-note p {
  margin: 0;
  font-size: .875rem;
  line-height: 1.5;
  color: var(--moon-soft);
}

.calibration-note strong {
  display: block;
  margin-bottom: 2px;
  color: var(--moon);
  font-weight: 560;
}

@media (max-width: 1099px) {
  .controls { grid-template-columns: 1fr; }
  .lab-grid { grid-template-columns: 1fr; }
}

@media (max-width: 559px) {
  .ablation-row { grid-template-columns: 1fr 4.5em; }
  .ablation-row > span:first-child { grid-column: 1 / -1; }
  .calibration-note { grid-template-columns: 1fr; gap: 8px; }
}

/* The lab runs the full width below its title, so the title can't stay pinned. */
.lab .chapter-title { position: static; }
