/* DejaVuGuard conference demo.
   Light, high-contrast, and legible from a metre away in a bright hall. The
   chat is a phone on purpose: nobody needs the "this is a conversation" part
   explained, which leaves all of the explaining for the monitor beside it. */

:root {
  --page:      #eef1f6;
  --card:      #ffffff;
  --ink:       #14181f;
  --ink-soft:  #4a5261;
  --muted:     #7b8494;
  --line:      #e0e5ee;
  --line-firm: #ccd4e0;

  --brand:     #4f46e5;
  --brand-dim: #eeedfd;
  --pass:      #12864b;
  --pass-bg:   #e6f6ed;
  --fail:      #c92a2a;
  --fail-bg:   #fdecec;
  --warn:      #a86500;
  --warn-bg:   #fdf3e0;

  /* WhatsApp */
  --wa-bar:    #008069;
  --wa-chat:   #efeae2;
  --wa-out:    #d9fdd3;
  --wa-in:     #ffffff;

  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: "Inter", ui-sans-serif, system-ui, -apple-system, sans-serif;

  --shadow:    0 1px 2px rgba(20, 24, 31, .05), 0 4px 14px rgba(20, 24, 31, .06);
  --shadow-lg: 0 10px 40px rgba(20, 24, 31, .16);
}

* { box-sizing: border-box; }
html { color-scheme: light; height: 100%; }

/* The demo is an appliance, not a document: the whole thing -- phone,
   transport, monitor -- has to be on screen at once on a laptop, because a
   presenter cannot scroll and talk. The page fills the viewport exactly and
   the two columns do any scrolling they need inside themselves. */
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  height: 100dvh;
  overflow: hidden;
}
/* rail | phone and its controls | everything explained */
.shell { display: flex; height: 100dvh; }

