.viewer-collaboration {
  position: fixed;
  inset: 0;
  box-sizing: border-box;
  width: min(720px, calc(100vw - 24px));
  max-height: min(84dvh, 760px);
  margin: auto;
  padding: 0;
  overflow-y: auto;
  border: 1px solid #c9d7e1;
  border-radius: 12px;
  background: #f5f9fc;
  box-shadow: 0 24px 70px rgba(11, 31, 58, .28);
  color: #123044;
  font: inherit;
}

.viewer-collaboration:not([open]) { display: none; }
.viewer-collaboration::backdrop { background: rgba(11, 31, 58, .46); }
.viewer-collaboration__heading {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .65rem .85rem;
  background: #f5f9fc;
}
.viewer-collaboration__heading strong { display: flex; align-items: center; gap: .5rem; }
.viewer-collaboration button {
  border: 1px solid #7b9eb1;
  border-radius: 7px;
  padding: .38rem .68rem;
  background: #fff;
  color: #0d3a50;
  font: inherit;
  cursor: pointer;
}
.viewer-collaboration button:hover { background: #e5f2f7; }
.viewer-collaboration button:focus-visible { outline: 3px solid #397db3; outline-offset: 2px; }
.viewer-collaboration button:disabled { cursor: not-allowed; opacity: .55; }
.viewer-collaboration__panel { padding: 0 .85rem .8rem; border-top: 1px solid #dbe5eb; }
.viewer-collaboration__panel[hidden],
.viewer-collaboration__active[hidden],
.viewer-collaboration__setup[hidden],
.viewer-collaboration__row[hidden],
.viewer-collaboration__members[hidden],
.viewer-collaboration__conflicts[hidden] { display: none; }
.viewer-collaboration__panel p { margin: .65rem 0; font-size: .9rem; }
.viewer-collaboration__setup, .viewer-collaboration__row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .55rem;
  margin: .55rem 0;
}
.viewer-collaboration__setup small { flex-basis: 100%; }
.viewer-collaboration label { display: flex; align-items: center; gap: .4rem; font-size: .88rem; }
.viewer-collaboration input, .viewer-collaboration select, .viewer-collaboration textarea {
  border: 1px solid #9cb4c2;
  border-radius: 6px;
  padding: .38rem;
  background: #fff;
  color: #123044;
  font: inherit;
}
.viewer-collaboration__grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 1rem; }
.viewer-collaboration__grid ul, .viewer-collaboration__members ul { list-style: none; margin: .35rem 0 .65rem; padding: 0; }
.viewer-collaboration__grid li, .viewer-collaboration__members li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  padding: .4rem 0;
  border-bottom: 1px solid #dbe5eb;
  font-size: .86rem;
}
.viewer-collaboration__grid li span, .viewer-collaboration__members li span { min-width: 0; overflow-wrap: anywhere; }
.viewer-collaboration__grid li small { color: #476478; }
.viewer-collaboration__status { min-height: 1.2rem; color: #28526a; }
.viewer-collaboration__status.is-error { color: #a22222; }
.viewer-collaboration__conflicts { border: 1px solid #d6a541; border-radius: 8px; padding: .65rem; background: #fff5d7; }
.viewer-collaboration__conflicts p { margin: .2rem 0 .5rem; }

.viewer-chat {
  position: fixed;
  left: 18px;
  bottom: 18px;
  z-index: 1100;
  box-sizing: border-box;
  width: min(370px, calc(100vw - 36px));
  overflow: hidden;
  border: 1px solid #9cb4c2;
  border-radius: 12px 12px 0 0;
  background: #fff;
  box-shadow: 0 12px 34px rgba(11, 31, 58, .24);
  color: #123044;
  font: inherit;
}
.viewer-chat[hidden] { display: none; }
.viewer-chat button { font: inherit; cursor: pointer; }
.viewer-chat button:focus-visible, .viewer-chat textarea:focus-visible, .viewer-chat input:focus-visible { outline: 3px solid #397db3; outline-offset: -3px; }
.viewer-chat button:disabled { cursor: not-allowed; opacity: .55; }
.viewer-chat__header { display: flex; align-items: stretch; background: #123f58; }
.viewer-chat__bar {
  display: flex;
  flex: 1;
  flex-wrap: wrap;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: .6rem;
  width: 100%;
  min-height: 48px;
  padding: .55rem .8rem;
  border: 0;
  background: #123f58;
  color: #fff;
  text-align: left;
}
.viewer-chat__bar:hover { background: #18516d; }
.viewer-chat__invite { flex: 0 0 44px; min-height: 48px; border: 0; border-left: 1px solid #476478; background: transparent; color: #fff; }
.viewer-chat__invite:hover { background: #18516d; }
.viewer-chat__invite[hidden], .viewer-chat__invite-copy[hidden] { display: none; }
.viewer-chat__invite-status { margin: 0; padding: .5rem .8rem; color: #215d7f; font-size: .78rem; overflow-wrap: anywhere; }
.viewer-chat__invite-status:empty { display: none; }
.viewer-chat__invite-status.is-error { color: #a22222; }
.viewer-chat__invite-copy { display: block; padding: 0 .8rem .65rem; font-size: .75rem; }
.viewer-chat__invite-copy input { display: block; box-sizing: border-box; width: 100%; margin-top: .35rem; padding: .45rem; border: 1px solid #9cb4c2; border-radius: 4px; background: #f7fafc; color: #123044; font: inherit; }
.viewer-chat__bar-title, .viewer-chat__bar-right { display: inline-flex; align-items: center; gap: .45rem; }
.viewer-chat__bar-title i { font-size: 1.05rem; }
.viewer-chat__bar-right small { font-size: .73rem; color: #cce8f3; white-space: nowrap; }
.viewer-chat.is-collapsed .viewer-chat__bar-right i { transform: rotate(180deg); }
.viewer-chat.is-collapsed .viewer-chat__body { display: none; }
.viewer-chat__body { background: #fff; }
.viewer-chat__context {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .7rem;
  padding: .5rem .8rem;
  border-bottom: 1px solid #dbe5eb;
  background: #edf5f9;
  color: #476478;
  font-size: .78rem;
}
.viewer-chat__context button { border: 0; background: transparent; color: #215d7f; text-decoration: underline; white-space: nowrap; }
.viewer-chat__context button:hover { color: #123f58; }
.viewer-chat__messages {
  display: flex;
  flex-direction: column;
  gap: .6rem;
  height: min(260px, 36dvh);
  min-height: 150px;
  margin: 0;
  padding: .8rem;
  overflow-y: auto;
  list-style: none;
  background: #f7fafc;
}
.viewer-chat__message { max-width: 88%; align-self: flex-start; }
.viewer-chat__message.is-own { align-self: flex-end; }
.viewer-chat__meta { display: flex; gap: .55rem; margin: 0 0 .2rem .2rem; color: #536d7c; font-size: .72rem; }
.viewer-chat__message.is-own .viewer-chat__meta { justify-content: flex-end; margin-right: .2rem; }
.viewer-chat__bubble {
  padding: .55rem .7rem;
  border: 1px solid #d9e5ec;
  border-radius: 9px 9px 9px 2px;
  background: #fff;
  color: #123044;
  font-size: .85rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}
.viewer-chat__message.is-own .viewer-chat__bubble {
  border-color: #215d7f;
  border-radius: 9px 9px 2px 9px;
  background: #215d7f;
  color: #fff;
}
.viewer-chat__empty { margin: auto; color: #536d7c; font-size: .85rem; text-align: center; }
.viewer-chat__compose { padding: .65rem .8rem .7rem; border-top: 1px solid #dbe5eb; }
.viewer-chat__label { display: block; margin-bottom: .35rem; font-size: .8rem; font-weight: 600; }
.viewer-chat__compose textarea { box-sizing: border-box; width: 100%; min-height: 64px; padding: .45rem; border: 1px solid #9cb4c2; border-radius: 6px; background: #fff; color: #123044; font: inherit; font-size: .84rem; resize: vertical; }
.viewer-chat__compose-bottom { display: flex; justify-content: space-between; align-items: center; gap: .6rem; margin-top: .4rem; }
.viewer-chat__compose-bottom small { color: #536d7c; font-size: .73rem; }
.viewer-chat__compose-bottom button { border: 1px solid #215d7f; border-radius: 6px; padding: .38rem .7rem; background: #215d7f; color: #fff; }
.viewer-chat__compose-bottom button:hover { background: #164764; }
.viewer-chat__feedback { min-height: 1em; margin: 0; padding: 0 .8rem .35rem; color: #a22222; font-size: .72rem; }
.viewer-chat__feedback:empty { display: none; }
.viewer-chat__prototype-note { margin: 0; padding: .35rem .8rem .55rem; color: #536d7c; font-size: .72rem; }

.viewer-cursor-prototype {
  position: fixed;
  inset: 0;
  z-index: 1000;
  pointer-events: none;
}
.viewer-cursor-prototype__marker {
  position: absolute;
  top: 0;
  left: 0;
  display: flex;
  align-items: flex-start;
  gap: 2px;
  white-space: nowrap;
  will-change: transform;
}
.viewer-cursor-prototype__marker[hidden] { display: none; }
.viewer-cursor-prototype__marker svg {
  width: 23px;
  height: 30px;
  flex: none;
  fill: var(--cursor-color);
  stroke: #fff;
  stroke-width: 1.8px;
  stroke-linejoin: round;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .42));
}
.viewer-cursor-prototype__marker span {
  margin-top: 14px;
  padding: .22rem .45rem;
  border: 1px solid #fff;
  border-radius: 5px;
  background: var(--cursor-color);
  box-shadow: 0 2px 6px rgba(0, 0, 0, .28);
  color: #fff;
  font: 700 12px/1.2 "Manrope", "Segoe UI", Arial, sans-serif;
}

@media (max-width: 700px) {
  .viewer-collaboration { width: calc(100vw - 12px); max-height: 92dvh; }
  .viewer-collaboration__grid { grid-template-columns: 1fr; }
  .viewer-chat { left: 8px; bottom: 8px; width: calc(100vw - 16px); }
  .viewer-chat__message { max-width: 94%; }
}
