/* Collaborative tests are an isolated UI layer. Every selector is prefixed. */
.qg-collab-launcher {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.qg-collab-launcher:disabled { opacity: .55; cursor: not-allowed; }

.qg-collab-dialog {
  width: min(620px, calc(100vw - 28px));
  max-height: min(760px, calc(100dvh - 28px));
  margin: auto;
  padding: 0;
  overflow: hidden;
  border: 1px solid rgba(22, 63, 43, .18);
  border-radius: 24px;
  background: #fffdf8;
  color: var(--ink, #102218);
  box-shadow: 0 34px 90px rgba(13, 35, 23, .28);
}
.qg-collab-dialog::backdrop {
  background: rgba(10, 24, 16, .55);
  backdrop-filter: blur(5px);
}
.qg-collab-dialog[open] { animation: qg-collab-dialog-in .24s ease-out; }
@keyframes qg-collab-dialog-in {
  from { opacity: 0; transform: translateY(12px) scale(.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.qg-collab-dialog-card {
  display: grid;
  gap: 18px;
  max-height: min(760px, calc(100dvh - 28px));
  padding: 24px;
  overflow: auto;
}
.qg-collab-dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}
.qg-collab-dialog-head h2 { margin: 3px 0 5px; font-size: clamp(25px, 4vw, 34px); }
.qg-collab-dialog-head p { max-width: 500px; margin: 0; color: var(--muted, #6e776f); line-height: 1.5; }
.qg-collab-kicker {
  display: inline-flex;
  color: var(--brand-dark, #16472f);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: .05em;
  text-transform: uppercase;
}
.qg-collab-dialog-close {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border: 1px solid rgba(22, 63, 43, .16);
  border-radius: 50%;
  background: #fff;
  color: #1d2c23;
  font-size: 25px;
  line-height: 1;
  cursor: pointer;
}
.qg-collab-dialog-close:hover { background: #eef5ec; }
.qg-collab-search-label { display: grid; gap: 7px; font-weight: 800; }
.qg-collab-search-label input { width: 100%; }
.qg-collab-search-results {
  display: grid;
  max-height: 238px;
  overflow: auto;
  border: 1px solid rgba(22, 63, 43, .14);
  border-radius: 16px;
  background: #fff;
}
.qg-collab-result-note { margin: 0; padding: 18px; color: var(--muted, #6e776f); text-align: center; }
.qg-collab-result-note.is-error { color: #a52c35; }
.qg-collab-user-result {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 11px 13px;
  border: 0;
  border-bottom: 1px solid rgba(22, 63, 43, .09);
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}
.qg-collab-user-result:last-child { border-bottom: 0; }
.qg-collab-user-result:hover { background: #f1f7ef; }
.qg-collab-user-result strong,
.qg-collab-user-result small { display: block; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qg-collab-user-result small { margin-top: 2px; color: var(--muted, #6e776f); }
.qg-collab-avatar {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 13px;
  background: #e8f1e4;
  color: #16472f;
  font-weight: 900;
}
.qg-collab-add-label { color: #16472f; font-size: 13px; font-weight: 850; }
.qg-collab-selected { display: flex; flex-wrap: wrap; gap: 8px; min-height: 32px; }
.qg-collab-selected-empty { color: var(--muted, #6e776f); font-size: 14px; }
.qg-collab-person-chip {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  max-width: 100%;
  padding: 7px 8px 7px 11px;
  border: 1px solid #d6e3d1;
  border-radius: 13px;
  background: #eff6ec;
}
.qg-collab-person-chip span { min-width: 0; }
.qg-collab-person-chip strong,
.qg-collab-person-chip small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qg-collab-person-chip small { color: var(--muted, #6e776f); font-size: 11px; }
.qg-collab-person-chip button {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 50%;
  background: rgba(22, 63, 43, .09);
  cursor: pointer;
}
.qg-collab-help { margin: -7px 0 0; color: var(--muted, #6e776f); font-size: 13px; }
.qg-collab-message { display: none; margin: 0; padding: 11px 13px; border-radius: 12px; font-weight: 750; }
.qg-collab-message.is-visible { display: block; }
.qg-collab-message.is-working { background: #f5f1dd; color: #704e14; }
.qg-collab-message.is-success { background: #e8f5e8; color: #16512f; }
.qg-collab-message.is-error { background: #fff0f0; color: #9b2630; }
.qg-collab-limit-link { display: inline-flex; margin-left: 10px; color: inherit; text-decoration: underline; }
.qg-collab-dialog-actions { display: flex; justify-content: flex-end; gap: 10px; }

/* Session room */
.qg-collab-page { --qg-collab-border: rgba(22, 63, 43, .15); }
.qg-collab-shell { width: min(1180px, calc(100% - 30px)); margin: 38px auto 70px; }
.qg-collab-room-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 24px;
  padding: clamp(24px, 4vw, 42px);
  border: 1px solid var(--qg-collab-border);
  border-radius: 28px;
  background: linear-gradient(135deg, #fffdf8 0%, #edf5e9 100%);
  box-shadow: 0 18px 48px rgba(24, 55, 36, .09);
}
.qg-collab-room-hero h1 { max-width: 820px; margin: 7px 0 8px; font-size: clamp(31px, 5vw, 54px); line-height: 1.05; }
.qg-collab-room-hero p { margin: 0; color: var(--muted, #6e776f); }
.qg-collab-status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 6px 12px;
  border-radius: 999px;
  background: #e6f2e3;
  color: #16472f;
  font-size: 13px;
  font-weight: 850;
}
.qg-collab-status-pill[data-status="expired"],
.qg-collab-status-pill[data-status="cancelled"] { background: #eee; color: #687069; }
.qg-collab-status-pill[data-status="completed"] { background: #e8f0ff; color: #264b83; }
.qg-collab-room-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(280px, .8fr); gap: 20px; margin-top: 20px; }
.qg-collab-panel {
  padding: 24px;
  border: 1px solid var(--qg-collab-border);
  border-radius: 22px;
  background: #fffdf9;
  box-shadow: 0 12px 34px rgba(24, 55, 36, .055);
}
.qg-collab-panel h2 { margin: 0 0 6px; }
.qg-collab-panel > p { color: var(--muted, #6e776f); }
.qg-collab-metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 20px 0; }
.qg-collab-metric { padding: 15px; border: 1px solid var(--qg-collab-border); border-radius: 16px; background: #f8fbf6; }
.qg-collab-metric strong { display: block; font-size: 24px; }
.qg-collab-metric span { color: var(--muted, #6e776f); font-size: 13px; }
.qg-collab-expired-message,
.qg-collab-stage-message { padding: 18px; border-radius: 16px; line-height: 1.55; }
.qg-collab-stage-message { border: 1px dashed #b8cdb0; background: #f1f7ee; color: #294638; }
.qg-collab-expired-message { border: 1px solid #e4c7c7; background: #fff1f1; color: #87252e; }
.qg-collab-member-list { display: grid; gap: 10px; margin-top: 16px; }
.qg-collab-member {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  align-items: center;
  gap: 11px;
  padding: 10px;
  border: 1px solid var(--qg-collab-border);
  border-radius: 14px;
}
.qg-collab-member strong,
.qg-collab-member small { display: block; }
.qg-collab-member small { color: var(--muted, #6e776f); }
.qg-collab-member-status { padding: 4px 8px; border-radius: 999px; background: #f0f2ef; color: #59635c; font-size: 11px; font-weight: 850; }
.qg-collab-member[data-status="active"] .qg-collab-member-status { background: #e5f3e3; color: #16512f; }
.qg-collab-room-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }
.qg-collab-invite-form { display: grid; gap: 12px; margin-top: 16px; }
.qg-collab-inline-results { max-height: 210px; }
.qg-collab-session-message { min-height: 22px; margin-top: 10px; color: var(--muted, #6e776f); }
.qg-collab-session-message.is-error { color: #9b2630; }
.qg-collab-session-message.is-success { color: #16512f; }

/* Dashboard summary */
.qg-collab-dashboard { margin-bottom: 20px; }
.qg-collab-dashboard-head { display: flex; align-items: end; justify-content: space-between; gap: 18px; margin-bottom: 16px; }
.qg-collab-dashboard-head h2 { margin: 0 0 4px; }
.qg-collab-dashboard-head p { margin: 0; color: var(--muted, #6e776f); }
.qg-collab-dashboard-columns { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.qg-collab-dashboard-column { min-width: 0; padding: 15px; border: 1px solid var(--qg-collab-border, rgba(22,63,43,.15)); border-radius: 17px; background: #fafcf8; }
.qg-collab-dashboard-column h3 { margin: 0 0 10px; font-size: 16px; }
.qg-collab-dashboard-item { display: block; padding: 10px 0; border-top: 1px solid rgba(22, 63, 43, .1); color: inherit; }
.qg-collab-dashboard-item:first-of-type { border-top: 0; padding-top: 0; }
.qg-collab-dashboard-item strong,
.qg-collab-dashboard-item small { display: block; }
.qg-collab-dashboard-item small { margin-top: 3px; color: var(--muted, #6e776f); }
.qg-collab-dashboard-empty { margin: 0; color: var(--muted, #6e776f); font-size: 14px; }

@media (max-width: 900px) {
  .qg-collab-room-grid { grid-template-columns: 1fr; }
  .qg-collab-dashboard-columns { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .qg-collab-dialog-card { padding: 18px; }
  .qg-collab-dialog-actions { flex-direction: column-reverse; }
  .qg-collab-dialog-actions .btn { width: 100%; }
  .qg-collab-room-hero { grid-template-columns: 1fr; align-items: start; }
  .qg-collab-metrics { grid-template-columns: 1fr; }
  .qg-collab-user-result { grid-template-columns: 38px minmax(0, 1fr); }
  .qg-collab-add-label { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .qg-collab-dialog[open] { animation: none; }
}

/* Phase 2 — shared JSON player adapter. All rules stay inside the module. */
.qg-collab-player-page .qg-collab-shell {
  width: min(1580px, calc(100% - 30px));
}
.qg-collab-panel-heading,
.qg-collab-player-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}
.qg-collab-panel-heading h2,
.qg-collab-player-head h2 { margin: 4px 0 6px; }
.qg-collab-live-state {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  min-height: 34px;
  padding: 7px 11px;
  border: 1px solid #c9ddc2;
  border-radius: 999px;
  background: #eff7ec;
  color: #185234;
  font-size: 12px;
  font-weight: 850;
  white-space: nowrap;
}
.qg-collab-live-state > span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #2f9360;
  box-shadow: 0 0 0 4px rgba(47, 147, 96, .13);
  animation: qg-collab-live-pulse 2.2s ease-in-out infinite;
}
.qg-collab-live-state[data-status="completed"],
.qg-collab-live-state[data-status="expired"],
.qg-collab-live-state[data-status="cancelled"] {
  border-color: #d8ddd8;
  background: #f3f4f2;
  color: #626c65;
}
.qg-collab-live-state[data-status="completed"] > span,
.qg-collab-live-state[data-status="expired"] > span,
.qg-collab-live-state[data-status="cancelled"] > span {
  background: #8b938d;
  box-shadow: none;
  animation: none;
}
@keyframes qg-collab-live-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(.82); opacity: .68; }
}

.qg-collab-player-panel {
  margin-top: 22px;
  padding: clamp(18px, 2.4vw, 30px);
  border: 1px solid var(--qg-collab-border, rgba(22, 63, 43, .15));
  border-radius: 24px;
  background: #f7fbff;
  box-shadow: 0 16px 42px rgba(24, 55, 36, .065);
}
.qg-collab-player-head { margin-bottom: 14px; }
.qg-collab-player-head > div { min-width: 0; }
.qg-collab-player-head h2 { font-size: clamp(25px, 3.4vw, 38px); }
.qg-collab-player-head p {
  max-width: 850px;
  margin: 0;
  color: var(--muted, #6e776f);
  line-height: 1.5;
}
.qg-collab-individual-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  min-height: 42px;
  padding: 9px 13px;
  border: 1px solid rgba(22, 63, 43, .16);
  border-radius: 13px;
  background: #fff;
  color: #16472f;
  font-size: 13px;
  font-weight: 850;
  text-decoration: none;
}
.qg-collab-individual-link:hover { background: #eef5ec; }
.qg-collab-player-warning {
  margin: 10px 0;
  padding: 11px 13px;
  border: 1px solid #e6d7a6;
  border-radius: 12px;
  background: #fff9e9;
  color: #755719;
  font-size: 13px;
}
.qg-collab-player-message {
  min-height: 22px;
  margin: 8px 0 12px;
  padding: 0 2px;
  color: #637268;
  font-weight: 750;
}
.qg-collab-player-message.is-working { color: #775916; }
.qg-collab-player-message.is-success { color: #17613b; }
.qg-collab-player-message.is-error { color: #a22631; }
.qg-collab-player { min-width: 0; }
.qg-collab-player .qgp-side { top: 92px; }
.qg-collab-player .qgp-side-actions [data-action="reset"],
.qg-collab-player [data-action="edit"] { display: none !important; }

.qg-collab-answer-meta,
.qg-collab-question-availability {
  margin: 16px 0 20px;
  border-radius: 16px;
  animation: qg-collab-shared-answer-in .22s ease-out;
}
.qg-collab-answer-meta {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 13px 15px;
  border: 1px solid;
}
.qg-collab-answer-meta.is-correct {
  border-color: #9cd8b9;
  background: #edf9f2;
  color: #155c39;
}
.qg-collab-answer-meta.is-incorrect {
  border-color: #efb5b5;
  background: #fff3f3;
  color: #8f222b;
}
.qg-collab-answer-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 13px;
  background: rgba(255, 255, 255, .76);
  font-size: 22px;
  font-weight: 950;
}
.qg-collab-answer-meta strong,
.qg-collab-answer-meta small { display: block; }
.qg-collab-answer-meta small {
  margin-top: 3px;
  color: currentColor;
  font-size: 13px;
  line-height: 1.4;
  opacity: .86;
}
.qg-collab-question-availability {
  padding: 12px 14px;
  border: 1px dashed #a9cbe8;
  background: #f2f8ff;
  color: #315774;
  font-size: 14px;
  font-weight: 720;
  line-height: 1.45;
}
.qg-collab-question-availability.is-readonly {
  border-color: #d0d5d1;
  background: #f4f5f3;
  color: #68716b;
}
.qgp-collaborative-readonly .qgp-option:not(.correct):not(.wrong) {
  cursor: not-allowed;
  opacity: .76;
}
.qgp-collaborative-mode .qgp-navbtn.ok,
.qgp-collaborative-mode .qgp-navbtn.bad {
  position: relative;
}
.qgp-collaborative-mode .qgp-navbtn.ok::after,
.qgp-collaborative-mode .qgp-navbtn.bad::after {
  content: "";
  position: absolute;
  top: 6px;
  right: 6px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  opacity: .55;
}
@keyframes qg-collab-shared-answer-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.qg-collab-legacy-note {
  background: #fffdf8;
}
.qg-collab-legacy-note h2 { margin: 6px 0 8px; }
.qg-collab-legacy-note p {
  max-width: 820px;
  color: var(--muted, #6e776f);
  line-height: 1.55;
}

@media (max-width: 1040px) {
  .qg-collab-player .qgp-shell { grid-template-columns: 300px minmax(0, 1fr); gap: 16px; }
  .qg-collab-player .qgp-side { padding: 20px; }
}
@media (max-width: 820px) {
  .qg-collab-player .qgp-shell { grid-template-columns: 1fr; }
  .qg-collab-player .qgp-side {
    position: static;
    max-height: none;
  }
}
@media (max-width: 640px) {
  .qg-collab-panel-heading,
  .qg-collab-player-head { flex-direction: column; }
  .qg-collab-live-state,
  .qg-collab-individual-link { align-self: flex-start; }
  .qg-collab-player-panel { padding: 14px; border-radius: 18px; }
  .qg-collab-answer-meta { grid-template-columns: 34px minmax(0, 1fr); padding: 11px; }
  .qg-collab-answer-icon { width: 34px; height: 34px; border-radius: 10px; font-size: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  .qg-collab-live-state > span,
  .qg-collab-answer-meta,
  .qg-collab-question-availability { animation: none; }
}

/* Phase 3 — read-only adapter for structured legacy HTML quizzes. */
.qg-collab-adapter-stage strong {
  display: block;
  margin-bottom: 4px;
  color: #194f34;
}
.qg-collab-legacy-adapted-page .qg-collab-player-panel {
  background: linear-gradient(180deg, #f8fbff 0%, #f6faf4 100%);
}
.qg-collab-legacy-adapted-page .qgp-context {
  line-height: 1.58;
}
.qg-collab-legacy-adapted-page .qgp-context br + br {
  display: block;
  content: "";
  margin-top: 8px;
}
.qg-collab-legacy-note .qg-collab-player-warning {
  max-width: 920px;
  margin: 14px 0;
}

/* Phase 4 — compact cooperative workspace, late inactivity warning and isolated fullscreen view. */
.qg-collab-player-page .qg-collab-shell {
  width: min(1580px, calc(100% - 30px));
  margin: 22px auto 70px;
}

.qg-collab-player-page .qg-collab-player-panel {
  position: relative;
  margin-top: 0;
  padding: clamp(18px, 2.2vw, 30px);
  overflow: visible;
}

.qg-collab-player-page .qg-collab-player-head {
  align-items: flex-start;
  margin-bottom: 0;
  padding-right: 58px;
}

.qg-collab-player-page .qg-collab-player-head > div:first-child {
  min-width: 0;
}

.qg-collab-player-page .qg-collab-player-head h1 {
  max-width: 1040px;
  margin: 5px 0 8px;
  color: #102218;
  font-size: clamp(30px, 4vw, 48px);
  line-height: 1.06;
  letter-spacing: -.035em;
}

.qg-collab-player-page .qg-collab-player-head p {
  max-width: 920px;
  margin: 0;
  color: var(--muted, #6e776f);
  line-height: 1.5;
}

.qg-collab-player-head-actions {
  display: flex;
  flex: 0 0 auto;
  flex-direction: column;
  align-items: flex-end;
  gap: 9px;
}

.qg-collab-control-deck {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(390px, .95fr);
  gap: 14px;
  margin: 18px 0 20px;
}

.qg-collab-session-card,
.qg-collab-participants-card {
  min-width: 0;
  padding: 16px;
  border: 1px solid rgba(22, 63, 43, .14);
  border-radius: 19px;
  background: rgba(255, 255, 255, .9);
  box-shadow: 0 10px 28px rgba(24, 55, 36, .045);
}

.qg-collab-compact-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.qg-collab-compact-heading h2 {
  margin: 3px 0 0;
  font-size: 21px;
  line-height: 1.15;
}

.qg-collab-player-page .qg-collab-live-state {
  min-height: 30px;
  padding: 6px 10px;
  font-size: 11px;
}

.qg-collab-player-page .qg-collab-metrics {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 12px 0;
}

.qg-collab-player-page .qg-collab-metric {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  min-height: 54px;
  padding: 9px 11px;
  border-radius: 13px;
  background: #f7faf5;
}

.qg-collab-player-page .qg-collab-metric strong {
  font-size: 22px;
  line-height: 1;
}

.qg-collab-player-page .qg-collab-metric span {
  line-height: 1.25;
}

.qg-collab-player-page .qg-collab-stage-message,
.qg-collab-player-page .qg-collab-expired-message {
  padding: 11px 12px;
  border-radius: 13px;
  font-size: 13px;
  line-height: 1.45;
}

.qg-collab-player-page .qg-collab-room-actions {
  gap: 8px;
  margin-top: 12px;
}

.qg-collab-player-page .qg-collab-room-actions .btn {
  min-height: 38px;
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 13px;
}

.qg-collab-player-page .qg-collab-session-message {
  min-height: 0;
  margin: 9px 0 0;
  font-size: 13px;
}

.qg-collab-player-page .qg-collab-session-message:empty {
  display: none;
}

.qg-collab-slot-summary {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  padding: 6px 9px;
  border-radius: 999px;
  background: #edf5e9;
  color: #31533e;
  font-size: 11px;
  line-height: 1.2;
  white-space: nowrap;
}

.qg-collab-slot-summary strong {
  font-size: 15px;
  line-height: 1;
}

.qg-collab-player-page .qg-collab-member-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.qg-collab-player-page .qg-collab-member {
  grid-template-columns: 34px minmax(0, 1fr) auto;
  gap: 8px;
  min-width: 0;
  padding: 8px;
  border-radius: 13px;
  background: #fff;
}

.qg-collab-player-page .qg-collab-member .qg-collab-avatar {
  width: 34px;
  height: 34px;
  border-radius: 11px;
  font-size: 13px;
}

.qg-collab-player-page .qg-collab-member > span:nth-child(2) {
  min-width: 0;
}

.qg-collab-player-page .qg-collab-member strong,
.qg-collab-player-page .qg-collab-member small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.qg-collab-player-page .qg-collab-member strong {
  font-size: 13px;
}

.qg-collab-player-page .qg-collab-member small,
.qg-collab-player-page .qg-collab-member-status {
  font-size: 10px;
}

.qg-collab-invite-disclosure {
  margin-top: 12px;
  overflow: hidden;
  border: 1px solid rgba(22, 63, 43, .14);
  border-radius: 14px;
  background: #fbfdf9;
}

.qg-collab-invite-disclosure > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 42px;
  padding: 9px 12px;
  color: #16472f;
  font-size: 13px;
  font-weight: 850;
  list-style: none;
  cursor: pointer;
  user-select: none;
}

.qg-collab-invite-disclosure > summary::-webkit-details-marker {
  display: none;
}

.qg-collab-invite-disclosure > summary:hover {
  background: #f0f6ed;
}

.qg-collab-disclosure-icon {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  border-radius: 8px;
  background: rgba(22, 63, 43, .08);
  font-size: 18px;
  line-height: 1;
  transition: transform .18s ease;
}

.qg-collab-invite-disclosure[open] .qg-collab-disclosure-icon {
  transform: rotate(45deg);
}

.qg-collab-invite-disclosure .qg-collab-invite-form {
  gap: 10px;
  margin: 0;
  padding: 0 12px 12px;
  border-top: 1px solid rgba(22, 63, 43, .08);
}

.qg-collab-invite-disclosure .qg-collab-search-label {
  padding-top: 11px;
  font-size: 13px;
}

.qg-collab-invite-disclosure input[type="search"] {
  min-height: 42px;
  padding: 9px 12px;
  border-radius: 12px;
}

.qg-collab-invite-disclosure .qg-collab-inline-results {
  max-height: 160px;
  border-radius: 12px;
}

.qg-collab-invite-disclosure .qg-collab-result-note {
  padding: 13px;
  font-size: 13px;
}

.qg-collab-invite-disclosure [data-qg-session-invite-submit] {
  width: 100%;
  min-height: 40px;
}

.qg-collab-player-page .qg-collab-player-warning {
  margin: 10px 0 12px;
}

.qg-collab-player-page .qg-collab-player-message {
  min-height: 0;
  margin: 0 0 12px;
}

.qg-collab-player-page .qg-collab-player-message:empty {
  display: none;
}

.qg-collab-unsupported {
  margin-top: 18px;
  padding: 18px;
  border: 1px dashed #c5d2c0;
  border-radius: 17px;
  background: #fffdf8;
}

.qg-collab-unsupported h2 {
  margin: 5px 0 8px;
}

.qg-collab-unsupported p {
  max-width: 920px;
  color: var(--muted, #6e776f);
  line-height: 1.55;
}

.qg-collab-expand-btn {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 12;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  padding: 0;
  border: 1px solid rgba(22, 63, 43, .16);
  border-radius: 16px;
  background: rgba(255, 255, 255, .96);
  color: #102218;
  box-shadow: 0 12px 28px rgba(17, 34, 17, .14);
  font: 800 24px/1 sans-serif;
  cursor: pointer;
  transition: background .16s ease, color .16s ease, transform .16s ease, box-shadow .16s ease;
}

.qg-collab-expand-btn:hover,
.qg-collab-expand-btn:focus-visible {
  background: #edf5e9;
  color: #16472f;
  transform: translateY(-1px);
}

.qg-collab-expand-btn:focus-visible {
  outline: 3px solid rgba(74, 151, 107, .28);
  outline-offset: 2px;
}

body.qg-collab-player-expanded-mode {
  overflow: hidden;
}

body.qg-collab-player-expanded-mode .site-header,
body.qg-collab-player-expanded-mode .site-footer {
  visibility: hidden;
}

.qg-collab-player-panel.is-expanded {
  position: fixed;
  inset: 0;
  z-index: 1300;
  width: 100vw;
  height: 100dvh;
  margin: 0;
  padding: 22px;
  overflow: auto;
  border: 0;
  border-radius: 0;
  background: linear-gradient(135deg, #eaf3ff 0%, #f8fbff 100%);
  box-shadow: none;
  overscroll-behavior: contain;
}

.qg-collab-player-panel.is-expanded .qg-collab-player-head,
.qg-collab-player-panel.is-expanded .qg-collab-control-deck,
.qg-collab-player-panel.is-expanded .qg-collab-player-warning,
.qg-collab-player-panel.is-expanded .qg-collab-player-message,
.qg-collab-player-panel.is-expanded .qg-collab-player,
.qg-collab-player-panel.is-expanded .qg-collab-unsupported {
  width: min(1576px, 100%);
  margin-right: auto;
  margin-left: auto;
}

.qg-collab-player-panel.is-expanded .qg-collab-expand-btn {
  position: fixed;
  top: 14px;
  right: 18px;
  z-index: 1502;
  border-radius: 999px;
  background: #fff;
  font-size: 34px;
}

.qg-collab-player-panel.is-expanded .qg-collab-player .qgp-side {
  top: 18px;
  max-height: calc(100dvh - 36px);
}

.qg-collab-expiry-toast {
  position: fixed;
  top: 90px;
  right: max(112px, env(safe-area-inset-right));
  z-index: 1450;
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  align-items: center;
  gap: 11px;
  width: min(350px, calc(100vw - 28px));
  min-height: 82px;
  padding: 12px 15px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: 20px;
  background: rgba(27, 29, 28, .96);
  color: #fff;
  box-shadow: 0 20px 52px rgba(8, 16, 11, .3), 0 2px 10px rgba(8, 16, 11, .2);
  backdrop-filter: blur(18px);
  pointer-events: none;
  opacity: 0;
  transform: translateX(calc(100% + 34px)) scale(.97);
  transform-origin: right center;
  transition: opacity .28s ease, transform .36s cubic-bezier(.2, .75, .2, 1);
}

.qg-collab-expiry-toast[hidden] {
  display: none;
}

.qg-collab-expiry-toast.is-visible {
  opacity: 1;
  transform: translateX(0) scale(1);
}

.qg-collab-expiry-icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid rgba(255, 212, 126, .22);
  border-radius: 13px;
  background: rgba(165, 112, 25, .22);
  color: #ffe2a3;
  font-size: 18px;
}

.qg-collab-expiry-copy {
  display: block;
  min-width: 0;
}

.qg-collab-expiry-copy strong,
.qg-collab-expiry-copy span {
  display: block;
}

.qg-collab-expiry-copy strong {
  color: #fff;
  font-size: 15px;
  line-height: 1.3;
}

.qg-collab-expiry-copy span {
  margin-top: 3px;
  color: rgba(255, 255, 255, .7);
  font-size: 12px;
  line-height: 1.35;
}

.qg-collab-expiry-copy b {
  color: #ffe2a3;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

body.qg-collab-expiry-warning-visible.qg-collab-player-page .qg-notification-toast-stack {
  --qg-notification-toast-top: 184px !important;
}

body.qg-collab-player-expanded-mode .qg-collab-expiry-toast {
  top: 74px;
  right: max(14px, env(safe-area-inset-right));
}

body.qg-collab-player-expanded-mode.qg-collab-player-page .qg-notification-toast-stack {
  --qg-notification-toast-top: 72px !important;
}

body.qg-collab-player-expanded-mode.qg-collab-expiry-warning-visible.qg-collab-player-page .qg-notification-toast-stack {
  --qg-notification-toast-top: 168px !important;
}

@media (max-width: 980px) {
  .qg-collab-control-deck {
    grid-template-columns: 1fr;
  }

  .qg-collab-player-page .qg-collab-member-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 680px) {
  .qg-collab-player-page .qg-collab-shell {
    width: min(calc(100% - 16px), 1580px);
    margin-top: 10px;
  }

  .qg-collab-player-page .qg-collab-player-panel,
  .qg-collab-player-panel.is-expanded {
    padding: 13px;
  }

  .qg-collab-player-page .qg-collab-player-head {
    gap: 12px;
    padding-right: 52px;
  }

  .qg-collab-player-page .qg-collab-player-head h1 {
    font-size: 30px;
  }

  .qg-collab-player-head-actions {
    align-items: flex-start;
  }

  .qg-collab-player-page .qg-collab-metrics,
  .qg-collab-player-page .qg-collab-member-list {
    grid-template-columns: 1fr;
  }

  .qg-collab-session-card,
  .qg-collab-participants-card {
    padding: 13px;
  }

  .qg-collab-compact-heading {
    align-items: flex-start;
  }

  .qg-collab-slot-summary span {
    display: none;
  }

  .qg-collab-player-page .qg-collab-room-actions .btn {
    flex: 1 1 100%;
    width: 100%;
  }

  .qg-collab-expand-btn {
    top: 10px;
    right: 10px;
    width: 42px;
    height: 42px;
    border-radius: 14px;
  }

  .qg-collab-player-panel.is-expanded .qg-collab-expand-btn {
    top: 10px;
    right: 10px;
  }

  .qg-collab-expiry-toast {
    top: 164px;
    right: max(9px, env(safe-area-inset-right));
    width: min(350px, calc(100vw - 18px));
  }

  body.qg-collab-expiry-warning-visible.qg-collab-player-page .qg-notification-toast-stack {
    --qg-notification-toast-top: 258px !important;
  }

  body.qg-collab-player-expanded-mode .qg-collab-expiry-toast {
    top: 64px;
    right: max(9px, env(safe-area-inset-right));
  }

  body.qg-collab-player-expanded-mode.qg-collab-expiry-warning-visible.qg-collab-player-page .qg-notification-toast-stack {
    --qg-notification-toast-top: 158px !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  .qg-collab-disclosure-icon,
  .qg-collab-expand-btn,
  .qg-collab-expiry-toast {
    transition-duration: .01ms !important;
  }
}

/* Phase 5 — encrypted real-time session chat. The widget is fixed and isolated
   from the quiz layout so opening/closing it never reflows the player. */
.qg-collab-chat {
  position: fixed;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 1605;
  width: 58px;
  height: 58px;
  pointer-events: none;
}

.qg-collab-chat > * {
  pointer-events: auto;
}

.qg-collab-chat .sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.qg-collab-chat-launcher {
  position: relative;
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, .46);
  border-radius: 50%;
  background: linear-gradient(145deg, #2ca7f4 0%, #167bd2 100%);
  color: #fff;
  box-shadow: 0 16px 36px rgba(20, 101, 172, .32), 0 4px 12px rgba(17, 47, 73, .2);
  cursor: pointer;
  transform: translateZ(0);
  transition: transform .2s ease, box-shadow .2s ease, filter .2s ease;
}

.qg-collab-chat-launcher::before {
  content: "";
  position: absolute;
  inset: 4px;
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: inherit;
  pointer-events: none;
}

.qg-collab-chat-launcher:hover,
.qg-collab-chat-launcher:focus-visible {
  filter: brightness(1.04);
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 20px 42px rgba(20, 101, 172, .36), 0 5px 14px rgba(17, 47, 73, .23);
}

.qg-collab-chat-launcher:focus-visible {
  outline: 3px solid rgba(44, 167, 244, .28);
  outline-offset: 3px;
}

.qg-collab-chat-launcher svg {
  width: 31px;
  height: 31px;
  overflow: visible;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.1;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.qg-collab-chat-launcher svg circle {
  fill: currentColor;
  stroke: none;
}

.qg-collab-chat.has-unread .qg-collab-chat-launcher {
  animation: qg-collab-chat-attention 2.8s ease-in-out infinite;
}

@keyframes qg-collab-chat-attention {
  0%, 72%, 100% { transform: translateY(0) scale(1); }
  79% { transform: translateY(-3px) scale(1.035); }
  86% { transform: translateY(0) scale(1); }
  92% { transform: translateY(-1px) scale(1.018); }
}

.qg-collab-chat-badge {
  position: absolute;
  top: -5px;
  right: -4px;
  display: grid;
  place-items: center;
  min-width: 23px;
  height: 23px;
  padding: 0 6px;
  border: 3px solid #f7fbff;
  border-radius: 999px;
  background: #e5484d;
  color: #fff;
  font-size: 11px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  box-shadow: 0 5px 12px rgba(118, 26, 31, .25);
}

.qg-collab-chat-badge[hidden] {
  display: none;
}

.qg-collab-chat-panel {
  position: absolute;
  right: 0;
  bottom: 72px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: min(370px, calc(100vw - 28px));
  height: min(520px, calc(100dvh - 116px));
  min-height: min(360px, calc(100dvh - 116px));
  overflow: hidden;
  border: 1px solid rgba(17, 43, 29, .16);
  border-radius: 22px;
  background: #fff;
  box-shadow: 0 28px 76px rgba(13, 31, 21, .28), 0 8px 24px rgba(13, 31, 21, .15);
  opacity: 0;
  transform: translateY(14px) scale(.96);
  transform-origin: right bottom;
  transition: opacity .2s ease, transform .24s cubic-bezier(.2, .76, .25, 1);
}

.qg-collab-chat-panel[hidden] {
  display: none;
}

.qg-collab-chat-panel.is-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.qg-collab-chat-head {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 36px;
  align-items: center;
  gap: 10px;
  min-height: 74px;
  padding: 12px 13px 12px 14px;
  background: linear-gradient(135deg, #1b3f31 0%, #19354a 100%);
  color: #fff;
}

.qg-collab-chat-head-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 14px;
  background: rgba(255, 255, 255, .1);
}

.qg-collab-chat-head-icon svg {
  width: 25px;
  height: 25px;
  fill: none;
  stroke: #fff;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.qg-collab-chat-head-icon circle {
  fill: #fff;
  stroke: none;
}

.qg-collab-chat-head-copy {
  display: block;
  min-width: 0;
}

.qg-collab-chat-head-copy strong,
.qg-collab-chat-head-copy small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.qg-collab-chat-head-copy strong {
  color: #fff;
  font-size: 15px;
  line-height: 1.25;
}

.qg-collab-chat-head-copy small {
  margin-top: 3px;
  color: rgba(255, 255, 255, .68);
  font-size: 11px;
}

.qg-collab-chat-close {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0 0 2px;
  border: 1px solid rgba(255, 255, 255, .13);
  border-radius: 12px;
  background: rgba(255, 255, 255, .08);
  color: #fff;
  font: 500 25px/1 sans-serif;
  cursor: pointer;
  transition: background .15s ease, transform .15s ease;
}

.qg-collab-chat-close:hover,
.qg-collab-chat-close:focus-visible {
  background: rgba(255, 255, 255, .17);
  transform: rotate(2deg);
}

.qg-collab-chat-close:focus-visible {
  outline: 2px solid rgba(255, 255, 255, .45);
  outline-offset: 2px;
}

.qg-collab-chat-body {
  position: relative;
  min-height: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 10% 0%, rgba(77, 168, 230, .07), transparent 34%),
    #f5f7f8;
}

.qg-collab-chat-messages {
  height: 100%;
  padding: 15px 13px 18px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(44, 74, 57, .28) transparent;
}

.qg-collab-chat-messages:focus-visible {
  outline: 3px solid rgba(44, 167, 244, .2);
  outline-offset: -3px;
}

.qg-collab-chat-loading,
.qg-collab-chat-load-error,
.qg-collab-chat-empty {
  display: grid;
  place-items: center;
  align-content: center;
  min-height: 100%;
  padding: 28px 18px;
  color: #778078;
  text-align: center;
}

.qg-collab-chat-load-error {
  color: #9b2f37;
  font-size: 13px;
  line-height: 1.45;
}

.qg-collab-chat-empty span {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  margin-bottom: 10px;
  border-radius: 16px;
  background: #e8f2f8;
  color: #247db9;
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 2px;
}

.qg-collab-chat-empty strong,
.qg-collab-chat-empty small {
  display: block;
}

.qg-collab-chat-empty strong {
  color: #2a3930;
  font-size: 14px;
}

.qg-collab-chat-empty small {
  max-width: 245px;
  margin-top: 5px;
  color: #7b847d;
  font-size: 12px;
  line-height: 1.4;
}

.qg-collab-chat-message {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin: 0 0 13px;
  animation: qg-collab-chat-message-in .2s ease-out both;
}

.qg-collab-chat-message:last-child {
  margin-bottom: 0;
}

.qg-collab-chat-message.is-own {
  flex-direction: row-reverse;
}

@keyframes qg-collab-chat-message-in {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

.qg-collab-chat-avatar {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 31px;
  height: 31px;
  border-radius: 11px;
  background: #dcebe3;
  color: #16472f;
  font-size: 11px;
  font-weight: 900;
  box-shadow: inset 0 0 0 1px rgba(22, 63, 43, .08);
}

.qg-collab-chat-message[data-sender-tone="1"] .qg-collab-chat-avatar { background: #e1ecfb; color: #27578e; }
.qg-collab-chat-message[data-sender-tone="2"] .qg-collab-chat-avatar { background: #f5e5f0; color: #81416a; }
.qg-collab-chat-message[data-sender-tone="3"] .qg-collab-chat-avatar { background: #fff0d8; color: #805520; }
.qg-collab-chat-message[data-sender-tone="4"] .qg-collab-chat-avatar { background: #e7e6fb; color: #514f8f; }
.qg-collab-chat-message[data-sender-tone="5"] .qg-collab-chat-avatar { background: #e0f2ef; color: #26695f; }
.qg-collab-chat-message[data-sender-tone="6"] .qg-collab-chat-avatar { background: #f7e7df; color: #8a4c35; }
.qg-collab-chat-message[data-sender-tone="7"] .qg-collab-chat-avatar { background: #e9efd9; color: #596c29; }

.qg-collab-chat-message-content {
  min-width: 0;
  max-width: min(78%, 268px);
}

.qg-collab-chat-message.is-own .qg-collab-chat-message-content {
  display: grid;
  justify-items: end;
}

.qg-collab-chat-message-meta {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  margin: 0 3px 4px;
}

.qg-collab-chat-message.is-own .qg-collab-chat-message-meta {
  flex-direction: row-reverse;
}

.qg-collab-chat-message-meta strong {
  min-width: 0;
  overflow: hidden;
  color: #385747;
  font-size: 11px;
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.qg-collab-chat-message-meta time {
  flex: 0 0 auto;
  color: #98a09a;
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.qg-collab-chat-bubble {
  width: fit-content;
  max-width: 100%;
  padding: 9px 11px;
  border: 1px solid rgba(31, 69, 47, .09);
  border-radius: 8px 16px 16px 16px;
  background: #fff;
  color: #26342c;
  box-shadow: 0 4px 12px rgba(19, 46, 30, .055);
  font-size: 13px;
  line-height: 1.42;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.qg-collab-chat-message.is-own .qg-collab-chat-bubble {
  border-color: rgba(28, 121, 78, .12);
  border-radius: 16px 8px 16px 16px;
  background: #dff3e7;
  color: #183f2b;
}

.qg-collab-chat-message.is-unavailable .qg-collab-chat-bubble {
  border-style: dashed;
  background: #fff8e7;
  color: #775b1f;
  font-style: italic;
}

.qg-collab-chat-new {
  position: absolute;
  left: 50%;
  bottom: 9px;
  z-index: 2;
  min-height: 31px;
  padding: 6px 12px;
  border: 1px solid rgba(35, 114, 164, .18);
  border-radius: 999px;
  background: rgba(255, 255, 255, .96);
  color: #226f9f;
  box-shadow: 0 8px 22px rgba(20, 74, 109, .18);
  font-size: 11px;
  font-weight: 850;
  cursor: pointer;
  transform: translateX(-50%);
}

.qg-collab-chat-new[hidden] {
  display: none;
}

.qg-collab-chat-composer {
  display: grid;
  gap: 7px;
  padding: 10px 11px 9px;
  border-top: 1px solid rgba(22, 63, 43, .12);
  background: #fff;
}

.qg-collab-chat-composer textarea {
  width: 100%;
  min-height: 40px;
  max-height: 98px;
  padding: 9px 11px;
  resize: none;
  overflow-y: auto;
  border: 1px solid #d6ded9;
  border-radius: 13px;
  background: #fbfcfb;
  color: #1d2b23;
  font: inherit;
  font-size: 13px;
  line-height: 1.4;
  box-shadow: none;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}

.qg-collab-chat-composer textarea:focus {
  border-color: #67a7cf;
  background: #fff;
  outline: 0;
  box-shadow: 0 0 0 3px rgba(44, 167, 244, .13);
}

.qg-collab-chat-composer textarea.is-near-limit {
  border-color: #d8a94e;
}

.qg-collab-chat-composer textarea.is-over-limit {
  border-color: #d84e56;
}

.qg-collab-chat-composer textarea:disabled {
  background: #f2f3f2;
  color: #778078;
  cursor: not-allowed;
}

.qg-collab-chat-compose-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.qg-collab-chat-hint {
  min-width: 0;
  overflow: hidden;
  color: #89918b;
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.qg-collab-chat-send {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(145deg, #2096e7, #1576c8);
  color: #fff;
  box-shadow: 0 7px 16px rgba(25, 115, 180, .23);
  cursor: pointer;
  transition: transform .15s ease, opacity .15s ease, filter .15s ease;
}

.qg-collab-chat-send:hover:not(:disabled),
.qg-collab-chat-send:focus-visible:not(:disabled) {
  filter: brightness(1.05);
  transform: translateY(-1px);
}

.qg-collab-chat-send:focus-visible {
  outline: 3px solid rgba(44, 167, 244, .24);
  outline-offset: 2px;
}

.qg-collab-chat-send:disabled {
  opacity: .35;
  box-shadow: none;
  cursor: not-allowed;
}

.qg-collab-chat-send svg {
  width: 19px;
  height: 19px;
  fill: currentColor;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.qg-collab-chat-composer.is-sending .qg-collab-chat-send svg {
  animation: qg-collab-chat-send-pulse .8s ease-in-out infinite alternate;
}

@keyframes qg-collab-chat-send-pulse {
  from { transform: translateX(-1px) scale(.94); opacity: .72; }
  to { transform: translateX(1px) scale(1.04); opacity: 1; }
}

.qg-collab-chat-status {
  min-height: 0;
  margin: 0;
  color: #69756d;
  font-size: 10px;
  line-height: 1.3;
}

.qg-collab-chat-status:empty {
  display: none;
}

.qg-collab-chat-status.is-working {
  color: #78601d;
}

.qg-collab-chat-status.is-error {
  color: #a02d35;
}

.qg-collab-chat-setup-note {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 1600;
  max-width: 360px;
  margin: 0;
  padding: 10px 12px;
  border: 1px solid #e0cd8d;
  border-radius: 12px;
  background: #fff8df;
  color: #72571b;
  box-shadow: 0 10px 28px rgba(80, 62, 18, .14);
  font-size: 11px;
}

body.qg-collab-player-expanded-mode .qg-collab-chat {
  z-index: 1705;
}

@media (max-width: 680px) {
  .qg-collab-chat {
    right: max(9px, env(safe-area-inset-right));
    bottom: max(10px, env(safe-area-inset-bottom));
    width: 52px;
    height: 52px;
  }

  .qg-collab-chat-launcher {
    width: 52px;
    height: 52px;
  }

  .qg-collab-chat-launcher svg {
    width: 28px;
    height: 28px;
  }

  .qg-collab-chat-panel {
    right: 0;
    bottom: 64px;
    width: calc(100vw - 18px);
    height: min(510px, calc(100dvh - 92px));
    min-height: min(330px, calc(100dvh - 92px));
    border-radius: 19px;
  }

  .qg-collab-chat-head {
    min-height: 68px;
    padding: 10px 11px;
  }

  .qg-collab-chat-messages {
    padding: 13px 10px 16px;
  }

  .qg-collab-chat-message-content {
    max-width: min(80%, 285px);
  }

  .qg-collab-chat-hint {
    max-width: calc(100% - 48px);
  }
}

@media (max-height: 620px) and (min-width: 681px) {
  .qg-collab-chat-panel {
    height: calc(100dvh - 96px);
    min-height: 300px;
    bottom: 68px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .qg-collab-chat-launcher,
  .qg-collab-chat-panel,
  .qg-collab-chat-close,
  .qg-collab-chat-send,
  .qg-collab-chat-message {
    animation: none !important;
    transition-duration: .01ms !important;
  }
}

/* Match each participant name to the stable avatar tone. */
.qg-collab-chat-message[data-sender-tone="1"] .qg-collab-chat-message-meta strong { color: #27578e; }
.qg-collab-chat-message[data-sender-tone="2"] .qg-collab-chat-message-meta strong { color: #81416a; }
.qg-collab-chat-message[data-sender-tone="3"] .qg-collab-chat-message-meta strong { color: #805520; }
.qg-collab-chat-message[data-sender-tone="4"] .qg-collab-chat-message-meta strong { color: #514f8f; }
.qg-collab-chat-message[data-sender-tone="5"] .qg-collab-chat-message-meta strong { color: #26695f; }
.qg-collab-chat-message[data-sender-tone="6"] .qg-collab-chat-message-meta strong { color: #8a4c35; }
.qg-collab-chat-message[data-sender-tone="7"] .qg-collab-chat-message-meta strong { color: #596c29; }
.qg-collab-chat-message.is-own .qg-collab-chat-message-meta strong { color: #17613b; }

/* Visual-only compact chat adjustment (v12).
   Keeps the widget clear of the quiz while preserving a 44px mobile touch target. */
.qg-collab-chat {
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  width: 48px;
  height: 48px;
}

.qg-collab-chat-launcher {
  width: 48px;
  height: 48px;
}

.qg-collab-chat-launcher::before {
  inset: 3px;
}

.qg-collab-chat-launcher svg {
  width: 25px;
  height: 25px;
}

.qg-collab-chat-badge {
  top: -4px;
  right: -3px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-width: 2px;
  font-size: 10px;
}

.qg-collab-chat-panel {
  bottom: 60px;
  width: min(310px, calc(100vw - 24px));
  height: min(440px, calc(100dvh - 96px));
  min-height: min(310px, calc(100dvh - 96px));
  border-radius: 18px;
}

.qg-collab-chat-head {
  grid-template-columns: 36px minmax(0, 1fr) 31px;
  gap: 8px;
  min-height: 62px;
  padding: 9px 10px;
}

.qg-collab-chat-head-icon {
  width: 36px;
  height: 36px;
  border-radius: 11px;
}

.qg-collab-chat-head-icon svg {
  width: 21px;
  height: 21px;
}

.qg-collab-chat-head-copy strong {
  font-size: 14px;
}

.qg-collab-chat-head-copy small {
  font-size: 10px;
}

.qg-collab-chat-close {
  width: 30px;
  height: 30px;
  border-radius: 10px;
  font-size: 22px;
}

.qg-collab-chat-messages {
  padding: 12px 10px 14px;
}

.qg-collab-chat-message {
  gap: 7px;
  margin-bottom: 11px;
}

.qg-collab-chat-avatar {
  width: 27px;
  height: 27px;
  border-radius: 9px;
  font-size: 10px;
}

.qg-collab-chat-message-content {
  max-width: min(80%, 224px);
}

.qg-collab-chat-message-meta {
  gap: 5px;
  margin: 0 2px 3px;
}

.qg-collab-chat-message-meta strong {
  font-size: 10px;
}

.qg-collab-chat-message-meta time {
  font-size: 9px;
}

.qg-collab-chat-bubble {
  padding: 8px 9px;
  border-radius: 7px 13px 13px 13px;
  font-size: 12px;
  line-height: 1.4;
}

.qg-collab-chat-message.is-own .qg-collab-chat-bubble {
  border-radius: 13px 7px 13px 13px;
}

.qg-collab-chat-composer {
  gap: 6px;
  padding: 8px 9px;
}

.qg-collab-chat-composer textarea {
  min-height: 36px;
  max-height: 82px;
  padding: 8px 9px;
  border-radius: 11px;
  font-size: 12px;
  line-height: 1.38;
}

.qg-collab-chat-compose-row {
  gap: 8px;
}

.qg-collab-chat-send {
  width: 32px;
  height: 32px;
  border-radius: 10px;
}

.qg-collab-chat-send svg {
  width: 17px;
  height: 17px;
}

@media (max-width: 680px) {
  .qg-collab-chat {
    right: max(8px, env(safe-area-inset-right));
    bottom: max(8px, env(safe-area-inset-bottom));
    width: 44px;
    height: 44px;
  }

  .qg-collab-chat-launcher {
    width: 44px;
    height: 44px;
  }

  .qg-collab-chat-launcher svg {
    width: 24px;
    height: 24px;
  }

  .qg-collab-chat-panel {
    bottom: 56px;
    width: min(320px, calc(100vw - 16px));
    height: min(430px, calc(100dvh - 76px));
    min-height: min(290px, calc(100dvh - 76px));
    border-radius: 17px;
  }

  .qg-collab-chat-head {
    min-height: 58px;
    padding: 8px 9px;
  }

  .qg-collab-chat-messages {
    padding: 11px 9px 13px;
  }

  .qg-collab-chat-message-content {
    max-width: min(82%, 230px);
  }

  .qg-collab-chat-hint {
    max-width: calc(100% - 42px);
  }
}

@media (max-height: 620px) and (min-width: 681px) {
  .qg-collab-chat-panel {
    bottom: 58px;
    height: calc(100dvh - 82px);
    min-height: 270px;
  }
}
