/* dotbot-lake live view. Tokens follow PyDotBot console-web tokens.css (Inria, BSD-3-Clause):
   dark by default, light from the system setting or data-theme="light". Colours are tokens only. */
:root {
  --canvas: #14161b;
  --surface: #1e222b;
  --elevated: #2a2f3a;
  --grid: #2c313c;
  --grid-sub: #21252d;
  --text: #e6e9ef;
  --muted: #9aa4b2;
  --accent: #e4032e;
  --hairline: rgba(255, 255, 255, 0.07);
  --tyre: #4a5160;
  --link: rgba(154, 164, 178, 0.28);

  /* State colours are shared across themes (console tokens). */
  --s-Running: #22c55e;
  --s-Programming: #f59e0b;
  --s-Stopping: #ef4444;
  --s-Inactive: #6b7280;
  --s-Bootloader: #38bdf8;
  --ok: var(--s-Running);
  --warn: var(--s-Programming);
  --err: var(--s-Stopping);
  --idle: var(--s-Inactive);
  --msg-up: var(--s-Bootloader);
  --msg-down: #a78bfa;
  --run: #c084fc; /* handshake running: the robot LED is purple (lakers-initiator 6f33195) */

  --font-ui: "IBM Plex Sans", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --canvas: #f4f6fa;
    --surface: #ffffff;
    --elevated: #eef1f6;
    --grid: #dbe1ea;
    --grid-sub: #e9edf3;
    --text: #0f172a;
    --muted: #5b6577;
    --hairline: rgba(0, 0, 0, 0.07);
    --tyre: #5a6270;
    --link: rgba(91, 101, 119, 0.3);
    --run: #9333ea;
    color-scheme: light;
  }
}
:root[data-theme="light"] {
  --canvas: #f4f6fa;
  --surface: #ffffff;
  --elevated: #eef1f6;
  --grid: #dbe1ea;
  --grid-sub: #e9edf3;
  --text: #0f172a;
  --muted: #5b6577;
  --hairline: rgba(0, 0, 0, 0.07);
  --tyre: #5a6270;
  --link: rgba(91, 101, 119, 0.3);
  --run: #9333ea;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--canvas); color: var(--text); }
body { font: 14px/1.45 var(--font-ui); -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; }
.mono { font-family: var(--font-mono); }
.muted { color: var(--muted); }

.wrap { max-width: 1120px; margin: 0 auto; padding: 14px 16px 40px; }

/* ---------------------------------------------------------------- header */
header { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; }
.brand { flex: 1 1 220px; min-width: 0; }
.brand h1 { margin: 0; font-size: 19px; font-weight: 700; letter-spacing: -0.01em; }
.brand h1 b { color: var(--accent); font-weight: 700; }
.brand p { margin: 2px 0 0; color: var(--muted); font-size: 12.5px; }
.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 9px;
  border: 1px solid var(--hairline); border-radius: 999px; background: var(--surface);
  font-size: 12px; color: var(--muted); white-space: nowrap;
}
.pill i { width: 8px; height: 8px; border-radius: 50%; background: var(--idle); display: inline-block; }
.pill[data-on="1"] i { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 22%, transparent); }
.pill[data-on="0"] i { background: var(--err); }
.pill[data-on="wait"] i { background: var(--warn); animation: dbBlink 1.2s infinite; }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 12px; }
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--hairline); border-radius: 8px; padding: 2px; }
.seg button {
  background: transparent; border: 0; border-radius: 6px; padding: 6px 11px; font-size: 12.5px;
  color: var(--muted); cursor: pointer;
}
.seg button[aria-pressed="true"] { background: var(--elevated); color: var(--text); }
.seg button:disabled { opacity: 0.4; cursor: not-allowed; }
.seg button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.toolbar .spacer { flex: 1; }

.demo-banner {
  display: none; margin-top: 10px; padding: 8px 12px; border-radius: 8px;
  background: color-mix(in srgb, var(--warn) 16%, var(--surface)); border: 1px solid color-mix(in srgb, var(--warn) 45%, transparent);
  font-size: 12.5px;
}
.demo-banner b { color: var(--warn); letter-spacing: 0.06em; }
body[data-mode="demo"] .demo-banner { display: block; }

