/* Braid — calm, Apple-style two-pane UI in General Reasoning's colours (gr.inc): warm cream
   surfaces, dark-brown text, a brown primary, tan/gold accents and a bright teal used only for
   "live". Every colour lives in this one token block (+ its dark-mode twin); nothing below
   hard-codes a colour. Text tokens are WCAG AA (>= 4.5:1) on every surface they sit on. */

/* ------------------------------------------------------------------ tokens */
:root {
  color-scheme: light;
  --font: "Suisse Intl", -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Inter, system-ui, sans-serif;
  --font-display: "Suisse Works", ui-serif, Georgia, Cambria, "Times New Roman", serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --radius: .625rem;

  /* brand */
  --accent: #774A2B;                 /* primary brown  hsl(23 47% 32%)  7.3:1 on cream */
  --on-accent: #FDF8F1;              /* primary-foreground hsl(36 73% 97%) */
  --on-accent-2: rgba(253, 248, 241, .8);
  --accent-tint: rgba(119, 74, 43, .1);
  --accent-ring: rgba(209, 153, 97, .55);   /* tan focus ring */
  --link: #8A4F35;                   /* 6.1:1 */
  --tan: #D19961;                    /* hsl(30 55% 60%) */
  --gold: #BB9B60;
  --teal: #3AE4C2;                   /* live only */
  --teal-edge: #14B394;
  --live-glow: rgba(58, 228, 194, .55);
  --green: var(--teal);
  --green-text: #0F7A66;             /* "Working" text, 5.1:1 */
  --orange: var(--gold);
  --orange-text: #866A33;            /* "Waiting" text, 4.9:1 */
  --orange-tint: rgba(187, 155, 96, .22);
  --agent: #0F7A66;                  /* AGENT heads: teal-ish, 5.1:1 on cream */
  --agent-tint: rgba(58, 228, 194, .16);
  --human: #866A33;                  /* HUMAN heads: warm gold, 4.9:1 on cream */
  --human-tint: rgba(187, 155, 96, .2);
  --red: #A94E33;                    /* rust, 5.3:1 */
  --red-tint: rgba(169, 78, 51, .1);

  /* text */
  --label: #271F1B;                  /* hsl(26 32% 15%)  15.7:1 */
  --label-2: #695749;                /* hsl(25 18% 35%)  6.6:1 */
  --label-3: #76685B;                /* #8A7D70 deepened to 5.2:1 for small text */

  /* lines & fills */
  --sep: #EBE0D2;
  --sep-strong: #EAD9C4;
  --sep-soft: #F1E8DC;
  --fill: rgba(119, 74, 43, .08);
  --fill-2: rgba(119, 74, 43, .045);
  --fill-3: rgba(119, 74, 43, .15);

  /* surfaces */
  --bg: #FFFBF4;
  --bg-sheet: #FAF6F0;
  --cell: #FFFBF4;
  --card: #FBF7F1;
  --sidebar: #FFF7EC;                /* hsl(36 100% 96%) */
  --sidebar-solid: #FFF7EC;
  --row-active: #E9D6B9;             /* sidebar-accent hsl(36 52% 82%) */
  --bubble-me: #774A2B;
  --bubble-me-fg: #FDF8F1;
  --bubble-me-code: rgba(253, 248, 241, .18);
  --bubble-other: #F7E6CC;           /* beige */
  --update-bg: #FBF7F1;
  --update-edge: #D19961;
  --menu-bg: rgba(255, 251, 244, .9);
  --alert-bg: rgba(250, 246, 240, .94);
  --scrim: rgba(39, 31, 27, .26);
  --wallpaper: #FFF7EC;
  --seg-on: #FFFBF4;
  --mark: rgba(187, 155, 96, .38);
  --mark-soft: rgba(187, 155, 96, .22);
  --helper: #8A4F35;
  --helper-tint: rgba(209, 153, 97, .22);
  --avatar-sheen: linear-gradient(180deg, rgba(255, 255, 255, .14), rgba(39, 31, 27, .06));
  --logo-halo: var(--bg);

  --shadow-seg: 0 1px 3px rgba(39, 31, 27, .12), 0 0 0 .5px rgba(39, 31, 27, .05);
  --shadow-sheet: 0 30px 80px rgba(39, 31, 27, .2), 0 4px 14px rgba(39, 31, 27, .08), 0 0 0 .5px rgba(39, 31, 27, .08);
  --shadow-pop: 0 12px 34px rgba(39, 31, 27, .14), 0 2px 6px rgba(39, 31, 27, .06), 0 0 0 .5px rgba(39, 31, 27, .12);

  --strand-1: #774A2B;
  --strand-2: #D19961;
  --strand-3: #BB9B60;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --spring: cubic-bezier(.2, .9, .3, 1.12);
}

/* Dark: warm near-black browns, cream text, tan primary, teal for live. Same token names. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --accent: #D19961;               /* tan; dark text on it is 7.3:1 */
    --on-accent: #1A1512;
    --on-accent-2: rgba(26, 21, 18, .75);
    --accent-tint: rgba(209, 153, 97, .16);
    --accent-ring: rgba(209, 153, 97, .5);
    --link: #E0AE7F;
    --green-text: #3AE4C2;
    --orange-text: #D4B57A;
    --orange-tint: rgba(212, 181, 122, .16);
    --agent: #3AE4C2;                /* AGENT heads: teal (bright on near-black) */
    --agent-tint: rgba(58, 228, 194, .18);
    --human: #D4B57A;                /* HUMAN heads: warm gold */
    --human-tint: rgba(212, 181, 122, .16);
    --red: #E07A5C;
    --red-tint: rgba(224, 122, 92, .14);
    --label: #F6EEE3;
    --label-2: #C9B8A6;
    --label-3: #A39282;
    --sep: rgba(246, 238, 227, .09);
    --sep-strong: rgba(246, 238, 227, .15);
    --sep-soft: rgba(246, 238, 227, .06);
    --fill: rgba(246, 238, 227, .08);
    --fill-2: rgba(246, 238, 227, .045);
    --fill-3: rgba(246, 238, 227, .16);
    --bg: #221C18;
    --bg-sheet: #221C18;
    --cell: #2B241F;
    --card: #2B241F;
    --sidebar: #1A1512;
    --sidebar-solid: #1A1512;
    --row-active: #43362C;
    --bubble-me: #8A4F35;
    --bubble-me-fg: #F6EEE3;
    --bubble-me-code: rgba(246, 238, 227, .16);
    --bubble-other: #3A2F27;
    --update-bg: #2B241F;
    --update-edge: #D19961;
    --menu-bg: rgba(43, 36, 31, .92);
    --alert-bg: rgba(43, 36, 31, .95);
    --scrim: rgba(0, 0, 0, .5);
    --wallpaper: #1A1512;
    --seg-on: #4A3C31;
    --mark: rgba(212, 181, 122, .32);
    --mark-soft: rgba(212, 181, 122, .18);
    --helper: #E0AE7F;
    --helper-tint: rgba(209, 153, 97, .18);
    --avatar-sheen: linear-gradient(180deg, rgba(255, 255, 255, .1), rgba(0, 0, 0, .1));
    --shadow-seg: 0 1px 3px rgba(0, 0, 0, .35), 0 0 0 .5px rgba(246, 238, 227, .06);
    --shadow-sheet: 0 30px 80px rgba(0, 0, 0, .55), 0 0 0 .5px rgba(246, 238, 227, .1);
    --shadow-pop: 0 12px 34px rgba(0, 0, 0, .5), 0 0 0 .5px rgba(246, 238, 227, .12);
    --strand-1: #E0AE7F;
    --strand-2: #8A4F35;
    --strand-3: #BB9B60;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --accent: #D19961;
  --on-accent: #1A1512;
  --on-accent-2: rgba(26, 21, 18, .75);
  --accent-tint: rgba(209, 153, 97, .16);
  --accent-ring: rgba(209, 153, 97, .5);
  --link: #E0AE7F;
  --green-text: #3AE4C2;
  --orange-text: #D4B57A;
  --orange-tint: rgba(212, 181, 122, .16);
  --agent: #3AE4C2;
  --agent-tint: rgba(58, 228, 194, .18);
  --human: #D4B57A;
  --human-tint: rgba(212, 181, 122, .16);
  --red: #E07A5C;
  --red-tint: rgba(224, 122, 92, .14);
  --label: #F6EEE3;
  --label-2: #C9B8A6;
  --label-3: #A39282;
  --sep: rgba(246, 238, 227, .09);
  --sep-strong: rgba(246, 238, 227, .15);
  --sep-soft: rgba(246, 238, 227, .06);
  --fill: rgba(246, 238, 227, .08);
  --fill-2: rgba(246, 238, 227, .045);
  --fill-3: rgba(246, 238, 227, .16);
  --bg: #221C18;
  --bg-sheet: #221C18;
  --cell: #2B241F;
  --card: #2B241F;
  --sidebar: #1A1512;
  --sidebar-solid: #1A1512;
  --row-active: #43362C;
  --bubble-me: #8A4F35;
  --bubble-me-fg: #F6EEE3;
  --bubble-me-code: rgba(246, 238, 227, .16);
  --bubble-other: #3A2F27;
  --update-bg: #2B241F;
  --update-edge: #D19961;
  --menu-bg: rgba(43, 36, 31, .92);
  --alert-bg: rgba(43, 36, 31, .95);
  --scrim: rgba(0, 0, 0, .5);
  --wallpaper: #1A1512;
  --seg-on: #4A3C31;
  --mark: rgba(212, 181, 122, .32);
  --mark-soft: rgba(212, 181, 122, .18);
  --helper: #E0AE7F;
  --helper-tint: rgba(209, 153, 97, .18);
  --avatar-sheen: linear-gradient(180deg, rgba(255, 255, 255, .1), rgba(0, 0, 0, .1));
  --shadow-seg: 0 1px 3px rgba(0, 0, 0, .35), 0 0 0 .5px rgba(246, 238, 227, .06);
  --shadow-sheet: 0 30px 80px rgba(0, 0, 0, .55), 0 0 0 .5px rgba(246, 238, 227, .1);
  --shadow-pop: 0 12px 34px rgba(0, 0, 0, .5), 0 0 0 .5px rgba(246, 238, 227, .12);
  --strand-1: #E0AE7F;
  --strand-2: #8A4F35;
  --strand-3: #BB9B60;
}

/* ------------------------------------------------------------------ base */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font: 15px/1.47 var(--font);
  color: var(--label);
  background: var(--bg-sheet) var(--wallpaper) no-repeat;
  background-size: 100% 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { -webkit-tap-highlight-color: transparent; }
