/* ============================================================
   MQTT Deck — landing candidate B ("the window is the page")

   Every value in the window below is taken from the app's own
   design system (src/index.css): the same token names, the same
   11 / 12 / 13 / 15 / 20 type ramp, the same 8px rhythm, the
   same ember accent, the same hairline rules. Nothing in the
   window is invented; the page around it adds one display step
   (32 / 44) because the app never renders above 20px.

   Dark is the default; light follows the OS.
   ============================================================ */

@font-face {
  font-family: "Inter Variable";
  src: url("assets/fonts/inter.woff2") format("woff2-variations");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "JetBrains Mono Variable";
  src: url("assets/fonts/jetbrains-mono.woff2") format("woff2-variations");
  font-weight: 100 800;
  font-style: normal;
  font-display: swap;
}

:root {
  --font-ui: "Inter Variable", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI",
    Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono Variable", "JetBrains Mono", ui-monospace, SFMono-Regular,
    "SF Mono", Menlo, Consolas, monospace;

  /* type ramp — the app's five working steps */
  --fs-xs: 11px;
  --fs-sm: 12px;
  --fs-md: 13px;
  --fs-lg: 15px;
  --fs-xl: 20px;
  /* the page's two display steps */
  --fs-32: 32px;
  --fs-44: 44px;

  --r-sm: 4px;
  --r-md: 6px;
  --r-lg: 10px;
  --r-xl: 14px;

  --ease: cubic-bezier(0.22, 0.68, 0.35, 1);
  --dur: 140ms;

  /* message grid: time / dir / topic / payload / flags */
  --msg-cols: 84px 42px minmax(110px, 1.05fr) minmax(0, 1.5fr) 72px;
  /* The window is presented at the app's compact pane widths (what the app
     itself uses below 1280px) so that the payload column survives on a 1440
     page next to the tree and the inspector. */
  --rail-w: 232px;
  --tree-w: 210px;
  --insp-w: 324px;

  --page: 1120px;
  --page-pad: 24px;
  --gutter: 32px;
}

/* One palette, two themes. The surfaces are deliberately far apart: a cool
   chrome (rail, tree, header, composer) on a neutral content field. */
:root {
  color-scheme: dark;
  --bg: #0b0d11;
  --bg-sunken: #080a0d;
  --panel: #161b23;
  --panel-2: #1d232d;
  --panel-3: #262e3a;
  --raise: #2b3442;
  --line: #232b36;
  --line-2: #313b49;
  --line-3: #43505f;

  --text: #eef2f7;
  --text-2: #bcc7d5;
  --text-3: #9dabbb;
  --text-4: #9dabbb;

  --accent: #ff7a45;
  --accent-2: #ff9668;
  --accent-ink: #1a0a04;
  --accent-text: #ff9a70;
  --accent-soft: rgba(255, 122, 69, 0.13);
  --accent-line: rgba(255, 122, 69, 0.38);

  --ok: #3ddc97;
  --warn: #f5b544;
  --danger: #ff6b6b;
  --ok-ink: #06231a;
  --warn-ink: #241703;
  --danger-ink: #2a0808;
  --ok-halo: rgba(61, 220, 151, 0.24);
  --ok-glow: rgba(61, 220, 151, 0.42);
  --danger-halo: rgba(255, 107, 107, 0.24);
  --warn-halo: rgba(245, 181, 68, 0.26);

  --data-in: #6fb0ff;
  --data-out: #ff8a5c;
  --q1: #9dabbb;
  --q2: #b18cff;
  --retain: #f5b544;
  --dup: #ff6b6b;
  --info: #6fb0ff;
  --violet: #b18cff;

  --focus: #ff7a45;
  --shadow: 0 20px 56px rgba(0, 0, 0, 0.66), 0 1px 3px rgba(0, 0, 0, 0.5);
  --row-in: rgba(111, 176, 255, 0.05);
  --row-out: rgba(255, 138, 92, 0.05);
  --scroll: #303a47;
  --msg-border: var(--line);
  --page-line: #1b222b;
}

@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --bg: #e9edf2;
    --bg-sunken: #e1e6ed;
    --panel: #ffffff;
    --panel-2: #f3f6fa;
    --panel-3: #e6ecf3;
    --raise: #ffffff;
    --line: #dbe2ea;
    --line-2: #c9d3de;
    --line-3: #aebbc9;

    --text: #0d1117;
    --text-2: #46525f;
    --text-3: #5b6875;
    --text-4: #5b6875;

    --accent: #c2410c;
    --accent-2: #a83806;
    --accent-ink: #ffffff;
    --accent-text: #a83806;
    --accent-soft: rgba(194, 65, 12, 0.09);
    --accent-line: rgba(194, 65, 12, 0.34);

    --ok: #0a7047;
    --warn: #8a5a06;
    --danger: #c0392b;
    --ok-ink: #ffffff;
    --warn-ink: #ffffff;
    --danger-ink: #ffffff;
    --ok-halo: rgba(10, 112, 71, 0.2);
    --ok-glow: rgba(10, 112, 71, 0.32);
    --danger-halo: rgba(192, 57, 43, 0.2);
    --warn-halo: rgba(138, 90, 6, 0.2);

    --data-in: #1d5fd0;
    --data-out: #a6400f;
    --q1: #5b6875;
    --q2: #6b3fd4;
    --retain: #8a5a06;
    --dup: #c0392b;
    --info: #1d5fd0;
    --violet: #6b3fd4;

    --focus: #c2410c;
    --shadow: 0 18px 48px rgba(19, 30, 44, 0.16), 0 1px 3px rgba(19, 30, 44, 0.08);
    --row-in: rgba(29, 95, 208, 0.05);
    --row-out: rgba(166, 64, 15, 0.05);
    --scroll: #b9c4d1;
    --msg-border: rgba(0, 0, 0, 0.045);
    --page-line: #d6dee7;
  }
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: var(--fs-md);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: "cv05" 1, "ss03" 1;
}

[hidden] {
  display: none !important;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  background: none;
  border: 0;
  cursor: pointer;
}

a {
  color: var(--accent);
}

::selection {
  background: var(--accent-soft);
}

/* A real, measurable ring — 7.6:1 dark, 5.2:1 light. WCAG 2.4.11 needs 3:1. */
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: inherit;
}

input::placeholder,
textarea::placeholder {
  color: var(--text-3);
  opacity: 1;
}

/* scrollbars */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--scroll) transparent;
}
*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
*::-webkit-scrollbar-track {
  background: transparent;
}
*::-webkit-scrollbar-thumb {
  background: var(--scroll);
  border-radius: 99px;
  border: 3px solid transparent;
  background-clip: padding-box;
}

.sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.ico {
  flex: none;
}

/* ---------------------------------------------------------------- typography */