.rail {
  flex: none;
  width: 58px;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 12px;
  background: var(--card);
  border-right: 1px solid var(--line);
}
/* The name and its info toggle belong to the phone layout only. */
.rail-name, .rail-info { display: none; }
.right {
  flex: 1 1 0;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.rulebar { flex: none; }

.hamburger {
  width: 42px; height: 42px;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 4.5px;
  background: var(--card);
  border: 1px solid var(--line-firm);
  border-radius: 10px;
  cursor: pointer;
  flex: none;
  transition: background .12s, border-color .12s;
}
.hamburger span { display: block; width: 17px; height: 2px; background: var(--ink); border-radius: 2px; }
.hamburger:hover { background: var(--brand-dim); border-color: var(--brand); }
.hamburger:focus-visible, .icon-btn:focus-visible,
button:focus-visible, select:focus-visible {
  outline: 3px solid rgba(79, 70, 229, .4);
  outline-offset: 2px;
}

/* ───────────── drawer ───────────── */

.scrim {
  position: fixed; inset: 0;
  background: rgba(20, 24, 31, .4);
  z-index: 40;
  animation: fade .16s ease;
}
@keyframes fade { from { opacity: 0; } }

.drawer {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: min(420px, 90vw);
  background: var(--card);
  z-index: 50;
  padding: 20px 22px 24px;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: slide .2s cubic-bezier(.2, .8, .3, 1);
}
@keyframes slide { from { transform: translateX(-100%); } }
@media (prefers-reduced-motion: reduce) { .drawer, .scrim { animation: none; } }

.drawer-head { display: flex; align-items: center; justify-content: space-between; }
.drawer-head h2 { margin: 0; font-size: 17px; }
.drawer-note { margin: 4px 0 18px; font-size: 13.5px; color: var(--muted); }

.icon-btn {
  width: 32px; height: 32px;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  color: var(--ink-soft);
  line-height: 1;
}
.icon-btn:hover { background: var(--page); }

.sc-item {
  display: block;
  width: 100%;
  text-align: left;
  border: 1px solid var(--line-firm);
  border-radius: 12px;
  background: var(--card);
  padding: 14px 16px;
  margin-bottom: 10px;
  cursor: pointer;
  font: inherit;
  transition: border-color .12s, box-shadow .12s, background .12s;
}
.sc-item:hover { border-color: var(--brand); background: #fbfbff; }
.sc-item.is-active { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-dim); }
.sc-item .row { display: flex; align-items: center; gap: 9px; }
.sc-item .num {
  width: 24px; height: 24px;
  display: grid; place-items: center;
  border-radius: 7px;
  background: var(--brand-dim);
  color: var(--brand);
  font-size: 12.5px;
  font-weight: 700;
  flex: none;
}
.sc-item.is-active .num { background: var(--brand); color: #fff; }
.sc-item .name { font-weight: 650; font-size: 15px; }
.sc-item .desc { margin: 7px 0 0; font-size: 13px; color: var(--ink-soft); line-height: 1.5; }
.sc-item .shows {
  display: inline-block;
  margin-top: 9px;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--brand);
  background: var(--brand-dim);
  border-radius: 6px;
  padding: 3px 8px;
}

.drawer-foot {
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: 13px;
  color: var(--muted);
}
.drawer-foot p { margin: 0 0 4px; }
kbd {
  font-family: var(--mono);
  font-size: 11.5px;
  border: 1px solid var(--line-firm);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 1px 5px;
  background: var(--card);
  color: var(--ink-soft);
}

/* ───────────── rule bar ───────────── */

.rulebar {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
  padding: 16px 22px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.rule-eyebrow {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--brand);
}
.rule-text {
  margin: 2px 0 0;
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -.015em;
  text-wrap: balance;
}
.link-btn {
  margin-left: auto;
  border: 1px solid var(--line-firm);
  background: var(--card);
  color: var(--brand);
  font: inherit;
  font-size: 13.5px;
  font-weight: 550;
  border-radius: 9px;
  padding: 9px 14px;
  cursor: pointer;
  white-space: nowrap;
}
.link-btn:hover { background: var(--brand-dim); border-color: var(--brand); }

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

.stage {
  flex: none;
  /* The frame's width follows the window height, so it keeps a phone's
     proportions on a 13" laptop and on a hall projector alike; the column
     adds what Back and Next need on either side. */
  --phone-w: clamp(310px, min(29vw, 54vh), 560px);
  width: calc(var(--phone-w) + 136px);
  display: flex;
  min-height: 0;
  padding: 12px 10px;
  border-right: 1px solid var(--line);
  background: var(--page);
}
.stage-row {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ───────────── back / next ─────────────
   Beside the phone rather than on it: these step the demo, they are not
   something the person in the conversation pressed. */

.nav {
  flex: none;
  width: 58px;
  display: grid;
  justify-items: center;
  gap: 3px;
  border: 0;
  background: none;
  font: inherit;
  color: var(--ink-soft);
  cursor: pointer;
  padding: 10px 0;
  border-radius: 14px;
  transition: background .12s, color .12s, transform .06s;
}
.nav-arrow {
  font-size: 15px;
  line-height: 1;
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--card);
  border: 1px solid var(--line-firm);
  box-shadow: var(--shadow);
  color: var(--brand);
}
.nav-label { font-size: 12px; font-weight: 550; }
.nav:hover:not(:disabled) .nav-arrow { background: var(--brand); border-color: var(--brand); color: #fff; }
.nav:active:not(:disabled) { transform: translateY(1px); }
.nav:disabled { opacity: .3; cursor: default; }

/* ───────────── play ─────────────
   It drives what the monitor shows, so it sits with the monitor. */

.play-btn {
  width: 46px; height: 46px;
  flex: none;
  padding: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font: inherit;
  font-size: 15px;
  line-height: 1;
  background: var(--brand);
  border: 1px solid var(--brand);
  color: #fff;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: background .12s, transform .06s;
}
.play-btn:hover { background: #4338ca; border-color: #4338ca; }
.play-btn:active { transform: translateY(1px); }

/* ───────────── phone ───────────── */

.phone {
  /* Full height of its row, never scrolled, always phone-shaped. */
  flex: none;
  align-self: stretch;
  width: var(--phone-w);
  min-width: 0;
  min-height: 0;
  background: #111b21;
  border-radius: 38px;
  padding: 10px;
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(20, 24, 31, .12);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}
.phone-notch {
  position: absolute;
  top: 10px; left: 50%;
  transform: translateX(-50%);
  width: 112px; height: 20px;
  background: #111b21;
  border-radius: 0 0 14px 14px;
  z-index: 3;
}

.wa-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--wa-bar);
  color: #fff;
  padding: 26px 14px 10px;
  border-radius: 30px 30px 0 0;
}
.wa-back { font-size: 21px; line-height: 1; opacity: .9; }
.wa-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: #d7e3e0;
  display: grid; place-items: center;
  font-size: 15px;
  flex: none;
}
.wa-who { display: flex; flex-direction: column; line-height: 1.25; }
.wa-who strong { font-size: 13.5px; font-weight: 600; }
.wa-who span { font-size: 11px; opacity: .85; }
.wa-icons { margin-left: auto; opacity: .9; }

