.avatar,
.message-avatar,
.community-avatar,
.mention-avatar,
.profile-avatar-preview {
  display: inline-grid;
  flex: 0 0 auto;
  overflow: hidden;
  place-items: center;
  border: 1px solid color-mix(in srgb, var(--profile-accent, var(--accent)) 70%, transparent);
  border-radius: 50%;
  background: color-mix(in srgb, var(--profile-accent, var(--accent)) 18%, #171411);
  color: color-mix(in srgb, var(--profile-accent, var(--accent)) 78%, white);
  font-family: var(--sans);
  font-weight: 700;
}

.avatar img,
.message-avatar img,
.community-avatar img,
.mention-avatar img,
.profile-avatar-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.notification-badge {
  display: inline-grid;
  min-width: 1.25rem;
  height: 1.25rem;
  padding: 0 0.3rem;
  place-items: center;
  border: 2px solid #181512;
  border-radius: 999px;
  background: #c65f5f;
  color: white;
  font-size: 0.62rem;
  font-weight: 800;
  line-height: 1;
}

.control-room-dialog {
  width: min(46rem, calc(100% - 2rem));
  max-width: none;
  max-height: min(50rem, calc(100dvh - 2rem));
}

.control-room-shell {
  max-height: min(50rem, calc(100dvh - 2rem));
  overflow-y: auto;
  padding: 1.5rem;
  scrollbar-color: var(--accent-deep) transparent;
}

.control-room-shell > header p {
  margin: 0.45rem 0 0;
  color: var(--dim);
  font-size: 0.74rem;
}

.control-room-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.3rem;
  margin: 1.25rem 0;
  padding: 0.25rem;
  border: 1px solid var(--line);
  border-radius: 0.8rem;
  background: rgba(0, 0, 0, 0.16);
}

.control-room-tabs button {
  padding: 0.72rem;
  border-radius: 0.6rem;
  background: transparent;
  color: var(--dim);
}

.control-room-tabs button.active {
  background: rgba(201, 155, 99, 0.13);
  color: var(--accent-bright);
}

.profile-form {
  display: grid;
  gap: 1rem;
}

.profile-privacy-note {
  margin: -0.25rem 0 0;
  padding: 0.8rem 0.9rem;
  border-left: 2px solid color-mix(in srgb, var(--accent) 65%, transparent);
  background: rgba(201, 155, 99, 0.055);
  color: var(--dim);
  font-size: 0.72rem;
  line-height: 1.55;
}

.insights-load-more {
  margin: 1rem auto 0;
}

.profile-visual-editor {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 1.15rem;
  align-items: center;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: rgba(255, 255, 255, 0.018);
}

.profile-avatar-preview {
  width: 5.5rem;
  height: 5.5rem;
  font-size: 1.5rem;
  box-shadow: 0 0 2rem color-mix(in srgb, var(--profile-accent, var(--accent)) 18%, transparent);
}

.profile-visual-editor strong {
  color: var(--paper);
}

.profile-visual-editor p {
  margin: 0.35rem 0 0.75rem;
  color: var(--dim);
  font-size: 0.72rem;
  line-height: 1.55;
}

.profile-image-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: center;
}

.avatar-upload-button {
  display: inline-flex !important;
  cursor: pointer;
}

.profile-color-field {
  margin: 0;
  padding: 0;
  border: 0;
}

.profile-color-field legend {
  margin-bottom: 0.55rem;
  color: var(--muted);
  font-size: 0.76rem;
}

.profile-accent-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.profile-accent-presets > button,
.custom-color {
  width: 2.25rem;
  height: 2.25rem;
  border: 2px solid rgba(255, 255, 255, 0.14);
  border-radius: 50%;
  background: var(--swatch, transparent);
  box-shadow: 0 0 0 2px transparent;
  cursor: pointer;
}

