.community-widget {
  position: fixed;
  right: 24px;
  bottom: 166px;
  z-index: 8500;
  color: var(--ink, #0f172a);
  font-family: "Plus Jakarta Sans", "DM Sans", system-ui, sans-serif;
}

.community-widget [hidden] {
  display: none !important;
}

.community-widget-buttons {
  display: grid;
  gap: 12px;
  justify-items: end;
}

.community-fab {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 62px;
  height: 62px;
  border: 0;
  border-radius: 20px;
  background: linear-gradient(135deg, #06b6d4, #7c3aed);
  color: #ffffff;
  box-shadow: 0 18px 46px rgba(15, 23, 42, 0.22), 0 0 0 1px rgba(255, 255, 255, 0.36) inset;
  cursor: pointer;
  font-size: 25px;
  line-height: 1;
  transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
}

.community-fab:hover,
.community-fab:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 22px 58px rgba(15, 23, 42, 0.28), 0 0 0 2px rgba(255, 255, 255, 0.52) inset;
  filter: saturate(1.08);
}

.community-fab:focus-visible {
  outline: 3px solid rgba(6, 182, 212, 0.38);
  outline-offset: 3px;
}

.community-fab-icon {
  display: block;
  transform: translateY(1px);
}

.community-fab-chat {
  background: linear-gradient(135deg, #00c2ff, #8b5cf6);
}

.community-fab-star {
  width: 44px;
  height: 44px;
  border: 1px solid rgba(217, 119, 6, 0.42);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  color: #d97706;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.16), 0 0 0 1px rgba(255, 255, 255, 0.72) inset;
  font-size: 22px;
}

.community-fab-star:hover,
.community-fab-star:focus-visible {
  border-color: rgba(217, 119, 6, 0.68);
  box-shadow: 0 16px 38px rgba(15, 23, 42, 0.2), 0 0 0 2px rgba(254, 243, 199, 0.86) inset;
}

body.quiz-rating-gated:not(.quiz-rating-ready):not(.community-rating-override-visible) .community-fab-star {
  display: none;
}

body.quiz-rating-ready .community-fab-star[data-community-hint]::after {
  position: absolute;
  right: calc(100% + 10px);
  top: 50%;
  z-index: 2;
  width: max-content;
  max-width: min(220px, calc(100vw - 96px));
  padding: 7px 10px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.92);
  color: #ffffff;
  content: attr(data-community-hint);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  opacity: 0;
  pointer-events: none;
  transform: translate(4px, -50%);
  transition: opacity 0.14s ease, transform 0.14s ease;
}

body.quiz-rating-ready .community-fab-star[data-community-hint]:hover::after,
body.quiz-rating-ready .community-fab-star[data-community-hint]:focus-visible::after {
  opacity: 1;
  transform: translate(0, -50%);
}

.community-panel {
  position: absolute;
  right: 76px;
  bottom: 0;
  width: min(440px, calc(100vw - 32px));
  max-height: min(680px, calc(100vh - 190px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(15, 23, 42, 0.1);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.97);
  box-shadow: 0 28px 80px rgba(15, 23, 42, 0.28);
  backdrop-filter: blur(14px);
}

.theme-dark .community-panel {
  border-color: rgba(255, 255, 255, 0.12);
  background: rgba(15, 23, 42, 0.96);
}

.community-panel[hidden] {
  display: none !important;
}

.community-panel-head,
.community-tabs,
.community-form-actions,
.community-comment-head,
.community-comment-actions,
.community-mute-row,
.community-moderation-meta,
.community-moderation-actions form {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.community-panel-head {
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(15, 23, 42, 0.1);
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.1), rgba(124, 58, 237, 0.1));
}

.community-panel-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  letter-spacing: 0.01em;
}

.community-icon-button,
.community-link-button {
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted, #64748b);
  cursor: pointer;
  font: inherit;
}

.community-icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  font-size: 22px;
}

.community-link-button {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 30px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
}

.community-icon-button:hover,
.community-link-button:hover {
  color: var(--ink, #0f172a);
  background: rgba(15, 23, 42, 0.06);
  border-color: rgba(15, 23, 42, 0.08);
}

.community-tabs {
  display: inline-flex;
  padding: 10px;
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
  background: rgba(248, 250, 252, 0.78);
}

.community-tab {
  flex: 1 1 0;
  min-height: 36px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--muted, #64748b);
  cursor: pointer;
  font-weight: 700;
}

.community-tab.is-active {
  background: #ffffff;
  border-color: rgba(6, 182, 212, 0.24);
  color: #0f766e;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}

.community-body {
  min-height: 0;
  overflow: auto;
  padding: 14px;
}

.community-status {
  margin-bottom: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  background: #ecfeff;
  color: #155e75;
  font-size: 13px;
}

.community-status.is-error {
  background: #fef2f2;
  color: #991b1b;
}

.community-comments {
  display: grid;
  gap: 10px;
}

.community-empty {
  display: grid;
  gap: 6px;
  justify-items: center;
  padding: 22px 14px;
  border: 1px dashed rgba(6, 182, 212, 0.32);
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.08), rgba(124, 58, 237, 0.07));
  color: var(--muted, #64748b);
  text-align: center;
}

.community-empty strong {
  color: var(--ink, #0f172a);
}

.community-empty-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 16px;
  background: #ffffff;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.12);
  font-size: 22px;
}

.community-comment {
  padding: 10px;
  border: 1px solid rgba(15, 23, 42, 0.1);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.78);
}