a { color: var(--link); }
:focus { outline: none; }
:focus-visible { outline: 3px solid var(--accent-ring); outline-offset: 1px; border-radius: 6px; }
::selection { background: var(--accent-ring); }
[hidden] { display: none !important; }
code, .mono { font-family: var(--mono); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.grow { flex: 1; }
.muted { color: var(--label-2); }
.center { display: flex; align-items: center; justify-content: center; }
.center.col { flex-direction: column; gap: 14px; }
.pad { padding: 16px; }
.pad-xl { padding: 56px 16px; }
.fill { height: 100vh; height: 100dvh; width: 100%; }

.icon { display: inline-flex; width: 16px; height: 16px; flex-shrink: 0; }
.icon svg { width: 100%; height: 100%; display: block; }

/* ------------------------------------------------------------------ shell */
.app {
  display: grid;
  grid-template-columns: 336px minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
}
.app.app-login, .app.app-loading { grid-template-columns: 1fr; }

.sidebar {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--sidebar);
  -webkit-backdrop-filter: saturate(180%) blur(30px);
  backdrop-filter: saturate(180%) blur(30px);
  border-right: .5px solid var(--sep-strong);
  --logo-halo: var(--sidebar-solid);
}
.detail {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--bg);
  outline: none;
}

/* ------------------------------------------------------------------ controls */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 30px;
  padding: 0 14px;
  border: 0;
  border-radius: calc(var(--radius) - 2px);
  font-size: 14px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color .15s, opacity .15s, transform .12s var(--ease), filter .15s;
  user-select: none;
}
.btn .icon { width: 15px; height: 15px; }
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled { opacity: .38; cursor: default; }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-danger { background: var(--danger, #b42318); color: #fff; }
.btn-danger:hover:not(:disabled) { filter: brightness(1.08); }
.team-head-actions { display: flex; align-items: center; gap: 8px; }
.team-stopped { font-size: 13px; color: var(--muted, #888); }
.btn-primary:hover:not(:disabled) { filter: brightness(1.08); }
.btn-secondary { background: var(--fill); color: var(--label); }
.btn-secondary:hover:not(:disabled) { background: var(--fill-3); }
.btn-plain { background: none; color: var(--accent); padding: 0 6px; }
.btn-plain:hover:not(:disabled) { background: var(--accent-tint); }
.btn-destructive { background: none; color: var(--red); padding: 0 8px; }
.btn-destructive:hover:not(:disabled) { background: var(--red-tint); }
.btn-sm { height: 26px; padding: 0 10px; font-size: 13px; border-radius: 7px; }
.btn-lg { height: 40px; font-size: 15px; border-radius: 10px; }
.btn-block { width: 100%; }

.icon-btn {
  width: 30px; height: 30px;
  display: inline-grid; place-items: center;
  border: 0; border-radius: 50%;
  background: var(--fill);
  color: var(--label);
  cursor: pointer;
  transition: background-color .15s, transform .12s var(--ease);
}
.icon-btn:hover { background: var(--fill-3); }
.icon-btn:active { transform: scale(.94); }
.icon-btn .icon { width: 17px; height: 17px; }

.linkish {
  background: none; border: 0; padding: 0;
  color: var(--accent); font: inherit; cursor: pointer;
}
.linkish:hover { text-decoration: underline; }

.segmented {
  display: flex;
  padding: 2px;
  gap: 2px;
  border-radius: 9px;
  background: var(--fill);
}
.segmented .seg {
  flex: 1;
  height: 26px;
  padding: 0 10px;
  border: 0;
  border-radius: 7px;
  background: none;
  font-size: 13px;
  font-weight: 500;
  color: var(--label);
  cursor: pointer;
  white-space: nowrap;
  transition: background-color .18s var(--ease), box-shadow .18s var(--ease);
}
.segmented .seg.on {
  background: var(--seg-on);
  box-shadow: var(--shadow-seg);
  font-weight: 600;
}
.seg-wide { width: 100%; }

.spinner {
  display: inline-block;
  width: 18px; height: 18px;
  border: 2px solid var(--fill-3);
  border-top-color: var(--label-2);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
.mini-spinner {
  display: inline-block;
  width: 10px; height: 10px;
  border: 1.5px solid var(--fill-3);
  border-top-color: var(--label-2);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  flex-shrink: 0;
}

.live-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.live-dot.working { background: var(--teal); box-shadow: inset 0 0 0 1px var(--teal-edge); animation: pulse 2s ease-in-out infinite; }
.live-dot.waiting { background: var(--orange); }

/* ------------------------------------------------------------------ avatars */
.avatar {
  --size: 30px;
  position: relative;
  display: inline-grid;
  place-items: center;
  width: var(--size); height: var(--size);
  border-radius: 50%;
  background: var(--av-bg, var(--fill-3));
  background-image: var(--avatar-sheen);
  color: var(--av-fg, var(--on-accent));
  font-size: calc(var(--size) * .4);
  font-weight: 600;
  letter-spacing: .01em;
  flex-shrink: 0;
  user-select: none;
}
.avatar-xs { --size: 18px; font-size: 8.5px; }
.avatar-sm { --size: 26px; }
.avatar-md { --size: 30px; }
.avatar-lg { --size: 38px; }
.avatar-xl { --size: 64px; }
.avatar.driving { box-shadow: 0 0 0 2px var(--bg), 0 0 0 3.5px var(--accent); }
.presence-dot {
  position: absolute; right: -1px; bottom: -1px;
  width: 30%; height: 30%; min-width: 8px; min-height: 8px;
  border-radius: 50%;
  border: 2px solid var(--cell);
}
.presence-dot.on { background: var(--green); }
.presence-dot.off { display: none; }
.driving-badge { display: none; }

.avatar-pair { position: relative; display: inline-flex; flex-shrink: 0; }
.avatar-second {
  position: absolute; right: -4px; bottom: -3px;
  box-shadow: 0 0 0 2px var(--sidebar-solid);
}

.stack { display: inline-flex; align-items: center; }
.stack .avatar { box-shadow: 0 0 0 2px var(--bg); }
.stack .avatar + .avatar { margin-left: -7px; }
.stack .avatar.driving { box-shadow: 0 0 0 2px var(--bg), 0 0 0 3.5px var(--accent); }
.avatar-more { --av-bg: var(--fill-3); background: var(--fill-3); color: var(--label-2); font-size: 10px; }
.avatar.enter { animation: pop .4s var(--spring); }

/* ------------------------------------------------------------------ sidebar */
.sb-top { padding: 14px 14px 6px; }
.sb-titlebar { display: flex; align-items: center; gap: 10px; margin: 10px 0 12px; }
.org-title {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 2px 6px;
  margin-left: -6px;
  border: 0;
  border-radius: 8px;
  background: none;
  text-align: left;
  cursor: pointer;
  font: 500 23px/1.15 var(--font-display);
  letter-spacing: -.012em;
  color: var(--label);
}
.org-title:hover { background: var(--fill-2); }
.org-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.org-chev { display: inline-flex; color: var(--label-2); transition: transform .2s var(--ease); }
.org-chev .icon { width: 15px; height: 15px; }
.org-title[aria-expanded="true"] .org-chev { transform: rotate(180deg); }
.me-btn { padding: 0; border: 0; background: none; border-radius: 50%; cursor: pointer; }
.me-btn:hover .avatar { filter: brightness(1.06); }

.search-field {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 8px 0 9px;
  border-radius: 10px;
  background: var(--fill);
  color: var(--label-2);
}
.search-field:focus-within { box-shadow: 0 0 0 3px var(--accent-ring); }
.search-field > .icon { width: 15px; height: 15px; }
.search-input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 0;
  outline: none;
  background: transparent;
  font-size: 15px;
  color: var(--label);
}
.search-input::placeholder { color: var(--label-2); }
.search-input::-webkit-search-cancel-button { display: none; }
.search-clear {
  width: 18px; height: 18px;
  display: grid; place-items: center;
  border: 0; border-radius: 50%;
  background: var(--label-3); color: var(--bg);
  cursor: pointer;
}
.search-clear .icon { width: 10px; height: 10px; }

.sb-toolbar { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.scope-seg { flex: 1; }
.select-btn { font-weight: 500; }

.sb-status {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 4px 0 2px;
  font-size: 12px; color: var(--label-2);
}

.sb-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 2px 8px 16px;
}
.sb-section-title {
  margin: 14px 10px 4px 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--label-2);
  letter-spacing: .02em;
}
.sb-section:first-child .sb-section-title { margin-top: 8px; }
.sb-loading { display: flex; justify-content: center; padding: 16px; }

.row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 58px;
  padding: 8px 10px 8px 14px;
  border-radius: var(--radius);
  color: inherit;
  text-decoration: none;
  cursor: default;
  transition: background-color .12s;
}
.row + .row::after {
  content: "";
  position: absolute;
  top: 0; left: 63px; right: 10px;
  border-top: .5px solid var(--sep);
}
@media (hover: hover) { .row:hover { background: var(--fill-2); } }
.row.active { background: var(--row-active); color: var(--label); }
.row.active::after, .row.active + .row::after, .row:hover::after, .row:hover + .row::after { border-color: transparent; }
.row.active .row-line2, .row.active .row-line2 time { color: var(--label-2); }
.row.active .avatar-second { box-shadow: 0 0 0 2px var(--row-active); }

.row.checked:not(.active) { background: var(--accent-tint); }
.unread-dot {
  position: absolute;
  left: 3px; top: 50%;
  width: 8px; height: 8px;
  margin-top: -4px;
  border-radius: 50%;
  background: var(--accent);
  transform: scale(0);
  transition: transform .25s var(--spring);
}
.row.unread .unread-dot { transform: scale(1); }
.row.active .unread-dot { transform: scale(0); }
.row-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.row-line1 { display: flex; align-items: center; gap: 8px; min-width: 0; }
.row .row-title {
  flex: 1;
  min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -.005em;
}
.row-line2 {
  display: flex;
  align-items: baseline;
  gap: 4px;
  min-width: 0;
  font-size: 13px;
  color: var(--label-2);
  white-space: nowrap;
}
.row-sub { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.row-line2 time { flex-shrink: 0; }
.hit-snippet {
  font-size: 12.5px; line-height: 1.4; color: var(--label-2);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.row.hit { min-height: 52px; align-items: flex-start; }
.row.hit .avatar-pair { margin-top: 2px; }

/* AgentOrg team rows: a stack of the team's agent avatars + an "N agents" tag, so a team reads
   distinctly from a single-person session (which shows one owner avatar + "You · repo · time"). */
.row-team-ind { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; min-width: 38px; }
.row-team-ind.team-fallback { width: 38px; height: 38px; border-radius: 50%; background: var(--fill-3); color: var(--label-2); }
.row-team-ind.team-fallback .icon { width: 20px; height: 20px; }
.row-team-tag { display: inline-flex; align-items: center; gap: 4px; flex-shrink: 0; color: var(--label-2); }
.row-team-tag .icon { width: 13px; height: 13px; }
.row.team.active .row-team-tag { color: var(--label-2); }
.check-circle {
  width: 22px; height: 22px;
  display: grid; place-items: center;
  flex-shrink: 0;
  border-radius: 50%;
  border: 1.5px solid var(--label-3);
  color: var(--on-accent);
  transition: background-color .15s, border-color .15s, transform .2s var(--spring);
  animation: pop .25s var(--spring);
}
.check-circle.on { background: var(--accent); border-color: var(--accent); }
.check-circle .icon { width: 13px; height: 13px; }

.sidebar.selecting .row { cursor: pointer; }
.sidebar.selecting .row + .row::after { left: 96px; }

.sb-bottom { flex-shrink: 0; }
.sb-foot {
  display: flex; align-items: center; gap: 6px;
  padding: 10px 20px 14px;
  font-size: 12px; font-weight: 600;
  color: var(--label-3);
}
.foot-logo { display: inline-flex; width: 16px; height: 16px; opacity: .85; }
.foot-logo svg { width: 100%; height: 100%; }
.select-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px 14px;
  border-top: .5px solid var(--sep-strong);
  animation: slideUp .28s var(--ease);
}
.select-count { flex: 1; font-size: 12.5px; color: var(--label-2); }

/* ------------------------------------------------------------------ empty / placeholder */
.empty { padding: 40px 20px; text-align: center; }
.empty-title { font-size: 15px; font-weight: 500; color: var(--label-2); }
.empty-body { margin-top: 4px; font-size: 13px; color: var(--label-3); }
.empty-action { margin-top: 12px; font-size: 14px; }

.placeholder {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 40px 24px;
  text-align: center;
  animation: fadeIn .4s var(--ease);
}
.ph-logo { width: 56px; height: 56px; margin-bottom: 6px; }
.ph-logo svg { width: 100%; height: 100%; }
.ph-title { font: 500 26px/1.2 var(--font-display); letter-spacing: -.012em; }
.ph-body { max-width: 40ch; font-size: 15px; color: var(--label-2); }
.placeholder .btn { margin-top: 10px; }
.ph-card {
  display: flex; align-items: center; gap: 12px;
  margin-top: 18px;
  width: min(420px, 100%);
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--fill-2);
  color: inherit; text-decoration: none; text-align: left;
  transition: background-color .15s, transform .15s var(--ease);
}
.ph-card:hover { background: var(--fill); }
.ph-card:active { transform: scale(.99); }
.ph-card-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ph-card-title { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ph-card-sub { font-size: 13px; color: var(--label-2); }
.ph-card-go { color: var(--accent); font-size: 14px; font-weight: 500; }

/* ------------------------------------------------------------------ session */
.session { display: flex; flex-direction: column; min-height: 0; height: 100%; }
.s-header {
  flex-shrink: 0;
  padding: 18px 28px 14px;
  border-bottom: .5px solid transparent;
  transition: border-color .2s;
}
.s-header.scrolled { border-bottom-color: var(--sep-strong); }
.back-btn {
  display: none;
  align-items: center;
  gap: 2px;
  margin: 0 0 6px -8px;
  padding: 4px 6px;
  border-radius: 8px;
  color: var(--accent);
  font-size: 17px;
  text-decoration: none;
}
.back-btn .icon { width: 22px; height: 22px; }
.s-head-row { display: flex; align-items: center; gap: 16px; }
.s-head-text { flex: 1; min-width: 0; }
.s-title {
  margin: 0;
  font: 500 23px/1.25 var(--font-display);
  letter-spacing: -.012em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.team-header .s-title {
  white-space: normal;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.s-title-input {
  width: 100%;
  font: 500 23px/1.25 var(--font-display);
  letter-spacing: -.012em;
  border: 0;
  border-radius: 6px;
  padding: 0 4px;
  margin-left: -4px;
  background: var(--fill-2);
  box-shadow: 0 0 0 3px var(--accent-ring);
}
.s-subtitle {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 3px;
  font-size: 13px;
  color: var(--label-2);
  white-space: nowrap;
  overflow: hidden;
}
.s-subtitle > span { overflow: hidden; text-overflow: ellipsis; }
.s-subtitle .sep-dot { color: var(--label-3); flex-shrink: 0; }
.s-state { font-weight: 500; flex-shrink: 0; }
.s-state.busy, .s-state.live { color: var(--green-text); }
.s-state.waiting { color: var(--orange-text); }
.s-head-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.here { display: inline-flex; }

.split { display: inline-flex; }
.split .ask-btn { border-radius: 8px 0 0 8px; }
.split .split-chev { border-radius: 0 8px 8px 0; padding: 0 8px; margin-left: 1px; }
.split .split-chev .icon { width: 13px; height: 13px; }

.control-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  padding: 0 4px 0 7px;
  border-radius: 16px;
  background: var(--accent-tint);
  font-size: 13px;
  white-space: nowrap;
}
.control-pill.attention { background: var(--orange-tint); }
.control-pill.waiting { background: var(--fill); padding-left: 12px; }
.control-pill.quiet { background: var(--fill-2); padding-right: 14px; }
.pill-text b { font-weight: 600; }
.pill-sub { color: var(--label-2); }
.pill-btn {
  height: 24px;
  padding: 0 11px;
  border: 0;
  border-radius: 12px;
  background: var(--cell);
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-seg);
}
.pill-btn.destructive { color: var(--red); }
.pill-btn:hover { filter: brightness(.97); }

.s-body { position: relative; flex: 1; min-height: 0; }
.s-scroll { height: 100%; overflow-y: auto; overscroll-behavior: contain; outline: none; }
.s-thread { max-width: 780px; margin: 0 auto; padding: 18px 28px 32px; }

.new-pill {
  position: absolute;
  bottom: 14px; left: 50%;
  transform: translateX(-50%);
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px;
  padding: 0 14px;
  border: 0;
  border-radius: 16px;
  background: var(--menu-bg);
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
  box-shadow: var(--shadow-pop);
  color: var(--accent);
  font-size: 13px; font-weight: 600;
  cursor: pointer;
  animation: rise .3s var(--spring);
}
.new-pill .icon { width: 14px; height: 14px; }

/* ------------------------------------------------------------------ transcript blocks */
.blk { margin: 0 0 16px; }
.blk-tools, .blk-helper { margin-top: -6px; margin-bottom: 12px; }
.blk-user + .blk-tools, .blk-user + .blk-helper { margin-top: 0; }
.blk.enter { animation: enter .34s var(--ease); }
.blk.highlight { animation: highlight 2.6s var(--ease); border-radius: 12px; }
.time-sep {
  margin: 20px 0 14px;
  text-align: center;
  font-size: 12px;
  font-weight: 500;
  color: var(--label-3);
}
.blk:first-child .time-sep { margin-top: 4px; }

.msg { display: flex; align-items: flex-end; gap: 8px; }
.msg-me { justify-content: flex-end; }
.msg-col { display: flex; flex-direction: column; min-width: 0; max-width: min(75%, 560px); }
.msg-me .msg-col { align-items: flex-end; }
.msg-name { margin: 0 0 3px 13px; font-size: 12px; color: var(--label-2); }
.msg-avatar { margin-bottom: 1px; }
.bubble {
  padding: 8px 14px;
  border-radius: 19px;
  font-size: 15px;
  line-height: 1.42;
  overflow-wrap: anywhere;
}
.msg-me .bubble { background: var(--bubble-me); color: var(--bubble-me-fg); border-bottom-right-radius: 6px; }
.msg-other .bubble { background: var(--bubble-other); color: var(--label); border-bottom-left-radius: 6px; }
.bubble .md p { margin: 0; }
.bubble .md p + p, .bubble .md p + ul, .bubble .md ul + p { margin-top: 6px; }
.msg-me .bubble a { color: var(--bubble-me-fg); text-decoration: underline; }
.msg-me .bubble code, .msg-me .bubble pre.code { background: var(--bubble-me-code); color: var(--bubble-me-fg); }
.msg-status { margin: 3px 8px 0; font-size: 11.5px; font-weight: 500; color: var(--label-2); display: flex; gap: 8px; align-items: center; }
.msg-status.failed { color: var(--red); }
.msg-status .icon { width: 13px; height: 13px; }
.msg-time { margin: 2px 13px 0; font-size: 11px; color: var(--label-3); }
.reply-label .msg-time { font-weight: 400; color: var(--label-3); }
.pending .bubble { opacity: .72; }
.pending.state-sending .bubble { opacity: .55; }

.reply { max-width: 72ch; font-size: 15px; line-height: 1.6; }
.reply-label {
  display: flex; align-items: center; gap: 6px;
  margin-bottom: 4px;
  font-size: 12px; font-weight: 600;
  color: var(--label-2);
}
.reply-mark .icon { width: 13px; height: 13px; }

.md > :first-child { margin-top: 0; }
.md p { margin: 0 0 .75em; }
.md p:last-child, .md > :last-child { margin-bottom: 0; }
.md ul, .md ol { margin: 0 0 .75em; padding-left: 1.35em; }
.md li { margin: .2em 0; }
.md li::marker { color: var(--label-2); }
.md h3, .md h4, .md h5, .md h6 { margin: 1.1em 0 .4em; font-size: 15px; font-weight: 600; }
.md code {
  font-size: .87em;
  padding: .1em .38em;
  border-radius: 5px;
  background: var(--fill);
}
.md pre.code {
  position: relative;
  margin: .4em 0 .9em;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--fill-2);
  overflow-x: auto;
  font: 12.5px/1.55 var(--mono);
}
.md pre code { padding: 0; background: none; font-size: inherit; }
.code-lang { position: absolute; top: 6px; right: 10px; font: 11px var(--font); color: var(--label-3); }
.md blockquote { margin: 0 0 .75em; padding-left: 12px; border-left: 3px solid var(--sep-strong); color: var(--label-2); }
.md a { color: var(--link); text-decoration: none; }
.md a:hover { text-decoration: underline; }
.md hr { border: 0; border-top: .5px solid var(--sep-strong); margin: 1em 0; }
.redacted { padding: 0 5px; border-radius: 4px; background: var(--fill); color: var(--label-2); font-size: .85em; }
mark { background: var(--mark); color: inherit; border-radius: 3px; padding: 0 1px; }
.redact-note { display: inline-flex; align-items: center; gap: 4px; margin-top: 4px; font-size: 11.5px; color: var(--label-3); }
.redact-note .icon { width: 11px; height: 11px; }

/* disclosure rows (tools, helper) */
.disclosure > summary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  margin-left: -6px;
  padding: 5px 10px 5px 6px;
  border-radius: 9px;
  list-style: none;
  font-size: 13px;
  color: var(--label-2);
  cursor: pointer;
  user-select: none;
  transition: background-color .12s, color .12s;
}
.disclosure > summary::-webkit-details-marker { display: none; }
.disclosure > summary:hover { background: var(--fill-2); color: var(--label); }
.disc-icon {
  display: grid; place-items: center;
  width: 22px; height: 22px;
  border-radius: 6px;
  background: var(--fill);
  color: var(--label-2);
  flex-shrink: 0;
}
.disc-icon .icon { width: 13px; height: 13px; }
.disc-icon.helper { color: var(--helper); background: var(--helper-tint); }
.disc-label { font-weight: 500; white-space: nowrap; }
.disc-sub { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--label-3); }
.disc-note { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--label-3); white-space: nowrap; }
.disc-note.warn { color: var(--orange-text); }
.chev { display: inline-flex; color: var(--label-3); flex-shrink: 0; }
.chev .icon { width: 12px; height: 12px; transition: transform .22s var(--ease); }
.disclosure[open] > summary .chev .icon { transform: rotate(90deg); }
.disclosure-body { margin: 6px 0 2px; animation: fadeIn .2s var(--ease); }

