/* The formal core, condensed: headline, one paragraph, one instrument (TLC's breadth-first
   search as a grid of states), and a collapsed drawer with one run through the machines, the
   results for every machine and, last, Meerkat Core composed step by step (composed.css). */

.cli .sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ---------- Head ---------- */
/* Compact: a wider measure beside the headline, and less air below it. */
.cli-head { column-gap: 48px; margin-bottom: 36px; }
.cli-head p { max-width: 660px; }
.cli-head h2 { text-wrap: balance; }
.cli-head h2 span { white-space: nowrap; }
.cli-head p { text-wrap: pretty; }

/* ---------- The search, drawn ---------- */
.cli-check-screen { height: clamp(256px, 19.5vw, 280px); }
.cli-check-screen canvas { position: absolute; inset: 0; width: 100%; height: 100%; }

/* The readout: four plain numbers, the pause key beside them, one caption line. On wide
   screens the caption sits between the numbers and the pause key, on one row. */
.cli-check-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "meter pause" "note note"; column-gap: 16px; padding: 16px 8px 0; }
.cli-check-row .key-pause { grid-area: pause; padding-top: 0; }
.cli-meter { grid-area: meter; min-width: 0; display: grid; grid-template-columns: minmax(0, 1.4fr) repeat(3, minmax(0, 1fr)); gap: 16px; margin: 0; }
.cli-meter > div { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.cli-meter dt { font-size: 10.5px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--mid); line-height: 1.3; }
.cli-meter dd { margin: 0; font-size: 24px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.15; font-variant-numeric: tabular-nums; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cli-check-note { grid-area: note; padding: 12px 0 4px; font-size: 13px; line-height: 1.5; color: var(--mid); }
@media (min-width: 1081px) {
  .cli-check-row { grid-template-columns: minmax(0, 1fr) minmax(0, 290px) auto; grid-template-areas: "meter note pause"; column-gap: 32px; align-items: center; padding: 10px 8px 0; }
  .cli-check-note { padding: 0; text-wrap: pretty; }
}

/* ---------- The quiet control ---------- */
.cli-more { margin-top: 20px; }
.cli-toggle { appearance: none; border: 0; background: transparent; font: inherit; color: var(--ink-2); cursor: pointer; display: inline-flex; align-items: center; gap: 12px; padding: 6px 4px 6px 0; font-size: 15px; font-weight: 500; line-height: 1.4; text-align: left; border-radius: 8px; }
.cli-toggle:hover { color: var(--ink); }
.cli-toggle:focus-visible { outline: 2px solid var(--accent-ink); outline-offset: 3px; }
.cli-toggle-cap { flex: none; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--screen); box-shadow: 0 1px 0 rgba(28, 28, 26, 0.12), inset 0 0 0 1px var(--line-2); transition: transform 0.2s, box-shadow 0.2s; }
.cli-toggle-cap svg { width: 12px; height: 12px; fill: none; stroke: var(--ink); stroke-width: 1.5; stroke-linecap: round; }
.cli-toggle-cap .v { transform-origin: 6px 6px; transition: transform 0.2s; }
.cli-toggle[aria-expanded="true"] { color: var(--ink); }
.cli-toggle[aria-expanded="true"] .cli-toggle-cap { box-shadow: inset 0 1px 2px rgba(28, 28, 26, 0.14), inset 0 0 0 1px var(--line-2); }
.cli-toggle[aria-expanded="true"] .cli-toggle-cap .v { transform: scaleY(0); }

.cli-under { margin-top: 28px; }
.cli-under[hidden] { display: none; }
.cli-under-lead { font-size: 15px; line-height: 1.55; color: var(--ink-2); max-width: 760px; margin-bottom: 18px; text-wrap: pretty; }

