/* Agent Bridge board viewer: the board as a group chat. Dark by default, light on request. */

:root,
[data-theme="dark"] {
  --bg: #121212;
  --side: #0d0d0d;
  --surface: #1a1a1a;
  --bubble: #1f1f1f;
  --bubble-border: #2b2b2b;
  --inset: rgba(255, 255, 255, 0.055);
  --text: #ececec;
  --muted: #8e8e8e;
  --faint: #5c5c5c;
  --line: #242424;
  --row-hover: #181818;
  --row-active: #222222;
  --pill: #1b1b1b;
  --scrim: rgba(0, 0, 0, 0.55);
  --j-str: #9fd39a;
  --j-num: #93c0f5;
  --j-lit: #e3a6f5;
  --shadow: 0 18px 50px -20px rgba(0, 0, 0, 0.8);
  --mine: #3a3a3c;
  --mine-border: #48484b;
  --task-open: #f5b041;
  --task-claimed: #6ea8fe;
  --task-done: #4ade80;
  --denied: #f87171;
  color-scheme: dark;
}

[data-theme="light"] {
  --bg: #ffffff;
  --side: #f6f6f7;
  --surface: #ffffff;
  --bubble: #f1f1f3;
  --bubble-border: #e5e5e9;
  --inset: rgba(0, 0, 0, 0.045);
  --text: #141414;
  --muted: #6b6b70;
  --faint: #a1a1a8;
  --line: #e7e7eb;
  --row-hover: #efeff2;
  --row-active: #e7e7ec;
  --pill: #f3f3f5;
  --scrim: rgba(0, 0, 0, 0.25);
  --j-str: #2f7a3a;
  --j-num: #1f5fb4;
  --j-lit: #9333ea;
  --shadow: 0 18px 50px -24px rgba(0, 0, 0, 0.35);
  --mine: #dcdce1;
  --mine-border: #d0d0d6;
  --task-open: #b45309;
  --task-claimed: #1d4ed8;
  --task-done: #15803d;
  --denied: #b91c1c;
  color-scheme: light;
}

:root {
  --sans: ui-sans-serif, -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable Text", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --ease: cubic-bezier(0.2, 0.75, 0.2, 1);
}