.wa-chat {
  flex: 1;
  overflow-y: auto;
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  scroll-behavior: smooth;
  background-color: var(--wa-chat);
  background-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22260%22%20height%3D%22260%22%20viewBox%3D%220%200%20260%20260%22%3E%3Cg%20fill%3D%22none%22%20stroke%3D%22%235b6b62%22%20stroke-width%3D%221.6%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%20opacity%3D%220.2%22%3E%3Cpath%20d%3D%22M22%2030c4-6%2012-6%2016%200%204-6%2012-6%2016%200%200%208-16%2018-16%2018S22%2038%2022%2030z%22%2F%3E%3Ccircle%20cx%3D%22112%22%20cy%3D%2226%22%20r%3D%229%22%2F%3E%3Cpath%20d%3D%22M112%2017v18M103%2026h18%22%2F%3E%3Cpath%20d%3D%22M170%2020h22v16h-8l-6%207v-7h-8z%22%2F%3E%3Cpath%20d%3D%22M232%2022v14M225%2029h14%22%2F%3E%3Cpath%20d%3D%22M42%2084c0-7%206-13%2013-13s13%206%2013%2013-6%2013-13%2013h-6l-7%206v-6c0-4%200-9%200-13z%22%2F%3E%3Cpath%20d%3D%22M128%2074l7%2014%2015%202-11%2010%203%2015-14-8-14%208%203-15-11-10%2015-2z%22%2F%3E%3Cpath%20d%3D%22M196%2078h20v14h-20zM199%2078v-5h14v5%22%2F%3E%3Cpath%20d%3D%22M26%20140c6-8%2018-8%2024%200M32%20148c3-4%209-4%2012%200%22%2F%3E%3Ccircle%20cx%3D%2238%22%20cy%3D%22156%22%20r%3D%221.8%22%20fill%3D%22%235b6b62%22%20stroke%3D%22none%22%2F%3E%3Cpath%20d%3D%22M96%20132h26v18H108l-6%206v-6h-6z%22%2F%3E%3Cpath%20d%3D%22M168%20130l10%2010-10%2010-10-10z%22%2F%3E%3Cpath%20d%3D%22M222%20128v12M216%20134h12M222%20146c0%204%204%206%208%205%22%2F%3E%3Cpath%20d%3D%22M54%20198c0-6%205-11%2011-11s11%205%2011%2011-5%2011-11%2011-11-5-11-11zM65%20191v8l5%203%22%2F%3E%3Cpath%20d%3D%22M118%20196h18l4%2010h-26z%22%2F%3E%3Cpath%20d%3D%22M127%20196v-6%22%2F%3E%3Cpath%20d%3D%22M186%20192c5-5%2013-5%2018%200s5%2013%200%2018-13%205-18%200-5-13%200-18z%22%20stroke-dasharray%3D%223%204%22%2F%3E%3Cpath%20d%3D%22M238%20200l-8%208M230%20200l8%208%22%2F%3E%3Cpath%20d%3D%22M12%20240c8-5%2018-5%2026%200%22%2F%3E%3Cpath%20d%3D%22M150%20236h20M160%20230v12%22%2F%3E%3C%2Fg%3E%3C%2Fsvg%3E");
  background-size: 260px 260px;
}
@media (prefers-reduced-motion: reduce) { .wa-chat { scroll-behavior: auto; } }