.hint {
  display: none; margin-top: 10px; padding: 10px 12px; border-radius: 8px; background: var(--surface);
  border: 1px solid var(--hairline); font-size: 13px; align-items: center; gap: 10px; flex-wrap: wrap;
}
.hint.show { display: flex; }
.hint button {
  border: 0; border-radius: 6px; padding: 6px 12px; background: var(--accent); color: #fff; font-weight: 600; cursor: pointer;
}

/* ---------------------------------------------------------------- turn lock */
.lockbar {
  display: flex; align-items: center; gap: 10px; margin-top: 10px; padding: 8px 12px; border-radius: 8px;
  background: var(--surface); border: 1px solid var(--hairline); font-size: 13px;
}
.lockbar[hidden] { display: none; }
.lockbar .lock-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.lockbar .who { color: var(--muted); font-size: 12px; }
.lockbar .who b { color: var(--text); font-weight: 600; }
.lockbar .rej { color: var(--err); font-size: 12px; font-weight: 600; }
.lockbar[data-state="mine"] {
  background: color-mix(in srgb, var(--ok) 16%, var(--surface)); border-color: var(--ok);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 22%, transparent);
}
.lockbar .turn { color: var(--ok); font-size: 15px; letter-spacing: 0.02em; }
.lockbar .run { flex: none; }

/* ---------------------------------------------------------------- stats */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.stat { background: var(--surface); border: 1px solid var(--hairline); border-radius: 10px; padding: 9px 11px; min-width: 0; }
.stat .v { font: 600 22px/1.1 var(--font-mono); white-space: nowrap; }
.stat .v small { font-size: 12px; color: var(--muted); font-weight: 500; margin-left: 2px; }
.stat .k { font-size: 11px; color: var(--muted); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 420px) {
  .stat { padding: 8px 9px; }
  .stat .v { font-size: 18px; }
  .stat .k { font-size: 10.5px; }
}

/* ---------------------------------------------------------------- stage */
.stage {
  position: relative; margin-top: 12px; border-radius: 12px; border: 1px solid var(--hairline);
  background:
    linear-gradient(var(--grid-sub) 1px, transparent 1px) 0 0 / 24px 24px,
    linear-gradient(90deg, var(--grid-sub) 1px, transparent 1px) 0 0 / 24px 24px,
    var(--canvas);
  overflow: hidden; touch-action: manipulation;
}
.stage svg.links { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.stage .empty {
  position: absolute; left: 0; right: 0; bottom: 18px; text-align: center; color: var(--muted); font-size: 13px; padding: 0 16px;
}

.node { position: absolute; transform: translate(-50%, -50%); text-align: center; }
.server .box {
  display: inline-flex; align-items: center; gap: 9px; padding: 8px 12px 8px 10px; border-radius: 10px;
  background: var(--surface); border: 1px solid var(--hairline); box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
  white-space: nowrap;
}
.server .box svg { flex: none; }
.server .t { text-align: left; }
.server .t b { display: block; font-size: 13px; }
.server .t span { display: block; font-size: 11px; color: var(--muted); }
.server[data-on="1"] .box { border-color: color-mix(in srgb, var(--ok) 45%, transparent); }
.server.flash .box { animation: srvFlash 0.5s ease-out; }
@keyframes srvFlash { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--msg-up) 60%, transparent); } 100% { box-shadow: 0 0 0 14px transparent; } }