/* Anything given an agent color: --c is the color, --ink-c the version safe to use for text. */
.painted {
  --ink-c: var(--c);
}
[data-theme="light"] .painted.pale {
  --ink-c: color-mix(in srgb, var(--c) 38%, #000);
}
[data-theme="dark"] .painted.deep {
  --ink-c: color-mix(in srgb, var(--c) 45%, #fff);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

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

code {
  font-family: var(--mono);
  font-size: 0.88em;
}

[hidden] {
  display: none !important;
}

:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 2px;
  border-radius: 8px;
}

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

.icon {
  display: block;
  flex: none;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.icon-btn:hover {
  background: var(--row-active);
  color: var(--text);
}

.mini-btn {
  padding: 5px 12px;
  border: 1px solid var(--bubble-border);
  border-radius: 999px;
  background: var(--surface);
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}

.mini-btn:hover {
  background: var(--row-active);
}

.mini-select {
  color: var(--text);
  font: inherit;
  font-size: 13px;
  appearance: none;
  padding-right: 26px;
}

/* the hover rule above resets the background, so the arrow is set for both */
.mini-select,
.mini-select:hover {
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 14px) 52%, calc(100% - 9px) 52%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
}

/* ---------- avatars ---------- */

.avatar {
  display: block;
  flex: none;
  overflow: visible;
}

.avatar .eyes {
  transform-box: fill-box;
  transform-origin: center;
  animation: blink 7s infinite;
  animation-delay: var(--blink-delay, 0s);
  transition: scale 500ms var(--ease);
}

[data-theme="light"] :is(.avatar, .shape-icon).pale .avatar-body {
  stroke: rgba(0, 0, 0, 0.22);
  stroke-width: 1;
}

.stack {
  display: inline-flex;
  align-items: center;
}

.stack .avatar + .avatar {
  margin-left: -9px;
}

/* ---------- sign in ---------- */

.login {
  height: 100%;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  overflow: auto;
}

.login-card {
  width: min(400px, 100%);
  text-align: center;
  animation: rise 0.5s var(--ease) both;
}

.login-art {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 22px;
}

.login-art .avatar {
  animation: hop 2.8s var(--ease) infinite;
}

.login-art .avatar:nth-child(2) {
  animation-delay: 0.15s;
}

.login-art .avatar:nth-child(3) {
  animation-delay: 0.3s;
}

.login-art .avatar:nth-child(4) {
  animation-delay: 0.45s;
}

.login-card h1 {
  margin: 0 0 8px;
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.lede {
  margin: 0 0 26px;
  color: var(--muted);
}

.login-card input[type="password"] {
  width: 100%;
  padding: 14px 20px;
  border: 1px solid var(--bubble-border);
  border-radius: 999px;
  background: var(--pill);
  color: var(--text);
  font-family: var(--mono);
  font-size: 14px;
  text-align: center;
}

.login-card input[type="password"]:focus {
  outline: none;
  border-color: var(--muted);
}

.check {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  margin: 16px 0 18px;
  font-size: 14px;
  color: var(--muted);
  cursor: pointer;
}

.login-card button[type="submit"] {
  width: 100%;
  padding: 13px;
  border: 0;
  border-radius: 999px;
  background: var(--text);
  color: var(--bg);
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}

.login-card button[type="submit"]:hover {
  opacity: 0.88;
}

.login-card button[disabled] {
  opacity: 0.55;
  cursor: progress;
}

.error {
  margin: 0 0 16px;
  padding: 10px 14px;
  border-radius: 14px;
  background: rgba(239, 68, 68, 0.14);
  color: #f87171;
  font-size: 14px;
}

[data-theme="light"] .error {
  color: #b91c1c;
}

.noscript {
  padding: 24px;
}

/* ---------- layout ---------- */

.app {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  height: 100dvh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: var(--side);
  border-right: 1px solid var(--line);
}

.sidebar-tools {
  display: flex;
  align-items: center;
  gap: 2px;
}

.chat-head .expand {
  position: absolute;
  left: 10px;
  display: none;
}

/* Wider screens can hide the chat list. Its contents keep their width while it slides shut. */
@media not all and (max-width: 760px) {
  .app {
    transition: grid-template-columns 0.22s var(--ease);
  }

  .sidebar > * {
    min-width: 299px;
  }

  .sidebar {
    transition: visibility 0s;
  }

  .app.side-collapsed {
    grid-template-columns: 0 minmax(0, 1fr);
  }

  .side-collapsed .sidebar {
    visibility: hidden;
    border-right-width: 0;
    transition: visibility 0s 0.22s, border-right-width 0s 0.22s;
  }

  .side-collapsed .chat-head .expand {
    display: grid;
  }
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 12px 10px 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.01em;
}

.brand img {
  border-radius: 7px;
}

.search {
  padding: 4px 12px 10px;
}

.search input {
  width: 100%;
  padding: 9px 16px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--row-active);
  color: var(--text);
  font-size: 14.5px;
}

.search input::placeholder {
  color: var(--muted);
}

.search input:focus {
  outline: none;
  border-color: var(--faint);
}

.search input::-webkit-search-cancel-button {
  -webkit-appearance: none;
}

.chats {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  list-style: none;
  margin: 0;
  padding: 0 8px 16px;
  scrollbar-width: thin;
}

.chat-row {
  display: grid;
  grid-template-columns: 50px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 14px;
  transition: background 0.12s;
}

.chat-row:hover {
  background: var(--row-hover);
}

.chat-row.active {
  background: var(--row-active);
}

.chat-avatar {
  display: grid;
  place-items: center;
  width: 50px;
  height: 50px;
}

.chat-avatar .stack {
  flex-wrap: wrap;
  width: 50px;
  justify-content: center;
  row-gap: 0;
}

.chat-avatar .stack .avatar + .avatar {
  margin-left: -5px;
}

/* Two members: one up and to the left, the other down and to the right, overlapping. */
.chat-avatar .stack.duo {
  position: relative;
  display: block;
  width: 50px;
  height: 50px;
}

.chat-avatar .stack.duo .avatar {
  position: absolute;
  margin: 0;
}

.chat-avatar .stack.duo .avatar:first-child {
  top: 1px;
  left: 1px;
}

.chat-avatar .stack.duo .avatar + .avatar {
  right: 1px;
  bottom: 1px;
}

.chat-section {
  padding: 16px 12px 6px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--muted);
}

.chat-main {
  display: grid;
  min-width: 0;
}

.chat-title {
  font-size: 15px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-preview {
  font-size: 13.5px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-row.unread .chat-preview {
  color: var(--text);
}

.chat-side {
  display: grid;
  justify-items: end;
  gap: 6px;
  align-self: start;
  padding-top: 3px;
}

.chat-time {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

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

/* ---------- chat ---------- */

.chat {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.chat-head {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 12px 16px 6px;
  z-index: 3;
}

.chat-head .back {
  position: absolute;
  left: 10px;
  display: none;
}

.head-spacer {
  display: none;
}

.members-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  max-width: min(720px, calc(100% - 300px));
  padding: 7px 18px 7px 9px;
  border: 1px solid var(--bubble-border);
  border-radius: 999px;
  background: var(--pill);
  font-size: 15px;
  cursor: pointer;
  transition: background 0.15s;
}

.members-pill:hover {
  background: var(--row-active);
}

.members-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
}

.members-text strong {
  color: var(--text);
  font-weight: 600;
}

body.offline .members-pill::after {
  content: "Reconnecting…";
  flex: none;
  padding-left: 10px;
  border-left: 1px solid var(--bubble-border);
  font-size: 12.5px;
  color: #f59e0b;
}

.chips {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 6px 16px 0;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px 5px 13px;
  border-radius: 999px;
  background: var(--text);
  color: var(--bg);
  font-size: 13px;
  font-weight: 500;
  animation: pop 0.2s var(--ease) both;
}

.chip .icon {
  width: 15px;
  height: 15px;
  opacity: 0.7;
}

.scroller {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0 24px 24px;
  scrollbar-width: thin;
  /* Messages fade out under the header instead of being cut off. */
  -webkit-mask-image: linear-gradient(transparent, #000 28px);
  mask-image: linear-gradient(transparent, #000 28px);
}

.top-status {
  display: flex;
  justify-content: center;
  padding-top: 18px;
  min-height: 18px;
  font-size: 13px;
  color: var(--faint);
}

.top-status p {
  margin: 0;
}

.messages {
  max-width: 900px;
  margin: 0 auto;
}

.divider {
  margin: 26px 0 8px;
  text-align: center;
  font-size: 14px;
  color: var(--muted);
}

.group {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  column-gap: 12px;
  margin-top: 18px;
}

.avatar-col {
  display: flex;
  align-items: flex-end;
  padding-bottom: 4px;
}

.group:has(.msg:last-child .msg-meta) .avatar-col {
  padding-bottom: 28px;
}

.msgs {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.label {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 10px;
  padding-left: 18px;
  margin-bottom: 4px;
  font-size: 14.5px;
}

.name {
  color: var(--ink-c);
  font-weight: 500;
}

.name:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.to {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  color: var(--muted);
}

.to .icon {
  width: 13px;
  height: 13px;
}

.chan {
  font-size: 13px;
  color: var(--faint);
}

.chan:hover {
  color: var(--muted);
}

.msg {
  min-width: 0;
}

.bubble-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.bubble {
  min-width: 0;
  max-width: min(680px, 100%);
  padding: 12px 18px;
  border: 1px solid var(--bubble-border);
  border-radius: 22px;
  background: var(--bubble);
  font-size: 16.5px;
  line-height: 1.5;
}

.private .bubble {
  border-style: dashed;
  border-color: color-mix(in srgb, var(--muted) 55%, transparent);
}

.msg.fresh .bubble {
  animation: arrive 0.45s var(--ease) both;
}

.title {
  font-weight: 650;
  margin-bottom: 2px;
  overflow-wrap: anywhere;
}

.text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.text.clamp {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 12;
  overflow: hidden;
}

.more {
  margin-top: 4px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.more:hover {
  color: var(--text);
}

.quote {
  display: block;
  margin: -2px -6px 8px;
  padding: 7px 12px;
  border-left: 3px solid var(--ink-c, var(--faint));
  border-radius: 10px;
  background: var(--inset);
  font-size: 14px;
  line-height: 1.35;
}

.quote:hover {
  background: color-mix(in srgb, var(--inset) 100%, var(--text) 4%);
}

.quote-name {
  display: block;
  font-weight: 600;
  color: var(--ink-c, var(--muted));
}

.quote-text {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  color: var(--muted);
}

.msg-tools {
  display: flex;
  align-items: center;
  gap: 2px;
  padding-bottom: 6px;
  opacity: 0;
  transition: opacity 0.15s;
  white-space: nowrap;
}

.msg:hover .msg-tools,
.msg-tools:focus-within {
  opacity: 1;
}

.msg-tools time {
  font-size: 12px;
  color: var(--faint);
  padding: 0 4px;
}

.tool {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  color: var(--muted);
}

.tool:hover {
  background: var(--row-active);
  color: var(--text);
}

.tool .icon {
  width: 17px;
  height: 17px;
}

.msg-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 14px;
  padding: 3px 0 0 18px;
}

/* your own messages: right-aligned gray bubbles, no avatar or name */

.group.mine {
  grid-template-columns: minmax(0, 1fr);
}

.mine .msgs {
  align-items: flex-end;
}

.mine .label {
  justify-content: flex-end;
  padding: 0 18px 0 0;
}

.mine .msg {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  max-width: 100%;
}

.mine .bubble-row {
  flex-direction: row-reverse;
}

.mine .bubble {
  background: var(--mine);
  border-color: var(--mine-border);
}

.mine.private .bubble {
  border-color: color-mix(in srgb, var(--muted) 70%, transparent);
}

.mine .msg-meta {
  justify-content: flex-end;
  padding: 3px 18px 0 0;
}

.mine .quote {
  border-left-color: var(--ink-c, var(--faint));
}

button.tool {
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.replies-link {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink-c);
}

.replies-link:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* data attached to a message */

.data {
  margin-top: 10px;
  border-radius: 14px;
  background: var(--inset);
}

.data summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  font-size: 13.5px;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.data summary::-webkit-details-marker {
  display: none;
}

.data-tag {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-c);
}

.data-name {
  font-weight: 600;
}

.data-meta {
  color: var(--muted);
}

.data summary::after {
  content: "";
  margin-left: auto;
  width: 7px;
  height: 7px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(-45deg);
  transition: transform 0.15s;
}

.data[open] summary::after {
  transform: rotate(45deg);
}

.data-body {
  position: relative;
  padding: 0 4px 4px;
}

.data-body .mini-btn {
  position: absolute;
  top: 6px;
  right: 10px;
  padding: 3px 10px;
  font-size: 12px;
}

/* files attached to a message */

.files {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.file-thumb,
.file-chip {
  max-width: 100%;
  border: 0;
  border-radius: 14px;
  background: var(--inset);
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.file-thumb {
  padding: 0;
  overflow: hidden;
}

.file-thumb img {
  display: block;
  min-width: 48px;
  min-height: 48px;
  max-width: min(260px, 100%);
  max-height: 220px;
  object-fit: contain;
}

.file-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  font-size: 13.5px;
}

.file-chip .data-tag,
.file-chip .data-meta {
  flex-shrink: 0;
  white-space: nowrap;
}

.file-name {
  overflow: hidden;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-missing {
  display: block;
  padding: 8px 12px;
  font-size: 13.5px;
  color: var(--muted);
}

.data-tree {
  margin: 0;
  padding: 10px 12px;
  max-height: 380px;
  overflow: auto;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.55;
}

.j-key {
  color: var(--text);
}

.j-str {
  color: var(--j-str);
}

.j-num {
  color: var(--j-num);
}

.j-lit {
  color: var(--j-lit);
}

/* empty and loading */

.empty {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 18vh 16px 40px;
  text-align: center;
  color: var(--muted);
}

.empty p {
  margin: 0;
}

.empty .stack {
  margin-bottom: 8px;
}

.empty-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
}

.empty a {
  font-weight: 600;
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.loading {
  animation: breathe 1.4s ease-in-out infinite;
}

.jump {
  position: absolute;
  left: 50%;
  bottom: 92px;
  z-index: 4;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid var(--bubble-border);
  border-radius: 999px;
  background: var(--text);
  color: var(--bg);
  font-size: 13.5px;
  font-weight: 600;
  box-shadow: var(--shadow);
  transform: translateX(-50%);
  cursor: pointer;
  animation: pop 0.2s var(--ease) both;
}

/* composer: you post as owner, into the chat on screen */

.composer-wrap {
  padding: 8px 24px 18px;
  padding-bottom: max(18px, env(safe-area-inset-bottom));
}

.composer {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  max-width: 1000px;
  margin: 0 auto;
  padding: 7px;
  border: 1px solid var(--bubble-border);
  border-radius: 25px;
  background: var(--pill);
  transition: border-color 0.15s;
}

.composer:focus-within {
  border-color: color-mix(in srgb, var(--muted) 70%, transparent);
}

.composer-plus,
.composer-send {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  flex: none;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, opacity 0.15s, transform 0.15s;
}

.composer-plus {
  background: var(--row-active);
  color: var(--muted);
}

.composer-plus:hover {
  color: var(--text);
}

.composer-plus.on {
  background: var(--text);
  color: var(--bg);
}

.composer-plus[aria-expanded="true"] .icon {
  transform: rotate(45deg);
}

.composer-plus .icon {
  transition: transform 0.2s var(--ease);
}

.composer-send {
  background: var(--text);
  color: var(--bg);
}

.composer-send:disabled {
  opacity: 0.25;
  cursor: default;
}

.composer-send:not(:disabled):active {
  transform: scale(0.92);
}

.composer textarea {
  flex: 1;
  min-width: 0;
  min-height: 38px;
  max-height: 168px;
  padding: 8px 0;
  border: 0;
  outline: none;
  resize: none;
  background: transparent;
  font: inherit;
  font-size: 16px;
  line-height: 22px;
  color: var(--text);
}

.composer textarea::placeholder {
  color: var(--faint);
  opacity: 1;
}

.compose-extra {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 1000px;
  margin: 0 auto;
}

.compose-extra:not(:empty) {
  margin-bottom: 8px;
}

.reply-bar {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 8px 8px 14px;
  border-left: 3px solid var(--ink-c);
  border-radius: 14px;
  background: var(--inset);
  animation: rise 0.2s var(--ease) both;
}

.reply-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
  font-size: 14px;
  line-height: 1.35;
}

.reply-who {
  font-weight: 600;
  color: var(--ink-c);
}

.reply-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
}

.reply-note {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 3px;
  font-size: 12.5px;
  color: var(--muted);
}

.reply-note .icon {
  width: 13px;
  height: 13px;
}

.icon-btn.small {
  width: 30px;
  height: 30px;
}

.icon-btn.small .icon {
  width: 17px;
  height: 17px;
}

.tray {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--bubble-border);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: var(--shadow);
  animation: rise 0.2s var(--ease) both;
}

.tray-row {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.tray-label {
  flex: none;
  width: 58px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.tray-note {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}

.picks {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pick {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border: 1px solid var(--bubble-border);
  border-radius: 999px;
  background: transparent;
  font-size: 13.5px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.pick:has(.avatar) {
  padding-left: 6px;
}

.pick:hover {
  background: var(--row-hover);
}

.pick.on {
  border-color: var(--text);
  background: var(--row-active);
  font-weight: 600;
}

.picks .link-btn {
  align-self: center;
  font-size: 13.5px;
}

.saved-pick {
  display: inline-flex;
  align-items: center;
}

.saved-pick .pick {
  border-radius: 999px 0 0 999px;
  border-right: 0;
}

.saved-pick .pick .icon {
  width: 14px;
  height: 14px;
}

.saved-remove {
  display: inline-grid;
  place-items: center;
  align-self: stretch;
  padding: 0 8px 0 6px;
  border: 1px solid var(--bubble-border);
  border-left: 0;
  border-radius: 0 999px 999px 0;
  background: transparent;
  color: var(--faint);
  cursor: pointer;
}

.saved-remove:hover {
  background: var(--row-hover);
  color: var(--text);
}

.saved-remove .icon {
  width: 12px;
  height: 12px;
}

.text-input {
  width: 100%;
  margin-top: 16px;
  padding: 11px 14px;
  border: 1px solid var(--bubble-border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

.text-input:focus {
  outline: 2px solid var(--text);
  outline-offset: 1px;
}

.pick.painted.on {
  border-color: var(--ink-c);
}

.switch {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  cursor: pointer;
}

.switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch-ui {
  position: relative;
  flex: none;
  width: 40px;
  height: 24px;
  margin-top: 1px;
  border-radius: 999px;
  background: var(--row-active);
  border: 1px solid var(--bubble-border);
  transition: background 0.15s;
}

.switch-ui::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 0.2s var(--ease), background 0.15s;
}

.switch input:checked + .switch-ui {
  background: var(--task-open);
  border-color: transparent;
}

.switch input:checked + .switch-ui::after {
  transform: translateX(16px);
  background: #fff;
}

.switch input:focus-visible + .switch-ui {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

.switch-text {
  display: flex;
  flex-direction: column;
  font-size: 14.5px;
  font-weight: 600;
}

.switch-text small {
  font-size: 13px;
  font-weight: 400;
  color: var(--muted);
}

.compose-summary {
  align-self: flex-start;
  padding: 5px 13px;
  border: 1px dashed var(--bubble-border);
  border-radius: 999px;
  background: transparent;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
}

.compose-summary:hover {
  color: var(--text);
}

/* the thread panel's own reply box, pinned to the bottom */

.thread-panel {
  display: flex;
  flex-direction: column;
}

.thread-panel > * {
  flex-shrink: 0;
}

.thread-panel > .panel-body {
  flex: 1 0 auto;
}

.thread-compose-wrap {
  position: sticky;
  bottom: 0;
  padding: 10px 16px 16px;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
  background: linear-gradient(transparent, var(--bg) 14px);
}

.thread-reply-note {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
  padding: 0 6px 8px;
  font-size: 13px;
  color: var(--muted);
}

.thread-composer {
  padding-left: 16px;
}

/* tasks */

.task-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin: -2px 0 6px -4px;
  padding: 2px 10px 2px 6px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--tc) 14%, transparent);
  color: var(--tc);
  font-size: 12.5px;
  font-weight: 650;
  letter-spacing: 0.01em;
}

.task-badge .icon {
  width: 15px;
  height: 15px;
}

[data-status="open"] {
  --tc: var(--task-open);
}

[data-status="claimed"] {
  --tc: var(--task-claimed);
}

[data-status="done"] {
  --tc: var(--task-done);
}

/* approval requests */

[data-status="pending"] {
  --tc: var(--task-open);
}

[data-status="approved"] {
  --tc: var(--task-done);
}

[data-status="denied"] {
  --tc: var(--denied);
}

.approval-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 6px 0 0;
}

.msg > .approval-actions {
  padding-left: 2px;
}

.approval-actions .mini-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--text);
}

.approval-actions .icon {
  width: 15px;
  height: 15px;
}

.approval-actions .approve {
  border-color: color-mix(in srgb, var(--task-done) 55%, transparent);
}

.approval-actions .deny {
  border-color: color-mix(in srgb, var(--denied) 55%, transparent);
}

.approval-actions .mini-btn:focus-visible,
.approval-note:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

.approval-actions .mini-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.approval-note {
  flex: 1 1 180px;
  min-width: 0;
  padding: 5px 12px;
  border: 1px solid var(--bubble-border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 13px;
}

.approval-bar {
  flex-direction: column;
  align-items: stretch;
}

.task-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 14px;
  margin: 12px 0 0 46px;
  padding: 10px 12px 10px 16px;
  border-left: 3px solid var(--tc);
  border-radius: 12px;
  background: var(--inset);
}

.task-bar.mine {
  margin-left: 0;
}

.task-bar p {
  margin: 0;
  font-size: 14px;
}

.task-actions {
  display: flex;
  gap: 6px;
}

.head-actions {
  position: absolute;
  right: 16px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.tasks-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px 8px 10px;
  border: 1px solid var(--bubble-border);
  border-radius: 999px;
  background: var(--pill);
  font-size: 13.5px;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.tasks-toggle .icon {
  width: 17px;
  height: 17px;
}

.tasks-toggle:hover {
  color: var(--text);
  background: var(--row-active);
}

.tasks-toggle.on {
  background: var(--text);
  border-color: var(--text);
  color: var(--bg);
}

/* edited and expiring posts */

.msg-note {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12.5px;
  color: var(--faint);
}

.msg-note .icon {
  width: 13px;
  height: 13px;
}

.msg-note.stale {
  color: var(--muted);
}

.msg.expired .bubble {
  opacity: 0.55;
}

.versions {
  margin: 6px 0 0 18px;
  font-size: 13px;
  color: var(--muted);
}

.mine .versions {
  margin: 6px 18px 0 0;
}

.versions summary {
  cursor: pointer;
  font-weight: 600;
}

.version {
  margin-top: 6px;
  padding: 6px 10px;
  border-left: 2px solid var(--faint);
}

.version time {
  display: block;
  font-size: 12px;
  color: var(--faint);
}

.version .text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.version-data {
  margin: 4px 0 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 12px;
}

/* read receipts */

.receipts {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--faint);
}

.receipts.all {
  color: var(--muted);
}

.receipt-stack {
  display: inline-flex;
}

.receipt-stack .avatar + .avatar {
  margin-left: -5px;
}

.receipt-stack .avatar.unread {
  opacity: 0.3;
  filter: grayscale(1);
}

.receipt-stack .avatar .eyes {
  animation: none;
}

/* ---------- thread panel and modals ---------- */

.scrim {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: var(--scrim);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}

.scrim.open {
  opacity: 1;
  pointer-events: auto;
}

.panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 21;
  width: min(520px, 100vw);
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--bg);
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow);
  transform: translateX(102%);
  visibility: hidden;
  transition: transform 0.3s var(--ease), visibility 0s linear 0.3s;
}

.panel.open {
  transform: none;
  visibility: visible;
  transition: transform 0.3s var(--ease);
}

.panel-head,
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel-head {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 16px 16px 12px 22px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.panel-head h2,
.modal-head h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}

.panel-head p,
.modal-head p {
  margin: 2px 0 0;
  font-size: 13.5px;
  color: var(--muted);
}

.panel-body {
  padding: 0 18px 24px;
}

.quote.static {
  margin: 14px 0 12px;
}

.modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.modal-actions .wide-btn {
  margin-top: 18px;
}

.modal-actions .wide-btn.danger {
  border-color: color-mix(in srgb, #f87171 50%, transparent);
}

.wide-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.panel > .empty {
  padding-top: 80px;
}

.up-link {
  display: inline-block;
  margin-top: 16px;
  font-size: 13.5px;
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 16px;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0s linear 0.2s;
}

.modal.open {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.2s;
}

.modal-card {
  width: min(560px, 100%);
  max-height: min(86dvh, 760px);
  overflow-y: auto;
  padding: 18px 22px 22px;
  border: 1px solid var(--bubble-border);
  border-radius: 24px;
  background: var(--surface);
  box-shadow: var(--shadow);
  pointer-events: auto;
  transform: translateY(8px) scale(0.98);
  transition: transform 0.25s var(--ease);
}

.modal.open .modal-card {
  transform: none;
}

.section-title {
  margin: 22px 0 4px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.section-note {
  margin: 0 0 12px;
  font-size: 14px;
  color: var(--muted);
}

/* stats */

.stat-tiles {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 4px 0 8px;
}

.stat-tile {
  padding: 12px 14px;
  border: 1px solid var(--bubble-border);
  border-radius: 14px;
  background: var(--surface);
}

.stat-label,
.stat-note {
  font-size: 13px;
  color: var(--muted);
}

.stat-value {
  margin-top: 2px;
  font-size: 26px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.note-list {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
}

.note-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  padding: 12px 0;
  border: 0;
  border-top: 1px solid var(--line);
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  overflow-wrap: anywhere;
  cursor: pointer;
}

.note-row:hover .member-name {
  text-decoration: underline;
}

.note-value,
.note-data {
  resize: vertical;
  min-height: 120px;
}

.note-data {
  min-height: 80px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
}

.stat-list {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
}

.stat-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 16px;
  padding: 14px 0;
  border-top: 1px solid var(--line);
}

.stat-row:first-child {
  border-top: 0;
}

.stat-who {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
}

/* a week of posts: one thin column per day, all agents on one scale */
.spark {
  display: flex;
  gap: 4px;
}

.spark-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 16px;
}

.spark-track {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  width: 100%;
  height: 44px;
  border-bottom: 1px solid var(--line);
}

.spark-bar {
  width: 10px;
  border-radius: 4px 4px 0 0;
  background: var(--c, var(--muted));
}

.spark-day {
  font-size: 11px;
  color: var(--faint);
}

@media (max-width: 520px) {
  .stat-tiles {
    grid-template-columns: minmax(0, 1fr);
  }

  .stat-row {
    grid-template-columns: minmax(0, 1fr);
  }
}

.member-list,
.color-list {
  list-style: none;
  margin: 16px 0 0;
  padding: 0;
}

.member {
  display: grid;
  grid-template-columns: 50px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.member:first-child {
  border-top: 0;
}

.member-name {
  font-weight: 600;
  color: var(--ink-c);
}

.member-about {
  font-size: 14px;
  color: var(--text);
}

.member-seen,
.color-state {
  font-size: 13px;
  color: var(--muted);
}

.color-list {
  margin-top: 4px;
}

.color-row {
  padding: 14px 0;
  border-top: 1px solid var(--line);
}

.color-row:first-child {
  border-top: 0;
}

.color-who {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  padding-left: 58px;
}

.swatch {
  position: relative;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid rgba(127, 127, 127, 0.35);
  border-radius: 50%;
  background: var(--c);
  cursor: pointer;
  transition: transform 0.12s;
}

.swatch:hover {
  transform: scale(1.1);
}

.swatch.on {
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--text);
}

.swatch.custom {
  display: block;
  background: conic-gradient(#ef4444, #eab308, #22c55e, #14b8a6, #3b82f6, #a855f7, #ec4899, #ef4444);
}

.swatch.custom.on {
  background: var(--c);
}

.swatch.custom input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.shapes {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  padding-left: 58px;
  margin-top: 10px;
}

.shape-pick {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  cursor: pointer;
  transition: transform 0.12s, background 0.12s;
}

.shape-pick:hover {
  transform: scale(1.1);
  background: var(--row-active);
}

.shape-pick.on {
  border-color: var(--text);
  background: var(--row-active);
}

.segmented {
  display: inline-flex;
  padding: 3px;
  border-radius: 999px;
  background: var(--row-active);
}

.seg {
  padding: 7px 16px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
}

.seg.on {
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.wide-btn {
  display: block;
  width: 100%;
  margin-top: 24px;
  padding: 12px;
  border: 1px solid var(--bubble-border);
  border-radius: 999px;
  background: transparent;
  font-weight: 600;
  cursor: pointer;
}

.wide-btn:hover {
  background: var(--row-active);
}

.wide-btn.danger {
  color: #f87171;
}

[data-theme="light"] .wide-btn.danger {
  color: #b91c1c;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 96px;
  z-index: 40;
  max-width: calc(100vw - 32px);
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--text);
  color: var(--bg);
  font-size: 14px;
  box-shadow: var(--shadow);
  transform: translateX(-50%);
  animation: pop 0.2s var(--ease) both;
}

/* ---------- phones: the chat list and a chat are separate screens ---------- */

@media (max-width: 760px) {
  .app {
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar {
    border-right: 0;
  }

  .side-toggle {
    display: none;
  }

  body.in-chat .sidebar,
  body:not(.in-chat) .chat {
    display: none;
  }

  .chat-head {
    padding: 10px 12px 6px 54px;
    justify-content: flex-start;
  }

  .chat-head .back {
    display: grid;
  }

  .members-pill {
    max-width: 100%;
    font-size: 14.5px;
  }

  .scroller {
    padding: 0 12px 16px;
  }

  .group {
    grid-template-columns: 34px minmax(0, 1fr);
    column-gap: 8px;
  }

  .group .avatar-col .avatar {
    width: 34px;
    height: 34px;
  }

  .label {
    padding-left: 14px;
  }

  .bubble {
    padding: 10px 15px;
    font-size: 16px;
  }

  .msg-tools {
    display: none;
  }

  /* No hover on a phone: tapping a message shows its tools. */
  .msg.picked .msg-tools {
    display: flex;
    opacity: 1;
  }

  .msg.picked .bubble {
    border-color: color-mix(in srgb, var(--muted) 80%, transparent);
  }

  .mine .label,
  .mine .msg-meta {
    padding-right: 14px;
  }

  .chat-head {
    padding-right: 96px;
  }

  .head-actions {
    right: 10px;
  }

  .tasks-toggle {
    padding: 9px;
  }

  .tasks-toggle-text {
    display: none;
  }

  .composer-wrap {
    padding: 6px 12px 12px;
  }

  .tray-row {
    flex-direction: column;
    gap: 6px;
  }

  .task-bar {
    margin-left: 0;
  }

  .panel-body {
    padding: 0 12px 24px;
  }

  .thread-compose-wrap {
    padding: 8px 10px 12px;
  }

  .swatches,
  .shapes {
    padding-left: 0;
  }
}

/* ---------- motion ---------- */

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
}

@keyframes pop {
  from {
    opacity: 0;
    transform: translateX(var(--tx, 0)) scale(0.94);
  }
}

.jump,
.toast {
  --tx: -50%;
}

@keyframes arrive {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }
}

@keyframes blink {
  0%,
  95%,
  100% {
    transform: scaleY(1);
  }
  97% {
    transform: scaleY(0.1);
  }
}

@keyframes hop {
  0%,
  70%,
  100% {
    transform: translateY(0);
  }
  80% {
    transform: translateY(-8px);
  }
}

@keyframes breathe {
  50% {
    opacity: 0.4;
  }
}

/* Separate layers let a glance, a hover pose and a hop overlap cleanly. */
.avatar :is(.avatar-reaction, .avatar-pose, .avatar-gaze) {
  transform-box: fill-box;
  transform-origin: center;
}

.avatar .avatar-reaction {
  transform-origin: center bottom;
}

.avatar .avatar-pose {
  transition: transform 220ms var(--ease);
}

#messages .group:not(:last-child) .eyes {
  animation: none;
}

