/* UniDoc collaboration: the same edge-mounted drawer geometry as "查看 .udoc". */
#collab-panel {
  position: fixed;
  z-index: 24020;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(420px, 100vw);
  max-height: none;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  color: #202124;
  background: #fff;
  border: 0;
  border-left: 1px solid #dce3ef;
  border-radius: 0;
  box-shadow: -4px 0 20px rgba(32, 45, 68, .22);
  font-family: "Google Sans", "Segoe UI", "Microsoft YaHei", sans-serif;
  transform: translateX(0);
  visibility: visible;
  transition: transform .25s ease, visibility 0s linear 0s;
  will-change: transform;
}

#collab-panel.hidden {
  display: flex;
  transform: translateX(100%);
  visibility: hidden;
  pointer-events: none;
  transition: transform .25s ease, visibility 0s linear .25s;
}

#collab-panel > header {
  min-height: 70px;
  display: grid;
  grid-template-columns: 42px 1fr 36px;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  border-bottom: 1px solid #e8eaed;
}

.collab-title-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  color: #0b57d0;
  background: #e8f0fe;
  border-radius: 14px;
  font-size: 25px;
  font-weight: 700;
}

#collab-panel header > span:nth-child(2) { display: flex; flex-direction: column; min-width: 0; }
#collab-panel header b { font-size: 18px; line-height: 1.35; }
#collab-panel header small { overflow: hidden; color: #747775; text-overflow: ellipsis; white-space: nowrap; }
#btn-close-collab {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 18px;
  color: #5f6368;
  background: transparent;
  font-size: 18px;
  cursor: pointer;
}
#btn-close-collab:hover { background: #f1f3f4; }