.mono {
  font-family: var(--font-mono);
  font-variant-ligatures: none;
}
.label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-3);
}
.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.kbd {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--panel-3);
  border: 1px solid var(--line-2);
  color: var(--text-2);
  line-height: 1.5;
  white-space: nowrap;
}

/* ---------------------------------------------------------------- page shell */

.skip {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: 100;
  padding: 10px 14px;
  border-radius: var(--r-md);
  background: var(--accent);
  color: var(--accent-ink);
  font-size: var(--fs-md);
  font-weight: 600;
  text-decoration: none;
  transition: top var(--dur) var(--ease);
}
.skip:focus {
  top: 12px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--panel);
  border-bottom: 1px solid var(--line-2);
}

.topbar-inner {
  display: flex;
  align-items: center;
  gap: 16px;
  height: 64px;
  padding: 0 var(--page-pad);
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--text);
  text-decoration: none;
  user-select: none;
}
.brand-mark {
  width: 26px;
  height: 26px;
  border-radius: var(--r-sm);
  display: grid;
  place-items: center;
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.18);
  flex: none;
}
.brand-name {
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.brand-name span {
  color: var(--text-3);
  font-weight: 500;
}
.brand-version {
  font-size: 11px;
  color: var(--text-3);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 5px;
  margin-left: 2px;
}

.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}
.topnav {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 20px;
}
.topnav a {
  font-size: var(--fs-md);
  color: var(--text-2);
  text-decoration: none;
  padding: 6px 0;
  border-bottom: 1px solid transparent;
  transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.topnav a:hover {
  color: var(--text);
  border-bottom-color: var(--accent-line);
}

/* The page's one button. Everything the window shows is a mock; this is real. */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 46px;
  padding: 0 18px;
  border: 0;
  border-radius: var(--r-md);
  background: var(--accent);
  color: var(--accent-ink);
  font-size: var(--fs-md);
  font-weight: 620;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.16) inset;
  transition: background var(--dur) var(--ease), opacity var(--dur) var(--ease),
    transform 60ms var(--ease);
}
.btn-primary:hover {
  background: var(--accent-2);
}
.btn-primary:active {
  transform: scale(0.985);
}
.btn-primary:disabled {
  opacity: 0.55;
  pointer-events: none;
}
.topbar .btn-primary {
  height: 44px;
  margin-left: 4px;
}

.wrap {
  width: 100%;
  max-width: calc(var(--page) + 2 * var(--page-pad));
  margin-inline: auto;
  padding-inline: var(--page-pad);
}

/* ---------------------------------------------------------------- the window */

/* The window is full-bleed: it is the page, not a framed picture of it. */
.window-section {
  padding: 24px 0 0;
}

.app {
  display: grid;
  grid-template-columns: var(--rail-w) minmax(0, 1fr);
  height: clamp(640px, 88vh, 900px);
  background: var(--bg);
  border-bottom: 1px solid var(--line-2);
  border-radius: 12px 12px 0 0;
  overflow: hidden;
}

.window-caption {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  padding: 12px var(--page-pad) 0;
  font-size: 11px;
  color: var(--text-3);
}
.window-caption .mono {
  color: var(--text-3);
}
.window-caption-hint {
  margin-left: auto;
  color: var(--text-2);
}

/* ------------------------------------------------------------------- rail */

.rail {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  background: var(--panel);
  border-right: 1px solid var(--line-2);
}

.rail-header {
  height: 54px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 12px 0 14px;
  border-bottom: 1px solid var(--line);
  flex: none;
}
.rail-header .brand {
  margin-right: auto;
}
.rail-tools {
  display: flex;
  gap: 4px;
}

.rail-search {
  padding: 10px 12px 8px;
  flex: none;
}
.search {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  color: var(--text-4);
}
.search .ico {
  color: var(--text-3);
}
.search-value {
  font-size: var(--fs-md);
  color: var(--text-4);
}

.rail-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 4px 8px 12px;
}

.section-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 6px 6px;
  color: var(--text-3);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}
.section-row .count {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0;
}

.group-head {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 6px 0 2px;
  margin-top: 6px;
  border-radius: var(--r-sm);
  color: var(--text-3);
  user-select: none;
}
.group-head.synthetic {
  margin-top: 12px;
}
.group-toggle {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  flex: 1;
  height: 100%;
  color: inherit;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.group-toggle svg {
  color: var(--text-3);
}
.group-toggle svg.open {
  transform: rotate(90deg);
}
.group-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.group-head .count {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-3);
  flex: none;
}

.conn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  position: relative;
}
.conn:last-child {
  border-bottom: 1px solid var(--line);
}
.conn.active {
  background: var(--panel-3);
  border-bottom-color: var(--line);
}
.conn.active::before {
  content: "";
  position: absolute;
  left: -8px;
  top: 50%;
  transform: translateY(-50%);
  width: 2px;
  height: 16px;
  border-radius: 2px;
  background: var(--accent);
}
.conn-body {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
}
.conn-name {
  font-size: var(--fs-md);
  font-weight: 550;
  letter-spacing: -0.005em;
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.conn-host {
  color: var(--text-3);
  font-size: var(--fs-sm);
  font-family: var(--font-mono);
  margin-top: 1px;
  min-width: 0;
}
.conn-badge {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 1px 4px;
  border-radius: 3px;
  background: var(--panel-3);
  color: var(--text-3);
  text-transform: uppercase;
  flex: none;
}

/* connection state: solid = connected, half = working, hollow = not */
.dot {
  width: 10px;
  height: 10px;
  border-radius: 99px;
  flex: none;
  background: transparent;
  box-shadow: inset 0 0 0 1.5px var(--text-3);
}
.dot.connected {
  background: var(--ok);
  box-shadow: 0 0 0 3px var(--ok-halo), 0 0 10px 1px var(--ok-glow);
}
.dot.reconnecting,
.dot.connecting {
  background: var(--warn);
  box-shadow: 0 0 0 3px var(--warn-halo);
}
.dot.error {
  background: var(--danger);
  box-shadow: 0 0 0 3px var(--danger-halo);
}
.dot.disconnected,
.dot.idle {
  background: transparent;
  box-shadow: inset 0 0 0 1.5px var(--text-3);
}

.rail-footer {
  border-top: 1px solid var(--line);
  padding: 8px;
  display: grid;
  gap: 2px;
  flex: none;
}
.ghost-row {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 7px 9px;
  border-radius: var(--r-md);
  color: var(--text-2);
  font-size: var(--fs-md);
}
.ghost-row svg {
  color: var(--text-3);
}
.ghost-row .kbd {
  margin-left: auto;
}

/* ------------------------------------------------------------------- buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 30px;
  padding: 0 11px;
  border-radius: var(--r-md);
  border: 1px solid var(--line-2);
  background: var(--panel-2);
  color: var(--text);
  font-size: var(--fs-md);
  font-weight: 550;
  white-space: nowrap;
}
.btn.sm {
  height: 26px;
  padding: 0 9px;
  font-size: var(--fs-sm);
  border-radius: var(--r-sm);
}
.btn.primary {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: transparent;
  font-weight: 620;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.16) inset;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: var(--r-sm);
  color: var(--text-3);
  flex: none;
}

.split-divider {
  width: 1px;
  height: 16px;
  background: var(--line-2);
  flex: none;
}

/* ------------------------------------------------------------------- main */

.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--bg);
}