/* Only the newest group in the feed gets an idle glance. */
:is(#messages .group:last-child, .chat-avatar, .members-pill, .member, .color-row, .login-art) .avatar-gaze {
  animation: avatar-glance 11s var(--ease) var(--glance-delay) infinite;
}

:is(.chat-avatar, .members-pill, .member) .avatar.recent .avatar-reaction {
  animation: avatar-lilt 5.3s var(--ease) var(--lilt-delay) infinite;
}

@media (prefers-reduced-motion: no-preference) {
  :is(.group, .member, .color-row):focus-within .avatar-pose {
    transform: translateY(-1px) rotate(-5deg);
  }
}

@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  :is(.group, .member, .color-row):hover .avatar-pose {
    transform: translateY(-1px) rotate(-5deg);
  }
}

.group:has(.msg.fresh) .avatar-reaction,
.avatar.color-changed .avatar-reaction {
  animation: avatar-pop 420ms var(--ease);
}

@keyframes avatar-glance {
  0%, 68%, 84%, 100% { transform: translateX(0); }
  72%, 79% { transform: translateX(var(--glance-x)); }
}

@keyframes avatar-lilt {
  0%, 78%, 94%, 100% { transform: translateY(0); }
  85% { transform: translateY(-1.5px); }
}

@keyframes avatar-pop {
  0%, 100% { transform: translateY(0) scale(1); }
  17% { transform: scale(1.1, 0.88); }
  48% { transform: translateY(-4px) scale(0.96, 1.06); }
  75% { transform: scale(1.05, 0.94); }
}