.profile-accent-presets > button[data-profile-accent="#c99b63"] { --swatch: #c99b63; }
.profile-accent-presets > button[data-profile-accent="#8bb8a8"] { --swatch: #8bb8a8; }
.profile-accent-presets > button[data-profile-accent="#8faad8"] { --swatch: #8faad8; }
.profile-accent-presets > button[data-profile-accent="#bd8fcf"] { --swatch: #bd8fcf; }
.profile-accent-presets > button[data-profile-accent="#d88989"] { --swatch: #d88989; }

.profile-accent-presets > button {
  background-color: var(--swatch);
  background-image: radial-gradient(circle at 32% 28%, rgba(255, 255, 255, 0.34), transparent 44%);
}

.profile-accent-presets > button:hover,
.profile-accent-presets > button:focus-visible,
.custom-color:hover {
  box-shadow: 0 0 0 2px var(--paper);
}

.profile-accent-presets > button[aria-pressed="true"],
.custom-color.active {
  border-color: var(--paper);
  box-shadow: 0 0 0 2px #171411, 0 0 0 4px var(--accent-bright);
  transform: scale(1.06);
}

.preview-environment .profile-accent-presets > button,
.preview-environment .custom-color,
.preview-environment .avatar-upload-button {
  opacity: 1;
}

.preview-environment .story-comment-form {
  border-color: rgba(201, 155, 99, 0.3);
  background: rgba(201, 155, 99, 0.045);
}

.custom-color {
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: conic-gradient(#d88989, #bd8fcf, #8faad8, #8bb8a8, #c99b63, #d88989);
  color: white;
  font-weight: 800;
}

.custom-color input {
  position: absolute;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.notifications-panel {
  min-height: 22rem;
}

.notifications-toolbar,
.story-comments-heading,
.insights-section-heading,
.announcement-actions {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.notifications-toolbar h3,
.story-comments-heading h3,
.insights-section-heading h3 {
  margin: 0.25rem 0 0;
  color: var(--paper);
  font-family: var(--serif);
  font-size: 1.65rem;
  font-weight: 400;
}

.notification-list {
  display: grid;
  gap: 0.7rem;
}

.notification-item {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.9rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 0.9rem;
  background: rgba(255, 255, 255, 0.018);
}

.notification-item.unread {
  border-color: rgba(201, 155, 99, 0.42);
  background: rgba(201, 155, 99, 0.07);
}

.notification-reaction[data-reaction-type="like"] .notification-marker {
  color: #a9c8e8;
  background: rgba(143, 170, 216, 0.12);
}

.notification-reaction[data-reaction-type="heart"] .notification-marker {
  color: #dc8b91;
  background: rgba(220, 139, 145, 0.12);
}

.notification-reaction[data-reaction-type="star"] .notification-marker,
.notification-admin-reaction .notification-marker {
  color: #ddb06d;
  background: rgba(221, 176, 109, 0.14);
}

.notification-admin-reaction {
  border-color: rgba(221, 176, 109, 0.34);
  box-shadow: inset 0 0 1.5rem rgba(221, 176, 109, 0.035);
}

.notification-marker {
  display: grid;
  width: 2rem;
  height: 2rem;
  place-items: center;
  border-radius: 50%;
  background: rgba(201, 155, 99, 0.13);
  color: var(--accent-bright);
  font-weight: 700;
}

.notification-meta {
  color: var(--dim);
  font-size: 0.65rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.notification-item strong {
  display: block;
  margin-top: 0.3rem;
  color: var(--paper);
}

.notification-item p {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.55;
  white-space: pre-wrap;
}

.notification-open-story {
  margin-top: 0.65rem;
  padding: 0;
}

.story-comments {
  margin-top: 6rem;
  padding-top: 3rem;
  border-top: 1px solid var(--line);
}

.story-comments-heading p {
  max-width: 36rem;
  margin: 0.55rem 0 0;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 0.78rem;
  line-height: 1.6;
}

.comment-heading-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.45rem;
  color: var(--dim);
  font-family: var(--sans);
  font-size: 0.7rem;
}

.comment-heading-actions button {
  padding: 0;
}

.story-comment-list {
  display: grid;
  gap: 1rem;
  margin-top: 1.6rem;
}

.comment-thread {
  display: grid;
  gap: 0.65rem;
}

.comment-replies {
  display: grid;
  gap: 0.55rem;
  margin-left: 3.35rem;
  padding-left: 1rem;
  border-left: 1px solid color-mix(in srgb, var(--accent) 36%, transparent);
}

.story-comment {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.9rem;
  padding: 1rem 1.1rem;
  border: 1px solid rgba(255, 255, 255, 0.075);
  border-left: 2px solid color-mix(in srgb, var(--profile-accent) 70%, transparent);
  border-radius: 0.85rem;
  background: rgba(255, 255, 255, 0.016);
  font-family: var(--sans);
}

.story-comment-reply {
  padding: 0.85rem 1rem;
  border-left-width: 1px;
  background: rgba(255, 255, 255, 0.011);
}

.story-comment-reply .community-avatar {
  width: 2.15rem;
  height: 2.15rem;
}

.story-comment.notification-target {
  animation: notification-comment-glow 2.4s ease-out;
}

@keyframes notification-comment-glow {
  0%, 35% {
    border-color: var(--accent-bright);
    background: rgba(201, 155, 99, 0.14);
    box-shadow: 0 0 0 0.3rem rgba(201, 155, 99, 0.08);
  }
  100% {
    border-color: rgba(255, 255, 255, 0.075);
    background: rgba(255, 255, 255, 0.016);
    box-shadow: none;
  }
}

.community-avatar {
  width: 2.55rem;
  height: 2.55rem;
  font-size: 0.72rem;
}

.story-comment-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}

.story-comment-head > div {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: baseline;
}

.story-comment-head strong {
  color: var(--paper);
  font-size: 0.84rem;
}

.story-comment-head span,
.story-comment-head time {
  color: var(--dim);
  font-size: 0.66rem;
}

.story-comment-body {
  margin: 0.5rem 0 0;
  color: #d8d0c4;
  font-size: 0.88rem;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
}

.comment-reply-target {
  margin-top: 0.35rem;
  color: color-mix(in srgb, var(--profile-accent, var(--accent)) 72%, white);
  font-size: 0.66rem;
  font-weight: 650;
}

.comment-mention {
  color: color-mix(in srgb, var(--profile-accent, var(--accent-bright)) 65%, white);
  font-weight: 700;
}

.comment-reaction-area {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem 1rem;
  margin-top: 0.75rem;
}

.comment-reactions {
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
}

.comment-reaction {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.32rem;
  min-width: 2.85rem;
  min-height: 1.85rem;
  padding: 0.3rem 0.48rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.025);
  color: var(--dim);
  font: 650 0.66rem/1 var(--sans);
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, color 160ms ease, transform 160ms ease;
}

.comment-reaction svg {
  width: 0.92rem;
  height: 0.92rem;
  fill: transparent;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.comment-reaction:not(:disabled):hover {
  border-color: color-mix(in srgb, var(--accent-bright) 52%, transparent);
  color: var(--paper);
  transform: translateY(-1px);
}

.comment-reaction.active {
  border-color: color-mix(in srgb, var(--reaction-color) 62%, transparent);
  background: color-mix(in srgb, var(--reaction-color) 13%, transparent);
  color: var(--reaction-color);
}

.comment-reaction.active svg {
  fill: currentColor;
}

.reaction-like {
  --reaction-color: #a9c8e8;
}

.reaction-heart {
  --reaction-color: #dc8b91;
}

.reaction-star {
  --reaction-color: #ddb06d;
}

.comment-reaction.admin-reacted {
  box-shadow: inset 0 0 0 1px rgba(221, 176, 109, 0.18);
}

.comment-reaction:disabled {
  cursor: default;
  opacity: 0.58;
}

.admin-reaction-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.42rem;
  color: #dcb375;
  font: 650 0.63rem/1.2 var(--sans);
  letter-spacing: 0.02em;
}

.admin-reaction-seal {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.1rem;
  min-width: 1.55rem;
  height: 1.55rem;
  padding: 0 0.28rem;
  border: 1px solid rgba(220, 179, 117, 0.7);
  border-radius: 999px;
  background: radial-gradient(circle at 35% 28%, rgba(220, 179, 117, 0.25), rgba(79, 55, 29, 0.22));
  box-shadow: 0 0 1rem rgba(220, 179, 117, 0.08);
}

.admin-reaction-seal svg {
  width: 0.72rem;
  height: 0.72rem;
  fill: currentColor;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linejoin: round;
}

.comment-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem;
  margin-top: 0.7rem;
}

.comment-remove,
.comment-reply-button {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--dim);
  font-size: 0.67rem;
  cursor: pointer;
}

.comment-reply-button {
  color: var(--accent-bright);
  font-weight: 650;
}

.comment-remove:hover,
.comment-reply-button:hover {
  color: var(--paper);
}

.story-comment-form {
  margin-top: 1.4rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 0.9rem;
  background: rgba(0, 0, 0, 0.14);
  font-family: var(--sans);
}

.story-comment-form > label {
  color: var(--muted);
  font-size: 0.74rem;
}

.comment-reply-context {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  margin: -0.15rem 0 0.8rem;
  padding: 0.7rem 0.8rem;
  border-left: 2px solid var(--accent);
  border-radius: 0.5rem;
  background: rgba(201, 155, 99, 0.08);
  color: var(--muted);
  font-size: 0.72rem;
}

.comment-reply-context[hidden] {
  display: none;
}

.comment-reply-context strong {
  color: var(--paper);
}

.comment-reply-context button {
  padding: 0;
}

.comment-composer {
  position: relative;
}

.story-comment-form textarea,
.announcement-card input,
.announcement-card textarea {
  width: 100%;
  margin-top: 0.45rem;
  padding: 0.8rem;
  border: 1px solid var(--line);
  border-radius: 0.7rem;
  outline: 0;
  background: rgba(0, 0, 0, 0.18);
  color: var(--paper);
  resize: vertical;
}

.story-comment-form textarea:focus,
.announcement-card input:focus,
.announcement-card textarea:focus {
  border-color: var(--accent);
}

.mention-suggestions {
  position: absolute;
  z-index: 3;
  right: 0;
  bottom: calc(100% - 0.3rem);
  left: 0;
  overflow-y: auto;
  max-height: 14rem;
  padding: 0.35rem;
  border: 1px solid var(--line);
  border-radius: 0.8rem;
  background: #211d18;
  box-shadow: var(--shadow);
}

.mention-suggestions button {
  display: flex;
  width: 100%;
  gap: 0.7rem;
  align-items: center;
  padding: 0.65rem;
  border-radius: 0.6rem;
  background: transparent;
  color: var(--paper);
  text-align: left;
}

.mention-suggestions button:hover {
  background: rgba(201, 155, 99, 0.1);
}

.mention-avatar {
  width: 2rem;
  height: 2rem;
  font-size: 0.6rem;
}

.mention-suggestions button span {
  display: grid;
}

.mention-suggestions small {
  color: var(--dim);
}

.insights-dialog {
  width: min(90rem, 100%);
  max-width: none;
  height: min(58rem, 100dvh);
  max-height: 100dvh;
  border: 1px solid var(--line);
  border-radius: 1.1rem;
  background: #151310;
  box-shadow: var(--shadow);
}

.insights-shell {
  display: flex;
  height: 100%;
  flex-direction: column;
}

.insights-header {
  display: flex;
  justify-content: space-between;
  gap: 2rem;
  padding: 1.5rem 1.7rem;
  border-bottom: 1px solid var(--line);
}

.insights-header h2 {
  margin: 0.25rem 0 0;
  font-family: var(--serif);
  font-size: clamp(2rem, 4vw, 3rem);
  font-weight: 400;
}

.insights-header p {
  margin: 0.45rem 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.insights-header-actions {
  display: flex;
  gap: 0.65rem;
  align-items: center;
}

.insights-content {
  overflow-y: auto;
  padding: clamp(1rem, 3vw, 1.7rem);
  scrollbar-color: var(--accent-deep) transparent;
}

.insight-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.8rem;
}

.insight-metrics article {
  display: grid;
  gap: 0.25rem;
  min-height: 8.8rem;
  padding: 1rem;
  align-content: center;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: linear-gradient(145deg, rgba(201, 155, 99, 0.07), rgba(255, 255, 255, 0.012));
}

.insight-metrics span,
.insight-metrics small {
  color: var(--dim);
  font-size: 0.68rem;
}

.insight-metrics strong {
  color: var(--accent-bright);
  font-family: var(--serif);
  font-size: 2.5rem;
  font-weight: 400;
}

.insights-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(19rem, 0.65fr);
  gap: 1rem;
  margin-top: 1rem;
}

.insights-card {
  min-width: 0;
  padding: 1.15rem;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: rgba(255, 255, 255, 0.015);
}

.member-presence-card,
.comments-moderation-card {
  grid-column: 1;
}

.ranking-card,
.announcement-card {
  grid-column: 2;
}

.ranking-card {
  grid-row: 1;
}

.announcement-card {
  grid-row: 2;
}

.comments-moderation-card {
  grid-row: 2;
}

.insights-section-heading small {
  color: var(--dim);
  font-size: 0.66rem;
}

.member-activity-list,
.activity-ranking,
.insights-comments-list {
  display: grid;
  gap: 0.5rem;
  max-height: 28rem;
  margin-top: 1rem;
  overflow-y: auto;
  scrollbar-color: var(--accent-deep) transparent;
}

.member-activity-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 0.75rem;
  align-items: center;
  padding: 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 0.8rem;
}

.member-activity-row.online {
  border-color: rgba(104, 177, 132, 0.33);
  background: rgba(104, 177, 132, 0.045);
}

.member-activity-row.online .community-avatar {
  box-shadow: 0 0 0 2px #68b184;
}

.member-identity,
.member-activity-time {
  display: grid;
  gap: 0.2rem;
}

.member-identity strong,
.member-activity-time strong {
  color: var(--paper);
  font-size: 0.78rem;
}

.member-identity span,
.member-activity-time span {
  color: var(--dim);
  font-size: 0.65rem;
}

.member-activity-time {
  justify-items: end;
  text-align: right;
}

.ranking-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.7rem;
  align-items: center;
  padding: 0.65rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.055);
}