.tabbar {
  height: 40px;
  display: flex;
  align-items: stretch;
  gap: 2px;
  padding: 0 8px;
  border-bottom: 1px solid var(--line-2);
  background: var(--panel);
  overflow-x: auto;
  scrollbar-width: none;
  flex: none;
}
.tabbar::-webkit-scrollbar {
  display: none;
}
.tab {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 6px 0 11px;
  min-width: 0;
  max-width: 220px;
  border-bottom: 1.5px solid transparent;
  color: var(--text-3);
  font-size: var(--fs-md);
  font-weight: 500;
}
.tab.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}
.tab-name {
  max-width: 150px;
}
.tab-close {
  flex: none;
  width: 24px;
  height: 24px;
  margin-right: -6px;
  border-radius: var(--r-sm);
  display: grid;
  place-items: center;
  color: var(--text-4);
}
.tab.active .tab-close {
  color: var(--text-2);
}
.tab-add {
  align-self: center;
  margin-left: 4px;
}

.workspace {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.ws-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px 9px 14px;
  border-bottom: 1px solid var(--line-2);
  background: var(--panel);
  flex: none;
  min-height: 48px;
}
.ws-title {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 0 0 auto;
  max-width: 42%;
}
.ws-name {
  font-size: var(--fs-lg);
  font-weight: 600;
  letter-spacing: -0.01em;
  min-width: 0;
}
.ws-meta {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--text-3);
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  min-width: 0;
  flex: 1 1 0;
  overflow: hidden;
}
.ws-actions {
  margin-left: auto;
  flex: none;
  display: flex;
  align-items: center;
  gap: 6px;
}

.ws-state {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-2);
  padding: 2px 9px;
  border: 1px solid var(--line-2);
  border-radius: 99px;
  background: var(--panel-2);
  white-space: nowrap;
  flex: none;
}
.ws-state.connected {
  color: var(--ok-ink);
  background: var(--ok);
  border-color: transparent;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 20px;
  padding: 0 7px;
  border-radius: 5px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text-2);
  font-size: 11px;
  font-weight: 550;
  white-space: nowrap;
  text-decoration: none;
}
.chip.mono {
  font-size: 11px;
}
.chip-accent {
  color: var(--accent-text);
  border-color: var(--accent-line);
  background: var(--accent-soft);
}

.ws-body {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: var(--tree-w) minmax(0, 1fr);
  position: relative;
}
.ws-body.with-inspector {
  grid-template-columns: var(--tree-w) minmax(0, 1fr) var(--insp-w);
}

/* ------------------------------------------------------------------- tree */

.tree {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  border-right: 1px solid var(--line-2);
  background: var(--panel);
}
.tree-head {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 8px 0 11px;
  border-bottom: 1px solid var(--line);
  flex: none;
}
.tree-head .label {
  margin-right: auto;
}
.topic-count {
  height: 17px;
  padding: 0 5px;
}
.tree-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 6px 6px 16px;
}
.tree-section {
  padding: 8px 4px 4px;
}

.topic {
  position: relative;
  display: flex;
  align-items: center;
  gap: 4px;
  width: 100%;
  height: 24px;
  padding-right: 6px;
  border-radius: 5px;
  color: var(--text-2);
  font-size: var(--fs-md);
  text-align: left;
  cursor: pointer;
}
.topic.d0 {
  padding-left: 4px;
}
.topic.d1 {
  padding-left: 15px;
}
.topic.d2 {
  padding-left: 26px;
}
.topic.d3 {
  padding-left: 37px;
}
.topic.pinned {
  padding-left: 5px;
}
.topic:hover {
  background: var(--panel-2);
  color: var(--text);
}
.topic.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 550;
}
.topic .twist {
  width: 14px;
  height: 14px;
  display: grid;
  place-items: center;
  color: var(--text-4);
  flex: none;
}
.topic .twist .ico {
  transition: transform 120ms var(--ease);
}
.topic .twist .ico.open {
  transform: rotate(90deg);
}
.topic .seg-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1 1 auto;
  min-width: 0;
}
.topic .seg-count {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-3);
  padding-left: 6px;
  white-space: nowrap;
  flex: none;
}
.topic.active .seg-count {
  color: var(--accent-text);
}
.topic .seg-rate {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-3);
  flex: none;
  padding-left: 4px;
  font-variant-numeric: tabular-nums;
}
.topic .retain-pin {
  color: var(--warn);
}
.topic .sub-badge {
  flex: none;
  height: 15px;
  padding: 0 4px;
  font-size: 9px;
  letter-spacing: 0.02em;
  color: var(--text-3);
  background: var(--panel-2);
}

/* ------------------------------------------------------------------- stream */

.stream-col {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--bg);
  /* the row layout depends on the stream's width, not the viewport's */
  container-type: inline-size;
  container-name: stream;
}