/* Eyes follow the pointer: app.js sets --look-x/--look-y, in SVG units, on each avatar. */
.avatar .avatar-look {
  transform-box: fill-box;
  transform-origin: center;
  transform: translate(var(--look-x, 0), var(--look-y, 0));
  transition: transform 160ms cubic-bezier(0.25, 0.9, 0.3, 1.25), scale 180ms var(--ease);
}

.avatar.settling .avatar-look {
  transition: none;
}

/* Right on top of an avatar: a happy squint. */
.avatar.delighted .avatar-look {
  scale: 1.08 0.42;
}

/* Reconnecting: the agents get drowsy, eyes half shut, and stop glancing around. */
body.offline .avatar .eyes {
  scale: 1 0.35;
}

body.offline .avatar-gaze {
  animation: none !important;
}

/* Back online: they blink awake and shake it off. */
@media (prefers-reduced-motion: no-preference) {
  body.waking .avatar .avatar-reaction {
    animation: avatar-wake 650ms var(--ease) !important;
  }
}

@keyframes avatar-wake {
  0%, 100% { transform: none; }
  20% { transform: translateY(-3px) rotate(-8deg); }
  45% { transform: rotate(7deg); }
  70% { transform: rotate(-4deg); }
}

/* An agent just picked a post up: its avatar fills back in with a little hop. */
.receipt-stack .avatar.woke {
  position: relative;
  animation: receipt-wake 700ms var(--ease) both;
}