.tool-list {
  border-radius: 12px;
  background: var(--fill-2);
  padding: 3px 4px;
  max-width: 72ch;
}
.tool-item + .tool-item { border-top: .5px solid var(--sep); }
.tool-item > summary {
  display: flex;
  width: 100%;
  margin: 0;
  padding: 8px 10px;
  gap: 10px;
  border-radius: 8px;
  color: var(--label-2);
}
.tool-item > summary:hover { background: var(--fill-2); }
.tool-name { flex-shrink: 0; font-weight: 600; color: var(--label); }
.tool-sum { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tool-sum.mono { font-size: 12px; }
.tool-failed { flex-shrink: 0; font-size: 11.5px; font-weight: 600; color: var(--red); }
.tool-item.plain { padding: 8px 10px; font-size: 13px; color: var(--label-2); }
.tool-detail { padding: 0 10px 10px; }
.tool-desc { font-size: 12.5px; color: var(--label-2); margin-bottom: 4px; }
.tool-waiting { font-size: 12.5px; color: var(--label-3); margin-top: 6px; }
.tool-detail pre.code {
  margin: 6px 0 0;
  padding: 10px 12px;
  max-height: 340px;
  overflow: auto;
  border-radius: 8px;
  background: var(--bg);
  border: .5px solid var(--sep);
  font: 12px/1.5 var(--mono);
  white-space: pre-wrap;
  word-break: break-word;
}
.tool-detail pre.cmd { color: var(--label); }
.tool-detail pre.output { color: var(--label-2); }
.tool-detail .btn-plain { margin-top: 4px; }

.helper-body {
  margin: 6px 0 4px 10px;
  padding: 4px 0 2px 16px;
  border-left: 2px solid var(--helper-tint);
}
.helper-cap { margin-bottom: 2px; font-size: 12px; font-weight: 600; color: var(--label-2); }
.helper-ask { margin: 4px 0 12px; font-size: 14px; max-width: 70ch; }
.helper-body .blk { margin-bottom: 10px; }
.helper-body .reply { font-size: 14px; }

.summary-card {
  max-width: 72ch;
  padding: 16px 20px 18px;
  border-radius: 14px;
  background: var(--card);
  border: .5px solid var(--sep);
}
.summary-head {
  display: flex; align-items: center; gap: 7px;
  margin-bottom: 10px;
  font-size: 13px; font-weight: 600;
  color: var(--label-2);
}
.summary-card .md { font-size: 14.5px; line-height: 1.58; }
.summary-card .md h3, .summary-card .md h4 { font-size: 14px; margin-top: 1em; }

.caption-center { padding: 2px 0; text-align: center; font-size: 12px; color: var(--label-3); }

.lineage-card { margin-bottom: 22px; }
.lineage-title { margin: 0 0 6px 4px; font-size: 13px; font-weight: 600; color: var(--label-2); }
.lineage-card .inset-list { background: var(--fill-2); }

/* ------------------------------------------------------------------ composer */
.composer-wrap {
  flex-shrink: 0;
  padding: 10px 28px 18px;
  background: var(--bg);
}
.composer-wrap > * { max-width: 724px; margin-left: auto; margin-right: auto; }
.composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 4px 4px 4px 16px;
  border: .5px solid var(--sep-strong);
  border-radius: 20px;
  background: var(--bg);
  transition: box-shadow .15s, border-color .15s;
}
.composer:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint); }
.composer-input {
  flex: 1;
  min-width: 0;
  max-height: 180px;
  padding: 6px 0;
  border: 0;
  outline: none;
  resize: none;
  background: transparent;
  font-size: 15px;
  line-height: 1.4;
  color: var(--label);
}
.composer-input::placeholder { color: var(--label-3); }
.send-btn {
  display: grid; place-items: center;
  width: 30px; height: 30px;
  flex-shrink: 0;
  border: 0; border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
  cursor: pointer;
  transition: background-color .15s, transform .15s var(--spring);
}
.send-btn:disabled { background: var(--fill-3); color: var(--bg); cursor: default; }
.send-btn:not(:disabled):active { transform: scale(.9); }
.send-btn .icon { width: 16px; height: 16px; }
.composer-caption {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 8px;
  padding-left: 16px;
  font-size: 12.5px;
  color: var(--label-2);
}
.cap-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); }
.composer-locked {
  display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 8px;
  padding: 7px 0 4px;
  font-size: 13px;
  color: var(--label-2);
  text-align: center;
}