.stream-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--line);
  flex: none;
  min-height: 40px;
}
.seg {
  display: inline-flex;
  padding: 2px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  gap: 1px;
  flex: none;
}
.seg > * {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 8px;
  border-radius: 4px;
  color: var(--text-3);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.seg > .on {
  background: var(--panel-3);
  color: var(--text);
}

.filter-input {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  max-width: 230px;
  height: 26px;
  padding: 0 8px;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  background: var(--panel);
  color: var(--text-4);
}
.filter-input.wide {
  max-width: 300px;
  flex: 1.2;
}
.filter-value {
  font-size: var(--fs-md);
  color: var(--text-4);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.stream-filters {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}

.stream {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
}

.msg-head {
  display: grid;
  grid-template-columns: var(--msg-cols);
  gap: 10px;
  padding: 0 12px 0 10px;
  height: 26px;
  align-items: center;
  border-bottom: 1px solid var(--line-2);
  color: var(--text-3);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  flex: none;
}
.msg-head .right {
  text-align: right;
}

.stream-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  position: relative;
}

.msg {
  position: relative;
  display: grid;
  grid-template-columns: var(--msg-cols);
  align-items: center;
  gap: 10px;
  height: 29px;
  padding: 0 8px 0 10px;
  border-bottom: 1px solid var(--msg-border);
  cursor: pointer;
  font-size: var(--fs-md);
  transition: background var(--dur) var(--ease);
}
.msg:hover {
  background: var(--panel);
}
.msg.selected {
  background: var(--panel-3);
  box-shadow: inset 2px 0 0 var(--accent);
}
.msg.selected .msg-topic {
  color: var(--text);
}
.msg.in {
  background-image: linear-gradient(90deg, var(--row-in), transparent 22%);
}
.msg.out {
  background-image: linear-gradient(90deg, var(--row-out), transparent 22%);
}
.msg.selected.in,
.msg.selected.out {
  background-image: none;
}
.msg-time {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-4);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
}
.msg-dir {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
}
.msg-dir.in {
  color: var(--data-in);
}
.msg-dir.out {
  color: var(--data-out);
}
.msg-topic {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.msg-payload {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.msg-payload .j {
  color: var(--accent-2);
  opacity: 0.85;
}
.msg-flags {
  display: flex;
  align-items: center;
  gap: 3px;
  justify-content: flex-end;
  overflow: hidden;
}
.flag {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  padding: 0 4px;
  height: 16px;
  line-height: 16px;
  border-radius: var(--r-sm);
  background: var(--panel-3);
  color: var(--text-3);
  flex: none;
}
.flag.q1 {
  color: var(--q1);
  background: rgba(141, 152, 167, 0.16);
}
.flag.q2 {
  color: var(--q2);
  background: rgba(177, 140, 255, 0.14);
}
.flag.r {
  color: var(--retain);
  background: rgba(245, 181, 68, 0.14);
}
.flag.dup {
  color: var(--dup);
  background: rgba(255, 107, 107, 0.12);
}

/* The row follows its container, exactly as the app's does: the actions go
   first, then the payload, so the topic never collapses to nothing. */
@container stream (max-width: 820px) {
  /* the filter bar wraps instead of crushing its inputs to "# S" */
  .stream-bar {
    flex-wrap: wrap;
    height: auto;
    row-gap: 6px;
  }
  .stream-bar .filter-input {
    min-width: 150px;
  }
  .stream-filters {
    flex-wrap: wrap;
  }
}
/* Below the width where the bar really wraps, one fewer row keeps the stream
   from ending on a half row. */
@container stream (max-width: 600px) {
  .msg:nth-child(n + 17) {
    display: none;
  }
}
@container stream (max-width: 700px) {
  .msg-head,
  .msg {
    /* the app's compact grid, with the topic a little wider and the payload
       a little narrower: a page has to name the topic it is showing */
    --msg-cols: 84px 42px minmax(90px, 1.15fr) minmax(0, 1.35fr) 58px;
    gap: 8px;
  }
}
@container stream (max-width: 540px) {
  .msg-head,
  .msg {
    --msg-cols: 84px 42px minmax(0, 1fr) 66px;
    gap: 8px;
  }
  .msg-payload,
  .msg-head > :nth-child(4) {
    display: none;
  }
}
@container stream (max-width: 430px) {
  .msg-head,
  .msg {
    --msg-cols: 74px 38px minmax(0, 1fr) 60px;
    gap: 6px;
  }
}

/* ------------------------------------------------------------------- composer */

.composer {
  position: relative;
  flex: none;
  border-top: 1px solid var(--line-2);
  background: var(--panel);
  padding: 24px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.composer-grip {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 24px;
  display: grid;
  place-items: center;
}
.composer-grip span {
  width: 46px;
  height: 4px;
  border-radius: 99px;
  background: var(--line-3);
}
.composer-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.composer-topic {
  position: relative;
  flex: 1;
  min-width: 0;
}
.composer-topic input,
.composer-payload {
  width: 100%;
  padding: 0 9px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: var(--panel-2);
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  color: var(--text);
  cursor: default;
}
.composer-topic input {
  height: 34px;
}
.composer-payload-wrap {
  min-width: 0;
  position: relative;
}
textarea.composer-payload {
  height: 72px;
  min-height: 72px;
  resize: none;
  line-height: 1.55;
  overflow-y: auto;
  padding: 7px 9px;
  display: block;
}
.composer-send {
  flex: none;
  height: 34px;
  padding: 0 16px;
}
.composer-meta-row .seg > * {
  padding: 0 9px;
}
.repeat-group {
  display: flex;
  align-items: center;
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  overflow: hidden;
  flex: none;
}
.repeat-group .btn.sm {
  border: 0;
  border-radius: 0;
  height: 24px;
}
.repeat-interval {
  height: 24px;
  padding: 0 7px;
  border-left: 1px solid var(--line-2);
  color: var(--text-3);
  font-size: 11px;
  display: inline-flex;
  align-items: center;
}
.composer-hint {
  font-size: 11px;
  color: var(--text-3);
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  white-space: nowrap;
  margin-left: auto;
}
.ws-body.with-inspector .composer-hint {
  display: none;
}

/* ------------------------------------------------------------------- inspector */

.inspector {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  border-left: 1px solid var(--line);
  background: var(--panel);
}
.insp-head {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 8px 0 12px;
  border-bottom: 1px solid var(--line);
  flex: none;
}
.spacer {
  margin-left: auto;
}
.insp-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 12px;
}
.insp-panel {
  display: none;
}
.insp-panel.is-active {
  display: block;
}
.insp-topic {
  font-family: var(--font-mono);
  font-size: var(--fs-md);
  line-height: 1.5;
  word-break: break-all;
  color: var(--text);
  margin-bottom: 10px;
}
.kv {
  display: grid;
  grid-template-columns: 78px 1fr;
  gap: 4px 10px;
  font-size: var(--fs-sm);
  margin-bottom: 14px;
}
.kv dt {
  color: var(--text-3);
  font-size: 11px;
  letter-spacing: 0.03em;
}
.kv dd {
  font-family: var(--font-mono);
  color: var(--text-2);
  overflow-wrap: anywhere;
}
.kv dd.in {
  color: var(--ok);
}
.kv dd.out {
  color: var(--info);
}
.insp-views {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.mini-tabs {
  display: flex;
  gap: 2px;
  padding: 2px;
  background: var(--panel-2);
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
}
.mini-tabs > * {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  letter-spacing: 0.02em;
}
.mini-tabs > .on {
  background: var(--panel-3);
  color: var(--text);
}
.insp-diff-count {
  margin-left: 5px;
  font-size: 9px;
  font-style: normal;
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
  color: var(--text-3);
}
.code {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--bg-sunken);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 9px 10px;
  color: var(--text);
}
.code.scroll {
  max-height: 46vh;
  overflow: auto;
  white-space: normal;
}
.json-tree {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.jt-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding-left: 20px;
  min-height: 18px;
  line-height: 1.5;
  border-radius: 3px;
}
.jt-root {
  padding-left: 0;
}
.jt-summary {
  color: var(--text-3);
  font-size: 11px;
}
.jt-key {
  flex: none;
  color: var(--accent-2);
  white-space: nowrap;
}
.jt-key::after {
  content: ":";
  color: var(--text-3);
  margin-left: 1px;
}
.jt-key.is-string {
  color: var(--accent-2);
}
.jt-val {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.jt-val.is-string {
  /* --accent-text, not --accent: the accent is a fill colour and drops under
     4.5:1 on the sunken panel in the light theme */
  color: var(--accent-text);
}
.jt-val.is-number {
  color: var(--info);
}
.jt-val.is-boolean {
  color: var(--violet);
}

/* ------------------------------------------------------------------- status bar */

/* Page furniture attached to the window, not app chrome. Tinted so nobody
   mistakes it for part of the product. */
.window-cta {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 40px;
  padding: 6px 12px;
  border-top: 1px solid var(--accent-line);
  background: var(--accent-soft);
  font-size: 12px;
  color: var(--text-2);
  flex: none;
  flex-wrap: wrap;
}
.window-cta-text {
  min-width: 0;
}
.window-cta-text strong {
  color: var(--text);
  font-weight: 600;
}
.window-cta-btn {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 4px 12px;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  flex: none;
}
.window-cta-btn:hover {
  filter: brightness(1.06);
}

/* ================================================================ the page */

.hero {
  padding: 72px var(--page-pad) 0;
}
.hero .label {
  margin-bottom: 14px;
}
.hero h1 {
  font-size: var(--fs-44);
  line-height: 1.06;
  font-weight: 620;
  letter-spacing: -0.028em;
  max-width: 20ch;
  text-wrap: balance;
}
.lead {
  margin-top: 20px;
  max-width: 68ch;
  font-size: var(--fs-lg);
  line-height: 1.65;
  color: var(--text-2);
}
.lead .mono {
  font-size: 13px;
  color: var(--text);
}
.lead-sub {
  margin-top: 14px;
  max-width: 68ch;
  font-size: var(--fs-md);
  line-height: 1.7;
  color: var(--text-3);
}

.facts {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  margin-top: 40px;
  border-top: 1px solid var(--page-line);
  border-bottom: 1px solid var(--page-line);
  background: var(--page-line);
}
.fact {
  background: var(--bg);
  padding: 18px 18px 20px 0;
}
.fact-value {
  font-size: var(--fs-32);
  font-weight: 620;
  letter-spacing: -0.02em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.fact-value .unit {
  font-size: var(--fs-md);
  font-weight: 550;
  color: var(--text-3);
  margin-left: 3px;
  letter-spacing: 0;
}
.fact-label {
  margin-top: 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-3);
}

.section {
  padding-top: 64px;
}
.section-head {
  display: grid;
  grid-template-columns: 140px minmax(0, 62ch) minmax(180px, 1fr);
  gap: var(--gutter);
  border-top: 1px solid var(--page-line);
  padding-top: 22px;
}
/* The readout strip: the app's own vocabulary, in the app's own mono. */
.spec {
  display: grid;
  grid-template-columns: 1fr auto;
  align-content: start;
  gap: 7px 14px;
  max-width: 300px;
  justify-self: end;
  align-self: start;
  padding-top: 2px;
}
.spec dt {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
}
.spec dd {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-2);
  text-align: right;
  white-space: nowrap;
}
.section-head h2 {
  font-size: var(--fs-32);
  line-height: 1.15;
  font-weight: 620;
  letter-spacing: -0.02em;
  max-width: 26ch;
  text-wrap: balance;
}
.section-head > div > h2 {
  max-width: 24ch;
}
.intro {
  margin-top: 14px;
  max-width: none;
  font-size: var(--fs-lg);
  line-height: 1.68;
  color: var(--text-2);
}
.intro + .intro {
  margin-top: 12px;
  font-size: var(--fs-md);
  color: var(--text-3);
  line-height: 1.75;
}
.intro .mono {
  font-size: 13px;
  color: var(--text);
}
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 20px;
}
.chips .chip {
  height: 24px;
  padding: 0 9px;
  transition: border-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
a.chip:hover {
  border-color: var(--accent-line);
  color: var(--text);
}

.platforms {
  margin-top: 28px;
  border: 1px solid var(--page-line);
  border-radius: var(--r-md);
  overflow: hidden;
}
.plat-row {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 0 14px;
  height: 52px;
  border-bottom: 1px solid var(--page-line);
}
.plat-row:last-child {
  border-bottom: 0;
}
.plat-name {
  font-size: var(--fs-md);
  font-weight: 600;
}
.plat-note {
  font-size: var(--fs-sm);
  color: var(--text-3);
}
.plat-size {
  font-size: var(--fs-sm);
  color: var(--text-2);
}
/* app.js writes data-os on <html>; the matching platform is the one the
   download button will fetch. */
[data-os="linux"] .plat-row.is-linux,
[data-os="macos"] .plat-row.is-macos,
[data-os="windows"] .plat-row.is-windows {
  background: var(--accent-soft);
  box-shadow: inset 2px 0 0 var(--accent);
}
[data-os="linux"] .plat-row.is-linux .plat-name,
[data-os="macos"] .plat-row.is-macos .plat-name,
[data-os="windows"] .plat-row.is-windows .plat-name {
  color: var(--accent-text);
}

.install-note {
  margin-top: 14px;
  max-width: 68ch;
  font-size: var(--fs-sm);
  line-height: 1.7;
  color: var(--text-3);
}

.keys {
  margin-top: 28px;
  display: grid;
  border: 1px solid var(--page-line);
  border-radius: var(--r-md);
  overflow: hidden;
}
.keys .label {
  padding: 10px 14px;
  border-bottom: 1px solid var(--page-line);
  background: var(--panel);
}
.key-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--page-line);
  font-size: var(--fs-md);
  color: var(--text-2);
}
.key-row:last-child {
  border-bottom: 0;
}
.kbd-group {
  display: flex;
  gap: 4px;
}