/* ---------- One run: terminal + machines ---------- */
.cli-bar { display: flex; align-items: center; gap: 10px; padding: 2px 2px 0; }
.cli-keys { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; gap: 4px; }
.cli-tab { appearance: none; border: 0; background: transparent; font: inherit; cursor: pointer; display: inline-flex; align-items: center; gap: 7px; padding: 6px 11px; border-radius: 999px; font-size: 13px; font-weight: 500; color: var(--mid); white-space: nowrap; }
.cli-tab::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--line); }
.cli-tab:hover { color: var(--ink); }
.cli-tab[aria-selected="true"] { color: var(--ink); background: var(--screen); box-shadow: 0 1px 0 rgba(28, 28, 26, 0.12); }
.cli-tab[aria-selected="true"]::before { background: var(--accent); }
.cli-inst.is-paused .cli-tab[aria-selected="true"]::before { background: var(--ink-2); }
.cli-tab:focus-visible, .cli-pause:focus-visible { outline: 2px solid var(--accent-ink); outline-offset: 2px; }
.cli-pause { appearance: none; border: 0; cursor: pointer; flex: none; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--screen); box-shadow: 0 1px 0 rgba(28, 28, 26, 0.12); }
.cli-pause[hidden] { display: none; }
.cli-pause svg { width: 11px; height: 11px; fill: var(--ink-2); }
.cli-inst.is-paused .cli-pause { box-shadow: inset 0 1px 2px rgba(28, 28, 26, 0.14); }
.cli-progress { height: 2px; background: var(--line-2); margin: 10px 4px 0; border-radius: 2px; overflow: hidden; }
.cli-progress i { display: block; height: 100%; width: 0; background: var(--ink-2); }
.cli-readout { padding: 10px 4px 12px; }
.cli-readout .moment { display: grid; max-width: 820px; font-size: 13.5px; line-height: 1.5; color: var(--ink-2); }
.cli-readout .moment > div { grid-area: 1 / 1; }
.cli-readout .moment > div[aria-hidden="true"] { visibility: hidden; }

.cli-screens { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 8px; align-items: stretch; }