.ranking-place {
  color: var(--accent);
  font-family: var(--serif);
}

.ranking-row > div {
  display: grid;
}

.ranking-row strong {
  color: var(--paper);
  font-size: 0.76rem;
}

.ranking-row small,
.ranking-row > span:last-child {
  color: var(--dim);
  font-size: 0.64rem;
}

.announcement-card form {
  display: grid;
  gap: 0.8rem;
  margin-top: 1rem;
}

.announcement-card label {
  display: grid;
  gap: 0.35rem;
  color: var(--muted);
  font-size: 0.72rem;
}

.announcement-actions {
  align-items: center;
}

.announcement-actions .form-status {
  margin: 0;
}

.insights-comment {
  padding: 0.8rem;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 0.75rem;
}

.insights-comment.deleted {
  opacity: 0.55;
}

.insights-comment small {
  color: var(--dim);
  font-size: 0.64rem;
}

.insights-comment p {
  margin: 0.45rem 0 0.65rem;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.5;
  white-space: pre-wrap;
}

.message-identity {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.6rem;
  align-items: center;
}

.message-avatar {
  width: 2rem;
  height: 2rem;
  font-size: 0.58rem;
}

.message-identity .message-head {
  min-width: 0;
}

@media (max-width: 900px) {
  .insight-metrics {
    grid-template-columns: 1fr 1fr;
  }

  .insights-grid {
    grid-template-columns: 1fr;
  }

  .member-presence-card,
  .comments-moderation-card,
  .ranking-card,
  .announcement-card {
    grid-column: 1;
    grid-row: auto;
  }
}