/* ------------------------------------------------------------------- the gate */

.gate-section {
  padding-top: 72px;
  padding-bottom: 8px;
}
.gate-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 560px);
  gap: var(--gutter);
  border-top: 1px solid var(--page-line);
  padding-top: 22px;
  align-items: start;
}
.gate-heading {
  font-size: var(--fs-32);
  line-height: 1.15;
  font-weight: 620;
  letter-spacing: -0.02em;
  max-width: 22ch;
  text-wrap: balance;
}
.gate-heading + .intro {
  margin-top: 14px;
}
.gate-spec {
  margin-top: 22px;
  justify-self: start;
  max-width: 260px;
}
.gate {
  width: 100%;
  border: 1px solid var(--line-2);
  border-radius: var(--r-lg);
  background: var(--panel);
  overflow: hidden;
}
.gate-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 20px 16px;
  border-bottom: 1px solid var(--line);
}
.gate-mark {
  width: 38px;
  height: 38px;
  border-radius: var(--r-md);
  display: grid;
  place-items: center;
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.18);
  flex: none;
}
.gate-title {
  font-size: var(--fs-xl);
  font-weight: 620;
  letter-spacing: -0.015em;
  line-height: 1.25;
}
.gate-sub {
  font-size: var(--fs-sm);
  color: var(--text-3);
  margin-top: 1px;
}