.cli-term { position: relative; contain: size; display: flex; flex-direction: column; min-height: 0; background: #1d1d1b; color: #e7e6e1; border-radius: 12px; overflow: hidden; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.04); }
.cli-term-head { flex: none; display: flex; align-items: center; justify-content: space-between; padding: 10px 14px 8px; font-size: 10px; font-weight: 600; letter-spacing: 0.09em; text-transform: uppercase; color: #8d8c86; border-bottom: 1px solid rgba(255, 255, 255, 0.06); }
.cli-live { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); transition: background 0.2s; }
.cli-live.off { background: #4a4a46; }
.cli-term-lines { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; overflow-anchor: none; padding: 10px 14px 14px 0; font-family: var(--mono); font-size: 11.5px; line-height: 1.58; scrollbar-width: thin; scrollbar-color: #3a3a37 transparent; }
.cli-l { display: grid; grid-template-columns: 46px minmax(0, 1fr); column-gap: 10px; }
.cli-g { text-align: right; font-size: 9.5px; letter-spacing: 0.05em; color: #8d8c86; padding-top: 1.5px; user-select: none; }
/* A terminal, not a text box: one line per line, clipped at the edge. Only the agent's own
   prose (its thinking, its finding) and the session summary wrap, at word boundaries. */
.cli-x { white-space: pre; overflow: hidden; text-overflow: ellipsis; }
.cli-l.k-thought .cli-x, .cli-l.k-out .cli-x, .cli-l.k-sys .cli-x { white-space: pre-wrap; overflow-wrap: break-word; text-overflow: clip; }
.cli-l.k-arg .cli-x, .cli-l.k-jobout .cli-x { padding-left: 2ch; }
.cli-l.k-arg .cli-x { color: #e7e6e1; }
.cli-l.k-jobout .cli-x { color: #a3a29c; }
.cli-l.k-cmd { margin-bottom: 6px; }
.cli-l.k-cmd .cli-g, .cli-l.k-prompt .cli-g { font-size: 11.5px; padding-top: 0; color: #8d8c86; }
.cli-l.k-cmd .cli-x { color: #fafaf7; }
.cli-l.k-in .cli-x { color: #a3a29c; }
.cli-l.k-in + .cli-l:not(.k-in) { margin-top: 8px; }
.cli-l.k-think { margin-top: 2px; }
.cli-l.k-thought .cli-x { color: #a3a29c; font-style: italic; }
.cli-l.k-tool { margin-top: 8px; }
.cli-l.k-tool .cli-x { color: #e7e6e1; }
.cli-tag { font-style: italic; color: var(--accent); margin-right: 2px; }
.cli-l.k-ok .cli-x { color: #8d8c86; }
.cli-ok { font-style: normal; color: #c9c8c2; }
.cli-l.k-job .cli-x { color: #a3a29c; }
.cli-l.k-ok + .cli-l.k-job { margin-top: 10px; }
.cli-l.k-jobout + .cli-l.k-job { margin-top: 4px; }
.cli-l.k-jobout + .cli-l.k-out, .cli-l.k-out + .cli-l.k-job, .cli-l.k-jobout + .cli-l.k-ctl { margin-top: 10px; }
.cli-l.k-out .cli-x { color: #fafaf7; font-weight: 500; }
.cli-l.k-ctl { margin-top: 10px; }
.cli-l.k-sys .cli-x { color: #8d8c86; }
.cli-l.k-prompt { margin-top: 6px; }
.cli-cur { display: inline-block; width: 0.62em; height: 1.15em; margin-left: 1px; vertical-align: -0.2em; background: var(--accent); animation: cli-blink 1.05s steps(1) infinite; }
.cli-inst.is-paused .cli-cur { animation: none; background: #6d6c67; }
@keyframes cli-blink { 50% { opacity: 0; } }

.cli-rig { position: relative; background: var(--screen); border-radius: 12px; overflow: hidden; box-shadow: inset 0 0 0 1px var(--line-2); }
.cli-rig canvas { position: absolute; inset: 0; width: 100%; height: 100%; }

.cli-legend i { flex: none; display: inline-block; width: 9px; height: 9px; border-radius: 50%; }
.cli-legend .cl-cur { background: var(--ink); }
.cli-legend .cl-seen { background: var(--screen); border: 1.2px solid rgba(28, 28, 26, 0.6); }
.cli-legend .cl-arc { width: 14px; height: 7px; border-radius: 14px 14px 0 0; border: 1.2px solid rgba(28, 28, 26, 0.45); border-bottom: 0; }
.cli-legend .cl-q { border-radius: 0; border: 1.2px solid rgba(28, 28, 26, 0.75); background: transparent; }
.cli-legend .cl-a { border-radius: 0; background: var(--ink); }
.cli-legend .cl-cell { border-radius: 0; width: 11px; height: 11px; background: var(--ink); }
.cli-legend .cl-held { width: 12px; border-radius: 0; background: transparent; position: relative; }
.cli-legend .cl-held::after { content: ""; position: absolute; left: 2px; top: 0; width: 4px; height: 7px; border: solid var(--green); border-width: 0 1.5px 1.5px 0; transform: rotate(45deg); }

/* ---------- The chain: one transition through definition, Rust, TLA+ and TLC ---------- */
/* 1 -> 2 across the top, 1 -> 3 down the left, 3 -> 4 along the bottom. */
.cli-art { margin-top: 56px; }
.cli-art-lead { font-size: 15px; line-height: 1.5; color: var(--ink-2); margin-bottom: 16px; max-width: 720px; }
.cli-art-lead code { font-size: 13.5px; }
.cli-art-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 28px 34px; }
.cli-pane { position: relative; background: var(--screen); border-radius: 10px; box-shadow: inset 0 0 0 1px var(--line); display: flex; flex-direction: column; min-width: 0; }
.cli-pane figcaption { display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 10px; align-items: baseline; padding: 12px 16px 9px; border-bottom: 1px solid var(--line-2); }
.cli-pane figcaption i { grid-row: 1 / span 2; font-style: normal; font-size: 11px; font-weight: 600; color: var(--screen); background: var(--ink); width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; align-self: start; margin-top: 1px; }
.cli-pane figcaption b { font-size: 14px; font-weight: 600; letter-spacing: -0.01em; }
.cli-pane figcaption span { font-size: 12.5px; color: var(--mid); line-height: 1.4; }
.cli-pane pre { margin: 0; padding: 10px 16px 14px; overflow-x: auto; font-size: 11px; line-height: 1.55; color: var(--ink-2); scrollbar-width: thin; scrollbar-color: var(--line) transparent; flex: 1; }
.cli-pane .kw { color: var(--ink); font-weight: 600; }
.cli-pane .cmt { color: var(--mid); }
.id { color: var(--ink); font-weight: 600; border-radius: 3px; box-shadow: 0 1.5px 0 rgba(28, 28, 26, 0.18); transition: color 0.25s, background-color 0.25s, box-shadow 0.25s; }
.id.lit { color: var(--accent-ink); background: rgba(224, 89, 42, 0.12); box-shadow: 0 0 0 2px rgba(224, 89, 42, 0.12); }
.cli-art-lead .id { font-family: var(--mono); }
.cli-pane .id-k { font-weight: 500; }
.cli-pane .id-k.lit { color: var(--green); background: rgba(70, 132, 60, 0.12); box-shadow: 0 0 0 2px rgba(70, 132, 60, 0.12); }
.cli-pane[data-n="1"]::after, .cli-pane[data-n="3"]::after { content: ""; position: absolute; top: 31px; right: -27px; width: 20px; height: 1px; background: var(--ink); }
.cli-pane[data-n="1"]::before, .cli-pane[data-n="3"]::before { content: ""; position: absolute; top: 27.5px; right: -29px; border: 3.5px solid transparent; border-left: 5px solid var(--ink); }
.cli-pane[data-n="1"] > figcaption::after { content: ""; position: absolute; left: 24px; bottom: -22px; width: 1px; height: 16px; background: var(--ink); }
.cli-pane[data-n="1"] > figcaption::before { content: ""; position: absolute; left: 20.5px; bottom: -28px; border: 3.5px solid transparent; border-top: 5px solid var(--ink); }
.cli-art-close { margin-top: 20px; font-size: 15.5px; line-height: 1.5; font-weight: 500; color: var(--ink); max-width: 760px; }

/* ---------- Every machine ---------- */
.cli-results { margin-top: 56px; display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 40px; align-items: start; }
.cli-results-head .label { display: block; margin-bottom: 10px; }
.cli-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.cli-table thead th { padding: 0 0 10px; font-size: 10.5px; font-weight: 600; letter-spacing: 0.07em; text-transform: uppercase; color: var(--mid); text-align: left; vertical-align: bottom; border-bottom: 1px solid var(--ink); }
.cli-table .n { text-align: right; font-variant-numeric: tabular-nums; padding-left: 14px; white-space: nowrap; }
.cli-table thead th.n { white-space: normal; width: 1%; line-height: 1.3; }
.cli-table .r { width: 26px; text-align: right; padding-left: 10px; }
.cli-table tbody th, .cli-table tbody td { padding: 8px 0; border-bottom: 1px solid var(--line); vertical-align: baseline; }
.cli-table tbody td.n { padding-left: 14px; color: var(--ink); }
.cli-table tbody th { font-weight: 400; text-align: left; }
.cli-table tbody th code { display: block; font-size: 12.5px; color: var(--ink); line-height: 1.35; }
.cli-gov { display: block; font-size: 12.5px; color: var(--mid); line-height: 1.4; margin-top: 1px; }
.cli-sub-m { display: none; }
.cli-held svg { width: 13px; height: 13px; fill: none; stroke: var(--green); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; vertical-align: -2px; }
.cli-table tfoot th, .cli-table tfoot td { padding: 12px 0 0; font-size: 13px; font-weight: 600; text-align: left; border-top: 1px solid var(--ink); }
.cli-table tfoot td.n { text-align: right; padding-left: 14px; }
.cli-table-note { font-size: 13.5px; line-height: 1.55; color: var(--mid); max-width: 420px; }

/* ---------- Core, composed (composed.js mounts it here when the drawer first opens) ---------- */
.cli-composed { margin-top: 56px; }
.cli-composed:empty { display: none; }

/* ---------- Responsive ---------- */
@media (max-width: 1080px) {
  .cli-results { grid-template-columns: 1fr; gap: 16px; }
  .cli-table-note { max-width: 620px; }
}
@media (max-width: 960px) {
  .cli-screens { grid-template-columns: 1fr; }
  .cli-term { height: 156px; }
  .cli-art-grid { grid-template-columns: minmax(0, 1fr); gap: 30px; }
  .cli-pane[data-n="1"]::after, .cli-pane[data-n="3"]::after, .cli-pane[data-n="1"]::before, .cli-pane[data-n="3"]::before, .cli-pane[data-n="1"] > figcaption::after, .cli-pane[data-n="1"] > figcaption::before { display: none; }
  .cli-pane + .cli-pane::after { content: ""; position: absolute; left: 24px; top: -24px; width: 1px; height: 16px; background: var(--ink); }
  .cli-pane + .cli-pane::before { content: ""; position: absolute; left: 20.5px; top: -9px; border: 3.5px solid transparent; border-top: 5px solid var(--ink); }
}
@media (max-width: 720px) {
  .cli-head { margin-bottom: 28px; }
  .cli-check-screen { height: 340px; }
  /* The numbers take the full width; the pause key moves beside the caption. */
  .cli-check-row { grid-template-areas: "meter meter" "note pause"; column-gap: 12px; padding: 14px 6px 0; }
  .cli-check-row .key-pause { align-self: center; margin-top: 6px; }
  .cli-meter { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .cli-meter dd { font-size: 21px; }
  .cli-meter .cm-name dd { font-size: 18px; line-height: 1.34; }
  .cli-check-note { padding: 10px 0 2px; font-size: 12.5px; }
  .cli-toggle { font-size: 14.5px; gap: 10px; }
  .cli-bar { align-items: flex-start; }
  .cli-tab { padding: 5px 9px; font-size: 12px; gap: 6px; }
  .cli-readout .moment { font-size: 13px; }
  .cli-term { height: 150px; border-radius: 10px; }
  .cli-term-lines { font-size: 10.5px; line-height: 1.58; padding: 8px 12px 10px 0; }
  .cli-l { grid-template-columns: 38px minmax(0, 1fr); column-gap: 8px; }
  .cli-g { font-size: 9.5px; letter-spacing: 0; }
  .cli-term-head { padding: 9px 12px 7px; }
  .cli-rig { border-radius: 10px; }
  .cli-art { margin-top: 44px; }
  .cli-pane pre { font-size: 10.5px; padding: 10px 14px 14px; -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent); }
  .cli-pane figcaption { padding: 12px 14px 9px; }
  .cli-results { margin-top: 44px; }
  .cli-composed { margin-top: 44px; }
  .cli-table .c-inv, .cli-table .c-dep { display: none; }
  .cli-table { font-size: 12.5px; }
  .cli-table .n { padding-left: 8px; }
  .cli-table thead th { font-size: 9.5px; letter-spacing: 0.05em; }
  .cli-table tbody td.n { padding-left: 8px; }
  .cli-table tbody th code { font-size: 12px; }
  .cli-gov { font-size: 12px; }
  .cli-sub-m { display: block; font-size: 11.5px; color: var(--mid); margin-top: 2px; }
  .cli-table tfoot th .cli-sub-m { font-weight: 500; }
}
@media (max-width: 359px) {
  .cli-meter dd { font-size: 18px; }
  .cli-meter .cm-name dd { font-size: 15.5px; line-height: 1.34; }
  .cli-tab { padding: 4px 7px; font-size: 11.5px; }
}
@media (prefers-reduced-motion: reduce) {
  .cli-cur { animation: none; }
  .cli-toggle-cap, .cli-toggle-cap .v { transition: none; }
}