/* ------------------------------------------------------------------ menus */
.menu {
  position: fixed;
  z-index: 80;
  min-width: 220px;
  max-width: calc(100vw - 16px);
  padding: 5px;
  border-radius: 11px;
  background: var(--menu-bg);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
  backdrop-filter: saturate(180%) blur(24px);
  box-shadow: var(--shadow-pop);
  animation: menuIn .16s var(--ease);
}
.menu.leaving { animation: menuOut .14s var(--ease) forwards; }
.menu-item {
  display: flex;
  align-items: center;
  gap: 4px;
  width: 100%;
  padding: 6px 10px 6px 4px;
  border: 0;
  border-radius: 6px;
  background: none;
  text-align: left;
  font-size: 14px;
  color: var(--label);
  cursor: default;
}
.menu-item:hover:not(:disabled), .menu-item:focus-visible { background: var(--accent); color: var(--on-accent); outline: none; }
.menu-item:hover:not(:disabled) .menu-hint, .menu-item:focus-visible .menu-hint,
.menu-item:hover:not(:disabled) .menu-icon, .menu-item:focus-visible .menu-icon { color: var(--on-accent-2); }
.menu-item:disabled { color: var(--label-3); }
.menu-item.destructive { color: var(--red); }
.menu-check { display: grid; place-items: center; width: 18px; flex-shrink: 0; }
.menu-check .icon { width: 12px; height: 12px; }
.menu-label { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.menu-hint { font-size: 12px; color: var(--label-2); }
.menu-item:disabled .menu-hint { color: var(--label-3); }
.menu-icon { display: inline-flex; color: var(--label-2); }
.menu-icon .icon { width: 15px; height: 15px; }
.menu-sep { height: .5px; margin: 5px 10px; background: var(--sep-strong); }
.menu-header { padding: 6px 10px 3px 22px; font-size: 12px; font-weight: 600; color: var(--label-2); }
.menu-node { padding: 4px 6px 6px; }
.menu-form .menu-header { padding-left: 10px; }
.menu-note { padding: 2px 6px 4px; font-size: 13px; color: var(--label-2); }
.menu-me { display: flex; align-items: center; gap: 10px; padding: 8px 8px 6px; }
.menu-me-text { min-width: 0; }
.menu-me-name { font-weight: 600; }
.menu-me-sub { font-size: 12.5px; color: var(--label-2); overflow: hidden; text-overflow: ellipsis; }

/* ------------------------------------------------------------------ toasts */
.toasts {
  position: fixed;
  top: 78px; right: 18px;
  z-index: 70;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(360px, calc(100vw - 28px));
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 12px;
  border-radius: 16px;
  background: var(--menu-bg);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
  backdrop-filter: saturate(180%) blur(24px);
  box-shadow: var(--shadow-pop);
  pointer-events: auto;
  animation: toastIn .42s var(--spring);
}
.toast.clickable { cursor: pointer; }
.toast.leaving { animation: toastOut .26s var(--ease) forwards; }
.toast-icon { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; background: var(--accent-tint); color: var(--accent); flex-shrink: 0; }
.toast-icon .icon { width: 17px; height: 17px; }
.toast-main { flex: 1; min-width: 0; }
.toast-title { font-size: 13.5px; font-weight: 600; line-height: 1.3; }
.toast-body { margin-top: 1px; font-size: 13px; line-height: 1.35; color: var(--label-2); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.toast-alert .toast-title { color: var(--red); }
.toast-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* ------------------------------------------------------------------ sheets & alerts */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--scrim);
  animation: fadeIn .2s var(--ease);
}
.overlay.leaving { animation: fadeOut .2s var(--ease) forwards; }
.overlay.leaving .sheet { animation: sheetOut .2s var(--ease) forwards; }
.sheet {
  display: flex;
  flex-direction: column;
  width: min(520px, 100%);
  max-height: min(86vh, 780px);
  overflow: hidden;
  border-radius: calc(var(--radius) + 4px);
  background: var(--bg-sheet);
  box-shadow: var(--shadow-sheet);
  animation: sheetIn .34s var(--spring);
  outline: none;
}
.sheet-tall { height: min(86vh, 720px); }
.sheet-grabber { display: none; }
.sheet-head { position: relative; display: flex; align-items: center; justify-content: center; padding: 16px 52px 6px; }
.sheet-title { margin: 0; font: 500 19px/1.25 var(--font-display); text-align: center; letter-spacing: -.005em; }
.sheet-close {
  position: absolute; right: 14px; top: 13px;
  display: grid; place-items: center;
  width: 28px; height: 28px;
  border: 0; border-radius: 50%;
  background: var(--fill);
  color: var(--label-2);
  cursor: pointer;
}
.sheet-close .icon { width: 12px; height: 12px; }
.sheet-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 12px 20px 8px; }
.sheet-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 12px 20px 18px; }
.sheet-foot .btn { min-width: 84px; }
.sheet-lead { margin: 0 0 16px; font-size: 14px; color: var(--label-2); }