.dl-form {
  padding: 18px 20px 20px;
  display: block;
}
.dl-form > label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 7px;
}
.dl-row {
  display: flex;
  gap: 8px;
}
.dl-row input {
  flex: 1 1 auto;
  min-width: 0;
  height: 46px;
  padding: 0 12px;
  border-radius: var(--r-md);
  border: 1px solid var(--line-2);
  background: var(--panel-2);
  color: var(--text);
  font-size: var(--fs-lg);
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease),
    box-shadow var(--dur) var(--ease);
}
.dl-row input:focus {
  outline: none;
  border-color: var(--accent-line);
  background: var(--bg);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.dl-row .btn-primary {
  flex: none;
}
.dl-fineprint {
  margin-top: 12px;
  font-size: 11px;
  line-height: 1.7;
  color: var(--text-3);
  max-width: 56ch;
}
.dl-status {
  margin-top: 10px;
  font-size: var(--fs-sm);
  line-height: 1.6;
  color: var(--warn);
}
.dl-status:empty {
  display: none;
}
.dl-fallback {
  margin-top: 8px;
  font-size: var(--fs-sm);
  color: var(--text-2);
}
.dl-fallback a {
  font-weight: 600;
}
.dl-success {
  margin: 0 20px 20px;
  padding: 14px 16px;
  border: 1px solid var(--accent-line);
  border-radius: var(--r-md);
  background: var(--accent-soft);
  font-size: var(--fs-md);
  line-height: 1.65;
  color: var(--text-2);
}
.dl-success-title {
  font-size: var(--fs-lg);
  font-weight: 620;
  color: var(--text);
  margin-bottom: 4px;
}
.dl-success a {
  font-weight: 600;
}
.gate-foot {
  padding: 10px 20px;
  border-top: 1px solid var(--line);
  background: var(--bg-sunken);
  font-size: 11px;
  color: var(--text-3);
}

/* ------------------------------------------------------------------- plain pages */

.notfound,
.doc {
  padding-top: 72px;
}
.notfound h1,
.doc h1 {
  margin-top: 12px;
  font-size: var(--fs-44);
  line-height: 1.08;
  font-weight: 620;
  letter-spacing: -0.028em;
  max-width: 24ch;
  text-wrap: balance;
}
.notfound .lead,
.doc .lead {
  max-width: 62ch;
}
.doc-list {
  margin-top: 44px;
  display: grid;
  gap: 0;
  border-top: 1px solid var(--page-line);
  max-width: 780px;
}
.doc-list section {
  padding: 22px 0 24px;
  border-bottom: 1px solid var(--page-line);
}
.doc-list h2 {
  font-size: var(--fs-lg);
  font-weight: 620;
  letter-spacing: -0.01em;
}
.doc-list p {
  margin-top: 8px;
  font-size: var(--fs-md);
  line-height: 1.75;
  color: var(--text-2);
  max-width: 66ch;
}
.doc-list .mono {
  color: var(--text);
}
.doc-foot {
  margin: 32px 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* ------------------------------------------------------------------- footer */

.footer {
  margin-top: 72px;
  border-top: 1px solid var(--page-line);
  padding: 28px 0 48px;
}
.footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 20px;
}
.footer-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
}
.footer-nav a {
  font-size: var(--fs-md);
  color: var(--text-2);
  text-decoration: none;
}
.footer-nav a:hover {
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.footer-meta {
  margin-left: auto;
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  font-size: 11px;
  color: var(--text-3);
}

/* ================================================================ responsive */

@media (max-width: 1180px) {
  :root {
    --rail-w: 208px;
    --insp-w: 320px;
  }
  /* the tree is the pane that can go: the stream already names every topic */
  .tree {
    display: none;
  }
  .ws-body,
  .ws-body.with-inspector {
    grid-template-columns: minmax(0, 1fr) var(--insp-w);
  }
  .ws-meta .chip:nth-child(2) {
    display: none;
  }
}

@media (max-width: 1040px) {
  :root {
    --rail-w: 184px;
    --insp-w: 300px;
  }
  .composer-hint {
    display: none;
  }
}

/* Below 900 the window becomes the stream and its composer. The rail, the
   tree and the inspector are chrome; the stream is the product. */
@media (max-width: 900px) {
  :root {
    --rail-w: 0px;
    --tree-w: 0px;
    --insp-w: 0px;
    --page-pad: 16px;
    --fs-44: 32px;
    --fs-32: 24px;
  }

  .app {
    height: auto;
    grid-template-columns: minmax(0, 1fr);
    border-radius: 0;
    border-inline: 0;
    border-bottom: 0;
  }
  .window-section {
    padding: 0;
  }
  .rail,
  .tree,
  .inspector {
    display: none;
  }
  .ws-body,
  .ws-body.with-inspector {
    grid-template-columns: minmax(0, 1fr);
  }

  .ws-head {
    flex-wrap: wrap;
    row-gap: 6px;
    padding: 8px 12px;
  }
  .ws-title {
    max-width: 100%;
  }
  .ws-meta {
    display: none;
  }
  .ws-actions .icon-btn:nth-of-type(n + 3) {
    display: none;
  }
  .ws-actions .split-divider {
    display: none;
  }

  .stream-bar {
    flex-wrap: wrap;
    row-gap: 6px;
  }
  .stream-bar .filter-input {
    display: none;
  }
  .stream-filters {
    margin-left: auto;
  }

  /* nine rows is a stream; eighteen is a wall on a phone */
  .msg:nth-child(n + 10) {
    display: none;
  }

  .composer {
    padding-bottom: 10px;
  }
  .composer-meta-row {
    flex-wrap: wrap;
    row-gap: 6px;
  }
  .composer-hint {
    display: none;
  }

  .topnav {
    display: none;
  }
  .topbar-inner {
    height: 56px;
  }
  .hero {
    padding-top: 40px;
  }
  .hero h1 {
    max-width: 100%;
  }
  .lead,
  .lead-sub {
    font-size: var(--fs-md);
    line-height: 1.7;
  }
  .facts {
    grid-template-columns: repeat(2, 1fr);
    margin-top: 28px;
  }
  .fact {
    padding: 14px 14px 16px 0;
  }
  .section {
    padding-top: 48px;
  }
  .spec dd {
    white-space: normal;
  }
  .section-head {
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
  }
  .spec {
    justify-self: start;
    max-width: none;
    margin-top: 4px;
  }
  .intro {
    font-size: var(--fs-md);
    line-height: 1.7;
  }
  .plat-row {
    grid-template-columns: 92px minmax(0, 1fr);
    row-gap: 2px;
    height: auto;
    padding: 12px 14px;
  }
  .plat-size {
    grid-column: 1 / -1;
    color: var(--text-3);
  }
  .gate-section {
    padding-top: 48px;
  }
  .gate-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .gate-spec {
    order: 2;
  }
  .dl-row {
    flex-direction: column;
  }
  .dl-row .btn-primary {
    width: 100%;
  }
  .footer-meta {
    margin-left: 0;
  }
  .window-caption {
    justify-content: space-between;
    gap: 8px;
  }
  .window-caption-hint {
    display: none;
  }
}

@media (max-width: 480px) {
  .brand-version {
    display: none;
  }
  /* one open tab is enough at this width; the rest stay in the rail */
  .tab + .tab {
    display: none;
  }
  .tab {
    max-width: none;
    flex: 1 1 auto;
  }
  .tab .tab-name {
    max-width: none;
  }
  .ws-actions .btn {
    display: none;
  }
  .topbar .btn-primary {
    margin-left: auto;
  }
  .composer-topic input {
    font-size: 11px;
  }
}

/* ---------- accessibility guards ---------- */

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

/* 44px rows on touch: a 29px target is a desktop target. */
@media (pointer: coarse) {
  .msg,
  .msg-head {
    height: 44px;
  }
  .topic {
    height: 34px;
  }
  .conn {
    padding-block: 10px;
  }
  .window-cta-btn,
  .topnav a {
    min-height: 44px;
  }
  .icon-btn {
    width: 34px;
    height: 34px;
  }
  .seg > * {
    min-height: 30px;
  }
}

/* ================================================================ page layout
   The page is a column of pairs: what you can do on the left, the part of the
   window that does it on the right. Everything below reuses the app's tokens
   and its own component classes, so a fragment is a real slice of the UI. */

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

/* ---- hero ---------------------------------------------------------------- */

.hero {
  padding-top: 56px;
}
.hero h1 {
  max-width: 26ch;
  font-size: clamp(30px, 3.6vw, 46px);
}
.hero .lead {
  max-width: 60ch;
}
.hero .lead em {
  font-style: normal;
  color: var(--text);
  box-shadow: inset 0 -0.09em 0 var(--accent-line);
}

.dl-form--hero {
  margin-top: 26px;
  max-width: 640px;
}
.hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  margin-top: 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-3);
}
.hero-meta span {
  position: relative;
}
.hero-meta span + span::before {
  content: "";
  position: absolute;
  left: -11px;
  top: 50%;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--line-3);
}