.bot { cursor: pointer; border: 0; background: transparent; padding: 0; transition: left 0.5s ease, top 0.5s ease; }
.bot:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 12px; }
.bot .glyph { position: relative; margin: 0 auto; }
.bot .glyph svg { display: block; overflow: visible; filter: drop-shadow(0 0 0.9px rgba(0, 0, 0, 0.6)) drop-shadow(0 2px 4px rgba(0, 0, 0, 0.35)); }
.bot .ring {
  position: absolute; inset: -6%; border-radius: 50%; border: 2px solid transparent; pointer-events: none;
}
.bot[data-state="running"] .ring { border-color: color-mix(in srgb, var(--run) 55%, transparent); animation: ripple 1.4s ease-out infinite; }
.bot[data-state="running"] .glyph svg { animation: breathe 1.4s ease-in-out infinite; }
.bot.burst-ok .ring { animation: burst 0.9s ease-out; border-color: var(--ok); }
.bot.burst-fail .glyph { animation: shake 0.45s ease-in-out; }
.bot[data-quiet="1"] .glyph { opacity: 0.55; }
.bot[aria-selected="true"] .glyph::after {
  content: ""; position: absolute; inset: -9%; border-radius: 14px; border: 2px solid var(--accent); pointer-events: none;
}
.bot.new .glyph { animation: appear 0.6s cubic-bezier(.2, .9, .3, 1.3); }
.bot .lbl { margin-top: 4px; font: 600 12.5px/1.2 var(--font-mono); color: var(--text); white-space: nowrap; }
.bot .sub { font-size: 11px; color: var(--muted); white-space: nowrap; }
.bot .sub b { font-weight: 600; }
.bot .sub b.ok { color: var(--ok); }
.bot .sub b.fail { color: var(--err); }
.bot .sub b.running { color: var(--run); }