.sheet-alert {
  width: 300px;
  text-align: center;
  background: var(--alert-bg);
  -webkit-backdrop-filter: saturate(180%) blur(30px);
  backdrop-filter: saturate(180%) blur(30px);
}
.sheet-alert .sheet-body { padding: 22px 18px 6px; overflow: visible; }
.sheet-alert .sheet-foot { display: block; padding: 12px 16px 16px; }
.alert-content { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.alert-title { margin: 8px 0 0; font-size: 15px; font-weight: 600; line-height: 1.35; letter-spacing: -.005em; }
.alert-text { margin: 0; font-size: 13px; line-height: 1.4; color: var(--label); }
.alert-row { display: flex; gap: 8px; }
.alert-row .btn { flex: 1; min-width: 0; padding: 0 8px; }
.alert-link { display: block; margin: 12px auto 0; font-size: 13px; }

/* grouped, inset lists (Settings-style) */
.grouped .group { margin-bottom: 22px; }
.group-title {
  display: flex; align-items: center; gap: 6px;
  margin: 0 0 6px 16px;
  font-size: 13px; font-weight: 400;
  color: var(--label-2);
}
.group-count { color: var(--label-3); }
.inset-list { margin: 0; padding: 0; list-style: none; border-radius: var(--radius); background: var(--cell); overflow: hidden; }
.inset-list > li { position: relative; }
.inset-list > li + li::before {
  content: "";
  position: absolute;
  top: 0; left: 14px; right: 0;
  border-top: .5px solid var(--sep-strong);
}
.inset-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  padding: 9px 14px;
  font-size: 14px;
  color: inherit;
  text-decoration: none;
}
.inset-row.wrap { align-items: flex-start; }
.inset-list.compact .inset-row { min-height: 38px; padding: 8px 12px; }
.inset-row.muted { color: var(--label-2); }
.link-row:hover { background: var(--fill-2); }
.row-main { flex: 1; min-width: 0; }
.inset-row .row-title { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inset-row .row-sub { font-size: 12.5px; color: var(--label-2); white-space: normal; }
.row-trail { margin-left: auto; flex-shrink: 0; font-size: 13px; color: var(--label-2); }
.row-chev { display: inline-flex; color: var(--label-3); }
.row-chev .icon { width: 13px; height: 13px; }
.row-icon { display: inline-flex; color: var(--label-2); margin-top: 1px; }
.row-icon .icon { width: 16px; height: 16px; }
.row-icon.warn { color: var(--orange); }
.row-icon.accent { color: var(--accent); }
.kv .kv-k { flex-shrink: 0; }
.kv .kv-v { margin-left: auto; min-width: 0; text-align: right; color: var(--label-2); overflow-wrap: anywhere; }
.kv .kv-v.mono { font-size: 12.5px; }
.remove-btn {
  display: grid; place-items: center;
  width: 22px; height: 22px;
  border: 0; border-radius: 50%;
  background: var(--fill);
  color: var(--label-2);
  cursor: pointer;
}
.remove-btn:hover { background: var(--red-tint); color: var(--red); }
.remove-btn .icon { width: 10px; height: 10px; }
.add-row { color: var(--accent); }
.add-row select { color: var(--accent); cursor: pointer; }

/* forms */
.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 0; }
.field-label { display: block; margin: 6px 0 6px 4px; font-size: 13px; color: var(--label-2); }
.field-input {
  height: 38px;
  padding: 0 12px;
  border: .5px solid var(--sep-strong);
  border-radius: 10px;
  background: var(--cell);
  font-size: 15px;
  color: var(--label);
  outline: none;
  transition: box-shadow .15s, border-color .15s;
}
.field-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint); }
.field-input.bare { flex: 1; min-width: 0; height: auto; padding: 0; border: 0; border-radius: 0; background: transparent; box-shadow: none; font-size: 14px; }
.field-hint { margin: -6px 4px 0; font-size: 12.5px; color: var(--label-2); }
.form-error { font-size: 13px; color: var(--red); }
.form-error:empty { display: none; }
.inset-fields { display: flex; flex-direction: column; overflow: hidden; border-radius: 10px; background: var(--cell); }
.inset-fields .field-input { border: 0; border-radius: 0; border-bottom: .5px solid var(--sep-strong); box-shadow: none; }
.inset-fields .field-input:last-child { border-bottom: 0; }
.invite { margin-top: 12px; }
.invite > summary { list-style: none; display: inline-flex; margin-bottom: 10px; }
.invite > summary::-webkit-details-marker { display: none; }
.people .segmented, .sheet-people .segmented { margin-bottom: 16px; }
.cmd-block {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 14px;
  padding: 8px 8px 8px 14px;
  border-radius: 10px;
  background: var(--cell);
  font-size: 13px;
}
.cmd-block code { flex: 1; min-width: 0; white-space: pre-wrap; word-break: break-all; line-height: 1.45; }
.handoff .inset-list { margin-bottom: 4px; }
.steps { display: flex; flex-direction: column; gap: 14px; margin: 0; padding-left: 1.3em; font-size: 14px; }
.steps .cmd-block { margin: 8px 0 0; }

/* ------------------------------------------------------------------ login */
.login-wrap { display: grid; place-items: center; width: 100%; min-height: 100vh; min-height: 100dvh; padding: 24px; }
.login-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: min(340px, 100%);
  text-align: center;
  animation: fadeIn .5s var(--ease);
  --logo-halo: var(--wallpaper);
}
.login-logo { width: 64px; height: 64px; }
.login-logo svg { width: 100%; height: 100%; }
.login-title { margin: 2px 0 10px; font: 500 28px/1.2 var(--font-display); letter-spacing: -.012em; }
.login-fields {
  width: 100%;
  overflow: hidden;
  border: .5px solid var(--sep-strong);
  border-radius: 11px;
  background: var(--cell);
  transition: box-shadow .15s, border-color .15s;
}
.login-fields:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint); }
.login-input {
  display: block;
  width: 100%;
  height: 44px;
  padding: 0 14px;
  border: 0;
  outline: none;
  background: transparent;
  font-size: 15px;
  color: var(--label);
}
.login-input + .login-input { border-top: .5px solid var(--sep-strong); }
.login-input::placeholder { color: var(--label-3); }
.login-card .btn-block { margin-top: 4px; }
.login-hint { margin: 6px 0 0; font-size: 12.5px; color: var(--label-2); }

/* ------------------------------------------------------------------ search tokens, people, sort */
.search-tokens { display: contents; }
.search-token {
  display: inline-flex; align-items: center; gap: 5px;
  flex-shrink: 0;
  max-width: 55%;
  height: 24px;
  padding: 0 3px 0 3px;
  border-radius: 12px;
  background: var(--row-active);
  color: var(--label);
  font-size: 13px; font-weight: 600;
  animation: pop .22s var(--spring);
}
.search-token .token-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.token-x {
  display: grid; place-items: center;
  width: 18px; height: 18px;
  border: 0; border-radius: 50%;
  background: var(--fill-3); color: var(--label-2);
  cursor: pointer; flex-shrink: 0;
}
.token-x .icon { width: 9px; height: 9px; }
.token-x:hover { background: var(--accent); color: var(--on-accent); }
.search-field.has-token { padding-left: 7px; }

.sort-btn { width: 28px; height: 28px; flex-shrink: 0; background: none; color: var(--label-2); }
.sort-btn:hover, .sort-btn[aria-expanded="true"] { background: var(--fill); color: var(--label); }
.sort-btn.custom { color: var(--accent); background: var(--accent-tint); }
.sort-btn .icon { width: 16px; height: 16px; }

.person-row {
  display: flex; align-items: center; gap: 11px;
  width: 100%;
  min-height: 50px;
  padding: 7px 12px 7px 14px;
  border: 0; border-radius: var(--radius);
  background: none;
  text-align: left;
  cursor: pointer;
  transition: background-color .12s;
}
.person-row:hover, .person-row:focus-visible { background: var(--fill-2); }
.person-row:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--accent-ring); }
.person-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.person-name { font-size: 14px; font-weight: 600; }
.person-sub { font-size: 12.5px; color: var(--label-2); }
.person-go { display: inline-flex; color: var(--label-3); }
.person-go .icon { width: 13px; height: 13px; }
.sb-people .sb-rows { padding-bottom: 4px; border-bottom: .5px solid var(--sep); margin-bottom: 4px; }
.row:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--accent-ring); }

.sb-person-head { display: flex; align-items: center; gap: 12px; padding: 10px 14px 4px; animation: fadeIn .25s var(--ease); }
.sb-person-name { font: 500 19px/1.2 var(--font-display); }
.sb-person-sub { font-size: 12.5px; color: var(--label-2); }
.row-follow { display: inline-flex; color: var(--label-3); flex-shrink: 0; align-self: center; }
.row-follow.on { color: var(--accent); }
.row-follow .icon { width: 12px; height: 12px; }

/* ------------------------------------------------------------------ switch */
.switch {
  position: relative;
  width: 44px; height: 26px;
  flex-shrink: 0;
  padding: 0;
  border: 0; border-radius: 13px;
  background: var(--fill-3);
  cursor: pointer;
  transition: background-color .2s var(--ease);
}
.switch.on { background: var(--accent); }
.switch-knob {
  position: absolute; top: 2px; left: 2px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--seg-on);
  box-shadow: var(--shadow-seg);
  transition: transform .22s var(--spring);
}
.switch.on .switch-knob { transform: translateX(18px); }
:root[data-theme="dark"] .switch.on .switch-knob { background: var(--on-accent); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .switch.on .switch-knob { background: var(--on-accent); } }
.follow-opt .row-main { cursor: pointer; }
.follow-opt .row-title { white-space: normal; }
.follow-opt .row-sub { margin-top: 1px; line-height: 1.35; }
.sheet-combine .inset-row .live-dot { margin-left: -4px; }

/* ------------------------------------------------------------------ follow (live combined sessions) */
.control-pill.follow { padding-left: 10px; gap: 7px; }
.follow-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--teal); box-shadow: inset 0 0 0 1px var(--teal-edge); animation: pulse 2s ease-in-out infinite; flex-shrink: 0; }
.stack-xs .avatar { box-shadow: 0 0 0 1.5px var(--bg); }
.stack-xs .avatar + .avatar { margin-left: -5px; }
.s-following { flex-shrink: 0; color: var(--label-2); }

.update-card {
  max-width: 64ch;
  margin: 2px 0;
  padding: 10px 14px 12px;
  border-radius: var(--radius);
  background: var(--update-bg);
  border: .5px solid var(--sep);
  border-left: 3px solid var(--update-edge);
}
.update-head {
  display: flex; align-items: center; gap: 7px;
  margin-bottom: 4px;
  font-size: 12.5px;
  color: var(--label-2);
  min-width: 0;
}
.update-title { font-weight: 600; color: var(--label); white-space: nowrap; }
.update-src {
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--label-2); text-decoration: none;
}
a.update-src:hover { color: var(--link); text-decoration: underline; }
.update-src::before { content: "·"; margin-right: 7px; color: var(--label-3); }
.update-card .md { font-size: 14px; line-height: 1.55; }
.update-card .md ul { margin-bottom: .4em; }
.seed-caption { display: flex; align-items: center; justify-content: center; gap: 6px; }
.seed-caption .icon { width: 13px; height: 13px; }