@keyframes receipt-wake {
  0% { opacity: 0.3; filter: grayscale(1); transform: none; }
  35% { transform: translateY(-5px) scale(1.15); }
  100% { opacity: 1; filter: none; transform: none; }
}

/* A task just changed hands: the badge pulses in its new color, and a finished one draws its check. */
.task-badge.changed {
  animation: badge-change 650ms var(--ease);
}

.task-badge.changed[data-status="done"] .icon path {
  stroke-dasharray: 1;
  animation: draw 450ms 150ms var(--ease) both;
}

.task-bar.changed {
  animation: bar-change 900ms var(--ease);
}

@keyframes badge-change {
  0% { transform: scale(0.85); box-shadow: 0 0 0 0 color-mix(in srgb, var(--tc) 55%, transparent); }
  45% { transform: scale(1.08); }
  100% { transform: none; box-shadow: 0 0 0 10px transparent; }
}

@keyframes draw {
  from { stroke-dashoffset: 1; }
  to { stroke-dashoffset: 0; }
}

@keyframes bar-change {
  from { background: color-mix(in srgb, var(--tc) 24%, transparent); }
}

/* A chat that just got a new post: its unread dot pops in. */
.dot.popped {
  animation: dot-pop 450ms var(--ease) both;
}

@keyframes dot-pop {
  0% { transform: scale(0); }
  55% { transform: scale(1.45); }
  100% { transform: none; }
}

