@layer components {
  .chat-nav {
    display: flex; flex-direction: column; gap: 1px;
    margin-bottom: 6px; padding-bottom: 8px; border-bottom: 1px solid var(--sidebar-border);
  }

  .sidebar-search { position: relative; margin: 0; padding: 2px 0 8px; }
  .sidebar-search svg { position: absolute; left: 9px; top: 10px; color: var(--muted-foreground); pointer-events: none; }
  /* Centred on the 30px field (2px padding + 15px) whatever the glyph metrics: the ⌘ glyph sits high in a line box. */
  .sidebar-search-hotkey {
    position: absolute; top: 17px; right: 6px; transform: translateY(-50%);
    display: inline-flex; align-items: center; height: 20px; padding: 0 6px; box-sizing: border-box;
    border: 1px solid var(--border); border-radius: 6px; background: var(--background); color: var(--muted-foreground);
    font: inherit; font-size: 13px; line-height: 1; pointer-events: none;
  }
  .sidebar-search .input { height: 30px; padding-left: 28px; padding-right: 48px; font-size: var(--text-body); background: var(--background); }

  .chat-nav .sidebar-section { display: flex; align-items: center; justify-content: space-between; gap: 6px; }

  /* Accordion sections: a heading button folds its list; the container's data-collapsed drives the CSS. */
  .nav-section-head { display: flex; align-items: center; gap: 6px; padding: 14px 8px 4px; }
  .nav-section-title, .nav-section-toggle {
    color: var(--muted-foreground); font-size: var(--text-meta); font-weight: 600; line-height: 20px;
    letter-spacing: 0.02em; text-transform: uppercase;
  }
  .nav-section-toggle {
    display: flex; align-items: center; gap: 6px; flex: 1; min-width: 0; padding: 0; border: 0; border-radius: 6px;
    background: transparent; font-family: inherit; text-align: start; cursor: pointer;
  }
  .nav-section-toggle svg { width: 12px; height: 12px; flex: none; }
  .nav-section-toggle[aria-expanded="true"] svg { transform: rotate(90deg); }
  .nav-section-title { flex: 1; }
  .nav-section-menu { display: flex; }
  /* Settings stay open on the phone's Vous screen: nothing folds there. */
  @media (max-width: 1099px) {
    .sidebar-search-hotkey { display: none; }
    .app-shell[data-screen="you"] .nav-section[data-collapsed] > .sidebar-list > li { display: list-item; }
    .app-shell[data-screen="you"] .nav-section-toggle { pointer-events: none; }
    .app-shell[data-screen="you"] .nav-section-toggle svg { display: none; }
  }
  .sidebar-add {
    padding: 0; border: 0; background: transparent; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px;
    margin: -4px -4px -4px 0; border-radius: 6px; color: var(--muted-foreground); text-decoration: none;
  }
  @media (hover: hover) { .sidebar-add:is(:hover, :active) { background: var(--sidebar-accent); color: var(--sidebar-foreground); } }

  .sidebar-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 1px; }
  .sidebar-label { min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  .sidebar-count {
    flex: none; margin-left: auto; min-width: 18px; padding: 0 5px; border-radius: 999px; text-align: center;
    font-size: 13px; font-weight: 700; line-height: 18px; font-variant-numeric: tabular-nums;
    background: var(--jx-accent); color: var(--jx-accent-fg);
  }
  .sidebar-count[hidden] { display: none; }
  /* Mentions wait for an answer: amber, like every pending item. */
  .sidebar-count--wait { background: var(--jx-wait); }
  /* A person's unread count is amber, its text on the page colour. */
  .sidebar-entry .sidebar-count { background: var(--jx-wait); color: var(--background); font-weight: 500; }

  .sidebar-dot { display: none; flex: none; margin: 0 6px 0 auto; width: 6px; height: 6px; border-radius: 999px; background: var(--jx-accent); }
  .sidebar-entry.is-unread .sidebar-label { font-weight: 600; }
  .sidebar-entry.is-unread:not(:has(.sidebar-count)) .sidebar-dot { display: block; }
  .sidebar-entry:not(.is-unread) .sidebar-unread-text { display: none; }
  .sidebar-link--muted { color: var(--muted-foreground); }

  /* Rows: a 24 px marker at 8 px, the label at 40; children of a project or an agent start at 40. */
  .nav-row-head { width: 100%; border: 0; background: transparent; font-family: inherit; font-size: inherit; text-align: start; cursor: pointer; }
  .nav-group-row, .sidebar-entry { position: relative; }
  .sidebar-link > svg:first-child:not(:last-child) { margin-inline: 5px; }
  .type-icon > .presence { display: inline-flex; flex: none; align-items: center; justify-content: center; width: 24px; height: 24px; }
  /* The kind of conversation, as in the header: « # », a padlock, the person's avatar or the agent's tinted tile. */
  .type-icon { display: inline-flex; flex: none; align-items: center; justify-content: center; width: 24px; height: 24px; color: var(--muted-foreground); }
  .type-icon svg { width: 16px; height: 16px; }
  .type-icon--agent {
    border-radius: 6px; color: var(--agent-color);
    background: light-dark(color-mix(in oklch, var(--agent-color) 12%, transparent), color-mix(in oklch, var(--agent-color) 16%, transparent));
  }
  .type-icon--agent svg { width: 14px; height: 14px; }
  /* A stack is wider than the 24px slot: let it size itself and stay out of the label's way. */
  .type-icon--group { width: auto; min-width: 24px; }
  .sidebar-meta { display: block; flex: 0 1 auto; min-width: 0; max-width: 45%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--text-meta); font-weight: 400; color: var(--muted-foreground); }
  .sidebar-link:has(.sidebar-meta) .sidebar-label { flex: 0 1 auto; }
  .type-icon--webhook svg { width: auto; height: auto; }
  .sidebar-link > .type-icon--channel { margin-inline: 1px; }
  .nav-agent-icon, .nav-project-icon { flex: none; align-items: center; justify-content: center; width: 24px; height: 24px; }
  .nav-project-icon { display: inline-flex; }
  .nav-agent-icon {
    border-radius: 6px;
    background: light-dark(color-mix(in oklch, var(--agent-color) 12%, transparent), color-mix(in oklch, var(--agent-color) 16%, transparent));
  }
  /* A guest's project is a title, not a link. */
  .sidebar-link.nav-project-title { cursor: default; }
  .sidebar-link.nav-project-title:hover { background: transparent; }
  .nav-project > .nav-row-head .sidebar-label { font-weight: 500; }
  /* Open folder while the project shows its channels, closed when folded; accent when it holds the current page. */
  .nav-project:not([data-collapsed]) > .nav-row-head .nav-project-icon > svg:first-child,
  .nav-project[data-collapsed] > .nav-row-head .nav-project-icon > svg:last-child { display: none; }
  .nav-project:has([aria-current="page"]) > .nav-row-head .nav-project-icon { color: var(--jx-accent); }
  /* In a channel of the project the whole block is tinted and its label stands out. */
  .nav-project:has(> .sidebar-list [aria-current="page"]) { border-radius: 8px; background: var(--sidebar-group-current); }
  .nav-project:has(> .sidebar-list [aria-current="page"]) > .nav-row-head .sidebar-label {
    color: var(--sidebar-accent-foreground); font-weight: 600;
  }
  .nav-section[data-collapsed] .nav-project { background: none; }
  /* Chevrons sit at the right, pointing down once the row is open. */
  .nav-row-head > svg:last-child, .sidebar-link--muted > svg:last-child { width: 12px; height: 12px; margin: 0; }
  .nav-row-head[aria-expanded="true"] > svg:last-child { transform: rotate(90deg); }
  /* A project's head is a link to its page: the chevron is its own button at the row's end. */
  .nav-project > .nav-row-head { padding-right: 28px; }
  .nav-row-chevron {
    position: absolute; top: 0; right: 0; z-index: 1; display: flex; align-items: center; justify-content: center;
    width: 28px; height: 32px; padding: 0; border: 0; background: transparent; color: var(--muted-foreground); cursor: pointer;
  }
  .nav-row-chevron > svg { width: 12px; height: 12px; }
  .nav-row-chevron[aria-expanded="true"] > svg { transform: rotate(90deg); }
  .nav-group-row > .sidebar-list { padding: 0; }
  :is(.nav-project, .nav-agent) > .sidebar-list > li > .sidebar-link { padding-left: 40px; }
  .nav-agent > .sidebar-list > li > .sidebar-link { min-height: 28px; gap: 6px; }
  .nav-agent > .sidebar-list > li > .sidebar-link > svg { margin: 0; }
  .nav-agent > .sidebar-list > li > .sidebar-link[aria-current="page"]::before { top: 6px; bottom: 6px; }
  .nav-agent-new, .sidebar-link--muted { color: var(--muted-foreground); }
  .nav-more-count { display: none; }
  .nav-privates-all { min-height: 28px; gap: 6px; color: var(--muted-foreground); }
  .nav-privates-all .sidebar-label { flex: none; }
  .nav-privates-all svg { margin: 0; }
  .nav-privates-count { font-size: 12px; font-variant-numeric: tabular-nums; } /* design */
  .sidebar-context { display: none; flex: 0 10 auto; min-width: 0; max-width: 60%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; font-weight: 400; color: var(--muted-foreground); } /* design */
  #sidebar_favorites .sidebar-context { display: block; }
  .sidebar-link:has(.sidebar-context) .sidebar-label { flex: 0 1 auto; }

  /* Hover and focus: a muted row with ☆ and ⋯ (and + for an agent) at the right, in the place of the unread marks. */
  .sidebar-link:focus-visible:not([aria-current="page"]),
  .sidebar-link:not([aria-current="page"]):has(+ .nav-row-actions:focus-within) { background: var(--muted); }
  @media (hover: hover) {
    .sidebar-link:is(:hover, :active):not([aria-current="page"]),
    .sidebar-link:not([aria-current="page"]):has(+ .nav-row-actions:hover) { background: var(--muted); }
  }
  .nav-row-actions { position: absolute; top: 9px; right: 8px; z-index: 1; display: none; align-items: center; gap: 8px; height: 14px; }
  .nav-group-row > .nav-row-actions { right: 28px; }
  .sidebar-link:focus-visible + .nav-row-actions, .nav-row-actions:focus-within { display: flex; }
  /* Shown, ☆ and ⋯ take the row's end: the label stops short of them instead of running under. */
  .sidebar-link:focus-visible:has(+ .nav-row-actions), .sidebar-link:has(+ .nav-row-actions:focus-within) { padding-right: 52px; }
  /* A tap hovers too, and iOS Safari drops the click of a tap whose hover reveals content: a real hover only (and its
     press). */
  @media (hover: hover) {
    .sidebar-link:is(:hover, :active) + .nav-row-actions, .nav-row-actions:hover { display: flex; }
    .sidebar-link:is(:hover, :active):has(+ .nav-row-actions), .sidebar-link:has(+ .nav-row-actions:hover) { padding-right: 52px; }
  }
  .nav-row-action {
    display: inline-flex; align-items: center; justify-content: center; width: 14px; height: 14px; padding: 0; border: 0; border-radius: 4px;
    background: transparent; color: var(--muted-foreground); cursor: pointer;
  }
  .nav-row-action[hidden] { display: none; }
  .nav-row-action:is(:hover, :focus-visible) { color: var(--foreground); }
  .sidebar-link:has(+ .nav-row-actions:is(:hover, :focus-within) > :not([hidden])) :is(.sidebar-count, .sidebar-dot) { visibility: hidden; }
  /* A touch screen has no hover: the project's ⋯ stays in reach. */
  @media (hover: none) { .nav-project > .nav-row-actions { display: flex; } }
  /* Favoris stays out of sight while it holds no row (and nothing is being dragged over it). */
  [data-nav-group="favorites"]:not(:has(#sidebar_favorites > li)):not(:has(.nav-drop-zone:not([hidden]))) { display: none; }

  /* An agent row is unread for the unread conversations it does not list; folded, its listed ones count too. Its
     head then says so: dot, hidden text, semi-bold name. */
  .nav-agent:is(.is-unread, :is([data-collapsed], .nav-section[data-collapsed] *):has(.is-unread)) > .nav-row-head {
    --nav-head-mark: block; --nav-head-weight: 600;
  }
  .nav-agent > .nav-row-head :is(.sidebar-dot, .nav-agent-unread-text) { display: var(--nav-head-mark, none); }
  .nav-agent > .nav-row-head .sidebar-label { font-weight: var(--nav-head-weight); }
  /* An agent in a folded section has its children hidden: its chevron shows the folded look. */
  .nav-section[data-collapsed] .nav-agent > .nav-row-head > svg:last-child { transform: none; }

  /* Folded: a project shows its unread and open channels only, an agent only its open conversation. */
  .nav-project[data-collapsed] > .sidebar-list > li:not(.is-unread, :has([aria-current="page"])) { display: none; }
  .nav-agent[data-collapsed] > .sidebar-list > li:not(:has([aria-current="page"])) { display: none; }

  /* A folded section keeps its unread rows and the open one; projects flatten, their name in context. */
  .nav-section[data-collapsed] > :not(.nav-section-head, .sidebar-list) { display: none; }
  .nav-section[data-collapsed] > .sidebar-list > li:not(.sidebar-entry, .nav-agent, .nav-project, :has([aria-current="page"])) { display: none; }
  .nav-section[data-collapsed] > .sidebar-list > .sidebar-entry:not(.is-unread, :has([aria-current="page"])) { display: none; }
  .nav-section[data-collapsed] > .sidebar-list > :is(.nav-project, .nav-agent):not(.is-unread, :has(.is-unread, [aria-current="page"])) { display: none; }
  .nav-section[data-collapsed] > .sidebar-list > .nav-project > :is(.nav-row-head, .nav-row-actions, .nav-row-chevron) { display: none; }
  .nav-section[data-collapsed] .nav-project > .sidebar-list > li:not(.is-unread, :has([aria-current="page"])) { display: none; }
  .nav-section[data-collapsed] .nav-project > .sidebar-list > li > .sidebar-link { padding-left: 8px; }
  .nav-section[data-collapsed] .sidebar-context { display: block; }
  .nav-section[data-collapsed] .nav-agent > .sidebar-list > li:not(:has([aria-current="page"])) { display: none; }

  /* The eight latest private conversations, plus the unread ones and the open one. */
  #sidebar_privates > li:nth-child(n+9):not(.is-unread, :has(.is-unread), :has([aria-current="page"])) { display: none; }
  /* The link leads to what the list hides: under nine rows, nothing is hidden. */
  #sidebar_privates:not(:has(> li:nth-child(9))) + .nav-privates-all { display: none; }

  /* Mobile shell: Accueil shows the search, the places and the private conversations, Vous the workspace's
     settings and the sign-out; rows a finger hits, the page scrolling rather than the list. */
  @media (max-width: 1099px) {
    .app-shell[data-screen] :is(.sidebar-head, .sidebar-foot, .nav-group) { display: none; }
    .app-shell[data-screen="home"] :is([data-nav-group="search"], [data-nav-group="places"], [data-nav-group="privates"]),
    .app-shell[data-screen="you"] [data-nav-group="settings"] { display: contents; }
    .app-shell[data-screen="you"] .chat-nav { display: none; }
    .app-shell[data-screen="you"] .sidebar-foot {
      display: flex; margin-top: 12px; padding: 8px var(--gutter); border-top: 1px solid var(--sidebar-border);
    }
    /* Vous opens on the person: the foot keeps the sign-out alone, a full row with its word. */
    .app-shell[data-screen="you"] .sidebar-me { display: none; }
    .app-shell[data-screen="you"] .sidebar-foot form { flex: 1; }
    .app-shell[data-screen="you"] .sidebar-sign-out {
      width: 100%; min-height: calc(var(--tap) + 2px); padding-inline: 14px; justify-content: center; gap: 12px;
      border-radius: var(--radius-lg); background: var(--card); font-size: var(--text-body);
    }
    /* The settings group is named after the workspace, its rows are the Vous rows': a card, a chevron at the end. */
    .app-shell[data-screen="you"] .nav-space-title {
      display: block; margin: 12px 8px 0; padding: 0 4px 8px; font-size: var(--text-meta); font-weight: 600;
      color: var(--muted-foreground);
    }
    .app-shell[data-screen="you"] [data-nav-group="settings"] .nav-section-head { display: none; }
    .app-shell[data-screen="you"] #sidebar_settings {
      gap: 0; margin: 0 8px; overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius-lg);
      background: var(--card);
    }
    .app-shell[data-screen="you"] #sidebar_settings li + li { border-top: 1px solid var(--border); }
    .app-shell[data-screen="you"] #sidebar_settings .sidebar-link {
      min-height: calc(var(--tap) + 2px); padding-inline: 14px; gap: 12px; border-radius: 0;
    }
    .app-shell[data-screen="you"] #sidebar_settings .sidebar-link:focus-visible { outline-offset: -2px; }
    .app-shell[data-screen="you"] #sidebar_settings .sidebar-link > svg:first-child { width: 16px; height: 16px; margin: 0; }
    .app-shell[data-screen="you"] #sidebar_settings .sidebar-link > span:not(.sidebar-link-chevron) { flex: 1; }
    .app-shell[data-screen="you"] .sidebar-link-chevron { display: flex; color: var(--muted-foreground); }
    .app-shell[data-screen] .sidebar-nav { flex: none; overflow: visible; padding: 0 calc(var(--gutter) - 8px); }
    .app-shell[data-screen] .chat-nav { margin-bottom: 0; border-bottom: 0; }
    .app-shell[data-screen] .chat-nav .sidebar-link { min-height: var(--tap); }
    /* The list's own 1 px gap, so a fractional row edge never hands a finger's corner to the next row. */
    .app-shell[data-screen] :is(.nav-section, .nav-group-row) > .sidebar-list { margin-top: 1px; }
    .app-shell[data-screen] .nav-row-actions { top: calc((var(--tap) - 14px) / 2); }
    .app-shell[data-screen] .nav-more-count { display: inline; }
    /* The rows keep 8 px inside their own box: the search takes it outside, in line with the title and headings. */
    .app-shell[data-screen] .sidebar-search { padding-inline: 8px; }
    .app-shell[data-screen] .sidebar-search .input { height: var(--tap); }
    .app-shell[data-screen] .sidebar-search svg { left: 17px; top: calc(2px + (var(--tap) - 14px) / 2); }
    /* A heading as tall as a finger, its text centred: the « + » touch area stays off the first row. */
    .app-shell[data-screen] .chat-nav :is(.sidebar-section, .nav-section-head) { min-height: var(--tap); padding-block: 0; }
  }

  /* A locked newcomer sees why the rest is missing, not a greyed-out list. */
  .sidebar-locked {
    display: flex; gap: 10px; margin: 12px 8px 0; padding: 10px 12px;
    font-size: var(--text-meta); color: var(--muted-foreground);
    border: 1px dashed var(--border); border-radius: var(--radius-md);
  }
  .sidebar-locked svg { flex: none; margin-top: 2px; }
  .sidebar-locked-title { margin: 0; font-weight: 600; color: var(--foreground); }
  .sidebar-locked-text { margin: 2px 0 0; }

  /* The navigation's parts, grouped for the mobile shell's screens; no box of their own, so nothing moves here. */
  .nav-group { display: contents; }
  /* Named after the workspace on the phone's Vous screen only. */
  .nav-space-title, .sidebar-link-chevron { display: none; }

  /* Touch screens with the desktop sidebar: an enlarged touch area at its edge must not make it scroll sideways. */
  @media (pointer: coarse) and (min-width: 1100px) {
    .sidebar-nav { overflow-x: hidden; }
    /* Headings as tall as a finger, so the « + » touch areas of two stacked headings never overlap. */
    .chat-nav :is(.sidebar-section, .nav-section-head) { min-height: var(--tap); padding-block: 0; }
    .nav-section > .sidebar-list { margin-top: 1px; }
  }

  /* « Non lus »: a row under Mentions; pressed, the sidebar keeps the rows left to read, the one on screen (it would
     vanish under the reader) and the groups holding them. */
  .nav-unread-filter { width: 100%; border: 0; background: transparent; font: inherit; text-align: start; cursor: pointer; }
  .nav-unread-filter[aria-pressed="true"] { background: var(--sidebar-accent); color: var(--sidebar-accent-foreground); font-weight: 600; }
  .nav-unread-filter[aria-pressed="true"] svg { color: var(--jx-accent); }
  .nav-unread-count { margin-left: auto; color: var(--muted-foreground); font-size: var(--text-meta); font-variant-numeric: tabular-nums; }
  .nav-unread-count[hidden], .nav-unread-chip-count[hidden] { display: none; }
  .chat-nav.is-unread-only :is(
    [data-sidebar-entry]:not(.is-unread, :has([aria-current="page"])),
    :is(.nav-project, .nav-agent):not(.is-unread, :has(.is-unread, [aria-current="page"])),
    .nav-section:not(:has(.is-unread, [aria-current="page"])),
    .nav-privates-all, .sidebar-link--muted, .nav-agent-new, .nav-drop-zone
  ) { display: none; }
  .nav-unread-empty { display: none; margin: 8px; color: var(--muted-foreground); font-size: var(--text-meta); }
  .chat-nav.is-unread-only:not(.has-unread) .nav-unread-empty { display: block; }

  /* Only the phone's Accueil makes the lists a box of their own (chat_nav_mobile.css). */
  .chat-nav-lists, .chat-nav-lists-body { display: contents; }

  /* The phone's Accueil opens the directory from its first row; the desktop has the sidebar link. */
  .nav-people-entry {
    display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 0 4px; border-radius: var(--radius-md);
    color: var(--foreground); font-size: calc(var(--text-body) * 16 / 15); text-decoration: none;
  }
  .nav-people-entry > svg:last-child { margin-left: auto; color: var(--muted-foreground); }
  .nav-people-entry:focus-visible { outline: 2px solid var(--jx-accent); outline-offset: 2px; box-shadow: 0 0 0 5px var(--ring); }
  @media (min-width: 1100px) { .nav-people-entry { display: none; } }
  .chat-nav.is-unread-only .nav-people-entry { display: none; }

  /* The phone's Accueil shows the same filter as two chips; the desktop has its row. */
  .nav-unread-chips { display: none; }
  .nav-unread-chips .list-tab { font: inherit; font-size: 14px; font-weight: 500; cursor: pointer; }
  .nav-unread-chips .list-tab[aria-pressed="true"] { border-color: transparent; background: var(--foreground); color: var(--background); }
  .nav-unread-chip-count::before { content: "·"; margin-right: 6px; }
  @media (max-width: 1099px) {
    .app-shell[data-screen="home"] .chat-nav .nav-unread-chips { display: flex; gap: 8px; padding: 4px 8px 8px; }
  }

  /* The recap conversations under the Orchestrateur: a folded sub-row (caret, label, count) and rows one step in. */
  .nav-recaps > .nav-row-head { min-height: 28px; gap: 6px; padding-left: 40px; color: var(--muted-foreground); }
  .nav-recaps > .nav-row-head[aria-expanded="true"] > svg:first-child { transform: rotate(90deg); }
  .nav-recaps-count { flex: none; font-size: 13px; font-variant-numeric: tabular-nums; }
  .nav-recaps[data-collapsed] > .sidebar-list { display: none; }
  .nav-recaps > .sidebar-list > li > .sidebar-link { min-height: 28px; gap: 6px; padding-left: 62px; }
  .nav-recaps > .nav-row-head :is(.sidebar-dot, .nav-recaps-unread-text) { display: none; }
  .nav-recaps.is-unread[data-collapsed] > .nav-row-head .sidebar-dot { display: block; }
  .nav-recaps.is-unread[data-collapsed] > .nav-row-head .nav-recaps-unread-text { display: inline; }
  .nav-recaps-all { width: 100%; border: 0; background: transparent; font-family: inherit; font-size: inherit; text-align: start; cursor: pointer; }
  .recap-list { display: flex; flex-direction: column; gap: 8px; }
  .recap-list-rows { list-style: none; margin: 0; padding: 0; }
}