.bubble {
  max-width: 82%;
  padding: 7px 10px 6px;
  border-radius: 9px;
  font-size: 13px;
  line-height: 1.44;
  color: #111b21;
  box-shadow: 0 1px .5px rgba(11, 20, 26, .13);
  position: relative;
  white-space: pre-wrap;
  word-wrap: break-word;
  animation: pop .22s ease both;
}
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.985); } }
@media (prefers-reduced-motion: reduce) { .bubble { animation: none; } }

.bubble b { font-weight: 650; }
.bubble.out { align-self: flex-end; background: var(--wa-out); border-top-right-radius: 2px; }
.bubble.in  { align-self: flex-start; background: var(--wa-in); border-top-left-radius: 2px; }

.bubble .time {
  display: block;
  text-align: right;
  font-size: 10.5px;
  color: #667781;
  margin-top: 2px;
}
.bubble .time .ticks { color: #53bdeb; letter-spacing: -2px; margin-left: 3px; }

.bubble.flagged { box-shadow: 0 0 0 2px var(--fail), 0 1px .5px rgba(11, 20, 26, .13); }
.flag-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 5px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--fail);
  background: var(--fail-bg);
  border-radius: 5px;
  padding: 2px 7px;
}

.typing {
  align-self: flex-start;
  display: flex; gap: 3px;
  padding: 11px 13px;
  background: var(--wa-in);
  border-radius: 9px;
  border-top-left-radius: 2px;
}
.typing i { width: 6px; height: 6px; border-radius: 50%; background: #9aa5ad; animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; }
.typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 60%, 100% { opacity: .35; } 30% { opacity: 1; } }

.wa-empty {
  margin: auto;
  text-align: center;
  font-size: 13px;
  color: #667781;
  background: #fff;
  border-radius: 9px;
  padding: 11px 15px;
  box-shadow: 0 1px .5px rgba(11, 20, 26, .13);
  max-width: 82%;
}

/* ───────────── who is who ─────────────
   Inside the frame, where the two sides actually are, rather than in a
   caption underneath that nobody connects to the bubbles. */

.wa-legend {
  display: flex;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
  margin: 0;
  padding: 5px 10px;
  background: #e4ded6;
  border-bottom: 1px solid rgba(11, 20, 26, .08);
  font-size: 11px;
  color: #5a6b62;
}
.wa-legend b { color: #37433c; font-weight: 600; }
.wa-legend .dot {
  display: inline-block;
  width: 9px; height: 9px;
  border-radius: 2px;
  margin-right: 5px;
  vertical-align: -.5px;
  border: 1px solid rgba(11, 20, 26, .2);
}
.wa-legend .dot.out { background: var(--wa-out); }
.wa-legend .dot.in  { background: var(--wa-in); }

/* ───────────── the phone's own keyboard bar ───────────── */

.wa-input {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px 13px;
  background: #f0f2f5;
  border-radius: 0 0 28px 28px;
}
.wa-field { flex: 1; background: #fff; border-radius: 20px; padding: 8px 15px; font-size: 12.5px; color: #8696a0; }
.wa-send {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--wa-bar);
  color: #fff;
  display: grid; place-items: center;
  font-size: 14px;
  flex: none;
}

.progress {
  margin: 0;
  font-size: 12.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ───────────── monitor ───────────── */

.monitor {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 16px 22px 18px;
}
.monitor-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding-right: 2px;
}

.monitor-head {
  flex: none;
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 12px;
}
.mh-text { min-width: 0; }
.monitor-head h2 { margin: 0; font-size: 19px; letter-spacing: -.02em; }
.monitor-head p { margin: 2px 0 0; color: var(--muted); font-size: 14px; }
.mh-controls {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 14px;
  flex: none;
}

.step {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 18px;
  box-shadow: var(--shadow);
}
.step-n {
  width: 28px; height: 28px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--brand-dim);
  color: var(--brand);
  font-weight: 700;
  font-size: 13.5px;
}
.step-body { min-width: 0; }
/* Nothing in this column may run outside its card: a long canonical form
   or predicate name breaks across lines rather than off the screen. */
