/* JITTER-FIX 2026-11-28 (老大 t1482u「我点击内容就会抖动」).
   Loaded LAST. Rules: nothing moves or scales on hover/press; nothing replays its entrance when the
   chat re-renders after a click; no bounce (overshoot) easing; scrollbars never change layout width.
   Motion stays: soft fades + a smooth accordion for the group's topics. */

/* 1. One calm easing everywhere — the old --ease-spring overshot (1.16) and made things wobble. */
:root {
  --ease-spring: cubic-bezier(0.22, 1, 0.36, 1);
}

/* 2. Press / hover never change geometry (also covers the in-chat department sheet). */
.cf-chip:active,
.cf-go:active:not(:disabled) {
  transform: none !important;
}
/* quiet press feedback without movement */
.comm-channel-row:active,
.nav-item:active,
.comm-topic-tab:active,
.comm-list-pane [data-select-topic]:active {
  opacity: 0.88;
}

/* 3. Sidebar rows animate in once (first paint of the chat); re-renders after a click do not replay it. */
[data-comm-mounted] .comm-channel-row {
  animation: none !important;
}

/* 3b. Even that first appearance is a pure fade — rows never slide (later @keyframes with the same name wins). */
@keyframes commRowIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* 4. Switching room / topic: the pane itself never slides or scales; only the messages fade in softly. */
.comm-thread-entering {
  animation: none !important;
}
.comm-thread-entering #comm-message-feed {
  animation: commFeedFade 200ms cubic-bezier(0.22, 1, 0.36, 1) both;
}
.comm-thread-entering .comm-msg-arriving {
  animation: none !important;
}
@keyframes commFeedFade {
  from { opacity: 0.35; }
  to   { opacity: 1; }
}

/* 5. Group topics open/close as a smooth accordion instead of snapping the list by ~240px. */
.comm-subtopics {
  interpolate-size: allow-keywords;
}
.comm-subtopics.is-entering {
  overflow: hidden;
  animation: commSubOpen 240ms cubic-bezier(0.22, 1, 0.36, 1) both;
}
.comm-subtopics.is-leaving {
  overflow: hidden;
  pointer-events: none;
  animation: commSubClose 220ms cubic-bezier(0.4, 0, 0.2, 1) both;
}
@keyframes commSubOpen {
  from { height: 0; opacity: 0; margin-top: 0; margin-bottom: 0; }
  to   { height: auto; opacity: 1; }
}
@keyframes commSubClose {
  from { height: auto; opacity: 1; }
  to   { height: 0; opacity: 0; margin-top: 0; margin-bottom: 0; }
}

/* 6. Scrollbars appearing/disappearing must not shift content sideways. */
html,
.comm-list-pane,
#comm-channel-list,
#comm-message-feed,
.comm-context-pane,
.workspace-main {
  scrollbar-gutter: stable;
}

@media (prefers-reduced-motion: reduce) {
  .comm-thread-entering #comm-message-feed,
  .comm-subtopics.is-entering,
  .comm-subtopics.is-leaving { animation: none !important; }
  .comm-subtopics.is-leaving { display: none; }
}
[data-reduce-motion="true"] .comm-thread-entering #comm-message-feed,
[data-reduce-motion="true"] .comm-subtopics.is-entering { animation: none !important; }
[data-reduce-motion="true"] .comm-subtopics.is-leaving { display: none; }

/* SEND-ROUTE-FIX (t1551u 会抖动): the page never scrolls; only inner panes do, and their scrollbar space is reserved
   up front so switching between an empty topic and a long one never changes any content width (no sideways jump). */
html, body { overflow: hidden !important; }
#comm-message-feed, #comm-channel-list { scrollbar-gutter: stable; }
@supports not (scrollbar-gutter: stable) {
  #comm-message-feed, #comm-channel-list { overflow-y: scroll; }
}