.theme-dark .community-comment {
  background: rgba(15, 23, 42, 0.72);
}

.community-comment-status-pending,
.community-comment-status-spam {
  border-style: dashed;
  opacity: 0.82;
}

.community-comment-head {
  justify-content: space-between;
  margin-bottom: 6px;
  font-size: 13px;
}

.community-comment-body {
  margin: 0;
  white-space: pre-wrap;
}

.community-comment-original,
.community-comment-duplicates {
  display: block;
  margin-top: 6px;
  color: var(--muted);
}

.community-author-profile {
  display: grid;
  gap: 5px;
  margin-top: 8px;
  padding: 8px;
  border-radius: 7px;
  background: rgba(2, 132, 199, 0.07);
  color: var(--muted);
  font-size: 12px;
}

.community-author-profile p {
  margin: 0;
}

.community-author-interests,
.community-comment-reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.community-author-connect {
  color: var(--ink);
}

.community-comment-reactions {
  margin-top: 8px;
}

.community-comment-reactions button {
  min-height: 28px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink, #0f172a);
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  padding: 4px 8px;
}

.community-comment-reactions button.is-selected {
  background: #dcfce7;
  border-color: #16a34a;
}

.community-replies {
  display: grid;
  gap: 8px;
  margin-top: 10px;
  padding-left: 12px;
  border-left: 2px solid rgba(2, 132, 199, 0.24);
}

.community-comment-form {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.community-comment-form textarea {
  width: 100%;
  min-height: 96px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink, #0f172a);
  font: inherit;
  padding: 12px;
  resize: vertical;
}

.community-comment-form textarea:focus {
  border-color: rgba(6, 182, 212, 0.5);
  box-shadow: 0 0 0 4px rgba(6, 182, 212, 0.12);
  outline: 0;
}

.community-form-actions {
  justify-content: flex-start;
}

.community-action-button {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  gap: 7px;
}

.community-rating {
  display: grid;
  gap: 10px;
}

.community-rating-summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  color: #92400e;
}

.community-rating-hint {
  color: var(--muted, #64748b);
  font-size: 12px;
}

.community-stars,
.community-emotions,
.community-emotion-counts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.community-stars button,
.community-emotions button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(15, 23, 42, 0.14);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.06);
  color: var(--ink, #0f172a);
  cursor: pointer;
  font-size: 20px;
  transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease;
}

.community-stars button:hover,
.community-emotions button:hover,
.community-stars button:focus-visible,
.community-emotions button:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(6, 182, 212, 0.42);
  box-shadow: 0 12px 26px rgba(15, 23, 42, 0.12);
  outline: 0;
}

.community-stars button.is-selected {
  background: linear-gradient(135deg, #fef3c7, #fed7aa);
  border-color: #f59e0b;
  color: #92400e;
}

.community-emotions button.is-selected {
  background: linear-gradient(135deg, #dcfce7, #cffafe);
  border-color: #16a34a;
}

.community-emotions button[data-tooltip]::after {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  z-index: 2;
  min-width: max-content;
  max-width: 150px;
  padding: 5px 8px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.92);
  color: #ffffff;
  content: attr(data-tooltip);
  font-size: 11px;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 4px);
  transition: opacity 0.14s ease, transform 0.14s ease;
}

.community-emotions button[data-tooltip]:hover::after,
.community-emotions button[data-tooltip]:focus-visible::after {
  opacity: 1;
  transform: translate(-50%, 0);
}

.community-mute-row {
  justify-content: flex-end;
  padding: 10px 12px 12px;
  border-top: 1px solid rgba(15, 23, 42, 0.08);
  font-size: 12px;
}

.community-settings-box .profile-checks {
  margin-bottom: 10px;
}

.profile-contact-settings {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(180px, 0.7fr);
  gap: 10px;
  width: 100%;
}

.profile-community-settings {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  width: 100%;
}

.profile-contact-settings label,
.profile-community-settings label {
  display: grid;
  gap: 6px;
}

.profile-community-settings label:nth-child(-n + 2) {
  grid-column: 1 / -1;
}

.profile-community-settings textarea {
  resize: vertical;
}

.community-moderation-toolbar,
.community-moderation-list {
  display: grid;
  gap: 12px;
}

.community-moderation-body {
  white-space: pre-wrap;
}

.theme-dark .community-tabs {
  background: rgba(15, 23, 42, 0.72);
}

.theme-dark .community-tab.is-active,
.theme-dark .community-empty-icon,
.theme-dark .community-stars button,
.theme-dark .community-emotions button,
.theme-dark .community-comment-reactions button,
.theme-dark .community-comment-form textarea {
  background: rgba(30, 41, 59, 0.92);
  color: #f8fafc;
}

.theme-dark .community-empty {
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.12), rgba(124, 58, 237, 0.12));
}

@media (max-width: 720px) {
  .community-widget {
    right: 12px;
    bottom: 148px;
  }

  .community-fab {
    width: 56px;
    height: 56px;
    border-radius: 18px;
  }

  .community-fab-star {
    width: 42px;
    height: 42px;
  }

  .community-panel {
    right: 0;
    bottom: 132px;
    width: calc(100vw - 24px);
    max-height: calc(100vh - 220px);
  }

  .profile-contact-settings {
    grid-template-columns: 1fr;
  }

  .profile-community-settings {
    grid-template-columns: 1fr;
  }

  .profile-community-settings label:nth-child(-n + 2) {
    grid-column: auto;
  }
}