/* While the agents are watching you, they stop their idle glances. */
body.looking .avatar-gaze {
  animation: none !important;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}

/* ---------- agent setup and channels ---------- */

.pick.sub {
  padding: 3px 10px 3px 5px;
  font-size: 12.5px;
}

.link-btn {
  padding: 0;
  border: 0;
  background: none;
  color: var(--text);
  font: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.member-actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
}

.member-channels {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 4px 0 2px;
  font-size: 13px;
  color: var(--muted);
}

.agent-chan {
  padding: 1px 8px;
  border: 1px solid var(--bubble-border);
  border-radius: 999px;
  font-size: 12.5px;
  color: var(--ink-c);
}

.member-health {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  margin-top: 4px;
  font-size: 12.5px;
  color: var(--ink-c);
}

.badge.warn {
  padding: 1px 8px;
  border: 1px solid color-mix(in srgb, #f59e0b 55%, transparent);
  border-radius: 999px;
  font-size: 12.5px;
  color: #f59e0b;
}

[data-theme="light"] .badge.warn {
  color: #b45309;
}

.setup-prompt,
.setup-channels {
  display: block;
  box-sizing: border-box;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--bubble-border);
  border-radius: 14px;
  background: var(--bg);
  color: var(--text);
  font: 13px/1.5 var(--mono);
  resize: vertical;
}

.setup-channels {
  margin-top: 8px;
}

.setup-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 8px;
}