@keyframes breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.035); } }
@keyframes ripple { 0% { transform: scale(0.85); opacity: 0.9; } 100% { transform: scale(1.18); opacity: 0; } }
@keyframes burst { 0% { transform: scale(0.8); opacity: 1; } 100% { transform: scale(1.3); opacity: 0; } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
@keyframes appear { 0% { transform: scale(0.4); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
@keyframes dbBlink { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
.led-blink { animation: dbBlink 0.9s ease-in-out infinite; }

.pulse-label { font: 600 11px var(--font-mono); paint-order: stroke; stroke: var(--canvas); stroke-width: 3.5px; stroke-linejoin: round; }

/* ---------------------------------------------------------------- legend + feed */
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 10px; font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; border: 1.5px solid rgba(255, 255, 255, 0.9); box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.6); }

h2 { font-size: 13px; font-weight: 600; margin: 18px 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.feed { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.feed li {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; background: var(--surface);
  border: 1px solid var(--hairline); font-size: 12.5px; cursor: pointer; min-width: 0;
}
.feed li .dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.feed li .who { font: 600 12.5px var(--font-mono); flex: none; }
.feed li .what { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted); }
.feed li .when { flex: none; color: var(--muted); font-size: 11.5px; }
.feed .none { color: var(--muted); background: transparent; border-style: dashed; cursor: default; }

footer { margin-top: 22px; font-size: 12px; color: var(--muted); line-height: 1.6; }
footer a { color: var(--accent); text-decoration: none; }

/* ---------------------------------------------------------------- details sheet */
.sheet-bg { position: fixed; inset: 0; background: color-mix(in srgb, var(--canvas) 55%, transparent); opacity: 0; pointer-events: none; transition: opacity 0.2s; z-index: 20; }
.sheet {
  position: fixed; z-index: 21; left: 0; right: 0; bottom: 0; max-height: 78vh; overflow-y: auto;
  background: var(--surface); border-top: 1px solid var(--hairline); border-radius: 14px 14px 0 0;
  padding: 10px 16px 22px; transform: translateY(calc(100% + 40px)); transition: transform 0.25s ease, visibility 0.25s;
  visibility: hidden;
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.3);
}
.sheet.open { transform: none; visibility: visible; }
.sheet-bg.open { opacity: 1; pointer-events: auto; }
.sheet .grab { width: 38px; height: 4px; border-radius: 2px; background: var(--grid); margin: 0 auto 10px; }
@media (min-width: 860px) {
  .sheet { left: auto; top: 0; width: 380px; max-height: none; border-radius: 0; border-top: 0; border-left: 1px solid var(--hairline); transform: translateX(calc(100% + 40px)); padding-top: 18px; }
  .sheet .grab { display: none; }
}
.sheet .head { display: flex; align-items: center; gap: 12px; }
.sheet .head .title { flex: 1; min-width: 0; }
.sheet .head b { display: block; font: 600 15px var(--font-mono); overflow-wrap: anywhere; }
.sheet .head span { font-size: 12px; color: var(--muted); }
.sheet .close { border: 1px solid var(--hairline); background: var(--elevated); border-radius: 8px; width: 34px; height: 34px; cursor: pointer; font-size: 18px; line-height: 1; }
.facts { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px 14px; margin-top: 14px; font-size: 13px; }
.facts dt { color: var(--muted); font-size: 12px; }
.facts dd { margin: 0; font-family: var(--font-mono); font-size: 12.5px; overflow-wrap: anywhere; }
.facts dd .tag { font-family: var(--font-ui); font-size: 11px; padding: 1px 6px; border-radius: 999px; margin-left: 6px; white-space: nowrap; display: inline-block; }
.tag.ok { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.tag.fail { background: color-mix(in srgb, var(--err) 18%, transparent); color: var(--err); }
.hist { display: flex; align-items: flex-end; gap: 4px; height: 64px; margin-top: 6px; padding: 6px 0; border-bottom: 1px solid var(--hairline); }
.hist div { flex: 1; max-width: 22px; border-radius: 3px 3px 0 0; min-height: 4px; }
.hist-list { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 4px; font-size: 12px; }
.hist-list li { display: flex; gap: 8px; align-items: center; font-family: var(--font-mono); font-size: 11.5px; }
.hist-list li .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.hist-list li .r { color: var(--muted); margin-left: auto; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

/* Run buttons: the robots handshake only when asked */
.run {
  border: 0; border-radius: 8px; padding: 7px 14px; background: var(--accent); color: #fff; font-weight: 600;
  cursor: pointer; min-height: 34px; white-space: nowrap;
}
.run:disabled { opacity: 0.45; cursor: not-allowed; }
.run:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
.sheet .run { width: 100%; margin-top: 12px; }

/* LAKE is the protocol name now; EDHOC (RFC 9528) stays as the secondary label */
.brand h1 small { font-size: 0.5em; font-weight: 600; color: var(--muted); letter-spacing: 0.04em; margin-left: 2px; vertical-align: 0.35em; }
#srv-name small { font-size: 0.7em; font-weight: 600; color: var(--muted); letter-spacing: 0.04em; }

/* ---------------------------------------------------------------- views: Swarm | Sequence */
.seqview { display: none; margin-top: 12px; }
body[data-view="sequence"] .seqview { display: block; }
body[data-view="sequence"] .stage,
body[data-view="sequence"] .legend,
body[data-view="sequence"] .swarm-only { display: none; }
.seq-top { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.seq-pick { display: flex; flex-wrap: wrap; gap: 6px; flex: 1 1 auto; min-width: 0; }
.seq-pick button {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 999px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--hairline); font: 500 12px var(--font-mono); color: var(--muted);
}
.seq-pick button[aria-pressed="true"] { color: var(--text); border-color: var(--accent); background: var(--elevated); }
.seq-pick button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.seq-pick i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5); }
.seq-link { display: block; margin-top: 10px; font-size: 12.5px; color: var(--accent); text-decoration: none; }
.seq-link:hover { text-decoration: underline; }
#seq-panel { background: var(--surface); border: 1px solid var(--hairline); border-radius: 12px; padding: 4px 12px 14px; margin-top: 10px; min-width: 0; }

/* ---------------------------------------------------------------- Sequence view: two lifelines, one arrow per frame */
.seq-demo {
  margin-top: 12px; padding: 7px 10px; border-radius: 8px; font-size: 12px;
  background: color-mix(in srgb, var(--warn) 16%, var(--surface)); border: 1px solid color-mix(in srgb, var(--warn) 45%, transparent);
}
.seq-demo b { color: var(--warn); letter-spacing: 0.06em; }
.seq-fine { font-size: 11.5px; margin: 8px 0 0; }
.seq { --life: 7px; margin-top: 10px; min-width: 0; }
.seq-heads { display: flex; justify-content: space-between; gap: 10px; position: sticky; top: 0; z-index: 1; background: var(--surface); padding: 4px 0 6px; }
.seq-heads > div {
  display: flex; flex-direction: column; padding: 5px 9px; border-radius: 8px; background: var(--elevated);
  border: 1px solid var(--hairline); min-width: 0;
}
.seq-heads > div:last-child { text-align: right; }
.seq-heads b { font-size: 12.5px; }
.seq-heads span { font-size: 10.5px; color: var(--muted); white-space: nowrap; }
.seq-body {
  position: relative; padding: 4px 0 10px; min-height: 60px;
  /* the two lifelines */
  background:
    linear-gradient(var(--grid), var(--grid)) var(--life) 0 / 2px 100% no-repeat,
    linear-gradient(var(--grid), var(--grid)) calc(100% - var(--life)) 0 / 2px 100% no-repeat;
}
.seq-none { margin: 0; padding: 18px 26px; color: var(--muted); font-size: 12.5px; text-align: center; }
.seq-msg { position: relative; margin: 10px 0 0; padding: 0 calc(var(--life) + 9px); --c: var(--msg-up); }
.seq-msg.down { --c: var(--msg-down); }
.seq-msg.t-resend { --c: var(--warn); }
.seq-msg.t-fail { --c: var(--err); }
.seq-msg.t-trigger { --c: #3b82f6; }
.seq-msg .arrow {
  position: relative; display: flex; align-items: flex-end; justify-content: space-between; gap: 8px;
  margin: 0 calc(-9px - 1px); padding: 0 12px 7px; font-size: 12px;
}
.seq-msg .arrow::before { /* the shaft */
  content: ""; position: absolute; left: 1px; right: 1px; bottom: 0; height: 2px; background: var(--c); border-radius: 1px;
  transform-origin: left center;
}
.seq-msg.down .arrow::before { transform-origin: right center; }
.seq-msg .arrow::after { /* the head */
  content: ""; position: absolute; bottom: -4px; right: -1px; border: 5px solid transparent; border-left: 8px solid var(--c); border-right: 0;
}
.seq-msg.down .arrow::after { right: auto; left: -1px; border-left: 0; border-right: 8px solid var(--c); }
.seq-msg.down .arrow { flex-direction: row-reverse; }
.seq-msg .lbl { font: 600 12.5px var(--font-mono); color: var(--c); }
.seq-msg .lbl small { font: 500 11px var(--font-ui); color: var(--muted); }
.seq-msg .lbl .rs { font: 600 10px var(--font-ui); font-style: normal; text-transform: uppercase; letter-spacing: 0.05em; color: var(--warn); border: 1px solid currentColor; border-radius: 4px; padding: 0 4px; margin-left: 3px; vertical-align: 1px; }
.seq-msg .when { font: 11px var(--font-mono); color: var(--muted); white-space: nowrap; }
.seq-msg .bytes {
  margin-top: 6px; padding: 6px 8px; border-radius: 8px; background: var(--canvas); border: 1px solid var(--hairline);
  border-left: 3px solid var(--c); display: grid; gap: 5px 14px; min-width: 0;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
}
/* short fields (header, METHOD, SUITES_I, C_I) pack side by side; long ones span the row */
.fld.long { grid-column: 1 / -1; }
.seq-msg.down .bytes { border-left-width: 1px; border-right: 3px solid var(--c); }
.fld { min-width: 0; }
.fld.sub { padding-left: 10px; border-left: 1px dashed var(--grid); }
.fld .fk { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; font-size: 11px; }
.fld .fk b { font: 600 11px var(--font-mono); letter-spacing: 0.02em; }
.fld .fk span { color: var(--muted); }
.fld code, .seq-res code {
  display: block; font: 11.5px/1.5 var(--font-mono); color: var(--text); white-space: normal; overflow-wrap: anywhere; word-break: break-word;
}
.fld code i { font-style: normal; color: var(--muted); }
.fld.hdr .fk b { color: var(--muted); }
.fld.hdr code { color: var(--muted); }
.seq-note {
  margin: 8px calc(var(--life) + 9px) 0 calc(var(--life) + 9px); font-size: 11.5px; color: var(--muted);
  padding: 3px 8px; border-left: 2px solid var(--grid); position: relative; overflow-wrap: anywhere;
}
.seq-note span { font: 600 10px var(--font-ui); text-transform: uppercase; letter-spacing: 0.05em; margin-right: 4px; }
.seq-note em { font: normal 11px var(--font-mono); float: right; margin-left: 8px; }
.seq-note.warn { color: var(--warn); border-left-color: var(--warn); }
#seq-res h3 { font-size: 12px; font-weight: 600; margin: 16px 0 0; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
#seq-res h3 .tag { font-size: 11px; padding: 1px 6px; border-radius: 999px; letter-spacing: 0; }
.seq-res { margin-top: 8px; }
.seq-res dd { min-width: 0; }

/* live: the shaft grows from the sender, then the bytes appear */
.seq-msg.new .arrow::before { animation: seqShaft 0.45s ease-out both; }
.seq-msg.new .arrow::after, .seq-msg.new .lbl, .seq-msg.new .when { animation: seqFade 0.25s 0.35s ease-out both; }
.seq-msg.new .bytes { animation: seqFade 0.35s 0.4s ease-out both; }
@keyframes seqShaft { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes seqFade { from { opacity: 0; transform: translateY(-3px); } to { opacity: 1; transform: none; } }

/* desktop: lifelines far apart, field name beside its bytes so a 32-byte key fits on one line */
@media (min-width: 760px) {
  .seq { --life: 24px; }
  .seq-heads > div { min-width: 160px; }
  .seq-msg { padding: 0 calc(var(--life) + 18px); }
  .seq-msg .arrow { margin: 0 calc(-18px - 1px); padding: 0 22px 8px; }
  .seq-msg .bytes { padding: 8px 12px; gap: 6px; }
  .seq-msg .bytes { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); column-gap: 18px; }
  .fld.long { display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 12px; align-items: baseline; }
  .fld .fk { flex-direction: column; gap: 0; }
  .fld.sub { padding-left: 14px; }
  .fld code { font-size: 12px; }
  .seq-note { margin-left: calc(var(--life) + 18px); margin-right: calc(var(--life) + 18px); }
}

/* ---------------------------------------------------------------- map layout: arena, charging zone, drag */
.sim-banner {
  display: none; margin-top: 10px; padding: 8px 12px; border-radius: 8px; font-size: 12.5px;
  background: color-mix(in srgb, var(--msg-up) 12%, var(--surface)); border: 1px solid color-mix(in srgb, var(--msg-up) 40%, transparent);
}
.sim-banner.show { display: block; }
.sim-banner b { color: var(--msg-up); }
.stage svg.arena { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.arena .field { fill: color-mix(in srgb, var(--surface) 70%, transparent); stroke: var(--grid); stroke-width: 1.5; }
.arena .fgrid { stroke: var(--grid-sub); stroke-width: 1; }
.arena .zone { fill: color-mix(in srgb, var(--ok) 13%, transparent); stroke: var(--ok); stroke-width: 1.6; }
.arena .zmargin { fill: none; stroke: color-mix(in srgb, var(--ok) 50%, transparent); stroke-width: 1; stroke-dasharray: 3 4; }
.arena .zicon path { fill: var(--ok); }
.arena .zlabel { font: 600 11.5px var(--font-ui); fill: var(--ok); }
.arena .fscale { font: 500 10.5px var(--font-mono); fill: var(--muted); }
.arena .tray { fill: none; stroke: var(--grid); stroke-width: 1.2; stroke-dasharray: 4 4; }
.stage[data-layout="map"] .bot { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.stage[data-layout="map"] .bot[data-drag="1"] { touch-action: none; cursor: grab; }
.stage[data-layout="map"] .bot.dragging { transition: none; cursor: grabbing; z-index: 5; }
.stage[data-layout="map"] .bot.dragging .glyph { transform: scale(1.12); }
.bot .ptag {
  position: absolute; top: -4px; right: -10px; padding: 0 4px; border-radius: 4px; pointer-events: none;
  font: 600 9.5px/14px var(--font-mono); text-transform: uppercase; letter-spacing: 0.04em;
  background: var(--msg-up); color: #0b1220;
}
.bot .ptag:empty { display: none; }
.bot .ptag[data-src="lh2"] { background: var(--elevated); color: var(--muted); border: 1px solid var(--hairline); }
.bot .zb { display: flex; flex-direction: column; align-items: center; font-size: 10.5px; line-height: 1.3; white-space: nowrap; }
.bot .zb:empty { display: none; }
.bot .zb b { font-weight: 600; padding: 1px 6px; border-radius: 999px; }
.bot .zb span { color: var(--muted); font-family: var(--font-mono); }
.bot .zb.ok b { color: var(--ok); background: color-mix(in srgb, var(--ok) 14%, var(--surface)); }
.bot .zb.fail b { color: #fff; background: var(--err); }
.bot .zb.warn b { color: #1a1300; background: var(--warn); }
.stage[data-layout="map"] .bot .lbl { font-size: 11.5px; }

.billing { margin-top: 4px; }
.billing .allow { margin: 0 0 8px; font-size: 12.5px; }
.billing .none { margin: 0; font-size: 12.5px; padding: 8px 10px; border-radius: 8px; background: var(--surface); }
.bill { width: 100%; border-collapse: collapse; font-size: 12.5px; background: var(--surface); border-radius: 8px; overflow: hidden; }
.bill th { text-align: left; font-weight: 500; color: var(--muted); font-size: 11px; padding: 6px 10px; border-bottom: 1px solid var(--hairline); }
.bill td { padding: 6px 10px; font-family: var(--font-mono); border-bottom: 1px solid var(--hairline); white-space: nowrap; }
.bill tr:last-child td { border-bottom: 0; }
.bill tr.open td { background: color-mix(in srgb, var(--ok) 7%, transparent); }
.bill b.ok { color: var(--ok); font-family: var(--font-ui); }
@media (max-width: 420px) { .bill th, .bill td { padding: 6px 7px; } }

/* ---------------------------------------------------------------- IETF 127 snapshot */
.snap-banner {
  margin: 0 0 12px; padding: 8px 12px; border-radius: 8px; font-size: 13px; line-height: 1.45;
  background: var(--surface); border: 1px solid var(--hairline); border-left: 3px solid var(--accent); color: var(--muted);
}
.snap-banner a { color: var(--text); text-underline-offset: 2px; overflow-wrap: anywhere; }
.snap-banner .sep { opacity: 0.6; margin: 0 2px; }
#pill-broker { display: none; } /* no broker in the snapshot */
body[data-src="rec"] .demo-banner { display: block; }
body[data-src="rec"] .run { display: none; } /* the recording is read only */

/* Slides view: the deck (1280x720 slides) scaled to the page width */
.slidesview { display: none; margin-top: 12px; }
body[data-view="slides"] .slidesview { display: block; }
body[data-view="slides"] .stage,
body[data-view="slides"] .legend,
body[data-view="slides"] .swarm-only,
body[data-view="slides"] .stats,
body[data-view="slides"] .seqview,
body[data-view="slides"] .billing,
body[data-view="slides"] #feed-title,
body[data-view="slides"] .feed,
body[data-view="slides"] .hint,
body[data-view="slides"] .demo-banner,
body[data-view="slides"] .data-only,
body[data-view="slides"] #run-all { display: none !important; }
.slide-frame {
  position: relative; width: 100%; aspect-ratio: 16 / 9; overflow: hidden; border-radius: 10px;
  border: 1px solid var(--hairline); background: #f4f6fa; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.18);
}
.slide-frame iframe { position: absolute; left: 0; top: 0; width: 1280px; height: 720px; border: 0; transform-origin: 0 0; }
.slide-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin-top: 10px; font-size: 13px; }
.slide-nav .nav {
  min-width: 44px; height: 36px; border-radius: 8px; cursor: pointer; font-size: 16px;
  background: var(--surface); border: 1px solid var(--hairline); color: var(--text);
}
.slide-nav .nav:disabled { opacity: 0.4; cursor: default; }
.slide-nav .nav:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.slide-nav .mono { font-family: var(--font-mono); color: var(--muted); min-width: 52px; text-align: center; }
.slide-nav .spacer { flex: 1 1 auto; }
.slide-nav .dl { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.slide-nav .dl a { color: var(--accent); text-decoration: none; }
.slide-nav .dl a:hover { text-decoration: underline; }