.collab-hero {
  display: grid;
  grid-template-columns: 16px 1fr;
  gap: 12px;
  align-items: start;
  margin: 16px;
  padding: 16px;
  background: #f6f9fe;
  border: 1px solid #d7e3f7;
  border-radius: 18px;
}
.collab-hero > div { display: flex; flex-direction: column; gap: 4px; }
.collab-hero b { font-size: 15px; }
.collab-hero small { color: #5f6368; line-height: 1.5; }
.collab-state-dot {
  width: 11px;
  height: 11px;
  margin-top: 5px;
  background: #9aa0a6;
  border-radius: 50%;
  box-shadow: 0 0 0 4px rgba(154, 160, 166, .14);
}
#collab-panel[data-state="connected"] .collab-state-dot { background: #188038; box-shadow: 0 0 0 4px rgba(24, 128, 56, .14); }
#collab-panel[data-state="connecting"] .collab-state-dot { background: #f9ab00; box-shadow: 0 0 0 4px rgba(249, 171, 0, .16); }
#collab-panel[data-state="error"] .collab-state-dot { background: #d93025; box-shadow: 0 0 0 4px rgba(217, 48, 37, .14); }

.collab-members-section {
  flex: 1 1 auto;
  min-height: 118px;
  padding: 0 16px 10px;
  overflow: auto;
  overscroll-behavior: contain;
}
.collab-section-title { display: flex; justify-content: space-between; color: #5f6368; font-size: 13px; font-weight: 600; }
#collab-member-count { min-width: 28px; padding: 2px 8px; text-align: center; background: #f1f3f4; border-radius: 999px; }
.collab-members { display: grid; gap: 8px; margin-top: 10px; }
.collab-members p { margin: 10px 2px; color: #80868b; font-size: 13px; }
.collab-member {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 14px;
}
.collab-member:hover { background: #f8fafd; }
.collab-avatar {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  color: #fff;
  border-radius: 50%;
  font-weight: 700;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.35);
}
.collab-avatar img,
.collab-author-avatar img {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: inherit;
  object-fit: cover;
}
.collab-member-main { min-width: 0; }
.collab-member-main b, .collab-member-main small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.collab-member-main b { font-size: 14px; }
.collab-member-main small { color: #747775; font-size: 12px; }
.collab-member-live { width: 8px; height: 8px; background: #188038; border-radius: 50%; }

.collab-attribution-controls { padding: 0 16px 14px; }
.collab-attribution-controls label {
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 12px;
  background: #f8fafd;
  border: 1px solid #e2e8f3;
  border-radius: 16px;
  cursor: pointer;
}
.collab-attribution-controls label > span { min-width: 0; display: grid; gap: 2px; }
.collab-attribution-controls b { font-size: 14px; }
.collab-attribution-controls small { color: #747775; font-size: 12px; line-height: 1.4; }
#collab-author-toggle {
  position: relative;
  width: 40px;
  height: 24px;
  flex: 0 0 auto;
  margin: 0;
  appearance: none;
  background: #bdc1c6;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  transition: background .16s ease;
}
#collab-author-toggle::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(32, 33, 36, .28);
  transition: transform .16s ease;
}
#collab-author-toggle:checked { background: #0b57d0; }
#collab-author-toggle:checked::after { transform: translateX(16px); }
#collab-author-toggle:focus-visible { outline: 2px solid #0b57d0; outline-offset: 3px; }

.collab-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 14px 16px; border-top: 1px solid #eef0f3; }
.collab-actions button {
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid #c7d2e4;
  border-radius: 20px;
  color: #0b57d0;
  background: #fff;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.collab-actions button:hover { background: #f3f7fd; }
.collab-actions button.primary { color: #fff; background: #0b57d0; border-color: #0b57d0; }
.collab-actions button.primary:hover { background: #0842a0; }
#collab-panel[data-state="connected"] #btn-collab-connect { color: #b3261e; background: #fff; border-color: #f0c6c2; }

#collab-panel > footer { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 16px 16px; }
#collab-panel > footer span { padding: 4px 8px; color: #5f6368; background: #f1f3f4; border-radius: 999px; font-size: 11px; }

#btn-collab[data-state="connected"] { color: #137333; background: rgba(232, 245, 233, .92); }
#btn-collab[data-state="connecting"] { color: #8a5200; background: rgba(254, 247, 224, .95); }
#btn-collab[data-state="error"] { color: #b3261e; background: rgba(252, 232, 230, .95); }

#collab-cursors { position: fixed; inset: 0; z-index: 24010; pointer-events: none; }
.collab-remote-cursor {
  position: fixed;
  width: 2px;
  height: 25px;
  border-radius: 2px;
  transform: translate(-1px, 0);
  opacity: .95;
  transition: left .09s linear, top .09s linear;
}
.collab-remote-cursor > span {
  position: absolute;
  left: 0;
  bottom: 100%;
  max-width: 150px;
  padding: 2px 7px;
  overflow: hidden;
  color: #fff;
  border-radius: 7px 7px 7px 0;
  font: 600 11px/18px "Segoe UI", sans-serif;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#collab-author-popover {
  position: fixed;
  z-index: 24012;
  min-width: 210px;
  max-width: min(300px, calc(100vw - 20px));
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  color: #202124;
  background: rgba(255, 255, 255, .98);
  border: 1px solid #dbe4f1;
  border-radius: 14px;
  box-shadow: 0 8px 24px rgba(35, 48, 72, .18);
  pointer-events: none;
  transition: opacity .12s ease, transform .12s ease;
}
#collab-author-popover.hidden { display: none; }
.collab-author-avatar {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  overflow: hidden;
  color: #fff;
  border-radius: 50%;
  font-weight: 700;
}
.collab-author-copy { min-width: 0; display: grid; gap: 2px; }
.collab-author-copy b,
.collab-author-copy small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.collab-author-copy b { font-size: 13px; }
.collab-author-copy small { color: #747775; font-size: 11px; }

@media print {
  #collab-panel,
  #collab-cursors,
  #collab-author-popover { display: none !important; }
}

@media (max-width: 720px) {
  #collab-panel { right: 0; width: 100vw; border-radius: 0; }
  .collab-actions { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  #collab-panel,
  #collab-panel.hidden { transition: none; }
}