.step-body, .anchor, .values, .trace, .tr { overflow-wrap: anywhere; }
.step h3 { margin: 3px 0 1px; font-size: 15.5px; letter-spacing: -.01em; }
.step-sub { margin: 0 0 9px; font-size: 13px; color: var(--muted); }
.step-content { min-width: 0; }
.idle { margin: 0; color: var(--muted); font-size: 13.5px; }

.flow-arrow { text-align: center; color: var(--line-firm); font-size: 16px; line-height: 1; padding: 3px 0; }

/* step 1 — grounding */

.fact { padding: 9px 0; border-top: 1px dashed var(--line); }
.fact:first-child { border-top: 0; padding-top: 0; }
.fact-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.fact-name { font-family: var(--mono); font-size: 13.5px; font-weight: 500; }
.pill { font-size: 11.5px; font-weight: 650; border-radius: 999px; padding: 2px 9px; }
.pill-yes { background: var(--pass-bg); color: var(--pass); }
.pill-no  { background: var(--page);    color: var(--muted); }

.values {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 9px;
  max-height: 104px;
  overflow-y: auto;
}
.value {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line-firm);
  border-radius: 8px;
  padding: 4px 9px;
  font-size: 12.5px;
  background: #fbfcfe;
}
.value .said { color: var(--ink-soft); }
.value .to   { color: var(--muted); }
.value .got  { font-family: var(--mono); font-weight: 600; color: var(--brand); }
.value.linked { border-color: var(--fail); background: var(--fail-bg); }
.value.linked .got { color: var(--fail); }

/* step 2 — trace */