@media (max-width: 640px) {
  #insights-open-button {
    min-height: 2.2rem;
    padding-inline: 0.65rem;
    font-size: 0.68rem;
  }

  .notification-badge {
    position: absolute;
    transform: translate(0.8rem, -0.85rem);
  }

  .control-room-dialog,
  .insights-dialog {
    width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
  }

  .control-room-shell {
    max-height: 100dvh;
    padding: 1rem;
  }

  .profile-visual-editor {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
  }

  .profile-image-actions,
  .story-comments-heading,
  .notifications-toolbar,
  .insights-header,
  .insights-header-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .story-comments {
    margin-top: 4rem;
  }

  .comment-heading-actions {
    align-items: flex-start;
  }

  .story-comment {
    grid-template-columns: 1fr;
  }

  .comment-replies {
    margin-left: 0.75rem;
    padding-left: 0.65rem;
  }

  .story-comment-head {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.25rem;
  }

  .comment-reaction-area {
    align-items: flex-start;
    flex-direction: column;
  }

  .insights-header {
    padding: 1rem;
  }

  .insights-header-actions {
    display: grid;
    grid-template-columns: 1fr auto;
  }

  .insight-metrics {
    grid-template-columns: 1fr 1fr;
  }

  .insight-metrics article {
    min-height: 7rem;
  }

  .member-activity-row {
    grid-template-columns: auto 1fr;
  }

  .member-activity-time {
    grid-column: 2;
    justify-items: start;
    text-align: left;
  }
}