/* ---- the demo, at content width ----------------------------------------- */

.window-section {
  /* Slightly wider than the text column so the stream keeps its payload
     column: the app's own container queries drop it under 540px. */
  max-width: calc(var(--page) + 120px);
  margin: 48px auto 0;
  padding: 0 var(--page-pad);
}
.window-section .app {
  --rail-w: 176px;
  --tree-w: 132px;
  --insp-w: 248px;
  height: clamp(540px, 76vh, 720px);
  border: 1px solid var(--line-2);
  border-radius: var(--r-lg);
  box-shadow: 0 30px 70px -50px rgba(0, 0, 0, 0.95);
}
.window-caption {
  padding: 10px 2px 0;
}

/* ---- the pairs ----------------------------------------------------------- */

.duo {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 24px 64px;
  align-items: center;
  padding-top: 96px;
}
.duo--flip .duo-copy {
  order: 2;
}
.duo-copy h2 {
  margin-top: 10px;
  font-size: clamp(21px, 2.3vw, 29px);
  line-height: 1.14;
  font-weight: 620;
  letter-spacing: -0.022em;
  max-width: 22ch;
  text-wrap: balance;
}
.duo-text {
  margin-top: 16px;
  font-size: var(--fs-lg);
  line-height: 1.62;
  color: var(--text-2);
  max-width: 52ch;
}
.duo-list {
  margin: 20px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 9px;
  max-width: 52ch;
}
.duo-list li {
  position: relative;
  padding-left: 18px;
  font-size: var(--fs-md);
  line-height: 1.55;
  color: var(--text-3);
}
.duo-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.62em;
  width: 6px;
  height: 6px;
  border-radius: 1px;
  background: var(--accent-line);
}
.duo-note {
  margin-top: 18px;
  font-size: var(--fs-md);
}
.duo-note a {
  color: var(--accent-text);
  text-decoration: none;
  border-bottom: 1px solid var(--accent-line);
}

/* ---- a fragment of the window ------------------------------------------- */

.frag {
  margin: 0;
  min-width: 0;
  border: 1px solid var(--line-2);
  border-radius: var(--r-lg);
  background: var(--bg);
  overflow: hidden;
  --msg-cols: 84px 46px minmax(0, 1fr) minmax(0, 1.15fr) 54px;
  box-shadow: 0 20px 50px -44px rgba(0, 0, 0, 1);
}
.frag-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 10px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  font-size: var(--fs-sm);
  color: var(--text-3);
  overflow: hidden;
}
.frag-title {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text-2);
  white-space: nowrap;
}
.frag-target {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.frag-tab {
  padding: 4px 8px;
  border-radius: var(--r-sm);
  white-space: nowrap;
}
.frag-tab.on {
  background: var(--panel-3);
  color: var(--text);
}
.frag-search {
  flex: 1 1 0;
  min-width: 0;
  height: 22px;
  padding: 0 8px;
  display: flex;
  align-items: center;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: var(--bg-sunken);
  font-size: 11px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.frag .msg-head,
.frag .msg {
  grid-template-columns: var(--msg-cols);
}
.frag .msg {
  cursor: default;
}
.frag-foot {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 30px;
  padding: 0 10px;
  border-top: 1px solid var(--line);
  background: var(--panel);
  font-size: 11px;
  color: var(--text-3);
}
.frag-foot span:last-child {
  margin-left: auto;
}
.frag .msg:hover {
  background: transparent;
}
.frag .msg.selected {
  background: var(--panel-3);
}

.seg--mini {
  display: inline-flex;
  flex: none;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  overflow: hidden;
  background: var(--bg-sunken);
}
.seg--mini > span {
  padding: 3px 7px;
  font-size: 11px;
  color: var(--text-3);
  white-space: nowrap;
}
.seg--mini > span.on {
  background: var(--panel-3);
  color: var(--text);
}

/* publish */
.frag-composer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 10px;
  border-bottom: 1px solid var(--line);
}
.frag-code {
  margin: 0;
  padding: 14px 12px;
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  line-height: 1.6;
  color: var(--text-2);
  background: var(--bg-sunken);
  overflow-x: auto;
}
.frag-code .p {
  color: var(--text-3);
}
.props-row {
  display: grid;
  gap: 6px;
  padding: 10px 12px;
  border-top: 1px solid var(--line);
}
.prop {
  display: flex;
  gap: 8px;
  font-size: 11px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.prop b {
  font-weight: 600;
  color: var(--text-2);
  min-width: 92px;
}
.frag-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-top: 1px solid var(--line);
}
.frag-actions .chip {
  margin: 0;
}
.btn-mini {
  margin-left: auto;
  height: 28px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  border-radius: var(--r-sm);
  background: var(--accent);
  color: var(--accent-ink);
  font-size: var(--fs-sm);
  font-weight: 620;
}
.chip.on {
  border-color: var(--accent-line);
  background: var(--accent-soft);
  color: var(--accent-text);
}

/* inspector */
.frag-kv {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}
.frag-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
}
.frag-tree {
  padding: 8px 0;
}
.frag .jt-row {
  padding-inline: 12px;
}
.jt-diff {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ok);
}
.jt-diff.down {
  color: var(--warn);
}