.trace {
  max-height: 150px;
  overflow-y: auto;
  margin: 0;
  padding: 0;
  list-style: none;
  scroll-behavior: smooth;
  /* positioned so a row's offsetTop is relative to this box: the demo
     scrolls the list itself, never the page. */
  position: relative;
  /* a row clipped at the edge with no hint reads as a rendering fault, so
     fade the boundary to say plainly that the list continues */
  mask-image: linear-gradient(180deg, #000 calc(100% - 22px), transparent 100%);
  -webkit-mask-image: linear-gradient(180deg, #000 calc(100% - 22px), transparent 100%);
  padding-bottom: 6px;
}
.tr {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 6px 9px;
  border-radius: 8px;
  font-family: var(--mono);
  font-size: 12.8px;
  color: var(--ink-soft);
}
.tr + .tr { margin-top: 3px; }
.tr .t { color: var(--muted); font-size: 11.5px; min-width: 2.4em; }
.tr .v { color: var(--brand); }
.tr.new     { background: var(--brand-dim); color: var(--ink); }
.tr.culprit { background: var(--fail-bg); color: var(--fail); font-weight: 500; }
.tr.culprit .t, .tr.culprit .v { color: var(--fail); }

/* step 3 — verdict */

.step-verdict.pass { border-color: #9fdcbd; background: linear-gradient(0deg, var(--pass-bg), var(--card) 62%); }
.step-verdict.fail { border-color: #f1a9a9; background: linear-gradient(0deg, var(--fail-bg), var(--card) 62%); }
.step-verdict.pass .step-n { background: var(--pass-bg); color: var(--pass); }
.step-verdict.fail .step-n { background: var(--fail-bg); color: var(--fail); }

.vd { display: flex; align-items: center; gap: 12px; }
.vd-icon {
  width: 38px; height: 38px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 19px;
  color: #fff;
  flex: none;
}
.pass .vd-icon { background: var(--pass); }
.fail .vd-icon { background: var(--fail); }
.vd-word { font-size: 17px; font-weight: 700; letter-spacing: -.01em; }
.pass .vd-word { color: var(--pass); }
.fail .vd-word { color: var(--fail); }
.vd-policy { font-family: var(--mono); font-size: 12px; color: var(--muted); }

.note { margin: 12px 0 0; border-radius: 10px; padding: 11px 13px; font-size: 13.5px; line-height: 1.55; }
.note.bad  { background: var(--fail-bg); color: #7a1a1a; }
.note.warn { background: var(--warn-bg); color: #6d4200; }
.note b { font-weight: 650; }

/* ───────────── modal ───────────── */

.modal-scrim { position: fixed; inset: 0; background: rgba(20, 24, 31, .45); z-index: 60; animation: fade .16s ease; }
.modal {
  position: fixed;
  z-index: 70;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: min(840px, 92vw);
  max-height: 86vh;
  overflow-y: auto;
  background: var(--card);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: var(--card);
  border-radius: 16px 16px 0 0;
}
.modal-head h2 { margin: 0; font-size: 17px; }
.modal-body { padding: 20px; }

.formula {
  font-family: var(--mono);
  font-size: 13.5px;
  line-height: 1.75;
  background: #f7f8fb;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 13px 15px;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0 0 14px;
  color: #2a2f3a;
  overflow-x: auto;
}
.modal h3 { margin: 22px 0 8px; font-size: 14px; letter-spacing: .01em; }
.modal h3:first-child { margin-top: 0; }
.modal p { margin: 0 0 12px; }

.pred-card {
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 13px 15px;
  margin-bottom: 10px;
  background: #fcfdff;
}
.pred-top { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; margin-bottom: 5px; }
.pred-name { font-family: var(--mono); font-size: 13.5px; font-weight: 600; color: var(--brand); }
.who {
  font-size: 11px; font-weight: 650; letter-spacing: .05em; text-transform: uppercase;
  border-radius: 999px; padding: 2px 9px; background: var(--page); color: var(--ink-soft);
}
.who.user { background: var(--brand-dim); color: var(--brand); }
.pred-card p { margin: 0 0 8px; font-size: 13.5px; }
.pred-arg { font-family: var(--mono); font-size: 12.5px; color: var(--ink-soft); }
.pred-arg b { color: var(--brand); font-weight: 600; }

.linkage { background: var(--brand-dim); border-radius: 10px; padding: 12px 14px; font-size: 13.5px; }
.linkage code { font-family: var(--mono); font-size: 12.5px; color: var(--brand); }

/* ───────────── short screens ───────────── */

@media (max-height: 760px) {
  .stage { padding: 9px 8px; }
  .wa-legend { padding: 5px 10px; }
}

/* ───────────── narrow ───────────── */

@media (max-width: 1080px) {
  /* one scrolling column: title, rule, phone, then the monitor under it */
  body { height: auto; overflow: visible; }
  .shell { flex-direction: column; height: auto; }
  .right { display: contents; }
  .rail {
    order: 0;
    width: 100%;
    flex-direction: row;
    padding: 10px 14px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .rulebar { order: 1; } .stage { order: 2; } .monitor { order: 3; }

  /* The rule bar costs a third of a phone screen, so it folds into the top
     row: the scenario's name beside the menu, and an "i" that opens the
     rule itself and the link to the formal policy. */
  .rail { align-items: center; gap: 12px; }
  .rail-name {
    display: block;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: var(--brand);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .rail-info {
    display: grid;
    place-items: center;
    flex: none;
    margin-left: auto;
    width: 30px; height: 30px;
    border-radius: 50%;
    border: 1px solid var(--line-firm);
    background: var(--card);
    color: var(--ink-soft);
    font: inherit;
    font-size: 13px;
    font-style: italic;
    font-weight: 700;
    cursor: pointer;
  }
  .shell.info-open .rail-info {
    background: var(--brand);
    border-color: var(--brand);
    color: #fff;
  }
  .rulebar { display: none; }
  .shell.info-open .rulebar { display: flex; }
  .rule-eyebrow { display: none; }
  .stage {
    width: 100%;
    --phone-w: 100%;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 16px 12px 18px;
    align-items: center;
  }

  /* On a phone the frame takes the width of the screen, so Back and Next
     cannot sit beside it -- they go under it as a pair of wide keys. */
  .stage-row {
    flex: none;
    width: 100%;
    max-width: 560px;
    margin: 0 auto;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
  }
  .phone {
    order: -1;
    width: 100%;
    height: clamp(430px, 68vh, 720px);
    align-self: auto;
    flex: none;
  }
  .nav {
    flex: 1 1 0;
    max-width: 210px;
    width: auto;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 9px;
    padding: 9px 14px;
    background: var(--card);
    border: 1px solid var(--line-firm);
    box-shadow: var(--shadow);
  }
  .nav-arrow {
    width: 24px; height: 24px;
    border: 0;
    box-shadow: none;
    background: transparent;
    font-size: 12px;
  }
  .nav:hover:not(:disabled) .nav-arrow { background: transparent; color: var(--brand); }
  .nav-label { font-size: 14.5px; }

  /* the heading and its controls stack rather than fighting for the width */
  .monitor { overflow: visible; }
  .monitor-head { flex-wrap: wrap; gap: 12px; }
  .mh-controls { margin-left: 0; width: 100%; flex-wrap: wrap; gap: 10px; }
  .speed { flex: 1 1 150px; min-width: 0; }
  #speed { flex: 1 1 auto; width: auto; min-width: 64px; }
  .progress { width: 100%; }
}
@media (max-width: 560px) {
  main { padding: 18px 14px 32px; }
  .rulebar { padding: 12px 14px; }
  .rule-text { font-size: 17px; }
  .link-btn { margin-left: 0; }
  .phone { height: 620px; }
}

/* ───────────── per-message monitor note ─────────────
   Each bubble carries what the monitor made of it. Someone stepping back
   through the conversation can read the verdict in place, rather than
   holding the right-hand panels in their head. */

.wrap-out, .wrap-in { display: flex; flex-direction: column; max-width: 86%; }
.wrap-out { align-self: flex-end; align-items: flex-end; }
.wrap-in  { align-self: flex-start; align-items: flex-start; }
.wrap-out .bubble, .wrap-in .bubble { max-width: 100%; }

.minfo { margin-top: 3px; max-width: 100%; }

.ibtn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 0;
  background: rgba(255, 255, 255, .72);
  border-radius: 11px;
  padding: 3px 9px;
  font: inherit;
  font-size: 10.5px;
  color: #4a5b52;
  cursor: pointer;
  box-shadow: 0 1px .5px rgba(11, 20, 26, .1);
}
.ibtn:hover { background: #fff; }
.minfo.bad .ibtn { background: rgba(255, 233, 233, .92); color: #9a2020; }
.imark { font-weight: 800; font-size: 11px; color: var(--pass); }
.minfo.bad .imark { color: var(--fail); }
.icaret { opacity: .55; font-size: 11px; }

.idetail {
  margin-top: 4px;
  background: rgba(255, 255, 255, .95);
  border-radius: 9px;
  padding: 8px 10px;
  box-shadow: 0 1px .5px rgba(11, 20, 26, .12);
  font-size: 11.5px;
  color: #3c4a44;
}
.irow { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 2px 0; }
.idot { width: 7px; height: 7px; border-radius: 50%; background: #c3ccc8; flex: none; }
.idot.yes { background: var(--pass); }
.iname { font-family: var(--mono); font-size: 11px; color: #22302a; }
.istate { color: #71807a; }
.ivals { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.iv {
  font-family: var(--mono);
  font-size: 10.5px;
  background: #eef3f0;
  border-radius: 5px;
  padding: 1px 6px;
  color: #2f4038;
}
.iv.hot { background: var(--fail-bg); color: var(--fail); font-weight: 600; }
.ifoot {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid #e6ebe8;
  color: #71807a;
  line-height: 1.7;
}
.ifoot code {
  font-family: var(--mono);
  font-size: 10.5px;
  background: #eef3f0;
  border-radius: 5px;
  padding: 1px 6px;
  color: #2f4038;
  white-space: nowrap;
}

/* ───────────── speed ─────────────
   0.5x is half speed, so the delay doubles -- slower than the old "Slow"
   preset, which is what someone reading every message out loud needs. */

.speed {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  font-size: 12.5px;
  color: var(--ink-soft);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 8px 13px;
  box-shadow: var(--shadow);
}
.speed-label { color: var(--muted); }
.speed output {
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--brand);
  min-width: 3.1em;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

#speed {
  -webkit-appearance: none;
  appearance: none;
  width: 92px;
  height: 4px;
  border-radius: 3px;
  background: var(--line-firm);
  cursor: pointer;
}
#speed::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--brand);
  border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(20, 24, 31, .3);
}
#speed::-moz-range-thumb {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--brand);
  border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(20, 24, 31, .3);
}
#speed:focus-visible { outline: 3px solid rgba(79, 70, 229, .4); outline-offset: 3px; }

/* ───────────── the anchor ─────────────
   The three steps below mix two timescales -- this message, and everything so
   far. Without naming the message they are about, the reader has to infer
   which panel means which. This says it. */

.anchor {
  border: 1px solid var(--line);
  border-left: 3px solid var(--brand);
  border-radius: 12px;
  background: var(--card);
  padding: 12px 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.anchor-idle { margin: 0; color: var(--muted); font-size: 13.5px; }
.anchor-head {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 5px;
}
.anchor-num {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 11.5px;
  background: var(--brand);
  color: #fff;
  border-radius: 6px;
  padding: 2px 7px;
}
.anchor-who {
  font-weight: 650;
  border-radius: 999px;
  padding: 1px 9px;
  font-size: 11.5px;
}
.anchor-who.user      { background: #e7f7ea; color: #1d6b32; }
.anchor-who.assistant { background: var(--page); color: var(--ink-soft); }
.anchor-text {
  margin: 0;
  font-size: 14px;
  color: var(--ink);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.anchor.bad { border-left-color: var(--fail); }
.anchor.bad .anchor-num { background: var(--fail); }

/* ───────────── timescale badges ───────────── */

.scope {
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: .01em;
  border-radius: 999px;
  padding: 2px 9px;
  margin-left: 7px;
  vertical-align: 1.5px;
  white-space: nowrap;
}
.scope.now { background: var(--brand-dim); color: var(--brand); }
.scope.all { background: #eef1f6; color: var(--ink-soft); }

/* ───────────── message numbers ───────────── */

.bubble .num {
  font-family: var(--mono);
  font-size: 10px;
  color: #8a9a92;
  margin-right: 5px;
  user-select: none;
}

/* ───────────── prompt viewer ───────────── */

.prompt-btn {
  border: 1px solid var(--line-firm);
  background: var(--card);
  color: var(--brand);
  font: inherit;
  font-size: 11.5px;
  font-weight: 600;
  border-radius: 7px;
  padding: 2px 9px;
  cursor: pointer;
  margin-left: auto;
}
.prompt-btn:hover { background: var(--brand-dim); border-color: var(--brand); }

.prompt-tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.prompt-tab {
  border: 1px solid var(--line-firm);
  background: var(--card);
  border-radius: 8px;
  padding: 7px 14px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  color: var(--ink-soft);
}
.prompt-tab.on { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.prompt-pre {
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.65;
  background: #f7f8fb;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 16px;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 52vh;
  overflow-y: auto;
  margin: 0;
  color: #2a2f3a;
}
.prompt-note {
  margin: 0 0 12px;
  font-size: 13.5px;
  color: var(--ink-soft);
  background: var(--brand-dim);
  border-radius: 10px;
  padding: 10px 13px;
}
.prompt-help {
  margin: 0 0 10px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--ink-soft);
}