/* ------------------------------------------------------------------ motion */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%, 100% { box-shadow: inset 0 0 0 1px var(--teal-edge), 0 0 0 0 var(--live-glow); } 50% { box-shadow: inset 0 0 0 1px var(--teal-edge), 0 0 0 4px transparent; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeOut { to { opacity: 0; } }
@keyframes enter { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: scale(.85); } to { opacity: 1; transform: none; } }
@keyframes rise { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes slideUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes sheetIn { from { opacity: 0; transform: translateY(14px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes sheetOut { to { opacity: 0; transform: scale(.97); } }
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: none; } }
@keyframes sheetDown { to { transform: translateY(100%); } }
@keyframes menuIn { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: none; } }
@keyframes menuOut { to { opacity: 0; } }
@keyframes toastIn { from { opacity: 0; transform: translateY(-14px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-8px) scale(.97); } }
@keyframes highlight { 0%, 30% { background: var(--mark-soft); box-shadow: 0 0 0 8px var(--mark-soft); } 100% { background: transparent; box-shadow: 0 0 0 8px transparent; } }

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

/* ------------------------------------------------------------------ phone */
@media (max-width: 760px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .app.show-detail .sidebar { display: none; }
  .app:not(.show-detail) .detail { display: none; }
  .sidebar { border-right: 0; background: var(--bg); -webkit-backdrop-filter: none; backdrop-filter: none; --logo-halo: var(--bg); }
  .avatar-second { box-shadow: 0 0 0 2px var(--bg); }
  .sb-top { padding: calc(8px + env(safe-area-inset-top)) 16px 6px; }
  .org-title { font-size: 28px; letter-spacing: -.028em; }
  .sb-titlebar { margin: 6px 0 10px; }
  .sb-list { padding: 0 6px calc(12px + env(safe-area-inset-bottom)); }
  .select-bar { padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
  .back-btn { display: inline-flex; }
  .s-header { padding: calc(6px + env(safe-area-inset-top)) 16px 10px; }
  .s-head-row { flex-wrap: wrap; gap: 10px; }
  .s-head-text { flex-basis: 100%; }
  .back-btn { margin-bottom: 2px; }
  .s-title { font-size: 21px; white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .s-subtitle { flex-wrap: wrap; white-space: normal; row-gap: 0; }
  .s-head-actions { width: 100%; }
  .s-head-actions .more-btn { margin-left: auto; flex-shrink: 0; }
  .s-head-actions .control-pill { min-width: 0; flex: 0 1 auto; }
  .control-pill .pill-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  .control-pill .pill-btn, .control-pill .stack, .control-pill .follow-dot { flex-shrink: 0; }
  .s-thread { padding: 14px 16px 24px; }
  .msg-col { max-width: 84%; }
  .composer-wrap { padding: 8px 12px calc(10px + env(safe-area-inset-bottom)); }
  .toasts { top: calc(8px + env(safe-area-inset-top)); left: 10px; right: 10px; width: auto; }
  .overlay { place-items: end stretch; padding: 0; }
  .overlay-alert { place-items: center; padding: 24px; }
  .sheet { width: 100%; max-height: 92vh; border-radius: 14px 14px 0 0; animation: sheetUp .36s var(--ease); }
  .overlay.leaving .sheet { animation: sheetDown .22s var(--ease) forwards; }
  .sheet-tall { height: 88vh; }
  .sheet-grabber { display: block; width: 36px; height: 5px; margin: 6px auto 0; border-radius: 3px; background: var(--fill-3); }
  .sheet-foot { padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
  .sheet-foot .btn { flex: 1; height: 44px; font-size: 16px; border-radius: 12px; }
  .sheet-alert { width: min(300px, 100%); border-radius: 14px; animation: sheetIn .3s var(--spring); }
  .overlay.leaving .sheet-alert { animation: sheetOut .2s var(--ease) forwards; }
  .sheet-alert .sheet-foot .btn { height: 34px; font-size: 14px; }
  .sheet-alert .sheet-grabber { display: none; }
}
.sidebar.selecting .unread-dot { display: none; }

/* ------------------------------------------------------------------ team workspace (AgentOrg cluster) */
.team { display: flex; flex-direction: column; min-height: 0; height: 100%; }
.team-header { flex-shrink: 0; }
/* The team is now a single full-width pane (the section tree lives inline in the sidebar). */
.team-nav-icon { display: inline-flex; width: 26px; height: 26px; flex-shrink: 0; align-items: center; justify-content: center; color: var(--label-2); }
.team-nav-icon .icon { width: 17px; height: 17px; }
.team-badge {
  flex-shrink: 0; padding: 1px 7px; border-radius: 9px; font-size: 11px; font-weight: 600;
  background: var(--accent-tint); color: var(--accent);
}
.team-dot { flex-shrink: 0; width: 8px; height: 8px; border-radius: 50%; background: var(--label-3); }
.team-dot.d-live, .team-dot.d-busy { background: var(--teal); box-shadow: inset 0 0 0 1px var(--teal-edge); }
.team-dot.d-waiting { background: var(--orange); }
.team-dot.d-idle { background: var(--label-3); }
.team-dot.d-ended { background: none; box-shadow: inset 0 0 0 1.5px var(--label-3); }

.team-main { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.team-pane-head {
  display: flex; align-items: center; gap: 9px; flex-shrink: 0;
  padding: 11px 24px; border-bottom: .5px solid var(--sep);
}
.team-pane-title { font: 500 17px/1.2 var(--font-display); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.team-pane-spacer { flex: 1; }
.team-toggle { flex-shrink: 0; }
.team-main .s-body { flex: 1; }
.team-scroll { height: 100%; }

/* Current to-do list (latest TodoWrite) for the selected agent — a compact checklist above the transcript. */
.todos-slot:empty { display: none; }
.todos {
  flex-shrink: 0; margin: 12px 24px 0; padding: 9px 13px;
  border: .5px solid var(--sep); border-radius: var(--radius); background: var(--fill-2);
}
.todos-head { display: flex; align-items: center; gap: 7px; margin-bottom: 7px; color: var(--label-2); }
.todos-head .icon { width: 14px; height: 14px; }
.todos-title { font: 500 12.5px/1 var(--font-display); letter-spacing: .01em; }
.todos-count { margin-left: auto; font-size: 12px; color: var(--label-3); font-variant-numeric: tabular-nums; }
.todos-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.todo { display: flex; align-items: flex-start; gap: 8px; font-size: 13.5px; line-height: 1.4; color: var(--label); }
.todo-mark { flex-shrink: 0; width: 15px; text-align: center; color: var(--label-3); line-height: 1.45; }
.todo-in_progress .todo-mark { color: var(--orange); }
.todo-completed .todo-mark { color: var(--teal); }
.todo-in_progress .todo-text { font-weight: 500; }
.todo-completed .todo-text { color: var(--label-3); text-decoration: line-through; }

/* Channel view: each post is a card — square avatar, a name/role/time header row, the markdown body,
   and a reactions row when present. Human vs agent authors differ by the name's accent colour. */
.team-channel { display: flex; flex-direction: column; gap: 10px; padding: 16px 0; }
.chan-hash { font: 500 18px/1 var(--font-display); color: var(--label-3); }
.chan-card {
  display: flex; gap: 11px;
  padding: 11px 13px; border: .5px solid var(--sep); border-radius: var(--radius); background: var(--card);
}
.chan-col { flex: 1; min-width: 0; }
.chan-meta { display: flex; align-items: baseline; gap: 8px; margin-bottom: 2px; }
.chan-author { font-weight: 600; font-size: 14px; }
.chan-author.is-agent { color: var(--agent); }
.chan-author.is-human { color: var(--human); }
.chan-role { font-size: 12px; color: var(--label-3); }
.chan-time { margin-left: auto; font-size: 12px; color: var(--label-3); flex-shrink: 0; }
.chan-body { font-size: 14px; line-height: 1.5; }
.chan-reactions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chan-react {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 1px 8px; border: .5px solid var(--sep-strong); border-radius: 11px;
  background: var(--fill-2); font-size: 12px; color: var(--label-2);
}
.chan-react-count { font-variant-numeric: tabular-nums; }

.team-activity { display: flex; flex-direction: column; gap: 1px; }
.act-row {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 7px 8px; border: 0; border-radius: 8px; background: none; color: inherit; font: inherit; cursor: pointer;
}
@media (hover: hover) { .act-row:hover { background: var(--fill-2); } }
.act-main { flex: 1; min-width: 0; display: flex; gap: 8px; align-items: baseline; overflow: hidden; }
.act-who { font-weight: 600; font-size: 13px; flex-shrink: 0; }
.act-where { font-size: 12px; color: var(--accent); flex-shrink: 0; }
.act-snippet { font-size: 13px; color: var(--label-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.act-time { font-size: 12px; color: var(--label-3); flex-shrink: 0; }

.team-info { max-width: 420px; margin: 0 auto; padding: 48px 24px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 7px; }
.team-info-name { font: 500 20px/1.2 var(--font-display); }
.team-info-sub { font-size: 13px; color: var(--label-2); }
.team-info-row { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--label-2); margin-top: 6px; }
.team-info-note { font-size: 13px; color: var(--label-3); margin-top: 12px; }

@media (max-width: 760px) {
  .team-pane-head { padding: 10px 16px; }
}

/* ---- human vs agent: one teal glyph for agents, one warm glyph for people (heads.kind) ---- */
.kind-glyph { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; width: 15px; height: 15px; }
.kind-glyph .icon, .kind-glyph svg { width: 15px; height: 15px; }
.kind-glyph.is-agent { color: var(--agent); }
.kind-glyph.is-human { color: var(--human); }
.kind-tag {
  display: inline-flex; align-items: center; gap: 4px; margin-top: 2px;
  font-size: 12px; font-weight: 600; padding: 2px 9px 2px 7px; border-radius: 9px;
}
.kind-tag .icon { width: 13px; height: 13px; }
.kind-tag.is-agent { background: var(--agent-tint); color: var(--agent); }
.kind-tag.is-human { background: var(--human-tint); color: var(--human); }
/* a thin kind-coloured ring on avatars so the color cue carries to the face itself */
.avatar.kind-agent { box-shadow: 0 0 0 1.5px var(--bg), 0 0 0 3px var(--agent-tint); }
.avatar.kind-human { box-shadow: 0 0 0 1.5px var(--bg), 0 0 0 3px var(--human-tint); }
/* Square avatar (rounded corners) — the Avalon team view uses these for channel cards + agent rows. */
.avatar.sq { border-radius: 7px; }
.avatar.sq.avatar-sm { border-radius: 6px; }

/* ---- sidebar: team-focus layout (Avalon desktop) — Sessions / Channels / Agents / More ---- */
/* A collapsible Sessions switcher heads the team-focus sidebar; Channels and Agents follow below. */
.sb-sec-head {
  display: flex; align-items: center; gap: 6px; width: 100%;
  margin: 14px 10px 2px 14px; padding: 2px 2px;
  border: 0; background: none; cursor: pointer; font: inherit; color: var(--label-2);
}
@media (hover: hover) { .sb-sec-head:hover { color: var(--label); } }
.sb-sec-chev { display: inline-flex; color: var(--label-3); transition: transform .15s var(--ease); }
.sb-sec-chev .icon { width: 13px; height: 13px; }
.sb-sec-head.open .sb-sec-chev { transform: rotate(90deg); }
.sb-sec-label { font-size: 12px; font-weight: 600; letter-spacing: .02em; }
.sb-sec-count { font-size: 11px; color: var(--label-3); font-variant-numeric: tabular-nums; }
.sb-nav-rows { display: flex; flex-direction: column; gap: 1px; }
.sb-chan-row { gap: 6px; }
.sb-chan-hash { width: 16px; flex-shrink: 0; text-align: center; font-weight: 600; color: var(--label-3); }
.sb-chan-row.active .sb-chan-hash { color: var(--label); }
.sb-agent-row { gap: 9px; align-items: center; }
.sb-agent-row .avatar { --size: 24px; }
.sb-agent-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
.sb-agent-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-agent-role { font-size: 11px; color: var(--label-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.sb-tree-empty { padding: 3px 14px; font-size: 12.5px; color: var(--label-3); }
.sb-tree-row {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 5px 9px; border-radius: 8px; color: inherit; text-decoration: none;
  font-size: 13.5px; cursor: pointer; transition: background-color .12s;
}
@media (hover: hover) { .sb-tree-row:hover { background: var(--fill-2); } }
.sb-tree-row.active { background: var(--row-active); color: var(--label); font-weight: 600; }
.sb-tree-row:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--accent-ring); }
.sb-tree-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-tree-row .team-nav-icon { width: 22px; height: 22px; }
.sb-tree-row .team-nav-icon .icon { width: 16px; height: 16px; }
.sb-tree-row .team-badge { padding: 0 6px; font-size: 10px; }

.field-textarea { height: auto; min-height: 96px; padding: 10px 12px; line-height: 1.45; resize: vertical; }

/* ---- team Strategy tab: the CEO's strategic plan + the shared work board (reserved .braid/ docs) ---- */
.strat-wrap { max-width: 760px; margin: 0 auto; padding: 18px 20px 48px; display: flex; flex-direction: column; gap: 28px; }
.strat-sec { display: flex; flex-direction: column; gap: 10px; }
.strat-head { display: flex; align-items: baseline; gap: 10px; }
.strat-sec-title { font: 600 13px/1 var(--font-display); letter-spacing: .03em; text-transform: uppercase; color: var(--label-3); }
.strat-unreviewed { font-size: 12px; color: var(--accent); }
.strat-list, .wb-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.strat-item { padding: 12px 14px; border: 1px solid var(--sep-strong); border-radius: 10px; background: var(--fill-2); }
.strat-item-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.strat-item-title { font: 500 15px/1.3 var(--font-display); flex: 1; min-width: 0; }
.strat-item-desc { margin: 6px 0 0; font-size: 13.5px; line-height: 1.45; color: var(--label-2); }
/* priority + status chips — shared pill, tinted by token */
.strat-chip {
  display: inline-flex; align-items: center; flex-shrink: 0;
  font-size: 11px; font-weight: 600; letter-spacing: .01em; text-transform: capitalize;
  padding: 2px 9px; border-radius: 9px; background: var(--fill-3); color: var(--label-2);
}
.strat-chip.prio-now { background: var(--agent-tint); color: var(--agent); }
.strat-chip.prio-next { background: var(--orange-tint); color: var(--orange-text); }
.strat-chip.st-active { background: var(--agent-tint); color: var(--agent); }
.strat-chip.st-done { background: var(--fill-3); color: var(--label-3); }
.strat-chip.st-dropped { color: var(--label-3); text-decoration: line-through; }
.wb-group { display: flex; flex-direction: column; gap: 6px; }
.wb-group + .wb-group { margin-top: 14px; }
.wb-group-title { font: 600 12.5px/1 var(--font-display); color: var(--label-2); }
.wb-item { display: flex; align-items: center; gap: 9px; padding: 7px 10px; border-radius: 8px; background: var(--fill-2); font-size: 14px; }
.wb-mark { flex-shrink: 0; width: 15px; text-align: center; color: var(--label-3); }
.wb-in_progress .wb-mark { color: var(--orange); }
.wb-done .wb-mark { color: var(--teal); }
.wb-text { flex: 1; min-width: 0; }
.wb-done .wb-text { color: var(--label-3); text-decoration: line-through; }
.wb-assignees { display: inline-flex; flex-shrink: 0; }
.wb-ava {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; margin-left: -5px; border-radius: 50%;
  background: var(--fill-3); color: var(--label-2); font-size: 9px; font-weight: 700;
  box-shadow: 0 0 0 1.5px var(--bg);
}
.wb-ava:first-child { margin-left: 0; }

/* tool-permission approval tray (approval-mode teams) */
.team-approvals-slot:empty { display: none; }
.team-approvals {
  margin: 12px 24px 0; padding: 12px 14px; border-radius: var(--radius);
  border: 1px solid var(--warn, #b4690e); background: var(--warn-fill, rgba(180,105,14,.10));
}
.team-approvals-head { display: flex; flex-direction: column; gap: 2px; margin-bottom: 8px; }
.team-approvals-title { font-weight: 600; }
.team-approvals-sub { font-size: 12px; opacity: .7; }
.team-approvals-list { display: flex; flex-direction: column; gap: 8px; }
.approval-card {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px 10px; border: .5px solid var(--sep); border-radius: var(--radius); background: var(--fill-2);
}
.approval-info { display: flex; align-items: center; gap: 8px; min-width: 0; flex-wrap: wrap; }
.approval-tool { font-weight: 600; }
.approval-where { font-size: 12px; opacity: .7; }
.approval-args { font-size: 12px; opacity: .85; overflow: hidden; text-overflow: ellipsis; max-width: 48ch; white-space: nowrap; }
.approval-actions { display: flex; gap: 6px; flex-shrink: 0; }
.field-switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

/* team session picker + sections */
.sb-session-picker .sb-session-select {
  box-sizing: border-box; width: 100%; max-width: 100%; margin: 2px 0 4px; padding: 7px 28px 7px 10px;
  font: inherit; font-size: 13px; color: var(--label);
  background-color: var(--fill-2); border: 1px solid var(--sep); border-radius: 8px;
  cursor: pointer; appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center;
}
.sb-session-picker .sb-session-select:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--accent-ring); }
.sb-team-sections { margin-top: 2px; }
.sb-team-sections .sb-section { margin-top: 4px; }


/* agent portraits (desktop app) */
.avatar.portrait-avatar { overflow: hidden; padding: 0; }
.avatar.portrait-avatar > svg.agent-portrait { width: 100%; height: 100%; display: block; }
.avatar.ceo-avatar > svg.agent-portrait { width: 64%; height: 64%; margin: auto; }
.avatar-sm .portrait-fine, .avatar-xs .portrait-fine { display: none; }
.avatar-sm .agent-portrait, .avatar-xs .agent-portrait { stroke-width: 3.8; }


/* elegant multi-select (left pane) */
/* Rows stay a single horizontal line (avatar + text), never stacking into tall blocks. */
.sb-list .row { flex-flow: row nowrap; align-items: center; }
.sb-list .row.hit { align-items: flex-start; }

/* Select mode: compact rows + a small checkbox, not fat full-width buttons. */
.sidebar.selecting .row { min-height: 48px; padding: 6px 12px; gap: 10px; }
.sidebar.selecting .row .row-text { flex: 1 1 auto; min-width: 0; }
.sidebar.selecting .row .row-team-ind,
.sidebar.selecting .row .avatar-pair,
.sidebar.selecting .check-circle { flex-shrink: 0; }
.sidebar.selecting .check-circle { width: 18px; height: 18px; border-width: 1.5px; }
.sidebar.selecting .check-circle .icon { width: 11px; height: 11px; }

/* Selected: a subtle tint + hairline accent ring, instead of a heavy filled block. */
.row.checked:not(.active) { background: var(--accent-tint); box-shadow: inset 0 0 0 1px var(--accent); }

/* Toolbar wraps instead of pushing the Select button off the edge at narrow widths. */
.sb-toolbar { flex-wrap: wrap; row-gap: 6px; }


/* session picker v2 */
.sb-session-select { color-scheme: light dark; }
:root[data-theme="light"] .sb-session-select { color-scheme: light; }
:root[data-theme="dark"] .sb-session-select { color-scheme: dark; }
.sb-session-select option, .sb-session-select optgroup { color: var(--label); background-color: var(--surface, var(--bg)); }
.sb-select-row { display: flex; align-items: center; gap: 8px; }
.sb-select-row .sb-session-select { flex: 1 1 auto; min-width: 0; margin: 0; }
.sb-select-row .team-dot { flex: 0 0 auto; }
.sb-show-ended { display: inline-flex; align-items: center; gap: 6px; margin: 7px 2px 2px; font-size: 12px; color: var(--label-2); cursor: pointer; user-select: none; }
.sb-show-ended input { accent-color: var(--accent); margin: 0; }


/* trace steps + agent state */
.trace-step { height: 0; border-top: 1px solid var(--sep); margin: 13px 8px; }
.agent-state { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; padding: 2px 9px; border-radius: 999px; white-space: nowrap; }
.agent-state.is-working { color: var(--accent); background: var(--accent-tint); }
.agent-state.is-waiting { color: var(--label-2); background: var(--fill-2); }
.agent-state.is-ended { color: var(--label-3); background: var(--fill-2); }
.agent-state .state-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.agent-state .mini-spinner { width: 12px; height: 12px; }


/* files viewer + richer markdown */
/* ---- Files tab: a tab strip of docs + a comfortable reading column ---- */
.team-files-layout { display: flex; flex-direction: column; min-height: 0; height: 100%; }
.team-file-scroll { flex: 0 0 auto; overflow-x: auto; overflow-y: hidden; border-bottom: 1px solid var(--sep); }
.team-file-list { display: flex; gap: 4px; padding: 10px 16px; min-width: max-content; }
.team-file-row { display: inline-flex; align-items: center; gap: 7px; padding: 7px 12px; border-radius: 8px; font-size: 13px; color: var(--label-2); background: var(--fill-2); border: 1px solid transparent; white-space: nowrap; cursor: pointer; transition: background .12s, color .12s; }
@media (hover: hover) { .team-file-row:hover { background: var(--fill-3); color: var(--label); } }
.team-file-row.is-active { background: var(--accent-tint); color: var(--label); border-color: var(--accent); font-weight: 600; }
.team-file-icon { display: inline-flex; color: var(--label-3); }
.team-file-icon .icon { width: 15px; height: 15px; }
.team-file-row.is-active .team-file-icon { color: var(--accent); }

.team-file-viewer { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
.team-file-head { display: flex; align-items: baseline; gap: 12px; max-width: 820px; margin: 0 auto; padding: 22px 28px 0; }
.team-file-path { font: 12.5px/1.4 var(--mono); font-weight: 600; color: var(--label-2); word-break: break-all; }
.team-file-time { font-size: 12px; color: var(--label-3); margin-left: auto; flex-shrink: 0; }
.team-file-md { max-width: 820px; margin: 0 auto; padding: 14px 28px 56px; }
.team-file-md.md { font-size: 14.5px; line-height: 1.72; color: var(--label); }

/* ---- richer markdown: headings (h1/h2 were unstyled), tables, images ---- */
.md h1 { font-size: 23px; font-weight: 650; letter-spacing: -.012em; line-height: 1.25; margin: 1.1em 0 .5em; }
.md h2 { font-size: 18.5px; font-weight: 650; line-height: 1.3; margin: 1.4em 0 .55em; padding-bottom: .28em; border-bottom: 1px solid var(--sep); }
.md h1:first-child, .md h2:first-child, .md h3:first-child { margin-top: 0; }
.md table { border-collapse: collapse; width: 100%; margin: 0 0 1em; font-size: 13.5px; }
.md th, .md td { border: 1px solid var(--sep-strong); padding: 7px 10px; text-align: left; vertical-align: top; }
.md th { background: var(--fill-2); font-weight: 600; color: var(--label); }
.md tr:nth-child(even) td, .md tbody tr:nth-child(even) td { background: var(--fill); }
.md img { max-width: 100%; height: auto; border-radius: 8px; }
.team-file-md.md pre.code { border: 1px solid var(--sep); border-radius: 10px; font-size: 12.5px; line-height: 1.6; }


/* files viewer height fix */
.team-file-scroll { height: auto; max-height: 40%; }


/* trace step time + code highlight */
.trace-step.has-time { border-top: 0; display: flex; align-items: center; gap: 8px; margin: 10px 8px; }
.trace-step.has-time::before, .trace-step.has-time::after { content: ""; flex: 1; border-top: 1px solid var(--sep); }
.trace-step-time { font-size: 11px; color: var(--label-3); font-variant-numeric: tabular-nums; flex: 0 0 auto; }
.team-file-md .hl-c { color: var(--label-3); font-style: italic; }
.team-file-md .hl-s { color: #8bc48a; }
.team-file-md .hl-n { color: #d9a05b; }
.team-file-md .hl-k { color: #b588e0; }
.team-file-md .hl-t { color: #5aa6e6; }
:root[data-theme="light"] .team-file-md .hl-s { color: #3c8a3c; }
:root[data-theme="light"] .team-file-md .hl-n { color: #a8601a; }
:root[data-theme="light"] .team-file-md .hl-k { color: #8a22c0; }
:root[data-theme="light"] .team-file-md .hl-t { color: #2060c0; }


/* trace gap (collapsed middle) */
.trace-gap { display: flex; align-items: center; gap: 10px; width: 100%; padding: 12px 8px; margin: 2px 0; background: none; border: 0; cursor: pointer; color: var(--label-2); font-size: 12px; font-weight: 500; }
@media (hover: hover) { .trace-gap:hover { color: var(--label); } }
.trace-gap:hover .trace-gap-line { border-color: var(--label-3); }
.trace-gap-line { flex: 1 1 auto; border-top: 1px dashed var(--sep-strong); }
.trace-gap-label { flex: 0 0 auto; }


/* composer disabled reason */
.composer-disabled { padding: 12px 14px; font-size: 12.5px; color: var(--label-3); text-align: center; border-top: 1px solid var(--sep); }


/* team s-body flex column so the composer is not pushed off-screen */
.team-main .s-body { display: flex; flex-direction: column; min-height: 0; }
.team-main .s-body > .s-scroll { flex: 1 1 auto; height: auto; min-height: 0; }
.team-main .s-body > .composer-wrap { flex: 0 0 auto; }


/* inactive (fired/ended) agents */
.sb-agent-row.agent-inactive { opacity: .45; }
.sb-agent-row.agent-inactive .avatar { filter: grayscale(1); }
@media (hover: hover) { .sb-agent-row.agent-inactive:hover { opacity: .7; } }
.sb-agent-row.agent-inactive.active { opacity: 1; }
.sb-agent-row.agent-inactive.active .avatar { filter: none; }


/* inactive agents toggle */
.sb-inactive-toggle { display: inline-flex; align-items: center; gap: 6px; width: 100%; padding: 6px 10px; margin-top: 2px; background: none; border: 0; cursor: pointer; color: var(--label-3); font-size: 12px; text-align: left; border-radius: 6px; }
@media (hover: hover) { .sb-inactive-toggle:hover { color: var(--label-2); background: var(--fill-2); } }
.sb-inactive-toggle .sb-sec-chev { display: inline-flex; transition: transform .15s var(--ease); }
.sb-inactive-toggle.open .sb-sec-chev { transform: rotate(90deg); }
.sb-inactive-toggle .sb-sec-chev .icon { width: 12px; height: 12px; }


/* per-agent model tag */
.sb-agent-sub { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.sb-agent-model { font-size: 10.5px; color: var(--label-3); font-variant-numeric: tabular-nums; background: var(--fill-2); padding: 0 5px; border-radius: 4px; }
.team-pane-model { font-size: 11px; color: var(--label-2); background: var(--fill-2); padding: 1px 7px; border-radius: 5px; }


/* strategy focus + roadmap */
.focus-sec .focus-cards { display: flex; flex-direction: column; gap: 10px; }
.focus-card { border: 1px solid var(--accent); background: var(--accent-tint); border-radius: 10px; padding: 12px 14px; }
.focus-card-head { display: flex; align-items: center; gap: 10px; }
.focus-card-title { font-size: 15px; font-weight: 650; color: var(--label); flex: 1; min-width: 0; }
.focus-card-desc { margin: 7px 0 0; font-size: 13px; line-height: 1.55; color: var(--label-2); }
.road-bucket { margin-bottom: 12px; }
.road-bucket-label { font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--label-3); margin: 6px 0 4px; }
.road-done { margin-top: 8px; }
.road-done > summary { cursor: pointer; font-size: 12px; color: var(--label-3); padding: 4px 0; }


/* strategy top nav */
.sb-strategy-nav { margin-bottom: 4px; }
.sb-strategy-nav .sb-tree-row { font-weight: 600; }


/* nested tactical under initiatives */
.init-cards { display: flex; flex-direction: column; gap: 8px; }
.init-card { border: 1px solid var(--sep); border-radius: 9px; padding: 10px 12px; }
.init-card .strat-item-desc { margin: 5px 0 0; }
.wb-list.nested { margin: 8px 0 0; padding-left: 2px; border-top: 1px dashed var(--sep); padding-top: 7px; }
.focus-card .wb-list.nested { border-top-color: var(--accent); }


/* agent todo progress + eta */
.todo-group-head { display: flex; align-items: center; gap: 10px; margin-bottom: 5px; }
.todo-group-head .wb-group-title { flex: 1; min-width: 0; }
.todo-progress { font-size: 11.5px; color: var(--label-2); font-variant-numeric: tabular-nums; }
.todo-eta { font-size: 11.5px; color: var(--accent); background: var(--accent-tint); padding: 1px 7px; border-radius: 5px; white-space: nowrap; }
.todo-bar-track { height: 5px; border-radius: 3px; background: var(--fill-2); overflow: hidden; margin-bottom: 7px; }
.todo-bar-fill { height: 100%; background: var(--accent); border-radius: 3px; transition: width .3s var(--ease); }


/* strategy human controls */
.prio-control { display: inline-flex; flex-direction: column; margin-left: auto; gap: 1px; }
.prio-btn { border: 0; background: var(--fill-2); color: var(--label-2); cursor: pointer; font-size: 9px; line-height: 1; padding: 2px 5px; border-radius: 4px; }
@media (hover: hover) { .prio-btn:hover:not(:disabled) { background: var(--accent-tint); color: var(--accent); } }
.prio-btn:disabled { opacity: .3; cursor: default; }
.wb-del { margin-left: 4px; border: 0; background: none; color: var(--label-3); cursor: pointer; font-size: 14px; line-height: 1; padding: 0 4px; border-radius: 4px; }
@media (hover: hover) { .wb-del:hover { color: var(--red, #cf625d); background: var(--fill-2); } }
.strat-ack { border: 1px solid var(--accent); background: var(--accent-tint); color: var(--accent); cursor: pointer; padding: 2px 9px; border-radius: 6px; font-size: 12px; }
@media (hover: hover) { .strat-ack:hover { background: var(--accent); color: var(--on-accent); } }


/* roadmap focus highlight */
.init-card.init-focus { border-color: var(--accent); background: var(--accent-tint); }
.road-bucket-now .road-bucket-label { color: var(--accent); }
.focus-badge { font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--on-accent); background: var(--accent); padding: 1px 6px; border-radius: 4px; margin-right: 2px; }


/* persistent end-notice (stopped badge + last-stop line) */
.row-stopped { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; color: var(--red, #cf625d); background: var(--red-tint, rgba(207,98,93,.12)); padding: 0 6px; border-radius: 4px; margin-left: 4px; white-space: nowrap; }
.last-stop { display: inline-flex; align-items: center; gap: 3px; color: var(--muted, #888); max-width: 100%; min-width: 0; }
.last-stop > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.last-stop svg { width: 11px; height: 11px; flex-shrink: 0; }


/* external (remote Claude) member badge */
.sb-agent-ext, .team-pane-ext { font-size: 10px; font-weight: 600; white-space: nowrap; color: var(--purple-text, #8a5cf6); background: var(--purple-tint, rgba(138,92,246,.14)); padding: 0 6px; border-radius: 4px; }
.sb-agent-ext { margin-left: 4px; }
.team-pane-ext { margin-left: 6px; }


/* driver-disconnected (teammate offline) */
.sb-tree-row.agent-offline { opacity: .72; }
.sb-agent-disc, .team-pane-disc { font-size: 10px; font-weight: 600; white-space: nowrap; color: var(--orange-text, #b4690e); background: var(--orange-tint, rgba(180,105,14,.14)); padding: 0 6px; border-radius: 4px; }
.sb-agent-disc { margin-left: 4px; }
.team-pane-disc { margin-left: 6px; }


/* fix: channel external tag + optimistic send + last-seen */
.chan-ext-tag { font-size: 10px; font-weight: 600; color: var(--orange-text, #b4690e); background: var(--orange-tint, rgba(180,105,14,.14)); padding: 0 6px; border-radius: 4px; }
.chan-optimistic { opacity: .6; }
.chan-sending { font-size: 11px; color: var(--muted, #888); margin-left: 6px; }
.chan-failed { opacity: 1; } .chan-failed .chan-sending { color: var(--red, #cf625d); }
.opt-msg { align-self: flex-end; max-width: 80%; margin: 4px 10px; padding: 6px 10px; border-radius: 10px; background: var(--fill-2, #eee); opacity: .7; }
.opt-failed { opacity: 1; border: 1px solid var(--red, #cf625d); }
.opt-state { display: block; font-size: 10px; color: var(--muted, #888); margin-top: 2px; }
.opt-failed .opt-state { color: var(--red, #cf625d); }
.sb-agent-seen { font-size: 10px; color: var(--muted, #888); }