/* replay */
.day-list {
  margin: 0;
  padding: 6px 0;
  list-style: none;
}
.day-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  font-size: var(--fs-md);
  color: var(--text-2);
  border-left: 2px solid transparent;
}
.day-list li .mono {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-3);
}
.day-list li.on {
  background: var(--panel);
  border-left-color: var(--accent);
  color: var(--text);
}

/* agents */
.frag-term .term {
  margin: 0;
  padding: 14px 12px;
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  line-height: 1.75;
  color: var(--text-2);
  white-space: pre-wrap;
  word-break: break-word;
}
.term-dim {
  color: var(--text-3);
}
.term-str {
  color: var(--ok);
}
.term-out {
  display: inline-block;
  color: var(--data-in);
}

/* local */
.set-list {
  margin: 0;
  padding: 6px 0;
  list-style: none;
}
.set-list li {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 12px;
  font-size: var(--fs-md);
  color: var(--text-2);
  border-bottom: 1px solid var(--line);
}
.set-list li:last-child {
  border-bottom: 0;
}
.set-val {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.switch {
  margin-left: auto;
  width: 30px;
  height: 16px;
  border-radius: 999px;
  background: var(--panel-3);
  border: 1px solid var(--line-2);
  position: relative;
  flex: none;
}
.switch::after {
  content: "";
  position: absolute;
  top: 1px;
  left: 1px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--text-3);
}

/* ---- install ------------------------------------------------------------- */

.plat {
  margin: 26px 0 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--page-line);
}
.plat-row {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr) 160px auto;
  gap: 16px;
  align-items: center;
  padding: 15px 2px;
  border-bottom: 1px solid var(--page-line);
  font-size: var(--fs-md);
  color: var(--text-2);
}
.plat-name {
  font-weight: 620;
  color: var(--text);
}
.plat-files,
.plat-size {
  font-size: var(--fs-sm);
  color: var(--text-3);
}
.plat-tag {
  justify-self: end;
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
  border: 1px solid var(--line-2);
  border-radius: 999px;
  padding: 3px 9px;
}
html[data-os="linux"] .plat-row[data-os="linux"],
html[data-os="macos"] .plat-row[data-os="macos"],
html[data-os="windows"] .plat-row[data-os="windows"] {
  background: var(--accent-soft);
  box-shadow: inset 2px 0 0 var(--accent);
}
.plat-note {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 24px;
}
.link-quiet {
  font-size: var(--fs-md);
  color: var(--text-3);
  text-decoration: none;
  border-bottom: 1px solid var(--line-2);
  padding-bottom: 2px;
}
.link-quiet:hover {
  color: var(--text);
}

/* ---- responsive ---------------------------------------------------------- */

@media (max-width: 1080px) {
  .duo {
    grid-template-columns: minmax(0, 1fr);
    gap: 28px;
    padding-top: 72px;
  }
  .duo--flip .duo-copy {
    order: 0;
  }
  .duo-copy h2 {
    max-width: 26ch;
  }
  .window-section .app {
    --rail-w: 176px;
    --tree-w: 150px;
    --insp-w: 260px;
  }
}

@media (max-width: 860px) {
  .window-section .app {
    --rail-w: 0px;
    --tree-w: 0px;
    --insp-w: 0px;
    height: auto;
  }
  .window-section .rail,
  .window-section .tree,
  .window-section .insp,
  .window-section .tabs {
    display: none;
  }
  .plat-row {
    grid-template-columns: 1fr auto;
    gap: 6px 16px;
  }
  .plat-files {
    grid-column: 1;
  }
  .plat-size {
    display: none;
  }
  .plat-tag {
    grid-row: 1;
    grid-column: 2;
  }
  .hero {
    padding-top: 36px;
  }
  .duo {
    padding-top: 56px;
  }
}

@media (max-width: 520px) {
  .frag-bar .frag-search {
    display: none;
  }
  .frag-composer .seg--mini:nth-of-type(2) {
    display: none;
  }
  .frag .msg-head,
  .frag .msg {
    --msg-cols: 62px 34px minmax(0, 1fr) 44px;
  }
  .frag .msg-payload {
    display: none;
  }
  .plat-note {
    flex-wrap: wrap;
  }
}

/* Install: heading and intro as a pair, not the old label-column grid. */
.section-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 420px);
  gap: 18px 56px;
  align-items: end;
}
.section-head h2 {
  margin-top: 10px;
  font-size: clamp(21px, 2.3vw, 29px);
  line-height: 1.14;
  font-weight: 620;
  letter-spacing: -0.022em;
  max-width: 20ch;
  text-wrap: balance;
}
.section-head .intro {
  margin: 0;
  font-size: var(--fs-md);
  line-height: 1.65;
  color: var(--text-3);
  max-width: 46ch;
}

@media (max-width: 860px) {
  .section-head {
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
    align-items: start;
  }
}

/* The section menu stays reachable on a phone: the bar wraps and the links
   scroll sideways instead of disappearing. */
@media (max-width: 860px) {
  .topbar-inner {
    flex-wrap: wrap;
    row-gap: 8px;
  }
  .topnav {
    display: flex;
    order: 3;
    width: 100%;
    margin-left: 0;
    gap: 18px;
    overflow-x: auto;
    scrollbar-width: none;
    padding-bottom: 2px;
  }
  .topnav::-webkit-scrollbar {
    display: none;
  }
  .topnav a {
    white-space: nowrap;
    font-size: var(--fs-sm);
  }
}

/* Anchor targets must clear the sticky bar, and the scroll itself should feel
   deliberate rather than instant. */
[id] {
  scroll-margin-top: 88px;
}
@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}
@media (max-width: 860px) {
  [id] {
    scroll-margin-top: 116px;
  }
  .hero {
    padding-top: 44px;
  }
  .topnav {
    padding-bottom: 8px;
  }
}
